@valbuild/server 0.154.3 → 0.154.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 +14 -0
- package/browser/dist/valbuild-server-browser.cjs.dev.js +4 -4
- package/browser/dist/valbuild-server-browser.cjs.prod.js +4 -4
- package/browser/dist/valbuild-server-browser.esm.js +4 -4
- package/dist/{ValOpsMemory-972616ae.esm.js → ValOpsMemory-82af54c9.esm.js} +33 -14
- package/dist/{ValOpsMemory-45ba05ad.cjs.dev.js → ValOpsMemory-88633e0f.cjs.dev.js} +32 -12
- package/dist/{ValOpsMemory-18337353.cjs.prod.js → ValOpsMemory-a1a58597.cjs.prod.js} +32 -12
- package/dist/{ValPatchStore-df8cdbe7.cjs.dev.js → ValPatchStore-457b166f.cjs.prod.js} +37 -59
- package/dist/{ValPatchStore-e23070df.esm.js → ValPatchStore-9ccc09e7.esm.js} +38 -60
- package/dist/{ValPatchStore-2f92eced.cjs.prod.js → ValPatchStore-b53db740.cjs.dev.js} +37 -59
- package/dist/{ValRouterCore-86757d56.cjs.dev.js → ValRouterCore-65bb6323.cjs.prod.js} +11 -2
- package/dist/{ValRouterCore-5b747abb.cjs.prod.js → ValRouterCore-adb69698.cjs.dev.js} +11 -2
- package/dist/{ValRouterCore-73eb843d.esm.js → ValRouterCore-f7d6394e.esm.js} +11 -2
- package/dist/{createPrettierFormatter-851fcf99.cjs.dev.js → createPrettierFormatter-5d830bdf.cjs.dev.js} +6 -14
- package/dist/{createPrettierFormatter-05ad7480.cjs.prod.js → createPrettierFormatter-b31bfbe5.cjs.prod.js} +6 -14
- package/dist/{createPrettierFormatter-1edca494.esm.js → createPrettierFormatter-ce478de1.esm.js} +7 -15
- package/dist/{createValRuntime-472df6e8.cjs.prod.js → createValRuntime-07bf43dd.cjs.prod.js} +5 -5
- package/dist/{createValRuntime-5cebf459.cjs.dev.js → createValRuntime-858474b4.cjs.dev.js} +5 -5
- package/dist/{createValRuntime-c77ee010.esm.js → createValRuntime-d34c69e8.esm.js} +5 -5
- package/dist/declarations/src/draftReads.d.ts +5 -0
- package/dist/declarations/src/head.d.ts +7 -7
- package/dist/{draftReads-3f7dcda5.cjs.prod.js → draftReads-1f256502.cjs.dev.js} +5 -0
- package/dist/{draftReads-a300a02f.cjs.dev.js → draftReads-27351e97.cjs.prod.js} +5 -0
- package/dist/{draftReads-bca0d49c.esm.js → draftReads-7f0f0eb3.esm.js} +5 -0
- package/dist/{inTabFetch-0c997998.esm.js → inTabFetch-54c1cb83.esm.js} +2 -2
- package/dist/{inTabFetch-c2efa1bd.cjs.prod.js → inTabFetch-e9a48fac.cjs.prod.js} +2 -2
- package/dist/{inTabFetch-db6d6425.cjs.dev.js → inTabFetch-fb9cf5e0.cjs.dev.js} +2 -2
- package/dist/{proposalJsonEntries-0669f027.esm.js → proposalJsonEntries-2cd6f6fe.esm.js} +1 -1
- package/dist/{proposalJsonEntries-26f397bd.cjs.dev.js → proposalJsonEntries-d21900d4.cjs.dev.js} +1 -1
- package/dist/{proposalJsonEntries-9e537244.cjs.prod.js → proposalJsonEntries-d4623810.cjs.prod.js} +1 -1
- package/dist/{publishKit-ac0af189.esm.js → publishKit-4e7a1516.esm.js} +7 -7
- package/dist/{publishKit-38d46a51.cjs.dev.js → publishKit-6b88a02e.cjs.dev.js} +5 -5
- package/dist/{publishKit-7aca03bb.cjs.prod.js → publishKit-cf3858a0.cjs.prod.js} +5 -5
- package/dist/{valRuntime-70ee2dc2.cjs.dev.js → valRuntime-5cadce34.cjs.dev.js} +41 -23
- package/dist/{valRuntime-2a3cc887.cjs.prod.js → valRuntime-ae69b225.cjs.prod.js} +41 -23
- package/dist/{valRuntime-e4d26702.esm.js → valRuntime-ca9958fc.esm.js} +42 -24
- package/dist/valbuild-server.cjs.dev.js +6 -6
- package/dist/valbuild-server.cjs.prod.js +6 -6
- package/dist/valbuild-server.esm.js +9 -9
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.dev.js +5 -5
- package/internal/browser/dist/valbuild-server-internal-browser.cjs.prod.js +5 -5
- package/internal/browser/dist/valbuild-server-internal-browser.esm.js +5 -5
- package/internal/dist/valbuild-server-internal.cjs.dev.js +4 -4
- package/internal/dist/valbuild-server-internal.cjs.prod.js +4 -4
- package/internal/dist/valbuild-server-internal.esm.js +4 -4
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Internal } from '@valbuild/core';
|
|
2
|
-
import { memoryTier, tiered, bundleTier, moduleKey, EMPTY_CHAIN, baseModuleContent, applyPatchRecord, extendChain, entryState, engineWork, resolveEntry, parseModuleKey } from '@valbuild/shared/internal';
|
|
2
|
+
import { settledOnce, SettledCache, memoryTier, tiered, bundleTier, moduleKey, EMPTY_CHAIN, baseModuleContent, applyPatchRecord, extendChain, entryState, engineWork, resolveEntry, parseModuleKey } from '@valbuild/shared/internal';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The patches a json entry render should apply, out of the whole chain:
|
|
@@ -159,10 +159,37 @@ class ValHead {
|
|
|
159
159
|
memory;
|
|
160
160
|
store;
|
|
161
161
|
facts = new WeakMap();
|
|
162
|
+
/*
|
|
163
|
+
* What the head keeps between reads is what they SETTLED to, never a
|
|
164
|
+
* promise one of them is still waiting on: a head lives as long as the
|
|
165
|
+
* process, and on workerd a promise belongs to the request that made it --
|
|
166
|
+
* one that ends while its read is pending leaves a promise every later
|
|
167
|
+
* request fails on. See `SettledCache` in `@valbuild/shared/internal`.
|
|
168
|
+
* So two requests that find the chain moved at the same moment each fetch
|
|
169
|
+
* it: they used to join one fetch.
|
|
170
|
+
*/
|
|
162
171
|
chain = null;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
serialized = settledOnce(() => this.ops.getSchemas().then(schemas => {
|
|
173
|
+
const serialized = {};
|
|
174
|
+
for (const [path, schema] of Object.entries(schemas)) {
|
|
175
|
+
try {
|
|
176
|
+
serialized[path] = schema["executeSerialize"]();
|
|
177
|
+
} catch {
|
|
178
|
+
// Reported elsewhere; read as "no schema", as the engine does.
|
|
179
|
+
serialized[path] = undefined;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return serialized;
|
|
183
|
+
}));
|
|
184
|
+
/** {@link tree}, for the newest chain it was made at. */
|
|
185
|
+
wholeTree = new SettledCache({
|
|
186
|
+
keep: made => "ok" in made,
|
|
187
|
+
max: 1
|
|
188
|
+
});
|
|
189
|
+
/** {@link changed}, made once per chain: it looks at every record's markers. */
|
|
190
|
+
changedIn = new SettledCache({
|
|
191
|
+
max: 1
|
|
192
|
+
});
|
|
166
193
|
constructor(ops, opts = {}) {
|
|
167
194
|
this.ops = ops;
|
|
168
195
|
this.memory = memoryTier({
|
|
@@ -184,8 +211,8 @@ class ValHead {
|
|
|
184
211
|
|
|
185
212
|
/**
|
|
186
213
|
* The chain, re-read only when `seq` moved (or the base did: a publish
|
|
187
|
-
* adopted). A read that finds
|
|
188
|
-
*
|
|
214
|
+
* adopted). A read that finds it moved fetches it, even while another
|
|
215
|
+
* read's fetch is under way: see {@link chain}.
|
|
189
216
|
*
|
|
190
217
|
* Asks "has the chain moved?" once per call -- in http mode one request to
|
|
191
218
|
* the content service. A caller that reads several modules for ONE answer
|
|
@@ -202,26 +229,7 @@ class ValHead {
|
|
|
202
229
|
ok: held
|
|
203
230
|
};
|
|
204
231
|
}
|
|
205
|
-
|
|
206
|
-
if (position !== null && fetching !== null && fetching.seq === position.seq && fetching.epoch === position.epoch) {
|
|
207
|
-
return fetching.promise;
|
|
208
|
-
}
|
|
209
|
-
const promise = this.fetchChain(position, base);
|
|
210
|
-
if (position !== null) {
|
|
211
|
-
const started = {
|
|
212
|
-
...position,
|
|
213
|
-
promise
|
|
214
|
-
};
|
|
215
|
-
this.fetching = started;
|
|
216
|
-
// Cleared however it ends. `finally` would hand on a rejection to a
|
|
217
|
-
// promise nobody holds: an unhandled rejection, which ends a Node
|
|
218
|
-
// process. The caller is handed `promise` itself, and sees it.
|
|
219
|
-
const done = () => {
|
|
220
|
-
if (this.fetching === started) this.fetching = null;
|
|
221
|
-
};
|
|
222
|
-
promise.then(done, done);
|
|
223
|
-
}
|
|
224
|
-
return promise;
|
|
232
|
+
return this.fetchChain(position, base);
|
|
225
233
|
}
|
|
226
234
|
|
|
227
235
|
/** The chain a read is answered at: the one given, or the newest. */
|
|
@@ -288,19 +296,7 @@ class ValHead {
|
|
|
288
296
|
* and MCP's tools their schemas.
|
|
289
297
|
*/
|
|
290
298
|
serializedSchemas() {
|
|
291
|
-
this.serialized
|
|
292
|
-
const serialized = {};
|
|
293
|
-
for (const [path, schema] of Object.entries(schemas)) {
|
|
294
|
-
try {
|
|
295
|
-
serialized[path] = schema["executeSerialize"]();
|
|
296
|
-
} catch {
|
|
297
|
-
// Reported elsewhere; read as "no schema", as the engine does.
|
|
298
|
-
serialized[path] = undefined;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return serialized;
|
|
302
|
-
});
|
|
303
|
-
return this.serialized;
|
|
299
|
+
return this.serialized();
|
|
304
300
|
}
|
|
305
301
|
|
|
306
302
|
// #region modules
|
|
@@ -685,25 +681,14 @@ class ValHead {
|
|
|
685
681
|
* publish wrote that the bundle has not got. What `fetchValDraft` sends.
|
|
686
682
|
*/
|
|
687
683
|
async changed(at) {
|
|
688
|
-
var _made;
|
|
689
684
|
const synced = await this.at(at);
|
|
690
685
|
if ("error" in synced) return synced;
|
|
691
686
|
const chain = synced.ok;
|
|
692
|
-
|
|
693
|
-
if (((_made = made) === null || _made === void 0 ? void 0 : _made.chain) !== chain) {
|
|
694
|
-
made = {
|
|
695
|
-
chain,
|
|
696
|
-
paths: this.changedOf(chain)
|
|
697
|
-
};
|
|
698
|
-
this.changedIn = made;
|
|
699
|
-
}
|
|
687
|
+
const paths = await this.changedIn.get(chain, () => this.changedOf(chain));
|
|
700
688
|
return {
|
|
701
|
-
ok: [...
|
|
689
|
+
ok: [...paths]
|
|
702
690
|
};
|
|
703
691
|
}
|
|
704
|
-
|
|
705
|
-
/** {@link changed}, made once per chain: it looks at every record's markers. */
|
|
706
|
-
changedIn = null;
|
|
707
692
|
async changedOf(chain) {
|
|
708
693
|
const changed = new Set(chain.byModule.keys());
|
|
709
694
|
for (const path of Object.keys(chain.versions)) {
|
|
@@ -722,17 +707,10 @@ class ValHead {
|
|
|
722
707
|
* MCP read; made once per chain.
|
|
723
708
|
*/
|
|
724
709
|
async tree() {
|
|
725
|
-
var _this$wholeTree;
|
|
726
710
|
const synced = await this.sync();
|
|
727
711
|
if ("error" in synced) return synced;
|
|
728
712
|
const chain = synced.ok;
|
|
729
|
-
|
|
730
|
-
this.wholeTree = {
|
|
731
|
-
chain,
|
|
732
|
-
promise: this.makeTree(chain)
|
|
733
|
-
};
|
|
734
|
-
}
|
|
735
|
-
return this.wholeTree.promise;
|
|
713
|
+
return this.wholeTree.get(chain, () => this.makeTree(chain));
|
|
736
714
|
}
|
|
737
715
|
async makeTree(chain) {
|
|
738
716
|
const base = await this.ops.getBaseSources();
|
|
@@ -161,10 +161,37 @@ class ValHead {
|
|
|
161
161
|
memory;
|
|
162
162
|
store;
|
|
163
163
|
facts = new WeakMap();
|
|
164
|
+
/*
|
|
165
|
+
* What the head keeps between reads is what they SETTLED to, never a
|
|
166
|
+
* promise one of them is still waiting on: a head lives as long as the
|
|
167
|
+
* process, and on workerd a promise belongs to the request that made it --
|
|
168
|
+
* one that ends while its read is pending leaves a promise every later
|
|
169
|
+
* request fails on. See `SettledCache` in `@valbuild/shared/internal`.
|
|
170
|
+
* So two requests that find the chain moved at the same moment each fetch
|
|
171
|
+
* it: they used to join one fetch.
|
|
172
|
+
*/
|
|
164
173
|
chain = null;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
174
|
+
serialized = internal.settledOnce(() => this.ops.getSchemas().then(schemas => {
|
|
175
|
+
const serialized = {};
|
|
176
|
+
for (const [path, schema] of Object.entries(schemas)) {
|
|
177
|
+
try {
|
|
178
|
+
serialized[path] = schema["executeSerialize"]();
|
|
179
|
+
} catch {
|
|
180
|
+
// Reported elsewhere; read as "no schema", as the engine does.
|
|
181
|
+
serialized[path] = undefined;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return serialized;
|
|
185
|
+
}));
|
|
186
|
+
/** {@link tree}, for the newest chain it was made at. */
|
|
187
|
+
wholeTree = new internal.SettledCache({
|
|
188
|
+
keep: made => "ok" in made,
|
|
189
|
+
max: 1
|
|
190
|
+
});
|
|
191
|
+
/** {@link changed}, made once per chain: it looks at every record's markers. */
|
|
192
|
+
changedIn = new internal.SettledCache({
|
|
193
|
+
max: 1
|
|
194
|
+
});
|
|
168
195
|
constructor(ops, opts = {}) {
|
|
169
196
|
this.ops = ops;
|
|
170
197
|
this.memory = internal.memoryTier({
|
|
@@ -186,8 +213,8 @@ class ValHead {
|
|
|
186
213
|
|
|
187
214
|
/**
|
|
188
215
|
* The chain, re-read only when `seq` moved (or the base did: a publish
|
|
189
|
-
* adopted). A read that finds
|
|
190
|
-
*
|
|
216
|
+
* adopted). A read that finds it moved fetches it, even while another
|
|
217
|
+
* read's fetch is under way: see {@link chain}.
|
|
191
218
|
*
|
|
192
219
|
* Asks "has the chain moved?" once per call -- in http mode one request to
|
|
193
220
|
* the content service. A caller that reads several modules for ONE answer
|
|
@@ -204,26 +231,7 @@ class ValHead {
|
|
|
204
231
|
ok: held
|
|
205
232
|
};
|
|
206
233
|
}
|
|
207
|
-
|
|
208
|
-
if (position !== null && fetching !== null && fetching.seq === position.seq && fetching.epoch === position.epoch) {
|
|
209
|
-
return fetching.promise;
|
|
210
|
-
}
|
|
211
|
-
const promise = this.fetchChain(position, base);
|
|
212
|
-
if (position !== null) {
|
|
213
|
-
const started = {
|
|
214
|
-
...position,
|
|
215
|
-
promise
|
|
216
|
-
};
|
|
217
|
-
this.fetching = started;
|
|
218
|
-
// Cleared however it ends. `finally` would hand on a rejection to a
|
|
219
|
-
// promise nobody holds: an unhandled rejection, which ends a Node
|
|
220
|
-
// process. The caller is handed `promise` itself, and sees it.
|
|
221
|
-
const done = () => {
|
|
222
|
-
if (this.fetching === started) this.fetching = null;
|
|
223
|
-
};
|
|
224
|
-
promise.then(done, done);
|
|
225
|
-
}
|
|
226
|
-
return promise;
|
|
234
|
+
return this.fetchChain(position, base);
|
|
227
235
|
}
|
|
228
236
|
|
|
229
237
|
/** The chain a read is answered at: the one given, or the newest. */
|
|
@@ -290,19 +298,7 @@ class ValHead {
|
|
|
290
298
|
* and MCP's tools their schemas.
|
|
291
299
|
*/
|
|
292
300
|
serializedSchemas() {
|
|
293
|
-
this.serialized
|
|
294
|
-
const serialized = {};
|
|
295
|
-
for (const [path, schema] of Object.entries(schemas)) {
|
|
296
|
-
try {
|
|
297
|
-
serialized[path] = schema["executeSerialize"]();
|
|
298
|
-
} catch {
|
|
299
|
-
// Reported elsewhere; read as "no schema", as the engine does.
|
|
300
|
-
serialized[path] = undefined;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return serialized;
|
|
304
|
-
});
|
|
305
|
-
return this.serialized;
|
|
301
|
+
return this.serialized();
|
|
306
302
|
}
|
|
307
303
|
|
|
308
304
|
// #region modules
|
|
@@ -687,25 +683,14 @@ class ValHead {
|
|
|
687
683
|
* publish wrote that the bundle has not got. What `fetchValDraft` sends.
|
|
688
684
|
*/
|
|
689
685
|
async changed(at) {
|
|
690
|
-
var _made;
|
|
691
686
|
const synced = await this.at(at);
|
|
692
687
|
if ("error" in synced) return synced;
|
|
693
688
|
const chain = synced.ok;
|
|
694
|
-
|
|
695
|
-
if (((_made = made) === null || _made === void 0 ? void 0 : _made.chain) !== chain) {
|
|
696
|
-
made = {
|
|
697
|
-
chain,
|
|
698
|
-
paths: this.changedOf(chain)
|
|
699
|
-
};
|
|
700
|
-
this.changedIn = made;
|
|
701
|
-
}
|
|
689
|
+
const paths = await this.changedIn.get(chain, () => this.changedOf(chain));
|
|
702
690
|
return {
|
|
703
|
-
ok: [...
|
|
691
|
+
ok: [...paths]
|
|
704
692
|
};
|
|
705
693
|
}
|
|
706
|
-
|
|
707
|
-
/** {@link changed}, made once per chain: it looks at every record's markers. */
|
|
708
|
-
changedIn = null;
|
|
709
694
|
async changedOf(chain) {
|
|
710
695
|
const changed = new Set(chain.byModule.keys());
|
|
711
696
|
for (const path of Object.keys(chain.versions)) {
|
|
@@ -724,17 +709,10 @@ class ValHead {
|
|
|
724
709
|
* MCP read; made once per chain.
|
|
725
710
|
*/
|
|
726
711
|
async tree() {
|
|
727
|
-
var _this$wholeTree;
|
|
728
712
|
const synced = await this.sync();
|
|
729
713
|
if ("error" in synced) return synced;
|
|
730
714
|
const chain = synced.ok;
|
|
731
|
-
|
|
732
|
-
this.wholeTree = {
|
|
733
|
-
chain,
|
|
734
|
-
promise: this.makeTree(chain)
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
return this.wholeTree.promise;
|
|
715
|
+
return this.wholeTree.get(chain, () => this.makeTree(chain));
|
|
738
716
|
}
|
|
739
717
|
async makeTree(chain) {
|
|
740
718
|
const base = await this.ops.getBaseSources();
|
|
@@ -217,13 +217,22 @@ function createValRequestHandler(route, valServerPromise, convert, serveStatic)
|
|
|
217
217
|
// Without this no-op catch, a config error (e.g. proxy mode without a project)
|
|
218
218
|
// rejects with no handler attached, which becomes an unhandledRejection and kills
|
|
219
219
|
// the dev server. The error is still reported per request by the try/catch below.
|
|
220
|
-
|
|
220
|
+
//
|
|
221
|
+
// The server itself is kept once it is made, and every request after that
|
|
222
|
+
// reads it rather than awaiting the promise: the promise was made by
|
|
223
|
+
// whichever request first loaded the app's route module, and on workerd a
|
|
224
|
+
// request awaiting a promise of one that has ended fails. See
|
|
225
|
+
// `SettledCache` in `@valbuild/shared/internal`.
|
|
226
|
+
let made = null;
|
|
227
|
+
valServerPromise.then(server => {
|
|
228
|
+
made = server;
|
|
229
|
+
}, () => {
|
|
221
230
|
// handled below
|
|
222
231
|
});
|
|
223
232
|
return async req => {
|
|
224
233
|
let valServer;
|
|
225
234
|
try {
|
|
226
|
-
valServer = await valServerPromise;
|
|
235
|
+
valServer = made ?? (await valServerPromise);
|
|
227
236
|
} catch (err) {
|
|
228
237
|
const error = {
|
|
229
238
|
message: "Val: could not start the Val server",
|
|
@@ -217,13 +217,22 @@ function createValRequestHandler(route, valServerPromise, convert, serveStatic)
|
|
|
217
217
|
// Without this no-op catch, a config error (e.g. proxy mode without a project)
|
|
218
218
|
// rejects with no handler attached, which becomes an unhandledRejection and kills
|
|
219
219
|
// the dev server. The error is still reported per request by the try/catch below.
|
|
220
|
-
|
|
220
|
+
//
|
|
221
|
+
// The server itself is kept once it is made, and every request after that
|
|
222
|
+
// reads it rather than awaiting the promise: the promise was made by
|
|
223
|
+
// whichever request first loaded the app's route module, and on workerd a
|
|
224
|
+
// request awaiting a promise of one that has ended fails. See
|
|
225
|
+
// `SettledCache` in `@valbuild/shared/internal`.
|
|
226
|
+
let made = null;
|
|
227
|
+
valServerPromise.then(server => {
|
|
228
|
+
made = server;
|
|
229
|
+
}, () => {
|
|
221
230
|
// handled below
|
|
222
231
|
});
|
|
223
232
|
return async req => {
|
|
224
233
|
let valServer;
|
|
225
234
|
try {
|
|
226
|
-
valServer = await valServerPromise;
|
|
235
|
+
valServer = made ?? (await valServerPromise);
|
|
227
236
|
} catch (err) {
|
|
228
237
|
const error = {
|
|
229
238
|
message: "Val: could not start the Val server",
|
|
@@ -215,13 +215,22 @@ function createValRequestHandler(route, valServerPromise, convert, serveStatic)
|
|
|
215
215
|
// Without this no-op catch, a config error (e.g. proxy mode without a project)
|
|
216
216
|
// rejects with no handler attached, which becomes an unhandledRejection and kills
|
|
217
217
|
// the dev server. The error is still reported per request by the try/catch below.
|
|
218
|
-
|
|
218
|
+
//
|
|
219
|
+
// The server itself is kept once it is made, and every request after that
|
|
220
|
+
// reads it rather than awaiting the promise: the promise was made by
|
|
221
|
+
// whichever request first loaded the app's route module, and on workerd a
|
|
222
|
+
// request awaiting a promise of one that has ended fails. See
|
|
223
|
+
// `SettledCache` in `@valbuild/shared/internal`.
|
|
224
|
+
let made = null;
|
|
225
|
+
valServerPromise.then(server => {
|
|
226
|
+
made = server;
|
|
227
|
+
}, () => {
|
|
219
228
|
// handled below
|
|
220
229
|
});
|
|
221
230
|
return async req => {
|
|
222
231
|
let valServer;
|
|
223
232
|
try {
|
|
224
|
-
valServer = await valServerPromise;
|
|
233
|
+
valServer = made ?? (await valServerPromise);
|
|
225
234
|
} catch (err) {
|
|
226
235
|
const error = {
|
|
227
236
|
message: "Val: could not start the Val server",
|
|
@@ -415,7 +415,7 @@ async function readerSnapshot(proposal, projectSource) {
|
|
|
415
415
|
}
|
|
416
416
|
const {
|
|
417
417
|
proposalSnapshotForReaders
|
|
418
|
-
} = await Promise.resolve().then(function () { return require('./proposalJsonEntries-
|
|
418
|
+
} = await Promise.resolve().then(function () { return require('./proposalJsonEntries-d21900d4.cjs.dev.js'); }).then(function (n) { return n.proposalJsonEntries$1; });
|
|
419
419
|
return proposalSnapshotForReaders(proposal, projectSource);
|
|
420
420
|
}
|
|
421
421
|
|
|
@@ -637,19 +637,11 @@ function resolveAgainstProject(projectRoot, filePath) {
|
|
|
637
637
|
* without a config has asked for.
|
|
638
638
|
*/
|
|
639
639
|
function createPrettierFormatter(prettierOrLoader, options) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
// Forgotten when it fails, so the next save tries again rather than
|
|
646
|
-
// failing on the same rejected promise for the life of the process.
|
|
647
|
-
loaded ??= prettierOrLoader().catch(err => {
|
|
648
|
-
loaded = null;
|
|
649
|
-
throw err;
|
|
650
|
-
});
|
|
651
|
-
return loaded;
|
|
652
|
-
};
|
|
640
|
+
// Kept once it is loaded -- prettier, never the promise of it: a server on
|
|
641
|
+
// a workerd isolate shares this closure between requests, and a promise
|
|
642
|
+
// made by a request that has ended fails every other request awaiting it.
|
|
643
|
+
// One that fails is loaded again by the next save.
|
|
644
|
+
const loadPrettier = typeof prettierOrLoader === "function" ? internal.keptOnce(prettierOrLoader) : () => Promise.resolve(prettierOrLoader);
|
|
653
645
|
const projectRoot = path__default["default"].resolve(options.projectRoot);
|
|
654
646
|
// One array, built once: prettier reads and caches the ignore file itself, so
|
|
655
647
|
// this is only here to avoid rebuilding the path per file.
|
|
@@ -415,7 +415,7 @@ async function readerSnapshot(proposal, projectSource) {
|
|
|
415
415
|
}
|
|
416
416
|
const {
|
|
417
417
|
proposalSnapshotForReaders
|
|
418
|
-
} = await Promise.resolve().then(function () { return require('./proposalJsonEntries-
|
|
418
|
+
} = await Promise.resolve().then(function () { return require('./proposalJsonEntries-d4623810.cjs.prod.js'); }).then(function (n) { return n.proposalJsonEntries$1; });
|
|
419
419
|
return proposalSnapshotForReaders(proposal, projectSource);
|
|
420
420
|
}
|
|
421
421
|
|
|
@@ -637,19 +637,11 @@ function resolveAgainstProject(projectRoot, filePath) {
|
|
|
637
637
|
* without a config has asked for.
|
|
638
638
|
*/
|
|
639
639
|
function createPrettierFormatter(prettierOrLoader, options) {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
// Forgotten when it fails, so the next save tries again rather than
|
|
646
|
-
// failing on the same rejected promise for the life of the process.
|
|
647
|
-
loaded ??= prettierOrLoader().catch(err => {
|
|
648
|
-
loaded = null;
|
|
649
|
-
throw err;
|
|
650
|
-
});
|
|
651
|
-
return loaded;
|
|
652
|
-
};
|
|
640
|
+
// Kept once it is loaded -- prettier, never the promise of it: a server on
|
|
641
|
+
// a workerd isolate shares this closure between requests, and a promise
|
|
642
|
+
// made by a request that has ended fails every other request awaiting it.
|
|
643
|
+
// One that fails is loaded again by the next save.
|
|
644
|
+
const loadPrettier = typeof prettierOrLoader === "function" ? internal.keptOnce(prettierOrLoader) : () => Promise.resolve(prettierOrLoader);
|
|
653
645
|
const projectRoot = path__default["default"].resolve(options.projectRoot);
|
|
654
646
|
// One array, built once: prettier reads and caches the ignore file itself, so
|
|
655
647
|
// this is only here to avoid rebuilding the path per file.
|
package/dist/{createPrettierFormatter-1edca494.esm.js → createPrettierFormatter-ce478de1.esm.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Internal } from '@valbuild/core';
|
|
2
|
-
import { STAGED_SCHEMA_PREFIX } from '@valbuild/shared/internal';
|
|
2
|
+
import { STAGED_SCHEMA_PREFIX, keptOnce } from '@valbuild/shared/internal';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -409,7 +409,7 @@ async function readerSnapshot(proposal, projectSource) {
|
|
|
409
409
|
}
|
|
410
410
|
const {
|
|
411
411
|
proposalSnapshotForReaders
|
|
412
|
-
} = await import('./proposalJsonEntries-
|
|
412
|
+
} = await import('./proposalJsonEntries-2cd6f6fe.esm.js').then(function (n) { return n.l; });
|
|
413
413
|
return proposalSnapshotForReaders(proposal, projectSource);
|
|
414
414
|
}
|
|
415
415
|
|
|
@@ -631,19 +631,11 @@ function resolveAgainstProject(projectRoot, filePath) {
|
|
|
631
631
|
* without a config has asked for.
|
|
632
632
|
*/
|
|
633
633
|
function createPrettierFormatter(prettierOrLoader, options) {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
// Forgotten when it fails, so the next save tries again rather than
|
|
640
|
-
// failing on the same rejected promise for the life of the process.
|
|
641
|
-
loaded ??= prettierOrLoader().catch(err => {
|
|
642
|
-
loaded = null;
|
|
643
|
-
throw err;
|
|
644
|
-
});
|
|
645
|
-
return loaded;
|
|
646
|
-
};
|
|
634
|
+
// Kept once it is loaded -- prettier, never the promise of it: a server on
|
|
635
|
+
// a workerd isolate shares this closure between requests, and a promise
|
|
636
|
+
// made by a request that has ended fails every other request awaiting it.
|
|
637
|
+
// One that fails is loaded again by the next save.
|
|
638
|
+
const loadPrettier = typeof prettierOrLoader === "function" ? keptOnce(prettierOrLoader) : () => Promise.resolve(prettierOrLoader);
|
|
647
639
|
const projectRoot = path.resolve(options.projectRoot);
|
|
648
640
|
// One array, built once: prettier reads and caches the ignore file itself, so
|
|
649
641
|
// this is only here to avoid rebuilding the path per file.
|
package/dist/{createValRuntime-472df6e8.cjs.prod.js → createValRuntime-07bf43dd.cjs.prod.js}
RENAMED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var valRuntime = require('./valRuntime-
|
|
3
|
+
var valRuntime = require('./valRuntime-ae69b225.cjs.prod.js');
|
|
4
4
|
require('@valbuild/core');
|
|
5
|
-
require('./ValOpsMemory-
|
|
5
|
+
require('./ValOpsMemory-a1a58597.cjs.prod.js');
|
|
6
6
|
require('zod');
|
|
7
7
|
require('@valbuild/shared/internal');
|
|
8
8
|
require('./jsonValuesPatch-92798812.cjs.prod.js');
|
|
9
9
|
require('@valbuild/core/fp');
|
|
10
10
|
require('zod-validation-error');
|
|
11
|
-
require('./ValPatchStore-
|
|
11
|
+
require('./ValPatchStore-457b166f.cjs.prod.js');
|
|
12
12
|
require('@valbuild/core/patch');
|
|
13
13
|
require('image-size');
|
|
14
14
|
require('path');
|
|
15
15
|
require('typescript');
|
|
16
16
|
require('fs');
|
|
17
|
-
require('./proposalJsonEntries-
|
|
18
|
-
require('./createPrettierFormatter-
|
|
17
|
+
require('./proposalJsonEntries-d4623810.cjs.prod.js');
|
|
18
|
+
require('./createPrettierFormatter-b31bfbe5.cjs.prod.js');
|
|
19
19
|
require('os');
|
|
20
20
|
require('crypto');
|
|
21
21
|
require('buffer');
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var valRuntime = require('./valRuntime-
|
|
3
|
+
var valRuntime = require('./valRuntime-5cadce34.cjs.dev.js');
|
|
4
4
|
require('@valbuild/core');
|
|
5
|
-
require('./ValOpsMemory-
|
|
5
|
+
require('./ValOpsMemory-88633e0f.cjs.dev.js');
|
|
6
6
|
require('zod');
|
|
7
7
|
require('@valbuild/shared/internal');
|
|
8
8
|
require('./jsonValuesPatch-88bc661d.cjs.dev.js');
|
|
9
9
|
require('@valbuild/core/fp');
|
|
10
10
|
require('zod-validation-error');
|
|
11
|
-
require('./ValPatchStore-
|
|
11
|
+
require('./ValPatchStore-b53db740.cjs.dev.js');
|
|
12
12
|
require('@valbuild/core/patch');
|
|
13
13
|
require('image-size');
|
|
14
14
|
require('path');
|
|
15
15
|
require('typescript');
|
|
16
16
|
require('fs');
|
|
17
|
-
require('./proposalJsonEntries-
|
|
18
|
-
require('./createPrettierFormatter-
|
|
17
|
+
require('./proposalJsonEntries-d21900d4.cjs.dev.js');
|
|
18
|
+
require('./createPrettierFormatter-5d830bdf.cjs.dev.js');
|
|
19
19
|
require('os');
|
|
20
20
|
require('crypto');
|
|
21
21
|
require('buffer');
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { i as initHandlerOptions, v as valRuntime } from './valRuntime-
|
|
1
|
+
import { i as initHandlerOptions, v as valRuntime } from './valRuntime-ca9958fc.esm.js';
|
|
2
2
|
import '@valbuild/core';
|
|
3
|
-
import './ValOpsMemory-
|
|
3
|
+
import './ValOpsMemory-82af54c9.esm.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@valbuild/shared/internal';
|
|
6
6
|
import './jsonValuesPatch-13acc674.esm.js';
|
|
7
7
|
import '@valbuild/core/fp';
|
|
8
8
|
import 'zod-validation-error';
|
|
9
|
-
import './ValPatchStore-
|
|
9
|
+
import './ValPatchStore-9ccc09e7.esm.js';
|
|
10
10
|
import '@valbuild/core/patch';
|
|
11
11
|
import 'image-size';
|
|
12
12
|
import 'path';
|
|
13
13
|
import 'typescript';
|
|
14
14
|
import 'fs';
|
|
15
|
-
import './proposalJsonEntries-
|
|
16
|
-
import './createPrettierFormatter-
|
|
15
|
+
import './proposalJsonEntries-2cd6f6fe.esm.js';
|
|
16
|
+
import './createPrettierFormatter-ce478de1.esm.js';
|
|
17
17
|
import 'os';
|
|
18
18
|
import 'crypto';
|
|
19
19
|
import 'buffer';
|
|
@@ -16,6 +16,11 @@ type Headers = {
|
|
|
16
16
|
* building the readers does not build the runtime: the runtime is the data
|
|
17
17
|
* layer, and a visitor -- draft mode off -- never needs it. A caller that
|
|
18
18
|
* already has one passes `() => runtime`; it is asked at most once a read.
|
|
19
|
+
*
|
|
20
|
+
* The frameworks' getter keeps the runtime once it is made (`settledOnce`),
|
|
21
|
+
* never the promise of it: the readers are made once per process, and a
|
|
22
|
+
* promise made in one request and awaited in another is what workerd fails a
|
|
23
|
+
* request for (see `SettledCache` in `@valbuild/shared/internal`).
|
|
19
24
|
*/
|
|
20
25
|
export type ReaderRuntime = () => Promise<ValRuntime>;
|
|
21
26
|
/** One module {@link readDraftChanges} read: what a reader's `reads` record. */
|
|
@@ -131,9 +131,11 @@ export declare class ValHead {
|
|
|
131
131
|
private readonly store;
|
|
132
132
|
private readonly facts;
|
|
133
133
|
private chain;
|
|
134
|
-
private
|
|
135
|
-
|
|
136
|
-
private wholeTree;
|
|
134
|
+
private readonly serialized;
|
|
135
|
+
/** {@link tree}, for the newest chain it was made at. */
|
|
136
|
+
private readonly wholeTree;
|
|
137
|
+
/** {@link changed}, made once per chain: it looks at every record's markers. */
|
|
138
|
+
private readonly changedIn;
|
|
137
139
|
constructor(ops: ValOps, opts?: {
|
|
138
140
|
budgetBytes?: number;
|
|
139
141
|
lastPerModule?: number;
|
|
@@ -142,8 +144,8 @@ export declare class ValHead {
|
|
|
142
144
|
stats(): MemoryTierStats;
|
|
143
145
|
/**
|
|
144
146
|
* The chain, re-read only when `seq` moved (or the base did: a publish
|
|
145
|
-
* adopted). A read that finds
|
|
146
|
-
*
|
|
147
|
+
* adopted). A read that finds it moved fetches it, even while another
|
|
148
|
+
* read's fetch is under way: see {@link chain}.
|
|
147
149
|
*
|
|
148
150
|
* Asks "has the chain moved?" once per call -- in http mode one request to
|
|
149
151
|
* the content service. A caller that reads several modules for ONE answer
|
|
@@ -206,8 +208,6 @@ export declare class ValHead {
|
|
|
206
208
|
* publish wrote that the bundle has not got. What `fetchValDraft` sends.
|
|
207
209
|
*/
|
|
208
210
|
changed(at?: HeadChain): Promise<HeadResult<ModuleFilePath[]>>;
|
|
209
|
-
/** {@link changed}, made once per chain: it looks at every record's markers. */
|
|
210
|
-
private changedIn;
|
|
211
211
|
private changedOf;
|
|
212
212
|
/**
|
|
213
213
|
* Every module at the newest chain: the patched ones made (once per
|
|
@@ -24,6 +24,11 @@ var internal = require('@valbuild/shared/internal');
|
|
|
24
24
|
* building the readers does not build the runtime: the runtime is the data
|
|
25
25
|
* layer, and a visitor -- draft mode off -- never needs it. A caller that
|
|
26
26
|
* already has one passes `() => runtime`; it is asked at most once a read.
|
|
27
|
+
*
|
|
28
|
+
* The frameworks' getter keeps the runtime once it is made (`settledOnce`),
|
|
29
|
+
* never the promise of it: the readers are made once per process, and a
|
|
30
|
+
* promise made in one request and awaited in another is what workerd fails a
|
|
31
|
+
* request for (see `SettledCache` in `@valbuild/shared/internal`).
|
|
27
32
|
*/
|
|
28
33
|
|
|
29
34
|
/** One module {@link readDraftChanges} read: what a reader's `reads` record. */
|
|
@@ -24,6 +24,11 @@ var internal = require('@valbuild/shared/internal');
|
|
|
24
24
|
* building the readers does not build the runtime: the runtime is the data
|
|
25
25
|
* layer, and a visitor -- draft mode off -- never needs it. A caller that
|
|
26
26
|
* already has one passes `() => runtime`; it is asked at most once a read.
|
|
27
|
+
*
|
|
28
|
+
* The frameworks' getter keeps the runtime once it is made (`settledOnce`),
|
|
29
|
+
* never the promise of it: the readers are made once per process, and a
|
|
30
|
+
* promise made in one request and awaited in another is what workerd fails a
|
|
31
|
+
* request for (see `SettledCache` in `@valbuild/shared/internal`).
|
|
27
32
|
*/
|
|
28
33
|
|
|
29
34
|
/** One module {@link readDraftChanges} read: what a reader's `reads` record. */
|
|
@@ -22,6 +22,11 @@ import { VAL_SESSION_COOKIE } from '@valbuild/shared/internal';
|
|
|
22
22
|
* building the readers does not build the runtime: the runtime is the data
|
|
23
23
|
* layer, and a visitor -- draft mode off -- never needs it. A caller that
|
|
24
24
|
* already has one passes `() => runtime`; it is asked at most once a read.
|
|
25
|
+
*
|
|
26
|
+
* The frameworks' getter keeps the runtime once it is made (`settledOnce`),
|
|
27
|
+
* never the promise of it: the readers are made once per process, and a
|
|
28
|
+
* promise made in one request and awaited in another is what workerd fails a
|
|
29
|
+
* request for (see `SettledCache` in `@valbuild/shared/internal`).
|
|
25
30
|
*/
|
|
26
31
|
|
|
27
32
|
/** One module {@link readDraftChanges} read: what a reader's `reads` record. */
|