@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.
Files changed (130) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +161 -156
  3. package/dist/accordionComponent/index.umd.js +9 -9
  4. package/dist/aiChat/chatManager.d.ts +15 -0
  5. package/dist/aiChat/clientTools.d.ts +3 -3
  6. package/dist/aiChat/clientToolsProcessors.d.ts +14 -1
  7. package/dist/aiChat/components/AiChatEmptyState.d.ts +4 -6
  8. package/dist/aiChat/components/AiChatError.d.ts +2 -1
  9. package/dist/aiChat/components/AiChatHeader.d.ts +2 -1
  10. package/dist/aiChat/components/AiChatInput/AssetsSection.d.ts +7 -0
  11. package/dist/aiChat/components/AiChatInput/AttachButton.d.ts +10 -0
  12. package/dist/aiChat/components/AiChatInput/ContextSection.d.ts +5 -0
  13. package/dist/aiChat/components/AiChatInput/DictateButton.d.ts +7 -0
  14. package/dist/aiChat/components/AiChatInput/TextAreaWithAutoResize.d.ts +6 -0
  15. package/dist/aiChat/components/AiChatInput/constants.d.ts +6 -0
  16. package/dist/aiChat/components/AiChatInput/hooks/useSpeechToText.d.ts +15 -0
  17. package/dist/aiChat/components/AiChatInput/index.d.ts +37 -0
  18. package/dist/aiChat/components/AiChatLoadingState.d.ts +2 -1
  19. package/dist/aiChat/components/AiChatMessage.d.ts +21 -9
  20. package/dist/aiChat/components/AiChatMessages.d.ts +5 -7
  21. package/dist/aiChat/components/AiChatMessagesStatus.d.ts +5 -0
  22. package/dist/aiChat/components/AiChatPanel.d.ts +2 -3
  23. package/dist/aiChat/components/AiChatProvider.d.ts +14 -0
  24. package/dist/aiChat/components/MemoizedMarkdown.d.ts +9 -0
  25. package/dist/aiChat/components/index.d.ts +24 -25
  26. package/dist/aiChat/components/utils.d.ts +12 -4
  27. package/dist/aiChat/index.cjs.d.ts +5 -0
  28. package/dist/aiChat/index.cjs.js +453 -0
  29. package/dist/aiChat/index.d.ts +4 -3
  30. package/dist/aiChat/index.es.d.ts +5 -0
  31. package/dist/aiChat/index.es.js +30930 -0
  32. package/dist/aiChat/index.js +453 -0
  33. package/dist/aiChat/index.umd.js +453 -0
  34. package/dist/aiChat/locales/en.d.ts +64 -0
  35. package/dist/aiChat/server/index.cjs.d.ts +4 -0
  36. package/dist/aiChat/server/index.cjs.js +309 -0
  37. package/dist/aiChat/server/index.d.ts +0 -50
  38. package/dist/aiChat/server/index.es.d.ts +4 -0
  39. package/dist/aiChat/server/index.es.js +876 -0
  40. package/dist/aiChat/server/index.js +309 -0
  41. package/dist/aiChat/server/index.umd.js +309 -0
  42. package/dist/aiChat/server/stream.d.ts +0 -6
  43. package/dist/aiChat/server/tools.d.ts +157 -51
  44. package/dist/aiChat/server/types.d.ts +108 -64
  45. package/dist/aiChat/types.d.ts +148 -108
  46. package/dist/aiChat/typesSchema.d.ts +238 -25
  47. package/dist/animationComponent/index.cjs.js +3 -3
  48. package/dist/animationComponent/index.es.js +174 -169
  49. package/dist/animationComponent/index.umd.js +3 -3
  50. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  51. package/dist/canvasAbsoluteMode/index.es.js +161 -156
  52. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  53. package/dist/canvasEmptyState/index.cjs.js +1 -1
  54. package/dist/canvasEmptyState/index.es.js +113 -108
  55. package/dist/canvasEmptyState/index.umd.js +1 -1
  56. package/dist/canvasFullSize/index.cjs.js +9 -9
  57. package/dist/canvasFullSize/index.es.js +137 -132
  58. package/dist/canvasFullSize/index.umd.js +9 -9
  59. package/dist/canvasGridMode/index.cjs.js +4 -4
  60. package/dist/canvasGridMode/index.es.js +168 -163
  61. package/dist/canvasGridMode/index.umd.js +8 -8
  62. package/dist/canvasScreenshot/index.cjs.js +1 -1
  63. package/dist/canvasScreenshot/index.es.js +132 -127
  64. package/dist/canvasScreenshot/index.umd.js +1 -1
  65. package/dist/dataSourceEjs/index.cjs.js +5 -5
  66. package/dist/dataSourceEjs/index.es.js +151 -146
  67. package/dist/dataSourceEjs/index.umd.js +5 -5
  68. package/dist/dataSourceHandlebars/index.cjs.js +4 -4
  69. package/dist/dataSourceHandlebars/index.es.js +91 -86
  70. package/dist/dataSourceHandlebars/index.umd.js +5 -5
  71. package/dist/dialogComponent/index.cjs.js +16 -16
  72. package/dist/dialogComponent/index.es.js +117 -112
  73. package/dist/dialogComponent/index.umd.js +16 -16
  74. package/dist/flexComponent/index.cjs.js +11 -11
  75. package/dist/flexComponent/index.es.js +416 -411
  76. package/dist/flexComponent/index.umd.js +11 -11
  77. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  78. package/dist/fsLightboxComponent/index.es.js +152 -147
  79. package/dist/fsLightboxComponent/index.umd.js +3 -3
  80. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  81. package/dist/googleFontsAssetProvider/index.es.js +127 -122
  82. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  83. package/dist/iconifyComponent/index.cjs.js +2 -2
  84. package/dist/iconifyComponent/index.es.js +170 -165
  85. package/dist/iconifyComponent/index.umd.js +2 -2
  86. package/dist/index.cjs.js +1 -1
  87. package/dist/index.es.js +27 -22
  88. package/dist/index.umd.js +1 -1
  89. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  90. package/dist/layoutSidebarButtons/index.es.js +156 -151
  91. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  92. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  93. package/dist/lightGalleryComponent/index.es.js +197 -192
  94. package/dist/lightGalleryComponent/index.umd.js +1 -1
  95. package/dist/linkImageComponent/index.cjs.js +2 -2
  96. package/dist/linkImageComponent/index.es.js +86 -81
  97. package/dist/linkImageComponent/index.umd.js +2 -2
  98. package/dist/listPagesComponent/index.cjs.js +5 -5
  99. package/dist/listPagesComponent/index.es.js +121 -116
  100. package/dist/listPagesComponent/index.umd.js +5 -5
  101. package/dist/presetPrintable/index.cjs.js +4 -4
  102. package/dist/presetPrintable/index.es.js +180 -175
  103. package/dist/presetPrintable/index.umd.js +4 -4
  104. package/dist/prosemirror/index.cjs.js +6 -6
  105. package/dist/prosemirror/index.es.js +128 -123
  106. package/dist/prosemirror/index.umd.js +8 -8
  107. package/dist/rendererReact/index.cjs.js +1 -1
  108. package/dist/rendererReact/index.es.js +127 -122
  109. package/dist/rendererReact/index.js +1 -1
  110. package/dist/rendererReact/index.umd.js +1 -1
  111. package/dist/rteTinyMce/index.cjs.js +2 -2
  112. package/dist/rteTinyMce/index.es.js +160 -155
  113. package/dist/rteTinyMce/index.umd.js +2 -2
  114. package/dist/shapeDividerComponent/index.cjs.js +25 -25
  115. package/dist/shapeDividerComponent/index.es.js +127 -122
  116. package/dist/shapeDividerComponent/index.umd.js +25 -25
  117. package/dist/swiperComponent/index.cjs.js +9 -9
  118. package/dist/swiperComponent/index.es.js +197 -192
  119. package/dist/swiperComponent/index.umd.js +9 -9
  120. package/dist/tableComponent/index.cjs.js +1 -1
  121. package/dist/tableComponent/index.es.js +227 -222
  122. package/dist/tableComponent/index.umd.js +1 -1
  123. package/dist/types.d.ts +1 -1
  124. package/dist/utils.d.ts +12 -1
  125. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  126. package/dist/youtubeAssetProvider/index.es.js +124 -119
  127. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  128. package/package.json +5 -2
  129. package/dist/aiChat/components/AiChatInput.d.ts +0 -17
  130. package/dist/aiChat/server/stream-utils.d.ts +0 -16
