@danielsimonjr/mathts-core 0.18.1 → 0.20.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.
Files changed (43) hide show
  1. package/README.md +30 -5
  2. package/dist/collection.d.ts +35 -23
  3. package/dist/collection.d.ts.map +1 -1
  4. package/dist/index.d.ts +3 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1348 -1534
  7. package/dist/internal.d.ts +3 -2
  8. package/dist/internal.d.ts.map +1 -1
  9. package/dist/internal.js +1021 -1514
  10. package/dist/numeric/rng.d.ts +88 -0
  11. package/dist/numeric/rng.d.ts.map +1 -0
  12. package/dist/numeric/strides.d.ts +18 -0
  13. package/dist/numeric/strides.d.ts.map +1 -0
  14. package/dist/object.d.ts +20 -2
  15. package/dist/object.d.ts.map +1 -1
  16. package/dist/shared.d.ts +19 -0
  17. package/dist/shared.d.ts.map +1 -1
  18. package/dist/switch.d.ts +2 -4
  19. package/dist/switch.d.ts.map +1 -1
  20. package/dist/types/bignumber.d.ts +7 -0
  21. package/dist/types/bignumber.d.ts.map +1 -1
  22. package/dist/types/complex.d.ts +20 -18
  23. package/dist/types/complex.d.ts.map +1 -1
  24. package/dist/types/fraction.d.ts +5 -0
  25. package/dist/types/fraction.d.ts.map +1 -1
  26. package/dist/types/si-dimension-vector.d.ts +62 -7
  27. package/dist/types/si-dimension-vector.d.ts.map +1 -1
  28. package/dist/types/unit/Unit.d.ts.map +1 -1
  29. package/dist/types/unit/index.d.ts +1 -1
  30. package/dist/types/unit/index.d.ts.map +1 -1
  31. package/dist/types/unit/unit-table.d.ts +8 -2
  32. package/dist/types/unit/unit-table.d.ts.map +1 -1
  33. package/dist/types/unit/unit-types.d.ts +10 -0
  34. package/dist/types/unit/unit-types.d.ts.map +1 -1
  35. package/dist/types/unit.d.ts +1 -1
  36. package/dist/types/unit.d.ts.map +1 -1
  37. package/dist/unit-Dul_E1rh.js +5946 -0
  38. package/dist/wasm-as-header.d.ts +17 -0
  39. package/dist/wasm-as-header.d.ts.map +1 -0
  40. package/dist/wasm-loader.d.ts +33 -1
  41. package/dist/wasm-loader.d.ts.map +1 -1
  42. package/package.json +6 -5
  43. package/dist/chunk-36FOYJAP.js +0 -6091
@@ -0,0 +1,17 @@
1
+ /**
2
+ * AssemblyScript managed ArrayBuffer + typed-array header allocation.
3
+ *
4
+ * Shared by `functions` WASM bridges and `matrix` AS backend allocation.
5
+ * Exported only from `@danielsimonjr/mathts-core/internal`.
6
+ */
7
+ export interface AsHeaderRuntime {
8
+ __new(size: number, id: number): number;
9
+ __pin(ptr: number): number;
10
+ memory: WebAssembly.Memory;
11
+ }
12
+ /** Pin a data buffer and write the 12-byte AS typed-array header. */
13
+ export declare function allocAsHeader(mod: AsHeaderRuntime, byteLength: number, typeId: number): {
14
+ headerPtr: number;
15
+ bufferPtr: number;
16
+ };
17
+ //# sourceMappingURL=wasm-as-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm-as-header.d.ts","sourceRoot":"","sources":["../src/wasm-as-header.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACxC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;CAC5B;AAED,qEAAqE;AACrE,wBAAgB,aAAa,CAC3B,GAAG,EAAE,eAAe,EACpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GACb;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAS1C"}
@@ -39,7 +39,7 @@
39
39
  *
40
40
  * @module @danielsimonjr/mathts-core/internal (wasm-loader)
41
41
  */
42
- import type { WasmManifest } from './types/wasm-loader.js';
42
+ import type { LoadingMetrics, WasmManifest } from './types/wasm-loader.js';
43
43
  export type { WasmManifest };
