feat(cli): support generate browser compatible codes (#1891)

This commit is contained in:
LongYinan 2024-01-08 21:02:46 +08:00 committed by GitHub
parent ecde07f8c1
commit 7d3b53d41d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 3690 additions and 282 deletions

View file

@ -16,4 +16,6 @@ triples/index.js
rollup.config.js
crates/cli/index.js
examples/napi/index.wasi.mjs
examples/napi/index.wasi-browser.js
examples/napi/wasi-worker.mjs
examples/napi/wasi-worker-browser.js

View file

@ -479,16 +479,15 @@ jobs:
run: cargo check -p ${{ matrix.settings.package }} -F ${{ matrix.settings.features }}
test-node-wasi:
runs-on: ubuntu-latest
runs-on: macos-latest
name: Test node wasi target
timeout-minutes: 10
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'yarn'
- name: Install
uses: dtolnay/rust-toolchain@stable
@ -502,7 +501,7 @@ jobs:
~/.cargo/registry
~/.cargo/git
target
key: stable-wasm32-wasi-preview1-threads-node@18-cargo-cache
key: stable-wasm32-wasi-preview1-threads-node@20-cargo-cache
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: Build
@ -514,6 +513,8 @@ jobs:
env:
WASI_TEST: 'true'
NODE_OPTIONS: '--max-old-space-size=8192'
- name: Browser test
run: yarn workspace @examples/napi vitest
test-latest-bun:
runs-on: ubuntu-latest

View file

@ -96,8 +96,16 @@ export async function collectArtifacts(userOptions: ArtifactsOptions) {
options.buildOutputDir ?? options.cwd,
`wasi-worker.mjs`,
)
const browserEntry = join(
options.buildOutputDir ?? options.cwd,
`${binaryName}.wasi-browser.js`,
)
const browserWorkerFile = join(
options.buildOutputDir ?? options.cwd,
`wasi-worker-browser.js`,
)
debug.info(
`Move wasi cjs file [${colors.yellowBright(
`Move wasi binding file [${colors.yellowBright(
cjsFile,
)}] to [${colors.yellowBright(wasiDir)}]`,
)
@ -114,6 +122,24 @@ export async function collectArtifacts(userOptions: ArtifactsOptions) {
join(wasiDir, `wasi-worker.mjs`),
await readFileAsync(workerFile),
)
debug.info(
`Move wasi browser entry file [${colors.yellowBright(
browserEntry,
)}] to [${colors.yellowBright(wasiDir)}]`,
)
await writeFileAsync(
join(wasiDir, `${binaryName}.wasi-browser.js`),
await readFileAsync(browserEntry),
)
debug.info(
`Move wasi browser worker file [${colors.yellowBright(
browserWorkerFile,
)}] to [${colors.yellowBright(wasiDir)}]`,
)
await writeFileAsync(
join(wasiDir, `wasi-worker-browser.js`),
await readFileAsync(browserWorkerFile),
)
}
}

View file

@ -32,8 +32,14 @@ import {
} from '../utils/index.js'
import { createCjsBinding } from './templates/index.js'
import { createWasiBinding } from './templates/load-wasi-template.js'
import { WASI_WORKER_TEMPLATE } from './templates/wasi-worker-template.js'
import {
createWasiBinding,
createWasiBrowserBinding,
} from './templates/load-wasi-template.js'
import {
WASI_WORKER_BROWSER_TEMPLATE,
WASI_WORKER_TEMPLATE,
} from './templates/wasi-worker-template.js'
const debug = debugFactory('build')
const require = createRequire(import.meta.url)
@ -635,7 +641,7 @@ class Builder {
})()
: []
const jsOutput = await this.writeJsBinding(idents)
const wasmOutput = await this.writeWasiBinding(
const wasmBindingsOutput = await this.writeWasiBinding(
wasiRegisterFunctions,
dest ?? 'index.wasm',
idents,
@ -643,8 +649,8 @@ class Builder {
if (jsOutput) {
this.outputs.push(jsOutput)
}
if (wasmOutput) {
this.outputs.push(wasmOutput)
if (wasmBindingsOutput) {
this.outputs.push(...wasmBindingsOutput)
}
}
@ -790,15 +796,20 @@ class Builder {
) {
if (distFileName && wasiRegisterFunctions.length) {
const { name, dir } = parse(distFileName)
const newPath = join(dir, `${this.config.binaryName}.wasi.cjs`)
const bindingPath = join(dir, `${this.config.binaryName}.wasi.cjs`)
const browserBindingPath = join(
dir,
`${this.config.binaryName}.wasi-browser.js`,
)
const workerPath = join(dir, 'wasi-worker.mjs')
const browserWorkerPath = join(dir, 'wasi-worker-browser.mjs')
const exportsCode = idents
.map(
(ident) => `module.exports.${ident} = __napiModule.exports.${ident}`,
)
.join(',\n')
.join('\n')
await writeFileAsync(
newPath,
bindingPath,
createWasiBinding(
name,
this.config.packageName,
@ -808,12 +819,43 @@ class Builder {
'\n',
'utf8',
)
await writeFileAsync(
browserBindingPath,
createWasiBrowserBinding(name, wasiRegisterFunctions) +
idents
.map(
(ident) =>
`export const ${ident} = __napiModule.exports.${ident}`,
)
.join('\n') +
'\n',
'utf8',
)
await writeFileAsync(workerPath, WASI_WORKER_TEMPLATE, 'utf8')
return {
kind: 'wasm',
path: newPath,
} satisfies Output
await writeFileAsync(
browserWorkerPath,
WASI_WORKER_BROWSER_TEMPLATE,
'utf8',
)
return [
{
kind: 'js',
path: bindingPath,
},
{
kind: 'js',
path: browserBindingPath,
},
{
kind: 'js',
path: workerPath,
},
{
kind: 'js',
path: browserWorkerPath,
},
] satisfies Output[]
}
return null
return []
}
}

View file

@ -90,6 +90,8 @@ export async function createNpmDirs(userOptions: CreateNpmDirsOptions) {
const entry = `${binaryName}.wasi.cjs`
scopedPackageJson.files.push(entry, `wasi-worker.mjs`)
scopedPackageJson.main = entry
// @ts-expect-error
scopedPackageJson.browser = `${binaryName}.wasi-browser.js`
let needRestrictNodeVersion = true
if (scopedPackageJson.engines?.node) {
try {
@ -114,10 +116,18 @@ export async function createNpmDirs(userOptions: CreateNpmDirsOptions) {
const emnapiRuntime = await fetch(
`https://registry.npmjs.org/@emnapi/runtime`,
).then((res) => res.json() as Promise<PackageMeta>)
const wasiUtil = await fetch(
`https://registry.npmjs.org/@tybys/wasm-util`,
).then((res) => res.json() as Promise<PackageMeta>)
const memfsBrowser = await fetch(
`https://registry.npmjs.org/memfs-browser`,
).then((res) => res.json() as Promise<PackageMeta>)
// @ts-expect-error
scopedPackageJson.dependencies = {
'@emnapi/core': `^${emnapiCore['dist-tags'].latest}`,
'@emnapi/runtime': `^${emnapiRuntime['dist-tags'].latest}`,
'@tybys/wasm-util': `^${wasiUtil['dist-tags'].latest}`,
'memfs-browser': `^${memfsBrowser['dist-tags'].latest}`,
}
}
@ -137,7 +147,7 @@ export async function createNpmDirs(userOptions: CreateNpmDirsOptions) {
const targetReadme = join(targetDir, 'README.md')
await writeFileAsync(targetReadme, readme(packageName, target))
debug.info(`${packageName}-${target.platformArchABI} created`)
debug.info(`${packageName} -${target.platformArchABI} created`)
}
}

View file

@ -170,7 +170,7 @@ jobs:
with:
operating_system: freebsd
version: '13.2'
memory: 13G
memory: 8G
cpu_count: 3
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
shell: bash

View file

