zitejs 0.10.3 → 0.10.4

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,11 @@
1
+ export type ZiteWorkspace = {
2
+ workspaceHomeUrl: string;
3
+ editorUrl: string;
4
+ appPublicIdentifier: string;
5
+ projectPublicIdentifier: string;
6
+ };
7
+ export declare class ZiteMeta {
8
+ /** Workspace home + this app's editor URL for *this* clone. */
9
+ static getWorkspace(): Promise<ZiteWorkspace>;
10
+ }
11
+ export declare const Meta: typeof ZiteMeta;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Meta = exports.ZiteMeta = void 0;
4
+ const reservedIds_js_1 = require("../internal/reservedIds.js");
5
+ const sdkCall_js_1 = require("../internal/sdkCall.js");
6
+ const META_SDK_INTEGRATION_ID = reservedIds_js_1.RESERVED_INTEGRATION_IDS.meta;
7
+ class ZiteMeta {
8
+ /** Workspace home + this app's editor URL for *this* clone. */
9
+ static getWorkspace() {
10
+ return (0, sdkCall_js_1.getSdkCall)()(META_SDK_INTEGRATION_ID, 'ZiteMeta', 'getWorkspace', {});
11
+ }
12
+ }
13
+ exports.ZiteMeta = ZiteMeta;
14
+ exports.Meta = ZiteMeta;
@@ -1,13 +1,5 @@
1
1
  import { type SourceDir } from '../../sourceRoots.js';
2
- export declare const START_SERVER_ENTRY = ".zite/server.ts";
3
2
  export declare const START_INSTANCE_ENTRY = ".zite/start.ts";
4
- export type StartTarget = 'cloudflare' | 'node';
5
- /**
6
- * The server entry every Start app builds with. Platform-owned: regenerated,
7
- * never edited. On Workers it's an entrypoint, so the host can hand each fetch
8
- * its props; on Node, a plain fetch handler.
9
- */
10
- export declare const renderStartServerEntry: (target?: StartTarget) => string;
11
3
  /** The start instance: the platform's middleware, then the app's own `src/start.ts` when it has one. */
12
4
  export declare const renderStartInstance: (hasAppStart: boolean) => string;
13
5
  export declare const hasAppStart: (appDir: string) => boolean;
@@ -20,6 +12,11 @@ export declare const workspaceHasStartApps: () => boolean;
20
12
  * `dev` all write them. Returns the ones that changed.
21
13
  */
22
14
  export declare function writeStartFiles(appDir: string): string[];
15
+ /**
16
+ * Where an app's role ids are typed: beside the zite.permissions.json they come from, so a workspace's apps share one
17
+ * file. Without one, the workspace root; a single app is its own.
18
+ */
19
+ export declare const rolesDirOf: (appDir: string) => string;
23
20
  export declare function regenerateStartEntries(app: SourceDir): void;
