proto-tinker-wc 0.1.63 → 0.1.65

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.
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ const globalScripts = () => {};
4
+
5
+ exports.globalScripts = globalScripts;
@@ -3,11 +3,8 @@
3
3
  const NAMESPACE = 'proto-tinker-wc';
4
4
  const BUILD = /* proto-tinker-wc */ { hydratedSelectorName: "hydrated", lazyLoad: true, updatable: true, watchCallback: false };
5
5
 
6
- const globalScripts = () => {};
7
- const globalStyles = "";
8
-
9
6
  /*
10
- Stencil Client Platform v4.35.1 | MIT Licensed | https://stenciljs.com
7
+ Stencil Client Platform v4.36.0 | MIT Licensed | https://stenciljs.com
11
8
  */
12
9
  var __defProp = Object.defineProperty;
13
10
  var __export = (target, all) => {
@@ -104,6 +101,7 @@ var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
104
101
  }
105
102
  return false;
106
103
  })() ;
104
+ var supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /* @__PURE__ */ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
107
105
  var queuePending = false;
108
106
  var queueDomReads = [];
109
107
  var queueDomWrites = [];
@@ -203,12 +201,24 @@ var unwrapErr = (result) => {
203
201
  throw result.value;
204
202
  }
205
203
  };
204
+
205
+ // src/utils/style.ts
206
+ function createStyleSheetIfNeededAndSupported(styles2) {
207
+ return void 0;
208
+ }
209
+
210
+ // src/utils/shadow-root.ts
211
+ var globalStyleSheet;
206
212
  function createShadowRoot(cmpMeta) {
213
+ var _a;
207
214
  const shadowRoot = this.attachShadow({ mode: "open" });
208
- if (supportsConstructableStylesheets) {
209
- const sheet = new CSSStyleSheet();
210
- sheet.replaceSync(globalStyles);
211
- shadowRoot.adoptedStyleSheets.push(sheet);
215
+ if (globalStyleSheet === void 0) globalStyleSheet = (_a = createStyleSheetIfNeededAndSupported()) != null ? _a : null;
216
+ if (globalStyleSheet) {
217
+ if (supportsMutableAdoptedStyleSheets) {
218
+ shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
219
+ } else {
220
+ shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
221
+ }
212
222
  }
213
223
  }
214
224
  var createTime = (fnName, tagName = "") => {
@@ -225,6 +235,110 @@ var uniqueTime = (key, measureText) => {
225
235
  };
226
236
  }
227
237
  };
