@valbuild/core 0.148.0 → 0.148.7

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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @valbuild/core
2
2
 
3
+ ## 0.148.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [#906](https://github.com/valbuild/val/pull/906) [`fb2eed8`](https://github.com/valbuild/val/commit/fb2eed8b51092cc2ad5c812bdf88b528913c824a) Thanks [@freekh](https://github.com/freekh)! - `val.attrs(post, "author")` tags an element with one field of what it shows. Use it for a value Val never encodes, like an `s.keyOf` key, a date or a colour. A byline that shows the author a post points at can carry the post's `author` field, so clicking it in the Studio opens the choice of author.
8
+
9
+ On a phone, a tour step about Pages, Media, Data or Settings points at the menu button, which is where they are when the rail is not drawn.
10
+
11
+ ## 0.148.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [#889](https://github.com/valbuild/val/pull/889) [`dc7c8cc`](https://github.com/valbuild/val/commit/dc7c8ccd82f643e662d00225fabec411b5d39e3a) Thanks [@freekh](https://github.com/freekh)! - Val is quieter in your app's console. Errors and warnings you can act on still
16
+ print, now prefixed with `[val]` so you can filter them. Val's own debug
17
+ output, which used to reach your terminal and browser console, is now off by
18
+ default. That includes the `Invalid JWT` line that printed on every request
19
+ with an expired session cookie, the "verifying draft mode" and polling notices,
20
+ and the Studio's sync and WebSocket chatter.
21
+
22
+ To turn the debug output back on, for example when reporting a bug:
23
+
24
+ - on the server, set `VAL_DEBUG=1`
25
+ - in the browser, run `localStorage.setItem("val:debug", "1")` in the console.
26
+ It takes effect immediately, with no reload. Remove the key to turn it off
27
+ again.
28
+
3
29
  ## 0.148.0
4
30
 
5
31
  ### Patch Changes
