@valbuild/next 0.144.10 → 0.144.12
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 +23 -0
- package/client/dist/valbuild-next-client.cjs.dev.js +44 -7
- package/client/dist/valbuild-next-client.cjs.prod.js +44 -7
- package/client/dist/valbuild-next-client.esm.js +44 -7
- package/dist/{routeFromVal-d53d5ffb.cjs.dev.js → routeFromVal-52811ee4.cjs.dev.js} +113 -0
- package/dist/{routeFromVal-e0995830.cjs.prod.js → routeFromVal-6fc9f240.cjs.prod.js} +113 -0
- package/dist/{routeFromVal-544e8318.esm.js → routeFromVal-fe1264b3.esm.js} +111 -1
- package/dist/valbuild-next.cjs.dev.js +1 -1
- package/dist/valbuild-next.cjs.prod.js +1 -1
- package/dist/valbuild-next.esm.js +1 -1
- package/dist/{version-843db7f4.cjs.prod.js → version-0810b6c6.cjs.prod.js} +1 -1
- package/dist/{version-0eab70c9.cjs.dev.js → version-ea45bbd4.cjs.dev.js} +1 -1
- package/dist/{version-718b1608.esm.js → version-fbd8cd3e.esm.js} +1 -1
- package/package.json +6 -6
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +322 -208
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +322 -208
- package/rsc/dist/valbuild-next-rsc.esm.js +322 -208
- package/server/dist/valbuild-next-server.cjs.dev.js +1 -1
- package/server/dist/valbuild-next-server.cjs.prod.js +1 -1
- package/server/dist/valbuild-next-server.esm.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @valbuild/next
|
|
2
2
|
|
|
3
|
+
## 0.144.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#854](https://github.com/valbuild/val/pull/854) [`2193e3a`](https://github.com/valbuild/val/commit/2193e3ae133cd05dd73d0937dde7c15c88417f71) Thanks [@freekh](https://github.com/freekh)! - `useVal` and `fetchVal` on a whole `.jsonValues()` record now give every entry's content. They gave each entry back empty in production, on the server and in the browser, because the record holds only a lazy import for each entry; content showed up only where a draft or a hosted content version supplied it. They now load every entry the record names, together. `useValKey` and `fetchValKey` still load only the entry they are asked for, which is the reader to use when a page shows one entry of a large record.
|
|
8
|
+
- Updated dependencies [[`2193e3a`](https://github.com/valbuild/val/commit/2193e3ae133cd05dd73d0937dde7c15c88417f71)]:
|
|
9
|
+
- @valbuild/ui@0.144.12
|
|
10
|
+
- @valbuild/react@0.144.12
|
|
11
|
+
- @valbuild/server@0.144.12
|
|
12
|
+
- @valbuild/language-server@0.144.12
|
|
13
|
+
- @valbuild/mcp@0.144.12
|
|
14
|
+
|
|
15
|
+
## 0.144.11
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`c606395`](https://github.com/valbuild/val/commit/c60639571f9e836726dfef38e6bd0defc503d726)]:
|
|
20
|
+
- @valbuild/ui@0.144.11
|
|
21
|
+
- @valbuild/react@0.144.11
|
|
22
|
+
- @valbuild/server@0.144.11
|
|
23
|
+
- @valbuild/language-server@0.144.11
|
|
24
|
+
- @valbuild/mcp@0.144.11
|
|
25
|
+
|
|
3
26
|
## 0.144.10
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('client-only');
|
|
6
|
-
var routeFromVal = require('../../dist/routeFromVal-
|
|
6
|
+
var routeFromVal = require('../../dist/routeFromVal-52811ee4.cjs.dev.js');
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
9
|
var React = require('react');
|
|
@@ -74,12 +74,34 @@ function useValStega(selector) {
|
|
|
74
74
|
if (valOverlayContext.suspend && valOverlayContext.draftMode !== false && !valOverlayContext.draftSourcesSynced && store && !store.hasAllLoaded(moduleIds)) {
|
|
75
75
|
React__default["default"].use(store.waitForLoad(moduleIds));
|
|
76
76
|
}
|
|
77
|
+
var sourceOf = function sourceOf(moduleId) {
|
|
78
|
+
return moduleMap && valOverlayContext.draftMode ? moduleMap[moduleId] : undefined;
|
|
79
|
+
};
|
|
80
|
+
/*
|
|
81
|
+
* A whole `.jsonValues()` record is read with every entry's content: its own
|
|
82
|
+
* source holds only lazy markers. The entries the draft view does not have
|
|
83
|
+
* are imported from the bundle -- all of them started before waiting on any,
|
|
84
|
+
* so they load together. `useValKey` is the reader for one entry.
|
|
85
|
+
*/
|
|
86
|
+
var jsonValues = routeFromVal.jsonValuesRecordToFill(selector, function (modulePath) {
|
|
87
|
+
return [sourceOf(modulePath)];
|
|
88
|
+
});
|
|
89
|
+
var filledRecord = null;
|
|
90
|
+
if (jsonValues !== null) {
|
|
91
|
+
var pending = jsonValues.load.map(function (key) {
|
|
92
|
+
return committedJsonEntryPromise(jsonValues.module, jsonValues.modulePath, key);
|
|
93
|
+
});
|
|
94
|
+
var loaded = {};
|
|
95
|
+
jsonValues.load.forEach(function (key, index) {
|
|
96
|
+
var promise = pending[index];
|
|
97
|
+
loaded[key] = promise === undefined ? undefined : React__default["default"].use(promise);
|
|
98
|
+
});
|
|
99
|
+
filledRecord = routeFromVal.fillJsonValuesRecord(jsonValues.record, loaded);
|
|
100
|
+
}
|
|
77
101
|
return stega.stegaEncode(selector, {
|
|
78
102
|
disabled: !valOverlayContext.draftMode,
|
|
79
103
|
getModule: function getModule(moduleId) {
|
|
80
|
-
|
|
81
|
-
return moduleMap[moduleId];
|
|
82
|
-
}
|
|
104
|
+
return jsonValues !== null && moduleId === jsonValues.modulePath ? filledRecord : sourceOf(moduleId);
|
|
83
105
|
}
|
|
84
106
|
});
|
|
85
107
|
}
|
|
@@ -191,7 +213,6 @@ function useValKeyStega(selector, key) {
|
|
|
191
213
|
* because `React.use` is not a hook, but a `use*` name would read like one.
|
|
192
214
|
*/
|
|
193
215
|
function readCommittedJsonEntry(selector, key) {
|
|
194
|
-
var _Internal$getValPath;
|
|
195
216
|
var source = selector && core.Internal.getSource(selector);
|
|
196
217
|
var marker = source && routeFromVal._typeof(source) === "object" ? source[key] : undefined;
|
|
197
218
|
if (!core.Internal.isJson(marker)) {
|
|
@@ -201,15 +222,31 @@ function readCommittedJsonEntry(selector, key) {
|
|
|
201
222
|
if (!thunk) {
|
|
202
223
|
return undefined;
|
|
203
224
|
}
|
|
204
|
-
var
|
|
225
|
+
var promise = committedJsonEntryPromise(selector, core.Internal.getValPath(selector), key);
|
|
226
|
+
return promise === undefined ? undefined : React__default["default"].use(promise);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The bundle's import of one entry, started once and kept, so every render
|
|
231
|
+
* that waits on it is handed the same promise (`React.use` needs that).
|
|
232
|
+
* `undefined` when the module has no import for `key`.
|
|
233
|
+
*/
|
|
234
|
+
function committedJsonEntryPromise(
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
236
|
+
module, modulePath, key) {
|
|
237
|
+
var cacheKey = "".concat(modulePath !== null && modulePath !== void 0 ? modulePath : "", " ").concat(key);
|
|
205
238
|
var promise = jsonEntryPromiseCache.get(cacheKey);
|
|
206
239
|
if (!promise) {
|
|
240
|
+
var thunk = routeFromVal.bundledJsonEntryImport(module, key);
|
|
241
|
+
if (!thunk) {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
207
244
|
promise = thunk().then(function (mod) {
|
|
208
245
|
return mod["default"];
|
|
209
246
|
});
|
|
210
247
|
jsonEntryPromiseCache.set(cacheKey, promise);
|
|
211
248
|
}
|
|
212
|
-
return
|
|
249
|
+
return promise;
|
|
213
250
|
}
|
|
214
251
|
function resolveParams(params) {
|
|
215
252
|
if (!params) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('client-only');
|
|
6
|
-
var routeFromVal = require('../../dist/routeFromVal-
|
|
6
|
+
var routeFromVal = require('../../dist/routeFromVal-6fc9f240.cjs.prod.js');
|
|
7
7
|
var core = require('@valbuild/core');
|
|
8
8
|
var stega = require('@valbuild/react/stega');
|
|
9
9
|
var React = require('react');
|
|
@@ -74,12 +74,34 @@ function useValStega(selector) {
|
|
|
74
74
|
if (valOverlayContext.suspend && valOverlayContext.draftMode !== false && !valOverlayContext.draftSourcesSynced && store && !store.hasAllLoaded(moduleIds)) {
|
|
75
75
|
React__default["default"].use(store.waitForLoad(moduleIds));
|
|
76
76
|
}
|
|
77
|
+
var sourceOf = function sourceOf(moduleId) {
|
|
78
|
+
return moduleMap && valOverlayContext.draftMode ? moduleMap[moduleId] : undefined;
|
|
79
|
+
};
|
|
80
|
+
/*
|
|
81
|
+
* A whole `.jsonValues()` record is read with every entry's content: its own
|
|
82
|
+
* source holds only lazy markers. The entries the draft view does not have
|
|
83
|
+
* are imported from the bundle -- all of them started before waiting on any,
|
|
84
|
+
* so they load together. `useValKey` is the reader for one entry.
|
|
85
|
+
*/
|
|
86
|
+
var jsonValues = routeFromVal.jsonValuesRecordToFill(selector, function (modulePath) {
|
|
87
|
+
return [sourceOf(modulePath)];
|
|
88
|
+
});
|
|
89
|
+
var filledRecord = null;
|
|
90
|
+
if (jsonValues !== null) {
|
|
91
|
+
var pending = jsonValues.load.map(function (key) {
|
|
92
|
+
return committedJsonEntryPromise(jsonValues.module, jsonValues.modulePath, key);
|
|
93
|
+
});
|
|
94
|
+
var loaded = {};
|
|
95
|
+
jsonValues.load.forEach(function (key, index) {
|
|
96
|
+
var promise = pending[index];
|
|
97
|
+
loaded[key] = promise === undefined ? undefined : React__default["default"].use(promise);
|
|
98
|
+
});
|
|
99
|
+
filledRecord = routeFromVal.fillJsonValuesRecord(jsonValues.record, loaded);
|
|
100
|
+
}
|
|
77
101
|
return stega.stegaEncode(selector, {
|
|
78
102
|
disabled: !valOverlayContext.draftMode,
|
|
79
103
|
getModule: function getModule(moduleId) {
|
|
80
|
-
|
|
81
|
-
return moduleMap[moduleId];
|
|
82
|
-
}
|
|
104
|
+
return jsonValues !== null && moduleId === jsonValues.modulePath ? filledRecord : sourceOf(moduleId);
|
|
83
105
|
}
|
|
84
106
|
});
|
|
85
107
|
}
|
|
@@ -191,7 +213,6 @@ function useValKeyStega(selector, key) {
|
|
|
191
213
|
* because `React.use` is not a hook, but a `use*` name would read like one.
|
|
192
214
|
*/
|
|
193
215
|
function readCommittedJsonEntry(selector, key) {
|
|
194
|
-
var _Internal$getValPath;
|
|
195
216
|
var source = selector && core.Internal.getSource(selector);
|
|
196
217
|
var marker = source && routeFromVal._typeof(source) === "object" ? source[key] : undefined;
|
|
197
218
|
if (!core.Internal.isJson(marker)) {
|
|
@@ -201,15 +222,31 @@ function readCommittedJsonEntry(selector, key) {
|
|
|
201
222
|
if (!thunk) {
|
|
202
223
|
return undefined;
|
|
203
224
|
}
|
|
204
|
-
var
|
|
225
|
+
var promise = committedJsonEntryPromise(selector, core.Internal.getValPath(selector), key);
|
|
226
|
+
return promise === undefined ? undefined : React__default["default"].use(promise);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* The bundle's import of one entry, started once and kept, so every render
|
|
231
|
+
* that waits on it is handed the same promise (`React.use` needs that).
|
|
232
|
+
* `undefined` when the module has no import for `key`.
|
|
233
|
+
*/
|
|
234
|
+
function committedJsonEntryPromise(
|
|
235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
236
|
+
module, modulePath, key) {
|
|
237
|
+
var cacheKey = "".concat(modulePath !== null && modulePath !== void 0 ? modulePath : "", " ").concat(key);
|
|
205
238
|
var promise = jsonEntryPromiseCache.get(cacheKey);
|
|
206
239
|
if (!promise) {
|
|
240
|
+
var thunk = routeFromVal.bundledJsonEntryImport(module, key);
|
|
241
|
+
if (!thunk) {
|
|
242
|
+
return undefined;
|
|
243
|
+
}
|
|
207
244
|
promise = thunk().then(function (mod) {
|
|
208
245
|
return mod["default"];
|
|
209
246
|
});
|
|
210
247
|
jsonEntryPromiseCache.set(cacheKey, promise);
|
|
211
248
|
}
|
|
212
|
-
return
|
|
249
|
+
return promise;
|
|
213
250
|
}
|
|
214
251
|
function resolveParams(params) {
|
|
215
252
|
if (!params) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'client-only';
|
|
2
|
-
import { g as getJsonEntryStegaRoot, _ as _typeof, a as isJsonValuesRecordSchema, b as getValRouteUrlFromVal, i as initValRouteFromVal } from '../../dist/routeFromVal-
|
|
2
|
+
import { j as jsonValuesRecordToFill, f as fillJsonValuesRecord, g as getJsonEntryStegaRoot, _ as _typeof, c as bundledJsonEntryImport, a as isJsonValuesRecordSchema, b as getValRouteUrlFromVal, i as initValRouteFromVal } from '../../dist/routeFromVal-fe1264b3.esm.js';
|
|
3
3
|
import { Internal } from '@valbuild/core';
|
|
4
4
|
import { getModuleIds, stegaEncode } from '@valbuild/react/stega';
|
|
5
5
|
import React from 'react';
|
|
@@ -66,12 +66,34 @@ function useValStega(selector) {
|
|
|
66
66
|
if (valOverlayContext.suspend && valOverlayContext.draftMode !== false && !valOverlayContext.draftSourcesSynced && store && !store.hasAllLoaded(moduleIds)) {
|
|
67
67
|
React.use(store.waitForLoad(moduleIds));
|
|
68
68
|
}
|
|
69
|
+
var sourceOf = function sourceOf(moduleId) {
|
|
70
|
+
return moduleMap && valOverlayContext.draftMode ? moduleMap[moduleId] : undefined;
|
|
71
|
+
};
|
|
72
|
+
/*
|
|
73
|
+
* A whole `.jsonValues()` record is read with every entry's content: its own
|
|
74
|
+
* source holds only lazy markers. The entries the draft view does not have
|
|
75
|
+
* are imported from the bundle -- all of them started before waiting on any,
|
|
76
|
+
* so they load together. `useValKey` is the reader for one entry.
|
|
77
|
+
*/
|
|
78
|
+
var jsonValues = jsonValuesRecordToFill(selector, function (modulePath) {
|
|
79
|
+
return [sourceOf(modulePath)];
|
|
80
|
+
});
|
|
81
|
+
var filledRecord = null;
|
|
82
|
+
if (jsonValues !== null) {
|
|
83
|
+
var pending = jsonValues.load.map(function (key) {
|
|
84
|
+
return committedJsonEntryPromise(jsonValues.module, jsonValues.modulePath, key);
|
|
85
|
+
});
|
|
86
|
+
var loaded = {};
|
|
87
|
+
jsonValues.load.forEach(function (key, index) {
|
|
88
|
+
var promise = pending[index];
|
|
89
|
+
loaded[key] = promise === undefined ? undefined : React.use(promise);
|
|
90
|
+
});
|
|
91
|
+
filledRecord = fillJsonValuesRecord(jsonValues.record, loaded);
|
|
92
|
+
}
|
|
69
93
|
return stegaEncode(selector, {
|
|
70
94
|
disabled: !valOverlayContext.draftMode,
|
|
71
95
|
getModule: function getModule(moduleId) {
|
|
72
|
-
|
|
73
|
-
return moduleMap[moduleId];
|
|
74
|
-
}
|
|
96
|
+
return jsonValues !== null && moduleId === jsonValues.modulePath ? filledRecord : sourceOf(moduleId);
|
|
75
97
|
}
|
|
76
98
|
});
|
|
77
99
|
}
|
|
@@ -183,7 +205,6 @@ function useValKeyStega(selector, key) {
|
|
|
183
205
|
* because `React.use` is not a hook, but a `use*` name would read like one.
|
|
184
206
|
*/
|
|
185
207
|
function readCommittedJsonEntry(selector, key) {
|
|
186
|
-
var _Internal$getValPath;
|
|
187
208
|
var source = selector && Internal.getSource(selector);
|
|
188
209
|
var marker = source && _typeof(source) === "object" ? source[key] : undefined;
|
|
189
210
|
if (!Internal.isJson(marker)) {
|
|
@@ -193,15 +214,31 @@ function readCommittedJsonEntry(selector, key) {
|
|
|
193
214
|
if (!thunk) {
|
|
194
215
|
return undefined;
|
|
195
216
|
}
|
|
196
|
-
var
|
|
217
|
+
var promise = committedJsonEntryPromise(selector, Internal.getValPath(selector), key);
|
|
218
|
+
return promise === undefined ? undefined : React.use(promise);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The bundle's import of one entry, started once and kept, so every render
|
|
223
|
+
* that waits on it is handed the same promise (`React.use` needs that).
|
|
224
|
+
* `undefined` when the module has no import for `key`.
|
|
225
|
+
*/
|
|
226
|
+
function committedJsonEntryPromise(
|
|
227
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
|
+
module, modulePath, key) {
|
|
229
|
+
var cacheKey = "".concat(modulePath !== null && modulePath !== void 0 ? modulePath : "", " ").concat(key);
|
|
197
230
|
var promise = jsonEntryPromiseCache.get(cacheKey);
|
|
198
231
|
if (!promise) {
|
|
232
|
+
var thunk = bundledJsonEntryImport(module, key);
|
|
233
|
+
if (!thunk) {
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
199
236
|
promise = thunk().then(function (mod) {
|
|
200
237
|
return mod["default"];
|
|
201
238
|
});
|
|
202
239
|
jsonEntryPromiseCache.set(cacheKey, promise);
|
|
203
240
|
}
|
|
204
|
-
return
|
|
241
|
+
return promise;
|
|
205
242
|
}
|
|
206
243
|
function resolveParams(params) {
|
|
207
244
|
if (!params) {
|
|
@@ -25,6 +25,116 @@ function isJsonValuesRecordSchema(schema) {
|
|
|
25
25
|
return schema instanceof core.RecordSchema && schema["executeSerialize"]().jsonValues === true;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* A whole `.jsonValues()` record, as `useVal` and `fetchVal` read it: with
|
|
30
|
+
* every entry's content. In the record's own source each entry is a lazy
|
|
31
|
+
* `c.json(() => import(...))` marker, so a reader that encodes that source
|
|
32
|
+
* renders every entry empty. (`useValKey` and `fetchValKey` read one entry,
|
|
33
|
+
* and load only that one.)
|
|
34
|
+
*
|
|
35
|
+
* `sourcesOf(modulePath)` are what the reader has before the bundle, the first
|
|
36
|
+
* that has the record winning: a draft view, then a snapshot (a proposal's saves, or the
|
|
37
|
+
* content version the site serves). An entry that is still a marker there is
|
|
38
|
+
* taken from a later source that has its content; the rest are named in
|
|
39
|
+
* `load`, for the reader to load from the bundle by key and hand to
|
|
40
|
+
* {@link fillJsonValuesRecord}.
|
|
41
|
+
*
|
|
42
|
+
* `null` when the selector is not a `.jsonValues()` module, or its record is
|
|
43
|
+
* not an object (a nullable record that is null): there is nothing to fill.
|
|
44
|
+
*/
|
|
45
|
+
function jsonValuesRecordToFill(
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
selector, sourcesOf) {
|
|
48
|
+
// Untyped, as `getJsonEntryStegaRoot`'s selector is: a module or a view of
|
|
49
|
+
// one, whichever source type it was defined with.
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
var module = core.Internal.resolveViewedModule(selector);
|
|
52
|
+
if (!module || !isJsonValuesRecordSchema(core.Internal.getSchema(module))) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
var modulePath = core.Internal.getValPath(module);
|
|
56
|
+
if (!modulePath) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
var sources = sourcesOf(modulePath);
|
|
60
|
+
var isRecord = function isRecord(value) {
|
|
61
|
+
return _typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
62
|
+
};
|
|
63
|
+
var chosen = sources.find(function (source) {
|
|
64
|
+
return source !== undefined;
|
|
65
|
+
});
|
|
66
|
+
var base = chosen !== undefined ? chosen : core.Internal.getSource(module);
|
|
67
|
+
if (!isRecord(base)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
var record = {};
|
|
71
|
+
var load = [];
|
|
72
|
+
var _loop = function _loop() {
|
|
73
|
+
var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
|
|
74
|
+
key = _Object$entries$_i[0],
|
|
75
|
+
entry = _Object$entries$_i[1];
|
|
76
|
+
if (!core.Internal.isJson(entry)) {
|
|
77
|
+
record[key] = entry;
|
|
78
|
+
return 1; // continue
|
|
79
|
+
}
|
|
80
|
+
var later = sources.slice(sources.indexOf(chosen) + 1).map(function (source) {
|
|
81
|
+
return isRecord(source) && Object.prototype.hasOwnProperty.call(source, key) ? source[key] : undefined;
|
|
82
|
+
}).find(function (content) {
|
|
83
|
+
return content !== undefined && !core.Internal.isJson(content);
|
|
84
|
+
});
|
|
85
|
+
if (later !== undefined) {
|
|
86
|
+
record[key] = later;
|
|
87
|
+
} else {
|
|
88
|
+
// Left as the marker until it is loaded: see `fillJsonValuesRecord`.
|
|
89
|
+
record[key] = entry;
|
|
90
|
+
load.push(key);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
for (var _i = 0, _Object$entries = Object.entries(base); _i < _Object$entries.length; _i++) {
|
|
94
|
+
if (_loop()) continue;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
modulePath: modulePath,
|
|
98
|
+
module: module,
|
|
99
|
+
record: record,
|
|
100
|
+
load: load
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The record from {@link jsonValuesRecordToFill}, with the entries it named in
|
|
106
|
+
* `load` put in: `loaded[key]`, as the bundle's import of that entry gave it.
|
|
107
|
+
* An entry the bundle has no import for keeps its marker.
|
|
108
|
+
*/
|
|
109
|
+
function fillJsonValuesRecord(record, loaded) {
|
|
110
|
+
var filled = objectSpread2._objectSpread2({}, record);
|
|
111
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(loaded); _i2 < _Object$entries2.length; _i2++) {
|
|
112
|
+
var _Object$entries2$_i = slicedToArray._slicedToArray(_Object$entries2[_i2], 2),
|
|
113
|
+
key = _Object$entries2$_i[0],
|
|
114
|
+
content = _Object$entries2$_i[1];
|
|
115
|
+
if (content !== undefined) {
|
|
116
|
+
filled[key] = content;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return filled;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The bundle's import of one `.jsonValues()` entry, started: `undefined` when
|
|
124
|
+
* the module's own source has no marker for `key` to import from.
|
|
125
|
+
*/
|
|
126
|
+
function bundledJsonEntryImport(
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
module, key) {
|
|
129
|
+
var _Internal$getJsonImpo;
|
|
130
|
+
var source = module && core.Internal.getSource(module);
|
|
131
|
+
var marker = _typeof(source) === "object" && source !== null && !Array.isArray(source) ? source[key] : undefined;
|
|
132
|
+
if (!core.Internal.isJson(marker)) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return (_Internal$getJsonImpo = core.Internal.getJsonImport(marker)) !== null && _Internal$getJsonImpo !== void 0 ? _Internal$getJsonImpo : undefined;
|
|
136
|
+
}
|
|
137
|
+
|
|
28
138
|
/**
|
|
29
139
|
* Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
|
|
30
140
|
* strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
|
|
@@ -196,7 +306,10 @@ val) {
|
|
|
196
306
|
}
|
|
197
307
|
|
|
198
308
|
exports._typeof = _typeof;
|
|
309
|
+
exports.bundledJsonEntryImport = bundledJsonEntryImport;
|
|
310
|
+
exports.fillJsonValuesRecord = fillJsonValuesRecord;
|
|
199
311
|
exports.getJsonEntryStegaRoot = getJsonEntryStegaRoot;
|
|
200
312
|
exports.getValRouteUrlFromVal = getValRouteUrlFromVal;
|
|
201
313
|
exports.initValRouteFromVal = initValRouteFromVal;
|
|
202
314
|
exports.isJsonValuesRecordSchema = isJsonValuesRecordSchema;
|
|
315
|
+
exports.jsonValuesRecordToFill = jsonValuesRecordToFill;
|
|
@@ -25,6 +25,116 @@ function isJsonValuesRecordSchema(schema) {
|
|
|
25
25
|
return schema instanceof core.RecordSchema && schema["executeSerialize"]().jsonValues === true;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* A whole `.jsonValues()` record, as `useVal` and `fetchVal` read it: with
|
|
30
|
+
* every entry's content. In the record's own source each entry is a lazy
|
|
31
|
+
* `c.json(() => import(...))` marker, so a reader that encodes that source
|
|
32
|
+
* renders every entry empty. (`useValKey` and `fetchValKey` read one entry,
|
|
33
|
+
* and load only that one.)
|
|
34
|
+
*
|
|
35
|
+
* `sourcesOf(modulePath)` are what the reader has before the bundle, the first
|
|
36
|
+
* that has the record winning: a draft view, then a snapshot (a proposal's saves, or the
|
|
37
|
+
* content version the site serves). An entry that is still a marker there is
|
|
38
|
+
* taken from a later source that has its content; the rest are named in
|
|
39
|
+
* `load`, for the reader to load from the bundle by key and hand to
|
|
40
|
+
* {@link fillJsonValuesRecord}.
|
|
41
|
+
*
|
|
42
|
+
* `null` when the selector is not a `.jsonValues()` module, or its record is
|
|
43
|
+
* not an object (a nullable record that is null): there is nothing to fill.
|
|
44
|
+
*/
|
|
45
|
+
function jsonValuesRecordToFill(
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
selector, sourcesOf) {
|
|
48
|
+
// Untyped, as `getJsonEntryStegaRoot`'s selector is: a module or a view of
|
|
49
|
+
// one, whichever source type it was defined with.
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
var module = core.Internal.resolveViewedModule(selector);
|
|
52
|
+
if (!module || !isJsonValuesRecordSchema(core.Internal.getSchema(module))) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
var modulePath = core.Internal.getValPath(module);
|
|
56
|
+
if (!modulePath) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
var sources = sourcesOf(modulePath);
|
|
60
|
+
var isRecord = function isRecord(value) {
|
|
61
|
+
return _typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
62
|
+
};
|
|
63
|
+
var chosen = sources.find(function (source) {
|
|
64
|
+
return source !== undefined;
|
|
65
|
+
});
|
|
66
|
+
var base = chosen !== undefined ? chosen : core.Internal.getSource(module);
|
|
67
|
+
if (!isRecord(base)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
var record = {};
|
|
71
|
+
var load = [];
|
|
72
|
+
var _loop = function _loop() {
|
|
73
|
+
var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
|
|
74
|
+
key = _Object$entries$_i[0],
|
|
75
|
+
entry = _Object$entries$_i[1];
|
|
76
|
+
if (!core.Internal.isJson(entry)) {
|
|
77
|
+
record[key] = entry;
|
|
78
|
+
return 1; // continue
|
|
79
|
+
}
|
|
80
|
+
var later = sources.slice(sources.indexOf(chosen) + 1).map(function (source) {
|
|
81
|
+
return isRecord(source) && Object.prototype.hasOwnProperty.call(source, key) ? source[key] : undefined;
|
|
82
|
+
}).find(function (content) {
|
|
83
|
+
return content !== undefined && !core.Internal.isJson(content);
|
|
84
|
+
});
|
|
85
|
+
if (later !== undefined) {
|
|
86
|
+
record[key] = later;
|
|
87
|
+
} else {
|
|
88
|
+
// Left as the marker until it is loaded: see `fillJsonValuesRecord`.
|
|
89
|
+
record[key] = entry;
|
|
90
|
+
load.push(key);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
for (var _i = 0, _Object$entries = Object.entries(base); _i < _Object$entries.length; _i++) {
|
|
94
|
+
if (_loop()) continue;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
modulePath: modulePath,
|
|
98
|
+
module: module,
|
|
99
|
+
record: record,
|
|
100
|
+
load: load
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The record from {@link jsonValuesRecordToFill}, with the entries it named in
|
|
106
|
+
* `load` put in: `loaded[key]`, as the bundle's import of that entry gave it.
|
|
107
|
+
* An entry the bundle has no import for keeps its marker.
|
|
108
|
+
*/
|
|
109
|
+
function fillJsonValuesRecord(record, loaded) {
|
|
110
|
+
var filled = objectSpread2._objectSpread2({}, record);
|
|
111
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(loaded); _i2 < _Object$entries2.length; _i2++) {
|
|
112
|
+
var _Object$entries2$_i = slicedToArray._slicedToArray(_Object$entries2[_i2], 2),
|
|
113
|
+
key = _Object$entries2$_i[0],
|
|
114
|
+
content = _Object$entries2$_i[1];
|
|
115
|
+
if (content !== undefined) {
|
|
116
|
+
filled[key] = content;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return filled;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The bundle's import of one `.jsonValues()` entry, started: `undefined` when
|
|
124
|
+
* the module's own source has no marker for `key` to import from.
|
|
125
|
+
*/
|
|
126
|
+
function bundledJsonEntryImport(
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
128
|
+
module, key) {
|
|
129
|
+
var _Internal$getJsonImpo;
|
|
130
|
+
var source = module && core.Internal.getSource(module);
|
|
131
|
+
var marker = _typeof(source) === "object" && source !== null && !Array.isArray(source) ? source[key] : undefined;
|
|
132
|
+
if (!core.Internal.isJson(marker)) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return (_Internal$getJsonImpo = core.Internal.getJsonImport(marker)) !== null && _Internal$getJsonImpo !== void 0 ? _Internal$getJsonImpo : undefined;
|
|
136
|
+
}
|
|
137
|
+
|
|
28
138
|
/**
|
|
29
139
|
* Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
|
|
30
140
|
* strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
|
|
@@ -196,7 +306,10 @@ val) {
|
|
|
196
306
|
}
|
|
197
307
|
|
|
198
308
|
exports._typeof = _typeof;
|
|
309
|
+
exports.bundledJsonEntryImport = bundledJsonEntryImport;
|
|
310
|
+
exports.fillJsonValuesRecord = fillJsonValuesRecord;
|
|
199
311
|
exports.getJsonEntryStegaRoot = getJsonEntryStegaRoot;
|
|
200
312
|
exports.getValRouteUrlFromVal = getValRouteUrlFromVal;
|
|
201
313
|
exports.initValRouteFromVal = initValRouteFromVal;
|
|
202
314
|
exports.isJsonValuesRecordSchema = isJsonValuesRecordSchema;
|
|
315
|
+
exports.jsonValuesRecordToFill = jsonValuesRecordToFill;
|
|
@@ -23,6 +23,116 @@ function isJsonValuesRecordSchema(schema) {
|
|
|
23
23
|
return schema instanceof RecordSchema && schema["executeSerialize"]().jsonValues === true;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* A whole `.jsonValues()` record, as `useVal` and `fetchVal` read it: with
|
|
28
|
+
* every entry's content. In the record's own source each entry is a lazy
|
|
29
|
+
* `c.json(() => import(...))` marker, so a reader that encodes that source
|
|
30
|
+
* renders every entry empty. (`useValKey` and `fetchValKey` read one entry,
|
|
31
|
+
* and load only that one.)
|
|
32
|
+
*
|
|
33
|
+
* `sourcesOf(modulePath)` are what the reader has before the bundle, the first
|
|
34
|
+
* that has the record winning: a draft view, then a snapshot (a proposal's saves, or the
|
|
35
|
+
* content version the site serves). An entry that is still a marker there is
|
|
36
|
+
* taken from a later source that has its content; the rest are named in
|
|
37
|
+
* `load`, for the reader to load from the bundle by key and hand to
|
|
38
|
+
* {@link fillJsonValuesRecord}.
|
|
39
|
+
*
|
|
40
|
+
* `null` when the selector is not a `.jsonValues()` module, or its record is
|
|
41
|
+
* not an object (a nullable record that is null): there is nothing to fill.
|
|
42
|
+
*/
|
|
43
|
+
function jsonValuesRecordToFill(
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
selector, sourcesOf) {
|
|
46
|
+
// Untyped, as `getJsonEntryStegaRoot`'s selector is: a module or a view of
|
|
47
|
+
// one, whichever source type it was defined with.
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
var module = Internal.resolveViewedModule(selector);
|
|
50
|
+
if (!module || !isJsonValuesRecordSchema(Internal.getSchema(module))) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
var modulePath = Internal.getValPath(module);
|
|
54
|
+
if (!modulePath) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
var sources = sourcesOf(modulePath);
|
|
58
|
+
var isRecord = function isRecord(value) {
|
|
59
|
+
return _typeof(value) === "object" && value !== null && !Array.isArray(value);
|
|
60
|
+
};
|
|
61
|
+
var chosen = sources.find(function (source) {
|
|
62
|
+
return source !== undefined;
|
|
63
|
+
});
|
|
64
|
+
var base = chosen !== undefined ? chosen : Internal.getSource(module);
|
|
65
|
+
if (!isRecord(base)) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
var record = {};
|
|
69
|
+
var load = [];
|
|
70
|
+
var _loop = function _loop() {
|
|
71
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
72
|
+
key = _Object$entries$_i[0],
|
|
73
|
+
entry = _Object$entries$_i[1];
|
|
74
|
+
if (!Internal.isJson(entry)) {
|
|
75
|
+
record[key] = entry;
|
|
76
|
+
return 1; // continue
|
|
77
|
+
}
|
|
78
|
+
var later = sources.slice(sources.indexOf(chosen) + 1).map(function (source) {
|
|
79
|
+
return isRecord(source) && Object.prototype.hasOwnProperty.call(source, key) ? source[key] : undefined;
|
|
80
|
+
}).find(function (content) {
|
|
81
|
+
return content !== undefined && !Internal.isJson(content);
|
|
82
|
+
});
|
|
83
|
+
if (later !== undefined) {
|
|
84
|
+
record[key] = later;
|
|
85
|
+
} else {
|
|
86
|
+
// Left as the marker until it is loaded: see `fillJsonValuesRecord`.
|
|
87
|
+
record[key] = entry;
|
|
88
|
+
load.push(key);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
for (var _i = 0, _Object$entries = Object.entries(base); _i < _Object$entries.length; _i++) {
|
|
92
|
+
if (_loop()) continue;
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
modulePath: modulePath,
|
|
96
|
+
module: module,
|
|
97
|
+
record: record,
|
|
98
|
+
load: load
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The record from {@link jsonValuesRecordToFill}, with the entries it named in
|
|
104
|
+
* `load` put in: `loaded[key]`, as the bundle's import of that entry gave it.
|
|
105
|
+
* An entry the bundle has no import for keeps its marker.
|
|
106
|
+
*/
|
|
107
|
+
function fillJsonValuesRecord(record, loaded) {
|
|
108
|
+
var filled = _objectSpread2({}, record);
|
|
109
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(loaded); _i2 < _Object$entries2.length; _i2++) {
|
|
110
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
111
|
+
key = _Object$entries2$_i[0],
|
|
112
|
+
content = _Object$entries2$_i[1];
|
|
113
|
+
if (content !== undefined) {
|
|
114
|
+
filled[key] = content;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return filled;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The bundle's import of one `.jsonValues()` entry, started: `undefined` when
|
|
122
|
+
* the module's own source has no marker for `key` to import from.
|
|
123
|
+
*/
|
|
124
|
+
function bundledJsonEntryImport(
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
|
+
module, key) {
|
|
127
|
+
var _Internal$getJsonImpo;
|
|
128
|
+
var source = module && Internal.getSource(module);
|
|
129
|
+
var marker = _typeof(source) === "object" && source !== null && !Array.isArray(source) ? source[key] : undefined;
|
|
130
|
+
if (!Internal.isJson(marker)) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
return (_Internal$getJsonImpo = Internal.getJsonImport(marker)) !== null && _Internal$getJsonImpo !== void 0 ? _Internal$getJsonImpo : undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
26
136
|
/**
|
|
27
137
|
* Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
|
|
28
138
|
* strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
|
|
@@ -193,4 +303,4 @@ val) {
|
|
|
193
303
|
return actualRoute;
|
|
194
304
|
}
|
|
195
305
|
|
|
196
|
-
export { _typeof as _, isJsonValuesRecordSchema as a, getValRouteUrlFromVal as b, getJsonEntryStegaRoot as g, initValRouteFromVal as i };
|
|
306
|
+
export { _typeof as _, isJsonValuesRecordSchema as a, getValRouteUrlFromVal as b, bundledJsonEntryImport as c, fillJsonValuesRecord as f, getJsonEntryStegaRoot as g, initValRouteFromVal as i, jsonValuesRecordToFill as j };
|
|
@@ -14,7 +14,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
14
14
|
var ValVideo = require('./ValVideo-b8130c1b.cjs.dev.js');
|
|
15
15
|
var ValApp = require('./ValApp-294e5b53.cjs.dev.js');
|
|
16
16
|
var ValModulesClient = require('./ValModulesClient-4ecabf99.cjs.dev.js');
|
|
17
|
-
var version = require('./version-
|
|
17
|
+
var version = require('./version-ea45bbd4.cjs.dev.js');
|
|
18
18
|
var createForOfIteratorHelper = require('./createForOfIteratorHelper-0445603c.cjs.dev.js');
|
|
19
19
|
require('./defineProperty-f90345d7.cjs.dev.js');
|
|
20
20
|
require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|