@parlor/host 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +10 -2
- package/dist/build.d.ts +18 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +57 -0
- package/dist/build.js.map +1 -0
- package/dist/entry.d.ts +8 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +42 -0
- package/dist/entry.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/presets.d.ts +13 -0
- package/dist/presets.d.ts.map +1 -0
- package/dist/presets.js +43 -0
- package/dist/presets.js.map +1 -0
- package/package.json +38 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cychien
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @parlor/host
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Builds the production server: wraps an app's `server.ts` and web build in a Nitro server for a deploy preset. Installed by `@parlor/cli`; you do not depend on it directly.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { DEPLOY_PRESETS } from "@parlor/host";
|
|
7
|
+
|
|
8
|
+
console.log(DEPLOY_PRESETS.join(", "));
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Docs: https://cychien.github.io/parlor/guides/deploy/
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type LoadedConfig } from "@parlor/config";
|
|
2
|
+
import type { NitroConfig } from "nitro/types";
|
|
3
|
+
import { type DeployPreset } from "./presets.js";
|
|
4
|
+
export declare const SYNC_TRANSPORT_ENV = "PARLOR_SYNC_TRANSPORT";
|
|
5
|
+
export interface ServerBuildOptions {
|
|
6
|
+
readonly preset: DeployPreset;
|
|
7
|
+
readonly basePath?: string | undefined;
|
|
8
|
+
readonly compatibilityDate?: NitroConfig["compatibilityDate"] | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface ServerBuildResult {
|
|
11
|
+
readonly rootDir: string;
|
|
12
|
+
readonly outputDir: string;
|
|
13
|
+
readonly preset: DeployPreset;
|
|
14
|
+
readonly syncTransport: "sse" | "poll";
|
|
15
|
+
}
|
|
16
|
+
export declare function hostRootDir(projectRoot: string): string;
|
|
17
|
+
export declare function buildServer({ config, rootDir }: LoadedConfig, options: ServerBuildOptions): Promise<ServerBuildResult>;
|
|
18
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAIA,OAAO,EAA+B,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGhF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO/C,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,cAAc,CAAC;AAEnE,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAK1D,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,mBAAmB,CAAC,GAAG,SAAS,CAAC;CAC3E;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,KAAK,GAAG,MAAM,CAAC;CACxC;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAsB,WAAW,CAC/B,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,YAAY,EACjC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAyD5B"}
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { UI_MANIFEST_FILE } from "@parlor/agent-ui";
|
|
4
|
+
import { appServerEnv, GENERATED_DIR } from "@parlor/config";
|
|
5
|
+
import { appCsp, serializeCsp, webOutDir } from "@parlor/shell-web";
|
|
6
|
+
import { build, copyPublicAssets, createNitro, prepare } from "nitro/builder";
|
|
7
|
+
import { hostEntrySource, INDEX_HTML_PLACEHOLDER, UI_MANIFEST_PLACEHOLDER, } from "./entry.js";
|
|
8
|
+
import { syncTransportFor } from "./presets.js";
|
|
9
|
+
export const SYNC_TRANSPORT_ENV = "PARLOR_SYNC_TRANSPORT";
|
|
10
|
+
const TRACED_DEPENDENCIES = ["@electric-sql/pglite", "pg"];
|
|
11
|
+
const DEFAULT_COMPATIBILITY_DATE = "2026-10-01";
|
|
12
|
+
export function hostRootDir(projectRoot) {
|
|
13
|
+
return join(projectRoot, GENERATED_DIR, "nitro");
|
|
14
|
+
}
|
|
15
|
+
export async function buildServer({ config, rootDir }, options) {
|
|
16
|
+
const hostRoot = hostRootDir(rootDir);
|
|
17
|
+
const basePath = options.basePath ?? "/_parlor";
|
|
18
|
+
const syncTransport = config.server.sync?.transport ?? syncTransportFor(options.preset);
|
|
19
|
+
const indexHtml = await readFile(join(webOutDir(rootDir), "index.html"), "utf8").catch(() => "");
|
|
20
|
+
const uiManifest = await readFile(join(rootDir, GENERATED_DIR, UI_MANIFEST_FILE), "utf8").then((text) => JSON.stringify(JSON.parse(text)), () => "undefined");
|
|
21
|
+
await mkdir(hostRoot, { recursive: true });
|
|
22
|
+
const entryPath = join(hostRoot, "entry.mjs");
|
|
23
|
+
await writeFile(entryPath, hostEntrySource({ serverEntry: join(rootDir, config.server.entry), basePath }));
|
|
24
|
+
await writeFile(join(hostRoot, ".gitignore"), "*\n");
|
|
25
|
+
const nitro = await createNitro({
|
|
26
|
+
rootDir: hostRoot,
|
|
27
|
+
preset: options.preset,
|
|
28
|
+
serverEntry: entryPath,
|
|
29
|
+
compatibilityDate: options.compatibilityDate ?? DEFAULT_COMPATIBILITY_DATE,
|
|
30
|
+
publicAssets: [{ dir: webOutDir(rootDir), baseURL: "/", fallthrough: true }],
|
|
31
|
+
routeRules: {
|
|
32
|
+
"/**": { headers: { "content-security-policy": serializeCsp(appCsp(config, {})) } },
|
|
33
|
+
[`${basePath}/**`]: { headers: false },
|
|
34
|
+
},
|
|
35
|
+
traceDeps: [...TRACED_DEPENDENCIES],
|
|
36
|
+
replace: {
|
|
37
|
+
[INDEX_HTML_PLACEHOLDER]: JSON.stringify(indexHtml),
|
|
38
|
+
[UI_MANIFEST_PLACEHOLDER]: uiManifest,
|
|
39
|
+
[`process.env.${SYNC_TRANSPORT_ENV}`]: JSON.stringify(syncTransport),
|
|
40
|
+
...Object.fromEntries(Object.entries(appServerEnv(config)).map(([name, value]) => [
|
|
41
|
+
`process.env.${name}`,
|
|
42
|
+
JSON.stringify(value),
|
|
43
|
+
])),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
await prepare(nitro);
|
|
47
|
+
await copyPublicAssets(nitro);
|
|
48
|
+
await build(nitro);
|
|
49
|
+
await nitro.close();
|
|
50
|
+
return {
|
|
51
|
+
rootDir: hostRoot,
|
|
52
|
+
outputDir: nitro.options.output.dir,
|
|
53
|
+
preset: options.preset,
|
|
54
|
+
syncTransport,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAqB,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG9E,OAAO,EACL,eAAe,EACf,sBAAsB,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AC;gBAC1D,eAAe,IAAI,EAAE;gBACrB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;aACtB,CAAC,CACH;SACF;KACF,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;IACrB,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC;IACnB,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;IAEpB,OAAO;QACL,OAAO,EAAE,QAAQ;QACjB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG;QACnC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,aAAa;KACd,CAAC;AACJ,CAAC"}
|
package/dist/entry.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface EntryOptions {
|
|
2
|
+
readonly serverEntry: string;
|
|
3
|
+
readonly basePath: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const INDEX_HTML_PLACEHOLDER = "__PARLOR_INDEX_HTML__";
|
|
6
|
+
export declare const UI_MANIFEST_PLACEHOLDER = "__PARLOR_UI_MANIFEST__";
|
|
7
|
+
export declare function hostEntrySource({ serverEntry, basePath }: EntryOptions): string;
|
|
8
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAC9D,eAAO,MAAM,uBAAuB,2BAA2B,CAAC;AAEhE,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,YAAY,GAAG,MAAM,CAsC/E"}
|
package/dist/entry.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const INDEX_HTML_PLACEHOLDER = "__PARLOR_INDEX_HTML__";
|
|
2
|
+
export const UI_MANIFEST_PLACEHOLDER = "__PARLOR_UI_MANIFEST__";
|
|
3
|
+
export function hostEntrySource({ serverEntry, basePath }) {
|
|
4
|
+
return `import app from ${JSON.stringify(serverEntry)};
|
|
5
|
+
|
|
6
|
+
const INDEX_HTML = ${INDEX_HTML_PLACEHOLDER};
|
|
7
|
+
const UI_MANIFEST = ${UI_MANIFEST_PLACEHOLDER};
|
|
8
|
+
const BASE_PATH = ${JSON.stringify(basePath)};
|
|
9
|
+
|
|
10
|
+
app.installUiManifest?.(() => UI_MANIFEST);
|
|
11
|
+
|
|
12
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
13
|
+
globalThis.process?.once?.(signal, async () => {
|
|
14
|
+
try {
|
|
15
|
+
await app.close?.();
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error("[parlor] shutdown failed:", error);
|
|
18
|
+
}
|
|
19
|
+
process.kill(process.pid, signal);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function wantsDocument(request) {
|
|
24
|
+
if (request.method !== "GET") return false;
|
|
25
|
+
const accept = request.headers.get("accept") ?? "";
|
|
26
|
+
return accept.includes("text/html");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
async fetch(request) {
|
|
31
|
+
const url = new URL(request.url);
|
|
32
|
+
if (!url.pathname.startsWith(BASE_PATH) && INDEX_HTML && wantsDocument(request)) {
|
|
33
|
+
return new Response(INDEX_HTML, {
|
|
34
|
+
headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-cache" },
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return app.fetch(request);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAEhE,MAAM,UAAU,eAAe,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAgB;IACrE,OAAO,mBAAmB,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;;qBAElC,sBAAsB;sBACrB,uBAAuB;oBACzB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgC3C,CAAC;AACF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +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";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,YAAY,EACjB,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,EACd,KAAK,YAAY,EACjB,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildServer, hostRootDir, SYNC_TRANSPORT_ENV, } from "./build.js";
|
|
2
|
+
export { hostEntrySource, INDEX_HTML_PLACEHOLDER, UI_MANIFEST_PLACEHOLDER, } from "./entry.js";
|
|
3
|
+
export { DEPLOY_PRESETS, detectCiPreset, isDeployPreset, PresetError, resolvePreset, syncTransportFor, } from "./presets.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,EAGX,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,cAAc,EAEd,cAAc,EACd,cAAc,EACd,WAAW,EACX,aAAa,EACb,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const DEPLOY_PRESETS: readonly ["node-server", "vercel", "netlify", "cloudflare-module", "aws-lambda", "deno-deploy", "bun"];
|
|
2
|
+
export type DeployPreset = (typeof DEPLOY_PRESETS)[number];
|
|
3
|
+
export declare class PresetError extends Error {
|
|
4
|
+
readonly name = "PresetError";
|
|
5
|
+
}
|
|
6
|
+
export declare function isDeployPreset(value: string): value is DeployPreset;
|
|
7
|
+
export declare function detectCiPreset(env?: NodeJS.ProcessEnv): DeployPreset | undefined;
|
|
8
|
+
export declare function resolvePreset(explicit: string | undefined, configured: string | undefined, env?: NodeJS.ProcessEnv): {
|
|
9
|
+
preset: DeployPreset;
|
|
10
|
+
reason: "flag" | "config" | "ci" | "default";
|
|
11
|
+
};
|
|
12
|
+
export declare function syncTransportFor(preset: DeployPreset): "sse" | "poll";
|
|
13
|
+
//# sourceMappingURL=presets.d.ts.map
|
|
@@ -0,0 +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;AAU3D,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"}
|
package/dist/presets.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const DEPLOY_PRESETS = [
|
|
2
|
+
"node-server",
|
|
3
|
+
"vercel",
|
|
4
|
+
"netlify",
|
|
5
|
+
"cloudflare-module",
|
|
6
|
+
"aws-lambda",
|
|
7
|
+
"deno-deploy",
|
|
8
|
+
"bun",
|
|
9
|
+
];
|
|
10
|
+
const LONG_LIVED = new Set(["node-server", "bun"]);
|
|
11
|
+
const CI_PRESETS = [
|
|
12
|
+
["VERCEL", "vercel"],
|
|
13
|
+
["NETLIFY", "netlify"],
|
|
14
|
+
["CF_PAGES", "cloudflare-module"],
|
|
15
|
+
];
|
|
16
|
+
export class PresetError extends Error {
|
|
17
|
+
name = "PresetError";
|
|
18
|
+
}
|
|
19
|
+
export function isDeployPreset(value) {
|
|
20
|
+
return DEPLOY_PRESETS.includes(value);
|
|
21
|
+
}
|
|
22
|
+
export function detectCiPreset(env = process.env) {
|
|
23
|
+
return CI_PRESETS.find(([name]) => Boolean(env[name]))?.[1];
|
|
24
|
+
}
|
|
25
|
+
export function resolvePreset(explicit, configured, env = process.env) {
|
|
26
|
+
const pick = (value, reason) => {
|
|
27
|
+
if (value === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
if (!isDeployPreset(value)) {
|
|
30
|
+
throw new PresetError(`Unknown deploy preset "${value}". Expected one of: ${DEPLOY_PRESETS.join(", ")}`);
|
|
31
|
+
}
|
|
32
|
+
return { preset: value, reason };
|
|
33
|
+
};
|
|
34
|
+
return (pick(explicit, "flag") ??
|
|
35
|
+
pick(configured, "config") ??
|
|
36
|
+
(detectCiPreset(env)
|
|
37
|
+
? { preset: detectCiPreset(env), reason: "ci" }
|
|
38
|
+
: undefined) ?? { preset: "node-server", reason: "default" });
|
|
39
|
+
}
|
|
40
|
+
export function syncTransportFor(preset) {
|
|
41
|
+
return LONG_LIVED.has(preset) ? "sse" : "poll";
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=presets.js.map
|
|
@@ -0,0 +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,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;AAE9E,MAAM,UAAU,GAAmD;IACjE,CAAC,QAAQ,EAAE,QAAQ,CAAC;IACpB,C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aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,CAC/D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAoB;IACnD,OAAO,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parlor/host",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"homepage": "https://cychien.github.io/parlor",
|
|
5
|
+
"bugs": "https://github.com/cychien/parlor/issues",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/cychien/parlor.git",
|
|
10
|
+
"directory": "packages/host"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"nitro": "3.0.260903-beta",
|
|
24
|
+
"@parlor/config": "0.1.0",
|
|
25
|
+
"@parlor/shell-web": "0.1.0",
|
|
26
|
+
"@parlor/agent-ui": "0.1.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^24.14.0",
|
|
30
|
+
"typescript": "^7.0.2",
|
|
31
|
+
"vitest": "^5.0.3",
|
|
32
|
+
"@parlor/data": "0.1.0",
|
|
33
|
+
"@parlor/core": "0.1.0",
|
|
34
|
+
"@parlor/server": "0.1.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -p tsconfig.json",
|
|
38
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
39
|
+
"test": "vitest run"
|
|
40
|
+
}
|
|
6
41
|
}
|