@grapesjs/studio-sdk-plugins 1.0.35 → 1.0.37

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 (92) hide show
  1. package/dist/accordionComponent/index.cjs.js +7 -7
  2. package/dist/accordionComponent/index.es.js +185 -159
  3. package/dist/accordionComponent/index.umd.js +7 -7
  4. package/dist/aiChat/clientToolsProcessors.d.ts +1 -2
  5. package/dist/aiChat/components/utils.d.ts +1 -0
  6. package/dist/aiChat/components/utilsTw.d.ts +11 -0
  7. package/dist/aiChat/index.cjs.js +75 -75
  8. package/dist/aiChat/index.es.js +9122 -8628
  9. package/dist/aiChat/index.js +75 -75
  10. package/dist/aiChat/index.umd.js +75 -75
  11. package/dist/aiChat/projectGeneration.d.ts +17 -0
  12. package/dist/animationComponent/index.cjs.js +3 -3
  13. package/dist/animationComponent/index.es.js +221 -195
  14. package/dist/animationComponent/index.umd.js +3 -3
  15. package/dist/canvasAbsoluteMode/index.cjs.js +1 -1
  16. package/dist/canvasAbsoluteMode/index.es.js +199 -173
  17. package/dist/canvasAbsoluteMode/index.umd.js +1 -1
  18. package/dist/canvasEmptyState/index.cjs.js +1 -1
  19. package/dist/canvasEmptyState/index.es.js +149 -123
  20. package/dist/canvasEmptyState/index.umd.js +1 -1
  21. package/dist/canvasFullSize/index.cjs.js +9 -9
  22. package/dist/canvasFullSize/index.es.js +186 -160
  23. package/dist/canvasFullSize/index.umd.js +9 -9
  24. package/dist/canvasGridMode/index.cjs.js +5 -5
  25. package/dist/canvasGridMode/index.es.js +263 -237
  26. package/dist/canvasGridMode/index.umd.js +2 -2
  27. package/dist/canvasScreenshot/index.cjs.js +1 -1
  28. package/dist/canvasScreenshot/index.es.js +168 -142
  29. package/dist/canvasScreenshot/index.umd.js +1 -1
  30. package/dist/dataSourceEjs/index.cjs.js +9 -9
  31. package/dist/dataSourceEjs/index.es.js +271 -245
  32. package/dist/dataSourceEjs/index.umd.js +9 -9
  33. package/dist/dataSourceHandlebars/index.cjs.js +8 -8
  34. package/dist/dataSourceHandlebars/index.es.js +232 -206
  35. package/dist/dataSourceHandlebars/index.umd.js +8 -8
  36. package/dist/dialogComponent/index.cjs.js +14 -14
  37. package/dist/dialogComponent/index.es.js +157 -131
  38. package/dist/dialogComponent/index.umd.js +14 -14
  39. package/dist/flexComponent/index.cjs.js +13 -13
  40. package/dist/flexComponent/index.es.js +497 -471
  41. package/dist/flexComponent/index.umd.js +13 -13
  42. package/dist/fsLightboxComponent/index.cjs.js +3 -3
  43. package/dist/fsLightboxComponent/index.es.js +189 -163
  44. package/dist/fsLightboxComponent/index.umd.js +3 -3
  45. package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
  46. package/dist/googleFontsAssetProvider/index.es.js +175 -149
  47. package/dist/googleFontsAssetProvider/index.umd.js +1 -1
  48. package/dist/iconifyComponent/index.cjs.js +2 -2
  49. package/dist/iconifyComponent/index.es.js +207 -181
  50. package/dist/iconifyComponent/index.umd.js +2 -2
  51. package/dist/index.cjs.js +36 -36
  52. package/dist/index.es.js +917 -891
  53. package/dist/index.umd.js +36 -36
  54. package/dist/layoutSidebarButtons/index.cjs.js +1 -1
  55. package/dist/layoutSidebarButtons/index.es.js +192 -166
  56. package/dist/layoutSidebarButtons/index.umd.js +1 -1
  57. package/dist/lightGalleryComponent/index.cjs.js +1 -1
  58. package/dist/lightGalleryComponent/index.es.js +265 -239
  59. package/dist/lightGalleryComponent/index.umd.js +1 -1
  60. package/dist/linkImageComponent/index.cjs.js +2 -2
  61. package/dist/linkImageComponent/index.es.js +121 -95
  62. package/dist/linkImageComponent/index.umd.js +2 -2
  63. package/dist/listPagesComponent/index.cjs.js +5 -5
  64. package/dist/listPagesComponent/index.es.js +171 -145
  65. package/dist/listPagesComponent/index.umd.js +5 -5
  66. package/dist/presetPrintable/index.cjs.js +3 -3
  67. package/dist/presetPrintable/index.es.js +227 -201
  68. package/dist/presetPrintable/index.umd.js +3 -3
  69. package/dist/prosemirror/index.cjs.js +7 -7
  70. package/dist/prosemirror/index.es.js +457 -431
  71. package/dist/prosemirror/index.umd.js +8 -8
  72. package/dist/rendererReact/index.cjs.js +1 -1
  73. package/dist/rendererReact/index.es.js +248 -223
  74. package/dist/rendererReact/index.js +1 -1
  75. package/dist/rendererReact/index.umd.js +1 -1
  76. package/dist/rteTinyMce/index.cjs.js +2 -2
  77. package/dist/rteTinyMce/index.es.js +150 -124
  78. package/dist/rteTinyMce/index.umd.js +2 -2
  79. package/dist/shapeDividerComponent/index.cjs.js +4 -4
  80. package/dist/shapeDividerComponent/index.es.js +143 -117
  81. package/dist/shapeDividerComponent/index.umd.js +4 -4
  82. package/dist/swiperComponent/index.cjs.js +9 -9
  83. package/dist/swiperComponent/index.es.js +218 -192
  84. package/dist/swiperComponent/index.umd.js +7 -7
  85. package/dist/tableComponent/index.cjs.js +1 -1
  86. package/dist/tableComponent/index.es.js +275 -249
  87. package/dist/tableComponent/index.umd.js +1 -1
  88. package/dist/types.d.ts +1 -1
  89. package/dist/youtubeAssetProvider/index.cjs.js +1 -1
  90. package/dist/youtubeAssetProvider/index.es.js +134 -108
  91. package/dist/youtubeAssetProvider/index.umd.js +1 -1
  92. package/package.json +2 -2
