-
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.
WIP: feat(bindgen): Generate typescript demo app
- Loading branch information
Showing
7 changed files
with
460 additions
and
47 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
packages/compress-stringify/typescript/cypress/tsconfig.json
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"include": [ | ||
"**/*.ts" | ||
], | ||
"compilerOptions": { | ||
"noEmit": false, | ||
"sourceMap": false, | ||
"inlineSourceMap": true, | ||
"types": ["cypress"] | ||
}, | ||
} |
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
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,18 +1,30 @@ | ||
import * as <bindgenBundleNameCamelCase> from '../../dist/bundles/<bindgenBundleName>.js' | ||
<bindgenBundleNameCamelCase>.setPipelinesBaseUrl('/pipelines') | ||
import * as @bindgenBundleNameCamelCase@ from '../../dist/bundles/@bindgenBundleName@.js' | ||
|
||
const packageFunctions = [] | ||
for (const [key, val] of Object.entries(<bindgenBundleNameCamelCase>)) { | ||
if (typeof val == 'function') { | ||
packageFunctions.push(key) | ||
} | ||
// Use local, vendored WebAssembly module assets | ||
const pipelinesBaseUrl: string | URL = new URL('/pipelines', document.location.origin).href | ||
@bindgenBundleNameCamelCase@.setPipelinesBaseUrl(pipelinesBaseUrl) | ||
const pipelineWorkerUrl: string | URL | null = new URL('/web-workers/pipeline.worker.js', document.location.origin).href | ||
@bindgenBundleNameCamelCase@.setPipelineWorkerUrl(pipelineWorkerUrl) | ||
|
||
|
||
// ------------------------------------------------------------------------------------ | ||
// Utilities | ||
|
||
function downloadFile(content, filename) { | ||
const url = URL.createObjectURL(new Blob([content])) | ||
const a = document.createElement('a') | ||
a.href = url | ||
a.download = filename || 'download' | ||
document.body.appendChild(a) | ||
function clickHandler(event) { | ||
setTimeout(() => { | ||
URL.revokeObjectURL(url) | ||
a.removeEventListener('click', clickHandler) | ||
}, 200) | ||
}; | ||
a.addEventListener('click', clickHandler, false) | ||
a.click() | ||
return a | ||
} | ||
|
||
const pipelineFunctionsList = document.getElementById('pipeline-functions-list') | ||
pipelineFunctionsList.innerHTML = ` | ||
<li> | ||
${packageFunctions.join('</li>\n<li>')} | ||
</li> | ||
` | ||
console.log(packageFunctions) | ||
console.log(<bindgenBundleNameCamelCase>) | ||
@bindgenFunctionLogic@ |
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
Oops, something went wrong.