@uniformdev/canvas 20.72.3-alpha.5 → 20.72.3-alpha.7
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/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.esm.js +7 -7
- package/dist/index.js +7 -7
- package/dist/index.mjs +7 -7
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -15049,10 +15049,14 @@ declare function createVariableReference(variableName: string): string;
|
|
|
15049
15049
|
declare function hasReferencedVariables(value: string | undefined): number;
|
|
15050
15050
|
|
|
15051
15051
|
/**
|
|
15052
|
-
* Parses an expression that may contain Uniform variables and invokes a callback for each text or variable token found
|
|
15052
|
+
* Parses an expression that may contain Uniform variables and invokes a callback for each text or variable token found.
|
|
15053
|
+
* The callback receives the token, its type, and `offset` — the index in `serialized` where the token's content
|
|
15054
|
+
* begins. Because text tokens are always contiguous substrings of `serialized`, `offset + token.indexOf(x)` maps a
|
|
15055
|
+
* position inside a text token back to the original string (which reconstructing from token lengths cannot do, since
|
|
15056
|
+
* escape characters are stripped from token values).
|
|
15053
15057
|
* @returns the number of tokens found in the string (variable or text)
|
|
15054
15058
|
*/
|
|
15055
|
-
declare function parseVariableExpression(serialized: string, onToken?: (token: string, type: 'text' | 'variable') => void | false): number;
|
|
15059
|
+
declare function parseVariableExpression(serialized: string, onToken?: (token: string, type: 'text' | 'variable', offset: number) => void | false): number;
|
|
15056
15060
|
|
|
15057
15061
|
declare const version = "20.72.2";
|
|
15058
15062
|
|
package/dist/index.d.ts
CHANGED
|
@@ -15049,10 +15049,14 @@ declare function createVariableReference(variableName: string): string;
|
|
|
15049
15049
|
declare function hasReferencedVariables(value: string | undefined): number;
|
|
15050
15050
|
|
|
15051
15051
|
/**
|
|
15052
|
-
* Parses an expression that may contain Uniform variables and invokes a callback for each text or variable token found
|
|
15052
|
+
* Parses an expression that may contain Uniform variables and invokes a callback for each text or variable token found.
|
|
15053
|
+
* The callback receives the token, its type, and `offset` — the index in `serialized` where the token's content
|
|
15054
|
+
* begins. Because text tokens are always contiguous substrings of `serialized`, `offset + token.indexOf(x)` maps a
|
|
15055
|
+
* position inside a text token back to the original string (which reconstructing from token lengths cannot do, since
|
|
15056
|
+
* escape characters are stripped from token values).
|
|
15053
15057
|
* @returns the number of tokens found in the string (variable or text)
|
|
15054
15058
|
*/
|
|
15055
|
-
declare function parseVariableExpression(serialized: string, onToken?: (token: string, type: 'text' | 'variable') => void | false): number;
|
|
15059
|
+
declare function parseVariableExpression(serialized: string, onToken?: (token: string, type: 'text' | 'variable', offset: number) => void | false): number;
|
|
15056
15060
|
|
|
15057
15061
|
declare const version = "20.72.2";
|
|
15058
15062
|
|
package/dist/index.esm.js
CHANGED
|
@@ -711,9 +711,9 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
711
711
|
let bufferStartIndex = 0;
|
|
712
712
|
let bufferEndIndex = 0;
|
|
713
713
|
let tokenCount = 0;
|
|
714
|
-
const handleToken = (token, type) => {
|
|
714
|
+
const handleToken = (token, type, offset) => {
|
|
715
715
|
tokenCount++;
|
|
716
|
-
return onToken == null ? void 0 : onToken(token, type);
|
|
716
|
+
return onToken == null ? void 0 : onToken(token, type, offset);
|
|
717
717
|
};
|
|
718
718
|
let state = "text";
|
|
719
719
|
for (let index = 0; index < serialized.length; index++) {
|
|
@@ -724,7 +724,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
724
724
|
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
|
725
725
|
if (serialized[index - 1] === escapeCharacter) {
|
|
726
726
|
bufferEndIndex -= escapeCharacter.length;
|
|
727
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
727
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
728
728
|
return tokenCount;
|
|
729
729
|
}
|
|
730
730
|
bufferStartIndex = index;
|
|
@@ -733,12 +733,12 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
733
733
|
}
|
|
734
734
|
if (state === "variable") {
|
|
735
735
|
const textStart = bufferStartIndex - variablePrefix.length;
|
|
736
|
-
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
|
|
736
|
+
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
|
|
737
737
|
return tokenCount;
|
|
738
738
|
}
|
|
739
739
|
bufferStartIndex = bufferEndIndex;
|
|
740
740
|
} else if (bufferEndIndex > bufferStartIndex) {
|
|
741
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
741
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
742
742
|
return tokenCount;
|
|
743
743
|
}
|
|
744
744
|
bufferStartIndex = bufferEndIndex;
|
|
@@ -756,7 +756,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
756
756
|
state = "text";
|
|
757
757
|
if (bufferEndIndex > bufferStartIndex) {
|
|
758
758
|
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
|
759
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
|
759
|
+
if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
|
|
760
760
|
return tokenCount;
|
|
761
761
|
}
|
|
762
762
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
|
@@ -770,7 +770,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
770
770
|
bufferStartIndex -= variablePrefix.length;
|
|
771
771
|
}
|
|
772
772
|
if (bufferStartIndex < serialized.length) {
|
|
773
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
|
773
|
+
handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
|
|
774
774
|
}
|
|
775
775
|
return tokenCount;
|
|
776
776
|
}
|
package/dist/index.js
CHANGED
|
@@ -920,9 +920,9 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
920
920
|
let bufferStartIndex = 0;
|
|
921
921
|
let bufferEndIndex = 0;
|
|
922
922
|
let tokenCount = 0;
|
|
923
|
-
const handleToken = (token, type) => {
|
|
923
|
+
const handleToken = (token, type, offset) => {
|
|
924
924
|
tokenCount++;
|
|
925
|
-
return onToken == null ? void 0 : onToken(token, type);
|
|
925
|
+
return onToken == null ? void 0 : onToken(token, type, offset);
|
|
926
926
|
};
|
|
927
927
|
let state = "text";
|
|
928
928
|
for (let index = 0; index < serialized.length; index++) {
|
|
@@ -933,7 +933,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
933
933
|
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
|
934
934
|
if (serialized[index - 1] === escapeCharacter) {
|
|
935
935
|
bufferEndIndex -= escapeCharacter.length;
|
|
936
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
936
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
937
937
|
return tokenCount;
|
|
938
938
|
}
|
|
939
939
|
bufferStartIndex = index;
|
|
@@ -942,12 +942,12 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
942
942
|
}
|
|
943
943
|
if (state === "variable") {
|
|
944
944
|
const textStart = bufferStartIndex - variablePrefix.length;
|
|
945
|
-
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
|
|
945
|
+
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
|
|
946
946
|
return tokenCount;
|
|
947
947
|
}
|
|
948
948
|
bufferStartIndex = bufferEndIndex;
|
|
949
949
|
} else if (bufferEndIndex > bufferStartIndex) {
|
|
950
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
950
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
951
951
|
return tokenCount;
|
|
952
952
|
}
|
|
953
953
|
bufferStartIndex = bufferEndIndex;
|
|
@@ -965,7 +965,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
965
965
|
state = "text";
|
|
966
966
|
if (bufferEndIndex > bufferStartIndex) {
|
|
967
967
|
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
|
968
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
|
968
|
+
if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
|
|
969
969
|
return tokenCount;
|
|
970
970
|
}
|
|
971
971
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
|
@@ -979,7 +979,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
979
979
|
bufferStartIndex -= variablePrefix.length;
|
|
980
980
|
}
|
|
981
981
|
if (bufferStartIndex < serialized.length) {
|
|
982
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
|
982
|
+
handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
|
|
983
983
|
}
|
|
984
984
|
return tokenCount;
|
|
985
985
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -711,9 +711,9 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
711
711
|
let bufferStartIndex = 0;
|
|
712
712
|
let bufferEndIndex = 0;
|
|
713
713
|
let tokenCount = 0;
|
|
714
|
-
const handleToken = (token, type) => {
|
|
714
|
+
const handleToken = (token, type, offset) => {
|
|
715
715
|
tokenCount++;
|
|
716
|
-
return onToken == null ? void 0 : onToken(token, type);
|
|
716
|
+
return onToken == null ? void 0 : onToken(token, type, offset);
|
|
717
717
|
};
|
|
718
718
|
let state = "text";
|
|
719
719
|
for (let index = 0; index < serialized.length; index++) {
|
|
@@ -724,7 +724,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
724
724
|
if (char === variablePrefix[0] && serialized[index + 1] === variablePrefix[1]) {
|
|
725
725
|
if (serialized[index - 1] === escapeCharacter) {
|
|
726
726
|
bufferEndIndex -= escapeCharacter.length;
|
|
727
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
727
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
728
728
|
return tokenCount;
|
|
729
729
|
}
|
|
730
730
|
bufferStartIndex = index;
|
|
@@ -733,12 +733,12 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
733
733
|
}
|
|
734
734
|
if (state === "variable") {
|
|
735
735
|
const textStart = bufferStartIndex - variablePrefix.length;
|
|
736
|
-
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text") === false) {
|
|
736
|
+
if (handleToken(serialized.substring(textStart, bufferEndIndex), "text", textStart) === false) {
|
|
737
737
|
return tokenCount;
|
|
738
738
|
}
|
|
739
739
|
bufferStartIndex = bufferEndIndex;
|
|
740
740
|
} else if (bufferEndIndex > bufferStartIndex) {
|
|
741
|
-
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text") === false) {
|
|
741
|
+
if (handleToken(serialized.substring(bufferStartIndex, bufferEndIndex), "text", bufferStartIndex) === false) {
|
|
742
742
|
return tokenCount;
|
|
743
743
|
}
|
|
744
744
|
bufferStartIndex = bufferEndIndex;
|
|
@@ -756,7 +756,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
756
756
|
state = "text";
|
|
757
757
|
if (bufferEndIndex > bufferStartIndex) {
|
|
758
758
|
const unescapedVariableName = serialized.substring(bufferStartIndex, bufferEndIndex).replace(/\\([${}])/g, "$1");
|
|
759
|
-
if (handleToken(unescapedVariableName, "variable") === false) {
|
|
759
|
+
if (handleToken(unescapedVariableName, "variable", bufferStartIndex) === false) {
|
|
760
760
|
return tokenCount;
|
|
761
761
|
}
|
|
762
762
|
bufferStartIndex = bufferEndIndex + variableSuffix.length;
|
|
@@ -770,7 +770,7 @@ function parseVariableExpression(serialized, onToken) {
|
|
|
770
770
|
bufferStartIndex -= variablePrefix.length;
|
|
771
771
|
}
|
|
772
772
|
if (bufferStartIndex < serialized.length) {
|
|
773
|
-
handleToken(serialized.substring(bufferStartIndex), state);
|
|
773
|
+
handleToken(serialized.substring(bufferStartIndex), state, bufferStartIndex);
|
|
774
774
|
}
|
|
775
775
|
return tokenCount;
|
|
776
776
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas",
|
|
3
|
-
"version": "20.72.3-alpha.
|
|
3
|
+
"version": "20.72.3-alpha.7+901df73c39",
|
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"svix": "1.96.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@uniformdev/assets": "20.72.3-alpha.
|
|
40
|
-
"@uniformdev/context": "20.72.3-alpha.
|
|
41
|
-
"@uniformdev/richtext": "20.72.3-alpha.
|
|
39
|
+
"@uniformdev/assets": "20.72.3-alpha.7+901df73c39",
|
|
40
|
+
"@uniformdev/context": "20.72.3-alpha.7+901df73c39",
|
|
41
|
+
"@uniformdev/richtext": "20.72.3-alpha.7+901df73c39",
|
|
42
42
|
"immer": "11.1.8",
|
|
43
43
|
"p-limit": "6.2.0",
|
|
44
44
|
"p-retry": "6.2.1",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "901df73c394d2803f714085ee620521e31c362c8"
|
|
54
54
|
}
|