fusee-framework 1.7.0 → 1.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/README.md +206 -139
- package/app/benchmark/benchmark.js +2 -2
- package/app/benchmark/vite.config.js +23 -0
- package/app/main.js +24 -3
- package/app/main.ts +7 -1
- package/app/pages/_layout.js +27 -0
- package/app/pages/async-work.js +65 -0
- package/app/pages/index.js +25 -5
- package/app/pages/index.ts +9 -0
- package/app/pages/router-example.js +24 -1
- package/app/pages/scroll-demo.ts +102 -0
- package/app/providers/ChildComponent.js +8 -2
- package/app/providers/ChildComponent.ts +47 -47
- package/app/providers/GrandchildComponent.js +19 -0
- package/app/providers/ParentComponent.js +5 -1
- package/app/routes/RouterExample.js +23 -1
- package/app/routes/TestResource.js +47 -0
- package/app/services.js +15 -0
- package/auto-imports.d.ts +12 -0
- package/framework/auto-import-preset.js +15 -9
- package/framework/core/async-context.js +27 -0
- package/framework/core/compiler/ast.js +167 -0
- package/framework/core/compiler/errors-list.js +47 -0
- package/framework/core/compiler/errors.js +107 -0
- package/framework/core/compiler/generator.js +363 -0
- package/framework/core/compiler/lexer.js +347 -0
- package/framework/core/compiler/main-compiler.js +115 -0
- package/framework/core/compiler/parser.js +414 -0
- package/framework/core/compiler/plugins/actions-plugin.js +263 -0
- package/framework/core/compiler/plugins/compiler-plugin.d.ts +5 -0
- package/framework/core/compiler/plugins/compiler-plugin.js +45 -0
- package/framework/core/compiler/plugins/file-router-plugin.js +301 -0
- package/framework/core/compiler/plugins/router-plugin.js +196 -0
- package/framework/core/compiler/transformer.js +398 -0
- package/framework/core/component.js +61 -23
- package/framework/core/di.js +187 -0
- package/framework/core/directives.js +40 -96
- package/framework/core/evaluator.js +1 -1
- package/framework/core/h.js +430 -0
- package/framework/core/hydration.js +83 -0
- package/framework/core/reconcile.js +151 -0
- package/framework/core/signal.js +269 -0
- package/framework/core/store.js +322 -81
- package/framework/index.js +5 -3
- package/framework/router/file-router.js +1 -1
- package/framework/router/router.js +113 -21
- package/framework/server/actions.js +173 -0
- package/framework/server/actions.server.js +88 -0
- package/framework/server/index.js +18 -0
- package/framework/types/actions.d.ts +50 -0
- package/framework/types/actions.server.d.ts +36 -0
- package/framework/types/compiler/ast.d.ts +166 -0
- package/framework/types/compiler/errors-codes.d.ts +23 -0
- package/framework/types/compiler/errors.d.ts +43 -0
- package/framework/types/compiler/generator.d.ts +8 -0
- package/framework/types/compiler/h.d.ts +46 -0
- package/framework/types/compiler/lexer.d.ts +27 -0
- package/framework/types/compiler/main-compiler.d.ts +60 -0
- package/framework/types/compiler/parser.d.ts +4 -0
- package/framework/types/compiler/plugins/actions.d.ts +30 -0
- package/framework/types/compiler/plugins/compiler-plugin.d.ts +5 -0
- package/framework/types/compiler/plugins/file-router-plugins.d.ts +32 -0
- package/framework/types/compiler/plugins/router-plugin.d.ts +24 -0
- package/framework/types/compiler/transformer.d.ts +28 -0
- package/framework/types/component.d.ts +89 -88
- package/framework/types/di.d.ts +43 -0
- package/framework/types/hydration.d.ts +30 -0
- package/framework/types/index.d.ts +38 -22
- package/framework/types/reconcile.d.ts +7 -0
- package/framework/types/router.d.ts +11 -1
- package/framework/types/server.d.ts +11 -0
- package/framework/types/signal.d.ts +142 -79
- package/framework/types/store.d.ts +66 -8
- package/ghid_go_fusee_integrat_go1_26.txt +276 -0
- package/ghid_rust_fusee_rust_1_95_0.txt +1118 -0
- package/package.json +44 -36
- package/vite.config.js +65 -47
|
@@ -1,88 +1,89 @@
|
|
|
1
|
-
export type ComponentProps = Record<string, any>
|
|
2
|
-
export type EmptyProps = Record<string, never>
|
|
3
|
-
export type PropSchema = string[] | Record<string, PropConfig>
|
|
4
|
-
|
|
5
|
-
export type PropConfig = {
|
|
6
|
-
type?: FunctionConstructor | StringConstructor | NumberConstructor | BooleanConstructor
|
|
7
|
-
default?: any | (() => any)
|
|
8
|
-
required?: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type EmitFn = (eventName: string, ...args: any[]) => void
|
|
12
|
-
|
|
13
|
-
export type Slots = Record<string, string>
|
|
14
|
-
|
|
15
|
-
export type SetupContext = {
|
|
16
|
-
emit: EmitFn
|
|
17
|
-
slots: Slots
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type ComponentInstance = {
|
|
21
|
-
props: ComponentProps
|
|
22
|
-
_mountHooks: (() => void)[]
|
|
23
|
-
_unmountHooks: (() => void)[]
|
|
24
|
-
_effects: import('./signal').EffectRunner[]
|
|
25
|
-
_element: HTMLElement | null
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export declare function
|
|
54
|
-
export declare function
|
|
55
|
-
export declare function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export declare function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
T extends
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
1
|
+
export type ComponentProps = Record<string, any>
|
|
2
|
+
export type EmptyProps = Record<string, never>
|
|
3
|
+
export type PropSchema = string[] | Record<string, PropConfig>
|
|
4
|
+
|
|
5
|
+
export type PropConfig = {
|
|
6
|
+
type?: FunctionConstructor | StringConstructor | NumberConstructor | BooleanConstructor
|
|
7
|
+
default?: any | (() => any)
|
|
8
|
+
required?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type EmitFn = (eventName: string, ...args: any[]) => void
|
|
12
|
+
|
|
13
|
+
export type Slots = Record<string, string>
|
|
14
|
+
|
|
15
|
+
export type SetupContext = {
|
|
16
|
+
emit: EmitFn
|
|
17
|
+
slots: Slots
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ComponentInstance = {
|
|
21
|
+
props: ComponentProps
|
|
22
|
+
_mountHooks: (() => void)[]
|
|
23
|
+
_unmountHooks: (() => void)[]
|
|
24
|
+
_effects: import('./signal').EffectRunner[]
|
|
25
|
+
_element: HTMLElement | null
|
|
26
|
+
_parent: ComponentInstance | null
|
|
27
|
+
_injector: import('./di').Injector
|
|
28
|
+
_ownsInjector: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type ComponentResult = {
|
|
32
|
+
template: string
|
|
33
|
+
[key: string]: any
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type ComponentOptions<TProps = ComponentProps, P = PropSchema> = {
|
|
37
|
+
props?: P
|
|
38
|
+
components?: Record<string, ComponentFactory<any>>
|
|
39
|
+
setup: (props: TProps, ctx: SetupContext) => ComponentResult
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ComponentFactory<TProps = ComponentProps> = (
|
|
43
|
+
props?: TProps,
|
|
44
|
+
options?: { listeners?: Record<string, Function>, slots?: Slots, parent?: ComponentInstance }
|
|
45
|
+
) => ComponentApi
|
|
46
|
+
|
|
47
|
+
export type ComponentApi = {
|
|
48
|
+
render: (container: HTMLElement) => ComponentInstance
|
|
49
|
+
unmount: () => void
|
|
50
|
+
instance: ComponentInstance
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare function onMount(fn: () => void): void
|
|
54
|
+
export declare function onUnmount(fn: () => void): void
|
|
55
|
+
export declare function parseSlots(slotHTML: string): Slots
|
|
56
|
+
export declare function getCurrentInstance(): ComponentInstance | null
|
|
57
|
+
|
|
58
|
+
export declare function provide(keyOrProvider: any, value?: any): void
|
|
59
|
+
export { inject } from './di'
|
|
60
|
+
|
|
61
|
+
type InferPropType<T> = T extends StringConstructor ? string :
|
|
62
|
+
T extends NumberConstructor ? number :
|
|
63
|
+
T extends BooleanConstructor ? boolean :
|
|
64
|
+
any;
|
|
65
|
+
|
|
66
|
+
type InferProps<P> = P extends string[]
|
|
67
|
+
? Record<P[number], any>
|
|
68
|
+
: P extends Record<string, PropConfig>
|
|
69
|
+
? {
|
|
70
|
+
[K in keyof P]: P[K]['required'] extends true
|
|
71
|
+
? InferPropType<P[K]['type']>
|
|
72
|
+
: InferPropType<P[K]['type']> | (P[K] extends { default: any } ? never : undefined)
|
|
73
|
+
}
|
|
74
|
+
: Record<string, any>;
|
|
75
|
+
|
|
76
|
+
export declare function defineComponent<P extends PropSchema = any, TProps = InferProps<P>>(
|
|
77
|
+
options: ComponentOptions<TProps, P>
|
|
78
|
+
): ComponentFactory<TProps>
|
|
79
|
+
|
|
80
|
+
export type AsyncComponentLoader<TProps = ComponentProps> = () => Promise<ComponentFactory<TProps> | { default: ComponentFactory<TProps> } | Record<string, any>>
|
|
81
|
+
|
|
82
|
+
export type AsyncComponentOptions<TProps = ComponentProps> = {
|
|
83
|
+
loader: AsyncComponentLoader<TProps>
|
|
84
|
+
loadingComponent?: ComponentFactory<any>
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare function defineAsyncComponent<TProps = ComponentProps>(
|
|
88
|
+
loaderOrOptions: AsyncComponentLoader<TProps> | AsyncComponentOptions<TProps>
|
|
89
|
+
): ComponentFactory<TProps>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare class InjectionToken<T = any> {
|
|
2
|
+
constructor(description: string);
|
|
3
|
+
description: string;
|
|
4
|
+
toString(): string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare function isClass(fn: any): boolean;
|
|
8
|
+
|
|
9
|
+
export interface InjectOptions {
|
|
10
|
+
optional?: boolean;
|
|
11
|
+
skipSelf?: boolean;
|
|
12
|
+
self?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare abstract class Injector {
|
|
16
|
+
get<T>(token: any, options?: InjectOptions): T;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export declare class NullInjector extends Injector {
|
|
20
|
+
get<T>(token: any, options?: InjectOptions): T | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare type Provider =
|
|
24
|
+
| any // class (shorthand)
|
|
25
|
+
| { provide: any, useClass: any }
|
|
26
|
+
| { provide: any, useValue: any }
|
|
27
|
+
| { provide: any, useFactory: () => any }
|
|
28
|
+
| { provide: any, useExisting: any };
|
|
29
|
+
|
|
30
|
+
export declare class EnvironmentInjector extends Injector {
|
|
31
|
+
constructor(providers?: Provider[], parent?: Injector);
|
|
32
|
+
parent: Injector;
|
|
33
|
+
provide(provider: Provider): void;
|
|
34
|
+
get<T>(token: any, options?: InjectOptions): T;
|
|
35
|
+
createChild(providers?: Provider[]): EnvironmentInjector;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export declare function runInContext<T>(injector: Injector, fn: () => T): T;
|
|
40
|
+
export declare function replaceActiveInjector(injector: Injector): void;
|
|
41
|
+
export declare function inject<T>(token: any, options: InjectOptions & { optional: true }): T | null;
|
|
42
|
+
export declare function inject<T>(token: any, options?: InjectOptions): T;
|
|
43
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface HydrationCacheEntry {
|
|
2
|
+
data: unknown
|
|
3
|
+
updatedAt: number
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type HydrationSnapshot = Record<string, Record<string, HydrationCacheEntry>>
|
|
7
|
+
export declare function _registerResourceCache(
|
|
8
|
+
resourceKey: string,
|
|
9
|
+
cache: Map<string, HydrationCacheEntry>
|
|
10
|
+
): void
|
|
11
|
+
|
|
12
|
+
export declare function extractHydrationData(): HydrationSnapshot
|
|
13
|
+
export declare function dehydrate(snapshot?: HydrationSnapshot): string
|
|
14
|
+
export declare function loadHydration(snapshot: HydrationSnapshot): void
|
|
15
|
+
export declare function hydrateFromWindow(): void
|
|
16
|
+
export declare function getHydratedEntries(resourceKey: string): Map<string, HydrationCacheEntry> | null
|
|
17
|
+
export declare function isHydrationFresh(
|
|
18
|
+
resourceKey: string,
|
|
19
|
+
cacheKey: string,
|
|
20
|
+
staleTime?: number
|
|
21
|
+
): boolean
|
|
22
|
+
|
|
23
|
+
export declare function clearHydration(): void
|
|
24
|
+
export declare function getHydrationSnapshot(): HydrationSnapshot
|
|
25
|
+
|
|
26
|
+
declare global {
|
|
27
|
+
interface Window {
|
|
28
|
+
__FUSEE_HYDRATION__?: HydrationSnapshot
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,22 +1,38 @@
|
|
|
1
|
-
export * from './signal'
|
|
2
|
-
export * from './component'
|
|
3
|
-
export * from './composable'
|
|
4
|
-
export * from './router'
|
|
5
|
-
export * from './compiler'
|
|
6
|
-
export * from './directives'
|
|
7
|
-
export * from './store'
|
|
8
|
-
export * from './event-delegation'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
type
|
|
16
|
-
type
|
|
17
|
-
type
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
export * from './signal'
|
|
2
|
+
export * from './component'
|
|
3
|
+
export * from './composable'
|
|
4
|
+
export * from './router'
|
|
5
|
+
export * from './compiler'
|
|
6
|
+
export * from './directives'
|
|
7
|
+
export * from './store'
|
|
8
|
+
export * from './event-delegation'
|
|
9
|
+
export * from './di'
|
|
10
|
+
export * from './reconcile'
|
|
11
|
+
export * from './actions'
|
|
12
|
+
export * from './actions.server'
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
type Signal<T = any> = import('./signal').Signal<T>
|
|
16
|
+
type Computed<T = any> = import('./signal').Computed<T>
|
|
17
|
+
type SignalAccessor<T> = import('./signal').SignalAccessor<T>
|
|
18
|
+
type Composable<T extends (...args: any[]) => any> = import('./composable').Composable<T>
|
|
19
|
+
type DirectiveBinding<V = any> = import('./directives').DirectiveBinding<V>
|
|
20
|
+
type DirectiveHooks<V = any> = import('./directives').DirectiveHooks<V>
|
|
21
|
+
type DelegatedEventOptions = import('./event-delegation').DelegatedEventOptions
|
|
22
|
+
const defineStore: typeof import('./store').defineStore
|
|
23
|
+
const storeToRefs: typeof import('./store').storeToRefs
|
|
24
|
+
const storeToState: typeof import('./store').storeToState
|
|
25
|
+
const storeToGetters: typeof import('./store').storeToGetters
|
|
26
|
+
const useNestedStore: typeof import('./store').useNestedStore
|
|
27
|
+
type StoreHook<T> = import('./store').StoreHook<T>
|
|
28
|
+
const isDelegatedEvent: typeof import('./event-delegation').isDelegatedEvent
|
|
29
|
+
const InjectionToken: typeof import('./di').InjectionToken
|
|
30
|
+
const provideGlobal: typeof import('./di').provideGlobal
|
|
31
|
+
const reconcile: typeof import('./reconcile').reconcile
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export as namespace Fusee
|
|
35
|
+
|
|
36
|
+
declare module '*.template.html' {
|
|
37
|
+
export const render: (_ctx: any, _components: any) => any[]
|
|
38
|
+
}
|
|
@@ -7,6 +7,15 @@ export type Route = {
|
|
|
7
7
|
children?: Route[]
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export type ScrollPosition = { left: number; top: number } | { selector: string } | false
|
|
11
|
+
|
|
12
|
+
export type ScrollBehaviorOptions = {
|
|
13
|
+
scrollToTop?: boolean
|
|
14
|
+
scrollToAnchor?: boolean
|
|
15
|
+
saveScrollPosition?: boolean
|
|
16
|
+
custom?: (to: string, from: string, savedPosition: ScrollPosition | null) => ScrollPosition | Promise<ScrollPosition>
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
export type Router = {
|
|
11
20
|
navigate: (path: string) => void
|
|
12
21
|
destroy: () => void
|
|
@@ -16,9 +25,10 @@ export type RouteParams = Record<string, string>
|
|
|
16
25
|
|
|
17
26
|
export declare const currentRoute: Signal<string>
|
|
18
27
|
export declare const routeParams: Signal<RouteParams>
|
|
28
|
+
export declare const routeQuery: Signal<Record<string, string>>
|
|
19
29
|
export declare const matchedRoutes: Signal<Route[]>
|
|
20
30
|
|
|
21
|
-
export declare function createRouter(routes: Route[], options?: { cacheSize?: number; routerViewTimeout?: number }): Router
|
|
31
|
+
export declare function createRouter(routes: Route[], options?: { cacheSize?: number; routerViewTimeout?: number; scrollBehavior?: ScrollBehaviorOptions }): Router
|
|
22
32
|
export declare function navigate(path: string): void
|
|
23
33
|
export declare function mountOutlet(el: HTMLElement): void
|
|
24
34
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface RequestContext {
|
|
2
|
+
inFlightMaps: {
|
|
3
|
+
byKey: Map<string, Promise<any>>
|
|
4
|
+
byFetcher: WeakMap<Function, Map<string, Promise<any>>>
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare function createRequestContext(): RequestContext
|
|
9
|
+
export declare function withRequestContext<T>(ctx: RequestContext, fn: () => T): T
|
|
10
|
+
export declare function getInFlightStore(): RequestContext['inFlightMaps']
|
|
11
|
+
export declare function isSSRContext(): boolean
|
|
@@ -1,79 +1,142 @@
|
|
|
1
|
-
export type SignalAccessor<T> = {
|
|
2
|
-
(): T;
|
|
3
|
-
(newValue: T): void;
|
|
4
|
-
isSignal: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface ReactiveArrayMethods<T> {
|
|
8
|
-
map<U>(callbackfn: (value: T, index: number, array: T[]) => U): Computed<U[]>;
|
|
9
|
-
filter(predicate: (value: T, index: number, array: T[]) => boolean): Computed<T[]>;
|
|
10
|
-
slice(start?: number, end?: number): Computed<T[]>;
|
|
11
|
-
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): Computed<U>;
|
|
12
|
-
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): Computed<T>;
|
|
13
|
-
find(predicate: (value: T, index: number, obj: T[]) => boolean): Computed<T | undefined>;
|
|
14
|
-
findLast(predicate: (value: T, index: number, obj: T[]) => boolean): Computed<T | undefined>;
|
|
15
|
-
findIndex(predicate: (value: T, index: number, obj: T[]) => boolean): Computed<number>;
|
|
16
|
-
findLastIndex(predicate: (value: T, index: number, obj: T[]) => boolean): Computed<number>;
|
|
17
|
-
every(predicate: (value: T, index: number, array: T[]) => boolean): Computed<boolean>;
|
|
18
|
-
some(predicate: (value: T, index: number, array: T[]) => boolean): Computed<boolean>;
|
|
19
|
-
includes(searchElement: T, fromIndex?: number): Computed<boolean>;
|
|
20
|
-
indexOf(searchElement: T, fromIndex?: number): Computed<number>;
|
|
21
|
-
lastIndexOf(searchElement: T, fromIndex?: number): Computed<number>;
|
|
22
|
-
at(index: number): Computed<T | undefined>;
|
|
23
|
-
concat(...items: (T | T[])[]): Computed<T[]>;
|
|
24
|
-
flat<depth extends number = 1>(depth?: depth): Computed<any[]>;
|
|
25
|
-
flatMap<U>(callback: (value: T, index: number, array: T[]) => U | U[]): Computed<U[]>;
|
|
26
|
-
join(separator?: string): Computed<string>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type ArraySignalAccessor<T extends any[]> = SignalAccessor<T> & ReactiveArrayMethods<T[number]> & {
|
|
30
|
-
push(...items: T[number][]): number;
|
|
31
|
-
pop(): T[number] | undefined;
|
|
32
|
-
shift(): T[number] | undefined;
|
|
33
|
-
unshift(...items: T[number][]): number;
|
|
34
|
-
splice(start: number, deleteCount: number, ...items: T[number][]): T[number][];
|
|
35
|
-
remove(predicate: (item: T[number], index: number) => boolean): void;
|
|
36
|
-
clear(): void;
|
|
37
|
-
sort(compareFn?: (a: T[number], b: T[number]) => number): ArraySignalAccessor<T>;
|
|
38
|
-
reverse(): ArraySignalAccessor<T>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type ComputedAccessor<T> = {
|
|
42
|
-
(): T;
|
|
43
|
-
isSignal: boolean;
|
|
44
|
-
readonly: true;
|
|
45
|
-
} & (T extends any[] ? ReactiveArrayMethods<T[number]> : {})
|
|
46
|
-
|
|
47
|
-
export type Signal<T = any> = SignalAccessor<T> & (T extends any[] ? ReactiveArrayMethods<T[number]> : {})
|
|
48
|
-
export type Computed<T = any> = ComputedAccessor<T> & (T extends any[] ? ReactiveArrayMethods<T[number]> : {})
|
|
49
|
-
|
|
50
|
-
type EffectRunner = {
|
|
51
|
-
(): void;
|
|
52
|
-
deps: Set<Set<EffectRunner>>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type WatchSource<T = any> = (() => T) | Signal<T> | Computed<T>
|
|
56
|
-
export type WatchCallback<T = any> = (newValue: T, oldValue: T | undefined, onCleanup: (fn: () => void) => void) => void
|
|
57
|
-
|
|
58
|
-
export interface WatchOptions {
|
|
59
|
-
immediate?: boolean;
|
|
60
|
-
equals?: (a: any, b: any) => boolean;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
export type SignalAccessor<T> = {
|
|
2
|
+
(): T;
|
|
3
|
+
(newValue: T): void;
|
|
4
|
+
isSignal: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface ReactiveArrayMethods<T> {
|
|
8
|
+
map<U>(callbackfn: (value: T, index: number, array: T[]) => U): Computed<U[]>;
|
|
9
|
+
filter(predicate: (value: T, index: number, array: T[]) => boolean): Computed<T[]>;
|
|
10
|
+
slice(start?: number, end?: number): Computed<T[]>;
|
|
11
|
+
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): Computed<U>;
|
|
12
|
+
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): Computed<T>;
|
|
13
|
+
find(predicate: (value: T, index: number, obj: T[]) => boolean): Computed<T | undefined>;
|
|
14
|
+
findLast(predicate: (value: T, index: number, obj: T[]) => boolean): Computed<T | undefined>;
|
|
15
|
+
findIndex(predicate: (value: T, index: number, obj: T[]) => boolean): Computed<number>;
|
|
16
|
+
findLastIndex(predicate: (value: T, index: number, obj: T[]) => boolean): Computed<number>;
|
|
17
|
+
every(predicate: (value: T, index: number, array: T[]) => boolean): Computed<boolean>;
|
|
18
|
+
some(predicate: (value: T, index: number, array: T[]) => boolean): Computed<boolean>;
|
|
19
|
+
includes(searchElement: T, fromIndex?: number): Computed<boolean>;
|
|
20
|
+
indexOf(searchElement: T, fromIndex?: number): Computed<number>;
|
|
21
|
+
lastIndexOf(searchElement: T, fromIndex?: number): Computed<number>;
|
|
22
|
+
at(index: number): Computed<T | undefined>;
|
|
23
|
+
concat(...items: (T | T[])[]): Computed<T[]>;
|
|
24
|
+
flat<depth extends number = 1>(depth?: depth): Computed<any[]>;
|
|
25
|
+
flatMap<U>(callback: (value: T, index: number, array: T[]) => U | U[]): Computed<U[]>;
|
|
26
|
+
join(separator?: string): Computed<string>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type ArraySignalAccessor<T extends any[]> = SignalAccessor<T> & ReactiveArrayMethods<T[number]> & {
|
|
30
|
+
push(...items: T[number][]): number;
|
|
31
|
+
pop(): T[number] | undefined;
|
|
32
|
+
shift(): T[number] | undefined;
|
|
33
|
+
unshift(...items: T[number][]): number;
|
|
34
|
+
splice(start: number, deleteCount: number, ...items: T[number][]): T[number][];
|
|
35
|
+
remove(predicate: (item: T[number], index: number) => boolean): void;
|
|
36
|
+
clear(): void;
|
|
37
|
+
sort(compareFn?: (a: T[number], b: T[number]) => number): ArraySignalAccessor<T>;
|
|
38
|
+
reverse(): ArraySignalAccessor<T>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type ComputedAccessor<T> = {
|
|
42
|
+
(): T;
|
|
43
|
+
isSignal: boolean;
|
|
44
|
+
readonly: true;
|
|
45
|
+
} & (T extends any[] ? ReactiveArrayMethods<T[number]> : {})
|
|
46
|
+
|
|
47
|
+
export type Signal<T = any> = SignalAccessor<T> & (T extends any[] ? ReactiveArrayMethods<T[number]> : {})
|
|
48
|
+
export type Computed<T = any> = ComputedAccessor<T> & (T extends any[] ? ReactiveArrayMethods<T[number]> : {})
|
|
49
|
+
|
|
50
|
+
type EffectRunner = {
|
|
51
|
+
(): void;
|
|
52
|
+
deps: Set<Set<EffectRunner>>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type WatchSource<T = any> = (() => T) | Signal<T> | Computed<T>
|
|
56
|
+
export type WatchCallback<T = any> = (newValue: T, oldValue: T | undefined, onCleanup: (fn: () => void) => void) => void
|
|
57
|
+
|
|
58
|
+
export interface WatchOptions {
|
|
59
|
+
immediate?: boolean;
|
|
60
|
+
equals?: (a: any, b: any) => boolean;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type ResourceAccessor<T> = {
|
|
64
|
+
(): T | undefined;
|
|
65
|
+
read(): T;
|
|
66
|
+
isSignal: boolean;
|
|
67
|
+
loading: Signal<boolean>;
|
|
68
|
+
isFetching: Signal<boolean>;
|
|
69
|
+
error: Signal<any>;
|
|
70
|
+
} & (T extends any[] ? ReactiveArrayMethods<T[number]> : {})
|
|
71
|
+
|
|
72
|
+
export type ResourceActions<T> = {
|
|
73
|
+
mutate: (val: T) => void;
|
|
74
|
+
refetch: () => void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type ResourceReturn<T, R = unknown> = [
|
|
78
|
+
ResourceAccessor<T>,
|
|
79
|
+
{
|
|
80
|
+
mutate: (val: T) => void;
|
|
81
|
+
refetch: () => void;
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
export interface SuspenseOptions {
|
|
86
|
+
onError?: (err: any) => void;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface SuspenseSignal<T> {
|
|
90
|
+
(): T;
|
|
91
|
+
pending: Signal<boolean>;
|
|
92
|
+
error: Signal<any>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type Resource<T> = [ResourceAccessor<T>, ResourceActions<T>]
|
|
96
|
+
|
|
97
|
+
export declare function signal<T extends any[]>(initialValue: T): ArraySignalAccessor<T>
|
|
98
|
+
export declare function signal<T>(initialValue: T): SignalAccessor<T>
|
|
99
|
+
export declare function effect(fn: () => void): () => void
|
|
100
|
+
export declare function computed<T>(fn: () => T): Computed<T>
|
|
101
|
+
export declare function batch<T>(fn: () => T): T
|
|
102
|
+
export declare function untrack<T>(fn: () => T): T
|
|
103
|
+
export declare function watch<T>(source: WatchSource<T>, callback: WatchCallback<T>, options?: WatchOptions): () => void
|
|
104
|
+
export declare function watch<T extends any[]>(
|
|
105
|
+
sources: [...{ [K in keyof T]: WatchSource<T[K]> }],
|
|
106
|
+
callback: (newValue: T, oldValue: T | undefined, onCleanup: (fn: () => void) => void) => void,
|
|
107
|
+
options?: WatchOptions
|
|
108
|
+
): () => void
|
|
109
|
+
export declare function inspect(...args: any[]): (() => void) | void
|
|
110
|
+
export declare function onCleanup(fn: () => void): void
|
|
111
|
+
|
|
112
|
+
export function resource<T, R = any>(
|
|
113
|
+
fetcher: (input: R) => Promise<T>,
|
|
114
|
+
options?: ResourceOptions
|
|
115
|
+
): ResourceReturn<T, R>;
|
|
116
|
+
|
|
117
|
+
export function resource<T, R>(
|
|
118
|
+
source: () => R,
|
|
119
|
+
fetcher: (input: R) => Promise<T>,
|
|
120
|
+
options?: ResourceOptions
|
|
121
|
+
): ResourceReturn<T, R>;
|
|
122
|
+
|
|
123
|
+
export function createSuspense<T>(
|
|
124
|
+
renderFn: () => T,
|
|
125
|
+
fallbackFn: (() => T) | T,
|
|
126
|
+
options?: SuspenseOptions
|
|
127
|
+
): [SuspenseSignal<T>, () => void];
|
|
128
|
+
|
|
129
|
+
declare function setEffectHook(fn: (eff: any) => void): void
|
|
130
|
+
|
|
131
|
+
export type AsyncPriority = 'high' | 'low';
|
|
132
|
+
export interface AsyncJobOptions {
|
|
133
|
+
priority?: AsyncPriority;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function scheduleAsyncJob(fn: () => void, opts?: AsyncJobOptions): void;
|
|
137
|
+
|
|
138
|
+
export interface ResourceOptions<T = any> {
|
|
139
|
+
key?: string | number;
|
|
140
|
+
staleTime?: number;
|
|
141
|
+
fetchPriority?: AsyncPriority;
|
|
142
|
+
}
|