@cloudflare/workers-utils 0.48.0 → 0.49.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'node:module';
2
2
  export { MetricsRegistry } from './chunk-6G6FCMPX.mjs';
3
- import { external_exports } from './chunk-CAPCWVOB.mjs';
4
- export { formatZodError } from './chunk-CAPCWVOB.mjs';
3
+ import { external_exports } from './chunk-XEBMRQST.mjs';
4
+ export { formatZodError } from './chunk-XEBMRQST.mjs';
5
5
  import { isRedirectedRawConfig, configFileName, formatConfigSnippet, partitionExports, getDurableObjectExports, getContainerNameToClassNameMap, parsePackageJSON, readFileSync, ParseError, parseJSON, APIError, isLiveDurableObjectExport, dir, parseTOML, modify, applyEdits, format, stringify, parseJSONC } from './chunk-2HLTAS5V.mjs';
6
6
  export { APIError, ENVIRONMENT_TAG_PREFIX, INHERIT_SYMBOL, JSON_CONFIG_FORMATS, PATH_TO_DEPLOY_CONFIG, ParseError, SERVICE_TAG_PREFIX, configFileName, configFormat, experimental_readRawConfig, findWranglerConfig, formatConfigSnippet, getContainerDurableObjectClassNames, getContainerNameToClassNameMap, getDurableObjectClassNameToUseSQLiteMap, getDurableObjectContainerApps, getDurableObjectExports, getResolvedDurableObjectContainerApps, hasDurableObjectExports, indexLocation, isDurableObjectContainerApp, isLiveDurableObjectExport, isRedirectedConfig, parseByteSize, parseHumanDuration, parseJSON, parseJSONC, parseNonHyphenedUuid, parsePackageJSON, parseTOML, partitionExports, readFileSync, readFileSyncToBuffer, resolveContainerClassName, resolveWranglerConfigPath, searchLocation, validateDurableObjectContainerApplications } from './chunk-2HLTAS5V.mjs';
7
7
  export { NODEJS_COMPAT_DEFAULT_ON_DATE, NODEJS_COMPAT_V2_SWITCH_OVER_DATE, getTodaysCompatDate, isCompatDate, isNodejsCompatDefaultOn, resolveNodejsCompat, stripRedundantNodejsCompatFlags } from './chunk-2Q77CKVU.mjs';