@@ -35,7 +35,7 @@ import { getSource, isValModule, splitModulePath, splitModuleFilePath, resolvePa
35
35
  declare const ModuleFilePathSep = "?p=";
36
36
  export { ModuleFilePathSep };
37
37
  import { SelectorSource, getSchema } from "./selector/index.js";
38
- import { ModulePath, SourcePath, getValPath, isVal } from "./val/index.js";
38
+ import { ModulePath, SourcePath, getValPath, isVal, setValPath } from "./val/index.js";
39
39
  import { createValPathOfItem } from "./selector/SelectorProxy.js";
40
40
  import { Operation } from "./patch/index.js";
41
41
  import { initSchema } from "./initSchema.js";
@@ -105,6 +105,7 @@ export { getSourcePathFromRoute, isPageRouter, routePatternOf, } from "./getSour
105
105
  export { describeSchemeRejection, isCheckableScheme, rejectScheme, schemeOf, UNSAFE_URL_SCHEMES, } from "./externalUrlSchemes.js";
106
106
  export type { ExternalUrlSchemePolicy, SchemeRejection, } from "./externalUrlSchemes.js";
107
107
  import { describeSchemeRejection, isCheckableScheme, rejectScheme, schemeOf } from "./externalUrlSchemes.js";
108
+ import { isDebugEnabled } from "./log.js";
108
109
  export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
109
110
  export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
110
111
  export declare const DEFAULT_CONTENT_HOST = "https://content.val.build";
@@ -138,6 +139,15 @@ export declare const DEFAULT_APP_HOST = "https://admin.val.build";
138
139
  */
139
140
  export declare const DEFAULT_STATIC_HOST = "https://content.val.build/v1/static";
140
141
  declare const Internal: {
142
+ /** Val's console output. See `log.ts` for which levels print, and when. */
143
+ log: {
144
+ error(...args: unknown[]): void;
145
+ warn(...args: unknown[]): void;
146
+ info(...args: unknown[]): void;
147
+ debug(...args: unknown[]): void;
148
+ };
149
+ isDebugEnabled: typeof isDebugEnabled;
150
+ VAL_DEBUG_STORAGE_KEY: string;
141
151
  VERSION: {
142
152
  core: string;
143
153
  };
@@ -163,6 +173,7 @@ declare const Internal: {
163
173
  };
164
174
  getSchema: typeof getSchema;
165
175
  getValPath: typeof getValPath;
176
+ setValPath: typeof setValPath;
166
177
  getSource: typeof getSource;
167
178
  isValModule: typeof isValModule;
168
179
  resolvePath: typeof resolvePath;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Val's console output, and the one place that decides what reaches it.
3
+ *
4
+ * Val runs inside someone else's app: the server in their dev server and their
5
+ * production logs, the Studio in their browser tab. Everything Val prints lands
6
+ * in a console that belongs to a developer who did not write the code printing
7
+ * it, so the levels are split by who the line is FOR:
8
+ *
9
+ * - `error` and `warn` are for that developer -- something broke, or something
10
+ * they can fix -- and always print.
11
+ * - `info` and `debug` are for whoever is debugging Val, and print only when
12
+ * asked for: `VAL_DEBUG=1` in the environment of a server, or
13
+ * `localStorage.setItem("val:debug", "1")` in a browser. Both are read on
14
+ * every call, so turning it on in a live tab needs no reload.
15
+ *
16
+ * In Node `console.debug` IS `console.log`, so a bare `console.debug` is not
17
+ * quiet on a server: it went to the developer's terminal on every request.
18
+ * That is why `no-console` is on for the packages that run in a host app, and
19
+ * this file is the exemption.
20
+ *
21
+ * Every line gets a `[val]` prefix, so a developer can filter Val out (or in).
22
+ * Arguments are otherwise passed through as they are, so an `Error` still
23
+ * prints with its stack.
24
+ */
25
+ /** The localStorage key that turns `debug` and `info` on in a browser. */
26
+ export declare const VAL_DEBUG_STORAGE_KEY = "val:debug";
27
+ export declare function isDebugEnabled(): boolean;
28
+ export declare const log: {
29
+ error(...args: unknown[]): void;
30
+ warn(...args: unknown[]): void;
31
+ info(...args: unknown[]): void;
32
+ debug(...args: unknown[]): void;
33
+ };
@@ -60,4 +60,13 @@ export type ParentPatchId = string & {
60
60
  [brand]: "ParentPatchId";
61
61
  };
62
62
  export declare function getValPath(valOrSelector: Val<Json> | Selector<Source>): SourcePath | undefined;
63
+ /**
64
+ * Gives an object Val read the path it was read from, where `getValPath`
65
+ * finds it: the readers' (`stegaEncode`'s) half of `getValPath`, for objects,
66
+ * which have no text to carry a path in.
67
+ *
68
+ * Not enumerable, and a symbol: `Object.keys`, `JSON.stringify` and every walk
69
+ * that reads content as data still see only the content.
70
+ */
71
+ export declare function setValPath(target: object, path: SourcePath): void;
63
72
  export {};
@@ -914,6 +914,22 @@ function getValPath(valOrSelector) {
914
914
  return valOrSelector[Path];
915
915
  }
916
916
 
917
+ /**
918
+ * Gives an object Val read the path it was read from, where `getValPath`
919
+ * finds it: the readers' (`stegaEncode`'s) half of `getValPath`, for objects,
920
+ * which have no text to carry a path in.
921
+ *
922
+ * Not enumerable, and a symbol: `Object.keys`, `JSON.stringify` and every walk
923
+ * that reads content as data still see only the content.
924
+ */
925
+ function setValPath(target, path) {
926
+ Object.defineProperty(target, Path, {
927
+ value: path,
928
+ enumerable: false,
929
+ configurable: true
930
+ });
931
+ }
932
+
917
933
  function createValPathOfItem(
918
934
  /**
919
935
  * `ModuleFilePath` is accepted because the no-separator branch below is
@@ -2762,6 +2778,122 @@ var discriminatedUnion = function discriminatedUnion(key) {
2762
2778
  return new DiscriminatedUnionSchema(key, objects);
2763
2779
  };
2764
2780
 
2781
+ function _toArray(r) {
2782
+ return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest();
2783
+ }
2784
+
2785
+ /**
2786
+ * Val's console output, and the one place that decides what reaches it.
2787
+ *
2788
+ * Val runs inside someone else's app: the server in their dev server and their
2789
+ * production logs, the Studio in their browser tab. Everything Val prints lands
2790
+ * in a console that belongs to a developer who did not write the code printing
2791
+ * it, so the levels are split by who the line is FOR:
2792
+ *
2793
+ * - `error` and `warn` are for that developer -- something broke, or something
2794
+ * they can fix -- and always print.
2795
+ * - `info` and `debug` are for whoever is debugging Val, and print only when
2796
+ * asked for: `VAL_DEBUG=1` in the environment of a server, or
2797
+ * `localStorage.setItem("val:debug", "1")` in a browser. Both are read on
2798
+ * every call, so turning it on in a live tab needs no reload.
2799
+ *
2800
+ * In Node `console.debug` IS `console.log`, so a bare `console.debug` is not
2801
+ * quiet on a server: it went to the developer's terminal on every request.
2802
+ * That is why `no-console` is on for the packages that run in a host app, and
2803
+ * this file is the exemption.
2804
+ *
2805
+ * Every line gets a `[val]` prefix, so a developer can filter Val out (or in).
2806
+ * Arguments are otherwise passed through as they are, so an `Error` still
2807
+ * prints with its stack.
2808
+ */
2809
+
2810
+ var PREFIX = "[val]";
2811
+
2812
+ /** The localStorage key that turns `debug` and `info` on in a browser. */
2813
+ var VAL_DEBUG_STORAGE_KEY = "val:debug";
2814
+ function isOn(value) {
2815
+ return value !== undefined && value !== null && value !== "" && value !== "0" && value !== "false";
2816
+ }
2817
+ function fromEnv() {
2818
+ var _process$env;
2819
+ // `typeof` first: a browser bundle may have no `process` at all.
2820
+ if (typeof process === "undefined") {
2821
+ return undefined;
2822
+ }
2823
+ return (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.VAL_DEBUG;
2824
+ }
2825
+ function fromLocalStorage() {
2826
+ // Not in Node, even where it has a `localStorage`: from Node 25 merely
2827
+ // touching it without `--localstorage-file` prints a warning of its own.
2828
+ if (!("window" in globalThis)) {
2829
+ return undefined;
2830
+ }
2831
+ try {
2832
+ var storage = Reflect.get(globalThis, "localStorage");
2833
+ if (_typeof(storage) === "object" && storage !== null && "getItem" in storage && typeof storage.getItem === "function") {
2834
+ var value = storage.getItem(VAL_DEBUG_STORAGE_KEY);
2835
+ return typeof value === "string" ? value : null;
2836
+ }
2837
+ } catch (_unused) {
2838
+ // A sandboxed frame or blocked site data throws on access.
2839
+ }
2840
+ return undefined;
2841
+ }
2842
+ function isDebugEnabled() {
2843
+ return isOn(fromEnv()) || isOn(fromLocalStorage());
2844
+ }
2845
+ function withPrefix(args) {
2846
+ var _args = _toArray(args),
2847
+ first = _args[0],
2848
+ rest = _arrayLikeToArray(_args).slice(1);
2849
+ if (typeof first === "string") {
2850
+ if (/^\[val\]/i.test(first)) {
2851
+ return args;
2852
+ }
2853
+ return ["".concat(PREFIX, " ").concat(first)].concat(_toConsumableArray(rest));
2854
+ }
2855
+ return [PREFIX].concat(_toConsumableArray(args));
2856
+ }
2857
+
2858
+ /*
2859
+ * `console` is looked up on every call rather than captured, so a test that
2860
+ * spies on `console.warn` after this module loaded still sees the call.
2861
+ */
2862
+ var log = {
2863
+ error: function error() {
2864
+ var _console;
2865
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2866
+ args[_key] = arguments[_key];
2867
+ }
2868
+ (_console = console).error.apply(_console, _toConsumableArray(withPrefix(args)));
2869
+ },
2870
+ warn: function warn() {
2871
+ var _console2;
2872
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2873
+ args[_key2] = arguments[_key2];
2874
+ }
2875
+ (_console2 = console).warn.apply(_console2, _toConsumableArray(withPrefix(args)));
2876
+ },
2877
+ info: function info() {
2878
+ if (isDebugEnabled()) {
2879
+ var _console3;
2880
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
2881
+ args[_key3] = arguments[_key3];
2882
+ }
2883
+ (_console3 = console).info.apply(_console3, _toConsumableArray(withPrefix(args)));
2884
+ }
2885
+ },
2886
+ debug: function debug() {
2887
+ if (isDebugEnabled()) {
2888
+ var _console4;
2889
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2890
+ args[_key4] = arguments[_key4];
2891
+ }
2892
+ (_console4 = console).debug.apply(_console4, _toConsumableArray(withPrefix(args)));
2893
+ }
2894
+ }
2895
+ };
2896
+
2765
2897
  function _objectWithoutPropertiesLoose(r, e) {
2766
2898
  if (null == r) return {};
2767
2899
  var t = {};
@@ -5040,7 +5172,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
5040
5172
  return hrefSchema["executeValidate"](hrefPath, node.href);
5041
5173
  } else {
5042
5174
  var exhaustiveCheck = hrefSchema;
5043
- console.error("Exhaustive check failed in RichText (anchor href validation)", exhaustiveCheck);
5175
+ log.error("Exhaustive check failed in RichText (anchor href validation)", exhaustiveCheck);
5044
5176
  return false;
5045
5177
  }
