zitejs 0.9.138 → 0.10.0-start.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.
Files changed (39) hide show
  1. package/dist/cjs/cli.js +10 -3
  2. package/dist/cjs/dev/index.js +3 -0
  3. package/dist/cjs/start/describeBuilt.d.ts +3 -0
  4. package/dist/cjs/start/describeBuilt.js +106 -0
  5. package/dist/cjs/start/entries.d.ts +11 -0
  6. package/dist/cjs/start/entries.js +64 -0
  7. package/dist/esm/cli.js +10 -3
  8. package/dist/esm/dev/index.js +3 -0
  9. package/dist/esm/start/describe.d.ts +40 -0
  10. package/dist/esm/start/describe.js +122 -0
  11. package/dist/esm/start/describeBuilt.d.ts +3 -0
  12. package/dist/esm/start/describeBuilt.js +66 -0
  13. package/dist/esm/start/entries.d.ts +11 -0
  14. package/dist/esm/start/entries.js +56 -0
  15. package/dist/esm/start/host.d.ts +3 -0
  16. package/dist/esm/start/host.js +4 -0
  17. package/dist/esm/start/index.d.ts +64 -0
  18. package/dist/esm/start/index.js +123 -0
  19. package/dist/esm/start/instance.d.ts +12 -0
  20. package/dist/esm/start/instance.js +89 -0
  21. package/dist/esm/start/router.d.ts +17 -0
  22. package/dist/esm/start/router.js +34 -0
  23. package/dist/esm/start/scope.d.ts +15 -0
  24. package/dist/esm/start/scope.js +58 -0
  25. package/dist/esm/start/server.d.ts +47 -0
  26. package/dist/esm/start/server.js +81 -0
  27. package/dist/esm/start/types.d.ts +32 -0
  28. package/dist/esm/start/types.js +1 -0
  29. package/dist/esm/start/vite.d.ts +9 -0
  30. package/dist/esm/start/vite.js +114 -0
  31. package/package.json +53 -2
  32. package/dist/cjs/meta/index.d.ts +0 -14
  33. package/dist/cjs/meta/index.js +0 -12
  34. package/dist/cjs/notifications/index.d.ts +0 -25
  35. package/dist/cjs/notifications/index.js +0 -12
  36. package/dist/esm/meta/index.d.ts +0 -14
  37. package/dist/esm/meta/index.js +0 -8
  38. package/dist/esm/notifications/index.d.ts +0 -25
  39. package/dist/esm/notifications/index.js +0 -8