238
+ var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
239
+ var registerStyle = (scopeId2, cssText, allowCS) => {
240
+ let style = styles.get(scopeId2);
241
+ if (supportsConstructableStylesheets && allowCS) {
242
+ style = style || new CSSStyleSheet();
243
+ if (typeof style === "string") {
244
+ style = cssText;
245
+ } else {
246
+ style.replaceSync(cssText);
247
+ }
248
+ } else {
249
+ style = cssText;
250
+ }
251
+ styles.set(scopeId2, style);
252
+ };
253
+ var addStyle = (styleContainerNode, cmpMeta, mode) => {
254
+ var _a;
255
+ const scopeId2 = getScopeId(cmpMeta);
256
+ const style = styles.get(scopeId2);
257
+ if (!win.document) {
258
+ return scopeId2;
259
+ }
260
+ styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
261
+ if (style) {
262
+ if (typeof style === "string") {
263
+ styleContainerNode = styleContainerNode.head || styleContainerNode;
264
+ let appliedStyles = rootAppliedStyles.get(styleContainerNode);
265
+ let styleElm;
266
+ if (!appliedStyles) {
267
+ rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
268
+ }
269
+ if (!appliedStyles.has(scopeId2)) {
270
+ {
271
+ styleElm = win.document.createElement("style");
272
+ styleElm.innerHTML = style;
273
+ const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
274
+ if (nonce != null) {
275
+ styleElm.setAttribute("nonce", nonce);
276
+ }
277
+ if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
278
+ if (styleContainerNode.nodeName === "HEAD") {
279
+ const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
280
+ const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
281
+ styleContainerNode.insertBefore(
282
+ styleElm,
283
+ (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
284
+ );
285
+ } else if ("host" in styleContainerNode) {
286
+ if (supportsConstructableStylesheets) {
287
+ const stylesheet = new CSSStyleSheet();
288
+ stylesheet.replaceSync(style);
289
+ if (supportsMutableAdoptedStyleSheets) {
290
+ styleContainerNode.adoptedStyleSheets.unshift(stylesheet);
291
+ } else {
292
+ styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
293
+ }
294
+ } else {
295
+ const existingStyleContainer = styleContainerNode.querySelector("style");
296
+ if (existingStyleContainer) {
297
+ existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
298
+ } else {
299
+ styleContainerNode.prepend(styleElm);
300
+ }
301
+ }
302
+ } else {
303
+ styleContainerNode.append(styleElm);
304
+ }
305
+ }
306
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
307
+ styleContainerNode.insertBefore(styleElm, null);
308
+ }
309
+ }
310
+ if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
311
+ styleElm.innerHTML += SLOT_FB_CSS;
312
+ }
313
+ if (appliedStyles) {
314
+ appliedStyles.add(scopeId2);
315
+ }
316
+ }
317
+ } else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
318
+ if (supportsMutableAdoptedStyleSheets) {
319
+ styleContainerNode.adoptedStyleSheets.push(style);
320
+ } else {
321
+ styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
322
+ }
323
+ }
324
+ }
325
+ return scopeId2;
326
+ };
327
+ var attachStyles = (hostRef) => {
328
+ const cmpMeta = hostRef.$cmpMeta$;
329
+ const elm = hostRef.$hostElement$;
330
+ const flags = cmpMeta.$flags$;
331
+ const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
332
+ const scopeId2 = addStyle(
333
+ elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
334
+ cmpMeta);
335
+ if (flags & 10 /* needsScopedEncapsulation */) {
336
+ elm["s-sc"] = scopeId2;
337
+ elm.classList.add(scopeId2 + "-h");
338
+ }
339
+ endAttachStyles();
340
+ };
341
+ var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
228
342
  var h = (nodeName, vnodeData, ...children) => {
229
343
  let child = null;
230
344
  let key = null;
@@ -352,102 +466,6 @@ var emitEvent = (elm, name, opts) => {
352
466
  elm.dispatchEvent(ev);
353
467
  return ev;
354
468
  };
355
- var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
356
- var registerStyle = (scopeId2, cssText, allowCS) => {
357
- let style = styles.get(scopeId2);
358
- if (supportsConstructableStylesheets && allowCS) {
359
- style = style || new CSSStyleSheet();
360
- if (typeof style === "string") {
361
- style = cssText;
362
- } else {
363
- style.replaceSync(cssText);
364
- }
365
- } else {
366
- style = cssText;
367
- }
368
- styles.set(scopeId2, style);
369
- };
370
- var addStyle = (styleContainerNode, cmpMeta, mode) => {
371
- var _a;
372
- const scopeId2 = getScopeId(cmpMeta);
373
- const style = styles.get(scopeId2);
374
- if (!win.document) {
375
- return scopeId2;
376
- }
377
- styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
378
- if (style) {
379
- if (typeof style === "string") {
380
- styleContainerNode = styleContainerNode.head || styleContainerNode;
381
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
382
- let styleElm;
383
- if (!appliedStyles) {
384
- rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
385
- }
386
- if (!appliedStyles.has(scopeId2)) {
387
- {
388
- styleElm = win.document.createElement("style");
389
- styleElm.innerHTML = style;
390
- const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
391
- if (nonce != null) {
392
- styleElm.setAttribute("nonce", nonce);
393
- }
394
- if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
395
- if (styleContainerNode.nodeName === "HEAD") {
396
- const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
397
- const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
398
- styleContainerNode.insertBefore(
399
- styleElm,
400
- (referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
401
- );
402
- } else if ("host" in styleContainerNode) {
403
- if (supportsConstructableStylesheets) {
404
- const stylesheet = new CSSStyleSheet();
405
- stylesheet.replaceSync(style);
406
- styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
407
- } else {
408
- const existingStyleContainer = styleContainerNode.querySelector("style");
409
- if (existingStyleContainer) {
410
- existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
411
- } else {
412
- styleContainerNode.prepend(styleElm);
413
- }
414
- }
415
- } else {
416
- styleContainerNode.append(styleElm);
417
- }
418
- }
419
- if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
420
- styleContainerNode.insertBefore(styleElm, null);
421
- }
422
- }
423
- if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
424
- styleElm.innerHTML += SLOT_FB_CSS;
425
- }
426
- if (appliedStyles) {
427
- appliedStyles.add(scopeId2);
428
- }
429
- }
430
- } else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
431
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
432
- }
433
- }
434
- return scopeId2;
435
- };
436
- var attachStyles = (hostRef) => {
437
- const cmpMeta = hostRef.$cmpMeta$;
438
- const elm = hostRef.$hostElement$;
439
- const flags = cmpMeta.$flags$;
440
- const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
441
- const scopeId2 = addStyle(
442
- elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
443
- cmpMeta);
444
- if (flags & 10 /* needsScopedEncapsulation */) {
445
- elm["s-sc"] = scopeId2;
446
- elm.classList.add(scopeId2 + "-h");
447
- }
448
- endAttachStyles();
449
- };
450
- var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
451
469
  var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