5046
5178
  };
@@ -15291,7 +15423,7 @@ function collectObjectRecursive(item, collector) {
15291
15423
  }
15292
15424
  return;
15293
15425
  } else {
15294
- console.warn("Unknown type encountered when hashing object", _typeof(item), item);
15426
+ log.warn("Unknown type encountered when hashing object", _typeof(item), item);
15295
15427
  }
15296
15428
  }
15297
15429
 
@@ -16803,7 +16935,7 @@ function isInlineRender(container) {
16803
16935
 
16804
16936
  var corePackageJson = {
16805
16937
  name: "@valbuild/core",
16806
- version: "0.148.0",
16938
+ version: "0.148.7",
16807
16939
  "private": false,
16808
16940
  description: "Val - supercharged hard-coded content",
16809
16941
  repository: {
@@ -16890,6 +17022,10 @@ var DEFAULT_APP_HOST = "https://admin.val.build";
16890
17022
  */
16891
17023
  var DEFAULT_STATIC_HOST = "https://content.val.build/v1/static";
16892
17024
  var Internal = {
17025
+ /** Val's console output. See `log.ts` for which levels print, and when. */
17026
+ log: log,
17027
+ isDebugEnabled: isDebugEnabled,
17028
+ VAL_DEBUG_STORAGE_KEY: VAL_DEBUG_STORAGE_KEY,
16893
17029
  VERSION: {
16894
17030
  core: corePackageJson.version
16895
17031
  },
@@ -16918,6 +17054,7 @@ var Internal = {
16918
17054
  },
16919
17055
  getSchema: getSchema,
16920
17056
  getValPath: getValPath,
17057
+ setValPath: setValPath,
16921
17058
  getSource: getSource,
16922
17059
  isValModule: isValModule,
16923
17060
  resolvePath: resolvePath,
@@ -916,6 +916,22 @@ function getValPath(valOrSelector) {
916
916
  return valOrSelector[Path];
917
917
  }
918
918
 
919
+ /**
920
+ * Gives an object Val read the path it was read from, where `getValPath`
921
+ * finds it: the readers' (`stegaEncode`'s) half of `getValPath`, for objects,
922
+ * which have no text to carry a path in.
923
+ *
924
+ * Not enumerable, and a symbol: `Object.keys`, `JSON.stringify` and every walk
925
+ * that reads content as data still see only the content.
926
+ */
927
+ function setValPath(target, path) {
928
+ Object.defineProperty(target, Path, {
929
+ value: path,
930
+ enumerable: false,
931
+ configurable: true
932
+ });
933
+ }
934
+
919
935
  function createValPathOfItem(
920
936
  /**
921
937
  * `ModuleFilePath` is accepted because the no-separator branch below is
@@ -2764,6 +2780,122 @@ var discriminatedUnion = function discriminatedUnion(key) {
2764
2780
  return new DiscriminatedUnionSchema(key, objects);
2765
2781
  };
2766
2782
 
2783
+ function _toArray(r) {
2784
+ return _arrayWithHoles(r) || _iterableToArray(r) || result._unsupportedIterableToArray(r) || _nonIterableRest();
2785
+ }
2786
+
2787
+ /**
2788
+ * Val's console output, and the one place that decides what reaches it.
2789
+ *
2790
+ * Val runs inside someone else's app: the server in their dev server and their
2791
+ * production logs, the Studio in their browser tab. Everything Val prints lands
2792
+ * in a console that belongs to a developer who did not write the code printing
2793
+ * it, so the levels are split by who the line is FOR:
2794
+ *
2795
+ * - `error` and `warn` are for that developer -- something broke, or something
2796
+ * they can fix -- and always print.
2797
+ * - `info` and `debug` are for whoever is debugging Val, and print only when
2798
+ * asked for: `VAL_DEBUG=1` in the environment of a server, or
2799
+ * `localStorage.setItem("val:debug", "1")` in a browser. Both are read on
2800
+ * every call, so turning it on in a live tab needs no reload.
2801
+ *
2802
+ * In Node `console.debug` IS `console.log`, so a bare `console.debug` is not
2803
+ * quiet on a server: it went to the developer's terminal on every request.
2804
+ * That is why `no-console` is on for the packages that run in a host app, and
2805
+ * this file is the exemption.
2806
+ *
2807
+ * Every line gets a `[val]` prefix, so a developer can filter Val out (or in).
2808
+ * Arguments are otherwise passed through as they are, so an `Error` still
2809
+ * prints with its stack.
2810
+ */
2811
+
2812
+ var PREFIX = "[val]";
2813
+
2814
+ /** The localStorage key that turns `debug` and `info` on in a browser. */
2815
+ var VAL_DEBUG_STORAGE_KEY = "val:debug";
2816
+ function isOn(value) {
2817
+ return value !== undefined && value !== null && value !== "" && value !== "0" && value !== "false";
2818
+ }
2819
+ function fromEnv() {
2820
+ var _process$env;
2821
+ // `typeof` first: a browser bundle may have no `process` at all.
2822
+ if (typeof process === "undefined") {
2823
+ return undefined;
2824
+ }
2825
+ return (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.VAL_DEBUG;
2826
+ }
2827
+ function fromLocalStorage() {
2828
+ // Not in Node, even where it has a `localStorage`: from Node 25 merely
2829
+ // touching it without `--localstorage-file` prints a warning of its own.
2830
+ if (!("window" in globalThis)) {
2831
+ return undefined;
2832
+ }
2833
+ try {
2834
+ var storage = Reflect.get(globalThis, "localStorage");
2835
+ if (_typeof(storage) === "object" && storage !== null && "getItem" in storage && typeof storage.getItem === "function") {
2836
+ var value = storage.getItem(VAL_DEBUG_STORAGE_KEY);
2837
+ return typeof value === "string" ? value : null;
2838
+ }
2839
+ } catch (_unused) {
2840
+ // A sandboxed frame or blocked site data throws on access.
2841
+ }
2842
+ return undefined;
2843
+ }
2844
+ function isDebugEnabled() {
2845
+ return isOn(fromEnv()) || isOn(fromLocalStorage());
2846
+ }
2847
+ function withPrefix(args) {
2848
+ var _args = _toArray(args),
2849
+ first = _args[0],
2850
+ rest = result._arrayLikeToArray(_args).slice(1);
2851
+ if (typeof first === "string") {
2852
+ if (/^\[val\]/i.test(first)) {
2853
+ return args;
2854
+ }
2855
+ return ["".concat(PREFIX, " ").concat(first)].concat(_toConsumableArray(rest));
2856
+ }
2857
+ return [PREFIX].concat(_toConsumableArray(args));
2858
+ }
2859
+
2860
+ /*
2861
+ * `console` is looked up on every call rather than captured, so a test that
2862
+ * spies on `console.warn` after this module loaded still sees the call.
2863
+ */
2864
+ var log = {
2865
+ error: function error() {
2866
+ var _console;
2867
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2868
+ args[_key] = arguments[_key];
2869
+ }
2870
+ (_console = console).error.apply(_console, _toConsumableArray(withPrefix(args)));
2871
+ },
2872
+ warn: function warn() {
2873
+ var _console2;
2874
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2875
+ args[_key2] = arguments[_key2];
2876
+ }
2877
+ (_console2 = console).warn.apply(_console2, _toConsumableArray(withPrefix(args)));
2878
+ },
2879
+ info: function info() {
2880
+ if (isDebugEnabled()) {
2881
+ var _console3;
2882
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
2883
+ args[_key3] = arguments[_key3];
2884
+ }
2885
+ (_console3 = console).info.apply(_console3, _toConsumableArray(withPrefix(args)));
2886
+ }
2887
+ },
2888
+ debug: function debug() {
2889
+ if (isDebugEnabled()) {
2890
+ var _console4;
2891
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2892
+ args[_key4] = arguments[_key4];
2893
+ }
2894
+ (_console4 = console).debug.apply(_console4, _toConsumableArray(withPrefix(args)));
2895
+ }
2896
+ }
2897
+ };
2898
+
2767
2899
  function _objectWithoutPropertiesLoose(r, e) {
2768
2900
  if (null == r) return {};
2769
2901
  var t = {};
@@ -5042,7 +5174,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
5042
5174
  return hrefSchema["executeValidate"](hrefPath, node.href);
5043
5175
  } else {
5044
5176
  var exhaustiveCheck = hrefSchema;
5045
- console.error("Exhaustive check failed in RichText (anchor href validation)", exhaustiveCheck);
5177
+ log.error("Exhaustive check failed in RichText (anchor href validation)", exhaustiveCheck);
5046
5178
  return false;
5047
5179
  }
5048
5180
  };
@@ -15293,7 +15425,7 @@ function collectObjectRecursive(item, collector) {
15293
15425
  }
15294
15426
  return;
15295
15427
  } else {
15296
- console.warn("Unknown type encountered when hashing object", _typeof(item), item);
15428
+ log.warn("Unknown type encountered when hashing object", _typeof(item), item);
15297
15429
  }
