ouider 0.0.8 → 0.1.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/dist/dom/dom.cjs +2 -2
- package/dist/dom/dom.cjs.map +1 -1
- package/dist/dom/dom.js +2 -2
- package/dist/dom/dom.js.map +1 -1
- package/dist/index.cjs +12 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +238 -19
- package/dist/index.d.ts +238 -19
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -70,13 +70,13 @@ declare namespace ODOM {
|
|
|
70
70
|
export class BatchUpdates {
|
|
71
71
|
private node;
|
|
72
72
|
private operations;
|
|
73
|
-
constructor(node:
|
|
73
|
+
constructor(node: OObject);
|
|
74
74
|
exec(): Promise<any>;
|
|
75
75
|
private append;
|
|
76
76
|
add(fn: () => void): this;
|
|
77
|
-
addEventListener(event: string, callback: (...args: any[]) => void): BatchUpdates;
|
|
77
|
+
addEventListener(event: string, callback: (...args: any[]) => void, options?: EventListenerOptions, policy?: EventControlPolicy): BatchUpdates;
|
|
78
78
|
setProperty(key: string, value: string): BatchUpdates;
|
|
79
|
-
dettachEventListener(
|
|
79
|
+
dettachEventListener(cbId: string): BatchUpdates;
|
|
80
80
|
invoke(fn: string, ...args: any[]): BatchUpdates;
|
|
81
81
|
dispatchEvent(eventName: string, eventClass?: string, initDict?: any): BatchUpdates;
|
|
82
82
|
addClass(...tokens: string[]): BatchUpdates;
|
|
@@ -91,7 +91,7 @@ declare namespace ODOM {
|
|
|
91
91
|
innerHTML(html: string): BatchUpdates;
|
|
92
92
|
replaceChildNode(node: ONode, child: ONode): BatchUpdates;
|
|
93
93
|
replaceWith(node: ONode): BatchUpdates;
|
|
94
|
-
after(
|
|
94
|
+
after(toInsert: ONode): BatchUpdates;
|
|
95
95
|
setInnerText(text: string): BatchUpdates;
|
|
96
96
|
setContentText(text: string): BatchUpdates;
|
|
97
97
|
insertBefore(element: ONode, node: ONode): BatchUpdates;
|
|
@@ -107,12 +107,22 @@ declare namespace ODOM {
|
|
|
107
107
|
uid: string;
|
|
108
108
|
tag: string;
|
|
109
109
|
constructor(uid: string, tag: string);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
release(): Promise<void>;
|
|
111
|
+
addEventListener(event: string, callback: (...args: any[]) => void, extra?: {
|
|
112
|
+
options?: EventListenerOptions;
|
|
113
|
+
policy?: EventControlPolicy;
|
|
114
|
+
}): Promise<string>;
|
|
115
|
+
dettachEventListener(cbId: string): Promise<void>;
|
|
116
|
+
invoke<T>(fn: string, ...args: any[]): Promise<T | null>;
|
|
117
|
+
invokeAndHold(fn: string, ...args: any[]): Promise<OObject | null>;
|
|
113
118
|
getProperty<T>(name: string): Promise<T | null>;
|
|
114
119
|
setProperty<T>(name: string, value: T): Promise<void>;
|
|
115
120
|
dispatchEvent(eventName: string, eventClass?: string, initDict?: any): Promise<void>;
|
|
121
|
+
updates(): BatchUpdates;
|
|
122
|
+
batches(): BatchUpdates;
|
|
123
|
+
get ref(): {
|
|
124
|
+
__ref__: string;
|
|
125
|
+
};
|
|
116
126
|
}
|
|
117
127
|
export abstract class ONode extends OObject {
|
|
118
128
|
textContent?: string | null;
|
|
@@ -124,6 +134,7 @@ declare namespace ODOM {
|
|
|
124
134
|
constructor(node: ONode);
|
|
125
135
|
}
|
|
126
136
|
export class OElement extends ONode {
|
|
137
|
+
[x: string]: any;
|
|
127
138
|
private _hydrated;
|
|
128
139
|
constructor(node: ONode);
|
|
129
140
|
addClass(...tokens: string[]): Promise<void>;
|
|
@@ -138,7 +149,7 @@ declare namespace ODOM {
|
|
|
138
149
|
removeChild(child: ONode): Promise<void>;
|
|
139
150
|
replaceChildNode(node: ONode, child: ONode): Promise<void>;
|
|
140
151
|
replaceWith(node: ONode): Promise<void>;
|
|
141
|
-
after(
|
|
152
|
+
after(toInsert: ONode): Promise<void>;
|
|
142
153
|
setHTML(html: string): Promise<void>;
|
|
143
154
|
HTML(): Promise<string>;
|
|
144
155
|
setInnerText(text: string): Promise<void>;
|
|
@@ -154,20 +165,214 @@ declare namespace ODOM {
|
|
|
154
165
|
parentNode(): Promise<OElement | null>;
|
|
155
166
|
insertBefore(element: ONode, node: ONode): Promise<void>;
|
|
156
167
|
setInputValue(value: string): Promise<void>;
|
|
157
|
-
inputValue(
|
|
168
|
+
inputValue(): Promise<string>;
|
|
158
169
|
get hydrated(): boolean;
|
|
159
170
|
hydrate(): void;
|
|
160
171
|
query(selector: string, filter?: QueryFilter[]): Promise<OElement | null>;
|
|
161
172
|
queryAll(selector: string, filter?: QueryFilter[]): Promise<OElement[] | null>;
|
|
162
|
-
release(): Promise<void>;
|
|
163
173
|
setStyle(key: string, value: any): Promise<void>;
|
|
164
|
-
|
|
174
|
+
}
|
|
175
|
+
export class CanvasGradient extends OObject {
|
|
176
|
+
constructor(obj: OObject);
|
|
177
|
+
addColorStop(offset: number, color: string): this;
|
|
178
|
+
}
|
|
179
|
+
export class DOMMatrix extends OObject {
|
|
180
|
+
batch: BatchUpdates;
|
|
181
|
+
constructor(obj: OObject);
|
|
182
|
+
static new(): Promise<DOMMatrix>;
|
|
183
|
+
static new(initString: string): Promise<DOMMatrix>;
|
|
184
|
+
static new(initArray: number[]): Promise<DOMMatrix>;
|
|
185
|
+
invertSelf(): this;
|
|
186
|
+
multiplySelf(): DOMMatrix;
|
|
187
|
+
premultiplySelf(): DOMMatrix;
|
|
188
|
+
rotateAxisAngleSelf(rotX?: number, rotY?: number, rotZ?: number, angle?: number): this;
|
|
189
|
+
rotateFromVectorSelf(rotX?: number, rotY?: number): this;
|
|
190
|
+
rotateSelf(rotX?: number, rotY?: number, rotZ?: number): this;
|
|
191
|
+
scale3dSelf(scale?: number, originX?: number, originY?: number, originZ?: number): this;
|
|
192
|
+
scaleSelf(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): this;
|
|
193
|
+
setMatrixValue(transformList: string): this;
|
|
194
|
+
skewXSelf(sX: number): this;
|
|
195
|
+
skewYSelf(sX: number): this;
|
|
196
|
+
translateSelf(translateX: number, translateY: number, translateZ?: number): this;
|
|
197
|
+
commit(): Promise<void>;
|
|
198
|
+
is2D(): Promise<boolean>;
|
|
199
|
+
isIdentity(): Promise<boolean>;
|
|
200
|
+
flipX(): Promise<DOMMatrix | null>;
|
|
201
|
+
flipY(): Promise<DOMMatrix | null>;
|
|
202
|
+
inverse(): Promise<DOMMatrix | null>;
|
|
203
|
+
multiply(other?: DOMMatrix): Promise<DOMMatrix | null>;
|
|
204
|
+
rotate(rotX?: number, rotY?: number, rotZ?: number): Promise<DOMMatrix | null>;
|
|
205
|
+
rotateAxisAngle(rotX?: number, rotY?: number, rotZ?: number, angle?: number): Promise<DOMMatrix | null>;
|
|
206
|
+
rotateFromVector(rotX?: number, rotY?: number): Promise<DOMMatrix | null>;
|
|
207
|
+
scale(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): Promise<DOMMatrix | null>;
|
|
208
|
+
scale3d(scale?: number, originX?: number, originY?: number, originZ?: number): Promise<DOMMatrix | null>;
|
|
209
|
+
skewX(sX?: number): Promise<DOMMatrix | null>;
|
|
210
|
+
skewY(sY?: number): Promise<DOMMatrix | null>;
|
|
211
|
+
toJSON(): Promise<any>;
|
|
212
|
+
toString(): Promise<string | null>;
|
|
213
|
+
translate(translateX?: number, translateY?: number, translateZ?: number): Promise<DOMMatrix | null>;
|
|
214
|
+
}
|
|
215
|
+
export class CanvasPattern extends OObject {
|
|
216
|
+
constructor(obj: OObject);
|
|
217
|
+
setTransform(matrix: DOMMatrix): void;
|
|
218
|
+
}
|
|
219
|
+
export class Canvas2DContext extends OObject {
|
|
220
|
+
private batch;
|
|
221
|
+
constructor(uid: string);
|
|
222
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): this;
|
|
223
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this;
|
|
224
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): this;
|
|
225
|
+
clearRect(x: number, y: number, width: number, height: number): this;
|
|
226
|
+
clip(path?: CanvasPath2D): Canvas2DContext;
|
|
227
|
+
clip(fillRule?: 'nonzero' | 'evenodd'): Canvas2DContext;
|
|
228
|
+
clip(path: CanvasPath2D, fillRule?: 'nonzero' | 'evenodd'): Canvas2DContext;
|
|
229
|
+
beginPath(): this;
|
|
230
|
+
closePath(): this;
|
|
231
|
+
createConicGradient(startAngle: number, x: number, y: number): Promise<CanvasGradient | null>;
|
|
232
|
+
createLinearGradient(x0: number, y0: number, x1: number, y1: number): Promise<CanvasGradient | null>;
|
|
233
|
+
createPattern(image: OObject, repetition?: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat' | ''): Promise<CanvasPattern | null>;
|
|
234
|
+
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): Promise<CanvasGradient | null>;
|
|
235
|
+
drawImage(image: Image | OObject, dx: number, dy: number): Canvas2DContext;
|
|
236
|
+
drawImage(image: Image | OObject, dx: number, dy: number, dWidth: number, dHeight: number): Canvas2DContext;
|
|
237
|
+
drawImage(image: Image | OObject, sx: number, sy: number, sWidth: number, sHeight: number, dx: number, dy: number, dWidth: number, dHeight: number): Canvas2DContext;
|
|
238
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): this;
|
|
239
|
+
fill(path?: CanvasPath2D | 'nonzero' | 'evenodd', fillRule?: 'nonzero' | 'evenodd'): this;
|
|
240
|
+
fillRect(x: number, y: number, width: number, height: number): this;
|
|
241
|
+
fillText(text: string, x: number, y: number, maxWidth?: number): this;
|
|
242
|
+
getImageData(sx: number, sy: number, sw: number, sh: number, settings?: {
|
|
243
|
+
colorSpace: 'srgb' | 'display-p3';
|
|
244
|
+
pixelFormat: 'rgba-unorm8' | 'rgba-float16';
|
|
245
|
+
}): Promise<OObject | null>;
|
|
246
|
+
getLineDash(): Promise<number[] | null>;
|
|
247
|
+
getTransform(): Promise<DOMMatrix | null>;
|
|
248
|
+
isContextLost(): Promise<boolean | null>;
|
|
249
|
+
isPointInPath(x: number, y: number, fillRule?: 'nonzero' | 'evenodd'): Promise<boolean>;
|
|
250
|
+
isPointInPath(path: CanvasPath2D, x: number, y: number, fillRule?: 'nonzero' | 'evenodd'): Promise<boolean>;
|
|
251
|
+
isPointInStroke(x: number, y: number): Promise<boolean>;
|
|
252
|
+
isPointInStroke(path: CanvasPath2D, x: number, y: number): Promise<boolean>;
|
|
253
|
+
lineTo(x: number, y: number): Canvas2DContext;
|
|
254
|
+
measureText(text: number): Promise<number>;
|
|
255
|
+
moveTo(x: number, y: number): Canvas2DContext;
|
|
256
|
+
putImageData(imageData: OObject, dx: number, dy: number): Canvas2DContext;
|
|
257
|
+
putImageData(imageData: OObject, dx: number, dy: number, dirtyX: number, dirtyY: number, dirtyWidth: number, dirtyHeight: number): Canvas2DContext;
|
|
258
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): this;
|
|
259
|
+
rect(x: number, y: number, width: number, height: number): this;
|
|
260
|
+
reset(): void;
|
|
261
|
+
resetTransform(): void;
|
|
262
|
+
restore(): Promise<void | null>;
|
|
263
|
+
rotate(angle: number): Canvas2DContext;
|
|
264
|
+
roundRect(x: number, y: number, width: number, height: number, radii: number | number[]): this;
|
|
265
|
+
save(): Promise<void | null>;
|
|
266
|
+
scale(x: number, y: number): Canvas2DContext;
|
|
267
|
+
setLineDash(segments: number[]): Promise<void | null>;
|
|
268
|
+
setTransform(matrix: DOMMatrix): Promise<void>;
|
|
269
|
+
setTransform(a: number, b: number, c: number, d: number, e: number, f: number): Promise<void>;
|
|
270
|
+
stroke(path?: CanvasPath2D): Canvas2DContext;
|
|
271
|
+
strokeRect(x: number, y: number, width: number, height: number): Canvas2DContext;
|
|
272
|
+
strokeText(text: string, x: number, y: number, maxWidth?: number): Canvas2DContext;
|
|
273
|
+
transform(a: number, b: number, c: number, d: number, e: number, f: number): Canvas2DContext;
|
|
274
|
+
translate(x: number, y: number): Canvas2DContext;
|
|
275
|
+
set fillStyle(value: string | CanvasGradient | CanvasPattern);
|
|
276
|
+
setFillStyle(style: string | CanvasGradient | CanvasPattern): Promise<Canvas2DContext>;
|
|
277
|
+
set filter(value: string);
|
|
278
|
+
setFilter(filter: string): Promise<this>;
|
|
279
|
+
set font(value: string);
|
|
280
|
+
setFont(font: string): Promise<this>;
|
|
281
|
+
set fontKerning(value: string);
|
|
282
|
+
setFontKerning(kerning: string): Promise<this>;
|
|
283
|
+
set fontStretch(value: string);
|
|
284
|
+
setFontStretch(value: string): Promise<this>;
|
|
285
|
+
set fontVariantCaps(value: string);
|
|
286
|
+
setFontVariantCaps(value: string): Promise<this>;
|
|
287
|
+
set globalAlpha(value: number);
|
|
288
|
+
setGlobalAlpha(value: number): Promise<this>;
|
|
289
|
+
set globalCompositeOperation(value: string);
|
|
290
|
+
setGlobalCompositeOperation(value: string): Promise<this>;
|
|
291
|
+
set imageSmoothingEnabled(value: boolean);
|
|
292
|
+
setImageSmoothingEnabled(value: boolean): Promise<this>;
|
|
293
|
+
set imageSmoothingQuality(value: string);
|
|
294
|
+
setImageSmoothingQuality(value: string): Promise<this>;
|
|
295
|
+
set letterSpacing(value: string);
|
|
296
|
+
setLetterSpacing(value: string): Promise<this>;
|
|
297
|
+
set lineCap(value: string);
|
|
298
|
+
setLineCap(value: string): Promise<this>;
|
|
299
|
+
set lineDashOffset(value: number);
|
|
300
|
+
setLineDashOffset(value: number): Promise<this>;
|
|
301
|
+
set lineJoin(value: string);
|
|
302
|
+
setLineJoin(value: string): Promise<this>;
|
|
303
|
+
set lineWidth(value: number);
|
|
304
|
+
setLineWidth(value: number): Promise<this>;
|
|
305
|
+
set miterLimit(value: number);
|
|
306
|
+
setMiterLimit(value: number): Promise<this>;
|
|
307
|
+
set shadowBlur(value: number);
|
|
308
|
+
setShadowBlur(value: number): Promise<this>;
|
|
309
|
+
set shadowColor(value: string);
|
|
310
|
+
setShadowColor(value: string): Promise<this>;
|
|
311
|
+
set shadowOffsetX(value: number);
|
|
312
|
+
setShadowOffsetX(value: number): Promise<this>;
|
|
313
|
+
set shadowOffsetY(value: number);
|
|
314
|
+
setShadowOffsetY(value: number): Promise<this>;
|
|
315
|
+
set strokeStyle(value: any);
|
|
316
|
+
setStrokeStyle(value: any): Promise<this>;
|
|
317
|
+
set textAlign(value: string);
|
|
318
|
+
setTextAlign(value: string): Promise<this>;
|
|
319
|
+
set textBaseline(value: string);
|
|
320
|
+
setTextBaseline(value: string): Promise<this>;
|
|
321
|
+
set wordSpacing(value: string);
|
|
322
|
+
setWordSpacing(value: string): Promise<this>;
|
|
323
|
+
set textRendering(value: string);
|
|
324
|
+
setTextRendering(value: string): Promise<this>;
|
|
325
|
+
commit(): Promise<void>;
|
|
326
|
+
}
|
|
327
|
+
export class Image extends OObject {
|
|
328
|
+
constructor(obj: OObject);
|
|
329
|
+
static new(width?: number, height?: number): Promise<Image | null>;
|
|
330
|
+
width(): Promise<number>;
|
|
331
|
+
height(): Promise<number>;
|
|
332
|
+
naturalWidth(): Promise<number>;
|
|
333
|
+
naturalHeight(): Promise<number>;
|
|
334
|
+
src(): Promise<string | null>;
|
|
335
|
+
currentSrc(): Promise<string | null>;
|
|
336
|
+
setSrc(src: string): Promise<void>;
|
|
337
|
+
}
|
|
338
|
+
export class CanvasPath2D extends OObject {
|
|
339
|
+
private batch;
|
|
340
|
+
constructor(obj: OObject);
|
|
341
|
+
static create(): Promise<CanvasPath2D | null>;
|
|
342
|
+
addPath(path: CanvasPath2D): this;
|
|
343
|
+
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): this;
|
|
344
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this;
|
|
345
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): this;
|
|
346
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): this;
|
|
347
|
+
closePath(): this;
|
|
348
|
+
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): this;
|
|
349
|
+
moveTo(x: number, y: number): this;
|
|
350
|
+
lineTo(x: number, y: number): this;
|
|
351
|
+
rect(x: number, y: number, width: number, height: number): this;
|
|
352
|
+
roundRect(x: number, y: number, width: number, height: number, radii: number | number[]): this;
|
|
353
|
+
commit(): Promise<void>;
|
|
354
|
+
}
|
|
355
|
+
export class CanvasElement extends OElement {
|
|
356
|
+
constructor(node: OElement);
|
|
357
|
+
width(): Promise<number | null>;
|
|
358
|
+
height(): Promise<number | null>;
|
|
359
|
+
setWidth(width: number): Promise<void>;
|
|
360
|
+
setHeight(height: number): Promise<void>;
|
|
361
|
+
getContext(context: string): Promise<Canvas2DContext | null>;
|
|
362
|
+
static of(selector: string, filter?: QueryFilter[], nodeId?: string): Promise<CanvasElement | null>;
|
|
165
363
|
}
|
|
166
364
|
export { };
|
|
167
365
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
366
|
+
interface EventListenerOptions {
|
|
367
|
+
once?: boolean;
|
|
368
|
+
passive?: boolean;
|
|
369
|
+
capture?: boolean;
|
|
370
|
+
}
|
|
371
|
+
interface EventControlPolicy {
|
|
372
|
+
alwaysPreventDefault?: boolean;
|
|
373
|
+
alwaysStopPropagation?: boolean;
|
|
374
|
+
alwaysStopImmediatePropagation?: boolean;
|
|
375
|
+
}
|
|
171
376
|
interface OUIDBridgeInterface {
|
|
172
377
|
invoke(name: string): Promise<any>;
|
|
173
378
|
emit(event: string, data: any): void;
|
|
@@ -216,8 +421,11 @@ declare class OUIDBridge implements OUIDBridgeInterface {
|
|
|
216
421
|
queryAll(selector: string, filter?: QueryFilter[], nodeId?: string): Promise<ODOM.OElement[] | null>;
|
|
217
422
|
createElement(tag: string, props?: Record<string, string>): Promise<ODOM.OElement | null>;
|
|
218
423
|
createComment(data: string): Promise<ODOM.OElement | null>;
|
|
219
|
-
addEventListener(node: ODOM.OObject | 'window' | 'document', event: string, callback: (...args: any[]) => void
|
|
220
|
-
|
|
424
|
+
addEventListener(node: ODOM.OObject | 'window' | 'document', event: string, callback: (...args: any[]) => void, extra?: {
|
|
425
|
+
options?: EventListenerOptions;
|
|
426
|
+
policy?: EventControlPolicy;
|
|
427
|
+
}): Promise<string>;
|
|
428
|
+
dettachEventListener(cbId: string): Promise<void>;
|
|
221
429
|
injectComponentStyles(css: string): Promise<ODOM.OElement | null>;
|
|
222
430
|
rejectComponentStyles(cssNode: ODOM.ONode): Promise<void>;
|
|
223
431
|
getOObject(id: string): Promise<ODOM.OObject | null>;
|
|
@@ -231,6 +439,7 @@ declare class OUIDBridge implements OUIDBridgeInterface {
|
|
|
231
439
|
fetch(url: string, input: RequestData, encodeAs: "base64"): Promise<string>;
|
|
232
440
|
alert(message: string): Promise<void>;
|
|
233
441
|
prompt(message: string): Promise<void>;
|
|
442
|
+
newObject(ctr: string, ...args: any[]): Promise<ODOM.OObject | null>;
|
|
234
443
|
}
|
|
235
444
|
declare const OUID: OUIDBridge & Record<string, (...args: any[]) => Promise<any>>;
|
|
236
445
|
declare global {
|
|
@@ -259,6 +468,7 @@ declare class RenderContext {
|
|
|
259
468
|
get hostElement(): ODOM.OElement;
|
|
260
469
|
get stack(): Record<string, any>[];
|
|
261
470
|
set stack(value: Record<string, any>[]);
|
|
471
|
+
getMountedComponent(node: ODOM.OElement): OComponent | undefined;
|
|
262
472
|
bind(binding: Binding): void;
|
|
263
473
|
directive(directive: Directive): void;
|
|
264
474
|
evaluateExpression(expr: string | null | undefined): boolean;
|
|
@@ -287,7 +497,7 @@ declare class RenderContext {
|
|
|
287
497
|
name: string;
|
|
288
498
|
value: any;
|
|
289
499
|
expr?: string;
|
|
290
|
-
}>, emits?: O): Promise<
|
|
500
|
+
}>, emits?: O): Promise<OComponent>;
|
|
291
501
|
unmountComponent(node: ODOM.OElement): Promise<void>;
|
|
292
502
|
}
|
|
293
503
|
type Binding = {
|
|
@@ -409,6 +619,8 @@ interface Component<P extends Record<string, any>, O extends Record<string, any>
|
|
|
409
619
|
state: State<any>;
|
|
410
620
|
readonly emits: Emits<O>;
|
|
411
621
|
readonly props: ComponentProps<P>;
|
|
622
|
+
onActivated(): void;
|
|
623
|
+
onDeactivated(): void;
|
|
412
624
|
onMounted(): void;
|
|
413
625
|
willMount(): void;
|
|
414
626
|
willUnmount(): void;
|
|
@@ -429,6 +641,8 @@ declare class OComponent<P extends Record<string, any> = {}, O extends Record<st
|
|
|
429
641
|
readonly props: ComponentProps<P>;
|
|
430
642
|
private provides;
|
|
431
643
|
constructor(props?: P, emits?: O);
|
|
644
|
+
onActivated(): void;
|
|
645
|
+
onDeactivated(): void;
|
|
432
646
|
onMounted(): void;
|
|
433
647
|
willMount(): void;
|
|
434
648
|
willUnmount(): void;
|
|
@@ -494,9 +708,14 @@ declare class Router implements Plugin<any> {
|
|
|
494
708
|
private windowObject;
|
|
495
709
|
private guards;
|
|
496
710
|
private eventRegistration;
|
|
711
|
+
private compiled;
|
|
712
|
+
private outletEl;
|
|
713
|
+
private keepAlive;
|
|
714
|
+
private keepAliveLimit;
|
|
715
|
+
private pendingNav;
|
|
497
716
|
constructor(routes: Routes);
|
|
498
717
|
install(app: App): void;
|
|
499
|
-
resolve(
|
|
718
|
+
resolve(url: string): MatchedRoute | null;
|
|
500
719
|
push(options: {
|
|
501
720
|
name?: string;
|
|
502
721
|
path?: string;
|
|
@@ -519,4 +738,4 @@ declare class OIcon extends OComponent {
|
|
|
519
738
|
|
|
520
739
|
declare function components(): Record<string, OComponent<any, any>>;
|
|
521
740
|
|
|
522
|
-
export { ACTIVE_ROUTE_TOKEN, App, type Binding, Component, type ComponentConstructor, type ComponentProps, type Directive, Emits, type InjectionKey, type LazyLoader,
|
|
741
|
+
export { ACTIVE_ROUTE_TOKEN, App, type Binding, Component, type ComponentConstructor, type ComponentProps, type Directive, Emits, type EventControlPolicy, type EventListenerOptions, type InjectionKey, type LazyLoader, OComponent, type OComponentType, ODOM, OIcon, 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, deferMacro, deferMicro, inject, isStated, node, o, provide, stated, useRouter };
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
`:"";for(let
|
|
3
|
-
`:n instanceof
|
|
1
|
+
import At from'route-parser';var yt=Object.defineProperty;var Rt=(o,e,s)=>e in o?yt(o,e,{enumerable:true,configurable:true,writable:true,value:s}):o[e]=s;var f=(o,e)=>yt(o,"name",{value:e,configurable:true});var p=(o,e,s)=>Rt(o,typeof e!="symbol"?e+"":e,s);var nt=class nt{constructor(){p(this,"components",new Map);}register(e,s){console.log(`[OUID] - Registering component: ${e}`);let n=e.toLocaleLowerCase();this.components.has(n)||this.components.set(n,s);}unregister(e){let s=e.toLocaleLowerCase();this.components.delete(s);}get(e){return this.components.get(e.toLocaleLowerCase())}has(e){return this.components.has(e)}getAll(){return Array.from(this.components.entries())}};f(nt,"ComponentsRegistry");var G=nt,U=new G;var it=class it{constructor(e){p(this,"events");this.events=e;}emit(e,...s){let n=this.events[e];n&&n(...s);}};f(it,"Emits");var X=it;var rt=class rt{constructor(e){p(this,"value");this.value=e;}};f(rt,"Stated");var K=rt;function vt(o){return typeof o=="object"&&!Array.isArray(o)&&"value"in o&&o instanceof K}f(vt,"isStated");function jt(o,e){let s=f((n,r=new Map)=>{if(r.has(n))return r.get(n);let c=new Proxy(n,{set:f((u,w,m)=>{let O=u[w];return typeof m=="object"?u[w]=s(m):u[w]=m,e.didChange(w,O,m),true},"set"),get:f((u,w)=>Reflect.get(u,w),"get")});r.set(n,c);for(let u=n;u;u=Object.getPrototypeOf(u))Object.keys(u).forEach(w=>{let m=n[w];typeof m=="object"&&(n[w]=s(m,r));});return c},"proxify");if(typeof o=="function")throw new Error("Can't create reactive element over a function");return typeof o!="object"&&typeof o!="symbol"?new Proxy(new K(o),{set:f((n,r,c)=>{if(r!=="value")throw new Error(`Undefined property ${String(r)} access`);let u=n[r];return n[r]=c,e.didChange(r,u,c),true},"set"),get:f((n,r)=>{if(r!=="value")throw new Error(`Undefined property ${String(r)} access`);return n[r]},"get")}):new K(s(o))}f(jt,"stated");var at=class at{constructor(e){p(this,"THRESHOLD_TIME",20);p(this,"debounceTime",new Date().getTime());p(this,"state");p(this,"listeners",[]);p(this,"timer",null);this.state=new Proxy(e,{set:f((s,n,r)=>{let c=s[n];return s[n]=r,this.didChange(n,c,r),true},"set"),get:f((s,n)=>s[n],"get")});}wrap(e){return jt(e,this)}has(e){return e in this.state}setValue(e,s){this.state[e]=s;}getValue(e){return this.state[e]}get value(){return this.state}dispatchChanges(e,s,n){for(let r of this.listeners)r(e,s,n);}async didChange(e,s,n){let r=Date.now();r-this.debounceTime<=this.THRESHOLD_TIME&&this.timer&&clearTimeout(this.timer),this.debounceTime=r,this.timer=setTimeout(()=>{this.dispatchChanges(e,s,n);},this.THRESHOLD_TIME);}watch(e){return this.listeners.push(e),this.listeners.length-1}unwatch(e){if(typeof e=="number"){this.listeners.splice(e,1);return}this.listeners.splice(this.listeners.indexOf(e),1);}};f(at,"State");var Z=at;var Dt=0;function gt(o){return function(e){var r;let s=(r=class extends e{constructor(){super(...arguments);p(this,"template",o.template);p(this,"css",o.css);p(this,"tag",o.tag);p(this,"use",o.use);p(this,"hostClasses",o.hostClasses);p(this,"hash","component-"+Dt+"-"+o.tag);}},f(r,"WithDecoration"),r),n=s;return n.tag=o.tag,s}}f(gt,"Component");var et=class et{constructor(e,s=[]){p(this,"node");p(this,"children");this.node=e,this.children=s;}attachTo(e){if(typeof this.node=="string"){e.innerHTML=this.node;return}let s=this.node;for(let n of this.children)n.attachTo(s);e.appendChild(s);}static of(e,s=[]){return new et(e,s)}addChild(e){return this.children.push(e),this}};f(et,"RenderNode");var F=et,J=class J{constructor(e,s){p(this,"data");p(this,"css");this.data=e,this.css=s;}toString(){let e=this.css?this.css+`
|
|
2
|
+
`:"";for(let s in this.data){let n=this.data[s];typeof n=="string"?e+=`${s} { ${n} }
|
|
3
|
+
`:n instanceof J&&(e+=`${s} {
|
|
4
4
|
${n.toString()}}
|
|
5
|
-
`);}return
|
|
6
|
-
`))}};u(I,"StyleData");var B=I;function Y(i,t,e){return new i(t,e)}u(Y,"createComponent");var J=class J{constructor(t={},e={}){l(this,"state");l(this,"parent");l(this,"emits");l(this,"props");l(this,"provides",new Map);this.state=new U(this),this.props=t,this.emits=new P(e);}onMounted(){}willMount(){}willUnmount(){}provide(t,e){this.provides.set(t,e);}inject(t){let e=this;for(;e;){if(e.provides.has(t))return e.provides.get(t);e=e.parent;}}decorateHostElement(t){return Promise.resolve()}};u(J,"OComponent");var _=J;function N(i){let t=Date.now();return `${(1e3+Math.floor(Math.random()*9e3)+i.length).toString(16)}-${t.toString(16)}`}u(N,"generateUIID");(function(i){var c,p,h,y,v;let t=(c=class{constructor(){l(this,"actions",[]);}async exec(){await this.commit();}add(a){return this.actions.push(a),this}async commit(){let a=this.actions;this.actions=[],await Promise.all(a.map(async r=>await r()));}},u(c,"BatchActions"),c);i.BatchActions=t;let e=(p=class{constructor(a){l(this,"node");l(this,"operations",[]);this.node=a;}async exec(){let a=this.operations.map(r=>typeof r=="object"?this.node[r.fn].apply(this.node,r.args):Promise.resolve(r()));try{await Promise.all(a);}catch{console.error("Error while batch updates");}}append(a,...r){return this.operations.push({fn:a,args:r}),this}add(a){return this.operations.push(a),this}addEventListener(a,r){return this.append("addEventListener",a,r)}setProperty(a,r){return this.append("setAttribute",a,r)}dettachEventListener(a,r){return this.append("dettachEventListener",a,r)}invoke(a,...r){return this.append("invoke",a,...r)}dispatchEvent(a,r,d){return this.append("dispatchEvent",a,r,d)}addClass(...a){return this.append("addClass",...a)}removeClass(...a){return this.append("removeClass",...a)}setAttribute(a,r){return this.append("setAttribute",a,r)}removeAttribute(a){return this.append("removeAttribute",a)}appendChild(a){return this.append("appendChild",a)}removeChild(a){return this.append("removeChild",a)}remove(){return this.append("remove")}removeAndRelease(){return this.append("removeAndRelease")}release(){return this.append("release")}innerHTML(a){return this.append("setHTML",a)}replaceChildNode(a,r){return this.append("replaceChildNode",a,r)}replaceWith(a){return this.append("replaceWith",a)}after(a){return this.append("after",a)}setInnerText(a){return this.append("setInnerText",a)}setContentText(a){return this.append("setContentText",a)}insertBefore(a,r){return this.append("insertBefore",a,r)}setInputValue(a){return this.append("setInputValue",a)}setStyle(a,r){return this.append("setStyle",a,r)}},u(p,"BatchUpdates"),p);i.BatchUpdates=e;let n=(h=class{constructor(a,r){l(this,"uid");l(this,"tag");this.uid=a,this.tag=r;}async addEventListener(a,r){return f.addEventListener(this,a,r)}async dettachEventListener(a,r){await f.dettachEventListener(this,a,r);}async invoke(a,...r){await f.call("invokeObjectMethod",this.uid,a,...r);}async getProperty(a){return await f.call("getObjectProperty",this.uid,a)}async setProperty(a,r){await f.call("setObjectProperty",this.uid,a,r);}async dispatchEvent(a,r,d){await f.call("dispatchEvent",this.uid,a,r,d);}},u(h,"OObject"),h);i.OObject=n;let s=(y=class extends n{constructor(r){super(r.uid,r.tag);l(this,"textContent");l(this,"type","Unknown");l(this,"attributes");l(this,"children");l(this,"classes");l(this,"style");for(let d in r)this[d]=r[d];this.attributes??(this.attributes=[]),this.classes??(this.classes=[]),this.style??(this.style="");}},u(y,"ONode"),y);i.ONode=s;let o=(v=class extends s{constructor(r){super(r);l(this,"_hydrated",false);}async addClass(...r){await f.call("addClass",this.uid,...r);}async removeClass(...r){await f.call("removeClass",this.uid,...r);}async setAttribute(r,d){let w=await f.call("setAttribute",this.uid,r,d);w&&(this.attributes=w);}async removeAttribute(r){let d=await f.call("removeAttribute",this.uid,r);d&&(this.attributes=d);}async appendChild(r){await f.call("appendChild",this.uid,r.uid);}set innerHTML(r){this.setHTML(r);}async cloneNode(r){let d=await f.call("cloneNode",this.uid,r);return d?new v(d):null}async remove(){await f.call("removeNode",this.uid);}async removeAndRelease(){await this.remove(),await this.release();}async removeChild(r){await f.call("removeChild",this.uid,r.uid);}async replaceChildNode(r,d){await f.call("removeChild",this.uid,r.uid,d.uid);}async replaceWith(r){await f.call("replaceWith",this.uid,r.uid);}async after(r){await f.call("insertAfter",this.uid,r.uid);}async setHTML(r){await f.call("setInnerHTML",this.uid,r);}async HTML(){return await f.call("getInnerHTML",this.uid)??""}async setInnerText(r){await f.call("setInnerText",this.uid,r);}async setContentText(r){await f.call("setContentText",this.uid,r);}async getContentText(){return await f.call("getContentText",this.uid)??""}async content(){try{return await f.call("getInnerText",this.uid)??""}catch(r){return console.error(r),""}}async childNodes(){return (await f.call("childNodes",this.uid))?.map(r=>new v(r))??[]}hasAttribute(r){return !!this.attributes.find(d=>d.name===r)}async getAttribute(r){return await f.call("getAttribte",this.uid,r)??""}attribute(r){return this.attributes.find(d=>d.name===r)?.value??null}async nextSibling(){let r=await f.call("nextSibling",this.uid);return r?new v(r):null}async getAttributeNames(){return await f.call("getAttributeNames",this.uid)??[]}async parentNode(){let r=await f.call("parentNode",this.uid);return r?new v(r):null}async insertBefore(r,d){await f.call("insertBefore",this.uid,d.uid,r.uid);}async setInputValue(r){await f.call("setInputValue",this.uid,r);}async inputValue(r){return await f.call("inputValue",this.uid,r)??""}get hydrated(){return this._hydrated}hydrate(){this._hydrated=true,this.addClass("hydrated");}async query(r,d){return await f.query(r,d,this.uid)}async queryAll(r,d){return await f.queryAll(r,d,this.uid)}async release(){await f.call("releaseNode",this.uid);}async setStyle(r,d){await f.call("setStyle",this.uid,r,d);}updates(){return new e(this)}},u(v,"OElement"),v);i.OElement=o;})(g||(g={}));function qt(){return function(i,t,e){e.value;e.value=async(...s)=>{let o=s[0];try{let c=await f.invoke(t,[{props:o.getSafePropsForNative}]);o.setSafePropsFromNative;}catch{console.error("Failed to invoke native function");}};}}u(qt,"Native");var z=class z{constructor(){l(this,"callbacks",new Map);l(this,"DOM_EVENT_LISTENERS",new Map);l(this,"timers",new Map);l(this,"_config");l(this,"listeners",new Map);this.subscribe("__ouid_native_event_success__",(t,e)=>{let n=this.callbacks.get(t);if(n)return this.callbacks.delete(t),n.success(...JSON.parse(e))}),this.subscribe("__ouid_native_event_error__",(t,e)=>{let n=this.callbacks.get(t);if(n)return this.callbacks.delete(t),n.error(...JSON.parse(e))}),this.subscribe("__ouid_web_event__",(t,e)=>{let n=this.DOM_EVENT_LISTENERS.get(t);if(n){let o=JSON.parse(e)[1];return o&&(o.target=o?.target?new g.OElement(o.target):null),n(o)}});}config(t){return this._config=t,this}invoke(t,...e){let n=N(t);return new Promise((s,o)=>{this.callbacks.set(n,{success:s,error:o});try{if(!WebOUID)throw new Error("NativeOUID bridge not available");WebOUID.invoke(n,t,JSON.stringify(e));}catch(c){console.error(c),this.callbacks.delete(n);}})}registerComponent(t,e){T.register(t,e);}unregisterComponent(t,e){T.unregister(t);}async call(t,...e){try{return (await this.invoke(`_ouid_${t}`,...e)).data}catch(n){return console.error(n),null}}emit(t,e){WebOUID?.invoke("event",t,JSON.stringify(e));}subscribe(t,e){this.listeners.has(t)||(this.listeners.set(t,[]),globalThis[t]=(n,s)=>{this.listeners.get(t)?.forEach(o=>o(n,s));}),this.listeners.get(t).push(e);}async query(t,e,n){let s=await this.call("query",t,e,n);return s?new g.OElement(s):null}async queryAll(t,e,n){let s=await this.call("queryAll",t,e,n);return s?s.map(o=>new g.OElement(o)):[]}async createElement(t,e={}){let n=await this.call("createElement",t,e);return n?new g.OElement(n):null}async createComment(t){let e=await this.call("createComment",t);return e?new g.OElement(e):null}async addEventListener(t,e,n){let s=N(e+(typeof t=="string"?t:t.tag));return this.DOM_EVENT_LISTENERS.set(s,n),await f.call("attachEventListener",typeof t=="string"?t:t.uid,s,e),s}async dettachEventListener(t,e,n){this.DOM_EVENT_LISTENERS.delete(n),await f.call("dettachEventListener",typeof t=="string"?t:t.uid,n,e);}async injectComponentStyles(t){let e=await f.call("injectComponentStyles",t);return e?new g.OElement(e):null}async rejectComponentStyles(t){await f.call("rejectComponentStyles",t.uid);}async getOObject(t){let e=await f.call("getOObject",t);return e?new g.OObject(e.uid,e.tag):null}async acquireObject(t){let e=await f.call("acquireObject",t);return e?new g.OObject(e.uid,e.tag):null}async setTimeout(t,e){let n=N("setTimeout"+e);this.DOM_EVENT_LISTENERS.set(n,()=>{t();let o=this.timers.get(s);o&&(this.timers.delete(s),this.DOM_EVENT_LISTENERS.delete(o));});let s=await f.call("setTimeout",n,e)??-1;return s>=0&&this.timers.set(s,n),s}async clearTimeout(t){let e=this.timers.get(t);e&&(this.timers.delete(t),this.DOM_EVENT_LISTENERS.delete(e),await f.call("clearTimeout",t));}async setInterval(t,e){let n=N("setInterval"+e);this.DOM_EVENT_LISTENERS.set(n,t);let s=await f.call("setInterval",n,e)??-1;return s>=0&&this.timers.set(s,n),s}async clearInterval(t){let e=this.timers.get(t);e&&(this.timers.delete(t),this.DOM_EVENT_LISTENERS.delete(e),await f.call("clearInterval",t));}async fetch(t,e,n="json"){return await f.call("fetch",t,e,n)}async alert(t){await f.call("alert",t);}async prompt(t){await f.call("prompt",t);}};u(z,"OUIDBridge");var K=z,f=new Proxy(new K,{get:u((i,t)=>t in i?i[t]:async(...e)=>await i.call(t,...e),"get")});globalThis.OUID=f;var g;function vt(i){return i.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}u(vt,"toCamelCase");function gt(i){return i.replace(/(?!^)([A-Z])/g,(t,e)=>`-${e.toLowerCase()}`)}u(gt,"toSnakeCase");function C(i){return st(i)?i.value:i}u(C,"normaliseValue");var bt=typeof globalThis.queueMicrotask=="function",R=u(i=>i?bt?queueMicrotask(i):Promise.resolve().then(i):Promise.resolve(),"deferMicro"),zt=u(()=>new Promise(i=>setTimeout(i,0)),"deferMacro");function Et(i){return typeof i=="function"&&!("prototype"in i)}u(Et,"isLazyLoader");var it=new Map,at=new Map,ot=new WeakMap;function ct(i){if(!i||typeof i!="object"&&typeof i!="function")return {};let t=ot.get(i);if(t)return t;let e=Object.create(null);for(let n=i;n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let s of Object.getOwnPropertyNames(n)){if(s==="constructor"||s.startsWith("__")||s.endsWith("__")||s in e)continue;let o=Object.getOwnPropertyDescriptor(n,s);if(!o)continue;let c=o.value??(o.get?o.get.call(i):void 0);e[s]=typeof c=="function"?c.bind(i):c;}return ot.set(i,e),e}u(ct,"getMethodsView");function lt(i,t){let e=it.get(i);return e||(e=new Function("s","with (s) { return ("+i+"); }"),it.set(i,e)),e(t)}u(lt,"evalInScope");function xt(i){let t=at.get(i);if(t)return t;let e=[],n=0;for(;n<i.length;){let s=i.indexOf("{{",n);if(s<0){e.push({t:i.slice(n)});break}s>n&&e.push({t:i.slice(n,s)});let o=i.indexOf("}}",s+2),c=o>=0?i.slice(s+2,o).trim():i.slice(s+2).trim();e.push({e:c}),n=o>=0?o+2:i.length;}return t=u(s=>{let o="";for(let c of e)if(c.t!==void 0)o+=c.t;else if(c.e!==void 0){let p=lt(c.e,s);o+=p==null?"":String(p);}return o},"fn"),at.set(i,t),t}u(xt,"compileInterpolated");var O=class O{constructor(t,e,n,...s){l(this,"app");l(this,"component");l(this,"parentContext");l(this,"bindings",[]);l(this,"directives",[]);l(this,"mountedComponents",new WeakMap);l(this,"componentsRegistry",new k);l(this,"updatingDirectives",false);l(this,"updatingBindings",false);l(this,"_stack",[]);l(this,"flatStack",Object.create(null));l(this,"hydradationActions",new g.BatchActions);this.app=t,this.component=e,this.parentContext=n;for(let o of s)this.push(o);}get hostElement(){return this.component._hostElement}get stack(){return this._stack}set stack(t){this.flatStack=Object.create(null),this._stack=[];for(let e of t)this.push(e);}bind(t){this.bindings.push(t);}directive(t){this.directives.push(t);}evaluateExpression(t){return this.resolve(t)}resolve(t,e=true,...n){if(!t)return;let s=this.component.state?.value??{},o=ct(s),c=new Proxy(Object.create(null),{get:u((p,h)=>{for(let y=n.length-1;y>=0;y--)if(h in n[y])return n[y][h];return h in this.flatStack?this.flatStack[h]:h in o?o[h]:s[h]},"get"),has:u((p,h)=>n.some(y=>h in y)||h in this.flatStack||h in o||h in s,"has")});try{return lt(t,c)}catch{return}}updateValue(t,e){let n=t.split(/[\.\[]/)[0];n in this.component?this.resolve(`${t}=__o_model_value__`,true,{__o_model_value__:e}):this.resolve(`${t}=__o_model_value__`,true,{__o_model_value__:e}),this.component.state.didChange(n,void 0,e);}push(t){this._stack.unshift(t),Object.assign(this.flatStack,t);}pop(){let t=this._stack.shift();if(t)for(let e of Object.keys(t))delete this.flatStack[e];}resolveTag(t){let e=this;for(;;){if(e.componentsRegistry.has(t))return e.componentsRegistry.get(t);if(e=e?.parentContext??null,!e)break}return T.get(t)}async updateBindings(t){if(this.updatingBindings)return;let e=!t;t=t??new g.BatchActions,this.updatingBindings=true;for(let n of this.bindings)this.updateBinding(n,t);this.updatingBindings=false,e&&await t.commit();}updateBinding(t,e){if(t.type==="model"){t.node.setProperty("value",C(t.context.resolve(t.key)));return}if(t.type==="interpolation"){e.add(async()=>{let n=t.templateFn({...this.flatStack,...ct(this.component.state?.value??{}),...this.component.state?.value??{}});await t.node.setContentText(n);});return}if(t.type==="attribute"){let n=t.key,s=C(this.resolve(t.template));n==="class"?e.add(()=>this.expandClass(t.node,s)):n==="style"?this.expandStyle(t.node,s):typeof s!="object"&&typeof s!="function"&&typeof s!="symbol"&&typeof s<"u"&&e.add(()=>t.node.setAttribute(n,s.toString()));return}if(t.type==="prop"&&t.context.component){let n=C(this.resolve(t.template));try{t.context.component.props[t.key]=n,t.context.updateBindings(),t.context.updateDirectives();}catch(s){console.error(s);}return}}async updateDirectives(t){if(this.updatingDirectives)return;let e=!t;this.updatingDirectives=true,t=t??new g.BatchActions;for(let n of this.directives){if(n.type==="if"){if(!C(n.context.evaluateExpression(n.expr))){if(n.active===false)continue;n.active=false,n.renderedNode&&(n.destroy?(this.unmountComponent(n.node),await n.renderedNode.removeAndRelease()):await n.renderedNode.addClass("oui-hidden"));continue}if(n.active===true)continue;n.active=true;let o=n.renderedNode;if(!o||n.destroy){let c=await n.node.cloneNode(true);n.renderedNode=c,await n.context.render(c),await n.placeholder.after(c),await n.context.hydradationActions.commit();}else await o.removeClass("oui-hidden");}if(n.type==="for"){let s=n.children??new Map,o=new Map,c=u((r,d)=>n.key?C(n.context.resolve(n.key,true,{[n.item]:r})):d,"keyFn"),p=C(n.context.resolve(n.list))||[],h=new g.BatchActions,y=32,v=0,m=[],a=n.placeholder;for(let r=0;r<p.length;r++){let d=p[r],w=c(d,r),b=s.get(w),x,E,D=a;b?(x=b.node,E=b.ctx,E.stack=[{[n.item]:d},...n.context.stack],h.add(async()=>{let et=await a.nextSibling();x.uid!==et?.uid&&h.add(()=>D.after(x));}),await Promise.all([E.updateBindings(t),E.updateDirectives(t)])):(E=new O(this.app,this.component,this),E.hydradationActions=this.hydradationActions,E.stack=[{[n.item]:d},...n.context.stack],x=await n.node.cloneNode(true),h.add(async()=>{await D.after(x);}),m.push(async()=>{await E.render(x),await E.updateDirectives(t);})),a=x,o.set(w,{node:x,ctx:E}),++v>=y&&(v=0,await h.commit(),await R());}for(let[r,d]of s.entries())o.has(r)||(this.unmountComponent(d.node),h.add(()=>d.node.removeAndRelease()));if(await h.commit(),m.length)for(let d=0;d<m.length;d+=12){let w=m.slice(d,d+12).map(b=>b());await Promise.all(w),await R();}n.children=o;}}e&&await t.commit(),await this.hydradationActions.commit(),this.updatingDirectives=false;}async render(t,e){if(t.hydrated||e?.skipSlotted&&t.hasAttribute("slotted"))return;switch(t.type){case "Text":this.handleTextNode(t);break;case "Element":await this.handleElementNode(t,e);break;}let n=new g.BatchActions;await Promise.all([this.updateBindings(n),this.updateDirectives(n)]),n.commit(),this.hydradationActions.add(()=>t.hydrate());}async expandClass(t,e){let n;typeof e=="object"?Array.isArray(e)?n=e:n=Object.keys(e).filter(s=>e[s]):n=e.toString().split(/\s+/),n.length>0&&await t.addClass(...n);}expandStyle(t,e){let n=e;typeof e=="object"&&!Array.isArray(e)&&(n=Object.keys(e).filter(s=>e[s]).map(s=>`${gt(s)}: ${e[s]}`).join(";")),n&&t.setAttribute("style",n);}expandStandardAttributes(t){let e=t.updates();[...t.attributes].filter(n=>n.name.startsWith(":")).forEach(n=>{let s=n.name.substring(1);this.bind({type:"attribute",node:t,key:s,context:this,template:n.value.trim()}),e.removeAttribute(n.name);}),e.exec();}async handleElementNode(t,e){let n=await t.parentNode(),s=null,o=t.hasAttribute("o-if")?"o-if":t.hasAttribute("o-show")?"o-show":null;if(o){let d=await t.getAttribute(o),w=await OUID.createComment(o+":"+d),b=o==="o-if";await n.insertBefore(w,t),await t.updates().removeAttribute(o).remove().exec(),this.directive({type:"if",expr:d,node:t,placeholder:w,context:this,active:void 0,destroy:b}),s="if";return}if(t.hasAttribute("o-for")){if(s==="if")throw new Error("Can't have o-if and o-for on the same component");let d=await t.getAttribute("o-for"),[w,b]=d.split(" of ").map(D=>D.trim()),x=await OUID.createComment("for:"+d),E=t.attribute(":key")??"";await n?.insertBefore(x,t),await t.updates().removeAttribute("o-for").removeAttribute(":key").remove().exec(),this.directive({type:"for",item:w,list:b,node:t,placeholder:x,context:this,key:E}),s="for";return}let c=t.tag.toLowerCase(),p=this.resolveTag(c),h=t.updates();[...t.attributes].forEach(async d=>{if(d.name==="o-model"){let w=d.value.trim(),b="input";t.tag==="selection"&&(b="change"),h.setInputValue(C(this.resolve(w))).addEventListener(b,async x=>{let E=await x.target.getProperty("value");this.updateValue(w,E);}),this.bind({node:t,key:w,type:"model",context:this}),h.removeAttribute(d.name);}});let y={},v={},{props:m,events:a}=this.componentAttributes(t,this);if(y=m,v=a,this.expandStandardAttributes(t),Object.keys(v).forEach(async d=>{let w=v[d];p||h.addEventListener(d,b=>{typeof w=="function"&&w.apply(this.component,[b]);}),h.removeAttribute("@"+d);}),await h.exec(),p){await this.mountComponent(t,p,this,y,v);return}let r=await t.childNodes();e?.skipSlotted&&(r=r.filter(d=>!d.hasAttribute("slotted")));for(let d of r)await this.render(d,e);}handleTextNode(t){let e=t.textContent??"";e.includes("{{")&&this.bind({type:"interpolation",node:t,key:"__template__",templateFn:xt(e),context:this});}componentAttributes(t,e){let n={},s={},o=["import","interface","module","o-model","o-if","o-for"];return [...t.attributes].filter(c=>!o.includes(c.name)).forEach(c=>{let p=c.name;if(p.startsWith("@")){let v=e?.resolve(c.value,true);if(typeof v!="function")throw new Error("Event handler can only be function");p=p.substring(1),s[p]=v;return}let h=null,y=c.value;p.startsWith(":")&&(h=c.value,p=p.substring(1),y=C(e?.resolve(c.value))),p=vt(p),n[p]={name:p,value:y,expr:h};}),{props:n,events:s}}async mountComponent(t,e,n,s={},o={}){if(this.mountedComponents.has(t))return;let c=new O(this.app,{},this),p={};for(let m of Object.keys(s)){let a=s[m];a.expr&&this.bind({type:"prop",node:t,key:m,context:c,template:a.expr}),p[m]=a.value;}let h=await Ot(e,p,o);c.component=h,c.stack=[],this.mountedComponents.set(t,h);{let m=t.updates();for(let r of Object.keys(s))s[r].expr||m.setAttribute(r,s[r].value);let a=h.hostClasses??[];a&&(a=typeof a=="string"?[a]:a),a.push("o-component-host"),t.tag.toLowerCase()!=="div"&&a.push("c-"+t.tag.toLowerCase()),m.addClass(...a),await m.exec();}R(async()=>{try{await h.decorateHostElement(t);}catch{}});{let m=h.use??{};for(let a of Object.keys(m))c.componentsRegistry.register(a,m[a]);}if(h.willMount(),!e.cssInstance){let m=h.style?h.style()?.toString():h.css;m&&(e.cssInstance??(e.cssInstance=await OUID.injectComponentStyles(m)));}R(()=>{let m=e.cssInstance;if(m){let a=O.STYLE_REF.get(m)??0;O.STYLE_REF.set(m,a+1),h.cssInstance=m;}});let y=await t.childNodes();if(h.render){let m=await h.render(c);m&&m.attachTo(t);}else await t.setHTML(h.template.trim());let v=await t.queryAll("slot");v&&v.length&&await Promise.all(v.filter(m=>!m.classes?.includes("hydrated")).map(async m=>{let a=m.attribute("name"),r=y.filter(w=>a?w.type==="Element"&&w.attribute("slot")===a:w.type!=="Element"||!w.hasAttribute("slot"));if(!r.length)return;let d=new g.BatchActions;for(let w of r)d.add(()=>w.setAttribute("slotted","true")),d.add(()=>m.appendChild(w));await d.commit(),await Promise.all(r.map(w=>this.render(w)));})),h._hostElement=t,h.parent=n?.component??void 0,h.provide(O.PROVIDE_TOKEN,this);{let m=await t.childNodes(),a=6,r=0;for(;r<m.length;){let d=m.slice(r,r+a);await Promise.all(d.map(w=>c.render(w,{skipSlotted:true}))),r+=a;}await c.hydradationActions.commit();}R(()=>{try{h.onMounted();}catch{}}),h.state.watch(()=>{let m=new g.BatchActions;c.updateBindings(m),c.updateDirectives(m),m.commit();});}async unmountComponent(t){let e=this.mountedComponents.get(t);if(e){let s=e.cssInstance;if(s){let o=O.STYLE_REF.get(s)??1;o===1?(await OUID.rejectComponentStyles(s),O.STYLE_REF.delete(s)):O.STYLE_REF.set(s,o-1);}e.willUnmount(),e._hostElement=null,e.cssInstance=null;}let n=await t.queryAll("*")??[];for(let s of n)await this.unmountComponent(s);this.mountedComponents.delete(t);}};u(O,"RenderContext"),l(O,"PROVIDE_TOKEN","RENDER_CONTEXT"),l(O,"STYLE_REF",new WeakMap);var A=O;async function Gt(i,t,e=[],n){let s=t??{},o=await OUID.createElement(i,Object.keys(s).reduce((c,p)=>(c[p]=s[p],c),{}));return Object.keys(n??{}).forEach(c=>{o?.addEventListener(c,p=>{let h=n[c];typeof h=="function"&&h(p);});}),new S(o,e)}u(Gt,"node");function Ot(i,t,e){return Et(i)?i().then(n=>Y(n.default,t,e)):Y(i,t,e)}u(Ot,"o");function Ct(i){return typeof i=="function"}u(Ct,"isProvideFunction");var L=class L{constructor(t,e){l(this,"root");l(this,"options");l(this,"providers",new Map);this.root=t,this.options=e,L.currentApp=this;}provide(t,e){if(this.providers.has(t)){console.warn(`[OUID] - Provider ${t} already exists`);return}this.providers.set(t,Ct(e)?{provide:e}:{value:e});}inject(t){return this.providers.get(t)?.value}use(t,e){return t.install(this,e),this}async mount(t){if(!globalThis.__OUI_PUR_JS_CONTEXT__)return;this.options?.css&&await OUID.injectComponentStyles(this.options.css),await OUID.injectComponentStyles(`
|
|
5
|
+
`);}return e}static of(e,...s){return new J(e,s.join(`
|
|
6
|
+
`))}};f(J,"StyleData");var tt=J;function ot(o,e,s){return new o(e,s)}f(ot,"createComponent");var ct=class ct{constructor(e={},s={}){p(this,"state");p(this,"parent");p(this,"emits");p(this,"props");p(this,"provides",new Map);this.state=new Z(this),this.props=e,this.emits=new X(s);}onActivated(){}onDeactivated(){}onMounted(){}willMount(){}willUnmount(){}provide(e,s){this.provides.set(e,s);}inject(e){let s=this;for(;s;){if(s.provides.has(e))return s.provides.get(e);s=s.parent;}}decorateHostElement(e){return Promise.resolve()}};f(ct,"OComponent");var W=ct;function z(o){let e=Date.now();return `${(1e3+Math.floor(Math.random()*9e3)+o.length).toString(16)}-${e.toString(16)}`}f(z,"generateUIID");(function(o){var b,v,k,S,E,A,T,D,B,_,M,H;let e=(b=class{constructor(){p(this,"actions",[]);}async exec(){await this.commit();}add(l){return this.actions.push(l),this}async commit(){let l=this.actions;this.actions=[],await Promise.all(l.map(async t=>await t()));}},f(b,"BatchActions"),b);o.BatchActions=e;let s=(v=class{constructor(l){p(this,"node");p(this,"operations",[]);this.node=l;}async exec(){let l=this.operations;this.operations=[];let t=l.map(i=>typeof i=="object"?this.node[i.fn].apply(this.node,i.args):Promise.resolve(i()));try{await Promise.all(t);}catch{console.error("Error while batch updates");}}append(l,...t){return this.operations.push({fn:l,args:t}),this}add(l){return this.operations.push(l),this}addEventListener(l,t,i,a){return this.append("addEventListener",l,t,{options:i,policy:a})}setProperty(l,t){return this.append("setAttribute",l,t)}dettachEventListener(l){return this.append("dettachEventListener",l)}invoke(l,...t){return this.append("invoke",l,...t)}dispatchEvent(l,t,i){return this.append("dispatchEvent",l,t,i)}addClass(...l){return this.append("addClass",...l)}removeClass(...l){return this.append("removeClass",...l)}setAttribute(l,t){return this.append("setAttribute",l,t)}removeAttribute(l){return this.append("removeAttribute",l)}appendChild(l){return this.append("appendChild",l)}removeChild(l){return this.append("removeChild",l)}remove(){return this.append("remove")}removeAndRelease(){return this.append("removeAndRelease")}release(){return this.append("release")}innerHTML(l){return this.append("setHTML",l)}replaceChildNode(l,t){return this.append("replaceChildNode",l,t)}replaceWith(l){return this.append("replaceWith",l)}after(l){return this.append("after",l)}setInnerText(l){return this.append("setInnerText",l)}setContentText(l){return this.append("setContentText",l)}insertBefore(l,t){return this.append("insertBefore",l,t)}setInputValue(l){return this.append("setInputValue",l)}setStyle(l,t){return this.append("setStyle",l,t)}},f(v,"BatchUpdates"),v);o.BatchUpdates=s;let n=(k=class{constructor(l,t){p(this,"uid");p(this,"tag");this.uid=l,this.tag=t;}async release(){await y.call("releaseNode",this.uid);}async addEventListener(l,t,i){return y.addEventListener(this,l,t,{options:i?.options,policy:i?.policy})}async dettachEventListener(l){await y.dettachEventListener(l);}async invoke(l,...t){return await y.call("invokeObjectMethod",this.uid,l,...t)}async invokeAndHold(l,...t){let i=await y.call("invokeObjectMethodAndHold",this.uid,l,...t);return i&&new k(i.uid,i.tag)}async getProperty(l){return await y.call("getObjectProperty",this.uid,l)}async setProperty(l,t){await y.call("setObjectProperty",this.uid,l,t);}async dispatchEvent(l,t,i){await y.call("dispatchEvent",this.uid,l,t,i);}updates(){return new s(this)}batches(){return new s(this)}get ref(){return {__ref__:this.uid}}},f(k,"OObject"),k);o.OObject=n;let r=(S=class extends n{constructor(t){super(t.uid,t.tag);p(this,"textContent");p(this,"type","Unknown");p(this,"attributes");p(this,"children");p(this,"classes");p(this,"style");for(let i in t)this[i]=t[i];this.attributes??(this.attributes=[]),this.classes??(this.classes=[]),this.style??(this.style="");}},f(S,"ONode"),S);o.ONode=r;let c=(E=class extends r{constructor(t){super(t);p(this,"_hydrated",false);}async addClass(...t){await y.call("addClass",this.uid,...t);}async removeClass(...t){await y.call("removeClass",this.uid,...t);}async setAttribute(t,i){let a=await y.call("setAttribute",this.uid,t,i);a&&(this.attributes=a);}async removeAttribute(t){let i=await y.call("removeAttribute",this.uid,t);i&&(this.attributes=i);}async appendChild(t){await y.call("appendChild",this.uid,t.uid);}set innerHTML(t){this.setHTML(t);}async cloneNode(t){let i=await y.call("cloneNode",this.uid,t);return i?new E(i):null}async remove(){await y.call("removeNode",this.uid);}async removeAndRelease(){await this.remove(),await this.release();}async removeChild(t){await y.call("removeChild",this.uid,t.uid);}async replaceChildNode(t,i){await y.call("replaceChildNode",this.uid,t.uid,i.uid);}async replaceWith(t){await y.call("replaceWith",this.uid,t.uid);}async after(t){await y.call("insertAfter",this.uid,t.uid);}async setHTML(t){await y.call("setInnerHTML",this.uid,t);}async HTML(){return await y.call("getInnerHTML",this.uid)??""}async setInnerText(t){await y.call("setInnerText",this.uid,t);}async setContentText(t){await y.call("setContentText",this.uid,t);}async getContentText(){return await y.call("getContentText",this.uid)??""}async content(){try{return await y.call("getInnerText",this.uid)??""}catch(t){return console.error(t),""}}async childNodes(){return (await y.call("childNodes",this.uid))?.map(t=>new E(t))??[]}hasAttribute(t){return !!this.attributes.find(i=>i.name===t)}async getAttribute(t){return await y.call("getAttribte",this.uid,t)??""}attribute(t){return this.attributes.find(i=>i.name===t)?.value??null}async nextSibling(){let t=await y.call("nextSibling",this.uid);return t?new E(t):null}async getAttributeNames(){return await y.call("getAttributeNames",this.uid)??[]}async parentNode(){let t=await y.call("parentNode",this.uid);return t?new E(t):null}async insertBefore(t,i){await y.call("insertBefore",this.uid,i.uid,t.uid);}async setInputValue(t){await y.call("setInputValue",this.uid,t);}async inputValue(){return await y.call("inputValue",this.uid)??""}get hydrated(){return this._hydrated}hydrate(){this._hydrated=true,this.addClass("hydrated");}async query(t,i){return await y.query(t,i,this.uid)}async queryAll(t,i){return await y.queryAll(t,i,this.uid)}async setStyle(t,i){await y.call("setStyle",this.uid,t,i);}},f(E,"OElement"),E);o.OElement=c;let u=(A=class extends n{constructor(l){super(l.uid,l.tag);}addColorStop(l,t){return this.invoke("addColorStop",l,t),this}},f(A,"CanvasGradient"),A);o.CanvasGradient=u;let w=(T=class extends n{constructor(t){super(t.uid,t.tag);p(this,"batch",new s(this));}static async new(t){let i=typeof t<"u"?await y.newObject("DOMMatrix",t):await y.newObject("DOMMatrix");return i?new T(i):null}invertSelf(){return this.batch.invoke("invertSelf"),this}multiplySelf(t){return this.batch.invoke("multiplySelf",...t?[t.ref]:[]),this}premultiplySelf(t){return this.batch.invoke("premultiplySelf",...t?[t.ref]:[]),this}rotateAxisAngleSelf(t,i,a,h){let d=[];return t&&d.push(t),i&&d.push(i),a&&d.push(a),h&&d.push(h),this.batch.invoke("rotateAxisAngleSelf",...d),this}rotateFromVectorSelf(t,i){let a=[];return t&&a.push(t),i&&a.push(i),this.batch.invoke("rotateFromVectorSelf",...a),this}rotateSelf(t,i,a){let h=[];return t&&h.push(t),i&&h.push(i),a&&h.push(a),this.batch.invoke("rotateFromVectorSelf",...h),this}scale3dSelf(t,i,a,h){let d=[];return t&&d.push(t),i&&d.push(i),a&&d.push(a),h&&d.push(h),this.batch.invoke("scale3dSelf",...d),this}scaleSelf(t,i,a,h,d,C){let P=[];return t&&P.push(t),i&&P.push(i),a&&P.push(a),h&&P.push(h),d&&P.push(d),C&&P.push(C),this.batch.invoke("scaleSelf",...P),this}setMatrixValue(t){return this.invoke("setMatrixValue",t),this}skewXSelf(t){return this.batch.invoke("skewXSelf",t),this}skewYSelf(t){return this.batch.invoke("skewYSelf",t),this}translateSelf(t,i,a){return this.batch.invoke("translateSelf",t,i,...a?[a]:[]),this}async commit(){await this.batch.exec();}async is2D(){return await this.invoke("is2D")??false}async isIdentity(){return await this.invoke("isIdentity")??false}async flipX(){let t=await this.invokeAndHold("flipX");return t?new T(t):null}async flipY(){let t=await this.invokeAndHold("flipY");return t?new T(t):null}async inverse(){let t=await this.invokeAndHold("inverse");return t?new T(t):null}async multiply(t){let i=await this.invokeAndHold("multiply",...t?[t.ref]:[]);return i?new T(i):null}async rotate(t,i,a){let h=[];t&&h.push(t),i&&h.push(i),a&&h.push(a);let d=await this.invokeAndHold("rotate",...h);return d?new T(d):null}async rotateAxisAngle(t,i,a,h){let d=[];t&&d.push(t),i&&d.push(i),a&&d.push(a),h&&d.push(h);let C=await this.invokeAndHold("rotateAxisAngle",...d);return C?new T(C):null}async rotateFromVector(t,i){let a=[];t&&a.push(t),i&&a.push(i);let h=await this.invokeAndHold("rotateFromVector",...a);return h?new T(h):null}async scale(t,i,a,h,d,C){let P=[];t&&P.push(t),i&&P.push(i),a&&P.push(a),h&&P.push(h),d&&P.push(d),C&&P.push(C);let R=await this.invokeAndHold("scale",...P);return R?new T(R):null}async scale3d(t,i,a,h){let d=[];t&&d.push(t),i&&d.push(i),a&&d.push(a),h&&d.push(h);let C=await this.invokeAndHold("scale",...d);return C?new T(C):null}async skewX(t){let i=[];t&&i.push(t);let a=await this.invokeAndHold("skewX",...i);return a?new T(a):null}async skewY(t){let i=[];t&&i.push(t);let a=await this.invokeAndHold("skewY",...i);return a?new T(a):null}toJSON(){return this.invoke("toJSON")}async toString(){return this.invoke("toString")}async translate(t,i,a){let h=[];t&&h.push(t),i&&h.push(i),a&&h.push(a);let d=await this.invokeAndHold("translate",...h);return d?new T(d):null}},f(T,"DOMMatrix"),T);o.DOMMatrix=w;let m=(D=class extends n{constructor(l){super(l.uid,l.tag);}setTransform(l){this.invoke("setTransform",l.ref);}},f(D,"CanvasPattern"),D);o.CanvasPattern=m;let O=(B=class extends n{constructor(t){super(t,"unknown");p(this,"batch",new s(this));}arc(t,i,a,h,d,C=false){return this.batch.invoke("arc",t,i,a,h,d,C),this}arcTo(t,i,a,h,d){return this.batch.invoke("arcTo",t,i,a,h,d),this}bezierCurveTo(t,i,a,h,d,C){return this.batch.invoke("bezierCurveTo",t,i,a,h,d,C),this}clearRect(t,i,a,h){return this.batch.invoke("clearRect",t,i,a,h),this}clip(t,i){let a=[];return typeof t=="string"?a.push(t):t instanceof g&&(t.commit(),a.push(t.ref)),typeof i=="string"&&a.push(i),this.batch.invoke("clip",...a),this}beginPath(){return this.batch.invoke("beginPath"),this}closePath(){return this.batch.invoke("closePath"),this}async createConicGradient(t,i,a){let h=await this.invokeAndHold("createConicGradient",t,i,a);return h?new u(h):null}async createLinearGradient(t,i,a,h){let d=await this.invokeAndHold("createLinearGradient",t,i,a,h);return d?new u(d):null}async createPattern(t,i=""){let a=await this.invokeAndHold("createPattern",t.ref,i);return a?new m(a):null}async createRadialGradient(t,i,a,h,d,C){let P=await this.invokeAndHold("createRadialGradient",t,i,a,h,d,C);return P?new u(P):null}drawImage(t,i,a,h,d,C,P,R,Lt){let q=[t.ref];return typeof C>"u"?(q.push(i,a),h&&q.push(h),d&&q.push(d),this.batch.invoke("drawImage",...q),this):(q.push(i,a,h,d,C,P,R,Lt),this.batch.invoke("drawImage",...q),this)}ellipse(t,i,a,h,d,C,P,R=false){return this.batch.invoke("ellipse",t,i,a,h,d,C,P,R),this}fill(t,i){let a=[];return t&&a.push(typeof t=="string"?t:(t.commit(),t.ref)),i&&a.push(i),this.batch.invoke("fill",...a),this}fillRect(t,i,a,h){return this.batch.invoke("fillRect",t,i,a,h),this}fillText(t,i,a,h){return this.batch.invoke("fillText",t,i,a,...h?[h]:[]),this}getImageData(t,i,a,h,d){return this.invokeAndHold("getImageData",t,i,a,h,...d?[d]:[])}getLineDash(){return this.invoke("getLineDash")}async getTransform(){let t=await this.invokeAndHold("getTransform");return t?new w(t):null}async isContextLost(){return await this.invoke("isContextLost")}async isPointInPath(t,i,a,h){let d=[];return typeof t=="number"?(d.push(t,i),a&&d.push(a)):(t.commit(),d.push(t.ref,i,a,h??"nonzero")),await this.invoke("isPointInPath",...d)??false}async isPointInStroke(t,i,a){let h=[];return typeof t=="number"?h.push(t,i):(t.commit(),h.push(t.ref,i,a)),await this.invoke("isPointInStroke",...h)??false}lineTo(t,i){return this.batch.invoke("lineTo",t,i),this}async measureText(t){return await this.invoke("measureText",t)??0}moveTo(t,i){return this.batch.invoke("moveTo",t,i),this}putImageData(t,i,a,h,d,C,P){let R=[t.ref,i,a];return h&&R.push(h),d&&R.push(d),C&&R.push(C),P&&R.push(P),this.batch.invoke("putImageData",...R),this}quadraticCurveTo(t,i,a,h){return this.batch.invoke("quadraticCurveTo",t,i,a,h),this}rect(t,i,a,h){return this.batch.invoke("rect",t,i,a,h),this}reset(){this.invoke("reset");}resetTransform(){this.invoke("resetTransform");}restore(){return this.invoke("restore")}rotate(t){return this.batch.invoke("rotate",t),this}roundRect(t,i,a,h,d){return this.batch.invoke("roundRect",t,i,a,h,d),this}save(){return this.invoke("save")}scale(t,i){return this.batch.invoke("scale",t,i),this}setLineDash(t){return this.invoke("setLineDash",t)}async setTransform(t,i,a,h,d,C){typeof t=="number"?await this.invoke("setTransform",t,i,a,h,d,C):await this.invoke("setTransform",t.ref);}stroke(t){return this.batch.invoke("stroke",...t?[(t.commit(),t.ref)]:[]),this}strokeRect(t,i,a,h){return this.batch.invoke("strokeRect",t,i,a,h),this}strokeText(t,i,a,h){return this.batch.invoke("strokeText",t,i,a,...h?[h]:[]),this}transform(t,i,a,h,d,C){return this.batch.invoke("transform",t,i,a,h,d,C),this}translate(t,i){return this.batch.invoke("translate",t,i),this}set fillStyle(t){this.setFillStyle(t);}async setFillStyle(t){return await this.setProperty("fillStyle",typeof t=="string"?t:t instanceof n?t.ref:t),this}set filter(t){this.setFilter(t);}async setFilter(t){return await this.setProperty("filter",t),this}set font(t){this.setFont(t);}async setFont(t){return await this.setProperty("font",t),this}set fontKerning(t){this.setFontKerning(t);}async setFontKerning(t){return await this.setProperty("fontKerning",t),this}set fontStretch(t){this.setFontStretch(t);}async setFontStretch(t){return await this.setProperty("fontStretch",t),this}set fontVariantCaps(t){this.setFontVariantCaps(t);}async setFontVariantCaps(t){return await this.setProperty("fontVariantCaps",t),this}set globalAlpha(t){this.setGlobalAlpha(t);}async setGlobalAlpha(t){return await this.setProperty("globalAlpha",t),this}set globalCompositeOperation(t){this.setGlobalCompositeOperation(t);}async setGlobalCompositeOperation(t){return await this.setProperty("globalCompositeOperation",t),this}set imageSmoothingEnabled(t){this.setImageSmoothingEnabled(t);}async setImageSmoothingEnabled(t){return await this.setProperty("imageSmoothingEnabled",t),this}set imageSmoothingQuality(t){this.setImageSmoothingQuality(t);}async setImageSmoothingQuality(t){return await this.setProperty("imageSmoothingQuality",t),this}set letterSpacing(t){this.setLetterSpacing(t);}async setLetterSpacing(t){return await this.setProperty("letterSpacing",t),this}set lineCap(t){this.setLineCap(t);}async setLineCap(t){return await this.setProperty("lineCap",t),this}set lineDashOffset(t){this.setLineDashOffset(t);}async setLineDashOffset(t){return await this.setProperty("lineDashOffset",t),this}set lineJoin(t){this.setLineJoin(t);}async setLineJoin(t){return await this.setProperty("lineJoin",t),this}set lineWidth(t){this.setLineWidth(t);}async setLineWidth(t){return await this.setProperty("lineWidth",t),this}set miterLimit(t){this.setMiterLimit(t);}async setMiterLimit(t){return await this.setProperty("miterLimit",t),this}set shadowBlur(t){this.setShadowBlur(t);}async setShadowBlur(t){return await this.setProperty("shadowBlur",t),this}set shadowColor(t){this.setShadowColor(t);}async setShadowColor(t){return await this.setProperty("shadowColor",t),this}set shadowOffsetX(t){this.setShadowOffsetX(t);}async setShadowOffsetX(t){return await this.setProperty("shadowOffsetX",t),this}set shadowOffsetY(t){this.setShadowOffsetY(t);}async setShadowOffsetY(t){return await this.setProperty("shadowOffsetY",t),this}set strokeStyle(t){this.setStrokeStyle(t);}async setStrokeStyle(t){return await this.setProperty("strokeStyle",typeof t=="string"?t:t instanceof n?t.ref:t),this}set textAlign(t){this.setTextAlign(t);}async setTextAlign(t){return await this.setProperty("textAlign",t),this}set textBaseline(t){this.setTextBaseline(t);}async setTextBaseline(t){return await this.setProperty("textBaseline",t),this}set wordSpacing(t){this.setWordSpacing(t);}async setWordSpacing(t){return await this.setProperty("wordSpacing",t),this}set textRendering(t){this.setTextRendering(t);}async setTextRendering(t){return await this.setProperty("textRendering",t),this}async commit(){await this.batch.exec();}},f(B,"Canvas2DContext"),B);o.Canvas2DContext=O;let L=(_=class extends n{constructor(l){super(l.uid,l.tag);}static async new(l,t){let i=[];l&&i.push(l),t&&i.push(t);let a=await y.newObject("Image",...i);return a?new _(a):null}async width(){return await this.getProperty("width")??0}async height(){return await this.getProperty("height")??0}async naturalWidth(){return await this.getProperty("naturalWidth")??0}async naturalHeight(){return await this.getProperty("naturalHeight")??0}async src(){return await this.getProperty("src")}async currentSrc(){return await this.getProperty("currentSrc")}async setSrc(l){await this.setProperty("src",l);}},f(_,"Image"),_);o.Image=L;let g=(M=class extends n{constructor(t){super(t.uid,t.tag);p(this,"batch",new s(this));}static async create(){let t=await y.newObject("Path2D");return t?new M(t):null}addPath(t){return this.batch.invoke("addPath",t.ref),this}arc(t,i,a,h,d,C=false){return this.batch.invoke("arc",t,i,a,h,d,C),this}arcTo(t,i,a,h,d){return this.batch.invoke("arcTo",t,i,a,h,d),this}bezierCurveTo(t,i,a,h,d,C){return this.batch.invoke("bezierCurveTo",t,i,a,h,d,C),this}quadraticCurveTo(t,i,a,h){return this.batch.invoke("quadraticCurveTo",t,i,a,h),this}closePath(){return this.batch.invoke("closePath"),this}ellipse(t,i,a,h,d,C,P,R=false){return this.batch.invoke("ellipse",t,i,a,h,d,C,P,R),this}moveTo(t,i){return this.batch.invoke("moveTo",t,i),this}lineTo(t,i){return this.batch.invoke("lineTo",t,i),this}rect(t,i,a,h){return this.batch.invoke("rect",t,i,a,h),this}roundRect(t,i,a,h,d){return this.batch.invoke("roundRect",t,i,a,h,d),this}async commit(){await this.batch.exec();}},f(M,"CanvasPath2D"),M);o.CanvasPath2D=g;let x=(H=class extends c{constructor(l){super(l);}async width(){return this.getProperty("width")}async height(){return this.getProperty("height")}async setWidth(l){this.setProperty("width",l);}async setHeight(l){this.setProperty("height",l);}async getContext(l){let t=await this.invokeAndHold("getContext",l);return t&&new O(t.uid)}static async of(l,t,i){let a=await y.query(l,t);return a?new H(a):null}},f(H,"CanvasElement"),H);o.CanvasElement=x;})(I||(I={}));var lt=class lt{constructor(){p(this,"callbacks",new Map);p(this,"DOM_EVENT_LISTENERS",new Map);p(this,"timers",new Map);p(this,"_config");p(this,"listeners",new Map);this.subscribe("__ouid_native_event_success__",(e,s)=>{let n=this.callbacks.get(e);if(n)return this.callbacks.delete(e),n.success(...JSON.parse(s))}),this.subscribe("__ouid_native_event_error__",(e,s)=>{let n=this.callbacks.get(e);if(n)return this.callbacks.delete(e),console.log("Error:",s),n.error(...JSON.parse(s))}),this.subscribe("__ouid_web_event__",(e,s)=>{let n=this.DOM_EVENT_LISTENERS.get(e);if(n){let c=JSON.parse(s)[1];return c&&(c.target=c?.target?new I.OElement(c.target):null,c.currentTarget=c?.currentTarget?new I.OElement(c.currentTarget):null,c.relatedTarget=c?.relatedTarget?new I.OElement(c.relatedTarget):null),n(c)}});}config(e){return this._config=e,this}invoke(e,...s){let n=z(e);return new Promise((r,c)=>{this.callbacks.set(n,{success:r,error:c});try{if(!WebOUID)throw new Error("NativeOUID bridge not available");WebOUID.invoke(n,e,JSON.stringify(s));}catch(u){console.error(u),this.callbacks.delete(n);}})}registerComponent(e,s){U.register(e,s);}unregisterComponent(e,s){U.unregister(e);}async call(e,...s){try{return (await this.invoke(`_ouid_${e}`,...s)).data}catch(n){return console.error(n),null}}emit(e,s){WebOUID?.invoke("event",e,JSON.stringify(s));}subscribe(e,s){this.listeners.has(e)||(this.listeners.set(e,[]),globalThis[e]=(n,r)=>{this.listeners.get(e)?.forEach(c=>c(n,r));}),this.listeners.get(e).push(s);}async query(e,s,n){let r=await this.call("query",e,s,n);return r?new I.OElement(r):null}async queryAll(e,s,n){let r=await this.call("queryAll",e,s,n);return r?r.map(c=>new I.OElement(c)):[]}async createElement(e,s={}){let n=await this.call("createElement",e,s);return n?new I.OElement(n):null}async createComment(e){let s=await this.call("createComment",e);return s?new I.OElement(s):null}async addEventListener(e,s,n,r){let c=z(s+(typeof e=="string"?e:e.tag));return this.DOM_EVENT_LISTENERS.set(c,n),await y.call("attachEventListener",typeof e=="string"?e:e.uid,c,s,r?.options,r?.policy),c}async dettachEventListener(e){this.DOM_EVENT_LISTENERS.delete(e),await y.call("dettachEventListener",e);}async injectComponentStyles(e){let s=await y.call("injectComponentStyles",e);return s?new I.OElement(s):null}async rejectComponentStyles(e){await y.call("rejectComponentStyles",e.uid);}async getOObject(e){let s=await y.call("getOObject",e);return s?new I.OObject(s.uid,s.tag):null}async acquireObject(e){let s=await y.call("acquireObject",e);return s?new I.OObject(s.uid,s.tag):null}async setTimeout(e,s){let n=z("setTimeout"+s);this.DOM_EVENT_LISTENERS.set(n,()=>{e();let c=this.timers.get(r);c&&(this.timers.delete(r),this.DOM_EVENT_LISTENERS.delete(c));});let r=await y.call("setTimeout",n,s)??-1;return r>=0&&this.timers.set(r,n),r}async clearTimeout(e){let s=this.timers.get(e);s&&(this.timers.delete(e),this.DOM_EVENT_LISTENERS.delete(s),await y.call("clearTimeout",e));}async setInterval(e,s){let n=z("setInterval"+s);this.DOM_EVENT_LISTENERS.set(n,e);let r=await y.call("setInterval",n,s)??-1;return r>=0&&this.timers.set(r,n),r}async clearInterval(e){let s=this.timers.get(e);s&&(this.timers.delete(e),this.DOM_EVENT_LISTENERS.delete(s),await y.call("clearInterval",e));}async fetch(e,s,n="json"){return await y.call("fetch",e,s,n)}async alert(e){await y.call("alert",e);}async prompt(e){await y.call("prompt",e);}async newObject(e,...s){return y.call("newObject",e,...s)}};f(lt,"OUIDBridge");var ht=lt,y=new Proxy(new ht,{get:f((o,e)=>e in o?o[e]:async(...s)=>await o.call(e,...s),"get")});globalThis.OUID=y;var I;function Nt(o){return o.replace(/-([a-z])/g,(e,s)=>s.toUpperCase())}f(Nt,"toCamelCase");function _t(o){return o.replace(/(?!^)([A-Z])/g,(e,s)=>`-${s.toLowerCase()}`)}f(_t,"toSnakeCase");function N(o){return vt(o)?o.value:o}f(N,"normaliseValue");var Mt=typeof globalThis.queueMicrotask=="function",V=f(o=>o?Mt?queueMicrotask(o):Promise.resolve().then(o):Promise.resolve(),"deferMicro"),ue=f(()=>new Promise(o=>setTimeout(o,0)),"deferMacro");function Ht(o){return typeof o=="function"&&!("prototype"in o)}f(Ht,"isLazyLoader");var bt=new Map,kt=new Map,Ct=new WeakMap;function xt(o){if(!o||typeof o!="object"&&typeof o!="function")return {};let e=Ct.get(o);if(e)return e;let s=Object.create(null);for(let n=o;n&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let r of Object.getOwnPropertyNames(n)){if(r==="constructor"||r.startsWith("__")||r.endsWith("__")||r in s)continue;let c=Object.getOwnPropertyDescriptor(n,r);if(!c)continue;let u=c.value??(c.get?c.get.call(o):void 0);s[r]=typeof u=="function"?u.bind(o):u;}return Ct.set(o,s),s}f(xt,"getMethodsView");function Et(o,e){let s=bt.get(o);return s||(s=new Function("s","with (s) { return ("+o+"); }"),bt.set(o,s)),s(e)}f(Et,"evalInScope");function Ut(o){let e=kt.get(o);if(e)return e;let s=[],n=0;for(;n<o.length;){let r=o.indexOf("{{",n);if(r<0){s.push({t:o.slice(n)});break}r>n&&s.push({t:o.slice(n,r)});let c=o.indexOf("}}",r+2),u=c>=0?o.slice(r+2,c).trim():o.slice(r+2).trim();s.push({e:u}),n=c>=0?c+2:o.length;}return e=f(r=>{let c="";for(let u of s)if(u.t!==void 0)c+=u.t;else if(u.e!==void 0){let w=N(Et(u.e,r));c+=w==null?"":String(w);}return c},"fn"),kt.set(o,e),e}f(Ut,"compileInterpolated");var j=class j{constructor(e,s,n,...r){p(this,"app");p(this,"component");p(this,"parentContext");p(this,"bindings",[]);p(this,"directives",[]);p(this,"mountedComponents",new WeakMap);p(this,"componentsRegistry",new G);p(this,"updatingDirectives",false);p(this,"updatingBindings",false);p(this,"_stack",[]);p(this,"flatStack",Object.create(null));p(this,"hydradationActions",new I.BatchActions);this.app=e,this.component=s,this.parentContext=n;for(let c of r)this.push(c);}get hostElement(){return this.component._hostElement}get stack(){return this._stack}set stack(e){this.flatStack=Object.create(null),this._stack=[];for(let s of e)this.push(s);}getMountedComponent(e){return this.mountedComponents.get(e)}bind(e){this.bindings.push(e);}directive(e){this.directives.push(e);}evaluateExpression(e){return this.resolve(e)}resolve(e,s=true,...n){if(!e)return;let r=this.component.state?.value??{},c=xt(r),u=new Proxy(Object.create(null),{get:f((w,m)=>{for(let O=n.length-1;O>=0;O--)if(m in n[O])return n[O][m];return m in this.flatStack?this.flatStack[m]:m in c?c[m]:r[m]},"get"),has:f((w,m)=>n.some(O=>m in O)||m in this.flatStack||m in c||m in r,"has")});try{return Et(e,u)}catch{return}}updateValue(e,s){let n=e.split(/[\.\[]/)[0];n in this.component?this.resolve(`${e}=__o_model_value__`,true,{__o_model_value__:s}):this.resolve(`${e}=__o_model_value__`,true,{__o_model_value__:s}),this.component.state.didChange(n,void 0,s);}push(e){this._stack.unshift(e),Object.assign(this.flatStack,e);}pop(){let e=this._stack.shift();if(e)for(let s of Object.keys(e))delete this.flatStack[s];}resolveTag(e){let s=this;for(;;){if(s.componentsRegistry.has(e))return s.componentsRegistry.get(e);if(s=s?.parentContext??null,!s)break}return U.get(e)}async updateBindings(e){if(this.updatingBindings)return;let s=!e;e=e??new I.BatchActions,this.updatingBindings=true;for(let n of this.bindings)this.updateBinding(n,e);this.updatingBindings=false,s&&await e.commit();}updateBinding(e,s){if(e.type==="model"){e.node.setProperty("value",N(e.context.resolve(e.key)));return}if(e.type==="interpolation"){s.add(async()=>{let n=e.templateFn({...this.flatStack,...xt(this.component.state?.value??{}),...this.component.state?.value??{}});await e.node.setContentText(n);});return}if(e.type==="attribute"){let n=e.key,r=N(this.resolve(e.template));n==="class"?s.add(()=>this.expandClass(e.node,r)):n==="style"?this.expandStyle(e.node,r):typeof r!="object"&&typeof r!="function"&&typeof r!="symbol"&&typeof r<"u"&&s.add(()=>e.node.setAttribute(n,r.toString()));return}if(e.type==="prop"&&e.context.component){let n=N(this.resolve(e.template));try{e.context.component.props[e.key]=n,e.context.updateBindings(),e.context.updateDirectives();}catch(r){console.error(r);}return}}async updateDirectives(e){if(this.updatingDirectives)return;let s=!e;this.updatingDirectives=true,e=e??new I.BatchActions;for(let n of this.directives){if(n.type==="if"){if(!N(n.context.evaluateExpression(n.expr))){if(n.active===false)continue;n.active=false,n.renderedNode&&(n.destroy?(this.unmountComponent(n.renderedNode),await n.renderedNode.removeAndRelease()):await n.renderedNode.addClass("oui-hidden"));continue}if(n.active===true)continue;n.active=true;let c=n.renderedNode;if(!c||n.destroy){let u=await n.node.cloneNode(true);n.renderedNode=u,await n.context.render(u),await n.placeholder.after(u),await n.context.hydradationActions.commit();}else await c.removeClass("oui-hidden");}if(n.type==="for"){let r=n.children??new Map,c=new Map,u=f((b,v)=>n.key?N(n.context.resolve(n.key,true,{[n.item]:b})):v,"keyFn"),w=N(n.context.resolve(n.list))||[],m=new I.BatchActions,O=32,L=0,g=[],x=n.placeholder;for(let b=0;b<w.length;b++){let v=w[b],k=u(v,b),S=r.get(k),E,A,T=x;S?(E=S.node,A=S.ctx,A.stack=[{[n.item]:v},...n.context.stack],m.add(async()=>{let D=await x.nextSibling();E.uid!==D?.uid&&m.add(()=>T.after(E));}),await Promise.all([A.updateBindings(e),A.updateDirectives(e)])):(A=new j(this.app,this.component,this),A.hydradationActions=this.hydradationActions,A.stack=[{[n.item]:v},...n.context.stack],E=await n.node.cloneNode(true),m.add(async()=>{await T.after(E);}),g.push(async()=>{await A.render(E),await A.updateDirectives(e);})),x=E,c.set(k,{node:E,ctx:A}),++L>=O&&(L=0,await m.commit(),await V());}for(let[b,v]of r.entries())c.has(b)||(this.unmountComponent(v.node),m.add(()=>v.node.removeAndRelease()));if(await m.commit(),g.length)for(let v=0;v<g.length;v+=12){let k=g.slice(v,v+12).map(S=>S());await Promise.all(k),await V();}n.children=c;}}s&&await e.commit(),await this.hydradationActions.commit(),this.updatingDirectives=false;}async render(e,s){if(e.hydrated||s?.skipSlotted&&e.hasAttribute("slotted"))return;switch(e.type){case "Text":this.handleTextNode(e);break;case "Element":await this.handleElementNode(e,s);break;}let n=new I.BatchActions;await Promise.all([this.updateBindings(n),this.updateDirectives(n)]),n.commit(),this.hydradationActions.add(()=>e.hydrate());}async expandClass(e,s){let n;typeof s=="object"?Array.isArray(s)?n=s:n=Object.keys(s).filter(r=>s[r]):n=s.toString().split(/\s+/),n.length>0&&await e.addClass(...n);}expandStyle(e,s){let n=s;typeof s=="object"&&!Array.isArray(s)&&(n=Object.keys(s).filter(r=>s[r]).map(r=>`${_t(r)}: ${s[r]}`).join(";")),n&&e.setAttribute("style",n);}expandStandardAttributes(e){let s=e.updates();[...e.attributes].filter(n=>n.name.startsWith(":")).forEach(n=>{let r=n.name.substring(1);this.bind({type:"attribute",node:e,key:r,context:this,template:n.value.trim()}),s.removeAttribute(n.name);}),s.exec();}async handleElementNode(e,s){let n=await e.parentNode(),r=null,c=e.hasAttribute("o-if")?"o-if":e.hasAttribute("o-show")?"o-show":null;if(c){let v=await e.getAttribute(c),k=await OUID.createComment(c+":"+v),S=c==="o-if";await n.insertBefore(k,e),await e.updates().removeAttribute(c).remove().exec(),this.directive({type:"if",expr:v,node:e,placeholder:k,context:this,active:void 0,destroy:S}),r="if";return}if(e.hasAttribute("o-for")){if(r==="if")throw new Error("Can't have o-if and o-for on the same component");let v=await e.getAttribute("o-for"),[k,S]=v.split(" of ").map(T=>T.trim()),E=await OUID.createComment("for:"+v),A=e.attribute(":key")??"";await n?.insertBefore(E,e),await e.updates().removeAttribute("o-for").removeAttribute(":key").remove().exec(),this.directive({type:"for",item:k,list:S,node:e,placeholder:E,context:this,key:A}),r="for";return}let u=e.tag.toLowerCase(),w=this.resolveTag(u),m=e.updates();[...e.attributes].forEach(async v=>{if(v.name==="o-model"){let k=v.value.trim();m.setInputValue(N(this.resolve(k))).addEventListener("input",async E=>{let A=await E.target.getProperty("value");this.updateValue(k,A);}),this.bind({node:e,key:k,type:"model",context:this}),m.removeAttribute(v.name);}});let O={},L={},{props:g,events:x}=this.componentAttributes(e,this);if(O=g,L=x,this.expandStandardAttributes(e),Object.keys(L).forEach(async v=>{let k=L[v];w||m.addEventListener(v,S=>{typeof k=="function"&&k.apply(this.component,[S]);}),m.removeAttribute("@"+v);}),await m.exec(),w){await this.mountComponent(e,w,this,O,L);return}let b=await e.childNodes();s?.skipSlotted&&(b=b.filter(v=>!v.hasAttribute("slotted")));for(let v of b)await this.render(v,s);}handleTextNode(e){let s=e.textContent??"";s.includes("{{")&&this.bind({type:"interpolation",node:e,key:"__template__",templateFn:Ut(s),context:this});}componentAttributes(e,s){let n={},r={},c=["import","interface","module","o-model","o-if","o-for"];return [...e.attributes].filter(u=>!c.includes(u.name)).forEach(u=>{let w=u.name;if(w.startsWith("@")){let L=s?.resolve(u.value,true);if(typeof L!="function")throw new Error("Event handler can only be function");w=w.substring(1),r[w]=L;return}let m=null,O=u.value;w.startsWith(":")&&(m=u.value,w=w.substring(1),O=N(s?.resolve(u.value))),w=Nt(w),n[w]={name:w,value:O,expr:m};}),{props:n,events:r}}async mountComponent(e,s,n,r={},c={}){if(this.mountedComponents.has(e))return this.mountedComponents.get(e);let u=new j(this.app,{},this),w={};for(let g of Object.keys(r)){let x=r[g];x.expr&&this.bind({type:"prop",node:e,key:g,context:u,template:x.expr}),w[g]=x.value;}let m=await Vt(s,w,c);u.component=m,u.stack=[],this.mountedComponents.set(e,m);{let g=e.updates();for(let b of Object.keys(r))r[b].expr||g.setAttribute(b,r[b].value);let x=m.hostClasses??[];x&&(x=typeof x=="string"?[x]:x),x.push("o-component-host"),e.tag.toLowerCase()!=="div"&&x.push("c-"+e.tag.toLowerCase()),g.addClass(...x),await g.exec();}V(async()=>{try{await m.decorateHostElement(e);}catch{}});{let g=m.use??{};for(let x of Object.keys(g))u.componentsRegistry.register(x,g[x]);}if(m.willMount(),!s.cssInstance){let g=m.style?m.style()?.toString():m.css;g&&(s.cssInstance??(s.cssInstance=await OUID.injectComponentStyles(g)));}V(()=>{let g=s.cssInstance;if(g){let x=j.STYLE_REF.get(g)??0;j.STYLE_REF.set(g,x+1),m.cssInstance=g;}});let O=await e.childNodes();if(m.render){let g=await m.render(u);g&&g.attachTo(e);}else await e.setHTML(m.template.trim());let L=await e.queryAll("slot");L&&L.length&&await Promise.all(L.filter(g=>!g.classes?.includes("hydrated")).map(async g=>{let x=g.attribute("name"),b=O.filter(k=>x?k.type==="Element"&&k.attribute("slot")===x:k.type!=="Element"||!k.hasAttribute("slot"));if(!b.length)return;let v=new I.BatchActions;for(let k of b)v.add(()=>k.setAttribute("slotted","true")),v.add(()=>g.appendChild(k));await v.commit(),await Promise.all(b.map(k=>this.render(k)));})),m._hostElement=e,m.parent=n?.component??void 0,m.provide(j.PROVIDE_TOKEN,this);{let g=await e.childNodes(),x=6,b=0;for(;b<g.length;){let v=g.slice(b,b+x);await Promise.all(v.map(k=>u.render(k,{skipSlotted:true}))),b+=x;}await u.hydradationActions.commit();}return V(()=>{try{m.onMounted();}catch{}e.hydrate();}),m.state.watch(()=>{let g=new I.BatchActions;u.updateBindings(g),u.updateDirectives(g),g.commit();}),m}async unmountComponent(e){let s=this.mountedComponents.get(e);if(s){let r=s.cssInstance;if(r){let c=j.STYLE_REF.get(r)??1;c===1?(await OUID.rejectComponentStyles(r),j.STYLE_REF.delete(r)):j.STYLE_REF.set(r,c-1);}s.willUnmount(),s._hostElement=null,s.cssInstance=null;}let n=await e.queryAll("*")??[];for(let r of n)await this.unmountComponent(r);this.mountedComponents.delete(e);}};f(j,"RenderContext"),p(j,"PROVIDE_TOKEN","RENDER_CONTEXT"),p(j,"STYLE_REF",new WeakMap);var $=j;async function de(o,e,s=[],n){let r=e??{},c=await OUID.createElement(o,Object.keys(r).reduce((u,w)=>(u[w]=r[w],u),{}));return Object.keys(n??{}).forEach(u=>{c?.addEventListener(u,w=>{let m=n[u];typeof m=="function"&&m(w);});}),new F(c,s)}f(de,"node");function Vt(o,e,s){return Ht(o)?o().then(n=>ot(n.default,e,s)):ot(o,e,s)}f(Vt,"o");function Bt(o){return typeof o=="function"}f(Bt,"isProvideFunction");var Q=class Q{constructor(e,s){p(this,"root");p(this,"options");p(this,"providers",new Map);this.root=e,this.options=s,Q.currentApp=this;}provide(e,s){if(this.providers.has(e)){console.warn(`[OUID] - Provider ${e} already exists`);return}this.providers.set(e,Bt(s)?{provide:s}:{value:s});}inject(e){return this.providers.get(e)?.value}use(e,s){return e.install(this,s),this}async mount(e){if(!globalThis.__OUI_PUR_JS_CONTEXT__)return;this.options?.css&&await OUID.injectComponentStyles(this.options.css),await OUID.injectComponentStyles(`
|
|
7
7
|
* {
|
|
8
|
-
${
|
|
8
|
+
${e} * {
|
|
9
9
|
visibility: hidden;
|
|
10
10
|
}
|
|
11
|
-
${
|
|
11
|
+
${e} *.hydrated {
|
|
12
12
|
visibility: inherit;
|
|
13
13
|
}
|
|
14
14
|
.oui-hidden {
|
|
15
15
|
display: none !important;
|
|
16
16
|
}
|
|
17
|
-
`);let
|
|
17
|
+
`);let s=await OUID.query(e);if(!s)throw new Error("No selector found for "+e);let n=new $(this,{},null);n.mountComponent(s,this.root,null).then(()=>{n.updateBindings(),n.updateDirectives();});}};f(Q,"App"),p(Q,"currentApp",null);var st=Q;function we(o,e){st.currentApp?.provide(o,e);}f(we,"provide");function St(o){return st.currentApp?.inject(o)??void 0}f(St,"inject");function qt(o,e,s,n){var r=arguments.length,c=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,s):n,u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(o,e,s,n);else for(var w=o.length-1;w>=0;w--)(u=o[w])&&(c=(r<3?u(c):r>3?u(e,s,c):u(e,s))||c);return r>3&&c&&Object.defineProperty(e,s,c),c}f(qt,"_ts_decorate");var ft=class ft extends W{constructor(){super(...arguments);p(this,"router");}willMount(){}onMounted(){this.router=Ft(),this.router?.bind(this).then(s=>{s?.();});}willUnmount(){this.router?.unbind();}};f(ft,"ORouter");var Y=ft;Y=qt([gt({tag:"o-router",template:`
|
|
18
18
|
<div id="router-view"></div>
|
|
19
19
|
`,css:`
|
|
20
|
-
|
|
20
|
+
#router-view {
|
|
21
21
|
height: 100%;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
.route-hidden { display: none; }
|
|
24
|
+
`})],Y);var Pt="OROUTER_TOKEN",ut="ACTIVE_ROUTE";function Ft(){return St(Pt)}f(Ft,"useRouter");function xe(o){return new pt(o)}f(xe,"createRouter");function Tt(o,e){let s=new At(o.path).reverse(e);return s===false?"":s}f(Tt,"generatePath");function Ot(o){o&&(o.__isActive=true,typeof o.onActivated=="function"&&o.onActivated());}f(Ot,"activate");function dt(o){o&&(o.__isActive=false,typeof o.onDeactivated=="function"&&o.onDeactivated());}f(dt,"deactivate");var mt=class mt{constructor(e){p(this,"routes");p(this,"windowObject",null);p(this,"guards",[]);p(this,"eventRegistration",null);p(this,"compiled");p(this,"outletEl",null);p(this,"keepAlive",new Map);p(this,"keepAliveLimit",3);p(this,"pendingNav",null);this.routes=e,this.compiled=e.map(s=>({route:s,parser:new At(s.path)}));}install(e){e.provide(Pt,this),OUID.registerComponent("o-router",Y);}resolve(e){let[s,n=""]=e.split("?"),r=n?n.split("&").reduce((c,u)=>{let[w,m=""]=u.split("=");return w&&(c[w]=decodeURIComponent(m)),c},{}):{};for(let c of this.compiled){let u=c.parser.match(s);if(u)return {route:c.route,params:u,query:r}}return null}push(e){if(!e.path&&!e.name){console.warn("[OUID-Router]: no path or name provided to push");return}if(e.name){let s=this.routes.find(r=>r.name===e.name);if(!s){console.warn("[OUID-Router]: No matched route name found");return}let n=Tt(s,e.params??{});this.windowObject?.invoke("history.pushState",{},"",n),this.windowObject?.dispatchEvent("popstate","PopStateEvent",{state:{}});return}if(e.absolute&&e.path&&this.windowObject?.invoke("history.pushState",{},"",e.path),e.path){let s=this.routes.find(n=>n.path===e.path);if(s){let n=Tt(s,e.params??{});this.windowObject?.invoke("history.pushState",{},"",n),this.windowObject?.dispatchEvent("popstate","PopStateEvent",{state:{}});return}}}pop(){this.windowObject?.invoke("history.back"),this.windowObject?.dispatchEvent("popstate","PopStateEvent",{state:{}});}async beforeRouteGoing(e,s){for(let n of this.guards.filter(r=>r.type==="before")){let r=await n.fn(e,s);if(r)return r}}async afterRouteGoing(e,s){for(let n of this.guards.filter(r=>r.type==="after")){let r=await n.fn(e,s);if(r)return r}}async bind(e){this.windowObject=await OUID.acquireObject("window");let s=f(async()=>{this.windowObject||(this.windowObject=await OUID.acquireObject("window"));let c=await this.windowObject.getProperty("location.pathname"),u=this.resolve(c);if(!u){console.warn(`[Router] No route found for: ${c}`);return}let w=e.inject($.PROVIDE_TOKEN);this.outletEl||(this.outletEl=await w.hostElement.query("#router-view"));let m=this.outletEl;if(!m)return;let O=await this.beforeRouteGoing({url:c,path:c,name:u.route.name},e.inject(ut));if(O){typeof O=="object"&&"name"in O&&this.push({name:O.name,params:O.params});return}e.provide(ut,{params:u.params,query:u.query});let L=u.route.name,g=this.keepAlive.get(L),x=await m.childNodes(),b=x[x.length-1]??null,v=await OUID.createElement("div",{class:"route-staging route-hidden"});await m.appendChild(v);let k=v;if(console.log("Changing route",c,u,g),g){k=g.host;let S=m.updates();S.add(()=>v.after(k)),S.removeChild(v),b&&S.add(()=>b.addClass("route-hidden")),S.add(()=>k.removeClass("route-hidden")),await S.exec(),console.log("Cached route",k,v),await Promise.all([g.ctx.updateBindings(),g.ctx.updateDirectives()]);let E=w.getMountedComponent(b)??null;dt(E),Ot(g.inst);}else {let S=await w.mountComponent(v,u.route.component,w),E=m.updates();if(b&&E.add(()=>b.addClass("route-hidden")),E.add(()=>v.removeClass("route-hidden")),await E.exec(),Ot(S),this.keepAlive.set(L,{host:v,ctx:w,inst:S}),this.keepAlive.size>this.keepAliveLimit){let A=this.keepAlive.keys().next().value;if(A){let T=this.keepAlive.get(A);dt(T.inst),await w.unmountComponent(T.host),await T.host.removeAndRelease(),this.keepAlive.delete(A);}}}if(b){let S=w.getMountedComponent(b)??null;[...this.keepAlive.values()].some(A=>A.host.uid===b.uid)||(dt(S),await w.unmountComponent(b),await b.removeAndRelease());}await this.afterRouteGoing({url:c,path:c,name:u.route.name},e.inject(ut)),await V();},"handler"),n=f(async()=>this.pendingNav?this.pendingNav:(this.pendingNav=(async()=>{try{await s();}finally{this.pendingNav=null;}})(),this.pendingNav),"run"),r=await this.windowObject.addEventListener("popstate",n);return this.eventRegistration=r,s}unbind(){this.eventRegistration&&this.windowObject?.dettachEventListener(this.eventRegistration);}beforeEach(e){let s={fn:e,type:"before"};return this.guards.push(s),()=>{this.guards.splice(this.guards.indexOf(s));}}afterEach(e){let s={fn:e,type:"after"};return this.guards.push(s),()=>{this.guards.splice(this.guards.indexOf(s));}}};f(mt,"Router");var pt=mt;var wt=class wt extends W{render(e){return F.of('<i class="o-icon"><slot></slot></i>')}style(){return tt.of({i:`
|
|
24
25
|
display: inline-block;
|
|
25
26
|
width: 1em;
|
|
26
27
|
height: 1em;
|
|
27
28
|
vertical-align: -0.15em;
|
|
28
29
|
overflow: hidden;
|
|
29
|
-
`})}};
|
|
30
|
+
`})}};f(wt,"OIcon");var It=wt;function Ie(){return U.getAll().reduce((e,[s,n])=>(e[s]=n,e),{})}f(Ie,"components");export{ut as ACTIVE_ROUTE_TOKEN,st as App,gt as Component,X as Emits,W as OComponent,I as ODOM,It as OIcon,Y as ORouter,y as OUID,ht as OUIDBridge,Pt as ROUTER_INJECTION_TOKEN,$ as RenderContext,F as RenderNode,pt as Router,Z as State,K as Stated,tt as StyleData,Ie as components,ot as createComponent,xe as createRouter,ue as deferMacro,V as deferMicro,St as inject,vt as isStated,de as node,Vt as o,we as provide,jt as stated,Ft as useRouter};//# sourceMappingURL=index.js.map
|
|
30
31
|
//# sourceMappingURL=index.js.map
|