ouider 0.0.3 → 0.0.4
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/dist/dom/dom.cjs +2 -1
- package/dist/dom/dom.cjs.map +1 -1
- package/dist/dom/dom.js +2 -1
- package/dist/dom/dom.js.map +1 -1
- package/dist/index.cjs +22 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +194 -101
- package/dist/index.d.ts +194 -101
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,95 +1,10 @@
|
|
|
1
|
-
declare class Emits<O extends Record<string, any>> {
|
|
2
|
-
private events;
|
|
3
|
-
constructor(events: O);
|
|
4
|
-
emit(event: keyof O, ...args: any): void;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
type StateWatcher<T> = <K extends keyof T>(key: K, oldValue: T[K], newValue: T[K]) => void;
|
|
8
|
-
declare class Stated<T> {
|
|
9
|
-
value: T;
|
|
10
|
-
constructor(value: T);
|
|
11
|
-
}
|
|
12
|
-
declare function isStated<T>(ob: any): ob is Stated<T>;
|
|
13
|
-
declare function stated<S extends Record<string, string>, T>(target: T, state: State<S>): Stated<T>;
|
|
14
|
-
declare class State<T extends Record<string, any>> {
|
|
15
|
-
private THRESHOLD_TIME;
|
|
16
|
-
private debounceTime;
|
|
17
|
-
private state;
|
|
18
|
-
private listeners;
|
|
19
|
-
private timer;
|
|
20
|
-
constructor(data: T);
|
|
21
|
-
wrap<T>(obj: T): Stated<T>;
|
|
22
|
-
has(key: keyof T): boolean;
|
|
23
|
-
setValue(key: keyof T, value: any): void;
|
|
24
|
-
getValue(key: keyof T): any;
|
|
25
|
-
get value(): T;
|
|
26
|
-
private dispatchChanges;
|
|
27
|
-
didChange(path: keyof T, oldValue: any, newValue: any): Promise<void>;
|
|
28
|
-
watch(listener: StateWatcher<T>): number;
|
|
29
|
-
unwatch(listener: StateWatcher<T> | number): void;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type ComponentProps<K extends Record<string, any>> = K;
|
|
33
|
-
/**
|
|
34
|
-
* Component decorator, it allow an auto registration of components
|
|
35
|
-
* @param options
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
declare function Component(options: {
|
|
39
|
-
template: string;
|
|
40
|
-
tag: string;
|
|
41
|
-
use?: OComponentType[];
|
|
42
|
-
css?: string;
|
|
43
|
-
}): <T extends {
|
|
44
|
-
new (...args: any[]): {};
|
|
45
|
-
}>(constructor: T) => {
|
|
46
|
-
new (...args: any[]): {
|
|
47
|
-
template: string;
|
|
48
|
-
css: string | undefined;
|
|
49
|
-
hash: string;
|
|
50
|
-
};
|
|
51
|
-
} & T;
|
|
52
|
-
interface Component<P extends Record<string, any>, O extends Record<string, any>> {
|
|
53
|
-
state: State<any>;
|
|
54
|
-
readonly emits: Emits<O>;
|
|
55
|
-
readonly props: ComponentProps<P>;
|
|
56
|
-
onMounted(): void;
|
|
57
|
-
willMount(): void;
|
|
58
|
-
willUnmount(): void;
|
|
59
|
-
provide<T>(key: string, value: T): void;
|
|
60
|
-
inject<T>(key: string): T | undefined;
|
|
61
|
-
}
|
|
62
|
-
interface ComponentConstructor<P extends Record<string, any>, O extends Record<string, any>> {
|
|
63
|
-
new (props?: P, emits?: O): Component<P, O>;
|
|
64
|
-
}
|
|
65
|
-
declare function createComponent<P extends Record<string, any>, O extends Record<string, any>>(ctr: ComponentConstructor<P, O>, props?: P, emits?: O): Component<P, O>;
|
|
66
|
-
declare class OComponent<P extends Record<string, any> = {}, O extends Record<string, any> = {}> implements Component<P, O> {
|
|
67
|
-
state: State<any>;
|
|
68
|
-
private parent?;
|
|
69
|
-
readonly emits: Emits<O>;
|
|
70
|
-
readonly props: ComponentProps<P>;
|
|
71
|
-
private provides;
|
|
72
|
-
constructor(props?: P, emits?: O);
|
|
73
|
-
onMounted(): void;
|
|
74
|
-
willMount(): void;
|
|
75
|
-
willUnmount(): void;
|
|
76
|
-
/** Provide a value for descendants */
|
|
77
|
-
provide<T>(key: string, value: T): void;
|
|
78
|
-
/** Inject a value from nearest ancestor */
|
|
79
|
-
inject<T>(key: string): T | undefined;
|
|
80
|
-
}
|
|
81
|
-
type LazyLoader<P extends Record<string, any>, O extends Record<string, any>> = () => Promise<{
|
|
82
|
-
default: ComponentConstructor<P, O>;
|
|
83
|
-
}>;
|
|
84
|
-
type OComponentType<P extends Record<string, any> = {}, O extends Record<string, any> = {}> = ComponentConstructor<P, O> | LazyLoader<P, O>;
|
|
85
|
-
|
|
86
1
|
type ProvideFunction<T> = () => T;
|
|
87
2
|
type Provider<T = any> = {
|
|
88
3
|
value?: T;
|
|
89
4
|
provide?: ProvideFunction<T>;
|
|
90
5
|
};
|
|
91
|
-
interface Plugin {
|
|
92
|
-
install(app: App): void;
|
|
6
|
+
interface Plugin<T> {
|
|
7
|
+
install(app: App, options?: T): void;
|
|
93
8
|
}
|
|
94
9
|
/** Injection token key */
|
|
95
10
|
type InjectionKey = string;
|
|
@@ -120,7 +35,7 @@ declare class App {
|
|
|
120
35
|
* @param plugin the plugin to register
|
|
121
36
|
* @returns `this` App instance
|
|
122
37
|
*/
|
|
123
|
-
use(plugin: Plugin): this;
|
|
38
|
+
use<T>(plugin: Plugin<T>, options?: T): this;
|
|
124
39
|
constructor(root: ComponentConstructor<any, any>, options?: {
|
|
125
40
|
css?: string;
|
|
126
41
|
} | undefined);
|
|
@@ -145,6 +60,44 @@ declare function inject<T>(token: InjectionKey): T | undefined;
|
|
|
145
60
|
|
|
146
61
|
type QueryFilter = "children" | "classes" | "style" | "attributes";
|
|
147
62
|
declare namespace ODOM {
|
|
63
|
+
export class BatchActions {
|
|
64
|
+
private actions;
|
|
65
|
+
constructor();
|
|
66
|
+
exec(): Promise<any>;
|
|
67
|
+
add(action: () => void): this;
|
|
68
|
+
commit(): Promise<void>;
|
|
69
|
+
}
|
|
70
|
+
export class BatchUpdates {
|
|
71
|
+
private node;
|
|
72
|
+
private operations;
|
|
73
|
+
constructor(node: OElement);
|
|
74
|
+
exec(): Promise<any>;
|
|
75
|
+
private append;
|
|
76
|
+
add(fn: () => void): this;
|
|
77
|
+
addEventListener(event: string, callback: (...args: any[]) => void): BatchUpdates;
|
|
78
|
+
setProperty(key: string, value: string): BatchUpdates;
|
|
79
|
+
dettachEventListener(event: string, cbId: string): BatchUpdates;
|
|
80
|
+
invoke(fn: string, ...args: any[]): BatchUpdates;
|
|
81
|
+
dispatchEvent(eventName: string, eventClass?: string, initDict?: any): BatchUpdates;
|
|
82
|
+
addClass(...tokens: string[]): BatchUpdates;
|
|
83
|
+
removeClass(...tokens: string[]): BatchUpdates;
|
|
84
|
+
setAttribute(name: string, value: string): BatchUpdates;
|
|
85
|
+
removeAttribute(name: string): BatchUpdates;
|
|
86
|
+
appendChild(child: ONode): BatchUpdates;
|
|
87
|
+
removeChild(child: ONode): BatchUpdates;
|
|
88
|
+
remove(): BatchUpdates;
|
|
89
|
+
removeAndRelease(): BatchUpdates;
|
|
90
|
+
release(): BatchUpdates;
|
|
91
|
+
innerHTML(html: string): BatchUpdates;
|
|
92
|
+
replaceChildNode(node: ONode, child: ONode): BatchUpdates;
|
|
93
|
+
replaceWith(node: ONode): BatchUpdates;
|
|
94
|
+
after(node: ONode): BatchUpdates;
|
|
95
|
+
setInnerText(text: string): BatchUpdates;
|
|
96
|
+
setContentText(text: string): BatchUpdates;
|
|
97
|
+
insertBefore(element: ONode, node: ONode): BatchUpdates;
|
|
98
|
+
setInputValue(value: string): BatchUpdates;
|
|
99
|
+
setStyle(key: string, value: any): BatchUpdates;
|
|
100
|
+
}
|
|
148
101
|
export type NodeType = 'Element' | 'Text' | 'Comment' | 'Attribute' | 'Unknown';
|
|
149
102
|
type Attributes = {
|
|
150
103
|
name: string;
|
|
@@ -171,14 +124,17 @@ declare namespace ODOM {
|
|
|
171
124
|
constructor(node: ONode);
|
|
172
125
|
}
|
|
173
126
|
export class OElement extends ONode {
|
|
127
|
+
private _hydrated;
|
|
174
128
|
constructor(node: ONode);
|
|
175
|
-
addClass(
|
|
129
|
+
addClass(...tokens: string[]): Promise<void>;
|
|
130
|
+
removeClass(...tokens: string[]): Promise<void>;
|
|
176
131
|
setAttribute(name: string, value: string): Promise<void>;
|
|
177
132
|
removeAttribute(name: string): Promise<void>;
|
|
178
133
|
appendChild(child: ONode): Promise<void>;
|
|
179
134
|
set innerHTML(value: string);
|
|
180
135
|
cloneNode(state: boolean): Promise<OElement | null>;
|
|
181
136
|
remove(): Promise<void>;
|
|
137
|
+
removeAndRelease(): Promise<void>;
|
|
182
138
|
removeChild(child: ONode): Promise<void>;
|
|
183
139
|
replaceChildNode(node: ONode, child: ONode): Promise<void>;
|
|
184
140
|
replaceWith(node: ONode): Promise<void>;
|
|
@@ -193,14 +149,19 @@ declare namespace ODOM {
|
|
|
193
149
|
hasAttribute(name: string): boolean;
|
|
194
150
|
getAttribute(name: string): Promise<string>;
|
|
195
151
|
attribute(name: string): string | null;
|
|
152
|
+
nextSibling(): Promise<OElement | null>;
|
|
196
153
|
getAttributeNames(): Promise<string[]>;
|
|
197
154
|
parentNode(): Promise<OElement | null>;
|
|
198
|
-
insertBefore(element: ONode, node: ONode): Promise<
|
|
155
|
+
insertBefore(element: ONode, node: ONode): Promise<void>;
|
|
199
156
|
setInputValue(value: string): Promise<void>;
|
|
200
157
|
inputValue(value: string): Promise<string>;
|
|
158
|
+
get hydrated(): boolean;
|
|
159
|
+
hydrate(): void;
|
|
201
160
|
query(selector: string, filter?: QueryFilter[]): Promise<OElement | null>;
|
|
202
161
|
queryAll(selector: string, filter?: QueryFilter[]): Promise<OElement[] | null>;
|
|
203
162
|
release(): Promise<void>;
|
|
163
|
+
setStyle(key: string, value: any): Promise<void>;
|
|
164
|
+
updates(): BatchUpdates;
|
|
204
165
|
}
|
|
205
166
|
export { };
|
|
206
167
|
}
|
|
@@ -220,6 +181,12 @@ type OUIDConfig = {
|
|
|
220
181
|
declare var WebOUID: {
|
|
221
182
|
invoke: (id: string, name: string, argsJson: string) => void;
|
|
222
183
|
} | undefined;
|
|
184
|
+
type RequestData = {
|
|
185
|
+
method: string;
|
|
186
|
+
headers: Record<string, string>;
|
|
187
|
+
body: any;
|
|
188
|
+
credentials: "include" | "omit" | "same-origin";
|
|
189
|
+
};
|
|
223
190
|
declare class OUIDBridge implements OUIDBridgeInterface {
|
|
224
191
|
private callbacks;
|
|
225
192
|
private DOM_EVENT_LISTENERS;
|
|
@@ -229,6 +196,8 @@ declare class OUIDBridge implements OUIDBridgeInterface {
|
|
|
229
196
|
constructor();
|
|
230
197
|
config(conf?: OUIDConfig): OUIDBridge;
|
|
231
198
|
invoke(name: string, ...args: any[]): Promise<any>;
|
|
199
|
+
registerComponent(tag: string, compClass: OComponentType<any, any>): void;
|
|
200
|
+
unregisterComponent(tag: string, compClass: OComponentType<any, any>): void;
|
|
232
201
|
/**
|
|
233
202
|
* Make a synchronous class
|
|
234
203
|
* @param name the name without '_oui' prefix
|
|
@@ -245,7 +214,7 @@ declare class OUIDBridge implements OUIDBridgeInterface {
|
|
|
245
214
|
subscribe(event: string, callback: (id: string, ...args: any[]) => void): void;
|
|
246
215
|
query(selector: string, filter?: QueryFilter[], nodeId?: string): Promise<ODOM.OElement | null>;
|
|
247
216
|
queryAll(selector: string, filter?: QueryFilter[], nodeId?: string): Promise<ODOM.OElement[] | null>;
|
|
248
|
-
|
|
217
|
+
createElement(tag: string, props?: Record<string, string>): Promise<ODOM.OElement | null>;
|
|
249
218
|
createComment(data: string): Promise<ODOM.OElement | null>;
|
|
250
219
|
addEventListener(node: ODOM.OObject | 'window' | 'document', event: string, callback: (...args: any[]) => void): Promise<string>;
|
|
251
220
|
dettachEventListener(node: ODOM.OObject | 'window' | 'document', event: string, cbId: string): Promise<void>;
|
|
@@ -257,6 +226,9 @@ declare class OUIDBridge implements OUIDBridgeInterface {
|
|
|
257
226
|
clearTimeout(id: number): Promise<void>;
|
|
258
227
|
setInterval(callback: () => void, delay: number): Promise<number>;
|
|
259
228
|
clearInterval(id: number): Promise<void>;
|
|
229
|
+
fetch(url: string, input: RequestData, encodeAs: "json"): Promise<any>;
|
|
230
|
+
fetch(url: string, input: RequestData, encodeAs: "text"): Promise<string>;
|
|
231
|
+
fetch(url: string, input: RequestData, encodeAs: "base64"): Promise<string>;
|
|
260
232
|
}
|
|
261
233
|
declare const OUID: OUIDBridge;
|
|
262
234
|
declare global {
|
|
@@ -268,10 +240,15 @@ declare class RenderContext {
|
|
|
268
240
|
component: OComponent<Record<string, any>, Record<string, any>>;
|
|
269
241
|
private parentContext;
|
|
270
242
|
static PROVIDE_TOKEN: string;
|
|
243
|
+
static STYLE_REF: WeakMap<any, number>;
|
|
271
244
|
private bindings;
|
|
272
245
|
private directives;
|
|
273
246
|
private mountedComponents;
|
|
247
|
+
private componentsRegistry;
|
|
248
|
+
private updatingDirectives;
|
|
249
|
+
private updatingBindings;
|
|
274
250
|
stack: Record<string, any>[];
|
|
251
|
+
hydradationActions: ODOM.BatchActions;
|
|
275
252
|
constructor(app: App, component: OComponent<Record<string, any>, Record<string, any>>, parentContext: RenderContext | null, ...frames: Record<string, any>[]);
|
|
276
253
|
get hostElement(): ODOM.OElement;
|
|
277
254
|
bind(binding: Binding): void;
|
|
@@ -285,14 +262,17 @@ declare class RenderContext {
|
|
|
285
262
|
updateValue(key: string, value: any): void;
|
|
286
263
|
push(frame: Record<string, any>): void;
|
|
287
264
|
pop(): void;
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
265
|
+
resolveTag(tag: string): OComponentType<any, any> | undefined;
|
|
266
|
+
updateBindings(updates?: ODOM.BatchActions): Promise<void>;
|
|
267
|
+
updateBinding(binding: Binding, updates: ODOM.BatchActions): void;
|
|
268
|
+
updateDirectives(updates?: ODOM.BatchActions): Promise<void>;
|
|
291
269
|
private render;
|
|
292
270
|
private expandClass;
|
|
293
271
|
private expandStyle;
|
|
294
272
|
private expandStandardAttributes;
|
|
295
|
-
handleElementNode(node: ODOM.OElement
|
|
273
|
+
handleElementNode(node: ODOM.OElement, options?: {
|
|
274
|
+
skipSlotted: boolean;
|
|
275
|
+
}): Promise<void>;
|
|
296
276
|
handleTextNode(node: ODOM.OElement): void;
|
|
297
277
|
private componentAttributes;
|
|
298
278
|
mountComponent<T extends Record<string, any>, O extends Record<string, string>>(hostNode: ODOM.OElement, component: OComponentType<T, O>, parentContext: RenderContext | null, props?: Record<string, {
|
|
@@ -316,6 +296,7 @@ type Directive = {
|
|
|
316
296
|
placeholder: ODOM.OElement;
|
|
317
297
|
context: RenderContext;
|
|
318
298
|
active?: boolean;
|
|
299
|
+
renderedNode?: ODOM.OElement;
|
|
319
300
|
list?: string;
|
|
320
301
|
item?: string;
|
|
321
302
|
children?: Map<any, {
|
|
@@ -323,16 +304,127 @@ type Directive = {
|
|
|
323
304
|
ctx: RenderContext;
|
|
324
305
|
}>;
|
|
325
306
|
key?: string;
|
|
307
|
+
destroy?: boolean;
|
|
326
308
|
};
|
|
309
|
+
declare function node<P extends Record<string, any>, O extends Record<string, any>>(component: string, p?: P, children?: RenderNode[], emits?: O): Promise<RenderNode>;
|
|
327
310
|
declare function o<P extends Record<string, any>, O extends Record<string, any>>(component: ComponentConstructor<P, O>, props: P, emits?: O): OComponent<P>;
|
|
328
311
|
declare function o<P extends Record<string, any>, O extends Record<string, any>>(component: OComponentType<P, O>, props: P, emits?: O): Promise<OComponent<P>>;
|
|
329
312
|
|
|
313
|
+
declare class Emits<O extends Record<string, any>> {
|
|
314
|
+
private events;
|
|
315
|
+
constructor(events: O);
|
|
316
|
+
emit(event: keyof O, ...args: any): void;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
type StateWatcher<T> = <K extends keyof T>(key: K, oldValue: T[K], newValue: T[K]) => void;
|
|
320
|
+
declare class Stated<T> {
|
|
321
|
+
value: T;
|
|
322
|
+
constructor(value: T);
|
|
323
|
+
}
|
|
324
|
+
declare function isStated<T>(ob: any): ob is Stated<T>;
|
|
325
|
+
declare function stated<S extends Record<string, string>, T>(target: T, state: State<S>): Stated<T>;
|
|
326
|
+
declare class State<T extends Record<string, any>> {
|
|
327
|
+
private THRESHOLD_TIME;
|
|
328
|
+
private debounceTime;
|
|
329
|
+
private state;
|
|
330
|
+
private listeners;
|
|
331
|
+
private timer;
|
|
332
|
+
constructor(data: T);
|
|
333
|
+
wrap<T>(obj: T): Stated<T>;
|
|
334
|
+
has(key: keyof T): boolean;
|
|
335
|
+
setValue(key: keyof T, value: any): void;
|
|
336
|
+
getValue(key: keyof T): any;
|
|
337
|
+
get value(): T;
|
|
338
|
+
private dispatchChanges;
|
|
339
|
+
didChange(path: keyof T, oldValue: any, newValue: any): Promise<void>;
|
|
340
|
+
watch(listener: StateWatcher<T>): number;
|
|
341
|
+
unwatch(listener: StateWatcher<T> | number): void;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
type ComponentProps<K extends Record<string, any>> = K;
|
|
345
|
+
declare class RenderNode {
|
|
346
|
+
private node;
|
|
347
|
+
private children;
|
|
348
|
+
constructor(node: ODOM.OElement | string, children?: RenderNode[]);
|
|
349
|
+
attachTo(host: ODOM.OElement): void;
|
|
350
|
+
static of(node: ODOM.OElement | string, children?: RenderNode[]): RenderNode;
|
|
351
|
+
addChild(node: RenderNode): RenderNode;
|
|
352
|
+
}
|
|
353
|
+
declare class StyleData {
|
|
354
|
+
private data;
|
|
355
|
+
private css;
|
|
356
|
+
constructor(data: Record<string, StyleData | string>, css: string);
|
|
357
|
+
toString(): string;
|
|
358
|
+
static of(data: Record<string, StyleData | string>, ...css: string[]): StyleData;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Component decorator, it allow an auto registration of components
|
|
362
|
+
* @param options
|
|
363
|
+
* @returns
|
|
364
|
+
*/
|
|
365
|
+
declare function Component(options: {
|
|
366
|
+
template: string;
|
|
367
|
+
tag: string;
|
|
368
|
+
use?: Record<string, OComponentType>;
|
|
369
|
+
css?: string;
|
|
370
|
+
hostClasses?: string | string[];
|
|
371
|
+
}): <T extends {
|
|
372
|
+
new (...args: any[]): {};
|
|
373
|
+
}>(constructor: T) => {
|
|
374
|
+
new (...args: any[]): {
|
|
375
|
+
template: string;
|
|
376
|
+
css: string | undefined;
|
|
377
|
+
tag: string;
|
|
378
|
+
use: Record<string, OComponentType<{}, {}>> | undefined;
|
|
379
|
+
hostClasses: string | string[] | undefined;
|
|
380
|
+
hash: string;
|
|
381
|
+
};
|
|
382
|
+
} & T;
|
|
383
|
+
interface Component<P extends Record<string, any>, O extends Record<string, any>> {
|
|
384
|
+
state: State<any>;
|
|
385
|
+
readonly emits: Emits<O>;
|
|
386
|
+
readonly props: ComponentProps<P>;
|
|
387
|
+
onMounted(): void;
|
|
388
|
+
willMount(): void;
|
|
389
|
+
willUnmount(): void;
|
|
390
|
+
provide<T>(key: string, value: T): void;
|
|
391
|
+
inject<T>(key: string): T | undefined;
|
|
392
|
+
render?(ctx: RenderContext): RenderNode | null | Promise<RenderNode | null>;
|
|
393
|
+
style?(): StyleData | null;
|
|
394
|
+
decorateHostElement(hostElement: ODOM.OElement): Promise<void>;
|
|
395
|
+
}
|
|
396
|
+
interface ComponentConstructor<P extends Record<string, any>, O extends Record<string, any>> {
|
|
397
|
+
new (props?: P, emits?: O): Component<P, O>;
|
|
398
|
+
}
|
|
399
|
+
declare function createComponent<P extends Record<string, any>, O extends Record<string, any>>(ctr: ComponentConstructor<P, O>, props?: P, emits?: O): Component<P, O>;
|
|
400
|
+
declare class OComponent<P extends Record<string, any> = {}, O extends Record<string, any> = {}> implements Component<P, O> {
|
|
401
|
+
state: State<any>;
|
|
402
|
+
private parent?;
|
|
403
|
+
readonly emits: Emits<O>;
|
|
404
|
+
readonly props: ComponentProps<P>;
|
|
405
|
+
private provides;
|
|
406
|
+
constructor(props?: P, emits?: O);
|
|
407
|
+
onMounted(): void;
|
|
408
|
+
willMount(): void;
|
|
409
|
+
willUnmount(): void;
|
|
410
|
+
/** Provide a value for descendants */
|
|
411
|
+
provide<T>(key: string, value: T): void;
|
|
412
|
+
/** Inject a value from nearest ancestor */
|
|
413
|
+
inject<T>(key: string): T | undefined;
|
|
414
|
+
render?(ctx: RenderContext): RenderNode | null | Promise<RenderNode | null>;
|
|
415
|
+
style?(): StyleData | null;
|
|
416
|
+
decorateHostElement(hostElement: ODOM.OElement): Promise<void>;
|
|
417
|
+
}
|
|
418
|
+
type LazyLoader<P extends Record<string, any>, O extends Record<string, any>> = () => Promise<{
|
|
419
|
+
default: ComponentConstructor<P, O>;
|
|
420
|
+
}>;
|
|
421
|
+
type OComponentType<P extends Record<string, any> = {}, O extends Record<string, any> = {}> = ComponentConstructor<P, O> | LazyLoader<P, O>;
|
|
422
|
+
|
|
330
423
|
/**
|
|
331
424
|
* Component responsible for display routes
|
|
332
425
|
* Usage: <o-router></o-router>
|
|
333
426
|
*/
|
|
334
|
-
declare class
|
|
335
|
-
private routeStateHander;
|
|
427
|
+
declare class ORouter extends OComponent {
|
|
336
428
|
private router;
|
|
337
429
|
willMount(): void;
|
|
338
430
|
onMounted(): void;
|
|
@@ -372,7 +464,7 @@ interface RouteGuard {
|
|
|
372
464
|
type: 'before' | 'after';
|
|
373
465
|
fn: RouteGaurdFunction;
|
|
374
466
|
}
|
|
375
|
-
declare class Router implements Plugin {
|
|
467
|
+
declare class Router implements Plugin<any> {
|
|
376
468
|
routes: Routes;
|
|
377
469
|
private windowObject;
|
|
378
470
|
private guards;
|
|
@@ -386,14 +478,15 @@ declare class Router implements Plugin {
|
|
|
386
478
|
params?: Record<string, string>;
|
|
387
479
|
absolute?: boolean;
|
|
388
480
|
}): void;
|
|
481
|
+
pop(): void;
|
|
389
482
|
private beforeRouteGoing;
|
|
390
483
|
private afterRouteGoing;
|
|
391
|
-
bind(component:
|
|
392
|
-
unbind(
|
|
484
|
+
bind(component: ORouter): Promise<(() => void)>;
|
|
485
|
+
unbind(): void;
|
|
393
486
|
beforeEach(fn: RouteGaurdFunction): (() => void);
|
|
394
487
|
afterEach(fn: RouteGaurdFunction): (() => void);
|
|
395
488
|
}
|
|
396
489
|
|
|
397
490
|
declare function components(): Record<string, OComponent<any, any>>;
|
|
398
491
|
|
|
399
|
-
export { ACTIVE_ROUTE_TOKEN, App, type Binding, Component, type ComponentConstructor, type ComponentProps, type Directive, Emits, type InjectionKey, type LazyLoader, Native, OComponent, type OComponentType, ODOM, OUID, OUIDBridge, type OUIDBridgeInterface, type OUIDConfig, type Plugin, type Promised, type Provider, type Providers, ROUTER_INJECTION_TOKEN, RenderContext, type Route, type RouteGaurdFunction, type RouteGuard, type RouteGuardReturn, type RouteLocationNamed, Router,
|
|
492
|
+
export { ACTIVE_ROUTE_TOKEN, App, type Binding, Component, type ComponentConstructor, type ComponentProps, type Directive, Emits, type InjectionKey, type LazyLoader, Native, OComponent, type OComponentType, ODOM, ORouter, OUID, OUIDBridge, type OUIDBridgeInterface, type OUIDConfig, type Plugin, type Promised, type Provider, type Providers, ROUTER_INJECTION_TOKEN, RenderContext, RenderNode, type Route, type RouteGaurdFunction, type RouteGuard, type RouteGuardReturn, type RouteLocationNamed, Router, type Routes, State, type StateWatcher, Stated, StyleData, WebOUID, components, createComponent, createRouter, inject, isStated, node, o, provide, stated, useRouter };
|