-
Notifications
You must be signed in to change notification settings - Fork 96
feat: expose id method to wasm #988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3743ad4
feat: expose id method to wasm
mchristopher d20b8a8
fix: fmt and pr changes
mchristopher b90ee35
fix: npm publishing
mchristopher db00502
fix: publish wasm package binary to npm
mchristopher dd270ce
fix: token permissions
mchristopher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| New ID function exports to TypeScript WASM target. |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,3 +14,5 @@ Cargo.lock | |
| .idea | ||
|
|
||
| .history | ||
|
|
||
| .pnpm-store | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,27 +1,52 @@ | ||
| import { wasm } from '@rollup/plugin-wasm' | ||
| import dts from 'rollup-plugin-dts' | ||
| import { copyFileSync } from 'node:fs' | ||
|
|
||
| const sync = ['src/{{NAME_UNDERSCORED}}_bg.wasm']; | ||
|
|
||
| const copyWasm = { | ||
| name: 'copy-wasm', | ||
| writeBundle() { | ||
| copyFileSync('src/{{NAME_UNDERSCORED}}_bg.wasm', 'dist/{{NAME_UNDERSCORED}}_bg.wasm'); | ||
| } | ||
| }; | ||
|
|
||
| export default [ | ||
| { | ||
| plugins: [wasm({ sync, targetEnv: 'auto-inline' })], | ||
| plugins: [wasm({ sync, targetEnv: 'auto' })], | ||
| input: 'src/index.js', | ||
| output: [ | ||
| { file: 'dist/node/index.cjs', format: 'cjs' }, | ||
| ] | ||
| }, { | ||
| plugins: [wasm({ sync, targetEnv: 'auto-inline' })], | ||
| plugins: [wasm({ sync, targetEnv: 'auto' })], | ||
| input: 'src/index.js', | ||
| output: [ | ||
| { file: 'dist/web/index.mjs', format: 'es' }, | ||
| ] | ||
| }, { | ||
| input: 'src/index_slim.js', | ||
| output: [ | ||
| { file: 'dist/slim/index.cjs', format: 'cjs' }, | ||
| ] | ||
| }, { | ||
| plugins: [copyWasm], | ||
| input: 'src/index_slim.js', | ||
| output: [ | ||
| { file: 'dist/slim/index.mjs', format: 'es' }, | ||
| ] | ||
| }, { | ||
| plugins: [dts()], | ||
| input: 'src/{{NAME_UNDERSCORED}}.d.ts', | ||
| input: 'src/index.d.ts', | ||
| output: [ | ||
| { file: 'dist/web/index.d.ts', format: 'es' }, | ||
| { file: 'dist/node/index.d.ts', format: 'es' } | ||
| { file: 'dist/node/index.d.ts', format: 'es' }, | ||
| ], | ||
| }, { | ||
| plugins: [dts()], | ||
| input: 'src/index_slim.d.ts', | ||
| output: [ | ||
| { file: 'dist/slim/index.d.ts', format: 'es' }, | ||
| ], | ||
| } | ||
| ] |
This file contains hidden or 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,9 @@ | ||
| export * from './{{NAME_UNDERSCORED}}.js'; | ||
|
|
||
| export type InitInput = | ||
| | WebAssembly.Module | ||
| | BufferSource | ||
| | Response | ||
| | Promise<Response>; | ||
|
|
||
| export function initWasm(module_or_path?: InitInput): Promise<void>; |
This file contains hidden or 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,14 +1,15 @@ | ||
| import init from './{{NAME_UNDERSCORED}}.js' | ||
| import wasm from './{{NAME_UNDERSCORED}}_bg.wasm' | ||
| import wasmModule from './{{NAME_UNDERSCORED}}_bg.wasm' | ||
|
|
||
| export async function initWasm () { | ||
| return await init({ module_or_path: wasm() }); | ||
| let _initPromise; | ||
|
|
||
| export async function initWasm (module_or_path) { | ||
| if (!_initPromise) { | ||
| _initPromise = init({ module_or_path: module_or_path ?? wasmModule() }); | ||
| } | ||
| return _initPromise; | ||
| } | ||
|
|
||
| /** | ||
| * calling it right away for pre-caching | ||
| * the wasm async initialization at startup | ||
| */ | ||
| initWasm(); | ||
|
|
||
| export * from './{{NAME_UNDERSCORED}}.js' |
This file contains hidden or 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,9 @@ | ||
| export * from './{{NAME_UNDERSCORED}}.js'; | ||
|
|
||
| export type InitInput = | ||
| | WebAssembly.Module | ||
| | BufferSource | ||
| | Response | ||
| | Promise<Response>; | ||
|
|
||
| export function initWasm(module_or_path: InitInput): Promise<void>; |
This file contains hidden or 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,18 @@ | ||
| import init from './{{NAME_UNDERSCORED}}.js' | ||
|
|
||
| let _initPromise; | ||
|
|
||
| export async function initWasm (module_or_path) { | ||
| if (!_initPromise) { | ||
| if (module_or_path == null) { | ||
| throw new Error( | ||
| '@fuels/vm-{{PKG_NAME}}/slim: initWasm() requires a WebAssembly.Module or BufferSource. ' + | ||
| 'Use "@fuels/vm-{{PKG_NAME}}" for automatic WASM loading.' | ||
| ); | ||
| } | ||
| _initPromise = init({ module_or_path }); | ||
| } | ||
| return _initPromise; | ||
| } | ||
|
|
||
| export * from './{{NAME_UNDERSCORED}}.js' |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.