@cloudflare/vite-plugin 2.0.0-rc.5 → 2.0.0-rc.7

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.
@@ -1,4 +1,4 @@
1
- import { u as getLocalExplorerEnabledFromEnv } from "./misc-variables-6mf5dDi6-D3ykvtRq.mjs";
1
+ import { u as getLocalExplorerEnabledFromEnv } from "./misc-variables-DAIhTBM--a11YYZcp.mjs";
2
2
  import os from "os";
3
3
  import { CorePaths } from "miniflare";
4
4
  import { execSync } from "child_process";
@@ -1,5 +1,5 @@
1
- import { S as isRolldown, b as debuglog, x as getOutputDirectory, y as createPlugin } from "./tunnel-BczPQL-8.mjs";
2
- import { C as virtualPrefix, S as WORKER_ENTRY_PATH_HEADER, _ as IS_ENTRY_WORKER_HEADER, b as VIRTUAL_EXPORT_TYPES, f as additionalModuleRE, g as INIT_PATH, h as GET_EXPORT_TYPES_PATH, m as ENVIRONMENT_NAME_HEADER, v as IS_PARENT_ENVIRONMENT_HEADER, x as VIRTUAL_WORKER_ENTRY, y as UNKNOWN_HOST } from "./debug-CPeJINaC.mjs";
1
+ import { S as isRolldown, b as debuglog, x as getOutputDirectory, y as createPlugin } from "./tunnel-vv4ffjYH.mjs";
2
+ import { C as virtualPrefix, S as WORKER_ENTRY_PATH_HEADER, _ as IS_ENTRY_WORKER_HEADER, b as VIRTUAL_EXPORT_TYPES, f as additionalModuleRE, g as INIT_PATH, h as GET_EXPORT_TYPES_PATH, m as ENVIRONMENT_NAME_HEADER, v as IS_PARENT_ENVIRONMENT_HEADER, x as VIRTUAL_WORKER_ENTRY, y as UNKNOWN_HOST } from "./debug-DfMbsbf8.mjs";
3
3
  import { builtinModules } from "node:module";
4
4
  import path, * as path$1 from "node:path";
5
5
  import fs, { realpathSync, statSync } from "node:fs";
@@ -1,14 +1,14 @@
1
1
  import { r as __toESM$1, t as __commonJSMin$1 } from "./rolldown-runtime-kJ_i4yPo.mjs";
2
2
  import { i as __toESM$2, t as __commonJSMin$2 } from "./rolldown-runtime-BMUeFane-CwDF_oX0.mjs";
3
- import { S as UserError, a as getCloudflareApiBaseUrl, l as getComplianceRegionSubdomain, n as COMPLIANCE_REGION_CONFIG_UNKNOWN } from "./misc-variables-6mf5dDi6-D3ykvtRq.mjs";
4
- import { I as sanitizeHeaders, L as addCustomApiHeaders, c as require_picocolors, l as toApiComplianceRegion, o as getPorts, s as portNumbers, v as cleanUrl, y as createPlugin, z as DEFAULT_MODULE_RULES } from "./tunnel-BczPQL-8.mjs";
3
+ import { S as UserError, a as getCloudflareApiBaseUrl, l as getComplianceRegionSubdomain, n as COMPLIANCE_REGION_CONFIG_UNKNOWN } from "./misc-variables-DAIhTBM--a11YYZcp.mjs";
4
+ import { I as sanitizeHeaders, L as addCustomApiHeaders, c as require_picocolors, l as toApiComplianceRegion, o as getPorts, s as portNumbers, v as cleanUrl, y as createPlugin, z as DEFAULT_MODULE_RULES } from "./tunnel-vv4ffjYH.mjs";
5
5
  import { createRequire } from "node:module";
6
6
  import * as path$1 from "node:path";
7
7
  import path, { relative } from "node:path";
8
8
  import { readFileSync } from "node:fs";
9
9
  import assert from "node:assert";
10
- import crypto, { createHash, randomUUID } from "node:crypto";
11
10
  import * as fsp from "node:fs/promises";
11
+ import crypto, { createHash, randomUUID } from "node:crypto";
12
12
  import { execFileSync, spawn } from "node:child_process";
13
13
  import * as vite from "vite";
14
14
  import { cleanBuildOutputDir, normalizeDirectoryName, writeContainerConfig } from "@cloudflare/build-output-utils";
@@ -1,10 +1,10 @@
1
1
  import { r as __toESM } from "./rolldown-runtime-kJ_i4yPo.mjs";
