@valbuild/react 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ValUI-3e00aae3.cjs.prod.js +104 -0
- package/dist/ValUI-64e3e5f2.browser.esm.js +102 -0
- package/dist/ValUI-9ac161d2.cjs.dev.js +104 -0
- package/dist/ValUI-d33998d0.esm.js +102 -0
- package/dist/declarations/src/ValProvider.d.ts +1 -1
- package/dist/declarations/src/ValStore.d.ts +8 -9
- package/dist/declarations/src/index.d.ts +1 -2
- package/dist/declarations/src/stega/index.d.ts +1 -3
- package/dist/declarations/src/stega/{stegaEncode.d.ts → transform.d.ts} +8 -5
- package/dist/{defineProperty-12b5bd29.esm.js → defineProperty-034d0378.browser.esm.js} +1 -1
- package/dist/{defineProperty-a4bf59bc.worker.esm.js → defineProperty-18559492.worker.esm.js} +1 -1
- package/dist/{defineProperty-f319cb47.browser.esm.js → defineProperty-b209a901.esm.js} +1 -1
- package/dist/{slicedToArray-d846e1d2.esm.js → slicedToArray-0cbb3d34.browser.esm.js} +13 -10
- package/dist/{slicedToArray-9e7d1407.worker.esm.js → slicedToArray-5a51fd33.worker.esm.js} +13 -10
- package/dist/{slicedToArray-b7cf26e0.cjs.dev.js → slicedToArray-5bddfa58.cjs.prod.js} +14 -11
- package/dist/slicedToArray-7b1713a7.cjs.dev.js +59 -0
- package/dist/{slicedToArray-1a246338.browser.esm.js → slicedToArray-b4fb91fa.esm.js} +13 -10
- package/dist/typeof-16c77f45.cjs.prod.js +13 -0
- package/dist/typeof-1de657a3.cjs.dev.js +13 -0
- package/dist/typeof-52fabea9.browser.esm.js +11 -0
- package/dist/typeof-5c86a240.esm.js +11 -0
- package/dist/typeof-8854ace1.worker.esm.js +11 -0
- package/dist/valbuild-react.browser.esm.js +618 -24
- package/dist/valbuild-react.cjs.dev.js +621 -28
- package/dist/valbuild-react.cjs.prod.js +621 -28
- package/dist/valbuild-react.esm.js +618 -24
- package/dist/valbuild-react.worker.esm.js +616 -24
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.browser.esm.js +2 -2
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.dev.js +3 -3
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.cjs.prod.js +3 -3
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.esm.js +2 -2
- package/jsx-dev-runtime/dist/valbuild-react-jsx-dev-runtime.worker.esm.js +2 -2
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.browser.esm.js +2 -2
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.dev.js +3 -3
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.cjs.prod.js +3 -3
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.esm.js +2 -2
- package/jsx-runtime/dist/valbuild-react-jsx-runtime.worker.esm.js +2 -2
- package/package.json +3 -3
- package/src/ValProvider.tsx +2 -3
- package/src/ValStore.ts +90 -40
- package/src/ValUI.tsx +49 -339
- package/src/index.ts +1 -2
- package/src/stega/autoTagJSX.ts +1 -1
- package/src/stega/index.ts +6 -3
- package/src/stega/transform.test.ts +145 -0
- package/src/stega/transform.ts +220 -0
- package/stega/dist/valbuild-react-stega.browser.esm.js +131 -46
- package/stega/dist/valbuild-react-stega.cjs.dev.js +134 -49
- package/stega/dist/valbuild-react-stega.cjs.prod.js +134 -49
- package/stega/dist/valbuild-react-stega.esm.js +131 -46
- package/stega/dist/valbuild-react-stega.worker.esm.js +109 -45
- package/dist/ValProvider-061ff397.cjs.dev.js +0 -715
- package/dist/ValProvider-b46efd66.browser.esm.js +0 -701
- package/dist/ValProvider-cb5a2161.worker.esm.js +0 -696
- package/dist/ValProvider-d7afb84b.cjs.js +0 -7
- package/dist/ValProvider-d7afb84b.cjs.prod.js +0 -715
- package/dist/ValProvider-fa35f7bd.esm.js +0 -701
- package/dist/ValUI-0bb9cc3d.cjs.prod.js +0 -383
- package/dist/ValUI-11cf8753.cjs.dev.js +0 -383
- package/dist/ValUI-13a58fa9.browser.esm.js +0 -381
- package/dist/ValUI-3d3b0d68.esm.js +0 -381
- package/dist/declarations/src/ValApi.d.ts +0 -12
- package/dist/declarations/src/hooks/useVal.d.ts +0 -3
- package/dist/declarations/src/stega/fetchVal.d.ts +0 -3
- package/dist/declarations/src/stega/hooks/useVal.d.ts +0 -3
- package/dist/objectSpread2-30cc2856.browser.esm.js +0 -25
- package/dist/objectSpread2-61fbd9a9.cjs.dev.js +0 -27
- package/dist/objectSpread2-7b752a35.cjs.prod.js +0 -27
- package/dist/objectSpread2-d5a1fe1c.esm.js +0 -25
- package/dist/slicedToArray-0eb0bcdb.cjs.prod.js +0 -56
- package/dist/unsupportedIterableToArray-51bb61c2.esm.js +0 -16
- package/dist/unsupportedIterableToArray-738344ef.worker.esm.js +0 -16
- package/dist/unsupportedIterableToArray-9e97e24a.cjs.dev.js +0 -18
- package/dist/unsupportedIterableToArray-afbea1dd.cjs.prod.js +0 -18
- package/dist/unsupportedIterableToArray-d3087ed5.browser.esm.js +0 -16
- package/src/AuthStatus.tsx +0 -13
- package/src/ValApi.ts +0 -65
- package/src/hooks/useVal.test.tsx +0 -57
- package/src/hooks/useVal.ts +0 -35
- package/src/stega/fetchVal.ts +0 -16
- package/src/stega/hooks/useVal.ts +0 -14
- package/src/stega/stegaEncode.ts +0 -84
@@ -2,16 +2,14 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var slicedToArray = require('../../dist/slicedToArray-
|
5
|
+
var slicedToArray = require('../../dist/slicedToArray-5bddfa58.cjs.prod.js');
|
6
|
+
var _typeof = require('../../dist/typeof-16c77f45.cjs.prod.js');
|
6
7
|
var ReactJSXRuntime = require('react/jsx-runtime');
|
7
8
|
var jsxRuntimeDev = require('react/jsx-dev-runtime');
|
8
9
|
var React = require('react');
|
9
10
|
var stega = require('@vercel/stega');
|
10
|
-
var
|
11
|
+
var defineProperty = require('../../dist/defineProperty-36ed93cd.cjs.prod.js');
|
11
12
|
var core = require('@valbuild/core');
|
12
|
-
var react = require('@valbuild/react');
|
13
|
-
require('../../dist/unsupportedIterableToArray-afbea1dd.cjs.prod.js');
|
14
|
-
require('../../dist/defineProperty-36ed93cd.cjs.prod.js');
|
15
13
|
|
16
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
17
15
|
|
@@ -25,21 +23,21 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
|
|
25
23
|
};
|
26
24
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
27
25
|
var valSources = [];
|
28
|
-
if (isIntrinsicElement(type) && props &&
|
26
|
+
if (isIntrinsicElement(type) && props && _typeof._typeof(props) === "object") {
|
29
27
|
for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
|
30
28
|
var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
|
31
29
|
key = _Object$entries$_i[0],
|
32
30
|
value = _Object$entries$_i[1];
|
33
31
|
if (typeof value === "string" && value.match(stega.VERCEL_STEGA_REGEX)) {
|
34
32
|
var encodedBits = stega.vercelStegaDecode(value);
|
35
|
-
if (!encodedBits ||
|
36
|
-
if ("origin" in encodedBits && "data" in encodedBits &&
|
33
|
+
if (!encodedBits || _typeof._typeof(encodedBits) !== "object") continue;
|
34
|
+
if ("origin" in encodedBits && "data" in encodedBits && _typeof._typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data) {
|
37
35
|
var _encodedBits$data;
|
38
36
|
var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
|
39
37
|
if (valPath) {
|
40
|
-
console.log("Found encoded valPath", valPath);
|
41
38
|
valSources.push(valPath);
|
42
39
|
props[key] = stega.vercelStegaSplit(value).cleaned;
|
40
|
+
props["data-val-attr-".concat(key)] = valPath;
|
43
41
|
}
|
44
42
|
}
|
45
43
|
}
|
@@ -79,6 +77,28 @@ function autoTagJSX() {
|
|
79
77
|
JsxPro.jsxDEV && ( /**/JsxPro.jsxDEV = WrapJsx(JsxPro.jsxDEV));
|
80
78
|
}
|
81
79
|
|
80
|
+
function ownKeys(object, enumerableOnly) {
|
81
|
+
var keys = Object.keys(object);
|
82
|
+
if (Object.getOwnPropertySymbols) {
|
83
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
84
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
85
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
86
|
+
})), keys.push.apply(keys, symbols);
|
87
|
+
}
|
88
|
+
return keys;
|
89
|
+
}
|
90
|
+
function _objectSpread2(target) {
|
91
|
+
for (var i = 1; i < arguments.length; i++) {
|
92
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
93
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
94
|
+
defineProperty._defineProperty(target, key, source[key]);
|
95
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
96
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
97
|
+
});
|
98
|
+
}
|
99
|
+
return target;
|
100
|
+
}
|
101
|
+
|
82
102
|
/**
|
83
103
|
* ValEncodedString is a string that is encoded using steganography.
|
84
104
|
*
|
@@ -88,52 +108,117 @@ function autoTagJSX() {
|
|
88
108
|
*
|
89
109
|
*/
|
90
110
|
|
91
|
-
function
|
92
|
-
|
93
|
-
if (
|
94
|
-
|
95
|
-
|
111
|
+
function transform(input, opts) {
|
112
|
+
function rec(sourceOrSelector, path) {
|
113
|
+
if (_typeof._typeof(sourceOrSelector) === "object") {
|
114
|
+
var selectorPath = core.Internal.getValPath(sourceOrSelector);
|
115
|
+
if (selectorPath) {
|
116
|
+
return rec(opts.getModule && opts.getModule(selectorPath) || core.Internal.getSource(sourceOrSelector), opts.disabled ? undefined : selectorPath);
|
117
|
+
}
|
118
|
+
if (!sourceOrSelector) {
|
119
|
+
return null;
|
120
|
+
}
|
121
|
+
if (core.VAL_EXTENSION in sourceOrSelector) {
|
122
|
+
if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
|
123
|
+
return _objectSpread2(_objectSpread2({}, sourceOrSelector), {}, {
|
124
|
+
valPath: path
|
125
|
+
});
|
126
|
+
}
|
127
|
+
if (sourceOrSelector[core.VAL_EXTENSION] === "file" && typeof sourceOrSelector[core.FILE_REF_PROP] === "string") {
|
128
|
+
var fileSelector = core.Internal.convertFileSource(sourceOrSelector);
|
129
|
+
return _objectSpread2(_objectSpread2({}, fileSelector), {}, {
|
130
|
+
url: rec(fileSelector.url, path)
|
131
|
+
});
|
132
|
+
}
|
133
|
+
console.error("Encountered unexpected extension: ".concat(sourceOrSelector[core.VAL_EXTENSION]));
|
134
|
+
return sourceOrSelector;
|
135
|
+
}
|
136
|
+
if (Array.isArray(sourceOrSelector)) {
|
137
|
+
return sourceOrSelector.map(function (el, i) {
|
138
|
+
return rec(el, path && core.Internal.createValPathOfItem(path, i));
|
139
|
+
});
|
140
|
+
}
|
141
|
+
if (!Array.isArray(sourceOrSelector)) {
|
142
|
+
var res = {};
|
143
|
+
for (var _i = 0, _Object$entries = Object.entries(sourceOrSelector); _i < _Object$entries.length; _i++) {
|
144
|
+
var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
|
145
|
+
_key = _Object$entries$_i[0],
|
146
|
+
value = _Object$entries$_i[1];
|
147
|
+
res[_key] = rec(value, path && core.Internal.createValPathOfItem(path, _key));
|
148
|
+
}
|
149
|
+
return res;
|
150
|
+
}
|
151
|
+
console.error("Could not transform source selector: ".concat(_typeof._typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
|
152
|
+
return sourceOrSelector;
|
96
153
|
}
|
97
|
-
if (
|
98
|
-
return
|
99
|
-
|
100
|
-
|
101
|
-
|
154
|
+
if (typeof sourceOrSelector === "string") {
|
155
|
+
return stega.vercelStegaCombine(sourceOrSelector, {
|
156
|
+
origin: "val.build",
|
157
|
+
data: {
|
158
|
+
valPath: path
|
159
|
+
}
|
160
|
+
}, false // auto detection on urls and dates is disabled, isDate could be used but it is also disabled (users should use a date schema instead): isDate(sourceOrSelector) // skip = true if isDate
|
161
|
+
);
|
102
162
|
}
|
103
163
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
}));
|
164
|
+
if (typeof sourceOrSelector === "number" || typeof sourceOrSelector === "boolean") {
|
165
|
+
return sourceOrSelector;
|
166
|
+
}
|
167
|
+
console.error("Unexpected type of source selector: ".concat(_typeof._typeof(sourceOrSelector)));
|
168
|
+
return sourceOrSelector;
|
110
169
|
}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
170
|
+
return rec(input);
|
171
|
+
}
|
172
|
+
function getModuleIds(input) {
|
173
|
+
var modules = new Set();
|
174
|
+
function rec(sourceOrSelector) {
|
175
|
+
if (_typeof._typeof(sourceOrSelector) === "object") {
|
176
|
+
var selectorPath = core.Internal.getValPath(sourceOrSelector);
|
177
|
+
if (selectorPath) {
|
178
|
+
modules.add(selectorPath);
|
179
|
+
return;
|
116
180
|
}
|
117
|
-
|
118
|
-
|
181
|
+
if (!sourceOrSelector) {
|
182
|
+
return;
|
183
|
+
}
|
184
|
+
if (core.VAL_EXTENSION in sourceOrSelector) {
|
185
|
+
if (sourceOrSelector[core.VAL_EXTENSION] === "richtext") {
|
186
|
+
return;
|
187
|
+
}
|
188
|
+
if (sourceOrSelector[core.VAL_EXTENSION] === "file" && typeof sourceOrSelector[core.FILE_REF_PROP] === "string") {
|
189
|
+
return;
|
190
|
+
}
|
191
|
+
console.error("Encountered unexpected extension: ".concat(sourceOrSelector[core.VAL_EXTENSION]));
|
192
|
+
return sourceOrSelector;
|
193
|
+
}
|
194
|
+
if (Array.isArray(sourceOrSelector)) {
|
195
|
+
sourceOrSelector.forEach(rec);
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
if (!Array.isArray(sourceOrSelector)) {
|
199
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(sourceOrSelector); _i2 < _Object$entries2.length; _i2++) {
|
200
|
+
var _Object$entries2$_i = slicedToArray._slicedToArray(_Object$entries2[_i2], 2),
|
201
|
+
value = _Object$entries2$_i[1];
|
202
|
+
rec(value);
|
203
|
+
}
|
204
|
+
return;
|
205
|
+
}
|
206
|
+
console.error("Could not transform source selector: ".concat(_typeof._typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
|
207
|
+
return;
|
208
|
+
}
|
209
|
+
if (typeof sourceOrSelector === "string") {
|
210
|
+
return;
|
211
|
+
}
|
212
|
+
if (typeof sourceOrSelector === "number" || typeof sourceOrSelector === "boolean") {
|
213
|
+
return;
|
214
|
+
}
|
215
|
+
console.error("Unexpected type of source selector: ".concat(_typeof._typeof(sourceOrSelector)));
|
216
|
+
return;
|
119
217
|
}
|
120
|
-
|
121
|
-
return
|
122
|
-
}
|
123
|
-
function isDate(s) {
|
124
|
-
return Boolean(Date.parse(s));
|
125
|
-
}
|
126
|
-
|
127
|
-
function fetchVal(selector, locale) {
|
128
|
-
return core.Internal.fetchVal(selector, locale).then(function (val) {
|
129
|
-
return stegaEncodeVal(val);
|
130
|
-
});
|
131
|
-
}
|
132
|
-
|
133
|
-
function useVal(selector, locale) {
|
134
|
-
return stegaEncodeVal(react.useVal(selector, locale));
|
218
|
+
rec(input);
|
219
|
+
return Array.from(modules);
|
135
220
|
}
|
136
221
|
|
137
222
|
exports.autoTagJSX = autoTagJSX;
|
138
|
-
exports.
|
139
|
-
exports.
|
223
|
+
exports.getModuleIds = getModuleIds;
|
224
|
+
exports.transform = transform;
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import { a as
|
1
|
+
import { a as _slicedToArray } from '../../dist/slicedToArray-b4fb91fa.esm.js';
|
2
|
+
import { _ as _typeof } from '../../dist/typeof-5c86a240.esm.js';
|
2
3
|
import ReactJSXRuntime__default from 'react/jsx-runtime';
|
3
4
|
import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
|
4
5
|
import React from 'react';
|
5
6
|
import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
|
6
|
-
import {
|
7
|
-
import { Internal } from '@valbuild/core';
|
8
|
-
import { useVal as useVal$1 } from '@valbuild/react';
|
9
|
-
import '../../dist/unsupportedIterableToArray-51bb61c2.esm.js';
|
10
|
-
import '../../dist/defineProperty-12b5bd29.esm.js';
|
7
|
+
import { a as _defineProperty } from '../../dist/defineProperty-b209a901.esm.js';
|
8
|
+
import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
|
11
9
|
|
12
10
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
13
11
|
// TODO: think this is not correct, but good enough for now?
|
@@ -27,9 +25,9 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
27
25
|
var _encodedBits$data;
|
28
26
|
var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
|
29
27
|
if (valPath) {
|
30
|
-
console.log("Found encoded valPath", valPath);
|
31
28
|
valSources.push(valPath);
|
32
29
|
props[key] = vercelStegaSplit(value).cleaned;
|
30
|
+
props["data-val-attr-".concat(key)] = valPath;
|
33
31
|
}
|
34
32
|
}
|
35
33
|
}
|
@@ -69,6 +67,28 @@ function autoTagJSX() {
|
|
69
67
|
JsxPro.jsxDEV && ( /**/JsxPro.jsxDEV = WrapJsx(JsxPro.jsxDEV));
|
70
68
|
}
|
71
69
|
|
70
|
+
function ownKeys(object, enumerableOnly) {
|
71
|
+
var keys = Object.keys(object);
|
72
|
+
if (Object.getOwnPropertySymbols) {
|
73
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
74
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
75
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
76
|
+
})), keys.push.apply(keys, symbols);
|
77
|
+
}
|
78
|
+
return keys;
|
79
|
+
}
|
80
|
+
function _objectSpread2(target) {
|
81
|
+
for (var i = 1; i < arguments.length; i++) {
|
82
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
83
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
84
|
+
_defineProperty(target, key, source[key]);
|
85
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
86
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
87
|
+
});
|
88
|
+
}
|
89
|
+
return target;
|
90
|
+
}
|
91
|
+
|
72
92
|
/**
|
73
93
|
* ValEncodedString is a string that is encoded using steganography.
|
74
94
|
*
|
@@ -78,50 +98,115 @@ function autoTagJSX() {
|
|
78
98
|
*
|
79
99
|
*/
|
80
100
|
|
81
|
-
function
|
82
|
-
|
83
|
-
if (
|
84
|
-
|
85
|
-
|
101
|
+
function transform(input, opts) {
|
102
|
+
function rec(sourceOrSelector, path) {
|
103
|
+
if (_typeof(sourceOrSelector) === "object") {
|
104
|
+
var selectorPath = Internal.getValPath(sourceOrSelector);
|
105
|
+
if (selectorPath) {
|
106
|
+
return rec(opts.getModule && opts.getModule(selectorPath) || Internal.getSource(sourceOrSelector), opts.disabled ? undefined : selectorPath);
|
107
|
+
}
|
108
|
+
if (!sourceOrSelector) {
|
109
|
+
return null;
|
110
|
+
}
|
111
|
+
if (VAL_EXTENSION in sourceOrSelector) {
|
112
|
+
if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
|
113
|
+
return _objectSpread2(_objectSpread2({}, sourceOrSelector), {}, {
|
114
|
+
valPath: path
|
115
|
+
});
|
116
|
+
}
|
117
|
+
if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
|
118
|
+
var fileSelector = Internal.convertFileSource(sourceOrSelector);
|
119
|
+
return _objectSpread2(_objectSpread2({}, fileSelector), {}, {
|
120
|
+
url: rec(fileSelector.url, path)
|
121
|
+
});
|
122
|
+
}
|
123
|
+
console.error("Encountered unexpected extension: ".concat(sourceOrSelector[VAL_EXTENSION]));
|
124
|
+
return sourceOrSelector;
|
125
|
+
}
|
126
|
+
if (Array.isArray(sourceOrSelector)) {
|
127
|
+
return sourceOrSelector.map(function (el, i) {
|
128
|
+
return rec(el, path && Internal.createValPathOfItem(path, i));
|
129
|
+
});
|
130
|
+
}
|
131
|
+
if (!Array.isArray(sourceOrSelector)) {
|
132
|
+
var res = {};
|
133
|
+
for (var _i = 0, _Object$entries = Object.entries(sourceOrSelector); _i < _Object$entries.length; _i++) {
|
134
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
135
|
+
_key = _Object$entries$_i[0],
|
136
|
+
value = _Object$entries$_i[1];
|
137
|
+
res[_key] = rec(value, path && Internal.createValPathOfItem(path, _key));
|
138
|
+
}
|
139
|
+
return res;
|
140
|
+
}
|
141
|
+
console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
|
142
|
+
return sourceOrSelector;
|
86
143
|
}
|
87
|
-
if (
|
88
|
-
return
|
89
|
-
|
90
|
-
|
91
|
-
|
144
|
+
if (typeof sourceOrSelector === "string") {
|
145
|
+
return vercelStegaCombine(sourceOrSelector, {
|
146
|
+
origin: "val.build",
|
147
|
+
data: {
|
148
|
+
valPath: path
|
149
|
+
}
|
150
|
+
}, false // auto detection on urls and dates is disabled, isDate could be used but it is also disabled (users should use a date schema instead): isDate(sourceOrSelector) // skip = true if isDate
|
151
|
+
);
|
92
152
|
}
|
93
153
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
}));
|
154
|
+
if (typeof sourceOrSelector === "number" || typeof sourceOrSelector === "boolean") {
|
155
|
+
return sourceOrSelector;
|
156
|
+
}
|
157
|
+
console.error("Unexpected type of source selector: ".concat(_typeof(sourceOrSelector)));
|
158
|
+
return sourceOrSelector;
|
100
159
|
}
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
160
|
+
return rec(input);
|
161
|
+
}
|
162
|
+
function getModuleIds(input) {
|
163
|
+
var modules = new Set();
|
164
|
+
function rec(sourceOrSelector) {
|
165
|
+
if (_typeof(sourceOrSelector) === "object") {
|
166
|
+
var selectorPath = Internal.getValPath(sourceOrSelector);
|
167
|
+
if (selectorPath) {
|
168
|
+
modules.add(selectorPath);
|
169
|
+
return;
|
106
170
|
}
|
107
|
-
|
108
|
-
|
171
|
+
if (!sourceOrSelector) {
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
if (VAL_EXTENSION in sourceOrSelector) {
|
175
|
+
if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
|
179
|
+
return;
|
180
|
+
}
|
181
|
+
console.error("Encountered unexpected extension: ".concat(sourceOrSelector[VAL_EXTENSION]));
|
182
|
+
return sourceOrSelector;
|
183
|
+
}
|
184
|
+
if (Array.isArray(sourceOrSelector)) {
|
185
|
+
sourceOrSelector.forEach(rec);
|
186
|
+
return;
|
187
|
+
}
|
188
|
+
if (!Array.isArray(sourceOrSelector)) {
|
189
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(sourceOrSelector); _i2 < _Object$entries2.length; _i2++) {
|
190
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
191
|
+
value = _Object$entries2$_i[1];
|
192
|
+
rec(value);
|
193
|
+
}
|
194
|
+
return;
|
195
|
+
}
|
196
|
+
console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
|
197
|
+
return;
|
198
|
+
}
|
199
|
+
if (typeof sourceOrSelector === "string") {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
if (typeof sourceOrSelector === "number" || typeof sourceOrSelector === "boolean") {
|
203
|
+
return;
|
204
|
+
}
|
205
|
+
console.error("Unexpected type of source selector: ".concat(_typeof(sourceOrSelector)));
|
206
|
+
return;
|
109
207
|
}
|
110
|
-
|
111
|
-
return
|
112
|
-
}
|
113
|
-
function isDate(s) {
|
114
|
-
return Boolean(Date.parse(s));
|
115
|
-
}
|
116
|
-
|
117
|
-
function fetchVal(selector, locale) {
|
118
|
-
return Internal.fetchVal(selector, locale).then(function (val) {
|
119
|
-
return stegaEncodeVal(val);
|
120
|
-
});
|
121
|
-
}
|
122
|
-
|
123
|
-
function useVal(selector, locale) {
|
124
|
-
return stegaEncodeVal(useVal$1(selector, locale));
|
208
|
+
rec(input);
|
209
|
+
return Array.from(modules);
|
125
210
|
}
|
126
211
|
|
127
|
-
export { autoTagJSX,
|
212
|
+
export { autoTagJSX, getModuleIds, transform };
|
@@ -1,12 +1,11 @@
|
|
1
|
-
import { a as
|
1
|
+
import { a as _slicedToArray } from '../../dist/slicedToArray-5a51fd33.worker.esm.js';
|
2
|
+
import { _ as _typeof } from '../../dist/typeof-8854ace1.worker.esm.js';
|
2
3
|
import ReactJSXRuntime__default from 'react/jsx-runtime';
|
3
4
|
import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
|
4
5
|
import React from 'react';
|
5
6
|
import { VERCEL_STEGA_REGEX, vercelStegaDecode, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
|
6
|
-
import {
|
7
|
-
import { Internal } from '@valbuild/core';
|
8
|
-
import { useVal as useVal$1 } from '@valbuild/react';
|
9
|
-
import '../../dist/unsupportedIterableToArray-738344ef.worker.esm.js';
|
7
|
+
import { a as _defineProperty } from '../../dist/defineProperty-18559492.worker.esm.js';
|
8
|
+
import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
|
10
9
|
|
11
10
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
12
11
|
// TODO: think this is not correct, but good enough for now?
|
@@ -26,9 +25,9 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
26
25
|
var _encodedBits$data;
|
27
26
|
var valPath = encodedBits === null || encodedBits === void 0 ? void 0 : (_encodedBits$data = encodedBits.data) === null || _encodedBits$data === void 0 ? void 0 : _encodedBits$data.valPath;
|
28
27
|
if (valPath) {
|
29
|
-
console.log("Found encoded valPath", valPath);
|
30
28
|
valSources.push(valPath);
|
31
29
|
props[key] = vercelStegaSplit(value).cleaned;
|
30
|
+
props["data-val-attr-".concat(key)] = valPath;
|
32
31
|
}
|
33
32
|
}
|
34
33
|
}
|
@@ -99,50 +98,115 @@ function _objectSpread2(target) {
|
|
99
98
|
*
|
100
99
|
*/
|
101
100
|
|
102
|
-
function
|
103
|
-
|
104
|
-
if (
|
105
|
-
|
106
|
-
|
101
|
+
function transform(input, opts) {
|
102
|
+
function rec(sourceOrSelector, path) {
|
103
|
+
if (_typeof(sourceOrSelector) === "object") {
|
104
|
+
var selectorPath = Internal.getValPath(sourceOrSelector);
|
105
|
+
if (selectorPath) {
|
106
|
+
return rec(opts.getModule && opts.getModule(selectorPath) || Internal.getSource(sourceOrSelector), opts.disabled ? undefined : selectorPath);
|
107
|
+
}
|
108
|
+
if (!sourceOrSelector) {
|
109
|
+
return null;
|
110
|
+
}
|
111
|
+
if (VAL_EXTENSION in sourceOrSelector) {
|
112
|
+
if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
|
113
|
+
return _objectSpread2(_objectSpread2({}, sourceOrSelector), {}, {
|
114
|
+
valPath: path
|
115
|
+
});
|
116
|
+
}
|
117
|
+
if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
|
118
|
+
var fileSelector = Internal.convertFileSource(sourceOrSelector);
|
119
|
+
return _objectSpread2(_objectSpread2({}, fileSelector), {}, {
|
120
|
+
url: rec(fileSelector.url, path)
|
121
|
+
});
|
122
|
+
}
|
123
|
+
console.error("Encountered unexpected extension: ".concat(sourceOrSelector[VAL_EXTENSION]));
|
124
|
+
return sourceOrSelector;
|
125
|
+
}
|
126
|
+
if (Array.isArray(sourceOrSelector)) {
|
127
|
+
return sourceOrSelector.map(function (el, i) {
|
128
|
+
return rec(el, path && Internal.createValPathOfItem(path, i));
|
129
|
+
});
|
130
|
+
}
|
131
|
+
if (!Array.isArray(sourceOrSelector)) {
|
132
|
+
var res = {};
|
133
|
+
for (var _i = 0, _Object$entries = Object.entries(sourceOrSelector); _i < _Object$entries.length; _i++) {
|
134
|
+
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
135
|
+
_key = _Object$entries$_i[0],
|
136
|
+
value = _Object$entries$_i[1];
|
137
|
+
res[_key] = rec(value, path && Internal.createValPathOfItem(path, _key));
|
138
|
+
}
|
139
|
+
return res;
|
140
|
+
}
|
141
|
+
console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
|
142
|
+
return sourceOrSelector;
|
107
143
|
}
|
108
|
-
if (
|
109
|
-
return
|
110
|
-
|
111
|
-
|
112
|
-
|
144
|
+
if (typeof sourceOrSelector === "string") {
|
145
|
+
return vercelStegaCombine(sourceOrSelector, {
|
146
|
+
origin: "val.build",
|
147
|
+
data: {
|
148
|
+
valPath: path
|
149
|
+
}
|
150
|
+
}, false // auto detection on urls and dates is disabled, isDate could be used but it is also disabled (users should use a date schema instead): isDate(sourceOrSelector) // skip = true if isDate
|
151
|
+
);
|
113
152
|
}
|
114
153
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
}));
|
154
|
+
if (typeof sourceOrSelector === "number" || typeof sourceOrSelector === "boolean") {
|
155
|
+
return sourceOrSelector;
|
156
|
+
}
|
157
|
+
console.error("Unexpected type of source selector: ".concat(_typeof(sourceOrSelector)));
|
158
|
+
return sourceOrSelector;
|
121
159
|
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
160
|
+
return rec(input);
|
161
|
+
}
|
162
|
+
function getModuleIds(input) {
|
163
|
+
var modules = new Set();
|
164
|
+
function rec(sourceOrSelector) {
|
165
|
+
if (_typeof(sourceOrSelector) === "object") {
|
166
|
+
var selectorPath = Internal.getValPath(sourceOrSelector);
|
167
|
+
if (selectorPath) {
|
168
|
+
modules.add(selectorPath);
|
169
|
+
return;
|
170
|
+
}
|
171
|
+
if (!sourceOrSelector) {
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
if (VAL_EXTENSION in sourceOrSelector) {
|
175
|
+
if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
if (sourceOrSelector[VAL_EXTENSION] === "file" && typeof sourceOrSelector[FILE_REF_PROP] === "string") {
|
179
|
+
return;
|
180
|
+
}
|
181
|
+
console.error("Encountered unexpected extension: ".concat(sourceOrSelector[VAL_EXTENSION]));
|
182
|
+
return sourceOrSelector;
|
127
183
|
}
|
128
|
-
|
129
|
-
|
184
|
+
if (Array.isArray(sourceOrSelector)) {
|
185
|
+
sourceOrSelector.forEach(rec);
|
186
|
+
return;
|
187
|
+
}
|
188
|
+
if (!Array.isArray(sourceOrSelector)) {
|
189
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(sourceOrSelector); _i2 < _Object$entries2.length; _i2++) {
|
190
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
191
|
+
value = _Object$entries2$_i[1];
|
192
|
+
rec(value);
|
193
|
+
}
|
194
|
+
return;
|
195
|
+
}
|
196
|
+
console.error("Could not transform source selector: ".concat(_typeof(sourceOrSelector), " (array: ").concat(Array.isArray(sourceOrSelector), ")"), sourceOrSelector);
|
197
|
+
return;
|
198
|
+
}
|
199
|
+
if (typeof sourceOrSelector === "string") {
|
200
|
+
return;
|
201
|
+
}
|
202
|
+
if (typeof sourceOrSelector === "number" || typeof sourceOrSelector === "boolean") {
|
203
|
+
return;
|
204
|
+
}
|
205
|
+
console.error("Unexpected type of source selector: ".concat(_typeof(sourceOrSelector)));
|
206
|
+
return;
|
130
207
|
}
|
131
|
-
|
132
|
-
return
|
133
|
-
}
|
134
|
-
function isDate(s) {
|
135
|
-
return Boolean(Date.parse(s));
|
136
|
-
}
|
137
|
-
|
138
|
-
function fetchVal(selector, locale) {
|
139
|
-
return Internal.fetchVal(selector, locale).then(function (val) {
|
140
|
-
return stegaEncodeVal(val);
|
141
|
-
});
|
142
|
-
}
|
143
|
-
|
144
|
-
function useVal(selector, locale) {
|
145
|
-
return stegaEncodeVal(useVal$1(selector, locale));
|
208
|
+
rec(input);
|
209
|
+
return Array.from(modules);
|
146
210
|
}
|
147
211
|
|
148
|
-
export { autoTagJSX,
|
212
|
+
export { autoTagJSX, getModuleIds, transform };
|