@valbuild/react 0.16.0 → 0.17.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
@@ -0,0 +1,220 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
2
|
+
import {
|
3
|
+
Json,
|
4
|
+
Internal,
|
5
|
+
RichTextSource,
|
6
|
+
RichText,
|
7
|
+
VAL_EXTENSION,
|
8
|
+
FILE_REF_PROP,
|
9
|
+
} from "@valbuild/core";
|
10
|
+
import { vercelStegaCombine } from "@vercel/stega";
|
11
|
+
import { FileSource, Source, SourceObject } from "@valbuild/core";
|
12
|
+
import { JsonPrimitive } from "@valbuild/core";
|
13
|
+
import { SourceArray } from "@valbuild/core";
|
14
|
+
|
15
|
+
declare const brand: unique symbol;
|
16
|
+
|
17
|
+
/**
|
18
|
+
* ValEncodedString is a string that is encoded using steganography.
|
19
|
+
*
|
20
|
+
* This means that there is a hidden / non-visible object embedded in the string.
|
21
|
+
* This object includes a path, which is used to automatically tag
|
22
|
+
* where the content comes from for contextual editing.
|
23
|
+
*
|
24
|
+
*/
|
25
|
+
export type ValEncodedString = string & {
|
26
|
+
[brand]: "ValEncodedString";
|
27
|
+
};
|
28
|
+
|
29
|
+
export type StegaOfSource<T extends Source> = Json extends T
|
30
|
+
? Json
|
31
|
+
: T extends RichTextSource
|
32
|
+
? RichText
|
33
|
+
: T extends FileSource
|
34
|
+
? { url: ValEncodedString }
|
35
|
+
: T extends SourceObject
|
36
|
+
? {
|
37
|
+
[key in keyof T]: StegaOfSource<T[key]>;
|
38
|
+
}
|
39
|
+
: T extends SourceArray
|
40
|
+
? StegaOfSource<T[number]>[]
|
41
|
+
: T extends string
|
42
|
+
? ValEncodedString
|
43
|
+
: T extends JsonPrimitive
|
44
|
+
? T
|
45
|
+
: never;
|
46
|
+
|
47
|
+
export function transform(
|
48
|
+
input: any,
|
49
|
+
opts: {
|
50
|
+
getModule?: (moduleId: string) => any;
|
51
|
+
disabled?: boolean;
|
52
|
+
}
|
53
|
+
): any {
|
54
|
+
function rec(sourceOrSelector: any, path?: any): any {
|
55
|
+
if (typeof sourceOrSelector === "object") {
|
56
|
+
const selectorPath = Internal.getValPath(sourceOrSelector);
|
57
|
+
if (selectorPath) {
|
58
|
+
return rec(
|
59
|
+
(opts.getModule && opts.getModule(selectorPath)) ||
|
60
|
+
Internal.getSource(sourceOrSelector),
|
61
|
+
opts.disabled ? undefined : selectorPath
|
62
|
+
);
|
63
|
+
}
|
64
|
+
|
65
|
+
if (!sourceOrSelector) {
|
66
|
+
return null;
|
67
|
+
}
|
68
|
+
|
69
|
+
if (VAL_EXTENSION in sourceOrSelector) {
|
70
|
+
if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
|
71
|
+
return {
|
72
|
+
...sourceOrSelector,
|
73
|
+
valPath: path,
|
74
|
+
};
|
75
|
+
}
|
76
|
+
|
77
|
+
if (
|
78
|
+
sourceOrSelector[VAL_EXTENSION] === "file" &&
|
79
|
+
typeof sourceOrSelector[FILE_REF_PROP] === "string"
|
80
|
+
) {
|
81
|
+
const fileSelector = Internal.convertFileSource(sourceOrSelector);
|
82
|
+
return {
|
83
|
+
...fileSelector,
|
84
|
+
url: rec(fileSelector.url, path),
|
85
|
+
};
|
86
|
+
}
|
87
|
+
console.error(
|
88
|
+
`Encountered unexpected extension: ${sourceOrSelector[VAL_EXTENSION]}`
|
89
|
+
);
|
90
|
+
return sourceOrSelector;
|
91
|
+
}
|
92
|
+
|
93
|
+
if (Array.isArray(sourceOrSelector)) {
|
94
|
+
return sourceOrSelector.map((el, i) =>
|
95
|
+
rec(el, path && Internal.createValPathOfItem(path, i))
|
96
|
+
);
|
97
|
+
}
|
98
|
+
|
99
|
+
if (!Array.isArray(sourceOrSelector)) {
|
100
|
+
const res: Record<string, any> = {};
|
101
|
+
for (const [key, value] of Object.entries(sourceOrSelector)) {
|
102
|
+
res[key] = rec(
|
103
|
+
value,
|
104
|
+
path && Internal.createValPathOfItem(path, key)
|
105
|
+
);
|
106
|
+
}
|
107
|
+
return res;
|
108
|
+
}
|
109
|
+
|
110
|
+
console.error(
|
111
|
+
`Could not transform source selector: ${typeof sourceOrSelector} (array: ${Array.isArray(
|
112
|
+
sourceOrSelector
|
113
|
+
)})`,
|
114
|
+
sourceOrSelector
|
115
|
+
);
|
116
|
+
return sourceOrSelector;
|
117
|
+
}
|
118
|
+
|
119
|
+
if (typeof sourceOrSelector === "string") {
|
120
|
+
return vercelStegaCombine(
|
121
|
+
sourceOrSelector,
|
122
|
+
{
|
123
|
+
origin: "val.build",
|
124
|
+
data: { valPath: path },
|
125
|
+
},
|
126
|
+
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
|
127
|
+
);
|
128
|
+
}
|
129
|
+
|
130
|
+
if (
|
131
|
+
typeof sourceOrSelector === "number" ||
|
132
|
+
typeof sourceOrSelector === "boolean"
|
133
|
+
) {
|
134
|
+
return sourceOrSelector;
|
135
|
+
}
|
136
|
+
|
137
|
+
console.error(
|
138
|
+
`Unexpected type of source selector: ${typeof sourceOrSelector}`
|
139
|
+
);
|
140
|
+
return sourceOrSelector;
|
141
|
+
}
|
142
|
+
return rec(input);
|
143
|
+
}
|
144
|
+
|
145
|
+
export function getModuleIds(input: any): string[] {
|
146
|
+
const modules: Set<string> = new Set();
|
147
|
+
function rec(sourceOrSelector: any): undefined {
|
148
|
+
if (typeof sourceOrSelector === "object") {
|
149
|
+
const selectorPath = Internal.getValPath(sourceOrSelector);
|
150
|
+
if (selectorPath) {
|
151
|
+
modules.add(selectorPath);
|
152
|
+
return;
|
153
|
+
}
|
154
|
+
|
155
|
+
if (!sourceOrSelector) {
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
|
159
|
+
if (VAL_EXTENSION in sourceOrSelector) {
|
160
|
+
if (sourceOrSelector[VAL_EXTENSION] === "richtext") {
|
161
|
+
return;
|
162
|
+
}
|
163
|
+
|
164
|
+
if (
|
165
|
+
sourceOrSelector[VAL_EXTENSION] === "file" &&
|
166
|
+
typeof sourceOrSelector[FILE_REF_PROP] === "string"
|
167
|
+
) {
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
console.error(
|
171
|
+
`Encountered unexpected extension: ${sourceOrSelector[VAL_EXTENSION]}`
|
172
|
+
);
|
173
|
+
return sourceOrSelector;
|
174
|
+
}
|
175
|
+
|
176
|
+
if (Array.isArray(sourceOrSelector)) {
|
177
|
+
sourceOrSelector.forEach(rec);
|
178
|
+
return;
|
179
|
+
}
|
180
|
+
|
181
|
+
if (!Array.isArray(sourceOrSelector)) {
|
182
|
+
for (const [, value] of Object.entries(sourceOrSelector)) {
|
183
|
+
rec(value);
|
184
|
+
}
|
185
|
+
return;
|
186
|
+
}
|
187
|
+
|
188
|
+
console.error(
|
189
|
+
`Could not transform source selector: ${typeof sourceOrSelector} (array: ${Array.isArray(
|
190
|
+
sourceOrSelector
|
191
|
+
)})`,
|
192
|
+
sourceOrSelector
|
193
|
+
);
|
194
|
+
return;
|
195
|
+
}
|
196
|
+
|
197
|
+
if (typeof sourceOrSelector === "string") {
|
198
|
+
return;
|
199
|
+
}
|
200
|
+
|
201
|
+
if (
|
202
|
+
typeof sourceOrSelector === "number" ||
|
203
|
+
typeof sourceOrSelector === "boolean"
|
204
|
+
) {
|
205
|
+
return;
|
206
|
+
}
|
207
|
+
|
208
|
+
console.error(
|
209
|
+
`Unexpected type of source selector: ${typeof sourceOrSelector}`
|
210
|
+
);
|
211
|
+
return;
|
212
|
+
}
|
213
|
+
rec(input);
|
214
|
+
return Array.from(modules);
|
215
|
+
}
|
216
|
+
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
218
|
+
function isDate(s: string) {
|
219
|
+
return Boolean(Date.parse(s));
|
220
|
+
}
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import { a as
|
1
|
+
import { a as _slicedToArray } from '../../dist/slicedToArray-0cbb3d34.browser.esm.js';
|
2
|
+
import { _ as _typeof } from '../../dist/typeof-52fabea9.browser.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-d3087ed5.browser.esm.js';
|
10
|
-
import '../../dist/defineProperty-f319cb47.browser.esm.js';
|
7
|
+
import { a as _defineProperty } from '../../dist/defineProperty-034d0378.browser.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 };
|
@@ -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-7b1713a7.cjs.dev.js');
|
6
|
+
var _typeof = require('../../dist/typeof-1de657a3.cjs.dev.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-c82a49b0.cjs.dev.js');
|
11
12
|
var core = require('@valbuild/core');
|
12
|
-
var react = require('@valbuild/react');
|
13
|
-
require('../../dist/unsupportedIterableToArray-9e97e24a.cjs.dev.js');
|
14
|
-
require('../../dist/defineProperty-c82a49b0.cjs.dev.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;
|