@valbuild/next 0.99.1 → 0.101.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.
@@ -1,9 +1,9 @@
1
1
  import 'client-only';
2
+ import { g as getJsonEntryStegaRoot, _ as _typeof, a as isJsonValuesRecordSchema, b as getValRouteUrlFromVal, i as initValRouteFromVal } from '../../dist/routeFromVal-263eec96.esm.js';
2
3
  import { Internal } from '@valbuild/core';
3
4
  import { getModuleIds, stegaEncode } from '@valbuild/react/stega';
4
5
  import React from 'react';
5
6
  import { useValOverlayContext } from '../../dist/ValOverlayContext-3c37e5a7.esm.js';
6
- import { i as initValRouteFromVal, g as getValRouteUrlFromVal } from '../../dist/routeFromVal-8855a5cc.esm.js';
7
7
  import '../../dist/createForOfIteratorHelper-5758a730.esm.js';
8
8
  import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
9
9
  import '../../dist/objectSpread2-60d1bd93.esm.js';
@@ -50,6 +50,133 @@ function useValStega(selector) {
50
50
  }
51
51
  });
52
52
  }
53
+
54
+ /**
55
+ * The module's source as the overlay currently sees it — i.e. WITH the editor's
56
+ * unpublished changes — or undefined when there is no draft view to be had
57
+ * (production, draft mode off, or the overlay has not pushed this module yet).
58
+ *
59
+ * This is what lets the single-entry readers show drafts. They otherwise resolve
60
+ * an entry through its local import thunk, which is the content that was bundled:
61
+ * correct in production, and stale the moment anyone edits in the Studio.
62
+ */
63
+ function useDraftModuleSource(moduleFilePath) {
64
+ var valOverlayContext = useValOverlayContext();
65
+ var store = valOverlayContext.store;
66
+ var moduleIds = React.useMemo(function () {
67
+ return moduleFilePath ? [moduleFilePath] : [];
68
+ }, [moduleFilePath]);
69
+ var moduleMap = React.useSyncExternalStore(store ? store.subscribe(moduleIds) : function () {
70
+ return function () {};
71
+ }, store ? store.getSnapshot(moduleIds) : function () {
72
+ return undefined;
73
+ }, store ? store.getServerSnapshot(moduleIds) : function () {
74
+ return undefined;
75
+ });
76
+ if (!valOverlayContext.draftMode || !moduleFilePath) {
77
+ return undefined;
78
+ }
79
+ return moduleMap === null || moduleMap === void 0 ? void 0 : moduleMap[moduleFilePath];
80
+ }
81
+
82
+ /**
83
+ * What the draft view says about one `.jsonValues()` entry.
84
+ *
85
+ * Mirrors the server-side rule in `fetchValKey`/`fetchValRoute`: a draft view
86
+ * that HAS an answer wins, including the answer "this entry is gone", and the
87
+ * bundled content is used only when there is no draft view.
88
+ */
89
+ function draftJsonEntry(draftSource, key) {
90
+ if (draftSource === undefined || draftSource === null || _typeof(draftSource) !== "object" || Array.isArray(draftSource)) {
91
+ return {
92
+ status: "unavailable"
93
+ };
94
+ }
95
+ var entry = draftSource[key];
96
+ if (entry === undefined) {
97
+ // The module IS in the draft view and this key is not: it was deleted.
98
+ return {
99
+ status: "absent"
100
+ };
101
+ }
102
+ if (Internal.isJson(entry)) {
103
+ // An un-loaded marker: the Studio has not fetched this entry's content, so
104
+ // the draft view cannot answer. (The engine asks for entries that pending
105
+ // patches touch, so this resolves itself for anything actually edited.)
106
+ return {
107
+ status: "unavailable"
108
+ };
109
+ }
110
+ return {
111
+ status: "content",
112
+ content: entry
113
+ };
114
+ }
115
+
116
+ // The (loosened) content type a single `.jsonValues()` entry resolves to.
117
+
118
+ // Module-level cache of in-flight/resolved entry loads, so `React.use` gets a
119
+ // stable promise across renders (keyed by module path + entry key).
120
+ var jsonEntryPromiseCache = new Map();
121
+
122
+ /**
123
+ * Client counterpart to `fetchValKey`: resolves a SINGLE `.jsonValues()` entry
124
+ * by key, loading only that entry's backing `*.val.json` (one dynamic import).
125
+ * Suspends (via `React.use`) until the entry loads, so it must be rendered
126
+ * inside a `<Suspense>` boundary.
127
+ *
128
+ * In draft mode it renders the editor's unpublished content, taken from the
129
+ * overlay; in production — and whenever there is no draft view — it resolves the
130
+ * entry's lazy import thunk from the local module.
131
+ */
132
+ function useValKeyStega(selector, key) {
133
+ var valOverlayContext = useValOverlayContext();
134
+ var moduleFilePath = selector && Internal.getValPath(selector);
135
+ var draftSource = useDraftModuleSource(moduleFilePath || undefined);
136
+ var draft = draftJsonEntry(draftSource, key);
137
+ if (draft.status === "absent") {
138
+ // Deleted in the draft state. Falling back to the bundled entry here would
139
+ // render content the editor has just removed.
140
+ return undefined;
141
+ }
142
+ var content = draft.status === "content" ? draft.content : undefined;
143
+ if (content === undefined) {
144
+ content = readCommittedJsonEntry(selector, key);
145
+ }
146
+ return stegaEncode(content, {
147
+ disabled: !valOverlayContext.draftMode,
148
+ root: getJsonEntryStegaRoot(selector, key)
149
+ });
150
+ }
151
+
152
+ /**
153
+ * The entry's content as bundled: its lazy import thunk, resolved through
154
+ * `React.use` so the caller suspends until it lands.
155
+ *
156
+ * Deliberately not named `use*`: it is called conditionally, which is fine
157
+ * because `React.use` is not a hook, but a `use*` name would read like one.
158
+ */
159
+ function readCommittedJsonEntry(selector, key) {
160
+ var _Internal$getValPath;
161
+ var source = selector && Internal.getSource(selector);
162
+ var marker = source && _typeof(source) === "object" ? source[key] : undefined;
163
+ if (!Internal.isJson(marker)) {
164
+ return undefined;
165
+ }
166
+ var thunk = Internal.getJsonImport(marker);
167
+ if (!thunk) {
168
+ return undefined;
169
+ }
170
+ var cacheKey = "".concat((_Internal$getValPath = Internal.getValPath(selector)) !== null && _Internal$getValPath !== void 0 ? _Internal$getValPath : "", " ").concat(key);
171
+ var promise = jsonEntryPromiseCache.get(cacheKey);
172
+ if (!promise) {
173
+ promise = thunk().then(function (mod) {
174
+ return mod["default"];
175
+ });
176
+ jsonEntryPromiseCache.set(cacheKey, promise);
177
+ }
178
+ return React.use(promise);
179
+ }
53
180
  function resolveParams(params) {
54
181
  if (!params) {
55
182
  return null;
@@ -68,13 +195,45 @@ function resolveParams(params) {
68
195
  return params;
69
196
  }
70
197
  function useValRouteStega(selector, params) {
198
+ var valOverlayContext = useValOverlayContext();
199
+ // Both called unconditionally to keep hook order stable. For a `.jsonValues()`
200
+ // router `val` is unused (we resolve a single entry below instead); for any
201
+ // other router `draftSource` is.
71
202
  var val = useValStega(selector);
203
+ var draftSource = useDraftModuleSource(selector && Internal.getValPath(selector) || undefined);
72
204
  var resolvedParams = resolveParams(params);
73
205
  // Careful: null means there was an error - undefined means no params
74
206
  if (resolvedParams === null) {
75
207
  return null;
76
208
  }
77
- var route = initValRouteFromVal(resolvedParams || {}, "useValRoute", selector && Internal.getValPath(selector), selector && Internal.getSchema(selector), val);
209
+ var path = selector && Internal.getValPath(selector);
210
+ var schema = selector && Internal.getSchema(selector);
211
+ // `.jsonValues()` router: map params → the entry key and load ONLY that
212
+ // entry's backing `*.val.json` (one dynamic import), like `useValKey`.
213
+ if (isJsonValuesRecordSchema(schema)) {
214
+ var source = selector && Internal.getSource(selector);
215
+ var url = getValRouteUrlFromVal(resolvedParams || {}, "useValRoute", path, schema, source);
216
+ if (!url) {
217
+ return null;
218
+ }
219
+ var draft = draftJsonEntry(draftSource, url);
220
+ if (draft.status === "absent") {
221
+ // The draft state says this route is gone — see useValKeyStega.
222
+ return null;
223
+ }
224
+ var content = draft.status === "content" ? draft.content : undefined;
225
+ if (content === undefined) {
226
+ content = readCommittedJsonEntry(selector, url);
227
+ }
228
+ if (content === undefined) {
229
+ return null;
230
+ }
231
+ return stegaEncode(content, {
232
+ disabled: !valOverlayContext.draftMode,
233
+ root: getJsonEntryStegaRoot(selector, url)
234
+ });
235
+ }
236
+ var route = initValRouteFromVal(resolvedParams || {}, "useValRoute", path, schema, val);
78
237
  return route;
79
238
  }
80
239
  function useValRouteUrl(selector, params) {
@@ -92,6 +251,7 @@ function useValRouteUrl(selector, params) {
92
251
  function initValClient(config) {
93
252
  return {
94
253
  useValStega: useValStega,
254
+ useValKeyStega: useValKeyStega,
95
255
  useValRouteStega: useValRouteStega,
96
256
  useValRouteUrl: useValRouteUrl
97
257
  };
@@ -1,13 +1,26 @@
1
- import { GenericSelector, SelectorOf, SelectorSource, SourceObject, ValModule } from "@valbuild/core";
1
+ import { GenericSelector, JsonSource, SelectorOf, SelectorSource, SourceObject, ValModule } from "@valbuild/core";
2
2
  import { StegaOfSource } from "@valbuild/react/stega";
3
3
  import { ValConfig } from "@valbuild/core";
4
4
  export type UseValType<T extends SelectorSource> = SelectorOf<T> extends GenericSelector<infer S> ? StegaOfSource<S> : never;
5
5
  declare function useValStega<T extends SelectorSource>(selector: T): UseValType<T>;
6
- type UseValRouteReturnType<T extends ValModule<GenericSelector<SourceObject>>> = T extends ValModule<infer S> ? S extends SourceObject ? StegaOfSource<NonNullable<S>[string]> | null : never : never;
6
+ type JsonEntryContentOf<T extends ValModule<GenericSelector<SourceObject>>> = T extends ValModule<infer S> ? S extends Record<string, infer V> ? V extends JsonSource<infer C> ? C : never : never : never;
7
+ /**
8
+ * Client counterpart to `fetchValKey`: resolves a SINGLE `.jsonValues()` entry
9
+ * by key, loading only that entry's backing `*.val.json` (one dynamic import).
10
+ * Suspends (via `React.use`) until the entry loads, so it must be rendered
11
+ * inside a `<Suspense>` boundary.
12
+ *
13
+ * In draft mode it renders the editor's unpublished content, taken from the
14
+ * overlay; in production — and whenever there is no draft view — it resolves the
15
+ * entry's lazy import thunk from the local module.
16
+ */
17
+ declare function useValKeyStega<T extends ValModule<GenericSelector<SourceObject>>>(selector: T, key: string): JsonEntryContentOf<T> | undefined;
18
+ type UseValRouteReturnType<T extends ValModule<GenericSelector<SourceObject>>> = T extends ValModule<infer S> ? S extends SourceObject ? NonNullable<S>[string] extends JsonSource<infer C> ? C | null : StegaOfSource<NonNullable<S>[string]> | null : never : never;
7
19
  declare function useValRouteStega<T extends ValModule<GenericSelector<SourceObject>>>(selector: T, params: Record<string, string | string[]> | Promise<Record<string, string | string[]>>): UseValRouteReturnType<T>;
8
20
  declare function useValRouteUrl<T extends ValModule<GenericSelector<SourceObject>>>(selector: T, params?: Record<string, string | string[]> | Promise<Record<string, string | string[]>>): string | null;
9
21
  export declare function initValClient(config: ValConfig): {
10
22
  useValStega: typeof useValStega;
23
+ useValKeyStega: typeof useValKeyStega;
11
24
  useValRouteStega: typeof useValRouteStega;
12
25
  useValRouteUrl: typeof useValRouteUrl;
13
26
  };
@@ -37,6 +37,13 @@ export declare const Internal: {
37
37
  joinModuleFilePathAndModulePath: typeof import("@valbuild/core/dist/declarations/src/module").joinModuleFilePathAndModulePath;
38
38
  nextAppRouter: import("@valbuild/core").ValRouter;
39
39
  externalPageRouter: import("@valbuild/core").ValRouter;
40
+ color: {
41
+ parseColor: typeof import("@valbuild/core/dist/declarations/src/schema/colorFormat").parseColor;
42
+ formatColor: typeof import("@valbuild/core/dist/declarations/src/schema/colorFormat").formatColor;
43
+ convertColor: typeof import("@valbuild/core/dist/declarations/src/schema/colorFormat").convertColor;
44
+ detectColorFormat: typeof import("@valbuild/core/dist/declarations/src/schema/colorFormat").detectColorFormat;
45
+ colorToHex: typeof import("@valbuild/core/dist/declarations/src/schema/colorFormat").colorToHex;
46
+ };
40
47
  remote: {
41
48
  createRemoteRef: typeof import("@valbuild/core/dist/declarations/src/source/remote").createRemoteRef;
42
49
  getValidationBasis: typeof import("@valbuild/core/dist/declarations/src/remote/validationBasis").getValidationBasis;
@@ -48,6 +55,9 @@ export declare const Internal: {
48
55
  validate: (val: import("@valbuild/core").ValModule<import("@valbuild/core").SelectorSource>, path: import("@valbuild/core").SourcePath, src: unknown) => import("@valbuild/core").ValidationErrors | undefined;
49
56
  isVal: typeof import("@valbuild/core/dist/declarations/src/val").isVal;
50
57
  isFile: typeof import("@valbuild/core/dist/declarations/src/source/file").isFile;
58
+ isJson: typeof import("@valbuild/core/dist/declarations/src/source/json").isJson;
59
+ getJsonImport: typeof import("@valbuild/core/dist/declarations/src/source/json").getJsonImport;
60
+ resolveJsonValues: typeof import("@valbuild/core/dist/declarations/src/source/json").resolveJsonValues;
51
61
  createValPathOfItem: typeof import("@valbuild/core/dist/declarations/src/selector/SelectorProxy").createValPathOfItem;
52
62
  getSHA256Hash: (bits: Uint8Array) => string;
53
63
  initSchema: typeof import("@valbuild/core/dist/declarations/src/initSchema").initSchema;
@@ -1,5 +1,5 @@
1
1
  import { type StegaOfSource } from "@valbuild/react/stega";
2
- import { SelectorSource, SelectorOf, GenericSelector, ValConfig, ValModules, ValModule, SourceObject } from "@valbuild/core";
2
+ import { SelectorSource, SelectorOf, GenericSelector, ValConfig, ValModules, ValModule, SourceObject, JsonSource } from "@valbuild/core";
3
3
  import { cookies, draftMode, headers } from "next/headers";
4
4
  import { ValServer } from "@valbuild/server";
5
5
  declare const initFetchValStega: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
@@ -10,7 +10,7 @@ declare const initFetchValStega: (config: ValConfig, valApiEndpoints: string, va
10
10
  value: string;
11
11
  } | undefined;
12
12
  }>) => <T extends SelectorSource>(selector: T) => Promise<SelectorOf<T> extends GenericSelector<infer S> ? StegaOfSource<S> : never>;
13
- type FetchValRouteReturnType<T extends ValModule<GenericSelector<SourceObject>>> = T extends ValModule<infer S> ? S extends SourceObject ? StegaOfSource<NonNullable<S>[string]> | null : never : never;
13
+ type FetchValRouteReturnType<T extends ValModule<GenericSelector<SourceObject>>> = T extends ValModule<infer S> ? S extends SourceObject ? NonNullable<S>[string] extends JsonSource<infer C> ? C | null : StegaOfSource<NonNullable<S>[string]> | null : never : never;
14
14
  declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
15
15
  get(name: string): string | null;
16
16
  }>, getCookies: () => Promise<{
@@ -19,6 +19,64 @@ declare const initFetchValRouteStega: (config: ValConfig, valApiEndpoints: strin
19
19
  value: string;
20
20
  } | undefined;
21
21
  }>) => <T extends ValModule<GenericSelector<SourceObject>>>(selector: T, params: Promise<Record<string, string | string[]>> | Record<string, string | string[]> | unknown) => Promise<FetchValRouteReturnType<T>>;
22
+ /**
23
+ * Loads a single `.jsonValues()` entry's DRAFT content via the in-process
24
+ * `/json` endpoint (which replays pending patches). Returns `undefined` when the
25
+ * entry has no draft content to serve — the caller then falls back to the
26
+ * locally-bundled committed content.
27
+ */
28
+ /**
29
+ * What the draft state says about an entry.
30
+ *
31
+ * The three cases have to stay distinct: `absent` is an ANSWER — the entry is not
32
+ * there in the draft state, e.g. a pending patch removed it — while `unavailable`
33
+ * means we could not ask. Collapsing them into `undefined` is what made a
34
+ * draft-deleted entry keep rendering its committed content: the caller could not
35
+ * tell "it is gone" from "ask the committed source instead".
36
+ */
37
+ /**
38
+ * The slice of `ValServer` the single-entry readers actually use. Narrower than
39
+ * `ValServer` on purpose: it says what the dependency IS, and it lets a test
40
+ * drive these readers with a one-route fake instead of casting a partial object
41
+ * to the whole server type.
42
+ */
43
+ export type JsonEntryValServer = Pick<ValServer, "/json">;
44
+ export type DraftJsonEntry = {
45
+ status: "content";
46
+ content: unknown;
47
+ } | {
48
+ status: "absent";
49
+ } | {
50
+ status: "unavailable";
51
+ };
52
+ /**
53
+ * Picks the content a draft-aware single-entry read should render.
54
+ *
55
+ * The rule the two callers share: the draft state WINS when it has an answer —
56
+ * including the answer "this entry is gone" — and the committed content is used
57
+ * only when there is no draft answer to be had (Val disabled, or we could not
58
+ * ask). Returning `undefined` means "render nothing"; both callers turn that into
59
+ * a null/undefined result.
60
+ */
61
+ export declare function resolveDraftOrCommittedEntry(draft: DraftJsonEntry, loadCommitted: () => Promise<unknown | undefined>): Promise<unknown | undefined>;
62
+ type JsonEntryContentOf<T extends ValModule<GenericSelector<SourceObject>>> = T extends ValModule<infer S> ? S extends Record<string, infer V> ? V extends JsonSource<infer C> ? C : never : never : never;
63
+ /**
64
+ * Resolves ONE `.jsonValues()` entry by key, loading only that entry instead of
65
+ * the whole record — the runtime-scaling counterpart to the eager `fetchVal`.
66
+ *
67
+ * Production (Val disabled): resolves the entry's lazy import thunk from the
68
+ * locally-bundled module. One dynamic import, no server round-trip.
69
+ *
70
+ * Enabled (draft mode): reads the entry through `/json`, which replays pending
71
+ * patches, so uncommitted Studio edits show up. Falls back to the local thunk if
72
+ * the draft read yields nothing.
73
+ */
74
+ export declare const initFetchValKeyStega: (valServerPromise: Promise<JsonEntryValServer>, isEnabled: () => Promise<boolean>, getCookies: () => Promise<{
75
+ get(name: string): {
76
+ name: string;
77
+ value: string;
78
+ } | undefined;
79
+ }>) => <T extends ValModule<GenericSelector<SourceObject>>>(selector: T, key: string) => Promise<JsonEntryContentOf<T> | undefined>;
22
80
  declare const initFetchValRouteUrl: (config: ValConfig, valApiEndpoints: string, valServerPromise: Promise<ValServer>, isEnabled: () => Promise<boolean>, getHeaders: () => Promise<{
23
81
  get(name: string): string | null;
24
82
  }>, getCookies: () => Promise<{
@@ -34,6 +92,7 @@ type ValNextRscConfig = {
34
92
  };
35
93
  export declare function initValRsc(config: ValConfig, valModules: ValModules, rscNextConfig: ValNextRscConfig): {
36
94
  fetchValStega: ReturnType<typeof initFetchValStega>;
95
+ fetchValKeyStega: ReturnType<typeof initFetchValKeyStega>;
37
96
  fetchValRouteStega: ReturnType<typeof initFetchValRouteStega>;
38
97
  fetchValRouteUrl: ReturnType<typeof initFetchValRouteUrl>;
39
98
  };
@@ -14,6 +14,46 @@ function _typeof(o) {
14
14
  }, _typeof(o);
15
15
  }
16
16
 
17
+ /**
18
+ * True when the module's schema is a `.jsonValues()` record/router — i.e. each
19
+ * entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
20
+ * route helpers to load ONLY the matched entry instead of the whole record.
21
+ */
22
+ function isJsonValuesRecordSchema(schema) {
23
+ return schema instanceof RecordSchema && schema["executeSerialize"]().jsonValues === true;
24
+ }
25
+
26
+ /**
27
+ * Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
28
+ * strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
29
+ * identity transform (the content carries no selector path/schema).
30
+ *
31
+ * Yields e.g. `/app/support/[slug]/page.val.ts?p="/support/faq"`, so a `title`
32
+ * field is tagged `…?p="/support/faq"."title"` — the shape the Studio's
33
+ * `findUnloadedJsonEntryKey` walks, so click-to-edit + lazy load line up.
34
+ */
35
+ function getJsonEntryStegaRoot(
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ selector, key
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ ) {
40
+ var modulePath = selector && Internal.getValPath(selector);
41
+ if (!modulePath) {
42
+ return undefined;
43
+ }
44
+ var schema = selector && Internal.getSchema(selector);
45
+ if (!(schema instanceof RecordSchema)) {
46
+ return undefined;
47
+ }
48
+ var path = Internal.createValPathOfItem(modulePath, key);
49
+ if (!path) {
50
+ return undefined;
51
+ }
52
+ return {
53
+ path: path,
54
+ schema: schema["executeSerialize"]().item
55
+ };
56
+ }
17
57
  function getValRouteUrlFromVal(resolvedParams, methodName,
18
58
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
59
  path,
@@ -153,4 +193,4 @@ val) {
153
193
  return actualRoute;
154
194
  }
155
195
 
156
- export { getValRouteUrlFromVal as g, initValRouteFromVal as i };
196
+ export { _typeof as _, isJsonValuesRecordSchema as a, getValRouteUrlFromVal as b, getJsonEntryStegaRoot as g, initValRouteFromVal as i };
@@ -16,6 +16,46 @@ function _typeof(o) {
16
16
  }, _typeof(o);
17
17
  }
18
18
 
19
+ /**
20
+ * True when the module's schema is a `.jsonValues()` record/router — i.e. each
21
+ * entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
22
+ * route helpers to load ONLY the matched entry instead of the whole record.
23
+ */
24
+ function isJsonValuesRecordSchema(schema) {
25
+ return schema instanceof core.RecordSchema && schema["executeSerialize"]().jsonValues === true;
26
+ }
27
+
28
+ /**
29
+ * Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
30
+ * strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
31
+ * identity transform (the content carries no selector path/schema).
32
+ *
33
+ * Yields e.g. `/app/support/[slug]/page.val.ts?p="/support/faq"`, so a `title`
34
+ * field is tagged `…?p="/support/faq"."title"` — the shape the Studio's
35
+ * `findUnloadedJsonEntryKey` walks, so click-to-edit + lazy load line up.
36
+ */
37
+ function getJsonEntryStegaRoot(
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ selector, key
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ ) {
42
+ var modulePath = selector && core.Internal.getValPath(selector);
43
+ if (!modulePath) {
44
+ return undefined;
45
+ }
46
+ var schema = selector && core.Internal.getSchema(selector);
47
+ if (!(schema instanceof core.RecordSchema)) {
48
+ return undefined;
49
+ }
50
+ var path = core.Internal.createValPathOfItem(modulePath, key);
51
+ if (!path) {
52
+ return undefined;
53
+ }
54
+ return {
55
+ path: path,
56
+ schema: schema["executeSerialize"]().item
57
+ };
58
+ }
19
59
  function getValRouteUrlFromVal(resolvedParams, methodName,
20
60
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
61
  path,
@@ -155,5 +195,8 @@ val) {
155
195
  return actualRoute;
156
196
  }
157
197
 
198
+ exports._typeof = _typeof;
199
+ exports.getJsonEntryStegaRoot = getJsonEntryStegaRoot;
158
200
  exports.getValRouteUrlFromVal = getValRouteUrlFromVal;
159
201
  exports.initValRouteFromVal = initValRouteFromVal;
202
+ exports.isJsonValuesRecordSchema = isJsonValuesRecordSchema;
@@ -16,6 +16,46 @@ function _typeof(o) {
16
16
  }, _typeof(o);
17
17
  }
18
18
 
19
+ /**
20
+ * True when the module's schema is a `.jsonValues()` record/router — i.e. each
21
+ * entry value is a lazily-loaded `c.json(() => import(...))` marker. Used by the
22
+ * route helpers to load ONLY the matched entry instead of the whole record.
23
+ */
24
+ function isJsonValuesRecordSchema(schema) {
25
+ return schema instanceof core.RecordSchema && schema["executeSerialize"]().jsonValues === true;
26
+ }
27
+
28
+ /**
29
+ * Builds the `stegaEncode` `root` seed for a single `.jsonValues()` entry, so its
30
+ * strings get edit tags. Without a seed, `stegaEncode` on raw entry content is an
31
+ * identity transform (the content carries no selector path/schema).
32
+ *
33
+ * Yields e.g. `/app/support/[slug]/page.val.ts?p="/support/faq"`, so a `title`
34
+ * field is tagged `…?p="/support/faq"."title"` — the shape the Studio's
35
+ * `findUnloadedJsonEntryKey` walks, so click-to-edit + lazy load line up.
36
+ */
37
+ function getJsonEntryStegaRoot(
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ selector, key
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ ) {
42
+ var modulePath = selector && core.Internal.getValPath(selector);
43
+ if (!modulePath) {
44
+ return undefined;
45
+ }
46
+ var schema = selector && core.Internal.getSchema(selector);
47
+ if (!(schema instanceof core.RecordSchema)) {
48
+ return undefined;
49
+ }
50
+ var path = core.Internal.createValPathOfItem(modulePath, key);
51
+ if (!path) {
52
+ return undefined;
53
+ }
54
+ return {
55
+ path: path,
56
+ schema: schema["executeSerialize"]().item
57
+ };
58
+ }
19
59
  function getValRouteUrlFromVal(resolvedParams, methodName,
20
60
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
61
  path,
@@ -155,5 +195,8 @@ val) {
155
195
  return actualRoute;
156
196
  }
157
197
 
198
+ exports._typeof = _typeof;
199
+ exports.getJsonEntryStegaRoot = getJsonEntryStegaRoot;
158
200
  exports.getValRouteUrlFromVal = getValRouteUrlFromVal;
159
201
  exports.initValRouteFromVal = initValRouteFromVal;
202
+ exports.isJsonValuesRecordSchema = isJsonValuesRecordSchema;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "next",
13
13
  "react"
14
14
  ],
15
- "version": "0.99.1",
15
+ "version": "0.101.0",
16
16
  "main": "dist/valbuild-next.cjs.js",
17
17
  "module": "dist/valbuild-next.esm.js",
18
18
  "exports": {
@@ -47,12 +47,12 @@
47
47
  "dependencies": {
48
48
  "client-only": "^0.0.1",
49
49
  "server-only": "^0.0.1",
50
- "@valbuild/core": "0.99.1",
51
- "@valbuild/language-server": "0.99.1",
52
- "@valbuild/react": "0.99.1",
53
- "@valbuild/server": "0.99.1",
54
- "@valbuild/shared": "0.99.1",
55
- "@valbuild/ui": "0.99.1"
50
+ "@valbuild/core": "0.101.0",
51
+ "@valbuild/language-server": "0.101.0",
52
+ "@valbuild/react": "0.101.0",
53
+ "@valbuild/server": "0.101.0",
54
+ "@valbuild/shared": "0.101.0",
55
+ "@valbuild/ui": "0.101.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@testing-library/react": "^14.0.0",