2
- import { _ as getDockerPath } from "./misc-variables-6mf5dDi6-D3ykvtRq.mjs";
3
- import { b as debuglog, c as require_picocolors, d as assertIsNotPreview, h as getCurrentWorkerNameToExportTypesMap, m as compareWorkerNameToExportTypesMaps, p as compareExportTypes } from "./tunnel-BczPQL-8.mjs";
4
- import { a as initRunners } from "./cloudflare-environment-1VsQlOBY.mjs";
5
- import { u as prepareContainerImagesForCfConfig, y as UNKNOWN_HOST } from "./debug-CPeJINaC.mjs";
6
- import { n as getDevMiniflareOptions, t as handleWebSocket } from "./websockets-DUMj2fpZ.mjs";
7
- import { a as kRequestType, createRequestHandler, r as ROUTER_WORKER_NAME, resolveRequestTarget, t as ASSET_WORKER_NAME } from "./request-handler-BBxibu2n.mjs";
2
+ import { _ as getDockerPath } from "./misc-variables-DAIhTBM--a11YYZcp.mjs";
3
+ import { b as debuglog, c as require_picocolors, d as assertIsNotPreview, h as getCurrentWorkerNameToExportTypesMap, m as compareWorkerNameToExportTypesMaps, p as compareExportTypes } from "./tunnel-vv4ffjYH.mjs";
4
+ import { a as initRunners } from "./cloudflare-environment-Bso9W5g-.mjs";
5
+ import { u as prepareContainerImagesForCfConfig, y as UNKNOWN_HOST } from "./debug-DfMbsbf8.mjs";
6
+ import { n as getDevMiniflareOptions, t as handleWebSocket } from "./websockets-DEKl8ASJ.mjs";
7
+ import { a as kRequestType, createRequestHandler, r as ROUTER_WORKER_NAME, resolveRequestTarget, t as ASSET_WORKER_NAME } from "./request-handler-B_lBXFY3.mjs";
8
8
  import assert from "node:assert";
9
9
  import { CoreHeaders, buildPublicUrl } from "miniflare";
10
10
  //#region ../workers-shared/asset-worker/src/utils/rules-engine.ts
package/dist/index.d.mts CHANGED
@@ -6,7 +6,7 @@ import { EventEmitter } from "node:events";
6
6
  import { Blob, File } from "node:buffer";
7
7
  import { ConnectionOptions, TLSSocket } from "node:tls";
8
8
  import * as vite from "vite";
9
- //#region ../config/dist/public-34zSX4F6.d.mts
9
+ //#region ../config/dist/public-CyrLrvy8.d.mts
10
10
  //#endregion
11
11
  //#region src/bindings.d.ts
12
12
  /** Options that control a binding during local development. */
