@parlor/host 0.4.2 → 0.4.3
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/build.d.ts +2 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +4 -0
- package/dist/build.js.map +1 -1
- package/package.json +8 -8
package/dist/build.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { type LoadedConfig, type ParlorConfig } from "@parlor/config";
|
|
|
2
2
|
import type { NitroConfig } from "nitro/types";
|
|
3
3
|
import { type DeployPreset } from "./presets.js";
|
|
4
4
|
export declare const SYNC_TRANSPORT_ENV = "PARLOR_SYNC_TRANSPORT";
|
|
5
|
+
/** Names one `parlor build`, so a client can tell a deploy happened (`@parlor/server` reads it). */
|
|
6
|
+
export declare const BUILD_ID_ENV = "PARLOR_BUILD_ID";
|
|
5
7
|
export declare const MIGRATIONS_PLACEHOLDER = "__PARLOR_MIGRATIONS__";
|
|
6
8
|
export interface ServerBuildOptions {
|
|
7
9
|
readonly preset: DeployPreset;
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAmB/C,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAC1D,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAK9D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,WAAW,CAAC,mBAAm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, labelChunkGroups, } f
|
|
|
11
11
|
import { cloudflareEntrySource, DURABLE_SERVER_BINDING, DURABLE_SERVER_CLASS, durableServerSource, hostEntrySource, INDEX_HTML_PLACEHOLDER, NONCE_PLACEHOLDER, PAGE_ROUTES_PLACEHOLDER, UI_MANIFEST_PLACEHOLDER, } from "./entry.js";
|
|
12
12
|
import { nitroPresetFor, runsOnWorkerd, syncTransportFor, } from "./presets.js";
|
|
13
13
|
export const SYNC_TRANSPORT_ENV = "PARLOR_SYNC_TRANSPORT";
|
|
14
|
+
/** Names one `parlor build`, so a client can tell a deploy happened (`@parlor/server` reads it). */
|
|
15
|
+
export const BUILD_ID_ENV = "PARLOR_BUILD_ID";
|
|
16
|
+
const buildId = () => `${Date.now().toString(36)}-${crypto.randomUUID().slice(0, 8)}`;
|
|
14
17
|
export const MIGRATIONS_PLACEHOLDER = "__PARLOR_MIGRATIONS__";
|
|
15
18
|
const TRACED_DEPENDENCIES = ["@electric-sql/pglite", "pg"];
|
|
16
19
|
const DEFAULT_COMPATIBILITY_DATE = "2026-10-01";
|
|
@@ -98,6 +101,7 @@ export async function buildServer({ config, rootDir }, options) {
|
|
|
98
101
|
[UI_MANIFEST_PLACEHOLDER]: manifest ? JSON.stringify(manifest) : "undefined",
|
|
99
102
|
[PAGE_ROUTES_PLACEHOLDER]: pageRoutesSource(manifest),
|
|
100
103
|
[`process.env.${SYNC_TRANSPORT_ENV}`]: JSON.stringify(syncTransport),
|
|
104
|
+
[`process.env.${BUILD_ID_ENV}`]: JSON.stringify(buildId()),
|
|
101
105
|
...(cloudflare ? { [MIGRATIONS_PLACEHOLDER]: cloudflare.migrations } : {}),
|
|
102
106
|
...Object.fromEntries(Object.entries(appServerEnv(config)).map(([name, value]) => [
|
|
103
107
|
`process.env.${name}`,
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,U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SAAS,CACb,WAAW,EACX,mBAAmB,CAAC;QAClB,WAAW;QACX,gBAAgB,EAAE,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC;QACpD,aAAa,EAAE,iBAAiB;KACjC,CAAC,CACH,CAAC;IACF,OAAO;QACL,UAAU,EAAE,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;QACnE,KAAK,EAAE;YACL,OAAO,EAAE,WAAW;YACpB,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,IAAI;YAChB,QAAQ,EAAE,qBAAqB,CAAC,MAAM,CAAC;SACxC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ;IACtB,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9E,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAExD,CAAC;IACF,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC;IACzD,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,sBAAsB,CAAC,CAAC;IAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\n\nimport { pagePattern, UI_MANIFEST_FILE, type UiManifest } from \"@parlor/agent-ui\";\nimport {\n appServerEnv,\n ConfigError,\n generatedDir,\n type LoadedConfig,\n type ParlorConfig,\n} from \"@parlor/config\";\nimport { appCsp, extendCsp, serializeCsp, webOutDir } from \"@parlor/shell-web\";\nimport { readMigrationFiles } from \"drizzle-orm/migrator\";\nimport { build, copyPublicAssets, createNitro, prepare } from \"nitro/builder\";\nimport type { NitroConfig } from \"nitro/types\";\n\nimport {\n importRequiredBuiltins,\n keepJsonOutOfChunkGroups,\n labelChunkGroups,\n} from \"./bundle.js\";\nimport {\n cloudflareEntrySource,\n DURABLE_SERVER_BINDING,\n DURABLE_SERVER_CLASS,\n durableServerSource,\n hostEntrySource,\n INDEX_HTML_PLACEHOLDER,\n NONCE_PLACEHOLDER,\n PAGE_ROUTES_PLACEHOLDER,\n type RenderEntryOptions,\n UI_MANIFEST_PLACEHOLDER,\n} from \"./entry.js\";\nimport {\n type DeployPreset,\n nitroPresetFor,\n runsOnWorkerd,\n syncTransportFor,\n} from \"./presets.js\";\n\nexport const SYNC_TRANSPORT_ENV = \"PARLOR_SYNC_TRANSPORT\";\nexport const MIGRATIONS_PLACEHOLDER = \"__PARLOR_MIGRATIONS__\";\nconst TRACED_DEPENDENCIES = [\"@electric-sql/pglite\", \"pg\"] as const;\nconst DEFAULT_COMPATIBILITY_DATE =\n \"2026-10-01\" satisfies NitroConfig[\"compatibilityDate\"];\n\nexport interface ServerBuildOptions {\n readonly preset: DeployPreset;\n readonly basePath?: string | undefined;\n readonly compatibilityDate?: NitroConfig[\"compatibilityDate\"] | undefined;\n /** The server render module `buildRender` wrote, for an app with `web.ssr`. */\n readonly render?: string | undefined;\n}\n\nexport interface ServerBuildResult {\n readonly rootDir: string;\n readonly outputDir: string;\n readonly preset: DeployPreset;\n readonly syncTransport: \"sse\" | \"poll\";\n}\n\nexport function hostRootDir(projectRoot: string): string {\n return join(generatedDir(projectRoot), \"nitro\");\n}\n\nfunction pageRoutesSource(manifest: Pick<UiManifest, \"routes\"> | undefined): string {\n return `[${(manifest?.routes ?? []).map((route) => String(pagePattern(route.path))).join(\", \")}]`;\n}\n\n/**\n * The entry sets the policy on the documents it serves itself, so these cover only the static\n * files: a rule matching every path would also override the app's own responses.\n */\nasync function staticFileRules(\n webDir: string,\n headers: Record<string, string>,\n ignored: readonly string[],\n): Promise<NonNullable<NitroConfig[\"routeRules\"]>> {\n const entries = await readdir(webDir, { withFileTypes: true }).catch(() => []);\n const rules: NonNullable<NitroConfig[\"routeRules\"]> = {};\n for (const entry of entries) {\n if (ignored.includes(entry.name)) continue;\n rules[entry.isDirectory() ? `/${entry.name}/**` : `/${entry.name}`] = { headers };\n if (entry.name === \"index.html\") rules[\"/\"] = { headers };\n }\n return rules;\n}\n\nexport async function buildServer(\n { config, rootDir }: LoadedConfig,\n options: ServerBuildOptions,\n): Promise<ServerBuildResult> {\n const hostRoot = hostRootDir(rootDir);\n const basePath = options.basePath ?? \"/_parlor\";\n const syncTransport = config.server.sync?.transport ?? syncTransportFor(options.preset);\n const indexHtml = await readFile(join(webOutDir(rootDir), \"index.html\"), \"utf8\").catch(\n () => \"\",\n );\n const manifest = await readFile(\n join(generatedDir(rootDir), UI_MANIFEST_FILE),\n \"utf8\",\n ).then(\n (text) => JSON.parse(text) as UiManifest,\n () => undefined,\n );\n const policy = appCsp(config, {});\n const contentSecurityPolicy = serializeCsp(policy);\n const render: RenderEntryOptions | undefined = options.render\n ? {\n module: options.render,\n contentSecurityPolicy: serializeCsp(\n extendCsp(policy, { \"script-src\": [`'nonce-${NONCE_PLACEHOLDER}'`] }),\n ),\n }\n : undefined;\n\n // With server rendering, every document goes through the entry, `/` included.\n const ignoredAssets = render ? [\"index.html\"] : [];\n\n await mkdir(hostRoot, { recursive: true });\n const serverEntry = join(rootDir, config.server.entry);\n const entryPath = join(hostRoot, \"entry.mjs\");\n const cloudflare =\n options.preset === \"cloudflare-durable\"\n ? await prepareDurable({ config, rootDir }, hostRoot, serverEntry)\n : undefined;\n await writeFile(\n entryPath,\n cloudflare\n ? cloudflareEntrySource({\n basePath,\n contentSecurityPolicy,\n render,\n locationHint: config.deploy.cloudflare?.locationHint,\n })\n : hostEntrySource({ serverEntry, basePath, contentSecurityPolicy, render }),\n );\n await writeFile(join(hostRoot, \".gitignore\"), \"*\\n\");\n\n const nitro = await createNitro({\n rootDir: hostRoot,\n preset: nitroPresetFor(options.preset),\n serverEntry: entryPath,\n ...(cloudflare ? { cloudflare: cloudflare.nitro } : {}),\n compatibilityDate: options.compatibilityDate ?? DEFAULT_COMPATIBILITY_DATE,\n publicAssets: [\n {\n dir: webOutDir(rootDir),\n baseURL: \"/\",\n fallthrough: true,\n ...(render\n ? { ignore: ignoredAssets.map((name) => join(webOutDir(rootDir), name)) }\n : {}),\n },\n ],\n routeRules: await staticFileRules(\n webOutDir(rootDir),\n { \"content-security-policy\": contentSecurityPolicy },\n ignoredAssets,\n ),\n traceDeps: [...TRACED_DEPENDENCIES],\n hooks: {\n \"rollup:before\": (nitroBuild, bundle) => {\n keepJsonOutOfChunkGroups(bundle);\n labelChunkGroups(bundle);\n if (runsOnWorkerd(options.preset)) importRequiredBuiltins(nitroBuild, bundle);\n },\n },\n replace: {\n [INDEX_HTML_PLACEHOLDER]: JSON.stringify(indexHtml),\n [UI_MANIFEST_PLACEHOLDER]: manifest ? JSON.stringify(manifest) : \"undefined\",\n [PAGE_ROUTES_PLACEHOLDER]: pageRoutesSource(manifest),\n [`process.env.${SYNC_TRANSPORT_ENV}`]: JSON.stringify(syncTransport),\n ...(cloudflare ? { [MIGRATIONS_PLACEHOLDER]: cloudflare.migrations } : {}),\n ...Object.fromEntries(\n Object.entries(appServerEnv(config)).map(([name, value]) => [\n `process.env.${name}`,\n JSON.stringify(value),\n ]),\n ),\n },\n });\n await prepare(nitro);\n await copyPublicAssets(nitro);\n await build(nitro);\n await nitro.close();\n\n return {\n rootDir: hostRoot,\n outputDir: nitro.options.output.dir,\n preset: options.preset,\n syncTransport,\n };\n}\n\ntype CloudflareOptions = NonNullable<NitroConfig[\"cloudflare\"]>;\ntype WranglerConfig = NonNullable<CloudflareOptions[\"wrangler\"]>;\n\ninterface DurableBuild {\n readonly nitro: CloudflareOptions;\n readonly migrations: string;\n}\n\n/** `app.id` is reverse-DNS lowercase alphanumerics, so only its dots need replacing. */\nfunction workerName(appId: string): string {\n return appId.replaceAll(\".\", \"-\").slice(0, 63);\n}\n\nfunction embeddedMigrations(rootDir: string, folder: string): string {\n const absolute = join(rootDir, folder);\n if (!existsSync(join(absolute, \"meta\", \"_journal.json\"))) return \"undefined\";\n return JSON.stringify({ [folder]: readMigrationFiles({ migrationsFolder: absolute }) });\n}\n\n/** The bundler's view: a node_modules lookup from the project, never NODE_PATH. */\nfunction installed(rootDir: string, name: string): boolean {\n for (let dir = rootDir; ; dir = dirname(dir)) {\n if (existsSync(join(dir, \"node_modules\", name, \"package.json\"))) return true;\n if (dirname(dir) === dir) return false;\n }\n}\n\n/**\n * Wrangler applies Durable Object migrations as an append-only log, after the last tag a\n * deployment applied. An app with its own migrations lists ours where it first deployed.\n */\nexport function withServerMigration(\n migrations: NonNullable<WranglerConfig[\"migrations\"]>,\n): NonNullable<WranglerConfig[\"migrations\"]> {\n const declared = migrations.some((migration) =>\n [migration.new_classes, migration.new_sqlite_classes].some((classes) =>\n classes?.includes(DURABLE_SERVER_CLASS),\n ),\n );\n if (declared) return migrations;\n return [\n ...migrations,\n { tag: \"parlor-server-v1\", new_sqlite_classes: [DURABLE_SERVER_CLASS] },\n ];\n}\n\nfunction durableWranglerConfig(config: ParlorConfig): WranglerConfig {\n const own = (config.deploy.cloudflare?.wrangler ?? {}) as WranglerConfig;\n return {\n name: workerName(config.app.id),\n ...own,\n durable_objects: {\n bindings: [\n { name: DURABLE_SERVER_BINDING, class_name: DURABLE_SERVER_CLASS },\n ...(own.durable_objects?.bindings ?? []),\n ],\n },\n migrations: withServerMigration(own.migrations ?? []),\n };\n}\n\nexport interface UnavailableDurableObject {\n readonly binding: string;\n readonly className: string;\n}\n\nexport interface DevWranglerConfig {\n readonly wrangler: WranglerConfig;\n /** Classes the Worker itself would define: no Worker code runs in development. */\n readonly unavailable: readonly UnavailableDurableObject[];\n}\n\n/** The bindings a cloudflare-durable build declares, as Wrangler's `getPlatformProxy()` reads them. */\nexport function devWranglerConfig(\n config: ParlorConfig,\n compatibilityDate: string = DEFAULT_COMPATIBILITY_DATE,\n): DevWranglerConfig {\n const {\n main: _main,\n assets: _assets,\n migrations: _migrations,\n durable_objects: durableObjects,\n ...production\n } = durableWranglerConfig(config);\n const bindings = durableObjects?.bindings ?? [];\n const ownClass = (binding: (typeof bindings)[number]) =>\n !binding.script_name || binding.script_name === production.name;\n return {\n wrangler: {\n ...production,\n compatibility_date: production.compatibility_date ?? compatibilityDate,\n compatibility_flags: [\n ...new Set([...(production.compatibility_flags ?? []), \"nodejs_compat\"]),\n ],\n durable_objects: { bindings: bindings.filter((binding) => !ownClass(binding)) },\n },\n unavailable: bindings\n .filter(ownClass)\n .map((binding) => ({ binding: binding.name, className: binding.class_name })),\n };\n}\n\nasync function prepareDurable(\n { config, rootDir }: Pick<LoadedConfig, \"config\" | \"rootDir\">,\n hostRoot: string,\n serverEntry: string,\n): Promise<DurableBuild> {\n const workerExports = config.deploy.cloudflare?.exports;\n const workerExportsPath = workerExports ? join(rootDir, workerExports) : undefined;\n if (workerExportsPath && !existsSync(workerExportsPath)) {\n throw new ConfigError(\n `deploy.cloudflare.exports names ${workerExports}, which does not exist in ${rootDir}`,\n );\n }\n const exportsPath = join(hostRoot, \"exports.cloudflare.mjs\");\n await writeFile(\n exportsPath,\n durableServerSource({\n serverEntry,\n connectionScopes: installed(rootDir, \"@parlor/data\"),\n workerExports: workerExportsPath,\n }),\n );\n return {\n migrations: embeddedMigrations(rootDir, config.database.migrations),\n nitro: {\n exports: exportsPath,\n deployConfig: true,\n nodeCompat: true,\n wrangler: durableWranglerConfig(config),\n },\n };\n}\n\n/**\n * The CLI of the nitro this package builds with, for `nitro deploy`. Nitro ships it as a\n * `bin`, not an export, so it is found through nitro's own manifest.\n */\nexport function nitroCli(): string {\n const manifest = createRequire(import.meta.url).resolve(\"nitro/package.json\");\n const { bin } = JSON.parse(readFileSync(manifest, \"utf8\")) as {\n readonly bin?: string | Readonly<Record<string, string>>;\n };\n const entry = typeof bin === \"string\" ? bin : bin?.nitro;\n if (!entry) throw new Error(`${manifest} names no nitro CLI.`);\n return join(dirname(manifest), entry);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AAClF,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,GAGb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG9E,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EAEvB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,cAAc,EACd,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAC1D,oGAAoG;AACpG,MAAM,CA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,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC;IACzD,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,sBAAsB,CAAC,CAAC;IAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { existsSync, readFileSync } from \"node:fs\";\nimport { mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join } from \"node:path\";\n\nimport { pagePattern, UI_MANIFEST_FILE, type UiManifest } from \"@parlor/agent-ui\";\nimport {\n appServerEnv,\n ConfigError,\n generatedDir,\n type LoadedConfig,\n type ParlorConfig,\n} from \"@parlor/config\";\nimport { appCsp, extendCsp, serializeCsp, webOutDir } from \"@parlor/shell-web\";\nimport { readMigrationFiles } from \"drizzle-orm/migrator\";\nimport { build, copyPublicAssets, createNitro, prepare } from \"nitro/builder\";\nimport type { NitroConfig } from \"nitro/types\";\n\nimport {\n importRequiredBuiltins,\n keepJsonOutOfChunkGroups,\n labelChunkGroups,\n} from \"./bundle.js\";\nimport {\n cloudflareEntrySource,\n DURABLE_SERVER_BINDING,\n DURABLE_SERVER_CLASS,\n durableServerSource,\n hostEntrySource,\n INDEX_HTML_PLACEHOLDER,\n NONCE_PLACEHOLDER,\n PAGE_ROUTES_PLACEHOLDER,\n type RenderEntryOptions,\n UI_MANIFEST_PLACEHOLDER,\n} from \"./entry.js\";\nimport {\n type DeployPreset,\n nitroPresetFor,\n runsOnWorkerd,\n syncTransportFor,\n} from \"./presets.js\";\n\nexport const SYNC_TRANSPORT_ENV = \"PARLOR_SYNC_TRANSPORT\";\n/** Names one `parlor build`, so a client can tell a deploy happened (`@parlor/server` reads it). */\nexport const BUILD_ID_ENV = \"PARLOR_BUILD_ID\";\n\nconst buildId = () => `${Date.now().toString(36)}-${crypto.randomUUID().slice(0, 8)}`;\nexport const MIGRATIONS_PLACEHOLDER = \"__PARLOR_MIGRATIONS__\";\nconst TRACED_DEPENDENCIES = [\"@electric-sql/pglite\", \"pg\"] as const;\nconst DEFAULT_COMPATIBILITY_DATE =\n \"2026-10-01\" satisfies NitroConfig[\"compatibilityDate\"];\n\nexport interface ServerBuildOptions {\n readonly preset: DeployPreset;\n readonly basePath?: string | undefined;\n readonly compatibilityDate?: NitroConfig[\"compatibilityDate\"] | undefined;\n /** The server render module `buildRender` wrote, for an app with `web.ssr`. */\n readonly render?: string | undefined;\n}\n\nexport interface ServerBuildResult {\n readonly rootDir: string;\n readonly outputDir: string;\n readonly preset: DeployPreset;\n readonly syncTransport: \"sse\" | \"poll\";\n}\n\nexport function hostRootDir(projectRoot: string): string {\n return join(generatedDir(projectRoot), \"nitro\");\n}\n\nfunction pageRoutesSource(manifest: Pick<UiManifest, \"routes\"> | undefined): string {\n return `[${(manifest?.routes ?? []).map((route) => String(pagePattern(route.path))).join(\", \")}]`;\n}\n\n/**\n * The entry sets the policy on the documents it serves itself, so these cover only the static\n * files: a rule matching every path would also override the app's own responses.\n */\nasync function staticFileRules(\n webDir: string,\n headers: Record<string, string>,\n ignored: readonly string[],\n): Promise<NonNullable<NitroConfig[\"routeRules\"]>> {\n const entries = await readdir(webDir, { withFileTypes: true }).catch(() => []);\n const rules: NonNullable<NitroConfig[\"routeRules\"]> = {};\n for (const entry of entries) {\n if (ignored.includes(entry.name)) continue;\n rules[entry.isDirectory() ? `/${entry.name}/**` : `/${entry.name}`] = { headers };\n if (entry.name === \"index.html\") rules[\"/\"] = { headers };\n }\n return rules;\n}\n\nexport async function buildServer(\n { config, rootDir }: LoadedConfig,\n options: ServerBuildOptions,\n): Promise<ServerBuildResult> {\n const hostRoot = hostRootDir(rootDir);\n const basePath = options.basePath ?? \"/_parlor\";\n const syncTransport = config.server.sync?.transport ?? syncTransportFor(options.preset);\n const indexHtml = await readFile(join(webOutDir(rootDir), \"index.html\"), \"utf8\").catch(\n () => \"\",\n );\n const manifest = await readFile(\n join(generatedDir(rootDir), UI_MANIFEST_FILE),\n \"utf8\",\n ).then(\n (text) => JSON.parse(text) as UiManifest,\n () => undefined,\n );\n const policy = appCsp(config, {});\n const contentSecurityPolicy = serializeCsp(policy);\n const render: RenderEntryOptions | undefined = options.render\n ? {\n module: options.render,\n contentSecurityPolicy: serializeCsp(\n extendCsp(policy, { \"script-src\": [`'nonce-${NONCE_PLACEHOLDER}'`] }),\n ),\n }\n : undefined;\n\n // With server rendering, every document goes through the entry, `/` included.\n const ignoredAssets = render ? [\"index.html\"] : [];\n\n await mkdir(hostRoot, { recursive: true });\n const serverEntry = join(rootDir, config.server.entry);\n const entryPath = join(hostRoot, \"entry.mjs\");\n const cloudflare =\n options.preset === \"cloudflare-durable\"\n ? await prepareDurable({ config, rootDir }, hostRoot, serverEntry)\n : undefined;\n await writeFile(\n entryPath,\n cloudflare\n ? cloudflareEntrySource({\n basePath,\n contentSecurityPolicy,\n render,\n locationHint: config.deploy.cloudflare?.locationHint,\n })\n : hostEntrySource({ serverEntry, basePath, contentSecurityPolicy, render }),\n );\n await writeFile(join(hostRoot, \".gitignore\"), \"*\\n\");\n\n const nitro = await createNitro({\n rootDir: hostRoot,\n preset: nitroPresetFor(options.preset),\n serverEntry: entryPath,\n ...(cloudflare ? { cloudflare: cloudflare.nitro } : {}),\n compatibilityDate: options.compatibilityDate ?? DEFAULT_COMPATIBILITY_DATE,\n publicAssets: [\n {\n dir: webOutDir(rootDir),\n baseURL: \"/\",\n fallthrough: true,\n ...(render\n ? { ignore: ignoredAssets.map((name) => join(webOutDir(rootDir), name)) }\n : {}),\n },\n ],\n routeRules: await staticFileRules(\n webOutDir(rootDir),\n { \"content-security-policy\": contentSecurityPolicy },\n ignoredAssets,\n ),\n traceDeps: [...TRACED_DEPENDENCIES],\n hooks: {\n \"rollup:before\": (nitroBuild, bundle) => {\n keepJsonOutOfChunkGroups(bundle);\n labelChunkGroups(bundle);\n if (runsOnWorkerd(options.preset)) importRequiredBuiltins(nitroBuild, bundle);\n },\n },\n replace: {\n [INDEX_HTML_PLACEHOLDER]: JSON.stringify(indexHtml),\n [UI_MANIFEST_PLACEHOLDER]: manifest ? JSON.stringify(manifest) : \"undefined\",\n [PAGE_ROUTES_PLACEHOLDER]: pageRoutesSource(manifest),\n [`process.env.${SYNC_TRANSPORT_ENV}`]: JSON.stringify(syncTransport),\n [`process.env.${BUILD_ID_ENV}`]: JSON.stringify(buildId()),\n ...(cloudflare ? { [MIGRATIONS_PLACEHOLDER]: cloudflare.migrations } : {}),\n ...Object.fromEntries(\n Object.entries(appServerEnv(config)).map(([name, value]) => [\n `process.env.${name}`,\n JSON.stringify(value),\n ]),\n ),\n },\n });\n await prepare(nitro);\n await copyPublicAssets(nitro);\n await build(nitro);\n await nitro.close();\n\n return {\n rootDir: hostRoot,\n outputDir: nitro.options.output.dir,\n preset: options.preset,\n syncTransport,\n };\n}\n\ntype CloudflareOptions = NonNullable<NitroConfig[\"cloudflare\"]>;\ntype WranglerConfig = NonNullable<CloudflareOptions[\"wrangler\"]>;\n\ninterface DurableBuild {\n readonly nitro: CloudflareOptions;\n readonly migrations: string;\n}\n\n/** `app.id` is reverse-DNS lowercase alphanumerics, so only its dots need replacing. */\nfunction workerName(appId: string): string {\n return appId.replaceAll(\".\", \"-\").slice(0, 63);\n}\n\nfunction embeddedMigrations(rootDir: string, folder: string): string {\n const absolute = join(rootDir, folder);\n if (!existsSync(join(absolute, \"meta\", \"_journal.json\"))) return \"undefined\";\n return JSON.stringify({ [folder]: readMigrationFiles({ migrationsFolder: absolute }) });\n}\n\n/** The bundler's view: a node_modules lookup from the project, never NODE_PATH. */\nfunction installed(rootDir: string, name: string): boolean {\n for (let dir = rootDir; ; dir = dirname(dir)) {\n if (existsSync(join(dir, \"node_modules\", name, \"package.json\"))) return true;\n if (dirname(dir) === dir) return false;\n }\n}\n\n/**\n * Wrangler applies Durable Object migrations as an append-only log, after the last tag a\n * deployment applied. An app with its own migrations lists ours where it first deployed.\n */\nexport function withServerMigration(\n migrations: NonNullable<WranglerConfig[\"migrations\"]>,\n): NonNullable<WranglerConfig[\"migrations\"]> {\n const declared = migrations.some((migration) =>\n [migration.new_classes, migration.new_sqlite_classes].some((classes) =>\n classes?.includes(DURABLE_SERVER_CLASS),\n ),\n );\n if (declared) return migrations;\n return [\n ...migrations,\n { tag: \"parlor-server-v1\", new_sqlite_classes: [DURABLE_SERVER_CLASS] },\n ];\n}\n\nfunction durableWranglerConfig(config: ParlorConfig): WranglerConfig {\n const own = (config.deploy.cloudflare?.wrangler ?? {}) as WranglerConfig;\n return {\n name: workerName(config.app.id),\n ...own,\n durable_objects: {\n bindings: [\n { name: DURABLE_SERVER_BINDING, class_name: DURABLE_SERVER_CLASS },\n ...(own.durable_objects?.bindings ?? []),\n ],\n },\n migrations: withServerMigration(own.migrations ?? []),\n };\n}\n\nexport interface UnavailableDurableObject {\n readonly binding: string;\n readonly className: string;\n}\n\nexport interface DevWranglerConfig {\n readonly wrangler: WranglerConfig;\n /** Classes the Worker itself would define: no Worker code runs in development. */\n readonly unavailable: readonly UnavailableDurableObject[];\n}\n\n/** The bindings a cloudflare-durable build declares, as Wrangler's `getPlatformProxy()` reads them. */\nexport function devWranglerConfig(\n config: ParlorConfig,\n compatibilityDate: string = DEFAULT_COMPATIBILITY_DATE,\n): DevWranglerConfig {\n const {\n main: _main,\n assets: _assets,\n migrations: _migrations,\n durable_objects: durableObjects,\n ...production\n } = durableWranglerConfig(config);\n const bindings = durableObjects?.bindings ?? [];\n const ownClass = (binding: (typeof bindings)[number]) =>\n !binding.script_name || binding.script_name === production.name;\n return {\n wrangler: {\n ...production,\n compatibility_date: production.compatibility_date ?? compatibilityDate,\n compatibility_flags: [\n ...new Set([...(production.compatibility_flags ?? []), \"nodejs_compat\"]),\n ],\n durable_objects: { bindings: bindings.filter((binding) => !ownClass(binding)) },\n },\n unavailable: bindings\n .filter(ownClass)\n .map((binding) => ({ binding: binding.name, className: binding.class_name })),\n };\n}\n\nasync function prepareDurable(\n { config, rootDir }: Pick<LoadedConfig, \"config\" | \"rootDir\">,\n hostRoot: string,\n serverEntry: string,\n): Promise<DurableBuild> {\n const workerExports = config.deploy.cloudflare?.exports;\n const workerExportsPath = workerExports ? join(rootDir, workerExports) : undefined;\n if (workerExportsPath && !existsSync(workerExportsPath)) {\n throw new ConfigError(\n `deploy.cloudflare.exports names ${workerExports}, which does not exist in ${rootDir}`,\n );\n }\n const exportsPath = join(hostRoot, \"exports.cloudflare.mjs\");\n await writeFile(\n exportsPath,\n durableServerSource({\n serverEntry,\n connectionScopes: installed(rootDir, \"@parlor/data\"),\n workerExports: workerExportsPath,\n }),\n );\n return {\n migrations: embeddedMigrations(rootDir, config.database.migrations),\n nitro: {\n exports: exportsPath,\n deployConfig: true,\n nodeCompat: true,\n wrangler: durableWranglerConfig(config),\n },\n };\n}\n\n/**\n * The CLI of the nitro this package builds with, for `nitro deploy`. Nitro ships it as a\n * `bin`, not an export, so it is found through nitro's own manifest.\n */\nexport function nitroCli(): string {\n const manifest = createRequire(import.meta.url).resolve(\"nitro/package.json\");\n const { bin } = JSON.parse(readFileSync(manifest, \"utf8\")) as {\n readonly bin?: string | Readonly<Record<string, string>>;\n };\n const entry = typeof bin === \"string\" ? bin : bin?.nitro;\n if (!entry) throw new Error(`${manifest} names no nitro CLI.`);\n return join(dirname(manifest), entry);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parlor/host",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"homepage": "https://cychien.github.io/parlor",
|
|
5
5
|
"bugs": "https://github.com/cychien/parlor/issues",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"drizzle-orm": "^0.45.4",
|
|
24
24
|
"nitro": "3.0.260903-beta",
|
|
25
|
-
"@parlor/agent-ui": "0.4.
|
|
26
|
-
"@parlor/config": "0.4.
|
|
27
|
-
"@parlor/shell-web": "0.4.
|
|
25
|
+
"@parlor/agent-ui": "0.4.3",
|
|
26
|
+
"@parlor/config": "0.4.3",
|
|
27
|
+
"@parlor/shell-web": "0.4.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@tanstack/react-query": "^5.104.1",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"typescript": "^7.0.2",
|
|
36
36
|
"vitest": "^5.0.3",
|
|
37
37
|
"wrangler": "^4.152.0",
|
|
38
|
-
"@parlor/core": "0.4.
|
|
39
|
-
"@parlor/server": "0.4.
|
|
40
|
-
"@parlor/data": "0.4.
|
|
41
|
-
"@parlor/client": "0.4.
|
|
38
|
+
"@parlor/core": "0.4.3",
|
|
39
|
+
"@parlor/server": "0.4.3",
|
|
40
|
+
"@parlor/data": "0.4.3",
|
|
41
|
+
"@parlor/client": "0.4.3"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc -p tsconfig.json",
|