@@ -1,8 +1,8 @@
1
- const $ = "app.grapesjs.com", b = "app-stage.grapesjs.com", I = "app2.grapesjs.com", w = "app-stage2.grapesjs.com", S = [
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
- ], P = "license:check:start", O = "license:check:end", k = () => typeof window < "u", L = ({ isDev: o, isStage: t }) => `${o ? "" : `https://${t ? b : $}`}/api`, C = () => {
15
- const o = k() && window.location.hostname;
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 N({
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 a = `${t || L({ isDev: !1, isStage: !1 })}${o}`, c = {
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 p = n ? new URLSearchParams(n).toString() : "", l = p ? `?${p}` : "", h = await fetch(`${a}${l}`, c);
35
- if (!h.ok)
36
- throw new Error(`HTTP error! status: ${h.status}`);
37
- return h.json();
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 g = /* @__PURE__ */ ((o) => (o.free = "free", o.startup = "startup", o.business = "business", o.enterprise = "enterprise", o))(g || {});
43
+ var m = /* @__PURE__ */ ((o) => (o.free = "free", o.startup = "startup", o.business = "business", o.enterprise = "enterprise", o))(m || {});
40
44
  const x = {
41
- [g.free]: 0,
42
- [g.startup]: 10,
43
- [g.business]: 20,
44
- [g.enterprise]: 30
45
+ [m.free]: 0,
46
+ [m.startup]: 10,
47
+ [m.business]: 20,
48
+ [m.enterprise]: 30
45
49
  };
46
- function v(o) {
50
+ function C(o) {
47
51
  const t = o;
48
52
  return t.init = (e) => (s) => o(s, e), t;
49
53
  }
50
- const T = (o) => /* @__PURE__ */ v(o);
51
- async function B({
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
- cleanup: n
60
+ onLicenseCheckResponse: n,
61
+ cleanup: r
57
62
  }) {
58
- let r = "", i = !1;
59
- const a = C(), c = (l) => {
60
- console.warn("Cleanup plugin:", e, "Reason:", l), n();
61
- }, p = (l = {}) => {
62
- var u;
63
- const { error: h, sdkLicense: d } = l, f = (u = l.plan) == null ? void 0 : u.category;
64
- if (!(d || l.license) || h)
65
- c(h || "Invalid license");
66
- else if (f) {
67
- const m = x[t], E = x[f];
68
- m > E && c({ pluginRequiredPlan: t, licensePlan: f });
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(P, (l) => {
72
- r = l == null ? void 0 : l.baseApiUrl, i = !0;
73
- }), o.on(O, (l) => {
74
- p(l);
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 (a) return;
82
+ if (c) return;
78
83
  if (s) {
79
- const l = await A({ licenseKey: s, pluginName: e, baseApiUrl: r });
80
- l && p(l);
84
+ const p = await M({ licenseKey: s, pluginName: e, baseApiUrl: a });
85
+ n == null || n(p), p && u(p);
81
86
  } else
82
- c("The `licenseKey` option not provided");
87
+ l("The `licenseKey` option not provided");
83
88
  }
84
89
  }, 2e3);
85
90
  }
86
- async function A(o) {
91
+ async function M(o) {
87
92
  const { licenseKey: t, pluginName: e, baseApiUrl: s } = o;
88
93
  try {
89
- return (await N({
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 M = (o) => {
107
+ const j = (o) => {
103
108
  const t = o;
104
109
  return t.logicalOperator === "and" || t.logicalOperator === "or";
105
- }, j = (o, t) => (o.config.optsHtml = {
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
- }), W = (o, t) => {
115
+ }), _ = (o, t) => {
111
116
  const e = (n) => {
112
- const { input: r } = n, { contains: i } = t;
113
- (!i || r.includes(i)) && (n.input = t.importer.import(r));
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, i = (s == null ? void 0 : s.path) || e || "", a = this._sanitizeVariableName(e);
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 p = n ?? 0, l = r !== void 0 ? r : "";
129
- c = `.slice(${p}${l !== "" ? `, ${l}` : ""})`;
133
+ const l = n ?? 0, u = r !== void 0 ? r : "";
134
+ c = `.slice(${l}${u !== "" ? `, ${u}` : ""})`;
130
135
  }
131
- return `<% ${i}${c}.forEach(function(currentItem, index, arr) {
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 ${a}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`;
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 (M(t)) {
157
- const e = t.statements.map((r) => this._parseCondition(r)), s = J[t.logicalOperator];
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 J = {
216
+ const F = {
212
217
  and: "&&",
213
218
  or: "||",
214
219
  xor: "^"
215
- }, F = ["===", "==", "!==", "!=", "<=", ">=", "<", ">", "&&", "||"], U = {
220
+ }, U = ["===", "==", "!==", "!=", "<=", ">=", "<", ">", "&&", "||"], D = {
216
221
  "===": "=",
217
222
  "==": "=",
218
223
  "!==": "!=",
@@ -224,7 +229,7 @@ const J = {
224
229
  "&&": "&&",
225
230
  "||": "||"
226
231
  };
227
- class D {
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 i = t.slice(n + 2, r).trim();
254
- if (s = r + 2, i.startsWith("=") || i.startsWith("-")) {
255
- const a = i.slice(1).trim();
256
- e.push(this.createAppendExpression(a));
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 (i.startsWith("#"))
263
+ if (a.startsWith("#"))
259
264
  continue;
260
- if (i.startsWith("if")) {
261
- const a = this.parseIfStatement(i, t, s);
262
- e.push(a), s = a.endPos || s;
263
- } else if (i.startsWith("for")) {
264
- const a = this.parseForStatement(i, t, s);
265
- e.push(a), s = a.endPos || s;
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 a = i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
268
- if (a) {
269
- const c = a[1], p = a[2], l = this.parseForEachStatement(c, p, t, s);
270
- e.push(l), s = l.endPos || s;
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: ${i}`);
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: i, endPos: a } = this.parseTemplateBlock(e, s);
306
- let c = null, p = a;
307
- const l = e.indexOf("<%", p);
308
- if (l === p) {
309
- const h = e.indexOf("%>", l);
310
- if (h !== -1) {
311
- const d = e.slice(l + 2, h).trim(), f = h + 2 - l;
312
- if (d.startsWith("} else if")) {
313
- p = l + f;
314
- const y = d.substring(d.indexOf("if")).trim(), u = this.parseIfStatement(y, e, p);
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: u.test,
318
- consequent: u.consequent,
319
- alternate: u.alternate
320
- }, p = u.endPos;
321
- } else if (d.startsWith("} else")) {
322
- p = l + f;
323
- const { body: y, endPos: u } = this.parseTemplateBlock(e, p);
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: y
327
- }, p = u;
328
- const m = e.indexOf("<%", p), E = e.indexOf("%>", m);
329
- m === p && e.slice(m + 2, E).trim() === "}" && (p = E + 2);
330
- } else d === "}" && (p = l + f);
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: i
343
+ body: a
339
344
  },
340
345
  alternate: c,
341
- endPos: p
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 i = r[0].trim().replace(/^let\s+|^const\s+|^var\s+/, ""), a = r[1].trim(), { body: c, endPos: p } = this.parseTemplateBlock(e, s);
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: i },
361
- init: this.parseJsExpression(a)
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 l = e.indexOf("<%", p), h = e.indexOf("%>", l);
374
- return l === p && e.slice(l + 2, h).trim() === "}" ? h + 2 : p;
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: i } = this.parseTemplateBlock(s, n);
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 a = s.indexOf("<%", i), c = s.indexOf("%>", a);
390
- return a === i && s.slice(a + 2, c).trim() === "}" ? c + 2 : i;
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 i = t.indexOf("%>", r);
405
- if (i === -1)
409
+ const a = t.indexOf("%>", r);
410
+ if (a === -1)
406
411
  throw new Error("Unclosed EJS tag within block");
407
- const a = t.slice(r + 2, i).trim();
408
- if (a === "}" || a.startsWith("} else")) {
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 = i + 2, a.startsWith("=") || a.startsWith("-")) {
413
- const c = a.slice(1).trim();
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 (a.startsWith("#"))
421
+ if (i.startsWith("#"))
417
422
  continue;
418
- if (a.startsWith("if")) {
419
- const c = this.parseIfStatement(a, t, n);
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 (a.startsWith("for")) {
422
- const c = this.parseForStatement(a, t, n);
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 = a.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
430
+ const c = i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
426
431
  if (c) {
427
- const p = c[1], l = c[2], h = this.parseForEachStatement(p, l, t, n);
428
- s.push(h), n = h.endPos || n;
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: ${a}`);
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 F) {
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: U[n],
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, i, a = !1;
475
+ let r, a, i = !1;
471
476
  if (n === e)
472
- r = t.slice(0, e), i = { type: "Identifier", name: t.slice(e + 1) }, a = !1;
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 p = t.slice(s + 1, c);
479
- i = /^(['"]).*\1$/.test(p) || /^-?\d+(\.\d+)?$/.test(p) ? this.parseJsExpression(p) : { type: "Identifier", name: p }, a = !0;
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: i,
485
- computed: a
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 a;
549
- if (((a = t.init) == null ? void 0 : a.type) !== "VariableDeclaration" || t.init.declarations.length === 0)
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 i = this.astToGrapesJS(t.body);
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
- ${i}
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 i = t;
613
- const a = [];
614
- for (; i.type === "MemberExpression"; )
615
- 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;
616
- if (i.type === "Identifier" && i.name === r) {
617
- const c = a.join(".");
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 V = "dataSourceEjs", G = g.startup, q = function(o, t = {}) {
703
- const e = j(o, new _()), s = W(o, {
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 D()
710
+ importer: new V()
706
711
  });
707
- B({
712
+ A({
708
713
  editor: o,
709
714
  licenseKey: t.licenseKey,
710
- plan: G,
711
- pluginName: V,
715
+ plan: q,
716
+ pluginName: G,
712
717
  cleanup: () => {
713
718
  e(), s();
714
719
  }
715
720
  });
716
- }, H = T(q);
721
+ }, K = B(H);
717
722
  export {
718
- H as default
723
+ K as default
719
724
  };