wrangler 2.3.2 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/__tests__/dev.test.tsx +26 -0
- package/src/__tests__/index.test.ts +2 -0
- package/src/__tests__/pages.test.ts +55 -1
- package/src/api/dev.ts +2 -0
- package/src/dev/dev.tsx +3 -0
- package/src/dev/local.tsx +134 -18
- package/src/dev/start-server.ts +14 -1
- package/src/dev.tsx +18 -1
- package/src/dialogs.tsx +1 -2
- package/src/index.tsx +1 -2
- package/src/pages/publish.tsx +20 -0
- package/wrangler-dist/cli.d.ts +2 -0
- package/wrangler-dist/cli.js +1053 -958
package/wrangler-dist/cli.js
CHANGED
|
@@ -12619,7 +12619,7 @@ var require_fetch = __commonJS({
|
|
|
12619
12619
|
this.emit("terminated", reason);
|
|
12620
12620
|
}
|
|
12621
12621
|
};
|
|
12622
|
-
async function
|
|
12622
|
+
async function fetch10(input, init = {}) {
|
|
12623
12623
|
if (arguments.length < 1) {
|
|
12624
12624
|
throw new TypeError(
|
|
12625
12625
|
`Failed to execute 'fetch' on 'Window': 1 argument required, but only ${arguments.length} present.`
|
|
@@ -13481,7 +13481,7 @@ var require_fetch = __commonJS({
|
|
|
13481
13481
|
}
|
|
13482
13482
|
}
|
|
13483
13483
|
module2.exports = {
|
|
13484
|
-
fetch:
|
|
13484
|
+
fetch: fetch10,
|
|
13485
13485
|
Fetch,
|
|
13486
13486
|
fetching,
|
|
13487
13487
|
finalizeAndReportTiming
|
|
@@ -13571,7 +13571,7 @@ var require_undici = __commonJS({
|
|
|
13571
13571
|
module2.exports.getGlobalDispatcher = getGlobalDispatcher;
|
|
13572
13572
|
if (nodeMajor > 16 || nodeMajor === 16 && nodeMinor >= 8) {
|
|
13573
13573
|
let fetchImpl = null;
|
|
13574
|
-
module2.exports.fetch = async function
|
|
13574
|
+
module2.exports.fetch = async function fetch10(resource) {
|
|
13575
13575
|
if (!fetchImpl) {
|
|
13576
13576
|
fetchImpl = require_fetch().fetch;
|
|
13577
13577
|
}
|
|
@@ -98945,7 +98945,7 @@ var require_utils3 = __commonJS({
|
|
|
98945
98945
|
}
|
|
98946
98946
|
}
|
|
98947
98947
|
};
|
|
98948
|
-
var
|
|
98948
|
+
var arrayToObject = function arrayToObject2(source, options6) {
|
|
98949
98949
|
var obj = options6 && options6.plainObjects ? /* @__PURE__ */ Object.create(null) : {};
|
|
98950
98950
|
for (var i2 = 0; i2 < source.length; ++i2) {
|
|
98951
98951
|
if (typeof source[i2] !== "undefined") {
|
|
@@ -98975,7 +98975,7 @@ var require_utils3 = __commonJS({
|
|
|
98975
98975
|
}
|
|
98976
98976
|
var mergeTarget = target;
|
|
98977
98977
|
if (isArray(target) && !isArray(source)) {
|
|
98978
|
-
mergeTarget =
|
|
98978
|
+
mergeTarget = arrayToObject(target, options6);
|
|
98979
98979
|
}
|
|
98980
98980
|
if (isArray(target) && isArray(source)) {
|
|
98981
98981
|
source.forEach(function(item, i2) {
|
|
@@ -99101,7 +99101,7 @@ var require_utils3 = __commonJS({
|
|
|
99101
99101
|
return fn(val);
|
|
99102
99102
|
};
|
|
99103
99103
|
module2.exports = {
|
|
99104
|
-
arrayToObject
|
|
99104
|
+
arrayToObject,
|
|
99105
99105
|
assign,
|
|
99106
99106
|
combine,
|
|
99107
99107
|
compact,
|
|
@@ -127367,98 +127367,6 @@ var require_lib5 = __commonJS({
|
|
|
127367
127367
|
}
|
|
127368
127368
|
});
|
|
127369
127369
|
|
|
127370
|
-
// ../../node_modules/glob-to-regexp/index.js
|
|
127371
|
-
var require_glob_to_regexp = __commonJS({
|
|
127372
|
-
"../../node_modules/glob-to-regexp/index.js"(exports2, module2) {
|
|
127373
|
-
init_import_meta_url();
|
|
127374
|
-
module2.exports = function(glob, opts) {
|
|
127375
|
-
if (typeof glob !== "string") {
|
|
127376
|
-
throw new TypeError("Expected a string");
|
|
127377
|
-
}
|
|
127378
|
-
var str = String(glob);
|
|
127379
|
-
var reStr = "";
|
|
127380
|
-
var extended = opts ? !!opts.extended : false;
|
|
127381
|
-
var globstar = opts ? !!opts.globstar : false;
|
|
127382
|
-
var inGroup = false;
|
|
127383
|
-
var flags = opts && typeof opts.flags === "string" ? opts.flags : "";
|
|
127384
|
-
var c;
|
|
127385
|
-
for (var i2 = 0, len = str.length; i2 < len; i2++) {
|
|
127386
|
-
c = str[i2];
|
|
127387
|
-
switch (c) {
|
|
127388
|
-
case "/":
|
|
127389
|
-
case "$":
|
|
127390
|
-
case "^":
|
|
127391
|
-
case "+":
|
|
127392
|
-
case ".":
|
|
127393
|
-
case "(":
|
|
127394
|
-
case ")":
|
|
127395
|
-
case "=":
|
|
127396
|
-
case "!":
|
|
127397
|
-
case "|":
|
|
127398
|
-
reStr += "\\" + c;
|
|
127399
|
-
break;
|
|
127400
|
-
case "?":
|
|
127401
|
-
if (extended) {
|
|
127402
|
-
reStr += ".";
|
|
127403
|
-
break;
|
|
127404
|
-
}
|
|
127405
|
-
case "[":
|
|
127406
|
-
case "]":
|
|
127407
|
-
if (extended) {
|
|
127408
|
-
reStr += c;
|
|
127409
|
-
break;
|
|
127410
|
-
}
|
|
127411
|
-
case "{":
|
|
127412
|
-
if (extended) {
|
|
127413
|
-
inGroup = true;
|
|
127414
|
-
reStr += "(";
|
|
127415
|
-
break;
|
|
127416
|
-
}
|
|
127417
|
-
case "}":
|
|
127418
|
-
if (extended) {
|
|
127419
|
-
inGroup = false;
|
|
127420
|
-
reStr += ")";
|
|
127421
|
-
break;
|
|
127422
|
-
}
|
|
127423
|
-
case ",":
|
|
127424
|
-
if (inGroup) {
|
|
127425
|
-
reStr += "|";
|
|
127426
|
-
break;
|
|
127427
|
-
}
|
|
127428
|
-
reStr += "\\" + c;
|
|
127429
|
-
break;
|
|
127430
|
-
case "*":
|
|
127431
|
-
var prevChar = str[i2 - 1];
|
|
127432
|
-
var starCount = 1;
|
|
127433
|
-
while (str[i2 + 1] === "*") {
|
|
127434
|
-
starCount++;
|
|
127435
|
-
i2++;
|
|
127436
|
-
}
|
|
127437
|
-
var nextChar = str[i2 + 1];
|
|
127438
|
-
if (!globstar) {
|
|
127439
|
-
reStr += ".*";
|
|
127440
|
-
} else {
|
|
127441
|
-
var isGlobstar = starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0);
|
|
127442
|
-
if (isGlobstar) {
|
|
127443
|
-
reStr += "((?:[^/]*(?:/|$))*)";
|
|
127444
|
-
i2++;
|
|
127445
|
-
} else {
|
|
127446
|
-
reStr += "([^/]*)";
|
|
127447
|
-
}
|
|
127448
|
-
}
|
|
127449
|
-
break;
|
|
127450
|
-
default:
|
|
127451
|
-
reStr += c;
|
|
127452
|
-
}
|
|
127453
|
-
}
|
|
127454
|
-
if (!flags || !~flags.indexOf("g")) {
|
|
127455
|
-
reStr = "^" + reStr + "$";
|
|
127456
|
-
}
|
|
127457
|
-
return new RegExp(reStr, flags);
|
|
127458
|
-
};
|
|
127459
|
-
}
|
|
127460
|
-
});
|
|
127461
|
-
|
|
127462
127370
|
// ../../node_modules/@webcontainer/env/dist/index.js
|
|
127463
127371
|
var require_dist = __commonJS({
|
|
127464
127372
|
"../../node_modules/@webcontainer/env/dist/index.js"(exports2, module2) {
|
|
@@ -129444,6 +129352,98 @@ var require_build3 = __commonJS({
|
|
|
129444
129352
|
}
|
|
129445
129353
|
});
|
|
129446
129354
|
|
|
129355
|
+
// ../../node_modules/glob-to-regexp/index.js
|
|
129356
|
+
var require_glob_to_regexp = __commonJS({
|
|
129357
|
+
"../../node_modules/glob-to-regexp/index.js"(exports2, module2) {
|
|
129358
|
+
init_import_meta_url();
|
|
129359
|
+
module2.exports = function(glob, opts) {
|
|
129360
|
+
if (typeof glob !== "string") {
|
|
129361
|
+
throw new TypeError("Expected a string");
|
|
129362
|
+
}
|
|
129363
|
+
var str = String(glob);
|
|
129364
|
+
var reStr = "";
|
|
129365
|
+
var extended = opts ? !!opts.extended : false;
|
|
129366
|
+
var globstar = opts ? !!opts.globstar : false;
|
|
129367
|
+
var inGroup = false;
|
|
129368
|
+
var flags = opts && typeof opts.flags === "string" ? opts.flags : "";
|
|
129369
|
+
var c;
|
|
129370
|
+
for (var i2 = 0, len = str.length; i2 < len; i2++) {
|
|
129371
|
+
c = str[i2];
|
|
129372
|
+
switch (c) {
|
|
129373
|
+
case "/":
|
|
129374
|
+
case "$":
|
|
129375
|
+
case "^":
|
|
129376
|
+
case "+":
|
|
129377
|
+
case ".":
|
|
129378
|
+
case "(":
|
|
129379
|
+
case ")":
|
|
129380
|
+
case "=":
|
|
129381
|
+
case "!":
|
|
129382
|
+
case "|":
|
|
129383
|
+
reStr += "\\" + c;
|
|
129384
|
+
break;
|
|
129385
|
+
case "?":
|
|
129386
|
+
if (extended) {
|
|
129387
|
+
reStr += ".";
|
|
129388
|
+
break;
|
|
129389
|
+
}
|
|
129390
|
+
case "[":
|
|
129391
|
+
case "]":
|
|
129392
|
+
if (extended) {
|
|
129393
|
+
reStr += c;
|
|
129394
|
+
break;
|
|
129395
|
+
}
|
|
129396
|
+
case "{":
|
|
129397
|
+
if (extended) {
|
|
129398
|
+
inGroup = true;
|
|
129399
|
+
reStr += "(";
|
|
129400
|
+
break;
|
|
129401
|
+
}
|
|
129402
|
+
case "}":
|
|
129403
|
+
if (extended) {
|
|
129404
|
+
inGroup = false;
|
|
129405
|
+
reStr += ")";
|
|
129406
|
+
break;
|
|
129407
|
+
}
|
|
129408
|
+
case ",":
|
|
129409
|
+
if (inGroup) {
|
|
129410
|
+
reStr += "|";
|
|
129411
|
+
break;
|
|
129412
|
+
}
|
|
129413
|
+
reStr += "\\" + c;
|
|
129414
|
+
break;
|
|
129415
|
+
case "*":
|
|
129416
|
+
var prevChar = str[i2 - 1];
|
|
129417
|
+
var starCount = 1;
|
|
129418
|
+
while (str[i2 + 1] === "*") {
|
|
129419
|
+
starCount++;
|
|
129420
|
+
i2++;
|
|
129421
|
+
}
|
|
129422
|
+
var nextChar = str[i2 + 1];
|
|
129423
|
+
if (!globstar) {
|
|
129424
|
+
reStr += ".*";
|
|
129425
|
+
} else {
|
|
129426
|
+
var isGlobstar = starCount > 1 && (prevChar === "/" || prevChar === void 0) && (nextChar === "/" || nextChar === void 0);
|
|
129427
|
+
if (isGlobstar) {
|
|
129428
|
+
reStr += "((?:[^/]*(?:/|$))*)";
|
|
129429
|
+
i2++;
|
|
129430
|
+
} else {
|
|
129431
|
+
reStr += "([^/]*)";
|
|
129432
|
+
}
|
|
129433
|
+
}
|
|
129434
|
+
break;
|
|
129435
|
+
default:
|
|
129436
|
+
reStr += c;
|
|
129437
|
+
}
|
|
129438
|
+
}
|
|
129439
|
+
if (!flags || !~flags.indexOf("g")) {
|
|
129440
|
+
reStr = "^" + reStr + "$";
|
|
129441
|
+
}
|
|
129442
|
+
return new RegExp(reStr, flags);
|
|
129443
|
+
};
|
|
129444
|
+
}
|
|
129445
|
+
});
|
|
129446
|
+
|
|
129447
129447
|
// ../../node_modules/ignore/index.js
|
|
129448
129448
|
var require_ignore = __commonJS({
|
|
129449
129449
|
"../../node_modules/ignore/index.js"(exports2, module2) {
|
|
@@ -141159,7 +141159,7 @@ var import_websocket_server = __toESM(require_websocket_server2(), 1);
|
|
|
141159
141159
|
var wrapper_default = import_websocket.default;
|
|
141160
141160
|
|
|
141161
141161
|
// package.json
|
|
141162
|
-
var version = "2.
|
|
141162
|
+
var version = "2.4.0";
|
|
141163
141163
|
var package_default = {
|
|
141164
141164
|
name: "wrangler",
|
|
141165
141165
|
version,
|
|
@@ -141281,7 +141281,7 @@ var package_default = {
|
|
|
141281
141281
|
"@databases/sql": "^3.2.0",
|
|
141282
141282
|
"@iarna/toml": "^3.0.0",
|
|
141283
141283
|
"@microsoft/api-extractor": "^7.28.3",
|
|
141284
|
-
"@miniflare/tre": "^3.0.0-next.
|
|
141284
|
+
"@miniflare/tre": "^3.0.0-next.6",
|
|
141285
141285
|
"@types/better-sqlite3": "^7.6.0",
|
|
141286
141286
|
"@types/busboy": "^1.5.0",
|
|
141287
141287
|
"@types/command-exists": "^1.2.0",
|
|
@@ -142471,11 +142471,11 @@ async function openInBrowser(url3) {
|
|
|
142471
142471
|
|
|
142472
142472
|
// src/dev/local.tsx
|
|
142473
142473
|
init_import_meta_url();
|
|
142474
|
-
var
|
|
142474
|
+
var import_node_assert5 = __toESM(require("node:assert"));
|
|
142475
142475
|
var import_node_child_process2 = require("node:child_process");
|
|
142476
|
-
var
|
|
142476
|
+
var import_node_fs6 = require("node:fs");
|
|
142477
142477
|
var import_promises3 = require("node:fs/promises");
|
|
142478
|
-
var
|
|
142478
|
+
var import_node_path15 = __toESM(require("node:path"));
|
|
142479
142479
|
var import_chalk = __toESM(require_chalk());
|
|
142480
142480
|
|
|
142481
142481
|
// ../../node_modules/npx-import/lib/index.js
|
|
@@ -142683,750 +142683,12 @@ ${JSON.stringify(paths)}`);
|
|
|
142683
142683
|
}
|
|
142684
142684
|
|
|
142685
142685
|
// src/dev/local.tsx
|
|
142686
|
-
var
|
|
142686
|
+
var import_react5 = __toESM(require_react());
|
|
142687
142687
|
var import_signal_exit2 = __toESM(require_signal_exit());
|
|
142688
142688
|
|
|
142689
|
-
// src/module-collection.ts
|
|
142690
|
-
init_import_meta_url();
|
|
142691
|
-
var import_node_crypto = __toESM(require("node:crypto"));
|
|
142692
|
-
var import_promises2 = require("node:fs/promises");
|
|
142693
|
-
var import_node_path13 = __toESM(require("node:path"));
|
|
142694
|
-
var import_glob_to_regexp = __toESM(require_glob_to_regexp());
|
|
142695
|
-
function flipObject(obj) {
|
|
142696
|
-
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k]));
|
|
142697
|
-
}
|
|
142698
|
-
var RuleTypeToModuleType = {
|
|
142699
|
-
ESModule: "esm",
|
|
142700
|
-
CommonJS: "commonjs",
|
|
142701
|
-
CompiledWasm: "compiled-wasm",
|
|
142702
|
-
Data: "buffer",
|
|
142703
|
-
Text: "text"
|
|
142704
|
-
};
|
|
142705
|
-
var ModuleTypeToRuleType = flipObject(RuleTypeToModuleType);
|
|
142706
|
-
var DEFAULT_MODULE_RULES = [
|
|
142707
|
-
{ type: "Text", globs: ["**/*.txt", "**/*.html"] },
|
|
142708
|
-
{ type: "Data", globs: ["**/*.bin"] },
|
|
142709
|
-
{ type: "CompiledWasm", globs: ["**/*.wasm"] }
|
|
142710
|
-
];
|
|
142711
|
-
function createModuleCollector(props) {
|
|
142712
|
-
const rules = [
|
|
142713
|
-
...props.rules || [],
|
|
142714
|
-
...DEFAULT_MODULE_RULES
|
|
142715
|
-
];
|
|
142716
|
-
const completedRuleLocations = {};
|
|
142717
|
-
let index = 0;
|
|
142718
|
-
const rulesToRemove = [];
|
|
142719
|
-
for (const rule of rules) {
|
|
142720
|
-
if (rule.type in completedRuleLocations) {
|
|
142721
|
-
if (rules[completedRuleLocations[rule.type]].fallthrough !== false) {
|
|
142722
|
-
if (index < (props.rules || []).length) {
|
|
142723
|
-
logger.warn(
|
|
142724
|
-
`The module rule at position ${index} (${JSON.stringify(
|
|
142725
|
-
rule
|
|
142726
|
-
)}) has the same type as a previous rule (at position ${completedRuleLocations[rule.type]}, ${JSON.stringify(
|
|
142727
|
-
rules[completedRuleLocations[rule.type]]
|
|
142728
|
-
)}). This rule will be ignored. To the previous rule, add \`fallthrough = true\` to allow this one to also be used, or \`fallthrough = false\` to silence this warning.`
|
|
142729
|
-
);
|
|
142730
|
-
} else {
|
|
142731
|
-
logger.warn(
|
|
142732
|
-
`The default module rule ${JSON.stringify(
|
|
142733
|
-
rule
|
|
142734
|
-
)} has the same type as a previous rule (at position ${completedRuleLocations[rule.type]}, ${JSON.stringify(
|
|
142735
|
-
rules[completedRuleLocations[rule.type]]
|
|
142736
|
-
)}). This rule will be ignored. To the previous rule, add \`fallthrough = true\` to allow the default one to also be used, or \`fallthrough = false\` to silence this warning.`
|
|
142737
|
-
);
|
|
142738
|
-
}
|
|
142739
|
-
}
|
|
142740
|
-
rulesToRemove.push(rule);
|
|
142741
|
-
}
|
|
142742
|
-
if (!(rule.type in completedRuleLocations) && rule.fallthrough !== true) {
|
|
142743
|
-
completedRuleLocations[rule.type] = index;
|
|
142744
|
-
}
|
|
142745
|
-
index++;
|
|
142746
|
-
}
|
|
142747
|
-
rulesToRemove.forEach((rule) => rules.splice(rules.indexOf(rule), 1));
|
|
142748
|
-
const modules = [];
|
|
142749
|
-
return {
|
|
142750
|
-
modules,
|
|
142751
|
-
plugin: {
|
|
142752
|
-
name: "wrangler-module-collector",
|
|
142753
|
-
setup(build5) {
|
|
142754
|
-
build5.onStart(() => {
|
|
142755
|
-
modules.splice(0);
|
|
142756
|
-
});
|
|
142757
|
-
const rulesMatchers = rules.flatMap((rule) => {
|
|
142758
|
-
return rule.globs.map((glob) => {
|
|
142759
|
-
const regex = (0, import_glob_to_regexp.default)(glob);
|
|
142760
|
-
return {
|
|
142761
|
-
regex,
|
|
142762
|
-
rule
|
|
142763
|
-
};
|
|
142764
|
-
});
|
|
142765
|
-
});
|
|
142766
|
-
if (props.wrangler1xlegacyModuleReferences.fileNames.size > 0) {
|
|
142767
|
-
build5.onResolve(
|
|
142768
|
-
{
|
|
142769
|
-
filter: new RegExp(
|
|
142770
|
-
"^(" + [...props.wrangler1xlegacyModuleReferences.fileNames].map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|") + ")$"
|
|
142771
|
-
)
|
|
142772
|
-
},
|
|
142773
|
-
async (args) => {
|
|
142774
|
-
if (args.kind !== "import-statement" && args.kind !== "require-call") {
|
|
142775
|
-
return;
|
|
142776
|
-
}
|
|
142777
|
-
logger.warn(
|
|
142778
|
-
`Deprecation: detected a legacy module import in "./${import_node_path13.default.relative(
|
|
142779
|
-
process.cwd(),
|
|
142780
|
-
args.importer
|
|
142781
|
-
)}". This will stop working in the future. Replace references to "${args.path}" with "./${args.path}";`
|
|
142782
|
-
);
|
|
142783
|
-
const filePath = import_node_path13.default.join(
|
|
142784
|
-
props.wrangler1xlegacyModuleReferences.rootDirectory,
|
|
142785
|
-
args.path
|
|
142786
|
-
);
|
|
142787
|
-
const fileContent = await (0, import_promises2.readFile)(filePath);
|
|
142788
|
-
const fileHash = import_node_crypto.default.createHash("sha1").update(fileContent).digest("hex");
|
|
142789
|
-
const fileName = `./${fileHash}-${import_node_path13.default.basename(args.path)}`;
|
|
142790
|
-
const { rule } = rulesMatchers.find(({ regex }) => regex.test(fileName)) || {};
|
|
142791
|
-
if (rule) {
|
|
142792
|
-
modules.push({
|
|
142793
|
-
name: fileName,
|
|
142794
|
-
content: fileContent,
|
|
142795
|
-
type: RuleTypeToModuleType[rule.type]
|
|
142796
|
-
});
|
|
142797
|
-
return {
|
|
142798
|
-
path: fileName,
|
|
142799
|
-
external: props.format === "modules",
|
|
142800
|
-
namespace: `wrangler-module-${rule.type}`,
|
|
142801
|
-
watchFiles: [filePath]
|
|
142802
|
-
};
|
|
142803
|
-
}
|
|
142804
|
-
}
|
|
142805
|
-
);
|
|
142806
|
-
}
|
|
142807
|
-
rules?.forEach((rule) => {
|
|
142808
|
-
if (rule.type === "ESModule" || rule.type === "CommonJS")
|
|
142809
|
-
return;
|
|
142810
|
-
rule.globs.forEach((glob) => {
|
|
142811
|
-
build5.onResolve(
|
|
142812
|
-
{ filter: (0, import_glob_to_regexp.default)(glob) },
|
|
142813
|
-
async (args) => {
|
|
142814
|
-
const filePath = import_node_path13.default.join(args.resolveDir, args.path);
|
|
142815
|
-
const fileContent = await (0, import_promises2.readFile)(filePath);
|
|
142816
|
-
const fileHash = import_node_crypto.default.createHash("sha1").update(fileContent).digest("hex");
|
|
142817
|
-
const fileName = `./${fileHash}-${import_node_path13.default.basename(args.path)}`;
|
|
142818
|
-
modules.push({
|
|
142819
|
-
name: fileName,
|
|
142820
|
-
content: fileContent,
|
|
142821
|
-
type: RuleTypeToModuleType[rule.type]
|
|
142822
|
-
});
|
|
142823
|
-
return {
|
|
142824
|
-
path: fileName,
|
|
142825
|
-
external: props.format === "modules",
|
|
142826
|
-
namespace: `wrangler-module-${rule.type}`,
|
|
142827
|
-
watchFiles: [filePath]
|
|
142828
|
-
};
|
|
142829
|
-
}
|
|
142830
|
-
);
|
|
142831
|
-
if (props.format === "service-worker") {
|
|
142832
|
-
build5.onLoad(
|
|
142833
|
-
{ filter: (0, import_glob_to_regexp.default)(glob) },
|
|
142834
|
-
async (args) => {
|
|
142835
|
-
return {
|
|
142836
|
-
contents: `export default ${args.path.replace(
|
|
142837
|
-
/[^a-zA-Z0-9_$]/g,
|
|
142838
|
-
"_"
|
|
142839
|
-
)};`
|
|
142840
|
-
};
|
|
142841
|
-
}
|
|
142842
|
-
);
|
|
142843
|
-
}
|
|
142844
|
-
});
|
|
142845
|
-
});
|
|
142846
|
-
rulesToRemove.forEach((rule) => {
|
|
142847
|
-
rule.globs.forEach((glob) => {
|
|
142848
|
-
build5.onResolve(
|
|
142849
|
-
{ filter: (0, import_glob_to_regexp.default)(glob) },
|
|
142850
|
-
async (args) => {
|
|
142851
|
-
throw new Error(
|
|
142852
|
-
`The file ${args.path} matched a module rule in your configuration (${JSON.stringify(
|
|
142853
|
-
rule
|
|
142854
|
-
)}), but was ignored because a previous rule with the same type was not marked as \`fallthrough = true\`.`
|
|
142855
|
-
);
|
|
142856
|
-
}
|
|
142857
|
-
);
|
|
142858
|
-
});
|
|
142859
|
-
});
|
|
142860
|
-
}
|
|
142861
|
-
}
|
|
142862
|
-
};
|
|
142863
|
-
}
|
|
142864
|
-
|
|
142865
|
-
// src/dev/local.tsx
|
|
142866
|
-
function Local(props) {
|
|
142867
|
-
const { inspectorUrl } = useLocalWorker(props);
|
|
142868
|
-
useInspector({
|
|
142869
|
-
inspectorUrl,
|
|
142870
|
-
port: props.inspectorPort,
|
|
142871
|
-
logToTerminal: false
|
|
142872
|
-
});
|
|
142873
|
-
return null;
|
|
142874
|
-
}
|
|
142875
|
-
function useLocalWorker({
|
|
142876
|
-
name: workerName,
|
|
142877
|
-
bundle,
|
|
142878
|
-
format: format6,
|
|
142879
|
-
compatibilityDate,
|
|
142880
|
-
compatibilityFlags,
|
|
142881
|
-
usageModel,
|
|
142882
|
-
bindings,
|
|
142883
|
-
workerDefinitions,
|
|
142884
|
-
assetPaths,
|
|
142885
|
-
port,
|
|
142886
|
-
inspectorPort,
|
|
142887
|
-
rules,
|
|
142888
|
-
localPersistencePath,
|
|
142889
|
-
liveReload,
|
|
142890
|
-
ip,
|
|
142891
|
-
crons,
|
|
142892
|
-
queueConsumers,
|
|
142893
|
-
localProtocol,
|
|
142894
|
-
localUpstream,
|
|
142895
|
-
inspect: inspect2,
|
|
142896
|
-
onReady,
|
|
142897
|
-
logPrefix,
|
|
142898
|
-
enablePagesAssetsServiceBinding,
|
|
142899
|
-
experimentalLocal
|
|
142900
|
-
}) {
|
|
142901
|
-
const local = (0, import_react3.useRef)();
|
|
142902
|
-
const experimentalLocalRef = (0, import_react3.useRef)();
|
|
142903
|
-
const removeSignalExitListener = (0, import_react3.useRef)();
|
|
142904
|
-
const removeExperimentalLocalSignalExitListener = (0, import_react3.useRef)();
|
|
142905
|
-
const [inspectorUrl, setInspectorUrl] = (0, import_react3.useState)();
|
|
142906
|
-
(0, import_react3.useEffect)(() => {
|
|
142907
|
-
if (bindings.services && bindings.services.length > 0) {
|
|
142908
|
-
logger.warn(
|
|
142909
|
-
"\u2394 Support for service bindings in local mode is experimental and may change."
|
|
142910
|
-
);
|
|
142911
|
-
}
|
|
142912
|
-
}, [bindings.services]);
|
|
142913
|
-
(0, import_react3.useEffect)(() => {
|
|
142914
|
-
const externalDurableObjects = (bindings.durable_objects?.bindings || []).filter((binding) => binding.script_name);
|
|
142915
|
-
if (externalDurableObjects.length > 0) {
|
|
142916
|
-
logger.warn(
|
|
142917
|
-
"\u2394 Support for external Durable Objects in local mode is experimental and may change."
|
|
142918
|
-
);
|
|
142919
|
-
}
|
|
142920
|
-
}, [bindings.durable_objects?.bindings]);
|
|
142921
|
-
(0, import_react3.useEffect)(() => {
|
|
142922
|
-
const abortController = new AbortController();
|
|
142923
|
-
async function startLocalWorker() {
|
|
142924
|
-
if (!bundle || !format6)
|
|
142925
|
-
return;
|
|
142926
|
-
await waitForPortToBeAvailable(port, {
|
|
142927
|
-
retryPeriod: 200,
|
|
142928
|
-
timeout: 2e3,
|
|
142929
|
-
abortSignal: abortController.signal
|
|
142930
|
-
});
|
|
142931
|
-
for (const module2 of bundle.modules) {
|
|
142932
|
-
await (0, import_promises3.writeFile)(
|
|
142933
|
-
import_node_path14.default.join(import_node_path14.default.dirname(bundle.path), module2.name),
|
|
142934
|
-
module2.content
|
|
142935
|
-
);
|
|
142936
|
-
}
|
|
142937
|
-
const scriptPath = (0, import_node_fs5.realpathSync)(bundle.path);
|
|
142938
|
-
const upstream = typeof localUpstream === "string" ? `${localProtocol}://${localUpstream}` : void 0;
|
|
142939
|
-
const {
|
|
142940
|
-
externalDurableObjects,
|
|
142941
|
-
internalDurableObjects,
|
|
142942
|
-
wasmBindings,
|
|
142943
|
-
textBlobBindings,
|
|
142944
|
-
dataBlobBindings
|
|
142945
|
-
} = setupBindings({
|
|
142946
|
-
wasm_modules: bindings.wasm_modules,
|
|
142947
|
-
text_blobs: bindings.text_blobs,
|
|
142948
|
-
data_blobs: bindings.data_blobs,
|
|
142949
|
-
durable_objects: bindings.durable_objects,
|
|
142950
|
-
format: format6,
|
|
142951
|
-
bundle
|
|
142952
|
-
});
|
|
142953
|
-
const { forkOptions, miniflareCLIPath, options: options6 } = setupMiniflareOptions({
|
|
142954
|
-
workerName,
|
|
142955
|
-
port,
|
|
142956
|
-
scriptPath,
|
|
142957
|
-
localProtocol,
|
|
142958
|
-
ip,
|
|
142959
|
-
format: format6,
|
|
142960
|
-
rules,
|
|
142961
|
-
compatibilityDate,
|
|
142962
|
-
compatibilityFlags,
|
|
142963
|
-
usageModel,
|
|
142964
|
-
kv_namespaces: bindings?.kv_namespaces,
|
|
142965
|
-
r2_buckets: bindings?.r2_buckets,
|
|
142966
|
-
queueBindings: bindings?.queues,
|
|
142967
|
-
queueConsumers,
|
|
142968
|
-
d1_databases: bindings?.d1_databases,
|
|
142969
|
-
internalDurableObjects,
|
|
142970
|
-
externalDurableObjects,
|
|
142971
|
-
localPersistencePath,
|
|
142972
|
-
liveReload,
|
|
142973
|
-
assetPaths,
|
|
142974
|
-
vars: bindings?.vars,
|
|
142975
|
-
wasmBindings,
|
|
142976
|
-
textBlobBindings,
|
|
142977
|
-
dataBlobBindings,
|
|
142978
|
-
crons,
|
|
142979
|
-
upstream,
|
|
142980
|
-
logPrefix,
|
|
142981
|
-
workerDefinitions,
|
|
142982
|
-
enablePagesAssetsServiceBinding
|
|
142983
|
-
});
|
|
142984
|
-
if (experimentalLocal) {
|
|
142985
|
-
const mf3Options = await transformLocalOptions(options6, format6, bundle);
|
|
142986
|
-
const current = experimentalLocalRef.current;
|
|
142987
|
-
if (current === void 0) {
|
|
142988
|
-
const Miniflare2 = await getMiniflare3Constructor();
|
|
142989
|
-
if (abortController.signal.aborted)
|
|
142990
|
-
return;
|
|
142991
|
-
const mf = new Miniflare2(mf3Options);
|
|
142992
|
-
experimentalLocalRef.current = mf;
|
|
142993
|
-
removeExperimentalLocalSignalExitListener.current = (0, import_signal_exit2.default)(() => {
|
|
142994
|
-
logger.log("\u2394 Shutting down experimental local server.");
|
|
142995
|
-
mf.dispose();
|
|
142996
|
-
experimentalLocalRef.current = void 0;
|
|
142997
|
-
});
|
|
142998
|
-
await mf.ready;
|
|
142999
|
-
} else {
|
|
143000
|
-
if (abortController.signal.aborted)
|
|
143001
|
-
return;
|
|
143002
|
-
logger.log("\u2394 Reloading experimental local server.");
|
|
143003
|
-
await current.setOptions(mf3Options);
|
|
143004
|
-
}
|
|
143005
|
-
return;
|
|
143006
|
-
}
|
|
143007
|
-
const nodeOptions = setupNodeOptions({ inspect: inspect2, ip, inspectorPort });
|
|
143008
|
-
logger.log("\u2394 Starting a local server...");
|
|
143009
|
-
const child = local.current = (0, import_node_child_process2.fork)(miniflareCLIPath, forkOptions, {
|
|
143010
|
-
cwd: import_node_path14.default.dirname(scriptPath),
|
|
143011
|
-
execArgv: nodeOptions,
|
|
143012
|
-
stdio: "pipe",
|
|
143013
|
-
env: {
|
|
143014
|
-
...process.env,
|
|
143015
|
-
FORCE_COLOR: import_chalk.default.supportsColor.hasBasic ? "1" : void 0
|
|
143016
|
-
}
|
|
143017
|
-
});
|
|
143018
|
-
child.on("message", async (messageString) => {
|
|
143019
|
-
const message = JSON.parse(messageString);
|
|
143020
|
-
if (message.ready) {
|
|
143021
|
-
if (workerName) {
|
|
143022
|
-
await registerWorker(workerName, {
|
|
143023
|
-
protocol: localProtocol,
|
|
143024
|
-
mode: "local",
|
|
143025
|
-
port,
|
|
143026
|
-
host: ip,
|
|
143027
|
-
durableObjects: internalDurableObjects.map((binding) => ({
|
|
143028
|
-
name: binding.name,
|
|
143029
|
-
className: binding.class_name
|
|
143030
|
-
})),
|
|
143031
|
-
...message.durableObjectsPort ? {
|
|
143032
|
-
durableObjectsHost: ip,
|
|
143033
|
-
durableObjectsPort: message.durableObjectsPort
|
|
143034
|
-
} : {}
|
|
143035
|
-
});
|
|
143036
|
-
}
|
|
143037
|
-
onReady?.(ip, message.mfPort);
|
|
143038
|
-
}
|
|
143039
|
-
});
|
|
143040
|
-
child.on("close", (code) => {
|
|
143041
|
-
if (code) {
|
|
143042
|
-
logger.log(`Miniflare process exited with code ${code}`);
|
|
143043
|
-
}
|
|
143044
|
-
});
|
|
143045
|
-
child.stdout?.on("data", (data) => {
|
|
143046
|
-
process.stdout.write(data);
|
|
143047
|
-
});
|
|
143048
|
-
let stderrData = "";
|
|
143049
|
-
let inspectorUrlFound = false;
|
|
143050
|
-
child.stderr?.on("data", (data) => {
|
|
143051
|
-
if (!inspectorUrlFound) {
|
|
143052
|
-
stderrData += data.toString();
|
|
143053
|
-
const matches = /Debugger listening on (ws:\/\/127\.0\.0\.1:\d+\/[A-Za-z0-9-]+)[\r|\n]/.exec(
|
|
143054
|
-
stderrData
|
|
143055
|
-
);
|
|
143056
|
-
if (matches) {
|
|
143057
|
-
inspectorUrlFound = true;
|
|
143058
|
-
setInspectorUrl(matches[1]);
|
|
143059
|
-
}
|
|
143060
|
-
}
|
|
143061
|
-
process.stderr.write(data);
|
|
143062
|
-
});
|
|
143063
|
-
child.on("exit", (code) => {
|
|
143064
|
-
if (code) {
|
|
143065
|
-
logger.error(`Miniflare process exited with code ${code}`);
|
|
143066
|
-
}
|
|
143067
|
-
});
|
|
143068
|
-
child.on("error", (error) => {
|
|
143069
|
-
logger.error(`Miniflare process failed to spawn`);
|
|
143070
|
-
logger.error(error);
|
|
143071
|
-
});
|
|
143072
|
-
removeSignalExitListener.current = (0, import_signal_exit2.default)((_code, _signal) => {
|
|
143073
|
-
logger.log("\u2394 Shutting down local server.");
|
|
143074
|
-
child.kill();
|
|
143075
|
-
local.current = void 0;
|
|
143076
|
-
});
|
|
143077
|
-
}
|
|
143078
|
-
startLocalWorker().catch((err2) => {
|
|
143079
|
-
logger.error("local worker:", err2);
|
|
143080
|
-
});
|
|
143081
|
-
return () => {
|
|
143082
|
-
abortController.abort();
|
|
143083
|
-
if (local.current) {
|
|
143084
|
-
logger.log("\u2394 Shutting down local server.");
|
|
143085
|
-
local.current?.kill();
|
|
143086
|
-
local.current = void 0;
|
|
143087
|
-
}
|
|
143088
|
-
removeSignalExitListener.current?.();
|
|
143089
|
-
removeSignalExitListener.current = void 0;
|
|
143090
|
-
};
|
|
143091
|
-
}, [
|
|
143092
|
-
bundle,
|
|
143093
|
-
workerName,
|
|
143094
|
-
format6,
|
|
143095
|
-
port,
|
|
143096
|
-
inspectorPort,
|
|
143097
|
-
ip,
|
|
143098
|
-
queueConsumers,
|
|
143099
|
-
bindings.queues,
|
|
143100
|
-
bindings.durable_objects,
|
|
143101
|
-
bindings.kv_namespaces,
|
|
143102
|
-
bindings.r2_buckets,
|
|
143103
|
-
bindings.d1_databases,
|
|
143104
|
-
bindings.vars,
|
|
143105
|
-
bindings.services,
|
|
143106
|
-
workerDefinitions,
|
|
143107
|
-
compatibilityDate,
|
|
143108
|
-
compatibilityFlags,
|
|
143109
|
-
usageModel,
|
|
143110
|
-
localPersistencePath,
|
|
143111
|
-
liveReload,
|
|
143112
|
-
assetPaths,
|
|
143113
|
-
rules,
|
|
143114
|
-
bindings.wasm_modules,
|
|
143115
|
-
bindings.text_blobs,
|
|
143116
|
-
bindings.data_blobs,
|
|
143117
|
-
crons,
|
|
143118
|
-
localProtocol,
|
|
143119
|
-
localUpstream,
|
|
143120
|
-
inspect2,
|
|
143121
|
-
logPrefix,
|
|
143122
|
-
onReady,
|
|
143123
|
-
enablePagesAssetsServiceBinding,
|
|
143124
|
-
experimentalLocal
|
|
143125
|
-
]);
|
|
143126
|
-
(0, import_react3.useEffect)(
|
|
143127
|
-
() => () => {
|
|
143128
|
-
if (experimentalLocalRef.current) {
|
|
143129
|
-
logger.log("\u2394 Shutting down experimental local server.");
|
|
143130
|
-
experimentalLocalRef.current?.dispose().catch(() => {
|
|
143131
|
-
});
|
|
143132
|
-
experimentalLocalRef.current = void 0;
|
|
143133
|
-
}
|
|
143134
|
-
removeExperimentalLocalSignalExitListener.current?.();
|
|
143135
|
-
removeExperimentalLocalSignalExitListener.current = void 0;
|
|
143136
|
-
},
|
|
143137
|
-
[]
|
|
143138
|
-
);
|
|
143139
|
-
return { inspectorUrl };
|
|
143140
|
-
}
|
|
143141
|
-
function setupBindings({
|
|
143142
|
-
wasm_modules,
|
|
143143
|
-
text_blobs,
|
|
143144
|
-
data_blobs,
|
|
143145
|
-
durable_objects,
|
|
143146
|
-
format: format6,
|
|
143147
|
-
bundle
|
|
143148
|
-
}) {
|
|
143149
|
-
const wasmBindings = {};
|
|
143150
|
-
for (const [name, filePath] of Object.entries(wasm_modules || {})) {
|
|
143151
|
-
wasmBindings[name] = import_node_path14.default.join(process.cwd(), filePath);
|
|
143152
|
-
}
|
|
143153
|
-
const textBlobBindings = {};
|
|
143154
|
-
for (const [name, filePath] of Object.entries(text_blobs || {})) {
|
|
143155
|
-
textBlobBindings[name] = import_node_path14.default.join(process.cwd(), filePath);
|
|
143156
|
-
}
|
|
143157
|
-
const dataBlobBindings = {};
|
|
143158
|
-
for (const [name, filePath] of Object.entries(data_blobs || {})) {
|
|
143159
|
-
dataBlobBindings[name] = import_node_path14.default.join(process.cwd(), filePath);
|
|
143160
|
-
}
|
|
143161
|
-
if (format6 === "service-worker") {
|
|
143162
|
-
for (const { type: type2, name } of bundle.modules) {
|
|
143163
|
-
if (type2 === "compiled-wasm") {
|
|
143164
|
-
const identifier = name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
143165
|
-
wasmBindings[identifier] = name;
|
|
143166
|
-
} else if (type2 === "text") {
|
|
143167
|
-
const identifier = name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
143168
|
-
textBlobBindings[identifier] = name;
|
|
143169
|
-
} else if (type2 === "buffer") {
|
|
143170
|
-
const identifier = name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
143171
|
-
dataBlobBindings[identifier] = name;
|
|
143172
|
-
}
|
|
143173
|
-
}
|
|
143174
|
-
}
|
|
143175
|
-
const internalDurableObjects = (durable_objects?.bindings || []).filter(
|
|
143176
|
-
(binding) => !binding.script_name
|
|
143177
|
-
);
|
|
143178
|
-
const externalDurableObjects = (durable_objects?.bindings || []).filter(
|
|
143179
|
-
(binding) => binding.script_name
|
|
143180
|
-
);
|
|
143181
|
-
return {
|
|
143182
|
-
internalDurableObjects,
|
|
143183
|
-
externalDurableObjects,
|
|
143184
|
-
wasmBindings,
|
|
143185
|
-
textBlobBindings,
|
|
143186
|
-
dataBlobBindings
|
|
143187
|
-
};
|
|
143188
|
-
}
|
|
143189
|
-
function setupMiniflareOptions({
|
|
143190
|
-
workerName,
|
|
143191
|
-
port,
|
|
143192
|
-
scriptPath,
|
|
143193
|
-
localProtocol,
|
|
143194
|
-
ip,
|
|
143195
|
-
format: format6,
|
|
143196
|
-
rules,
|
|
143197
|
-
compatibilityDate,
|
|
143198
|
-
compatibilityFlags,
|
|
143199
|
-
usageModel,
|
|
143200
|
-
kv_namespaces,
|
|
143201
|
-
queueBindings,
|
|
143202
|
-
queueConsumers,
|
|
143203
|
-
r2_buckets,
|
|
143204
|
-
d1_databases,
|
|
143205
|
-
internalDurableObjects,
|
|
143206
|
-
externalDurableObjects,
|
|
143207
|
-
localPersistencePath,
|
|
143208
|
-
liveReload,
|
|
143209
|
-
assetPaths,
|
|
143210
|
-
vars,
|
|
143211
|
-
wasmBindings,
|
|
143212
|
-
textBlobBindings,
|
|
143213
|
-
dataBlobBindings,
|
|
143214
|
-
crons,
|
|
143215
|
-
upstream,
|
|
143216
|
-
logPrefix,
|
|
143217
|
-
workerDefinitions,
|
|
143218
|
-
enablePagesAssetsServiceBinding
|
|
143219
|
-
}) {
|
|
143220
|
-
const options6 = {
|
|
143221
|
-
name: workerName,
|
|
143222
|
-
port,
|
|
143223
|
-
scriptPath,
|
|
143224
|
-
https: localProtocol === "https",
|
|
143225
|
-
host: ip,
|
|
143226
|
-
modules: format6 === "modules",
|
|
143227
|
-
modulesRules: (rules || []).concat(DEFAULT_MODULE_RULES).map(({ type: type2, globs: include, fallthrough }) => ({
|
|
143228
|
-
type: type2,
|
|
143229
|
-
include,
|
|
143230
|
-
fallthrough
|
|
143231
|
-
})),
|
|
143232
|
-
compatibilityDate,
|
|
143233
|
-
compatibilityFlags,
|
|
143234
|
-
usageModel,
|
|
143235
|
-
kvNamespaces: kv_namespaces?.map((kv) => kv.binding),
|
|
143236
|
-
queueBindings: queueBindings?.map((queue) => {
|
|
143237
|
-
return { name: queue.binding, queueName: queue.queue_name };
|
|
143238
|
-
}),
|
|
143239
|
-
queueConsumers: queueConsumers?.map((consumer) => {
|
|
143240
|
-
const waitMs = consumer.max_batch_timeout ? 1e3 * consumer.max_batch_timeout : void 0;
|
|
143241
|
-
return {
|
|
143242
|
-
queueName: consumer.queue,
|
|
143243
|
-
maxBatchSize: consumer.max_batch_size,
|
|
143244
|
-
maxWaitMs: waitMs,
|
|
143245
|
-
maxRetries: consumer.max_retries,
|
|
143246
|
-
deadLetterQueue: consumer.dead_letter_queue
|
|
143247
|
-
};
|
|
143248
|
-
}),
|
|
143249
|
-
r2Buckets: r2_buckets?.map((r22) => r22.binding),
|
|
143250
|
-
durableObjects: Object.fromEntries(
|
|
143251
|
-
internalDurableObjects.map((binding) => [
|
|
143252
|
-
binding.name,
|
|
143253
|
-
binding.class_name
|
|
143254
|
-
])
|
|
143255
|
-
),
|
|
143256
|
-
externalDurableObjects: Object.fromEntries(
|
|
143257
|
-
externalDurableObjects.map((binding) => {
|
|
143258
|
-
const service = workerDefinitions && workerDefinitions[binding.script_name];
|
|
143259
|
-
if (!service)
|
|
143260
|
-
return [binding.name, void 0];
|
|
143261
|
-
const name = service.durableObjects.find(
|
|
143262
|
-
(durableObject) => durableObject.className === binding.class_name
|
|
143263
|
-
)?.name;
|
|
143264
|
-
if (!name)
|
|
143265
|
-
return [binding.name, void 0];
|
|
143266
|
-
return [
|
|
143267
|
-
binding.name,
|
|
143268
|
-
{
|
|
143269
|
-
name,
|
|
143270
|
-
host: service.durableObjectsHost,
|
|
143271
|
-
port: service.durableObjectsPort
|
|
143272
|
-
}
|
|
143273
|
-
];
|
|
143274
|
-
}).filter(([_2, details]) => !!details)
|
|
143275
|
-
),
|
|
143276
|
-
d1Databases: d1_databases?.map((db) => db.binding),
|
|
143277
|
-
...localPersistencePath ? {
|
|
143278
|
-
cachePersist: import_node_path14.default.join(localPersistencePath, "cache"),
|
|
143279
|
-
durableObjectsPersist: import_node_path14.default.join(localPersistencePath, "do"),
|
|
143280
|
-
kvPersist: import_node_path14.default.join(localPersistencePath, "kv"),
|
|
143281
|
-
r2Persist: import_node_path14.default.join(localPersistencePath, "r2"),
|
|
143282
|
-
d1Persist: import_node_path14.default.join(localPersistencePath, "d1")
|
|
143283
|
-
} : {
|
|
143284
|
-
cachePersist: true,
|
|
143285
|
-
durableObjectsPersist: true,
|
|
143286
|
-
kvPersist: true,
|
|
143287
|
-
r2Persist: true
|
|
143288
|
-
},
|
|
143289
|
-
liveReload,
|
|
143290
|
-
sitePath: assetPaths?.assetDirectory ? import_node_path14.default.join(assetPaths.baseDirectory, assetPaths.assetDirectory) : void 0,
|
|
143291
|
-
siteInclude: assetPaths?.includePatterns.length ? assetPaths?.includePatterns : void 0,
|
|
143292
|
-
siteExclude: assetPaths?.excludePatterns.length ? assetPaths.excludePatterns : void 0,
|
|
143293
|
-
bindings: vars,
|
|
143294
|
-
wasmBindings,
|
|
143295
|
-
textBlobBindings,
|
|
143296
|
-
dataBlobBindings,
|
|
143297
|
-
sourceMap: true,
|
|
143298
|
-
logUnhandledRejections: true,
|
|
143299
|
-
crons,
|
|
143300
|
-
upstream,
|
|
143301
|
-
logLevel: logger.loggerLevel,
|
|
143302
|
-
logOptions: logPrefix ? { prefix: logPrefix } : void 0,
|
|
143303
|
-
enablePagesAssetsServiceBinding
|
|
143304
|
-
};
|
|
143305
|
-
const miniflareCLIPath = import_node_path14.default.resolve(
|
|
143306
|
-
getBasePath(),
|
|
143307
|
-
"miniflare-dist/index.mjs"
|
|
143308
|
-
);
|
|
143309
|
-
const miniflareOptions = JSON.stringify(options6, null);
|
|
143310
|
-
const forkOptions = [miniflareOptions];
|
|
143311
|
-
if (enablePagesAssetsServiceBinding) {
|
|
143312
|
-
forkOptions.push(JSON.stringify(enablePagesAssetsServiceBinding));
|
|
143313
|
-
}
|
|
143314
|
-
return { miniflareCLIPath, forkOptions, options: options6 };
|
|
143315
|
-
}
|
|
143316
|
-
function setupNodeOptions({
|
|
143317
|
-
inspect: inspect2,
|
|
143318
|
-
ip,
|
|
143319
|
-
inspectorPort
|
|
143320
|
-
}) {
|
|
143321
|
-
const nodeOptions = [
|
|
143322
|
-
"--experimental-vm-modules",
|
|
143323
|
-
"--no-warnings"
|
|
143324
|
-
];
|
|
143325
|
-
if (inspect2) {
|
|
143326
|
-
nodeOptions.push(`--inspect=${ip}:${inspectorPort}`);
|
|
143327
|
-
}
|
|
143328
|
-
return nodeOptions;
|
|
143329
|
-
}
|
|
143330
|
-
function arrayToObject(values = []) {
|
|
143331
|
-
return Object.fromEntries(values.map((value) => [value, value]));
|
|
143332
|
-
}
|
|
143333
|
-
async function transformLocalOptions(mf2Options, format6, bundle) {
|
|
143334
|
-
const options6 = {
|
|
143335
|
-
...mf2Options,
|
|
143336
|
-
kvNamespaces: arrayToObject(mf2Options.kvNamespaces),
|
|
143337
|
-
r2Buckets: arrayToObject(mf2Options.r2Buckets),
|
|
143338
|
-
inspectorPort: await getPorts({ port: 9229 }),
|
|
143339
|
-
verbose: true
|
|
143340
|
-
};
|
|
143341
|
-
if (format6 === "modules") {
|
|
143342
|
-
const root = import_node_path14.default.dirname(bundle.path);
|
|
143343
|
-
import_node_assert3.default.strictEqual(bundle.type, "esm");
|
|
143344
|
-
options6.modules = [
|
|
143345
|
-
{
|
|
143346
|
-
type: "ESModule",
|
|
143347
|
-
path: import_node_path14.default.relative(root, bundle.path),
|
|
143348
|
-
contents: await (0, import_promises3.readFile)(bundle.path, "utf-8")
|
|
143349
|
-
},
|
|
143350
|
-
...bundle.modules.map((module2) => ({
|
|
143351
|
-
type: ModuleTypeToRuleType[module2.type ?? "esm"],
|
|
143352
|
-
path: module2.name,
|
|
143353
|
-
contents: module2.content
|
|
143354
|
-
}))
|
|
143355
|
-
];
|
|
143356
|
-
}
|
|
143357
|
-
return options6;
|
|
143358
|
-
}
|
|
143359
|
-
var Miniflare;
|
|
143360
|
-
async function getMiniflare3Constructor() {
|
|
143361
|
-
if (Miniflare === void 0) {
|
|
143362
|
-
({ Miniflare } = await npxImport("@miniflare/tre@3.0.0-next.5"));
|
|
143363
|
-
}
|
|
143364
|
-
return Miniflare;
|
|
143365
|
-
}
|
|
143366
|
-
|
|
143367
|
-
// src/dev/remote.tsx
|
|
143368
|
-
init_import_meta_url();
|
|
143369
|
-
var import_promises5 = require("node:fs/promises");
|
|
143370
|
-
var import_node_path16 = __toESM(require("node:path"));
|
|
143371
|
-
var import_react6 = __toESM(require_react());
|
|
143372
|
-
var import_react_error_boundary = __toESM(require_react_error_boundary_cjs());
|
|
143373
|
-
|
|
143374
|
-
// src/bundle-reporter.tsx
|
|
143375
|
-
init_import_meta_url();
|
|
143376
|
-
var import_node_buffer2 = require("node:buffer");
|
|
143377
|
-
var import_node_zlib = require("node:zlib");
|
|
143378
|
-
var ONE_KIB_BYTES = 1024;
|
|
143379
|
-
var ONE_MIB_BYTES = ONE_KIB_BYTES * 1024;
|
|
143380
|
-
async function getSize(modules) {
|
|
143381
|
-
const gzipSize = (0, import_node_zlib.gzipSync)(
|
|
143382
|
-
await new import_node_buffer2.Blob(modules.map((file) => file.content)).arrayBuffer()
|
|
143383
|
-
).byteLength;
|
|
143384
|
-
const aggregateSize = new import_node_buffer2.Blob(modules.map((file) => file.content)).size;
|
|
143385
|
-
return { size: aggregateSize, gzipSize };
|
|
143386
|
-
}
|
|
143387
|
-
async function printBundleSize(main2, modules) {
|
|
143388
|
-
const { size, gzipSize } = await getSize([...modules, main2]);
|
|
143389
|
-
const bundleReport = `${(size / ONE_KIB_BYTES).toFixed(2)} KiB / gzip: ${(gzipSize / ONE_KIB_BYTES).toFixed(2)} KiB`;
|
|
143390
|
-
logger.log(`Total Upload: ${bundleReport}`);
|
|
143391
|
-
if (gzipSize > ONE_MIB_BYTES && !process.env.NO_SCRIPT_SIZE_WARNING) {
|
|
143392
|
-
logger.warn(
|
|
143393
|
-
"We recommend keeping your script less than 1MiB (1024 KiB) after gzip. Exceeding past this can affect cold start time"
|
|
143394
|
-
);
|
|
143395
|
-
}
|
|
143396
|
-
}
|
|
143397
|
-
function printOffendingDependencies(dependencies) {
|
|
143398
|
-
const warning = [];
|
|
143399
|
-
const dependenciesSorted = Object.entries(dependencies);
|
|
143400
|
-
dependenciesSorted.sort(
|
|
143401
|
-
([_adep, aData], [_bdep, bData]) => bData.bytesInOutput - aData.bytesInOutput
|
|
143402
|
-
);
|
|
143403
|
-
const topLargest = dependenciesSorted.slice(0, 5);
|
|
143404
|
-
if (topLargest.length > 0) {
|
|
143405
|
-
warning.push(
|
|
143406
|
-
`Here are the ${topLargest.length} largest dependencies included in your script:`
|
|
143407
|
-
);
|
|
143408
|
-
for (const [dep, data] of topLargest) {
|
|
143409
|
-
warning.push(
|
|
143410
|
-
`- ${dep} - ${(data.bytesInOutput / ONE_KIB_BYTES).toFixed(2)} KiB`
|
|
143411
|
-
);
|
|
143412
|
-
}
|
|
143413
|
-
warning.push("If these are unnecessary, consider removing them");
|
|
143414
|
-
logger.warn(warning.join("\n"));
|
|
143415
|
-
}
|
|
143416
|
-
}
|
|
143417
|
-
|
|
143418
|
-
// src/create-worker-preview.ts
|
|
143419
|
-
init_import_meta_url();
|
|
143420
|
-
var import_node_url10 = require("node:url");
|
|
143421
|
-
var import_undici6 = __toESM(require_undici());
|
|
143422
|
-
|
|
143423
|
-
// src/cfetch/index.ts
|
|
143424
|
-
init_import_meta_url();
|
|
143425
|
-
var import_node_url9 = require("node:url");
|
|
143426
|
-
|
|
143427
142689
|
// src/cfetch/internal.ts
|
|
143428
142690
|
init_import_meta_url();
|
|
143429
|
-
var
|
|
142691
|
+
var import_node_assert4 = __toESM(require("node:assert"));
|
|
143430
142692
|
var import_undici4 = __toESM(require_undici());
|
|
143431
142693
|
|
|
143432
142694
|
// src/user/index.ts
|
|
@@ -143434,24 +142696,24 @@ init_import_meta_url();
|
|
|
143434
142696
|
|
|
143435
142697
|
// src/user/user.tsx
|
|
143436
142698
|
init_import_meta_url();
|
|
143437
|
-
var
|
|
143438
|
-
var
|
|
143439
|
-
var
|
|
142699
|
+
var import_node_assert3 = __toESM(require("node:assert"));
|
|
142700
|
+
var import_node_crypto2 = require("node:crypto");
|
|
142701
|
+
var import_node_fs5 = require("node:fs");
|
|
143440
142702
|
var import_node_http4 = __toESM(require("node:http"));
|
|
143441
|
-
var
|
|
143442
|
-
var
|
|
142703
|
+
var import_node_path13 = __toESM(require("node:path"));
|
|
142704
|
+
var import_node_url9 = __toESM(require("node:url"));
|
|
143443
142705
|
var import_node_util3 = require("node:util");
|
|
143444
142706
|
var import_toml3 = __toESM(require_toml());
|
|
143445
142707
|
var import_env = __toESM(require_dist());
|
|
143446
142708
|
var import_ink2 = __toESM(require_build2());
|
|
143447
142709
|
var import_ink_table = __toESM(require_dist2());
|
|
143448
|
-
var
|
|
142710
|
+
var import_react4 = __toESM(require_react());
|
|
143449
142711
|
var import_undici3 = __toESM(require_undici());
|
|
143450
142712
|
|
|
143451
142713
|
// src/config-cache.ts
|
|
143452
142714
|
init_import_meta_url();
|
|
143453
142715
|
var import_fs5 = require("fs");
|
|
143454
|
-
var
|
|
142716
|
+
var path12 = __toESM(require("path"));
|
|
143455
142717
|
|
|
143456
142718
|
// src/is-ci.ts
|
|
143457
142719
|
init_import_meta_url();
|
|
@@ -143484,7 +142746,7 @@ function getCacheFolder() {
|
|
|
143484
142746
|
const closestNodeModulesDirectory = findUpSync("node_modules", {
|
|
143485
142747
|
type: "directory"
|
|
143486
142748
|
});
|
|
143487
|
-
__cacheFolder = closestNodeModulesDirectory ?
|
|
142749
|
+
__cacheFolder = closestNodeModulesDirectory ? path12.join(closestNodeModulesDirectory, ".cache/wrangler") : null;
|
|
143488
142750
|
if (!__cacheFolder) {
|
|
143489
142751
|
logger.debug("No folder available to cache configuration");
|
|
143490
142752
|
}
|
|
@@ -143500,7 +142762,7 @@ function showCacheMessage(fields, folder) {
|
|
|
143500
142762
|
logger.debug(
|
|
143501
142763
|
`Retrieving cached values for ${arrayFormatter.format(
|
|
143502
142764
|
fields
|
|
143503
|
-
)} from ${
|
|
142765
|
+
)} from ${path12.relative(process.cwd(), folder)}`
|
|
143504
142766
|
);
|
|
143505
142767
|
cacheMessageShown = true;
|
|
143506
142768
|
}
|
|
@@ -143510,7 +142772,7 @@ function getConfigCache(fileName) {
|
|
|
143510
142772
|
try {
|
|
143511
142773
|
const cacheFolder = getCacheFolder();
|
|
143512
142774
|
if (cacheFolder) {
|
|
143513
|
-
const configCacheLocation =
|
|
142775
|
+
const configCacheLocation = path12.join(cacheFolder, fileName);
|
|
143514
142776
|
const configCache = JSON.parse(
|
|
143515
142777
|
(0, import_fs5.readFileSync)(configCacheLocation, "utf-8")
|
|
143516
142778
|
);
|
|
@@ -143526,9 +142788,9 @@ function saveToConfigCache(fileName, newValues) {
|
|
|
143526
142788
|
const cacheFolder = getCacheFolder();
|
|
143527
142789
|
if (cacheFolder) {
|
|
143528
142790
|
logger.debug(`Saving to cache: ${JSON.stringify(newValues)}`);
|
|
143529
|
-
const configCacheLocation =
|
|
142791
|
+
const configCacheLocation = path12.join(cacheFolder, fileName);
|
|
143530
142792
|
const existingValues = getConfigCache(fileName);
|
|
143531
|
-
(0, import_fs5.mkdirSync)(
|
|
142793
|
+
(0, import_fs5.mkdirSync)(path12.dirname(configCacheLocation), { recursive: true });
|
|
143532
142794
|
(0, import_fs5.writeFileSync)(
|
|
143533
142795
|
configCacheLocation,
|
|
143534
142796
|
JSON.stringify({ ...existingValues, ...newValues }, null, 2)
|
|
@@ -143547,7 +142809,99 @@ function purgeConfigCaches() {
|
|
|
143547
142809
|
init_import_meta_url();
|
|
143548
142810
|
var import_ink = __toESM(require_build2());
|
|
143549
142811
|
var import_ink_select_input = __toESM(require_build3());
|
|
143550
|
-
var
|
|
142812
|
+
var import_react3 = __toESM(require_react());
|
|
142813
|
+
|
|
142814
|
+
// src/cfetch/index.ts
|
|
142815
|
+
init_import_meta_url();
|
|
142816
|
+
var import_node_url8 = require("node:url");
|
|
142817
|
+
async function fetchResult(resource, init = {}, queryParams, abortSignal) {
|
|
142818
|
+
const json = await fetchInternal(
|
|
142819
|
+
resource,
|
|
142820
|
+
init,
|
|
142821
|
+
queryParams,
|
|
142822
|
+
abortSignal
|
|
142823
|
+
);
|
|
142824
|
+
if (json.success) {
|
|
142825
|
+
return json.result;
|
|
142826
|
+
} else {
|
|
142827
|
+
throwFetchError(resource, json);
|
|
142828
|
+
}
|
|
142829
|
+
}
|
|
142830
|
+
async function fetchListResult(resource, init = {}, queryParams) {
|
|
142831
|
+
const results = [];
|
|
142832
|
+
let getMoreResults = true;
|
|
142833
|
+
let cursor;
|
|
142834
|
+
while (getMoreResults) {
|
|
142835
|
+
if (cursor) {
|
|
142836
|
+
queryParams = new import_node_url8.URLSearchParams(queryParams);
|
|
142837
|
+
queryParams.set("cursor", cursor);
|
|
142838
|
+
}
|
|
142839
|
+
const json = await fetchInternal(
|
|
142840
|
+
resource,
|
|
142841
|
+
init,
|
|
142842
|
+
queryParams
|
|
142843
|
+
);
|
|
142844
|
+
if (json.success) {
|
|
142845
|
+
results.push(...json.result);
|
|
142846
|
+
if (hasCursor(json.result_info)) {
|
|
142847
|
+
cursor = json.result_info?.cursor;
|
|
142848
|
+
} else {
|
|
142849
|
+
getMoreResults = false;
|
|
142850
|
+
}
|
|
142851
|
+
} else {
|
|
142852
|
+
throwFetchError(resource, json);
|
|
142853
|
+
}
|
|
142854
|
+
}
|
|
142855
|
+
return results;
|
|
142856
|
+
}
|
|
142857
|
+
function throwFetchError(resource, response) {
|
|
142858
|
+
const error = new ParseError({
|
|
142859
|
+
text: `A request to the Cloudflare API (${resource}) failed.`,
|
|
142860
|
+
notes: response.errors.map((err2) => ({
|
|
142861
|
+
text: renderError(err2)
|
|
142862
|
+
}))
|
|
142863
|
+
});
|
|
142864
|
+
const code = response.errors[0]?.code;
|
|
142865
|
+
if (code) {
|
|
142866
|
+
error.code = code;
|
|
142867
|
+
}
|
|
142868
|
+
throw error;
|
|
142869
|
+
}
|
|
142870
|
+
function hasCursor(result_info) {
|
|
142871
|
+
const cursor = result_info?.cursor;
|
|
142872
|
+
return cursor !== void 0 && cursor !== null && cursor !== "";
|
|
142873
|
+
}
|
|
142874
|
+
function renderError(err2, level = 0) {
|
|
142875
|
+
const chainedMessages = err2.error_chain?.map(
|
|
142876
|
+
(chainedError) => `
|
|
142877
|
+
${" ".repeat(level)}- ${renderError(chainedError, level + 1)}`
|
|
142878
|
+
).join("\n") ?? "";
|
|
142879
|
+
return (err2.code ? `${err2.message} [code: ${err2.code}]` : err2.message) + chainedMessages;
|
|
142880
|
+
}
|
|
142881
|
+
async function fetchScriptContent(resource, init = {}, queryParams, abortSignal) {
|
|
142882
|
+
const response = await performApiFetch(
|
|
142883
|
+
resource,
|
|
142884
|
+
init,
|
|
142885
|
+
queryParams,
|
|
142886
|
+
abortSignal
|
|
142887
|
+
);
|
|
142888
|
+
logger.debug(
|
|
142889
|
+
"-- START CF API RESPONSE:",
|
|
142890
|
+
response.statusText,
|
|
142891
|
+
response.status
|
|
142892
|
+
);
|
|
142893
|
+
logger.debug("HEADERS:", { ...response.headers });
|
|
142894
|
+
logger.debug("-- END CF API RESPONSE");
|
|
142895
|
+
const contentType = response.headers.get("content-type");
|
|
142896
|
+
const usesModules = contentType?.startsWith("multipart");
|
|
142897
|
+
if (usesModules && contentType) {
|
|
142898
|
+
const form = await response.formData();
|
|
142899
|
+
const entries = Array.from(form.entries());
|
|
142900
|
+
return entries.map((e2) => e2[1]).join("\n");
|
|
142901
|
+
} else {
|
|
142902
|
+
return await response.text();
|
|
142903
|
+
}
|
|
142904
|
+
}
|
|
143551
142905
|
|
|
143552
142906
|
// src/user/env-vars.ts
|
|
143553
142907
|
init_import_meta_url();
|
|
@@ -143580,9 +142934,9 @@ var getCloudflareAccountIdFromEnv = getEnvironmentVariableFactory({
|
|
|
143580
142934
|
|
|
143581
142935
|
// src/user/choose-account.tsx
|
|
143582
142936
|
function ChooseAccount(props) {
|
|
143583
|
-
return /* @__PURE__ */
|
|
142937
|
+
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(import_ink.Text, {
|
|
143584
142938
|
bold: true
|
|
143585
|
-
}, "Select an account from below:"), /* @__PURE__ */
|
|
142939
|
+
}, "Select an account from below:"), /* @__PURE__ */ import_react3.default.createElement(import_ink_select_input.default, {
|
|
143586
142940
|
items: props.accounts.map((item) => ({
|
|
143587
142941
|
key: item.id,
|
|
143588
142942
|
label: item.name,
|
|
@@ -143636,10 +142990,10 @@ var generateAuthUrl = ({
|
|
|
143636
142990
|
|
|
143637
142991
|
// src/user/generate-random-state.ts
|
|
143638
142992
|
init_import_meta_url();
|
|
143639
|
-
var
|
|
142993
|
+
var import_node_crypto = require("node:crypto");
|
|
143640
142994
|
function generateRandomState(lengthOfState) {
|
|
143641
142995
|
const output = new Uint32Array(lengthOfState);
|
|
143642
|
-
|
|
142996
|
+
import_node_crypto.webcrypto.getRandomValues(output);
|
|
143643
142997
|
return Array.from(output).map((num2) => PKCE_CHARSET[num2 % PKCE_CHARSET.length]).join("");
|
|
143644
142998
|
}
|
|
143645
142999
|
|
|
@@ -143839,7 +143193,7 @@ function isReturningFromAuthServer(query) {
|
|
|
143839
143193
|
);
|
|
143840
143194
|
throw new ErrorInvalidReturnedStateParam();
|
|
143841
143195
|
}
|
|
143842
|
-
(0,
|
|
143196
|
+
(0, import_node_assert3.default)(!Array.isArray(code));
|
|
143843
143197
|
state.authorizationCode = code;
|
|
143844
143198
|
state.hasAuthCodeBeenExchangedForAccessToken = false;
|
|
143845
143199
|
return true;
|
|
@@ -143984,11 +143338,11 @@ function base64urlEncode(value) {
|
|
|
143984
143338
|
}
|
|
143985
143339
|
async function generatePKCECodes() {
|
|
143986
143340
|
const output = new Uint32Array(RECOMMENDED_CODE_VERIFIER_LENGTH);
|
|
143987
|
-
|
|
143341
|
+
import_node_crypto2.webcrypto.getRandomValues(output);
|
|
143988
143342
|
const codeVerifier = base64urlEncode(
|
|
143989
143343
|
Array.from(output).map((num2) => PKCE_CHARSET[num2 % PKCE_CHARSET.length]).join("")
|
|
143990
143344
|
);
|
|
143991
|
-
const buffer2 = await
|
|
143345
|
+
const buffer2 = await import_node_crypto2.webcrypto.subtle.digest(
|
|
143992
143346
|
"SHA-256",
|
|
143993
143347
|
new import_node_util3.TextEncoder().encode(codeVerifier)
|
|
143994
143348
|
);
|
|
@@ -144002,22 +143356,22 @@ async function generatePKCECodes() {
|
|
|
144002
143356
|
return { codeChallenge, codeVerifier };
|
|
144003
143357
|
}
|
|
144004
143358
|
function writeAuthConfigFile(config) {
|
|
144005
|
-
const authConfigFilePath =
|
|
143359
|
+
const authConfigFilePath = import_node_path13.default.join(
|
|
144006
143360
|
getGlobalWranglerConfigPath(),
|
|
144007
143361
|
USER_AUTH_CONFIG_FILE
|
|
144008
143362
|
);
|
|
144009
|
-
(0,
|
|
143363
|
+
(0, import_node_fs5.mkdirSync)(import_node_path13.default.dirname(authConfigFilePath), {
|
|
144010
143364
|
recursive: true
|
|
144011
143365
|
});
|
|
144012
|
-
(0,
|
|
144013
|
-
|
|
143366
|
+
(0, import_node_fs5.writeFileSync)(
|
|
143367
|
+
import_node_path13.default.join(authConfigFilePath),
|
|
144014
143368
|
import_toml3.default.stringify(config),
|
|
144015
143369
|
{ encoding: "utf-8" }
|
|
144016
143370
|
);
|
|
144017
143371
|
reinitialiseAuthTokens();
|
|
144018
143372
|
}
|
|
144019
143373
|
function readAuthConfigFile() {
|
|
144020
|
-
const authConfigFilePath =
|
|
143374
|
+
const authConfigFilePath = import_node_path13.default.join(
|
|
144021
143375
|
getGlobalWranglerConfigPath(),
|
|
144022
143376
|
USER_AUTH_CONFIG_FILE
|
|
144023
143377
|
);
|
|
@@ -144065,8 +143419,8 @@ async function login(props) {
|
|
|
144065
143419
|
resolve15(status);
|
|
144066
143420
|
});
|
|
144067
143421
|
}
|
|
144068
|
-
(0,
|
|
144069
|
-
const { pathname, query } =
|
|
143422
|
+
(0, import_node_assert3.default)(req.url, "This request doesn't have a URL");
|
|
143423
|
+
const { pathname, query } = import_node_url9.default.parse(req.url, true);
|
|
144070
143424
|
switch (pathname) {
|
|
144071
143425
|
case "/oauth/callback": {
|
|
144072
143426
|
let hasAuthCode = false;
|
|
@@ -144172,7 +143526,7 @@ async function logout() {
|
|
|
144172
143526
|
}
|
|
144173
143527
|
});
|
|
144174
143528
|
await response.text();
|
|
144175
|
-
(0,
|
|
143529
|
+
(0, import_node_fs5.rmSync)(import_node_path13.default.join(getGlobalWranglerConfigPath(), USER_AUTH_CONFIG_FILE));
|
|
144176
143530
|
logger.log(`Successfully logged out.`);
|
|
144177
143531
|
}
|
|
144178
143532
|
function listScopes(message = "\u{1F481} Available scopes:") {
|
|
@@ -144181,7 +143535,7 @@ function listScopes(message = "\u{1F481} Available scopes:") {
|
|
|
144181
143535
|
Scope: scope,
|
|
144182
143536
|
Description: Scopes[scope]
|
|
144183
143537
|
}));
|
|
144184
|
-
const { unmount } = (0, import_ink2.render)(/* @__PURE__ */
|
|
143538
|
+
const { unmount } = (0, import_ink2.render)(/* @__PURE__ */ import_react4.default.createElement(import_ink_table.default, {
|
|
144185
143539
|
data
|
|
144186
143540
|
}));
|
|
144187
143541
|
unmount();
|
|
@@ -144203,7 +143557,7 @@ async function getAccountId() {
|
|
|
144203
143557
|
const account = await new Promise(
|
|
144204
143558
|
(resolve15, reject) => {
|
|
144205
143559
|
const { unmount } = (0, import_ink2.render)(
|
|
144206
|
-
/* @__PURE__ */
|
|
143560
|
+
/* @__PURE__ */ import_react4.default.createElement(ChooseAccount, {
|
|
144207
143561
|
accounts,
|
|
144208
143562
|
onSelect: async (selected) => {
|
|
144209
143563
|
saveAccountToCache(selected);
|
|
@@ -144274,7 +143628,7 @@ var getCloudflareAPIBaseURL = getEnvironmentVariableFactory({
|
|
|
144274
143628
|
});
|
|
144275
143629
|
async function performApiFetch(resource, init = {}, queryParams, abortSignal) {
|
|
144276
143630
|
const method = init.method ?? "GET";
|
|
144277
|
-
(0,
|
|
143631
|
+
(0, import_node_assert4.default)(
|
|
144278
143632
|
resource.startsWith("/"),
|
|
144279
143633
|
`CF API fetch - resource path must start with a "/" but got "${resource}"`
|
|
144280
143634
|
);
|
|
@@ -144426,96 +143780,795 @@ async function fetchDashboardScript(resource, bodyInit = {}) {
|
|
|
144426
143780
|
}
|
|
144427
143781
|
}
|
|
144428
143782
|
|
|
144429
|
-
// src/
|
|
144430
|
-
|
|
144431
|
-
|
|
144432
|
-
|
|
144433
|
-
|
|
144434
|
-
|
|
144435
|
-
|
|
144436
|
-
);
|
|
144437
|
-
|
|
144438
|
-
|
|
144439
|
-
|
|
144440
|
-
|
|
143783
|
+
// src/module-collection.ts
|
|
143784
|
+
init_import_meta_url();
|
|
143785
|
+
var import_node_crypto3 = __toESM(require("node:crypto"));
|
|
143786
|
+
var import_promises2 = require("node:fs/promises");
|
|
143787
|
+
var import_node_path14 = __toESM(require("node:path"));
|
|
143788
|
+
var import_glob_to_regexp = __toESM(require_glob_to_regexp());
|
|
143789
|
+
function flipObject(obj) {
|
|
143790
|
+
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k]));
|
|
143791
|
+
}
|
|
143792
|
+
var RuleTypeToModuleType = {
|
|
143793
|
+
ESModule: "esm",
|
|
143794
|
+
CommonJS: "commonjs",
|
|
143795
|
+
CompiledWasm: "compiled-wasm",
|
|
143796
|
+
Data: "buffer",
|
|
143797
|
+
Text: "text"
|
|
143798
|
+
};
|
|
143799
|
+
var ModuleTypeToRuleType = flipObject(RuleTypeToModuleType);
|
|
143800
|
+
var DEFAULT_MODULE_RULES = [
|
|
143801
|
+
{ type: "Text", globs: ["**/*.txt", "**/*.html"] },
|
|
143802
|
+
{ type: "Data", globs: ["**/*.bin"] },
|
|
143803
|
+
{ type: "CompiledWasm", globs: ["**/*.wasm"] }
|
|
143804
|
+
];
|
|
143805
|
+
function createModuleCollector(props) {
|
|
143806
|
+
const rules = [
|
|
143807
|
+
...props.rules || [],
|
|
143808
|
+
...DEFAULT_MODULE_RULES
|
|
143809
|
+
];
|
|
143810
|
+
const completedRuleLocations = {};
|
|
143811
|
+
let index = 0;
|
|
143812
|
+
const rulesToRemove = [];
|
|
143813
|
+
for (const rule of rules) {
|
|
143814
|
+
if (rule.type in completedRuleLocations) {
|
|
143815
|
+
if (rules[completedRuleLocations[rule.type]].fallthrough !== false) {
|
|
143816
|
+
if (index < (props.rules || []).length) {
|
|
143817
|
+
logger.warn(
|
|
143818
|
+
`The module rule at position ${index} (${JSON.stringify(
|
|
143819
|
+
rule
|
|
143820
|
+
)}) has the same type as a previous rule (at position ${completedRuleLocations[rule.type]}, ${JSON.stringify(
|
|
143821
|
+
rules[completedRuleLocations[rule.type]]
|
|
143822
|
+
)}). This rule will be ignored. To the previous rule, add \`fallthrough = true\` to allow this one to also be used, or \`fallthrough = false\` to silence this warning.`
|
|
143823
|
+
);
|
|
143824
|
+
} else {
|
|
143825
|
+
logger.warn(
|
|
143826
|
+
`The default module rule ${JSON.stringify(
|
|
143827
|
+
rule
|
|
143828
|
+
)} has the same type as a previous rule (at position ${completedRuleLocations[rule.type]}, ${JSON.stringify(
|
|
143829
|
+
rules[completedRuleLocations[rule.type]]
|
|
143830
|
+
)}). This rule will be ignored. To the previous rule, add \`fallthrough = true\` to allow the default one to also be used, or \`fallthrough = false\` to silence this warning.`
|
|
143831
|
+
);
|
|
143832
|
+
}
|
|
143833
|
+
}
|
|
143834
|
+
rulesToRemove.push(rule);
|
|
143835
|
+
}
|
|
143836
|
+
if (!(rule.type in completedRuleLocations) && rule.fallthrough !== true) {
|
|
143837
|
+
completedRuleLocations[rule.type] = index;
|
|
143838
|
+
}
|
|
143839
|
+
index++;
|
|
144441
143840
|
}
|
|
143841
|
+
rulesToRemove.forEach((rule) => rules.splice(rules.indexOf(rule), 1));
|
|
143842
|
+
const modules = [];
|
|
143843
|
+
return {
|
|
143844
|
+
modules,
|
|
143845
|
+
plugin: {
|
|
143846
|
+
name: "wrangler-module-collector",
|
|
143847
|
+
setup(build5) {
|
|
143848
|
+
build5.onStart(() => {
|
|
143849
|
+
modules.splice(0);
|
|
143850
|
+
});
|
|
143851
|
+
const rulesMatchers = rules.flatMap((rule) => {
|
|
143852
|
+
return rule.globs.map((glob) => {
|
|
143853
|
+
const regex = (0, import_glob_to_regexp.default)(glob);
|
|
143854
|
+
return {
|
|
143855
|
+
regex,
|
|
143856
|
+
rule
|
|
143857
|
+
};
|
|
143858
|
+
});
|
|
143859
|
+
});
|
|
143860
|
+
if (props.wrangler1xlegacyModuleReferences.fileNames.size > 0) {
|
|
143861
|
+
build5.onResolve(
|
|
143862
|
+
{
|
|
143863
|
+
filter: new RegExp(
|
|
143864
|
+
"^(" + [...props.wrangler1xlegacyModuleReferences.fileNames].map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|") + ")$"
|
|
143865
|
+
)
|
|
143866
|
+
},
|
|
143867
|
+
async (args) => {
|
|
143868
|
+
if (args.kind !== "import-statement" && args.kind !== "require-call") {
|
|
143869
|
+
return;
|
|
143870
|
+
}
|
|
143871
|
+
logger.warn(
|
|
143872
|
+
`Deprecation: detected a legacy module import in "./${import_node_path14.default.relative(
|
|
143873
|
+
process.cwd(),
|
|
143874
|
+
args.importer
|
|
143875
|
+
)}". This will stop working in the future. Replace references to "${args.path}" with "./${args.path}";`
|
|
143876
|
+
);
|
|
143877
|
+
const filePath = import_node_path14.default.join(
|
|
143878
|
+
props.wrangler1xlegacyModuleReferences.rootDirectory,
|
|
143879
|
+
args.path
|
|
143880
|
+
);
|
|
143881
|
+
const fileContent = await (0, import_promises2.readFile)(filePath);
|
|
143882
|
+
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
|
143883
|
+
const fileName = `./${fileHash}-${import_node_path14.default.basename(args.path)}`;
|
|
143884
|
+
const { rule } = rulesMatchers.find(({ regex }) => regex.test(fileName)) || {};
|
|
143885
|
+
if (rule) {
|
|
143886
|
+
modules.push({
|
|
143887
|
+
name: fileName,
|
|
143888
|
+
content: fileContent,
|
|
143889
|
+
type: RuleTypeToModuleType[rule.type]
|
|
143890
|
+
});
|
|
143891
|
+
return {
|
|
143892
|
+
path: fileName,
|
|
143893
|
+
external: props.format === "modules",
|
|
143894
|
+
namespace: `wrangler-module-${rule.type}`,
|
|
143895
|
+
watchFiles: [filePath]
|
|
143896
|
+
};
|
|
143897
|
+
}
|
|
143898
|
+
}
|
|
143899
|
+
);
|
|
143900
|
+
}
|
|
143901
|
+
rules?.forEach((rule) => {
|
|
143902
|
+
if (rule.type === "ESModule" || rule.type === "CommonJS")
|
|
143903
|
+
return;
|
|
143904
|
+
rule.globs.forEach((glob) => {
|
|
143905
|
+
build5.onResolve(
|
|
143906
|
+
{ filter: (0, import_glob_to_regexp.default)(glob) },
|
|
143907
|
+
async (args) => {
|
|
143908
|
+
const filePath = import_node_path14.default.join(args.resolveDir, args.path);
|
|
143909
|
+
const fileContent = await (0, import_promises2.readFile)(filePath);
|
|
143910
|
+
const fileHash = import_node_crypto3.default.createHash("sha1").update(fileContent).digest("hex");
|
|
143911
|
+
const fileName = `./${fileHash}-${import_node_path14.default.basename(args.path)}`;
|
|
143912
|
+
modules.push({
|
|
143913
|
+
name: fileName,
|
|
143914
|
+
content: fileContent,
|
|
143915
|
+
type: RuleTypeToModuleType[rule.type]
|
|
143916
|
+
});
|
|
143917
|
+
return {
|
|
143918
|
+
path: fileName,
|
|
143919
|
+
external: props.format === "modules",
|
|
143920
|
+
namespace: `wrangler-module-${rule.type}`,
|
|
143921
|
+
watchFiles: [filePath]
|
|
143922
|
+
};
|
|
143923
|
+
}
|
|
143924
|
+
);
|
|
143925
|
+
if (props.format === "service-worker") {
|
|
143926
|
+
build5.onLoad(
|
|
143927
|
+
{ filter: (0, import_glob_to_regexp.default)(glob) },
|
|
143928
|
+
async (args) => {
|
|
143929
|
+
return {
|
|
143930
|
+
contents: `export default ${args.path.replace(
|
|
143931
|
+
/[^a-zA-Z0-9_$]/g,
|
|
143932
|
+
"_"
|
|
143933
|
+
)};`
|
|
143934
|
+
};
|
|
143935
|
+
}
|
|
143936
|
+
);
|
|
143937
|
+
}
|
|
143938
|
+
});
|
|
143939
|
+
});
|
|
143940
|
+
rulesToRemove.forEach((rule) => {
|
|
143941
|
+
rule.globs.forEach((glob) => {
|
|
143942
|
+
build5.onResolve(
|
|
143943
|
+
{ filter: (0, import_glob_to_regexp.default)(glob) },
|
|
143944
|
+
async (args) => {
|
|
143945
|
+
throw new Error(
|
|
143946
|
+
`The file ${args.path} matched a module rule in your configuration (${JSON.stringify(
|
|
143947
|
+
rule
|
|
143948
|
+
)}), but was ignored because a previous rule with the same type was not marked as \`fallthrough = true\`.`
|
|
143949
|
+
);
|
|
143950
|
+
}
|
|
143951
|
+
);
|
|
143952
|
+
});
|
|
143953
|
+
});
|
|
143954
|
+
}
|
|
143955
|
+
}
|
|
143956
|
+
};
|
|
144442
143957
|
}
|
|
144443
|
-
|
|
144444
|
-
|
|
144445
|
-
|
|
144446
|
-
|
|
144447
|
-
|
|
144448
|
-
|
|
144449
|
-
|
|
144450
|
-
|
|
143958
|
+
|
|
143959
|
+
// src/dev/local.tsx
|
|
143960
|
+
function Local(props) {
|
|
143961
|
+
const { inspectorUrl } = useLocalWorker(props);
|
|
143962
|
+
useInspector({
|
|
143963
|
+
inspectorUrl,
|
|
143964
|
+
port: props.inspectorPort,
|
|
143965
|
+
logToTerminal: props.experimentalLocal ?? false
|
|
143966
|
+
});
|
|
143967
|
+
return null;
|
|
143968
|
+
}
|
|
143969
|
+
function useLocalWorker({
|
|
143970
|
+
name: workerName,
|
|
143971
|
+
bundle,
|
|
143972
|
+
format: format6,
|
|
143973
|
+
compatibilityDate,
|
|
143974
|
+
compatibilityFlags,
|
|
143975
|
+
usageModel,
|
|
143976
|
+
bindings,
|
|
143977
|
+
workerDefinitions,
|
|
143978
|
+
assetPaths,
|
|
143979
|
+
port,
|
|
143980
|
+
inspectorPort,
|
|
143981
|
+
rules,
|
|
143982
|
+
localPersistencePath,
|
|
143983
|
+
liveReload,
|
|
143984
|
+
ip,
|
|
143985
|
+
crons,
|
|
143986
|
+
queueConsumers,
|
|
143987
|
+
localProtocol,
|
|
143988
|
+
localUpstream,
|
|
143989
|
+
inspect: inspect2,
|
|
143990
|
+
onReady,
|
|
143991
|
+
logPrefix,
|
|
143992
|
+
enablePagesAssetsServiceBinding,
|
|
143993
|
+
experimentalLocal,
|
|
143994
|
+
accountId,
|
|
143995
|
+
experimentalLocalRemoteKv
|
|
143996
|
+
}) {
|
|
143997
|
+
const local = (0, import_react5.useRef)();
|
|
143998
|
+
const experimentalLocalRef = (0, import_react5.useRef)();
|
|
143999
|
+
const removeSignalExitListener = (0, import_react5.useRef)();
|
|
144000
|
+
const removeExperimentalLocalSignalExitListener = (0, import_react5.useRef)();
|
|
144001
|
+
const [inspectorUrl, setInspectorUrl] = (0, import_react5.useState)();
|
|
144002
|
+
(0, import_react5.useEffect)(() => {
|
|
144003
|
+
if (bindings.services && bindings.services.length > 0) {
|
|
144004
|
+
logger.warn(
|
|
144005
|
+
"\u2394 Support for service bindings in local mode is experimental and may change."
|
|
144006
|
+
);
|
|
144451
144007
|
}
|
|
144452
|
-
|
|
144453
|
-
|
|
144454
|
-
|
|
144455
|
-
|
|
144456
|
-
|
|
144457
|
-
|
|
144458
|
-
|
|
144459
|
-
|
|
144460
|
-
|
|
144461
|
-
|
|
144462
|
-
|
|
144008
|
+
}, [bindings.services]);
|
|
144009
|
+
(0, import_react5.useEffect)(() => {
|
|
144010
|
+
const externalDurableObjects = (bindings.durable_objects?.bindings || []).filter((binding) => binding.script_name);
|
|
144011
|
+
if (externalDurableObjects.length > 0) {
|
|
144012
|
+
logger.warn(
|
|
144013
|
+
"\u2394 Support for external Durable Objects in local mode is experimental and may change."
|
|
144014
|
+
);
|
|
144015
|
+
}
|
|
144016
|
+
}, [bindings.durable_objects?.bindings]);
|
|
144017
|
+
(0, import_react5.useEffect)(() => {
|
|
144018
|
+
const abortController = new AbortController();
|
|
144019
|
+
async function startLocalWorker() {
|
|
144020
|
+
if (!bundle || !format6)
|
|
144021
|
+
return;
|
|
144022
|
+
await waitForPortToBeAvailable(port, {
|
|
144023
|
+
retryPeriod: 200,
|
|
144024
|
+
timeout: 2e3,
|
|
144025
|
+
abortSignal: abortController.signal
|
|
144026
|
+
});
|
|
144027
|
+
for (const module2 of bundle.modules) {
|
|
144028
|
+
await (0, import_promises3.writeFile)(
|
|
144029
|
+
import_node_path15.default.join(import_node_path15.default.dirname(bundle.path), module2.name),
|
|
144030
|
+
module2.content
|
|
144031
|
+
);
|
|
144463
144032
|
}
|
|
144464
|
-
|
|
144465
|
-
|
|
144033
|
+
const scriptPath = (0, import_node_fs6.realpathSync)(bundle.path);
|
|
144034
|
+
const upstream = typeof localUpstream === "string" ? `${localProtocol}://${localUpstream}` : void 0;
|
|
144035
|
+
const {
|
|
144036
|
+
externalDurableObjects,
|
|
144037
|
+
internalDurableObjects,
|
|
144038
|
+
wasmBindings,
|
|
144039
|
+
textBlobBindings,
|
|
144040
|
+
dataBlobBindings
|
|
144041
|
+
} = setupBindings({
|
|
144042
|
+
wasm_modules: bindings.wasm_modules,
|
|
144043
|
+
text_blobs: bindings.text_blobs,
|
|
144044
|
+
data_blobs: bindings.data_blobs,
|
|
144045
|
+
durable_objects: bindings.durable_objects,
|
|
144046
|
+
format: format6,
|
|
144047
|
+
bundle
|
|
144048
|
+
});
|
|
144049
|
+
const { forkOptions, miniflareCLIPath, options: options6 } = setupMiniflareOptions({
|
|
144050
|
+
workerName,
|
|
144051
|
+
port,
|
|
144052
|
+
scriptPath,
|
|
144053
|
+
localProtocol,
|
|
144054
|
+
ip,
|
|
144055
|
+
format: format6,
|
|
144056
|
+
rules,
|
|
144057
|
+
compatibilityDate,
|
|
144058
|
+
compatibilityFlags,
|
|
144059
|
+
usageModel,
|
|
144060
|
+
kv_namespaces: bindings?.kv_namespaces,
|
|
144061
|
+
r2_buckets: bindings?.r2_buckets,
|
|
144062
|
+
queueBindings: bindings?.queues,
|
|
144063
|
+
queueConsumers,
|
|
144064
|
+
d1_databases: bindings?.d1_databases,
|
|
144065
|
+
internalDurableObjects,
|
|
144066
|
+
externalDurableObjects,
|
|
144067
|
+
localPersistencePath,
|
|
144068
|
+
liveReload,
|
|
144069
|
+
assetPaths,
|
|
144070
|
+
vars: bindings?.vars,
|
|
144071
|
+
wasmBindings,
|
|
144072
|
+
textBlobBindings,
|
|
144073
|
+
dataBlobBindings,
|
|
144074
|
+
crons,
|
|
144075
|
+
upstream,
|
|
144076
|
+
logPrefix,
|
|
144077
|
+
workerDefinitions,
|
|
144078
|
+
enablePagesAssetsServiceBinding
|
|
144079
|
+
});
|
|
144080
|
+
if (experimentalLocal) {
|
|
144081
|
+
const mf3Options = await transformLocalOptions({
|
|
144082
|
+
miniflare2Options: options6,
|
|
144083
|
+
format: format6,
|
|
144084
|
+
bundle,
|
|
144085
|
+
kvNamespaces: bindings?.kv_namespaces,
|
|
144086
|
+
r2Buckets: bindings?.r2_buckets,
|
|
144087
|
+
authenticatedAccountId: accountId,
|
|
144088
|
+
kvRemote: experimentalLocalRemoteKv,
|
|
144089
|
+
inspectorPort
|
|
144090
|
+
});
|
|
144091
|
+
const current = experimentalLocalRef.current;
|
|
144092
|
+
if (current === void 0) {
|
|
144093
|
+
const Miniflare2 = await getMiniflare3Constructor();
|
|
144094
|
+
if (abortController.signal.aborted)
|
|
144095
|
+
return;
|
|
144096
|
+
const mf = new Miniflare2(mf3Options);
|
|
144097
|
+
experimentalLocalRef.current = mf;
|
|
144098
|
+
removeExperimentalLocalSignalExitListener.current = (0, import_signal_exit2.default)(() => {
|
|
144099
|
+
logger.log("\u2394 Shutting down experimental local server.");
|
|
144100
|
+
mf.dispose();
|
|
144101
|
+
experimentalLocalRef.current = void 0;
|
|
144102
|
+
});
|
|
144103
|
+
await mf.ready;
|
|
144104
|
+
} else {
|
|
144105
|
+
if (abortController.signal.aborted)
|
|
144106
|
+
return;
|
|
144107
|
+
logger.log("\u2394 Reloading experimental local server.");
|
|
144108
|
+
await current.setOptions(mf3Options);
|
|
144109
|
+
}
|
|
144110
|
+
try {
|
|
144111
|
+
const inspectorJSONArr = await (await fetch(`http://127.0.0.1:${inspectorPort}/json`)).json();
|
|
144112
|
+
const foundInspectorURL = inspectorJSONArr?.find(
|
|
144113
|
+
(inspectorJSON) => inspectorJSON.id.startsWith("core:user")
|
|
144114
|
+
)?.webSocketDebuggerUrl;
|
|
144115
|
+
if (foundInspectorURL === void 0) {
|
|
144116
|
+
setInspectorUrl(void 0);
|
|
144117
|
+
} else {
|
|
144118
|
+
const url3 = new URL(foundInspectorURL);
|
|
144119
|
+
url3.username = `${Date.now()}-${Math.floor(
|
|
144120
|
+
Math.random() * Number.MAX_SAFE_INTEGER
|
|
144121
|
+
)}`;
|
|
144122
|
+
setInspectorUrl(url3.toString());
|
|
144123
|
+
}
|
|
144124
|
+
} catch (error) {
|
|
144125
|
+
logger.error("Error attempting to retrieve Debugger URL:", error);
|
|
144126
|
+
}
|
|
144127
|
+
return;
|
|
144128
|
+
}
|
|
144129
|
+
const nodeOptions = setupNodeOptions({ inspect: inspect2, ip, inspectorPort });
|
|
144130
|
+
logger.log("\u2394 Starting a local server...");
|
|
144131
|
+
const child = local.current = (0, import_node_child_process2.fork)(miniflareCLIPath, forkOptions, {
|
|
144132
|
+
cwd: import_node_path15.default.dirname(scriptPath),
|
|
144133
|
+
execArgv: nodeOptions,
|
|
144134
|
+
stdio: "pipe",
|
|
144135
|
+
env: {
|
|
144136
|
+
...process.env,
|
|
144137
|
+
FORCE_COLOR: import_chalk.default.supportsColor.hasBasic ? "1" : void 0
|
|
144138
|
+
}
|
|
144139
|
+
});
|
|
144140
|
+
child.on("message", async (messageString) => {
|
|
144141
|
+
const message = JSON.parse(messageString);
|
|
144142
|
+
if (message.ready) {
|
|
144143
|
+
if (workerName) {
|
|
144144
|
+
await registerWorker(workerName, {
|
|
144145
|
+
protocol: localProtocol,
|
|
144146
|
+
mode: "local",
|
|
144147
|
+
port,
|
|
144148
|
+
host: ip,
|
|
144149
|
+
durableObjects: internalDurableObjects.map((binding) => ({
|
|
144150
|
+
name: binding.name,
|
|
144151
|
+
className: binding.class_name
|
|
144152
|
+
})),
|
|
144153
|
+
...message.durableObjectsPort ? {
|
|
144154
|
+
durableObjectsHost: ip,
|
|
144155
|
+
durableObjectsPort: message.durableObjectsPort
|
|
144156
|
+
} : {}
|
|
144157
|
+
});
|
|
144158
|
+
}
|
|
144159
|
+
onReady?.(ip, message.mfPort);
|
|
144160
|
+
}
|
|
144161
|
+
});
|
|
144162
|
+
child.on("close", (code) => {
|
|
144163
|
+
if (code) {
|
|
144164
|
+
logger.log(`Miniflare process exited with code ${code}`);
|
|
144165
|
+
}
|
|
144166
|
+
});
|
|
144167
|
+
child.stdout?.on("data", (data) => {
|
|
144168
|
+
process.stdout.write(data);
|
|
144169
|
+
});
|
|
144170
|
+
let stderrData = "";
|
|
144171
|
+
let inspectorUrlFound = false;
|
|
144172
|
+
child.stderr?.on("data", (data) => {
|
|
144173
|
+
if (!inspectorUrlFound) {
|
|
144174
|
+
stderrData += data.toString();
|
|
144175
|
+
const matches = /Debugger listening on (ws:\/\/127\.0\.0\.1:\d+\/[A-Za-z0-9-]+)[\r|\n]/.exec(
|
|
144176
|
+
stderrData
|
|
144177
|
+
);
|
|
144178
|
+
if (matches) {
|
|
144179
|
+
inspectorUrlFound = true;
|
|
144180
|
+
setInspectorUrl(matches[1]);
|
|
144181
|
+
}
|
|
144182
|
+
}
|
|
144183
|
+
process.stderr.write(data);
|
|
144184
|
+
});
|
|
144185
|
+
child.on("exit", (code) => {
|
|
144186
|
+
if (code) {
|
|
144187
|
+
logger.error(`Miniflare process exited with code ${code}`);
|
|
144188
|
+
}
|
|
144189
|
+
});
|
|
144190
|
+
child.on("error", (error) => {
|
|
144191
|
+
logger.error(`Miniflare process failed to spawn`);
|
|
144192
|
+
logger.error(error);
|
|
144193
|
+
});
|
|
144194
|
+
removeSignalExitListener.current = (0, import_signal_exit2.default)((_code, _signal) => {
|
|
144195
|
+
logger.log("\u2394 Shutting down local server.");
|
|
144196
|
+
child.kill();
|
|
144197
|
+
local.current = void 0;
|
|
144198
|
+
});
|
|
144466
144199
|
}
|
|
144200
|
+
startLocalWorker().catch((err2) => {
|
|
144201
|
+
logger.error("local worker:", err2);
|
|
144202
|
+
});
|
|
144203
|
+
return () => {
|
|
144204
|
+
abortController.abort();
|
|
144205
|
+
if (local.current) {
|
|
144206
|
+
logger.log("\u2394 Shutting down local server.");
|
|
144207
|
+
local.current?.kill();
|
|
144208
|
+
local.current = void 0;
|
|
144209
|
+
}
|
|
144210
|
+
removeSignalExitListener.current?.();
|
|
144211
|
+
removeSignalExitListener.current = void 0;
|
|
144212
|
+
};
|
|
144213
|
+
}, [
|
|
144214
|
+
bundle,
|
|
144215
|
+
workerName,
|
|
144216
|
+
format6,
|
|
144217
|
+
port,
|
|
144218
|
+
inspectorPort,
|
|
144219
|
+
ip,
|
|
144220
|
+
queueConsumers,
|
|
144221
|
+
bindings.queues,
|
|
144222
|
+
bindings.durable_objects,
|
|
144223
|
+
bindings.kv_namespaces,
|
|
144224
|
+
bindings.r2_buckets,
|
|
144225
|
+
bindings.d1_databases,
|
|
144226
|
+
bindings.vars,
|
|
144227
|
+
bindings.services,
|
|
144228
|
+
workerDefinitions,
|
|
144229
|
+
compatibilityDate,
|
|
144230
|
+
compatibilityFlags,
|
|
144231
|
+
usageModel,
|
|
144232
|
+
localPersistencePath,
|
|
144233
|
+
liveReload,
|
|
144234
|
+
assetPaths,
|
|
144235
|
+
rules,
|
|
144236
|
+
bindings.wasm_modules,
|
|
144237
|
+
bindings.text_blobs,
|
|
144238
|
+
bindings.data_blobs,
|
|
144239
|
+
crons,
|
|
144240
|
+
localProtocol,
|
|
144241
|
+
localUpstream,
|
|
144242
|
+
inspect2,
|
|
144243
|
+
logPrefix,
|
|
144244
|
+
onReady,
|
|
144245
|
+
enablePagesAssetsServiceBinding,
|
|
144246
|
+
experimentalLocal,
|
|
144247
|
+
accountId,
|
|
144248
|
+
experimentalLocalRemoteKv
|
|
144249
|
+
]);
|
|
144250
|
+
(0, import_react5.useEffect)(
|
|
144251
|
+
() => () => {
|
|
144252
|
+
if (experimentalLocalRef.current) {
|
|
144253
|
+
logger.log("\u2394 Shutting down experimental local server.");
|
|
144254
|
+
experimentalLocalRef.current?.dispose().catch(() => {
|
|
144255
|
+
});
|
|
144256
|
+
experimentalLocalRef.current = void 0;
|
|
144257
|
+
}
|
|
144258
|
+
removeExperimentalLocalSignalExitListener.current?.();
|
|
144259
|
+
removeExperimentalLocalSignalExitListener.current = void 0;
|
|
144260
|
+
},
|
|
144261
|
+
[]
|
|
144262
|
+
);
|
|
144263
|
+
return { inspectorUrl };
|
|
144264
|
+
}
|
|
144265
|
+
function setupBindings({
|
|
144266
|
+
wasm_modules,
|
|
144267
|
+
text_blobs,
|
|
144268
|
+
data_blobs,
|
|
144269
|
+
durable_objects,
|
|
144270
|
+
format: format6,
|
|
144271
|
+
bundle
|
|
144272
|
+
}) {
|
|
144273
|
+
const wasmBindings = {};
|
|
144274
|
+
for (const [name, filePath] of Object.entries(wasm_modules || {})) {
|
|
144275
|
+
wasmBindings[name] = import_node_path15.default.join(process.cwd(), filePath);
|
|
144467
144276
|
}
|
|
144468
|
-
|
|
144277
|
+
const textBlobBindings = {};
|
|
144278
|
+
for (const [name, filePath] of Object.entries(text_blobs || {})) {
|
|
144279
|
+
textBlobBindings[name] = import_node_path15.default.join(process.cwd(), filePath);
|
|
144280
|
+
}
|
|
144281
|
+
const dataBlobBindings = {};
|
|
144282
|
+
for (const [name, filePath] of Object.entries(data_blobs || {})) {
|
|
144283
|
+
dataBlobBindings[name] = import_node_path15.default.join(process.cwd(), filePath);
|
|
144284
|
+
}
|
|
144285
|
+
if (format6 === "service-worker") {
|
|
144286
|
+
for (const { type: type2, name } of bundle.modules) {
|
|
144287
|
+
if (type2 === "compiled-wasm") {
|
|
144288
|
+
const identifier = name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
144289
|
+
wasmBindings[identifier] = name;
|
|
144290
|
+
} else if (type2 === "text") {
|
|
144291
|
+
const identifier = name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
144292
|
+
textBlobBindings[identifier] = name;
|
|
144293
|
+
} else if (type2 === "buffer") {
|
|
144294
|
+
const identifier = name.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
144295
|
+
dataBlobBindings[identifier] = name;
|
|
144296
|
+
}
|
|
144297
|
+
}
|
|
144298
|
+
}
|
|
144299
|
+
const internalDurableObjects = (durable_objects?.bindings || []).filter(
|
|
144300
|
+
(binding) => !binding.script_name
|
|
144301
|
+
);
|
|
144302
|
+
const externalDurableObjects = (durable_objects?.bindings || []).filter(
|
|
144303
|
+
(binding) => binding.script_name
|
|
144304
|
+
);
|
|
144305
|
+
return {
|
|
144306
|
+
internalDurableObjects,
|
|
144307
|
+
externalDurableObjects,
|
|
144308
|
+
wasmBindings,
|
|
144309
|
+
textBlobBindings,
|
|
144310
|
+
dataBlobBindings
|
|
144311
|
+
};
|
|
144469
144312
|
}
|
|
144470
|
-
function
|
|
144471
|
-
|
|
144472
|
-
|
|
144473
|
-
|
|
144474
|
-
|
|
144475
|
-
|
|
144476
|
-
|
|
144477
|
-
|
|
144478
|
-
|
|
144479
|
-
|
|
144313
|
+
function setupMiniflareOptions({
|
|
144314
|
+
workerName,
|
|
144315
|
+
port,
|
|
144316
|
+
scriptPath,
|
|
144317
|
+
localProtocol,
|
|
144318
|
+
ip,
|
|
144319
|
+
format: format6,
|
|
144320
|
+
rules,
|
|
144321
|
+
compatibilityDate,
|
|
144322
|
+
compatibilityFlags,
|
|
144323
|
+
usageModel,
|
|
144324
|
+
kv_namespaces,
|
|
144325
|
+
queueBindings,
|
|
144326
|
+
queueConsumers,
|
|
144327
|
+
r2_buckets,
|
|
144328
|
+
d1_databases,
|
|
144329
|
+
internalDurableObjects,
|
|
144330
|
+
externalDurableObjects,
|
|
144331
|
+
localPersistencePath,
|
|
144332
|
+
liveReload,
|
|
144333
|
+
assetPaths,
|
|
144334
|
+
vars,
|
|
144335
|
+
wasmBindings,
|
|
144336
|
+
textBlobBindings,
|
|
144337
|
+
dataBlobBindings,
|
|
144338
|
+
crons,
|
|
144339
|
+
upstream,
|
|
144340
|
+
logPrefix,
|
|
144341
|
+
workerDefinitions,
|
|
144342
|
+
enablePagesAssetsServiceBinding
|
|
144343
|
+
}) {
|
|
144344
|
+
const options6 = {
|
|
144345
|
+
name: workerName,
|
|
144346
|
+
port,
|
|
144347
|
+
scriptPath,
|
|
144348
|
+
https: localProtocol === "https",
|
|
144349
|
+
host: ip,
|
|
144350
|
+
modules: format6 === "modules",
|
|
144351
|
+
modulesRules: (rules || []).concat(DEFAULT_MODULE_RULES).map(({ type: type2, globs: include, fallthrough }) => ({
|
|
144352
|
+
type: type2,
|
|
144353
|
+
include,
|
|
144354
|
+
fallthrough
|
|
144355
|
+
})),
|
|
144356
|
+
compatibilityDate,
|
|
144357
|
+
compatibilityFlags,
|
|
144358
|
+
usageModel,
|
|
144359
|
+
kvNamespaces: kv_namespaces?.map((kv) => kv.binding),
|
|
144360
|
+
queueBindings: queueBindings?.map((queue) => {
|
|
144361
|
+
return { name: queue.binding, queueName: queue.queue_name };
|
|
144362
|
+
}),
|
|
144363
|
+
queueConsumers: queueConsumers?.map((consumer) => {
|
|
144364
|
+
const waitMs = consumer.max_batch_timeout ? 1e3 * consumer.max_batch_timeout : void 0;
|
|
144365
|
+
return {
|
|
144366
|
+
queueName: consumer.queue,
|
|
144367
|
+
maxBatchSize: consumer.max_batch_size,
|
|
144368
|
+
maxWaitMs: waitMs,
|
|
144369
|
+
maxRetries: consumer.max_retries,
|
|
144370
|
+
deadLetterQueue: consumer.dead_letter_queue
|
|
144371
|
+
};
|
|
144372
|
+
}),
|
|
144373
|
+
r2Buckets: r2_buckets?.map((r22) => r22.binding),
|
|
144374
|
+
durableObjects: Object.fromEntries(
|
|
144375
|
+
internalDurableObjects.map((binding) => [
|
|
144376
|
+
binding.name,
|
|
144377
|
+
binding.class_name
|
|
144378
|
+
])
|
|
144379
|
+
),
|
|
144380
|
+
externalDurableObjects: Object.fromEntries(
|
|
144381
|
+
externalDurableObjects.map((binding) => {
|
|
144382
|
+
const service = workerDefinitions && workerDefinitions[binding.script_name];
|
|
144383
|
+
if (!service)
|
|
144384
|
+
return [binding.name, void 0];
|
|
144385
|
+
const name = service.durableObjects.find(
|
|
144386
|
+
(durableObject) => durableObject.className === binding.class_name
|
|
144387
|
+
)?.name;
|
|
144388
|
+
if (!name)
|
|
144389
|
+
return [binding.name, void 0];
|
|
144390
|
+
return [
|
|
144391
|
+
binding.name,
|
|
144392
|
+
{
|
|
144393
|
+
name,
|
|
144394
|
+
host: service.durableObjectsHost,
|
|
144395
|
+
port: service.durableObjectsPort
|
|
144396
|
+
}
|
|
144397
|
+
];
|
|
144398
|
+
}).filter(([_2, details]) => !!details)
|
|
144399
|
+
),
|
|
144400
|
+
d1Databases: d1_databases?.map((db) => db.binding),
|
|
144401
|
+
...localPersistencePath ? {
|
|
144402
|
+
cachePersist: import_node_path15.default.join(localPersistencePath, "cache"),
|
|
144403
|
+
durableObjectsPersist: import_node_path15.default.join(localPersistencePath, "do"),
|
|
144404
|
+
kvPersist: import_node_path15.default.join(localPersistencePath, "kv"),
|
|
144405
|
+
r2Persist: import_node_path15.default.join(localPersistencePath, "r2"),
|
|
144406
|
+
d1Persist: import_node_path15.default.join(localPersistencePath, "d1")
|
|
144407
|
+
} : {
|
|
144408
|
+
cachePersist: true,
|
|
144409
|
+
durableObjectsPersist: true,
|
|
144410
|
+
kvPersist: true,
|
|
144411
|
+
r2Persist: true
|
|
144412
|
+
},
|
|
144413
|
+
liveReload,
|
|
144414
|
+
sitePath: assetPaths?.assetDirectory ? import_node_path15.default.join(assetPaths.baseDirectory, assetPaths.assetDirectory) : void 0,
|
|
144415
|
+
siteInclude: assetPaths?.includePatterns.length ? assetPaths?.includePatterns : void 0,
|
|
144416
|
+
siteExclude: assetPaths?.excludePatterns.length ? assetPaths.excludePatterns : void 0,
|
|
144417
|
+
bindings: vars,
|
|
144418
|
+
wasmBindings,
|
|
144419
|
+
textBlobBindings,
|
|
144420
|
+
dataBlobBindings,
|
|
144421
|
+
sourceMap: true,
|
|
144422
|
+
logUnhandledRejections: true,
|
|
144423
|
+
crons,
|
|
144424
|
+
upstream,
|
|
144425
|
+
logLevel: logger.loggerLevel,
|
|
144426
|
+
logOptions: logPrefix ? { prefix: logPrefix } : void 0,
|
|
144427
|
+
enablePagesAssetsServiceBinding
|
|
144428
|
+
};
|
|
144429
|
+
const miniflareCLIPath = import_node_path15.default.resolve(
|
|
144430
|
+
getBasePath(),
|
|
144431
|
+
"miniflare-dist/index.mjs"
|
|
144432
|
+
);
|
|
144433
|
+
const miniflareOptions = JSON.stringify(options6, null);
|
|
144434
|
+
const forkOptions = [miniflareOptions];
|
|
144435
|
+
if (enablePagesAssetsServiceBinding) {
|
|
144436
|
+
forkOptions.push(JSON.stringify(enablePagesAssetsServiceBinding));
|
|
144480
144437
|
}
|
|
144481
|
-
|
|
144438
|
+
return { miniflareCLIPath, forkOptions, options: options6 };
|
|
144482
144439
|
}
|
|
144483
|
-
function
|
|
144484
|
-
|
|
144485
|
-
|
|
144440
|
+
function setupNodeOptions({
|
|
144441
|
+
inspect: inspect2,
|
|
144442
|
+
ip,
|
|
144443
|
+
inspectorPort
|
|
144444
|
+
}) {
|
|
144445
|
+
const nodeOptions = [
|
|
144446
|
+
"--experimental-vm-modules",
|
|
144447
|
+
"--no-warnings"
|
|
144448
|
+
];
|
|
144449
|
+
if (inspect2) {
|
|
144450
|
+
nodeOptions.push(`--inspect=${ip}:${inspectorPort}`);
|
|
144451
|
+
}
|
|
144452
|
+
return nodeOptions;
|
|
144486
144453
|
}
|
|
144487
|
-
function
|
|
144488
|
-
|
|
144489
|
-
|
|
144490
|
-
|
|
144491
|
-
|
|
144492
|
-
|
|
144454
|
+
async function transformLocalOptions({
|
|
144455
|
+
miniflare2Options,
|
|
144456
|
+
format: format6,
|
|
144457
|
+
bundle,
|
|
144458
|
+
kvNamespaces,
|
|
144459
|
+
r2Buckets,
|
|
144460
|
+
authenticatedAccountId,
|
|
144461
|
+
kvRemote,
|
|
144462
|
+
inspectorPort
|
|
144463
|
+
}) {
|
|
144464
|
+
let cloudflareFetch;
|
|
144465
|
+
if (kvRemote && authenticatedAccountId !== void 0) {
|
|
144466
|
+
const preferredAccountId = authenticatedAccountId === true ? void 0 : authenticatedAccountId;
|
|
144467
|
+
const accountId = await requireAuth({ account_id: preferredAccountId });
|
|
144468
|
+
cloudflareFetch = (resource, searchParams, init) => {
|
|
144469
|
+
resource = `/accounts/${accountId}/${resource}`;
|
|
144470
|
+
return performApiFetch(resource, init, searchParams);
|
|
144471
|
+
};
|
|
144472
|
+
}
|
|
144473
|
+
const options6 = {
|
|
144474
|
+
...miniflare2Options,
|
|
144475
|
+
kvNamespaces: Object.fromEntries(
|
|
144476
|
+
kvNamespaces?.map(({ binding, id }) => [binding, id]) ?? []
|
|
144477
|
+
),
|
|
144478
|
+
r2Buckets: Object.fromEntries(
|
|
144479
|
+
r2Buckets?.map(({ binding, bucket_name }) => [binding, bucket_name]) ?? []
|
|
144480
|
+
),
|
|
144481
|
+
inspectorPort,
|
|
144482
|
+
verbose: true,
|
|
144483
|
+
cloudflareFetch
|
|
144484
|
+
};
|
|
144485
|
+
if (format6 === "modules") {
|
|
144486
|
+
const root = import_node_path15.default.dirname(bundle.path);
|
|
144487
|
+
import_node_assert5.default.strictEqual(bundle.type, "esm");
|
|
144488
|
+
options6.modules = [
|
|
144489
|
+
{
|
|
144490
|
+
type: "ESModule",
|
|
144491
|
+
path: import_node_path15.default.relative(root, bundle.path),
|
|
144492
|
+
contents: await (0, import_promises3.readFile)(bundle.path, "utf-8")
|
|
144493
|
+
},
|
|
144494
|
+
...bundle.modules.map((module2) => ({
|
|
144495
|
+
type: ModuleTypeToRuleType[module2.type ?? "esm"],
|
|
144496
|
+
path: module2.name,
|
|
144497
|
+
contents: module2.content
|
|
144498
|
+
}))
|
|
144499
|
+
];
|
|
144500
|
+
}
|
|
144501
|
+
if (kvRemote) {
|
|
144502
|
+
(0, import_node_assert5.default)(options6.kvPersist);
|
|
144503
|
+
const kvRemoteCache = options6.kvPersist === true ? import_node_path15.default.join(import_node_path15.default.dirname(bundle.path), ".mf", "kv-remote") : import_node_path15.default.join(import_node_path15.default.dirname(options6.kvPersist), "kv-remote");
|
|
144504
|
+
options6.kvPersist = `remote:?cache=${encodeURIComponent(kvRemoteCache)}`;
|
|
144505
|
+
}
|
|
144506
|
+
return options6;
|
|
144493
144507
|
}
|
|
144494
|
-
|
|
144495
|
-
|
|
144496
|
-
|
|
144497
|
-
|
|
144498
|
-
|
|
144499
|
-
|
|
144500
|
-
|
|
144501
|
-
|
|
144502
|
-
|
|
144503
|
-
|
|
144504
|
-
|
|
144508
|
+
var Miniflare;
|
|
144509
|
+
async function getMiniflare3Constructor() {
|
|
144510
|
+
if (Miniflare === void 0) {
|
|
144511
|
+
({ Miniflare } = await npxImport("@miniflare/tre@3.0.0-next.6"));
|
|
144512
|
+
}
|
|
144513
|
+
return Miniflare;
|
|
144514
|
+
}
|
|
144515
|
+
|
|
144516
|
+
// src/dev/remote.tsx
|
|
144517
|
+
init_import_meta_url();
|
|
144518
|
+
var import_promises5 = require("node:fs/promises");
|
|
144519
|
+
var import_node_path16 = __toESM(require("node:path"));
|
|
144520
|
+
var import_react6 = __toESM(require_react());
|
|
144521
|
+
var import_react_error_boundary = __toESM(require_react_error_boundary_cjs());
|
|
144522
|
+
|
|
144523
|
+
// src/bundle-reporter.tsx
|
|
144524
|
+
init_import_meta_url();
|
|
144525
|
+
var import_node_buffer2 = require("node:buffer");
|
|
144526
|
+
var import_node_zlib = require("node:zlib");
|
|
144527
|
+
var ONE_KIB_BYTES = 1024;
|
|
144528
|
+
var ONE_MIB_BYTES = ONE_KIB_BYTES * 1024;
|
|
144529
|
+
async function getSize(modules) {
|
|
144530
|
+
const gzipSize = (0, import_node_zlib.gzipSync)(
|
|
144531
|
+
await new import_node_buffer2.Blob(modules.map((file) => file.content)).arrayBuffer()
|
|
144532
|
+
).byteLength;
|
|
144533
|
+
const aggregateSize = new import_node_buffer2.Blob(modules.map((file) => file.content)).size;
|
|
144534
|
+
return { size: aggregateSize, gzipSize };
|
|
144535
|
+
}
|
|
144536
|
+
async function printBundleSize(main2, modules) {
|
|
144537
|
+
const { size, gzipSize } = await getSize([...modules, main2]);
|
|
144538
|
+
const bundleReport = `${(size / ONE_KIB_BYTES).toFixed(2)} KiB / gzip: ${(gzipSize / ONE_KIB_BYTES).toFixed(2)} KiB`;
|
|
144539
|
+
logger.log(`Total Upload: ${bundleReport}`);
|
|
144540
|
+
if (gzipSize > ONE_MIB_BYTES && !process.env.NO_SCRIPT_SIZE_WARNING) {
|
|
144541
|
+
logger.warn(
|
|
144542
|
+
"We recommend keeping your script less than 1MiB (1024 KiB) after gzip. Exceeding past this can affect cold start time"
|
|
144543
|
+
);
|
|
144544
|
+
}
|
|
144545
|
+
}
|
|
144546
|
+
function printOffendingDependencies(dependencies) {
|
|
144547
|
+
const warning = [];
|
|
144548
|
+
const dependenciesSorted = Object.entries(dependencies);
|
|
144549
|
+
dependenciesSorted.sort(
|
|
144550
|
+
([_adep, aData], [_bdep, bData]) => bData.bytesInOutput - aData.bytesInOutput
|
|
144505
144551
|
);
|
|
144506
|
-
|
|
144507
|
-
|
|
144508
|
-
|
|
144509
|
-
|
|
144510
|
-
|
|
144511
|
-
const
|
|
144512
|
-
|
|
144513
|
-
|
|
144514
|
-
|
|
144515
|
-
|
|
144552
|
+
const topLargest = dependenciesSorted.slice(0, 5);
|
|
144553
|
+
if (topLargest.length > 0) {
|
|
144554
|
+
warning.push(
|
|
144555
|
+
`Here are the ${topLargest.length} largest dependencies included in your script:`
|
|
144556
|
+
);
|
|
144557
|
+
for (const [dep, data] of topLargest) {
|
|
144558
|
+
warning.push(
|
|
144559
|
+
`- ${dep} - ${(data.bytesInOutput / ONE_KIB_BYTES).toFixed(2)} KiB`
|
|
144560
|
+
);
|
|
144561
|
+
}
|
|
144562
|
+
warning.push("If these are unnecessary, consider removing them");
|
|
144563
|
+
logger.warn(warning.join("\n"));
|
|
144516
144564
|
}
|
|
144517
144565
|
}
|
|
144518
144566
|
|
|
144567
|
+
// src/create-worker-preview.ts
|
|
144568
|
+
init_import_meta_url();
|
|
144569
|
+
var import_node_url10 = require("node:url");
|
|
144570
|
+
var import_undici6 = __toESM(require_undici());
|
|
144571
|
+
|
|
144519
144572
|
// src/create-worker-upload-form.ts
|
|
144520
144573
|
init_import_meta_url();
|
|
144521
144574
|
var import_node_fs7 = require("node:fs");
|
|
@@ -146546,7 +146599,9 @@ function DevSession(props) {
|
|
|
146546
146599
|
inspect: props.inspect,
|
|
146547
146600
|
onReady: props.onReady,
|
|
146548
146601
|
enablePagesAssetsServiceBinding: props.enablePagesAssetsServiceBinding,
|
|
146549
|
-
experimentalLocal: props.experimentalLocal
|
|
146602
|
+
experimentalLocal: props.experimentalLocal,
|
|
146603
|
+
accountId: props.accountId,
|
|
146604
|
+
experimentalLocalRemoteKv: props.experimentalLocalRemoteKv
|
|
146550
146605
|
}) : /* @__PURE__ */ import_react8.default.createElement(Remote, {
|
|
146551
146606
|
name: props.name,
|
|
146552
146607
|
bundle,
|
|
@@ -146861,7 +146916,9 @@ async function startDevServer(props) {
|
|
|
146861
146916
|
enablePagesAssetsServiceBinding: props.enablePagesAssetsServiceBinding,
|
|
146862
146917
|
usageModel: props.usageModel,
|
|
146863
146918
|
workerDefinitions,
|
|
146864
|
-
experimentalLocal: props.experimentalLocal
|
|
146919
|
+
experimentalLocal: props.experimentalLocal,
|
|
146920
|
+
accountId: props.accountId,
|
|
146921
|
+
experimentalLocalRemoteKv: props.experimentalLocalRemoteKv
|
|
146865
146922
|
});
|
|
146866
146923
|
return {
|
|
146867
146924
|
stop: async () => {
|
|
@@ -147008,7 +147065,9 @@ async function startLocalServer({
|
|
|
147008
147065
|
onReady,
|
|
147009
147066
|
logPrefix,
|
|
147010
147067
|
enablePagesAssetsServiceBinding,
|
|
147011
|
-
experimentalLocal
|
|
147068
|
+
experimentalLocal,
|
|
147069
|
+
accountId,
|
|
147070
|
+
experimentalLocalRemoteKv
|
|
147012
147071
|
}) {
|
|
147013
147072
|
let local;
|
|
147014
147073
|
let experimentalLocalRef;
|
|
@@ -147087,7 +147146,16 @@ async function startLocalServer({
|
|
|
147087
147146
|
enablePagesAssetsServiceBinding
|
|
147088
147147
|
});
|
|
147089
147148
|
if (experimentalLocal) {
|
|
147090
|
-
const mf3Options = await transformLocalOptions(
|
|
147149
|
+
const mf3Options = await transformLocalOptions({
|
|
147150
|
+
miniflare2Options: options6,
|
|
147151
|
+
format: format6,
|
|
147152
|
+
bundle,
|
|
147153
|
+
kvNamespaces: bindings?.kv_namespaces,
|
|
147154
|
+
r2Buckets: bindings?.r2_buckets,
|
|
147155
|
+
authenticatedAccountId: accountId,
|
|
147156
|
+
kvRemote: experimentalLocalRemoteKv,
|
|
147157
|
+
inspectorPort
|
|
147158
|
+
});
|
|
147091
147159
|
const Miniflare2 = await getMiniflare3Constructor();
|
|
147092
147160
|
const mf = new Miniflare2(mf3Options);
|
|
147093
147161
|
const runtimeURL = await mf.ready;
|
|
@@ -147297,7 +147365,7 @@ async function fromDashMessagePrompt(deploySource) {
|
|
|
147297
147365
|
if (deploySource === "dash") {
|
|
147298
147366
|
logger.warn(
|
|
147299
147367
|
`You are about to publish a Workers Service that was last published via the Cloudflare Dashboard.
|
|
147300
|
-
|
|
147368
|
+
Edits that have been made via the dashboard will be overridden by your local code and config.`
|
|
147301
147369
|
);
|
|
147302
147370
|
if (!isInteractive() || CI.isCI())
|
|
147303
147371
|
return true;
|
|
@@ -159668,11 +159736,17 @@ To silence this warning, pass in --commit-dirty=true`
|
|
|
159668
159736
|
let builtFunctions = void 0;
|
|
159669
159737
|
const functionsDirectory = (0, import_node_path34.join)((0, import_node_process7.cwd)(), "functions");
|
|
159670
159738
|
const routesOutputPath = !(0, import_node_fs19.existsSync)((0, import_node_path34.join)(directory, "_routes.json")) ? (0, import_node_path34.join)((0, import_node_os13.tmpdir)(), `_routes-${Math.random()}.json`) : void 0;
|
|
159739
|
+
let filepathRoutingConfig;
|
|
159671
159740
|
if (!_workerJS && (0, import_node_fs19.existsSync)(functionsDirectory)) {
|
|
159672
159741
|
const outfile = (0, import_node_path34.join)((0, import_node_os13.tmpdir)(), `./functionsWorker-${Math.random()}.js`);
|
|
159742
|
+
const outputConfigPath = (0, import_node_path34.join)(
|
|
159743
|
+
(0, import_node_os13.tmpdir)(),
|
|
159744
|
+
`functions-filepath-routing-config-${Math.random()}.json`
|
|
159745
|
+
);
|
|
159673
159746
|
try {
|
|
159674
159747
|
await buildFunctions({
|
|
159675
159748
|
outfile,
|
|
159749
|
+
outputConfigPath,
|
|
159676
159750
|
functionsDirectory,
|
|
159677
159751
|
onEnd: () => {
|
|
159678
159752
|
},
|
|
@@ -159684,6 +159758,7 @@ To silence this warning, pass in --commit-dirty=true`
|
|
|
159684
159758
|
)
|
|
159685
159759
|
});
|
|
159686
159760
|
builtFunctions = (0, import_node_fs19.readFileSync)(outfile, "utf-8");
|
|
159761
|
+
filepathRoutingConfig = (0, import_node_fs19.readFileSync)(outputConfigPath, "utf-8");
|
|
159687
159762
|
} catch (e2) {
|
|
159688
159763
|
if (e2 instanceof FunctionsNoRoutesError) {
|
|
159689
159764
|
logger.warn(
|
|
@@ -159717,6 +159792,15 @@ To silence this warning, pass in --commit-dirty=true`
|
|
|
159717
159792
|
formData.append("_redirects", new import_undici10.File([_redirects], "_redirects"));
|
|
159718
159793
|
logger.log(`\u2728 Uploading _redirects`);
|
|
159719
159794
|
}
|
|
159795
|
+
if (filepathRoutingConfig) {
|
|
159796
|
+
formData.append(
|
|
159797
|
+
"functions-filepath-routing-config.json",
|
|
159798
|
+
new import_undici10.File(
|
|
159799
|
+
[filepathRoutingConfig],
|
|
159800
|
+
"functions-filepath-routing-config.json"
|
|
159801
|
+
)
|
|
159802
|
+
);
|
|
159803
|
+
}
|
|
159720
159804
|
if (_workerJS) {
|
|
159721
159805
|
formData.append("_worker.js", new import_undici10.File([_workerJS], "_worker.js"));
|
|
159722
159806
|
logger.log(`\u2728 Uploading _worker.js`);
|
|
@@ -163059,7 +163143,7 @@ function createCLIParser(argv) {
|
|
|
163059
163143
|
const deploymentsWarning = "\u{1F6A7}`wrangler deployments` is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose";
|
|
163060
163144
|
wrangler.command(
|
|
163061
163145
|
"deployments",
|
|
163062
|
-
|
|
163146
|
+
"\u{1F6A2} Displays the 10 most recent deployments for a worker",
|
|
163063
163147
|
(yargs) => {
|
|
163064
163148
|
yargs.option("name", {
|
|
163065
163149
|
describe: "The name of your worker",
|
|
@@ -163275,10 +163359,19 @@ function devOptions(yargs) {
|
|
|
163275
163359
|
describe: "Run on my machine using the Cloudflare Workers runtime",
|
|
163276
163360
|
type: "boolean",
|
|
163277
163361
|
default: false
|
|
163362
|
+
}).option("experimental-local-remote-kv", {
|
|
163363
|
+
describe: "Read/write KV data from/to real namespaces on the Cloudflare network",
|
|
163364
|
+
type: "boolean",
|
|
163365
|
+
default: false
|
|
163278
163366
|
}).check((argv) => {
|
|
163279
163367
|
if (argv.local && argv["experimental-local"]) {
|
|
163280
163368
|
throw new Error(
|
|
163281
|
-
"--local and --experimental-local are mutually exclusive. Please
|
|
163369
|
+
"--local and --experimental-local are mutually exclusive. Please enable one or the other."
|
|
163370
|
+
);
|
|
163371
|
+
}
|
|
163372
|
+
if (argv["experimental-local-remote-kv"] && !argv["experimental-local"]) {
|
|
163373
|
+
throw new Error(
|
|
163374
|
+
"--experimental-local-remote-kv requires --experimental-local to be enabled."
|
|
163282
163375
|
);
|
|
163283
163376
|
}
|
|
163284
163377
|
return true;
|
|
@@ -163427,7 +163520,8 @@ async function startDev(args) {
|
|
|
163427
163520
|
firstPartyWorker: configParam.first_party_worker,
|
|
163428
163521
|
sendMetrics: configParam.send_metrics,
|
|
163429
163522
|
testScheduled: args["test-scheduled"],
|
|
163430
|
-
experimentalLocal: args.experimentalLocal
|
|
163523
|
+
experimentalLocal: args.experimentalLocal,
|
|
163524
|
+
experimentalLocalRemoteKv: args.experimentalLocalRemoteKv
|
|
163431
163525
|
});
|
|
163432
163526
|
}
|
|
163433
163527
|
const devReactElement = (0, import_ink17.render)(await getDevReactElement(config));
|
|
@@ -163523,7 +163617,8 @@ async function startApiDev(args) {
|
|
|
163523
163617
|
firstPartyWorker: configParam.first_party_worker,
|
|
163524
163618
|
sendMetrics: configParam.send_metrics,
|
|
163525
163619
|
testScheduled: args.testScheduled,
|
|
163526
|
-
experimentalLocal: args.experimentalLocal
|
|
163620
|
+
experimentalLocal: args.experimentalLocal,
|
|
163621
|
+
experimentalLocalRemoteKv: args.experimentalLocalRemoteKv
|
|
163527
163622
|
});
|
|
163528
163623
|
}
|
|
163529
163624
|
const devServer = await getDevServer(config);
|