revojs 0.0.87 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +0,0 @@
1
- import { type Descriptor, Scope, type State } from "../signals";
2
- export type LocaleOptions = {
3
- locales: Record<string, Record<string, string>>;
4
- defaultLocale: string;
5
- input: string;
6
- };
7
- export type LocaleContext = {
8
- locale: State<string | undefined>;
9
- messages: State<Record<string, string> | undefined>;
10
- options: LocaleOptions;
11
- };
12
- export declare function provideLocaleContext(scope: Scope, options: LocaleOptions): {
13
- locale: State<string | undefined>;
14
- messages: State<Record<string, string> | undefined>;
15
- options: LocaleOptions;
16
- $: (key: string) => () => string | number | symbol;
17
- $date: (date?: Date, options?: Intl.DateTimeFormatOptions) => string | undefined;
18
- };
19
- export declare function useLocale<T extends LocaleContext>(scope: Scope, context?: Descriptor<T>): {
20
- locale: State<string | undefined>;
21
- messages: State<Record<string, string> | undefined>;
22
- options: LocaleOptions;
23
- $: (key: keyof T["options"]["locales"][keyof T["options"]["locales"]]) => () => string | number | symbol;
24
- $date: (date?: Date, options?: Intl.DateTimeFormatOptions) => string | undefined;
25
- };
26
- export declare const LOCALE_CONTEXT: Descriptor<LocaleContext>;
@@ -1,12 +0,0 @@
1
- export type Match<T> = {
2
- value?: T;
3
- inputs: Record<string, string>;
4
- };
5
- export declare class Radix<T> {
6
- value?: T;
7
- input?: string;
8
- children: Record<string, Radix<T>>;
9
- constructor(input?: string);
10
- insert(path: string, value: T): this;
11
- match(path: string): Match<T>;
12
- }
@@ -1,45 +0,0 @@
1
- import { type Slot } from "../html";
2
- import { Radix } from "../radix";
3
- import { type Descriptor, Scope, type State } from "../signals";
4
- export type RouterOptions = {
5
- routes: Record<string, Slot>;
6
- };
7
- export type RouterContext = {
8
- url: State<URL | undefined>;
9
- route: State<Slot | undefined>;
10
- radix: Radix<Slot>;
11
- navigator: EventTarget;
12
- options: RouterOptions;
13
- };
14
- export declare class NavigateEvent extends Event {
15
- constructor();
16
- }
17
- export declare class AfterNavigateEvent extends Event {
18
- constructor();
19
- }
20
- export declare function provideRouterContext(scope: Scope, options: RouterOptions): {
21
- url: State<URL | undefined>;
22
- route: State<unknown>;
23
- navigator: EventTarget;
24
- options: RouterOptions;
25
- radix: Radix<unknown>;
26
- navigate: (path: string) => void;
27
- anchorNavigate: (event: Event) => void;
28
- };
29
- export declare function useRouter<T extends RouterContext>(scope: Scope, context?: Descriptor<T>): {
30
- url: State<URL | undefined>;
31
- route: State<unknown>;
32
- navigator: EventTarget;
33
- options: RouterOptions;
34
- radix: Radix<unknown>;
35
- navigate: (path: string) => void;
36
- anchorNavigate: (event: Event) => void;
37
- };
38
- export declare const Page: import("..").ComponentConstructor<import("..").Events, import("..").Attributes>;
39
- export declare const ROUTER_CONTEXT: Descriptor<RouterContext>;
40
- declare global {
41
- interface ElementEventMap {
42
- navigate: NavigateEvent;
43
- afterNavigate: AfterNavigateEvent;
44
- }
45
- }
@@ -1,55 +0,0 @@
1
- import { type Chain, type Handle, type ResponseOptions } from "../http";
2
- import { Radix } from "../radix";
3
- import { Scope, type State } from "../signals";
4
- export type Route = {
5
- fetch: Handle;
6
- };
7
- export type Middleware = {
8
- fetch: Chain;
9
- };
10
- export type Runtime = {
11
- radix: Radix<Route>;
12
- middlewares: Array<Middleware>;
13
- fetch: (scope: Scope) => Promise<Response>;
14
- };
15
- export type RuntimeContext<T = Record<string, unknown>> = {
16
- tasks: Array<Promise<unknown>>;
17
- states: Record<string, State<unknown>>;
18
- request: Request;
19
- response: ResponseOptions;
20
- variables: T;
21
- };
22
- export type RouteContext = {
23
- inputs: State<Record<string, string>>;
24
- };
25
- export type AsyncOptions<T> = {
26
- viewTransition?: false | string;
27
- catch?: (error: T) => void | Promise<void>;
28
- };
29
- export declare function isRoute<T>(value?: T): value is Route & T;
30
- export declare function useRuntime<T = Record<string, unknown>>(scope: Scope): RuntimeContext<T>;
31
- export declare function useRoute(scope: Scope): RouteContext;
32
- export declare function useRoutes(): Promise<Record<string, unknown>>;
33
- export declare function useAssets(): Promise<Record<string, string>>;
34
- export declare function useLocales(): Promise<Record<string, Record<string, string>>>;
35
- export declare function defineRoute(route: Route): Route;
36
- export declare function defineMiddleware(middleware: Middleware): Middleware;
37
- export declare function fileName(path: string): string | undefined;
38
- export declare function toPath(value: string): (string | undefined)[];
39
- export declare function $fetch<T>(scope: Scope, input: string | URL, options?: RequestInit): Promise<T>;
40
- export declare function useState<T>(scope: Scope, name: string): State<T | undefined>;
41
- export declare function useState<T>(scope: Scope, name: string, value: T): State<T>;
42
- export declare function useAsync<T, TError = Error>(scope: Scope, name: string, invoke: () => Promise<T>, defaultOptions?: AsyncOptions<TError>): {
43
- state: State<T | undefined>;
44
- isLoading: State<boolean>;
45
- execute: (options?: AsyncOptions<TError>) => Promise<T | undefined>;
46
- };
47
- export declare function useFetch<T, TError = Error>(scope: Scope, input: string | URL, options?: RequestInit & AsyncOptions<TError>): {
48
- state: State<T | undefined>;
49
- isLoading: State<boolean>;
50
- execute: (options?: AsyncOptions<TError> | undefined) => Promise<T | undefined>;
51
- };
52
- export declare function createRuntime(): Promise<Runtime>;
53
- export declare let STATES: Record<string, unknown>;
54
- export declare const RUNTIME_CONTEXT: import("..").Descriptor<RuntimeContext<Record<string, unknown>>>;
55
- export declare const ROUTE_CONTEXT: import("..").Descriptor<RouteContext>;
@@ -1,22 +0,0 @@
1
- export type Issue = {
2
- readonly message: string;
3
- };
4
- export type Success<T> = {
5
- readonly value: T;
6
- };
7
- export type Failure = {
8
- readonly issues: ReadonlyArray<Issue>;
9
- };
10
- export type Result<Output> = Success<Output> | Failure;
11
- export type Schema<T = unknown, TOutput = T> = {
12
- readonly "~standard": {
13
- readonly validate: (value: unknown) => Result<TOutput>;
14
- readonly types?: {
15
- readonly input: T;
16
- readonly output: TOutput;
17
- };
18
- };
19
- };
20
- export type InferInput<T extends Schema> = NonNullable<T["~standard"]["types"]>["input"];
21
- export type InferOutput<T extends Schema> = NonNullable<T["~standard"]["types"]>["output"];
22
- export declare function isFailure<T>(result: Result<T>): result is Failure;
@@ -1,44 +0,0 @@
1
- declare const descriptor: unique symbol;
2
- export type Value<T> = T | (() => Value<T>);
3
- export type Descriptor<T> = string & {
4
- [descriptor]: T;
5
- };
6
- export interface State<T> {
7
- value: T;
8
- }
9
- export declare class StopEvent extends Event {
10
- constructor();
11
- }
12
- export declare class Scope extends EventTarget {
13
- parentScope?: Scope;
14
- readonly context: Map<string, unknown>;
15
- constructor(parentScope?: Scope);
16
- getContext<T>(input: Descriptor<T>): T;
17
- setContext<T>(input: Descriptor<T>, value: T): void;
18
- onStop(input: (event: StopEvent) => void): void;
19
- stop(): boolean;
20
- }
21
- export declare class Compute<T = void> extends Scope {
22
- readonly invoke: (scope: Scope) => T;
23
- constructor(parentScope: Scope, invoke: (scope: Scope) => T);
24
- run(): T;
25
- }
26
- export declare class Handler<T extends object> implements ProxyHandler<T> {
27
- get(target: T, key: string | symbol): unknown;
28
- set(target: T, key: string | symbol, value: unknown): boolean;
29
- }
30
- export declare function createState<T>(): State<T | undefined>;
31
- export declare function createState<T>(value: T): State<T>;
32
- export declare function createCompute<T>(scope: Scope, invoke: (scope: Scope) => T): T;
33
- export declare function createMemo<T>(scope: Scope, invoke: (scope: Scope) => T): State<T>;
34
- export declare function fromValue<T>(value: Value<T>): T;
35
- export declare function untrack<T>(invoke: () => T): T;
36
- export declare function defineContext<T>(key: string): Descriptor<T>;
37
- export declare let activeCompute: Compute | undefined;
38
- export declare const targets: WeakMap<object, Map<string | symbol, Set<Compute<void>>>>;
39
- declare global {
40
- interface ElementEventMap {
41
- stop: StopEvent;
42
- }
43
- }
44
- export {};