dothtml 6.0.0-beta.44 → 6.0.0-beta.46
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/build_module/css/css-props.js +38 -1
- package/build_module/css/css-props.js.map +1 -1
- package/build_module/css/format-css-type.d.ts +4 -3
- package/build_module/css/format-css-type.js +7 -0
- package/build_module/css/format-css-type.js.map +1 -1
- package/build_module/decoration/component.d.ts +4 -14
- package/build_module/decoration/component.js +29 -29
- package/build_module/decoration/component.js.map +1 -1
- package/build_module/dot.js +130 -68
- package/build_module/dot.js.map +1 -1
- package/build_module/events/event-manager.d.ts +14 -0
- package/build_module/events/event-manager.js +98 -0
- package/build_module/events/event-manager.js.map +1 -0
- package/build_module/events/synthetic-event.d.ts +17 -0
- package/build_module/events/synthetic-event.js +33 -0
- package/build_module/events/synthetic-event.js.map +1 -0
- package/build_module/helpers/render-stylesheet.js +18 -9
- package/build_module/helpers/render-stylesheet.js.map +1 -1
- package/build_module/index.d.ts +3 -1
- package/build_module/index.js +14 -1
- package/build_module/index.js.map +1 -1
- package/build_module/reactivity/binding.d.ts +3 -1
- package/build_module/reactivity/binding.js +8 -2
- package/build_module/reactivity/binding.js.map +1 -1
- package/build_module/reactivity/computed.d.ts +18 -0
- package/build_module/reactivity/computed.js +106 -0
- package/build_module/reactivity/computed.js.map +1 -0
- package/build_module/reactivity/priority.d.ts +6 -0
- package/build_module/reactivity/priority.js +8 -0
- package/build_module/reactivity/priority.js.map +1 -0
- package/build_module/reactivity/ref-collection.d.ts +8 -0
- package/build_module/reactivity/ref-collection.js +32 -0
- package/build_module/reactivity/ref-collection.js.map +1 -0
- package/build_module/reactivity/ref.d.ts +5 -3
- package/build_module/reactivity/ref.js +31 -2
- package/build_module/reactivity/ref.js.map +1 -1
- package/build_module/reactivity/scheduler.d.ts +22 -0
- package/build_module/reactivity/scheduler.js +124 -0
- package/build_module/reactivity/scheduler.js.map +1 -0
- package/build_module/reactivity/store.d.ts +14 -0
- package/build_module/reactivity/store.js +91 -0
- package/build_module/reactivity/store.js.map +1 -0
- package/build_module/reactivity/subscription.d.ts +2 -1
- package/build_module/reactivity/subscription.js +4 -5
- package/build_module/reactivity/subscription.js.map +1 -1
- package/build_module/reactivity/watcher.d.ts +6 -3
- package/build_module/reactivity/watcher.js +31 -10
- package/build_module/reactivity/watcher.js.map +1 -1
- package/build_module/routing/helpers.d.ts +2 -0
- package/build_module/routing/helpers.js +21 -0
- package/build_module/routing/helpers.js.map +1 -0
- package/build_module/routing/index.d.ts +5 -0
- package/build_module/routing/index.js +6 -0
- package/build_module/routing/index.js.map +1 -0
- package/build_module/routing/link.d.ts +2 -0
- package/build_module/routing/link.js +45 -0
- package/build_module/routing/link.js.map +1 -0
- package/build_module/routing/router.d.ts +23 -0
- package/build_module/routing/router.js +209 -0
- package/build_module/routing/router.js.map +1 -0
- package/build_module/routing/scroll-manager.d.ts +1 -0
- package/build_module/routing/scroll-manager.js +33 -0
- package/build_module/routing/scroll-manager.js.map +1 -0
- package/build_module/routing/state.d.ts +7 -0
- package/build_module/routing/state.js +45 -0
- package/build_module/routing/state.js.map +1 -0
- package/build_module/v-meta-nodes/style-v-node.d.ts +17 -7
- package/build_module/v-meta-nodes/style-v-node.js +181 -85
- package/build_module/v-meta-nodes/style-v-node.js.map +1 -1
- package/build_module/v-style-nodes/base-v-style.d.ts +10 -11
- package/build_module/v-style-nodes/base-v-style.js +23 -95
- package/build_module/v-style-nodes/base-v-style.js.map +1 -1
- package/build_module/v-style-nodes/css-function-builder-v-style.d.ts +0 -3
- package/build_module/v-style-nodes/css-function-builder-v-style.js +10 -5
- package/build_module/v-style-nodes/css-function-builder-v-style.js.map +1 -1
- package/build_module/v-style-nodes/style-sheet-builder.d.ts +9 -0
- package/build_module/v-style-nodes/style-sheet-builder.js +51 -0
- package/build_module/v-style-nodes/style-sheet-builder.js.map +1 -0
- package/build_module/v-style-nodes/transform-v-style.js.map +1 -1
- package/build_module/vdom-nodes/collection-vdom.d.ts +3 -1
- package/build_module/vdom-nodes/collection-vdom.js +114 -97
- package/build_module/vdom-nodes/collection-vdom.js.map +1 -1
- package/build_module/vdom-nodes/component-context.d.ts +5 -0
- package/build_module/vdom-nodes/component-context.js +5 -0
- package/build_module/vdom-nodes/component-context.js.map +1 -0
- package/build_module/vdom-nodes/component-vdom.d.ts +22 -0
- package/build_module/vdom-nodes/component-vdom.js +250 -12
- package/build_module/vdom-nodes/component-vdom.js.map +1 -1
- package/build_module/vdom-nodes/conditional-vdom.d.ts +1 -0
- package/build_module/vdom-nodes/conditional-vdom.js +14 -0
- package/build_module/vdom-nodes/conditional-vdom.js.map +1 -1
- package/build_module/vdom-nodes/container-vdom.d.ts +6 -2
- package/build_module/vdom-nodes/container-vdom.js +54 -1
- package/build_module/vdom-nodes/container-vdom.js.map +1 -1
- package/build_module/vdom-nodes/element-vdom.d.ts +2 -1
- package/build_module/vdom-nodes/element-vdom.js +72 -18
- package/build_module/vdom-nodes/element-vdom.js.map +1 -1
- package/build_module/vdom-nodes/html-vdom.d.ts +1 -0
- package/build_module/vdom-nodes/html-vdom.js +12 -0
- package/build_module/vdom-nodes/html-vdom.js.map +1 -1
- package/build_module/vdom-nodes/text-vdom.d.ts +1 -0
- package/build_module/vdom-nodes/text-vdom.js +3 -0
- package/build_module/vdom-nodes/text-vdom.js.map +1 -1
- package/build_module/vdom-nodes/vdom.d.ts +2 -0
- package/build_module/vdom-nodes/vdom.js +17 -0
- package/build_module/vdom-nodes/vdom.js.map +1 -1
- package/package.json +58 -57
- package/readme.md +32 -26
- package/build_module/css/css.d.ts +0 -0
- package/build_module/css/css.js +0 -1
- package/build_module/css/css.js.map +0 -1
- package/build_module/decoration/use-styles.d.ts +0 -14
- package/build_module/decoration/use-styles.js +0 -19
- package/build_module/decoration/use-styles.js.map +0 -1
- package/build_module/helpers/render-css.d.ts +0 -2
- package/build_module/helpers/render-css.js +0 -20
- package/build_module/helpers/render-css.js.map +0 -1
- package/build_module/helpers.d.ts +0 -3
- package/build_module/helpers.js +0 -50
- package/build_module/helpers.js.map +0 -1
- package/build_module/reactive.d.ts +0 -46
- package/build_module/reactive.js +0 -150
- package/build_module/reactive.js.map +0 -1
- package/build_module/reactivity/bound-reactive.d.ts +0 -13
- package/build_module/reactivity/bound-reactive.js +0 -20
- package/build_module/reactivity/bound-reactive.js.map +0 -1
- package/build_module/reactivity/reactive.d.ts +0 -22
- package/build_module/reactivity/reactive.js +0 -54
- package/build_module/reactivity/reactive.js.map +0 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import SyntheticEvent from "./synthetic-event";
|
|
2
|
+
class EventManager {
|
|
3
|
+
static { this.managers = new Map(); }
|
|
4
|
+
static getForDocument(document) {
|
|
5
|
+
let manager = this.managers.get(document);
|
|
6
|
+
if (!manager) {
|
|
7
|
+
manager = new EventManager(document);
|
|
8
|
+
this.managers.set(document, manager);
|
|
9
|
+
}
|
|
10
|
+
return manager;
|
|
11
|
+
}
|
|
12
|
+
constructor(document) {
|
|
13
|
+
this.listeners = new WeakMap();
|
|
14
|
+
this.activeEventTypes = new Set();
|
|
15
|
+
this.document = document;
|
|
16
|
+
}
|
|
17
|
+
addListener(element, eventType, handler, modifiers = []) {
|
|
18
|
+
let elementListeners = this.listeners.get(element);
|
|
19
|
+
if (!elementListeners) {
|
|
20
|
+
elementListeners = new Map();
|
|
21
|
+
this.listeners.set(element, elementListeners);
|
|
22
|
+
}
|
|
23
|
+
let handlers = elementListeners.get(eventType);
|
|
24
|
+
if (!handlers) {
|
|
25
|
+
handlers = [];
|
|
26
|
+
elementListeners.set(eventType, handlers);
|
|
27
|
+
}
|
|
28
|
+
handlers.push({ handler, modifiers });
|
|
29
|
+
this.ensureGlobalListener(eventType);
|
|
30
|
+
}
|
|
31
|
+
removeListener(element, eventType, handler) {
|
|
32
|
+
const elementListeners = this.listeners.get(element);
|
|
33
|
+
if (!elementListeners)
|
|
34
|
+
return;
|
|
35
|
+
const handlers = elementListeners.get(eventType);
|
|
36
|
+
if (!handlers)
|
|
37
|
+
return;
|
|
38
|
+
const index = handlers.findIndex(h => h.handler === handler);
|
|
39
|
+
if (index !== -1) {
|
|
40
|
+
handlers.splice(index, 1);
|
|
41
|
+
}
|
|
42
|
+
if (handlers.length === 0) {
|
|
43
|
+
elementListeners.delete(eventType);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
ensureGlobalListener(eventType) {
|
|
47
|
+
if (this.activeEventTypes.has(eventType))
|
|
48
|
+
return;
|
|
49
|
+
const useCapture = eventType === "focus" || eventType === "blur";
|
|
50
|
+
this.document.addEventListener(eventType, (nativeEvent) => {
|
|
51
|
+
this.dispatchEvent(eventType, nativeEvent);
|
|
52
|
+
}, useCapture);
|
|
53
|
+
this.activeEventTypes.add(eventType);
|
|
54
|
+
}
|
|
55
|
+
dispatchEvent(eventType, nativeEvent) {
|
|
56
|
+
let path = nativeEvent.composedPath();
|
|
57
|
+
if (!path || path.length === 0) {
|
|
58
|
+
path = [];
|
|
59
|
+
let current = nativeEvent.target;
|
|
60
|
+
while (current) {
|
|
61
|
+
path.push(current);
|
|
62
|
+
current = current.parentNode || current.host;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const syntheticEvent = new SyntheticEvent(nativeEvent);
|
|
66
|
+
for (const element of path) {
|
|
67
|
+
if (element === this.document || element === window)
|
|
68
|
+
continue;
|
|
69
|
+
const elementListeners = this.listeners.get(element);
|
|
70
|
+
if (!elementListeners)
|
|
71
|
+
continue;
|
|
72
|
+
const handlers = elementListeners.get(eventType);
|
|
73
|
+
if (!handlers)
|
|
74
|
+
continue;
|
|
75
|
+
syntheticEvent.currentTarget = element;
|
|
76
|
+
for (const { handler, modifiers } of [...handlers]) {
|
|
77
|
+
if (modifiers.includes("self") && nativeEvent.target !== element)
|
|
78
|
+
continue;
|
|
79
|
+
if (modifiers.includes("stop"))
|
|
80
|
+
syntheticEvent.stopPropagation();
|
|
81
|
+
if (modifiers.includes("prevent"))
|
|
82
|
+
syntheticEvent.preventDefault();
|
|
83
|
+
handler(syntheticEvent);
|
|
84
|
+
if (modifiers.includes("once")) {
|
|
85
|
+
this.removeListener(element, eventType, handler);
|
|
86
|
+
}
|
|
87
|
+
if (syntheticEvent.isImmediatePropagationStopped()) {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (syntheticEvent.isPropagationStopped()) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export { EventManager };
|
|
98
|
+
//# sourceMappingURL=event-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-manager.js","sourceRoot":"","sources":["../../src/events/event-manager.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAS/C,MAAa,YAAY;aACT,aAAQ,GAAG,IAAI,GAAG,EAA0B,AAApC,CAAqC;IAErD,MAAM,CAAC,cAAc,CAAC,QAAkB;QAC9C,IAAI,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,EAAE;YACb,OAAO,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;YACrC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;SACrC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IAMD,YAAY,QAAkB;QAHtB,cAAS,GAAG,IAAI,OAAO,EAA8C,CAAC;QACtE,qBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;QAG5C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAEM,WAAW,CAAC,OAAgB,EAAE,SAAiB,EAAE,OAAqB,EAAE,YAAsB,EAAE;QACtG,IAAI,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,C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CAAC,EAAE;gBACnD,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,MAAM,KAAK,OAAO;oBAAE,SAAS;gBAE3E,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC;oBAAE,cAAc,CAAC,eAAe,EAAE,CAAC;gBACjE,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC;oBAAE,cAAc,CAAC,cAAc,EAAE,CAAC;gBAEnE,OAAO,CAAC,cAAc,CAAC,CAAC;gBAExB,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;oBAC/B,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;iBACjD;gBAED,IAAI,cAAc,CAAC,6BAA6B,EAAE,EAAE;oBACnD,MAAM;iBACN;aACD;YAED,IAAI,cAAc,CAAC,oBAAoB,EAAE,EAAE;gBAC1C,MAAM;aACN;SACD;IACF,CAAC;;SAhHW,YAAY"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default class SyntheticEvent {
|
|
2
|
+
nativeEvent: Event;
|
|
3
|
+
target: EventTarget;
|
|
4
|
+
currentTarget: EventTarget;
|
|
5
|
+
type: string;
|
|
6
|
+
timeStamp: number;
|
|
7
|
+
defaultPrevented: boolean;
|
|
8
|
+
detail: any;
|
|
9
|
+
private _propagationStopped;
|
|
10
|
+
private _immediatePropagationStopped;
|
|
11
|
+
constructor(e: Event);
|
|
12
|
+
preventDefault(): void;
|
|
13
|
+
stopPropagation(): void;
|
|
14
|
+
stopImmediatePropagation(): void;
|
|
15
|
+
isPropagationStopped(): boolean;
|
|
16
|
+
isImmediatePropagationStopped(): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export default class SyntheticEvent {
|
|
2
|
+
constructor(e) {
|
|
3
|
+
this._propagationStopped = false;
|
|
4
|
+
this._immediatePropagationStopped = false;
|
|
5
|
+
this.nativeEvent = e;
|
|
6
|
+
this.target = e.target;
|
|
7
|
+
this.currentTarget = e.currentTarget;
|
|
8
|
+
this.type = e.type;
|
|
9
|
+
this.timeStamp = e.timeStamp;
|
|
10
|
+
this.defaultPrevented = e.defaultPrevented;
|
|
11
|
+
this.detail = e.detail;
|
|
12
|
+
}
|
|
13
|
+
preventDefault() {
|
|
14
|
+
this.defaultPrevented = true;
|
|
15
|
+
this.nativeEvent.preventDefault();
|
|
16
|
+
}
|
|
17
|
+
stopPropagation() {
|
|
18
|
+
this._propagationStopped = true;
|
|
19
|
+
this.nativeEvent.stopPropagation();
|
|
20
|
+
}
|
|
21
|
+
stopImmediatePropagation() {
|
|
22
|
+
this._immediatePropagationStopped = true;
|
|
23
|
+
this._propagationStopped = true;
|
|
24
|
+
this.nativeEvent.stopImmediatePropagation();
|
|
25
|
+
}
|
|
26
|
+
isPropagationStopped() {
|
|
27
|
+
return this._propagationStopped;
|
|
28
|
+
}
|
|
29
|
+
isImmediatePropagationStopped() {
|
|
30
|
+
return this._immediatePropagationStopped;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=synthetic-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthetic-event.js","sourceRoot":"","sources":["../../src/events/synthetic-event.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,OAAO,OAAO,cAAc;IAWlC,YAAY,CAAQ;QAHZ,wBAAmB,GAAG,KAAK,CAAC;QAC5B,iCAA4B,GAAG,KAAK,CAAC;QAG5C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC;QAC7B,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC,gBAAgB,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAI,CAAS,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,cAAc;QACb,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;IACnC,CAAC;IAED,eAAe;QACd,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;IACpC,CAAC;IAED,wBAAwB;QACvB,IAAI,CAAC,4BAA4B,GAAG,IAAI,CAAC;QACzC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,WAAW,CAAC,wBAAwB,EAAE,CAAC;IAC7C,CAAC;IAED,oBAAoB;QACnB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACjC,CAAC;IAED,6BAA6B;QAC5B,OAAO,IAAI,CAAC,4BAA4B,CAAC;IAC1C,CAAC;CACD"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
const stylesheetCache = new Map();
|
|
1
2
|
export default function renderStylesheet(styleCallback, document) {
|
|
2
|
-
let DocumentCSSStyleSheet = document.defaultView.CSSStyleSheet;
|
|
3
|
-
let sharedStyles = new DocumentCSSStyleSheet();
|
|
4
3
|
let finalStylesheet = "";
|
|
5
4
|
if (typeof styleCallback == "string") {
|
|
6
5
|
finalStylesheet = styleCallback;
|
|
@@ -14,14 +13,24 @@ export default function renderStylesheet(styleCallback, document) {
|
|
|
14
13
|
else {
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
return sharedStyles;
|
|
16
|
+
if (stylesheetCache.has(finalStylesheet)) {
|
|
17
|
+
return stylesheetCache.get(finalStylesheet);
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
let DocumentCSSStyleSheet = document.defaultView?.CSSStyleSheet;
|
|
20
|
+
if (DocumentCSSStyleSheet) {
|
|
21
|
+
try {
|
|
22
|
+
let sharedStyles = new DocumentCSSStyleSheet();
|
|
23
|
+
if (sharedStyles.replaceSync) {
|
|
24
|
+
sharedStyles.replaceSync(finalStylesheet);
|
|
25
|
+
stylesheetCache.set(finalStylesheet, sharedStyles);
|
|
26
|
+
return sharedStyles;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
}
|
|
25
31
|
}
|
|
32
|
+
let style = document.createElement("style");
|
|
33
|
+
style.innerHTML = finalStylesheet;
|
|
34
|
+
return style;
|
|
26
35
|
}
|
|
27
36
|
//# sourceMappingURL=render-stylesheet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-stylesheet.js","sourceRoot":"","sources":["../../src/helpers/render-stylesheet.ts"],"names":[],"mappings":"AAEA,MAAM,
|
|
1
|
+
{"version":3,"file":"render-stylesheet.js","sourceRoot":"","sources":["../../src/helpers/render-stylesheet.ts"],"names":[],"mappings":"AAEA,MAAM,eAAe,GAAG,IAAI,GAAG,EAAyB,CAAC;AAEzD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,aAAoD,EAAE,QAAkB;IAEhH,IAAI,eAAe,GAAG,EAAE,CAAC;IAEzB,IAAI,OAAO,aAAa,IAAI,QAAQ,EAAE;QACrC,eAAe,GAAG,aAAa,CAAC;KAChC;SACI;QACJ,IAAI,GAAG,GAAG,IAAI,CAAC;QACf,IAAI,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAEhC,IAAI,OAAO,MAAM,IAAI,QAAQ,EAAE;YAC9B,eAAe,GAAG,MAAM,CAAC;SACzB;aACI;SAEJ;KACD;IAED,IAAI,eAAe,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE;QACzC,OAAO,eAAe,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;KAC5C;IAED,IAAI,qBAAqB,GAAI,QAAQ,CAAC,WAAmB,EAAE,aAAa,CAAC;IAEzE,IAAI,qBAAqB,EAAE;QAC1B,IAAI;YACH,IAAI,YAAY,GAAG,IAAI,qBAAqB,EAAE,CAAC;YAC/C,IAAI,YAAY,CAAC,WAAW,EAAE;gBAC7B,YAAY,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;gBAC1C,eAAe,CAAC,GAAG,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;gBACnD,OAAO,YAAY,CAAC;aACpB;SACD;QAAC,OAAO,CAAC,EAAE;SAEX;KACD;IAGD,IAAI,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5C,KAAK,CAAC,SAAS,GAAG,eAAe,CAAC;IAClC,OAAO,KAAK,CAAC;AACd,CAAC"}
|
package/build_module/index.d.ts
CHANGED
package/build_module/index.js
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import dot from "./dot";
|
|
2
|
+
import { Priority } from "./reactivity/priority";
|
|
3
|
+
import { currentPath, currentSearch, currentHash, navigate, useQueryParams, useHash, Router, Link } from "./routing";
|
|
4
|
+
import { initScrollManager } from "./routing/scroll-manager";
|
|
2
5
|
dot.version = "6.0.0";
|
|
6
|
+
initScrollManager();
|
|
7
|
+
dot.currentPath = currentPath;
|
|
8
|
+
dot.currentSearch = currentSearch;
|
|
9
|
+
dot.currentHash = currentHash;
|
|
10
|
+
dot.navigate = navigate;
|
|
11
|
+
dot.useQueryParams = useQueryParams;
|
|
12
|
+
dot.useHash = useHash;
|
|
13
|
+
dot.Router = Router;
|
|
14
|
+
dot.Link = Link;
|
|
3
15
|
window.dot = dot;
|
|
4
16
|
document["_dotId"] = "default";
|
|
5
|
-
export { dot };
|
|
17
|
+
export { dot, Priority };
|
|
18
|
+
export * from "./routing";
|
|
6
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EACN,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,cAAc,EACd,OAAO,EACP,MAAM,EACN,IAAI,EACJ,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;AAGtB,iBAAiB,EAAE,CAAC;AAGnB,GAAW,CAAC,WAAW,GAAG,WAAW,CAAC;AACtC,GAAW,CAAC,aAAa,GAAG,aAAa,CAAC;AAC1C,GAAW,CAAC,WAAW,GAAG,WAAW,CAAC;AACtC,GAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAChC,GAAW,CAAC,cAAc,GAAG,cAAc,CAAC;AAC5C,GAAW,CAAC,OAAO,GAAG,OAAO,CAAC;AAC9B,GAAW,CAAC,MAAM,GAAG,MAAM,CAAC;AAC5B,GAAW,CAAC,IAAI,GAAG,IAAI,CAAC;AAWzB,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;AACjB,QAAQ,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;AAE/B,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;AACzB,cAAc,WAAW,CAAC"}
|
|
@@ -5,9 +5,11 @@ export default class Binding<T = any, Td = T> implements IBinding<T, Td> {
|
|
|
5
5
|
display?: (v: T) => Td;
|
|
6
6
|
read?: (v: string) => T;
|
|
7
7
|
};
|
|
8
|
+
get value(): Td;
|
|
8
9
|
_get(): Td;
|
|
9
10
|
_set(v: string | number | boolean): void;
|
|
10
|
-
_subscribe(subscriber: any): number;
|
|
11
|
+
_subscribe(subscriber: any, sync?: boolean): number;
|
|
12
|
+
subscribe(callback: Function, sync?: boolean): number;
|
|
11
13
|
_unsubscribe(id: number): void;
|
|
12
14
|
constructor(source: IWatcher<T>);
|
|
13
15
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export default class Binding {
|
|
2
|
+
get value() {
|
|
3
|
+
return this._get();
|
|
4
|
+
}
|
|
2
5
|
_get() {
|
|
3
6
|
let v = this._transform?.display ? this._transform.display(this._source.value) : this._source.value;
|
|
4
7
|
return v;
|
|
@@ -7,8 +10,11 @@ export default class Binding {
|
|
|
7
10
|
let value = this._transform?.read ? this._transform.read(v) : v;
|
|
8
11
|
this._source.value = value;
|
|
9
12
|
}
|
|
10
|
-
_subscribe(subscriber) {
|
|
11
|
-
return this._source._subscribe(this, subscriber);
|
|
13
|
+
_subscribe(subscriber, sync = false) {
|
|
14
|
+
return this._source._subscribe(this, subscriber, sync);
|
|
15
|
+
}
|
|
16
|
+
subscribe(callback, sync = false) {
|
|
17
|
+
return this._subscribe(callback, sync);
|
|
12
18
|
}
|
|
13
19
|
_unsubscribe(id) {
|
|
14
20
|
this._source._detachBinding(id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.js","sourceRoot":"","sources":["../../src/reactivity/binding.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,OAAO;IAQ3B,IAAI;QAEH,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAsB,CAAC;QAErH,OAAO,CAAC,CAAC;IACV,CAAC;IAED,IAAI,CAAC,CAAwB;QAC5B,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,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QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACvB,CAAC;CACD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Watcher from "./watcher";
|
|
2
|
+
export default class Computed<T> extends Watcher<T> {
|
|
3
|
+
private getter;
|
|
4
|
+
private dependencies;
|
|
5
|
+
private isQueued;
|
|
6
|
+
private isEvaluating;
|
|
7
|
+
private active;
|
|
8
|
+
private dirty;
|
|
9
|
+
private error;
|
|
10
|
+
private updateSubscription;
|
|
11
|
+
constructor(getter: () => T);
|
|
12
|
+
get value(): T;
|
|
13
|
+
addDependency(watcher: Watcher): void;
|
|
14
|
+
private requestUpdate;
|
|
15
|
+
private newDependencies;
|
|
16
|
+
private _update;
|
|
17
|
+
dispose(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import Watcher, { dependencyStack } from "./watcher";
|
|
2
|
+
import { scheduler } from "./scheduler";
|
|
3
|
+
import { Priority } from "./priority";
|
|
4
|
+
export default class Computed extends Watcher {
|
|
5
|
+
constructor(getter) {
|
|
6
|
+
super();
|
|
7
|
+
this.dependencies = new Map();
|
|
8
|
+
this.isQueued = false;
|
|
9
|
+
this.isEvaluating = false;
|
|
10
|
+
this.active = true;
|
|
11
|
+
this.dirty = true;
|
|
12
|
+
this.error = null;
|
|
13
|
+
this.updateSubscription = {
|
|
14
|
+
active: true,
|
|
15
|
+
update: () => {
|
|
16
|
+
this.isQueued = false;
|
|
17
|
+
if (this.dirty) {
|
|
18
|
+
this._update();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
this.newDependencies = new Set();
|
|
23
|
+
this.getter = getter;
|
|
24
|
+
this._update();
|
|
25
|
+
}
|
|
26
|
+
get value() {
|
|
27
|
+
if (this.isEvaluating) {
|
|
28
|
+
throw new Error("Circular dependency detected in computed watcher.");
|
|
29
|
+
}
|
|
30
|
+
if (this.dirty) {
|
|
31
|
+
this._update();
|
|
32
|
+
}
|
|
33
|
+
if (this.error) {
|
|
34
|
+
throw this.error;
|
|
35
|
+
}
|
|
36
|
+
return super.value;
|
|
37
|
+
}
|
|
38
|
+
addDependency(watcher) {
|
|
39
|
+
if (!this.active)
|
|
40
|
+
return;
|
|
41
|
+
if (!this.newDependencies.has(watcher)) {
|
|
42
|
+
this.newDependencies.add(watcher);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
requestUpdate() {
|
|
46
|
+
if (!this.active)
|
|
47
|
+
return;
|
|
48
|
+
this.dirty = true;
|
|
49
|
+
if (!this.isQueued) {
|
|
50
|
+
this.isQueued = true;
|
|
51
|
+
scheduler.enqueue(this.updateSubscription, Priority.Normal);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
_update() {
|
|
55
|
+
if (!this.active)
|
|
56
|
+
return;
|
|
57
|
+
if (this.isEvaluating) {
|
|
58
|
+
throw new Error("Circular dependency detected in computed watcher.");
|
|
59
|
+
}
|
|
60
|
+
this.isEvaluating = true;
|
|
61
|
+
this.dirty = false;
|
|
62
|
+
this.error = null;
|
|
63
|
+
this.newDependencies.clear();
|
|
64
|
+
dependencyStack.push(this);
|
|
65
|
+
let newValue;
|
|
66
|
+
let hasError = false;
|
|
67
|
+
try {
|
|
68
|
+
newValue = this.getter();
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
this.error = e;
|
|
72
|
+
hasError = true;
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
dependencyStack.pop();
|
|
76
|
+
this.isEvaluating = false;
|
|
77
|
+
}
|
|
78
|
+
if (!hasError) {
|
|
79
|
+
this.setValue(newValue);
|
|
80
|
+
}
|
|
81
|
+
const toRemove = [];
|
|
82
|
+
for (const [watcher, subId] of this.dependencies) {
|
|
83
|
+
if (!this.newDependencies.has(watcher)) {
|
|
84
|
+
watcher._detachBinding(subId);
|
|
85
|
+
toRemove.push(watcher);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const watcher of toRemove) {
|
|
89
|
+
this.dependencies.delete(watcher);
|
|
90
|
+
}
|
|
91
|
+
for (const watcher of this.newDependencies) {
|
|
92
|
+
if (!this.dependencies.has(watcher)) {
|
|
93
|
+
const subId = watcher.subscribe(() => this.requestUpdate(), true);
|
|
94
|
+
this.dependencies.set(watcher, subId);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
dispose() {
|
|
99
|
+
this.active = false;
|
|
100
|
+
for (const [watcher, subId] of this.dependencies) {
|
|
101
|
+
watcher._detachBinding(subId);
|
|
102
|
+
}
|
|
103
|
+
this.dependencies.clear();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=computed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computed.js","sourceRoot":"","sources":["../../src/reactivity/computed.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,CAAC,OAAO,OAAO,QAAY,SAAQ,OAAU;IAmBlD,YAAY,MAAe;QAC1B,KAAK,EAAE,CAAC;QAlBD,iBAAY,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC1C,aAAQ,GAAG,KAAK,CAAC;QACjB,iBAAY,GAAG,KAAK,CAAC;QACrB,WAAM,GAAG,IAAI,CAAC;QACd,UAAK,GAAG,IAAI,CAAC;QACb,UAAK,GAAQ,IAAI,CAAC;QAElB,uBAAkB,GAAG;YAC5B,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,GAAG,EAAE;gBACZ,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACtB,IAAI,IAAI,CAAC,KAAK,EAAE;oBACf,IAAI,CAAC,OAAO,EAAE,CAAC;iBACf;YACF,CAAC;SACD,CAAC;QAsC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C;SACD;IACF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE;YACjD,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;SAC9B;QACD,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var Priority;
|
|
2
|
+
(function (Priority) {
|
|
3
|
+
Priority[Priority["Immediate"] = 0] = "Immediate";
|
|
4
|
+
Priority[Priority["UserBlocking"] = 1] = "UserBlocking";
|
|
5
|
+
Priority[Priority["Normal"] = 2] = "Normal";
|
|
6
|
+
Priority[Priority["Background"] = 3] = "Background";
|
|
7
|
+
})(Priority || (Priority = {}));
|
|
8
|
+
//# sourceMappingURL=priority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priority.js","sourceRoot":"","sources":["../../src/reactivity/priority.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IACnB,iDAAa,CAAA;IACb,uDAAgB,CAAA;IAChB,2CAAU,CAAA;IACV,mDAAc,CAAA;AACf,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import Ref from "./ref";
|
|
2
|
+
export default class RefCollection<T = any> {
|
|
3
|
+
private _refs;
|
|
4
|
+
get(key: string | number): Ref<T>;
|
|
5
|
+
get elements(): Record<string | number, T | null>;
|
|
6
|
+
forEach(callback: (el: T | null, key: string | number) => void): void;
|
|
7
|
+
map<U>(callback: (el: T | null, key: string | number) => U): U[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Ref from "./ref";
|
|
2
|
+
export default class RefCollection {
|
|
3
|
+
constructor() {
|
|
4
|
+
this._refs = new Map();
|
|
5
|
+
}
|
|
6
|
+
get(key) {
|
|
7
|
+
if (!this._refs.has(key)) {
|
|
8
|
+
this._refs.set(key, new Ref());
|
|
9
|
+
}
|
|
10
|
+
return this._refs.get(key);
|
|
11
|
+
}
|
|
12
|
+
get elements() {
|
|
13
|
+
const result = {};
|
|
14
|
+
this._refs.forEach((ref, key) => {
|
|
15
|
+
result[key] = ref.value;
|
|
16
|
+
});
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
forEach(callback) {
|
|
20
|
+
this._refs.forEach((ref, key) => {
|
|
21
|
+
callback(ref.value, key);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
map(callback) {
|
|
25
|
+
const result = [];
|
|
26
|
+
this._refs.forEach((ref, key) => {
|
|
27
|
+
result.push(callback(ref.value, key));
|
|
28
|
+
});
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ref-collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ref-collection.js","sourceRoot":"","sources":["../../src/reactivity/ref-collection.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB,MAAM,CAAC,OAAO,OAAO,aAAa;IAAlC;QACS,UAAK,GAAiC,IAAI,GAAG,EAAE,CAAC;IAoCzD,CAAC;IAlCA,GAAG,CAAC,GAAoB;QACvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,GAAG,EAAK,CAAC,CAAC;SAClC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC;IAC7B,CAAC;IAED,IAAI,QAAQ;QACX,MAAM,MAAM,GAAsC,EAAE,CAAC;QACrD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IACf,CAAC;IAKD,OAAO,CAAC,QAAsD;QAC7D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC/B,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACJ,CAAC;IAKD,GAAG,CAAI,QAAmD;QACzD,MAAM,MAAM,GAAQ,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;YAC/B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IACf,CAAC;CACD"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { IRef } from "dothtml-interfaces/src/bindings/i-ref";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import Watcher from "./watcher";
|
|
3
|
+
export default class Ref<T = any> extends Watcher<T | null> implements IRef<any> {
|
|
4
|
+
constructor();
|
|
5
|
+
get element(): T;
|
|
6
|
+
ready(): Promise<T>;
|
|
5
7
|
}
|
|
@@ -1,6 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import Watcher from "./watcher";
|
|
2
|
+
export default class Ref extends Watcher {
|
|
3
|
+
constructor() {
|
|
4
|
+
super();
|
|
5
|
+
this._value = null;
|
|
6
|
+
return new Proxy(this, {
|
|
7
|
+
get(target, prop, receiver) {
|
|
8
|
+
if (prop in target) {
|
|
9
|
+
return Reflect.get(target, prop, receiver);
|
|
10
|
+
}
|
|
11
|
+
const val = target.value;
|
|
12
|
+
if (val && typeof val[prop] === "function") {
|
|
13
|
+
return (...args) => val[prop].apply(val, args);
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
2
19
|
get element() {
|
|
3
|
-
return this.
|
|
20
|
+
return this.value;
|
|
21
|
+
}
|
|
22
|
+
async ready() {
|
|
23
|
+
if (this.value)
|
|
24
|
+
return this.value;
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
const id = this.subscribe((val) => {
|
|
27
|
+
if (val) {
|
|
28
|
+
this._detachBinding(id);
|
|
29
|
+
resolve(val);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
4
33
|
}
|
|
5
34
|
}
|
|
6
35
|
//# sourceMappingURL=ref.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../../src/reactivity/ref.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ref.js","sourceRoot":"","sources":["../../src/reactivity/ref.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,WAAW,CAAC;AAMhC,MAAM,CAAC,OAAO,OAAO,GAAa,SAAQ,OAAiB;IAC1D;QACC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QAEnB,OAAO,IAAI,KAAK,CAAC,IAAI,EAAE;YACtB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;gBACzB,IAAI,IAAI,IAAI,MAAM,EAAE;oBACnB,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;iBAC3C;gBACD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC;gBACzB,IAAI,GAAG,IAAI,OAAQ,GAAW,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE;oBACpD,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE,CAAE,GAAW,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;iBAC/D;gBACD,OAAO,SAAS,CAAC;YAClB,CAAC;SACD,CAAQ,CAAC;IACX,CAAC;IAKD,IAAI,OAAO;QACV,OAAO,IAAI,CAAC,KAAU,CAAC;IACxB,CAAC;IAKD,KAAK,CAAC,KAAK;QACV,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,KAAU,CAAC;QACvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAa,EAAE,EAAE;gBAC3C,IAAI,GAAG,EAAE;oBACR,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;oBACxB,OAAO,CAAC,GAAG,CAAC,CAAC;iBACb;YACF,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Priority } from "./priority";
|
|
2
|
+
import Subscription from "./subscription";
|
|
3
|
+
declare class Scheduler {
|
|
4
|
+
private queues;
|
|
5
|
+
private isPending;
|
|
6
|
+
private startTime;
|
|
7
|
+
private frameYieldMs;
|
|
8
|
+
private isSync;
|
|
9
|
+
private isSyncing;
|
|
10
|
+
private channel;
|
|
11
|
+
constructor();
|
|
12
|
+
enqueue(subscription: Subscription, priority?: Priority): void;
|
|
13
|
+
private scheduleFlush;
|
|
14
|
+
shouldYield(): boolean;
|
|
15
|
+
private workLoop;
|
|
16
|
+
private flushQueues;
|
|
17
|
+
flushSync(): void;
|
|
18
|
+
setSync(sync: boolean): void;
|
|
19
|
+
clear(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare const scheduler: Scheduler;
|
|
22
|
+
export {};
|