@@ -1,124 +1,150 @@
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 x = "app.grapesjs.com", $ = "app-stage.grapesjs.com", k = "app2.grapesjs.com", A = "app-stage2.grapesjs.com", P = [
3
+ x,
4
+ k,
5
5
  $,
6
- N,
6
+ A,
7
7
  "localhost",
8
8
  "127.0.0.1",
9
9
  ".local-credentialless.webcontainer.io",
10
10
  // For stackblitz.com demos
11
11
  ".local.webcontainer.io",
12
12
  // For stackblitz.com demos
13
- "-sandpack.codesandbox.io"
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
+ ".claudemcpcontent.com",
16
+ // For Claude mcp app
17
+ ".web-sandbox.oaiusercontent.com"
18
+ // For OpenAI mcp app
19
+ ], L = "license:check:end", N = () => typeof window < "u", R = ({
20
+ isDev: e,
17
21
  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)));
22
+ isPlatform: s
23
+ }) => `${e ? "" : `https://${t ? $ : x}`}/${s ? "platform-api" : "api"}`, O = () => {
24
+ if (!N()) return "";
25
+ const { hostname: e } = window.location;
26
+ if (e) return e;
27
+ try {
28
+ return window.parent.location.hostname || "";
29
+ } catch {
30
+ return "";
31
+ }
32
+ }, _ = () => {
33
+ const e = O();
34
+ return !!e && (P.includes(e) || P.some((t) => e.endsWith(t)));
22
35
  };
