-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #930 from thewtex/demo-prerun
perf: support demo pre-runs
- Loading branch information
Showing
21 changed files
with
457 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ export default null | |
|
||
// return model | ||
// } | ||
|
||
export const usePreRun = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 23 additions & 11 deletions
34
...press-stringify/typescript/test/browser/demo-app/compress-stringify-load-sample-inputs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
export default async function compressStringifyLoadSampleInputs (model) { | ||
export default async function compressStringifyLoadSampleInputs (model, preRun=false) { | ||
const sampleInput = new Uint8Array([222, 173, 190, 239]) | ||
model.inputs.set("input", sampleInput) | ||
const inputElement = document.getElementById("compressStringify-input-details") | ||
inputElement.innerHTML = `<pre>${globalThis.escapeHtml(sampleInput.toString())}</pre>` | ||
inputElement.disabled = false | ||
if (!preRun) { | ||
const inputElement = document.getElementById("compressStringify-input-details") | ||
inputElement.innerHTML = `<pre>${globalThis.escapeHtml(sampleInput.toString())}</pre>` | ||
inputElement.disabled = false | ||
} | ||
|
||
const stringify = true | ||
model.options.set("stringify", stringify) | ||
const stringifyElement = document.querySelector('#compressStringifyInputs sl-checkbox[name=stringify]') | ||
stringifyElement.checked = stringify | ||
if (!preRun) { | ||
const stringifyElement = document.querySelector('#compressStringifyInputs sl-checkbox[name=stringify]') | ||
stringifyElement.checked = stringify | ||
} | ||
|
||
const compressionLevel = 5 | ||
model.options.set("compressionLevel", compressionLevel) | ||
const compressionLevelElement = document.querySelector('#compressStringifyInputs sl-input[name=compression-level]') | ||
compressionLevelElement.value = compressionLevel | ||
if (!preRun) { | ||
const compressionLevelElement = document.querySelector('#compressStringifyInputs sl-input[name=compression-level]') | ||
compressionLevelElement.value = compressionLevel | ||
} | ||
|
||
const dataUrlPrefix = 'data:application/iwi+cbor+zstd;base64,' | ||
model.options.set("dataUrlPrefix", dataUrlPrefix) | ||
const dataUrlPrefixElement = document.querySelector('#compressStringifyInputs sl-input[name=data-url-prefix]') | ||
dataUrlPrefixElement.value = dataUrlPrefix | ||
} | ||
if (!preRun) { | ||
const dataUrlPrefixElement = document.querySelector('#compressStringifyInputs sl-input[name=data-url-prefix]') | ||
dataUrlPrefixElement.value = dataUrlPrefix | ||
} | ||
|
||
return model | ||
} | ||
|
||
export const usePreRun = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 15 additions & 9 deletions
24
...-stringify/typescript/test/browser/demo-app/parse-string-decompress-load-sample-inputs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
export default async function parseStringDecompressLoadSampleInputs (context) { | ||
export default async function parseStringDecompressLoadSampleInputs (model, preRun=false) { | ||
// const sampleInput = TextDecoder().decode('data:application/iwi+cbor+zstd;base64,KLUv/SAEIQAA3q2+7w==') | ||
const sampleInput = new Uint8Array([100,97,116,97,58,97,112,112,108,105,99,97,116,105,111,110,47,105,119,105,43,99,98,111,114,43,122,115,116,100,59,98,97,115,101,54,52,44,75,76,85,118,47,83,65,69,73,81,65,65,51,113,50,43,55,119,61,61]) | ||
context.inputs.set("input", sampleInput) | ||
const inputElement = document.getElementById("parseStringDecompress-input-details") | ||
inputElement.innerHTML = `<pre>${globalThis.escapeHtml(sampleInput.toString())}</pre>` | ||
inputElement.disabled = false | ||
model.inputs.set("input", sampleInput) | ||
if (!preRun) { | ||
const inputElement = document.getElementById("parseStringDecompress-input-details") | ||
inputElement.innerHTML = `<pre>${globalThis.escapeHtml(sampleInput.toString())}</pre>` | ||
inputElement.disabled = false | ||
} | ||
|
||
const parseString = true | ||
context.options.set("parseString", parseString) | ||
const parseStringElement = document.querySelector('#parseStringDecompressInputs sl-checkbox[name=parse-string]') | ||
parseStringElement.checked = parseString | ||
} | ||
model.options.set("parseString", parseString) | ||
if (!preRun) { | ||
const parseStringElement = document.querySelector('#parseStringDecompressInputs sl-checkbox[name=parse-string]') | ||
parseStringElement.checked = parseString | ||
} | ||
} | ||
|
||
export const usePreRun = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 20 additions & 10 deletions
30
.../typescript/test/browser/demo-app/apply-presentation-state-to-image-load-sample-inputs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
export default async function applyPresentationStateToImageLoadSampleInputs (model) { | ||
export default async function applyPresentationStateToImageLoadSampleInputs (model, preRun=false) { | ||
const imageInButton = document.querySelector('#applyPresentationStateToImageInputs sl-button[name=image-in-file-button]') | ||
imageInButton.loading = true | ||
if (!preRun) { | ||
imageInButton.loading = true | ||
} | ||
const imageInReponse = await fetch('https://bafybeihmnqsufckyjxt2z3yunppqggtq2rle7fta27rbetmf7fgviytghi.ipfs.w3s.link/ipfs/bafybeihmnqsufckyjxt2z3yunppqggtq2rle7fta27rbetmf7fgviytghi/input/gsps-pstate-test-input-image.dcm') | ||
const imageInData = new Uint8Array(await imageInReponse.arrayBuffer()) | ||
model.inputs.set('imageIn', { data: imageInData, path: 'gsps-pstate-test-input-image.dcm' }) | ||
const imageInElement = document.getElementById('applyPresentationStateToImage-image-in-details') | ||
imageInElement.innerHTML = `<pre>${globalThis.escapeHtml(imageInData.subarray(0, 50).toString())}</pre>` | ||
imageInElement.disabled = false | ||
imageInButton.loading = false | ||
if (!preRun) { | ||
imageInElement.innerHTML = `<pre>${globalThis.escapeHtml(imageInData.subarray(0, 50).toString())}</pre>` | ||
imageInElement.disabled = false | ||
imageInButton.loading = false | ||
} | ||
|
||
const pstateButton = document.querySelector('#applyPresentationStateToImageInputs sl-button[name=presentation-state-file-file-button]') | ||
pstateButton.loading = true | ||
if (!preRun) { | ||
pstateButton.loading = true | ||
} | ||
const pstateReponse = await fetch('https://bafybeihmnqsufckyjxt2z3yunppqggtq2rle7fta27rbetmf7fgviytghi.ipfs.w3s.link/ipfs/bafybeihmnqsufckyjxt2z3yunppqggtq2rle7fta27rbetmf7fgviytghi/input/gsps-pstate-test-input-pstate.dcm') | ||
const pstateData = new Uint8Array(await pstateReponse.arrayBuffer()) | ||
model.inputs.set('presentationStateFile', { data: pstateData, path: 'gsps-pstate-test-input-pstate.dcm' }) | ||
const pstateElement = document.getElementById('applyPresentationStateToImage-presentation-state-file-details') | ||
pstateElement.innerHTML = `<pre>${globalThis.escapeHtml(pstateData.subarray(0, 50).toString())}</pre>` | ||
pstateElement.disabled = false | ||
pstateButton.loading = false | ||
if (!preRun) { | ||
const pstateElement = document.getElementById('applyPresentationStateToImage-presentation-state-file-details') | ||
pstateElement.innerHTML = `<pre>${globalThis.escapeHtml(pstateData.subarray(0, 50).toString())}</pre>` | ||
pstateElement.disabled = false | ||
pstateButton.loading = false | ||
} | ||
|
||
return model | ||
} | ||
|
||
export const usePreRun = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.