taggedjs 2.5.12 → 2.5.14

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 (55) hide show
  1. package/bundle.js +1 -4698
  2. package/bundle.js.gz +0 -0
  3. package/bundle.js.map +1 -1
  4. package/bundle.js.map.gz +0 -0
  5. package/js/TemplaterResult.class.d.ts +2 -2
  6. package/js/TemplaterResult.class.js +1 -1
  7. package/js/TemplaterResult.class.js.map +1 -1
  8. package/js/alterProps.function.js +2 -2
  9. package/js/alterProps.function.js.map +1 -1
  10. package/js/index.d.ts +1 -0
  11. package/js/index.js +1 -0
  12. package/js/index.js.map +1 -1
  13. package/js/interpolations/processAttribute.function.js +7 -1
  14. package/js/interpolations/processAttribute.function.js.map +1 -1
  15. package/js/isInstance.d.ts +2 -2
  16. package/js/isInstance.js +12 -8
  17. package/js/isInstance.js.map +1 -1
  18. package/js/state/subject.function.d.ts +2 -0
  19. package/js/state/subject.function.js +19 -4
  20. package/js/state/subject.function.js.map +1 -1
  21. package/js/subject/Subject.class.d.ts +5 -3
  22. package/js/subject/Subject.class.js +13 -5
  23. package/js/subject/Subject.class.js.map +1 -1
  24. package/js/subject/ValueSubject.d.ts +4 -2
  25. package/js/subject/ValueSubject.js +8 -3
  26. package/js/subject/ValueSubject.js.map +1 -1
  27. package/js/subject.types.d.ts +2 -1
  28. package/js/tag/Tag.class.d.ts +2 -2
  29. package/js/tag/Tag.class.js +2 -1
  30. package/js/tag/Tag.class.js.map +1 -1
  31. package/js/tag/TagSupport.class.js.map +1 -1
  32. package/js/tag/checkDestroyPrevious.function.js +11 -6
  33. package/js/tag/checkDestroyPrevious.function.js.map +1 -1
  34. package/js/tag/cloneValueArray.function.js +10 -10
  35. package/js/tag/cloneValueArray.function.js.map +1 -1
  36. package/js/tag/tag.d.ts +8 -18
  37. package/js/tag/tag.js +15 -4
  38. package/js/tag/tag.js.map +1 -1
  39. package/js/tag/tag.utils.d.ts +16 -0
  40. package/js/tag/tag.utils.js +2 -0
  41. package/js/tag/tag.utils.js.map +1 -0
  42. package/js/tag/tagElement.d.ts +1 -1
  43. package/js/tag/update/processFirstSubject.utils.d.ts +2 -2
  44. package/js/tag/update/processFirstSubject.utils.js +27 -23
  45. package/js/tag/update/processFirstSubject.utils.js.map +1 -1
  46. package/js/tag/update/processFirstSubjectValue.function.js +26 -1
  47. package/js/tag/update/processFirstSubjectValue.function.js.map +1 -1
  48. package/js/tag/update/processTag.function.d.ts +1 -0
  49. package/js/tag/update/processTag.function.js +8 -4
  50. package/js/tag/update/processTag.function.js.map +1 -1
  51. package/js/tag/update/updateContextItem.function.js +2 -0
  52. package/js/tag/update/updateContextItem.function.js.map +1 -1
  53. package/js/tag/update/updateExistingValue.function.js +3 -0
  54. package/js/tag/update/updateExistingValue.function.js.map +1 -1
  55. package/package.json +1 -1
package/bundle.js CHANGED
@@ -1,4699 +1,2 @@
1
- /******/ var __webpack_modules__ = ({
2
-
3
- /***/ "./ts/TemplaterResult.class.ts":
4
- /*!*************************************!*\
5
- !*** ./ts/TemplaterResult.class.ts ***!
6
- \*************************************/
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- __webpack_require__.r(__webpack_exports__);
10
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11
- /* harmony export */ TemplaterResult: () => (/* binding */ TemplaterResult)
12
- /* harmony export */ });
13
- /* harmony import */ var _tag_Tag_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tag/Tag.class */ "./ts/tag/Tag.class.ts");
14
- /* harmony import */ var _tag_tag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tag/tag */ "./ts/tag/tag.ts");
15
- /* harmony import */ var _subject__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./subject */ "./ts/subject/index.ts");
16
-
17
-
18
-
19
- class TemplaterResult {
20
- props;
21
- isTemplater = true;
22
- tagged;
23
- wrapper;
24
- madeChildIntoSubject = false;
25
- tag;
26
- children = new _subject__WEBPACK_IMPORTED_MODULE_2__.ValueSubject([]);
27
- constructor(props) {
28
- this.props = props;
29
- }
30
- html(strings, ...values) {
31
- const children = new _tag_Tag_class__WEBPACK_IMPORTED_MODULE_0__.Tag(strings, values);
32
- const { childSubject, madeSubject } = (0,_tag_tag__WEBPACK_IMPORTED_MODULE_1__.kidsToTagArraySubject)(children);
33
- this.children = childSubject;
34
- this.madeChildIntoSubject = madeSubject;
35
- return this;
36
- }
37
- }
38
-
39
-
40
- /***/ }),
41
-
42
- /***/ "./ts/alterProps.function.ts":
43
- /*!***********************************!*\
44
- !*** ./ts/alterProps.function.ts ***!
45
- \***********************************/
46
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
47
-
48
- __webpack_require__.r(__webpack_exports__);
49
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
50
- /* harmony export */ alterProps: () => (/* binding */ alterProps),
51
- /* harmony export */ callbackPropOwner: () => (/* binding */ callbackPropOwner)
52
- /* harmony export */ });
53
- /* harmony import */ var _deepFunctions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./deepFunctions */ "./ts/deepFunctions.ts");
54
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./isInstance */ "./ts/isInstance.ts");
55
- /* harmony import */ var _tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tag/render/renderTagSupport.function */ "./ts/tag/render/renderTagSupport.function.ts");
56
- /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./state */ "./ts/state/index.ts");
57
- /* harmony import */ var _tag_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./tag/getSupportInCycle.function */ "./ts/tag/getSupportInCycle.function.ts");
58
-
59
-
60
-
61
-
62
-
63
- /* Used to rewrite props that are functions. When they are called it should cause parent rendering */
64
- function alterProps(props, ownerSupport) {
65
- const isPropTag = (0,_isInstance__WEBPACK_IMPORTED_MODULE_1__.isTag)(props);
66
- const watchProps = isPropTag ? 0 : props;
67
- const newProps = resetFunctionProps(watchProps, ownerSupport);
68
- return newProps;
69
- }
70
- function resetFunctionProps(newProps, ownerSupport) {
71
- if (typeof (newProps) !== 'object' || !ownerSupport) {
72
- return newProps;
73
- }
74
- // BELOW: Do not clone because if first argument is object, the memory ref back is lost
75
- // const newProps = {...props}
76
- for (const name in newProps) {
77
- const value = newProps[name];
78
- if (!(value instanceof Function)) {
79
- continue;
80
- }
81
- const toCall = newProps[name].toCall;
82
- if (toCall) {
83
- continue; // already previously converted
84
- }
85
- newProps[name] = (...args) => newProps[name].toCall(...args); // what gets called can switch over parent state changes
86
- // Currently, call self but over parent state changes, I may need to call a newer parent tag owner
87
- newProps[name].toCall = (...args) => callbackPropOwner(value, args, ownerSupport);
88
- newProps[name].original = value;
89
- }
90
- return newProps;
91
- }
92
- function callbackPropOwner(toCall, callWith, ownerSupport) {
93
- // const renderCount = ownerSupport.global.renderCount
94
- const cycle = (0,_tag_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_4__.getSupportInCycle)();
95
- const result = toCall(...callWith);
96
- const run = () => {
97
- const lastestOwner = ownerSupport.global.newest;
98
- if (cycle) {
99
- // appears a prop function was called sync/immediately so lets see if owner changed state
100
- const allMatched = lastestOwner.memory.state.every(state => {
101
- const lastValue = state.lastValue;
102
- const get = state.get();
103
- const equal = (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepEqual)((0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepClone)(lastValue), get);
104
- return equal;
105
- });
106
- if (allMatched) {
107
- return result; // owner did not change
108
- }
109
- }
110
- const newest = (0,_tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_2__.renderTagSupport)(lastestOwner, true);
111
- lastestOwner.global.newest = newest;
112
- return result;
113
- };
114
- if (!cycle) {
115
- return run();
116
- }
117
- _state__WEBPACK_IMPORTED_MODULE_3__.setUse.memory.tagClosed$.toCallback(run);
118
- return result;
119
- }
120
-
121
-
122
- /***/ }),
123
-
124
- /***/ "./ts/deepFunctions.ts":
125
- /*!*****************************!*\
126
- !*** ./ts/deepFunctions.ts ***!
127
- \*****************************/
128
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
129
-
130
- __webpack_require__.r(__webpack_exports__);
131
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
132
- /* harmony export */ deepClone: () => (/* binding */ deepClone),
133
- /* harmony export */ deepEqual: () => (/* binding */ deepEqual)
134
- /* harmony export */ });
135
- function deepClone(obj) {
136
- return makeDeepClone(obj, new WeakMap());
137
- }
138
- function makeDeepClone(obj, visited) {
139
- // If obj is a primitive type or null, return it directly
140
- if (obj === null || typeof obj !== 'object') {
141
- return obj;
142
- }
143
- // If obj is already visited, return the cloned reference
144
- if (visited.has(obj)) {
145
- return visited.get(obj);
146
- }
147
- // Handle special cases like Date and RegExp
148
- if (obj instanceof Date) {
149
- return new Date(obj);
150
- }
151
- if (obj instanceof RegExp) {
152
- return new RegExp(obj);
153
- }
154
- // Create an empty object or array with the same prototype
155
- const clone = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj));
156
- // Register the cloned object to avoid cyclic references
157
- visited.set(obj, clone);
158
- // Clone each property or element of the object or array
159
- if (Array.isArray(obj)) {
160
- for (let i = 0; i < obj.length; i++) {
161
- clone[i] = makeDeepClone(obj[i], visited);
162
- }
163
- }
164
- else {
165
- for (const key in obj) {
166
- if (obj.hasOwnProperty(key)) {
167
- clone[key] = makeDeepClone(obj[key], visited);
168
- }
169
- }
170
- }
171
- return clone;
172
- }
173
- function deepEqual(obj1, obj2) {
174
- return isDeepEqual(obj1, obj2, new WeakMap());
175
- }
176
- function isDeepEqual(obj1, obj2, visited) {
177
- const directEqual = obj1 === obj2;
178
- if (directEqual || isSameFunctions(obj1, obj2)) {
179
- return true;
180
- }
181
- // If obj is already visited, return the cloned reference
182
- if (visited.has(obj1)) {
183
- return true;
184
- }
185
- if (typeof obj1 === 'object' && typeof obj2 === 'object') {
186
- // both are dates and were already determined not the same
187
- if (obj1 instanceof Date && obj2 instanceof Date) {
188
- return obj1.getTime() === obj2.getTime();
189
- }
190
- // Register the cloned object to avoid cyclic references
191
- visited.set(obj1, 0);
192
- // Check if obj1 and obj2 are both arrays
193
- if (Array.isArray(obj1) && Array.isArray(obj2)) {
194
- return isArrayDeepEqual(obj1, obj2, visited);
195
- }
196
- else if (Array.isArray(obj1) || Array.isArray(obj2)) {
197
- // One is an array, and the other is not
198
- return false;
199
- }
200
- return isObjectDeepEqual(obj1, obj2, visited);
201
- }
202
- return false;
203
- }
204
- function isObjectDeepEqual(obj1, obj2, visited) {
205
- const keys1 = Object.keys(obj1);
206
- const keys2 = Object.keys(obj2);
207
- if (keys1.length === 0 && keys2.length === 0) {
208
- return true;
209
- }
210
- if (keys1.length !== keys2.length) {
211
- return false;
212
- }
213
- for (const key of keys1) {
214
- const keyFound = keys2.includes(key);
215
- if (!keyFound || !isDeepEqual(obj1[key], obj2[key], visited)) {
216
- return false;
217
- }
218
- }
219
- return true;
220
- }
221
- function isArrayDeepEqual(obj1, obj2, visited) {
222
- if (obj1.length !== obj2.length) {
223
- return false;
224
- }
225
- for (let i = 0; i < obj1.length; i++) {
226
- if (!isDeepEqual(obj1[i], obj2[i], visited)) {
227
- return false;
228
- }
229
- }
230
- return true;
231
- }
232
- function isSameFunctions(fn0, fn1) {
233
- const bothFunction = fn0 instanceof Function && fn1 instanceof Function;
234
- return bothFunction && fn0.toString() === fn1.toString();
235
- }
236
-
237
-
238
- /***/ }),
239
-
240
- /***/ "./ts/errors.ts":
241
- /*!**********************!*\
242
- !*** ./ts/errors.ts ***!
243
- \**********************/
244
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
245
-
246
- __webpack_require__.r(__webpack_exports__);
247
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
248
- /* harmony export */ ArrayNoKeyError: () => (/* binding */ ArrayNoKeyError),
249
- /* harmony export */ StateMismatchError: () => (/* binding */ StateMismatchError),
250
- /* harmony export */ SyncCallbackError: () => (/* binding */ SyncCallbackError),
251
- /* harmony export */ TagError: () => (/* binding */ TagError)
252
- /* harmony export */ });
253
- class TagError extends Error {
254
- details;
255
- constructor(message, errorCode, details = {}) {
256
- super(message);
257
- this.name = TagError.name;
258
- this.details = { ...details, errorCode };
259
- }
260
- }
261
- class ArrayNoKeyError extends TagError {
262
- constructor(message, details) {
263
- super(message, 'array-no-key-error', details);
264
- this.name = ArrayNoKeyError.name;
265
- }
266
- }
267
- class StateMismatchError extends TagError {
268
- constructor(message, details) {
269
- super(message, 'state-mismatch-error', details);
270
- this.name = StateMismatchError.name;
271
- }
272
- }
273
- class SyncCallbackError extends TagError {
274
- constructor(message, details) {
275
- super(message, 'sync-callback-error', details);
276
- this.name = SyncCallbackError.name;
277
- }
278
- }
279
-
280
-
281
- /***/ }),
282
-
283
- /***/ "./ts/insertAfter.function.ts":
284
- /*!************************************!*\
285
- !*** ./ts/insertAfter.function.ts ***!
286
- \************************************/
287
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
288
-
289
- __webpack_require__.r(__webpack_exports__);
290
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
291
- /* harmony export */ insertAfter: () => (/* binding */ insertAfter)
292
- /* harmony export */ });
293
- // Function to insert element after reference element
294
- function insertAfter(newNode, referenceNode) {
295
- const parentNode = referenceNode.parentNode;
296
- parentNode.insertBefore(newNode, referenceNode.nextSibling);
297
- }
298
-
299
-
300
- /***/ }),
301
-
302
- /***/ "./ts/interpolations/ElementTargetEvent.interface.ts":
303
- /*!***********************************************************!*\
304
- !*** ./ts/interpolations/ElementTargetEvent.interface.ts ***!
305
- \***********************************************************/
306
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
307
-
308
- __webpack_require__.r(__webpack_exports__);
309
-
310
-
311
-
312
- /***/ }),
313
-
314
- /***/ "./ts/interpolations/afterInterpolateElement.function.ts":
315
- /*!***************************************************************!*\
316
- !*** ./ts/interpolations/afterInterpolateElement.function.ts ***!
317
- \***************************************************************/
318
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
319
-
320
- __webpack_require__.r(__webpack_exports__);
321
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
322
- /* harmony export */ afterInterpolateElement: () => (/* binding */ afterInterpolateElement)
323
- /* harmony export */ });
324
- /* harmony import */ var _render__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../render */ "./ts/render.ts");
325
- /* harmony import */ var _interpolateTemplate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./interpolateTemplate */ "./ts/interpolations/interpolateTemplate.ts");
326
-
327
-
328
- function afterInterpolateElement(container, insertBefore, tagSupport, context, options) {
329
- const clones = (0,_render__WEBPACK_IMPORTED_MODULE_0__.buildClones)(container, insertBefore);
330
- if (!clones.length) {
331
- return clones;
332
- }
333
- for (let index = clones.length - 1; index >= 0; --index) {
334
- const clone = clones[index];
335
- (0,_interpolateTemplate__WEBPACK_IMPORTED_MODULE_1__.afterElmBuild)(clone, options, context, tagSupport);
336
- tagSupport.clones.push(clone);
337
- }
338
- return clones;
339
- }
340
-
341
-
342
- /***/ }),
343
-
344
- /***/ "./ts/interpolations/bindSubjectCallback.function.ts":
345
- /*!***********************************************************!*\
346
- !*** ./ts/interpolations/bindSubjectCallback.function.ts ***!
347
- \***********************************************************/
348
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
349
-
350
- __webpack_require__.r(__webpack_exports__);
351
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
352
- /* harmony export */ bindSubjectCallback: () => (/* binding */ bindSubjectCallback),
353
- /* harmony export */ runTagCallback: () => (/* binding */ runTagCallback)
354
- /* harmony export */ });
355
- /* harmony import */ var _tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../tag/render/renderTagSupport.function */ "./ts/tag/render/renderTagSupport.function.ts");
356
- /** File largely responsible for reacting to element events, such as onclick */
357
-
358
- function bindSubjectCallback(value, tagSupport) {
359
- // Is this children? No override needed
360
- if (value.isChildOverride) {
361
- return value;
362
- }
363
- const subjectFunction = (element, args) => runTagCallback(value, tagSupport, element, args);
364
- // link back to original. Mostly used for <div oninit ondestroy> animations
365
- subjectFunction.tagFunction = value;
366
- return subjectFunction;
367
- }
368
- function runTagCallback(value, tagSupport, bindTo, args) {
369
- const myGlobal = tagSupport.global;
370
- const renderCount = myGlobal.renderCount;
371
- const method = value.bind(bindTo);
372
- const callbackResult = method(...args);
373
- const sameRenderCount = renderCount === myGlobal.renderCount;
374
- const skipRender = !sameRenderCount || myGlobal.deleted;
375
- // already rendered OR tag was deleted before event processing
376
- if (skipRender) {
377
- if (callbackResult instanceof Promise) {
378
- return callbackResult.then(() => {
379
- return 'promise-no-data-ever'; // tag was deleted during event processing
380
- });
381
- }
382
- return 'no-data-ever'; // already rendered
383
- }
384
- const newest = (0,_tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_0__.renderTagSupport)(myGlobal.newest, true);
385
- myGlobal.newest = newest;
386
- if (callbackResult instanceof Promise) {
387
- return callbackResult.then(() => {
388
- if (myGlobal.deleted) {
389
- return 'promise-no-data-ever'; // tag was deleted during event processing
390
- }
391
- const newest = (0,_tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_0__.renderTagSupport)(myGlobal.newest, true);
392
- myGlobal.newest = newest;
393
- return 'promise-no-data-ever';
394
- });
395
- }
396
- // Caller always expects a Promise
397
- return 'no-data-ever';
398
- }
399
-
400
-
401
- /***/ }),
402
-
403
- /***/ "./ts/interpolations/elementInitCheck.ts":
404
- /*!***********************************************!*\
405
- !*** ./ts/interpolations/elementInitCheck.ts ***!
406
- \***********************************************/
407
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
408
-
409
- __webpack_require__.r(__webpack_exports__);
410
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
411
- /* harmony export */ elementInitCheck: () => (/* binding */ elementInitCheck)
412
- /* harmony export */ });
413
- function elementInitCheck(nextSibling, counts) {
414
- const onInitDoubleWrap = nextSibling.oninit;
415
- if (!onInitDoubleWrap) {
416
- return counts.added;
417
- }
418
- const onInitWrap = onInitDoubleWrap.tagFunction;
419
- if (!onInitWrap) {
420
- return counts.added;
421
- }
422
- const onInit = onInitWrap.tagFunction;
423
- if (!onInit) {
424
- return counts.added;
425
- }
426
- const event = { target: nextSibling, stagger: counts.added };
427
- onInit(event);
428
- return ++counts.added;
429
- }
430
-
431
-
432
- /***/ }),
433
-
434
- /***/ "./ts/interpolations/inputAttribute.ts":
435
- /*!*********************************************!*\
436
- !*** ./ts/interpolations/inputAttribute.ts ***!
437
- \*********************************************/
438
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
439
-
440
- __webpack_require__.r(__webpack_exports__);
441
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
442
- /* harmony export */ inputAttribute: () => (/* binding */ inputAttribute)
443
- /* harmony export */ });
444
- function inputAttribute(name, value, element) {
445
- const names = name.split('.');
446
- // style.position = "absolute"
447
- if (names[0] === 'style') {
448
- element.style[names[1]] = value;
449
- }
450
- // Example: class.width-full = "true"
451
- if (names[0] === 'class') {
452
- names.shift();
453
- if (value) {
454
- for (let index = 0; index < names.length; ++index) {
455
- element.classList.add(names[index]);
456
- }
457
- }
458
- else {
459
- for (let index = 0; index < names.length; ++index) {
460
- element.classList.remove(names[index]);
461
- }
462
- }
463
- }
464
- }
465
-
466
-
467
- /***/ }),
468
-
469
- /***/ "./ts/interpolations/interpolateAttributes.ts":
470
- /*!****************************************************!*\
471
- !*** ./ts/interpolations/interpolateAttributes.ts ***!
472
- \****************************************************/
473
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
474
-
475
- __webpack_require__.r(__webpack_exports__);
476
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
477
- /* harmony export */ interpolateAttributes: () => (/* binding */ interpolateAttributes)
478
- /* harmony export */ });
479
- /* harmony import */ var _processAttribute_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./processAttribute.function */ "./ts/interpolations/processAttribute.function.ts");
480
-
481
- function howToSetAttribute(element, name, value) {
482
- element.setAttribute(name, value);
483
- }
484
- function howToSetInputValue(element, name, value) {
485
- element[name] = value;
486
- }
487
- function interpolateAttributes(child, scope, ownerSupport) {
488
- const attrNames = child.getAttributeNames();
489
- let howToSet = howToSetAttribute;
490
- for (let index = 0; index < attrNames.length; ++index) {
491
- const attrName = attrNames[index];
492
- if (child.nodeName === 'INPUT' && attrName === 'value') {
493
- howToSet = howToSetInputValue;
494
- }
495
- const value = child.getAttribute(attrName);
496
- (0,_processAttribute_function__WEBPACK_IMPORTED_MODULE_0__.processAttribute)(attrName, value, child, scope, ownerSupport, howToSet);
497
- howToSet = howToSetAttribute; // put back
498
- }
499
- }
500
-
501
-
502
- /***/ }),
503
-
504
- /***/ "./ts/interpolations/interpolateContentTemplates.ts":
505
- /*!**********************************************************!*\
506
- !*** ./ts/interpolations/interpolateContentTemplates.ts ***!
507
- \**********************************************************/
508
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
509
-
510
- __webpack_require__.r(__webpack_exports__);
511
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
512
- /* harmony export */ interpolateContentTemplates: () => (/* binding */ interpolateContentTemplates)
513
- /* harmony export */ });
514
- /* harmony import */ var _interpolateTemplate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./interpolateTemplate */ "./ts/interpolations/interpolateTemplate.ts");
515
-
516
- function interpolateContentTemplates(context, tagSupport, options, children) {
517
- // counting for animation stagger computing
518
- const counts = options.counts;
519
- const clones = [];
520
- const tagComponents = [];
521
- const childLength = children.length;
522
- for (let index = childLength - 1; index >= 0; --index) {
523
- const child = children[index];
524
- const { clones: nextClones, tagComponent } = (0,_interpolateTemplate__WEBPACK_IMPORTED_MODULE_0__.interpolateTemplate)(child, context, tagSupport, counts, options);
525
- clones.push(...nextClones);
526
- if (tagComponent) {
527
- tagComponents.push(tagComponent);
528
- continue;
529
- }
530
- if (child.children) {
531
- for (let index = child.children.length - 1; index >= 0; --index) {
532
- const subChild = child.children[index];
533
- // IF <template end /> its a variable to be processed
534
- if (isRenderEndTemplate(subChild)) {
535
- const { tagComponent } = (0,_interpolateTemplate__WEBPACK_IMPORTED_MODULE_0__.interpolateTemplate)(subChild, context, tagSupport, counts, options);
536
- if (tagComponent) {
537
- tagComponents.push(tagComponent);
538
- }
539
- }
540
- const { clones: nextClones, tagComponents: nextTagComponent } = interpolateContentTemplates(context, tagSupport, options, subChild.children);
541
- clones.push(...nextClones);
542
- tagComponents.push(...nextTagComponent);
543
- }
544
- }
545
- }
546
- return { clones, tagComponents };
547
- }
548
- function isRenderEndTemplate(child) {
549
- const isTemplate = child.tagName === 'TEMPLATE';
550
- return isTemplate &&
551
- child.getAttribute('interpolate') !== undefined &&
552
- child.getAttribute('end') !== undefined;
553
- }
554
-
555
-
556
- /***/ }),
557
-
558
- /***/ "./ts/interpolations/interpolateElement.ts":
559
- /*!*************************************************!*\
560
- !*** ./ts/interpolations/interpolateElement.ts ***!
561
- \*************************************************/
562
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
563
-
564
- __webpack_require__.r(__webpack_exports__);
565
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
566
- /* harmony export */ interpolateElement: () => (/* binding */ interpolateElement),
567
- /* harmony export */ interpolateString: () => (/* binding */ interpolateString)
568
- /* harmony export */ });
569
- /* harmony import */ var _interpolateAttributes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./interpolateAttributes */ "./ts/interpolations/interpolateAttributes.ts");
570
- /* harmony import */ var _interpolations__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./interpolations */ "./ts/interpolations/interpolations.ts");
571
- /* harmony import */ var _interpolateContentTemplates__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interpolateContentTemplates */ "./ts/interpolations/interpolateContentTemplates.ts");
572
- /* harmony import */ var _tag_Tag_class__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../tag/Tag.class */ "./ts/tag/Tag.class.ts");
573
-
574
-
575
-
576
-
577
- /** Review elements within an element */
578
- function interpolateElement(container, // element containing innerHTML to review interpolations
579
- context, // variables used to evaluate
580
- interpolatedTemplates, ownerSupport, options) {
581
- const clones = [];
582
- const tagComponents = [];
583
- const result = interpolatedTemplates.interpolation;
584
- const template = container.children[0];
585
- const children = template.content.children;
586
- if (result.keys.length) {
587
- const { clones: nextClones, tagComponents: nextTagComponents } = (0,_interpolateContentTemplates__WEBPACK_IMPORTED_MODULE_2__.interpolateContentTemplates)(context, ownerSupport, options, children);
588
- clones.push(...nextClones);
589
- tagComponents.push(...nextTagComponents);
590
- }
591
- (0,_interpolateAttributes__WEBPACK_IMPORTED_MODULE_0__.interpolateAttributes)(template, context, ownerSupport);
592
- processChildrenAttributes(children, context, ownerSupport);
593
- return { clones, tagComponents };
594
- }
595
- function processChildrenAttributes(children, context, ownerSupport) {
596
- for (let index = children.length - 1; index >= 0; --index) {
597
- const child = children[index];
598
- (0,_interpolateAttributes__WEBPACK_IMPORTED_MODULE_0__.interpolateAttributes)(child, context, ownerSupport);
599
- if (child.children) {
600
- processChildrenAttributes(child.children, context, ownerSupport);
601
- }
602
- }
603
- }
604
- function interpolateString(string) {
605
- const result = (0,_interpolations__WEBPACK_IMPORTED_MODULE_1__.interpolateToTemplates)(string);
606
- result.string = result.string.replace(_tag_Tag_class__WEBPACK_IMPORTED_MODULE_3__.escapeSearch, _tag_Tag_class__WEBPACK_IMPORTED_MODULE_3__.variablePrefix);
607
- return result;
608
- }
609
-
610
-
611
- /***/ }),
612
-
613
- /***/ "./ts/interpolations/interpolateTemplate.ts":
614
- /*!**************************************************!*\
615
- !*** ./ts/interpolations/interpolateTemplate.ts ***!
616
- \**************************************************/
617
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
618
-
619
- __webpack_require__.r(__webpack_exports__);
620
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
621
- /* harmony export */ afterElmBuild: () => (/* binding */ afterElmBuild),
622
- /* harmony export */ interpolateTemplate: () => (/* binding */ interpolateTemplate),
623
- /* harmony export */ subscribeToTemplate: () => (/* binding */ subscribeToTemplate)
624
- /* harmony export */ });
625
- /* harmony import */ var _tag_Tag_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../tag/Tag.class */ "./ts/tag/Tag.class.ts");
626
- /* harmony import */ var _elementInitCheck__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./elementInitCheck */ "./ts/interpolations/elementInitCheck.ts");
627
- /* harmony import */ var _tag_update_processFirstSubjectValue_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../tag/update/processFirstSubjectValue.function */ "./ts/tag/update/processFirstSubjectValue.function.ts");
628
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../isInstance */ "./ts/isInstance.ts");
629
- /* harmony import */ var _scanTextAreaValue_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scanTextAreaValue.function */ "./ts/interpolations/scanTextAreaValue.function.ts");
630
- /* harmony import */ var _tag_update_updateExistingValue_function__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../tag/update/updateExistingValue.function */ "./ts/tag/update/updateExistingValue.function.ts");
631
- /* harmony import */ var _tag_setTagPlaceholder_function__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../tag/setTagPlaceholder.function */ "./ts/tag/setTagPlaceholder.function.ts");
632
-
633
-
634
-
635
-
636
-
637
-
638
-
639
- function interpolateTemplate(insertBefore, // <template end interpolate /> (will be removed)
640
- context, // variable scope of {`__tagvar${index}`:'x'}
641
- ownerSupport, // Tag class
642
- counts, // used for animation stagger computing
643
- options) {
644
- // TODO: THe clones array is useless here
645
- const clones = [];
646
- if (!insertBefore.hasAttribute('end')) {
647
- return { clones }; // only care about <template end>
648
- }
649
- const variableName = insertBefore.getAttribute('id');
650
- if (variableName?.substring(0, _tag_Tag_class__WEBPACK_IMPORTED_MODULE_0__.variablePrefix.length) !== _tag_Tag_class__WEBPACK_IMPORTED_MODULE_0__.variablePrefix) {
651
- return { clones }; // ignore, not a tagVar
652
- }
653
- const existingSubject = context[variableName];
654
- const isDynamic = (0,_isInstance__WEBPACK_IMPORTED_MODULE_3__.isTagComponent)(existingSubject.value) || (0,_isInstance__WEBPACK_IMPORTED_MODULE_3__.isTagArray)(existingSubject.value);
655
- // process dynamics later
656
- if (isDynamic) {
657
- return {
658
- clones,
659
- tagComponent: {
660
- variableName,
661
- ownerSupport,
662
- subject: existingSubject,
663
- insertBefore
664
- }
665
- };
666
- }
667
- subscribeToTemplate(insertBefore, existingSubject, ownerSupport, counts);
668
- return { clones };
669
- }
670
- function subscribeToTemplate(insertBefore, subject, ownerSupport, counts) {
671
- let called = false;
672
- const onValue = (value) => {
673
- if (called) {
674
- (0,_tag_update_updateExistingValue_function__WEBPACK_IMPORTED_MODULE_5__.updateExistingValue)(subject, value, ownerSupport, insertBefore);
675
- return;
676
- }
677
- const templater = value;
678
- (0,_tag_update_processFirstSubjectValue_function__WEBPACK_IMPORTED_MODULE_2__.processFirstSubjectValue)(templater, subject, insertBefore, ownerSupport, {
679
- counts: { ...counts },
680
- });
681
- called = true;
682
- };
683
- let mutatingCallback = onValue;
684
- const callback = (value) => mutatingCallback(value);
685
- const sub = subject.subscribe(callback);
686
- // on subscribe, the Subject did NOT emit immediately. Lets pull the template off the document
687
- if (insertBefore.parentNode) {
688
- const clone = subject.clone = (0,_tag_setTagPlaceholder_function__WEBPACK_IMPORTED_MODULE_6__.swapInsertBefore)(insertBefore);
689
- mutatingCallback = v => {
690
- const parentNode = clone.parentNode;
691
- parentNode.insertBefore(insertBefore, clone);
692
- parentNode.removeChild(clone);
693
- delete subject.clone;
694
- mutatingCallback = onValue; // all future calls will just produce value
695
- onValue(v); // calls for rending
696
- };
697
- }
698
- ownerSupport.global.subscriptions.push(sub);
699
- }
700
- function afterElmBuild(elm, options, context, ownerSupport) {
701
- if (!elm.getAttribute) {
702
- return;
703
- }
704
- const tagName = elm.nodeName; // elm.tagName
705
- if (tagName === 'TEXTAREA') {
706
- (0,_scanTextAreaValue_function__WEBPACK_IMPORTED_MODULE_4__.scanTextAreaValue)(elm, context, ownerSupport);
707
- }
708
- let diff = options.counts.added;
709
- diff = (0,_elementInitCheck__WEBPACK_IMPORTED_MODULE_1__.elementInitCheck)(elm, options.counts) - diff;
710
- if (elm.children) {
711
- const children = elm.children;
712
- for (let index = children.length - 1; index >= 0; --index) {
713
- const child = children[index];
714
- const subOptions = {
715
- ...options,
716
- counts: options.counts,
717
- };
718
- return afterElmBuild(child, subOptions, context, ownerSupport);
719
- }
720
- }
721
- }
722
-
723
-
724
- /***/ }),
725
-
726
- /***/ "./ts/interpolations/interpolations.ts":
727
- /*!*********************************************!*\
728
- !*** ./ts/interpolations/interpolations.ts ***!
729
- \*********************************************/
730
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
731
-
732
- __webpack_require__.r(__webpack_exports__);
733
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
734
- /* harmony export */ interpolateReplace: () => (/* binding */ interpolateReplace),
735
- /* harmony export */ interpolateToTemplates: () => (/* binding */ interpolateToTemplates)
736
- /* harmony export */ });
737
- // support arrow functions in attributes
738
- const interpolateReplace = /(?:<[^>]*?(?:(?:\s+\w+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+)))*\s*)\/?>)|({__tagvar[^}]+})/g;
739
- /** replaces ${x} with <template id="x-start"></template><template id="x-end"></template> */
740
- function interpolateToTemplates(template) {
741
- const keys = [];
742
- const string = template.replace(interpolateReplace, (match, expression) => {
743
- if (match.startsWith('<')) {
744
- // If the match is an HTML tag, don't replace
745
- return match;
746
- }
747
- const noBraces = expression.substring(1, expression.length - 1);
748
- const id = noBraces;
749
- keys.push(id);
750
- return `<template interpolate end id="${id}"></template>`;
751
- });
752
- return { string, keys };
753
- }
754
-
755
-
756
- /***/ }),
757
-
758
- /***/ "./ts/interpolations/processAttribute.function.ts":
759
- /*!********************************************************!*\
760
- !*** ./ts/interpolations/processAttribute.function.ts ***!
761
- \********************************************************/
762
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
763
-
764
- __webpack_require__.r(__webpack_exports__);
765
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
766
- /* harmony export */ processAttribute: () => (/* binding */ processAttribute)
767
- /* harmony export */ });
768
- /* harmony import */ var _inputAttribute__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./inputAttribute */ "./ts/interpolations/inputAttribute.ts");
769
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../isInstance */ "./ts/isInstance.ts");
770
- /* harmony import */ var _bindSubjectCallback_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bindSubjectCallback.function */ "./ts/interpolations/bindSubjectCallback.function.ts");
771
-
772
-
773
-
774
- const startRegX = /^\s*{__tagvar/;
775
- const endRegX = /}\s*$/;
776
- function isTagVar(value) {
777
- return value && value.search(startRegX) >= 0 && value.search(endRegX) >= 0;
778
- }
779
- function processAttribute(attrName, value, child, scope, ownerSupport, howToSet) {
780
- if (isTagVar(value)) {
781
- return processScopedNameValueAttr(attrName, value, child, scope, ownerSupport, howToSet);
782
- }
783
- if (isTagVar(attrName)) {
784
- const contextValueSubject = getContextValueByVarString(scope, attrName);
785
- let lastValue;
786
- // the above callback gets called immediately since its a ValueSubject()
787
- const sub = contextValueSubject.subscribe((value) => {
788
- processNameOnlyAttr(value, lastValue, child, ownerSupport, howToSet);
789
- lastValue = value;
790
- });
791
- ownerSupport.global.subscriptions.push(sub); // this is where unsubscribe is picked up
792
- child.removeAttribute(attrName);
793
- return;
794
- }
795
- // Non dynamic
796
- const isSpecial = isSpecialAttr(attrName);
797
- if (isSpecial) {
798
- return (0,_inputAttribute__WEBPACK_IMPORTED_MODULE_0__.inputAttribute)(attrName, value, child);
799
- }
800
- }
801
- function processScopedNameValueAttr(attrName, value, // {__tagVarN}
802
- child, scope, ownerSupport, howToSet) {
803
- // get the code inside the brackets like "variable0" or "{variable0}"
804
- const result = getContextValueByVarString(scope, value);
805
- return processNameValueAttr(attrName, result, child, ownerSupport, howToSet);
806
- }
807
- function getContextValueByVarString(scope, value) {
808
- const code = value.replace('{', '').split('').reverse().join('').replace('}', '').split('').reverse().join('');
809
- return scope[code];
810
- }
811
- function processNameOnlyAttr(attrValue, lastValue, child, ownerSupport, howToSet) {
812
- if (lastValue && lastValue != attrValue) {
813
- if (typeof (lastValue) === 'string') {
814
- child.removeAttribute(lastValue);
815
- }
816
- else if (lastValue instanceof Object) {
817
- for (const name in lastValue) {
818
- child.removeAttribute(name);
819
- }
820
- }
821
- }
822
- if (typeof (attrValue) === 'string') {
823
- if (!attrValue.length) {
824
- return;
825
- }
826
- processNameValueAttr(attrValue, '', child, ownerSupport, howToSet);
827
- return;
828
- }
829
- if (attrValue instanceof Object) {
830
- for (const name in attrValue) {
831
- processNameValueAttr(name, attrValue[name], child, ownerSupport, howToSet);
832
- }
833
- }
834
- }
835
- function processNameValueAttr(attrName, result, child, ownerSupport, howToSet) {
836
- const isSpecial = isSpecialAttr(attrName);
837
- if (result instanceof Function) {
838
- const action = function (...args) {
839
- const result2 = result(child, args);
840
- return result2;
841
- };
842
- child[attrName].action = action;
843
- }
844
- // Most every variable comes in here since everything is made a ValueSubject
845
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_1__.isSubjectInstance)(result)) {
846
- child.removeAttribute(attrName);
847
- const callback = (newAttrValue) => {
848
- if (newAttrValue instanceof Function) {
849
- newAttrValue = (0,_bindSubjectCallback_function__WEBPACK_IMPORTED_MODULE_2__.bindSubjectCallback)(newAttrValue, ownerSupport);
850
- }
851
- return processAttributeSubjectValue(newAttrValue, child, attrName, isSpecial, howToSet);
852
- };
853
- // 🗞️ Subscribe. Above callback called immediately since its a ValueSubject()
854
- const sub = result.subscribe(callback);
855
- // Record subscription for later unsubscribe when element destroyed
856
- ownerSupport.global.subscriptions.push(sub);
857
- return;
858
- }
859
- howToSet(child, attrName, result);
860
- // child.setAttribute(attrName, result.value)
861
- return;
862
- }
863
- function processAttributeSubjectValue(newAttrValue, child, attrName, isSpecial, howToSet) {
864
- if (newAttrValue instanceof Function) {
865
- const fun = function (...args) {
866
- return newAttrValue(child, args);
867
- };
868
- // access to original function
869
- fun.tagFunction = newAttrValue;
870
- child[attrName] = fun;
871
- return;
872
- }
873
- if (isSpecial) {
874
- (0,_inputAttribute__WEBPACK_IMPORTED_MODULE_0__.inputAttribute)(attrName, newAttrValue, child);
875
- return;
876
- }
877
- if (newAttrValue) {
878
- howToSet(child, attrName, newAttrValue);
879
- return;
880
- }
881
- const isDeadValue = [undefined, false, null].includes(newAttrValue);
882
- if (isDeadValue) {
883
- child.removeAttribute(attrName);
884
- return;
885
- }
886
- // value is 0
887
- howToSet(child, attrName, newAttrValue);
888
- }
889
- /** Looking for (class | style) followed by a period */
890
- function isSpecialAttr(attrName) {
891
- return attrName.search(/^(class|style)(\.)/) >= 0;
892
- }
893
-
894
-
895
- /***/ }),
896
-
897
- /***/ "./ts/interpolations/scanTextAreaValue.function.ts":
898
- /*!*********************************************************!*\
899
- !*** ./ts/interpolations/scanTextAreaValue.function.ts ***!
900
- \*********************************************************/
901
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
902
-
903
- __webpack_require__.r(__webpack_exports__);
904
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
905
- /* harmony export */ scanTextAreaValue: () => (/* binding */ scanTextAreaValue)
906
- /* harmony export */ });
907
- /* harmony import */ var _processAttribute_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./processAttribute.function */ "./ts/interpolations/processAttribute.function.ts");
908
-
909
- const search = new RegExp('\\s*<template interpolate end id="__tagvar(\\d{1,4})"([^>]*)></template>(\\s*)');
910
- function scanTextAreaValue(textarea, context, ownerSupport) {
911
- const value = textarea.value;
912
- if (value.search(search) >= 0) {
913
- const match = value.match(/__tagvar(\d{1,4})/);
914
- const token = match ? match[0] : '';
915
- const dynamic = '{' + token + '}';
916
- textarea.value = '';
917
- textarea.setAttribute('text-var-value', dynamic);
918
- const howToSet = (_elm, _name, value) => textarea.value = value;
919
- (0,_processAttribute_function__WEBPACK_IMPORTED_MODULE_0__.processAttribute)('text-var-value', dynamic, // realValue, // context[token].value,
920
- textarea, context, ownerSupport, howToSet);
921
- }
922
- }
923
-
924
-
925
- /***/ }),
926
-
927
- /***/ "./ts/isInstance.ts":
928
- /*!**************************!*\
929
- !*** ./ts/isInstance.ts ***!
930
- \**************************/
931
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
932
-
933
- __webpack_require__.r(__webpack_exports__);
934
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
935
- /* harmony export */ isSubjectInstance: () => (/* binding */ isSubjectInstance),
936
- /* harmony export */ isTag: () => (/* binding */ isTag),
937
- /* harmony export */ isTagArray: () => (/* binding */ isTagArray),
938
- /* harmony export */ isTagClass: () => (/* binding */ isTagClass),
939
- /* harmony export */ isTagComponent: () => (/* binding */ isTagComponent),
940
- /* harmony export */ isTagTemplater: () => (/* binding */ isTagTemplater)
941
- /* harmony export */ });
942
- function isTag(value) {
943
- return isTagTemplater(value) || isTagClass(value);
944
- }
945
- function isTagTemplater(value) {
946
- const templater = value;
947
- return templater?.isTemplater === true && templater.wrapper === undefined;
948
- }
949
- // TODO: whats the difference between isTagClass and isTagComponent
950
- function isTagComponent(value) {
951
- return value?.wrapper?.parentWrap.original instanceof Function;
952
- }
953
- function isTagClass(value) {
954
- const templater = value;
955
- return templater?.isTagClass === true;
956
- }
957
- // isSubjectLike
958
- function isSubjectInstance(subject) {
959
- return (subject?.isSubject === true || subject?.subscribe) ? true : false; // subject?.isSubject === true ||
960
- }
961
- function isTagArray(value) {
962
- return value instanceof Array && value.every(x => isTagClass(x) || isTagTemplater(x));
963
- }
964
-
965
-
966
- /***/ }),
967
-
968
- /***/ "./ts/render.ts":
969
- /*!**********************!*\
970
- !*** ./ts/render.ts ***!
971
- \**********************/
972
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
973
-
974
- __webpack_require__.r(__webpack_exports__);
975
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
976
- /* harmony export */ buildClones: () => (/* binding */ buildClones)
977
- /* harmony export */ });
978
- function buildClones(temporary, insertBefore) {
979
- const clones = [];
980
- const template = temporary.children[0];
981
- let nextSibling = template.content.firstChild;
982
- const fragment = document.createDocumentFragment();
983
- while (nextSibling) {
984
- const nextNextSibling = nextSibling.nextSibling;
985
- clones.push(nextSibling);
986
- fragment.appendChild(nextSibling);
987
- nextSibling = nextNextSibling;
988
- }
989
- if (insertBefore.parentNode) {
990
- const parentNode = insertBefore.parentNode;
991
- parentNode.insertBefore(fragment, insertBefore);
992
- }
993
- return clones;
994
- }
995
-
996
-
997
- /***/ }),
998
-
999
- /***/ "./ts/state/callbackMaker.function.ts":
1000
- /*!********************************************!*\
1001
- !*** ./ts/state/callbackMaker.function.ts ***!
1002
- \********************************************/
1003
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1004
-
1005
- __webpack_require__.r(__webpack_exports__);
1006
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1007
- /* harmony export */ callback: () => (/* binding */ callback),
1008
- /* harmony export */ callbackMaker: () => (/* binding */ callbackMaker)
1009
- /* harmony export */ });
1010
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1011
- /* harmony import */ var _tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../tag/render/renderTagSupport.function */ "./ts/tag/render/renderTagSupport.function.ts");
1012
- /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../errors */ "./ts/errors.ts");
1013
- /* harmony import */ var _syncStates_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./syncStates.function */ "./ts/state/syncStates.function.ts");
1014
- /* harmony import */ var _tag_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tag/getSupportInCycle.function */ "./ts/tag/getSupportInCycle.function.ts");
1015
-
1016
-
1017
-
1018
-
1019
-
1020
- let innerCallback = (callback) => (a, b, c, d, e, f) => {
1021
- throw new _errors__WEBPACK_IMPORTED_MODULE_2__.SyncCallbackError('Callback function was called immediately in sync and must instead be call async');
1022
- };
1023
- const callbackMaker = () => innerCallback;
1024
- const originalGetter = innerCallback; // callbackMaker
1025
- (0,_setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse)({
1026
- beforeRender: (tagSupport) => initMemory(tagSupport),
1027
- beforeRedraw: (tagSupport) => initMemory(tagSupport),
1028
- afterRender: (tagSupport) => {
1029
- ;
1030
- tagSupport.global.callbackMaker = true;
1031
- innerCallback = originalGetter; // prevent crossing callbacks with another tag
1032
- },
1033
- });
1034
- function callback(callback) {
1035
- const tagSupport = (0,_tag_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_4__.getSupportInCycle)();
1036
- if (!tagSupport) {
1037
- const error = new _errors__WEBPACK_IMPORTED_MODULE_2__.SyncCallbackError('callback() was called outside of synchronous rendering. Use `callback = callbackMaker()` to create a callback that could be called out of sync with rendering');
1038
- throw error;
1039
- }
1040
- const oldState = _setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.stateConfig.array;
1041
- const trigger = (...args) => {
1042
- const callbackMaker = tagSupport.global.callbackMaker;
1043
- if (callbackMaker) {
1044
- return triggerStateUpdate(tagSupport, callback, oldState, ...args);
1045
- }
1046
- return callback(...args);
1047
- };
1048
- return trigger;
1049
- }
1050
- function initMemory(tagSupport) {
1051
- const oldState = _setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.stateConfig.array;
1052
- innerCallback = (callback) => {
1053
- const trigger = (...args) => {
1054
- const callbackMaker = tagSupport.global.callbackMaker;
1055
- if (callbackMaker) {
1056
- return triggerStateUpdate(tagSupport, callback, oldState, ...args);
1057
- }
1058
- return callback(...args);
1059
- };
1060
- return trigger;
1061
- };
1062
- }
1063
- function triggerStateUpdate(tagSupport, callback, oldState, ...args) {
1064
- const state = tagSupport.memory.state;
1065
- // ensure that the oldest has the latest values first
1066
- (0,_syncStates_function__WEBPACK_IMPORTED_MODULE_3__.syncStates)(state, oldState);
1067
- // run the callback
1068
- const maybePromise = callback(...args);
1069
- // send the oldest state changes into the newest
1070
- (0,_syncStates_function__WEBPACK_IMPORTED_MODULE_3__.syncStates)(oldState, state);
1071
- /*
1072
- if(tagSupport.global.deleted) {
1073
- return maybePromise // While running callback the tag was deleted. Often that happens
1074
- }
1075
- */
1076
- (0,_tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_1__.renderTagSupport)(tagSupport, false);
1077
- if (maybePromise instanceof Promise) {
1078
- maybePromise.finally(() => {
1079
- // send the oldest state changes into the newest
1080
- (0,_syncStates_function__WEBPACK_IMPORTED_MODULE_3__.syncStates)(oldState, state);
1081
- (0,_tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_1__.renderTagSupport)(tagSupport, false);
1082
- });
1083
- }
1084
- // return undefined as T
1085
- return maybePromise;
1086
- }
1087
-
1088
-
1089
- /***/ }),
1090
-
1091
- /***/ "./ts/state/children.ts":
1092
- /*!******************************!*\
1093
- !*** ./ts/state/children.ts ***!
1094
- \******************************/
1095
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1096
-
1097
- __webpack_require__.r(__webpack_exports__);
1098
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1099
- /* harmony export */ children: () => (/* binding */ children)
1100
- /* harmony export */ });
1101
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1102
-
1103
- function setCurrentTagSupport(support) {
1104
- _setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.childrenCurrentSupport = support;
1105
- }
1106
- function children() {
1107
- const tagSupport = _setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.childrenCurrentSupport;
1108
- const children = tagSupport.templater.children;
1109
- return children;
1110
- }
1111
- (0,_setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse)({
1112
- beforeRender: tagSupport => setCurrentTagSupport(tagSupport),
1113
- beforeRedraw: tagSupport => setCurrentTagSupport(tagSupport),
1114
- });
1115
-
1116
-
1117
- /***/ }),
1118
-
1119
- /***/ "./ts/state/index.ts":
1120
- /*!***************************!*\
1121
- !*** ./ts/state/index.ts ***!
1122
- \***************************/
1123
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1124
-
1125
- __webpack_require__.r(__webpack_exports__);
1126
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1127
- /* harmony export */ callback: () => (/* reexport safe */ _callbackMaker_function__WEBPACK_IMPORTED_MODULE_7__.callback),
1128
- /* harmony export */ callbackMaker: () => (/* reexport safe */ _callbackMaker_function__WEBPACK_IMPORTED_MODULE_7__.callbackMaker),
1129
- /* harmony export */ children: () => (/* reexport safe */ _children__WEBPACK_IMPORTED_MODULE_10__.children),
1130
- /* harmony export */ letProp: () => (/* reexport safe */ _letProp_function__WEBPACK_IMPORTED_MODULE_4__.letProp),
1131
- /* harmony export */ letState: () => (/* reexport safe */ _letState_function__WEBPACK_IMPORTED_MODULE_5__.letState),
1132
- /* harmony export */ onDestroy: () => (/* reexport safe */ _onDestroy__WEBPACK_IMPORTED_MODULE_9__.onDestroy),
1133
- /* harmony export */ onInit: () => (/* reexport safe */ _onInit__WEBPACK_IMPORTED_MODULE_8__.onInit),
1134
- /* harmony export */ providers: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_6__.providers),
1135
- /* harmony export */ setUse: () => (/* reexport safe */ _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse),
1136
- /* harmony export */ state: () => (/* reexport safe */ _state_function__WEBPACK_IMPORTED_MODULE_2__.state),
1137
- /* harmony export */ subject: () => (/* reexport safe */ _subject_function__WEBPACK_IMPORTED_MODULE_3__.subject),
1138
- /* harmony export */ watch: () => (/* reexport safe */ _watch_function__WEBPACK_IMPORTED_MODULE_0__.watch)
1139
- /* harmony export */ });
1140
- /* harmony import */ var _watch_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./watch.function */ "./ts/state/watch.function.ts");
1141
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1142
- /* harmony import */ var _state_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./state.function */ "./ts/state/state.function.ts");
1143
- /* harmony import */ var _subject_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./subject.function */ "./ts/state/subject.function.ts");
1144
- /* harmony import */ var _letProp_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./letProp.function */ "./ts/state/letProp.function.ts");
1145
- /* harmony import */ var _letState_function__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./letState.function */ "./ts/state/letState.function.ts");
1146
- /* harmony import */ var _providers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./providers */ "./ts/state/providers.ts");
1147
- /* harmony import */ var _callbackMaker_function__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./callbackMaker.function */ "./ts/state/callbackMaker.function.ts");
1148
- /* harmony import */ var _onInit__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./onInit */ "./ts/state/onInit.ts");
1149
- /* harmony import */ var _onDestroy__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./onDestroy */ "./ts/state/onDestroy.ts");
1150
- /* harmony import */ var _children__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./children */ "./ts/state/children.ts");
1151
-
1152
-
1153
-
1154
-
1155
-
1156
-
1157
-
1158
-
1159
-
1160
-
1161
-
1162
-
1163
-
1164
- /***/ }),
1165
-
1166
- /***/ "./ts/state/letProp.function.ts":
1167
- /*!**************************************!*\
1168
- !*** ./ts/state/letProp.function.ts ***!
1169
- \**************************************/
1170
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1171
-
1172
- __webpack_require__.r(__webpack_exports__);
1173
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1174
- /* harmony export */ letProp: () => (/* binding */ letProp)
1175
- /* harmony export */ });
1176
- /* harmony import */ var _letState_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./letState.function */ "./ts/state/letState.function.ts");
1177
- /* harmony import */ var _watch_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./watch.function */ "./ts/state/watch.function.ts");
1178
-
1179
-
1180
- /**
1181
- * Enables the ability to maintain a change to a props value until the prop itself changes
1182
- * @param prop typically the name of an existing prop
1183
- * @returns immediately call the returned function: letProp(y)(x => [y, y=x])
1184
- */
1185
- function letProp(prop) {
1186
- return getSetProp => {
1187
- let myProp = (0,_letState_function__WEBPACK_IMPORTED_MODULE_0__.letState)(prop)(getSetProp);
1188
- (0,_watch_function__WEBPACK_IMPORTED_MODULE_1__.watch)([prop], () => getSetProp(myProp = prop));
1189
- getSetProp(myProp);
1190
- return myProp;
1191
- };
1192
- }
1193
-
1194
-
1195
- /***/ }),
1196
-
1197
- /***/ "./ts/state/letState.function.ts":
1198
- /*!***************************************!*\
1199
- !*** ./ts/state/letState.function.ts ***!
1200
- \***************************************/
1201
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1202
-
1203
- __webpack_require__.r(__webpack_exports__);
1204
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1205
- /* harmony export */ letState: () => (/* binding */ letState)
1206
- /* harmony export */ });
1207
- /* harmony import */ var _state_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./state.utils */ "./ts/state/state.utils.ts");
1208
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1209
-
1210
-
1211
- /** Used for variables that need to remain the same variable during render passes */
1212
- function letState(defaultValue) {
1213
- const config = _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.stateConfig;
1214
- const rearray = config.rearray;
1215
- let getSetMethod;
1216
- const restate = rearray[config.array.length];
1217
- if (restate) {
1218
- let oldValue = (0,_state_utils__WEBPACK_IMPORTED_MODULE_0__.getStateValue)(restate);
1219
- getSetMethod = ((x) => [oldValue, oldValue = x]);
1220
- const push = {
1221
- get: () => (0,_state_utils__WEBPACK_IMPORTED_MODULE_0__.getStateValue)(push),
1222
- callback: getSetMethod,
1223
- lastValue: oldValue,
1224
- defaultValue: restate.defaultValue,
1225
- };
1226
- config.array.push(push);
1227
- return makeStateResult(oldValue, push);
1228
- }
1229
- // State first time run
1230
- const defaultFn = defaultValue instanceof Function ? defaultValue : () => defaultValue;
1231
- let initValue = defaultFn();
1232
- getSetMethod = ((x) => [initValue, initValue = x]);
1233
- const push = {
1234
- get: () => (0,_state_utils__WEBPACK_IMPORTED_MODULE_0__.getStateValue)(push),
1235
- callback: getSetMethod,
1236
- lastValue: initValue,
1237
- defaultValue: initValue,
1238
- };
1239
- config.array.push(push);
1240
- return makeStateResult(initValue, push);
1241
- }
1242
- function makeStateResult(initValue, push) {
1243
- // return initValue
1244
- const result = (y) => {
1245
- push.callback = y || (x => [initValue, initValue = x]);
1246
- return initValue;
1247
- };
1248
- return result;
1249
- }
1250
-
1251
-
1252
- /***/ }),
1253
-
1254
- /***/ "./ts/state/onDestroy.ts":
1255
- /*!*******************************!*\
1256
- !*** ./ts/state/onDestroy.ts ***!
1257
- \*******************************/
1258
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1259
-
1260
- __webpack_require__.r(__webpack_exports__);
1261
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1262
- /* harmony export */ onDestroy: () => (/* binding */ onDestroy)
1263
- /* harmony export */ });
1264
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1265
-
1266
- function setCurrentTagSupport(support) {
1267
- _setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.destroyCurrentSupport = support;
1268
- }
1269
- function onDestroy(callback) {
1270
- const tagSupport = _setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.destroyCurrentSupport;
1271
- tagSupport.global.destroyCallback = callback;
1272
- }
1273
- (0,_setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse)({
1274
- beforeRender: tagSupport => setCurrentTagSupport(tagSupport),
1275
- beforeRedraw: tagSupport => setCurrentTagSupport(tagSupport),
1276
- beforeDestroy: (tagSupport) => {
1277
- const callback = tagSupport.global.destroyCallback;
1278
- if (callback) {
1279
- callback();
1280
- }
1281
- }
1282
- });
1283
-
1284
-
1285
- /***/ }),
1286
-
1287
- /***/ "./ts/state/onInit.ts":
1288
- /*!****************************!*\
1289
- !*** ./ts/state/onInit.ts ***!
1290
- \****************************/
1291
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1292
-
1293
- __webpack_require__.r(__webpack_exports__);
1294
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1295
- /* harmony export */ onInit: () => (/* binding */ onInit)
1296
- /* harmony export */ });
1297
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1298
-
1299
- function setCurrentTagSupport(support) {
1300
- _setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.currentSupport = support;
1301
- }
1302
- function onInit(callback) {
1303
- const tagSupport = _setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.currentSupport;
1304
- if (!tagSupport.global.init) {
1305
- tagSupport.global.init = callback;
1306
- callback(); // fire init
1307
- }
1308
- }
1309
- (0,_setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse)({
1310
- beforeRender: tagSupport => setCurrentTagSupport(tagSupport),
1311
- beforeRedraw: tagSupport => setCurrentTagSupport(tagSupport),
1312
- });
1313
-
1314
-
1315
- /***/ }),
1316
-
1317
- /***/ "./ts/state/provider.utils.ts":
1318
- /*!************************************!*\
1319
- !*** ./ts/state/provider.utils.ts ***!
1320
- \************************************/
1321
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1322
-
1323
- __webpack_require__.r(__webpack_exports__);
1324
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1325
- /* harmony export */ providersChangeCheck: () => (/* binding */ providersChangeCheck)
1326
- /* harmony export */ });
1327
- /* harmony import */ var _deepFunctions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../deepFunctions */ "./ts/deepFunctions.ts");
1328
- /* harmony import */ var _tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../tag/render/renderTagSupport.function */ "./ts/tag/render/renderTagSupport.function.ts");
1329
-
1330
-
1331
- function providersChangeCheck(tagSupport) {
1332
- const global = tagSupport.global;
1333
- const providersWithChanges = global.providers.filter(provider => !(0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepEqual)(provider.instance, provider.clone));
1334
- // reset clones
1335
- for (let index = providersWithChanges.length - 1; index >= 0; --index) {
1336
- const provider = providersWithChanges[index];
1337
- const appSupport = tagSupport.getAppTagSupport();
1338
- handleProviderChanges(appSupport, provider);
1339
- provider.clone = (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepClone)(provider.instance);
1340
- }
1341
- }
1342
- function handleProviderChanges(appSupport, provider) {
1343
- const tagsWithProvider = getTagsWithProvider(appSupport, provider);
1344
- for (let index = tagsWithProvider.length - 1; index >= 0; --index) {
1345
- const { tagSupport, renderCount, provider } = tagsWithProvider[index];
1346
- if (tagSupport.global.deleted) {
1347
- continue; // i was deleted after another tag processed
1348
- }
1349
- const notRendered = renderCount === tagSupport.global.renderCount;
1350
- if (notRendered) {
1351
- provider.clone = (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepClone)(provider.instance);
1352
- (0,_tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_1__.renderTagSupport)(tagSupport, false);
1353
- continue;
1354
- }
1355
- }
1356
- }
1357
- /** Updates and returns memory of tag providers */
1358
- function getTagsWithProvider(tagSupport, provider, memory = []) {
1359
- const global = tagSupport.global;
1360
- const compare = global.providers;
1361
- const hasProvider = compare.find(xProvider => xProvider.constructMethod.compareTo === provider.constructMethod.compareTo);
1362
- if (hasProvider) {
1363
- memory.push({
1364
- tagSupport,
1365
- renderCount: global.renderCount,
1366
- provider: hasProvider,
1367
- });
1368
- }
1369
- const childTags = tagSupport.childTags;
1370
- for (let index = childTags.length - 1; index >= 0; --index) {
1371
- getTagsWithProvider(childTags[index], provider, memory);
1372
- }
1373
- return memory;
1374
- }
1375
-
1376
-
1377
- /***/ }),
1378
-
1379
- /***/ "./ts/state/providers.ts":
1380
- /*!*******************************!*\
1381
- !*** ./ts/state/providers.ts ***!
1382
- \*******************************/
1383
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1384
-
1385
- __webpack_require__.r(__webpack_exports__);
1386
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1387
- /* harmony export */ providers: () => (/* binding */ providers)
1388
- /* harmony export */ });
1389
- /* harmony import */ var _deepFunctions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../deepFunctions */ "./ts/deepFunctions.ts");
1390
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1391
- /* harmony import */ var _state_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./state.function */ "./ts/state/state.function.ts");
1392
-
1393
-
1394
-
1395
- _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.providerConfig = {
1396
- providers: [],
1397
- ownerSupport: undefined,
1398
- };
1399
- const providers = {
1400
- create: (constructMethod) => {
1401
- const stateDiffMemory = (0,_state_function__WEBPACK_IMPORTED_MODULE_2__.state)(() => ({ stateDiff: 0, provider: undefined }));
1402
- // mimic how many states were called the first time
1403
- if (stateDiffMemory.stateDiff) {
1404
- for (let x = stateDiffMemory.stateDiff; x > 0; --x) {
1405
- (0,_state_function__WEBPACK_IMPORTED_MODULE_2__.state)(undefined);
1406
- }
1407
- const result = (0,_state_function__WEBPACK_IMPORTED_MODULE_2__.state)(undefined);
1408
- // stateDiffMemory.provider.constructMethod.compareTo = compareTo
1409
- return result;
1410
- }
1411
- const result = (0,_state_function__WEBPACK_IMPORTED_MODULE_2__.state)(() => {
1412
- const memory = _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory;
1413
- const stateConfig = memory.stateConfig;
1414
- const oldStateCount = stateConfig.array.length;
1415
- // Providers with provider requirements just need to use providers.create() and providers.inject()
1416
- const instance = 'prototype' in constructMethod ? new constructMethod() : constructMethod();
1417
- const stateDiff = stateConfig.array.length - oldStateCount;
1418
- const config = memory.providerConfig;
1419
- const provider = {
1420
- constructMethod,
1421
- instance,
1422
- clone: (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepClone)(instance),
1423
- stateDiff,
1424
- };
1425
- stateDiffMemory.provider = provider;
1426
- config.providers.push(provider);
1427
- stateDiffMemory.stateDiff = stateDiff;
1428
- return instance;
1429
- });
1430
- const cm = constructMethod;
1431
- // const compareTo = cm.compareTo = cm.compareTo || cm.toString()
1432
- const compareTo = cm.compareTo = cm.toString();
1433
- stateDiffMemory.provider.constructMethod.compareTo = compareTo;
1434
- return result;
1435
- },
1436
- /**
1437
- * @template T
1438
- * @param {(new (...args: any[]) => T) | () => T} constructor
1439
- * @returns {T}
1440
- */
1441
- inject: (constructor) => {
1442
- // find once, return same every time after
1443
- return (0,_state_function__WEBPACK_IMPORTED_MODULE_2__.state)(() => {
1444
- const config = _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.providerConfig;
1445
- const cm = constructor;
1446
- const compareTo = cm.compareTo = cm.compareTo || constructor.toString();
1447
- let owner = {
1448
- ownerTagSupport: config.ownerSupport
1449
- };
1450
- while (owner.ownerTagSupport) {
1451
- const ownerProviders = owner.ownerTagSupport.global.providers;
1452
- const provider = ownerProviders.find(provider => {
1453
- const constructorMatch = provider.constructMethod.compareTo === compareTo;
1454
- if (constructorMatch) {
1455
- return true;
1456
- }
1457
- });
1458
- if (provider) {
1459
- provider.clone = (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepClone)(provider.instance); // keep a copy of the latest before any change occur
1460
- config.providers.push(provider);
1461
- return provider.instance;
1462
- }
1463
- owner = owner.ownerTagSupport; // cause reloop checking next parent
1464
- }
1465
- const msg = `Could not inject provider: ${constructor.name} ${constructor}`;
1466
- console.warn(`${msg}. Available providers`, config.providers);
1467
- throw new Error(msg);
1468
- });
1469
- }
1470
- };
1471
- (0,_setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse)({
1472
- beforeRender: (tagSupport, ownerSupport) => {
1473
- run(tagSupport, ownerSupport);
1474
- },
1475
- beforeRedraw: (tagSupport, newTagSupport) => {
1476
- run(tagSupport, newTagSupport.ownerTagSupport);
1477
- },
1478
- afterRender: (tagSupport) => {
1479
- const config = _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.providerConfig;
1480
- tagSupport.global.providers = [...config.providers];
1481
- config.providers.length = 0;
1482
- }
1483
- });
1484
- function run(tagSupport, ownerSupport) {
1485
- const config = _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.providerConfig;
1486
- config.ownerSupport = ownerSupport;
1487
- if (tagSupport.global.providers.length) {
1488
- config.providers.length = 0;
1489
- config.providers.push(...tagSupport.global.providers);
1490
- }
1491
- }
1492
-
1493
-
1494
- /***/ }),
1495
-
1496
- /***/ "./ts/state/setUse.function.ts":
1497
- /*!*************************************!*\
1498
- !*** ./ts/state/setUse.function.ts ***!
1499
- \*************************************/
1500
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1501
-
1502
- __webpack_require__.r(__webpack_exports__);
1503
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1504
- /* harmony export */ setUse: () => (/* binding */ setUse)
1505
- /* harmony export */ });
1506
- const tagUse = [];
1507
- function setUse(use) {
1508
- // must provide defaults
1509
- const useMe = {
1510
- beforeRender: use.beforeRender || (() => undefined),
1511
- beforeRedraw: use.beforeRedraw || (() => undefined),
1512
- afterRender: use.afterRender || (() => undefined),
1513
- beforeDestroy: use.beforeDestroy || (() => undefined),
1514
- };
1515
- setUse.tagUse.push(useMe);
1516
- }
1517
- setUse.tagUse = tagUse;
1518
- setUse.memory = {};
1519
-
1520
-
1521
- /***/ }),
1522
-
1523
- /***/ "./ts/state/state.function.ts":
1524
- /*!************************************!*\
1525
- !*** ./ts/state/state.function.ts ***!
1526
- \************************************/
1527
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1528
-
1529
- __webpack_require__.r(__webpack_exports__);
1530
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1531
- /* harmony export */ state: () => (/* binding */ state)
1532
- /* harmony export */ });
1533
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1534
- /* harmony import */ var _state_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./state.utils */ "./ts/state/state.utils.ts");
1535
- /* harmony import */ var _syncStates_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./syncStates.function */ "./ts/state/syncStates.function.ts");
1536
-
1537
-
1538
-
1539
- /** Used for variables that need to remain the same variable during render passes */
1540
- function state(defaultValue) {
1541
- const config = _setUse_function__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.stateConfig;
1542
- let getSetMethod;
1543
- const rearray = config.rearray;
1544
- const restate = rearray[config.array.length];
1545
- if (restate) {
1546
- let oldValue = (0,_state_utils__WEBPACK_IMPORTED_MODULE_1__.getStateValue)(restate);
1547
- getSetMethod = ((x) => [oldValue, oldValue = x]);
1548
- const push = {
1549
- get: () => (0,_state_utils__WEBPACK_IMPORTED_MODULE_1__.getStateValue)(push),
1550
- callback: getSetMethod,
1551
- lastValue: oldValue,
1552
- defaultValue: restate.defaultValue,
1553
- };
1554
- config.array.push(push);
1555
- return oldValue;
1556
- }
1557
- // State first time run
1558
- const defaultFn = defaultValue instanceof Function ? defaultValue : () => defaultValue;
1559
- let initValue = defaultFn();
1560
- // the state is actually intended to be a function
1561
- if (initValue instanceof Function) {
1562
- const oldState = config.array;
1563
- const tagSupport = config.tagSupport;
1564
- const original = initValue;
1565
- initValue = ((...args) => {
1566
- const global = tagSupport.global;
1567
- const newest = global.newest;
1568
- const newState = newest.memory.state;
1569
- (0,_syncStates_function__WEBPACK_IMPORTED_MODULE_2__.syncStates)(newState, oldState);
1570
- const result = original(...args);
1571
- (0,_syncStates_function__WEBPACK_IMPORTED_MODULE_2__.syncStates)(oldState, newState);
1572
- return result;
1573
- });
1574
- initValue.original = original;
1575
- }
1576
- getSetMethod = ((x) => [initValue, initValue = x]);
1577
- const push = {
1578
- get: () => (0,_state_utils__WEBPACK_IMPORTED_MODULE_1__.getStateValue)(push),
1579
- callback: getSetMethod,
1580
- lastValue: initValue,
1581
- defaultValue: initValue,
1582
- };
1583
- config.array.push(push);
1584
- return initValue;
1585
- }
1586
-
1587
-
1588
- /***/ }),
1589
-
1590
- /***/ "./ts/state/state.utils.ts":
1591
- /*!*********************************!*\
1592
- !*** ./ts/state/state.utils.ts ***!
1593
- \*********************************/
1594
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1595
-
1596
- __webpack_require__.r(__webpack_exports__);
1597
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1598
- /* harmony export */ StateEchoBack: () => (/* binding */ StateEchoBack),
1599
- /* harmony export */ getCallbackValue: () => (/* binding */ getCallbackValue),
1600
- /* harmony export */ getStateValue: () => (/* binding */ getStateValue)
1601
- /* harmony export */ });
1602
- /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../errors */ "./ts/errors.ts");
1603
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1604
-
1605
-
1606
- _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.stateConfig = {
1607
- array: [], // state memory on the first render
1608
- // rearray: [] as State,
1609
- };
1610
- const beforeRender = (tagSupport) => initState(tagSupport);
1611
- (0,_setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse)({
1612
- beforeRender,
1613
- beforeRedraw: beforeRender,
1614
- afterRender: (tagSupport) => {
1615
- const memory = tagSupport.memory;
1616
- const config = _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.stateConfig;
1617
- const rearray = config.rearray;
1618
- if (rearray.length) {
1619
- if (rearray.length !== config.array.length) {
1620
- const message = `States lengths have changed ${rearray.length} !== ${config.array.length}. State tracking requires the same amount of function calls every render. Typically this errors is thrown when a state like function call occurs only for certain conditions or when a function is intended to be wrapped with a tag() call`;
1621
- const wrapper = tagSupport.templater?.wrapper;
1622
- const details = {
1623
- oldStates: config.array,
1624
- newStates: config.rearray,
1625
- tagFunction: wrapper.parentWrap.original,
1626
- };
1627
- const error = new _errors__WEBPACK_IMPORTED_MODULE_0__.StateMismatchError(message, details);
1628
- console.warn(message, details);
1629
- throw error;
1630
- }
1631
- }
1632
- delete config.rearray; // clean up any previous runs
1633
- delete config.tagSupport;
1634
- memory.state.length = 0;
1635
- memory.state.push(...config.array);
1636
- const state = memory.state;
1637
- for (let index = state.length - 1; index >= 0; --index) {
1638
- const item = state[index];
1639
- item.lastValue = getStateValue(item); // set last values
1640
- }
1641
- config.array = [];
1642
- }
1643
- });
1644
- function getStateValue(state) {
1645
- const callback = state.callback;
1646
- if (!callback) {
1647
- return state.defaultValue;
1648
- }
1649
- const [value, checkValue] = getCallbackValue(callback);
1650
- if (checkValue !== StateEchoBack) {
1651
- const message = 'State property not used correctly. Second item in array is not setting value as expected.\n\n' +
1652
- 'For "let" state use `let name = state(default)(x => [name, name = x])`\n\n' +
1653
- 'For "const" state use `const name = state(default)()`\n\n' +
1654
- 'Problem state:\n' + (callback ? callback.toString() : JSON.stringify(state)) + '\n';
1655
- console.error(message, { state, callback, value, checkValue });
1656
- throw new Error(message);
1657
- }
1658
- return value;
1659
- }
1660
- class StateEchoBack {
1661
- }
1662
- function initState(tagSupport) {
1663
- const memory = tagSupport.memory;
1664
- const state = memory.state;
1665
- const config = _setUse_function__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.stateConfig;
1666
- // TODO: The following two blocks of code are state protects, have a production mode that removes this checks
1667
- /*
1668
- if (config.rearray) {
1669
- checkStateMismatch(tagSupport, config, state)
1670
- }
1671
- */
1672
- config.rearray = [];
1673
- const stateLength = state?.length;
1674
- if (stateLength) {
1675
- for (let index = 0; index < stateLength; ++index) {
1676
- getStateValue(state[index]);
1677
- }
1678
- config.rearray.push(...state);
1679
- }
1680
- config.tagSupport = tagSupport;
1681
- }
1682
- /*
1683
- function checkStateMismatch(
1684
- tagSupport: BaseTagSupport,
1685
- config: Config,
1686
- state: State,
1687
- ) {
1688
- const wrapper = tagSupport.templater?.wrapper as Wrapper
1689
- const wasWrapper = config.tagSupport?.templater.wrapper as Wrapper
1690
- const message = 'last state not cleared. Possibly in the middle of rendering one component and another is trying to render'
1691
-
1692
- if(!wasWrapper) {
1693
- return // its not a component or was not a component before
1694
- }
1695
-
1696
- console.error(message, {
1697
- config,
1698
- tagFunction: wrapper.parentWrap.original,
1699
- wasInMiddleOf: wasWrapper.parentWrap.original,
1700
- state,
1701
- expectedClearArray: config.rearray,
1702
- })
1703
-
1704
- throw new StateMismatchError(message, {
1705
- config,
1706
- tagFunction: wrapper.parentWrap.original,
1707
- state,
1708
- expectedClearArray: config.rearray,
1709
- })
1710
- }
1711
- */
1712
- function getCallbackValue(callback) {
1713
- const oldState = callback(StateEchoBack); // get value and set to undefined
1714
- const [value] = oldState;
1715
- const [checkValue] = callback(value); // set back to original value
1716
- return [value, checkValue];
1717
- }
1718
-
1719
-
1720
- /***/ }),
1721
-
1722
- /***/ "./ts/state/subject.function.ts":
1723
- /*!**************************************!*\
1724
- !*** ./ts/state/subject.function.ts ***!
1725
- \**************************************/
1726
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1727
-
1728
- __webpack_require__.r(__webpack_exports__);
1729
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1730
- /* harmony export */ subject: () => (/* binding */ subject)
1731
- /* harmony export */ });
1732
- /* harmony import */ var _subject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../subject */ "./ts/subject/index.ts");
1733
- /* harmony import */ var _tag_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../tag/getSupportInCycle.function */ "./ts/tag/getSupportInCycle.function.ts");
1734
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1735
- /* harmony import */ var _state_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./state.function */ "./ts/state/state.function.ts");
1736
- /* harmony import */ var _syncStates_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./syncStates.function */ "./ts/state/syncStates.function.ts");
1737
-
1738
-
1739
-
1740
-
1741
-
1742
- function subject(value, onSubscription) {
1743
- const oldestState = (0,_state_function__WEBPACK_IMPORTED_MODULE_3__.state)(() => _setUse_function__WEBPACK_IMPORTED_MODULE_2__.setUse.memory.stateConfig.array);
1744
- const nowTagSupport = (0,_tag_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_1__.getSupportInCycle)();
1745
- return new _subject__WEBPACK_IMPORTED_MODULE_0__.Subject(value, onSubscription).pipe(x => {
1746
- (0,_syncStates_function__WEBPACK_IMPORTED_MODULE_4__.syncStates)(nowTagSupport.memory.state, oldestState);
1747
- return x;
1748
- });
1749
- }
1750
- function all(args) {
1751
- const oldestState = (0,_state_function__WEBPACK_IMPORTED_MODULE_3__.state)(() => _setUse_function__WEBPACK_IMPORTED_MODULE_2__.setUse.memory.stateConfig.array);
1752
- const nowTagSupport = (0,_tag_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_1__.getSupportInCycle)();
1753
- return _subject__WEBPACK_IMPORTED_MODULE_0__.Subject.all(args).pipe(x => {
1754
- (0,_syncStates_function__WEBPACK_IMPORTED_MODULE_4__.syncStates)(nowTagSupport.memory.state, oldestState);
1755
- return x;
1756
- });
1757
- }
1758
- subject.all = all;
1759
-
1760
-
1761
- /***/ }),
1762
-
1763
- /***/ "./ts/state/syncStates.function.ts":
1764
- /*!*****************************************!*\
1765
- !*** ./ts/state/syncStates.function.ts ***!
1766
- \*****************************************/
1767
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1768
-
1769
- __webpack_require__.r(__webpack_exports__);
1770
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1771
- /* harmony export */ syncStates: () => (/* binding */ syncStates)
1772
- /* harmony export */ });
1773
- function syncStates(stateFrom, stateTo) {
1774
- for (let index = stateFrom.length - 1; index >= 0; --index) {
1775
- const state = stateFrom[index];
1776
- const fromValue = state.get();
1777
- const callback = stateTo[index].callback;
1778
- if (callback) {
1779
- callback(fromValue); // set the value
1780
- }
1781
- stateTo[index].lastValue = fromValue; // record the value
1782
- }
1783
- }
1784
-
1785
-
1786
- /***/ }),
1787
-
1788
- /***/ "./ts/state/watch.function.ts":
1789
- /*!************************************!*\
1790
- !*** ./ts/state/watch.function.ts ***!
1791
- \************************************/
1792
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1793
-
1794
- __webpack_require__.r(__webpack_exports__);
1795
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1796
- /* harmony export */ watch: () => (/* binding */ watch)
1797
- /* harmony export */ });
1798
- /* harmony import */ var _subject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../subject */ "./ts/subject/index.ts");
1799
- /* harmony import */ var _tag_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../tag/getSupportInCycle.function */ "./ts/tag/getSupportInCycle.function.ts");
1800
- /* harmony import */ var _setUse_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./setUse.function */ "./ts/state/setUse.function.ts");
1801
- /* harmony import */ var _state_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./state.function */ "./ts/state/state.function.ts");
1802
- /* harmony import */ var _syncStates_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./syncStates.function */ "./ts/state/syncStates.function.ts");
1803
-
1804
-
1805
-
1806
-
1807
-
1808
- /**
1809
- * When an item in watch array changes, callback function will be triggered. Triggers on initial watch setup. TIP: try watch.noInit()
1810
- * @param currentValues T[]
1811
- * @param callback WatchCallback
1812
- * @returns T[]
1813
- */
1814
- const watch = ((currentValues, callback) => {
1815
- return setupWatch(currentValues, callback);
1816
- });
1817
- const defaultFinally = (x) => x;
1818
- function newWatch(setup) {
1819
- const method = (currentValues, callback) => {
1820
- return setupWatch(currentValues, callback, setup);
1821
- };
1822
- method.setup = setup;
1823
- defineOnMethod(() => method, method);
1824
- return method;
1825
- }
1826
- /**
1827
- * puts above functionality together
1828
- * @param currentValues values being watched
1829
- * @param callback (currentValue, previousValues) => resolveToValue
1830
- * @param param2
1831
- * @returns
1832
- */
1833
- const setupWatch = (currentValues, callback, { init, before = () => true, final = defaultFinally, } = {}) => {
1834
- let previous = (0,_state_function__WEBPACK_IMPORTED_MODULE_3__.state)({
1835
- pastResult: undefined,
1836
- values: undefined,
1837
- });
1838
- const previousValues = previous.values;
1839
- // First time running watch?
1840
- if (previousValues === undefined) {
1841
- if (!before(currentValues)) {
1842
- previous.values = currentValues;
1843
- return previous.pastResult; // do not continue
1844
- }
1845
- const castedInit = init || callback;
1846
- const result = castedInit(currentValues, previousValues);
1847
- previous.pastResult = final(result);
1848
- previous.values = currentValues;
1849
- return previous.pastResult;
1850
- }
1851
- const allExact = currentValues.every((item, index) => item === previousValues[index]);
1852
- if (allExact) {
1853
- return previous.pastResult;
1854
- }
1855
- if (!before(currentValues)) {
1856
- previous.values = currentValues;
1857
- return previous.pastResult; // do not continue
1858
- }
1859
- const result = callback(currentValues, previousValues);
1860
- previous.pastResult = final(result);
1861
- previousValues.length = 0;
1862
- previousValues.push(...currentValues);
1863
- return previous.pastResult;
1864
- };
1865
- function defineOnMethod(getWatch, attachTo) {
1866
- Object.defineProperty(attachTo, 'noInit', {
1867
- get() {
1868
- const watch = getWatch();
1869
- watch.setup.init = () => undefined;
1870
- return watch;
1871
- },
1872
- });
1873
- Object.defineProperty(attachTo, 'asSubject', {
1874
- get() {
1875
- const oldWatch = getWatch();
1876
- const method = (currentValues, callback) => {
1877
- const originalState = (0,_state_function__WEBPACK_IMPORTED_MODULE_3__.state)(() => (0,_tag_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_1__.getSupportInCycle)().memory.state);
1878
- const subject = (0,_state_function__WEBPACK_IMPORTED_MODULE_3__.state)(() => new _subject__WEBPACK_IMPORTED_MODULE_0__.ValueSubject(undefined));
1879
- setupWatch(currentValues, (currentValues, previousValues) => {
1880
- const setTo = callback(currentValues, previousValues);
1881
- if (originalState.length) {
1882
- const newestState = _setUse_function__WEBPACK_IMPORTED_MODULE_2__.setUse.memory.stateConfig.array;
1883
- (0,_syncStates_function__WEBPACK_IMPORTED_MODULE_4__.syncStates)(newestState, originalState);
1884
- }
1885
- subject.set(setTo);
1886
- }, oldWatch.setup);
1887
- return subject;
1888
- };
1889
- method.setup = oldWatch.setup;
1890
- defineOnMethod(() => method, method);
1891
- return method;
1892
- /*
1893
- method.setup = setup
1894
-
1895
- defineOnMethod(() => method as any, method)
1896
-
1897
- return method as any
1898
-
1899
-
1900
- const oldWatch = getWatch()
1901
- const watch = newWatch( oldWatch.setup )
1902
- // const watch = getWatch()
1903
-
1904
- const subject = state(() => new Subject())
1905
- watch.setup.final = (x: any) => {
1906
- subject.set(x)
1907
- return subject
1908
- }
1909
- return watch
1910
- */
1911
- },
1912
- });
1913
- Object.defineProperty(attachTo, 'truthy', {
1914
- get() {
1915
- const watch = getWatch();
1916
- watch.setup.before = (currentValues) => currentValues.every(x => x);
1917
- return watch;
1918
- },
1919
- });
1920
- return attachTo;
1921
- }
1922
- defineOnMethod(() => newWatch({}), watch);
1923
-
1924
-
1925
- /***/ }),
1926
-
1927
- /***/ "./ts/subject/Subject.class.ts":
1928
- /*!*************************************!*\
1929
- !*** ./ts/subject/Subject.class.ts ***!
1930
- \*************************************/
1931
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1932
-
1933
- __webpack_require__.r(__webpack_exports__);
1934
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1935
- /* harmony export */ Subject: () => (/* binding */ Subject)
1936
- /* harmony export */ });
1937
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../isInstance */ "./ts/isInstance.ts");
1938
- /* harmony import */ var _combineLatest_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./combineLatest.function */ "./ts/subject/combineLatest.function.ts");
1939
- /* harmony import */ var _subject_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./subject.utils */ "./ts/subject/subject.utils.ts");
1940
-
1941
-
1942
-
1943
- class Subject {
1944
- value;
1945
- onSubscription;
1946
- methods = [];
1947
- isSubject = true;
1948
- subscribers = [];
1949
- subscribeWith;
1950
- // unsubcount = 0 // 🔬 testing
1951
- constructor(value, onSubscription) {
1952
- this.value = value;
1953
- this.onSubscription = onSubscription;
1954
- }
1955
- subscribe(callback) {
1956
- const subscription = (0,_subject_utils__WEBPACK_IMPORTED_MODULE_2__.getSubscription)(this, callback);
1957
- // are we within a pipe?
1958
- const subscribeWith = this.subscribeWith;
1959
- if (subscribeWith) {
1960
- // are we in a pipe?
1961
- if (this.methods.length) {
1962
- const orgCallback = callback;
1963
- callback = (value) => {
1964
- (0,_subject_utils__WEBPACK_IMPORTED_MODULE_2__.runPipedMethods)(value, this.methods, lastValue => orgCallback(lastValue, subscription));
1965
- };
1966
- }
1967
- return subscribeWith(callback);
1968
- }
1969
- this.subscribers.push(subscription);
1970
- // Subject.globalSubs.push(subscription) // 🔬 testing
1971
- const count = Subject.globalSubCount$.value;
1972
- Subject.globalSubCount$.set(count + 1); // 🔬 testing
1973
- if (this.onSubscription) {
1974
- this.onSubscription(subscription);
1975
- }
1976
- return subscription;
1977
- }
1978
- set(value) {
1979
- this.value = value;
1980
- // Notify all subscribers with the new value
1981
- const subs = [...this.subscribers]; // subs may change as we call callbacks
1982
- const length = subs.length;
1983
- for (let index = 0; index < length; ++index) {
1984
- const sub = subs[index];
1985
- sub.callback(value, sub);
1986
- }
1987
- }
1988
- // next() is available for rxjs compatibility
1989
- next = this.set;
1990
- toPromise() {
1991
- return new Promise(res => {
1992
- this.subscribe((x, subscription) => {
1993
- subscription.unsubscribe();
1994
- res(x);
1995
- });
1996
- });
1997
- }
1998
- /** like toPromise but faster */
1999
- toCallback(callback) {
2000
- this.subscribe((x, subscription) => {
2001
- subscription.unsubscribe();
2002
- callback(x);
2003
- });
2004
- return this;
2005
- }
2006
- pipe(...operations) {
2007
- const subject = new Subject();
2008
- subject.methods = operations;
2009
- subject.subscribeWith = (x) => this.subscribe(x);
2010
- return subject;
2011
- }
2012
- static all(args) {
2013
- const switched = args.map(arg => {
2014
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isSubjectInstance)(arg))
2015
- return arg;
2016
- // Call the callback immediately with the current value
2017
- const x = new Subject(arg, subscription => {
2018
- subscription.next(arg);
2019
- return subscription;
2020
- });
2021
- return x;
2022
- });
2023
- return (0,_combineLatest_function__WEBPACK_IMPORTED_MODULE_1__.combineLatest)(switched);
2024
- }
2025
- static globalSubCount$ = new Subject(0); // for ease of debugging
2026
- }
2027
-
2028
-
2029
- /***/ }),
2030
-
2031
- /***/ "./ts/subject/ValueSubject.ts":
2032
- /*!************************************!*\
2033
- !*** ./ts/subject/ValueSubject.ts ***!
2034
- \************************************/
2035
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2036
-
2037
- __webpack_require__.r(__webpack_exports__);
2038
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2039
- /* harmony export */ ValueSubject: () => (/* binding */ ValueSubject)
2040
- /* harmony export */ });
2041
- /* harmony import */ var _Subject_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Subject.class */ "./ts/subject/Subject.class.ts");
2042
-
2043
- class ValueSubject extends _Subject_class__WEBPACK_IMPORTED_MODULE_0__.Subject {
2044
- value;
2045
- constructor(value) {
2046
- super(value);
2047
- this.value = value;
2048
- }
2049
- subscribe(callback) {
2050
- const subscription = super.subscribe(callback);
2051
- // Call the callback immediately with the current value
2052
- callback(this.value, subscription);
2053
- return subscription;
2054
- }
2055
- }
2056
-
2057
-
2058
- /***/ }),
2059
-
2060
- /***/ "./ts/subject/combineLatest.function.ts":
2061
- /*!**********************************************!*\
2062
- !*** ./ts/subject/combineLatest.function.ts ***!
2063
- \**********************************************/
2064
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2065
-
2066
- __webpack_require__.r(__webpack_exports__);
2067
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2068
- /* harmony export */ combineLatest: () => (/* binding */ combineLatest)
2069
- /* harmony export */ });
2070
- /* harmony import */ var _Subject_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Subject.class */ "./ts/subject/Subject.class.ts");
2071
-
2072
- function combineLatest(subjects) {
2073
- const output = new _Subject_class__WEBPACK_IMPORTED_MODULE_0__.Subject();
2074
- const subscribe = (callback) => {
2075
- const valuesSeen = [];
2076
- const values = [];
2077
- const setValue = (x, index) => {
2078
- valuesSeen[index] = true;
2079
- values[index] = x;
2080
- const countMatched = valuesSeen.length === subjects.length;
2081
- if (!countMatched) {
2082
- return;
2083
- }
2084
- for (let index = valuesSeen.length - 1; index >= 0; --index) {
2085
- if (!valuesSeen[index]) {
2086
- return;
2087
- }
2088
- }
2089
- // everyone has reported values
2090
- callback(values, subscription);
2091
- };
2092
- const clones = [...subjects];
2093
- const firstSub = clones.shift();
2094
- const subscription = firstSub.subscribe(x => setValue(x, 0));
2095
- const subscriptions = clones.map((subject, index) => subject.subscribe(x => setValue(x, index + 1)));
2096
- subscription.subscriptions = subscriptions;
2097
- return subscription;
2098
- };
2099
- output.subscribeWith = subscribe;
2100
- return output;
2101
- }
2102
-
2103
-
2104
- /***/ }),
2105
-
2106
- /***/ "./ts/subject/index.ts":
2107
- /*!*****************************!*\
2108
- !*** ./ts/subject/index.ts ***!
2109
- \*****************************/
2110
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2111
-
2112
- __webpack_require__.r(__webpack_exports__);
2113
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2114
- /* harmony export */ Subject: () => (/* reexport safe */ _Subject_class__WEBPACK_IMPORTED_MODULE_0__.Subject),
2115
- /* harmony export */ ValueSubject: () => (/* reexport safe */ _ValueSubject__WEBPACK_IMPORTED_MODULE_1__.ValueSubject),
2116
- /* harmony export */ combineLatest: () => (/* reexport safe */ _combineLatest_function__WEBPACK_IMPORTED_MODULE_2__.combineLatest),
2117
- /* harmony export */ willCallback: () => (/* reexport safe */ _will_functions__WEBPACK_IMPORTED_MODULE_3__.willCallback),
2118
- /* harmony export */ willPromise: () => (/* reexport safe */ _will_functions__WEBPACK_IMPORTED_MODULE_3__.willPromise),
2119
- /* harmony export */ willSubscribe: () => (/* reexport safe */ _will_functions__WEBPACK_IMPORTED_MODULE_3__.willSubscribe)
2120
- /* harmony export */ });
2121
- /* harmony import */ var _Subject_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Subject.class */ "./ts/subject/Subject.class.ts");
2122
- /* harmony import */ var _ValueSubject__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ValueSubject */ "./ts/subject/ValueSubject.ts");
2123
- /* harmony import */ var _combineLatest_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./combineLatest.function */ "./ts/subject/combineLatest.function.ts");
2124
- /* harmony import */ var _will_functions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./will.functions */ "./ts/subject/will.functions.ts");
2125
-
2126
-
2127
-
2128
-
2129
-
2130
-
2131
- /***/ }),
2132
-
2133
- /***/ "./ts/subject/subject.utils.ts":
2134
- /*!*************************************!*\
2135
- !*** ./ts/subject/subject.utils.ts ***!
2136
- \*************************************/
2137
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2138
-
2139
- __webpack_require__.r(__webpack_exports__);
2140
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2141
- /* harmony export */ getSubscription: () => (/* binding */ getSubscription),
2142
- /* harmony export */ runPipedMethods: () => (/* binding */ runPipedMethods)
2143
- /* harmony export */ });
2144
- /* harmony import */ var _Subject_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Subject.class */ "./ts/subject/Subject.class.ts");
2145
-
2146
- function removeSubFromArray(subscribers, callback) {
2147
- const index = subscribers.findIndex(sub => sub.callback === callback);
2148
- if (index !== -1) {
2149
- subscribers.splice(index, 1);
2150
- }
2151
- }
2152
- function getSubscription(subject, callback) {
2153
- const countSubject = _Subject_class__WEBPACK_IMPORTED_MODULE_0__.Subject.globalSubCount$;
2154
- _Subject_class__WEBPACK_IMPORTED_MODULE_0__.Subject.globalSubCount$.set(countSubject.value + 1);
2155
- const subscription = () => {
2156
- subscription.unsubscribe();
2157
- };
2158
- subscription.callback = callback;
2159
- subscription.subscriptions = [];
2160
- // Return a function to unsubscribe from the BehaviorSubject
2161
- subscription.unsubscribe = () => {
2162
- removeSubFromArray(subject.subscribers, callback); // each will be called when update comes in
2163
- // removeSubFromArray(Subject.globalSubs, callback) // 🔬 testing
2164
- _Subject_class__WEBPACK_IMPORTED_MODULE_0__.Subject.globalSubCount$.set(countSubject.value - 1);
2165
- // any double unsubscribes will be ignored
2166
- subscription.unsubscribe = () => subscription;
2167
- // unsubscribe from any combined subjects
2168
- const subscriptions = subscription.subscriptions;
2169
- for (let index = subscriptions.length - 1; index >= 0; --index) {
2170
- subscriptions[index].unsubscribe();
2171
- }
2172
- return subscription;
2173
- };
2174
- subscription.add = (sub) => {
2175
- subscription.subscriptions.push(sub);
2176
- return subscription;
2177
- };
2178
- subscription.next = (value) => {
2179
- callback(value, subscription);
2180
- };
2181
- return subscription;
2182
- }
2183
- function runPipedMethods(value, methods, onComplete) {
2184
- const cloneMethods = [...methods];
2185
- const firstMethod = cloneMethods.shift();
2186
- const next = (newValue) => {
2187
- if (cloneMethods.length) {
2188
- return runPipedMethods(newValue, cloneMethods, onComplete);
2189
- }
2190
- onComplete(newValue);
2191
- };
2192
- let handler = next;
2193
- const setHandler = (x) => handler = x;
2194
- const pipeUtils = { setHandler, next };
2195
- const methodResponse = firstMethod(value, pipeUtils);
2196
- handler(methodResponse);
2197
- }
2198
-
2199
-
2200
- /***/ }),
2201
-
2202
- /***/ "./ts/subject/will.functions.ts":
2203
- /*!**************************************!*\
2204
- !*** ./ts/subject/will.functions.ts ***!
2205
- \**************************************/
2206
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2207
-
2208
- __webpack_require__.r(__webpack_exports__);
2209
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2210
- /* harmony export */ willCallback: () => (/* binding */ willCallback),
2211
- /* harmony export */ willPromise: () => (/* binding */ willPromise),
2212
- /* harmony export */ willSubscribe: () => (/* binding */ willSubscribe)
2213
- /* harmony export */ });
2214
- function willCallback(callback) {
2215
- return ((lastValue, utils) => {
2216
- utils.setHandler(() => {
2217
- return undefined;
2218
- });
2219
- callback(lastValue, utils.next);
2220
- });
2221
- }
2222
- /** .pipe( promise((x) => Promise.resolve(44)) ) */
2223
- function willPromise(callback) {
2224
- return ((lastValue, utils) => {
2225
- utils.setHandler(() => {
2226
- return undefined;
2227
- }); // do nothing on initial return
2228
- const result = callback(lastValue);
2229
- result.then(x => utils.next(x));
2230
- });
2231
- }
2232
- /** .pipe( willSubscribe((x) => new ValueSubject(44)) ) */
2233
- const willSubscribe = (callback) => {
2234
- return ((lastValue, utils) => {
2235
- utils.setHandler(() => {
2236
- return undefined;
2237
- }); // do nothing on initial return
2238
- const result = callback(lastValue);
2239
- const subscription = result.subscribe(x => {
2240
- subscription.unsubscribe();
2241
- utils.next(x);
2242
- });
2243
- });
2244
- };
2245
-
2246
-
2247
- /***/ }),
2248
-
2249
- /***/ "./ts/tag/Tag.class.ts":
2250
- /*!*****************************!*\
2251
- !*** ./ts/tag/Tag.class.ts ***!
2252
- \*****************************/
2253
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2254
-
2255
- __webpack_require__.r(__webpack_exports__);
2256
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2257
- /* harmony export */ Tag: () => (/* binding */ Tag),
2258
- /* harmony export */ escapeSearch: () => (/* binding */ escapeSearch),
2259
- /* harmony export */ escapeVariable: () => (/* binding */ escapeVariable),
2260
- /* harmony export */ variablePrefix: () => (/* binding */ variablePrefix)
2261
- /* harmony export */ });
2262
- const variablePrefix = '__tagvar';
2263
- const escapeVariable = '--' + variablePrefix + '--';
2264
- const escapeSearch = new RegExp(escapeVariable, 'g');
2265
- class Tag {
2266
- strings;
2267
- values;
2268
- isTagClass = true;
2269
- // present only when an array. Populated by Tag.key()
2270
- memory = {};
2271
- templater;
2272
- constructor(strings, values) {
2273
- this.strings = strings;
2274
- this.values = values;
2275
- }
2276
- /** Used for array, such as array.map(), calls aka array.map(x => html``.key(x)) */
2277
- key(arrayValue) {
2278
- this.memory.arrayValue = arrayValue;
2279
- return this;
2280
- }
2281
- // TODO: Is this just a fake function that can be data typed?
2282
- children;
2283
- html(strings, ...values) {
2284
- this.children = { strings, values };
2285
- return this;
2286
- }
2287
- }
2288
-
2289
-
2290
- /***/ }),
2291
-
2292
- /***/ "./ts/tag/TagSupport.class.ts":
2293
- /*!************************************!*\
2294
- !*** ./ts/tag/TagSupport.class.ts ***!
2295
- \************************************/
2296
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2297
-
2298
- __webpack_require__.r(__webpack_exports__);
2299
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2300
- /* harmony export */ BaseTagSupport: () => (/* binding */ BaseTagSupport),
2301
- /* harmony export */ TagSupport: () => (/* binding */ TagSupport)
2302
- /* harmony export */ });
2303
- /* harmony import */ var _Tag_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Tag.class */ "./ts/tag/Tag.class.ts");
2304
- /* harmony import */ var _deepFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../deepFunctions */ "./ts/deepFunctions.ts");
2305
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../isInstance */ "./ts/isInstance.ts");
2306
- /* harmony import */ var _cloneValueArray_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./cloneValueArray.function */ "./ts/tag/cloneValueArray.function.ts");
2307
- /* harmony import */ var _checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./checkDestroyPrevious.function */ "./ts/tag/checkDestroyPrevious.function.ts");
2308
- /* harmony import */ var _tagRunner__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tagRunner */ "./ts/tag/tagRunner.ts");
2309
- /* harmony import */ var _destroy_support__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./destroy.support */ "./ts/tag/destroy.support.ts");
2310
- /* harmony import */ var _elementDestroyCheck_function__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./elementDestroyCheck.function */ "./ts/tag/elementDestroyCheck.function.ts");
2311
- /* harmony import */ var _update_updateContextItem_function__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./update/updateContextItem.function */ "./ts/tag/update/updateContextItem.function.ts");
2312
- /* harmony import */ var _update_processNewValue_function__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./update/processNewValue.function */ "./ts/tag/update/processNewValue.function.ts");
2313
- /* harmony import */ var _setTagPlaceholder_function__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./setTagPlaceholder.function */ "./ts/tag/setTagPlaceholder.function.ts");
2314
- /* harmony import */ var _interpolations_interpolateElement__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../interpolations/interpolateElement */ "./ts/interpolations/interpolateElement.ts");
2315
- /* harmony import */ var _interpolations_interpolateTemplate__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../interpolations/interpolateTemplate */ "./ts/interpolations/interpolateTemplate.ts");
2316
- /* harmony import */ var _interpolations_afterInterpolateElement_function__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../interpolations/afterInterpolateElement.function */ "./ts/interpolations/afterInterpolateElement.function.ts");
2317
-
2318
-
2319
-
2320
-
2321
-
2322
-
2323
-
2324
-
2325
-
2326
-
2327
-
2328
-
2329
-
2330
-
2331
- const prefixSearch = new RegExp(_Tag_class__WEBPACK_IMPORTED_MODULE_0__.variablePrefix, 'g');
2332
- /** used only for apps, otherwise use TagSupport */
2333
- class BaseTagSupport {
2334
- templater;
2335
- subject;
2336
- isApp = true;
2337
- appElement; // only seen on this.getAppTagSupport().appElement
2338
- strings;
2339
- values;
2340
- propsConfig;
2341
- // stays with current render
2342
- memory = {
2343
- state: [],
2344
- };
2345
- clones = []; // elements on document. Needed at destroy process to know what to destroy
2346
- // travels with all rerenderings
2347
- global = {
2348
- context: {}, // populated after reading interpolated.values array converted to an object {variable0, variable:1}
2349
- providers: [],
2350
- /** Indicator of re-rending. Saves from double rending something already rendered */
2351
- renderCount: 0,
2352
- deleted: false,
2353
- subscriptions: [],
2354
- };
2355
- hasLiveElements = false;
2356
- constructor(templater, subject) {
2357
- this.templater = templater;
2358
- this.subject = subject;
2359
- const children = templater.children; // children tags passed in as arguments
2360
- const kidValue = children.value;
2361
- const props = templater.props; // natural props
2362
- const latestCloned = props.map(props => (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_1__.deepClone)(props));
2363
- this.propsConfig = {
2364
- latest: props,
2365
- latestCloned, // assume its HTML children and then detect
2366
- lastClonedKidValues: kidValue.map(kid => {
2367
- const cloneValues = (0,_cloneValueArray_function__WEBPACK_IMPORTED_MODULE_3__.cloneValueArray)(kid.values);
2368
- return cloneValues;
2369
- })
2370
- };
2371
- }
2372
- /** Function that kicks off actually putting tags down as HTML elements */
2373
- buildBeforeElement(insertBefore, options = {
2374
- counts: { added: 0, removed: 0 },
2375
- }) {
2376
- const subject = this.subject;
2377
- const global = this.global;
2378
- global.insertBefore = insertBefore;
2379
- if (!global.placeholder) {
2380
- (0,_setTagPlaceholder_function__WEBPACK_IMPORTED_MODULE_10__.setTagPlaceholder)(global);
2381
- }
2382
- const placeholderElm = global.placeholder;
2383
- global.oldest = this;
2384
- global.newest = this;
2385
- subject.tagSupport = this;
2386
- this.hasLiveElements = true;
2387
- const context = this.update();
2388
- const template = this.getTemplate();
2389
- const elementContainer = document.createDocumentFragment();
2390
- const tempDraw = document.createElement('template');
2391
- tempDraw.innerHTML = template.string;
2392
- elementContainer.appendChild(tempDraw);
2393
- // Search/replace innerHTML variables but don't interpolate tag components just yet
2394
- const { tagComponents } = (0,_interpolations_interpolateElement__WEBPACK_IMPORTED_MODULE_11__.interpolateElement)(elementContainer, context, template, this, // ownerSupport,
2395
- {
2396
- counts: options.counts
2397
- });
2398
- (0,_interpolations_afterInterpolateElement_function__WEBPACK_IMPORTED_MODULE_13__.afterInterpolateElement)(elementContainer, placeholderElm, this, // ownerSupport
2399
- context, options);
2400
- // Any tag components that were found should be processed AFTER the owner processes its elements. Avoid double processing of elements attributes like (oninit)=${}
2401
- const length = tagComponents.length;
2402
- for (let index = 0; index < length; ++index) {
2403
- const tagComponent = tagComponents[index];
2404
- (0,_interpolations_interpolateTemplate__WEBPACK_IMPORTED_MODULE_12__.subscribeToTemplate)(tagComponent.insertBefore, tagComponent.subject, tagComponent.ownerSupport, options.counts);
2405
- (0,_interpolations_afterInterpolateElement_function__WEBPACK_IMPORTED_MODULE_13__.afterInterpolateElement)(elementContainer, tagComponent.insertBefore, tagComponent.ownerSupport, context, options);
2406
- }
2407
- }
2408
- getTemplate() {
2409
- const thisTag = this.templater.tag;
2410
- const strings = this.strings || thisTag.strings;
2411
- const values = this.values || thisTag.values;
2412
- const string = strings.map((string, index) => {
2413
- const safeString = string.replace(prefixSearch, _Tag_class__WEBPACK_IMPORTED_MODULE_0__.escapeVariable);
2414
- const endString = safeString + (values.length > index ? `{${_Tag_class__WEBPACK_IMPORTED_MODULE_0__.variablePrefix}${index}}` : '');
2415
- const trimString = endString.replace(/>\s*/g, '>').replace(/\s*</g, '<');
2416
- return trimString;
2417
- }).join('');
2418
- const interpolation = (0,_interpolations_interpolateElement__WEBPACK_IMPORTED_MODULE_11__.interpolateString)(string);
2419
- return {
2420
- interpolation,
2421
- string: interpolation.string,
2422
- strings,
2423
- values,
2424
- context: this.global.context || {},
2425
- };
2426
- }
2427
- update() {
2428
- return this.updateContext(this.global.context);
2429
- }
2430
- updateContext(context) {
2431
- const thisTag = this.templater.tag;
2432
- const strings = this.strings || thisTag.strings;
2433
- const values = this.values || thisTag.values;
2434
- strings.map((_string, index) => {
2435
- const hasValue = values.length > index;
2436
- if (!hasValue) {
2437
- return;
2438
- }
2439
- const variableName = _Tag_class__WEBPACK_IMPORTED_MODULE_0__.variablePrefix + index;
2440
- const value = values[index];
2441
- // is something already there?
2442
- const exists = variableName in context;
2443
- if (exists) {
2444
- return (0,_update_updateContextItem_function__WEBPACK_IMPORTED_MODULE_8__.updateContextItem)(context, variableName, value);
2445
- }
2446
- // 🆕 First time values below
2447
- context[variableName] = (0,_update_processNewValue_function__WEBPACK_IMPORTED_MODULE_9__.processNewValue)(value, this);
2448
- });
2449
- return context;
2450
- }
2451
- }
2452
- class TagSupport extends BaseTagSupport {
2453
- templater;
2454
- ownerTagSupport;
2455
- subject;
2456
- version;
2457
- isApp = false;
2458
- childTags = []; // tags on me
2459
- constructor(templater, // at runtime rendering of a tag, it needs to be married to a new TagSupport()
2460
- ownerTagSupport, subject, version = 0) {
2461
- super(templater, subject);
2462
- this.templater = templater;
2463
- this.ownerTagSupport = ownerTagSupport;
2464
- this.subject = subject;
2465
- this.version = version;
2466
- }
2467
- destroy(options = {
2468
- stagger: 0,
2469
- byParent: false, // Only destroy clones of direct children
2470
- }) {
2471
- const firstDestroy = !options.byParent;
2472
- const global = this.global;
2473
- const subject = this.subject;
2474
- const childTags = options.byParent ? [] : (0,_destroy_support__WEBPACK_IMPORTED_MODULE_6__.getChildTagsToDestroy)(this.childTags);
2475
- if (firstDestroy && (0,_isInstance__WEBPACK_IMPORTED_MODULE_2__.isTagComponent)(this.templater)) {
2476
- (0,_tagRunner__WEBPACK_IMPORTED_MODULE_5__.runBeforeDestroy)(this, this);
2477
- }
2478
- this.destroySubscriptions();
2479
- // signify immediately child has been deleted (looked for during event processing)
2480
- for (let index = childTags.length - 1; index >= 0; --index) {
2481
- const child = childTags[index];
2482
- const subGlobal = child.global;
2483
- delete subGlobal.newest;
2484
- subGlobal.deleted = true;
2485
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_2__.isTagComponent)(child.templater)) {
2486
- (0,_tagRunner__WEBPACK_IMPORTED_MODULE_5__.runBeforeDestroy)(child, child);
2487
- }
2488
- }
2489
- // HTML DOM manipulation. Put back down the template tag
2490
- const insertBefore = global.insertBefore;
2491
- if (insertBefore.nodeName === 'TEMPLATE') {
2492
- const placeholder = global.placeholder;
2493
- if (placeholder && !('arrayValue' in this.memory)) {
2494
- if (!options.byParent) {
2495
- (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_4__.restoreTagMarker)(this);
2496
- }
2497
- }
2498
- }
2499
- let mainPromise;
2500
- if (this.ownerTagSupport) {
2501
- this.ownerTagSupport.childTags = this.ownerTagSupport.childTags.filter(child => child !== this);
2502
- }
2503
- if (firstDestroy) {
2504
- const { stagger, promise } = this.destroyClones(options);
2505
- options.stagger = stagger;
2506
- if (promise) {
2507
- mainPromise = promise;
2508
- }
2509
- }
2510
- else {
2511
- this.destroyClones();
2512
- }
2513
- // data reset
2514
- delete global.placeholder;
2515
- global.context = {};
2516
- delete global.oldest;
2517
- delete global.newest;
2518
- global.deleted = true;
2519
- this.childTags.length = 0;
2520
- this.hasLiveElements = false;
2521
- delete subject.tagSupport;
2522
- if (mainPromise) {
2523
- mainPromise = mainPromise.then(async () => {
2524
- const promises = childTags.map(kid => kid.destroy({ stagger: 0, byParent: true }));
2525
- return Promise.all(promises);
2526
- });
2527
- }
2528
- else {
2529
- mainPromise = Promise.all(childTags.map(kid => kid.destroy({ stagger: 0, byParent: true })));
2530
- }
2531
- return mainPromise.then(() => options.stagger);
2532
- }
2533
- destroySubscriptions() {
2534
- const subs = this.global.subscriptions;
2535
- for (let index = subs.length - 1; index >= 0; --index) {
2536
- subs[index].unsubscribe();
2537
- }
2538
- subs.length = 0;
2539
- }
2540
- destroyClones({ stagger } = {
2541
- stagger: 0,
2542
- }) {
2543
- const oldClones = [...this.clones];
2544
- this.clones.length = 0; // tag maybe used for something else
2545
- const promises = oldClones.map(clone => this.checkCloneRemoval(clone, stagger)).filter(x => x); // only return promises
2546
- // check subjects that may have clones attached to them
2547
- const oldContext = this.global.context;
2548
- for (const name in oldContext) {
2549
- const value = oldContext[name];
2550
- const clone = value.clone;
2551
- if (clone?.parentNode) {
2552
- clone.parentNode.removeChild(clone);
2553
- }
2554
- }
2555
- if (promises.length) {
2556
- return { promise: Promise.all(promises), stagger };
2557
- }
2558
- return { stagger };
2559
- }
2560
- /** Reviews elements for the presences of ondestroy */
2561
- checkCloneRemoval(clone, stagger) {
2562
- let promise;
2563
- const customElm = clone;
2564
- if (customElm.ondestroy) {
2565
- promise = (0,_elementDestroyCheck_function__WEBPACK_IMPORTED_MODULE_7__.elementDestroyCheck)(customElm, stagger);
2566
- }
2567
- const next = () => {
2568
- const parentNode = clone.parentNode;
2569
- if (parentNode) {
2570
- parentNode.removeChild(clone);
2571
- }
2572
- const ownerSupport = this.ownerTagSupport;
2573
- if (ownerSupport) {
2574
- // Sometimes my clones were first registered to my owner, remove them from owner
2575
- ownerSupport.clones = ownerSupport.clones.filter(compareClone => compareClone !== clone);
2576
- }
2577
- };
2578
- if (promise instanceof Promise) {
2579
- return promise.then(next);
2580
- }
2581
- else {
2582
- next();
2583
- }
2584
- return promise;
2585
- }
2586
- updateBy(tagSupport) {
2587
- const tempTag = tagSupport.templater.tag;
2588
- this.updateConfig(tempTag.strings, tempTag.values);
2589
- }
2590
- updateConfig(strings, values) {
2591
- this.strings = strings;
2592
- this.updateValues(values);
2593
- }
2594
- updateValues(values) {
2595
- this.values = values;
2596
- return this.updateContext(this.global.context);
2597
- }
2598
- getAppTagSupport() {
2599
- let tag = this;
2600
- while (tag.ownerTagSupport) {
2601
- tag = tag.ownerTagSupport;
2602
- }
2603
- return tag;
2604
- }
2605
- }
2606
- function restoreTagMarkers(support) {
2607
- (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_4__.restoreTagMarker)(support);
2608
- const childTags = support.childTags;
2609
- for (let index = childTags.length - 1; index >= 0; --index) {
2610
- restoreTagMarkers(childTags[index].global.oldest);
2611
- }
2612
- }
2613
-
2614
-
2615
- /***/ }),
2616
-
2617
- /***/ "./ts/tag/checkDestroyPrevious.function.ts":
2618
- /*!*************************************************!*\
2619
- !*** ./ts/tag/checkDestroyPrevious.function.ts ***!
2620
- \*************************************************/
2621
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2622
-
2623
- __webpack_require__.r(__webpack_exports__);
2624
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2625
- /* harmony export */ checkDestroyPrevious: () => (/* binding */ checkDestroyPrevious),
2626
- /* harmony export */ destroyArrayTag: () => (/* binding */ destroyArrayTag),
2627
- /* harmony export */ isSimpleType: () => (/* binding */ isSimpleType),
2628
- /* harmony export */ restoreTagMarker: () => (/* binding */ restoreTagMarker)
2629
- /* harmony export */ });
2630
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../isInstance */ "./ts/isInstance.ts");
2631
- /* harmony import */ var _isLikeTags_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./isLikeTags.function */ "./ts/tag/isLikeTags.function.ts");
2632
- /* harmony import */ var _destroyTag_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./destroyTag.function */ "./ts/tag/destroyTag.function.ts");
2633
- /* harmony import */ var _insertAfter_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../insertAfter.function */ "./ts/insertAfter.function.ts");
2634
-
2635
-
2636
-
2637
-
2638
- function checkDestroyPrevious(subject, // existing.value is the old value
2639
- newValue, insertBefore) {
2640
- const displaySubject = subject;
2641
- const hasLastValue = 'lastValue' in displaySubject;
2642
- const lastValue = displaySubject.lastValue; // TODO: we maybe able to use displaySubject.value and remove concept of lastValue
2643
- // was simple value but now something bigger
2644
- if (hasLastValue && lastValue !== newValue) {
2645
- const newType = typeof (newValue);
2646
- if (isSimpleType(newType) && typeof (lastValue) === newType) {
2647
- return false;
2648
- }
2649
- if (newValue instanceof Function && lastValue instanceof Function) {
2650
- return false;
2651
- }
2652
- destroySimpleValue(insertBefore, displaySubject);
2653
- return 'changed-simple-value';
2654
- }
2655
- const arraySubject = subject;
2656
- const wasArray = arraySubject.lastArray;
2657
- // no longer an array
2658
- if (wasArray && !(0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagArray)(newValue)) {
2659
- const placeholderElm = arraySubject.placeholder;
2660
- delete arraySubject.lastArray;
2661
- delete arraySubject.placeholder;
2662
- (0,_insertAfter_function__WEBPACK_IMPORTED_MODULE_3__.insertAfter)(insertBefore, placeholderElm);
2663
- for (let index = wasArray.length - 1; index >= 0; --index) {
2664
- const { tagSupport } = wasArray[index];
2665
- destroyArrayTag(tagSupport, { added: 0, removed: 0 });
2666
- }
2667
- return 'array';
2668
- }
2669
- const tagSubject = subject;
2670
- const lastSupport = tagSubject.tagSupport;
2671
- // no longer tag or component?
2672
- if (lastSupport) {
2673
- const isValueTag = (0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTag)(newValue);
2674
- const isSubjectTag = (0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTag)(subject.value);
2675
- if (isSubjectTag && isValueTag) {
2676
- const newTag = newValue;
2677
- // its a different tag now
2678
- if (!(0,_isLikeTags_function__WEBPACK_IMPORTED_MODULE_1__.isLikeTags)(newTag, lastSupport)) {
2679
- // put template back down
2680
- restoreTagMarker(lastSupport);
2681
- (0,_destroyTag_function__WEBPACK_IMPORTED_MODULE_2__.destroyTagMemory)(lastSupport);
2682
- return 2;
2683
- }
2684
- return false;
2685
- }
2686
- const isValueTagComponent = (0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagComponent)(newValue);
2687
- if (isValueTagComponent) {
2688
- return false; // its still a tag component
2689
- }
2690
- // put template back down
2691
- restoreTagMarker(lastSupport);
2692
- // destroy old component, value is not a component
2693
- (0,_destroyTag_function__WEBPACK_IMPORTED_MODULE_2__.destroyTagMemory)(lastSupport);
2694
- return 'different-tag';
2695
- }
2696
- return false;
2697
- }
2698
- function isSimpleType(value) {
2699
- return ['string', 'number', 'boolean'].includes(value);
2700
- }
2701
- function destroyArrayTag(tagSupport, counts) {
2702
- (0,_destroyTag_function__WEBPACK_IMPORTED_MODULE_2__.destroyTagSupportPast)(tagSupport);
2703
- tagSupport.destroy({
2704
- stagger: counts.removed++,
2705
- });
2706
- const insertBefore = tagSupport.global.insertBefore;
2707
- const parentNode = insertBefore.parentNode;
2708
- parentNode.removeChild(insertBefore);
2709
- }
2710
- function destroySimpleValue(insertBefore, // always a template tag
2711
- subject) {
2712
- const clone = subject.clone;
2713
- const parent = clone.parentNode;
2714
- // 1 put the template back down
2715
- parent.insertBefore(insertBefore, clone);
2716
- parent.removeChild(clone);
2717
- delete subject.clone;
2718
- delete subject.lastValue;
2719
- }
2720
- function restoreTagMarker(lastSupport) {
2721
- const insertBefore = lastSupport.global.insertBefore;
2722
- const global = lastSupport.global;
2723
- const placeholderElm = global.placeholder;
2724
- if (placeholderElm) {
2725
- (0,_insertAfter_function__WEBPACK_IMPORTED_MODULE_3__.insertAfter)(insertBefore, placeholderElm);
2726
- delete global.placeholder;
2727
- }
2728
- }
2729
-
2730
-
2731
- /***/ }),
2732
-
2733
- /***/ "./ts/tag/cloneValueArray.function.ts":
2734
- /*!********************************************!*\
2735
- !*** ./ts/tag/cloneValueArray.function.ts ***!
2736
- \********************************************/
2737
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2738
-
2739
- __webpack_require__.r(__webpack_exports__);
2740
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2741
- /* harmony export */ cloneValueArray: () => (/* binding */ cloneValueArray)
2742
- /* harmony export */ });
2743
- /* harmony import */ var _deepFunctions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../deepFunctions */ "./ts/deepFunctions.ts");
2744
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../isInstance */ "./ts/isInstance.ts");
2745
-
2746
-
2747
- function cloneValueArray(values) {
2748
- return values.map((value) => {
2749
- const tag = value;
2750
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_1__.isTagComponent)(value)) {
2751
- const tagComponent = value;
2752
- return (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepClone)(tagComponent.props);
2753
- }
2754
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_1__.isTagClass)(tag) || (0,_isInstance__WEBPACK_IMPORTED_MODULE_1__.isTagTemplater)(tag)) {
2755
- return cloneValueArray(tag.values);
2756
- }
2757
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_1__.isTagArray)(tag)) {
2758
- return cloneValueArray(tag);
2759
- }
2760
- return (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepClone)(value);
2761
- });
2762
- }
2763
-
2764
-
2765
- /***/ }),
2766
-
2767
- /***/ "./ts/tag/destroy.support.ts":
2768
- /*!***********************************!*\
2769
- !*** ./ts/tag/destroy.support.ts ***!
2770
- \***********************************/
2771
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2772
-
2773
- __webpack_require__.r(__webpack_exports__);
2774
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2775
- /* harmony export */ getChildTagsToDestroy: () => (/* binding */ getChildTagsToDestroy)
2776
- /* harmony export */ });
2777
- function getChildTagsToDestroy(childTags, allTags = []) {
2778
- for (let index = childTags.length - 1; index >= 0; --index) {
2779
- const cTag = childTags[index];
2780
- allTags.push(cTag);
2781
- childTags.splice(index, 1);
2782
- getChildTagsToDestroy(cTag.childTags, allTags);
2783
- }
2784
- return allTags;
2785
- }
2786
-
2787
-
2788
- /***/ }),
2789
-
2790
- /***/ "./ts/tag/destroyTag.function.ts":
2791
- /*!***************************************!*\
2792
- !*** ./ts/tag/destroyTag.function.ts ***!
2793
- \***************************************/
2794
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2795
-
2796
- __webpack_require__.r(__webpack_exports__);
2797
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2798
- /* harmony export */ destroyTagMemory: () => (/* binding */ destroyTagMemory),
2799
- /* harmony export */ destroyTagSupportPast: () => (/* binding */ destroyTagSupportPast)
2800
- /* harmony export */ });
2801
- function destroyTagMemory(oldTagSupport) {
2802
- // must destroy oldest which is tag with elements on stage
2803
- const oldest = oldTagSupport.global.oldest;
2804
- oldest.destroy();
2805
- destroyTagSupportPast(oldTagSupport);
2806
- oldTagSupport.global.context = {};
2807
- }
2808
- function destroyTagSupportPast(oldTagSupport) {
2809
- delete oldTagSupport.global.oldest;
2810
- delete oldTagSupport.global.newest;
2811
- }
2812
-
2813
-
2814
- /***/ }),
2815
-
2816
- /***/ "./ts/tag/elementDestroyCheck.function.ts":
2817
- /*!************************************************!*\
2818
- !*** ./ts/tag/elementDestroyCheck.function.ts ***!
2819
- \************************************************/
2820
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2821
-
2822
- __webpack_require__.r(__webpack_exports__);
2823
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2824
- /* harmony export */ elementDestroyCheck: () => (/* binding */ elementDestroyCheck)
2825
- /* harmony export */ });
2826
- function elementDestroyCheck(nextSibling, stagger) {
2827
- const onDestroyDoubleWrap = nextSibling.ondestroy;
2828
- if (!onDestroyDoubleWrap) {
2829
- return;
2830
- }
2831
- const onDestroyWrap = onDestroyDoubleWrap.tagFunction;
2832
- if (!onDestroyWrap) {
2833
- return;
2834
- }
2835
- const onDestroy = onDestroyWrap.tagFunction;
2836
- if (!onDestroy) {
2837
- return;
2838
- }
2839
- const event = { target: nextSibling, stagger };
2840
- return onDestroy(event);
2841
- }
2842
-
2843
-
2844
- /***/ }),
2845
-
2846
- /***/ "./ts/tag/getSupportInCycle.function.ts":
2847
- /*!**********************************************!*\
2848
- !*** ./ts/tag/getSupportInCycle.function.ts ***!
2849
- \**********************************************/
2850
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2851
-
2852
- __webpack_require__.r(__webpack_exports__);
2853
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2854
- /* harmony export */ getSupportInCycle: () => (/* binding */ getSupportInCycle)
2855
- /* harmony export */ });
2856
- /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../state */ "./ts/state/index.ts");
2857
-
2858
- function getSupportInCycle() {
2859
- return _state__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.stateConfig.tagSupport;
2860
- }
2861
-
2862
-
2863
- /***/ }),
2864
-
2865
- /***/ "./ts/tag/hasPropChanges.function.ts":
2866
- /*!*******************************************!*\
2867
- !*** ./ts/tag/hasPropChanges.function.ts ***!
2868
- \*******************************************/
2869
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2870
-
2871
- __webpack_require__.r(__webpack_exports__);
2872
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2873
- /* harmony export */ hasPropChanges: () => (/* binding */ hasPropChanges)
2874
- /* harmony export */ });
2875
- /* harmony import */ var _deepFunctions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../deepFunctions */ "./ts/deepFunctions.ts");
2876
-
2877
- /**
2878
- *
2879
- * @param props
2880
- * @param pastCloneProps
2881
- * @returns WHEN number then props have changed. WHEN false props have not changed
2882
- */
2883
- function hasPropChanges(props, // natural props
2884
- pastCloneProps) {
2885
- /*
2886
- const isCommonEqual = props === undefined && props === compareToProps
2887
- if(isCommonEqual) {
2888
- return false
2889
- }
2890
- */
2891
- let castedProps = props;
2892
- let castedPastProps = pastCloneProps;
2893
- // check all prop functions match
2894
- if (typeof (props) === 'object') {
2895
- if (!pastCloneProps) {
2896
- return 3;
2897
- }
2898
- // castedProps = {...props}
2899
- castedProps = [...props];
2900
- // castedPastProps = {...(pastCloneProps || {})}
2901
- castedPastProps = [...(pastCloneProps || [])];
2902
- const allFunctionsMatch = castedProps.every((value, index) => {
2903
- let compare = castedPastProps[index];
2904
- if (value && typeof (value) === 'object') {
2905
- const subCastedProps = { ...value };
2906
- const subCompareProps = { ...compare || {} };
2907
- const matched = Object.entries(subCastedProps).every(([key, value]) => {
2908
- return compareProps(value, subCompareProps[key], () => {
2909
- delete subCastedProps[key]; // its a function and not needed to be compared
2910
- delete subCompareProps[key]; // its a function and not needed to be compared
2911
- });
2912
- });
2913
- return matched;
2914
- }
2915
- return compareProps(value, compare, () => {
2916
- castedProps.splice(index, 1);
2917
- castedPastProps.splice(index, 1);
2918
- });
2919
- });
2920
- if (!allFunctionsMatch) {
2921
- return 6; // a change has been detected by function comparisons
2922
- }
2923
- }
2924
- // const isEqual = deepEqual(castedPastProps, castedProps)
2925
- // return isEqual ? false : 7 // if equal then no changes
2926
- return false;
2927
- }
2928
- /** returning a number means true good comparison */
2929
- function compareProps(value, compare, onDelete) {
2930
- if (!(value instanceof Function)) {
2931
- return (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepEqual)(value, compare) ? 4 : false;
2932
- }
2933
- const compareFn = compare;
2934
- if (!(compareFn instanceof Function)) {
2935
- return false; // its a function now but was not before
2936
- }
2937
- // ensure we are comparing apples to apples as function get wrapped
2938
- const compareOriginal = compare?.original;
2939
- if (compareOriginal) {
2940
- compare = compareOriginal;
2941
- }
2942
- const original = value.original;
2943
- if (original) {
2944
- value = value.original;
2945
- }
2946
- const valueString = value.toString();
2947
- const compareString = compare.toString();
2948
- if (valueString === compareString) {
2949
- onDelete();
2950
- return 3; // both are function the same
2951
- }
2952
- onDelete();
2953
- return 5;
2954
- }
2955
-
2956
-
2957
- /***/ }),
2958
-
2959
- /***/ "./ts/tag/hasTagSupportChanged.function.ts":
2960
- /*!*************************************************!*\
2961
- !*** ./ts/tag/hasTagSupportChanged.function.ts ***!
2962
- \*************************************************/
2963
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2964
-
2965
- __webpack_require__.r(__webpack_exports__);
2966
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2967
- /* harmony export */ hasKidsChanged: () => (/* binding */ hasKidsChanged),
2968
- /* harmony export */ hasTagSupportChanged: () => (/* binding */ hasTagSupportChanged)
2969
- /* harmony export */ });
2970
- /* harmony import */ var _hasPropChanges_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./hasPropChanges.function */ "./ts/tag/hasPropChanges.function.ts");
2971
-
2972
- function hasTagSupportChanged(oldTagSupport, newTagSupport, newTemplater) {
2973
- const latestProps = newTemplater.props; // newTagSupport.propsConfig.latest
2974
- const pastCloneProps = oldTagSupport.propsConfig.latestCloned;
2975
- const propsChanged = (0,_hasPropChanges_function__WEBPACK_IMPORTED_MODULE_0__.hasPropChanges)(latestProps, pastCloneProps);
2976
- // if no changes detected, no need to continue to rendering further tags
2977
- if (propsChanged) {
2978
- return propsChanged;
2979
- }
2980
- const kidsChanged = hasKidsChanged(oldTagSupport, newTagSupport);
2981
- // we already know props didn't change and if kids didn't either, than don't render
2982
- return kidsChanged;
2983
- }
2984
- function hasKidsChanged(oldTagSupport, newTagSupport) {
2985
- const oldCloneKidValues = oldTagSupport.propsConfig.lastClonedKidValues;
2986
- const newClonedKidValues = newTagSupport.propsConfig.lastClonedKidValues;
2987
- const everySame = oldCloneKidValues.every((set, index) => {
2988
- const x = newClonedKidValues[index];
2989
- return set.every((item, index) => item === x[index]);
2990
- });
2991
- return everySame ? false : 9;
2992
- }
2993
-
2994
-
2995
- /***/ }),
2996
-
2997
- /***/ "./ts/tag/html.ts":
2998
- /*!************************!*\
2999
- !*** ./ts/tag/html.ts ***!
3000
- \************************/
3001
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3002
-
3003
- __webpack_require__.r(__webpack_exports__);
3004
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3005
- /* harmony export */ html: () => (/* binding */ html)
3006
- /* harmony export */ });
3007
- /* harmony import */ var _Tag_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Tag.class */ "./ts/tag/Tag.class.ts");
3008
-
3009
- function html(strings, ...values) {
3010
- return new _Tag_class__WEBPACK_IMPORTED_MODULE_0__.Tag(strings, values);
3011
- }
3012
-
3013
-
3014
- /***/ }),
3015
-
3016
- /***/ "./ts/tag/isLikeTags.function.ts":
3017
- /*!***************************************!*\
3018
- !*** ./ts/tag/isLikeTags.function.ts ***!
3019
- \***************************************/
3020
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3021
-
3022
- __webpack_require__.r(__webpack_exports__);
3023
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3024
- /* harmony export */ isLikeTags: () => (/* binding */ isLikeTags),
3025
- /* harmony export */ isLikeValueSets: () => (/* binding */ isLikeValueSets)
3026
- /* harmony export */ });
3027
- function isLikeTags(tagSupport0, // new
3028
- tagSupport1) {
3029
- const templater0 = tagSupport0.templater;
3030
- const templater1 = tagSupport1.templater;
3031
- const tag0 = templater0?.tag || tagSupport0;
3032
- const tag1 = templater1.tag;
3033
- const strings0 = tag0.strings;
3034
- const strings1 = tagSupport1.strings || tag1.strings;
3035
- if (strings0.length !== strings1.length) {
3036
- return false;
3037
- }
3038
- const everyStringMatched = strings0.every((string, index) => strings1[index] === string);
3039
- if (!everyStringMatched) {
3040
- return false;
3041
- }
3042
- const values0 = tagSupport0.values || tag0.values;
3043
- const values1 = tagSupport1.values || tag1.values;
3044
- return isLikeValueSets(values0, values1);
3045
- }
3046
- function isLikeValueSets(values0, values1) {
3047
- const valuesLengthsMatch = values0.length === values1.length;
3048
- if (!valuesLengthsMatch) {
3049
- return false;
3050
- }
3051
- const allVarsMatch = values1.every((value, index) => {
3052
- const compareTo = values0[index];
3053
- const isFunctions = value instanceof Function && compareTo instanceof Function;
3054
- if (isFunctions) {
3055
- const stringMatch = value.toString() === compareTo.toString();
3056
- if (stringMatch) {
3057
- return true;
3058
- }
3059
- return false;
3060
- }
3061
- return true; // deepEqual(value, compareTo)
3062
- });
3063
- if (allVarsMatch) {
3064
- return true;
3065
- }
3066
- return false;
3067
- }
3068
-
3069
-
3070
- /***/ }),
3071
-
3072
- /***/ "./ts/tag/render/renderExistingTag.function.ts":
3073
- /*!*****************************************************!*\
3074
- !*** ./ts/tag/render/renderExistingTag.function.ts ***!
3075
- \*****************************************************/
3076
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3077
-
3078
- __webpack_require__.r(__webpack_exports__);
3079
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3080
- /* harmony export */ renderExistingTag: () => (/* binding */ renderExistingTag)
3081
- /* harmony export */ });
3082
- /* harmony import */ var _state_provider_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../state/provider.utils */ "./ts/state/provider.utils.ts");
3083
- /* harmony import */ var _isLikeTags_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../isLikeTags.function */ "./ts/tag/isLikeTags.function.ts");
3084
- /* harmony import */ var _renderWithSupport_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./renderWithSupport.function */ "./ts/tag/render/renderWithSupport.function.ts");
3085
-
3086
-
3087
-
3088
- /** Returns true when rendering owner is not needed. Returns false when rendering owner should occur */
3089
- function renderExistingTag(oldestSupport, // oldest with elements on html
3090
- newSupport, // new to be rendered
3091
- ownerSupport, // ownerSupport
3092
- subject) {
3093
- const lastSupport = subject.tagSupport;
3094
- const global = lastSupport.global;
3095
- // share point between renders
3096
- newSupport.global = global;
3097
- const preRenderCount = global.renderCount;
3098
- (0,_state_provider_utils__WEBPACK_IMPORTED_MODULE_0__.providersChangeCheck)(oldestSupport);
3099
- // When the providers were checked, a render to myself occurred and I do not need to re-render again
3100
- const prevSupport = global.newest;
3101
- if (preRenderCount !== global.renderCount) {
3102
- oldestSupport.updateBy(prevSupport);
3103
- return prevSupport; // already rendered during triggered events
3104
- }
3105
- const toRedrawTag = prevSupport || lastSupport || global.oldest;
3106
- const reSupport = (0,_renderWithSupport_function__WEBPACK_IMPORTED_MODULE_2__.renderWithSupport)(newSupport, toRedrawTag, subject, ownerSupport);
3107
- const oldest = global.oldest || oldestSupport;
3108
- reSupport.global.oldest = oldest;
3109
- // TODO: renderWithSupport already does an isLikeTags compare
3110
- if ((0,_isLikeTags_function__WEBPACK_IMPORTED_MODULE_1__.isLikeTags)(prevSupport, reSupport)) {
3111
- subject.tagSupport = reSupport;
3112
- oldest.updateBy(reSupport);
3113
- }
3114
- return reSupport;
3115
- }
3116
-
3117
-
3118
- /***/ }),
3119
-
3120
- /***/ "./ts/tag/render/renderSubjectComponent.function.ts":
3121
- /*!**********************************************************!*\
3122
- !*** ./ts/tag/render/renderSubjectComponent.function.ts ***!
3123
- \**********************************************************/
3124
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3125
-
3126
- __webpack_require__.r(__webpack_exports__);
3127
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3128
- /* harmony export */ renderSubjectComponent: () => (/* binding */ renderSubjectComponent)
3129
- /* harmony export */ });
3130
- /* harmony import */ var _renderWithSupport_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderWithSupport.function */ "./ts/tag/render/renderWithSupport.function.ts");
3131
-
3132
- function renderSubjectComponent(subject, reSupport, ownerSupport) {
3133
- const preClones = ownerSupport.clones.map(clone => clone);
3134
- reSupport = (0,_renderWithSupport_function__WEBPACK_IMPORTED_MODULE_0__.renderWithSupport)(reSupport, subject.tagSupport, // existing tag
3135
- subject, ownerSupport);
3136
- reSupport.global.newest = reSupport;
3137
- if (ownerSupport.clones.length > preClones.length) {
3138
- const myClones = ownerSupport.clones.filter(fClone => !preClones.find(clone => clone === fClone));
3139
- reSupport.clones.push(...myClones);
3140
- }
3141
- ownerSupport.childTags.push(reSupport);
3142
- return reSupport;
3143
- }
3144
-
3145
-
3146
- /***/ }),
3147
-
3148
- /***/ "./ts/tag/render/renderTagOnly.function.ts":
3149
- /*!*************************************************!*\
3150
- !*** ./ts/tag/render/renderTagOnly.function.ts ***!
3151
- \*************************************************/
3152
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3153
-
3154
- __webpack_require__.r(__webpack_exports__);
3155
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3156
- /* harmony export */ renderTagOnly: () => (/* binding */ renderTagOnly)
3157
- /* harmony export */ });
3158
- /* harmony import */ var _tagRunner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../tagRunner */ "./ts/tag/tagRunner.ts");
3159
- /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../state */ "./ts/state/index.ts");
3160
-
3161
-
3162
-
3163
- function renderTagOnly(newTagSupport, lastSupport, subject, ownerSupport) {
3164
- const oldRenderCount = newTagSupport.global.renderCount;
3165
- beforeWithRender(newTagSupport, ownerSupport, lastSupport);
3166
- const templater = newTagSupport.templater;
3167
- // NEW TAG CREATED HERE
3168
- const wrapper = templater.wrapper;
3169
- let reSupport = wrapper(newTagSupport, subject);
3170
- /* AFTER */
3171
- (0,_tagRunner__WEBPACK_IMPORTED_MODULE_0__.runAfterRender)(newTagSupport, ownerSupport);
3172
- // When we rendered, only 1 render should have taken place OTHERWISE rendering caused another render and that is the latest instead
3173
- if (reSupport.global.renderCount > oldRenderCount + 1) {
3174
- return newTagSupport.global.newest;
3175
- }
3176
- newTagSupport.global.newest = reSupport;
3177
- return reSupport;
3178
- }
3179
- function beforeWithRender(tagSupport, // new
3180
- ownerSupport, lastSupport) {
3181
- const lastOwnerSupport = lastSupport?.ownerTagSupport;
3182
- const runtimeOwnerSupport = lastOwnerSupport || ownerSupport;
3183
- if (lastSupport) {
3184
- const lastState = lastSupport.memory.state;
3185
- const memory = tagSupport.memory;
3186
- // memory.state.length = 0
3187
- // memory.state.push(...lastState)
3188
- memory.state = [...lastState];
3189
- tagSupport.global = lastSupport.global;
3190
- (0,_tagRunner__WEBPACK_IMPORTED_MODULE_0__.runBeforeRedraw)(tagSupport, lastSupport);
3191
- }
3192
- else {
3193
- // first time render
3194
- (0,_tagRunner__WEBPACK_IMPORTED_MODULE_0__.runBeforeRender)(tagSupport, runtimeOwnerSupport);
3195
- // TODO: Logic below most likely could live within providers.ts inside the runBeforeRender function
3196
- const providers = _state__WEBPACK_IMPORTED_MODULE_1__.setUse.memory.providerConfig;
3197
- providers.ownerSupport = runtimeOwnerSupport;
3198
- }
3199
- }
3200
-
3201
-
3202
- /***/ }),
3203
-
3204
- /***/ "./ts/tag/render/renderTagSupport.function.ts":
3205
- /*!****************************************************!*\
3206
- !*** ./ts/tag/render/renderTagSupport.function.ts ***!
3207
- \****************************************************/
3208
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3209
-
3210
- __webpack_require__.r(__webpack_exports__);
3211
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3212
- /* harmony export */ renderTagSupport: () => (/* binding */ renderTagSupport)
3213
- /* harmony export */ });
3214
- /* harmony import */ var _deepFunctions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../deepFunctions */ "./ts/deepFunctions.ts");
3215
- /* harmony import */ var _renderExistingTag_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./renderExistingTag.function */ "./ts/tag/render/renderExistingTag.function.ts");
3216
-
3217
-
3218
- /** Main function used by all other callers to render/update display of a tag component */
3219
- function renderTagSupport(tagSupport, // must be latest/newest state render
3220
- renderUp) {
3221
- const global = tagSupport.global;
3222
- const templater = tagSupport.templater;
3223
- // is it just a vanilla tag, not component?
3224
- if (!templater.wrapper) { // || isTagTemplater(templater)
3225
- const ownerTag = tagSupport.ownerTagSupport;
3226
- ++global.renderCount;
3227
- return renderTagSupport(ownerTag, true);
3228
- }
3229
- const subject = tagSupport.subject;
3230
- let ownerSupport;
3231
- let selfPropChange = false;
3232
- const shouldRenderUp = renderUp && tagSupport;
3233
- if (shouldRenderUp) {
3234
- ownerSupport = tagSupport.ownerTagSupport;
3235
- if (ownerSupport) {
3236
- const nowProps = templater.props;
3237
- const latestProps = tagSupport.propsConfig.latestCloned;
3238
- selfPropChange = !nowProps.every((props, index) => (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_0__.deepEqual)(props, latestProps[index]));
3239
- }
3240
- }
3241
- const oldest = tagSupport.global.oldest;
3242
- const tag = (0,_renderExistingTag_function__WEBPACK_IMPORTED_MODULE_1__.renderExistingTag)(oldest, tagSupport, ownerSupport, // useTagSupport,
3243
- subject);
3244
- const renderOwner = ownerSupport && selfPropChange;
3245
- if (renderOwner) {
3246
- const ownerTagSupport = ownerSupport;
3247
- renderTagSupport(ownerTagSupport, true);
3248
- return tag;
3249
- }
3250
- return tag;
3251
- }
3252
-
3253
-
3254
- /***/ }),
3255
-
3256
- /***/ "./ts/tag/render/renderWithSupport.function.ts":
3257
- /*!*****************************************************!*\
3258
- !*** ./ts/tag/render/renderWithSupport.function.ts ***!
3259
- \*****************************************************/
3260
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3261
-
3262
- __webpack_require__.r(__webpack_exports__);
3263
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3264
- /* harmony export */ renderWithSupport: () => (/* binding */ renderWithSupport)
3265
- /* harmony export */ });
3266
- /* harmony import */ var _isLikeTags_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../isLikeTags.function */ "./ts/tag/isLikeTags.function.ts");
3267
- /* harmony import */ var _destroyTag_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../destroyTag.function */ "./ts/tag/destroyTag.function.ts");
3268
- /* harmony import */ var _renderTagOnly_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./renderTagOnly.function */ "./ts/tag/render/renderTagOnly.function.ts");
3269
-
3270
-
3271
-
3272
- function renderWithSupport(newTagSupport, lastSupport, // previous
3273
- subject, // events & memory
3274
- ownerSupport) {
3275
- const reSupport = (0,_renderTagOnly_function__WEBPACK_IMPORTED_MODULE_2__.renderTagOnly)(newTagSupport, lastSupport, subject, ownerSupport);
3276
- const isLikeTag = !lastSupport || (0,_isLikeTags_function__WEBPACK_IMPORTED_MODULE_0__.isLikeTags)(lastSupport, reSupport);
3277
- if (!isLikeTag) {
3278
- destroyUnlikeTags(lastSupport, reSupport, subject);
3279
- }
3280
- const lastOwnerSupport = lastSupport?.ownerTagSupport;
3281
- reSupport.ownerTagSupport = (ownerSupport || lastOwnerSupport);
3282
- return reSupport;
3283
- }
3284
- function destroyUnlikeTags(lastSupport, // old
3285
- reSupport, // new
3286
- subject) {
3287
- const oldGlobal = lastSupport.global;
3288
- const insertBefore = oldGlobal.insertBefore;
3289
- (0,_destroyTag_function__WEBPACK_IMPORTED_MODULE_1__.destroyTagMemory)(lastSupport);
3290
- // when a tag is destroyed, disconnect the globals
3291
- reSupport.global = { ...oldGlobal }; // break memory references
3292
- const global = reSupport.global;
3293
- global.insertBefore = insertBefore;
3294
- global.deleted = false;
3295
- delete global.oldest;
3296
- delete global.newest;
3297
- delete subject.tagSupport;
3298
- }
3299
-
3300
-
3301
- /***/ }),
3302
-
3303
- /***/ "./ts/tag/setTagPlaceholder.function.ts":
3304
- /*!**********************************************!*\
3305
- !*** ./ts/tag/setTagPlaceholder.function.ts ***!
3306
- \**********************************************/
3307
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3308
-
3309
- __webpack_require__.r(__webpack_exports__);
3310
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3311
- /* harmony export */ setTagPlaceholder: () => (/* binding */ setTagPlaceholder),
3312
- /* harmony export */ swapInsertBefore: () => (/* binding */ swapInsertBefore)
3313
- /* harmony export */ });
3314
- function setTagPlaceholder(global) {
3315
- const insertBefore = global.insertBefore;
3316
- return global.placeholder = swapInsertBefore(insertBefore);
3317
- }
3318
- function swapInsertBefore(insertBefore) {
3319
- const placeholder = document.createTextNode('');
3320
- const parentNode = insertBefore.parentNode;
3321
- parentNode.insertBefore(placeholder, insertBefore);
3322
- parentNode.removeChild(insertBefore);
3323
- return placeholder;
3324
- }
3325
-
3326
-
3327
- /***/ }),
3328
-
3329
- /***/ "./ts/tag/tag.ts":
3330
- /*!***********************!*\
3331
- !*** ./ts/tag/tag.ts ***!
3332
- \***********************/
3333
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3334
-
3335
- __webpack_require__.r(__webpack_exports__);
3336
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3337
- /* harmony export */ kidsToTagArraySubject: () => (/* binding */ kidsToTagArraySubject),
3338
- /* harmony export */ tag: () => (/* binding */ tag),
3339
- /* harmony export */ tags: () => (/* binding */ tags)
3340
- /* harmony export */ });
3341
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../isInstance */ "./ts/isInstance.ts");
3342
- /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../state */ "./ts/state/index.ts");
3343
- /* harmony import */ var _TemplaterResult_class__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../TemplaterResult.class */ "./ts/TemplaterResult.class.ts");
3344
- /* harmony import */ var _interpolations_bindSubjectCallback_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../interpolations/bindSubjectCallback.function */ "./ts/interpolations/bindSubjectCallback.function.ts");
3345
- /* harmony import */ var _deepFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../deepFunctions */ "./ts/deepFunctions.ts");
3346
- /* harmony import */ var _TagSupport_class__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./TagSupport.class */ "./ts/tag/TagSupport.class.ts");
3347
- /* harmony import */ var _alterProps_function__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../alterProps.function */ "./ts/alterProps.function.ts");
3348
- /* harmony import */ var _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../subject/ValueSubject */ "./ts/subject/ValueSubject.ts");
3349
-
3350
-
3351
-
3352
-
3353
-
3354
-
3355
-
3356
-
3357
- // export const tags: TagComponentBase<any>[] = []
3358
- const tags = [];
3359
- let tagCount = 0;
3360
- /** Wraps a tag component in a state manager and always push children to last argument as an array */
3361
- // export function tag<T>(a: T): T;
3362
- function tag(tagComponent) {
3363
- /** function developer triggers */
3364
- const parentWrap = (function tagWrapper(...props) {
3365
- const templater = new _TemplaterResult_class__WEBPACK_IMPORTED_MODULE_2__.TemplaterResult(props);
3366
- // attach memory back to original function that contains developer display logic
3367
- const innerTagWrap = getTagWrap(templater, parentWrap);
3368
- if (!innerTagWrap.parentWrap) {
3369
- innerTagWrap.parentWrap = parentWrap;
3370
- }
3371
- templater.tagged = true;
3372
- templater.wrapper = innerTagWrap;
3373
- return templater;
3374
- }) // we override the function provided and pretend original is what's returned
3375
- ;
3376
- parentWrap.original = tagComponent;
3377
- parentWrap.compareTo = tagComponent.toString();
3378
- updateResult(parentWrap, tagComponent);
3379
- // group tags together and have hmr pickup
3380
- updateComponent(tagComponent);
3381
- tags.push(parentWrap);
3382
- return parentWrap;
3383
- }
3384
- function kidsToTagArraySubject(children) {
3385
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isSubjectInstance)(children)) {
3386
- return { childSubject: children, madeSubject: false };
3387
- }
3388
- const kidArray = children;
3389
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagArray)(kidArray)) {
3390
- return { childSubject: new _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_7__.ValueSubject(children), madeSubject: true };
3391
- }
3392
- const kid = children;
3393
- if (kid) {
3394
- kid.memory.arrayValue = 0;
3395
- return { childSubject: new _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_7__.ValueSubject([kid]), madeSubject: true };
3396
- }
3397
- return {
3398
- childSubject: new _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_7__.ValueSubject([]),
3399
- madeSubject: true // was converted into a subject
3400
- };
3401
- }
3402
- function updateResult(result, tagComponent) {
3403
- result.isTag = true;
3404
- result.original = tagComponent;
3405
- }
3406
- function updateComponent(tagComponent) {
3407
- tagComponent.tags = tags;
3408
- tagComponent.setUse = _state__WEBPACK_IMPORTED_MODULE_1__.setUse;
3409
- tagComponent.tagIndex = tagCount++; // needed for things like HMR
3410
- }
3411
- /** creates/returns a function that when called then calls the original component function
3412
- * Gets used as templater.wrapper()
3413
- */
3414
- function getTagWrap(templater, result) {
3415
- // this function gets called by taggedjs
3416
- const wrapper = function (newTagSupport, subject) {
3417
- const global = newTagSupport.global;
3418
- ++global.renderCount;
3419
- const childSubject = templater.children;
3420
- const lastArray = global.oldest?.templater.children.lastArray;
3421
- if (lastArray) {
3422
- childSubject.lastArray = lastArray;
3423
- }
3424
- // result.original
3425
- const originalFunction = result.original; // (innerTagWrap as any).original as unknown as TagComponent
3426
- let props = templater.props;
3427
- let castedProps = props.map(props => (0,_alterProps_function__WEBPACK_IMPORTED_MODULE_6__.alterProps)(props, newTagSupport.ownerTagSupport));
3428
- const latestCloned = props.map(props => (0,_deepFunctions__WEBPACK_IMPORTED_MODULE_4__.deepClone)(props)); // castedProps
3429
- // CALL ORIGINAL COMPONENT FUNCTION
3430
- let tag = originalFunction(...castedProps);
3431
- if (tag instanceof Function) {
3432
- tag = tag();
3433
- }
3434
- tag.templater = templater;
3435
- templater.tag = tag;
3436
- const tagSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_5__.TagSupport(templater, newTagSupport.ownerTagSupport, subject, global.renderCount);
3437
- tagSupport.global = global;
3438
- tagSupport.propsConfig = {
3439
- latest: props,
3440
- latestCloned,
3441
- lastClonedKidValues: tagSupport.propsConfig.lastClonedKidValues,
3442
- };
3443
- tagSupport.memory = newTagSupport.memory; // state handover
3444
- if (templater.madeChildIntoSubject) {
3445
- const value = childSubject.value;
3446
- for (let index = value.length - 1; index >= 0; --index) {
3447
- const kid = value[index];
3448
- const values = kid.values;
3449
- for (let index = values.length - 1; index >= 0; --index) {
3450
- const value = values[index];
3451
- if (!(value instanceof Function)) {
3452
- continue;
3453
- }
3454
- const valuesValue = kid.values[index];
3455
- if (valuesValue.isChildOverride) {
3456
- continue; // already overwritten
3457
- }
3458
- // all functions need to report to me
3459
- kid.values[index] = function (...args) {
3460
- const ownerSupport = tagSupport.ownerTagSupport;
3461
- return (0,_interpolations_bindSubjectCallback_function__WEBPACK_IMPORTED_MODULE_3__.runTagCallback)(value, // callback
3462
- ownerSupport, this, // bindTo
3463
- args);
3464
- };
3465
- valuesValue.isChildOverride = true;
3466
- }
3467
- }
3468
- }
3469
- return tagSupport;
3470
- };
3471
- return wrapper;
3472
- }
3473
-
3474
-
3475
- /***/ }),
3476
-
3477
- /***/ "./ts/tag/tagElement.ts":
3478
- /*!******************************!*\
3479
- !*** ./ts/tag/tagElement.ts ***!
3480
- \******************************/
3481
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3482
-
3483
- __webpack_require__.r(__webpack_exports__);
3484
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3485
- /* harmony export */ runWrapper: () => (/* binding */ runWrapper),
3486
- /* harmony export */ tagElement: () => (/* binding */ tagElement)
3487
- /* harmony export */ });
3488
- /* harmony import */ var _TagSupport_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./TagSupport.class */ "./ts/tag/TagSupport.class.ts");
3489
- /* harmony import */ var _tagRunner__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tagRunner */ "./ts/tag/tagRunner.ts");
3490
- /* harmony import */ var _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../subject/ValueSubject */ "./ts/subject/ValueSubject.ts");
3491
-
3492
-
3493
-
3494
- const appElements = [];
3495
- /**
3496
- *
3497
- * @param app taggedjs tag
3498
- * @param element HTMLElement
3499
- * @param props object
3500
- * @returns
3501
- */
3502
- function tagElement(app, // (...args: unknown[]) => TemplaterResult,
3503
- element, props) {
3504
- const appElmIndex = appElements.findIndex(appElm => appElm.element === element);
3505
- if (appElmIndex >= 0) {
3506
- appElements[appElmIndex].tagSupport.destroy();
3507
- appElements.splice(appElmIndex, 1);
3508
- // an element already had an app on it
3509
- console.warn('Found and destroyed app element already rendered to element', { element });
3510
- }
3511
- // Create the app which returns [props, runOneTimeFunction]
3512
- const wrapper = app(props);
3513
- // have a function setup and call the tagWrapper with (props, {update, async, on})
3514
- const tagSupport = runWrapper(wrapper);
3515
- // TODO: is the below needed?
3516
- tagSupport.appElement = element;
3517
- tagSupport.isApp = true;
3518
- tagSupport.global.isApp = true;
3519
- const templateElm = document.createElement('template');
3520
- templateElm.setAttribute('id', 'app-tag-' + appElements.length);
3521
- templateElm.setAttribute('app-tag-detail', appElements.length.toString());
3522
- const fragment = document.createDocumentFragment();
3523
- fragment.appendChild(templateElm);
3524
- element.destroy = async () => {
3525
- await tagSupport.destroy();
3526
- const insertBefore = tagSupport.global.insertBefore;
3527
- const parentNode = insertBefore.parentNode;
3528
- parentNode.removeChild(insertBefore);
3529
- };
3530
- tagSupport.buildBeforeElement(templateElm);
3531
- tagSupport.global.oldest = tagSupport;
3532
- tagSupport.global.newest = tagSupport;
3533
- element.setUse = app.original.setUse;
3534
- appElements.push({ element, tagSupport });
3535
- element.appendChild(fragment);
3536
- return {
3537
- tagSupport,
3538
- tags: app.original.tags,
3539
- };
3540
- }
3541
- function runWrapper(templater) {
3542
- let newSupport = {};
3543
- const subject = new _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_2__.ValueSubject(newSupport);
3544
- newSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_0__.BaseTagSupport(templater, subject);
3545
- subject.set(templater);
3546
- subject.tagSupport = newSupport;
3547
- (0,_tagRunner__WEBPACK_IMPORTED_MODULE_1__.runBeforeRender)(newSupport, undefined);
3548
- // Call the apps function for our tag templater
3549
- const wrapper = templater.wrapper;
3550
- const tagSupport = wrapper(newSupport, subject);
3551
- (0,_tagRunner__WEBPACK_IMPORTED_MODULE_1__.runAfterRender)(newSupport, tagSupport);
3552
- return tagSupport;
3553
- }
3554
-
3555
-
3556
- /***/ }),
3557
-
3558
- /***/ "./ts/tag/tagRunner.ts":
3559
- /*!*****************************!*\
3560
- !*** ./ts/tag/tagRunner.ts ***!
3561
- \*****************************/
3562
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3563
-
3564
- __webpack_require__.r(__webpack_exports__);
3565
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3566
- /* harmony export */ runAfterRender: () => (/* binding */ runAfterRender),
3567
- /* harmony export */ runBeforeDestroy: () => (/* binding */ runBeforeDestroy),
3568
- /* harmony export */ runBeforeRedraw: () => (/* binding */ runBeforeRedraw),
3569
- /* harmony export */ runBeforeRender: () => (/* binding */ runBeforeRender)
3570
- /* harmony export */ });
3571
- /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../state */ "./ts/state/index.ts");
3572
- /* harmony import */ var _subject__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../subject */ "./ts/subject/index.ts");
3573
- /* harmony import */ var _getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./getSupportInCycle.function */ "./ts/tag/getSupportInCycle.function.ts");
3574
-
3575
-
3576
-
3577
- // Emits event at the end of a tag being rendered. Use tagClosed$.toPromise() to render a tag after a current tag is done rendering
3578
- _state__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.tagClosed$ = new _subject__WEBPACK_IMPORTED_MODULE_1__.Subject(undefined, subscription => {
3579
- if (!(0,_getSupportInCycle_function__WEBPACK_IMPORTED_MODULE_2__.getSupportInCycle)()) {
3580
- subscription.next(); // we are not currently processing so process now
3581
- }
3582
- });
3583
- // Life cycle 1
3584
- function runBeforeRender(tagSupport, ownerSupport) {
3585
- const tagUse = _state__WEBPACK_IMPORTED_MODULE_0__.setUse.tagUse;
3586
- const length = tagUse.length;
3587
- for (let index = 0; index < length; ++index) {
3588
- tagUse[index].beforeRender(tagSupport, ownerSupport);
3589
- }
3590
- }
3591
- // Life cycle 2
3592
- function runAfterRender(tagSupport, ownerTagSupport) {
3593
- const tagUse = _state__WEBPACK_IMPORTED_MODULE_0__.setUse.tagUse;
3594
- const length = tagUse.length;
3595
- for (let index = 0; index < length; ++index) {
3596
- tagUse[index].afterRender(tagSupport, ownerTagSupport);
3597
- }
3598
- _state__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.tagClosed$.next(ownerTagSupport);
3599
- }
3600
- // Life cycle 3
3601
- function runBeforeRedraw(tagSupport, ownerTagSupport) {
3602
- const tagUse = _state__WEBPACK_IMPORTED_MODULE_0__.setUse.tagUse;
3603
- const length = tagUse.length;
3604
- for (let index = 0; index < length; ++index) {
3605
- tagUse[index].beforeRedraw(tagSupport, ownerTagSupport);
3606
- }
3607
- }
3608
- // Life cycle 4 - end of life
3609
- function runBeforeDestroy(tagSupport, ownerTagSupport) {
3610
- const tagUse = _state__WEBPACK_IMPORTED_MODULE_0__.setUse.tagUse;
3611
- const length = tagUse.length;
3612
- for (let index = 0; index < length; ++index) {
3613
- tagUse[index].beforeDestroy(tagSupport, ownerTagSupport);
3614
- }
3615
- }
3616
-
3617
-
3618
- /***/ }),
3619
-
3620
- /***/ "./ts/tag/update/processFirstSubject.utils.ts":
3621
- /*!****************************************************!*\
3622
- !*** ./ts/tag/update/processFirstSubject.utils.ts ***!
3623
- \****************************************************/
3624
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3625
-
3626
- __webpack_require__.r(__webpack_exports__);
3627
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3628
- /* harmony export */ ValueTypes: () => (/* binding */ ValueTypes),
3629
- /* harmony export */ getValueType: () => (/* binding */ getValueType)
3630
- /* harmony export */ });
3631
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../isInstance */ "./ts/isInstance.ts");
3632
- /* harmony import */ var _checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../checkDestroyPrevious.function */ "./ts/tag/checkDestroyPrevious.function.ts");
3633
-
3634
-
3635
- var ValueTypes;
3636
- (function (ValueTypes) {
3637
- ValueTypes["unknown"] = "unknown";
3638
- ValueTypes["tag"] = "tag";
3639
- ValueTypes["templater"] = "templater";
3640
- ValueTypes["tagArray"] = "tag-array";
3641
- ValueTypes["tagComponent"] = "tag-component";
3642
- ValueTypes["subject"] = "subject";
3643
- ValueTypes["date"] = "date";
3644
- ValueTypes["string"] = "string";
3645
- ValueTypes["boolean"] = "boolean";
3646
- ValueTypes["function"] = "function";
3647
- ValueTypes["undefined"] = "undefined";
3648
- })(ValueTypes || (ValueTypes = {}));
3649
- function getValueType(value) {
3650
- if (value === undefined || value === null) {
3651
- return ValueTypes.undefined;
3652
- }
3653
- if (value instanceof Date) {
3654
- return ValueTypes.date;
3655
- }
3656
- if (value instanceof Function) {
3657
- return ValueTypes.function;
3658
- }
3659
- const type = typeof (value);
3660
- if ((0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_1__.isSimpleType)(type)) {
3661
- return type;
3662
- }
3663
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagComponent)(value)) {
3664
- return ValueTypes.tagComponent;
3665
- }
3666
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagTemplater)(value)) {
3667
- return ValueTypes.templater;
3668
- }
3669
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagClass)(value)) {
3670
- return ValueTypes.tag;
3671
- }
3672
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagArray)(value)) {
3673
- return ValueTypes.tagArray;
3674
- }
3675
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isSubjectInstance)(value)) {
3676
- return ValueTypes.subject;
3677
- }
3678
- return ValueTypes.unknown;
3679
- }
3680
-
3681
-
3682
- /***/ }),
3683
-
3684
- /***/ "./ts/tag/update/processFirstSubjectValue.function.ts":
3685
- /*!************************************************************!*\
3686
- !*** ./ts/tag/update/processFirstSubjectValue.function.ts ***!
3687
- \************************************************************/
3688
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3689
-
3690
- __webpack_require__.r(__webpack_exports__);
3691
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3692
- /* harmony export */ processFirstSubjectValue: () => (/* binding */ processFirstSubjectValue)
3693
- /* harmony export */ });
3694
- /* harmony import */ var _processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./processSubjectComponent.function */ "./ts/tag/update/processSubjectComponent.function.ts");
3695
- /* harmony import */ var _processTagArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./processTagArray */ "./ts/tag/update/processTagArray.ts");
3696
- /* harmony import */ var _processRegularValue_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./processRegularValue.function */ "./ts/tag/update/processRegularValue.function.ts");
3697
- /* harmony import */ var _processTag_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./processTag.function */ "./ts/tag/update/processTag.function.ts");
3698
- /* harmony import */ var _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./processFirstSubject.utils */ "./ts/tag/update/processFirstSubject.utils.ts");
3699
-
3700
-
3701
-
3702
-
3703
-
3704
- function processFirstSubjectValue(value, subject, // could be tag via result.tag
3705
- insertBefore, // <template end interpolate /> (will be removed)
3706
- ownerSupport, // owner
3707
- options) {
3708
- const valueType = (0,_processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_4__.getValueType)(value);
3709
- switch (valueType) {
3710
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_4__.ValueTypes.templater:
3711
- (0,_processTag_function__WEBPACK_IMPORTED_MODULE_3__.processTag)(value, insertBefore, ownerSupport, subject);
3712
- return;
3713
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_4__.ValueTypes.tag:
3714
- const tag = value;
3715
- let templater = tag.templater;
3716
- if (!templater) {
3717
- templater = (0,_processTag_function__WEBPACK_IMPORTED_MODULE_3__.tagFakeTemplater)(tag);
3718
- }
3719
- (0,_processTag_function__WEBPACK_IMPORTED_MODULE_3__.processTag)(templater, insertBefore, ownerSupport, subject);
3720
- return;
3721
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_4__.ValueTypes.tagArray:
3722
- return (0,_processTagArray__WEBPACK_IMPORTED_MODULE_1__.processTagArray)(subject, value, insertBefore, ownerSupport, options);
3723
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_4__.ValueTypes.tagComponent:
3724
- (0,_processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_0__.processSubjectComponent)(value, subject, insertBefore, ownerSupport, options);
3725
- return;
3726
- }
3727
- (0,_processRegularValue_function__WEBPACK_IMPORTED_MODULE_2__.processFirstRegularValue)(value, subject, insertBefore);
3728
- }
3729
-
3730
-
3731
- /***/ }),
3732
-
3733
- /***/ "./ts/tag/update/processNewValue.function.ts":
3734
- /*!***************************************************!*\
3735
- !*** ./ts/tag/update/processNewValue.function.ts ***!
3736
- \***************************************************/
3737
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3738
-
3739
- __webpack_require__.r(__webpack_exports__);
3740
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3741
- /* harmony export */ processNewValue: () => (/* binding */ processNewValue)
3742
- /* harmony export */ });
3743
- /* harmony import */ var _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../subject/ValueSubject */ "./ts/subject/ValueSubject.ts");
3744
- /* harmony import */ var _TemplaterResult_class__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../TemplaterResult.class */ "./ts/TemplaterResult.class.ts");
3745
- /* harmony import */ var _TagSupport_class__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../TagSupport.class */ "./ts/tag/TagSupport.class.ts");
3746
- /* harmony import */ var _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./processFirstSubject.utils */ "./ts/tag/update/processFirstSubject.utils.ts");
3747
-
3748
-
3749
-
3750
-
3751
- function processNewValue(value, ownerSupport) {
3752
- const valueType = (0,_processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.getValueType)(value);
3753
- switch (valueType) {
3754
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.tagComponent:
3755
- const tagSubject = new _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_0__.ValueSubject(value);
3756
- return tagSubject;
3757
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.templater:
3758
- const templater = value;
3759
- const tag = templater.tag;
3760
- return processNewTag(tag, ownerSupport);
3761
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.tag:
3762
- return processNewTag(value, ownerSupport);
3763
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.subject:
3764
- return value;
3765
- }
3766
- return new _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_0__.ValueSubject(value);
3767
- }
3768
- function processNewTag(value, ownerSupport) {
3769
- const tag = value;
3770
- let templater = tag.templater;
3771
- if (!templater) {
3772
- templater = new _TemplaterResult_class__WEBPACK_IMPORTED_MODULE_1__.TemplaterResult([]);
3773
- templater.tag = tag;
3774
- tag.templater = templater;
3775
- }
3776
- const subject = new _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_0__.ValueSubject(templater);
3777
- subject.tagSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_2__.TagSupport(templater, ownerSupport, subject);
3778
- return subject;
3779
- }
3780
-
3781
-
3782
- /***/ }),
3783
-
3784
- /***/ "./ts/tag/update/processRegularValue.function.ts":
3785
- /*!*******************************************************!*\
3786
- !*** ./ts/tag/update/processRegularValue.function.ts ***!
3787
- \*******************************************************/
3788
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3789
-
3790
- __webpack_require__.r(__webpack_exports__);
3791
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3792
- /* harmony export */ processFirstRegularValue: () => (/* binding */ processFirstRegularValue),
3793
- /* harmony export */ processRegularValue: () => (/* binding */ processRegularValue)
3794
- /* harmony export */ });
3795
- /* harmony import */ var _updateBeforeTemplate_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../updateBeforeTemplate.function */ "./ts/updateBeforeTemplate.function.ts");
3796
-
3797
- function processRegularValue(value, subject, // could be tag via subject.tag
3798
- insertBefore) {
3799
- subject.insertBefore = insertBefore;
3800
- const before = subject.clone || insertBefore; // Either the template is on the doc OR its the first element we last put on doc
3801
- // matches but also was defined at some point
3802
- if (subject.lastValue === value && 'lastValue' in subject) {
3803
- return; // no need to update display, its the same
3804
- }
3805
- subject.lastValue = value;
3806
- const castedValue = (0,_updateBeforeTemplate_function__WEBPACK_IMPORTED_MODULE_0__.castTextValue)(value);
3807
- // replace existing string?
3808
- const oldClone = subject.clone;
3809
- if (oldClone) {
3810
- oldClone.textContent = castedValue;
3811
- return;
3812
- }
3813
- // Processing of regular values
3814
- const clone = (0,_updateBeforeTemplate_function__WEBPACK_IMPORTED_MODULE_0__.updateBeforeTemplate)(castedValue, before);
3815
- subject.clone = clone; // remember single element put down, for future updates
3816
- }
3817
- function processFirstRegularValue(value, subject, // could be tag via subject.tag
3818
- insertBefore) {
3819
- subject.lastValue = value;
3820
- const castedValue = (0,_updateBeforeTemplate_function__WEBPACK_IMPORTED_MODULE_0__.castTextValue)(value);
3821
- // Processing of regular values
3822
- const clone = (0,_updateBeforeTemplate_function__WEBPACK_IMPORTED_MODULE_0__.updateBeforeTemplate)(castedValue, insertBefore);
3823
- subject.clone = clone; // remember single element put down, for future updates
3824
- }
3825
-
3826
-
3827
- /***/ }),
3828
-
3829
- /***/ "./ts/tag/update/processSubjectComponent.function.ts":
3830
- /*!***********************************************************!*\
3831
- !*** ./ts/tag/update/processSubjectComponent.function.ts ***!
3832
- \***********************************************************/
3833
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3834
-
3835
- __webpack_require__.r(__webpack_exports__);
3836
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3837
- /* harmony export */ processSubjectComponent: () => (/* binding */ processSubjectComponent)
3838
- /* harmony export */ });
3839
- /* harmony import */ var _state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../state */ "./ts/state/index.ts");
3840
- /* harmony import */ var _processTagResult_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./processTagResult.function */ "./ts/tag/update/processTagResult.function.ts");
3841
- /* harmony import */ var _TagSupport_class__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../TagSupport.class */ "./ts/tag/TagSupport.class.ts");
3842
- /* harmony import */ var _render_renderSubjectComponent_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../render/renderSubjectComponent.function */ "./ts/tag/render/renderSubjectComponent.function.ts");
3843
-
3844
-
3845
-
3846
-
3847
- function processSubjectComponent(templater, subject, insertBefore, ownerSupport, options) {
3848
- // Check if function component is wrapped in a tag() call
3849
- // TODO: This below check not needed in production mode
3850
- if (templater.tagged !== true) {
3851
- const wrapper = templater.wrapper;
3852
- const original = wrapper.parentWrap.original;
3853
- let name = original.name || original.constructor?.name;
3854
- if (name === 'Function') {
3855
- name = undefined;
3856
- }
3857
- const label = name || original.toString().substring(0, 120);
3858
- const error = new Error(`Not a tag component. Wrap your function with tag(). Example tag(props => html\`\`) on component:\n\n${label}\n\n`);
3859
- throw error;
3860
- }
3861
- const tagSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_2__.TagSupport(templater, ownerSupport, subject);
3862
- let reSupport = subject.tagSupport;
3863
- const global = tagSupport.global = reSupport?.global || tagSupport.global;
3864
- global.insertBefore = insertBefore;
3865
- const providers = _state__WEBPACK_IMPORTED_MODULE_0__.setUse.memory.providerConfig;
3866
- providers.ownerSupport = ownerSupport;
3867
- const isRender = !reSupport;
3868
- if (isRender) {
3869
- const support = reSupport || tagSupport;
3870
- reSupport = (0,_render_renderSubjectComponent_function__WEBPACK_IMPORTED_MODULE_3__.renderSubjectComponent)(subject, support, ownerSupport);
3871
- }
3872
- (0,_processTagResult_function__WEBPACK_IMPORTED_MODULE_1__.processTagResult)(reSupport, subject, // The element set here will be removed from document. Also result.tag will be added in here
3873
- insertBefore, // <template end interpolate /> (will be removed)
3874
- options);
3875
- return reSupport;
3876
- }
3877
-
3878
-
3879
- /***/ }),
3880
-
3881
- /***/ "./ts/tag/update/processTag.function.ts":
3882
- /*!**********************************************!*\
3883
- !*** ./ts/tag/update/processTag.function.ts ***!
3884
- \**********************************************/
3885
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3886
-
3887
- __webpack_require__.r(__webpack_exports__);
3888
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3889
- /* harmony export */ getFakeTemplater: () => (/* binding */ getFakeTemplater),
3890
- /* harmony export */ processTag: () => (/* binding */ processTag),
3891
- /* harmony export */ setupNewTemplater: () => (/* binding */ setupNewTemplater),
3892
- /* harmony export */ tagFakeTemplater: () => (/* binding */ tagFakeTemplater)
3893
- /* harmony export */ });
3894
- /* harmony import */ var _TagSupport_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../TagSupport.class */ "./ts/tag/TagSupport.class.ts");
3895
- /* harmony import */ var _subject__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../subject */ "./ts/subject/index.ts");
3896
-
3897
-
3898
- /** Could be a regular tag or a component. Both are Tag.class */
3899
- function processTag(templater, insertBefore, ownerSupport, // owner
3900
- subject) {
3901
- let tagSupport = subject.tagSupport;
3902
- // first time seeing this tag?
3903
- if (!tagSupport) {
3904
- tagSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_0__.TagSupport(templater, ownerSupport, subject);
3905
- setupNewTemplater(tagSupport, ownerSupport, subject);
3906
- ownerSupport.childTags.push(tagSupport);
3907
- }
3908
- subject.tagSupport = tagSupport;
3909
- tagSupport.ownerTagSupport = ownerSupport;
3910
- tagSupport.buildBeforeElement(insertBefore, {
3911
- counts: { added: 0, removed: 0 },
3912
- });
3913
- }
3914
- function setupNewTemplater(tagSupport, ownerSupport, subject) {
3915
- tagSupport.global.oldest = tagSupport;
3916
- tagSupport.global.newest = tagSupport;
3917
- // asking me to render will cause my parent to render
3918
- tagSupport.ownerTagSupport = ownerSupport;
3919
- subject.tagSupport = tagSupport;
3920
- }
3921
- function tagFakeTemplater(tag) {
3922
- const templater = getFakeTemplater();
3923
- templater.tag = tag;
3924
- tag.templater = templater;
3925
- return templater;
3926
- }
3927
- function getFakeTemplater() {
3928
- const fake = {
3929
- children: new _subject__WEBPACK_IMPORTED_MODULE_1__.ValueSubject([]), // no children
3930
- // props: {} as Props,
3931
- props: [],
3932
- isTag: true,
3933
- isTemplater: false,
3934
- tagged: false,
3935
- madeChildIntoSubject: false,
3936
- html: () => fake
3937
- };
3938
- return fake;
3939
- }
3940
-
3941
-
3942
- /***/ }),
3943
-
3944
- /***/ "./ts/tag/update/processTagArray.ts":
3945
- /*!******************************************!*\
3946
- !*** ./ts/tag/update/processTagArray.ts ***!
3947
- \******************************************/
3948
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3949
-
3950
- __webpack_require__.r(__webpack_exports__);
3951
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3952
- /* harmony export */ processTagArray: () => (/* binding */ processTagArray)
3953
- /* harmony export */ });
3954
- /* harmony import */ var _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../subject/ValueSubject */ "./ts/subject/ValueSubject.ts");
3955
- /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../errors */ "./ts/errors.ts");
3956
- /* harmony import */ var _checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../checkDestroyPrevious.function */ "./ts/tag/checkDestroyPrevious.function.ts");
3957
- /* harmony import */ var _processTag_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./processTag.function */ "./ts/tag/update/processTag.function.ts");
3958
- /* harmony import */ var _TagSupport_class__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../TagSupport.class */ "./ts/tag/TagSupport.class.ts");
3959
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../isInstance */ "./ts/isInstance.ts");
3960
-
3961
-
3962
-
3963
-
3964
-
3965
-
3966
- function processTagArray(subject, value, // arry of Tag classes
3967
- insertBefore, // <template end interpolate />
3968
- ownerSupport, options) {
3969
- const clones = ownerSupport.clones; // []
3970
- let lastArray = subject.lastArray = subject.lastArray || [];
3971
- if (!subject.placeholder) {
3972
- setPlaceholderElm(insertBefore, subject);
3973
- }
3974
- const runtimeInsertBefore = subject.placeholder; // || insertBefore
3975
- let removed = 0;
3976
- /** 🗑️ remove previous items first */
3977
- lastArray = subject.lastArray = subject.lastArray.filter((item, index) => {
3978
- const newLength = value.length - 1;
3979
- const at = index - removed;
3980
- const lessLength = newLength < at;
3981
- const subValue = value[index - removed];
3982
- const subTag = subValue;
3983
- // const tag = subTag?.templater.tag as Tag
3984
- const lastTag = item.tagSupport.templater.tag;
3985
- const newArrayValue = subTag?.memory.arrayValue;
3986
- const lastArrayValue = lastTag.memory.arrayValue;
3987
- const destroyItem = lessLength || !areLikeValues(newArrayValue, lastArrayValue);
3988
- if (destroyItem) {
3989
- const last = lastArray[index];
3990
- const tagSupport = last.tagSupport;
3991
- (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_2__.destroyArrayTag)(tagSupport, options.counts);
3992
- last.deleted = true;
3993
- ++removed;
3994
- ++options.counts.removed;
3995
- return false;
3996
- }
3997
- return true;
3998
- });
3999
- const length = value.length;
4000
- for (let index = 0; index < length; ++index) {
4001
- const item = value[index];
4002
- const previous = lastArray[index];
4003
- const previousSupport = previous?.tagSupport;
4004
- const subTag = item;
4005
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_5__.isTagClass)(subTag) && !subTag.templater) {
4006
- (0,_processTag_function__WEBPACK_IMPORTED_MODULE_3__.tagFakeTemplater)(subTag);
4007
- }
4008
- const tagSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_4__.TagSupport(subTag.templater, ownerSupport, new _subject_ValueSubject__WEBPACK_IMPORTED_MODULE_0__.ValueSubject(undefined));
4009
- if (previousSupport) {
4010
- (0,_processTag_function__WEBPACK_IMPORTED_MODULE_3__.setupNewTemplater)(tagSupport, ownerSupport, previousSupport.subject);
4011
- const global = previousSupport.global;
4012
- tagSupport.global = global;
4013
- global.newest = tagSupport;
4014
- }
4015
- // check for html``.key()
4016
- const keySet = 'arrayValue' in subTag.memory;
4017
- if (!keySet) {
4018
- const details = {
4019
- template: tagSupport.getTemplate().string,
4020
- array: value,
4021
- };
4022
- const message = 'Use html`...`.key(item) instead of html`...` to template an Array';
4023
- console.error(message, details);
4024
- const err = new _errors__WEBPACK_IMPORTED_MODULE_1__.ArrayNoKeyError(message, details);
4025
- throw err;
4026
- }
4027
- const couldBeSame = lastArray.length > index;
4028
- if (couldBeSame) {
4029
- const prevSupport = previous.tagSupport;
4030
- const prevGlobal = prevSupport.global;
4031
- // subTag.tagSupport = subTag.tagSupport || prevSupport
4032
- const oldest = prevGlobal.oldest;
4033
- oldest.updateBy(tagSupport);
4034
- // return []
4035
- continue;
4036
- }
4037
- processAddTagArrayItem(runtimeInsertBefore, tagSupport, index, options, lastArray);
4038
- ownerSupport.childTags.push(tagSupport);
4039
- }
4040
- return clones;
4041
- }
4042
- function setPlaceholderElm(insertBefore, subject) {
4043
- if (insertBefore.nodeName !== 'TEMPLATE') {
4044
- subject.placeholder = insertBefore;
4045
- return;
4046
- }
4047
- const placeholder = subject.placeholder = document.createTextNode('');
4048
- const parentNode = insertBefore.parentNode;
4049
- parentNode.insertBefore(placeholder, insertBefore);
4050
- parentNode.removeChild(insertBefore);
4051
- }
4052
- function processAddTagArrayItem(before, tagSupport, index, options, lastArray) {
4053
- const lastValue = {
4054
- tagSupport, index
4055
- };
4056
- // Added to previous array
4057
- lastArray.push(lastValue);
4058
- const counts = {
4059
- added: options.counts.added + index,
4060
- removed: options.counts.removed,
4061
- };
4062
- const fragment = document.createDocumentFragment();
4063
- const newTempElm = document.createElement('template');
4064
- fragment.appendChild(newTempElm);
4065
- tagSupport.buildBeforeElement(newTempElm, // before,
4066
- { counts });
4067
- const parent = before.parentNode;
4068
- parent.insertBefore(fragment, before);
4069
- }
4070
- /** compare two values. If both values are arrays then the items will be compared */
4071
- function areLikeValues(valueA, valueB) {
4072
- if (valueA === valueB) {
4073
- return true;
4074
- }
4075
- const bothArrays = valueA instanceof Array && valueB instanceof Array;
4076
- const matchLengths = bothArrays && valueA.length == valueB.length;
4077
- if (matchLengths) {
4078
- return valueA.every((item, index) => item == valueB[index]);
4079
- }
4080
- return false;
4081
- }
4082
-
4083
-
4084
- /***/ }),
4085
-
4086
- /***/ "./ts/tag/update/processTagResult.function.ts":
4087
- /*!****************************************************!*\
4088
- !*** ./ts/tag/update/processTagResult.function.ts ***!
4089
- \****************************************************/
4090
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4091
-
4092
- __webpack_require__.r(__webpack_exports__);
4093
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4094
- /* harmony export */ processTagResult: () => (/* binding */ processTagResult)
4095
- /* harmony export */ });
4096
- function processTagResult(tagSupport, subject, // used for recording past and current value
4097
- insertBefore, // <template end interpolate />
4098
- { counts, }) {
4099
- // *if appears we already have seen
4100
- const subjectTag = subject;
4101
- const lastSupport = subjectTag.tagSupport;
4102
- const prevSupport = lastSupport?.global.oldest || undefined;
4103
- const justUpdate = prevSupport;
4104
- if (prevSupport && justUpdate) {
4105
- return processTagResultUpdate(tagSupport, subjectTag, prevSupport);
4106
- }
4107
- tagSupport.buildBeforeElement(insertBefore, {
4108
- counts,
4109
- });
4110
- }
4111
- function processTagResultUpdate(tagSupport, subject, // used for recording past and current value
4112
- prevSupport) {
4113
- // components
4114
- if (subject instanceof Function) {
4115
- const newSupport = subject(prevSupport);
4116
- prevSupport.updateBy(newSupport);
4117
- subject.tagSupport = newSupport;
4118
- return;
4119
- }
4120
- prevSupport.updateBy(tagSupport);
4121
- subject.tagSupport = tagSupport;
4122
- return;
4123
- }
4124
-
4125
-
4126
- /***/ }),
4127
-
4128
- /***/ "./ts/tag/update/updateContextItem.function.ts":
4129
- /*!*****************************************************!*\
4130
- !*** ./ts/tag/update/updateContextItem.function.ts ***!
4131
- \*****************************************************/
4132
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4133
-
4134
- __webpack_require__.r(__webpack_exports__);
4135
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4136
- /* harmony export */ updateContextItem: () => (/* binding */ updateContextItem)
4137
- /* harmony export */ });
4138
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../isInstance */ "./ts/isInstance.ts");
4139
- /* harmony import */ var _TagSupport_class__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../TagSupport.class */ "./ts/tag/TagSupport.class.ts");
4140
-
4141
-
4142
- function updateContextItem(context, variableName, value) {
4143
- const subject = context[variableName];
4144
- const tagSubject = subject;
4145
- const tagSupport = tagSubject.tagSupport;
4146
- if (tagSupport) {
4147
- if (value) {
4148
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagComponent)(value)) {
4149
- const templater = value;
4150
- let newSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_1__.TagSupport(templater, tagSupport.ownerTagSupport, subject);
4151
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isTagComponent)(tagSupport)) {
4152
- shareTemplaterGlobal(tagSupport, newSupport);
4153
- }
4154
- }
4155
- }
4156
- }
4157
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_0__.isSubjectInstance)(value)) {
4158
- return; // emits on its own
4159
- }
4160
- // listeners will evaluate updated values to possibly update display(s)
4161
- subject.set(value);
4162
- return;
4163
- }
4164
- function shareTemplaterGlobal(oldTagSupport, tagSupport) {
4165
- const oldTemp = oldTagSupport.templater;
4166
- const oldWrap = oldTemp.wrapper; // tag versus component
4167
- const oldValueFn = oldWrap.parentWrap.original;
4168
- const templater = tagSupport.templater;
4169
- const newWrapper = templater.wrapper;
4170
- const newValueFn = newWrapper?.parentWrap.original;
4171
- const fnMatched = oldValueFn === newValueFn;
4172
- if (fnMatched) {
4173
- tagSupport.global = oldTagSupport.global;
4174
- const newest = oldTagSupport.global.newest;
4175
- if (newest) {
4176
- const prevState = newest.memory.state;
4177
- tagSupport.memory.state.length = 0;
4178
- tagSupport.memory.state.push(...prevState);
4179
- // tagSupport.memory.state = [...prevState]
4180
- }
4181
- }
4182
- }
4183
-
4184
-
4185
- /***/ }),
4186
-
4187
- /***/ "./ts/tag/update/updateExistingTagComponent.function.ts":
4188
- /*!**************************************************************!*\
4189
- !*** ./ts/tag/update/updateExistingTagComponent.function.ts ***!
4190
- \**************************************************************/
4191
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4192
-
4193
- __webpack_require__.r(__webpack_exports__);
4194
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4195
- /* harmony export */ updateExistingTagComponent: () => (/* binding */ updateExistingTagComponent)
4196
- /* harmony export */ });
4197
- /* harmony import */ var _hasTagSupportChanged_function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../hasTagSupportChanged.function */ "./ts/tag/hasTagSupportChanged.function.ts");
4198
- /* harmony import */ var _processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./processSubjectComponent.function */ "./ts/tag/update/processSubjectComponent.function.ts");
4199
- /* harmony import */ var _destroyTag_function__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../destroyTag.function */ "./ts/tag/destroyTag.function.ts");
4200
- /* harmony import */ var _render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../render/renderTagSupport.function */ "./ts/tag/render/renderTagSupport.function.ts");
4201
- /* harmony import */ var _alterProps_function__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../alterProps.function */ "./ts/alterProps.function.ts");
4202
- /* harmony import */ var _isLikeTags_function__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../isLikeTags.function */ "./ts/tag/isLikeTags.function.ts");
4203
-
4204
-
4205
-
4206
-
4207
-
4208
-
4209
- function updateExistingTagComponent(ownerSupport, tagSupport, // lastest
4210
- subject, insertBefore) {
4211
- let lastSupport = subject.tagSupport?.global.newest; // || subject.tagSupport
4212
- let oldestTag = lastSupport.global.oldest;
4213
- const oldWrapper = lastSupport.templater.wrapper;
4214
- const newWrapper = tagSupport.templater.wrapper;
4215
- let isSameTag = false;
4216
- if (oldWrapper && newWrapper) {
4217
- const oldFunction = oldWrapper.parentWrap.original;
4218
- const newFunction = newWrapper.parentWrap.original;
4219
- // string compare both functions
4220
- isSameTag = oldFunction === newFunction;
4221
- }
4222
- const templater = tagSupport.templater;
4223
- if (!isSameTag) {
4224
- const oldestSupport = lastSupport.global.oldest;
4225
- (0,_destroyTag_function__WEBPACK_IMPORTED_MODULE_2__.destroyTagMemory)(oldestSupport);
4226
- return (0,_processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_1__.processSubjectComponent)(templater, subject, insertBefore, ownerSupport, {
4227
- counts: { added: 0, removed: 0 },
4228
- });
4229
- }
4230
- else {
4231
- const hasChanged = (0,_hasTagSupportChanged_function__WEBPACK_IMPORTED_MODULE_0__.hasTagSupportChanged)(lastSupport, tagSupport, templater);
4232
- if (!hasChanged) {
4233
- // if the new props are an object then implicitly since no change, the old props are an object
4234
- const newProps = templater.props;
4235
- syncFunctionProps(lastSupport, ownerSupport, newProps);
4236
- return lastSupport; // its the same tag component
4237
- }
4238
- }
4239
- const previous = lastSupport.global.newest;
4240
- const newSupport = (0,_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_3__.renderTagSupport)(tagSupport, false);
4241
- lastSupport = subject.tagSupport;
4242
- const newOldest = newSupport.global.oldest;
4243
- const hasOldest = newOldest ? true : false;
4244
- if (!hasOldest) {
4245
- return buildNewTag(newSupport, insertBefore, lastSupport, subject);
4246
- }
4247
- if (newOldest && templater.children.value.length) {
4248
- const oldKidsSub = newOldest.templater.children;
4249
- oldKidsSub.set(templater.children.value);
4250
- }
4251
- // detect if both the function is the same and the return is the same
4252
- const isLikeTag = isSameTag && (0,_isLikeTags_function__WEBPACK_IMPORTED_MODULE_5__.isLikeTags)(previous, newSupport);
4253
- if (isLikeTag) {
4254
- subject.tagSupport = newSupport;
4255
- oldestTag.updateBy(newSupport); // the oldest tag has element references
4256
- return newSupport;
4257
- }
4258
- else {
4259
- // Although function looked the same it returned a different html result
4260
- if (isSameTag && lastSupport) {
4261
- (0,_destroyTag_function__WEBPACK_IMPORTED_MODULE_2__.destroyTagMemory)(lastSupport);
4262
- newSupport.global.context = {}; // do not share previous outputs
4263
- }
4264
- oldestTag = undefined;
4265
- }
4266
- if (!oldestTag) {
4267
- lastSupport = newSupport;
4268
- buildNewTag(newSupport, lastSupport.global.insertBefore, lastSupport, subject);
4269
- }
4270
- lastSupport.global.newest = newSupport;
4271
- return newSupport;
4272
- }
4273
- function buildNewTag(newSupport, oldInsertBefore, oldTagSupport, subject) {
4274
- newSupport.buildBeforeElement(oldInsertBefore, {
4275
- counts: { added: 0, removed: 0 },
4276
- });
4277
- newSupport.global.oldest = newSupport;
4278
- newSupport.global.newest = newSupport;
4279
- oldTagSupport.global.oldest = newSupport;
4280
- oldTagSupport.global.newest = newSupport;
4281
- subject.tagSupport = newSupport;
4282
- return newSupport;
4283
- }
4284
- function syncFunctionProps(lastSupport, ownerSupport, newPropsArray) {
4285
- lastSupport = lastSupport.global.newest || lastSupport;
4286
- const priorPropConfig = lastSupport.propsConfig;
4287
- const priorPropsArray = priorPropConfig.latestCloned;
4288
- const prevSupport = ownerSupport.global.newest;
4289
- for (let index = newPropsArray.length - 1; index >= 0; --index) {
4290
- const argPosition = newPropsArray[index];
4291
- if (typeof (argPosition) !== 'object') {
4292
- return;
4293
- }
4294
- const priorProps = priorPropsArray[index];
4295
- if (typeof (priorProps) !== 'object') {
4296
- return;
4297
- }
4298
- for (const name in argPosition) {
4299
- const value = argPosition[name];
4300
- if (!(value instanceof Function)) {
4301
- continue;
4302
- }
4303
- const newCallback = argPosition[name]; // || value
4304
- const original = newCallback instanceof Function && newCallback.toCall;
4305
- if (original) {
4306
- continue; // already previously converted
4307
- }
4308
- // Currently, call self but over parent state changes, I may need to call a newer parent tag owner
4309
- priorProps[name].toCall = (...args) => {
4310
- return (0,_alterProps_function__WEBPACK_IMPORTED_MODULE_4__.callbackPropOwner)(newCallback, // value, // newOriginal,
4311
- args, prevSupport);
4312
- };
4313
- }
4314
- }
4315
- }
4316
-
4317
-
4318
- /***/ }),
4319
-
4320
- /***/ "./ts/tag/update/updateExistingValue.function.ts":
4321
- /*!*******************************************************!*\
4322
- !*** ./ts/tag/update/updateExistingValue.function.ts ***!
4323
- \*******************************************************/
4324
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4325
-
4326
- __webpack_require__.r(__webpack_exports__);
4327
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4328
- /* harmony export */ updateExistingValue: () => (/* binding */ updateExistingValue)
4329
- /* harmony export */ });
4330
- /* harmony import */ var _TagSupport_class__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../TagSupport.class */ "./ts/tag/TagSupport.class.ts");
4331
- /* harmony import */ var _TemplaterResult_class__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../TemplaterResult.class */ "./ts/TemplaterResult.class.ts");
4332
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../isInstance */ "./ts/isInstance.ts");
4333
- /* harmony import */ var _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./processFirstSubject.utils */ "./ts/tag/update/processFirstSubject.utils.ts");
4334
- /* harmony import */ var _processTagArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./processTagArray */ "./ts/tag/update/processTagArray.ts");
4335
- /* harmony import */ var _updateExistingTagComponent_function__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./updateExistingTagComponent.function */ "./ts/tag/update/updateExistingTagComponent.function.ts");
4336
- /* harmony import */ var _processRegularValue_function__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./processRegularValue.function */ "./ts/tag/update/processRegularValue.function.ts");
4337
- /* harmony import */ var _checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../checkDestroyPrevious.function */ "./ts/tag/checkDestroyPrevious.function.ts");
4338
- /* harmony import */ var _processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./processSubjectComponent.function */ "./ts/tag/update/processSubjectComponent.function.ts");
4339
- /* harmony import */ var _isLikeTags_function__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../isLikeTags.function */ "./ts/tag/isLikeTags.function.ts");
4340
- /* harmony import */ var _processTag_function__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./processTag.function */ "./ts/tag/update/processTag.function.ts");
4341
- /* harmony import */ var _setTagPlaceholder_function__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../setTagPlaceholder.function */ "./ts/tag/setTagPlaceholder.function.ts");
4342
-
4343
-
4344
-
4345
-
4346
-
4347
-
4348
-
4349
-
4350
-
4351
-
4352
-
4353
-
4354
- function updateExistingValue(subject, value, ownerSupport, insertBefore) {
4355
- const subjectTag = subject;
4356
- const valueType = (0,_processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.getValueType)(value);
4357
- (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_7__.checkDestroyPrevious)(subject, value, insertBefore);
4358
- // handle already seen tag components
4359
- if (valueType === _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.tagComponent) {
4360
- return prepareUpdateToComponent(value, subjectTag, insertBefore, ownerSupport);
4361
- }
4362
- // was component but no longer
4363
- const tagSupport = subjectTag.tagSupport;
4364
- if (tagSupport) {
4365
- handleStillTag(subject, value, ownerSupport);
4366
- return subjectTag;
4367
- }
4368
- switch (valueType) {
4369
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.tagArray:
4370
- (0,_processTagArray__WEBPACK_IMPORTED_MODULE_4__.processTagArray)(subject, value, insertBefore, // oldInsertBefore as InsertBefore,
4371
- ownerSupport, { counts: {
4372
- added: 0,
4373
- removed: 0,
4374
- } });
4375
- return subject;
4376
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.templater:
4377
- (0,_processTag_function__WEBPACK_IMPORTED_MODULE_10__.processTag)(value, insertBefore, ownerSupport, subjectTag);
4378
- return subjectTag;
4379
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.tag:
4380
- const tag = value;
4381
- let templater = tag.templater;
4382
- if (!templater) {
4383
- templater = (0,_processTag_function__WEBPACK_IMPORTED_MODULE_10__.getFakeTemplater)();
4384
- tag.templater = templater;
4385
- templater.tag = tag;
4386
- }
4387
- (0,_processTag_function__WEBPACK_IMPORTED_MODULE_10__.processTag)(templater, insertBefore, ownerSupport, subjectTag);
4388
- return subjectTag;
4389
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.subject:
4390
- return value;
4391
- // now its a useless function (we don't automatically call functions)
4392
- case _processFirstSubject_utils__WEBPACK_IMPORTED_MODULE_3__.ValueTypes.function:
4393
- // const bound = bindSubjectCallback(value as Callback, ownerSupport)
4394
- // subject.set(bound)
4395
- if (!subject.clone) {
4396
- subject.clone = (0,_setTagPlaceholder_function__WEBPACK_IMPORTED_MODULE_11__.swapInsertBefore)(insertBefore);
4397
- }
4398
- return subject;
4399
- }
4400
- // This will cause all other values to render
4401
- (0,_processRegularValue_function__WEBPACK_IMPORTED_MODULE_6__.processRegularValue)(value, subject, insertBefore);
4402
- return subjectTag;
4403
- }
4404
- function handleStillTag(subject, value, ownerSupport) {
4405
- const lastSupport = subject.tagSupport;
4406
- let templater = value;
4407
- const isClass = (0,_isInstance__WEBPACK_IMPORTED_MODULE_2__.isTagClass)(value);
4408
- if (isClass) {
4409
- const tag = value;
4410
- templater = tag.templater;
4411
- if (!templater) {
4412
- templater = new _TemplaterResult_class__WEBPACK_IMPORTED_MODULE_1__.TemplaterResult([]);
4413
- templater.tag = tag;
4414
- tag.templater = templater;
4415
- }
4416
- }
4417
- const valueSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_0__.TagSupport(templater, ownerSupport, subject);
4418
- if (isClass) {
4419
- valueSupport.global = lastSupport.global;
4420
- }
4421
- const isSameTag = value && (0,_isLikeTags_function__WEBPACK_IMPORTED_MODULE_9__.isLikeTags)(lastSupport, valueSupport);
4422
- if ((0,_isInstance__WEBPACK_IMPORTED_MODULE_2__.isTagTemplater)(value)) {
4423
- (0,_processTag_function__WEBPACK_IMPORTED_MODULE_10__.setupNewTemplater)(valueSupport, ownerSupport, subject);
4424
- }
4425
- if (isSameTag) {
4426
- lastSupport.updateBy(valueSupport);
4427
- return;
4428
- }
4429
- if (isSameTag) {
4430
- // const subjectTag = subject as TagSubject
4431
- const global = lastSupport.global;
4432
- const insertBefore = global.insertBefore;
4433
- return (0,_processTag_function__WEBPACK_IMPORTED_MODULE_10__.processTag)(templater, insertBefore, ownerSupport, subject);
4434
- }
4435
- return (0,_processRegularValue_function__WEBPACK_IMPORTED_MODULE_6__.processRegularValue)(value, subject, subject.insertBefore);
4436
- }
4437
- function prepareUpdateToComponent(templater, subjectTag, insertBefore, ownerSupport) {
4438
- // When last value was not a component
4439
- if (!subjectTag.tagSupport) {
4440
- (0,_processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_8__.processSubjectComponent)(templater, subjectTag, insertBefore, // oldInsertBefore as InsertBefore,
4441
- ownerSupport, {
4442
- counts: { added: 0, removed: 0 },
4443
- });
4444
- return subjectTag;
4445
- }
4446
- const tagSupport = new _TagSupport_class__WEBPACK_IMPORTED_MODULE_0__.TagSupport(templater, ownerSupport, subjectTag);
4447
- const subjectSup = subjectTag.tagSupport;
4448
- const prevSupport = subjectSup.global.newest;
4449
- if (prevSupport) {
4450
- const newestState = prevSupport.memory.state;
4451
- tagSupport.memory.state.length = 0;
4452
- tagSupport.memory.state.push(...newestState);
4453
- }
4454
- else {
4455
- (0,_checkDestroyPrevious_function__WEBPACK_IMPORTED_MODULE_7__.restoreTagMarker)(subjectSup);
4456
- (0,_processSubjectComponent_function__WEBPACK_IMPORTED_MODULE_8__.processSubjectComponent)(templater, subjectTag, insertBefore, ownerSupport, {
4457
- counts: { added: 0, removed: 0 },
4458
- });
4459
- return subjectTag;
4460
- }
4461
- tagSupport.global = subjectSup.global;
4462
- subjectTag.tagSupport = tagSupport;
4463
- (0,_updateExistingTagComponent_function__WEBPACK_IMPORTED_MODULE_5__.updateExistingTagComponent)(ownerSupport, tagSupport, // latest value
4464
- subjectTag, insertBefore);
4465
- return subjectTag;
4466
- }
4467
-
4468
-
4469
- /***/ }),
4470
-
4471
- /***/ "./ts/updateBeforeTemplate.function.ts":
4472
- /*!*********************************************!*\
4473
- !*** ./ts/updateBeforeTemplate.function.ts ***!
4474
- \*********************************************/
4475
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4476
-
4477
- __webpack_require__.r(__webpack_exports__);
4478
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4479
- /* harmony export */ castTextValue: () => (/* binding */ castTextValue),
4480
- /* harmony export */ updateBeforeTemplate: () => (/* binding */ updateBeforeTemplate)
4481
- /* harmony export */ });
4482
- // Function to update the value of x
4483
- function updateBeforeTemplate(value, // value should be casted before calling here
4484
- lastFirstChild) {
4485
- const parent = lastFirstChild.parentNode;
4486
- // Insert the new value (never use innerHTML here)
4487
- const textNode = document.createTextNode(value); // never innerHTML
4488
- parent.insertBefore(textNode, lastFirstChild);
4489
- /* remove existing nodes */
4490
- parent.removeChild(lastFirstChild);
4491
- return textNode;
4492
- }
4493
- function castTextValue(value) {
4494
- // mimic React skipping to display EXCEPT for true does display on page
4495
- if ([undefined, false, null].includes(value)) { // || value === true
4496
- return '';
4497
- }
4498
- return value;
4499
- }
4500
-
4501
-
4502
- /***/ })
4503
-
4504
- /******/ });
4505
- /************************************************************************/
4506
- /******/ // The module cache
4507
- /******/ var __webpack_module_cache__ = {};
4508
- /******/
4509
- /******/ // The require function
4510
- /******/ function __webpack_require__(moduleId) {
4511
- /******/ // Check if module is in cache
4512
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
4513
- /******/ if (cachedModule !== undefined) {
4514
- /******/ return cachedModule.exports;
4515
- /******/ }
4516
- /******/ // Create a new module (and put it into the cache)
4517
- /******/ var module = __webpack_module_cache__[moduleId] = {
4518
- /******/ // no module.id needed
4519
- /******/ // no module.loaded needed
4520
- /******/ exports: {}
4521
- /******/ };
4522
- /******/
4523
- /******/ // Execute the module function
4524
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
4525
- /******/
4526
- /******/ // Return the exports of the module
4527
- /******/ return module.exports;
4528
- /******/ }
4529
- /******/
4530
- /************************************************************************/
4531
- /******/ /* webpack/runtime/define property getters */
4532
- /******/ (() => {
4533
- /******/ // define getter functions for harmony exports
4534
- /******/ __webpack_require__.d = (exports, definition) => {
4535
- /******/ for(var key in definition) {
4536
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
4537
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
4538
- /******/ }
4539
- /******/ }
4540
- /******/ };
4541
- /******/ })();
4542
- /******/
4543
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
4544
- /******/ (() => {
4545
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
4546
- /******/ })();
4547
- /******/
4548
- /******/ /* webpack/runtime/make namespace object */
4549
- /******/ (() => {
4550
- /******/ // define __esModule on exports
4551
- /******/ __webpack_require__.r = (exports) => {
4552
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
4553
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4554
- /******/ }
4555
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
4556
- /******/ };
4557
- /******/ })();
4558
- /******/
4559
- /************************************************************************/
4560
- var __webpack_exports__ = {};
4561
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
4562
- (() => {
4563
- /*!*********************!*\
4564
- !*** ./ts/index.ts ***!
4565
- \*********************/
4566
- __webpack_require__.r(__webpack_exports__);
4567
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4568
- /* harmony export */ ArrayNoKeyError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_2__.ArrayNoKeyError),
4569
- /* harmony export */ BaseTagSupport: () => (/* reexport safe */ _tag_TagSupport_class__WEBPACK_IMPORTED_MODULE_6__.BaseTagSupport),
4570
- /* harmony export */ StateMismatchError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_2__.StateMismatchError),
4571
- /* harmony export */ Subject: () => (/* reexport safe */ _subject_index__WEBPACK_IMPORTED_MODULE_5__.Subject),
4572
- /* harmony export */ SyncCallbackError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_2__.SyncCallbackError),
4573
- /* harmony export */ Tag: () => (/* reexport safe */ _tag_Tag_class__WEBPACK_IMPORTED_MODULE_10__.Tag),
4574
- /* harmony export */ TagError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_2__.TagError),
4575
- /* harmony export */ TagSupport: () => (/* reexport safe */ _tag_TagSupport_class__WEBPACK_IMPORTED_MODULE_6__.TagSupport),
4576
- /* harmony export */ ValueSubject: () => (/* reexport safe */ _subject_index__WEBPACK_IMPORTED_MODULE_5__.ValueSubject),
4577
- /* harmony export */ callback: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.callback),
4578
- /* harmony export */ callbackMaker: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.callbackMaker),
4579
- /* harmony export */ children: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.children),
4580
- /* harmony export */ combineLatest: () => (/* reexport safe */ _subject_index__WEBPACK_IMPORTED_MODULE_5__.combineLatest),
4581
- /* harmony export */ hmr: () => (/* binding */ hmr),
4582
- /* harmony export */ html: () => (/* reexport safe */ _tag_html__WEBPACK_IMPORTED_MODULE_1__.html),
4583
- /* harmony export */ interpolateElement: () => (/* reexport safe */ _interpolations_interpolateElement__WEBPACK_IMPORTED_MODULE_8__.interpolateElement),
4584
- /* harmony export */ interpolateString: () => (/* reexport safe */ _interpolations_interpolateElement__WEBPACK_IMPORTED_MODULE_8__.interpolateString),
4585
- /* harmony export */ isLikeValueSets: () => (/* reexport safe */ _tag_isLikeTags_function__WEBPACK_IMPORTED_MODULE_14__.isLikeValueSets),
4586
- /* harmony export */ isSubjectInstance: () => (/* reexport safe */ _isInstance__WEBPACK_IMPORTED_MODULE_3__.isSubjectInstance),
4587
- /* harmony export */ isTag: () => (/* reexport safe */ _isInstance__WEBPACK_IMPORTED_MODULE_3__.isTag),
4588
- /* harmony export */ isTagArray: () => (/* reexport safe */ _isInstance__WEBPACK_IMPORTED_MODULE_3__.isTagArray),
4589
- /* harmony export */ isTagClass: () => (/* reexport safe */ _isInstance__WEBPACK_IMPORTED_MODULE_3__.isTagClass),
4590
- /* harmony export */ isTagComponent: () => (/* reexport safe */ _isInstance__WEBPACK_IMPORTED_MODULE_3__.isTagComponent),
4591
- /* harmony export */ isTagTemplater: () => (/* reexport safe */ _isInstance__WEBPACK_IMPORTED_MODULE_3__.isTagTemplater),
4592
- /* harmony export */ kidsToTagArraySubject: () => (/* reexport safe */ _tag_tag__WEBPACK_IMPORTED_MODULE_0__.kidsToTagArraySubject),
4593
- /* harmony export */ letProp: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.letProp),
4594
- /* harmony export */ letState: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.letState),
4595
- /* harmony export */ onDestroy: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.onDestroy),
4596
- /* harmony export */ onInit: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.onInit),
4597
- /* harmony export */ providers: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.providers),
4598
- /* harmony export */ renderTagSupport: () => (/* reexport safe */ _tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_12__.renderTagSupport),
4599
- /* harmony export */ renderWithSupport: () => (/* reexport safe */ _tag_render_renderWithSupport_function__WEBPACK_IMPORTED_MODULE_13__.renderWithSupport),
4600
- /* harmony export */ runBeforeRender: () => (/* reexport safe */ _tag_tagRunner__WEBPACK_IMPORTED_MODULE_11__.runBeforeRender),
4601
- /* harmony export */ setUse: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.setUse),
4602
- /* harmony export */ state: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.state),
4603
- /* harmony export */ subject: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.subject),
4604
- /* harmony export */ tag: () => (/* reexport safe */ _tag_tag__WEBPACK_IMPORTED_MODULE_0__.tag),
4605
- /* harmony export */ tagElement: () => (/* reexport safe */ _tag_tagElement__WEBPACK_IMPORTED_MODULE_9__.tagElement),
4606
- /* harmony export */ tags: () => (/* reexport safe */ _tag_tag__WEBPACK_IMPORTED_MODULE_0__.tags),
4607
- /* harmony export */ watch: () => (/* reexport safe */ _state_index__WEBPACK_IMPORTED_MODULE_4__.watch),
4608
- /* harmony export */ willCallback: () => (/* reexport safe */ _subject_index__WEBPACK_IMPORTED_MODULE_5__.willCallback),
4609
- /* harmony export */ willPromise: () => (/* reexport safe */ _subject_index__WEBPACK_IMPORTED_MODULE_5__.willPromise),
4610
- /* harmony export */ willSubscribe: () => (/* reexport safe */ _subject_index__WEBPACK_IMPORTED_MODULE_5__.willSubscribe)
4611
- /* harmony export */ });
4612
- /* harmony import */ var _tag_tag__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tag/tag */ "./ts/tag/tag.ts");
4613
- /* harmony import */ var _tag_html__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tag/html */ "./ts/tag/html.ts");
4614
- /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./errors */ "./ts/errors.ts");
4615
- /* harmony import */ var _isInstance__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./isInstance */ "./ts/isInstance.ts");
4616
- /* harmony import */ var _state_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./state/index */ "./ts/state/index.ts");
4617
- /* harmony import */ var _subject_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./subject/index */ "./ts/subject/index.ts");
4618
- /* harmony import */ var _tag_TagSupport_class__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./tag/TagSupport.class */ "./ts/tag/TagSupport.class.ts");
4619
- /* harmony import */ var _interpolations_ElementTargetEvent_interface__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./interpolations/ElementTargetEvent.interface */ "./ts/interpolations/ElementTargetEvent.interface.ts");
4620
- /* harmony import */ var _interpolations_interpolateElement__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./interpolations/interpolateElement */ "./ts/interpolations/interpolateElement.ts");
4621
- /* harmony import */ var _tag_tagElement__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./tag/tagElement */ "./ts/tag/tagElement.ts");
4622
- /* harmony import */ var _tag_Tag_class__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./tag/Tag.class */ "./ts/tag/Tag.class.ts");
4623
- /* harmony import */ var _tag_tagRunner__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./tag/tagRunner */ "./ts/tag/tagRunner.ts");
4624
- /* harmony import */ var _tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./tag/render/renderTagSupport.function */ "./ts/tag/render/renderTagSupport.function.ts");
4625
- /* harmony import */ var _tag_render_renderWithSupport_function__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tag/render/renderWithSupport.function */ "./ts/tag/render/renderWithSupport.function.ts");
4626
- /* harmony import */ var _tag_isLikeTags_function__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tag/isLikeTags.function */ "./ts/tag/isLikeTags.function.ts");
4627
- /* harmony import */ var _tag_render_renderTagOnly_function__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./tag/render/renderTagOnly.function */ "./ts/tag/render/renderTagOnly.function.ts");
4628
-
4629
-
4630
-
4631
-
4632
-
4633
-
4634
-
4635
-
4636
-
4637
-
4638
-
4639
-
4640
-
4641
-
4642
-
4643
-
4644
-
4645
-
4646
-
4647
- const hmr = {
4648
- tagElement: _tag_tagElement__WEBPACK_IMPORTED_MODULE_9__.tagElement, renderWithSupport: _tag_render_renderWithSupport_function__WEBPACK_IMPORTED_MODULE_13__.renderWithSupport, renderTagSupport: _tag_render_renderTagSupport_function__WEBPACK_IMPORTED_MODULE_12__.renderTagSupport,
4649
- renderTagOnly: _tag_render_renderTagOnly_function__WEBPACK_IMPORTED_MODULE_15__.renderTagOnly,
4650
- };
4651
-
4652
- })();
4653
-
4654
- var __webpack_exports__ArrayNoKeyError = __webpack_exports__.ArrayNoKeyError;
4655
- var __webpack_exports__BaseTagSupport = __webpack_exports__.BaseTagSupport;
4656
- var __webpack_exports__StateMismatchError = __webpack_exports__.StateMismatchError;
4657
- var __webpack_exports__Subject = __webpack_exports__.Subject;
4658
- var __webpack_exports__SyncCallbackError = __webpack_exports__.SyncCallbackError;
4659
- var __webpack_exports__Tag = __webpack_exports__.Tag;
4660
- var __webpack_exports__TagError = __webpack_exports__.TagError;
4661
- var __webpack_exports__TagSupport = __webpack_exports__.TagSupport;
4662
- var __webpack_exports__ValueSubject = __webpack_exports__.ValueSubject;
4663
- var __webpack_exports__callback = __webpack_exports__.callback;
4664
- var __webpack_exports__callbackMaker = __webpack_exports__.callbackMaker;
4665
- var __webpack_exports__children = __webpack_exports__.children;
4666
- var __webpack_exports__combineLatest = __webpack_exports__.combineLatest;
4667
- var __webpack_exports__hmr = __webpack_exports__.hmr;
4668
- var __webpack_exports__html = __webpack_exports__.html;
4669
- var __webpack_exports__interpolateElement = __webpack_exports__.interpolateElement;
4670
- var __webpack_exports__interpolateString = __webpack_exports__.interpolateString;
4671
- var __webpack_exports__isLikeValueSets = __webpack_exports__.isLikeValueSets;
4672
- var __webpack_exports__isSubjectInstance = __webpack_exports__.isSubjectInstance;
4673
- var __webpack_exports__isTag = __webpack_exports__.isTag;
4674
- var __webpack_exports__isTagArray = __webpack_exports__.isTagArray;
4675
- var __webpack_exports__isTagClass = __webpack_exports__.isTagClass;
4676
- var __webpack_exports__isTagComponent = __webpack_exports__.isTagComponent;
4677
- var __webpack_exports__isTagTemplater = __webpack_exports__.isTagTemplater;
4678
- var __webpack_exports__kidsToTagArraySubject = __webpack_exports__.kidsToTagArraySubject;
4679
- var __webpack_exports__letProp = __webpack_exports__.letProp;
4680
- var __webpack_exports__letState = __webpack_exports__.letState;
4681
- var __webpack_exports__onDestroy = __webpack_exports__.onDestroy;
4682
- var __webpack_exports__onInit = __webpack_exports__.onInit;
4683
- var __webpack_exports__providers = __webpack_exports__.providers;
4684
- var __webpack_exports__renderTagSupport = __webpack_exports__.renderTagSupport;
4685
- var __webpack_exports__renderWithSupport = __webpack_exports__.renderWithSupport;
4686
- var __webpack_exports__runBeforeRender = __webpack_exports__.runBeforeRender;
4687
- var __webpack_exports__setUse = __webpack_exports__.setUse;
4688
- var __webpack_exports__state = __webpack_exports__.state;
4689
- var __webpack_exports__subject = __webpack_exports__.subject;
4690
- var __webpack_exports__tag = __webpack_exports__.tag;
4691
- var __webpack_exports__tagElement = __webpack_exports__.tagElement;
4692
- var __webpack_exports__tags = __webpack_exports__.tags;
4693
- var __webpack_exports__watch = __webpack_exports__.watch;
4694
- var __webpack_exports__willCallback = __webpack_exports__.willCallback;
4695
- var __webpack_exports__willPromise = __webpack_exports__.willPromise;
4696
- var __webpack_exports__willSubscribe = __webpack_exports__.willSubscribe;
4697
- export { __webpack_exports__ArrayNoKeyError as ArrayNoKeyError, __webpack_exports__BaseTagSupport as BaseTagSupport, __webpack_exports__StateMismatchError as StateMismatchError, __webpack_exports__Subject as Subject, __webpack_exports__SyncCallbackError as SyncCallbackError, __webpack_exports__Tag as Tag, __webpack_exports__TagError as TagError, __webpack_exports__TagSupport as TagSupport, __webpack_exports__ValueSubject as ValueSubject, __webpack_exports__callback as callback, __webpack_exports__callbackMaker as callbackMaker, __webpack_exports__children as children, __webpack_exports__combineLatest as combineLatest, __webpack_exports__hmr as hmr, __webpack_exports__html as html, __webpack_exports__interpolateElement as interpolateElement, __webpack_exports__interpolateString as interpolateString, __webpack_exports__isLikeValueSets as isLikeValueSets, __webpack_exports__isSubjectInstance as isSubjectInstance, __webpack_exports__isTag as isTag, __webpack_exports__isTagArray as isTagArray, __webpack_exports__isTagClass as isTagClass, __webpack_exports__isTagComponent as isTagComponent, __webpack_exports__isTagTemplater as isTagTemplater, __webpack_exports__kidsToTagArraySubject as kidsToTagArraySubject, __webpack_exports__letProp as letProp, __webpack_exports__letState as letState, __webpack_exports__onDestroy as onDestroy, __webpack_exports__onInit as onInit, __webpack_exports__providers as providers, __webpack_exports__renderTagSupport as renderTagSupport, __webpack_exports__renderWithSupport as renderWithSupport, __webpack_exports__runBeforeRender as runBeforeRender, __webpack_exports__setUse as setUse, __webpack_exports__state as state, __webpack_exports__subject as subject, __webpack_exports__tag as tag, __webpack_exports__tagElement as tagElement, __webpack_exports__tags as tags, __webpack_exports__watch as watch, __webpack_exports__willCallback as willCallback, __webpack_exports__willPromise as willPromise, __webpack_exports__willSubscribe as willSubscribe };
4698
-
1
+ var t,e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},n={};function r(t,e){const n=t.templater,r=e.templater,s=n?.tag||t,a=r.tag,i=s.strings,l=e.strings||a.strings;if(i.length!==l.length)return!1;if(!i.every(((t,e)=>l[e]===t)))return!1;return o(t.values||s.values,e.values||a.values)}function o(t,e){if(!(t.length===e.length))return!1;return!!e.every(((e,n)=>{const r=t[n];if(e instanceof Function&&r instanceof Function){return!!(e.toString()===r.toString())}return!0}))}function s(t){t.global.oldest.destroy(),a(t),t.global.context={}}function a(t){delete t.global.oldest,delete t.global.newest}function i(t,e){e.parentNode.insertBefore(t,e.nextSibling)}function l(t){return["string","number","boolean"].includes(t)}function c(t,e){a(t),t.destroy({stagger:e.removed++});const n=t.global.insertBefore;n.parentNode.removeChild(n)}function u(t){const e=t.global.insertBefore,n=t.global,r=n.placeholder;r&&(i(e,r),delete n.placeholder)}function p(e){if(null==e)return t.undefined;const n=typeof e;if(e instanceof Function)return t.function;if("object"===n){if(e instanceof Date)return t.date;if(l(n))return n;const r=e.tagJsType;if(r){if([t.tagComponent,t.templater,t.tag].includes(r))return r}if(b(e))return t.tagArray;if(m(e))return t.subject}return t.unknown}function g(e){return[t.tag,t.templater].includes(e?.tagJsType)}function d(e){return e?.tagJsType===t.templater}function f(e){return e?.tagJsType===t.tagComponent}function h(e){return e?.tagJsType===t.tag}function m(t){return!(!0!==t?.isSubject&&!t?.subscribe)}function b(e){return e instanceof Array&&e.every((e=>[t.tag,t.templater,t.tag,t.tagComponent].includes(e?.tagJsType)))}function y(t){const e=new w;return e.subscribeWith=e=>{const n=[],r=[],o=(o,s)=>{n[s]=!0,r[s]=o;if(n.length===t.length){for(let t=n.length-1;t>=0;--t)if(!n[t])return;e(r,a)}},s=[...t],a=s.shift().subscribe((t=>o(t,0))),i=s.map(((t,e)=>t.subscribe((t=>o(t,e+1)))));return a.subscriptions=i,a},e}function v(t,e,n){const r=[...e],o=r.shift(),s=t=>{if(r.length)return v(t,r,n);n(t)};let a=s;const i=o(t,{setHandler:t=>a=t,next:s});a(i)}e.d(n,{W9:()=>x,t3:()=>me,ei:()=>B,B7:()=>w,XF:()=>E,vw:()=>wt,PC:()=>R,uX:()=>be,Ot:()=>S,E2:()=>lt,OH:()=>at,Y_:()=>mt,zV:()=>y,cF:()=>je,qy:()=>Ce,u2:()=>pe,zl:()=>de,O5:()=>o,Ze:()=>g,_4:()=>m,iO:()=>b,dk:()=>h,mn:()=>f,NM:()=>d,Gy:()=>Se,z:()=>U,bc:()=>J,sA:()=>ft,MG:()=>gt,r5:()=>G,yN:()=>ot,QB:()=>nt,vJ:()=>Y,AI:()=>k,wk:()=>O,uz:()=>$,Tc:()=>we,Hf:()=>Ae,_A:()=>ye,wB:()=>_,id:()=>C,MC:()=>T,zC:()=>A}),function(t){t.unknown="unknown",t.tag="tag",t.templater="templater",t.tagComponent="tag-component",t.tagArray="tag-array",t.subject="subject",t.date="date",t.string="string",t.boolean="boolean",t.function="function",t[void 0]="undefined"}(t||(t={}));class w{onSubscription;methods=[];isSubject=!0;subscribers=[];subscribeWith;_value;constructor(t,e){this.onSubscription=e,this._value=t}get value(){return this._value}set value(t){this._value=t,this.set(t)}subscribe(t){const e=function(t,e){const n=w.globalSubCount$;w.globalSubCount$.set(n.value+1);const r=()=>{r.unsubscribe()};return r.callback=e,r.subscriptions=[],r.unsubscribe=()=>{!function(t,e){const n=t.findIndex((t=>t.callback===e));-1!==n&&t.splice(n,1)}(t.subscribers,e),w.globalSubCount$.set(n.value-1),r.unsubscribe=()=>r;const o=r.subscriptions;for(let t=o.length-1;t>=0;--t)o[t].unsubscribe();return r},r.add=t=>(r.subscriptions.push(t),r),r.next=t=>{e(t,r)},r}(this,t),n=this.subscribeWith;if(n){if(this.methods.length){const n=t;t=t=>{v(t,this.methods,(t=>n(t,e)))}}return n(t)}this.subscribers.push(e);const r=w.globalSubCount$.value;return w.globalSubCount$.set(r+1),this.onSubscription&&this.onSubscription(e),e}set(t){this._value=t;const e=[...this.subscribers],n=e.length;for(let r=0;r<n;++r){const n=e[r];n.callback(t,n)}}next=this.set;toPromise(){return new Promise((t=>{this.subscribe(((e,n)=>{n.unsubscribe(),t(e)}))}))}toCallback(t){return this.subscribe(((e,n)=>{n.unsubscribe(),t(e)})),this}pipe(...t){const e=new w(this._value);return e.methods=t,e.subscribeWith=t=>this.subscribe(t),e.set=t=>this.set(t),e.next=e.set,e}static all(t){return y(t.map((t=>{if(m(t))return t;return new w(t,(e=>(e.next(t),e)))})))}static globalSubCount$=new w(0)}class S extends w{constructor(t){super(t)}get value(){return this._value}set value(t){this._value=t,this.set(t)}subscribe(t){const e=super.subscribe(t);return t(this._value,e),e}}function C(t){return(e,n)=>{n.setHandler((()=>{})),t(e,n.next)}}function T(t){return(e,n)=>{n.setHandler((()=>{}));t(e).then((t=>n.next(t)))}}const A=t=>(e,n)=>{n.setHandler((()=>{}));const r=t(e).subscribe((t=>{r.unsubscribe(),n.next(t)}))};function j(){return k.memory.stateConfig.tagSupport}function k(t){const e={beforeRender:t.beforeRender||(()=>{}),beforeRedraw:t.beforeRedraw||(()=>{}),afterRender:t.afterRender||(()=>{}),beforeDestroy:t.beforeDestroy||(()=>{})};k.tagUse.push(e)}k.tagUse=[],k.memory={};class R extends Error{details;constructor(t,e,n={}){super(t),this.name=R.name,this.details={...n,errorCode:e}}}class x extends R{constructor(t,e){super(t,"array-no-key-error",e),this.name=x.name}}class B extends R{constructor(t,e){super(t,"state-mismatch-error",e),this.name=B.name}}class E extends R{constructor(t,e){super(t,"sync-callback-error",e),this.name=E.name}}k.memory.stateConfig={array:[]};const F=t=>function(t){const e=t.memory,n=e.state,r=k.memory.stateConfig;r.rearray=[];const o=n?.length;if(o){for(let t=0;t<o;++t)V(n[t]);r.rearray.push(...n)}r.tagSupport=t}(t);function V(t){const e=t.callback;if(!e)return t.defaultValue;const[n,r]=function(t){const e=t(N),[n]=e,[r]=t(n);return[n,r]}(e);if(r!==N){const o='State property not used correctly. Second item in array is not setting value as expected.\n\nFor "let" state use `let name = state(default)(x => [name, name = x])`\n\nFor "const" state use `const name = state(default)()`\n\nProblem state:\n'+(e?e.toString():JSON.stringify(t))+"\n";throw console.error(o,{state:t,callback:e,value:n,checkValue:r}),new Error(o)}return n}k({beforeRender:F,beforeRedraw:F,afterRender:t=>{const e=t.memory,n=k.memory.stateConfig,r=n.rearray;if(r.length&&r.length!==n.array.length){const e=`States lengths have changed ${r.length} !== ${n.array.length}. State tracking requires the same amount of function calls every render. Typically this errors is thrown when a state like function call occurs only for certain conditions or when a function is intended to be wrapped with a tag() call`,o=t.templater?.wrapper,s={oldStates:n.array,newStates:n.rearray,tagFunction:o.parentWrap.original},a=new B(e,s);throw console.warn(e,s),a}delete n.rearray,delete n.tagSupport,e.state.length=0,e.state.push(...n.array);const o=e.state;for(let t=o.length-1;t>=0;--t){const e=o[t];e.lastValue=V(e)}n.array=[]}});class N{}function P(t,e){for(let n=t.length-1;n>=0;--n){const r=t[n].get(),o=e[n].callback;o&&o(r),e[n].lastValue=r}}function O(t){const e=k.memory.stateConfig;let n;const r=e.rearray[e.array.length];if(r){let t=V(r);n=e=>[t,t=e];const o={get:()=>V(o),callback:n,lastValue:t,defaultValue:r.defaultValue};return e.array.push(o),t}let o=(t instanceof Function?t:()=>t)();if(o instanceof Function){const t=e.array,n=e.tagSupport,r=o;o=(...e)=>{const o=n.global.newest.memory.state;P(o,t);const s=r(...e);return P(t,o),s},o.original=r}n=t=>[o,o=t];const s={get:()=>V(s),callback:n,lastValue:o,defaultValue:o};return e.array.push(s),o}const _=(t,e)=>W(t,e),M=t=>t;const W=(t,e,{init:n,before:r=(()=>!0),final:o=M}={})=>{let s=O({pastResult:void 0,values:void 0});const a=s.values;if(void 0===a){if(!r(t))return s.values=t,s.pastResult;const i=(n||e)(t,a);return s.pastResult=o(i),s.values=t,s.pastResult}if(t.every(((t,e)=>t===a[e])))return s.pastResult;if(!r(t))return s.values=t,s.pastResult;const i=e(t,a);return s.pastResult=o(i),a.length=0,a.push(...t),s.pastResult};function D(t,e){return Object.defineProperty(e,"noInit",{get(){const e=t();return e.setup.init=()=>{},e}}),Object.defineProperty(e,"asSubject",{get(){const e=t(),n=(t,n)=>{const r=O((()=>j().memory.state)),o=O((()=>new S(void 0)));return W(t,((t,e)=>{const s=n(t,e);if(r.length){P(k.memory.stateConfig.array,r)}o.set(s)}),e.setup),o};return n.setup=e.setup,D((()=>n),n),n}}),Object.defineProperty(e,"truthy",{get(){const e=t();return e.setup.before=t=>t.every((t=>t)),e}}),e}function $(t,e){const n=O((()=>k.memory.stateConfig.array)),r=j();return O((()=>new w(t,e).pipe((t=>(P(r.memory.state,n),t)))))}function J(t){const e=k.memory.stateConfig;let n;const r=e.rearray[e.array.length];if(r){let t=V(r);n=e=>[t,t=e];const o={get:()=>V(o),callback:n,lastValue:t,defaultValue:r.defaultValue};return e.array.push(o),I(t,o)}let o=(t instanceof Function?t:()=>t)();n=t=>[o,o=t];const s={get:()=>V(s),callback:n,lastValue:o,defaultValue:o};return e.array.push(s),I(o,s)}function I(t,e){return n=>(e.callback=n||(e=>[t,t=e]),t)}function U(t){return e=>{let n=J(t)(e);return _([t],(()=>e(n=t))),e(n),n}}function L(t){return z(t,new WeakMap)}function z(t,e){if(null===t||"object"!=typeof t)return t;if(e.has(t))return e.get(t);if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));if(e.set(t,n),Array.isArray(t))for(let r=0;r<t.length;r++)n[r]=z(t[r],e);else for(const r in t)t.hasOwnProperty(r)&&(n[r]=z(t[r],e));return n}function H(t,e){return K(t,e,new WeakMap)}function K(t,e,n){return!!(t===e||(r=t,o=e,r instanceof Function&&o instanceof Function&&r.toString()===o.toString()))||(!!n.has(t)||"object"==typeof t&&"object"==typeof e&&(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():(n.set(t,0),Array.isArray(t)&&Array.isArray(e)?function(t,e,n){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!K(t[r],e[r],n))return!1;return!0}(t,e,n):!Array.isArray(t)&&!Array.isArray(e)&&function(t,e,n){const r=Object.keys(t),o=Object.keys(e);if(0===r.length&&0===o.length)return!0;if(r.length!==o.length)return!1;for(const s of r){if(!o.includes(s)||!K(t[s],e[s],n))return!1}return!0}(t,e,n))));var r,o}D((()=>function(t){const e=(e,n)=>W(e,n,t);return e.setup=t,D((()=>e),e),e}({})),_),$.value=t=>{const e=O((()=>k.memory.stateConfig.array)),n=j();return O((()=>new S(t).pipe((t=>(P(n.memory.state,e),t)))))},$.all=function(t){const e=O((()=>k.memory.stateConfig.array)),n=j();return w.all(t).pipe((t=>(P(n.memory.state,e),t)))},k.memory.providerConfig={providers:[],ownerSupport:void 0};const G={create:t=>{const e=O((()=>({stateDiff:0,provider:void 0})));if(e.stateDiff){for(let t=e.stateDiff;t>0;--t)O(void 0);return O(void 0)}const n=O((()=>{const n=k.memory,r=n.stateConfig,o=r.array.length,s="prototype"in t?new t:t(),a=r.array.length-o,i=n.providerConfig,l={constructMethod:t,instance:s,clone:L(s),stateDiff:a};return e.provider=l,i.providers.push(l),e.stateDiff=a,s})),r=t,o=r.compareTo=r.toString();return e.provider.constructMethod.compareTo=o,n},inject:t=>O((()=>{const e=k.memory.providerConfig,n=t,r=n.compareTo=n.compareTo||t.toString();let o={ownerTagSupport:e.ownerSupport};for(;o.ownerTagSupport;){const t=o.ownerTagSupport.global.providers.find((t=>{if(t.constructMethod.compareTo===r)return!0}));if(t)return t.clone=L(t.instance),e.providers.push(t),t.instance;o=o.ownerTagSupport}const s=`Could not inject provider: ${t.name} ${t}`;throw console.warn(`${s}. Available providers`,e.providers),new Error(s)}))};function X(t,e){const n=k.memory.providerConfig;n.ownerSupport=e,t.global.providers.length&&(n.providers.length=0,n.providers.push(...t.global.providers))}function q(t,e){const n=Q(t,e);for(let t=n.length-1;t>=0;--t){const{tagSupport:e,renderCount:r,provider:o}=n[t];if(e.global.deleted)continue;r===e.global.renderCount&&(o.clone=L(o.instance),ot(e,!1))}}function Q(t,e,n=[]){const r=t.global,o=r.providers.find((t=>t.constructMethod.compareTo===e.constructMethod.compareTo));o&&n.push({tagSupport:t,renderCount:r.renderCount,provider:o});const s=t.childTags;for(let t=s.length-1;t>=0;--t)Q(s[t],e,n);return n}function Y(t,e){const n=k.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].beforeRender(t,e)}function Z(t,e){const n=k.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].afterRender(t,e);k.memory.tagClosed$.next(e)}function tt(t,e){const n=k.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].beforeDestroy(t,e)}function et(t,e,n,r){const o=t.global.renderCount;!function(t,e,n){const r=n?.ownerTagSupport,o=r||e;if(n){const e=n.memory.state;t.memory.state=[...e],t.global=n.global,function(t,e){const n=k.tagUse,r=n.length;for(let o=0;o<r;++o)n[o].beforeRedraw(t,e)}(t,n)}else{Y(t,o);k.memory.providerConfig.ownerSupport=o}}(t,r,e);let s=(0,t.templater.wrapper)(t,n);return Z(t,r),s.global.renderCount>o+1?t.global.newest:(t.global.newest=s,s)}function nt(t,e,n,o){const a=et(t,e,n,o);!e||r(e,a)||function(t,e,n){const r=t.global,o=r.insertBefore;s(t),e.global={...r};const a=e.global;a.insertBefore=o,a.deleted=!1,delete a.oldest,delete a.newest,delete n.tagSupport}(e,a,n);const i=e?.ownerTagSupport;return a.ownerTagSupport=o||i,a}function rt(t,e,n,o){const s=o.tagSupport,a=s.global;e.global=a;const i=a.renderCount;!function(t){const e=t.global.providers.filter((t=>!H(t.instance,t.clone)));for(let n=e.length-1;n>=0;--n){const r=e[n];q(t.getAppTagSupport(),r),r.clone=L(r.instance)}}(t);const l=a.newest;if(i!==a.renderCount)return t.updateBy(l),l;const c=nt(e,l||s||a.oldest,o,n),u=a.oldest||t;return c.global.oldest=u,r(l,c)&&(o.tagSupport=c,u.updateBy(c)),c}function ot(t,e){const n=t.global,r=t.templater;if(!r.wrapper){const e=t.ownerTagSupport;return++n.renderCount,ot(e,!0)}const o=t.subject;let s,a=!1;if(e&&t&&(s=t.ownerTagSupport,s)){const e=r.props,n=t.propsConfig.latestCloned;a=!e.every(((t,e)=>H(t,n[e])))}const i=rt(t.global.oldest,t,s,o);if(s&&a){return ot(s,!0),i}return i}k({beforeRender:(t,e)=>{X(t,e)},beforeRedraw:(t,e)=>{X(t,e.ownerTagSupport)},afterRender:t=>{const e=k.memory.providerConfig;t.global.providers=[...e.providers],e.providers.length=0}}),k.memory.tagClosed$=new w(void 0,(t=>{j()||t.next()}));let st=t=>(t,e,n,r,o,s)=>{throw new E("Callback function was called immediately in sync and must instead be call async")};const at=()=>st,it=st;function lt(t){const e=j();if(!e){throw new E("callback() was called outside of synchronous rendering. Use `callback = callbackMaker()` to create a callback that could be called out of sync with rendering")}const n=k.memory.stateConfig.array;return(...r)=>e.global.callbackMaker?ut(e,t,n,...r):t(...r)}function ct(t){const e=k.memory.stateConfig.array;st=n=>(...r)=>t.global.callbackMaker?ut(t,n,e,...r):n(...r)}function ut(t,e,n,...r){const o=t.memory.state;P(o,n);const s=e(...r);return P(n,o),ot(t,!1),s instanceof Promise&&s.finally((()=>{P(n,o),ot(t,!1)})),s}function pt(t){k.memory.currentSupport=t}function gt(t){const e=k.memory.currentSupport;e.global.init||(e.global.init=t,t())}function dt(t){k.memory.destroyCurrentSupport=t}function ft(t){k.memory.destroyCurrentSupport.global.destroyCallback=t}function ht(t){k.memory.childrenCurrentSupport=t}function mt(){return k.memory.childrenCurrentSupport.templater.children}k({beforeRender:t=>ct(t),beforeRedraw:t=>ct(t),afterRender:t=>{t.global.callbackMaker=!0,st=it}}),k({beforeRender:t=>pt(t),beforeRedraw:t=>pt(t)}),k({beforeRender:t=>dt(t),beforeRedraw:t=>dt(t),beforeDestroy:t=>{const e=t.global.destroyCallback;e&&e()}}),k({beforeRender:t=>ht(t),beforeRedraw:t=>ht(t)});const bt="__tagvar",yt="--"+bt+"--",vt=new RegExp(yt,"g");class wt{strings;values;tagJsType=t.tag;memory={};templater;constructor(t,e){this.strings=t,this.values=e}key(t){return this.memory.arrayValue=t,this}children;html(t,...e){return this.children={strings:t,values:e},this}}class St{props;tagJsType="templater";tagged;wrapper;madeChildIntoSubject=!1;tag;children=new S([]);constructor(t){this.props=t}html(t,...e){const n=new wt(t,e),{childSubject:r,madeSubject:o}=Se(n);return this.children=r,this.madeChildIntoSubject=o,this}}function Ct(t,e,n,r){const o=e.global,s=o.renderCount,a=t.bind(n)(...r);if(!(s===o.renderCount)||o.deleted)return a instanceof Promise?a.then((()=>"promise-no-data-ever")):"no-data-ever";const i=ot(o.newest,!0);return o.newest=i,a instanceof Promise?a.then((()=>{if(o.deleted)return"promise-no-data-ever";const t=ot(o.newest,!0);return o.newest=t,"promise-no-data-ever"})):"no-data-ever"}function Tt(e){return e.map((e=>{const n=e;switch(p(e)){case t.tagComponent:return L(e.props);case t.tag:case t.templater:return Tt(n.values);case t.tagArray:return Tt(n)}return L(e)}))}function At(t,e=[]){for(let n=t.length-1;n>=0;--n){const r=t[n];e.push(r),t.splice(n,1),At(r.childTags,e)}return e}function jt(t,e){const n=t;let r=n.templater;r||(r=new St([]),r.tag=n,n.templater=r);const o=new S(r);return o.tagSupport=new be(r,e,o),o}function kt(t){const e=document.createTextNode(""),n=t.parentNode;return n.insertBefore(e,t),n.removeChild(t),e}function Rt(t,e,n){const r=t.split(".");if("style"===r[0]&&(n.style[r[1]]=e),"class"===r[0])if(r.shift(),e)for(let t=0;t<r.length;++t)n.classList.add(r[t]);else for(let t=0;t<r.length;++t)n.classList.remove(r[t])}const xt=/^\s*{__tagvar/,Bt=/}\s*$/;function Et(t){return t&&t.search(xt)>=0&&t.search(Bt)>=0}function Ft(t,e,n,r,o,s){if(Et(e))return function(t,e,n,r,o,s){const a=Vt(r,e);return Nt(t,a,n,o,s)}(t,e,n,r,o,s);if(Et(t)){let e;const a=Vt(r,t).subscribe((t=>{!function(t,e,n,r,o){if(e&&e!=t)if("string"==typeof e)n.removeAttribute(e);else if(e instanceof Object)for(const t in e)n.removeAttribute(t);if("string"==typeof t){if(!t.length)return;return void Nt(t,"",n,r,o)}if(t instanceof Object)for(const e in t)Nt(e,t[e],n,r,o)}(t,e,n,o,s),e=t}));return o.global.subscriptions.push(a),void n.removeAttribute(t)}return Pt(t)?Rt(t,e,n):void 0}function Vt(t,e){return t[e.replace("{","").split("").reverse().join("").replace("}","").split("").reverse().join("")]}function Nt(t,e,n,r,o){const s=Pt(t);if(e instanceof Function){const r=function(...t){return e(n,t)};n[t].action=r}if(m(e)){n.removeAttribute(t);const a=e=>{if(e instanceof Function){const t=r.templater.wrapper,n=t?.parentWrap,o=n?.oneRender;o||(e=function(t,e){if(t.isChildOverride)return t;const n=(n,r)=>Ct(t,e,n,r);return n.tagFunction=t,n}(e,r))}return function(t,e,n,r,o){if(t instanceof Function){const r=function(...n){return t(e,n)};return r.tagFunction=t,void(e[n]=r)}if(r)return void Rt(n,t,e);if(t)return void o(e,n,t);const s=[void 0,!1,null].includes(t);if(s)return void e.removeAttribute(n);o(e,n,t)}(e,n,t,s,o)},i=e.subscribe(a);r.global.subscriptions.push(i)}else o(n,t,e)}function Pt(t){return t.search(/^(class|style)(\.)/)>=0}function Ot(t,e,n){t.setAttribute(e,n)}function _t(t,e,n){t[e]=n}function Mt(t,e,n){const r=t.getAttributeNames();let o=Ot;for(let s=0;s<r.length;++s){const a=r[s];"INPUT"===t.nodeName&&"value"===a&&(o=_t);Ft(a,t.getAttribute(a),t,e,n,o),o=Ot}}const Wt=/(?:<[^>]*?(?:(?:\s+\w+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+)))*\s*)\/?>)|({__tagvar[^}]+})/g;function Dt(t,e,n,{counts:r}){const o=e,s=o.tagSupport,a=s?.global.oldest||void 0;if(a&&a)return function(t,e,n){if(e instanceof Function){const t=e(n);return n.updateBy(t),void(e.tagSupport=t)}return n.updateBy(t),void(e.tagSupport=t)}(t,o,a);t.buildBeforeElement(n,{counts:r})}function $t(t,e,n,r,o){if(!0!==t.tagged){const e=t.wrapper.parentWrap.original;let n=e.name||e.constructor?.name;"Function"===n&&(n=void 0);const r=n||e.toString().substring(0,120);throw new Error(`Not a tag component. Wrap your function with tag(). Example tag(props => html\`\`) on component:\n\n${r}\n\n`)}const s=new be(t,r,e);let a=e.tagSupport;(s.global=a?.global||s.global).insertBefore=n;k.memory.providerConfig.ownerSupport=r;if(!a){a=function(t,e,n){const r=n.clones.map((t=>t));if((e=nt(e,t.tagSupport,t,n)).global.newest=e,n.clones.length>r.length){const t=n.clones.filter((t=>!r.find((e=>e===t))));e.clones.push(...t)}return n.childTags.push(e),e}(e,a||s,r)}return Dt(a,e,n,o),a}function Jt(t,e,n,r){let o=r.tagSupport;o||(o=zt(t,n,r)),r.tagSupport=o,o.ownerTagSupport=n,o.buildBeforeElement(e,{counts:{added:0,removed:0}})}function It(t,e,n){t.global.oldest=t,t.global.newest=t,t.ownerTagSupport=e,n.tagSupport=t}function Ut(t){const e=Lt();return e.tag=t,t.templater=e,e}function Lt(){const t={children:new S([]),props:[],isTag:!0,tagJsType:"templater",tagged:!1,madeChildIntoSubject:!1,html:()=>t};return t}function zt(t,e,n){const r=new be(t,e,n);return It(r,e,n),e.childTags.push(r),r}function Ht(t,e,n,r,o){const s=r.clones;let a=t.lastArray=t.lastArray||[];t.placeholder||function(t,e){if("TEMPLATE"!==t.nodeName)return void(e.placeholder=t);const n=e.placeholder=document.createTextNode(""),r=t.parentNode;r.insertBefore(n,t),r.removeChild(t)}(n,t);const i=t.placeholder;let l=0;a=t.lastArray=t.lastArray.filter(((t,n)=>{const r=e.length-1<n-l,s=e[n-l],i=t.tagSupport.templater.tag,u=s?.memory.arrayValue,p=i.memory.arrayValue,g=r||!function(t,e){if(t===e)return!0;if(t instanceof Array&&e instanceof Array&&t.length==e.length)return t.every(((t,n)=>t==e[n]));return!1}(u,p);if(g){const t=a[n];return c(t.tagSupport,o.counts),t.deleted=!0,++l,++o.counts.removed,!1}return!0}));const u=e.length;for(let t=0;t<u;++t){const n=e[t],s=a[t],l=s?.tagSupport,c=n;h(c)&&!c.templater&&Ut(c);const u=new be(c.templater,r,new S(void 0));if(l){It(u,r,l.subject);const t=l.global;u.global=t,t.newest=u}if(!("arrayValue"in c.memory)){const t={template:u.getTemplate().string,array:e},n="Use html`...`.key(item) instead of html`...` to template an Array";console.error(n,t);throw new x(n,t)}if(a.length>t){s.tagSupport.global.oldest.updateBy(u)}else Kt(i,u,t,o,a),r.childTags.push(u)}return s}function Kt(t,e,n,r,o){const s={tagSupport:e,index:n};o.push(s);const a={added:r.counts.added+n,removed:r.counts.removed},i=document.createDocumentFragment(),l=document.createElement("template");i.appendChild(l),e.buildBeforeElement(l,{counts:a});t.parentNode.insertBefore(i,t)}function Gt(t,e){const n=e.parentNode,r=document.createTextNode(t);return n.insertBefore(r,e),n.removeChild(e),r}function Xt(t){return[void 0,!1,null].includes(t)?"":t}function qt(t,e,n){e.insertBefore=n;const r=e.clone||n;if(e.lastValue===t&&"lastValue"in e)return;e.lastValue=t;const o=Xt(t),s=e.clone;if(s)return void(s.textContent=o);const a=Gt(o,r);e.clone=a}function Qt(e,n,r,o,s){switch(p(e)){case t.templater:return void Jt(e,r,o,n);case t.tag:const a=e;let i=a.templater;return i||(i=Ut(a)),void Jt(i,r,o,n);case t.tagArray:return Ht(n,e,r,o,s);case t.tagComponent:return void $t(e,n,r,o,s);case t.function:const l=e;if(l.oneRender){const t=new St([]);t.tagJsType="oneRender";const e=zt(t,o,n);let s;const a=()=>(t.tag=s||l(),e);return t.wrapper=a,a.parentWrap=a,a.oneRender=!0,a.parentWrap.original=l,et(e,e,n,o),void Jt(t,r,o,n)}}!function(t,e,n){e.lastValue=t;const r=Gt(Xt(t),n);e.clone=r}(e,n,r)}const Yt=new RegExp('\\s*<template interpolate end id="__tagvar(\\d{1,4})"([^>]*)></template>(\\s*)');function Zt(t,e,n){if(!(t instanceof Function))return!!H(t,e)&&4;if(!(e instanceof Function))return!1;const r=e?.original;r&&(e=r);t.original&&(t=t.original);return t.toString()===e.toString()?(n(),3):(n(),5)}function te(t,e,n){const r=function(t,e){let n=t,r=e;if("object"==typeof t){if(!e)return 3;if(n=[...t],r=[...e||[]],!n.every(((t,e)=>{let o=r[e];if(t&&"object"==typeof t){const e={...t},n={...o||{}},r=Object.entries(e).every((([t,r])=>Zt(r,n[t],(()=>{delete e[t],delete n[t]}))));return r}return Zt(t,o,(()=>{n.splice(e,1),r.splice(e,1)}))})))return 6}return!1}(n.props,t.propsConfig.latestCloned);if(r)return r;const o=function(t,e){const n=t.propsConfig.lastClonedKidValues,r=e.propsConfig.lastClonedKidValues;return!n.every(((t,e)=>{const n=r[e];return t.every(((t,e)=>t===n[e]))}))&&9}(t,e);return o}function ee(t,e){const n=function(t,e){if("object"!=typeof t||!e)return t;for(const n in t){const r=t[n];if(!(r instanceof Function))continue;t[n].toCall||(t[n]=(...e)=>t[n].toCall(...e),t[n].toCall=(...t)=>ne(r,t,e),t[n].original=r)}return t}(g(t)?0:t,e);return n}function ne(t,e,n){const r=j(),o=t(...e),s=()=>{const t=n.global.newest;if(r){const e=t.memory.state.every((t=>{const e=t.lastValue,n=t.get();return H(L(e),n)}));if(e)return o}const e=ot(t,!0);return t.global.newest=e,o};return r?(k.memory.tagClosed$.toCallback(s),o):s()}function re(t,e,n,o){let a=n.tagSupport?.global.newest,i=a.global.oldest;const l=a.templater.wrapper,c=e.templater.wrapper;let u=!1;if(l&&c){u=l.parentWrap.original===c.parentWrap.original}const p=e.templater;if(!u){return s(a.global.oldest),$t(p,n,o,t,{counts:{added:0,removed:0}})}if(!te(a,e,p)){return function(t,e,n){t=t.global.newest||t;const r=t.propsConfig,o=r.latestCloned,s=e.global.newest;for(let t=n.length-1;t>=0;--t){const e=n[t];if("object"!=typeof e)return;const r=o[t];if("object"!=typeof r)return;for(const t in e){if(!(e[t]instanceof Function))continue;const n=e[t];n instanceof Function&&n.toCall||(r[t].toCall=(...t)=>ne(n,t,s))}}}(a,t,p.props),a}const g=a.global.newest,d=ot(e,!1);a=n.tagSupport;const f=d.global.oldest;if(!!!f)return oe(d,o,a,n);if(f&&p.children.value.length){f.templater.children.set(p.children.value)}return u&&r(g,d)?(n.tagSupport=d,i.updateBy(d),d):(u&&a&&(s(a),d.global.context={}),i=void 0,i||(a=d,oe(d,a.global.insertBefore,a,n)),a.global.newest=d,d)}function oe(t,e,n,r){return t.buildBeforeElement(e,{counts:{added:0,removed:0}}),t.global.oldest=t,t.global.newest=t,n.global.oldest=t,n.global.newest=t,r.tagSupport=t,t}function se(e,n,o,a){const f=e,m=p(n);if(function(e,n,o){const a=e,d="lastValue"in a,f=a.lastValue;if(d&&f!==n){const t=typeof n;return(!l(t)||typeof f!==t)&&!(n instanceof Function&&f instanceof Function)&&(function(t,e){const n=e.clone,r=n.parentNode;r.insertBefore(t,n),r.removeChild(n),delete e.clone,delete e.lastValue}(o,a),"changed-simple-value")}const h=p(n),m=e,b=m.lastArray;if(b&&h!==t.tagArray){const t=m.placeholder;delete m.lastArray,delete m.placeholder,i(o,t);for(let t=b.length-1;t>=0;--t){const{tagSupport:e}=b[t];c(e,{added:0,removed:0})}return"array"}const y=e.tagSupport;if(y){const o=g(n);return g(e.value)&&o?!r(n,y)&&(u(y),s(y),2):h!==t.tagComponent&&(!n||!n.oneRender)&&(u(y),s(y),"different-tag")}}(e,n,a),m===t.tagComponent)return function(t,e,n,r){if(!e.tagSupport)return $t(t,e,n,r,{counts:{added:0,removed:0}}),e;const o=new be(t,r,e),s=e.tagSupport,a=s.global.newest;if(!a)return u(s),$t(t,e,n,r,{counts:{added:0,removed:0}}),e;{const t=a.memory.state;o.memory.state.length=0,o.memory.state.push(...t)}return o.global=s.global,e.tagSupport=o,re(r,o,e,n),e}(n,f,a,o);if(f.tagSupport)return m===t.function||function(t,e,n){const o=t.tagSupport;let s=e;const a=h(e);if(a){const t=e;s=t.templater,s||(s=new St([]),s.tag=t,t.templater=s)}const i=new be(s,n,t);a&&(i.global=o.global);const l=e&&r(o,i);d(e)&&It(i,n,t);if(l)return void o.updateBy(i);if(l){return Jt(s,o.global.insertBefore,n,t)}qt(e,t,t.insertBefore)}(e,n,o),f;switch(m){case t.tagArray:return Ht(e,n,a,o,{counts:{added:0,removed:0}}),e;case t.templater:return Jt(n,a,o,f),f;case t.tag:const r=n;let s=r.templater;return s||(s=Lt(),r.templater=s,s.tag=r),Jt(s,a,o,f),f;case t.subject:return n;case t.function:return e.clone||(e.clone=kt(a)),e}return qt(n,e,a),f}function ae(t,e,n,r,o){const s=[];if(!t.hasAttribute("end"))return{clones:s};const a=t.getAttribute("id");if(a?.substring(0,bt.length)!==bt)return{clones:s};const i=e[a];return f(i.value)||b(i.value)?{clones:s,tagComponent:{variableName:a,ownerSupport:n,subject:i,insertBefore:t}}:(ie(t,i,n,r),{clones:s})}function ie(t,e,n,r){let o=!1;const s=s=>{if(o)return void se(e,s,n,t);Qt(s,e,t,n,{counts:{...r}}),o=!0};let a=s;const i=e.subscribe((t=>a(t)));if(t.parentNode){const n=e.clone=kt(t);a=r=>{const o=n.parentNode;o.insertBefore(t,n),o.removeChild(n),delete e.clone,a=s,s(r)}}n.global.subscriptions.push(i)}function le(t,e,n,r){if(!t.getAttribute)return;"TEXTAREA"===t.nodeName&&function(t,e,n){const r=t.value;if(r.search(Yt)>=0){const o=r.match(/__tagvar(\d{1,4})/),s="{"+(o?o[0]:"")+"}";t.value="",t.setAttribute("text-var-value",s);const a=(e,n,r)=>t.value=r;Ft("text-var-value",s,t,e,n,a)}}(t,n,r);let o=e.counts.added;if(o=function(t,e){const n=t.oninit;if(!n)return e.added;const r=n.tagFunction;if(!r)return e.added;const o=r.tagFunction;return o?(o({target:t,stagger:e.added}),++e.added):e.added}(t,e.counts)-o,t.children){const o=t.children;for(let t=o.length-1;t>=0;--t){return le(o[t],{...e,counts:e.counts},n,r)}}}function ce(t,e,n,r){const o=n.counts,s=[],a=[];for(let i=r.length-1;i>=0;--i){const l=r[i],{clones:c,tagComponent:u}=ae(l,t,e,o);if(s.push(...c),u)a.push(u);else if(l.children)for(let r=l.children.length-1;r>=0;--r){const i=l.children[r];if(ue(i)){const{tagComponent:n}=ae(i,t,e,o);n&&a.push(n)}const{clones:c,tagComponents:u}=ce(t,e,n,i.children);s.push(...c),a.push(...u)}}return{clones:s,tagComponents:a}}function ue(t){return"TEMPLATE"===t.tagName&&void 0!==t.getAttribute("interpolate")&&void 0!==t.getAttribute("end")}function pe(t,e,n,r,o){const s=[],a=[],i=n.interpolation,l=t.children[0],c=l.content.children;if(i.keys.length){const{clones:t,tagComponents:n}=ce(e,r,o,c);s.push(...t),a.push(...n)}return Mt(l,e,r),ge(c,e,r),{clones:s,tagComponents:a}}function ge(t,e,n){for(let r=t.length-1;r>=0;--r){const o=t[r];Mt(o,e,n),o.children&&ge(o.children,e,n)}}function de(t){const e=function(t){const e=[];return{string:t.replace(Wt,((t,n)=>{if(t.startsWith("<"))return t;const r=n.substring(1,n.length-1);return e.push(r),`<template interpolate end id="${r}"></template>`})),keys:e}}(t);return e.string=e.string.replace(vt,bt),e}function fe(t,e,n,r,o){const s=function(t,e){const n=[];let r=t.children[0].content.firstChild;const o=document.createDocumentFragment();for(;r;){const t=r.nextSibling;n.push(r),o.appendChild(r),r=t}e.parentNode&&e.parentNode.insertBefore(o,e);return n}(t,e);if(!s.length)return s;for(let t=s.length-1;t>=0;--t){const e=s[t];le(e,o,r,n),n.clones.push(e)}return s}const he=new RegExp(bt,"g");class me{templater;subject;isApp=!0;appElement;strings;values;propsConfig;memory={state:[]};clones=[];global={context:{},providers:[],renderCount:0,deleted:!1,subscriptions:[]};hasLiveElements=!1;constructor(t,e){this.templater=t,this.subject=e;const n=t.children.value,r=t.props,o=r.map((t=>L(t)));this.propsConfig={latest:r,latestCloned:o,lastClonedKidValues:n.map((t=>Tt(t.values)))}}buildBeforeElement(t,e={counts:{added:0,removed:0}}){const n=this.subject,r=this.global;r.insertBefore=t,r.placeholder||function(t){const e=t.insertBefore;t.placeholder=kt(e)}(r);const o=r.placeholder;r.oldest=this,r.newest=this,n.tagSupport=this,this.hasLiveElements=!0;const s=this.update(),a=this.getTemplate(),i=document.createDocumentFragment(),l=document.createElement("template");l.innerHTML=a.string,i.appendChild(l);const{tagComponents:c}=pe(i,s,a,this,{counts:e.counts});fe(i,o,this,s,e);const u=c.length;for(let t=0;t<u;++t){const n=c[t];ie(n.insertBefore,n.subject,n.ownerSupport,e.counts),fe(i,n.insertBefore,n.ownerSupport,s,e)}}getTemplate(){const t=this.templater.tag,e=this.strings||t.strings,n=this.values||t.values,r=de(e.map(((t,e)=>(t.replace(he,yt)+(n.length>e?`{${bt}${e}}`:"")).replace(/>\s*/g,">").replace(/\s*</g,"<"))).join(""));return{interpolation:r,string:r.string,strings:e,values:n,context:this.global.context||{}}}update(){return this.updateContext(this.global.context)}updateContext(e){const n=this.templater.tag,r=this.strings||n.strings,o=this.values||n.values;return r.map(((n,r)=>{if(!(o.length>r))return;const s=bt+r,a=o[r];if(s in e)return function(t,e,n){const r=t[e],o=r.tagSupport;if(o&&n&&f(n)){let t=new be(n,o.ownerTagSupport,r);f(o)&&(console.warn("👉 deprecated code is being used #shareTemplaterGlobal 👈"),function(t,e){const n=t.templater.wrapper.parentWrap.original,r=e.templater.wrapper,o=r?.parentWrap.original;if(n===o){e.global=t.global;const n=t.global.newest;if(n){const t=n.memory.state;e.memory.state.length=0,e.memory.state.push(...t)}}}(o,t))}m(n)||r.set(n)}(e,s,a);e[s]=function(e,n){switch(p(e)){case t.tagComponent:return new S(e);case t.templater:return jt(e.tag,n);case t.tag:return jt(e,n);case t.subject:return e}return new S(e)}(a,this)})),e}}class be extends me{templater;ownerTagSupport;subject;version;isApp=!1;childTags=[];constructor(t,e,n,r=0){super(t,n),this.templater=t,this.ownerTagSupport=e,this.subject=n,this.version=r}destroy(t={stagger:0,byParent:!1}){const e=!t.byParent,n=this.global,r=this.subject,o=t.byParent?[]:At(this.childTags);e&&f(this.templater)&&tt(this,this),this.destroySubscriptions();for(let t=o.length-1;t>=0;--t){const e=o[t],n=e.global;delete n.newest,n.deleted=!0,f(e.templater)&&tt(e,e)}if("TEMPLATE"===n.insertBefore.nodeName){n.placeholder&&!("arrayValue"in this.memory)&&(t.byParent||u(this))}let s;if(this.ownerTagSupport&&(this.ownerTagSupport.childTags=this.ownerTagSupport.childTags.filter((t=>t!==this))),e){const{stagger:e,promise:n}=this.destroyClones(t);t.stagger=e,n&&(s=n)}else this.destroyClones();return delete n.placeholder,n.context={},delete n.oldest,delete n.newest,n.deleted=!0,this.childTags.length=0,this.hasLiveElements=!1,delete r.tagSupport,s=s?s.then((async()=>{const t=o.map((t=>t.destroy({stagger:0,byParent:!0})));return Promise.all(t)})):Promise.all(o.map((t=>t.destroy({stagger:0,byParent:!0})))),s.then((()=>t.stagger))}destroySubscriptions(){const t=this.global.subscriptions;for(let e=t.length-1;e>=0;--e)t[e].unsubscribe();t.length=0}destroyClones({stagger:t}={stagger:0}){const e=[...this.clones];this.clones.length=0;const n=e.map((e=>this.checkCloneRemoval(e,t))).filter((t=>t)),r=this.global.context;for(const t in r){const e=r[t].clone;e?.parentNode&&e.parentNode.removeChild(e)}return n.length?{promise:Promise.all(n),stagger:t}:{stagger:t}}checkCloneRemoval(t,e){let n;const r=t;r.ondestroy&&(n=function(t,e){const n=t.ondestroy;if(!n)return;const r=n.tagFunction;if(!r)return;const o=r.tagFunction;if(!o)return;return o({target:t,stagger:e})}(r,e));const o=()=>{const e=t.parentNode;e&&e.removeChild(t);const n=this.ownerTagSupport;n&&(n.clones=n.clones.filter((e=>e!==t)))};return n instanceof Promise?n.then(o):(o(),n)}updateBy(t){const e=t.templater.tag;this.updateConfig(e.strings,e.values)}updateConfig(t,e){this.strings=t,this.updateValues(e)}updateValues(t){return this.values=t,this.updateContext(this.global.context)}getAppTagSupport(){let t=this;for(;t.ownerTagSupport;)t=t.ownerTagSupport;return t}}const ye=[];let ve=0;function we(e){const n=function(...e){const r=new St(e);r.tagJsType=t.tagComponent;const o=function(t,e){const n=function(n,r){const o=n.global;++o.renderCount;const s=t.children,a=o.oldest?.templater.children.lastArray;a&&(s.lastArray=a);const i=e.original;let l=t.props,c=l.map((t=>ee(t,n.ownerTagSupport)));const u=l.map((t=>L(t)));let p=i(...c);p instanceof Function&&(p=p()),p.templater=t,t.tag=p;const g=new be(t,n.ownerTagSupport,r,o.renderCount);if(g.global=o,g.propsConfig={latest:l,latestCloned:u,lastClonedKidValues:g.propsConfig.lastClonedKidValues},g.memory=n.memory,t.madeChildIntoSubject){const t=s.value;for(let e=t.length-1;e>=0;--e){const n=t[e],r=n.values;for(let t=r.length-1;t>=0;--t){const e=r[t];if(!(e instanceof Function))continue;const o=n.values[t];o.isChildOverride||(n.values[t]=function(...t){const n=g.ownerTagSupport;return Ct(e,n,this,t)},o.isChildOverride=!0)}}}return g};return n}(r,n);return o.parentWrap||(o.parentWrap=n),r.tagged=!0,r.wrapper=o,r};return n.original=e,n.compareTo=e.toString(),function(t,e){t.isTag=!0,t.original=e}(n,e),function(t){t.tags=ye,t.setUse=k,t.tagIndex=ve++}(e),ye.push(n),n}function Se(t){if(m(t))return{childSubject:t,madeSubject:!1};if(b(t))return{childSubject:new S(t),madeSubject:!0};const e=t;return e?(e.memory.arrayValue=0,{childSubject:new S([e]),madeSubject:!0}):{childSubject:new S([]),madeSubject:!0}}function Ce(t,...e){return new wt(t,e)}we.oneRender=(...t)=>{throw new Error("Do not call function tag.oneRender but instead set it as: `tag.oneRender = (props) => html`` `")},Object.defineProperty(we,"oneRender",{set(t){t.oneRender=!0}});const Te=[];function Ae(t,e,n){const r=Te.findIndex((t=>t.element===e));r>=0&&(Te[r].tagSupport.destroy(),Te.splice(r,1),console.warn("Found and destroyed app element already rendered to element",{element:e}));const o=function(t){let e={};const n=new S(e);e=new me(t,n),n.set(t),n.tagSupport=e,Y(e,void 0);const r=t.wrapper,o=r(e,n);return Z(e,o),o}(t(n));o.appElement=e,o.isApp=!0,o.global.isApp=!0;const s=document.createElement("template");s.setAttribute("id","app-tag-"+Te.length),s.setAttribute("app-tag-detail",Te.length.toString());const a=document.createDocumentFragment();return a.appendChild(s),e.destroy=async()=>{await o.destroy();const t=o.global.insertBefore;t.parentNode.removeChild(t)},o.buildBeforeElement(s),o.global.oldest=o,o.global.newest=o,e.setUse=t.original.setUse,Te.push({element:e,tagSupport:o}),e.appendChild(a),{tagSupport:o,tags:t.original.tags}}const je={tagElement:Ae,renderWithSupport:nt,renderTagSupport:ot,renderTagOnly:et};var ke=n.W9,Re=n.t3,xe=n.ei,Be=n.B7,Ee=n.XF,Fe=n.vw,Ve=n.PC,Ne=n.uX,Pe=n.Ot,Oe=n.E2,_e=n.OH,Me=n.Y_,We=n.zV,De=n.cF,$e=n.qy,Je=n.u2,Ie=n.zl,Ue=n.O5,Le=n.Ze,ze=n._4,He=n.iO,Ke=n.dk,Ge=n.mn,Xe=n.NM,qe=n.Gy,Qe=n.z,Ye=n.bc,Ze=n.sA,tn=n.MG,en=n.r5,nn=n.yN,rn=n.QB,on=n.vJ,sn=n.AI,an=n.wk,ln=n.uz,cn=n.Tc,un=n.Hf,pn=n._A,gn=n.wB,dn=n.id,fn=n.MC,hn=n.zC;export{ke as ArrayNoKeyError,Re as BaseTagSupport,xe as StateMismatchError,Be as Subject,Ee as SyncCallbackError,Fe as Tag,Ve as TagError,Ne as TagSupport,Pe as ValueSubject,Oe as callback,_e as callbackMaker,Me as children,We as combineLatest,De as hmr,$e as html,Je as interpolateElement,Ie as interpolateString,Ue as isLikeValueSets,Le as isStaticTag,ze as isSubjectInstance,He as isTagArray,Ke as isTagClass,Ge as isTagComponent,Xe as isTagTemplater,qe as kidsToTagArraySubject,Qe as letProp,Ye as letState,Ze as onDestroy,tn as onInit,en as providers,nn as renderTagSupport,rn as renderWithSupport,on as runBeforeRender,sn as setUse,an as state,ln as subject,cn as tag,un as tagElement,pn as tags,gn as watch,dn as willCallback,fn as willPromise,hn as willSubscribe};
4699
2
  //# sourceMappingURL=bundle.js.map