@wavehouse/chtypes 1.0.2 → 1.0.4
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/CHANGELOG.md +18 -0
- package/dist/abi1/index.d.ts +1 -1
- package/dist/abi1/index.d.ts.map +1 -1
- package/dist/abi1/index.js +1 -1
- package/dist/abi1/index.js.map +1 -1
- package/dist/abi1/loader.d.ts +2 -2
- package/dist/abi1/loader.d.ts.map +1 -1
- package/dist/abi1/loader.js +8 -14
- package/dist/abi1/loader.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +7 -1
- package/dist/cli.js.map +1 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +16 -4
- package/dist/library.js.map +1 -1
- package/dist/ocifetch/ensure.d.ts +9 -0
- package/dist/ocifetch/ensure.d.ts.map +1 -1
- package/dist/ocifetch/ensure.js +61 -21
- package/dist/ocifetch/ensure.js.map +1 -1
- package/dist/ocifetch/index.d.ts +2 -2
- package/dist/ocifetch/index.d.ts.map +1 -1
- package/dist/ocifetch/index.js +2 -2
- package/dist/ocifetch/index.js.map +1 -1
- package/dist/ocifetch/layout.d.ts +28 -2
- package/dist/ocifetch/layout.d.ts.map +1 -1
- package/dist/ocifetch/layout.js +89 -6
- package/dist/ocifetch/layout.js.map +1 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +41 -11
- package/dist/registry.js.map +1 -1
- package/dist/setup.d.ts +17 -10
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +36 -19
- package/dist/setup.js.map +1 -1
- package/package.json +1 -1
package/dist/setup.js
CHANGED
|
@@ -11,12 +11,16 @@
|
|
|
11
11
|
* the first open records the empty setup: the empty zone, which the
|
|
12
12
|
* library reads as UTC, and no defaults. Once an image completes loader
|
|
13
13
|
* step 7 (`chs_initialize`, then `chs_set_defaults` when there are
|
|
14
|
-
* defaults), `setup` succeeds only with exactly the setup in effect
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* defaults), `setup` succeeds only with exactly the setup in effect
|
|
15
|
+
* (`latchSetup`). Until then, an open that attempted a load and failed,
|
|
16
|
+
* whatever failed (the fetch, the signature, an incompatible artifact, a
|
|
17
|
+
* missing symbol or step 7), keeps the record but makes it replaceable
|
|
18
|
+
* (`settleFailedOpen`): a retry with no new `setup` runs under the
|
|
19
|
+
* recorded setup, and a different `setup` replaces it. A refused version
|
|
20
|
+
* spelling or an unverified open without the caller's opt-in fails before
|
|
21
|
+
* any load is attempted, and unlocks nothing.
|
|
17
22
|
* 3. Every image is set up at loader step 7, once, from this record
|
|
18
|
-
* (`./abi1/loader.ts`)
|
|
19
|
-
* nothing sets either again for that image.
|
|
23
|
+
* (`./abi1/loader.ts`); nothing sets either again for that image.
|
|
20
24
|
*
|
|
21
25
|
* This is state of the isolate: every worker thread calls it identically, and
|
|
22
26
|
* a worker whose zone differs is refused by the library at its first open.
|
|
@@ -26,6 +30,10 @@ import { validateDefaults } from './settings.js';
|
|
|
26
30
|
let recorded;
|
|
27
31
|
/** Whether any image has completed loader step 7 under the record. */
|
|
28
32
|
let latched = false;
|
|
33
|
+
/** Whether an open that attempted a load failed since the record was last set or committed, with nothing latched: a different `setup` then replaces the record instead of being refused. */
|
|
34
|
+
let replaceable = false;
|
|
35
|
+
/** Counts the records `setup` made or replaced. An open reads it when its attempt begins, and unlocks the record on failure only if it is unchanged: a failed open never unlocks a setup recorded after it began. */
|
|
36
|
+
let generation = 0;
|
|
29
37
|
function describe(s) {
|
|
30
38
|
const keys = Object.keys(s.defaults).sort();
|
|
31
39
|
const defaults = keys.length === 0 ? 'no defaults' : `defaults ${JSON.stringify(Object.fromEntries(keys.map((k) => [k, s.defaults[k]])))}`;
|
|
@@ -46,34 +54,43 @@ export function setup(options = {}) {
|
|
|
46
54
|
const defaults = options.defaults ?? {};
|
|
47
55
|
validateDefaults(defaults);
|
|
48
56
|
const next = { timezone, defaults: { ...defaults } };
|
|
49
|
-
if (recorded
|
|
50
|
-
recorded = next;
|
|
57
|
+
if (recorded !== undefined && same(recorded, next))
|
|
51
58
|
return;
|
|
52
|
-
|
|
53
|
-
if (!same(recorded, next)) {
|
|
59
|
+
if (recorded !== undefined && (latched || !replaceable)) {
|
|
54
60
|
throw usageError(`setup was already fixed at ${describe(recorded)}; it was asked for ${describe(next)}. The first setup stands: call setup before the first open, once.`);
|
|
55
61
|
}
|
|
62
|
+
// A first record, or a replacement after a failed open: either way the new record is locked until the next failed open.
|
|
63
|
+
recorded = next;
|
|
64
|
+
replaceable = false;
|
|
65
|
+
generation += 1;
|
|
56
66
|
}
|
|
57
|
-
/** The setup in effect, recording the empty setup if none was recorded: what an open does before step 7. */
|
|
67
|
+
/** The setup in effect, recording the empty setup if none was recorded: what an open does before step 7. The load that follows claims the record, so it is locked again. */
|
|
58
68
|
export function commitSetup() {
|
|
59
69
|
recorded ??= { timezone: '', defaults: {} };
|
|
70
|
+
replaceable = false;
|
|
60
71
|
return recorded;
|
|
61
72
|
}
|
|
73
|
+
/** Read when an open's attempt begins, for `settleFailedOpen`. */
|
|
74
|
+
export function setupGeneration() {
|
|
75
|
+
return generation;
|
|
76
|
+
}
|
|
77
|
+
/** An image completed loader step 7: from then on the setup in effect stands. An open calls it synchronously after the load that committed the record, so it latches the record that load ran under. */
|
|
78
|
+
export function latchSetup() {
|
|
79
|
+
latched = true;
|
|
80
|
+
replaceable = false;
|
|
81
|
+
}
|
|
62
82
|
/**
|
|
63
|
-
*
|
|
64
|
-
* An isolate runs this synchronously with the commit and the load that preceded it, so the record it settles is the one that load ran under.
|
|
83
|
+
* Settle an open that attempted a load and failed, whatever failed. While no image has completed step 7 it unlocks the record: the record stays, so a retry runs under it, and a different `setup` may replace it. It leaves alone a setup recorded or replaced after the open began (`began` is `setupGeneration()` then), and once the setup has latched it changes nothing: the library's own process-once rule answers a different zone on an image that already has one.
|
|
65
84
|
*/
|
|
66
|
-
export function
|
|
67
|
-
if (
|
|
68
|
-
latched = true;
|
|
85
|
+
export function settleFailedOpen(began) {
|
|
86
|
+
if (latched || recorded === undefined || generation !== began)
|
|
69
87
|
return;
|
|
70
|
-
|
|
71
|
-
if (!latched)
|
|
72
|
-
recorded = undefined;
|
|
88
|
+
replaceable = true;
|
|
73
89
|
}
|
|
74
|
-
/** Test only: forget the recorded setup and the
|
|
90
|
+
/** Test only: forget the recorded setup, the latch and the unlock. Not part of the public API. */
|
|
75
91
|
export function resetSetupForTests() {
|
|
76
92
|
recorded = undefined;
|
|
77
93
|
latched = false;
|
|
94
|
+
replaceable = false;
|
|
78
95
|
}
|
|
79
96
|
//# sourceMappingURL=setup.js.map
|
package/dist/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAiB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAchE,IAAI,QAAkC,CAAC;AACvC,sEAAsE;AACtE,IAAI,OAAO,GAAG,KAAK,CAAC;AACpB,4LAA4L;AAC5L,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,qNAAqN;AACrN,IAAI,UAAU,GAAG,CAAC,CAAC;AAEnB,SAAS,QAAQ,CAAC,CAAe;IAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;IAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EA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