@ -1,3 +1,68 @@
export const createWasiBrowserBinding = (
wasiFilename: string,
wasiRegisterFunctions: string[],
) => `import { instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync } from '@emnapi/core'
import { getDefaultContext as __emnapiGetDefaultContext } from '@emnapi/runtime'
import { WASI as __WASI } from '@tybys/wasm-util'
import { Volume as __Volume, createFsFromVolume as __createFsFromVolume } from 'memfs-browser'
import __wasmUrl from './${wasiFilename}.wasm?url'
const __fs = __createFsFromVolume(
__Volume.fromJSON({
'/': null,
}),
)
const __wasi = new __WASI({
version: 'preview1',
fs: __fs,
})
const __emnapiContext = __emnapiGetDefaultContext()
const __sharedMemory = new WebAssembly.Memory({
initial: 1024,
maximum: 10240,
shared: true,
})
let __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
const {
instance: __napiInstance,
module: __wasiModule,
napiModule: __napiModule,
} = __emnapiInstantiateNapiModuleSync(__wasmFile, {
context: __emnapiContext,
asyncWorkPoolSize: 4,
wasi: __wasi,
onCreateWorker() {
return new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
type: 'module',
})
},
overwriteImports(importObject) {
importObject.env = {
...importObject.env,
...importObject.napi,
...importObject.emnapi,
memory: __sharedMemory,
}
return importObject
},
beforeInit({ instance }) {
__napi_rs_initialize_modules(instance)
},
})
function __napi_rs_initialize_modules(__napiInstance) {
${wasiRegisterFunctions
.map((name) => ` __napiInstance.exports['${name}']?.()`)
.join('\n')}
}
`
export const createWasiBinding = (
wasmFileName: string,
packageName: string,

View file

@ -50,3 +50,37 @@ globalThis.onmessage = function (e) {
handler.handle(e);
};
`
export const WASI_WORKER_BROWSER_TEMPLATE = `import { instantiateNapiModuleSync, MessageHandler } from '@emnapi/core'
import { WASI } from '@tybys/wasm-util'
import { Volume, createFsFromVolume } from 'memfs-browser'
const fs = createFsFromVolume(Volume.fromJSON({
'/': null
}))
const handler = new MessageHandler({
onLoad({ wasmModule, wasmMemory }) {
const wasi = new WASI({
fs,
print: function() { console.log.apply(console, arguments) }
})
return instantiateNapiModuleSync(wasmModule, {
childThread: true,
wasi,
overwriteImports(importObject) {
importObject.env = {
...importObject.env,
...importObject.napi,
...importObject.emnapi,
memory: wasmMemory
}
}
})
}
})
globalThis.onmessage = function(e) {
handler.handle(e)
}
`

View file

@ -11,9 +11,16 @@ Generated by [AVA](https://avajs.dev).
[
'@napi-rs/cli',
'@types/lodash',
'@vitest/browser',
'@vitest/ui',
'ava',
'cross-env',
'electron',
'lodash',
'memfs-browser',
'sinon',
'vite',
'vite-plugin-node-polyfills',
'vitest',
'webdriverio',
]

View file

@ -0,0 +1,56 @@
import { describe, it, expect } from 'vitest'
// @ts-expect-error
const {
DEFAULT_COST,
Bird,
GetterSetterWithClosures,
tsfnReturnPromise,
tsfnReturnPromiseTimeout,
}: typeof import('../index') = await import('../index.wasi-browser')
describe('NAPI-RS wasi browser test', function () {
it('DEFAULT_COST', function () {
expect(DEFAULT_COST).toBe(12)
})
it('async self in class', async function () {
const b = new Bird('foo')
expect(await b.getNameAsync()).toBe('foo')
})
it('Class with getter setter closures', () => {
const instance = new GetterSetterWithClosures()
// @ts-expect-error
instance.name = 'Allie'
// @ts-expect-error
expect(instance.name).toBe(`I'm Allie`)
// @ts-expect-error
expect(instance.age).toBe(0.3)
})
it('threadsafe function return Promise and await in Rust', async () => {
const value = await tsfnReturnPromise((err, value) => {
if (err) {
throw err
}
return Promise.resolve(value + 2)
})
expect(value).toBe(5)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
expect(
tsfnReturnPromiseTimeout((err, value) => {
if (err) {
throw err
}
return new Promise((resolve) => {
setTimeout(() => {
resolve(value + 2)
}, 300)
})
}),
).rejects.toMatchObject(new Error('Timeout'))
// trigger Promise.then in Rust after `Promise` is dropped
await new Promise((resolve) => setTimeout(resolve, 400))
})
})

15
examples/napi/index.html Normal file
View file

@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/png" href="https://napi.rs/img/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>NAPI-RS examples playground</title>
</head>
<body>
<div id="app" />
</body>
</html>

View file

