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