wrangler 3.28.1 → 3.28.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "3.28.1",
3
+ "version": "3.28.2",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -83,7 +83,6 @@
83
83
  }
84
84
  },
85
85
  "dependencies": {
86
- "@cloudflare/kv-asset-handler": "^0.2.0",
87
86
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
88
87
  "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
89
88
  "blake3-wasm": "^2.1.5",
@@ -96,7 +95,8 @@
96
95
  "selfsigned": "^2.0.1",
97
96
  "source-map": "0.6.1",
98
97
  "xxhash-wasm": "^1.0.1",
99
- "miniflare": "3.20240129.1"
98
+ "@cloudflare/kv-asset-handler": "0.3.1",
99
+ "miniflare": "3.20240129.2"
100
100
  },
101
101
  "devDependencies": {
102
102
  "@cloudflare/ai": "^1.0.35",
@@ -187,7 +187,7 @@
187
187
  "yargs": "^17.7.2",
188
188
  "yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
189
189
  "@cloudflare/cli": "1.1.1",
190
- "@cloudflare/pages-shared": "^0.11.11",
190
+ "@cloudflare/pages-shared": "^0.11.12",
191
191
  "@cloudflare/workers-tsconfig": "0.0.0"
192
192
  },
193
193
  "optionalDependencies": {
@@ -220,7 +220,7 @@
220
220
  "test": "pnpm run assert-git-version && jest",
221
221
  "test:ci": "pnpm run test --coverage",
222
222
  "test:debug": "pnpm run test --silent=false --verbose=true",
223
- "test:e2e": "vitest --test-timeout 240000 --single-thread --dir ./e2e --retry 2 run",
223
+ "test:e2e": "vitest --test-timeout 240000 --poolOptions.threads.singleThread --dir ./e2e --retry 2 run",
224
224
  "test:watch": "pnpm run test --testTimeout=50000 --watch",
225
225
  "type:tests": "tsc -p ./src/__tests__/tsconfig.json && tsc -p ./e2e/tsconfig.json"
226
226
  }