@ -0,0 +1,548 @@
import { instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync } from '@emnapi/core'
import { getDefaultContext as __emnapiGetDefaultContext } from '@emnapi/runtime'
import { WASI as __WASI } from '@tybys/wasm-util'
import {
Volume as __Volume,
createFsFromVolume as __createFsFromVolume,
} from 'memfs-browser'
import __wasmUrl from './index.wasm?url'
const __fs = __createFsFromVolume(
__Volume.fromJSON({
'/': null,
}),
)
const __wasi = new __WASI({
version: 'preview1',
fs: __fs,
})
const __emnapiContext = __emnapiGetDefaultContext()
const __sharedMemory = new WebAssembly.Memory({
initial: 1024,
maximum: 10240,
shared: true,
})
let __wasmFile = await fetch(__wasmUrl).then((res) => res.arrayBuffer())
const {
instance: __napiInstance,
module: __wasiModule,
napiModule: __napiModule,
} = __emnapiInstantiateNapiModuleSync(__wasmFile, {
context: __emnapiContext,
asyncWorkPoolSize: 4,
wasi: __wasi,
onCreateWorker() {
return new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
type: 'module',
})
},
overwriteImports(importObject) {
importObject.env = {
...importObject.env,
...importObject.napi,
...importObject.emnapi,
memory: __sharedMemory,
}
return importObject
},
beforeInit({ instance }) {
__napi_rs_initialize_modules(instance)
},
})
function __napi_rs_initialize_modules(__napiInstance) {
__napiInstance.exports['__napi_register__Shared_struct_0']?.()
__napiInstance.exports['__napi_register__DEFAULT_COST_0']?.()
__napiInstance.exports['__napi_register__TYPE_SKIPPED_CONST_1']?.()
__napiInstance.exports['__napi_register__get_words_2']?.()
__napiInstance.exports['__napi_register__get_nums_3']?.()
__napiInstance.exports['__napi_register__sum_nums_4']?.()
__napiInstance.exports['__napi_register__to_js_obj_5']?.()
__napiInstance.exports['__napi_register__get_num_arr_6']?.()
__napiInstance.exports['__napi_register__get_nested_num_arr_7']?.()
__napiInstance.exports['__napi_register__read_file_async_8']?.()
__napiInstance.exports['__napi_register__async_multi_two_9']?.()
__napiInstance.exports['__napi_register__bigint_add_10']?.()
__napiInstance.exports['__napi_register__create_big_int_11']?.()
__napiInstance.exports['__napi_register__create_big_int_i64_12']?.()
__napiInstance.exports['__napi_register__bigint_get_u64_as_string_13']?.()
__napiInstance.exports['__napi_register__bigint_from_i64_14']?.()
__napiInstance.exports['__napi_register__bigint_from_i128_15']?.()
__napiInstance.exports['__napi_register__get_cwd_16']?.()
__napiInstance.exports['__napi_register__option_end_17']?.()
__napiInstance.exports['__napi_register__option_start_18']?.()
__napiInstance.exports['__napi_register__option_start_end_19']?.()
__napiInstance.exports['__napi_register__option_only_20']?.()
__napiInstance.exports['__napi_register__read_file_21']?.()
__napiInstance.exports['__napi_register__return_js_function_22']?.()
__napiInstance.exports['__napi_register__callback_return_promise_23']?.()
__napiInstance.exports[
'__napi_register__callback_return_promise_and_spawn_24'
]?.()
__napiInstance.exports['__napi_register__capture_error_in_callback_25']?.()
__napiInstance.exports['__napi_register__Animal_struct_26']?.()
__napiInstance.exports['__napi_register__Animal_impl_38']?.()
__napiInstance.exports['__napi_register__Dog_struct_39']?.()
__napiInstance.exports['__napi_register__Bird_struct_40']?.()
__napiInstance.exports['__napi_register__Bird_impl_44']?.()
__napiInstance.exports['__napi_register__Blake2bHasher_struct_45']?.()
__napiInstance.exports['__napi_register__Blake2bHasher_impl_47']?.()
__napiInstance.exports['__napi_register__Blake2bHasher_impl_49']?.()
__napiInstance.exports['__napi_register__Blake2bKey_struct_50']?.()
__napiInstance.exports['__napi_register__Context_struct_51']?.()
__napiInstance.exports['__napi_register__Context_impl_56']?.()
__napiInstance.exports[
'__napi_register__AnimalWithDefaultConstructor_struct_57'
]?.()
__napiInstance.exports['__napi_register__NinjaTurtle_struct_58']?.()
__napiInstance.exports['__napi_register__NinjaTurtle_impl_65']?.()
__napiInstance.exports['__napi_register__JsAssets_struct_66']?.()
__napiInstance.exports['__napi_register__JsAssets_impl_69']?.()
__napiInstance.exports['__napi_register__JsAsset_struct_70']?.()
__napiInstance.exports['__napi_register__JsAsset_impl_73']?.()
__napiInstance.exports['__napi_register__Optional_struct_74']?.()
__napiInstance.exports['__napi_register__Optional_impl_79']?.()
__napiInstance.exports[
'__napi_register__ObjectFieldClassInstance_struct_80'
]?.()
__napiInstance.exports[
'__napi_register__create_object_with_class_field_81'
]?.()
__napiInstance.exports[
'__napi_register__receive_object_with_class_field_82'
]?.()
__napiInstance.exports['__napi_register__NotWritableClass_struct_83']?.()
__napiInstance.exports['__napi_register__NotWritableClass_impl_85']?.()
__napiInstance.exports['__napi_register__CustomFinalize_struct_86']?.()
__napiInstance.exports['__napi_register__CustomFinalize_impl_88']?.()
__napiInstance.exports['__napi_register__Width_struct_89']?.()
__napiInstance.exports['__napi_register__plus_one_90']?.()
__napiInstance.exports[
'__napi_register__GetterSetterWithClosures_struct_91'
]?.()
__napiInstance.exports[
'__napi_register__GetterSetterWithClosures_impl_93'
]?.()
__napiInstance.exports['__napi_register__CatchOnConstructor_struct_94']?.()
__napiInstance.exports['__napi_register__CatchOnConstructor_impl_96']?.()
__napiInstance.exports['__napi_register__CatchOnConstructor2_struct_97']?.()
__napiInstance.exports['__napi_register__CatchOnConstructor2_impl_99']?.()
__napiInstance.exports['__napi_register__ClassWithFactory_struct_100']?.()
__napiInstance.exports['__napi_register__ClassWithFactory_impl_105']?.()
__napiInstance.exports['__napi_register__Selector_struct_106']?.()
__napiInstance.exports['__napi_register__date_to_number_107']?.()
__napiInstance.exports['__napi_register__chrono_date_to_millis_108']?.()
__napiInstance.exports['__napi_register__chrono_date_add_1_minute_109']?.()
__napiInstance.exports['__napi_register__Dates_struct_110']?.()
__napiInstance.exports['__napi_register__chrono_native_date_time_111']?.()
__napiInstance.exports[
'__napi_register__chrono_native_date_time_return_112'
]?.()
__napiInstance.exports['__napi_register__either_string_or_number_113']?.()
__napiInstance.exports['__napi_register__return_either_114']?.()
__napiInstance.exports['__napi_register__either3_115']?.()
__napiInstance.exports['__napi_register__Obj_struct_116']?.()
__napiInstance.exports['__napi_register__either4_117']?.()
__napiInstance.exports['__napi_register__JsClassForEither_struct_118']?.()
__napiInstance.exports['__napi_register__JsClassForEither_impl_120']?.()
__napiInstance.exports[
'__napi_register__AnotherClassForEither_struct_121'
]?.()
__napiInstance.exports['__napi_register__AnotherClassForEither_impl_123']?.()
__napiInstance.exports['__napi_register__receive_class_or_number_124']?.()
__napiInstance.exports['__napi_register__receive_mut_class_or_number_125']?.()
__napiInstance.exports['__napi_register__receive_different_class_126']?.()
__napiInstance.exports['__napi_register__return_either_class_127']?.()
__napiInstance.exports['__napi_register__either_from_option_128']?.()
__napiInstance.exports['__napi_register__A_struct_129']?.()
__napiInstance.exports['__napi_register__B_struct_130']?.()
__napiInstance.exports['__napi_register__C_struct_131']?.()
__napiInstance.exports['__napi_register__either_from_objects_132']?.()
__napiInstance.exports['__napi_register__either_bool_or_function_133']?.()
__napiInstance.exports['__napi_register__promise_in_either_134']?.()
__napiInstance.exports['__napi_register__Kind_135']?.()
__napiInstance.exports['__napi_register__Empty_136']?.()
__napiInstance.exports['__napi_register__Status_137']?.()
__napiInstance.exports['__napi_register__CustomNumEnum_138']?.()
__napiInstance.exports['__napi_register__enum_to_i32_139']?.()
__napiInstance.exports['__napi_register__SkippedEnums_140']?.()
__napiInstance.exports['__napi_register__run_script_141']?.()
__napiInstance.exports['__napi_register__get_module_file_name_142']?.()
__napiInstance.exports['__napi_register__throw_syntax_error_143']?.()
__napiInstance.exports['__napi_register__throw_error_144']?.()
__napiInstance.exports['__napi_register__panic_145']?.()
__napiInstance.exports['__napi_register__receive_string_146']?.()
__napiInstance.exports['__napi_register__custom_status_code_147']?.()
__napiInstance.exports['__napi_register__throw_async_error_148']?.()
__napiInstance.exports['__napi_register__create_external_149']?.()
__napiInstance.exports['__napi_register__create_external_string_150']?.()
__napiInstance.exports['__napi_register__get_external_151']?.()
__napiInstance.exports['__napi_register__mutate_external_152']?.()
__napiInstance.exports['__napi_register__validate_array_153']?.()
__napiInstance.exports['__napi_register__validate_buffer_154']?.()
__napiInstance.exports['__napi_register__validate_typed_array_155']?.()
__napiInstance.exports['__napi_register__validate_bigint_156']?.()
__napiInstance.exports['__napi_register__validate_boolean_157']?.()
__napiInstance.exports['__napi_register__validate_date_158']?.()
__napiInstance.exports['__napi_register__validate_date_time_159']?.()
__napiInstance.exports['__napi_register__validate_external_160']?.()
__napiInstance.exports['__napi_register__validate_function_161']?.()
__napiInstance.exports['__napi_register__validate_hash_map_162']?.()
__napiInstance.exports['__napi_register__validate_null_163']?.()
__napiInstance.exports['__napi_register__validate_undefined_164']?.()
__napiInstance.exports['__napi_register__validate_number_165']?.()
__napiInstance.exports['__napi_register__validate_promise_166']?.()
__napiInstance.exports['__napi_register__validate_string_167']?.()
__napiInstance.exports['__napi_register__validate_symbol_168']?.()
__napiInstance.exports['__napi_register__validate_optional_169']?.()
__napiInstance.exports['__napi_register__return_undefined_if_invalid_170']?.()
__napiInstance.exports[
'__napi_register__return_undefined_if_invalid_promise_171'
]?.()
__napiInstance.exports['__napi_register__ts_rename_172']?.()
__napiInstance.exports[
'__napi_register__override_individual_arg_on_function_173'
]?.()
__napiInstance.exports[
'__napi_register__override_individual_arg_on_function_with_cb_arg_174'
]?.()
__napiInstance.exports['__napi_register__Fib_struct_175']?.()
__napiInstance.exports['__napi_register__Fib_impl_176']?.()
__napiInstance.exports['__napi_register__Fib_impl_178']?.()
__napiInstance.exports['__napi_register__Fib2_struct_179']?.()
__napiInstance.exports['__napi_register__Fib2_impl_180']?.()
__napiInstance.exports['__napi_register__Fib2_impl_182']?.()
__napiInstance.exports['__napi_register__Fib3_struct_183']?.()
__napiInstance.exports['__napi_register__Fib3_impl_184']?.()
__napiInstance.exports['__napi_register__ALIGNMENT_185']?.()
__napiInstance.exports['__napi_register__xxh64_186']?.()
__napiInstance.exports['__napi_register__xxh128_187']?.()
__napiInstance.exports['__napi_register__Xxh3_struct_188']?.()
__napiInstance.exports['__napi_register__Xxh3_impl_192']?.()
__napiInstance.exports['__napi_register__xxh2_plus_193']?.()
__napiInstance.exports['__napi_register__xxh3_xxh64_alias_194']?.()
__napiInstance.exports['__napi_register__xxh64_alias_195']?.()
__napiInstance.exports['__napi_register__get_mapping_196']?.()
__napiInstance.exports['__napi_register__sum_mapping_197']?.()
__napiInstance.exports['__napi_register__map_option_198']?.()
__napiInstance.exports['__napi_register__return_null_199']?.()
__napiInstance.exports['__napi_register__return_undefined_200']?.()
__napiInstance.exports['__napi_register__add_201']?.()
__napiInstance.exports['__napi_register__fibonacci_202']?.()
__napiInstance.exports['__napi_register__list_obj_keys_203']?.()
__napiInstance.exports['__napi_register__create_obj_204']?.()
__napiInstance.exports['__napi_register__get_global_205']?.()
__napiInstance.exports['__napi_register__get_undefined_206']?.()
__napiInstance.exports['__napi_register__get_null_207']?.()
__napiInstance.exports['__napi_register__AllOptionalObject_struct_208']?.()
__napiInstance.exports['__napi_register__receive_all_optional_object_209']?.()
__napiInstance.exports['__napi_register__AliasedEnum_210']?.()
__napiInstance.exports[
'__napi_register__StructContainsAliasedEnum_struct_211'
]?.()
__napiInstance.exports['__napi_register__fn_received_aliased_212']?.()
__napiInstance.exports['__napi_register__StrictObject_struct_213']?.()
__napiInstance.exports['__napi_register__receive_strict_object_214']?.()
__napiInstance.exports['__napi_register__get_str_from_object_215']?.()
__napiInstance.exports['__napi_register__TsTypeChanged_struct_216']?.()
__napiInstance.exports['__napi_register__create_obj_with_property_217']?.()
__napiInstance.exports['__napi_register__getter_from_obj_218']?.()
__napiInstance.exports['__napi_register__ObjectOnlyFromJs_struct_219']?.()
__napiInstance.exports['__napi_register__receive_object_only_from_js_220']?.()
__napiInstance.exports['__napi_register__async_plus_100_221']?.()
__napiInstance.exports['__napi_register__JsRepo_struct_222']?.()
__napiInstance.exports['__napi_register__JsRepo_impl_225']?.()
__napiInstance.exports['__napi_register__JsRemote_struct_226']?.()
__napiInstance.exports['__napi_register__JsRemote_impl_228']?.()
__napiInstance.exports['__napi_register__CSSRuleList_struct_229']?.()
__napiInstance.exports['__napi_register__CSSRuleList_impl_233']?.()
__napiInstance.exports['__napi_register__CSSStyleSheet_struct_234']?.()
__napiInstance.exports['__napi_register__AnotherCSSStyleSheet_struct_235']?.()
__napiInstance.exports['__napi_register__AnotherCSSStyleSheet_impl_237']?.()
__napiInstance.exports['__napi_register__CSSStyleSheet_impl_241']?.()
__napiInstance.exports['__napi_register__PackageJson_struct_242']?.()
__napiInstance.exports['__napi_register__read_package_json_243']?.()
__napiInstance.exports['__napi_register__get_package_json_name_244']?.()
__napiInstance.exports['__napi_register__test_serde_roundtrip_245']?.()
__napiInstance.exports[
'__napi_register__test_serde_big_number_precision_246'
]?.()
__napiInstance.exports['__napi_register__return_from_shared_crate_247']?.()
__napiInstance.exports['__napi_register__contains_248']?.()
__napiInstance.exports['__napi_register__concat_str_249']?.()
__napiInstance.exports['__napi_register__concat_utf16_250']?.()
__napiInstance.exports['__napi_register__concat_latin1_251']?.()
__napiInstance.exports['__napi_register__roundtrip_str_252']?.()
__napiInstance.exports['__napi_register__set_symbol_in_obj_253']?.()
__napiInstance.exports['__napi_register__create_symbol_254']?.()
__napiInstance.exports['__napi_register__create_symbol_for_255']?.()
__napiInstance.exports['__napi_register__DelaySum_impl_256']?.()
__napiInstance.exports['__napi_register__without_abort_controller_257']?.()
__napiInstance.exports['__napi_register__with_abort_controller_258']?.()
__napiInstance.exports['__napi_register__AsyncTaskVoidReturn_impl_259']?.()
__napiInstance.exports['__napi_register__async_task_void_return_260']?.()
__napiInstance.exports[
'__napi_register__AsyncTaskOptionalReturn_impl_261'
]?.()
__napiInstance.exports['__napi_register__async_task_optional_return_262']?.()
__napiInstance.exports['__napi_register__call_threadsafe_function_263']?.()
__napiInstance.exports[
'__napi_register__call_long_threadsafe_function_264'
]?.()
__napiInstance.exports[
'__napi_register__threadsafe_function_throw_error_265'
]?.()
__napiInstance.exports[
'__napi_register__threadsafe_function_fatal_mode_266'
]?.()
__napiInstance.exports[
'__napi_register__threadsafe_function_fatal_mode_error_267'
]?.()
__napiInstance.exports[
'__napi_register__threadsafe_function_closure_capture_268'
]?.()
__napiInstance.exports['__napi_register__tsfn_call_with_callback_269']?.()
__napiInstance.exports['__napi_register__tsfn_async_call_270']?.()
__napiInstance.exports['__napi_register__accept_threadsafe_function_271']?.()
__napiInstance.exports[
'__napi_register__accept_threadsafe_function_fatal_272'
]?.()
__napiInstance.exports[
'__napi_register__accept_threadsafe_function_tuple_args_273'
]?.()
__napiInstance.exports['__napi_register__tsfn_return_promise_274']?.()
__napiInstance.exports['__napi_register__tsfn_return_promise_timeout_275']?.()
__napiInstance.exports['__napi_register__tsfn_throw_from_js_276']?.()
__napiInstance.exports['__napi_register__get_buffer_277']?.()
__napiInstance.exports['__napi_register__append_buffer_278']?.()
__napiInstance.exports['__napi_register__get_empty_buffer_279']?.()
__napiInstance.exports['__napi_register__convert_u32_array_280']?.()
__napiInstance.exports['__napi_register__create_external_typed_array_281']?.()
__napiInstance.exports['__napi_register__mutate_typed_array_282']?.()
__napiInstance.exports['__napi_register__deref_uint8_array_283']?.()
__napiInstance.exports['__napi_register__buffer_pass_through_284']?.()
__napiInstance.exports['__napi_register__array_buffer_pass_through_285']?.()
__napiInstance.exports['__napi_register__AsyncBuffer_impl_286']?.()
__napiInstance.exports['__napi_register__async_reduce_buffer_287']?.()
}
export const Animal = __napiModule.exports.Animal
export const AnimalWithDefaultConstructor =
__napiModule.exports.AnimalWithDefaultConstructor
export const AnotherClassForEither = __napiModule.exports.AnotherClassForEither
export const AnotherCssStyleSheet = __napiModule.exports.AnotherCssStyleSheet
export const AnotherCSSStyleSheet = __napiModule.exports.AnotherCSSStyleSheet
export const Asset = __napiModule.exports.Asset
export const JsAsset = __napiModule.exports.JsAsset
export const Assets = __napiModule.exports.Assets
export const JsAssets = __napiModule.exports.JsAssets
export const Bird = __napiModule.exports.Bird
export const Blake2BHasher = __napiModule.exports.Blake2BHasher
export const Blake2bHasher = __napiModule.exports.Blake2bHasher
export const Blake2BKey = __napiModule.exports.Blake2BKey
export const Blake2bKey = __napiModule.exports.Blake2bKey
export const CatchOnConstructor = __napiModule.exports.CatchOnConstructor
export const CatchOnConstructor2 = __napiModule.exports.CatchOnConstructor2
export const ClassWithFactory = __napiModule.exports.ClassWithFactory
export const Context = __napiModule.exports.Context
export const CssRuleList = __napiModule.exports.CssRuleList
export const CSSRuleList = __napiModule.exports.CSSRuleList
export const CssStyleSheet = __napiModule.exports.CssStyleSheet
export const CSSStyleSheet = __napiModule.exports.CSSStyleSheet
export const CustomFinalize = __napiModule.exports.CustomFinalize
export const Dog = __napiModule.exports.Dog
export const Fib = __napiModule.exports.Fib
export const Fib2 = __napiModule.exports.Fib2
export const Fib3 = __napiModule.exports.Fib3
export const GetterSetterWithClosures =
__napiModule.exports.GetterSetterWithClosures
export const JsClassForEither = __napiModule.exports.JsClassForEither
export const JsRemote = __napiModule.exports.JsRemote
export const JsRepo = __napiModule.exports.JsRepo
export const NinjaTurtle = __napiModule.exports.NinjaTurtle
export const NotWritableClass = __napiModule.exports.NotWritableClass
export const Optional = __napiModule.exports.Optional
export const Selector = __napiModule.exports.Selector
export const Width = __napiModule.exports.Width
export const acceptThreadsafeFunction =
__napiModule.exports.acceptThreadsafeFunction
export const acceptThreadsafeFunctionFatal =
__napiModule.exports.acceptThreadsafeFunctionFatal
export const acceptThreadsafeFunctionTupleArgs =
__napiModule.exports.acceptThreadsafeFunctionTupleArgs
export const add = __napiModule.exports.add
export const ALIAS = __napiModule.exports.ALIAS
export const AliasedEnum = __napiModule.exports.AliasedEnum
export const appendBuffer = __napiModule.exports.appendBuffer
export const arrayBufferPassThrough =
__napiModule.exports.arrayBufferPassThrough
export const asyncMultiTwo = __napiModule.exports.asyncMultiTwo
export const asyncPlus100 = __napiModule.exports.asyncPlus100
export const asyncReduceBuffer = __napiModule.exports.asyncReduceBuffer
export const asyncTaskOptionalReturn =
__napiModule.exports.asyncTaskOptionalReturn
export const asyncTaskVoidReturn = __napiModule.exports.asyncTaskVoidReturn
export const bigintAdd = __napiModule.exports.bigintAdd
export const bigintFromI128 = __napiModule.exports.bigintFromI128
export const bigintFromI64 = __napiModule.exports.bigintFromI64
export const bigintGetU64AsString = __napiModule.exports.bigintGetU64AsString
export const bufferPassThrough = __napiModule.exports.bufferPassThrough
export const callbackReturnPromise = __napiModule.exports.callbackReturnPromise
export const callbackReturnPromiseAndSpawn =
__napiModule.exports.callbackReturnPromiseAndSpawn
export const callLongThreadsafeFunction =
__napiModule.exports.callLongThreadsafeFunction
export const callThreadsafeFunction =
__napiModule.exports.callThreadsafeFunction
export const captureErrorInCallback =
__napiModule.exports.captureErrorInCallback
export const chronoDateAdd1Minute = __napiModule.exports.chronoDateAdd1Minute
export const chronoDateToMillis = __napiModule.exports.chronoDateToMillis
export const chronoNativeDateTime = __napiModule.exports.chronoNativeDateTime
export const chronoNativeDateTimeReturn =
__napiModule.exports.chronoNativeDateTimeReturn
export const concatLatin1 = __napiModule.exports.concatLatin1
export const concatStr = __napiModule.exports.concatStr
export const concatUtf16 = __napiModule.exports.concatUtf16
export const contains = __napiModule.exports.contains
export const convertU32Array = __napiModule.exports.convertU32Array
export const createBigInt = __napiModule.exports.createBigInt
export const createBigIntI64 = __napiModule.exports.createBigIntI64
export const createExternal = __napiModule.exports.createExternal
export const createExternalString = __napiModule.exports.createExternalString
export const createExternalTypedArray =
__napiModule.exports.createExternalTypedArray
export const createObj = __napiModule.exports.createObj
export const createObjectWithClassField =
__napiModule.exports.createObjectWithClassField
export const createObjWithProperty = __napiModule.exports.createObjWithProperty
export const createSymbol = __napiModule.exports.createSymbol
export const createSymbolFor = __napiModule.exports.createSymbolFor
export const CustomNumEnum = __napiModule.exports.CustomNumEnum
export const customStatusCode = __napiModule.exports.customStatusCode
export const dateToNumber = __napiModule.exports.dateToNumber
export const DEFAULT_COST = __napiModule.exports.DEFAULT_COST
export const derefUint8Array = __napiModule.exports.derefUint8Array
export const either3 = __napiModule.exports.either3
export const either4 = __napiModule.exports.either4
export const eitherBoolOrFunction = __napiModule.exports.eitherBoolOrFunction
export const eitherFromObjects = __napiModule.exports.eitherFromObjects
export const eitherFromOption = __napiModule.exports.eitherFromOption
export const eitherStringOrNumber = __napiModule.exports.eitherStringOrNumber
export const Empty = __napiModule.exports.Empty
export const enumToI32 = __napiModule.exports.enumToI32
export const fibonacci = __napiModule.exports.fibonacci
export const fnReceivedAliased = __napiModule.exports.fnReceivedAliased
export const getBuffer = __napiModule.exports.getBuffer
export const getCwd = __napiModule.exports.getCwd
export const getEmptyBuffer = __napiModule.exports.getEmptyBuffer
export const getExternal = __napiModule.exports.getExternal
export const getGlobal = __napiModule.exports.getGlobal
export const getMapping = __napiModule.exports.getMapping
export const getModuleFileName = __napiModule.exports.getModuleFileName
export const getNestedNumArr = __napiModule.exports.getNestedNumArr
export const getNull = __napiModule.exports.getNull
export const getNumArr = __napiModule.exports.getNumArr
export const getNums = __napiModule.exports.getNums
export const getPackageJsonName = __napiModule.exports.getPackageJsonName
export const getStrFromObject = __napiModule.exports.getStrFromObject
export const getterFromObj = __napiModule.exports.getterFromObj
export const getUndefined = __napiModule.exports.getUndefined
export const getWords = __napiModule.exports.getWords
export const Kind = __napiModule.exports.Kind
export const listObjKeys = __napiModule.exports.listObjKeys
export const mapOption = __napiModule.exports.mapOption
export const mutateExternal = __napiModule.exports.mutateExternal
export const mutateTypedArray = __napiModule.exports.mutateTypedArray
export const optionEnd = __napiModule.exports.optionEnd
export const optionOnly = __napiModule.exports.optionOnly
export const optionStart = __napiModule.exports.optionStart
export const optionStartEnd = __napiModule.exports.optionStartEnd
export const overrideIndividualArgOnFunction =
__napiModule.exports.overrideIndividualArgOnFunction
export const overrideIndividualArgOnFunctionWithCbArg =
__napiModule.exports.overrideIndividualArgOnFunctionWithCbArg
export const panic = __napiModule.exports.panic
export const plusOne = __napiModule.exports.plusOne
export const promiseInEither = __napiModule.exports.promiseInEither
export const readFile = __napiModule.exports.readFile
export const readFileAsync = __napiModule.exports.readFileAsync
export const readPackageJson = __napiModule.exports.readPackageJson
export const receiveAllOptionalObject =
__napiModule.exports.receiveAllOptionalObject
export const receiveClassOrNumber = __napiModule.exports.receiveClassOrNumber
export const receiveDifferentClass = __napiModule.exports.receiveDifferentClass
export const receiveMutClassOrNumber =
__napiModule.exports.receiveMutClassOrNumber
export const receiveObjectOnlyFromJs =
__napiModule.exports.receiveObjectOnlyFromJs
export const receiveObjectWithClassField =
__napiModule.exports.receiveObjectWithClassField
export const receiveStrictObject = __napiModule.exports.receiveStrictObject
export const receiveString = __napiModule.exports.receiveString
export const returnEither = __napiModule.exports.returnEither
export const returnEitherClass = __napiModule.exports.returnEitherClass
export const returnFromSharedCrate = __napiModule.exports.returnFromSharedCrate
export const returnJsFunction = __napiModule.exports.returnJsFunction
export const returnNull = __napiModule.exports.returnNull
export const returnUndefined = __napiModule.exports.returnUndefined
export const returnUndefinedIfInvalid =
__napiModule.exports.returnUndefinedIfInvalid
export const returnUndefinedIfInvalidPromise =
__napiModule.exports.returnUndefinedIfInvalidPromise
export const roundtripStr = __napiModule.exports.roundtripStr
export const runScript = __napiModule.exports.runScript
export const setSymbolInObj = __napiModule.exports.setSymbolInObj
export const Status = __napiModule.exports.Status
export const sumMapping = __napiModule.exports.sumMapping
export const sumNums = __napiModule.exports.sumNums
export const testSerdeBigNumberPrecision =
__napiModule.exports.testSerdeBigNumberPrecision
export const testSerdeRoundtrip = __napiModule.exports.testSerdeRoundtrip
export const threadsafeFunctionClosureCapture =
__napiModule.exports.threadsafeFunctionClosureCapture
export const threadsafeFunctionFatalMode =
__napiModule.exports.threadsafeFunctionFatalMode
export const threadsafeFunctionFatalModeError =
__napiModule.exports.threadsafeFunctionFatalModeError
export const threadsafeFunctionThrowError =
__napiModule.exports.threadsafeFunctionThrowError
export const throwAsyncError = __napiModule.exports.throwAsyncError
export const throwError = __napiModule.exports.throwError
export const throwSyntaxError = __napiModule.exports.throwSyntaxError
export const toJsObj = __napiModule.exports.toJsObj
export const tsfnAsyncCall = __napiModule.exports.tsfnAsyncCall
export const tsfnCallWithCallback = __napiModule.exports.tsfnCallWithCallback
export const tsfnReturnPromise = __napiModule.exports.tsfnReturnPromise
export const tsfnReturnPromiseTimeout =
__napiModule.exports.tsfnReturnPromiseTimeout
export const tsfnThrowFromJs = __napiModule.exports.tsfnThrowFromJs
export const tsRename = __napiModule.exports.tsRename
export const validateArray = __napiModule.exports.validateArray
export const validateBigint = __napiModule.exports.validateBigint
export const validateBoolean = __napiModule.exports.validateBoolean
export const validateBuffer = __napiModule.exports.validateBuffer
export const validateDate = __napiModule.exports.validateDate
export const validateDateTime = __napiModule.exports.validateDateTime
export const validateExternal = __napiModule.exports.validateExternal
export const validateFunction = __napiModule.exports.validateFunction
export const validateHashMap = __napiModule.exports.validateHashMap
export const validateNull = __napiModule.exports.validateNull
export const validateNumber = __napiModule.exports.validateNumber
export const validateOptional = __napiModule.exports.validateOptional
export const validatePromise = __napiModule.exports.validatePromise
export const validateString = __napiModule.exports.validateString
export const validateSymbol = __napiModule.exports.validateSymbol
export const validateTypedArray = __napiModule.exports.validateTypedArray
export const validateUndefined = __napiModule.exports.validateUndefined
export const withAbortController = __napiModule.exports.withAbortController
export const withoutAbortController =
__napiModule.exports.withoutAbortController
export const xxh64Alias = __napiModule.exports.xxh64Alias
export const xxh2 = __napiModule.exports.xxh2
export const xxh3 = __napiModule.exports.xxh3

