edgeone 1.0.6 → 1.0.8
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/edgeone-dist/cli.js +66 -15
- package/package.json +1 -1
package/edgeone-dist/cli.js
CHANGED
|
@@ -103190,7 +103190,7 @@ var yargs_default = Yargs;
|
|
|
103190
103190
|
// package.json
|
|
103191
103191
|
var package_default = {
|
|
103192
103192
|
name: "edgeone",
|
|
103193
|
-
version: "1.0.
|
|
103193
|
+
version: "1.0.8",
|
|
103194
103194
|
description: "Command-line interface for TencentCloud Pages Functions",
|
|
103195
103195
|
bin: {
|
|
103196
103196
|
edgeone: "./edgeone-bin/edgeone.js"
|
|
@@ -106746,7 +106746,7 @@ var {
|
|
|
106746
106746
|
var cookie = __toESM(require_dist2());
|
|
106747
106747
|
var getHost = async () => {
|
|
106748
106748
|
const region = await getLoginRegion();
|
|
106749
|
-
if (region === "
|
|
106749
|
+
if (region === "global") {
|
|
106750
106750
|
return "https://edgeone.tencentcloud.com/api/cli/proxy";
|
|
106751
106751
|
}
|
|
106752
106752
|
return "https://edgeone.cloud.tencent.com/api/cli/proxy";
|
|
@@ -106782,6 +106782,7 @@ async function capi(action, params, options, callback) {
|
|
|
106782
106782
|
try {
|
|
106783
106783
|
const res1 = await axios_default.post(
|
|
106784
106784
|
// `https://siaas.cloud.tencent.com/cgi/capi?csrfCode=${await getCsrfCode()}`,
|
|
106785
|
+
// `https://siaas.tencentcloud.com/cgi/capi?csrfCode=${await getCsrfCode()}`,
|
|
106785
106786
|
await getHost(),
|
|
106786
106787
|
JSON.stringify(data.body),
|
|
106787
106788
|
{
|
|
@@ -112942,6 +112943,13 @@ function isSource(v) {
|
|
|
112942
112943
|
if (/(?<![a-zA-Z0-9_\-/:*.~=?#!$&+,;%@ ]):/.test(v) || /:(?![a-zA-Z0-9]+)/.test(v)) {
|
|
112943
112944
|
return Error_Message.char_match;
|
|
112944
112945
|
}
|
|
112946
|
+
if (v.length) {
|
|
112947
|
+
const arr = v.split("/");
|
|
112948
|
+
const ret = arr.some((v2) => v2.includes(":") && (v2.includes("*") || v2.includes(".")));
|
|
112949
|
+
if (ret) {
|
|
112950
|
+
return Error_Message.char_match;
|
|
112951
|
+
}
|
|
112952
|
+
}
|
|
112945
112953
|
}
|
|
112946
112954
|
function isDestination(v) {
|
|
112947
112955
|
var _a6;
|
|
@@ -112962,6 +112970,13 @@ function isDestination(v) {
|
|
|
112962
112970
|
if (/(?<![a-zA-Z0-9_\-/:*.~=?#!$&+,;%@ ]):/.test(v) || /:(?![a-zA-Z0-9]+)/.test(v)) {
|
|
112963
112971
|
return Error_Message.char_match;
|
|
112964
112972
|
}
|
|
112973
|
+
if (v.length) {
|
|
112974
|
+
const arr = v.split("/");
|
|
112975
|
+
const ret = arr.some((v2) => v2.includes(":") && (v2.includes("*") || v2.includes(".")));
|
|
112976
|
+
if (ret) {
|
|
112977
|
+
return Error_Message.char_match;
|
|
112978
|
+
}
|
|
112979
|
+
}
|
|
112965
112980
|
}
|
|
112966
112981
|
function isKey(v) {
|
|
112967
112982
|
if (v.length === 0) {
|
|
@@ -113503,6 +113518,7 @@ var path5 = require("path");
|
|
|
113503
113518
|
var esbuild = require("esbuild");
|
|
113504
113519
|
var FUNCTIONPATH = "./functions";
|
|
113505
113520
|
var OUTPUTPATH = "./.edgeone/functions/index.js";
|
|
113521
|
+
var CSSOUTPUTPATH = "./.edgeone/assets/index.css";
|
|
113506
113522
|
var OUTPUTMETA = "./.edgeone/meta.json";
|
|
113507
113523
|
var regex1 = /^\/(?:[^/]+\/)*\[(.+?)\]$/;
|
|
113508
113524
|
var regex2 = /^\/(?:[^/]+\/)*\[\[(.+?)\]\]$/;
|
|
@@ -113545,6 +113561,7 @@ var BuildFunctionGenerator = class {
|
|
|
113545
113561
|
env;
|
|
113546
113562
|
logicText;
|
|
113547
113563
|
bundleText;
|
|
113564
|
+
cssText;
|
|
113548
113565
|
functionList;
|
|
113549
113566
|
functionIndex;
|
|
113550
113567
|
constructor(props) {
|
|
@@ -113552,6 +113569,7 @@ var BuildFunctionGenerator = class {
|
|
|
113552
113569
|
this.env = props.env;
|
|
113553
113570
|
this.logicText = "";
|
|
113554
113571
|
this.bundleText = "";
|
|
113572
|
+
this.cssText = "";
|
|
113555
113573
|
this.functionList = [];
|
|
113556
113574
|
this.functionIndex = 0;
|
|
113557
113575
|
if (!props.env) {
|
|
@@ -113569,9 +113587,31 @@ var BuildFunctionGenerator = class {
|
|
|
113569
113587
|
}
|
|
113570
113588
|
async init() {
|
|
113571
113589
|
await this.readIndexFiles(FUNCTIONPATH);
|
|
113590
|
+
if (this.cssText) {
|
|
113591
|
+
writeFileSync(CSSOUTPUTPATH, this.cssText);
|
|
113592
|
+
}
|
|
113572
113593
|
if (this.logicText) {
|
|
113573
113594
|
this.bundleText = `
|
|
113574
113595
|
let global = globalThis;
|
|
113596
|
+
|
|
113597
|
+
class MessageChannel {
|
|
113598
|
+
constructor() {
|
|
113599
|
+
this.port1 = new MessagePort();
|
|
113600
|
+
this.port2 = new MessagePort();
|
|
113601
|
+
}
|
|
113602
|
+
}
|
|
113603
|
+
class MessagePort {
|
|
113604
|
+
constructor() {
|
|
113605
|
+
this.onmessage = null;
|
|
113606
|
+
}
|
|
113607
|
+
postMessage(data) {
|
|
113608
|
+
if (this.onmessage) {
|
|
113609
|
+
setTimeout(() => this.onmessage({ data }), 0);
|
|
113610
|
+
}
|
|
113611
|
+
}
|
|
113612
|
+
}
|
|
113613
|
+
global.MessageChannel = MessageChannel;
|
|
113614
|
+
|
|
113575
113615
|
let routeParams = {};
|
|
113576
113616
|
let pagesFunctionResponse = null;
|
|
113577
113617
|
async function handleRequest(context){
|
|
@@ -113695,7 +113735,7 @@ var BuildFunctionGenerator = class {
|
|
|
113695
113735
|
let tempResult = stringMap.text;
|
|
113696
113736
|
const onRequestRegex = /onRequest(?![a-zA-Z])/;
|
|
113697
113737
|
if (onRequestRegex.test(tempResult)) {
|
|
113698
|
-
tempResult = stringMap.text.replace(/\}\)\(\)\;\
|
|
113738
|
+
tempResult = stringMap.text.replace(/\}\)\(\)\;\n(\/\*\!(.|\n)*\*\/\n)*responseFoo/, `
|
|
113699
113739
|
pagesFunctionResponse = onRequest;
|
|
113700
113740
|
})();`);
|
|
113701
113741
|
const routeParams = this.matchPath(`${stringMap.path}`);
|
|
@@ -113733,7 +113773,7 @@ var BuildFunctionGenerator = class {
|
|
|
113733
113773
|
}
|
|
113734
113774
|
methodList.forEach((item) => {
|
|
113735
113775
|
if (tempResult.indexOf(item.funcName) > -1) {
|
|
113736
|
-
tempResult = stringMap.text.replace(/\}\)\(\)\;\
|
|
113776
|
+
tempResult = stringMap.text.replace(/\}\)\(\)\;\n(\/\*\!(.|\n)*\*\/\n)*responseFoo/, `
|
|
113737
113777
|
pagesFunctionResponse = ${item.funcName};
|
|
113738
113778
|
})();`);
|
|
113739
113779
|
const routeParams = this.matchPath(stringMap.path);
|
|
@@ -113799,19 +113839,30 @@ var BuildFunctionGenerator = class {
|
|
|
113799
113839
|
const result = esbuild.buildSync({
|
|
113800
113840
|
entryPoints: [filePath],
|
|
113801
113841
|
bundle: true,
|
|
113842
|
+
// minify: true,
|
|
113802
113843
|
// minifyWhitespace: true,
|
|
113803
|
-
|
|
113844
|
+
// outdir: './.tef_dist/assets',
|
|
113845
|
+
write: false,
|
|
113804
113846
|
// 禁止写入文件
|
|
113847
|
+
outfile: "./.tef_dist/assets.js"
|
|
113805
113848
|
});
|
|
113806
|
-
|
|
113807
|
-
|
|
113808
|
-
|
|
113809
|
-
|
|
113810
|
-
|
|
113811
|
-
|
|
113812
|
-
|
|
113813
|
-
|
|
113814
|
-
|
|
113849
|
+
let currentFileInfo;
|
|
113850
|
+
for (let i3 = 0; i3 < result.outputFiles.length; i3++) {
|
|
113851
|
+
if (result.outputFiles[i3].path.indexOf(".css") > -1) {
|
|
113852
|
+
this.cssText += result.outputFiles[i3].text;
|
|
113853
|
+
} else {
|
|
113854
|
+
const regex = /\.(js|ts|cjs|tsx|jsx)$/;
|
|
113855
|
+
const bundledCode = result.outputFiles[i3].text;
|
|
113856
|
+
filePath = filePath.replace(/\\/g, "/");
|
|
113857
|
+
const extractedPath = filePath.replace(/\/index\.(js|ts|cjs|tsx|jsx)/, ".js").replace(regex, "").replace("functions", "");
|
|
113858
|
+
currentFileInfo = {
|
|
113859
|
+
filePath: filePath.replace("functions/", ""),
|
|
113860
|
+
path: extractedPath === "" ? "/" : extractedPath,
|
|
113861
|
+
text: `${bundledCode}responseFoo`
|
|
113862
|
+
};
|
|
113863
|
+
}
|
|
113864
|
+
}
|
|
113865
|
+
return currentFileInfo;
|
|
113815
113866
|
}
|
|
113816
113867
|
};
|
|
113817
113868
|
async function PagesBuild(props) {
|
|
@@ -114402,7 +114453,7 @@ var path6 = require("path");
|
|
|
114402
114453
|
var chokidar = require("chokidar");
|
|
114403
114454
|
var listenFileTypes = ["js", "json", "html", "css", "jsx", "ts", "tsx", "vue", "md", "cjs"];
|
|
114404
114455
|
async function remoteDevServer(jscontent, projectId, metaJSON) {
|
|
114405
|
-
const res = await pagesCapi("
|
|
114456
|
+
const res = await pagesCapi("CreateDebugFunction", {
|
|
114406
114457
|
JSContent: jscontent,
|
|
114407
114458
|
ProjectId: projectId,
|
|
114408
114459
|
MetaData: metaJSON
|