15298
15430
  }
15299
15431
 
@@ -16805,7 +16937,7 @@ function isInlineRender(container) {
16805
16937
 
16806
16938
  var corePackageJson = {
16807
16939
  name: "@valbuild/core",
16808
- version: "0.148.0",
16940
+ version: "0.148.7",
16809
16941
  "private": false,
16810
16942
  description: "Val - supercharged hard-coded content",
16811
16943
  repository: {
@@ -16892,6 +17024,10 @@ var DEFAULT_APP_HOST = "https://admin.val.build";
16892
17024
  */
16893
17025
  var DEFAULT_STATIC_HOST = "https://content.val.build/v1/static";
16894
17026
  var Internal = {
17027
+ /** Val's console output. See `log.ts` for which levels print, and when. */
17028
+ log: log,
17029
+ isDebugEnabled: isDebugEnabled,
17030
+ VAL_DEBUG_STORAGE_KEY: VAL_DEBUG_STORAGE_KEY,
16895
17031
  VERSION: {
16896
17032
  core: corePackageJson.version
16897
17033
  },
@@ -16920,6 +17056,7 @@ var Internal = {
16920
17056
  },
16921
17057
  getSchema: getSchema,
16922
17058
  getValPath: getValPath,
17059
+ setValPath: setValPath,
16923
17060
  getSource: getSource,
16924
17061
  isValModule: isValModule,
16925
17062
  resolvePath: resolvePath,
@@ -916,6 +916,22 @@ function getValPath(valOrSelector) {
916
916
  return valOrSelector[Path];
917
917
  }
918
918
 
919
+ /**
920
+ * Gives an object Val read the path it was read from, where `getValPath`
921
+ * finds it: the readers' (`stegaEncode`'s) half of `getValPath`, for objects,
922
+ * which have no text to carry a path in.
923
+ *
924
+ * Not enumerable, and a symbol: `Object.keys`, `JSON.stringify` and every walk
925
+ * that reads content as data still see only the content.
926
+ */
927
+ function setValPath(target, path) {
928
+ Object.defineProperty(target, Path, {
929
+ value: path,
930
+ enumerable: false,
931
+ configurable: true
932
+ });
933
+ }
934
+
919
935
  function createValPathOfItem(
920
936
  /**
921
937
  * `ModuleFilePath` is accepted because the no-separator branch below is
@@ -2764,6 +2780,122 @@ var discriminatedUnion = function discriminatedUnion(key) {
2764
2780
  return new DiscriminatedUnionSchema(key, objects);
2765
2781
  };
2766
2782
 
2783
+ function _toArray(r) {
2784
+ return _arrayWithHoles(r) || _iterableToArray(r) || result._unsupportedIterableToArray(r) || _nonIterableRest();
2785
+ }
2786
+
2787
+ /**
2788
+ * Val's console output, and the one place that decides what reaches it.
2789
+ *
2790
+ * Val runs inside someone else's app: the server in their dev server and their
2791
+ * production logs, the Studio in their browser tab. Everything Val prints lands
2792
+ * in a console that belongs to a developer who did not write the code printing
2793
+ * it, so the levels are split by who the line is FOR:
2794
+ *
2795
+ * - `error` and `warn` are for that developer -- something broke, or something
2796
+ * they can fix -- and always print.
2797
+ * - `info` and `debug` are for whoever is debugging Val, and print only when
2798
+ * asked for: `VAL_DEBUG=1` in the environment of a server, or
2799
+ * `localStorage.setItem("val:debug", "1")` in a browser. Both are read on
2800
+ * every call, so turning it on in a live tab needs no reload.
2801
+ *
2802
+ * In Node `console.debug` IS `console.log`, so a bare `console.debug` is not
2803
+ * quiet on a server: it went to the developer's terminal on every request.
2804
+ * That is why `no-console` is on for the packages that run in a host app, and
2805
+ * this file is the exemption.
2806
+ *
2807
+ * Every line gets a `[val]` prefix, so a developer can filter Val out (or in).
2808
+ * Arguments are otherwise passed through as they are, so an `Error` still
2809
+ * prints with its stack.
2810
+ */
2811
+
2812
+ var PREFIX = "[val]";
2813
+
2814
+ /** The localStorage key that turns `debug` and `info` on in a browser. */
2815
+ var VAL_DEBUG_STORAGE_KEY = "val:debug";
2816
+ function isOn(value) {
2817
+ return value !== undefined && value !== null && value !== "" && value !== "0" && value !== "false";
2818
+ }
2819
+ function fromEnv() {
2820
+ var _process$env;
2821
+ // `typeof` first: a browser bundle may have no `process` at all.
2822
+ if (typeof process === "undefined") {
2823
+ return undefined;
2824
+ }
2825
+ return (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.VAL_DEBUG;
2826
+ }
2827
+ function fromLocalStorage() {
2828
+ // Not in Node, even where it has a `localStorage`: from Node 25 merely
2829
+ // touching it without `--localstorage-file` prints a warning of its own.
2830
+ if (!("window" in globalThis)) {
2831
+ return undefined;
2832
+ }
2833
+ try {
2834
+ var storage = Reflect.get(globalThis, "localStorage");
2835
+ if (_typeof(storage) === "object" && storage !== null && "getItem" in storage && typeof storage.getItem === "function") {
2836
+ var value = storage.getItem(VAL_DEBUG_STORAGE_KEY);
2837
+ return typeof value === "string" ? value : null;
2838
+ }
2839
+ } catch (_unused) {
2840
+ // A sandboxed frame or blocked site data throws on access.
2841
+ }
2842
+ return undefined;
2843
+ }
2844
+ function isDebugEnabled() {
2845
+ return isOn(fromEnv()) || isOn(fromLocalStorage());
2846
+ }
2847
+ function withPrefix(args) {
2848
+ var _args = _toArray(args),
2849
+ first = _args[0],
2850
+ rest = result._arrayLikeToArray(_args).slice(1);
2851
+ if (typeof first === "string") {
2852
+ if (/^\[val\]/i.test(first)) {
2853
+ return args;
2854
+ }
2855
+ return ["".concat(PREFIX, " ").concat(first)].concat(_toConsumableArray(rest));
2856
+ }
2857
+ return [PREFIX].concat(_toConsumableArray(args));
2858
+ }
2859
+
2860
+ /*
2861
+ * `console` is looked up on every call rather than captured, so a test that
2862
+ * spies on `console.warn` after this module loaded still sees the call.
2863
+ */
2864
+ var log = {
2865
+ error: function error() {
2866
+ var _console;
2867
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2868
+ args[_key] = arguments[_key];
2869
+ }
2870
+ (_console = console).error.apply(_console, _toConsumableArray(withPrefix(args)));
2871
+ },
2872
+ warn: function warn() {
2873
+ var _console2;
2874
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2875
+ args[_key2] = arguments[_key2];
2876
+ }
2877
+ (_console2 = console).warn.apply(_console2, _toConsumableArray(withPrefix(args)));
2878
+ },
2879
+ info: function info() {
2880
+ if (isDebugEnabled()) {
2881
+ var _console3;
2882
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
2883
+ args[_key3] = arguments[_key3];
2884
+ }
2885
+ (_console3 = console).info.apply(_console3, _toConsumableArray(withPrefix(args)));
2886
+ }
2887
+ },
2888
+ debug: function debug() {
2889
+ if (isDebugEnabled()) {
2890
+ var _console4;
2891
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2892
+ args[_key4] = arguments[_key4];
2893
+ }
2894
+ (_console4 = console).debug.apply(_console4, _toConsumableArray(withPrefix(args)));
2895
+ }
2896
+ }
2897
+ };
2898
+
2767
2899
  function _objectWithoutPropertiesLoose(r, e) {
2768
2900
  if (null == r) return {};
2769
2901
  var t = {};
@@ -5042,7 +5174,7 @@ var RichTextSchema = /*#__PURE__*/function (_Schema) {
5042
5174
  return hrefSchema["executeValidate"](hrefPath, node.href);
5043
5175
  } else {
5044
5176
  var exhaustiveCheck = hrefSchema;
5045
- console.error("Exhaustive check failed in RichText (anchor href validation)", exhaustiveCheck);
5177
+ log.error("Exhaustive check failed in RichText (anchor href validation)", exhaustiveCheck);
5046
5178
  return false;
5047
5179
  }
5048
5180
  };
@@ -15293,7 +15425,7 @@ function collectObjectRecursive(item, collector) {
15293
15425
  }
15294
15426
  return;
15295
15427
  } else {
15296
- console.warn("Unknown type encountered when hashing object", _typeof(item), item);
15428
+ log.warn("Unknown type encountered when hashing object", _typeof(item), item);
15297
15429
  }
15298
15430
  }