@@ -0,0 +1,114 @@
1
+ import path from "node:path";
2
+ import { tanstackStart } from "@tanstack/react-start/plugin/vite";
3
+ import viteReact from "@vitejs/plugin-react";
4
+ import { ziteId } from "../vite/index.js";
5
+ import { hasAppStart, renderStartInstance, renderStartServerEntry, START_INSTANCE_ENTRY, START_SERVER_ENTRY, writeIfChanged, } from "./entries.js";
6
+ // Must match the literal in ./server.ts, which the build rewrites.
7
+ const FN_IDS_TOKEN = "__ZITE_FN_IDS__";
8
+ // Platform-pinned Worker settings. The deploy uses its own fixed template, so
9
+ // these only have to match it; apps don't carry a wrangler config.
10
+ const WORKER_COMPATIBILITY_DATE = "2026-09-25";
11
+ const WORKER_COMPATIBILITY_FLAGS = ["nodejs_compat"];
12
+ // Resolved from the app at build time; zitejs doesn't depend on it.
13
+ const loadCloudflare = async (main) => {
14
+ const { cloudflare } = (await import("@cloudflare/vite-plugin"));
15
+ return cloudflare({
16
+ viteEnvironment: { name: "ssr" },
17
+ config: {
18
+ name: "zite-app",
19
+ main,
20
+ compatibility_date: WORKER_COMPATIBILITY_DATE,
21
+ compatibility_flags: WORKER_COMPATIBILITY_FLAGS,
22
+ },
23
+ });
24
+ };
25
+ /** The one plugin a Zite app's `vite.config.ts` uses. */
26
+ export function zite(options = {}) {
27
+ const serverEntry = options.serverEntry ?? START_SERVER_ENTRY;
28
+ // Platform-owned, so they're rewritten whenever they differ. Sandboxes run the
29
+ // image's zitejs for `generate`, which may predate Start; the plugin can't.
30
+ const appDir = process.cwd();
31
+ if (!options.serverEntry)
32
+ writeIfChanged(appDir, START_SERVER_ENTRY, renderStartServerEntry());
33
+ writeIfChanged(appDir, START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir)));
34
+ // Every server function TanStack's compiler found, from its own hook, by id.
35
+ const ids = new Map();
36
+ const compileZitejs = {
37
+ name: "zite:compile-zitejs",
38
+ // The factories must go through TanStack's compiler in both environments.
39
+ // The peer dependency gets zitejs crawled already; this keeps it true if an
40
+ // install drops that. A Node build bundles everything, so externalized
41
+ // libraries can't load the root's React 18 renderer.
42
+ config: (config) => {
43
+ const root = path.resolve(config.root ?? ".");
44
+ const src = `${path.join(root, "src")}/`;
45
+ return {
46
+ ssr: { noExternal: options.cloudflare === false ? true : ["zitejs"] },
47
+ optimizeDeps: { exclude: ["zitejs"] },
48
+ resolve: {
49
+ // `@/` as in classic apps and shadcn, `~/` as in TanStack's templates.
50
+ alias: [
51
+ { find: /^@\//, replacement: src },
52
+ { find: /^~\//, replacement: src },
53
+ // The workspace SDKs `zitejs generate` writes, as classic apps map them.
54
+ { find: /^zitejs\/db$/, replacement: path.join(root, "../../.zite/db.ts") },
55
+ { find: /^zitejs\/integrations$/, replacement: path.join(root, ".zite/integrations/index.ts") },
56
+ { find: /^zitejs\/email$/, replacement: path.join(root, ".zite/integrations/email.ts") },
57
+ { find: /^zitejs\/meta$/, replacement: path.join(root, ".zite/meta.ts") },
58
+ ],
59
+ // Shared workspace libraries resolve from the root, where classic apps
60
+ // keep React 18; recharts 2 needs the app's react-is 19 or drops series.
61
+ dedupe: ["react-is"],
62
+ },
63
+ };
64
+ },
65
+ };
66
+ const functionIds = {
67
+ name: "zite:function-ids",
68
+ apply: "build",
69
+ generateBundle(_, bundle) {
70
+ for (const chunk of Object.values(bundle)) {
71
+ if (chunk.type === "chunk" && chunk.code.includes(FN_IDS_TOKEN)) {
72
+ chunk.code = chunk.code.replace(FN_IDS_TOKEN, [...ids.keys()].join(","));
73
+ }
74
+ }
75
+ },
76
+ };
77
+ return [
78
+ tanstackStart({
79
+ // TanStack resolves these from `src/`.
80
+ server: { entry: `../${serverEntry.replace(/\.ts$/, "")}` },
81
+ start: { entry: `../${START_INSTANCE_ENTRY.replace(/\.ts$/, "")}` },
82
+ serverFns: {
83
+ generateFunctionId: ({ filename, functionName }) => {
84
+ const id = functionName.replace(/_createServerFn_handler$/, "");
85
+ if (/(^|\/)node_modules\//.test(filename)) {
86
+ throw new Error(`[zite] ${filename} defines server function ${id}; dependencies can't ship server functions`);
87
+ }
88
+ const existing = ids.get(id);
89
+ if (existing && existing !== filename) {
90
+ throw new Error(`[zite] server function name ${id} is used in both ${existing} and ${filename}`);
91
+ }
92
+ ids.set(id, filename);
93
+ return id;
94
+ },
95
+ },
96
+ importProtection: {
97
+ behavior: "error",
98
+ client: {
99
+ // Appended to TanStack's own.
100
+ specifiers: ["zitejs/start/server", "zitejs/start/describe", "zitejs/runtime"],
101
+ // Replaces TanStack's list, so its `**/*.server.*` is restated. File
102
+ // patterns also catch `zitejs/db` and `zitejs/integrations`, which the
103
+ // aliases above rewrite before specifiers are matched.
104
+ files: ["**/*.server.*", "**/.zite/db.ts", "**/.zite/integrations/**"],
105
+ },
106
+ },
107
+ }),
108
+ options.cloudflare !== false ? loadCloudflare(serverEntry) : null,
109
+ viteReact(),
110
+ ziteId(),
111
+ compileZitejs,
112
+ functionIds,
113
+ ];
114
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.138",
3
+ "version": "0.10.0-start.1",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -90,11 +90,37 @@
90
90
  "import": "./dist/esm/vite/index.js",
91
91
  "require": "./dist/cjs/vite/index.js",
92
92
  "default": "./dist/esm/vite/index.js"
93
+ },
94
+ "./start": {
95
+ "types": "./dist/esm/start/index.d.ts",
96
+ "import": "./dist/esm/start/index.js",
97
+ "default": "./dist/esm/start/index.js"
98
+ },
99
+ "./start/server": {
100
+ "types": "./dist/esm/start/server.d.ts",
101
+ "import": "./dist/esm/start/server.js",
102
+ "default": "./dist/esm/start/server.js"
103
+ },
104
+ "./start/instance": {
105
+ "types": "./dist/esm/start/instance.d.ts",
106
+ "import": "./dist/esm/start/instance.js",
107
+ "default": "./dist/esm/start/instance.js"
108
+ },
109
+ "./start/describe": {
110
+ "types": "./dist/esm/start/describe.d.ts",
111
+ "import": "./dist/esm/start/describe.js",
112
+ "default": "./dist/esm/start/describe.js"
113
+ },
114
+ "./vite": {
115
+ "types": "./dist/esm/start/vite.d.ts",
116
+ "import": "./dist/esm/start/vite.js",
117
+ "default": "./dist/esm/start/vite.js"
93
118
  }
94
119
  },
