@valbuild/core 0.153.0 → 0.154.2

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.
@@ -91,6 +91,28 @@ function _defineProperty(e, r, t) {
91
91
  }) : e[r] = t, e;
92
92
  }
93
93
 
94
+ function ownKeys(e, r) {
95
+ var t = Object.keys(e);
96
+ if (Object.getOwnPropertySymbols) {
97
+ var o = Object.getOwnPropertySymbols(e);
98
+ r && (o = o.filter(function (r) {
99
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
100
+ })), t.push.apply(t, o);
101
+ }
102
+ return t;
103
+ }
104
+ function _objectSpread2(e) {
105
+ for (var r = 1; r < arguments.length; r++) {
106
+ var t = null != arguments[r] ? arguments[r] : {};
107
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
108
+ _defineProperty(e, r, t[r]);
109
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
110
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
111
+ });
112
+ }
113
+ return e;
114
+ }
115
+
94
116
  function _classCallCheck(a, n) {
95
117
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
96
118
  }
@@ -523,6 +545,16 @@ var Schema = /*#__PURE__*/function () {
523
545
  value: function executePreviewItem(src) {
524
546
  return null;
525
547
  }
548
+ /**
549
+ * EXPERIMENTAL: the component that renders this value, for a value whose
550
+ * source is `src`. Only `s.object(...).component(...)` declares
551
+ * one; a discriminated union answers for the variant `src` takes.
552
+ */
553
+ }, {
554
+ key: "executeComponentRender",
555
+ value: function executeComponentRender(src) {
556
+ return null;
557
+ }
526
558
  /**
527
559
  * Could {@link executePreviewItem} ever answer? A container reifies a rows
528
560
  * preview only when its item schema says yes — asked here rather than by
@@ -601,28 +633,6 @@ var Schema = /*#__PURE__*/function () {
601
633
 
602
634
  // TODO: SourceError<"Could not determine type of Schema">
603
635
 
604
- function ownKeys(e, r) {
605
- var t = Object.keys(e);
606
- if (Object.getOwnPropertySymbols) {
607
- var o = Object.getOwnPropertySymbols(e);
608
- r && (o = o.filter(function (r) {
609
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
610
- })), t.push.apply(t, o);
611
- }
612
- return t;
613
- }
614
- function _objectSpread2(e) {
615
- for (var r = 1; r < arguments.length; r++) {
616
- var t = null != arguments[r] ? arguments[r] : {};
617
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
618
- _defineProperty(e, r, t[r]);
619
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
620
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
621
- });
622
- }
623
- return e;
624
- }
625
-
626
636
  /**
627
637
  * THE RULE, and the only sentence that needs to be remembered:
628
638
  *
@@ -913,6 +923,19 @@ function isVal(val) {
913
923
  function getValPath(valOrSelector) {
914
924
  return valOrSelector[Path];
915
925
  }
926
+ function carriesValPath(value) {
927
+ return Path in value && typeof value[Path] === "string";
928
+ }
929
+
930
+ /**
931
+ * The path a value was read from, for a value of ANY type: `getValPath` for
932
+ * code that was handed something and does not know it to be a `Val`. An
933
+ * object or a list a reader gave back carries one in draft mode
934
+ * (`setValPath`); anything else, and everything in production, does not.
935
+ */
936
+ function valPathOf(value) {
937
+ return _typeof(value) === "object" && value !== null && carriesValPath(value) ? value[Path] : undefined;
938
+ }
916
939
 
917
940
  /**
918
941
  * Gives an object Val read the path it was read from, where `getValPath`
@@ -1331,6 +1354,7 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
1331
1354
  var isHidden = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
1332
1355
  var description = arguments.length > 5 ? arguments[5] : undefined;
1333
1356
  var previewInput = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
1357
+ var renderInput = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
1334
1358
  _classCallCheck(this, ObjectSchema);
1335
1359
  _this = _callSuper(this, ObjectSchema);
1336
1360
  _this.items = items;
@@ -1340,6 +1364,7 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
1340
1364
  _this.isHidden = isHidden;
1341
1365
  _this.description = description;
1342
1366
  _this.previewInput = previewInput;
1367
+ _this.renderInput = renderInput;
1343
1368
  return _this;
1344
1369
  }
1345
1370
 
@@ -1369,7 +1394,7 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
1369
1394
  return _createClass(ObjectSchema, [{
1370
1395
  key: "describe",
1371
1396
  value: function describe(description) {
1372
- return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput);
1397
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, description !== null && description !== void 0 ? description : undefined, this.previewInput, this.renderInput);
1373
1398
  }
1374
1399
 
1375
1400
  /**
@@ -1401,7 +1426,7 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
1401
1426
  }, {
1402
1427
  key: "validate",
1403
1428
  value: function validate(validationFunction) {
1404
- return new ObjectSchema(this.items, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput);
1429
+ return new ObjectSchema(this.items, this.opt, [].concat(_toConsumableArray(this.customValidateFunctions), [validationFunction]), this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
1405
1430
  }
1406
1431
  }, {
1407
1432
  key: "executeValidate",
@@ -1534,19 +1559,19 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
1534
1559
  key: "nullable",
1535
1560
  value: function nullable() {
1536
1561
  // Explicit type args: `previewInput` would otherwise pin inference to `Src`.
1537
- return new ObjectSchema(this.items, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput);
1562
+ return new ObjectSchema(this.items, true, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
1538
1563
  }
1539
1564
  }, {
1540
1565
  key: "readonly",
1541
1566
  value: function readonly() {
1542
1567
  var isReadonly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1543
- return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, isReadonly, this.isHidden, this.description, this.previewInput);
1568
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, isReadonly, this.isHidden, this.description, this.previewInput, this.renderInput);
1544
1569
  }
1545
1570
  }, {
1546
1571
  key: "hidden",
1547
1572
  value: function hidden() {
1548
1573
  var isHidden = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1549
- return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, isHidden, this.description, this.previewInput);
1574
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, isHidden, this.description, this.previewInput, this.renderInput);
1550
1575
  }
1551
1576
 
1552
1577
  /** The names of this object's `s.locale()` fields, in declaration order. */
