@valbuild/next 0.150.22 → 0.151.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 +174 -0
- package/README.md +82 -1
- package/client/dist/valbuild-next-client.cjs.dev.js +123 -256
- package/client/dist/valbuild-next-client.cjs.prod.js +123 -256
- package/client/dist/valbuild-next-client.esm.js +122 -255
- package/dist/{ValApp-a88a9ded.esm.js → ValApp-69cd599c.esm.js} +3 -3
- package/dist/{ValApp-c718d1a6.cjs.dev.js → ValApp-826dca6c.cjs.dev.js} +3 -3
- package/dist/ValApp-866089f6.cjs.js +7 -0
- package/dist/{ValApp-6c3da222.cjs.prod.js → ValApp-866089f6.cjs.prod.js} +3 -3
- package/dist/{ValCanvasBridge-9d221d32.cjs.dev.js → ValCanvasBridge-4b81f653.cjs.dev.js} +46 -13
- package/dist/ValCanvasBridge-6f568f1d.cjs.js +7 -0
- package/dist/{ValCanvasBridge-134c3ae1.cjs.prod.js → ValCanvasBridge-6f568f1d.cjs.prod.js} +46 -13
- package/dist/{ValCanvasBridge-4a5ef73c.esm.js → ValCanvasBridge-badc186b.esm.js} +46 -13
- package/dist/ValNextProvider-41d622a7.cjs.js +7 -0
- package/dist/{ValNextProvider-35d0b521.cjs.prod.js → ValNextProvider-41d622a7.cjs.prod.js} +124 -234
- package/dist/{ValNextProvider-a85a1d33.cjs.dev.js → ValNextProvider-4b9bcfc0.cjs.dev.js} +124 -234
- package/dist/{ValNextProvider-df6f351e.esm.js → ValNextProvider-745ed99e.esm.js} +124 -234
- package/dist/ValOverlayContext-0c29b6a7.cjs.dev.js +51 -0
- package/dist/ValOverlayContext-0f51d111.cjs.js +7 -0
- package/dist/ValOverlayContext-0f51d111.cjs.prod.js +51 -0
- package/dist/ValOverlayContext-178db68e.esm.js +37 -0
- package/dist/ValVideo-02f43a7c.cjs.js +7 -0
- package/dist/{ValVideo-dcd2b9f8.cjs.prod.js → ValVideo-02f43a7c.cjs.prod.js} +1 -2
- package/dist/{ValVideo-6e410ad8.cjs.dev.js → ValVideo-15e5c4fa.cjs.dev.js} +1 -2
- package/dist/{ValVideo-d377f06e.esm.js → ValVideo-8acf31b6.esm.js} +1 -2
- package/dist/{createForOfIteratorHelper-d4afcad8.cjs.prod.js → createForOfIteratorHelper-8459fbc7.cjs.prod.js} +1 -1
- package/dist/{createForOfIteratorHelper-5758a730.esm.js → createForOfIteratorHelper-9209e9dd.esm.js} +1 -1
- package/dist/{createForOfIteratorHelper-0445603c.cjs.dev.js → createForOfIteratorHelper-9c6aa3c7.cjs.dev.js} +1 -1
- package/dist/declarations/src/ValProvider.d.ts +1 -0
- package/dist/declarations/src/client/initValClient.d.ts +25 -3
- package/dist/declarations/src/external_exempt_from_val_quickjs.d.ts +1 -0
- package/dist/declarations/src/rsc/index.d.ts +1 -0
- package/dist/declarations/src/rsc/initValRsc.d.ts +56 -118
- package/dist/declarations/src/server/initValServer.d.ts +2 -1
- package/dist/{fallbackColors-149dfbc9.esm.js → fallbackColors-0d915c59.esm.js} +1 -1
- package/dist/{fallbackColors-080c1bbc.cjs.dev.js → fallbackColors-38f01ad2.cjs.dev.js} +1 -1
- package/dist/{fallbackColors-e1d73b36.cjs.prod.js → fallbackColors-d9a7b81e.cjs.prod.js} +1 -1
- package/dist/{objectSpread2-13f847a9.cjs.prod.js → objectSpread2-469273e9.cjs.prod.js} +25 -2
- package/dist/{objectSpread2-58024783.cjs.dev.js → objectSpread2-58726b14.cjs.dev.js} +25 -2
- package/dist/{objectSpread2-60d1bd93.esm.js → objectSpread2-f1f0d77a.esm.js} +24 -1
- package/dist/{routeFromVal-64cba2a6.esm.js → routeFromVal-80976677.esm.js} +5 -155
- package/dist/{routeFromVal-4df1157a.cjs.dev.js → routeFromVal-a1e0a8be.cjs.dev.js} +3 -159
- package/dist/{routeFromVal-812be6ea.cjs.prod.js → routeFromVal-c4dace91.cjs.prod.js} +3 -159
- package/dist/{slicedToArray-ce613de6.cjs.prod.js → slicedToArray-0fc63719.cjs.prod.js} +1 -1
- package/dist/{slicedToArray-aa291011.esm.js → slicedToArray-5ff32315.esm.js} +1 -1
- package/dist/{slicedToArray-44036a76.cjs.dev.js → slicedToArray-ed812733.cjs.dev.js} +1 -1
- package/dist/{unsupportedIterableToArray-c8ab77c9.cjs.dev.js → unsupportedIterableToArray-1aadf9fb.cjs.prod.js} +1 -0
- package/dist/{unsupportedIterableToArray-0d2087a2.cjs.prod.js → unsupportedIterableToArray-20a9209f.cjs.dev.js} +1 -0
- package/dist/{unsupportedIterableToArray-5baabfdc.esm.js → unsupportedIterableToArray-f57eb659.esm.js} +1 -1
- package/dist/useHydrated-8e90c7fa.cjs.js +7 -0
- package/dist/useHydrated-8e90c7fa.cjs.prod.js +34 -0
- package/dist/useHydrated-afcdbb66.esm.js +26 -0
- package/dist/useHydrated-ff733777.cjs.dev.js +34 -0
- package/dist/valbuild-next.cjs.dev.js +7 -8
- package/dist/valbuild-next.cjs.prod.js +7 -8
- package/dist/valbuild-next.esm.js +7 -8
- package/dist/{version-18c11a6d.cjs.prod.js → version-114c45b6.cjs.prod.js} +1 -1
- package/dist/{version-70b7333d.cjs.dev.js → version-cc1bc4e5.cjs.dev.js} +1 -1
- package/dist/{version-a2218191.esm.js → version-d8f64e54.esm.js} +1 -1
- package/package.json +8 -8
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +243 -872
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +243 -872
- package/rsc/dist/valbuild-next-rsc.esm.js +243 -872
- package/server/dist/valbuild-next-server.cjs.dev.js +4 -5
- package/server/dist/valbuild-next-server.cjs.prod.js +4 -5
- package/server/dist/valbuild-next-server.esm.js +4 -5
- package/dist/ValApp-6c3da222.cjs.js +0 -7
- package/dist/ValCanvasBridge-134c3ae1.cjs.js +0 -7
- package/dist/ValNextProvider-35d0b521.cjs.js +0 -7
- package/dist/ValOverlayContext-1a45e03d.esm.js +0 -290
- package/dist/ValOverlayContext-262899b3.cjs.dev.js +0 -301
- package/dist/ValOverlayContext-405ca70c.cjs.js +0 -7
- package/dist/ValOverlayContext-405ca70c.cjs.prod.js +0 -301
- package/dist/ValVideo-dcd2b9f8.cjs.js +0 -7
- package/dist/defineProperty-8951f469.cjs.prod.js +0 -29
- package/dist/defineProperty-cca5affa.esm.js +0 -26
- package/dist/defineProperty-f90345d7.cjs.dev.js +0 -29
|
@@ -1,168 +1,87 @@
|
|
|
1
1
|
import 'client-only';
|
|
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-64cba2a6.esm.js';
|
|
3
2
|
import { Internal } from '@valbuild/core';
|
|
4
|
-
import {
|
|
3
|
+
import { useResolvedVal, useResolvedEntry, useResolved, isJsonValuesRecordSchema, mapResolution, resolveModuleEntry, resolveVal, overlaySource } from '@valbuild/react/internal';
|
|
5
4
|
import React from 'react';
|
|
6
|
-
import { useValOverlayContext } from '../../dist/ValOverlayContext-
|
|
7
|
-
import '../../dist/
|
|
8
|
-
import '../../dist/
|
|
9
|
-
import '../../dist/
|
|
10
|
-
import '../../dist/
|
|
11
|
-
import '../../dist/
|
|
5
|
+
import { useValOverlayContext } from '../../dist/ValOverlayContext-178db68e.esm.js';
|
|
6
|
+
import { useHydrated } from '../../dist/useHydrated-afcdbb66.esm.js';
|
|
7
|
+
import { g as getValRouteUrlFromVal, i as initValRouteFromVal } from '../../dist/routeFromVal-80976677.esm.js';
|
|
8
|
+
import '../../dist/createForOfIteratorHelper-9209e9dd.esm.js';
|
|
9
|
+
import '../../dist/unsupportedIterableToArray-f57eb659.esm.js';
|
|
10
|
+
import '../../dist/objectSpread2-f1f0d77a.esm.js';
|
|
11
|
+
import '../../dist/slicedToArray-5ff32315.esm.js';
|
|
12
12
|
import '@valbuild/shared/client';
|
|
13
13
|
|
|
14
|
-
/** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
|
|
15
|
-
|
|
16
|
-
function useValStega(selector) {
|
|
17
|
-
var valOverlayContext = useValOverlayContext();
|
|
18
|
-
var moduleIds = React.useMemo(function () {
|
|
19
|
-
return getModuleIds(selector);
|
|
20
|
-
}, [selector]);
|
|
21
|
-
var store = valOverlayContext.store;
|
|
22
|
-
var moduleMap = React.useSyncExternalStore(store ? store.subscribe(moduleIds) : function () {
|
|
23
|
-
return function () {};
|
|
24
|
-
}, store ? store.getSnapshot(moduleIds) : function () {
|
|
25
|
-
return;
|
|
26
|
-
}, store ? store.getServerSnapshot(moduleIds) : function () {
|
|
27
|
-
return;
|
|
28
|
-
});
|
|
29
|
-
// Suspense gate. `suspend` is false during SSR and hydration (so the static
|
|
30
|
-
// committed source is rendered, matching the server HTML exactly) and is
|
|
31
|
-
// activated by ValProvider after hydration — inside a transition — when the
|
|
32
|
-
// `suspend` prop is set AND the Val Enable cookie is present (checked
|
|
33
|
-
// client-side; the server store is never populated). It never deactivates.
|
|
34
|
-
// The production path (no cookie) skips the call entirely. The
|
|
35
|
-
// `draftMode !== false` check is a release valve: with draft mode off the
|
|
36
|
-
// store never receives source updates, so waitForLoad could only ever
|
|
37
|
-
// resolve via its timeout — and would then re-suspend on every subsequent
|
|
38
|
-
// render since the resolved promise is evicted from the cache. draftMode is
|
|
39
|
-
// null until the first /draft/stat poll resolves; null -> true keeps
|
|
40
|
-
// suspending, -> false only unblocks, and false -> true happens only on an
|
|
41
|
-
// explicit draft-mode enable which already refreshes the route.
|
|
42
|
-
// React.use is allowed inside conditionals — it is not a hook.
|
|
43
|
-
/**
|
|
44
|
-
* Wait until draft mode is KNOWN, before anything else.
|
|
45
|
-
*
|
|
46
|
-
* `draftMode === null` means `/draft/stat` has not answered yet, and the
|
|
47
|
-
* `getModule` below treats it as off — so a render that slips through here
|
|
48
|
-
* while it is unknown resolves against committed source. For an ordinary field
|
|
49
|
-
* that is a flash of published content; for `useValRoute` on a route that
|
|
50
|
-
* exists only in an uncommitted patch it is `notFound()`, which no later
|
|
51
|
-
* answer can undo. That was the 404 on a page you had just created.
|
|
52
|
-
*/
|
|
53
|
-
if (valOverlayContext.suspend && valOverlayContext.draftMode === null && valOverlayContext.draftModeReady) {
|
|
54
|
-
React.use(valOverlayContext.draftModeReady);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Then wait for the draft sources — but only while more might be coming.
|
|
58
|
-
*
|
|
59
|
-
* `draftSourcesSynced` is the editor saying it has sent everything it holds,
|
|
60
|
-
* and it only holds modules with patches: an unedited module has no draft, so
|
|
61
|
-
* nothing is ever sent for it. Without that signal this could not tell "not
|
|
62
|
-
* sent yet" from "nothing to send", and waited out `waitForLoad`'s ten second
|
|
63
|
-
* timeout once per unedited module the page reads — which is what left a newly
|
|
64
|
-
* created page sitting on its loading fallback.
|
|
65
|
-
*/
|
|
66
|
-
if (valOverlayContext.suspend && valOverlayContext.draftMode !== false && !valOverlayContext.draftSourcesSynced && store && !store.hasAllLoaded(moduleIds)) {
|
|
67
|
-
React.use(store.waitForLoad(moduleIds));
|
|
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
|
-
}
|
|
93
|
-
return stegaEncode(selector, {
|
|
94
|
-
disabled: !valOverlayContext.draftMode,
|
|
95
|
-
getModule: function getModule(moduleId) {
|
|
96
|
-
return jsonValues !== null && moduleId === jsonValues.modulePath ? filledRecord : sourceOf(moduleId);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
14
|
/**
|
|
102
|
-
*
|
|
103
|
-
* unpublished changes — or undefined when there is no draft view to be had
|
|
104
|
-
* (production, draft mode off, or the overlay has not pushed this module yet).
|
|
15
|
+
* Whether the content this component renders carries its edit tags.
|
|
105
16
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
17
|
+
* In draft mode -- except, on a page rendered from a server-read draft
|
|
18
|
+
* (`<ValProvider draft>`), for the server's render and for this component's
|
|
19
|
+
* own hydration render: then the draft text goes out without them, and the
|
|
20
|
+
* render React does right after hydrating the component puts them in. JSX
|
|
21
|
+
* auto-tagging turns a tagged string into a `data-val-path` attribute as the
|
|
22
|
+
* element is created, and whether the server renders with the patched JSX
|
|
23
|
+
* runtime depends on how it was bundled; a string with no tags in it has
|
|
24
|
+
* nothing to tag, so the server's HTML and every hydration render agree.
|
|
25
|
+
* The same rule as `@valbuild/tanstack`'s.
|
|
109
26
|
*/
|
|
110
|
-
function
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return moduleFilePath ? [moduleFilePath] : [];
|
|
115
|
-
}, [moduleFilePath]);
|
|
116
|
-
var moduleMap = React.useSyncExternalStore(store ? store.subscribe(moduleIds) : function () {
|
|
117
|
-
return function () {};
|
|
118
|
-
}, store ? store.getSnapshot(moduleIds) : function () {
|
|
119
|
-
return undefined;
|
|
120
|
-
}, store ? store.getServerSnapshot(moduleIds) : function () {
|
|
121
|
-
return undefined;
|
|
122
|
-
});
|
|
123
|
-
if (!valOverlayContext.draftMode || !moduleFilePath) {
|
|
124
|
-
return undefined;
|
|
125
|
-
}
|
|
126
|
-
return moduleMap === null || moduleMap === void 0 ? void 0 : moduleMap[moduleFilePath];
|
|
27
|
+
function useEncodesEditTags(context) {
|
|
28
|
+
var hydrated = useHydrated();
|
|
29
|
+
if (!context.draftMode) return false;
|
|
30
|
+
return !context.serverDraft || hydrated;
|
|
127
31
|
}
|
|
128
32
|
|
|
33
|
+
/** What the provider tells the hooks: `ValOverlayContext`'s value. */
|
|
34
|
+
|
|
129
35
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
36
|
+
* Where this page's hooks read from, in order: what the Studio sent (the
|
|
37
|
+
* overlay, which starts from the server-read draft when the page has one),
|
|
38
|
+
* then -- added by every read -- the bundle. Edit tags in draft mode, unless
|
|
39
|
+
* `encode` says otherwise (see `useEncodesEditTags`). A plain function of the
|
|
40
|
+
* provider's state, as `@valbuild/tanstack`'s is (which the scenario world
|
|
41
|
+
* reads a page with).
|
|
135
42
|
*/
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
status: "unavailable"
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
var entry = draftSource[key];
|
|
143
|
-
if (entry === undefined) {
|
|
144
|
-
// The module IS in the draft view and this key is not: it was deleted.
|
|
145
|
-
return {
|
|
146
|
-
status: "absent"
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
if (Internal.isJson(entry)) {
|
|
150
|
-
// An un-loaded marker: the Studio has not fetched this entry's content, so
|
|
151
|
-
// the draft view cannot answer. (The engine asks for entries that pending
|
|
152
|
-
// patches touch, so this resolves itself for anything actually edited.)
|
|
153
|
-
return {
|
|
154
|
-
status: "unavailable"
|
|
155
|
-
};
|
|
156
|
-
}
|
|
43
|
+
function pageReadEnv(state) {
|
|
44
|
+
var _state$draftSourcesSy;
|
|
45
|
+
var encode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !!state.draftMode;
|
|
157
46
|
return {
|
|
158
|
-
|
|
159
|
-
|
|
47
|
+
sources: [overlaySource(state.store, {
|
|
48
|
+
draftMode: state.draftMode,
|
|
49
|
+
suspend: state.suspend,
|
|
50
|
+
draftModeReady: state.draftModeReady,
|
|
51
|
+
synced: (_state$draftSourcesSy = state.draftSourcesSynced) !== null && _state$draftSourcesSy !== void 0 ? _state$draftSourcesSy : false
|
|
52
|
+
})],
|
|
53
|
+
encode: encode
|
|
160
54
|
};
|
|
161
55
|
}
|
|
162
56
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
57
|
+
/**
|
|
58
|
+
* {@link pageReadEnv} for this component, kept while nothing it is made of
|
|
59
|
+
* moves, so a component's subscription is not made again on every render.
|
|
60
|
+
*/
|
|
61
|
+
function useReadEnv() {
|
|
62
|
+
var context = useValOverlayContext();
|
|
63
|
+
var encode = useEncodesEditTags(context);
|
|
64
|
+
var store = context.store,
|
|
65
|
+
draftMode = context.draftMode,
|
|
66
|
+
suspend = context.suspend,
|
|
67
|
+
draftModeReady = context.draftModeReady,
|
|
68
|
+
draftSourcesSynced = context.draftSourcesSynced;
|
|
69
|
+
return React.useMemo(function () {
|
|
70
|
+
return pageReadEnv({
|
|
71
|
+
store: store,
|
|
72
|
+
draftMode: draftMode,
|
|
73
|
+
suspend: suspend,
|
|
74
|
+
draftModeReady: draftModeReady,
|
|
75
|
+
draftSourcesSynced: draftSourcesSynced
|
|
76
|
+
}, encode);
|
|
77
|
+
}, [store, draftMode, suspend, draftModeReady, draftSourcesSynced, encode]);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** What `useVal` gives back — see `ResolvedVal` in `@valbuild/react/stega`. */
|
|
81
|
+
|
|
82
|
+
function useValStega(selector) {
|
|
83
|
+
return useResolvedVal(selector, useReadEnv());
|
|
84
|
+
}
|
|
166
85
|
|
|
167
86
|
/**
|
|
168
87
|
* Client counterpart to `fetchValKey`: resolves a SINGLE `.jsonValues()` entry
|
|
@@ -171,74 +90,10 @@ var jsonEntryPromiseCache = new Map();
|
|
|
171
90
|
* inside a `<Suspense>` boundary.
|
|
172
91
|
*
|
|
173
92
|
* In draft mode it renders the editor's unpublished content, taken from the
|
|
174
|
-
* overlay;
|
|
175
|
-
* entry's lazy import thunk from the local module.
|
|
93
|
+
* overlay; an entry the draft deleted is `undefined`, never the bundled one.
|
|
176
94
|
*/
|
|
177
95
|
function useValKeyStega(selector, key) {
|
|
178
|
-
|
|
179
|
-
// A view is a pointer: everything below reads a path, a schema and a source
|
|
180
|
-
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
181
|
-
var valModule = Internal.resolveViewedModule(selector);
|
|
182
|
-
var moduleFilePath = valModule && Internal.getValPath(valModule);
|
|
183
|
-
var draftSource = useDraftModuleSource(moduleFilePath || undefined);
|
|
184
|
-
var draft = draftJsonEntry(draftSource, key);
|
|
185
|
-
if (draft.status === "absent") {
|
|
186
|
-
// Deleted in the draft state. Falling back to the bundled entry here would
|
|
187
|
-
// render content the editor has just removed.
|
|
188
|
-
return undefined;
|
|
189
|
-
}
|
|
190
|
-
var content = draft.status === "content" ? draft.content : undefined;
|
|
191
|
-
if (content === undefined) {
|
|
192
|
-
content = readCommittedJsonEntry(valModule, key);
|
|
193
|
-
}
|
|
194
|
-
return stegaEncode(content, {
|
|
195
|
-
disabled: !valOverlayContext.draftMode,
|
|
196
|
-
root: getJsonEntryStegaRoot(valModule, key)
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* The entry's content as bundled: its lazy import thunk, resolved through
|
|
202
|
-
* `React.use` so the caller suspends until it lands.
|
|
203
|
-
*
|
|
204
|
-
* Deliberately not named `use*`: it is called conditionally, which is fine
|
|
205
|
-
* because `React.use` is not a hook, but a `use*` name would read like one.
|
|
206
|
-
*/
|
|
207
|
-
function readCommittedJsonEntry(selector, key) {
|
|
208
|
-
var source = selector && Internal.getSource(selector);
|
|
209
|
-
var marker = source && _typeof(source) === "object" ? source[key] : undefined;
|
|
210
|
-
if (!Internal.isJson(marker)) {
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
|
-
var thunk = Internal.getJsonImport(marker);
|
|
214
|
-
if (!thunk) {
|
|
215
|
-
return undefined;
|
|
216
|
-
}
|
|
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);
|
|
230
|
-
var promise = jsonEntryPromiseCache.get(cacheKey);
|
|
231
|
-
if (!promise) {
|
|
232
|
-
var thunk = bundledJsonEntryImport(module, key);
|
|
233
|
-
if (!thunk) {
|
|
234
|
-
return undefined;
|
|
235
|
-
}
|
|
236
|
-
promise = thunk().then(function (mod) {
|
|
237
|
-
return mod["default"];
|
|
238
|
-
});
|
|
239
|
-
jsonEntryPromiseCache.set(cacheKey, promise);
|
|
240
|
-
}
|
|
241
|
-
return promise;
|
|
96
|
+
return useResolvedEntry(selector, key, useReadEnv());
|
|
242
97
|
}
|
|
243
98
|
function resolveParams(params) {
|
|
244
99
|
if (!params) {
|
|
@@ -257,63 +112,75 @@ function resolveParams(params) {
|
|
|
257
112
|
}
|
|
258
113
|
return params;
|
|
259
114
|
}
|
|
260
|
-
|
|
261
|
-
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* `useValRoute`'s read, once its params are known: a `.jsonValues()`
|
|
118
|
+
* router's one entry for the params (one dynamic import, like `useValKey`),
|
|
119
|
+
* or the router's entry for them. `null` for no such route.
|
|
120
|
+
*/
|
|
121
|
+
function routeRead(selector, params, env, settled) {
|
|
262
122
|
// A view is a pointer: everything below reads a path, a schema and a source
|
|
263
123
|
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
var path = valModule && Internal.getValPath(valModule);
|
|
276
|
-
var schema = valModule && Internal.getSchema(valModule);
|
|
277
|
-
// `.jsonValues()` router: map params → the entry key and load ONLY that
|
|
278
|
-
// entry's backing `*.val.json` (one dynamic import), like `useValKey`.
|
|
124
|
+
return moduleRouteRead(Internal.resolveViewedModule(selector), params, env, settled);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* {@link routeRead}, for a module (a view resolved). A plain function, so the
|
|
129
|
+
* scenario world (`scenarios/`) reads a route as the hook does.
|
|
130
|
+
*/
|
|
131
|
+
function moduleRouteRead(valModule, params, env, settled) {
|
|
132
|
+
var path = Internal.getValPath(valModule);
|
|
133
|
+
var schema = Internal.getSchema(valModule);
|
|
279
134
|
if (isJsonValuesRecordSchema(schema)) {
|
|
280
|
-
var
|
|
281
|
-
var url = getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
|
|
135
|
+
var url = getValRouteUrlFromVal(params, "useValRoute", path, schema, Internal.getSource(valModule));
|
|
282
136
|
if (!url) {
|
|
283
|
-
return
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
var content = draft.status === "content" ? draft.content : undefined;
|
|
291
|
-
if (content === undefined) {
|
|
292
|
-
content = readCommittedJsonEntry(valModule, url);
|
|
137
|
+
return {
|
|
138
|
+
status: "ready",
|
|
139
|
+
value: null,
|
|
140
|
+
reads: []
|
|
141
|
+
};
|
|
293
142
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
disabled: !valOverlayContext.draftMode,
|
|
299
|
-
root: getJsonEntryStegaRoot(valModule, url)
|
|
143
|
+
return mapResolution(resolveModuleEntry(valModule, url, env, {
|
|
144
|
+
settled: settled
|
|
145
|
+
}), function (entry) {
|
|
146
|
+
return entry === undefined ? null : entry;
|
|
300
147
|
});
|
|
301
148
|
}
|
|
302
|
-
|
|
303
|
-
|
|
149
|
+
return mapResolution(resolveVal(valModule, env, {
|
|
150
|
+
settled: settled
|
|
151
|
+
}), function (val) {
|
|
152
|
+
return initValRouteFromVal(params, "useValRoute", path, schema, val);
|
|
153
|
+
});
|
|
304
154
|
}
|
|
155
|
+
function useValRouteStega(selector, params) {
|
|
156
|
+
var env = useReadEnv();
|
|
157
|
+
var resolvedParams = resolveParams(params);
|
|
158
|
+
var value = useResolved(selector, env, function (settled) {
|
|
159
|
+
return resolvedParams === null ? NO_ROUTE : routeRead(selector, resolvedParams || {}, env, settled);
|
|
160
|
+
});
|
|
161
|
+
// Careful: null means there was an error - undefined means no params
|
|
162
|
+
return resolvedParams === null ? null : value;
|
|
163
|
+
}
|
|
164
|
+
var NO_ROUTE = {
|
|
165
|
+
status: "ready",
|
|
166
|
+
value: null,
|
|
167
|
+
reads: []
|
|
168
|
+
};
|
|
305
169
|
function useValRouteUrl(selector, params) {
|
|
306
170
|
// A view is a pointer: everything below reads a path, a schema and a source
|
|
307
171
|
// off this, and a pointer has none of them. See `resolveViewedModule`.
|
|
308
172
|
var valModule = Internal.resolveViewedModule(selector);
|
|
309
|
-
|
|
173
|
+
// The url is made of the params and the module's path: a `.jsonValues()`
|
|
174
|
+
// router's entries are not imported for it.
|
|
175
|
+
var val = useResolvedVal(valModule, useReadEnv(), {
|
|
176
|
+
entries: false
|
|
177
|
+
});
|
|
310
178
|
var resolvedParams = params === undefined ? undefined : resolveParams(params);
|
|
311
179
|
// Careful: null means there was an error - undefined means no params
|
|
312
180
|
if (resolvedParams === null) {
|
|
313
181
|
return null;
|
|
314
182
|
}
|
|
315
|
-
|
|
316
|
-
return route;
|
|
183
|
+
return getValRouteUrlFromVal(resolvedParams || {}, "useValRouteUrl", valModule && Internal.getValPath(valModule), valModule && Internal.getSchema(valModule), val);
|
|
317
184
|
}
|
|
318
185
|
|
|
319
186
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { _ as _slicedToArray } from './slicedToArray-
|
|
2
|
+
import { _ as _slicedToArray } from './slicedToArray-5ff32315.esm.js';
|
|
3
3
|
import { VERSION, VAL_APP_PATH, VAL_APP_ID } from '@valbuild/ui';
|
|
4
4
|
import Script from 'next/script';
|
|
5
5
|
import { useState, useRef, useEffect } from 'react';
|
|
6
|
-
import { u as useConfigStorageSave, v as valPrefixedClass, c as cn, a as canvasDarkBg, b as canvasLightBg } from './fallbackColors-
|
|
6
|
+
import { u as useConfigStorageSave, v as valPrefixedClass, c as cn, a as canvasDarkBg, b as canvasLightBg } from './fallbackColors-0d915c59.esm.js';
|
|
7
7
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
8
|
-
import './unsupportedIterableToArray-
|
|
8
|
+
import './unsupportedIterableToArray-f57eb659.esm.js';
|
|
9
9
|
import '@valbuild/shared/client';
|
|
10
10
|
import '@valbuild/core';
|
|
11
11
|
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var slicedToArray = require('./slicedToArray-
|
|
6
|
+
var slicedToArray = require('./slicedToArray-ed812733.cjs.dev.js');
|
|
7
7
|
var ui = require('@valbuild/ui');
|
|
8
8
|
var Script = require('next/script');
|
|
9
9
|
var React = require('react');
|
|
10
|
-
var fallbackColors = require('./fallbackColors-
|
|
10
|
+
var fallbackColors = require('./fallbackColors-38f01ad2.cjs.dev.js');
|
|
11
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
-
require('./unsupportedIterableToArray-
|
|
12
|
+
require('./unsupportedIterableToArray-20a9209f.cjs.dev.js');
|
|
13
13
|
require('@valbuild/shared/client');
|
|
14
14
|
require('@valbuild/core');
|
|
15
15
|
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var slicedToArray = require('./slicedToArray-
|
|
6
|
+
var slicedToArray = require('./slicedToArray-0fc63719.cjs.prod.js');
|
|
7
7
|
var ui = require('@valbuild/ui');
|
|
8
8
|
var Script = require('next/script');
|
|
9
9
|
var React = require('react');
|
|
10
|
-
var fallbackColors = require('./fallbackColors-
|
|
10
|
+
var fallbackColors = require('./fallbackColors-d9a7b81e.cjs.prod.js');
|
|
11
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
-
require('./unsupportedIterableToArray-
|
|
12
|
+
require('./unsupportedIterableToArray-1aadf9fb.cjs.prod.js');
|
|
13
13
|
require('@valbuild/shared/client');
|
|
14
14
|
require('@valbuild/core');
|
|
15
15
|
|
|
@@ -3,20 +3,35 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var objectSpread2 = require('./objectSpread2-58024783.cjs.dev.js');
|
|
7
6
|
var asyncToGenerator = require('./asyncToGenerator-c3823d62.cjs.dev.js');
|
|
8
|
-
var
|
|
7
|
+
var unsupportedIterableToArray = require('./unsupportedIterableToArray-20a9209f.cjs.dev.js');
|
|
8
|
+
var objectSpread2 = require('./objectSpread2-58726b14.cjs.dev.js');
|
|
9
|
+
var slicedToArray = require('./slicedToArray-ed812733.cjs.dev.js');
|
|
9
10
|
var React = require('react');
|
|
10
11
|
var core = require('@valbuild/core');
|
|
11
12
|
var client = require('@valbuild/shared/client');
|
|
12
13
|
var jsxRuntime = require('react/jsx-runtime');
|
|
13
|
-
require('./defineProperty-f90345d7.cjs.dev.js');
|
|
14
|
-
require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
15
14
|
|
|
16
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
17
16
|
|
|
18
17
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
19
18
|
|
|
19
|
+
function _arrayWithoutHoles(r) {
|
|
20
|
+
if (Array.isArray(r)) return unsupportedIterableToArray._arrayLikeToArray(r);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function _iterableToArray(r) {
|
|
24
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function _nonIterableSpread() {
|
|
28
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _toConsumableArray(r) {
|
|
32
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || unsupportedIterableToArray._unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
var DEFAULT_SELECTION = {
|
|
21
36
|
selection: client.DEFAULT_CANVAS_SELECTION,
|
|
22
37
|
selectionSoft: client.DEFAULT_CANVAS_SELECTION_SOFT
|
|
@@ -45,7 +60,9 @@ var RESCAN_INTERVAL_MS = 5000;
|
|
|
45
60
|
function ValCanvasBridge(_ref) {
|
|
46
61
|
var _elementPicking$modif;
|
|
47
62
|
var draftMode = _ref.draftMode,
|
|
48
|
-
isRefreshing = _ref.isRefreshing
|
|
63
|
+
isRefreshing = _ref.isRefreshing,
|
|
64
|
+
holds = _ref.holds,
|
|
65
|
+
holdsVersions = _ref.holdsVersions;
|
|
49
66
|
var _React$useState = React__default["default"].useState(false),
|
|
50
67
|
_React$useState2 = slicedToArray._slicedToArray(_React$useState, 2),
|
|
51
68
|
picking = _React$useState2[0],
|
|
@@ -188,13 +205,17 @@ function ValCanvasBridge(_ref) {
|
|
|
188
205
|
|
|
189
206
|
// Announce the frame, and say whether it is actually showing draft content.
|
|
190
207
|
React__default["default"].useEffect(function () {
|
|
191
|
-
post({
|
|
208
|
+
post(objectSpread2._objectSpread2(objectSpread2._objectSpread2({
|
|
192
209
|
val: client.VAL_CANVAS_MESSAGE,
|
|
193
210
|
type: "ready",
|
|
194
211
|
draftMode: draftMode,
|
|
195
212
|
url: window.location.href
|
|
196
|
-
}
|
|
197
|
-
|
|
213
|
+
}, holds !== undefined && holds.length > 0 ? {
|
|
214
|
+
holds: _toConsumableArray(holds)
|
|
215
|
+
} : {}), holdsVersions !== undefined && Object.keys(holdsVersions).length > 0 ? {
|
|
216
|
+
holdsVersions: holdsVersions
|
|
217
|
+
} : {}));
|
|
218
|
+
}, [post, draftMode, holds, holdsVersions]);
|
|
198
219
|
|
|
199
220
|
/**
|
|
200
221
|
* Re-scan whenever the page could have moved.
|
|
@@ -442,16 +463,17 @@ function ValCanvasBridge(_ref) {
|
|
|
442
463
|
* `ValNextProvider` listens for this event on its own window to make an
|
|
443
464
|
* inline edit visible behind the overlay; the only thing different here
|
|
444
465
|
* is that the edit was made in another window. Re-dispatching rather
|
|
445
|
-
* than reaching into the store keeps one path into the page
|
|
446
|
-
* the
|
|
447
|
-
* server component's own re-read across.
|
|
466
|
+
* than reaching into the store keeps one path into the page. (What
|
|
467
|
+
* re-reads the server's own content is `confirmed`, below.)
|
|
448
468
|
*/
|
|
449
469
|
window.dispatchEvent(new CustomEvent("val-event", {
|
|
450
|
-
detail: {
|
|
470
|
+
detail: objectSpread2._objectSpread2({
|
|
451
471
|
type: "source-update",
|
|
452
472
|
moduleFilePath: message.moduleFilePath,
|
|
453
473
|
source: message.source
|
|
454
|
-
}
|
|
474
|
+
}, message.read !== undefined ? {
|
|
475
|
+
read: message.read
|
|
476
|
+
} : {})
|
|
455
477
|
}));
|
|
456
478
|
return;
|
|
457
479
|
}
|
|
@@ -465,6 +487,17 @@ function ValCanvasBridge(_ref) {
|
|
|
465
487
|
}));
|
|
466
488
|
return;
|
|
467
489
|
}
|
|
490
|
+
if (message.type === "confirmed") {
|
|
491
|
+
// How far the server holds the editor's changes: what the provider
|
|
492
|
+
// re-reads its server-rendered content on. Relayed like the two above.
|
|
493
|
+
window.dispatchEvent(new CustomEvent("val-event", {
|
|
494
|
+
detail: {
|
|
495
|
+
type: "confirmed",
|
|
496
|
+
seq: message.seq
|
|
497
|
+
}
|
|
498
|
+
}));
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
468
501
|
setHighlighted(message.path);
|
|
469
502
|
if (message.path !== null && message.scrollIntoView) {
|
|
470
503
|
var target = findByPath(message.path);
|