@grapesjs/studio-sdk-plugins 1.0.23 → 1.0.24

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.
@@ -1,7 +1,7 @@
1
- import L from "handlebars/dist/cjs/handlebars";
2
- const C = "app.grapesjs.com", b = "app-stage.grapesjs.com", y = [
3
- C,
4
- b,
1
+ import C from "handlebars/dist/cjs/handlebars";
2
+ const S = "app.grapesjs.com", y = "app-stage.grapesjs.com", f = [
3
+ S,
4
+ y,
5
5
  "localhost",
6
6
  "127.0.0.1",
7
7
  ".local-credentialless.webcontainer.io",
@@ -10,82 +10,82 @@ const C = "app.grapesjs.com", b = "app-stage.grapesjs.com", y = [
10
10
  // For stackblitz.com demos
11
11
  "-sandpack.codesandbox.io"
12
12
  // For Sandpack demos
13
- ], k = "license:check:start", T = "license:check:end", N = () => typeof window < "u", _ = ({ isDev: r, isStage: t }) => `${r ? "" : `https://${t ? b : C}`}/api`, w = () => {
14
- const r = N() && window.location.hostname;
15
- return !!r && (y.includes(r) || y.some((t) => r.endsWith(t)));
13
+ ], I = "license:check:start", k = "license:check:end", v = () => typeof window < "u", N = ({ isDev: a, isStage: t }) => `${a ? "" : `https://${t ? y : S}`}/api`, _ = () => {
14
+ const a = v() && window.location.hostname;
15
+ return !!a && (f.includes(a) || f.some((t) => a.endsWith(t)));
16
16
  };
