@plitzi/sdk-shared 0.37.2 → 0.37.3
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 +1146 -0
- package/dist/actions/access.d.ts +12 -0
- package/dist/actions/access.mjs +13 -0
- package/dist/actions/functions.d.ts +27 -0
- package/dist/actions/functions.mjs +18 -0
- package/dist/actions/index.d.ts +4 -0
- package/dist/actions/index.mjs +9 -7
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.mjs +2 -1
- package/dist/auth/visitorRoles.d.ts +27 -0
- package/dist/auth/visitorRoles.mjs +48 -0
- package/dist/authoring/builder.mjs +1 -0
- package/dist/authoring/declare.d.ts +53 -0
- package/dist/authoring/declare.mjs +2 -2
- package/dist/authoring/index.mjs +5 -5
- package/dist/authoring/paramSpec.d.ts +1 -1
- package/dist/authoring/paramSpec.mjs +1 -0
- package/dist/authoring/spaceCallbacks.mjs +2 -2
- package/dist/dataSource/computed.d.ts +21 -0
- package/dist/dataSource/computed.mjs +45 -0
- package/dist/dataSource/getBindingsDetails.mjs +35 -34
- package/dist/dataSource/index.d.ts +1 -0
- package/dist/dataSource/index.mjs +7 -6
- package/dist/dataSource/utility/not.mjs +4 -7
- package/dist/dataSource/utility/stringToArray.mjs +1 -1
- package/dist/dataSource/utility/truthiness.d.ts +1 -0
- package/dist/dataSource/utility/truthiness.mjs +8 -0
- package/dist/dataSource/utility/twigTemplate.d.ts +2 -1
- package/dist/dataSource/utility/twigTemplate.mjs +29 -17
- package/dist/devTools/utils/PlitziConsole.mjs +22 -22
- package/dist/helpers/cookies.d.ts +10 -0
- package/dist/helpers/cookies.mjs +19 -0
- package/dist/helpers/fetchManifest.d.ts +9 -0
- package/dist/helpers/fetchManifest.mjs +3 -6
- package/dist/helpers/formatDate.d.ts +5 -3
- package/dist/helpers/formatDate.mjs +34 -36
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.mjs +18 -14
- package/dist/helpers/isDate.d.ts +7 -0
- package/dist/helpers/isDate.mjs +15 -0
- package/dist/helpers/keys.d.ts +42 -0
- package/dist/helpers/keys.mjs +91 -0
- package/dist/helpers/twigWrapper/AST.d.ts +2 -2
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.d.ts +12 -2
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +57 -34
- package/dist/helpers/twigWrapper/Evaluator/index.d.ts +1 -1
- package/dist/helpers/twigWrapper/Evaluator/index.mjs +2 -2
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.d.ts +2 -2
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +147 -34
- package/dist/helpers/twigWrapper/Parser/Parser.d.ts +2 -1
- package/dist/helpers/twigWrapper/Parser/Parser.mjs +21 -20
- package/dist/helpers/twigWrapper/filters/filters.mjs +130 -112
- package/dist/helpers/twigWrapper/index.d.ts +5 -2
- package/dist/helpers/twigWrapper/index.mjs +7 -5
- package/dist/helpers/twigWrapper/inspectTemplate.d.ts +23 -0
- package/dist/helpers/twigWrapper/inspectTemplate.mjs +110 -0
- package/dist/helpers/twigWrapper/processTwig/helpers.d.ts +7 -0
- package/dist/helpers/twigWrapper/processTwig/helpers.mjs +2 -1
- package/dist/helpers/twigWrapper/processTwig/index.d.ts +2 -1
- package/dist/helpers/twigWrapper/processTwig/index.mjs +3 -2
- package/dist/helpers/twigWrapper/processTwig/processTwig.d.ts +28 -0
- package/dist/helpers/twigWrapper/processTwig/processTwig.mjs +73 -16
- package/dist/helpers/twigWrapper/processTwig/resolveStepParam.d.ts +17 -0
- package/dist/helpers/twigWrapper/processTwig/resolveStepParam.mjs +14 -0
- package/dist/helpers/twigWrapper/templateRoots.d.ts +11 -0
- package/dist/helpers/twigWrapper/templateRoots.mjs +4 -4
- package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.d.ts +1 -1
- package/dist/history/describe.d.ts +29 -0
- package/dist/history/describe.mjs +93 -0
- package/dist/history/diff.d.ts +33 -0
- package/dist/history/diff.mjs +73 -0
- package/dist/history/index.d.ts +3 -0
- package/dist/history/index.mjs +3 -0
- package/dist/history/types.d.ts +48 -0
- package/dist/history/types.mjs +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +77 -66
- package/dist/navigation/index.d.ts +1 -1
- package/dist/navigation/index.mjs +2 -2
- package/dist/navigation/routes.d.ts +11 -1
- package/dist/navigation/routes.mjs +15 -10
- package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.d.ts +14 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceFixIssuesMutation.mjs +16 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdatePluginMutation.mjs +2 -2
- package/dist/network/graphql/builder/Mutations/Space/actions/SpaceRunActionMutation.mjs +1 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.d.ts +3 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceRemoveFunctionsMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.d.ts +11 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceSaveFunctionsMutation.mjs +24 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.d.ts +4 -0
- package/dist/network/graphql/builder/Mutations/Space/functions/SpaceTryFunctionMutation.mjs +15 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceRemoveRuntimeVariableMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeSizeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceSetRuntimeVariableMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStartRuntimeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/runtime/SpaceStopRuntimeMutation.mjs +9 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceAddVisitorMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.d.ts +2 -0
- package/dist/network/graphql/builder/Mutations/Space/visitors/SpaceRemoveVisitorMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/index.d.ts +28 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +108 -84
- package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.d.ts +23 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceChangesQuery.mjs +49 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceFunctionsQuery.mjs +13 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.d.ts +17 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceIssuesQuery.mjs +22 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceRuntimeQuery.mjs +32 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.d.ts +6 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceVisitorsQuery.mjs +16 -0
- package/dist/network/graphql/builder/Queries/index.d.ts +17 -3
- package/dist/network/graphql/builder/Queries/index.mjs +30 -22
- package/dist/network/graphql/sdk/Mutations/index.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +2 -91
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/Segment/SegmentQuery.mjs +2 -44
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.d.ts +1 -1
- package/dist/network/graphql/sdk/Queries/Segment/SegmentsQuery.mjs +2 -55
- package/dist/network/graphql/sdk/Queries/index.d.ts +1 -5
- package/dist/network/index.mjs +7 -7
- package/dist/network/spaceEvents.d.ts +33 -3
- package/dist/network/spaceEvents.mjs +102 -89
- package/dist/realtime/client.d.ts +46 -0
- package/dist/realtime/client.mjs +192 -0
- package/dist/realtime/index.d.ts +6 -0
- package/dist/realtime/index.mjs +4 -0
- package/dist/realtime/presence.d.ts +38 -0
- package/dist/realtime/presence.mjs +70 -0
- package/dist/realtime/topics.d.ts +36 -0
- package/dist/realtime/topics.mjs +25 -0
- package/dist/server/actions/useRealtimeSync.d.ts +9 -0
- package/dist/server/actions/useRealtimeSync.mjs +7 -0
- package/dist/state/index.d.ts +1 -0
- package/dist/state/index.mjs +3 -2
- package/dist/state/paintedState.d.ts +52 -0
- package/dist/state/paintedState.mjs +37 -0
- package/dist/state/runtimeStatePersist.d.ts +8 -1
- package/dist/state/runtimeStatePersist.mjs +79 -29
- package/dist/store/index.d.ts +45 -45
- package/dist/store/renderSettings.d.ts +6 -3
- package/dist/store/tracing/index.d.ts +1 -0
- package/dist/store/tracing/tracingCollector.d.ts +17 -1
- package/dist/store/tracing/tracingCollector.mjs +5 -0
- package/dist/style/index.d.ts +1 -0
- package/dist/style/index.mjs +3 -2
- package/dist/style/runtimeStyle.d.ts +29 -0
- package/dist/style/runtimeStyle.mjs +7 -0
- package/dist/style/styleConstants.d.ts +3 -2
- package/dist/style/styleConstants.mjs +2 -0
- package/dist/style/styleStates.d.ts +14 -1
- package/dist/style/styleStates.mjs +10 -7
- package/dist/theme/ThemeProvider.mjs +35 -29
- package/dist/theme/themeCookie.mjs +11 -15
- package/dist/types/ActionTypes.d.ts +4 -0
- package/dist/types/AuthTypes.d.ts +11 -1
- package/dist/types/CommonTypes.d.ts +6 -0
- package/dist/types/FunctionTypes.d.ts +52 -0
- package/dist/types/FunctionTypes.mjs +0 -0
- package/dist/types/PluginTypes.d.ts +0 -1
- package/dist/types/RealtimeTypes.d.ts +94 -0
- package/dist/types/RealtimeTypes.mjs +0 -0
- package/dist/types/SchemaTypes.d.ts +54 -0
- package/dist/types/SchemaTypes.mjs +8 -0
- package/dist/types/ServerTypes.d.ts +259 -15
- package/dist/types/SpaceTypes.d.ts +53 -0
- package/dist/types/StateTypes.d.ts +6 -0
- package/dist/types/StoreTypes.d.ts +11 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.mjs +3 -2
- package/package.json +172 -11
- package/vite.config.ts +0 -12
- package/dist/network/graphql/builder/Queries/PluginsQuery.d.ts +0 -9
- package/dist/network/graphql/builder/Queries/PluginsQuery.mjs +0 -54
|
@@ -1,13 +1,13 @@
|
|
|
1
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),
|
|
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 === void 0 || typeof e == "function" || typeof e == "symbol" ? "null" : typeof e == "bigint" ? e.toString() : JSON.stringify(e), i = (e) => e == null ? "" : String(e), a = (e) => {
|
|
3
3
|
let t = new TextEncoder().encode(e), n = "";
|
|
4
4
|
for (let e = 0; e < t.length; e++) n += String.fromCharCode(t[e]);
|
|
5
5
|
return btoa(n);
|
|
6
|
-
},
|
|
6
|
+
}, o = (e) => {
|
|
7
7
|
let t = atob(e), n = new Uint8Array(t.length);
|
|
8
8
|
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
|
|
9
9
|
return new TextDecoder().decode(n);
|
|
10
|
-
},
|
|
10
|
+
}, s = (e) => {
|
|
11
11
|
let t = [
|
|
12
12
|
7,
|
|
13
13
|
12,
|
|
@@ -96,10 +96,10 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
96
96
|
return t;
|
|
97
97
|
};
|
|
98
98
|
return p(c) + p(l) + p(u) + p(d);
|
|
99
|
-
},
|
|
99
|
+
}, c = "__PLITZI_RAW__", l = (e) => typeof e == "object" && !!e && e.__marker === "__PLITZI_RAW__", u = (e) => ({
|
|
100
100
|
__raw: e,
|
|
101
|
-
__marker:
|
|
102
|
-
}),
|
|
101
|
+
__marker: c
|
|
102
|
+
}), d = (e) => l(e) ? e.__raw : e, f = [
|
|
103
103
|
"Sun",
|
|
104
104
|
"Mon",
|
|
105
105
|
"Tue",
|
|
@@ -107,9 +107,9 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
107
107
|
"Thu",
|
|
108
108
|
"Fri",
|
|
109
109
|
"Sat"
|
|
110
|
-
],
|
|
111
|
-
if (!
|
|
112
|
-
|
|
110
|
+
], p = /* @__PURE__ */ new Map(), m = (e) => {
|
|
111
|
+
if (!p.has(e)) try {
|
|
112
|
+
p.set(e, new Intl.DateTimeFormat("en-US", {
|
|
113
113
|
timeZone: e,
|
|
114
114
|
hourCycle: "h23",
|
|
115
115
|
year: "numeric",
|
|
@@ -121,15 +121,15 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
121
121
|
weekday: "short"
|
|
122
122
|
}));
|
|
123
123
|
} catch {
|
|
124
|
-
|
|
124
|
+
p.set(e, null);
|
|
125
125
|
}
|
|
126
|
-
return
|
|
127
|
-
},
|
|
126
|
+
return p.get(e) ?? null;
|
|
127
|
+
}, h = (e) => {
|
|
128
128
|
if (e instanceof Date) return e;
|
|
129
129
|
if (typeof e == "number") return new Date(e);
|
|
130
130
|
let t = String(e).trim();
|
|
131
131
|
return /^-?\d+$/.test(t) ? new Date(Number(t)) : new Date(t);
|
|
132
|
-
},
|
|
132
|
+
}, g = (e, t) => {
|
|
133
133
|
if (!t) return {
|
|
134
134
|
year: e.getFullYear(),
|
|
135
135
|
month: e.getMonth() + 1,
|
|
@@ -139,7 +139,7 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
139
139
|
seconds: e.getSeconds(),
|
|
140
140
|
weekday: e.getDay()
|
|
141
141
|
};
|
|
142
|
-
let n =
|
|
142
|
+
let n = m(t);
|
|
143
143
|
if (!n) return;
|
|
144
144
|
let r = n.formatToParts(e), i = (e) => r.find((t) => t.type === e)?.value ?? "";
|
|
145
145
|
return {
|
|
@@ -149,12 +149,12 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
149
149
|
hours: Number(i("hour")),
|
|
150
150
|
minutes: Number(i("minute")),
|
|
151
151
|
seconds: Number(i("second")),
|
|
152
|
-
weekday:
|
|
152
|
+
weekday: f.indexOf(i("weekday"))
|
|
153
153
|
};
|
|
154
|
-
},
|
|
155
|
-
raw: (e) =>
|
|
156
|
-
to_json: (e) =>
|
|
157
|
-
json_encode: (e) =>
|
|
154
|
+
}, _ = {
|
|
155
|
+
raw: (e) => u(e),
|
|
156
|
+
to_json: (e) => r(e),
|
|
157
|
+
json_encode: (e) => r(e),
|
|
158
158
|
object_as_json: (e) => typeof e == "object" && e ? JSON.stringify(e) : e,
|
|
159
159
|
default: (e, n) => t(e) ? n[0] : e,
|
|
160
160
|
upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
|
|
@@ -169,21 +169,21 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
169
169
|
rtrim: (e) => typeof e == "string" ? e.trimEnd() : e,
|
|
170
170
|
pad: (e, t) => {
|
|
171
171
|
if (typeof e != "string") return e;
|
|
172
|
-
let n = Number(t[0]) || 0,
|
|
173
|
-
if (
|
|
172
|
+
let n = Number(t[0]) || 0, r = t.length > 1 ? i(t[1]) : " ";
|
|
173
|
+
if (r === "") return e;
|
|
174
174
|
let a = n - e.length;
|
|
175
175
|
if (a <= 0) return e;
|
|
176
|
-
let o = Math.ceil(a /
|
|
177
|
-
return
|
|
176
|
+
let o = Math.ceil(a / r.length);
|
|
177
|
+
return r.repeat(o).slice(0, a) + e;
|
|
178
178
|
},
|
|
179
179
|
padRight: (e, t) => {
|
|
180
180
|
if (typeof e != "string") return e;
|
|
181
|
-
let n = Number(t[0]) || 0,
|
|
182
|
-
if (
|
|
181
|
+
let n = Number(t[0]) || 0, r = t.length > 1 ? i(t[1]) : " ";
|
|
182
|
+
if (r === "") return e;
|
|
183
183
|
let a = n - e.length;
|
|
184
184
|
if (a <= 0) return e;
|
|
185
|
-
let o = Math.ceil(a /
|
|
186
|
-
return e +
|
|
185
|
+
let o = Math.ceil(a / r.length);
|
|
186
|
+
return e + r.repeat(o).slice(0, a);
|
|
187
187
|
},
|
|
188
188
|
number: (e, t) => {
|
|
189
189
|
if (typeof e == "number") {
|
|
@@ -194,31 +194,31 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
194
194
|
let n = e.match(/-?\d+(?:\.\d+)?/);
|
|
195
195
|
return n ? Number(n[0]) : 0;
|
|
196
196
|
},
|
|
197
|
-
replace: (e, t) => typeof e != "string" || t.length === 0 ? e : e.split(
|
|
197
|
+
replace: (e, t) => typeof e != "string" || t.length === 0 ? e : e.split(i(t[0])).join(i(t[1])),
|
|
198
198
|
slice: (e, t) => {
|
|
199
199
|
if (t.length === 0) return e;
|
|
200
200
|
let n = Number(t[0]) || 0, r = t.length > 1 && Number.isFinite(Number(t[1])) ? n + Number(t[1]) : void 0;
|
|
201
201
|
return typeof e == "string" || Array.isArray(e) ? e.slice(n, r) : e;
|
|
202
202
|
},
|
|
203
|
-
split: (e, t) => typeof e == "string" && t.length > 0 ? e.split(
|
|
204
|
-
join: (e, t) => Array.isArray(e) ? e.join(t.length === 0 ? "" :
|
|
203
|
+
split: (e, t) => typeof e == "string" && t.length > 0 ? e.split(i(t[0])) : e,
|
|
204
|
+
join: (e, t) => Array.isArray(e) ? e.join(t.length === 0 ? "" : i(t[0])) : e,
|
|
205
205
|
reverse: (e) => typeof e == "string" ? e.split("").reverse().join("") : Array.isArray(e) ? [...e].reverse() : e,
|
|
206
|
-
length: (e) => typeof e == "string" || Array.isArray(e) ? e.length : typeof e == "number" ?
|
|
206
|
+
length: (e) => typeof e == "string" || Array.isArray(e) ? e.length : typeof e == "number" ? i(e).length : typeof e == "object" && e ? Object.keys(e).length : 0,
|
|
207
207
|
first: (e) => typeof e == "string" ? e.length > 0 ? e[0] : "" : Array.isArray(e) ? e.length > 0 ? e[0] : void 0 : e,
|
|
208
208
|
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,
|
|
209
209
|
contains: (e, t) => {
|
|
210
210
|
if (t.length === 0) return !1;
|
|
211
211
|
let n = t[0];
|
|
212
|
-
return typeof e == "string" ? e.includes(
|
|
212
|
+
return typeof e == "string" ? e.includes(i(n)) : Array.isArray(e) ? e.includes(n) : !1;
|
|
213
213
|
},
|
|
214
|
-
startswith: (e, t) => typeof e == "string" && t.length > 0 && e.startsWith(
|
|
215
|
-
endswith: (e, t) => typeof e == "string" && t.length > 0 && e.endsWith(
|
|
214
|
+
startswith: (e, t) => typeof e == "string" && t.length > 0 && e.startsWith(i(t[0])),
|
|
215
|
+
endswith: (e, t) => typeof e == "string" && t.length > 0 && e.endsWith(i(t[0])),
|
|
216
216
|
number_format: (e, t) => {
|
|
217
217
|
if (typeof e != "number") return e;
|
|
218
|
-
let n = Number(t[0]) || 0,
|
|
219
|
-
if (a === "") return o.replace(".",
|
|
218
|
+
let n = Number(t[0]) || 0, r = t[1] == null ? "." : i(t[1]), a = t[2] == null ? "" : i(t[2]), o = e.toFixed(n);
|
|
219
|
+
if (a === "") return o.replace(".", r);
|
|
220
220
|
let s = o.split(".");
|
|
221
|
-
return s[0] = s[0].replace(/\B(?=(\d{3})+(?!\d))/g, a), s.join(
|
|
221
|
+
return s[0] = s[0].replace(/\B(?=(\d{3})+(?!\d))/g, a), s.join(r);
|
|
222
222
|
},
|
|
223
223
|
sort: (t, r) => {
|
|
224
224
|
if (!Array.isArray(t)) return t;
|
|
@@ -265,10 +265,10 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
265
265
|
if (t.length === 0) return e.filter(Boolean);
|
|
266
266
|
let n = t[0];
|
|
267
267
|
if (typeof n == "function") return e.filter((e, t) => n(e, t));
|
|
268
|
-
let
|
|
268
|
+
let r = i(n);
|
|
269
269
|
return e.filter((e) => {
|
|
270
270
|
if (typeof e == "object" && e) {
|
|
271
|
-
let t = e[
|
|
271
|
+
let t = e[r];
|
|
272
272
|
return t != null && t !== !1 && t !== "";
|
|
273
273
|
}
|
|
274
274
|
return !!e;
|
|
@@ -276,14 +276,14 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
276
276
|
},
|
|
277
277
|
column: (e, t) => {
|
|
278
278
|
if (!Array.isArray(e) || t.length === 0) return e;
|
|
279
|
-
let n =
|
|
279
|
+
let n = i(t[0]);
|
|
280
280
|
return e.map((e) => typeof e == "object" && e ? e[n] : void 0);
|
|
281
281
|
},
|
|
282
|
-
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,
|
|
282
|
+
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, i(t)]))).toString() : e,
|
|
283
283
|
nl2br: (e) => typeof e == "string" ? e.replace(/\n/g, "<br>") : e,
|
|
284
284
|
striptags: (e, t) => {
|
|
285
285
|
if (typeof e != "string") return e;
|
|
286
|
-
let n = t.length > 0 ?
|
|
286
|
+
let n = t.length > 0 ? i(t[0]).trim() : "";
|
|
287
287
|
if (n) {
|
|
288
288
|
let t = n.split(/(?:\s*>\s*<\s*|<\s*|>\s*)/).filter(Boolean).map((e) => e.replace(/[/>]/g, "").trim());
|
|
289
289
|
if (t.length > 0) {
|
|
@@ -296,106 +296,124 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
296
296
|
abs: (e) => typeof e == "number" ? Math.abs(e) : e,
|
|
297
297
|
round: (e, t) => {
|
|
298
298
|
if (typeof e != "number") return e;
|
|
299
|
-
let n = Number(t[0]) || 0,
|
|
300
|
-
return
|
|
299
|
+
let n = Number(t[0]) || 0, r = t[1] == null ? "common" : i(t[1]), a = 10 ** n;
|
|
300
|
+
return r === "ceil" ? Math.ceil(e * a) / a : r === "floor" ? Math.floor(e * a) / a : Math.round(e * a) / a;
|
|
301
301
|
},
|
|
302
302
|
format: (e, t) => {
|
|
303
303
|
if (typeof e != "string") return e;
|
|
304
304
|
let n = 0;
|
|
305
|
-
return e.replace(/%
|
|
306
|
-
if (
|
|
307
|
-
let
|
|
308
|
-
|
|
305
|
+
return e.replace(/%((?:[-+ 0]|'.)*)(\d*)(?:\.(\d+))?([sdf%])/g, (e, r, a, o, s) => {
|
|
306
|
+
if (s === "%") return "%";
|
|
307
|
+
let c = t[n];
|
|
308
|
+
if (n++, c === void 0) return e;
|
|
309
|
+
let l = r.includes("+"), u;
|
|
310
|
+
if (s === "d") {
|
|
311
|
+
let e = Math.trunc(Number(c));
|
|
312
|
+
u = `${l && e >= 0 ? "+" : ""}${e}`;
|
|
313
|
+
} else if (s === "f") {
|
|
314
|
+
let e = Number(c);
|
|
315
|
+
u = `${l && e >= 0 ? "+" : ""}${o === void 0 ? String(e) : e.toFixed(Number(o))}`;
|
|
316
|
+
} else u = i(c), u = o === void 0 ? u : u.slice(0, Number(o));
|
|
317
|
+
let d = Number(a || 0);
|
|
318
|
+
if (u.length >= d) return u;
|
|
319
|
+
let f = /'(.)/.exec(r), p = f ? f[1] : r.includes("0") ? "0" : " ";
|
|
320
|
+
return r.includes("-") ? u.padEnd(d, p === "0" ? " " : p) : p === "0" && s !== "s" && /^[+-]/.test(u) ? u[0] + u.slice(1).padStart(d - 1, "0") : u.padStart(d, p);
|
|
309
321
|
});
|
|
310
322
|
},
|
|
311
323
|
spaceless: (e) => typeof e == "string" ? e.replace(/>\s+</g, "><").trim() : e,
|
|
312
324
|
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,
|
|
313
325
|
date: (e, t) => {
|
|
314
326
|
if (t.length === 0) return e;
|
|
315
|
-
let n =
|
|
316
|
-
if (Number.isNaN(
|
|
317
|
-
let a =
|
|
327
|
+
let n = i(t[0]), r = h(e);
|
|
328
|
+
if (Number.isNaN(r.getTime())) return "";
|
|
329
|
+
let a = g(r, t.length > 1 ? i(t[1]) : "");
|
|
318
330
|
if (!a) return "";
|
|
319
|
-
let o = (e) => String(e).padStart(2, "0"), s =
|
|
331
|
+
let o = (e) => String(e).padStart(2, "0"), s = [
|
|
332
|
+
"January",
|
|
333
|
+
"February",
|
|
334
|
+
"March",
|
|
335
|
+
"April",
|
|
336
|
+
"May",
|
|
337
|
+
"June",
|
|
338
|
+
"July",
|
|
339
|
+
"August",
|
|
340
|
+
"September",
|
|
341
|
+
"October",
|
|
342
|
+
"November",
|
|
343
|
+
"December"
|
|
344
|
+
], c = [
|
|
345
|
+
"Jan",
|
|
346
|
+
"Feb",
|
|
347
|
+
"Mar",
|
|
348
|
+
"Apr",
|
|
349
|
+
"May",
|
|
350
|
+
"Jun",
|
|
351
|
+
"Jul",
|
|
352
|
+
"Aug",
|
|
353
|
+
"Sep",
|
|
354
|
+
"Oct",
|
|
355
|
+
"Nov",
|
|
356
|
+
"Dec"
|
|
357
|
+
], l = [
|
|
358
|
+
"Sunday",
|
|
359
|
+
"Monday",
|
|
360
|
+
"Tuesday",
|
|
361
|
+
"Wednesday",
|
|
362
|
+
"Thursday",
|
|
363
|
+
"Friday",
|
|
364
|
+
"Saturday"
|
|
365
|
+
], u = {
|
|
320
366
|
Y: String(a.year),
|
|
367
|
+
y: o(a.year % 100),
|
|
321
368
|
m: o(a.month),
|
|
322
369
|
n: String(a.month),
|
|
323
370
|
d: o(a.day),
|
|
324
371
|
j: String(a.day),
|
|
325
372
|
H: o(a.hours),
|
|
326
373
|
G: String(a.hours),
|
|
374
|
+
h: o(a.hours % 12 || 12),
|
|
375
|
+
g: String(a.hours % 12 || 12),
|
|
376
|
+
A: a.hours < 12 ? "AM" : "PM",
|
|
377
|
+
a: a.hours < 12 ? "am" : "pm",
|
|
327
378
|
i: o(a.minutes),
|
|
328
379
|
s: o(a.seconds),
|
|
329
380
|
w: String(a.weekday),
|
|
330
381
|
N: String(a.weekday === 0 ? 7 : a.weekday),
|
|
331
|
-
U: String(Math.floor(
|
|
332
|
-
l: [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
"Saturday"
|
|
340
|
-
][a.weekday],
|
|
341
|
-
F: [
|
|
342
|
-
"January",
|
|
343
|
-
"February",
|
|
344
|
-
"March",
|
|
345
|
-
"April",
|
|
346
|
-
"May",
|
|
347
|
-
"June",
|
|
348
|
-
"July",
|
|
349
|
-
"August",
|
|
350
|
-
"September",
|
|
351
|
-
"October",
|
|
352
|
-
"November",
|
|
353
|
-
"December"
|
|
354
|
-
][a.month - 1],
|
|
355
|
-
M: [
|
|
356
|
-
"Jan",
|
|
357
|
-
"Feb",
|
|
358
|
-
"Mar",
|
|
359
|
-
"Apr",
|
|
360
|
-
"May",
|
|
361
|
-
"Jun",
|
|
362
|
-
"Jul",
|
|
363
|
-
"Aug",
|
|
364
|
-
"Sep",
|
|
365
|
-
"Oct",
|
|
366
|
-
"Nov",
|
|
367
|
-
"Dec"
|
|
368
|
-
][a.month - 1]
|
|
369
|
-
}, c = "";
|
|
370
|
-
for (let e of n) c += Object.prototype.hasOwnProperty.call(s, e) ? s[e] : e;
|
|
371
|
-
return c;
|
|
382
|
+
U: String(Math.floor(r.getTime() / 1e3)),
|
|
383
|
+
l: l[a.weekday],
|
|
384
|
+
D: l[a.weekday].slice(0, 3),
|
|
385
|
+
F: s[a.month - 1],
|
|
386
|
+
M: c[a.month - 1]
|
|
387
|
+
}, d = "", f = !1;
|
|
388
|
+
for (let e of n) f ? (d += e, f = !1) : e === "\\" ? f = !0 : d += Object.prototype.hasOwnProperty.call(u, e) ? u[e] : e;
|
|
389
|
+
return d;
|
|
372
390
|
},
|
|
373
|
-
base64_encode: (e) => typeof e == "string" ?
|
|
374
|
-
base64_decode: (e) => typeof e == "string" ?
|
|
375
|
-
md5: (e) => typeof e == "string" ?
|
|
391
|
+
base64_encode: (e) => typeof e == "string" ? a(e) : e,
|
|
392
|
+
base64_decode: (e) => typeof e == "string" ? o(e) : e,
|
|
393
|
+
md5: (e) => typeof e == "string" ? s(e) : e,
|
|
376
394
|
without: (e, t) => {
|
|
377
395
|
if (typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
378
|
-
let n = t.map(
|
|
379
|
-
for (let [t,
|
|
380
|
-
return
|
|
396
|
+
let n = t.map(i), r = {};
|
|
397
|
+
for (let [t, i] of Object.entries(e)) n.includes(t) || (r[t] = i);
|
|
398
|
+
return r;
|
|
381
399
|
},
|
|
382
400
|
only: (e, t) => {
|
|
383
401
|
if (typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
384
|
-
let n = t.map(
|
|
385
|
-
for (let [t,
|
|
386
|
-
return
|
|
402
|
+
let n = t.map(i), r = {};
|
|
403
|
+
for (let [t, i] of Object.entries(e)) n.includes(t) && (r[t] = i);
|
|
404
|
+
return r;
|
|
387
405
|
},
|
|
388
406
|
find: (e, t) => {
|
|
389
407
|
if (!Array.isArray(e) || t.length === 0) return;
|
|
390
408
|
let n = t[0];
|
|
391
409
|
if (typeof n == "function") return e.find((e, t) => n(e, t));
|
|
392
410
|
if (t.length < 2) return;
|
|
393
|
-
let
|
|
394
|
-
return e.find((e) => typeof e == "object" && e ? e[
|
|
411
|
+
let r = i(n), a = t[1];
|
|
412
|
+
return e.find((e) => typeof e == "object" && e ? e[r] === a : e === a);
|
|
395
413
|
},
|
|
396
414
|
pluck: (e, t) => {
|
|
397
415
|
if (!Array.isArray(e) || t.length === 0) return e;
|
|
398
|
-
let n =
|
|
416
|
+
let n = i(t[0]);
|
|
399
417
|
return e.map((e) => typeof e == "object" && e ? e[n] : void 0);
|
|
400
418
|
},
|
|
401
419
|
unique: (e) => Array.isArray(e) ? [...new Set(e)] : e,
|
|
@@ -411,22 +429,22 @@ var e = Symbol("twigArrowParams"), t = (e) => e == null || e === "", n = (e, t)
|
|
|
411
429
|
},
|
|
412
430
|
index_by: (e, t) => {
|
|
413
431
|
if (!Array.isArray(e) || t.length === 0) return e;
|
|
414
|
-
let n =
|
|
432
|
+
let n = i(t[0]), r = {};
|
|
415
433
|
for (let t of e) if (typeof t == "object" && t) {
|
|
416
434
|
let e = String(t[n] ?? "");
|
|
417
|
-
|
|
435
|
+
r[e] = t;
|
|
418
436
|
}
|
|
419
|
-
return
|
|
437
|
+
return r;
|
|
420
438
|
},
|
|
421
439
|
group_by: (e, t) => {
|
|
422
440
|
if (!Array.isArray(e) || t.length === 0) return e;
|
|
423
|
-
let n =
|
|
441
|
+
let n = i(t[0]), r = {};
|
|
424
442
|
for (let t of e) if (typeof t == "object" && t) {
|
|
425
443
|
let e = String(t[n] ?? "");
|
|
426
|
-
|
|
444
|
+
r[e] = r[e] ?? [], r[e].push(t);
|
|
427
445
|
}
|
|
428
|
-
return
|
|
446
|
+
return r;
|
|
429
447
|
}
|
|
430
448
|
};
|
|
431
449
|
//#endregion
|
|
432
|
-
export { e as ARROW_PARAMS,
|
|
450
|
+
export { e as ARROW_PARAMS, c as RAW_MARKER, _ as filters, l as isRawMarker, d as unwrapRaw, u as wrapRaw };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export { processTwig } from './processTwig';
|
|
1
|
+
export { processTwig, processTwigParam, processTwigValue } from './processTwig';
|
|
2
|
+
export { MAX_PARAM_PASSES, resolveStepParam } from './processTwig/resolveStepParam';
|
|
2
3
|
export { hasTemplateSyntax } from './tokens/hasTemplateSyntax';
|
|
3
4
|
export { hasValidToken } from './tokens/hasValidToken';
|
|
4
|
-
export {
|
|
5
|
+
export { inspectTemplate } from './inspectTemplate';
|
|
6
|
+
export { templatePaths, templateRootNames } from './templateRoots';
|
|
5
7
|
export { filters } from './filters/filters';
|
|
6
8
|
export type { ASTNode, Expression } from './AST';
|
|
9
|
+
export type { TemplateInspection } from './inspectTemplate';
|
|
7
10
|
export type { TwigFilter } from './filters/filters';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { filters as e } from "./filters/filters.mjs";
|
|
2
|
-
import { processTwig as t } from "./processTwig/processTwig.mjs";
|
|
3
|
-
import { hasTemplateSyntax as
|
|
4
|
-
import { hasValidToken as
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { processTwig as t, processTwigParam as n, processTwigValue as r } from "./processTwig/processTwig.mjs";
|
|
3
|
+
import { hasTemplateSyntax as i } from "./tokens/hasTemplateSyntax.mjs";
|
|
4
|
+
import { hasValidToken as a } from "./tokens/hasValidToken.mjs";
|
|
5
|
+
import { MAX_PARAM_PASSES as o, resolveStepParam as s } from "./processTwig/resolveStepParam.mjs";
|
|
6
|
+
import { inspectTemplate as c } from "./inspectTemplate.mjs";
|
|
7
|
+
import { templatePaths as l, templateRootNames as u } from "./templateRoots.mjs";
|
|
8
|
+
export { o as MAX_PARAM_PASSES, e as filters, i as hasTemplateSyntax, a as hasValidToken, c as inspectTemplate, t as processTwig, n as processTwigParam, r as processTwigValue, s as resolveStepParam, l as templatePaths, u as templateRootNames };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type TemplateInspection = {
|
|
2
|
+
/**
|
|
3
|
+
* Everything the interpreter would read past rather than understand, in words: a character it skipped, an operator
|
|
4
|
+
* it does not implement, a filter or function it does not have, a tag it drops. Empty for a template that renders
|
|
5
|
+
* what it says.
|
|
6
|
+
*/
|
|
7
|
+
issues: string[];
|
|
8
|
+
/**
|
|
9
|
+
* The names the template reads from its context — the first segment of every path that is not bound by the
|
|
10
|
+
* template itself (a `set`, a `for` variable, an arrow's parameter). What a caller checks against what will be in
|
|
11
|
+
* scope when it renders.
|
|
12
|
+
*/
|
|
13
|
+
freeNames: string[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* What a template would do that its author did not write — read at author time, with the parser the runtime uses.
|
|
17
|
+
*
|
|
18
|
+
* The interpreter is forgiving on purpose: a page renders what it can rather than throwing. That same forgiveness is
|
|
19
|
+
* what turns a typo into a plausible wrong value — `s starts with 'x'` evaluated to `s` before the test existed, and a
|
|
20
|
+
* value in a condition is true. Anything that authors templates (the authoring surface, the builder) asks this first
|
|
21
|
+
* and refuses what it reports.
|
|
22
|
+
*/
|
|
23
|
+
export declare const inspectTemplate: (template: string) => TemplateInspection;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { filters as e } from "./filters/filters.mjs";
|
|
2
|
+
import { lex as t } from "./Lexer/Lexer.mjs";
|
|
3
|
+
import { parse as n } from "./Parser/Parser.mjs";
|
|
4
|
+
//#region src/helpers/twigWrapper/inspectTemplate.ts
|
|
5
|
+
var r = /* @__PURE__ */ new Set([
|
|
6
|
+
"cycle",
|
|
7
|
+
"max",
|
|
8
|
+
"min",
|
|
9
|
+
"range"
|
|
10
|
+
]), i = "loop", a = class {
|
|
11
|
+
issues = [];
|
|
12
|
+
freeNames = /* @__PURE__ */ new Set();
|
|
13
|
+
nodes(e, t) {
|
|
14
|
+
let n = new Set(t);
|
|
15
|
+
for (let t of e) switch (t.type) {
|
|
16
|
+
case "text":
|
|
17
|
+
case "break":
|
|
18
|
+
case "continue": break;
|
|
19
|
+
case "variable":
|
|
20
|
+
this.expression(t.expression, n);
|
|
21
|
+
break;
|
|
22
|
+
case "if":
|
|
23
|
+
this.expression(t.condition, n), this.nodes(t.body, n);
|
|
24
|
+
for (let e of t.elseifClauses) this.expression(e.condition, n), this.nodes(e.body, n);
|
|
25
|
+
t.elseBody && this.nodes(t.elseBody, n);
|
|
26
|
+
break;
|
|
27
|
+
case "for": {
|
|
28
|
+
this.expression(t.collection, n);
|
|
29
|
+
let e = /* @__PURE__ */ new Set([
|
|
30
|
+
...n,
|
|
31
|
+
t.valueVar,
|
|
32
|
+
i,
|
|
33
|
+
...t.keyVar ? [t.keyVar] : []
|
|
34
|
+
]);
|
|
35
|
+
this.nodes(t.body, e), n = /* @__PURE__ */ new Set([...n, ...this.setsIn(t.body)]), t.elseBody && this.nodes(t.elseBody, n);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
case "set":
|
|
39
|
+
Array.isArray(t.value) ? this.nodes(t.value, n) : this.expression(t.value, n), n = /* @__PURE__ */ new Set([...n, t.name]);
|
|
40
|
+
break;
|
|
41
|
+
case "apply":
|
|
42
|
+
this.filterNames(t.filters.map((e) => e.name));
|
|
43
|
+
for (let e of t.filters) e.args.forEach((e) => this.expression(e, n));
|
|
44
|
+
this.nodes(t.body, n);
|
|
45
|
+
}
|
|
46
|
+
return n;
|
|
47
|
+
}
|
|
48
|
+
setsIn(e) {
|
|
49
|
+
return e.flatMap((e) => e.type === "set" ? [e.name] : []);
|
|
50
|
+
}
|
|
51
|
+
filterNames(t) {
|
|
52
|
+
for (let n of t) n && !Object.hasOwn(e, n) && this.issues.push(`Unknown filter "${n}"`);
|
|
53
|
+
}
|
|
54
|
+
expression(e, t) {
|
|
55
|
+
switch (e.type) {
|
|
56
|
+
case "literal": return;
|
|
57
|
+
case "array":
|
|
58
|
+
e.elements.forEach((e) => this.expression(e, t));
|
|
59
|
+
return;
|
|
60
|
+
case "object":
|
|
61
|
+
for (let n of e.entries) this.expression(n.key, t), this.expression(n.value, t);
|
|
62
|
+
return;
|
|
63
|
+
case "range":
|
|
64
|
+
this.expression(e.start, t), this.expression(e.end, t);
|
|
65
|
+
return;
|
|
66
|
+
case "path":
|
|
67
|
+
t.has(e.segments[0]) || this.freeNames.add(e.segments[0]);
|
|
68
|
+
return;
|
|
69
|
+
case "index":
|
|
70
|
+
this.expression(e.object, t), this.expression(e.index, t);
|
|
71
|
+
return;
|
|
72
|
+
case "function":
|
|
73
|
+
r.has(e.name) || this.issues.push(`Unknown function "${e.name}()": the functions are ${[...r].join(", ")}`), e.args.forEach((e) => this.expression(e, t));
|
|
74
|
+
return;
|
|
75
|
+
case "filter":
|
|
76
|
+
this.expression(e.subject, t), this.filterNames(e.filters.map((e) => e.name));
|
|
77
|
+
for (let n of e.filters) n.args.forEach((e) => this.expression(e, t));
|
|
78
|
+
return;
|
|
79
|
+
case "concat":
|
|
80
|
+
e.parts.forEach((e) => this.expression(e, t));
|
|
81
|
+
return;
|
|
82
|
+
case "unary":
|
|
83
|
+
this.expression(e.operand, t);
|
|
84
|
+
return;
|
|
85
|
+
case "binary":
|
|
86
|
+
this.expression(e.left, t), (e.operator !== "is" && e.operator !== "is not" || e.right.type !== "path") && this.expression(e.right, t);
|
|
87
|
+
return;
|
|
88
|
+
case "default":
|
|
89
|
+
this.expression(e.value, t), this.expression(e.defaultExpr, t);
|
|
90
|
+
return;
|
|
91
|
+
case "ternary":
|
|
92
|
+
this.expression(e.condition, t), e.trueExpr && this.expression(e.trueExpr, t), this.expression(e.falseExpr, t);
|
|
93
|
+
return;
|
|
94
|
+
case "arrow": this.expression(e.body, /* @__PURE__ */ new Set([...t, ...e.params]));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, o = (e) => {
|
|
98
|
+
let r = t(e);
|
|
99
|
+
if (r.error) return {
|
|
100
|
+
issues: [r.error],
|
|
101
|
+
freeNames: []
|
|
102
|
+
};
|
|
103
|
+
let i = new a(), { nodes: o, error: s } = n(r.tokens, !1, i.issues);
|
|
104
|
+
return s && i.issues.push(s), i.nodes(o, /* @__PURE__ */ new Set()), {
|
|
105
|
+
issues: [...new Set(i.issues)],
|
|
106
|
+
freeNames: [...i.freeNames]
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
//#endregion
|
|
110
|
+
export { o as inspectTemplate };
|
|
@@ -2,6 +2,13 @@ import { CacheEntry } from '../TemplateCache';
|
|
|
2
2
|
export declare const resolveSimplePath: (context: Record<string, unknown>, name: string) => unknown;
|
|
3
3
|
export declare const resolveDottedPath: (context: Record<string, unknown>, path: string) => unknown;
|
|
4
4
|
export declare const serializeValue: (value: unknown) => string;
|
|
5
|
+
/**
|
|
6
|
+
* A rendered template as the value it reads as: `30` the number, `true`, an object from its JSON.
|
|
7
|
+
*
|
|
8
|
+
* Except a number that would not read back as the text it came from — `012345`, a code with a leading zero, or a
|
|
9
|
+
* 20-digit id past what a number can hold exactly. Those were handed on as `12345` and as the nearest double, which is
|
|
10
|
+
* a different second-factor code, PIN or id by the time anything sends it; they stay the text they were.
|
|
11
|
+
*/
|
|
5
12
|
export declare const finalizeRaw: (output: string) => unknown;
|
|
6
13
|
export declare const flattenContext: (variables: Record<string, unknown>) => Record<string, unknown>;
|
|
7
14
|
export declare const renderSimpleTokens: (entry: CacheEntry, context: Record<string, unknown>) => string;
|
|
@@ -12,7 +12,8 @@ var e = (e, t) => e[t], t = (e, t) => {
|
|
|
12
12
|
return r;
|
|
13
13
|
}, n = (e) => e == null ? "" : typeof e == "object" ? JSON.stringify(e) : String(e), r = (e) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
let t = JSON.parse(e);
|
|
16
|
+
return typeof t == "number" && String(t) !== e.trim() ? e : t || e;
|
|
16
17
|
} catch {
|
|
17
18
|
return e;
|
|
18
19
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { processTwig } from './processTwig';
|
|
1
|
+
export { processTwig, processTwigParam, processTwigValue } from './processTwig';
|
|
2
|
+
export { MAX_PARAM_PASSES, resolveStepParam } from './resolveStepParam';
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { processTwig as e } from "./processTwig.mjs";
|
|
2
|
-
|
|
1
|
+
import { processTwig as e, processTwigParam as t, processTwigValue as n } from "./processTwig.mjs";
|
|
2
|
+
import { MAX_PARAM_PASSES as r, resolveStepParam as i } from "./resolveStepParam.mjs";
|
|
3
|
+
export { r as MAX_PARAM_PASSES, e as processTwig, t as processTwigParam, n as processTwigValue, i as resolveStepParam };
|
|
@@ -1 +1,29 @@
|
|
|
1
1
|
export declare const processTwig: (template: string, variables?: Record<string, unknown>, keepEmptyTokens?: boolean, asRaw?: boolean) => unknown;
|
|
2
|
+
/**
|
|
3
|
+
* A template's VALUE, where it has one: `{{ rows|filter(r => r.open) }}` is the filtered array, `{{ count > 0 }}` a
|
|
4
|
+
* boolean, `{{ total }}` the number it holds.
|
|
5
|
+
*
|
|
6
|
+
* A template that is one `{{ expression }}` and nothing else (surrounding whitespace aside) answers that expression's
|
|
7
|
+
* value untouched. Anything with text around it, or tags, is text by nature and renders as {@link processTwig}.
|
|
8
|
+
*
|
|
9
|
+
* Unlike `processTwig`'s `asRaw`, nothing goes through JSON on the way: `0`, `false` and `null` come back as
|
|
10
|
+
* themselves, and a string that looks like a number stays a string.
|
|
11
|
+
*/
|
|
12
|
+
export declare const processTwigValue: (template: string, variables?: Record<string, unknown>) => unknown;
|
|
13
|
+
/**
|
|
14
|
+
* A flow step's param — in the browser's flows and in a server action's — as the value the step is handed.
|
|
15
|
+
*
|
|
16
|
+
* A param that is one `{{ expression }}` is that expression's value, exactly: a string stays a string however it
|
|
17
|
+
* looks. The type is the VALUE's, never guessed from its text — which is what the step params used to do, rendering
|
|
18
|
+
* the value to text and reading the text back as JSON: a password typed as `1234` reached the server as a number, and
|
|
19
|
+
* a text field declared `text` on the far side then saw no password at all. What a param should be converted to is
|
|
20
|
+
* the business of whoever declares its type — `setState`'s `type`, an action's input fields — not of the resolver.
|
|
21
|
+
*
|
|
22
|
+
* Two readings of JSON stay, because in both the author wrote JSON on purpose: a param that is nothing but a JSON
|
|
23
|
+
* filter (`{{ saved|json_encode }}`) is the value it encodes, and text around the tokens that makes a JSON object or
|
|
24
|
+
* array (`{ "id": "{{ id }}" }`, an `input` written as a document) is that document. A value printed inside one of
|
|
25
|
+
* the document's string literals is escaped for it: a visitor's `Say "hi"` or a note on two lines used to break the
|
|
26
|
+
* document, and the step was handed its raw text instead. Any other text is text. A value that is not there reads as
|
|
27
|
+
* an empty string, as it renders.
|
|
28
|
+
*/
|
|
29
|
+
export declare const processTwigParam: (template: string, variables?: Record<string, unknown>) => unknown;
|