24
21
  /**
25
22
  * App modules that mention createAutomation or createProviderTrigger: what the workflow registry imports. Describe
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderWorkflowModules = exports.workspaceHasStartApps = exports.isStartAppDir = exports.writeIfChanged = exports.hasAppStart = exports.renderStartInstance = exports.renderStartServerEntry = exports.START_INSTANCE_ENTRY = exports.START_SERVER_ENTRY = void 0;
3
+ exports.renderWorkflowModules = exports.rolesDirOf = exports.workspaceHasStartApps = exports.isStartAppDir = exports.writeIfChanged = exports.hasAppStart = exports.renderStartInstance = exports.START_INSTANCE_ENTRY = void 0;
4
4
  exports.writeStartFiles = writeStartFiles;
5
5
  exports.regenerateStartEntries = regenerateStartEntries;
6
6
  exports.workflowFiles = workflowFiles;
@@ -8,34 +8,8 @@ const node_fs_1 = require("node:fs");
8
8
  const node_path_1 = require("node:path");
9
9
  const sourceRoots_js_1 = require("../../sourceRoots.js");
10
10
  const roleIds_js_1 = require("./roleIds.js");
11
- exports.START_SERVER_ENTRY = '.zite/server.ts';
12
11
  exports.START_INSTANCE_ENTRY = '.zite/start.ts';
13
12
  const APP_START_FILES = ['src/start.ts', 'src/start.tsx'];
14
- /**
15
- * The server entry every Start app builds with. Platform-owned: regenerated,
16
- * never edited. On Workers it's an entrypoint, so the host can hand each fetch
17
- * its props; on Node, a plain fetch handler.
18
- */
19
- const renderStartServerEntry = (target = 'cloudflare') => target === 'cloudflare'
20
- ? `// Generated by zitejs for TanStack Start apps. The platform owns this file.
21
- // First, so an SDK client an app module builds as it loads gets zitejs's fetch.
22
- import 'zitejs/start/fetch';
23
- import handler from '@tanstack/react-start/server-entry';
24
- import { createZiteWorker } from 'zitejs/start/worker';
25
- import { getRouter } from '../src/router';
26
-
27
- export default createZiteWorker({ handler, getRouter });
28
- `
29
- : `// Generated by zitejs for TanStack Start apps. The platform owns this file.
30
- // First, so an SDK client an app module builds as it loads gets zitejs's fetch.
31
- import 'zitejs/start/fetch';
32
- import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
33
- import { createZiteFetch } from 'zitejs/start/server';
34
- import { getRouter } from '../src/router';
35
-
36
- export default createServerEntry({ fetch: createZiteFetch({ handler, getRouter }) });
37
- `;
38
- exports.renderStartServerEntry = renderStartServerEntry;
39
13
  const START_INSTANCE_HEADER = `// Generated by zitejs for TanStack Start apps. The platform owns this file.
40
14
  // TanStack's start-instance file, the only place Start 1.169 registers global middleware. Generated so the platform's
41
15
  // CSRF check and run log can't be dropped; the app's own src/start.ts composes after them.
@@ -99,13 +73,32 @@ exports.workspaceHasStartApps = workspaceHasStartApps;
99
73
  * `dev` all write them. Returns the ones that changed.
100
74
  */
101
75
  function writeStartFiles(appDir) {
102
- const files = [
103
- [exports.START_SERVER_ENTRY, (0, exports.renderStartServerEntry)()],
104
- [exports.START_INSTANCE_ENTRY, (0, exports.renderStartInstance)((0, exports.hasAppStart)(appDir))],
105
- [roleIds_js_1.START_ROLES_FILE, (0, roleIds_js_1.renderRoleIds)((0, roleIds_js_1.workspaceRoleIds)(appDir))],
76
+ const rolesDir = (0, exports.rolesDirOf)(appDir);
77
+ return [
78
+ ...((0, exports.writeIfChanged)(appDir, exports.START_INSTANCE_ENTRY, (0, exports.renderStartInstance)((0, exports.hasAppStart)(appDir)))
79
+ ? [exports.START_INSTANCE_ENTRY]
80
+ : []),
81
+ ...((0, exports.writeIfChanged)(rolesDir, roleIds_js_1.START_ROLES_FILE, (0, roleIds_js_1.renderRoleIds)((0, roleIds_js_1.workspaceRoleIds)(appDir)))
82
+ ? [(0, node_path_1.relative)(appDir, (0, node_path_1.join)(rolesDir, roleIds_js_1.START_ROLES_FILE))]
83
+ : []),
106
84
  ];
107
- return files.flatMap(([file, content]) => (0, exports.writeIfChanged)(appDir, file, content) ? [file] : []);
108
85
  }
86
+ /**
87
+ * Where an app's role ids are typed: beside the zite.permissions.json they come from, so a workspace's apps share one
88
+ * file. Without one, the workspace root; a single app is its own.
89
+ */
90
+ const rolesDirOf = (appDir) => {
91
+ const permissions = (0, roleIds_js_1.findPermissionsFile)(appDir);
92
+ if (permissions)
93
+ return (0, node_path_1.dirname)(permissions);
94
+ for (let at = (0, node_path_1.resolve)(appDir);; at = (0, node_path_1.dirname)(at)) {
95
+ if (readConfig(at)?.project !== undefined)
96
+ return at;
97
+ if ((0, node_path_1.dirname)(at) === at)
98
+ return (0, node_path_1.resolve)(appDir);
99
+ }
100
+ };
101
+ exports.rolesDirOf = rolesDirOf;
109
102
  function regenerateStartEntries(app) {
110
103
  if (!isStartApp(app))
111
104
  return;
@@ -1,6 +1,7 @@
1
1
  export declare const START_ROLES_FILE = ".zite/roles.d.ts";
2
2
  /** The roles every workspace has without defining them, as the platform names them. */
3
3
  export declare const BUILTIN_ROLE_IDS: readonly ["builtin:all-team-members", "builtin:all-users"];
4
+ export declare const findPermissionsFile: (appDir: string) => string | undefined;
4
5
  /**
5
6
  * The built-ins, then the roles the nearest `zite.permissions.json` defines. None at all when there's no readable
6
7
  * file, so role ids stay plain strings: a missing or broken file would otherwise type every role the app names as a
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderRoleIds = exports.workspaceRoleIds = exports.BUILTIN_ROLE_IDS = exports.START_ROLES_FILE = void 0;
3
+ exports.renderRoleIds = exports.workspaceRoleIds = exports.findPermissionsFile = exports.BUILTIN_ROLE_IDS = exports.START_ROLES_FILE = void 0;
4
4
  const node_fs_1 = require("node:fs");
5
5
  const node_path_1 = require("node:path");
6
6
  exports.START_ROLES_FILE = '.zite/roles.d.ts';
@@ -20,6 +20,7 @@ const findPermissionsFile = (appDir) => {
20
20
  return undefined;
21
21
  }
22
22
  };
23
+ exports.findPermissionsFile = findPermissionsFile;
23
24
  // Undefined for a file that isn't a permissions file: its roles can't be known.
24
25
  const definedRoleIds = (file) => {
25
26
  try {
@@ -41,7 +42,7 @@ const definedRoleIds = (file) => {
41
42
  * typo, and the nearest id that compiles is a built-in that admits everyone.
42
43
  */
43
44
  const workspaceRoleIds = (appDir) => {
44
- const file = findPermissionsFile(appDir);
45
+ const file = (0, exports.findPermissionsFile)(appDir);
45
46
  const defined = file ? definedRoleIds(file) : undefined;
46
47
  return defined ? [...new Set([...exports.BUILTIN_ROLE_IDS, ...defined])] : [];
47
48
  };
@@ -2,6 +2,7 @@ import type { StepEventStatus, StepSuspension } from '../steps/index.js';
2
2
  import type { AiUsageRecord } from './platform/aiUsage.js';
3
3
  import type { AirtableCache } from './platform/airtable/cache.js';
4
4
  import type { InvokeKind } from './protocol.js';
5
+ import type { ZiteWorkspace } from '../meta/index.js';
5
6
  export type Role = {
6
7
  id: string;
7
8
  name: string;
@@ -238,13 +239,7 @@ export type SiteHead = {
238
239
  /** An installable app's, served at `/manifest.webmanifest`. */
239
240
  manifest?: WebManifest;
240
241
  };
241
- /** `ZiteMeta.getWorkspace()`'s answer: where the app and its workspace are in Zite. */
242
- export type ZiteWorkspace = {
243
- workspaceHomeUrl: string;
244
- editorUrl: string;
245
- appPublicIdentifier: string;
246
- projectPublicIdentifier: string;
247
- };
242
+ export type { ZiteWorkspace };
248
243
  /** A marketplace demo's listing, which the platform's runtime shows the visitor. */
249
244
  export type DemoListing = {
250
245
  listingSlug: string;
@@ -0,0 +1,11 @@
1
+ export type ZiteWorkspace = {
2
+ workspaceHomeUrl: string;
3
+ editorUrl: string;
4
+ appPublicIdentifier: string;
5
+ projectPublicIdentifier: string;
6
+ };
7
+ export declare class ZiteMeta {
8
+ /** Workspace home + this app's editor URL for *this* clone. */
9
+ static getWorkspace(): Promise<ZiteWorkspace>;
10
+ }
11
+ export declare const Meta: typeof ZiteMeta;
@@ -0,0 +1,10 @@
1
+ import { RESERVED_INTEGRATION_IDS } from '../internal/reservedIds.js';
2
+ import { getSdkCall } from '../internal/sdkCall.js';
3
+ const META_SDK_INTEGRATION_ID = RESERVED_INTEGRATION_IDS.meta;
4
+ export class ZiteMeta {
5
+ /** Workspace home + this app's editor URL for *this* clone. */
6
+ static getWorkspace() {
7
+ return getSdkCall()(META_SDK_INTEGRATION_ID, 'ZiteMeta', 'getWorkspace', {});
8
+ }
9
+ }
10
+ export const Meta = ZiteMeta;
@@ -1,13 +1,5 @@
1
1
  import { type SourceDir } from '../../sourceRoots.js';
2
- export declare const START_SERVER_ENTRY = ".zite/server.ts";
3
2
  export declare const START_INSTANCE_ENTRY = ".zite/start.ts";
4
- export type StartTarget = 'cloudflare' | 'node';
5
- /**
6
- * The server entry every Start app builds with. Platform-owned: regenerated,
7
- * never edited. On Workers it's an entrypoint, so the host can hand each fetch
8
- * its props; on Node, a plain fetch handler.
9
- */
10
- export declare const renderStartServerEntry: (target?: StartTarget) => string;
11
3
  /** The start instance: the platform's middleware, then the app's own `src/start.ts` when it has one. */
12
4
  export declare const renderStartInstance: (hasAppStart: boolean) => string;
13
5
  export declare const hasAppStart: (appDir: string) => boolean;
@@ -20,6 +12,11 @@ export declare const workspaceHasStartApps: () => boolean;
20
12
  * `dev` all write them. Returns the ones that changed.
21
13
  */
22
14
  export declare function writeStartFiles(appDir: string): string[];
15
+ /**
16
+ * Where an app's role ids are typed: beside the zite.permissions.json they come from, so a workspace's apps share one
17
+ * file. Without one, the workspace root; a single app is its own.
18
+ */
19
+ export declare const rolesDirOf: (appDir: string) => string;
23
20
  export declare function regenerateStartEntries(app: SourceDir): void;
24
21
  /**
25
22
  * App modules that mention createAutomation or createProviderTrigger: what the workflow registry imports. Describe
@@ -1,34 +1,9 @@
1
1
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, } from 'node:fs';
2
2
  import { dirname, join, relative, resolve } from 'node:path';
3
3
  import { listSourceDirs } from '../../sourceRoots.js';
4
- import { renderRoleIds, START_ROLES_FILE, workspaceRoleIds, } from './roleIds.js';
5
- export const START_SERVER_ENTRY = '.zite/server.ts';
4
+ import { findPermissionsFile, renderRoleIds, START_ROLES_FILE, workspaceRoleIds, } from './roleIds.js';
6
5
  export const START_INSTANCE_ENTRY = '.zite/start.ts';
7
6
  const APP_START_FILES = ['src/start.ts', 'src/start.tsx'];
8
- /**
9
- * The server entry every Start app builds with. Platform-owned: regenerated,
10
- * never edited. On Workers it's an entrypoint, so the host can hand each fetch
11
- * its props; on Node, a plain fetch handler.
12
- */
13
- export const renderStartServerEntry = (target = 'cloudflare') => target === 'cloudflare'
14
- ? `// Generated by zitejs for TanStack Start apps. The platform owns this file.
15
- // First, so an SDK client an app module builds as it loads gets zitejs's fetch.
16
- import 'zitejs/start/fetch';
17
- import handler from '@tanstack/react-start/server-entry';
18
- import { createZiteWorker } from 'zitejs/start/worker';
19
- import { getRouter } from '../src/router';
20
-
21
- export default createZiteWorker({ handler, getRouter });
22
- `
23
- : `// Generated by zitejs for TanStack Start apps. The platform owns this file.
24
- // First, so an SDK client an app module builds as it loads gets zitejs's fetch.
25
- import 'zitejs/start/fetch';
26
- import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
27
- import { createZiteFetch } from 'zitejs/start/server';
28
- import { getRouter } from '../src/router';
29
-
30
- export default createServerEntry({ fetch: createZiteFetch({ handler, getRouter }) });
31
- `;
32
7
  const START_INSTANCE_HEADER = `// Generated by zitejs for TanStack Start apps. The platform owns this file.