17
- async function H({
18
- path: r,
17
+ async function L({
18
+ path: a,
19
19
  baseApiUrl: t,
20
20
  method: e = "GET",
21
21
  headers: n = {},
22
- params: a,
23
- body: s
22
+ params: s,
23
+ body: i
24
24
  }) {
25
- const o = `${t || _({ isDev: !1, isStage: !1 })}${r}`, c = {
25
+ const o = `${t || N({ isDev: !1, isStage: !1 })}${a}`, c = {
26
26
  method: e,
27
27
  headers: {
28
28
  "Content-Type": "application/json",
29
29
  ...n
30
30
  }
31
31
  };
32
- s && (c.body = JSON.stringify(s));
33
- const h = a ? new URLSearchParams(a).toString() : "", l = h ? `?${h}` : "", u = await fetch(`${o}${l}`, c);
32
+ i && (c.body = JSON.stringify(i));
33
+ const h = s ? new URLSearchParams(s).toString() : "", l = h ? `?${h}` : "", u = await fetch(`${o}${l}`, c);
34
34
  if (!u.ok)
35
35
  throw new Error(`HTTP error! status: ${u.status}`);
36
36
  return u.json();
37
37
  }
38
- var d = /* @__PURE__ */ ((r) => (r.free = "free", r.startup = "startup", r.business = "business", r.enterprise = "enterprise", r))(d || {});
38
+ var p = /* @__PURE__ */ ((a) => (a.free = "free", a.startup = "startup", a.business = "business", a.enterprise = "enterprise", a))(p || {});
39
39
  const P = {
40
- [d.free]: 0,
41
- [d.startup]: 10,
42
- [d.business]: 20,
43
- [d.enterprise]: 30
40
+ [p.free]: 0,
41
+ [p.startup]: 10,
42
+ [p.business]: 20,
43
+ [p.enterprise]: 30
44
44
  };
45
- function M(r) {
46
- const t = r;
47
- return t.init = (e) => (n) => r(n, e), t;
45
+ function T(a) {
46
+ const t = a;
47
+ return t.init = (e) => (n) => a(n, e), t;
48
48
  }
49
- const O = (r) => /* @__PURE__ */ M(r);
50
- async function R({
51
- editor: r,
49
+ const w = (a) => /* @__PURE__ */ T(a);
50
+ async function O({
51
+ editor: a,
52
52
  plan: t,
53
53
  pluginName: e,
54
54
  licenseKey: n,
55
- cleanup: a
55
+ cleanup: s
56
56
  }) {
57
- let s = "", i = !1;
58
- const o = w(), c = (l) => {
59
- console.warn("Cleanup plugin:", e, "Reason:", l), a();
57
+ let i = "", r = !1;
58
+ const o = _(), c = (l) => {
59
+ console.warn("Cleanup plugin:", e, "Reason:", l), s();
60
60
  }, h = (l = {}) => {
61
- var $;
62
- const { error: u, sdkLicense: E } = l, m = ($ = l.plan) == null ? void 0 : $.category;
63
- if (!(E || l.license) || u)
61
+ var g;
62
+ const { error: u, sdkLicense: b } = l, m = (g = l.plan) == null ? void 0 : g.category;
63
+ if (!(b || l.license) || u)
64
64
  c(u || "Invalid license");
65
65
  else if (m) {
66
- const v = P[t], I = P[m];
67
- v > I && c({ pluginRequiredPlan: t, licensePlan: m });
66
+ const x = P[t], E = P[m];
67
+ x > E && c({ pluginRequiredPlan: t, licensePlan: m });
68
68
  }
69
69
  };
70
- r.on(k, (l) => {
71
- s = l == null ? void 0 : l.baseApiUrl, i = !0;
72
- }), r.on(T, (l) => {
70
+ a.on(I, (l) => {
71
+ i = l == null ? void 0 : l.baseApiUrl, r = !0;
72
+ }), a.on(k, (l) => {
73
73
  h(l);
74
74
  }), setTimeout(async () => {
75
- if (!i) {
75
+ if (!r) {
76
76
  if (o) return;
77
77
  if (n) {
78
- const l = await A({ licenseKey: n, pluginName: e, baseApiUrl: s });
78
+ const l = await A({ licenseKey: n, pluginName: e, baseApiUrl: i });
79
79
  l && h(l);
80
80
  } else
81
81
  c("The `licenseKey` option not provided");
82
82
  }
83
83
  }, 2e3);
84
84
  }
85
- async function A(r) {
86
- const { licenseKey: t, pluginName: e, baseApiUrl: n } = r;
85
+ async function A(a) {
86
+ const { licenseKey: t, pluginName: e, baseApiUrl: n } = a;
87
87
  try {
88
- return (await H({
88
+ return (await L({
89
89
  baseApiUrl: n,
90
90
  path: `/sdk/${t || "na"}`,
91
91
  method: "POST",
@@ -94,147 +94,24 @@ async function A(r) {
94
94
  pn: e
95
95
  }
96
96
  })).result || {};
97
- } catch (a) {
98
- return console.error("Error during SDK license check:", a), !1;
97
+ } catch (s) {
98
+ return console.error("Error during SDK license check:", s), !1;
99
99
  }
100
100
  }
101
- var p = /* @__PURE__ */ ((r) => (r.variable = "data-variable", r.condition = "data-condition", r.conditionTrue = "data-condition-true-content", r.conditionFalse = "data-condition-false-content", r.collection = "data-collection", r.collectionItem = "data-collection-item", r))(p || {});
102
- class D {
103
- constructor(t) {
104
- this.strategy = t, this.requiredHelpers = /* @__PURE__ */ new Set(), this.helperLibrary = {};
105
- }
106
- registerHelper(t) {
107
- this.helperLibrary[t] && this.requiredHelpers.add(t);
108
- }
109
- generateVariable(t) {
110
- return this.strategy.getVariableSyntax(t);
111
- }
112
- generateCollectionStart(t) {
113
- return this.registerHelper("slice"), this.strategy.getCollectionStartSyntax(t);
114
- }
115
- generateCollectionEnd() {
116
- return this.strategy.getCollectionEndSyntax();
117
- }
118
- generateConditionalStart(t) {
119
- return this.strategy.getConditionalStartSyntax(t);
120
- }
121
- generateConditionElse() {
122
- return this.strategy.getConditionElseSyntax();
123
- }
124
- generateConditionalEnd() {
125
- return this.strategy.getConditionalEndSyntax();
126
- }
127
- reset() {
128
- this.requiredHelpers.clear();
129
- }
130
- }
131
- function j(r) {
132
- return typeof r == "object" && r.type === p.variable;
133
- }
134
- function g({
135
- component: r,
136
- value: t,
137
- getCustomPath: e
138
- }) {
139
- if (j(t) && !t.collectionId && e) {
140
- const n = t.path ?? "", a = n.split(".");
141
- return {
142
- ...t,
143
- path: e({ component: r, path: n, paths: a })
144
- };
145
- }
146
- return t;
147
- }
148
- const V = (r) => {
149
- f(r, p.variable, {
150
- toHTML(t) {
151
- var i;
152
- const e = this.tagName, n = this.__attrToString(t), a = (i = this.getDataResolver) == null ? void 0 : i.call(this), s = g({
153
- component: this,
154
- value: a,
155
- getCustomPath: t == null ? void 0 : t.getCustomPath
156
- });
157
- return `<${e}${n ? ` ${n}` : ""}>${t.exporter.generateVariable(s)}</${e}>`;
158
- }
159
- }), f(r, p.condition, {
160
- toHTML(t) {
161
- var l, u;
162
- const e = t.exporter, n = t == null ? void 0 : t.getCustomPath, a = this.components(), [s, i] = (a == null ? void 0 : a.models) ?? [], o = (l = this.getDataResolver) == null ? void 0 : l.call(this), c = ((u = this.resolveCondition) == null ? void 0 : u.call(this, o == null ? void 0 : o.condition, n)) ?? {};
163
- let h = "";
164
- return i && (h = `
165
- ${e.generateConditionElse()}
166
- ${i.toHTML(t) ?? ""}`), `
167
- ${e.generateConditionalStart(c)}
168
- ${(s == null ? void 0 : s.toHTML(t)) ?? ""}${h}
169
- ${e.generateConditionalEnd()}
170
- `;
171
- },
172
- resolveCondition(t, e) {
173
- var a, s;
174
- if (!t) return {};
175
- if (t.operator === "and" || t.operator === "or")
176
- return {
177
- operator: t.operator,
178
- statements: ((s = (a = t.statements) == null ? void 0 : a.map) == null ? void 0 : s.call(a, (i) => {
179
- var o;
180
- return ((o = this.resolveCondition) == null ? void 0 : o.call(this, i, e)) ?? {};
181
- })) ?? []
182
- };
183
- const n = { component: this, getCustomPath: e };
184
- return {
185
- ...t,
186
- left: g({ ...n, value: t.left }),
187
- right: g({ ...n, value: t.right })
188
- };
189
- }
190
- }), f(r, p.collection, {
191
- toHTML(t) {
192
- const e = t.exporter, n = this.tagName, a = this.__attrToString(t), s = this.getDataResolver(), i = {
193
- ...s,
194
- dataSource: g({
195
- component: this,
196
- value: s == null ? void 0 : s.dataSource,
197
- getCustomPath: t == null ? void 0 : t.getCustomPath
198
- })
199
- }, o = this.components().at(0);
200
- return `
201
- <${n}${a ? ` ${a}` : ""}>${e.generateCollectionStart(i)}
202
- ${(o == null ? void 0 : o.toHTML(t)) ?? ""}
203
- ${e.generateCollectionEnd()}</${n}>
204
- `;
205
- }
206
- });
207
- }, f = (r, t, e) => {
208
- const n = r.Components.getType(t);
209
- if (!n) {
210
- console.warn(`Component type ${t} not found`);
211
- return;
212
- }
213
- const { model: a } = n;
214
- r.Components.addType(t, {
215
- model: {
216
- ...e,
217
- toHTML(s = {}) {
218
- var o;
219
- const { exporter: i } = s;
220
- return i ? i.export ? i.export({ component: this }) : ((o = e.toHTML) == null ? void 0 : o.call(this, s)) ?? "" : a.prototype.toHTML.call(this, s) ?? "";
221
- }
222
- }
223
- });
224
- }, B = (r, t) => (r.config.optsHtml = {
225
- ...r.config.optsHtml,
226
- exporter: new D(t)
227
- }, V(r), () => {
228
- r.config.optsHtml.exporter = void 0;
229
- }), U = (r, t) => {
230
- const e = (a) => {
231
- const { input: s } = a, { contains: i } = t;
232
- (!i || s.includes(i)) && (a.input = t.importer.import(s));
233
- }, n = r.Parser.events.htmlBefore;
234
- return r.on(n, e), () => {
235
- r.off(n, e);
101
+ const j = (a, t) => (a.config.optsHtml = {
102
+ ...a.config.optsHtml,
103
+ exporter: t
104
+ }, () => {
105
+ a.config.optsHtml.exporter = void 0;
106
+ }), H = (a, t) => {
107
+ const e = (s) => {
108
+ const { input: i } = s, { contains: r } = t;
109
+ (!r || i.includes(r)) && (s.input = t.importer.import(i));
110
+ }, n = a.Parser.events.htmlBefore;
111
+ return a.on(n, e), () => {
112
+ a.off(n, e);
236
113
  };
237
- }, x = {
114
+ }, $ = {
238
115
  equals: "equals",
239
116
  isTruthy: "isTruthy",
240
117
  isFalsy: "isFalsy",
@@ -247,71 +124,72 @@ ${e.generateCollectionEnd()}</${n}>
247
124
  isNumber: "isNumber",
248
125
  isBoolean: "isBoolean",
249
126
  isDefaultValue: "isDefaultValue"
250
- }, W = {
127
+ }, M = {
251
128
  ">": "numGt",
252
129
  "<": "numLt",
253
130
  ">=": "numGte",
254
131
  "<=": "numLte",
255
132
  "=": "numEq",
256
133
  "!=": "numNeq"
257
- }, q = {
134
+ }, U = {
258
135
  contains: "strContains",
259
136
  startsWith: "strStartsWith",
260
137
  endsWith: "strEndsWith",
261
138
  equalsIgnoreCase: "strEqualsIgnoreCase",
262
139
  trimEquals: "strTrimEquals"
263
- }, G = {
264
- ...x,
265
- ...W,
266
- ...q
140
+ }, B = {
141
+ ...$,
142
+ ...M,
143
+ ...U
267
144
  };
268
- class F {
145
+ class D {
269
146
  getHelperId(t) {
270
- return G[t] || t;
147
+ return B[t] || t;
271
148
  }
272
149
  getFullPath({ collectionId: t, path: e }) {
273
150
  let n = e;
274
151
  return t && (n = [this._sanitizeVariableName(t), e].filter(Boolean).join(".")), n || "";
275
152
  }
276
- getVariableSyntax(t) {
153
+ getVariableSyntax({ dataResolver: t }) {
277
154
  const { defaultValue: e } = t, n = this.getFullPath(t);
278
155
  return e ? `{{#if ${n}}}{{{${n}}}}{{else}}${e}{{/if}}` : `{{{${n}}}}`;
279
156
  }
280
- getCollectionStartSyntax(t) {
281
- const { collectionId: e, dataSource: n } = t, a = n == null ? void 0 : n.path;
282
- let s = "";
157
+ getCollectionStartSyntax({ dataResolver: t }) {
158
+ const { collectionId: e, dataSource: n } = t, s = n == null ? void 0 : n.path;
159
+ let i = "";
283
160
  if (t.startIndex !== void 0 || t.endIndex !== void 0) {
284
161
  const h = t.startIndex ?? 0, l = t.endIndex !== void 0 ? t.endIndex : "";
285
- l !== "" ? s = ` (slice ${a} ${h} ${l})` : s = ` (slice ${a} ${h})`;
162
+ l !== "" ? i = ` (slice ${s} ${h} ${l})` : i = ` (slice ${s} ${h})`;
286
163
  }
287
164
  const o = ` as |${this._sanitizeVariableName(e)}|`;
288
- return `{{#each ${s || a}${o}}}`;
165
+ return `{{#each ${i || s}${o}}}`;
289
166
  }
290
167
  getCollectionEndSyntax() {
291
168
  return "{{/each}}";
292
169
  }
293
- getConditionalStartSyntax(t) {
294
- if (!t) return "";
295
- const e = t, n = t;
296
- if (n.statements && n.logicalOperator === "and" || n.logicalOperator === "or") {
297
- const { statements: a } = n, s = n.logicalOperator, i = a.map((c) => this._parseCondition(c)).join(" ");
298
- return `{{#if ${a.length > 1 ? `(${s} ${i})` : i}}}`;
170
+ getConditionalStartSyntax({ dataResolver: t }) {
171
+ const e = t.condition;
172
+ if (!e) return "";
173
+ const n = e, s = e;
174
+ if (s.statements && s.logicalOperator === "and" || s.logicalOperator === "or") {
175
+ const { statements: i } = s, r = s.logicalOperator, o = i.map((h) => this._parseCondition(h)).join(" ");
176
+ return `{{#if ${i.length > 1 ? `(${r} ${o})` : o}}}`;
299
177
  } else
300
- return `{{#if ${this._parseCondition(e)}}}`;
178
+ return `{{#if ${this._parseCondition(n)}}}`;
301
179
  }
302
180
  _parseCondition(t) {
303
181
  if (!t) return "";
304
182
  const e = t, n = t;
305
183
  if (n.statements && n.logicalOperator === "and" || n.logicalOperator === "or") {
306
- const { statements: a } = n, s = n.logicalOperator, i = n.statements.map((o) => this._parseCondition(o)).join(" ");
307
- return a.length > 1 ? `(${s} ${i})` : i;
184
+ const { statements: s } = n, i = n.logicalOperator, r = n.statements.map((o) => this._parseCondition(o)).join(" ");
185
+ return s.length > 1 ? `(${i} ${r})` : r;
308
186
  } else {
309
- const a = e.operator, s = this.getHelperId(a), i = this._parseValue(e.left), o = this._parseValue(e.right);
310
- return this.getExpressionStr(s, i, o);
187
+ const s = e.operator, i = this.getHelperId(s), r = this._parseValue(e.left), o = this._parseValue(e.right);
188
+ return this.getExpressionStr(i, r, o);
311
189
  }
312
190
  }
313
191
  getExpressionStr(t, e, n) {
314
- return x[t] ? t === "isTruthy" ? e : t === "isFalsy" ? `!${e}` : `${t} ${e}` : `(${t} ${e} ${n})`;
192
+ return $[t] ? t === "isTruthy" ? e : t === "isFalsy" ? `!${e}` : `${t} ${e}` : `(${t} ${e} ${n})`;
315
193
  }
316
194
  _parseValue(t) {
317
195
  return typeof t == "object" ? this.getFullPath(t) : typeof t == "string" ? `'${t.replace(/'/g, "\\'")}'` : String(t);
@@ -326,7 +204,7 @@ class F {
326
204
  return "{{/if}}";
327
205
  }
328
206
  }
329
- class J {
207
+ class R {
330
208
  constructor() {
331
209
  this.messages = [], this.collectionStack = [];
332
210
  }
@@ -337,11 +215,11 @@ class J {
337
215
  }
338
216
  parse(t) {
339
217
  try {
340
- return L.parse(t);
218
+ return C.parse(t);
341
219
  } catch (e) {
342
220
  if (e instanceof Error && e.message.includes("Parse error")) {
343
- const n = e.message.match(/line (\d+)/), a = n ? parseInt(n[1]) : 0, s = e.message.match(/column (\d+)/), i = s ? parseInt(s[1]) : 0;
344
- throw new Error(`Handlebars syntax error at line ${a}, column ${i}: ${e.message}`);
221
+ const n = e.message.match(/line (\d+)/), s = n ? parseInt(n[1]) : 0, i = e.message.match(/column (\d+)/), r = i ? parseInt(i[1]) : 0;
222
+ throw new Error(`Handlebars syntax error at line ${s}, column ${r}: ${e.message}`);
345
223
  }
346
224
  throw e;
347
225
  }
@@ -379,8 +257,8 @@ class J {
379
257
  return t.value || "";
380
258
  }
381
259
  handleMustacheStatement(t, e = {}) {
382
- const n = this.getExpressionString(t.path), a = { ...e };
383
- return this.collectionStack.length > 0 ? this.processPathWithCollectionContext(n, a) : a.path = n, `<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`;
260
+ const n = this.getExpressionString(t.path), s = { ...e };
261
+ return this.collectionStack.length > 0 ? this.processPathWithCollectionContext(n, s) : s.path = n, `<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`;
384
262
  }
385
263
  processPathWithCollectionContext(t, e) {
386
264
  t.startsWith("@") ? this.handleDirectCollectionReference(t, e) : this.handleRelativePathReference(t, e);
@@ -390,46 +268,46 @@ class J {
390
268
  this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length - 1], t, e);
391
269
  return;
392
270
  }
393
- const [n, ...a] = t.substring(1).split("/"), s = a.join(".");
394
- this.collectionStack.includes(n) ? this.setCurrentItemResolver(n, s, e) : this.handleParentReferenceFallback(t, e);
271
+ const [n, ...s] = t.substring(1).split("/"), i = s.join(".");
272
+ this.collectionStack.includes(n) ? this.setCurrentItemResolver(n, i, e) : this.handleParentReferenceFallback(t, e);
395
273
  }
396
274
  isSpecialIterationVariable(t) {
397
275
  return ["index", "@index", "key", "@key"].includes(t);
398
276
  }
399
277
  setSpecialVariableResolver(t, e, n) {
400
278
  n.collectionId = t;
401
- const a = {
279
+ const s = {
402
280
  index: "currentIndex",
403
281
  "@index": "currentIndex",
404
282
  key: "currentKey",
405
283
  "@key": "currentKey"
406
284
  };
407
- n.variableType = a[e];
285
+ n.variableType = s[e];
408
286
  }
409
287
  setCurrentItemResolver(t, e, n) {
410
288
  n.collectionId = t, n.variableType = "currentItem", e && (n.path = e);
411
289
  }
412
290
  handleRelativePathReference(t, e) {
413
- const n = S(t), { parentLevel: a, remainingPathParts: s } = this.calculateParentLevel(n), i = s.join("."), o = this.collectionStack.length - 1 - a;
414
- o >= 0 && o < this.collectionStack.length ? this.resolveRelativePath(i, o, e) : e.path = s.join(".");
291
+ const n = d(t), { parentLevel: s, remainingPathParts: i } = this.calculateParentLevel(n), r = i.join("."), o = this.collectionStack.length - 1 - s;
292
+ o >= 0 && o < this.collectionStack.length ? this.resolveRelativePath(r, o, e) : e.path = i.join(".");
415
293
  }
416
294
  calculateParentLevel(t) {
417
- const e = this.collectionStack.findLastIndex((s) => s === t[0]);
295
+ const e = this.collectionStack.findLastIndex((i) => i === t[0]);
418
296
  if (e !== -1)
419
297
  return { parentLevel: this.collectionStack.length - 1 - e, remainingPathParts: t.slice(1) };
420
298
  let n = 0;
421
- const a = [...t];
422
- for (; a[0] === ".."; )
423
- n++, a.shift();
424
- return { parentLevel: n, remainingPathParts: a };
299
+ const s = [...t];
300
+ for (; s[0] === ".."; )
301
+ n++, s.shift();
302
+ return { parentLevel: n, remainingPathParts: s };
425
303
  }
426
304
  resolveRelativePath(t, e, n) {
427
- const a = this.collectionStack[e];
428
- n.collectionId = a, n.variableType = "currentItem", t !== "this" && (n.path = t.startsWith("this.") ? t.split(".").slice(1).join(".") : t);
305
+ const s = this.collectionStack[e];
306
+ n.collectionId = s, n.variableType = "currentItem", t !== "this" && (n.path = t.startsWith("this.") ? t.split(".").slice(1).join(".") : t);
429
307
  }
430
308
  handleParentReferenceFallback(t, e) {
431
- const n = S(t), { parentLevel: a, remainingPathParts: s } = this.calculateParentLevel(n), i = s.join("."), o = this.collectionStack.length - 1 - a;
432
- o >= 0 && o < this.collectionStack.length ? this.resolveRelativePath(i, o, e) : e.path = s.join(".");
309
+ const n = d(t), { parentLevel: s, remainingPathParts: i } = this.calculateParentLevel(n), r = i.join("."), o = this.collectionStack.length - 1 - s;
310
+ o >= 0 && o < this.collectionStack.length ? this.resolveRelativePath(r, o, e) : e.path = i.join(".");
433
311
  }
434
312
  handleBlockStatement(t) {
435
313
  const e = t.path.original;
@@ -444,7 +322,7 @@ class J {
444
322
  }
445
323
  }
446
324
  handleConditionalBlock(t, e) {
447
- const s = {
325
+ const i = {
448
326
  logicalOperator: "and",
449
327
  statements: [
450
328
  {
@@ -452,26 +330,26 @@ class J {
452
330
  operator: e === "unless" ? "isFalsy" : "isTruthy"
453
331
  }
454
332
  ]
455
- }, i = this.handleProgram(t.program), o = t.inverse ? this.handleProgram(t.inverse) : "";
333
+ }, r = this.handleProgram(t.program), o = t.inverse ? this.handleProgram(t.inverse) : "";
456
334
  return `
457
- <data-condition data-gjs-data-resolver='${JSON.stringify({ condition: s })}'>
458
- <data-condition-true-content>${i}</data-condition-true-content>
335
+ <data-condition data-gjs-data-resolver='${JSON.stringify({ condition: i })}'>
336
+ <data-condition-true-content>${r}</data-condition-true-content>
459
337
  <data-condition-false-content>${o}</data-condition-false-content>
460
338
  </data-condition>
461
339
  `;
462
340
  }
463
341
  handleEachBlock(t) {
464
- var s, i, o;
342
+ var i, r, o;
465
343
  const e = this.getExpressionString(t.params[0]);
466
344
  let n;
467
- t.params.length >= 3 && t.params[1] === "as" && ((s = t.params[2]) == null ? void 0 : s.type) === "PathExpression" ? n = t.params[2].original : (o = (i = t.program) == null ? void 0 : i.blockParams) != null && o.length ? n = t.program.blockParams[0] : n = `collection-${Math.random().toString(36).substring(2, 10)}`, this.collectionStack.push(n);
468
- const a = this.handleProgram(t.program);
345
+ t.params.length >= 3 && t.params[1] === "as" && ((i = t.params[2]) == null ? void 0 : i.type) === "PathExpression" ? n = t.params[2].original : (o = (r = t.program) == null ? void 0 : r.blockParams) != null && o.length ? n = t.program.blockParams[0] : n = `collection-${Math.random().toString(36).substring(2, 10)}`, this.collectionStack.push(n);
346
+ const s = this.handleProgram(t.program);
469
347
  return this.collectionStack.pop(), `
470
348
  <data-collection data-gjs-data-resolver='${JSON.stringify({
471
349
  dataSource: { type: "data-variable", path: e },
472
350
  collectionId: n
473
351
  })}'>
474
- <data-collection-item>${a}</data-collection-item>
352
+ <data-collection-item>${s}</data-collection-item>
475
353
  </data-collection>
476
354
  `;
477
355
  }
@@ -481,12 +359,12 @@ class J {
481
359
  handleElementNode(t) {
482
360
  let e = "";
483
361
  if (t.attributes)
484
- for (const a of t.attributes)
485
- a.value.type === "TextNode" ? e += ` ${a.name}="${a.value.chars}"` : (this.addMessage("warning", `Complex attribute values not fully supported: ${a.name}`, t.loc), e += ` ${a.name}="${this.getExpressionString(a.value)}"`);
362
+ for (const s of t.attributes)
363
+ s.value.type === "TextNode" ? e += ` ${s.name}="${s.value.chars}"` : (this.addMessage("warning", `Complex attribute values not fully supported: ${s.name}`, t.loc), e += ` ${s.name}="${this.getExpressionString(s.value)}"`);
486
364
  let n = "";
487
365
  if (t.children)
488
- for (const a of t.children)
489
- n += this.astToGrapesJS(a);
366
+ for (const s of t.children)
367
+ n += this.astToGrapesJS(s);
490
368
  return `<${t.tag}${e}>${n}</${t.tag}>`;
491
369
  }
492
370
  handleTextNode(t) {
@@ -510,50 +388,50 @@ class J {
510
388
  });
511
389
  }
512
390
  }
513
- const S = (r) => {
514
- if (r == null || r === "")
391
+ const d = (a) => {
392
+ if (a == null || a === "")
515
393
  return [];
516
- if (r === ".")
394
+ if (a === ".")
517
395
  return ["this"];
518
- if (r === ".." || r === "../")
396
+ if (a === ".." || a === "../")
519
397
  return [".."];
520
- if (r.startsWith("../")) {
521
- const i = r.substring(3);
522
- return ["..", ...S(i)];
398
+ if (a.startsWith("../")) {
399
+ const r = a.substring(3);
400
+ return ["..", ...d(r)];
523
401
  }
524
402
  const t = [];
525
- let e = 0, n = r.replace(
403
+ let e = 0, n = a.replace(
526
404
  /\[(?:(['"])(.*?)\1|([^\]]*))\]/g,
527
- (i, o, c, h) => {
405
+ (r, o, c, h) => {
528
406
  const l = c !== void 0 ? c : h || "";
529
407
  return t[e] = l, `__HANDLEBARS_PLACEHOLDER_${e++}__`;
530
408
  }
531
409
  );
532
410
  n = n.replace(/\//g, ".");
533
- const a = n.split("."), s = [];
534
- for (const i of a) {
535
- const o = /^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(i);
411
+ const s = n.split("."), i = [];
412
+ for (const r of s) {
413
+ const o = /^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(r);
536
414
  if (o) {
537
415
  const c = parseInt(o[1], 10);
538
- s.push(t[c]);
539
- } else i !== "" && s.push(i);
416
+ i.push(t[c]);
417
+ } else r !== "" && i.push(r);
540
418
  }
541
- return s;
542
- }, K = "dataSourceHandlebars", z = d.startup, Y = function(r, t = {}) {
543
- const e = B(r, new F()), n = U(r, {
419
+ return i;
420
+ }, W = "dataSourceHandlebars", V = p.startup, G = function(a, t = {}) {
421
+ const e = j(a, new D()), n = H(a, {
544
422
  contains: "{{",
545
- importer: new J()
423
+ importer: new R()
546
424
  });
547
- R({
548
- editor: r,
425
+ O({
426
+ editor: a,
549
427
  licenseKey: t.licenseKey,
550
- plan: z,
551
- pluginName: K,
428
+ plan: V,
429
+ pluginName: W,
552
430
  cleanup: () => {
553
431
  e(), n();
554
432
  }
555
433
  });
556
- }, X = O(Y);
434
+ }, J = w(G);
557
435
  export {
558
- X as default
436
+ J as default
559
437
  };