@tailorkit/app 0.1.0-beta.14 → 0.1.0-beta.16

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.
@@ -0,0 +1,120 @@
1
+ // src/server/functions.ts
2
+ function query(definition) {
3
+ return Object.freeze({ ...definition, kind: "query" });
4
+ }
5
+ function mutation(definition) {
6
+ return Object.freeze({ ...definition, kind: "mutation" });
7
+ }
8
+ function action(definition) {
9
+ return Object.freeze({ ...definition, kind: "action" });
10
+ }
11
+ function isFunction(value) {
12
+ return typeof value.kind === "string" && typeof value.handler === "function";
13
+ }
14
+ function defineServer(functions) {
15
+ for (const [name, value] of Object.entries(functions)) {
16
+ if (!/^[a-zA-Z][a-zA-Z0-9_]{0,63}$/u.test(name)) {
17
+ throw new Error("Invalid function name");
18
+ }
19
+ if (!isFunction(value)) defineServer(value);
20
+ }
21
+ return Object.freeze({ functions });
22
+ }
23
+
24
+ // src/server/builder.ts
25
+ import { z } from "zod";
26
+ var FunctionBuilder = class _FunctionBuilder {
27
+ kind;
28
+ args;
29
+ result;
30
+ calls;
31
+ constructor(kind, args, result, calls) {
32
+ this.kind = kind;
33
+ this.args = args;
34
+ this.result = result;
35
+ this.calls = calls;
36
+ }
37
+ input(schema) {
38
+ return new _FunctionBuilder(this.kind, schema, this.result, this.calls);
39
+ }
40
+ output(schema) {
41
+ return new _FunctionBuilder(this.kind, this.args, schema, this.calls);
42
+ }
43
+ functions(functions) {
44
+ return new _FunctionBuilder(this.kind, this.args, this.result, functions);
45
+ }
46
+ handler(handler) {
47
+ return Object.freeze({
48
+ kind: this.kind,
49
+ args: this.args,
50
+ ...this.result ? { result: this.result } : {},
51
+ ...this.kind === "action" ? { functions: this.calls } : {},
52
+ handler: (context) => handler({ ...context, input: context.args })
53
+ });
54
+ }
55
+ };
56
+ var tk = Object.freeze({
57
+ query: new FunctionBuilder("query", z.undefined(), void 0, {}),
58
+ mutation: new FunctionBuilder("mutation", z.undefined(), void 0, {}),
59
+ action: new FunctionBuilder("action", z.undefined(), void 0, {})
60
+ });
61
+
62
+ // src/database/schema.ts
63
+ import {
64
+ sqliteTable,
65
+ text as sqliteText,
66
+ integer as sqliteInteger,
67
+ real as sqliteReal
68
+ } from "drizzle-orm/sqlite-core";
69
+ import {
70
+ eq,
71
+ ne,
72
+ gt,
73
+ gte,
74
+ lt,
75
+ lte,
76
+ and,
77
+ or,
78
+ asc,
79
+ desc,
80
+ count,
81
+ isNull,
82
+ isNotNull,
83
+ inArray
84
+ } from "drizzle-orm";
85
+ function table(name, columns) {
86
+ if (!/^[a-zA-Z][a-zA-Z0-9_]{0,62}$/u.test(name) || name.startsWith("sqlite_") || name.startsWith("tailorkit_"))
87
+ throw new Error("Invalid or reserved table name");
88
+ return sqliteTable(name, columns);
89
+ }
90
+ var text = (name = "") => sqliteText(name);
91
+ var integer = (name = "") => sqliteInteger(name);
92
+ var real = (name = "") => sqliteReal(name);
93
+ var boolean = (name = "") => sqliteInteger(name, { mode: "boolean" });
94
+
95
+ export {
96
+ query,
97
+ mutation,
98
+ action,
99
+ defineServer,
100
+ tk,
101
+ table,
102
+ text,
103
+ integer,
104
+ real,
105
+ boolean,
106
+ eq,
107
+ ne,
108
+ gt,
109
+ gte,
110
+ lt,
111
+ lte,
112
+ and,
113
+ or,
114
+ asc,
115
+ desc,
116
+ count,
117
+ isNull,
118
+ isNotNull,
119
+ inArray
120
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  tailorkitConfigSchema
3
- } from "./chunk-ZFYKVXDO.js";
3
+ } from "./chunk-GVB2PAK7.js";
4
4
 
