@grapesjs/studio-sdk-plugins 1.0.33-rc.1 → 1.0.33
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/accordionComponent/index.cjs.js +7 -7
- package/dist/accordionComponent/index.es.js +161 -156
- package/dist/accordionComponent/index.umd.js +9 -9
- package/dist/aiChat/chatManager.d.ts +15 -0
- package/dist/aiChat/clientTools.d.ts +3 -3
- package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
- package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
- package/dist/aiChat/components/AiChatError.d.ts +2 -1
- package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
- package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
- package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
- package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
- package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
- package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
- package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
- package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
- package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
- package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
- package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
- package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
- package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
- package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
- package/dist/aiChat/components/index.d.ts +24 -25
- package/dist/aiChat/components/utils.d.ts +12 -4
- package/dist/aiChat/index.cjs.d.ts +5 -0
- package/dist/aiChat/index.cjs.js +453 -0
- package/dist/aiChat/index.d.ts +4 -3
- package/dist/aiChat/index.es.d.ts +5 -0
- package/dist/aiChat/index.es.js +30930 -0
- package/dist/aiChat/index.js +453 -0
- package/dist/aiChat/index.umd.js +453 -0
- package/dist/aiChat/locales/en.d.ts +64 -0
- package/dist/aiChat/server/index.cjs.d.ts +4 -0
- package/dist/aiChat/server/index.cjs.js +309 -0
- package/dist/aiChat/server/index.d.ts +0 -50
- package/dist/aiChat/server/index.es.d.ts +4 -0
- package/dist/aiChat/server/index.es.js +876 -0
- package/dist/aiChat/server/index.js +309 -0
- package/dist/aiChat/server/index.umd.js +309 -0
- package/dist/aiChat/server/stream.d.ts +0 -6
- package/dist/aiChat/server/tools.d.ts +157 -51
- package/dist/aiChat/server/types.d.ts +108 -64
- package/dist/aiChat/types.d.ts +148 -108
- package/dist/aiChat/typesSchema.d.ts +238 -25
- package/dist/animationComponent/index.cjs.js +3 -3
- package/dist/animationComponent/index.es.js +174 -169
- package/dist/animationComponent/index.umd.js +3 -3
- package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
- package/dist/canvasAbsoluteMode/index.es.js +161 -156
- package/dist/canvasAbsoluteMode/index.umd.js +1 -1
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +113 -108
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.js +9 -9
- package/dist/canvasFullSize/index.es.js +137 -132
- package/dist/canvasFullSize/index.umd.js +9 -9
- package/dist/canvasGridMode/index.cjs.js +4 -4
- package/dist/canvasGridMode/index.es.js +168 -163
- package/dist/canvasGridMode/index.umd.js +8 -8
- package/dist/canvasScreenshot/index.cjs.js +1 -1
- package/dist/canvasScreenshot/index.es.js +132 -127
- package/dist/canvasScreenshot/index.umd.js +1 -1
- package/dist/dataSourceEjs/index.cjs.js +5 -5
- package/dist/dataSourceEjs/index.es.js +151 -146
- package/dist/dataSourceEjs/index.umd.js +5 -5
- package/dist/dataSourceHandlebars/index.cjs.js +4 -4
- package/dist/dataSourceHandlebars/index.es.js +91 -86
- package/dist/dataSourceHandlebars/index.umd.js +5 -5
- package/dist/dialogComponent/index.cjs.js +16 -16
- package/dist/dialogComponent/index.es.js +117 -112
- package/dist/dialogComponent/index.umd.js +16 -16
- package/dist/flexComponent/index.cjs.js +11 -11
- package/dist/flexComponent/index.es.js +416 -411
- package/dist/flexComponent/index.umd.js +11 -11
- package/dist/fsLightboxComponent/index.cjs.js +3 -3
- package/dist/fsLightboxComponent/index.es.js +152 -147
- package/dist/fsLightboxComponent/index.umd.js +3 -3
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +127 -122
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +170 -165
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +27 -22
- package/dist/index.umd.js +1 -1
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +156 -151
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +197 -192
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/linkImageComponent/index.cjs.js +2 -2
- package/dist/linkImageComponent/index.es.js +86 -81
- package/dist/linkImageComponent/index.umd.js +2 -2
- package/dist/listPagesComponent/index.cjs.js +5 -5
- package/dist/listPagesComponent/index.es.js +121 -116
- package/dist/listPagesComponent/index.umd.js +5 -5
- package/dist/presetPrintable/index.cjs.js +4 -4
- package/dist/presetPrintable/index.es.js +180 -175
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +6 -6
- package/dist/prosemirror/index.es.js +128 -123
- package/dist/prosemirror/index.umd.js +8 -8
- package/dist/rendererReact/index.cjs.js +1 -1
- package/dist/rendererReact/index.es.js +127 -122
- package/dist/rendererReact/index.js +1 -1
- package/dist/rendererReact/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +160 -155
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/shapeDividerComponent/index.cjs.js +25 -25
- package/dist/shapeDividerComponent/index.es.js +127 -122
- package/dist/shapeDividerComponent/index.umd.js +25 -25
- package/dist/swiperComponent/index.cjs.js +9 -9
- package/dist/swiperComponent/index.es.js +197 -192
- package/dist/swiperComponent/index.umd.js +9 -9
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +227 -222
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils.d.ts +12 -1
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +124 -119
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +5 -2
- package/dist/aiChat/components/AiChatInput.d.ts +0 -17
- package/dist/aiChat/server/stream-utils.d.ts +0 -16
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const $ = "app.grapesjs.com", b = "app-stage.grapesjs.com",
|
|
1
|
+
const $ = "app.grapesjs.com", b = "app-stage.grapesjs.com", w = "app2.grapesjs.com", P = "app-stage2.grapesjs.com", S = [
|
|
2
2
|
$,
|
|
3
|
-
I,
|
|
4
|
-
b,
|
|
5
3
|
w,
|
|
4
|
+
b,
|
|
5
|
+
P,
|
|
6
6
|
"localhost",
|
|
7
7
|
"127.0.0.1",
|
|
8
8
|
".local-credentialless.webcontainer.io",
|
|
@@ -11,11 +11,15 @@ const $ = "app.grapesjs.com", b = "app-stage.grapesjs.com", I = "app2.grapesjs.c
|
|
|
11
11
|
// For stackblitz.com demos
|
|
12
12
|
"-sandpack.codesandbox.io"
|
|
13
13
|
// For Sandpack demos
|
|
14
|
-
],
|
|
15
|
-
|
|
14
|
+
], O = "license:check:start", N = "license:check:end", v = () => typeof window < "u", T = ({
|
|
15
|
+
isDev: o,
|
|
16
|
+
isStage: t,
|
|
17
|
+
isPlatform: e
|
|
18
|
+
}) => `${o ? "" : `https://${t ? b : $}`}/${e ? "platform-api" : "api"}`, k = () => {
|
|
19
|
+
const o = v() && window.location.hostname;
|
|
16
20
|
return !!o && (S.includes(o) || S.some((t) => o.endsWith(t)));
|
|
17
21
|
};
|
|
18
|
-
async function
|
|
22
|
+
async function L({
|
|
19
23
|
path: o,
|
|
20
24
|
baseApiUrl: t,
|
|
21
25
|
method: e = "GET",
|
|
@@ -23,7 +27,7 @@ async function N({
|
|
|
23
27
|
params: n,
|
|
24
28
|
body: r
|
|
25
29
|
}) {
|
|
26
|
-
const
|
|
30
|
+
const i = `${t || T({ isDev: !1, isStage: !1 })}${o}`, c = {
|
|
27
31
|
method: e,
|
|
28
32
|
headers: {
|
|
29
33
|
"Content-Type": "application/json",
|
|
@@ -31,62 +35,63 @@ async function N({
|
|
|
31
35
|
}
|
|
32
36
|
};
|
|
33
37
|
r && (c.body = JSON.stringify(r));
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
36
|
-
throw new Error(`HTTP error! status: ${
|
|
37
|
-
return
|
|
38
|
+
const l = n ? new URLSearchParams(n).toString() : "", u = l ? `?${l}` : "", p = await fetch(`${i}${u}`, c);
|
|
39
|
+
if (!p.ok)
|
|
40
|
+
throw new Error(`HTTP error! status: ${p.status}`);
|
|
41
|
+
return p.json();
|
|
38
42
|
}
|
|
39
|
-
var
|
|
43
|
+
var m = /* @__PURE__ */ ((o) => (o.free = "free", o.startup = "startup", o.business = "business", o.enterprise = "enterprise", o))(m || {});
|
|
40
44
|
const x = {
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
[
|
|
45
|
+
[m.free]: 0,
|
|
46
|
+
[m.startup]: 10,
|
|
47
|
+
[m.business]: 20,
|
|
48
|
+
[m.enterprise]: 30
|
|
45
49
|
};
|
|
46
|
-
function
|
|
50
|
+
function C(o) {
|
|
47
51
|
const t = o;
|
|
48
52
|
return t.init = (e) => (s) => o(s, e), t;
|
|
49
53
|
}
|
|
50
|
-
const
|
|
51
|
-
async function
|
|
54
|
+
const B = (o) => /* @__PURE__ */ C(o);
|
|
55
|
+
async function A({
|
|
52
56
|
editor: o,
|
|
53
57
|
plan: t,
|
|
54
58
|
pluginName: e,
|
|
55
59
|
licenseKey: s,
|
|
56
|
-
|
|
60
|
+
onLicenseCheckResponse: n,
|
|
61
|
+
cleanup: r
|
|
57
62
|
}) {
|
|
58
|
-
let
|
|
59
|
-
const
|
|
60
|
-
console.warn("Cleanup plugin:", e, "Reason:",
|
|
61
|
-
},
|
|
62
|
-
var
|
|
63
|
-
const { error: h, sdkLicense:
|
|
64
|
-
if (!(
|
|
65
|
-
|
|
66
|
-
else if (
|
|
67
|
-
const
|
|
68
|
-
|
|
63
|
+
let a = "", i = !1;
|
|
64
|
+
const c = k(), l = (p) => {
|
|
65
|
+
console.warn("Cleanup plugin:", e, "Reason:", p), r();
|
|
66
|
+
}, u = (p = {}) => {
|
|
67
|
+
var g;
|
|
68
|
+
const { error: h, sdkLicense: y } = p, d = (g = p.plan) == null ? void 0 : g.category;
|
|
69
|
+
if (!(y || p.license) || h)
|
|
70
|
+
l(h || "Invalid license");
|
|
71
|
+
else if (d) {
|
|
72
|
+
const E = x[t], I = x[d];
|
|
73
|
+
E > I && l({ pluginRequiredPlan: t, licensePlan: d });
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
|
-
o.on(
|
|
72
|
-
|
|
73
|
-
}), o.on(
|
|
74
|
-
p(
|
|
76
|
+
o.on(O, (p) => {
|
|
77
|
+
a = p == null ? void 0 : p.baseApiUrl, i = !0;
|
|
78
|
+
}), o.on(N, (p) => {
|
|
79
|
+
n == null || n(p), u(p);
|
|
75
80
|
}), setTimeout(async () => {
|
|
76
81
|
if (!i) {
|
|
77
|
-
if (
|
|
82
|
+
if (c) return;
|
|
78
83
|
if (s) {
|
|
79
|
-
const
|
|
80
|
-
|
|
84
|
+
const p = await M({ licenseKey: s, pluginName: e, baseApiUrl: a });
|
|
85
|
+
n == null || n(p), p && u(p);
|
|
81
86
|
} else
|
|
82
|
-
|
|
87
|
+
l("The `licenseKey` option not provided");
|
|
83
88
|
}
|
|
84
89
|
}, 2e3);
|
|
85
90
|
}
|
|
86
|
-
async function
|
|
91
|
+
async function M(o) {
|
|
87
92
|
const { licenseKey: t, pluginName: e, baseApiUrl: s } = o;
|
|
88
93
|
try {
|
|
89
|
-
return (await
|
|
94
|
+
return (await L({
|
|
90
95
|
baseApiUrl: s,
|
|
91
96
|
path: `/sdk/${t || "na"}`,
|
|
92
97
|
method: "POST",
|
|
@@ -99,39 +104,39 @@ async function A(o) {
|
|
|
99
104
|
return console.error("Error during SDK license check:", n), !1;
|
|
100
105
|
}
|
|
101
106
|
}
|
|
102
|
-
const
|
|
107
|
+
const j = (o) => {
|
|
103
108
|
const t = o;
|
|
104
109
|
return t.logicalOperator === "and" || t.logicalOperator === "or";
|
|
105
|
-
},
|
|
110
|
+
}, W = (o, t) => (o.config.optsHtml = {
|
|
106
111
|
...o.config.optsHtml,
|
|
107
112
|
exporter: t
|
|
108
113
|
}, () => {
|
|
109
114
|
o.config.optsHtml.exporter = void 0;
|
|
110
|
-
}),
|
|
115
|
+
}), _ = (o, t) => {
|
|
111
116
|
const e = (n) => {
|
|
112
|
-
const { input: r } = n, { contains:
|
|
113
|
-
(!
|
|
117
|
+
const { input: r } = n, { contains: a } = t;
|
|
118
|
+
(!a || r.includes(a)) && (n.input = t.importer.import(r));
|
|
114
119
|
}, s = o.Parser.events.htmlBefore;
|
|
115
120
|
return o.on(s, e), () => {
|
|
116
121
|
o.off(s, e);
|
|
117
122
|
};
|
|
118
123
|
};
|
|
119
|
-
class
|
|
124
|
+
class J {
|
|
120
125
|
getVariableSyntax({ dataResolver: t }) {
|
|
121
126
|
const { defaultValue: e } = t, s = this.getFullPath(t), n = e ? ` || \`${e}\`` : "";
|
|
122
127
|
return `<%= ${s}${n} %>`;
|
|
123
128
|
}
|
|
124
129
|
getCollectionStartSyntax({ dataResolver: t }) {
|
|
125
|
-
const { collectionId: e, dataSource: s, startIndex: n, endIndex: r } = t,
|
|
130
|
+
const { collectionId: e, dataSource: s, startIndex: n, endIndex: r } = t, a = (s == null ? void 0 : s.path) || e || "", i = this._sanitizeVariableName(e);
|
|
126
131
|
let c = "";
|
|
127
132
|
if (n !== void 0 || r !== void 0) {
|
|
128
|
-
const
|
|
129
|
-
c = `.slice(${
|
|
133
|
+
const l = n ?? 0, u = r !== void 0 ? r : "";
|
|
134
|
+
c = `.slice(${l}${u !== "" ? `, ${u}` : ""})`;
|
|
130
135
|
}
|
|
131
|
-
return `<% ${
|
|
136
|
+
return `<% ${a}${c}.forEach(function(currentItem, index, arr) {
|
|
132
137
|
const startIndex = parseInt(${n ?? 0}, 10);
|
|
133
138
|
const endIndex = startIndex + arr.length;
|
|
134
|
-
const ${
|
|
139
|
+
const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`;
|
|
135
140
|
}
|
|
136
141
|
_sanitizeVariableName(t) {
|
|
137
142
|
return t.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
@@ -153,8 +158,8 @@ const ${a}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
|
|
|
153
158
|
}
|
|
154
159
|
_parseCondition(t) {
|
|
155
160
|
if (!t) return "";
|
|
156
|
-
if (
|
|
157
|
-
const e = t.statements.map((r) => this._parseCondition(r)), s =
|
|
161
|
+
if (j(t)) {
|
|
162
|
+
const e = t.statements.map((r) => this._parseCondition(r)), s = F[t.logicalOperator];
|
|
158
163
|
let n = e.length > 1 ? `(${e.join(`)${s}(`)})` : e[0];
|
|
159
164
|
return t.logicalOperator === "xor" && (n = `!!(${n})`), n;
|
|
160
165
|
} else {
|
|
@@ -208,11 +213,11 @@ const ${a}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
|
|
|
208
213
|
return typeof t == "object" ? this.getFullPath(t) : typeof t == "string" ? `'${t.replace(/'/g, "\\'")}'` : String(t);
|
|
209
214
|
}
|
|
210
215
|
}
|
|
211
|
-
const
|
|
216
|
+
const F = {
|
|
212
217
|
and: "&&",
|
|
213
218
|
or: "||",
|
|
214
219
|
xor: "^"
|
|
215
|
-
},
|
|
220
|
+
}, U = ["===", "==", "!==", "!=", "<=", ">=", "<", ">", "&&", "||"], D = {
|
|
216
221
|
"===": "=",
|
|
217
222
|
"==": "=",
|
|
218
223
|
"!==": "!=",
|
|
@@ -224,7 +229,7 @@ const J = {
|
|
|
224
229
|
"&&": "&&",
|
|
225
230
|
"||": "||"
|
|
226
231
|
};
|
|
227
|
-
class
|
|
232
|
+
class V {
|
|
228
233
|
constructor() {
|
|
229
234
|
this.messages = [], this.collectionStack = [];
|
|
230
235
|
}
|
|
@@ -250,26 +255,26 @@ class D {
|
|
|
250
255
|
const r = t.indexOf("%>", n);
|
|
251
256
|
if (r === -1)
|
|
252
257
|
throw new Error("Unclosed EJS tag");
|
|
253
|
-
const
|
|
254
|
-
if (s = r + 2,
|
|
255
|
-
const
|
|
256
|
-
e.push(this.createAppendExpression(
|
|
258
|
+
const a = t.slice(n + 2, r).trim();
|
|
259
|
+
if (s = r + 2, a.startsWith("=") || a.startsWith("-")) {
|
|
260
|
+
const i = a.slice(1).trim();
|
|
261
|
+
e.push(this.createAppendExpression(i));
|
|
257
262
|
} else {
|
|
258
|
-
if (
|
|
263
|
+
if (a.startsWith("#"))
|
|
259
264
|
continue;
|
|
260
|
-
if (
|
|
261
|
-
const
|
|
262
|
-
e.push(
|
|
263
|
-
} else if (
|
|
264
|
-
const
|
|
265
|
-
e.push(
|
|
265
|
+
if (a.startsWith("if")) {
|
|
266
|
+
const i = this.parseIfStatement(a, t, s);
|
|
267
|
+
e.push(i), s = i.endPos || s;
|
|
268
|
+
} else if (a.startsWith("for")) {
|
|
269
|
+
const i = this.parseForStatement(a, t, s);
|
|
270
|
+
e.push(i), s = i.endPos || s;
|
|
266
271
|
} else {
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
const c =
|
|
270
|
-
e.push(
|
|
272
|
+
const i = a.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
|
|
273
|
+
if (i) {
|
|
274
|
+
const c = i[1], l = i[2], u = this.parseForEachStatement(c, l, t, s);
|
|
275
|
+
e.push(u), s = u.endPos || s;
|
|
271
276
|
} else
|
|
272
|
-
this.addMessage("info", `Unsupported scriptlet content: ${
|
|
277
|
+
this.addMessage("info", `Unsupported scriptlet content: ${a}`);
|
|
273
278
|
}
|
|
274
279
|
}
|
|
275
280
|
}
|
|
@@ -302,32 +307,32 @@ class D {
|
|
|
302
307
|
const n = t.match(/if\s*\((.*)\)\s*\{?/);
|
|
303
308
|
if (!n)
|
|
304
309
|
throw new Error("Invalid if statement syntax");
|
|
305
|
-
const r = this.parseJsExpression(n[1]), { body:
|
|
306
|
-
let c = null,
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
309
|
-
const
|
|
310
|
-
if (
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
313
|
-
|
|
314
|
-
const
|
|
310
|
+
const r = this.parseJsExpression(n[1]), { body: a, endPos: i } = this.parseTemplateBlock(e, s);
|
|
311
|
+
let c = null, l = i;
|
|
312
|
+
const u = e.indexOf("<%", l);
|
|
313
|
+
if (u === l) {
|
|
314
|
+
const p = e.indexOf("%>", u);
|
|
315
|
+
if (p !== -1) {
|
|
316
|
+
const h = e.slice(u + 2, p).trim(), y = p + 2 - u;
|
|
317
|
+
if (h.startsWith("} else if")) {
|
|
318
|
+
l = u + y;
|
|
319
|
+
const d = h.substring(h.indexOf("if")).trim(), f = this.parseIfStatement(d, e, l);
|
|
315
320
|
c = {
|
|
316
321
|
type: "IfStatement",
|
|
317
|
-
test:
|
|
318
|
-
consequent:
|
|
319
|
-
alternate:
|
|
320
|
-
},
|
|
321
|
-
} else if (
|
|
322
|
-
|
|
323
|
-
const { body:
|
|
322
|
+
test: f.test,
|
|
323
|
+
consequent: f.consequent,
|
|
324
|
+
alternate: f.alternate
|
|
325
|
+
}, l = f.endPos;
|
|
326
|
+
} else if (h.startsWith("} else")) {
|
|
327
|
+
l = u + y;
|
|
328
|
+
const { body: d, endPos: f } = this.parseTemplateBlock(e, l);
|
|
324
329
|
c = {
|
|
325
330
|
type: "BlockStatement",
|
|
326
|
-
body:
|
|
327
|
-
},
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
} else
|
|
331
|
+
body: d
|
|
332
|
+
}, l = f;
|
|
333
|
+
const g = e.indexOf("<%", l), E = e.indexOf("%>", g);
|
|
334
|
+
g === l && e.slice(g + 2, E).trim() === "}" && (l = E + 2);
|
|
335
|
+
} else h === "}" && (l = u + y);
|
|
331
336
|
}
|
|
332
337
|
}
|
|
333
338
|
return {
|
|
@@ -335,10 +340,10 @@ class D {
|
|
|
335
340
|
test: r,
|
|
336
341
|
consequent: {
|
|
337
342
|
type: "BlockStatement",
|
|
338
|
-
body:
|
|
343
|
+
body: a
|
|
339
344
|
},
|
|
340
345
|
alternate: c,
|
|
341
|
-
endPos:
|
|
346
|
+
endPos: l
|
|
342
347
|
};
|
|
343
348
|
}
|
|
344
349
|
parseForStatement(t, e, s) {
|
|
@@ -348,7 +353,7 @@ class D {
|
|
|
348
353
|
const r = n[1].split("of");
|
|
349
354
|
if (r.length !== 2)
|
|
350
355
|
throw new Error("Only for...of loops are supported");
|
|
351
|
-
const
|
|
356
|
+
const a = r[0].trim().replace(/^let\s+|^const\s+|^var\s+/, ""), i = r[1].trim(), { body: c, endPos: l } = this.parseTemplateBlock(e, s);
|
|
352
357
|
return {
|
|
353
358
|
type: "ForStatement",
|
|
354
359
|
init: {
|
|
@@ -357,8 +362,8 @@ class D {
|
|
|
357
362
|
declarations: [
|
|
358
363
|
{
|
|
359
364
|
type: "VariableDeclarator",
|
|
360
|
-
id: { type: "Identifier", name:
|
|
361
|
-
init: this.parseJsExpression(
|
|
365
|
+
id: { type: "Identifier", name: a },
|
|
366
|
+
init: this.parseJsExpression(i)
|
|
362
367
|
}
|
|
363
368
|
]
|
|
364
369
|
},
|
|
@@ -370,13 +375,13 @@ class D {
|
|
|
370
375
|
},
|
|
371
376
|
// Consume the closing '}' tag for the for loop
|
|
372
377
|
endPos: (() => {
|
|
373
|
-
const
|
|
374
|
-
return
|
|
378
|
+
const u = e.indexOf("<%", l), p = e.indexOf("%>", u);
|
|
379
|
+
return u === l && e.slice(u + 2, p).trim() === "}" ? p + 2 : l;
|
|
375
380
|
})()
|
|
376
381
|
};
|
|
377
382
|
}
|
|
378
383
|
parseForEachStatement(t, e, s, n) {
|
|
379
|
-
const { body: r, endPos:
|
|
384
|
+
const { body: r, endPos: a } = this.parseTemplateBlock(s, n);
|
|
380
385
|
return {
|
|
381
386
|
type: "ForEachStatement",
|
|
382
387
|
collection: this.parseJsExpression(t),
|
|
@@ -386,8 +391,8 @@ class D {
|
|
|
386
391
|
body: r
|
|
387
392
|
},
|
|
388
393
|
endPos: (() => {
|
|
389
|
-
const
|
|
390
|
-
return
|
|
394
|
+
const i = s.indexOf("<%", a), c = s.indexOf("%>", i);
|
|
395
|
+
return i === a && s.slice(i + 2, c).trim() === "}" ? c + 2 : a;
|
|
391
396
|
})()
|
|
392
397
|
};
|
|
393
398
|
}
|
|
@@ -401,33 +406,33 @@ class D {
|
|
|
401
406
|
break;
|
|
402
407
|
}
|
|
403
408
|
r > n && s.push(this.createAppendLiteral(t.slice(n, r)));
|
|
404
|
-
const
|
|
405
|
-
if (
|
|
409
|
+
const a = t.indexOf("%>", r);
|
|
410
|
+
if (a === -1)
|
|
406
411
|
throw new Error("Unclosed EJS tag within block");
|
|
407
|
-
const
|
|
408
|
-
if (
|
|
412
|
+
const i = t.slice(r + 2, a).trim();
|
|
413
|
+
if (i === "}" || i.startsWith("} else")) {
|
|
409
414
|
n = r;
|
|
410
415
|
break;
|
|
411
416
|
}
|
|
412
|
-
if (n =
|
|
413
|
-
const c =
|
|
417
|
+
if (n = a + 2, i.startsWith("=") || i.startsWith("-")) {
|
|
418
|
+
const c = i.slice(1).trim();
|
|
414
419
|
s.push(this.createAppendExpression(c));
|
|
415
420
|
} else {
|
|
416
|
-
if (
|
|
421
|
+
if (i.startsWith("#"))
|
|
417
422
|
continue;
|
|
418
|
-
if (
|
|
419
|
-
const c = this.parseIfStatement(
|
|
423
|
+
if (i.startsWith("if")) {
|
|
424
|
+
const c = this.parseIfStatement(i, t, n);
|
|
420
425
|
s.push(c), n = c.endPos || n;
|
|
421
|
-
} else if (
|
|
422
|
-
const c = this.parseForStatement(
|
|
426
|
+
} else if (i.startsWith("for")) {
|
|
427
|
+
const c = this.parseForStatement(i, t, n);
|
|
423
428
|
s.push(c), n = c.endPos || n;
|
|
424
429
|
} else {
|
|
425
|
-
const c =
|
|
430
|
+
const c = i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
|
|
426
431
|
if (c) {
|
|
427
|
-
const
|
|
428
|
-
s.push(
|
|
432
|
+
const l = c[1], u = c[2], p = this.parseForEachStatement(l, u, t, n);
|
|
433
|
+
s.push(p), n = p.endPos || n;
|
|
429
434
|
} else
|
|
430
|
-
this.addMessage("info", `Unsupported scriptlet content within block: ${
|
|
435
|
+
this.addMessage("info", `Unsupported scriptlet content within block: ${i}`);
|
|
431
436
|
}
|
|
432
437
|
}
|
|
433
438
|
}
|
|
@@ -454,12 +459,12 @@ class D {
|
|
|
454
459
|
type: "Literal",
|
|
455
460
|
value: t === "true"
|
|
456
461
|
};
|
|
457
|
-
for (const n of
|
|
462
|
+
for (const n of U) {
|
|
458
463
|
const r = t.lastIndexOf(n);
|
|
459
464
|
if (r > 0 && t[r - 1] !== "!" && t[r - 1] !== "=" && t[r - 1] !== "<" && t[r - 1] !== ">")
|
|
460
465
|
return {
|
|
461
466
|
type: n === "&&" || n === "||" ? "LogicalExpression" : "BinaryExpression",
|
|
462
|
-
operator:
|
|
467
|
+
operator: D[n],
|
|
463
468
|
left: this.parseJsExpression(t.slice(0, r).trim()),
|
|
464
469
|
right: this.parseJsExpression(t.slice(r + n.length).trim())
|
|
465
470
|
};
|
|
@@ -467,22 +472,22 @@ class D {
|
|
|
467
472
|
const e = t.indexOf("."), s = t.indexOf("[");
|
|
468
473
|
if (e > 0 && (s === -1 || e < s) || s > 0 && (e === -1 || s < e)) {
|
|
469
474
|
const n = e > 0 && (s === -1 || e < s) ? e : s;
|
|
470
|
-
let r,
|
|
475
|
+
let r, a, i = !1;
|
|
471
476
|
if (n === e)
|
|
472
|
-
r = t.slice(0, e),
|
|
477
|
+
r = t.slice(0, e), a = { type: "Identifier", name: t.slice(e + 1) }, i = !1;
|
|
473
478
|
else {
|
|
474
479
|
r = t.slice(0, s);
|
|
475
480
|
const c = t.indexOf("]", s);
|
|
476
481
|
if (c === -1)
|
|
477
482
|
throw new Error("Unclosed bracket in expression");
|
|
478
|
-
const
|
|
479
|
-
|
|
483
|
+
const l = t.slice(s + 1, c);
|
|
484
|
+
a = /^(['"]).*\1$/.test(l) || /^-?\d+(\.\d+)?$/.test(l) ? this.parseJsExpression(l) : { type: "Identifier", name: l }, i = !0;
|
|
480
485
|
}
|
|
481
486
|
return {
|
|
482
487
|
type: "MemberExpression",
|
|
483
488
|
object: this.parseJsExpression(r),
|
|
484
|
-
property:
|
|
485
|
-
computed:
|
|
489
|
+
property: a,
|
|
490
|
+
computed: i
|
|
486
491
|
};
|
|
487
492
|
}
|
|
488
493
|
return {
|
|
@@ -545,8 +550,8 @@ class D {
|
|
|
545
550
|
`;
|
|
546
551
|
}
|
|
547
552
|
handleForStatement(t) {
|
|
548
|
-
var
|
|
549
|
-
if (((
|
|
553
|
+
var i;
|
|
554
|
+
if (((i = t.init) == null ? void 0 : i.type) !== "VariableDeclaration" || t.init.declarations.length === 0)
|
|
550
555
|
return this.addMessage("warning", "Unsupported for loop init format"), "";
|
|
551
556
|
const e = t.init.declarations[0];
|
|
552
557
|
if (e.id.type !== "Identifier")
|
|
@@ -558,14 +563,14 @@ class D {
|
|
|
558
563
|
return this.addMessage("warning", "For loop collection is undefined"), "";
|
|
559
564
|
const n = e.id.name, r = n;
|
|
560
565
|
this.collectionStack.push(n);
|
|
561
|
-
const
|
|
566
|
+
const a = this.astToGrapesJS(t.body);
|
|
562
567
|
return this.collectionStack.pop(), `
|
|
563
568
|
<data-collection data-gjs-data-resolver='${JSON.stringify({
|
|
564
569
|
dataSource: { type: "data-variable", path: s },
|
|
565
570
|
collectionId: r
|
|
566
571
|
})}'>
|
|
567
572
|
<data-collection-item>
|
|
568
|
-
${
|
|
573
|
+
${a}
|
|
569
574
|
</data-collection-item>
|
|
570
575
|
</data-collection>
|
|
571
576
|
`;
|
|
@@ -609,12 +614,12 @@ class D {
|
|
|
609
614
|
let n = { path: this.getExpressionString(t), ...e };
|
|
610
615
|
if (this.collectionStack.length > 0) {
|
|
611
616
|
const r = this.collectionStack[this.collectionStack.length - 1];
|
|
612
|
-
let
|
|
613
|
-
const
|
|
614
|
-
for (;
|
|
615
|
-
|
|
616
|
-
if (
|
|
617
|
-
const c =
|
|
617
|
+
let a = t;
|
|
618
|
+
const i = [];
|
|
619
|
+
for (; a.type === "MemberExpression"; )
|
|
620
|
+
a.property.type === "Identifier" && !a.computed ? i.unshift(a.property.name) : a.property.type === "Literal" && a.computed ? i.unshift(String(a.property.value)) : i.unshift(this.getExpressionString(a.property)), a = a.object;
|
|
621
|
+
if (a.type === "Identifier" && a.name === r) {
|
|
622
|
+
const c = i.join(".");
|
|
618
623
|
n = {
|
|
619
624
|
...e,
|
|
620
625
|
collectionId: r,
|
|
@@ -699,21 +704,21 @@ class D {
|
|
|
699
704
|
});
|
|
700
705
|
}
|
|
701
706
|
}
|
|
702
|
-
const
|
|
703
|
-
const e =
|
|
707
|
+
const G = "dataSourceEjs", q = m.startup, H = function(o, t = {}) {
|
|
708
|
+
const e = W(o, new J()), s = _(o, {
|
|
704
709
|
contains: "<%",
|
|
705
|
-
importer: new
|
|
710
|
+
importer: new V()
|
|
706
711
|
});
|
|
707
|
-
|
|
712
|
+
A({
|
|
708
713
|
editor: o,
|
|
709
714
|
licenseKey: t.licenseKey,
|
|
710
|
-
plan:
|
|
711
|
-
pluginName:
|
|
715
|
+
plan: q,
|
|
716
|
+
pluginName: G,
|
|
712
717
|
cleanup: () => {
|
|
713
718
|
e(), s();
|
|
714
719
|
}
|
|
715
720
|
});
|
|
716
|
-
},
|
|
721
|
+
}, K = B(H);
|
|
717
722
|
export {
|
|
718
|
-
|
|
723
|
+
K as default
|
|
719
724
|
};
|