@danielsimonjr/mathts-matrix 0.6.2 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -8
- package/dist/integrity-LIWCCDIJ.js +13 -0
- package/dist/resolve-DDCEWHWX.js +8 -0
- package/package.json +3 -3
- package/dist/integrity-X3CLNVGW.js +0 -78
- package/dist/resolve-VJX3YTS6.js +0 -43
package/dist/index.js
CHANGED
|
@@ -2499,7 +2499,7 @@ var WASMBackend = class {
|
|
|
2499
2499
|
*/
|
|
2500
2500
|
async resolveAsWasmPath() {
|
|
2501
2501
|
const isNode = typeof process !== "undefined" && process.versions?.node !== void 0;
|
|
2502
|
-
const { resolvePackagedWasm, defaultWasmLocation } = await import("./resolve-
|
|
2502
|
+
const { resolvePackagedWasm, defaultWasmLocation } = await import("./resolve-DDCEWHWX.js");
|
|
2503
2503
|
if (isNode) {
|
|
2504
2504
|
const found = await resolvePackagedWasm(import.meta.url, "mathts-as.wasm");
|
|
2505
2505
|
if (found) return found;
|
|
@@ -2525,7 +2525,7 @@ var WASMBackend = class {
|
|
|
2525
2525
|
Date
|
|
2526
2526
|
};
|
|
2527
2527
|
const isNode = typeof process !== "undefined" && process.versions?.node !== void 0;
|
|
2528
|
-
const { loadWasmManifest, verifyWasmIntegrity } = await import("./integrity-
|
|
2528
|
+
const { loadWasmManifest, verifyWasmIntegrity } = await import("./integrity-LIWCCDIJ.js");
|
|
2529
2529
|
let instance;
|
|
2530
2530
|
if (isNode) {
|
|
2531
2531
|
const fs = await import("fs");
|
|
@@ -4289,7 +4289,7 @@ var WasmLoader = class _WasmLoader {
|
|
|
4289
4289
|
if (this.compiledModule) return;
|
|
4290
4290
|
const path = wasmPath || await this.getDefaultWasmPath();
|
|
4291
4291
|
const startTime = performance.now();
|
|
4292
|
-
const { loadWasmManifest, verifyWasmIntegrity } = await import("./integrity-
|
|
4292
|
+
const { loadWasmManifest, verifyWasmIntegrity } = await import("./integrity-LIWCCDIJ.js");
|
|
4293
4293
|
if (this.isNode) {
|
|
4294
4294
|
const fs = await import("fs");
|
|
4295
4295
|
const { promisify } = await import("util");
|
|
@@ -4350,20 +4350,20 @@ var WasmLoader = class _WasmLoader {
|
|
|
4350
4350
|
async getDefaultWasmPath() {
|
|
4351
4351
|
const wasmFile = "mathts-as.wasm";
|
|
4352
4352
|
if (this.isNode) {
|
|
4353
|
-
const { resolvePackagedWasm } = await import("./resolve-
|
|
4353
|
+
const { resolvePackagedWasm } = await import("./resolve-DDCEWHWX.js");
|
|
4354
4354
|
const found = await resolvePackagedWasm(import.meta.url, wasmFile);
|
|
4355
4355
|
if (found) return found;
|
|
4356
|
-
const { defaultWasmLocation: defaultWasmLocation2 } = await import("./resolve-
|
|
4356
|
+
const { defaultWasmLocation: defaultWasmLocation2 } = await import("./resolve-DDCEWHWX.js");
|
|
4357
4357
|
return defaultWasmLocation2(import.meta.url, wasmFile);
|
|
4358
4358
|
}
|
|
4359
|
-
const { defaultWasmLocation } = await import("./resolve-
|
|
4359
|
+
const { defaultWasmLocation } = await import("./resolve-DDCEWHWX.js");
|
|
4360
4360
|
return defaultWasmLocation(import.meta.url, wasmFile, { browser: true });
|
|
4361
4361
|
}
|
|
4362
4362
|
async loadNodeWasm(path, totalStart) {
|
|
4363
4363
|
const fs = await import("fs");
|
|
4364
4364
|
const { promisify } = await import("util");
|
|
4365
4365
|
const readFile = promisify(fs.readFile);
|
|
4366
|
-
const { verifyWasmIntegrity } = await import("./integrity-
|
|
4366
|
+
const { verifyWasmIntegrity } = await import("./integrity-LIWCCDIJ.js");
|
|
4367
4367
|
const readStart = performance.now();
|
|
4368
4368
|
const buffer = await readFile(path);
|
|
4369
4369
|
const readEnd = performance.now();
|
|
@@ -4384,7 +4384,7 @@ var WasmLoader = class _WasmLoader {
|
|
|
4384
4384
|
return instance.exports;
|
|
4385
4385
|
}
|
|
4386
4386
|
async loadBrowserWasm(path, totalStart) {
|
|
4387
|
-
const { loadWasmManifest, verifyWasmIntegrity } = await import("./integrity-
|
|
4387
|
+
const { loadWasmManifest, verifyWasmIntegrity } = await import("./integrity-LIWCCDIJ.js");
|
|
4388
4388
|
const manifest = await loadWasmManifest(path);
|
|
4389
4389
|
if (!manifest && typeof WebAssembly.instantiateStreaming === "function") {
|
|
4390
4390
|
const instStart2 = performance.now();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "./chunk-4VMDO6W2.js";
|
|
2
|
+
|
|
3
|
+
// src/backends/wasm/integrity.ts
|
|
4
|
+
import {
|
|
5
|
+
sha384OfBuffer,
|
|
6
|
+
loadWasmManifest,
|
|
7
|
+
verifyWasmIntegrity
|
|
8
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
9
|
+
export {
|
|
10
|
+
loadWasmManifest,
|
|
11
|
+
sha384OfBuffer,
|
|
12
|
+
verifyWasmIntegrity
|
|
13
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-matrix",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "Matrix operations for MathTS with WASM/WebGPU backend support",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"build:prod": "tsup src/index.ts --format esm --dts --clean --minify --treeshake && node scripts/copy-wasm.mjs"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@danielsimonjr/mathts-core": "^0.
|
|
35
|
+
"@danielsimonjr/mathts-core": "^0.13.0",
|
|
36
36
|
"@danielsimonjr/mathts-gpu": "^0.2.0",
|
|
37
|
-
"@danielsimonjr/mathts-parallel": "^0.6.
|
|
37
|
+
"@danielsimonjr/mathts-parallel": "^0.6.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^25.5.2",
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import "./chunk-4VMDO6W2.js";
|
|
2
|
-
|
|
3
|
-
// src/backends/wasm/integrity.ts
|
|
4
|
-
var ALGO = "sha384";
|
|
5
|
-
async function sha384OfBuffer(buffer) {
|
|
6
|
-
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
7
|
-
const isNode = typeof process !== "undefined" && process.versions?.node !== void 0;
|
|
8
|
-
let digest;
|
|
9
|
-
if (isNode) {
|
|
10
|
-
const { createHash } = await import("crypto");
|
|
11
|
-
const hash = createHash(ALGO);
|
|
12
|
-
hash.update(bytes);
|
|
13
|
-
digest = new Uint8Array(hash.digest());
|
|
14
|
-
} else {
|
|
15
|
-
const copy = new ArrayBuffer(bytes.byteLength);
|
|
16
|
-
new Uint8Array(copy).set(bytes);
|
|
17
|
-
const out = await crypto.subtle.digest("SHA-384", copy);
|
|
18
|
-
digest = new Uint8Array(out);
|
|
19
|
-
}
|
|
20
|
-
let binary = "";
|
|
21
|
-
for (let i = 0; i < digest.length; i++) binary += String.fromCharCode(digest[i]);
|
|
22
|
-
const b64 = typeof btoa === "function" ? btoa(binary) : Buffer.from(digest).toString("base64");
|
|
23
|
-
return `sha384-${b64}`;
|
|
24
|
-
}
|
|
25
|
-
async function loadWasmManifest(wasmPath) {
|
|
26
|
-
const isNode = typeof process !== "undefined" && process.versions?.node !== void 0;
|
|
27
|
-
const manifestPath = wasmPath.replace(/[^/\\]+$/, "wasm-manifest.json");
|
|
28
|
-
try {
|
|
29
|
-
if (isNode) {
|
|
30
|
-
const fs = await import("fs");
|
|
31
|
-
const { promisify } = await import("util");
|
|
32
|
-
const readFile = promisify(fs.readFile);
|
|
33
|
-
const text = await readFile(manifestPath, "utf8");
|
|
34
|
-
return JSON.parse(text);
|
|
35
|
-
} else {
|
|
36
|
-
const res = await fetch(manifestPath);
|
|
37
|
-
if (!res.ok) return null;
|
|
38
|
-
return await res.json();
|
|
39
|
-
}
|
|
40
|
-
} catch {
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
async function verifyWasmIntegrity(buffer, wasmPath, options = {}) {
|
|
45
|
-
const fileName = wasmPath.split(/[/\\]/).pop() || wasmPath;
|
|
46
|
-
const manifest = options.manifest !== void 0 ? options.manifest : await loadWasmManifest(wasmPath);
|
|
47
|
-
if (!manifest) {
|
|
48
|
-
if (options.required) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
`WASM integrity check failed: no manifest at sibling of "${wasmPath}" (required)`
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
if (typeof console !== "undefined") {
|
|
54
|
-
console.warn(
|
|
55
|
-
`[wasm-integrity] no manifest found beside "${wasmPath}"; skipping SHA-384 verification (set options.required=true to fail closed)`
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const expected = manifest[fileName];
|
|
61
|
-
if (!expected) {
|
|
62
|
-
if (options.required) {
|
|
63
|
-
throw new Error(`WASM integrity check failed: manifest has no entry for "${fileName}"`);
|
|
64
|
-
}
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const actual = await sha384OfBuffer(buffer);
|
|
68
|
-
if (actual !== expected) {
|
|
69
|
-
throw new Error(
|
|
70
|
-
`WASM integrity check failed for "${fileName}": expected ${expected}, got ${actual}`
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export {
|
|
75
|
-
loadWasmManifest,
|
|
76
|
-
sha384OfBuffer,
|
|
77
|
-
verifyWasmIntegrity
|
|
78
|
-
};
|
package/dist/resolve-VJX3YTS6.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import "./chunk-4VMDO6W2.js";
|
|
2
|
-
|
|
3
|
-
// src/backends/wasm/resolve.ts
|
|
4
|
-
async function resolvePackagedWasm(metaUrl, wasmFile) {
|
|
5
|
-
const isNode = typeof process !== "undefined" && process.versions?.node !== void 0;
|
|
6
|
-
if (!isNode) return null;
|
|
7
|
-
const { fileURLToPath } = await import("url");
|
|
8
|
-
const { dirname, join } = await import("path");
|
|
9
|
-
const { existsSync } = await import("fs");
|
|
10
|
-
let dir = dirname(fileURLToPath(metaUrl));
|
|
11
|
-
for (let depth = 0; depth < 8; depth++) {
|
|
12
|
-
const candidates = [join(dir, "wasm", wasmFile), join(dir, "dist", "wasm", wasmFile)];
|
|
13
|
-
for (const candidate of candidates) {
|
|
14
|
-
if (existsSync(candidate)) return candidate;
|
|
15
|
-
}
|
|
16
|
-
const parent = dirname(dir);
|
|
17
|
-
if (parent === dir) break;
|
|
18
|
-
dir = parent;
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
async function defaultWasmLocation(metaUrl, wasmFile, opts) {
|
|
23
|
-
if (opts?.browser) {
|
|
24
|
-
return new URL(`./wasm/${wasmFile}`, metaUrl).href;
|
|
25
|
-
}
|
|
26
|
-
const { fileURLToPath } = await import("url");
|
|
27
|
-
const { dirname, join } = await import("path");
|
|
28
|
-
const { existsSync } = await import("fs");
|
|
29
|
-
let dir = dirname(fileURLToPath(metaUrl));
|
|
30
|
-
for (let depth = 0; depth < 8; depth++) {
|
|
31
|
-
if (existsSync(join(dir, "package.json"))) {
|
|
32
|
-
return join(dir, "dist", "wasm", wasmFile);
|
|
33
|
-
}
|
|
34
|
-
const parent = dirname(dir);
|
|
35
|
-
if (parent === dir) break;
|
|
36
|
-
dir = parent;
|
|
37
|
-
}
|
|
38
|
-
return join(dirname(fileURLToPath(metaUrl)), "wasm", wasmFile);
|
|
39
|
-
}
|
|
40
|
-
export {
|
|
41
|
-
defaultWasmLocation,
|
|
42
|
-
resolvePackagedWasm
|
|
43
|
-
};
|