5
5
  // src/config/loader.ts
6
6
  import { cosmiconfig } from "cosmiconfig";
@@ -14,6 +14,11 @@ var loadTailorKitConfig = async (configPath, cwd = process.cwd()) => {
14
14
  if (result === null) {
15
15
  throw new Error(`Could not find tailorkit config from ${searchFrom}.`);
16
16
  }
17
+ if (result.config && typeof result.config === "object" && "storage" in result.config) {
18
+ throw new Error(
19
+ "The legacy storage configuration was removed. Use server configuration and @tailorkit/app."
20
+ );
21
+ }
17
22
  return {
18
23
  config: tailorkitConfigSchema.parse(result.config),
19
24
  filepath: result.filepath,
@@ -1,8 +1,5 @@
1
1
  // src/config/config.ts
2
2
  import { z } from "zod";
3
- var clientConfigSchema = z.object({
4
- entry: z.string().default("./src/client.ts")
5
- });
6
3
  var buildConfigSchema = z.object({
7
4
  outDir: z.string().default(".tailorkit")
8
5
  });
@@ -10,12 +7,16 @@ var logosConfigSchema = z.object({
10
7
  dark: z.string().min(1).optional(),
11
8
  light: z.string().min(1).optional()
12
9
  });
13
- var tailorkitConfigSchema = z.object({
10
+ var tailorkitConfigSchema = z.strictObject({
14
11
  appId: z.string().min(1).optional(),
15
12
  build: buildConfigSchema.optional(),
16
- client: clientConfigSchema.optional(),
13
+ client: z.strictObject({ entry: z.string().min(1).default("src/client.ts") }).optional(),
17
14
  host: z.string().url(),
18
- logos: logosConfigSchema.optional()
15
+ logos: logosConfigSchema.optional(),
16
+ server: z.strictObject({
17
+ entry: z.string().min(1).default("src/server.ts"),
18
+ migrations: z.string().min(1).optional()
19
+ }).optional()
19
20
  });
20
21
  var defineConfig = (config) => config;
21
22
  var defineTailorKitConfig = defineConfig;
@@ -0,0 +1,35 @@
1
+ // src/errors.ts
2
+ var AppError = class extends Error {
3
+ constructor(code, message = code) {
4
+ super(message);
5
+ this.code = code;
6
+ this.name = "AppError";
7
+ }
8
+ code;
9
+ };
10
+ function appError(error) {
11
+ if (error instanceof AppError) return error;
12
+ if (error instanceof Error && error.name === "AbortError")
13
+ return new AppError("UNAVAILABLE", "App connection interrupted");
14
+ if (error && typeof error === "object" && "code" in error && error.code === "NETWORK_ERROR")
15
+ return new AppError("UNAVAILABLE", "App connection interrupted");
16
+ if (error && typeof error === "object" && "code" in error && [
17
+ "BAD_REQUEST",
18
+ "UNAUTHORIZED",
19
+ "FORBIDDEN",
20
+ "NOT_FOUND",
21
+ "CONFLICT",
22
+ "INCOMPATIBLE_VERSION",
23
+ "UNAVAILABLE"
24
+ ].includes(String(error.code)))
25
+ return new AppError(
26
+ error.code,
27
+ "message" in error ? String(error.message) : String(error.code)
28
+ );
29
+ return new AppError("INTERNAL_SERVER_ERROR", "App function failed");
30
+ }
31
+
32
+ export {
33
+ AppError,
34
+ appError
35
+ };
@@ -0,0 +1,31 @@
1
+ import { AppError } from "../errors";
2
+ import type { Reference } from "./reference";
3
+ import type { Session } from "./session";
4
+ export type { Session } from "./session";
5
+ export { reference } from "./reference";
6
+ export type { Reference, References } from "./reference";
7
+ export { AppError } from "../errors";
8
+ type InputArguments<I> = undefined extends I ? [args?: I] : [args: I];
9
+ type MutationArguments<I> = undefined extends I ? [args?: I, options?: {
10
+ requestId?: string;
11
+ }] : [args: I, options?: {
12
+ requestId?: string;
13
+ }];
14
+ export interface Client {
15
+ query<I, O>(reference: Reference<"query", I, O>, ...args: InputArguments<NoInfer<I>>): Promise<O>;
16
+ mutate<I, O>(reference: Reference<"mutation", I, O>, ...args: MutationArguments<NoInfer<I>>): Promise<O>;
17
+ action<I, O>(reference: Reference<"action", I, O>, ...args: InputArguments<NoInfer<I>>): Promise<O>;
18
+ subscribe<I, O>(reference: Reference<"query", I, O>, args: NoInfer<I>, next: (value: O) => void, options?: {
19
+ onError?: (error: AppError) => void;
20
+ }): () => void;
21
+ close(): void;
22
+ }
23
+ export declare function createClient(options?: {
24
+ getSession?: (options: {
25
+ refresh: boolean;
26
+ }) => Promise<Session>;
27
+ connect?: (url: string, protocols: string[]) => WebSocket | Promise<WebSocket>;
28
+ fetch?: typeof fetch;
29
+ retryDelayMs?: number;
30
+ }): Client;
31
+ export { createSessionProvider } from "./session";
@@ -0,0 +1,23 @@
1
+ import type { Client } from "./connection";
2
+ import type { Reference } from "./reference";
3
+ import type { AppError } from "../errors";
4
+ export interface QueryState<T> {
5
+ data: T | undefined;
6
+ error: AppError | null;
7
+ status: "pending" | "success" | "error";
8
+ }
9
+ export declare const pendingQuery: QueryState<never>;
10
+ export declare function serializeInput(input: unknown): string;
11
+ /** One subscription per active query/input pair, scoped to this provider's client. */
12
+ export declare class QueryStore {
13
+ readonly state: import("@tanstack/store").Store<Map<string, QueryState<unknown>>, never>;
14
+ private readonly entries;
15
+ private disposed;
16
+ readonly client: Client;
17
+ private readonly ownsClient;
18
+ private readonly errorHandler;
19
+ constructor(client: Client, ownsClient: boolean, errorHandler?: (error: AppError) => void);
20
+ watch<I, O>(key: string, ref: Reference<"query", I, O>, input: I): () => void;
21
+ dispose(): void;
22
+ onError(error: AppError): void;
23
+ }
@@ -0,0 +1,20 @@
1
+ import type { z } from "zod";
2
+ import type { FunctionResult, Functions } from "../server/functions";
3
+ export interface Reference<K extends "query" | "mutation" | "action", I, O> {
4
+ readonly name: string;
5
+ readonly $types?: {
6
+ kind: K;
7
+ input: I;
8
+ output: O;
9
+ };
10
+ }
11
+ export declare function reference<K extends "query" | "mutation" | "action", I, O>(name: string, _kind: K): Reference<K, I, O>;
12
+ export type References<F> = {
13
+ readonly [N in keyof F]: F[N] extends {
14
+ kind: infer K extends "query" | "mutation" | "action";
15
+ args: infer A extends z.ZodType;
16
+ handler: (...args: never[]) => unknown;
17
+ } ? Reference<K, z.input<A>, FunctionResult<F[N]>> : F[N] extends Functions ? References<F[N]> : never;
18
+ };
19
+ /** Browser references inferred directly from the server's exported function type. */
20
+ export declare function createApi<F extends Functions>(): References<F>;
@@ -0,0 +1,14 @@
1
+ export interface Session {
2
+ token: string;
3
+ expiresAt: number;
4
+ url: string;
5
+ }
6
+ export declare function sessionRenewalDelay(session: Session): number;
7
+ /** Host-owned provider: project credentials never cross into the sandbox. */
8
+ export declare function createSessionProvider(options: {
9
+ baseUrl: string | URL;
10
+ appId: string;
11
+ fetch?: typeof fetch;
12
+ }): (input: {
13
+ refresh: boolean;
14
+ }) => Promise<Session>;
@@ -0,0 +1,7 @@
1
+ export * from "./views";
2
+ export * from "./preact";
3
+ export { createClient, createSessionProvider, reference } from "./client/connection";
4
+ export { createApi } from "./client/reference";
5
+ export type { Client, Session, Reference, References } from "./client/connection";
6
+ export { AppError, appError } from "./errors";
7
+ export type { ErrorCode } from "./errors";
package/dist/client.js ADDED
@@ -0,0 +1,32 @@
1
+ import {
2
+ ClientProvider,
3
+ createApi,
4
+ createClient,
5
+ createRemoteComponent,
6
+ createSessionProvider,
7
+ createView,
8
+ defineClient,
9
+ reference,
10
+ useAction,
11
+ useMutation,
12
+ useQuery
13
+ } from "./chunk-3XA36UOQ.js";
14
+ import {
15
+ AppError,
16
+ appError
17
+ } from "./chunk-IJBQ77AH.js";
18
+ export {
19
+ AppError,
20
+ ClientProvider,
21
+ appError,
22
+ createApi,
23
+ createClient,
24
+ createRemoteComponent,
25
+ createSessionProvider,
26
+ createView,
27
+ defineClient,
28
+ reference,
29
+ useAction,
30
+ useMutation,
31
+ useQuery
32
+ };
@@ -6,13 +6,17 @@ declare const tailorkitConfigSchema: z.ZodObject<{
6
6
  }, z.core.$strip>>;
7
7
  client: z.ZodOptional<z.ZodObject<{
8
8
  entry: z.ZodDefault<z.ZodString>;
9
- }, z.core.$strip>>;
9
+ }, z.core.$strict>>;
10
10
  host: z.ZodString;
11
11
  logos: z.ZodOptional<z.ZodObject<{
12
12
  dark: z.ZodOptional<z.ZodString>;
13
13
  light: z.ZodOptional<z.ZodString>;
14
14
  }, z.core.$strip>>;
15
- }, z.core.$strip>;
15
+ server: z.ZodOptional<z.ZodObject<{
16
+ entry: z.ZodDefault<z.ZodString>;
17
+ migrations: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strict>>;
19
+ }, z.core.$strict>;
16
20
  export type TailorKitConfig = z.input<typeof tailorkitConfigSchema>;
17
21
  export type ResolvedTailorKitConfig = z.output<typeof tailorkitConfigSchema>;
18
22
  export { tailorkitConfigSchema };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  loadTailorKitConfig
3
- } from "./chunk-EKCUETAV.js";
4
- import "./chunk-ZFYKVXDO.js";
3
+ } from "./chunk-DEU6RITM.js";
4
+ import "./chunk-GVB2PAK7.js";
5
5
  export {
6
6
  loadTailorKitConfig
7
7
  };
