@valbuild/react 0.150.23 → 0.152.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/CHANGELOG.md +178 -0
- package/dist/declarations/src/internal/index.d.ts +1 -0
- package/dist/declarations/src/read/draft.d.ts +105 -0
- package/dist/declarations/src/read/index.d.ts +8 -0
- package/dist/declarations/src/read/jsonValues.d.ts +26 -0
- package/dist/declarations/src/read/layered.d.ts +45 -0
- package/dist/declarations/src/read/overlayStore.d.ts +113 -0
- package/dist/declarations/src/read/readers.d.ts +51 -0
- package/dist/declarations/src/read/refreshLoop.d.ts +61 -0
- package/dist/declarations/src/read/resolveVal.d.ts +93 -0
- package/dist/declarations/src/read/sources.d.ts +63 -0
- package/dist/{raw-be4b57fa.browser.esm.js → raw-15ce77ae.browser.esm.js} +1 -1
- package/dist/{raw-1b40484b.esm.js → raw-534fcde0.esm.js} +1 -1
- package/dist/{raw-43f9221a.worker.esm.js → raw-645a854a.worker.esm.js} +1 -1
- package/dist/{raw-ff060f24.cjs.dev.js → raw-67d24dd6.cjs.dev.js} +2 -0
- package/dist/{raw-b3745603.cjs.prod.js → raw-d504f4fd.cjs.prod.js} +2 -0
- package/internal/dist/valbuild-react-internal.browser.esm.js +1723 -6
- package/internal/dist/valbuild-react-internal.cjs.dev.js +1748 -4
- package/internal/dist/valbuild-react-internal.cjs.prod.js +1748 -4
- package/internal/dist/valbuild-react-internal.esm.js +1723 -6
- package/internal/dist/valbuild-react-internal.worker.esm.js +1723 -6
- package/package.json +4 -4
- package/stega/dist/valbuild-react-stega.browser.esm.js +2 -2
- package/stega/dist/valbuild-react-stega.cjs.dev.js +1 -1
- package/stega/dist/valbuild-react-stega.cjs.prod.js +1 -1
- package/stega/dist/valbuild-react-stega.esm.js +2 -2
- package/stega/dist/valbuild-react-stega.worker.esm.js +2 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { _ as _toConsumableArray } from '../../dist/createForOfIteratorHelper-595d57b7.esm.js';
|
|
2
|
-
import { _ as _objectSpread2, r as raw, c as attrs } from '../../dist/raw-
|
|
1
|
+
import { _ as _toConsumableArray, a as _createForOfIteratorHelper } from '../../dist/createForOfIteratorHelper-595d57b7.esm.js';
|
|
2
|
+
import { _ as _objectSpread2, r as raw, c as attrs, d as _toPropertyKey, e as _defineProperty, g as getModuleIds, a as stegaEncode } from '../../dist/raw-534fcde0.esm.js';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
|
-
import '../../dist/
|
|
6
|
-
import '
|
|
7
|
-
import '@valbuild/core';
|
|
5
|
+
import { _ as _typeof } from '../../dist/typeof-a1531d8f.esm.js';
|
|
6
|
+
import { Internal, RecordSchema } from '@valbuild/core';
|
|
7
|
+
import { deepEqual } from '@valbuild/core/patch';
|
|
8
|
+
import { _ as _slicedToArray } from '../../dist/slicedToArray-70ecb9da.esm.js';
|
|
8
9
|
import '@vercel/stega';
|
|
9
10
|
|
|
10
11
|
function _objectWithoutPropertiesLoose(r, e) {
|
|
@@ -147,4 +148,1720 @@ function classNameOfTag(tag, style, theme) {
|
|
|
147
148
|
}))).join(" ");
|
|
148
149
|
}
|
|
149
150
|
|
|
150
|
-
|
|
151
|
+
function _classCallCheck(a, n) {
|
|
152
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function _defineProperties(e, r) {
|
|
156
|
+
for (var t = 0; t < r.length; t++) {
|
|
157
|
+
var o = r[t];
|
|
158
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function _createClass(e, r, t) {
|
|
162
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
163
|
+
writable: !1
|
|
164
|
+
}), e;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// How long waitForLoad waits for draft data before giving up and resolving
|
|
168
|
+
// anyway (logging an error) so the Suspense boundary never hangs forever.
|
|
169
|
+
var LOAD_TIMEOUT_MS = 10000;
|
|
170
|
+
|
|
171
|
+
/** A read the overlay holds: always an answer. */
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The page's store of what the Studio sent it: one read per module, as the
|
|
175
|
+
* relay sent it (`startOverlayRelay`). What `overlaySource` answers from.
|
|
176
|
+
*
|
|
177
|
+
* Moved here from `@valbuild/next` and `@valbuild/tanstack`, which each had a
|
|
178
|
+
* copy: the page's half of the relay is the same in both.
|
|
179
|
+
*/
|
|
180
|
+
var ValExternalStore = /*#__PURE__*/function () {
|
|
181
|
+
function ValExternalStore() {
|
|
182
|
+
var _this = this;
|
|
183
|
+
_classCallCheck(this, ValExternalStore);
|
|
184
|
+
_defineProperty(this, "listeners", void 0);
|
|
185
|
+
_defineProperty(this, "loadPromises", void 0);
|
|
186
|
+
// Path-keyed reads, as the Studio sent them. The single source of truth:
|
|
187
|
+
// load state, snapshots and revisions are all derived from this, so data
|
|
188
|
+
// can be queried for any combination of paths even before a subscriber
|
|
189
|
+
// registers.
|
|
190
|
+
_defineProperty(this, "reads", void 0);
|
|
191
|
+
// Bumped per path whenever its read MOVES: what `revision` is made of.
|
|
192
|
+
_defineProperty(this, "revisions", void 0);
|
|
193
|
+
// Reference-stable per-subscriberId snapshot cache for `get`.
|
|
194
|
+
// Built lazily from `reads` in get() and invalidated in receive().
|
|
195
|
+
_defineProperty(this, "snapshots", void 0);
|
|
196
|
+
// One-shot listeners used solely by waitForLoad. Kept separate from the
|
|
197
|
+
// useSyncExternalStore listeners so waitForLoad never has to register (and
|
|
198
|
+
// leak) a subscriberId.
|
|
199
|
+
_defineProperty(this, "loadListeners", void 0);
|
|
200
|
+
_defineProperty(this, "subscribe", function (paths) {
|
|
201
|
+
return function (listener) {
|
|
202
|
+
var subscriberId = createSubscriberId(paths);
|
|
203
|
+
var existing = _this.listeners.get(subscriberId);
|
|
204
|
+
if (existing) {
|
|
205
|
+
existing.push(listener);
|
|
206
|
+
} else {
|
|
207
|
+
_this.listeners.set(subscriberId, [listener]);
|
|
208
|
+
}
|
|
209
|
+
return function () {
|
|
210
|
+
var current = _this.listeners.get(subscriberId);
|
|
211
|
+
if (!current) return;
|
|
212
|
+
var idx = current.indexOf(listener);
|
|
213
|
+
if (idx >= 0) current.splice(idx, 1);
|
|
214
|
+
if (current.length === 0) _this.listeners["delete"](subscriberId);
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
_defineProperty(this, "getSnapshot", function (paths) {
|
|
219
|
+
return function () {
|
|
220
|
+
return _this.get(paths);
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
_defineProperty(this, "getServerSnapshot", function (paths) {
|
|
224
|
+
return function () {
|
|
225
|
+
return _this.get(paths);
|
|
226
|
+
};
|
|
227
|
+
});
|
|
228
|
+
_defineProperty(this, "get", function (paths) {
|
|
229
|
+
var subscriberId = createSubscriberId(paths);
|
|
230
|
+
if (_this.snapshots.has(subscriberId)) {
|
|
231
|
+
return _this.snapshots.get(subscriberId);
|
|
232
|
+
}
|
|
233
|
+
// Build the snapshot from the path-keyed reads so data that arrived
|
|
234
|
+
// before this subscriber registered is still returned. Cache it for a
|
|
235
|
+
// reference-stable result.
|
|
236
|
+
var record;
|
|
237
|
+
var _iterator = _createForOfIteratorHelper(paths),
|
|
238
|
+
_step;
|
|
239
|
+
try {
|
|
240
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
241
|
+
var p = _step.value;
|
|
242
|
+
var loaded = _this.reads.get(p);
|
|
243
|
+
if (loaded !== undefined) {
|
|
244
|
+
if (!record) {
|
|
245
|
+
record = {};
|
|
246
|
+
}
|
|
247
|
+
record[p] = loaded.source;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
} catch (err) {
|
|
251
|
+
_iterator.e(err);
|
|
252
|
+
} finally {
|
|
253
|
+
_iterator.f();
|
|
254
|
+
}
|
|
255
|
+
_this.snapshots.set(subscriberId, record);
|
|
256
|
+
return record;
|
|
257
|
+
});
|
|
258
|
+
_defineProperty(this, "hasAllLoaded", function (paths) {
|
|
259
|
+
var _iterator2 = _createForOfIteratorHelper(paths),
|
|
260
|
+
_step2;
|
|
261
|
+
try {
|
|
262
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
263
|
+
var p = _step2.value;
|
|
264
|
+
if (!_this.reads.has(p)) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
} catch (err) {
|
|
269
|
+
_iterator2.e(err);
|
|
270
|
+
} finally {
|
|
271
|
+
_iterator2.f();
|
|
272
|
+
}
|
|
273
|
+
return true;
|
|
274
|
+
});
|
|
275
|
+
/**
|
|
276
|
+
* Returns a cached promise that resolves once `update()` has populated
|
|
277
|
+
* every path in `paths`. The same promise instance is returned for the
|
|
278
|
+
* same paths until it resolves — required so `React.use` / classic
|
|
279
|
+
* Suspense doesn't re-suspend on every render.
|
|
280
|
+
*
|
|
281
|
+
* If the data never arrives (network failure, a path that is never
|
|
282
|
+
* `update()`'d, a typo in a module path) the promise would otherwise hang
|
|
283
|
+
* forever and keep the Suspense boundary in its fallback. To avoid a silent
|
|
284
|
+
* hang it resolves anyway after `LOAD_TIMEOUT_MS`, logging an error so the
|
|
285
|
+
* failure is diagnosable while the page still renders with partial data.
|
|
286
|
+
*/
|
|
287
|
+
_defineProperty(this, "waitForLoad", function (paths) {
|
|
288
|
+
if (_this.hasAllLoaded(paths)) {
|
|
289
|
+
return Promise.resolve();
|
|
290
|
+
}
|
|
291
|
+
var subscriberId = createSubscriberId(paths);
|
|
292
|
+
var existing = _this.loadPromises.get(subscriberId);
|
|
293
|
+
if (existing) {
|
|
294
|
+
return existing;
|
|
295
|
+
}
|
|
296
|
+
var promise = new Promise(function (resolve) {
|
|
297
|
+
var cleanup = function cleanup() {
|
|
298
|
+
clearTimeout(timeout);
|
|
299
|
+
_this.loadListeners["delete"](listener);
|
|
300
|
+
_this.loadPromises["delete"](subscriberId);
|
|
301
|
+
};
|
|
302
|
+
var listener = function listener() {
|
|
303
|
+
if (_this.hasAllLoaded(paths)) {
|
|
304
|
+
cleanup();
|
|
305
|
+
resolve();
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
var timeout = setTimeout(function () {
|
|
309
|
+
var missing = paths.filter(function (p) {
|
|
310
|
+
return !_this.reads.has(p);
|
|
311
|
+
});
|
|
312
|
+
Internal.log.error("draft module(s) did not load within ".concat(LOAD_TIMEOUT_MS, "ms; rendering with partial data. Missing: ").concat(missing.join(", ")));
|
|
313
|
+
cleanup();
|
|
314
|
+
resolve();
|
|
315
|
+
}, LOAD_TIMEOUT_MS);
|
|
316
|
+
// Don't let the pending timer keep a Node process (e.g. the test runner
|
|
317
|
+
// or SSR) alive; setTimeout returns a number in the browser, where there
|
|
318
|
+
// is nothing to unref.
|
|
319
|
+
if (typeof timeout !== "number") {
|
|
320
|
+
timeout.unref();
|
|
321
|
+
}
|
|
322
|
+
_this.loadListeners.add(listener);
|
|
323
|
+
});
|
|
324
|
+
_this.loadPromises.set(subscriberId, promise);
|
|
325
|
+
return promise;
|
|
326
|
+
});
|
|
327
|
+
this.listeners = new Map();
|
|
328
|
+
this.loadPromises = new Map();
|
|
329
|
+
this.reads = new Map();
|
|
330
|
+
this.revisions = new Map();
|
|
331
|
+
this.snapshots = new Map();
|
|
332
|
+
this.loadListeners = new Set();
|
|
333
|
+
}
|
|
334
|
+
return _createClass(ValExternalStore, [{
|
|
335
|
+
key: "update",
|
|
336
|
+
value: /** {@link receive}, for a source with nothing more to say about it. */
|
|
337
|
+
function update(path, source) {
|
|
338
|
+
return this.receive(path, {
|
|
339
|
+
status: "ready",
|
|
340
|
+
source: source,
|
|
341
|
+
from: "overlay",
|
|
342
|
+
version: null
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Take a module's read from the editor, as it sent it.
|
|
348
|
+
*
|
|
349
|
+
* Returns whether this actually MOVED the value, which the caller needs and
|
|
350
|
+
* cannot work out for itself: the same source arrives more than once by
|
|
351
|
+
* design. The editor sends a catch-up snapshot of everything it holds every
|
|
352
|
+
* time the page becomes a new document — a reload, or the one the dev server
|
|
353
|
+
* does when a publish rewrites the `.val.ts` files — and most of that
|
|
354
|
+
* snapshot is content this page already has.
|
|
355
|
+
*
|
|
356
|
+
* The answer tells the page's refresh loop whether the Studio's catch-up
|
|
357
|
+
* found the page behind (`startRefreshLoop`'s `changed`): a re-sent module
|
|
358
|
+
* the page already shows is no reason to re-read its server, and with
|
|
359
|
+
* auto-save on, counting arrivals was a whole-route request per pause in
|
|
360
|
+
* typing -- in development a re-render (and sometimes a recompile) of the
|
|
361
|
+
* page, and what left the canvas looking permanently busy.
|
|
362
|
+
*/
|
|
363
|
+
}, {
|
|
364
|
+
key: "receive",
|
|
365
|
+
value: function receive(path, read) {
|
|
366
|
+
var _this$revisions$get;
|
|
367
|
+
// A miss means this page has never been given this module.
|
|
368
|
+
var before = this.reads.get(path);
|
|
369
|
+
var changed = before === undefined || !sameContent(before, read);
|
|
370
|
+
this.reads.set(path, read);
|
|
371
|
+
if (!changed) {
|
|
372
|
+
// Nothing downstream to do: every subscriber's snapshot still answers
|
|
373
|
+
// with the same value, so invalidating them would be a re-render that
|
|
374
|
+
// shows exactly what is already on screen.
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
this.revisions.set(path, ((_this$revisions$get = this.revisions.get(path)) !== null && _this$revisions$get !== void 0 ? _this$revisions$get : 0) + 1);
|
|
378
|
+
// Invalidate cached snapshots that include this path so the next get()
|
|
379
|
+
// rebuilds a fresh (new-reference) record, then notify their listeners.
|
|
380
|
+
for (var _i = 0, _Array$from = Array.from(this.snapshots.keys()); _i < _Array$from.length; _i++) {
|
|
381
|
+
var subscriberId = _Array$from[_i];
|
|
382
|
+
if (includesPath(subscriberId, path)) {
|
|
383
|
+
this.snapshots["delete"](subscriberId);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
var _iterator3 = _createForOfIteratorHelper(this.listeners.keys()),
|
|
387
|
+
_step3;
|
|
388
|
+
try {
|
|
389
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
390
|
+
var _subscriberId = _step3.value;
|
|
391
|
+
if (includesPath(_subscriberId, path)) {
|
|
392
|
+
this.emitChange(_subscriberId);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
} catch (err) {
|
|
396
|
+
_iterator3.e(err);
|
|
397
|
+
} finally {
|
|
398
|
+
_iterator3.f();
|
|
399
|
+
}
|
|
400
|
+
for (var _i2 = 0, _Array$from2 = Array.from(this.loadListeners); _i2 < _Array$from2.length; _i2++) {
|
|
401
|
+
var listener = _Array$from2[_i2];
|
|
402
|
+
listener();
|
|
403
|
+
}
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** What the editor sent for `path`, or `undefined` for nothing yet. */
|
|
408
|
+
}, {
|
|
409
|
+
key: "read",
|
|
410
|
+
value: function read(path) {
|
|
411
|
+
return this.reads.get(path);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Changes exactly when what this store holds for any of `paths` moves: a
|
|
416
|
+
* `useSyncExternalStore` snapshot that is `===` while nothing moved.
|
|
417
|
+
*/
|
|
418
|
+
}, {
|
|
419
|
+
key: "revision",
|
|
420
|
+
value: function revision(paths) {
|
|
421
|
+
var _this2 = this;
|
|
422
|
+
return paths.map(function (path) {
|
|
423
|
+
var _this2$revisions$get;
|
|
424
|
+
return (_this2$revisions$get = _this2.revisions.get(path)) !== null && _this2$revisions$get !== void 0 ? _this2$revisions$get : 0;
|
|
425
|
+
}).join(",");
|
|
426
|
+
}
|
|
427
|
+
}, {
|
|
428
|
+
key: "emitChange",
|
|
429
|
+
value: function emitChange(subscriberId) {
|
|
430
|
+
var _this$listeners$get;
|
|
431
|
+
var _iterator4 = _createForOfIteratorHelper((_this$listeners$get = this.listeners.get(subscriberId)) !== null && _this$listeners$get !== void 0 ? _this$listeners$get : []),
|
|
432
|
+
_step4;
|
|
433
|
+
try {
|
|
434
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
435
|
+
var listener = _step4.value;
|
|
436
|
+
listener();
|
|
437
|
+
}
|
|
438
|
+
} catch (err) {
|
|
439
|
+
_iterator4.e(err);
|
|
440
|
+
} finally {
|
|
441
|
+
_iterator4.f();
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}]);
|
|
445
|
+
}();
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Whether two reads of a module hold the same content: the same object, or
|
|
449
|
+
* the same version, or -- where either has none -- the same JSON.
|
|
450
|
+
*
|
|
451
|
+
* The versions settle it without walking the module: the Studio relays each
|
|
452
|
+
* module with the version it computed (phase 5 of
|
|
453
|
+
* `docs/plans/one-content-model.md`), and the server's draft carries the
|
|
454
|
+
* version it read (`ValDraft.versions`, phase 6) -- the same version for the
|
|
455
|
+
* same content, so a page rendered from the server's draft takes the
|
|
456
|
+
* Studio's first relay of an unchanged module as the nothing it is (risk 8
|
|
457
|
+
* in the plan). A version names what a reader renders: the module's source,
|
|
458
|
+
* and the `.jsonValues()` entries its chain touched, which both the Studio
|
|
459
|
+
* (`entriesToRelay`) and the server's draft send in place of their markers;
|
|
460
|
+
* every other entry is the bundle's whether it travels as content or as a
|
|
461
|
+
* marker. A read without a version (a server or a Studio of the release
|
|
462
|
+
* before) is compared by content, as before.
|
|
463
|
+
*/
|
|
464
|
+
function sameContent(a, b) {
|
|
465
|
+
if (a.source === b.source) return true;
|
|
466
|
+
if (a.version !== null && b.version !== null) {
|
|
467
|
+
return a.version.schema === b.version.schema && a.version.base === b.version.base && a.version.chain === b.version.chain;
|
|
468
|
+
}
|
|
469
|
+
return deepEqual(a.source, b.source);
|
|
470
|
+
}
|
|
471
|
+
var SEPARATOR = "&";
|
|
472
|
+
function createSubscriberId(paths) {
|
|
473
|
+
return paths.slice().sort().join(SEPARATOR);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/** Whether `path` is one of the paths a subscriber id was made of. */
|
|
477
|
+
function includesPath(subscriberId, path) {
|
|
478
|
+
return subscriberId.split(SEPARATOR).includes(path);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/** What one `val-event` from the overlay did to the page's store. */
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Apply one overlay event (`detail` of a `val-event`) to the page's store.
|
|
485
|
+
* `sources-synced` says the editor has sent everything it holds;
|
|
486
|
+
* `confirmed` how far the server holds the editor's changes; a
|
|
487
|
+
* `source-update` hands over one module's read, which the store keeps as it
|
|
488
|
+
* is (`read`). A Studio from the release before sent the bare `source`
|
|
489
|
+
* instead, and a page newer than the Studio it is open in -- a deploy rolling
|
|
490
|
+
* out -- still takes that.
|
|
491
|
+
*
|
|
492
|
+
* Moved here from `@valbuild/tanstack`'s draft store; `@valbuild/next`'s
|
|
493
|
+
* provider had the same rule written inline.
|
|
494
|
+
*/
|
|
495
|
+
function applyValEvent(store, detail) {
|
|
496
|
+
if (_typeof(detail) !== "object" || detail === null || !("type" in detail)) {
|
|
497
|
+
return {
|
|
498
|
+
type: "invalid",
|
|
499
|
+
detail: detail
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
if (detail.type === "sources-synced") {
|
|
503
|
+
return {
|
|
504
|
+
type: "synced"
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
if (detail.type === "confirmed") {
|
|
508
|
+
var seq = "seq" in detail ? detail.seq : undefined;
|
|
509
|
+
if (seq === null || typeof seq === "number") {
|
|
510
|
+
return {
|
|
511
|
+
type: "confirmed",
|
|
512
|
+
seq: seq
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
type: "invalid",
|
|
517
|
+
detail: detail
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
if (detail.type === "source-update") {
|
|
521
|
+
var moduleFilePath = "moduleFilePath" in detail ? detail.moduleFilePath : undefined;
|
|
522
|
+
if (!isModuleFilePath$1(moduleFilePath)) {
|
|
523
|
+
return {
|
|
524
|
+
type: "invalid",
|
|
525
|
+
detail: detail
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
var read = "read" in detail ? heldRead(detail.read) : undefined;
|
|
529
|
+
if (read !== undefined) {
|
|
530
|
+
return {
|
|
531
|
+
type: "updated",
|
|
532
|
+
changed: store.receive(moduleFilePath, read)
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
// A Studio of the release before sent the bare `source`. This fallback
|
|
536
|
+
// goes with the relay's `source` field: see "Release-delayed deletions"
|
|
537
|
+
// in `docs/plans/one-content-model.md`.
|
|
538
|
+
var source = "source" in detail ? detail.source : undefined;
|
|
539
|
+
if (isJson(source)) {
|
|
540
|
+
return {
|
|
541
|
+
type: "updated",
|
|
542
|
+
changed: store.update(moduleFilePath, source),
|
|
543
|
+
fromPreviousStudio: true
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return {
|
|
548
|
+
type: "invalid",
|
|
549
|
+
detail: detail
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/** A relayed module path, checked: it crossed a window, as data. */
|
|
554
|
+
function isModuleFilePath$1(value) {
|
|
555
|
+
return typeof value === "string" && value.startsWith("/");
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** A relayed read, checked: it crossed a window, as data. */
|
|
559
|
+
function heldRead(value) {
|
|
560
|
+
if (_typeof(value) !== "object" || value === null || !("status" in value) || value.status !== "ready" || !("source" in value) || !isJson(value.source)) {
|
|
561
|
+
return undefined;
|
|
562
|
+
}
|
|
563
|
+
return {
|
|
564
|
+
status: "ready",
|
|
565
|
+
source: value.source,
|
|
566
|
+
from: "overlay",
|
|
567
|
+
version: "version" in value && isModuleVersion(value.version) ? value.version : null
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
function isModuleVersion(value) {
|
|
571
|
+
return _typeof(value) === "object" && value !== null && "schema" in value && typeof value.schema === "string" && "base" in value && typeof value.base === "string" && "chain" in value && typeof value.chain === "string";
|
|
572
|
+
}
|
|
573
|
+
function isJson(value) {
|
|
574
|
+
return value !== undefined;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* What a draft page shows, read by the server for the request that renders it.
|
|
579
|
+
*
|
|
580
|
+
* The source of every module the editor's draft CHANGES -- the ones with
|
|
581
|
+
* patches applied, published-not-yet-built ones included -- and nothing
|
|
582
|
+
* else: a module without changes is the build's own source, which the page
|
|
583
|
+
* already has. Handed to `<ValProvider draft>` so the server's render and the
|
|
584
|
+
* browser's first render resolve the same text, and the page never shows the
|
|
585
|
+
* published version first and the draft a moment later.
|
|
586
|
+
*
|
|
587
|
+
* A `.jsonValues()` module is in the shape the Studio's own store gives it: the
|
|
588
|
+
* entries the draft edits hold their content, and every other entry is the
|
|
589
|
+
* thunkless marker the hooks resolve from the bundle.
|
|
590
|
+
*
|
|
591
|
+
* Plain JSON, because it travels from the server to the browser in the page's
|
|
592
|
+
* loader data (or a server component's props). `fetchValDraft` in
|
|
593
|
+
* `@valbuild/tanstack/server` reads it. Moved here from `@valbuild/tanstack`,
|
|
594
|
+
* which still exports it, when `@valbuild/next`'s `ValProvider` took a
|
|
595
|
+
* `draft` too: the page's half is the same in both.
|
|
596
|
+
*/
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Whether a server-read draft is a draft. At a proposal's address the server
|
|
600
|
+
* sends its snapshot whether or not draft mode is on, and one that is ONLY a
|
|
601
|
+
* snapshot (`draftMode: false`) is not a draft: it must not turn draft mode on
|
|
602
|
+
* or say the draft is synced.
|
|
603
|
+
*/
|
|
604
|
+
function isDraft(draft) {
|
|
605
|
+
return draft !== null && draft !== undefined && draft.draftMode !== false;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* The store a page starts from: seeded with the server-read draft, so the
|
|
610
|
+
* server render and the browser's first render show the same thing. What
|
|
611
|
+
* both frameworks' providers start from, and the scenario world's page.
|
|
612
|
+
*
|
|
613
|
+
* The seed (`seeded`, in a read's `from`) is held in the overlay's store
|
|
614
|
+
* rather than read as a source of its own, because what the Studio relays
|
|
615
|
+
* later is compared with what the page shows (`ValExternalStore.receive`):
|
|
616
|
+
* the first relay of a module the server already rendered moves nothing.
|
|
617
|
+
*/
|
|
618
|
+
function createDraftStore(draft) {
|
|
619
|
+
var store = new ValExternalStore();
|
|
620
|
+
if (isDraft(draft)) {
|
|
621
|
+
for (var _i = 0, _draftHolds = draftHolds(draft); _i < _draftHolds.length; _i++) {
|
|
622
|
+
var _draft$versions$path, _draft$versions;
|
|
623
|
+
var path = _draftHolds[_i];
|
|
624
|
+
store.receive(path, {
|
|
625
|
+
status: "ready",
|
|
626
|
+
source: draft.sources[path],
|
|
627
|
+
from: "seeded",
|
|
628
|
+
version: (_draft$versions$path = (_draft$versions = draft.versions) === null || _draft$versions === void 0 ? void 0 : _draft$versions[path]) !== null && _draft$versions$path !== void 0 ? _draft$versions$path : null
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return store;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* What the page reports to the Studio when it connects: the modules it was
|
|
637
|
+
* rendered with a draft of. The Studio sends each of them in its catch-up,
|
|
638
|
+
* pending or not (`sendPendingSources` in `@valbuild/ui`), so a draft that
|
|
639
|
+
* stopped being the draft before the Studio was there -- discarded,
|
|
640
|
+
* published -- is replaced rather than kept. With the version of each
|
|
641
|
+
* where the draft carries one ({@link draftHoldsVersions}): the page compares
|
|
642
|
+
* what it is sent with what it holds by version (`ValExternalStore.receive`),
|
|
643
|
+
* and a module that did not move costs nothing.
|
|
644
|
+
*/
|
|
645
|
+
function draftHolds(draft) {
|
|
646
|
+
if (!isDraft(draft)) return [];
|
|
647
|
+
return Object.keys(draft.sources).filter(isModuleFilePathOf(draft.sources));
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* The versions the page was rendered with, of the modules
|
|
652
|
+
* {@link draftHolds} names, where the draft says (phase 6 of
|
|
653
|
+
* `docs/plans/one-content-model.md`): what the page reports beside the paths
|
|
654
|
+
* when it connects, so the Studio can tell a module the page holds at the
|
|
655
|
+
* version it would send. A module without one is left out.
|
|
656
|
+
*/
|
|
657
|
+
function draftHoldsVersions(draft) {
|
|
658
|
+
var versions = {};
|
|
659
|
+
if (!isDraft(draft) || draft.versions === undefined) return versions;
|
|
660
|
+
var _iterator = _createForOfIteratorHelper(draftHolds(draft)),
|
|
661
|
+
_step;
|
|
662
|
+
try {
|
|
663
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
664
|
+
var path = _step.value;
|
|
665
|
+
var version = draft.versions[path];
|
|
666
|
+
if (version !== undefined) versions[path] = version;
|
|
667
|
+
}
|
|
668
|
+
} catch (err) {
|
|
669
|
+
_iterator.e(err);
|
|
670
|
+
} finally {
|
|
671
|
+
_iterator.f();
|
|
672
|
+
}
|
|
673
|
+
return versions;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
/** Narrows a key of `sources` back to the path it was written under. */
|
|
677
|
+
function isModuleFilePathOf(sources) {
|
|
678
|
+
return function (key) {
|
|
679
|
+
return Object.prototype.hasOwnProperty.call(sources, key);
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* When a draft page re-reads what its server rendered: its loaders (TanStack
|
|
685
|
+
* Start's `router.invalidate()`) or its server components (Next's
|
|
686
|
+
* `router.refresh()`). The hooks need none of this -- they read what the
|
|
687
|
+
* Studio relays -- but server-read content only changes on a refresh, and only
|
|
688
|
+
* shows an edit once the server has it.
|
|
689
|
+
*
|
|
690
|
+
* So the page refreshes when the Studio says the server has CONFIRMED the
|
|
691
|
+
* edit (`confirmed`, with the server's `seq`), never when the edit arrives.
|
|
692
|
+
* Arrived, it raced the write: the page asked a server that did not have the
|
|
693
|
+
* patch yet, got the old content back, and nothing asked again until a safety
|
|
694
|
+
* refresh ten seconds later (S05 in `scenarios/`). That timer, and the 500 ms
|
|
695
|
+
* throttle that was there to keep the edit-driven refreshes from stacking,
|
|
696
|
+
* are gone: this has no timer at all. See `docs/plans/one-content-model.md`,
|
|
697
|
+
* "The page converges on the Studio".
|
|
698
|
+
*
|
|
699
|
+
* - **One refresh per confirmed version.** A version told twice (a save's
|
|
700
|
+
* answer, then the stat after it) or out of order refreshes once.
|
|
701
|
+
* - **At most one in flight**, where the refresh says when it is done (a
|
|
702
|
+
* promise): a version confirmed meanwhile waits for it and is then one more
|
|
703
|
+
* refresh, however many arrived. A refresh that cannot say (Next's
|
|
704
|
+
* `router.refresh()`) is simply sent each time.
|
|
705
|
+
* - **The first `confirmed` is the connection, not news.** The Studio says
|
|
706
|
+
* it once after its catch-up. The page refreshes then only if the catch-up
|
|
707
|
+
* moved what it holds (`changed`): its server render is older than what the
|
|
708
|
+
* Studio has. A page rendered from the draft the Studio holds -- the
|
|
709
|
+
* `draft` prop, read for this request -- is not refreshed for loading.
|
|
710
|
+
* - **A Studio of the release before never says `confirmed`** (a deploy
|
|
711
|
+
* rolling out: this page, that Studio). Its changes refresh the page as
|
|
712
|
+
* they arrive (`changedByPreviousStudio`), as that release's page did,
|
|
713
|
+
* until a `confirmed` says the Studio is this release's. They race the
|
|
714
|
+
* write, as they did then; it lasts as long as the rollout.
|
|
715
|
+
*/
|
|
716
|
+
|
|
717
|
+
function startRefreshLoop(options) {
|
|
718
|
+
/** The version last told; `undefined` until the first. */
|
|
719
|
+
var told = undefined;
|
|
720
|
+
/** Whether the catch-up moved what the page holds: see above. */
|
|
721
|
+
var behind = false;
|
|
722
|
+
var running = false;
|
|
723
|
+
var again = false;
|
|
724
|
+
var stopped = false;
|
|
725
|
+
var refreshes = 0;
|
|
726
|
+
var _run = function run() {
|
|
727
|
+
if (stopped) return;
|
|
728
|
+
if (running) {
|
|
729
|
+
again = true;
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
refreshes++;
|
|
733
|
+
var done = options.refresh();
|
|
734
|
+
if (done === undefined) return;
|
|
735
|
+
running = true;
|
|
736
|
+
var next = function next() {
|
|
737
|
+
running = false;
|
|
738
|
+
if (!again) return;
|
|
739
|
+
again = false;
|
|
740
|
+
_run();
|
|
741
|
+
};
|
|
742
|
+
done.then(next, next);
|
|
743
|
+
};
|
|
744
|
+
return {
|
|
745
|
+
changed: function changed() {
|
|
746
|
+
if (told === undefined) behind = true;
|
|
747
|
+
},
|
|
748
|
+
changedByPreviousStudio: function changedByPreviousStudio() {
|
|
749
|
+
if (told !== undefined) {
|
|
750
|
+
// A Studio that confirms: its `confirmed` is the refresh.
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
_run();
|
|
754
|
+
},
|
|
755
|
+
confirmed: function confirmed(seq) {
|
|
756
|
+
if (told !== undefined && told !== null && seq !== null && seq <= told) {
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
var first = told === undefined;
|
|
760
|
+
told = seq;
|
|
761
|
+
if (first && !behind) return;
|
|
762
|
+
_run();
|
|
763
|
+
},
|
|
764
|
+
refresh: function refresh() {
|
|
765
|
+
_run();
|
|
766
|
+
},
|
|
767
|
+
get refreshes() {
|
|
768
|
+
return refreshes;
|
|
769
|
+
},
|
|
770
|
+
stop: function stop() {
|
|
771
|
+
stopped = true;
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/*
|
|
777
|
+
* `.jsonValues()` records, as the readers meet them. Moved here from the
|
|
778
|
+
* `routeFromVal.ts` of `@valbuild/next` and `@valbuild/tanstack`, which were
|
|
779
|
+
* the same lines twice.
|
|
780
|
+
*/
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* True when the module's schema is a `.jsonValues()` record/router — i.e. each
|
|
784
|
+
* entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
|
|
785
|
+
* readers to load ONLY the entries they need instead of the whole record.
|
|
786
|
+
*/
|
|
787
|
+
function isJsonValuesRecordSchema(schema) {
|
|
788
|
+
return schema instanceof RecordSchema && schema["executeSerialize"]().jsonValues === true;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* The bundle's import of one `.jsonValues()` entry: `undefined` when the
|
|
793
|
+
* module's own source has no marker for `key` to import from.
|
|
794
|
+
*/
|
|
795
|
+
function bundledJsonEntryImport(
|
|
796
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
797
|
+
module, key) {
|
|
798
|
+
var _Internal$getJsonImpo;
|
|
799
|
+
var source = module && Internal.getSource(module);
|
|
800
|
+
var marker = _typeof(source) === "object" && source !== null && !Array.isArray(source) ? Object.prototype.hasOwnProperty.call(source, key) ? source[key] : undefined : undefined;
|
|
801
|
+
if (!Internal.isJson(marker)) {
|
|
802
|
+
return undefined;
|
|
803
|
+
}
|
|
804
|
+
return (_Internal$getJsonImpo = Internal.getJsonImport(marker)) !== null && _Internal$getJsonImpo !== void 0 ? _Internal$getJsonImpo : undefined;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/**
|
|
808
|
+
* Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
|
|
809
|
+
* strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
|
|
810
|
+
* identity transform (the content carries no selector path/schema).
|
|
811
|
+
*
|
|
812
|
+
* Yields e.g. `/src/routes/support.$slug.val.ts?p="/support/faq"`, so a `title`
|
|
813
|
+
* field is tagged `…?p="/support/faq"."title"` — the shape the Studio's
|
|
814
|
+
* `findUnloadedJsonEntryKey` walks, so click-to-edit + lazy load line up.
|
|
815
|
+
*/
|
|
816
|
+
function getJsonEntryStegaRoot(
|
|
817
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
818
|
+
selector, key
|
|
819
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
820
|
+
) {
|
|
821
|
+
var modulePath = selector && Internal.getValPath(selector);
|
|
822
|
+
if (!modulePath) {
|
|
823
|
+
return undefined;
|
|
824
|
+
}
|
|
825
|
+
var schema = selector && Internal.getSchema(selector);
|
|
826
|
+
if (!(schema instanceof RecordSchema)) {
|
|
827
|
+
return undefined;
|
|
828
|
+
}
|
|
829
|
+
var path = Internal.createValPathOfItem(modulePath, key);
|
|
830
|
+
if (!path) {
|
|
831
|
+
return undefined;
|
|
832
|
+
}
|
|
833
|
+
return {
|
|
834
|
+
path: path,
|
|
835
|
+
schema: schema["executeSerialize"]().item
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/*
|
|
840
|
+
* The sources a page reads from, in the browser and on the server alike
|
|
841
|
+
* (the server's own draft, `serverDraftSource`, is in `@valbuild/server`).
|
|
842
|
+
* See `docs/plans/one-content-model.md`, "One way to load".
|
|
843
|
+
*/
|
|
844
|
+
|
|
845
|
+
var PASS$1 = {
|
|
846
|
+
status: "pass"
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* What a module's source says about one of its `.jsonValues()` entries: the
|
|
851
|
+
* same rule for every source that holds a whole module (the overlay, a
|
|
852
|
+
* snapshot). A module that is `null` (a nullable record) has no entries; a
|
|
853
|
+
* key it does not have is GONE -- an answer, not "ask the next one"; an entry
|
|
854
|
+
* that is still a marker is one this source has not loaded, so it passes.
|
|
855
|
+
*/
|
|
856
|
+
function entryOfModuleSource(source, key, from) {
|
|
857
|
+
var _Object$entries$find;
|
|
858
|
+
if (source === null) {
|
|
859
|
+
return {
|
|
860
|
+
status: "gone",
|
|
861
|
+
from: from
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
if (_typeof(source) !== "object" || Array.isArray(source)) {
|
|
865
|
+
return PASS$1;
|
|
866
|
+
}
|
|
867
|
+
// Own keys only: an entry may be named `toString`.
|
|
868
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) {
|
|
869
|
+
return {
|
|
870
|
+
status: "gone",
|
|
871
|
+
from: from
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
var entry = (_Object$entries$find = Object.entries(source).find(function (_ref) {
|
|
875
|
+
var _ref2 = _slicedToArray(_ref, 1),
|
|
876
|
+
k = _ref2[0];
|
|
877
|
+
return k === key;
|
|
878
|
+
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[1];
|
|
879
|
+
if (Internal.isJson(entry)) {
|
|
880
|
+
return PASS$1;
|
|
881
|
+
}
|
|
882
|
+
return {
|
|
883
|
+
status: "ready",
|
|
884
|
+
content: entry,
|
|
885
|
+
from: from
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* A content version's or a proposal's saved Source, for the modules it has
|
|
891
|
+
* (`ValDraft.snapshot`, `snapshotForReaders`): it stands in for the bundle's,
|
|
892
|
+
* draft mode or not. Its entries are content where the proposal saved them.
|
|
893
|
+
*/
|
|
894
|
+
function snapshotSource(snapshot) {
|
|
895
|
+
var sourceOf = function sourceOf(path) {
|
|
896
|
+
return snapshot !== undefined && Object.prototype.hasOwnProperty.call(snapshot, path) ? snapshot[path] : undefined;
|
|
897
|
+
};
|
|
898
|
+
return {
|
|
899
|
+
name: "snapshot",
|
|
900
|
+
module: function module(path) {
|
|
901
|
+
var source = sourceOf(path);
|
|
902
|
+
return source === undefined ? PASS$1 : {
|
|
903
|
+
status: "ready",
|
|
904
|
+
source: source,
|
|
905
|
+
from: "snapshot",
|
|
906
|
+
version: null
|
|
907
|
+
};
|
|
908
|
+
},
|
|
909
|
+
entry: function entry(path, key) {
|
|
910
|
+
var source = sourceOf(path);
|
|
911
|
+
return source === undefined ? PASS$1 : entryOfModuleSource(source, key, "snapshot");
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/** What the page knows about draft mode and the Studio, for {@link overlaySource}. */
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* What the Studio sent the page (`ValExternalStore`, fed by the relay), with
|
|
920
|
+
* the three waits `suspend` is made of (`architecture/quirks.md`, "`suspend`
|
|
921
|
+
* is three waits") as its states:
|
|
922
|
+
*
|
|
923
|
+
* 1. Draft mode unknown: wait for it to be known (`draftModeReady`), because
|
|
924
|
+
* a read that slips through then is a read of published content, and for
|
|
925
|
+
* a route that only exists in a patch that is a `notFound()` nothing later
|
|
926
|
+
* undoes.
|
|
927
|
+
* 2. Draft mode on, and the Studio has not yet said it sent everything: a
|
|
928
|
+
* module it has not sent may still be coming, so wait for it. After
|
|
929
|
+
* `sources-synced` a module it did not send has no draft: pass.
|
|
930
|
+
* 3. The render that decides is the provider's, which turns `suspend` on
|
|
931
|
+
* after hydrating; until then every wait is a pass.
|
|
932
|
+
*
|
|
933
|
+
* Draft mode off, or no store (a visitor): pass, always.
|
|
934
|
+
*/
|
|
935
|
+
function overlaySource(store, state) {
|
|
936
|
+
var gate = function gate(path) {
|
|
937
|
+
if (store === undefined || state.draftMode === false) {
|
|
938
|
+
return PASS$1;
|
|
939
|
+
}
|
|
940
|
+
if (state.suspend && state.draftMode === null && state.draftModeReady !== undefined) {
|
|
941
|
+
return {
|
|
942
|
+
status: "pending",
|
|
943
|
+
ready: state.draftModeReady
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
var held = state.draftMode === true ? store.read(path) : undefined;
|
|
947
|
+
if (held !== undefined) {
|
|
948
|
+
return held;
|
|
949
|
+
}
|
|
950
|
+
if (state.suspend && !state.synced && store.read(path) === undefined) {
|
|
951
|
+
return {
|
|
952
|
+
status: "pending",
|
|
953
|
+
ready: store.waitForLoad([path])
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
return PASS$1;
|
|
957
|
+
};
|
|
958
|
+
return {
|
|
959
|
+
name: "overlay",
|
|
960
|
+
module: function module(path) {
|
|
961
|
+
return gate(path);
|
|
962
|
+
},
|
|
963
|
+
entry: function entry(path, key) {
|
|
964
|
+
var read = gate(path);
|
|
965
|
+
if (read.status === "pass") {
|
|
966
|
+
return PASS$1;
|
|
967
|
+
}
|
|
968
|
+
if (read.status === "pending") {
|
|
969
|
+
return read;
|
|
970
|
+
}
|
|
971
|
+
return entryOfModuleSource(read.source, key, "overlay");
|
|
972
|
+
},
|
|
973
|
+
subscribe: function subscribe(paths, onChange) {
|
|
974
|
+
return store === undefined ? function () {} : store.subscribe(paths)(onChange);
|
|
975
|
+
},
|
|
976
|
+
revision: function revision(paths) {
|
|
977
|
+
return store === undefined ? "" : store.revision(paths);
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/** Where one bundled entry's import is. */
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Every bundled entry's import, started once and kept, by the MODULE OBJECT
|
|
986
|
+
* it belongs to -- the build it came from -- so a new build (or a hot reload)
|
|
987
|
+
* is a new key rather than an old answer. Replaces the frameworks'
|
|
988
|
+
* `jsonEntryPromiseCache`, which was keyed by path and kept a previous
|
|
989
|
+
* build's entries for good.
|
|
990
|
+
*
|
|
991
|
+
* Kept for the process, as the imports themselves are: the module object
|
|
992
|
+
* keeps them alive, and with it the entries the page has read. A failed
|
|
993
|
+
* import is kept for {@link RETRY_FAILED_ENTRY_AFTER_MS}, then tried again.
|
|
994
|
+
*/
|
|
995
|
+
var bundledEntries = new WeakMap();
|
|
996
|
+
|
|
997
|
+
/** How long a failed entry import answers "failed" before it is tried again. */
|
|
998
|
+
var RETRY_FAILED_ENTRY_AFTER_MS = 5000;
|
|
999
|
+
function bundledEntry(module, key) {
|
|
1000
|
+
var entries = bundledEntries.get(module);
|
|
1001
|
+
if (entries === undefined) {
|
|
1002
|
+
entries = new Map();
|
|
1003
|
+
bundledEntries.set(module, entries);
|
|
1004
|
+
}
|
|
1005
|
+
var entry = entries.get(key);
|
|
1006
|
+
if (entry === undefined) {
|
|
1007
|
+
var thunk = bundledJsonEntryImport(module, key);
|
|
1008
|
+
if (thunk === undefined) {
|
|
1009
|
+
return {
|
|
1010
|
+
status: "gone",
|
|
1011
|
+
from: "bundle"
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
var kept = entries;
|
|
1015
|
+
var ready = thunk().then(function (imported) {
|
|
1016
|
+
kept.set(key, {
|
|
1017
|
+
status: "loaded",
|
|
1018
|
+
content: imported["default"]
|
|
1019
|
+
});
|
|
1020
|
+
}, function (error) {
|
|
1021
|
+
kept.set(key, {
|
|
1022
|
+
status: "failed",
|
|
1023
|
+
error: error,
|
|
1024
|
+
at: Date.now()
|
|
1025
|
+
});
|
|
1026
|
+
});
|
|
1027
|
+
entry = {
|
|
1028
|
+
status: "loading",
|
|
1029
|
+
ready: ready
|
|
1030
|
+
};
|
|
1031
|
+
entries.set(key, entry);
|
|
1032
|
+
}
|
|
1033
|
+
if (entry.status === "loading") {
|
|
1034
|
+
return {
|
|
1035
|
+
status: "pending",
|
|
1036
|
+
ready: entry.ready
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
if (entry.status === "failed") {
|
|
1040
|
+
// A chunk that failed to load (a deploy, a dropped connection) is
|
|
1041
|
+
// imported again by a read after a while, rather than failing every
|
|
1042
|
+
// read until the page is reloaded -- and not by every read before
|
|
1043
|
+
// that, each of which would suspend a component again.
|
|
1044
|
+
if (Date.now() - entry.at >= RETRY_FAILED_ENTRY_AFTER_MS) {
|
|
1045
|
+
entries["delete"](key);
|
|
1046
|
+
return bundledEntry(module, key);
|
|
1047
|
+
}
|
|
1048
|
+
return {
|
|
1049
|
+
status: "failed",
|
|
1050
|
+
error: entry.error
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
return {
|
|
1054
|
+
status: "ready",
|
|
1055
|
+
content: entry.content,
|
|
1056
|
+
from: "bundle"
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* The build's own modules: what the code a reader runs was built with. Always
|
|
1062
|
+
* the last source, and the only one that never passes on an entry: its
|
|
1063
|
+
* entries are its own `import()`s, started when one is first read (never
|
|
1064
|
+
* before: a `.jsonValues()` record stays lazy) and kept by build.
|
|
1065
|
+
*
|
|
1066
|
+
* A module the bundle has passes here: the reader's own selector carries its
|
|
1067
|
+
* source, and `stegaEncode` reads it there (and a gallery's from the schema
|
|
1068
|
+
* that picks from it), so there is nothing to hand over.
|
|
1069
|
+
*/
|
|
1070
|
+
function bundleSource(modules) {
|
|
1071
|
+
return {
|
|
1072
|
+
name: "bundle",
|
|
1073
|
+
module: function module() {
|
|
1074
|
+
return PASS$1;
|
|
1075
|
+
},
|
|
1076
|
+
entry: function entry(path, key) {
|
|
1077
|
+
var module = modules.get(path);
|
|
1078
|
+
if (_typeof(module) !== "object" || module === null) {
|
|
1079
|
+
return PASS$1;
|
|
1080
|
+
}
|
|
1081
|
+
return bundledEntry(module, key);
|
|
1082
|
+
}
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* The rule that content is only read with the schema it was made for
|
|
1088
|
+
* (`docs/plans/one-content-model.md`, goal 3).
|
|
1089
|
+
*
|
|
1090
|
+
* `schemaOf(path)` is the version of the schema the READER's code has for a
|
|
1091
|
+
* module (`null`: not known, so no rule). A source whose answer names
|
|
1092
|
+
* another schema is not read: with `codeChanged` the read waits until the
|
|
1093
|
+
* code catches up; without it the next source answers, which ends at the
|
|
1094
|
+
* reader's own bundle -- content of the code that reads it.
|
|
1095
|
+
*/
|
|
1096
|
+
|
|
1097
|
+
/** A module read, with the place in the list of the source that answered it. */
|
|
1098
|
+
|
|
1099
|
+
/** What `layered` gives back: one view over the sources, first answer wins. */
|
|
1100
|
+
|
|
1101
|
+
var PASS = {
|
|
1102
|
+
status: "pass"
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* The ONE place that decides which source wins: the first that does not
|
|
1107
|
+
* pass. Replaces the source-priority arrays each reader wrote inline
|
|
1108
|
+
* (`[draft, snapshot]`, then the bundle, in four places), and is the only
|
|
1109
|
+
* place the schema rule is applied.
|
|
1110
|
+
*/
|
|
1111
|
+
function layered(sources, rule,
|
|
1112
|
+
/**
|
|
1113
|
+
* Waits that are already over. A source still answering one of them is
|
|
1114
|
+
* passed over: what it waited for came and did not give it an answer (draft
|
|
1115
|
+
* mode stayed unknown, a module the Studio never sent), and the read goes on
|
|
1116
|
+
* as it would have without waiting.
|
|
1117
|
+
*/
|
|
1118
|
+
settled) {
|
|
1119
|
+
/**
|
|
1120
|
+
* THE schema rule: content made with another schema than this code has is
|
|
1121
|
+
* not read with it. `null`: read it. `next`: read the next source. A
|
|
1122
|
+
* promise: the code is changing (`codeChanged`), wait for it.
|
|
1123
|
+
*/
|
|
1124
|
+
var schemaRule = function schemaRule(path, version, from) {
|
|
1125
|
+
if (version === null || version === undefined || !rule) return null;
|
|
1126
|
+
var own = rule.schemaOf(path);
|
|
1127
|
+
if (own === null || own === version.schema) return null;
|
|
1128
|
+
if (rule.codeChanged) return rule.codeChanged(path, version.schema);
|
|
1129
|
+
Internal.log.debug("".concat(path, " from ").concat(from, " was made with another schema than this code has; reading the next source"));
|
|
1130
|
+
return "next";
|
|
1131
|
+
};
|
|
1132
|
+
return {
|
|
1133
|
+
sources: sources,
|
|
1134
|
+
module: function module(path) {
|
|
1135
|
+
for (var at = 0; at < sources.length; at++) {
|
|
1136
|
+
var source = sources[at];
|
|
1137
|
+
if (source === undefined) continue;
|
|
1138
|
+
var read = source.module(path);
|
|
1139
|
+
if (read.status === "pass") continue;
|
|
1140
|
+
if (read.status === "pending" && settled !== null && settled !== void 0 && settled.has(read.ready)) continue;
|
|
1141
|
+
if (read.status === "ready") {
|
|
1142
|
+
var ruled = schemaRule(path, read.version, read.from);
|
|
1143
|
+
if (ruled === "next") continue;
|
|
1144
|
+
if (ruled !== null) {
|
|
1145
|
+
return {
|
|
1146
|
+
read: {
|
|
1147
|
+
status: "pending",
|
|
1148
|
+
ready: ruled
|
|
1149
|
+
},
|
|
1150
|
+
at: at
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
return {
|
|
1155
|
+
read: read,
|
|
1156
|
+
at: at
|
|
1157
|
+
};
|
|
1158
|
+
}
|
|
1159
|
+
return {
|
|
1160
|
+
read: PASS,
|
|
1161
|
+
at: -1
|
|
1162
|
+
};
|
|
1163
|
+
},
|
|
1164
|
+
entry: function entry(path, key) {
|
|
1165
|
+
var after = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;
|
|
1166
|
+
for (var at = after + 1; at < sources.length; at++) {
|
|
1167
|
+
var _sources$at;
|
|
1168
|
+
var read = (_sources$at = sources[at]) === null || _sources$at === void 0 ? void 0 : _sources$at.entry(path, key);
|
|
1169
|
+
if (read === undefined || read.status === "pass") continue;
|
|
1170
|
+
if (read.status === "pending" && settled !== null && settled !== void 0 && settled.has(read.ready)) continue;
|
|
1171
|
+
if (read.status === "ready") {
|
|
1172
|
+
// The same rule as a module's: an entry carries its record's
|
|
1173
|
+
// schema version.
|
|
1174
|
+
var ruled = schemaRule(path, read.version, read.from);
|
|
1175
|
+
if (ruled === "next") continue;
|
|
1176
|
+
if (ruled !== null) return {
|
|
1177
|
+
status: "pending",
|
|
1178
|
+
ready: ruled
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
return read;
|
|
1182
|
+
}
|
|
1183
|
+
return {
|
|
1184
|
+
status: "pass"
|
|
1185
|
+
};
|
|
1186
|
+
},
|
|
1187
|
+
subscribe: function subscribe(paths, onChange) {
|
|
1188
|
+
var offs = sources.map(function (source) {
|
|
1189
|
+
var _source$subscribe, _source$subscribe2;
|
|
1190
|
+
return (_source$subscribe = (_source$subscribe2 = source.subscribe) === null || _source$subscribe2 === void 0 ? void 0 : _source$subscribe2.call(source, paths, onChange)) !== null && _source$subscribe !== void 0 ? _source$subscribe : function () {};
|
|
1191
|
+
});
|
|
1192
|
+
return function () {
|
|
1193
|
+
var _iterator = _createForOfIteratorHelper(offs),
|
|
1194
|
+
_step;
|
|
1195
|
+
try {
|
|
1196
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1197
|
+
var off = _step.value;
|
|
1198
|
+
off();
|
|
1199
|
+
}
|
|
1200
|
+
} catch (err) {
|
|
1201
|
+
_iterator.e(err);
|
|
1202
|
+
} finally {
|
|
1203
|
+
_iterator.f();
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
},
|
|
1207
|
+
revision: function revision(paths) {
|
|
1208
|
+
return sources.map(function (source) {
|
|
1209
|
+
var _source$revision, _source$revision2;
|
|
1210
|
+
return (_source$revision = (_source$revision2 = source.revision) === null || _source$revision2 === void 0 ? void 0 : _source$revision2.call(source, paths)) !== null && _source$revision !== void 0 ? _source$revision : "";
|
|
1211
|
+
}).join("|");
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* Everything a read needs that is not the selector: where content comes from
|
|
1218
|
+
* and whether it carries edit tags. Built once per request on the server and
|
|
1219
|
+
* once per render in a component; the only thing the readers differ in.
|
|
1220
|
+
*
|
|
1221
|
+
* `encode` is decided ONCE, from draft mode (and, on TanStack, hydration and
|
|
1222
|
+
* analytics): there is no second encode on an error path to forget it.
|
|
1223
|
+
*/
|
|
1224
|
+
|
|
1225
|
+
/** Which source a module was read from, and the version of what it read. */
|
|
1226
|
+
|
|
1227
|
+
/** What a read is: a value with the reads it was made of, or a wait. */
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* What a read of `selector` reads: every module it names (`getModuleIds`),
|
|
1231
|
+
* the module objects it carries -- whose `.jsonValues()` entries the bundle
|
|
1232
|
+
* imports -- and the whole `.jsonValues()` record it is, if it is one.
|
|
1233
|
+
*/
|
|
1234
|
+
|
|
1235
|
+
var plans = new WeakMap();
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* The plan of a read: see {@link ReadPlan}. Kept per selector object, like
|
|
1239
|
+
* `getModuleIds`: a module is a module-level constant, so its plan is made
|
|
1240
|
+
* once for the life of the process.
|
|
1241
|
+
*/
|
|
1242
|
+
/** A module id `getModuleIds` collected: a module's path. */
|
|
1243
|
+
function isModuleFilePath(id) {
|
|
1244
|
+
return id.startsWith("/");
|
|
1245
|
+
}
|
|
1246
|
+
function planOf(selector) {
|
|
1247
|
+
var _Internal$viewHandleM;
|
|
1248
|
+
var root = (_Internal$viewHandleM = Internal.viewHandleModule(selector)) !== null && _Internal$viewHandleM !== void 0 ? _Internal$viewHandleM : selector;
|
|
1249
|
+
var cacheable = _typeof(root) === "object" && root !== null;
|
|
1250
|
+
if (cacheable) {
|
|
1251
|
+
var cached = plans.get(root);
|
|
1252
|
+
if (cached !== undefined) return cached;
|
|
1253
|
+
}
|
|
1254
|
+
// The ids `getModuleIds` collects are module paths, as `useVal`
|
|
1255
|
+
// subscribed to them.
|
|
1256
|
+
var modules = getModuleIds(root).filter(isModuleFilePath);
|
|
1257
|
+
var own = new Map();
|
|
1258
|
+
var record = null;
|
|
1259
|
+
var rootPath = Internal.isValModule(root) ? Internal.getValPath(root) : undefined;
|
|
1260
|
+
if (Internal.isValModule(root) && rootPath !== undefined) {
|
|
1261
|
+
var _Internal$splitModule = Internal.splitModuleFilePathAndModulePath(rootPath),
|
|
1262
|
+
_Internal$splitModule2 = _slicedToArray(_Internal$splitModule, 1),
|
|
1263
|
+
path = _Internal$splitModule2[0];
|
|
1264
|
+
own.set(path, root);
|
|
1265
|
+
if (isJsonValuesRecordSchema(Internal.getSchema(root))) {
|
|
1266
|
+
record = path;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
var plan = {
|
|
1270
|
+
modules: modules,
|
|
1271
|
+
own: own,
|
|
1272
|
+
record: record
|
|
1273
|
+
};
|
|
1274
|
+
if (cacheable) plans.set(root, plan);
|
|
1275
|
+
return plan;
|
|
1276
|
+
}
|
|
1277
|
+
var resolves = 0;
|
|
1278
|
+
var encodes = 0;
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* Counted work, for the scenarios' budgets (`read:resolve`, `read:encode`):
|
|
1282
|
+
* how many times a reader resolved, and how many of those encoded a value.
|
|
1283
|
+
* A render resolves once per selector unless something it waited on is in;
|
|
1284
|
+
* a server read resolves once per wait, plus the one that is ready.
|
|
1285
|
+
*/
|
|
1286
|
+
function readWork() {
|
|
1287
|
+
return {
|
|
1288
|
+
resolve: resolves,
|
|
1289
|
+
encode: encodes
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
/** How a read is made, beyond its env. */
|
|
1294
|
+
|
|
1295
|
+
function viewOf(env, plan, settled) {
|
|
1296
|
+
var schemaVersionOf = env.schemaVersionOf;
|
|
1297
|
+
return layered([].concat(_toConsumableArray(env.sources), [bundleSource(plan.own)]), schemaVersionOf ? _objectSpread2({
|
|
1298
|
+
schemaOf: function schemaOf(path) {
|
|
1299
|
+
var module = plan.own.get(path);
|
|
1300
|
+
return module === undefined ? null : schemaVersionOf(module);
|
|
1301
|
+
}
|
|
1302
|
+
}, env.codeChanged ? {
|
|
1303
|
+
codeChanged: env.codeChanged
|
|
1304
|
+
} : {}) : undefined, settled);
|
|
1305
|
+
}
|
|
1306
|
+
function pending(waits) {
|
|
1307
|
+
var _waits = _slicedToArray(waits, 1),
|
|
1308
|
+
first = _waits[0];
|
|
1309
|
+
return first === undefined ? null : {
|
|
1310
|
+
status: "pending",
|
|
1311
|
+
ready: first,
|
|
1312
|
+
waits: waits
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* Resolve `selector` against `env`: read the modules {@link planOf} names
|
|
1318
|
+
* from the sources (the first that does not pass wins: `layered`), fill a
|
|
1319
|
+
* whole `.jsonValues()` record's entries, and -- once nothing is pending --
|
|
1320
|
+
* encode the value. Every reader of a value goes through this: `fetchVal`,
|
|
1321
|
+
* `useVal`, and the route readers' modules.
|
|
1322
|
+
*/
|
|
1323
|
+
function resolveVal(selector, env, opts) {
|
|
1324
|
+
resolves++;
|
|
1325
|
+
var plan = planOf(selector);
|
|
1326
|
+
var view = viewOf(env, plan, opts === null || opts === void 0 ? void 0 : opts.settled);
|
|
1327
|
+
var answers = new Map();
|
|
1328
|
+
var reads = [];
|
|
1329
|
+
var waits = [];
|
|
1330
|
+
var _iterator = _createForOfIteratorHelper(plan.modules),
|
|
1331
|
+
_step;
|
|
1332
|
+
try {
|
|
1333
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1334
|
+
var path = _step.value;
|
|
1335
|
+
var _view$module = view.module(path),
|
|
1336
|
+
read = _view$module.read,
|
|
1337
|
+
at = _view$module.at;
|
|
1338
|
+
if (read.status === "pending") {
|
|
1339
|
+
waits.push(read.ready);
|
|
1340
|
+
continue;
|
|
1341
|
+
}
|
|
1342
|
+
if (read.status === "ready") {
|
|
1343
|
+
answers.set(path, read.source);
|
|
1344
|
+
reads.push({
|
|
1345
|
+
path: path,
|
|
1346
|
+
from: read.from,
|
|
1347
|
+
version: read.version
|
|
1348
|
+
});
|
|
1349
|
+
} else {
|
|
1350
|
+
reads.push({
|
|
1351
|
+
path: path,
|
|
1352
|
+
from: "bundle",
|
|
1353
|
+
version: null
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
if (path === plan.record && (opts === null || opts === void 0 ? void 0 : opts.entries) !== false) {
|
|
1357
|
+
var _answers$get;
|
|
1358
|
+
var own = plan.own.get(path);
|
|
1359
|
+
var filled = fillRecord(view, path, (_answers$get = answers.get(path)) !== null && _answers$get !== void 0 ? _answers$get : own && Internal.getSource(own), at, waits);
|
|
1360
|
+
if (filled !== undefined) answers.set(path, filled);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
} catch (err) {
|
|
1364
|
+
_iterator.e(err);
|
|
1365
|
+
} finally {
|
|
1366
|
+
_iterator.f();
|
|
1367
|
+
}
|
|
1368
|
+
var wait = pending(waits);
|
|
1369
|
+
if (wait !== null) return wait;
|
|
1370
|
+
encodes++;
|
|
1371
|
+
return {
|
|
1372
|
+
status: "ready",
|
|
1373
|
+
value: stegaEncode(selector, {
|
|
1374
|
+
disabled: !env.encode,
|
|
1375
|
+
getModule: function getModule(moduleId) {
|
|
1376
|
+
return answers.get(moduleId);
|
|
1377
|
+
}
|
|
1378
|
+
}),
|
|
1379
|
+
reads: reads
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* A whole `.jsonValues()` record, with its entries' content: its own source
|
|
1385
|
+
* holds a lazy marker per entry, so a reader that encodes that source renders
|
|
1386
|
+
* every entry empty. An entry that is still a marker where the record was
|
|
1387
|
+
* read is taken from a later source that has its content, ending at the
|
|
1388
|
+
* bundle's import; one whose import failed keeps its marker, which is what a
|
|
1389
|
+
* failed read rendered before.
|
|
1390
|
+
*
|
|
1391
|
+
* `undefined` when there is nothing to fill: the record is not an object (a
|
|
1392
|
+
* nullable record that is null), or holds no marker.
|
|
1393
|
+
*/
|
|
1394
|
+
function fillRecord(view, path, record, at, waits) {
|
|
1395
|
+
if (_typeof(record) !== "object" || record === null || Array.isArray(record)) {
|
|
1396
|
+
return undefined;
|
|
1397
|
+
}
|
|
1398
|
+
var filled = null;
|
|
1399
|
+
for (var _i = 0, _Object$entries = Object.entries(record); _i < _Object$entries.length; _i++) {
|
|
1400
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
1401
|
+
key = _Object$entries$_i[0],
|
|
1402
|
+
entry = _Object$entries$_i[1];
|
|
1403
|
+
if (!Internal.isJson(entry)) continue;
|
|
1404
|
+
var content = undefined;
|
|
1405
|
+
// `gone` from a later source is not this entry gone: the source that
|
|
1406
|
+
// answered for the record has it. Ask the next one.
|
|
1407
|
+
for (var after = at; after < view.sources.length;) {
|
|
1408
|
+
var read = view.entry(path, key, after);
|
|
1409
|
+
if (read.status === "ready") {
|
|
1410
|
+
content = read.content;
|
|
1411
|
+
break;
|
|
1412
|
+
}
|
|
1413
|
+
if (read.status === "pending") {
|
|
1414
|
+
waits.push(read.ready);
|
|
1415
|
+
break;
|
|
1416
|
+
}
|
|
1417
|
+
if (read.status === "failed") {
|
|
1418
|
+
Internal.log.error("could not load the entry '".concat(key, "' of ").concat(path), read.error);
|
|
1419
|
+
break;
|
|
1420
|
+
}
|
|
1421
|
+
if (read.status === "gone") {
|
|
1422
|
+
after = sourceIndex(view, read.from, after);
|
|
1423
|
+
continue;
|
|
1424
|
+
}
|
|
1425
|
+
break;
|
|
1426
|
+
}
|
|
1427
|
+
if (content !== undefined) {
|
|
1428
|
+
filled !== null && filled !== void 0 ? filled : filled = _objectSpread2({}, record);
|
|
1429
|
+
filled[key] = content;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
return filled === null ? undefined : filled;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/** The index of the source named `from`, after `after`. */
|
|
1436
|
+
function sourceIndex(view, from, after) {
|
|
1437
|
+
for (var at = after + 1; at < view.sources.length; at++) {
|
|
1438
|
+
var _view$sources$at;
|
|
1439
|
+
if (((_view$sources$at = view.sources[at]) === null || _view$sources$at === void 0 ? void 0 : _view$sources$at.name) === from) return at;
|
|
1440
|
+
}
|
|
1441
|
+
return view.sources.length;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* Resolve ONE `.jsonValues()` entry of `selector` by key: the first source
|
|
1446
|
+
* that has an answer, where "the entry is gone" is an answer (a draft that
|
|
1447
|
+
* deleted it must not render the published one) and the bundle's import is
|
|
1448
|
+
* the last. Loads that entry and no other. `undefined` for an entry that is
|
|
1449
|
+
* not there. An entry whose import failed throws, as the import did.
|
|
1450
|
+
*/
|
|
1451
|
+
function resolveValEntry(selector, key, env, opts) {
|
|
1452
|
+
return resolveModuleEntry(Internal.resolveViewedModule(selector), key, env, opts);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
/** {@link resolveValEntry}, for a module (a view resolved). */
|
|
1456
|
+
function resolveModuleEntry(module, key, env, opts) {
|
|
1457
|
+
resolves++;
|
|
1458
|
+
var plan = planOf(module);
|
|
1459
|
+
var path = plan.own.keys().next().value;
|
|
1460
|
+
if (path === undefined) {
|
|
1461
|
+
return {
|
|
1462
|
+
status: "ready",
|
|
1463
|
+
value: undefined,
|
|
1464
|
+
reads: []
|
|
1465
|
+
};
|
|
1466
|
+
}
|
|
1467
|
+
var read = viewOf(env, plan, opts === null || opts === void 0 ? void 0 : opts.settled).entry(path, key);
|
|
1468
|
+
if (read.status === "pending") {
|
|
1469
|
+
return {
|
|
1470
|
+
status: "pending",
|
|
1471
|
+
ready: read.ready,
|
|
1472
|
+
waits: [read.ready]
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
if (read.status === "failed") {
|
|
1476
|
+
throw read.error;
|
|
1477
|
+
}
|
|
1478
|
+
var reads = [{
|
|
1479
|
+
path: path,
|
|
1480
|
+
from: read.status === "pass" ? "bundle" : read.from,
|
|
1481
|
+
version: null
|
|
1482
|
+
}];
|
|
1483
|
+
if (read.status !== "ready" || read.content === undefined) {
|
|
1484
|
+
return {
|
|
1485
|
+
status: "ready",
|
|
1486
|
+
value: undefined,
|
|
1487
|
+
reads: reads
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
encodes++;
|
|
1491
|
+
return {
|
|
1492
|
+
status: "ready",
|
|
1493
|
+
value: stegaEncode(read.content, {
|
|
1494
|
+
disabled: !env.encode,
|
|
1495
|
+
root: getJsonEntryStegaRoot(module, key)
|
|
1496
|
+
}),
|
|
1497
|
+
reads: reads
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
/** A resolution's value, mapped; a wait stays the same wait. */
|
|
1502
|
+
function mapResolution(r, f) {
|
|
1503
|
+
return r.status === "ready" ? {
|
|
1504
|
+
status: "ready",
|
|
1505
|
+
value: f(r.value),
|
|
1506
|
+
reads: r.reads
|
|
1507
|
+
} : r;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
1511
|
+
var i = Object.defineProperty;
|
|
1512
|
+
try {
|
|
1513
|
+
i({}, "", {});
|
|
1514
|
+
} catch (e) {
|
|
1515
|
+
i = 0;
|
|
1516
|
+
}
|
|
1517
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
1518
|
+
function o(r, n) {
|
|
1519
|
+
_regeneratorDefine(e, r, function (e) {
|
|
1520
|
+
return this._invoke(r, n, e);
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
r ? i ? i(e, r, {
|
|
1524
|
+
value: n,
|
|
1525
|
+
enumerable: !t,
|
|
1526
|
+
configurable: !t,
|
|
1527
|
+
writable: !t
|
|
1528
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
1529
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
function _regenerator() {
|
|
1533
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
1534
|
+
var e,
|
|
1535
|
+
t,
|
|
1536
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
1537
|
+
n = r.iterator || "@@iterator",
|
|
1538
|
+
o = r.toStringTag || "@@toStringTag";
|
|
1539
|
+
function i(r, n, o, i) {
|
|
1540
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
1541
|
+
u = Object.create(c.prototype);
|
|
1542
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
1543
|
+
var i,
|
|
1544
|
+
c,
|
|
1545
|
+
u,
|
|
1546
|
+
f = 0,
|
|
1547
|
+
p = o || [],
|
|
1548
|
+
y = !1,
|
|
1549
|
+
G = {
|
|
1550
|
+
p: 0,
|
|
1551
|
+
n: 0,
|
|
1552
|
+
v: e,
|
|
1553
|
+
a: d,
|
|
1554
|
+
f: d.bind(e, 4),
|
|
1555
|
+
d: function (t, r) {
|
|
1556
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
function d(r, n) {
|
|
1560
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
1561
|
+
var o,
|
|
1562
|
+
i = p[t],
|
|
1563
|
+
d = G.p,
|
|
1564
|
+
l = i[2];
|
|
1565
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
1566
|
+
}
|
|
1567
|
+
if (o || r > 1) return a;
|
|
1568
|
+
throw y = !0, n;
|
|
1569
|
+
}
|
|
1570
|
+
return function (o, p, l) {
|
|
1571
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
1572
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
1573
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
1574
|
+
try {
|
|
1575
|
+
if (f = 2, i) {
|
|
1576
|
+
if (c || (o = "next"), t = i[o]) {
|
|
1577
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
1578
|
+
if (!t.done) return t;
|
|
1579
|
+
u = t.value, c < 2 && (c = 0);
|
|
1580
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
1581
|
+
i = e;
|
|
1582
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
1583
|
+
} catch (t) {
|
|
1584
|
+
i = e, c = 1, u = t;
|
|
1585
|
+
} finally {
|
|
1586
|
+
f = 1;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
return {
|
|
1590
|
+
value: t,
|
|
1591
|
+
done: y
|
|
1592
|
+
};
|
|
1593
|
+
};
|
|
1594
|
+
}(r, o, i), !0), u;
|
|
1595
|
+
}
|
|
1596
|
+
var a = {};
|
|
1597
|
+
function Generator() {}
|
|
1598
|
+
function GeneratorFunction() {}
|
|
1599
|
+
function GeneratorFunctionPrototype() {}
|
|
1600
|
+
t = Object.getPrototypeOf;
|
|
1601
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
1602
|
+
return this;
|
|
1603
|
+
}), t),
|
|
1604
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
1605
|
+
function f(e) {
|
|
1606
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
1607
|
+
}
|
|
1608
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
1609
|
+
return this;
|
|
1610
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
1611
|
+
return "[object Generator]";
|
|
1612
|
+
}), (_regenerator = function () {
|
|
1613
|
+
return {
|
|
1614
|
+
w: i,
|
|
1615
|
+
m: f
|
|
1616
|
+
};
|
|
1617
|
+
})();
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
1621
|
+
try {
|
|
1622
|
+
var i = n[a](c),
|
|
1623
|
+
u = i.value;
|
|
1624
|
+
} catch (n) {
|
|
1625
|
+
return void e(n);
|
|
1626
|
+
}
|
|
1627
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
1628
|
+
}
|
|
1629
|
+
function _asyncToGenerator(n) {
|
|
1630
|
+
return function () {
|
|
1631
|
+
var t = this,
|
|
1632
|
+
e = arguments;
|
|
1633
|
+
return new Promise(function (r, o) {
|
|
1634
|
+
var a = n.apply(t, e);
|
|
1635
|
+
function _next(n) {
|
|
1636
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
1637
|
+
}
|
|
1638
|
+
function _throw(n) {
|
|
1639
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
1640
|
+
}
|
|
1641
|
+
_next(void 0);
|
|
1642
|
+
});
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
/*
|
|
1647
|
+
* How the readers wait: the one thing, besides where content comes from,
|
|
1648
|
+
* that differs between them. A server read awaits and resolves again; a
|
|
1649
|
+
* component suspends (`React.use`) and renders again. Everything before the
|
|
1650
|
+
* wait is `resolveVal`.
|
|
1651
|
+
*/
|
|
1652
|
+
|
|
1653
|
+
/** A read that is ready: the value, and what it was read from. */
|
|
1654
|
+
|
|
1655
|
+
/**
|
|
1656
|
+
* How many times a server read may wait before it is a bug: each wait is a
|
|
1657
|
+
* source that will have an answer once it has loaded, and a read meets at
|
|
1658
|
+
* most a few (the draft, then the entries it names).
|
|
1659
|
+
*/
|
|
1660
|
+
var MAX_WAITS = 50;
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* Resolve on the server: wait for what is pending, then resolve again, with
|
|
1664
|
+
* the waits that are over handed back (`settled`, see `layered`).
|
|
1665
|
+
*/
|
|
1666
|
+
function awaitResolved(_x) {
|
|
1667
|
+
return _awaitResolved.apply(this, arguments);
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
/**
|
|
1671
|
+
* Resolve in a component: subscribe to the modules `selector` reads, and
|
|
1672
|
+
* suspend on what is pending (`React.use`, which the caller's `<Suspense>`
|
|
1673
|
+
* boundary waits on). The one hook every client reader of both frameworks is
|
|
1674
|
+
* built on; `env` is the framework's.
|
|
1675
|
+
*
|
|
1676
|
+
* Re-renders when a source says a read of those modules would answer
|
|
1677
|
+
* differently -- `revision` is a string, so `useSyncExternalStore` compares
|
|
1678
|
+
* it with `===` and a render that moves nothing re-renders nothing.
|
|
1679
|
+
*/
|
|
1680
|
+
function _awaitResolved() {
|
|
1681
|
+
_awaitResolved = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(resolve) {
|
|
1682
|
+
var settled, waited, r, _iterator2, _step2, wait;
|
|
1683
|
+
return _regenerator().w(function (_context2) {
|
|
1684
|
+
while (1) switch (_context2.n) {
|
|
1685
|
+
case 0:
|
|
1686
|
+
settled = new Set();
|
|
1687
|
+
waited = 0;
|
|
1688
|
+
case 1:
|
|
1689
|
+
r = resolve(settled);
|
|
1690
|
+
if (!(r.status === "ready")) {
|
|
1691
|
+
_context2.n = 2;
|
|
1692
|
+
break;
|
|
1693
|
+
}
|
|
1694
|
+
return _context2.a(2, {
|
|
1695
|
+
value: r.value,
|
|
1696
|
+
reads: r.reads
|
|
1697
|
+
});
|
|
1698
|
+
case 2:
|
|
1699
|
+
if (!(waited >= MAX_WAITS)) {
|
|
1700
|
+
_context2.n = 3;
|
|
1701
|
+
break;
|
|
1702
|
+
}
|
|
1703
|
+
throw new Error("A content read was still waiting after ".concat(MAX_WAITS, " answers: a source answered \"pending\" without ever becoming ready."));
|
|
1704
|
+
case 3:
|
|
1705
|
+
_context2.n = 4;
|
|
1706
|
+
return Promise.all(r.waits);
|
|
1707
|
+
case 4:
|
|
1708
|
+
_iterator2 = _createForOfIteratorHelper(r.waits);
|
|
1709
|
+
try {
|
|
1710
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1711
|
+
wait = _step2.value;
|
|
1712
|
+
settled.add(wait);
|
|
1713
|
+
}
|
|
1714
|
+
} catch (err) {
|
|
1715
|
+
_iterator2.e(err);
|
|
1716
|
+
} finally {
|
|
1717
|
+
_iterator2.f();
|
|
1718
|
+
}
|
|
1719
|
+
case 5:
|
|
1720
|
+
waited++;
|
|
1721
|
+
_context2.n = 1;
|
|
1722
|
+
break;
|
|
1723
|
+
case 6:
|
|
1724
|
+
return _context2.a(2);
|
|
1725
|
+
}
|
|
1726
|
+
}, _callee2);
|
|
1727
|
+
}));
|
|
1728
|
+
return _awaitResolved.apply(this, arguments);
|
|
1729
|
+
}
|
|
1730
|
+
function useResolved(selector, env, resolve) {
|
|
1731
|
+
var modules = planOf(selector).modules;
|
|
1732
|
+
var subscribe = React.useCallback(function (onChange) {
|
|
1733
|
+
return layered(env.sources).subscribe(modules, onChange);
|
|
1734
|
+
}, [env, modules]);
|
|
1735
|
+
var revision = function revision() {
|
|
1736
|
+
return layered(env.sources).revision(modules);
|
|
1737
|
+
};
|
|
1738
|
+
React.useSyncExternalStore(subscribe, revision, revision);
|
|
1739
|
+
var settled = new Set();
|
|
1740
|
+
for (;;) {
|
|
1741
|
+
var r = resolve(settled);
|
|
1742
|
+
if (r.status === "ready") {
|
|
1743
|
+
return r.value;
|
|
1744
|
+
}
|
|
1745
|
+
// Every wait the read met, together, as the server awaits them: one
|
|
1746
|
+
// suspension for a whole record's entries, not one per entry (each a
|
|
1747
|
+
// render that resolves the whole read again). Returns only once they
|
|
1748
|
+
// are all over (it throws to suspend until then), and then the read is
|
|
1749
|
+
// made again: what it waited for is in, or -- a source still waiting on
|
|
1750
|
+
// it -- did not come, and is passed over.
|
|
1751
|
+
React.use(allOf(r.waits));
|
|
1752
|
+
var _iterator = _createForOfIteratorHelper(r.waits),
|
|
1753
|
+
_step;
|
|
1754
|
+
try {
|
|
1755
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1756
|
+
var wait = _step.value;
|
|
1757
|
+
settled.add(wait);
|
|
1758
|
+
}
|
|
1759
|
+
} catch (err) {
|
|
1760
|
+
_iterator.e(err);
|
|
1761
|
+
} finally {
|
|
1762
|
+
_iterator.f();
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
/**
|
|
1768
|
+
* The waits a read met, as one promise -- the SAME promise for the same
|
|
1769
|
+
* waits, render after render, which `React.use` needs (one made afresh each
|
|
1770
|
+
* render is never seen to settle). Kept beside the first wait.
|
|
1771
|
+
*/
|
|
1772
|
+
var combined = new WeakMap();
|
|
1773
|
+
function allOf(waits) {
|
|
1774
|
+
var _combined$get;
|
|
1775
|
+
var _waits = _slicedToArray(waits, 1),
|
|
1776
|
+
first = _waits[0];
|
|
1777
|
+
if (first === undefined) return Promise.resolve();
|
|
1778
|
+
if (waits.length === 1) return first;
|
|
1779
|
+
var held = (_combined$get = combined.get(first)) !== null && _combined$get !== void 0 ? _combined$get : [];
|
|
1780
|
+
var found = held.find(function (entry) {
|
|
1781
|
+
return entry.waits.length === waits.length && entry.waits.every(function (wait, i) {
|
|
1782
|
+
return wait === waits[i];
|
|
1783
|
+
});
|
|
1784
|
+
});
|
|
1785
|
+
if (found !== undefined) return found.all;
|
|
1786
|
+
var all = Promise.all(waits).then(function () {
|
|
1787
|
+
return undefined;
|
|
1788
|
+
});
|
|
1789
|
+
held.push({
|
|
1790
|
+
waits: _toConsumableArray(waits),
|
|
1791
|
+
all: all
|
|
1792
|
+
});
|
|
1793
|
+
combined.set(first, held);
|
|
1794
|
+
return all;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
/**
|
|
1798
|
+
* `useVal`, for both frameworks: the one hook that was `useValStega` in each,
|
|
1799
|
+
* with the framework's env (its overlay, its snapshot, its rule for edit
|
|
1800
|
+
* tags). `entries: false` for a reader that needs a `.jsonValues()` record's
|
|
1801
|
+
* keys and not its entries.
|
|
1802
|
+
*/
|
|
1803
|
+
function useResolvedVal(selector, env, opts) {
|
|
1804
|
+
return useResolved(selector, env, function (settled) {
|
|
1805
|
+
return resolveVal(selector, env, _objectSpread2({
|
|
1806
|
+
settled: settled
|
|
1807
|
+
}, opts));
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
var NOTHING = {
|
|
1811
|
+
status: "ready",
|
|
1812
|
+
value: undefined,
|
|
1813
|
+
reads: []
|
|
1814
|
+
};
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* `useValKey`, for both frameworks: one `.jsonValues()` entry, loading that
|
|
1818
|
+
* entry and no other. `key: null` reads nothing (a route the params did not
|
|
1819
|
+
* match), and still subscribes, so the hooks of a component stay the same.
|
|
1820
|
+
*/
|
|
1821
|
+
function useResolvedEntry(selector, key, env) {
|
|
1822
|
+
return useResolved(selector, env, function (settled) {
|
|
1823
|
+
return key === null ? NOTHING : resolveValEntry(selector, key, env, {
|
|
1824
|
+
settled: settled
|
|
1825
|
+
});
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
/** A `fetchVal` that also says what it read. */
|
|
1830
|
+
|
|
1831
|
+
var fetchValReads = new WeakMap();
|
|
1832
|
+
|
|
1833
|
+
/**
|
|
1834
|
+
* The public `fetchVal` of a framework: `withReads`, giving the value only.
|
|
1835
|
+
* The reads stay reachable, from the function, for the scenario world
|
|
1836
|
+
* (`scenarios/`), which records the version beside the value a loader shows
|
|
1837
|
+
* and must call the same function the product does to get it
|
|
1838
|
+
* ({@link readsOfFetchVal}). Nothing in the product asks.
|
|
1839
|
+
*/
|
|
1840
|
+
function fetchValFrom(withReads) {
|
|
1841
|
+
var fetchVal = /*#__PURE__*/function () {
|
|
1842
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(selector) {
|
|
1843
|
+
return _regenerator().w(function (_context) {
|
|
1844
|
+
while (1) switch (_context.n) {
|
|
1845
|
+
case 0:
|
|
1846
|
+
_context.n = 1;
|
|
1847
|
+
return withReads(selector);
|
|
1848
|
+
case 1:
|
|
1849
|
+
return _context.a(2, _context.v.value);
|
|
1850
|
+
}
|
|
1851
|
+
}, _callee);
|
|
1852
|
+
}));
|
|
1853
|
+
return function fetchVal(_x2) {
|
|
1854
|
+
return _ref.apply(this, arguments);
|
|
1855
|
+
};
|
|
1856
|
+
}();
|
|
1857
|
+
fetchValReads.set(fetchVal, withReads);
|
|
1858
|
+
return fetchVal;
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
/** The read behind a `fetchVal` made by {@link fetchValFrom}. */
|
|
1862
|
+
function readsOfFetchVal(fetchVal) {
|
|
1863
|
+
var _fetchValReads$get;
|
|
1864
|
+
return (_fetchValReads$get = fetchValReads.get(fetchVal)) !== null && _fetchValReads$get !== void 0 ? _fetchValReads$get : null;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
export { ValExternalStore, ValRichText, applyValEvent, awaitResolved, bundleSource, bundledJsonEntryImport, createDraftStore, draftHolds, draftHoldsVersions, entryOfModuleSource, fetchValFrom, getJsonEntryStegaRoot, isDraft, isJsonValuesRecordSchema, layered, mapResolution, overlaySource, planOf, readWork, readsOfFetchVal, resolveModuleEntry, resolveVal, resolveValEntry, snapshotSource, startRefreshLoop, useResolved, useResolvedEntry, useResolvedVal };
|