@@ -2372,6 +2372,12 @@ declare const KnownBindingSchema: ZodDiscriminatedUnion<[ZodObject<{
2372
2372
  dev: ZodOptional<ZodObject<{
2373
2373
  remote: ZodOptional<ZodBoolean>;
2374
2374
  }, $strict>>;
2375
+ }, $strict>, ZodObject<{
2376
+ type: ZodLiteral<"realtime-kit">;
2377
+ id: ZodString;
2378
+ dev: ZodOptional<ZodObject<{
2379
+ remote: ZodOptional<ZodBoolean>;
2380
+ }, $strict>>;
2375
2381
  }, $strict>, ZodObject<{
2376
2382
  type: ZodLiteral<"hyperdrive">;
2377
2383
  id: ZodString;
@@ -2498,6 +2504,13 @@ declare const KnownBindingSchema: ZodDiscriminatedUnion<[ZodObject<{
2498
2504
  dev: ZodOptional<ZodObject<{
2499
2505
  remote: ZodOptional<ZodBoolean>;
2500
2506
  }, $strict>>;
2507
+ }, $strict>, ZodObject<{
2508
+ type: ZodLiteral<"oidc-token">;
2509
+ audience: ZodString;
2510
+ alg: ZodOptional<ZodEnum<{
2511
+ ES256: "ES256";
2512
+ RS256: "RS256";
2513
+ }>>;
2501
2514
  }, $strict>, ZodObject<{
2502
2515
  type: ZodLiteral<"vpc-network">;
2503
2516
  tunnelId: ZodOptional<ZodString>;
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { n as __require, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-kJ_i4yPo.mjs";
2
2
  import { t as __commonJSMin$1 } from "./rolldown-runtime-BMUeFane-CwDF_oX0.mjs";
3
- import { _ as getDockerPath } from "./misc-variables-6mf5dDi6-D3ykvtRq.mjs";
4
- import { A as getWorkerNameFromProject, C as satisfiesMinimumViteVersion, K as prettifyError, R as DEFAULT_COMPAT_DATE, S as isRolldown, T as PACKAGE_INFO, b as debuglog, c as require_picocolors, d as assertIsNotPreview, f as assertIsPreview, i as tunnelPlugin, u as PluginContext, v as cleanUrl, x as getOutputDirectory, y as createPlugin } from "./tunnel-BczPQL-8.mjs";
5
- import { c as assertHasNodeJsCompat, d as isNodeAlsModule, f as nodeBuiltinsRE, h as virtualModulesPlugin, i as createCloudflareEnvironmentOptions, l as hasNodeJsAls, m as virtualClientFallbackPlugin, n as applyWorkerEsbuildSupported, o as NodeJsCompat, p as VIRTUAL_CLIENT_FALLBACK_ENTRY, r as cloudflareBuiltInModules, s as NodeJsCompatWarnings, t as MAIN_ENTRY_NAME, u as hasNodeJsCompat } from "./cloudflare-environment-1VsQlOBY.mjs";
6
- import { T as hasAssetsConfigChanged, a as buildAndWriteContainerOutput, n as addDebugToVitePrintUrls, p as additionalModulesPlugin, r as getDebugPathHtml, t as DEBUG_PATH } from "./debug-CPeJINaC.mjs";
3
+ import { _ as getDockerPath } from "./misc-variables-DAIhTBM--a11YYZcp.mjs";
4
+ import { A as getWorkerNameFromProject, C as satisfiesMinimumViteVersion, K as prettifyError, R as DEFAULT_COMPAT_DATE, S as isRolldown, T as PACKAGE_INFO, b as debuglog, c as require_picocolors, d as assertIsNotPreview, f as assertIsPreview, i as tunnelPlugin, u as PluginContext, v as cleanUrl, x as getOutputDirectory, y as createPlugin } from "./tunnel-vv4ffjYH.mjs";
5
+ import { c as assertHasNodeJsCompat, d as isNodeAlsModule, f as nodeBuiltinsRE, h as virtualModulesPlugin, i as createCloudflareEnvironmentOptions, l as hasNodeJsAls, m as virtualClientFallbackPlugin, n as applyWorkerEsbuildSupported, o as NodeJsCompat, p as VIRTUAL_CLIENT_FALLBACK_ENTRY, r as cloudflareBuiltInModules, s as NodeJsCompatWarnings, t as MAIN_ENTRY_NAME, u as hasNodeJsCompat } from "./cloudflare-environment-Bso9W5g-.mjs";
6
+ import { T as hasAssetsConfigChanged, a as buildAndWriteContainerOutput, n as addDebugToVitePrintUrls, p as additionalModulesPlugin, r as getDebugPathHtml, t as DEBUG_PATH } from "./debug-DfMbsbf8.mjs";
7
7
  import { builtinModules } from "node:module";
8
8
  import * as path$1 from "node:path";
9
9
  import * as fs$2 from "node:fs";
@@ -696,15 +696,42 @@ function resolveWorkerType(options) {
696
696
  }
697
697
  };
698
698
  }
699
+ const copiedCloudflareEnv = /* @__PURE__ */ new Map();
700
+ /**
701
+ * Load the environment files and copy their `CLOUDFLARE_*` values into
702
+ * `process.env`, where Cloudflare tooling reads them.
703
+ *
704
+ * Vite reloads the config in the same process when an environment file
705
+ * changes. `loadEnv` gives `process.env` precedence over the files, so values
706
+ * copied by the previous load are removed first. Otherwise a value removed from
707
+ * or changed in a file would keep its old value. A value that has since changed
708
+ * in `process.env` is left alone.
709
+ *
710
+ * TODO: Replace this process-global compatibility bridge by explicitly passing
711
+ * typed Cloudflare tool settings to the services that consume them.
712
+ *
713
+ * @param envDir - The resolved environment directory, or `false` to skip files.
714
+ * @param mode - The mode whose environment files are loaded, if any.
715
+ * @returns The loaded values and their sources.
716
+ */
717
+ async function loadLocalEnv(envDir, mode) {
718
+ for (const [name, value] of copiedCloudflareEnv) if (process.env[name] === value) delete process.env[name];
719
+ copiedCloudflareEnv.clear();
720
+ const localEnv = await loadEnv(envDir, mode);
721
+ for (const [name, value] of Object.entries(localEnv.values)) if (name.startsWith("CLOUDFLARE_") && localEnv.sources[name]?.type === "file") {
722
+ process.env[name] = value;
723
+ copiedCloudflareEnv.set(name, value);
724
+ }
725
+ return localEnv;
726
+ }
699
727
  async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
700
728
  if (typeof pluginConfig.tunnel === "object" && pluginConfig.tunnel.name !== void 0 && (pluginConfig.tunnel.allowedMail?.length ?? 0) > 0) throw new Error("`tunnel.allowedMail` is only supported for Quick Tunnels and cannot be used together with `tunnel.name`.");
701
729
  const mode = "mode" in userConfig && typeof userConfig.mode === "string" ? userConfig.mode : viteEnv.mode;
702
730
  const root = userConfig.root ? path$1.resolve(userConfig.root) : process.cwd();
703
731
  const envDir = resolveEnvDir(root, userConfig.envDir);
704
732
  const preview = viteEnv.isPreview ? await readBuildOutputPreview(root, !!process.env.CLOUDFLARE_VITE_BUILD) : void 0;
705
- const localEnvMode = preview?.rootConfig.buildContext.mode ?? mode;
706
- const [localEnv, devVars] = await Promise.all([loadEnv(envDir, localEnvMode), loadDevVars(envDir, localEnvMode)]);
707
- Object.assign(process.env, Object.fromEntries(Object.entries(localEnv.values).filter(([name]) => name.startsWith("CLOUDFLARE_"))));
733
+ const localEnvMode = preview ? preview.rootConfig.buildContext.mode : mode;
734
+ const [localEnv, devVars] = await Promise.all([loadLocalEnv(envDir, localEnvMode), loadDevVars(envDir, localEnvMode)]);
708
735
  const types = normalizeTypes(pluginConfig.types);
709
736
  const shared = {
710
737
  persistState: pluginConfig.persistState ?? true,
@@ -726,6 +753,7 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
726
753
  ...shared,
727
754
  remoteBindings,
728
755
  type: "preview",
756
+ mode: localEnvMode,
729
757
  settings: {
730
758
  accountId,
731
759
  complianceRegion
@@ -1508,11 +1536,11 @@ const rscPlugin = createPlugin("rsc", () => {
1508
1536
  //#endregion
1509
1537
  //#region src/plugins/runtime.ts
1510
1538
  const devPlugin = createPlugin("dev", (ctx) => ({ async configureServer(viteDevServer) {
1511
- const { configureDevServer } = await import("./dev-DNaG-ije.mjs");
1539
+ const { configureDevServer } = await import("./dev-DxtsstTp.mjs");
1512
1540
  return configureDevServer(ctx, viteDevServer);
1513
1541
  } }));
1514
1542
  const previewPlugin = createPlugin("preview", (ctx) => ({ async configurePreviewServer(vitePreviewServer) {
1515
- const { configurePreviewServer } = await import("./preview-Dy_2X8R4.mjs");
1543
+ const { configurePreviewServer } = await import("./preview-BfBF559i.mjs");
1516
1544
  return configurePreviewServer(ctx, vitePreviewServer);
1517
1545
  } }));
1518
1546
  const shortcutsPlugin = createPlugin("shortcuts", (ctx) => {
@@ -1521,13 +1549,13 @@ const shortcutsPlugin = createPlugin("shortcuts", (ctx) => {
1521
1549
  async configureServer(viteDevServer) {
1522
1550
  if (!isCustomShortcutsSupported) return;
1523
1551
  assertIsNotPreview(ctx);
1524
- const { addShortcuts } = await import("./shortcuts-BbJ3uPyY.mjs");
1552
+ const { addShortcuts } = await import("./shortcuts-DZD7uOEe.mjs");
1525
1553
  addShortcuts(viteDevServer, ctx);
1526
1554
  },
1527
1555
  async configurePreviewServer(vitePreviewServer) {
1528
1556
  if (!isCustomShortcutsSupported) return;
1529
1557
  assertIsPreview(ctx);
1530
- const { addShortcuts } = await import("./shortcuts-BbJ3uPyY.mjs");
1558
+ const { addShortcuts } = await import("./shortcuts-DZD7uOEe.mjs");
1531
1559
  addShortcuts(vitePreviewServer, ctx);
1532
1560
  }
1533
1561
  };
@@ -1542,11 +1570,11 @@ const shortcutsPlugin = createPlugin("shortcuts", (ctx) => {
1542
1570
  */
1543
1571
  const agentHintPlugin = createPlugin("agent-hint", () => ({
1544
1572
  async configureServer(viteDevServer) {
1545
- const { maybeAddAgentHint } = await import("./agent-hint-D03l5fox.mjs");
1573
+ const { maybeAddAgentHint } = await import("./agent-hint-CtuGRWM-.mjs");
1546
1574
  maybeAddAgentHint(viteDevServer, "dev");
1547
1575
  },
1548
1576
  async configurePreviewServer(vitePreviewServer) {
1549
- const { maybeAddAgentHint } = await import("./agent-hint-D03l5fox.mjs");
1577
+ const { maybeAddAgentHint } = await import("./agent-hint-CtuGRWM-.mjs");
1550
1578
  maybeAddAgentHint(vitePreviewServer, "preview");
1551
1579
  }
1552
1580
  }));
@@ -1561,7 +1589,7 @@ const triggerHandlersPlugin = createPlugin("trigger-handlers", (ctx) => {
1561
1589
  async configureServer(viteDevServer) {
1562
1590
  const entryWorkerConfig = ctx.entryWorkerConfig;
1563
1591
  if (!entryWorkerConfig) return;
1564
- const [{ CoreHeaders }, { createRequestHandler }] = await Promise.all([import("miniflare"), import("./request-handler-BBxibu2n.mjs")]);
1592
+ const [{ CoreHeaders }, { createRequestHandler }] = await Promise.all([import("miniflare"), import("./request-handler-B_lBXFY3.mjs")]);
1565
1593
  const entryWorkerName = entryWorkerConfig.name;
1566
1594
  const requestHandler = createRequestHandler((request) => {
1567
1595
  request.headers.set(CoreHeaders.ROUTE_OVERRIDE, entryWorkerName);
@@ -342,18 +342,24 @@ const COMPLIANCE_REGION_CONFIG_PUBLIC = { compliance_region: "public" };
342
342
  const COMPLIANCE_REGION_CONFIG_UNKNOWN = { compliance_region: void 0 };
343
343
  const getCloudflareComplianceRegionFromEnv = getEnvironmentVariableFactory({
344
344
  variableName: "CLOUDFLARE_COMPLIANCE_REGION",
345
- choices: ["public", "fedramp_high"]
345
+ choices: [
346
+ "public",
347
+ "fedramp_high",
348
+ "fedramp-high"
349
+ ]
346
350
  });
347
351
  /**
348
352
  * Set `CLOUDFLARE_COMPLIANCE_REGION` environment variable to "fedramp_high"
349
- * or set the `compliance_region` property in the Wrangler configuration
350
- * to tell Wrangler to run in FedRAMP High compliance region mode, rather than "public" mode.
353
+ * or "fedramp-high", or set the `compliance_region` property in the Wrangler
354
+ * configuration to tell Wrangler to run in FedRAMP High compliance region mode,
355
+ * rather than "public" mode.
351
356
  */
352
357
  const getCloudflareComplianceRegion = (complianceConfig) => {
353
- const complianceRegionFromEnv = getCloudflareComplianceRegionFromEnv();
358
+ const regionFromEnv = getCloudflareComplianceRegionFromEnv();
359
+ const complianceRegionFromEnv = regionFromEnv === "fedramp-high" ? "fedramp_high" : regionFromEnv;
354
360
  if (complianceRegionFromEnv !== void 0 && complianceConfig?.compliance_region !== void 0 && complianceRegionFromEnv !== complianceConfig.compliance_region) throw new UserError(dedent`
355
361
  The compliance region has been set to different values in two places:
356
- - \`CLOUDFLARE_COMPLIANCE_REGION\` environment variable: \`${complianceRegionFromEnv}\`
362
+ - \`CLOUDFLARE_COMPLIANCE_REGION\` environment variable: \`${regionFromEnv}\`
357
363
  - \`compliance_region\` configuration property: \`${complianceConfig.compliance_region}\`
358
364
  `, { telemetryMessage: false });
359
365
  return complianceRegionFromEnv || complianceConfig?.compliance_region || "public";
@@ -3,12 +3,12 @@ import path from "node:path";
3
3
  import fs from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import os from "node:os";
6
+ import fs$1, { constants as constants$1 } from "node:fs/promises";
6
7
  import { promisify } from "node:util";
7
8
  import process from "node:process";
8
9
  import { Buffer } from "node:buffer";
9
- import fs$1, { constants as constants$1 } from "node:fs/promises";
10
10
  import childProcess, { execFile } from "node:child_process";
11
- //#region ../workers-utils/dist/open-BPppUKSJ.mjs
11
+ //#region ../workers-utils/dist/open-DIY0wydR.mjs
12
12
  let isDockerCached;
13
13
  function hasDockerEnv() {
14
14
  try {
@@ -1,7 +1,7 @@
1
1
  //#region package.json
2
2
  var package_default = {
3
3
  name: "@cloudflare/vite-plugin",
4
- version: "2.0.0-rc.5",
4
+ version: "2.0.0-rc.7",
5
5
  description: "Cloudflare plugin for Vite",
6
6
  keywords: [
7
7
  "cloudflare",
@@ -1,9 +1,9 @@
1
1
  import { r as __toESM } from "./rolldown-runtime-kJ_i4yPo.mjs";
2
- import { _ as getDockerPath } from "./misc-variables-6mf5dDi6-D3ykvtRq.mjs";
3
- import { c as require_picocolors, f as assertIsPreview } from "./tunnel-BczPQL-8.mjs";
4
- import { u as prepareContainerImagesForCfConfig } from "./debug-CPeJINaC.mjs";
5
- import { r as getPreviewMiniflareOptions, t as handleWebSocket } from "./websockets-DUMj2fpZ.mjs";
6
- import { createRequestHandler } from "./request-handler-BBxibu2n.mjs";
2
+ import { _ as getDockerPath } from "./misc-variables-DAIhTBM--a11YYZcp.mjs";
3
+ import { c as require_picocolors, f as assertIsPreview } from "./tunnel-vv4ffjYH.mjs";
4
+ import { u as prepareContainerImagesForCfConfig } from "./debug-DfMbsbf8.mjs";
5
+ import { r as getPreviewMiniflareOptions, t as handleWebSocket } from "./websockets-DEKl8ASJ.mjs";
6
+ import { createRequestHandler } from "./request-handler-B_lBXFY3.mjs";
7
7
  import { buildPublicUrl } from "miniflare";
8
8
  //#region src/plugins/preview.ts
9
9
  var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
@@ -1,4 +1,4 @@
1
- import { a as warnIfQuickTunnelSseResponse } from "./tunnel-BczPQL-8.mjs";
1
+ import { a as warnIfQuickTunnelSseResponse } from "./tunnel-vv4ffjYH.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { CoreHeaders, Request as Request$1, Response as Response$1, parseForwardedProto } from "miniflare";
4
4
  //#region src/constants.ts
@@ -1,13 +1,13 @@
1
1
  import { r as __toESM } from "./rolldown-runtime-kJ_i4yPo.mjs";
2
- import { M as printBindings, V as convertConfigToBindings, c as require_picocolors, n as isTunnelOpen, r as toggleTunnel, t as extendTunnelExpiry } from "./tunnel-BczPQL-8.mjs";
2
+ import { M as printBindings, V as convertConfigToBindings, c as require_picocolors, n as isTunnelOpen, r as toggleTunnel, t as extendTunnelExpiry } from "./tunnel-vv4ffjYH.mjs";
3
3
  import path from "node:path";
4
4
  import fs from "node:fs";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import os from "node:os";
7
+ import fs$1, { constants as constants$1 } from "node:fs/promises";
7
8
  import { promisify } from "node:util";
8
9
  import process$1 from "node:process";
9
10
  import { Buffer } from "node:buffer";
10
- import fs$1, { constants as constants$1 } from "node:fs/promises";
11
11
  import childProcess, { execFile } from "node:child_process";
12
12
  import { convertToWranglerConfig } from "@cloudflare/config";
13
13
  import { CorePaths, getDefaultDevRegistryPath, getWorkerRegistry } from "miniflare";
@@ -1,6 +1,6 @@
1
1
  import { n as __require, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-kJ_i4yPo.mjs";
2
2
  import { i as __toESM$1, n as __name$1, r as __require$1, t as __commonJSMin$1 } from "./rolldown-runtime-BMUeFane-CwDF_oX0.mjs";
3
- import { S as UserError, a as getCloudflareApiBaseUrl, b as removeDirSync, c as getCloudflaredPathFromEnv, g as getBooleanEnvironmentVariableFactory, h as getWranglerCacheDirFromEnv, i as getCIOverrideName, m as getTraceHeader, o as getCloudflareApiEnvironmentFromEnv, p as getSanitizeLogs, s as getCloudflareComplianceRegion, t as COMPLIANCE_REGION_CONFIG_PUBLIC, v as getEnvironmentVariableFactory, x as FatalError, y as getGlobalConfigPath } from "./misc-variables-6mf5dDi6-D3ykvtRq.mjs";
3
+ import { S as UserError, a as getCloudflareApiBaseUrl, b as removeDirSync, c as getCloudflaredPathFromEnv, g as getBooleanEnvironmentVariableFactory, h as getWranglerCacheDirFromEnv, i as getCIOverrideName, m as getTraceHeader, o as getCloudflareApiEnvironmentFromEnv, p as getSanitizeLogs, s as getCloudflareComplianceRegion, t as COMPLIANCE_REGION_CONFIG_PUBLIC, v as getEnvironmentVariableFactory, x as FatalError, y as getGlobalConfigPath } from "./misc-variables-DAIhTBM--a11YYZcp.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import * as path$1 from "node:path";
6
6
  import path, { basename, dirname, isAbsolute, join, resolve } from "node:path";
@@ -8,14 +8,14 @@ import { accessSync, chmodSync, constants, existsSync, mkdirSync, readFileSync,
8
8
  import url, { URLSearchParams as URLSearchParams$1 } from "node:url";
9
9
  import os, { arch, tmpdir } from "node:os";
10
10
  import assert from "node:assert";
11
- import http, { validateHeaderName, validateHeaderValue } from "node:http";
11
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
12
12
  import * as util from "node:util";
13
13
  import { TextEncoder as TextEncoder$1, format, isDeepStrictEqual, stripVTControlCharacters, styleText } from "node:util";
14
+ import http, { validateHeaderName, validateHeaderValue } from "node:http";
14
15
  import process$1, { exit, stdin, stdout } from "node:process";
15
16
  import tty from "node:tty";
16
17
  import net from "node:net";
17
18
  import { createCipheriv, createDecipheriv, createHash, randomBytes, webcrypto } from "node:crypto";
18
- import { mkdir, readFile, writeFile } from "node:fs/promises";
19
19
  import { execFileSync, spawn, spawnSync } from "node:child_process";
20
20
  import * as timersPromises from "node:timers/promises";
21
21
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
@@ -2795,7 +2795,7 @@ function prettifyError(error) {
2795
2795
  return lines.join("\n");
2796
2796
  }
2797
2797
  //#endregion
2798
- //#region ../workers-utils/dist/public-DbHGgnhY.mjs
2798
+ //#region ../workers-utils/dist/public-cxfGmt0z.mjs
2799
2799
  const ARTIFACTS_EVENT_TYPES = [
2800
2800
  "cf.artifacts.repo.created",
2801
2801
  "cf.artifacts.repo.deleted",
@@ -7593,10 +7593,12 @@ const bindingTypeFriendlyNames = {
7593
7593
  logfwdr: "logfwdr",
7594
7594
  unsafe_hello_world: "Hello World",
7595
7595
  flagship: "Flagship",
7596
+ realtimekit: "RealtimeKit",
7596
7597
  ratelimit: "Rate Limit",
7597
7598
  worker_loader: "Worker Loader",
7598
7599
  vpc_service: "VPC Service",
7599
7600
  vpc_network: "VPC Network",
7601
+ oidc_token: "OIDC Token",
7600
7602
  media: "Media",
7601
7603
  assets: "Assets",
7602
7604
  inherit: "Inherited"
@@ -7629,6 +7631,7 @@ const BINDING_LOCAL_SUPPORT = {
7629
7631
  secrets_store_secret: "local-only",
7630
7632
  ratelimit: "local-only",
7631
7633
  worker_loader: "local-only",
7634
+ oidc_token: "local-only",
7632
7635
  kv_namespace: "local-and-remote",
7633
7636
  r2_bucket: "local-and-remote",
7634
7637
  d1: "local-and-remote",
@@ -7647,6 +7650,7 @@ const BINDING_LOCAL_SUPPORT = {
7647
7650
  vectorize: "remote",
7648
7651
  mtls_certificate: "remote",
7649
7652
  dispatch_namespace: "remote",
7653
+ realtimekit: "remote",
7650
7654
  k2: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
7651
7655
  ai: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
7652
7656
  ai_search: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
@@ -7734,7 +7738,7 @@ function createArtifactsLocalDefaultWarner(configFormat) {
7734
7738
  * @see https://github.com/cloudflare/workerd/blob/main/src/workerd/io/BUILD.bazel
7735
7739
  * @see https://github.com/cloudflare/workerd/blob/main/src/workerd/io/compatibility-date.c%2B%2B
7736
7740
  */
7737
- const DEFAULT_COMPAT_DATE = "2026-11-23";
7741
+ const DEFAULT_COMPAT_DATE = "2026-11-27";
7738
7742
  /**
7739
7743
  * Convert Config to the Record<string, Binding> format for consistent internal use.
7740
7744
  */
@@ -8003,6 +8007,12 @@ function convertConfigToBindings(config, options) {
8003
8007
  ...x
8004
8008
  };
8005
8009
  break;
8010
+ case "realtimekit":
8011
+ for (const { binding, ...x } of info) output[binding] = {
8012
+ type: "realtimekit",
8013
+ ...x
8014
+ };
8015
+ break;
8006
8016
  case "ratelimits":
8007
8017
  for (const { name, ...x } of info) output[name] = {
8008
8018
  type: "ratelimit",
@@ -8027,6 +8037,12 @@ function convertConfigToBindings(config, options) {
8027
8037
  ...x
8028
8038
  };
8029
8039
  break;
8040
+ case "oidc_tokens":
8041
+ for (const { binding, ...x } of info) output[binding] = {
8042
+ type: "oidc_token",
8043
+ ...x
8044
+ };
8045
+ break;
8030
8046
  case "media": {
8031
8047
  const { binding, ...x } = info;
8032
8048
  output[binding] = {
@@ -33376,6 +33392,7 @@ function printBindings(bindings, options) {
33376
33392
  const services = extractBindingsOfType("service", bindings);
33377
33393
  const vpc_services = extractBindingsOfType("vpc_service", bindings);
33378
33394
  const vpc_networks = extractBindingsOfType("vpc_network", bindings);
33395
+ const oidc_tokens = extractBindingsOfType("oidc_token", bindings);
33379
33396
  const analytics_engine_datasets = extractBindingsOfType("analytics_engine", bindings);
33380
33397
  const text_blobs = extractBindingsOfType("text_blob", bindings);
33381
33398
  const browser = extractBindingsOfType("browser", bindings);
@@ -33397,6 +33414,7 @@ function printBindings(bindings, options) {
33397
33414
  const assets = extractBindingsOfType("assets", bindings);
33398
33415
  const unsafe_hello_world = extractBindingsOfType("unsafe_hello_world", bindings);
33399
33416
  const flagship = extractBindingsOfType("flagship", bindings);
33417
+ const realtimekit = extractBindingsOfType("realtimekit", bindings);
33400
33418
  const media = extractBindingsOfType("media", bindings);
33401
33419
  const worker_loaders = extractBindingsOfType("worker_loader", bindings);
33402
33420
  const unsafe_bindings = Object.entries(bindings ?? {}).filter(([_, binding]) => isUnsafeBindingType(binding.type) && binding.type !== "unsafe_hello_world").map(([name, binding]) => ({
@@ -33539,6 +33557,14 @@ function printBindings(bindings, options) {
33539
33557
  mode: getMode({ isSimulatedLocally: remote && !context.remoteBindingsDisabled ? false : void 0 })
33540
33558
  };
33541
33559
  }));
33560
+ if (oidc_tokens.length > 0) output.push(...oidc_tokens.map(({ binding, audience, alg }) => {
33561
+ return {
33562
+ name: binding,
33563
+ type: getBindingTypeFriendlyName("oidc_token"),
33564
+ value: alg === void 0 ? audience : `${audience}, ${alg}`,
33565
+ mode: getMode()
33566
+ };
33567
+ }));
33542
33568
  if (r2_buckets.length > 0) output.push(...r2_buckets.map(({ binding, bucket_name, jurisdiction, remote }) => {
33543
33569
  const value = typeof bucket_name === "symbol" ? bucket_name : bucket_name ? `${bucket_name}${jurisdiction ? ` (${jurisdiction})` : ""}` : void 0;
33544
33570
  return {
@@ -33588,6 +33614,14 @@ function printBindings(bindings, options) {
33588
33614
  mode: getMode({ isSimulatedLocally: context.remoteBindingsDisabled || !remote })
33589
33615
  };
33590
33616
  }));
33617
+ if (realtimekit.length > 0) output.push(...realtimekit.map(({ binding, app_id, remote }) => {
33618
+ return {
33619
+ name: binding,
33620
+ type: getBindingTypeFriendlyName("realtimekit"),
33621
+ value: app_id,
33622
+ mode: getMode({ isSimulatedLocally: remote && !context.remoteBindingsDisabled ? false : void 0 })
33623
+ };
33624
+ }));
33591
33625
  if (services.length > 0) output.push(...services.map(({ binding, service, entrypoint, remote, dev }) => {
33592
33626
  let value = service;
33593
33627
  let mode = void 0;
@@ -35669,7 +35703,7 @@ function compareVersions(a, b) {
35669
35703
  */
35670
35704
  async function openInBrowser(url, logger) {
35671
35705
  try {
35672
- const { default: open } = await import("./open-BPppUKSJ-B1ds-b_1.mjs");
35706
+ const { default: open } = await import("./open-DIY0wydR-Df6d7IVS.mjs");
35673
35707
  (await open(url)).on("error", (err) => {
35674
35708
  handleBrowserOpenError(url, err, logger);
35675
35709
  });
@@ -39065,7 +39099,7 @@ var __name = (target, value) => __defProp(target, "name", {
39065
39099
  configurable: true
39066
39100
  });
39067
39101
  //#endregion
39068
- //#region ../workers-auth/dist/authentication-error-CFW0YLMA.mjs
39102
+ //#region ../workers-auth/dist/authentication-error-C1QXCk7I.mjs
39069
39103
  /**
39070
39104
  * Latch shared at module scope so the deprecated-v1-api-token warning fires
39071
39105
  * at most once per process.
@@ -40757,7 +40791,7 @@ function createOAuthFlow(ctx) {
40757
40791
  }
40758
40792
  const complianceRegion = getCloudflareComplianceRegion(props.complianceConfig);
40759
40793
  if (complianceRegion === "fedramp_high") {
40760
- const configurationSource = props.complianceConfig?.compliance_region ? "`compliance_region` configuration property" : "`CLOUDFLARE_API_ENVIRONMENT` environment variable";
40794
+ const configurationSource = props.complianceConfig?.compliance_region ? "`compliance_region` configuration property" : "`CLOUDFLARE_COMPLIANCE_REGION` environment variable";
40761
40795
  throw new UserError(dedent`
40762
40796
  OAuth login is not supported in the \`${complianceRegion}\` compliance region.
40763
40797
  Please use a Cloudflare API token (\`CLOUDFLARE_API_TOKEN\` environment variable) or remove the ${configurationSource}.
@@ -42328,7 +42362,7 @@ var AuthenticationError = class extends UserError {
42328
42362
  }
42329
42363
  };
42330
42364
  //#endregion
42331
- //#region ../workers-auth/dist/auth-config-file-DFymMppU.mjs
42365
+ //#region ../workers-auth/dist/auth-config-file-Cw8iqS0P.mjs
42332
42366
  -(Math.pow(10, 8) * 24 * 60 * 60 * 1e3);
42333
42367
  /**
42334
42368
  * @constant
@@ -43432,6 +43466,7 @@ function createCloudflareAuth(descriptor, ctx) {
43432
43466
  const NOT_LOGGED_IN_WHOAMI_TIP = `\nRun \`${descriptor.commands.whoami}\` to check your current authentication status.`;
43433
43467
  const preferences = createPreferences(descriptor.getConfigPath);
43434
43468
  const persistAccountSelection = descriptor.persistAccountSelection ?? false;
43469
+ const preferConfiguredAccountId = descriptor.preferConfiguredAccountId ?? false;
43435
43470
  const configCache = createConfigCache(logger, descriptor.cacheNamespace ? { namespace: descriptor.cacheNamespace } : void 0);
43436
43471
  let accountSelection;
43437
43472
  let accountSelectionPromise;
@@ -43601,10 +43636,11 @@ Alternatively, try running \`${descriptor.commands.login}\` to re-authenticate.`
43601
43636
  function getActiveAccountId(config) {
43602
43637
  const temporaryAccount = oauthFlow.getActiveTemporaryAccount();
43603
43638
  if (temporaryAccount) return temporaryAccount.account.id;
43604
- if (config.account_id) return validateAccountId(config.account_id, `set in your ${descriptor.getConfigFileLabel()} file`);
43605
- const envAccountId = getCloudflareAccountIdFromEnv();
43606
- if (envAccountId) return envAccountId;
43607
- return resolveAccountSelection()?.id;
43639
+ if (preferConfiguredAccountId) return getConfiguredAccountId(config) ?? getCloudflareAccountIdFromEnv() ?? resolveAccountSelection()?.id;
43640
+ return getCloudflareAccountIdFromEnv() ?? getConfiguredAccountId(config) ?? resolveAccountSelection()?.id;
43641
+ }
43642
+ function getConfiguredAccountId(config) {
43643
+ return config.account_id ? validateAccountId(config.account_id, `set in your ${descriptor.getConfigFileLabel()} file`) : void 0;
43608
43644
  }
43609
43645
  async function selectAccountId(config) {
43610
43646
  const accounts = await fetchAllAccounts(config);
@@ -44904,8 +44940,10 @@ function createAuthForProfile(profile, logger) {
44904
44940
  /**
44905
44941
  * Get the cf credentials for remote bindings sessions.
44906
44942
  *
44907
- * The key includes the resolved profile so a profile change restarts the
44908
- * session with the newly selected credentials.
44943
+ * The key includes the resolved profile, `CLOUDFLARE_ACCOUNT_ID` and
44944
+ * `CLOUDFLARE_API_TOKEN`, so a change to any of them restarts the session with
44945
+ * the new credentials. The variables can change when Vite restarts after an
44946
+ * edit to a `.env` file. The key is hashed so it holds no secret.
44909
44947
  *
44910
44948
  * @param profileDir - Directory used to resolve the cf auth profile.
44911
44949
  * @param accountId - The configured account ID, if any.
@@ -44922,11 +44960,13 @@ function getRemoteBindingsAuth(profileDir, accountId, getAuth) {
44922
44960
  apiToken: auth.requireApiToken()
44923
44961
  };
44924
44962
  },
44925
- key: JSON.stringify([
44963
+ key: createHash("sha256").update(JSON.stringify([
44926
44964
  profileDir,
44927
44965
  accountId,
44966
+ process.env.CLOUDFLARE_ACCOUNT_ID,
44967
+ process.env.CLOUDFLARE_API_TOKEN,
44928
44968
  auth.getActiveProfile()
44929
- ])
44969
+ ])).digest("hex")
44930
44970
  };
44931
44971
  }
44932
44972
  /** Adapt Vite's logger to the shared Cloudflare API logger interface. */
@@ -45041,8 +45081,16 @@ var PluginContext = class {
45041
45081
  }
45042
45082
  getCloudflareAuth(profileDir, logger) {
45043
45083
  const profile = resolveAuthProfile(profileDir, logger);
45044
- if (this.#sharedContext.auth?.getActiveProfile() !== profile) this.#sharedContext.auth = createAuthForProfile(profile, logger);
45045
- return this.#sharedContext.auth;
45084
+ const apiToken = process.env.CLOUDFLARE_API_TOKEN;
45085
+ let auth = this.#sharedContext.auth;
45086
+ if (auth?.instance.getActiveProfile() !== profile || auth.apiToken !== apiToken) {
45087
+ auth = {
45088
+ instance: createAuthForProfile(profile, logger),
45089
+ apiToken
45090
+ };
45091
+ this.#sharedContext.auth = auth;
45092
+ }
45093
+ return auth.instance;
45046
45094
  }
45047
45095
  /** Creates a new Miniflare instance or updates the existing instance */
45048
45096
  async startOrUpdateMiniflare(options) {