@epoch32/visage 1.0.0 → 1.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/api/client.d.ts +5 -0
- package/dist/api/file-router.d.ts +29 -0
- package/dist/api/handler.d.ts +15 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/{src/api → api}/index.js +87 -2
- package/dist/api/middleware.d.ts +11 -0
- package/dist/api/pragma.d.ts +21 -0
- package/dist/api/procedure.d.ts +66 -0
- package/dist/api/types.d.ts +181 -0
- package/dist/charts/Area.d.ts +18 -0
- package/dist/charts/Axis.d.ts +21 -0
- package/dist/charts/Bar.d.ts +10 -0
- package/dist/charts/CartesianGrid.d.ts +10 -0
- package/dist/charts/Chart.d.ts +16 -0
- package/dist/charts/Cursor.d.ts +8 -0
- package/dist/charts/Legend.d.ts +9 -0
- package/dist/charts/Line.d.ts +18 -0
- package/dist/charts/Pie.d.ts +12 -0
- package/dist/charts/Tooltip.d.ts +12 -0
- package/dist/charts/context.d.ts +20 -0
- package/dist/charts/index.d.ts +14 -0
- package/dist/{src/charts → charts}/index.js +87 -2
- package/dist/charts/path.d.ts +27 -0
- package/dist/charts/scale.d.ts +23 -0
- package/dist/charts/types.d.ts +43 -0
- package/dist/devtools/DomTab.d.ts +6 -0
- package/dist/devtools/GraphInspector.d.ts +11 -0
- package/dist/devtools/GraphTab.d.ts +10 -0
- package/dist/devtools/QueryTab.d.ts +10 -0
- package/dist/devtools/RpcTab.d.ts +10 -0
- package/dist/devtools/SignalsTab.d.ts +10 -0
- package/dist/devtools/component.d.ts +2 -0
- package/dist/devtools/highlighter.d.ts +2 -0
- package/dist/devtools/hub.d.ts +41 -0
- package/dist/devtools/index.d.ts +9 -0
- package/dist/{src/devtools → devtools}/index.js +87 -2
- package/dist/devtools/styles.d.ts +1 -0
- package/dist/devtools/types.d.ts +44 -0
- package/dist/dom/async.d.ts +41 -0
- package/dist/dom/control-flow.d.ts +53 -0
- package/dist/dom/index.d.ts +3 -0
- package/dist/{src/dom → dom}/index.js +87 -2
- package/dist/dom/lazy.d.ts +30 -0
- package/dist/dom/render.d.ts +23 -0
- package/dist/dom/resource.d.ts +34 -0
- package/dist/form/form.d.ts +41 -0
- package/dist/form/index.d.ts +2 -0
- package/dist/{src/form → form}/index.js +87 -2
- package/dist/form/schema.d.ts +96 -0
- package/dist/index.d.ts +15 -0
- package/dist/{src/index.js → index.js} +87 -2
- package/dist/jsx-dev-runtime/index.d.ts +1 -0
- package/dist/jsx-runtime/index.d.ts +8 -0
- package/dist/{src/jsx-runtime → jsx-runtime}/index.js +87 -2
- package/dist/jsx-runtime/jsx.d.ts +278 -0
- package/dist/query/create-mutation.d.ts +3 -0
- package/dist/query/create-query.d.ts +4 -0
- package/dist/query/focus-manager.d.ts +14 -0
- package/dist/query/index.d.ts +9 -0
- package/dist/{src/query → query}/index.js +87 -2
- package/dist/query/mutation-cache.d.ts +24 -0
- package/dist/query/online-manager.d.ts +14 -0
- package/dist/query/query-cache.d.ts +69 -0
- package/dist/query/query-client.d.ts +46 -0
- package/dist/query/types.d.ts +131 -0
- package/dist/query/utils.d.ts +16 -0
- package/dist/router/index.d.ts +1 -0
- package/dist/{src/router → router}/index.js +87 -2
- package/dist/router/router.d.ts +91 -0
- package/dist/rpc/client.d.ts +2 -0
- package/dist/rpc/error.d.ts +16 -0
- package/dist/rpc/index.d.ts +7 -0
- package/dist/{src/rpc → rpc}/index.js +87 -2
- package/dist/rpc/procedure.d.ts +8 -0
- package/dist/rpc/router.d.ts +19 -0
- package/dist/rpc/server.d.ts +3 -0
- package/dist/rpc/types.d.ts +200 -0
- package/dist/server/hydrate.d.ts +5 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/{src/server → server}/index.js +87 -2
- package/dist/server/render-to-stream.d.ts +9 -0
- package/dist/server/render-to-string.d.ts +6 -0
- package/dist/signals/computed.d.ts +61 -0
- package/dist/signals/context.d.ts +44 -0
- package/dist/signals/effect.d.ts +56 -0
- package/dist/signals/index.d.ts +8 -0
- package/dist/{src/signals → signals}/index.js +87 -2
- package/dist/signals/scope.d.ts +61 -0
- package/dist/signals/signal.d.ts +40 -0
- package/dist/signals/store.d.ts +45 -0
- package/dist/signals/system.d.ts +56 -0
- package/dist/signals/types.d.ts +58 -0
- package/dist/style/component.d.ts +49 -0
- package/dist/style/create-style.d.ts +63 -0
- package/dist/style/cx.d.ts +18 -0
- package/dist/style/hash.d.ts +8 -0
- package/dist/style/index.d.ts +8 -0
- package/dist/{src/style → style}/index.js +87 -2
- package/dist/style/layout.d.ts +129 -0
- package/dist/style/manager.d.ts +31 -0
- package/dist/style/parser.d.ts +12 -0
- package/dist/style/scale.d.ts +82 -0
- package/dist/template/index.d.ts +1 -0
- package/dist/{src/template → template}/index.js +87 -2
- package/dist/template/template.d.ts +8 -0
- package/dist/ui/accordion.d.ts +81 -0
- package/dist/ui/command-dialog.d.ts +10 -0
- package/dist/ui/command.d.ts +103 -0
- package/dist/ui/data-table.d.ts +38 -0
- package/dist/ui/dialog.d.ts +102 -0
- package/dist/ui/dropdown-menu.d.ts +92 -0
- package/dist/ui/icon.d.ts +18 -0
- package/dist/ui/index.d.ts +14 -0
- package/dist/{src/ui → ui}/index.js +87 -2
- package/dist/ui/layout.d.ts +1 -0
- package/dist/ui/popover.d.ts +68 -0
- package/dist/ui/switch.d.ts +31 -0
- package/dist/ui/tabs.d.ts +71 -0
- package/dist/ui/toast.d.ts +91 -0
- package/dist/ui/tooltip.d.ts +64 -0
- package/dist/ui/utils.d.ts +21 -0
- package/dist/virtual/index.d.ts +2 -0
- package/dist/{src/virtual → virtual}/index.js +87 -2
- package/dist/virtual/virtual-list.d.ts +21 -0
- package/dist/virtual/virtualizer.d.ts +31 -0
- package/dist/vite/hmr.d.ts +7 -0
- package/dist/vite/index.d.ts +3 -0
- package/dist/{src/vite → vite}/index.js +4 -0
- package/dist/vite/lucide.d.ts +27 -0
- package/dist/vite/plugin.d.ts +3 -0
- package/dist/vite/rpc-middleware.d.ts +5 -0
- package/dist/vite/types.d.ts +59 -0
- package/package.json +40 -40
- package/src/signals/index.ts +1 -0
- package/src/signals/signal.ts +110 -2
- package/src/signals/types.ts +9 -0
- package/src/vite/plugin.ts +4 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FileRouteModule, RouteMatch } from "./types";
|
|
2
|
+
export interface FileRouteEntry {
|
|
3
|
+
filePath: string;
|
|
4
|
+
module: FileRouteModule;
|
|
5
|
+
sourceCode?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Compile a route path pattern into a regex and parameter list
|
|
9
|
+
* e.g. `/admin/users/:id` or `/admin/files/*slug`
|
|
10
|
+
*/
|
|
11
|
+
export declare function compileRoutePattern(path: string): {
|
|
12
|
+
pattern: RegExp;
|
|
13
|
+
paramNames: string[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Normalize a file path to an API URL route path and directory
|
|
17
|
+
*/
|
|
18
|
+
export declare function normalizeFilePath(rawPath: string): {
|
|
19
|
+
isMiddleware: boolean;
|
|
20
|
+
routePath: string;
|
|
21
|
+
directory: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Build a file-based routing manifest with hierarchical middleware cascades
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildFileRouter(files: Record<string, FileRouteModule | {
|
|
27
|
+
default?: any;
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}>, sourceMap?: Record<string, string>): RouteMatch[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ApiRouterConfig, FileRouteModule, RouteMatch } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Create a standard Web Fetch API handler from compiled route manifests
|
|
4
|
+
*/
|
|
5
|
+
export declare function createApiHandler(routes: RouteMatch[], config?: ApiRouterConfig): (req: Request) => Promise<Response>;
|
|
6
|
+
/**
|
|
7
|
+
* High-level createApi factory for file-based API routers
|
|
8
|
+
*/
|
|
9
|
+
export declare function createApi(files: Record<string, FileRouteModule | {
|
|
10
|
+
default?: any;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}>, sourceMapOrConfig?: Record<string, string> | ApiRouterConfig, maybeConfig?: ApiRouterConfig): {
|
|
13
|
+
routes: RouteMatch[];
|
|
14
|
+
fetch: (req: Request) => Promise<Response>;
|
|
15
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visage File-Based API & Opinionated RPC Framework (visage/api)
|
|
3
|
+
*/
|
|
4
|
+
export { Schema, type SchemaLike, type StandardSchemaV1, type ValidationIssue, type ValidationResult, v, validateWithSchema } from "../form/schema";
|
|
5
|
+
export { ERROR_CODE_TO_STATUS, RPCError, STATUS_TO_ERROR_CODE } from "../rpc/error";
|
|
6
|
+
export { createApiClient } from "./client";
|
|
7
|
+
export { buildFileRouter, compileRoutePattern, type FileRouteEntry, normalizeFilePath } from "./file-router";
|
|
8
|
+
export { createApi, createApiHandler } from "./handler";
|
|
9
|
+
export { executeMiddlewareChain } from "./middleware";
|
|
10
|
+
export { globToRegExp, matchesAnyPattern, parsePragma, shouldApplyMiddleware } from "./pragma";
|
|
11
|
+
export { defineMiddleware, mutation, ProcedureBuilder, procedure, query, subscription } from "./procedure";
|
|
12
|
+
export type { ApiCallOptions, ApiClient, ApiClientHeadersRule, ApiClientOptions, ApiEndpointMethods, ApiMethodCaller, ApiProcedure, ApiRouterConfig, ApiSubscriptionCallbacks, ApiSubscriptionCaller, ApiSubscriptionHandle, FileRouteModule, HttpMethod, InferApiInput, InferApiOutput, MiddlewareContext, MiddlewareDefinition, MiddlewareFn, MiddlewarePragma, NextFn, ProcedureOptions, ProcedureType, RouteMatch, RPCErrorCode } from "./types";
|
|
@@ -1112,10 +1112,12 @@ class Signal {
|
|
|
1112
1112
|
_value;
|
|
1113
1113
|
_subscribers = new Set;
|
|
1114
1114
|
_equals;
|
|
1115
|
+
_onSet;
|
|
1115
1116
|
version = 0;
|
|
1116
|
-
constructor(initialValue, equals) {
|
|
1117
|
+
constructor(initialValue, equals, onSet) {
|
|
1117
1118
|
this._value = initialValue;
|
|
1118
1119
|
this._equals = equals ?? Object.is;
|
|
1120
|
+
this._onSet = onSet;
|
|
1119
1121
|
}
|
|
1120
1122
|
get() {
|
|
1121
1123
|
if (currentSubscriber !== null && currentSubscriber.state !== 3 /* DISPOSED */) {
|
|
@@ -1140,6 +1142,9 @@ class Signal {
|
|
|
1140
1142
|
}
|
|
1141
1143
|
this._value = newValue;
|
|
1142
1144
|
this.version++;
|
|
1145
|
+
if (this._onSet) {
|
|
1146
|
+
this._onSet(newValue);
|
|
1147
|
+
}
|
|
1143
1148
|
batch(() => {
|
|
1144
1149
|
this.notify();
|
|
1145
1150
|
});
|
|
@@ -1165,11 +1170,91 @@ class Signal {
|
|
|
1165
1170
|
}
|
|
1166
1171
|
}
|
|
1167
1172
|
}
|
|
1173
|
+
function resolveStorage(storageOption) {
|
|
1174
|
+
if (storageOption && typeof storageOption === "object") {
|
|
1175
|
+
return storageOption;
|
|
1176
|
+
}
|
|
1177
|
+
if (storageOption === "session") {
|
|
1178
|
+
try {
|
|
1179
|
+
if (typeof sessionStorage !== "undefined")
|
|
1180
|
+
return sessionStorage;
|
|
1181
|
+
} catch {}
|
|
1182
|
+
try {
|
|
1183
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
1184
|
+
return window.sessionStorage;
|
|
1185
|
+
}
|
|
1186
|
+
} catch {}
|
|
1187
|
+
try {
|
|
1188
|
+
if (typeof globalThis !== "undefined" && globalThis.sessionStorage) {
|
|
1189
|
+
return globalThis.sessionStorage;
|
|
1190
|
+
}
|
|
1191
|
+
} catch {}
|
|
1192
|
+
return null;
|
|
1193
|
+
}
|
|
1194
|
+
try {
|
|
1195
|
+
if (typeof localStorage !== "undefined")
|
|
1196
|
+
return localStorage;
|
|
1197
|
+
} catch {}
|
|
1198
|
+
try {
|
|
1199
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
1200
|
+
return window.localStorage;
|
|
1201
|
+
}
|
|
1202
|
+
} catch {}
|
|
1203
|
+
try {
|
|
1204
|
+
if (typeof globalThis !== "undefined" && globalThis.localStorage) {
|
|
1205
|
+
return globalThis.localStorage;
|
|
1206
|
+
}
|
|
1207
|
+
} catch {}
|
|
1208
|
+
return null;
|
|
1209
|
+
}
|
|
1168
1210
|
function signal(initialValue, optionsOrEquals) {
|
|
1169
1211
|
const equals = typeof optionsOrEquals === "function" ? optionsOrEquals : optionsOrEquals?.equals;
|
|
1170
1212
|
const isInternal = typeof optionsOrEquals === "object" ? optionsOrEquals?.internal : false;
|
|
1171
1213
|
const customName = typeof optionsOrEquals === "object" ? optionsOrEquals?.name : undefined;
|
|
1172
|
-
const
|
|
1214
|
+
const persistOption = typeof optionsOrEquals === "object" ? optionsOrEquals?.persist : undefined;
|
|
1215
|
+
const persistConfig = persistOption ? typeof persistOption === "string" ? { key: persistOption } : persistOption : undefined;
|
|
1216
|
+
let effectiveInitial = initialValue;
|
|
1217
|
+
const storage = persistConfig ? resolveStorage(persistConfig.storage) : null;
|
|
1218
|
+
const serialize = persistConfig?.serialize ?? JSON.stringify;
|
|
1219
|
+
const deserialize = persistConfig?.deserialize ?? JSON.parse;
|
|
1220
|
+
if (persistConfig && storage) {
|
|
1221
|
+
try {
|
|
1222
|
+
const stored = storage.getItem(persistConfig.key);
|
|
1223
|
+
if (stored !== null) {
|
|
1224
|
+
effectiveInitial = deserialize(stored);
|
|
1225
|
+
}
|
|
1226
|
+
} catch {}
|
|
1227
|
+
}
|
|
1228
|
+
let isSyncing = false;
|
|
1229
|
+
const onSet = persistConfig && storage ? (val) => {
|
|
1230
|
+
if (isSyncing)
|
|
1231
|
+
return;
|
|
1232
|
+
try {
|
|
1233
|
+
storage.setItem(persistConfig.key, serialize(val));
|
|
1234
|
+
} catch {}
|
|
1235
|
+
} : undefined;
|
|
1236
|
+
const s = new Signal(effectiveInitial, equals, onSet);
|
|
1237
|
+
if (persistConfig && storage && (persistConfig.syncTabs ?? true) && typeof window !== "undefined" && typeof window.addEventListener === "function") {
|
|
1238
|
+
const onStorage = (e) => {
|
|
1239
|
+
if (e.key === persistConfig.key) {
|
|
1240
|
+
try {
|
|
1241
|
+
const nextVal = e.newValue !== null ? deserialize(e.newValue) : initialValue;
|
|
1242
|
+
isSyncing = true;
|
|
1243
|
+
try {
|
|
1244
|
+
s.set(nextVal);
|
|
1245
|
+
} finally {
|
|
1246
|
+
isSyncing = false;
|
|
1247
|
+
}
|
|
1248
|
+
} catch {}
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
window.addEventListener("storage", onStorage);
|
|
1252
|
+
if (currentScope) {
|
|
1253
|
+
currentScope.addCleanup(() => {
|
|
1254
|
+
window.removeEventListener("storage", onStorage);
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1173
1258
|
const accessor = (...args) => {
|
|
1174
1259
|
if (args.length === 0) {
|
|
1175
1260
|
return s.get();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visage Middleware Execution Engine & Context Propagation
|
|
3
|
+
*/
|
|
4
|
+
import type { MiddlewareFn } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Execute a chain of middlewares, accumulating context and returning either an early Response or merged Context
|
|
7
|
+
*/
|
|
8
|
+
export declare function executeMiddlewareChain(middlewares: MiddlewareFn[], req: Request, url: URL, params: Record<string, string>, initialCtx?: Record<string, any>): Promise<{
|
|
9
|
+
response?: Response;
|
|
10
|
+
ctx: Record<string, any>;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visage API Pragma Parser & Path Pattern Matcher
|
|
3
|
+
* Parses `// @visage-middleware` pragmas at the top of middleware files.
|
|
4
|
+
*/
|
|
5
|
+
import type { MiddlewarePragma } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Parse top-level `// @visage-middleware` pragma from file source code
|
|
8
|
+
*/
|
|
9
|
+
export declare function parsePragma(sourceCode: string): MiddlewarePragma;
|
|
10
|
+
/**
|
|
11
|
+
* Convert a glob-like pattern (e.g. `admin/*`, `users/**`, `stats`) into a RegExp
|
|
12
|
+
*/
|
|
13
|
+
export declare function globToRegExp(pattern: string): RegExp;
|
|
14
|
+
/**
|
|
15
|
+
* Test whether a normalized route path matches any glob pattern in a list
|
|
16
|
+
*/
|
|
17
|
+
export declare function matchesAnyPattern(routePath: string, patterns: string[]): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Evaluate if a middleware definition should apply to a specific route
|
|
20
|
+
*/
|
|
21
|
+
export declare function shouldApplyMiddleware(pragma: MiddlewarePragma, routePath: string, routeDir: string, middlewareDir: string): boolean;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { InferSchemaType, SchemaLike, StandardSchemaV1 } from "../form/schema";
|
|
2
|
+
import type { ApiProcedure, MiddlewareDefinition, MiddlewareFn, MiddlewarePragma, ProcedureOptions } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Define a type-safe Query procedure
|
|
5
|
+
*/
|
|
6
|
+
export declare function query<TSchema extends SchemaLike<any> | StandardSchemaV1<any>, TOutput = any, TCtx = any>(options: {
|
|
7
|
+
input: TSchema;
|
|
8
|
+
output?: SchemaLike<TOutput> | StandardSchemaV1<TOutput>;
|
|
9
|
+
resolve: (args: {
|
|
10
|
+
input: InferSchemaType<TSchema>;
|
|
11
|
+
ctx: TCtx;
|
|
12
|
+
req: Request;
|
|
13
|
+
params: Record<string, string>;
|
|
14
|
+
}) => Promise<TOutput> | TOutput | AsyncGenerator<any, void, unknown>;
|
|
15
|
+
}): ApiProcedure<InferSchemaType<TSchema>, TOutput, TCtx>;
|
|
16
|
+
export declare function query<TInput = void, TOutput = any, TCtx = any>(options: ProcedureOptions<TInput, TOutput, TCtx>): ApiProcedure<TInput, TOutput, TCtx>;
|
|
17
|
+
/**
|
|
18
|
+
* Define a type-safe Mutation procedure
|
|
19
|
+
*/
|
|
20
|
+
export declare function mutation<TSchema extends SchemaLike<any> | StandardSchemaV1<any>, TOutput = any, TCtx = any>(options: {
|
|
21
|
+
input: TSchema;
|
|
22
|
+
output?: SchemaLike<TOutput> | StandardSchemaV1<TOutput>;
|
|
23
|
+
resolve: (args: {
|
|
24
|
+
input: InferSchemaType<TSchema>;
|
|
25
|
+
ctx: TCtx;
|
|
26
|
+
req: Request;
|
|
27
|
+
params: Record<string, string>;
|
|
28
|
+
}) => Promise<TOutput> | TOutput | AsyncGenerator<any, void, unknown>;
|
|
29
|
+
}): ApiProcedure<InferSchemaType<TSchema>, TOutput, TCtx>;
|
|
30
|
+
export declare function mutation<TInput = void, TOutput = any, TCtx = any>(options: ProcedureOptions<TInput, TOutput, TCtx>): ApiProcedure<TInput, TOutput, TCtx>;
|
|
31
|
+
/**
|
|
32
|
+
* Define a real-time SSE / Stream Subscription procedure
|
|
33
|
+
*/
|
|
34
|
+
export declare function subscription<TOutput = any, TCtx = any>(options: Omit<ProcedureOptions<void, TOutput, TCtx>, "input">): ApiProcedure<void, TOutput, TCtx>;
|
|
35
|
+
/**
|
|
36
|
+
* Helper to define a middleware function with optional pragma metadata
|
|
37
|
+
*/
|
|
38
|
+
export declare function defineMiddleware<TCtxIn = any, TCtxOut = any>(fn: MiddlewareFn<TCtxIn, TCtxOut>, pragma?: MiddlewarePragma): MiddlewareDefinition;
|
|
39
|
+
/**
|
|
40
|
+
* Composable Procedure Builder (Fluent Style)
|
|
41
|
+
*/
|
|
42
|
+
export declare class ProcedureBuilder<TCtx = any, TInput = any> {
|
|
43
|
+
private _middlewares;
|
|
44
|
+
private _inputSchema?;
|
|
45
|
+
constructor(middlewares?: MiddlewareFn[], inputSchema?: SchemaLike<TInput>);
|
|
46
|
+
use<TNextCtx = Record<string, unknown>>(middleware: MiddlewareFn<TCtx, TNextCtx>): ProcedureBuilder<TCtx & TNextCtx, TInput>;
|
|
47
|
+
input<TNewInput>(schema: SchemaLike<TNewInput> | StandardSchemaV1<TNewInput>): ProcedureBuilder<TCtx, TNewInput>;
|
|
48
|
+
query<TOutput>(resolve: (args: {
|
|
49
|
+
input: TInput;
|
|
50
|
+
ctx: TCtx;
|
|
51
|
+
req: Request;
|
|
52
|
+
params: Record<string, string>;
|
|
53
|
+
}) => Promise<TOutput> | TOutput): ApiProcedure<TInput, TOutput, TCtx>;
|
|
54
|
+
mutation<TOutput>(resolve: (args: {
|
|
55
|
+
input: TInput;
|
|
56
|
+
ctx: TCtx;
|
|
57
|
+
req: Request;
|
|
58
|
+
params: Record<string, string>;
|
|
59
|
+
}) => Promise<TOutput> | TOutput): ApiProcedure<TInput, TOutput, TCtx>;
|
|
60
|
+
subscription<TOutput>(resolve: (args: {
|
|
61
|
+
ctx: TCtx;
|
|
62
|
+
req: Request;
|
|
63
|
+
params: Record<string, string>;
|
|
64
|
+
}) => AsyncGenerator<TOutput, void, unknown>): ApiProcedure<void, TOutput, TCtx>;
|
|
65
|
+
}
|
|
66
|
+
export declare const procedure: ProcedureBuilder<Record<string, unknown>, any>;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visage API & File-Based RPC Routing System Types
|
|
3
|
+
*/
|
|
4
|
+
import type { SchemaLike, StandardSchemaV1 } from "../form/schema";
|
|
5
|
+
import type { RPCErrorCode } from "../rpc/types";
|
|
6
|
+
export type { RPCErrorCode };
|
|
7
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD";
|
|
8
|
+
export interface MiddlewarePragma {
|
|
9
|
+
/**
|
|
10
|
+
* Whether this middleware cascades to child subdirectories.
|
|
11
|
+
* Default: true
|
|
12
|
+
*/
|
|
13
|
+
cascade?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Route name / path globs to include.
|
|
16
|
+
* Default: ["*"]
|
|
17
|
+
*/
|
|
18
|
+
match?: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Route name / path globs to exclude.
|
|
21
|
+
* Default: []
|
|
22
|
+
*/
|
|
23
|
+
exclude?: string[];
|
|
24
|
+
/**
|
|
25
|
+
* Execution priority within the same directory (higher runs earlier).
|
|
26
|
+
* Default: 0
|
|
27
|
+
*/
|
|
28
|
+
priority?: number;
|
|
29
|
+
}
|
|
30
|
+
export type NextFn<TCtxIn = any, TCtxOut = any> = (enriched?: Partial<TCtxOut>) => Promise<Response | (TCtxIn & TCtxOut)>;
|
|
31
|
+
export interface MiddlewareContext<TCtx = any> {
|
|
32
|
+
req: Request;
|
|
33
|
+
ctx: TCtx;
|
|
34
|
+
url: URL;
|
|
35
|
+
params: Record<string, string>;
|
|
36
|
+
next: NextFn<TCtx, any>;
|
|
37
|
+
}
|
|
38
|
+
export type MiddlewareFn<TCtxIn = any, _TCtxOut = any> = (args: MiddlewareContext<TCtxIn>) => Promise<Response | void | any>;
|
|
39
|
+
export interface MiddlewareDefinition {
|
|
40
|
+
fn: MiddlewareFn;
|
|
41
|
+
pragma: MiddlewarePragma;
|
|
42
|
+
filePath?: string;
|
|
43
|
+
directory?: string;
|
|
44
|
+
}
|
|
45
|
+
export type ProcedureType = "query" | "mutation" | "subscription";
|
|
46
|
+
export interface ProcedureOptions<TInput = any, TOutput = any, TCtx = any> {
|
|
47
|
+
input?: SchemaLike<TInput> | StandardSchemaV1<TInput>;
|
|
48
|
+
output?: SchemaLike<TOutput> | StandardSchemaV1<TOutput>;
|
|
49
|
+
resolve: (args: {
|
|
50
|
+
input: TInput;
|
|
51
|
+
ctx: TCtx;
|
|
52
|
+
req: Request;
|
|
53
|
+
params: Record<string, string>;
|
|
54
|
+
}) => Promise<TOutput> | TOutput | AsyncGenerator<any, void, unknown>;
|
|
55
|
+
}
|
|
56
|
+
export interface ApiProcedure<TInput = any, TOutput = any, TCtx = any> {
|
|
57
|
+
type: ProcedureType;
|
|
58
|
+
options: ProcedureOptions<TInput, TOutput, TCtx>;
|
|
59
|
+
middlewares?: MiddlewareFn[];
|
|
60
|
+
}
|
|
61
|
+
export interface RouteMatch {
|
|
62
|
+
pattern: RegExp;
|
|
63
|
+
paramNames: string[];
|
|
64
|
+
routePath: string;
|
|
65
|
+
filePath: string;
|
|
66
|
+
directory: string;
|
|
67
|
+
procedures: Record<string, ApiProcedure>;
|
|
68
|
+
middlewares: MiddlewareDefinition[];
|
|
69
|
+
handler?: (req: Request, ctx: any) => Promise<Response> | Response;
|
|
70
|
+
}
|
|
71
|
+
export interface FileRouteModule {
|
|
72
|
+
default?: ApiProcedure | ((req: Request, ctx?: any) => Promise<Response> | Response);
|
|
73
|
+
middleware?: MiddlewareFn;
|
|
74
|
+
get?: ApiProcedure;
|
|
75
|
+
post?: ApiProcedure;
|
|
76
|
+
put?: ApiProcedure;
|
|
77
|
+
del?: ApiProcedure;
|
|
78
|
+
patch?: ApiProcedure;
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
}
|
|
81
|
+
export interface ApiRouterConfig {
|
|
82
|
+
prefix?: string;
|
|
83
|
+
cors?: {
|
|
84
|
+
origin?: string | string[] | ((origin: string) => boolean);
|
|
85
|
+
methods?: string[];
|
|
86
|
+
allowedHeaders?: string[];
|
|
87
|
+
credentials?: boolean;
|
|
88
|
+
maxAge?: number;
|
|
89
|
+
};
|
|
90
|
+
onError?: (err: Error, req: Request) => Response | Promise<Response>;
|
|
91
|
+
}
|
|
92
|
+
export type ApiClientHeadersRule = Record<string, string> | (() => Promise<Record<string, string>> | Record<string, string>);
|
|
93
|
+
export interface ApiClientOptions {
|
|
94
|
+
baseUrl: string;
|
|
95
|
+
fetch?: typeof fetch;
|
|
96
|
+
headers?: Record<string, string> | Record<string, ApiClientHeadersRule> | (() => Promise<Record<string, string>> | Record<string, string>);
|
|
97
|
+
}
|
|
98
|
+
export interface ApiCallOptions {
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
headers?: Record<string, string>;
|
|
101
|
+
}
|
|
102
|
+
export interface ApiSubscriptionCallbacks<TData = any> {
|
|
103
|
+
onData: (data: TData) => void;
|
|
104
|
+
onError?: (error: any) => void;
|
|
105
|
+
onComplete?: () => void;
|
|
106
|
+
}
|
|
107
|
+
export interface ApiSubscriptionHandle {
|
|
108
|
+
unsubscribe: () => void;
|
|
109
|
+
}
|
|
110
|
+
export type InferApiInput<P> = P extends ApiProcedure<infer TInput, any, any> ? TInput : P extends (...args: any[]) => any ? any : void;
|
|
111
|
+
export type InferApiOutput<P> = P extends ApiProcedure<any, infer TOutput, any> ? TOutput : P extends (...args: any[]) => Promise<infer TOutput> ? TOutput : unknown;
|
|
112
|
+
export type ApiMethodCaller<P> = InferApiInput<P> extends void | undefined ? (input?: void, options?: ApiCallOptions) => Promise<InferApiOutput<P>> : (input: InferApiInput<P>, options?: ApiCallOptions) => Promise<InferApiOutput<P>>;
|
|
113
|
+
export type ApiSubscriptionCaller<P> = InferApiInput<P> extends void | undefined ? (input: void | undefined, callbacks: ApiSubscriptionCallbacks<InferApiOutput<P>>) => ApiSubscriptionHandle : (input: InferApiInput<P>, callbacks: ApiSubscriptionCallbacks<InferApiOutput<P>>) => ApiSubscriptionHandle;
|
|
114
|
+
export type ApiEndpointMethods<T> = {
|
|
115
|
+
get: T extends {
|
|
116
|
+
GET: infer P;
|
|
117
|
+
} ? ApiMethodCaller<P> : T extends {
|
|
118
|
+
get: infer P;
|
|
119
|
+
} ? ApiMethodCaller<P> : T extends {
|
|
120
|
+
default: infer P;
|
|
121
|
+
} ? ApiMethodCaller<P> : (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
122
|
+
post: T extends {
|
|
123
|
+
POST: infer P;
|
|
124
|
+
} ? ApiMethodCaller<P> : T extends {
|
|
125
|
+
post: infer P;
|
|
126
|
+
} ? ApiMethodCaller<P> : (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
127
|
+
put: T extends {
|
|
128
|
+
PUT: infer P;
|
|
129
|
+
} ? ApiMethodCaller<P> : T extends {
|
|
130
|
+
put: infer P;
|
|
131
|
+
} ? ApiMethodCaller<P> : (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
132
|
+
patch: T extends {
|
|
133
|
+
PATCH: infer P;
|
|
134
|
+
} ? ApiMethodCaller<P> : T extends {
|
|
135
|
+
patch: infer P;
|
|
136
|
+
} ? ApiMethodCaller<P> : (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
137
|
+
del: T extends {
|
|
138
|
+
DELETE: infer P;
|
|
139
|
+
} ? ApiMethodCaller<P> : T extends {
|
|
140
|
+
del: infer P;
|
|
141
|
+
} ? ApiMethodCaller<P> : (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
142
|
+
delete: T extends {
|
|
143
|
+
DELETE: infer P;
|
|
144
|
+
} ? ApiMethodCaller<P> : T extends {
|
|
145
|
+
del: infer P;
|
|
146
|
+
} ? ApiMethodCaller<P> : (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
147
|
+
subscribe: T extends {
|
|
148
|
+
GET: infer P;
|
|
149
|
+
} ? ApiSubscriptionCaller<P> : T extends {
|
|
150
|
+
subscription: infer P;
|
|
151
|
+
} ? ApiSubscriptionCaller<P> : (input: any, callbacks: ApiSubscriptionCallbacks) => ApiSubscriptionHandle;
|
|
152
|
+
queryKey: (input?: any) => unknown[];
|
|
153
|
+
queryOptions: (input?: any, extra?: any) => any;
|
|
154
|
+
createQuery: (input?: any, extra?: any) => any;
|
|
155
|
+
useQuery: (input?: any, extra?: any) => any;
|
|
156
|
+
mutationKey: () => unknown[];
|
|
157
|
+
mutationOptions: (extra?: any) => any;
|
|
158
|
+
createMutation: (extra?: any) => any;
|
|
159
|
+
useMutation: (extra?: any) => any;
|
|
160
|
+
};
|
|
161
|
+
export type DynamicApiClient = {
|
|
162
|
+
get: (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
163
|
+
post: (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
164
|
+
put: (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
165
|
+
patch: (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
166
|
+
del: (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
167
|
+
delete: (input?: any, options?: ApiCallOptions) => Promise<any>;
|
|
168
|
+
subscribe: (input: any, callbacks: ApiSubscriptionCallbacks) => ApiSubscriptionHandle;
|
|
169
|
+
queryKey: (input?: any) => unknown[];
|
|
170
|
+
queryOptions: (input?: any, extra?: any) => any;
|
|
171
|
+
createQuery: (input?: any, extra?: any) => any;
|
|
172
|
+
useQuery: (input?: any, extra?: any) => any;
|
|
173
|
+
mutationKey: () => unknown[];
|
|
174
|
+
mutationOptions: (extra?: any) => any;
|
|
175
|
+
createMutation: (extra?: any) => any;
|
|
176
|
+
useMutation: (extra?: any) => any;
|
|
177
|
+
(param: string | number): DynamicApiClient;
|
|
178
|
+
} & Record<string, any>;
|
|
179
|
+
export type ApiClient<TRoutes = any> = 0 extends 1 & TRoutes ? DynamicApiClient : [TRoutes] extends [Record<string, any>] ? {
|
|
180
|
+
[K in keyof TRoutes]-?: ((param: string | number) => ApiClient<TRoutes[K]>) & ApiEndpointMethods<TRoutes[K]> & ApiClient<TRoutes[K]>;
|
|
181
|
+
} & ((param: string | number) => any) & ApiEndpointMethods<any> : DynamicApiClient;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Child } from "../dom";
|
|
2
|
+
import type { CurveType } from "./types";
|
|
3
|
+
export interface AreaProps {
|
|
4
|
+
dataKey: string;
|
|
5
|
+
stroke?: string;
|
|
6
|
+
strokeWidth?: number | string;
|
|
7
|
+
fill?: string;
|
|
8
|
+
fillOpacity?: number | string;
|
|
9
|
+
curve?: CurveType;
|
|
10
|
+
dot?: boolean | {
|
|
11
|
+
r?: number;
|
|
12
|
+
fill?: string;
|
|
13
|
+
stroke?: string;
|
|
14
|
+
};
|
|
15
|
+
name?: string;
|
|
16
|
+
opacity?: number | string;
|
|
17
|
+
}
|
|
18
|
+
export declare function Area(props: AreaProps): Child;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Child } from "../dom";
|
|
2
|
+
export interface XAxisProps {
|
|
3
|
+
dataKey?: string;
|
|
4
|
+
tickFormat?: (val: any, index: number) => string;
|
|
5
|
+
tickCount?: number;
|
|
6
|
+
stroke?: string;
|
|
7
|
+
fontSize?: number | string;
|
|
8
|
+
fontFamily?: string;
|
|
9
|
+
hideLine?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function XAxis(props: XAxisProps): Child;
|
|
12
|
+
export interface YAxisProps {
|
|
13
|
+
dataKey?: string;
|
|
14
|
+
tickFormat?: (val: any, index: number) => string;
|
|
15
|
+
unit?: string;
|
|
16
|
+
tickCount?: number;
|
|
17
|
+
stroke?: string;
|
|
18
|
+
fontSize?: number | string;
|
|
19
|
+
hideLine?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function YAxis(props: YAxisProps): Child;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Child } from "../dom";
|
|
2
|
+
export interface CartesianGridProps {
|
|
3
|
+
horizontal?: boolean;
|
|
4
|
+
vertical?: boolean;
|
|
5
|
+
stroke?: string;
|
|
6
|
+
strokeWidth?: number | string;
|
|
7
|
+
strokeDasharray?: string;
|
|
8
|
+
opacity?: number | string;
|
|
9
|
+
}
|
|
10
|
+
export declare function CartesianGrid(props: CartesianGridProps): Child;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Child } from "../dom";
|
|
2
|
+
import type { ClassProp, ReactiveProp } from "../jsx-runtime/jsx";
|
|
3
|
+
import type { Margin } from "./types";
|
|
4
|
+
export interface ChartProps {
|
|
5
|
+
data: ReactiveProp<any[]>;
|
|
6
|
+
width?: number | string;
|
|
7
|
+
height?: number | string;
|
|
8
|
+
margin?: Partial<Margin>;
|
|
9
|
+
yDomain?: [number, number];
|
|
10
|
+
class?: ClassProp;
|
|
11
|
+
className?: ClassProp;
|
|
12
|
+
style?: any;
|
|
13
|
+
children?: Child;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}
|
|
16
|
+
export declare function Chart(props: ChartProps): Child;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Child } from "../dom";
|
|
2
|
+
import type { ClassProp } from "../jsx-runtime/jsx";
|
|
3
|
+
export interface LegendProps {
|
|
4
|
+
align?: "left" | "center" | "right";
|
|
5
|
+
class?: ClassProp;
|
|
6
|
+
className?: ClassProp;
|
|
7
|
+
}
|
|
8
|
+
export declare function ChartLegend(props: LegendProps): Child;
|
|
9
|
+
export declare const Legend: typeof ChartLegend;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Child } from "../dom";
|
|
2
|
+
import type { CurveType } from "./types";
|
|
3
|
+
export interface LineProps {
|
|
4
|
+
dataKey: string;
|
|
5
|
+
stroke?: string;
|
|
6
|
+
strokeWidth?: number | string;
|
|
7
|
+
strokeDasharray?: string;
|
|
8
|
+
curve?: CurveType;
|
|
9
|
+
dot?: boolean | {
|
|
10
|
+
r?: number;
|
|
11
|
+
fill?: string;
|
|
12
|
+
stroke?: string;
|
|
13
|
+
strokeWidth?: number;
|
|
14
|
+
};
|
|
15
|
+
name?: string;
|
|
16
|
+
opacity?: number | string;
|
|
17
|
+
}
|
|
18
|
+
export declare function Line(props: LineProps): Child;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Child } from "../dom";
|
|
2
|
+
export interface PieProps {
|
|
3
|
+
dataKey: string;
|
|
4
|
+
nameKey?: string;
|
|
5
|
+
innerRadius?: number;
|
|
6
|
+
outerRadius?: number;
|
|
7
|
+
colors?: string[];
|
|
8
|
+
cx?: number;
|
|
9
|
+
cy?: number;
|
|
10
|
+
padAngle?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function Pie(props: PieProps): Child;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Child } from "../dom";
|
|
2
|
+
import type { ClassProp } from "../jsx-runtime/jsx";
|
|
3
|
+
import type { SeriesMeta } from "./types";
|
|
4
|
+
export interface TooltipProps {
|
|
5
|
+
format?: (val: any, name: string) => string;
|
|
6
|
+
labelFormat?: (label: any) => string;
|
|
7
|
+
content?: (datum: any, series: SeriesMeta[]) => Child;
|
|
8
|
+
class?: ClassProp;
|
|
9
|
+
className?: ClassProp;
|
|
10
|
+
}
|
|
11
|
+
export declare function ChartTooltip(props: TooltipProps): Child;
|
|
12
|
+
export declare const Tooltip: typeof ChartTooltip;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AnyScale, HoverState, LinearScale, Margin, SeriesMeta } from "./types";
|
|
2
|
+
export interface ChartContextValue {
|
|
3
|
+
data: () => any[];
|
|
4
|
+
width: () => number;
|
|
5
|
+
height: () => number;
|
|
6
|
+
margin: Margin;
|
|
7
|
+
innerWidth: () => number;
|
|
8
|
+
innerHeight: () => number;
|
|
9
|
+
xScale: () => AnyScale;
|
|
10
|
+
yScale: () => LinearScale;
|
|
11
|
+
hoverState: () => HoverState;
|
|
12
|
+
setHoverState: (state: HoverState) => void;
|
|
13
|
+
xDataKey: () => string | undefined;
|
|
14
|
+
setXDataKey: (key: string) => void;
|
|
15
|
+
series: () => SeriesMeta[];
|
|
16
|
+
registerSeries: (meta: SeriesMeta) => void;
|
|
17
|
+
unregisterSeries: (id: string) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const ChartContext: import("..").Context<ChartContextValue | undefined>;
|
|
20
|
+
export declare function useChartContext(): ChartContextValue;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from "./Area";
|
|
2
|
+
export * from "./Axis";
|
|
3
|
+
export * from "./Bar";
|
|
4
|
+
export * from "./CartesianGrid";
|
|
5
|
+
export * from "./Chart";
|
|
6
|
+
export * from "./Cursor";
|
|
7
|
+
export * from "./context";
|
|
8
|
+
export * from "./Legend";
|
|
9
|
+
export * from "./Line";
|
|
10
|
+
export * from "./Pie";
|
|
11
|
+
export * from "./path";
|
|
12
|
+
export * from "./scale";
|
|
13
|
+
export * from "./Tooltip";
|
|
14
|
+
export * from "./types";
|