webspresso 0.0.110 → 0.0.111
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/core/client/adapter/datastar.js +73 -23
- package/core/client/api.js +23 -21
- package/core/client/controller.js +288 -30
- package/core/client/debug.js +12 -12
- package/core/client/devtool.js +124 -19
- package/core/client/forms.js +39 -19
- package/core/client/fragments.js +433 -95
- package/core/client/host.js +365 -0
- package/core/client/index.d.ts +18 -0
- package/core/client/index.js +154 -23
- package/core/client/lite.js +101 -4
- package/core/client/server-fragments.js +99 -21
- package/core/client/services.js +588 -0
- package/core/client/utils.js +188 -2
- package/index.d.ts +322 -28
- package/index.js +3 -0
- package/package.json +1 -1
- package/src/bundle/index.js +175 -14
- package/src/dev/banner.js +4 -1
- package/src/dev-reload/index.js +29 -1
- package/src/server.js +28 -0
package/index.d.ts
CHANGED
|
@@ -6421,11 +6421,15 @@ export interface AppApiRouteMap {
|
|
|
6421
6421
|
DELETE: Record<string, { input: any; response: any }>;
|
|
6422
6422
|
}
|
|
6423
6423
|
|
|
6424
|
+
export type ClientRefetchPolicy = boolean | 'always';
|
|
6425
|
+
|
|
6424
6426
|
export interface ClientTask<TData = any, TArgs extends unknown[] = any[]> {
|
|
6425
6427
|
readonly pending: boolean;
|
|
6426
6428
|
readonly data: TData | null;
|
|
6427
6429
|
readonly error: ClientRequestError | Error | null;
|
|
6428
6430
|
readonly stale: boolean;
|
|
6431
|
+
readonly lastUpdatedAt: number;
|
|
6432
|
+
isStale(): boolean;
|
|
6429
6433
|
run(...args: TArgs): Promise<TData | undefined>;
|
|
6430
6434
|
cancel(): void;
|
|
6431
6435
|
dispose(): void;
|
|
@@ -6435,6 +6439,14 @@ export interface ClientTaskOptions {
|
|
|
6435
6439
|
concurrency?: ClientConcurrencyPolicy;
|
|
6436
6440
|
policy?: ClientConcurrencyPolicy;
|
|
6437
6441
|
key?: string;
|
|
6442
|
+
staleTime?: number | string;
|
|
6443
|
+
refetchOnMount?: ClientRefetchPolicy;
|
|
6444
|
+
refetchOnVisit?: ClientRefetchPolicy;
|
|
6445
|
+
refetchOnWindowFocus?: ClientRefetchPolicy;
|
|
6446
|
+
refetchOnFocus?: ClientRefetchPolicy;
|
|
6447
|
+
refetchOnReconnect?: ClientRefetchPolicy;
|
|
6448
|
+
refetchInterval?: number | string | false;
|
|
6449
|
+
refetchIntervalInBackground?: boolean;
|
|
6438
6450
|
}
|
|
6439
6451
|
|
|
6440
6452
|
export interface ClientFormFillOptions {
|
|
@@ -6533,21 +6545,196 @@ export interface ControllerPersistConfig<TState extends Record<string, any> = Re
|
|
|
6533
6545
|
debounce?: number;
|
|
6534
6546
|
}
|
|
6535
6547
|
|
|
6548
|
+
export interface AppClientServices {}
|
|
6549
|
+
|
|
6550
|
+
export interface ClientServiceMountHostOptions {
|
|
6551
|
+
key?: string;
|
|
6552
|
+
name?: string;
|
|
6553
|
+
target?: HTMLElement | null;
|
|
6554
|
+
selector?: string;
|
|
6555
|
+
container?: HTMLElement | null;
|
|
6556
|
+
root?: Document | HTMLElement | null;
|
|
6557
|
+
tagName?: string;
|
|
6558
|
+
id?: string;
|
|
6559
|
+
className?: string;
|
|
6560
|
+
attributes?: Record<string, string | number | boolean | null | undefined>;
|
|
6561
|
+
createOnly?: boolean;
|
|
6562
|
+
clearOnUnmount?: boolean;
|
|
6563
|
+
}
|
|
6564
|
+
|
|
6565
|
+
export interface ClientServiceHostHandle {
|
|
6566
|
+
readonly key: string;
|
|
6567
|
+
readonly el: ControllerElement;
|
|
6568
|
+
readonly created: boolean;
|
|
6569
|
+
readonly mounted: boolean;
|
|
6570
|
+
clear(): void;
|
|
6571
|
+
onUnmount(cleanupFn: (el: ControllerElement) => void): () => void;
|
|
6572
|
+
unmount(): void;
|
|
6573
|
+
destroy(): void;
|
|
6574
|
+
}
|
|
6575
|
+
|
|
6576
|
+
export interface ClientServiceHostHelper {
|
|
6577
|
+
mount(keyOrOptions?: string | ClientServiceMountHostOptions, options?: ClientServiceMountHostOptions): ClientServiceHostHandle;
|
|
6578
|
+
get(key?: string): ClientServiceHostHandle | null;
|
|
6579
|
+
has(key?: string): boolean;
|
|
6580
|
+
unmount(key?: string): boolean;
|
|
6581
|
+
}
|
|
6582
|
+
|
|
6583
|
+
export interface ClientServiceContext<TServices = AppClientServices> {
|
|
6584
|
+
readonly name: string;
|
|
6585
|
+
readonly api: ClientApiClient;
|
|
6586
|
+
readonly storage: ClientStorage & { readonly global: ClientStorage; readonly root: ClientStorage };
|
|
6587
|
+
readonly signal: AbortSignal;
|
|
6588
|
+
readonly root: Document | HTMLElement | null;
|
|
6589
|
+
readonly runtime: ClientRuntime<TServices> | null;
|
|
6590
|
+
readonly services: ClientServicesRegistry<TServices>;
|
|
6591
|
+
readonly host: ClientServiceHostHelper;
|
|
6592
|
+
mountHost(keyOrOptions?: string | ClientServiceMountHostOptions, options?: ClientServiceMountHostOptions): ClientServiceHostHandle;
|
|
6593
|
+
onCleanup(cleanupFn: () => void): () => void;
|
|
6594
|
+
onDispose(cleanupFn: () => void): () => void;
|
|
6595
|
+
isDisposed(): boolean;
|
|
6596
|
+
}
|
|
6597
|
+
|
|
6598
|
+
export interface ClientServiceDefinition<TService = any> {
|
|
6599
|
+
readonly __isWebspressoClientService: true;
|
|
6600
|
+
readonly __serviceType?: TService;
|
|
6601
|
+
readonly name: string | null;
|
|
6602
|
+
readonly load: ((ctx: ClientServiceContext) => Promise<any> | any) | null;
|
|
6603
|
+
readonly create: ((ctx: ClientServiceContext, loaded?: any) => Promise<TService> | TService) | null;
|
|
6604
|
+
readonly dispose: ((instance: TService, ctx: ClientServiceContext) => void | Promise<void>) | null;
|
|
6605
|
+
}
|
|
6606
|
+
|
|
6607
|
+
export type InferClientServiceExport<T> =
|
|
6608
|
+
T extends ClientServiceDefinition<infer S>
|
|
6609
|
+
? S
|
|
6610
|
+
: T extends (...args: any[]) => infer R
|
|
6611
|
+
? Awaited<R> extends ClientServiceDefinition<infer S>
|
|
6612
|
+
? S
|
|
6613
|
+
: Awaited<R>
|
|
6614
|
+
: T extends { createService: (...args: any[]) => infer R }
|
|
6615
|
+
? Awaited<R>
|
|
6616
|
+
: T extends { setup: (...args: any[]) => infer R }
|
|
6617
|
+
? Awaited<R>
|
|
6618
|
+
: T extends { create: (...args: any[]) => infer R }
|
|
6619
|
+
? Awaited<R>
|
|
6620
|
+
: T;
|
|
6621
|
+
|
|
6622
|
+
export type InferClientService<T> =
|
|
6623
|
+
T extends ClientServiceDefinition<infer S>
|
|
6624
|
+
? S
|
|
6625
|
+
: T extends { default: infer D }
|
|
6626
|
+
? InferClientServiceExport<D>
|
|
6627
|
+
: InferClientServiceExport<T>;
|
|
6628
|
+
|
|
6629
|
+
export type InferClientServicesMap<TMap> = {
|
|
6630
|
+
[K in keyof TMap]: InferClientService<TMap[K]>;
|
|
6631
|
+
};
|
|
6632
|
+
|
|
6633
|
+
export type ResolvedClientServicesMap<TServices = AppClientServices> =
|
|
6634
|
+
[keyof TServices] extends [never]
|
|
6635
|
+
? AppClientServices
|
|
6636
|
+
: InferClientServicesMap<TServices>;
|
|
6637
|
+
|
|
6638
|
+
export type ClientServiceKey<TServices = AppClientServices> =
|
|
6639
|
+
[keyof ResolvedClientServicesMap<TServices>] extends [never]
|
|
6640
|
+
? string
|
|
6641
|
+
: keyof ResolvedClientServicesMap<TServices> & string;
|
|
6642
|
+
|
|
6643
|
+
export interface ClientServicesRegistry<TServices = AppClientServices> {
|
|
6644
|
+
get<K extends ClientServiceKey<TServices>>(
|
|
6645
|
+
name: K
|
|
6646
|
+
): Promise<
|
|
6647
|
+
K extends keyof ResolvedClientServicesMap<TServices>
|
|
6648
|
+
? ResolvedClientServicesMap<TServices>[K]
|
|
6649
|
+
: any
|
|
6650
|
+
>;
|
|
6651
|
+
has(name: string): boolean;
|
|
6652
|
+
isInitialized(name: string): boolean;
|
|
6653
|
+
peek<K extends ClientServiceKey<TServices>>(
|
|
6654
|
+
name: K
|
|
6655
|
+
): K extends keyof ResolvedClientServicesMap<TServices>
|
|
6656
|
+
? ResolvedClientServicesMap<TServices>[K] | undefined
|
|
6657
|
+
: any;
|
|
6658
|
+
register<TDef>(name: string, definition: TDef): ClientServiceDefinition<InferClientService<TDef>>;
|
|
6659
|
+
registerAll(services: Record<string, unknown>): void;
|
|
6660
|
+
dispose(): void;
|
|
6661
|
+
destroy(): void;
|
|
6662
|
+
readonly isDisposed: boolean;
|
|
6663
|
+
}
|
|
6664
|
+
|
|
6665
|
+
export function defineClientService<TLoaded, TService>(definition: {
|
|
6666
|
+
name?: string;
|
|
6667
|
+
load: (ctx: ClientServiceContext) => Promise<TLoaded> | TLoaded;
|
|
6668
|
+
create: (ctx: ClientServiceContext, loaded: TLoaded) => Promise<TService> | TService;
|
|
6669
|
+
dispose?: (instance: TService, ctx: ClientServiceContext) => void | Promise<void>;
|
|
6670
|
+
}): ClientServiceDefinition<TService>;
|
|
6671
|
+
|
|
6672
|
+
export function defineClientService<TLoaded>(definition: {
|
|
6673
|
+
name?: string;
|
|
6674
|
+
load: (ctx: ClientServiceContext) => Promise<TLoaded> | TLoaded;
|
|
6675
|
+
dispose?: (instance: InferClientService<TLoaded>, ctx: ClientServiceContext) => void | Promise<void>;
|
|
6676
|
+
}): ClientServiceDefinition<InferClientService<TLoaded>>;
|
|
6677
|
+
|
|
6678
|
+
export function defineClientService<TService>(definition: {
|
|
6679
|
+
name?: string;
|
|
6680
|
+
create: (ctx: ClientServiceContext) => Promise<TService> | TService;
|
|
6681
|
+
dispose?: (instance: TService, ctx: ClientServiceContext) => void | Promise<void>;
|
|
6682
|
+
}): ClientServiceDefinition<TService>;
|
|
6683
|
+
|
|
6684
|
+
export function defineClientService<TService>(definition: {
|
|
6685
|
+
name?: string;
|
|
6686
|
+
setup: (ctx: ClientServiceContext) => Promise<TService> | TService;
|
|
6687
|
+
dispose?: (instance: TService, ctx: ClientServiceContext) => void | Promise<void>;
|
|
6688
|
+
}): ClientServiceDefinition<TService>;
|
|
6689
|
+
|
|
6690
|
+
export function defineClientService<TService>(
|
|
6691
|
+
factory: (ctx: ClientServiceContext) => Promise<TService> | TService
|
|
6692
|
+
): ClientServiceDefinition<Awaited<TService>>;
|
|
6693
|
+
|
|
6694
|
+
export function createClientServiceRegistry<TServices extends Record<string, any> = AppClientServices>(options?: {
|
|
6695
|
+
root?: Document | HTMLElement | null;
|
|
6696
|
+
api?: ClientApiClient;
|
|
6697
|
+
storage?: ClientStorage;
|
|
6698
|
+
debug?: Record<string, any>;
|
|
6699
|
+
services?: TServices;
|
|
6700
|
+
}): ClientServicesRegistry<TServices>;
|
|
6701
|
+
|
|
6702
|
+
export function createClientHostManager(options?: {
|
|
6703
|
+
root?: Document | HTMLElement | null;
|
|
6704
|
+
debug?: Record<string, any>;
|
|
6705
|
+
}): ClientServiceHostHelper & { dispose(): void; readonly isDisposed: boolean };
|
|
6706
|
+
|
|
6536
6707
|
export interface ClientFormSubmitResult<TData = any> {
|
|
6537
6708
|
ok: boolean;
|
|
6709
|
+
submitted?: boolean;
|
|
6538
6710
|
data?: TData;
|
|
6539
6711
|
refreshOk?: boolean;
|
|
6540
6712
|
refreshError?: Error | null;
|
|
6713
|
+
hookError?: Error | null;
|
|
6541
6714
|
error?: ClientRequestError | Error;
|
|
6542
6715
|
aborted?: boolean;
|
|
6543
6716
|
}
|
|
6544
6717
|
|
|
6718
|
+
export interface ClientFormHookMeta<
|
|
6719
|
+
TValues extends Record<string, any> = Record<string, any>,
|
|
6720
|
+
TResponse = any,
|
|
6721
|
+
TServices = AppClientServices
|
|
6722
|
+
> {
|
|
6723
|
+
values: TValues;
|
|
6724
|
+
form: ClientFormHandle<TValues, TResponse, TServices>;
|
|
6725
|
+
services: ClientServicesRegistry<TServices>;
|
|
6726
|
+
refreshOk?: boolean;
|
|
6727
|
+
refreshError?: Error | null;
|
|
6728
|
+
}
|
|
6729
|
+
|
|
6545
6730
|
export interface ClientFormHandle<
|
|
6546
6731
|
TValues extends Record<string, any> = Record<string, any>,
|
|
6547
|
-
TResponse = any
|
|
6732
|
+
TResponse = any,
|
|
6733
|
+
TServices = AppClientServices
|
|
6548
6734
|
> {
|
|
6549
6735
|
readonly name: string;
|
|
6550
6736
|
readonly el: HTMLFormElement | null;
|
|
6737
|
+
readonly services: ClientServicesRegistry<TServices>;
|
|
6551
6738
|
readonly pending: boolean;
|
|
6552
6739
|
readonly dirty: boolean;
|
|
6553
6740
|
readonly errors: Record<string, string>;
|
|
@@ -6568,22 +6755,39 @@ export interface ClientFormHandle<
|
|
|
6568
6755
|
restoreDraft(): boolean;
|
|
6569
6756
|
clearDraft(): boolean;
|
|
6570
6757
|
readonly hasDraft: boolean;
|
|
6571
|
-
submit(submitter?: HTMLElement | null): Promise<ClientFormSubmitResult<TResponse>>;
|
|
6572
|
-
onSuccess(
|
|
6758
|
+
submit(submitter?: HTMLElement | null | Record<string, unknown>): Promise<ClientFormSubmitResult<TResponse>>;
|
|
6759
|
+
onSuccess(
|
|
6760
|
+
callback: (data: TResponse, meta: ClientFormHookMeta<TValues, TResponse, TServices>) => void | Promise<void>
|
|
6761
|
+
): () => void;
|
|
6762
|
+
onError(
|
|
6763
|
+
callback: (
|
|
6764
|
+
error: ClientRequestError | Error,
|
|
6765
|
+
meta: ClientFormHookMeta<TValues, TResponse, TServices>
|
|
6766
|
+
) => void | Promise<void>
|
|
6767
|
+
): () => void;
|
|
6573
6768
|
destroy(): void;
|
|
6574
6769
|
}
|
|
6575
6770
|
|
|
6576
|
-
export interface ControllerFormsRegistry {
|
|
6771
|
+
export interface ControllerFormsRegistry<TServices = AppClientServices> {
|
|
6772
|
+
<TValues extends Record<string, any> = Record<string, any>, TResponse = any>(
|
|
6773
|
+
formNameOrElement: string | HTMLFormElement,
|
|
6774
|
+
options?: {
|
|
6775
|
+
resetOnSuccess?: boolean;
|
|
6776
|
+
clearOnSuccess?: boolean;
|
|
6777
|
+
redirectOnSuccess?: string | ((data: TResponse) => string | void);
|
|
6778
|
+
onSuccess?: (data: TResponse, meta: ClientFormHookMeta<TValues, TResponse, TServices>) => void | Promise<void>;
|
|
6779
|
+
}
|
|
6780
|
+
): ClientFormHandle<TValues, TResponse, TServices>;
|
|
6577
6781
|
get<TValues extends Record<string, any> = Record<string, any>, TResponse = any>(
|
|
6578
6782
|
formNameOrElement: string | HTMLFormElement,
|
|
6579
6783
|
options?: {
|
|
6580
6784
|
resetOnSuccess?: boolean;
|
|
6581
6785
|
clearOnSuccess?: boolean;
|
|
6582
6786
|
redirectOnSuccess?: string | ((data: TResponse) => string | void);
|
|
6583
|
-
onSuccess?: (data: TResponse, meta:
|
|
6787
|
+
onSuccess?: (data: TResponse, meta: ClientFormHookMeta<TValues, TResponse, TServices>) => void | Promise<void>;
|
|
6584
6788
|
}
|
|
6585
|
-
): ClientFormHandle<TValues, TResponse>;
|
|
6586
|
-
all(): ClientFormHandle[];
|
|
6789
|
+
): ClientFormHandle<TValues, TResponse, TServices>;
|
|
6790
|
+
all(): ClientFormHandle<any, any, TServices>[];
|
|
6587
6791
|
}
|
|
6588
6792
|
|
|
6589
6793
|
export interface FragmentRefreshResult {
|
|
@@ -6653,27 +6857,32 @@ export interface WatchDescriptor<T = any> extends WatchOptions {
|
|
|
6653
6857
|
|
|
6654
6858
|
export type ControllerErrorHandler<
|
|
6655
6859
|
TState extends Record<string, any> = Record<string, any>,
|
|
6656
|
-
TTasks extends Record<string, ClientTask> = Record<string, ClientTask
|
|
6860
|
+
TTasks extends Record<string, ClientTask> = Record<string, ClientTask>,
|
|
6861
|
+
TServices = AppClientServices
|
|
6657
6862
|
> = (
|
|
6658
6863
|
err: Error | ClientRequestError,
|
|
6659
|
-
ctx: ControllerContext<TState, TTasks>,
|
|
6864
|
+
ctx: ControllerContext<TState, TTasks, TServices>,
|
|
6660
6865
|
meta?: ControllerErrorMeta
|
|
6661
6866
|
) => void | boolean;
|
|
6662
6867
|
|
|
6663
6868
|
export interface ControllerContext<
|
|
6664
6869
|
TState extends Record<string, any> = Record<string, any>,
|
|
6665
|
-
TTasks extends Record<string, ClientTask> = Record<string, ClientTask
|
|
6870
|
+
TTasks extends Record<string, ClientTask> = Record<string, ClientTask>,
|
|
6871
|
+
TServices = AppClientServices
|
|
6666
6872
|
> {
|
|
6667
6873
|
readonly el: HTMLElement;
|
|
6668
6874
|
readonly instanceId: string;
|
|
6669
6875
|
readonly name: string;
|
|
6670
6876
|
readonly state: TState;
|
|
6671
6877
|
readonly api: ClientApiClient;
|
|
6672
|
-
readonly
|
|
6878
|
+
readonly services: ClientServicesRegistry<TServices>;
|
|
6879
|
+
readonly forms: ControllerFormsRegistry<TServices>;
|
|
6673
6880
|
readonly tasks: TTasks;
|
|
6674
6881
|
readonly signal: AbortSignal;
|
|
6675
6882
|
readonly isConnected: () => boolean;
|
|
6676
6883
|
readonly isDisposed: () => boolean;
|
|
6884
|
+
readonly isBusy: boolean;
|
|
6885
|
+
isActionBusy(actionName: string): boolean;
|
|
6677
6886
|
readonly lastError: Error | null;
|
|
6678
6887
|
clearError(): void;
|
|
6679
6888
|
readonly storage: ClientStorage & { readonly global: ClientStorage; readonly root: ClientStorage };
|
|
@@ -6719,10 +6928,13 @@ export type ControllerComputedGetter<
|
|
|
6719
6928
|
|
|
6720
6929
|
export type ControllerTaskFactory<
|
|
6721
6930
|
TState extends Record<string, any> = Record<string, any>,
|
|
6722
|
-
TData = any
|
|
6931
|
+
TData = any,
|
|
6932
|
+
TServices = AppClientServices
|
|
6723
6933
|
> =
|
|
6724
|
-
| ((
|
|
6725
|
-
|
|
6934
|
+
| ((
|
|
6935
|
+
ctx: ControllerContext<TState, Record<string, ClientTask>, TServices>
|
|
6936
|
+
) => ClientTask<TData> | ({ run: (...args: any[]) => Promise<TData> } & ClientTaskOptions))
|
|
6937
|
+
| ({ run: (...args: any[]) => Promise<TData> } & ClientTaskOptions);
|
|
6726
6938
|
|
|
6727
6939
|
export interface ControllerElement extends HTMLElement {
|
|
6728
6940
|
data(): Record<string, unknown>;
|
|
@@ -6733,9 +6945,10 @@ export interface ControllerElement extends HTMLElement {
|
|
|
6733
6945
|
|
|
6734
6946
|
export type ControllerActionHandler<
|
|
6735
6947
|
TState extends Record<string, any> = Record<string, any>,
|
|
6736
|
-
TTasks extends Record<string, ClientTask> = Record<string, ClientTask
|
|
6948
|
+
TTasks extends Record<string, ClientTask> = Record<string, ClientTask>,
|
|
6949
|
+
TServices = AppClientServices
|
|
6737
6950
|
> = (
|
|
6738
|
-
ctx: ControllerContext<TState, TTasks>,
|
|
6951
|
+
ctx: ControllerContext<TState, TTasks, TServices>,
|
|
6739
6952
|
event: Event,
|
|
6740
6953
|
actionEl: ControllerElement
|
|
6741
6954
|
) => unknown | Promise<unknown>;
|
|
@@ -6743,7 +6956,8 @@ export type ControllerActionHandler<
|
|
|
6743
6956
|
export interface ControllerDefinition<
|
|
6744
6957
|
TState extends Record<string, any> = Record<string, any>,
|
|
6745
6958
|
TComputed extends Record<string, ControllerComputedGetter<TState>> = Record<string, ControllerComputedGetter<TState>>,
|
|
6746
|
-
TTasks extends Record<string, ControllerTaskFactory<TState>> = Record<string, ControllerTaskFactory<TState
|
|
6959
|
+
TTasks extends Record<string, ControllerTaskFactory<TState, any, TServices>> = Record<string, ControllerTaskFactory<TState, any, any>>,
|
|
6960
|
+
TServices = AppClientServices
|
|
6747
6961
|
> {
|
|
6748
6962
|
name?: string;
|
|
6749
6963
|
state?: () => TState;
|
|
@@ -6751,22 +6965,30 @@ export interface ControllerDefinition<
|
|
|
6751
6965
|
tasks?: TTasks;
|
|
6752
6966
|
connect?: (
|
|
6753
6967
|
ctx: ControllerContext<
|
|
6754
|
-
[TState][TState extends any ? 0 : never] & { readonly [K in keyof TComputed]: ReturnType<TComputed[K]> }
|
|
6968
|
+
[TState][TState extends any ? 0 : never] & { readonly [K in keyof TComputed]: ReturnType<TComputed[K]> },
|
|
6969
|
+
Record<string, ClientTask>,
|
|
6970
|
+
TServices
|
|
6755
6971
|
>
|
|
6756
6972
|
) => void | (() => void);
|
|
6757
6973
|
disconnect?: (
|
|
6758
6974
|
ctx: ControllerContext<
|
|
6759
|
-
[TState][TState extends any ? 0 : never] & { readonly [K in keyof TComputed]: ReturnType<TComputed[K]> }
|
|
6975
|
+
[TState][TState extends any ? 0 : never] & { readonly [K in keyof TComputed]: ReturnType<TComputed[K]> },
|
|
6976
|
+
Record<string, ClientTask>,
|
|
6977
|
+
TServices
|
|
6760
6978
|
>
|
|
6761
6979
|
) => void;
|
|
6762
6980
|
onError?: ControllerErrorHandler<
|
|
6763
|
-
[TState][TState extends any ? 0 : never] & { readonly [K in keyof TComputed]: ReturnType<TComputed[K]> }
|
|
6981
|
+
[TState][TState extends any ? 0 : never] & { readonly [K in keyof TComputed]: ReturnType<TComputed[K]> },
|
|
6982
|
+
Record<string, ClientTask>,
|
|
6983
|
+
TServices
|
|
6764
6984
|
>;
|
|
6765
6985
|
persist?: ControllerPersistConfig<TState> | (keyof TState & string)[] | 'local' | 'session' | null;
|
|
6766
6986
|
watch?: Record<string, WatchCallback<any> | WatchDescriptor<any>>;
|
|
6767
6987
|
actions?: {
|
|
6768
6988
|
[actionName: string]: ControllerActionHandler<
|
|
6769
|
-
[TState][TState extends any ? 0 : never] & { readonly [K in keyof TComputed]: ReturnType<TComputed[K]> }
|
|
6989
|
+
[TState][TState extends any ? 0 : never] & { readonly [K in keyof TComputed]: ReturnType<TComputed[K]> },
|
|
6990
|
+
Record<string, ClientTask>,
|
|
6991
|
+
TServices
|
|
6770
6992
|
>;
|
|
6771
6993
|
};
|
|
6772
6994
|
}
|
|
@@ -6774,10 +6996,11 @@ export interface ControllerDefinition<
|
|
|
6774
6996
|
export function defineController<
|
|
6775
6997
|
TState extends Record<string, any> = Record<string, any>,
|
|
6776
6998
|
TComputed extends Record<string, ControllerComputedGetter<TState>> = Record<string, ControllerComputedGetter<TState>>,
|
|
6777
|
-
TTasks extends Record<string, ControllerTaskFactory<TState>> = Record<string, ControllerTaskFactory<TState
|
|
6999
|
+
TTasks extends Record<string, ControllerTaskFactory<TState, any, TServices>> = Record<string, ControllerTaskFactory<TState, any, any>>,
|
|
7000
|
+
TServices = AppClientServices
|
|
6778
7001
|
>(
|
|
6779
|
-
definition: ControllerDefinition<TState, TComputed, TTasks>
|
|
6780
|
-
): ControllerDefinition<TState, TComputed, TTasks> & { __isWebspressoController: true };
|
|
7002
|
+
definition: ControllerDefinition<TState, TComputed, TTasks, TServices>
|
|
7003
|
+
): ControllerDefinition<TState, TComputed, TTasks, TServices> & { __isWebspressoController: true };
|
|
6781
7004
|
|
|
6782
7005
|
export function watch<T = any>(
|
|
6783
7006
|
source: WatchSource<T>,
|
|
@@ -6810,6 +7033,14 @@ export interface FragmentDefinition<TInput = Record<string, unknown>, TData = Re
|
|
|
6810
7033
|
schema?: ZodTypeAny | Record<string, ZodTypeAny> | ((helpers: { z: typeof z }) => ZodTypeAny | Record<string, ZodTypeAny>);
|
|
6811
7034
|
auth?: boolean | string | string[] | ((user: any, ctx: PageContext) => boolean | Promise<boolean>);
|
|
6812
7035
|
middleware?: Array<string | import('express').RequestHandler>;
|
|
7036
|
+
staleTime?: number | string;
|
|
7037
|
+
refetchOnWindowFocus?: ClientRefetchPolicy;
|
|
7038
|
+
refetchOnFocus?: ClientRefetchPolicy;
|
|
7039
|
+
refetchOnReconnect?: ClientRefetchPolicy;
|
|
7040
|
+
refetchOnMount?: ClientRefetchPolicy;
|
|
7041
|
+
refetchOnVisit?: ClientRefetchPolicy;
|
|
7042
|
+
refetchInterval?: number | string | false;
|
|
7043
|
+
refetchIntervalInBackground?: boolean;
|
|
6813
7044
|
load?: (context: FragmentLoaderContext<TInput>) => TData | Promise<TData>;
|
|
6814
7045
|
}
|
|
6815
7046
|
|
|
@@ -6846,11 +7077,74 @@ export function parseFormElement(formEl: HTMLFormElement, options?: Record<strin
|
|
|
6846
7077
|
hasFile: boolean;
|
|
6847
7078
|
formData: FormData;
|
|
6848
7079
|
};
|
|
7080
|
+
export interface ClientRuntimeOptions<TServices extends Record<string, any> = AppClientServices> {
|
|
7081
|
+
root?: Document | Element;
|
|
7082
|
+
document?: Document | Element;
|
|
7083
|
+
fetch?: typeof fetch;
|
|
7084
|
+
baseUrl?: string;
|
|
7085
|
+
fragmentEndpoint?: string;
|
|
7086
|
+
datastar?: Record<string, unknown>;
|
|
7087
|
+
debug?: boolean | Record<string, unknown>;
|
|
7088
|
+
devtools?: boolean;
|
|
7089
|
+
devtoolsOptions?: Record<string, unknown>;
|
|
7090
|
+
observe?: boolean;
|
|
7091
|
+
hmr?: boolean;
|
|
7092
|
+
staleTime?: number | string;
|
|
7093
|
+
refetchOnWindowFocus?: ClientRefetchPolicy;
|
|
7094
|
+
refetchOnFocus?: ClientRefetchPolicy;
|
|
7095
|
+
refetchOnReconnect?: ClientRefetchPolicy;
|
|
7096
|
+
refetchOnMount?: ClientRefetchPolicy;
|
|
7097
|
+
refetchOnVisit?: ClientRefetchPolicy;
|
|
7098
|
+
refetchInterval?: number | string | false;
|
|
7099
|
+
refetchIntervalInBackground?: boolean;
|
|
7100
|
+
lazyLoader?: (name: string, el: Element) => Promise<any>;
|
|
7101
|
+
controllers?: Record<string, any>;
|
|
7102
|
+
services?: TServices;
|
|
7103
|
+
[key: string]: unknown;
|
|
7104
|
+
}
|
|
7105
|
+
|
|
7106
|
+
export interface ClientRuntime<TServices = AppClientServices> {
|
|
7107
|
+
readonly api: ClientApiClient;
|
|
7108
|
+
readonly services: ClientServicesRegistry<TServices>;
|
|
7109
|
+
readonly fragments: Record<string, any>;
|
|
7110
|
+
readonly controllers: Record<string, any>;
|
|
7111
|
+
readonly datastar: Record<string, any>;
|
|
7112
|
+
readonly adapter: Record<string, any>;
|
|
7113
|
+
readonly debug: Record<string, any>;
|
|
7114
|
+
register(name: string, definition: any, meta?: Record<string, unknown>): any;
|
|
7115
|
+
registerService<TDef>(name: string, definition: TDef): ClientServiceDefinition<InferClientService<TDef>>;
|
|
7116
|
+
mount(targetRoot?: Document | Element): Promise<any[]>;
|
|
7117
|
+
unmount(targetRoot?: Document | Element): void;
|
|
7118
|
+
destroy(): void;
|
|
7119
|
+
dispose(): void;
|
|
7120
|
+
getControllerInstance(el: Element, name?: string): any;
|
|
7121
|
+
getController(el: Element, name?: string): any;
|
|
7122
|
+
invalidate(tags: string | string[], meta?: Record<string, unknown>): Promise<any>;
|
|
7123
|
+
refresh(idOrName: string, input?: Record<string, unknown>, opts?: FragmentRefreshOptions): Promise<FragmentRefreshResult>;
|
|
7124
|
+
mountDevtool(opts?: Record<string, unknown>): ClientDevtoolHandle;
|
|
7125
|
+
forms: {
|
|
7126
|
+
parse: typeof parseFormElement;
|
|
7127
|
+
create<TValues extends Record<string, any> = Record<string, any>, TResponse = any>(
|
|
7128
|
+
formEl: HTMLFormElement,
|
|
7129
|
+
formOpts?: Record<string, unknown>
|
|
7130
|
+
): ClientFormHandle<TValues, TResponse, TServices>;
|
|
7131
|
+
};
|
|
7132
|
+
[key: string]: any;
|
|
7133
|
+
}
|
|
7134
|
+
|
|
6849
7135
|
export function createFragmentCoordinator(options?: Record<string, unknown>): Record<string, any>;
|
|
6850
|
-
export function createClientRuntime
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
export function
|
|
7136
|
+
export function createClientRuntime<TServices extends Record<string, any> = AppClientServices>(
|
|
7137
|
+
options?: ClientRuntimeOptions<TServices>
|
|
7138
|
+
): ClientRuntime<TServices>;
|
|
7139
|
+
export function bootClient<TServices extends Record<string, any> = AppClientServices>(
|
|
7140
|
+
options?: ClientRuntimeOptions<TServices>
|
|
7141
|
+
): ClientRuntime<TServices>;
|
|
7142
|
+
export function createLiteClientRuntime<TServices extends Record<string, any> = AppClientServices>(
|
|
7143
|
+
options?: ClientRuntimeOptions<TServices>
|
|
7144
|
+
): Record<string, any> & { readonly services: ClientServicesRegistry<TServices> };
|
|
7145
|
+
export function bootLiteClient<TServices extends Record<string, any> = AppClientServices>(
|
|
7146
|
+
options?: ClientRuntimeOptions<TServices>
|
|
7147
|
+
): Record<string, any> & { readonly services: ClientServicesRegistry<TServices> };
|
|
6854
7148
|
export function createDatastarAdapter(options?: Record<string, unknown>): Record<string, any>;
|
|
6855
7149
|
export function createClientDebugger(options?: { enabled?: boolean; maxEvents?: number }): Record<string, any>;
|
|
6856
7150
|
export interface ClientDevtoolHandle {
|
package/index.js
CHANGED
|
@@ -799,6 +799,9 @@ Object.defineProperties(module.exports, {
|
|
|
799
799
|
// Datastar Client Behavior Layer & SSR Fragments (core/client)
|
|
800
800
|
client: { get: () => require('./core/client'), enumerable: true, configurable: true },
|
|
801
801
|
defineController: { get: () => require('./core/client').defineController, enumerable: true, configurable: true },
|
|
802
|
+
defineClientService: { get: () => require('./core/client').defineClientService, enumerable: true, configurable: true },
|
|
803
|
+
createClientServiceRegistry: { get: () => require('./core/client').createClientServiceRegistry, enumerable: true, configurable: true },
|
|
804
|
+
createClientHostManager: { get: () => require('./core/client').createClientHostManager, enumerable: true, configurable: true },
|
|
802
805
|
deriveControllerNameFromPath: { get: () => require('./core/client').deriveControllerNameFromPath, enumerable: true, configurable: true },
|
|
803
806
|
createClientRuntime: { get: () => require('./core/client').createClientRuntime, enumerable: true, configurable: true },
|
|
804
807
|
bootClient: { get: () => require('./core/client').bootClient, enumerable: true, configurable: true },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webspresso",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.111",
|
|
4
4
|
"description": "Minimal, production-ready SSR framework for Node.js with file-based routing, Nunjucks templating, built-in i18n, and CLI tooling",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|