@@ -1601,7 +1626,74 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
1601
1626
  }, {
1602
1627
  key: "preview",
1603
1628
  value: function preview(select) {
1604
- return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select);
1629
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, select, this.renderInput);
1630
+ }
1631
+
1632
+ /**
1633
+ * EXPERIMENTAL: the component that renders this object on the site.
1634
+ *
1635
+ * The site renders the object with it through `ValComponentEditor`, and the
1636
+ * Studio shows it next to the fields while they are edited, so the two
1637
+ * cannot drift.
1638
+ *
1639
+ * `load` is a lazy `import()`, never the component itself: a `.val.ts` is
1640
+ * evaluated outside of the app, where a component's CSS, images and
1641
+ * framework code cannot be loaded. See {@link ComponentRender}.
1642
+ *
1643
+ * It is type checked against the component's own props. An object whose
1644
+ * fields ARE the props needs nothing else. One whose fields are not - any
1645
+ * component that was not written for this schema - takes a `props`
1646
+ * function, which is then required and whose result is checked instead.
1647
+ * `props` is given the value as a reader returns it (an image has its
1648
+ * `url`), so a string it passes on unchanged can still be clicked to edit.
1649
+ *
1650
+ * Do not type the component's props from the schema it is linked from
1651
+ * (`t.inferSchema<typeof hero>` where `hero` is the result of this call):
1652
+ * the schema's type then depends on the component's and the component's on
1653
+ * the schema's, and TypeScript gives up on both. Declare the fields first
1654
+ * and link them in a second `const`, or let the component own its props.
1655
+ *
1656
+ * `example` is content that is not on the site, to preview with as well:
1657
+ * long titles and empty lists that make layout problems easy to spot.
1658
+ *
1659
+ * @example
1660
+ * const hero = s
1661
+ * .object({ title: s.string() })
1662
+ * .component(() => import("./HeroSection"), {
1663
+ * example: { title: "A very long title that should wrap nicely" },
1664
+ * });
1665
+ * export default c.define("/example.val.ts", s.array(hero), []);
1666
+ *
1667
+ * @example
1668
+ * // A component with props of its own: `props` says how to make them.
1669
+ * const banner = s
1670
+ * .object({ heading: s.string() })
1671
+ * .component(() => import("./HeroSection"), {
1672
+ * props: (value) => ({ title: value.heading }),
1673
+ * });
1674
+ * export default c.define("/example.val.ts", banner, { heading: "Hello" });
1675
+ */
1676
+ }, {
1677
+ key: "component",
1678
+ value: function component(load) {
1679
+ for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key3 = 1; _key3 < _len; _key3++) {
1680
+ rest[_key3 - 1] = arguments[_key3];
1681
+ }
1682
+ var options = rest[0];
1683
+ var input = _objectSpread2(_objectSpread2({
1684
+ as: "component",
1685
+ component: load
1686
+ }, (options === null || options === void 0 ? void 0 : options.props) !== undefined ? {
1687
+ props: options.props
1688
+ } : {}), (options === null || options === void 0 ? void 0 : options.example) !== undefined ? {
1689
+ example: options.example
1690
+ } : {});
1691
+ return new ObjectSchema(this.items, this.opt, this.customValidateFunctions, this.isReadonly, this.isHidden, this.description, this.previewInput, input);
1692
+ }
1693
+ }, {
1694
+ key: "executeComponentRender",
1695
+ value: function executeComponentRender(src) {
1696
+ return this.renderInput;
1605
1697
  }
1606
1698
  }, {
1607
1699
  key: "executePreviewItem",
@@ -1622,7 +1714,7 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
1622
1714
  key: "executeSerialize",
1623
1715
  value: function executeSerialize() {
1624
1716
  var _this$customValidateF;
1625
- return {
1717
+ return _objectSpread2({
1626
1718
  type: "object",
1627
1719
  preview: this.previewInput ? true : undefined,
1628
1720
  items: Object.fromEntries(Object.entries(this.items).map(function (_ref5) {
@@ -1636,7 +1728,12 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
1636
1728
  readonly: this.isReadonly,
1637
1729
  hidden: this.isHidden,
1638
1730
  description: this.description
1639
- };
1731
+ }, this.renderInput ? {
1732
+ render: {
1733
+ as: "component",
1734
+ example: this.renderInput.example !== undefined ? true : undefined
1735
+ }
1736
+ } : {});
1640
1737
  }
1641
1738
  }, {
1642
1739
  key: "executePreview",
@@ -1645,19 +1742,19 @@ var ObjectSchema = /*#__PURE__*/function (_Schema) {
1645
1742
  if (src === null) {
1646
1743
  return res;
1647
1744
  }
1648
- for (var _key3 in this.items) {
1649
- var itemSrc = src[_key3];
1745
+ for (var _key4 in this.items) {
1746
+ var itemSrc = src[_key4];
1650
1747
  if (itemSrc === null || itemSrc === undefined) {
1651
1748
  continue;
1652
1749
  }
1653
- var subPath = unsafeCreateSourcePath(sourcePath, _key3);
1750
+ var subPath = unsafeCreateSourcePath(sourcePath, _key4);
1654
1751
  // An object produces no preview of its own, so it is pure recursion — and
1655
1752
  // pruning it is the whole contribution: a field deep in one branch stops
1656
1753
  // paying for every sibling branch's previews.
1657
1754
  if (scope !== undefined && !scope.wantsUnder(subPath)) {
1658
1755
  continue;
1659
1756
  }
1660
- mergePreviewInto(res, this.items[_key3]["executePreview"](subPath, itemSrc, scope));
1757
+ mergePreviewInto(res, this.items[_key4]["executePreview"](subPath, itemSrc, scope));
1661
1758
  }
1662
1759
  // An object reifies no rows of its own, so the only thing it adds is what
1663
1760
  // IT is called — which nothing else can supply for a field of an object.
@@ -2693,6 +2790,12 @@ var DiscriminatedUnionSchema = /*#__PURE__*/function (_Schema) {
2693
2790
  }
2694
2791
  return null;
2695
2792
  }
2793
+ }, {
2794
+ key: "executeComponentRender",
2795
+ value: function executeComponentRender(src) {
2796
+ var matched = this.matchedVariant(src);
2797
+ return matched ? matched["executeComponentRender"](src) : null;
2798
+ }
2696
2799
  }, {
2697
2800
  key: "declaresItemPreview",
2698
2801
  value: function declaresItemPreview() {
@@ -10488,7 +10591,7 @@ function settings() {
10488
10591
  context: string().multiline().maxLength(ASSISTANT_SETTINGS_MAX_LENGTH).nullable().describe("Background the assistant would otherwise have to guess: what this site is, who runs it, names and spellings that matter."),
10489
10592
  tone: string().multiline().maxLength(ASSISTANT_SETTINGS_MAX_LENGTH).nullable().describe("How the assistant should write when it writes content: formal or playful, British or American, how headings are cased."),
10490
10593
  translation: record(locale(), string().multiline().maxLength(ASSISTANT_SETTINGS_MAX_LENGTH).nullable()).nullable().describe("How to translate into each language: dialect, formality, and the words that stay untranslated."),
10491
- webSearch: _boolean().nullable().describe("Whether the assistant may search the web. Off unless turned on. After a search it asks before changing code.")
10594
+ webSearch: _boolean().nullable().describe("Whether the assistant may search the web. Unset: it asks you when it needs to. Off: it never asks. After a search it asks before changing code.")
10492
10595
  }),
10493
10596
  theme: new SettingsSchema({
10494
10597
  accent: color({
@@ -16891,11 +16994,16 @@ function routerForParams(routerId) {
16891
16994
  * A RENDER is how a field is laid out in the editor, and it applies only when
16892
16995
  * you are looking at the field. On a list it is declared by the CONTAINER about
16893
16996
  * its children, never by a child about itself: `s.array(item).render({ as: "inline" })`
16894
- * and `s.record(item).render({ as: "inline" })`. Two other schemas take a
16997
+ * and `s.record(item).render({ as: "inline" })`. Three other schemas take a
16895
16998
  * render, each meaning something of its own: `s.keyOf(...)` (see
16896
- * `KeyOfSchema.render`) and `s.number()` / `s.int()`, whose `{ as: "slider" }`
16999
+ * `KeyOfSchema.render`), `s.number()` / `s.int()`, whose `{ as: "slider" }`
16897
17000
  * is a different input for the same value (see {@link SliderRender}).
16898
17001
  *
17002
+ * EXPERIMENTAL: an object's component is declared with `.component(...)` and
17003
+ * not with `.render(...)`, because it is more than layout in the editor: the
17004
+ * site renders the object with it (see {@link ComponentRender}). Its marker
17005
+ * still travels as the serialized `render`, `{ as: "component" }`.
17006
+ *
16899
17007
  * Why the container: inline is a property of the LIST — "my items are edited in
16900
17008
  * their rows" — and the item schema is the wrong place to say it. An item can be
16901
17009
  * reused in a list that wants preview rows and one that wants forms; a tagged
@@ -17000,9 +17108,210 @@ function isInlineRender(container) {
17000
17108
  return ((_container$render = container.render) === null || _container$render === void 0 ? void 0 : _container$render.as) === "inline";
17001
17109
  }
17002
17110
 
17111
+ /**
17112
+ * EXPERIMENTAL. A React (or any) component, typed loosely because core knows
17113
+ * nothing about React. `never` in the parameter position accepts a component
17114
+ * of any props, since parameters are contravariant.
17115
+ */
17116
+
17117
+ /**
17118
+ * What the `component` thunk of a {@link ComponentRender} resolves to: the
17119
+ * component itself, or a module whose default export is the component.
17120
+ */
17121
+
17122
+ /**
17123
+ * The props a component takes, read off its own type: what `.component()`
17124
+ * checks a schema's fields (or its `props` function) against. Structural, so
17125
+ * it needs nothing of React: a function component is a function of its props,
17126
+ * and a class component is constructed with them.
17127
+ */
17128
+
17129
+ /**
17130
+ * EXPERIMENTAL. What `.component(load, options)` on `s.object(...)` holds:
17131
+ * the component that renders this object on the site.
17132
+ *
17133
+ * The site renders the object through it (`ValComponentEditor`), and the
17134
+ * app's preview route (`ValComponentPreview`) renders it alone. Both go
17135
+ * through the same thunk and the same `props`, so what the editor sees cannot
17136
+ * drift from what a visitor gets. In the Studio's field panel the object is
17137
+ * edited as any other object: its fields, with no component beside them.
17138
+ *
17139
+ * It holds CLOSURES - the `component` thunk and `props` - so, exactly like a
17140
+ * preview, only a marker travels in the serialized schema
17141
+ * ({@link SerializedComponentRender}) and the component is rendered by the
17142
+ * host app, which has the schema instance.
17143
+ *
17144
+ * `component` is a lazy `import()` rather than the component itself. A
17145
+ * `.val.ts` may not import app code (`@valbuild/eslint-plugin`'s
17146
+ * `no-illegal-imports`), because Val evaluates val files outside of the app -
17147
+ * `val validate`, the language server and the Studio all do - and a component
17148
+ * pulls in CSS, images and framework code none of those can load. A thunk is
17149
+ * never called there, so the component's file is never loaded either. On the
17150
+ * site it also means a page downloads the components it shows and no others.
17151
+ *
17152
+ * `props` turns the value into the component's props, for a component whose
17153
+ * props are not the object's fields: one that was written before the schema,
17154
+ * or belongs to a design system. It is called with the READ value (an image
17155
+ * has its `url`, a string carries its edit tag), so a string it passes on
17156
+ * unchanged is still a click away from its field, and one it transforms is
17157
+ * not. Without it the value itself is the props.
17158
+ *
17159
+ * `example` is content to preview the component with that is not on the site:
17160
+ * a fixture, and a good place for deliberately unrepresentative values (very
17161
+ * long titles, empty lists) that make layout problems easy to spot.
17162
+ */
17163
+
17164
+ /**
17165
+ * The options of `.component(load, options)` that are not the `props`
17166
+ * function. See {@link ComponentRender} for each.
17167
+ */
17168
+
17169
+ /** {@link ComponentOptions} for a component whose props ARE the read value. */
17170
+
17171
+ /**
17172
+ * {@link ComponentOptions} for a component whose props are NOT the read
17173
+ * value: `props` is what makes them, so it is required.
17174
+ */
17175
+
17176
+ /**
17177
+ * What follows the thunk in `.component(load, ...)`: nothing or options when
17178
+ * the value a reader gives back (`Read`) is assignable to the component's
17179
+ * props, and options with a `props` function when it is not. That is the
17180
+ * whole type check: a component that cannot be handed this object does not
17181
+ * compile, on the line that links them.
17182
+ *
17183
+ * In tuples so the test does not distribute over a union of props.
17184
+ */
17185
+
17186
+ /**
17187
+ * What a {@link ComponentRender} serializes to. The component is a closure and
17188
+ * cannot travel; `example` says whether there is one to preview with.
17189
+ */
17190
+
17191
+ /**
17192
+ * The messages between the Studio and the host app's preview route, which run
17193
+ * in different frames. Both sides read them from here so they cannot drift.
17194
+ *
17195
+ * - `ready`: preview to Studio. The preview is listening; tell it whether
17196
+ * clicking picks.
17197
+ * - `refresh`: Studio to preview. The content changed; render it again.
17198
+ * - `size`: preview to Studio, with `{ height }`. What the component rendered
17199
+ * is this tall, so the Studio can size the frame to fit it.
17200
+ * - `picking`: Studio to preview, with `{ enabled }`. Whether a click on
17201
+ * content picks the field it came from, rather than doing what a click on
17202
+ * the site does.
17203
+ * - `pick`: preview to Studio, with `{ paths }`. The editor clicked content
17204
+ * with these source paths behind it (from its `data-val-path`).
17205
+ */
17206
+ var VAL_PREVIEW_MESSAGES = {
17207
+ ready: "val-preview-ready",
17208
+ refresh: "val-preview-refresh",
17209
+ size: "val-preview-size",
17210
+ picking: "val-preview-picking",
17211
+ pick: "val-preview-pick"
17212
+ };
17213
+
17214
+ /**
17215
+ * EXPERIMENTAL: the component that renders a value of `schema` whose source is
17216
+ * `src`, or `null` when there is none. A discriminated union answers for the
17217
+ * variant `src` takes, which is what a list of page sections needs.
17218
+ */
17219
+ function getComponentRender(schema, src) {
17220
+ return schema["executeComponentRender"](src);
17221
+ }
17222
+
17223
+ /**
17224
+ * EXPERIMENTAL: call a {@link ComponentRender}'s thunk and unwrap a module's
17225
+ * default export.
17226
+ */
17227
+ function loadComponent(_x) {
17228
+ return _loadComponent.apply(this, arguments);
17229
+ }
17230
+
17231
+ /**
17232
+ * EXPERIMENTAL: the props to render a {@link ComponentRender}'s component
17233
+ * with, for `value` as a reader gave it back: what its `props` function makes
17234
+ * of it, or the value itself when it has none.
17235
+ *
17236
+ * The one place the mapper is called, so the site (`ValComponentEditor`) and
17237
+ * the Studio's preview cannot disagree about what the component is handed.
17238
+ */
17239
+ function _loadComponent() {
17240
+ _loadComponent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(render) {
17241
+ var imported;
17242
+ return _regenerator().w(function (_context) {
17243
+ while (1) switch (_context.n) {
17244
+ case 0:
17245
+ _context.n = 1;
17246
+ return render.component();
17247
+ case 1:
17248
+ imported = _context.v;
17249
+ return _context.a(2, typeof imported === "function" ? imported : imported["default"]);
17250
+ }
17251
+ }, _callee);
17252
+ }));
17253
+ return _loadComponent.apply(this, arguments);
17254
+ }
17255
+ function componentPropsOf(render, value) {
17256
+ if (render.props === undefined) {
17257
+ return value;
17258
+ }
17259
+ // `.component()` checked this function against the read type of the schema
17260
+ // that holds it. A render found by path has lost that relation - it is why
17261
+ // the parameter is `never` - and `value` is that schema's value, read: this
17262
+ // assertion is what restores it, here and nowhere else.
17263
+ return render.props(value);
17264
+ }
17265
+
17266
+ /**
17267
+ * Where a value's component rides. Registered globally for the reason the
17268
+ * selector symbols are (`selector/index.ts`): two bundled copies of core must
17269
+ * agree on it, or what one attached the other cannot find.
17270
+ */
17271
+ var ComponentOfValue = Symbol["for"]("@valbuild/core/ComponentOfValue");
17272
+ function isComponentRender(value) {
17273
+ return _typeof(value) === "object" && value !== null && "as" in value && value.as === "component" && "component" in value && typeof value.component === "function";
17274
+ }
17275
+
17276
+ /**
17277
+ * EXPERIMENTAL: attach, to a value a reader is about to give back, the
17278
+ * component its schema links it to (`.component()`), so `ValComponentEditor`
17279
+ * can render the value without a registry: the value says what renders it.
17280
+ *
17281
+ * The same idea as a view's handle, for the same reason. The app cannot get
17282
+ * from a value back to its schema, and the reader (`stegaEncode`) is the one
17283
+ * place that has both.
17284
+ *
17285
+ * Not enumerable, and a symbol: `Object.keys`, `JSON.stringify` and every
17286
+ * walk that reads content as data still see only the content. So, like a
17287
+ * view's handle, it does not survive serialization: a value passed from a
17288
+ * server component to a client one arrives without it.
17289
+ */
17290
+ function setComponentOfValue(target, render) {
17291
+ Object.defineProperty(target, ComponentOfValue, {
17292
+ value: render,
17293
+ enumerable: false,
17294
+ configurable: true
17295
+ });
17296
+ }
17297
+
17298
+ /**
17299
+ * EXPERIMENTAL: the component a read value is linked to, or `null` when it
17300
+ * carries none: its schema has no `.component()`, or the value crossed a
17301
+ * server/client boundary and lost it.
17302
+ */
17303
+ function componentOfValue(value) {
17304
+ var _Object$getOwnPropert;
17305
+ if (_typeof(value) !== "object" || value === null) {
17306
+ return null;
17307
+ }
17308
+ var render = (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(value, ComponentOfValue)) === null || _Object$getOwnPropert === void 0 ? void 0 : _Object$getOwnPropert.value;
17309
+ return isComponentRender(render) ? render : null;
17310
+ }
17311
+
17003
17312
  var corePackageJson = {
17004
17313
  name: "@valbuild/core",
17005
- version: "0.153.0",
17314
+ version: "0.154.2",
17006
17315
  "private": false,
17007
17316
  description: "Val - supercharged hard-coded content",
17008
17317
  repository: {
@@ -17123,6 +17432,7 @@ var Internal = {
17123
17432
  getSchema: getSchema,
17124
17433
  getValPath: getValPath,
17125
17434
  setValPath: setValPath,
17435
+ valPathOf: valPathOf,
17126
17436
  getSource: getSource,
17127
17437
  isValModule: isValModule,
17128
17438
  resolvePath: resolvePath,
@@ -17241,4 +17551,4 @@ function tryJsonParse(str) {
17241
17551
  }
17242
17552
  }
17243
17553
 
17244
- export { declaredKeySetOf as $, ArraySchema as A, BooleanSchema as B, DateSchema as C, DEFAULT_CONTENT_HOST as D, SettingsSchema as E, FATAL_ERROR_TYPES as F, GenericSelector as G, ASSISTANT_SETTINGS_MAX_LENGTH as H, Internal as I, THEME_RADIUS_STEPS as J, THEME_RADIUS_LENGTHS as K, assistantAvailability as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, SETTINGS_MODULE_CONVENTION as Q, RecordSchema as R, Schema as S, THEME_LOGO_DIRECTORY as T, isRootModuleFilePath as U, VAL_EXTENSION as V, resolveSettingsModule as W, localeTagError as X, localeOfValue as Y, LocaleSchema as Z, _typeof as _, _slicedToArray as a, missingDeclaredKeys as a0, discriminatedUnionBranchOf as a1, ColorSchema as a2, CodeSchema as a3, CODE_LANGUAGES as a4, COLOR_FORMATS as a5, DEFAULT_COLOR_FORMAT as a6, DateTimeSchema as a7, KeyOfSchema as a8, ValViewSchema as a9, isValViewSource as aa, RouteSchema as ab, RichTextSchema as ac, DiscriminatedUnionSchema as ad, EnumSchema as ae, LiteralSchema as af, deserializeSchema as ag, previewScope as ah, isInlineRender as ai, parseNextJsRoutePattern as aj, parseTanStackRoutePattern as ak, tanStackSegmentsOfRoutePath as al, validateUrlAgainstPattern as am, matchRoutePattern as an, getSourcePathFromRoute as ao, isPageRouter as ap, routePatternOf as aq, describeSchemeRejection as ar, isCheckableScheme as as, rejectScheme as at, schemeOf as au, UNSAFE_URL_SCHEMES as av, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, DEFAULT_STATIC_HOST as f, extractValModules as g, computeValModuleShas as h, initVal as i, computeSourcesSha as j, computeSchemaSha as k, hasRemoteFileSchema as l, modules as m, hasMediaSchema as n, DEFAULT_VAL_REMOTE_HOST as o, derefPatch as p, StringSchema as q, ImageSchema as r, splitModuleFilePathAndModulePath as s, FileSchema as t, DEFAULT_FONT_ACCEPT as u, FONT_MIME_TYPES as v, VideoSchema as w, DEFAULT_VIDEO_ACCEPT as x, DEFAULT_VIDEO_RENDITIONS as y, DEFAULT_VIDEO_SEGMENT_DURATION as z };
17554
+ export { declaredKeySetOf as $, ArraySchema as A, BooleanSchema as B, DateSchema as C, DEFAULT_CONTENT_HOST as D, SettingsSchema as E, FATAL_ERROR_TYPES as F, GenericSelector as G, ASSISTANT_SETTINGS_MAX_LENGTH as H, Internal as I, THEME_RADIUS_STEPS as J, THEME_RADIUS_LENGTHS as K, assistantAvailability as L, ModuleFilePathSep as M, NumberSchema as N, ObjectSchema as O, PatchError as P, SETTINGS_MODULE_CONVENTION as Q, RecordSchema as R, Schema as S, THEME_LOGO_DIRECTORY as T, isRootModuleFilePath as U, VAL_EXTENSION as V, resolveSettingsModule as W, localeTagError as X, localeOfValue as Y, LocaleSchema as Z, _typeof as _, _slicedToArray as a, missingDeclaredKeys as a0, discriminatedUnionBranchOf as a1, ColorSchema as a2, CodeSchema as a3, CODE_LANGUAGES as a4, COLOR_FORMATS as a5, DEFAULT_COLOR_FORMAT as a6, DateTimeSchema as a7, KeyOfSchema as a8, ValViewSchema as a9, schemeOf as aA, UNSAFE_URL_SCHEMES as aB, isValViewSource as aa, RouteSchema as ab, RichTextSchema as ac, DiscriminatedUnionSchema as ad, EnumSchema as ae, LiteralSchema as af, deserializeSchema as ag, previewScope as ah, isInlineRender as ai, getComponentRender as aj, loadComponent as ak, componentPropsOf as al, setComponentOfValue as am, componentOfValue as an, VAL_PREVIEW_MESSAGES as ao, parseNextJsRoutePattern as ap, parseTanStackRoutePattern as aq, tanStackSegmentsOfRoutePath as ar, validateUrlAgainstPattern as as, matchRoutePattern as at, getSourcePathFromRoute as au, isPageRouter as av, routePatternOf as aw, describeSchemeRejection as ax, isCheckableScheme as ay, rejectScheme as az, _createClass as b, _classCallCheck as c, _toConsumableArray as d, DEFAULT_APP_HOST as e, DEFAULT_STATIC_HOST as f, extractValModules as g, computeValModuleShas as h, initVal as i, computeSourcesSha as j, computeSchemaSha as k, hasRemoteFileSchema as l, modules as m, hasMediaSchema as n, DEFAULT_VAL_REMOTE_HOST as o, derefPatch as p, StringSchema as q, ImageSchema as r, splitModuleFilePathAndModulePath as s, FileSchema as t, DEFAULT_FONT_ACCEPT as u, FONT_MIME_TYPES as v, VideoSchema as w, DEFAULT_VIDEO_ACCEPT as x, DEFAULT_VIDEO_RENDITIONS as y, DEFAULT_VIDEO_SEGMENT_DURATION as z };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-8a50c651.cjs.dev.js');
5
+ var dist_valbuildCore = require('./index-48d6f61b.cjs.dev.js');
6
6
  require('./result-bb1f436e.cjs.dev.js');
7
7
 
8
8
 
@@ -51,9 +51,12 @@ exports.THEME_RADIUS_LENGTHS = dist_valbuildCore.THEME_RADIUS_LENGTHS;
51
51
  exports.THEME_RADIUS_STEPS = dist_valbuildCore.THEME_RADIUS_STEPS;
52
52
  exports.UNSAFE_URL_SCHEMES = dist_valbuildCore.UNSAFE_URL_SCHEMES;
53
53
  exports.VAL_EXTENSION = dist_valbuildCore.VAL_EXTENSION;
54
+ exports.VAL_PREVIEW_MESSAGES = dist_valbuildCore.VAL_PREVIEW_MESSAGES;
54
55
  exports.ValViewSchema = dist_valbuildCore.ValViewSchema;
55
56
  exports.VideoSchema = dist_valbuildCore.VideoSchema;
56
57
  exports.assistantAvailability = dist_valbuildCore.assistantAvailability;
58
+ exports.componentOfValue = dist_valbuildCore.componentOfValue;
59
+ exports.componentPropsOf = dist_valbuildCore.componentPropsOf;
57
60
  exports.computeSchemaSha = dist_valbuildCore.computeSchemaSha;
58
61
  exports.computeSourcesSha = dist_valbuildCore.computeSourcesSha;
59
62
  exports.computeValModuleShas = dist_valbuildCore.computeValModuleShas;
@@ -63,6 +66,7 @@ exports.describeSchemeRejection = dist_valbuildCore.describeSchemeRejection;
63
66
  exports.deserializeSchema = dist_valbuildCore.deserializeSchema;
64
67
  exports.discriminatedUnionBranchOf = dist_valbuildCore.discriminatedUnionBranchOf;
65
68
  exports.extractValModules = dist_valbuildCore.extractValModules;
69
+ exports.getComponentRender = dist_valbuildCore.getComponentRender;
66
70
  exports.getSourcePathFromRoute = dist_valbuildCore.getSourcePathFromRoute;
67
71
  exports.hasMediaSchema = dist_valbuildCore.hasMediaSchema;
68
72
  exports.hasRemoteFileSchema = dist_valbuildCore.hasRemoteFileSchema;
@@ -72,6 +76,7 @@ exports.isInlineRender = dist_valbuildCore.isInlineRender;
72
76
  exports.isPageRouter = dist_valbuildCore.isPageRouter;
73
77
  exports.isRootModuleFilePath = dist_valbuildCore.isRootModuleFilePath;
74
78
  exports.isValViewSource = dist_valbuildCore.isValViewSource;
79
+ exports.loadComponent = dist_valbuildCore.loadComponent;
75
80
  exports.localeOfValue = dist_valbuildCore.localeOfValue;
76
81
  exports.localeTagError = dist_valbuildCore.localeTagError;
77
82
  exports.matchRoutePattern = dist_valbuildCore.matchRoutePattern;
@@ -84,5 +89,6 @@ exports.rejectScheme = dist_valbuildCore.rejectScheme;
84
89
  exports.resolveSettingsModule = dist_valbuildCore.resolveSettingsModule;
85
90
  exports.routePatternOf = dist_valbuildCore.routePatternOf;
86
91
  exports.schemeOf = dist_valbuildCore.schemeOf;
92
+ exports.setComponentOfValue = dist_valbuildCore.setComponentOfValue;
87
93
  exports.tanStackSegmentsOfRoutePath = dist_valbuildCore.tanStackSegmentsOfRoutePath;
88
94
  exports.validateUrlAgainstPattern = dist_valbuildCore.validateUrlAgainstPattern;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dist_valbuildCore = require('./index-2fecc26e.cjs.prod.js');
5
+ var dist_valbuildCore = require('./index-58e0cce0.cjs.prod.js');
6
6
  require('./result-787e35f6.cjs.prod.js');
7
7
 
8
8
 
@@ -51,9 +51,12 @@ exports.THEME_RADIUS_LENGTHS = dist_valbuildCore.THEME_RADIUS_LENGTHS;
51
51
  exports.THEME_RADIUS_STEPS = dist_valbuildCore.THEME_RADIUS_STEPS;
52
52
  exports.UNSAFE_URL_SCHEMES = dist_valbuildCore.UNSAFE_URL_SCHEMES;
53
53
  exports.VAL_EXTENSION = dist_valbuildCore.VAL_EXTENSION;
54
+ exports.VAL_PREVIEW_MESSAGES = dist_valbuildCore.VAL_PREVIEW_MESSAGES;
54
55
  exports.ValViewSchema = dist_valbuildCore.ValViewSchema;
55
56
  exports.VideoSchema = dist_valbuildCore.VideoSchema;
56
57
  exports.assistantAvailability = dist_valbuildCore.assistantAvailability;
58
+ exports.componentOfValue = dist_valbuildCore.componentOfValue;
59
+ exports.componentPropsOf = dist_valbuildCore.componentPropsOf;
57
60
  exports.computeSchemaSha = dist_valbuildCore.computeSchemaSha;
58
61
  exports.computeSourcesSha = dist_valbuildCore.computeSourcesSha;
59
62
  exports.computeValModuleShas = dist_valbuildCore.computeValModuleShas;
@@ -63,6 +66,7 @@ exports.describeSchemeRejection = dist_valbuildCore.describeSchemeRejection;
63
66
  exports.deserializeSchema = dist_valbuildCore.deserializeSchema;
64
67
  exports.discriminatedUnionBranchOf = dist_valbuildCore.discriminatedUnionBranchOf;
65
68
  exports.extractValModules = dist_valbuildCore.extractValModules;
69
+ exports.getComponentRender = dist_valbuildCore.getComponentRender;
66
70
  exports.getSourcePathFromRoute = dist_valbuildCore.getSourcePathFromRoute;
67
71
  exports.hasMediaSchema = dist_valbuildCore.hasMediaSchema;
68
72
  exports.hasRemoteFileSchema = dist_valbuildCore.hasRemoteFileSchema;
@@ -72,6 +76,7 @@ exports.isInlineRender = dist_valbuildCore.isInlineRender;
72
76
  exports.isPageRouter = dist_valbuildCore.isPageRouter;
73
77
  exports.isRootModuleFilePath = dist_valbuildCore.isRootModuleFilePath;
74
78
  exports.isValViewSource = dist_valbuildCore.isValViewSource;
79
+ exports.loadComponent = dist_valbuildCore.loadComponent;
75
80
  exports.localeOfValue = dist_valbuildCore.localeOfValue;
76
81
  exports.localeTagError = dist_valbuildCore.localeTagError;
77
82
  exports.matchRoutePattern = dist_valbuildCore.matchRoutePattern;
@@ -84,5 +89,6 @@ exports.rejectScheme = dist_valbuildCore.rejectScheme;
84
89
  exports.resolveSettingsModule = dist_valbuildCore.resolveSettingsModule;
85
90
  exports.routePatternOf = dist_valbuildCore.routePatternOf;
86
91
  exports.schemeOf = dist_valbuildCore.schemeOf;
92
+ exports.setComponentOfValue = dist_valbuildCore.setComponentOfValue;
87
93
  exports.tanStackSegmentsOfRoutePath = dist_valbuildCore.tanStackSegmentsOfRoutePath;
88
94
  exports.validateUrlAgainstPattern = dist_valbuildCore.validateUrlAgainstPattern;
@@ -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-d44e8db9.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, aB as UNSAFE_URL_SCHEMES, V as VAL_EXTENSION, ao as VAL_PREVIEW_MESSAGES, a9 as ValViewSchema, w as VideoSchema, L as assistantAvailability, an as componentOfValue, al as componentPropsOf, k as computeSchemaSha, j as computeSourcesSha, h as computeValModuleShas, $ as declaredKeySetOf, p as derefPatch, ax as describeSchemeRejection, ag as deserializeSchema, a1 as discriminatedUnionBranchOf, g as extractValModules, aj as getComponentRender, au as getSourcePathFromRoute, n as hasMediaSchema, l as hasRemoteFileSchema, i as initVal, ay as isCheckableScheme, ai as isInlineRender, av as isPageRouter, U as isRootModuleFilePath, aa as isValViewSource, ak as loadComponent, Y as localeOfValue, X as localeTagError, at as matchRoutePattern, a0 as missingDeclaredKeys, m as modules, ap as parseNextJsRoutePattern, aq as parseTanStackRoutePattern, ah as previewScope, az as rejectScheme, W as resolveSettingsModule, aw as routePatternOf, aA as schemeOf, am as setComponentOfValue, ar as tanStackSegmentsOfRoutePath, as as validateUrlAgainstPattern } from './index-676a0af1.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.153.0",
3
+ "version": "0.154.2",
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-8a50c651.cjs.dev.js');
5
+ var dist_valbuildCore = require('../../dist/index-48d6f61b.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