@cloudflare/vite-plugin 1.9.6 → 1.10.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/asset-workers/router-worker.js +26 -15
- package/dist/index.js +1489 -194
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -218,8 +218,8 @@ var require_ignore = __commonJS({
|
|
|
218
218
|
}
|
|
219
219
|
return ignoreCase ? new RegExp(source, "i") : new RegExp(source);
|
|
220
220
|
};
|
|
221
|
-
var
|
|
222
|
-
var checkPattern = (pattern) => pattern &&
|
|
221
|
+
var isString2 = (subject) => typeof subject === "string";
|
|
222
|
+
var checkPattern = (pattern) => pattern && isString2(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
|
|
223
223
|
var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF);
|
|
224
224
|
var IgnoreRule = class {
|
|
225
225
|
constructor(origin, pattern, negative, regex) {
|
|
@@ -248,17 +248,17 @@ var require_ignore = __commonJS({
|
|
|
248
248
|
var throwError = (message, Ctor) => {
|
|
249
249
|
throw new Ctor(message);
|
|
250
250
|
};
|
|
251
|
-
var checkPath = (
|
|
252
|
-
if (!
|
|
251
|
+
var checkPath = (path14, originalPath, doThrow) => {
|
|
252
|
+
if (!isString2(path14)) {
|
|
253
253
|
return doThrow(
|
|
254
254
|
`path must be a string, but got \`${originalPath}\``,
|
|
255
255
|
TypeError
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
|
-
if (!
|
|
258
|
+
if (!path14) {
|
|
259
259
|
return doThrow(`path must not be empty`, TypeError);
|
|
260
260
|
}
|
|
261
|
-
if (checkPath.isNotRelative(
|
|
261
|
+
if (checkPath.isNotRelative(path14)) {
|
|
262
262
|
const r2 = "`path.relative()`d";
|
|
263
263
|
return doThrow(
|
|
264
264
|
`path should be a ${r2} string, but got "${originalPath}"`,
|
|
@@ -267,7 +267,7 @@ var require_ignore = __commonJS({
|
|
|
267
267
|
}
|
|
268
268
|
return true;
|
|
269
269
|
};
|
|
270
|
-
var isNotRelative = (
|
|
270
|
+
var isNotRelative = (path14) => REGEX_TEST_INVALID_PATH.test(path14);
|
|
271
271
|
checkPath.isNotRelative = isNotRelative;
|
|
272
272
|
checkPath.convert = (p) => p;
|
|
273
273
|
var Ignore = class {
|
|
@@ -302,7 +302,7 @@ var require_ignore = __commonJS({
|
|
|
302
302
|
add(pattern) {
|
|
303
303
|
this._added = false;
|
|
304
304
|
makeArray(
|
|
305
|
-
|
|
305
|
+
isString2(pattern) ? splitPattern(pattern) : pattern
|
|
306
306
|
).forEach(this._addPattern, this);
|
|
307
307
|
if (this._added) {
|
|
308
308
|
this._initCache();
|
|
@@ -326,7 +326,7 @@ var require_ignore = __commonJS({
|
|
|
326
326
|
// setting `checkUnignored` to `false` could reduce additional
|
|
327
327
|
// path matching.
|
|
328
328
|
// @returns {TestResult} true if a file is ignored
|
|
329
|
-
_testOne(
|
|
329
|
+
_testOne(path14, checkUnignored) {
|
|
330
330
|
let ignored = false;
|
|
331
331
|
let unignored = false;
|
|
332
332
|
this._rules.forEach((rule) => {
|
|
@@ -334,7 +334,7 @@ var require_ignore = __commonJS({
|
|
|
334
334
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
335
335
|
return;
|
|
336
336
|
}
|
|
337
|
-
const matched = rule.regex.test(
|
|
337
|
+
const matched = rule.regex.test(path14);
|
|
338
338
|
if (matched) {
|
|
339
339
|
ignored = !negative;
|
|
340
340
|
unignored = negative;
|
|
@@ -347,24 +347,24 @@ var require_ignore = __commonJS({
|
|
|
347
347
|
}
|
|
348
348
|
// @returns {TestResult}
|
|
349
349
|
_test(originalPath, cache2, checkUnignored, slices) {
|
|
350
|
-
const
|
|
350
|
+
const path14 = originalPath && checkPath.convert(originalPath);
|
|
351
351
|
checkPath(
|
|
352
|
-
|
|
352
|
+
path14,
|
|
353
353
|
originalPath,
|
|
354
354
|
this._allowRelativePaths ? RETURN_FALSE : throwError
|
|
355
355
|
);
|
|
356
|
-
return this._t(
|
|
356
|
+
return this._t(path14, cache2, checkUnignored, slices);
|
|
357
357
|
}
|
|
358
|
-
_t(
|
|
359
|
-
if (
|
|
360
|
-
return cache2[
|
|
358
|
+
_t(path14, cache2, checkUnignored, slices) {
|
|
359
|
+
if (path14 in cache2) {
|
|
360
|
+
return cache2[path14];
|
|
361
361
|
}
|
|
362
362
|
if (!slices) {
|
|
363
|
-
slices =
|
|
363
|
+
slices = path14.split(SLASH);
|
|
364
364
|
}
|
|
365
365
|
slices.pop();
|
|
366
366
|
if (!slices.length) {
|
|
367
|
-
return cache2[
|
|
367
|
+
return cache2[path14] = this._testOne(path14, checkUnignored);
|
|
368
368
|
}
|
|
369
369
|
const parent = this._t(
|
|
370
370
|
slices.join(SLASH) + SLASH,
|
|
@@ -372,24 +372,24 @@ var require_ignore = __commonJS({
|
|
|
372
372
|
checkUnignored,
|
|
373
373
|
slices
|
|
374
374
|
);
|
|
375
|
-
return cache2[
|
|
375
|
+
return cache2[path14] = parent.ignored ? parent : this._testOne(path14, checkUnignored);
|
|
376
376
|
}
|
|
377
|
-
ignores(
|
|
378
|
-
return this._test(
|
|
377
|
+
ignores(path14) {
|
|
378
|
+
return this._test(path14, this._ignoreCache, false).ignored;
|
|
379
379
|
}
|
|
380
380
|
createFilter() {
|
|
381
|
-
return (
|
|
381
|
+
return (path14) => !this.ignores(path14);
|
|
382
382
|
}
|
|
383
383
|
filter(paths) {
|
|
384
384
|
return makeArray(paths).filter(this.createFilter());
|
|
385
385
|
}
|
|
386
386
|
// @returns {TestResult}
|
|
387
|
-
test(
|
|
388
|
-
return this._test(
|
|
387
|
+
test(path14) {
|
|
388
|
+
return this._test(path14, this._testCache, true);
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
var factory = (options) => new Ignore(options);
|
|
392
|
-
var isPathValid = (
|
|
392
|
+
var isPathValid = (path14) => checkPath(path14 && checkPath.convert(path14), path14, RETURN_FALSE);
|
|
393
393
|
factory.isPathValid = isPathValid;
|
|
394
394
|
factory.default = factory;
|
|
395
395
|
module.exports = factory;
|
|
@@ -400,7 +400,7 @@ var require_ignore = __commonJS({
|
|
|
400
400
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
401
401
|
checkPath.convert = makePosix;
|
|
402
402
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
403
|
-
checkPath.isNotRelative = (
|
|
403
|
+
checkPath.isNotRelative = (path14) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path14) || isNotRelative(path14);
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
});
|
|
@@ -443,11 +443,11 @@ var require_Mime = __commonJS({
|
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
};
|
|
446
|
-
Mime.prototype.getType = function(
|
|
447
|
-
|
|
448
|
-
let last =
|
|
446
|
+
Mime.prototype.getType = function(path14) {
|
|
447
|
+
path14 = String(path14);
|
|
448
|
+
let last = path14.replace(/^.*[/\\]/, "").toLowerCase();
|
|
449
449
|
let ext = last.replace(/^.*\./, "").toLowerCase();
|
|
450
|
-
let hasPath = last.length <
|
|
450
|
+
let hasPath = last.length < path14.length;
|
|
451
451
|
let hasDot = ext.length < last.length - 1;
|
|
452
452
|
return (hasDot || !hasPath) && this._types[ext] || null;
|
|
453
453
|
};
|
|
@@ -487,7 +487,1149 @@ var require_mime = __commonJS({
|
|
|
487
487
|
// src/index.ts
|
|
488
488
|
import assert11 from "node:assert";
|
|
489
489
|
import * as fsp2 from "node:fs/promises";
|
|
490
|
-
import * as
|
|
490
|
+
import * as path13 from "node:path";
|
|
491
|
+
|
|
492
|
+
// ../containers-shared/src/build.ts
|
|
493
|
+
import { spawn } from "child_process";
|
|
494
|
+
import { readFileSync } from "fs";
|
|
495
|
+
import path from "path";
|
|
496
|
+
async function constructBuildCommand(options, configPath, logger) {
|
|
497
|
+
const platform = options.platform ?? "linux/amd64";
|
|
498
|
+
const buildCmd = [
|
|
499
|
+
"build",
|
|
500
|
+
"-t",
|
|
501
|
+
options.tag,
|
|
502
|
+
"--platform",
|
|
503
|
+
platform,
|
|
504
|
+
"--provenance=false"
|
|
505
|
+
];
|
|
506
|
+
if (options.args) {
|
|
507
|
+
for (const arg in options.args) {
|
|
508
|
+
buildCmd.push("--build-arg", `${arg}=${options.args[arg]}`);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (options.setNetworkToHost) {
|
|
512
|
+
buildCmd.push("--network", "host");
|
|
513
|
+
}
|
|
514
|
+
const baseDir = configPath ? path.dirname(configPath) : process.cwd();
|
|
515
|
+
const absDockerfilePath = path.resolve(baseDir, options.pathToDockerfile);
|
|
516
|
+
const dockerfile = readFileSync(absDockerfilePath, "utf-8");
|
|
517
|
+
const absBuildContext = options.buildContext ? path.resolve(baseDir, options.buildContext) : path.dirname(absDockerfilePath);
|
|
518
|
+
buildCmd.push("-f", "-");
|
|
519
|
+
buildCmd.push(absBuildContext);
|
|
520
|
+
logger?.debug(`Building image with command: ${buildCmd.join(" ")}`);
|
|
521
|
+
return { buildCmd, dockerfile };
|
|
522
|
+
}
|
|
523
|
+
function dockerBuild(dockerPath, options) {
|
|
524
|
+
let errorHandled = false;
|
|
525
|
+
let resolve9;
|
|
526
|
+
let reject;
|
|
527
|
+
const ready = new Promise((res, rej) => {
|
|
528
|
+
resolve9 = res;
|
|
529
|
+
reject = rej;
|
|
530
|
+
});
|
|
531
|
+
const child = spawn(dockerPath, options.buildCmd, {
|
|
532
|
+
stdio: ["pipe", "inherit", "inherit"],
|
|
533
|
+
// We need to set detached to true so that the child process
|
|
534
|
+
// will control all of its child processed and we can kill
|
|
535
|
+
// all of them in case we need to abort the build process
|
|
536
|
+
detached: true
|
|
537
|
+
});
|
|
538
|
+
if (child.stdin !== null) {
|
|
539
|
+
child.stdin.write(options.dockerfile);
|
|
540
|
+
child.stdin.end();
|
|
541
|
+
}
|
|
542
|
+
child.on("exit", (code) => {
|
|
543
|
+
if (code === 0) {
|
|
544
|
+
resolve9();
|
|
545
|
+
} else if (!errorHandled) {
|
|
546
|
+
errorHandled = true;
|
|
547
|
+
reject(new Error(`Docker build exited with code: ${code}`));
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
child.on("error", (err) => {
|
|
551
|
+
if (!errorHandled) {
|
|
552
|
+
errorHandled = true;
|
|
553
|
+
reject(err);
|
|
554
|
+
}
|
|
555
|
+
});
|
|
556
|
+
return {
|
|
557
|
+
abort: () => {
|
|
558
|
+
child.unref();
|
|
559
|
+
if (child.pid !== void 0) {
|
|
560
|
+
process.kill(-child.pid);
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
ready
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
async function buildImage(dockerPath, options, configPath) {
|
|
567
|
+
const { buildCmd, dockerfile } = await constructBuildCommand(
|
|
568
|
+
{
|
|
569
|
+
tag: options.imageTag,
|
|
570
|
+
pathToDockerfile: options.image,
|
|
571
|
+
buildContext: options.imageBuildContext,
|
|
572
|
+
args: options.args,
|
|
573
|
+
platform: "linux/amd64"
|
|
574
|
+
},
|
|
575
|
+
configPath
|
|
576
|
+
);
|
|
577
|
+
return dockerBuild(dockerPath, { buildCmd, dockerfile });
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// ../containers-shared/src/registry.ts
|
|
581
|
+
var MF_DEV_CONTAINER_PREFIX = "cloudflare-dev";
|
|
582
|
+
|
|
583
|
+
// ../containers-shared/src/knobs.ts
|
|
584
|
+
var getCloudflareContainerRegistry = () => {
|
|
585
|
+
return process.env.CLOUDFLARE_CONTAINER_REGISTRY ?? "registry.cloudflare.com";
|
|
586
|
+
};
|
|
587
|
+
function isCloudflareRegistryLink(image) {
|
|
588
|
+
const cfRegistry = getCloudflareContainerRegistry();
|
|
589
|
+
return image.includes(cfRegistry);
|
|
590
|
+
}
|
|
591
|
+
var getDevContainerImageName = (name, tag) => {
|
|
592
|
+
return `${MF_DEV_CONTAINER_PREFIX}/${name.toLowerCase()}:${tag}`;
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
// ../containers-shared/src/login.ts
|
|
596
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
597
|
+
|
|
598
|
+
// ../containers-shared/src/client/core/ApiError.ts
|
|
599
|
+
var ApiError = class extends Error {
|
|
600
|
+
url;
|
|
601
|
+
status;
|
|
602
|
+
statusText;
|
|
603
|
+
body;
|
|
604
|
+
request;
|
|
605
|
+
constructor(request2, response, message) {
|
|
606
|
+
super(message);
|
|
607
|
+
this.name = "ApiError";
|
|
608
|
+
this.url = response.url;
|
|
609
|
+
this.status = response.status;
|
|
610
|
+
this.statusText = response.statusText;
|
|
611
|
+
this.body = response.body;
|
|
612
|
+
this.request = request2;
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
// ../containers-shared/src/client/core/CancelablePromise.ts
|
|
617
|
+
var CancelError = class extends Error {
|
|
618
|
+
constructor(message) {
|
|
619
|
+
super(message);
|
|
620
|
+
this.name = "CancelError";
|
|
621
|
+
}
|
|
622
|
+
get isCancelled() {
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
var CancelablePromise = class {
|
|
627
|
+
#isResolved;
|
|
628
|
+
#isRejected;
|
|
629
|
+
#isCancelled;
|
|
630
|
+
#cancelHandlers;
|
|
631
|
+
#promise;
|
|
632
|
+
#resolve;
|
|
633
|
+
#reject;
|
|
634
|
+
constructor(executor) {
|
|
635
|
+
this.#isResolved = false;
|
|
636
|
+
this.#isRejected = false;
|
|
637
|
+
this.#isCancelled = false;
|
|
638
|
+
this.#cancelHandlers = [];
|
|
639
|
+
this.#promise = new Promise((resolve9, reject) => {
|
|
640
|
+
this.#resolve = resolve9;
|
|
641
|
+
this.#reject = reject;
|
|
642
|
+
const onResolve = (value) => {
|
|
643
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
this.#isResolved = true;
|
|
647
|
+
this.#resolve?.(value);
|
|
648
|
+
};
|
|
649
|
+
const onReject = (reason) => {
|
|
650
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
this.#isRejected = true;
|
|
654
|
+
this.#reject?.(reason);
|
|
655
|
+
};
|
|
656
|
+
const onCancel = (cancelHandler) => {
|
|
657
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
this.#cancelHandlers.push(cancelHandler);
|
|
661
|
+
};
|
|
662
|
+
Object.defineProperty(onCancel, "isResolved", {
|
|
663
|
+
get: () => this.#isResolved
|
|
664
|
+
});
|
|
665
|
+
Object.defineProperty(onCancel, "isRejected", {
|
|
666
|
+
get: () => this.#isRejected
|
|
667
|
+
});
|
|
668
|
+
Object.defineProperty(onCancel, "isCancelled", {
|
|
669
|
+
get: () => this.#isCancelled
|
|
670
|
+
});
|
|
671
|
+
return executor(onResolve, onReject, onCancel);
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
get [Symbol.toStringTag]() {
|
|
675
|
+
return "Cancellable Promise";
|
|
676
|
+
}
|
|
677
|
+
then(onFulfilled, onRejected) {
|
|
678
|
+
return this.#promise.then(onFulfilled, onRejected);
|
|
679
|
+
}
|
|
680
|
+
catch(onRejected) {
|
|
681
|
+
return this.#promise.catch(onRejected);
|
|
682
|
+
}
|
|
683
|
+
finally(onFinally) {
|
|
684
|
+
return this.#promise.finally(onFinally);
|
|
685
|
+
}
|
|
686
|
+
cancel() {
|
|
687
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
this.#isCancelled = true;
|
|
691
|
+
if (this.#cancelHandlers.length) {
|
|
692
|
+
try {
|
|
693
|
+
for (const cancelHandler of this.#cancelHandlers) {
|
|
694
|
+
cancelHandler();
|
|
695
|
+
}
|
|
696
|
+
} catch (error) {
|
|
697
|
+
console.warn("Cancellation threw an error", error);
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
this.#cancelHandlers.length = 0;
|
|
702
|
+
this.#reject?.(new CancelError("Request aborted"));
|
|
703
|
+
}
|
|
704
|
+
get isCancelled() {
|
|
705
|
+
return this.#isCancelled;
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
// ../containers-shared/src/client/core/OpenAPI.ts
|
|
710
|
+
var OpenAPI = {
|
|
711
|
+
BASE: "",
|
|
712
|
+
VERSION: "1.0.0",
|
|
713
|
+
WITH_CREDENTIALS: false,
|
|
714
|
+
CREDENTIALS: "include",
|
|
715
|
+
TOKEN: void 0,
|
|
716
|
+
USERNAME: void 0,
|
|
717
|
+
PASSWORD: void 0,
|
|
718
|
+
HEADERS: void 0,
|
|
719
|
+
ENCODE_PATH: void 0
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
// ../containers-shared/src/client/models/ApplicationRollout.ts
|
|
723
|
+
var ApplicationRollout;
|
|
724
|
+
((ApplicationRollout2) => {
|
|
725
|
+
let kind;
|
|
726
|
+
((kind2) => {
|
|
727
|
+
kind2["FULL_AUTO"] = "full_auto";
|
|
728
|
+
kind2["FULL_MANUAL"] = "full_manual";
|
|
729
|
+
kind2["DURABLE_OBJECTS_AUTO"] = "durable_objects_auto";
|
|
730
|
+
})(kind = ApplicationRollout2.kind || (ApplicationRollout2.kind = {}));
|
|
731
|
+
let strategy;
|
|
732
|
+
((strategy2) => {
|
|
733
|
+
strategy2["ROLLING"] = "rolling";
|
|
734
|
+
})(strategy = ApplicationRollout2.strategy || (ApplicationRollout2.strategy = {}));
|
|
735
|
+
let status;
|
|
736
|
+
((status2) => {
|
|
737
|
+
status2["PENDING"] = "pending";
|
|
738
|
+
status2["PROGRESSING"] = "progressing";
|
|
739
|
+
status2["COMPLETED"] = "completed";
|
|
740
|
+
status2["REVERTED"] = "reverted";
|
|
741
|
+
status2["REPLACED"] = "replaced";
|
|
742
|
+
})(status = ApplicationRollout2.status || (ApplicationRollout2.status = {}));
|
|
743
|
+
})(ApplicationRollout || (ApplicationRollout = {}));
|
|
744
|
+
|
|
745
|
+
// ../containers-shared/src/client/models/BadRequestWithCodeError.ts
|
|
746
|
+
var BadRequestWithCodeError;
|
|
747
|
+
((BadRequestWithCodeError2) => {
|
|
748
|
+
let error;
|
|
749
|
+
((error2) => {
|
|
750
|
+
error2["VALIDATE_INPUT"] = "VALIDATE_INPUT";
|
|
751
|
+
})(error = BadRequestWithCodeError2.error || (BadRequestWithCodeError2.error = {}));
|
|
752
|
+
})(BadRequestWithCodeError || (BadRequestWithCodeError = {}));
|
|
753
|
+
|
|
754
|
+
// ../containers-shared/src/client/models/CreateApplicationRolloutRequest.ts
|
|
755
|
+
var CreateApplicationRolloutRequest;
|
|
756
|
+
((CreateApplicationRolloutRequest2) => {
|
|
757
|
+
let strategy;
|
|
758
|
+
((strategy2) => {
|
|
759
|
+
strategy2["ROLLING"] = "rolling";
|
|
760
|
+
})(strategy = CreateApplicationRolloutRequest2.strategy || (CreateApplicationRolloutRequest2.strategy = {}));
|
|
761
|
+
let step_percentage;
|
|
762
|
+
((step_percentage2) => {
|
|
763
|
+
step_percentage2[step_percentage2["_5"] = 5] = "_5";
|
|
764
|
+
step_percentage2[step_percentage2["_10"] = 10] = "_10";
|
|
765
|
+
step_percentage2[step_percentage2["_20"] = 20] = "_20";
|
|
766
|
+
step_percentage2[step_percentage2["_25"] = 25] = "_25";
|
|
767
|
+
step_percentage2[step_percentage2["_50"] = 50] = "_50";
|
|
768
|
+
step_percentage2[step_percentage2["_100"] = 100] = "_100";
|
|
769
|
+
})(step_percentage = CreateApplicationRolloutRequest2.step_percentage || (CreateApplicationRolloutRequest2.step_percentage = {}));
|
|
770
|
+
let kind;
|
|
771
|
+
((kind2) => {
|
|
772
|
+
kind2["FULL_AUTO"] = "full_auto";
|
|
773
|
+
kind2["FULL_MANUAL"] = "full_manual";
|
|
774
|
+
})(kind = CreateApplicationRolloutRequest2.kind || (CreateApplicationRolloutRequest2.kind = {}));
|
|
775
|
+
})(CreateApplicationRolloutRequest || (CreateApplicationRolloutRequest = {}));
|
|
776
|
+
|
|
777
|
+
// ../containers-shared/src/client/models/DeploymentNotFoundError.ts
|
|
778
|
+
var DeploymentNotFoundError;
|
|
779
|
+
((DeploymentNotFoundError2) => {
|
|
780
|
+
let error;
|
|
781
|
+
((error2) => {
|
|
782
|
+
error2["DEPLOYMENT_NOT_FOUND"] = "DEPLOYMENT_NOT_FOUND";
|
|
783
|
+
})(error = DeploymentNotFoundError2.error || (DeploymentNotFoundError2.error = {}));
|
|
784
|
+
})(DeploymentNotFoundError || (DeploymentNotFoundError = {}));
|
|
785
|
+
|
|
786
|
+
// ../containers-shared/src/client/models/ImageRegistryAlreadyExistsError.ts
|
|
787
|
+
var ImageRegistryAlreadyExistsError;
|
|
788
|
+
((ImageRegistryAlreadyExistsError2) => {
|
|
789
|
+
let error;
|
|
790
|
+
((error2) => {
|
|
791
|
+
error2["IMAGE_REGISTRY_ALREADY_EXISTS"] = "IMAGE_REGISTRY_ALREADY_EXISTS";
|
|
792
|
+
})(error = ImageRegistryAlreadyExistsError2.error || (ImageRegistryAlreadyExistsError2.error = {}));
|
|
793
|
+
})(ImageRegistryAlreadyExistsError || (ImageRegistryAlreadyExistsError = {}));
|
|
794
|
+
|
|
795
|
+
// ../containers-shared/src/client/models/ImageRegistryIsPublic.ts
|
|
796
|
+
var ImageRegistryIsPublic;
|
|
797
|
+
((ImageRegistryIsPublic2) => {
|
|
798
|
+
let error;
|
|
799
|
+
((error2) => {
|
|
800
|
+
error2["IMAGE_REGISTRY_IS_PUBLIC"] = "IMAGE_REGISTRY_IS_PUBLIC";
|
|
801
|
+
})(error = ImageRegistryIsPublic2.error || (ImageRegistryIsPublic2.error = {}));
|
|
802
|
+
})(ImageRegistryIsPublic || (ImageRegistryIsPublic = {}));
|
|
803
|
+
|
|
804
|
+
// ../containers-shared/src/client/models/ImageRegistryNotAllowedError.ts
|
|
805
|
+
var ImageRegistryNotAllowedError;
|
|
806
|
+
((ImageRegistryNotAllowedError2) => {
|
|
807
|
+
let error;
|
|
808
|
+
((error2) => {
|
|
809
|
+
error2["IMAGE_REGISTRY_NOT_ALLOWED"] = "IMAGE_REGISTRY_NOT_ALLOWED";
|
|
810
|
+
})(error = ImageRegistryNotAllowedError2.error || (ImageRegistryNotAllowedError2.error = {}));
|
|
811
|
+
})(ImageRegistryNotAllowedError || (ImageRegistryNotAllowedError = {}));
|
|
812
|
+
|
|
813
|
+
// ../containers-shared/src/client/models/ImageRegistryNotFoundError.ts
|
|
814
|
+
var ImageRegistryNotFoundError;
|
|
815
|
+
((ImageRegistryNotFoundError2) => {
|
|
816
|
+
let error;
|
|
817
|
+
((error2) => {
|
|
818
|
+
error2["IMAGE_REGISTRY_NOT_FOUND"] = "IMAGE_REGISTRY_NOT_FOUND";
|
|
819
|
+
})(error = ImageRegistryNotFoundError2.error || (ImageRegistryNotFoundError2.error = {}));
|
|
820
|
+
})(ImageRegistryNotFoundError || (ImageRegistryNotFoundError = {}));
|
|
821
|
+
|
|
822
|
+
// ../containers-shared/src/client/models/ImageRegistryProtocolAlreadyExists.ts
|
|
823
|
+
var ImageRegistryProtocolAlreadyExists;
|
|
824
|
+
((ImageRegistryProtocolAlreadyExists2) => {
|
|
825
|
+
let error;
|
|
826
|
+
((error2) => {
|
|
827
|
+
error2["IMAGE_REGISTRY_PROTOCOL_ALREADY_EXISTS"] = "IMAGE_REGISTRY_PROTOCOL_ALREADY_EXISTS";
|
|
828
|
+
})(error = ImageRegistryProtocolAlreadyExists2.error || (ImageRegistryProtocolAlreadyExists2.error = {}));
|
|
829
|
+
})(ImageRegistryProtocolAlreadyExists || (ImageRegistryProtocolAlreadyExists = {}));
|
|
830
|
+
|
|
831
|
+
// ../containers-shared/src/client/models/ImageRegistryProtocolIsReferencedError.ts
|
|
832
|
+
var ImageRegistryProtocolIsReferencedError;
|
|
833
|
+
((ImageRegistryProtocolIsReferencedError2) => {
|
|
834
|
+
let error;
|
|
835
|
+
((error2) => {
|
|
836
|
+
error2["IMAGE_REGISTRY_PROTO_IS_REFERENCED"] = "IMAGE_REGISTRY_PROTO_IS_REFERENCED";
|
|
837
|
+
})(error = ImageRegistryProtocolIsReferencedError2.error || (ImageRegistryProtocolIsReferencedError2.error = {}));
|
|
838
|
+
})(ImageRegistryProtocolIsReferencedError || (ImageRegistryProtocolIsReferencedError = {}));
|
|
839
|
+
|
|
840
|
+
// ../containers-shared/src/client/models/ImageRegistryProtocolNotFound.ts
|
|
841
|
+
var ImageRegistryProtocolNotFound;
|
|
842
|
+
((ImageRegistryProtocolNotFound2) => {
|
|
843
|
+
let error;
|
|
844
|
+
((error2) => {
|
|
845
|
+
error2["IMAGE_REGISTRY_PROTOCOL_NOT_FOUND"] = "IMAGE_REGISTRY_PROTOCOL_NOT_FOUND";
|
|
846
|
+
})(error = ImageRegistryProtocolNotFound2.error || (ImageRegistryProtocolNotFound2.error = {}));
|
|
847
|
+
})(ImageRegistryProtocolNotFound || (ImageRegistryProtocolNotFound = {}));
|
|
848
|
+
|
|
849
|
+
// ../containers-shared/src/client/models/ProvisionerConfiguration.ts
|
|
850
|
+
var ProvisionerConfiguration;
|
|
851
|
+
((ProvisionerConfiguration2) => {
|
|
852
|
+
let type;
|
|
853
|
+
((type2) => {
|
|
854
|
+
type2["NONE"] = "none";
|
|
855
|
+
type2["CLOUDINIT"] = "cloudinit";
|
|
856
|
+
})(type = ProvisionerConfiguration2.type || (ProvisionerConfiguration2.type = {}));
|
|
857
|
+
})(ProvisionerConfiguration || (ProvisionerConfiguration = {}));
|
|
858
|
+
|
|
859
|
+
// ../containers-shared/src/client/models/RolloutStep.ts
|
|
860
|
+
var RolloutStep;
|
|
861
|
+
((RolloutStep2) => {
|
|
862
|
+
let status;
|
|
863
|
+
((status2) => {
|
|
864
|
+
status2["PENDING"] = "pending";
|
|
865
|
+
status2["PROGRESSING"] = "progressing";
|
|
866
|
+
status2["REVERTING"] = "reverting";
|
|
867
|
+
status2["COMPLETED"] = "completed";
|
|
868
|
+
status2["REVERTED"] = "reverted";
|
|
869
|
+
})(status = RolloutStep2.status || (RolloutStep2.status = {}));
|
|
870
|
+
})(RolloutStep || (RolloutStep = {}));
|
|
871
|
+
|
|
872
|
+
// ../containers-shared/src/client/models/SecretNameAlreadyExists.ts
|
|
873
|
+
var SecretNameAlreadyExists;
|
|
874
|
+
((SecretNameAlreadyExists2) => {
|
|
875
|
+
let error;
|
|
876
|
+
((error2) => {
|
|
877
|
+
error2["SECRET_NAME_ALREADY_EXISTS"] = "SECRET_NAME_ALREADY_EXISTS";
|
|
878
|
+
})(error = SecretNameAlreadyExists2.error || (SecretNameAlreadyExists2.error = {}));
|
|
879
|
+
})(SecretNameAlreadyExists || (SecretNameAlreadyExists = {}));
|
|
880
|
+
|
|
881
|
+
// ../containers-shared/src/client/models/SecretNotFound.ts
|
|
882
|
+
var SecretNotFound;
|
|
883
|
+
((SecretNotFound2) => {
|
|
884
|
+
let error;
|
|
885
|
+
((error2) => {
|
|
886
|
+
error2["SECRET_NAME_NOT_FOUND"] = "SECRET_NAME_NOT_FOUND";
|
|
887
|
+
})(error = SecretNotFound2.error || (SecretNotFound2.error = {}));
|
|
888
|
+
})(SecretNotFound || (SecretNotFound = {}));
|
|
889
|
+
|
|
890
|
+
// ../containers-shared/src/client/models/SSHPublicKeyNotFoundError.ts
|
|
891
|
+
var SSHPublicKeyNotFoundError;
|
|
892
|
+
((SSHPublicKeyNotFoundError2) => {
|
|
893
|
+
let error;
|
|
894
|
+
((error2) => {
|
|
895
|
+
error2["SSH_PUBLIC_KEY_NOT_FOUND"] = "SSH_PUBLIC_KEY_NOT_FOUND";
|
|
896
|
+
})(error = SSHPublicKeyNotFoundError2.error || (SSHPublicKeyNotFoundError2.error = {}));
|
|
897
|
+
})(SSHPublicKeyNotFoundError || (SSHPublicKeyNotFoundError = {}));
|
|
898
|
+
|
|
899
|
+
// ../containers-shared/src/client/models/UpdateApplicationRolloutRequest.ts
|
|
900
|
+
var UpdateApplicationRolloutRequest;
|
|
901
|
+
((UpdateApplicationRolloutRequest2) => {
|
|
902
|
+
let action;
|
|
903
|
+
((action2) => {
|
|
904
|
+
action2["NEXT"] = "next";
|
|
905
|
+
action2["PREVIOUS"] = "previous";
|
|
906
|
+
action2["REVERT"] = "revert";
|
|
907
|
+
})(action = UpdateApplicationRolloutRequest2.action || (UpdateApplicationRolloutRequest2.action = {}));
|
|
908
|
+
})(UpdateApplicationRolloutRequest || (UpdateApplicationRolloutRequest = {}));
|
|
909
|
+
|
|
910
|
+
// ../containers-shared/src/client/core/request.ts
|
|
911
|
+
var isDefined = (value) => {
|
|
912
|
+
return value !== void 0 && value !== null;
|
|
913
|
+
};
|
|
914
|
+
var isString = (value) => {
|
|
915
|
+
return typeof value === "string";
|
|
916
|
+
};
|
|
917
|
+
var isStringWithValue = (value) => {
|
|
918
|
+
return isString(value) && value !== "";
|
|
919
|
+
};
|
|
920
|
+
var isBlob = (value) => {
|
|
921
|
+
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]);
|
|
922
|
+
};
|
|
923
|
+
var base64 = (str) => {
|
|
924
|
+
try {
|
|
925
|
+
return btoa(str);
|
|
926
|
+
} catch (err) {
|
|
927
|
+
return Buffer.from(str).toString("base64");
|
|
928
|
+
}
|
|
929
|
+
};
|
|
930
|
+
var getQueryString = (params) => {
|
|
931
|
+
const qs = [];
|
|
932
|
+
const append = (key, value) => {
|
|
933
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
934
|
+
};
|
|
935
|
+
const process2 = (key, value) => {
|
|
936
|
+
if (isDefined(value)) {
|
|
937
|
+
if (Array.isArray(value)) {
|
|
938
|
+
value.forEach((v) => {
|
|
939
|
+
process2(key, v);
|
|
940
|
+
});
|
|
941
|
+
} else if (typeof value === "object") {
|
|
942
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
943
|
+
process2(`${key}[${k}]`, v);
|
|
944
|
+
});
|
|
945
|
+
} else {
|
|
946
|
+
append(key, value);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
951
|
+
process2(key, value);
|
|
952
|
+
});
|
|
953
|
+
if (qs.length > 0) {
|
|
954
|
+
return `?${qs.join("&")}`;
|
|
955
|
+
}
|
|
956
|
+
return "";
|
|
957
|
+
};
|
|
958
|
+
var getUrl = (config, options) => {
|
|
959
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
960
|
+
const path14 = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
961
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
962
|
+
return encoder(String(options.path[group]));
|
|
963
|
+
}
|
|
964
|
+
return substring;
|
|
965
|
+
});
|
|
966
|
+
const url = `${config.BASE}${path14}`;
|
|
967
|
+
if (options.query) {
|
|
968
|
+
return `${url}${getQueryString(options.query)}`;
|
|
969
|
+
}
|
|
970
|
+
return url;
|
|
971
|
+
};
|
|
972
|
+
var getFormData = (options) => {
|
|
973
|
+
if (options.formData) {
|
|
974
|
+
const formData = new FormData();
|
|
975
|
+
const process2 = async (key, value) => {
|
|
976
|
+
if (isString(value)) {
|
|
977
|
+
formData.append(key, value);
|
|
978
|
+
} else {
|
|
979
|
+
formData.append(key, JSON.stringify(value));
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
Object.entries(options.formData).filter(([_, value]) => isDefined(value)).forEach(([key, value]) => {
|
|
983
|
+
if (Array.isArray(value)) {
|
|
984
|
+
value.forEach((v) => process2(key, v));
|
|
985
|
+
} else {
|
|
986
|
+
process2(key, value);
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
return formData;
|
|
990
|
+
}
|
|
991
|
+
return void 0;
|
|
992
|
+
};
|
|
993
|
+
var resolve = async (options, resolver) => {
|
|
994
|
+
if (typeof resolver === "function") {
|
|
995
|
+
return resolver(options);
|
|
996
|
+
}
|
|
997
|
+
return resolver;
|
|
998
|
+
};
|
|
999
|
+
var getHeaders = async (config, options) => {
|
|
1000
|
+
const token = await resolve(options, config.TOKEN);
|
|
1001
|
+
const username = await resolve(options, config.USERNAME);
|
|
1002
|
+
const password = await resolve(options, config.PASSWORD);
|
|
1003
|
+
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
1004
|
+
const headers = Object.entries({
|
|
1005
|
+
Accept: "application/json",
|
|
1006
|
+
...additionalHeaders,
|
|
1007
|
+
...options.headers
|
|
1008
|
+
}).filter(([_, value]) => isDefined(value)).reduce(
|
|
1009
|
+
(headers2, [key, value]) => ({
|
|
1010
|
+
...headers2,
|
|
1011
|
+
[key]: String(value)
|
|
1012
|
+
}),
|
|
1013
|
+
{}
|
|
1014
|
+
);
|
|
1015
|
+
if (isStringWithValue(token)) {
|
|
1016
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
1017
|
+
}
|
|
1018
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
1019
|
+
const credentials = base64(`${username}:${password}`);
|
|
1020
|
+
headers["Authorization"] = `Basic ${credentials}`;
|
|
1021
|
+
}
|
|
1022
|
+
if (options.body) {
|
|
1023
|
+
if (options.mediaType) {
|
|
1024
|
+
headers["Content-Type"] = options.mediaType;
|
|
1025
|
+
} else if (isBlob(options.body)) {
|
|
1026
|
+
headers["Content-Type"] = options.body.type || "application/octet-stream";
|
|
1027
|
+
} else if (isString(options.body)) {
|
|
1028
|
+
headers["Content-Type"] = "text/plain";
|
|
1029
|
+
} else {
|
|
1030
|
+
headers["Content-Type"] = "application/json";
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
return new Headers(headers);
|
|
1034
|
+
};
|
|
1035
|
+
var getRequestBody = (options) => {
|
|
1036
|
+
if (options.body !== void 0) {
|
|
1037
|
+
if (options.mediaType?.includes("/json")) {
|
|
1038
|
+
return JSON.stringify(options.body);
|
|
1039
|
+
} else if (isString(options.body) || isBlob(options.body)) {
|
|
1040
|
+
return options.body;
|
|
1041
|
+
} else {
|
|
1042
|
+
return JSON.stringify(options.body);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
return void 0;
|
|
1046
|
+
};
|
|
1047
|
+
var isResponseSchemaV4 = (config, _options) => {
|
|
1048
|
+
return config.BASE.endsWith("/containers");
|
|
1049
|
+
};
|
|
1050
|
+
var parseResponseSchemaV4 = (url, response, responseHeader, responseBody) => {
|
|
1051
|
+
const fetchResult = typeof responseBody === "object" ? responseBody : JSON.parse(responseBody);
|
|
1052
|
+
const ok = response.ok && fetchResult.success;
|
|
1053
|
+
let result;
|
|
1054
|
+
if (ok) {
|
|
1055
|
+
if (fetchResult.result !== void 0) {
|
|
1056
|
+
result = fetchResult.result;
|
|
1057
|
+
} else {
|
|
1058
|
+
result = {};
|
|
1059
|
+
}
|
|
1060
|
+
} else {
|
|
1061
|
+
result = { error: fetchResult.errors?.[0]?.message };
|
|
1062
|
+
}
|
|
1063
|
+
return {
|
|
1064
|
+
url,
|
|
1065
|
+
ok,
|
|
1066
|
+
status: response.status,
|
|
1067
|
+
statusText: response.statusText,
|
|
1068
|
+
body: responseHeader ?? result
|
|
1069
|
+
};
|
|
1070
|
+
};
|
|
1071
|
+
var sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
1072
|
+
const controller = new AbortController();
|
|
1073
|
+
const request2 = {
|
|
1074
|
+
headers,
|
|
1075
|
+
body: body ?? formData,
|
|
1076
|
+
method: options.method,
|
|
1077
|
+
signal: controller.signal
|
|
1078
|
+
};
|
|
1079
|
+
if (config.WITH_CREDENTIALS) {
|
|
1080
|
+
request2.credentials = config.CREDENTIALS;
|
|
1081
|
+
}
|
|
1082
|
+
onCancel(() => controller.abort());
|
|
1083
|
+
return await fetch(url, request2);
|
|
1084
|
+
};
|
|
1085
|
+
var getResponseHeader = (response, responseHeader) => {
|
|
1086
|
+
if (responseHeader) {
|
|
1087
|
+
const content = response.headers.get(responseHeader);
|
|
1088
|
+
if (isString(content)) {
|
|
1089
|
+
return content;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
return void 0;
|
|
1093
|
+
};
|
|
1094
|
+
var getResponseBody = async (response) => {
|
|
1095
|
+
if (response.status !== 204) {
|
|
1096
|
+
try {
|
|
1097
|
+
const contentType = response.headers.get("Content-Type");
|
|
1098
|
+
if (contentType) {
|
|
1099
|
+
const jsonTypes = ["application/json", "application/problem+json"];
|
|
1100
|
+
const isJSON = jsonTypes.some(
|
|
1101
|
+
(type) => contentType.toLowerCase().startsWith(type)
|
|
1102
|
+
);
|
|
1103
|
+
if (isJSON) {
|
|
1104
|
+
return await response.json();
|
|
1105
|
+
} else {
|
|
1106
|
+
return await response.text();
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
} catch (error) {
|
|
1110
|
+
console.error(error);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
return void 0;
|
|
1114
|
+
};
|
|
1115
|
+
var catchErrorCodes = (options, result) => {
|
|
1116
|
+
const errors = {
|
|
1117
|
+
400: "Bad Request",
|
|
1118
|
+
401: "Unauthorized",
|
|
1119
|
+
403: "Forbidden",
|
|
1120
|
+
404: "Not Found",
|
|
1121
|
+
500: "Internal Server Error",
|
|
1122
|
+
502: "Bad Gateway",
|
|
1123
|
+
503: "Service Unavailable",
|
|
1124
|
+
...options.errors
|
|
1125
|
+
};
|
|
1126
|
+
const error = errors[result.status];
|
|
1127
|
+
if (error) {
|
|
1128
|
+
throw new ApiError(options, result, error);
|
|
1129
|
+
}
|
|
1130
|
+
if (!result.ok) {
|
|
1131
|
+
throw new ApiError(options, result, "Generic Error");
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
var request = (config, options) => {
|
|
1135
|
+
return new CancelablePromise(async (resolve9, reject, onCancel) => {
|
|
1136
|
+
try {
|
|
1137
|
+
const url = getUrl(config, options);
|
|
1138
|
+
const formData = getFormData(options);
|
|
1139
|
+
const body = getRequestBody(options);
|
|
1140
|
+
const headers = await getHeaders(config, options);
|
|
1141
|
+
if (!onCancel.isCancelled) {
|
|
1142
|
+
const response = await sendRequest(
|
|
1143
|
+
config,
|
|
1144
|
+
options,
|
|
1145
|
+
url,
|
|
1146
|
+
body,
|
|
1147
|
+
formData,
|
|
1148
|
+
headers,
|
|
1149
|
+
onCancel
|
|
1150
|
+
);
|
|
1151
|
+
const responseBody = await getResponseBody(response);
|
|
1152
|
+
const responseHeader = getResponseHeader(
|
|
1153
|
+
response,
|
|
1154
|
+
options.responseHeader
|
|
1155
|
+
);
|
|
1156
|
+
let result;
|
|
1157
|
+
if (isResponseSchemaV4(config, options)) {
|
|
1158
|
+
result = parseResponseSchemaV4(
|
|
1159
|
+
url,
|
|
1160
|
+
response,
|
|
1161
|
+
responseHeader,
|
|
1162
|
+
responseBody
|
|
1163
|
+
);
|
|
1164
|
+
} else {
|
|
1165
|
+
result = {
|
|
1166
|
+
url,
|
|
1167
|
+
ok: response.ok,
|
|
1168
|
+
status: response.status,
|
|
1169
|
+
statusText: response.statusText,
|
|
1170
|
+
body: responseHeader ?? responseBody
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
catchErrorCodes(options, result);
|
|
1174
|
+
resolve9(result.body);
|
|
1175
|
+
}
|
|
1176
|
+
} catch (error) {
|
|
1177
|
+
reject(error);
|
|
1178
|
+
}
|
|
1179
|
+
});
|
|
1180
|
+
};
|
|
1181
|
+
|
|
1182
|
+
// ../containers-shared/src/client/services/ImageRegistriesService.ts
|
|
1183
|
+
var ImageRegistriesService = class {
|
|
1184
|
+
/**
|
|
1185
|
+
* Create an image registry protocol that resolves to multiple domains.
|
|
1186
|
+
* @param requestBody
|
|
1187
|
+
* @returns ImageRegistryProtocol The image registry protocol was created
|
|
1188
|
+
* @throws ApiError
|
|
1189
|
+
*/
|
|
1190
|
+
static createImageRegistryProtocol(requestBody) {
|
|
1191
|
+
return request(OpenAPI, {
|
|
1192
|
+
method: "POST",
|
|
1193
|
+
url: "/registries/protos",
|
|
1194
|
+
body: requestBody,
|
|
1195
|
+
mediaType: "application/json",
|
|
1196
|
+
errors: {
|
|
1197
|
+
400: `Bad Request that contains a specific constant code and details object about the error.`,
|
|
1198
|
+
403: `The registry that is being added is not allowed`,
|
|
1199
|
+
409: `Image registry protocol already exists`,
|
|
1200
|
+
500: `There has been an internal error`
|
|
1201
|
+
}
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* List all image registry protocols.
|
|
1206
|
+
* @returns ImageRegistryProtocols The image registry protocols in the account
|
|
1207
|
+
* @throws ApiError
|
|
1208
|
+
*/
|
|
1209
|
+
static listImageRegistryProtocols() {
|
|
1210
|
+
return request(OpenAPI, {
|
|
1211
|
+
method: "GET",
|
|
1212
|
+
url: "/registries/protos",
|
|
1213
|
+
errors: {
|
|
1214
|
+
500: `There has been an internal error`
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Modify an image registry protocol. The previous list of domains will be replaced by the ones you specify in this endpoint.
|
|
1220
|
+
* @param requestBody
|
|
1221
|
+
* @returns ImageRegistryProtocol The image registry protocol was modified
|
|
1222
|
+
* @throws ApiError
|
|
1223
|
+
*/
|
|
1224
|
+
static modifyImageRegistryProtocol(requestBody) {
|
|
1225
|
+
return request(OpenAPI, {
|
|
1226
|
+
method: "PUT",
|
|
1227
|
+
url: "/registries/protos",
|
|
1228
|
+
body: requestBody,
|
|
1229
|
+
mediaType: "application/json",
|
|
1230
|
+
errors: {
|
|
1231
|
+
400: `Bad Request that contains a specific constant code and details object about the error.`,
|
|
1232
|
+
403: `The registry that is being added is not allowed`,
|
|
1233
|
+
404: `Image registry protocol doesn't exist`,
|
|
1234
|
+
500: `There has been an internal error`
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Delete an image registry protocol. Be careful, if there is deployments running referencing this protocol they won't be able to pull the image.
|
|
1240
|
+
* @param proto
|
|
1241
|
+
* @returns EmptyResponse Image registry protocol was deleted successfully
|
|
1242
|
+
* @throws ApiError
|
|
1243
|
+
*/
|
|
1244
|
+
static deleteImageRegistryProto(proto) {
|
|
1245
|
+
return request(OpenAPI, {
|
|
1246
|
+
method: "DELETE",
|
|
1247
|
+
url: "/registries/protos/{proto}",
|
|
1248
|
+
path: {
|
|
1249
|
+
proto
|
|
1250
|
+
},
|
|
1251
|
+
errors: {
|
|
1252
|
+
400: `The image registry protocol couldn't be deleted because it's referenced by a deployment or application`,
|
|
1253
|
+
404: `Image registry protocol doesn't exist`,
|
|
1254
|
+
500: `There has been an internal error`
|
|
1255
|
+
}
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
/**
|
|
1259
|
+
* Get a JWT to pull from the image registry
|
|
1260
|
+
* Get a JWT to pull from the image registry specifying its domain
|
|
1261
|
+
* @param domain
|
|
1262
|
+
* @param requestBody
|
|
1263
|
+
* @returns AccountRegistryToken Credentials with 'pull' or 'push' permissions to access the registry
|
|
1264
|
+
* @throws ApiError
|
|
1265
|
+
*/
|
|
1266
|
+
static generateImageRegistryCredentials(domain, requestBody) {
|
|
1267
|
+
return request(OpenAPI, {
|
|
1268
|
+
method: "POST",
|
|
1269
|
+
url: "/registries/{domain}/credentials",
|
|
1270
|
+
path: {
|
|
1271
|
+
domain
|
|
1272
|
+
},
|
|
1273
|
+
body: requestBody,
|
|
1274
|
+
mediaType: "application/json",
|
|
1275
|
+
errors: {
|
|
1276
|
+
400: `Bad Request that contains a specific constant code and details object about the error.`,
|
|
1277
|
+
404: `The image registry does not exist`,
|
|
1278
|
+
409: `The registry was configured as public, so credentials can not be generated`,
|
|
1279
|
+
500: `There has been an internal error`
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Delete a registry from the account
|
|
1285
|
+
* Delete a registry from the account, this will make Cloudchamber unable to pull images from the registry
|
|
1286
|
+
* @param domain
|
|
1287
|
+
* @returns EmptyResponse The image registry is deleted
|
|
1288
|
+
* @throws ApiError
|
|
1289
|
+
*/
|
|
1290
|
+
static deleteImageRegistry(domain) {
|
|
1291
|
+
return request(OpenAPI, {
|
|
1292
|
+
method: "DELETE",
|
|
1293
|
+
url: "/registries/{domain}",
|
|
1294
|
+
path: {
|
|
1295
|
+
domain
|
|
1296
|
+
},
|
|
1297
|
+
errors: {
|
|
1298
|
+
404: `The image registry does not exist`,
|
|
1299
|
+
500: `There has been an internal error`
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Get the list of configured registries in the account
|
|
1305
|
+
* Get the list of configured registries in the account
|
|
1306
|
+
* @returns CustomerImageRegistry The list of registries that are added in the account
|
|
1307
|
+
* @throws ApiError
|
|
1308
|
+
*/
|
|
1309
|
+
static listImageRegistries() {
|
|
1310
|
+
return request(OpenAPI, {
|
|
1311
|
+
method: "GET",
|
|
1312
|
+
url: "/registries",
|
|
1313
|
+
errors: {
|
|
1314
|
+
500: `There has been an internal error`
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Add a new image registry configuration
|
|
1320
|
+
* Add a new image registry into your account, so then Cloudflare can pull docker images with public key JWT authentication
|
|
1321
|
+
* @param requestBody
|
|
1322
|
+
* @returns CustomerImageRegistry Created a new image registry in the account
|
|
1323
|
+
* @throws ApiError
|
|
1324
|
+
*/
|
|
1325
|
+
static createImageRegistry(requestBody) {
|
|
1326
|
+
return request(OpenAPI, {
|
|
1327
|
+
method: "POST",
|
|
1328
|
+
url: "/registries",
|
|
1329
|
+
body: requestBody,
|
|
1330
|
+
mediaType: "application/json",
|
|
1331
|
+
errors: {
|
|
1332
|
+
400: `Image registry input is malformed, see the error details`,
|
|
1333
|
+
403: `The registry that is being added is not allowed`,
|
|
1334
|
+
409: `The image registry already exists in the account`,
|
|
1335
|
+
500: `There has been an internal error`
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1340
|
+
|
|
1341
|
+
// ../containers-shared/src/login.ts
|
|
1342
|
+
async function dockerLoginManagedRegistry(pathToDocker) {
|
|
1343
|
+
const expirationMinutes = 15;
|
|
1344
|
+
const credentials = await ImageRegistriesService.generateImageRegistryCredentials(
|
|
1345
|
+
getCloudflareContainerRegistry(),
|
|
1346
|
+
{
|
|
1347
|
+
expiration_minutes: expirationMinutes,
|
|
1348
|
+
permissions: [
|
|
1349
|
+
"push" /* PUSH */,
|
|
1350
|
+
"pull" /* PULL */
|
|
1351
|
+
]
|
|
1352
|
+
}
|
|
1353
|
+
);
|
|
1354
|
+
const child = spawn2(
|
|
1355
|
+
pathToDocker,
|
|
1356
|
+
[
|
|
1357
|
+
"login",
|
|
1358
|
+
"--password-stdin",
|
|
1359
|
+
"--username",
|
|
1360
|
+
"v1",
|
|
1361
|
+
getCloudflareContainerRegistry()
|
|
1362
|
+
],
|
|
1363
|
+
{ stdio: ["pipe", "inherit", "inherit"] }
|
|
1364
|
+
).on("error", (err) => {
|
|
1365
|
+
throw err;
|
|
1366
|
+
});
|
|
1367
|
+
child.stdin.write(credentials.password);
|
|
1368
|
+
child.stdin.end();
|
|
1369
|
+
await new Promise((resolve9, reject) => {
|
|
1370
|
+
child.on("close", (code) => {
|
|
1371
|
+
if (code === 0) {
|
|
1372
|
+
resolve9();
|
|
1373
|
+
} else {
|
|
1374
|
+
reject(new Error(`Login failed with code: ${code}`));
|
|
1375
|
+
}
|
|
1376
|
+
});
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
// ../containers-shared/src/utils.ts
|
|
1381
|
+
import { execFile, spawn as spawn4 } from "child_process";
|
|
1382
|
+
import { randomUUID } from "crypto";
|
|
1383
|
+
import { existsSync, statSync } from "fs";
|
|
1384
|
+
import path2 from "path";
|
|
1385
|
+
|
|
1386
|
+
// ../containers-shared/src/inspect.ts
|
|
1387
|
+
import { spawn as spawn3 } from "child_process";
|
|
1388
|
+
async function dockerImageInspect(dockerPath, options) {
|
|
1389
|
+
return new Promise((resolve9, reject) => {
|
|
1390
|
+
const proc = spawn3(
|
|
1391
|
+
dockerPath,
|
|
1392
|
+
["image", "inspect", options.imageTag, "--format", options.formatString],
|
|
1393
|
+
{
|
|
1394
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1395
|
+
}
|
|
1396
|
+
);
|
|
1397
|
+
let stdout = "";
|
|
1398
|
+
let stderr = "";
|
|
1399
|
+
proc.stdout.on("data", (chunk) => stdout += chunk);
|
|
1400
|
+
proc.stderr.on("data", (chunk) => stderr += chunk);
|
|
1401
|
+
proc.on("close", (code) => {
|
|
1402
|
+
if (code !== 0) {
|
|
1403
|
+
return reject(
|
|
1404
|
+
new Error(`failed inspecting image locally: ${stderr.trim()}`)
|
|
1405
|
+
);
|
|
1406
|
+
}
|
|
1407
|
+
resolve9(stdout.trim());
|
|
1408
|
+
});
|
|
1409
|
+
proc.on("error", (err) => reject(err));
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
// ../containers-shared/src/utils.ts
|
|
1414
|
+
var runDockerCmd = (dockerPath, args, stdio) => {
|
|
1415
|
+
let aborted = false;
|
|
1416
|
+
let resolve9;
|
|
1417
|
+
let reject;
|
|
1418
|
+
const ready = new Promise((res, rej) => {
|
|
1419
|
+
resolve9 = res;
|
|
1420
|
+
reject = rej;
|
|
1421
|
+
});
|
|
1422
|
+
const child = spawn4(dockerPath, args, {
|
|
1423
|
+
stdio: stdio ?? "inherit",
|
|
1424
|
+
// We need to set detached to true so that the child process
|
|
1425
|
+
// will control all of its child processed and we can kill
|
|
1426
|
+
// all of them in case we need to abort the build process
|
|
1427
|
+
detached: true
|
|
1428
|
+
});
|
|
1429
|
+
let errorHandled = false;
|
|
1430
|
+
child.on("close", (code) => {
|
|
1431
|
+
if (code === 0 || aborted) {
|
|
1432
|
+
resolve9({ aborted });
|
|
1433
|
+
} else if (!errorHandled) {
|
|
1434
|
+
errorHandled = true;
|
|
1435
|
+
reject(new Error(`Docker command exited with code: ${code}`));
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
child.on("error", (err) => {
|
|
1439
|
+
if (!errorHandled) {
|
|
1440
|
+
errorHandled = true;
|
|
1441
|
+
reject(new Error(`Docker command failed: ${err.message}`));
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
return {
|
|
1445
|
+
abort: () => {
|
|
1446
|
+
aborted = true;
|
|
1447
|
+
child.unref();
|
|
1448
|
+
if (child.pid !== void 0) {
|
|
1449
|
+
process.kill(-child.pid);
|
|
1450
|
+
}
|
|
1451
|
+
},
|
|
1452
|
+
ready,
|
|
1453
|
+
then: async (resolve10, reject2) => ready.then(resolve10).catch(reject2)
|
|
1454
|
+
};
|
|
1455
|
+
};
|
|
1456
|
+
var runDockerCmdWithOutput = async (dockerPath, args) => {
|
|
1457
|
+
return new Promise((resolve9, reject) => {
|
|
1458
|
+
execFile(dockerPath, args, (error, stdout) => {
|
|
1459
|
+
if (error) {
|
|
1460
|
+
return reject(
|
|
1461
|
+
new Error(
|
|
1462
|
+
`Failed running docker command: ${error.message}. Command: ${dockerPath} ${args.join(" ")}`
|
|
1463
|
+
)
|
|
1464
|
+
);
|
|
1465
|
+
}
|
|
1466
|
+
return resolve9(stdout.trim());
|
|
1467
|
+
});
|
|
1468
|
+
});
|
|
1469
|
+
};
|
|
1470
|
+
var verifyDockerInstalled = async (dockerPath, isDev = true) => {
|
|
1471
|
+
try {
|
|
1472
|
+
await runDockerCmd(dockerPath, ["info"], ["inherit", "pipe", "pipe"]);
|
|
1473
|
+
} catch {
|
|
1474
|
+
throw new Error(
|
|
1475
|
+
`The Docker CLI could not be launched. Please ensure that the Docker CLI is installed and the daemon is running.
|
|
1476
|
+
Other container tooling that is compatible with the Docker CLI and engine may work, but is not yet guaranteed to do so. You can specify an executable with the environment variable WRANGLER_DOCKER_BIN and a socket with WRANGLER_DOCKER_HOST.${isDev ? "\nTo suppress this error if you do not intend on triggering any container instances, set dev.enable_containers to false in your Wrangler config or passing in --enable-containers=false." : ""}`
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
function isDir(path14) {
|
|
1481
|
+
const stats = statSync(path14);
|
|
1482
|
+
return stats.isDirectory();
|
|
1483
|
+
}
|
|
1484
|
+
var isDockerfile = (image, configPath) => {
|
|
1485
|
+
const baseDir = configPath ? path2.dirname(configPath) : process.cwd();
|
|
1486
|
+
const maybeDockerfile = path2.resolve(baseDir, image);
|
|
1487
|
+
if (existsSync(maybeDockerfile)) {
|
|
1488
|
+
if (isDir(maybeDockerfile)) {
|
|
1489
|
+
throw new Error(
|
|
1490
|
+
`${image} is a directory, you should specify a path to the Dockerfile`
|
|
1491
|
+
);
|
|
1492
|
+
}
|
|
1493
|
+
return true;
|
|
1494
|
+
}
|
|
1495
|
+
const errorPrefix = `The image "${image}" does not appear to be a valid path to a Dockerfile, or a valid image registry path:
|
|
1496
|
+
`;
|
|
1497
|
+
try {
|
|
1498
|
+
new URL(`https://${image}`);
|
|
1499
|
+
} catch (e) {
|
|
1500
|
+
if (e instanceof Error) {
|
|
1501
|
+
throw new Error(errorPrefix + e.message);
|
|
1502
|
+
}
|
|
1503
|
+
throw e;
|
|
1504
|
+
}
|
|
1505
|
+
const imageParts = image.split("/");
|
|
1506
|
+
if (!imageParts[imageParts.length - 1]?.includes(":")) {
|
|
1507
|
+
throw new Error(
|
|
1508
|
+
errorPrefix + `If this is an image registry path, it needs to include at least a tag ':' (e.g: docker.io/httpd:1)`
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
if (image.includes("://")) {
|
|
1512
|
+
throw new Error(
|
|
1513
|
+
errorPrefix + `Image reference should not include the protocol part (e.g: docker.io/httpd:1, not https://docker.io/httpd:1)`
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1516
|
+
return false;
|
|
1517
|
+
};
|
|
1518
|
+
async function getContainerIdsByImageTags(dockerPath, imageTags) {
|
|
1519
|
+
const ids = /* @__PURE__ */ new Set();
|
|
1520
|
+
for (const imageTag of imageTags) {
|
|
1521
|
+
const containerIdsFromImage = await getContainerIdsFromImage(
|
|
1522
|
+
dockerPath,
|
|
1523
|
+
imageTag
|
|
1524
|
+
);
|
|
1525
|
+
containerIdsFromImage.forEach((id) => ids.add(id));
|
|
1526
|
+
}
|
|
1527
|
+
return Array.from(ids);
|
|
1528
|
+
}
|
|
1529
|
+
var getContainerIdsFromImage = async (dockerPath, ancestorImage) => {
|
|
1530
|
+
const output = await runDockerCmdWithOutput(dockerPath, [
|
|
1531
|
+
"ps",
|
|
1532
|
+
"-a",
|
|
1533
|
+
"--filter",
|
|
1534
|
+
`ancestor=${ancestorImage}`,
|
|
1535
|
+
"--format",
|
|
1536
|
+
"{{.ID}}"
|
|
1537
|
+
]);
|
|
1538
|
+
return output.split("\n").filter((line) => line.trim());
|
|
1539
|
+
};
|
|
1540
|
+
async function checkExposedPorts(dockerPath, options) {
|
|
1541
|
+
const output = await dockerImageInspect(dockerPath, {
|
|
1542
|
+
imageTag: options.imageTag,
|
|
1543
|
+
formatString: "{{ len .Config.ExposedPorts }}"
|
|
1544
|
+
});
|
|
1545
|
+
if (output === "0") {
|
|
1546
|
+
throw new Error(
|
|
1547
|
+
`The container "${options.class_name}" does not expose any ports. In your Dockerfile, please expose any ports you intend to connect to.
|
|
1548
|
+
For additional information please see: https://developers.cloudflare.com/containers/local-dev/#exposing-ports.
|
|
1549
|
+
`
|
|
1550
|
+
);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
function generateContainerBuildId() {
|
|
1554
|
+
return randomUUID().slice(0, 8);
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
// ../containers-shared/src/images.ts
|
|
1558
|
+
async function pullImage(dockerPath, options) {
|
|
1559
|
+
await dockerLoginManagedRegistry(dockerPath);
|
|
1560
|
+
const pull = runDockerCmd(dockerPath, [
|
|
1561
|
+
"pull",
|
|
1562
|
+
options.image,
|
|
1563
|
+
// All containers running on our platform need to be built for amd64 architecture, but by default docker pull seems to look for an image matching the host system, so we need to specify this here
|
|
1564
|
+
"--platform",
|
|
1565
|
+
"linux/amd64"
|
|
1566
|
+
]);
|
|
1567
|
+
const ready = pull.ready.then(async ({ aborted }) => {
|
|
1568
|
+
if (!aborted) {
|
|
1569
|
+
await runDockerCmd(dockerPath, ["tag", options.image, options.imageTag]);
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
return {
|
|
1573
|
+
abort: () => {
|
|
1574
|
+
pull.abort();
|
|
1575
|
+
},
|
|
1576
|
+
ready
|
|
1577
|
+
};
|
|
1578
|
+
}
|
|
1579
|
+
async function prepareContainerImagesForDev(options) {
|
|
1580
|
+
const {
|
|
1581
|
+
dockerPath,
|
|
1582
|
+
configPath,
|
|
1583
|
+
containerOptions,
|
|
1584
|
+
onContainerImagePreparationStart,
|
|
1585
|
+
onContainerImagePreparationEnd
|
|
1586
|
+
} = options;
|
|
1587
|
+
let aborted = false;
|
|
1588
|
+
if (process.platform === "win32") {
|
|
1589
|
+
throw new Error(
|
|
1590
|
+
"Local development with containers is currently not supported on Windows. You should use WSL instead. You can also set `enable_containers` to false if you do not need to develop the container part of your application."
|
|
1591
|
+
);
|
|
1592
|
+
}
|
|
1593
|
+
await verifyDockerInstalled(dockerPath);
|
|
1594
|
+
for (const options2 of containerOptions) {
|
|
1595
|
+
if (isDockerfile(options2.image, configPath)) {
|
|
1596
|
+
const build = await buildImage(dockerPath, options2, configPath);
|
|
1597
|
+
onContainerImagePreparationStart({
|
|
1598
|
+
containerOptions: options2,
|
|
1599
|
+
abort: () => {
|
|
1600
|
+
aborted = true;
|
|
1601
|
+
build.abort();
|
|
1602
|
+
}
|
|
1603
|
+
});
|
|
1604
|
+
await build.ready;
|
|
1605
|
+
onContainerImagePreparationEnd({
|
|
1606
|
+
containerOptions: options2
|
|
1607
|
+
});
|
|
1608
|
+
} else {
|
|
1609
|
+
if (!isCloudflareRegistryLink(options2.image)) {
|
|
1610
|
+
throw new Error(
|
|
1611
|
+
`Image "${options2.image}" is a registry link but does not point to the Cloudflare container registry.
|
|
1612
|
+
To use an existing image from another repository, see https://developers.cloudflare.com/containers/image-management/#using-existing-images`
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1615
|
+
const pull = await pullImage(dockerPath, options2);
|
|
1616
|
+
onContainerImagePreparationStart({
|
|
1617
|
+
containerOptions: options2,
|
|
1618
|
+
abort: () => {
|
|
1619
|
+
aborted = true;
|
|
1620
|
+
pull.abort();
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
await pull.ready;
|
|
1624
|
+
onContainerImagePreparationEnd({
|
|
1625
|
+
containerOptions: options2
|
|
1626
|
+
});
|
|
1627
|
+
}
|
|
1628
|
+
if (!aborted) {
|
|
1629
|
+
await checkExposedPorts(dockerPath, options2);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
491
1633
|
|
|
492
1634
|
// ../workers-shared/asset-worker/src/utils/rules-engine.ts
|
|
493
1635
|
var ESCAPE_REGEX_CHARACTERS = /[-/\\^$*+?.()|[\]{}]/g;
|
|
@@ -499,8 +1641,8 @@ var generateGlobOnlyRuleRegExp = (rule) => {
|
|
|
499
1641
|
rule = "^" + rule + "$";
|
|
500
1642
|
return RegExp(rule);
|
|
501
1643
|
};
|
|
502
|
-
var generateStaticRoutingRuleMatcher = (rules) => ({ request }) => {
|
|
503
|
-
const { pathname } = new URL(
|
|
1644
|
+
var generateStaticRoutingRuleMatcher = (rules) => ({ request: request2 }) => {
|
|
1645
|
+
const { pathname } = new URL(request2.url);
|
|
504
1646
|
for (const rule of rules) {
|
|
505
1647
|
try {
|
|
506
1648
|
const regExp = generateGlobOnlyRuleRegExp(rule);
|
|
@@ -761,7 +1903,7 @@ function getBtoa() {
|
|
|
761
1903
|
};
|
|
762
1904
|
}
|
|
763
1905
|
}
|
|
764
|
-
var
|
|
1906
|
+
var btoa2 = /* @__PURE__ */ getBtoa();
|
|
765
1907
|
var SourceMap = class {
|
|
766
1908
|
constructor(properties) {
|
|
767
1909
|
this.version = 3;
|
|
@@ -781,7 +1923,7 @@ var SourceMap = class {
|
|
|
781
1923
|
return JSON.stringify(this);
|
|
782
1924
|
}
|
|
783
1925
|
toUrl() {
|
|
784
|
-
return "data:application/json;charset=utf-8;base64," +
|
|
1926
|
+
return "data:application/json;charset=utf-8;base64," + btoa2(this.toString());
|
|
785
1927
|
}
|
|
786
1928
|
};
|
|
787
1929
|
function guessIndent(code) {
|
|
@@ -1619,7 +2761,7 @@ function createModuleReference(type, id) {
|
|
|
1619
2761
|
}
|
|
1620
2762
|
|
|
1621
2763
|
// src/asset-config.ts
|
|
1622
|
-
import * as
|
|
2764
|
+
import * as path3 from "node:path";
|
|
1623
2765
|
|
|
1624
2766
|
// ../workers-shared/utils/configuration/constructConfiguration.ts
|
|
1625
2767
|
import { relative } from "node:path";
|
|
@@ -1755,11 +2897,11 @@ ${invalidHeaderRulesList}`
|
|
|
1755
2897
|
}
|
|
1756
2898
|
|
|
1757
2899
|
// ../workers-shared/utils/configuration/validateURL.ts
|
|
1758
|
-
var extractPathname = (
|
|
1759
|
-
if (!
|
|
1760
|
-
|
|
2900
|
+
var extractPathname = (path14 = "/", includeSearch, includeHash) => {
|
|
2901
|
+
if (!path14.startsWith("/")) {
|
|
2902
|
+
path14 = `/${path14}`;
|
|
1761
2903
|
}
|
|
1762
|
-
const url = new URL(`//${
|
|
2904
|
+
const url = new URL(`//${path14}`, "relative://");
|
|
1763
2905
|
return `${url.pathname}${includeSearch ? url.search : ""}${includeHash ? url.hash : ""}`;
|
|
1764
2906
|
};
|
|
1765
2907
|
var URL_REGEX = /^https:\/\/+(?<host>[^/]+)\/?(?<path>.*)/;
|
|
@@ -1792,8 +2934,8 @@ var validateUrl = (token, onlyRelative = false, disallowPorts = false, includeSe
|
|
|
1792
2934
|
if (!token.startsWith("/") && onlyRelative) {
|
|
1793
2935
|
token = `/${token}`;
|
|
1794
2936
|
}
|
|
1795
|
-
const
|
|
1796
|
-
if (
|
|
2937
|
+
const path14 = PATH_REGEX.exec(token);
|
|
2938
|
+
if (path14) {
|
|
1797
2939
|
try {
|
|
1798
2940
|
return [extractPathname(token, includeSearch, includeHash), void 0];
|
|
1799
2941
|
} catch {
|
|
@@ -1854,7 +2996,7 @@ function parseHeaders(input, {
|
|
|
1854
2996
|
});
|
|
1855
2997
|
}
|
|
1856
2998
|
}
|
|
1857
|
-
const [
|
|
2999
|
+
const [path14, pathError] = validateUrl(line, false, true);
|
|
1858
3000
|
if (pathError) {
|
|
1859
3001
|
invalid.push({
|
|
1860
3002
|
line,
|
|
@@ -1865,7 +3007,7 @@ function parseHeaders(input, {
|
|
|
1865
3007
|
continue;
|
|
1866
3008
|
}
|
|
1867
3009
|
rule = {
|
|
1868
|
-
path:
|
|
3010
|
+
path: path14,
|
|
1869
3011
|
line,
|
|
1870
3012
|
headers: {},
|
|
1871
3013
|
unsetHeaders: []
|
|
@@ -2076,7 +3218,7 @@ var REDIRECTS_FILENAME = "_redirects";
|
|
|
2076
3218
|
var HEADERS_FILENAME = "_headers";
|
|
2077
3219
|
|
|
2078
3220
|
// ../workers-shared/utils/helpers.ts
|
|
2079
|
-
import { readFileSync } from "node:fs";
|
|
3221
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
2080
3222
|
var import_ignore = __toESM(require_ignore());
|
|
2081
3223
|
var import_mime = __toESM(require_mime());
|
|
2082
3224
|
function thrownIsDoesNotExistError(thrown) {
|
|
@@ -2084,7 +3226,7 @@ function thrownIsDoesNotExistError(thrown) {
|
|
|
2084
3226
|
}
|
|
2085
3227
|
function maybeGetFile(filePath) {
|
|
2086
3228
|
try {
|
|
2087
|
-
return
|
|
3229
|
+
return readFileSync2(filePath, "utf8");
|
|
2088
3230
|
} catch (e) {
|
|
2089
3231
|
if (!thrownIsDoesNotExistError(e)) {
|
|
2090
3232
|
throw e;
|
|
@@ -2440,8 +3582,8 @@ function getErrorMap() {
|
|
|
2440
3582
|
return overrideErrorMap;
|
|
2441
3583
|
}
|
|
2442
3584
|
var makeIssue = (params) => {
|
|
2443
|
-
const { data: data2, path:
|
|
2444
|
-
const fullPath = [...
|
|
3585
|
+
const { data: data2, path: path14, errorMaps, issueData } = params;
|
|
3586
|
+
const fullPath = [...path14, ...issueData.path || []];
|
|
2445
3587
|
const fullIssue = {
|
|
2446
3588
|
...issueData,
|
|
2447
3589
|
path: fullPath
|
|
@@ -2540,11 +3682,11 @@ var errorUtil;
|
|
|
2540
3682
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
2541
3683
|
})(errorUtil || (errorUtil = {}));
|
|
2542
3684
|
var ParseInputLazyPath = class {
|
|
2543
|
-
constructor(parent, value,
|
|
3685
|
+
constructor(parent, value, path14, key) {
|
|
2544
3686
|
this._cachedPath = [];
|
|
2545
3687
|
this.parent = parent;
|
|
2546
3688
|
this.data = value;
|
|
2547
|
-
this._path =
|
|
3689
|
+
this._path = path14;
|
|
2548
3690
|
this._key = key;
|
|
2549
3691
|
}
|
|
2550
3692
|
get path() {
|
|
@@ -5940,22 +7082,22 @@ function getAssetsConfig(resolvedPluginConfig, entryWorkerConfig, resolvedConfig
|
|
|
5940
7082
|
};
|
|
5941
7083
|
}
|
|
5942
7084
|
function getRedirectsConfigPath(config) {
|
|
5943
|
-
return
|
|
7085
|
+
return path3.join(config.publicDir, REDIRECTS_FILENAME);
|
|
5944
7086
|
}
|
|
5945
7087
|
function getHeadersConfigPath(config) {
|
|
5946
|
-
return
|
|
7088
|
+
return path3.join(config.publicDir, HEADERS_FILENAME);
|
|
5947
7089
|
}
|
|
5948
7090
|
|
|
5949
7091
|
// src/build.ts
|
|
5950
7092
|
import assert from "node:assert";
|
|
5951
7093
|
import * as fs from "node:fs";
|
|
5952
|
-
import * as
|
|
7094
|
+
import * as path4 from "node:path";
|
|
5953
7095
|
import colors from "picocolors";
|
|
5954
7096
|
function createBuildApp(resolvedPluginConfig) {
|
|
5955
7097
|
return async (builder) => {
|
|
5956
7098
|
const clientEnvironment = builder.environments.client;
|
|
5957
7099
|
assert(clientEnvironment, `No "client" environment`);
|
|
5958
|
-
const defaultHtmlPath =
|
|
7100
|
+
const defaultHtmlPath = path4.resolve(builder.config.root, "index.html");
|
|
5959
7101
|
const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs.existsSync(defaultHtmlPath);
|
|
5960
7102
|
if (resolvedPluginConfig.type === "assets-only") {
|
|
5961
7103
|
if (hasClientEntry) {
|
|
@@ -5981,7 +7123,7 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
5981
7123
|
entryWorkerEnvironment,
|
|
5982
7124
|
`No "${entryWorkerEnvironmentName}" environment`
|
|
5983
7125
|
);
|
|
5984
|
-
const entryWorkerBuildDirectory =
|
|
7126
|
+
const entryWorkerBuildDirectory = path4.resolve(
|
|
5985
7127
|
builder.config.root,
|
|
5986
7128
|
entryWorkerEnvironment.config.build.outDir
|
|
5987
7129
|
);
|
|
@@ -5992,7 +7134,7 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
5992
7134
|
} else if (importedAssetPaths.size || getHasPublicAssets(builder.config)) {
|
|
5993
7135
|
await fallbackBuild(builder, clientEnvironment);
|
|
5994
7136
|
} else {
|
|
5995
|
-
const entryWorkerConfigPath =
|
|
7137
|
+
const entryWorkerConfigPath = path4.join(
|
|
5996
7138
|
entryWorkerBuildDirectory,
|
|
5997
7139
|
"wrangler.json"
|
|
5998
7140
|
);
|
|
@@ -6003,21 +7145,21 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
6003
7145
|
fs.writeFileSync(entryWorkerConfigPath, JSON.stringify(workerConfig));
|
|
6004
7146
|
return;
|
|
6005
7147
|
}
|
|
6006
|
-
const clientBuildDirectory =
|
|
7148
|
+
const clientBuildDirectory = path4.resolve(
|
|
6007
7149
|
builder.config.root,
|
|
6008
7150
|
clientEnvironment.config.build.outDir
|
|
6009
7151
|
);
|
|
6010
7152
|
const movedAssetPaths = [];
|
|
6011
7153
|
for (const assetPath of importedAssetPaths) {
|
|
6012
|
-
const src =
|
|
6013
|
-
const dest =
|
|
7154
|
+
const src = path4.join(entryWorkerBuildDirectory, assetPath);
|
|
7155
|
+
const dest = path4.join(clientBuildDirectory, assetPath);
|
|
6014
7156
|
if (!fs.existsSync(src)) {
|
|
6015
7157
|
continue;
|
|
6016
7158
|
}
|
|
6017
7159
|
if (fs.existsSync(dest)) {
|
|
6018
7160
|
fs.unlinkSync(src);
|
|
6019
7161
|
} else {
|
|
6020
|
-
const destDir =
|
|
7162
|
+
const destDir = path4.dirname(dest);
|
|
6021
7163
|
fs.mkdirSync(destDir, { recursive: true });
|
|
6022
7164
|
fs.renameSync(src, dest);
|
|
6023
7165
|
movedAssetPaths.push(dest);
|
|
@@ -6028,7 +7170,7 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
6028
7170
|
[
|
|
6029
7171
|
`${colors.green("\u2713")} ${movedAssetPaths.length} asset${movedAssetPaths.length > 1 ? "s" : ""} moved from "${entryWorkerEnvironmentName}" to "client" build output.`,
|
|
6030
7172
|
...movedAssetPaths.map(
|
|
6031
|
-
(assetPath) => colors.dim(
|
|
7173
|
+
(assetPath) => colors.dim(path4.relative(builder.config.root, assetPath))
|
|
6032
7174
|
)
|
|
6033
7175
|
].join("\n")
|
|
6034
7176
|
);
|
|
@@ -6058,7 +7200,7 @@ async function fallbackBuild(builder, environment) {
|
|
|
6058
7200
|
}
|
|
6059
7201
|
};
|
|
6060
7202
|
await builder.build(environment);
|
|
6061
|
-
const fallbackEntryPath =
|
|
7203
|
+
const fallbackEntryPath = path4.resolve(
|
|
6062
7204
|
builder.config.root,
|
|
6063
7205
|
environment.config.build.outDir,
|
|
6064
7206
|
fallbackEntryName
|
|
@@ -6067,7 +7209,7 @@ async function fallbackBuild(builder, environment) {
|
|
|
6067
7209
|
}
|
|
6068
7210
|
function loadViteManifest(directory) {
|
|
6069
7211
|
const contents = fs.readFileSync(
|
|
6070
|
-
|
|
7212
|
+
path4.resolve(directory, ".vite", "manifest.json"),
|
|
6071
7213
|
"utf-8"
|
|
6072
7214
|
);
|
|
6073
7215
|
return JSON.parse(contents);
|
|
@@ -6086,7 +7228,7 @@ import * as vite2 from "vite";
|
|
|
6086
7228
|
// src/node-js-compat.ts
|
|
6087
7229
|
import assert3 from "node:assert";
|
|
6088
7230
|
import { builtinModules as builtinModules2 } from "node:module";
|
|
6089
|
-
import
|
|
7231
|
+
import path6 from "node:path";
|
|
6090
7232
|
import { cloudflare } from "@cloudflare/unenv-preset";
|
|
6091
7233
|
import { getNodeCompat } from "miniflare";
|
|
6092
7234
|
|
|
@@ -11619,7 +12761,7 @@ Parser.acorn = {
|
|
|
11619
12761
|
|
|
11620
12762
|
// ../../node_modules/.pnpm/mlly@1.7.4/node_modules/mlly/dist/index.mjs
|
|
11621
12763
|
import { builtinModules, createRequire } from "node:module";
|
|
11622
|
-
import fs2, { realpathSync, statSync, promises } from "node:fs";
|
|
12764
|
+
import fs2, { realpathSync, statSync as statSync2, promises } from "node:fs";
|
|
11623
12765
|
|
|
11624
12766
|
// ../../node_modules/.pnpm/ufo@1.5.4/node_modules/ufo/dist/index.mjs
|
|
11625
12767
|
var r = String.fromCharCode;
|
|
@@ -11638,17 +12780,17 @@ function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
|
11638
12780
|
if (hasTrailingSlash(input, true)) {
|
|
11639
12781
|
return input || "/";
|
|
11640
12782
|
}
|
|
11641
|
-
let
|
|
12783
|
+
let path14 = input;
|
|
11642
12784
|
let fragment = "";
|
|
11643
12785
|
const fragmentIndex = input.indexOf("#");
|
|
11644
12786
|
if (fragmentIndex >= 0) {
|
|
11645
|
-
|
|
12787
|
+
path14 = input.slice(0, fragmentIndex);
|
|
11646
12788
|
fragment = input.slice(fragmentIndex);
|
|
11647
|
-
if (!
|
|
12789
|
+
if (!path14) {
|
|
11648
12790
|
return fragment;
|
|
11649
12791
|
}
|
|
11650
12792
|
}
|
|
11651
|
-
const [s0, ...s] =
|
|
12793
|
+
const [s0, ...s] = path14.split("?");
|
|
11652
12794
|
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
11653
12795
|
}
|
|
11654
12796
|
function isNonEmptyURL(url) {
|
|
@@ -11678,12 +12820,12 @@ var isAbsolute = function(p) {
|
|
|
11678
12820
|
import { fileURLToPath as fileURLToPath$1, URL as URL$1, pathToFileURL as pathToFileURL$1 } from "node:url";
|
|
11679
12821
|
import assert2 from "node:assert";
|
|
11680
12822
|
import process$1 from "node:process";
|
|
11681
|
-
import
|
|
12823
|
+
import path5, { dirname as dirname3 } from "node:path";
|
|
11682
12824
|
import v8 from "node:v8";
|
|
11683
12825
|
import { format as format2, inspect } from "node:util";
|
|
11684
12826
|
var BUILTIN_MODULES = new Set(builtinModules);
|
|
11685
|
-
function normalizeSlash(
|
|
11686
|
-
return
|
|
12827
|
+
function normalizeSlash(path14) {
|
|
12828
|
+
return path14.replace(/\\/g, "/");
|
|
11687
12829
|
}
|
|
11688
12830
|
var own$1 = {}.hasOwnProperty;
|
|
11689
12831
|
var classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
@@ -11784,8 +12926,8 @@ codes.ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
|
11784
12926
|
* @param {string} reason
|
|
11785
12927
|
* @param {string} [base]
|
|
11786
12928
|
*/
|
|
11787
|
-
(
|
|
11788
|
-
return `Invalid module "${
|
|
12929
|
+
(request2, reason, base = void 0) => {
|
|
12930
|
+
return `Invalid module "${request2}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
11789
12931
|
},
|
|
11790
12932
|
TypeError
|
|
11791
12933
|
);
|
|
@@ -11796,8 +12938,8 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
|
11796
12938
|
* @param {string} [base]
|
|
11797
12939
|
* @param {string} [message]
|
|
11798
12940
|
*/
|
|
11799
|
-
(
|
|
11800
|
-
return `Invalid package config ${
|
|
12941
|
+
(path14, base, message) => {
|
|
12942
|
+
return `Invalid package config ${path14}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
11801
12943
|
},
|
|
11802
12944
|
Error
|
|
11803
12945
|
);
|
|
@@ -11829,8 +12971,8 @@ codes.ERR_MODULE_NOT_FOUND = createError(
|
|
|
11829
12971
|
* @param {string} base
|
|
11830
12972
|
* @param {boolean} [exactUrl]
|
|
11831
12973
|
*/
|
|
11832
|
-
(
|
|
11833
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${
|
|
12974
|
+
(path14, base, exactUrl = false) => {
|
|
12975
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path14}' imported from ${base}`;
|
|
11834
12976
|
},
|
|
11835
12977
|
Error
|
|
11836
12978
|
);
|
|
@@ -11881,8 +13023,8 @@ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
|
11881
13023
|
* @param {string} extension
|
|
11882
13024
|
* @param {string} path
|
|
11883
13025
|
*/
|
|
11884
|
-
(extension,
|
|
11885
|
-
return `Unknown file extension "${extension}" for ${
|
|
13026
|
+
(extension, path14) => {
|
|
13027
|
+
return `Unknown file extension "${extension}" for ${path14}`;
|
|
11886
13028
|
},
|
|
11887
13029
|
TypeError
|
|
11888
13030
|
);
|
|
@@ -12027,7 +13169,7 @@ function read(jsonPath, { base, specifier }) {
|
|
|
12027
13169
|
}
|
|
12028
13170
|
let string;
|
|
12029
13171
|
try {
|
|
12030
|
-
string = fs2.readFileSync(
|
|
13172
|
+
string = fs2.readFileSync(path5.toNamespacedPath(jsonPath), "utf8");
|
|
12031
13173
|
} catch (error) {
|
|
12032
13174
|
const exception = (
|
|
12033
13175
|
/** @type {ErrnoException} */
|
|
@@ -12213,14 +13355,14 @@ var patternRegEx = /\*/g;
|
|
|
12213
13355
|
var encodedSeparatorRegEx = /%2f|%5c/i;
|
|
12214
13356
|
var emittedPackageWarnings = /* @__PURE__ */ new Set();
|
|
12215
13357
|
var doubleSlashRegEx = /[/\\]{2}/;
|
|
12216
|
-
function emitInvalidSegmentDeprecation(target2,
|
|
13358
|
+
function emitInvalidSegmentDeprecation(target2, request2, match, packageJsonUrl, internal, base, isTarget) {
|
|
12217
13359
|
if (process$1.noDeprecation) {
|
|
12218
13360
|
return;
|
|
12219
13361
|
}
|
|
12220
13362
|
const pjsonPath = fileURLToPath$1(packageJsonUrl);
|
|
12221
|
-
const double = doubleSlashRegEx.exec(isTarget ? target2 :
|
|
13363
|
+
const double = doubleSlashRegEx.exec(isTarget ? target2 : request2) !== null;
|
|
12222
13364
|
process$1.emitWarning(
|
|
12223
|
-
`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target2}" for module request "${
|
|
13365
|
+
`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target2}" for module request "${request2}" ${request2 === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath$1(base)}` : ""}.`,
|
|
12224
13366
|
"DeprecationWarning",
|
|
12225
13367
|
"DEP0166"
|
|
12226
13368
|
);
|
|
@@ -12243,7 +13385,7 @@ Default "index" lookups for the main are deprecated for ES modules.`,
|
|
|
12243
13385
|
"DeprecationWarning",
|
|
12244
13386
|
"DEP0151"
|
|
12245
13387
|
);
|
|
12246
|
-
} else if (
|
|
13388
|
+
} else if (path5.resolve(packagePath, main) !== urlPath) {
|
|
12247
13389
|
process$1.emitWarning(
|
|
12248
13390
|
`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(
|
|
12249
13391
|
packagePath.length
|
|
@@ -12254,14 +13396,14 @@ Default "index" lookups for the main are deprecated for ES modules.`,
|
|
|
12254
13396
|
);
|
|
12255
13397
|
}
|
|
12256
13398
|
}
|
|
12257
|
-
function tryStatSync(
|
|
13399
|
+
function tryStatSync(path14) {
|
|
12258
13400
|
try {
|
|
12259
|
-
return
|
|
13401
|
+
return statSync2(path14);
|
|
12260
13402
|
} catch {
|
|
12261
13403
|
}
|
|
12262
13404
|
}
|
|
12263
13405
|
function fileExists(url) {
|
|
12264
|
-
const stats =
|
|
13406
|
+
const stats = statSync2(url, { throwIfNoEntry: false });
|
|
12265
13407
|
const isFile = stats ? stats.isFile() : void 0;
|
|
12266
13408
|
return isFile === null || isFile === void 0 ? false : isFile;
|
|
12267
13409
|
}
|
|
@@ -12350,7 +13492,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
|
12350
13492
|
{
|
|
12351
13493
|
const real = realpathSync(filePath);
|
|
12352
13494
|
const { search, hash } = resolved;
|
|
12353
|
-
resolved = pathToFileURL$1(real + (filePath.endsWith(
|
|
13495
|
+
resolved = pathToFileURL$1(real + (filePath.endsWith(path5.sep) ? "/" : ""));
|
|
12354
13496
|
resolved.search = search;
|
|
12355
13497
|
resolved.hash = hash;
|
|
12356
13498
|
}
|
|
@@ -12370,10 +13512,10 @@ function exportsNotFound(subpath, packageJsonUrl, base) {
|
|
|
12370
13512
|
base && fileURLToPath$1(base)
|
|
12371
13513
|
);
|
|
12372
13514
|
}
|
|
12373
|
-
function throwInvalidSubpath(
|
|
13515
|
+
function throwInvalidSubpath(request2, match, packageJsonUrl, internal, base) {
|
|
12374
13516
|
const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath$1(packageJsonUrl)}`;
|
|
12375
13517
|
throw new ERR_INVALID_MODULE_SPECIFIER(
|
|
12376
|
-
|
|
13518
|
+
request2,
|
|
12377
13519
|
reason,
|
|
12378
13520
|
base && fileURLToPath$1(base)
|
|
12379
13521
|
);
|
|
@@ -12413,7 +13555,7 @@ function resolvePackageTargetString(target2, subpath, match, packageJsonUrl, bas
|
|
|
12413
13555
|
if (invalidSegmentRegEx.exec(target2.slice(2)) !== null) {
|
|
12414
13556
|
if (deprecatedInvalidSegmentRegEx.exec(target2.slice(2)) === null) {
|
|
12415
13557
|
if (!isPathMap) {
|
|
12416
|
-
const
|
|
13558
|
+
const request2 = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
12417
13559
|
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
12418
13560
|
patternRegEx,
|
|
12419
13561
|
target2,
|
|
@@ -12421,7 +13563,7 @@ function resolvePackageTargetString(target2, subpath, match, packageJsonUrl, bas
|
|
|
12421
13563
|
) : target2;
|
|
12422
13564
|
emitInvalidSegmentDeprecation(
|
|
12423
13565
|
resolvedTarget,
|
|
12424
|
-
|
|
13566
|
+
request2,
|
|
12425
13567
|
match,
|
|
12426
13568
|
packageJsonUrl,
|
|
12427
13569
|
internal,
|
|
@@ -12440,7 +13582,7 @@ function resolvePackageTargetString(target2, subpath, match, packageJsonUrl, bas
|
|
|
12440
13582
|
throw invalidPackageTarget(match, target2, packageJsonUrl, internal, base);
|
|
12441
13583
|
if (subpath === "") return resolved;
|
|
12442
13584
|
if (invalidSegmentRegEx.exec(subpath) !== null) {
|
|
12443
|
-
const
|
|
13585
|
+
const request2 = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
12444
13586
|
if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
|
|
12445
13587
|
if (!isPathMap) {
|
|
12446
13588
|
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(
|
|
@@ -12450,7 +13592,7 @@ function resolvePackageTargetString(target2, subpath, match, packageJsonUrl, bas
|
|
|
12450
13592
|
) : target2;
|
|
12451
13593
|
emitInvalidSegmentDeprecation(
|
|
12452
13594
|
resolvedTarget,
|
|
12453
|
-
|
|
13595
|
+
request2,
|
|
12454
13596
|
match,
|
|
12455
13597
|
packageJsonUrl,
|
|
12456
13598
|
internal,
|
|
@@ -12459,7 +13601,7 @@ function resolvePackageTargetString(target2, subpath, match, packageJsonUrl, bas
|
|
|
12459
13601
|
);
|
|
12460
13602
|
}
|
|
12461
13603
|
} else {
|
|
12462
|
-
throwInvalidSubpath(
|
|
13604
|
+
throwInvalidSubpath(request2, match, packageJsonUrl, internal, base);
|
|
12463
13605
|
}
|
|
12464
13606
|
}
|
|
12465
13607
|
if (pattern) {
|
|
@@ -12953,7 +14095,7 @@ function _resolve(id, options = {}) {
|
|
|
12953
14095
|
}
|
|
12954
14096
|
if (isAbsolute(id)) {
|
|
12955
14097
|
try {
|
|
12956
|
-
const stat2 =
|
|
14098
|
+
const stat2 = statSync2(id);
|
|
12957
14099
|
if (stat2.isFile()) {
|
|
12958
14100
|
return pathToFileURL(id);
|
|
12959
14101
|
}
|
|
@@ -13061,8 +14203,8 @@ function isNodeAls(workerConfig) {
|
|
|
13061
14203
|
workerConfig.compatibility_flags ?? []
|
|
13062
14204
|
).mode === "als";
|
|
13063
14205
|
}
|
|
13064
|
-
function isNodeAlsModule(
|
|
13065
|
-
return /^(node:)?async_hooks$/.test(
|
|
14206
|
+
function isNodeAlsModule(path14) {
|
|
14207
|
+
return /^(node:)?async_hooks$/.test(path14);
|
|
13066
14208
|
}
|
|
13067
14209
|
var injectsByModule = /* @__PURE__ */ new Map();
|
|
13068
14210
|
var virtualModulePathToSpecifier = /* @__PURE__ */ new Map();
|
|
@@ -13169,7 +14311,7 @@ var NodeJsCompatWarnings = class {
|
|
|
13169
14311
|
`;
|
|
13170
14312
|
this.sources.forEach((importers, source) => {
|
|
13171
14313
|
importers.forEach((importer) => {
|
|
13172
|
-
message += ` - "${source}" imported from "${
|
|
14314
|
+
message += ` - "${source}" imported from "${path6.relative(this.resolvedViteConfig.root, importer)}"
|
|
13173
14315
|
`;
|
|
13174
14316
|
});
|
|
13175
14317
|
});
|
|
@@ -13193,7 +14335,7 @@ var additionalModuleGlobalRE = new RegExp(
|
|
|
13193
14335
|
var VITE_DEV_METADATA_HEADER = "__VITE_DEV_METADATA__";
|
|
13194
14336
|
|
|
13195
14337
|
// src/utils.ts
|
|
13196
|
-
import * as
|
|
14338
|
+
import * as path7 from "node:path";
|
|
13197
14339
|
import { createRequest, sendResponse } from "@mjackson/node-fetch-server";
|
|
13198
14340
|
import {
|
|
13199
14341
|
Request as MiniflareRequest,
|
|
@@ -13201,20 +14343,20 @@ import {
|
|
|
13201
14343
|
} from "miniflare";
|
|
13202
14344
|
function getOutputDirectory(userConfig, environmentName) {
|
|
13203
14345
|
const rootOutputDirectory = userConfig.build?.outDir ?? "dist";
|
|
13204
|
-
return userConfig.environments?.[environmentName]?.build?.outDir ??
|
|
14346
|
+
return userConfig.environments?.[environmentName]?.build?.outDir ?? path7.join(rootOutputDirectory, environmentName);
|
|
13205
14347
|
}
|
|
13206
14348
|
var postfixRE = /[?#].*$/;
|
|
13207
14349
|
function cleanUrl(url) {
|
|
13208
14350
|
return url.replace(postfixRE, "");
|
|
13209
14351
|
}
|
|
13210
|
-
function withTrailingSlash2(
|
|
13211
|
-
return
|
|
14352
|
+
function withTrailingSlash2(path14) {
|
|
14353
|
+
return path14.endsWith("/") ? path14 : `${path14}/`;
|
|
13212
14354
|
}
|
|
13213
14355
|
function createRequestHandler(handler) {
|
|
13214
14356
|
return async (req, res, next) => {
|
|
13215
14357
|
try {
|
|
13216
|
-
const
|
|
13217
|
-
let response = await handler(toMiniflareRequest(
|
|
14358
|
+
const request2 = createRequest(req, res);
|
|
14359
|
+
let response = await handler(toMiniflareRequest(request2), req);
|
|
13218
14360
|
if (req.httpVersionMajor === 2) {
|
|
13219
14361
|
response = new MiniflareResponse(response.body, response);
|
|
13220
14362
|
response.headers.delete("transfer-encoding");
|
|
@@ -13225,19 +14367,19 @@ function createRequestHandler(handler) {
|
|
|
13225
14367
|
}
|
|
13226
14368
|
};
|
|
13227
14369
|
}
|
|
13228
|
-
function toMiniflareRequest(
|
|
13229
|
-
const host =
|
|
14370
|
+
function toMiniflareRequest(request2) {
|
|
14371
|
+
const host = request2.headers.get("Host");
|
|
13230
14372
|
if (host) {
|
|
13231
|
-
|
|
14373
|
+
request2.headers.set("X-Forwarded-Host", host);
|
|
13232
14374
|
}
|
|
13233
|
-
const secFetchMode =
|
|
14375
|
+
const secFetchMode = request2.headers.get("Sec-Fetch-Mode");
|
|
13234
14376
|
if (secFetchMode) {
|
|
13235
|
-
|
|
14377
|
+
request2.headers.set("X-Mf-Sec-Fetch-Mode", secFetchMode);
|
|
13236
14378
|
}
|
|
13237
|
-
return new MiniflareRequest(
|
|
13238
|
-
method:
|
|
13239
|
-
headers: [["accept-encoding", "identity"], ...
|
|
13240
|
-
body:
|
|
14379
|
+
return new MiniflareRequest(request2.url, {
|
|
14380
|
+
method: request2.method,
|
|
14381
|
+
headers: [["accept-encoding", "identity"], ...request2.headers],
|
|
14382
|
+
body: request2.body,
|
|
13241
14383
|
duplex: "half"
|
|
13242
14384
|
});
|
|
13243
14385
|
}
|
|
@@ -13355,7 +14497,9 @@ function createCloudflareEnvironmentOptions(workerConfig, userConfig, environmen
|
|
|
13355
14497
|
copyPublicDir: false,
|
|
13356
14498
|
ssr: true,
|
|
13357
14499
|
rollupOptions: {
|
|
13358
|
-
input: workerConfig.main
|
|
14500
|
+
input: workerConfig.main,
|
|
14501
|
+
// rolldown-only option
|
|
14502
|
+
..."rolldownVersion" in vite2 ? { platform: "neutral" } : {}
|
|
13359
14503
|
}
|
|
13360
14504
|
},
|
|
13361
14505
|
optimizeDeps: {
|
|
@@ -13397,6 +14541,27 @@ function initRunners(resolvedPluginConfig, viteDevServer, miniflare2) {
|
|
|
13397
14541
|
);
|
|
13398
14542
|
}
|
|
13399
14543
|
|
|
14544
|
+
// src/containers.ts
|
|
14545
|
+
function getDockerPath() {
|
|
14546
|
+
const defaultDockerPath = "docker";
|
|
14547
|
+
const dockerPathEnvVar = "WRANGLER_DOCKER_BIN";
|
|
14548
|
+
return process.env[dockerPathEnvVar] || defaultDockerPath;
|
|
14549
|
+
}
|
|
14550
|
+
async function removeContainersByIds(dockerPath, containerIds) {
|
|
14551
|
+
try {
|
|
14552
|
+
if (containerIds.length === 0) {
|
|
14553
|
+
return;
|
|
14554
|
+
}
|
|
14555
|
+
await runDockerCmd(
|
|
14556
|
+
dockerPath,
|
|
14557
|
+
["rm", "--force", ...containerIds],
|
|
14558
|
+
["inherit", "pipe", "pipe"]
|
|
14559
|
+
);
|
|
14560
|
+
} catch (error) {
|
|
14561
|
+
return;
|
|
14562
|
+
}
|
|
14563
|
+
}
|
|
14564
|
+
|
|
13400
14565
|
// src/debugging.ts
|
|
13401
14566
|
import assert5 from "node:assert";
|
|
13402
14567
|
import getPort, { portNumbers } from "get-port";
|
|
@@ -13480,11 +14645,11 @@ function getDebugPathHtml(workerNames, inspectorPort) {
|
|
|
13480
14645
|
// src/deploy-config.ts
|
|
13481
14646
|
import assert6 from "node:assert";
|
|
13482
14647
|
import * as fs3 from "node:fs";
|
|
13483
|
-
import * as
|
|
14648
|
+
import * as path8 from "node:path";
|
|
13484
14649
|
import "vite";
|
|
13485
14650
|
import { unstable_readConfig } from "wrangler";
|
|
13486
14651
|
function getDeployConfigPath(root) {
|
|
13487
|
-
return
|
|
14652
|
+
return path8.resolve(root, ".wrangler", "deploy", "config.json");
|
|
13488
14653
|
}
|
|
13489
14654
|
function getWorkerConfigs(root) {
|
|
13490
14655
|
const deployConfigPath = getDeployConfigPath(root);
|
|
@@ -13495,22 +14660,22 @@ function getWorkerConfigs(root) {
|
|
|
13495
14660
|
{ configPath: deployConfig.configPath },
|
|
13496
14661
|
...deployConfig.auxiliaryWorkers
|
|
13497
14662
|
].map(({ configPath }) => {
|
|
13498
|
-
const resolvedConfigPath =
|
|
13499
|
-
|
|
14663
|
+
const resolvedConfigPath = path8.resolve(
|
|
14664
|
+
path8.dirname(deployConfigPath),
|
|
13500
14665
|
configPath
|
|
13501
14666
|
);
|
|
13502
14667
|
return unstable_readConfig({ config: resolvedConfigPath });
|
|
13503
14668
|
});
|
|
13504
14669
|
}
|
|
13505
14670
|
function getRelativePathToWorkerConfig(deployConfigDirectory, root, outputDirectory) {
|
|
13506
|
-
return
|
|
14671
|
+
return path8.relative(
|
|
13507
14672
|
deployConfigDirectory,
|
|
13508
|
-
|
|
14673
|
+
path8.resolve(root, outputDirectory, "wrangler.json")
|
|
13509
14674
|
);
|
|
13510
14675
|
}
|
|
13511
14676
|
function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
|
|
13512
14677
|
const deployConfigPath = getDeployConfigPath(resolvedViteConfig.root);
|
|
13513
|
-
const deployConfigDirectory =
|
|
14678
|
+
const deployConfigDirectory = path8.dirname(deployConfigPath);
|
|
13514
14679
|
fs3.mkdirSync(deployConfigDirectory, { recursive: true });
|
|
13515
14680
|
if (resolvedPluginConfig.type === "assets-only") {
|
|
13516
14681
|
const clientOutputDirectory = resolvedViteConfig.environments.client?.build.outDir;
|
|
@@ -13561,9 +14726,9 @@ function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
|
|
|
13561
14726
|
|
|
13562
14727
|
// src/dev-vars.ts
|
|
13563
14728
|
import * as fs4 from "node:fs";
|
|
13564
|
-
import * as
|
|
14729
|
+
import * as path9 from "node:path";
|
|
13565
14730
|
function getDotDevDotVarsContent(configPath, cloudflareEnv) {
|
|
13566
|
-
const configDir =
|
|
14731
|
+
const configDir = path9.dirname(configPath);
|
|
13567
14732
|
const defaultDotDevDotVarsPath = `${configDir}/.dev.vars`;
|
|
13568
14733
|
const inputDotDevDotVarsPath = `${defaultDotDevDotVarsPath}${cloudflareEnv ? `.${cloudflareEnv}` : ""}`;
|
|
13569
14734
|
const targetPath = fs4.existsSync(inputDotDevDotVarsPath) ? inputDotDevDotVarsPath : fs4.existsSync(defaultDotDevDotVarsPath) ? defaultDotDevDotVarsPath : null;
|
|
@@ -13575,7 +14740,7 @@ function getDotDevDotVarsContent(configPath, cloudflareEnv) {
|
|
|
13575
14740
|
}
|
|
13576
14741
|
function hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) {
|
|
13577
14742
|
return [...resolvedPluginConfig.configPaths].some((configPath) => {
|
|
13578
|
-
const dotDevDotVars =
|
|
14743
|
+
const dotDevDotVars = path9.join(path9.dirname(configPath), ".dev.vars");
|
|
13579
14744
|
if (dotDevDotVars === changedFilePath) {
|
|
13580
14745
|
return true;
|
|
13581
14746
|
}
|
|
@@ -13591,7 +14756,7 @@ function hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) {
|
|
|
13591
14756
|
import assert7 from "node:assert";
|
|
13592
14757
|
import * as fs5 from "node:fs";
|
|
13593
14758
|
import * as fsp from "node:fs/promises";
|
|
13594
|
-
import * as
|
|
14759
|
+
import * as path10 from "node:path";
|
|
13595
14760
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
13596
14761
|
import {
|
|
13597
14762
|
getDefaultDevRegistryPath,
|
|
@@ -13613,7 +14778,7 @@ function getPersistenceRoot(root, persistState) {
|
|
|
13613
14778
|
return;
|
|
13614
14779
|
}
|
|
13615
14780
|
const defaultPersistPath = ".wrangler/state";
|
|
13616
|
-
const persistPath =
|
|
14781
|
+
const persistPath = path10.resolve(
|
|
13617
14782
|
root,
|
|
13618
14783
|
typeof persistState === "object" ? persistState.path : defaultPersistPath,
|
|
13619
14784
|
"v3"
|
|
@@ -13726,7 +14891,13 @@ function logUnknownTails(tails, userWorkers, log) {
|
|
|
13726
14891
|
}
|
|
13727
14892
|
}
|
|
13728
14893
|
var remoteProxySessionsDataMap = /* @__PURE__ */ new Map();
|
|
13729
|
-
async function getDevMiniflareOptions(
|
|
14894
|
+
async function getDevMiniflareOptions(config) {
|
|
14895
|
+
const {
|
|
14896
|
+
resolvedPluginConfig,
|
|
14897
|
+
viteDevServer,
|
|
14898
|
+
inspectorPort,
|
|
14899
|
+
containerBuildId
|
|
14900
|
+
} = config;
|
|
13730
14901
|
const resolvedViteConfig = viteDevServer.config;
|
|
13731
14902
|
const entryWorkerConfig = getEntryWorkerConfig(resolvedPluginConfig);
|
|
13732
14903
|
const assetsConfig = getAssetsConfig(
|
|
@@ -13742,7 +14913,7 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
13742
14913
|
modules: [
|
|
13743
14914
|
{
|
|
13744
14915
|
type: "ESModule",
|
|
13745
|
-
path:
|
|
14916
|
+
path: path10.join(miniflareModulesRoot, ROUTER_WORKER_PATH),
|
|
13746
14917
|
contents: fs5.readFileSync(
|
|
13747
14918
|
fileURLToPath2(new URL(ROUTER_WORKER_PATH, import.meta.url))
|
|
13748
14919
|
)
|
|
@@ -13765,7 +14936,7 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
13765
14936
|
modules: [
|
|
13766
14937
|
{
|
|
13767
14938
|
type: "ESModule",
|
|
13768
|
-
path:
|
|
14939
|
+
path: path10.join(miniflareModulesRoot, ASSET_WORKER_PATH),
|
|
13769
14940
|
contents: fs5.readFileSync(
|
|
13770
14941
|
fileURLToPath2(new URL(ASSET_WORKER_PATH, import.meta.url))
|
|
13771
14942
|
)
|
|
@@ -13775,8 +14946,8 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
13775
14946
|
CONFIG: assetsConfig
|
|
13776
14947
|
},
|
|
13777
14948
|
serviceBindings: {
|
|
13778
|
-
__VITE_HTML_EXISTS__: async (
|
|
13779
|
-
const { pathname } = new URL(
|
|
14949
|
+
__VITE_HTML_EXISTS__: async (request2) => {
|
|
14950
|
+
const { pathname } = new URL(request2.url);
|
|
13780
14951
|
if (pathname.endsWith(".html")) {
|
|
13781
14952
|
const { root, publicDir } = resolvedViteConfig;
|
|
13782
14953
|
const publicDirInRoot = publicDir.startsWith(
|
|
@@ -13786,8 +14957,8 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
13786
14957
|
if (publicDirInRoot && pathname.startsWith(publicPath)) {
|
|
13787
14958
|
return MiniflareResponse2.json(null);
|
|
13788
14959
|
}
|
|
13789
|
-
const publicDirFilePath =
|
|
13790
|
-
const rootDirFilePath =
|
|
14960
|
+
const publicDirFilePath = path10.join(publicDir, pathname);
|
|
14961
|
+
const rootDirFilePath = path10.join(root, pathname);
|
|
13791
14962
|
for (const resolvedPath of [publicDirFilePath, rootDirFilePath]) {
|
|
13792
14963
|
try {
|
|
13793
14964
|
const stats = await fsp.stat(resolvedPath);
|
|
@@ -13802,11 +14973,11 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
13802
14973
|
}
|
|
13803
14974
|
return MiniflareResponse2.json(null);
|
|
13804
14975
|
},
|
|
13805
|
-
__VITE_FETCH_HTML__: async (
|
|
13806
|
-
const { pathname } = new URL(
|
|
14976
|
+
__VITE_FETCH_HTML__: async (request2) => {
|
|
14977
|
+
const { pathname } = new URL(request2.url);
|
|
13807
14978
|
const { root, publicDir } = resolvedViteConfig;
|
|
13808
14979
|
const isInPublicDir = pathname.startsWith(PUBLIC_DIR_PREFIX);
|
|
13809
|
-
const resolvedPath = isInPublicDir ?
|
|
14980
|
+
const resolvedPath = isInPublicDir ? path10.join(publicDir, pathname.slice(PUBLIC_DIR_PREFIX.length)) : path10.join(root, pathname);
|
|
13810
14981
|
try {
|
|
13811
14982
|
let html = await fsp.readFile(resolvedPath, "utf-8");
|
|
13812
14983
|
if (!isInPublicDir) {
|
|
@@ -13850,7 +15021,8 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
13850
15021
|
resolvedPluginConfig.cloudflareEnv,
|
|
13851
15022
|
{
|
|
13852
15023
|
remoteProxyConnectionString: remoteProxySessionData?.session?.remoteProxyConnectionString,
|
|
13853
|
-
remoteBindingsEnabled: resolvedPluginConfig.experimental.remoteBindings
|
|
15024
|
+
remoteBindingsEnabled: resolvedPluginConfig.experimental.remoteBindings,
|
|
15025
|
+
containerBuildId
|
|
13854
15026
|
}
|
|
13855
15027
|
);
|
|
13856
15028
|
const { externalWorkers: externalWorkers2 } = miniflareWorkerOptions;
|
|
@@ -13877,8 +15049,8 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
13877
15049
|
}
|
|
13878
15050
|
}
|
|
13879
15051
|
} : {},
|
|
13880
|
-
__VITE_INVOKE_MODULE__: async (
|
|
13881
|
-
const payload = await
|
|
15052
|
+
__VITE_INVOKE_MODULE__: async (request2) => {
|
|
15053
|
+
const payload = await request2.json();
|
|
13882
15054
|
const invokePayloadData = payload.data;
|
|
13883
15055
|
assert7(
|
|
13884
15056
|
invokePayloadData.name === "fetchModule",
|
|
@@ -13979,12 +15151,12 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
13979
15151
|
modules: [
|
|
13980
15152
|
{
|
|
13981
15153
|
type: "ESModule",
|
|
13982
|
-
path:
|
|
15154
|
+
path: path10.join(miniflareModulesRoot, WRAPPER_PATH),
|
|
13983
15155
|
contents: wrappers.join("\n")
|
|
13984
15156
|
},
|
|
13985
15157
|
{
|
|
13986
15158
|
type: "ESModule",
|
|
13987
|
-
path:
|
|
15159
|
+
path: path10.join(miniflareModulesRoot, RUNNER_PATH),
|
|
13988
15160
|
contents: fs5.readFileSync(
|
|
13989
15161
|
fileURLToPath2(new URL(RUNNER_PATH, import.meta.url))
|
|
13990
15162
|
)
|
|
@@ -13994,8 +15166,8 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
13994
15166
|
};
|
|
13995
15167
|
})
|
|
13996
15168
|
],
|
|
13997
|
-
async unsafeModuleFallbackService(
|
|
13998
|
-
const url = new URL(
|
|
15169
|
+
async unsafeModuleFallbackService(request2) {
|
|
15170
|
+
const url = new URL(request2.url);
|
|
13999
15171
|
const rawSpecifier = url.searchParams.get("rawSpecifier");
|
|
14000
15172
|
assert7(
|
|
14001
15173
|
rawSpecifier,
|
|
@@ -14039,8 +15211,8 @@ async function getDevMiniflareOptions(resolvedPluginConfig, viteDevServer, inspe
|
|
|
14039
15211
|
}
|
|
14040
15212
|
function getPreviewModules(main, modulesRules) {
|
|
14041
15213
|
assert7(modulesRules, `Unexpected error: 'modulesRules' is undefined`);
|
|
14042
|
-
const rootPath =
|
|
14043
|
-
const entryPath =
|
|
15214
|
+
const rootPath = path10.dirname(main);
|
|
15215
|
+
const entryPath = path10.basename(main);
|
|
14044
15216
|
return {
|
|
14045
15217
|
rootPath,
|
|
14046
15218
|
modules: [
|
|
@@ -14049,9 +15221,9 @@ function getPreviewModules(main, modulesRules) {
|
|
|
14049
15221
|
path: entryPath
|
|
14050
15222
|
},
|
|
14051
15223
|
...modulesRules.flatMap(
|
|
14052
|
-
({ type, include }) => globSync(include, { cwd: rootPath, ignore: entryPath }).map((
|
|
15224
|
+
({ type, include }) => globSync(include, { cwd: rootPath, ignore: entryPath }).map((path14) => ({
|
|
14053
15225
|
type,
|
|
14054
|
-
path:
|
|
15226
|
+
path: path14
|
|
14055
15227
|
}))
|
|
14056
15228
|
)
|
|
14057
15229
|
]
|
|
@@ -14161,7 +15333,7 @@ function miniflareLogLevelFromViteLogLevel(level = "info") {
|
|
|
14161
15333
|
|
|
14162
15334
|
// src/plugin-config.ts
|
|
14163
15335
|
import assert9 from "node:assert";
|
|
14164
|
-
import * as
|
|
15336
|
+
import * as path12 from "node:path";
|
|
14165
15337
|
|
|
14166
15338
|
// ../workers-shared/utils/configuration/parseStaticRouting.ts
|
|
14167
15339
|
function parseStaticRouting(input) {
|
|
@@ -14245,7 +15417,7 @@ import * as vite5 from "vite";
|
|
|
14245
15417
|
// src/workers-configs.ts
|
|
14246
15418
|
import assert8 from "node:assert";
|
|
14247
15419
|
import * as fs6 from "node:fs";
|
|
14248
|
-
import * as
|
|
15420
|
+
import * as path11 from "node:path";
|
|
14249
15421
|
import { unstable_readConfig as unstable_readConfig2 } from "wrangler";
|
|
14250
15422
|
var nonApplicableWorkerConfigs = {
|
|
14251
15423
|
/**
|
|
@@ -14337,7 +15509,7 @@ function getWarningForWorkersConfigs(configs) {
|
|
|
14337
15509
|
const lines2 = [
|
|
14338
15510
|
`
|
|
14339
15511
|
|
|
14340
|
-
\x1B[43mWARNING\x1B[0m: your worker config${configs.entryWorker.config.configPath ? ` (at \`${
|
|
15512
|
+
\x1B[43mWARNING\x1B[0m: your worker config${configs.entryWorker.config.configPath ? ` (at \`${path11.relative("", configs.entryWorker.config.configPath)}\`)` : ""} contains the following configuration options which are ignored since they are not applicable when using Vite:`
|
|
14341
15513
|
];
|
|
14342
15514
|
nonApplicableLines.forEach((line) => lines2.push(line));
|
|
14343
15515
|
lines2.push("");
|
|
@@ -14351,7 +15523,7 @@ function getWarningForWorkersConfigs(configs) {
|
|
|
14351
15523
|
);
|
|
14352
15524
|
if (nonApplicableLines.length > 0) {
|
|
14353
15525
|
lines.push(
|
|
14354
|
-
` - (${isEntryWorker ? "entry" : "auxiliary"}) worker${workerConfig.config.name ? ` "${workerConfig.config.name}"` : ""}${workerConfig.config.configPath ? ` (config at \`${
|
|
15526
|
+
` - (${isEntryWorker ? "entry" : "auxiliary"}) worker${workerConfig.config.name ? ` "${workerConfig.config.name}"` : ""}${workerConfig.config.configPath ? ` (config at \`${path11.relative("", workerConfig.config.configPath)}\`)` : ""}`
|
|
14355
15527
|
);
|
|
14356
15528
|
nonApplicableLines.forEach((line) => lines.push(line));
|
|
14357
15529
|
}
|
|
@@ -14452,10 +15624,10 @@ function getWorkerConfig(configPath, env2, opts) {
|
|
|
14452
15624
|
}
|
|
14453
15625
|
function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliaryWorker = false) {
|
|
14454
15626
|
if (requestedConfigPath) {
|
|
14455
|
-
const configPath2 =
|
|
15627
|
+
const configPath2 = path11.resolve(root, requestedConfigPath);
|
|
14456
15628
|
const forAuxiliaryWorkerErrorMessage = isForAuxiliaryWorker ? " requested for one of your auxiliary workers" : "";
|
|
14457
15629
|
const errorMessagePrefix = `The provided configPath (${configPath2})${forAuxiliaryWorkerErrorMessage}`;
|
|
14458
|
-
const fileExtension =
|
|
15630
|
+
const fileExtension = path11.extname(configPath2).slice(1);
|
|
14459
15631
|
if (!allowedWranglerConfigExtensions.includes(fileExtension)) {
|
|
14460
15632
|
const foundExtensionMessage = !fileExtension ? "no extension found" : `"${fileExtension}" found`;
|
|
14461
15633
|
throw new Error(
|
|
@@ -14489,7 +15661,7 @@ function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliar
|
|
|
14489
15661
|
}
|
|
14490
15662
|
function findWranglerConfig(root) {
|
|
14491
15663
|
for (const extension of allowedWranglerConfigExtensions) {
|
|
14492
|
-
const configPath =
|
|
15664
|
+
const configPath = path11.join(root, `wrangler.${extension}`);
|
|
14493
15665
|
if (fs6.existsSync(configPath)) {
|
|
14494
15666
|
return configPath;
|
|
14495
15667
|
}
|
|
@@ -14507,7 +15679,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
14507
15679
|
inspectorPort: pluginConfig.inspectorPort,
|
|
14508
15680
|
experimental: pluginConfig.experimental ?? {}
|
|
14509
15681
|
};
|
|
14510
|
-
const root = userConfig.root ?
|
|
15682
|
+
const root = userConfig.root ? path12.resolve(userConfig.root) : process.cwd();
|
|
14511
15683
|
if (viteEnv.isPreview) {
|
|
14512
15684
|
return {
|
|
14513
15685
|
...shared,
|
|
@@ -14623,10 +15795,10 @@ function validateWorkerEnvironmentOptions(resolvedPluginConfig, resolvedViteConf
|
|
|
14623
15795
|
environmentOptions,
|
|
14624
15796
|
`Missing environment config for "${environmentName}"`
|
|
14625
15797
|
);
|
|
14626
|
-
const { resolve:
|
|
15798
|
+
const { resolve: resolve9 } = environmentOptions;
|
|
14627
15799
|
const disallowedEnvironmentOptions = {};
|
|
14628
|
-
if (
|
|
14629
|
-
disallowedEnvironmentOptions.resolveExternal =
|
|
15800
|
+
if (resolve9.external === true || resolve9.external.length) {
|
|
15801
|
+
disallowedEnvironmentOptions.resolveExternal = resolve9.external;
|
|
14630
15802
|
}
|
|
14631
15803
|
if (Object.keys(disallowedEnvironmentOptions).length) {
|
|
14632
15804
|
disallowedEnvironmentOptionsMap.set(
|
|
@@ -14658,16 +15830,16 @@ function handleWebSocket(httpServer, getFetcher) {
|
|
|
14658
15830
|
const nodeWebSocket = new WebSocketServer({ noServer: true });
|
|
14659
15831
|
httpServer.on(
|
|
14660
15832
|
"upgrade",
|
|
14661
|
-
async (
|
|
14662
|
-
const url = new URL(
|
|
14663
|
-
if (
|
|
15833
|
+
async (request2, socket, head) => {
|
|
15834
|
+
const url = new URL(request2.url ?? "", UNKNOWN_HOST);
|
|
15835
|
+
if (request2.headers["sec-websocket-protocol"]?.startsWith("vite")) {
|
|
14664
15836
|
return;
|
|
14665
15837
|
}
|
|
14666
|
-
const headers = createHeaders(
|
|
15838
|
+
const headers = createHeaders(request2);
|
|
14667
15839
|
const fetcher = await getFetcher();
|
|
14668
15840
|
const response = await fetcher(url, {
|
|
14669
15841
|
headers,
|
|
14670
|
-
method:
|
|
15842
|
+
method: request2.method
|
|
14671
15843
|
});
|
|
14672
15844
|
const workerWebSocket = response.webSocket;
|
|
14673
15845
|
if (!workerWebSocket) {
|
|
@@ -14675,12 +15847,12 @@ function handleWebSocket(httpServer, getFetcher) {
|
|
|
14675
15847
|
return;
|
|
14676
15848
|
}
|
|
14677
15849
|
nodeWebSocket.handleUpgrade(
|
|
14678
|
-
|
|
15850
|
+
request2,
|
|
14679
15851
|
socket,
|
|
14680
15852
|
head,
|
|
14681
15853
|
async (clientWebSocket) => {
|
|
14682
15854
|
coupleWebSocket(clientWebSocket, workerWebSocket);
|
|
14683
|
-
nodeWebSocket.emit("connection", clientWebSocket,
|
|
15855
|
+
nodeWebSocket.emit("connection", clientWebSocket, request2);
|
|
14684
15856
|
}
|
|
14685
15857
|
);
|
|
14686
15858
|
}
|
|
@@ -14695,11 +15867,15 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14695
15867
|
let resolvedViteConfig;
|
|
14696
15868
|
const additionalModulePaths = /* @__PURE__ */ new Set();
|
|
14697
15869
|
const nodeJsCompatWarningsMap = /* @__PURE__ */ new Map();
|
|
15870
|
+
const containerImageTagsSeen = /* @__PURE__ */ new Set();
|
|
15871
|
+
let runningContainerIds;
|
|
14698
15872
|
return [
|
|
14699
15873
|
{
|
|
14700
15874
|
name: "vite-plugin-cloudflare",
|
|
14701
15875
|
// This only applies to this plugin so is safe to use while other plugins migrate to the Environment API
|
|
14702
15876
|
sharedDuringBuild: true,
|
|
15877
|
+
// Vite `config` Hook
|
|
15878
|
+
// see https://vite.dev/guide/api-plugin.html#config
|
|
14703
15879
|
config(userConfig, env2) {
|
|
14704
15880
|
resolvedPluginConfig = resolvePluginConfig(
|
|
14705
15881
|
pluginConfig,
|
|
@@ -14763,6 +15939,8 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14763
15939
|
buildStart() {
|
|
14764
15940
|
workersConfigsWarningShown = false;
|
|
14765
15941
|
},
|
|
15942
|
+
// Vite `configResolved` Hook
|
|
15943
|
+
// see https://vite.dev/guide/api-plugin.html#configresolved
|
|
14766
15944
|
configResolved(config) {
|
|
14767
15945
|
resolvedViteConfig = config;
|
|
14768
15946
|
if (resolvedPluginConfig.type === "workers") {
|
|
@@ -14772,6 +15950,26 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14772
15950
|
);
|
|
14773
15951
|
}
|
|
14774
15952
|
},
|
|
15953
|
+
async transform(code, id) {
|
|
15954
|
+
const workerConfig = getWorkerConfig2(this.environment.name);
|
|
15955
|
+
if (!workerConfig) {
|
|
15956
|
+
return;
|
|
15957
|
+
}
|
|
15958
|
+
const resolvedWorkerEntry = await this.resolve(workerConfig.main);
|
|
15959
|
+
if (id === resolvedWorkerEntry?.id) {
|
|
15960
|
+
const modified = new MagicString(code);
|
|
15961
|
+
const hmrCode = `
|
|
15962
|
+
if (import.meta.hot) {
|
|
15963
|
+
import.meta.hot.accept();
|
|
15964
|
+
}
|
|
15965
|
+
`;
|
|
15966
|
+
modified.append(hmrCode);
|
|
15967
|
+
return {
|
|
15968
|
+
code: modified.toString(),
|
|
15969
|
+
map: modified.generateMap({ hires: "boundary", source: id })
|
|
15970
|
+
};
|
|
15971
|
+
}
|
|
15972
|
+
},
|
|
14775
15973
|
generateBundle(_, bundle) {
|
|
14776
15974
|
assertIsNotPreview(resolvedPluginConfig);
|
|
14777
15975
|
let config;
|
|
@@ -14798,11 +15996,36 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14798
15996
|
);
|
|
14799
15997
|
workerConfig.assets = {
|
|
14800
15998
|
...workerConfig.assets,
|
|
14801
|
-
directory:
|
|
14802
|
-
|
|
14803
|
-
|
|
15999
|
+
directory: path13.relative(
|
|
16000
|
+
path13.resolve(resolvedViteConfig.root, workerOutputDirectory),
|
|
16001
|
+
path13.resolve(resolvedViteConfig.root, clientOutputDirectory)
|
|
14804
16002
|
)
|
|
14805
16003
|
};
|
|
16004
|
+
if (workerConfig.containers?.length) {
|
|
16005
|
+
workerConfig.containers = workerConfig.containers.map(
|
|
16006
|
+
(container) => {
|
|
16007
|
+
const baseDir = workerConfig.configPath ? path13.dirname(workerConfig.configPath) : resolvedViteConfig.root;
|
|
16008
|
+
const image = container.configuration?.image ?? container.image;
|
|
16009
|
+
if (isDockerfile(image, workerConfig.configPath)) {
|
|
16010
|
+
const output = {
|
|
16011
|
+
...container,
|
|
16012
|
+
image: path13.resolve(baseDir, image),
|
|
16013
|
+
...container.image_build_context ? {
|
|
16014
|
+
image_build_context: path13.resolve(
|
|
16015
|
+
baseDir,
|
|
16016
|
+
container.image_build_context
|
|
16017
|
+
)
|
|
16018
|
+
} : {}
|
|
16019
|
+
};
|
|
16020
|
+
delete output.configuration?.image;
|
|
16021
|
+
if (output.configuration && Object.keys(output.configuration).length === 0) {
|
|
16022
|
+
delete output.configuration;
|
|
16023
|
+
}
|
|
16024
|
+
return output;
|
|
16025
|
+
} else return container;
|
|
16026
|
+
}
|
|
16027
|
+
);
|
|
16028
|
+
}
|
|
14806
16029
|
} else {
|
|
14807
16030
|
workerConfig.assets = void 0;
|
|
14808
16031
|
}
|
|
@@ -14855,7 +16078,7 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14855
16078
|
},
|
|
14856
16079
|
hotUpdate(options) {
|
|
14857
16080
|
assertIsNotPreview(resolvedPluginConfig);
|
|
14858
|
-
const changedFilePath =
|
|
16081
|
+
const changedFilePath = path13.resolve(options.file);
|
|
14859
16082
|
if (resolvedPluginConfig.configPaths.has(changedFilePath) || hasDotDevDotVarsFileChanged(resolvedPluginConfig, changedFilePath) || hasAssetsConfigChanged(
|
|
14860
16083
|
resolvedPluginConfig,
|
|
14861
16084
|
resolvedViteConfig,
|
|
@@ -14865,6 +16088,8 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14865
16088
|
return [];
|
|
14866
16089
|
}
|
|
14867
16090
|
},
|
|
16091
|
+
// Vite `configureServer` Hook
|
|
16092
|
+
// see https://vite.dev/guide/api-plugin.html#configureserver
|
|
14868
16093
|
async configureServer(viteDevServer) {
|
|
14869
16094
|
assertIsNotPreview(resolvedPluginConfig);
|
|
14870
16095
|
const inputInspectorPort = await getInputInspectorPortOption(
|
|
@@ -14872,11 +16097,18 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14872
16097
|
viteDevServer,
|
|
14873
16098
|
miniflare
|
|
14874
16099
|
);
|
|
14875
|
-
|
|
16100
|
+
let containerBuildId;
|
|
16101
|
+
const entryWorkerConfig = getEntryWorkerConfig(resolvedPluginConfig);
|
|
16102
|
+
const hasDevContainers = entryWorkerConfig?.containers?.length && entryWorkerConfig.dev.enable_containers;
|
|
16103
|
+
if (hasDevContainers) {
|
|
16104
|
+
containerBuildId = generateContainerBuildId();
|
|
16105
|
+
}
|
|
16106
|
+
const miniflareDevOptions = await getDevMiniflareOptions({
|
|
14876
16107
|
resolvedPluginConfig,
|
|
14877
16108
|
viteDevServer,
|
|
14878
|
-
inputInspectorPort
|
|
14879
|
-
|
|
16109
|
+
inspectorPort: inputInspectorPort,
|
|
16110
|
+
containerBuildId
|
|
16111
|
+
});
|
|
14880
16112
|
if (!miniflare) {
|
|
14881
16113
|
miniflare = new Miniflare(miniflareDevOptions);
|
|
14882
16114
|
} else {
|
|
@@ -14884,11 +16116,8 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14884
16116
|
}
|
|
14885
16117
|
let preMiddleware;
|
|
14886
16118
|
if (resolvedPluginConfig.type === "workers") {
|
|
14887
|
-
await initRunners(resolvedPluginConfig, viteDevServer, miniflare);
|
|
14888
|
-
const entryWorkerConfig = getWorkerConfig2(
|
|
14889
|
-
resolvedPluginConfig.entryWorkerEnvironmentName
|
|
14890
|
-
);
|
|
14891
16119
|
assert11(entryWorkerConfig, `No entry Worker config`);
|
|
16120
|
+
await initRunners(resolvedPluginConfig, viteDevServer, miniflare);
|
|
14892
16121
|
const entryWorkerName = entryWorkerConfig.name;
|
|
14893
16122
|
if (viteDevServer.httpServer) {
|
|
14894
16123
|
handleWebSocket(viteDevServer.httpServer, async () => {
|
|
@@ -14905,26 +16134,61 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14905
16134
|
const includeRulesMatcher = generateStaticRoutingRuleMatcher(
|
|
14906
16135
|
staticRouting.user_worker
|
|
14907
16136
|
);
|
|
14908
|
-
const userWorkerHandler = createRequestHandler(async (
|
|
16137
|
+
const userWorkerHandler = createRequestHandler(async (request2) => {
|
|
14909
16138
|
assert11(miniflare, `Miniflare not defined`);
|
|
14910
16139
|
const userWorker = await miniflare.getWorker(entryWorkerName);
|
|
14911
|
-
return userWorker.fetch(
|
|
16140
|
+
return userWorker.fetch(request2, { redirect: "manual" });
|
|
14912
16141
|
});
|
|
14913
16142
|
preMiddleware = async (req, res, next) => {
|
|
14914
16143
|
assert11(req.url, `req.url not defined`);
|
|
14915
|
-
const
|
|
16144
|
+
const request2 = new Request(new URL(req.url, UNKNOWN_HOST));
|
|
14916
16145
|
if (req[kRequestType] === "asset") {
|
|
14917
16146
|
next();
|
|
14918
|
-
} else if (excludeRulesMatcher({ request })) {
|
|
16147
|
+
} else if (excludeRulesMatcher({ request: request2 })) {
|
|
14919
16148
|
req[kRequestType] === "asset";
|
|
14920
16149
|
next();
|
|
14921
|
-
} else if (includeRulesMatcher({ request })) {
|
|
16150
|
+
} else if (includeRulesMatcher({ request: request2 })) {
|
|
14922
16151
|
userWorkerHandler(req, res, next);
|
|
14923
16152
|
} else {
|
|
14924
16153
|
next();
|
|
14925
16154
|
}
|
|
14926
16155
|
};
|
|
14927
16156
|
}
|
|
16157
|
+
if (hasDevContainers) {
|
|
16158
|
+
assert11(
|
|
16159
|
+
containerBuildId,
|
|
16160
|
+
"Build ID should be set if containers are enabled and defined"
|
|
16161
|
+
);
|
|
16162
|
+
const containerOptions = await getContainerOptions(
|
|
16163
|
+
entryWorkerConfig,
|
|
16164
|
+
containerBuildId
|
|
16165
|
+
);
|
|
16166
|
+
const dockerPath = getDockerPath();
|
|
16167
|
+
if (containerOptions) {
|
|
16168
|
+
for (const container of containerOptions) {
|
|
16169
|
+
containerImageTagsSeen.add(container.imageTag);
|
|
16170
|
+
}
|
|
16171
|
+
await prepareContainerImagesForDev({
|
|
16172
|
+
dockerPath,
|
|
16173
|
+
configPath: entryWorkerConfig.configPath,
|
|
16174
|
+
containerOptions,
|
|
16175
|
+
onContainerImagePreparationStart: () => {
|
|
16176
|
+
},
|
|
16177
|
+
onContainerImagePreparationEnd: () => {
|
|
16178
|
+
}
|
|
16179
|
+
});
|
|
16180
|
+
}
|
|
16181
|
+
const dockerPollIntervalId = setInterval(async () => {
|
|
16182
|
+
runningContainerIds = await getContainerIdsByImageTags(
|
|
16183
|
+
dockerPath,
|
|
16184
|
+
containerImageTagsSeen
|
|
16185
|
+
);
|
|
16186
|
+
}, 2e3);
|
|
16187
|
+
process.on("exit", () => {
|
|
16188
|
+
clearInterval(dockerPollIntervalId);
|
|
16189
|
+
removeContainersByIds(dockerPath, runningContainerIds);
|
|
16190
|
+
});
|
|
16191
|
+
}
|
|
14928
16192
|
}
|
|
14929
16193
|
return () => {
|
|
14930
16194
|
if (preMiddleware) {
|
|
@@ -14942,14 +16206,14 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14942
16206
|
});
|
|
14943
16207
|
}
|
|
14944
16208
|
viteDevServer.middlewares.use(
|
|
14945
|
-
createRequestHandler(async (
|
|
16209
|
+
createRequestHandler(async (request2, req) => {
|
|
14946
16210
|
assert11(miniflare, `Miniflare not defined`);
|
|
14947
16211
|
if (req[kRequestType] === "asset") {
|
|
14948
16212
|
const assetWorker = await miniflare.getWorker(ASSET_WORKER_NAME);
|
|
14949
|
-
return assetWorker.fetch(
|
|
16213
|
+
return assetWorker.fetch(request2, { redirect: "manual" });
|
|
14950
16214
|
} else {
|
|
14951
16215
|
const routerWorker = await miniflare.getWorker(ROUTER_WORKER_NAME);
|
|
14952
|
-
return routerWorker.fetch(
|
|
16216
|
+
return routerWorker.fetch(request2, {
|
|
14953
16217
|
redirect: "manual"
|
|
14954
16218
|
});
|
|
14955
16219
|
}
|
|
@@ -14957,6 +16221,8 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14957
16221
|
);
|
|
14958
16222
|
};
|
|
14959
16223
|
},
|
|
16224
|
+
// Vite `configurePreviewServer` Hook
|
|
16225
|
+
// see https://vite.dev/guide/api-plugin.html#configurepreviewserver
|
|
14960
16226
|
async configurePreviewServer(vitePreviewServer) {
|
|
14961
16227
|
assertIsPreview(resolvedPluginConfig);
|
|
14962
16228
|
const inputInspectorPort = await getInputInspectorPortOption(
|
|
@@ -14975,11 +16241,23 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
14975
16241
|
return miniflare.dispatchFetch;
|
|
14976
16242
|
});
|
|
14977
16243
|
vitePreviewServer.middlewares.use(
|
|
14978
|
-
createRequestHandler((
|
|
16244
|
+
createRequestHandler((request2) => {
|
|
14979
16245
|
assert11(miniflare, `Miniflare not defined`);
|
|
14980
|
-
return miniflare.dispatchFetch(
|
|
16246
|
+
return miniflare.dispatchFetch(request2, { redirect: "manual" });
|
|
14981
16247
|
})
|
|
14982
16248
|
);
|
|
16249
|
+
},
|
|
16250
|
+
async buildEnd() {
|
|
16251
|
+
if (resolvedViteConfig.command === "serve") {
|
|
16252
|
+
const dockerPath = getDockerPath();
|
|
16253
|
+
runningContainerIds = await getContainerIdsByImageTags(
|
|
16254
|
+
dockerPath,
|
|
16255
|
+
containerImageTagsSeen
|
|
16256
|
+
);
|
|
16257
|
+
await removeContainersByIds(dockerPath, runningContainerIds);
|
|
16258
|
+
containerImageTagsSeen.clear();
|
|
16259
|
+
runningContainerIds = [];
|
|
16260
|
+
}
|
|
14983
16261
|
}
|
|
14984
16262
|
},
|
|
14985
16263
|
// Plugin to provide a fallback entry file
|
|
@@ -15069,13 +16347,13 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
15069
16347
|
}
|
|
15070
16348
|
const referenceId = this.emitFile({
|
|
15071
16349
|
type: "asset",
|
|
15072
|
-
name:
|
|
16350
|
+
name: path13.basename(modulePath),
|
|
15073
16351
|
originalFileName: modulePath,
|
|
15074
16352
|
source
|
|
15075
16353
|
});
|
|
15076
16354
|
const emittedFileName = this.getFileName(referenceId);
|
|
15077
16355
|
const relativePath = vite6.normalizePath(
|
|
15078
|
-
|
|
16356
|
+
path13.relative(path13.dirname(chunk.fileName), emittedFileName)
|
|
15079
16357
|
);
|
|
15080
16358
|
const importPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
15081
16359
|
magicString.update(
|
|
@@ -15282,13 +16560,13 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
15282
16560
|
setup(build) {
|
|
15283
16561
|
build.onResolve(
|
|
15284
16562
|
{ filter: NODEJS_MODULES_RE },
|
|
15285
|
-
({ path:
|
|
15286
|
-
if (isNodeAls(workerConfig) && isNodeAlsModule(
|
|
16563
|
+
({ path: path14, importer }) => {
|
|
16564
|
+
if (isNodeAls(workerConfig) && isNodeAlsModule(path14)) {
|
|
15287
16565
|
return;
|
|
15288
16566
|
}
|
|
15289
16567
|
const nodeJsCompatWarnings = nodeJsCompatWarningsMap.get(workerConfig);
|
|
15290
|
-
nodeJsCompatWarnings?.registerImport(
|
|
15291
|
-
return { path:
|
|
16568
|
+
nodeJsCompatWarnings?.registerImport(path14, importer);
|
|
16569
|
+
return { path: path14, external: true };
|
|
15292
16570
|
}
|
|
15293
16571
|
);
|
|
15294
16572
|
}
|
|
@@ -15333,6 +16611,23 @@ function cloudflare2(pluginConfig = {}) {
|
|
|
15333
16611
|
function getWorkerConfig2(environmentName) {
|
|
15334
16612
|
return resolvedPluginConfig.type === "workers" ? resolvedPluginConfig.workers[environmentName] : void 0;
|
|
15335
16613
|
}
|
|
16614
|
+
async function getContainerOptions(config, containerBuildId) {
|
|
16615
|
+
if (!config.containers?.length || config.dev.enable_containers === false) {
|
|
16616
|
+
return void 0;
|
|
16617
|
+
}
|
|
16618
|
+
return config.containers.map((container) => {
|
|
16619
|
+
return {
|
|
16620
|
+
image: container.image ?? container.configuration?.image,
|
|
16621
|
+
imageTag: getDevContainerImageName(
|
|
16622
|
+
container.class_name,
|
|
16623
|
+
containerBuildId
|
|
16624
|
+
),
|
|
16625
|
+
args: container.image_vars,
|
|
16626
|
+
imageBuildContext: container.image_build_context,
|
|
16627
|
+
class_name: container.class_name
|
|
16628
|
+
};
|
|
16629
|
+
});
|
|
16630
|
+
}
|
|
15336
16631
|
}
|
|
15337
16632
|
export {
|
|
15338
16633
|
cloudflare2 as cloudflare
|