@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.36

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 (88) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +175 -162
  3. package/dist/accordionComponent/index.umd.js +7 -7
  4. package/dist/aiChat/index.cjs.js +64 -64
  5. package/dist/aiChat/index.es.js +5785 -5757
  6. package/dist/aiChat/index.js +64 -64
  7. package/dist/aiChat/index.umd.js +63 -63
  8. package/dist/animationComponent/index.cjs.js +3 -3
  9. package/dist/animationComponent/index.es.js +204 -191
  10. package/dist/animationComponent/index.umd.js +3 -3
  11. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  12. package/dist/canvasAbsoluteMode/index.es.js +183 -170
  13. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  14. package/dist/canvasEmptyState/index.cjs.js +1 -1
  15. package/dist/canvasEmptyState/index.es.js +134 -121
  16. package/dist/canvasEmptyState/index.umd.js +1 -1
  17. package/dist/canvasFullSize/index.cjs.js +9 -9
  18. package/dist/canvasFullSize/index.es.js +165 -152
  19. package/dist/canvasFullSize/index.umd.js +9 -9
  20. package/dist/canvasGridMode/index.cjs.js +5 -5
  21. package/dist/canvasGridMode/index.es.js +245 -232
  22. package/dist/canvasGridMode/index.umd.js +4 -4
  23. package/dist/canvasScreenshot/index.cjs.js +1 -1
  24. package/dist/canvasScreenshot/index.es.js +155 -142
  25. package/dist/canvasScreenshot/index.umd.js +1 -1
  26. package/dist/dataSourceEjs/index.cjs.js +9 -9
  27. package/dist/dataSourceEjs/index.es.js +257 -244
  28. package/dist/dataSourceEjs/index.umd.js +9 -9
  29. package/dist/dataSourceHandlebars/index.cjs.js +8 -8
  30. package/dist/dataSourceHandlebars/index.es.js +216 -203
  31. package/dist/dataSourceHandlebars/index.umd.js +7 -7
  32. package/dist/dialogComponent/index.cjs.js +14 -14
  33. package/dist/dialogComponent/index.es.js +141 -128
  34. package/dist/dialogComponent/index.umd.js +14 -14
  35. package/dist/flexComponent/index.cjs.js +13 -13
  36. package/dist/flexComponent/index.es.js +484 -471
  37. package/dist/flexComponent/index.umd.js +13 -13
  38. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  39. package/dist/fsLightboxComponent/index.es.js +173 -160
  40. package/dist/fsLightboxComponent/index.umd.js +3 -3
  41. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  42. package/dist/googleFontsAssetProvider/index.es.js +160 -147
  43. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  44. package/dist/iconifyComponent/index.cjs.js +2 -2
  45. package/dist/iconifyComponent/index.es.js +196 -183
  46. package/dist/iconifyComponent/index.umd.js +2 -2
  47. package/dist/index.cjs.js +25 -25
  48. package/dist/index.es.js +121 -108
  49. package/dist/index.umd.js +18 -18
  50. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  51. package/dist/layoutSidebarButtons/index.es.js +157 -144
  52. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  53. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  54. package/dist/lightGalleryComponent/index.es.js +245 -232
  55. package/dist/lightGalleryComponent/index.umd.js +1 -1
  56. package/dist/linkImageComponent/index.cjs.js +2 -2
  57. package/dist/linkImageComponent/index.es.js +106 -93
  58. package/dist/linkImageComponent/index.umd.js +2 -2
  59. package/dist/listPagesComponent/index.cjs.js +5 -5
  60. package/dist/listPagesComponent/index.es.js +157 -144
  61. package/dist/listPagesComponent/index.umd.js +5 -5
  62. package/dist/presetPrintable/index.cjs.js +3 -3
  63. package/dist/presetPrintable/index.es.js +181 -168
  64. package/dist/presetPrintable/index.umd.js +3 -3
  65. package/dist/prosemirror/index.cjs.js +7 -7
  66. package/dist/prosemirror/index.es.js +385 -372
  67. package/dist/prosemirror/index.umd.js +8 -8
  68. package/dist/rendererReact/index.cjs.js +1 -1
  69. package/dist/rendererReact/index.es.js +200 -187
  70. package/dist/rendererReact/index.js +1 -1
  71. package/dist/rendererReact/index.umd.js +1 -1
  72. package/dist/rteTinyMce/index.cjs.js +2 -2
  73. package/dist/rteTinyMce/index.es.js +118 -105
  74. package/dist/rteTinyMce/index.umd.js +2 -2
  75. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  76. package/dist/shapeDividerComponent/index.es.js +129 -116
  77. package/dist/shapeDividerComponent/index.umd.js +4 -4
  78. package/dist/swiperComponent/index.cjs.js +9 -9
  79. package/dist/swiperComponent/index.es.js +203 -190
  80. package/dist/swiperComponent/index.umd.js +7 -7
  81. package/dist/tableComponent/index.cjs.js +1 -1
  82. package/dist/tableComponent/index.es.js +257 -244
  83. package/dist/tableComponent/index.umd.js +1 -1
  84. package/dist/types.d.ts +1 -1
  85. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  86. package/dist/youtubeAssetProvider/index.es.js +121 -108
  87. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  88. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- const $ = "app.grapesjs.com", b = "app-stage.grapesjs.com", w = "app2.grapesjs.com", P = "app-stage2.grapesjs.com", S = [
2
- $,
3
- w,
4
- b,
5
- P,
1
+ const I = "app.grapesjs.com", m = "app-stage.grapesjs.com", v = "app2.grapesjs.com", O = "app-stage2.grapesjs.com", $ = [
2
+ I,
3
+ v,
4
+ m,
5
+ O,
6
6
  "localhost",
7
7
  "127.0.0.1",
8
8
  ".local-credentialless.webcontainer.io",
@@ -11,88 +11,101 @@ const $ = "app.grapesjs.com", b = "app-stage.grapesjs.com", w = "app2.grapesjs.c
11
11
  // For stackblitz.com demos
12
12
  "-sandpack.codesandbox.io"
13
13
  // For Sandpack demos
14
- ], O = "license:check:start", N = "license:check:end", v = () => typeof window < "u", T = ({
15
- isDev: o,
14
+ ], w = "license:check:end", T = () => typeof window < "u", L = ({
15
+ isDev: s,
16
16
  isStage: t,
17
17
  isPlatform: e
18
- }) => `${o ? "" : `https://${t ? b : $}`}/${e ? "platform-api" : "api"}`, k = () => {
19
- const o = v() && window.location.hostname;
20
- return !!o && (S.includes(o) || S.some((t) => o.endsWith(t)));
18
+ }) => `${s ? "" : `https://${t ? m : I}`}/${e ? "platform-api" : "api"}`, k = () => {
19
+ const s = T() && window.location.hostname;
20
+ return !!s && ($.includes(s) || $.some((t) => s.endsWith(t)));
21
21
  };
