@cloudflare/vite-plugin 1.28.0 → 1.29.1
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 +4 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +258 -221
- package/dist/index.mjs.map +1 -1
- package/dist/{package-D3nFXhZC.mjs → package-JK3bcV9H.mjs} +4 -3
- package/dist/{package-D3nFXhZC.mjs.map → package-JK3bcV9H.mjs.map} +1 -1
- package/dist/workers/runner-worker/index.js +471 -0
- package/dist/workers/{runner-worker.js → runner-worker/module-runner-legacy.js} +33 -471
- package/dist/workers/runner-worker/module-runner.js +1220 -0
- package/package.json +9 -8
- /package/dist/workers/{asset-worker.js → asset-worker/index.js} +0 -0
- /package/dist/workers/{router-worker.js → router-worker/index.js} +0 -0
- /package/dist/workers/{vite-proxy-worker.js → vite-proxy-worker/index.js} +0 -0
package/README.md
CHANGED
|
@@ -23,13 +23,15 @@ Full documentation can be found [here](https://developers.cloudflare.com/workers
|
|
|
23
23
|
- Uses the Vite [Environment API](https://vite.dev/guide/api-environment) to integrate Vite with the Workers runtime
|
|
24
24
|
- Provides direct access to [Workers runtime APIs](https://developers.cloudflare.com/workers/runtime-apis/) and [bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/)
|
|
25
25
|
- Builds your front-end assets for deployment to Cloudflare, enabling you to build static sites, SPAs, and full-stack applications
|
|
26
|
-
- Official support for [React Router v7](https://reactrouter.com/) with server-side rendering
|
|
26
|
+
- Official support for [TanStack Start](https://tanstack.com/start/) and [React Router v7](https://reactrouter.com/) with server-side rendering
|
|
27
27
|
- Leverages Vite's hot module replacement for consistently fast updates
|
|
28
28
|
- Supports `vite preview` for previewing your build output in the Workers runtime prior to deployment
|
|
29
29
|
|
|
30
30
|
## Use cases
|
|
31
31
|
|
|
32
|
-
-
|
|
32
|
+
- [TanStack Start](https://tanstack.com/start/)
|
|
33
|
+
- [React Router v7](https://reactrouter.com/)
|
|
34
|
+
- Support for more full-stack frameworks is coming soon
|
|
33
35
|
- Static sites, such as single-page applications, with or without an integrated backend API
|
|
34
36
|
- Standalone Workers
|
|
35
37
|
- Multi-Worker applications
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/utils.ts","../src/workers-configs.ts","../src/plugin-config.ts","../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/utils.ts","../src/workers-configs.ts","../src/plugin-config.ts","../src/index.ts"],"sourcesContent":[],"mappings":"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"}
|
package/dist/index.mjs
CHANGED
|
@@ -5442,6 +5442,7 @@ var getCfFetchEnabledFromEnv = getBooleanEnvironmentVariableFactory({
|
|
|
5442
5442
|
});
|
|
5443
5443
|
var getCfFetchPathFromEnv = getEnvironmentVariableFactory({ variableName: "CLOUDFLARE_CF_FETCH_PATH" });
|
|
5444
5444
|
var getWranglerCacheDirFromEnv = getEnvironmentVariableFactory({ variableName: "WRANGLER_CACHE_DIR" });
|
|
5445
|
+
var getCloudflaredPathFromEnv = getEnvironmentVariableFactory({ variableName: "CLOUDFLARED_PATH" });
|
|
5445
5446
|
var Diagnostics = class {
|
|
5446
5447
|
/**
|
|
5447
5448
|
* Create a new Diagnostics object.
|
|
@@ -21610,8 +21611,13 @@ function createHotChannel(webSocketContainer) {
|
|
|
21610
21611
|
return {
|
|
21611
21612
|
send(payload) {
|
|
21612
21613
|
const webSocket = webSocketContainer.webSocket;
|
|
21613
|
-
|
|
21614
|
-
webSocket
|
|
21614
|
+
const message = JSON.stringify(payload);
|
|
21615
|
+
if (!webSocket) {
|
|
21616
|
+
webSocketContainer.messageBuffers ??= [];
|
|
21617
|
+
webSocketContainer.messageBuffers.push(message);
|
|
21618
|
+
return;
|
|
21619
|
+
}
|
|
21620
|
+
webSocket.send(message);
|
|
21615
21621
|
},
|
|
21616
21622
|
on(event, listener) {
|
|
21617
21623
|
const listeners = listenersMap.get(event) ?? /* @__PURE__ */ new Set();
|
|
@@ -21657,6 +21663,10 @@ var CloudflareDevEnvironment = class extends vite.DevEnvironment {
|
|
|
21657
21663
|
assert(webSocket, "Failed to establish WebSocket");
|
|
21658
21664
|
webSocket.accept();
|
|
21659
21665
|
this.#webSocketContainer.webSocket = webSocket;
|
|
21666
|
+
if (this.#webSocketContainer.messageBuffers) {
|
|
21667
|
+
for (const bufferedMessage of this.#webSocketContainer.messageBuffers) webSocket.send(bufferedMessage);
|
|
21668
|
+
delete this.#webSocketContainer.messageBuffers;
|
|
21669
|
+
}
|
|
21660
21670
|
}
|
|
21661
21671
|
async fetchWorkerExportTypes(miniflare, workerConfig) {
|
|
21662
21672
|
await this.depsOptimizer?.init();
|
|
@@ -22287,6 +22297,229 @@ const OpenAPI = {
|
|
|
22287
22297
|
LOGGER: void 0
|
|
22288
22298
|
};
|
|
22289
22299
|
|
|
22300
|
+
//#endregion
|
|
22301
|
+
//#region ../containers-shared/src/client/core/request.ts
|
|
22302
|
+
/* istanbul ignore file */
|
|
22303
|
+
const isDefined = (value) => {
|
|
22304
|
+
return value !== void 0 && value !== null;
|
|
22305
|
+
};
|
|
22306
|
+
const isString = (value) => {
|
|
22307
|
+
return typeof value === "string";
|
|
22308
|
+
};
|
|
22309
|
+
const isStringWithValue = (value) => {
|
|
22310
|
+
return isString(value) && value !== "";
|
|
22311
|
+
};
|
|
22312
|
+
const isBlob = (value) => {
|
|
22313
|
+
return typeof value === "object" && typeof value.type === "string" && typeof value.stream === "function" && typeof value.arrayBuffer === "function" && typeof value.constructor === "function" && typeof value.constructor.name === "string" && /^(Blob|File)$/.test(value.constructor.name) && /^(Blob|File)$/.test(value[Symbol.toStringTag]);
|
|
22314
|
+
};
|
|
22315
|
+
const base64 = (str) => {
|
|
22316
|
+
try {
|
|
22317
|
+
return btoa(str);
|
|
22318
|
+
} catch (err) {
|
|
22319
|
+
return Buffer.from(str).toString("base64");
|
|
22320
|
+
}
|
|
22321
|
+
};
|
|
22322
|
+
const getQueryString = (params) => {
|
|
22323
|
+
const qs = [];
|
|
22324
|
+
const append = (key, value) => {
|
|
22325
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
22326
|
+
};
|
|
22327
|
+
const process$2 = (key, value) => {
|
|
22328
|
+
if (isDefined(value)) if (Array.isArray(value)) value.forEach((v) => {
|
|
22329
|
+
process$2(key, v);
|
|
22330
|
+
});
|
|
22331
|
+
else if (typeof value === "object") Object.entries(value).forEach(([k, v]) => {
|
|
22332
|
+
process$2(`${key}[${k}]`, v);
|
|
22333
|
+
});
|
|
22334
|
+
else append(key, value);
|
|
22335
|
+
};
|
|
22336
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
22337
|
+
process$2(key, value);
|
|
22338
|
+
});
|
|
22339
|
+
if (qs.length > 0) return `?${qs.join("&")}`;
|
|
22340
|
+
return "";
|
|
22341
|
+
};
|
|
22342
|
+
const getUrl = (config, options) => {
|
|
22343
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
22344
|
+
const path$1 = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
22345
|
+
if (options.path?.hasOwnProperty(group)) return encoder(String(options.path[group]));
|
|
22346
|
+
return substring;
|
|
22347
|
+
});
|
|
22348
|
+
const url = `${config.BASE}${path$1}`;
|
|
22349
|
+
if (options.query) return `${url}${getQueryString(options.query)}`;
|
|
22350
|
+
return url;
|
|
22351
|
+
};
|
|
22352
|
+
const getFormData = (options) => {
|
|
22353
|
+
if (options.formData) {
|
|
22354
|
+
const formData = new FormData();
|
|
22355
|
+
const process$2 = async (key, value) => {
|
|
22356
|
+
if (isString(value)) formData.append(key, value);
|
|
22357
|
+
else formData.append(key, JSON.stringify(value));
|
|
22358
|
+
};
|
|
22359
|
+
Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
|
|
22360
|
+
if (Array.isArray(value)) value.forEach((v) => process$2(key, v));
|
|
22361
|
+
else process$2(key, value);
|
|
22362
|
+
});
|
|
22363
|
+
return formData;
|
|
22364
|
+
}
|
|
22365
|
+
};
|
|
22366
|
+
const resolve$1 = async (options, resolver) => {
|
|
22367
|
+
if (typeof resolver === "function") return resolver(options);
|
|
22368
|
+
return resolver;
|
|
22369
|
+
};
|
|
22370
|
+
const getHeaders = async (config, options) => {
|
|
22371
|
+
const token = await resolve$1(options, config.TOKEN);
|
|
22372
|
+
const username = await resolve$1(options, config.USERNAME);
|
|
22373
|
+
const password = await resolve$1(options, config.PASSWORD);
|
|
22374
|
+
const additionalHeaders = await resolve$1(options, config.HEADERS);
|
|
22375
|
+
const headers = Object.entries({
|
|
22376
|
+
Accept: "application/json",
|
|
22377
|
+
...additionalHeaders,
|
|
22378
|
+
...options.headers
|
|
22379
|
+
}).filter(([_, value]) => isDefined(value)).reduce((headers$1, [key, value]) => ({
|
|
22380
|
+
...headers$1,
|
|
22381
|
+
[key]: String(value)
|
|
22382
|
+
}), {});
|
|
22383
|
+
if (isStringWithValue(token)) headers["Authorization"] = `Bearer ${token}`;
|
|
22384
|
+
if (isStringWithValue(username) && isStringWithValue(password)) headers["Authorization"] = `Basic ${base64(`${username}:${password}`)}`;
|
|
22385
|
+
if (options.body) if (options.mediaType) headers["Content-Type"] = options.mediaType;
|
|
22386
|
+
else if (isBlob(options.body)) headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
22387
|
+
else if (isString(options.body)) headers["Content-Type"] = "text/plain";
|
|
22388
|
+
else headers["Content-Type"] = "application/json";
|
|
22389
|
+
return new Headers(headers);
|
|
22390
|
+
};
|
|
22391
|
+
const getRequestBody = (options) => {
|
|
22392
|
+
if (options.body !== void 0) if (options.mediaType?.includes("/json")) return JSON.stringify(options.body);
|
|
22393
|
+
else if (isString(options.body) || isBlob(options.body)) return options.body;
|
|
22394
|
+
else return JSON.stringify(options.body);
|
|
22395
|
+
};
|
|
22396
|
+
const isResponseSchemaV4 = (config, _options) => {
|
|
22397
|
+
return config.BASE.endsWith("/containers");
|
|
22398
|
+
};
|
|
22399
|
+
const parseResponseSchemaV4 = (url, response, responseHeader, responseBody) => {
|
|
22400
|
+
const fetchResult = typeof responseBody === "object" ? responseBody : JSON.parse(responseBody);
|
|
22401
|
+
const ok = response.ok && fetchResult.success;
|
|
22402
|
+
let result;
|
|
22403
|
+
if (ok) if (fetchResult.result !== void 0) result = fetchResult.result;
|
|
22404
|
+
else result = {};
|
|
22405
|
+
else result = { error: fetchResult.errors?.[0]?.message };
|
|
22406
|
+
return {
|
|
22407
|
+
url,
|
|
22408
|
+
ok,
|
|
22409
|
+
status: response.status,
|
|
22410
|
+
statusText: response.statusText,
|
|
22411
|
+
body: responseHeader ?? result
|
|
22412
|
+
};
|
|
22413
|
+
};
|
|
22414
|
+
const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
22415
|
+
const controller = new AbortController();
|
|
22416
|
+
const request$1 = {
|
|
22417
|
+
headers,
|
|
22418
|
+
body: body ?? formData,
|
|
22419
|
+
method: options.method,
|
|
22420
|
+
signal: controller.signal
|
|
22421
|
+
};
|
|
22422
|
+
if (config.WITH_CREDENTIALS) request$1.credentials = config.CREDENTIALS;
|
|
22423
|
+
onCancel(() => controller.abort());
|
|
22424
|
+
return await fetch(url, request$1);
|
|
22425
|
+
};
|
|
22426
|
+
const getResponseHeader = (response, responseHeader) => {
|
|
22427
|
+
if (responseHeader) {
|
|
22428
|
+
const content = response.headers.get(responseHeader);
|
|
22429
|
+
if (isString(content)) return content;
|
|
22430
|
+
}
|
|
22431
|
+
};
|
|
22432
|
+
const getResponseBody = async (response) => {
|
|
22433
|
+
if (response.status !== 204) try {
|
|
22434
|
+
const contentType = response.headers.get("Content-Type");
|
|
22435
|
+
if (contentType) if (["application/json", "application/problem+json"].some((type) => contentType.toLowerCase().startsWith(type))) return await response.json();
|
|
22436
|
+
else return await response.text();
|
|
22437
|
+
} catch (error) {
|
|
22438
|
+
console.error(error);
|
|
22439
|
+
}
|
|
22440
|
+
};
|
|
22441
|
+
const catchErrorCodes = (options, result) => {
|
|
22442
|
+
const error = {
|
|
22443
|
+
400: "Bad Request",
|
|
22444
|
+
401: "Unauthorized",
|
|
22445
|
+
403: "Forbidden",
|
|
22446
|
+
404: "Not Found",
|
|
22447
|
+
500: "Internal Server Error",
|
|
22448
|
+
502: "Bad Gateway",
|
|
22449
|
+
503: "Service Unavailable",
|
|
22450
|
+
...options.errors
|
|
22451
|
+
}[result.status];
|
|
22452
|
+
if (error) throw new ApiError(options, result, error);
|
|
22453
|
+
if (!result.ok) throw new ApiError(options, result, "Generic Error");
|
|
22454
|
+
};
|
|
22455
|
+
/**
|
|
22456
|
+
* Shared HTTP execution: builds URL, headers, body, sends the request,
|
|
22457
|
+
* and returns the raw response components for further processing.
|
|
22458
|
+
* Returns null if the request was cancelled before sending.
|
|
22459
|
+
*/
|
|
22460
|
+
const executeRequest = async (config, options, onCancel) => {
|
|
22461
|
+
const url = getUrl(config, options);
|
|
22462
|
+
const formData = getFormData(options);
|
|
22463
|
+
const body = getRequestBody(options);
|
|
22464
|
+
const headers = await getHeaders(config, options);
|
|
22465
|
+
debugLogRequest(config, url, headers, formData ?? body ?? {});
|
|
22466
|
+
if (onCancel.isCancelled) return null;
|
|
22467
|
+
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
22468
|
+
return {
|
|
22469
|
+
url,
|
|
22470
|
+
response,
|
|
22471
|
+
responseBody: await getResponseBody(response),
|
|
22472
|
+
responseHeader: getResponseHeader(response, options.responseHeader)
|
|
22473
|
+
};
|
|
22474
|
+
};
|
|
22475
|
+
/**
|
|
22476
|
+
* Build an ApiResult from the raw response, handling V4 schema parsing.
|
|
22477
|
+
*/
|
|
22478
|
+
const buildApiResult = (config, options, req) => {
|
|
22479
|
+
if (isResponseSchemaV4(config, options)) return parseResponseSchemaV4(req.url, req.response, req.responseHeader, req.responseBody);
|
|
22480
|
+
return {
|
|
22481
|
+
url: req.url,
|
|
22482
|
+
ok: req.response.ok,
|
|
22483
|
+
status: req.response.status,
|
|
22484
|
+
statusText: req.response.statusText,
|
|
22485
|
+
body: req.responseHeader ?? req.responseBody
|
|
22486
|
+
};
|
|
22487
|
+
};
|
|
22488
|
+
/**
|
|
22489
|
+
* Request method
|
|
22490
|
+
* @param config The OpenAPI configuration object
|
|
22491
|
+
* @param options The request options from the service
|
|
22492
|
+
* @returns CancelablePromise<T>
|
|
22493
|
+
* @throws ApiError
|
|
22494
|
+
*/
|
|
22495
|
+
const request = (config, options) => {
|
|
22496
|
+
return new CancelablePromise(async (resolve$2, reject, onCancel) => {
|
|
22497
|
+
try {
|
|
22498
|
+
const req = await executeRequest(config, options, onCancel);
|
|
22499
|
+
if (!req) return;
|
|
22500
|
+
const result = buildApiResult(config, options, req);
|
|
22501
|
+
debugLogResponse(config, result);
|
|
22502
|
+
catchErrorCodes(options, result);
|
|
22503
|
+
resolve$2(result.body);
|
|
22504
|
+
} catch (error) {
|
|
22505
|
+
reject(error);
|
|
22506
|
+
}
|
|
22507
|
+
});
|
|
22508
|
+
};
|
|
22509
|
+
const debugLogRequest = async (config, url, headers, body) => {
|
|
22510
|
+
config.LOGGER?.debug(`-- START CF API REQUEST: ${url}`);
|
|
22511
|
+
const logHeaders = new Headers(headers);
|
|
22512
|
+
logHeaders.delete("Authorization");
|
|
22513
|
+
config.LOGGER?.debugWithSanitization("HEADERS:", JSON.stringify(logHeaders, null, 2));
|
|
22514
|
+
config.LOGGER?.debugWithSanitization("BODY:", JSON.stringify(body instanceof FormData ? await new Response(body).text() : body, null, 2));
|
|
22515
|
+
config.LOGGER?.debug("-- END CF API REQUEST");
|
|
22516
|
+
};
|
|
22517
|
+
const debugLogResponse = (config, response) => {
|
|
22518
|
+
config.LOGGER?.debug("-- START CF API RESPONSE:", response.statusText, response.status);
|
|
22519
|
+
config.LOGGER?.debugWithSanitization("RESPONSE:", response.body);
|
|
22520
|
+
config.LOGGER?.debug("-- END CF API RESPONSE");
|
|
22521
|
+
};
|
|
22522
|
+
|
|
22290
22523
|
//#endregion
|
|
22291
22524
|
//#region ../containers-shared/src/client/models/ApplicationRollout.ts
|
|
22292
22525
|
let ApplicationRollout;
|
|
@@ -22513,212 +22746,6 @@ let UpdateApplicationRolloutRequest;
|
|
|
22513
22746
|
}({});
|
|
22514
22747
|
})(UpdateApplicationRolloutRequest || (UpdateApplicationRolloutRequest = {}));
|
|
22515
22748
|
|
|
22516
|
-
//#endregion
|
|
22517
|
-
//#region ../containers-shared/src/client/core/request.ts
|
|
22518
|
-
/* istanbul ignore file */
|
|
22519
|
-
const isDefined = (value) => {
|
|
22520
|
-
return value !== void 0 && value !== null;
|
|
22521
|
-
};
|
|
22522
|
-
const isString = (value) => {
|
|
22523
|
-
return typeof value === "string";
|
|
22524
|
-
};
|
|
22525
|
-
const isStringWithValue = (value) => {
|
|
22526
|
-
return isString(value) && value !== "";
|
|
22527
|
-
};
|
|
22528
|
-
const isBlob = (value) => {
|
|
22529
|
-
return typeof value === "object" && typeof value.type === "string" && typeof value.stream === "function" && typeof value.arrayBuffer === "function" && typeof value.constructor === "function" && typeof value.constructor.name === "string" && /^(Blob|File)$/.test(value.constructor.name) && /^(Blob|File)$/.test(value[Symbol.toStringTag]);
|
|
22530
|
-
};
|
|
22531
|
-
const base64 = (str) => {
|
|
22532
|
-
try {
|
|
22533
|
-
return btoa(str);
|
|
22534
|
-
} catch (err) {
|
|
22535
|
-
return Buffer.from(str).toString("base64");
|
|
22536
|
-
}
|
|
22537
|
-
};
|
|
22538
|
-
const getQueryString = (params) => {
|
|
22539
|
-
const qs = [];
|
|
22540
|
-
const append = (key, value) => {
|
|
22541
|
-
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
22542
|
-
};
|
|
22543
|
-
const process$2 = (key, value) => {
|
|
22544
|
-
if (isDefined(value)) if (Array.isArray(value)) value.forEach((v) => {
|
|
22545
|
-
process$2(key, v);
|
|
22546
|
-
});
|
|
22547
|
-
else if (typeof value === "object") Object.entries(value).forEach(([k, v]) => {
|
|
22548
|
-
process$2(`${key}[${k}]`, v);
|
|
22549
|
-
});
|
|
22550
|
-
else append(key, value);
|
|
22551
|
-
};
|
|
22552
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
22553
|
-
process$2(key, value);
|
|
22554
|
-
});
|
|
22555
|
-
if (qs.length > 0) return `?${qs.join("&")}`;
|
|
22556
|
-
return "";
|
|
22557
|
-
};
|
|
22558
|
-
const getUrl = (config, options) => {
|
|
22559
|
-
const encoder = config.ENCODE_PATH || encodeURI;
|
|
22560
|
-
const path$1 = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
22561
|
-
if (options.path?.hasOwnProperty(group)) return encoder(String(options.path[group]));
|
|
22562
|
-
return substring;
|
|
22563
|
-
});
|
|
22564
|
-
const url = `${config.BASE}${path$1}`;
|
|
22565
|
-
if (options.query) return `${url}${getQueryString(options.query)}`;
|
|
22566
|
-
return url;
|
|
22567
|
-
};
|
|
22568
|
-
const getFormData = (options) => {
|
|
22569
|
-
if (options.formData) {
|
|
22570
|
-
const formData = new FormData();
|
|
22571
|
-
const process$2 = async (key, value) => {
|
|
22572
|
-
if (isString(value)) formData.append(key, value);
|
|
22573
|
-
else formData.append(key, JSON.stringify(value));
|
|
22574
|
-
};
|
|
22575
|
-
Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
|
|
22576
|
-
if (Array.isArray(value)) value.forEach((v) => process$2(key, v));
|
|
22577
|
-
else process$2(key, value);
|
|
22578
|
-
});
|
|
22579
|
-
return formData;
|
|
22580
|
-
}
|
|
22581
|
-
};
|
|
22582
|
-
const resolve$1 = async (options, resolver) => {
|
|
22583
|
-
if (typeof resolver === "function") return resolver(options);
|
|
22584
|
-
return resolver;
|
|
22585
|
-
};
|
|
22586
|
-
const getHeaders = async (config, options) => {
|
|
22587
|
-
const token = await resolve$1(options, config.TOKEN);
|
|
22588
|
-
const username = await resolve$1(options, config.USERNAME);
|
|
22589
|
-
const password = await resolve$1(options, config.PASSWORD);
|
|
22590
|
-
const additionalHeaders = await resolve$1(options, config.HEADERS);
|
|
22591
|
-
const headers = Object.entries({
|
|
22592
|
-
Accept: "application/json",
|
|
22593
|
-
...additionalHeaders,
|
|
22594
|
-
...options.headers
|
|
22595
|
-
}).filter(([_, value]) => isDefined(value)).reduce((headers$1, [key, value]) => ({
|
|
22596
|
-
...headers$1,
|
|
22597
|
-
[key]: String(value)
|
|
22598
|
-
}), {});
|
|
22599
|
-
if (isStringWithValue(token)) headers["Authorization"] = `Bearer ${token}`;
|
|
22600
|
-
if (isStringWithValue(username) && isStringWithValue(password)) headers["Authorization"] = `Basic ${base64(`${username}:${password}`)}`;
|
|
22601
|
-
if (options.body) if (options.mediaType) headers["Content-Type"] = options.mediaType;
|
|
22602
|
-
else if (isBlob(options.body)) headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
22603
|
-
else if (isString(options.body)) headers["Content-Type"] = "text/plain";
|
|
22604
|
-
else headers["Content-Type"] = "application/json";
|
|
22605
|
-
return new Headers(headers);
|
|
22606
|
-
};
|
|
22607
|
-
const getRequestBody = (options) => {
|
|
22608
|
-
if (options.body !== void 0) if (options.mediaType?.includes("/json")) return JSON.stringify(options.body);
|
|
22609
|
-
else if (isString(options.body) || isBlob(options.body)) return options.body;
|
|
22610
|
-
else return JSON.stringify(options.body);
|
|
22611
|
-
};
|
|
22612
|
-
const isResponseSchemaV4 = (config, _options) => {
|
|
22613
|
-
return config.BASE.endsWith("/containers");
|
|
22614
|
-
};
|
|
22615
|
-
const parseResponseSchemaV4 = (url, response, responseHeader, responseBody) => {
|
|
22616
|
-
const fetchResult = typeof responseBody === "object" ? responseBody : JSON.parse(responseBody);
|
|
22617
|
-
const ok = response.ok && fetchResult.success;
|
|
22618
|
-
let result;
|
|
22619
|
-
if (ok) if (fetchResult.result !== void 0) result = fetchResult.result;
|
|
22620
|
-
else result = {};
|
|
22621
|
-
else result = { error: fetchResult.errors?.[0]?.message };
|
|
22622
|
-
return {
|
|
22623
|
-
url,
|
|
22624
|
-
ok,
|
|
22625
|
-
status: response.status,
|
|
22626
|
-
statusText: response.statusText,
|
|
22627
|
-
body: responseHeader ?? result
|
|
22628
|
-
};
|
|
22629
|
-
};
|
|
22630
|
-
const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
22631
|
-
const controller = new AbortController();
|
|
22632
|
-
const request$1 = {
|
|
22633
|
-
headers,
|
|
22634
|
-
body: body ?? formData,
|
|
22635
|
-
method: options.method,
|
|
22636
|
-
signal: controller.signal
|
|
22637
|
-
};
|
|
22638
|
-
if (config.WITH_CREDENTIALS) request$1.credentials = config.CREDENTIALS;
|
|
22639
|
-
onCancel(() => controller.abort());
|
|
22640
|
-
return await fetch(url, request$1);
|
|
22641
|
-
};
|
|
22642
|
-
const getResponseHeader = (response, responseHeader) => {
|
|
22643
|
-
if (responseHeader) {
|
|
22644
|
-
const content = response.headers.get(responseHeader);
|
|
22645
|
-
if (isString(content)) return content;
|
|
22646
|
-
}
|
|
22647
|
-
};
|
|
22648
|
-
const getResponseBody = async (response) => {
|
|
22649
|
-
if (response.status !== 204) try {
|
|
22650
|
-
const contentType = response.headers.get("Content-Type");
|
|
22651
|
-
if (contentType) if (["application/json", "application/problem+json"].some((type) => contentType.toLowerCase().startsWith(type))) return await response.json();
|
|
22652
|
-
else return await response.text();
|
|
22653
|
-
} catch (error) {
|
|
22654
|
-
console.error(error);
|
|
22655
|
-
}
|
|
22656
|
-
};
|
|
22657
|
-
const catchErrorCodes = (options, result) => {
|
|
22658
|
-
const error = {
|
|
22659
|
-
400: "Bad Request",
|
|
22660
|
-
401: "Unauthorized",
|
|
22661
|
-
403: "Forbidden",
|
|
22662
|
-
404: "Not Found",
|
|
22663
|
-
500: "Internal Server Error",
|
|
22664
|
-
502: "Bad Gateway",
|
|
22665
|
-
503: "Service Unavailable",
|
|
22666
|
-
...options.errors
|
|
22667
|
-
}[result.status];
|
|
22668
|
-
if (error) throw new ApiError(options, result, error);
|
|
22669
|
-
if (!result.ok) throw new ApiError(options, result, "Generic Error");
|
|
22670
|
-
};
|
|
22671
|
-
/**
|
|
22672
|
-
* Request method
|
|
22673
|
-
* @param config The OpenAPI configuration object
|
|
22674
|
-
* @param options The request options from the service
|
|
22675
|
-
* @returns CancelablePromise<T>
|
|
22676
|
-
* @throws ApiError
|
|
22677
|
-
*/
|
|
22678
|
-
const request = (config, options) => {
|
|
22679
|
-
return new CancelablePromise(async (resolve$2, reject, onCancel) => {
|
|
22680
|
-
try {
|
|
22681
|
-
const url = getUrl(config, options);
|
|
22682
|
-
const formData = getFormData(options);
|
|
22683
|
-
const body = getRequestBody(options);
|
|
22684
|
-
const headers = await getHeaders(config, options);
|
|
22685
|
-
debugLogRequest(config, url, headers, formData ?? body ?? {});
|
|
22686
|
-
if (!onCancel.isCancelled) {
|
|
22687
|
-
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
22688
|
-
const responseBody = await getResponseBody(response);
|
|
22689
|
-
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
22690
|
-
let result;
|
|
22691
|
-
if (isResponseSchemaV4(config, options)) result = parseResponseSchemaV4(url, response, responseHeader, responseBody);
|
|
22692
|
-
else result = {
|
|
22693
|
-
url,
|
|
22694
|
-
ok: response.ok,
|
|
22695
|
-
status: response.status,
|
|
22696
|
-
statusText: response.statusText,
|
|
22697
|
-
body: responseHeader ?? responseBody
|
|
22698
|
-
};
|
|
22699
|
-
debugLogResponse(config, result);
|
|
22700
|
-
catchErrorCodes(options, result);
|
|
22701
|
-
resolve$2(result.body);
|
|
22702
|
-
}
|
|
22703
|
-
} catch (error) {
|
|
22704
|
-
reject(error);
|
|
22705
|
-
}
|
|
22706
|
-
});
|
|
22707
|
-
};
|
|
22708
|
-
const debugLogRequest = async (config, url, headers, body) => {
|
|
22709
|
-
config.LOGGER?.debug(`-- START CF API REQUEST: ${url}`);
|
|
22710
|
-
const logHeaders = new Headers(headers);
|
|
22711
|
-
logHeaders.delete("Authorization");
|
|
22712
|
-
config.LOGGER?.debugWithSanitization("HEADERS:", JSON.stringify(logHeaders, null, 2));
|
|
22713
|
-
config.LOGGER?.debugWithSanitization("BODY:", JSON.stringify(body instanceof FormData ? await new Response(body).text() : body, null, 2));
|
|
22714
|
-
config.LOGGER?.debug("-- END CF API REQUEST");
|
|
22715
|
-
};
|
|
22716
|
-
const debugLogResponse = (config, response) => {
|
|
22717
|
-
config.LOGGER?.debug("-- START CF API RESPONSE:", response.statusText, response.status);
|
|
22718
|
-
config.LOGGER?.debugWithSanitization("RESPONSE:", response.body);
|
|
22719
|
-
config.LOGGER?.debug("-- END CF API RESPONSE");
|
|
22720
|
-
};
|
|
22721
|
-
|
|
22722
22749
|
//#endregion
|
|
22723
22750
|
//#region ../containers-shared/src/client/services/ImageRegistriesService.ts
|
|
22724
22751
|
/* istanbul ignore file */
|
|
@@ -25948,10 +25975,12 @@ function getPersistenceRoot(root, persistState) {
|
|
|
25948
25975
|
return nodePath.resolve(root, typeof persistState === "object" ? persistState.path : ".wrangler/state", "v3");
|
|
25949
25976
|
}
|
|
25950
25977
|
const miniflareModulesRoot = process.platform === "win32" ? "Z:\\" : "/";
|
|
25951
|
-
const ROUTER_WORKER_PATH = "./workers/router-worker.js";
|
|
25952
|
-
const ASSET_WORKER_PATH = "./workers/asset-worker.js";
|
|
25953
|
-
const VITE_PROXY_WORKER_PATH = "./workers/vite-proxy-worker.js";
|
|
25954
|
-
const RUNNER_PATH = "./workers/runner-worker.js";
|
|
25978
|
+
const ROUTER_WORKER_PATH = "./workers/router-worker/index.js";
|
|
25979
|
+
const ASSET_WORKER_PATH = "./workers/asset-worker/index.js";
|
|
25980
|
+
const VITE_PROXY_WORKER_PATH = "./workers/vite-proxy-worker/index.js";
|
|
25981
|
+
const RUNNER_PATH = "./workers/runner-worker/index.js";
|
|
25982
|
+
const MODULE_RUNNER_PATH = "./workers/runner-worker/module-runner.js";
|
|
25983
|
+
const MODULE_RUNNER_LEGACY_PATH = "./workers/runner-worker/module-runner-legacy.js";
|
|
25955
25984
|
const WRAPPER_PATH = "__VITE_WORKER_ENTRY__";
|
|
25956
25985
|
/** Map that maps worker configPaths to their existing remote proxy session data (if any) */
|
|
25957
25986
|
const remoteProxySessionsDataMap = /* @__PURE__ */ new Map();
|
|
@@ -26077,15 +26106,23 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
26077
26106
|
...workerOptions,
|
|
26078
26107
|
name: worker.config.name,
|
|
26079
26108
|
modulesRoot: miniflareModulesRoot,
|
|
26080
|
-
modules: [
|
|
26081
|
-
|
|
26082
|
-
|
|
26083
|
-
|
|
26084
|
-
|
|
26085
|
-
|
|
26086
|
-
|
|
26087
|
-
|
|
26088
|
-
|
|
26109
|
+
modules: [
|
|
26110
|
+
{
|
|
26111
|
+
type: "ESModule",
|
|
26112
|
+
path: nodePath.join(miniflareModulesRoot, WRAPPER_PATH),
|
|
26113
|
+
contents: wrappers.join("\n")
|
|
26114
|
+
},
|
|
26115
|
+
{
|
|
26116
|
+
type: "ESModule",
|
|
26117
|
+
path: nodePath.join(miniflareModulesRoot, RUNNER_PATH),
|
|
26118
|
+
contents: fs$1.readFileSync(fileURLToPath(new URL(RUNNER_PATH, import.meta.url)))
|
|
26119
|
+
},
|
|
26120
|
+
{
|
|
26121
|
+
type: "ESModule",
|
|
26122
|
+
path: nodePath.join(miniflareModulesRoot, "workers/runner-worker/vite/module-runner"),
|
|
26123
|
+
contents: fs$1.readFileSync(fileURLToPath(new URL(satisfiesViteVersion("7.2.0") ? MODULE_RUNNER_PATH : MODULE_RUNNER_LEGACY_PATH, import.meta.url)))
|
|
26124
|
+
}
|
|
26125
|
+
],
|
|
26089
26126
|
unsafeUseModuleFallbackService: true,
|
|
26090
26127
|
unsafeInspectorProxy: inputInspectorPort !== false,
|
|
26091
26128
|
unsafeDirectSockets: environmentName === resolvedPluginConfig.entryWorkerEnvironmentName ? [{
|