funnel-gfx-wc 0.1.129 → 0.1.134

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CJmmK8iX.js');
3
+ var index = require('./index-BFBRUSYG.js');
4
4
  var appGlobals = require('./app-globals-V2Kpy_OQ.js');
5
5
 
6
6
  const defineCustomElements = async (win, options) => {
@@ -1,4 +1,4 @@
1
- import { h, g as getRenderingRef, f as forceUpdate, r as registerInstance } from './index-Tnvcatci.js';
1
+ import { h, S as StencilCore, r as registerInstance } from './index-CQ7_4qF8.js';
2
2
 
3
3
  const Radio = props => {
4
4
  const hex = props.hex || 'currentColor';
@@ -69,12 +69,13 @@ const colorFor = (key) => _namedColors[key] || _altColors[key];
69
69
  const colorKeys = Object.keys(_namedColors);
70
70
 
71
71
  const appendToMap = (map, propName, value) => {
72
- const items = map.get(propName);
73
- if (!items) {
74
- map.set(propName, [value]);
72
+ let refs = map.get(propName);
73
+ if (!refs) {
74
+ refs = [];
75
+ map.set(propName, refs);
75
76
  }
76
- else if (!items.includes(value)) {
77
- items.push(value);
77
+ if (!refs.some((ref) => ref.deref() === value)) {
78
+ refs.push(new WeakRef(value));
78
79
  }
79
80
  };
80
81
  const debounce = (fn, ms) => {
@@ -102,33 +103,54 @@ const debounce = (fn, ms) => {
102
103
  const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
103
104
  const cleanupElements = debounce((map) => {
104
105
  for (let key of map.keys()) {
105
- map.set(key, map.get(key).filter(isConnected));
106
+ const refs = map.get(key).filter((ref) => {
107
+ const elm = ref.deref();
108
+ return elm && isConnected(elm);
109
+ });
110
+ map.set(key, refs);
106
111
  }
107
112
  }, 2_000);
113
+ const core = StencilCore;
114
+ const forceUpdate = core.forceUpdate;
115
+ const getRenderingRef = core.getRenderingRef;
108
116
  const stencilSubscription = () => {
109
- if (typeof getRenderingRef !== 'function') {
117
+ if (typeof getRenderingRef !== 'function' || typeof forceUpdate !== 'function') {
110
118
  // If we are not in a stencil project, we do nothing.
111
119
  // This function is not really exported by @stencil/core.
112
120
  return {};
113
121
  }
122
+ const ensureForceUpdate = forceUpdate;
123
+ const ensureGetRenderingRef = getRenderingRef;
114
124
  const elmsToUpdate = new Map();
115
125
  return {
116
126
  dispose: () => elmsToUpdate.clear(),
117
127
  get: (propName) => {
118
- const elm = getRenderingRef();
128
+ const elm = ensureGetRenderingRef();
119
129
  if (elm) {
120
130
  appendToMap(elmsToUpdate, propName, elm);
121
131
  }
122
132
  },
123
133
  set: (propName) => {
124
- const elements = elmsToUpdate.get(propName);
125
- if (elements) {
126
- elmsToUpdate.set(propName, elements.filter(forceUpdate));
134
+ const refs = elmsToUpdate.get(propName);
135
+ if (refs) {
136
+ const nextRefs = refs.filter((ref) => {
137
+ const elm = ref.deref();
138
+ if (!elm)
139
+ return false;
140
+ return ensureForceUpdate(elm);
141
+ });
142
+ elmsToUpdate.set(propName, nextRefs);
127
143
  }
128
144
  cleanupElements(elmsToUpdate);
129
145
  },
130
146
  reset: () => {
131
- elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
147
+ elmsToUpdate.forEach((refs) => {
148
+ refs.forEach((ref) => {
149
+ const elm = ref.deref();
150
+ if (elm)
151
+ ensureForceUpdate(elm);
152
+ });
153
+ });
132
154
  cleanupElements(elmsToUpdate);
133
155
  },
134
156
  };
@@ -136,8 +158,11 @@ const stencilSubscription = () => {
136
158
 
137
159
  const unwrap = (val) => (typeof val === 'function' ? val() : val);
138
160
  const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
139
- const unwrappedState = unwrap(defaultState);
140
- let states = new Map(Object.entries(unwrappedState ?? {}));
161
+ const resolveDefaultState = () => (unwrap(defaultState) ?? {});
162
+ const initialState = resolveDefaultState();
163
+ let states = new Map(Object.entries(initialState));
164
+ const proxyAvailable = typeof Proxy !== 'undefined';
165
+ const plainState = proxyAvailable ? null : {};
141
166
  const handlers = {
142
167
  dispose: [],
143
168
  get: [],
@@ -149,7 +174,10 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
149
174
  const reset = () => {
150
175
  // When resetting the state, the default state may be a function - unwrap it to invoke it.
151
176
  // otherwise, the state won't be properly reset
152
- states = new Map(Object.entries(unwrap(defaultState) ?? {}));
177
+ states = new Map(Object.entries(resolveDefaultState()));
178
+ if (!proxyAvailable) {
179
+ syncPlainStateKeys();
180
+ }
153
181
  handlers.reset.forEach((cb) => cb());
154
182
  };
155
183
  const dispose = () => {
@@ -166,12 +194,14 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
166
194
  const oldValue = states.get(propName);
167
195
  if (shouldUpdate(value, oldValue, propName)) {
168
196
  states.set(propName, value);
197
+ if (!proxyAvailable) {
198
+ ensurePlainProperty(propName);
199
+ }
169
200
  handlers.set.forEach((cb) => cb(propName, value, oldValue));
170
201
  }
171
202
  };
172
- const state = (typeof Proxy === 'undefined'
173
- ? {}
174
- : new Proxy(unwrappedState, {
203
+ const state = (proxyAvailable
204
+ ? new Proxy(initialState, {
175
205
  get(_, propName) {
176
206
  return get(propName);
177
207
  },
@@ -191,7 +221,11 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
191
221
  set(propName, value);
192
222
  return true;
193
223
  },
194
- }));
224
+ })
225
+ : (() => {
226
+ syncPlainStateKeys();
227
+ return plainState;
228
+ })());
195
229
  const on = (eventName, callback) => {
196
230
  handlers[eventName].push(callback);
197
231
  return () => {
@@ -204,7 +238,10 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
204
238
  cb(newValue);
205
239
  }
206
240
  };
207
- const resetHandler = () => cb(unwrap(defaultState)[propName]);
241
+ const resetHandler = () => {
242
+ const snapshot = resolveDefaultState();
243
+ cb(snapshot[propName]);
244
+ };
208
245
  // Register the handlers
209
246
  const unSet = on('set', setHandler);
210
247
  const unReset = on('reset', resetHandler);
@@ -247,6 +284,38 @@ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) =>
247
284
  changeListeners.delete(listener);
248
285
  }
249
286
  };
287
+ function ensurePlainProperty(key) {
288
+ if (proxyAvailable || !plainState) {
289
+ return;
290
+ }
291
+ if (Object.prototype.hasOwnProperty.call(plainState, key)) {
292
+ return;
293
+ }
294
+ Object.defineProperty(plainState, key, {
295
+ configurable: true,
296
+ enumerable: true,
297
+ get() {
298
+ return get(key);
299
+ },
300
+ set(value) {
301
+ set(key, value);
302
+ },
303
+ });
304
+ }
305
+ function syncPlainStateKeys() {
306
+ if (proxyAvailable || !plainState) {
307
+ return;
308
+ }
309
+ const knownKeys = new Set(states.keys());
310
+ for (const key of Object.keys(plainState)) {
311
+ if (!knownKeys.has(key)) {
312
+ delete plainState[key];
313
+ }
314
+ }
315
+ for (const key of knownKeys) {
316
+ ensurePlainProperty(key);
317
+ }
318
+ }
250
319
  return {
251
320
  state,
252
321
  get,
@@ -1,5 +1,5 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-Tnvcatci.js';
2
- export { s as setNonce } from './index-Tnvcatci.js';
1
+ import { p as promiseResolve, B as BUILD, c as consoleDevInfo, w as win, N as NAMESPACE, H, b as bootstrapLazy } from './index-CQ7_4qF8.js';
2
+ export { s as setNonce } from './index-CQ7_4qF8.js';
3
3
  import { g as globalScripts } from './app-globals-DQuL1Twl.js';
4
4
 
5
5
  /*
@@ -7,13 +7,40 @@ import { g as globalScripts } from './app-globals-DQuL1Twl.js';
7
7
  */
8
8
 
9
9
  var patchBrowser = () => {
10
+ if (BUILD.isDev && !BUILD.isTesting) {
11
+ consoleDevInfo("Running in development mode.");
12
+ }
13
+ if (BUILD.cloneNodeFix) {
14
+ patchCloneNodeFix(H.prototype);
15
+ }
16
+ const scriptElm = BUILD.scriptDataOpts ? win.document && Array.from(win.document.querySelectorAll("script")).find(
17
+ (s) => new RegExp(`/${NAMESPACE}(\\.esm)?\\.js($|\\?|#)`).test(s.src) || s.getAttribute("data-stencil-namespace") === NAMESPACE
18
+ ) : null;
10
19
  const importMeta = import.meta.url;
11
- const opts = {};
20
+ const opts = BUILD.scriptDataOpts ? (scriptElm || {})["data-opts"] || {} : {};
12
21
  if (importMeta !== "") {
13
22
  opts.resourcesUrl = new URL(".", importMeta).href;
14
23
  }
15
24
  return promiseResolve(opts);
16
25
  };
26
+ var patchCloneNodeFix = (HTMLElementPrototype) => {
27
+ const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;
28
+ HTMLElementPrototype.cloneNode = function(deep) {
29
+ if (this.nodeName === "TEMPLATE") {
30
+ return nativeCloneNodeFn.call(this, deep);
31
+ }
32
+ const clonedNode = nativeCloneNodeFn.call(this, false);
33
+ const srcChildNodes = this.childNodes;
34
+ if (deep) {
35
+ for (let i = 0; i < srcChildNodes.length; i++) {
36
+ if (srcChildNodes[i].nodeType !== 2) {
37
+ clonedNode.appendChild(srcChildNodes[i].cloneNode(true));
38
+ }
39
+ }
40
+ }
41
+ return clonedNode;
42
+ };
43
+ };
17
44
 
18
45
  patchBrowser().then(async (options) => {
19
46
  await globalScripts();