33
8
  // TanStack's start-instance file, the only place Start 1.169 registers global middleware. Generated so the platform's
34
9
  // CSRF check and run log can't be dropped; the app's own src/start.ts composes after them.
@@ -87,13 +62,31 @@ export const workspaceHasStartApps = () => listSourceDirs().some(isStartApp);
87
62
  * `dev` all write them. Returns the ones that changed.
88
63
  */
89
64
  export function writeStartFiles(appDir) {
90
- const files = [
91
- [START_SERVER_ENTRY, renderStartServerEntry()],
92
- [START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir))],
93
- [START_ROLES_FILE, renderRoleIds(workspaceRoleIds(appDir))],
65
+ const rolesDir = rolesDirOf(appDir);
66
+ return [
67
+ ...(writeIfChanged(appDir, START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir)))
68
+ ? [START_INSTANCE_ENTRY]
69
+ : []),
70
+ ...(writeIfChanged(rolesDir, START_ROLES_FILE, renderRoleIds(workspaceRoleIds(appDir)))
71
+ ? [relative(appDir, join(rolesDir, START_ROLES_FILE))]
72
+ : []),
94
73
  ];
95
- return files.flatMap(([file, content]) => writeIfChanged(appDir, file, content) ? [file] : []);
96
74
  }
