@async/framework 0.7.0 → 0.9.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/server.d.ts ADDED
@@ -0,0 +1,690 @@
1
+ // Generated by scripts/build-framework-bundle.js. Do not edit by hand.
2
+ // Server-capable type declarations for @async/framework.
3
+
4
+ export type RuntimeTarget = "browser" | "server";
5
+ export type RouterMode = "csr" | "spa" | "ssr" | "ssr-spa" | "mpa";
6
+ export type AsyncSignalStatus = "idle" | "loading" | "ready" | "error";
7
+ export type MaybePromise<T> = T | Promise<T>;
8
+ export type Cleanup = () => void;
9
+ export type RegistryType =
10
+ | "signal"
11
+ | "handler"
12
+ | "server"
13
+ | "partial"
14
+ | "route"
15
+ | "component"
16
+ | "cache.browser"
17
+ | "cache.server"
18
+ | "cache.browser.entries"
19
+ | "cache.server.entries";
20
+
21
+ export interface AttributeConfig {
22
+ async?: string | string[];
23
+ class?: string | string[];
24
+ signal?: string | string[];
25
+ on?: string | string[];
26
+ }
27
+
28
+ export interface NormalizedAttributeConfig {
29
+ async: string[];
30
+ class: string[];
31
+ signal: string[];
32
+ on: string[];
33
+ }
34
+
35
+ export type TemplatePrimitive = string | number | boolean | null | undefined;
36
+ export type TemplateLike = TemplateResult | TemplatePrimitive | Node | TemplateLike[];
37
+
38
+ export interface TemplateResult {
39
+ readonly strings: TemplateStringsArray;
40
+ readonly values: readonly unknown[];
41
+ }
42
+
43
+ export type SchedulerStrategy = "microtask" | "manual";
44
+ export type SchedulerPhase = "binding" | "lifecycle" | "effect" | "async" | "post" | string;
45
+ export interface SchedulerJob {
46
+ id: number;
47
+ phase: SchedulerPhase;
48
+ scope?: unknown;
49
+ boundary?: string;
50
+ key?: string;
51
+ canceled: boolean;
52
+ cancel(): void;
53
+ }
54
+ export interface SchedulerOptions {
55
+ strategy?: SchedulerStrategy;
56
+ phases?: SchedulerPhase[];
57
+ maxDepth?: number;
58
+ onError?(error: unknown, job: SchedulerJob): void;
59
+ }
60
+ export interface SchedulerInspection {
61
+ strategy: SchedulerStrategy;
62
+ phases: SchedulerPhase[];
63
+ pending: Record<string, number>;
64
+ scopesDestroyed: number;
65
+ flushing: boolean;
66
+ scheduled: boolean;
67
+ }
68
+ export interface Scheduler {
69
+ strategy: SchedulerStrategy;
70
+ phases: SchedulerPhase[];
71
+ batch<T>(fn: () => T): T;
72
+ enqueue(phase: SchedulerPhase, job: () => MaybePromise<unknown>, options?: { scope?: unknown; boundary?: string; key?: string }): Cleanup;
73
+ flush(): Promise<void>;
74
+ flushScope(scope: unknown): Promise<void>;
75
+ afterFlush(job: () => MaybePromise<unknown>, options?: { scope?: unknown; boundary?: string; key?: string }): Cleanup;
76
+ cancelScope(scope: unknown): this;
77
+ markScopeDestroyed(scope: unknown): this;
78
+ isScopeDestroyed(scope: unknown): boolean;
79
+ destroy(): void;
80
+ inspect(): SchedulerInspection;
81
+ }
82
+
83
+ export interface RequestContextStore {
84
+ run<T>(context: Record<string, unknown> | undefined, fn: () => T): T;
85
+ get(): Record<string, unknown> | undefined;
86
+ snapshot(): Record<string, unknown>;
87
+ }
88
+
89
+ export interface Signal<T = unknown> {
90
+ readonly kind: "signal";
91
+ value: T;
92
+ set(value: T): T;
93
+ update(fn: (value: T) => T): T;
94
+ subscribe(fn: (value: T) => void): Cleanup;
95
+ snapshot(): T;
96
+ }
97
+
98
+ export interface ComputedSignal<T = unknown> extends Omit<Signal<T>, "kind"> {
99
+ readonly kind: "computed";
100
+ }
101
+
102
+ export interface EffectDefinition {
103
+ readonly kind: "effect";
104
+ readonly fn: () => unknown;
105
+ }
106
+
107
+ export interface AsyncSignalSnapshot<T = unknown> {
108
+ value: T | undefined;
109
+ loading: boolean;
110
+ error: unknown;
111
+ status: AsyncSignalStatus;
112
+ version: number;
113
+ }
114
+
115
+ export interface AsyncSignal<T = unknown> extends Omit<Signal<T | undefined>, "kind" | "snapshot"> {
116
+ readonly kind: "async-signal";
117
+ readonly id: string;
118
+ readonly loading: boolean;
119
+ readonly error: unknown;
120
+ readonly status: AsyncSignalStatus;
121
+ readonly version: number;
122
+ refresh(): Promise<T | undefined>;
123
+ cancel(reason?: unknown): void;
124
+ snapshot(): AsyncSignalSnapshot<T>;
125
+ }
126
+
127
+ export interface SignalRef<T = unknown> {
128
+ readonly kind: "signal-ref";
129
+ readonly id: string;
130
+ value: T;
131
+ readonly loading: boolean;
132
+ readonly error: unknown;
133
+ readonly status: AsyncSignalStatus;
134
+ readonly version: number;
135
+ get(): T;
136
+ set(value: T): T;
137
+ update(fn: (value: T) => T): T;
138
+ subscribe(fn: (value: T, info?: SignalSubscriptionInfo) => void): Cleanup;
139
+ refresh(): Promise<T | undefined>;
140
+ cancel(reason?: unknown): void;
141
+ toString(): string;
142
+ }
143
+
144
+ export interface SignalSubscriptionInfo {
145
+ id: string;
146
+ path: string;
147
+ signal: unknown;
148
+ }
149
+
150
+ export type SignalLike<T = unknown> = Signal<T> | AsyncSignal<T> | ComputedSignal<T>;
151
+ export type SignalMap = Record<string, SignalLike | unknown>;
152
+
153
+ export interface AsyncSignalContext {
154
+ signals: SignalRegistry;
155
+ id: string;
156
+ version: number;
157
+ abort: AbortSignal & { cancel?(reason?: unknown): void };
158
+ server?: ServerNamespace;
159
+ router?: Router;
160
+ loader?: LoaderInstance;
161
+ cache?: CacheRegistry;
162
+ scheduler?: Scheduler;
163
+ refresh(): Promise<unknown>;
164
+ }
165
+
166
+ export type AsyncSignalFunction<T = unknown> = (this: AsyncSignalContext) => MaybePromise<T>;
167
+
168
+ export interface RegistryInspection<T = unknown> {
169
+ registry: RegistryStore;
170
+ keys(): string[];
171
+ entries(): Array<[string, T]>;
172
+ inspect(): Array<[string, T]>;
173
+ }
174
+
175
+ export interface SignalRegistry extends RegistryInspection {
176
+ register<T = unknown>(id: string, signalLike: SignalLike<T> | T): SignalRef<T>;
177
+ registerMany(map?: SignalMap): this;
178
+ unregister(id: string): boolean;
179
+ ensure<T = unknown>(id: string, initial: T): SignalRef<T>;
180
+ has(id: string): boolean;
181
+ get<T = unknown>(path: string): T;
182
+ set<T = unknown>(path: string, value: T): T;
183
+ update<T = unknown>(path: string, fn: (value: T) => T): T;
184
+ ref<T = unknown>(id: string): SignalRef<T>;
185
+ subscribe<T = unknown>(path: string, fn: (value: T, info: SignalSubscriptionInfo) => void): Cleanup;
186
+ snapshot(): Record<string, unknown>;
187
+ asyncSignal<T = unknown>(id: string, fn: AsyncSignalFunction<T>): SignalRef<T>;
188
+ effect(fn: () => unknown): Cleanup;
189
+ destroy(): void;
190
+ }
191
+
192
+ export interface HandlerContext {
193
+ signals: SignalRegistry;
194
+ handlers: HandlerRegistry;
195
+ server?: ServerNamespace;
196
+ loader?: LoaderInstance;
197
+ router?: Router;
198
+ cache?: CacheRegistry;
199
+ scheduler?: Scheduler;
200
+ event?: Event;
201
+ element?: Element;
202
+ el?: Element;
203
+ root?: Document | Element;
204
+ input?: unknown;
205
+ stop(): void;
206
+ [key: string]: unknown;
207
+ }
208
+
209
+ export type HandlerFunction = (this: HandlerContext, context: HandlerContext) => MaybePromise<unknown>;
210
+
211
+ export interface HandlerRegistry extends RegistryInspection<HandlerFunction> {
212
+ register(id: string, fn: HandlerFunction): string;
213
+ registerMany(map?: Record<string, HandlerFunction>): this;
214
+ unregister(id: string): boolean;
215
+ resolve(id: string): HandlerFunction | undefined;
216
+ run(ref: string, context?: Partial<HandlerContext>): Promise<unknown[]>;
217
+ }
218
+
219
+ export interface ServerEnvelope<T = unknown> {
220
+ value?: T;
221
+ signals?: Record<string, unknown>;
222
+ boundary?: string;
223
+ html?: TemplateLike;
224
+ redirect?: string;
225
+ error?: unknown;
226
+ status?: number;
227
+ cache?: { browser?: Record<string, unknown>; server?: Record<string, unknown> };
228
+ }
229
+
230
+ export type ServerResult<T = unknown> = T | ServerEnvelope<T>;
231
+
232
+ export interface ServerContext {
233
+ id: string;
234
+ args: unknown[];
235
+ input?: unknown;
236
+ signals?: SignalRegistry | { get(path: string): unknown; snapshot?(): Record<string, unknown> };
237
+ request?: Request;
238
+ headers?: Headers;
239
+ cookies?: unknown;
240
+ locals?: unknown;
241
+ abort?: AbortSignal;
242
+ cache?: CacheRegistry;
243
+ scheduler?: Scheduler;
244
+ server: ServerNamespace;
245
+ [key: string]: unknown;
246
+ }
247
+
248
+ export type ServerFunction<T = unknown> = (this: ServerContext, ...args: unknown[]) => MaybePromise<ServerResult<T>>;
249
+
250
+ export interface ServerNamespace {
251
+ run<T = unknown>(id: string, args?: unknown[], context?: Partial<ServerContext>): Promise<T>;
252
+ register?(id: string, fn: ServerFunction): string;
253
+ registerMany?(map?: Record<string, ServerFunction>): this;
254
+ unregister?(id: string): boolean;
255
+ resolve?(id: string): ServerFunction | undefined;
256
+ _setContext?(context?: Record<string, unknown>): this;
257
+ _withContext?(context?: Record<string, unknown>): ServerNamespace;
258
+ [key: string]: unknown;
259
+ }
260
+
261
+ export interface ServerProxyOptions {
262
+ endpoint?: string;
263
+ fetch?: typeof fetch;
264
+ signals?: SignalRegistry;
265
+ loader?: LoaderInstance;
266
+ router?: Router;
267
+ cache?: CacheRegistry;
268
+ scheduler?: Scheduler;
269
+ headers?: Record<string, string>;
270
+ }
271
+
272
+ export interface CacheDefinition {
273
+ readonly kind: "cache-definition";
274
+ store: string;
275
+ ttl?: number;
276
+ }
277
+
278
+ export interface CacheRegistry extends RegistryInspection<CacheDefinition> {
279
+ register(id: string, definition?: CacheDefinition | CacheDefinitionOptions): string;
280
+ registerMany(map?: Record<string, CacheDefinition | CacheDefinitionOptions>): this;
281
+ unregister(id: string): boolean;
282
+ resolve(id: string): CacheDefinition | undefined;
283
+ get<T = unknown>(key: string): T | undefined;
284
+ set<T = unknown>(key: string, value: T, options?: CacheSetOptions): T;
285
+ getOrSet<T = unknown>(key: string, fn: () => MaybePromise<T>, options?: CacheSetOptions): Promise<T>;
286
+ delete(key: string): boolean;
287
+ clear(prefix?: string): this;
288
+ snapshot(): Record<string, unknown>;
289
+ restore(snapshot?: Record<string, unknown>): this;
290
+ entryKeys(): string[];
291
+ entryEntries(): Array<[string, unknown]>;
292
+ }
293
+
294
+ export interface CacheDefinitionOptions {
295
+ store?: string;
296
+ ttl?: number;
297
+ }
298
+
299
+ export interface CacheSetOptions {
300
+ ttl?: number;
301
+ cache?: string;
302
+ }
303
+
304
+ export interface PartialContext {
305
+ id: string;
306
+ props: Record<string, unknown>;
307
+ params?: Record<string, string>;
308
+ route?: RouteDefinition;
309
+ signals?: SignalRegistry;
310
+ handlers?: HandlerRegistry;
311
+ server?: ServerNamespace;
312
+ cache?: CacheRegistry;
313
+ browserCache?: CacheRegistry;
314
+ partials: PartialRegistry;
315
+ abort?: AbortSignal;
316
+ scheduler?: Scheduler;
317
+ request?: Request;
318
+ locals?: unknown;
319
+ [key: string]: unknown;
320
+ }
321
+
322
+ export type PartialFunction = (this: PartialContext, props: Record<string, unknown>) => MaybePromise<TemplateLike | ServerEnvelope>;
323
+
324
+ export interface PartialRegistry extends RegistryInspection<PartialFunction> {
325
+ register(id: string, fn: PartialFunction): string;
326
+ registerMany(map?: Record<string, PartialFunction>): this;
327
+ unregister(id: string): boolean;
328
+ resolve(id: string): PartialFunction | undefined;
329
+ render(id: string, props?: Record<string, unknown>, context?: Partial<PartialContext>): Promise<ServerEnvelope>;
330
+ }
331
+
332
+ export interface RouteDefinition {
333
+ partial?: string;
334
+ load?: string;
335
+ [key: string]: unknown;
336
+ }
337
+
338
+ export interface RouteMatch {
339
+ pattern: string;
340
+ params: Record<string, string>;
341
+ route: RouteDefinition;
342
+ }
343
+
344
+ export interface RouteRegistry {
345
+ registry: RegistryStore;
346
+ register(pattern: string, definition: RouteDefinition | string): RouteMatch;
347
+ registerMany(map?: Record<string, RouteDefinition | string>): this;
348
+ unregister(pattern: string): boolean;
349
+ match(url: string | URL): RouteMatch | null;
350
+ entries(): Array<{ pattern: string; route: RouteDefinition }>;
351
+ keys(): string[];
352
+ inspect(): Array<[string, RouteDefinition]>;
353
+ }
354
+
355
+ export interface RouterOptions {
356
+ mode?: RouterMode;
357
+ root?: Document | Element;
358
+ boundary?: string;
359
+ routes?: RouteRegistry;
360
+ loader?: LoaderInstance;
361
+ signals?: SignalRegistry;
362
+ handlers?: HandlerRegistry;
363
+ server?: ServerNamespace;
364
+ cache?: CacheRegistry;
365
+ partials?: PartialRegistry;
366
+ fetch?: typeof fetch;
367
+ routeEndpoint?: string;
368
+ attributes?: AttributeConfig;
369
+ scheduler?: Scheduler;
370
+ }
371
+
372
+ export interface Router {
373
+ mode: RouterMode;
374
+ root: Document | Element;
375
+ boundary: string;
376
+ routes: RouteRegistry;
377
+ loader: LoaderInstance;
378
+ signals: SignalRegistry;
379
+ handlers: HandlerRegistry;
380
+ server?: ServerNamespace;
381
+ cache?: CacheRegistry;
382
+ partials?: PartialRegistry;
383
+ scheduler: Scheduler;
384
+ attributes: NormalizedAttributeConfig;
385
+ start(): this;
386
+ match(url: string | URL): RouteMatch | null;
387
+ prefetch(url: string | URL): Promise<unknown>;
388
+ navigate(url: string | URL, options?: { replace?: boolean; initial?: boolean; source?: string; history?: boolean }): Promise<unknown>;
389
+ destroy(): void;
390
+ }
391
+
392
+ export type LifecycleEventName = "attach" | "mount" | "visible" | "destroy";
393
+
394
+ export interface ComponentContext {
395
+ scope: string;
396
+ signals: SignalRegistry;
397
+ handlers: HandlerRegistry;
398
+ loader: LoaderInstance;
399
+ server?: ServerNamespace;
400
+ router?: Router;
401
+ cache?: CacheRegistry;
402
+ scheduler?: Scheduler;
403
+ signal<T = unknown>(initial: T): SignalRef<T>;
404
+ signal<T = unknown>(name: string, initial: T): SignalRef<T>;
405
+ computed<T = unknown>(name: string, fn: (this: ComponentContext) => T): SignalRef<T>;
406
+ asyncSignal<T = unknown>(name: string, fn: AsyncSignalFunction<T>): SignalRef<T>;
407
+ effect(fn: (this: ComponentContext) => unknown): Cleanup;
408
+ handler(fn: HandlerFunction): string;
409
+ handler(name: string, fn: HandlerFunction): string;
410
+ render<TProps extends Record<string, unknown> = Record<string, unknown>>(Child: ComponentFunction<TProps>, props?: TProps): TemplateLike;
411
+ suspense(signalRef: Pick<SignalRef, "id">, views: SuspenseViews | SuspenseReadyView): TemplateLike;
412
+ on(eventName: LifecycleEventName, fn: (this: ComponentContext, target?: Element) => unknown): void;
413
+ onMount(fn: (this: ComponentContext, target?: Element) => unknown): void;
414
+ onVisible(fn: (this: ComponentContext, target?: Element) => unknown): void;
415
+ }
416
+
417
+ export type ComponentFunction<TProps extends Record<string, unknown> = Record<string, unknown>> = (this: ComponentContext, props: TProps) => TemplateLike;
418
+ export type SuspenseReadyView = (this: ComponentContext, signalRef: Pick<SignalRef, "id">) => TemplateLike;
419
+ export interface SuspenseViews {
420
+ loading?: SuspenseReadyView;
421
+ ready?: SuspenseReadyView;
422
+ error?: SuspenseReadyView;
423
+ }
424
+
425
+ export interface ComponentRegistry extends RegistryInspection<ComponentFunction> {
426
+ register(id: string, Component: ComponentFunction): string;
427
+ registerMany(map?: Record<string, ComponentFunction>): this;
428
+ unregister(id: string): boolean;
429
+ resolve(id: string): ComponentFunction | undefined;
430
+ }
431
+
432
+ export interface LoaderOptions {
433
+ root?: Document | Element | DocumentFragment;
434
+ signals?: SignalRegistry;
435
+ handlers?: HandlerRegistry;
436
+ server?: ServerNamespace;
437
+ router?: Router;
438
+ cache?: CacheRegistry;
439
+ scheduler?: Scheduler;
440
+ attributes?: AttributeConfig;
441
+ }
442
+
443
+ export interface LoaderInstance {
444
+ root: Document | Element | DocumentFragment;
445
+ signals: SignalRegistry;
446
+ handlers: HandlerRegistry;
447
+ server?: ServerNamespace;
448
+ router?: Router;
449
+ cache?: CacheRegistry;
450
+ scheduler: Scheduler;
451
+ attributes: NormalizedAttributeConfig;
452
+ start(): this;
453
+ scan(rootOrFragment?: Document | Element | DocumentFragment): this;
454
+ swap(boundaryId: string, fragmentOrTemplate: TemplateLike): Element;
455
+ mount<TProps extends Record<string, unknown> = Record<string, unknown>>(target: Element, Component: ComponentFunction<TProps>, props?: TProps): unknown;
456
+ destroy(): void;
457
+ }
458
+
459
+ export type AsyncLoaderOptions = LoaderOptions;
460
+ export type AsyncLoaderInstance = LoaderInstance;
461
+
462
+ export interface BoundaryPatch {
463
+ boundary: string;
464
+ seq: number;
465
+ html?: TemplateLike;
466
+ signals?: Record<string, unknown>;
467
+ cache?: { browser?: Record<string, unknown> };
468
+ redirect?: string;
469
+ error?: unknown;
470
+ parentScope?: string;
471
+ scope?: string;
472
+ meta?: Record<string, unknown>;
473
+ }
474
+
475
+ export type BoundaryApplyResult =
476
+ | { status: "applied"; boundary: string; seq: number }
477
+ | { status: "ignored-stale"; boundary: string; seq: number; lastSeq: number }
478
+ | { status: "ignored-destroyed"; boundary: string; seq: number; parentScope?: string }
479
+ | { status: "redirected"; boundary: string; seq: number; redirect: string }
480
+ | { status: "errored"; boundary: string; seq: number; error: Error };
481
+
482
+ export interface BoundaryReceiverInspection {
483
+ destroyed: boolean;
484
+ boundaries: Record<string, { lastSeq: number; applied: number; ignored: number; errored?: number; lastStatus?: BoundaryApplyResult["status"] }>;
485
+ recent: Array<{ boundary: string; seq: number; status: BoundaryApplyResult["status"]; lastSeq?: number; parentScope?: string; redirect?: string }>;
486
+ }
487
+
488
+ export interface BoundaryReceiverOptions {
489
+ loader: LoaderInstance;
490
+ signals?: SignalRegistry;
491
+ cache?: CacheRegistry;
492
+ scheduler?: Scheduler;
493
+ router?: Router;
494
+ onApply?(result: BoundaryApplyResult, patch: BoundaryPatch): void;
495
+ onIgnore?(result: BoundaryApplyResult, patch: BoundaryPatch): void;
496
+ onError?(error: Error, result: BoundaryApplyResult, patch: BoundaryPatch): void;
497
+ throwOnError?: boolean;
498
+ recentLimit?: number;
499
+ isScopeDestroyed?(scope: string): boolean;
500
+ }
501
+
502
+ export interface BoundaryReceiver {
503
+ apply(patch: BoundaryPatch): Promise<BoundaryApplyResult>;
504
+ inspect(): BoundaryReceiverInspection;
505
+ reset(boundary?: string): this;
506
+ destroy(): void;
507
+ }
508
+
509
+ export interface RegistryStore {
510
+ target: RuntimeTarget;
511
+ register(type: RegistryType, id: string, value: unknown): string;
512
+ registerMany(type: RegistryType, map?: Record<string, unknown>): this;
513
+ set(type: RegistryType, id: string, value: unknown): unknown;
514
+ unregister(type: RegistryType, id: string): boolean;
515
+ delete(type: RegistryType, id: string): boolean;
516
+ keys(type: RegistryType, options?: Record<string, unknown>): string[];
517
+ entries(type: RegistryType, options?: Record<string, unknown>): Array<[string, unknown]>;
518
+ has(type: RegistryType, id: string, options?: Record<string, unknown>): boolean;
519
+ get(type: RegistryType, id: string, options?: Record<string, unknown>): unknown;
520
+ snapshot(options?: { target?: RuntimeTarget }): RegistrySnapshot;
521
+ rawSnapshot(): AppDefinition;
522
+ view(options?: { target?: RuntimeTarget }): RegistryStore;
523
+ }
524
+
525
+ export interface RegistrySnapshot {
526
+ signal: Record<string, unknown>;
527
+ handler: Record<string, { id: string; kind: "handler" }>;
528
+ server: Record<string, { id: string; kind: "server" }>;
529
+ partial: Record<string, { id: string; kind: "partial" }>;
530
+ route: Record<string, RouteDefinition>;
531
+ component: Record<string, { id: string; kind: "component" }>;
532
+ cache: { browser: Record<string, CacheDefinition>; server: Record<string, CacheDefinition> };
533
+ entries: { browser: Record<string, unknown>; server: Record<string, unknown> };
534
+ }
535
+
536
+ export interface AppDefinition {
537
+ signal?: SignalMap;
538
+ handler?: Record<string, HandlerFunction>;
539
+ server?: Record<string, ServerFunction>;
540
+ partial?: Record<string, PartialFunction>;
541
+ route?: Record<string, RouteDefinition | string>;
542
+ component?: Record<string, ComponentFunction>;
543
+ cache?: {
544
+ browser?: Record<string, CacheDefinition | CacheDefinitionOptions>;
545
+ server?: Record<string, CacheDefinition | CacheDefinitionOptions>;
546
+ };
547
+ entries?: { browser?: Record<string, unknown>; server?: Record<string, unknown> };
548
+ }
549
+
550
+ export interface AppHub {
551
+ registry: RegistryStore;
552
+ runtime?: AppRuntime;
553
+ use(type: "signal", entries: SignalMap): this;
554
+ use(type: "handler", entries: Record<string, HandlerFunction>): this;
555
+ use(type: "server", entries: Record<string, ServerFunction>): this;
556
+ use(type: "partial", entries: Record<string, PartialFunction>): this;
557
+ use(type: "route", entries: Record<string, RouteDefinition | string>): this;
558
+ use(type: "component", entries: Record<string, ComponentFunction>): this;
559
+ use(moduleObject: AppDefinition): this;
560
+ snapshot(): AppDefinition;
561
+ start(options?: CreateAppOptions): AppRuntime;
562
+ }
563
+
564
+ export interface CreateAppOptions extends LoaderOptions {
565
+ target?: RuntimeTarget;
566
+ mode?: RouterMode;
567
+ boundary?: string;
568
+ snapshot?: { signals?: Record<string, unknown>; cache?: { browser?: Record<string, unknown> } };
569
+ registry?: RegistryStore;
570
+ loader?: LoaderInstance;
571
+ router?: Router | false;
572
+ routes?: RouteRegistry;
573
+ partials?: PartialRegistry;
574
+ components?: ComponentRegistry;
575
+ fetch?: typeof fetch;
576
+ routeEndpoint?: string;
577
+ request?: Request;
578
+ locals?: unknown;
579
+ requestContext?: RequestContextStore;
580
+ scheduler?: Scheduler;
581
+ }
582
+
583
+ export interface RenderResult {
584
+ html: string;
585
+ status: number;
586
+ signals: Record<string, unknown>;
587
+ cache: { browser: Record<string, unknown> };
588
+ }
589
+
590
+ export interface AppRuntime {
591
+ app: AppHub;
592
+ registry: RegistryStore;
593
+ target: RuntimeTarget;
594
+ signals: SignalRegistry;
595
+ handlers: HandlerRegistry;
596
+ server: ServerNamespace & { cache: CacheRegistry };
597
+ partials: PartialRegistry;
598
+ routes: RouteRegistry;
599
+ components: ComponentRegistry;
600
+ browser: { cache: CacheRegistry };
601
+ loader?: LoaderInstance;
602
+ router?: Router;
603
+ scheduler: Scheduler;
604
+ attributes: NormalizedAttributeConfig;
605
+ start(): this;
606
+ use(type: Parameters<AppHub["use"]>[0], entries?: unknown): this;
607
+ render(url: string | URL): Promise<RenderResult>;
608
+ destroy(): void;
609
+ }
610
+
611
+ export interface AsyncNamespace extends AppHub {
612
+ Async: AsyncNamespace;
613
+ asyncSignal: typeof asyncSignal;
614
+ createApp: typeof createApp;
615
+ defineApp: typeof defineApp;
616
+ readSnapshot: typeof readSnapshot;
617
+ attributeName: typeof attributeName;
618
+ defineAttributeConfig: typeof defineAttributeConfig;
619
+ createBoundaryReceiver: typeof createBoundaryReceiver;
620
+ createCacheRegistry: typeof createCacheRegistry;
621
+ defineCache: typeof defineCache;
622
+ component: typeof component;
623
+ createComponentRegistry: typeof createComponentRegistry;
624
+ defineComponent: typeof defineComponent;
625
+ delay: typeof delay;
626
+ createHandlerRegistry: typeof createHandlerRegistry;
627
+ html: typeof html;
628
+ Loader: typeof Loader;
629
+ AsyncLoader: typeof Loader;
630
+ createPartialRegistry: typeof createPartialRegistry;
631
+ createRegistryStore: typeof createRegistryStore;
632
+ createRouteRegistry: typeof createRouteRegistry;
633
+ createRouter: typeof createRouter;
634
+ createScheduler: typeof createScheduler;
635
+ defineRoute: typeof defineRoute;
636
+ route: typeof route;
637
+ applyServerResult: typeof applyServerResult;
638
+ createServerProxy: typeof createServerProxy;
639
+ createServerRegistry: typeof createServerRegistry;
640
+ createRequestContextStore: typeof createRequestContextStore;
641
+ resolveServerCommandArguments: typeof resolveServerCommandArguments;
642
+ unwrapServerResult: typeof unwrapServerResult;
643
+ computed: typeof computed;
644
+ createSignal: typeof createSignal;
645
+ createSignalRegistry: typeof createSignalRegistry;
646
+ effect: typeof effect;
647
+ signal: typeof signal;
648
+ }
649
+
650
+ export declare function asyncSignal<T = unknown>(id: string, fn: AsyncSignalFunction<T>): AsyncSignal<T>;
651
+ export declare const Async: AppHub;
652
+ export declare function createApp(appOrDefinition?: AppHub | AppDefinition, options?: CreateAppOptions): AppRuntime;
653
+ export declare function defineApp(initial?: AppDefinition): AppHub;
654
+ export declare function readSnapshot(root?: Document | Element, options?: { attributes?: AttributeConfig }): { signals?: Record<string, unknown>; cache?: { browser?: Record<string, unknown> } };
655
+ export declare function attributeName(attributes: AttributeConfig | undefined, type: keyof NormalizedAttributeConfig, name: string): string;
656
+ export declare function defineAttributeConfig(config?: AttributeConfig): NormalizedAttributeConfig;
657
+ export declare function createBoundaryReceiver(options: BoundaryReceiverOptions): BoundaryReceiver;
658
+ export declare function createCacheRegistry(initialMap?: Record<string, CacheDefinition | CacheDefinitionOptions>, options?: { now?: () => number; registry?: RegistryStore; type?: "cache.browser" | "cache.server" }): CacheRegistry;
659
+ export declare function defineCache(options?: CacheDefinitionOptions): CacheDefinition;
660
+ export declare function component<TProps extends Record<string, unknown> = Record<string, unknown>>(fn: ComponentFunction<TProps>): ComponentFunction<TProps>;
661
+ export declare function createComponentRegistry(initialMap?: Record<string, ComponentFunction>, options?: { registry?: RegistryStore; type?: "component" }): ComponentRegistry;
662
+ export declare function defineComponent<TProps extends Record<string, unknown> = Record<string, unknown>>(fn: ComponentFunction<TProps>): ComponentFunction<TProps>;
663
+ export declare function delay(ms: number, signal?: AbortSignal): Promise<void>;
664
+ export declare function createHandlerRegistry(initialMap?: Record<string, HandlerFunction>, options?: { registry?: RegistryStore; type?: "handler" }): HandlerRegistry;
665
+ export declare function html(strings: TemplateStringsArray, ...values: unknown[]): TemplateResult;
666
+ export declare function Loader(options?: LoaderOptions): LoaderInstance;
667
+ export declare const AsyncLoader: typeof Loader;
668
+ export declare function createPartialRegistry(initialMap?: Record<string, PartialFunction>, options?: { registry?: RegistryStore; type?: "partial" }): PartialRegistry;
669
+ export declare function createRegistryStore(initial?: AppDefinition, options?: { target?: RuntimeTarget; backing?: unknown }): RegistryStore;
670
+ export declare function createRouteRegistry(initialMap?: Record<string, RouteDefinition | string>, options?: { registry?: RegistryStore; type?: "route" }): RouteRegistry;
671
+ export declare function createRouter(options?: RouterOptions): Router;
672
+ export declare function createScheduler(options?: SchedulerOptions): Scheduler;
673
+ export declare function defineRoute(partial: string, options?: Omit<RouteDefinition, "partial">): RouteDefinition;
674
+ export declare const route: typeof defineRoute;
675
+ export declare function applyServerResult(result: unknown, context?: Record<string, unknown>): Promise<unknown>;
676
+ export declare function createServerProxy(options?: ServerProxyOptions): ServerNamespace;
677
+ export declare function createServerRegistry(initialMap?: Record<string, ServerFunction>, options?: { registry?: RegistryStore; type?: "server" }): ServerNamespace;
678
+ export declare function createRequestContextStore(): RequestContextStore;
679
+ export declare function resolveServerCommandArguments(args: Array<{ type: "local"; name: string } | { type: "signal"; path: string }>, context?: Record<string, unknown>): { args: unknown[]; signalValues: Record<string, unknown>; signalPaths: string[] };
680
+ export declare function unwrapServerResult<T = unknown>(result: ServerResult<T>): T | ServerResult<T>;
681
+ export declare function computed<T = unknown>(fn: (this: { signals: SignalRegistry; id: string; server?: ServerNamespace; router?: Router; loader?: LoaderInstance; cache?: CacheRegistry; scheduler?: Scheduler }) => T): ComputedSignal<T>;
682
+ export declare function createSignal<T = unknown>(initial: T): Signal<T>;
683
+ export declare function createSignalRegistry(initialMap?: SignalMap, options?: { registry?: RegistryStore; type?: "signal" }): SignalRegistry;
684
+ export declare function effect(fn: () => unknown): EffectDefinition;
685
+ export declare const signal: typeof createSignal;
686
+
687
+ declare global {
688
+ const Async: AsyncNamespace;
689
+ const AsyncFramework: AsyncNamespace;
690
+ }