@@ -9166,7 +9166,7 @@ function mapWorkerMetadataBindings(bindings) {
9166
9166
  __name(mapWorkerMetadataBindings, "mapWorkerMetadataBindings");
9167
9167
 
9168
9168
  // src/default-compat-date.ts
9169
- var DEFAULT_COMPAT_DATE = "2026-10-19";
9169
+ var DEFAULT_COMPAT_DATE = "2026-10-23";
9170
9170
 
9171
9171
  // src/construct-wrangler-config.ts
9172
9172
  function constructWranglerConfig(config) {
@@ -1,3 +1,5 @@
1
+ declare function caseInsensitiveEnv(): Record<string, string>;
2
+
1
3
  type LocalEnvValueSource = {
2
4
  type: "file";
3
5
  path: string;
@@ -8,6 +10,21 @@ interface LoadedEnv {
8
10
  values: Record<string, string>;
9
11
  sources: Record<string, LocalEnvValueSource>;
10
12
  }
13
+ /**
14
+ * Parses dotenv contents and expands variable references without changing the
15
+ * supplied process environment or adding its unrelated keys to the result.
16
+ *
17
+ * Process values override file values, including explicitly empty strings. On
18
+ * Windows, process keys are matched case-insensitively. References can use
19
+ * process values and earlier file values; unresolved references become empty
20
+ * strings. Escape a dollar sign with `\$` to keep it literal.
21
+ *
22
+ * @param contents The dotenv contents to parse and expand.
23
+ * @param processEnv The process values used for expansion and overrides.
24
+ * Defaults to `process.env`.
25
+ * @returns Expanded values for the keys declared in the dotenv contents.
26
+ */
27
+ declare function parseAndExpandDotEnv(contents: string, processEnv?: NodeJS.ProcessEnv): Record<string, string>;
11
28
  /**
12
29
  * Returns the local `.env` candidates in increasing precedence order.
13
30
  *
@@ -51,4 +68,4 @@ declare function loadEnv(envDir: string | false, mode?: string): Promise<LoadedE
51
68
  */
52
69
  declare function loadDevVars(envDir: string | false, mode?: string): Promise<Record<string, string> | undefined>;
53
70
 
54
- export { type LoadedEnv, type LocalEnvValueSource, getDevVarsCandidatePaths, getEnvPaths, loadDevVars, loadEnv };
71
+ export { type LoadedEnv, type LocalEnvValueSource, caseInsensitiveEnv, getDevVarsCandidatePaths, getEnvPaths, loadDevVars, loadEnv, parseAndExpandDotEnv };
@@ -82,6 +82,71 @@ var require_main = __commonJS({
82
82
 
83
83
  // src/local-env.ts
84
84
  var import_dotenv_expand = __toESM(require_main());
85
+
86
+ // src/case-insensitive-env.ts
87
+ function caseInsensitiveEnv() {
88
+ const tracked = /* @__PURE__ */ new Map();
89
+ const targetObj = {};
90
+ const canonical = /* @__PURE__ */ __name((property) => typeof property === "string" ? property.toLowerCase() : property, "canonical");
91
+ return new Proxy(targetObj, {
92
+ get(target, property, receiver) {
93
+ const actualProperty = tracked.get(canonical(property));
94
+ return actualProperty !== void 0 ? Reflect.get(target, actualProperty, receiver) : void 0;
95
+ },
96
+ set(target, property, value, receiver) {
97
+ const key = canonical(property);
98
+ const previous = tracked.get(key);
99
+ if (previous !== void 0 && previous !== property) {
100
+ Reflect.deleteProperty(target, previous);
101
+ }
102
+ tracked.set(key, property);
103
+ return Reflect.set(target, property, value, receiver);
104
+ },
105
+ has(target, property) {
106
+ const actualProperty = tracked.get(canonical(property));
107
+ return actualProperty !== void 0 ? Reflect.has(target, actualProperty) : false;
108
+ },
109
+ getOwnPropertyDescriptor(target, property) {
110
+ const actualProperty = tracked.get(canonical(property));
111
+ return actualProperty !== void 0 ? Reflect.getOwnPropertyDescriptor(target, actualProperty) : void 0;
112
+ },
113
+ defineProperty(target, property, descriptor) {
114
+ const key = canonical(property);
115
+ const previous = tracked.get(key);
116
+ if (previous !== void 0 && previous !== property) {
117
+ Reflect.deleteProperty(target, previous);
118
+ }
119
+ tracked.set(key, property);
120
+ return Reflect.defineProperty(target, property, descriptor);
121
+ },
122
+ deleteProperty(target, property) {
123
+ const key = canonical(property);
124
+ const actualProperty = tracked.get(key);
125
+ tracked.delete(key);
126
+ return actualProperty !== void 0 ? Reflect.deleteProperty(target, actualProperty) : Reflect.deleteProperty(target, property);
127
+ }
128
+ });
129
+ }
130
+ __name(caseInsensitiveEnv, "caseInsensitiveEnv");
131
+
132
+ // src/local-env.ts
133
+ function parseAndExpandDotEnv(contents, processEnv = process.env) {
134
+ return expandParsedDotEnv(parse(contents), processEnv);
135
+ }
136
+ __name(parseAndExpandDotEnv, "parseAndExpandDotEnv");
137
+ function expandParsedDotEnv(parsed, processEnv) {
138
+ const expanded = { ...parsed };
139
+ const expandedKeys = Object.keys(expanded);
140
+ const processEnvOverrides = copyProcessEnv(processEnv);
141
+ (0, import_dotenv_expand.expand)({ parsed: expanded, processEnv: copyProcessEnv(processEnv) });
142
+ for (const key of expandedKeys) {
143
+ if (Object.hasOwn(processEnvOverrides, key)) {
144
+ expanded[key] = processEnvOverrides[key];
145
+ }
146
+ }
147
+ return expanded;
148
+ }
149
+ __name(expandParsedDotEnv, "expandParsedDotEnv");
85
150
  function getEnvPaths(envDir, mode) {
86
151
  if (envDir === false) {
87
152
  return [];
@@ -123,9 +188,8 @@ async function loadEnv(envDir, mode) {
123
188
  parsedSources[key] = { type: "file", path: loaded.path };
124
189
  }
125
190
  }
126
- const processEnv = copyProcessEnv();
127
- (0, import_dotenv_expand.expand)({ parsed, processEnv: { ...processEnv } });
128
- const values = { ...parsed };
191
+ const processEnv = copyProcessEnv(process.env);
192
+ const values = expandParsedDotEnv(parsed, processEnv);
129
193
  const sources = { ...parsedSources };
130
194
  for (const [key, value] of Object.entries(processEnv)) {
131
195
  values[key] = value;
@@ -167,13 +231,15 @@ function isMissingFileError(error) {
167
231
  return error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR");
168
232
  }
169
233
  __name(isMissingFileError, "isMissingFileError");
170
- function copyProcessEnv() {
171
- return Object.fromEntries(
172
- Object.entries(process.env).filter(
173
- (entry) => entry[1] !== void 0
174
- )
175
- );
234
+ function copyProcessEnv(processEnv) {
235
+ const copied = process.platform === "win32" ? caseInsensitiveEnv() : {};
236
+ for (const [key, value] of Object.entries(processEnv)) {
237
+ if (value !== void 0) {
238
+ copied[key] = value;
239
+ }
240
+ }
241
+ return copied;
176
242
  }
177
243
  __name(copyProcessEnv, "copyProcessEnv");
178
244
 
179
- export { getDevVarsCandidatePaths, getEnvPaths, loadDevVars, loadEnv };
245
+ export { caseInsensitiveEnv, getDevVarsCandidatePaths, getEnvPaths, loadDevVars, loadEnv, parseAndExpandDotEnv };