package/dist/config.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  defineConfig,
3
3
  defineTailorKitConfig
4
- } from "./chunk-ZFYKVXDO.js";
4
+ } from "./chunk-GVB2PAK7.js";
5
5
  export {
6
6
  defineConfig,
7
7
  defineTailorKitConfig
@@ -0,0 +1,78 @@
1
+ import type { ColumnBuilderBase } from "drizzle-orm";
2
+ export declare function table<N extends string, C extends Record<string, ColumnBuilderBase>>(name: N, columns: C): import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
3
+ name: N;
4
+ schema: undefined;
5
+ columns: { [Key in keyof C]: import("drizzle-orm/sqlite-core").SQLiteColumn<{
6
+ name: string;
7
+ tableName: N;
8
+ dataType: C[Key]["_"]["dataType"];
9
+ data: C[Key]["_"] extends infer T ? T extends C[Key]["_"] ? T extends {
10
+ $type: infer U;
11
+ } ? U : T["data"] : never : never;
12
+ driverParam: C[Key]["_"]["driverParam"];
13
+ notNull: C[Key]["_"]["notNull"] extends true ? true : false;
14
+ hasDefault: C[Key]["_"]["hasDefault"] extends true ? true : false;
15
+ isPrimaryKey: C[Key]["_"] extends infer T_1 ? T_1 extends C[Key]["_"] ? T_1 extends {
16
+ isPrimaryKey: true;
17
+ } ? true : false : never : never;
18
+ isAutoincrement: C[Key]["_"] extends infer T_2 ? T_2 extends C[Key]["_"] ? T_2 extends {
19
+ isAutoincrement: true;
20
+ } ? true : false : never : never;
21
+ hasRuntimeDefault: C[Key]["_"] extends infer T_3 ? T_3 extends C[Key]["_"] ? T_3 extends {
22
+ hasRuntimeDefault: true;
23
+ } ? true : false : never : never;
24
+ enumValues: C[Key]["_"] extends infer T_4 ? T_4 extends C[Key]["_"] ? T_4 extends {
25
+ enumValues: [string, ...string[]];
26
+ } ? T_4["enumValues"] : undefined : never : never;
27
+ baseColumn: C[Key]["_"] extends infer T_5 ? T_5 extends C[Key]["_"] ? T_5 extends {
28
+ baseBuilder: infer U_1 extends ColumnBuilderBase;
29
+ } ? import("drizzle-orm/sqlite-core").SQLiteColumn<{
30
+ name: string;
31
+ tableName: N;
32
+ dataType: U_1["_"]["dataType"];
33
+ data: U_1["_"] extends infer T_6 ? T_6 extends U_1["_"] ? T_6 extends {
34
+ $type: infer U;
35
+ } ? U : T_6["data"] : never : never;
36
+ driverParam: U_1["_"]["driverParam"];
37
+ notNull: U_1["_"]["notNull"] extends true ? true : false;
38
+ hasDefault: U_1["_"]["hasDefault"] extends true ? true : false;
39
+ isPrimaryKey: U_1["_"] extends infer T_7 ? T_7 extends U_1["_"] ? T_7 extends {
40
+ isPrimaryKey: true;
41
+ } ? true : false : never : never;
42
+ isAutoincrement: U_1["_"] extends infer T_8 ? T_8 extends U_1["_"] ? T_8 extends {
43
+ isAutoincrement: true;
44
+ } ? true : false : never : never;
45
+ hasRuntimeDefault: U_1["_"] extends infer T_9 ? T_9 extends U_1["_"] ? T_9 extends {
46
+ hasRuntimeDefault: true;
47
+ } ? true : false : never : never;
48
+ enumValues: U_1["_"] extends infer T_10 ? T_10 extends U_1["_"] ? T_10 extends {
49
+ enumValues: [string, ...string[]];
50
+ } ? T_10["enumValues"] : undefined : never : never;
51
+ baseColumn: U_1["_"] extends infer T_11 ? T_11 extends U_1["_"] ? T_11 extends {
52
+ baseBuilder: infer U_1 extends ColumnBuilderBase;
53
+ } ? import("drizzle-orm/sqlite-core").SQLiteColumn</*elided*/ any, {}> : never : never : never;
54
+ identity: U_1["_"] extends infer T_12 ? T_12 extends U_1["_"] ? T_12 extends {
55
+ identity: 'always';
56
+ } ? "always" : T_12 extends {
57
+ identity: 'byDefault';
58
+ } ? "byDefault" : undefined : never : never;
59
+ generated: U_1["_"] extends infer T_13 ? T_13 extends U_1["_"] ? T_13 extends {
60
+ generated: infer G;
61
+ } ? unknown extends G ? undefined : G extends undefined ? undefined : G : undefined : never : never;
62
+ }, {}> : never : never : never;
63
+ identity: C[Key]["_"] extends infer T_14 ? T_14 extends C[Key]["_"] ? T_14 extends {
64
+ identity: 'always';
65
+ } ? "always" : T_14 extends {
66
+ identity: 'byDefault';
67
+ } ? "byDefault" : undefined : never : never;
68
+ generated: C[Key]["_"] extends infer T_15 ? T_15 extends C[Key]["_"] ? T_15 extends {
69
+ generated: infer G;
70
+ } ? unknown extends G ? undefined : G extends undefined ? undefined : G : undefined : never : never;
71
+ }, {}>; };
72
+ dialect: 'sqlite';
73
+ }>;
74
+ export declare const text: (name?: string) => import("drizzle-orm/sqlite-core").SQLiteTextBuilder<[string, ...string[]]>;
75
+ export declare const integer: (name?: string) => import("drizzle-orm/sqlite-core").SQLiteIntegerBuilder;
76
+ export declare const real: (name?: string) => import("drizzle-orm/sqlite-core").SQLiteRealBuilder;
77
+ export declare const boolean: (name?: string) => import("drizzle-orm/sqlite-core").SQLiteBooleanBuilder;
78
+ export { eq, ne, gt, gte, lt, lte, and, or, asc, desc, count, isNull, isNotNull, inArray, } from "drizzle-orm";
@@ -0,0 +1,7 @@
1
+ import type { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
2
+ type Database = BaseSQLiteDatabase<"sync", {
3
+ changes: number;
4
+ }>;
5
+ export type QueryDatabase = Pick<Database, "select" | "selectDistinct">;
6
+ export type MutationDatabase = QueryDatabase & Pick<Database, "insert" | "update" | "delete">;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ export type ErrorCode = "BAD_REQUEST" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT" | "INCOMPATIBLE_VERSION" | "UNAVAILABLE" | "INTERNAL_SERVER_ERROR";
2
+ export declare class AppError extends Error {
3
+ readonly code: ErrorCode;
4
+ constructor(code: ErrorCode, message?: string);
5
+ }
6
+ export declare function appError(error: unknown): AppError;
package/dist/index.d.ts CHANGED
@@ -1,87 +1,2 @@
1
- import { h } from "preact";
2
- import type { ComponentChild, ComponentChildren, VNode } from "preact";
3
- export interface TailorKitViews {
4
- }
5
- export interface TailorKitSlots {
6
- }
7
- export type SlotName = keyof TailorKitSlots & string;
8
- export type ViewPath = Extract<keyof TailorKitViews & string, `/${string}`>;
9
- export type AppViewPath = ViewPath;
10
- export type ViewProps<TPath extends ViewPath> = TailorKitViews[TPath] extends object ? TailorKitViews[TPath] : Record<string, never>;
11
- export type ViewPropsForPath<TPath extends AppViewPath> = TPath extends ViewPath ? ViewProps<TPath> : never;
12
- export type ViewContext<TPath extends AppViewPath> = ViewPropsForPath<TPath> extends {
13
- context: infer TContext;
14
- } ? TContext : Record<string, never>;
15
- export type View<TProps extends object = Record<string, never>> = (props: TProps) => ComponentChild;
16
- export type ViewRuntimeProps<TPath extends AppViewPath> = {
17
- context: ViewContext<TPath>;
18
- view: TPath;
19
- status: "ready";
20
- } | {
21
- context?: never;
22
- view: TPath;
23
- status: "loading";
24
- } | {
25
- context?: never;
26
- view: TPath;
27
- status: "error";
28
- };
29
- export interface ViewDefinition<TPath extends AppViewPath = AppViewPath> {
30
- component: View<ViewRuntimeProps<TPath>>;
31
- path: TPath;
32
- useContext: () => ViewContext<TPath>;
33
- }
34
- type RegisteredViews = {
35
- [TPath in AppViewPath]: ViewDefinition<TPath>;
36
- };
37
- type ViewDefinitions = Partial<{
38
- [P in AppViewPath]: RegisteredViews[P] | false;
39
- }>;
40
- type InvalidViewPath<TViews> = Exclude<keyof TViews & string, AppViewPath>;
41
- type RequireViewPaths<TViews> = InvalidViewPath<TViews> extends never ? unknown : {
42
- readonly __tailorkit_error__: `View paths must be declared by the host. Invalid view: ${InvalidViewPath<TViews>}`;
43
- };
44
- type ViewKeyPathMismatch<TViews> = {
45
- [TPath in keyof TViews & string]: TViews[TPath] extends false ? never : TViews[TPath] extends ViewDefinition<infer TViewPath> ? TViewPath extends TPath ? never : TPath : TPath;
46
- }[keyof TViews & string];
47
- type RequireMatchingViewKeys<TViews> = ViewKeyPathMismatch<TViews> extends never ? unknown : {
48
- readonly __tailorkit_error__: `View key must match createView path. Invalid view: ${ViewKeyPathMismatch<TViews>}`;
49
- };
50
- export type SlotView<TSlot extends SlotName> = Extract<TailorKitSlots[TSlot], AppViewPath>;
51
- type SlotDefinitions = {
52
- [V in SlotName]?: Pick<ViewDefinitions, SlotView<V>>;
53
- };
54
- type RequireSlotViews<V, S> = V extends SlotName ? Exclude<keyof S, SlotView<V>> extends never ? unknown : {
55
- readonly __tailorkit_error__: "View is not supported by this slot";
56
- } : never;
57
- export interface TailorKitClient<TSlots extends SlotDefinitions = SlotDefinitions> {
58
- slots: TSlots;
59
- }
60
- export interface TailorKitClientMeta {
61
- preactVersion: string;
62
- }
63
- export interface TailorKitClientRuntime {
64
- h: typeof h;
65
- render: (vnode: VNode | null, parent: Element | Document | ShadowRoot | DocumentFragment) => void;
66
- }
67
- export type TailorKitClientWithMeta<TViews extends SlotDefinitions = SlotDefinitions> = TailorKitClient<TViews> & {
68
- $meta: TailorKitClientMeta;
69
- $runtime: TailorKitClientRuntime;
70
- };
71
- export declare const createView: <const TPath extends AppViewPath>(path: TPath, options: {
72
- component: View<Record<string, never>>;
73
- error?: View<Record<string, never>>;
74
- loading?: View<Record<string, never>>;
75
- }) => ViewDefinition<TPath>;
76
- export declare const defineClient: <const TSlots extends SlotDefinitions>(client: TailorKitClient<TSlots> & {
77
- slots: { [V in keyof TSlots]: TSlots[V] & RequireViewPaths<TSlots[V]> & RequireMatchingViewKeys<TSlots[V]> & RequireSlotViews<V, TSlots[V]>; };
78
- } & (Exclude<keyof TSlots, SlotName> extends never ? unknown : {
79
- __tailorkit_error__: "Unknown slot";
80
- })) => TailorKitClientWithMeta<TSlots>;
81
- export declare const createRemoteComponent: <TProps extends object, TChildren extends boolean = false>(name: string, options?: {
82
- callbacks?: Record<string, number>;
83
- children?: TChildren;
84
- }) => View<TProps & {
85
- children?: TChildren extends true ? ComponentChildren : never;
86
- }>;
87
- export {};
1
+ export * from "./client";
2
+ export * from "./server";