@valbuild/react 0.48.0 → 0.49.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/declarations/src/stega/stegaEncode.d.ts +6 -2
- package/package.json +4 -4
- package/stega/dist/valbuild-react-stega.browser.esm.js +36 -6
- package/stega/dist/valbuild-react-stega.cjs.dev.js +36 -6
- package/stega/dist/valbuild-react-stega.cjs.prod.js +36 -6
- package/stega/dist/valbuild-react-stega.esm.js +36 -6
- package/stega/dist/valbuild-react-stega.worker.esm.js +36 -6
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Json, RichTextSource, RichText, ImageMetadata } from "@valbuild/core";
|
1
|
+
import { Json, RichTextSource, RichText, ImageMetadata, FileMetadata } from "@valbuild/core";
|
2
2
|
import { FileSource, Source, SourceObject } from "@valbuild/core";
|
3
3
|
import { JsonPrimitive } from "@valbuild/core";
|
4
4
|
import { SourceArray } from "@valbuild/core";
|
@@ -150,7 +150,11 @@ export type Image = {
|
|
150
150
|
readonly url: ValEncodedString;
|
151
151
|
readonly metadata?: ImageMetadata;
|
152
152
|
};
|
153
|
-
export type
|
153
|
+
export type File<Metadata extends FileMetadata> = {
|
154
|
+
readonly url: ValEncodedString;
|
155
|
+
readonly metadata?: Metadata;
|
156
|
+
};
|
157
|
+
export type StegaOfSource<T extends Source> = Json extends T ? Json : T extends RichTextSource<infer O> ? RichText<O> : T extends FileSource<infer M> ? M extends ImageMetadata ? Image : M extends FileMetadata ? File<M> : never : T extends SourceObject ? {
|
154
158
|
[key in keyof T]: StegaOfSource<T[key]>;
|
155
159
|
} : T extends SourceArray ? StegaOfSource<T[number]>[] : T extends RawString ? string : string extends T ? ValEncodedString : T extends JsonPrimitive ? T : never;
|
156
160
|
export declare function stegaEncode(input: any, opts: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@valbuild/react",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.49.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.
|
13
|
-
"@valbuild/shared": "~0.
|
14
|
-
"@valbuild/ui": "~0.
|
12
|
+
"@valbuild/core": "~0.49.0",
|
13
|
+
"@valbuild/shared": "~0.49.0",
|
14
|
+
"@valbuild/ui": "~0.49.0",
|
15
15
|
"@vercel/stega": "^0.1.0",
|
16
16
|
"base64-arraybuffer": "^1.0.2",
|
17
17
|
"style-to-object": "^0.4.1"
|
@@ -23,18 +23,48 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
|
|
23
23
|
};
|
24
24
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
25
25
|
var valSources = [];
|
26
|
+
function add(key, value, props, container) {
|
27
|
+
var valPath = stegaDecodeString(value);
|
28
|
+
var attr = "data-val-attr-".concat(key.toString().toLowerCase());
|
29
|
+
if (valPath && !props[attr]) {
|
30
|
+
valSources.push(valPath);
|
31
|
+
var cleanValue = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
|
32
|
+
if (Array.isArray(container) && typeof key === "number") {
|
33
|
+
container[key] = cleanValue;
|
34
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
35
|
+
container[key] = cleanValue;
|
36
|
+
} else {
|
37
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
38
|
+
}
|
39
|
+
props[attr] = valPath;
|
40
|
+
}
|
41
|
+
}
|
26
42
|
if (props && _typeof(props) === "object") {
|
27
43
|
for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
|
28
44
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
29
45
|
key = _Object$entries$_i[0],
|
30
46
|
value = _Object$entries$_i[1];
|
31
47
|
if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
|
32
|
-
|
33
|
-
|
34
|
-
if (
|
35
|
-
|
36
|
-
|
37
|
-
|
48
|
+
add(key, value, props, props);
|
49
|
+
} else if (_typeof(value) === "object" && value !== null) {
|
50
|
+
if (key === "style") {
|
51
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
|
52
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
53
|
+
styleKey = _Object$entries2$_i[0],
|
54
|
+
styleValue = _Object$entries2$_i[1];
|
55
|
+
if (typeof styleValue === "string" && styleValue.match(VERCEL_STEGA_REGEX)) {
|
56
|
+
add(styleKey, styleValue, props, value);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
} else if (value instanceof Array) {
|
60
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
|
61
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
62
|
+
index = _Object$entries3$_i[0],
|
63
|
+
item = _Object$entries3$_i[1];
|
64
|
+
if (typeof item === "string" && item.match(VERCEL_STEGA_REGEX)) {
|
65
|
+
add(index, item, props, value);
|
66
|
+
}
|
67
|
+
}
|
38
68
|
}
|
39
69
|
}
|
40
70
|
}
|
@@ -33,18 +33,48 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
|
|
33
33
|
};
|
34
34
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
35
35
|
var valSources = [];
|
36
|
+
function add(key, value, props, container) {
|
37
|
+
var valPath = stegaDecodeString(value);
|
38
|
+
var attr = "data-val-attr-".concat(key.toString().toLowerCase());
|
39
|
+
if (valPath && !props[attr]) {
|
40
|
+
valSources.push(valPath);
|
41
|
+
var cleanValue = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
|
42
|
+
if (Array.isArray(container) && typeof key === "number") {
|
43
|
+
container[key] = cleanValue;
|
44
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
45
|
+
container[key] = cleanValue;
|
46
|
+
} else {
|
47
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
48
|
+
}
|
49
|
+
props[attr] = valPath;
|
50
|
+
}
|
51
|
+
}
|
36
52
|
if (props && _typeof._typeof(props) === "object") {
|
37
53
|
for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
|
38
54
|
var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
|
39
55
|
key = _Object$entries$_i[0],
|
40
56
|
value = _Object$entries$_i[1];
|
41
57
|
if (typeof value === "string" && value.match(stega.VERCEL_STEGA_REGEX)) {
|
42
|
-
|
43
|
-
|
44
|
-
if (
|
45
|
-
|
46
|
-
|
47
|
-
|
58
|
+
add(key, value, props, props);
|
59
|
+
} else if (_typeof._typeof(value) === "object" && value !== null) {
|
60
|
+
if (key === "style") {
|
61
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
|
62
|
+
var _Object$entries2$_i = slicedToArray._slicedToArray(_Object$entries2[_i2], 2),
|
63
|
+
styleKey = _Object$entries2$_i[0],
|
64
|
+
styleValue = _Object$entries2$_i[1];
|
65
|
+
if (typeof styleValue === "string" && styleValue.match(stega.VERCEL_STEGA_REGEX)) {
|
66
|
+
add(styleKey, styleValue, props, value);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
} else if (value instanceof Array) {
|
70
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
|
71
|
+
var _Object$entries3$_i = slicedToArray._slicedToArray(_Object$entries3[_i3], 2),
|
72
|
+
index = _Object$entries3$_i[0],
|
73
|
+
item = _Object$entries3$_i[1];
|
74
|
+
if (typeof item === "string" && item.match(stega.VERCEL_STEGA_REGEX)) {
|
75
|
+
add(index, item, props, value);
|
76
|
+
}
|
77
|
+
}
|
48
78
|
}
|
49
79
|
}
|
50
80
|
}
|
@@ -33,18 +33,48 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
|
|
33
33
|
};
|
34
34
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
35
35
|
var valSources = [];
|
36
|
+
function add(key, value, props, container) {
|
37
|
+
var valPath = stegaDecodeString(value);
|
38
|
+
var attr = "data-val-attr-".concat(key.toString().toLowerCase());
|
39
|
+
if (valPath && !props[attr]) {
|
40
|
+
valSources.push(valPath);
|
41
|
+
var cleanValue = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
|
42
|
+
if (Array.isArray(container) && typeof key === "number") {
|
43
|
+
container[key] = cleanValue;
|
44
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
45
|
+
container[key] = cleanValue;
|
46
|
+
} else {
|
47
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
48
|
+
}
|
49
|
+
props[attr] = valPath;
|
50
|
+
}
|
51
|
+
}
|
36
52
|
if (props && _typeof._typeof(props) === "object") {
|
37
53
|
for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
|
38
54
|
var _Object$entries$_i = slicedToArray._slicedToArray(_Object$entries[_i], 2),
|
39
55
|
key = _Object$entries$_i[0],
|
40
56
|
value = _Object$entries$_i[1];
|
41
57
|
if (typeof value === "string" && value.match(stega.VERCEL_STEGA_REGEX)) {
|
42
|
-
|
43
|
-
|
44
|
-
if (
|
45
|
-
|
46
|
-
|
47
|
-
|
58
|
+
add(key, value, props, props);
|
59
|
+
} else if (_typeof._typeof(value) === "object" && value !== null) {
|
60
|
+
if (key === "style") {
|
61
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
|
62
|
+
var _Object$entries2$_i = slicedToArray._slicedToArray(_Object$entries2[_i2], 2),
|
63
|
+
styleKey = _Object$entries2$_i[0],
|
64
|
+
styleValue = _Object$entries2$_i[1];
|
65
|
+
if (typeof styleValue === "string" && styleValue.match(stega.VERCEL_STEGA_REGEX)) {
|
66
|
+
add(styleKey, styleValue, props, value);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
} else if (value instanceof Array) {
|
70
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
|
71
|
+
var _Object$entries3$_i = slicedToArray._slicedToArray(_Object$entries3[_i3], 2),
|
72
|
+
index = _Object$entries3$_i[0],
|
73
|
+
item = _Object$entries3$_i[1];
|
74
|
+
if (typeof item === "string" && item.match(stega.VERCEL_STEGA_REGEX)) {
|
75
|
+
add(index, item, props, value);
|
76
|
+
}
|
77
|
+
}
|
48
78
|
}
|
49
79
|
}
|
50
80
|
}
|
@@ -23,18 +23,48 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
|
|
23
23
|
};
|
24
24
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
25
25
|
var valSources = [];
|
26
|
+
function add(key, value, props, container) {
|
27
|
+
var valPath = stegaDecodeString(value);
|
28
|
+
var attr = "data-val-attr-".concat(key.toString().toLowerCase());
|
29
|
+
if (valPath && !props[attr]) {
|
30
|
+
valSources.push(valPath);
|
31
|
+
var cleanValue = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
|
32
|
+
if (Array.isArray(container) && typeof key === "number") {
|
33
|
+
container[key] = cleanValue;
|
34
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
35
|
+
container[key] = cleanValue;
|
36
|
+
} else {
|
37
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
38
|
+
}
|
39
|
+
props[attr] = valPath;
|
40
|
+
}
|
41
|
+
}
|
26
42
|
if (props && _typeof(props) === "object") {
|
27
43
|
for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
|
28
44
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
29
45
|
key = _Object$entries$_i[0],
|
30
46
|
value = _Object$entries$_i[1];
|
31
47
|
if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
|
32
|
-
|
33
|
-
|
34
|
-
if (
|
35
|
-
|
36
|
-
|
37
|
-
|
48
|
+
add(key, value, props, props);
|
49
|
+
} else if (_typeof(value) === "object" && value !== null) {
|
50
|
+
if (key === "style") {
|
51
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
|
52
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
53
|
+
styleKey = _Object$entries2$_i[0],
|
54
|
+
styleValue = _Object$entries2$_i[1];
|
55
|
+
if (typeof styleValue === "string" && styleValue.match(VERCEL_STEGA_REGEX)) {
|
56
|
+
add(styleKey, styleValue, props, value);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
} else if (value instanceof Array) {
|
60
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
|
61
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
62
|
+
index = _Object$entries3$_i[0],
|
63
|
+
item = _Object$entries3$_i[1];
|
64
|
+
if (typeof item === "string" && item.match(VERCEL_STEGA_REGEX)) {
|
65
|
+
add(index, item, props, value);
|
66
|
+
}
|
67
|
+
}
|
38
68
|
}
|
39
69
|
}
|
40
70
|
}
|
@@ -23,18 +23,48 @@ var isIntrinsicElement = function isIntrinsicElement(type) {
|
|
23
23
|
};
|
24
24
|
var addValPathIfFound = function addValPathIfFound(type, props) {
|
25
25
|
var valSources = [];
|
26
|
+
function add(key, value, props, container) {
|
27
|
+
var valPath = stegaDecodeString(value);
|
28
|
+
var attr = "data-val-attr-".concat(key.toString().toLowerCase());
|
29
|
+
if (valPath && !props[attr]) {
|
30
|
+
valSources.push(valPath);
|
31
|
+
var cleanValue = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
|
32
|
+
if (Array.isArray(container) && typeof key === "number") {
|
33
|
+
container[key] = cleanValue;
|
34
|
+
} else if (typeof key === "string" && !Array.isArray(container)) {
|
35
|
+
container[key] = cleanValue;
|
36
|
+
} else {
|
37
|
+
console.error("Val: Could not auto tag. Reason: unexpected types found while cleaning and / or adding val path data props.");
|
38
|
+
}
|
39
|
+
props[attr] = valPath;
|
40
|
+
}
|
41
|
+
}
|
26
42
|
if (props && _typeof(props) === "object") {
|
27
43
|
for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
|
28
44
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
29
45
|
key = _Object$entries$_i[0],
|
30
46
|
value = _Object$entries$_i[1];
|
31
47
|
if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
|
32
|
-
|
33
|
-
|
34
|
-
if (
|
35
|
-
|
36
|
-
|
37
|
-
|
48
|
+
add(key, value, props, props);
|
49
|
+
} else if (_typeof(value) === "object" && value !== null) {
|
50
|
+
if (key === "style") {
|
51
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(value); _i2 < _Object$entries2.length; _i2++) {
|
52
|
+
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
53
|
+
styleKey = _Object$entries2$_i[0],
|
54
|
+
styleValue = _Object$entries2$_i[1];
|
55
|
+
if (typeof styleValue === "string" && styleValue.match(VERCEL_STEGA_REGEX)) {
|
56
|
+
add(styleKey, styleValue, props, value);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
} else if (value instanceof Array) {
|
60
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(value); _i3 < _Object$entries3.length; _i3++) {
|
61
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
62
|
+
index = _Object$entries3$_i[0],
|
63
|
+
item = _Object$entries3$_i[1];
|
64
|
+
if (typeof item === "string" && item.match(VERCEL_STEGA_REGEX)) {
|
65
|
+
add(index, item, props, value);
|
66
|
+
}
|
67
|
+
}
|
38
68
|
}
|
39
69
|
}
|
40
70
|
}
|