15299
15431
 
@@ -16805,7 +16937,7 @@ function isInlineRender(container) {
16805
16937
 
16806
16938
  var corePackageJson = {
16807
16939
  name: "@valbuild/core",
16808
- version: "0.148.0",
16940
+ version: "0.148.7",
16809
16941
  "private": false,
16810
16942
  description: "Val - supercharged hard-coded content",
16811
16943
  repository: {
@@ -16892,6 +17024,10 @@ var DEFAULT_APP_HOST = "https://admin.val.build";
16892
17024
  */
16893
17025
  var DEFAULT_STATIC_HOST = "https://content.val.build/v1/static";
16894
17026
  var Internal = {
17027
+ /** Val's console output. See `log.ts` for which levels print, and when. */
17028
+ log: log,
17029
+ isDebugEnabled: isDebugEnabled,
17030
+ VAL_DEBUG_STORAGE_KEY: VAL_DEBUG_STORAGE_KEY,
16895
17031
  VERSION: {
16896
17032
  core: corePackageJson.version
16897
17033
  },
@@ -16920,6 +17056,7 @@ var Internal = {
16920
17056
  },
16921
17057
  getSchema: getSchema,
16922
17058
  getValPath: getValPath,
17059
+ setValPath: setValPath,
16923
17060
  getSource: getSource,
16924
17061
  isValModule: isValModule,
16925
17062
  resolvePath: resolvePath,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-b0fa804a.cjs.dev.js');
5
+ var dist_valbuildCore = require('./index-66258256.cjs.dev.js');
6
6
  require('./result-bb1f436e.cjs.dev.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-ad3488f6.cjs.prod.js');
5
+ var dist_valbuildCore = require('./index-dfea75c9.cjs.prod.js');
6
6
  require('./result-787e35f6.cjs.prod.js');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { H as ASSISTANT_SETTINGS_MAX_LENGTH, A as ArraySchema, B as BooleanSchema, a4 as CODE_LANGUAGES, a5 as COLOR_FORMATS, a3 as CodeSchema, a2 as ColorSchema, e as DEFAULT_APP_HOST, a6 as DEFAULT_COLOR_FORMAT, D as DEFAULT_CONTENT_HOST, u as DEFAULT_FONT_ACCEPT, f as DEFAULT_STATIC_HOST, o as DEFAULT_VAL_REMOTE_HOST, x as DEFAULT_VIDEO_ACCEPT, y as DEFAULT_VIDEO_RENDITIONS, z as DEFAULT_VIDEO_SEGMENT_DURATION, C as DateSchema, a7 as DateTimeSchema, ad as DiscriminatedUnionSchema, ae as EnumSchema, F as FATAL_ERROR_TYPES, v as FONT_MIME_TYPES, t as FileSchema, G as GenericSelector, r as ImageSchema, I as Internal, a8 as KeyOfSchema, af as LiteralSchema, Z as LocaleSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, ac as RichTextSchema, ab as RouteSchema, Q as SETTINGS_MODULE_CONVENTION, S as Schema, E as SettingsSchema, q as StringSchema, T as THEME_LOGO_DIRECTORY, K as THEME_RADIUS_LENGTHS, J as THEME_RADIUS_STEPS, av as UNSAFE_URL_SCHEMES, V as VAL_EXTENSION, a9 as ValViewSchema, w as VideoSchema, L as assistantAvailability, k as computeSchemaSha, j as computeSourcesSha, h as computeValModuleShas, $ as declaredKeySetOf, p as derefPatch, ar as describeSchemeRejection, ag as deserializeSchema, a1 as discriminatedUnionBranchOf, g as extractValModules, ao as getSourcePathFromRoute, n as hasMediaSchema, l as hasRemoteFileSchema, i as initVal, as as isCheckableScheme, ai as isInlineRender, ap as isPageRouter, U as isRootModuleFilePath, aa as isValViewSource, Y as localeOfValue, X as localeTagError, an as matchRoutePattern, a0 as missingDeclaredKeys, m as modules, aj as parseNextJsRoutePattern, ak as parseTanStackRoutePattern, ah as previewScope, at as rejectScheme, W as resolveSettingsModule, aq as routePatternOf, au as schemeOf, al as tanStackSegmentsOfRoutePath, am as validateUrlAgainstPattern } from './index-09bd1d7d.esm.js';
1
+ export { H as ASSISTANT_SETTINGS_MAX_LENGTH, A as ArraySchema, B as BooleanSchema, a4 as CODE_LANGUAGES, a5 as COLOR_FORMATS, a3 as CodeSchema, a2 as ColorSchema, e as DEFAULT_APP_HOST, a6 as DEFAULT_COLOR_FORMAT, D as DEFAULT_CONTENT_HOST, u as DEFAULT_FONT_ACCEPT, f as DEFAULT_STATIC_HOST, o as DEFAULT_VAL_REMOTE_HOST, x as DEFAULT_VIDEO_ACCEPT, y as DEFAULT_VIDEO_RENDITIONS, z as DEFAULT_VIDEO_SEGMENT_DURATION, C as DateSchema, a7 as DateTimeSchema, ad as DiscriminatedUnionSchema, ae as EnumSchema, F as FATAL_ERROR_TYPES, v as FONT_MIME_TYPES, t as FileSchema, G as GenericSelector, r as ImageSchema, I as Internal, a8 as KeyOfSchema, af as LiteralSchema, Z as LocaleSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, ac as RichTextSchema, ab as RouteSchema, Q as SETTINGS_MODULE_CONVENTION, S as Schema, E as SettingsSchema, q as StringSchema, T as THEME_LOGO_DIRECTORY, K as THEME_RADIUS_LENGTHS, J as THEME_RADIUS_STEPS, av as UNSAFE_URL_SCHEMES, V as VAL_EXTENSION, a9 as ValViewSchema, w as VideoSchema, L as assistantAvailability, k as computeSchemaSha, j as computeSourcesSha, h as computeValModuleShas, $ as declaredKeySetOf, p as derefPatch, ar as describeSchemeRejection, ag as deserializeSchema, a1 as discriminatedUnionBranchOf, g as extractValModules, ao as getSourcePathFromRoute, n as hasMediaSchema, l as hasRemoteFileSchema, i as initVal, as as isCheckableScheme, ai as isInlineRender, ap as isPageRouter, U as isRootModuleFilePath, aa as isValViewSource, Y as localeOfValue, X as localeTagError, an as matchRoutePattern, a0 as missingDeclaredKeys, m as modules, aj as parseNextJsRoutePattern, ak as parseTanStackRoutePattern, ah as previewScope, at as rejectScheme, W as resolveSettingsModule, aq as routePatternOf, au as schemeOf, al as tanStackSegmentsOfRoutePath, am as validateUrlAgainstPattern } from './index-52c01907.esm.js';
2
2
  import './result-daff1cae.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/core",
3
- "version": "0.148.0",
3
+ "version": "0.148.7",
4
4
  "private": false,
5
5
  "description": "Val - supercharged hard-coded content",
6
6
  "repository": {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('../../dist/index-b0fa804a.cjs.dev.js');
5
+ var dist_valbuildCore = require('../../dist/index-66258256.cjs.dev.js');
6
6
  var result = require('../../dist/result-bb1f436e.cjs.dev.js');
7
7
  var util = require('../../dist/util-b213092b.cjs.dev.js');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('../../dist/index-ad3488f6.cjs.prod.js');
5
+ var dist_valbuildCore = require('../../dist/index-dfea75c9.cjs.prod.js');
6
6
  var result = require('../../dist/result-787e35f6.cjs.prod.js');
7
7
  var util = require('../../dist/util-030d8a1f.cjs.prod.js');
8
8
 
@@ -1,5 +1,5 @@
1
- import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-09bd1d7d.esm.js';
2
- export { P as PatchError } from '../../dist/index-09bd1d7d.esm.js';
1
+ import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-52c01907.esm.js';
2
+ export { P as PatchError } from '../../dist/index-52c01907.esm.js';
3
3
  import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-daff1cae.esm.js';
4
4
  import { p as pipe } from '../../dist/util-18613e99.esm.js';
5
5