23
- async function A({
24
- path: a,
36
+ async function w({
37
+ path: e,
25
38
  baseApiUrl: t,
26
- method: e = "GET",
39
+ method: s = "GET",
27
40
  headers: n = {},
28
- params: s,
29
- body: i
41
+ params: a,
42
+ body: r
30
43
  }) {
31
- const l = `${t || w({ isDev: !1, isStage: !1 })}${a}`, u = {
32
- method: e,
44
+ const i = `${t || R({ isDev: !1, isStage: !1 })}${e}`, c = {
45
+ method: s,
33
46
  headers: {
34
47
  "Content-Type": "application/json",
35
48
  ...n
36
49
  }
37
50
  };
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();
51
+ r && (c.body = JSON.stringify(r));
52
+ const u = a ? new URLSearchParams(a).toString() : "", h = u ? `?${u}` : "", l = await fetch(`${i}${h}`, c);
53
+ if (!l.ok)
54
+ throw new Error(`HTTP error! status: ${l.status}`);
55
+ return l.json();
43
56
  }
44
- var p = /* @__PURE__ */ ((a) => (a.free = "free", a.startup = "startup", a.business = "business", a.enterprise = "enterprise", a))(p || {});
45
- const S = {
57
+ 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 || {});
58
+ const m = {
46
59
  [p.free]: 0,
47
60
  [p.startup]: 10,
48
61
  [p.business]: 20,
49
62
  [p.enterprise]: 30
50
63
  };
51
- function L(a) {
52
- const t = a;
53
- return t.init = (e) => (n) => a(n, e), t;
64
+ function D(e) {
65
+ const t = e;
66
+ return t.init = (s) => (n) => e(n, s), t;
54
67
  }
55
- const j = (a) => /* @__PURE__ */ L(a);
56
- async function D({
57
- editor: a,
68
+ const G = (e) => /* @__PURE__ */ D(e);
69
+ async function M({
70
+ editor: e,
58
71
  plan: t,
59
- pluginName: e,
72
+ pluginName: s,
60
73
  licenseKey: n,
61
- onLicenseCheckResponse: s,
62
- cleanup: i
74
+ onLicenseCheckResponse: a,
75
+ cleanup: r
63
76
  }) {
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 });
77
+ let o = "", i;
78
+ const c = (l) => {
79
+ console.warn("Cleanup plugin:", s, "Reason:", l), r();
80
+ }, u = (l = {}) => {
81
+ var b;
82
+ const { error: y, sdkLicense: E } = l, g = (b = l.plan) == null ? void 0 : b.category;
83
+ if (!(E || l.license) || y)
84
+ c(y || "Invalid license");
85
+ else if (g) {
86
+ const I = m[t], S = m[g];
87
+ I > S && c({ pluginRequiredPlan: t, licensePlan: g });
75
88
  }
76
89
  };
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);
90
+ e.Commands.has(d.settings) && (i = e.runCommand(d.settings), o = (i == null ? void 0 : i.baseUrl) || "");
91
+ const h = (l) => {
92
+ a == null || a(l), l && u(l);
93
+ };
94
+ if (!i) {
95
+ e.onReady(async () => {
96
+ if (!_())
97
+ if (n) {
98
+ const l = await j({ licenseKey: n, pluginName: s, baseApiUrl: o });
99
+ h(l);
100
+ } else
101
+ c("The `licenseKey` option not provided");
102
+ });
103
+ return;
104
+ }
105
+ if (i.licensePlan || i.licenseError) {
106
+ const l = B(i);
107
+ h(l);
108
+ return;
109
+ }
110
+ e.on(L, (l) => h(l));
91
111
  }
92
- async function M(a) {
93
- const { licenseKey: t, pluginName: e, baseApiUrl: n } = a;
112
+ const B = (e) => ({
113
+ sdkLicense: e.license,
114
+ license: e.license,
115
+ error: e.licenseError,
116
+ plan: e.licensePlan
117
+ });
118
+ async function j(e) {
119
+ const { licenseKey: t, pluginName: s, baseApiUrl: n } = e;
94
120
  try {
95
- return (await A({
121
+ return (await w({
96
122
  baseApiUrl: n,
97
123
  path: `/sdk/${t || "na"}`,
98
124
  method: "POST",
99
125
  params: {
100
126
  d: window.location.hostname,
101
- pn: e
127
+ pn: s
102
128
  }
103
129
  })).result || {};
104
- } catch (s) {
105
- return console.error("Error during SDK license check:", s), !1;
130
+ } catch (a) {
131
+ return console.error("Error during SDK license check:", a), !1;
106
132
  }
107
133
  }
108
- const H = (a, t) => (a.config.optsHtml = {
109
- ...a.config.optsHtml,
134
+ const U = (e, t) => (e.config.optsHtml = {
135
+ ...e.config.optsHtml,
110
136
  exporter: t
111
137
  }, () => {
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);
138
+ e.config.optsHtml.exporter = void 0;
139
+ }), H = (e, t) => {
140
+ const s = (a) => {
141
+ const { input: r } = a, { contains: o } = t;
142
+ (!o || r.includes(o)) && (a.input = t.importer.import(r));
143
+ }, n = e.Parser.events.htmlBefore;
144
+ return e.on(n, s), () => {
145
+ e.off(n, s);
120
146
  };
121
- }, b = {
147
+ }, v = {
122
148
  equals: "equals",
123
149
  isTruthy: "isTruthy",
124
150
  isFalsy: "isFalsy",
@@ -131,72 +157,72 @@ const H = (a, t) => (a.config.optsHtml = {
131
157
  isNumber: "isNumber",
132
158
  isBoolean: "isBoolean",
133
159
  isDefaultValue: "isDefaultValue"
134
- }, B = {
160
+ }, W = {
135
161
  ">": "numGt",
136
162
  "<": "numLt",
137
163
  ">=": "numGte",
138
164
  "<=": "numLte",
139
165
  "=": "numEq",
140
166
  "!=": "numNeq"
141
- }, W = {
167
+ }, V = {
142
168
  contains: "strContains",
143
169
  startsWith: "strStartsWith",
144
170
  endsWith: "strEndsWith",
145
171
  equalsIgnoreCase: "strEqualsIgnoreCase",
146
172
  trimEquals: "strTrimEquals"
147
- }, V = {
148
- ...b,
149
- ...B,
150
- ...W
173
+ }, F = {
174
+ ...v,
175
+ ...W,
176
+ ...V
151
177
  };
152
- class G {
178
+ class C {
153
179
  getHelperId(t) {
154
- return V[t] || t;
180
+ return F[t] || t;
155
181
  }
156
- getFullPath({ collectionId: t, path: e }) {
157
- let n = e;
158
- return t && (n = [this._sanitizeVariableName(t), e].filter(Boolean).join(".")), n || "";
182
+ getFullPath({ collectionId: t, path: s }) {
183
+ let n = s;
184
+ return t && (n = [this._sanitizeVariableName(t), s].filter(Boolean).join(".")), n || "";
159
185
  }
160
186
  getVariableSyntax({ dataResolver: t }) {
161
- const { defaultValue: e } = t, n = this.getFullPath(t);
162
- return e ? `{{#if ${n}}}{{{${n}}}}{{else}}${e}{{/if}}` : `{{{${n}}}}`;
187
+ const { defaultValue: s } = t, n = this.getFullPath(t);
188
+ return s ? `{{#if ${n}}}{{{${n}}}}{{else}}${s}{{/if}}` : `{{{${n}}}}`;
163
189
  }
164
190
  getCollectionStartSyntax({ dataResolver: t }) {
165
- const { collectionId: e, dataSource: n } = t, s = n == null ? void 0 : n.path;
166
- let i = "";
191
+ const { collectionId: s, dataSource: n } = t, a = n == null ? void 0 : n.path;
192
+ let r = "";
167
193
  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})`;
194
+ const u = t.startIndex ?? 0, h = t.endIndex !== void 0 ? t.endIndex : "";
195
+ h !== "" ? r = ` (slice ${a} ${u} ${h})` : r = ` (slice ${a} ${u})`;
170
196
  }
171
- const l = ` as |${this._sanitizeVariableName(e)}|`;
172
- return `{{#each ${i || s}${l}}}`;
197
+ const i = ` as |${this._sanitizeVariableName(s)}|`;
198
+ return `{{#each ${r || a}${i}}}`;
173
199
  }
174
200
  getCollectionEndSyntax() {
175
201
  return "{{/each}}";
176
202
  }
177
203
  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}}}`;
204
+ const s = t.condition;
205
+ if (!s) return "";
206
+ const n = s, a = s;
207
+ if (a.statements && a.logicalOperator === "and" || a.logicalOperator === "or") {
208
+ const { statements: r } = a, o = a.logicalOperator, i = r.map((u) => this._parseCondition(u)).join(" ");
209
+ return `{{#if ${r.length > 1 ? `(${o} ${i})` : i}}}`;
184
210
  } else
185
211
  return `{{#if ${this._parseCondition(n)}}}`;
186
212
  }
187
213
  _parseCondition(t) {
188
214
  if (!t) return "";
189
- const e = t, n = t;
215
+ const s = t, n = t;
190
216
  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;
217
+ const { statements: a } = n, r = n.logicalOperator, o = n.statements.map((i) => this._parseCondition(i)).join(" ");
218
+ return a.length > 1 ? `(${r} ${o})` : o;
193
219
  } 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);
220
+ const a = s.operator, r = this.getHelperId(a), o = this._parseValue(s.left), i = this._parseValue(s.right);
221
+ return this.getExpressionStr(r, o, i);
196
222
  }
197
223
  }
198
- getExpressionStr(t, e, n) {
199
- return b[t] ? t === "isTruthy" ? e : t === "isFalsy" ? `!${e}` : `${t} ${e}` : `(${t} ${e} ${n})`;
224
+ getExpressionStr(t, s, n) {
225
+ return v[t] ? t === "isTruthy" ? s : t === "isFalsy" ? `!${s}` : `${t} ${s}` : `(${t} ${s} ${n})`;
200
226
  }
201
227
  _parseValue(t) {
202
228
  return typeof t == "object" ? this.getFullPath(t) : typeof t == "string" ? `'${t.replace(/'/g, "\\'")}'` : String(t);
@@ -217,18 +243,18 @@ class q {
217
243
  }
218
244
  import(t) {
219
245
  this.messages = [], this.collectionStack = [];
220
- const e = this.parse(t);
221
- return this.astToGrapesJS(e);
246
+ const s = this.parse(t);
247
+ return this.astToGrapesJS(s);
222
248
  }
223
249
  parse(t) {
224
250
  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}`);
251
+ return T.parse(t);
252
+ } catch (s) {
253
+ if (s instanceof Error && s.message.includes("Parse error")) {
254
+ 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;
255
+ throw new Error(`Handlebars syntax error at line ${a}, column ${o}: ${s.message}`);
230
256
  }
231
- throw e;
257
+ throw s;
232
258
  }
233
259
  }
234
260
  astToGrapesJS(t) {
@@ -254,109 +280,109 @@ class q {
254
280
  }
255
281
  }
256
282
  handleProgram(t) {
257
- let e = "";
283
+ let s = "";
258
284
  if (t.body)
259
285
  for (const n of t.body)
260
- e += this.astToGrapesJS(n);
261
- return e;
286
+ s += this.astToGrapesJS(n);
287
+ return s;
262
288
  }
263
289
  handleContentStatement(t) {
264
290
  return t.value || "";
265
291
  }
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>`;
292
+ handleMustacheStatement(t, s = {}) {
293
+ const n = this.getExpressionString(t.path), a = { ...s };
294
+ return this.collectionStack.length > 0 ? this.processPathWithCollectionContext(n, a) : a.path = n, `<data-variable data-gjs-data-resolver='${JSON.stringify(a)}'></data-variable>`;
269
295
  }
270
- processPathWithCollectionContext(t, e) {
271
- t.startsWith("@") ? this.handleDirectCollectionReference(t, e) : this.handleRelativePathReference(t, e);
296
+ processPathWithCollectionContext(t, s) {
297
+ t.startsWith("@") ? this.handleDirectCollectionReference(t, s) : this.handleRelativePathReference(t, s);
272
298
  }
273
- handleDirectCollectionReference(t, e) {
299
+ handleDirectCollectionReference(t, s) {
274
300
  if (this.isSpecialIterationVariable(t)) {
275
- this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length - 1], t, e);
301
+ this.setSpecialVariableResolver(this.collectionStack[this.collectionStack.length - 1], t, s);
276
302
  return;
277
303
  }
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);
304
+ const [n, ...a] = t.substring(1).split("/"), r = a.join(".");
305
+ this.collectionStack.includes(n) ? this.setCurrentItemResolver(n, r, s) : this.handleParentReferenceFallback(t, s);
280
306
  }
281
307
  isSpecialIterationVariable(t) {
282
308
  return ["index", "@index", "key", "@key"].includes(t);
283
309
  }
284
- setSpecialVariableResolver(t, e, n) {
310
+ setSpecialVariableResolver(t, s, n) {
285
311
  n.collectionId = t;
286
- const s = {
312
+ const a = {
287
313
  index: "currentIndex",
288
314
  "@index": "currentIndex",
289
315
  key: "currentKey",
290
316
  "@key": "currentKey"
291
317
  };
292
- n.variableType = s[e];
318
+ n.variableType = a[s];
293
319
  }
294
- setCurrentItemResolver(t, e, n) {
295
- n.collectionId = t, n.variableType = "currentItem", e && (n.path = e);
320
+ setCurrentItemResolver(t, s, n) {
321
+ n.collectionId = t, n.variableType = "currentItem", s && (n.path = s);
296
322
  }
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(".");
323
+ handleRelativePathReference(t, s) {
324
+ const n = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(n), o = r.join("."), i = this.collectionStack.length - 1 - a;
325
+ i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, s) : s.path = r.join(".");
300
326
  }
301
327
  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) };
328
+ const s = this.collectionStack.findLastIndex((r) => r === t[0]);
329
+ if (s !== -1)
330
+ return { parentLevel: this.collectionStack.length - 1 - s, remainingPathParts: t.slice(1) };
305
331
  let n = 0;
306
- const s = [...t];
307
- for (; s[0] === ".."; )
308
- n++, s.shift();
309
- return { parentLevel: n, remainingPathParts: s };
332
+ const a = [...t];
333
+ for (; a[0] === ".."; )
334
+ n++, a.shift();
335
+ return { parentLevel: n, remainingPathParts: a };
310
336
  }
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);
337
+ resolveRelativePath(t, s, n) {
338
+ const a = this.collectionStack[s];
339
+ n.collectionId = a, n.variableType = "currentItem", t !== "this" && (n.path = t.startsWith("this.") ? t.split(".").slice(1).join(".") : t);
314
340
  }
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(".");
341
+ handleParentReferenceFallback(t, s) {
342
+ const n = f(t), { parentLevel: a, remainingPathParts: r } = this.calculateParentLevel(n), o = r.join("."), i = this.collectionStack.length - 1 - a;
343
+ i >= 0 && i < this.collectionStack.length ? this.resolveRelativePath(o, i, s) : s.path = r.join(".");
318
344
  }
319
345
  handleBlockStatement(t) {
320
- const e = t.path.original;
321
- switch (e) {
346
+ const s = t.path.original;
347
+ switch (s) {
322
348
  case "if":
323
349
  case "unless":
324
- return this.handleConditionalBlock(t, e);
350
+ return this.handleConditionalBlock(t, s);
325
351
  case "each":
326
352
  return this.handleEachBlock(t);
327
353
  default:
328
- return this.addMessage("warning", `Unsupported block helper: ${e}`, t.loc), this.handleGenericBlock(t);
354
+ return this.addMessage("warning", `Unsupported block helper: ${s}`, t.loc), this.handleGenericBlock(t);
329
355
  }
330
356
  }
331
- handleConditionalBlock(t, e) {
332
- const i = {
357
+ handleConditionalBlock(t, s) {
358
+ const r = {
333
359
  logicalOperator: "and",
334
360
  statements: [
335
361
  {
336
362
  left: { type: "data-variable", path: this.getExpressionString(t.params[0]) },
337
- operator: e === "unless" ? "isFalsy" : "isTruthy"
363
+ operator: s === "unless" ? "isFalsy" : "isTruthy"
338
364
  }
339
365
  ]
340
- }, r = this.handleProgram(t.program), l = t.inverse ? this.handleProgram(t.inverse) : "";
366
+ }, o = this.handleProgram(t.program), i = t.inverse ? this.handleProgram(t.inverse) : "";
341
367
  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>
368
+ <data-condition data-gjs-data-resolver='${JSON.stringify({ condition: r })}'>
369
+ <data-condition-true-content>${o}</data-condition-true-content>
370
+ <data-condition-false-content>${i}</data-condition-false-content>
345
371
  </data-condition>
346
372
  `;
347
373
  }
348
374
  handleEachBlock(t) {
349
- var i, r, l;
350
- const e = this.getExpressionString(t.params[0]);
375
+ var r, o, i;
376
+ const s = this.getExpressionString(t.params[0]);
351
377
  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);
378
+ 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);
379
+ const a = this.handleProgram(t.program);
354
380
  return this.collectionStack.pop(), `
355
381
  <data-collection data-gjs-data-resolver='${JSON.stringify({
356
- dataSource: { type: "data-variable", path: e },
382
+ dataSource: { type: "data-variable", path: s },
357
383
  collectionId: n
358
384
  })}'>
359
- <data-collection-item>${s}</data-collection-item>
385
+ <data-collection-item>${a}</data-collection-item>
360
386
  </data-collection>
361
387
  `;
362
388
  }
@@ -364,15 +390,15 @@ class q {
364
390
  return `<!--${t.value}-->`;
365
391
  }
366
392
  handleElementNode(t) {
367
- let e = "";
393
+ let s = "";
368
394
  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)}"`);
395
+ for (const a of t.attributes)
396
+ 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
397
  let n = "";
372
398
  if (t.children)
373
- for (const s of t.children)
374
- n += this.astToGrapesJS(s);
375
- return `<${t.tag}${e}>${n}</${t.tag}>`;
399
+ for (const a of t.children)
400
+ n += this.astToGrapesJS(a);
401
+ return `<${t.tag}${s}>${n}</${t.tag}>`;
376
402
  }
377
403
  handleTextNode(t) {
378
404
  return t.chars || "";
@@ -381,64 +407,64 @@ class q {
381
407
  return this.addMessage("warning", `Partials are not fully supported: ${t.name.original}`, t.loc), `{{> ${t.name.original}}}`;
382
408
  }
383
409
  handleGenericBlock(t) {
384
- const e = this.handleProgram(t.program);
385
- return `<!-- Unsupported block: ${t.path.original} -->${e}`;
410
+ const s = this.handleProgram(t.program);
411
+ return `<!-- Unsupported block: ${t.path.original} -->${s}`;
386
412
  }
387
413
  getExpressionString(t) {
388
414
  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
415
  }
390
- addMessage(t, e, n) {
416
+ addMessage(t, s, n) {
391
417
  this.messages.push({
392
418
  type: t,
393
- message: e,
419
+ message: s,
394
420
  location: n ? { line: n.start.line, column: n.start.column } : void 0
395
421
  });
396
422
  }
397
423
  }
398
- const d = (a) => {
399
- if (a == null || a === "")
424
+ const f = (e) => {
425
+ if (e == null || e === "")
400
426
  return [];
401
- if (a === ".")
427
+ if (e === ".")
402
428
  return ["this"];
403
- if (a === ".." || a === "../")
429
+ if (e === ".." || e === "../")
404
430
  return [".."];
405
- if (a.startsWith("../")) {
406
- const r = a.substring(3);
407
- return ["..", ...d(r)];
431
+ if (e.startsWith("../")) {
432
+ const o = e.substring(3);
433
+ return ["..", ...f(o)];
408
434
  }
409
435
  const t = [];
410
- let e = 0, n = a.replace(
436
+ let s = 0, n = e.replace(
411
437
  /\[(?:(['"])(.*?)\1|([^\]]*))\]/g,
412
- (r, l, u, c) => {
413
- const h = u !== void 0 ? u : c || "";
414
- return t[e] = h, `__HANDLEBARS_PLACEHOLDER_${e++}__`;
438
+ (o, i, c, u) => {
439
+ const h = c !== void 0 ? c : u || "";
440
+ return t[s] = h, `__HANDLEBARS_PLACEHOLDER_${s++}__`;
415
441
  }
416
442
  );
417
443
  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, {
444
+ const a = n.split("."), r = [];
445
+ for (const o of a) {
446
+ const i = /^__HANDLEBARS_PLACEHOLDER_(\d+)__$/.exec(o);
447
+ if (i) {
448
+ const c = parseInt(i[1], 10);
449
+ r.push(t[c]);
450
+ } else o !== "" && r.push(o);
451
+ }
452
+ return r;
453
+ }, J = "dataSourceHandlebars", z = p.startup, K = function(e, t = {}) {
454
+ const s = U(e, new C()), n = H(e, {
429
455
  contains: "{{",
430
456
  importer: new q()
431
457
  });
432
- D({
433
- editor: a,
458
+ M({
459
+ editor: e,
434
460
  licenseKey: t.licenseKey,
435
- plan: R,
436
- pluginName: F,
461
+ plan: z,
462
+ pluginName: J,
437
463
  cleanup: () => {
438
- e(), n();
464
+ s(), n();
439
465
  }
440
466
  });
441
- }, Y = j(J);
467
+ }, Q = G(K);
442
468
  export {
443
- Y as default
469
+ Q as default
444
470
  };