@slotform/vite 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 fcalell
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,35 @@
1
- # Temporary Holding Version
1
+ # @slotform/vite
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Framework-agnostic Vite lifecycle plugin for the `slotform` framework. Renders `.slotform/vite.config.ts` from what other plugins contribute, runs the consumer's Vite for dev and build, and provides the `virtual:slotform-providers` module used by the generated app entry and the `virtual:slotform-schema` module a `Form` derives its fields from. Required by any framework plugin that runs a Vite dev/build pipeline; list it explicitly alongside the framework plugin in your `slotform.config.ts`.
4
+
5
+ **Stack:** Vite (internal -- consumers don't import it)
6
+
7
+ How it is built: [docs/architecture/plugins/vite.md](../../docs/architecture/plugins/vite.md).
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ slotform add vite
13
+ ```
14
+
15
+ The consumer declares `vite` itself (an optional peer of the plugin, and its `devDependencies`, which `slotform init` writes): the generated config imports it, and the dev process and the build step run the consumer's own bin, resolved from its directory, so no PATH or registry lookup stands in.
16
+
17
+ ## Guide
18
+
19
+ The consumer-facing options (`port`, `restart`, `maxRestarts`), the dev server and its API proxy
20
+ live in the `react` plugin's [`web-app.md`](../react/guide/web-app.md), indexed into a consumer's
21
+ `.slotform/guide.md`: `react()` is the one plugin that runs on Vite, so a consumer meets `vite()`
22
+ there.
23
+
24
+ ## Exports
25
+
26
+ | Subpath | Purpose |
27
+ |---------|---------|
28
+ | `@slotform/vite` | `vite()`, `ViteOptions`, `AppPlugin`, `ServerProxyEntry` |
29
+ | `@slotform/vite/preset` | `providersPlugin()`, `schemaPlugin()`, `excludedImportsPlugin()` |
30
+ | `@slotform/vite/node` | `renderViteConfig()`, `ViteConfigValues`, `ServerProxyEntry` |
31
+ | `@slotform/vite/csp` | `scriptHash()`, `allowScript()`, `mergeCsp()`, `mergeClientHeader()`, `headerKey()` |
32
+
33
+ ## License
34
+
35
+ MIT
@@ -0,0 +1,30 @@
1
+ import type { TsExpression, TsImportSpec } from "@slotform/cli/ast";
2
+ import { type AppPlugin, type ServerProxyEntry } from "./types.ts";
3
+ export declare const vite: import("@slotform/cli").PluginFactory<"vite", {
4
+ port?: number | undefined;
5
+ restart?: "always" | "never" | "on-crash" | undefined;
6
+ maxRestarts?: number | undefined;
7
+ }, {
8
+ readonly configImports: import("@slotform/cli").Slot<TsImportSpec[]>;
9
+ readonly pluginCalls: import("@slotform/cli").Slot<TsExpression[]>;
10
+ readonly appPlugins: import("@slotform/cli").Slot<AppPlugin[]>;
11
+ readonly resolveAliases: import("@slotform/cli").Slot<{
12
+ find: string;
13
+ replacement: string;
14
+ }[]>;
15
+ readonly resolveDedupe: import("@slotform/cli").Slot<string[]>;
16
+ readonly optimizeExclude: import("@slotform/cli").Slot<string[]>;
17
+ readonly devServerPort: import("@slotform/cli").Slot<number>;
18
+ readonly outDir: import("@slotform/cli").Slot<string | null>;
19
+ readonly serverProxy: import("@slotform/cli").Slot<ServerProxyEntry[]>;
20
+ readonly fsAllow: import("@slotform/cli").Slot<TsExpression[]>;
21
+ readonly watchIgnored: import("@slotform/cli").Slot<string[]>;
22
+ readonly clientHeaders: import("@slotform/cli").Slot<Record<string, string>>;
23
+ readonly viteConfig: import("@slotform/cli").Slot<string | null>;
24
+ }, Record<string, never>, {
25
+ port?: number | undefined;
26
+ restart?: "always" | "never" | "on-crash" | undefined;
27
+ maxRestarts?: number | undefined;
28
+ }>;
29
+ export type { AppPlugin, ServerProxyEntry, ViteOptions } from "./types.ts";
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMpE,OAAO,EACN,KAAK,SAAS,EACd,KAAK,gBAAgB,EAGrB,MAAM,YAAY,CAAC;AAqKpB,eAAO,MAAM,IAAI;;;;;;;;;cA7GwB,MAAM;qBAAe,MAAM;;;;;;;;;;;;;;;EAyOlE,CAAC;AAEH,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,258 @@
1
+ import { createRequire } from "node:module";
2
+ import { dirname, join } from "node:path";
3
+ import { api } from "@slotform/api";
4
+ import { GENERATED_DIR, plugin, slot } from "@slotform/cli";
5
+ import { cliSlots, emitArtifact } from "@slotform/cli/cli-slots";
6
+ import { SlotformError } from "@slotform/cli/errors";
7
+ import { z } from "zod";
8
+ import { renderViteConfig } from "./node/codegen.js";
9
+ import { headerKey, mergeClientHeader } from "./node/csp.js";
10
+ import { viteOptionsSchema, } from "./types.js";
11
+ const SOURCE = "vite";
12
+ const viteManifestSchema = z.object({ bin: z.object({ vite: z.string() }) });
13
+ // The consumer's own vite: docs/architecture/plugins/vite.md, "How it works".
14
+ function viteBin(cwd) {
15
+ const consumer = createRequire(join(cwd, "package.json"));
16
+ let manifest;
17
+ try {
18
+ manifest = consumer.resolve("vite/package.json");
19
+ }
20
+ catch (err) {
21
+ if (!(err instanceof Error && "code" in err) ||
22
+ err.code !== "MODULE_NOT_FOUND")
23
+ throw err;
24
+ throw new SlotformError("vite is not installed in this app: run `pnpm install` (vite is in its devDependencies), then retry.", "VITE_NOT_INSTALLED");
25
+ }
26
+ return join(dirname(manifest), viteManifestSchema.parse(consumer(manifest)).bin.vite);
27
+ }
28
+ // Sort config imports by source so the emitted vite.config.ts order is
29
+ // independent of `config.plugins` array order.
30
+ const configImports = slot.list({
31
+ source: SOURCE,
32
+ name: "configImports",
33
+ sortBy: (a, b) => a.source.localeCompare(b.source),
34
+ });
35
+ // Plugin call order: docs/architecture/plugins/vite.md, "How it works".
36
+ function pluginCallName(expr) {
37
+ if (expr.kind === "call" && expr.callee.kind === "identifier") {
38
+ return expr.callee.name;
39
+ }
40
+ return "";
41
+ }
42
+ const pluginCalls = slot.list({
43
+ source: SOURCE,
44
+ name: "pluginCalls",
45
+ sortBy: (a, b) => pluginCallName(a).localeCompare(pluginCallName(b)),
46
+ });
47
+ // App-only plugin calls: docs/architecture/plugins/vite.md, "App-only plugin calls".
48
+ const appPlugins = slot.list({
49
+ source: SOURCE,
50
+ name: "appPlugins",
51
+ });
52
+ const resolveAliases = slot.list({
53
+ source: SOURCE,
54
+ name: "resolveAliases",
55
+ // `find` is the key in the emitted Vite `resolve.alias` object; two
56
+ // contributions with the same `find` would silently overwrite when the
57
+ // TS object literal is rendered. Fail loudly at compose time instead.
58
+ uniqueBy: (a) => a.find,
59
+ });
60
+ // Dedupe: docs/architecture/plugins/vite.md, "Singletons and the optimizer".
61
+ const resolveDedupe = slot.list({
62
+ source: SOURCE,
63
+ name: "resolveDedupe",
64
+ sortBy: (a, b) => a.localeCompare(b),
65
+ });
66
+ // Exclude and include: docs/architecture/plugins/vite.md, "Singletons and the optimizer".
67
+ const optimizeExclude = slot.list({
68
+ source: SOURCE,
69
+ name: "optimizeExclude",
70
+ sortBy: (a, b) => a.localeCompare(b),
71
+ });
72
+ const devServerPort = slot.value({
73
+ source: SOURCE,
74
+ name: "devServerPort",
75
+ seed: (ctx) => {
76
+ return ctx.options.port ?? 3000;
77
+ },
78
+ });
79
+ // Dev server proxy: docs/architecture/plugins/vite.md, "Dev server proxy, file access and watching".
80
+ const serverProxy = slot.list({
81
+ source: SOURCE,
82
+ name: "serverProxy",
83
+ sortBy: (a, b) => a.path.localeCompare(b.path),
84
+ // `path` is the key in the emitted `server.proxy` object; duplicates
85
+ // would silently overwrite when rendered. Fail loudly at compose time.
86
+ uniqueBy: (e) => e.path,
87
+ });
88
+ // File access: docs/architecture/plugins/vite.md, "Dev server proxy, file access and watching".
89
+ const fsAllow = slot.list({
90
+ source: SOURCE,
91
+ name: "fsAllow",
92
+ });
93
+ // Watching: docs/architecture/plugins/vite.md, "Dev server proxy, file access and watching".
94
+ const watchIgnored = slot.list({
95
+ source: SOURCE,
96
+ name: "watchIgnored",
97
+ sortBy: (a, b) => a.localeCompare(b),
98
+ });
99
+ // Build output directory: docs/architecture/plugins/vite.md, "Lifecycle contributions".
100
+ const outDir = slot.value({
101
+ source: SOURCE,
102
+ name: "outDir",
103
+ seed: () => null,
104
+ });
105
+ // Client headers: docs/architecture/slot-catalog.md, "`vite.slots.*` (the `vite` plugin)".
106
+ const clientHeaders = slot.map({
107
+ source: SOURCE,
108
+ name: "clientHeaders",
109
+ keyOf: headerKey,
110
+ merge: mergeClientHeader,
111
+ });
112
+ // Null without an `outDir`, or with no plugin call, import or app-only call,
113
+ // so a vite-less config never writes an empty file.
114
+ const viteConfig = slot.derived({
115
+ source: SOURCE,
116
+ name: "viteConfig",
117
+ inputs: {
118
+ configImports,
119
+ pluginCalls,
120
+ appPlugins,
121
+ resolveAliases,
122
+ resolveDedupe,
123
+ optimizeExclude,
124
+ devServerPort,
125
+ outDir,
126
+ serverProxy,
127
+ fsAllow,
128
+ watchIgnored,
129
+ clientHeaders,
130
+ },
131
+ compute: (inp) => {
132
+ if (inp.outDir === null)
133
+ return null;
134
+ if (inp.pluginCalls.length === 0 &&
135
+ inp.configImports.length === 0 &&
136
+ inp.appPlugins.length === 0)
137
+ return null;
138
+ const { appPlugins: app, ...values } = inp;
139
+ return renderViteConfig({
140
+ ...values,
141
+ outDir: inp.outDir,
142
+ configImports: [
143
+ ...inp.configImports,
144
+ ...app.flatMap((a) => a.imports),
145
+ ].sort((a, b) => a.source.localeCompare(b.source)),
146
+ pluginCalls: [...app.map((a) => a.call), ...inp.pluginCalls],
147
+ });
148
+ },
149
+ });
150
+ export const vite = plugin("vite", {
151
+ // The consumer runs vite: its generated config imports it and the dev
152
+ // process and the build step run its bin.
153
+ devDependencies: {
154
+ vite: "^8.3.8",
155
+ },
156
+ label: "Vite",
157
+ schema: viteOptionsSchema,
158
+ slots: {
159
+ configImports,
160
+ pluginCalls,
161
+ appPlugins,
162
+ resolveAliases,
163
+ resolveDedupe,
164
+ optimizeExclude,
165
+ devServerPort,
166
+ outDir,
167
+ serverProxy,
168
+ fsAllow,
169
+ watchIgnored,
170
+ clientHeaders,
171
+ viteConfig,
172
+ },
173
+ contributes: (self) => [
174
+ self.slots.outDir.contribute(() => "dist/client"),
175
+ // No Slotform app is framed: `frame-ancestors` is the standard, and
176
+ // `X-Frame-Options` covers a browser without it.
177
+ self.slots.clientHeaders.contribute(() => ({
178
+ "Content-Security-Policy": "frame-ancestors 'none'",
179
+ "X-Frame-Options": "DENY",
180
+ })),
181
+ self.slots.configImports.contribute(() => ({
182
+ source: "@slotform/vite/preset",
183
+ named: ["excludedImportsPlugin", "providersPlugin", "schemaPlugin"],
184
+ })),
185
+ self.slots.pluginCalls.contribute(() => ({
186
+ kind: "call",
187
+ callee: { kind: "identifier", name: "providersPlugin" },
188
+ args: [],
189
+ })),
190
+ self.slots.pluginCalls.contribute(() => ({
191
+ kind: "call",
192
+ callee: { kind: "identifier", name: "schemaPlugin" },
193
+ args: [],
194
+ })),
195
+ // The optimizer bundles what an excluded package imports (`excludedImportsPlugin`).
196
+ self.slots.pluginCalls.contribute(() => ({
197
+ kind: "call",
198
+ callee: { kind: "identifier", name: "excludedImportsPlugin" },
199
+ args: [],
200
+ })),
201
+ // Dev CORS origin: docs/architecture/plugins/api.md, "CORS and origins".
202
+ // The predicate is `!== undefined`, so `app.origins: []` stays a lockdown.
203
+ api.slots.devCorsOrigins.contribute(async (ctx) => {
204
+ if (ctx.app.origins !== undefined)
205
+ return undefined;
206
+ const port = await ctx.resolve(self.slots.devServerPort);
207
+ return `http://localhost:${port}`;
208
+ }),
209
+ emitArtifact(`${GENERATED_DIR}/vite.config.ts`, self.slots.viteConfig),
210
+ // Dev process: docs/architecture/plugins/vite.md, "Dev server port".
211
+ cliSlots.devProcesses.contribute(async (ctx) => {
212
+ const port = await ctx.resolve(self.slots.devServerPort);
213
+ const opts = self.options;
214
+ return {
215
+ name: "vite",
216
+ command: process.execPath,
217
+ args: [
218
+ viteBin(ctx.cwd),
219
+ "dev",
220
+ "--config",
221
+ `${GENERATED_DIR}/vite.config.ts`,
222
+ ],
223
+ defaultPort: port,
224
+ readyPattern: /Local:/,
225
+ // Default `restart: "never"` — Vite handles HMR; auto-restart
226
+ // on crash usually hides the real failure. Consumer can opt in.
227
+ restart: opts.restart ?? "never",
228
+ maxRestarts: opts.maxRestarts,
229
+ // Use the supervisor's default EADDRINUSE pattern. Explicitly
230
+ // returns `undefined` rather than relying on implicit-void
231
+ // because `() => void` isn't assignable to the spec's
232
+ // `() => { restart: boolean } | undefined` under strict TS.
233
+ onExit: (event) => {
234
+ if (!event.portInUse)
235
+ return undefined;
236
+ const detected = event.detectedPort ?? port;
237
+ ctx.log.error(`vite dev: port :${detected} is in use — set \`vite({ port: ... })\` in slotform.config.ts or stop the process holding it.`);
238
+ return undefined;
239
+ },
240
+ };
241
+ }),
242
+ // Build step: docs/architecture/plugins/vite.md, "Lifecycle contributions".
243
+ cliSlots.buildSteps.contribute((ctx) => ({
244
+ name: "vite-build",
245
+ phase: "main",
246
+ exec: {
247
+ command: process.execPath,
248
+ args: [
249
+ viteBin(ctx.cwd),
250
+ "build",
251
+ "--config",
252
+ `${GENERATED_DIR}/vite.config.ts`,
253
+ ],
254
+ },
255
+ })),
256
+ ],
257
+ });
258
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAIN,iBAAiB,GACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,GAAG,MAAM,CAAC;AAEtB,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AAE7E,8EA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AAM,QAAQ,GAAG,KAAK,CAAC,YAAY,IAAI,IAAI,CAAC;oBAC5C,GAAG,CAAC,GAAG,CAAC,KAAK,CACZ,mBAAmB,QAAQ,gGAAgG,CAC3H,CAAC;oBACF,OAAO,SAAS,CAAC;gBAClB,CAAC;aACD,CAAC;QACH,CAAC,CAAC;QAEF,4EAA4E;QAC5E,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACxC,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,MAAM;YACb,IAAI,EAAE;gBACL,OAAO,EAAE,OAAO,CAAC,QAAQ;gBACzB,IAAI,EAAE;oBACL,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;oBAChB,OAAO;oBACP,UAAU;oBACV,GAAG,aAAa,iBAAiB;iBACjC;aACD;SACD,CAAC,CAAC;KACH;CACD,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ViteConfigValues } from "../types.ts";
2
+ export declare function renderViteConfig(values: ViteConfigValues): string;
3
+ //# sourceMappingURL=codegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../../src/node/codegen.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CA4PjE"}
@@ -0,0 +1,247 @@
1
+ import { posix } from "node:path";
2
+ import { dedupeImports, renderTsSourceFile, } from "@slotform/cli/ast";
3
+ // Renders a Vite config module from the resolved `vite.slots.*` values: docs/architecture/plugins/vite.md, "How it works".
4
+ export function renderViteConfig(values) {
5
+ const imports = dedupeImports([
6
+ { source: "node:url", named: ["fileURLToPath"] },
7
+ {
8
+ source: "vite",
9
+ named: values.fsAllow.length > 0
10
+ ? ["defineConfig", "searchForWorkspaceRoot"]
11
+ : ["defineConfig"],
12
+ },
13
+ ...values.configImports,
14
+ ]);
15
+ const configProps = [
16
+ {
17
+ key: "root",
18
+ value: {
19
+ kind: "call",
20
+ callee: { kind: "identifier", name: "fileURLToPath" },
21
+ args: [
22
+ {
23
+ kind: "new",
24
+ callee: { kind: "identifier", name: "URL" },
25
+ args: [
26
+ { kind: "string", value: "." },
27
+ {
28
+ kind: "member",
29
+ object: { kind: "identifier", name: "import.meta" },
30
+ property: "url",
31
+ },
32
+ ],
33
+ },
34
+ ],
35
+ },
36
+ },
37
+ { key: "publicDir", value: { kind: "string", value: "../public" } },
38
+ {
39
+ key: "build",
40
+ value: {
41
+ kind: "object",
42
+ properties: [
43
+ {
44
+ key: "outDir",
45
+ value: { kind: "string", value: posix.join("..", values.outDir) },
46
+ },
47
+ { key: "emptyOutDir", value: { kind: "boolean", value: true } },
48
+ ],
49
+ },
50
+ },
51
+ {
52
+ key: "plugins",
53
+ value: { kind: "array", items: values.pluginCalls },
54
+ },
55
+ ];
56
+ const serverProps = [];
57
+ if (values.devServerPort > 0) {
58
+ serverProps.push({
59
+ key: "port",
60
+ value: { kind: "number", value: values.devServerPort },
61
+ });
62
+ }
63
+ if (values.serverProxy.length > 0) {
64
+ serverProps.push({
65
+ key: "proxy",
66
+ value: {
67
+ kind: "object",
68
+ properties: values.serverProxy.map((entry) => ({
69
+ key: entry.path,
70
+ value: {
71
+ kind: "object",
72
+ properties: [
73
+ {
74
+ key: "target",
75
+ value: { kind: "string", value: entry.target },
76
+ },
77
+ ...(entry.ws
78
+ ? [
79
+ {
80
+ key: "ws",
81
+ value: { kind: "boolean", value: true },
82
+ },
83
+ ]
84
+ : []),
85
+ ],
86
+ },
87
+ })),
88
+ },
89
+ });
90
+ }
91
+ const headerNames = Object.keys(values.clientHeaders).sort();
92
+ if (headerNames.length > 0) {
93
+ serverProps.push({
94
+ key: "headers",
95
+ value: {
96
+ kind: "object",
97
+ properties: headerNames.map((name) => ({
98
+ key: name,
99
+ value: {
100
+ kind: "string",
101
+ // `name` is a key just read from the object; the index read types it possibly undefined.
102
+ value: values.clientHeaders[name],
103
+ },
104
+ })),
105
+ },
106
+ });
107
+ }
108
+ if (values.fsAllow.length > 0) {
109
+ serverProps.push({
110
+ key: "fs",
111
+ value: {
112
+ kind: "object",
113
+ properties: [
114
+ {
115
+ key: "allow",
116
+ value: {
117
+ kind: "array",
118
+ items: [
119
+ {
120
+ kind: "call",
121
+ callee: {
122
+ kind: "identifier",
123
+ name: "searchForWorkspaceRoot",
124
+ },
125
+ args: [
126
+ {
127
+ kind: "call",
128
+ callee: {
129
+ kind: "member",
130
+ object: { kind: "identifier", name: "process" },
131
+ property: "cwd",
132
+ },
133
+ args: [],
134
+ },
135
+ ],
136
+ },
137
+ ...values.fsAllow,
138
+ ],
139
+ },
140
+ },
141
+ ],
142
+ },
143
+ });
144
+ }
145
+ const watchIgnored = [...new Set(values.watchIgnored)];
146
+ if (watchIgnored.length > 0) {
147
+ serverProps.push({
148
+ key: "watch",
149
+ value: {
150
+ kind: "object",
151
+ properties: [
152
+ {
153
+ key: "ignored",
154
+ value: {
155
+ kind: "array",
156
+ items: watchIgnored.map((glob) => ({
157
+ kind: "string",
158
+ value: glob,
159
+ })),
160
+ },
161
+ },
162
+ ],
163
+ },
164
+ });
165
+ }
166
+ if (serverProps.length > 0) {
167
+ configProps.push({
168
+ key: "server",
169
+ value: { kind: "object", properties: serverProps },
170
+ });
171
+ }
172
+ const resolveProps = [];
173
+ if (values.resolveAliases.length > 0) {
174
+ resolveProps.push({
175
+ key: "alias",
176
+ value: {
177
+ kind: "object",
178
+ properties: values.resolveAliases.map((a) => ({
179
+ key: a.find,
180
+ value: { kind: "string", value: a.replacement },
181
+ })),
182
+ },
183
+ });
184
+ }
185
+ const dedupe = [...new Set(values.resolveDedupe)];
186
+ if (dedupe.length > 0) {
187
+ resolveProps.push({
188
+ key: "dedupe",
189
+ value: {
190
+ kind: "array",
191
+ items: dedupe.map((specifier) => ({
192
+ kind: "string",
193
+ value: specifier,
194
+ })),
195
+ },
196
+ });
197
+ }
198
+ if (resolveProps.length > 0) {
199
+ configProps.push({
200
+ key: "resolve",
201
+ value: { kind: "object", properties: resolveProps },
202
+ });
203
+ }
204
+ // `.tsx` optimizer extension: docs/architecture/plugins/vite.md, "Singletons and the optimizer".
205
+ const exclude = [...new Set(values.optimizeExclude)];
206
+ configProps.push({
207
+ key: "optimizeDeps",
208
+ value: {
209
+ kind: "object",
210
+ properties: [
211
+ {
212
+ key: "extensions",
213
+ value: { kind: "array", items: [{ kind: "string", value: ".tsx" }] },
214
+ },
215
+ ...(exclude.length > 0
216
+ ? [
217
+ {
218
+ key: "exclude",
219
+ value: {
220
+ kind: "array",
221
+ items: exclude.map((name) => ({
222
+ kind: "string",
223
+ value: name,
224
+ })),
225
+ },
226
+ },
227
+ ]
228
+ : []),
229
+ ],
230
+ },
231
+ });
232
+ const spec = {
233
+ imports,
234
+ statements: [
235
+ {
236
+ kind: "export-default",
237
+ value: {
238
+ kind: "call",
239
+ callee: { kind: "identifier", name: "defineConfig" },
240
+ args: [{ kind: "object", properties: configProps }],
241
+ },
242
+ },
243
+ ],
244
+ };
245
+ return renderTsSourceFile(spec);
246
+ }
247
+ //# sourceMappingURL=codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/node/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EACN,aAAa,EACb,kBAAkB,GAIlB,MAAM,mBAAmB,CAAC;AAG3B,2HAA2H;AAC3H,MAAM,UAAU,gBAAgB,CAAC,MAAwB;IACxD,MAAM,OAAO,GAAmB,aAAa,CAAC;QAC7C,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,eAAe,CAAC,EAAE;QAChD;YACC,MAAM,EAAE,MAAM;YACd,KAAK,EACJ,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;gBACxB,CAAC,CAAC,CAAC,cAAc,EAAE,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BACC,IAAI,EAAE,gBAAgB;gBACtB,KAAK,EAAE;oBACN,IAAI,EAAE,MAAM;oBACZ,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE;oBACpD,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;iBACnD;aACD;SACD;KACD,CAAC;IAEF,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function headerKey(name: string): string;
2
+ export declare function mergeCsp(a: string, b: string): string;
3
+ export declare function scriptHash(script: string): string;
4
+ export declare function allowScript(policy: string, source: string): string;
5
+ export declare function mergeClientHeader(a: string, b: string, key: string): string | undefined;
6
+ //# sourceMappingURL=csp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csp.d.ts","sourceRoot":"","sources":["../../src/node/csp.ts"],"names":[],"mappings":"AAOA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAsCD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBrD;AAID,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD;AAgBD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAQlE;AAID,wBAAgB,iBAAiB,CAChC,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,GAAG,EAAE,MAAM,GACT,MAAM,GAAG,SAAS,CAEpB"}