@c9up/atom 0.1.11 → 0.1.13
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/README.md +9 -1
- package/dist/Decimal.d.ts +8 -1
- package/dist/Decimal.d.ts.map +1 -1
- package/dist/Decimal.js +132 -96
- package/dist/Decimal.js.map +1 -1
- package/dist/Money.d.ts +15 -2
- package/dist/Money.d.ts.map +1 -1
- package/dist/Money.js +28 -3
- package/dist/Money.js.map +1 -1
- package/dist/atlas.d.ts +2 -5
- package/dist/atlas.d.ts.map +1 -1
- package/dist/atlas.js +2 -5
- package/dist/atlas.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -33
- package/dist/index.js.map +1 -1
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +8 -7
- package/scripts/build-napi-types.mjs +4 -3
- package/scripts/clean-wasm-pack-meta.mjs +32 -0
- package/scripts/copy-napi.mjs +11 -3
- package/scripts/generate-napi-types.mjs +9 -6
- package/scripts/verify-wasm.mjs +29 -1
- package/src/Decimal.ts +203 -134
- package/src/Money.ts +44 -5
- package/src/atlas.ts +2 -5
- package/src/index.ts +75 -36
- package/wasm/atom_engine_wasm.d.ts +60 -0
- package/wasm/atom_engine_wasm.js +416 -0
- package/wasm/atom_engine_wasm_bg.wasm +0 -0
- package/wasm/atom_engine_wasm_bg.wasm.d.ts +17 -0
package/dist/atlas.d.ts
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* column pipeline. Lives on a sub-export so the default `@c9up/atom` import
|
|
6
6
|
* surface stays adapter-free.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* boot-time wiring.
|
|
8
|
+
* The callbacks are baked into the entity definition: no global registry, no
|
|
9
|
+
* boot-time wiring, nothing to import in a provider.
|
|
11
10
|
*
|
|
12
11
|
* Usage:
|
|
13
12
|
*
|
|
@@ -19,8 +18,6 @@
|
|
|
19
18
|
* @PrimaryKey() id!: number
|
|
20
19
|
* @Column(decimalAtlasAdapter) balance!: Decimal | null
|
|
21
20
|
* }
|
|
22
|
-
*
|
|
23
|
-
* @implements Story 35.10
|
|
24
21
|
*/
|
|
25
22
|
import { Decimal, type RoundMode } from "./Decimal.js";
|
|
26
23
|
export interface DecimalColumnOptions {
|
package/dist/atlas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atlas.d.ts","sourceRoot":"","sources":["../src/atlas.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"atlas.d.ts","sourceRoot":"","sources":["../src/atlas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEvD,MAAM,WAAW,oBAAoB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,mBAAmB;IACnC,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;IACtC,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC9D,IAAI,EAAE;QACL,WAAW,EAAE,IAAI,CAAC;QAClB,UAAU,EAAE,SAAS,GAAG,SAAS,CAAC;QAClC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,OAAO,CAAC;KAClB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,mBAAmB,EAAE,mBAyBhC,CAAC;AAEH,wBAAgB,aAAa,CAC5B,OAAO,GAAE,oBAAyB,GAChC,kBAAkB,CAoCpB"}
|
package/dist/atlas.js
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
* column pipeline. Lives on a sub-export so the default `@c9up/atom` import
|
|
6
6
|
* surface stays adapter-free.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* boot-time wiring.
|
|
8
|
+
* The callbacks are baked into the entity definition: no global registry, no
|
|
9
|
+
* boot-time wiring, nothing to import in a provider.
|
|
11
10
|
*
|
|
12
11
|
* Usage:
|
|
13
12
|
*
|
|
@@ -19,8 +18,6 @@
|
|
|
19
18
|
* @PrimaryKey() id!: number
|
|
20
19
|
* @Column(decimalAtlasAdapter) balance!: Decimal | null
|
|
21
20
|
* }
|
|
22
|
-
*
|
|
23
|
-
* @implements Story 35.10
|
|
24
21
|
*/
|
|
25
22
|
import { Decimal } from "./Decimal.js";
|
|
26
23
|
/**
|
package/dist/atlas.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atlas.js","sourceRoot":"","sources":["../src/atlas.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"atlas.js","sourceRoot":"","sources":["../src/atlas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,OAAO,EAAkB,MAAM,cAAc,CAAC;AAwBvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAwB,MAAM,CAAC,MAAM,CAAC;IACrE,OAAO,CAAC,GAAY;QACnB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACnD,IAAI,GAAG,YAAY,OAAO;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D,CACrD,CAAC;gBACH,CAAC;gBACD,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,sBAAsB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;QACD,OAAO,CAAC,KAAc;YACrB,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpD,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACvB,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACf,MAAM,IAAI,SAAS,CAClB,qDAAqD,CACrD,CAAC;gBACH,CAAC;gBACD,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,sBAAsB,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC1E,CAAC;KACD,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,sBAAsB,CAC9B,KAAc,EACd,OAA6B;IAE7B,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC9C,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,cAAc,CAC5B,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,EACjC,OAAO,CAAC,KAAK,CACb,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { AtomContext, AtomContextOptions } from "./context.js";
|
|
|
7
7
|
export { configureAtomContext, getAtomContext, resetAtomContext, withAtomContext, } from "./context.js";
|
|
8
8
|
export type { BetweenOptions, DecimalInput, DecimalSafeParseResult, DecimalScaled, DivOptions, MedianOptions, PowOptions, QuantizeOptions, RoundMode, SqrtOptions, StddevOptions, ToMinorUnitsOptions, } from "./Decimal.js";
|
|
9
9
|
export { Decimal } from "./Decimal.js";
|
|
10
|
-
export type { MoneyFormatOptions, MoneyOptions } from "./Money.js";
|
|
10
|
+
export type { MoneyFormatOptions, MoneyOptions, MoneyRoundingOptions, } from "./Money.js";
|
|
11
11
|
export { Money, money } from "./Money.js";
|
|
12
12
|
export { isNativeAvailable } from "./native.js";
|
|
13
13
|
import type { MedianOptions, StddevOptions } from "./Decimal.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,eAAe,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EACX,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,aAAa,EACb,UAAU,EACV,eAAe,EACf,SAAS,EACT,WAAW,EACX,aAAa,EACb,mBAAmB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,eAAe,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EACX,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,aAAa,EACb,UAAU,EACV,eAAe,EACf,SAAS,EACT,WAAW,EACX,aAAa,EACb,mBAAmB,GACnB,MA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BAAS,QAAQ,CAChB,GAAG,IAAI,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,aAAa,CAAC,CAAC,GAAG,YAAY,EAAE,GAChE,OAAO,CAGT;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,IAAI;IAChB,iGAAiG;;IAEjG,2DAA2D;;IAE3D,0DAA0D;;IAE1D,kKAAkK;;IAElK;;;;;;;;OAQG;;IAEH;;;;;OAKG;;IAEH,mDAAmD;;IAEnD,kDAAkD;;IAElD,8EAA8E;yBACzD,MAAM,YAAY,IAAI,CAAC,eAAe;IAE3D,gDAAgD;;CAEhD,CAAC;AAEF,eAAO,MAAM,GAAG,cAAQ,CAAC;AACzB,eAAO,MAAM,GAAG,cAAQ,CAAC;AACzB,eAAO,MAAM,MAAM,iBAAW,CAAC;AAC/B,eAAO,MAAM,IAAI,eAAS,CAAC;AAC3B,eAAO,MAAM,MAAM,iBAAW,CAAC;AAC/B,eAAO,MAAM,GAAG,cAAQ,CAAC;AACzB,eAAO,MAAM,GAAG,cAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,11 +18,30 @@ function isDecimalIterable(value) {
|
|
|
18
18
|
return false;
|
|
19
19
|
return (typeof value === "object" && value !== null && Symbol.iterator in value);
|
|
20
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* What every aggregate accepts as one value.
|
|
23
|
+
*
|
|
24
|
+
* The variadic form used to be asserted back into shape — a claim about the
|
|
25
|
+
* caller's arguments made in the one place that can check them. Anything else
|
|
26
|
+
* reached `new Decimal(...)`, where an object failed as
|
|
27
|
+
* `input.trim is not a function`, naming neither the argument nor the call.
|
|
28
|
+
*/
|
|
29
|
+
function isDecimalValue(value) {
|
|
30
|
+
return (Decimal.isDecimal(value) ||
|
|
31
|
+
typeof value === "string" ||
|
|
32
|
+
typeof value === "number" ||
|
|
33
|
+
typeof value === "bigint");
|
|
34
|
+
}
|
|
35
|
+
function toDecimalValue(value) {
|
|
36
|
+
if (isDecimalValue(value))
|
|
37
|
+
return value;
|
|
38
|
+
throw new Error(`Atom aggregates take a string, number, bigint or Decimal, got ${value === null ? "null" : typeof value}`);
|
|
39
|
+
}
|
|
21
40
|
function resolveValues(args) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return args;
|
|
41
|
+
const head = args[0];
|
|
42
|
+
if (args.length === 1 && isDecimalIterable(head))
|
|
43
|
+
return head;
|
|
44
|
+
return args.map(toDecimalValue);
|
|
26
45
|
}
|
|
27
46
|
function sumImpl(values) {
|
|
28
47
|
let total = Decimal.zero();
|
|
@@ -44,26 +63,26 @@ function avgImpl(values) {
|
|
|
44
63
|
return total.div(String(count));
|
|
45
64
|
}
|
|
46
65
|
function minImpl(values) {
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
66
|
+
const [first, ...rest] = [...values].map((value) => new Decimal(value));
|
|
67
|
+
if (first === undefined) {
|
|
49
68
|
throw new Error("Atom.min requires at least one value");
|
|
50
69
|
}
|
|
51
|
-
let best =
|
|
52
|
-
for (
|
|
53
|
-
if (
|
|
54
|
-
best =
|
|
70
|
+
let best = first;
|
|
71
|
+
for (const candidate of rest) {
|
|
72
|
+
if (candidate.lt(best))
|
|
73
|
+
best = candidate;
|
|
55
74
|
}
|
|
56
75
|
return best;
|
|
57
76
|
}
|
|
58
77
|
function maxImpl(values) {
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
78
|
+
const [first, ...rest] = [...values].map((value) => new Decimal(value));
|
|
79
|
+
if (first === undefined) {
|
|
61
80
|
throw new Error("Atom.max requires at least one value");
|
|
62
81
|
}
|
|
63
|
-
let best =
|
|
64
|
-
for (
|
|
65
|
-
if (
|
|
66
|
-
best =
|
|
82
|
+
let best = first;
|
|
83
|
+
for (const candidate of rest) {
|
|
84
|
+
if (candidate.gt(best))
|
|
85
|
+
best = candidate;
|
|
67
86
|
}
|
|
68
87
|
return best;
|
|
69
88
|
}
|
|
@@ -74,10 +93,17 @@ function medianImpl(values, options = {}) {
|
|
|
74
93
|
}
|
|
75
94
|
list.sort((a, b) => a.cmp(b));
|
|
76
95
|
const mid = Math.floor(list.length / 2);
|
|
96
|
+
// The empty case threw above, so both halves of the middle are present.
|
|
97
|
+
const upper = list[mid];
|
|
98
|
+
if (upper === undefined)
|
|
99
|
+
throw new Error("Atom.median lost its middle value");
|
|
77
100
|
if (list.length % 2 === 1)
|
|
78
|
-
return
|
|
101
|
+
return upper;
|
|
102
|
+
const lower = list[mid - 1];
|
|
103
|
+
if (lower === undefined)
|
|
104
|
+
throw new Error("Atom.median lost its middle value");
|
|
79
105
|
const precision = options.precision ?? defaultPrecision();
|
|
80
|
-
return
|
|
106
|
+
return lower.plus(upper).div("2", { precision });
|
|
81
107
|
}
|
|
82
108
|
function modeImpl(values) {
|
|
83
109
|
const frequencies = new Map();
|
|
@@ -123,25 +149,33 @@ function stddevImpl(values, options = {}) {
|
|
|
123
149
|
});
|
|
124
150
|
return variance.sqrt({ precision, mode });
|
|
125
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* The trailing options object of `median(values, options)` / `stddev(values,
|
|
154
|
+
* options)`, or `{}`.
|
|
155
|
+
*
|
|
156
|
+
* A `Decimal` is an object too, so excluding it is what lets the compiler
|
|
157
|
+
* check the narrowing instead of being told the answer.
|
|
158
|
+
*/
|
|
159
|
+
function optionsFrom(value) {
|
|
160
|
+
if (typeof value !== "object" || value === null)
|
|
161
|
+
return {};
|
|
162
|
+
if (Decimal.isDecimal(value))
|
|
163
|
+
return {};
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
126
166
|
function parseMedianArgs(args) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
? args[1]
|
|
131
|
-
: {};
|
|
132
|
-
return { values, options };
|
|
167
|
+
const head = args[0];
|
|
168
|
+
if (isDecimalIterable(head)) {
|
|
169
|
+
return { values: head, options: optionsFrom(args[1]) };
|
|
133
170
|
}
|
|
134
|
-
return { values: args, options: {} };
|
|
171
|
+
return { values: resolveValues(args), options: {} };
|
|
135
172
|
}
|
|
136
173
|
function parseStddevArgs(args) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return { values, options };
|
|
143
|
-
}
|
|
144
|
-
return { values: args, options: {} };
|
|
174
|
+
const head = args[0];
|
|
175
|
+
if (isDecimalIterable(head)) {
|
|
176
|
+
return { values: head, options: optionsFrom(args[1]) };
|
|
177
|
+
}
|
|
178
|
+
return { values: resolveValues(args), options: {} };
|
|
145
179
|
}
|
|
146
180
|
function sumFn(...args) {
|
|
147
181
|
return sumImpl(resolveValues(args));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,eAAe,GACf,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,eAAe,GACf,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAMvC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,UAAU,OAAO,CAAC,KAAmB;IAC1C,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CA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AM,IAAI,GAAG,MAAM,CAAC;AAC3B,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAC/B,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AACzB,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC"}
|
package/index.darwin-arm64.node
CHANGED
|
Binary file
|
package/index.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
package/index.linux-x64-gnu.node
CHANGED
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c9up/atom",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Atom — exact decimal arithmetic for the Ream ecosystem (TypeScript + Rust N-API)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
"wasm"
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@biomejs/biome": "^2.
|
|
30
|
-
"@types/node": "^22.
|
|
31
|
-
"
|
|
32
|
-
"
|
|
29
|
+
"@biomejs/biome": "^2.5.12",
|
|
30
|
+
"@types/node": "^22.20.1",
|
|
31
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
32
|
+
"typescript": "^6.0.3",
|
|
33
|
+
"vitest": "4.1.11"
|
|
33
34
|
},
|
|
34
35
|
"engines": {
|
|
35
36
|
"node": ">=22.0.0"
|
|
@@ -51,8 +52,8 @@
|
|
|
51
52
|
"test:rust": "cargo test -p atom-engine",
|
|
52
53
|
"test:napi": "node scripts/verify-napi.mjs",
|
|
53
54
|
"bench": "pnpm build && node scripts/bench.mjs",
|
|
54
|
-
"build:wasm": "wasm-pack build --target web crates/atom-engine-wasm --out-dir ../../wasm",
|
|
55
|
-
"lint": "biome check src/",
|
|
55
|
+
"build:wasm": "wasm-pack build --target web crates/atom-engine-wasm --out-dir ../../wasm && node scripts/clean-wasm-pack-meta.mjs",
|
|
56
|
+
"lint": "biome check src/ tests/",
|
|
56
57
|
"test:coverage": "vitest run --coverage"
|
|
57
58
|
}
|
|
58
59
|
}
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* cargo a `/tmp/...` path the native proc-macro cannot write to, so the
|
|
8
8
|
* type-def file comes back empty and the build fails for no visible reason.
|
|
9
9
|
*
|
|
10
|
-
* One crate at a time on purpose: napi-derive
|
|
10
|
+
* One crate at a time on purpose: with napi-derive 2 the writes all went to a
|
|
11
|
+
* single `TYPE_DEF_TMP_PATH` and a parallel build interleaved them
|
|
11
12
|
* while cargo compiles, and a parallel build interleaves the writes —
|
|
12
13
|
* definitions go missing, silently, and the generated file comes out short.
|
|
13
14
|
*/
|
|
@@ -28,11 +29,11 @@ const scratch = mkdtempSync(join(tmpdir(), 'napi-types-'))
|
|
|
28
29
|
try {
|
|
29
30
|
const lines = []
|
|
30
31
|
for (const crate of CRATES) {
|
|
31
|
-
const perCrate = join(scratch,
|
|
32
|
+
const perCrate = join(scratch, crate)
|
|
32
33
|
writeFileSync(perCrate, '')
|
|
33
34
|
execFileSync('cargo', ['build', '-p', crate], {
|
|
34
35
|
cwd: packageRoot,
|
|
35
|
-
env: { ...process.env,
|
|
36
|
+
env: { ...process.env, NAPI_TYPE_DEF_TMP_FOLDER: scratch },
|
|
36
37
|
stdio: ['ignore', 'ignore', 'inherit'],
|
|
37
38
|
})
|
|
38
39
|
const emitted = readFileSync(perCrate, 'utf8').split('\n').filter(Boolean)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { existsSync, rmSync } from 'node:fs'
|
|
2
|
+
import { dirname, join } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
|
|
5
|
+
// Removes the package metadata `wasm-pack` writes into its output directory.
|
|
6
|
+
//
|
|
7
|
+
// `wasm-pack build` treats its out-dir as a publishable package of its own and
|
|
8
|
+
// scaffolds one: a `package.json`, and a `.gitignore` whose entire content is
|
|
9
|
+
// `*`. Ours is not a package — it is a directory inside this one, listed in
|
|
10
|
+
// `files`.
|
|
11
|
+
//
|
|
12
|
+
// The `.gitignore` is the damaging half. npm honours a .gitignore nested INSIDE
|
|
13
|
+
// a published directory even when `files` lists that directory, so a single `*`
|
|
14
|
+
// silently strips every artifact from the tarball — the built .js and .wasm, and
|
|
15
|
+
// the committed .d.ts stub with them. The package then publishes green and every
|
|
16
|
+
// browser consumer gets the engine-missing error. Measured here: with the file
|
|
17
|
+
// present `npm pack --dry-run` reports zero wasm/ entries, without it, two.
|
|
18
|
+
//
|
|
19
|
+
// Runs right after wasm-pack, before anything packs.
|
|
20
|
+
|
|
21
|
+
const wasmDir = join(dirname(fileURLToPath(import.meta.url)), '..', 'wasm')
|
|
22
|
+
|
|
23
|
+
// Only what wasm-pack scaffolds. The artifacts and the committed .d.ts stay.
|
|
24
|
+
const generated = ['.gitignore', 'package.json', 'README.md', 'LICENSE']
|
|
25
|
+
|
|
26
|
+
for (const name of generated) {
|
|
27
|
+
const path = join(wasmDir, name)
|
|
28
|
+
if (existsSync(path)) {
|
|
29
|
+
rmSync(path)
|
|
30
|
+
console.log(`[wasm] removed generated wasm/${name}`)
|
|
31
|
+
}
|
|
32
|
+
}
|
package/scripts/copy-napi.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { copyFileSync, existsSync } from 'node:fs'
|
|
2
|
-
import { dirname, join } from 'node:path'
|
|
2
|
+
import { dirname, join, resolve } from 'node:path'
|
|
3
3
|
import { arch, env, platform } from 'node:process'
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
|
|
@@ -20,16 +20,24 @@ const hostSuffixMap = {
|
|
|
20
20
|
'darwin-x64': 'darwin-x64', 'darwin-arm64': 'darwin-arm64', 'win32-x64': 'win32-x64-msvc',
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
// Cargo writes its artifacts under CARGO_TARGET_DIR when that is set — a
|
|
24
|
+
// shared cache, a CI mount — so they are not under this package's `target/` at
|
|
25
|
+
// all. A relative value is resolved against the directory cargo ran in, which
|
|
26
|
+
// is this package root.
|
|
27
|
+
const targetDir = env.CARGO_TARGET_DIR
|
|
28
|
+
? resolve(root, env.CARGO_TARGET_DIR)
|
|
29
|
+
: join(root, 'target')
|
|
30
|
+
|
|
23
31
|
const triple = env.CARGO_BUILD_TARGET ?? ''
|
|
24
32
|
let suffix, os, releaseDir
|
|
25
33
|
if (triple) {
|
|
26
34
|
const entry = tripleMap[triple]
|
|
27
35
|
if (!entry) throw new Error(`${TAG} unsupported CARGO_BUILD_TARGET: ${triple}`)
|
|
28
36
|
suffix = entry.suffix; os = entry.os
|
|
29
|
-
releaseDir = join(
|
|
37
|
+
releaseDir = join(targetDir, triple, 'release')
|
|
30
38
|
} else {
|
|
31
39
|
suffix = hostSuffixMap[`${platform}-${arch}`]; os = platform
|
|
32
|
-
releaseDir = join(
|
|
40
|
+
releaseDir = join(targetDir, 'release')
|
|
33
41
|
if (!suffix) throw new Error(`${TAG} unsupported platform/arch: ${platform}-${arch}`)
|
|
34
42
|
}
|
|
35
43
|
|
|
@@ -130,12 +130,15 @@ for (const fn of fns) {
|
|
|
130
130
|
// napi-derive emits the whole declaration for a function, unlike a struct
|
|
131
131
|
// where `def` holds only the members.
|
|
132
132
|
const declaration = fn.def.trim()
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
// napi-derive 3 emits a bare `function name(...)` where 2 emitted the
|
|
134
|
+
// signature after the name; concatenating onto the former produced
|
|
135
|
+
// `function xfunction x(...)`.
|
|
136
|
+
const rendered = declaration.startsWith('export declare function')
|
|
137
|
+
? declaration
|
|
138
|
+
: declaration.startsWith('function ')
|
|
139
|
+
? `export declare ${declaration}`
|
|
140
|
+
: `export declare function ${fn.name}${declaration}`
|
|
141
|
+
out.push(`${rendered};`, '')
|
|
139
142
|
}
|
|
140
143
|
|
|
141
144
|
const stale = Object.keys(CALLBACK_REFINEMENTS).filter((k) => !used.has(k))
|
package/scripts/verify-wasm.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process'
|
|
1
2
|
import { existsSync, readFileSync, statSync } from 'node:fs'
|
|
2
3
|
import { dirname, join } from 'node:path'
|
|
3
4
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
@@ -53,4 +54,31 @@ if (wasm.cmp('1.20', '1.2') !== 0) {
|
|
|
53
54
|
throw new Error('[atom:wasm] cmp smoke test failed')
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
// Present on disk is NOT the same question as present in the package, and it is
|
|
58
|
+
// the weaker one. `wasm-pack` writes a `.gitignore` of `*` into its out-dir, and
|
|
59
|
+
// npm honours a .gitignore nested inside a published directory even when `files`
|
|
60
|
+
// lists that directory — so every check above, smoke tests included, can pass
|
|
61
|
+
// while the tarball ships nothing. That is exactly how 0.1.12 went out.
|
|
62
|
+
//
|
|
63
|
+
// So ask the packer. `--ignore-scripts` keeps this from re-entering
|
|
64
|
+
// prepublishOnly, which is what invoked us.
|
|
65
|
+
const packed = JSON.parse(
|
|
66
|
+
execFileSync('npm', ['pack', '--dry-run', '--json', '--ignore-scripts'], {
|
|
67
|
+
cwd: join(here, '..'),
|
|
68
|
+
encoding: 'utf-8',
|
|
69
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
70
|
+
}),
|
|
71
|
+
)[0]
|
|
72
|
+
|
|
73
|
+
const shipped = new Set(packed.files.map((f) => f.path))
|
|
74
|
+
for (const name of required) {
|
|
75
|
+
if (!shipped.has(`wasm/${name}`)) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`[atom:wasm] wasm/${name} is on disk but NOT in the tarball — something is excluding it ` +
|
|
78
|
+
`(a .gitignore or .npmignore nested in wasm/ will do this even though "wasm" is in package.json files). ` +
|
|
79
|
+
`Run \`node scripts/clean-wasm-pack-meta.mjs\` after wasm-pack.`,
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(`[atom:wasm] browser artifacts present, functional, and in the tarball (${shipped.size} files)`)
|