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/providers.d.ts
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { Tag } from "./Tag.class.js";
|
|
2
1
|
export type Provider = {
|
|
3
2
|
constructMethod: any;
|
|
4
3
|
instance: any;
|
|
5
4
|
clone: any;
|
|
6
5
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
currentTag: Tag | undefined;
|
|
10
|
-
ownerTag: Tag | undefined;
|
|
11
|
-
};
|
|
6
|
+
type functionProvider = <T>() => T;
|
|
7
|
+
type classProvider = new <T>(...args: any[]) => T;
|
|
12
8
|
export declare const providers: {
|
|
13
|
-
|
|
14
|
-
* @template T
|
|
15
|
-
* @param {(new (...args: any[]) => T) | () => T} constructor
|
|
16
|
-
* @returns {T}
|
|
17
|
-
*/
|
|
18
|
-
create: (constructMethod: any) => any;
|
|
9
|
+
create: <T>(constructMethod: classProvider | functionProvider) => T;
|
|
19
10
|
/**
|
|
20
11
|
* @template T
|
|
21
12
|
* @param {(new (...args: any[]) => T) | () => T} constructor
|
|
@@ -23,3 +14,4 @@ export declare const providers: {
|
|
|
23
14
|
*/
|
|
24
15
|
inject: (constructor: any) => any;
|
|
25
16
|
};
|
|
17
|
+
export {};
|
package/js/providers.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { deepClone } from "./deepFunctions.js";
|
|
2
|
-
import { setUse } from "./
|
|
3
|
-
|
|
2
|
+
import { setUse } from "./setUse.function.js";
|
|
3
|
+
// TODO: rename
|
|
4
|
+
setUse.memory.providerConfig = {
|
|
4
5
|
providers: [],
|
|
5
|
-
|
|
6
|
+
currentTagSupport: undefined,
|
|
6
7
|
ownerTag: undefined,
|
|
7
8
|
};
|
|
8
9
|
function get(constructMethod) {
|
|
9
|
-
|
|
10
|
+
const config = setUse.memory.providerConfig;
|
|
11
|
+
const providers = config.providers;
|
|
12
|
+
return providers.find(provider => provider.constructMethod === constructMethod);
|
|
10
13
|
}
|
|
11
14
|
export const providers = {
|
|
12
|
-
/**
|
|
13
|
-
* @template T
|
|
14
|
-
* @param {(new (...args: any[]) => T) | () => T} constructor
|
|
15
|
-
* @returns {T}
|
|
16
|
-
*/
|
|
17
15
|
create: (constructMethod) => {
|
|
18
16
|
const existing = get(constructMethod);
|
|
19
17
|
if (existing) {
|
|
@@ -22,6 +20,7 @@ export const providers = {
|
|
|
22
20
|
}
|
|
23
21
|
// Providers with provider requirements just need to use providers.create() and providers.inject()
|
|
24
22
|
const instance = constructMethod.constructor ? new constructMethod() : constructMethod();
|
|
23
|
+
const config = setUse.memory.providerConfig;
|
|
25
24
|
config.providers.push({
|
|
26
25
|
constructMethod,
|
|
27
26
|
instance,
|
|
@@ -39,11 +38,12 @@ export const providers = {
|
|
|
39
38
|
if (oldValue) {
|
|
40
39
|
return oldValue.instance;
|
|
41
40
|
}
|
|
41
|
+
const config = setUse.memory.providerConfig;
|
|
42
42
|
let owner = {
|
|
43
43
|
ownerTag: config.ownerTag
|
|
44
44
|
};
|
|
45
45
|
while (owner.ownerTag) {
|
|
46
|
-
const ownerProviders = owner.ownerTag.providers;
|
|
46
|
+
const ownerProviders = owner.ownerTag.tagSupport.memory.providers;
|
|
47
47
|
const provider = ownerProviders.find(provider => {
|
|
48
48
|
if (provider.constructMethod === constructor) {
|
|
49
49
|
return true;
|
|
@@ -56,23 +56,31 @@ export const providers = {
|
|
|
56
56
|
}
|
|
57
57
|
owner = owner.ownerTag; // cause reloop
|
|
58
58
|
}
|
|
59
|
-
const msg = `Could not inject provider: ${constructor}`;
|
|
59
|
+
const msg = `Could not inject provider: ${constructor.name} ${constructor}`;
|
|
60
60
|
console.warn(`${msg}. Available providers`, config.providers);
|
|
61
61
|
throw new Error(msg);
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
setUse({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
config.providers.push(...tag.providers);
|
|
71
|
-
}
|
|
65
|
+
beforeRender: (tagSupport, ownerTag) => {
|
|
66
|
+
run(tagSupport, ownerTag);
|
|
67
|
+
},
|
|
68
|
+
beforeRedraw: (tagSupport, tag) => {
|
|
69
|
+
run(tagSupport, tag.ownerTag);
|
|
72
70
|
},
|
|
73
|
-
afterRender: (
|
|
74
|
-
|
|
71
|
+
afterRender: (tagSupport) => {
|
|
72
|
+
const config = setUse.memory.providerConfig;
|
|
73
|
+
tagSupport.memory.providers = [...config.providers];
|
|
75
74
|
config.providers.length = 0;
|
|
76
75
|
}
|
|
77
76
|
});
|
|
77
|
+
function run(tagSupport, ownerTag) {
|
|
78
|
+
const config = setUse.memory.providerConfig;
|
|
79
|
+
config.currentTagSuport = tagSupport;
|
|
80
|
+
config.ownerTag = ownerTag;
|
|
81
|
+
if (tagSupport.memory.providers.length) {
|
|
82
|
+
config.providers.length = 0;
|
|
83
|
+
config.providers.push(...tagSupport.memory.providers);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
78
86
|
//# sourceMappingURL=providers.js.map
|
package/js/providers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../ts/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../ts/providers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAQ7C,eAAe;AACf,MAAM,CAAC,MAAM,CAAC,cAAc,GAAG;IAC7B,SAAS,EAAE,EAAgB;IAE3B,iBAAiB,EAAE,SAAmC;IACtD,QAAQ,EAAE,SAA4B;CACvC,CAAA;AAED,SAAS,GAAG,CAAC,eAAyB;IACpC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAA;IAC3C,MAAM,SAAS,GAAe,MAAM,CAAC,SAAS,CAAA;IAC9C,OAAO,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,eAAe,KAAK,eAAe,CAAC,CAAA;AACjF,CAAC;AAKD,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,MAAM,EAAE,CACN,eAAiD,EAC9C,EAAE;QACL,MAAM,QAAQ,GAAG,GAAG,CAAC,eAAe,C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M,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;QAC3B,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IACvD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TemplaterResult } from "./templater.utils.js";
|
|
2
|
+
import { Tag } from "./Tag.class.js";
|
|
3
|
+
export declare function redrawTag(existingTag: Tag | undefined, templater: TemplaterResult, // latest tag function to call for rendering
|
|
4
|
+
ownerTag?: Tag): {
|
|
5
|
+
remit: boolean;
|
|
6
|
+
retag: Tag;
|
|
7
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getTagSupport } from "./getTagSupport.js";
|
|
2
|
+
export function redrawTag(existingTag, templater, // latest tag function to call for rendering
|
|
3
|
+
ownerTag) {
|
|
4
|
+
const tagSupport = existingTag?.tagSupport || getTagSupport(templater);
|
|
5
|
+
const result = templater.renderWithSupport(tagSupport, existingTag, ownerTag);
|
|
6
|
+
return result;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=redrawTag.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redrawTag.function.js","sourceRoot":"","sources":["../ts/redrawTag.function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIlD,MAAM,UAAU,SAAS,CACvB,WAA4B,EAC5B,SAA0B,EAAE,4CAA4C;AACxE,QAAc;IAEd,MAAM,UAAU,GAAG,WAAW,EAAE,UAAU,IAAI,aAAa,CAAC,SAAS,CAAC,CAAA;IAEtE,MAAM,MAAM,GAAG,SAAS,CAAC,iBAAiB,CACxC,UAAU,EACV,WAAW,EACX,QAAQ,CACT,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/js/render.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function buildItemTagMap(tag: Tag, template: {
|
|
3
|
-
string: string;
|
|
4
|
-
context: Context;
|
|
5
|
-
}, // {string, context}
|
|
6
|
-
insertBefore: Element): (ChildNode | Element)[];
|
|
1
|
+
export declare function buildClones(temporary: Element, insertBefore: Element): ChildNode[];
|
package/js/render.js
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export function buildItemTagMap(tag, template, // {string, context}
|
|
3
|
-
insertBefore) {
|
|
4
|
-
const temporary = document.createElement('div');
|
|
5
|
-
temporary.id = 'tag-temp-holder';
|
|
6
|
-
// render content with a first child that we can know is our first element
|
|
7
|
-
temporary.innerHTML = '<div></div>' + template.string;
|
|
8
|
-
const context = tag.update();
|
|
9
|
-
interpolateElement(temporary, context, tag);
|
|
10
|
-
const clones = buildClones(temporary, insertBefore);
|
|
11
|
-
tag.clones.push(...clones);
|
|
12
|
-
return clones;
|
|
13
|
-
}
|
|
14
|
-
function buildClones(temporary, insertBefore) {
|
|
1
|
+
export function buildClones(temporary, insertBefore) {
|
|
15
2
|
const clones = [];
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
let nextSibling = sibling.nextSibling;
|
|
19
|
-
temporary.removeChild(templateClone); // remove the div
|
|
3
|
+
const template = temporary.children[0];
|
|
4
|
+
let nextSibling = template.content.firstChild;
|
|
20
5
|
while (nextSibling) {
|
|
21
6
|
const nextNextSibling = nextSibling.nextSibling;
|
|
22
7
|
buildSibling(nextSibling, insertBefore);
|
|
@@ -26,6 +11,7 @@ function buildClones(temporary, insertBefore) {
|
|
|
26
11
|
return clones;
|
|
27
12
|
}
|
|
28
13
|
function buildSibling(nextSibling, insertBefore) {
|
|
29
|
-
insertBefore.parentNode
|
|
14
|
+
const parentNode = insertBefore.parentNode;
|
|
15
|
+
parentNode.insertBefore(nextSibling, insertBefore);
|
|
30
16
|
}
|
|
31
17
|
//# sourceMappingURL=render.js.map
|
package/js/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../ts/render.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../ts/render.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW,CACzB,SAAkB,EAClB,YAAqB;IAErB,MAAM,MAAM,GAAG,EAAE,CAAA;IACjB,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAwB,CAAA;IAC7D,IAAI,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAA;IAE7C,OAAO,WAAW,EAAE,CAAC;QACnB,MAAM,eAAe,GAAG,WAAW,CAAC,WAAW,CAAA;QAC/C,YAAY,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;QACvC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACxB,WAAW,GAAG,eAAe,CAAA;IAC/B,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,YAAY,CACnB,WAAsB,EACtB,YAAqB;IAErB,MAAM,UAAU,GAAG,YAAY,CAAC,UAAwB,CAAA;IACxD,UAAU,CAAC,YAAY,CACrB,WAAW,EACX,YAAY,CACb,CAAA;AACH,CAAC"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { TagSupport } from "./getTagSupport.js";
|
|
2
|
+
import { TagComponent, TemplaterResult } from "./templater.utils.js";
|
|
2
3
|
import { Tag } from "./Tag.class.js";
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
export declare function renderAppToElement(app: TagComponent, // (...args: unknown[]) => TemplaterResult,
|
|
5
|
+
element: Element, props: unknown): {
|
|
6
|
+
tag: Tag;
|
|
7
|
+
tags: TagComponent[];
|
|
8
|
+
};
|
|
5
9
|
export declare function applyTagUpdater(wrapper: TemplaterResult): {
|
|
6
10
|
tag: Tag;
|
|
7
11
|
tagSupport: TagSupport;
|
|
8
12
|
};
|
|
13
|
+
/** Overwrites arguments.tagSupport.mutatingRender */
|
|
14
|
+
export declare function addAppTagRender(tagSupport: TagSupport, tag: Tag): void;
|
package/js/renderAppToElement.js
CHANGED
|
@@ -1,38 +1,57 @@
|
|
|
1
|
-
import { interpolateElement } from "./interpolateElement.js";
|
|
2
|
-
import { getTagSupport } from "./getTagSupport.js";
|
|
3
1
|
import { runBeforeRender } from "./tagRunner.js";
|
|
4
|
-
|
|
2
|
+
const appElements = [];
|
|
3
|
+
export function renderAppToElement(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
|
+
}
|
|
5
11
|
// Create the app which returns [props, runOneTimeFunction]
|
|
6
12
|
const wrapper = app(props);
|
|
7
13
|
// have a function setup and call the tagWrapper with (props, {update, async, on})
|
|
8
14
|
const result = applyTagUpdater(wrapper);
|
|
9
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) {
|
|
10
39
|
let lastTag;
|
|
11
40
|
tagSupport.mutatingRender = () => {
|
|
12
|
-
runBeforeRender(tagSupport, tag);
|
|
13
41
|
tag.beforeRedraw();
|
|
14
|
-
const
|
|
15
|
-
fromTag.
|
|
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);
|
|
16
48
|
tag.afterRender();
|
|
17
49
|
tag.updateByTag(fromTag);
|
|
18
50
|
if (lastTag) {
|
|
19
|
-
lastTag.destroy(0);
|
|
51
|
+
lastTag.destroy({ stagger: 0 });
|
|
20
52
|
}
|
|
53
|
+
tagSupport.newest = fromTag;
|
|
21
54
|
return lastTag;
|
|
22
55
|
};
|
|
23
|
-
const context = tag.updateValues(tag.values);
|
|
24
|
-
const template = tag.getTemplate();
|
|
25
|
-
element.innerHTML = template.string;
|
|
26
|
-
interpolateElement(element, context, tag);
|
|
27
|
-
}
|
|
28
|
-
export function applyTagUpdater(wrapper) {
|
|
29
|
-
const tagSupport = getTagSupport(wrapper);
|
|
30
|
-
runBeforeRender(tagSupport);
|
|
31
|
-
// Call the apps function for our tag templater
|
|
32
|
-
const templater = tagSupport.templater;
|
|
33
|
-
const tag = templater.wrapper();
|
|
34
|
-
tag.tagSupport = tagSupport;
|
|
35
|
-
tag.afterRender();
|
|
36
|
-
return { tag, tagSupport };
|
|
37
56
|
}
|
|
38
57
|
//# sourceMappingURL=renderAppToElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderAppToElement.js","sourceRoot":"","sources":["../ts/renderAppToElement.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderAppToElement.js","sourceRoot":"","sources":["../ts/renderAppToElement.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAIhD,MAAM,WAAW,GAAmC,EAAE,CAAA;AAEtD,MAAM,UAAU,kBAAkB,CAChC,GAAiB,EAAE,2CAA2C;AAC9D,OAAgB,EAChB,KAAc;IAEd,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,CAAA;IAC/E,IAAG,WAAW,IAAI,CAAC,EAAE,CAAC;QACpB,WAAW,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;QACtC,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;QAClC,OAAO,CAAC,IAAI,CAAC,6DAA6D,EAAE,EAAC,OAAO,EAAC,CAAC,CAAA;IACxF,CAAC;IAED,2DAA2D;IAC3D,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAA+B,CAAA;IAExD,kFAAkF;IAClF,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IACvC,MAAM,EAAC,GAAG,EAAE,UAAU,EAAC,GAAG,MAAM,CAAA;IAEhC,GAAG,CAAC,UAAU,GAAG,OAAO,CAAA;IAExB,eAAe,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;IAEhC,+CAA+C;IAE/C,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;IACtD,WAAW,CAAC,YAAY,CAAC,YAAY,EAAC,0BA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,CAAC,CAAA;QAC9B,GAAG,CAAC,WAAW,EAAE,CAAA;QACjB,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAExB,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,23 @@
|
|
|
1
|
+
import { Tag } from "./Tag.class.js";
|
|
2
|
+
import { TagSupport } from "./getTagSupport";
|
|
3
|
+
import { Config } from "./state";
|
|
4
|
+
interface TagUse {
|
|
5
|
+
beforeRender: (tagSupport: TagSupport, ownerTag: Tag) => void;
|
|
6
|
+
beforeRedraw: (tagSupport: TagSupport, tag: Tag) => void;
|
|
7
|
+
afterRender: (tagSupport: TagSupport, tag: Tag) => void;
|
|
8
|
+
beforeDestroy: (tagSupport: TagSupport, tag: Tag) => void;
|
|
9
|
+
}
|
|
10
|
+
export type UseOptions = {
|
|
11
|
+
beforeRender?: (tagSupport: TagSupport, ownerTag: Tag) => void;
|
|
12
|
+
beforeRedraw?: (tagSupport: TagSupport, tag: Tag) => void;
|
|
13
|
+
afterRender?: (tagSupport: TagSupport, tag: Tag) => void;
|
|
14
|
+
beforeDestroy?: (tagSupport: TagSupport, tag: Tag) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function setUse(use: UseOptions): void;
|
|
17
|
+
export declare namespace setUse {
|
|
18
|
+
var tagUse: TagUse[];
|
|
19
|
+
var memory: Record<string, any> & {
|
|
20
|
+
stateConfig: Config;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const tagUse = [];
|
|
2
|
+
export function setUse(use) {
|
|
3
|
+
// must provide defaults
|
|
4
|
+
const useMe = {
|
|
5
|
+
beforeRender: use.beforeRender || (() => undefined),
|
|
6
|
+
beforeRedraw: use.beforeRedraw || (() => undefined),
|
|
7
|
+
afterRender: use.afterRender || (() => undefined),
|
|
8
|
+
beforeDestroy: use.beforeDestroy || (() => undefined),
|
|
9
|
+
};
|
|
10
|
+
setUse.tagUse.push(useMe);
|
|
11
|
+
}
|
|
12
|
+
setUse.tagUse = tagUse;
|
|
13
|
+
setUse.memory = {};
|
|
14
|
+
//# sourceMappingURL=setUse.function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setUse.function.js","sourceRoot":"","sources":["../ts/setUse.function.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,GAAa,EAAE,CAAA;AAsB3B,MAAM,UAAU,MAAM,CAAC,GAAe;IACpC,wBAAwB;IACxB,MAAM,KAAK,GAAW;QACpB,YAAY,EAAE,GAAG,CAAC,YAAY,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;QACnD,YAAY,EAAE,GAAG,CAAC,YAAY,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;QACnD,WAAW,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;QACjD,aAAa,EAAE,GAAG,CAAC,aAAa,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;KACtD,CAAA;IAED,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAC3B,CAAC;AAED,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,MAAM,GAAG,EAAkD,CAAA"}
|
package/js/state.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import { TagSupport } from "./getTagSupport.js";
|
|
2
1
|
export type StateConfig = ((x?: any) => [any, any]);
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
export type StateTagSupport = TagSupport & {
|
|
9
|
-
state?: State;
|
|
2
|
+
type StateConfigItem = {
|
|
3
|
+
callback?: StateConfig;
|
|
4
|
+
lastValue?: any;
|
|
5
|
+
defaultValue?: any;
|
|
10
6
|
};
|
|
11
|
-
export
|
|
7
|
+
export type StateConfigArray = StateConfigItem[];
|
|
8
|
+
export type Config = {
|
|
12
9
|
array: StateConfigArray;
|
|
13
10
|
rearray: StateConfigArray;
|
|
14
11
|
};
|
|
12
|
+
export type State = {
|
|
13
|
+
newest: StateConfigArray;
|
|
14
|
+
};
|
|
15
15
|
/**
|
|
16
16
|
* @template T
|
|
17
17
|
* @param {T} defaultValue
|
|
18
18
|
* @returns {T}
|
|
19
19
|
*/
|
|
20
|
-
export declare function state<T>(defaultValue: T, getSetMethod?: (x: T) => [T, T]): T;
|
|
21
|
-
export declare function getStateValue(state:
|
|
20
|
+
export declare function state<T>(defaultValue: T | (() => T), getSetMethod?: (x: T) => [T, T]): T;
|
|
21
|
+
export declare function getStateValue(state: StateConfigItem): any;
|
|
22
|
+
export declare class StateEchoBack {
|
|
23
|
+
}
|
|
24
|
+
export {};
|
package/js/state.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { setUse } from "./
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { setUse } from "./setUse.function.js";
|
|
2
|
+
// TODO: rename
|
|
3
|
+
setUse.memory.stateConfig = {
|
|
4
|
+
array: [], // state memory on the first render
|
|
5
|
+
rearray: [], // state memory to be used before the next render
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* @template T
|
|
@@ -9,47 +10,63 @@ export const config = {
|
|
|
9
10
|
* @returns {T}
|
|
10
11
|
*/
|
|
11
12
|
export function state(defaultValue, getSetMethod) {
|
|
13
|
+
const config = setUse.memory.stateConfig;
|
|
12
14
|
const restate = config.rearray[config.array.length];
|
|
13
15
|
if (restate) {
|
|
14
16
|
const oldValue = getStateValue(restate);
|
|
15
|
-
config.array.push(
|
|
17
|
+
config.array.push({
|
|
18
|
+
callback: getSetMethod,
|
|
19
|
+
lastValue: oldValue,
|
|
20
|
+
defaultValue: restate.defaultValue,
|
|
21
|
+
});
|
|
16
22
|
return oldValue; // return old value instead
|
|
17
23
|
}
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const defaultFn = defaultValue instanceof Function ? defaultValue : () => defaultValue;
|
|
25
|
+
const initValue = defaultFn();
|
|
26
|
+
config.array.push({
|
|
27
|
+
callback: getSetMethod,
|
|
28
|
+
lastValue: initValue,
|
|
29
|
+
defaultValue: initValue,
|
|
30
|
+
});
|
|
31
|
+
return initValue;
|
|
20
32
|
}
|
|
21
33
|
setUse({
|
|
22
|
-
beforeRender: (tagSupport) =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
beforeRedraw: (tagSupport) => {
|
|
28
|
-
const state = tagSupport.state;
|
|
29
|
-
config.rearray.length = 0;
|
|
30
|
-
if (state?.newest.length) {
|
|
31
|
-
// state.oldest = [...state.newest]
|
|
32
|
-
config.rearray.push(...state.newest);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
afterRender: (tagSupport) => {
|
|
34
|
+
beforeRender: (tagSupport) => initState(tagSupport),
|
|
35
|
+
beforeRedraw: (tagSupport) => initState(tagSupport),
|
|
36
|
+
afterRender: (tagSupport, tag) => {
|
|
37
|
+
const state = tagSupport.memory.state;
|
|
38
|
+
const config = setUse.memory.stateConfig;
|
|
36
39
|
if (config.rearray.length) {
|
|
37
40
|
if (config.rearray.length !== config.array.length) {
|
|
38
|
-
|
|
41
|
+
const message = `States lengths mismatched ${config.rearray.length} !== ${config.array.length}`;
|
|
42
|
+
console.error(message, {
|
|
43
|
+
oldStates: config.array,
|
|
44
|
+
newStates: config.rearray,
|
|
45
|
+
component: tagSupport.templater?.wrapper.original
|
|
46
|
+
});
|
|
47
|
+
throw new Error(message);
|
|
39
48
|
}
|
|
40
49
|
}
|
|
41
|
-
config.rearray.length = 0
|
|
42
|
-
|
|
43
|
-
state.newest.length = 0
|
|
44
|
-
state.newest.push(...config.array)
|
|
45
|
-
state.
|
|
46
|
-
config.array.length = 0
|
|
50
|
+
// config.rearray.length = 0 // clean up any previous runs
|
|
51
|
+
config.rearray = []; // clean up any previous runs
|
|
52
|
+
// state.newest.length = 0
|
|
53
|
+
// state.newest.push(...config.array) as any
|
|
54
|
+
state.newest = [...config.array];
|
|
55
|
+
// config.array.length = 0
|
|
56
|
+
config.array = [];
|
|
47
57
|
}
|
|
48
58
|
});
|
|
49
|
-
export function getStateValue(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
export function getStateValue(
|
|
60
|
+
// state: StateConfig,
|
|
61
|
+
state) {
|
|
62
|
+
const callback = state.callback;
|
|
63
|
+
if (!callback) {
|
|
64
|
+
return state.defaultValue;
|
|
65
|
+
}
|
|
66
|
+
const oldState = callback(StateEchoBack); // get value and set to undefined
|
|
67
|
+
const [oldValue] = oldState;
|
|
68
|
+
const [checkValue] = callback(oldValue); // set back to original value
|
|
69
|
+
if (checkValue !== StateEchoBack) {
|
|
53
70
|
const error = new Error('State property not used correctly.\n\n' +
|
|
54
71
|
'For "let" state use `let name = state(default, x => [name, name = x])`\n\n' +
|
|
55
72
|
'For "const" state use `const name = state(default)`\n\n' +
|
|
@@ -58,6 +75,24 @@ export function getStateValue(state) {
|
|
|
58
75
|
}
|
|
59
76
|
return oldValue;
|
|
60
77
|
}
|
|
61
|
-
class
|
|
78
|
+
export class StateEchoBack {
|
|
79
|
+
}
|
|
80
|
+
function initState(tagSupport) {
|
|
81
|
+
const state = tagSupport.memory.state;
|
|
82
|
+
const config = setUse.memory.stateConfig;
|
|
83
|
+
if (config.rearray.length) {
|
|
84
|
+
const message = 'last array not cleared';
|
|
85
|
+
console.error(message, {
|
|
86
|
+
config,
|
|
87
|
+
component: tagSupport.templater?.wrapper.original,
|
|
88
|
+
state,
|
|
89
|
+
});
|
|
90
|
+
throw message;
|
|
91
|
+
}
|
|
92
|
+
// TODO: this maybe redundant and not needed
|
|
93
|
+
config.rearray = []; // .length = 0
|
|
94
|
+
if (state?.newest.length) {
|
|
95
|
+
config.rearray.push(...state.newest);
|
|
96
|
+
}
|
|
62
97
|
}
|
|
63
98
|
//# sourceMappingURL=state.js.map
|
package/js/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../ts/state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../ts/state.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAuB7C,eAAe;AACf,MAAM,CAAC,MAAM,CAAC,WAAW,GAAG;IAC1B,KAAK,EAAE,EAAsB,EAAE,mCAAmC;IAClE,OAAO,EAAE,EAAsB,EAAE,iDAAiD;CACzE,CAAA;AAEX;;;;GAIG;AACH,MAAM,UAAU,KAAK,CACnB,YAA2B,EAC3B,YAA+B;IAE/B,MAAM,MAAM,GAAW,MAAM,CAAC,MAAM,CAAC,WAAW,CAAA;IAEhD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACnD,IAAG,OAAO,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;YAChB,QAAQ,EAAE,YAA2B;YACrC,SAAS,EAAE,QAAQ;YACnB,YAAY,EAAE,OAAO,CAAC,YAAY;SACnC,CAAC,CAAA;QACF,OAAO,QAAQ,CAAA,CAAC,2BAA2B;IAC7C,CAAC;IAED,MAAM,SAAS,GAAG,YAAY,YAAY,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY,CAAA;IACtF,MAAM,SAAS,GAAG,SAAS,EAAE,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AAA,CAAC,cAAc;IAElC,IAAG,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACxB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAE,GAAG,KAAK,CAAC,MAAM,CAAE,CAAA;IACxC,CAAC;AACH,CAAC"}
|
package/js/tag.d.ts
CHANGED
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { Tag } from "./Tag.class.js";
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
tagged: boolean;
|
|
9
|
-
wrapper: Wrapper;
|
|
10
|
-
newest?: Tag;
|
|
11
|
-
oldest?: Tag;
|
|
12
|
-
redraw?: () => Tag | undefined;
|
|
13
|
-
}
|
|
14
|
-
type TagResult = (props: Props, // props or children
|
|
15
|
-
children?: Tag) => Tag;
|
|
16
|
-
export declare function tag<T>(tagComponent: T | TagResult): T;
|
|
17
|
-
export {};
|
|
2
|
+
import { TagComponent } from "./templater.utils.js";
|
|
3
|
+
export declare const tags: TagComponent[];
|
|
4
|
+
export type TagEnv = {
|
|
5
|
+
children?: Tag;
|
|
6
|
+
};
|
|
7
|
+
export declare function tag<T>(tagComponent: T | TagComponent): T;
|