@parlor/host 0.1.0 → 0.2.0
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 +23 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +165 -17
- package/dist/build.js.map +1 -1
- package/dist/bundle.d.ts +21 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +77 -0
- package/dist/bundle.js.map +1 -0
- package/dist/entry.d.ts +31 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +110 -15
- package/dist/entry.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +7 -1
- package/dist/presets.d.ts.map +1 -1
- package/dist/presets.js +28 -1
- package/dist/presets.js.map +1 -1
- package/package.json +14 -7
package/dist/build.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { type LoadedConfig } from "@parlor/config";
|
|
1
|
+
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
|
+
export declare const MIGRATIONS_PLACEHOLDER = "__PARLOR_MIGRATIONS__";
|
|
5
6
|
export interface ServerBuildOptions {
|
|
6
7
|
readonly preset: DeployPreset;
|
|
7
8
|
readonly basePath?: string | undefined;
|
|
8
9
|
readonly compatibilityDate?: NitroConfig["compatibilityDate"] | undefined;
|
|
10
|
+
/** The server render module `buildRender` wrote, for an app with `web.ssr`. */
|
|
11
|
+
readonly render?: string | undefined;
|
|
9
12
|
}
|
|
10
13
|
export interface ServerBuildResult {
|
|
11
14
|
readonly rootDir: string;
|
|
@@ -15,4 +18,23 @@ export interface ServerBuildResult {
|
|
|
15
18
|
}
|
|
16
19
|
export declare function hostRootDir(projectRoot: string): string;
|
|
17
20
|
export declare function buildServer({ config, rootDir }: LoadedConfig, options: ServerBuildOptions): Promise<ServerBuildResult>;
|
|
21
|
+
type CloudflareOptions = NonNullable<NitroConfig["cloudflare"]>;
|
|
22
|
+
type WranglerConfig = NonNullable<CloudflareOptions["wrangler"]>;
|
|
23
|
+
/**
|
|
24
|
+
* Wrangler applies Durable Object migrations as an append-only log, after the last tag a
|
|
25
|
+
* deployment applied. An app with its own migrations lists ours where it first deployed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withServerMigration(migrations: NonNullable<WranglerConfig["migrations"]>): NonNullable<WranglerConfig["migrations"]>;
|
|
28
|
+
export interface UnavailableDurableObject {
|
|
29
|
+
readonly binding: string;
|
|
30
|
+
readonly className: string;
|
|
31
|
+
}
|
|
32
|
+
export interface DevWranglerConfig {
|
|
33
|
+
readonly wrangler: WranglerConfig;
|
|
34
|
+
/** Classes the Worker itself would define: no Worker code runs in development. */
|
|
35
|
+
readonly unavailable: readonly UnavailableDurableObject[];
|
|
36
|
+
}
|
|
37
|
+
/** The bindings a cloudflare-durable build declares, as Wrangler's `getPlatformProxy()` reads them. */
|
|
38
|
+
export declare function devWranglerConfig(config: ParlorConfig, compatibilityDate?: string): DevWranglerConfig;
|
|
39
|
+
export {};
|
|
18
40
|
//# sourceMappingURL=build.d.ts.map
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAKA,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;A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AED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,kFAAkF;IAClF,QAAQ,CAAC,WAAW,EAAE,SAAS,wBAAwB,EAAE,CAAC;CAC3D;AAED,uGAAuG;AACvG,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,EACpB,iBAAiB,GAAE,MAAmC,GACrD,iBAAiB,CAwBnB"}
|
package/dist/build.js
CHANGED
|
@@ -1,42 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { mkdir, readdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { pagePattern, UI_MANIFEST_FILE } from "@parlor/agent-ui";
|
|
5
|
+
import { appServerEnv, ConfigError, generatedDir, } from "@parlor/config";
|
|
6
|
+
import { appCsp, extendCsp, serializeCsp, webOutDir } from "@parlor/shell-web";
|
|
7
|
+
import { readMigrationFiles } from "drizzle-orm/migrator";
|
|
6
8
|
import { build, copyPublicAssets, createNitro, prepare } from "nitro/builder";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
+
import { importRequiredBuiltins, keepJsonOutOfChunkGroups, labelChunkGroups, } from "./bundle.js";
|
|
10
|
+
import { cloudflareEntrySource, DURABLE_SERVER_BINDING, DURABLE_SERVER_CLASS, durableServerSource, hostEntrySource, INDEX_HTML_PLACEHOLDER, NONCE_PLACEHOLDER, PAGE_ROUTES_PLACEHOLDER, UI_MANIFEST_PLACEHOLDER, } from "./entry.js";
|
|
11
|
+
import { nitroPresetFor, runsOnWorkerd, syncTransportFor, } from "./presets.js";
|
|
9
12
|
export const SYNC_TRANSPORT_ENV = "PARLOR_SYNC_TRANSPORT";
|
|
13
|
+
export const MIGRATIONS_PLACEHOLDER = "__PARLOR_MIGRATIONS__";
|
|
10
14
|
const TRACED_DEPENDENCIES = ["@electric-sql/pglite", "pg"];
|
|
11
15
|
const DEFAULT_COMPATIBILITY_DATE = "2026-10-01";
|
|
12
16
|
export function hostRootDir(projectRoot) {
|
|
13
|
-
return join(projectRoot,
|
|
17
|
+
return join(generatedDir(projectRoot), "nitro");
|
|
18
|
+
}
|
|
19
|
+
function pageRoutesSource(manifest) {
|
|
20
|
+
return `[${(manifest?.routes ?? []).map((route) => String(pagePattern(route.path))).join(", ")}]`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The entry sets the policy on the documents it serves itself, so these cover only the static
|
|
24
|
+
* files: a rule matching every path would also override the app's own responses.
|
|
25
|
+
*/
|
|
26
|
+
async function staticFileRules(webDir, headers, ignored) {
|
|
27
|
+
const entries = await readdir(webDir, { withFileTypes: true }).catch(() => []);
|
|
28
|
+
const rules = {};
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
if (ignored.includes(entry.name))
|
|
31
|
+
continue;
|
|
32
|
+
rules[entry.isDirectory() ? `/${entry.name}/**` : `/${entry.name}`] = { headers };
|
|
33
|
+
if (entry.name === "index.html")
|
|
34
|
+
rules["/"] = { headers };
|
|
35
|
+
}
|
|
36
|
+
return rules;
|
|
14
37
|
}
|
|
15
38
|
export async function buildServer({ config, rootDir }, options) {
|
|
16
39
|
const hostRoot = hostRootDir(rootDir);
|
|
17
40
|
const basePath = options.basePath ?? "/_parlor";
|
|
18
41
|
const syncTransport = config.server.sync?.transport ?? syncTransportFor(options.preset);
|
|
19
42
|
const indexHtml = await readFile(join(webOutDir(rootDir), "index.html"), "utf8").catch(() => "");
|
|
20
|
-
const
|
|
43
|
+
const manifest = await readFile(join(generatedDir(rootDir), UI_MANIFEST_FILE), "utf8").then((text) => JSON.parse(text), () => undefined);
|
|
44
|
+
const policy = appCsp(config, {});
|
|
45
|
+
const contentSecurityPolicy = serializeCsp(policy);
|
|
46
|
+
const render = options.render
|
|
47
|
+
? {
|
|
48
|
+
module: options.render,
|
|
49
|
+
contentSecurityPolicy: serializeCsp(extendCsp(policy, { "script-src": [`'nonce-${NONCE_PLACEHOLDER}'`] })),
|
|
50
|
+
}
|
|
51
|
+
: undefined;
|
|
52
|
+
// With server rendering, every document goes through the entry, `/` included.
|
|
53
|
+
const ignoredAssets = render ? ["index.html"] : [];
|
|
21
54
|
await mkdir(hostRoot, { recursive: true });
|
|
55
|
+
const serverEntry = join(rootDir, config.server.entry);
|
|
22
56
|
const entryPath = join(hostRoot, "entry.mjs");
|
|
23
|
-
|
|
57
|
+
const cloudflare = options.preset === "cloudflare-durable"
|
|
58
|
+
? await prepareDurable({ config, rootDir }, hostRoot, serverEntry)
|
|
59
|
+
: undefined;
|
|
60
|
+
await writeFile(entryPath, cloudflare
|
|
61
|
+
? cloudflareEntrySource({
|
|
62
|
+
basePath,
|
|
63
|
+
contentSecurityPolicy,
|
|
64
|
+
render,
|
|
65
|
+
locationHint: config.deploy.cloudflare?.locationHint,
|
|
66
|
+
})
|
|
67
|
+
: hostEntrySource({ serverEntry, basePath, contentSecurityPolicy, render }));
|
|
24
68
|
await writeFile(join(hostRoot, ".gitignore"), "*\n");
|
|
25
69
|
const nitro = await createNitro({
|
|
26
70
|
rootDir: hostRoot,
|
|
27
|
-
preset: options.preset,
|
|
71
|
+
preset: nitroPresetFor(options.preset),
|
|
28
72
|
serverEntry: entryPath,
|
|
73
|
+
...(cloudflare ? { cloudflare: cloudflare.nitro } : {}),
|
|
29
74
|
compatibilityDate: options.compatibilityDate ?? DEFAULT_COMPATIBILITY_DATE,
|
|
30
|
-
publicAssets: [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
75
|
+
publicAssets: [
|
|
76
|
+
{
|
|
77
|
+
dir: webOutDir(rootDir),
|
|
78
|
+
baseURL: "/",
|
|
79
|
+
fallthrough: true,
|
|
80
|
+
...(render
|
|
81
|
+
? { ignore: ignoredAssets.map((name) => join(webOutDir(rootDir), name)) }
|
|
82
|
+
: {}),
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
routeRules: await staticFileRules(webOutDir(rootDir), { "content-security-policy": contentSecurityPolicy }, ignoredAssets),
|
|
35
86
|
traceDeps: [...TRACED_DEPENDENCIES],
|
|
87
|
+
hooks: {
|
|
88
|
+
"rollup:before": (nitroBuild, bundle) => {
|
|
89
|
+
keepJsonOutOfChunkGroups(bundle);
|
|
90
|
+
labelChunkGroups(bundle);
|
|
91
|
+
if (runsOnWorkerd(options.preset))
|
|
92
|
+
importRequiredBuiltins(nitroBuild, bundle);
|
|
93
|
+
},
|
|
94
|
+
},
|
|
36
95
|
replace: {
|
|
37
96
|
[INDEX_HTML_PLACEHOLDER]: JSON.stringify(indexHtml),
|
|
38
|
-
[UI_MANIFEST_PLACEHOLDER]:
|
|
97
|
+
[UI_MANIFEST_PLACEHOLDER]: manifest ? JSON.stringify(manifest) : "undefined",
|
|
98
|
+
[PAGE_ROUTES_PLACEHOLDER]: pageRoutesSource(manifest),
|
|
39
99
|
[`process.env.${SYNC_TRANSPORT_ENV}`]: JSON.stringify(syncTransport),
|
|
100
|
+
...(cloudflare ? { [MIGRATIONS_PLACEHOLDER]: cloudflare.migrations } : {}),
|
|
40
101
|
...Object.fromEntries(Object.entries(appServerEnv(config)).map(([name, value]) => [
|
|
41
102
|
`process.env.${name}`,
|
|
42
103
|
JSON.stringify(value),
|
|
@@ -54,4 +115,91 @@ export async function buildServer({ config, rootDir }, options) {
|
|
|
54
115
|
syncTransport,
|
|
55
116
|
};
|
|
56
117
|
}
|
|
118
|
+
/** `app.id` is reverse-DNS lowercase alphanumerics, so only its dots need replacing. */
|
|
119
|
+
function workerName(appId) {
|
|
120
|
+
return appId.replaceAll(".", "-").slice(0, 63);
|
|
121
|
+
}
|
|
122
|
+
function embeddedMigrations(rootDir, folder) {
|
|
123
|
+
const absolute = join(rootDir, folder);
|
|
124
|
+
if (!existsSync(join(absolute, "meta", "_journal.json")))
|
|
125
|
+
return "undefined";
|
|
126
|
+
return JSON.stringify({ [folder]: readMigrationFiles({ migrationsFolder: absolute }) });
|
|
127
|
+
}
|
|
128
|
+
/** The bundler's view: a node_modules lookup from the project, never NODE_PATH. */
|
|
129
|
+
function installed(rootDir, name) {
|
|
130
|
+
for (let dir = rootDir;; dir = dirname(dir)) {
|
|
131
|
+
if (existsSync(join(dir, "node_modules", name, "package.json")))
|
|
132
|
+
return true;
|
|
133
|
+
if (dirname(dir) === dir)
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Wrangler applies Durable Object migrations as an append-only log, after the last tag a
|
|
139
|
+
* deployment applied. An app with its own migrations lists ours where it first deployed.
|
|
140
|
+
*/
|
|
141
|
+
export function withServerMigration(migrations) {
|
|
142
|
+
const declared = migrations.some((migration) => [migration.new_classes, migration.new_sqlite_classes].some((classes) => classes?.includes(DURABLE_SERVER_CLASS)));
|
|
143
|
+
if (declared)
|
|
144
|
+
return migrations;
|
|
145
|
+
return [
|
|
146
|
+
...migrations,
|
|
147
|
+
{ tag: "parlor-server-v1", new_sqlite_classes: [DURABLE_SERVER_CLASS] },
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
function durableWranglerConfig(config) {
|
|
151
|
+
const own = (config.deploy.cloudflare?.wrangler ?? {});
|
|
152
|
+
return {
|
|
153
|
+
name: workerName(config.app.id),
|
|
154
|
+
...own,
|
|
155
|
+
durable_objects: {
|
|
156
|
+
bindings: [
|
|
157
|
+
{ name: DURABLE_SERVER_BINDING, class_name: DURABLE_SERVER_CLASS },
|
|
158
|
+
...(own.durable_objects?.bindings ?? []),
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
migrations: withServerMigration(own.migrations ?? []),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/** The bindings a cloudflare-durable build declares, as Wrangler's `getPlatformProxy()` reads them. */
|
|
165
|
+
export function devWranglerConfig(config, compatibilityDate = DEFAULT_COMPATIBILITY_DATE) {
|
|
166
|
+
const { main: _main, assets: _assets, migrations: _migrations, durable_objects: durableObjects, ...production } = durableWranglerConfig(config);
|
|
167
|
+
const bindings = durableObjects?.bindings ?? [];
|
|
168
|
+
const ownClass = (binding) => !binding.script_name || binding.script_name === production.name;
|
|
169
|
+
return {
|
|
170
|
+
wrangler: {
|
|
171
|
+
...production,
|
|
172
|
+
compatibility_date: production.compatibility_date ?? compatibilityDate,
|
|
173
|
+
compatibility_flags: [
|
|
174
|
+
...new Set([...(production.compatibility_flags ?? []), "nodejs_compat"]),
|
|
175
|
+
],
|
|
176
|
+
durable_objects: { bindings: bindings.filter((binding) => !ownClass(binding)) },
|
|
177
|
+
},
|
|
178
|
+
unavailable: bindings
|
|
179
|
+
.filter(ownClass)
|
|
180
|
+
.map((binding) => ({ binding: binding.name, className: binding.class_name })),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
async function prepareDurable({ config, rootDir }, hostRoot, serverEntry) {
|
|
184
|
+
const workerExports = config.deploy.cloudflare?.exports;
|
|
185
|
+
const workerExportsPath = workerExports ? join(rootDir, workerExports) : undefined;
|
|
186
|
+
if (workerExportsPath && !existsSync(workerExportsPath)) {
|
|
187
|
+
throw new ConfigError(`deploy.cloudflare.exports names ${workerExports}, which does not exist in ${rootDir}`);
|
|
188
|
+
}
|
|
189
|
+
const exportsPath = join(hostRoot, "exports.cloudflare.mjs");
|
|
190
|
+
await writeFile(exportsPath, durableServerSource({
|
|
191
|
+
serverEntry,
|
|
192
|
+
connectionScopes: installed(rootDir, "@parlor/data"),
|
|
193
|
+
workerExports: workerExportsPath,
|
|
194
|
+
}));
|
|
195
|
+
return {
|
|
196
|
+
migrations: embeddedMigrations(rootDir, config.database.migrations),
|
|
197
|
+
nitro: {
|
|
198
|
+
exports: exportsPath,
|
|
199
|
+
deployConfig: true,
|
|
200
|
+
nodeCompat: true,
|
|
201
|
+
wrangler: durableWranglerConfig(config),
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
}
|
|
57
205
|
//#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BAAkB,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","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { mkdir, readdir, readFile, writeFile } from \"node:fs/promises\";\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"]}
|
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Nitro, NitroHooks } from "nitro/types";
|
|
2
|
+
type BundleConfig = Parameters<NitroHooks["rollup:before"]>[1];
|
|
3
|
+
/**
|
|
4
|
+
* Rolldown lists a JSON module's keys among the exports of the shared chunk it groups the
|
|
5
|
+
* module into, without defining them, when the module is imported lazily and the bundle has
|
|
6
|
+
* top-level await. The chunk then fails to load, so JSON stays out of Nitro's library chunks.
|
|
7
|
+
*/
|
|
8
|
+
export declare function keepJsonOutOfChunkGroups(config: BundleConfig): void;
|
|
9
|
+
/**
|
|
10
|
+
* Rolldown warns on every build that a chunk group named by a function has no label for its
|
|
11
|
+
* timing report, and Nitro names its library group that way.
|
|
12
|
+
*/
|
|
13
|
+
export declare function labelChunkGroups(config: BundleConfig): void;
|
|
14
|
+
/**
|
|
15
|
+
* workerd's `require` cannot load every built-in its `import` can, `node:process` among them,
|
|
16
|
+
* so a dependency's CommonJS `require` of a built-in becomes an import of it, as Wrangler's own
|
|
17
|
+
* bundler does.
|
|
18
|
+
*/
|
|
19
|
+
export declare function importRequiredBuiltins(nitro: Nitro, config: BundleConfig): void;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErD,KAAK,YAAY,GAAG,UAAU,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA0B/D;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAKnE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAI3D;AASD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CA8B/E"}
|
package/dist/bundle.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { isBuiltin } from "node:module";
|
|
2
|
+
const JSON_MODULE = /\.json(?:\?|$)/;
|
|
3
|
+
const REQUIRED_BUILTIN = "\0parlor:required:";
|
|
4
|
+
function matches(test, id) {
|
|
5
|
+
if (test === undefined)
|
|
6
|
+
return true;
|
|
7
|
+
return typeof test === "function" ? Boolean(test(id)) : test.test(id);
|
|
8
|
+
}
|
|
9
|
+
function chunkGroups(config) {
|
|
10
|
+
const splitting = config.output
|
|
11
|
+
?.codeSplitting;
|
|
12
|
+
if (typeof splitting !== "object" || splitting === null)
|
|
13
|
+
return [];
|
|
14
|
+
const { groups } = splitting;
|
|
15
|
+
return Array.isArray(groups) ? groups : [];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Rolldown lists a JSON module's keys among the exports of the shared chunk it groups the
|
|
19
|
+
* module into, without defining them, when the module is imported lazily and the bundle has
|
|
20
|
+
* top-level await. The chunk then fails to load, so JSON stays out of Nitro's library chunks.
|
|
21
|
+
*/
|
|
22
|
+
export function keepJsonOutOfChunkGroups(config) {
|
|
23
|
+
for (const group of chunkGroups(config)) {
|
|
24
|
+
const { test } = group;
|
|
25
|
+
group.test = (id) => !JSON_MODULE.test(id) && matches(test, id);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Rolldown warns on every build that a chunk group named by a function has no label for its
|
|
30
|
+
* timing report, and Nitro names its library group that way.
|
|
31
|
+
*/
|
|
32
|
+
export function labelChunkGroups(config) {
|
|
33
|
+
for (const group of chunkGroups(config)) {
|
|
34
|
+
if (typeof group.name === "function")
|
|
35
|
+
group.debugName ??= "libs";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** The Node built-ins the runtime provides itself, which the bundle leaves to it. */
|
|
39
|
+
function nativeBuiltins(nitro) {
|
|
40
|
+
return new Set(nitro.options.unenv.flatMap((preset) => preset.external ?? []).filter(isBuiltin));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* workerd's `require` cannot load every built-in its `import` can, `node:process` among them,
|
|
44
|
+
* so a dependency's CommonJS `require` of a built-in becomes an import of it, as Wrangler's own
|
|
45
|
+
* bundler does.
|
|
46
|
+
*/
|
|
47
|
+
export function importRequiredBuiltins(nitro, config) {
|
|
48
|
+
const native = nativeBuiltins(nitro);
|
|
49
|
+
const builtin = (id) => native.has(id) ? id : native.has(`node:${id}`) ? `node:${id}` : undefined;
|
|
50
|
+
if (Array.isArray(config.external)) {
|
|
51
|
+
config.external = config.external.filter((id) => typeof id !== "string" || builtin(id) === undefined);
|
|
52
|
+
}
|
|
53
|
+
config.plugins = [
|
|
54
|
+
{
|
|
55
|
+
name: "parlor:import-required-builtins",
|
|
56
|
+
resolveId: {
|
|
57
|
+
order: "pre",
|
|
58
|
+
handler(id, _importer, { kind }) {
|
|
59
|
+
const name = builtin(id);
|
|
60
|
+
if (name === undefined)
|
|
61
|
+
return undefined;
|
|
62
|
+
return kind === "require-call"
|
|
63
|
+
? `${REQUIRED_BUILTIN}${name}`
|
|
64
|
+
: { id, external: true };
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
load(id) {
|
|
68
|
+
if (!id.startsWith(REQUIRED_BUILTIN))
|
|
69
|
+
return undefined;
|
|
70
|
+
const name = JSON.stringify(id.slice(REQUIRED_BUILTIN.length));
|
|
71
|
+
return `import builtin from ${name};\nmodule.exports = builtin;\n`;
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
...(config.plugins ?? []),
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAcxC,MAAM,WAAW,GAAG,gBAAgB,CAAC;AACrC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAE9C,SAAS,OAAO,CAAC,IAA2B,EAAE,EAAU;IACtD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,WAAW,CAAC,MAAoB;IACvC,MAAM,SAAS,GAAa,MAAM,CAAC,MAAkD;QACnF,EAAE,aAAa,CAAC;IAClB,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACnE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAiC,CAAC;IACrD,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAuB,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAoB;IAC3D,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACxC,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QACvB,KAAK,CAAC,IAAI,GAAG,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D,CAAC;IACJ,CAAC;IACD,MAAM,CAAC,OAAO,GAAG;QACf;YACE,IAAI,EAAE,iCAAiC;YACvC,SAAS,EAAE;gBACT,KAAK,EAAE,KAAK;gBACZ,OAAO,CAAC,EAAU,EAAE,SAA6B,EAAE,EAAE,IAAI,EAAqB;oBAC5E,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;oBACzB,IAAI,IAAI,KAAK,SAAS;wBAAE,OAAO,SAAS,CAAC;oBACzC,OAAO,IAAI,KAAK,cAAc;wBAC5B,CAAC,CAAC,GAAG,gBAAgB,GAAG,IAAI,EAAE;wBAC9B,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBAC7B,CAAC;aACF;YACD,IAAI,CAAC,EAAU;gBACb,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC;oBAAE,OAAO,SAAS,CAAC;gBACvD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC/D,OAAO,uBAAuB,IAAI,gCAAgC,CAAC;YACrE,CAAC;SACF;QACD,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { isBuiltin } from \"node:module\";\n\nimport type { Nitro, NitroHooks } from \"nitro/types\";\n\ntype BundleConfig = Parameters<NitroHooks[\"rollup:before\"]>[1];\n\ntype ChunkTest = RegExp | ((id: string) => boolean | null | undefined);\n\ninterface ChunkGroup {\n test?: ChunkTest;\n name?: unknown;\n debugName?: string;\n}\n\nconst JSON_MODULE = /\\.json(?:\\?|$)/;\nconst REQUIRED_BUILTIN = \"\\0parlor:required:\";\n\nfunction matches(test: ChunkTest | undefined, id: string): boolean {\n if (test === undefined) return true;\n return typeof test === \"function\" ? Boolean(test(id)) : test.test(id);\n}\n\nfunction chunkGroups(config: BundleConfig): ChunkGroup[] {\n const splitting: unknown = (config.output as { codeSplitting?: unknown } | undefined)\n ?.codeSplitting;\n if (typeof splitting !== \"object\" || splitting === null) return [];\n const { groups } = splitting as { groups?: unknown };\n return Array.isArray(groups) ? (groups as ChunkGroup[]) : [];\n}\n\n/**\n * Rolldown lists a JSON module's keys among the exports of the shared chunk it groups the\n * module into, without defining them, when the module is imported lazily and the bundle has\n * top-level await. The chunk then fails to load, so JSON stays out of Nitro's library chunks.\n */\nexport function keepJsonOutOfChunkGroups(config: BundleConfig): void {\n for (const group of chunkGroups(config)) {\n const { test } = group;\n group.test = (id) => !JSON_MODULE.test(id) && matches(test, id);\n }\n}\n\n/**\n * Rolldown warns on every build that a chunk group named by a function has no label for its\n * timing report, and Nitro names its library group that way.\n */\nexport function labelChunkGroups(config: BundleConfig): void {\n for (const group of chunkGroups(config)) {\n if (typeof group.name === \"function\") group.debugName ??= \"libs\";\n }\n}\n\n/** The Node built-ins the runtime provides itself, which the bundle leaves to it. */\nfunction nativeBuiltins(nitro: Nitro): Set<string> {\n return new Set(\n nitro.options.unenv.flatMap((preset) => preset.external ?? []).filter(isBuiltin),\n );\n}\n\n/**\n * workerd's `require` cannot load every built-in its `import` can, `node:process` among them,\n * so a dependency's CommonJS `require` of a built-in becomes an import of it, as Wrangler's own\n * bundler does.\n */\nexport function importRequiredBuiltins(nitro: Nitro, config: BundleConfig): void {\n const native = nativeBuiltins(nitro);\n const builtin = (id: string) =>\n native.has(id) ? id : native.has(`node:${id}`) ? `node:${id}` : undefined;\n if (Array.isArray(config.external)) {\n config.external = config.external.filter(\n (id) => typeof id !== \"string\" || builtin(id) === undefined,\n );\n }\n config.plugins = [\n {\n name: \"parlor:import-required-builtins\",\n resolveId: {\n order: \"pre\",\n handler(id: string, _importer: string | undefined, { kind }: { kind?: string }) {\n const name = builtin(id);\n if (name === undefined) return undefined;\n return kind === \"require-call\"\n ? `${REQUIRED_BUILTIN}${name}`\n : { id, external: true };\n },\n },\n load(id: string) {\n if (!id.startsWith(REQUIRED_BUILTIN)) return undefined;\n const name = JSON.stringify(id.slice(REQUIRED_BUILTIN.length));\n return `import builtin from ${name};\\nmodule.exports = builtin;\\n`;\n },\n },\n ...(config.plugins ?? []),\n ];\n}\n"]}
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,8 +1,38 @@
|
|
|
1
|
+
export interface RenderEntryOptions {
|
|
2
|
+
/** The module `parlor build` built from `web.ssr`, exporting `render`. */
|
|
3
|
+
readonly module: string;
|
|
4
|
+
/** The page policy with `{nonce}` in `script-src`, replaced per response. */
|
|
5
|
+
readonly contentSecurityPolicy: string;
|
|
6
|
+
}
|
|
1
7
|
export interface EntryOptions {
|
|
2
8
|
readonly serverEntry: string;
|
|
3
9
|
readonly basePath: string;
|
|
10
|
+
readonly contentSecurityPolicy: string;
|
|
11
|
+
readonly render?: RenderEntryOptions | undefined;
|
|
4
12
|
}
|
|
13
|
+
export declare const NONCE_PLACEHOLDER = "{nonce}";
|
|
5
14
|
export declare const INDEX_HTML_PLACEHOLDER = "__PARLOR_INDEX_HTML__";
|
|
6
15
|
export declare const UI_MANIFEST_PLACEHOLDER = "__PARLOR_UI_MANIFEST__";
|
|
7
|
-
export declare
|
|
16
|
+
export declare const PAGE_ROUTES_PLACEHOLDER = "__PARLOR_PAGE_ROUTES__";
|
|
17
|
+
export declare const DURABLE_SERVER_BINDING = "PARLOR_SERVER";
|
|
18
|
+
export declare const DURABLE_SERVER_CLASS = "ParlorServer";
|
|
19
|
+
type DocumentOptions = Pick<EntryOptions, "basePath" | "contentSecurityPolicy" | "render">;
|
|
20
|
+
export declare function hostEntrySource({ serverEntry, ...document }: EntryOptions): string;
|
|
21
|
+
export interface CloudflareEntryOptions extends DocumentOptions {
|
|
22
|
+
readonly locationHint?: string | undefined;
|
|
23
|
+
}
|
|
24
|
+
/** The stateless Worker: documents here, everything else to the one Durable Object. */
|
|
25
|
+
export declare function cloudflareEntrySource({ locationHint, ...document }: CloudflareEntryOptions): string;
|
|
26
|
+
export interface DurableServerOptions {
|
|
27
|
+
readonly serverEntry: string;
|
|
28
|
+
readonly connectionScopes: boolean;
|
|
29
|
+
/** The app's own Worker exports, such as its Durable Object classes. */
|
|
30
|
+
readonly workerExports?: string | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The app's server, imported on the Durable Object's first request: workerd allows no I/O
|
|
34
|
+
* or timers while a module loads, and server.ts may await its database at the top level.
|
|
35
|
+
*/
|
|
36
|
+
export declare function durableServerSource({ serverEntry, connectionScopes, workerExports, }: DurableServerOptions): string;
|
|
37
|
+
export {};
|
|
8
38
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAClD;AAED,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAC9D,eAAO,MAAM,uBAAuB,2BAA2B,CAAC;AAChE,eAAO,MAAM,uBAAuB,2BAA2B,CAAC;AAEhE,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AACtD,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AAEnD,KAAK,eAAe,GAAG,IAAI,CACzB,YAAY,EACZ,UAAU,GAAG,uBAAuB,GAAG,QAAQ,CAChD,CAAC;AAuEF,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,GAAG,QAAQ,EAAE,EAAE,YAAY,GAAG,MAAM,CAyBlF;AAED,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC7D,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5C;AAED,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,EACpC,YAAY,EACZ,GAAG,QAAQ,EACZ,EAAE,sBAAsB,GAAG,MAAM,CAejC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,wEAAwE;IACxE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,gBAAgB,EAChB,aAAa,GACd,EAAE,oBAAoB,GAAG,MAAM,CAmB/B"}
|
package/dist/entry.js
CHANGED
|
@@ -1,11 +1,77 @@
|
|
|
1
|
+
import { UNROUTED_HEADER } from "@parlor/agent-ui";
|
|
2
|
+
export const NONCE_PLACEHOLDER = "{nonce}";
|
|
1
3
|
export const INDEX_HTML_PLACEHOLDER = "__PARLOR_INDEX_HTML__";
|
|
2
4
|
export const UI_MANIFEST_PLACEHOLDER = "__PARLOR_UI_MANIFEST__";
|
|
3
|
-
export
|
|
5
|
+
export const PAGE_ROUTES_PLACEHOLDER = "__PARLOR_PAGE_ROUTES__";
|
|
6
|
+
export const DURABLE_SERVER_BINDING = "PARLOR_SERVER";
|
|
7
|
+
export const DURABLE_SERVER_CLASS = "ParlorServer";
|
|
8
|
+
/** Imported on the first page it renders, keeping the app's pages out of the server's startup. */
|
|
9
|
+
const renderSource = (render) => render
|
|
10
|
+
? `let rendering;
|
|
11
|
+
const loadRender = () => (rendering ??= import(${JSON.stringify(render.module)}).then((module) => module.render));
|
|
12
|
+
const RENDERED_POLICY = ${JSON.stringify(render.contentSecurityPolicy)};
|
|
13
|
+
|
|
14
|
+
function createNonce() {
|
|
15
|
+
return btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(16))));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function renderPage(request, serve) {
|
|
19
|
+
const nonce = createNonce();
|
|
20
|
+
try {
|
|
21
|
+
const page = await (await loadRender())(request, { template: INDEX_HTML, fetch: serve, nonce });
|
|
22
|
+
if (!page) return undefined;
|
|
23
|
+
const response = new Response(page.body, page);
|
|
24
|
+
response.headers.set("content-security-policy", RENDERED_POLICY.replace(${JSON.stringify(NONCE_PLACEHOLDER)}, nonce));
|
|
25
|
+
if (!response.headers.has("cache-control")) response.headers.set("cache-control", "private, no-cache");
|
|
26
|
+
return response;
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(\`[parlor] Rendering \${request.url} on the server failed, so it is served without:\`, error);
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}`
|
|
32
|
+
: "const renderPage = async () => undefined;";
|
|
33
|
+
/**
|
|
34
|
+
* A page route's document is rendered on the server when its routes opt in, and is
|
|
35
|
+
* `index.html` otherwise, without asking the app. Any other request goes to the app, and a
|
|
36
|
+
* browser gets the document only when no route of the app's matches either.
|
|
37
|
+
*/
|
|
38
|
+
const documentSource = ({ basePath, contentSecurityPolicy, render, }) => `const INDEX_HTML = ${INDEX_HTML_PLACEHOLDER};
|
|
39
|
+
const PAGE_ROUTES = ${PAGE_ROUTES_PLACEHOLDER};
|
|
40
|
+
const BASE_PATH = ${JSON.stringify(basePath)};
|
|
41
|
+
const DOCUMENT_HEADERS = {
|
|
42
|
+
"content-type": "text/html; charset=utf-8",
|
|
43
|
+
"cache-control": "no-cache",
|
|
44
|
+
"content-security-policy": ${JSON.stringify(contentSecurityPolicy)},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
${renderSource(render)}
|
|
48
|
+
|
|
49
|
+
function wantsDocument(request, path) {
|
|
50
|
+
if (!INDEX_HTML || request.method !== "GET" || path.startsWith(BASE_PATH)) return false;
|
|
51
|
+
return (request.headers.get("accept") ?? "").includes("text/html");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function withDocument(request, serve) {
|
|
55
|
+
const { pathname } = new URL(request.url);
|
|
56
|
+
if (INDEX_HTML && pathname === "/index.html") {
|
|
57
|
+
return new Response(INDEX_HTML, { headers: DOCUMENT_HEADERS });
|
|
58
|
+
}
|
|
59
|
+
const document = wantsDocument(request, pathname);
|
|
60
|
+
if (document && PAGE_ROUTES.some((page) => page.test(pathname))) {
|
|
61
|
+
return (await renderPage(request, serve)) ?? new Response(INDEX_HTML, { headers: DOCUMENT_HEADERS });
|
|
62
|
+
}
|
|
63
|
+
const response = await serve(request);
|
|
64
|
+
if (!document || response.status !== 404 || !response.headers.has(${JSON.stringify(UNROUTED_HEADER)})) {
|
|
65
|
+
return response;
|
|
66
|
+
}
|
|
67
|
+
await response.body?.cancel();
|
|
68
|
+
return new Response(INDEX_HTML, { headers: DOCUMENT_HEADERS });
|
|
69
|
+
}`;
|
|
70
|
+
export function hostEntrySource({ serverEntry, ...document }) {
|
|
4
71
|
return `import app from ${JSON.stringify(serverEntry)};
|
|
5
72
|
|
|
6
|
-
const INDEX_HTML = ${INDEX_HTML_PLACEHOLDER};
|
|
7
73
|
const UI_MANIFEST = ${UI_MANIFEST_PLACEHOLDER};
|
|
8
|
-
|
|
74
|
+
${documentSource(document)}
|
|
9
75
|
|
|
10
76
|
app.installUiManifest?.(() => UI_MANIFEST);
|
|
11
77
|
|
|
@@ -20,23 +86,52 @@ for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
|
20
86
|
});
|
|
21
87
|
}
|
|
22
88
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
89
|
+
export default {
|
|
90
|
+
fetch(request) {
|
|
91
|
+
return withDocument(request, (request) => app.fetch(request));
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
`;
|
|
27
95
|
}
|
|
96
|
+
/** The stateless Worker: documents here, everything else to the one Durable Object. */
|
|
97
|
+
export function cloudflareEntrySource({ locationHint, ...document }) {
|
|
98
|
+
return `import { env } from "cloudflare:workers";
|
|
99
|
+
|
|
100
|
+
${documentSource(document)}
|
|
28
101
|
|
|
29
102
|
export default {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
return app.fetch(request);
|
|
103
|
+
fetch(request) {
|
|
104
|
+
return withDocument(request, (request) => {
|
|
105
|
+
const servers = env.${DURABLE_SERVER_BINDING};
|
|
106
|
+
const server = servers.get(servers.idFromName("app")${locationHint ? `, { locationHint: ${JSON.stringify(locationHint)} }` : ""});
|
|
107
|
+
return server.fetch(request);
|
|
108
|
+
});
|
|
38
109
|
},
|
|
39
110
|
};
|
|
40
111
|
`;
|
|
41
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* The app's server, imported on the Durable Object's first request: workerd allows no I/O
|
|
115
|
+
* or timers while a module loads, and server.ts may await its database at the top level.
|
|
116
|
+
*/
|
|
117
|
+
export function durableServerSource({ serverEntry, connectionScopes, workerExports, }) {
|
|
118
|
+
return `import { DurableObject } from "cloudflare:workers";
|
|
119
|
+
${connectionScopes ? 'import { createConnectionScope } from "@parlor/data";\n' : ""}${workerExports ? `export * from ${JSON.stringify(workerExports)};\n` : ""}
|
|
120
|
+
const UI_MANIFEST = ${UI_MANIFEST_PLACEHOLDER};
|
|
121
|
+
|
|
122
|
+
let loading;
|
|
123
|
+
function app() {
|
|
124
|
+
return (loading ??= import(${JSON.stringify(serverEntry)}).then(({ default: server }) => {
|
|
125
|
+
server.installUiManifest?.(() => UI_MANIFEST);
|
|
126
|
+
return server;
|
|
127
|
+
}));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class ${DURABLE_SERVER_CLASS} extends DurableObject {
|
|
131
|
+
${connectionScopes ? " #connections = createConnectionScope();\n\n" : ""} fetch(request) {
|
|
132
|
+
${connectionScopes ? "return this.#connections.run(async () => (await app()).fetch(request));" : "return app().then((server) => server.fetch(request));"}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
}
|
|
42
137
|
//# sourceMappingURL=entry.js.map
|
package/dist/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAgBnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAChE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAEhE,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC;AACtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAOnD,kGAAkG;AAClG,MAAM,YAAY,GAAG,CAAC,MAAsC,EAAE,EAAE,CAC9D,MAAM;IACJ,CAAC,CAAC;iDAC2C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;0BACpD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,qBAAqB,CAAC;;;;;;;;;;;;8EAYQ,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC;;;;;;;EAO7G;IACE,CAAC,CAAC,2CAA2C,CAAC;AAElD;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,EACt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AAgB,CAAC,CAAC,CAAC,yEAAyE,CAAC,CAAC,CAAC,uDAAuD;;;CAG3J,CAAC;AACF,CAAC","sourcesContent":["import { UNROUTED_HEADER } from \"@parlor/agent-ui\";\n\nexport interface RenderEntryOptions {\n /** The module `parlor build` built from `web.ssr`, exporting `render`. */\n readonly module: string;\n /** The page policy with `{nonce}` in `script-src`, replaced per response. */\n readonly contentSecurityPolicy: string;\n}\n\nexport interface EntryOptions {\n readonly serverEntry: string;\n readonly basePath: string;\n readonly contentSecurityPolicy: string;\n readonly render?: RenderEntryOptions | undefined;\n}\n\nexport const NONCE_PLACEHOLDER = \"{nonce}\";\n\nexport const INDEX_HTML_PLACEHOLDER = \"__PARLOR_INDEX_HTML__\";\nexport const UI_MANIFEST_PLACEHOLDER = \"__PARLOR_UI_MANIFEST__\";\nexport const PAGE_ROUTES_PLACEHOLDER = \"__PARLOR_PAGE_ROUTES__\";\n\nexport const DURABLE_SERVER_BINDING = \"PARLOR_SERVER\";\nexport const DURABLE_SERVER_CLASS = \"ParlorServer\";\n\ntype DocumentOptions = Pick<\n EntryOptions,\n \"basePath\" | \"contentSecurityPolicy\" | \"render\"\n>;\n\n/** Imported on the first page it renders, keeping the app's pages out of the server's startup. */\nconst renderSource = (render: RenderEntryOptions | undefined) =>\n render\n ? `let rendering;\nconst loadRender = () => (rendering ??= import(${JSON.stringify(render.module)}).then((module) => module.render));\nconst RENDERED_POLICY = ${JSON.stringify(render.contentSecurityPolicy)};\n\nfunction createNonce() {\n return btoa(String.fromCharCode(...crypto.getRandomValues(new Uint8Array(16))));\n}\n\nasync function renderPage(request, serve) {\n const nonce = createNonce();\n try {\n const page = await (await loadRender())(request, { template: INDEX_HTML, fetch: serve, nonce });\n if (!page) return undefined;\n const response = new Response(page.body, page);\n response.headers.set(\"content-security-policy\", RENDERED_POLICY.replace(${JSON.stringify(NONCE_PLACEHOLDER)}, nonce));\n if (!response.headers.has(\"cache-control\")) response.headers.set(\"cache-control\", \"private, no-cache\");\n return response;\n } catch (error) {\n console.error(\\`[parlor] Rendering \\${request.url} on the server failed, so it is served without:\\`, error);\n return undefined;\n }\n}`\n : \"const renderPage = async () => undefined;\";\n\n/**\n * A page route's document is rendered on the server when its routes opt in, and is\n * `index.html` otherwise, without asking the app. Any other request goes to the app, and a\n * browser gets the document only when no route of the app's matches either.\n */\nconst documentSource = ({\n basePath,\n contentSecurityPolicy,\n render,\n}: DocumentOptions) => `const INDEX_HTML = ${INDEX_HTML_PLACEHOLDER};\nconst PAGE_ROUTES = ${PAGE_ROUTES_PLACEHOLDER};\nconst BASE_PATH = ${JSON.stringify(basePath)};\nconst DOCUMENT_HEADERS = {\n \"content-type\": \"text/html; charset=utf-8\",\n \"cache-control\": \"no-cache\",\n \"content-security-policy\": ${JSON.stringify(contentSecurityPolicy)},\n};\n\n${renderSource(render)}\n\nfunction wantsDocument(request, path) {\n if (!INDEX_HTML || request.method !== \"GET\" || path.startsWith(BASE_PATH)) return false;\n return (request.headers.get(\"accept\") ?? \"\").includes(\"text/html\");\n}\n\nasync function withDocument(request, serve) {\n const { pathname } = new URL(request.url);\n if (INDEX_HTML && pathname === \"/index.html\") {\n return new Response(INDEX_HTML, { headers: DOCUMENT_HEADERS });\n }\n const document = wantsDocument(request, pathname);\n if (document && PAGE_ROUTES.some((page) => page.test(pathname))) {\n return (await renderPage(request, serve)) ?? new Response(INDEX_HTML, { headers: DOCUMENT_HEADERS });\n }\n const response = await serve(request);\n if (!document || response.status !== 404 || !response.headers.has(${JSON.stringify(UNROUTED_HEADER)})) {\n return response;\n }\n await response.body?.cancel();\n return new Response(INDEX_HTML, { headers: DOCUMENT_HEADERS });\n}`;\n\nexport function hostEntrySource({ serverEntry, ...document }: EntryOptions): string {\n return `import app from ${JSON.stringify(serverEntry)};\n\nconst UI_MANIFEST = ${UI_MANIFEST_PLACEHOLDER};\n${documentSource(document)}\n\napp.installUiManifest?.(() => UI_MANIFEST);\n\nfor (const signal of [\"SIGINT\", \"SIGTERM\"]) {\n globalThis.process?.once?.(signal, async () => {\n try {\n await app.close?.();\n } catch (error) {\n console.error(\"[parlor] shutdown failed:\", error);\n }\n process.kill(process.pid, signal);\n });\n}\n\nexport default {\n fetch(request) {\n return withDocument(request, (request) => app.fetch(request));\n },\n};\n`;\n}\n\nexport interface CloudflareEntryOptions extends DocumentOptions {\n readonly locationHint?: string | undefined;\n}\n\n/** The stateless Worker: documents here, everything else to the one Durable Object. */\nexport function cloudflareEntrySource({\n locationHint,\n ...document\n}: CloudflareEntryOptions): string {\n return `import { env } from \"cloudflare:workers\";\n\n${documentSource(document)}\n\nexport default {\n fetch(request) {\n return withDocument(request, (request) => {\n const servers = env.${DURABLE_SERVER_BINDING};\n const server = servers.get(servers.idFromName(\"app\")${locationHint ? `, { locationHint: ${JSON.stringify(locationHint)} }` : \"\"});\n return server.fetch(request);\n });\n },\n};\n`;\n}\n\nexport interface DurableServerOptions {\n readonly serverEntry: string;\n readonly connectionScopes: boolean;\n /** The app's own Worker exports, such as its Durable Object classes. */\n readonly workerExports?: string | undefined;\n}\n\n/**\n * The app's server, imported on the Durable Object's first request: workerd allows no I/O\n * or timers while a module loads, and server.ts may await its database at the top level.\n */\nexport function durableServerSource({\n serverEntry,\n connectionScopes,\n workerExports,\n}: DurableServerOptions): string {\n return `import { DurableObject } from \"cloudflare:workers\";\n${connectionScopes ? 'import { createConnectionScope } from \"@parlor/data\";\\n' : \"\"}${workerExports ? `export * from ${JSON.stringify(workerExports)};\\n` : \"\"}\nconst UI_MANIFEST = ${UI_MANIFEST_PLACEHOLDER};\n\nlet loading;\nfunction app() {\n return (loading ??= import(${JSON.stringify(serverEntry)}).then(({ default: server }) => {\n server.installUiManifest?.(() => UI_MANIFEST);\n return server;\n }));\n}\n\nexport class ${DURABLE_SERVER_CLASS} extends DurableObject {\n${connectionScopes ? \" #connections = createConnectionScope();\\n\\n\" : \"\"} fetch(request) {\n ${connectionScopes ? \"return this.#connections.run(async () => (await app()).fetch(request));\" : \"return app().then((server) => server.fetch(request));\"}\n }\n}\n`;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { buildServer, hostRootDir, type ServerBuildOptions, type ServerBuildResult, SYNC_TRANSPORT_ENV, } from "./build.js";
|
|
2
|
-
export { type EntryOptions, hostEntrySource, INDEX_HTML_PLACEHOLDER, UI_MANIFEST_PLACEHOLDER, } from "./entry.js";
|
|
3
|
-
export { DEPLOY_PRESETS, type DeployPreset, detectCiPreset, isDeployPreset, PresetError, resolvePreset, syncTransportFor, } from "./presets.js";
|
|
1
|
+
export { buildServer, devWranglerConfig, type DevWranglerConfig, hostRootDir, type ServerBuildOptions, type ServerBuildResult, SYNC_TRANSPORT_ENV, type UnavailableDurableObject, } from "./build.js";
|
|
2
|
+
export { type EntryOptions, hostEntrySource, INDEX_HTML_PLACEHOLDER, type RenderEntryOptions, UI_MANIFEST_PLACEHOLDER, } from "./entry.js";
|
|
3
|
+
export { DEPLOY_PRESETS, type DeployPreset, detectCiPreset, isDeployPreset, nitroPresetFor, PresetError, renderConditionsFor, resolvePreset, syncTransportFor, } from "./presets.js";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,kBAAkB,EAClB,KAAK,wBAAwB,GAC9B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,YAAY,EACjB,eAAe,EACf,sBAAsB,EACtB,KAAK,kBAAkB,EACvB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,EACd,KAAK,YAAY,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { buildServer, hostRootDir, SYNC_TRANSPORT_ENV, } from "./build.js";
|
|
1
|
+
export { buildServer, devWranglerConfig, hostRootDir, SYNC_TRANSPORT_ENV, } from "./build.js";
|
|
2
2
|
export { hostEntrySource, INDEX_HTML_PLACEHOLDER, UI_MANIFEST_PLACEHOLDER, } from "./entry.js";
|
|
3
|
-
export { DEPLOY_PRESETS, detectCiPreset, isDeployPreset, PresetError, resolvePreset, syncTransportFor, } from "./presets.js";
|
|
3
|
+
export { DEPLOY_PRESETS, detectCiPreset, isDeployPreset, nitroPresetFor, PresetError, renderConditionsFor, resolvePreset, syncTransportFor, } from "./presets.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,EAGX,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EAEjB,WAAW,EAGX,kBAAkB,GAEnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,eAAe,EACf,sBAAsB,EAEtB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,EAEd,cAAc,EACd,cAAc,EACd,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAC","sourcesContent":["export {\n buildServer,\n devWranglerConfig,\n type DevWranglerConfig,\n hostRootDir,\n type ServerBuildOptions,\n type ServerBuildResult,\n SYNC_TRANSPORT_ENV,\n type UnavailableDurableObject,\n} from \"./build.js\";\nexport {\n type EntryOptions,\n hostEntrySource,\n INDEX_HTML_PLACEHOLDER,\n type RenderEntryOptions,\n UI_MANIFEST_PLACEHOLDER,\n} from \"./entry.js\";\nexport {\n DEPLOY_PRESETS,\n type DeployPreset,\n detectCiPreset,\n isDeployPreset,\n nitroPresetFor,\n PresetError,\n renderConditionsFor,\n resolvePreset,\n syncTransportFor,\n} from \"./presets.js\";\n"]}
|
package/dist/presets.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const DEPLOY_PRESETS: readonly ["node-server", "vercel", "netlify", "cloudflare-module", "aws-lambda", "deno-deploy", "bun"];
|
|
1
|
+
export declare const DEPLOY_PRESETS: readonly ["node-server", "vercel", "netlify", "cloudflare-module", "cloudflare-durable", "aws-lambda", "deno-deploy", "bun"];
|
|
2
2
|
export type DeployPreset = (typeof DEPLOY_PRESETS)[number];
|
|
3
3
|
export declare class PresetError extends Error {
|
|
4
4
|
readonly name = "PresetError";
|
|
@@ -10,4 +10,10 @@ export declare function resolvePreset(explicit: string | undefined, configured:
|
|
|
10
10
|
reason: "flag" | "config" | "ci" | "default";
|
|
11
11
|
};
|
|
12
12
|
export declare function syncTransportFor(preset: DeployPreset): "sse" | "poll";
|
|
13
|
+
/** `cloudflare-durable` is a Worker that hands every request but documents to one Durable Object. */
|
|
14
|
+
export declare function nitroPresetFor(preset: DeployPreset): string;
|
|
15
|
+
/** Export conditions of the runtime that renders pages, for the server render build. */
|
|
16
|
+
export declare function renderConditionsFor(preset: DeployPreset): readonly string[];
|
|
17
|
+
/** The presets whose server runs on Cloudflare's workerd. */
|
|
18
|
+
export declare function runsOnWorkerd(preset: DeployPreset): boolean;
|
|
13
19
|
//# sourceMappingURL=presets.d.ts.map
|
package/dist/presets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,YACzB,aAAa,EACb,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,KAAK,CACG,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,YACzB,aAAa,EACb,QAAQ,EACR,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,aAAa,EACb,KAAK,CACG,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAmB3D,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAkB,IAAI,iBAAiB;CACxC;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,YAAY,CAEnE;AAED,wBAAgB,cAAc,CAC5B,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,YAAY,GAAG,SAAS,CAE1B;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,CAiBxE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,KAAK,GAAG,MAAM,CAErE;AAED,qGAAqG;AACrG,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAE3D;AASD,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,CAE3E;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAE3D"}
|
package/dist/presets.js
CHANGED
|
@@ -3,11 +3,20 @@ export const DEPLOY_PRESETS = [
|
|
|
3
3
|
"vercel",
|
|
4
4
|
"netlify",
|
|
5
5
|
"cloudflare-module",
|
|
6
|
+
"cloudflare-durable",
|
|
6
7
|
"aws-lambda",
|
|
7
8
|
"deno-deploy",
|
|
8
9
|
"bun",
|
|
9
10
|
];
|
|
10
|
-
const LONG_LIVED = new Set([
|
|
11
|
+
const LONG_LIVED = new Set([
|
|
12
|
+
"node-server",
|
|
13
|
+
"bun",
|
|
14
|
+
"cloudflare-durable",
|
|
15
|
+
]);
|
|
16
|
+
const ON_WORKERD = new Set([
|
|
17
|
+
"cloudflare-module",
|
|
18
|
+
"cloudflare-durable",
|
|
19
|
+
]);
|
|
11
20
|
const CI_PRESETS = [
|
|
12
21
|
["VERCEL", "vercel"],
|
|
13
22
|
["NETLIFY", "netlify"],
|
|
@@ -40,4 +49,22 @@ export function resolvePreset(explicit, configured, env = process.env) {
|
|
|
40
49
|
export function syncTransportFor(preset) {
|
|
41
50
|
return LONG_LIVED.has(preset) ? "sse" : "poll";
|
|
42
51
|
}
|
|
52
|
+
/** `cloudflare-durable` is a Worker that hands every request but documents to one Durable Object. */
|
|
53
|
+
export function nitroPresetFor(preset) {
|
|
54
|
+
return preset === "cloudflare-durable" ? "cloudflare-module" : preset;
|
|
55
|
+
}
|
|
56
|
+
const RENDER_CONDITIONS = {
|
|
57
|
+
"cloudflare-module": ["workerd", "worker"],
|
|
58
|
+
"cloudflare-durable": ["workerd", "worker"],
|
|
59
|
+
"deno-deploy": ["deno"],
|
|
60
|
+
bun: ["bun", "node"],
|
|
61
|
+
};
|
|
62
|
+
/** Export conditions of the runtime that renders pages, for the server render build. */
|
|
63
|
+
export function renderConditionsFor(preset) {
|
|
64
|
+
return RENDER_CONDITIONS[preset] ?? ["node"];
|
|
65
|
+
}
|
|
66
|
+
/** The presets whose server runs on Cloudflare's workerd. */
|
|
67
|
+
export function runsOnWorkerd(preset) {
|
|
68
|
+
return ON_WORKERD.has(preset);
|
|
69
|
+
}
|
|
43
70
|
//# sourceMappingURL=presets.js.map
|
package/dist/presets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,aAAa;IACb,QAAQ;IACR,SAAS;IACT,mBAAmB;IACnB,YAAY;IACZ,aAAa;IACb,KAAK;CACG,CAAC;AAGX,MAAM,UAAU,GAA8B,IAAI,GAAG,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"presets.js","sourceRoot":"","sources":["../src/presets.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,aAAa;IACb,QAAQ;IACR,SAAS;IACT,mBAAmB;IACnB,oBAAoB;IACpB,YAAY;IACZ,aAAa;IACb,KAAK;CACG,CAAC;AAGX,MAAM,UAAU,GAA8B,IAAI,GAAG,CAAC;IACpD,aAAa;IACb,KAAK;IACL,oBAAoB;CACrB,CAAC,CAAC;AAEH,MAAM,UAAU,GAA8B,IAAI,GAAG,CAAC;IACpD,mBAAmB;IACnB,oBAAoB;CACrB,CAAC,CAAC;AAEH,MAAM,UAAU,GAAmD;IACjE,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,CAAC,SAAS,EAAE,SAAS,CAAC;IACtB,CAAC,UAAU,EAAE,mBAAmB,CAAC;CAClC,CAAC;AAEF,MAAM,OAAO,WAAY,SAAQ,KAAK;IAClB,IAAI,GAAG,aAAa,CAAC;CACxC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAQ,cAAoC,CAAC,QAAQ,CAAC,KAAK,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AAM,UAAU,cAAc,CAAC,MAAoB;IACjD,OAAO,MAAM,KAAK,oBAAoB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;AACxE,CAAC;AAED,MAAM,iBAAiB,GAAqD;IAC1E,mBAAmB,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC1C,oBAAoB,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC3C,aAAa,EAAE,CAAC,MAAM,CAAC;IACvB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wFAAwF;AACxF,MAAM,UAAU,mBAAmB,CAAC,MAAoB;IACtD,OAAO,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,aAAa,CAAC,MAAoB;IAChD,OAAO,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC","sourcesContent":["export const DEPLOY_PRESETS = [\n \"node-server\",\n \"vercel\",\n \"netlify\",\n \"cloudflare-module\",\n \"cloudflare-durable\",\n \"aws-lambda\",\n \"deno-deploy\",\n \"bun\",\n] as const;\nexport type DeployPreset = (typeof DEPLOY_PRESETS)[number];\n\nconst LONG_LIVED: ReadonlySet<DeployPreset> = new Set([\n \"node-server\",\n \"bun\",\n \"cloudflare-durable\",\n]);\n\nconst ON_WORKERD: ReadonlySet<DeployPreset> = new Set([\n \"cloudflare-module\",\n \"cloudflare-durable\",\n]);\n\nconst CI_PRESETS: ReadonlyArray<readonly [string, DeployPreset]> = [\n [\"VERCEL\", \"vercel\"],\n [\"NETLIFY\", \"netlify\"],\n [\"CF_PAGES\", \"cloudflare-module\"],\n];\n\nexport class PresetError extends Error {\n override readonly name = \"PresetError\";\n}\n\nexport function isDeployPreset(value: string): value is DeployPreset {\n return (DEPLOY_PRESETS as readonly string[]).includes(value);\n}\n\nexport function detectCiPreset(\n env: NodeJS.ProcessEnv = process.env,\n): DeployPreset | undefined {\n return CI_PRESETS.find(([name]) => Boolean(env[name]))?.[1];\n}\n\nexport function resolvePreset(\n explicit: string | undefined,\n configured: string | undefined,\n env: NodeJS.ProcessEnv = process.env,\n): { preset: DeployPreset; reason: \"flag\" | \"config\" | \"ci\" | \"default\" } {\n const pick = (value: string | undefined, reason: \"flag\" | \"config\") => {\n if (value === undefined) return undefined;\n if (!isDeployPreset(value)) {\n throw new PresetError(\n `Unknown deploy preset \"${value}\". Expected one of: ${DEPLOY_PRESETS.join(\", \")}`,\n );\n }\n return { preset: value, reason } as const;\n };\n return (\n pick(explicit, \"flag\") ??\n pick(configured, \"config\") ??\n (detectCiPreset(env)\n ? { preset: detectCiPreset(env)!, reason: \"ci\" as const }\n : undefined) ?? { preset: \"node-server\", reason: \"default\" }\n );\n}\n\nexport function syncTransportFor(preset: DeployPreset): \"sse\" | \"poll\" {\n return LONG_LIVED.has(preset) ? \"sse\" : \"poll\";\n}\n\n/** `cloudflare-durable` is a Worker that hands every request but documents to one Durable Object. */\nexport function nitroPresetFor(preset: DeployPreset): string {\n return preset === \"cloudflare-durable\" ? \"cloudflare-module\" : preset;\n}\n\nconst RENDER_CONDITIONS: Partial<Record<DeployPreset, readonly string[]>> = {\n \"cloudflare-module\": [\"workerd\", \"worker\"],\n \"cloudflare-durable\": [\"workerd\", \"worker\"],\n \"deno-deploy\": [\"deno\"],\n bun: [\"bun\", \"node\"],\n};\n\n/** Export conditions of the runtime that renders pages, for the server render build. */\nexport function renderConditionsFor(preset: DeployPreset): readonly string[] {\n return RENDER_CONDITIONS[preset] ?? [\"node\"];\n}\n\n/** The presets whose server runs on Cloudflare's workerd. */\nexport function runsOnWorkerd(preset: DeployPreset): boolean {\n return ON_WORKERD.has(preset);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parlor/host",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"homepage": "https://cychien.github.io/parlor",
|
|
5
5
|
"bugs": "https://github.com/cychien/parlor/issues",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,18 +20,25 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"drizzle-orm": "^0.45.4",
|
|
23
24
|
"nitro": "3.0.260903-beta",
|
|
24
|
-
"@parlor/
|
|
25
|
-
"@parlor/
|
|
26
|
-
"@parlor/
|
|
25
|
+
"@parlor/agent-ui": "0.2.0",
|
|
26
|
+
"@parlor/config": "0.2.0",
|
|
27
|
+
"@parlor/shell-web": "0.2.0"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
30
|
+
"@tanstack/react-query": "^5.104.1",
|
|
31
|
+
"@tanstack/react-router": "^1.170.45",
|
|
29
32
|
"@types/node": "^24.14.0",
|
|
33
|
+
"react": "^19.3.0",
|
|
34
|
+
"react-dom": "^19.3.0",
|
|
30
35
|
"typescript": "^7.0.2",
|
|
31
36
|
"vitest": "^5.0.3",
|
|
32
|
-
"
|
|
33
|
-
"@parlor/
|
|
34
|
-
"@parlor/
|
|
37
|
+
"wrangler": "^4.152.0",
|
|
38
|
+
"@parlor/client": "0.2.0",
|
|
39
|
+
"@parlor/core": "0.2.0",
|
|
40
|
+
"@parlor/server": "0.2.0",
|
|
41
|
+
"@parlor/data": "0.2.0"
|
|
35
42
|
},
|
|
36
43
|
"scripts": {
|
|
37
44
|
"build": "tsc -p tsconfig.json",
|