vite-plugin-windmill 1.746.0 → 1.749.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/README.md +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,9 +17,9 @@ This package version tracks Windmill minor releases. New package versions are pu
|
|
|
17
17
|
|
|
18
18
|
<!-- windmill-release:compat-start -->
|
|
19
19
|
|
|
20
|
-
Current release line: `1.
|
|
20
|
+
Current release line: `1.749.x`
|
|
21
21
|
|
|
22
|
-
It currently depends on `windmill-client@^1.
|
|
22
|
+
It currently depends on `windmill-client@^1.749.0` and bundles `rawAppWmillTs.ts` generated from `windmill-labs/windmill@v1.749.0`.
|
|
23
23
|
|
|
24
24
|
<!-- windmill-release:compat-end -->
|
|
25
25
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["requireProjectConnection"],"sources":["../src/project.ts","../src/deploy.ts","../src/dev-runtime-source.ts","../src/generated/upstream-build-runtime.ts","../src/runtime.ts","../src/plugin.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { access, mkdir, readFile, readdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { Policy } from \"windmill-client\";\nimport { parse } from \"yaml\";\n\nimport type {\n PluginOptions,\n Project,\n RawAppField,\n RawAppFileConfig,\n RawAppProject,\n RawAppRunnable,\n} from \"./types.ts\";\n\nconst WMILL_IMPORT_PATTERN = /^(?:\\.\\/|\\/)?wmill(?:\\.ts)?$|^(?:\\.\\.\\/)+wmill(?:\\.ts)?$/;\nconst RAW_APP_FOLDER_SUFFIXES = [\".raw_app\", \"__raw_app\"] as const;\nconst RAW_APP_FILE_NAME = \"raw_app.yaml\";\nconst WMILL_CONFIG_FILE_NAME = \"wmill.yaml\";\nconst DEPLOY_IGNORED_FILE_NAMES = new Set([\n \"AGENTS.md\",\n \"DATATABLES.md\",\n \"package-lock.json\",\n \"raw_app.yaml\",\n \"wmill.d.ts\",\n]);\nconst DEPLOY_IGNORED_DIRECTORIES = new Set([\n \".claude\",\n \"backend\",\n \"dist\",\n \"node_modules\",\n \"sql_to_apply\",\n]);\n\nconst LANGUAGE_BY_EXTENSION = {\n \"bq.sql\": \"bigquery\",\n \"bun.ts\": \"bun\",\n cs: \"csharp\",\n \"deno.ts\": \"deno\",\n \"duckdb.sql\": \"duckdb\",\n \"frontend.js\": \"frontend\",\n go: \"go\",\n gql: \"graphql\",\n java: \"java\",\n \"ms.sql\": \"mssql\",\n \"my.sql\": \"mysql\",\n \"native.ts\": \"nativets\",\n nu: \"nu\",\n \"odb.sql\": \"oracledb\",\n \"pg.sql\": \"postgresql\",\n php: \"php\",\n \"playbook.yml\": \"ansible\",\n ps1: \"powershell\",\n py: \"python3\",\n rb: \"ruby\",\n rs: \"rust\",\n \"sf.sql\": \"snowflake\",\n sh: \"bash\",\n ts: \"bun\",\n} as const satisfies Record<string, string>;\n\nconst isNodeError = (value: unknown): value is NodeJS.ErrnoException =>\n value instanceof Error && \"code\" in value;\n\nconst pathExists = async (filePath: string): Promise<boolean> => {\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n};\n\nconst normalizeToPosix = (value: string): string => value.split(path.sep).join(\"/\");\n\nconst dirnameIfPossible = (value: string): string | undefined => {\n const parent = path.dirname(value);\n return parent === value ? undefined : parent;\n};\n\nconst findUp = async (startDir: string, fileName: string): Promise<string | undefined> => {\n let currentDir = path.resolve(startDir);\n\n while (true) {\n const candidate = path.join(currentDir, fileName);\n if (await pathExists(candidate)) return candidate;\n\n const parentDir = dirnameIfPossible(currentDir);\n if (!parentDir) return undefined;\n\n currentDir = parentDir;\n }\n};\n\nconst parseYamlFile = async <T>(filePath: string): Promise<T> => {\n const content = await readFile(filePath, \"utf8\");\n return parse(content) as T;\n};\n\nconst resolveRoot = async (\n explicitRoot: string | undefined,\n dir: string,\n): Promise<{ path?: string; root: string }> => {\n if (explicitRoot) {\n const root = path.resolve(explicitRoot);\n return {\n path: (await pathExists(path.join(root, WMILL_CONFIG_FILE_NAME)))\n ? path.join(root, WMILL_CONFIG_FILE_NAME)\n : undefined,\n root,\n };\n }\n\n const configPath = await findUp(dir, WMILL_CONFIG_FILE_NAME);\n return {\n path: configPath,\n root: configPath ? path.dirname(configPath) : dir,\n };\n};\n\nconst resolveDir = async (explicitDir: string | undefined): Promise<string> => {\n const candidate = path.resolve(explicitDir ?? process.cwd());\n const rawAppPath = await findUp(candidate, RAW_APP_FILE_NAME);\n if (!rawAppPath) throw new Error(`Could not find ${RAW_APP_FILE_NAME} from ${candidate}`);\n\n return path.dirname(rawAppPath);\n};\n\nconst stripRawAppSuffix = (folderName: string): string | undefined => {\n for (const suffix of RAW_APP_FOLDER_SUFFIXES)\n if (folderName.endsWith(suffix)) return folderName.slice(0, -suffix.length);\n\n return undefined;\n};\n\nexport const inferPath = (dir: string, root: string): string => {\n const relativePath = normalizeToPosix(path.relative(root, dir));\n const segments = relativePath.split(\"/\").filter(Boolean);\n if (segments.length === 0) throw new Error(`Could not infer a Windmill app path from ${dir}`);\n\n const lastSegment = segments.at(-1);\n if (!lastSegment) throw new Error(`Could not infer a Windmill app path from ${dir}`);\n\n const strippedSegment = stripRawAppSuffix(lastSegment);\n if (!strippedSegment) {\n throw new Error(\n `Expected ${dir} to end in .raw_app or __raw_app so the app path can be inferred`,\n );\n }\n\n return [...segments.slice(0, -1), strippedSegment].join(\"/\");\n};\n\nexport const inferBase = (pathValue: string): string => `/apps_raw/get/${pathValue}/`;\n\nconst resolveEntry = async (dir: string, value: string | undefined): Promise<string> => {\n if (value) {\n const entry = path.resolve(dir, value);\n if (!(await pathExists(entry))) throw new Error(`Entry file does not exist: ${entry}`);\n\n return entry;\n }\n\n const tsEntry = path.join(dir, \"index.ts\");\n if (await pathExists(tsEntry)) return tsEntry;\n\n const tsxEntry = path.join(dir, \"index.tsx\");\n if (await pathExists(tsxEntry)) return tsxEntry;\n\n throw new Error(`Could not find index.ts or index.tsx inside ${dir}`);\n};\n\nconst resolveEnv = (options: PluginOptions) => ({\n url: options.url ?? process.env.BASE_INTERNAL_URL ?? process.env.BASE_URL,\n token: options.token ?? process.env.WM_TOKEN,\n workspace: options.workspace ?? process.env.WM_WORKSPACE,\n});\n\nexport const resolveProject = async (options: PluginOptions = {}): Promise<Project> => {\n const dir = await resolveDir(options.dir);\n const { path: config, root } = await resolveRoot(options.root, dir);\n const wmillConfig = config\n ? await parseYamlFile<{ defaultTs?: string; excludes?: string[]; nonDottedPaths?: boolean }>(\n config,\n )\n : {};\n const pathValue = options.path ?? inferPath(dir, root);\n const entry = await resolveEntry(dir, options.entry);\n const { url, token, workspace } = resolveEnv(options);\n\n return {\n base: options.base ?? inferBase(pathValue),\n config,\n dir,\n entry,\n nonDotted: options.nonDotted ?? wmillConfig.nonDottedPaths ?? false,\n path: pathValue,\n root,\n syncExcludes: wmillConfig.excludes ?? [],\n ts: options.ts ?? wmillConfig.defaultTs ?? \"bun\",\n workspace,\n token,\n url,\n yaml: path.join(dir, RAW_APP_FILE_NAME),\n };\n};\n\nconst collectStaticFields = (fields: Record<string, RawAppField> | undefined) =>\n Object.fromEntries(\n Object.entries(fields ?? {})\n .filter(([, field]) => field.type === \"static\")\n .map(([name, field]) => [name, field.value]),\n );\n\nconst createRawscriptHash = (content: string | undefined): string =>\n createHash(\"sha256\")\n .update(content ?? \"\")\n .digest(\"hex\");\n\nconst resolveTriggerableEntry = async (\n runnableId: string,\n runnable: RawAppRunnable,\n): Promise<\n | [\n string,\n { allow_user_resources: string[]; one_of_inputs: {}; static_inputs: Record<string, unknown> },\n ]\n | undefined\n> => {\n const staticInputs = collectStaticFields(runnable.fields);\n const allowUserResources = Object.entries(runnable.fields ?? {})\n .filter(([, field]) => field.allowUserResources)\n .map(([name]) => name);\n\n if (runnable.inlineScript) {\n return [\n `${runnableId}:rawscript/${createRawscriptHash(runnable.inlineScript.content)}`,\n { allow_user_resources: allowUserResources, one_of_inputs: {}, static_inputs: staticInputs },\n ];\n }\n\n if (runnable.path && runnable.runType) {\n const runType = runnable.runType === \"hubscript\" ? \"script\" : runnable.runType;\n return [\n `${runnableId}:${runType}/${runnable.path}`,\n { allow_user_resources: allowUserResources, one_of_inputs: {}, static_inputs: staticInputs },\n ];\n }\n\n return undefined;\n};\n\nexport const generateRawAppPolicy = async (\n runnables: Record<string, RawAppRunnable>,\n policy: RawAppFileConfig[\"policy\"],\n isPublic: boolean,\n): Promise<Policy> => {\n const triggerableEntries = await Promise.all(\n Object.entries(runnables).map(async ([runnableId, runnable]) =>\n resolveTriggerableEntry(runnableId, runnable),\n ),\n );\n\n const resolvedTriggerableEntries = triggerableEntries.filter(\n (\n entry,\n ): entry is [\n string,\n { allow_user_resources: string[]; one_of_inputs: {}; static_inputs: Record<string, unknown> },\n ] => entry !== undefined,\n );\n\n return {\n ...policy,\n execution_mode: isPublic ? \"anonymous\" : \"publisher\",\n triggerables_v2: Object.fromEntries(resolvedTriggerableEntries),\n };\n};\n\nconst resolveRunnableLanguage = (extension: string, ts: string): string | undefined => {\n const language = LANGUAGE_BY_EXTENSION[extension as keyof typeof LANGUAGE_BY_EXTENSION];\n if (!language) return undefined;\n\n return extension === \"ts\" ? ts : language;\n};\n\nconst findRunnableContentFile = async (\n backendDir: string,\n runnableId: string,\n allFileNames: string[],\n): Promise<{ content: string; extension: string } | undefined> => {\n for (const fileName of allFileNames) {\n if (fileName.endsWith(\".yaml\") || fileName.endsWith(\".lock\")) continue;\n\n if (!fileName.startsWith(`${runnableId}.`)) continue;\n\n const extension = fileName.slice(runnableId.length + 1);\n if (!resolveRunnableLanguage(extension, \"bun\")) continue;\n\n return {\n content: await readFile(path.join(backendDir, fileName), \"utf8\"),\n extension,\n };\n }\n\n return undefined;\n};\n\nconst getRunnableIdFromCodeFile = (fileName: string): string | undefined => {\n if (fileName.endsWith(\".yaml\") || fileName.endsWith(\".lock\")) return undefined;\n\n for (const extension of Object.keys(LANGUAGE_BY_EXTENSION))\n if (fileName.endsWith(`.${extension}`)) return fileName.slice(0, -(extension.length + 1));\n\n return undefined;\n};\n\nconst inlinePathPrefix = \"!inline \";\n\nconst dereferenceInlineValue = async (value: unknown, localPath: string): Promise<unknown> => {\n if (typeof value !== \"string\" || !value.startsWith(inlinePathPrefix)) return value;\n\n const relativePath = value.slice(inlinePathPrefix.length);\n return readFile(path.join(localPath, relativePath), \"utf8\");\n};\n\nconst cloneRunnable = async (value: unknown, localPath: string): Promise<unknown> => {\n if (Array.isArray(value))\n return Promise.all(value.map(async (item) => cloneRunnable(item, localPath)));\n\n if (typeof value !== \"object\" || value === null) return dereferenceInlineValue(value, localPath);\n\n const entries = await Promise.all(\n Object.entries(value).map(async ([key, entryValue]) => [\n key,\n await cloneRunnable(entryValue, localPath),\n ]),\n );\n\n return Object.fromEntries(entries);\n};\n\nexport const loadRunnablesFromBackend = async (\n backendDir: string,\n ts = \"bun\",\n): Promise<Record<string, RawAppRunnable>> => {\n const runnables: Record<string, RawAppRunnable> = {};\n\n try {\n const entries = await readdir(backendDir, { withFileTypes: true });\n const allFileNames = entries.filter((entry) => entry.isFile()).map((entry) => entry.name);\n const processedIds = new Set<string>();\n\n for (const fileName of allFileNames) {\n if (!fileName.endsWith(\".yaml\")) continue;\n\n const runnableId = fileName.slice(0, -\".yaml\".length);\n processedIds.add(runnableId);\n const runnable = await parseYamlFile<RawAppRunnable>(path.join(backendDir, fileName));\n if (runnable.type === \"inline\") {\n const contentFile = await findRunnableContentFile(backendDir, runnableId, allFileNames);\n if (contentFile) {\n const lockPath = path.join(backendDir, `${runnableId}.lock`);\n let lock: string | undefined;\n try {\n lock = await readFile(lockPath, \"utf8\");\n } catch (error) {\n if (!isNodeError(error) || error.code !== \"ENOENT\") throw error;\n }\n\n runnable.inlineScript = {\n ...runnable.inlineScript,\n content: contentFile.content,\n language: resolveRunnableLanguage(contentFile.extension, ts),\n ...(lock ? { lock } : {}),\n };\n }\n } else if (\n runnable.type === \"flow\" ||\n runnable.type === \"hubscript\" ||\n runnable.type === \"script\"\n ) {\n const { type, schema: _schema, ...rest } = runnable;\n runnables[runnableId] = {\n ...rest,\n runType: type,\n type: \"path\",\n };\n continue;\n }\n\n runnables[runnableId] = runnable;\n }\n\n for (const fileName of allFileNames) {\n const runnableId = getRunnableIdFromCodeFile(fileName);\n if (!runnableId || processedIds.has(runnableId)) continue;\n\n processedIds.add(runnableId);\n const contentFile = await findRunnableContentFile(backendDir, runnableId, allFileNames);\n if (!contentFile) continue;\n\n const lockPath = path.join(backendDir, `${runnableId}.lock`);\n let lock: string | undefined;\n try {\n lock = await readFile(lockPath, \"utf8\");\n } catch (error) {\n if (!isNodeError(error) || error.code !== \"ENOENT\") throw error;\n }\n\n runnables[runnableId] = {\n inlineScript: {\n content: contentFile.content,\n language: resolveRunnableLanguage(contentFile.extension, ts),\n ...(lock ? { lock } : {}),\n },\n type: \"inline\",\n };\n }\n } catch (error) {\n if (!isNodeError(error) || error.code !== \"ENOENT\") throw error;\n }\n\n return runnables;\n};\n\nconst matchesSyncExclude = (relativePath: string, excludes: string[]): boolean =>\n excludes.some((pattern) => path.posix.matchesGlob(relativePath, pattern));\n\nexport const collectAppFiles = async (\n dir: string,\n options: { excludes?: string[]; root?: string } = {},\n): Promise<Record<string, string>> => {\n const files: Record<string, string> = {};\n const root = options.root ? path.resolve(options.root) : dir;\n const excludes = options.excludes ?? [];\n\n const walk = async (currentDir: string, relativeDir = \"/\"): Promise<void> => {\n const entries = await readdir(currentDir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = path.join(currentDir, entry.name);\n const relativePath = `${relativeDir}${entry.name}`;\n const relativeToRoot = normalizeToPosix(path.relative(root, fullPath));\n\n if (entry.isDirectory()) {\n if (DEPLOY_IGNORED_DIRECTORIES.has(entry.name)) continue;\n\n await walk(fullPath, `${relativePath}/`);\n continue;\n }\n\n if (DEPLOY_IGNORED_FILE_NAMES.has(entry.name)) continue;\n if (matchesSyncExclude(relativeToRoot, excludes)) continue;\n\n files[relativePath] = await readFile(fullPath, \"utf8\");\n }\n };\n\n await walk(dir);\n return files;\n};\n\nexport const loadRawAppProject = async (project: Project): Promise<RawAppProject> => {\n const config = await parseYamlFile<RawAppFileConfig>(project.yaml);\n const backendDir = path.join(project.dir, \"backend\");\n const backendRunnables = await loadRunnablesFromBackend(backendDir, project.ts);\n const rawRunnables =\n Object.keys(backendRunnables).length > 0 ? backendRunnables : (config.runnables ?? {});\n const runnables = (await cloneRunnable(rawRunnables, backendDir)) as Record<\n string,\n RawAppRunnable\n >;\n const files = await collectAppFiles(project.dir, {\n excludes: project.syncExcludes,\n root: project.root,\n });\n const policy = await generateRawAppPolicy(runnables, config.policy, Boolean(config.public));\n const value = {\n ...(config.data !== undefined ? { data: config.data } : {}),\n files,\n runnables,\n };\n\n return {\n config,\n files,\n policy,\n runnables,\n value,\n };\n};\n\nconst createArgsType = (_runnable: RawAppRunnable): string => \"{}\";\n\nconst generateWmillDts = (\n runnables: Record<string, RawAppRunnable>,\n): string => `// THIS FILE IS READ-ONLY\n// AND GENERATED AUTOMATICALLY FROM YOUR RUNNABLES\n\nexport declare const backend: {\n${Object.entries(runnables)\n .map(([name, runnable]) => ` ${name}: (args: ${createArgsType(runnable)}) => Promise<any>`)\n .join(\"\\n\")}\n}\n\nexport declare const backendAsync: {\n${Object.entries(runnables)\n .map(([name, runnable]) => ` ${name}: (args: ${createArgsType(runnable)}) => Promise<string>`)\n .join(\"\\n\")}\n}\n\nexport type Job = {\n type: 'QueuedJob' | 'CompletedJob'\n id: string\n created_at: number\n started_at: number | undefined\n duration_ms: number\n success: boolean\n args: any\n result: any\n}\n\nexport declare function waitJob(id: string): Promise<Job>\nexport declare function getJob(id: string): Promise<Job>\n\nexport type StreamUpdate = {\n new_result_stream?: string\n stream_offset?: number\n}\n\nexport declare function streamJob(id: string, onUpdate?: (data: StreamUpdate) => void): Promise<any>\n`;\n\nexport const writeGeneratedWmillTypes = async (project: Project): Promise<void> => {\n const rawAppProject = await loadRawAppProject(project);\n const filePath = path.join(project.dir, \"wmill.d.ts\");\n const contents = generateWmillDts(rawAppProject.runnables);\n await mkdir(path.dirname(filePath), { recursive: true });\n await writeFile(filePath, contents);\n};\n\nexport { WMILL_IMPORT_PATTERN };\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { ApiError, AppService, setClient } from \"windmill-client\";\n\nimport { loadRawAppProject, resolveProject } from \"./project.ts\";\nimport type { BundleContents, DeployOptions, DeployRawAppResult, Project } from \"./types.ts\";\n\nconst defaultDeploymentMessage = () => {\n const sha = process.env.GITHUB_SHA;\n return sha ? `vite-plugin-windmill deploy ${sha}` : \"vite-plugin-windmill deploy\";\n};\n\nconst requireProjectConnection = (project: Project) => {\n if (!project.workspace)\n throw new Error(\"Missing Windmill workspace. Set `workspace` or `WM_WORKSPACE`.\");\n\n if (!project.token) throw new Error(\"Missing Windmill token. Set `token` or `WM_TOKEN`.\");\n\n if (!project.url)\n throw new Error(\"Missing Windmill URL. Set `url`, `BASE_INTERNAL_URL`, or `BASE_URL`.\");\n\n return {\n url: project.url,\n token: project.token,\n workspace: project.workspace,\n };\n};\n\nconst readBundleFile = async (filePath: string, fallback = \"\"): Promise<string> => {\n try {\n return await readFile(filePath, \"utf8\");\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") return fallback;\n\n throw error;\n }\n};\n\nconst readBundleContents = async (\n dir: string,\n js = path.join(dir, \"dist/windmill/bundle.js\"),\n css = path.join(dir, \"dist/windmill/bundle.css\"),\n): Promise<BundleContents> => ({\n css: await readBundleFile(css, \"\"),\n js: await readBundleFile(js),\n});\n\nconst findExistingRawApp = async (workspace: string, pathValue: string) => {\n try {\n return await AppService.getAppByPath({\n workspace,\n path: pathValue,\n });\n } catch (error) {\n if (error instanceof ApiError && error.status === 404) return undefined;\n\n throw error;\n }\n};\n\n/**\n * Deploys a raw app to Windmill using `windmill-client` instead of shelling out to the CLI.\n */\nexport const deploy = async (options: DeployOptions): Promise<DeployRawAppResult> => {\n const dir = options.dir ?? process.cwd();\n const project = await resolveProject({ ...options, dir });\n const rawAppProject = await loadRawAppProject(project);\n const connection = requireProjectConnection(project);\n const bundles = options.bundles ?? (await readBundleContents(dir, options.js, options.css));\n\n if (!bundles.js) throw new Error(\"Cannot deploy a Windmill raw app without a JavaScript bundle\");\n\n if (options.dry) {\n return {\n action: \"dry-run\",\n base: project.base,\n path: project.path,\n workspace: connection.workspace,\n };\n }\n\n setClient(connection.token, connection.url);\n\n const existingApp = await findExistingRawApp(connection.workspace, project.path);\n\n if (existingApp && !existingApp.raw_app)\n throw new Error(`${project.path} exists remotely but is not a raw app`);\n\n const message = options.message ?? defaultDeploymentMessage();\n const appPayload = {\n ...(rawAppProject.config.custom_path ? { custom_path: rawAppProject.config.custom_path } : {}),\n deployment_message: message,\n path: project.path,\n policy: rawAppProject.policy,\n summary: rawAppProject.config.summary,\n value: rawAppProject.value,\n };\n\n if (existingApp) {\n await AppService.updateAppRaw({\n workspace: connection.workspace,\n path: project.path,\n formData: {\n app: appPayload,\n css: bundles.css,\n js: bundles.js,\n },\n });\n return {\n action: \"update\",\n base: project.base,\n path: project.path,\n workspace: connection.workspace,\n };\n }\n\n await AppService.createAppRaw({\n workspace: connection.workspace,\n formData: {\n app: appPayload,\n css: bundles.css,\n js: bundles.js,\n },\n });\n\n return {\n action: \"create\",\n base: project.base,\n path: project.path,\n workspace: connection.workspace,\n };\n};\n","export const devRuntimeSource = String.raw`\nconst requestJson = async (path, body) => {\n\tconst response = await fetch(path, {\n\t\tmethod: 'POST',\n\t\theaders: { 'content-type': 'application/json' },\n\t\tbody: body ? JSON.stringify(body) : undefined,\n\t})\n\n\tconst payload = await response.json()\n\tif (!response.ok || payload.error) {\n\t\tthrow new Error(\n\t\t\tpayload.error ?? 'Windmill dev request failed with status ' + response.status,\n\t\t)\n\t}\n\n\treturn payload.result\n}\n\nexport const backend = new Proxy(\n\t{},\n\t{\n\t\tget(_, runnableId) {\n\t\t\treturn async (v) =>\n\t\t\t\trequestJson('/__windmill__/backend', { runnableId, args: v ?? {} })\n\t\t},\n\t},\n)\n\nexport const backendAsync = new Proxy(\n\t{},\n\t{\n\t\tget(_, runnableId) {\n\t\t\treturn async (v) =>\n\t\t\t\trequestJson('/__windmill__/backend-async', { runnableId, args: v ?? {} })\n\t\t},\n\t},\n)\n\nexport const waitJob = async (jobId) => requestJson('/__windmill__/wait-job', { jobId })\n\nexport const getJob = async (jobId) => requestJson('/__windmill__/get-job', { jobId })\n\nexport const streamJob = async (jobId, onUpdate) =>\n\tnew Promise((resolve, reject) => {\n\t\tconst source = new EventSource(\n\t\t\t'/__windmill__/stream-job/' + encodeURIComponent(jobId),\n\t\t)\n\n\t\tsource.addEventListener('update', (event) => {\n\t\t\tconst data = JSON.parse(event.data)\n\t\t\tonUpdate?.(data)\n\t\t})\n\n\t\tsource.addEventListener('done', (event) => {\n\t\t\tsource.close()\n\t\t\tresolve(JSON.parse(event.data))\n\t\t})\n\n\t\tsource.addEventListener('error', (event) => {\n\t\t\tsource.close()\n\t\t\tconst message =\n\t\t\t\tevent instanceof MessageEvent && typeof event.data === 'string'\n\t\t\t\t\t? event.data\n\t\t\t\t\t: 'Windmill stream request failed'\n\t\t\treject(new Error(message))\n\t\t})\n\t})\n`;\n","// Generated by scripts/sync-upstream-runtime.mjs\n// Source: https://raw.githubusercontent.com/windmill-labs/windmill/v1.746.0/frontend/src/lib/rawAppWmillTs.ts\n\nexport const UPSTREAM_WINDMILL_VERSION = \"1.746.0\";\nexport const UPSTREAM_WINDMILL_RELEASE_VERSION = \"1.746.0\";\nexport const UPSTREAM_WINDMILL_RELEASE_LINE = \"1.746.x\";\nexport const UPSTREAM_RAW_APP_WMILL_TS_REF = \"v1.746.0\";\nexport const UPSTREAM_RAW_APP_WMILL_TS_URL =\n \"https://raw.githubusercontent.com/windmill-labs/windmill/v1.746.0/frontend/src/lib/rawAppWmillTs.ts\";\nexport const buildRuntimeSource =\n \"let reqs = {};\\nfunction doRequest(type, o, extra) {\\n return new Promise((resolve, reject) => {\\n const reqId = Math.random().toString(36);\\n reqs[reqId] = { resolve, reject, ...extra };\\n const req = { ...o, type, reqId };\\n parent.postMessage(req, '*');\\n });\\n}\\nexport const backend = new Proxy({}, {\\n get(_, runnable_id) {\\n return (v) => {\\n return doRequest('backend', { runnable_id, v });\\n };\\n }\\n});\\nexport const backendAsync = new Proxy({}, {\\n get(_, runnable_id) {\\n return (v) => {\\n return doRequest('backendAsync', { runnable_id, v });\\n };\\n }\\n});\\nexport function waitJob(jobId) {\\n return doRequest('waitJob', { jobId });\\n}\\nexport function getJob(jobId) {\\n return doRequest('getJob', { jobId });\\n}\\n/**\\n * Stream job results using SSE. Calls onUpdate for each stream update,\\n * and resolves with the final result when the job completes.\\n * @param jobId - The job ID to stream\\n * @param onUpdate - Callback for stream updates with new_result_stream data\\n * @returns Promise that resolves with the final job result\\n */\\nexport function streamJob(jobId, onUpdate) {\\n return doRequest('streamJob', { jobId }, { onUpdate });\\n}\\nwindow.addEventListener('message', (e) => {\\n if (e.data.type === 'streamJobUpdate') {\\n // Handle streaming update\\n let job = reqs[e.data.reqId];\\n if (job && job.onUpdate) {\\n job.onUpdate({\\n new_result_stream: e.data.new_result_stream,\\n stream_offset: e.data.stream_offset\\n });\\n }\\n }\\n else if (e.data.type === 'streamJobRes') {\\n // Handle stream completion\\n let job = reqs[e.data.reqId];\\n if (job) {\\n if (e.data.error) {\\n job.reject(new Error(e.data.result?.stack ?? e.data.result?.message ?? 'Stream error'));\\n }\\n else {\\n job.resolve(e.data.result);\\n }\\n delete reqs[e.data.reqId];\\n }\\n }\\n else if (e.data.type === 'backendRes' ||\\n e.data.type === 'backendAsyncRes' ||\\n e.data.type === 'waitJobRes' ||\\n e.data.type === 'getJobRes') {\\n console.log('Message from parent backend', e.data);\\n let job = reqs[e.data.reqId];\\n if (job) {\\n const result = e.data.result;\\n if (e.data.error) {\\n job.reject(new Error(result.stack ?? result.message));\\n }\\n else {\\n job.resolve(result);\\n }\\n delete reqs[e.data.reqId];\\n }\\n else {\\n console.error('No job found for', e.data.reqId);\\n }\\n }\\n});\\n\";\n","import { devRuntimeSource } from \"./dev-runtime-source.ts\";\nimport { buildRuntimeSource } from \"./generated/upstream-build-runtime.ts\";\n\nexport const getWindmillRuntimeSource = (mode: \"build\" | \"serve\"): string =>\n mode === \"serve\" ? devRuntimeSource : buildRuntimeSource;\n\nexport { buildRuntimeSource, devRuntimeSource };\n","import path from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport { scheduler } from \"node:timers/promises\";\n\nimport type { Plugin, Connect, ProxyOptions } from \"vite\";\nimport { loadEnv } from \"vite\";\nimport type { OutputBundle } from \"vite/rolldown\";\nimport { AppService, JobService, setClient, type ExecuteComponentData } from \"windmill-client\";\n\nimport { deploy } from \"./deploy.ts\";\nimport {\n WMILL_IMPORT_PATTERN,\n loadRawAppProject,\n resolveProject,\n writeGeneratedWmillTypes,\n} from \"./project.ts\";\nimport { getWindmillRuntimeSource } from \"./runtime.ts\";\nimport type {\n PluginDeployOptions,\n PluginOptions,\n Project,\n RawAppRunnable,\n WindmillApiProxyOptions,\n} from \"./types.ts\";\nconst VIRTUAL_WMILL_ID = \"virtual:vite-plugin-windmill/wmill\";\nconst RESOLVED_VIRTUAL_WMILL_ID = `\\0${VIRTUAL_WMILL_ID}`;\nconst DEFAULT_BUILD_OUT_DIR = \"dist/windmill\";\nconst DEFAULT_API_PROXY_CONTEXT = \"/api\";\nconst DEPLOY_TRUE_VALUES = new Set([\"\", \"1\", \"on\", \"true\", \"yes\"]);\nconst DEPLOY_FALSE_VALUES = new Set([\"0\", \"false\", \"no\", \"off\"]);\nconst DEPLOY_DRY_VALUES = new Set([\"check\", \"dry\"]);\n\nconst normalizePath = (value: string): string => value.split(path.sep).join(\"/\");\n\nconst buildHtmlDocument = (entryFile: string): string => {\n const entryPath = normalizePath(entryFile.startsWith(\"/\") ? entryFile : `/${entryFile}`);\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Windmill Dev</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/@vite/client\"></script>\n <script type=\"module\" src=\"${entryPath}\"></script>\n </body>\n</html>`;\n};\n\nconst toErrorMessage = (value: unknown): string => {\n if (value instanceof Error) return value.message;\n\n if (typeof value === \"string\") return value;\n\n try {\n return JSON.stringify(value);\n } catch {\n return \"Unknown error\";\n }\n};\n\nconst requireString = (value: unknown, fieldName: string): string => {\n if (typeof value === \"string\" && value.length > 0) return value;\n\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value);\n\n throw new Error(`Missing or invalid ${fieldName}`);\n};\n\nconst requireProjectConnection = (project: Project) => {\n if (!project.workspace)\n throw new Error(\"Missing Windmill workspace. Set `workspace` or `WM_WORKSPACE`.\");\n\n if (!project.token) throw new Error(\"Missing Windmill token. Set `token` or `WM_TOKEN`.\");\n\n if (!project.url)\n throw new Error(\"Missing Windmill URL. Set `url`, `BASE_INTERNAL_URL`, or `BASE_URL`.\");\n\n return {\n url: project.url,\n token: project.token,\n workspace: project.workspace,\n };\n};\n\nconst readJsonBody = async (request: NodeJS.ReadableStream): Promise<Record<string, unknown>> => {\n const chunks: Uint8Array[] = [];\n for await (const chunk of request)\n chunks.push(typeof chunk === \"string\" ? Buffer.from(chunk) : chunk);\n\n if (chunks.length === 0) return {};\n\n return JSON.parse(Buffer.concat(chunks).toString(\"utf8\")) as Record<string, unknown>;\n};\n\nconst waitForJobResult = async (workspace: string, jobId: string): Promise<unknown> => {\n let delay = 50;\n for (;;) {\n const result = await JobService.getCompletedJobResultMaybe({\n workspace,\n id: jobId,\n getStarted: false,\n });\n\n if (result.completed) {\n if (\n !result.success &&\n typeof result.result === \"object\" &&\n result.result &&\n \"error\" in result.result\n )\n throw new Error(toErrorMessage((result.result as { error?: unknown }).error));\n\n return result.result;\n }\n\n await scheduler.wait(delay);\n delay = delay >= 500 ? 2_000 : 500;\n }\n};\n\nconst executeRunnable = async (\n project: Project,\n workspace: string,\n runnableId: string,\n runnable: RawAppRunnable,\n args: unknown,\n): Promise<string> => {\n const requestBody: ExecuteComponentData[\"requestBody\"] = {\n args: (args ?? {}) as Record<string, unknown>,\n component: runnableId,\n force_viewer_allow_user_resources: Object.entries(runnable.fields ?? {})\n .filter(([, field]) => field.allowUserResources)\n .map(([name]) => name),\n force_viewer_one_of_fields: {},\n force_viewer_static_fields: Object.fromEntries(\n Object.entries(runnable.fields ?? {})\n .filter(([, field]) => field.type === \"static\")\n .map(([name, field]) => [name, field.value]),\n ),\n };\n\n if (runnable.inlineScript) {\n requestBody.raw_code = {\n cache_ttl: runnable.inlineScript.cache_ttl,\n content: runnable.inlineScript.id === undefined ? (runnable.inlineScript.content ?? \"\") : \"\",\n language: runnable.inlineScript.language ?? \"\",\n lock: runnable.inlineScript.id === undefined ? runnable.inlineScript.lock : undefined,\n path: `${project.path}/${runnableId}`,\n };\n if (runnable.inlineScript.id !== undefined) requestBody.id = runnable.inlineScript.id;\n } else if (runnable.path && runnable.runType)\n requestBody.path = `${runnable.runType === \"hubscript\" ? \"script\" : runnable.runType}/${runnable.path}`;\n else throw new Error(`Runnable ${runnableId} is missing inline or path metadata`);\n\n return AppService.executeComponent({\n workspace,\n path: project.path,\n requestBody,\n });\n};\n\nconst extractBundleContents = (bundle: OutputBundle) => {\n let css = \"\";\n let js = \"\";\n\n for (const output of Object.values(bundle)) {\n if (output.type === \"chunk\" && output.fileName === \"bundle.js\") js = output.code;\n\n if (output.type === \"asset\" && output.fileName === \"bundle.css\") {\n css =\n typeof output.source === \"string\"\n ? output.source\n : Buffer.from(output.source).toString(\"utf8\");\n }\n }\n\n return { css, js };\n};\n\nconst hasAuthorizationHeader = (headers: ProxyOptions[\"headers\"]): boolean =>\n Object.keys(headers ?? {}).some((key) => key.toLowerCase() === \"authorization\");\n\nconst resolveApiProxyConfig = (\n project: Project,\n proxy: PluginOptions[\"proxy\"],\n): Record<string, ProxyOptions> | undefined => {\n if (proxy === false) return undefined;\n\n const proxyOptions =\n proxy && typeof proxy === \"object\" ? ({ ...proxy } as WindmillApiProxyOptions) : undefined;\n const enabled = typeof proxy === \"object\" ? (proxy.enabled ?? true) : (proxy ?? true);\n if (!enabled) return undefined;\n\n const context = proxyOptions?.context ?? DEFAULT_API_PROXY_CONTEXT;\n const target = proxyOptions?.target ?? project.url;\n if (!target) return undefined;\n\n const {\n context: _context,\n enabled: _enabled,\n target: _target,\n token,\n ...rest\n } = proxyOptions ?? {};\n const headers = { ...rest.headers };\n const resolvedToken = token ?? project.token;\n if (!hasAuthorizationHeader(headers) && resolvedToken)\n headers.Authorization = `Bearer ${resolvedToken}`;\n\n return {\n [context]: {\n changeOrigin: rest.changeOrigin ?? true,\n ...rest,\n headers,\n target,\n },\n };\n};\n\nconst resolveProjectFromViteConfig = async (\n options: PluginOptions,\n root: string | undefined,\n mode: string,\n): Promise<Project> => {\n const env = loadEnv(mode, root ?? process.cwd(), \"\");\n\n return resolveProject({\n ...options,\n dir: root ?? options.dir,\n token: options.token ?? env.WM_TOKEN ?? process.env.WM_TOKEN,\n url:\n options.url ??\n env.BASE_INTERNAL_URL ??\n env.BASE_URL ??\n process.env.BASE_INTERNAL_URL ??\n process.env.BASE_URL,\n workspace: options.workspace ?? env.WM_WORKSPACE ?? process.env.WM_WORKSPACE,\n });\n};\n\nconst normalizeDeployOptions = (\n deployOptions: PluginOptions[\"deploy\"],\n): PluginDeployOptions | undefined => {\n if (typeof deployOptions === \"boolean\") return { deploy: deployOptions };\n if (!deployOptions) return undefined;\n\n return {\n deploy: deployOptions.deploy ?? true,\n dry: deployOptions.dry,\n message: deployOptions.message,\n };\n};\n\nconst parseDeployEnv = (value: string | undefined): PluginDeployOptions | undefined => {\n if (value === undefined) return undefined;\n\n const normalized = value.trim().toLowerCase();\n if (normalized === \"undefined\" || normalized === \"null\") return undefined;\n if (DEPLOY_TRUE_VALUES.has(normalized)) return { deploy: true };\n if (DEPLOY_FALSE_VALUES.has(normalized)) return { deploy: false };\n if (DEPLOY_DRY_VALUES.has(normalized)) return { deploy: true, dry: true };\n\n throw new Error(`Invalid WM_DEPLOY value \\`${value}\\`. Expected boolean-like values or \\`dry\\`.`);\n};\n\nconst resolveDeployOptions = (\n options: PluginOptions,\n root: string | undefined,\n mode: string,\n): PluginDeployOptions => {\n const explicitDeploy = normalizeDeployOptions(options.deploy);\n if (explicitDeploy) return explicitDeploy;\n\n const env = loadEnv(mode, root ?? process.cwd(), \"\");\n return parseDeployEnv(env.WM_DEPLOY ?? process.env.WM_DEPLOY) ?? { deploy: false };\n};\n\n/**\n * Generates the HTML host shell for `vite preview`. It embeds the production IIFE bundle\n * in a same-origin blob-URL iframe, mirroring how Windmill renders raw apps, and relays\n * postMessage backend requests to the local /__windmill__/ HTTP proxy.\n */\nconst buildPreviewHostShellHtml = (workspace: string): string => `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Windmill Preview</title>\n <style>html,body{margin:0;padding:0;width:100%;height:100%;overflow:hidden}iframe{position:fixed;inset:0;width:100%;height:100%;border:none}</style>\n</head>\n<body>\n <iframe id=\"app\" title=\"raw-app\" sandbox=\"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads allow-modals allow-pointer-lock allow-presentation allow-storage-access-by-user-activation allow-top-navigation-by-user-activation\"></iframe>\n <script type=\"module\">\n window.localStorage.setItem('workspace', ${JSON.stringify(workspace)})\n\n window.addEventListener('message', async ({ data: msg }) => {\n if (!msg?.type || !msg?.reqId) return\n const { type, reqId } = msg\n const frame = document.getElementById('app')\n const send = (result, error) =>\n frame.contentWindow?.postMessage({ type: type + 'Res', reqId, result, error: !!error }, '*')\n\n try {\n if (type === 'backend' || type === 'backendAsync') {\n const ep = type === 'backend' ? '/__windmill__/backend' : '/__windmill__/backend-async'\n const r = await fetch(ep, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ runnableId: msg.runnable_id, args: msg.v ?? {} }),\n })\n const p = await r.json()\n send(p.result, !!p.error)\n } else if (type === 'waitJob') {\n const r = await fetch('/__windmill__/wait-job', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ jobId: msg.jobId }),\n })\n const p = await r.json()\n send(p.result, !!p.error)\n } else if (type === 'getJob') {\n const r = await fetch('/__windmill__/get-job', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ jobId: msg.jobId }),\n })\n const p = await r.json()\n send(p.result, !!p.error)\n } else if (type === 'streamJob') {\n const source = new EventSource('/__windmill__/stream-job/' + encodeURIComponent(msg.jobId))\n source.addEventListener('update', (e) =>\n frame.contentWindow?.postMessage({ type: 'streamJobUpdate', reqId, ...JSON.parse(e.data) }, '*'))\n source.addEventListener('done', (e) => { source.close(); send(JSON.parse(e.data), false) })\n source.addEventListener('error', () => { source.close(); send({ message: 'Stream error' }, true) })\n }\n } catch (err) {\n send({ message: err?.message ?? String(err) }, true)\n }\n })\n\n // Fetch the production bundle, wrap it in a blob URL, and load it into the iframe.\n // Using a blob URL makes window.location.protocol === 'blob:' inside the iframe,\n // which matches the production Windmill embedding behaviour.\n const [cssRes, jsRes] = await Promise.all([fetch('/bundle.css'), fetch('/bundle.js')])\n const [css, js] = await Promise.all([cssRes.text(), jsRes.text()])\n const html = '<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\">'\n + (css ? '<style>' + css + '</style>' : '')\n + '</head><body><div id=\"root\"></div><script>'\n + js + '<\\\\/script></body></html>'\n document.getElementById('app').src = URL.createObjectURL(new Blob([html], { type: 'text/html' }))\n </script>\n</body>\n</html>`;\n\n/**\n * Creates a Vite plugin that aligns a SPA with Windmill raw-app build and deploy behavior.\n */\nconst windmill = (options: PluginOptions = {}): Plugin => {\n let project: Project | undefined;\n let command: \"build\" | \"serve\" = \"serve\";\n let deployOptions: PluginDeployOptions = { deploy: false };\n\n /**\n * Shared Connect middleware that handles all /__windmill__/ API routes.\n * Used by both the dev server and the preview server.\n */\n const windmillApiHandler: Connect.NextHandleFunction = async (request, response, next) => {\n try {\n if (!project) return next();\n\n const sendJson = (payload: unknown) => response.end(JSON.stringify(payload));\n\n const connection = requireProjectConnection(project);\n setClient(connection.token, connection.url);\n\n if (request.url === \"/__windmill__/backend\" && request.method === \"POST\") {\n try {\n const body = await readJsonBody(request);\n const rawAppProject = await loadRawAppProject(project);\n const runnableId = requireString(body.runnableId, \"runnableId\");\n const runnable = rawAppProject.runnables[runnableId];\n if (!runnable) throw new Error(`Runnable not found: ${runnableId}`);\n\n const jobId = await executeRunnable(\n project,\n connection.workspace,\n runnableId,\n runnable,\n body.args,\n );\n const result = await waitForJobResult(connection.workspace, jobId);\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ result });\n } catch (error) {\n response.statusCode = 500;\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ error: toErrorMessage(error) });\n }\n return;\n }\n\n if (request.url === \"/__windmill__/backend-async\" && request.method === \"POST\") {\n try {\n const body = await readJsonBody(request);\n const rawAppProject = await loadRawAppProject(project);\n const runnableId = requireString(body.runnableId, \"runnableId\");\n const runnable = rawAppProject.runnables[runnableId];\n if (!runnable) throw new Error(`Runnable not found: ${runnableId}`);\n\n const jobId = await executeRunnable(\n project,\n connection.workspace,\n runnableId,\n runnable,\n body.args,\n );\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ result: jobId });\n } catch (error) {\n response.statusCode = 500;\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ error: toErrorMessage(error) });\n }\n return;\n }\n\n if (request.url === \"/__windmill__/wait-job\" && request.method === \"POST\") {\n try {\n const body = await readJsonBody(request);\n const result = await waitForJobResult(\n connection.workspace,\n requireString(body.jobId, \"jobId\"),\n );\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ result });\n } catch (error) {\n response.statusCode = 500;\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ error: toErrorMessage(error) });\n }\n return;\n }\n\n if (request.url === \"/__windmill__/get-job\" && request.method === \"POST\") {\n try {\n const body = await readJsonBody(request);\n const result = await JobService.getJob({\n workspace: connection.workspace,\n id: requireString(body.jobId, \"jobId\"),\n });\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ result });\n } catch (error) {\n response.statusCode = 500;\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ error: toErrorMessage(error) });\n }\n return;\n }\n\n if (request.url?.startsWith(\"/__windmill__/stream-job/\") && request.method === \"GET\") {\n try {\n const jobId = decodeURIComponent(request.url.slice(\"/__windmill__/stream-job/\".length));\n response.setHeader(\"cache-control\", \"no-cache\");\n response.setHeader(\"content-type\", \"text/event-stream\");\n response.setHeader(\"connection\", \"keep-alive\");\n const sseResponse = await fetch(\n `${connection.url.replace(/\\/$/, \"\")}/api/w/${connection.workspace}/jobs_u/getupdate_sse/${jobId}?fast=true`,\n {\n headers: {\n accept: \"text/event-stream\",\n authorization: `Bearer ${connection.token}`,\n },\n },\n );\n\n if (!sseResponse.ok || !sseResponse.body)\n throw new Error(`Failed to stream Windmill job ${jobId}`);\n\n const reader = Readable.fromWeb(sseResponse.body);\n let buffer = \"\";\n for await (const chunk of reader) {\n buffer += chunk.toString();\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n\n const payload = JSON.parse(line.slice(\"data: \".length)) as {\n completed?: boolean;\n error?: string;\n new_result_stream?: string;\n only_result?: unknown;\n stream_offset?: number;\n type?: string;\n };\n\n if (payload.type === \"ping\") continue;\n\n if (payload.type === \"timeout\") {\n response.write(`event: error\\ndata: ${JSON.stringify(\"Stream timed out\")}\\n\\n`);\n response.end();\n return;\n }\n\n if (payload.type === \"error\") {\n response.write(\n `event: error\\ndata: ${JSON.stringify(payload.error ?? \"Stream error\")}\\n\\n`,\n );\n response.end();\n return;\n }\n\n if (payload.new_result_stream !== undefined) {\n response.write(\n `event: update\\ndata: ${JSON.stringify({ new_result_stream: payload.new_result_stream, stream_offset: payload.stream_offset })}\\n\\n`,\n );\n }\n\n if (payload.completed) {\n response.write(`event: done\\ndata: ${JSON.stringify(payload.only_result)}\\n\\n`);\n response.end();\n return;\n }\n }\n }\n\n response.end();\n } catch (error) {\n response.write(`event: error\\ndata: ${JSON.stringify(toErrorMessage(error))}\\n\\n`);\n response.end();\n }\n return;\n }\n\n next();\n } catch (error) {\n next(error);\n }\n };\n\n return {\n name: \"vite-plugin-windmill\",\n async config(userConfig, env) {\n project = await resolveProjectFromViteConfig(options, userConfig.root, env.mode);\n command = env.command;\n deployOptions = resolveDeployOptions(options, userConfig.root, env.mode);\n\n const isServe = env.command === \"serve\";\n const apiProxy = resolveApiProxyConfig(project, options.proxy);\n\n return {\n appType: \"custom\",\n // In serve mode (dev + preview), use '/' so Vite's base middleware does not\n // intercept /__windmill__/ backend routes. The Windmill app base only matters\n // for the production IIFE bundle (asset URL resolution inside the iframe).\n base: isServe ? \"/\" : project.base,\n // Always set outDir so that `vite preview` serves from the same directory\n // that `vite build` writes to.\n build: {\n chunkSizeWarningLimit: 2_048,\n outDir: DEFAULT_BUILD_OUT_DIR,\n ...(isServe\n ? {}\n : {\n assetsInlineLimit: Number.MAX_SAFE_INTEGER,\n cssCodeSplit: false,\n modulePreload: false,\n reportCompressedSize: false,\n rolldownOptions: {\n input: project.entry,\n output: {\n assetFileNames: (assetInfo) =>\n assetInfo.name?.endsWith(\".css\")\n ? \"bundle.css\"\n : \"assets/[name]-[hash][extname]\",\n entryFileNames: \"bundle.js\",\n format: \"iife\",\n },\n },\n }),\n },\n ...(isServe ? { publicDir: false } : {}),\n define: {\n \"process.env.NODE_ENV\": JSON.stringify(isServe ? \"development\" : \"production\"),\n },\n preview: {\n open: false,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n server: {\n open: false,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n };\n },\n async configResolved(resolvedConfig) {\n project = await resolveProjectFromViteConfig(\n options,\n resolvedConfig.root,\n resolvedConfig.mode,\n );\n deployOptions = resolveDeployOptions(options, resolvedConfig.root, resolvedConfig.mode);\n await writeGeneratedWmillTypes(project);\n },\n resolveId(id) {\n if (WMILL_IMPORT_PATTERN.test(id)) return RESOLVED_VIRTUAL_WMILL_ID;\n\n return undefined;\n },\n load(id) {\n if (id === RESOLVED_VIRTUAL_WMILL_ID) return getWindmillRuntimeSource(command);\n\n return undefined;\n },\n configurePreviewServer(previewServer) {\n return () => {\n // Serve the host shell HTML for any HTML GET that Vite's static middleware\n // did not handle (no index.html in the build output directory).\n const previewHandler: Connect.NextHandleFunction = async (request, response, next) => {\n if (!project) return next();\n\n const acceptsHtml = request.headers.accept?.includes(\"text/html\") ?? false;\n const url = request.url ?? \"/\";\n if (\n request.method === \"GET\" &&\n !url.startsWith(\"/__windmill__/\") &&\n (acceptsHtml || (!path.extname(url) && !url.includes(\"?\")))\n ) {\n if (!project.workspace)\n throw new Error(\"Missing Windmill workspace. Set `workspace` or `WM_WORKSPACE`.\");\n response.setHeader(\"content-type\", \"text/html\");\n response.end(buildPreviewHostShellHtml(project.workspace));\n return;\n }\n\n // oxlint-disable-next-line promise/no-callback-in-promise\n return Promise.resolve(windmillApiHandler(request, response, next)).catch(next);\n };\n\n previewServer.middlewares.use((req, res, next) =>\n // oxlint-disable-next-line promise/no-callback-in-promise\n Promise.resolve(previewHandler(req, res, next)).catch(next),\n );\n };\n },\n configureServer(configuredServer) {\n return () => {\n const handler: Connect.NextHandleFunction = async (request, response, next) => {\n try {\n if (!project) return next();\n\n // Delegate all /__windmill__/ API requests to the shared handler.\n if (request.url?.startsWith(\"/__windmill__/\")) {\n // oxlint-disable-next-line promise/no-callback-in-promise\n return Promise.resolve(windmillApiHandler(request, response, next)).catch(next);\n }\n\n // Serve the app HTML for all extensionless GET requests (SPA routing).\n // Do not gate on Accept: text/html — health-check tools and Playwright\n // webServer readiness probes send plain GET requests without that header.\n const url = request.url ?? \"/\";\n if (request.method === \"GET\" && !path.extname(url) && !url.includes(\"?\")) {\n const entryRelative = normalizePath(path.relative(project.dir, project.entry));\n const html = await configuredServer.transformIndexHtml(\n url,\n buildHtmlDocument(entryRelative),\n );\n response.setHeader(\"content-type\", \"text/html\");\n response.end(html);\n return;\n }\n\n next();\n } catch (error) {\n next(error);\n }\n };\n\n configuredServer.middlewares.use((req, res, next) =>\n // oxlint-disable-next-line promise/no-callback-in-promise\n Promise.resolve(handler(req, res, next)).catch(next),\n );\n };\n },\n async handleHotUpdate(context) {\n if (!project) return;\n\n if (\n context.file.startsWith(path.join(project.dir, \"backend\")) ||\n context.file === project.yaml\n ) {\n await writeGeneratedWmillTypes(project);\n context.server.ws.send({ type: \"full-reload\" });\n return;\n }\n },\n async writeBundle(_outputOptions, bundle) {\n if (!project) return;\n\n if (!deployOptions.deploy) return;\n\n const result = await deploy({\n base: project.base,\n bundles: extractBundleContents(bundle),\n dir: project.dir,\n dry: deployOptions.dry,\n message: deployOptions.message ?? options.message,\n path: project.path,\n root: project.root,\n token: project.token,\n url: project.url,\n workspace: project.workspace,\n });\n\n this.info(\n result.action === \"dry-run\"\n ? `Windmill deploy dry-run ready for ${result.path}`\n : `Windmill raw app ${result.action}d: ${result.path}`,\n );\n },\n };\n};\n\nexport default windmill;\n"],"mappings":";;;;;;;;;AAgBA,MAAM,uBAAuB;AAC7B,MAAM,0BAA0B,CAAC,YAAY,YAAY;AACzD,MAAM,oBAAoB;AAC1B,MAAM,yBAAyB;AAC/B,MAAM,4BAA4B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;CACD,CAAC;AACF,MAAM,6BAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,wBAAwB;CAC5B,UAAU;CACV,UAAU;CACV,IAAI;CACJ,WAAW;CACX,cAAc;CACd,eAAe;CACf,IAAI;CACJ,KAAK;CACL,MAAM;CACN,UAAU;CACV,UAAU;CACV,aAA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AAK,KAAK,QAAQ,KAAK,UAAU,CAAC,IAC1D,QAAQ,SAAS,QAAQ,MACzB;AACA,UAAM,yBAAyB,QAAQ;AACvC,YAAQ,OAAO,GAAG,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/C;;;EAGJ,MAAM,YAAY,gBAAgB,QAAQ;AACxC,OAAI,CAAC,QAAS;AAEd,OAAI,CAAC,cAAc,OAAQ;GAE3B,MAAM,SAAS,MAAM,OAAO;IAC1B,MAAM,QAAQ;IACd,SAAS,sBAAsB,OAAO;IACtC,KAAK,QAAQ;IACb,KAAK,cAAc;IACnB,SAAS,cAAc,WAAW,QAAQ;IAC1C,MAAM,QAAQ;IACd,MAAM,QAAQ;IACd,OAAO,QAAQ;IACf,KAAK,QAAQ;IACb,WAAW,QAAQ;IACpB,CAAC;AAEF,QAAK,KACH,OAAO,WAAW,YACd,qCAAqC,OAAO,SAC5C,oBAAoB,OAAO,OAAO,KAAK,OAAO,OACnD;;EAEJ"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["requireProjectConnection"],"sources":["../src/project.ts","../src/deploy.ts","../src/dev-runtime-source.ts","../src/generated/upstream-build-runtime.ts","../src/runtime.ts","../src/plugin.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { access, mkdir, readFile, readdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport type { Policy } from \"windmill-client\";\nimport { parse } from \"yaml\";\n\nimport type {\n PluginOptions,\n Project,\n RawAppField,\n RawAppFileConfig,\n RawAppProject,\n RawAppRunnable,\n} from \"./types.ts\";\n\nconst WMILL_IMPORT_PATTERN = /^(?:\\.\\/|\\/)?wmill(?:\\.ts)?$|^(?:\\.\\.\\/)+wmill(?:\\.ts)?$/;\nconst RAW_APP_FOLDER_SUFFIXES = [\".raw_app\", \"__raw_app\"] as const;\nconst RAW_APP_FILE_NAME = \"raw_app.yaml\";\nconst WMILL_CONFIG_FILE_NAME = \"wmill.yaml\";\nconst DEPLOY_IGNORED_FILE_NAMES = new Set([\n \"AGENTS.md\",\n \"DATATABLES.md\",\n \"package-lock.json\",\n \"raw_app.yaml\",\n \"wmill.d.ts\",\n]);\nconst DEPLOY_IGNORED_DIRECTORIES = new Set([\n \".claude\",\n \"backend\",\n \"dist\",\n \"node_modules\",\n \"sql_to_apply\",\n]);\n\nconst LANGUAGE_BY_EXTENSION = {\n \"bq.sql\": \"bigquery\",\n \"bun.ts\": \"bun\",\n cs: \"csharp\",\n \"deno.ts\": \"deno\",\n \"duckdb.sql\": \"duckdb\",\n \"frontend.js\": \"frontend\",\n go: \"go\",\n gql: \"graphql\",\n java: \"java\",\n \"ms.sql\": \"mssql\",\n \"my.sql\": \"mysql\",\n \"native.ts\": \"nativets\",\n nu: \"nu\",\n \"odb.sql\": \"oracledb\",\n \"pg.sql\": \"postgresql\",\n php: \"php\",\n \"playbook.yml\": \"ansible\",\n ps1: \"powershell\",\n py: \"python3\",\n rb: \"ruby\",\n rs: \"rust\",\n \"sf.sql\": \"snowflake\",\n sh: \"bash\",\n ts: \"bun\",\n} as const satisfies Record<string, string>;\n\nconst isNodeError = (value: unknown): value is NodeJS.ErrnoException =>\n value instanceof Error && \"code\" in value;\n\nconst pathExists = async (filePath: string): Promise<boolean> => {\n try {\n await access(filePath);\n return true;\n } catch {\n return false;\n }\n};\n\nconst normalizeToPosix = (value: string): string => value.split(path.sep).join(\"/\");\n\nconst dirnameIfPossible = (value: string): string | undefined => {\n const parent = path.dirname(value);\n return parent === value ? undefined : parent;\n};\n\nconst findUp = async (startDir: string, fileName: string): Promise<string | undefined> => {\n let currentDir = path.resolve(startDir);\n\n while (true) {\n const candidate = path.join(currentDir, fileName);\n if (await pathExists(candidate)) return candidate;\n\n const parentDir = dirnameIfPossible(currentDir);\n if (!parentDir) return undefined;\n\n currentDir = parentDir;\n }\n};\n\nconst parseYamlFile = async <T>(filePath: string): Promise<T> => {\n const content = await readFile(filePath, \"utf8\");\n return parse(content) as T;\n};\n\nconst resolveRoot = async (\n explicitRoot: string | undefined,\n dir: string,\n): Promise<{ path?: string; root: string }> => {\n if (explicitRoot) {\n const root = path.resolve(explicitRoot);\n return {\n path: (await pathExists(path.join(root, WMILL_CONFIG_FILE_NAME)))\n ? path.join(root, WMILL_CONFIG_FILE_NAME)\n : undefined,\n root,\n };\n }\n\n const configPath = await findUp(dir, WMILL_CONFIG_FILE_NAME);\n return {\n path: configPath,\n root: configPath ? path.dirname(configPath) : dir,\n };\n};\n\nconst resolveDir = async (explicitDir: string | undefined): Promise<string> => {\n const candidate = path.resolve(explicitDir ?? process.cwd());\n const rawAppPath = await findUp(candidate, RAW_APP_FILE_NAME);\n if (!rawAppPath) throw new Error(`Could not find ${RAW_APP_FILE_NAME} from ${candidate}`);\n\n return path.dirname(rawAppPath);\n};\n\nconst stripRawAppSuffix = (folderName: string): string | undefined => {\n for (const suffix of RAW_APP_FOLDER_SUFFIXES)\n if (folderName.endsWith(suffix)) return folderName.slice(0, -suffix.length);\n\n return undefined;\n};\n\nexport const inferPath = (dir: string, root: string): string => {\n const relativePath = normalizeToPosix(path.relative(root, dir));\n const segments = relativePath.split(\"/\").filter(Boolean);\n if (segments.length === 0) throw new Error(`Could not infer a Windmill app path from ${dir}`);\n\n const lastSegment = segments.at(-1);\n if (!lastSegment) throw new Error(`Could not infer a Windmill app path from ${dir}`);\n\n const strippedSegment = stripRawAppSuffix(lastSegment);\n if (!strippedSegment) {\n throw new Error(\n `Expected ${dir} to end in .raw_app or __raw_app so the app path can be inferred`,\n );\n }\n\n return [...segments.slice(0, -1), strippedSegment].join(\"/\");\n};\n\nexport const inferBase = (pathValue: string): string => `/apps_raw/get/${pathValue}/`;\n\nconst resolveEntry = async (dir: string, value: string | undefined): Promise<string> => {\n if (value) {\n const entry = path.resolve(dir, value);\n if (!(await pathExists(entry))) throw new Error(`Entry file does not exist: ${entry}`);\n\n return entry;\n }\n\n const tsEntry = path.join(dir, \"index.ts\");\n if (await pathExists(tsEntry)) return tsEntry;\n\n const tsxEntry = path.join(dir, \"index.tsx\");\n if (await pathExists(tsxEntry)) return tsxEntry;\n\n throw new Error(`Could not find index.ts or index.tsx inside ${dir}`);\n};\n\nconst resolveEnv = (options: PluginOptions) => ({\n url: options.url ?? process.env.BASE_INTERNAL_URL ?? process.env.BASE_URL,\n token: options.token ?? process.env.WM_TOKEN,\n workspace: options.workspace ?? process.env.WM_WORKSPACE,\n});\n\nexport const resolveProject = async (options: PluginOptions = {}): Promise<Project> => {\n const dir = await resolveDir(options.dir);\n const { path: config, root } = await resolveRoot(options.root, dir);\n const wmillConfig = config\n ? await parseYamlFile<{ defaultTs?: string; excludes?: string[]; nonDottedPaths?: boolean }>(\n config,\n )\n : {};\n const pathValue = options.path ?? inferPath(dir, root);\n const entry = await resolveEntry(dir, options.entry);\n const { url, token, workspace } = resolveEnv(options);\n\n return {\n base: options.base ?? inferBase(pathValue),\n config,\n dir,\n entry,\n nonDotted: options.nonDotted ?? wmillConfig.nonDottedPaths ?? false,\n path: pathValue,\n root,\n syncExcludes: wmillConfig.excludes ?? [],\n ts: options.ts ?? wmillConfig.defaultTs ?? \"bun\",\n workspace,\n token,\n url,\n yaml: path.join(dir, RAW_APP_FILE_NAME),\n };\n};\n\nconst collectStaticFields = (fields: Record<string, RawAppField> | undefined) =>\n Object.fromEntries(\n Object.entries(fields ?? {})\n .filter(([, field]) => field.type === \"static\")\n .map(([name, field]) => [name, field.value]),\n );\n\nconst createRawscriptHash = (content: string | undefined): string =>\n createHash(\"sha256\")\n .update(content ?? \"\")\n .digest(\"hex\");\n\nconst resolveTriggerableEntry = async (\n runnableId: string,\n runnable: RawAppRunnable,\n): Promise<\n | [\n string,\n { allow_user_resources: string[]; one_of_inputs: {}; static_inputs: Record<string, unknown> },\n ]\n | undefined\n> => {\n const staticInputs = collectStaticFields(runnable.fields);\n const allowUserResources = Object.entries(runnable.fields ?? {})\n .filter(([, field]) => field.allowUserResources)\n .map(([name]) => name);\n\n if (runnable.inlineScript) {\n return [\n `${runnableId}:rawscript/${createRawscriptHash(runnable.inlineScript.content)}`,\n { allow_user_resources: allowUserResources, one_of_inputs: {}, static_inputs: staticInputs },\n ];\n }\n\n if (runnable.path && runnable.runType) {\n const runType = runnable.runType === \"hubscript\" ? \"script\" : runnable.runType;\n return [\n `${runnableId}:${runType}/${runnable.path}`,\n { allow_user_resources: allowUserResources, one_of_inputs: {}, static_inputs: staticInputs },\n ];\n }\n\n return undefined;\n};\n\nexport const generateRawAppPolicy = async (\n runnables: Record<string, RawAppRunnable>,\n policy: RawAppFileConfig[\"policy\"],\n isPublic: boolean,\n): Promise<Policy> => {\n const triggerableEntries = await Promise.all(\n Object.entries(runnables).map(async ([runnableId, runnable]) =>\n resolveTriggerableEntry(runnableId, runnable),\n ),\n );\n\n const resolvedTriggerableEntries = triggerableEntries.filter(\n (\n entry,\n ): entry is [\n string,\n { allow_user_resources: string[]; one_of_inputs: {}; static_inputs: Record<string, unknown> },\n ] => entry !== undefined,\n );\n\n return {\n ...policy,\n execution_mode: isPublic ? \"anonymous\" : \"publisher\",\n triggerables_v2: Object.fromEntries(resolvedTriggerableEntries),\n };\n};\n\nconst resolveRunnableLanguage = (extension: string, ts: string): string | undefined => {\n const language = LANGUAGE_BY_EXTENSION[extension as keyof typeof LANGUAGE_BY_EXTENSION];\n if (!language) return undefined;\n\n return extension === \"ts\" ? ts : language;\n};\n\nconst findRunnableContentFile = async (\n backendDir: string,\n runnableId: string,\n allFileNames: string[],\n): Promise<{ content: string; extension: string } | undefined> => {\n for (const fileName of allFileNames) {\n if (fileName.endsWith(\".yaml\") || fileName.endsWith(\".lock\")) continue;\n\n if (!fileName.startsWith(`${runnableId}.`)) continue;\n\n const extension = fileName.slice(runnableId.length + 1);\n if (!resolveRunnableLanguage(extension, \"bun\")) continue;\n\n return {\n content: await readFile(path.join(backendDir, fileName), \"utf8\"),\n extension,\n };\n }\n\n return undefined;\n};\n\nconst getRunnableIdFromCodeFile = (fileName: string): string | undefined => {\n if (fileName.endsWith(\".yaml\") || fileName.endsWith(\".lock\")) return undefined;\n\n for (const extension of Object.keys(LANGUAGE_BY_EXTENSION))\n if (fileName.endsWith(`.${extension}`)) return fileName.slice(0, -(extension.length + 1));\n\n return undefined;\n};\n\nconst inlinePathPrefix = \"!inline \";\n\nconst dereferenceInlineValue = async (value: unknown, localPath: string): Promise<unknown> => {\n if (typeof value !== \"string\" || !value.startsWith(inlinePathPrefix)) return value;\n\n const relativePath = value.slice(inlinePathPrefix.length);\n return readFile(path.join(localPath, relativePath), \"utf8\");\n};\n\nconst cloneRunnable = async (value: unknown, localPath: string): Promise<unknown> => {\n if (Array.isArray(value))\n return Promise.all(value.map(async (item) => cloneRunnable(item, localPath)));\n\n if (typeof value !== \"object\" || value === null) return dereferenceInlineValue(value, localPath);\n\n const entries = await Promise.all(\n Object.entries(value).map(async ([key, entryValue]) => [\n key,\n await cloneRunnable(entryValue, localPath),\n ]),\n );\n\n return Object.fromEntries(entries);\n};\n\nexport const loadRunnablesFromBackend = async (\n backendDir: string,\n ts = \"bun\",\n): Promise<Record<string, RawAppRunnable>> => {\n const runnables: Record<string, RawAppRunnable> = {};\n\n try {\n const entries = await readdir(backendDir, { withFileTypes: true });\n const allFileNames = entries.filter((entry) => entry.isFile()).map((entry) => entry.name);\n const processedIds = new Set<string>();\n\n for (const fileName of allFileNames) {\n if (!fileName.endsWith(\".yaml\")) continue;\n\n const runnableId = fileName.slice(0, -\".yaml\".length);\n processedIds.add(runnableId);\n const runnable = await parseYamlFile<RawAppRunnable>(path.join(backendDir, fileName));\n if (runnable.type === \"inline\") {\n const contentFile = await findRunnableContentFile(backendDir, runnableId, allFileNames);\n if (contentFile) {\n const lockPath = path.join(backendDir, `${runnableId}.lock`);\n let lock: string | undefined;\n try {\n lock = await readFile(lockPath, \"utf8\");\n } catch (error) {\n if (!isNodeError(error) || error.code !== \"ENOENT\") throw error;\n }\n\n runnable.inlineScript = {\n ...runnable.inlineScript,\n content: contentFile.content,\n language: resolveRunnableLanguage(contentFile.extension, ts),\n ...(lock ? { lock } : {}),\n };\n }\n } else if (\n runnable.type === \"flow\" ||\n runnable.type === \"hubscript\" ||\n runnable.type === \"script\"\n ) {\n const { type, schema: _schema, ...rest } = runnable;\n runnables[runnableId] = {\n ...rest,\n runType: type,\n type: \"path\",\n };\n continue;\n }\n\n runnables[runnableId] = runnable;\n }\n\n for (const fileName of allFileNames) {\n const runnableId = getRunnableIdFromCodeFile(fileName);\n if (!runnableId || processedIds.has(runnableId)) continue;\n\n processedIds.add(runnableId);\n const contentFile = await findRunnableContentFile(backendDir, runnableId, allFileNames);\n if (!contentFile) continue;\n\n const lockPath = path.join(backendDir, `${runnableId}.lock`);\n let lock: string | undefined;\n try {\n lock = await readFile(lockPath, \"utf8\");\n } catch (error) {\n if (!isNodeError(error) || error.code !== \"ENOENT\") throw error;\n }\n\n runnables[runnableId] = {\n inlineScript: {\n content: contentFile.content,\n language: resolveRunnableLanguage(contentFile.extension, ts),\n ...(lock ? { lock } : {}),\n },\n type: \"inline\",\n };\n }\n } catch (error) {\n if (!isNodeError(error) || error.code !== \"ENOENT\") throw error;\n }\n\n return runnables;\n};\n\nconst matchesSyncExclude = (relativePath: string, excludes: string[]): boolean =>\n excludes.some((pattern) => path.posix.matchesGlob(relativePath, pattern));\n\nexport const collectAppFiles = async (\n dir: string,\n options: { excludes?: string[]; root?: string } = {},\n): Promise<Record<string, string>> => {\n const files: Record<string, string> = {};\n const root = options.root ? path.resolve(options.root) : dir;\n const excludes = options.excludes ?? [];\n\n const walk = async (currentDir: string, relativeDir = \"/\"): Promise<void> => {\n const entries = await readdir(currentDir, { withFileTypes: true });\n for (const entry of entries) {\n const fullPath = path.join(currentDir, entry.name);\n const relativePath = `${relativeDir}${entry.name}`;\n const relativeToRoot = normalizeToPosix(path.relative(root, fullPath));\n\n if (entry.isDirectory()) {\n if (DEPLOY_IGNORED_DIRECTORIES.has(entry.name)) continue;\n\n await walk(fullPath, `${relativePath}/`);\n continue;\n }\n\n if (DEPLOY_IGNORED_FILE_NAMES.has(entry.name)) continue;\n if (matchesSyncExclude(relativeToRoot, excludes)) continue;\n\n files[relativePath] = await readFile(fullPath, \"utf8\");\n }\n };\n\n await walk(dir);\n return files;\n};\n\nexport const loadRawAppProject = async (project: Project): Promise<RawAppProject> => {\n const config = await parseYamlFile<RawAppFileConfig>(project.yaml);\n const backendDir = path.join(project.dir, \"backend\");\n const backendRunnables = await loadRunnablesFromBackend(backendDir, project.ts);\n const rawRunnables =\n Object.keys(backendRunnables).length > 0 ? backendRunnables : (config.runnables ?? {});\n const runnables = (await cloneRunnable(rawRunnables, backendDir)) as Record<\n string,\n RawAppRunnable\n >;\n const files = await collectAppFiles(project.dir, {\n excludes: project.syncExcludes,\n root: project.root,\n });\n const policy = await generateRawAppPolicy(runnables, config.policy, Boolean(config.public));\n const value = {\n ...(config.data !== undefined ? { data: config.data } : {}),\n files,\n runnables,\n };\n\n return {\n config,\n files,\n policy,\n runnables,\n value,\n };\n};\n\nconst createArgsType = (_runnable: RawAppRunnable): string => \"{}\";\n\nconst generateWmillDts = (\n runnables: Record<string, RawAppRunnable>,\n): string => `// THIS FILE IS READ-ONLY\n// AND GENERATED AUTOMATICALLY FROM YOUR RUNNABLES\n\nexport declare const backend: {\n${Object.entries(runnables)\n .map(([name, runnable]) => ` ${name}: (args: ${createArgsType(runnable)}) => Promise<any>`)\n .join(\"\\n\")}\n}\n\nexport declare const backendAsync: {\n${Object.entries(runnables)\n .map(([name, runnable]) => ` ${name}: (args: ${createArgsType(runnable)}) => Promise<string>`)\n .join(\"\\n\")}\n}\n\nexport type Job = {\n type: 'QueuedJob' | 'CompletedJob'\n id: string\n created_at: number\n started_at: number | undefined\n duration_ms: number\n success: boolean\n args: any\n result: any\n}\n\nexport declare function waitJob(id: string): Promise<Job>\nexport declare function getJob(id: string): Promise<Job>\n\nexport type StreamUpdate = {\n new_result_stream?: string\n stream_offset?: number\n}\n\nexport declare function streamJob(id: string, onUpdate?: (data: StreamUpdate) => void): Promise<any>\n`;\n\nexport const writeGeneratedWmillTypes = async (project: Project): Promise<void> => {\n const rawAppProject = await loadRawAppProject(project);\n const filePath = path.join(project.dir, \"wmill.d.ts\");\n const contents = generateWmillDts(rawAppProject.runnables);\n await mkdir(path.dirname(filePath), { recursive: true });\n await writeFile(filePath, contents);\n};\n\nexport { WMILL_IMPORT_PATTERN };\n","import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { ApiError, AppService, setClient } from \"windmill-client\";\n\nimport { loadRawAppProject, resolveProject } from \"./project.ts\";\nimport type { BundleContents, DeployOptions, DeployRawAppResult, Project } from \"./types.ts\";\n\nconst defaultDeploymentMessage = () => {\n const sha = process.env.GITHUB_SHA;\n return sha ? `vite-plugin-windmill deploy ${sha}` : \"vite-plugin-windmill deploy\";\n};\n\nconst requireProjectConnection = (project: Project) => {\n if (!project.workspace)\n throw new Error(\"Missing Windmill workspace. Set `workspace` or `WM_WORKSPACE`.\");\n\n if (!project.token) throw new Error(\"Missing Windmill token. Set `token` or `WM_TOKEN`.\");\n\n if (!project.url)\n throw new Error(\"Missing Windmill URL. Set `url`, `BASE_INTERNAL_URL`, or `BASE_URL`.\");\n\n return {\n url: project.url,\n token: project.token,\n workspace: project.workspace,\n };\n};\n\nconst readBundleFile = async (filePath: string, fallback = \"\"): Promise<string> => {\n try {\n return await readFile(filePath, \"utf8\");\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") return fallback;\n\n throw error;\n }\n};\n\nconst readBundleContents = async (\n dir: string,\n js = path.join(dir, \"dist/windmill/bundle.js\"),\n css = path.join(dir, \"dist/windmill/bundle.css\"),\n): Promise<BundleContents> => ({\n css: await readBundleFile(css, \"\"),\n js: await readBundleFile(js),\n});\n\nconst findExistingRawApp = async (workspace: string, pathValue: string) => {\n try {\n return await AppService.getAppByPath({\n workspace,\n path: pathValue,\n });\n } catch (error) {\n if (error instanceof ApiError && error.status === 404) return undefined;\n\n throw error;\n }\n};\n\n/**\n * Deploys a raw app to Windmill using `windmill-client` instead of shelling out to the CLI.\n */\nexport const deploy = async (options: DeployOptions): Promise<DeployRawAppResult> => {\n const dir = options.dir ?? process.cwd();\n const project = await resolveProject({ ...options, dir });\n const rawAppProject = await loadRawAppProject(project);\n const connection = requireProjectConnection(project);\n const bundles = options.bundles ?? (await readBundleContents(dir, options.js, options.css));\n\n if (!bundles.js) throw new Error(\"Cannot deploy a Windmill raw app without a JavaScript bundle\");\n\n if (options.dry) {\n return {\n action: \"dry-run\",\n base: project.base,\n path: project.path,\n workspace: connection.workspace,\n };\n }\n\n setClient(connection.token, connection.url);\n\n const existingApp = await findExistingRawApp(connection.workspace, project.path);\n\n if (existingApp && !existingApp.raw_app)\n throw new Error(`${project.path} exists remotely but is not a raw app`);\n\n const message = options.message ?? defaultDeploymentMessage();\n const appPayload = {\n ...(rawAppProject.config.custom_path ? { custom_path: rawAppProject.config.custom_path } : {}),\n deployment_message: message,\n path: project.path,\n policy: rawAppProject.policy,\n summary: rawAppProject.config.summary,\n value: rawAppProject.value,\n };\n\n if (existingApp) {\n await AppService.updateAppRaw({\n workspace: connection.workspace,\n path: project.path,\n formData: {\n app: appPayload,\n css: bundles.css,\n js: bundles.js,\n },\n });\n return {\n action: \"update\",\n base: project.base,\n path: project.path,\n workspace: connection.workspace,\n };\n }\n\n await AppService.createAppRaw({\n workspace: connection.workspace,\n formData: {\n app: appPayload,\n css: bundles.css,\n js: bundles.js,\n },\n });\n\n return {\n action: \"create\",\n base: project.base,\n path: project.path,\n workspace: connection.workspace,\n };\n};\n","export const devRuntimeSource = String.raw`\nconst requestJson = async (path, body) => {\n\tconst response = await fetch(path, {\n\t\tmethod: 'POST',\n\t\theaders: { 'content-type': 'application/json' },\n\t\tbody: body ? JSON.stringify(body) : undefined,\n\t})\n\n\tconst payload = await response.json()\n\tif (!response.ok || payload.error) {\n\t\tthrow new Error(\n\t\t\tpayload.error ?? 'Windmill dev request failed with status ' + response.status,\n\t\t)\n\t}\n\n\treturn payload.result\n}\n\nexport const backend = new Proxy(\n\t{},\n\t{\n\t\tget(_, runnableId) {\n\t\t\treturn async (v) =>\n\t\t\t\trequestJson('/__windmill__/backend', { runnableId, args: v ?? {} })\n\t\t},\n\t},\n)\n\nexport const backendAsync = new Proxy(\n\t{},\n\t{\n\t\tget(_, runnableId) {\n\t\t\treturn async (v) =>\n\t\t\t\trequestJson('/__windmill__/backend-async', { runnableId, args: v ?? {} })\n\t\t},\n\t},\n)\n\nexport const waitJob = async (jobId) => requestJson('/__windmill__/wait-job', { jobId })\n\nexport const getJob = async (jobId) => requestJson('/__windmill__/get-job', { jobId })\n\nexport const streamJob = async (jobId, onUpdate) =>\n\tnew Promise((resolve, reject) => {\n\t\tconst source = new EventSource(\n\t\t\t'/__windmill__/stream-job/' + encodeURIComponent(jobId),\n\t\t)\n\n\t\tsource.addEventListener('update', (event) => {\n\t\t\tconst data = JSON.parse(event.data)\n\t\t\tonUpdate?.(data)\n\t\t})\n\n\t\tsource.addEventListener('done', (event) => {\n\t\t\tsource.close()\n\t\t\tresolve(JSON.parse(event.data))\n\t\t})\n\n\t\tsource.addEventListener('error', (event) => {\n\t\t\tsource.close()\n\t\t\tconst message =\n\t\t\t\tevent instanceof MessageEvent && typeof event.data === 'string'\n\t\t\t\t\t? event.data\n\t\t\t\t\t: 'Windmill stream request failed'\n\t\t\treject(new Error(message))\n\t\t})\n\t})\n`;\n","// Generated by scripts/sync-upstream-runtime.mjs\n// Source: https://raw.githubusercontent.com/windmill-labs/windmill/v1.749.0/frontend/src/lib/rawAppWmillTs.ts\n\nexport const UPSTREAM_WINDMILL_VERSION = \"1.749.0\";\nexport const UPSTREAM_WINDMILL_RELEASE_VERSION = \"1.749.0\";\nexport const UPSTREAM_WINDMILL_RELEASE_LINE = \"1.749.x\";\nexport const UPSTREAM_RAW_APP_WMILL_TS_REF = \"v1.749.0\";\nexport const UPSTREAM_RAW_APP_WMILL_TS_URL =\n \"https://raw.githubusercontent.com/windmill-labs/windmill/v1.749.0/frontend/src/lib/rawAppWmillTs.ts\";\nexport const buildRuntimeSource =\n \"let reqs = {};\\nfunction doRequest(type, o, extra) {\\n return new Promise((resolve, reject) => {\\n const reqId = Math.random().toString(36);\\n reqs[reqId] = { resolve, reject, ...extra };\\n const req = { ...o, type, reqId };\\n parent.postMessage(req, '*');\\n });\\n}\\nexport const backend = new Proxy({}, {\\n get(_, runnable_id) {\\n return (v) => {\\n return doRequest('backend', { runnable_id, v });\\n };\\n }\\n});\\nexport const backendAsync = new Proxy({}, {\\n get(_, runnable_id) {\\n return (v) => {\\n return doRequest('backendAsync', { runnable_id, v });\\n };\\n }\\n});\\nexport function waitJob(jobId) {\\n return doRequest('waitJob', { jobId });\\n}\\nexport function getJob(jobId) {\\n return doRequest('getJob', { jobId });\\n}\\n/**\\n * Stream job results using SSE. Calls onUpdate for each stream update,\\n * and resolves with the final result when the job completes.\\n * @param jobId - The job ID to stream\\n * @param onUpdate - Callback for stream updates with new_result_stream data\\n * @returns Promise that resolves with the final job result\\n */\\nexport function streamJob(jobId, onUpdate) {\\n return doRequest('streamJob', { jobId }, { onUpdate });\\n}\\nwindow.addEventListener('message', (e) => {\\n if (e.data.type === 'streamJobUpdate') {\\n // Handle streaming update\\n let job = reqs[e.data.reqId];\\n if (job && job.onUpdate) {\\n job.onUpdate({\\n new_result_stream: e.data.new_result_stream,\\n stream_offset: e.data.stream_offset\\n });\\n }\\n }\\n else if (e.data.type === 'streamJobRes') {\\n // Handle stream completion\\n let job = reqs[e.data.reqId];\\n if (job) {\\n if (e.data.error) {\\n job.reject(new Error(e.data.result?.stack ?? e.data.result?.message ?? 'Stream error'));\\n }\\n else {\\n job.resolve(e.data.result);\\n }\\n delete reqs[e.data.reqId];\\n }\\n }\\n else if (e.data.type === 'backendRes' ||\\n e.data.type === 'backendAsyncRes' ||\\n e.data.type === 'waitJobRes' ||\\n e.data.type === 'getJobRes') {\\n console.log('Message from parent backend', e.data);\\n let job = reqs[e.data.reqId];\\n if (job) {\\n const result = e.data.result;\\n if (e.data.error) {\\n job.reject(new Error(result.stack ?? result.message));\\n }\\n else {\\n job.resolve(result);\\n }\\n delete reqs[e.data.reqId];\\n }\\n else {\\n console.error('No job found for', e.data.reqId);\\n }\\n }\\n});\\n\";\n","import { devRuntimeSource } from \"./dev-runtime-source.ts\";\nimport { buildRuntimeSource } from \"./generated/upstream-build-runtime.ts\";\n\nexport const getWindmillRuntimeSource = (mode: \"build\" | \"serve\"): string =>\n mode === \"serve\" ? devRuntimeSource : buildRuntimeSource;\n\nexport { buildRuntimeSource, devRuntimeSource };\n","import path from \"node:path\";\nimport { Readable } from \"node:stream\";\nimport { scheduler } from \"node:timers/promises\";\n\nimport type { Plugin, Connect, ProxyOptions } from \"vite\";\nimport { loadEnv } from \"vite\";\nimport type { OutputBundle } from \"vite/rolldown\";\nimport { AppService, JobService, setClient, type ExecuteComponentData } from \"windmill-client\";\n\nimport { deploy } from \"./deploy.ts\";\nimport {\n WMILL_IMPORT_PATTERN,\n loadRawAppProject,\n resolveProject,\n writeGeneratedWmillTypes,\n} from \"./project.ts\";\nimport { getWindmillRuntimeSource } from \"./runtime.ts\";\nimport type {\n PluginDeployOptions,\n PluginOptions,\n Project,\n RawAppRunnable,\n WindmillApiProxyOptions,\n} from \"./types.ts\";\nconst VIRTUAL_WMILL_ID = \"virtual:vite-plugin-windmill/wmill\";\nconst RESOLVED_VIRTUAL_WMILL_ID = `\\0${VIRTUAL_WMILL_ID}`;\nconst DEFAULT_BUILD_OUT_DIR = \"dist/windmill\";\nconst DEFAULT_API_PROXY_CONTEXT = \"/api\";\nconst DEPLOY_TRUE_VALUES = new Set([\"\", \"1\", \"on\", \"true\", \"yes\"]);\nconst DEPLOY_FALSE_VALUES = new Set([\"0\", \"false\", \"no\", \"off\"]);\nconst DEPLOY_DRY_VALUES = new Set([\"check\", \"dry\"]);\n\nconst normalizePath = (value: string): string => value.split(path.sep).join(\"/\");\n\nconst buildHtmlDocument = (entryFile: string): string => {\n const entryPath = normalizePath(entryFile.startsWith(\"/\") ? entryFile : `/${entryFile}`);\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Windmill Dev</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/@vite/client\"></script>\n <script type=\"module\" src=\"${entryPath}\"></script>\n </body>\n</html>`;\n};\n\nconst toErrorMessage = (value: unknown): string => {\n if (value instanceof Error) return value.message;\n\n if (typeof value === \"string\") return value;\n\n try {\n return JSON.stringify(value);\n } catch {\n return \"Unknown error\";\n }\n};\n\nconst requireString = (value: unknown, fieldName: string): string => {\n if (typeof value === \"string\" && value.length > 0) return value;\n\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value);\n\n throw new Error(`Missing or invalid ${fieldName}`);\n};\n\nconst requireProjectConnection = (project: Project) => {\n if (!project.workspace)\n throw new Error(\"Missing Windmill workspace. Set `workspace` or `WM_WORKSPACE`.\");\n\n if (!project.token) throw new Error(\"Missing Windmill token. Set `token` or `WM_TOKEN`.\");\n\n if (!project.url)\n throw new Error(\"Missing Windmill URL. Set `url`, `BASE_INTERNAL_URL`, or `BASE_URL`.\");\n\n return {\n url: project.url,\n token: project.token,\n workspace: project.workspace,\n };\n};\n\nconst readJsonBody = async (request: NodeJS.ReadableStream): Promise<Record<string, unknown>> => {\n const chunks: Uint8Array[] = [];\n for await (const chunk of request)\n chunks.push(typeof chunk === \"string\" ? Buffer.from(chunk) : chunk);\n\n if (chunks.length === 0) return {};\n\n return JSON.parse(Buffer.concat(chunks).toString(\"utf8\")) as Record<string, unknown>;\n};\n\nconst waitForJobResult = async (workspace: string, jobId: string): Promise<unknown> => {\n let delay = 50;\n for (;;) {\n const result = await JobService.getCompletedJobResultMaybe({\n workspace,\n id: jobId,\n getStarted: false,\n });\n\n if (result.completed) {\n if (\n !result.success &&\n typeof result.result === \"object\" &&\n result.result &&\n \"error\" in result.result\n )\n throw new Error(toErrorMessage((result.result as { error?: unknown }).error));\n\n return result.result;\n }\n\n await scheduler.wait(delay);\n delay = delay >= 500 ? 2_000 : 500;\n }\n};\n\nconst executeRunnable = async (\n project: Project,\n workspace: string,\n runnableId: string,\n runnable: RawAppRunnable,\n args: unknown,\n): Promise<string> => {\n const requestBody: ExecuteComponentData[\"requestBody\"] = {\n args: (args ?? {}) as Record<string, unknown>,\n component: runnableId,\n force_viewer_allow_user_resources: Object.entries(runnable.fields ?? {})\n .filter(([, field]) => field.allowUserResources)\n .map(([name]) => name),\n force_viewer_one_of_fields: {},\n force_viewer_static_fields: Object.fromEntries(\n Object.entries(runnable.fields ?? {})\n .filter(([, field]) => field.type === \"static\")\n .map(([name, field]) => [name, field.value]),\n ),\n };\n\n if (runnable.inlineScript) {\n requestBody.raw_code = {\n cache_ttl: runnable.inlineScript.cache_ttl,\n content: runnable.inlineScript.id === undefined ? (runnable.inlineScript.content ?? \"\") : \"\",\n language: runnable.inlineScript.language ?? \"\",\n lock: runnable.inlineScript.id === undefined ? runnable.inlineScript.lock : undefined,\n path: `${project.path}/${runnableId}`,\n };\n if (runnable.inlineScript.id !== undefined) requestBody.id = runnable.inlineScript.id;\n } else if (runnable.path && runnable.runType)\n requestBody.path = `${runnable.runType === \"hubscript\" ? \"script\" : runnable.runType}/${runnable.path}`;\n else throw new Error(`Runnable ${runnableId} is missing inline or path metadata`);\n\n return AppService.executeComponent({\n workspace,\n path: project.path,\n requestBody,\n });\n};\n\nconst extractBundleContents = (bundle: OutputBundle) => {\n let css = \"\";\n let js = \"\";\n\n for (const output of Object.values(bundle)) {\n if (output.type === \"chunk\" && output.fileName === \"bundle.js\") js = output.code;\n\n if (output.type === \"asset\" && output.fileName === \"bundle.css\") {\n css =\n typeof output.source === \"string\"\n ? output.source\n : Buffer.from(output.source).toString(\"utf8\");\n }\n }\n\n return { css, js };\n};\n\nconst hasAuthorizationHeader = (headers: ProxyOptions[\"headers\"]): boolean =>\n Object.keys(headers ?? {}).some((key) => key.toLowerCase() === \"authorization\");\n\nconst resolveApiProxyConfig = (\n project: Project,\n proxy: PluginOptions[\"proxy\"],\n): Record<string, ProxyOptions> | undefined => {\n if (proxy === false) return undefined;\n\n const proxyOptions =\n proxy && typeof proxy === \"object\" ? ({ ...proxy } as WindmillApiProxyOptions) : undefined;\n const enabled = typeof proxy === \"object\" ? (proxy.enabled ?? true) : (proxy ?? true);\n if (!enabled) return undefined;\n\n const context = proxyOptions?.context ?? DEFAULT_API_PROXY_CONTEXT;\n const target = proxyOptions?.target ?? project.url;\n if (!target) return undefined;\n\n const {\n context: _context,\n enabled: _enabled,\n target: _target,\n token,\n ...rest\n } = proxyOptions ?? {};\n const headers = { ...rest.headers };\n const resolvedToken = token ?? project.token;\n if (!hasAuthorizationHeader(headers) && resolvedToken)\n headers.Authorization = `Bearer ${resolvedToken}`;\n\n return {\n [context]: {\n changeOrigin: rest.changeOrigin ?? true,\n ...rest,\n headers,\n target,\n },\n };\n};\n\nconst resolveProjectFromViteConfig = async (\n options: PluginOptions,\n root: string | undefined,\n mode: string,\n): Promise<Project> => {\n const env = loadEnv(mode, root ?? process.cwd(), \"\");\n\n return resolveProject({\n ...options,\n dir: root ?? options.dir,\n token: options.token ?? env.WM_TOKEN ?? process.env.WM_TOKEN,\n url:\n options.url ??\n env.BASE_INTERNAL_URL ??\n env.BASE_URL ??\n process.env.BASE_INTERNAL_URL ??\n process.env.BASE_URL,\n workspace: options.workspace ?? env.WM_WORKSPACE ?? process.env.WM_WORKSPACE,\n });\n};\n\nconst normalizeDeployOptions = (\n deployOptions: PluginOptions[\"deploy\"],\n): PluginDeployOptions | undefined => {\n if (typeof deployOptions === \"boolean\") return { deploy: deployOptions };\n if (!deployOptions) return undefined;\n\n return {\n deploy: deployOptions.deploy ?? true,\n dry: deployOptions.dry,\n message: deployOptions.message,\n };\n};\n\nconst parseDeployEnv = (value: string | undefined): PluginDeployOptions | undefined => {\n if (value === undefined) return undefined;\n\n const normalized = value.trim().toLowerCase();\n if (normalized === \"undefined\" || normalized === \"null\") return undefined;\n if (DEPLOY_TRUE_VALUES.has(normalized)) return { deploy: true };\n if (DEPLOY_FALSE_VALUES.has(normalized)) return { deploy: false };\n if (DEPLOY_DRY_VALUES.has(normalized)) return { deploy: true, dry: true };\n\n throw new Error(`Invalid WM_DEPLOY value \\`${value}\\`. Expected boolean-like values or \\`dry\\`.`);\n};\n\nconst resolveDeployOptions = (\n options: PluginOptions,\n root: string | undefined,\n mode: string,\n): PluginDeployOptions => {\n const explicitDeploy = normalizeDeployOptions(options.deploy);\n if (explicitDeploy) return explicitDeploy;\n\n const env = loadEnv(mode, root ?? process.cwd(), \"\");\n return parseDeployEnv(env.WM_DEPLOY ?? process.env.WM_DEPLOY) ?? { deploy: false };\n};\n\n/**\n * Generates the HTML host shell for `vite preview`. It embeds the production IIFE bundle\n * in a same-origin blob-URL iframe, mirroring how Windmill renders raw apps, and relays\n * postMessage backend requests to the local /__windmill__/ HTTP proxy.\n */\nconst buildPreviewHostShellHtml = (workspace: string): string => `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Windmill Preview</title>\n <style>html,body{margin:0;padding:0;width:100%;height:100%;overflow:hidden}iframe{position:fixed;inset:0;width:100%;height:100%;border:none}</style>\n</head>\n<body>\n <iframe id=\"app\" title=\"raw-app\" sandbox=\"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads allow-modals allow-pointer-lock allow-presentation allow-storage-access-by-user-activation allow-top-navigation-by-user-activation\"></iframe>\n <script type=\"module\">\n window.localStorage.setItem('workspace', ${JSON.stringify(workspace)})\n\n window.addEventListener('message', async ({ data: msg }) => {\n if (!msg?.type || !msg?.reqId) return\n const { type, reqId } = msg\n const frame = document.getElementById('app')\n const send = (result, error) =>\n frame.contentWindow?.postMessage({ type: type + 'Res', reqId, result, error: !!error }, '*')\n\n try {\n if (type === 'backend' || type === 'backendAsync') {\n const ep = type === 'backend' ? '/__windmill__/backend' : '/__windmill__/backend-async'\n const r = await fetch(ep, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ runnableId: msg.runnable_id, args: msg.v ?? {} }),\n })\n const p = await r.json()\n send(p.result, !!p.error)\n } else if (type === 'waitJob') {\n const r = await fetch('/__windmill__/wait-job', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ jobId: msg.jobId }),\n })\n const p = await r.json()\n send(p.result, !!p.error)\n } else if (type === 'getJob') {\n const r = await fetch('/__windmill__/get-job', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ jobId: msg.jobId }),\n })\n const p = await r.json()\n send(p.result, !!p.error)\n } else if (type === 'streamJob') {\n const source = new EventSource('/__windmill__/stream-job/' + encodeURIComponent(msg.jobId))\n source.addEventListener('update', (e) =>\n frame.contentWindow?.postMessage({ type: 'streamJobUpdate', reqId, ...JSON.parse(e.data) }, '*'))\n source.addEventListener('done', (e) => { source.close(); send(JSON.parse(e.data), false) })\n source.addEventListener('error', () => { source.close(); send({ message: 'Stream error' }, true) })\n }\n } catch (err) {\n send({ message: err?.message ?? String(err) }, true)\n }\n })\n\n // Fetch the production bundle, wrap it in a blob URL, and load it into the iframe.\n // Using a blob URL makes window.location.protocol === 'blob:' inside the iframe,\n // which matches the production Windmill embedding behaviour.\n const [cssRes, jsRes] = await Promise.all([fetch('/bundle.css'), fetch('/bundle.js')])\n const [css, js] = await Promise.all([cssRes.text(), jsRes.text()])\n const html = '<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\">'\n + (css ? '<style>' + css + '</style>' : '')\n + '</head><body><div id=\"root\"></div><script>'\n + js + '<\\\\/script></body></html>'\n document.getElementById('app').src = URL.createObjectURL(new Blob([html], { type: 'text/html' }))\n </script>\n</body>\n</html>`;\n\n/**\n * Creates a Vite plugin that aligns a SPA with Windmill raw-app build and deploy behavior.\n */\nconst windmill = (options: PluginOptions = {}): Plugin => {\n let project: Project | undefined;\n let command: \"build\" | \"serve\" = \"serve\";\n let deployOptions: PluginDeployOptions = { deploy: false };\n\n /**\n * Shared Connect middleware that handles all /__windmill__/ API routes.\n * Used by both the dev server and the preview server.\n */\n const windmillApiHandler: Connect.NextHandleFunction = async (request, response, next) => {\n try {\n if (!project) return next();\n\n const sendJson = (payload: unknown) => response.end(JSON.stringify(payload));\n\n const connection = requireProjectConnection(project);\n setClient(connection.token, connection.url);\n\n if (request.url === \"/__windmill__/backend\" && request.method === \"POST\") {\n try {\n const body = await readJsonBody(request);\n const rawAppProject = await loadRawAppProject(project);\n const runnableId = requireString(body.runnableId, \"runnableId\");\n const runnable = rawAppProject.runnables[runnableId];\n if (!runnable) throw new Error(`Runnable not found: ${runnableId}`);\n\n const jobId = await executeRunnable(\n project,\n connection.workspace,\n runnableId,\n runnable,\n body.args,\n );\n const result = await waitForJobResult(connection.workspace, jobId);\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ result });\n } catch (error) {\n response.statusCode = 500;\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ error: toErrorMessage(error) });\n }\n return;\n }\n\n if (request.url === \"/__windmill__/backend-async\" && request.method === \"POST\") {\n try {\n const body = await readJsonBody(request);\n const rawAppProject = await loadRawAppProject(project);\n const runnableId = requireString(body.runnableId, \"runnableId\");\n const runnable = rawAppProject.runnables[runnableId];\n if (!runnable) throw new Error(`Runnable not found: ${runnableId}`);\n\n const jobId = await executeRunnable(\n project,\n connection.workspace,\n runnableId,\n runnable,\n body.args,\n );\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ result: jobId });\n } catch (error) {\n response.statusCode = 500;\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ error: toErrorMessage(error) });\n }\n return;\n }\n\n if (request.url === \"/__windmill__/wait-job\" && request.method === \"POST\") {\n try {\n const body = await readJsonBody(request);\n const result = await waitForJobResult(\n connection.workspace,\n requireString(body.jobId, \"jobId\"),\n );\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ result });\n } catch (error) {\n response.statusCode = 500;\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ error: toErrorMessage(error) });\n }\n return;\n }\n\n if (request.url === \"/__windmill__/get-job\" && request.method === \"POST\") {\n try {\n const body = await readJsonBody(request);\n const result = await JobService.getJob({\n workspace: connection.workspace,\n id: requireString(body.jobId, \"jobId\"),\n });\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ result });\n } catch (error) {\n response.statusCode = 500;\n response.setHeader(\"content-type\", \"application/json\");\n sendJson({ error: toErrorMessage(error) });\n }\n return;\n }\n\n if (request.url?.startsWith(\"/__windmill__/stream-job/\") && request.method === \"GET\") {\n try {\n const jobId = decodeURIComponent(request.url.slice(\"/__windmill__/stream-job/\".length));\n response.setHeader(\"cache-control\", \"no-cache\");\n response.setHeader(\"content-type\", \"text/event-stream\");\n response.setHeader(\"connection\", \"keep-alive\");\n const sseResponse = await fetch(\n `${connection.url.replace(/\\/$/, \"\")}/api/w/${connection.workspace}/jobs_u/getupdate_sse/${jobId}?fast=true`,\n {\n headers: {\n accept: \"text/event-stream\",\n authorization: `Bearer ${connection.token}`,\n },\n },\n );\n\n if (!sseResponse.ok || !sseResponse.body)\n throw new Error(`Failed to stream Windmill job ${jobId}`);\n\n const reader = Readable.fromWeb(sseResponse.body);\n let buffer = \"\";\n for await (const chunk of reader) {\n buffer += chunk.toString();\n const lines = buffer.split(\"\\n\");\n buffer = lines.pop() ?? \"\";\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n\n const payload = JSON.parse(line.slice(\"data: \".length)) as {\n completed?: boolean;\n error?: string;\n new_result_stream?: string;\n only_result?: unknown;\n stream_offset?: number;\n type?: string;\n };\n\n if (payload.type === \"ping\") continue;\n\n if (payload.type === \"timeout\") {\n response.write(`event: error\\ndata: ${JSON.stringify(\"Stream timed out\")}\\n\\n`);\n response.end();\n return;\n }\n\n if (payload.type === \"error\") {\n response.write(\n `event: error\\ndata: ${JSON.stringify(payload.error ?? \"Stream error\")}\\n\\n`,\n );\n response.end();\n return;\n }\n\n if (payload.new_result_stream !== undefined) {\n response.write(\n `event: update\\ndata: ${JSON.stringify({ new_result_stream: payload.new_result_stream, stream_offset: payload.stream_offset })}\\n\\n`,\n );\n }\n\n if (payload.completed) {\n response.write(`event: done\\ndata: ${JSON.stringify(payload.only_result)}\\n\\n`);\n response.end();\n return;\n }\n }\n }\n\n response.end();\n } catch (error) {\n response.write(`event: error\\ndata: ${JSON.stringify(toErrorMessage(error))}\\n\\n`);\n response.end();\n }\n return;\n }\n\n next();\n } catch (error) {\n next(error);\n }\n };\n\n return {\n name: \"vite-plugin-windmill\",\n async config(userConfig, env) {\n project = await resolveProjectFromViteConfig(options, userConfig.root, env.mode);\n command = env.command;\n deployOptions = resolveDeployOptions(options, userConfig.root, env.mode);\n\n const isServe = env.command === \"serve\";\n const apiProxy = resolveApiProxyConfig(project, options.proxy);\n\n return {\n appType: \"custom\",\n // In serve mode (dev + preview), use '/' so Vite's base middleware does not\n // intercept /__windmill__/ backend routes. The Windmill app base only matters\n // for the production IIFE bundle (asset URL resolution inside the iframe).\n base: isServe ? \"/\" : project.base,\n // Always set outDir so that `vite preview` serves from the same directory\n // that `vite build` writes to.\n build: {\n chunkSizeWarningLimit: 2_048,\n outDir: DEFAULT_BUILD_OUT_DIR,\n ...(isServe\n ? {}\n : {\n assetsInlineLimit: Number.MAX_SAFE_INTEGER,\n cssCodeSplit: false,\n modulePreload: false,\n reportCompressedSize: false,\n rolldownOptions: {\n input: project.entry,\n output: {\n assetFileNames: (assetInfo) =>\n assetInfo.name?.endsWith(\".css\")\n ? \"bundle.css\"\n : \"assets/[name]-[hash][extname]\",\n entryFileNames: \"bundle.js\",\n format: \"iife\",\n },\n },\n }),\n },\n ...(isServe ? { publicDir: false } : {}),\n define: {\n \"process.env.NODE_ENV\": JSON.stringify(isServe ? \"development\" : \"production\"),\n },\n preview: {\n open: false,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n server: {\n open: false,\n ...(apiProxy ? { proxy: apiProxy } : {}),\n },\n };\n },\n async configResolved(resolvedConfig) {\n project = await resolveProjectFromViteConfig(\n options,\n resolvedConfig.root,\n resolvedConfig.mode,\n );\n deployOptions = resolveDeployOptions(options, resolvedConfig.root, resolvedConfig.mode);\n await writeGeneratedWmillTypes(project);\n },\n resolveId(id) {\n if (WMILL_IMPORT_PATTERN.test(id)) return RESOLVED_VIRTUAL_WMILL_ID;\n\n return undefined;\n },\n load(id) {\n if (id === RESOLVED_VIRTUAL_WMILL_ID) return getWindmillRuntimeSource(command);\n\n return undefined;\n },\n configurePreviewServer(previewServer) {\n return () => {\n // Serve the host shell HTML for any HTML GET that Vite's static middleware\n // did not handle (no index.html in the build output directory).\n const previewHandler: Connect.NextHandleFunction = async (request, response, next) => {\n if (!project) return next();\n\n const acceptsHtml = request.headers.accept?.includes(\"text/html\") ?? false;\n const url = request.url ?? \"/\";\n if (\n request.method === \"GET\" &&\n !url.startsWith(\"/__windmill__/\") &&\n (acceptsHtml || (!path.extname(url) && !url.includes(\"?\")))\n ) {\n if (!project.workspace)\n throw new Error(\"Missing Windmill workspace. Set `workspace` or `WM_WORKSPACE`.\");\n response.setHeader(\"content-type\", \"text/html\");\n response.end(buildPreviewHostShellHtml(project.workspace));\n return;\n }\n\n // oxlint-disable-next-line promise/no-callback-in-promise\n return Promise.resolve(windmillApiHandler(request, response, next)).catch(next);\n };\n\n previewServer.middlewares.use((req, res, next) =>\n // oxlint-disable-next-line promise/no-callback-in-promise\n Promise.resolve(previewHandler(req, res, next)).catch(next),\n );\n };\n },\n configureServer(configuredServer) {\n return () => {\n const handler: Connect.NextHandleFunction = async (request, response, next) => {\n try {\n if (!project) return next();\n\n // Delegate all /__windmill__/ API requests to the shared handler.\n if (request.url?.startsWith(\"/__windmill__/\")) {\n // oxlint-disable-next-line promise/no-callback-in-promise\n return Promise.resolve(windmillApiHandler(request, response, next)).catch(next);\n }\n\n // Serve the app HTML for all extensionless GET requests (SPA routing).\n // Do not gate on Accept: text/html — health-check tools and Playwright\n // webServer readiness probes send plain GET requests without that header.\n const url = request.url ?? \"/\";\n if (request.method === \"GET\" && !path.extname(url) && !url.includes(\"?\")) {\n const entryRelative = normalizePath(path.relative(project.dir, project.entry));\n const html = await configuredServer.transformIndexHtml(\n url,\n buildHtmlDocument(entryRelative),\n );\n response.setHeader(\"content-type\", \"text/html\");\n response.end(html);\n return;\n }\n\n next();\n } catch (error) {\n next(error);\n }\n };\n\n configuredServer.middlewares.use((req, res, next) =>\n // oxlint-disable-next-line promise/no-callback-in-promise\n Promise.resolve(handler(req, res, next)).catch(next),\n );\n };\n },\n async handleHotUpdate(context) {\n if (!project) return;\n\n if (\n context.file.startsWith(path.join(project.dir, \"backend\")) ||\n context.file === project.yaml\n ) {\n await writeGeneratedWmillTypes(project);\n context.server.ws.send({ type: \"full-reload\" });\n return;\n }\n },\n async writeBundle(_outputOptions, bundle) {\n if (!project) return;\n\n if (!deployOptions.deploy) return;\n\n const result = await deploy({\n base: project.base,\n bundles: extractBundleContents(bundle),\n dir: project.dir,\n dry: deployOptions.dry,\n message: deployOptions.message ?? options.message,\n path: project.path,\n root: project.root,\n token: project.token,\n url: project.url,\n workspace: project.workspace,\n });\n\n this.info(\n result.action === \"dry-run\"\n ? `Windmill deploy dry-run ready for ${result.path}`\n : `Windmill raw app ${result.action}d: ${result.path}`,\n );\n },\n };\n};\n\nexport default windmill;\n"],"mappings":";;;;;;;;;AAgBA,MAAM,uBAAuB;AAC7B,MAAM,0BAA0B,CAAC,YAAY,YAAY;AACzD,MAAM,oBAAoB;AAC1B,MAAM,yBAAyB;AAC/B,MAAM,4BAA4B,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;CACD,CAAC;AACF,MAAM,6BAA6B,IAAI,IAAI;CACzC;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,wBAAwB;CAC5B,UAAU;CACV,UAAU;CACV,IAAI;CACJ,WAAW;CACX,cAAc;CACd,eAAe;CACf,IAAI;CACJ,KAAK;CACL,M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AS;AAEd,OACE,QAAQ,KAAK,WAAW,KAAK,KAAK,QAAQ,KAAK,UAAU,CAAC,IAC1D,QAAQ,SAAS,QAAQ,MACzB;AACA,UAAM,yBAAyB,QAAQ;AACvC,YAAQ,OAAO,GAAG,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/C;;;EAGJ,MAAM,YAAY,gBAAgB,QAAQ;AACxC,OAAI,CAAC,QAAS;AAEd,OAAI,CAAC,cAAc,OAAQ;GAE3B,MAAM,SAAS,MAAM,OAAO;IAC1B,MAAM,QAAQ;IACd,SAAS,sBAAsB,OAAO;IACtC,KAAK,QAAQ;IACb,KAAK,cAAc;IACnB,SAAS,cAAc,WAAW,QAAQ;IAC1C,MAAM,QAAQ;IACd,MAAM,QAAQ;IACd,OAAO,QAAQ;IACf,KAAK,QAAQ;IACb,WAAW,QAAQ;IACpB,CAAC;AAEF,QAAK,KACH,OAAO,WAAW,YACd,qCAAqC,OAAO,SAC5C,oBAAoB,OAAO,OAAO,KAAK,OAAO,OACnD;;EAEJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-windmill",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.749.0",
|
|
4
4
|
"description": "Vite plugin and deploy tooling for Windmill raw apps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"raw-app",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"prepublishOnly": "pnpm build"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"windmill-client": "^1.
|
|
53
|
+
"windmill-client": "^1.749.0",
|
|
54
54
|
"yaml": "^2.8.3"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|