revojs 0.0.88 → 0.1.1
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/dist/index.d.ts +176 -9
- package/dist/index.js +220 -915
- package/dist/vite/index.d.ts +53 -0
- package/dist/vite/index.js +468 -0
- package/package.json +11 -10
- package/src/types/index.d.ts +20 -16
- package/dist/app/index.d.ts +0 -36
- package/dist/html/index.d.ts +0 -110
- package/dist/http/index.d.ts +0 -41
- package/dist/jsx/index.d.ts +0 -371
- package/dist/jsx/index.js +0 -160
- package/dist/locale/index.d.ts +0 -26
- package/dist/radix/index.d.ts +0 -12
- package/dist/router/index.d.ts +0 -45
- package/dist/runtime/index.d.ts +0 -55
- package/dist/schema/index.d.ts +0 -24
- package/dist/signals/index.d.ts +0 -44
package/dist/jsx/index.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
//#region src/signals/index.ts
|
|
2
|
-
var Handler = class Handler {
|
|
3
|
-
get(target, key) {
|
|
4
|
-
const compute = activeCompute;
|
|
5
|
-
if (compute) {
|
|
6
|
-
const computes = targets.get(target) ?? /* @__PURE__ */ new Map();
|
|
7
|
-
const set = computes.get(key) ?? /* @__PURE__ */ new Set();
|
|
8
|
-
computes.set(key, set.add(compute));
|
|
9
|
-
targets.set(target, computes);
|
|
10
|
-
compute.parentScope?.onStop(() => {
|
|
11
|
-
set.delete(compute);
|
|
12
|
-
if (set.size === 0) {
|
|
13
|
-
computes.delete(key);
|
|
14
|
-
if (computes.size === 0) targets.delete(target);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
const value = Reflect.get(target, key);
|
|
19
|
-
if (value) {
|
|
20
|
-
if (typeof value === "function" && !value.prototype) return value.bind(target);
|
|
21
|
-
if (typeof value === "object") {
|
|
22
|
-
const tag = Object.prototype.toString.call(value);
|
|
23
|
-
if (tag === "[object Object]" || tag === "[object Array]" || tag === "[object Map]" || tag === "[object Set]" || tag === "[object WeakMap]" || tag === "[object WeakSet]") return new Proxy(value, new Handler());
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
set(target, key, value) {
|
|
29
|
-
const result = Reflect.set(target, key, value);
|
|
30
|
-
for (const compute of targets.get(target)?.get(key) ?? []) compute.run();
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
function createState(value) {
|
|
35
|
-
return new Proxy({ value }, new Handler());
|
|
36
|
-
}
|
|
37
|
-
function defineContext(key) {
|
|
38
|
-
return key;
|
|
39
|
-
}
|
|
40
|
-
let activeCompute;
|
|
41
|
-
const targets = /* @__PURE__ */ new WeakMap();
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/runtime/index.ts
|
|
45
|
-
const RUNTIME_CONTEXT = defineContext("RUNTIME_CONTEXT");
|
|
46
|
-
const ROUTE_CONTEXT = defineContext("ROUTE_CONTEXT");
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/html/index.ts
|
|
50
|
-
function isComponent(value) {
|
|
51
|
-
return !!value && typeof value === "function" && "$name" in value;
|
|
52
|
-
}
|
|
53
|
-
function createElement(input, attributes, ...children) {
|
|
54
|
-
if (isComponent(input)) return {
|
|
55
|
-
tag: input.$name,
|
|
56
|
-
attributes: attributes ?? {},
|
|
57
|
-
children
|
|
58
|
-
};
|
|
59
|
-
if (typeof input === "string") return {
|
|
60
|
-
tag: input,
|
|
61
|
-
attributes: attributes ?? {},
|
|
62
|
-
children
|
|
63
|
-
};
|
|
64
|
-
return input?.({
|
|
65
|
-
...attributes,
|
|
66
|
-
children
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
const activeViewTransition = createState();
|
|
70
|
-
const HOST_CONTEXT = defineContext("HOST_CONTEXT");
|
|
71
|
-
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/jsx/index.ts
|
|
74
|
-
const svgElements = new Set([
|
|
75
|
-
"altGlyph",
|
|
76
|
-
"altGlyphDef",
|
|
77
|
-
"altGlyphItem",
|
|
78
|
-
"animate",
|
|
79
|
-
"animateColor",
|
|
80
|
-
"animateMotion",
|
|
81
|
-
"animateTransform",
|
|
82
|
-
"circle",
|
|
83
|
-
"clipPath",
|
|
84
|
-
"color-profile",
|
|
85
|
-
"cursor",
|
|
86
|
-
"defs",
|
|
87
|
-
"desc",
|
|
88
|
-
"ellipse",
|
|
89
|
-
"feBlend",
|
|
90
|
-
"feColorMatrix",
|
|
91
|
-
"feComponentTransfer",
|
|
92
|
-
"feComposite",
|
|
93
|
-
"feConvolveMatrix",
|
|
94
|
-
"feDiffuseLighting",
|
|
95
|
-
"feDisplacementMap",
|
|
96
|
-
"feDistantLight",
|
|
97
|
-
"feDropShadow",
|
|
98
|
-
"feFlood",
|
|
99
|
-
"feFuncA",
|
|
100
|
-
"feFuncB",
|
|
101
|
-
"feFuncG",
|
|
102
|
-
"feFuncR",
|
|
103
|
-
"feGaussianBlur",
|
|
104
|
-
"feImage",
|
|
105
|
-
"feMerge",
|
|
106
|
-
"feMergeNode",
|
|
107
|
-
"feMorphology",
|
|
108
|
-
"feOffset",
|
|
109
|
-
"fePointLight",
|
|
110
|
-
"feSpecularLighting",
|
|
111
|
-
"feSpotLight",
|
|
112
|
-
"feTile",
|
|
113
|
-
"feTurbulence",
|
|
114
|
-
"filter",
|
|
115
|
-
"font",
|
|
116
|
-
"font-face",
|
|
117
|
-
"font-face-format",
|
|
118
|
-
"font-face-name",
|
|
119
|
-
"font-face-src",
|
|
120
|
-
"font-face-uri",
|
|
121
|
-
"foreignObject",
|
|
122
|
-
"g",
|
|
123
|
-
"glyph",
|
|
124
|
-
"glyphRef",
|
|
125
|
-
"hkern",
|
|
126
|
-
"image",
|
|
127
|
-
"line",
|
|
128
|
-
"linearGradient",
|
|
129
|
-
"marker",
|
|
130
|
-
"mask",
|
|
131
|
-
"metadata",
|
|
132
|
-
"missing-glyph",
|
|
133
|
-
"mpath",
|
|
134
|
-
"path",
|
|
135
|
-
"pattern",
|
|
136
|
-
"polygon",
|
|
137
|
-
"polyline",
|
|
138
|
-
"radialGradient",
|
|
139
|
-
"rect",
|
|
140
|
-
"set",
|
|
141
|
-
"stop",
|
|
142
|
-
"svg",
|
|
143
|
-
"switch",
|
|
144
|
-
"symbol",
|
|
145
|
-
"text",
|
|
146
|
-
"textPath",
|
|
147
|
-
"tref",
|
|
148
|
-
"tspan",
|
|
149
|
-
"use",
|
|
150
|
-
"view",
|
|
151
|
-
"vkern"
|
|
152
|
-
]);
|
|
153
|
-
function namespace(tag) {
|
|
154
|
-
return svgElements.has(tag) ? "http://www.w3.org/2000/svg" : "http://www.w3.org/1999/xhtml";
|
|
155
|
-
}
|
|
156
|
-
const h = createElement;
|
|
157
|
-
const fragment = ({ children }) => children;
|
|
158
|
-
|
|
159
|
-
//#endregion
|
|
160
|
-
export { fragment, h, namespace, svgElements };
|
package/dist/locale/index.d.ts
DELETED
|
@@ -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>;
|
package/dist/radix/index.d.ts
DELETED
|
@@ -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
|
-
}
|
package/dist/router/index.d.ts
DELETED
|
@@ -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
|
-
}
|
package/dist/runtime/index.d.ts
DELETED
|
@@ -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>;
|
package/dist/schema/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Scope } from "../signals";
|
|
2
|
-
export type Issue = {
|
|
3
|
-
readonly message: string;
|
|
4
|
-
};
|
|
5
|
-
export type Success<T> = {
|
|
6
|
-
readonly value: T;
|
|
7
|
-
};
|
|
8
|
-
export type Failure = {
|
|
9
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
10
|
-
};
|
|
11
|
-
export type Result<Output> = Success<Output> | Failure;
|
|
12
|
-
export type Schema<T = unknown, TOutput = T> = {
|
|
13
|
-
readonly "~standard": {
|
|
14
|
-
readonly validate: (value: unknown) => Result<TOutput> | Promise<Result<TOutput>>;
|
|
15
|
-
readonly types?: {
|
|
16
|
-
readonly input: T;
|
|
17
|
-
readonly output: TOutput;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export type InferInput<T extends Schema> = NonNullable<T["~standard"]["types"]>["input"];
|
|
22
|
-
export type InferOutput<T extends Schema> = NonNullable<T["~standard"]["types"]>["output"];
|
|
23
|
-
export declare function isFailure<T>(result: Result<T>): result is Failure;
|
|
24
|
-
export declare function parseSchema<T extends Schema>(scope: Scope, schema: T, value: unknown): InferOutput<T>;
|
package/dist/signals/index.d.ts
DELETED
|
@@ -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 {};
|