Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
21
Frontend-Learner/node_modules/unwasm/LICENSE
generated
vendored
Normal file
21
Frontend-Learner/node_modules/unwasm/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
237
Frontend-Learner/node_modules/unwasm/README.md
generated
vendored
Normal file
237
Frontend-Learner/node_modules/unwasm/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
# unwasm
|
||||
|
||||
<!-- automd:badges color=yellow codecov -->
|
||||
|
||||
[](https://npmjs.com/package/unwasm)
|
||||
[](https://npm.chart.dev/unwasm)
|
||||
[](https://codecov.io/gh/unjs/unwasm)
|
||||
|
||||
<!-- /automd -->
|
||||
|
||||
Universal [WebAssembly](https://webassembly.org/) tools for JavaScript.
|
||||
|
||||
## Goal
|
||||
|
||||
This project aims to make a common and future-proof solution for WebAssembly modules support suitable for various JavaScript runtimes, frameworks, and build Tools following [WebAssembly/ES Module Integration](https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration) proposal from WebAssembly Community Group as much as possible while also trying to keep compatibility with current ecosystem libraries.
|
||||
|
||||
## Bindings API
|
||||
|
||||
When importing a `.wasm` module, unwasm resolves, reads, and then parses the module during the build process to get the information about imports and exports and even tries to [automatically resolve imports](#auto-imports) and generate appropriate code bindings for the bundler.
|
||||
|
||||
If the target environment supports [top level `await`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await) and also the wasm module requires no imports object (or they are auto resolvable), unwasm generates bindings to allow importing wasm module like any other ESM import.
|
||||
|
||||
If the target environment lacks support for top-level `await` or the wasm module requires an imports object or `lazy` plugin option is set to `true`, unwasm will export a wrapped [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) object which can be called as a function to evaluate the module with custom imports object lazily. This way we still have a simple syntax as close as possible to ESM modules and also we can lazily initialize modules.
|
||||
|
||||
**Example:** Using static import
|
||||
|
||||
```js
|
||||
import { sum } from "unwasm/examples/sum.wasm";
|
||||
```
|
||||
|
||||
**Example:** Using dynamic import
|
||||
|
||||
```js
|
||||
const { sum } = await import("unwasm/examples/sum.wasm");
|
||||
```
|
||||
|
||||
If your WebAssembly module requires an import object (unwasm can [automatically infer them](#auto-imports)), the usage syntax would be slightly different as we need to initiate the module with an import object first.
|
||||
|
||||
**Example:** Using dynamic import with imports object
|
||||
|
||||
```js
|
||||
const { rand } = await import("unwasm/examples/rand.wasm").then((r) =>
|
||||
r.default({
|
||||
env: {
|
||||
seed: () => () => Math.random() * Date.now(),
|
||||
},
|
||||
}),
|
||||
);
|
||||
```
|
||||
|
||||
**Example:** Using static import with imports object
|
||||
|
||||
```js
|
||||
import initRand, { rand } from "unwasm/examples/rand.wasm";
|
||||
|
||||
await initRand({
|
||||
env: {
|
||||
seed: () => () => Math.random() * Date.now(),
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> When using **static import syntax**, and before initializing the module, the named exports will be wrapped into a function by proxy that waits for the module initialization and if called before init, will immediately try to call init without imports and return a Promise that calls a function after init.
|
||||
|
||||
### Module compatibility
|
||||
|
||||
There are situations where libraries require a [`WebAssembly.Module`](https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Module) instance to initialize [`WebAssembly.Instance`](https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Instance/Instance) themselves. In order to maximize compatibility, unwasm allows a specific import suffix `?module` to import `.wasm` files as a Module directly.
|
||||
|
||||
```js
|
||||
import _sumMod from "unwasm/examples/sum.wasm?module";
|
||||
const { sum } = await WebAssembly.instantiate(_sumMod).then((i) => i.exports);
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> Open [an issue](https://github.com/unjs/unwasm/issues/new/choose) to us! We would love to help those libraries to migrate!
|
||||
|
||||
## Integration
|
||||
|
||||
Unwasm needs to transform the `.wasm` imports to the compatible bindings. Currently, the only method is using a rollup plugin. In the future, more usage methods will be introduced.
|
||||
|
||||
### Install
|
||||
|
||||
First, install the [`unwasm`](https://www.npmjs.com/package/unwasm) npm package.
|
||||
|
||||
<!-- automd:pm-install -->
|
||||
|
||||
```sh
|
||||
# ✨ Auto-detect
|
||||
npx nypm install unwasm
|
||||
|
||||
# npm
|
||||
npm install unwasm
|
||||
|
||||
# yarn
|
||||
yarn add unwasm
|
||||
|
||||
# pnpm
|
||||
pnpm install unwasm
|
||||
|
||||
# bun
|
||||
bun install unwasm
|
||||
|
||||
# deno
|
||||
deno install unwasm
|
||||
```
|
||||
|
||||
<!-- /automd -->
|
||||
|
||||
### Builder Plugins
|
||||
|
||||
###### Rollup
|
||||
|
||||
```js
|
||||
// rollup.config.js
|
||||
import { rollup as unwasm } from "unwasm/plugin";
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
unwasm({
|
||||
/* options */
|
||||
}),
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
### Plugin Options
|
||||
|
||||
- `esmImport`: Direct import the wasm file instead of bundling, required in Cloudflare Workers and works with environments that allow natively importing a `.wasm` module (default is `false`)
|
||||
- `lazy`: Import `.wasm` files using a lazily evaluated proxy for compatibility with runtimes without top-level await support (default is `false`)
|
||||
|
||||
## Tools
|
||||
|
||||
unwasm provides useful build tools to operate on `.wasm` modules directly.
|
||||
|
||||
**Note:** `unwasm/tools` subpath export is **not** meant or optimized for production runtime. Only rely on it for development and build time.
|
||||
|
||||
### `parseWasm`
|
||||
|
||||
Parses `wasm` binary format with useful information using [webassemblyjs/wasm-parser](https://github.com/xtuc/webassemblyjs/tree/master/packages/wasm-parser).
|
||||
|
||||
```js
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { parseWasm } from "unwasm/tools";
|
||||
|
||||
const source = await readFile(new URL("examples/sum.wasm", import.meta.url));
|
||||
const parsed = parseWasm(source);
|
||||
console.log(JSON.stringify(parsed, undefined, 2));
|
||||
```
|
||||
|
||||
Example parsed result:
|
||||
|
||||
```json
|
||||
{
|
||||
"modules": [
|
||||
{
|
||||
"exports": [
|
||||
{
|
||||
"id": 5,
|
||||
"name": "rand",
|
||||
"type": "Func"
|
||||
},
|
||||
{
|
||||
"id": 0,
|
||||
"name": "memory",
|
||||
"type": "Memory"
|
||||
}
|
||||
],
|
||||
"imports": [
|
||||
{
|
||||
"module": "env",
|
||||
"name": "seed",
|
||||
"params": [],
|
||||
"returnType": "f64"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Auto Imports
|
||||
|
||||
unwasm can automatically infer the imports object and bundle them using imports maps (read more: [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap), [Node.js](https://nodejs.org/api/packages.html#imports) and [WICG](https://github.com/WICG/import-maps)).
|
||||
|
||||
To hint to the bundler how to resolve imports needed by the `.wasm` file, you need to define them in a parent `package.json` file.
|
||||
|
||||
**Example:**
|
||||
|
||||
```json
|
||||
{
|
||||
"exports": {
|
||||
"./rand.wasm": "./rand.wasm"
|
||||
},
|
||||
"imports": {
|
||||
"env": "./env.mjs"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** The imports can also be prefixed with `#` like `#env` if you like to respect Node.js conventions.
|
||||
|
||||
## Contribution
|
||||
|
||||
<details>
|
||||
<summary>Local development</summary>
|
||||
|
||||
- Clone this repository
|
||||
- Install the latest LTS version of [Node.js](https://nodejs.org/en/)
|
||||
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
|
||||
- Install dependencies using `pnpm install`
|
||||
- Run tests using `pnpm dev` or `pnpm test`
|
||||
|
||||
</details>
|
||||
|
||||
<!-- /automd -->
|
||||
|
||||
## License
|
||||
|
||||
<!-- automd:contributors license=MIT author="pi0" -->
|
||||
|
||||
Published under the [MIT](https://github.com/unjs/unwasm/blob/main/LICENSE) license.
|
||||
Made by [@pi0](https://github.com/pi0) and [community](https://github.com/unjs/unwasm/graphs/contributors) 💛
|
||||
<br><br>
|
||||
<a href="https://github.com/unjs/unwasm/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=unjs/unwasm" />
|
||||
</a>
|
||||
|
||||
<!-- /automd -->
|
||||
|
||||
<!-- automd:with-automd -->
|
||||
|
||||
---
|
||||
|
||||
_🤖 auto updated with [automd](https://automd.unjs.io)_
|
||||
|
||||
<!-- /automd -->
|
||||
377
Frontend-Learner/node_modules/unwasm/dist/plugin.cjs
generated
vendored
Normal file
377
Frontend-Learner/node_modules/unwasm/dist/plugin.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,377 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const node_fs = require('node:fs');
|
||||
const pathe = require('pathe');
|
||||
const MagicString = require('magic-string');
|
||||
const unplugin$1 = require('unplugin');
|
||||
const node_crypto = require('node:crypto');
|
||||
const knitwork = require('knitwork');
|
||||
const tools = require('./tools.cjs');
|
||||
|
||||
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
||||
|
||||
const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
|
||||
|
||||
const UNWASM_EXTERNAL_PREFIX = "\0unwasm:external:";
|
||||
const UNWASM_EXTERNAL_RE = /(\0|\\0)unwasm:external:([^"']+)/gu;
|
||||
const UMWASM_HELPERS_ID = "\0unwasm:helpers";
|
||||
function sha1(source) {
|
||||
return node_crypto.createHash("sha1").update(source).digest("hex").slice(0, 16);
|
||||
}
|
||||
|
||||
async function getWasmImports(asset, _opts) {
|
||||
const importNames = Object.keys(asset.imports || {});
|
||||
if (importNames.length === 0) {
|
||||
return {
|
||||
code: "const _imports = { /* no imports */ }",
|
||||
resolved: true
|
||||
};
|
||||
}
|
||||
const { readPackageJSON } = await import('pkg-types');
|
||||
const pkgJSON = await readPackageJSON(asset.id);
|
||||
let resolved = true;
|
||||
const imports = [];
|
||||
const importsObject = {};
|
||||
for (const moduleName of importNames) {
|
||||
const importNames2 = asset.imports[moduleName];
|
||||
const pkgImport = pkgJSON.imports?.[moduleName] || pkgJSON.imports?.[`#${moduleName}`];
|
||||
const importName = "_imports_" + knitwork.genSafeVariableName(moduleName);
|
||||
if (pkgImport && typeof pkgImport === "string") {
|
||||
imports.push(knitwork.genImport(pkgImport, { name: "*", as: importName }));
|
||||
} else {
|
||||
resolved = false;
|
||||
}
|
||||
importsObject[moduleName] = Object.fromEntries(
|
||||
importNames2.map((name) => [
|
||||
name,
|
||||
pkgImport ? `${importName}[${knitwork.genString(name)}]` : `() => { throw new Error(${knitwork.genString(moduleName + "." + importName)} + " is not provided!")}`
|
||||
])
|
||||
);
|
||||
}
|
||||
const code = `${imports.join("\n")}
|
||||
|
||||
const _imports = ${knitwork.genObjectFromRaw(importsObject)}`;
|
||||
return {
|
||||
code,
|
||||
resolved
|
||||
};
|
||||
}
|
||||
|
||||
async function getWasmESMBinding(asset, opts) {
|
||||
const autoImports = await getWasmImports(asset);
|
||||
const instantiateCode = opts.esmImport ? getESMImportInstantiate(asset, autoImports.code) : getBase64Instantiate(asset, autoImports.code);
|
||||
return opts.lazy !== true && autoImports.resolved ? getExports(asset, instantiateCode) : getLazyExports(asset, instantiateCode);
|
||||
}
|
||||
function getWasmModuleBinding(asset, opts) {
|
||||
return opts.esmImport ? (
|
||||
/* js */
|
||||
`
|
||||
const _mod = ${opts.lazy === true ? "" : `await`} import("${UNWASM_EXTERNAL_PREFIX}${asset.name}").then(r => r.default || r);
|
||||
export default _mod;
|
||||
`
|
||||
) : (
|
||||
/* js */
|
||||
`
|
||||
import { base64ToUint8Array } from "${UMWASM_HELPERS_ID}";
|
||||
const _data = base64ToUint8Array("${asset.source.toString("base64")}");
|
||||
const _mod = new WebAssembly.Module(_data);
|
||||
export default _mod;
|
||||
`
|
||||
);
|
||||
}
|
||||
function getESMImportInstantiate(asset, importsCode) {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
${importsCode}
|
||||
|
||||
async function _instantiate(imports = _imports) {
|
||||
const _mod = await import("${UNWASM_EXTERNAL_PREFIX}${asset.name}").then(r => r.default || r);
|
||||
return WebAssembly.instantiate(_mod, imports)
|
||||
}
|
||||
`
|
||||
);
|
||||
}
|
||||
function getBase64Instantiate(asset, importsCode) {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
import { base64ToUint8Array } from "${UMWASM_HELPERS_ID}";
|
||||
|
||||
${importsCode}
|
||||
|
||||
function _instantiate(imports = _imports) {
|
||||
const _data = base64ToUint8Array("${asset.source.toString("base64")}")
|
||||
return WebAssembly.instantiate(_data, imports) }
|
||||
`
|
||||
);
|
||||
}
|
||||
function getExports(asset, instantiateCode) {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
import { getExports } from "${UMWASM_HELPERS_ID}";
|
||||
|
||||
${instantiateCode}
|
||||
|
||||
const $exports = getExports(await _instantiate());
|
||||
|
||||
${asset.exports.map((name) => `export const ${name} = $exports.${name};`).join("\n")}
|
||||
|
||||
const defaultExport = () => $exports;
|
||||
${asset.exports.map((name) => `defaultExport["${name}"] = $exports.${name};`).join("\n")}
|
||||
export default defaultExport;
|
||||
`
|
||||
);
|
||||
}
|
||||
function getLazyExports(asset, instantiateCode) {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
import { createLazyWasmModule } from "${UMWASM_HELPERS_ID}";
|
||||
|
||||
${instantiateCode}
|
||||
|
||||
const _mod = createLazyWasmModule(_instantiate);
|
||||
|
||||
${asset.exports.map((name) => `export const ${name} = _mod.${name};`).join("\n")}
|
||||
|
||||
export default _mod;
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
function getPluginUtils() {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
export function debug(...args) {
|
||||
console.log('[unwasm] [debug]', ...args);
|
||||
}
|
||||
|
||||
export function getExports(input) {
|
||||
return input?.instance?.exports || input?.exports || input;
|
||||
}
|
||||
|
||||
export function base64ToUint8Array(str) {
|
||||
const data = atob(str);
|
||||
const size = data.length;
|
||||
const bytes = new Uint8Array(size);
|
||||
for (let i = 0; i < size; i++) {
|
||||
bytes[i] = data.charCodeAt(i);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
export function createLazyWasmModule(_instantiator) {
|
||||
const _exports = Object.create(null);
|
||||
let _loaded;
|
||||
let _promise;
|
||||
|
||||
const init = (imports) => {
|
||||
if (_loaded) {
|
||||
return Promise.resolve(exportsProxy);
|
||||
}
|
||||
if (_promise) {
|
||||
return _promise;
|
||||
}
|
||||
return _promise = _instantiator(imports)
|
||||
.then(r => {
|
||||
Object.assign(_exports, getExports(r));
|
||||
_loaded = true;
|
||||
_promise = undefined;
|
||||
return exportsProxy;
|
||||
})
|
||||
.catch(error => {
|
||||
_promise = undefined;
|
||||
console.error('[wasm] [error]', error);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
const exportsProxy = new Proxy(_exports, {
|
||||
get(_, prop) {
|
||||
if (_loaded) {
|
||||
return _exports[prop];
|
||||
}
|
||||
return (...args) => {
|
||||
return _loaded
|
||||
? _exports[prop]?.(...args)
|
||||
: init().then(() => _exports[prop]?.(...args));
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const lazyProxy = new Proxy(() => {}, {
|
||||
get(_, prop) {
|
||||
return exportsProxy[prop];
|
||||
},
|
||||
apply(_, __, args) {
|
||||
return init(args[0])
|
||||
},
|
||||
});
|
||||
|
||||
return lazyProxy;
|
||||
}
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
const WASM_ID_RE = /\.wasm\??.*$/i;
|
||||
const unplugin = unplugin$1.createUnplugin((opts) => {
|
||||
const assets = /* @__PURE__ */ Object.create(null);
|
||||
const _parseCache = /* @__PURE__ */ Object.create(null);
|
||||
function parse(name, source) {
|
||||
if (_parseCache[name]) {
|
||||
return _parseCache[name];
|
||||
}
|
||||
const imports = /* @__PURE__ */ Object.create(null);
|
||||
const exports = [];
|
||||
try {
|
||||
const parsed = tools.parseWasm(source, { name });
|
||||
for (const mod of parsed.modules) {
|
||||
exports.push(...mod.exports.map((e) => e.name));
|
||||
for (const imp of mod.imports) {
|
||||
if (!imports[imp.module]) {
|
||||
imports[imp.module] = [];
|
||||
}
|
||||
imports[imp.module].push(imp.name);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`[unwasm] Failed to parse WASM module ${name}:`, error);
|
||||
}
|
||||
_parseCache[name] = {
|
||||
imports,
|
||||
exports
|
||||
};
|
||||
return _parseCache[name];
|
||||
}
|
||||
return {
|
||||
name: "unwasm",
|
||||
rollup: {
|
||||
async resolveId(id, importer) {
|
||||
if (id === UMWASM_HELPERS_ID) {
|
||||
return id;
|
||||
}
|
||||
if (id.startsWith(UNWASM_EXTERNAL_PREFIX)) {
|
||||
return {
|
||||
id,
|
||||
external: true
|
||||
};
|
||||
}
|
||||
if (WASM_ID_RE.test(id)) {
|
||||
const r = await this.resolve(id, importer, { skipSelf: true });
|
||||
if (r?.id && r.id !== id) {
|
||||
return {
|
||||
id: r.id.startsWith("file://") ? r.id.slice(7) : r.id,
|
||||
external: false,
|
||||
moduleSideEffects: false
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
generateBundle() {
|
||||
if (opts.esmImport) {
|
||||
for (const asset of Object.values(assets)) {
|
||||
this.emitFile({
|
||||
type: "asset",
|
||||
source: asset.source,
|
||||
fileName: asset.name
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
async load(id) {
|
||||
if (id === UMWASM_HELPERS_ID) {
|
||||
return getPluginUtils();
|
||||
}
|
||||
if (!WASM_ID_RE.test(id)) {
|
||||
return;
|
||||
}
|
||||
const idPath = id.split("?")[0];
|
||||
if (!node_fs.existsSync(idPath)) {
|
||||
return;
|
||||
}
|
||||
this.addWatchFile(idPath);
|
||||
const buff = await node_fs.promises.readFile(idPath);
|
||||
return buff.toString("binary");
|
||||
},
|
||||
async transform(code, id) {
|
||||
if (!WASM_ID_RE.test(id)) {
|
||||
return;
|
||||
}
|
||||
const buff = Buffer.from(code, "binary");
|
||||
const isModule = id.endsWith("?module");
|
||||
const name = `wasm/${pathe.basename(id.split("?")[0], ".wasm")}-${sha1(buff)}.wasm`;
|
||||
const parsed = isModule ? { imports: [], exports: ["default"] } : parse(name, buff);
|
||||
const asset = assets[name] = {
|
||||
name,
|
||||
id,
|
||||
source: buff,
|
||||
imports: parsed.imports,
|
||||
exports: parsed.exports
|
||||
};
|
||||
return {
|
||||
code: isModule ? await getWasmModuleBinding(asset, opts) : await getWasmESMBinding(asset, opts),
|
||||
map: { mappings: "" }
|
||||
};
|
||||
},
|
||||
renderChunk(code, chunk) {
|
||||
if (!opts.esmImport) {
|
||||
return;
|
||||
}
|
||||
if (!(chunk.moduleIds.some((id) => WASM_ID_RE.test(id)) || chunk.imports.some((id) => WASM_ID_RE.test(id)))) {
|
||||
return;
|
||||
}
|
||||
const s = new MagicString__default(code);
|
||||
const resolveImport = (id) => {
|
||||
if (typeof id !== "string") {
|
||||
return;
|
||||
}
|
||||
const asset = assets[id];
|
||||
if (!asset) {
|
||||
return;
|
||||
}
|
||||
const nestedLevel = chunk.fileName.split("/").filter(
|
||||
Boolean
|
||||
/* handle // */
|
||||
).length - 1;
|
||||
const relativeId = (nestedLevel ? "../".repeat(nestedLevel) : "./") + asset.name;
|
||||
return {
|
||||
relativeId,
|
||||
asset
|
||||
};
|
||||
};
|
||||
for (const match of code.matchAll(UNWASM_EXTERNAL_RE)) {
|
||||
const resolved = resolveImport(match[2]);
|
||||
const index = match.index;
|
||||
const len = match[0].length;
|
||||
if (!resolved || !index) {
|
||||
console.warn(
|
||||
`Failed to resolve WASM import: ${JSON.stringify(match[1])}`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
s.overwrite(index, index + len, resolved.relativeId);
|
||||
}
|
||||
if (s.hasChanged()) {
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap({ includeContent: true })
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
const rollup = unplugin.rollup;
|
||||
const index = {
|
||||
rollup
|
||||
};
|
||||
|
||||
exports.default = index;
|
||||
exports.rollup = rollup;
|
||||
28
Frontend-Learner/node_modules/unwasm/dist/plugin.d.cts
generated
vendored
Normal file
28
Frontend-Learner/node_modules/unwasm/dist/plugin.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { Plugin } from 'rollup';
|
||||
|
||||
interface UnwasmPluginOptions {
|
||||
/**
|
||||
* Directly import the `.wasm` files instead of bundling as base64 string.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
esmImport?: boolean;
|
||||
/**
|
||||
* Avoid using top level await and always use a proxy.
|
||||
*
|
||||
* Useful for compatibility with environments that don't support top level await.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
lazy?: boolean;
|
||||
}
|
||||
|
||||
declare const rollup: (opts: UnwasmPluginOptions) => Plugin;
|
||||
declare const _default: {
|
||||
rollup: (opts: UnwasmPluginOptions) => Plugin;
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
export = _default;
|
||||
export { rollup };
|
||||
export type { UnwasmPluginOptions };
|
||||
26
Frontend-Learner/node_modules/unwasm/dist/plugin.d.mts
generated
vendored
Normal file
26
Frontend-Learner/node_modules/unwasm/dist/plugin.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { Plugin } from 'rollup';
|
||||
|
||||
interface UnwasmPluginOptions {
|
||||
/**
|
||||
* Directly import the `.wasm` files instead of bundling as base64 string.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
esmImport?: boolean;
|
||||
/**
|
||||
* Avoid using top level await and always use a proxy.
|
||||
*
|
||||
* Useful for compatibility with environments that don't support top level await.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
lazy?: boolean;
|
||||
}
|
||||
|
||||
declare const rollup: (opts: UnwasmPluginOptions) => Plugin;
|
||||
declare const _default: {
|
||||
rollup: (opts: UnwasmPluginOptions) => Plugin;
|
||||
};
|
||||
|
||||
export { _default as default, rollup };
|
||||
export type { UnwasmPluginOptions };
|
||||
28
Frontend-Learner/node_modules/unwasm/dist/plugin.d.ts
generated
vendored
Normal file
28
Frontend-Learner/node_modules/unwasm/dist/plugin.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { Plugin } from 'rollup';
|
||||
|
||||
interface UnwasmPluginOptions {
|
||||
/**
|
||||
* Directly import the `.wasm` files instead of bundling as base64 string.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
esmImport?: boolean;
|
||||
/**
|
||||
* Avoid using top level await and always use a proxy.
|
||||
*
|
||||
* Useful for compatibility with environments that don't support top level await.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
lazy?: boolean;
|
||||
}
|
||||
|
||||
declare const rollup: (opts: UnwasmPluginOptions) => Plugin;
|
||||
declare const _default: {
|
||||
rollup: (opts: UnwasmPluginOptions) => Plugin;
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
export = _default;
|
||||
export { rollup };
|
||||
export type { UnwasmPluginOptions };
|
||||
368
Frontend-Learner/node_modules/unwasm/dist/plugin.mjs
generated
vendored
Normal file
368
Frontend-Learner/node_modules/unwasm/dist/plugin.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,368 @@
|
|||
import { existsSync, promises } from 'node:fs';
|
||||
import { basename } from 'pathe';
|
||||
import MagicString from 'magic-string';
|
||||
import { createUnplugin } from 'unplugin';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { genSafeVariableName, genImport, genString, genObjectFromRaw } from 'knitwork';
|
||||
import { parseWasm } from './tools.mjs';
|
||||
|
||||
const UNWASM_EXTERNAL_PREFIX = "\0unwasm:external:";
|
||||
const UNWASM_EXTERNAL_RE = /(\0|\\0)unwasm:external:([^"']+)/gu;
|
||||
const UMWASM_HELPERS_ID = "\0unwasm:helpers";
|
||||
function sha1(source) {
|
||||
return createHash("sha1").update(source).digest("hex").slice(0, 16);
|
||||
}
|
||||
|
||||
async function getWasmImports(asset, _opts) {
|
||||
const importNames = Object.keys(asset.imports || {});
|
||||
if (importNames.length === 0) {
|
||||
return {
|
||||
code: "const _imports = { /* no imports */ }",
|
||||
resolved: true
|
||||
};
|
||||
}
|
||||
const { readPackageJSON } = await import('pkg-types');
|
||||
const pkgJSON = await readPackageJSON(asset.id);
|
||||
let resolved = true;
|
||||
const imports = [];
|
||||
const importsObject = {};
|
||||
for (const moduleName of importNames) {
|
||||
const importNames2 = asset.imports[moduleName];
|
||||
const pkgImport = pkgJSON.imports?.[moduleName] || pkgJSON.imports?.[`#${moduleName}`];
|
||||
const importName = "_imports_" + genSafeVariableName(moduleName);
|
||||
if (pkgImport && typeof pkgImport === "string") {
|
||||
imports.push(genImport(pkgImport, { name: "*", as: importName }));
|
||||
} else {
|
||||
resolved = false;
|
||||
}
|
||||
importsObject[moduleName] = Object.fromEntries(
|
||||
importNames2.map((name) => [
|
||||
name,
|
||||
pkgImport ? `${importName}[${genString(name)}]` : `() => { throw new Error(${genString(moduleName + "." + importName)} + " is not provided!")}`
|
||||
])
|
||||
);
|
||||
}
|
||||
const code = `${imports.join("\n")}
|
||||
|
||||
const _imports = ${genObjectFromRaw(importsObject)}`;
|
||||
return {
|
||||
code,
|
||||
resolved
|
||||
};
|
||||
}
|
||||
|
||||
async function getWasmESMBinding(asset, opts) {
|
||||
const autoImports = await getWasmImports(asset);
|
||||
const instantiateCode = opts.esmImport ? getESMImportInstantiate(asset, autoImports.code) : getBase64Instantiate(asset, autoImports.code);
|
||||
return opts.lazy !== true && autoImports.resolved ? getExports(asset, instantiateCode) : getLazyExports(asset, instantiateCode);
|
||||
}
|
||||
function getWasmModuleBinding(asset, opts) {
|
||||
return opts.esmImport ? (
|
||||
/* js */
|
||||
`
|
||||
const _mod = ${opts.lazy === true ? "" : `await`} import("${UNWASM_EXTERNAL_PREFIX}${asset.name}").then(r => r.default || r);
|
||||
export default _mod;
|
||||
`
|
||||
) : (
|
||||
/* js */
|
||||
`
|
||||
import { base64ToUint8Array } from "${UMWASM_HELPERS_ID}";
|
||||
const _data = base64ToUint8Array("${asset.source.toString("base64")}");
|
||||
const _mod = new WebAssembly.Module(_data);
|
||||
export default _mod;
|
||||
`
|
||||
);
|
||||
}
|
||||
function getESMImportInstantiate(asset, importsCode) {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
${importsCode}
|
||||
|
||||
async function _instantiate(imports = _imports) {
|
||||
const _mod = await import("${UNWASM_EXTERNAL_PREFIX}${asset.name}").then(r => r.default || r);
|
||||
return WebAssembly.instantiate(_mod, imports)
|
||||
}
|
||||
`
|
||||
);
|
||||
}
|
||||
function getBase64Instantiate(asset, importsCode) {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
import { base64ToUint8Array } from "${UMWASM_HELPERS_ID}";
|
||||
|
||||
${importsCode}
|
||||
|
||||
function _instantiate(imports = _imports) {
|
||||
const _data = base64ToUint8Array("${asset.source.toString("base64")}")
|
||||
return WebAssembly.instantiate(_data, imports) }
|
||||
`
|
||||
);
|
||||
}
|
||||
function getExports(asset, instantiateCode) {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
import { getExports } from "${UMWASM_HELPERS_ID}";
|
||||
|
||||
${instantiateCode}
|
||||
|
||||
const $exports = getExports(await _instantiate());
|
||||
|
||||
${asset.exports.map((name) => `export const ${name} = $exports.${name};`).join("\n")}
|
||||
|
||||
const defaultExport = () => $exports;
|
||||
${asset.exports.map((name) => `defaultExport["${name}"] = $exports.${name};`).join("\n")}
|
||||
export default defaultExport;
|
||||
`
|
||||
);
|
||||
}
|
||||
function getLazyExports(asset, instantiateCode) {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
import { createLazyWasmModule } from "${UMWASM_HELPERS_ID}";
|
||||
|
||||
${instantiateCode}
|
||||
|
||||
const _mod = createLazyWasmModule(_instantiate);
|
||||
|
||||
${asset.exports.map((name) => `export const ${name} = _mod.${name};`).join("\n")}
|
||||
|
||||
export default _mod;
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
function getPluginUtils() {
|
||||
return (
|
||||
/* js */
|
||||
`
|
||||
export function debug(...args) {
|
||||
console.log('[unwasm] [debug]', ...args);
|
||||
}
|
||||
|
||||
export function getExports(input) {
|
||||
return input?.instance?.exports || input?.exports || input;
|
||||
}
|
||||
|
||||
export function base64ToUint8Array(str) {
|
||||
const data = atob(str);
|
||||
const size = data.length;
|
||||
const bytes = new Uint8Array(size);
|
||||
for (let i = 0; i < size; i++) {
|
||||
bytes[i] = data.charCodeAt(i);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
export function createLazyWasmModule(_instantiator) {
|
||||
const _exports = Object.create(null);
|
||||
let _loaded;
|
||||
let _promise;
|
||||
|
||||
const init = (imports) => {
|
||||
if (_loaded) {
|
||||
return Promise.resolve(exportsProxy);
|
||||
}
|
||||
if (_promise) {
|
||||
return _promise;
|
||||
}
|
||||
return _promise = _instantiator(imports)
|
||||
.then(r => {
|
||||
Object.assign(_exports, getExports(r));
|
||||
_loaded = true;
|
||||
_promise = undefined;
|
||||
return exportsProxy;
|
||||
})
|
||||
.catch(error => {
|
||||
_promise = undefined;
|
||||
console.error('[wasm] [error]', error);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
const exportsProxy = new Proxy(_exports, {
|
||||
get(_, prop) {
|
||||
if (_loaded) {
|
||||
return _exports[prop];
|
||||
}
|
||||
return (...args) => {
|
||||
return _loaded
|
||||
? _exports[prop]?.(...args)
|
||||
: init().then(() => _exports[prop]?.(...args));
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const lazyProxy = new Proxy(() => {}, {
|
||||
get(_, prop) {
|
||||
return exportsProxy[prop];
|
||||
},
|
||||
apply(_, __, args) {
|
||||
return init(args[0])
|
||||
},
|
||||
});
|
||||
|
||||
return lazyProxy;
|
||||
}
|
||||
`
|
||||
);
|
||||
}
|
||||
|
||||
const WASM_ID_RE = /\.wasm\??.*$/i;
|
||||
const unplugin = createUnplugin((opts) => {
|
||||
const assets = /* @__PURE__ */ Object.create(null);
|
||||
const _parseCache = /* @__PURE__ */ Object.create(null);
|
||||
function parse(name, source) {
|
||||
if (_parseCache[name]) {
|
||||
return _parseCache[name];
|
||||
}
|
||||
const imports = /* @__PURE__ */ Object.create(null);
|
||||
const exports = [];
|
||||
try {
|
||||
const parsed = parseWasm(source, { name });
|
||||
for (const mod of parsed.modules) {
|
||||
exports.push(...mod.exports.map((e) => e.name));
|
||||
for (const imp of mod.imports) {
|
||||
if (!imports[imp.module]) {
|
||||
imports[imp.module] = [];
|
||||
}
|
||||
imports[imp.module].push(imp.name);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`[unwasm] Failed to parse WASM module ${name}:`, error);
|
||||
}
|
||||
_parseCache[name] = {
|
||||
imports,
|
||||
exports
|
||||
};
|
||||
return _parseCache[name];
|
||||
}
|
||||
return {
|
||||
name: "unwasm",
|
||||
rollup: {
|
||||
async resolveId(id, importer) {
|
||||
if (id === UMWASM_HELPERS_ID) {
|
||||
return id;
|
||||
}
|
||||
if (id.startsWith(UNWASM_EXTERNAL_PREFIX)) {
|
||||
return {
|
||||
id,
|
||||
external: true
|
||||
};
|
||||
}
|
||||
if (WASM_ID_RE.test(id)) {
|
||||
const r = await this.resolve(id, importer, { skipSelf: true });
|
||||
if (r?.id && r.id !== id) {
|
||||
return {
|
||||
id: r.id.startsWith("file://") ? r.id.slice(7) : r.id,
|
||||
external: false,
|
||||
moduleSideEffects: false
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
generateBundle() {
|
||||
if (opts.esmImport) {
|
||||
for (const asset of Object.values(assets)) {
|
||||
this.emitFile({
|
||||
type: "asset",
|
||||
source: asset.source,
|
||||
fileName: asset.name
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
async load(id) {
|
||||
if (id === UMWASM_HELPERS_ID) {
|
||||
return getPluginUtils();
|
||||
}
|
||||
if (!WASM_ID_RE.test(id)) {
|
||||
return;
|
||||
}
|
||||
const idPath = id.split("?")[0];
|
||||
if (!existsSync(idPath)) {
|
||||
return;
|
||||
}
|
||||
this.addWatchFile(idPath);
|
||||
const buff = await promises.readFile(idPath);
|
||||
return buff.toString("binary");
|
||||
},
|
||||
async transform(code, id) {
|
||||
if (!WASM_ID_RE.test(id)) {
|
||||
return;
|
||||
}
|
||||
const buff = Buffer.from(code, "binary");
|
||||
const isModule = id.endsWith("?module");
|
||||
const name = `wasm/${basename(id.split("?")[0], ".wasm")}-${sha1(buff)}.wasm`;
|
||||
const parsed = isModule ? { imports: [], exports: ["default"] } : parse(name, buff);
|
||||
const asset = assets[name] = {
|
||||
name,
|
||||
id,
|
||||
source: buff,
|
||||
imports: parsed.imports,
|
||||
exports: parsed.exports
|
||||
};
|
||||
return {
|
||||
code: isModule ? await getWasmModuleBinding(asset, opts) : await getWasmESMBinding(asset, opts),
|
||||
map: { mappings: "" }
|
||||
};
|
||||
},
|
||||
renderChunk(code, chunk) {
|
||||
if (!opts.esmImport) {
|
||||
return;
|
||||
}
|
||||
if (!(chunk.moduleIds.some((id) => WASM_ID_RE.test(id)) || chunk.imports.some((id) => WASM_ID_RE.test(id)))) {
|
||||
return;
|
||||
}
|
||||
const s = new MagicString(code);
|
||||
const resolveImport = (id) => {
|
||||
if (typeof id !== "string") {
|
||||
return;
|
||||
}
|
||||
const asset = assets[id];
|
||||
if (!asset) {
|
||||
return;
|
||||
}
|
||||
const nestedLevel = chunk.fileName.split("/").filter(
|
||||
Boolean
|
||||
/* handle // */
|
||||
).length - 1;
|
||||
const relativeId = (nestedLevel ? "../".repeat(nestedLevel) : "./") + asset.name;
|
||||
return {
|
||||
relativeId,
|
||||
asset
|
||||
};
|
||||
};
|
||||
for (const match of code.matchAll(UNWASM_EXTERNAL_RE)) {
|
||||
const resolved = resolveImport(match[2]);
|
||||
const index = match.index;
|
||||
const len = match[0].length;
|
||||
if (!resolved || !index) {
|
||||
console.warn(
|
||||
`Failed to resolve WASM import: ${JSON.stringify(match[1])}`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
s.overwrite(index, index + len, resolved.relativeId);
|
||||
}
|
||||
if (s.hasChanged()) {
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap({ includeContent: true })
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
const rollup = unplugin.rollup;
|
||||
const index = {
|
||||
rollup
|
||||
};
|
||||
|
||||
export { index as default, rollup };
|
||||
6598
Frontend-Learner/node_modules/unwasm/dist/tools.cjs
generated
vendored
Normal file
6598
Frontend-Learner/node_modules/unwasm/dist/tools.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
28
Frontend-Learner/node_modules/unwasm/dist/tools.d.cts
generated
vendored
Normal file
28
Frontend-Learner/node_modules/unwasm/dist/tools.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
type ParsedWasmModule = {
|
||||
id?: string;
|
||||
imports: ModuleImport[];
|
||||
exports: ModuleExport[];
|
||||
};
|
||||
type ModuleImport = {
|
||||
module: string;
|
||||
name: string;
|
||||
returnType?: string;
|
||||
params?: {
|
||||
id?: string;
|
||||
type: string;
|
||||
}[];
|
||||
};
|
||||
type ModuleExport = {
|
||||
name: string;
|
||||
id: string | number;
|
||||
type: "Func" | "Memory";
|
||||
};
|
||||
type ParseResult = {
|
||||
modules: ParsedWasmModule[];
|
||||
};
|
||||
declare function parseWasm(source: Buffer | ArrayBuffer, opts?: {
|
||||
name?: string;
|
||||
}): ParseResult;
|
||||
|
||||
export { parseWasm };
|
||||
export type { ModuleExport, ModuleImport, ParseResult, ParsedWasmModule };
|
||||
28
Frontend-Learner/node_modules/unwasm/dist/tools.d.mts
generated
vendored
Normal file
28
Frontend-Learner/node_modules/unwasm/dist/tools.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
type ParsedWasmModule = {
|
||||
id?: string;
|
||||
imports: ModuleImport[];
|
||||
exports: ModuleExport[];
|
||||
};
|
||||
type ModuleImport = {
|
||||
module: string;
|
||||
name: string;
|
||||
returnType?: string;
|
||||
params?: {
|
||||
id?: string;
|
||||
type: string;
|
||||
}[];
|
||||
};
|
||||
type ModuleExport = {
|
||||
name: string;
|
||||
id: string | number;
|
||||
type: "Func" | "Memory";
|
||||
};
|
||||
type ParseResult = {
|
||||
modules: ParsedWasmModule[];
|
||||
};
|
||||
declare function parseWasm(source: Buffer | ArrayBuffer, opts?: {
|
||||
name?: string;
|
||||
}): ParseResult;
|
||||
|
||||
export { parseWasm };
|
||||
export type { ModuleExport, ModuleImport, ParseResult, ParsedWasmModule };
|
||||
28
Frontend-Learner/node_modules/unwasm/dist/tools.d.ts
generated
vendored
Normal file
28
Frontend-Learner/node_modules/unwasm/dist/tools.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
type ParsedWasmModule = {
|
||||
id?: string;
|
||||
imports: ModuleImport[];
|
||||
exports: ModuleExport[];
|
||||
};
|
||||
type ModuleImport = {
|
||||
module: string;
|
||||
name: string;
|
||||
returnType?: string;
|
||||
params?: {
|
||||
id?: string;
|
||||
type: string;
|
||||
}[];
|
||||
};
|
||||
type ModuleExport = {
|
||||
name: string;
|
||||
id: string | number;
|
||||
type: "Func" | "Memory";
|
||||
};
|
||||
type ParseResult = {
|
||||
modules: ParsedWasmModule[];
|
||||
};
|
||||
declare function parseWasm(source: Buffer | ArrayBuffer, opts?: {
|
||||
name?: string;
|
||||
}): ParseResult;
|
||||
|
||||
export { parseWasm };
|
||||
export type { ModuleExport, ModuleImport, ParseResult, ParsedWasmModule };
|
||||
6596
Frontend-Learner/node_modules/unwasm/dist/tools.mjs
generated
vendored
Normal file
6596
Frontend-Learner/node_modules/unwasm/dist/tools.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
20
Frontend-Learner/node_modules/unwasm/examples/build.mjs
generated
vendored
Normal file
20
Frontend-Learner/node_modules/unwasm/examples/build.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { fileURLToPath } from "node:url";
|
||||
import { main as asc } from "assemblyscript/asc";
|
||||
|
||||
async function compile(name) {
|
||||
// https://www.assemblyscript.org/compiler.html#programmatic-usage
|
||||
const res = await asc([`${name}.asc.ts`, "-o", `${name}.wasm`], {});
|
||||
|
||||
if (res.error) {
|
||||
console.log(`Compilation failed for ${name}:`, res.error);
|
||||
console.log(res.stderr.toString());
|
||||
} else {
|
||||
console.log(`Compiled: ${name}.wasm`);
|
||||
console.log(res.stdout.toString());
|
||||
}
|
||||
}
|
||||
|
||||
process.chdir(fileURLToPath(new URL(".", import.meta.url)));
|
||||
|
||||
await compile("sum");
|
||||
await compile("rand");
|
||||
1
Frontend-Learner/node_modules/unwasm/examples/env.mjs
generated
vendored
Normal file
1
Frontend-Learner/node_modules/unwasm/examples/env.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export const seed = () => Math.random() * Date.now()
|
||||
5
Frontend-Learner/node_modules/unwasm/examples/package.json
generated
vendored
Normal file
5
Frontend-Learner/node_modules/unwasm/examples/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"imports": {
|
||||
"#env": "./env.mjs"
|
||||
}
|
||||
}
|
||||
BIN
Frontend-Learner/node_modules/unwasm/examples/rand.wasm
generated
vendored
Normal file
BIN
Frontend-Learner/node_modules/unwasm/examples/rand.wasm
generated
vendored
Normal file
Binary file not shown.
BIN
Frontend-Learner/node_modules/unwasm/examples/sum.wasm
generated
vendored
Normal file
BIN
Frontend-Learner/node_modules/unwasm/examples/sum.wasm
generated
vendored
Normal file
Binary file not shown.
87
Frontend-Learner/node_modules/unwasm/package.json
generated
vendored
Normal file
87
Frontend-Learner/node_modules/unwasm/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
"name": "unwasm",
|
||||
"version": "0.3.11",
|
||||
"description": "WebAssembly tools for JavaScript",
|
||||
"repository": "unjs/unwasm",
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./examples/*": "./examples/*",
|
||||
"./plugin": {
|
||||
"import": {
|
||||
"types": "./dist/plugin.d.mts",
|
||||
"default": "./dist/plugin.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/plugin.d.ts",
|
||||
"default": "./dist/plugin.cjs"
|
||||
}
|
||||
},
|
||||
"./tools": {
|
||||
"import": {
|
||||
"types": "./dist/tools.d.mts",
|
||||
"default": "./dist/tools.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/tools.d.ts",
|
||||
"default": "./dist/tools.cjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"*.d.ts",
|
||||
"examples/*.wasm",
|
||||
"examples/package.json",
|
||||
"examples/*.mjs"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "unbuild && pnpm build:examples",
|
||||
"build:examples": "node ./examples/build.mjs",
|
||||
"dev": "vitest dev",
|
||||
"lint": "eslint --cache . && prettier -c src test",
|
||||
"lint:fix": "eslint --cache . --fix && prettier -c src test -w",
|
||||
"prepack": "pnpm build",
|
||||
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
|
||||
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
|
||||
"test:types": "tsc --noEmit --skipLibCheck"
|
||||
},
|
||||
"dependencies": {
|
||||
"knitwork": "^1.2.0",
|
||||
"magic-string": "^0.30.17",
|
||||
"mlly": "^1.7.4",
|
||||
"pathe": "^2.0.3",
|
||||
"pkg-types": "^2.2.0",
|
||||
"unplugin": "^2.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@prisma/client": "^6.14.0",
|
||||
"@rollup/plugin-node-resolve": "^16.0.1",
|
||||
"@types/node": "^24.3.0",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"@webassemblyjs/wasm-parser": "^1.14.1",
|
||||
"assemblyscript": "^0.28.4",
|
||||
"automd": "^0.4.0",
|
||||
"changelogen": "^0.6.2",
|
||||
"esbuild": "^0.25.9",
|
||||
"eslint": "^9.33.0",
|
||||
"eslint-config-unjs": "^0.5.0",
|
||||
"exsolve": "^1.0.7",
|
||||
"jiti": "^2.5.1",
|
||||
"miniflare": "^4.20250813.1",
|
||||
"prettier": "^3.6.2",
|
||||
"rollup": "^4.46.3",
|
||||
"typescript": "^5.9.2",
|
||||
"unbuild": "^3.6.1",
|
||||
"vite": "^7.1.2",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"resolutions": {
|
||||
"@webassemblyjs/helper-wasm-bytecode": "1.14.1",
|
||||
"@webassemblyjs/ieee754": "1.14.1",
|
||||
"@webassemblyjs/leb128": "1.14.1",
|
||||
"@webassemblyjs/utf8": "1.14.1"
|
||||
},
|
||||
"packageManager": "pnpm@10.14.0"
|
||||
}
|
||||
3
Frontend-Learner/node_modules/unwasm/plugin.d.ts
generated
vendored
Normal file
3
Frontend-Learner/node_modules/unwasm/plugin.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export * from "./dist/plugin";
|
||||
|
||||
export { default } from "./dist/plugin";
|
||||
Loading…
Add table
Add a link
Reference in a new issue