@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,9 +1,9 @@
1
- import v from "handlebars/dist/cjs/handlebars";
2
- const y = "app.grapesjs.com", $ = "app-stage.grapesjs.com", C = "app2.grapesjs.com", N = "app-stage2.grapesjs.com", P = [
3
- y,
4
- C,
1
+ import T from "handlebars/dist/cjs/handlebars";
2
+ const $ = "app.grapesjs.com", x = "app-stage.grapesjs.com", k = "app2.grapesjs.com", A = "app-stage2.grapesjs.com", b = [
5
3
  $,
6
- N,
4
+ k,
5
+ x,
6
+ A,
7
7
  "localhost",
8
8
  "127.0.0.1",
9
9
  ".local-credentialless.webcontainer.io",
@@ -12,113 +12,126 @@ const y = "app.grapesjs.com", $ = "app-stage.grapesjs.com", C = "app2.grapesjs.c
12
12
  // For stackblitz.com demos
13
13
  "-sandpack.codesandbox.io"
14
14
  // For Sandpack demos
15
- ], _ = "license:check:start", k = "license:check:end", T = () => typeof window < "u", w = ({
16
- isDev: a,
15
+ ], L = "license:check:end", N = () => typeof window < "u", R = ({
16
+ isDev: e,
17
17
  isStage: t,
18
- isPlatform: e
19
- }) => `${a ? "" : `https://${t ? $ : y}`}/${e ? "platform-api" : "api"}`, O = () => {
20
- const a = T() && window.location.hostname;
21
- return !!a && (P.includes(a) || P.some((t) => a.endsWith(t)));
18
+ isPlatform: s
19
+ }) => `${e ? "" : `https://${t ? x : $}`}/${s ? "platform-api" : "api"}`, O = () => {
20
+ const e = N() && window.location.hostname;
21
+ return !!e && (b.includes(e) || b.some((t) => e.endsWith(t)));
22
22
  };
