@granularjs/core 1.0.0
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 +576 -0
- package/dist/granular.min.js +2 -0
- package/dist/granular.min.js.map +7 -0
- package/package.json +54 -0
- package/src/core/bootstrap.js +63 -0
- package/src/core/collections/observable-array.js +204 -0
- package/src/core/component/function-component.js +82 -0
- package/src/core/context.js +172 -0
- package/src/core/dom/dom.js +25 -0
- package/src/core/dom/element.js +725 -0
- package/src/core/dom/error-boundary.js +111 -0
- package/src/core/dom/input-format.js +82 -0
- package/src/core/dom/list.js +185 -0
- package/src/core/dom/portal.js +57 -0
- package/src/core/dom/tags.js +182 -0
- package/src/core/dom/virtual-list.js +242 -0
- package/src/core/dom/when.js +138 -0
- package/src/core/events/event-hub.js +97 -0
- package/src/core/forms/form.js +127 -0
- package/src/core/internal/symbols.js +5 -0
- package/src/core/network/websocket.js +165 -0
- package/src/core/query/query-client.js +529 -0
- package/src/core/reactivity/after-flush.js +20 -0
- package/src/core/reactivity/computed.js +51 -0
- package/src/core/reactivity/concat.js +89 -0
- package/src/core/reactivity/dirty-host.js +162 -0
- package/src/core/reactivity/observe.js +421 -0
- package/src/core/reactivity/persist.js +180 -0
- package/src/core/reactivity/resolve.js +8 -0
- package/src/core/reactivity/signal.js +97 -0
- package/src/core/reactivity/state.js +294 -0
- package/src/core/renderable/render-string.js +51 -0
- package/src/core/renderable/renderable.js +21 -0
- package/src/core/renderable/renderer.js +66 -0
- package/src/core/router/router.js +865 -0
- package/src/core/runtime.js +28 -0
- package/src/index.js +42 -0
- package/types/core/bootstrap.d.ts +11 -0
- package/types/core/collections/observable-array.d.ts +25 -0
- package/types/core/component/function-component.d.ts +14 -0
- package/types/core/context.d.ts +29 -0
- package/types/core/dom/dom.d.ts +13 -0
- package/types/core/dom/element.d.ts +10 -0
- package/types/core/dom/error-boundary.d.ts +8 -0
- package/types/core/dom/input-format.d.ts +6 -0
- package/types/core/dom/list.d.ts +8 -0
- package/types/core/dom/portal.d.ts +8 -0
- package/types/core/dom/tags.d.ts +114 -0
- package/types/core/dom/virtual-list.d.ts +8 -0
- package/types/core/dom/when.d.ts +13 -0
- package/types/core/events/event-hub.d.ts +48 -0
- package/types/core/forms/form.d.ts +9 -0
- package/types/core/internal/symbols.d.ts +4 -0
- package/types/core/network/websocket.d.ts +18 -0
- package/types/core/query/query-client.d.ts +73 -0
- package/types/core/reactivity/after-flush.d.ts +4 -0
- package/types/core/reactivity/computed.d.ts +1 -0
- package/types/core/reactivity/concat.d.ts +1 -0
- package/types/core/reactivity/dirty-host.d.ts +42 -0
- package/types/core/reactivity/observe.d.ts +10 -0
- package/types/core/reactivity/persist.d.ts +1 -0
- package/types/core/reactivity/resolve.d.ts +1 -0
- package/types/core/reactivity/signal.d.ts +11 -0
- package/types/core/reactivity/state.d.ts +14 -0
- package/types/core/renderable/render-string.d.ts +2 -0
- package/types/core/renderable/renderable.d.ts +15 -0
- package/types/core/renderable/renderer.d.ts +38 -0
- package/types/core/router/router.d.ts +57 -0
- package/types/core/runtime.d.ts +26 -0
- package/types/index.d.ts +2 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { bootstrap } from './bootstrap.js';
|
|
2
|
+
export { component } from './component/function-component.js';
|
|
3
|
+
export { signal, isSignal, setSignal, readSignal } from './reactivity/signal.js';
|
|
4
|
+
export { state, isState, isStatePath, isComputed } from './reactivity/state.js';
|
|
5
|
+
export { after, before, set, subscribe } from './reactivity/observe.js';
|
|
6
|
+
export { resolve } from './reactivity/resolve.js';
|
|
7
|
+
export { computed } from './reactivity/computed.js';
|
|
8
|
+
export { concat } from './reactivity/concat.js';
|
|
9
|
+
export { persist } from './reactivity/persist.js';
|
|
10
|
+
export { form } from './forms/form.js';
|
|
11
|
+
export { list } from './dom/list.js';
|
|
12
|
+
export { when } from './dom/when.js';
|
|
13
|
+
export { ErrorBoundary } from './dom/error-boundary.js';
|
|
14
|
+
export { virtualList } from './dom/virtual-list.js';
|
|
15
|
+
export { portal } from './dom/portal.js';
|
|
16
|
+
export { WebSocketClient, createWebSocket } from './network/websocket.js';
|
|
17
|
+
export { observableArray } from './collections/observable-array.js';
|
|
18
|
+
export { Renderable } from './renderable/renderable.js';
|
|
19
|
+
export { Renderer } from './renderable/renderer.js';
|
|
20
|
+
export { renderToString, hydrate } from './renderable/render-string.js';
|
|
21
|
+
export { QueryClient } from './query/query-client.js';
|
|
22
|
+
export { EventHub } from './events/event-hub.js';
|
|
23
|
+
export { Router, createRouter, router } from './router/router.js';
|
|
24
|
+
export { context } from './context.js';
|
|
25
|
+
export { Elements } from './dom/tags.js';
|
|
26
|
+
export * from './dom/tags.js';
|
|
27
|
+
|
|
28
|
+
|
package/src/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export {
|
|
2
|
+
bootstrap,
|
|
3
|
+
component,
|
|
4
|
+
signal,
|
|
5
|
+
isSignal,
|
|
6
|
+
setSignal,
|
|
7
|
+
readSignal,
|
|
8
|
+
state,
|
|
9
|
+
isState,
|
|
10
|
+
isStatePath,
|
|
11
|
+
isComputed,
|
|
12
|
+
after,
|
|
13
|
+
before,
|
|
14
|
+
set,
|
|
15
|
+
resolve,
|
|
16
|
+
computed,
|
|
17
|
+
concat,
|
|
18
|
+
subscribe,
|
|
19
|
+
persist,
|
|
20
|
+
form,
|
|
21
|
+
list,
|
|
22
|
+
when,
|
|
23
|
+
ErrorBoundary,
|
|
24
|
+
virtualList,
|
|
25
|
+
portal,
|
|
26
|
+
WebSocketClient,
|
|
27
|
+
createWebSocket,
|
|
28
|
+
observableArray,
|
|
29
|
+
Renderable,
|
|
30
|
+
Renderer,
|
|
31
|
+
renderToString,
|
|
32
|
+
hydrate,
|
|
33
|
+
QueryClient,
|
|
34
|
+
EventHub,
|
|
35
|
+
Router,
|
|
36
|
+
createRouter,
|
|
37
|
+
router,
|
|
38
|
+
Elements,
|
|
39
|
+
context,
|
|
40
|
+
} from './core/runtime.js';
|
|
41
|
+
|
|
42
|
+
export * from './core/dom/tags.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates and attaches a component instance or render function to a target element.
|
|
3
|
+
*
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {new (...args: any[]) => T | (() => any)} ComponentClass
|
|
6
|
+
* @param {string|Element} target
|
|
7
|
+
* @returns {Promise<T|{ unmount(): void }>}
|
|
8
|
+
*/
|
|
9
|
+
export function bootstrap<T>(ComponentClass: new (...args: any[]) => T | (() => any), target: string | Element): Promise<T | {
|
|
10
|
+
unmount(): void;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function isObservableArray(value: any): boolean;
|
|
2
|
+
export function observableArray(initial?: any[]): any[];
|
|
3
|
+
export type ObservableArrayPatchInsert = {
|
|
4
|
+
type: "insert";
|
|
5
|
+
index: number;
|
|
6
|
+
items: any[];
|
|
7
|
+
};
|
|
8
|
+
export type ObservableArrayPatchRemove = {
|
|
9
|
+
type: "remove";
|
|
10
|
+
index: number;
|
|
11
|
+
count: number;
|
|
12
|
+
items: any[];
|
|
13
|
+
};
|
|
14
|
+
export type ObservableArrayPatchSet = {
|
|
15
|
+
type: "set";
|
|
16
|
+
index: number;
|
|
17
|
+
value: any;
|
|
18
|
+
prev: any;
|
|
19
|
+
};
|
|
20
|
+
export type ObservableArrayPatchReset = {
|
|
21
|
+
type: "reset";
|
|
22
|
+
items: any[];
|
|
23
|
+
prevItems: any[];
|
|
24
|
+
};
|
|
25
|
+
export type ObservableArrayPatch = ObservableArrayPatchInsert | ObservableArrayPatchRemove | ObservableArrayPatchSet | ObservableArrayPatchReset;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function component(renderFn: any): {
|
|
2
|
+
(props: any): FunctionComponentInstance;
|
|
3
|
+
__zbFactory: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare class FunctionComponentInstance extends DirtyHost {
|
|
6
|
+
constructor(renderFn: any, props: any);
|
|
7
|
+
props: any;
|
|
8
|
+
mountInto(parent: any, beforeNode: any): void;
|
|
9
|
+
renderToString(render: any): any;
|
|
10
|
+
onCleanup(fn: any): void;
|
|
11
|
+
#private;
|
|
12
|
+
}
|
|
13
|
+
import { DirtyHost } from '../reactivity/dirty-host.js';
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a context for sharing reactive state across a component tree
|
|
3
|
+
* without prop drilling.
|
|
4
|
+
*
|
|
5
|
+
* Returns { scope, state }:
|
|
6
|
+
* - scope(value?) — creates a new provider level. Returns a state with
|
|
7
|
+
* .get(), .set(), path access, and .serve(renderable) to wrap children.
|
|
8
|
+
* - state() — returns a reactive state bound to the nearest ancestor provider.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* const sizeCtx = context([1, 2, 3]);
|
|
12
|
+
*
|
|
13
|
+
* const Parent = (...children) => {
|
|
14
|
+
* const sizes = sizeCtx.scope();
|
|
15
|
+
* sizes.set([10, 20, 30]);
|
|
16
|
+
* return sizes.serve(Div(...children));
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* const Child = () => {
|
|
20
|
+
* const sizes = sizeCtx.state();
|
|
21
|
+
* return Div(sizes[0]);
|
|
22
|
+
* };
|
|
23
|
+
*
|
|
24
|
+
* Parent(Child());
|
|
25
|
+
*/
|
|
26
|
+
export function context(defaultValue: any): {
|
|
27
|
+
scope: (value: any) => {};
|
|
28
|
+
state: () => {};
|
|
29
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a comment node used as a stable DOM anchor.
|
|
3
|
+
* @param {string} label
|
|
4
|
+
* @param {string} name
|
|
5
|
+
*/
|
|
6
|
+
export function createComment(label: string, name: string): Comment;
|
|
7
|
+
/**
|
|
8
|
+
* Removes all sibling nodes between two anchors.
|
|
9
|
+
* @param {Comment} start
|
|
10
|
+
* @param {Comment} end
|
|
11
|
+
* @param {(node: Node) => void} [disposer]
|
|
12
|
+
*/
|
|
13
|
+
export function clearBetween(start: Comment, end: Comment, disposer?: (node: Node) => void): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class ElementNode extends Renderable {
|
|
2
|
+
constructor(tagName: any, props?: {}, children?: any[]);
|
|
3
|
+
tagName: any;
|
|
4
|
+
props: {};
|
|
5
|
+
children: any[];
|
|
6
|
+
mountInto(parent: any, beforeNode: any): void;
|
|
7
|
+
renderToString(render: any): string;
|
|
8
|
+
#private;
|
|
9
|
+
}
|
|
10
|
+
import { Renderable } from '../renderable/renderable.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function ErrorBoundary(options: any, child: any): ErrorBoundaryNode;
|
|
2
|
+
export class ErrorBoundaryNode extends Renderable {
|
|
3
|
+
constructor(options: any, child: any);
|
|
4
|
+
mountInto(parent: any, beforeNode: any): void;
|
|
5
|
+
renderToString(render: any): any;
|
|
6
|
+
#private;
|
|
7
|
+
}
|
|
8
|
+
import { Renderable } from '../renderable/renderable.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function list(items: any, renderItem: any): ListNode;
|
|
2
|
+
export class ListNode extends Renderable {
|
|
3
|
+
constructor(items: any, renderItem: any);
|
|
4
|
+
mountInto(parent: any, beforeNode: any): void;
|
|
5
|
+
renderToString(render: any): any;
|
|
6
|
+
#private;
|
|
7
|
+
}
|
|
8
|
+
import { Renderable } from '../renderable/renderable.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function portal(target: any, content: any): PortalNode;
|
|
2
|
+
export class PortalNode extends Renderable {
|
|
3
|
+
constructor(target: any, content: any);
|
|
4
|
+
mountInto(_parent: any, _beforeNode: any): void;
|
|
5
|
+
renderToString(render: any): any;
|
|
6
|
+
#private;
|
|
7
|
+
}
|
|
8
|
+
import { Renderable } from '../renderable/renderable.js';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export const Elements: Readonly<{}>;
|
|
2
|
+
export const Html: any;
|
|
3
|
+
export const Head: any;
|
|
4
|
+
export const Title: any;
|
|
5
|
+
export const Base: any;
|
|
6
|
+
export const Link: any;
|
|
7
|
+
export const Meta: any;
|
|
8
|
+
export const Style: any;
|
|
9
|
+
export const Body: any;
|
|
10
|
+
export const Article: any;
|
|
11
|
+
export const Section: any;
|
|
12
|
+
export const Nav: any;
|
|
13
|
+
export const Aside: any;
|
|
14
|
+
export const H1: any;
|
|
15
|
+
export const H2: any;
|
|
16
|
+
export const H3: any;
|
|
17
|
+
export const H4: any;
|
|
18
|
+
export const H5: any;
|
|
19
|
+
export const H6: any;
|
|
20
|
+
export const Hgroup: any;
|
|
21
|
+
export const Header: any;
|
|
22
|
+
export const Footer: any;
|
|
23
|
+
export const Address: any;
|
|
24
|
+
export const Main: any;
|
|
25
|
+
export const Search: any;
|
|
26
|
+
export const P: any;
|
|
27
|
+
export const Hr: any;
|
|
28
|
+
export const Pre: any;
|
|
29
|
+
export const Blockquote: any;
|
|
30
|
+
export const Ol: any;
|
|
31
|
+
export const Ul: any;
|
|
32
|
+
export const Li: any;
|
|
33
|
+
export const Dl: any;
|
|
34
|
+
export const Dt: any;
|
|
35
|
+
export const Dd: any;
|
|
36
|
+
export const Figure: any;
|
|
37
|
+
export const Figcaption: any;
|
|
38
|
+
export const Div: any;
|
|
39
|
+
export const Menu: any;
|
|
40
|
+
export const A: any;
|
|
41
|
+
export const Em: any;
|
|
42
|
+
export const Strong: any;
|
|
43
|
+
export const Small: any;
|
|
44
|
+
export const S: any;
|
|
45
|
+
export const Cite: any;
|
|
46
|
+
export const Q: any;
|
|
47
|
+
export const Dfn: any;
|
|
48
|
+
export const Abbr: any;
|
|
49
|
+
export const Ruby: any;
|
|
50
|
+
export const Rt: any;
|
|
51
|
+
export const Rp: any;
|
|
52
|
+
export const Data: any;
|
|
53
|
+
export const Time: any;
|
|
54
|
+
export const Code: any;
|
|
55
|
+
export const Var: any;
|
|
56
|
+
export const Samp: any;
|
|
57
|
+
export const Kbd: any;
|
|
58
|
+
export const Sub: any;
|
|
59
|
+
export const Sup: any;
|
|
60
|
+
export const I: any;
|
|
61
|
+
export const B: any;
|
|
62
|
+
export const U: any;
|
|
63
|
+
export const Mark: any;
|
|
64
|
+
export const Bdi: any;
|
|
65
|
+
export const Bdo: any;
|
|
66
|
+
export const Span: any;
|
|
67
|
+
export const Br: any;
|
|
68
|
+
export const Wbr: any;
|
|
69
|
+
export const Ins: any;
|
|
70
|
+
export const Del: any;
|
|
71
|
+
export const Picture: any;
|
|
72
|
+
export const Source: any;
|
|
73
|
+
export const Img: any;
|
|
74
|
+
export const Iframe: any;
|
|
75
|
+
export const Embed: any;
|
|
76
|
+
export const HtmlObject: any;
|
|
77
|
+
export const Param: any;
|
|
78
|
+
export const Video: any;
|
|
79
|
+
export const Audio: any;
|
|
80
|
+
export const Track: any;
|
|
81
|
+
export const Map: any;
|
|
82
|
+
export const Area: any;
|
|
83
|
+
export const Table: any;
|
|
84
|
+
export const Caption: any;
|
|
85
|
+
export const Colgroup: any;
|
|
86
|
+
export const Col: any;
|
|
87
|
+
export const Tbody: any;
|
|
88
|
+
export const Thead: any;
|
|
89
|
+
export const Tfoot: any;
|
|
90
|
+
export const Tr: any;
|
|
91
|
+
export const Td: any;
|
|
92
|
+
export const Th: any;
|
|
93
|
+
export const Form: any;
|
|
94
|
+
export const Label: any;
|
|
95
|
+
export const Input: any;
|
|
96
|
+
export const Button: any;
|
|
97
|
+
export const Select: any;
|
|
98
|
+
export const Datalist: any;
|
|
99
|
+
export const Optgroup: any;
|
|
100
|
+
export const Option: any;
|
|
101
|
+
export const Textarea: any;
|
|
102
|
+
export const Output: any;
|
|
103
|
+
export const Progress: any;
|
|
104
|
+
export const Meter: any;
|
|
105
|
+
export const Fieldset: any;
|
|
106
|
+
export const Legend: any;
|
|
107
|
+
export const Details: any;
|
|
108
|
+
export const Summary: any;
|
|
109
|
+
export const Dialog: any;
|
|
110
|
+
export const Script: any;
|
|
111
|
+
export const Noscript: any;
|
|
112
|
+
export const Template: any;
|
|
113
|
+
export const Slot: any;
|
|
114
|
+
export const Canvas: any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function virtualList(items: any, options: any): VirtualListNode;
|
|
2
|
+
export class VirtualListNode extends Renderable {
|
|
3
|
+
constructor(items: any, options?: {});
|
|
4
|
+
mountInto(parent: any, beforeNode: any): void;
|
|
5
|
+
renderToString(render: any): any;
|
|
6
|
+
#private;
|
|
7
|
+
}
|
|
8
|
+
import { Renderable } from '../renderable/renderable.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function when(source: any, renderTrue: any, renderFalse: any): WhenNode;
|
|
2
|
+
export function isWhen(value: any): boolean;
|
|
3
|
+
export function readWhenValue(value: any): any;
|
|
4
|
+
export function subscribeWhenValue(value: any, fn: any): any;
|
|
5
|
+
export class WhenNode extends Renderable {
|
|
6
|
+
constructor(source: any, renderTrue: any, renderFalse: any);
|
|
7
|
+
mountInto(parent: any, beforeNode: any): void;
|
|
8
|
+
readValue(): any;
|
|
9
|
+
subscribeValue(fn: any): any;
|
|
10
|
+
renderToString(render: any): any;
|
|
11
|
+
#private;
|
|
12
|
+
}
|
|
13
|
+
import { Renderable } from '../renderable/renderable.js';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal before/after event hub.
|
|
3
|
+
*
|
|
4
|
+
* - `before` handlers may return `false` to cancel the operation.
|
|
5
|
+
* - `after` handlers are fire-and-forget.
|
|
6
|
+
*/
|
|
7
|
+
export class EventHub {
|
|
8
|
+
/**
|
|
9
|
+
* @param {'before'|'after'} phase
|
|
10
|
+
* @param {string} type
|
|
11
|
+
* @param {(payload: any, ctx: any) => (void|boolean)} fn
|
|
12
|
+
* @returns {() => void}
|
|
13
|
+
*/
|
|
14
|
+
on(phase: "before" | "after", type: string, fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
15
|
+
/**
|
|
16
|
+
* Emits a before event. Returns false when cancelled.
|
|
17
|
+
* @param {string} type
|
|
18
|
+
* @param {any} payload
|
|
19
|
+
* @param {any} ctx
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
emitBefore(type: string, payload: any, ctx: any): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Emits an after event.
|
|
25
|
+
* @param {string} type
|
|
26
|
+
* @param {any} payload
|
|
27
|
+
* @param {any} ctx
|
|
28
|
+
*/
|
|
29
|
+
emitAfter(type: string, payload: any, ctx: any): void;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a fluent API for registering hooks.
|
|
32
|
+
* @param {'before'|'after'} phase
|
|
33
|
+
*/
|
|
34
|
+
phase(phase: "before" | "after"): {
|
|
35
|
+
/**
|
|
36
|
+
* Registers a handler for a given type.
|
|
37
|
+
* @param {string} type
|
|
38
|
+
* @param {(payload: any, ctx: any) => (void|boolean)} fn
|
|
39
|
+
*/
|
|
40
|
+
on(type: string, fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Registers a handler for any type.
|
|
43
|
+
* @param {(payload: any, ctx: any) => (void|boolean)} fn
|
|
44
|
+
*/
|
|
45
|
+
any(fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
46
|
+
};
|
|
47
|
+
#private;
|
|
48
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function createWebSocket(options: any): WebSocketClient;
|
|
2
|
+
export class WebSocketClient {
|
|
3
|
+
constructor(options?: {});
|
|
4
|
+
state(): {};
|
|
5
|
+
before(): {
|
|
6
|
+
on(type: string, fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
7
|
+
any(fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
8
|
+
};
|
|
9
|
+
after(): {
|
|
10
|
+
on(type: string, fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
11
|
+
any(fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
12
|
+
};
|
|
13
|
+
setUrl(next: any): void;
|
|
14
|
+
connect(): void;
|
|
15
|
+
send(value: any): void;
|
|
16
|
+
close(code: any, reason: any): void;
|
|
17
|
+
#private;
|
|
18
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query manager with caching and refetch orchestration.
|
|
3
|
+
*/
|
|
4
|
+
export class QueryClient {
|
|
5
|
+
/**
|
|
6
|
+
* Gets (or creates) a query instance for the given key.
|
|
7
|
+
*
|
|
8
|
+
* @param {QueryOptions} options
|
|
9
|
+
* @returns {Store & QueryState & { refetch(): Promise<any>, invalidate(): void, cancel(): void, ensure(): (Promise<any>|null), isStale: boolean }}
|
|
10
|
+
*/
|
|
11
|
+
query(options: QueryOptions): Store & QueryState & {
|
|
12
|
+
refetch(): Promise<any>;
|
|
13
|
+
invalidate(): void;
|
|
14
|
+
cancel(): void;
|
|
15
|
+
ensure(): (Promise<any> | null);
|
|
16
|
+
isStale: boolean;
|
|
17
|
+
};
|
|
18
|
+
use(middleware: any): () => void;
|
|
19
|
+
service(config?: {}): {
|
|
20
|
+
request: (endpoint: any, input?: {}) => Promise<any>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Marks a query as invalidated.
|
|
24
|
+
* @param {QueryKey} key
|
|
25
|
+
*/
|
|
26
|
+
invalidate(key: QueryKey): void;
|
|
27
|
+
/**
|
|
28
|
+
* Refetches a query immediately.
|
|
29
|
+
* @param {QueryKey} key
|
|
30
|
+
* @returns {Promise<any>|null}
|
|
31
|
+
*/
|
|
32
|
+
refetch(key: QueryKey): Promise<any> | null;
|
|
33
|
+
/**
|
|
34
|
+
* Removes a query from cache (cancels in-flight).
|
|
35
|
+
* @param {QueryKey} key
|
|
36
|
+
*/
|
|
37
|
+
remove(key: QueryKey): void;
|
|
38
|
+
#private;
|
|
39
|
+
}
|
|
40
|
+
export type QueryKeyAtom = string | number | boolean | null;
|
|
41
|
+
export type QueryKey = QueryKeyAtom | QueryKeyAtom[];
|
|
42
|
+
export type QueryStatus = "idle" | "loading" | "success" | "error";
|
|
43
|
+
export type QueryState = {
|
|
44
|
+
data: any;
|
|
45
|
+
error: any;
|
|
46
|
+
status: QueryStatus;
|
|
47
|
+
fetching: boolean;
|
|
48
|
+
updatedAt: number | null;
|
|
49
|
+
errorAt: number | null;
|
|
50
|
+
invalidated: boolean;
|
|
51
|
+
};
|
|
52
|
+
export type QueryContext = {
|
|
53
|
+
key: QueryKey;
|
|
54
|
+
signal: AbortSignal;
|
|
55
|
+
};
|
|
56
|
+
export type QueryOptions = {
|
|
57
|
+
key: QueryKey;
|
|
58
|
+
fetcher: (ctx: QueryContext) => Promise<any>;
|
|
59
|
+
/**
|
|
60
|
+
* ms
|
|
61
|
+
*/
|
|
62
|
+
staleTime?: number;
|
|
63
|
+
/**
|
|
64
|
+
* ms
|
|
65
|
+
*/
|
|
66
|
+
cacheTime?: number;
|
|
67
|
+
refetchOnFocus?: boolean;
|
|
68
|
+
refetchOnReconnect?: boolean;
|
|
69
|
+
retry?: number;
|
|
70
|
+
retryDelay?: (attempt: number) => number;
|
|
71
|
+
dedupe?: boolean;
|
|
72
|
+
refetchOnInvalidate?: boolean;
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function computed(input: any): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function concat(...input: any[]): any;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class that provides:
|
|
3
|
+
* - property instrumentation (dirty tracking)
|
|
4
|
+
* - microtask-batched flushing
|
|
5
|
+
* - subscription mechanism for template bindings
|
|
6
|
+
*
|
|
7
|
+
* This is part of the core runtime and is inherited by `Component`.
|
|
8
|
+
*/
|
|
9
|
+
export class DirtyHost extends Renderable {
|
|
10
|
+
[x: symbol]: ((prop: string, fn: () => void) => () => void) | ((prop: string) => void);
|
|
11
|
+
/**
|
|
12
|
+
* Registers BEFORE hooks. Handlers may return false to cancel.
|
|
13
|
+
* Example: `store.before().set(({ prop, next }) => next !== null)`
|
|
14
|
+
*/
|
|
15
|
+
before(): {
|
|
16
|
+
on(type: string, fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
17
|
+
any(fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Registers AFTER hooks.
|
|
21
|
+
* Example: `store.after().flush(({ props }) => console.log(props))`
|
|
22
|
+
*/
|
|
23
|
+
after(): {
|
|
24
|
+
on(type: string, fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
25
|
+
any(fn: (payload: any, ctx: any) => (void | boolean)): () => void;
|
|
26
|
+
};
|
|
27
|
+
emitBefore(type: any, payload: any, ctx: any): boolean;
|
|
28
|
+
emitAfter(type: any, payload: any, ctx: any): void;
|
|
29
|
+
/**
|
|
30
|
+
* Batches multiple assignments into a single flush.
|
|
31
|
+
*
|
|
32
|
+
* @param {() => void} cb
|
|
33
|
+
*/
|
|
34
|
+
set(cb: () => void): void;
|
|
35
|
+
/**
|
|
36
|
+
* Flushes all dirty properties, notifying any subscribers registered by bindings.
|
|
37
|
+
* Usually you don't need to call this manually, because assignments trigger a microtask flush.
|
|
38
|
+
*/
|
|
39
|
+
update(): void;
|
|
40
|
+
#private;
|
|
41
|
+
}
|
|
42
|
+
import { Renderable } from '../renderable/renderable.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function after(...targets: any[]): {
|
|
2
|
+
change(fn: any): () => void;
|
|
3
|
+
compute(fn: any, options?: {}): {};
|
|
4
|
+
};
|
|
5
|
+
export function before(...targets: any[]): {
|
|
6
|
+
change(fn: any): () => void;
|
|
7
|
+
compute(fn: any, options?: {}): {};
|
|
8
|
+
};
|
|
9
|
+
export function set(target: any, value: any): void;
|
|
10
|
+
export function subscribe(target: any, selector: any, listener: any, equalityFn: any): {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function persist(target: any, options?: {}): any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function resolve(value: any): any;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function signal(initial: any): {
|
|
2
|
+
get(): any;
|
|
3
|
+
set(next: any, force?: boolean): boolean;
|
|
4
|
+
subscribe(fn: any): () => boolean;
|
|
5
|
+
before(fn: any): () => boolean;
|
|
6
|
+
};
|
|
7
|
+
export function isSignal(value: any): boolean;
|
|
8
|
+
export function subscribeSignal(sig: any, fn: any): any;
|
|
9
|
+
export function readSignal(sig: any): any;
|
|
10
|
+
export function setSignal(sig: any, next: any, force?: boolean): any;
|
|
11
|
+
export function getMappedArrayMeta(value: any): any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function state(initial: any): {};
|
|
2
|
+
export function createStateFromAdapter(adapter: any): {};
|
|
3
|
+
export function mutateAdapter(adapter: any, optimistic: any, mutation: any, options?: {}): Promise<any>;
|
|
4
|
+
export function isState(value: any): boolean;
|
|
5
|
+
export function isComputed(value: any): boolean;
|
|
6
|
+
export function isStatePath(value: any): any;
|
|
7
|
+
export function readState(value: any): any;
|
|
8
|
+
export function readStateFromRoot(value: any, root: any): any;
|
|
9
|
+
export function subscribeState(value: any, fn: any): any;
|
|
10
|
+
export function readStateMeta(meta: any): any;
|
|
11
|
+
export function subscribeStateMeta(meta: any, fn: any): any;
|
|
12
|
+
export function setStateValue(value: any, next: any): any;
|
|
13
|
+
export function getMappedMeta(value: any): any;
|
|
14
|
+
export function withDefaults(target: any, defaults: any, options?: {}): any;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base contract for objects that can be mounted/unmounted by the core renderer.
|
|
3
|
+
*/
|
|
4
|
+
export class Renderable {
|
|
5
|
+
/**
|
|
6
|
+
* Mounts the instance into the DOM.
|
|
7
|
+
* @param {Node} parent
|
|
8
|
+
* @param {Node|null} beforeNode
|
|
9
|
+
*/
|
|
10
|
+
mountInto(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Unmounts and releases DOM/resources owned by the instance.
|
|
13
|
+
*/
|
|
14
|
+
unmount(): void;
|
|
15
|
+
}
|