@@ -113,10 +113,11 @@ export class ProxyWorker implements DurableObject {
113
113
  this.requestRetryQueue.delete(request);
114
114
  this.requestQueue.delete(request);
115
115
 
116
- const userWorkerUrl = new URL(request.url);
116
+ const outerUrl = new URL(request.url);
117
117
  const headers = new Headers(request.headers);
118
118
 
119
119
  // override url parts for proxying
120
+ const userWorkerUrl = new URL(request.url);
120
121
  Object.assign(userWorkerUrl, proxyData.userWorkerUrl);
121
122
 
122
123
  // set request.url in the UserWorker
@@ -125,6 +126,8 @@ export class ProxyWorker implements DurableObject {
125
126
  headers.set("MF-Original-URL", innerUrl.href);
126
127
  headers.set("MF-Disable-Pretty-Error", "true"); // disables the UserWorker miniflare instance from rendering the pretty error -- instead the ProxyWorker miniflare instance will intercept the json error response and render the pretty error page
127
128
 
129
+ rewriteUrlRelatedHeaders(headers, outerUrl, innerUrl);
130
+
128
131
  // merge proxyData headers with the request headers
129
132
  for (const [key, value] of Object.entries(proxyData.headers ?? {})) {
130
133
  if (value === undefined) continue;
@@ -140,6 +143,9 @@ export class ProxyWorker implements DurableObject {
140
143
  // explicitly NOT await-ing this promise, we are in a loop and want to process the whole queue quickly + synchronously
141
144
  void fetch(userWorkerUrl, new Request(request, { headers }))
142
145
  .then((res) => {
146
+ res = new Response(res.body, res);
147
+ rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);
148
+
143
149
  if (isHtmlResponse(res)) {
144
150
  res = insertLiveReloadScript(request, res, this.env, proxyData);
145
151
  }
@@ -290,3 +296,20 @@ function insertLiveReloadScript(
290
296
 
291
297
  return htmlRewriter.transform(response);
292
298
  }
299
+
300
+ /**
301
+ * Rewrite references to URLs in request/response headers.
302
+ *
303
+ * This function is used to map the URLs in headers like Origin and Access-Control-Allow-Origin
304
+ * so that this proxy is transparent to the Client Browser and User Worker.
305
+ */
306
+ function rewriteUrlRelatedHeaders(headers: Headers, from: URL, to: URL) {
307
+ headers.forEach((value, key) => {
308
+ if (typeof value === "string" && value.includes(from.host)) {
309
+ headers.set(
310
+ key,
311
+ value.replaceAll(from.origin, to.origin).replaceAll(from.host, to.host)
312
+ );
313
+ }
314
+ });
315
+ }
@@ -90,13 +90,15 @@ var ProxyWorker = class {
90
90
  for (const [request, deferredResponse] of this.getOrderedQueue()) {
91
91
  this.requestRetryQueue.delete(request);
92
92
  this.requestQueue.delete(request);
93
- const userWorkerUrl = new URL(request.url);
93
+ const outerUrl = new URL(request.url);
94
94
  const headers = new Headers(request.headers);
95
+ const userWorkerUrl = new URL(request.url);
95
96
  Object.assign(userWorkerUrl, proxyData.userWorkerUrl);
96
97
  const innerUrl = new URL(request.url);
97
98
  Object.assign(innerUrl, proxyData.userWorkerInnerUrlOverrides);
98
99
  headers.set("MF-Original-URL", innerUrl.href);
99
100
  headers.set("MF-Disable-Pretty-Error", "true");
101
+ rewriteUrlRelatedHeaders(headers, outerUrl, innerUrl);
100
102
  for (const [key, value] of Object.entries(proxyData.headers ?? {})) {
101
103
  if (value === void 0)
102
104
  continue;
@@ -108,6 +110,8 @@ var ProxyWorker = class {
108
110
  }
109
111
  }
110
112
  void fetch(userWorkerUrl, new Request(request, { headers })).then((res) => {
113
+ res = new Response(res.body, res);
114
+ rewriteUrlRelatedHeaders(res.headers, innerUrl, outerUrl);
111
115
  if (isHtmlResponse(res)) {
112
116
  res = insertLiveReloadScript(request, res, this.env, proxyData);
113
117
  }
@@ -205,6 +209,16 @@ function insertLiveReloadScript(request, response, env, proxyData) {
205
209
  });
206
210
  return htmlRewriter.transform(response);
207
211
  }
212
+ function rewriteUrlRelatedHeaders(headers, from, to) {
213
+ headers.forEach((value, key) => {
214
+ if (typeof value === "string" && value.includes(from.host)) {
215
+ headers.set(
216
+ key,
217
+ value.replaceAll(from.origin, to.origin).replaceAll(from.host, to.host)
218
+ );
219
+ }
220
+ });
221
+ }
208
222
  export {
209
223
  ProxyWorker,
210
224
  ProxyWorker_default as default
@@ -1,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S;AACvE,UAAQ,QAAQ,CAAC,OAAO,QAAQ;AAC/B,QAAI,OAAO,UAAU,YAAY,MAAM,SAAS,KAAK,IAAI,GAAG;AAC3D,cAAQ;AAAA,QACP;AAAA,QACA,MAAM,WAAW,KAAK,QAAQ,GAAG,MAAM,EAAE,WAAW,KAAK,MAAM,GAAG,IAAI;AAAA,MACvE;AAAA,IACD;AAAA,EACD,CAAC;AACF;",
5
5
  "names": []
6
6
  }
@@ -137,27 +137,11 @@ declare type Binding = {
137
137
  /**
138
138
  * Result of the `getBindingsProxy` utility
139
139
  */
140
- export declare type BindingsProxy<Bindings = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties_2> = {
140
+ export declare type BindingsProxy<Bindings = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties_2> = Omit<PlatformProxy<Bindings, CfProperties>, "env"> & {
141
141
  /**
142
142
  * Object containing the various proxies
143
143
  */
144
144
  bindings: Bindings;
145
- /**
146
- * Mock of the context object that Workers received in their request handler, all the object's methods are no-op
147
- */
148
- cf: CfProperties;
149
- /**
150
- * Mock of the context object that Workers received in their request handler, all the object's methods are no-op
151
- */
152
- ctx: ExecutionContext_2;
153
- /**
154
- * Caches object emulating the Workers Cache runtime API
155
- */
156
- caches: CacheStorage_3;
157
- /**
158
- * Function used to dispose of the child process providing the bindings implementation
159
- */
160
- dispose: () => Promise<void>;
161
145
  };
162
146
 
163
147
  declare interface BlobPropertyBag {
@@ -353,7 +337,7 @@ declare const CacheStorage_2: {
353
337
  *
354
338
  * We are not using miniflare's implementation because that would require the user to provide
355
339
  * miniflare-specific Request objects and they would receive back miniflare-specific Response
356
- * objects, this (in particular the Request part) is not really suitable for `getBindingsProxy`
340
+ * objects, this (in particular the Request part) is not really suitable for `getPlatformProxy`
357
341
  * as people would ideally interact with their bindings in a very production-like manner and
358
342
  * requiring them to deal with miniflare-specific classes defeats a bit the purpose of the utility.
359
343
  *
@@ -2280,15 +2264,36 @@ declare type FormDataEntryValue = string | File_2
2280
2264
  * By reading from a `wrangler.toml` file this function generates proxy binding objects that can be
2281
2265
  * used to simulate the interaction with bindings during local development in a Node.js environment
2282
2266
  *
2267
+ * @deprecated use `getPlatformProxy` instead
2268
+ *
2283
2269
  * @param options The various options that can tweak this function's behavior
2284
2270
  * @returns An Object containing the generated proxies alongside other related utilities
2285
2271
  */
2286
2272
  export declare function getBindingsProxy<Bindings = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties_2>(options?: GetBindingsProxyOptions): Promise<BindingsProxy<Bindings, CfProperties>>;
2287
2273
 
2274
+ /** Options for the `getBindingsProxy` utility */
2275
+ export declare type GetBindingsProxyOptions = GetPlatformProxyOptions;
2276
+
2277
+ declare function getCookies (headers: Headers_2): Record<string, string>
2278
+
2279
+ declare function getGlobalDispatcher(): Dispatcher;
2280
+
2281
+ declare function getGlobalOrigin(): URL | undefined;
2282
+
2283
+ /**
2284
+ * By reading from a `wrangler.toml` file this function generates proxy objects that can be
2285
+ * used to simulate the interaction with the Cloudflare platform during local development
2286
+ * in a Node.js environment
2287
+ *
2288
+ * @param options The various options that can tweak this function's behavior
2289
+ * @returns An Object containing the generated proxies alongside other related utilities
2290
+ */
2291
+ export declare function getPlatformProxy<Env = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties_2>(options?: GetPlatformProxyOptions): Promise<PlatformProxy<Env, CfProperties>>;
2292
+
2288
2293
  /**
2289
- * Options for the `getBindingsProxy` utility
2294
+ * Options for the `getPlatformProxy` utility
2290
2295
  */
2291
- export declare type GetBindingsProxyOptions = {
2296
+ export declare type GetPlatformProxyOptions = {
2292
2297
  /**
2293
2298
  * The path to the config object to use (default `wrangler.toml`)
2294
2299
  */
@@ -2310,12 +2315,6 @@ export declare type GetBindingsProxyOptions = {
2310
2315
  };
2311
2316
  };
2312
2317
 
2313
- declare function getCookies (headers: Headers_2): Record<string, string>
2314
-
2315
- declare function getGlobalDispatcher(): Dispatcher;
2316
-
2317
- declare function getGlobalOrigin(): URL | undefined;
2318
-
2319
2318
  declare function getSetCookies (headers: Headers_2): Cookie[]
2320
2319
 
2321
2320
  declare class Headers_2 implements SpecIterable<[string, string]> {
@@ -2660,6 +2659,32 @@ options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions, 'origin'
2660
2659
  handler: Dispatcher.PipelineHandler
2661
2660
  ): Duplex;
2662
2661
 
2662
+ /**
2663
+ * Result of the `getPlatformProxy` utility
2664
+ */
2665
+ export declare type PlatformProxy<Env = Record<string, unknown>, CfProperties extends Record<string, unknown> = IncomingRequestCfProperties_2> = {
2666
+ /**
2667
+ * Environment object containing the various Cloudflare bindings
2668
+ */
2669
+ env: Env;
2670
+ /**
2671
+ * Mock of the context object that Workers received in their request handler, all the object's methods are no-op
2672
+ */
2673
+ cf: CfProperties;
2674
+ /**
2675
+ * Mock of the context object that Workers received in their request handler, all the object's methods are no-op
2676
+ */
2677
+ ctx: ExecutionContext_2;
2678
+ /**
2679
+ * Caches object emulating the Workers Cache runtime API
2680
+ */
2681
+ caches: CacheStorage_3;
2682
+ /**
2683
+ * Function used to dispose of the child process providing the bindings implementation
2684
+ */
2685
+ dispose: () => Promise<void>;
2686
+ };
2687
+
2663
2688
  declare class Pool extends Dispatcher {
2664
2689
  constructor(url: string | URL_2, options?: Pool.Options)
2665
2690
  /** `true` after `pool.close()` has been called. */
@@ -23018,7 +23043,7 @@ declare type ProxyData = {
23018
23043
  userWorkerUrl: UrlOriginParts;
23019
23044
  userWorkerInspectorUrl: UrlOriginAndPathnameParts;
23020
23045
  userWorkerInnerUrlOverrides: Partial<UrlOriginParts>;
23021
- headers: Record<string, string | undefined>;
23046
+ headers: Record<string, string>;
23022
23047
  liveReload?: boolean;
23023
23048
  proxyLogsToController?: boolean;
23024
23049
  internalDurableObjects?: CfDurableObject[];
@@ -116035,6 +116035,7 @@ var require_dist6 = __commonJS({
116035
116035
  var cli_exports = {};
116036
116036
  __export(cli_exports, {
116037
116037
  getBindingsProxy: () => getBindingsProxy,
116038
+ getPlatformProxy: () => getPlatformProxy,
116038
116039
  unstable_DevEnv: () => DevEnv,
116039
116040
  unstable_dev: () => unstable_dev,
116040
116041
  unstable_pages: () => unstable_pages
@@ -119620,7 +119621,7 @@ var import_node_assert2 = __toESM(require("node:assert"));
119620
119621
  var import_undici3 = __toESM(require_undici());
119621
119622
 
119622
119623
  // package.json
119623
- var version = "3.28.1";
119624
+ var version = "3.28.2";
119624
119625
  var package_default = {
119625
119626
  name: "wrangler",
119626
119627
  version,
@@ -119686,7 +119687,7 @@ var package_default = {
119686
119687
  test: "pnpm run assert-git-version && jest",
119687
119688
  "test:ci": "pnpm run test --coverage",
119688
119689
  "test:debug": "pnpm run test --silent=false --verbose=true",
119689
- "test:e2e": "vitest --test-timeout 240000 --single-thread --dir ./e2e --retry 2 run",
119690
+ "test:e2e": "vitest --test-timeout 240000 --poolOptions.threads.singleThread --dir ./e2e --retry 2 run",
119690
119691
  "test:watch": "pnpm run test --testTimeout=50000 --watch",
119691
119692
  "type:tests": "tsc -p ./src/__tests__/tsconfig.json && tsc -p ./e2e/tsconfig.json"
119692
119693
  },
@@ -119724,7 +119725,7 @@ var package_default = {
119724
119725
  }
119725
119726
  },
119726
119727
  dependencies: {
119727
- "@cloudflare/kv-asset-handler": "^0.2.0",
119728
+ "@cloudflare/kv-asset-handler": "workspace:*",
119728
119729
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
119729
119730
  "@esbuild-plugins/node-modules-polyfill": "^0.2.2",
119730
119731
  "blake3-wasm": "^2.1.5",
@@ -126577,14 +126578,23 @@ __name(execaCommandSync, "execaCommandSync");
126577
126578
  async function runCustomBuild(expectedEntryAbsolute, expectedEntryRelative, build5) {
126578
126579
  if (build5.command) {
126579
126580
  logger.log("Running custom build:", build5.command);
126580
- await execaCommand(build5.command, {
126581
- shell: true,
126582
- // we keep these two as "inherit" so that
126583
- // logs are still visible.
126584
- stdout: "inherit",
126585
- stderr: "inherit",
126586
- ...build5.cwd && { cwd: build5.cwd }
126587
- });
126581
+ try {
126582
+ await execaCommand(build5.command, {
126583
+ shell: true,
126584
+ // we keep these two as "inherit" so that
126585
+ // logs are still visible.
126586
+ stdout: "inherit",
126587
+ stderr: "inherit",
126588
+ ...build5.cwd && { cwd: build5.cwd }
126589
+ });
126590
+ } catch (e3) {
126591
+ throw new UserError(
126592
+ `Running custom build \`${build5.command}\` failed. There are likely more logs from your build command above.`,
126593
+ {
126594
+ cause: e3
126595
+ }
126596
+ );
126597
+ }
126588
126598
  assertEntryPointExists(
126589
126599
  expectedEntryAbsolute,
126590
126600
  expectedEntryRelative,
@@ -166015,11 +166025,13 @@ ${onboardingLink}`);
166015
166025
  port: workerPreviewToken.inspectorUrl.port.toString(),
166016
166026
  pathname: workerPreviewToken.inspectorUrl.pathname
166017
166027
  },
166018
- userWorkerInnerUrlOverrides: {},
166019
- // there is no analagous prop for this option because we did not permit overriding request.url in remote mode
166028
+ userWorkerInnerUrlOverrides: {
166029
+ hostname: props.host,
166030
+ port: props.port.toString()
166031
+ },
166020
166032
  headers: {
166021
166033
  "cf-workers-preview-token": workerPreviewToken.value,
166022
- Cookie: accessToken && `CF_Authorization=${accessToken}`
166034
+ ...accessToken ? { Cookie: `CF_Authorization=${accessToken}` } : {}
166023
166035
  },
166024
166036
  liveReload: false,
166025
166037
  // liveReload currently disabled in remote-mode, but will be supported with startDevWorker
@@ -166113,11 +166125,13 @@ async function startRemoteServer(props) {
166113
166125
  port: previewToken.inspectorUrl.port.toString(),
166114
166126
  pathname: previewToken.inspectorUrl.pathname
166115
166127
  },
166116
- userWorkerInnerUrlOverrides: {},
166117
- // there is no analagous prop for this option because we did not permit overriding request.url in remote mode
166128
+ userWorkerInnerUrlOverrides: {
166129
+ hostname: props.host,
166130
+ port: props.port.toString()
166131
+ },
166118
166132
  headers: {
166119
166133
  "cf-workers-preview-token": previewToken.value,
166120
- Cookie: accessToken && `CF_Authorization=${accessToken}`
166134
+ ...accessToken ? { Cookie: `CF_Authorization=${accessToken}` } : {}
166121
166135
  },
166122
166136
  liveReload: false,
166123
166137
  // liveReload currently disabled in remote-mode, but will be supported with startDevWorker
@@ -166516,7 +166530,8 @@ function useEsbuild({
166516
166530
  testScheduled,
166517
166531
  experimentalLocal,
166518
166532
  projectRoot,
166519
- onBundleStart
166533
+ onBundleStart,
166534
+ defineNavigatorUserAgent
166520
166535
  ]);
166521
166536
  return bundle;
166522
166537
  }
@@ -169053,11 +169068,11 @@ init_import_meta_url();
169053
169068
  // src/api/integrations/index.ts
169054
169069
  init_import_meta_url();
169055
169070
 
169056
- // src/api/integrations/bindings/index.ts
169071
+ // src/api/integrations/platform/index.ts
169057
169072
  init_import_meta_url();
169058
169073
  var import_miniflare18 = require("miniflare");
169059
169074
 
169060
- // src/api/integrations/bindings/caches.ts
169075
+ // src/api/integrations/platform/caches.ts
169061
169076
  init_import_meta_url();
169062
169077
  var CacheStorage = class {
169063
169078
  async open(cacheName) {
@@ -169080,7 +169095,7 @@ var Cache2 = class {
169080
169095
  };
169081
169096
  __name(Cache2, "Cache");
169082
169097
 
169083
- // src/api/integrations/bindings/executionContext.ts
169098
+ // src/api/integrations/platform/executionContext.ts
169084
169099
  init_import_meta_url();
169085
169100
  var ExecutionContext = class {
169086
169101
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, unused-imports/no-unused-vars
@@ -169091,7 +169106,7 @@ var ExecutionContext = class {
169091
169106
  };
169092
169107
  __name(ExecutionContext, "ExecutionContext");
169093
169108
 
169094
- // src/api/integrations/bindings/services.ts
169109
+ // src/api/integrations/platform/services.ts
169095
169110
  init_import_meta_url();
169096
169111
  var import_miniflare17 = require("miniflare");
169097
169112
  var import_undici24 = __toESM(require_undici());
@@ -169161,8 +169176,8 @@ async function maybeGetRegisteredWorkers() {
169161
169176
  }
169162
169177
  __name(maybeGetRegisteredWorkers, "maybeGetRegisteredWorkers");
169163
169178
 
169164
- // src/api/integrations/bindings/index.ts
169165
- async function getBindingsProxy(options25 = {}) {
169179
+ // src/api/integrations/platform/index.ts
169180
+ async function getPlatformProxy(options25 = {}) {
169166
169181
  const rawConfig = readConfig(options25.configPath, {
169167
169182
  experimentalJsonConfig: options25.experimentalJsonConfig
169168
169183
  });
@@ -169182,7 +169197,7 @@ async function getBindingsProxy(options25 = {}) {
169182
169197
  const cf = await mf.getCf();
169183
169198
  deepFreeze(cf);
169184
169199
  return {
169185
- bindings: {
169200
+ env: {
169186
169201
  ...vars,
169187
169202
  ...bindings
169188
169203
  },
@@ -169192,7 +169207,7 @@ async function getBindingsProxy(options25 = {}) {
169192
169207
  dispose: () => mf.dispose()
169193
169208
  };
169194
169209
  }
169195
- __name(getBindingsProxy, "getBindingsProxy");
169210
+ __name(getPlatformProxy, "getPlatformProxy");
169196
169211
  async function getMiniflareOptionsFromConfig(rawConfig, env5, options25) {
169197
169212
  const bindings = getBindings(rawConfig, env5, true, {});
169198
169213
  const workerDefinitions = await getBoundRegisteredWorkers({
@@ -169255,6 +169270,20 @@ function deepFreeze(obj) {
169255
169270
  }
169256
169271
  __name(deepFreeze, "deepFreeze");
169257
169272
 
169273
+ // src/api/integrations/deprecated/index.ts
169274
+ init_import_meta_url();
169275
+
169276
+ // src/api/integrations/deprecated/getBindingsProxy.ts
169277
+ init_import_meta_url();
169278
+ async function getBindingsProxy(options25 = {}) {
169279
+ const { env: env5, ...restOfPlatformProxy } = await getPlatformProxy(options25);
169280
+ return {
169281
+ bindings: env5,
169282
+ ...restOfPlatformProxy
169283
+ };
169284
+ }
169285
+ __name(getBindingsProxy, "getBindingsProxy");
169286
+
169258
169287
  // src/cli.ts
169259
169288
  if (typeof jest === "undefined" && require.main === module) {
169260
169289
  main(hideBin(import_process6.default.argv)).catch((e3) => {
@@ -169265,6 +169294,7 @@ if (typeof jest === "undefined" && require.main === module) {
169265
169294
  // Annotate the CommonJS export names for ESM import in node:
169266
169295
  0 && (module.exports = {
169267
169296
  getBindingsProxy,
169297
+ getPlatformProxy,
169268
169298
  unstable_DevEnv,
169269
169299
  unstable_dev,
169270
169300
  unstable_pages