View file

@ -300,189 +300,189 @@ function __napi_rs_initialize_modules(__napiInstance) {
__napiInstance.exports['__napi_register__AsyncBuffer_impl_286']?.()
__napiInstance.exports['__napi_register__async_reduce_buffer_287']?.()
}
module.exports.Animal = __napiModule.exports.Animal,
module.exports.AnimalWithDefaultConstructor = __napiModule.exports.AnimalWithDefaultConstructor,
module.exports.AnotherClassForEither = __napiModule.exports.AnotherClassForEither,
module.exports.AnotherCssStyleSheet = __napiModule.exports.AnotherCssStyleSheet,
module.exports.AnotherCSSStyleSheet = __napiModule.exports.AnotherCSSStyleSheet,
module.exports.Asset = __napiModule.exports.Asset,
module.exports.JsAsset = __napiModule.exports.JsAsset,
module.exports.Assets = __napiModule.exports.Assets,
module.exports.JsAssets = __napiModule.exports.JsAssets,
module.exports.Bird = __napiModule.exports.Bird,
module.exports.Blake2BHasher = __napiModule.exports.Blake2BHasher,
module.exports.Blake2bHasher = __napiModule.exports.Blake2bHasher,
module.exports.Blake2BKey = __napiModule.exports.Blake2BKey,
module.exports.Blake2bKey = __napiModule.exports.Blake2bKey,
module.exports.CatchOnConstructor = __napiModule.exports.CatchOnConstructor,
module.exports.CatchOnConstructor2 = __napiModule.exports.CatchOnConstructor2,
module.exports.ClassWithFactory = __napiModule.exports.ClassWithFactory,
module.exports.Context = __napiModule.exports.Context,
module.exports.CssRuleList = __napiModule.exports.CssRuleList,
module.exports.CSSRuleList = __napiModule.exports.CSSRuleList,
module.exports.CssStyleSheet = __napiModule.exports.CssStyleSheet,
module.exports.CSSStyleSheet = __napiModule.exports.CSSStyleSheet,
module.exports.CustomFinalize = __napiModule.exports.CustomFinalize,
module.exports.Dog = __napiModule.exports.Dog,
module.exports.Fib = __napiModule.exports.Fib,
module.exports.Fib2 = __napiModule.exports.Fib2,
module.exports.Fib3 = __napiModule.exports.Fib3,
module.exports.GetterSetterWithClosures = __napiModule.exports.GetterSetterWithClosures,
module.exports.JsClassForEither = __napiModule.exports.JsClassForEither,
module.exports.JsRemote = __napiModule.exports.JsRemote,
module.exports.JsRepo = __napiModule.exports.JsRepo,
module.exports.NinjaTurtle = __napiModule.exports.NinjaTurtle,
module.exports.NotWritableClass = __napiModule.exports.NotWritableClass,
module.exports.Optional = __napiModule.exports.Optional,
module.exports.Selector = __napiModule.exports.Selector,
module.exports.Width = __napiModule.exports.Width,
module.exports.acceptThreadsafeFunction = __napiModule.exports.acceptThreadsafeFunction,
module.exports.acceptThreadsafeFunctionFatal = __napiModule.exports.acceptThreadsafeFunctionFatal,
module.exports.acceptThreadsafeFunctionTupleArgs = __napiModule.exports.acceptThreadsafeFunctionTupleArgs,
module.exports.add = __napiModule.exports.add,
module.exports.ALIAS = __napiModule.exports.ALIAS,
module.exports.AliasedEnum = __napiModule.exports.AliasedEnum,
module.exports.appendBuffer = __napiModule.exports.appendBuffer,
module.exports.arrayBufferPassThrough = __napiModule.exports.arrayBufferPassThrough,
module.exports.asyncMultiTwo = __napiModule.exports.asyncMultiTwo,
module.exports.asyncPlus100 = __napiModule.exports.asyncPlus100,
module.exports.asyncReduceBuffer = __napiModule.exports.asyncReduceBuffer,
module.exports.asyncTaskOptionalReturn = __napiModule.exports.asyncTaskOptionalReturn,
module.exports.asyncTaskVoidReturn = __napiModule.exports.asyncTaskVoidReturn,
module.exports.bigintAdd = __napiModule.exports.bigintAdd,
module.exports.bigintFromI128 = __napiModule.exports.bigintFromI128,
module.exports.bigintFromI64 = __napiModule.exports.bigintFromI64,
module.exports.bigintGetU64AsString = __napiModule.exports.bigintGetU64AsString,
module.exports.bufferPassThrough = __napiModule.exports.bufferPassThrough,
module.exports.callbackReturnPromise = __napiModule.exports.callbackReturnPromise,
module.exports.callbackReturnPromiseAndSpawn = __napiModule.exports.callbackReturnPromiseAndSpawn,
module.exports.callLongThreadsafeFunction = __napiModule.exports.callLongThreadsafeFunction,
module.exports.callThreadsafeFunction = __napiModule.exports.callThreadsafeFunction,
module.exports.captureErrorInCallback = __napiModule.exports.captureErrorInCallback,
module.exports.chronoDateAdd1Minute = __napiModule.exports.chronoDateAdd1Minute,
module.exports.chronoDateToMillis = __napiModule.exports.chronoDateToMillis,
module.exports.chronoNativeDateTime = __napiModule.exports.chronoNativeDateTime,
module.exports.chronoNativeDateTimeReturn = __napiModule.exports.chronoNativeDateTimeReturn,
module.exports.concatLatin1 = __napiModule.exports.concatLatin1,
module.exports.concatStr = __napiModule.exports.concatStr,
module.exports.concatUtf16 = __napiModule.exports.concatUtf16,
module.exports.contains = __napiModule.exports.contains,
module.exports.convertU32Array = __napiModule.exports.convertU32Array,
module.exports.createBigInt = __napiModule.exports.createBigInt,
module.exports.createBigIntI64 = __napiModule.exports.createBigIntI64,
module.exports.createExternal = __napiModule.exports.createExternal,
module.exports.createExternalString = __napiModule.exports.createExternalString,
module.exports.createExternalTypedArray = __napiModule.exports.createExternalTypedArray,
module.exports.createObj = __napiModule.exports.createObj,
module.exports.createObjectWithClassField = __napiModule.exports.createObjectWithClassField,
module.exports.createObjWithProperty = __napiModule.exports.createObjWithProperty,
module.exports.createSymbol = __napiModule.exports.createSymbol,
module.exports.createSymbolFor = __napiModule.exports.createSymbolFor,
module.exports.CustomNumEnum = __napiModule.exports.CustomNumEnum,
module.exports.customStatusCode = __napiModule.exports.customStatusCode,
module.exports.dateToNumber = __napiModule.exports.dateToNumber,
module.exports.DEFAULT_COST = __napiModule.exports.DEFAULT_COST,
module.exports.derefUint8Array = __napiModule.exports.derefUint8Array,
module.exports.either3 = __napiModule.exports.either3,
module.exports.either4 = __napiModule.exports.either4,
module.exports.eitherBoolOrFunction = __napiModule.exports.eitherBoolOrFunction,
module.exports.eitherFromObjects = __napiModule.exports.eitherFromObjects,
module.exports.eitherFromOption = __napiModule.exports.eitherFromOption,
module.exports.eitherStringOrNumber = __napiModule.exports.eitherStringOrNumber,
module.exports.Empty = __napiModule.exports.Empty,
module.exports.enumToI32 = __napiModule.exports.enumToI32,
module.exports.fibonacci = __napiModule.exports.fibonacci,
module.exports.fnReceivedAliased = __napiModule.exports.fnReceivedAliased,
module.exports.getBuffer = __napiModule.exports.getBuffer,
module.exports.getCwd = __napiModule.exports.getCwd,
module.exports.getEmptyBuffer = __napiModule.exports.getEmptyBuffer,
module.exports.getExternal = __napiModule.exports.getExternal,
module.exports.getGlobal = __napiModule.exports.getGlobal,
module.exports.getMapping = __napiModule.exports.getMapping,
module.exports.getModuleFileName = __napiModule.exports.getModuleFileName,
module.exports.getNestedNumArr = __napiModule.exports.getNestedNumArr,
module.exports.getNull = __napiModule.exports.getNull,
module.exports.getNumArr = __napiModule.exports.getNumArr,
module.exports.getNums = __napiModule.exports.getNums,
module.exports.getPackageJsonName = __napiModule.exports.getPackageJsonName,
module.exports.getStrFromObject = __napiModule.exports.getStrFromObject,
module.exports.getterFromObj = __napiModule.exports.getterFromObj,
module.exports.getUndefined = __napiModule.exports.getUndefined,
module.exports.getWords = __napiModule.exports.getWords,
module.exports.Kind = __napiModule.exports.Kind,
module.exports.listObjKeys = __napiModule.exports.listObjKeys,
module.exports.mapOption = __napiModule.exports.mapOption,
module.exports.mutateExternal = __napiModule.exports.mutateExternal,
module.exports.mutateTypedArray = __napiModule.exports.mutateTypedArray,
module.exports.optionEnd = __napiModule.exports.optionEnd,
module.exports.optionOnly = __napiModule.exports.optionOnly,
module.exports.optionStart = __napiModule.exports.optionStart,
module.exports.optionStartEnd = __napiModule.exports.optionStartEnd,
module.exports.overrideIndividualArgOnFunction = __napiModule.exports.overrideIndividualArgOnFunction,
module.exports.overrideIndividualArgOnFunctionWithCbArg = __napiModule.exports.overrideIndividualArgOnFunctionWithCbArg,
module.exports.panic = __napiModule.exports.panic,
module.exports.plusOne = __napiModule.exports.plusOne,
module.exports.promiseInEither = __napiModule.exports.promiseInEither,
module.exports.readFile = __napiModule.exports.readFile,
module.exports.readFileAsync = __napiModule.exports.readFileAsync,
module.exports.readPackageJson = __napiModule.exports.readPackageJson,
module.exports.receiveAllOptionalObject = __napiModule.exports.receiveAllOptionalObject,
module.exports.receiveClassOrNumber = __napiModule.exports.receiveClassOrNumber,
module.exports.receiveDifferentClass = __napiModule.exports.receiveDifferentClass,
module.exports.receiveMutClassOrNumber = __napiModule.exports.receiveMutClassOrNumber,
module.exports.receiveObjectOnlyFromJs = __napiModule.exports.receiveObjectOnlyFromJs,
module.exports.receiveObjectWithClassField = __napiModule.exports.receiveObjectWithClassField,
module.exports.receiveStrictObject = __napiModule.exports.receiveStrictObject,
module.exports.receiveString = __napiModule.exports.receiveString,
module.exports.returnEither = __napiModule.exports.returnEither,
module.exports.returnEitherClass = __napiModule.exports.returnEitherClass,
module.exports.returnFromSharedCrate = __napiModule.exports.returnFromSharedCrate,
module.exports.returnJsFunction = __napiModule.exports.returnJsFunction,
module.exports.returnNull = __napiModule.exports.returnNull,
module.exports.returnUndefined = __napiModule.exports.returnUndefined,
module.exports.returnUndefinedIfInvalid = __napiModule.exports.returnUndefinedIfInvalid,
module.exports.returnUndefinedIfInvalidPromise = __napiModule.exports.returnUndefinedIfInvalidPromise,
module.exports.roundtripStr = __napiModule.exports.roundtripStr,
module.exports.runScript = __napiModule.exports.runScript,
module.exports.setSymbolInObj = __napiModule.exports.setSymbolInObj,
module.exports.Status = __napiModule.exports.Status,
module.exports.sumMapping = __napiModule.exports.sumMapping,
module.exports.sumNums = __napiModule.exports.sumNums,
module.exports.testSerdeBigNumberPrecision = __napiModule.exports.testSerdeBigNumberPrecision,
module.exports.testSerdeRoundtrip = __napiModule.exports.testSerdeRoundtrip,
module.exports.threadsafeFunctionClosureCapture = __napiModule.exports.threadsafeFunctionClosureCapture,
module.exports.threadsafeFunctionFatalMode = __napiModule.exports.threadsafeFunctionFatalMode,
module.exports.threadsafeFunctionFatalModeError = __napiModule.exports.threadsafeFunctionFatalModeError,
module.exports.threadsafeFunctionThrowError = __napiModule.exports.threadsafeFunctionThrowError,
module.exports.throwAsyncError = __napiModule.exports.throwAsyncError,
module.exports.throwError = __napiModule.exports.throwError,
module.exports.throwSyntaxError = __napiModule.exports.throwSyntaxError,
module.exports.toJsObj = __napiModule.exports.toJsObj,
module.exports.tsfnAsyncCall = __napiModule.exports.tsfnAsyncCall,
module.exports.tsfnCallWithCallback = __napiModule.exports.tsfnCallWithCallback,
module.exports.tsfnReturnPromise = __napiModule.exports.tsfnReturnPromise,
module.exports.tsfnReturnPromiseTimeout = __napiModule.exports.tsfnReturnPromiseTimeout,
module.exports.tsfnThrowFromJs = __napiModule.exports.tsfnThrowFromJs,
module.exports.tsRename = __napiModule.exports.tsRename,
module.exports.validateArray = __napiModule.exports.validateArray,
module.exports.validateBigint = __napiModule.exports.validateBigint,
module.exports.validateBoolean = __napiModule.exports.validateBoolean,
module.exports.validateBuffer = __napiModule.exports.validateBuffer,
module.exports.validateDate = __napiModule.exports.validateDate,
module.exports.validateDateTime = __napiModule.exports.validateDateTime,
module.exports.validateExternal = __napiModule.exports.validateExternal,
module.exports.validateFunction = __napiModule.exports.validateFunction,
module.exports.validateHashMap = __napiModule.exports.validateHashMap,
module.exports.validateNull = __napiModule.exports.validateNull,
module.exports.validateNumber = __napiModule.exports.validateNumber,
module.exports.validateOptional = __napiModule.exports.validateOptional,
module.exports.validatePromise = __napiModule.exports.validatePromise,
module.exports.validateString = __napiModule.exports.validateString,
module.exports.validateSymbol = __napiModule.exports.validateSymbol,
module.exports.validateTypedArray = __napiModule.exports.validateTypedArray,
module.exports.validateUndefined = __napiModule.exports.validateUndefined,
module.exports.withAbortController = __napiModule.exports.withAbortController,
module.exports.withoutAbortController = __napiModule.exports.withoutAbortController,
module.exports.xxh64Alias = __napiModule.exports.xxh64Alias,
module.exports.xxh2 = __napiModule.exports.xxh2,
module.exports.Animal = __napiModule.exports.Animal
module.exports.AnimalWithDefaultConstructor = __napiModule.exports.AnimalWithDefaultConstructor
module.exports.AnotherClassForEither = __napiModule.exports.AnotherClassForEither
module.exports.AnotherCssStyleSheet = __napiModule.exports.AnotherCssStyleSheet
module.exports.AnotherCSSStyleSheet = __napiModule.exports.AnotherCSSStyleSheet
module.exports.Asset = __napiModule.exports.Asset
module.exports.JsAsset = __napiModule.exports.JsAsset
module.exports.Assets = __napiModule.exports.Assets
module.exports.JsAssets = __napiModule.exports.JsAssets
module.exports.Bird = __napiModule.exports.Bird
module.exports.Blake2BHasher = __napiModule.exports.Blake2BHasher
module.exports.Blake2bHasher = __napiModule.exports.Blake2bHasher
module.exports.Blake2BKey = __napiModule.exports.Blake2BKey
module.exports.Blake2bKey = __napiModule.exports.Blake2bKey
module.exports.CatchOnConstructor = __napiModule.exports.CatchOnConstructor
module.exports.CatchOnConstructor2 = __napiModule.exports.CatchOnConstructor2
module.exports.ClassWithFactory = __napiModule.exports.ClassWithFactory
module.exports.Context = __napiModule.exports.Context
module.exports.CssRuleList = __napiModule.exports.CssRuleList
module.exports.CSSRuleList = __napiModule.exports.CSSRuleList
module.exports.CssStyleSheet = __napiModule.exports.CssStyleSheet
module.exports.CSSStyleSheet = __napiModule.exports.CSSStyleSheet
module.exports.CustomFinalize = __napiModule.exports.CustomFinalize
module.exports.Dog = __napiModule.exports.Dog
module.exports.Fib = __napiModule.exports.Fib
module.exports.Fib2 = __napiModule.exports.Fib2
module.exports.Fib3 = __napiModule.exports.Fib3
module.exports.GetterSetterWithClosures = __napiModule.exports.GetterSetterWithClosures
module.exports.JsClassForEither = __napiModule.exports.JsClassForEither
module.exports.JsRemote = __napiModule.exports.JsRemote
module.exports.JsRepo = __napiModule.exports.JsRepo
module.exports.NinjaTurtle = __napiModule.exports.NinjaTurtle
module.exports.NotWritableClass = __napiModule.exports.NotWritableClass
module.exports.Optional = __napiModule.exports.Optional
module.exports.Selector = __napiModule.exports.Selector
module.exports.Width = __napiModule.exports.Width
module.exports.acceptThreadsafeFunction = __napiModule.exports.acceptThreadsafeFunction
module.exports.acceptThreadsafeFunctionFatal = __napiModule.exports.acceptThreadsafeFunctionFatal
module.exports.acceptThreadsafeFunctionTupleArgs = __napiModule.exports.acceptThreadsafeFunctionTupleArgs
module.exports.add = __napiModule.exports.add
module.exports.ALIAS = __napiModule.exports.ALIAS
module.exports.AliasedEnum = __napiModule.exports.AliasedEnum
module.exports.appendBuffer = __napiModule.exports.appendBuffer
module.exports.arrayBufferPassThrough = __napiModule.exports.arrayBufferPassThrough
module.exports.asyncMultiTwo = __napiModule.exports.asyncMultiTwo
module.exports.asyncPlus100 = __napiModule.exports.asyncPlus100
module.exports.asyncReduceBuffer = __napiModule.exports.asyncReduceBuffer
module.exports.asyncTaskOptionalReturn = __napiModule.exports.asyncTaskOptionalReturn
module.exports.asyncTaskVoidReturn = __napiModule.exports.asyncTaskVoidReturn
module.exports.bigintAdd = __napiModule.exports.bigintAdd
module.exports.bigintFromI128 = __napiModule.exports.bigintFromI128
module.exports.bigintFromI64 = __napiModule.exports.bigintFromI64
module.exports.bigintGetU64AsString = __napiModule.exports.bigintGetU64AsString
module.exports.bufferPassThrough = __napiModule.exports.bufferPassThrough
module.exports.callbackReturnPromise = __napiModule.exports.callbackReturnPromise
module.exports.callbackReturnPromiseAndSpawn = __napiModule.exports.callbackReturnPromiseAndSpawn
module.exports.callLongThreadsafeFunction = __napiModule.exports.callLongThreadsafeFunction
module.exports.callThreadsafeFunction = __napiModule.exports.callThreadsafeFunction
module.exports.captureErrorInCallback = __napiModule.exports.captureErrorInCallback
module.exports.chronoDateAdd1Minute = __napiModule.exports.chronoDateAdd1Minute
module.exports.chronoDateToMillis = __napiModule.exports.chronoDateToMillis
module.exports.chronoNativeDateTime = __napiModule.exports.chronoNativeDateTime
module.exports.chronoNativeDateTimeReturn = __napiModule.exports.chronoNativeDateTimeReturn
module.exports.concatLatin1 = __napiModule.exports.concatLatin1
module.exports.concatStr = __napiModule.exports.concatStr
module.exports.concatUtf16 = __napiModule.exports.concatUtf16
module.exports.contains = __napiModule.exports.contains
module.exports.convertU32Array = __napiModule.exports.convertU32Array
module.exports.createBigInt = __napiModule.exports.createBigInt
module.exports.createBigIntI64 = __napiModule.exports.createBigIntI64
module.exports.createExternal = __napiModule.exports.createExternal
module.exports.createExternalString = __napiModule.exports.createExternalString
module.exports.createExternalTypedArray = __napiModule.exports.createExternalTypedArray
module.exports.createObj = __napiModule.exports.createObj
module.exports.createObjectWithClassField = __napiModule.exports.createObjectWithClassField
module.exports.createObjWithProperty = __napiModule.exports.createObjWithProperty
module.exports.createSymbol = __napiModule.exports.createSymbol
module.exports.createSymbolFor = __napiModule.exports.createSymbolFor
module.exports.CustomNumEnum = __napiModule.exports.CustomNumEnum
module.exports.customStatusCode = __napiModule.exports.customStatusCode
module.exports.dateToNumber = __napiModule.exports.dateToNumber
module.exports.DEFAULT_COST = __napiModule.exports.DEFAULT_COST
module.exports.derefUint8Array = __napiModule.exports.derefUint8Array
module.exports.either3 = __napiModule.exports.either3
module.exports.either4 = __napiModule.exports.either4
module.exports.eitherBoolOrFunction = __napiModule.exports.eitherBoolOrFunction
module.exports.eitherFromObjects = __napiModule.exports.eitherFromObjects
module.exports.eitherFromOption = __napiModule.exports.eitherFromOption
module.exports.eitherStringOrNumber = __napiModule.exports.eitherStringOrNumber
module.exports.Empty = __napiModule.exports.Empty
module.exports.enumToI32 = __napiModule.exports.enumToI32
module.exports.fibonacci = __napiModule.exports.fibonacci
module.exports.fnReceivedAliased = __napiModule.exports.fnReceivedAliased
module.exports.getBuffer = __napiModule.exports.getBuffer
module.exports.getCwd = __napiModule.exports.getCwd
module.exports.getEmptyBuffer = __napiModule.exports.getEmptyBuffer
module.exports.getExternal = __napiModule.exports.getExternal
module.exports.getGlobal = __napiModule.exports.getGlobal
module.exports.getMapping = __napiModule.exports.getMapping
module.exports.getModuleFileName = __napiModule.exports.getModuleFileName
module.exports.getNestedNumArr = __napiModule.exports.getNestedNumArr
module.exports.getNull = __napiModule.exports.getNull
module.exports.getNumArr = __napiModule.exports.getNumArr
module.exports.getNums = __napiModule.exports.getNums
module.exports.getPackageJsonName = __napiModule.exports.getPackageJsonName
module.exports.getStrFromObject = __napiModule.exports.getStrFromObject
module.exports.getterFromObj = __napiModule.exports.getterFromObj
module.exports.getUndefined = __napiModule.exports.getUndefined
module.exports.getWords = __napiModule.exports.getWords
module.exports.Kind = __napiModule.exports.Kind
module.exports.listObjKeys = __napiModule.exports.listObjKeys
module.exports.mapOption = __napiModule.exports.mapOption
module.exports.mutateExternal = __napiModule.exports.mutateExternal
module.exports.mutateTypedArray = __napiModule.exports.mutateTypedArray
module.exports.optionEnd = __napiModule.exports.optionEnd
module.exports.optionOnly = __napiModule.exports.optionOnly
module.exports.optionStart = __napiModule.exports.optionStart
module.exports.optionStartEnd = __napiModule.exports.optionStartEnd
module.exports.overrideIndividualArgOnFunction = __napiModule.exports.overrideIndividualArgOnFunction
module.exports.overrideIndividualArgOnFunctionWithCbArg = __napiModule.exports.overrideIndividualArgOnFunctionWithCbArg
module.exports.panic = __napiModule.exports.panic
module.exports.plusOne = __napiModule.exports.plusOne
module.exports.promiseInEither = __napiModule.exports.promiseInEither
module.exports.readFile = __napiModule.exports.readFile
module.exports.readFileAsync = __napiModule.exports.readFileAsync
module.exports.readPackageJson = __napiModule.exports.readPackageJson
module.exports.receiveAllOptionalObject = __napiModule.exports.receiveAllOptionalObject
module.exports.receiveClassOrNumber = __napiModule.exports.receiveClassOrNumber
module.exports.receiveDifferentClass = __napiModule.exports.receiveDifferentClass
module.exports.receiveMutClassOrNumber = __napiModule.exports.receiveMutClassOrNumber
module.exports.receiveObjectOnlyFromJs = __napiModule.exports.receiveObjectOnlyFromJs
module.exports.receiveObjectWithClassField = __napiModule.exports.receiveObjectWithClassField
module.exports.receiveStrictObject = __napiModule.exports.receiveStrictObject
module.exports.receiveString = __napiModule.exports.receiveString
module.exports.returnEither = __napiModule.exports.returnEither
module.exports.returnEitherClass = __napiModule.exports.returnEitherClass
module.exports.returnFromSharedCrate = __napiModule.exports.returnFromSharedCrate
module.exports.returnJsFunction = __napiModule.exports.returnJsFunction
module.exports.returnNull = __napiModule.exports.returnNull
module.exports.returnUndefined = __napiModule.exports.returnUndefined
module.exports.returnUndefinedIfInvalid = __napiModule.exports.returnUndefinedIfInvalid
module.exports.returnUndefinedIfInvalidPromise = __napiModule.exports.returnUndefinedIfInvalidPromise
module.exports.roundtripStr = __napiModule.exports.roundtripStr
module.exports.runScript = __napiModule.exports.runScript
module.exports.setSymbolInObj = __napiModule.exports.setSymbolInObj
module.exports.Status = __napiModule.exports.Status
module.exports.sumMapping = __napiModule.exports.sumMapping
module.exports.sumNums = __napiModule.exports.sumNums
module.exports.testSerdeBigNumberPrecision = __napiModule.exports.testSerdeBigNumberPrecision
module.exports.testSerdeRoundtrip = __napiModule.exports.testSerdeRoundtrip
module.exports.threadsafeFunctionClosureCapture = __napiModule.exports.threadsafeFunctionClosureCapture
module.exports.threadsafeFunctionFatalMode = __napiModule.exports.threadsafeFunctionFatalMode
module.exports.threadsafeFunctionFatalModeError = __napiModule.exports.threadsafeFunctionFatalModeError
module.exports.threadsafeFunctionThrowError = __napiModule.exports.threadsafeFunctionThrowError
module.exports.throwAsyncError = __napiModule.exports.throwAsyncError
module.exports.throwError = __napiModule.exports.throwError
module.exports.throwSyntaxError = __napiModule.exports.throwSyntaxError
module.exports.toJsObj = __napiModule.exports.toJsObj
module.exports.tsfnAsyncCall = __napiModule.exports.tsfnAsyncCall
module.exports.tsfnCallWithCallback = __napiModule.exports.tsfnCallWithCallback
module.exports.tsfnReturnPromise = __napiModule.exports.tsfnReturnPromise
module.exports.tsfnReturnPromiseTimeout = __napiModule.exports.tsfnReturnPromiseTimeout
module.exports.tsfnThrowFromJs = __napiModule.exports.tsfnThrowFromJs
module.exports.tsRename = __napiModule.exports.tsRename
module.exports.validateArray = __napiModule.exports.validateArray
module.exports.validateBigint = __napiModule.exports.validateBigint
module.exports.validateBoolean = __napiModule.exports.validateBoolean
module.exports.validateBuffer = __napiModule.exports.validateBuffer
module.exports.validateDate = __napiModule.exports.validateDate
module.exports.validateDateTime = __napiModule.exports.validateDateTime
module.exports.validateExternal = __napiModule.exports.validateExternal
module.exports.validateFunction = __napiModule.exports.validateFunction
module.exports.validateHashMap = __napiModule.exports.validateHashMap
module.exports.validateNull = __napiModule.exports.validateNull
module.exports.validateNumber = __napiModule.exports.validateNumber
module.exports.validateOptional = __napiModule.exports.validateOptional
module.exports.validatePromise = __napiModule.exports.validatePromise
module.exports.validateString = __napiModule.exports.validateString
module.exports.validateSymbol = __napiModule.exports.validateSymbol
module.exports.validateTypedArray = __napiModule.exports.validateTypedArray
module.exports.validateUndefined = __napiModule.exports.validateUndefined
module.exports.withAbortController = __napiModule.exports.withAbortController
module.exports.withoutAbortController = __napiModule.exports.withoutAbortController
module.exports.xxh64Alias = __napiModule.exports.xxh64Alias
module.exports.xxh2 = __napiModule.exports.xxh2
module.exports.xxh3 = __napiModule.exports.xxh3