23
- async function A({
24
- path: a,
23
+ async function _({
24
+ path: e,
25
25
  baseApiUrl: t,
26
- method: e = "GET",
26
+ method: s = "GET",
27
27
  headers: n = {},
28
- params: s,
29
- body: i
28
+ params: a,
29
+ body: r
30
30
  }) {
31
- const l = `${t || w({ isDev: !1, isStage: !1 })}${a}`, u = {
32
- method: e,
31
+ const i = `${t || R({ isDev: !1, isStage: !1 })}${e}`, c = {
32
+ method: s,
33
33
  headers: {
34
34
  "Content-Type": "application/json",
35
35
  ...n
36
36
  }
37
37
  };
38
- i && (u.body = JSON.stringify(i));
39
- const c = s ? new URLSearchParams(s).toString() : "", h = c ? `?${c}` : "", o = await fetch(`${l}${h}`, u);
40
- if (!o.ok)
41
- throw new Error(`HTTP error! status: ${o.status}`);
42
- return o.json();
38
+ r && (c.body = JSON.stringify(r));
39
+ const u = a ? new URLSearchParams(a).toString() : "", h = u ? `?${u}` : "", l = await fetch(`${i}${h}`, c);
40
+ if (!l.ok)
41
+ throw new Error(`HTTP error! status: ${l.status}`);
42
+ return l.json();
43
43
  }
44
- var p = /* @__PURE__ */ ((a) => (a.free = "free", a.startup = "startup", a.business = "business", a.enterprise = "enterprise", a))(p || {});
45
- const S = {
44
+ var p = /* @__PURE__ */ ((e) => (e.free = "free", e.startup = "startup", e.business = "business", e.enterprise = "enterprise", e))(p || {}), d = /* @__PURE__ */ ((e) => (e.toastAdd = "studio:toastAdd", e.toastRemove = "studio:toastRemove", e.dialogOpen = "studio:dialogOpen", e.dialogClose = "studio:dialogClose", e.dialogExportCode = "studio:dialogExportCode", e.dialogImportCode = "studio:dialogImportCode", e.sidebarLeftSet = "studio:sidebarLeft:set", e.sidebarLeftGet = "studio:sidebarLeft:get", e.sidebarLeftToggle = "studio:sidebarLeft:toggle", e.sidebarRightSet = "studio:sidebarRight:set", e.sidebarRightGet = "studio:sidebarRight:get", e.sidebarRightToggle = "studio:sidebarRight:toggle", e.sidebarTopSet = "studio:sidebarTop:set", e.sidebarTopGet = "studio:sidebarTop:get", e.sidebarTopToggle = "studio:sidebarTop:toggle", e.sidebarBottomSet = "studio:sidebarBottom:set", e.sidebarBottomGet = "studio:sidebarBottom:get", e.sidebarBottomToggle = "studio:sidebarBottom:toggle", e.symbolAdd = "studio:symbolAdd", e.symbolDetach = "studio:symbolDetach", e.symbolOverride = "studio:symbolOverride", e.symbolPropagateStyles = "studio:propagateStyles", e.getPagesConfig = "studio:getPagesConfig", e.setPagesConfig = "studio:setPagesConfig", e.getPageSettings = "studio:getPageSettings", e.setPageSettings = "studio:setPageSettings", e.clearPage = "studio:clearPage", e.projectFiles = "studio:projectFiles", e.validateCode = "studio:validateCode", e.canvasReload = "studio:canvasReload", e.getBlocksPanel = "studio:getBlocksPanel", e.setBlocksPanel = "studio:setBlocksPanel", e.getStateContextMenu = "studio:getStateContextMenu", e.setStateContextMenu = "studio:setStateContextMenu", e.contextMenuComponent = "studio:contextMenuComponent", e.layoutAdd = "studio:layoutAdd", e.layoutRemove = "studio:layoutRemove", e.layoutToggle = "studio:layoutToggle", e.layoutUpdate = "studio:layoutUpdate", e.layoutGet = "studio:layoutGet", e.layoutConfigGet = "studio:layoutConfigGet", e.layoutConfigSet = "studio:layoutConfigSet", e.layoutComponentAdd = "studio:layoutComponentAdd", e.layoutComponentGet = "studio:layoutComponentGet", e.layoutComponentRemove = "studio:layoutComponentRemove", e.layoutComponentRender = "studio:layoutComponentRender", e.getStateTheme = "studio:getStateTheme", e.setStateTheme = "studio:setStateTheme", e.settings = "studio:settings", e.assetProviderGet = "studio:assetProviderGet", e.assetProviderAdd = "studio:assetProviderAdd", e.assetProviderRemove = "studio:assetProviderRemove", e.fontGet = "studio:fontGet", e.fontAdd = "studio:fontAdd", e.fontRemove = "studio:fontRemove", e.fontManagerOpen = "studio:fontManagerOpen", e.menuFontLoad = "studio:menuFontLoad", e.toggleStateDataSource = "studio:toggleStateDataSource", e.getStateDataSource = "studio:getStateDataSource", e.dataSourceSetGlobalData = "studio:dataSourceSetGlobalData", e.dataSourceSetImporter = "studio:dataSourceSetImporter", e.dataSourceSetExporter = "studio:dataSourceSetExporter", e.setDragAbsolute = "studio:setDragAbsolute", e))(d || {});
45
+ const m = {
46
46
  [p.free]: 0,
47
47
  [p.startup]: 10,
48
48
  [p.business]: 20,
49
49
  [p.enterprise]: 30
50
50
  };
51
- function L(a) {
52
- const t = a;
53
- return t.init = (e) => (n) => a(n, e), t;
51
+ function w(e) {
52
+ const t = e;
53
+ return t.init = (s) => (n) => e(n, s), t;
54
54
  }
55
- const j = (a) => /* @__PURE__ */ L(a);
56
- async function D({
57
- editor: a,
55
+ const D = (e) => /* @__PURE__ */ w(e);
56
+ async function G({
57
+ editor: e,
58
58
  plan: t,
59
- pluginName: e,
59
+ pluginName: s,
60
60
  licenseKey: n,
61
- onLicenseCheckResponse: s,
62
- cleanup: i
61
+ onLicenseCheckResponse: a,
62
+ cleanup: r
63
63
  }) {
64
- let r = "", l = !1;
65
- const u = O(), c = (o) => {
66
- console.warn("Cleanup plugin:", e, "Reason:", o), i();
67
- }, h = (o = {}) => {
68
- var f;
69
- const { error: g, sdkLicense: x } = o, m = (f = o.plan) == null ? void 0 : f.category;
70
- if (!(x || o.license) || g)
71
- c(g || "Invalid license");
72
- else if (m) {
73
- const E = S[t], I = S[m];
74
- E > I && c({ pluginRequiredPlan: t, licensePlan: m });
64
+ let o = "", i;
65
+ const c = (l) => {
66
+ console.warn("Cleanup plugin:", s, "Reason:", l), r();
67
+ }, u = (l = {}) => {
68
+ var P;
69
+ const { error: y, sdkLicense: E } = l, g = (P = l.plan) == null ? void 0 : P.category;
70
+ if (!(E || l.license) || y)
71
+ c(y || "Invalid license");
72
+ else if (g) {
73
+ const I = m[t], S = m[g];
74
+ I > S && c({ pluginRequiredPlan: t, licensePlan: g });
75
75
  }
76
76
  };
77
- a.on(_, (o) => {
78
- r = o == null ? void 0 : o.baseApiUrl, l = !0;
79
- }), a.on(k, (o) => {
80
- s == null || s(o), h(o);
81
- }), setTimeout(async () => {
82
- if (!l) {
83
- if (u) return;
84
- if (n) {
85
- const o = await M({ licenseKey: n, pluginName: e, baseApiUrl: r });
86
- s == null || s(o), o && h(o);
87
- } else
88
- c("The `licenseKey` option not provided");
89
- }
90
- }, 2e3);
77
+ e.Commands.has(d.settings) && (i = e.runCommand(d.settings), o = (i == null ? void 0 : i.baseUrl) || "");
78
+ const h = (l) => {
79
+ a == null || a(l), l && u(l);
80
+ };
81
+ if (!i) {
82
+ e.onReady(async () => {
83
+ if (!O())
84
+ if (n) {
85
+ const l = await B({ licenseKey: n, pluginName: s, baseApiUrl: o });
86
+ h(l);
87
+ } else
88
+ c("The `licenseKey` option not provided");
89
+ });
90
+ return;
91
+ }
92
+ if (i.licensePlan || i.licenseError) {
93
+ const l = M(i);
94
+ h(l);
95
+ return;
96
+ }
97
+ e.on(L, (l) => h(l));
91
98
  }
92
- async function M(a) {
93
- const { licenseKey: t, pluginName: e, baseApiUrl: n } = a;
99
+ const M = (e) => ({
100
+ sdkLicense: e.license,
101
+ license: e.license,
102
+ error: e.licenseError,
103
+ plan: e.licensePlan
104
+ });
105
+ async function B(e) {
106
+ const { licenseKey: t, pluginName: s, baseApiUrl: n } = e;
94
107
  try {
95
- return (await A({
108
+ return (await _({
96
109
  baseApiUrl: n,
97
110
  path: `/sdk/${t || "na"}`,
98
111
  method: "POST",
99
112
  params: {
100
113
  d: window.location.hostname,
101
- pn: e
114
+ pn: s
102
115
  }
103
116
  })).result || {};
104
- } catch (s) {
105
- return console.error("Error during SDK license check:", s), !1;
117
+ } catch (a) {
118
+ return console.error("Error during SDK license check:", a), !1;
106
119
  }
107
120
  }
108
- const H = (a, t) => (a.config.optsHtml = {
109
- ...a.config.optsHtml,
121
+ const j = (e, t) => (e.config.optsHtml = {
122
+ ...e.config.optsHtml,
110
123
  exporter: t
111
124
  }, () => {
112
- a.config.optsHtml.exporter = void 0;
113
- }), U = (a, t) => {
114
- const e = (s) => {
115
- const { input: i } = s, { contains: r } = t;
116
- (!r || i.includes(r)) && (s.input = t.importer.import(i));
117
- }, n = a.Parser.events.htmlBefore;
118
- return a.on(n, e), () => {
119
- a.off(n, e);
125
+ e.config.optsHtml.exporter = void 0;
126
+ }), U = (e, t) => {
127
+ const s = (a) => {
128
+ const { input: r } = a, { contains: o } = t;
129
+ (!o || r.includes(o)) && (a.input = t.importer.import(r));
130
+ }, n = e.Parser.events.htmlBefore;
131
+ return e.on(n, s), () => {
132
+ e.off(n, s);
120
133
  };
121
- }, b = {
134
+ }, v = {
122
135
  equals: "equals",
123
136
  isTruthy: "isTruthy",
124
137
  isFalsy: "isFalsy",
@@ -131,7 +144,7 @@ const H = (a, t) => (a.config.optsHtml = {
131
144
  isNumber: "isNumber",
132
145
  isBoolean: "isBoolean",
133
146
  isDefaultValue: "isDefaultValue"
134
- }, B = {
147
+ }, H = {
135
148
  ">": "numGt",
136
149
  "<": "numLt",
137
150
  ">=": "numGte",
@@ -145,58 +158,58 @@ const H = (a, t) => (a.config.optsHtml = {
145
158
  equalsIgnoreCase: "strEqualsIgnoreCase",
146
159
  trimEquals: "strTrimEquals"
147
160
  }, V = {
148
- ...b,
149
- ...B,
161
+ ...v,
162
+ ...H,
150
163
  ...W
151
164
  };
152
- class G {
165
+ class F {
153
166
  getHelperId(t) {
154
167
  return V[t] || t;
155
168
  }
156
- getFullPath({ collectionId: t, path: e }) {
157
- let n = e;
158
- return t && (n = [this._sanitizeVariableName(t), e].filter(Boolean).join(".")), n || "";
169
+ getFullPath({ collectionId: t, path: s }) {
170
+ let n = s;
171
+ return t && (n = [this._sanitizeVariableName(t), s].filter(Boolean).join(".")), n || "";
159
172
  }
160
173
  getVariableSyntax({ dataResolver: t }) {
161
- const { defaultValue: e } = t, n = this.getFullPath(t);
162
- return e ? `{{#if ${n}}}{{{${n}}}}{{else}}${e}{{/if}}` : `{{{${n}}}}`;
174
+ const { defaultValue: s } = t, n = this.getFullPath(t);
175
+ return s ? `{{#if ${n}}}{{{${n}}}}{{else}}${s}{{/if}}` : `{{{${n}}}}`;
163
176
  }
164
177
  getCollectionStartSyntax({ dataResolver: t }) {
165
- const { collectionId: e, dataSource: n } = t, s = n == null ? void 0 : n.path;
166
- let i = "";
178
+ const { collectionId: s, dataSource: n } = t, a = n == null ? void 0 : n.path;
179
+ let r = "";
167
180
  if (t.startIndex !== void 0 || t.endIndex !== void 0) {
168
- const c = t.startIndex ?? 0, h = t.endIndex !== void 0 ? t.endIndex : "";
169
- h !== "" ? i = ` (slice ${s} ${c} ${h})` : i = ` (slice ${s} ${c})`;
181
+ const u = t.startIndex ?? 0, h = t.endIndex !== void 0 ? t.endIndex : "";
182
+ h !== "" ? r = ` (slice ${a} ${u} ${h})` : r = ` (slice ${a} ${u})`;
170
183
  }
171
- const l = ` as |${this._sanitizeVariableName(e)}|`;
172
- return `{{#each ${i || s}${l}}}`;
184
+ const i = ` as |${this._sanitizeVariableName(s)}|`;
185
+ return `{{#each ${r || a}${i}}}`;
173
186
  }
174
187
  getCollectionEndSyntax() {
175
188
  return "{{/each}}";
176
189
  }
177
190
  getConditionalStartSyntax({ dataResolver: t }) {
178
- const e = t.condition;
179
- if (!e) return "";
180
- const n = e, s = e;
181
- if (s.statements && s.logicalOperator === "and" || s.logicalOperator === "or") {
182
- const { statements: i } = s, r = s.logicalOperator, l = i.map((c) => this._parseCondition(c)).join(" ");
183
- return `{{#if ${i.length > 1 ? `(${r} ${l})` : l}}}`;
191
+ const s = t.condition;
192
+ if (!s) return "";
193
+ const n = s, a = s;
194
+ if (a.statements && a.logicalOperator === "and" || a.logicalOperator === "or") {
195
+ const { statements: r } = a, o = a.logicalOperator, i = r.map((u) => this._parseCondition(u)).join(" ");
196
+ return `{{#if ${r.length > 1 ? `(${o} ${i})` : i}}}`;
184
197
  } else
185
198
  return `{{#if ${this._parseCondition(n)}}}`;
186
199
  }
187
200
  _parseCondition(t) {
188
201
  if (!t) return "";
189
- const e = t, n = t;
202
+ const s = t, n = t;
190
203
  if (n.statements && n.logicalOperator === "and" || n.logicalOperator === "or") {
191
- const { statements: s } = n, i = n.logicalOperator, r = n.statements.map((l) => this._parseCondition(l)).join(" ");
192
- return s.length > 1 ? `(${i} ${r})` : r;
204
+ const { statements: a } = n, r = n.logicalOperator, o = n.statements.map((i) => this._parseCondition(i)).join(" ");
205
+ return a.length > 1 ? `(${r} ${o})` : o;
193
206
  } else {
194
- const s = e.operator, i = this.getHelperId(s), r = this._parseValue(e.left), l = this._parseValue(e.right);
195
- return this.getExpressionStr(i, r, l);
207
+ const a = s.operator, r = this.getHelperId(a), o = this._parseValue(s.left), i = this._parseValue(s.right);
208
+ return this.getExpressionStr(r, o, i);
196
209
  }
197
210
  }
198
- getExpressionStr(t, e, n) {
199
- return b[t] ? t === "isTruthy" ? e : t === "isFalsy" ? `!${e}` : `${t} ${e}` : `(${t} ${e} ${n})`;
211
+ getExpressionStr(t, s, n) {
212
+ return v[t] ? t === "isTruthy" ? s : t === "isFalsy" ? `!${s}` : `${t} ${s}` : `(${t} ${s} ${n})`;
200
213
  }
201
214
  _parseValue(t) {
202
215
  return typeof t == "object" ? this.getFullPath(t) : typeof t == "string" ? `'${t.replace(/'/g, "\\'")}'` : String(t);
@@ -211,24 +224,24 @@ class G {
211
224
  return "{{/if}}";
212
225
  }
213
226
  }
214
- class q {
227
+ class C {
215
228
  constructor() {
216
229
  this.messages = [], this.collectionStack = [];
217
230
  }
218
231
  import(t) {
219
232
  this.messages = [], this.collectionStack = [];
220
- const e = this.parse(t);
221
- return this.astToGrapesJS(e);
233
+ const s = this.parse(t);
234
+ return this.astToGrapesJS(s);
222
235
  }
223
236
  parse(t) {
224
237
  try {
225
- return v.parse(t);
226
- } catch (e) {
227
- if (e instanceof Error && e.message.includes("Parse error")) {
228
- 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;
229
- throw new Error(`Handlebars syntax error at line ${s}, column ${r}: ${e.message}`);
238
+ return T.parse(t);
239
+ } catch (s) {
240
+ if (s instanceof Error && s.message.includes("Parse error")) {
241
+ const n = s.message.match(/line (\d+)/), a = n ? parseInt(n[1]) : 0, r = s.message.match(/column (\d+)/), o = r ? parseInt(r[1]) : 0;
242
+ throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${s.message}`);
230
243
  }
231
- throw e;
244
+ throw s;
232
245
  }
233
246
  }
234
247
  astToGrapesJS(t) {
@@ -254,109 +267,109 @@ class q {
254
267
  }
255
268
  }
256
269
  handleProgram(t) {
257
- let e = "";
270
+ let s = "";
258
271
  if (t.body)
259
272
  for (const n of t.body)
260
- e += this.astToGrapesJS(n);
261
- return e;
273
+ s += this.astToGrapesJS(n);
274
+ return s;
262
275
  }
263
276
  handleContentStatement(t) {
264
277
  return t.value || "";
265
278
  }
266
- handleMustacheStatement(t, e = {}) {
267
- const n = this.getExpressionString(t.path), s = { ...e };
268
- return this.collectionStack.length > 0 ? this.processPathWithCollectionContext(n, s) : s.path = n, `<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`;
279
+ handleMustacheStatement(t, s = {}) {
280
+ const n = this.getExpressionString(t.path), a = { ...s };
281
+ return this.collectionStack.length > 0 ? this.processPathWithCollectionContext(n, a) : a.path = n, `<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`;
269
282
  }
270
- processPathWithCollectionContext(t, e) {
271
- t.startsWith("@") ? this.handleDirectCollectionReference(t, e) : this.handleRelativePathReference(t, e);
283
+ processPathWithCollectionContext(t, s) {
284
+ t.startsWith("@") ? this.handleDirectCollectionReference(t, s) : this.handleRelativePathReference(t, s);
272
285
  }
273
- handleDirectCollectionReference(t, e) {
286
+ handleDirectCollectionReference(t, s) {
274
287
  if (this.isSpecialIterationVariable(t)) {
275
- this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length - 1], t, e);
288
+ this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length - 1], t, s);
276
289
  return;
277
290
  }
278
- const [n, ...s] = t.substring(1).split("/"), i = s.join(".");
279
- this.collectionStack.includes(n) ? this.setCurrentItemResolver(n, i, e) : this.handleParentReferenceFallback(t, e);
291
+ const [n, ...a] = t.substring(1).split("/"), r = a.join(".");
292
+ this.collectionStack.includes(n) ? this.setCurrentItemResolver(n, r, s) : this.handleParentReferenceFallback(t, s);
280
293
  }
281
294
  isSpecialIterationVariable(t) {
282
295
  return ["index", "@index", "key", "@key"].includes(t);
283
296
  }
284
- setSpecialVariableResolver(t, e, n) {
297
+ setSpecialVariableResolver(t, s, n) {
285
298
  n.collectionId = t;
286
- const s = {
299
+ const a = {
287
300
  index: "currentIndex",
288
301
  "@index": "currentIndex",
289
302
  key: "currentKey",
290
303
  "@key": "currentKey"
291
304
  };
292
- n.variableType = s[e];
305
+ n.variableType = a[s];
293
306
  }
294
- setCurrentItemResolver(t, e, n) {
295
- n.collectionId = t, n.variableType = "currentItem", e && (n.path = e);
307
+ setCurrentItemResolver(t, s, n) {
308
+ n.collectionId = t, n.variableType = "currentItem", s && (n.path = s);
296
309
  }
297
- handleRelativePathReference(t, e) {
298
- const n = d(t), { parentLevel: s, remainingPathParts: i } = this.calculateParentLevel(n), r = i.join("."), l = this.collectionStack.length - 1 - s;
299
- l >= 0 && l < this.collectionStack.length ? this.resolveRelativePath(r, l, e) : e.path = i.join(".");
310
+ handleRelativePathReference(t, s) {
311
+ const n = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(n), o = r.join("."), i = this.collectionStack.length - 1 - a;
312
+ i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, s) : s.path = r.join(".");
300
313
  }
301
314
  calculateParentLevel(t) {
302
- const e = this.collectionStack.findLastIndex((i) => i === t[0]);
303
- if (e !== -1)
304
- return { parentLevel: this.collectionStack.length - 1 - e, remainingPathParts: t.slice(1) };
315
+ const s = this.collectionStack.findLastIndex((r) => r === t[0]);
316
+ if (s !== -1)
317
+ return { parentLevel: this.collectionStack.length - 1 - s, remainingPathParts: t.slice(1) };
305
318
  let n = 0;
306
- const s = [...t];
307
- for (; s[0] === ".."; )
308
- n++, s.shift();
309
- return { parentLevel: n, remainingPathParts: s };
319
+ const a = [...t];
320
+ for (; a[0] === ".."; )
321
+ n++, a.shift();
322
+ return { parentLevel: n, remainingPathParts: a };
310
323
  }
311
- resolveRelativePath(t, e, n) {
312
- const s = this.collectionStack[e];
313
- n.collectionId = s, n.variableType = "currentItem", t !== "this" && (n.path = t.startsWith("this.") ? t.split(".").slice(1).join(".") : t);
324
+ resolveRelativePath(t, s, n) {
325
+ const a = this.collectionStack[s];
326
+ n.collectionId = a, n.variableType = "currentItem", t !== "this" && (n.path = t.startsWith("this.") ? t.split(".").slice(1).join(".") : t);
314
327
  }
315
- handleParentReferenceFallback(t, e) {
316
- const n = d(t), { parentLevel: s, remainingPathParts: i } = this.calculateParentLevel(n), r = i.join("."), l = this.collectionStack.length - 1 - s;
317
- l >= 0 && l < this.collectionStack.length ? this.resolveRelativePath(r, l, e) : e.path = i.join(".");
328
+ handleParentReferenceFallback(t, s) {
329
+ const n = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(n), o = r.join("."), i = this.collectionStack.length - 1 - a;
330
+ i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, s) : s.path = r.join(".");
318
331
  }
319
332
  handleBlockStatement(t) {
320
- const e = t.path.original;
321
- switch (e) {
333
+ const s = t.path.original;
334
+ switch (s) {
322
335
  case "if":
323
336
  case "unless":
324
- return this.handleConditionalBlock(t, e);
337
+ return this.handleConditionalBlock(t, s);
325
338
  case "each":
326
339
  return this.handleEachBlock(t);
327
340
  default:
328
- return this.addMessage("warning", `Unsupported block helper: ${e}`, t.loc), this.handleGenericBlock(t);
341
+ return this.addMessage("warning", `Unsupported block helper: ${s}`, t.loc), this.handleGenericBlock(t);
329
342
  }
330
343
  }
331
- handleConditionalBlock(t, e) {
332
- const i = {
344
+ handleConditionalBlock(t, s) {
345
+ const r = {
333
346
  logicalOperator: "and",
334
347
  statements: [
335
348
  {
336
349
  left: { type: "data-variable", path: this.getExpressionString(t.params[0]) },
337
- operator: e === "unless" ? "isFalsy" : "isTruthy"
350
+ operator: s === "unless" ? "isFalsy" : "isTruthy"
338
351
  }
339
352
  ]
340
- }, r = this.handleProgram(t.program), l = t.inverse ? this.handleProgram(t.inverse) : "";
353
+ }, o = this.handleProgram(t.program), i = t.inverse ? this.handleProgram(t.inverse) : "";
341
354
  return `
342
- <data-condition data-gjs-data-resolver='${JSON.stringify({ condition: i })}'>
343
- <data-condition-true-content>${r}</data-condition-true-content>
344
- <data-condition-false-content>${l}</data-condition-false-content>
355
+ <data-condition data-gjs-data-resolver='${JSON.stringify({ condition: r })}'>
356
+ <data-condition-true-content>${o}</data-condition-true-content>
357
+ <data-condition-false-content>${i}</data-condition-false-content>
345
358
  </data-condition>
346
359
  `;
347
360
  }
348
361
  handleEachBlock(t) {
349
- var i, r, l;
350
- const e = this.getExpressionString(t.params[0]);
362
+ var r, o, i;
363
+ const s = this.getExpressionString(t.params[0]);
351
364
  let n;
352
- t.params.length >= 3 && t.params[1] === "as" && ((i = t.params[2]) == null ? void 0 : i.type) === "PathExpression" ? n = t.params[2].original : (l = (r = t.program) == null ? void 0 : r.blockParams) != null && l.length ? n = t.program.blockParams[0] : n = `collection-${Math.random().toString(36).substring(2, 10)}`, this.collectionStack.push(n);
353
- const s = this.handleProgram(t.program);
365
+ t.params.length >= 3 && t.params[1] === "as" && ((r = t.params[2]) == null ? void 0 : r.type) === "PathExpression" ? n = t.params[2].original : (i = (o = t.program) == null ? void 0 : o.blockParams) != null && i.length ? n = t.program.blockParams[0] : n = `collection-${Math.random().toString(36).substring(2, 10)}`, this.collectionStack.push(n);
366
+ const a = this.handleProgram(t.program);
354
367
  return this.collectionStack.pop(), `
355
368
  <data-collection data-gjs-data-resolver='${JSON.stringify({
356
- dataSource: { type: "data-variable", path: e },
369
+ dataSource: { type: "data-variable", path: s },
357
370
  collectionId: n
358
371
  })}'>
359
- <data-collection-item>${s}</data-collection-item>
372
+ <data-collection-item>${a}</data-collection-item>
360
373
  </data-collection>
361
374
  `;
362
375
  }
@@ -364,15 +377,15 @@ class q {
364
377
  return `<!--${t.value}-->`;
365
378
  }
366
379
  handleElementNode(t) {
367
- let e = "";
380
+ let s = "";
368
381
  if (t.attributes)
369
- for (const s of t.attributes)
370
- 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)}"`);
382
+ for (const a of t.attributes)
383
+ a.value.type === "TextNode" ? s += ` ${a.name}="${a.value.chars}"` : (this.addMessage("warning", `Complex attribute values not fully supported: ${a.name}`, t.loc), s += ` ${a.name}="${this.getExpressionString(a.value)}"`);
371
384
  let n = "";
372
385
  if (t.children)
373
- for (const s of t.children)
374
- n += this.astToGrapesJS(s);
375
- return `<${t.tag}${e}>${n}</${t.tag}>`;
386
+ for (const a of t.children)
387
+ n += this.astToGrapesJS(a);
388
+ return `<${t.tag}${s}>${n}</${t.tag}>`;
376
389
  }
377
390
  handleTextNode(t) {
378
391
  return t.chars || "";
@@ -381,64 +394,64 @@ class q {
381
394
  return this.addMessage("warning", `Partials are not fully supported: ${t.name.original}`, t.loc), `{{> ${t.name.original}}}`;
382
395
  }
383
396
  handleGenericBlock(t) {
384
- const e = this.handleProgram(t.program);
385
- return `<!-- Unsupported block: ${t.path.original} -->${e}`;
397
+ const s = this.handleProgram(t.program);
398
+ return `<!-- Unsupported block: ${t.path.original} -->${s}`;
386
399
  }
387
400
  getExpressionString(t) {
388
401
  return t.type === "PathExpression" ? t.original : t.type === "StringLiteral" ? t.value : t.type === "NumberLiteral" ? t.value.toString() : t.type === "BooleanLiteral" ? t.value ? "true" : "false" : t.type === "SubExpression" ? this.getExpressionString(t.params[0]) : t.type === "Hash" ? `{${t.pairs.map((n) => `${n.key}=${this.getExpressionString(n.value)}`).join(", ")}}` : (this.addMessage("warning", `Complex expression type not fully supported: ${t.type}`, t.loc), "");
389
402
  }
390
- addMessage(t, e, n) {
403
+ addMessage(t, s, n) {
391
404
  this.messages.push({
392
405
  type: t,
393
- message: e,
406
+ message: s,
394
407
  location: n ? { line: n.start.line, column: n.start.column } : void 0
395
408
  });
396
409
  }
397
410
  }
398
- const d = (a) => {
399
- if (a == null || a === "")
411
+ const f = (e) => {
412
+ if (e == null || e === "")
400
413
  return [];
401
- if (a === ".")
414
+ if (e === ".")
402
415
  return ["this"];
403
- if (a === ".." || a === "../")
416
+ if (e === ".." || e === "../")
404
417
  return [".."];
405
- if (a.startsWith("../")) {
406
- const r = a.substring(3);
407
- return ["..", ...d(r)];
418
+ if (e.startsWith("../")) {
419
+ const o = e.substring(3);
420
+ return ["..", ...f(o)];
408
421
  }
409
422
  const t = [];
410
- let e = 0, n = a.replace(
423
+ let s = 0, n = e.replace(
411
424
  /\[(?:(['"])(.*?)\1|([^\]]*))\]/g,
412
- (r, l, u, c) => {
413
- const h = u !== void 0 ? u : c || "";
414
- return t[e] = h, `__HANDLEBARS_PLACEHOLDER_${e++}__`;
425
+ (o, i, c, u) => {
426
+ const h = c !== void 0 ? c : u || "";
427
+ return t[s] = h, `__HANDLEBARS_PLACEHOLDER_${s++}__`;
415
428
  }
416
429
  );
417
430
  n = n.replace(/\//g, ".");
418
- const s = n.split("."), i = [];
419
- for (const r of s) {
420
- const l = /^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(r);
421
- if (l) {
422
- const u = parseInt(l[1], 10);
423
- i.push(t[u]);
424
- } else r !== "" && i.push(r);
425
- }
426
- return i;
427
- }, F = "dataSourceHandlebars", R = p.startup, J = function(a, t = {}) {
428
- const e = H(a, new G()), n = U(a, {
431
+ const a = n.split("."), r = [];
432
+ for (const o of a) {
433
+ const i = /^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);
434
+ if (i) {
435
+ const c = parseInt(i[1], 10);
436
+ r.push(t[c]);
437
+ } else o !== "" && r.push(o);
438
+ }
439
+ return r;
440
+ }, q = "dataSourceHandlebars", J = p.startup, z = function(e, t = {}) {
441
+ const s = j(e, new F()), n = U(e, {
429
442
  contains: "{{",
430
- importer: new q()
443
+ importer: new C()
431
444
  });
432
- D({
433
- editor: a,
445
+ G({
446
+ editor: e,
434
447
  licenseKey: t.licenseKey,
435
- plan: R,
436
- pluginName: F,
448
+ plan: J,
449
+ pluginName: q,
437
450
  cleanup: () => {
438
- e(), n();
451
+ s(), n();
439
452
  }
440
453
  });
441
- }, Y = j(J);
454
+ }, Z = D(z);
442
455
  export {
443
- Y as default
456
+ Z as default
444
457
  };