@async/framework 0.5.0 → 0.6.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/framework.d.ts ADDED
@@ -0,0 +1,569 @@
1
+ // Generated by scripts/build-framework-bundle.js. Do not edit by hand.
2
+ // Public 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 interface Signal<T = unknown> {
44
+ readonly kind: "signal";
45
+ value: T;
46
+ set(value: T): T;
47
+ update(fn: (value: T) => T): T;
48
+ subscribe(fn: (value: T) => void): Cleanup;
49
+ snapshot(): T;
50
+ }
51
+
52
+ export interface ComputedSignal<T = unknown> extends Omit<Signal<T>, "kind"> {
53
+ readonly kind: "computed";
54
+ }
55
+
56
+ export interface EffectDefinition {
57
+ readonly kind: "effect";
58
+ readonly fn: () => unknown;
59
+ }
60
+
61
+ export interface AsyncSignalSnapshot<T = unknown> {
62
+ value: T | undefined;
63
+ loading: boolean;
64
+ error: unknown;
65
+ status: AsyncSignalStatus;
66
+ version: number;
67
+ }
68
+
69
+ export interface AsyncSignal<T = unknown> extends Omit<Signal<T | undefined>, "kind" | "snapshot"> {
70
+ readonly kind: "async-signal";
71
+ readonly id: string;
72
+ readonly loading: boolean;
73
+ readonly error: unknown;
74
+ readonly status: AsyncSignalStatus;
75
+ readonly version: number;
76
+ refresh(): Promise<T | undefined>;
77
+ cancel(reason?: unknown): void;
78
+ snapshot(): AsyncSignalSnapshot<T>;
79
+ }
80
+
81
+ export interface SignalRef<T = unknown> {
82
+ readonly kind: "signal-ref";
83
+ readonly id: string;
84
+ value: T;
85
+ readonly loading: boolean;
86
+ readonly error: unknown;
87
+ readonly status: AsyncSignalStatus;
88
+ readonly version: number;
89
+ get(): T;
90
+ set(value: T): T;
91
+ update(fn: (value: T) => T): T;
92
+ subscribe(fn: (value: T, info?: SignalSubscriptionInfo) => void): Cleanup;
93
+ refresh(): Promise<T | undefined>;
94
+ cancel(reason?: unknown): void;
95
+ toString(): string;
96
+ }
97
+
98
+ export interface SignalSubscriptionInfo {
99
+ id: string;
100
+ path: string;
101
+ signal: unknown;
102
+ }
103
+
104
+ export type SignalLike<T = unknown> = Signal<T> | AsyncSignal<T> | ComputedSignal<T>;
105
+ export type SignalMap = Record<string, SignalLike | unknown>;
106
+
107
+ export interface AsyncSignalContext {
108
+ signals: SignalRegistry;
109
+ id: string;
110
+ version: number;
111
+ abort: AbortSignal & { cancel?(reason?: unknown): void };
112
+ server?: ServerNamespace;
113
+ router?: Router;
114
+ loader?: LoaderInstance;
115
+ cache?: CacheRegistry;
116
+ refresh(): Promise<unknown>;
117
+ }
118
+
119
+ export type AsyncSignalFunction<T = unknown> = (this: AsyncSignalContext) => MaybePromise<T>;
120
+
121
+ export interface RegistryInspection<T = unknown> {
122
+ registry: RegistryStore;
123
+ keys(): string[];
124
+ entries(): Array<[string, T]>;
125
+ inspect(): Array<[string, T]>;
126
+ }
127
+
128
+ export interface SignalRegistry extends RegistryInspection {
129
+ register<T = unknown>(id: string, signalLike: SignalLike<T> | T): SignalRef<T>;
130
+ registerMany(map?: SignalMap): this;
131
+ unregister(id: string): boolean;
132
+ ensure<T = unknown>(id: string, initial: T): SignalRef<T>;
133
+ has(id: string): boolean;
134
+ get<T = unknown>(path: string): T;
135
+ set<T = unknown>(path: string, value: T): T;
136
+ update<T = unknown>(path: string, fn: (value: T) => T): T;
137
+ ref<T = unknown>(id: string): SignalRef<T>;
138
+ subscribe<T = unknown>(path: string, fn: (value: T, info: SignalSubscriptionInfo) => void): Cleanup;
139
+ snapshot(): Record<string, unknown>;
140
+ asyncSignal<T = unknown>(id: string, fn: AsyncSignalFunction<T>): SignalRef<T>;
141
+ effect(fn: () => unknown): Cleanup;
142
+ destroy(): void;
143
+ }
144
+
145
+ export interface HandlerContext {
146
+ signals: SignalRegistry;
147
+ handlers: HandlerRegistry;
148
+ server?: ServerNamespace;
149
+ loader?: LoaderInstance;
150
+ router?: Router;
151
+ cache?: CacheRegistry;
152
+ event?: Event;
153
+ element?: Element;
154
+ el?: Element;
155
+ root?: Document | Element;
156
+ input?: unknown;
157
+ stop(): void;
158
+ [key: string]: unknown;
159
+ }
160
+
161
+ export type HandlerFunction = (this: HandlerContext, context: HandlerContext) => MaybePromise<unknown>;
162
+
163
+ export interface HandlerRegistry extends RegistryInspection<HandlerFunction> {
164
+ register(id: string, fn: HandlerFunction): string;
165
+ registerMany(map?: Record<string, HandlerFunction>): this;
166
+ unregister(id: string): boolean;
167
+ resolve(id: string): HandlerFunction | undefined;
168
+ run(ref: string, context?: Partial<HandlerContext>): Promise<unknown[]>;
169
+ }
170
+
171
+ export interface ServerEnvelope<T = unknown> {
172
+ value?: T;
173
+ signals?: Record<string, unknown>;
174
+ boundary?: string;
175
+ html?: TemplateLike;
176
+ redirect?: string;
177
+ error?: unknown;
178
+ status?: number;
179
+ cache?: { browser?: Record<string, unknown>; server?: Record<string, unknown> };
180
+ }
181
+
182
+ export type ServerResult<T = unknown> = T | ServerEnvelope<T>;
183
+
184
+ export interface ServerContext {
185
+ id: string;
186
+ args: unknown[];
187
+ input?: unknown;
188
+ signals?: SignalRegistry | { get(path: string): unknown; snapshot?(): Record<string, unknown> };
189
+ request?: Request;
190
+ headers?: Headers;
191
+ cookies?: unknown;
192
+ locals?: unknown;
193
+ abort?: AbortSignal;
194
+ cache?: CacheRegistry;
195
+ server: ServerNamespace;
196
+ [key: string]: unknown;
197
+ }
198
+
199
+ export type ServerFunction<T = unknown> = (this: ServerContext, ...args: unknown[]) => MaybePromise<ServerResult<T>>;
200
+
201
+ export interface ServerNamespace {
202
+ run<T = unknown>(id: string, args?: unknown[], context?: Partial<ServerContext>): Promise<T>;
203
+ register?(id: string, fn: ServerFunction): string;
204
+ registerMany?(map?: Record<string, ServerFunction>): this;
205
+ unregister?(id: string): boolean;
206
+ resolve?(id: string): ServerFunction | undefined;
207
+ _setContext?(context?: Record<string, unknown>): this;
208
+ _withContext?(context?: Record<string, unknown>): ServerNamespace;
209
+ [key: string]: unknown;
210
+ }
211
+
212
+ export interface ServerProxyOptions {
213
+ endpoint?: string;
214
+ fetch?: typeof fetch;
215
+ signals?: SignalRegistry;
216
+ loader?: LoaderInstance;
217
+ router?: Router;
218
+ cache?: CacheRegistry;
219
+ headers?: Record<string, string>;
220
+ }
221
+
222
+ export interface CacheDefinition {
223
+ readonly kind: "cache-definition";
224
+ store: string;
225
+ ttl?: number;
226
+ }
227
+
228
+ export interface CacheRegistry extends RegistryInspection<CacheDefinition> {
229
+ register(id: string, definition?: CacheDefinition | CacheDefinitionOptions): string;
230
+ registerMany(map?: Record<string, CacheDefinition | CacheDefinitionOptions>): this;
231
+ unregister(id: string): boolean;
232
+ resolve(id: string): CacheDefinition | undefined;
233
+ get<T = unknown>(key: string): T | undefined;
234
+ set<T = unknown>(key: string, value: T, options?: CacheSetOptions): T;
235
+ getOrSet<T = unknown>(key: string, fn: () => MaybePromise<T>, options?: CacheSetOptions): Promise<T>;
236
+ delete(key: string): boolean;
237
+ clear(prefix?: string): this;
238
+ snapshot(): Record<string, unknown>;
239
+ restore(snapshot?: Record<string, unknown>): this;
240
+ entryKeys(): string[];
241
+ entryEntries(): Array<[string, unknown]>;
242
+ }
243
+
244
+ export interface CacheDefinitionOptions {
245
+ store?: string;
246
+ ttl?: number;
247
+ }
248
+
249
+ export interface CacheSetOptions {
250
+ ttl?: number;
251
+ cache?: string;
252
+ }
253
+
254
+ export interface PartialContext {
255
+ id: string;
256
+ props: Record<string, unknown>;
257
+ params?: Record<string, string>;
258
+ route?: RouteDefinition;
259
+ signals?: SignalRegistry;
260
+ handlers?: HandlerRegistry;
261
+ server?: ServerNamespace;
262
+ cache?: CacheRegistry;
263
+ browserCache?: CacheRegistry;
264
+ partials: PartialRegistry;
265
+ request?: Request;
266
+ locals?: unknown;
267
+ [key: string]: unknown;
268
+ }
269
+
270
+ export type PartialFunction = (this: PartialContext, props: Record<string, unknown>) => MaybePromise<TemplateLike | ServerEnvelope>;
271
+
272
+ export interface PartialRegistry extends RegistryInspection<PartialFunction> {
273
+ register(id: string, fn: PartialFunction): string;
274
+ registerMany(map?: Record<string, PartialFunction>): this;
275
+ unregister(id: string): boolean;
276
+ resolve(id: string): PartialFunction | undefined;
277
+ render(id: string, props?: Record<string, unknown>, context?: Partial<PartialContext>): Promise<ServerEnvelope>;
278
+ }
279
+
280
+ export interface RouteDefinition {
281
+ partial?: string;
282
+ load?: string;
283
+ [key: string]: unknown;
284
+ }
285
+
286
+ export interface RouteMatch {
287
+ pattern: string;
288
+ params: Record<string, string>;
289
+ route: RouteDefinition;
290
+ }
291
+
292
+ export interface RouteRegistry {
293
+ registry: RegistryStore;
294
+ register(pattern: string, definition: RouteDefinition | string): RouteMatch;
295
+ registerMany(map?: Record<string, RouteDefinition | string>): this;
296
+ unregister(pattern: string): boolean;
297
+ match(url: string | URL): RouteMatch | null;
298
+ entries(): Array<{ pattern: string; route: RouteDefinition }>;
299
+ keys(): string[];
300
+ inspect(): Array<[string, RouteDefinition]>;
301
+ }
302
+
303
+ export interface RouterOptions {
304
+ mode?: RouterMode;
305
+ root?: Document | Element;
306
+ boundary?: string;
307
+ routes?: RouteRegistry;
308
+ loader?: LoaderInstance;
309
+ signals?: SignalRegistry;
310
+ handlers?: HandlerRegistry;
311
+ server?: ServerNamespace;
312
+ cache?: CacheRegistry;
313
+ partials?: PartialRegistry;
314
+ fetch?: typeof fetch;
315
+ routeEndpoint?: string;
316
+ attributes?: AttributeConfig;
317
+ }
318
+
319
+ export interface Router {
320
+ mode: RouterMode;
321
+ root: Document | Element;
322
+ boundary: string;
323
+ routes: RouteRegistry;
324
+ loader: LoaderInstance;
325
+ signals: SignalRegistry;
326
+ handlers: HandlerRegistry;
327
+ server?: ServerNamespace;
328
+ cache?: CacheRegistry;
329
+ partials?: PartialRegistry;
330
+ attributes: NormalizedAttributeConfig;
331
+ start(): this;
332
+ match(url: string | URL): RouteMatch | null;
333
+ prefetch(url: string | URL): Promise<unknown>;
334
+ navigate(url: string | URL, options?: { replace?: boolean; initial?: boolean; source?: string; history?: boolean }): Promise<unknown>;
335
+ destroy(): void;
336
+ }
337
+
338
+ export type LifecycleEventName = "attach" | "mount" | "visible" | "destroy";
339
+
340
+ export interface ComponentContext {
341
+ scope: string;
342
+ signals: SignalRegistry;
343
+ handlers: HandlerRegistry;
344
+ loader: LoaderInstance;
345
+ server?: ServerNamespace;
346
+ router?: Router;
347
+ cache?: CacheRegistry;
348
+ signal<T = unknown>(initial: T): SignalRef<T>;
349
+ signal<T = unknown>(name: string, initial: T): SignalRef<T>;
350
+ computed<T = unknown>(name: string, fn: (this: ComponentContext) => T): SignalRef<T>;
351
+ asyncSignal<T = unknown>(name: string, fn: AsyncSignalFunction<T>): SignalRef<T>;
352
+ effect(fn: (this: ComponentContext) => unknown): Cleanup;
353
+ handler(fn: HandlerFunction): string;
354
+ handler(name: string, fn: HandlerFunction): string;
355
+ render<TProps extends Record<string, unknown> = Record<string, unknown>>(Child: ComponentFunction<TProps>, props?: TProps): TemplateLike;
356
+ suspense(signalRef: Pick<SignalRef, "id">, views: SuspenseViews | SuspenseReadyView): TemplateLike;
357
+ on(eventName: LifecycleEventName, fn: (this: ComponentContext, target?: Element) => unknown): void;
358
+ onMount(fn: (this: ComponentContext, target?: Element) => unknown): void;
359
+ onVisible(fn: (this: ComponentContext, target?: Element) => unknown): void;
360
+ }
361
+
362
+ export type ComponentFunction<TProps extends Record<string, unknown> = Record<string, unknown>> = (this: ComponentContext, props: TProps) => TemplateLike;
363
+ export type SuspenseReadyView = (this: ComponentContext, signalRef: Pick<SignalRef, "id">) => TemplateLike;
364
+ export interface SuspenseViews {
365
+ loading?: SuspenseReadyView;
366
+ ready?: SuspenseReadyView;
367
+ error?: SuspenseReadyView;
368
+ }
369
+
370
+ export interface ComponentRegistry extends RegistryInspection<ComponentFunction> {
371
+ register(id: string, Component: ComponentFunction): string;
372
+ registerMany(map?: Record<string, ComponentFunction>): this;
373
+ unregister(id: string): boolean;
374
+ resolve(id: string): ComponentFunction | undefined;
375
+ }
376
+
377
+ export interface LoaderOptions {
378
+ root?: Document | Element | DocumentFragment;
379
+ signals?: SignalRegistry;
380
+ handlers?: HandlerRegistry;
381
+ server?: ServerNamespace;
382
+ router?: Router;
383
+ cache?: CacheRegistry;
384
+ attributes?: AttributeConfig;
385
+ }
386
+
387
+ export interface LoaderInstance {
388
+ root: Document | Element | DocumentFragment;
389
+ signals: SignalRegistry;
390
+ handlers: HandlerRegistry;
391
+ server?: ServerNamespace;
392
+ router?: Router;
393
+ cache?: CacheRegistry;
394
+ attributes: NormalizedAttributeConfig;
395
+ start(): this;
396
+ scan(rootOrFragment?: Document | Element | DocumentFragment): this;
397
+ swap(boundaryId: string, fragmentOrTemplate: TemplateLike): Element;
398
+ mount<TProps extends Record<string, unknown> = Record<string, unknown>>(target: Element, Component: ComponentFunction<TProps>, props?: TProps): unknown;
399
+ destroy(): void;
400
+ }
401
+
402
+ export type AsyncLoaderOptions = LoaderOptions;
403
+ export type AsyncLoaderInstance = LoaderInstance;
404
+
405
+ export interface RegistryStore {
406
+ target: RuntimeTarget;
407
+ register(type: RegistryType, id: string, value: unknown): string;
408
+ registerMany(type: RegistryType, map?: Record<string, unknown>): this;
409
+ set(type: RegistryType, id: string, value: unknown): unknown;
410
+ unregister(type: RegistryType, id: string): boolean;
411
+ delete(type: RegistryType, id: string): boolean;
412
+ keys(type: RegistryType, options?: Record<string, unknown>): string[];
413
+ entries(type: RegistryType, options?: Record<string, unknown>): Array<[string, unknown]>;
414
+ has(type: RegistryType, id: string, options?: Record<string, unknown>): boolean;
415
+ get(type: RegistryType, id: string, options?: Record<string, unknown>): unknown;
416
+ snapshot(options?: { target?: RuntimeTarget }): RegistrySnapshot;
417
+ rawSnapshot(): AppDefinition;
418
+ view(options?: { target?: RuntimeTarget }): RegistryStore;
419
+ }
420
+
421
+ export interface RegistrySnapshot {
422
+ signal: Record<string, unknown>;
423
+ handler: Record<string, { id: string; kind: "handler" }>;
424
+ server: Record<string, { id: string; kind: "server" }>;
425
+ partial: Record<string, { id: string; kind: "partial" }>;
426
+ route: Record<string, RouteDefinition>;
427
+ component: Record<string, { id: string; kind: "component" }>;
428
+ cache: { browser: Record<string, CacheDefinition>; server: Record<string, CacheDefinition> };
429
+ entries: { browser: Record<string, unknown>; server: Record<string, unknown> };
430
+ }
431
+
432
+ export interface AppDefinition {
433
+ signal?: SignalMap;
434
+ handler?: Record<string, HandlerFunction>;
435
+ server?: Record<string, ServerFunction>;
436
+ partial?: Record<string, PartialFunction>;
437
+ route?: Record<string, RouteDefinition | string>;
438
+ component?: Record<string, ComponentFunction>;
439
+ cache?: {
440
+ browser?: Record<string, CacheDefinition | CacheDefinitionOptions>;
441
+ server?: Record<string, CacheDefinition | CacheDefinitionOptions>;
442
+ };
443
+ entries?: { browser?: Record<string, unknown>; server?: Record<string, unknown> };
444
+ }
445
+
446
+ export interface AppHub {
447
+ registry: RegistryStore;
448
+ runtime?: AppRuntime;
449
+ use(type: "signal", entries: SignalMap): this;
450
+ use(type: "handler", entries: Record<string, HandlerFunction>): this;
451
+ use(type: "server", entries: Record<string, ServerFunction>): this;
452
+ use(type: "partial", entries: Record<string, PartialFunction>): this;
453
+ use(type: "route", entries: Record<string, RouteDefinition | string>): this;
454
+ use(type: "component", entries: Record<string, ComponentFunction>): this;
455
+ use(moduleObject: AppDefinition): this;
456
+ snapshot(): AppDefinition;
457
+ start(options?: CreateAppOptions): AppRuntime;
458
+ }
459
+
460
+ export interface CreateAppOptions extends LoaderOptions {
461
+ target?: RuntimeTarget;
462
+ mode?: RouterMode;
463
+ boundary?: string;
464
+ snapshot?: { signals?: Record<string, unknown>; cache?: { browser?: Record<string, unknown> } };
465
+ registry?: RegistryStore;
466
+ loader?: LoaderInstance;
467
+ router?: Router | false;
468
+ routes?: RouteRegistry;
469
+ partials?: PartialRegistry;
470
+ components?: ComponentRegistry;
471
+ fetch?: typeof fetch;
472
+ routeEndpoint?: string;
473
+ request?: Request;
474
+ locals?: unknown;
475
+ }
476
+
477
+ export interface RenderResult {
478
+ html: string;
479
+ status: number;
480
+ signals: Record<string, unknown>;
481
+ cache: { browser: Record<string, unknown> };
482
+ }
483
+
484
+ export interface AppRuntime {
485
+ app: AppHub;
486
+ registry: RegistryStore;
487
+ target: RuntimeTarget;
488
+ signals: SignalRegistry;
489
+ handlers: HandlerRegistry;
490
+ server: ServerNamespace & { cache: CacheRegistry };
491
+ partials: PartialRegistry;
492
+ routes: RouteRegistry;
493
+ components: ComponentRegistry;
494
+ browser: { cache: CacheRegistry };
495
+ loader?: LoaderInstance;
496
+ router?: Router;
497
+ attributes: NormalizedAttributeConfig;
498
+ start(): this;
499
+ use(type: Parameters<AppHub["use"]>[0], entries?: unknown): this;
500
+ render(url: string | URL): Promise<RenderResult>;
501
+ destroy(): void;
502
+ }
503
+
504
+ export interface AsyncNamespace extends AppHub {
505
+ Async: AsyncNamespace;
506
+ asyncSignal: typeof asyncSignal;
507
+ createApp: typeof createApp;
508
+ defineApp: typeof defineApp;
509
+ attributeName: typeof attributeName;
510
+ defineAttributeConfig: typeof defineAttributeConfig;
511
+ createCacheRegistry: typeof createCacheRegistry;
512
+ defineCache: typeof defineCache;
513
+ component: typeof component;
514
+ createComponentRegistry: typeof createComponentRegistry;
515
+ defineComponent: typeof defineComponent;
516
+ delay: typeof delay;
517
+ createHandlerRegistry: typeof createHandlerRegistry;
518
+ html: typeof html;
519
+ Loader: typeof Loader;
520
+ AsyncLoader: typeof Loader;
521
+ createPartialRegistry: typeof createPartialRegistry;
522
+ createRegistryStore: typeof createRegistryStore;
523
+ createRouteRegistry: typeof createRouteRegistry;
524
+ createRouter: typeof createRouter;
525
+ defineRoute: typeof defineRoute;
526
+ route: typeof route;
527
+ createServerProxy: typeof createServerProxy;
528
+ createServerRegistry: typeof createServerRegistry;
529
+ computed: typeof computed;
530
+ createSignal: typeof createSignal;
531
+ createSignalRegistry: typeof createSignalRegistry;
532
+ effect: typeof effect;
533
+ signal: typeof signal;
534
+ }
535
+
536
+ export declare function asyncSignal<T = unknown>(id: string, fn: AsyncSignalFunction<T>): AsyncSignal<T>;
537
+ export declare const Async: AppHub;
538
+ export declare function createApp(appOrDefinition?: AppHub | AppDefinition, options?: CreateAppOptions): AppRuntime;
539
+ export declare function defineApp(initial?: AppDefinition): AppHub;
540
+ export declare function attributeName(attributes: AttributeConfig | undefined, type: keyof NormalizedAttributeConfig, name: string): string;
541
+ export declare function defineAttributeConfig(config?: AttributeConfig): NormalizedAttributeConfig;
542
+ export declare function createCacheRegistry(initialMap?: Record<string, CacheDefinition | CacheDefinitionOptions>, options?: { now?: () => number; registry?: RegistryStore; type?: "cache.browser" | "cache.server" }): CacheRegistry;
543
+ export declare function defineCache(options?: CacheDefinitionOptions): CacheDefinition;
544
+ export declare function component<TProps extends Record<string, unknown> = Record<string, unknown>>(fn: ComponentFunction<TProps>): ComponentFunction<TProps>;
545
+ export declare function createComponentRegistry(initialMap?: Record<string, ComponentFunction>, options?: { registry?: RegistryStore; type?: "component" }): ComponentRegistry;
546
+ export declare function defineComponent<TProps extends Record<string, unknown> = Record<string, unknown>>(fn: ComponentFunction<TProps>): ComponentFunction<TProps>;
547
+ export declare function delay(ms: number, signal?: AbortSignal): Promise<void>;
548
+ export declare function createHandlerRegistry(initialMap?: Record<string, HandlerFunction>, options?: { registry?: RegistryStore; type?: "handler" }): HandlerRegistry;
549
+ export declare function html(strings: TemplateStringsArray, ...values: unknown[]): TemplateResult;
550
+ export declare function Loader(options?: LoaderOptions): LoaderInstance;
551
+ export declare const AsyncLoader: typeof Loader;
552
+ export declare function createPartialRegistry(initialMap?: Record<string, PartialFunction>, options?: { registry?: RegistryStore; type?: "partial" }): PartialRegistry;
553
+ export declare function createRegistryStore(initial?: AppDefinition, options?: { target?: RuntimeTarget; backing?: unknown }): RegistryStore;
554
+ export declare function createRouteRegistry(initialMap?: Record<string, RouteDefinition | string>, options?: { registry?: RegistryStore; type?: "route" }): RouteRegistry;
555
+ export declare function createRouter(options?: RouterOptions): Router;
556
+ export declare function defineRoute(partial: string, options?: Omit<RouteDefinition, "partial">): RouteDefinition;
557
+ export declare const route: typeof defineRoute;
558
+ export declare function createServerProxy(options?: ServerProxyOptions): ServerNamespace;
559
+ export declare function createServerRegistry(initialMap?: Record<string, ServerFunction>, options?: { registry?: RegistryStore; type?: "server" }): ServerNamespace;
560
+ export declare function computed<T = unknown>(fn: (this: { signals: SignalRegistry; id: string; server?: ServerNamespace; router?: Router; loader?: LoaderInstance; cache?: CacheRegistry }) => T): ComputedSignal<T>;
561
+ export declare function createSignal<T = unknown>(initial: T): Signal<T>;
562
+ export declare function createSignalRegistry(initialMap?: SignalMap, options?: { registry?: RegistryStore; type?: "signal" }): SignalRegistry;
563
+ export declare function effect(fn: () => unknown): EffectDefinition;
564
+ export declare const signal: typeof createSignal;
565
+
566
+ declare global {
567
+ const Async: AsyncNamespace;
568
+ const AsyncFramework: AsyncNamespace;
569
+ }
package/framework.js CHANGED
@@ -1516,7 +1516,7 @@ const __componentModule = (() => {
1516
1516
  bind(value) {
1517
1517
  const id = runtime.loader?._registerBinding?.(value);
1518
1518
  if (!id) {
1519
- throw new Error("Inline template bindings require an AsyncLoader.");
1519
+ throw new Error("Inline template bindings require a Loader.");
1520
1520
  }
1521
1521
  bindingIds.push(id);
1522
1522
  return id;
@@ -2356,7 +2356,7 @@ const __loaderModule = (() => {
2356
2356
  const { matchAttribute, normalizeAttributeConfig, readAttribute } = __attributesModule;
2357
2357
  const inlineBindingPrefix = "__async:inline:";
2358
2358
 
2359
- function AsyncLoader({ root, signals, handlers, server, router, cache, attributes } = {}) {
2359
+ function Loader({ root, signals, handlers, server, router, cache, attributes } = {}) {
2360
2360
  const documentRef = root?.ownerDocument ?? root ?? globalThis.document;
2361
2361
  const rootNode = root ?? documentRef;
2362
2362
  const signalRegistry = signals ?? createSignalRegistry();
@@ -2798,7 +2798,7 @@ const __loaderModule = (() => {
2798
2798
 
2799
2799
  function assertActive() {
2800
2800
  if (destroyed) {
2801
- throw new Error("AsyncLoader has been destroyed.");
2801
+ throw new Error("Loader has been destroyed.");
2802
2802
  }
2803
2803
  }
2804
2804
 
@@ -2862,6 +2862,8 @@ const __loaderModule = (() => {
2862
2862
  return api;
2863
2863
  }
2864
2864
 
2865
+ const AsyncLoader = Loader;
2866
+
2865
2867
  function normalizeClassTokens(value, tokens = new Set()) {
2866
2868
  if (value == null || value === false) {
2867
2869
  return tokens;
@@ -3062,7 +3064,7 @@ const __loaderModule = (() => {
3062
3064
  })
3063
3065
  );
3064
3066
  }
3065
- return { AsyncLoader };
3067
+ return { Loader, AsyncLoader };
3066
3068
  })();
3067
3069
 
3068
3070
  const __partialsModule = (() => {
@@ -3185,7 +3187,7 @@ const __partialsModule = (() => {
3185
3187
  })();
3186
3188
 
3187
3189
  const __routerModule = (() => {
3188
- const { AsyncLoader } = __loaderModule;
3190
+ const { Loader } = __loaderModule;
3189
3191
  const { createHandlerRegistry } = __handlersModule;
3190
3192
  const { createSignalRegistry } = __signalsModule;
3191
3193
  const { applyServerResult } = __serverModule;
@@ -3314,7 +3316,7 @@ const __routerModule = (() => {
3314
3316
  const attributeConfig = normalizeAttributeConfig(attributes ?? loader?.attributes);
3315
3317
  const loaderInstance =
3316
3318
  loader ??
3317
- AsyncLoader({
3319
+ Loader({
3318
3320
  root: rootNode,
3319
3321
  signals: signalRegistry,
3320
3322
  handlers: handlerRegistry,
@@ -3665,7 +3667,7 @@ const __appModule = (() => {
3665
3667
  const { createCacheRegistry } = __cacheModule;
3666
3668
  const { createComponentRegistry } = __componentModule;
3667
3669
  const { createHandlerRegistry } = __handlersModule;
3668
- const { AsyncLoader } = __loaderModule;
3670
+ const { Loader } = __loaderModule;
3669
3671
  const { createPartialRegistry } = __partialsModule;
3670
3672
  const { createRouteRegistry, createRouter } = __routerModule;
3671
3673
  const { createServerRegistry } = __serverModule;
@@ -3764,7 +3766,7 @@ const __appModule = (() => {
3764
3766
  started = true;
3765
3767
 
3766
3768
  if (target !== "server") {
3767
- loader = loader ?? AsyncLoader({
3769
+ loader = loader ?? Loader({
3768
3770
  root: options.root,
3769
3771
  signals,
3770
3772
  handlers,
@@ -4115,6 +4117,7 @@ const { defineComponent: defineComponent } = __componentModule;
4115
4117
  const { delay: delay } = __delayModule;
4116
4118
  const { createHandlerRegistry: createHandlerRegistry } = __handlersModule;
4117
4119
  const { html: html } = __htmlModule;
4120
+ const { Loader: Loader } = __loaderModule;
4118
4121
  const { AsyncLoader: AsyncLoader } = __loaderModule;
4119
4122
  const { createPartialRegistry: createPartialRegistry } = __partialsModule;
4120
4123
  const { createRegistryStore: createRegistryStore } = __registryStoreModule;
@@ -4130,4 +4133,4 @@ const { createSignalRegistry: createSignalRegistry } = __signalsModule;
4130
4133
  const { effect: effect } = __signalsModule;
4131
4134
  const { signal: signal } = __signalsModule;
4132
4135
 
4133
- export { asyncSignal, Async, createApp, defineApp, attributeName, defineAttributeConfig, createCacheRegistry, defineCache, component, createComponentRegistry, defineComponent, delay, createHandlerRegistry, html, AsyncLoader, createPartialRegistry, createRegistryStore, createRouteRegistry, createRouter, defineRoute, route, createServerProxy, createServerRegistry, computed, createSignal, createSignalRegistry, effect, signal };
4136
+ export { asyncSignal, Async, createApp, defineApp, attributeName, defineAttributeConfig, createCacheRegistry, defineCache, component, createComponentRegistry, defineComponent, delay, createHandlerRegistry, html, Loader, AsyncLoader, createPartialRegistry, createRegistryStore, createRouteRegistry, createRouter, defineRoute, route, createServerProxy, createServerRegistry, computed, createSignal, createSignalRegistry, effect, signal };