@danielsimonjr/mathts-core 0.11.0 → 0.13.0
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/{chunk-PALIR4V6.js → chunk-7BUNGMQB.js} +16 -4
- package/dist/index.d.ts +8 -1
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +158 -1
- package/dist/internal.js +117 -1
- package/package.json +1 -1
|
@@ -458,11 +458,19 @@ var Complex = class _Complex {
|
|
|
458
458
|
return this.add(this.multiply(this).add(one).sqrt()).log();
|
|
459
459
|
}
|
|
460
460
|
/**
|
|
461
|
-
* Inverse hyperbolic cosine: acosh(z) = ln(z + √(z
|
|
461
|
+
* Inverse hyperbolic cosine: acosh(z) = ln(z + √(z-1)·√(z+1))
|
|
462
|
+
*
|
|
463
|
+
* The principal value has non-negative real part (C99 Annex G / DLMF 4.37 /
|
|
464
|
+
* NumPy convention). Using the factored `√(z-1)·√(z+1)` rather than `√(z²-1)`
|
|
465
|
+
* selects the correct Riemann sheet for Re(z) < 0 and on the real-axis branch
|
|
466
|
+
* cuts (z < 1), where `√(z²-1)` lands on the wrong branch — the previous form
|
|
467
|
+
* returned a negative real part (e.g. acosh(-1+0.5i)) and the wrong sign of π
|
|
468
|
+
* on z < -1.
|
|
462
469
|
*/
|
|
463
470
|
acosh() {
|
|
464
471
|
const one = new _Complex(1, 0);
|
|
465
|
-
|
|
472
|
+
const s = this.subtract(one).sqrt().multiply(this.add(one).sqrt());
|
|
473
|
+
return this.add(s).log();
|
|
466
474
|
}
|
|
467
475
|
/**
|
|
468
476
|
* Inverse hyperbolic tangent: atanh(z) = (1/2)·ln((1 + z)/(1 - z))
|
|
@@ -2454,10 +2462,13 @@ var BigNumber = class _BigNumber {
|
|
|
2454
2462
|
if (this._sign === 0) return new _BigNumber(0, 0n, 0);
|
|
2455
2463
|
const sign2 = this._sign * b._sign;
|
|
2456
2464
|
const precision = globalConfig.precision;
|
|
2457
|
-
const
|
|
2465
|
+
const aDigits = this._coefficient.toString().length;
|
|
2466
|
+
const bDigits = b._coefficient.toString().length;
|
|
2467
|
+
const scaleDigits = precision + 10 + Math.max(0, bDigits - aDigits);
|
|
2468
|
+
const scale = BigInt(10) ** BigInt(scaleDigits);
|
|
2458
2469
|
const scaledDividend = this._coefficient * scale;
|
|
2459
2470
|
const quotient = scaledDividend / b._coefficient;
|
|
2460
|
-
const exponent = this._exponent - b._exponent -
|
|
2471
|
+
const exponent = this._exponent - b._exponent - scaleDigits;
|
|
2461
2472
|
return this.normalize(sign2, quotient, exponent).roundToPrecision(precision);
|
|
2462
2473
|
}
|
|
2463
2474
|
/**
|
|
@@ -6432,6 +6443,7 @@ export {
|
|
|
6432
6443
|
BIGNUMBER_E,
|
|
6433
6444
|
BIGNUMBER_LN2,
|
|
6434
6445
|
BIGNUMBER_LN10,
|
|
6446
|
+
DEFAULT_CONFIG,
|
|
6435
6447
|
addScalar,
|
|
6436
6448
|
subtractScalar,
|
|
6437
6449
|
multiplyScalar,
|
package/dist/index.d.ts
CHANGED
|
@@ -355,7 +355,14 @@ declare class Complex implements IComplex {
|
|
|
355
355
|
*/
|
|
356
356
|
asinh(): Complex;
|
|
357
357
|
/**
|
|
358
|
-
* Inverse hyperbolic cosine: acosh(z) = ln(z + √(z
|
|
358
|
+
* Inverse hyperbolic cosine: acosh(z) = ln(z + √(z-1)·√(z+1))
|
|
359
|
+
*
|
|
360
|
+
* The principal value has non-negative real part (C99 Annex G / DLMF 4.37 /
|
|
361
|
+
* NumPy convention). Using the factored `√(z-1)·√(z+1)` rather than `√(z²-1)`
|
|
362
|
+
* selects the correct Riemann sheet for Re(z) < 0 and on the real-axis branch
|
|
363
|
+
* cuts (z < 1), where `√(z²-1)` lands on the wrong branch — the previous form
|
|
364
|
+
* returned a negative real part (e.g. acosh(-1+0.5i)) and the wrong sign of π
|
|
365
|
+
* on z < -1.
|
|
359
366
|
*/
|
|
360
367
|
acosh(): Complex;
|
|
361
368
|
/**
|
package/dist/index.js
CHANGED
package/dist/internal.d.ts
CHANGED
|
@@ -479,6 +479,23 @@ declare function pick(object: Record<string, unknown>, properties: string[], tra
|
|
|
479
479
|
*/
|
|
480
480
|
declare function pickShallow(object: Record<string, unknown>, properties: string[]): Record<string, unknown>;
|
|
481
481
|
|
|
482
|
+
/**
|
|
483
|
+
* Configuration interface for math.js
|
|
484
|
+
*/
|
|
485
|
+
interface ConfigOptions {
|
|
486
|
+
relTol: number;
|
|
487
|
+
absTol: number;
|
|
488
|
+
matrix: 'Matrix' | 'Array';
|
|
489
|
+
number: 'number' | 'BigNumber' | 'bigint' | 'Fraction';
|
|
490
|
+
numberFallback: 'number' | 'BigNumber';
|
|
491
|
+
precision: number;
|
|
492
|
+
predictable: boolean;
|
|
493
|
+
randomSeed: string | null;
|
|
494
|
+
legacySubset: boolean;
|
|
495
|
+
}
|
|
496
|
+
type MathJsConfig = ConfigOptions;
|
|
497
|
+
declare const DEFAULT_CONFIG: ConfigOptions;
|
|
498
|
+
|
|
482
499
|
/**
|
|
483
500
|
* Custom error type for Mathjs errors
|
|
484
501
|
* @extends Error
|
|
@@ -1073,6 +1090,15 @@ declare function reduce<T, U>(mat: T[] | Matrix<T>, dim: number, callback: (acc:
|
|
|
1073
1090
|
*/
|
|
1074
1091
|
declare function scatter<T>(a: SparseMatrix<T>, j: number, w: number[], x: T[] | null, u: number[], mark: number, cindex: number[], f?: (a: T, b: T) => T, inverse?: boolean, update?: boolean, value?: T): void;
|
|
1075
1092
|
|
|
1093
|
+
/**
|
|
1094
|
+
* Transpose a 2D array. Private helper used only by `core/src/collection.ts`'s
|
|
1095
|
+
* `_reduce` (Bucket B slice 2 canonical) — mirrors `expression/src/utils/switch.ts`
|
|
1096
|
+
* / `functions/src/utils/switch.ts`, which remain in place unchanged for now
|
|
1097
|
+
* (not part of this slice's named scope). Not exported from `internal.ts`.
|
|
1098
|
+
* @private
|
|
1099
|
+
*/
|
|
1100
|
+
declare function _switch<T>(mat: T[][]): T[][];
|
|
1101
|
+
|
|
1076
1102
|
/**
|
|
1077
1103
|
* A map facade on a bare object.
|
|
1078
1104
|
*
|
|
@@ -1185,4 +1211,135 @@ declare function assign<K = unknown, V = unknown>(map: Map<K, V>, ...objects: (M
|
|
|
1185
1211
|
*/
|
|
1186
1212
|
declare function isObjectWrappingMap(object: unknown): object is ObjectWrappingMap;
|
|
1187
1213
|
|
|
1188
|
-
|
|
1214
|
+
/**
|
|
1215
|
+
* Shared type-only shapes for the two independent WASM loader implementations
|
|
1216
|
+
* (`functions/src/wasm/WasmLoader.ts` and `matrix/src/backends/WasmLoader.ts`).
|
|
1217
|
+
*
|
|
1218
|
+
* Both packages bind to the same `mathts-as.wasm` AssemblyScript binary but each
|
|
1219
|
+
* declares its own package-scoped subset of the exported function ABI (`WasmModule`
|
|
1220
|
+
* genuinely differs between the two — matrix only needs matrix-relevant exports,
|
|
1221
|
+
* functions needs the full breadth including signal/geometry/special-function
|
|
1222
|
+
* kernels — so `WasmModule` stays local to each package). `LoadingMetrics` (perf
|
|
1223
|
+
* timings) and `WasmManifest` (the SHA-384 integrity manifest shape) were,
|
|
1224
|
+
* however, byte-for-byte identical copies with no principled reason to diverge;
|
|
1225
|
+
* consolidated here (cross-package type-dedup pass,
|
|
1226
|
+
* docs/Architecture/duplicate-symbols.json).
|
|
1227
|
+
*
|
|
1228
|
+
* @module @danielsimonjr/mathts-core/types/wasm-loader
|
|
1229
|
+
*/
|
|
1230
|
+
/**
|
|
1231
|
+
* Loading performance metrics for a WASM module load/instantiate cycle.
|
|
1232
|
+
*/
|
|
1233
|
+
interface LoadingMetrics {
|
|
1234
|
+
fileReadMs: number;
|
|
1235
|
+
compileMs: number;
|
|
1236
|
+
instantiateMs: number;
|
|
1237
|
+
totalMs: number;
|
|
1238
|
+
fromCache: boolean;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* SHA-384 integrity manifest: maps a `.wasm` filename to its
|
|
1242
|
+
* `"sha384-<base64 digest>"` value (SRI-style), as generated by
|
|
1243
|
+
* `tools/generate-wasm-manifest.mjs`.
|
|
1244
|
+
*/
|
|
1245
|
+
interface WasmManifest {
|
|
1246
|
+
[fileName: string]: string;
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* Shared WASM-loader runtime logic — SHA-384 integrity verification + packaged
|
|
1251
|
+
* artifact path resolution — consolidated here so `functions` and `matrix` build
|
|
1252
|
+
* on ONE copy instead of maintaining byte-identical forks.
|
|
1253
|
+
*
|
|
1254
|
+
* Why core: `matrix` cannot import from `functions` (functions depends on matrix,
|
|
1255
|
+
* which would invert the edge and create a cycle), so the historical solution was
|
|
1256
|
+
* to duplicate this logic in both packages. Both packages already depend on
|
|
1257
|
+
* `core`, so `@danielsimonjr/mathts-core/internal` is a home reachable from both
|
|
1258
|
+
* WITHOUT introducing a cycle. Exposed ONLY via the `/internal` subpath (never the
|
|
1259
|
+
* browser-facing `.` entry); every filesystem/crypto access uses a LAZY dynamic
|
|
1260
|
+
* `import()` so this module stays browser-safe (no static `node:` imports).
|
|
1261
|
+
*
|
|
1262
|
+
* SECURITY INVARIANT (CLAUDE.md "Security Invariants" #1): the SHA-384
|
|
1263
|
+
* hash-and-compare-before-instantiate is preserved BYTE-FOR-BYTE from the former
|
|
1264
|
+
* per-package `integrity.ts` copies — same algorithm, same fail-closed/soft-warn
|
|
1265
|
+
* behavior. Do NOT bypass, weaken to a non-cryptographic check, or skip on
|
|
1266
|
+
* streaming compile paths. Regression-covered by
|
|
1267
|
+
* `functions/tests/security/wasm-integrity.test.ts` and
|
|
1268
|
+
* `matrix/tests/security/wasm-integrity.test.ts`.
|
|
1269
|
+
*
|
|
1270
|
+
* The build pipeline writes a JSON manifest beside the .wasm artefact:
|
|
1271
|
+
*
|
|
1272
|
+
* {
|
|
1273
|
+
* "mathts-as.wasm": "sha384-<base64-of-binary-digest>"
|
|
1274
|
+
* }
|
|
1275
|
+
*
|
|
1276
|
+
* At load time the runtime hashes the freshly read buffer with SHA-384 and
|
|
1277
|
+
* compares against the manifest. A mismatch throws — preventing silent
|
|
1278
|
+
* code-injection if the .wasm artefact is tampered with on disk or in transit
|
|
1279
|
+
* (e.g. a CDN/MITM compromise).
|
|
1280
|
+
*
|
|
1281
|
+
* Browser path uses `crypto.subtle.digest('SHA-384', buf)`.
|
|
1282
|
+
* Node path uses `crypto.createHash('sha384').update(buf).digest()`.
|
|
1283
|
+
*
|
|
1284
|
+
* If the manifest is missing or has no entry for the given file, we emit a
|
|
1285
|
+
* console warning and fall through. This keeps existing unsigned builds usable
|
|
1286
|
+
* while making signed builds tamper-evident.
|
|
1287
|
+
*
|
|
1288
|
+
* @module @danielsimonjr/mathts-core/internal (wasm-loader)
|
|
1289
|
+
*/
|
|
1290
|
+
|
|
1291
|
+
/**
|
|
1292
|
+
* Compute the SHA-384 digest of a buffer and return base64 encoding,
|
|
1293
|
+
* prefixed with "sha384-" to match SRI conventions.
|
|
1294
|
+
*/
|
|
1295
|
+
declare function sha384OfBuffer(buffer: ArrayBuffer | Uint8Array): Promise<string>;
|
|
1296
|
+
/**
|
|
1297
|
+
* Load the manifest sitting next to the .wasm artefact.
|
|
1298
|
+
*
|
|
1299
|
+
* @param wasmPath Resolved path or URL to the .wasm file.
|
|
1300
|
+
* @returns parsed manifest, or `null` if the manifest cannot be located.
|
|
1301
|
+
*/
|
|
1302
|
+
declare function loadWasmManifest(wasmPath: string): Promise<WasmManifest | null>;
|
|
1303
|
+
/**
|
|
1304
|
+
* Verify a freshly loaded WASM buffer against the manifest.
|
|
1305
|
+
*
|
|
1306
|
+
* @throws Error if the buffer's SHA-384 differs from the manifest entry.
|
|
1307
|
+
*/
|
|
1308
|
+
declare function verifyWasmIntegrity(buffer: ArrayBuffer | Uint8Array, wasmPath: string, options?: {
|
|
1309
|
+
manifest?: WasmManifest | null;
|
|
1310
|
+
required?: boolean;
|
|
1311
|
+
}): Promise<void>;
|
|
1312
|
+
/**
|
|
1313
|
+
* Robustly locate a packaged `.wasm` artifact across both the monorepo-source
|
|
1314
|
+
* layout and the published-package layout (Node only).
|
|
1315
|
+
*
|
|
1316
|
+
* The historical loaders hard-coded `../../../lib/wasm/<file>` relative to
|
|
1317
|
+
* `import.meta.url`, which only resolved for the monorepo source layout and
|
|
1318
|
+
* pointed outside the package once bundled/published — so the wasm was never
|
|
1319
|
+
* found and every consumer silently fell back to JS. This walks up from the
|
|
1320
|
+
* calling module's directory probing `<dir>/wasm/<file>` and
|
|
1321
|
+
* `<dir>/dist/wasm/<file>` at each level, matching bundled dist, unbundled dist,
|
|
1322
|
+
* and monorepo source.
|
|
1323
|
+
*
|
|
1324
|
+
* The caller injects its OWN `metaUrl` (its `import.meta.url`) so resolution is
|
|
1325
|
+
* relative to the calling package, not to core.
|
|
1326
|
+
*
|
|
1327
|
+
* @returns absolute path to the artifact, or `null` if not found.
|
|
1328
|
+
*/
|
|
1329
|
+
declare function resolvePackagedWasm(metaUrl: string, wasmFile: string): Promise<string | null>;
|
|
1330
|
+
/**
|
|
1331
|
+
* Canonical fallback location for the packaged wasm when {@link resolvePackagedWasm}
|
|
1332
|
+
* finds nothing: `<packageRoot>/dist/wasm/<wasmFile>`, with the package root found
|
|
1333
|
+
* by walking up from `metaUrl` to the nearest `package.json`. This replaces the
|
|
1334
|
+
* historical `../../../lib/wasm/<file>` fabrication, which was only correct for the
|
|
1335
|
+
* pre-bundling source layout. The returned path is where the binary SHOULD be, so
|
|
1336
|
+
* the missing-binary warning tells the user exactly what to build.
|
|
1337
|
+
*
|
|
1338
|
+
* In browser mode (no filesystem) it returns the bundle-relative `./wasm/<file>`
|
|
1339
|
+
* URL — correct for a served `dist/`, which is the only layout browsers see.
|
|
1340
|
+
*/
|
|
1341
|
+
declare function defaultWasmLocation(metaUrl: string, wasmFile: string, opts?: {
|
|
1342
|
+
browser?: boolean;
|
|
1343
|
+
}): Promise<string>;
|
|
1344
|
+
|
|
1345
|
+
export { type BigNumberValue, type ConfigOptions, DEFAULT_CONFIG, DimensionError, FactoryFunction, type FormatOptions, type GeneralFormatOptions, type IdentifiedValue, Index, IndexError, type LoadingMetrics, type MathJsConfig, MathjsError, Matrix$1 as Matrix, type MemoizedFunction, type NestedArray, type NormalizedFormatOptions, type NumberTypeConfig, ObjectWrappingMap, PartitionedMap, type SplitValue, UnitConstructor, UnitDependencies, type WasmManifest, _switch, acosh, arraySize, asinh, assign as assignMap, atanh, broadcastArrays, broadcastSizes, broadcastTo, canDefineProperty, cbrt, checkBroadcastingRules, clone$1 as clone, clone as cloneArray, compareText, concat, containsCollections, copysign, cosh, createEmptyMap, createIndexError, createMap, createUnitClass, deepExtend, deepFlatten, deepForEach, deepForEach$1 as deepForEachArray, deepMap, deepMap$1 as deepMapArray, deepStrictEqual, defaultWasmLocation, digits, endsWith, escape, expm1, extend, filter, filterRegExp, flatten, forEach, format$2 as format, format as formatBigNumber, format$1 as formatGeneric, generalize, get$1 as get, getArrayDataType, get as getArrayElement, hasOwnProperty, identify, initial, isEmptyIndex, isInteger, isLegacyFactory, isObjectWrappingMap, isPowZeroAtInfinity, join, last, lazy, loadWasmManifest, log10, log1p, log2, map, mapObject, memoize, nearlyEqual, normalizeFormatOptions, pick, pickShallow, processSizesWildcard, reduce, reshape, resize, resolvePackagedWasm, roundDigits, safeNumberType, scatter, set, sha384OfBuffer, sign, sinh, splitNumber, squeeze, stretch, stringify, tanh, toEngineering$1 as toEngineering, toEngineering as toEngineeringBigNumber, toExponential$1 as toExponential, toExponential as toExponentialBigNumber, toFixed$1 as toFixed, toFixed as toFixedBigNumber, toObject, toPrecision, traverse, unitDependencies, unsqueeze, validate, validateIndex, validateIndexSourceSize, verifyWasmIntegrity, warnOnce };
|
package/dist/internal.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DEFAULT_CONFIG,
|
|
2
3
|
MathjsError,
|
|
3
4
|
Unit,
|
|
4
5
|
acosh,
|
|
@@ -77,7 +78,7 @@ import {
|
|
|
77
78
|
typeOf,
|
|
78
79
|
unitDependencies,
|
|
79
80
|
warnOnce
|
|
80
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-7BUNGMQB.js";
|
|
81
82
|
|
|
82
83
|
// src/error/DimensionError.ts
|
|
83
84
|
var DimensionError = class _DimensionError extends RangeError {
|
|
@@ -1351,13 +1352,123 @@ function isObjectWrappingMap(object) {
|
|
|
1351
1352
|
const wrapper = object;
|
|
1352
1353
|
return isObject(wrapper.wrappedObject);
|
|
1353
1354
|
}
|
|
1355
|
+
|
|
1356
|
+
// src/wasm-loader.ts
|
|
1357
|
+
var ALGO = "sha384";
|
|
1358
|
+
async function sha384OfBuffer(buffer) {
|
|
1359
|
+
const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
|
|
1360
|
+
const isNode = typeof process !== "undefined" && process.versions?.node !== void 0;
|
|
1361
|
+
let digest;
|
|
1362
|
+
if (isNode) {
|
|
1363
|
+
const { createHash } = await import("crypto");
|
|
1364
|
+
const hash = createHash(ALGO);
|
|
1365
|
+
hash.update(bytes);
|
|
1366
|
+
digest = new Uint8Array(hash.digest());
|
|
1367
|
+
} else {
|
|
1368
|
+
const copy = new ArrayBuffer(bytes.byteLength);
|
|
1369
|
+
new Uint8Array(copy).set(bytes);
|
|
1370
|
+
const out = await crypto.subtle.digest("SHA-384", copy);
|
|
1371
|
+
digest = new Uint8Array(out);
|
|
1372
|
+
}
|
|
1373
|
+
let binary = "";
|
|
1374
|
+
for (let i = 0; i < digest.length; i++) binary += String.fromCharCode(digest[i]);
|
|
1375
|
+
const b64 = typeof btoa === "function" ? btoa(binary) : Buffer.from(digest).toString("base64");
|
|
1376
|
+
return `sha384-${b64}`;
|
|
1377
|
+
}
|
|
1378
|
+
async function loadWasmManifest(wasmPath) {
|
|
1379
|
+
const isNode = typeof process !== "undefined" && process.versions?.node !== void 0;
|
|
1380
|
+
const manifestPath = wasmPath.replace(/[^/\\]+$/, "wasm-manifest.json");
|
|
1381
|
+
try {
|
|
1382
|
+
if (isNode) {
|
|
1383
|
+
const fs = await import("fs");
|
|
1384
|
+
const { promisify } = await import("util");
|
|
1385
|
+
const readFile = promisify(fs.readFile);
|
|
1386
|
+
const text = await readFile(manifestPath, "utf8");
|
|
1387
|
+
return JSON.parse(text);
|
|
1388
|
+
} else {
|
|
1389
|
+
const res = await fetch(manifestPath);
|
|
1390
|
+
if (!res.ok) return null;
|
|
1391
|
+
return await res.json();
|
|
1392
|
+
}
|
|
1393
|
+
} catch {
|
|
1394
|
+
return null;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
async function verifyWasmIntegrity(buffer, wasmPath, options = {}) {
|
|
1398
|
+
const fileName = wasmPath.split(/[/\\]/).pop() || wasmPath;
|
|
1399
|
+
const manifest = options.manifest !== void 0 ? options.manifest : await loadWasmManifest(wasmPath);
|
|
1400
|
+
if (!manifest) {
|
|
1401
|
+
if (options.required) {
|
|
1402
|
+
throw new Error(
|
|
1403
|
+
`WASM integrity check failed: no manifest at sibling of "${wasmPath}" (required)`
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
if (typeof console !== "undefined") {
|
|
1407
|
+
console.warn(
|
|
1408
|
+
`[wasm-integrity] no manifest found beside "${wasmPath}"; skipping SHA-384 verification (set options.required=true to fail closed)`
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
const expected = manifest[fileName];
|
|
1414
|
+
if (!expected) {
|
|
1415
|
+
if (options.required) {
|
|
1416
|
+
throw new Error(`WASM integrity check failed: manifest has no entry for "${fileName}"`);
|
|
1417
|
+
}
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
const actual = await sha384OfBuffer(buffer);
|
|
1421
|
+
if (actual !== expected) {
|
|
1422
|
+
throw new Error(
|
|
1423
|
+
`WASM integrity check failed for "${fileName}": expected ${expected}, got ${actual}`
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
async function resolvePackagedWasm(metaUrl, wasmFile) {
|
|
1428
|
+
const isNode = typeof process !== "undefined" && process.versions?.node !== void 0;
|
|
1429
|
+
if (!isNode) return null;
|
|
1430
|
+
const { fileURLToPath } = await import("url");
|
|
1431
|
+
const { dirname, join: join2 } = await import("path");
|
|
1432
|
+
const { existsSync } = await import("fs");
|
|
1433
|
+
let dir = dirname(fileURLToPath(metaUrl));
|
|
1434
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
1435
|
+
const candidates = [join2(dir, "wasm", wasmFile), join2(dir, "dist", "wasm", wasmFile)];
|
|
1436
|
+
for (const candidate of candidates) {
|
|
1437
|
+
if (existsSync(candidate)) return candidate;
|
|
1438
|
+
}
|
|
1439
|
+
const parent = dirname(dir);
|
|
1440
|
+
if (parent === dir) break;
|
|
1441
|
+
dir = parent;
|
|
1442
|
+
}
|
|
1443
|
+
return null;
|
|
1444
|
+
}
|
|
1445
|
+
async function defaultWasmLocation(metaUrl, wasmFile, opts) {
|
|
1446
|
+
if (opts?.browser) {
|
|
1447
|
+
return new URL(`./wasm/${wasmFile}`, metaUrl).href;
|
|
1448
|
+
}
|
|
1449
|
+
const { fileURLToPath } = await import("url");
|
|
1450
|
+
const { dirname, join: join2 } = await import("path");
|
|
1451
|
+
const { existsSync } = await import("fs");
|
|
1452
|
+
let dir = dirname(fileURLToPath(metaUrl));
|
|
1453
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
1454
|
+
if (existsSync(join2(dir, "package.json"))) {
|
|
1455
|
+
return join2(dir, "dist", "wasm", wasmFile);
|
|
1456
|
+
}
|
|
1457
|
+
const parent = dirname(dir);
|
|
1458
|
+
if (parent === dir) break;
|
|
1459
|
+
dir = parent;
|
|
1460
|
+
}
|
|
1461
|
+
return join2(dirname(fileURLToPath(metaUrl)), "wasm", wasmFile);
|
|
1462
|
+
}
|
|
1354
1463
|
export {
|
|
1355
1464
|
Unit as CoreUnit,
|
|
1465
|
+
DEFAULT_CONFIG,
|
|
1356
1466
|
DimensionError,
|
|
1357
1467
|
IndexError,
|
|
1358
1468
|
MathjsError,
|
|
1359
1469
|
ObjectWrappingMap,
|
|
1360
1470
|
PartitionedMap,
|
|
1471
|
+
_switch,
|
|
1361
1472
|
acosh,
|
|
1362
1473
|
arraySize,
|
|
1363
1474
|
asinh,
|
|
@@ -1389,6 +1500,7 @@ export {
|
|
|
1389
1500
|
deepMap2 as deepMap,
|
|
1390
1501
|
deepMap as deepMapArray,
|
|
1391
1502
|
deepStrictEqual,
|
|
1503
|
+
defaultWasmLocation,
|
|
1392
1504
|
digits,
|
|
1393
1505
|
endsWith,
|
|
1394
1506
|
escape,
|
|
@@ -1441,6 +1553,7 @@ export {
|
|
|
1441
1553
|
join,
|
|
1442
1554
|
last,
|
|
1443
1555
|
lazy,
|
|
1556
|
+
loadWasmManifest,
|
|
1444
1557
|
log10,
|
|
1445
1558
|
log1p,
|
|
1446
1559
|
log2,
|
|
@@ -1455,10 +1568,12 @@ export {
|
|
|
1455
1568
|
reduce,
|
|
1456
1569
|
reshape,
|
|
1457
1570
|
resize,
|
|
1571
|
+
resolvePackagedWasm,
|
|
1458
1572
|
roundDigits,
|
|
1459
1573
|
safeNumberType,
|
|
1460
1574
|
scatter,
|
|
1461
1575
|
set,
|
|
1576
|
+
sha384OfBuffer,
|
|
1462
1577
|
sign,
|
|
1463
1578
|
sinh,
|
|
1464
1579
|
sortFactories,
|
|
@@ -1483,5 +1598,6 @@ export {
|
|
|
1483
1598
|
validate,
|
|
1484
1599
|
validateIndex,
|
|
1485
1600
|
validateIndexSourceSize,
|
|
1601
|
+
verifyWasmIntegrity,
|
|
1486
1602
|
warnOnce
|
|
1487
1603
|
};
|