@valbuild/react 0.40.0 → 0.42.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.
Files changed (28) hide show
  1. package/dist/{ValProvider-396d7da7.cjs.dev.js → ValProvider-387a3070.cjs.dev.js} +46 -23
  2. package/dist/{ValProvider-05e0ada2.esm.js → ValProvider-52a0ce49.esm.js} +46 -23
  3. package/dist/ValProvider-8d8e3678.cjs.js +7 -0
  4. package/dist/{ValProvider-d9e0b778.cjs.prod.js → ValProvider-8d8e3678.cjs.prod.js} +46 -23
  5. package/dist/{ValProvider-9be9362b.browser.esm.js → ValProvider-9a2431d9.browser.esm.js} +46 -23
  6. package/dist/{ValProvider-e745414d.worker.esm.js → ValProvider-e21d3e7d.worker.esm.js} +46 -23
  7. package/dist/ValUI-0f2e6b7d.cjs.js +7 -0
  8. package/dist/{ValUI-41cd1ce0.cjs.prod.js → ValUI-0f2e6b7d.cjs.prod.js} +2 -2
  9. package/dist/{ValUI-400cffb5.worker.esm.js → ValUI-3fac1b71.worker.esm.js} +2 -2
  10. package/dist/{ValUI-053ef45d.browser.esm.js → ValUI-4d8bf402.browser.esm.js} +2 -2
  11. package/dist/{ValUI-0091169b.esm.js → ValUI-d0e6ed41.esm.js} +2 -2
  12. package/dist/{ValUI-3a6c5666.cjs.dev.js → ValUI-ec9857f2.cjs.dev.js} +2 -2
  13. package/dist/declarations/src/internal/ValStore.d.ts +1 -0
  14. package/dist/declarations/src/stega/index.d.ts +1 -1
  15. package/dist/declarations/src/stega/stegaEncode.d.ts +133 -2
  16. package/internal/dist/valbuild-react-internal.browser.esm.js +1 -1
  17. package/internal/dist/valbuild-react-internal.cjs.dev.js +1 -1
  18. package/internal/dist/valbuild-react-internal.cjs.prod.js +1 -1
  19. package/internal/dist/valbuild-react-internal.esm.js +1 -1
  20. package/internal/dist/valbuild-react-internal.worker.esm.js +1 -1
  21. package/package.json +4 -4
  22. package/stega/dist/valbuild-react-stega.browser.esm.js +69 -16
  23. package/stega/dist/valbuild-react-stega.cjs.dev.js +69 -15
  24. package/stega/dist/valbuild-react-stega.cjs.prod.js +69 -15
  25. package/stega/dist/valbuild-react-stega.esm.js +69 -16
  26. package/stega/dist/valbuild-react-stega.worker.esm.js +69 -16
  27. package/dist/ValProvider-d9e0b778.cjs.js +0 -7
  28. package/dist/ValUI-41cd1ce0.cjs.js +0 -7
@@ -452,21 +452,23 @@ var ValStore = /*#__PURE__*/function () {
452
452
  this.subscribers = new Map();
453
453
  this.listeners = {};
454
454
  }
455
-
456
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
457
455
  _createClass(ValStore, [{
458
456
  key: "update",
459
457
  value: function () {
460
458
  var _update = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(moduleIds) {
459
+ var _this2 = this;
461
460
  return _regeneratorRuntime().wrap(function _callee$(_context) {
462
461
  while (1) switch (_context.prev = _context.next) {
463
462
  case 0:
464
- return _context.abrupt("return", this.updateAll());
465
- case 1:
463
+ _context.next = 2;
464
+ return Promise.all(moduleIds.map(function (moduleId) {
465
+ return _this2.updateTree(moduleId);
466
+ }));
467
+ case 2:
466
468
  case "end":
467
469
  return _context.stop();
468
470
  }
469
- }, _callee, this);
471
+ }, _callee);
470
472
  }));
