@plitzi/sdk-shared 0.32.5 → 0.32.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/CHANGELOG.md +8 -0
- package/dist/dataSource/getBindingsDetails.mjs +17 -23
- package/dist/dataSource/helpers/getSourceName.d.ts +4 -0
- package/dist/dataSource/helpers/getSourceName.mjs +4 -0
- package/dist/dataSource/helpers/index.d.ts +2 -0
- package/dist/dataSource/helpers/index.mjs +2 -0
- package/dist/dataSource/hooks/useRegisterSource.mjs +20 -18
- package/dist/dataSource/index.d.ts +1 -0
- package/dist/dataSource/index.mjs +5 -4
- package/dist/dataSource/utility/twigTemplate.mjs +3 -2
- package/dist/helpers/index.mjs +7 -5
- package/dist/helpers/twigWrapper/AST.d.ts +116 -0
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +7 -0
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +220 -0
- package/dist/helpers/twigWrapper/Evaluator/helpers.d.ts +4 -0
- package/dist/helpers/twigWrapper/Evaluator/helpers.mjs +4 -0
- package/dist/helpers/twigWrapper/Evaluator/index.d.ts +2 -0
- package/dist/helpers/twigWrapper/Evaluator/index.mjs +2 -0
- package/dist/helpers/twigWrapper/Lexer/Lexer.d.ts +2 -0
- package/dist/helpers/twigWrapper/Lexer/Lexer.mjs +53 -0
- package/dist/helpers/twigWrapper/Lexer/index.d.ts +3 -0
- package/dist/helpers/twigWrapper/Lexer/index.mjs +3 -0
- package/dist/helpers/twigWrapper/Lexer/types.d.ts +17 -0
- package/dist/helpers/twigWrapper/Lexer/types.mjs +10 -0
- package/dist/helpers/twigWrapper/Parser/Cursor.d.ts +14 -0
- package/dist/helpers/twigWrapper/Parser/Cursor.mjs +63 -0
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.d.ts +3 -0
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +296 -0
- package/dist/helpers/twigWrapper/Parser/Parser.d.ts +3 -0
- package/dist/helpers/twigWrapper/Parser/Parser.mjs +237 -0
- package/dist/helpers/twigWrapper/Parser/helpers.d.ts +2 -0
- package/dist/helpers/twigWrapper/Parser/helpers.mjs +18 -0
- package/dist/helpers/twigWrapper/Parser/index.d.ts +2 -0
- package/dist/helpers/twigWrapper/Parser/index.mjs +2 -0
- package/dist/helpers/twigWrapper/Parser/types.d.ts +5 -0
- package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.d.ts +17 -0
- package/dist/helpers/twigWrapper/TemplateCache/TemplateCache.mjs +64 -0
- package/dist/helpers/twigWrapper/TemplateCache/index.d.ts +1 -0
- package/dist/helpers/twigWrapper/TemplateCache/index.mjs +2 -0
- package/dist/helpers/twigWrapper/bench.bench.d.ts +1 -0
- package/dist/helpers/twigWrapper/charClass.d.ts +44 -0
- package/dist/helpers/twigWrapper/charClass.mjs +59 -0
- package/dist/helpers/twigWrapper/filters/filters.d.ts +14 -0
- package/dist/helpers/twigWrapper/filters/filters.mjs +372 -0
- package/dist/helpers/twigWrapper/filters/index.d.ts +1 -0
- package/dist/helpers/twigWrapper/filters/index.mjs +2 -0
- package/dist/helpers/twigWrapper/index.d.ts +5 -0
- package/dist/helpers/twigWrapper/index.mjs +4 -0
- package/dist/helpers/twigWrapper/processTwig/helpers.d.ts +7 -0
- package/dist/helpers/twigWrapper/processTwig/helpers.mjs +34 -0
- package/dist/helpers/twigWrapper/processTwig/index.d.ts +1 -0
- package/dist/helpers/twigWrapper/processTwig/index.mjs +2 -0
- package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +1 -0
- package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +24 -0
- package/dist/helpers/twigWrapper/tokens/hasValidToken.d.ts +1 -0
- package/dist/helpers/twigWrapper/tokens/hasValidToken.mjs +9 -0
- package/dist/helpers/twigWrapper/tokens/tokenPatterns.d.ts +2 -0
- package/dist/helpers/twigWrapper/tokens/tokenPatterns.mjs +4 -0
- package/dist/hooks/useNetwork.mjs +1 -1
- package/dist/index.mjs +37 -34
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Segment/SegmentAddTemplateMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Segment/SegmentUpdateMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentAddElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentCloneElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentMoveElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentRemoveElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Segment/space/elements/SegmentUpdateElementsMutation.mjs +24 -0
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Segment/style/selectors/SegmentStyleRemoveSelectorsMutation.mjs +12 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceAddTemplateMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceCloneElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceMoveElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRemoveElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementsMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateElementsMutation.mjs +24 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSchemaMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceAddPageMutation.mjs +9 -2
- package/dist/network/graphql/builder/Mutations/Space/pages/SpaceUpdatePageMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorsMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Style/selectors/StyleRemoveSelectorsMutation.mjs +12 -0
- package/dist/network/graphql/builder/Mutations/index.d.ts +8 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +124 -116
- package/dist/network/graphql/builder/Queries/InitQuery.mjs +2 -0
- package/dist/network/graphql/builder/Queries/Segment/SegmentQuery.mjs +1 -0
- package/dist/network/graphql/builder/Queries/Segment/SegmentsQuery.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Segment/SegmentAddTemplateSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentAddElementSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentCloneElementSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentUpdateElementSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentUpdateElementsSubscription.d.ts +7 -0
- package/dist/network/graphql/builder/Subscriptions/Segment/space/elements/SegmentUpdateElementsSubscription.mjs +27 -0
- package/dist/network/graphql/builder/Subscriptions/Segment/style/selectors/SegmentStyleRemoveSelectorsSubscription.d.ts +8 -0
- package/dist/network/graphql/builder/Subscriptions/Segment/style/selectors/SegmentStyleRemoveSelectorsSubscription.mjs +13 -0
- package/dist/network/graphql/builder/Subscriptions/Space/SpaceAddTemplateSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Space/SpaceUpdatedSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceAddElementSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceCloneElementSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceUpdateElementSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceUpdateElementsSubscription.d.ts +6 -0
- package/dist/network/graphql/builder/Subscriptions/Space/elements/SpaceUpdateElementsSubscription.mjs +26 -0
- package/dist/network/graphql/builder/Subscriptions/Space/pages/SpaceAddPageSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Space/pages/SpaceHomePageSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Space/pages/SpaceUpdatePageSubscription.mjs +1 -0
- package/dist/network/graphql/builder/Subscriptions/Style/selector/StyleRemoveSelectorsSubscription.d.ts +7 -0
- package/dist/network/graphql/builder/Subscriptions/Style/selector/StyleRemoveSelectorsSubscription.mjs +12 -0
- package/dist/network/graphql/builder/Subscriptions/index.d.ts +12 -0
- package/dist/network/graphql/builder/Subscriptions/index.mjs +94 -86
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +2 -0
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +1 -0
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +1 -0
- package/dist/store/index.d.ts +33 -33
- package/dist/style/styleConstants.mjs +12 -8
- package/dist/types/CommonTypes.d.ts +1 -3
- package/dist/types/EventBridgeTypes.d.ts +1 -1
- package/dist/types/InteractionTypes.d.ts +2 -1
- package/dist/types/SchemaTypes.d.ts +6 -11
- package/dist/types/ServerTypes.d.ts +59 -0
- package/dist/types/StyleTypes.d.ts +1 -0
- package/package.json +176 -21
- package/dist/helpers/twigWrapper.d.ts +0 -4
- package/dist/helpers/twigWrapper.mjs +0 -33
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isDottedPath as e } from "../charClass.mjs";
|
|
2
|
+
import { lex as t } from "../Lexer/Lexer.mjs";
|
|
3
|
+
import { parse as n } from "../Parser/Parser.mjs";
|
|
4
|
+
//#region src/helpers/twigWrapper/TemplateCache/TemplateCache.ts
|
|
5
|
+
var r = /* @__PURE__ */ new Map(), i = 256, a = {
|
|
6
|
+
hits: 0,
|
|
7
|
+
misses: 0
|
|
8
|
+
}, o = () => ({
|
|
9
|
+
hits: a.hits,
|
|
10
|
+
misses: a.misses
|
|
11
|
+
}), s = () => {
|
|
12
|
+
a.hits = 0, a.misses = 0;
|
|
13
|
+
}, c = (t) => {
|
|
14
|
+
let n = !1, r = !0;
|
|
15
|
+
for (let i = 0; i < t.length; i++) {
|
|
16
|
+
let a = t[i];
|
|
17
|
+
if (a.type === "tag") {
|
|
18
|
+
n = !0;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
if (a.type === "variable" && !e(a.content.trim())) {
|
|
22
|
+
r = !1;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
hasTags: n,
|
|
28
|
+
allSimpleOrDotted: r
|
|
29
|
+
};
|
|
30
|
+
}, l = () => {
|
|
31
|
+
if (r.size >= i) {
|
|
32
|
+
let e = r.keys().next().value;
|
|
33
|
+
e !== void 0 && r.delete(e);
|
|
34
|
+
}
|
|
35
|
+
}, u = (e) => {
|
|
36
|
+
let r = t(e);
|
|
37
|
+
if (r.error) return null;
|
|
38
|
+
let i = r.tokens, { hasTags: a, allSimpleOrDotted: o } = c(i), s = a || !o, l = null, u = null;
|
|
39
|
+
if (s) {
|
|
40
|
+
let e = n(i, !1);
|
|
41
|
+
if (e.error) return null;
|
|
42
|
+
l = e.nodes;
|
|
43
|
+
let t = n(i, !0);
|
|
44
|
+
t.error || (u = t.nodes);
|
|
45
|
+
} else {
|
|
46
|
+
let e = n(i, !0);
|
|
47
|
+
e.error || (u = e.nodes);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
tokens: i,
|
|
51
|
+
hasTags: a,
|
|
52
|
+
allSimpleOrDotted: o,
|
|
53
|
+
nodes: l,
|
|
54
|
+
nodesWithSource: u
|
|
55
|
+
};
|
|
56
|
+
}, d = (e) => {
|
|
57
|
+
let t = r.get(e);
|
|
58
|
+
if (t) return a.hits++, t;
|
|
59
|
+
a.misses++;
|
|
60
|
+
let n = u(e);
|
|
61
|
+
return n ? (l(), r.set(e, n), n) : null;
|
|
62
|
+
}, f = (e, t) => t ? e.nodesWithSource : e.nodes;
|
|
63
|
+
//#endregion
|
|
64
|
+
export { o as getCacheStats, f as getNodes, s as resetCacheStats, d as resolveTokens };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TemplateCache';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const Char: {
|
|
2
|
+
readonly Tab: 9;
|
|
3
|
+
readonly Newline: 10;
|
|
4
|
+
readonly CarriageReturn: 13;
|
|
5
|
+
readonly Space: 32;
|
|
6
|
+
readonly Bang: 33;
|
|
7
|
+
readonly DoubleQuote: 34;
|
|
8
|
+
readonly Percent: 37;
|
|
9
|
+
readonly SingleQuote: 39;
|
|
10
|
+
readonly LParen: 40;
|
|
11
|
+
readonly RParen: 41;
|
|
12
|
+
readonly Star: 42;
|
|
13
|
+
readonly Plus: 43;
|
|
14
|
+
readonly Comma: 44;
|
|
15
|
+
readonly Minus: 45;
|
|
16
|
+
readonly Dot: 46;
|
|
17
|
+
readonly Slash: 47;
|
|
18
|
+
readonly Zero: 48;
|
|
19
|
+
readonly Nine: 57;
|
|
20
|
+
readonly Colon: 58;
|
|
21
|
+
readonly Less: 60;
|
|
22
|
+
readonly Equals: 61;
|
|
23
|
+
readonly Greater: 62;
|
|
24
|
+
readonly Question: 63;
|
|
25
|
+
readonly LBracket: 91;
|
|
26
|
+
readonly RBracket: 93;
|
|
27
|
+
readonly Underscore: 95;
|
|
28
|
+
readonly Backslash: 92;
|
|
29
|
+
readonly LBrace: 123;
|
|
30
|
+
readonly Pipe: 124;
|
|
31
|
+
readonly RBrace: 125;
|
|
32
|
+
readonly Tilde: 126;
|
|
33
|
+
readonly LowerN: 110;
|
|
34
|
+
readonly LowerR: 114;
|
|
35
|
+
readonly LowerT: 116;
|
|
36
|
+
};
|
|
37
|
+
export declare const isIdentStart: (c: number) => boolean;
|
|
38
|
+
export declare const isIdentPart: (c: number) => boolean;
|
|
39
|
+
export declare const isPathPart: (c: number) => boolean;
|
|
40
|
+
export declare const isDigit: (c: number) => boolean;
|
|
41
|
+
export declare const isSpace: (c: number) => boolean;
|
|
42
|
+
export declare const isSimpleIdentifier: (s: string) => boolean;
|
|
43
|
+
export declare const isDottedPath: (s: string) => boolean;
|
|
44
|
+
export declare const isVariableName: (s: string) => boolean;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/helpers/twigWrapper/charClass.ts
|
|
2
|
+
var e = {
|
|
3
|
+
Tab: 9,
|
|
4
|
+
Newline: 10,
|
|
5
|
+
CarriageReturn: 13,
|
|
6
|
+
Space: 32,
|
|
7
|
+
Bang: 33,
|
|
8
|
+
DoubleQuote: 34,
|
|
9
|
+
Percent: 37,
|
|
10
|
+
SingleQuote: 39,
|
|
11
|
+
LParen: 40,
|
|
12
|
+
RParen: 41,
|
|
13
|
+
Star: 42,
|
|
14
|
+
Plus: 43,
|
|
15
|
+
Comma: 44,
|
|
16
|
+
Minus: 45,
|
|
17
|
+
Dot: 46,
|
|
18
|
+
Slash: 47,
|
|
19
|
+
Zero: 48,
|
|
20
|
+
Nine: 57,
|
|
21
|
+
Colon: 58,
|
|
22
|
+
Less: 60,
|
|
23
|
+
Equals: 61,
|
|
24
|
+
Greater: 62,
|
|
25
|
+
Question: 63,
|
|
26
|
+
LBracket: 91,
|
|
27
|
+
RBracket: 93,
|
|
28
|
+
Underscore: 95,
|
|
29
|
+
Backslash: 92,
|
|
30
|
+
LBrace: 123,
|
|
31
|
+
Pipe: 124,
|
|
32
|
+
RBrace: 125,
|
|
33
|
+
Tilde: 126,
|
|
34
|
+
LowerN: 110,
|
|
35
|
+
LowerR: 114,
|
|
36
|
+
LowerT: 116
|
|
37
|
+
}, t = (t) => t >= 97 && t <= 122 || t >= 65 && t <= 90 || t === e.Underscore, n = (n) => t(n) || n >= e.Zero && n <= e.Nine, r = (t) => n(t) || t === e.Minus, i = (t) => t >= e.Zero && t <= e.Nine, a = (t) => t === e.Space || t === e.Tab || t === e.Newline || t === e.CarriageReturn, o = (e) => {
|
|
38
|
+
let r = e.length;
|
|
39
|
+
if (r === 0 || !t(e.charCodeAt(0))) return !1;
|
|
40
|
+
for (let t = 1; t < r; t++) if (!n(e.charCodeAt(t))) return !1;
|
|
41
|
+
return !0;
|
|
42
|
+
}, s = (r) => {
|
|
43
|
+
let i = r.length;
|
|
44
|
+
if (i === 0) return !1;
|
|
45
|
+
let a = !0;
|
|
46
|
+
for (let o = 0; o < i; o++) {
|
|
47
|
+
let i = r.charCodeAt(o);
|
|
48
|
+
if (i === e.Dot) {
|
|
49
|
+
if (a) return !1;
|
|
50
|
+
a = !0;
|
|
51
|
+
} else {
|
|
52
|
+
if (a && !t(i) || !a && !n(i)) return !1;
|
|
53
|
+
a = !1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return !a;
|
|
57
|
+
}, c = (e) => o(e);
|
|
58
|
+
//#endregion
|
|
59
|
+
export { e as Char, i as isDigit, s as isDottedPath, n as isIdentPart, t as isIdentStart, r as isPathPart, o as isSimpleIdentifier, a as isSpace, c as isVariableName };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type TwigFilter = (value: unknown, args: readonly unknown[]) => unknown;
|
|
2
|
+
export declare const ARROW_PARAMS: unique symbol;
|
|
3
|
+
export type ArrowCallback = ((...args: unknown[]) => unknown) & {
|
|
4
|
+
[ARROW_PARAMS]?: number;
|
|
5
|
+
};
|
|
6
|
+
export type RawMarker = {
|
|
7
|
+
readonly __raw: unknown;
|
|
8
|
+
readonly __marker: typeof RAW_MARKER;
|
|
9
|
+
};
|
|
10
|
+
export declare const RAW_MARKER = "__PLITZI_RAW__";
|
|
11
|
+
export declare const isRawMarker: (value: unknown) => value is RawMarker;
|
|
12
|
+
export declare const wrapRaw: (value: unknown) => RawMarker;
|
|
13
|
+
export declare const unwrapRaw: (value: unknown) => unknown;
|
|
14
|
+
export declare const filters: Record<string, TwigFilter>;
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
//#region src/helpers/twigWrapper/filters/filters.ts
|
|
2
|
+
var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t) => e === t ? 0 : e == null ? -1 : t == null ? 1 : typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t)), r = (e) => e == null ? "" : String(e), i = (e) => {
|
|
3
|
+
let t = new TextEncoder().encode(e), n = "";
|
|
4
|
+
for (let e = 0; e < t.length; e++) n += String.fromCharCode(t[e]);
|
|
5
|
+
return btoa(n);
|
|
6
|
+
}, a = (e) => {
|
|
7
|
+
let t = atob(e), n = new Uint8Array(t.length);
|
|
8
|
+
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
9
|
+
return new TextDecoder().decode(n);
|
|
10
|
+
}, o = (e) => {
|
|
11
|
+
let t = [
|
|
12
|
+
7,
|
|
13
|
+
12,
|
|
14
|
+
17,
|
|
15
|
+
22,
|
|
16
|
+
7,
|
|
17
|
+
12,
|
|
18
|
+
17,
|
|
19
|
+
22,
|
|
20
|
+
7,
|
|
21
|
+
12,
|
|
22
|
+
17,
|
|
23
|
+
22,
|
|
24
|
+
7,
|
|
25
|
+
12,
|
|
26
|
+
17,
|
|
27
|
+
22,
|
|
28
|
+
5,
|
|
29
|
+
9,
|
|
30
|
+
14,
|
|
31
|
+
20,
|
|
32
|
+
5,
|
|
33
|
+
9,
|
|
34
|
+
14,
|
|
35
|
+
20,
|
|
36
|
+
5,
|
|
37
|
+
9,
|
|
38
|
+
14,
|
|
39
|
+
20,
|
|
40
|
+
5,
|
|
41
|
+
9,
|
|
42
|
+
14,
|
|
43
|
+
20,
|
|
44
|
+
4,
|
|
45
|
+
11,
|
|
46
|
+
16,
|
|
47
|
+
23,
|
|
48
|
+
4,
|
|
49
|
+
11,
|
|
50
|
+
16,
|
|
51
|
+
23,
|
|
52
|
+
4,
|
|
53
|
+
11,
|
|
54
|
+
16,
|
|
55
|
+
23,
|
|
56
|
+
4,
|
|
57
|
+
11,
|
|
58
|
+
16,
|
|
59
|
+
23,
|
|
60
|
+
6,
|
|
61
|
+
10,
|
|
62
|
+
15,
|
|
63
|
+
21,
|
|
64
|
+
6,
|
|
65
|
+
10,
|
|
66
|
+
15,
|
|
67
|
+
21,
|
|
68
|
+
6,
|
|
69
|
+
10,
|
|
70
|
+
15,
|
|
71
|
+
21,
|
|
72
|
+
6,
|
|
73
|
+
10,
|
|
74
|
+
15,
|
|
75
|
+
21
|
|
76
|
+
], n = /* @__PURE__ */ new Uint32Array(64);
|
|
77
|
+
for (let e = 0; e < 64; e++) n[e] = Math.floor(Math.abs(Math.sin(e + 1)) * 4294967296);
|
|
78
|
+
let r = new TextEncoder().encode(e), i = r.length * 8, a = (r.length + 8 >> 6) + 1 << 6, o = new Uint8Array(a);
|
|
79
|
+
o.set(r), o[r.length] = 128;
|
|
80
|
+
let s = new DataView(o.buffer);
|
|
81
|
+
s.setUint32(a - 8, i >>> 0, !0), s.setUint32(a - 4, Math.floor(i / 4294967296) >>> 0, !0);
|
|
82
|
+
let c = 1732584193, l = 4023233417, u = 2562383102, d = 271733878, f = (e, t) => e << t | e >>> 32 - t;
|
|
83
|
+
for (let e = 0; e < a; e += 64) {
|
|
84
|
+
let r = /* @__PURE__ */ new Uint32Array(16);
|
|
85
|
+
for (let t = 0; t < 16; t++) r[t] = s.getUint32(e + t * 4, !0);
|
|
86
|
+
let i = c, a = l, o = u, p = d;
|
|
87
|
+
for (let e = 0; e < 64; e++) {
|
|
88
|
+
let s, c;
|
|
89
|
+
e < 16 ? (s = a & o | ~a & p, c = e) : e < 32 ? (s = p & a | ~p & o, c = (5 * e + 1) % 16) : e < 48 ? (s = a ^ o ^ p, c = (3 * e + 5) % 16) : (s = o ^ (a | ~p), c = 7 * e % 16), s = s + i + n[e] + r[c] | 0, i = p, p = o, o = a, a = a + f(s, t[e]) | 0;
|
|
90
|
+
}
|
|
91
|
+
c = c + i | 0, l = l + a | 0, u = u + o | 0, d = d + p | 0;
|
|
92
|
+
}
|
|
93
|
+
let p = (e) => {
|
|
94
|
+
let t = "";
|
|
95
|
+
for (let n = 0; n < 4; n++) t += (e >>> n * 8 & 255).toString(16).padStart(2, "0");
|
|
96
|
+
return t;
|
|
97
|
+
};
|
|
98
|
+
return p(c) + p(l) + p(u) + p(d);
|
|
99
|
+
}, s = "__PLITZI_RAW__", c = (e) => typeof e == "object" && !!e && e.__marker === "__PLITZI_RAW__", l = (e) => ({
|
|
100
|
+
__raw: e,
|
|
101
|
+
__marker: s
|
|
102
|
+
}), u = (e) => c(e) ? e.__raw : e, d = {
|
|
103
|
+
raw: (e) => l(e),
|
|
104
|
+
to_json: (e) => typeof e == "object" && e ? JSON.stringify(e) : r(e),
|
|
105
|
+
json_encode: (e) => typeof e == "object" && e ? JSON.stringify(e) : r(e),
|
|
106
|
+
object_as_json: (e) => typeof e == "object" && e ? JSON.stringify(e) : e,
|
|
107
|
+
default: (e, n) => t(e) ? n[0] : e,
|
|
108
|
+
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
109
|
+
lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
|
|
110
|
+
trim: (e) => typeof e == "string" ? e.trim() : e,
|
|
111
|
+
capitalize: (e) => typeof e == "string" && e.length > 0 ? e[0].toUpperCase() + e.slice(1).toLowerCase() : e,
|
|
112
|
+
title: (e) => typeof e == "string" ? e.replace(/\b\w/g, (e) => e.toUpperCase()) : e,
|
|
113
|
+
camelize: (e) => typeof e == "string" ? e.replace(/[-_]+(.)?/g, (e, t) => t ? t.toUpperCase() : "") : e,
|
|
114
|
+
kebab: (e) => typeof e == "string" ? e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase() : e,
|
|
115
|
+
snake: (e) => typeof e == "string" ? e.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase() : e,
|
|
116
|
+
ltrim: (e) => typeof e == "string" ? e.trimStart() : e,
|
|
117
|
+
rtrim: (e) => typeof e == "string" ? e.trimEnd() : e,
|
|
118
|
+
pad: (e, t) => {
|
|
119
|
+
if (typeof e != "string") return e;
|
|
120
|
+
let n = Number(t[0]) || 0, i = t.length > 1 ? r(t[1]) : " ";
|
|
121
|
+
if (i === "") return e;
|
|
122
|
+
let a = n - e.length;
|
|
123
|
+
if (a <= 0) return e;
|
|
124
|
+
let o = Math.ceil(a / i.length);
|
|
125
|
+
return i.repeat(o).slice(0, a) + e;
|
|
126
|
+
},
|
|
127
|
+
padRight: (e, t) => {
|
|
128
|
+
if (typeof e != "string") return e;
|
|
129
|
+
let n = Number(t[0]) || 0, i = t.length > 1 ? r(t[1]) : " ";
|
|
130
|
+
if (i === "") return e;
|
|
131
|
+
let a = n - e.length;
|
|
132
|
+
if (a <= 0) return e;
|
|
133
|
+
let o = Math.ceil(a / i.length);
|
|
134
|
+
return e + i.repeat(o).slice(0, a);
|
|
135
|
+
},
|
|
136
|
+
number: (e, t) => {
|
|
137
|
+
if (typeof e == "number") {
|
|
138
|
+
let n = Number(t[0]) || 0;
|
|
139
|
+
return e.toFixed(n);
|
|
140
|
+
}
|
|
141
|
+
if (typeof e != "string") return e;
|
|
142
|
+
let n = e.match(/-?\d+(?:\.\d+)?/);
|
|
143
|
+
return n ? Number(n[0]) : 0;
|
|
144
|
+
},
|
|
145
|
+
replace: (e, t) => typeof e != "string" || t.length === 0 ? e : e.split(r(t[0])).join(r(t[1])),
|
|
146
|
+
slice: (e, t) => {
|
|
147
|
+
if (t.length === 0) return e;
|
|
148
|
+
let n = Number(t[0]) || 0, r = t.length > 1 && Number.isFinite(Number(t[1])) ? n + Number(t[1]) : void 0;
|
|
149
|
+
return typeof e == "string" || Array.isArray(e) ? e.slice(n, r) : e;
|
|
150
|
+
},
|
|
151
|
+
split: (e, t) => typeof e == "string" && t.length > 0 ? e.split(r(t[0])) : e,
|
|
152
|
+
join: (e, t) => Array.isArray(e) ? e.join(t.length === 0 ? "" : r(t[0])) : e,
|
|
153
|
+
reverse: (e) => typeof e == "string" ? e.split("").reverse().join("") : Array.isArray(e) ? [...e].reverse() : e,
|
|
154
|
+
length: (e) => typeof e == "string" || Array.isArray(e) ? e.length : typeof e == "number" ? r(e).length : typeof e == "object" && e ? Object.keys(e).length : 0,
|
|
155
|
+
first: (e) => typeof e == "string" ? e.length > 0 ? e[0] : "" : Array.isArray(e) ? e.length > 0 ? e[0] : void 0 : e,
|
|
156
|
+
last: (e) => typeof e == "string" ? e.length > 0 ? e[e.length - 1] : "" : Array.isArray(e) ? e.length > 0 ? e[e.length - 1] : void 0 : e,
|
|
157
|
+
contains: (e, t) => {
|
|
158
|
+
if (t.length === 0) return !1;
|
|
159
|
+
let n = t[0];
|
|
160
|
+
return typeof e == "string" ? e.includes(r(n)) : Array.isArray(e) ? e.includes(n) : !1;
|
|
161
|
+
},
|
|
162
|
+
startswith: (e, t) => typeof e == "string" && t.length > 0 && e.startsWith(r(t[0])),
|
|
163
|
+
endswith: (e, t) => typeof e == "string" && t.length > 0 && e.endsWith(r(t[0])),
|
|
164
|
+
number_format: (e, t) => {
|
|
165
|
+
if (typeof e != "number") return e;
|
|
166
|
+
let n = Number(t[0]) || 0, i = t[1] == null ? "." : r(t[1]), a = t[2] == null ? "" : r(t[2]), o = e.toFixed(n);
|
|
167
|
+
if (a === "") return o.replace(".", i);
|
|
168
|
+
let s = o.split(".");
|
|
169
|
+
return s[0] = s[0].replace(/\B(?=(\d{3})+(?!\d))/g, a), s.join(i);
|
|
170
|
+
},
|
|
171
|
+
sort: (t, r) => {
|
|
172
|
+
if (!Array.isArray(t)) return t;
|
|
173
|
+
let i = [...t], a = r[0];
|
|
174
|
+
if (typeof a == "function") {
|
|
175
|
+
let t = a;
|
|
176
|
+
return (t[e] ?? 1) >= 2 ? i.sort((e, n) => Number(t(e, n))) : i.sort((e, r) => n(t(e), t(r)));
|
|
177
|
+
}
|
|
178
|
+
return i.sort(n);
|
|
179
|
+
},
|
|
180
|
+
batch: (e, t) => {
|
|
181
|
+
if (!Array.isArray(e) || t.length === 0) return e;
|
|
182
|
+
let n = Number(t[0]);
|
|
183
|
+
if (n <= 0) return e;
|
|
184
|
+
let r = [];
|
|
185
|
+
for (let t = 0; t < e.length; t += n) r.push(e.slice(t, t + n));
|
|
186
|
+
return r;
|
|
187
|
+
},
|
|
188
|
+
map: (e, t) => {
|
|
189
|
+
if (!Array.isArray(e) || t.length === 0) return e;
|
|
190
|
+
let n = t[0];
|
|
191
|
+
return typeof n == "function" ? e.map((e, t) => n(e, t)) : e;
|
|
192
|
+
},
|
|
193
|
+
reduce: (e, t) => {
|
|
194
|
+
if (!Array.isArray(e) || t.length === 0) return e;
|
|
195
|
+
let n = t[0];
|
|
196
|
+
if (typeof n != "function") return e;
|
|
197
|
+
let r = t[1], i = +(r === void 0), a = r === void 0 ? e[0] : r;
|
|
198
|
+
for (let t = i; t < e.length; t++) a = n(a, e[t], t);
|
|
199
|
+
return a;
|
|
200
|
+
},
|
|
201
|
+
merge: (e, t) => {
|
|
202
|
+
if (t.length === 0) return e;
|
|
203
|
+
let n = t[0];
|
|
204
|
+
return Array.isArray(e) && Array.isArray(n) ? [...e, ...n] : typeof e == "object" && e && typeof n == "object" && n && !Array.isArray(n) ? {
|
|
205
|
+
...e,
|
|
206
|
+
...n
|
|
207
|
+
} : e;
|
|
208
|
+
},
|
|
209
|
+
keys: (e) => typeof e == "object" && e && !Array.isArray(e) ? Object.keys(e) : e,
|
|
210
|
+
values: (e) => typeof e == "object" && e && !Array.isArray(e) ? Object.values(e) : e,
|
|
211
|
+
filter: (e, t) => {
|
|
212
|
+
if (!Array.isArray(e)) return e;
|
|
213
|
+
if (t.length === 0) return e.filter(Boolean);
|
|
214
|
+
let n = t[0];
|
|
215
|
+
if (typeof n == "function") return e.filter((e, t) => n(e, t));
|
|
216
|
+
let i = r(n);
|
|
217
|
+
return e.filter((e) => {
|
|
218
|
+
if (typeof e == "object" && e) {
|
|
219
|
+
let t = e[i];
|
|
220
|
+
return t != null && t !== !1 && t !== "";
|
|
221
|
+
}
|
|
222
|
+
return !!e;
|
|
223
|
+
});
|
|
224
|
+
},
|
|
225
|
+
column: (e, t) => {
|
|
226
|
+
if (!Array.isArray(e) || t.length === 0) return e;
|
|
227
|
+
let n = r(t[0]);
|
|
228
|
+
return e.map((e) => typeof e == "object" && e ? e[n] : void 0);
|
|
229
|
+
},
|
|
230
|
+
url_encode: (e) => typeof e == "string" ? encodeURIComponent(e) : typeof e == "object" && e && !Array.isArray(e) ? new URLSearchParams(Object.fromEntries(Object.entries(e).map(([e, t]) => [e, r(t)]))).toString() : e,
|
|
231
|
+
nl2br: (e) => typeof e == "string" ? e.replace(/\n/g, "<br>") : e,
|
|
232
|
+
striptags: (e, t) => {
|
|
233
|
+
if (typeof e != "string") return e;
|
|
234
|
+
let n = t.length > 0 ? r(t[0]).trim() : "";
|
|
235
|
+
if (n) {
|
|
236
|
+
let t = n.split(/(?:\s*>\s*<\s*|<\s*|>\s*)/).filter(Boolean).map((e) => e.replace(/[/>]/g, "").trim());
|
|
237
|
+
if (t.length > 0) {
|
|
238
|
+
let n = RegExp(`<(?!/?(?:${t.join("|")})\\b)[^>]+>`, "gi");
|
|
239
|
+
return e.replace(n, "").replace(/\s+/g, " ").trim();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return e.replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim();
|
|
243
|
+
},
|
|
244
|
+
abs: (e) => typeof e == "number" ? Math.abs(e) : e,
|
|
245
|
+
round: (e, t) => {
|
|
246
|
+
if (typeof e != "number") return e;
|
|
247
|
+
let n = Number(t[0]) || 0, i = t[1] == null ? "common" : r(t[1]), a = 10 ** n;
|
|
248
|
+
return i === "ceil" ? Math.ceil(e * a) / a : i === "floor" ? Math.floor(e * a) / a : Math.round(e * a) / a;
|
|
249
|
+
},
|
|
250
|
+
format: (e, t) => {
|
|
251
|
+
if (typeof e != "string") return e;
|
|
252
|
+
let n = 0;
|
|
253
|
+
return e.replace(/%s|%d|%f|%%/g, (e) => {
|
|
254
|
+
if (e === "%%") return "%";
|
|
255
|
+
let i = t[n];
|
|
256
|
+
return n++, i === void 0 ? e : e === "%d" ? String(Math.floor(Number(i))) : e === "%f" ? String(Number(i)) : r(i);
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
spaceless: (e) => typeof e == "string" ? e.replace(/>\s+</g, "><").trim() : e,
|
|
260
|
+
random: (e) => Array.isArray(e) ? e.length > 0 ? e[Math.floor(Math.random() * e.length)] : void 0 : typeof e == "string" ? e.length > 0 ? e[Math.floor(Math.random() * e.length)] : "" : typeof e == "number" ? Math.floor(Math.random() * e) : e,
|
|
261
|
+
date: (e, t) => {
|
|
262
|
+
if (t.length === 0) return e;
|
|
263
|
+
let n = r(t[0]), i = e instanceof Date ? e : new Date(String(e));
|
|
264
|
+
if (Number.isNaN(i.getTime())) return "";
|
|
265
|
+
let a = (e) => String(e).padStart(2, "0"), o = {
|
|
266
|
+
Y: String(i.getFullYear()),
|
|
267
|
+
m: a(i.getMonth() + 1),
|
|
268
|
+
d: a(i.getDate()),
|
|
269
|
+
H: a(i.getHours()),
|
|
270
|
+
i: a(i.getMinutes()),
|
|
271
|
+
s: a(i.getSeconds()),
|
|
272
|
+
l: [
|
|
273
|
+
"Sunday",
|
|
274
|
+
"Monday",
|
|
275
|
+
"Tuesday",
|
|
276
|
+
"Wednesday",
|
|
277
|
+
"Thursday",
|
|
278
|
+
"Friday",
|
|
279
|
+
"Saturday"
|
|
280
|
+
][i.getDay()],
|
|
281
|
+
F: [
|
|
282
|
+
"January",
|
|
283
|
+
"February",
|
|
284
|
+
"March",
|
|
285
|
+
"April",
|
|
286
|
+
"May",
|
|
287
|
+
"June",
|
|
288
|
+
"July",
|
|
289
|
+
"August",
|
|
290
|
+
"September",
|
|
291
|
+
"October",
|
|
292
|
+
"November",
|
|
293
|
+
"December"
|
|
294
|
+
][i.getMonth()],
|
|
295
|
+
M: [
|
|
296
|
+
"Jan",
|
|
297
|
+
"Feb",
|
|
298
|
+
"Mar",
|
|
299
|
+
"Apr",
|
|
300
|
+
"May",
|
|
301
|
+
"Jun",
|
|
302
|
+
"Jul",
|
|
303
|
+
"Aug",
|
|
304
|
+
"Sep",
|
|
305
|
+
"Oct",
|
|
306
|
+
"Nov",
|
|
307
|
+
"Dec"
|
|
308
|
+
][i.getMonth()]
|
|
309
|
+
}, s = "";
|
|
310
|
+
for (let e of n) s += Object.prototype.hasOwnProperty.call(o, e) ? o[e] : e;
|
|
311
|
+
return s;
|
|
312
|
+
},
|
|
313
|
+
base64_encode: (e) => typeof e == "string" ? i(e) : e,
|
|
314
|
+
base64_decode: (e) => typeof e == "string" ? a(e) : e,
|
|
315
|
+
md5: (e) => typeof e == "string" ? o(e) : e,
|
|
316
|
+
without: (e, t) => {
|
|
317
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
318
|
+
let n = t.map(r), i = {};
|
|
319
|
+
for (let [t, r] of Object.entries(e)) n.includes(t) || (i[t] = r);
|
|
320
|
+
return i;
|
|
321
|
+
},
|
|
322
|
+
only: (e, t) => {
|
|
323
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
324
|
+
let n = t.map(r), i = {};
|
|
325
|
+
for (let [t, r] of Object.entries(e)) n.includes(t) && (i[t] = r);
|
|
326
|
+
return i;
|
|
327
|
+
},
|
|
328
|
+
find: (e, t) => {
|
|
329
|
+
if (!Array.isArray(e) || t.length === 0) return;
|
|
330
|
+
let n = t[0];
|
|
331
|
+
if (typeof n == "function") return e.find((e, t) => n(e, t));
|
|
332
|
+
if (t.length < 2) return;
|
|
333
|
+
let i = r(n), a = t[1];
|
|
334
|
+
return e.find((e) => typeof e == "object" && e ? e[i] === a : e === a);
|
|
335
|
+
},
|
|
336
|
+
pluck: (e, t) => {
|
|
337
|
+
if (!Array.isArray(e) || t.length === 0) return e;
|
|
338
|
+
let n = r(t[0]);
|
|
339
|
+
return e.map((e) => typeof e == "object" && e ? e[n] : void 0);
|
|
340
|
+
},
|
|
341
|
+
unique: (e) => Array.isArray(e) ? [...new Set(e)] : e,
|
|
342
|
+
flatten: (e) => Array.isArray(e) ? e.flat() : e,
|
|
343
|
+
sum: (e) => Array.isArray(e) ? e.reduce((e, t) => e + (typeof t == "number" ? t : 0), 0) : e,
|
|
344
|
+
chunk: (e, t) => {
|
|
345
|
+
if (!Array.isArray(e) || t.length === 0) return e;
|
|
346
|
+
let n = Number(t[0]);
|
|
347
|
+
if (n <= 0) return e;
|
|
348
|
+
let r = [];
|
|
349
|
+
for (let t = 0; t < e.length; t += n) r.push(e.slice(t, t + n));
|
|
350
|
+
return r;
|
|
351
|
+
},
|
|
352
|
+
index_by: (e, t) => {
|
|
353
|
+
if (!Array.isArray(e) || t.length === 0) return e;
|
|
354
|
+
let n = r(t[0]), i = {};
|
|
355
|
+
for (let t of e) if (typeof t == "object" && t) {
|
|
356
|
+
let e = String(t[n] ?? "");
|
|
357
|
+
i[e] = t;
|
|
358
|
+
}
|
|
359
|
+
return i;
|
|
360
|
+
},
|
|
361
|
+
group_by: (e, t) => {
|
|
362
|
+
if (!Array.isArray(e) || t.length === 0) return e;
|
|
363
|
+
let n = r(t[0]), i = {};
|
|
364
|
+
for (let t of e) if (typeof t == "object" && t) {
|
|
365
|
+
let e = String(t[n] ?? "");
|
|
366
|
+
i[e] = i[e] ?? [], i[e].push(t);
|
|
367
|
+
}
|
|
368
|
+
return i;
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
//#endregion
|
|
372
|
+
export { e as ARROW_PARAMS, s as RAW_MARKER, d as filters, c as isRawMarker, u as unwrapRaw, l as wrapRaw };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './filters';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CacheEntry } from '../TemplateCache';
|
|
2
|
+
export declare const resolveSimplePath: (context: Record<string, unknown>, name: string) => unknown;
|
|
3
|
+
export declare const resolveDottedPath: (context: Record<string, unknown>, path: string) => unknown;
|
|
4
|
+
export declare const serializeValue: (value: unknown) => string;
|
|
5
|
+
export declare const finalizeRaw: (output: string) => unknown;
|
|
6
|
+
export declare const flattenContext: (variables: Record<string, unknown>) => Record<string, unknown>;
|
|
7
|
+
export declare const renderSimpleTokens: (entry: CacheEntry, context: Record<string, unknown>) => string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/helpers/twigWrapper/processTwig/helpers.ts
|
|
2
|
+
var e = (e, t) => e[t], t = (e, t) => {
|
|
3
|
+
let n = t.indexOf(".");
|
|
4
|
+
if (n === -1) return e[t];
|
|
5
|
+
let r = e[t.slice(0, n)], i = n + 1, a = t.length;
|
|
6
|
+
for (; i < a;) {
|
|
7
|
+
if (r == null) return;
|
|
8
|
+
let e = t.indexOf(".", i);
|
|
9
|
+
if (e === -1) return r[t.slice(i)];
|
|
10
|
+
r = r[t.slice(i, e)], i = e + 1;
|
|
11
|
+
}
|
|
12
|
+
return r;
|
|
13
|
+
}, n = (e) => e == null ? "" : typeof e == "object" ? JSON.stringify(e) : String(e), r = (e) => {
|
|
14
|
+
try {
|
|
15
|
+
return JSON.parse(e) || e;
|
|
16
|
+
} catch {
|
|
17
|
+
return e;
|
|
18
|
+
}
|
|
19
|
+
}, i = (e) => {
|
|
20
|
+
let t = {}, n = e.variables;
|
|
21
|
+
for (let e in n) t[e] = n[e];
|
|
22
|
+
for (let n in e) t[n] = e[n];
|
|
23
|
+
return t;
|
|
24
|
+
}, a = (r, i) => {
|
|
25
|
+
let a = "";
|
|
26
|
+
for (let o of r.tokens) if (o.type === "text") a += o.value;
|
|
27
|
+
else if (o.type === "variable") {
|
|
28
|
+
let r = o.content.trim(), s = o.content.indexOf(".") === -1 ? e(i, r) : t(i, r);
|
|
29
|
+
a += o.raw ? s == null ? "" : String(s) : n(s);
|
|
30
|
+
}
|
|
31
|
+
return a;
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { r as finalizeRaw, i as flattenContext, a as renderSimpleTokens, t as resolveDottedPath, e as resolveSimplePath, n as serializeValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { processTwig } from './processTwig';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const processTwig: (template: string, variables?: Record<string, unknown>, keepEmptyTokens?: boolean, asRaw?: boolean) => unknown;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { evaluate as e } from "../Evaluator/Evaluator.mjs";
|
|
2
|
+
import { finalizeRaw as t, flattenContext as n, renderSimpleTokens as r } from "./helpers.mjs";
|
|
3
|
+
import { getNodes as i, resolveTokens as a } from "../TemplateCache/TemplateCache.mjs";
|
|
4
|
+
//#region src/helpers/twigWrapper/processTwig/processTwig.ts
|
|
5
|
+
var o = (o, s = {}, c = !1, l = !1) => {
|
|
6
|
+
if (typeof o != "string") return o;
|
|
7
|
+
try {
|
|
8
|
+
if (o.indexOf("{%") === -1 && o.indexOf("{{") === -1) return o;
|
|
9
|
+
let u = "variables" in s ? n(s) : s, d = a(o);
|
|
10
|
+
if (!d) return o;
|
|
11
|
+
if (!c && !d.hasTags && d.allSimpleOrDotted) {
|
|
12
|
+
let e = r(d, u);
|
|
13
|
+
return l ? t(e) : e;
|
|
14
|
+
}
|
|
15
|
+
let f = i(d, c);
|
|
16
|
+
if (!f) return o;
|
|
17
|
+
let { output: p, variables: m, hasSet: h } = e(f, u, c);
|
|
18
|
+
return h && Object.assign(s, m), c && p === o ? o : l ? t(p) : p;
|
|
19
|
+
} catch {
|
|
20
|
+
return o;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { o as processTwig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hasValidToken: (value?: string, strict?: boolean) => boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TOKEN_REGEX as e, TOKEN_STRICT_REGEX as t } from "./tokenPatterns.mjs";
|
|
2
|
+
//#region src/helpers/twigWrapper/tokens/hasValidToken.ts
|
|
3
|
+
var n = (n, r = !1) => {
|
|
4
|
+
if (typeof n != "string") return !1;
|
|
5
|
+
let i = r ? t : e;
|
|
6
|
+
return i.lastIndex = 0, i.test(n.trim());
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { n as hasValidToken };
|