@tailorkit/app 0.1.0-beta.3 → 0.1.0-beta.32
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/LICENSE.md +74 -0
- package/README.md +115 -0
- package/dist/chunk-7ZQPXG7O.js +34 -0
- package/dist/chunk-PJBDA2RU.js +415 -0
- package/dist/chunk-UDXPIO6D.js +618 -0
- package/dist/chunk-YX3JURMG.js +262 -0
- package/dist/client/connection.d.ts +31 -0
- package/dist/client/query-store.d.ts +23 -0
- package/dist/client/reference.d.ts +20 -0
- package/dist/client/session.d.ts +41 -0
- package/dist/client/tools.d.ts +16 -0
- package/dist/client-connection.js +16 -0
- package/dist/client.d.ts +11 -0
- package/dist/client.js +40 -0
- package/dist/database/definition.d.ts +8 -0
- package/dist/database/schema.d.ts +78 -0
- package/dist/database/types.d.ts +8 -0
- package/dist/errors.d.ts +6 -0
- package/dist/index.d.ts +2 -72
- package/dist/index.js +91 -76
- package/dist/preact.d.ts +52 -0
- package/dist/protocol.d.ts +74 -0
- package/dist/protocol.js +30 -0
- package/dist/routing.d.ts +34 -0
- package/dist/server/builder.d.ts +45 -0
- package/dist/server/bundle.d.ts +12 -0
- package/dist/server/functions.d.ts +105 -0
- package/dist/server/instances.d.ts +17 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.js +60 -0
- package/dist/views.d.ts +126 -0
- package/package.json +56 -34
- package/LICENSE +0 -674
- package/dist/builder/index.d.ts +0 -11
- package/dist/builder/index.d.ts.map +0 -1
- package/dist/builder/upload-manifest.d.ts +0 -10
- package/dist/builder/upload-manifest.d.ts.map +0 -1
- package/dist/builder.js +0 -135
- package/dist/chunk-7L6ZZHCK.js +0 -26
- package/dist/chunk-AGGRUUWG.js +0 -22
- package/dist/config/config.d.ts +0 -17
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/index.d.ts +0 -2
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/loader.d.ts +0 -8
- package/dist/config/loader.d.ts.map +0 -1
- package/dist/config-loader.js +0 -7
- package/dist/config.js +0 -8
- package/dist/index.d.ts.map +0 -1
- package/dist/preact-version.d.ts +0 -8
- package/dist/preact-version.d.ts.map +0 -1
- package/src/builder/index.ts +0 -116
- package/src/builder/upload-manifest.ts +0 -18
- package/src/config/config.ts +0 -24
- package/src/config/index.ts +0 -1
- package/src/config/loader.ts +0 -35
- package/src/index.ts +0 -206
- package/src/preact-version.ts +0 -31
package/dist/views.d.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { h } from "preact";
|
|
2
|
+
import type { ComponentChild, ComponentChildren, VNode } from "preact";
|
|
3
|
+
import type { z } from "zod";
|
|
4
|
+
import type { FunctionCalls, Identity } from "./server/functions";
|
|
5
|
+
export interface TailorKitViews {
|
|
6
|
+
}
|
|
7
|
+
export interface TailorKitSlots {
|
|
8
|
+
}
|
|
9
|
+
export interface TailorKitServerFunctions {
|
|
10
|
+
}
|
|
11
|
+
export type ViewDataFields = Record<string, unknown>;
|
|
12
|
+
export interface ViewInstance<TData = unknown> {
|
|
13
|
+
key: string;
|
|
14
|
+
metadata: ViewDataFields;
|
|
15
|
+
data: TData;
|
|
16
|
+
}
|
|
17
|
+
export interface InstanceResolverContext<TPath extends AppViewPath> {
|
|
18
|
+
context: ViewContext<TPath>;
|
|
19
|
+
identity: Identity;
|
|
20
|
+
signal: AbortSignal;
|
|
21
|
+
queries: FunctionCalls<TailorKitServerFunctions, "query">;
|
|
22
|
+
}
|
|
23
|
+
export interface ViewInstances<TPath extends AppViewPath, TSchema extends z.ZodType> {
|
|
24
|
+
dataSchema: TSchema;
|
|
25
|
+
/** Runs on the app server. Only registered queries are available. */
|
|
26
|
+
resolve: (context: InstanceResolverContext<TPath>) => ViewInstance<z.input<TSchema>>[] | Promise<ViewInstance<z.input<TSchema>>[]>;
|
|
27
|
+
}
|
|
28
|
+
export type SlotName = keyof TailorKitSlots & string;
|
|
29
|
+
export type ViewPath = Extract<keyof TailorKitViews & string, `/${string}`>;
|
|
30
|
+
export type AppViewPath = ViewPath;
|
|
31
|
+
export type ViewProps<TPath extends ViewPath> = TailorKitViews[TPath] extends object ? TailorKitViews[TPath] : Record<string, never>;
|
|
32
|
+
export type ViewPropsForPath<TPath extends AppViewPath> = TPath extends ViewPath ? ViewProps<TPath> : never;
|
|
33
|
+
export type ViewContext<TPath extends AppViewPath> = ViewPropsForPath<TPath> extends {
|
|
34
|
+
context: infer TContext;
|
|
35
|
+
} ? TContext : Record<string, never>;
|
|
36
|
+
export type View<TProps extends object = Record<string, never>> = (props: TProps) => ComponentChild;
|
|
37
|
+
export type ViewRuntimeProps<TPath extends AppViewPath, TData = unknown> = {
|
|
38
|
+
context: ViewContext<TPath>;
|
|
39
|
+
view: TPath;
|
|
40
|
+
status: "ready";
|
|
41
|
+
instance?: ViewInstance<TData>;
|
|
42
|
+
} | {
|
|
43
|
+
context?: never;
|
|
44
|
+
view: TPath;
|
|
45
|
+
status: "loading";
|
|
46
|
+
instance?: never;
|
|
47
|
+
} | {
|
|
48
|
+
context?: never;
|
|
49
|
+
view: TPath;
|
|
50
|
+
status: "error";
|
|
51
|
+
instance?: never;
|
|
52
|
+
};
|
|
53
|
+
export interface ViewDefinition<TPath extends AppViewPath = AppViewPath, TData = unknown, TSlot extends SlotName = SlotName> {
|
|
54
|
+
component: View<ViewRuntimeProps<TPath>>;
|
|
55
|
+
path: TPath;
|
|
56
|
+
slot: TSlot;
|
|
57
|
+
useContext: () => ViewContext<TPath>;
|
|
58
|
+
/** The selected instance, with data inferred from instances.dataSchema. */
|
|
59
|
+
useInstance: () => ViewInstance<TData>;
|
|
60
|
+
/** Build-only lookup key connecting this view to its extracted server implementation. */
|
|
61
|
+
instances?: {
|
|
62
|
+
resolver: string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export type SlotView<TSlot extends SlotName> = TailorKitSlots[TSlot] extends {
|
|
66
|
+
views: infer TViews;
|
|
67
|
+
} ? Extract<TViews, AppViewPath> : never;
|
|
68
|
+
type SlotInstanceDefinition<TSlot extends SlotName> = TailorKitSlots[TSlot] extends {
|
|
69
|
+
multiple: true;
|
|
70
|
+
} ? {
|
|
71
|
+
instances: {
|
|
72
|
+
resolver: string;
|
|
73
|
+
};
|
|
74
|
+
} : {
|
|
75
|
+
instances?: never;
|
|
76
|
+
};
|
|
77
|
+
type SlotDefinitions = {
|
|
78
|
+
[V in SlotName]?: Partial<{
|
|
79
|
+
[P in SlotView<V>]: (ViewDefinition<P, unknown, V> & SlotInstanceDefinition<V>) | false;
|
|
80
|
+
}>;
|
|
81
|
+
};
|
|
82
|
+
export interface TailorKitClient<TSlots extends SlotDefinitions = SlotDefinitions> {
|
|
83
|
+
slots: TSlots;
|
|
84
|
+
}
|
|
85
|
+
export interface TailorKitClientMeta {
|
|
86
|
+
preactVersion: string;
|
|
87
|
+
}
|
|
88
|
+
export interface TailorKitClientRuntime {
|
|
89
|
+
h: typeof h;
|
|
90
|
+
render: (vnode: VNode | null, parent: Element | Document | ShadowRoot | DocumentFragment) => void;
|
|
91
|
+
}
|
|
92
|
+
export type TailorKitClientWithMeta<TViews extends SlotDefinitions = SlotDefinitions> = TailorKitClient<TViews> & {
|
|
93
|
+
$meta: TailorKitClientMeta;
|
|
94
|
+
$runtime: TailorKitClientRuntime;
|
|
95
|
+
};
|
|
96
|
+
type ViewOptions<TPath extends AppViewPath, TSlot extends SlotName, TSchema extends z.ZodType> = {
|
|
97
|
+
[S in TSlot]: {
|
|
98
|
+
slot: S;
|
|
99
|
+
view: TPath;
|
|
100
|
+
component: View;
|
|
101
|
+
} & (TPath extends SlotView<S> ? unknown : {
|
|
102
|
+
readonly __tailorkit_error__: "View is not supported by this slot";
|
|
103
|
+
}) & (TailorKitSlots[S] extends {
|
|
104
|
+
multiple: true;
|
|
105
|
+
} ? {
|
|
106
|
+
instances: ViewInstances<TPath, TSchema>;
|
|
107
|
+
} : {
|
|
108
|
+
instances?: never;
|
|
109
|
+
});
|
|
110
|
+
}[TSlot];
|
|
111
|
+
/** In .view.tsx files, the builder supplies the slot and filename-derived path.
|
|
112
|
+
* Keep an explicit view for a custom path and precise host context typing. */
|
|
113
|
+
export declare function defineView<const TPath extends AppViewPath = AppViewPath, TSchema extends z.ZodType = z.ZodType>(options: {
|
|
114
|
+
slot?: never;
|
|
115
|
+
view?: TPath;
|
|
116
|
+
component: View;
|
|
117
|
+
instances?: ViewInstances<TPath, TSchema>;
|
|
118
|
+
}): ViewDefinition<TPath, z.output<TSchema>>;
|
|
119
|
+
export declare function defineView<const TPath extends AppViewPath, const TSlot extends SlotName, TSchema extends z.ZodType>(options: ViewOptions<TPath, TSlot, TSchema>): ViewDefinition<TPath, z.output<TSchema>, TSlot> & SlotInstanceDefinition<TSlot>;
|
|
120
|
+
export declare const createRemoteComponent: <TProps extends object, TChildren extends boolean = false>(name: string, options?: {
|
|
121
|
+
callbacks?: Record<string, number>;
|
|
122
|
+
children?: TChildren;
|
|
123
|
+
}) => View<TProps & {
|
|
124
|
+
children?: TChildren extends true ? ComponentChildren : never;
|
|
125
|
+
}>;
|
|
126
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,69 +1,91 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailorkit/app",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
4
|
-
"license": "
|
|
3
|
+
"version": "0.1.0-beta.32",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/TailorKit-Labs/TailorKit.git",
|
|
8
8
|
"directory": "packages/app"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
"src"
|
|
11
|
+
"dist"
|
|
13
12
|
],
|
|
14
13
|
"type": "module",
|
|
15
14
|
"imports": {
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
"#env": "./src/env.ts",
|
|
16
|
+
"#*": {
|
|
17
|
+
"development": [
|
|
18
|
+
"./src/*",
|
|
19
|
+
"./src/*.ts",
|
|
20
|
+
"./src/*.tsx",
|
|
21
|
+
"./src/*/index.ts",
|
|
22
|
+
"./src/*/index.tsx"
|
|
23
|
+
],
|
|
24
|
+
"types": [
|
|
25
|
+
"./dist/*",
|
|
26
|
+
"./dist/*.d.ts",
|
|
27
|
+
"./dist/*/index.d.ts"
|
|
28
|
+
],
|
|
29
|
+
"default": [
|
|
30
|
+
"./src/*",
|
|
31
|
+
"./src/*.ts",
|
|
32
|
+
"./src/*.tsx",
|
|
33
|
+
"./src/*/index.ts",
|
|
34
|
+
"./src/*/index.tsx"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
23
37
|
},
|
|
24
38
|
"exports": {
|
|
25
39
|
".": {
|
|
26
|
-
"development": "./src/index.ts",
|
|
27
40
|
"types": "./dist/index.d.ts",
|
|
28
41
|
"import": "./dist/index.js"
|
|
29
42
|
},
|
|
30
|
-
"./
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
43
|
+
"./client": {
|
|
44
|
+
"types": "./dist/client.d.ts",
|
|
45
|
+
"import": "./dist/client.js"
|
|
46
|
+
},
|
|
47
|
+
"./server": {
|
|
48
|
+
"types": "./dist/server.d.ts",
|
|
49
|
+
"import": "./dist/server.js"
|
|
34
50
|
},
|
|
35
|
-
"./
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"import": "./dist/config-loader.js"
|
|
51
|
+
"./protocol": {
|
|
52
|
+
"types": "./dist/protocol.d.ts",
|
|
53
|
+
"import": "./dist/protocol.js"
|
|
39
54
|
},
|
|
40
|
-
"./
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"import": "./dist/builder.js"
|
|
55
|
+
"./client/connection": {
|
|
56
|
+
"types": "./dist/client/connection.d.ts",
|
|
57
|
+
"import": "./dist/client-connection.js"
|
|
44
58
|
}
|
|
45
59
|
},
|
|
46
60
|
"publishConfig": {
|
|
47
61
|
"access": "public"
|
|
48
62
|
},
|
|
49
63
|
"dependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
64
|
+
"@nanostores/preact": "1.1.1",
|
|
65
|
+
"@orpc/client": "2.0.0-beta.40",
|
|
66
|
+
"@orpc/contract": "2.0.0-beta.40",
|
|
67
|
+
"drizzle-orm": "1.0.0-rc.4-5d5b77c",
|
|
68
|
+
"nanostores": "1.5.5",
|
|
69
|
+
"zod": "^4.6.5"
|
|
54
70
|
},
|
|
55
71
|
"devDependencies": {
|
|
56
72
|
"@tailorkit/config": "0.0.0",
|
|
57
|
-
"@types/node": "26.
|
|
58
|
-
"
|
|
73
|
+
"@types/node": "26.6.4",
|
|
74
|
+
"happy-dom": "^20.14.6",
|
|
75
|
+
"preact": "^11.0.1",
|
|
59
76
|
"tsup": "^8.5.1",
|
|
60
|
-
"typescript": "^7.0.2"
|
|
77
|
+
"typescript": "^7.0.2",
|
|
78
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
|
|
79
|
+
"vite-plus": "1.1.0"
|
|
61
80
|
},
|
|
62
81
|
"peerDependencies": {
|
|
63
|
-
"preact": "^
|
|
82
|
+
"preact": "^11.0.0"
|
|
64
83
|
},
|
|
65
84
|
"scripts": {
|
|
66
85
|
"build": "tsup --config tsup.config.ts && tsc -p tsconfig.build.json",
|
|
67
|
-
"check-types": "tsc --noEmit"
|
|
86
|
+
"check-types": "tsc --noEmit",
|
|
87
|
+
"test": "vp test run",
|
|
88
|
+
"lint": "vp lint .",
|
|
89
|
+
"lint:fix": "vp lint --fix ."
|
|
68
90
|
}
|
|
69
91
|
}
|