471
473
  function update(_x) {
472
474
  return _update.apply(this, arguments);
@@ -477,27 +479,48 @@ var ValStore = /*#__PURE__*/function () {
477
479
  key: "updateAll",
478
480
  value: function () {
479
481
  var _updateAll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
482
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
483
+ while (1) switch (_context2.prev = _context2.next) {
484
+ case 0:
485
+ _context2.next = 2;
486
+ return this.updateTree();
487
+ case 2:
488
+ case "end":
489
+ return _context2.stop();
490
+ }
491
+ }, _callee2, this);
492
+ }));
493
+ function updateAll() {
494
+ return _updateAll.apply(this, arguments);
495
+ }
496
+ return updateAll;
497
+ }()
498
+ }, {
499
+ key: "updateTree",
500
+ value: function () {
501
+ var _updateTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(treePath) {
480
502
  var data, updatedSubscriberIds, subscriberIds, _loop, _i, _arr, _i2, _Array$from, _Array$from$_i, updatedSubscriberId, moduleIds, subscriberModules;
481
- return _regeneratorRuntime().wrap(function _callee2$(_context3) {
482
- while (1) switch (_context3.prev = _context3.next) {
503
+ return _regeneratorRuntime().wrap(function _callee3$(_context4) {
504
+ while (1) switch (_context4.prev = _context4.next) {
483
505
  case 0:
484
- _context3.next = 2;
506
+ _context4.next = 2;
485
507
  return this.api.getTree({
508
+ treePath: treePath,
486
509
  patch: true,
487
510
  includeSource: true
488
511
  });
489
512
  case 2:
490
- data = _context3.sent;
513
+ data = _context4.sent;
491
514
  if (!result.isOk(data)) {
492
- _context3.next = 16;
515
+ _context4.next = 16;
493
516
  break;
494
517
  }
495
518
  updatedSubscriberIds = new Map();
496
519
  subscriberIds = Array.from(this.subscribers.keys()); // Figure out which modules have been updated and map to updated subscribed id
497
520
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
498
521
  var moduleId, source, updatedSubscriberId;
499
- return _regeneratorRuntime().wrap(function _loop$(_context2) {
500
- while (1) switch (_context2.prev = _context2.next) {
522
+ return _regeneratorRuntime().wrap(function _loop$(_context3) {
523
+ while (1) switch (_context3.prev = _context3.next) {
501
524
  case 0:
502
525
  moduleId = _arr[_i];
503
526
  source = data.value.modules[moduleId].source;
@@ -513,20 +536,20 @@ var ValStore = /*#__PURE__*/function () {
513
536
  }
514
537
  case 3:
515
538
  case "end":
516
- return _context2.stop();
539
+ return _context3.stop();
517
540
  }
518
541
  }, _loop);
519
542
  });
520
543
  _i = 0, _arr = Object.keys(data.value.modules);
521
544
  case 8:
522
545
  if (!(_i < _arr.length)) {
523
- _context3.next = 13;
546
+ _context4.next = 13;
524
547
  break;
525
548
  }
526
- return _context3.delegateYield(_loop(), "t0", 10);
549
+ return _context4.delegateYield(_loop(), "t0", 10);
527
550
  case 10:
528
551
  _i++;
529
- _context3.next = 8;
552
+ _context4.next = 8;
530
553
  break;
531
554
  case 13:
532
555
  // For all updated subscribers: set new module data and emit change
@@ -542,20 +565,20 @@ var ValStore = /*#__PURE__*/function () {
542
565
  this.subscribers.set(updatedSubscriberId, subscriberModules);
543
566
  this.emitChange(updatedSubscriberId);
544
567
  }
545
- _context3.next = 17;
568
+ _context4.next = 17;
546
569
  break;
547
570
  case 16:
548
571
  console.error("Val: failed to update modules", data.error);
549
572
  case 17:
550
573
  case "end":
551
- return _context3.stop();
574
+ return _context4.stop();
552
575
  }
553
- }, _callee2, this);
576
+ }, _callee3, this);
554
577
  }));
555
- function updateAll() {
556
- return _updateAll.apply(this, arguments);
578
+ function updateTree(_x2) {
579
+ return _updateTree.apply(this, arguments);
557
580
  }
558
- return updateAll;
581
+ return updateTree;
559
582
  }()
560
583
  }, {
561
584
  key: "emitChange",
@@ -592,7 +615,7 @@ var useValApi = function useValApi() {
592
615
  };
593
616
  var ValContext = undefined;
594
617
  var ValUI = /*#__PURE__*/lazy(function () {
595
- return import('./ValUI-400cffb5.worker.esm.js');
618
+ return import('./ValUI-3fac1b71.worker.esm.js');
596
619
  });
597
620
  function ValProvider(_ref) {
598
621
  var children = _ref.children,
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === "production") {
4
+ module.exports = require("./ValUI-0f2e6b7d.cjs.prod.js");
5
+ } else {
6
+ module.exports = require("./ValUI-0f2e6b7d.cjs.dev.js");
7
+ }
@@ -8,7 +8,7 @@ var slicedToArray = require('./slicedToArray-a2a426c7.cjs.prod.js');
8
8
  var React = require('react');
9
9
  var reactDom = require('react-dom');
10
10
  var ReactJSXRuntime = require('react/jsx-runtime');
11
- var ValProvider = require('./ValProvider-d9e0b778.cjs.prod.js');
11
+ var ValProvider = require('./ValProvider-8d8e3678.cjs.prod.js');
12
12
 
13
13
  function ShadowContent(_ref) {
14
14
  var root = _ref.root,
@@ -74,7 +74,7 @@ function ValUI(props) {
74
74
  href: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",
75
75
  rel: "stylesheet"
76
76
  }), /*#__PURE__*/ReactJSXRuntime.jsx(ui.Style, {
77
- route: props === null || props === void 0 ? void 0 : props.host
77
+ route: props.host
78
78
  }), /*#__PURE__*/ReactJSXRuntime.jsx(ui.ValOverlay, {
79
79
  api: api,
80
80
  store: store,
@@ -4,7 +4,7 @@ import { _ as _slicedToArray } from './slicedToArray-d4c4a4ed.worker.esm.js';
4
4
  import { useRef, useState, useLayoutEffect } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import { useValApi, useValStore } from './ValProvider-e745414d.worker.esm.js';
7
+ import { useValApi, useValStore } from './ValProvider-e21d3e7d.worker.esm.js';
8
8
 
9
9
  function ShadowContent(_ref) {
10
10
  var root = _ref.root,
@@ -70,7 +70,7 @@ function ValUI(props) {
70
70
  href: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",
71
71
  rel: "stylesheet"
72
72
  }), /*#__PURE__*/jsx(Style, {
73
- route: props === null || props === void 0 ? void 0 : props.host
73
+ route: props.host
74
74
  }), /*#__PURE__*/jsx(ValOverlay, {
75
75
  api: api,
76
76
  store: store,
@@ -4,7 +4,7 @@ import { _ as _slicedToArray } from './slicedToArray-85f6bb43.browser.esm.js';
4
4
  import { useRef, useState, useLayoutEffect } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import { useValApi, useValStore } from './ValProvider-9be9362b.browser.esm.js';
7
+ import { useValApi, useValStore } from './ValProvider-9a2431d9.browser.esm.js';
8
8
 
9
9
  function ShadowContent(_ref) {
10
10
  var root = _ref.root,
@@ -70,7 +70,7 @@ function ValUI(props) {
70
70
  href: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",
71
71
  rel: "stylesheet"
72
72
  }), /*#__PURE__*/jsx(Style, {
73
- route: props === null || props === void 0 ? void 0 : props.host
73
+ route: props.host
74
74
  }), /*#__PURE__*/jsx(ValOverlay, {
75
75
  api: api,
76
76
  store: store,
@@ -4,7 +4,7 @@ import { _ as _slicedToArray } from './slicedToArray-331bebbb.esm.js';
4
4
  import { useRef, useState, useLayoutEffect } from 'react';
5
5
  import { createPortal } from 'react-dom';
6
6
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
7
- import { useValApi, useValStore } from './ValProvider-05e0ada2.esm.js';
7
+ import { useValApi, useValStore } from './ValProvider-52a0ce49.esm.js';
8
8
 
9
9
  function ShadowContent(_ref) {
10
10
  var root = _ref.root,
@@ -70,7 +70,7 @@ function ValUI(props) {
70
70
  href: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",
71
71
  rel: "stylesheet"
72
72
  }), /*#__PURE__*/jsx(Style, {
73
- route: props === null || props === void 0 ? void 0 : props.host
73
+ route: props.host
74
74
  }), /*#__PURE__*/jsx(ValOverlay, {
75
75
  api: api,
76
76
  store: store,
@@ -8,7 +8,7 @@ var slicedToArray = require('./slicedToArray-a9d0d9cd.cjs.dev.js');
8
8
  var React = require('react');
9
9
  var reactDom = require('react-dom');
10
10
  var ReactJSXRuntime = require('react/jsx-runtime');
11
- var ValProvider = require('./ValProvider-396d7da7.cjs.dev.js');
11
+ var ValProvider = require('./ValProvider-387a3070.cjs.dev.js');
12
12
 
13
13
  function ShadowContent(_ref) {
14
14
  var root = _ref.root,
@@ -74,7 +74,7 @@ function ValUI(props) {
74
74
  href: "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;1,100;1,300;1,400;1,500;1,700&family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap",
75
75
  rel: "stylesheet"
76
76
  }), /*#__PURE__*/ReactJSXRuntime.jsx(ui.Style, {
77
- route: props === null || props === void 0 ? void 0 : props.host
77
+ route: props.host
78
78
  }), /*#__PURE__*/ReactJSXRuntime.jsx(ui.ValOverlay, {
79
79
  api: api,
80
80
  store: store,
@@ -7,6 +7,7 @@ export declare class ValStore implements IValStore {
7
7
  constructor(api: ValApi);
8
8
  update(moduleIds: ModuleId[]): Promise<void>;
9
9
  updateAll(): Promise<void>;
10
+ updateTree(treePath?: string): Promise<void>;
10
11
  subscribe: (moduleIds: ModuleId[]) => (listener: () => void) => () => void;
11
12
  private emitChange;
12
13
  getSnapshot: (moduleIds: ModuleId[]) => () => Record<ModuleId, Json> | undefined;
@@ -1,2 +1,2 @@
1
1
  export { autoTagJSX } from "./autoTagJSX.js";
2
- export { stegaEncode, getModuleIds, type ValEncodedString, type StegaOfSource, } from "./stegaEncode.js";
2
+ export { stegaEncode, getModuleIds, stegaClean, type ValEncodedString, type StegaOfSource, } from "./stegaEncode.js";
@@ -12,14 +12,145 @@ declare const brand: unique symbol;
12
12
  * where the content comes from for contextual editing.
13
13
  *
14
14
  */
15
- export type ValEncodedString = string & {
15
+ export type ValEncodedString = `${string}__VAL_ENCODED_STRING_INVISIBLE_CHARS` & {
16
+ /**
17
+ *
18
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
19
+ *
20
+ * Instead, get the raw string using `val.raw`
21
+ *
22
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
23
+ *
24
+ * @example
25
+ * val.raw(myEncodedString) // returns a normal string
26
+ */
27
+ substring: never;
28
+ /**
29
+ *
30
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
31
+ *
32
+ * Instead, get the raw string using `val.raw`
33
+ *
34
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
35
+ *
36
+ * @example
37
+ * val.raw(myEncodedString) // returns a normal string
38
+ */
39
+ match: never;
40
+ /**
41
+ *
42
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
43
+ *
44
+ * Instead, get the raw string using `val.raw`
45
+ *
46
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
47
+ *
48
+ * @example
49
+ * val.raw(myEncodedString) // returns a normal string
50
+ */
51
+ charAt: never;
52
+ /**
53
+ *
54
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
55
+ *
56
+ * Instead, get the raw string using `val.raw`
57
+ *
58
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
59
+ *
60
+ * @example
61
+ * val.raw(myEncodedString) // returns a normal string
62
+ */
63
+ charCodeAt: never;
64
+ /**
65
+ *
66
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
67
+ *
68
+ * Instead, get the raw string using `val.raw`
69
+ *
70
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
71
+ *
72
+ * @example
73
+ * val.raw(myEncodedString) // returns a normal string
74
+ */
75
+ concat: never;
76
+ /**
77
+ *
78
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
79
+ *
80
+ * Instead, get the raw string using `val.raw`
81
+ *
82
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
83
+ *
84
+ * @example
85
+ * val.raw(myEncodedString) // returns a normal string
86
+ */
87
+ indexOf: never;
88
+ /**
89
+ *
90
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
91
+ *
92
+ * Instead, get the raw string using `val.raw`
93
+ *
94
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
95
+ *
96
+ * @example
97
+ * val.raw(myEncodedString) // returns a normal string
98
+ */
99
+ lastIndexOf: never;
100
+ /**
101
+ *
102
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
103
+ *
104
+ * Instead, get the raw string using `val.raw`
105
+ *
106
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
107
+ *
108
+ * @example
109
+ * val.raw(myEncodedString) // returns a normal string
110
+ */
111
+ slice: never;
112
+ /**
113
+ *
114
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
115
+ *
116
+ * Instead, get the raw string using `val.raw`
117
+ *
118
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
119
+ *
120
+ * @example
121
+ * val.raw(myEncodedString) // returns a normal string
122
+ */
123
+ toString: never;
124
+ /**
125
+ *
126
+ * NB: This is a Val ENCODED string, which means that you should not use this method.
127
+ *
128
+ * Instead, get the raw string using `val.raw`
129
+ *
130
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
131
+ *
132
+ * @example
133
+ * val.raw(myEncodedString) // returns a normal string
134
+ */
135
+ /**
136
+ *
137
+ * NB: This is a Val ENCODED string, which means that you should not use length on it.
138
+ *
139
+ * Instead, get the raw string using `val.raw`
140
+ *
141
+ * @deprecated NB: This is a Val ENCODED string, which means that you should not use this method.
142
+ *
143
+ * @example
144
+ * val.raw(myEncodedString) // returns a normal string
145
+ */
146
+ length: never;
16
147
  [brand]: "ValEncodedString";
17
148
  };
18
149
  export type StegaOfSource<T extends Source> = Json extends T ? Json : T extends RichTextSource<infer O> ? RichText<O> : T extends FileSource ? {
19
150
  url: ValEncodedString;
20
151
  } : T extends SourceObject ? {
21
152
  [key in keyof T]: StegaOfSource<T[key]>;
22
- } : T extends SourceArray ? StegaOfSource<T[number]>[] : T extends RawString ? string : T extends string ? ValEncodedString : T extends JsonPrimitive ? T : never;
153
+ } : T extends SourceArray ? StegaOfSource<T[number]>[] : T extends RawString ? string : string extends T ? ValEncodedString : T extends JsonPrimitive ? T : never;
23
154
  export declare function stegaEncode(input: any, opts: {
24
155
  getModule?: (moduleId: string) => any;
25
156
  disabled?: boolean;
@@ -1,4 +1,4 @@
1
- export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-9be9362b.browser.esm.js';
1
+ export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-9a2431d9.browser.esm.js';
2
2
  import React from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ValProvider = require('../../dist/ValProvider-396d7da7.cjs.dev.js');
5
+ var ValProvider = require('../../dist/ValProvider-387a3070.cjs.dev.js');
6
6
  var React = require('react');
7
7
  var ReactJSXRuntime = require('react/jsx-runtime');
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ValProvider = require('../../dist/ValProvider-d9e0b778.cjs.prod.js');
5
+ var ValProvider = require('../../dist/ValProvider-8d8e3678.cjs.prod.js');
6
6
  var React = require('react');
7
7
  var ReactJSXRuntime = require('react/jsx-runtime');
8
8
 
@@ -1,4 +1,4 @@
1
- export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-05e0ada2.esm.js';
1
+ export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-52a0ce49.esm.js';
2
2
  import React from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
@@ -1,4 +1,4 @@
1
- export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-e745414d.worker.esm.js';
1
+ export { ValProvider, useValApi, useValStore } from '../../dist/ValProvider-e21d3e7d.worker.esm.js';
2
2
  import React from 'react';
3
3
  import { jsx } from 'react/jsx-runtime';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/react",
3
- "version": "0.40.0",
3
+ "version": "0.42.0",
4
4
  "private": false,
5
5
  "description": "Val - React internal helpers",
6
6
  "sideEffects": false,
@@ -9,9 +9,9 @@
9
9
  "test": "jest"
10
10
  },
11
11
  "dependencies": {
12
- "@valbuild/core": "~0.40.0",
13
- "@valbuild/shared": "~0.40.0",
14
- "@valbuild/ui": "~0.40.0",
12
+ "@valbuild/core": "~0.42.0",
13
+ "@valbuild/shared": "~0.42.0",
14
+ "@valbuild/ui": "~0.42.0",
15
15
  "@vercel/stega": "^0.1.0",
16
16
  "base64-arraybuffer": "^1.0.2",
17
17
  "style-to-object": "^0.4.1"
@@ -101,6 +101,41 @@ function _objectSpread2(e) {
101
101
 
102
102
  function stegaEncode(input, opts) {
103
103
  function rec(sourceOrSelector, recOpts) {
104
+ if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isUnionSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
105
+ if (sourceOrSelector && _typeof(sourceOrSelector) === "object" && recOpts.schema.key) {
106
+ var _key = sourceOrSelector[recOpts.schema.key];
107
+ if (_key) {
108
+ var schema = recOpts.schema.items.find(function (s) {
109
+ if (isObjectSchema(s) && s.items && s.items[recOpts.schema.key]) {
110
+ var keySchema = s.items[recOpts.schema.key];
111
+ if (isLiteralSchema(keySchema)) {
112
+ return keySchema.value === _key;
113
+ } else {
114
+ console.warn("Expected literal schema at key in , but found: ", keySchema, {
115
+ key: _key,
116
+ schema: s
117
+ });
118
+ }
119
+ } else {
120
+ console.warn("Expected union containing object schema, but found: ", s);
121
+ }
122
+ });
123
+ if (schema) {
124
+ return rec(sourceOrSelector, {
125
+ path: recOpts.path,
126
+ schema: schema
127
+ });
128
+ }
129
+ }
130
+ } else {
131
+ return rec(sourceOrSelector, {
132
+ path: recOpts.path,
133
+ schema: recOpts.schema.items.find(function (s) {
134
+ return isLiteralSchema(s) && s.value === sourceOrSelector;
135
+ })
136
+ });
137
+ }
138
+ }
104
139
  if (_typeof(sourceOrSelector) === "object") {
105
140
  if (!sourceOrSelector) {
106
141
  return null;
@@ -110,7 +145,7 @@ function stegaEncode(input, opts) {
110
145
  var newSchema = Internal.getSchema(sourceOrSelector);
111
146
  return rec(opts.getModule && opts.getModule(selectorPath) || Internal.getSource(sourceOrSelector), opts.disabled ? undefined : {
112
147
  path: selectorPath,
113
- schema: newSchema
148
+ schema: newSchema === null || newSchema === void 0 ? void 0 : newSchema.serialize()
114
149
  });
115
150
  }
116
151
  if (VAL_EXTENSION in sourceOrSelector) {
@@ -141,28 +176,27 @@ function stegaEncode(input, opts) {
141
176
  }
142
177
  if (!Array.isArray(sourceOrSelector)) {
143
178
  var res = {};
144
- for (var _i = 0, _Object$entries = Object.entries(sourceOrSelector); _i < _Object$entries.length; _i++) {
145
- var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
146
- _key = _Object$entries$_i[0],
147
- value = _Object$entries$_i[1];
148
- res[_key] = rec(value, recOpts && {
149
- path: Internal.createValPathOfItem(recOpts.path, _key),
150
- schema: recOpts.schema.item ||
151
- // Record
152
- recOpts.schema.items[_key] // Object
179
+ var entries = Object.entries(sourceOrSelector);
180
+ for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
181
+ var _entries$_i = _slicedToArray(_entries[_i], 2),
182
+ _key2 = _entries$_i[0],
183
+ value = _entries$_i[1];
184
+ res[_key2] = rec(value, (recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema) && {
185
+ path: Internal.createValPathOfItem(recOpts.path, _key2),
186
+ schema: isRecordSchema(recOpts.schema) ? recOpts.schema.item : isObjectSchema(recOpts.schema) ? recOpts.schema.items[_key2] : unknownSchema(recOpts.schema)
153
187
  });
154
188
  }
155
-
156
189
  return res;
157
190
  }
158
191
  console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
159
192
  return sourceOrSelector;
160
193
  }
161
194
  if (typeof sourceOrSelector === "string") {
195
+ var _recOpts$schema, _recOpts$schema2;
162
196
  if (!recOpts) {
163
197
  return sourceOrSelector;
164
198
  }
165
- if (recOpts.schema.isRaw) {
199
+ if ((_recOpts$schema = recOpts.schema) !== null && _recOpts$schema !== void 0 && _recOpts$schema.raw || ((_recOpts$schema2 = recOpts.schema) === null || _recOpts$schema2 === void 0 ? void 0 : _recOpts$schema2.type) === "literal") {
166
200
  return sourceOrSelector;
167
201
  }
168
202
  return vercelStegaCombine(sourceOrSelector, {
@@ -182,6 +216,25 @@ function stegaEncode(input, opts) {
182
216
  }
183
217
  return rec(input);
184
218
  }
219
+ function isRecordSchema(schema) {
220
+ return (schema === null || schema === void 0 ? void 0 : schema.type) === "record";
221
+ }
222
+ function isLiteralSchema(schema) {
223
+ return (schema === null || schema === void 0 ? void 0 : schema.type) === "literal";
224
+ }
225
+ function unknownSchema(schema) {
226
+ console.debug("Found unknown schema", schema);
227
+ return schema;
228
+ }
229
+ function isUnionSchema(schema) {
230
+ return (schema === null || schema === void 0 ? void 0 : schema.type) === "union";
231
+ }
232
+ function isObjectSchema(schema) {
233
+ return (schema === null || schema === void 0 ? void 0 : schema.type) === "object";
234
+ }
235
+ function stegaClean(source) {
236
+ return vercelStegaSplit(source).cleaned;
237
+ }
185
238
  function getModuleIds(input) {
186
239
  var modules = new Set();
187
240
  function rec(sourceOrSelector) {
@@ -209,9 +262,9 @@ function getModuleIds(input) {
209
262
  return;
210
263
  }
211
264
  if (!Array.isArray(sourceOrSelector)) {
212
- for (var _i2 = 0, _Object$entries2 = Object.entries(sourceOrSelector); _i2 < _Object$entries2.length; _i2++) {
213
- var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
214
- value = _Object$entries2$_i[1];
265
+ for (var _i2 = 0, _Object$entries = Object.entries(sourceOrSelector); _i2 < _Object$entries.length; _i2++) {
266
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
267
+ value = _Object$entries$_i[1];
215
268
  rec(value);
216
269
  }
217
270
  return;
@@ -232,4 +285,4 @@ function getModuleIds(input) {
232
285
  return Array.from(modules);
233
286
  }
234
287
 
235
- export { autoTagJSX, getModuleIds, stegaEncode };
288
+ export { autoTagJSX, getModuleIds, stegaClean, stegaEncode };