44
44
  /**
45
45
  * Compute the SHA-384 digest of a buffer and return base64 encoding,
@@ -94,4 +94,36 @@ export declare function resolvePackagedWasm(metaUrl: string, wasmFile: string):
94
94
  export declare function defaultWasmLocation(metaUrl: string, wasmFile: string, opts?: {
95
95
  browser?: boolean;
96
96
  }): Promise<string>;
97
+ /**
98
+ * Shared load / instantiate orchestration for the two package-local
99
+ * `WasmLoader` singletons (`functions` and `matrix`). Subclasses keep their own
100
+ * `WasmModule` ABI type and path resolution; the Node and browser load arms
101
+ * (`precompile`, `loadNodeWasm`, `loadBrowserWasm`) live here and call
102
+ * {@link verifyWasmIntegrity} before every compile/instantiate (G45–G47, P6-10).
103
+ */
104
+ export declare abstract class WasmModuleLoader<TModule> {
105
+ protected wasmModule: TModule | null;
106
+ protected compiledModule: WebAssembly.Module | null;
107
+ protected loading: Promise<TModule> | null;
108
+ protected isNode: boolean;
109
+ protected lastMetrics: LoadingMetrics | null;
110
+ protected constructor();
111
+ /**
112
+ * Load the WASM module (cached; concurrent callers share one in-flight promise).
113
+ */
114
+ load(wasmPath?: string): Promise<TModule>;
115
+ private loadModule;
116
+ protected abstract getDefaultWasmPath(): Promise<string>;
117
+ /**
118
+ * Precompile the WASM module without instantiation.
119
+ * Useful for build-time or startup optimization.
120
+ *
121
+ * Same integrity rule as `load()`: the bytes are hashed against the manifest before
122
+ * `WebAssembly.compile`. The browser arm streams only when no manifest exists.
123
+ */
124
+ precompile(wasmPath?: string): Promise<void>;
125
+ protected loadNodeWasm(path: string, totalStart: number): Promise<TModule>;
126
+ protected loadBrowserWasm(path: string, totalStart: number): Promise<TModule>;
127
+ protected getImports(): WebAssembly.Imports;
128
+ }
97
129
  //# sourceMappingURL=wasm-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"wasm-loader.d.ts","sourceRoot":"","sources":["../src/wasm-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,SAAS,CAAC,QAAQ,CAAC,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzD;;;;;;OAMG;IACU,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkCxD;IAED,UAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA8B/E;IAED,UAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA+ClF;IAED,SAAS,CAAC,UAAU,IAAI,WAAW,CAAC,OAAO,CAY1C;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-core",
3
- "version": "0.18.1",
3
+ "version": "0.20.0",
4
4
  "description": "Core types, utilities, and configuration for MathTS",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",
@@ -23,8 +23,8 @@
23
23
  "README.md"
24
24
  ],
25
25
  "scripts": {
26
- "build": "tsup && tsc -p tsconfig.dts.json",
27
- "dev": "tsup --watch --onSuccess \"tsc -p tsconfig.dts.json\"",
26
+ "build": "tsdown && tsc -p tsconfig.dts.json",
27
+ "dev": "tsdown --watch --on-success \"tsc -p tsconfig.dts.json\"",
28
28
  "test": "bun test --isolate --timeout 30000",
29
29
  "test:watch": "vitest",
30
30
  "test:coverage": "bun test --isolate --timeout 30000 --coverage",
@@ -32,14 +32,15 @@
32
32
  "lint": "oxlint src",
33
33
  "lint:fix": "oxlint src --fix",
34
34
  "clean": "rm -rf dist",
35
- "build:prod": "tsup --minify --treeshake && tsc -p tsconfig.dts.json"
35
+ "build:prod": "tsdown --minify && tsc -p tsconfig.dts.json"
36
36
  },
37
37
  "dependencies": {
38
38
  "typed-function": "npm:@danielsimonjr/typed-function@5.0.0-alpha.4"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/node": "^26.4.0",
42
- "tsup": "^8.0.0",
42
+ "fast-check": "^4.9.0",
43
+ "tsdown": "^0.23.0",
43
44
  "typescript": "^7.0.2",
44
45
  "vitest": "^5.0.0"
45
46
  },