ouider 0.0.2 → 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 +3 -0
- package/dist/dom/dom.cjs.map +1 -0
- package/dist/dom/dom.d.cts +26 -0
- package/dist/dom/dom.d.ts +26 -0
- package/dist/dom/dom.js +3 -0
- package/dist/dom/dom.js.map +1 -0
- package/dist/index.cjs +24 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +492 -0
- package/dist/index.d.ts +340 -115
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/package.json +12 -2
- package/dist/index.d.mts +0 -267
- package/dist/index.mjs +0 -4
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,89 +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, 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): 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
|
-
declare function Component(options: {
|
|
34
|
-
template: string;
|
|
35
|
-
tag: string;
|
|
36
|
-
use?: OComponentType[];
|
|
37
|
-
css?: string;
|
|
38
|
-
}): <T extends {
|
|
39
|
-
new (...args: any[]): {};
|
|
40
|
-
}>(constructor: T) => {
|
|
41
|
-
new (...args: any[]): {
|
|
42
|
-
template: string;
|
|
43
|
-
css: string;
|
|
44
|
-
};
|
|
45
|
-
} & T;
|
|
46
|
-
interface Component<P extends Record<string, any>, O extends Record<string, any>> {
|
|
47
|
-
state: State<any>;
|
|
48
|
-
readonly emits: Emits<O>;
|
|
49
|
-
readonly props: ComponentProps<P>;
|
|
50
|
-
onMounted(): void;
|
|
51
|
-
willMount(): void;
|
|
52
|
-
willUnmount(): void;
|
|
53
|
-
provide<T>(key: string, value: T): void;
|
|
54
|
-
inject<T>(key: string): T | undefined;
|
|
55
|
-
}
|
|
56
|
-
interface ComponentConstructor<P extends Record<string, any>, O extends Record<string, any>> {
|
|
57
|
-
new (props?: P, emits?: O): Component<P, O>;
|
|
58
|
-
}
|
|
59
|
-
declare function createComponent<P extends Record<string, any>, O extends Record<string, any>>(ctr: ComponentConstructor<P, O>, props?: P, emits?: O): Component<P, O>;
|
|
60
|
-
declare class OComponent<P extends Record<string, any> = {}, O extends Record<string, any> = {}> implements Component<P, O> {
|
|
61
|
-
state: State<any>;
|
|
62
|
-
private parent?;
|
|
63
|
-
readonly emits: Emits<O>;
|
|
64
|
-
readonly props: ComponentProps<P>;
|
|
65
|
-
private provides;
|
|
66
|
-
constructor(props?: P, emits?: O);
|
|
67
|
-
onMounted(): void;
|
|
68
|
-
willMount(): void;
|
|
69
|
-
willUnmount(): void;
|
|
70
|
-
/** Provide a value for descendants */
|
|
71
|
-
provide<T>(key: string, value: T): void;
|
|
72
|
-
/** Inject a value from nearest ancestor */
|
|
73
|
-
inject<T>(key: string): T | undefined;
|
|
74
|
-
}
|
|
75
|
-
type LazyLoader<P extends Record<string, any>, O extends Record<string, any>> = () => Promise<{
|
|
76
|
-
default: ComponentConstructor<P, O>;
|
|
77
|
-
}>;
|
|
78
|
-
type OComponentType<P extends Record<string, any> = {}, O extends Record<string, any> = {}> = ComponentConstructor<P, O> | LazyLoader<P, O>;
|
|
79
|
-
|
|
80
1
|
type ProvideFunction<T> = () => T;
|
|
81
2
|
type Provider<T = any> = {
|
|
82
3
|
value?: T;
|
|
83
4
|
provide?: ProvideFunction<T>;
|
|
84
5
|
};
|
|
85
|
-
interface Plugin {
|
|
86
|
-
install(app: App): void;
|
|
6
|
+
interface Plugin<T> {
|
|
7
|
+
install(app: App, options?: T): void;
|
|
87
8
|
}
|
|
88
9
|
/** Injection token key */
|
|
89
10
|
type InjectionKey = string;
|
|
@@ -94,6 +15,7 @@ type Providers = Map<InjectionKey, Provider>;
|
|
|
94
15
|
*/
|
|
95
16
|
declare class App {
|
|
96
17
|
private root;
|
|
18
|
+
private options?;
|
|
97
19
|
static currentApp: App | null;
|
|
98
20
|
private providers;
|
|
99
21
|
/**
|
|
@@ -107,20 +29,21 @@ declare class App {
|
|
|
107
29
|
* @param token the key to look up globally
|
|
108
30
|
* @returns a provider value
|
|
109
31
|
*/
|
|
110
|
-
inject<T>(token: InjectionKey): T;
|
|
32
|
+
inject<T>(token: InjectionKey): T | undefined;
|
|
111
33
|
/**
|
|
112
34
|
* Register a plugin to be used by this app
|
|
113
35
|
* @param plugin the plugin to register
|
|
114
36
|
* @returns `this` App instance
|
|
115
37
|
*/
|
|
116
|
-
use(plugin: Plugin): this;
|
|
117
|
-
|
|
118
|
-
|
|
38
|
+
use<T>(plugin: Plugin<T>, options?: T): this;
|
|
39
|
+
constructor(root: ComponentConstructor<any, any>, options?: {
|
|
40
|
+
css?: string;
|
|
41
|
+
} | undefined);
|
|
119
42
|
/**
|
|
120
43
|
* Mount the App in a host element
|
|
121
44
|
* @param selector the host element where the app's root component should be mounted
|
|
122
45
|
*/
|
|
123
|
-
mount(selector: string): void
|
|
46
|
+
mount(selector: string): Promise<void>;
|
|
124
47
|
}
|
|
125
48
|
/**
|
|
126
49
|
* Provide a value through a key to all the app globally
|
|
@@ -133,23 +56,205 @@ declare function provide<T>(token: InjectionKey, value: T | (() => T)): void;
|
|
|
133
56
|
* @param token the key to look up globally
|
|
134
57
|
* @returns a provider value
|
|
135
58
|
*/
|
|
136
|
-
declare function inject<T>(token: InjectionKey): T;
|
|
59
|
+
declare function inject<T>(token: InjectionKey): T | undefined;
|
|
60
|
+
|
|
61
|
+
type QueryFilter = "children" | "classes" | "style" | "attributes";
|
|
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
|
+
}
|
|
101
|
+
export type NodeType = 'Element' | 'Text' | 'Comment' | 'Attribute' | 'Unknown';
|
|
102
|
+
type Attributes = {
|
|
103
|
+
name: string;
|
|
104
|
+
value: string;
|
|
105
|
+
}[];
|
|
106
|
+
export class OObject {
|
|
107
|
+
uid: string;
|
|
108
|
+
tag: string;
|
|
109
|
+
constructor(uid: string, tag: string);
|
|
110
|
+
addEventListener(event: string, callback: (...args: any[]) => void): Promise<string>;
|
|
111
|
+
dettachEventListener(event: string, cbId: string): Promise<void>;
|
|
112
|
+
invoke(fn: string, ...args: any[]): Promise<void>;
|
|
113
|
+
getProperty<T>(name: string): Promise<T | null>;
|
|
114
|
+
setProperty<T>(name: string, value: T): Promise<void>;
|
|
115
|
+
dispatchEvent(eventName: string, eventClass?: string, initDict?: any): Promise<void>;
|
|
116
|
+
}
|
|
117
|
+
export abstract class ONode extends OObject {
|
|
118
|
+
textContent?: string | null;
|
|
119
|
+
type: NodeType;
|
|
120
|
+
attributes: Attributes;
|
|
121
|
+
children?: ONode[];
|
|
122
|
+
classes?: string[];
|
|
123
|
+
style?: string;
|
|
124
|
+
constructor(node: ONode);
|
|
125
|
+
}
|
|
126
|
+
export class OElement extends ONode {
|
|
127
|
+
private _hydrated;
|
|
128
|
+
constructor(node: ONode);
|
|
129
|
+
addClass(...tokens: string[]): Promise<void>;
|
|
130
|
+
removeClass(...tokens: string[]): Promise<void>;
|
|
131
|
+
setAttribute(name: string, value: string): Promise<void>;
|
|
132
|
+
removeAttribute(name: string): Promise<void>;
|
|
133
|
+
appendChild(child: ONode): Promise<void>;
|
|
134
|
+
set innerHTML(value: string);
|
|
135
|
+
cloneNode(state: boolean): Promise<OElement | null>;
|
|
136
|
+
remove(): Promise<void>;
|
|
137
|
+
removeAndRelease(): Promise<void>;
|
|
138
|
+
removeChild(child: ONode): Promise<void>;
|
|
139
|
+
replaceChildNode(node: ONode, child: ONode): Promise<void>;
|
|
140
|
+
replaceWith(node: ONode): Promise<void>;
|
|
141
|
+
after(node: ONode): Promise<void>;
|
|
142
|
+
setHTML(html: string): Promise<void>;
|
|
143
|
+
HTML(): Promise<string>;
|
|
144
|
+
setInnerText(text: string): Promise<void>;
|
|
145
|
+
setContentText(text: string): Promise<void>;
|
|
146
|
+
getContentText(): Promise<string>;
|
|
147
|
+
content(): Promise<string>;
|
|
148
|
+
childNodes(): Promise<OElement[]>;
|
|
149
|
+
hasAttribute(name: string): boolean;
|
|
150
|
+
getAttribute(name: string): Promise<string>;
|
|
151
|
+
attribute(name: string): string | null;
|
|
152
|
+
nextSibling(): Promise<OElement | null>;
|
|
153
|
+
getAttributeNames(): Promise<string[]>;
|
|
154
|
+
parentNode(): Promise<OElement | null>;
|
|
155
|
+
insertBefore(element: ONode, node: ONode): Promise<void>;
|
|
156
|
+
setInputValue(value: string): Promise<void>;
|
|
157
|
+
inputValue(value: string): Promise<string>;
|
|
158
|
+
get hydrated(): boolean;
|
|
159
|
+
hydrate(): void;
|
|
160
|
+
query(selector: string, filter?: QueryFilter[]): Promise<OElement | null>;
|
|
161
|
+
queryAll(selector: string, filter?: QueryFilter[]): Promise<OElement[] | null>;
|
|
162
|
+
release(): Promise<void>;
|
|
163
|
+
setStyle(key: string, value: any): Promise<void>;
|
|
164
|
+
updates(): BatchUpdates;
|
|
165
|
+
}
|
|
166
|
+
export { };
|
|
167
|
+
}
|
|
168
|
+
declare function Native(): (clazz: any, fnName: string, descriptor: {
|
|
169
|
+
value: Function;
|
|
170
|
+
} | Record<string, any>) => void;
|
|
171
|
+
interface OUIDBridgeInterface {
|
|
172
|
+
invoke(name: string): Promise<any>;
|
|
173
|
+
emit(event: string, data: any): void;
|
|
174
|
+
subscribe(event: string, callback: (id: string, data: string) => void): void;
|
|
175
|
+
}
|
|
176
|
+
type OUIDConfig = {
|
|
177
|
+
appId: string;
|
|
178
|
+
appName: string;
|
|
179
|
+
appSecret: string;
|
|
180
|
+
};
|
|
181
|
+
declare var WebOUID: {
|
|
182
|
+
invoke: (id: string, name: string, argsJson: string) => void;
|
|
183
|
+
} | undefined;
|
|
184
|
+
type RequestData = {
|
|
185
|
+
method: string;
|
|
186
|
+
headers: Record<string, string>;
|
|
187
|
+
body: any;
|
|
188
|
+
credentials: "include" | "omit" | "same-origin";
|
|
189
|
+
};
|
|
190
|
+
declare class OUIDBridge implements OUIDBridgeInterface {
|
|
191
|
+
private callbacks;
|
|
192
|
+
private DOM_EVENT_LISTENERS;
|
|
193
|
+
private timers;
|
|
194
|
+
private _config?;
|
|
195
|
+
private listeners;
|
|
196
|
+
constructor();
|
|
197
|
+
config(conf?: OUIDConfig): OUIDBridge;
|
|
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;
|
|
201
|
+
/**
|
|
202
|
+
* Make a synchronous class
|
|
203
|
+
* @param name the name without '_oui' prefix
|
|
204
|
+
* @param args the arguments list
|
|
205
|
+
* @returns a promise of T
|
|
206
|
+
*/
|
|
207
|
+
call<T>(name: string, ...args: any[]): Promise<T | null>;
|
|
208
|
+
emit(event: string, data: any): void;
|
|
209
|
+
/**
|
|
210
|
+
*
|
|
211
|
+
* @param event Create a subscription for a given event name, should be possible to register only once ??
|
|
212
|
+
* @param callback
|
|
213
|
+
*/
|
|
214
|
+
subscribe(event: string, callback: (id: string, ...args: any[]) => void): void;
|
|
215
|
+
query(selector: string, filter?: QueryFilter[], nodeId?: string): Promise<ODOM.OElement | null>;
|
|
216
|
+
queryAll(selector: string, filter?: QueryFilter[], nodeId?: string): Promise<ODOM.OElement[] | null>;
|
|
217
|
+
createElement(tag: string, props?: Record<string, string>): Promise<ODOM.OElement | null>;
|
|
218
|
+
createComment(data: string): Promise<ODOM.OElement | null>;
|
|
219
|
+
addEventListener(node: ODOM.OObject | 'window' | 'document', event: string, callback: (...args: any[]) => void): Promise<string>;
|
|
220
|
+
dettachEventListener(node: ODOM.OObject | 'window' | 'document', event: string, cbId: string): Promise<void>;
|
|
221
|
+
injectComponentStyles(css: string): Promise<ODOM.OElement | null>;
|
|
222
|
+
rejectComponentStyles(cssNode: ODOM.ONode): Promise<void>;
|
|
223
|
+
getOObject(id: string): Promise<ODOM.OObject | null>;
|
|
224
|
+
acquireObject(name: string): Promise<ODOM.OObject | null>;
|
|
225
|
+
setTimeout(callback: () => void, delay: number): Promise<number>;
|
|
226
|
+
clearTimeout(id: number): Promise<void>;
|
|
227
|
+
setInterval(callback: () => void, delay: number): Promise<number>;
|
|
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>;
|
|
232
|
+
}
|
|
233
|
+
declare const OUID: OUIDBridge;
|
|
234
|
+
declare global {
|
|
235
|
+
var OUID: OUIDBridge;
|
|
236
|
+
}
|
|
137
237
|
|
|
138
238
|
declare class RenderContext {
|
|
139
239
|
private app;
|
|
140
|
-
component: OComponent
|
|
240
|
+
component: OComponent<Record<string, any>, Record<string, any>>;
|
|
141
241
|
private parentContext;
|
|
142
242
|
static PROVIDE_TOKEN: string;
|
|
243
|
+
static STYLE_REF: WeakMap<any, number>;
|
|
143
244
|
private bindings;
|
|
144
245
|
private directives;
|
|
145
246
|
private mountedComponents;
|
|
247
|
+
private componentsRegistry;
|
|
248
|
+
private updatingDirectives;
|
|
249
|
+
private updatingBindings;
|
|
146
250
|
stack: Record<string, any>[];
|
|
147
|
-
|
|
148
|
-
|
|
251
|
+
hydradationActions: ODOM.BatchActions;
|
|
252
|
+
constructor(app: App, component: OComponent<Record<string, any>, Record<string, any>>, parentContext: RenderContext | null, ...frames: Record<string, any>[]);
|
|
253
|
+
get hostElement(): ODOM.OElement;
|
|
149
254
|
bind(binding: Binding): void;
|
|
150
255
|
directive(directive: Directive): void;
|
|
151
|
-
evaluateExpression(expr: string): boolean;
|
|
152
|
-
resolve(key: string, strict?: boolean, ...additionFrames: Record<string, any>[]): any;
|
|
256
|
+
evaluateExpression(expr: string | null | undefined): boolean;
|
|
257
|
+
resolve(key: string | null | undefined, strict?: boolean, ...additionFrames: Record<string, any>[]): any;
|
|
153
258
|
/**
|
|
154
259
|
* Handing (o-model) like (ngModel) update, we should support mutliple syntaxe like o-mode="value" where value is defined directly on the component
|
|
155
260
|
* o-model="data['key']" where data is either defined on the component, of in the enclosing scope in case of for-loop for instance
|
|
@@ -157,54 +262,169 @@ declare class RenderContext {
|
|
|
157
262
|
updateValue(key: string, value: any): void;
|
|
158
263
|
push(frame: Record<string, any>): void;
|
|
159
264
|
pop(): void;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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>;
|
|
163
269
|
private render;
|
|
164
270
|
private expandClass;
|
|
165
271
|
private expandStyle;
|
|
166
272
|
private expandStandardAttributes;
|
|
167
|
-
handleElementNode(node:
|
|
168
|
-
|
|
273
|
+
handleElementNode(node: ODOM.OElement, options?: {
|
|
274
|
+
skipSlotted: boolean;
|
|
275
|
+
}): Promise<void>;
|
|
276
|
+
handleTextNode(node: ODOM.OElement): void;
|
|
169
277
|
private componentAttributes;
|
|
170
|
-
mountComponent<T, O
|
|
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, {
|
|
171
279
|
name: string;
|
|
172
280
|
value: any;
|
|
173
281
|
expr?: string;
|
|
174
282
|
}>, emits?: O): Promise<void>;
|
|
175
|
-
unmountComponent(node:
|
|
176
|
-
static h<P, O>(component: ComponentConstructor<P, O>, props: P, emits?: O): OComponent<P>;
|
|
177
|
-
static h<P, O>(component: OComponentType<P>, props: P, emits?: O): Promise<OComponent<P>>;
|
|
283
|
+
unmountComponent(node: ODOM.OElement): Promise<void>;
|
|
178
284
|
}
|
|
179
285
|
type Binding = {
|
|
180
286
|
type: 'model' | 'interpolation' | 'attribute' | 'prop';
|
|
181
|
-
node:
|
|
287
|
+
node: ODOM.OElement;
|
|
182
288
|
key: string;
|
|
183
289
|
template?: string | null;
|
|
184
290
|
context: RenderContext;
|
|
185
291
|
};
|
|
186
292
|
type Directive = {
|
|
187
293
|
type: 'if' | 'for';
|
|
188
|
-
node:
|
|
294
|
+
node: ODOM.OElement;
|
|
189
295
|
expr?: string;
|
|
190
|
-
placeholder:
|
|
296
|
+
placeholder: ODOM.OElement;
|
|
191
297
|
context: RenderContext;
|
|
192
298
|
active?: boolean;
|
|
299
|
+
renderedNode?: ODOM.OElement;
|
|
193
300
|
list?: string;
|
|
194
301
|
item?: string;
|
|
195
302
|
children?: Map<any, {
|
|
196
|
-
node:
|
|
303
|
+
node: ODOM.ONode;
|
|
197
304
|
ctx: RenderContext;
|
|
198
305
|
}>;
|
|
199
306
|
key?: string;
|
|
307
|
+
destroy?: boolean;
|
|
200
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>;
|
|
310
|
+
declare function o<P extends Record<string, any>, O extends Record<string, any>>(component: ComponentConstructor<P, O>, props: P, emits?: O): OComponent<P>;
|
|
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>>;
|
|
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>;
|
|
201
422
|
|
|
202
423
|
/**
|
|
203
424
|
* Component responsible for display routes
|
|
204
425
|
* Usage: <o-router></o-router>
|
|
205
426
|
*/
|
|
206
|
-
declare class
|
|
207
|
-
private routeStateHander;
|
|
427
|
+
declare class ORouter extends OComponent {
|
|
208
428
|
private router;
|
|
209
429
|
willMount(): void;
|
|
210
430
|
onMounted(): void;
|
|
@@ -213,12 +433,12 @@ declare class RouterComponent extends OComponent {
|
|
|
213
433
|
declare const ROUTER_INJECTION_TOKEN = "OROUTER_TOKEN";
|
|
214
434
|
declare const ACTIVE_ROUTE_TOKEN = "ACTIVE_ROUTE";
|
|
215
435
|
interface Route {
|
|
216
|
-
path
|
|
436
|
+
path: string;
|
|
217
437
|
name: string;
|
|
218
|
-
component?: OComponentType
|
|
438
|
+
component?: OComponentType<any, any>;
|
|
219
439
|
redirectTo?: string;
|
|
220
440
|
}
|
|
221
|
-
declare function useRouter(): Router;
|
|
441
|
+
declare function useRouter(): Router | undefined;
|
|
222
442
|
declare function createRouter(routes: Routes): Router;
|
|
223
443
|
type Routes = Array<Route>;
|
|
224
444
|
type MatchedRoute = {
|
|
@@ -244,24 +464,29 @@ interface RouteGuard {
|
|
|
244
464
|
type: 'before' | 'after';
|
|
245
465
|
fn: RouteGaurdFunction;
|
|
246
466
|
}
|
|
247
|
-
declare class Router implements Plugin {
|
|
467
|
+
declare class Router implements Plugin<any> {
|
|
248
468
|
routes: Routes;
|
|
469
|
+
private windowObject;
|
|
249
470
|
private guards;
|
|
471
|
+
private eventRegistration;
|
|
250
472
|
constructor(routes: Routes);
|
|
251
473
|
install(app: App): void;
|
|
252
|
-
resolve(path: string): MatchedRoute;
|
|
474
|
+
resolve(path: string): MatchedRoute | null;
|
|
253
475
|
push(options: {
|
|
254
476
|
name?: string;
|
|
255
477
|
path?: string;
|
|
256
478
|
params?: Record<string, string>;
|
|
257
479
|
absolute?: boolean;
|
|
258
480
|
}): void;
|
|
481
|
+
pop(): void;
|
|
259
482
|
private beforeRouteGoing;
|
|
260
483
|
private afterRouteGoing;
|
|
261
|
-
bind(component:
|
|
262
|
-
unbind(
|
|
484
|
+
bind(component: ORouter): Promise<(() => void)>;
|
|
485
|
+
unbind(): void;
|
|
263
486
|
beforeEach(fn: RouteGaurdFunction): (() => void);
|
|
264
487
|
afterEach(fn: RouteGaurdFunction): (() => void);
|
|
265
488
|
}
|
|
266
489
|
|
|
267
|
-
|
|
490
|
+
declare function components(): Record<string, OComponent<any, any>>;
|
|
491
|
+
|
|
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 };
|