View file

@ -6,17 +6,25 @@
"main": "./index.js",
"types": "./index.d.ts",
"scripts": {
"browser": "vite",
"build": "napi-raw build",
"test": "cross-env TS_NODE_PROJECT=./tsconfig.json node --es-module-specifier-resolution=node --loader ts-node/esm/transpile-only --experimental-wasi-unstable-preview1 ../../node_modules/ava/entrypoints/cli.mjs"
},
"devDependencies": {
"@napi-rs/cli": "workspace:*",
"@types/lodash": "^4.14.201",
"@vitest/browser": "^1.1.3",
"@vitest/ui": "^1.1.3",
"ava": "^6.0.0",
"cross-env": "7.0.3",
"electron": "^28.0.0",
"lodash": "^4.17.21",
"sinon": "^17.0.1"
"memfs-browser": "^3.4.13000",
"sinon": "^17.0.1",
"vite": "^5.0.11",
"vite-plugin-node-polyfills": "^0.19.0",
"vitest": "^1.1.3",
"webdriverio": "^8.27.0"
},
"ava": {
"extensions": {
@ -32,7 +40,6 @@
},
"dependencies": {
"@emnapi/core": "0.45.0",
"@tybys/wasm-util": "^0.8.0",
"@types/lodash": "^4.14.202",
"lodash": "^4.17.21",
"sinon": "^17.0.1"

View file

@ -0,0 +1,39 @@
import { defineConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
export default defineConfig({
server: {
headers: {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'require-corp',
},
},
define: {
process: {
env: {},
},
},
plugins: [
nodePolyfills({
include: ['util', 'stream'],
}),
{
name: 'configure-response-headers',
enforce: 'pre',
configureServer: (server) => {
server.middlewares.use((_req, res, next) => {
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
next()
})
},
},
],
test: {
include: ['browser/**/*.{spec,test}.{js,jsx,ts,tsx}'],
browser: {
enabled: true,
name: 'chrome',
},
},
})

View file

@ -0,0 +1,36 @@
import { instantiateNapiModuleSync, MessageHandler } from '@emnapi/core'
import { WASI } from '@tybys/wasm-util'
import { Volume, createFsFromVolume } from 'memfs-browser'
const fs = createFsFromVolume(
Volume.fromJSON({
'/': null,
}),
)
const handler = new MessageHandler({
onLoad({ wasmModule, wasmMemory }) {
const wasi = new WASI({
fs,
print: function () {
console.log.apply(console, arguments)
},
})
return instantiateNapiModuleSync(wasmModule, {
childThread: true,
wasi,
overwriteImports(importObject) {
importObject.env = {
...importObject.env,
...importObject.napi,
...importObject.emnapi,
memory: wasmMemory,
}
},
})
},
})
globalThis.onmessage = function (e) {
handler.handle(e)
}

View file

@ -0,0 +1,32 @@
import { instantiateNapiModuleSync, MessageHandler } from '@emnapi/core'
import { WASI } from '@tybys/wasm-util'
import { Volume, createFsFromVolume } from 'memfs-browser'
const fs = createFsFromVolume(Volume.fromJSON({
'/': null
}))
const handler = new MessageHandler({
onLoad({ wasmModule, wasmMemory }) {
const wasi = new WASI({
fs,
print: function() { console.log.apply(console, arguments) }
})
return instantiateNapiModuleSync(wasmModule, {
childThread: true,
wasi,
overwriteImports(importObject) {
importObject.env = {
...importObject.env,
...importObject.napi,
...importObject.emnapi,
memory: wasmMemory
}
}
})
}
})
globalThis.onmessage = function(e) {
handler.handle(e)
}

2638
yarn.lock

File diff suppressed because it is too large Load diff