@spiffcommerce/theme-bridge 1.11.3 → 1.12.0-alpha.0

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.
package/dist/index.d.ts CHANGED
@@ -284,12 +284,18 @@ type SpiffThemeLoader = {
284
284
  * @param message The design information to send.
285
285
  */
286
286
  addToEcommerceCart(message: DesignCreationMessage | BundleDesignCreationMessage): void;
287
+ /**
288
+ * Navigates away from the Theme and launches the Customer Portal.
289
+ *
290
+ * WARNING: This will **immediately** exit your session.
291
+ */
292
+ navigateToCustomerPortal(): void;
287
293
  };
288
294
 
289
295
  type SpiffDevOptions = Omit<ThemeContextTransaction, "container"> | Omit<ThemeContextBundle, "container">;
290
296
  declare function setSpiffDevOptions(container: HTMLElement | string, context: SpiffDevOptions): void;
291
297
  declare function exampleThemeInstallConfig(opts?: Partial<ThemeInstallConfigurationResource>): ThemeInstallConfigurationResource;
292
- declare function getDefaultsForSchema(schema: ThemeConfigurationSchema): ThemeInstallConfigurationField[];
298
+ declare function getDefaultsForSchema(schema: ThemeConfigurationSchema, ...excludeKeys: string[]): ThemeInstallConfigurationField[];
293
299
 