452
470
  if (oldValue === newValue) {
453
471
  return;
@@ -760,7 +778,7 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
760
778
  !isInitialRender && BUILD.updatable && oldChildren !== null
761
779
  ) {
762
780
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
763
- }
781
+ } else ;
764
782
  if (isSvgMode && tag === "svg") {
765
783
  isSvgMode = false;
766
784
  }
@@ -816,6 +834,12 @@ var scheduleUpdate = (hostRef, isInitialLoad) => {
816
834
  }
817
835
  attachToAncestor(hostRef, hostRef.$ancestorComponent$);
818
836
  const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
837
+ if (isInitialLoad) {
838
+ queueMicrotask(() => {
839
+ dispatch();
840
+ });
841
+ return;
842
+ }
819
843
  return writeTask(dispatch) ;
820
844
  };
821
845
  var dispatchHooks = (hostRef, isInitialLoad) => {
@@ -933,9 +957,10 @@ var postUpdateComponent = (hostRef) => {
933
957
  }
934
958
  };
935
959
  var forceUpdate = (ref) => {
960
+ var _a;
936
961
  {
937
962
  const hostRef = getHostRef(ref);
938
- const isConnected = hostRef.$hostElement$.isConnected;
963
+ const isConnected = (_a = hostRef == null ? void 0 : hostRef.$hostElement$) == null ? void 0 : _a.isConnected;
939
964
  if (isConnected && (hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
940
965
  scheduleUpdate(hostRef, false);
941
966
  }
@@ -964,6 +989,9 @@ var addHydratedFlag = (elm) => {
964
989
  var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
965
990
  var setValue = (ref, propName, newVal, cmpMeta) => {
966
991
  const hostRef = getHostRef(ref);
992
+ if (!hostRef) {
993
+ return;
994
+ }
967
995
  if (!hostRef) {
968
996
  throw new Error(
969
997
  `Couldn't find host element for "${cmpMeta.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/stenciljs/core/issues/5457).`
@@ -1023,6 +1051,9 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1023
1051
  Object.defineProperty(prototype, memberName, {
1024
1052
  set(newValue) {
1025
1053
  const ref = getHostRef(this);
1054
+ if (!ref) {
1055
+ return;
1056
+ }
1026
1057
  if (origSetter) {
1027
1058
  const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
1028
1059
  if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
@@ -1086,7 +1117,7 @@ var proxyComponent = (Cstr, cmpMeta, flags) => {
1086
1117
  } else if (propName == null) {
1087
1118
  const hostRef = getHostRef(this);
1088
1119
  const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
1089
- if (flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
1120
+ if (hostRef && flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
1090
1121
  const instance = hostRef.$lazyInstance$ ;
1091
1122
  const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
1092
1123
  entry == null ? void 0 : entry.forEach((callbackName) => {
@@ -1191,6 +1222,9 @@ var fireConnectedCallback = (instance, elm) => {
1191
1222
  var connectedCallback = (elm) => {
1192
1223
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1193
1224
  const hostRef = getHostRef(elm);
1225
+ if (!hostRef) {
1226
+ return;
1227
+ }
1194
1228
  const cmpMeta = hostRef.$cmpMeta$;
1195
1229
  const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
1196
1230
  if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
@@ -1305,7 +1339,10 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
1305
1339
  }
1306
1340
  }
1307
1341
  connectedCallback() {
1308
- getHostRef(this);
1342
+ const hostRef = getHostRef(this);
1343
+ if (!hostRef) {
1344
+ return;
1345
+ }
1309
1346
  if (!this.hasRegisteredEventListeners) {
1310
1347
  this.hasRegisteredEventListeners = true;
1311
1348
  }
@@ -1324,6 +1361,9 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
1324
1361
  plt.raf(() => {
1325
1362
  var _a3;
1326
1363
  const hostRef = getHostRef(this);
1364
+ if (!hostRef) {
1365
+ return;
1366
+ }
1327
1367
  const i2 = deferredConnectedCallbacks.findIndex((host) => host === this);
1328
1368
  if (i2 > -1) {
1329
1369
  deferredConnectedCallbacks.splice(i2, 1);
@@ -1334,7 +1374,8 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
1334
1374
  });
1335
1375
  }
1336
1376
  componentOnReady() {
1337
- return getHostRef(this).$onReadyPromise$;
1377
+ var _a3;
1378
+ return (_a3 = getHostRef(this)) == null ? void 0 : _a3.$onReadyPromise$;
1338
1379
  }
1339
1380
  };
1340
1381
  cmpMeta.$lazyBundleId$ = lazyBundle[0];
@@ -1380,7 +1421,6 @@ var setNonce = (nonce) => plt.$nonce$ = nonce;
1380
1421
  exports.bootstrapLazy = bootstrapLazy;
1381
1422
  exports.forceUpdate = forceUpdate;
1382
1423
  exports.getRenderingRef = getRenderingRef;
1383
- exports.globalScripts = globalScripts;
1384
1424
  exports.h = h;
1385
1425
  exports.promiseResolve = promiseResolve;
1386
1426
  exports.registerInstance = registerInstance;
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-D7u_fy5q.js');
3
+ var index = require('./index-DTzuImFS.js');
4
+ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
4
5
 
5
6
  const defineCustomElements = async (win, options) => {
6
7
  if (typeof window === 'undefined') return undefined;
7
- await index.globalScripts();
8
+ await appGlobals.globalScripts();
8
9
  return index.bootstrapLazy([["proto-tinker.cjs",[[1,"proto-tinker",{"tag":[1]}]]]], options);
9
10
  };
10
11
 
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-D7u_fy5q.js');
3
+ var index = require('./index-DTzuImFS.js');
4
+ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
4
5
 
5
6
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
6
7
  /*
7
- Stencil Client Patch Browser v4.35.1 | MIT Licensed | https://stenciljs.com
8
+ Stencil Client Patch Browser v4.36.0 | MIT Licensed | https://stenciljs.com
8
9
  */
9
10
 
10
11
  var patchBrowser = () => {
@@ -17,7 +18,7 @@ var patchBrowser = () => {
17
18
  };
18
19
 
19
20
  patchBrowser().then(async (options) => {
20
- await index.globalScripts();
21
+ await appGlobals.globalScripts();
21
22
  return index.bootstrapLazy([["proto-tinker.cjs",[[1,"proto-tinker",{"tag":[1]}]]]], options);
22
23
  });
23
24
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-D7u_fy5q.js');
3
+ var index = require('./index-DTzuImFS.js');
4
4
 
5
5
  const Radio = props => {
6
6
  const hex = props.hex || 'currentColor';
@@ -2344,6 +2344,8 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
2344
2344
  set: [],
2345
2345
  reset: [],
2346
2346
  };
2347
+ // Track onChange listeners to enable removeListener functionality
2348
+ const changeListeners = new Map();
2347
2349
  const reset = () => {
2348
2350
  // When resetting the state, the default state may be a function - unwrap it to invoke it.
2349
2351
  // otherwise, the state won't be properly reset
@@ -2397,17 +2399,21 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
2397
2399
  };
2398
2400
  };
2399
2401
  const onChange = (propName, cb) => {
2400
- const unSet = on('set', (key, newValue) => {
2402
+ const setHandler = (key, newValue) => {
2401
2403
  if (key === propName) {
2402
2404
  cb(newValue);
2403
2405
  }
2404
- });
2405
- // We need to unwrap the defaultState because it might be a function.
2406
- // Otherwise we might not be sending the right reset value.
2407
- const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
2406
+ };
2407
+ const resetHandler = () => cb(unwrap(defaultState)[propName]);
2408
+ // Register the handlers
2409
+ const unSet = on('set', setHandler);
2410
+ const unReset = on('reset', resetHandler);
2411
+ // Track the relationship between the user callback and internal handlers
2412
+ changeListeners.set(cb, { setHandler, resetHandler, propName });
2408
2413
  return () => {
2409
2414
  unSet();
2410
2415
  unReset();
2416
+ changeListeners.delete(cb);
2411
2417
  };
2412
2418
  };
2413
2419
  const use = (...subscriptions) => {
@@ -2432,6 +2438,15 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
2432
2438
  const oldValue = states.get(key);
2433
2439
  handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
2434
2440
  };
2441
+ const removeListener = (propName, listener) => {
2442
+ const listenerInfo = changeListeners.get(listener);
2443
+ if (listenerInfo && listenerInfo.propName === propName) {
2444
+ // Remove the specific handlers that were created for this listener
2445
+ removeFromArray(handlers.set, listenerInfo.setHandler);
2446
+ removeFromArray(handlers.reset, listenerInfo.resetHandler);
2447
+ changeListeners.delete(listener);
2448
+ }
2449
+ };
2435
2450
  return {
2436
2451
  state,
2437
2452
  get,
@@ -2442,6 +2457,7 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
2442
2457
  dispose,
2443
2458
  reset,
2444
2459
  forceUpdate,
2460
+ removeListener,
2445
2461
  };
2446
2462
  };
2447
2463
  const removeFromArray = (array, item) => {
@@ -4,7 +4,7 @@
4
4
  ],
5
5
  "compiler": {
6
6
  "name": "@stencil/core",
7
- "version": "4.35.1",
7
+ "version": "4.36.0",
8
8
  "typescriptVersion": "5.5.4"
9
9
  },
10
10
  "collections": [],
@@ -2342,6 +2342,8 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
2342
2342
  set: [],
2343
2343
  reset: [],
2344
2344
  };
2345
+ // Track onChange listeners to enable removeListener functionality
2346
+ const changeListeners = new Map();
2345
2347
  const reset = () => {
2346
2348
  // When resetting the state, the default state may be a function - unwrap it to invoke it.
2347
2349
  // otherwise, the state won't be properly reset
@@ -2395,17 +2397,21 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
2395
2397
  };
2396
2398
  };
2397
2399
  const onChange = (propName, cb) => {
2398
- const unSet = on('set', (key, newValue) => {
2400
+ const setHandler = (key, newValue) => {
2399
2401
  if (key === propName) {
2400
2402
  cb(newValue);
2401
2403
  }
2402
- });
2403
- // We need to unwrap the defaultState because it might be a function.
2404
- // Otherwise we might not be sending the right reset value.
2405
- const unReset = on('reset', () => cb(unwrap(defaultState)[propName]));
2404
+ };
2405
+ const resetHandler = () => cb(unwrap(defaultState)[propName]);
2406
+ // Register the handlers
2407
+ const unSet = on('set', setHandler);
2408
+ const unReset = on('reset', resetHandler);
2409
+ // Track the relationship between the user callback and internal handlers
2410
+ changeListeners.set(cb, { setHandler, resetHandler, propName });
2406
2411
  return () => {
2407
2412
  unSet();
2408
2413
  unReset();
2414
+ changeListeners.delete(cb);
2409
2415
  };
2410
2416
  };
2411
2417
  const use = (...subscriptions) => {
@@ -2430,6 +2436,15 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
2430
2436
  const oldValue = states.get(key);
2431
2437
  handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
2432
2438
  };
2439
+ const removeListener = (propName, listener) => {
2440
+ const listenerInfo = changeListeners.get(listener);
2441
+ if (listenerInfo && listenerInfo.propName === propName) {
2442
+ // Remove the specific handlers that were created for this listener
2443
+ removeFromArray(handlers.set, listenerInfo.setHandler);
2444
+ removeFromArray(handlers.reset, listenerInfo.resetHandler);
2445
+ changeListeners.delete(listener);
2446
+ }
2447
+ };
2433
2448
  return {
2434
2449
  state,
2435
2450
  get,
@@ -2440,6 +2455,7 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
2440
2455
  dispose,
2441
2456
  reset,
2442
2457
  forceUpdate,
2458
+ removeListener,
2443
2459
  };
2444
2460
  };
2445
2461
  const removeFromArray = (array, item) => {
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };