taggedjs 2.1.2 → 2.3.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/js/Clones.type.d.ts +1 -0
- package/js/Clones.type.js +2 -0
- package/js/Clones.type.js.map +1 -0
- package/js/Props.d.ts +1 -0
- package/js/Props.js +2 -0
- package/js/Props.js.map +1 -0
- package/js/Subject.d.ts +7 -2
- package/js/Subject.js +15 -10
- package/js/Subject.js.map +1 -1
- package/js/Tag.class.d.ts +37 -13
- package/js/Tag.class.js +133 -99
- package/js/Tag.class.js.map +1 -1
- package/js/Tag.utils.d.ts +8 -20
- package/js/Tag.utils.js +17 -88
- package/js/Tag.utils.js.map +1 -1
- package/js/ValueSubject.d.ts +1 -1
- package/js/ValueSubject.js.map +1 -1
- package/js/bindSubjectCallback.function.d.ts +5 -0
- package/js/bindSubjectCallback.function.js +19 -0
- package/js/bindSubjectCallback.function.js.map +1 -0
- package/js/elementDestroyCheck.function.d.ts +3 -0
- package/js/elementDestroyCheck.function.js +17 -0
- package/js/elementDestroyCheck.function.js.map +1 -0
- package/js/elementInitCheck.js.map +1 -1
- package/js/gateway/gateway.web.component.d.ts +11 -0
- package/js/gateway/gateway.web.component.js +20 -0
- package/js/gateway/gateway.web.component.js.map +1 -0
- package/js/gateway/index.d.ts +3 -0
- package/js/gateway/index.js +3 -0
- package/js/gateway/index.js.map +1 -0
- package/js/gateway/loadTagGateway.function.d.ts +2 -0
- package/js/gateway/loadTagGateway.function.js +18 -0
- package/js/gateway/loadTagGateway.function.js.map +1 -0
- package/js/gateway/tagGateway.function.d.ts +31 -0
- package/js/gateway/tagGateway.function.js +187 -0
- package/js/gateway/tagGateway.function.js.map +1 -0
- package/js/getCallback.js +39 -42
- package/js/getCallback.js.map +1 -1
- package/js/getTagSupport.d.ts +18 -17
- package/js/getTagSupport.js +104 -15
- package/js/getTagSupport.js.map +1 -1
- package/js/html.d.ts +1 -1
- package/js/html.js.map +1 -1
- package/js/index.d.ts +16 -7
- package/js/index.js +20 -8
- package/js/index.js.map +1 -1
- package/js/inputAttribute.js +3 -3
- package/js/inputAttribute.js.map +1 -1
- package/js/interpolateAttributes.d.ts +2 -1
- package/js/interpolateAttributes.js +126 -60
- package/js/interpolateAttributes.js.map +1 -1
- package/js/interpolateContentTemplates.d.ts +4 -1
- package/js/interpolateContentTemplates.js +32 -25
- package/js/interpolateContentTemplates.js.map +1 -1
- package/js/interpolateElement.d.ts +8 -13
- package/js/interpolateElement.js +26 -22
- package/js/interpolateElement.js.map +1 -1
- package/js/interpolateTemplate.d.ts +15 -19
- package/js/interpolateTemplate.js +33 -231
- package/js/interpolateTemplate.js.map +1 -1
- package/js/interpolations.d.ts +3 -2
- package/js/interpolations.js +2 -1
- package/js/interpolations.js.map +1 -1
- package/js/isInstance.d.ts +6 -0
- package/js/isInstance.js +10 -0
- package/js/isInstance.js.map +1 -0
- package/js/js/Clones.type.d.ts +1 -0
- package/js/js/Clones.type.js +2 -0
- package/js/js/Clones.type.js.map +1 -0
- package/js/js/Props.d.ts +1 -0
- package/js/js/Props.js +2 -0
- package/js/js/Props.js.map +1 -0
- package/js/js/Subject.d.ts +7 -2
- package/js/js/Subject.js +15 -10
- package/js/js/Subject.js.map +1 -1
- package/js/js/Tag.class.d.ts +27 -5
- package/js/js/Tag.class.js +109 -81
- package/js/js/Tag.class.js.map +1 -1
- package/js/js/Tag.utils.d.ts +8 -20
- package/js/js/Tag.utils.js +17 -88
- package/js/js/Tag.utils.js.map +1 -1
- package/js/js/ValueSubject.d.ts +1 -1
- package/js/js/ValueSubject.js.map +1 -1
- package/js/js/bindSubjectCallback.function.d.ts +5 -0
- package/js/js/bindSubjectCallback.function.js +19 -0
- package/js/js/bindSubjectCallback.function.js.map +1 -0
- package/js/js/elementDestroyCheck.function.d.ts +3 -0
- package/js/js/elementDestroyCheck.function.js +17 -0
- package/js/js/elementDestroyCheck.function.js.map +1 -0
- package/js/js/elementInitCheck.js.map +1 -1
- package/js/js/getCallback.js +39 -42
- package/js/js/getCallback.js.map +1 -1
- package/js/js/getTagSupport.d.ts +19 -17
- package/js/js/getTagSupport.js +111 -15
- package/js/js/getTagSupport.js.map +1 -1
- package/js/js/html.d.ts +1 -1
- package/js/js/html.js.map +1 -1
- package/js/js/index.d.ts +16 -7
- package/js/js/index.js +20 -8
- package/js/js/index.js.map +1 -1
- package/js/js/interpolateAttributes.d.ts +2 -1
- package/js/js/interpolateAttributes.js +118 -60
- package/js/js/interpolateAttributes.js.map +1 -1
- package/js/js/interpolateContentTemplates.d.ts +3 -1
- package/js/js/interpolateContentTemplates.js +32 -22
- package/js/js/interpolateContentTemplates.js.map +1 -1
- package/js/js/interpolateElement.d.ts +7 -12
- package/js/js/interpolateElement.js +18 -21
- package/js/js/interpolateElement.js.map +1 -1
- package/js/js/interpolateTemplate.d.ts +15 -19
- package/js/js/interpolateTemplate.js +33 -231
- package/js/js/interpolateTemplate.js.map +1 -1
- package/js/js/interpolations.d.ts +3 -1
- package/js/js/interpolations.js +3 -3
- package/js/js/interpolations.js.map +1 -1
- package/js/js/isInstance.d.ts +6 -0
- package/js/js/isInstance.js +10 -0
- package/js/js/isInstance.js.map +1 -0
- package/js/js/onDestroy.d.ts +2 -0
- package/js/js/onDestroy.js +20 -0
- package/js/js/onDestroy.js.map +1 -0
- package/js/js/onInit.d.ts +0 -4
- package/js/js/onInit.js +12 -10
- package/js/js/onInit.js.map +1 -1
- package/js/js/processSubjectComponent.function.d.ts +8 -0
- package/js/js/processSubjectComponent.function.js +53 -0
- package/js/js/processSubjectComponent.function.js.map +1 -0
- package/js/js/processSubjectValue.function.d.ts +16 -0
- package/js/js/processSubjectValue.function.js +122 -0
- package/js/js/processSubjectValue.function.js.map +1 -0
- package/js/js/processTagArray.d.ts +5 -1
- package/js/js/processTagArray.js +21 -10
- package/js/js/processTagArray.js.map +1 -1
- package/js/js/processTagResult.function.d.ts +10 -0
- package/js/js/processTagResult.function.js +42 -0
- package/js/js/processTagResult.function.js.map +1 -0
- package/js/js/providers.d.ts +4 -12
- package/js/js/providers.js +28 -20
- package/js/js/providers.js.map +1 -1
- package/js/js/redrawTag.function.d.ts +7 -0
- package/js/js/redrawTag.function.js +9 -0
- package/js/js/redrawTag.function.js.map +1 -0
- package/js/js/render.d.ts +1 -6
- package/js/js/render.js +8 -15
- package/js/js/render.js.map +1 -1
- package/js/js/renderAppToElement.d.ts +8 -2
- package/js/js/renderAppToElement.js +40 -21
- package/js/js/renderAppToElement.js.map +1 -1
- package/js/js/setUse.function.d.ts +23 -0
- package/js/js/setUse.function.js +14 -0
- package/js/js/setUse.function.js.map +1 -0
- package/js/js/state.d.ts +14 -11
- package/js/js/state.js +68 -33
- package/js/js/state.js.map +1 -1
- package/js/js/tag.d.ts +7 -16
- package/js/js/tag.js +33 -44
- package/js/js/tag.js.map +1 -1
- package/js/js/tagElement.d.ts +14 -0
- package/js/js/tagElement.js +57 -0
- package/js/js/tagElement.js.map +1 -0
- package/js/js/tagGateway.function.d.ts +5 -0
- package/js/js/tagGateway.function.js +119 -0
- package/js/js/tagGateway.function.js.map +1 -0
- package/js/js/tagRunner.d.ts +2 -13
- package/js/js/tagRunner.js +12 -12
- package/js/js/tagRunner.js.map +1 -1
- package/js/js/templater.utils.d.ts +28 -0
- package/js/js/templater.utils.js +99 -0
- package/js/js/templater.utils.js.map +1 -0
- package/js/js/updateTag.utils.d.ts +6 -0
- package/js/js/updateTag.utils.js +84 -0
- package/js/js/updateTag.utils.js.map +1 -0
- package/js/onDestroy.d.ts +2 -0
- package/js/onDestroy.js +20 -0
- package/js/onDestroy.js.map +1 -0
- package/js/onInit.d.ts +0 -4
- package/js/onInit.js +12 -10
- package/js/onInit.js.map +1 -1
- package/js/processSubjectComponent.function.d.ts +8 -0
- package/js/processSubjectComponent.function.js +53 -0
- package/js/processSubjectComponent.function.js.map +1 -0
- package/js/processSubjectValue.function.d.ts +16 -0
- package/js/processSubjectValue.function.js +122 -0
- package/js/processSubjectValue.function.js.map +1 -0
- package/js/processTagArray.d.ts +5 -1
- package/js/processTagArray.js +21 -10
- package/js/processTagArray.js.map +1 -1
- package/js/processTagResult.function.d.ts +10 -0
- package/js/processTagResult.function.js +39 -0
- package/js/processTagResult.function.js.map +1 -0
- package/js/providers.d.ts +4 -12
- package/js/providers.js +28 -20
- package/js/providers.js.map +1 -1
- package/js/redrawTag.function.d.ts +7 -0
- package/js/redrawTag.function.js +8 -0
- package/js/redrawTag.function.js.map +1 -0
- package/js/render.d.ts +1 -6
- package/js/render.js +5 -19
- package/js/render.js.map +1 -1
- package/js/renderAppToElement.d.ts +8 -2
- package/js/renderAppToElement.js +40 -21
- package/js/renderAppToElement.js.map +1 -1
- package/js/setUse.function.d.ts +23 -0
- package/js/setUse.function.js +14 -0
- package/js/setUse.function.js.map +1 -0
- package/js/state.d.ts +14 -11
- package/js/state.js +68 -33
- package/js/state.js.map +1 -1
- package/js/tag.d.ts +6 -16
- package/js/tag.js +32 -43
- package/js/tag.js.map +1 -1
- package/js/tagElement.d.ts +14 -0
- package/js/tagElement.js +57 -0
- package/js/tagElement.js.map +1 -0
- package/js/tagGateway.function.d.ts +14 -0
- package/js/tagGateway.function.js +138 -0
- package/js/tagGateway.function.js.map +1 -0
- package/js/tagRunner.d.ts +2 -13
- package/js/tagRunner.js +12 -12
- package/js/tagRunner.js.map +1 -1
- package/js/templater.utils.d.ts +27 -0
- package/js/templater.utils.js +98 -0
- package/js/templater.utils.js.map +1 -0
- package/js/updateTag.utils.d.ts +6 -0
- package/js/updateTag.utils.js +102 -0
- package/js/updateTag.utils.js.map +1 -0
- package/package.json +1 -1
package/js/tag.js
CHANGED
|
@@ -1,57 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
cloneProps;
|
|
7
|
-
tagged;
|
|
8
|
-
wrapper;
|
|
9
|
-
newest;
|
|
10
|
-
oldest;
|
|
11
|
-
redraw;
|
|
12
|
-
}
|
|
1
|
+
import { isTagInstance } from "./isInstance.js";
|
|
2
|
+
import { setUse } from "./setUse.function.js";
|
|
3
|
+
import { TemplaterResult, getNewProps } from "./templater.utils.js";
|
|
4
|
+
export const tags = [];
|
|
5
|
+
let tagCount = 0;
|
|
13
6
|
export function tag(tagComponent) {
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return callbackResult;
|
|
19
|
-
};
|
|
20
|
-
const isPropTag = props instanceof Tag;
|
|
21
|
-
const watchProps = isPropTag ? 0 : props;
|
|
22
|
-
const newProps = resetFunctionProps(watchProps, callback);
|
|
7
|
+
const result = (function tagWrapper(props, children) {
|
|
8
|
+
const isPropTag = isTagInstance(props);
|
|
9
|
+
const templater = new TemplaterResult(props);
|
|
10
|
+
const newProps = getNewProps(props, templater);
|
|
23
11
|
let argProps = newProps;
|
|
24
12
|
if (isPropTag) {
|
|
25
13
|
children = props;
|
|
26
14
|
argProps = noPropsGiven;
|
|
27
15
|
}
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
function innerTagWrap() {
|
|
17
|
+
const originalFunction = innerTagWrap.original;
|
|
18
|
+
const props = templater.tagSupport.props; // argProps
|
|
19
|
+
const tag = originalFunction(props, children);
|
|
20
|
+
tag.setSupport(templater.tagSupport);
|
|
21
|
+
return tag;
|
|
22
|
+
}
|
|
23
|
+
innerTagWrap.original = tagComponent;
|
|
30
24
|
templater.tagged = true;
|
|
31
|
-
templater.
|
|
32
|
-
templater.newProps = newProps;
|
|
33
|
-
templater.cloneProps = deepClone(newProps);
|
|
34
|
-
templater.wrapper = wrapper;
|
|
25
|
+
templater.wrapper = innerTagWrap;
|
|
35
26
|
return templater;
|
|
36
27
|
}); // we override the function provided and pretend original is what's returned
|
|
28
|
+
updateResult(result, tagComponent);
|
|
29
|
+
// group tags together and have hmr pickup
|
|
30
|
+
updateComponent(tagComponent);
|
|
31
|
+
tags.push(tagComponent);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function updateResult(result, tagComponent) {
|
|
35
|
+
result.isTag = true;
|
|
36
|
+
result.original = tagComponent;
|
|
37
|
+
}
|
|
38
|
+
function updateComponent(tagComponent) {
|
|
39
|
+
tagComponent.tags = tags;
|
|
40
|
+
tagComponent.setUse = setUse;
|
|
41
|
+
tagComponent.tagIndex = ++tagCount;
|
|
37
42
|
}
|
|
38
43
|
class NoPropsGiven {
|
|
39
44
|
}
|
|
40
45
|
const noPropsGiven = new NoPropsGiven();
|
|
41
|
-
function resetFunctionProps(props, callback) {
|
|
42
|
-
if (typeof (props) !== 'object') {
|
|
43
|
-
return props;
|
|
44
|
-
}
|
|
45
|
-
const newProps = { ...props };
|
|
46
|
-
Object.entries(newProps).forEach(([name, value]) => {
|
|
47
|
-
if (value instanceof Function) {
|
|
48
|
-
newProps[name] = (...args) => {
|
|
49
|
-
return callback(value, args);
|
|
50
|
-
};
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
newProps[name] = value;
|
|
54
|
-
});
|
|
55
|
-
return newProps;
|
|
56
|
-
}
|
|
57
46
|
//# sourceMappingURL=tag.js.map
|
package/js/tag.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../ts/tag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../ts/tag.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,OAAO,EAAgB,eAAe,EAAW,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAE1F,MAAM,CAAC,MAAM,IAAI,GAAmB,EAAE,CAAA;AAEtC,IAAI,QAAQ,GAAG,CAAC,CAAA;AAWhB,MAAM,UAAU,GAAG,CACjB,YAA8B;IAE9B,MAAM,MAAM,GAAG,CAAC,SAAS,UAAU,CACjC,KAA8B,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IAAI,CAAA;IACxB,YAAY,CAAC,MAAM,GAAG,MAAM,CAAA;IAC5B,YAAY,CAAC,QAAQ,GAAG,EAAE,QAAQ,CAAA;AACpC,CAAC;AACD,MAAM,YAAY;CAAG;AACrB,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TagSupport } from "./getTagSupport.js";
|
|
2
|
+
import { TagComponent, TemplaterResult } from "./templater.utils.js";
|
|
3
|
+
import { Tag } from "./Tag.class.js";
|
|
4
|
+
export declare function tagElement(app: TagComponent, // (...args: unknown[]) => TemplaterResult,
|
|
5
|
+
element: HTMLElement | Element, props: unknown): {
|
|
6
|
+
tag: Tag;
|
|
7
|
+
tags: TagComponent[];
|
|
8
|
+
};
|
|
9
|
+
export declare function applyTagUpdater(wrapper: TemplaterResult): {
|
|
10
|
+
tag: Tag;
|
|
11
|
+
tagSupport: TagSupport;
|
|
12
|
+
};
|
|
13
|
+
/** Overwrites arguments.tagSupport.mutatingRender */
|
|
14
|
+
export declare function addAppTagRender(tagSupport: TagSupport, tag: Tag): void;
|
package/js/tagElement.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { runBeforeRender } from "./tagRunner.js";
|
|
2
|
+
const appElements = [];
|
|
3
|
+
export function tagElement(app, // (...args: unknown[]) => TemplaterResult,
|
|
4
|
+
element, props) {
|
|
5
|
+
const appElmIndex = appElements.findIndex(appElm => appElm.element === element);
|
|
6
|
+
if (appElmIndex >= 0) {
|
|
7
|
+
appElements[appElmIndex].tag.destroy();
|
|
8
|
+
appElements.splice(appElmIndex, 1);
|
|
9
|
+
console.warn('Found and destroyed app element already rendered to element', { element });
|
|
10
|
+
}
|
|
11
|
+
// Create the app which returns [props, runOneTimeFunction]
|
|
12
|
+
const wrapper = app(props);
|
|
13
|
+
// have a function setup and call the tagWrapper with (props, {update, async, on})
|
|
14
|
+
const result = applyTagUpdater(wrapper);
|
|
15
|
+
const { tag, tagSupport } = result;
|
|
16
|
+
tag.appElement = element;
|
|
17
|
+
addAppTagRender(tagSupport, tag);
|
|
18
|
+
// const context = tag.updateValues(tag.values)
|
|
19
|
+
const templateElm = document.createElement('template');
|
|
20
|
+
templateElm.setAttribute('tag-detail', 'app-template-placeholder');
|
|
21
|
+
element.appendChild(templateElm);
|
|
22
|
+
tag.buildBeforeElement(templateElm);
|
|
23
|
+
element.setUse = app.original.setUse;
|
|
24
|
+
appElements.push({ element, tag });
|
|
25
|
+
return { tag, tags: app.original.tags };
|
|
26
|
+
}
|
|
27
|
+
export function applyTagUpdater(wrapper) {
|
|
28
|
+
const tagSupport = wrapper.tagSupport; // getTagSupport(0, wrapper)
|
|
29
|
+
runBeforeRender(tagSupport, undefined);
|
|
30
|
+
// Call the apps function for our tag templater
|
|
31
|
+
// const templater = tagSupport.templater as TemplaterResult
|
|
32
|
+
const tag = wrapper.wrapper(); // templater.wrapper()
|
|
33
|
+
tag.tagSupport = tagSupport;
|
|
34
|
+
tag.afterRender();
|
|
35
|
+
return { tag, tagSupport };
|
|
36
|
+
}
|
|
37
|
+
/** Overwrites arguments.tagSupport.mutatingRender */
|
|
38
|
+
export function addAppTagRender(tagSupport, tag) {
|
|
39
|
+
let lastTag;
|
|
40
|
+
tagSupport.mutatingRender = () => {
|
|
41
|
+
tag.beforeRedraw();
|
|
42
|
+
const templater = tagSupport.templater; // wrapper
|
|
43
|
+
const fromTag = lastTag = templater.wrapper();
|
|
44
|
+
// tagSupport.props = fromTag.tagSupport.props
|
|
45
|
+
tagSupport.latestProps = fromTag.tagSupport.props;
|
|
46
|
+
tagSupport.latestClonedProps = fromTag.tagSupport.clonedProps;
|
|
47
|
+
fromTag.setSupport(tagSupport);
|
|
48
|
+
tag.afterRender();
|
|
49
|
+
tag.updateByTag(fromTag);
|
|
50
|
+
if (lastTag) {
|
|
51
|
+
lastTag.destroy({ stagger: 0 });
|
|
52
|
+
}
|
|
53
|
+
tagSupport.newest = fromTag;
|
|
54
|
+
return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AExB,IAAG,OAAO,EAAE,CAAC;YACX,OAAO,CAAC,OAAO,CAAC,EAAC,OAAO,EAAE,CAAC,EAAC,CAAC,CAAA;QAC/B,CAAC;QAED,UAAU,CAAC,MAAM,GAAG,OAAO,CAAA;QAE3B,OAAO,OAAO,CAAA;IAChB,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Props } from "./Props.js";
|
|
2
|
+
import { TagComponent } from "./templater.utils.js";
|
|
3
|
+
export type dispatchEvent = (name: string, eventData: EventData) => void;
|
|
4
|
+
export type GatewayProps = Props & {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
dispatchEvent: dispatchEvent;
|
|
7
|
+
};
|
|
8
|
+
export declare function checkGateways(): void;
|
|
9
|
+
export declare const tagGateway: (component: TagComponent) => {
|
|
10
|
+
id: string;
|
|
11
|
+
};
|
|
12
|
+
export type EventData = {
|
|
13
|
+
detail: Record<string, any>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { redrawTag } from "./redrawTag.function.js";
|
|
2
|
+
import { tagElement } from "./tagElement.js";
|
|
3
|
+
export function checkGateways() {
|
|
4
|
+
Object.entries(gateways).forEach(([id, gateway]) => checkGateway(gateway));
|
|
5
|
+
}
|
|
6
|
+
function checkGateway(gateway) {
|
|
7
|
+
const { id, observer, tag } = gateway;
|
|
8
|
+
if (document.getElementById(id)) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
observer.disconnect();
|
|
12
|
+
tag.destroy();
|
|
13
|
+
delete gateways[id];
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const namedTimeouts = {};
|
|
17
|
+
export const tagGateway = function tagGateway(component) {
|
|
18
|
+
const componentString = functionToHtmlId(component);
|
|
19
|
+
const id = '__tagTemplate_' + componentString;
|
|
20
|
+
if (namedTimeouts[id]) {
|
|
21
|
+
return namedTimeouts[id];
|
|
22
|
+
}
|
|
23
|
+
let intervalId;
|
|
24
|
+
let hitCount = 0;
|
|
25
|
+
const interval = 5;
|
|
26
|
+
function findElements() {
|
|
27
|
+
const elements = document.querySelectorAll('#' + id);
|
|
28
|
+
if (!elements.length) {
|
|
29
|
+
return elements.length;
|
|
30
|
+
}
|
|
31
|
+
// Element has been found, load
|
|
32
|
+
if (intervalId) {
|
|
33
|
+
clearInterval(intervalId);
|
|
34
|
+
}
|
|
35
|
+
delete namedTimeouts[id];
|
|
36
|
+
elements.forEach(element => {
|
|
37
|
+
const updateTag = element.updateTag;
|
|
38
|
+
if (updateTag) {
|
|
39
|
+
updateTag();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const props = parsePropsString(element);
|
|
43
|
+
try {
|
|
44
|
+
const { tag } = tagElement(component, element, props);
|
|
45
|
+
watchElement(id, element, tag);
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
console.warn('Failed to render component to element', { component, element, props });
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return elements.length;
|
|
53
|
+
}
|
|
54
|
+
function findElement() {
|
|
55
|
+
intervalId = setInterval(() => {
|
|
56
|
+
hitCount = hitCount + interval;
|
|
57
|
+
if (hitCount >= 2000) {
|
|
58
|
+
clearInterval(intervalId);
|
|
59
|
+
throw new Error(`TaggedJs Element ${id} not found`);
|
|
60
|
+
}
|
|
61
|
+
findElements();
|
|
62
|
+
}, interval);
|
|
63
|
+
}
|
|
64
|
+
const elementCounts = findElements();
|
|
65
|
+
if (elementCounts) {
|
|
66
|
+
return { id };
|
|
67
|
+
}
|
|
68
|
+
findElement();
|
|
69
|
+
namedTimeouts[id] = { id };
|
|
70
|
+
return namedTimeouts[id];
|
|
71
|
+
};
|
|
72
|
+
function parsePropsString(element) {
|
|
73
|
+
const propsString = element.getAttribute('props');
|
|
74
|
+
if (!propsString) {
|
|
75
|
+
return { element };
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const props = JSON.parse(propsString);
|
|
79
|
+
// props.element = element
|
|
80
|
+
props.dispatchEvent = function (name, eventData) {
|
|
81
|
+
const event = new CustomEvent(name, eventData);
|
|
82
|
+
element.dispatchEvent(event);
|
|
83
|
+
};
|
|
84
|
+
return props;
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
console.warn('Failed to parse props on element', { element, propsString });
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function watchElement(id, targetNode, tag) {
|
|
92
|
+
let lastTag = tag;
|
|
93
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
94
|
+
if (!checkGateway(gateway)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
for (const mutation of mutationsList) {
|
|
98
|
+
if (mutation.type === 'attributes') {
|
|
99
|
+
updateTag();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
function updateTag() {
|
|
104
|
+
const templater = tag.tagSupport.templater;
|
|
105
|
+
const oldProps = templater.tagSupport.props;
|
|
106
|
+
templater.tagSupport.props = parsePropsString(targetNode);
|
|
107
|
+
const isSameProps = JSON.stringify(oldProps) === JSON.stringify(templater.tagSupport.props);
|
|
108
|
+
if (isSameProps) {
|
|
109
|
+
return; // no reason to update, same props
|
|
110
|
+
}
|
|
111
|
+
templater.tagSupport.latestProps = templater.tagSupport.props;
|
|
112
|
+
const result = redrawTag(lastTag, templater);
|
|
113
|
+
// update records
|
|
114
|
+
gateway.tag = lastTag = result.retag;
|
|
115
|
+
}
|
|
116
|
+
;
|
|
117
|
+
targetNode.updateTag = updateTag;
|
|
118
|
+
const gateway = { id, tag, observer };
|
|
119
|
+
gateways[id] = gateway;
|
|
120
|
+
// Configure the observer to watch for changes in child nodes and attributes
|
|
121
|
+
const config = { attributes: true };
|
|
122
|
+
// Start observing the target node for specified changes
|
|
123
|
+
observer.observe(targetNode, config);
|
|
124
|
+
}
|
|
125
|
+
function functionToHtmlId(func) {
|
|
126
|
+
// Convert function to string
|
|
127
|
+
let funcString = func.toString();
|
|
128
|
+
// Remove spaces and replace special characters with underscores
|
|
129
|
+
let cleanedString = funcString.replace(/\s+/g, '_')
|
|
130
|
+
.replace(/[^\w\d]/g, '_');
|
|
131
|
+
// Ensure the ID starts with a letter
|
|
132
|
+
if (!/^[a-zA-Z]/.test(cleanedString)) {
|
|
133
|
+
cleanedString = 'fn_' + cleanedString;
|
|
134
|
+
}
|
|
135
|
+
return cleanedString;
|
|
136
|
+
}
|
|
137
|
+
const gateways = {};
|
|
138
|
+
//# sourceMappingURL=tagGateway.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagGateway.function.js","sourceRoot":"","sources":["../ts/tagGateway.function.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAW5C,MAAM,UAAU,aAAa;IAC3B,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAA;AAC5E,CAAC;AAED,SAAS,YAAY,CAAC,OAAgB;IACpC,MAAM,EAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAC,GAAG,OAAO,CAAA;IAEnC,IAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,QAAQ,CAAC,UAAU,EAAE,CAAA;IACrB,GAAG,CAAC,OAAO,EAAE,CAAA;IAEb,OAAO,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEnB,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,aAAa,GAAwB,EAAE,CAAA;AAC7C,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,UAAU,CAC3C,SAAuB;IAE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SAAS,CAAA;IAE1C,MAAM,OAAO,GAAG,EAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAC,CAAA;IACnC,QAAQ,CAAC,EAAE,CAAC,GAAG,OAAO,CAAA;IAEtB,4EAA4E;IAC5E,MAAM,MAAM,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAA;IAEnC,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;AACtC,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAS;IACjC,6BAA6B;IAC7B,IAAI,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAEjC,gEAAgE;IAChE,IAAI,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACrB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IAEvD,qCAAqC;IACrC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QACnC,aAAa,GAAG,KAAK,GAAG,aAAa,CAAC;IAC1C,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAMD,MAAM,QAAQ,GAA2B,EAAE,CAAA"}
|
package/js/tagRunner.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { Tag } from "./Tag.class.js";
|
|
2
2
|
import { TagSupport } from "./getTagSupport";
|
|
3
|
-
|
|
4
|
-
beforeRender: (tagSupport: TagSupport, tag?: Tag) => void;
|
|
5
|
-
beforeRedraw: (tagSupport: TagSupport, tag: Tag) => void;
|
|
6
|
-
afterRender: (tagSupport: TagSupport, tag: Tag) => void;
|
|
7
|
-
}
|
|
8
|
-
export declare const tagUse: TagUse[];
|
|
9
|
-
export declare function runBeforeRender(tagSupport: TagSupport, tag?: Tag): void;
|
|
3
|
+
export declare function runBeforeRender(tagSupport: TagSupport, tagOwner: Tag): void;
|
|
10
4
|
export declare function runAfterRender(tagSupport: TagSupport, tag: Tag): void;
|
|
11
5
|
export declare function runBeforeRedraw(tagSupport: TagSupport, tag: Tag): void;
|
|
12
|
-
export declare function
|
|
13
|
-
beforeRender?: (tagSupport: TagSupport, tag?: Tag) => void;
|
|
14
|
-
beforeRedraw?: (tagSupport: TagSupport, tag: Tag) => void;
|
|
15
|
-
afterRender?: (tagSupport: TagSupport, tag: Tag) => void;
|
|
16
|
-
}): void;
|
|
17
|
-
export {};
|
|
6
|
+
export declare function runBeforeDestroy(tagSupport: TagSupport, tag: Tag): void;
|
package/js/tagRunner.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// TODO: This should be more like `new TaggedJs().use({})`
|
|
2
|
+
import { setUse } from "./setUse.function.js";
|
|
3
|
+
// Life cycle 1
|
|
4
|
+
export function runBeforeRender(tagSupport, tagOwner) {
|
|
5
|
+
setUse.tagUse.forEach(tagUse => tagUse.beforeRender(tagSupport, tagOwner));
|
|
4
6
|
}
|
|
7
|
+
// Life cycle 2
|
|
5
8
|
export function runAfterRender(tagSupport, tag) {
|
|
6
|
-
tagUse.forEach(tagUse => tagUse.afterRender(tagSupport, tag));
|
|
9
|
+
setUse.tagUse.forEach(tagUse => tagUse.afterRender(tagSupport, tag));
|
|
7
10
|
}
|
|
11
|
+
// Life cycle 3
|
|
8
12
|
export function runBeforeRedraw(tagSupport, tag) {
|
|
9
|
-
tagUse.forEach(tagUse => tagUse.beforeRedraw(tagSupport, tag));
|
|
13
|
+
setUse.tagUse.forEach(tagUse => tagUse.beforeRedraw(tagSupport, tag));
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
beforeRedraw: use.beforeRedraw || (() => undefined),
|
|
15
|
-
afterRender: use.afterRender || (() => undefined),
|
|
16
|
-
};
|
|
17
|
-
tagUse.push(useMe);
|
|
15
|
+
// Life cycle 4 - end of life
|
|
16
|
+
export function runBeforeDestroy(tagSupport, tag) {
|
|
17
|
+
setUse.tagUse.forEach(tagUse => tagUse.beforeDestroy(tagSupport, tag));
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=tagRunner.js.map
|
package/js/tagRunner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tagRunner.js","sourceRoot":"","sources":["../ts/tagRunner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tagRunner.js","sourceRoot":"","sources":["../ts/tagRunner.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAI1D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAE7C,eAAe;AACf,MAAM,UAAU,eAAe,CAC7B,UAAsB,EACtB,QAAa;IAEb,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC5E,CAAC;AAED,eAAe;AACf,MAAM,UAAU,cAAc,CAC5B,UAAsB,EACtB,GAAQ;IAER,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;AACtE,CAAC;AAED,eAAe;AACf,MAAM,UAAU,eAAe,CAC7B,UAAsB,EACtB,GAAQ;IAER,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;AACvE,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,gBAAgB,CAC9B,UAAsB,EACtB,GAAQ;IAER,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,CAAA;AACxE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Tag } from "./Tag.class.js";
|
|
2
|
+
import { TagSupport } from "./getTagSupport.js";
|
|
3
|
+
import { Props } from "./Props.js";
|
|
4
|
+
export type Wrapper = (() => Tag) & {
|
|
5
|
+
original: () => Tag;
|
|
6
|
+
};
|
|
7
|
+
export declare class TemplaterResult {
|
|
8
|
+
tagged: boolean;
|
|
9
|
+
wrapper: Wrapper;
|
|
10
|
+
newest?: Tag;
|
|
11
|
+
oldest?: Tag;
|
|
12
|
+
tagSupport: TagSupport;
|
|
13
|
+
constructor(props: Props);
|
|
14
|
+
redraw?: (force?: boolean) => Tag | undefined;
|
|
15
|
+
isTemplater: boolean;
|
|
16
|
+
forceRenderTemplate(tagSupport: TagSupport, ownerTag: Tag): Tag;
|
|
17
|
+
renderWithSupport(tagSupport: TagSupport, existingTag: Tag | undefined, ownerTag?: Tag): {
|
|
18
|
+
remit: boolean;
|
|
19
|
+
retag: Tag;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface TemplateRedraw extends TemplaterResult {
|
|
23
|
+
redraw: () => Tag | undefined;
|
|
24
|
+
}
|
|
25
|
+
export type TagComponent = (props: Props, // props or children
|
|
26
|
+
children?: Tag) => Tag;
|
|
27
|
+
export declare function getNewProps(props: Props, templater: TemplaterResult): any;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { getTagSupport } from "./getTagSupport.js";
|
|
2
|
+
import { isTagInstance } from "./isInstance.js";
|
|
3
|
+
import { runAfterRender, runBeforeRedraw, runBeforeRender } from "./tagRunner.js";
|
|
4
|
+
import { setUse } from "./setUse.function.js";
|
|
5
|
+
export class TemplaterResult {
|
|
6
|
+
tagged;
|
|
7
|
+
wrapper;
|
|
8
|
+
newest;
|
|
9
|
+
oldest;
|
|
10
|
+
tagSupport;
|
|
11
|
+
constructor(props) {
|
|
12
|
+
this.tagSupport = getTagSupport(this, props);
|
|
13
|
+
}
|
|
14
|
+
redraw;
|
|
15
|
+
isTemplater = true;
|
|
16
|
+
forceRenderTemplate(tagSupport, ownerTag) {
|
|
17
|
+
const tag = this.wrapper();
|
|
18
|
+
tag.setSupport(tagSupport);
|
|
19
|
+
tag.afterRender();
|
|
20
|
+
this.oldest = tag;
|
|
21
|
+
tagSupport.oldest = tag;
|
|
22
|
+
this.oldest = tag;
|
|
23
|
+
this.newest = tag;
|
|
24
|
+
tag.ownerTag = ownerTag;
|
|
25
|
+
return tag;
|
|
26
|
+
}
|
|
27
|
+
renderWithSupport(tagSupport, existingTag, ownerTag) {
|
|
28
|
+
/* BEFORE RENDER */
|
|
29
|
+
// signify to other operations that a rendering has occurred so they do not need to render again
|
|
30
|
+
++tagSupport.memory.renderCount;
|
|
31
|
+
const runtimeOwnerTag = existingTag?.ownerTag || ownerTag;
|
|
32
|
+
if (tagSupport.oldest) {
|
|
33
|
+
// ensure props are the last ones used
|
|
34
|
+
tagSupport.props = tagSupport.latestProps;
|
|
35
|
+
tagSupport.clonedProps = tagSupport.latestClonedProps;
|
|
36
|
+
runBeforeRedraw(tagSupport, tagSupport.oldest);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// first time render
|
|
40
|
+
runBeforeRender(tagSupport, runtimeOwnerTag);
|
|
41
|
+
// TODO: Logic below most likely could live within providers.ts inside the runBeforeRender function
|
|
42
|
+
const providers = setUse.memory.providerConfig;
|
|
43
|
+
providers.ownerTag = runtimeOwnerTag;
|
|
44
|
+
}
|
|
45
|
+
/* END: BEFORE RENDER */
|
|
46
|
+
const templater = this;
|
|
47
|
+
const retag = templater.wrapper();
|
|
48
|
+
/* AFTER */
|
|
49
|
+
tagSupport.latestProps = retag.tagSupport.props;
|
|
50
|
+
tagSupport.latestClonedProps = retag.tagSupport.clonedProps;
|
|
51
|
+
retag.setSupport(tagSupport);
|
|
52
|
+
runAfterRender(tagSupport, retag);
|
|
53
|
+
templater.newest = retag;
|
|
54
|
+
retag.ownerTag = runtimeOwnerTag;
|
|
55
|
+
const oldest = tagSupport.oldest = tagSupport.oldest || retag;
|
|
56
|
+
tagSupport.newest = retag;
|
|
57
|
+
const oldestTagSupport = oldest.tagSupport;
|
|
58
|
+
oldest.tagSupport = oldestTagSupport || tagSupport;
|
|
59
|
+
oldest.tagSupport.templater = templater;
|
|
60
|
+
// retag.setSupport(tagSupport)
|
|
61
|
+
const isSameTag = existingTag && existingTag.isLikeTag(retag);
|
|
62
|
+
// If previously was a tag and seems to be same tag, then just update current tag with new values
|
|
63
|
+
if (isSameTag) {
|
|
64
|
+
oldest.updateByTag(retag);
|
|
65
|
+
return { remit: false, retag };
|
|
66
|
+
}
|
|
67
|
+
return { remit: true, retag };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/* rewriter */
|
|
71
|
+
export function getNewProps(props, templater) {
|
|
72
|
+
function callback(toCall, callWith) {
|
|
73
|
+
const callbackResult = toCall(...callWith);
|
|
74
|
+
templater.newest?.ownerTag?.tagSupport.render();
|
|
75
|
+
return callbackResult;
|
|
76
|
+
}
|
|
77
|
+
const isPropTag = isTagInstance(props);
|
|
78
|
+
const watchProps = isPropTag ? 0 : props;
|
|
79
|
+
const newProps = resetFunctionProps(watchProps, callback);
|
|
80
|
+
return newProps;
|
|
81
|
+
}
|
|
82
|
+
function resetFunctionProps(props, callback) {
|
|
83
|
+
if (typeof (props) !== 'object') {
|
|
84
|
+
return props;
|
|
85
|
+
}
|
|
86
|
+
const newProps = { ...props };
|
|
87
|
+
Object.entries(newProps).forEach(([name, value]) => {
|
|
88
|
+
if (value instanceof Function) {
|
|
89
|
+
newProps[name] = (...args) => {
|
|
90
|
+
return callback(value, args);
|
|
91
|
+
};
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
newProps[name] = value;
|
|
95
|
+
});
|
|
96
|
+
return newProps;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=templater.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templater.utils.js","sourceRoot":"","sources":["../ts/templater.utils.ts"],"names":[],"mappings":"AACA,OAA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GAAG,KAAK,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TagSubject } from "./Tag.utils.js";
|
|
2
|
+
import { TagSupport } from "./getTagSupport.js";
|
|
3
|
+
import { Subject } from "./Subject.js";
|
|
4
|
+
import { TemplaterResult } from "./templater.utils.js";
|
|
5
|
+
import { Tag } from "./Tag.class.js";
|
|
6
|
+
export declare function updateExistingValue(existing: Subject<Tag> | TemplaterResult | TagSubject, value: TemplaterResult | TagSupport | Function | Subject<any>, tag: Tag, variableName: string): void;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { setValueRedraw } from "./Tag.utils.js";
|
|
2
|
+
import { deepClone } from "./deepFunctions.js";
|
|
3
|
+
import { isSubjectInstance, isTagComponent } from "./isInstance.js";
|
|
4
|
+
import { bindSubjectCallback } from "./bindSubjectCallback.function.js";
|
|
5
|
+
function updateExistingTagComponent(tag, tempResult, existingSubject, subjectValue) {
|
|
6
|
+
const latestProps = tempResult.tagSupport.props;
|
|
7
|
+
let existingTag = existingSubject.tag;
|
|
8
|
+
// previously was something else, now a tag component
|
|
9
|
+
if (!existingTag) {
|
|
10
|
+
setValueRedraw(tempResult, existingSubject, tag);
|
|
11
|
+
tempResult.redraw();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// tag existingTag
|
|
15
|
+
const oldWrapper = existingTag.tagSupport.templater.wrapper;
|
|
16
|
+
const newWrapper = tempResult.wrapper;
|
|
17
|
+
let isSameTag = false;
|
|
18
|
+
if (oldWrapper && newWrapper) {
|
|
19
|
+
const oldFunction = oldWrapper.original;
|
|
20
|
+
const newFunction = newWrapper.original;
|
|
21
|
+
isSameTag = oldFunction === newFunction;
|
|
22
|
+
}
|
|
23
|
+
const oldTagSetup = existingTag.tagSupport;
|
|
24
|
+
oldTagSetup.latestProps = latestProps;
|
|
25
|
+
oldTagSetup.latestClonedProps = tempResult.tagSupport.clonedProps;
|
|
26
|
+
if (!isSameTag) {
|
|
27
|
+
destroyTagMemory(existingTag, existingSubject, subjectValue);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const subjectTagSupport = subjectValue?.tagSupport;
|
|
31
|
+
// old props may have changed, reclone first
|
|
32
|
+
const oldCloneProps = deepClone(subjectTagSupport.props); // tagSupport.clonedProps
|
|
33
|
+
const oldProps = subjectTagSupport?.props; // tagSupport.props
|
|
34
|
+
if (existingTag) {
|
|
35
|
+
const equal = oldTagSetup.hasPropChanges(oldProps, oldCloneProps, latestProps);
|
|
36
|
+
if (equal) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
setValueRedraw(tempResult, existingSubject, tag);
|
|
42
|
+
oldTagSetup.templater = tempResult;
|
|
43
|
+
const redraw = tempResult.redraw();
|
|
44
|
+
existingSubject.value.tag = oldTagSetup.newest = redraw;
|
|
45
|
+
if (!isSameTag) {
|
|
46
|
+
existingSubject.tag = redraw;
|
|
47
|
+
subjectValue.tagSupport = tempResult.tagSupport;
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
function updateExistingTag(templater, ogTag, existingSubject) {
|
|
52
|
+
const tagSupport = ogTag.tagSupport;
|
|
53
|
+
const oldest = tagSupport.oldest;
|
|
54
|
+
oldest.beforeRedraw();
|
|
55
|
+
const retag = templater.wrapper();
|
|
56
|
+
// move my props onto tagSupport
|
|
57
|
+
tagSupport.latestProps = retag.tagSupport.props;
|
|
58
|
+
tagSupport.latestClonedProps = retag.tagSupport.clonedProps;
|
|
59
|
+
tagSupport.memory = retag.tagSupport.memory;
|
|
60
|
+
retag.setSupport(tagSupport);
|
|
61
|
+
templater.newest = retag;
|
|
62
|
+
tagSupport.newest = retag;
|
|
63
|
+
oldest.afterRender();
|
|
64
|
+
ogTag.updateByTag(retag);
|
|
65
|
+
existingSubject.set(templater);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
export function updateExistingValue(existing, value, tag, variableName) {
|
|
69
|
+
const subjectValue = existing.value;
|
|
70
|
+
const ogTag = subjectValue?.tag;
|
|
71
|
+
const tempResult = value;
|
|
72
|
+
const existingSubject = existing;
|
|
73
|
+
// handle already seen tag components
|
|
74
|
+
if (isTagComponent(tempResult)) {
|
|
75
|
+
return updateExistingTagComponent(tag, tempResult, existingSubject, subjectValue);
|
|
76
|
+
}
|
|
77
|
+
// was component but no longer
|
|
78
|
+
if (existingSubject.tag) {
|
|
79
|
+
destroyTagMemory(existingSubject.tag, existingSubject, subjectValue);
|
|
80
|
+
}
|
|
81
|
+
else if (ogTag) {
|
|
82
|
+
return updateExistingTag(value, ogTag, existingSubject);
|
|
83
|
+
}
|
|
84
|
+
// now its a function
|
|
85
|
+
if (value instanceof Function) {
|
|
86
|
+
existingSubject.set(bindSubjectCallback(value, tag));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (isSubjectInstance(value)) {
|
|
90
|
+
existingSubject.set(value.value); // let ValueSubject now of newest value
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
existingSubject.set(value); // let ValueSubject now of newest value
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
function destroyTagMemory(existingTag, existingSubject, subjectValue) {
|
|
97
|
+
delete existingSubject.tag;
|
|
98
|
+
delete existingSubject.tagSupport;
|
|
99
|
+
delete subjectValue.tagSupport;
|
|
100
|
+
existingTag.destroy();
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=updateTag.utils.js.map
|