22
- async function L({
23
- path: o,
22
+ async function A({
23
+ path: s,
24
24
  baseApiUrl: t,
25
25
  method: e = "GET",
26
- headers: s = {},
26
+ headers: r = {},
27
27
  params: n,
28
- body: r
28
+ body: a
29
29
  }) {
30
- const i = `${t || T({ isDev: !1, isStage: !1 })}${o}`, c = {
30
+ const i = `${t || L({ isDev: !1, isStage: !1 })}${s}`, l = {
31
31
  method: e,
32
32
  headers: {
33
33
  "Content-Type": "application/json",
34
- ...s
34
+ ...r
35
35
  }
36
36
  };
37
- r && (c.body = JSON.stringify(r));
38
- const l = n ? new URLSearchParams(n).toString() : "", u = l ? `?${l}` : "", p = await fetch(`${i}${u}`, c);
37
+ a && (l.body = JSON.stringify(a));
38
+ const c = n ? new URLSearchParams(n).toString() : "", u = c ? `?${c}` : "", p = await fetch(`${i}${u}`, l);
39
39
  if (!p.ok)
40
40
  throw new Error(`HTTP error! status: ${p.status}`);
41
41
  return p.json();
42
42
  }
43
- var m = /* @__PURE__ */ ((o) => (o.free = "free", o.startup = "startup", o.business = "business", o.enterprise = "enterprise", o))(m || {});
44
- const x = {
45
- [m.free]: 0,
46
- [m.startup]: 10,
47
- [m.business]: 20,
48
- [m.enterprise]: 30
43
+ var y = /* @__PURE__ */ ((s) => (s.free = "free", s.startup = "startup", s.business = "business", s.enterprise = "enterprise", s))(y || {}), b = /* @__PURE__ */ ((s) => (s.toastAdd = "studio:toastAdd", s.toastRemove = "studio:toastRemove", s.dialogOpen = "studio:dialogOpen", s.dialogClose = "studio:dialogClose", s.dialogExportCode = "studio:dialogExportCode", s.dialogImportCode = "studio:dialogImportCode", s.sidebarLeftSet = "studio:sidebarLeft:set", s.sidebarLeftGet = "studio:sidebarLeft:get", s.sidebarLeftToggle = "studio:sidebarLeft:toggle", s.sidebarRightSet = "studio:sidebarRight:set", s.sidebarRightGet = "studio:sidebarRight:get", s.sidebarRightToggle = "studio:sidebarRight:toggle", s.sidebarTopSet = "studio:sidebarTop:set", s.sidebarTopGet = "studio:sidebarTop:get", s.sidebarTopToggle = "studio:sidebarTop:toggle", s.sidebarBottomSet = "studio:sidebarBottom:set", s.sidebarBottomGet = "studio:sidebarBottom:get", s.sidebarBottomToggle = "studio:sidebarBottom:toggle", s.symbolAdd = "studio:symbolAdd", s.symbolDetach = "studio:symbolDetach", s.symbolOverride = "studio:symbolOverride", s.symbolPropagateStyles = "studio:propagateStyles", s.getPagesConfig = "studio:getPagesConfig", s.setPagesConfig = "studio:setPagesConfig", s.getPageSettings = "studio:getPageSettings", s.setPageSettings = "studio:setPageSettings", s.clearPage = "studio:clearPage", s.projectFiles = "studio:projectFiles", s.validateCode = "studio:validateCode", s.canvasReload = "studio:canvasReload", s.getBlocksPanel = "studio:getBlocksPanel", s.setBlocksPanel = "studio:setBlocksPanel", s.getStateContextMenu = "studio:getStateContextMenu", s.setStateContextMenu = "studio:setStateContextMenu", s.contextMenuComponent = "studio:contextMenuComponent", s.layoutAdd = "studio:layoutAdd", s.layoutRemove = "studio:layoutRemove", s.layoutToggle = "studio:layoutToggle", s.layoutUpdate = "studio:layoutUpdate", s.layoutGet = "studio:layoutGet", s.layoutConfigGet = "studio:layoutConfigGet", s.layoutConfigSet = "studio:layoutConfigSet", s.layoutComponentAdd = "studio:layoutComponentAdd", s.layoutComponentGet = "studio:layoutComponentGet", s.layoutComponentRemove = "studio:layoutComponentRemove", s.layoutComponentRender = "studio:layoutComponentRender", s.getStateTheme = "studio:getStateTheme", s.setStateTheme = "studio:setStateTheme", s.settings = "studio:settings", s.assetProviderGet = "studio:assetProviderGet", s.assetProviderAdd = "studio:assetProviderAdd", s.assetProviderRemove = "studio:assetProviderRemove", s.fontGet = "studio:fontGet", s.fontAdd = "studio:fontAdd", s.fontRemove = "studio:fontRemove", s.fontManagerOpen = "studio:fontManagerOpen", s.menuFontLoad = "studio:menuFontLoad", s.toggleStateDataSource = "studio:toggleStateDataSource", s.getStateDataSource = "studio:getStateDataSource", s.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", s.dataSourceSetImporter = "studio:dataSourceSetImporter", s.dataSourceSetExporter = "studio:dataSourceSetExporter", s.setDragAbsolute = "studio:setDragAbsolute", s))(b || {});
44
+ const S = {
45
+ [y.free]: 0,
46
+ [y.startup]: 10,
47
+ [y.business]: 20,
48
+ [y.enterprise]: 30
49
49
  };
50
- function C(o) {
51
- const t = o;
52
- return t.init = (e) => (s) => o(s, e), t;
50
+ function B(s) {
51
+ const t = s;
52
+ return t.init = (e) => (r) => s(r, e), t;
53
53
  }
54
- const B = (o) => /* @__PURE__ */ C(o);
55
- async function A({
56
- editor: o,
54
+ const N = (s) => /* @__PURE__ */ B(s);
55
+ async function M({
56
+ editor: s,
57
57
  plan: t,
58
58
  pluginName: e,
59
- licenseKey: s,
59
+ licenseKey: r,
60
60
  onLicenseCheckResponse: n,
61
- cleanup: r
61
+ cleanup: a
62
62
  }) {
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)
63
+ let o = "", i;
64
+ const l = (p) => {
65
+ console.warn("Cleanup plugin:", e, "Reason:", p), a();
66
+ }, c = (p = {}) => {
67
+ var f;
68
+ const { error: h, sdkLicense: E } = p, g = (f = p.plan) == null ? void 0 : f.category;
69
+ if (!(E || p.license) || h)
70
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 });
71
+ else if (g) {
72
+ const x = S[t], P = S[g];
73
+ x > P && l({ pluginRequiredPlan: t, licensePlan: g });
74
74
  }
75
75
  };
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);
80
- }), setTimeout(async () => {
81
- if (!i) {
82
- if (c) return;
83
- if (s) {
84
- const p = await M({ licenseKey: s, pluginName: e, baseApiUrl: a });
85
- n == null || n(p), p && u(p);
86
- } else
87
- l("The `licenseKey` option not provided");
88
- }
89
- }, 2e3);
76
+ s.Commands.has(b.settings) && (i = s.runCommand(b.settings), o = (i == null ? void 0 : i.baseUrl) || "");
77
+ const u = (p) => {
78
+ n == null || n(p), p && c(p);
79
+ };
80
+ if (!i) {
81
+ s.onReady(async () => {
82
+ if (!k())
83
+ if (r) {
84
+ const p = await j({ licenseKey: r, pluginName: e, baseApiUrl: o });
85
+ u(p);
86
+ } else
87
+ l("The `licenseKey` option not provided");
88
+ });
89
+ return;
90
+ }
91
+ if (i.licensePlan || i.licenseError) {
92
+ const p = G(i);
93
+ u(p);
94
+ return;
95
+ }
96
+ s.on(w, (p) => u(p));
90
97
  }
91
- async function M(o) {
92
- const { licenseKey: t, pluginName: e, baseApiUrl: s } = o;
98
+ const G = (s) => ({
99
+ sdkLicense: s.license,
100
+ license: s.license,
101
+ error: s.licenseError,
102
+ plan: s.licensePlan
103
+ });
104
+ async function j(s) {
105
+ const { licenseKey: t, pluginName: e, baseApiUrl: r } = s;
93
106
  try {
94
- return (await L({
95
- baseApiUrl: s,
107
+ return (await A({
108
+ baseApiUrl: r,
96
109
  path: `/sdk/${t || "na"}`,
97
110
  method: "POST",
98
111
  params: {
@@ -104,36 +117,36 @@ async function M(o) {
104
117
  return console.error("Error during SDK license check:", n), !1;
105
118
  }
106
119
  }
107
- const j = (o) => {
108
- const t = o;
120
+ const D = (s) => {
121
+ const t = s;
109
122
  return t.logicalOperator === "and" || t.logicalOperator === "or";
110
- }, W = (o, t) => (o.config.optsHtml = {
111
- ...o.config.optsHtml,
123
+ }, F = (s, t) => (s.config.optsHtml = {
124
+ ...s.config.optsHtml,
112
125
  exporter: t
113
126
  }, () => {
114
- o.config.optsHtml.exporter = void 0;
115
- }), _ = (o, t) => {
127
+ s.config.optsHtml.exporter = void 0;
128
+ }), J = (s, t) => {
116
129
  const e = (n) => {
117
- const { input: r } = n, { contains: a } = t;
118
- (!a || r.includes(a)) && (n.input = t.importer.import(r));
119
- }, s = o.Parser.events.htmlBefore;
120
- return o.on(s, e), () => {
121
- o.off(s, e);
130
+ const { input: a } = n, { contains: o } = t;
131
+ (!o || a.includes(o)) && (n.input = t.importer.import(a));
132
+ }, r = s.Parser.events.htmlBefore;
133
+ return s.on(r, e), () => {
134
+ s.off(r, e);
122
135
  };
123
136
  };
124
- class J {
137
+ class W {
125
138
  getVariableSyntax({ dataResolver: t }) {
126
- const { defaultValue: e } = t, s = this.getFullPath(t), n = e ? ` || \`${e}\`` : "";
127
- return `<%= ${s}${n} %>`;
139
+ const { defaultValue: e } = t, r = this.getFullPath(t), n = e ? ` || \`${e}\`` : "";
140
+ return `<%= ${r}${n} %>`;
128
141
  }
129
142
  getCollectionStartSyntax({ dataResolver: t }) {
130
- const { collectionId: e, dataSource: s, startIndex: n, endIndex: r } = t, a = (s == null ? void 0 : s.path) || e || "", i = this._sanitizeVariableName(e);
131
- let c = "";
132
- if (n !== void 0 || r !== void 0) {
133
- const l = n ?? 0, u = r !== void 0 ? r : "";
134
- c = `.slice(${l}${u !== "" ? `, ${u}` : ""})`;
143
+ const { collectionId: e, dataSource: r, startIndex: n, endIndex: a } = t, o = (r == null ? void 0 : r.path) || e || "", i = this._sanitizeVariableName(e);
144
+ let l = "";
145
+ if (n !== void 0 || a !== void 0) {
146
+ const c = n ?? 0, u = a !== void 0 ? a : "";
147
+ l = `.slice(${c}${u !== "" ? `, ${u}` : ""})`;
135
148
  }
136
- return `<% ${a}${c}.forEach(function(currentItem, index, arr) {
149
+ return `<% ${o}${l}.forEach(function(currentItem, index, arr) {
137
150
  const startIndex = parseInt(${n ?? 0}, 10);
138
151
  const endIndex = startIndex + arr.length;
139
152
  const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`;
@@ -153,37 +166,37 @@ const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
153
166
  getConditionalEndSyntax() {
154
167
  return "<% } %>";
155
168
  }
156
- getFullPath({ collectionId: t, path: e, variableType: s }) {
157
- return (t ? [this._sanitizeVariableName(t), s, e].filter(Boolean).join(".") : e) || "";
169
+ getFullPath({ collectionId: t, path: e, variableType: r }) {
170
+ return (t ? [this._sanitizeVariableName(t), r, e].filter(Boolean).join(".") : e) || "";
158
171
  }
159
172
  _parseCondition(t) {
160
173
  if (!t) return "";
161
- if (j(t)) {
162
- const e = t.statements.map((r) => this._parseCondition(r)), s = F[t.logicalOperator];
163
- let n = e.length > 1 ? `(${e.join(`)${s}(`)})` : e[0];
174
+ if (D(t)) {
175
+ const e = t.statements.map((a) => this._parseCondition(a)), r = _[t.logicalOperator];
176
+ let n = e.length > 1 ? `(${e.join(`)${r}(`)})` : e[0];
164
177
  return t.logicalOperator === "xor" && (n = `!!(${n})`), n;
165
178
  } else {
166
- const e = this._parseValue(t.left), s = this._parseValue(t.right);
179
+ const e = this._parseValue(t.left), r = this._parseValue(t.right);
167
180
  switch (t.operator) {
168
181
  case "equals":
169
- return `${e} === ${s}`;
182
+ return `${e} === ${r}`;
170
183
  case ">":
171
184
  case "<":
172
185
  case ">=":
173
186
  case "<=":
174
187
  case "=":
175
188
  case "!=":
176
- return `${e} ${t.operator} ${s}`;
189
+ return `${e} ${t.operator} ${r}`;
177
190
  case "contains":
178
- return `${e}?.includes(${s})`;
191
+ return `${e}?.includes(${r})`;
179
192
  case "startsWith":
180
- return `${e}?.startsWith(${s})`;
193
+ return `${e}?.startsWith(${r})`;
181
194
  case "endsWith":
182
- return `${e}?.endsWith(${s})`;
195
+ return `${e}?.endsWith(${r})`;
183
196
  case "equalsIgnoreCase":
184
- return `${e}?.toLowerCase() === ${s}?.toLowerCase()`;
197
+ return `${e}?.toLowerCase() === ${r}?.toLowerCase()`;
185
198
  case "trimEquals":
186
- return `${e}?.trim() === ${s}?.trim()`;
199
+ return `${e}?.trim() === ${r}?.trim()`;
187
200
  case "isTruthy":
188
201
  return `!!${e}`;
189
202
  case "isFalsy":
@@ -205,7 +218,7 @@ const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
205
218
  case "isBoolean":
206
219
  return `typeof ${e} === 'boolean'`;
207
220
  default:
208
- return `${e} ${t.operator} ${s}`;
221
+ return `${e} ${t.operator} ${r}`;
209
222
  }
210
223
  }
211
224
  }
@@ -213,11 +226,11 @@ const ${i}={ currentItem, currentIndex: startIndex + index, remainingItems: endI
213
226
  return typeof t == "object" ? this.getFullPath(t) : typeof t == "string" ? `'${t.replace(/'/g, "\\'")}'` : String(t);
214
227
  }
215
228
  }
216
- const F = {
229
+ const _ = {
217
230
  and: "&&",
218
231
  or: "||",
219
232
  xor: "^"
220
- }, U = ["===", "==", "!==", "!=", "<=", ">=", "<", ">", "&&", "||"], D = {
233
+ }, R = ["===", "==", "!==", "!=", "<=", ">=", "<", ">", "&&", "||"], U = {
221
234
  "===": "=",
222
235
  "==": "=",
223
236
  "!==": "!=",
@@ -244,37 +257,37 @@ class V {
244
257
  }
245
258
  parseEjsTemplate(t) {
246
259
  const e = [];
247
- let s = 0;
248
- for (; s < t.length; ) {
249
- const n = t.indexOf("<%", s);
260
+ let r = 0;
261
+ for (; r < t.length; ) {
262
+ const n = t.indexOf("<%", r);
250
263
  if (n === -1) {
251
- s < t.length && e.push(this.createAppendLiteral(t.slice(s)));
264
+ r < t.length && e.push(this.createAppendLiteral(t.slice(r)));
252
265
  break;
253
266
  }
254
- n > s && e.push(this.createAppendLiteral(t.slice(s, n)));
255
- const r = t.indexOf("%>", n);
256
- if (r === -1)
267
+ n > r && e.push(this.createAppendLiteral(t.slice(r, n)));
268
+ const a = t.indexOf("%>", n);
269
+ if (a === -1)
257
270
  throw new Error("Unclosed EJS tag");
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();
271
+ const o = t.slice(n + 2, a).trim();
272
+ if (r = a + 2, o.startsWith("=") || o.startsWith("-")) {
273
+ const i = o.slice(1).trim();
261
274
  e.push(this.createAppendExpression(i));
262
275
  } else {
263
- if (a.startsWith("#"))
276
+ if (o.startsWith("#"))
264
277
  continue;
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;
278
+ if (o.startsWith("if")) {
279
+ const i = this.parseIfStatement(o, t, r);
280
+ e.push(i), r = i.endPos || r;
281
+ } else if (o.startsWith("for")) {
282
+ const i = this.parseForStatement(o, t, r);
283
+ e.push(i), r = i.endPos || r;
271
284
  } else {
272
- const i = a.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
285
+ const i = o.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
273
286
  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;
287
+ const l = i[1], c = i[2], u = this.parseForEachStatement(l, c, t, r);
288
+ e.push(u), r = u.endPos || r;
276
289
  } else
277
- this.addMessage("info", `Unsupported scriptlet content: ${a}`);
290
+ this.addMessage("info", `Unsupported scriptlet content: ${o}`);
278
291
  }
279
292
  }
280
293
  }
@@ -303,57 +316,57 @@ class V {
303
316
  }
304
317
  };
305
318
  }
306
- parseIfStatement(t, e, s) {
319
+ parseIfStatement(t, e, r) {
307
320
  const n = t.match(/if\s*\((.*)\)\s*\{?/);
308
321
  if (!n)
309
322
  throw new Error("Invalid if statement syntax");
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) {
323
+ const a = this.parseJsExpression(n[1]), { body: o, endPos: i } = this.parseTemplateBlock(e, r);
324
+ let l = null, c = i;
325
+ const u = e.indexOf("<%", c);
326
+ if (u === c) {
314
327
  const p = e.indexOf("%>", u);
315
328
  if (p !== -1) {
316
- const h = e.slice(u + 2, p).trim(), y = p + 2 - u;
329
+ const h = e.slice(u + 2, p).trim(), E = p + 2 - u;
317
330
  if (h.startsWith("} else if")) {
318
- l = u + y;
319
- const d = h.substring(h.indexOf("if")).trim(), f = this.parseIfStatement(d, e, l);
320
- c = {
331
+ c = u + E;
332
+ const g = h.substring(h.indexOf("if")).trim(), d = this.parseIfStatement(g, e, c);
333
+ l = {
321
334
  type: "IfStatement",
322
- test: f.test,
323
- consequent: f.consequent,
324
- alternate: f.alternate
325
- }, l = f.endPos;
335
+ test: d.test,
336
+ consequent: d.consequent,
337
+ alternate: d.alternate
338
+ }, c = d.endPos;
326
339
  } else if (h.startsWith("} else")) {
327
- l = u + y;
328
- const { body: d, endPos: f } = this.parseTemplateBlock(e, l);
329
- c = {
340
+ c = u + E;
341
+ const { body: g, endPos: d } = this.parseTemplateBlock(e, c);
342
+ l = {
330
343
  type: "BlockStatement",
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);
344
+ body: g
345
+ }, c = d;
346
+ const f = e.indexOf("<%", c), x = e.indexOf("%>", f);
347
+ f === c && e.slice(f + 2, x).trim() === "}" && (c = x + 2);
348
+ } else h === "}" && (c = u + E);
336
349
  }
337
350
  }
338
351
  return {
339
352
  type: "IfStatement",
340
- test: r,
353
+ test: a,
341
354
  consequent: {
342
355
  type: "BlockStatement",
343
- body: a
356
+ body: o
344
357
  },
345
- alternate: c,
346
- endPos: l
358
+ alternate: l,
359
+ endPos: c
347
360
  };
348
361
  }
349
- parseForStatement(t, e, s) {
362
+ parseForStatement(t, e, r) {
350
363
  const n = t.match(/for\s*\((.*)\)\s*\{?/);
351
364
  if (!n)
352
365
  throw new Error("Invalid for statement syntax");
353
- const r = n[1].split("of");
354
- if (r.length !== 2)
366
+ const a = n[1].split("of");
367
+ if (a.length !== 2)
355
368
  throw new Error("Only for...of loops are supported");
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);
369
+ const o = a[0].trim().replace(/^let\s+|^const\s+|^var\s+/, ""), i = a[1].trim(), { body: l, endPos: c } = this.parseTemplateBlock(e, r);
357
370
  return {
358
371
  type: "ForStatement",
359
372
  init: {
@@ -362,7 +375,7 @@ class V {
362
375
  declarations: [
363
376
  {
364
377
  type: "VariableDeclarator",
365
- id: { type: "Identifier", name: a },
378
+ id: { type: "Identifier", name: o },
366
379
  init: this.parseJsExpression(i)
367
380
  }
368
381
  ]
@@ -371,72 +384,72 @@ class V {
371
384
  update: null,
372
385
  body: {
373
386
  type: "BlockStatement",
374
- body: c
387
+ body: l
375
388
  },
376
389
  // Consume the closing '}' tag for the for loop
377
390
  endPos: (() => {
378
- const u = e.indexOf("<%", l), p = e.indexOf("%>", u);
379
- return u === l && e.slice(u + 2, p).trim() === "}" ? p + 2 : l;
391
+ const u = e.indexOf("<%", c), p = e.indexOf("%>", u);
392
+ return u === c && e.slice(u + 2, p).trim() === "}" ? p + 2 : c;
380
393
  })()
381
394
  };
382
395
  }
383
- parseForEachStatement(t, e, s, n) {
384
- const { body: r, endPos: a } = this.parseTemplateBlock(s, n);
396
+ parseForEachStatement(t, e, r, n) {
397
+ const { body: a, endPos: o } = this.parseTemplateBlock(r, n);
385
398
  return {
386
399
  type: "ForEachStatement",
387
400
  collection: this.parseJsExpression(t),
388
401
  itemIdentifier: { type: "Identifier", name: e },
389
402
  body: {
390
403
  type: "BlockStatement",
391
- body: r
404
+ body: a
392
405
  },
393
406
  endPos: (() => {
394
- const i = s.indexOf("<%", a), c = s.indexOf("%>", i);
395
- return i === a && s.slice(i + 2, c).trim() === "}" ? c + 2 : a;
407
+ const i = r.indexOf("<%", o), l = r.indexOf("%>", i);
408
+ return i === o && r.slice(i + 2, l).trim() === "}" ? l + 2 : o;
396
409
  })()
397
410
  };
398
411
  }
399
412
  parseTemplateBlock(t, e) {
400
- const s = [];
413
+ const r = [];
401
414
  let n = e;
402
415
  for (; n < t.length; ) {
403
- const r = t.indexOf("<%", n);
404
- if (r === -1) {
405
- n < t.length && s.push(this.createAppendLiteral(t.slice(n))), n = t.length;
416
+ const a = t.indexOf("<%", n);
417
+ if (a === -1) {
418
+ n < t.length && r.push(this.createAppendLiteral(t.slice(n))), n = t.length;
406
419
  break;
407
420
  }
408
- r > n && s.push(this.createAppendLiteral(t.slice(n, r)));
409
- const a = t.indexOf("%>", r);
410
- if (a === -1)
421
+ a > n && r.push(this.createAppendLiteral(t.slice(n, a)));
422
+ const o = t.indexOf("%>", a);
423
+ if (o === -1)
411
424
  throw new Error("Unclosed EJS tag within block");
412
- const i = t.slice(r + 2, a).trim();
425
+ const i = t.slice(a + 2, o).trim();
413
426
  if (i === "}" || i.startsWith("} else")) {
414
- n = r;
427
+ n = a;
415
428
  break;
416
429
  }
417
- if (n = a + 2, i.startsWith("=") || i.startsWith("-")) {
418
- const c = i.slice(1).trim();
419
- s.push(this.createAppendExpression(c));
430
+ if (n = o + 2, i.startsWith("=") || i.startsWith("-")) {
431
+ const l = i.slice(1).trim();
432
+ r.push(this.createAppendExpression(l));
420
433
  } else {
421
434
  if (i.startsWith("#"))
422
435
  continue;
423
436
  if (i.startsWith("if")) {
424
- const c = this.parseIfStatement(i, t, n);
425
- s.push(c), n = c.endPos || n;
437
+ const l = this.parseIfStatement(i, t, n);
438
+ r.push(l), n = l.endPos || n;
426
439
  } else if (i.startsWith("for")) {
427
- const c = this.parseForStatement(i, t, n);
428
- s.push(c), n = c.endPos || n;
440
+ const l = this.parseForStatement(i, t, n);
441
+ r.push(l), n = l.endPos || n;
429
442
  } else {
430
- const c = i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
431
- if (c) {
432
- const l = c[1], u = c[2], p = this.parseForEachStatement(l, u, t, n);
433
- s.push(p), n = p.endPos || n;
443
+ const l = i.match(/([\w][\w.-]*[\w])\s*\.\s*forEach\s*\(\s*(\w+)\s*=>\s*\{?/);
444
+ if (l) {
445
+ const c = l[1], u = l[2], p = this.parseForEachStatement(c, u, t, n);
446
+ r.push(p), n = p.endPos || n;
434
447
  } else
435
448
  this.addMessage("info", `Unsupported scriptlet content within block: ${i}`);
436
449
  }
437
450
  }
438
451
  }
439
- return { body: s, endPos: n };
452
+ return { body: r, endPos: n };
440
453
  }
441
454
  parseJsExpression(t) {
442
455
  if (/^(['"]).*\1$/.test(t))
@@ -459,34 +472,34 @@ class V {
459
472
  type: "Literal",
460
473
  value: t === "true"
461
474
  };
462
- for (const n of U) {
463
- const r = t.lastIndexOf(n);
464
- if (r > 0 && t[r - 1] !== "!" && t[r - 1] !== "=" && t[r - 1] !== "<" && t[r - 1] !== ">")
475
+ for (const n of R) {
476
+ const a = t.lastIndexOf(n);
477
+ if (a > 0 && t[a - 1] !== "!" && t[a - 1] !== "=" && t[a - 1] !== "<" && t[a - 1] !== ">")
465
478
  return {
466
479
  type: n === "&&" || n === "||" ? "LogicalExpression" : "BinaryExpression",
467
- operator: D[n],
468
- left: this.parseJsExpression(t.slice(0, r).trim()),
469
- right: this.parseJsExpression(t.slice(r + n.length).trim())
480
+ operator: U[n],
481
+ left: this.parseJsExpression(t.slice(0, a).trim()),
482
+ right: this.parseJsExpression(t.slice(a + n.length).trim())
470
483
  };
471
484
  }
472
- const e = t.indexOf("."), s = t.indexOf("[");
473
- if (e > 0 && (s === -1 || e < s) || s > 0 && (e === -1 || s < e)) {
474
- const n = e > 0 && (s === -1 || e < s) ? e : s;
475
- let r, a, i = !1;
485
+ const e = t.indexOf("."), r = t.indexOf("[");
486
+ if (e > 0 && (r === -1 || e < r) || r > 0 && (e === -1 || r < e)) {
487
+ const n = e > 0 && (r === -1 || e < r) ? e : r;
488
+ let a, o, i = !1;
476
489
  if (n === e)
477
- r = t.slice(0, e), a = { type: "Identifier", name: t.slice(e + 1) }, i = !1;
490
+ a = t.slice(0, e), o = { type: "Identifier", name: t.slice(e + 1) }, i = !1;
478
491
  else {
479
- r = t.slice(0, s);
480
- const c = t.indexOf("]", s);
481
- if (c === -1)
492
+ a = t.slice(0, r);
493
+ const l = t.indexOf("]", r);
494
+ if (l === -1)
482
495
  throw new Error("Unclosed bracket in expression");
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;
496
+ const c = t.slice(r + 1, l);
497
+ o = /^(['"]).*\1$/.test(c) || /^-?\d+(\.\d+)?$/.test(c) ? this.parseJsExpression(c) : { type: "Identifier", name: c }, i = !0;
485
498
  }
486
499
  return {
487
500
  type: "MemberExpression",
488
- object: this.parseJsExpression(r),
489
- property: a,
501
+ object: this.parseJsExpression(a),
502
+ property: o,
490
503
  computed: i
491
504
  };
492
505
  }
@@ -529,8 +542,8 @@ class V {
529
542
  }
530
543
  handleProgram(t) {
531
544
  let e = "";
532
- for (const s of t.body)
533
- e += this.astToGrapesJS(s);
545
+ for (const r of t.body)
546
+ e += this.astToGrapesJS(r);
534
547
  return e;
535
548
  }
536
549
  handleVariableDeclaration(t) {
@@ -540,11 +553,11 @@ class V {
540
553
  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]) : "";
541
554
  }
542
555
  handleIfStatement(t) {
543
- const e = this.getConditionExpression(t.test), s = this.astToGrapesJS(t.consequent);
556
+ const e = this.getConditionExpression(t.test), r = this.astToGrapesJS(t.consequent);
544
557
  let n = "";
545
558
  return t.alternate && (n = this.astToGrapesJS(t.alternate)), `
546
559
  <data-condition data-gjs-data-resolver='${JSON.stringify({ condition: e })}'>
547
- <data-condition-true-content>${s}</data-condition-true-content>
560
+ <data-condition-true-content>${r}</data-condition-true-content>
548
561
  <data-condition-false-content>${n}</data-condition-false-content>
549
562
  </data-condition>
550
563
  `;
@@ -556,44 +569,44 @@ class V {
556
569
  const e = t.init.declarations[0];
557
570
  if (e.id.type !== "Identifier")
558
571
  return this.addMessage("warning", "Unsupported for loop variable declaration id"), "";
559
- let s = "";
572
+ let r = "";
560
573
  if (e.init)
561
- s = this.getExpressionString(e.init);
574
+ r = this.getExpressionString(e.init);
562
575
  else
563
576
  return this.addMessage("warning", "For loop collection is undefined"), "";
564
- const n = e.id.name, r = n;
577
+ const n = e.id.name, a = n;
565
578
  this.collectionStack.push(n);
566
- const a = this.astToGrapesJS(t.body);
579
+ const o = this.astToGrapesJS(t.body);
567
580
  return this.collectionStack.pop(), `
568
581
  <data-collection data-gjs-data-resolver='${JSON.stringify({
569
- dataSource: { type: "data-variable", path: s },
570
- collectionId: r
582
+ dataSource: { type: "data-variable", path: r },
583
+ collectionId: a
571
584
  })}'>
572
585
  <data-collection-item>
573
- ${a}
586
+ ${o}
574
587
  </data-collection-item>
575
588
  </data-collection>
576
589
  `;
577
590
  }
578
591
  handleForEachStatement(t) {
579
- const e = this.getExpressionString(t.collection), s = t.itemIdentifier.name, n = s;
580
- this.collectionStack.push(s);
581
- const r = this.astToGrapesJS(t.body);
592
+ const e = this.getExpressionString(t.collection), r = t.itemIdentifier.name, n = r;
593
+ this.collectionStack.push(r);
594
+ const a = this.astToGrapesJS(t.body);
582
595
  return this.collectionStack.pop(), `
583
596
  <data-collection data-gjs-data-resolver='${JSON.stringify({
584
597
  dataSource: { type: "data-variable", path: e },
585
598
  collectionId: n
586
599
  })}'>
587
600
  <data-collection-item>
588
- ${r}
601
+ ${a}
589
602
  </data-collection-item>
590
603
  </data-collection>
591
604
  `;
592
605
  }
593
606
  handleBlockStatement(t) {
594
607
  let e = "";
595
- for (const s of t.body)
596
- e += this.astToGrapesJS(s);
608
+ for (const r of t.body)
609
+ e += this.astToGrapesJS(r);
597
610
  return e;
598
611
  }
599
612
  handleLiteral(t) {
@@ -602,9 +615,9 @@ class V {
602
615
  handleIdentifier(t) {
603
616
  let e = { path: t.name };
604
617
  if (this.collectionStack.length > 0) {
605
- const s = this.collectionStack[this.collectionStack.length - 1];
606
- t.name === s && (e = {
607
- collectionId: s,
618
+ const r = this.collectionStack[this.collectionStack.length - 1];
619
+ t.name === r && (e = {
620
+ collectionId: r,
608
621
  variableType: "currentItem"
609
622
  });
610
623
  }
@@ -613,18 +626,18 @@ class V {
613
626
  handleMemberExpression(t, e = {}) {
614
627
  let n = { path: this.getExpressionString(t), ...e };
615
628
  if (this.collectionStack.length > 0) {
616
- const r = this.collectionStack[this.collectionStack.length - 1];
617
- let a = t;
629
+ const a = this.collectionStack[this.collectionStack.length - 1];
630
+ let o = t;
618
631
  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(".");
632
+ for (; o.type === "MemberExpression"; )
633
+ o.property.type === "Identifier" && !o.computed ? i.unshift(o.property.name) : o.property.type === "Literal" && o.computed ? i.unshift(String(o.property.value)) : i.unshift(this.getExpressionString(o.property)), o = o.object;
634
+ if (o.type === "Identifier" && o.name === a) {
635
+ const l = i.join(".");
623
636
  n = {
624
637
  ...e,
625
- collectionId: r,
638
+ collectionId: a,
626
639
  variableType: "currentItem",
627
- path: c
640
+ path: l
628
641
  };
629
642
  }
630
643
  }
@@ -641,8 +654,8 @@ class V {
641
654
  handleCallExpression(t) {
642
655
  var e;
643
656
  if (t.callee.type === "Identifier" && t.callee.name === "include") {
644
- const s = ((e = t.arguments[0]) == null ? void 0 : e.type) === "Literal" ? String(t.arguments[0].value) : "";
645
- return this.addMessage("info", `Partial includes are not fully supported: ${s}`), "";
657
+ const r = ((e = t.arguments[0]) == null ? void 0 : e.type) === "Literal" ? String(t.arguments[0].value) : "";
658
+ return this.addMessage("info", `Partial includes are not fully supported: ${r}`), "";
646
659
  }
647
660
  return "";
648
661
  }
@@ -658,20 +671,20 @@ class V {
658
671
  ]
659
672
  };
660
673
  if (t.type === "MemberExpression") {
661
- let e = this.getExpressionString(t), s = "isTruthy";
662
- return e.startsWith("!!") ? (s = "isTruthy", e = e.slice(2)) : e.startsWith("!") && (s = "isFalsy", e = e.slice(1)), {
674
+ let e = this.getExpressionString(t), r = "isTruthy";
675
+ return e.startsWith("!!") ? (r = "isTruthy", e = e.slice(2)) : e.startsWith("!") && (r = "isFalsy", e = e.slice(1)), {
663
676
  logicalOperator: "and",
664
677
  statements: [
665
678
  {
666
679
  left: { type: "data-variable", path: e },
667
- operator: s
680
+ operator: r
668
681
  }
669
682
  ]
670
683
  };
671
684
  }
672
685
  if (t.type === "BinaryExpression" || t.type === "LogicalExpression") {
673
- const e = this.getConditionExpression(t.left), s = this.getConditionExpression(t.right);
674
- return `${e} ${t.operator} ${s}`;
686
+ const e = this.getConditionExpression(t.left), r = this.getConditionExpression(t.right);
687
+ return `${e} ${t.operator} ${r}`;
675
688
  }
676
689
  return t.type === "Literal" ? typeof t.value == "string" ? `'${t.value}'` : String(t.value ?? "") : this.getExpressionString(t);
677
690
  }
@@ -682,16 +695,16 @@ class V {
682
695
  case "Literal":
683
696
  return String(t.value ?? "");
684
697
  case "MemberExpression": {
685
- const e = this.getExpressionString(t.object), s = this.getExpressionString(t.property);
686
- return t.computed ? `${e}[${s}]` : `${e}.${s}`;
698
+ const e = this.getExpressionString(t.object), r = this.getExpressionString(t.property);
699
+ return t.computed ? `${e}[${r}]` : `${e}.${r}`;
687
700
  }
688
701
  case "BinaryExpression": {
689
- const e = this.getExpressionString(t.left), s = this.getExpressionString(t.right);
690
- return `${e} ${t.operator} ${s}`;
702
+ const e = this.getExpressionString(t.left), r = this.getExpressionString(t.right);
703
+ return `${e} ${t.operator} ${r}`;
691
704
  }
692
705
  case "LogicalExpression": {
693
- const e = this.getExpressionString(t.left), s = this.getExpressionString(t.right);
694
- return `${e} ${t.operator} ${s}`;
706
+ const e = this.getExpressionString(t.left), r = this.getExpressionString(t.right);
707
+ return `${e} ${t.operator} ${r}`;
695
708
  }
696
709
  default:
697
710
  return this.addMessage("warning", `Unsupported expression type for getExpressionString: ${t.type}`), "";
@@ -704,21 +717,21 @@ class V {
704
717
  });
705
718
  }
706
719
  }
707
- const G = "dataSourceEjs", q = m.startup, H = function(o, t = {}) {
708
- const e = W(o, new J()), s = _(o, {
720
+ const q = "dataSourceEjs", H = y.startup, K = function(s, t = {}) {
721
+ const e = F(s, new W()), r = J(s, {
709
722
  contains: "<%",
710
723
  importer: new V()
711
724
  });
712
- A({
713
- editor: o,
725
+ M({
726
+ editor: s,
714
727
  licenseKey: t.licenseKey,
715
- plan: q,
716
- pluginName: G,
728
+ plan: H,
729
+ pluginName: q,
717
730
  cleanup: () => {
718
- e(), s();
731
+ e(), r();
719
732
  }
720
733
  });
721
- }, K = B(H);
734
+ }, z = N(K);
722
735
  export {
723
- K as default
736
+ z as default
724
737
  };