@valbuild/react 0.44.0 → 0.45.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/index.d.ts +2 -0
- package/dist/declarations/src/stega/stegaDecodeString.d.ts +1 -0
- package/dist/declarations/src/stega/stegaEncode.d.ts +6 -4
- package/package.json +4 -4
- package/stega/dist/valbuild-react-stega.browser.esm.js +18 -13
- package/stega/dist/valbuild-react-stega.cjs.dev.js +17 -11
- package/stega/dist/valbuild-react-stega.cjs.prod.js +17 -11
- package/stega/dist/valbuild-react-stega.esm.js +18 -13
- package/stega/dist/valbuild-react-stega.worker.esm.js +18 -13
@@ -1,2 +1,4 @@
|
|
1
1
|
export { autoTagJSX } from "./autoTagJSX.js";
|
2
2
|
export { stegaEncode, getModuleIds, stegaClean, type ValEncodedString, type StegaOfSource, } from "./stegaEncode.js";
|
3
|
+
export { type Image } from "./stegaEncode.js";
|
4
|
+
export { stegaDecodeString } from "./stegaDecodeString.js";
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function stegaDecodeString(encodedString: string): string | undefined;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Json, RichTextSource, RichText } from "@valbuild/core";
|
1
|
+
import { Json, RichTextSource, RichText, ImageMetadata } 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";
|
@@ -146,9 +146,11 @@ export type ValEncodedString = `${string}__VAL_ENCODED_STRING_INVISIBLE_CHARS` &
|
|
146
146
|
length: never;
|
147
147
|
[brand]: "ValEncodedString";
|
148
148
|
};
|
149
|
-
export type
|
150
|
-
url: ValEncodedString;
|
151
|
-
|
149
|
+
export type Image = {
|
150
|
+
readonly url: ValEncodedString;
|
151
|
+
readonly metadata?: ImageMetadata;
|
152
|
+
};
|
153
|
+
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 : T : T extends SourceObject ? {
|
152
154
|
[key in keyof T]: StegaOfSource<T[key]>;
|
153
155
|
} : T extends SourceArray ? StegaOfSource<T[number]>[] : T extends RawString ? string : string extends T ? ValEncodedString : T extends JsonPrimitive ? T : never;
|
154
156
|
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.45.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.45.0",
|
13
|
+
"@valbuild/shared": "~0.45.0",
|
14
|
+
"@valbuild/ui": "~0.45.0",
|
15
15
|
"@vercel/stega": "^0.1.0",
|
16
16
|
"base64-arraybuffer": "^1.0.2",
|
17
17
|
"style-to-object": "^0.4.1"
|
@@ -3,11 +3,20 @@ import { _ as _typeof } from '../../dist/typeof-9915e135.browser.esm.js';
|
|
3
3
|
import ReactJSXRuntime__default from 'react/jsx-runtime';
|
4
4
|
import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
|
5
5
|
import React from 'react';
|
6
|
-
import {
|
6
|
+
import { vercelStegaDecode, VERCEL_STEGA_REGEX, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
|
7
7
|
import { _ as _defineProperty } from '../../dist/defineProperty-f319cb47.browser.esm.js';
|
8
8
|
import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
|
9
9
|
import { parseRichTextSource } from '@valbuild/shared/internal';
|
10
10
|
|
11
|
+
function stegaDecodeString(encodedString) {
|
12
|
+
var encodedBits = vercelStegaDecode(encodedString);
|
13
|
+
if (encodedBits && _typeof(encodedBits) === "object") {
|
14
|
+
if ("origin" in encodedBits && "data" in encodedBits && _typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
|
15
|
+
return encodedBits.data.valPath;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
11
20
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
12
21
|
// TODO: think this is not correct, but good enough for now?
|
13
22
|
return typeof type === "string";
|
@@ -20,20 +29,16 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
20
29
|
key = _Object$entries$_i[0],
|
21
30
|
value = _Object$entries$_i[1];
|
22
31
|
if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
|
23
|
-
var
|
24
|
-
|
25
|
-
if (
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
valSources.push(valPath);
|
30
|
-
props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
|
31
|
-
props["data-val-attr-".concat(key.toLowerCase())] = valPath;
|
32
|
-
}
|
32
|
+
var valPath = stegaDecodeString(value);
|
33
|
+
var attr = "data-val-attr-".concat(key.toLowerCase());
|
34
|
+
if (valPath && !props[attr]) {
|
35
|
+
valSources.push(valPath);
|
36
|
+
props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
|
37
|
+
props[attr] = valPath;
|
33
38
|
}
|
34
39
|
}
|
35
40
|
}
|
36
|
-
if (valSources.length > 0) {
|
41
|
+
if (valSources.length > 0 && !props["data-val-path"]) {
|
37
42
|
props["data-val-path"] = valSources.join(",");
|
38
43
|
}
|
39
44
|
}
|
@@ -285,4 +290,4 @@ function getModuleIds(input) {
|
|
285
290
|
return Array.from(modules);
|
286
291
|
}
|
287
292
|
|
288
|
-
export { autoTagJSX, getModuleIds, stegaClean, stegaEncode };
|
293
|
+
export { autoTagJSX, getModuleIds, stegaClean, stegaDecodeString, stegaEncode };
|
@@ -18,6 +18,15 @@ var ReactJSXRuntime__default = /*#__PURE__*/_interopDefault(ReactJSXRuntime);
|
|
18
18
|
var jsxRuntimeDev__default = /*#__PURE__*/_interopDefault(jsxRuntimeDev);
|
19
19
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
20
20
|
|
21
|
+
function stegaDecodeString(encodedString) {
|
22
|
+
var encodedBits = stega.vercelStegaDecode(encodedString);
|
23
|
+
if (encodedBits && _typeof._typeof(encodedBits) === "object") {
|
24
|
+
if ("origin" in encodedBits && "data" in encodedBits && _typeof._typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
|
25
|
+
return encodedBits.data.valPath;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
21
30
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
22
31
|
// TODO: think this is not correct, but good enough for now?
|
23
32
|
return typeof type === "string";
|
@@ -30,20 +39,16 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
30
39
|
key = _Object$entries$_i[0],
|
31
40
|
value = _Object$entries$_i[1];
|
32
41
|
if (typeof value === "string" && value.match(stega.VERCEL_STEGA_REGEX)) {
|
33
|
-
var
|
34
|
-
|
35
|
-
if (
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
valSources.push(valPath);
|
40
|
-
props[key] = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
|
41
|
-
props["data-val-attr-".concat(key.toLowerCase())] = valPath;
|
42
|
-
}
|
42
|
+
var valPath = stegaDecodeString(value);
|
43
|
+
var attr = "data-val-attr-".concat(key.toLowerCase());
|
44
|
+
if (valPath && !props[attr]) {
|
45
|
+
valSources.push(valPath);
|
46
|
+
props[key] = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
|
47
|
+
props[attr] = valPath;
|
43
48
|
}
|
44
49
|
}
|
45
50
|
}
|
46
|
-
if (valSources.length > 0) {
|
51
|
+
if (valSources.length > 0 && !props["data-val-path"]) {
|
47
52
|
props["data-val-path"] = valSources.join(",");
|
48
53
|
}
|
49
54
|
}
|
@@ -298,4 +303,5 @@ function getModuleIds(input) {
|
|
298
303
|
exports.autoTagJSX = autoTagJSX;
|
299
304
|
exports.getModuleIds = getModuleIds;
|
300
305
|
exports.stegaClean = stegaClean;
|
306
|
+
exports.stegaDecodeString = stegaDecodeString;
|
301
307
|
exports.stegaEncode = stegaEncode;
|
@@ -18,6 +18,15 @@ var ReactJSXRuntime__default = /*#__PURE__*/_interopDefault(ReactJSXRuntime);
|
|
18
18
|
var jsxRuntimeDev__default = /*#__PURE__*/_interopDefault(jsxRuntimeDev);
|
19
19
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
20
20
|
|
21
|
+
function stegaDecodeString(encodedString) {
|
22
|
+
var encodedBits = stega.vercelStegaDecode(encodedString);
|
23
|
+
if (encodedBits && _typeof._typeof(encodedBits) === "object") {
|
24
|
+
if ("origin" in encodedBits && "data" in encodedBits && _typeof._typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
|
25
|
+
return encodedBits.data.valPath;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
21
30
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
22
31
|
// TODO: think this is not correct, but good enough for now?
|
23
32
|
return typeof type === "string";
|
@@ -30,20 +39,16 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
30
39
|
key = _Object$entries$_i[0],
|
31
40
|
value = _Object$entries$_i[1];
|
32
41
|
if (typeof value === "string" && value.match(stega.VERCEL_STEGA_REGEX)) {
|
33
|
-
var
|
34
|
-
|
35
|
-
if (
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
valSources.push(valPath);
|
40
|
-
props[key] = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
|
41
|
-
props["data-val-attr-".concat(key.toLowerCase())] = valPath;
|
42
|
-
}
|
42
|
+
var valPath = stegaDecodeString(value);
|
43
|
+
var attr = "data-val-attr-".concat(key.toLowerCase());
|
44
|
+
if (valPath && !props[attr]) {
|
45
|
+
valSources.push(valPath);
|
46
|
+
props[key] = isIntrinsicElement(type) ? stega.vercelStegaSplit(value).cleaned : value;
|
47
|
+
props[attr] = valPath;
|
43
48
|
}
|
44
49
|
}
|
45
50
|
}
|
46
|
-
if (valSources.length > 0) {
|
51
|
+
if (valSources.length > 0 && !props["data-val-path"]) {
|
47
52
|
props["data-val-path"] = valSources.join(",");
|
48
53
|
}
|
49
54
|
}
|
@@ -298,4 +303,5 @@ function getModuleIds(input) {
|
|
298
303
|
exports.autoTagJSX = autoTagJSX;
|
299
304
|
exports.getModuleIds = getModuleIds;
|
300
305
|
exports.stegaClean = stegaClean;
|
306
|
+
exports.stegaDecodeString = stegaDecodeString;
|
301
307
|
exports.stegaEncode = stegaEncode;
|
@@ -3,11 +3,20 @@ import { _ as _typeof } from '../../dist/typeof-a1531d8f.esm.js';
|
|
3
3
|
import ReactJSXRuntime__default from 'react/jsx-runtime';
|
4
4
|
import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
|
5
5
|
import React from 'react';
|
6
|
-
import {
|
6
|
+
import { vercelStegaDecode, VERCEL_STEGA_REGEX, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
|
7
7
|
import { _ as _defineProperty } from '../../dist/defineProperty-12b5bd29.esm.js';
|
8
8
|
import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
|
9
9
|
import { parseRichTextSource } from '@valbuild/shared/internal';
|
10
10
|
|
11
|
+
function stegaDecodeString(encodedString) {
|
12
|
+
var encodedBits = vercelStegaDecode(encodedString);
|
13
|
+
if (encodedBits && _typeof(encodedBits) === "object") {
|
14
|
+
if ("origin" in encodedBits && "data" in encodedBits && _typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
|
15
|
+
return encodedBits.data.valPath;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
11
20
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
12
21
|
// TODO: think this is not correct, but good enough for now?
|
13
22
|
return typeof type === "string";
|
@@ -20,20 +29,16 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
20
29
|
key = _Object$entries$_i[0],
|
21
30
|
value = _Object$entries$_i[1];
|
22
31
|
if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
|
23
|
-
var
|
24
|
-
|
25
|
-
if (
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
valSources.push(valPath);
|
30
|
-
props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
|
31
|
-
props["data-val-attr-".concat(key.toLowerCase())] = valPath;
|
32
|
-
}
|
32
|
+
var valPath = stegaDecodeString(value);
|
33
|
+
var attr = "data-val-attr-".concat(key.toLowerCase());
|
34
|
+
if (valPath && !props[attr]) {
|
35
|
+
valSources.push(valPath);
|
36
|
+
props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
|
37
|
+
props[attr] = valPath;
|
33
38
|
}
|
34
39
|
}
|
35
40
|
}
|
36
|
-
if (valSources.length > 0) {
|
41
|
+
if (valSources.length > 0 && !props["data-val-path"]) {
|
37
42
|
props["data-val-path"] = valSources.join(",");
|
38
43
|
}
|
39
44
|
}
|
@@ -285,4 +290,4 @@ function getModuleIds(input) {
|
|
285
290
|
return Array.from(modules);
|
286
291
|
}
|
287
292
|
|
288
|
-
export { autoTagJSX, getModuleIds, stegaClean, stegaEncode };
|
293
|
+
export { autoTagJSX, getModuleIds, stegaClean, stegaDecodeString, stegaEncode };
|
@@ -3,11 +3,20 @@ import { _ as _typeof } from '../../dist/typeof-e0c837cc.worker.esm.js';
|
|
3
3
|
import ReactJSXRuntime__default from 'react/jsx-runtime';
|
4
4
|
import jsxRuntimeDev__default from 'react/jsx-dev-runtime';
|
5
5
|
import React from 'react';
|
6
|
-
import {
|
6
|
+
import { vercelStegaDecode, VERCEL_STEGA_REGEX, vercelStegaSplit, vercelStegaCombine } from '@vercel/stega';
|
7
7
|
import { _ as _defineProperty } from '../../dist/defineProperty-a4bf59bc.worker.esm.js';
|
8
8
|
import { Internal, VAL_EXTENSION, FILE_REF_PROP } from '@valbuild/core';
|
9
9
|
import { parseRichTextSource } from '@valbuild/shared/internal';
|
10
10
|
|
11
|
+
function stegaDecodeString(encodedString) {
|
12
|
+
var encodedBits = vercelStegaDecode(encodedString);
|
13
|
+
if (encodedBits && _typeof(encodedBits) === "object") {
|
14
|
+
if ("origin" in encodedBits && "data" in encodedBits && _typeof(encodedBits.data) === "object" && encodedBits.data && "valPath" in encodedBits.data && typeof encodedBits.data.valPath === "string") {
|
15
|
+
return encodedBits.data.valPath;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
11
20
|
var isIntrinsicElement = function isIntrinsicElement(type) {
|
12
21
|
// TODO: think this is not correct, but good enough for now?
|
13
22
|
return typeof type === "string";
|
@@ -20,20 +29,16 @@ var addValPathIfFound = function addValPathIfFound(type, props) {
|
|
20
29
|
key = _Object$entries$_i[0],
|
21
30
|
value = _Object$entries$_i[1];
|
22
31
|
if (typeof value === "string" && value.match(VERCEL_STEGA_REGEX)) {
|
23
|
-
var
|
24
|
-
|
25
|
-
if (
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
valSources.push(valPath);
|
30
|
-
props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
|
31
|
-
props["data-val-attr-".concat(key.toLowerCase())] = valPath;
|
32
|
-
}
|
32
|
+
var valPath = stegaDecodeString(value);
|
33
|
+
var attr = "data-val-attr-".concat(key.toLowerCase());
|
34
|
+
if (valPath && !props[attr]) {
|
35
|
+
valSources.push(valPath);
|
36
|
+
props[key] = isIntrinsicElement(type) ? vercelStegaSplit(value).cleaned : value;
|
37
|
+
props[attr] = valPath;
|
33
38
|
}
|
34
39
|
}
|
35
40
|
}
|
36
|
-
if (valSources.length > 0) {
|
41
|
+
if (valSources.length > 0 && !props["data-val-path"]) {
|
37
42
|
props["data-val-path"] = valSources.join(",");
|
38
43
|
}
|
39
44
|
}
|
@@ -285,4 +290,4 @@ function getModuleIds(input) {
|
|
285
290
|
return Array.from(modules);
|
286
291
|
}
|
287
292
|
|
288
|
-
export { autoTagJSX, getModuleIds, stegaClean, stegaEncode };
|
293
|
+
export { autoTagJSX, getModuleIds, stegaClean, stegaDecodeString, stegaEncode };
|