@esportsplus/template 0.28.3 → 0.29.2
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/README.md +431 -0
- package/build/attributes.d.ts +7 -1
- package/build/attributes.js +86 -33
- package/build/constants.d.ts +3 -11
- package/build/constants.js +4 -32
- package/build/event/constants.d.ts +3 -0
- package/build/event/constants.js +13 -0
- package/build/event/index.d.ts +9 -1
- package/build/event/index.js +29 -35
- package/build/event/ontick.js +6 -9
- package/build/html.d.ts +9 -0
- package/build/html.js +7 -0
- package/build/index.d.ts +8 -2
- package/build/index.js +8 -1
- package/build/render.d.ts +2 -2
- package/build/render.js +2 -3
- package/build/runtime.d.ts +1 -0
- package/build/runtime.js +5 -0
- package/build/slot/array.d.ts +3 -3
- package/build/slot/array.js +11 -14
- package/build/slot/cleanup.d.ts +1 -1
- package/build/slot/cleanup.js +1 -2
- package/build/slot/effect.js +5 -7
- package/build/slot/index.js +1 -7
- package/build/slot/render.js +6 -8
- package/build/svg.d.ts +1 -1
- package/build/svg.js +1 -1
- package/build/transformer/codegen.d.ts +18 -0
- package/build/transformer/codegen.js +316 -0
- package/build/transformer/index.d.ts +12 -0
- package/build/transformer/index.js +62 -0
- package/build/transformer/parser.d.ts +18 -0
- package/build/transformer/parser.js +166 -0
- package/build/transformer/plugins/esbuild.d.ts +5 -0
- package/build/transformer/plugins/esbuild.js +35 -0
- package/build/transformer/plugins/tsc.d.ts +3 -0
- package/build/transformer/plugins/tsc.js +4 -0
- package/build/transformer/plugins/vite.d.ts +5 -0
- package/build/transformer/plugins/vite.js +37 -0
- package/build/transformer/ts-parser.d.ts +21 -0
- package/build/transformer/ts-parser.js +72 -0
- package/build/transformer/type-analyzer.d.ts +7 -0
- package/build/transformer/type-analyzer.js +230 -0
- package/build/types.d.ts +2 -3
- package/build/utilities.d.ts +7 -0
- package/build/utilities.js +31 -0
- package/package.json +33 -4
- package/src/attributes.ts +115 -51
- package/src/constants.ts +6 -53
- package/src/event/constants.ts +16 -0
- package/src/event/index.ts +36 -42
- package/src/event/onconnect.ts +1 -1
- package/src/event/onresize.ts +1 -1
- package/src/event/ontick.ts +7 -11
- package/src/html.ts +18 -0
- package/src/index.ts +8 -2
- package/src/render.ts +6 -7
- package/src/runtime.ts +8 -0
- package/src/slot/array.ts +18 -24
- package/src/slot/cleanup.ts +3 -4
- package/src/slot/effect.ts +6 -8
- package/src/slot/index.ts +2 -8
- package/src/slot/render.ts +7 -9
- package/src/svg.ts +1 -1
- package/src/transformer/codegen.ts +518 -0
- package/src/transformer/index.ts +98 -0
- package/src/transformer/parser.ts +239 -0
- package/src/transformer/plugins/esbuild.ts +46 -0
- package/src/transformer/plugins/tsc.ts +7 -0
- package/src/transformer/plugins/vite.ts +49 -0
- package/src/transformer/ts-parser.ts +123 -0
- package/src/transformer/type-analyzer.ts +334 -0
- package/src/types.ts +3 -4
- package/src/utilities.ts +52 -0
- package/storage/rewrite-analysis-2026-01-04.md +439 -0
- package/test/constants.ts +69 -0
- package/test/effects.ts +237 -0
- package/test/events.ts +318 -0
- package/test/imported-values.ts +253 -0
- package/test/nested.ts +298 -0
- package/test/slots.ts +259 -0
- package/test/spread.ts +290 -0
- package/test/static.ts +118 -0
- package/test/templates.ts +473 -0
- package/test/tsconfig.json +17 -0
- package/test/vite.config.ts +50 -0
- package/build/html/index.d.ts +0 -9
- package/build/html/index.js +0 -29
- package/build/html/parser.d.ts +0 -5
- package/build/html/parser.js +0 -165
- package/build/utilities/element.d.ts +0 -11
- package/build/utilities/element.js +0 -9
- package/build/utilities/fragment.d.ts +0 -3
- package/build/utilities/fragment.js +0 -10
- package/build/utilities/marker.d.ts +0 -2
- package/build/utilities/marker.js +0 -4
- package/build/utilities/node.d.ts +0 -9
- package/build/utilities/node.js +0 -10
- package/build/utilities/raf.d.ts +0 -2
- package/build/utilities/raf.js +0 -1
- package/build/utilities/text.d.ts +0 -2
- package/build/utilities/text.js +0 -9
- package/src/html/index.ts +0 -48
- package/src/html/parser.ts +0 -235
- package/src/utilities/element.ts +0 -28
- package/src/utilities/fragment.ts +0 -19
- package/src/utilities/marker.ts +0 -6
- package/src/utilities/node.ts +0 -29
- package/src/utilities/raf.ts +0 -1
- package/src/utilities/text.ts +0 -15
package/build/constants.js
CHANGED
|
@@ -1,39 +1,11 @@
|
|
|
1
|
-
import { fragment } from './utilities
|
|
1
|
+
import { fragment } from './utilities.js';
|
|
2
2
|
const ARRAY_SLOT = Symbol('template.array.slot');
|
|
3
3
|
const CLEANUP = Symbol('template.cleanup');
|
|
4
4
|
const EMPTY_FRAGMENT = fragment('');
|
|
5
|
-
const NODE_CLOSING = 1;
|
|
6
|
-
const NODE_COMMENT = 2;
|
|
7
|
-
const NODE_ELEMENT = 3;
|
|
8
|
-
const NODE_SLOT = 4;
|
|
9
|
-
const NODE_VOID = 5;
|
|
10
|
-
const NODE_WHITELIST = {
|
|
11
|
-
'/': NODE_CLOSING,
|
|
12
|
-
'!': NODE_COMMENT,
|
|
13
|
-
'area': NODE_VOID,
|
|
14
|
-
'base': NODE_VOID,
|
|
15
|
-
'br': NODE_VOID,
|
|
16
|
-
'col': NODE_VOID,
|
|
17
|
-
'embed': NODE_VOID,
|
|
18
|
-
'hr': NODE_VOID,
|
|
19
|
-
'img': NODE_VOID,
|
|
20
|
-
'input': NODE_VOID,
|
|
21
|
-
'keygen': NODE_VOID,
|
|
22
|
-
'link': NODE_VOID,
|
|
23
|
-
'menuitem': NODE_VOID,
|
|
24
|
-
'meta': NODE_VOID,
|
|
25
|
-
'param': NODE_VOID,
|
|
26
|
-
'source': NODE_VOID,
|
|
27
|
-
'track': NODE_VOID,
|
|
28
|
-
'wbr': NODE_VOID
|
|
29
|
-
};
|
|
30
|
-
const REGEX_EMPTY_TEXT_NODES = /(>|}|\s)\s+(<|{|\s)/g;
|
|
31
|
-
const REGEX_EVENTS = /(?:\s*on[\w-:]+\s*=(?:\s*["'][^"']*["'])*)/g;
|
|
32
|
-
const REGEX_SLOT_ATTRIBUTES = /<[\w-]+([^><]*{{\$}}[^><]*)>/g;
|
|
33
|
-
const REGEX_SLOT_NODES = /<([\w-]+|[\/!])(?:([^><]*{{\$}}[^><]*)|(?:[^><]*))?>|{{\$}}/g;
|
|
34
5
|
const SLOT_HTML = '<!--$-->';
|
|
35
|
-
const SLOT_MARKER = '{{$}}';
|
|
36
6
|
const STATE_HYDRATING = 0;
|
|
37
7
|
const STATE_NONE = 1;
|
|
38
8
|
const STATE_WAITING = 2;
|
|
39
|
-
|
|
9
|
+
const STORE = Symbol('template.store');
|
|
10
|
+
export { ARRAY_SLOT, CLEANUP, EMPTY_FRAGMENT, SLOT_HTML, STATE_HYDRATING, STATE_NONE, STATE_WAITING, STORE };
|
|
11
|
+
export * from './event/constants.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const DIRECT_ATTACH_EVENTS = new Set([
|
|
2
|
+
'onblur',
|
|
3
|
+
'onerror',
|
|
4
|
+
'onfocus', 'onfocusin', 'onfocusout',
|
|
5
|
+
'onload',
|
|
6
|
+
'onplay', 'onpause', 'onended', 'ontimeupdate',
|
|
7
|
+
'onreset',
|
|
8
|
+
'onscroll', 'onsubmit'
|
|
9
|
+
]);
|
|
10
|
+
const LIFECYCLE_EVENTS = new Set([
|
|
11
|
+
'onconnect', 'ondisconnect', 'onrender', 'onresize', 'ontick'
|
|
12
|
+
]);
|
|
13
|
+
export { DIRECT_ATTACH_EVENTS, LIFECYCLE_EVENTS };
|
package/build/event/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { Element } from '../types.js';
|
|
2
|
-
declare const _default:
|
|
2
|
+
declare const _default: {
|
|
3
|
+
delegate: (element: Element, event: string, listener: Function) => void;
|
|
4
|
+
direct: (element: Element, event: string, listener: Function) => void;
|
|
5
|
+
onconnect: (element: globalThis.Element, listener: Function) => void;
|
|
6
|
+
ondisconnect: (element: Element, listener: Function) => void;
|
|
7
|
+
onrender: (element: Element, listener: Function) => void;
|
|
8
|
+
onresize: (element: Element, listener: Function) => void;
|
|
9
|
+
ontick: (element: globalThis.Element, listener: Function) => void;
|
|
10
|
+
};
|
|
3
11
|
export default _default;
|
package/build/event/index.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { root } from '@esportsplus/reactivity';
|
|
2
2
|
import { defineProperty } from '@esportsplus/utilities';
|
|
3
|
-
import {
|
|
4
|
-
import { parentElement } from '../utilities/node.js';
|
|
5
|
-
import { ondisconnect } from '../slot/cleanup.js';
|
|
3
|
+
import { ondisconnect as disconnect } from '../slot/cleanup.js';
|
|
6
4
|
import onconnect from './onconnect.js';
|
|
7
5
|
import onresize from './onresize.js';
|
|
8
6
|
import ontick from './ontick.js';
|
|
9
|
-
let
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
7
|
+
let controllers = new Map(), host = window.document, keys = {}, passive = new Set([
|
|
8
|
+
'animationend', 'animationiteration', 'animationstart',
|
|
9
|
+
'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'mousewheel',
|
|
10
|
+
'pointerenter', 'pointerleave', 'pointermove', 'pointerout', 'pointerover',
|
|
11
|
+
'scroll',
|
|
12
|
+
'touchcancel', 'touchend', 'touchleave', 'touchmove', 'touchstart', 'transitionend',
|
|
13
|
+
'wheel'
|
|
16
14
|
]);
|
|
17
|
-
['
|
|
15
|
+
['mousemove', 'mousewheel', 'scroll', 'touchend', 'touchmove', 'touchstart', 'wheel'].map(event => {
|
|
18
16
|
controllers.set(event, null);
|
|
19
17
|
});
|
|
20
18
|
function register(element, event) {
|
|
@@ -39,7 +37,7 @@ function register(element, event) {
|
|
|
39
37
|
signal = controller.signal;
|
|
40
38
|
}
|
|
41
39
|
let key = keys[event] = Symbol();
|
|
42
|
-
addEventListener
|
|
40
|
+
host.addEventListener(event.slice(2), (e) => {
|
|
43
41
|
let fn, node = e.target;
|
|
44
42
|
while (node) {
|
|
45
43
|
fn = node[key];
|
|
@@ -52,34 +50,30 @@ function register(element, event) {
|
|
|
52
50
|
});
|
|
53
51
|
return fn.call(node, e);
|
|
54
52
|
}
|
|
55
|
-
node = parentElement
|
|
53
|
+
node = node.parentElement;
|
|
56
54
|
}
|
|
57
55
|
}, {
|
|
58
|
-
capture: capture.has(event),
|
|
59
56
|
passive: passive.has(event),
|
|
60
57
|
signal
|
|
61
58
|
});
|
|
62
59
|
return key;
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
default:
|
|
82
|
-
element[keys[event] || register(element, event)] = listener;
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
61
|
+
const delegate = (element, event, listener) => {
|
|
62
|
+
element[keys[event] || register(element, event)] = listener;
|
|
63
|
+
};
|
|
64
|
+
const direct = (element, event, listener) => {
|
|
65
|
+
let handler = (e) => listener.call(element, e);
|
|
66
|
+
element.addEventListener(event, handler, {
|
|
67
|
+
passive: passive.has(event)
|
|
68
|
+
});
|
|
69
|
+
ondisconnect(element, () => {
|
|
70
|
+
element.removeEventListener(event, handler);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const ondisconnect = (element, listener) => {
|
|
74
|
+
disconnect(element, () => listener(element));
|
|
75
|
+
};
|
|
76
|
+
const onrender = (element, listener) => {
|
|
77
|
+
root(() => listener(element));
|
|
85
78
|
};
|
|
79
|
+
export default { delegate, direct, onconnect, ondisconnect, onrender, onresize, ontick };
|
package/build/event/ontick.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import raf from '../utilities/raf.js';
|
|
1
|
+
import { raf } from '../utilities.js';
|
|
3
2
|
let tasks = Object.assign(new Set(), { running: false });
|
|
4
3
|
function tick() {
|
|
5
4
|
if (tasks.size === 0) {
|
|
@@ -22,12 +21,10 @@ const remove = (task) => {
|
|
|
22
21
|
tasks.delete(task);
|
|
23
22
|
};
|
|
24
23
|
export default (element, listener) => {
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
}, fn = () => {
|
|
28
|
-
if (state === STATE_HYDRATING) {
|
|
24
|
+
let connected = false, fn = () => {
|
|
25
|
+
if (connected === false) {
|
|
29
26
|
if (element.isConnected) {
|
|
30
|
-
|
|
27
|
+
connected = true;
|
|
31
28
|
}
|
|
32
29
|
else if (retry--) {
|
|
33
30
|
return;
|
|
@@ -37,8 +34,8 @@ export default (element, listener) => {
|
|
|
37
34
|
remove(fn);
|
|
38
35
|
return;
|
|
39
36
|
}
|
|
40
|
-
listener(
|
|
41
|
-
}, retry = 60
|
|
37
|
+
listener(() => remove(fn), element);
|
|
38
|
+
}, retry = 60;
|
|
42
39
|
add(fn);
|
|
43
40
|
};
|
|
44
41
|
export { add, remove };
|
package/build/html.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactiveArray } from '@esportsplus/reactivity';
|
|
2
|
+
import { Attribute, Attributes, Renderable } from './types.js';
|
|
3
|
+
import { ArraySlot } from './slot/array.js';
|
|
4
|
+
type Values<T> = Attribute | Attributes<any> | ArraySlot<T> | Renderable<T>;
|
|
5
|
+
declare const html: {
|
|
6
|
+
<T>(_literals: TemplateStringsArray, ..._values: (Values<T> | Values<T>[])[]): DocumentFragment;
|
|
7
|
+
reactive<T>(_arr: ReactiveArray<T>, _template: (value: T) => DocumentFragment): ArraySlot<T>;
|
|
8
|
+
};
|
|
9
|
+
export default html;
|
package/build/html.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const html = (_literals, ..._values) => {
|
|
2
|
+
throw new Error('html`` templates must be compiled. Ensure vite-plugin is configured.');
|
|
3
|
+
};
|
|
4
|
+
html.reactive = (_arr, _template) => {
|
|
5
|
+
throw new Error('html.reactive() must be compiled. Ensure vite-plugin is configured.');
|
|
6
|
+
};
|
|
7
|
+
export default html;
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import './runtime.js';
|
|
2
|
+
export { default as attributes } from './attributes.js';
|
|
3
|
+
export { default as event } from './event/index.js';
|
|
4
|
+
export { default as html } from './html.js';
|
|
2
5
|
export { default as render } from './render.js';
|
|
6
|
+
export { default as slot } from './slot/index.js';
|
|
3
7
|
export { default as svg } from './svg.js';
|
|
4
|
-
export
|
|
8
|
+
export { ArraySlot } from './slot/array.js';
|
|
9
|
+
export { EffectSlot } from './slot/effect.js';
|
|
5
10
|
export type { Attributes, Element, Renderable } from './types.js';
|
|
11
|
+
export * from './utilities.js';
|
package/build/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import './runtime.js';
|
|
2
|
+
export { default as attributes } from './attributes.js';
|
|
3
|
+
export { default as event } from './event/index.js';
|
|
4
|
+
export { default as html } from './html.js';
|
|
2
5
|
export { default as render } from './render.js';
|
|
6
|
+
export { default as slot } from './slot/index.js';
|
|
3
7
|
export { default as svg } from './svg.js';
|
|
8
|
+
export { ArraySlot } from './slot/array.js';
|
|
9
|
+
export { EffectSlot } from './slot/effect.js';
|
|
10
|
+
export * from './utilities.js';
|
package/build/render.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Renderable } from './types.js';
|
|
2
|
-
declare const _default: <T>(parent: HTMLElement, renderable: Renderable<T
|
|
1
|
+
import { Effect, Renderable } from './types.js';
|
|
2
|
+
declare const _default: <T>(parent: HTMLElement, renderable: Exclude<Renderable<T>, Effect<T>>) => void;
|
|
3
3
|
export default _default;
|
package/build/render.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import marker from './utilities/marker.js';
|
|
1
|
+
import { marker } from './utilities.js';
|
|
3
2
|
import slot from './slot/index.js';
|
|
4
3
|
export default (parent, renderable) => {
|
|
5
4
|
let anchor = marker.cloneNode();
|
|
6
|
-
nodeValue
|
|
5
|
+
parent.nodeValue = '';
|
|
7
6
|
parent.append(anchor);
|
|
8
7
|
slot(anchor, renderable);
|
|
9
8
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/runtime.js
ADDED
package/build/slot/array.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ReactiveArray } from '@esportsplus/reactivity';
|
|
2
|
-
import html from '../html
|
|
2
|
+
import html from '../html.js';
|
|
3
3
|
declare class ArraySlot<T> {
|
|
4
4
|
private array;
|
|
5
|
-
private queue;
|
|
6
5
|
private marker;
|
|
7
6
|
private nodes;
|
|
7
|
+
private queue;
|
|
8
8
|
private scheduled;
|
|
9
9
|
private signal;
|
|
10
10
|
private template;
|
|
11
|
-
readonly fragment:
|
|
11
|
+
readonly fragment: DocumentFragment;
|
|
12
12
|
constructor(array: ReactiveArray<T>, template: ((value: T) => ReturnType<typeof html>));
|
|
13
13
|
private anchor;
|
|
14
14
|
private clear;
|
package/build/slot/array.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { read, root, set, signal } from '@esportsplus/reactivity';
|
|
2
2
|
import { ARRAY_SLOT, EMPTY_FRAGMENT } from '../constants.js';
|
|
3
|
-
import {
|
|
4
|
-
import { cloneNode, firstChild, lastChild, nextSibling } from '../utilities/node.js';
|
|
3
|
+
import { clone, marker, raf } from '../utilities.js';
|
|
5
4
|
import { ondisconnect, remove } from './cleanup.js';
|
|
6
|
-
import marker from '../utilities/marker.js';
|
|
7
|
-
import raf from '../utilities/raf.js';
|
|
8
5
|
class ArraySlot {
|
|
9
6
|
array;
|
|
10
|
-
queue = [];
|
|
11
7
|
marker;
|
|
12
8
|
nodes = [];
|
|
9
|
+
queue = [];
|
|
13
10
|
scheduled = false;
|
|
14
11
|
signal;
|
|
15
12
|
template;
|
|
16
13
|
fragment;
|
|
17
14
|
constructor(array, template) {
|
|
18
15
|
this.array = array;
|
|
19
|
-
let fragment = this.fragment =
|
|
16
|
+
let fragment = this.fragment = clone(EMPTY_FRAGMENT);
|
|
20
17
|
this.marker = marker.cloneNode();
|
|
21
18
|
this.signal = signal(array.length);
|
|
22
19
|
this.template = function (data) {
|
|
@@ -24,14 +21,14 @@ class ArraySlot {
|
|
|
24
21
|
dispose = d;
|
|
25
22
|
return template(data);
|
|
26
23
|
}), group = {
|
|
27
|
-
head: firstChild
|
|
28
|
-
tail: lastChild
|
|
24
|
+
head: frag.firstChild,
|
|
25
|
+
tail: frag.lastChild
|
|
29
26
|
};
|
|
30
|
-
append
|
|
27
|
+
fragment.append(frag);
|
|
31
28
|
ondisconnect(group.head, dispose);
|
|
32
29
|
return group;
|
|
33
30
|
};
|
|
34
|
-
append
|
|
31
|
+
fragment.append(this.marker);
|
|
35
32
|
if (array.length) {
|
|
36
33
|
root(() => {
|
|
37
34
|
this.nodes = array.map(this.template);
|
|
@@ -95,7 +92,8 @@ class ArraySlot {
|
|
|
95
92
|
this.scheduled = true;
|
|
96
93
|
raf(() => {
|
|
97
94
|
let queue = this.queue;
|
|
98
|
-
this.queue
|
|
95
|
+
this.queue = [];
|
|
96
|
+
this.scheduled = false;
|
|
99
97
|
root(() => {
|
|
100
98
|
for (let i = 0, n = queue.length; i < n; i++) {
|
|
101
99
|
let op = queue[i];
|
|
@@ -132,7 +130,6 @@ class ArraySlot {
|
|
|
132
130
|
}
|
|
133
131
|
});
|
|
134
132
|
set(this.signal, this.nodes.length);
|
|
135
|
-
this.scheduled = false;
|
|
136
133
|
});
|
|
137
134
|
}
|
|
138
135
|
shift() {
|
|
@@ -172,8 +169,8 @@ class ArraySlot {
|
|
|
172
169
|
for (let i = 0; i < n; i++) {
|
|
173
170
|
let group = nodes[i], next, node = group.head;
|
|
174
171
|
while (node) {
|
|
175
|
-
next = node === group.tail ? null : nextSibling
|
|
176
|
-
|
|
172
|
+
next = node === group.tail ? null : node.nextSibling;
|
|
173
|
+
this.fragment.append(node);
|
|
177
174
|
node = next;
|
|
178
175
|
}
|
|
179
176
|
}
|
package/build/slot/cleanup.d.ts
CHANGED
package/build/slot/cleanup.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CLEANUP } from '../constants.js';
|
|
2
|
-
import { previousSibling } from '../utilities/node.js';
|
|
3
2
|
const ondisconnect = (element, fn) => {
|
|
4
3
|
(element[CLEANUP] ??= []).push(fn);
|
|
5
4
|
};
|
|
@@ -13,7 +12,7 @@ const remove = (...groups) => {
|
|
|
13
12
|
fn();
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
|
-
next = previousSibling
|
|
15
|
+
next = tail.previousSibling;
|
|
17
16
|
tail.remove();
|
|
18
17
|
if (head === tail) {
|
|
19
18
|
break;
|
package/build/slot/effect.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { effect } from '@esportsplus/reactivity';
|
|
2
|
-
import { firstChild, lastChild, nodeValue } from '../utilities/node.js';
|
|
3
2
|
import { remove } from './cleanup.js';
|
|
4
|
-
import raf from '../utilities
|
|
5
|
-
import text from '../utilities/text.js';
|
|
3
|
+
import { raf, text } from '../utilities.js';
|
|
6
4
|
import render from './render.js';
|
|
7
5
|
function read(value) {
|
|
8
6
|
if (typeof value === 'function') {
|
|
@@ -60,7 +58,7 @@ class EffectSlot {
|
|
|
60
58
|
value = String(value);
|
|
61
59
|
}
|
|
62
60
|
if (textnode) {
|
|
63
|
-
nodeValue
|
|
61
|
+
textnode.nodeValue = value;
|
|
64
62
|
if (!textnode.isConnected) {
|
|
65
63
|
anchor.after(textnode);
|
|
66
64
|
}
|
|
@@ -70,14 +68,14 @@ class EffectSlot {
|
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
70
|
else {
|
|
73
|
-
let fragment = render(anchor, value), head = firstChild
|
|
71
|
+
let fragment = render(anchor, value), head = fragment.firstChild;
|
|
74
72
|
if (textnode?.isConnected) {
|
|
75
73
|
remove({ head: textnode, tail: textnode });
|
|
76
74
|
}
|
|
77
75
|
if (head) {
|
|
78
76
|
this.group = {
|
|
79
|
-
head,
|
|
80
|
-
tail: lastChild
|
|
77
|
+
head: head,
|
|
78
|
+
tail: fragment.lastChild
|
|
81
79
|
};
|
|
82
80
|
anchor.after(fragment);
|
|
83
81
|
}
|
package/build/slot/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import { EffectSlot } from './effect.js';
|
|
2
1
|
import render from './render.js';
|
|
3
2
|
export default (anchor, value) => {
|
|
4
|
-
|
|
5
|
-
new EffectSlot(anchor, value);
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
anchor.after(render(anchor, value));
|
|
9
|
-
}
|
|
3
|
+
anchor.after(render(anchor, value));
|
|
10
4
|
};
|
package/build/slot/render.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { isArray } from '@esportsplus/utilities';
|
|
2
2
|
import { ARRAY_SLOT, EMPTY_FRAGMENT } from '../constants.js';
|
|
3
|
-
import {
|
|
4
|
-
import { append } from '../utilities/fragment.js';
|
|
5
|
-
import text from '../utilities/text.js';
|
|
3
|
+
import { clone, text } from '../utilities.js';
|
|
6
4
|
export default function render(anchor, value) {
|
|
7
5
|
if (value == null || value === false || value === '') {
|
|
8
6
|
return EMPTY_FRAGMENT;
|
|
@@ -26,17 +24,17 @@ export default function render(anchor, value) {
|
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
if (isArray(value)) {
|
|
29
|
-
let fragment =
|
|
27
|
+
let fragment = clone(EMPTY_FRAGMENT);
|
|
30
28
|
for (let i = 0; i < n; i++) {
|
|
31
|
-
append
|
|
32
|
-
anchor = lastChild
|
|
29
|
+
fragment.append(render(anchor, value[i]));
|
|
30
|
+
anchor = fragment.lastChild;
|
|
33
31
|
}
|
|
34
32
|
return fragment;
|
|
35
33
|
}
|
|
36
34
|
if (value instanceof NodeList) {
|
|
37
|
-
let fragment =
|
|
35
|
+
let fragment = clone(EMPTY_FRAGMENT);
|
|
38
36
|
for (let i = 0; i < n; i++) {
|
|
39
|
-
append
|
|
37
|
+
fragment.append(value[i]);
|
|
40
38
|
}
|
|
41
39
|
return fragment;
|
|
42
40
|
}
|
package/build/svg.d.ts
CHANGED
package/build/svg.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactiveCallInfo, TemplateInfo } from './ts-parser.js';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
type CodegenResult = {
|
|
4
|
+
changed: boolean;
|
|
5
|
+
code: string;
|
|
6
|
+
};
|
|
7
|
+
declare const addArraySlotImport: (code: string) => string;
|
|
8
|
+
declare const generateCode: (templates: TemplateInfo[], originalCode: string, sourceFile: ts.SourceFile) => CodegenResult;
|
|
9
|
+
declare const generateReactiveInlining: (calls: ReactiveCallInfo[], code: string, sourceFile: ts.SourceFile) => string;
|
|
10
|
+
declare const getNames: () => {
|
|
11
|
+
attr: string;
|
|
12
|
+
event: string;
|
|
13
|
+
slot: string;
|
|
14
|
+
};
|
|
15
|
+
declare const needsArraySlotImport: (sourceFile: ts.SourceFile) => boolean;
|
|
16
|
+
declare const setTypeChecker: (checker: ts.TypeChecker | undefined) => void;
|
|
17
|
+
export { addArraySlotImport, generateCode, generateReactiveInlining, getNames, needsArraySlotImport, setTypeChecker };
|
|
18
|
+
export type { CodegenResult };
|