@grapesjs/studio-sdk-plugins 1.0.22 → 1.0.23
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/dataSourceEjs/EjsImporter.d.ts +2 -1
- package/dist/dataSourceEjs/index.cjs.js +23 -17
- package/dist/dataSourceEjs/index.es.js +339 -290
- package/dist/dataSourceEjs/index.umd.js +23 -17
- package/dist/dataSourceEjs/tests/EjsExporter.test.d.ts +1 -0
- package/dist/dataSourceEjs/tests/EjsImporter.test.d.ts +1 -0
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +2 -2
- package/dist/dataSourceHandlebars/HandlebarsImporter.d.ts +9 -0
- package/dist/dataSourceHandlebars/constants.d.ts +16 -0
- package/dist/dataSourceHandlebars/index.cjs.js +13 -13
- package/dist/dataSourceHandlebars/index.es.js +272 -217
- package/dist/dataSourceHandlebars/index.umd.js +13 -13
- package/dist/dataSourceHandlebars/tests/HandlebarsExporter.test.d.ts +1 -0
- package/dist/dataSourceHandlebars/tests/HandlebarsImporter.test.d.ts +1 -0
- package/dist/index.cjs.js +70 -63
- package/dist/index.es.js +3297 -3187
- package/dist/index.umd.js +70 -63
- package/dist/presetPrintable/index.cjs.js +7 -6
- package/dist/presetPrintable/index.es.js +204 -197
- package/dist/presetPrintable/index.umd.js +7 -6
- package/dist/presetPrintable/shared.d.ts +3 -0
- package/dist/presetPrintable/types.d.ts +4 -1
- package/dist/presetPrintable/typesSchema.d.ts +18 -0
- package/dist/presetPrintable/utils.d.ts +11 -0
- package/jest.config.js +9 -0
- package/package.json +4 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const C = "app.grapesjs.com", w = "app-stage.grapesjs.com", b = [
|
|
2
|
+
C,
|
|
3
|
+
w,
|
|
4
4
|
"localhost",
|
|
5
5
|
"127.0.0.1",
|
|
6
6
|
".local-credentialless.webcontainer.io",
|
|
@@ -9,83 +9,83 @@ const b = "app.grapesjs.com", I = "app-stage.grapesjs.com", S = [
|
|
|
9
9
|
// For stackblitz.com demos
|
|
10
10
|
"-sandpack.codesandbox.io"
|
|
11
11
|
// For Sandpack demos
|
|
12
|
-
],
|
|
13
|
-
const
|
|
14
|
-
return !!
|
|
12
|
+
], P = "license:check:start", L = "license:check:end", v = () => typeof window < "u", O = ({ isDev: o, isStage: t }) => `${o ? "" : `https://${t ? w : C}`}/api`, k = () => {
|
|
13
|
+
const o = v() && window.location.hostname;
|
|
14
|
+
return !!o && (b.includes(o) || b.some((t) => o.endsWith(t)));
|
|
15
15
|
};
|
|
16
|
-
async function
|
|
17
|
-
path:
|
|
16
|
+
async function T({
|
|
17
|
+
path: o,
|
|
18
18
|
baseApiUrl: t,
|
|
19
19
|
method: e = "GET",
|
|
20
|
-
headers:
|
|
20
|
+
headers: n = {},
|
|
21
21
|
params: s,
|
|
22
|
-
body:
|
|
22
|
+
body: r
|
|
23
23
|
}) {
|
|
24
|
-
const
|
|
24
|
+
const a = `${t || O({ isDev: !1, isStage: !1 })}${o}`, c = {
|
|
25
25
|
method: e,
|
|
26
26
|
headers: {
|
|
27
27
|
"Content-Type": "application/json",
|
|
28
|
-
...
|
|
28
|
+
...n
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
const p = s ? new URLSearchParams(s).toString() : "",
|
|
31
|
+
r && (c.body = JSON.stringify(r));
|
|
32
|
+
const p = s ? new URLSearchParams(s).toString() : "", l = p ? `?${p}` : "", h = await fetch(`${a}${l}`, c);
|
|
33
33
|
if (!h.ok)
|
|
34
34
|
throw new Error(`HTTP error! status: ${h.status}`);
|
|
35
35
|
return h.json();
|
|
36
36
|
}
|
|
37
|
-
var
|
|
38
|
-
const
|
|
39
|
-
[
|
|
40
|
-
[
|
|
41
|
-
[
|
|
42
|
-
[
|
|
37
|
+
var g = /* @__PURE__ */ ((o) => (o.free = "free", o.startup = "startup", o.business = "business", o.enterprise = "enterprise", o))(g || {});
|
|
38
|
+
const I = {
|
|
39
|
+
[g.free]: 0,
|
|
40
|
+
[g.startup]: 10,
|
|
41
|
+
[g.business]: 20,
|
|
42
|
+
[g.enterprise]: 30
|
|
43
43
|
};
|
|
44
|
-
function N(
|
|
45
|
-
const t =
|
|
46
|
-
return t.init = (e) => (
|
|
44
|
+
function N(o) {
|
|
45
|
+
const t = o;
|
|
46
|
+
return t.init = (e) => (n) => o(n, e), t;
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
async function
|
|
50
|
-
editor:
|
|
48
|
+
const M = (o) => /* @__PURE__ */ N(o);
|
|
49
|
+
async function B({
|
|
50
|
+
editor: o,
|
|
51
51
|
plan: t,
|
|
52
52
|
pluginName: e,
|
|
53
|
-
licenseKey:
|
|
53
|
+
licenseKey: n,
|
|
54
54
|
cleanup: s
|
|
55
55
|
}) {
|
|
56
|
-
let
|
|
57
|
-
const
|
|
58
|
-
console.warn("Cleanup plugin:", e, "Reason:",
|
|
59
|
-
}, p = (
|
|
60
|
-
var
|
|
61
|
-
const { error: h, sdkLicense:
|
|
62
|
-
if (!(
|
|
63
|
-
|
|
64
|
-
else if (
|
|
65
|
-
const
|
|
66
|
-
|
|
56
|
+
let r = "", i = !1;
|
|
57
|
+
const a = k(), c = (l) => {
|
|
58
|
+
console.warn("Cleanup plugin:", e, "Reason:", l), s();
|
|
59
|
+
}, p = (l = {}) => {
|
|
60
|
+
var u;
|
|
61
|
+
const { error: h, sdkLicense: d } = l, f = (u = l.plan) == null ? void 0 : u.category;
|
|
62
|
+
if (!(d || l.license) || h)
|
|
63
|
+
c(h || "Invalid license");
|
|
64
|
+
else if (f) {
|
|
65
|
+
const m = I[t], S = I[f];
|
|
66
|
+
m > S && c({ pluginRequiredPlan: t, licensePlan: f });
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}),
|
|
72
|
-
p(
|
|
69
|
+
o.on(P, (l) => {
|
|
70
|
+
r = l == null ? void 0 : l.baseApiUrl, i = !0;
|
|
71
|
+
}), o.on(L, (l) => {
|
|
72
|
+
p(l);
|
|
73
73
|
}), setTimeout(async () => {
|
|
74
|
-
if (!
|
|
75
|
-
if (
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
78
|
-
|
|
74
|
+
if (!i) {
|
|
75
|
+
if (a) return;
|
|
76
|
+
if (n) {
|
|
77
|
+
const l = await _({ licenseKey: n, pluginName: e, baseApiUrl: r });
|
|
78
|
+
l && p(l);
|
|
79
79
|
} else
|
|
80
|
-
|
|
80
|
+
c("The `licenseKey` option not provided");
|
|
81
81
|
}
|
|
82
82
|
}, 2e3);
|
|
83
83
|
}
|
|
84
|
-
async function
|
|
85
|
-
const { licenseKey: t, pluginName: e, baseApiUrl:
|
|
84
|
+
async function _(o) {
|
|
85
|
+
const { licenseKey: t, pluginName: e, baseApiUrl: n } = o;
|
|
86
86
|
try {
|
|
87
|
-
return (await
|
|
88
|
-
baseApiUrl:
|
|
87
|
+
return (await T({
|
|
88
|
+
baseApiUrl: n,
|
|
89
89
|
path: `/sdk/${t || "na"}`,
|
|
90
90
|
method: "POST",
|
|
91
91
|
params: {
|
|
@@ -97,7 +97,7 @@ async function B(i) {
|
|
|
97
97
|
return console.error("Error during SDK license check:", s), !1;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
var
|
|
100
|
+
var y = /* @__PURE__ */ ((o) => (o.variable = "data-variable", o.condition = "data-condition", o.conditionTrue = "data-condition-true-content", o.conditionFalse = "data-condition-false-content", o.collection = "data-collection", o.collectionItem = "data-collection-item", o))(y || {});
|
|
101
101
|
class W {
|
|
102
102
|
constructor(t) {
|
|
103
103
|
this.strategy = t, this.requiredHelpers = /* @__PURE__ */ new Set(), this.helperLibrary = {};
|
|
@@ -127,131 +127,132 @@ class W {
|
|
|
127
127
|
this.requiredHelpers.clear();
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
function j(
|
|
131
|
-
return typeof
|
|
130
|
+
function j(o) {
|
|
131
|
+
return typeof o == "object" && o.type === y.variable;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
component:
|
|
133
|
+
function x({
|
|
134
|
+
component: o,
|
|
135
135
|
value: t,
|
|
136
136
|
getCustomPath: e
|
|
137
137
|
}) {
|
|
138
138
|
if (j(t) && !t.collectionId && e) {
|
|
139
|
-
const
|
|
139
|
+
const n = t.path ?? "", s = n.split(".");
|
|
140
140
|
return {
|
|
141
141
|
...t,
|
|
142
|
-
path: e({ component:
|
|
142
|
+
path: e({ component: o, path: n, paths: s })
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
return t;
|
|
146
146
|
}
|
|
147
|
-
const A = (
|
|
148
|
-
|
|
147
|
+
const A = (o) => {
|
|
148
|
+
$(o, y.variable, {
|
|
149
149
|
toHTML(t) {
|
|
150
|
-
var
|
|
151
|
-
const e = this.tagName,
|
|
150
|
+
var i;
|
|
151
|
+
const e = this.tagName, n = this.__attrToString(t), s = (i = this.getDataResolver) == null ? void 0 : i.call(this), r = x({
|
|
152
152
|
component: this,
|
|
153
153
|
value: s,
|
|
154
154
|
getCustomPath: t == null ? void 0 : t.getCustomPath
|
|
155
155
|
});
|
|
156
|
-
return `<${e}${
|
|
156
|
+
return `<${e}${n ? ` ${n}` : ""}>${t.exporter.generateVariable(r)}</${e}>`;
|
|
157
157
|
}
|
|
158
|
-
}),
|
|
158
|
+
}), $(o, y.condition, {
|
|
159
159
|
toHTML(t) {
|
|
160
|
-
var
|
|
161
|
-
const e = t.exporter,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
160
|
+
var l, h;
|
|
161
|
+
const e = t.exporter, n = t == null ? void 0 : t.getCustomPath, s = this.components(), [r, i] = (s == null ? void 0 : s.models) ?? [], a = (l = this.getDataResolver) == null ? void 0 : l.call(this), c = ((h = this.resolveCondition) == null ? void 0 : h.call(this, a == null ? void 0 : a.condition, n)) ?? {};
|
|
162
|
+
let p = "";
|
|
163
|
+
return i && (p = `
|
|
164
|
+
${e.generateConditionElse()}
|
|
165
|
+
${i.toHTML(t) ?? ""}`), `
|
|
166
|
+
${e.generateConditionalStart(c)}
|
|
167
|
+
${(r == null ? void 0 : r.toHTML(t)) ?? ""}${p}
|
|
168
|
+
${e.generateConditionalEnd()}
|
|
168
169
|
`;
|
|
169
170
|
},
|
|
170
171
|
resolveCondition(t, e) {
|
|
171
|
-
var s,
|
|
172
|
+
var s, r;
|
|
172
173
|
if (!t) return {};
|
|
173
174
|
if (t.operator === "and" || t.operator === "or")
|
|
174
175
|
return {
|
|
175
176
|
operator: t.operator,
|
|
176
|
-
statements: ((
|
|
177
|
-
var
|
|
178
|
-
return ((
|
|
177
|
+
statements: ((r = (s = t.statements) == null ? void 0 : s.map) == null ? void 0 : r.call(s, (i) => {
|
|
178
|
+
var a;
|
|
179
|
+
return ((a = this.resolveCondition) == null ? void 0 : a.call(this, i, e)) ?? {};
|
|
179
180
|
})) ?? []
|
|
180
181
|
};
|
|
181
|
-
const
|
|
182
|
+
const n = { component: this, getCustomPath: e };
|
|
182
183
|
return {
|
|
183
184
|
...t,
|
|
184
|
-
left:
|
|
185
|
-
right:
|
|
185
|
+
left: x({ ...n, value: t.left }),
|
|
186
|
+
right: x({ ...n, value: t.right })
|
|
186
187
|
};
|
|
187
188
|
}
|
|
188
|
-
}),
|
|
189
|
+
}), $(o, y.collection, {
|
|
189
190
|
toHTML(t) {
|
|
190
|
-
const e = t.exporter,
|
|
191
|
-
...
|
|
192
|
-
dataSource:
|
|
191
|
+
const e = t.exporter, n = this.tagName, s = this.__attrToString(t), r = this.getDataResolver(), i = {
|
|
192
|
+
...r,
|
|
193
|
+
dataSource: x({
|
|
193
194
|
component: this,
|
|
194
|
-
value:
|
|
195
|
+
value: r == null ? void 0 : r.dataSource,
|
|
195
196
|
getCustomPath: t == null ? void 0 : t.getCustomPath
|
|
196
197
|
})
|
|
197
|
-
},
|
|
198
|
+
}, a = this.components().at(0);
|
|
198
199
|
return `
|
|
199
|
-
<${
|
|
200
|
-
${(
|
|
201
|
-
|
|
200
|
+
<${n}${s ? ` ${s}` : ""}>${e.generateCollectionStart(i)}
|
|
201
|
+
${(a == null ? void 0 : a.toHTML(t)) ?? ""}
|
|
202
|
+
${e.generateCollectionEnd()}</${n}>
|
|
202
203
|
`;
|
|
203
204
|
}
|
|
204
205
|
});
|
|
205
|
-
},
|
|
206
|
-
const
|
|
207
|
-
if (!
|
|
206
|
+
}, $ = (o, t, e) => {
|
|
207
|
+
const n = o.Components.getType(t);
|
|
208
|
+
if (!n) {
|
|
208
209
|
console.warn(`Component type ${t} not found`);
|
|
209
210
|
return;
|
|
210
211
|
}
|
|
211
|
-
const { model: s } =
|
|
212
|
-
|
|
212
|
+
const { model: s } = n;
|
|
213
|
+
o.Components.addType(t, {
|
|
213
214
|
model: {
|
|
214
215
|
...e,
|
|
215
|
-
toHTML(
|
|
216
|
-
var
|
|
217
|
-
const { exporter:
|
|
218
|
-
return
|
|
216
|
+
toHTML(r = {}) {
|
|
217
|
+
var a;
|
|
218
|
+
const { exporter: i } = r;
|
|
219
|
+
return i ? i.export ? i.export({ component: this }) : ((a = e.toHTML) == null ? void 0 : a.call(this, r)) ?? "" : s.prototype.toHTML.call(this, r) ?? "";
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
});
|
|
222
|
-
}, J = (
|
|
223
|
-
const t =
|
|
223
|
+
}, J = (o) => {
|
|
224
|
+
const t = o;
|
|
224
225
|
return t.logicalOperator === "and" || t.logicalOperator === "or";
|
|
225
|
-
},
|
|
226
|
-
...
|
|
226
|
+
}, F = (o, t) => (o.config.optsHtml = {
|
|
227
|
+
...o.config.optsHtml,
|
|
227
228
|
exporter: new W(t)
|
|
228
|
-
}, A(
|
|
229
|
-
|
|
230
|
-
}),
|
|
229
|
+
}, A(o), () => {
|
|
230
|
+
o.config.optsHtml.exporter = void 0;
|
|
231
|
+
}), H = (o, t) => {
|
|
231
232
|
const e = (s) => {
|
|
232
|
-
const { input:
|
|
233
|
-
(!
|
|
234
|
-
},
|
|
235
|
-
return
|
|
236
|
-
|
|
233
|
+
const { input: r } = s, { contains: i } = t;
|
|
234
|
+
(!i || r.includes(i)) && (s.input = t.importer.import(r));
|
|
235
|
+
}, n = o.Parser.events.htmlBefore;
|
|
236
|
+
return o.on(n, e), () => {
|
|
237
|
+
o.off(n, e);
|
|
237
238
|
};
|
|
238
239
|
};
|
|
239
|
-
class
|
|
240
|
+
class U {
|
|
240
241
|
getVariableSyntax(t) {
|
|
241
|
-
const { defaultValue: e } = t,
|
|
242
|
-
return `<%= ${
|
|
242
|
+
const { defaultValue: e } = t, n = this.getFullPath(t), s = e ? ` || \`${e}\`` : "";
|
|
243
|
+
return `<%= ${n}${s} %>`;
|
|
243
244
|
}
|
|
244
245
|
getCollectionStartSyntax(t) {
|
|
245
|
-
const { collectionId: e, dataSource:
|
|
246
|
-
let
|
|
247
|
-
if (s !== void 0 ||
|
|
248
|
-
const p = s ?? 0,
|
|
249
|
-
|
|
246
|
+
const { collectionId: e, dataSource: n, startIndex: s, endIndex: r } = t, i = (n == null ? void 0 : n.path) || e || "", a = this._sanitizeVariableName(e);
|
|
247
|
+
let c = "";
|
|
248
|
+
if (s !== void 0 || r !== void 0) {
|
|
249
|
+
const p = s ?? 0, l = r !== void 0 ? r : "";
|
|
250
|
+
c = `.slice(${p}${l !== "" ? `, ${l}` : ""})`;
|
|
250
251
|
}
|
|
251
|
-
return `<% ${
|
|
252
|
+
return `<% ${i}${c}.forEach(function(currentItem, index, arr) {
|
|
252
253
|
const startIndex = parseInt(${s ?? 0}, 10);
|
|
253
254
|
const endIndex = startIndex + arr.length;
|
|
254
|
-
const ${
|
|
255
|
+
const ${a}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`;
|
|
255
256
|
}
|
|
256
257
|
_sanitizeVariableName(t) {
|
|
257
258
|
return t.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
@@ -268,36 +269,37 @@ const ${o}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
|
|
|
268
269
|
getConditionalEndSyntax() {
|
|
269
270
|
return "<% } %>";
|
|
270
271
|
}
|
|
271
|
-
getFullPath({ collectionId: t, path: e, variableType:
|
|
272
|
-
return (t ? [this._sanitizeVariableName(t),
|
|
272
|
+
getFullPath({ collectionId: t, path: e, variableType: n }) {
|
|
273
|
+
return (t ? [this._sanitizeVariableName(t), n, e].filter(Boolean).join(".") : e) || "";
|
|
273
274
|
}
|
|
274
275
|
_parseCondition(t) {
|
|
275
276
|
if (!t) return "";
|
|
276
277
|
if (J(t)) {
|
|
277
|
-
const e = t.statements.map((r) => this._parseCondition(r));
|
|
278
|
-
|
|
278
|
+
const e = t.statements.map((r) => this._parseCondition(r)), n = D[t.logicalOperator];
|
|
279
|
+
let s = e.length > 1 ? `(${e.join(`)${n}(`)})` : e[0];
|
|
280
|
+
return t.logicalOperator === "xor" && (s = `!!(${s})`), s;
|
|
279
281
|
} else {
|
|
280
|
-
const e = this._parseValue(t.left),
|
|
282
|
+
const e = this._parseValue(t.left), n = this._parseValue(t.right);
|
|
281
283
|
switch (t.operator) {
|
|
282
284
|
case "equals":
|
|
283
|
-
return `${e} === ${
|
|
285
|
+
return `${e} === ${n}`;
|
|
284
286
|
case ">":
|
|
285
287
|
case "<":
|
|
286
288
|
case ">=":
|
|
287
289
|
case "<=":
|
|
288
290
|
case "=":
|
|
289
291
|
case "!=":
|
|
290
|
-
return `${e} ${t.operator} ${
|
|
292
|
+
return `${e} ${t.operator} ${n}`;
|
|
291
293
|
case "contains":
|
|
292
|
-
return `${e}?.includes(${
|
|
294
|
+
return `${e}?.includes(${n})`;
|
|
293
295
|
case "startsWith":
|
|
294
|
-
return `${e}?.startsWith(${
|
|
296
|
+
return `${e}?.startsWith(${n})`;
|
|
295
297
|
case "endsWith":
|
|
296
|
-
return `${e}?.endsWith(${
|
|
298
|
+
return `${e}?.endsWith(${n})`;
|
|
297
299
|
case "equalsIgnoreCase":
|
|
298
|
-
return `${e}?.toLowerCase() === ${
|
|
300
|
+
return `${e}?.toLowerCase() === ${n}?.toLowerCase()`;
|
|
299
301
|
case "trimEquals":
|
|
300
|
-
return `${e}?.trim() === ${
|
|
302
|
+
return `${e}?.trim() === ${n}?.trim()`;
|
|
301
303
|
case "isTruthy":
|
|
302
304
|
return `!!${e}`;
|
|
303
305
|
case "isFalsy":
|
|
@@ -319,7 +321,7 @@ const ${o}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
|
|
|
319
321
|
case "isBoolean":
|
|
320
322
|
return `typeof ${e} === 'boolean'`;
|
|
321
323
|
default:
|
|
322
|
-
return `${e} ${t.operator} ${
|
|
324
|
+
return `${e} ${t.operator} ${n}`;
|
|
323
325
|
}
|
|
324
326
|
}
|
|
325
327
|
}
|
|
@@ -327,7 +329,11 @@ const ${o}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
|
|
|
327
329
|
return typeof t == "object" ? this.getFullPath(t) : typeof t == "string" ? `'${t.replace(/'/g, "\\'")}'` : String(t);
|
|
328
330
|
}
|
|
329
331
|
}
|
|
330
|
-
const
|
|
332
|
+
const D = {
|
|
333
|
+
and: "&&",
|
|
334
|
+
or: "||",
|
|
335
|
+
xor: "^"
|
|
336
|
+
}, V = ["===", "==", "!==", "!=", "<=", ">=", "<", ">", "&&", "||"], q = {
|
|
331
337
|
"===": "=",
|
|
332
338
|
"==": "=",
|
|
333
339
|
"!==": "!=",
|
|
@@ -339,7 +345,7 @@ const V = ["===", "==", "!==", "!=", "<=", ">=", "<", ">", "&&", "||"], q = {
|
|
|
339
345
|
"&&": "&&",
|
|
340
346
|
"||": "||"
|
|
341
347
|
};
|
|
342
|
-
class
|
|
348
|
+
class G {
|
|
343
349
|
constructor() {
|
|
344
350
|
this.messages = [], this.collectionStack = [];
|
|
345
351
|
}
|
|
@@ -354,34 +360,37 @@ class F {
|
|
|
354
360
|
}
|
|
355
361
|
parseEjsTemplate(t) {
|
|
356
362
|
const e = [];
|
|
357
|
-
let
|
|
358
|
-
for (;
|
|
359
|
-
const s = t.indexOf("<%",
|
|
363
|
+
let n = 0;
|
|
364
|
+
for (; n < t.length; ) {
|
|
365
|
+
const s = t.indexOf("<%", n);
|
|
360
366
|
if (s === -1) {
|
|
361
|
-
|
|
367
|
+
n < t.length && e.push(this.createAppendLiteral(t.slice(n)));
|
|
362
368
|
break;
|
|
363
369
|
}
|
|
364
|
-
s >
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
370
|
+
s > n && e.push(this.createAppendLiteral(t.slice(n, s)));
|
|
371
|
+
const r = t.indexOf("%>", s);
|
|
372
|
+
if (r === -1)
|
|
367
373
|
throw new Error("Unclosed EJS tag");
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
370
|
-
const
|
|
371
|
-
e.push(this.createAppendExpression(
|
|
374
|
+
const i = t.slice(s + 2, r).trim();
|
|
375
|
+
if (n = r + 2, i.startsWith("=") || i.startsWith("-")) {
|
|
376
|
+
const a = i.slice(1).trim();
|
|
377
|
+
e.push(this.createAppendExpression(a));
|
|
372
378
|
} else {
|
|
373
|
-
if (
|
|
379
|
+
if (i.startsWith("#"))
|
|
374
380
|
continue;
|
|
375
|
-
if (
|
|
376
|
-
const
|
|
377
|
-
e.push(
|
|
378
|
-
} else if (
|
|
379
|
-
const
|
|
380
|
-
e.push(
|
|
381
|
+
if (i.startsWith("if")) {
|
|
382
|
+
const a = this.parseIfStatement(i, t, n);
|
|
383
|
+
e.push(a), n = a.endPos || n;
|
|
384
|
+
} else if (i.startsWith("for")) {
|
|
385
|
+
const a = this.parseForStatement(i, t, n);
|
|
386
|
+
e.push(a), n = a.endPos || n;
|
|
381
387
|
} else {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
388
|
+
const a = i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
|
|
389
|
+
if (a) {
|
|
390
|
+
const c = a[1], p = a[2], l = this.parseForEachStatement(c, p, t, n);
|
|
391
|
+
e.push(l), n = l.endPos || n;
|
|
392
|
+
} else
|
|
393
|
+
this.addMessage("info", `Unsupported scriptlet content: ${i}`);
|
|
385
394
|
}
|
|
386
395
|
}
|
|
387
396
|
}
|
|
@@ -410,60 +419,57 @@ class F {
|
|
|
410
419
|
}
|
|
411
420
|
};
|
|
412
421
|
}
|
|
413
|
-
|
|
414
|
-
const r = /<%\s*\}\s*else(?:\s+if\s*\([^)]*\))?\s*\{\s*%>/g;
|
|
415
|
-
r.lastIndex = e;
|
|
416
|
-
const s = r.exec(t);
|
|
417
|
-
return s ? {
|
|
418
|
-
start: s.index,
|
|
419
|
-
end: t.indexOf("%>", s.index) + 2
|
|
420
|
-
// End of <% } else { %>
|
|
421
|
-
} : null;
|
|
422
|
-
}
|
|
423
|
-
parseIfStatement(t, e, r) {
|
|
422
|
+
parseIfStatement(t, e, n) {
|
|
424
423
|
const s = t.match(/if\s*\((.*)\)\s*\{?/);
|
|
425
424
|
if (!s)
|
|
426
425
|
throw new Error("Invalid if statement syntax");
|
|
427
|
-
const
|
|
428
|
-
let
|
|
429
|
-
const
|
|
430
|
-
if (
|
|
431
|
-
const h = e.
|
|
432
|
-
if (
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
426
|
+
const r = this.parseJsExpression(s[1]), { body: i, endPos: a } = this.parseTemplateBlock(e, n);
|
|
427
|
+
let c = null, p = a;
|
|
428
|
+
const l = e.indexOf("<%", p);
|
|
429
|
+
if (l === p) {
|
|
430
|
+
const h = e.indexOf("%>", l);
|
|
431
|
+
if (h !== -1) {
|
|
432
|
+
const d = e.slice(l + 2, h).trim(), f = h + 2 - l;
|
|
433
|
+
if (d.startsWith("} else if")) {
|
|
434
|
+
p = l + f;
|
|
435
|
+
const E = d.substring(d.indexOf("if")).trim(), u = this.parseIfStatement(E, e, p);
|
|
436
|
+
c = {
|
|
437
|
+
type: "IfStatement",
|
|
438
|
+
test: u.test,
|
|
439
|
+
consequent: u.consequent,
|
|
440
|
+
alternate: u.alternate
|
|
441
|
+
}, p = u.endPos;
|
|
442
|
+
} else if (d.startsWith("} else")) {
|
|
443
|
+
p = l + f;
|
|
444
|
+
const { body: E, endPos: u } = this.parseTemplateBlock(e, p);
|
|
445
|
+
c = {
|
|
446
|
+
type: "BlockStatement",
|
|
447
|
+
body: E
|
|
448
|
+
}, p = u;
|
|
449
|
+
const m = e.indexOf("<%", p), S = e.indexOf("%>", m);
|
|
450
|
+
m === p && e.slice(m + 2, S).trim() === "}" && (p = S + 2);
|
|
451
|
+
} else d === "}" && (p = l + f);
|
|
446
452
|
}
|
|
447
453
|
}
|
|
448
454
|
return {
|
|
449
455
|
type: "IfStatement",
|
|
450
|
-
test:
|
|
456
|
+
test: r,
|
|
451
457
|
consequent: {
|
|
452
458
|
type: "BlockStatement",
|
|
453
|
-
body:
|
|
459
|
+
body: i
|
|
454
460
|
},
|
|
455
|
-
alternate:
|
|
461
|
+
alternate: c,
|
|
456
462
|
endPos: p
|
|
457
463
|
};
|
|
458
464
|
}
|
|
459
|
-
parseForStatement(t, e,
|
|
465
|
+
parseForStatement(t, e, n) {
|
|
460
466
|
const s = t.match(/for\s*\((.*)\)\s*\{?/);
|
|
461
467
|
if (!s)
|
|
462
468
|
throw new Error("Invalid for statement syntax");
|
|
463
|
-
const
|
|
464
|
-
if (
|
|
469
|
+
const r = s[1].split("of");
|
|
470
|
+
if (r.length !== 2)
|
|
465
471
|
throw new Error("Only for...of loops are supported");
|
|
466
|
-
const
|
|
472
|
+
const i = r[0].trim().replace(/^let\s+|^const\s+|^var\s+/, ""), a = r[1].trim(), { body: c, endPos: p } = this.parseTemplateBlock(e, n);
|
|
467
473
|
return {
|
|
468
474
|
type: "ForStatement",
|
|
469
475
|
init: {
|
|
@@ -472,8 +478,8 @@ class F {
|
|
|
472
478
|
declarations: [
|
|
473
479
|
{
|
|
474
480
|
type: "VariableDeclarator",
|
|
475
|
-
id: { type: "Identifier", name:
|
|
476
|
-
init: this.parseJsExpression(
|
|
481
|
+
id: { type: "Identifier", name: i },
|
|
482
|
+
init: this.parseJsExpression(a)
|
|
477
483
|
}
|
|
478
484
|
]
|
|
479
485
|
},
|
|
@@ -481,42 +487,72 @@ class F {
|
|
|
481
487
|
update: null,
|
|
482
488
|
body: {
|
|
483
489
|
type: "BlockStatement",
|
|
484
|
-
body:
|
|
490
|
+
body: c
|
|
485
491
|
},
|
|
486
|
-
|
|
492
|
+
// Consume the closing '}' tag for the for loop
|
|
493
|
+
endPos: (() => {
|
|
494
|
+
const l = e.indexOf("<%", p), h = e.indexOf("%>", l);
|
|
495
|
+
return l === p && e.slice(l + 2, h).trim() === "}" ? h + 2 : p;
|
|
496
|
+
})()
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
parseForEachStatement(t, e, n, s) {
|
|
500
|
+
const { body: r, endPos: i } = this.parseTemplateBlock(n, s);
|
|
501
|
+
return {
|
|
502
|
+
type: "ForEachStatement",
|
|
503
|
+
collection: this.parseJsExpression(t),
|
|
504
|
+
itemIdentifier: { type: "Identifier", name: e },
|
|
505
|
+
body: {
|
|
506
|
+
type: "BlockStatement",
|
|
507
|
+
body: r
|
|
508
|
+
},
|
|
509
|
+
endPos: (() => {
|
|
510
|
+
const a = n.indexOf("<%", i), c = n.indexOf("%>", a);
|
|
511
|
+
return a === i && n.slice(a + 2, c).trim() === "}" ? c + 2 : i;
|
|
512
|
+
})()
|
|
487
513
|
};
|
|
488
514
|
}
|
|
489
515
|
parseTemplateBlock(t, e) {
|
|
490
|
-
const
|
|
491
|
-
let s = e
|
|
492
|
-
for (; s < t.length
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
495
|
-
s < t.length &&
|
|
516
|
+
const n = [];
|
|
517
|
+
let s = e;
|
|
518
|
+
for (; s < t.length; ) {
|
|
519
|
+
const r = t.indexOf("<%", s);
|
|
520
|
+
if (r === -1) {
|
|
521
|
+
s < t.length && n.push(this.createAppendLiteral(t.slice(s))), s = t.length;
|
|
496
522
|
break;
|
|
497
523
|
}
|
|
498
|
-
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
501
|
-
throw new Error("Unclosed EJS tag");
|
|
502
|
-
const
|
|
503
|
-
if (
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}
|
|
507
|
-
if (
|
|
508
|
-
const
|
|
509
|
-
|
|
524
|
+
r > s && n.push(this.createAppendLiteral(t.slice(s, r)));
|
|
525
|
+
const i = t.indexOf("%>", r);
|
|
526
|
+
if (i === -1)
|
|
527
|
+
throw new Error("Unclosed EJS tag within block");
|
|
528
|
+
const a = t.slice(r + 2, i).trim();
|
|
529
|
+
if (a === "}" || a.startsWith("} else")) {
|
|
530
|
+
s = r;
|
|
531
|
+
break;
|
|
532
|
+
}
|
|
533
|
+
if (s = i + 2, a.startsWith("=") || a.startsWith("-")) {
|
|
534
|
+
const c = a.slice(1).trim();
|
|
535
|
+
n.push(this.createAppendExpression(c));
|
|
510
536
|
} else {
|
|
511
|
-
if (
|
|
537
|
+
if (a.startsWith("#"))
|
|
512
538
|
continue;
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
|
|
539
|
+
if (a.startsWith("if")) {
|
|
540
|
+
const c = this.parseIfStatement(a, t, s);
|
|
541
|
+
n.push(c), s = c.endPos || s;
|
|
542
|
+
} else if (a.startsWith("for")) {
|
|
543
|
+
const c = this.parseForStatement(a, t, s);
|
|
544
|
+
n.push(c), s = c.endPos || s;
|
|
545
|
+
} else {
|
|
546
|
+
const c = a.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
|
|
547
|
+
if (c) {
|
|
548
|
+
const p = c[1], l = c[2], h = this.parseForEachStatement(p, l, t, s);
|
|
549
|
+
n.push(h), s = h.endPos || s;
|
|
550
|
+
} else
|
|
551
|
+
this.addMessage("info", `Unsupported scriptlet content within block: ${a}`);
|
|
516
552
|
}
|
|
517
553
|
}
|
|
518
554
|
}
|
|
519
|
-
return { body:
|
|
555
|
+
return { body: n, endPos: s };
|
|
520
556
|
}
|
|
521
557
|
parseJsExpression(t) {
|
|
522
558
|
if (/^(['"]).*\1$/.test(t))
|
|
@@ -540,33 +576,34 @@ class F {
|
|
|
540
576
|
value: t === "true"
|
|
541
577
|
};
|
|
542
578
|
for (const s of V) {
|
|
543
|
-
const
|
|
544
|
-
if (
|
|
579
|
+
const r = t.lastIndexOf(s);
|
|
580
|
+
if (r > 0 && t[r - 1] !== "!" && t[r - 1] !== "=" && t[r - 1] !== "<" && t[r - 1] !== ">")
|
|
545
581
|
return {
|
|
546
582
|
type: s === "&&" || s === "||" ? "LogicalExpression" : "BinaryExpression",
|
|
547
583
|
operator: q[s],
|
|
548
|
-
left: this.parseJsExpression(t.slice(0,
|
|
549
|
-
right: this.parseJsExpression(t.slice(
|
|
584
|
+
left: this.parseJsExpression(t.slice(0, r).trim()),
|
|
585
|
+
right: this.parseJsExpression(t.slice(r + s.length).trim())
|
|
550
586
|
};
|
|
551
587
|
}
|
|
552
|
-
const e = t.indexOf("."),
|
|
553
|
-
if (e > 0 ||
|
|
554
|
-
const s = e > 0 && (
|
|
555
|
-
let
|
|
588
|
+
const e = t.indexOf("."), n = t.indexOf("[");
|
|
589
|
+
if (e > 0 && (n === -1 || e < n) || n > 0 && (e === -1 || n < e)) {
|
|
590
|
+
const s = e > 0 && (n === -1 || e < n) ? e : n;
|
|
591
|
+
let r, i, a = !1;
|
|
556
592
|
if (s === e)
|
|
557
|
-
|
|
593
|
+
r = t.slice(0, e), i = { type: "Identifier", name: t.slice(e + 1) }, a = !1;
|
|
558
594
|
else {
|
|
559
|
-
|
|
560
|
-
const
|
|
561
|
-
if (
|
|
595
|
+
r = t.slice(0, n);
|
|
596
|
+
const c = t.indexOf("]", n);
|
|
597
|
+
if (c === -1)
|
|
562
598
|
throw new Error("Unclosed bracket in expression");
|
|
563
|
-
|
|
599
|
+
const p = t.slice(n + 1, c);
|
|
600
|
+
i = /^(['"]).*\1$/.test(p) || /^-?\d+(\.\d+)?$/.test(p) ? this.parseJsExpression(p) : { type: "Identifier", name: p }, a = !0;
|
|
564
601
|
}
|
|
565
602
|
return {
|
|
566
603
|
type: "MemberExpression",
|
|
567
|
-
object: this.parseJsExpression(
|
|
568
|
-
property:
|
|
569
|
-
computed:
|
|
604
|
+
object: this.parseJsExpression(r),
|
|
605
|
+
property: i,
|
|
606
|
+
computed: a
|
|
570
607
|
};
|
|
571
608
|
}
|
|
572
609
|
return {
|
|
@@ -586,6 +623,8 @@ class F {
|
|
|
586
623
|
return this.handleIfStatement(t);
|
|
587
624
|
case "ForStatement":
|
|
588
625
|
return this.handleForStatement(t);
|
|
626
|
+
case "ForEachStatement":
|
|
627
|
+
return this.handleForEachStatement(t);
|
|
589
628
|
case "BlockStatement":
|
|
590
629
|
return this.handleBlockStatement(t);
|
|
591
630
|
case "Literal":
|
|
@@ -606,8 +645,8 @@ class F {
|
|
|
606
645
|
}
|
|
607
646
|
handleProgram(t) {
|
|
608
647
|
let e = "";
|
|
609
|
-
for (const
|
|
610
|
-
e += this.astToGrapesJS(
|
|
648
|
+
for (const n of t.body)
|
|
649
|
+
e += this.astToGrapesJS(n);
|
|
611
650
|
return e;
|
|
612
651
|
}
|
|
613
652
|
handleVariableDeclaration(t) {
|
|
@@ -617,11 +656,11 @@ class F {
|
|
|
617
656
|
return t.expression.type === "CallExpression" && t.expression.callee.type === "Identifier" && t.expression.callee.name === "__append" && t.expression.arguments.length > 0 ? this.astToGrapesJS(t.expression.arguments[0]) : "";
|
|
618
657
|
}
|
|
619
658
|
handleIfStatement(t) {
|
|
620
|
-
const e = this.getConditionExpression(t.test),
|
|
659
|
+
const e = this.getConditionExpression(t.test), n = this.astToGrapesJS(t.consequent);
|
|
621
660
|
let s = "";
|
|
622
661
|
return t.alternate && (s = this.astToGrapesJS(t.alternate)), `
|
|
623
662
|
<data-condition data-gjs-data-resolver='${JSON.stringify({ condition: e })}'>
|
|
624
|
-
<data-condition-true-content>${
|
|
663
|
+
<data-condition-true-content>${n}</data-condition-true-content>
|
|
625
664
|
<data-condition-false-content>${s}</data-condition-false-content>
|
|
626
665
|
</data-condition>
|
|
627
666
|
`;
|
|
@@ -633,30 +672,44 @@ class F {
|
|
|
633
672
|
const e = t.init.declarations[0];
|
|
634
673
|
if (e.id.type !== "Identifier")
|
|
635
674
|
return this.addMessage("warning", "Unsupported for loop variable declaration id"), "";
|
|
636
|
-
let
|
|
675
|
+
let n = "";
|
|
637
676
|
if (e.init)
|
|
638
|
-
|
|
677
|
+
n = this.getExpressionString(e.init);
|
|
639
678
|
else
|
|
640
679
|
return this.addMessage("warning", "For loop collection is undefined"), "";
|
|
641
|
-
|
|
642
|
-
const s = `collection-${Math.random().toString(36).substring(2, 10)}`;
|
|
680
|
+
const s = e.id.name, r = s;
|
|
643
681
|
this.collectionStack.push(s);
|
|
644
|
-
const
|
|
682
|
+
const i = this.astToGrapesJS(t.body);
|
|
683
|
+
return this.collectionStack.pop(), `
|
|
684
|
+
<data-collection data-gjs-data-resolver='${JSON.stringify({
|
|
685
|
+
dataSource: { type: "data-variable", path: n },
|
|
686
|
+
collectionId: r
|
|
687
|
+
})}'>
|
|
688
|
+
<data-collection-item>
|
|
689
|
+
${i}
|
|
690
|
+
</data-collection-item>
|
|
691
|
+
</data-collection>
|
|
692
|
+
`;
|
|
693
|
+
}
|
|
694
|
+
handleForEachStatement(t) {
|
|
695
|
+
const e = this.getExpressionString(t.collection), n = t.itemIdentifier.name, s = n;
|
|
696
|
+
this.collectionStack.push(n);
|
|
697
|
+
const r = this.astToGrapesJS(t.body);
|
|
645
698
|
return this.collectionStack.pop(), `
|
|
646
699
|
<data-collection data-gjs-data-resolver='${JSON.stringify({
|
|
647
|
-
dataSource: { type: "data-variable", path:
|
|
700
|
+
dataSource: { type: "data-variable", path: e },
|
|
648
701
|
collectionId: s
|
|
649
702
|
})}'>
|
|
650
703
|
<data-collection-item>
|
|
651
|
-
${
|
|
704
|
+
${r}
|
|
652
705
|
</data-collection-item>
|
|
653
706
|
</data-collection>
|
|
654
707
|
`;
|
|
655
708
|
}
|
|
656
709
|
handleBlockStatement(t) {
|
|
657
710
|
let e = "";
|
|
658
|
-
for (const
|
|
659
|
-
e += this.astToGrapesJS(
|
|
711
|
+
for (const n of t.body)
|
|
712
|
+
e += this.astToGrapesJS(n);
|
|
660
713
|
return e;
|
|
661
714
|
}
|
|
662
715
|
handleLiteral(t) {
|
|
@@ -664,34 +717,30 @@ class F {
|
|
|
664
717
|
}
|
|
665
718
|
handleIdentifier(t) {
|
|
666
719
|
let e = { path: t.name };
|
|
667
|
-
if (this.collectionStack.length > 0
|
|
668
|
-
const
|
|
669
|
-
e = {
|
|
670
|
-
|
|
671
|
-
collectionId: r,
|
|
720
|
+
if (this.collectionStack.length > 0) {
|
|
721
|
+
const n = this.collectionStack[this.collectionStack.length - 1];
|
|
722
|
+
t.name === n && (e = {
|
|
723
|
+
collectionId: n,
|
|
672
724
|
variableType: "currentItem"
|
|
673
|
-
};
|
|
725
|
+
});
|
|
674
726
|
}
|
|
675
727
|
return `<data-variable data-gjs-data-resolver='${JSON.stringify(e)}'></data-variable>`;
|
|
676
728
|
}
|
|
677
729
|
handleMemberExpression(t, e = {}) {
|
|
678
730
|
let s = { path: this.getExpressionString(t), ...e };
|
|
679
731
|
if (this.collectionStack.length > 0) {
|
|
680
|
-
|
|
732
|
+
const r = this.collectionStack[this.collectionStack.length - 1];
|
|
733
|
+
let i = t;
|
|
681
734
|
const a = [];
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
break;
|
|
687
|
-
}
|
|
688
|
-
if (o && n.type === "Identifier" && n.name === "item") {
|
|
689
|
-
const l = this.collectionStack[this.collectionStack.length - 1], p = a.join(".").replace(/\.\[/g, "[");
|
|
735
|
+
for (; i.type === "MemberExpression"; )
|
|
736
|
+
i.property.type === "Identifier" && !i.computed ? a.unshift(i.property.name) : i.property.type === "Literal" && i.computed ? a.unshift(String(i.property.value)) : a.unshift(this.getExpressionString(i.property)), i = i.object;
|
|
737
|
+
if (i.type === "Identifier" && i.name === r) {
|
|
738
|
+
const c = a.join(".");
|
|
690
739
|
s = {
|
|
691
|
-
...
|
|
692
|
-
collectionId:
|
|
740
|
+
...e,
|
|
741
|
+
collectionId: r,
|
|
693
742
|
variableType: "currentItem",
|
|
694
|
-
path:
|
|
743
|
+
path: c
|
|
695
744
|
};
|
|
696
745
|
}
|
|
697
746
|
}
|
|
@@ -708,8 +757,8 @@ class F {
|
|
|
708
757
|
handleCallExpression(t) {
|
|
709
758
|
var e;
|
|
710
759
|
if (t.callee.type === "Identifier" && t.callee.name === "include") {
|
|
711
|
-
const
|
|
712
|
-
return this.addMessage("info", `Partial includes are not fully supported: ${
|
|
760
|
+
const n = ((e = t.arguments[0]) == null ? void 0 : e.type) === "Literal" ? String(t.arguments[0].value) : "";
|
|
761
|
+
return this.addMessage("info", `Partial includes are not fully supported: ${n}`), "";
|
|
713
762
|
}
|
|
714
763
|
return "";
|
|
715
764
|
}
|
|
@@ -725,20 +774,20 @@ class F {
|
|
|
725
774
|
]
|
|
726
775
|
};
|
|
727
776
|
if (t.type === "MemberExpression") {
|
|
728
|
-
let e = this.getExpressionString(t),
|
|
729
|
-
return e.startsWith("!!") ? (
|
|
777
|
+
let e = this.getExpressionString(t), n = "isTruthy";
|
|
778
|
+
return e.startsWith("!!") ? (n = "isTruthy", e = e.slice(2)) : e.startsWith("!") && (n = "isFalsy", e = e.slice(1)), {
|
|
730
779
|
logicalOperator: "and",
|
|
731
780
|
statements: [
|
|
732
781
|
{
|
|
733
782
|
left: { type: "data-variable", path: e },
|
|
734
|
-
operator:
|
|
783
|
+
operator: n
|
|
735
784
|
}
|
|
736
785
|
]
|
|
737
786
|
};
|
|
738
787
|
}
|
|
739
788
|
if (t.type === "BinaryExpression" || t.type === "LogicalExpression") {
|
|
740
|
-
const e = this.getConditionExpression(t.left),
|
|
741
|
-
return `${e} ${t.operator} ${
|
|
789
|
+
const e = this.getConditionExpression(t.left), n = this.getConditionExpression(t.right);
|
|
790
|
+
return `${e} ${t.operator} ${n}`;
|
|
742
791
|
}
|
|
743
792
|
return t.type === "Literal" ? typeof t.value == "string" ? `'${t.value}'` : String(t.value ?? "") : this.getExpressionString(t);
|
|
744
793
|
}
|
|
@@ -749,16 +798,16 @@ class F {
|
|
|
749
798
|
case "Literal":
|
|
750
799
|
return String(t.value ?? "");
|
|
751
800
|
case "MemberExpression": {
|
|
752
|
-
const e = this.getExpressionString(t.object),
|
|
753
|
-
return t.computed ? `${e}[${
|
|
801
|
+
const e = this.getExpressionString(t.object), n = this.getExpressionString(t.property);
|
|
802
|
+
return t.computed ? `${e}[${n}]` : `${e}.${n}`;
|
|
754
803
|
}
|
|
755
804
|
case "BinaryExpression": {
|
|
756
|
-
const e = this.getExpressionString(t.left),
|
|
757
|
-
return `${e} ${t.operator} ${
|
|
805
|
+
const e = this.getExpressionString(t.left), n = this.getExpressionString(t.right);
|
|
806
|
+
return `${e} ${t.operator} ${n}`;
|
|
758
807
|
}
|
|
759
808
|
case "LogicalExpression": {
|
|
760
|
-
const e = this.getExpressionString(t.left),
|
|
761
|
-
return `${e} ${t.operator} ${
|
|
809
|
+
const e = this.getExpressionString(t.left), n = this.getExpressionString(t.right);
|
|
810
|
+
return `${e} ${t.operator} ${n}`;
|
|
762
811
|
}
|
|
763
812
|
default:
|
|
764
813
|
return this.addMessage("warning", `Unsupported expression type for getExpressionString: ${t.type}`), "";
|
|
@@ -771,21 +820,21 @@ class F {
|
|
|
771
820
|
});
|
|
772
821
|
}
|
|
773
822
|
}
|
|
774
|
-
const
|
|
775
|
-
const e =
|
|
823
|
+
const R = "dataSourceEjs", K = g.startup, z = function(o, t = {}) {
|
|
824
|
+
const e = F(o, new U()), n = H(o, {
|
|
776
825
|
contains: "<%",
|
|
777
|
-
importer: new
|
|
826
|
+
importer: new G()
|
|
778
827
|
});
|
|
779
|
-
|
|
780
|
-
editor:
|
|
828
|
+
B({
|
|
829
|
+
editor: o,
|
|
781
830
|
licenseKey: t.licenseKey,
|
|
782
|
-
plan:
|
|
783
|
-
pluginName:
|
|
831
|
+
plan: K,
|
|
832
|
+
pluginName: R,
|
|
784
833
|
cleanup: () => {
|
|
785
|
-
e(),
|
|
834
|
+
e(), n();
|
|
786
835
|
}
|
|
787
836
|
});
|
|
788
|
-
},
|
|
837
|
+
}, Z = M(z);
|
|
789
838
|
export {
|
|
790
|
-
|
|
839
|
+
Z as default
|
|
791
840
|
};
|