294
300
  interface PluginOptions {
295
301
  /**
package/dist/index.js CHANGED
@@ -58,13 +58,13 @@ function ee(e) {
58
58
  function F() {
59
59
  var e, t, _, n, o, i, c, s, a;
60
60
  for (S.sort(Z); e = S.shift(); )
61
- e.__d && (t = S.length, n = void 0, i = (o = (_ = e).__v).__e, s = [], a = [], (c = _.__P) && ((n = C({}, o)).__v = o.__v + 1, f.vnode && f.vnode(n), Y(c, n, o, _.__n, c.ownerSVGElement !== void 0, 32 & o.__u ? [i] : null, s, i ?? E(o), !!(32 & o.__u), a), n.__.__k[n.__i] = n, ye(s, n, a), n.__e != i && he(n)), S.length > t && S.sort(Z));
61
+ e.__d && (t = S.length, n = void 0, i = (o = (_ = e).__v).__e, s = [], a = [], (c = _.__P) && ((n = C({}, o)).__v = o.__v + 1, f.vnode && f.vnode(n), Y(c, n, o, _.__n, c.ownerSVGElement !== void 0, 32 & o.__u ? [i] : null, s, i ?? E(o), !!(32 & o.__u), a), n.__.__k[n.__i] = n, ge(s, n, a), n.__e != i && he(n)), S.length > t && S.sort(Z));
62
62
  F.__r = 0;
63
63
  }
64
64
  function ve(e, t, _, n, o, i, c, s, a, l, p) {
65
- var r, d, u, m, k, y = n && n.__k || pe, h = t.length;
66
- for (_.__d = a, Ne(_, t, y), a = _.__d, r = 0; r < h; r++)
67
- (u = _.__k[r]) != null && typeof u != "boolean" && typeof u != "function" && (d = u.__i === -1 ? D : y[u.__i] || D, u.__i = r, Y(e, u, d, o, i, c, s, a, l, p), m = u.__e, u.ref && d.ref != u.ref && (d.ref && K(d.ref, null, u), p.push(u.ref, u.__c || m, u)), k == null && m != null && (k = m), 65536 & u.__u || d.__k === u.__k ? a = me(u, a, e) : typeof u.type == "function" && u.__d !== void 0 ? a = u.__d : m && (a = m.nextSibling), u.__d = void 0, u.__u &= -196609);
65
+ var r, d, u, m, k, g = n && n.__k || pe, h = t.length;
66
+ for (_.__d = a, Ne(_, t, g), a = _.__d, r = 0; r < h; r++)
67
+ (u = _.__k[r]) != null && typeof u != "boolean" && typeof u != "function" && (d = u.__i === -1 ? D : g[u.__i] || D, u.__i = r, Y(e, u, d, o, i, c, s, a, l, p), m = u.__e, u.ref && d.ref != u.ref && (d.ref && K(d.ref, null, u), p.push(u.ref, u.__c || m, u)), k == null && m != null && (k = m), 65536 & u.__u || d.__k === u.__k ? a = me(u, a, e) : typeof u.type == "function" && u.__d !== void 0 ? a = u.__d : m && (a = m.nextSibling), u.__d = void 0, u.__u &= -196609);
68
68
  _.__d = a, _.__e = k;
69
69
  }
70
70
  function Ne(e, t, _) {
@@ -147,14 +147,14 @@ function ne(e) {
147
147
  return this.l[e.type + !0](f.event ? f.event(e) : e);
148
148
  }
149
149
  function Y(e, t, _, n, o, i, c, s, a, l) {
150
- var p, r, d, u, m, k, y, h, g, x, $, w, Q, H, A, b = t.type;
150
+ var p, r, d, u, m, k, g, h, y, x, $, w, Q, H, A, b = t.type;
151
151
  if (t.constructor !== void 0)
152
152
  return null;
153
153
  128 & _.__u && (a = !!(32 & _.__u), i = [s = t.__e = _.__e]), (p = f.__b) && p(t);
154
154
  e:
155
155
  if (typeof b == "function")
156
156
  try {
157
- if (h = t.props, g = (p = b.contextType) && n[p.__c], x = p ? g ? g.props.value : p.__ : n, _.__c ? y = (r = t.__c = _.__c).__ = r.__E : ("prototype" in b && b.prototype.render ? t.__c = r = new b(h, x) : (t.__c = r = new I(h, x), r.constructor = b, r.render = je), g && g.sub(r), r.props = h, r.state || (r.state = {}), r.context = x, r.__n = n, d = r.__d = !0, r.__h = [], r._sb = []), r.__s == null && (r.__s = r.state), b.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = C({}, r.__s)), C(r.__s, b.getDerivedStateFromProps(h, r.__s))), u = r.props, m = r.state, r.__v = t, d)
157
+ if (h = t.props, y = (p = b.contextType) && n[p.__c], x = p ? y ? y.props.value : p.__ : n, _.__c ? g = (r = t.__c = _.__c).__ = r.__E : ("prototype" in b && b.prototype.render ? t.__c = r = new b(h, x) : (t.__c = r = new I(h, x), r.constructor = b, r.render = je), y && y.sub(r), r.props = h, r.state || (r.state = {}), r.context = x, r.__n = n, d = r.__d = !0, r.__h = [], r._sb = []), r.__s == null && (r.__s = r.state), b.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = C({}, r.__s)), C(r.__s, b.getDerivedStateFromProps(h, r.__s))), u = r.props, m = r.state, r.__v = t, d)
158
158
  b.getDerivedStateFromProps == null && r.componentWillMount != null && r.componentWillMount(), r.componentDidMount != null && r.__h.push(r.componentDidMount);
159
159
  else {
160
160
  if (b.getDerivedStateFromProps == null && h !== u && r.componentWillReceiveProps != null && r.componentWillReceiveProps(h, x), !r.__e && (r.shouldComponentUpdate != null && r.shouldComponentUpdate(h, r.__s, x) === !1 || t.__v === _.__v)) {
@@ -177,7 +177,7 @@ function Y(e, t, _, n, o, i, c, s, a, l) {
177
177
  do
178
178
  r.__d = !1, w && w(t), p = r.render(r.props, r.state, r.context), r.state = r.__s;
179
179
  while (r.__d && ++Q < 25);
180
- r.state = r.__s, r.getChildContext != null && (n = C(C({}, n), r.getChildContext())), d || r.getSnapshotBeforeUpdate == null || (k = r.getSnapshotBeforeUpdate(u, m)), ve(e, G(A = p != null && p.type === W && p.key == null ? p.props.children : p) ? A : [A], t, _, n, o, i, c, s, a, l), r.base = t.__e, t.__u &= -161, r.__h.length && c.push(r), y && (r.__E = r.__ = null);
180
+ r.state = r.__s, r.getChildContext != null && (n = C(C({}, n), r.getChildContext())), d || r.getSnapshotBeforeUpdate == null || (k = r.getSnapshotBeforeUpdate(u, m)), ve(e, G(A = p != null && p.type === W && p.key == null ? p.props.children : p) ? A : [A], t, _, n, o, i, c, s, a, l), r.base = t.__e, t.__u &= -161, r.__h.length && c.push(r), g && (r.__E = r.__ = null);
181
181
  } catch (P) {
182
182
  t.__v = null, a || i != null ? (t.__e = s, t.__u |= a ? 160 : 32, i[i.indexOf(s)] = null) : (t.__e = _.__e, t.__k = _.__k), f.__e(P, t, _);
183
183
  }
@@ -185,7 +185,7 @@ function Y(e, t, _, n, o, i, c, s, a, l) {
185
185
  i == null && t.__v === _.__v ? (t.__k = _.__k, t.__e = _.__e) : t.__e = Ie(_.__e, t, _, n, o, i, c, a, l);
186
186
  (p = f.diffed) && p(t);
187
187
  }
188
- function ye(e, t, _) {
188
+ function ge(e, t, _) {
189
189
  t.__d = void 0;
190
190
  for (var n = 0; n < _.length; n++)
191
191
  K(_[n], _[++n], _[++n]);
@@ -200,35 +200,35 @@ function ye(e, t, _) {
200
200
  });
201
201
  }
202
202
  function Ie(e, t, _, n, o, i, c, s, a) {
203
- var l, p, r, d, u, m, k, y = _.props, h = t.props, g = t.type;
204
- if (g === "svg" && (o = !0), i != null) {
203
+ var l, p, r, d, u, m, k, g = _.props, h = t.props, y = t.type;
204
+ if (y === "svg" && (o = !0), i != null) {
205
205
  for (l = 0; l < i.length; l++)
206
- if ((u = i[l]) && "setAttribute" in u == !!g && (g ? u.localName === g : u.nodeType === 3)) {
206
+ if ((u = i[l]) && "setAttribute" in u == !!y && (y ? u.localName === y : u.nodeType === 3)) {
207
207
  e = u, i[l] = null;
208
208
  break;
209
209
  }
210
210
  }
211
211
  if (e == null) {
212
- if (g === null)
212
+ if (y === null)
213
213
  return document.createTextNode(h);
214
- e = o ? document.createElementNS("http://www.w3.org/2000/svg", g) : document.createElement(g, h.is && h), i = null, s = !1;
214
+ e = o ? document.createElementNS("http://www.w3.org/2000/svg", y) : document.createElement(y, h.is && h), i = null, s = !1;
215
215
  }
216
- if (g === null)
217
- y === h || s && e.data === h || (e.data = h);
216
+ if (y === null)
217
+ g === h || s && e.data === h || (e.data = h);
218
218
  else {
219
- if (i = i && V.call(e.childNodes), y = _.props || D, !s && i != null)
220
- for (y = {}, l = 0; l < e.attributes.length; l++)
221
- y[(u = e.attributes[l]).name] = u.value;
222
- for (l in y)
223
- u = y[l], l == "children" || (l == "dangerouslySetInnerHTML" ? r = u : l === "key" || l in h || N(e, l, null, u, o));
219
+ if (i = i && V.call(e.childNodes), g = _.props || D, !s && i != null)
220
+ for (g = {}, l = 0; l < e.attributes.length; l++)
221
+ g[(u = e.attributes[l]).name] = u.value;
222
+ for (l in g)
223
+ u = g[l], l == "children" || (l == "dangerouslySetInnerHTML" ? r = u : l === "key" || l in h || N(e, l, null, u, o));
224
224
  for (l in h)
225
- u = h[l], l == "children" ? d = u : l == "dangerouslySetInnerHTML" ? p = u : l == "value" ? m = u : l == "checked" ? k = u : l === "key" || s && typeof u != "function" || y[l] === u || N(e, l, u, y[l], o);
225
+ u = h[l], l == "children" ? d = u : l == "dangerouslySetInnerHTML" ? p = u : l == "value" ? m = u : l == "checked" ? k = u : l === "key" || s && typeof u != "function" || g[l] === u || N(e, l, u, g[l], o);
226
226
  if (p)
227
227
  s || r && (p.__html === r.__html || p.__html === e.innerHTML) || (e.innerHTML = p.__html), t.__k = [];
228
- else if (r && (e.innerHTML = ""), ve(e, G(d) ? d : [d], t, _, n, o && g !== "foreignObject", i, c, i ? i[0] : _.__k && E(_, 0), s, a), i != null)
228
+ else if (r && (e.innerHTML = ""), ve(e, G(d) ? d : [d], t, _, n, o && y !== "foreignObject", i, c, i ? i[0] : _.__k && E(_, 0), s, a), i != null)
229
229
  for (l = i.length; l--; )
230
230
  i[l] != null && de(i[l]);
231
- s || (l = "value", m !== void 0 && (m !== e[l] || g === "progress" && !m || g === "option" && m !== y[l]) && N(e, l, m, y[l], !1), l = "checked", k !== void 0 && k !== e[l] && N(e, l, k, y[l], !1));
231
+ s || (l = "value", m !== void 0 && (m !== e[l] || y === "progress" && !m || y === "option" && m !== g[l]) && N(e, l, m, g[l], !1), l = "checked", k !== void 0 && k !== e[l] && N(e, l, k, g[l], !1));
232
232
  }
233
233
  return e;
234
234
  }
@@ -260,7 +260,7 @@ function je(e, t, _) {
260
260
  }
261
261
  function Ue(e, t, _) {
262
262
  var n, o, i, c;
263
- f.__ && f.__(e, t), o = (n = typeof _ == "function") ? null : _ && _.__k || t.__k, i = [], c = [], Y(t, e = (!n && _ || t).__k = Pe(W, null, [e]), o || D, D, t.ownerSVGElement !== void 0, !n && _ ? [_] : o ? null : t.firstChild ? V.call(t.childNodes) : null, i, !n && _ ? _ : o ? o.__e : t.firstChild, n, c), ye(i, e, c);
263
+ f.__ && f.__(e, t), o = (n = typeof _ == "function") ? null : _ && _.__k || t.__k, i = [], c = [], Y(t, e = (!n && _ || t).__k = Pe(W, null, [e]), o || D, D, t.ownerSVGElement !== void 0, !n && _ ? [_] : o ? null : t.firstChild ? V.call(t.childNodes) : null, i, !n && _ ? _ : o ? o.__e : t.firstChild, n, c), ge(i, e, c);
264
264
  }
265
265
  V = pe.slice, f = { __e: function(e, t, _, n) {
266
266
  for (var o, i, c; t = t.__; )
@@ -280,7 +280,7 @@ V = pe.slice, f = { __e: function(e, t, _, n) {
280
280
  }, I.prototype.render = W, S = [], fe = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Z = function(e, t) {
281
281
  return e.__v.__b - t.__v.__b;
282
282
  }, F.__r = 0;
283
- var L, v, O, oe, J = 0, ge = [], j = [], re = f.__b, ie = f.__r, le = f.diffed, se = f.__c, ce = f.unmount;
283
+ var L, v, O, oe, J = 0, ye = [], j = [], re = f.__b, ie = f.__r, le = f.diffed, se = f.__c, ce = f.unmount;
284
284
  function be(e, t) {
285
285
  f.__h && f.__h(v, e, J || t), J = 0;
286
286
  var _ = v.__H || (v.__H = { __: [], __h: [] });
@@ -330,7 +330,7 @@ function Me(e, t) {
330
330
  !f.__s && Ae(_.__H, t) && (_.__ = e, _.i = t, v.__H.__h.push(_));
331
331
  }
332
332
  function Ve() {
333
- for (var e; e = ge.shift(); )
333
+ for (var e; e = ye.shift(); )
334
334
  if (e.__P && e.__H)
335
335
  try {
336
336
  e.__H.__h.forEach(U), e.__H.__h.forEach(R), e.__H.__h = [];
@@ -349,7 +349,7 @@ f.__b = function(e) {
349
349
  }, f.diffed = function(e) {
350
350
  le && le(e);
351
351
  var t = e.__c;
352
- t && t.__H && (t.__H.__h.length && (ge.push(t) !== 1 && oe === f.requestAnimationFrame || ((oe = f.requestAnimationFrame) || We)(Ve)), t.__H.__.forEach(function(_) {
352
+ t && t.__H && (t.__H.__h.length && (ye.push(t) !== 1 && oe === f.requestAnimationFrame || ((oe = f.requestAnimationFrame) || We)(Ve)), t.__H.__.forEach(function(_) {
353
353
  _.i && (_.__H = _.i), _.__V !== j && (_.__ = _.__V), _.i = void 0, _.__V = j;
354
354
  })), O = v = null;
355
355
  }, f.__c = function(e, t) {
@@ -434,6 +434,9 @@ class Oe {
434
434
  addToEcommerceCart(t) {
435
435
  console.log("Add to cart", t);
436
436
  }
437
+ navigateToCustomerPortal() {
438
+ console.log("Navigating to customer portal");
439
+ }
437
440
  }
438
441
  let M;
439
442
  const qe = ({
@@ -494,16 +497,16 @@ const Ze = (e) => {
494
497
  if (Object.keys(e).includes("defaultValue"))
495
498
  return e.defaultValue;
496
499
  };
497
- function ut(e) {
498
- return e.fields.map((t) => ({
499
- key: t.key,
500
+ function ut(e, ...t) {
501
+ return e.fields.filter((_) => !_.key || !t.includes(_.key)).map((_) => ({
502
+ key: _.key,
500
503
  fallbackToDefaultConfiguration: !1,
501
- value: Ze(t),
502
- type: t.type,
504
+ value: Ze(_),
505
+ type: _.type,
503
506
  asset: void 0
504
507
  }));
505
508
  }
506
- const ze = "@spiffcommerce/theme-bridge", Je = "1.11.2", Re = "module", Ge = {
509
+ const ze = "@spiffcommerce/theme-bridge", Je = "1.11.4", Re = "module", Ge = {
507
510
  build: "tsc && vite build",
508
511
  preview: "vite preview",
509
512
  dev: "ladle serve",
@@ -1,2 +1,2 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("#spiffThemeWrapper{width:100%;height:100%}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- (function(v,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("fs"),require("path")):typeof define=="function"&&define.amd?define(["exports","fs","path"],k):(v=typeof globalThis<"u"?globalThis:v||self,k(v.theme={},v.fs,v.path))})(this,function(v,k,w){"use strict";var Ke=Object.defineProperty;var Qe=(v,k,w)=>k in v?Ke(v,k,{enumerable:!0,configurable:!0,writable:!0,value:w}):v[k]=w;var ee=(v,k,w)=>(Qe(v,typeof k!="symbol"?k+"":k,w),w);var P=(e=>(e.Javascript="Javascript",e.CSS="CSS",e))(P||{}),te=(e=>(e.Asset="Asset",e.Boolean="Boolean",e.Color="Color",e.Heading="Heading",e.Number="Number",e.Select="Select",e.Text="Text",e))(te||{}),_e=(e=>(e.Color="Color",e.ColorProfile="ColorProfile",e.Data="Data",e.Environment="Environment",e.Font="Font",e.Frame="Frame",e.Illustration="Illustration",e.Image="Image",e.Material="Material",e.Model="Model",e.Video="Video",e))(_e||{}),N,f,ne,D,oe,re,Z,T={},ie=[],$e=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,z=Array.isArray;function S(e,t){for(var _ in t)e[_]=t[_];return e}function le(e){var t=e.parentNode;t&&t.removeChild(e)}function Te(e,t,_){var n,o,i,c={};for(i in t)i=="key"?n=t[i]:i=="ref"?o=t[i]:c[i]=t[i];if(arguments.length>2&&(c.children=arguments.length>3?N.call(arguments,2):_),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)c[i]===void 0&&(c[i]=e.defaultProps[i]);return I(e,c,n,o,null)}function I(e,t,_,n,o){var i={type:e,props:t,key:_,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:o??++ne,__i:-1,__u:0};return o==null&&f.vnode!=null&&f.vnode(i),i}function j(e){return e.children}function F(e,t){this.props=e,this.context=t}function $(e,t){if(t==null)return e.__?$(e.__,e.__i+1):null;for(var _;t<e.__k.length;t++)if((_=e.__k[t])!=null&&_.__e!=null)return _.__e;return typeof e.type=="function"?$(e):null}function se(e){var t,_;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((_=e.__k[t])!=null&&_.__e!=null){e.__e=e.__c.base=_.__e;break}return se(e)}}function ce(e){(!e.__d&&(e.__d=!0)&&D.push(e)&&!M.__r++||oe!==f.debounceRendering)&&((oe=f.debounceRendering)||re)(M)}function M(){var e,t,_,n,o,i,c,s,u;for(D.sort(Z);e=D.shift();)e.__d&&(t=D.length,n=void 0,i=(o=(_=e).__v).__e,s=[],u=[],(c=_.__P)&&((n=S({},o)).__v=o.__v+1,f.vnode&&f.vnode(n),J(c,n,o,_.__n,c.ownerSVGElement!==void 0,32&o.__u?[i]:null,s,i??$(o),!!(32&o.__u),u),n.__.__k[n.__i]=n,he(s,n,u),n.__e!=i&&se(n)),D.length>t&&D.sort(Z));M.__r=0}function ue(e,t,_,n,o,i,c,s,u,l,p){var r,d,a,y,C,g=n&&n.__k||ie,h=t.length;for(_.__d=u,He(_,t,g),u=_.__d,r=0;r<h;r++)(a=_.__k[r])!=null&&typeof a!="boolean"&&typeof a!="function"&&(d=a.__i===-1?T:g[a.__i]||T,a.__i=r,J(e,a,d,o,i,c,s,u,l,p),y=a.__e,a.ref&&d.ref!=a.ref&&(d.ref&&R(d.ref,null,a),p.push(a.ref,a.__c||y,a)),C==null&&y!=null&&(C=y),65536&a.__u||d.__k===a.__k?u=ae(a,u,e):typeof a.type=="function"&&a.__d!==void 0?u=a.__d:y&&(u=y.nextSibling),a.__d=void 0,a.__u&=-196609);_.__d=u,_.__e=C}function He(e,t,_){var n,o,i,c,s,u=t.length,l=_.length,p=l,r=0;for(e.__k=[],n=0;n<u;n++)(o=e.__k[n]=(o=t[n])==null||typeof o=="boolean"||typeof o=="function"?null:typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?I(null,o,null,null,o):z(o)?I(j,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?I(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o)!=null?(o.__=e,o.__b=e.__b+1,s=Pe(o,_,c=n+r,p),o.__i=s,i=null,s!==-1&&(p--,(i=_[s])&&(i.__u|=131072)),i==null||i.__v===null?(s==-1&&r--,typeof o.type!="function"&&(o.__u|=65536)):s!==c&&(s===c+1?r++:s>c?p>u-c?r+=s-c:r--:r=s<c&&s==c-1?s-c:0,s!==n+r&&(o.__u|=65536))):(i=_[n])&&i.key==null&&i.__e&&(i.__e==e.__d&&(e.__d=$(i)),G(i,i,!1),_[n]=null,p--);if(p)for(n=0;n<l;n++)(i=_[n])!=null&&!(131072&i.__u)&&(i.__e==e.__d&&(e.__d=$(i)),G(i,i))}function ae(e,t,_){var n,o;if(typeof e.type=="function"){for(n=e.__k,o=0;n&&o<n.length;o++)n[o]&&(n[o].__=e,t=ae(n[o],t,_));return t}return e.__e!=t&&(_.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function Pe(e,t,_,n){var o=e.key,i=e.type,c=_-1,s=_+1,u=t[_];if(u===null||u&&o==u.key&&i===u.type)return _;if(n>(u!=null&&!(131072&u.__u)?1:0))for(;c>=0||s<t.length;){if(c>=0){if((u=t[c])&&!(131072&u.__u)&&o==u.key&&i===u.type)return c;c--}if(s<t.length){if((u=t[s])&&!(131072&u.__u)&&o==u.key&&i===u.type)return s;s++}}return-1}function fe(e,t,_){t[0]==="-"?e.setProperty(t,_??""):e[t]=_==null?"":typeof _!="number"||$e.test(t)?_:_+"px"}function U(e,t,_,n,o){var i;e:if(t==="style")if(typeof _=="string")e.style.cssText=_;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)_&&t in _||fe(e.style,t,"");if(_)for(t in _)n&&_[t]===n[t]||fe(e.style,t,_[t])}else if(t[0]==="o"&&t[1]==="n")i=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=_,_?n?_.u=n.u:(_.u=Date.now(),e.addEventListener(t,i?de:pe,i)):e.removeEventListener(t,i?de:pe,i);else{if(o)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!=="width"&&t!=="height"&&t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t!=="rowSpan"&&t!=="colSpan"&&t!=="role"&&t in e)try{e[t]=_??"";break e}catch{}typeof _=="function"||(_==null||_===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,_))}}function pe(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(f.event?f.event(e):e)}function de(e){return this.l[e.type+!0](f.event?f.event(e):e)}function J(e,t,_,n,o,i,c,s,u,l){var p,r,d,a,y,C,g,h,b,E,O,H,De,q,X,x=t.type;if(t.constructor!==void 0)return null;128&_.__u&&(u=!!(32&_.__u),i=[s=t.__e=_.__e]),(p=f.__b)&&p(t);e:if(typeof x=="function")try{if(h=t.props,b=(p=x.contextType)&&n[p.__c],E=p?b?b.props.value:p.__:n,_.__c?g=(r=t.__c=_.__c).__=r.__E:("prototype"in x&&x.prototype.render?t.__c=r=new x(h,E):(t.__c=r=new F(h,E),r.constructor=x,r.render=Ie),b&&b.sub(r),r.props=h,r.state||(r.state={}),r.context=E,r.__n=n,d=r.__d=!0,r.__h=[],r._sb=[]),r.__s==null&&(r.__s=r.state),x.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=S({},r.__s)),S(r.__s,x.getDerivedStateFromProps(h,r.__s))),a=r.props,y=r.state,r.__v=t,d)x.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(x.getDerivedStateFromProps==null&&h!==a&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(h,E),!r.__e&&(r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(h,r.__s,E)===!1||t.__v===_.__v)){for(t.__v!==_.__v&&(r.props=h,r.state=r.__s,r.__d=!1),t.__e=_.__e,t.__k=_.__k,t.__k.forEach(function(B){B&&(B.__=t)}),O=0;O<r._sb.length;O++)r.__h.push(r._sb[O]);r._sb=[],r.__h.length&&c.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(h,r.__s,E),r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(a,y,C)})}if(r.context=E,r.props=h,r.__P=e,r.__e=!1,H=f.__r,De=0,"prototype"in x&&x.prototype.render){for(r.state=r.__s,r.__d=!1,H&&H(t),p=r.render(r.props,r.state,r.context),q=0;q<r._sb.length;q++)r.__h.push(r._sb[q]);r._sb=[]}else do r.__d=!1,H&&H(t),p=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++De<25);r.state=r.__s,r.getChildContext!=null&&(n=S(S({},n),r.getChildContext())),d||r.getSnapshotBeforeUpdate==null||(C=r.getSnapshotBeforeUpdate(a,y)),ue(e,z(X=p!=null&&p.type===j&&p.key==null?p.props.children:p)?X:[X],t,_,n,o,i,c,s,u,l),r.base=t.__e,t.__u&=-161,r.__h.length&&c.push(r),g&&(r.__E=r.__=null)}catch(B){t.__v=null,u||i!=null?(t.__e=s,t.__u|=u?160:32,i[i.indexOf(s)]=null):(t.__e=_.__e,t.__k=_.__k),f.__e(B,t,_)}else i==null&&t.__v===_.__v?(t.__k=_.__k,t.__e=_.__e):t.__e=Ne(_.__e,t,_,n,o,i,c,u,l);(p=f.diffed)&&p(t)}function he(e,t,_){t.__d=void 0;for(var n=0;n<_.length;n++)R(_[n],_[++n],_[++n]);f.__c&&f.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(i){i.call(o)})}catch(i){f.__e(i,o.__v)}})}function Ne(e,t,_,n,o,i,c,s,u){var l,p,r,d,a,y,C,g=_.props,h=t.props,b=t.type;if(b==="svg"&&(o=!0),i!=null){for(l=0;l<i.length;l++)if((a=i[l])&&"setAttribute"in a==!!b&&(b?a.localName===b:a.nodeType===3)){e=a,i[l]=null;break}}if(e==null){if(b===null)return document.createTextNode(h);e=o?document.createElementNS("http://www.w3.org/2000/svg",b):document.createElement(b,h.is&&h),i=null,s=!1}if(b===null)g===h||s&&e.data===h||(e.data=h);else{if(i=i&&N.call(e.childNodes),g=_.props||T,!s&&i!=null)for(g={},l=0;l<e.attributes.length;l++)g[(a=e.attributes[l]).name]=a.value;for(l in g)a=g[l],l=="children"||(l=="dangerouslySetInnerHTML"?r=a:l==="key"||l in h||U(e,l,null,a,o));for(l in h)a=h[l],l=="children"?d=a:l=="dangerouslySetInnerHTML"?p=a:l=="value"?y=a:l=="checked"?C=a:l==="key"||s&&typeof a!="function"||g[l]===a||U(e,l,a,g[l],o);if(p)s||r&&(p.__html===r.__html||p.__html===e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(r&&(e.innerHTML=""),ue(e,z(d)?d:[d],t,_,n,o&&b!=="foreignObject",i,c,i?i[0]:_.__k&&$(_,0),s,u),i!=null)for(l=i.length;l--;)i[l]!=null&&le(i[l]);s||(l="value",y!==void 0&&(y!==e[l]||b==="progress"&&!y||b==="option"&&y!==g[l])&&U(e,l,y,g[l],!1),l="checked",C!==void 0&&C!==e[l]&&U(e,l,C,g[l],!1))}return e}function R(e,t,_){try{typeof e=="function"?e(t):e.current=t}catch(n){f.__e(n,_)}}function G(e,t,_){var n,o;if(f.unmount&&f.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||R(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(i){f.__e(i,t)}n.base=n.__P=null,e.__c=void 0}if(n=e.__k)for(o=0;o<n.length;o++)n[o]&&G(n[o],t,_||typeof e.type!="function");_||e.__e==null||le(e.__e),e.__=e.__e=e.__d=void 0}function Ie(e,t,_){return this.constructor(e,_)}function je(e,t,_){var n,o,i,c;f.__&&f.__(e,t),o=(n=typeof _=="function")?null:_&&_.__k||t.__k,i=[],c=[],J(t,e=(!n&&_||t).__k=Te(j,null,[e]),o||T,T,t.ownerSVGElement!==void 0,!n&&_?[_]:o?null:t.firstChild?N.call(t.childNodes):null,i,!n&&_?_:o?o.__e:t.firstChild,n,c),he(i,e,c)}N=ie.slice,f={__e:function(e,t,_,n){for(var o,i,c;t=t.__;)if((o=t.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(e)),c=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,n||{}),c=o.__d),c)return o.__E=o}catch(s){e=s}throw e}},ne=0,F.prototype.setState=function(e,t){var _;_=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=S({},this.state),typeof e=="function"&&(e=e(S({},_),this.props)),e&&S(_,e),e!=null&&this.__v&&(t&&this._sb.push(t),ce(this))},F.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ce(this))},F.prototype.render=j,D=[],re=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Z=function(e,t){return e.__v.__b-t.__v.__b},M.__r=0;var L,m,Y,me,K=0,ve=[],A=[],ye=f.__b,ge=f.__r,be=f.diffed,ke=f.__c,xe=f.unmount;function Ce(e,t){f.__h&&f.__h(m,e,K||t),K=0;var _=m.__H||(m.__H={__:[],__h:[]});return e>=_.__.length&&_.__.push({__V:A}),_.__[e]}function Fe(e){return K=1,Me(Ee,e)}function Me(e,t,_){var n=Ce(L++,2);if(n.t=e,!n.__c&&(n.__=[_?_(t):Ee(void 0,t),function(s){var u=n.__N?n.__N[0]:n.__[0],l=n.t(u,s);u!==l&&(n.__N=[l,n.__[1]],n.__c.setState({}))}],n.__c=m,!m.u)){var o=function(s,u,l){if(!n.__c.__H)return!0;var p=n.__c.__H.__.filter(function(d){return d.__c});if(p.every(function(d){return!d.__N}))return!i||i.call(this,s,u,l);var r=!1;return p.forEach(function(d){if(d.__N){var a=d.__[0];d.__=d.__N,d.__N=void 0,a!==d.__[0]&&(r=!0)}}),!(!r&&n.__c.props===s)&&(!i||i.call(this,s,u,l))};m.u=!0;var i=m.shouldComponentUpdate,c=m.componentWillUpdate;m.componentWillUpdate=function(s,u,l){if(this.__e){var p=i;i=void 0,o(s,u,l),i=p}c&&c.call(this,s,u,l)},m.shouldComponentUpdate=o}return n.__N||n.__}function Ue(e,t){var _=Ce(L++,3);!f.__s&&Ve(_.__H,t)&&(_.__=e,_.i=t,m.__H.__h.push(_))}function Le(){for(var e;e=ve.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(V),e.__H.__h.forEach(Q),e.__H.__h=[]}catch(t){e.__H.__h=[],f.__e(t,e.__v)}}f.__b=function(e){m=null,ye&&ye(e)},f.__r=function(e){ge&&ge(e),L=0;var t=(m=e.__c).__H;t&&(Y===m?(t.__h=[],m.__h=[],t.__.forEach(function(_){_.__N&&(_.__=_.__N),_.__V=A,_.__N=_.i=void 0})):(t.__h.forEach(V),t.__h.forEach(Q),t.__h=[],L=0)),Y=m},f.diffed=function(e){be&&be(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ve.push(t)!==1&&me===f.requestAnimationFrame||((me=f.requestAnimationFrame)||Ae)(Le)),t.__H.__.forEach(function(_){_.i&&(_.__H=_.i),_.__V!==A&&(_.__=_.__V),_.i=void 0,_.__V=A})),Y=m=null},f.__c=function(e,t){t.some(function(_){try{_.__h.forEach(V),_.__h=_.__h.filter(function(n){return!n.__||Q(n)})}catch(n){t.some(function(o){o.__h&&(o.__h=[])}),t=[],f.__e(n,_.__v)}}),ke&&ke(e,t)},f.unmount=function(e){xe&&xe(e);var t,_=e.__c;_&&_.__H&&(_.__H.__.forEach(function(n){try{V(n)}catch(o){t=o}}),_.__H=void 0,t&&f.__e(t,_.__v))};var Se=typeof requestAnimationFrame=="function";function Ae(e){var t,_=function(){clearTimeout(n),Se&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(_,100);Se&&(t=requestAnimationFrame(_))}function V(e){var t=m,_=e.__c;typeof _=="function"&&(e.__c=void 0,_()),m=t}function Q(e){var t=m;e.__c=e.__(),m=t}function Ve(e,t){return!e||e.length!==t.length||t.some(function(_,n){return _!==e[n]})}function Ee(e,t){return typeof t=="function"?t(e):t}var We=0;function we(e,t,_,n,o,i){var c,s,u={};for(s in t)s=="ref"?c=t[s]:u[s]=t[s];var l={type:e,props:u,key:_,ref:c,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--We,__i:-1,__u:0,__source:o,__self:i};if(typeof e=="function"&&(c=e.defaultProps))for(s in c)u[s]===void 0&&(u[s]=c[s]);return f.vnode&&f.vnode(l),l}class Oe{constructor(){ee(this,"_context");ee(this,"_getContextCallbacks",[])}async getContext(){return this._context?this._context:new Promise(t=>{this._getContextCallbacks.push(t)})}setContext(t){this._context=t,this._getContextCallbacks.forEach(_=>_(t)),this._getContextCallbacks=[]}configureClient(t){console.log("Client configured")}themeLoaded(){console.log("Theme loaded")}close(){console.log("Theme closed")}addToEcommerceCart(t){console.log("Add to cart",t)}}let W;const qe=({context:e})=>{const[t,_]=Fe(null);return Ue(()=>{if(t){if(W===void 0)throw new Error("Please call setSpiffDevOptions before requesting the context.");W.setContext({...e,container:t})}},[t,e]),we("div",{ref:_,id:"spiffThemeWrapper"})};function Be(e,t){W=new Oe,window.SpiffThemeLoader=W;let _;typeof e=="string"?_=document.getElementById(e):_=e,je(we(qe,{context:t}),_)}function Ze(e){return{id:"example",themeInstallId:(e==null?void 0:e.themeInstallId)??"example",name:"Example Configuration",createdAt:"2021-01-01T00:00:00Z",updatedAt:"2021-01-01T00:00:00Z",themeVersion:{id:"example",version:"1.0.0",createdAt:"2021-01-01T00:00:00Z",updatedAt:"2021-01-01T00:00:00Z",configurationSchema:{fields:[]},launchData:{targetFiles:[]},theme:{id:"example",name:"Example Theme",createdAt:"2021-01-01T00:00:00Z",updatedAt:"2021-01-01T00:00:00Z"}},fields:[],...e}}const ze=e=>{if(Object.keys(e).includes("defaultValue"))return e.defaultValue};function Je(e){return e.fields.map(t=>({key:t.key,fallbackToDefaultConfiguration:!1,value:ze(t),type:t.type,asset:void 0}))}const Re={name:"@spiffcommerce/theme-bridge",version:"1.11.2",type:"module",scripts:{build:"tsc && vite build",preview:"vite preview",dev:"ladle serve",schema:"node --no-warnings=ExperimentalWarning --loader ts-node/esm scripts/generateSchema.ts"},main:"./dist/index.umd.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",files:["./dist"],exports:{import:"./dist/index.js",require:"./dist/index.umd.cjs"},dependencies:{},devDependencies:{"@ladle/react":"^4.0.2","@preact/preset-vite":"^2.7.0","@spiffcommerce/core":"^21.0.1","@types/node":"^20.11.16","@typescript-eslint/eslint-plugin":"^7.1.0","@typescript-eslint/parser":"^7.1.0",eslint:"^8.57.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3",preact:"^10.19.3",prettier:"^3.2.4",rollup:"^4.12.0","ts-json-schema-generator":"^1.5.0","ts-node":"^10.9.2",tsup:"^8.0.1",typescript:"^5.2.2",vite:"^5.0.8","vite-plugin-css-injected-by-js":"^3.4.0","vite-plugin-externalize-deps":"^0.8.0"},peerDependencies:{"@spiffcommerce/core":"^21.0.1"}};function Ge(e,t,_){if(t.type==="chunk"){if(console.log(`chunk ${e} isEntry: ${t.isEntry}, isDynamicEntry: ${t.isDynamicEntry}, isImplicitEntry: ${t.isImplicitEntry}`),!t.isEntry&&!_)return null;if(!t.isDynamicEntry)return{type:P.Javascript,mimeType:"text/javascript",preload:!t.isEntry,filename:e}}else if(e.endsWith(".css"))return{type:P.CSS,mimeType:"text/css",filename:e};return null}function Ye(e){const{autoGenerateTargetFiles:t=!0,configurationSchema:_,includePreloadChunks:n=!1,targetFiles:o}=e??{};return{name:"spiff-theme-plugin",version:Re.version,config(i,c){i.base!==void 0&&i.base!==""&&console.warn('You have specified a `base` in your vite configuration other than "". This value will now be overwritten.'),i.base=""},writeBundle(i,c){const s=t?Object.keys(c).map(l=>o!=null&&o.some(p=>p.filename===l)?null:Ge(l,c[l],n)).filter(l=>l!==null):[];o&&s.push(...o);const u={launchData:{targetFiles:s},configurationSchema:_};k.writeFileSync(w.join(i.dir,"spiffTheme.json"),JSON.stringify(u,void 0,4))}}}v.AssetType=_e,v.FieldType=te,v.ThemeFileType=P,v.exampleThemeInstallConfig=Ze,v.getDefaultsForSchema=Je,v.setSpiffDevOptions=Be,v.spiffThemePlugin=Ye,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
2
+ (function(v,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("fs"),require("path")):typeof define=="function"&&define.amd?define(["exports","fs","path"],k):(v=typeof globalThis<"u"?globalThis:v||self,k(v.theme={},v.fs,v.path))})(this,function(v,k,w){"use strict";var Ke=Object.defineProperty;var Qe=(v,k,w)=>k in v?Ke(v,k,{enumerable:!0,configurable:!0,writable:!0,value:w}):v[k]=w;var ee=(v,k,w)=>(Qe(v,typeof k!="symbol"?k+"":k,w),w);var H=(e=>(e.Javascript="Javascript",e.CSS="CSS",e))(H||{}),te=(e=>(e.Asset="Asset",e.Boolean="Boolean",e.Color="Color",e.Heading="Heading",e.Number="Number",e.Select="Select",e.Text="Text",e))(te||{}),_e=(e=>(e.Color="Color",e.ColorProfile="ColorProfile",e.Data="Data",e.Environment="Environment",e.Font="Font",e.Frame="Frame",e.Illustration="Illustration",e.Image="Image",e.Material="Material",e.Model="Model",e.Video="Video",e))(_e||{}),N,f,ne,D,oe,re,Z,T={},ie=[],$e=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,z=Array.isArray;function S(e,t){for(var _ in t)e[_]=t[_];return e}function le(e){var t=e.parentNode;t&&t.removeChild(e)}function Te(e,t,_){var n,o,i,c={};for(i in t)i=="key"?n=t[i]:i=="ref"?o=t[i]:c[i]=t[i];if(arguments.length>2&&(c.children=arguments.length>3?N.call(arguments,2):_),typeof e=="function"&&e.defaultProps!=null)for(i in e.defaultProps)c[i]===void 0&&(c[i]=e.defaultProps[i]);return I(e,c,n,o,null)}function I(e,t,_,n,o){var i={type:e,props:t,key:_,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:o??++ne,__i:-1,__u:0};return o==null&&f.vnode!=null&&f.vnode(i),i}function j(e){return e.children}function F(e,t){this.props=e,this.context=t}function $(e,t){if(t==null)return e.__?$(e.__,e.__i+1):null;for(var _;t<e.__k.length;t++)if((_=e.__k[t])!=null&&_.__e!=null)return _.__e;return typeof e.type=="function"?$(e):null}function se(e){var t,_;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((_=e.__k[t])!=null&&_.__e!=null){e.__e=e.__c.base=_.__e;break}return se(e)}}function ce(e){(!e.__d&&(e.__d=!0)&&D.push(e)&&!M.__r++||oe!==f.debounceRendering)&&((oe=f.debounceRendering)||re)(M)}function M(){var e,t,_,n,o,i,c,s,u;for(D.sort(Z);e=D.shift();)e.__d&&(t=D.length,n=void 0,i=(o=(_=e).__v).__e,s=[],u=[],(c=_.__P)&&((n=S({},o)).__v=o.__v+1,f.vnode&&f.vnode(n),J(c,n,o,_.__n,c.ownerSVGElement!==void 0,32&o.__u?[i]:null,s,i??$(o),!!(32&o.__u),u),n.__.__k[n.__i]=n,he(s,n,u),n.__e!=i&&se(n)),D.length>t&&D.sort(Z));M.__r=0}function ue(e,t,_,n,o,i,c,s,u,l,p){var r,d,a,y,C,g=n&&n.__k||ie,h=t.length;for(_.__d=u,Pe(_,t,g),u=_.__d,r=0;r<h;r++)(a=_.__k[r])!=null&&typeof a!="boolean"&&typeof a!="function"&&(d=a.__i===-1?T:g[a.__i]||T,a.__i=r,J(e,a,d,o,i,c,s,u,l,p),y=a.__e,a.ref&&d.ref!=a.ref&&(d.ref&&R(d.ref,null,a),p.push(a.ref,a.__c||y,a)),C==null&&y!=null&&(C=y),65536&a.__u||d.__k===a.__k?u=ae(a,u,e):typeof a.type=="function"&&a.__d!==void 0?u=a.__d:y&&(u=y.nextSibling),a.__d=void 0,a.__u&=-196609);_.__d=u,_.__e=C}function Pe(e,t,_){var n,o,i,c,s,u=t.length,l=_.length,p=l,r=0;for(e.__k=[],n=0;n<u;n++)(o=e.__k[n]=(o=t[n])==null||typeof o=="boolean"||typeof o=="function"?null:typeof o=="string"||typeof o=="number"||typeof o=="bigint"||o.constructor==String?I(null,o,null,null,o):z(o)?I(j,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?I(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o)!=null?(o.__=e,o.__b=e.__b+1,s=He(o,_,c=n+r,p),o.__i=s,i=null,s!==-1&&(p--,(i=_[s])&&(i.__u|=131072)),i==null||i.__v===null?(s==-1&&r--,typeof o.type!="function"&&(o.__u|=65536)):s!==c&&(s===c+1?r++:s>c?p>u-c?r+=s-c:r--:r=s<c&&s==c-1?s-c:0,s!==n+r&&(o.__u|=65536))):(i=_[n])&&i.key==null&&i.__e&&(i.__e==e.__d&&(e.__d=$(i)),G(i,i,!1),_[n]=null,p--);if(p)for(n=0;n<l;n++)(i=_[n])!=null&&!(131072&i.__u)&&(i.__e==e.__d&&(e.__d=$(i)),G(i,i))}function ae(e,t,_){var n,o;if(typeof e.type=="function"){for(n=e.__k,o=0;n&&o<n.length;o++)n[o]&&(n[o].__=e,t=ae(n[o],t,_));return t}return e.__e!=t&&(_.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function He(e,t,_,n){var o=e.key,i=e.type,c=_-1,s=_+1,u=t[_];if(u===null||u&&o==u.key&&i===u.type)return _;if(n>(u!=null&&!(131072&u.__u)?1:0))for(;c>=0||s<t.length;){if(c>=0){if((u=t[c])&&!(131072&u.__u)&&o==u.key&&i===u.type)return c;c--}if(s<t.length){if((u=t[s])&&!(131072&u.__u)&&o==u.key&&i===u.type)return s;s++}}return-1}function fe(e,t,_){t[0]==="-"?e.setProperty(t,_??""):e[t]=_==null?"":typeof _!="number"||$e.test(t)?_:_+"px"}function U(e,t,_,n,o){var i;e:if(t==="style")if(typeof _=="string")e.style.cssText=_;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)_&&t in _||fe(e.style,t,"");if(_)for(t in _)n&&_[t]===n[t]||fe(e.style,t,_[t])}else if(t[0]==="o"&&t[1]==="n")i=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=_,_?n?_.u=n.u:(_.u=Date.now(),e.addEventListener(t,i?de:pe,i)):e.removeEventListener(t,i?de:pe,i);else{if(o)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!=="width"&&t!=="height"&&t!=="href"&&t!=="list"&&t!=="form"&&t!=="tabIndex"&&t!=="download"&&t!=="rowSpan"&&t!=="colSpan"&&t!=="role"&&t in e)try{e[t]=_??"";break e}catch{}typeof _=="function"||(_==null||_===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,_))}}function pe(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(f.event?f.event(e):e)}function de(e){return this.l[e.type+!0](f.event?f.event(e):e)}function J(e,t,_,n,o,i,c,s,u,l){var p,r,d,a,y,C,g,h,b,E,O,P,De,q,X,x=t.type;if(t.constructor!==void 0)return null;128&_.__u&&(u=!!(32&_.__u),i=[s=t.__e=_.__e]),(p=f.__b)&&p(t);e:if(typeof x=="function")try{if(h=t.props,b=(p=x.contextType)&&n[p.__c],E=p?b?b.props.value:p.__:n,_.__c?g=(r=t.__c=_.__c).__=r.__E:("prototype"in x&&x.prototype.render?t.__c=r=new x(h,E):(t.__c=r=new F(h,E),r.constructor=x,r.render=Ie),b&&b.sub(r),r.props=h,r.state||(r.state={}),r.context=E,r.__n=n,d=r.__d=!0,r.__h=[],r._sb=[]),r.__s==null&&(r.__s=r.state),x.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=S({},r.__s)),S(r.__s,x.getDerivedStateFromProps(h,r.__s))),a=r.props,y=r.state,r.__v=t,d)x.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(x.getDerivedStateFromProps==null&&h!==a&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(h,E),!r.__e&&(r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(h,r.__s,E)===!1||t.__v===_.__v)){for(t.__v!==_.__v&&(r.props=h,r.state=r.__s,r.__d=!1),t.__e=_.__e,t.__k=_.__k,t.__k.forEach(function(B){B&&(B.__=t)}),O=0;O<r._sb.length;O++)r.__h.push(r._sb[O]);r._sb=[],r.__h.length&&c.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(h,r.__s,E),r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(a,y,C)})}if(r.context=E,r.props=h,r.__P=e,r.__e=!1,P=f.__r,De=0,"prototype"in x&&x.prototype.render){for(r.state=r.__s,r.__d=!1,P&&P(t),p=r.render(r.props,r.state,r.context),q=0;q<r._sb.length;q++)r.__h.push(r._sb[q]);r._sb=[]}else do r.__d=!1,P&&P(t),p=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++De<25);r.state=r.__s,r.getChildContext!=null&&(n=S(S({},n),r.getChildContext())),d||r.getSnapshotBeforeUpdate==null||(C=r.getSnapshotBeforeUpdate(a,y)),ue(e,z(X=p!=null&&p.type===j&&p.key==null?p.props.children:p)?X:[X],t,_,n,o,i,c,s,u,l),r.base=t.__e,t.__u&=-161,r.__h.length&&c.push(r),g&&(r.__E=r.__=null)}catch(B){t.__v=null,u||i!=null?(t.__e=s,t.__u|=u?160:32,i[i.indexOf(s)]=null):(t.__e=_.__e,t.__k=_.__k),f.__e(B,t,_)}else i==null&&t.__v===_.__v?(t.__k=_.__k,t.__e=_.__e):t.__e=Ne(_.__e,t,_,n,o,i,c,u,l);(p=f.diffed)&&p(t)}function he(e,t,_){t.__d=void 0;for(var n=0;n<_.length;n++)R(_[n],_[++n],_[++n]);f.__c&&f.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(i){i.call(o)})}catch(i){f.__e(i,o.__v)}})}function Ne(e,t,_,n,o,i,c,s,u){var l,p,r,d,a,y,C,g=_.props,h=t.props,b=t.type;if(b==="svg"&&(o=!0),i!=null){for(l=0;l<i.length;l++)if((a=i[l])&&"setAttribute"in a==!!b&&(b?a.localName===b:a.nodeType===3)){e=a,i[l]=null;break}}if(e==null){if(b===null)return document.createTextNode(h);e=o?document.createElementNS("http://www.w3.org/2000/svg",b):document.createElement(b,h.is&&h),i=null,s=!1}if(b===null)g===h||s&&e.data===h||(e.data=h);else{if(i=i&&N.call(e.childNodes),g=_.props||T,!s&&i!=null)for(g={},l=0;l<e.attributes.length;l++)g[(a=e.attributes[l]).name]=a.value;for(l in g)a=g[l],l=="children"||(l=="dangerouslySetInnerHTML"?r=a:l==="key"||l in h||U(e,l,null,a,o));for(l in h)a=h[l],l=="children"?d=a:l=="dangerouslySetInnerHTML"?p=a:l=="value"?y=a:l=="checked"?C=a:l==="key"||s&&typeof a!="function"||g[l]===a||U(e,l,a,g[l],o);if(p)s||r&&(p.__html===r.__html||p.__html===e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(r&&(e.innerHTML=""),ue(e,z(d)?d:[d],t,_,n,o&&b!=="foreignObject",i,c,i?i[0]:_.__k&&$(_,0),s,u),i!=null)for(l=i.length;l--;)i[l]!=null&&le(i[l]);s||(l="value",y!==void 0&&(y!==e[l]||b==="progress"&&!y||b==="option"&&y!==g[l])&&U(e,l,y,g[l],!1),l="checked",C!==void 0&&C!==e[l]&&U(e,l,C,g[l],!1))}return e}function R(e,t,_){try{typeof e=="function"?e(t):e.current=t}catch(n){f.__e(n,_)}}function G(e,t,_){var n,o;if(f.unmount&&f.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||R(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(i){f.__e(i,t)}n.base=n.__P=null,e.__c=void 0}if(n=e.__k)for(o=0;o<n.length;o++)n[o]&&G(n[o],t,_||typeof e.type!="function");_||e.__e==null||le(e.__e),e.__=e.__e=e.__d=void 0}function Ie(e,t,_){return this.constructor(e,_)}function je(e,t,_){var n,o,i,c;f.__&&f.__(e,t),o=(n=typeof _=="function")?null:_&&_.__k||t.__k,i=[],c=[],J(t,e=(!n&&_||t).__k=Te(j,null,[e]),o||T,T,t.ownerSVGElement!==void 0,!n&&_?[_]:o?null:t.firstChild?N.call(t.childNodes):null,i,!n&&_?_:o?o.__e:t.firstChild,n,c),he(i,e,c)}N=ie.slice,f={__e:function(e,t,_,n){for(var o,i,c;t=t.__;)if((o=t.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(e)),c=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,n||{}),c=o.__d),c)return o.__E=o}catch(s){e=s}throw e}},ne=0,F.prototype.setState=function(e,t){var _;_=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=S({},this.state),typeof e=="function"&&(e=e(S({},_),this.props)),e&&S(_,e),e!=null&&this.__v&&(t&&this._sb.push(t),ce(this))},F.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),ce(this))},F.prototype.render=j,D=[],re=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Z=function(e,t){return e.__v.__b-t.__v.__b},M.__r=0;var L,m,Y,me,K=0,ve=[],A=[],ye=f.__b,ge=f.__r,be=f.diffed,ke=f.__c,xe=f.unmount;function Ce(e,t){f.__h&&f.__h(m,e,K||t),K=0;var _=m.__H||(m.__H={__:[],__h:[]});return e>=_.__.length&&_.__.push({__V:A}),_.__[e]}function Fe(e){return K=1,Me(Ee,e)}function Me(e,t,_){var n=Ce(L++,2);if(n.t=e,!n.__c&&(n.__=[_?_(t):Ee(void 0,t),function(s){var u=n.__N?n.__N[0]:n.__[0],l=n.t(u,s);u!==l&&(n.__N=[l,n.__[1]],n.__c.setState({}))}],n.__c=m,!m.u)){var o=function(s,u,l){if(!n.__c.__H)return!0;var p=n.__c.__H.__.filter(function(d){return d.__c});if(p.every(function(d){return!d.__N}))return!i||i.call(this,s,u,l);var r=!1;return p.forEach(function(d){if(d.__N){var a=d.__[0];d.__=d.__N,d.__N=void 0,a!==d.__[0]&&(r=!0)}}),!(!r&&n.__c.props===s)&&(!i||i.call(this,s,u,l))};m.u=!0;var i=m.shouldComponentUpdate,c=m.componentWillUpdate;m.componentWillUpdate=function(s,u,l){if(this.__e){var p=i;i=void 0,o(s,u,l),i=p}c&&c.call(this,s,u,l)},m.shouldComponentUpdate=o}return n.__N||n.__}function Ue(e,t){var _=Ce(L++,3);!f.__s&&Ve(_.__H,t)&&(_.__=e,_.i=t,m.__H.__h.push(_))}function Le(){for(var e;e=ve.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(V),e.__H.__h.forEach(Q),e.__H.__h=[]}catch(t){e.__H.__h=[],f.__e(t,e.__v)}}f.__b=function(e){m=null,ye&&ye(e)},f.__r=function(e){ge&&ge(e),L=0;var t=(m=e.__c).__H;t&&(Y===m?(t.__h=[],m.__h=[],t.__.forEach(function(_){_.__N&&(_.__=_.__N),_.__V=A,_.__N=_.i=void 0})):(t.__h.forEach(V),t.__h.forEach(Q),t.__h=[],L=0)),Y=m},f.diffed=function(e){be&&be(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ve.push(t)!==1&&me===f.requestAnimationFrame||((me=f.requestAnimationFrame)||Ae)(Le)),t.__H.__.forEach(function(_){_.i&&(_.__H=_.i),_.__V!==A&&(_.__=_.__V),_.i=void 0,_.__V=A})),Y=m=null},f.__c=function(e,t){t.some(function(_){try{_.__h.forEach(V),_.__h=_.__h.filter(function(n){return!n.__||Q(n)})}catch(n){t.some(function(o){o.__h&&(o.__h=[])}),t=[],f.__e(n,_.__v)}}),ke&&ke(e,t)},f.unmount=function(e){xe&&xe(e);var t,_=e.__c;_&&_.__H&&(_.__H.__.forEach(function(n){try{V(n)}catch(o){t=o}}),_.__H=void 0,t&&f.__e(t,_.__v))};var Se=typeof requestAnimationFrame=="function";function Ae(e){var t,_=function(){clearTimeout(n),Se&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(_,100);Se&&(t=requestAnimationFrame(_))}function V(e){var t=m,_=e.__c;typeof _=="function"&&(e.__c=void 0,_()),m=t}function Q(e){var t=m;e.__c=e.__(),m=t}function Ve(e,t){return!e||e.length!==t.length||t.some(function(_,n){return _!==e[n]})}function Ee(e,t){return typeof t=="function"?t(e):t}var We=0;function we(e,t,_,n,o,i){var c,s,u={};for(s in t)s=="ref"?c=t[s]:u[s]=t[s];var l={type:e,props:u,key:_,ref:c,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--We,__i:-1,__u:0,__source:o,__self:i};if(typeof e=="function"&&(c=e.defaultProps))for(s in c)u[s]===void 0&&(u[s]=c[s]);return f.vnode&&f.vnode(l),l}class Oe{constructor(){ee(this,"_context");ee(this,"_getContextCallbacks",[])}async getContext(){return this._context?this._context:new Promise(t=>{this._getContextCallbacks.push(t)})}setContext(t){this._context=t,this._getContextCallbacks.forEach(_=>_(t)),this._getContextCallbacks=[]}configureClient(t){console.log("Client configured")}themeLoaded(){console.log("Theme loaded")}close(){console.log("Theme closed")}addToEcommerceCart(t){console.log("Add to cart",t)}navigateToCustomerPortal(){console.log("Navigating to customer portal")}}let W;const qe=({context:e})=>{const[t,_]=Fe(null);return Ue(()=>{if(t){if(W===void 0)throw new Error("Please call setSpiffDevOptions before requesting the context.");W.setContext({...e,container:t})}},[t,e]),we("div",{ref:_,id:"spiffThemeWrapper"})};function Be(e,t){W=new Oe,window.SpiffThemeLoader=W;let _;typeof e=="string"?_=document.getElementById(e):_=e,je(we(qe,{context:t}),_)}function Ze(e){return{id:"example",themeInstallId:(e==null?void 0:e.themeInstallId)??"example",name:"Example Configuration",createdAt:"2021-01-01T00:00:00Z",updatedAt:"2021-01-01T00:00:00Z",themeVersion:{id:"example",version:"1.0.0",createdAt:"2021-01-01T00:00:00Z",updatedAt:"2021-01-01T00:00:00Z",configurationSchema:{fields:[]},launchData:{targetFiles:[]},theme:{id:"example",name:"Example Theme",createdAt:"2021-01-01T00:00:00Z",updatedAt:"2021-01-01T00:00:00Z"}},fields:[],...e}}const ze=e=>{if(Object.keys(e).includes("defaultValue"))return e.defaultValue};function Je(e,...t){return e.fields.filter(_=>!_.key||!t.includes(_.key)).map(_=>({key:_.key,fallbackToDefaultConfiguration:!1,value:ze(_),type:_.type,asset:void 0}))}const Re={name:"@spiffcommerce/theme-bridge",version:"1.11.4",type:"module",scripts:{build:"tsc && vite build",preview:"vite preview",dev:"ladle serve",schema:"node --no-warnings=ExperimentalWarning --loader ts-node/esm scripts/generateSchema.ts"},main:"./dist/index.umd.cjs",module:"./dist/index.js",types:"./dist/index.d.ts",files:["./dist"],exports:{import:"./dist/index.js",require:"./dist/index.umd.cjs"},dependencies:{},devDependencies:{"@ladle/react":"^4.0.2","@preact/preset-vite":"^2.7.0","@spiffcommerce/core":"^21.0.1","@types/node":"^20.11.16","@typescript-eslint/eslint-plugin":"^7.1.0","@typescript-eslint/parser":"^7.1.0",eslint:"^8.57.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3",preact:"^10.19.3",prettier:"^3.2.4",rollup:"^4.12.0","ts-json-schema-generator":"^1.5.0","ts-node":"^10.9.2",tsup:"^8.0.1",typescript:"^5.2.2",vite:"^5.0.8","vite-plugin-css-injected-by-js":"^3.4.0","vite-plugin-externalize-deps":"^0.8.0"},peerDependencies:{"@spiffcommerce/core":"^21.0.1"}};function Ge(e,t,_){if(t.type==="chunk"){if(console.log(`chunk ${e} isEntry: ${t.isEntry}, isDynamicEntry: ${t.isDynamicEntry}, isImplicitEntry: ${t.isImplicitEntry}`),!t.isEntry&&!_)return null;if(!t.isDynamicEntry)return{type:H.Javascript,mimeType:"text/javascript",preload:!t.isEntry,filename:e}}else if(e.endsWith(".css"))return{type:H.CSS,mimeType:"text/css",filename:e};return null}function Ye(e){const{autoGenerateTargetFiles:t=!0,configurationSchema:_,includePreloadChunks:n=!1,targetFiles:o}=e??{};return{name:"spiff-theme-plugin",version:Re.version,config(i,c){i.base!==void 0&&i.base!==""&&console.warn('You have specified a `base` in your vite configuration other than "". This value will now be overwritten.'),i.base=""},writeBundle(i,c){const s=t?Object.keys(c).map(l=>o!=null&&o.some(p=>p.filename===l)?null:Ge(l,c[l],n)).filter(l=>l!==null):[];o&&s.push(...o);const u={launchData:{targetFiles:s},configurationSchema:_};k.writeFileSync(w.join(i.dir,"spiffTheme.json"),JSON.stringify(u,void 0,4))}}}v.AssetType=_e,v.FieldType=te,v.ThemeFileType=H,v.exampleThemeInstallConfig=Ze,v.getDefaultsForSchema=Je,v.setSpiffDevOptions=Be,v.spiffThemePlugin=Ye,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/theme-bridge",
3
- "version": "1.11.3",
3
+ "version": "1.12.0-alpha.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "tsc && vite build",