75
+ /**
76
+ * Where an app's role ids are typed: beside the zite.permissions.json they come from, so a workspace's apps share one
77
+ * file. Without one, the workspace root; a single app is its own.
78
+ */
79
+ export const rolesDirOf = (appDir) => {
80
+ const permissions = findPermissionsFile(appDir);
81
+ if (permissions)
82
+ return dirname(permissions);
83
+ for (let at = resolve(appDir);; at = dirname(at)) {
84
+ if (readConfig(at)?.project !== undefined)
85
+ return at;
86
+ if (dirname(at) === at)
87
+ return resolve(appDir);
88
+ }
89
+ };
97
90
  export function regenerateStartEntries(app) {
98
91
  if (!isStartApp(app))
99
92
  return;
@@ -1,6 +1,7 @@
1
1
  export declare const START_ROLES_FILE = ".zite/roles.d.ts";
2
2
  /** The roles every workspace has without defining them, as the platform names them. */
3
3
  export declare const BUILTIN_ROLE_IDS: readonly ["builtin:all-team-members", "builtin:all-users"];
4
+ export declare const findPermissionsFile: (appDir: string) => string | undefined;
4
5
  /**
5
6
  * The built-ins, then the roles the nearest `zite.permissions.json` defines. None at all when there's no readable
6
7
  * file, so role ids stay plain strings: a missing or broken file would otherwise type every role the app names as a
@@ -8,7 +8,7 @@ export const BUILTIN_ROLE_IDS = [
8
8
  ];
9
9
  const PERMISSIONS_FILE = 'zite.permissions.json';
10
10
  // The workspace root's in a monorepo, above apps/<dir>/.
11
- const findPermissionsFile = (appDir) => {
11
+ export const findPermissionsFile = (appDir) => {
12
12
  for (let dir = resolve(appDir);; dir = dirname(dir)) {
13
13
  const file = join(dir, PERMISSIONS_FILE);
14
14
  if (existsSync(file))
@@ -41,7 +41,7 @@ export declare const devSignInOf: (appDir: string, appEnv: Record<string, string
41
41
  /** @internal The app's id in its zite.config.json, which `local` mints dev tokens for; null without one. */
42
42
  export declare const devAppIdOf: (appDir: string) => string | null;
43
43
  export type ZiteOptions = {
44
- /** A server entry the caller owns, relative to the app root. By default zite() writes the platform's. */
44
+ /** A server entry the caller owns, relative to the app root. By default the app builds on zitejs's own. */
45
45
  serverEntry?: string;
46
46
  /** Build for Cloudflare Workers, the target the platform deploys. Defaults to true; false builds for Node. */
47
47
  cloudflare?: boolean;
@@ -1,5 +1,6 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
3
4
  import { loadEnv } from 'vite';
4
5
  import { parse as parseEnv } from 'dotenv';
5
6
  import { tanstackStart } from '@tanstack/react-start/plugin/vite';
@@ -13,7 +14,7 @@ import { sourceRootOf } from '../../sourceRoots.js';
13
14
  import { registrationHashes } from './registrationHash.js';
14
15
  import { sdkPatches } from './sdkPatches.js';
15
16
  import { siteHeadOf } from './siteHead.js';
16
- import { hasAppStart, renderStartInstance, renderStartServerEntry, renderWorkflowModules, START_INSTANCE_ENTRY, START_SERVER_ENTRY, workflowFiles, writeIfChanged, } from './entries.js';
17
+ import { hasAppStart, renderStartInstance, renderWorkflowModules, START_INSTANCE_ENTRY, workflowFiles, writeIfChanged, } from './entries.js';
17
18
  // Must match the literals in ../serve/server.ts and ../describe/describe.ts, which the build rewrites.
18
19
  const FN_IDS_TOKEN = '__ZITE_FN_IDS__';
19
20
  const FN_DESCRIPTIONS_LITERAL = /(["'`])__ZITE_FN_DESCRIPTIONS__\1/;
@@ -176,13 +177,12 @@ const loadCloudflare = async (main) => {
176
177
  };
177
178
  /** The one plugin a Zite app's `vite.config.ts` uses. */
178
179
  export function zite(options = {}) {
179
- const serverEntry = options.serverEntry ?? START_SERVER_ENTRY;
180
- // Platform-owned, so they're rewritten whenever they differ. Sandboxes run the
181
- // image's zitejs for `generate`, which may predate Start; the plugin can't.
182
180
  const appDir = process.cwd();
183
- if (!options.serverEntry) {
184
- writeIfChanged(appDir, START_SERVER_ENTRY, renderStartServerEntry(options.cloudflare === false ? 'node' : 'cloudflare'));
185
- }
181
+ const serverEntry = options.serverEntry
182
+ ? path.join(appDir, options.serverEntry)
183
+ : fileURLToPath(new URL(`../entries/${options.cloudflare === false ? 'node' : 'worker'}/server.js`, import.meta.url));
184
+ // Platform-owned, so it's rewritten whenever it differs. Sandboxes run the
185
+ // image's zitejs for `generate`, which may predate Start; the plugin can't.
186
186
  writeIfChanged(appDir, START_INSTANCE_ENTRY, renderStartInstance(hasAppStart(appDir)));
187
187
  // Every server function TanStack's compiler found, from its own hook, by id.
188
188
  const ids = new Map();
@@ -225,10 +225,6 @@ export function zite(options = {}) {
225
225
  find: /^zitejs\/email$/,
226
226
  replacement: path.join(root, '.zite/integrations/email.ts'),
227
227
  },
228
- {
229
- find: /^zitejs\/meta$/,
230
- replacement: path.join(root, '.zite/meta.ts'),
231
- },
232
228
  // Classic's actions run on better-auth's client; Start's call the sign-in module's routes.
233
229
  { find: /^zitejs\/auth$/, replacement: 'zitejs/start/auth' },
234
230
  ],
@@ -418,12 +414,27 @@ export function zite(options = {}) {
418
414
  return `export const devSignIn = ${JSON.stringify(settings)};\n`;
419
415
  },
420
416
  };
417
+ // The built-in server entry imports the app's router through this.
418
+ const appRouter = {
419
+ name: 'zite:app-router',
420
+ enforce: 'pre',
421
+ resolveId(id) {
422
+ return id === 'virtual:zite/app-router'
423
+ ? this.resolve(path.join(appDir, 'src', 'router'))
424
+ : undefined;
425
+ },
426
+ };
421
427
  return [
422
428
  // First, so ids name lines in the source, before TanStack splits a route's component out of it.
423
429
  ziteId(),
430
+ appRouter,
424
431
  tanstackStart({
425
- // TanStack resolves these from `src/`.
426
- server: { entry: `../${serverEntry.replace(/\.ts$/, '')}` },
432
+ // TanStack resolves its entries from the app's src/, and only as relative paths.
433
+ server: {
434
+ entry: path
435
+ .relative(path.join(appDir, 'src'), serverEntry)
436
+ .replace(/\.ts$/, ''),
437
+ },
427
438
  start: { entry: `../${START_INSTANCE_ENTRY.replace(/\.ts$/, '')}` },
428
439
  serverFns: {
429
440
  generateFunctionId: ({ filename, functionName }) => {
@@ -456,15 +467,15 @@ export function zite(options = {}) {
456
467
  'zitejs/start/worker',
457
468
  'zitejs/start/describe',
458
469
  'zitejs/runtime',
470
+ 'zitejs/meta',
459
471
  ],
460
472
  // Replaces TanStack's list, so its `**/*.server.*` is restated. File
461
- // patterns also catch `zitejs/db`, `zitejs/integrations` and `zitejs/meta`,
462
- // which the aliases above rewrite before specifiers are matched.
473
+ // patterns also catch `zitejs/db` and `zitejs/integrations`, which the
474
+ // aliases above rewrite before specifiers are matched.
463
475
  files: [
464
476
  '**/*.server.*',
465
477
  '**/.zite/db.ts',
466
478
  '**/.zite/integrations/**',
467
- '**/.zite/meta.ts',
468
479
  ],
469
480
  },
470
481
  // Replaces TanStack's empty list; its `**/*.client.*` files stay.
@@ -0,0 +1,3 @@
1
+ import '../../serve/fetch.js';
2
+ declare const _default: import("@tanstack/react-start/server-entry").ServerEntry;
3
+ export default _default;
@@ -0,0 +1,9 @@
1
+ // The server entry a Start app builds with off Workers: a plain fetch handler.
2
+ // First, so an SDK client an app module builds as it loads gets zitejs's fetch.
3
+ import '../../serve/fetch.js';
4
+ import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
5
+ import { getRouter } from 'virtual:zite/app-router';
6
+ import { createZiteFetch } from '../../serve/server.js';
7
+ export default createServerEntry({
8
+ fetch: createZiteFetch({ handler, getRouter }),
9
+ });
@@ -0,0 +1,3 @@
1
+ import '../../serve/fetch.js';
2
+ declare const _default: import("../../serve/worker.js").ZiteWorker;
3
+ export default _default;
@@ -0,0 +1,7 @@
1
+ // The server entry every Start app builds with on Workers: an entrypoint, so the host can hand each fetch its props.
2
+ // First, so an SDK client an app module builds as it loads gets zitejs's fetch.
3
+ import '../../serve/fetch.js';
4
+ import handler from '@tanstack/react-start/server-entry';
5
+ import { getRouter } from 'virtual:zite/app-router';
6
+ import { createZiteWorker } from '../../serve/worker.js';
7
+ export default createZiteWorker({ handler, getRouter });
@@ -2,6 +2,7 @@ import type { StepEventStatus, StepSuspension } from '../steps/index.js';
2
2
  import type { AiUsageRecord } from './platform/aiUsage.js';
3
3
  import type { AirtableCache } from './platform/airtable/cache.js';
4
4
  import type { InvokeKind } from './protocol.js';
5
+ import type { ZiteWorkspace } from '../meta/index.js';
5
6
  export type Role = {
6
7
  id: string;
7
8
  name: string;
@@ -238,13 +239,7 @@ export type SiteHead = {
238
239
  /** An installable app's, served at `/manifest.webmanifest`. */
239
240
  manifest?: WebManifest;
240
241
  };
241
- /** `ZiteMeta.getWorkspace()`'s answer: where the app and its workspace are in Zite. */
242
- export type ZiteWorkspace = {
243
- workspaceHomeUrl: string;
244
- editorUrl: string;
245
- appPublicIdentifier: string;
246
- projectPublicIdentifier: string;
247
- };
242
+ export type { ZiteWorkspace };
248
243
  /** A marketplace demo's listing, which the platform's runtime shows the visitor. */
249
244
  export type DemoListing = {
250
245
  listingSlug: string;
@@ -1 +1 @@
1
- export declare const ZITEJS_VERSION = "0.10.3";
1
+ export declare const ZITEJS_VERSION = "0.10.4";
@@ -1,2 +1,2 @@
1
1
  // Written by scripts/write-version.mjs from package.json.
2
- export const ZITEJS_VERSION = '0.10.3';
2
+ export const ZITEJS_VERSION = '0.10.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -79,6 +79,11 @@
79
79
  "import": "./dist/esm/pdf/index.js",
80
80
  "require": "./dist/cjs/pdf/index.js"
81
81
  },
82
+ "./meta": {
83
+ "types": "./dist/esm/meta/index.d.ts",
84
+ "import": "./dist/esm/meta/index.js",
85
+ "require": "./dist/cjs/meta/index.js"
86
+ },
82
87
  "./schedules": {
83
88
  "types": "./dist/esm/schedules/index.d.ts",
84
89
  "import": "./dist/esm/schedules/index.js",
@@ -24,7 +24,6 @@
24
24
  "zitejs/db": ["${configDir}/../../.zite/db.ts"],
25
25
  "zitejs/integrations": ["${configDir}/.zite/integrations/index.ts"],
26
26
  "zitejs/email": ["${configDir}/.zite/integrations/email.ts"],
27
- "zitejs/meta": ["${configDir}/.zite/meta.ts"],
28
27
  "react": ["${configDir}/node_modules/@types/react"],
29
28
  "react/*": ["${configDir}/node_modules/@types/react/*"],
30
29
  "react-dom": ["${configDir}/node_modules/@types/react-dom"],
@@ -34,6 +33,7 @@
34
33
  "include": [
35
34
  "${configDir}/src",
36
35
  "${configDir}/.zite/*.d.ts",
36
+ "${configDir}/../../.zite/*.d.ts",
37
37
  "${configDir}/vite.config.ts"
38
38
  ],
39
39
  "exclude": ["${configDir}/node_modules", "${configDir}/dist"]