95
120
  "scripts": {
96
121
  "build": "tsc && tsc -p tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
97
122
  "test": "vitest run",
123
+ "test:start": "node tests/start/run-contract.mjs",
98
124
  "test:watch": "vitest",
99
125
  "typecheck": "tsc --noEmit",
100
126
  "prepublishOnly": "npm run build"
@@ -148,7 +174,12 @@
148
174
  "peerDependencies": {
149
175
  "@tanstack/react-query": ">=5",
150
176
  "react": ">=18",
151
- "vite": ">=5"
177
+ "vite": ">=5",
178
+ "@tanstack/react-start": "1.168.60",
179
+ "@tanstack/start-storage-context": "1.167.36",
180
+ "@vitejs/plugin-react": ">=5",
181
+ "@cloudflare/vite-plugin": ">=1",
182
+ "@tanstack/react-router": "1.170.41"
152
183
  },
153
184
  "peerDependenciesMeta": {
154
185
  "react": {
@@ -159,14 +190,34 @@
159
190
  },
160
191
  "vite": {
161
192
  "optional": true
193
+ },
194
+ "@tanstack/react-start": {
195
+ "optional": true
196
+ },
197
+ "@tanstack/start-storage-context": {
198
+ "optional": true
199
+ },
200
+ "@vitejs/plugin-react": {
201
+ "optional": true
202
+ },
203
+ "@cloudflare/vite-plugin": {
204
+ "optional": true
205
+ },
206
+ "@tanstack/react-router": {
207
+ "optional": true
162
208
  }
163
209
  },
164
210
  "devDependencies": {
165
211
  "@tanstack/react-query": "^5.100.14",
212
+ "@tanstack/react-router": "1.170.41",
213
+ "@tanstack/react-start": "1.168.60",
214
+ "@tanstack/start-storage-context": "1.167.36",
166
215
  "@types/node": "^25.9.1",
167
216
  "@types/react": "^19.0.0",
217
+ "@vitejs/plugin-react": "^5.2.0",
168
218
  "react": "^19.0.0",
169
219
  "typescript": "^5.4.0",
220
+ "vite": "^7.3.7",
170
221
  "vitest": "^3.0.0"
171
222
  },
172
223
  "keywords": [
@@ -1,14 +0,0 @@
1
- export type ZiteProjectUser = {
2
- uuid: string;
3
- firstName: string | null;
4
- lastName: string | null;
5
- email: string;
6
- profilePictureUrl: string | null;
7
- };
8
- export type MetaListUsersResult = {
9
- users: ZiteProjectUser[];
10
- };
11
- export declare class ZiteMeta {
12
- static listUsers(): Promise<MetaListUsersResult>;
13
- }
14
- export declare const Meta: typeof ZiteMeta;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Meta = exports.ZiteMeta = void 0;
4
- const sdkCall_js_1 = require("../internal/sdkCall.js");
5
- const META_SDK_INTEGRATION_ID = '__meta__';
6
- class ZiteMeta {
7
- static listUsers() {
8
- return (0, sdkCall_js_1.getSdkCall)()(META_SDK_INTEGRATION_ID, 'ZiteMeta', 'listUsers', {});
9
- }
10
- }
11
- exports.ZiteMeta = ZiteMeta;
12
- exports.Meta = ZiteMeta;
@@ -1,25 +0,0 @@
1
- export interface NotificationLink {
2
- path?: string;
3
- params?: Record<string, string>;
4
- }
5
- export type NotificationsCreateParams = {
6
- recipients: string[];
7
- title: string;
8
- body?: string;
9
- link?: NotificationLink;
10
- path?: string;
11
- params?: Record<string, string>;
12
- payload?: Record<string, unknown>;
13
- idempotencyKey?: string;
14
- };
15
- export type NotificationsCreateResult = {
16
- created: number;
17
- } | {
18
- created: 0;
19
- preview: true;
20
- wouldCreate: number;
21
- };
22
- export declare class ZiteNotifications {
23
- static create(params: NotificationsCreateParams): Promise<NotificationsCreateResult>;
24
- }
25
- export declare const Notifications: typeof ZiteNotifications;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Notifications = exports.ZiteNotifications = void 0;
4
- const sdkCall_js_1 = require("../internal/sdkCall.js");
5
- const NOTIFICATIONS_SDK_INTEGRATION_ID = '__notifications__';
6
- class ZiteNotifications {
7
- static create(params) {
8
- return (0, sdkCall_js_1.getSdkCall)()(NOTIFICATIONS_SDK_INTEGRATION_ID, 'ZiteNotifications', 'create', params);
9
- }
10
- }
11
- exports.ZiteNotifications = ZiteNotifications;
12
- exports.Notifications = ZiteNotifications;
@@ -1,14 +0,0 @@
1
- export type ZiteProjectUser = {
2
- uuid: string;
3
- firstName: string | null;
4
- lastName: string | null;
5
- email: string;
6
- profilePictureUrl: string | null;
7
- };
8
- export type MetaListUsersResult = {
9
- users: ZiteProjectUser[];
10
- };
11
- export declare class ZiteMeta {
12
- static listUsers(): Promise<MetaListUsersResult>;
13
- }
14
- export declare const Meta: typeof ZiteMeta;
@@ -1,8 +0,0 @@
1
- import { getSdkCall } from '../internal/sdkCall.js';
2
- const META_SDK_INTEGRATION_ID = '__meta__';
3
- export class ZiteMeta {
4
- static listUsers() {
5
- return getSdkCall()(META_SDK_INTEGRATION_ID, 'ZiteMeta', 'listUsers', {});
6
- }
7
- }
8
- export const Meta = ZiteMeta;
@@ -1,25 +0,0 @@
1
- export interface NotificationLink {
2
- path?: string;
3
- params?: Record<string, string>;
4
- }
5
- export type NotificationsCreateParams = {
6
- recipients: string[];
7
- title: string;
8
- body?: string;
9
- link?: NotificationLink;
10
- path?: string;
11
- params?: Record<string, string>;
12
- payload?: Record<string, unknown>;
13
- idempotencyKey?: string;
14
- };
15
- export type NotificationsCreateResult = {
16
- created: number;
17
- } | {
18
- created: 0;
19
- preview: true;
20
- wouldCreate: number;
21
- };
22
- export declare class ZiteNotifications {
23
- static create(params: NotificationsCreateParams): Promise<NotificationsCreateResult>;
24
- }
25
- export declare const Notifications: typeof ZiteNotifications;
@@ -1,8 +0,0 @@
1
- import { getSdkCall } from '../internal/sdkCall.js';
2
- const NOTIFICATIONS_SDK_INTEGRATION_ID = '__notifications__';
3
- export class ZiteNotifications {
4
- static create(params) {
5
- return getSdkCall()(NOTIFICATIONS_SDK_INTEGRATION_ID, 'ZiteNotifications', 'create', params);
6
- }
7
- }
8
- export const Notifications = ZiteNotifications;