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