@valbuild/react 0.62.4 → 0.62.6
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/declarations/src/stega/index.d.ts +2 -0
- package/package.json +4 -4
- package/stega/dist/valbuild-react-stega.browser.esm.js +46 -17
- package/stega/dist/valbuild-react-stega.cjs.dev.js +47 -16
- package/stega/dist/valbuild-react-stega.cjs.prod.js +47 -16
- package/stega/dist/valbuild-react-stega.esm.js +46 -17
- package/stega/dist/valbuild-react-stega.worker.esm.js +46 -17
@@ -2,3 +2,5 @@ export { autoTagJSX } from "./autoTagJSX.js";
|
|
2
2
|
export { stegaEncode, getModuleIds, stegaClean, type ValEncodedString, type StegaOfSource, } from "./stegaEncode.js";
|
3
3
|
export { type Image } from "./stegaEncode.js";
|
4
4
|
export { stegaDecodeString } from "./stegaDecodeString.js";
|
5
|
+
export declare function IS_AUTO_TAG_JSX_ENABLED(): boolean;
|
6
|
+
export declare function SET_AUTO_TAG_JSX_ENABLED(enabled: boolean): void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/react",
|
3
|
-
"version": "0.62.
|
3
|
+
"version": "0.62.6",
|
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.62.
|
13
|
-
"@valbuild/shared": "~0.62.
|
14
|
-
"@valbuild/ui": "~0.62.
|
12
|
+
"@valbuild/core": "~0.62.6",
|
13
|
+
"@valbuild/shared": "~0.62.6",
|
14
|
+
"@valbuild/ui": "~0.62.6",
|
15
15
|
"@vercel/stega": "^0.1.0",
|
16
16
|
"base64-arraybuffer": "^1.0.2"
|
17
17
|
},
|
@@ -18,12 +18,19 @@ function stegaDecodeString(encodedString) {
|
|
18
18
|
}
|
19
19
|
}
|
20
20
|
|
21
|
+
// import { IS_AUTO_TAG_JSX_ENABLED } from ".";
|
22
|
+
|
21
23
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
22
24
|
// TODO: think this is not correct, but good enough for now?
|
23
25
|
return typeof type === "string";
|
24
26
|
};
|
25
27
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
26
|
-
|
28
|
+
// TODO: increases performance. Unsure about the implications right now - seems to work. Remember to look at RSC and client (and pages/?).
|
29
|
+
// if (!IS_AUTO_TAG_JSX_ENABLED()) {
|
30
|
+
// return;
|
31
|
+
// }
|
32
|
+
|
33
|
+
var valSources = new Set();
|
27
34
|
|
28
35
|
// skip auto-tagging fragments since we can't add attributes to them
|
29
36
|
if (type === Symbol["for"]("react.fragment")) {
|
@@ -39,20 +46,27 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
39
46
|
return;
|
40
47
|
}
|
41
48
|
var valPath = stegaDecodeString(value);
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
//
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
if (valPath) {
|
50
|
+
// Found val path - this is a stega encoded string
|
51
|
+
// The logic below is as follows:
|
52
|
+
// if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
|
53
|
+
// always add to sources (intrinsic or not)
|
54
|
+
// if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
|
55
|
+
valSources.add(valPath);
|
56
|
+
if (isIntrinsicElement(type)) {
|
57
|
+
// clean values before adding them to the props
|
58
|
+
// we cannot do this
|
59
|
+
var cleanValue = vercelStegaSplit(value).cleaned;
|
60
|
+
// we do Object.entries earlier over props so props that are arrays have string keys:
|
61
|
+
var numberOfKey = Number(key);
|
62
|
+
if (Array.isArray(container) && numberOfKey > -1) {
|
63
|
+
container[numberOfKey] = cleanValue;
|
64
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
65
|
+
container[key] = cleanValue;
|
66
|
+
} else {
|
67
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
68
|
+
}
|
54
69
|
}
|
55
|
-
props[attr] = valPath;
|
56
70
|
}
|
57
71
|
}
|
58
72
|
if (props && _typeof(props) === "object") {
|
@@ -84,8 +98,8 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
84
98
|
}
|
85
99
|
}
|
86
100
|
}
|
87
|
-
if (valSources.
|
88
|
-
props["data-val-path"] = valSources.join(",");
|
101
|
+
if (valSources.size > 0 && !props["data-val-path"]) {
|
102
|
+
props["data-val-path"] = Array.from(valSources).join(",");
|
89
103
|
}
|
90
104
|
}
|
91
105
|
};
|
@@ -183,6 +197,9 @@ function _objectSpread2(e) {
|
|
183
197
|
|
184
198
|
function stegaEncode(input, opts) {
|
185
199
|
function rec(sourceOrSelector, recOpts) {
|
200
|
+
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isKeyOfSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
201
|
+
return sourceOrSelector;
|
202
|
+
}
|
186
203
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLiteralSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
187
204
|
return sourceOrSelector;
|
188
205
|
}
|
@@ -325,6 +342,9 @@ function unknownSchema(schema) {
|
|
325
342
|
function isUnionSchema(schema) {
|
326
343
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "union";
|
327
344
|
}
|
345
|
+
function isKeyOfSchema(schema) {
|
346
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "keyOf";
|
347
|
+
}
|
328
348
|
function isObjectSchema(schema) {
|
329
349
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "object";
|
330
350
|
}
|
@@ -381,4 +401,13 @@ function getModuleIds(input) {
|
|
381
401
|
return Array.from(modules);
|
382
402
|
}
|
383
403
|
|
384
|
-
|
404
|
+
// NOTE: the exports of this file needs to be kept in sync with ValQuickJSRuntime
|
405
|
+
var autoTagJSXEnabled = false;
|
406
|
+
function IS_AUTO_TAG_JSX_ENABLED() {
|
407
|
+
return autoTagJSXEnabled;
|
408
|
+
}
|
409
|
+
function SET_AUTO_TAG_JSX_ENABLED(enabled) {
|
410
|
+
autoTagJSXEnabled = enabled;
|
411
|
+
}
|
412
|
+
|
413
|
+
export { IS_AUTO_TAG_JSX_ENABLED, SET_AUTO_TAG_JSX_ENABLED, autoTagJSX, getModuleIds, stegaClean, stegaDecodeString, stegaEncode };
|
@@ -28,12 +28,19 @@ function stegaDecodeString(encodedString) {
|
|
28
28
|
}
|
29
29
|
}
|
30
30
|
|
31
|
+
// import { IS_AUTO_TAG_JSX_ENABLED } from ".";
|
32
|
+
|
31
33
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
32
34
|
// TODO: think this is not correct, but good enough for now?
|
33
35
|
return typeof type === "string";
|
34
36
|
};
|
35
37
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
36
|
-
|
38
|
+
// TODO: increases performance. Unsure about the implications right now - seems to work. Remember to look at RSC and client (and pages/?).
|
39
|
+
// if (!IS_AUTO_TAG_JSX_ENABLED()) {
|
40
|
+
// return;
|
41
|
+
// }
|
42
|
+
|
43
|
+
var valSources = new Set();
|
37
44
|
|
38
45
|
// skip auto-tagging fragments since we can't add attributes to them
|
39
46
|
if (type === Symbol["for"]("react.fragment")) {
|
@@ -49,20 +56,27 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
49
56
|
return;
|
50
57
|
}
|
51
58
|
var valPath = stegaDecodeString(value);
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
//
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
if (valPath) {
|
60
|
+
// Found val path - this is a stega encoded string
|
61
|
+
// The logic below is as follows:
|
62
|
+
// if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
|
63
|
+
// always add to sources (intrinsic or not)
|
64
|
+
// if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
|
65
|
+
valSources.add(valPath);
|
66
|
+
if (isIntrinsicElement(type)) {
|
67
|
+
// clean values before adding them to the props
|
68
|
+
// we cannot do this
|
69
|
+
var cleanValue = stega.vercelStegaSplit(value).cleaned;
|
70
|
+
// we do Object.entries earlier over props so props that are arrays have string keys:
|
71
|
+
var numberOfKey = Number(key);
|
72
|
+
if (Array.isArray(container) && numberOfKey > -1) {
|
73
|
+
container[numberOfKey] = cleanValue;
|
74
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
75
|
+
container[key] = cleanValue;
|
76
|
+
} else {
|
77
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
78
|
+
}
|
64
79
|
}
|
65
|
-
props[attr] = valPath;
|
66
80
|
}
|
67
81
|
}
|
68
82
|
if (props && slicedToArray._typeof(props) === "object") {
|
@@ -94,8 +108,8 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
94
108
|
}
|
95
109
|
}
|
96
110
|
}
|
97
|
-
if (valSources.
|
98
|
-
props["data-val-path"] = valSources.join(",");
|
111
|
+
if (valSources.size > 0 && !props["data-val-path"]) {
|
112
|
+
props["data-val-path"] = Array.from(valSources).join(",");
|
99
113
|
}
|
100
114
|
}
|
101
115
|
};
|
@@ -193,6 +207,9 @@ function _objectSpread2(e) {
|
|
193
207
|
|
194
208
|
function stegaEncode(input, opts) {
|
195
209
|
function rec(sourceOrSelector, recOpts) {
|
210
|
+
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isKeyOfSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
211
|
+
return sourceOrSelector;
|
212
|
+
}
|
196
213
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLiteralSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
197
214
|
return sourceOrSelector;
|
198
215
|
}
|
@@ -335,6 +352,9 @@ function unknownSchema(schema) {
|
|
335
352
|
function isUnionSchema(schema) {
|
336
353
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "union";
|
337
354
|
}
|
355
|
+
function isKeyOfSchema(schema) {
|
356
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "keyOf";
|
357
|
+
}
|
338
358
|
function isObjectSchema(schema) {
|
339
359
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "object";
|
340
360
|
}
|
@@ -391,6 +411,17 @@ function getModuleIds(input) {
|
|
391
411
|
return Array.from(modules);
|
392
412
|
}
|
393
413
|
|
414
|
+
// NOTE: the exports of this file needs to be kept in sync with ValQuickJSRuntime
|
415
|
+
var autoTagJSXEnabled = false;
|
416
|
+
function IS_AUTO_TAG_JSX_ENABLED() {
|
417
|
+
return autoTagJSXEnabled;
|
418
|
+
}
|
419
|
+
function SET_AUTO_TAG_JSX_ENABLED(enabled) {
|
420
|
+
autoTagJSXEnabled = enabled;
|
421
|
+
}
|
422
|
+
|
423
|
+
exports.IS_AUTO_TAG_JSX_ENABLED = IS_AUTO_TAG_JSX_ENABLED;
|
424
|
+
exports.SET_AUTO_TAG_JSX_ENABLED = SET_AUTO_TAG_JSX_ENABLED;
|
394
425
|
exports.autoTagJSX = autoTagJSX;
|
395
426
|
exports.getModuleIds = getModuleIds;
|
396
427
|
exports.stegaClean = stegaClean;
|
@@ -28,12 +28,19 @@ function stegaDecodeString(encodedString) {
|
|
28
28
|
}
|
29
29
|
}
|
30
30
|
|
31
|
+
// import { IS_AUTO_TAG_JSX_ENABLED } from ".";
|
32
|
+
|
31
33
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
32
34
|
// TODO: think this is not correct, but good enough for now?
|
33
35
|
return typeof type === "string";
|
34
36
|
};
|
35
37
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
36
|
-
|
38
|
+
// TODO: increases performance. Unsure about the implications right now - seems to work. Remember to look at RSC and client (and pages/?).
|
39
|
+
// if (!IS_AUTO_TAG_JSX_ENABLED()) {
|
40
|
+
// return;
|
41
|
+
// }
|
42
|
+
|
43
|
+
var valSources = new Set();
|
37
44
|
|
38
45
|
// skip auto-tagging fragments since we can't add attributes to them
|
39
46
|
if (type === Symbol["for"]("react.fragment")) {
|
@@ -49,20 +56,27 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
49
56
|
return;
|
50
57
|
}
|
51
58
|
var valPath = stegaDecodeString(value);
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
//
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
if (valPath) {
|
60
|
+
// Found val path - this is a stega encoded string
|
61
|
+
// The logic below is as follows:
|
62
|
+
// if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
|
63
|
+
// always add to sources (intrinsic or not)
|
64
|
+
// if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
|
65
|
+
valSources.add(valPath);
|
66
|
+
if (isIntrinsicElement(type)) {
|
67
|
+
// clean values before adding them to the props
|
68
|
+
// we cannot do this
|
69
|
+
var cleanValue = stega.vercelStegaSplit(value).cleaned;
|
70
|
+
// we do Object.entries earlier over props so props that are arrays have string keys:
|
71
|
+
var numberOfKey = Number(key);
|
72
|
+
if (Array.isArray(container) && numberOfKey > -1) {
|
73
|
+
container[numberOfKey] = cleanValue;
|
74
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
75
|
+
container[key] = cleanValue;
|
76
|
+
} else {
|
77
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
78
|
+
}
|
64
79
|
}
|
65
|
-
props[attr] = valPath;
|
66
80
|
}
|
67
81
|
}
|
68
82
|
if (props && slicedToArray._typeof(props) === "object") {
|
@@ -94,8 +108,8 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
94
108
|
}
|
95
109
|
}
|
96
110
|
}
|
97
|
-
if (valSources.
|
98
|
-
props["data-val-path"] = valSources.join(",");
|
111
|
+
if (valSources.size > 0 && !props["data-val-path"]) {
|
112
|
+
props["data-val-path"] = Array.from(valSources).join(",");
|
99
113
|
}
|
100
114
|
}
|
101
115
|
};
|
@@ -193,6 +207,9 @@ function _objectSpread2(e) {
|
|
193
207
|
|
194
208
|
function stegaEncode(input, opts) {
|
195
209
|
function rec(sourceOrSelector, recOpts) {
|
210
|
+
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isKeyOfSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
211
|
+
return sourceOrSelector;
|
212
|
+
}
|
196
213
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLiteralSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
197
214
|
return sourceOrSelector;
|
198
215
|
}
|
@@ -335,6 +352,9 @@ function unknownSchema(schema) {
|
|
335
352
|
function isUnionSchema(schema) {
|
336
353
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "union";
|
337
354
|
}
|
355
|
+
function isKeyOfSchema(schema) {
|
356
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "keyOf";
|
357
|
+
}
|
338
358
|
function isObjectSchema(schema) {
|
339
359
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "object";
|
340
360
|
}
|
@@ -391,6 +411,17 @@ function getModuleIds(input) {
|
|
391
411
|
return Array.from(modules);
|
392
412
|
}
|
393
413
|
|
414
|
+
// NOTE: the exports of this file needs to be kept in sync with ValQuickJSRuntime
|
415
|
+
var autoTagJSXEnabled = false;
|
416
|
+
function IS_AUTO_TAG_JSX_ENABLED() {
|
417
|
+
return autoTagJSXEnabled;
|
418
|
+
}
|
419
|
+
function SET_AUTO_TAG_JSX_ENABLED(enabled) {
|
420
|
+
autoTagJSXEnabled = enabled;
|
421
|
+
}
|
422
|
+
|
423
|
+
exports.IS_AUTO_TAG_JSX_ENABLED = IS_AUTO_TAG_JSX_ENABLED;
|
424
|
+
exports.SET_AUTO_TAG_JSX_ENABLED = SET_AUTO_TAG_JSX_ENABLED;
|
394
425
|
exports.autoTagJSX = autoTagJSX;
|
395
426
|
exports.getModuleIds = getModuleIds;
|
396
427
|
exports.stegaClean = stegaClean;
|
@@ -18,12 +18,19 @@ function stegaDecodeString(encodedString) {
|
|
18
18
|
}
|
19
19
|
}
|
20
20
|
|
21
|
+
// import { IS_AUTO_TAG_JSX_ENABLED } from ".";
|
22
|
+
|
21
23
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
22
24
|
// TODO: think this is not correct, but good enough for now?
|
23
25
|
return typeof type === "string";
|
24
26
|
};
|
25
27
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
26
|
-
|
28
|
+
// TODO: increases performance. Unsure about the implications right now - seems to work. Remember to look at RSC and client (and pages/?).
|
29
|
+
// if (!IS_AUTO_TAG_JSX_ENABLED()) {
|
30
|
+
// return;
|
31
|
+
// }
|
32
|
+
|
33
|
+
var valSources = new Set();
|
27
34
|
|
28
35
|
// skip auto-tagging fragments since we can't add attributes to them
|
29
36
|
if (type === Symbol["for"]("react.fragment")) {
|
@@ -39,20 +46,27 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
39
46
|
return;
|
40
47
|
}
|
41
48
|
var valPath = stegaDecodeString(value);
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
//
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
if (valPath) {
|
50
|
+
// Found val path - this is a stega encoded string
|
51
|
+
// The logic below is as follows:
|
52
|
+
// if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
|
53
|
+
// always add to sources (intrinsic or not)
|
54
|
+
// if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
|
55
|
+
valSources.add(valPath);
|
56
|
+
if (isIntrinsicElement(type)) {
|
57
|
+
// clean values before adding them to the props
|
58
|
+
// we cannot do this
|
59
|
+
var cleanValue = vercelStegaSplit(value).cleaned;
|
60
|
+
// we do Object.entries earlier over props so props that are arrays have string keys:
|
61
|
+
var numberOfKey = Number(key);
|
62
|
+
if (Array.isArray(container) && numberOfKey > -1) {
|
63
|
+
container[numberOfKey] = cleanValue;
|
64
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
65
|
+
container[key] = cleanValue;
|
66
|
+
} else {
|
67
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
68
|
+
}
|
54
69
|
}
|
55
|
-
props[attr] = valPath;
|
56
70
|
}
|
57
71
|
}
|
58
72
|
if (props && _typeof(props) === "object") {
|
@@ -84,8 +98,8 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
84
98
|
}
|
85
99
|
}
|
86
100
|
}
|
87
|
-
if (valSources.
|
88
|
-
props["data-val-path"] = valSources.join(",");
|
101
|
+
if (valSources.size > 0 && !props["data-val-path"]) {
|
102
|
+
props["data-val-path"] = Array.from(valSources).join(",");
|
89
103
|
}
|
90
104
|
}
|
91
105
|
};
|
@@ -183,6 +197,9 @@ function _objectSpread2(e) {
|
|
183
197
|
|
184
198
|
function stegaEncode(input, opts) {
|
185
199
|
function rec(sourceOrSelector, recOpts) {
|
200
|
+
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isKeyOfSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
201
|
+
return sourceOrSelector;
|
202
|
+
}
|
186
203
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLiteralSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
187
204
|
return sourceOrSelector;
|
188
205
|
}
|
@@ -325,6 +342,9 @@ function unknownSchema(schema) {
|
|
325
342
|
function isUnionSchema(schema) {
|
326
343
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "union";
|
327
344
|
}
|
345
|
+
function isKeyOfSchema(schema) {
|
346
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "keyOf";
|
347
|
+
}
|
328
348
|
function isObjectSchema(schema) {
|
329
349
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "object";
|
330
350
|
}
|
@@ -381,4 +401,13 @@ function getModuleIds(input) {
|
|
381
401
|
return Array.from(modules);
|
382
402
|
}
|
383
403
|
|
384
|
-
|
404
|
+
// NOTE: the exports of this file needs to be kept in sync with ValQuickJSRuntime
|
405
|
+
var autoTagJSXEnabled = false;
|
406
|
+
function IS_AUTO_TAG_JSX_ENABLED() {
|
407
|
+
return autoTagJSXEnabled;
|
408
|
+
}
|
409
|
+
function SET_AUTO_TAG_JSX_ENABLED(enabled) {
|
410
|
+
autoTagJSXEnabled = enabled;
|
411
|
+
}
|
412
|
+
|
413
|
+
export { IS_AUTO_TAG_JSX_ENABLED, SET_AUTO_TAG_JSX_ENABLED, autoTagJSX, getModuleIds, stegaClean, stegaDecodeString, stegaEncode };
|
@@ -18,12 +18,19 @@ function stegaDecodeString(encodedString) {
|
|
18
18
|
}
|
19
19
|
}
|
20
20
|
|
21
|
+
// import { IS_AUTO_TAG_JSX_ENABLED } from ".";
|
22
|
+
|
21
23
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
22
24
|
// TODO: think this is not correct, but good enough for now?
|
23
25
|
return typeof type === "string";
|
24
26
|
};
|
25
27
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
26
|
-
|
28
|
+
// TODO: increases performance. Unsure about the implications right now - seems to work. Remember to look at RSC and client (and pages/?).
|
29
|
+
// if (!IS_AUTO_TAG_JSX_ENABLED()) {
|
30
|
+
// return;
|
31
|
+
// }
|
32
|
+
|
33
|
+
var valSources = new Set();
|
27
34
|
|
28
35
|
// skip auto-tagging fragments since we can't add attributes to them
|
29
36
|
if (type === Symbol["for"]("react.fragment")) {
|
@@ -39,20 +46,27 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
39
46
|
return;
|
40
47
|
}
|
41
48
|
var valPath = stegaDecodeString(value);
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
//
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
if (valPath) {
|
50
|
+
// Found val path - this is a stega encoded string
|
51
|
+
// The logic below is as follows:
|
52
|
+
// if this is an intrinsic element (a, div, etc.), add data attrs will be on the DOM element
|
53
|
+
// always add to sources (intrinsic or not)
|
54
|
+
// if this is not an intrinsic element, we pass the stega encoded value downwards until we hit an intrinsic element
|
55
|
+
valSources.add(valPath);
|
56
|
+
if (isIntrinsicElement(type)) {
|
57
|
+
// clean values before adding them to the props
|
58
|
+
// we cannot do this
|
59
|
+
var cleanValue = vercelStegaSplit(value).cleaned;
|
60
|
+
// we do Object.entries earlier over props so props that are arrays have string keys:
|
61
|
+
var numberOfKey = Number(key);
|
62
|
+
if (Array.isArray(container) && numberOfKey > -1) {
|
63
|
+
container[numberOfKey] = cleanValue;
|
64
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
65
|
+
container[key] = cleanValue;
|
66
|
+
} else {
|
67
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
68
|
+
}
|
54
69
|
}
|
55
|
-
props[attr] = valPath;
|
56
70
|
}
|
57
71
|
}
|
58
72
|
if (props && _typeof(props) === "object") {
|
@@ -84,8 +98,8 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
84
98
|
}
|
85
99
|
}
|
86
100
|
}
|
87
|
-
if (valSources.
|
88
|
-
props["data-val-path"] = valSources.join(",");
|
101
|
+
if (valSources.size > 0 && !props["data-val-path"]) {
|
102
|
+
props["data-val-path"] = Array.from(valSources).join(",");
|
89
103
|
}
|
90
104
|
}
|
91
105
|
};
|
@@ -183,6 +197,9 @@ function _objectSpread2(e) {
|
|
183
197
|
|
184
198
|
function stegaEncode(input, opts) {
|
185
199
|
function rec(sourceOrSelector, recOpts) {
|
200
|
+
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isKeyOfSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
201
|
+
return sourceOrSelector;
|
202
|
+
}
|
186
203
|
if (recOpts !== null && recOpts !== void 0 && recOpts.schema && isLiteralSchema(recOpts === null || recOpts === void 0 ? void 0 : recOpts.schema)) {
|
187
204
|
return sourceOrSelector;
|
188
205
|
}
|
@@ -325,6 +342,9 @@ function unknownSchema(schema) {
|
|
325
342
|
function isUnionSchema(schema) {
|
326
343
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "union";
|
327
344
|
}
|
345
|
+
function isKeyOfSchema(schema) {
|
346
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === "keyOf";
|
347
|
+
}
|
328
348
|
function isObjectSchema(schema) {
|
329
349
|
return (schema === null || schema === void 0 ? void 0 : schema.type) === "object";
|
330
350
|
}
|
@@ -381,4 +401,13 @@ function getModuleIds(input) {
|
|
381
401
|
return Array.from(modules);
|
382
402
|
}
|
383
403
|
|
384
|
-
|
404
|
+
// NOTE: the exports of this file needs to be kept in sync with ValQuickJSRuntime
|
405
|
+
var autoTagJSXEnabled = false;
|
406
|
+
function IS_AUTO_TAG_JSX_ENABLED() {
|
407
|
+
return autoTagJSXEnabled;
|
408
|
+
}
|
409
|
+
function SET_AUTO_TAG_JSX_ENABLED(enabled) {
|
410
|
+
autoTagJSXEnabled = enabled;
|
411
|
+
}
|
412
|
+
|
413
|
+
export { IS_AUTO_TAG_JSX_ENABLED, SET_AUTO_TAG_JSX_ENABLED, autoTagJSX, getModuleIds, stegaClean, stegaDecodeString, stegaEncode };
|