edgeone 1.0.7 → 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.
@@ -1827,115 +1827,6 @@ var require_browser = __commonJS({
1827
1827
  }
1828
1828
  });
1829
1829
 
1830
- // ../../node_modules/has-flag/index.js
1831
- var require_has_flag = __commonJS({
1832
- "../../node_modules/has-flag/index.js"(exports2, module2) {
1833
- "use strict";
1834
- module2.exports = (flag, argv) => {
1835
- argv = argv || process.argv;
1836
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1837
- const pos = argv.indexOf(prefix + flag);
1838
- const terminatorPos = argv.indexOf("--");
1839
- return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
1840
- };
1841
- }
1842
- });
1843
-
1844
- // ../../node_modules/supports-color/index.js
1845
- var require_supports_color = __commonJS({
1846
- "../../node_modules/supports-color/index.js"(exports2, module2) {
1847
- "use strict";
1848
- var os = require("os");
1849
- var hasFlag = require_has_flag();
1850
- var env = process.env;
1851
- var forceColor;
1852
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false")) {
1853
- forceColor = false;
1854
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
1855
- forceColor = true;
1856
- }
1857
- if ("FORCE_COLOR" in env) {
1858
- forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
1859
- }
1860
- function translateLevel(level) {
1861
- if (level === 0) {
1862
- return false;
1863
- }
1864
- return {
1865
- level,
1866
- hasBasic: true,
1867
- has256: level >= 2,
1868
- has16m: level >= 3
1869
- };
1870
- }
1871
- function supportsColor(stream) {
1872
- if (forceColor === false) {
1873
- return 0;
1874
- }
1875
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
1876
- return 3;
1877
- }
1878
- if (hasFlag("color=256")) {
1879
- return 2;
1880
- }
1881
- if (stream && !stream.isTTY && forceColor !== true) {
1882
- return 0;
1883
- }
1884
- const min = forceColor ? 1 : 0;
1885
- if (process.platform === "win32") {
1886
- const osRelease = os.release().split(".");
1887
- if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1888
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
1889
- }
1890
- return 1;
1891
- }
1892
- if ("CI" in env) {
1893
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
1894
- return 1;
1895
- }
1896
- return min;
1897
- }
1898
- if ("TEAMCITY_VERSION" in env) {
1899
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1900
- }
1901
- if (env.COLORTERM === "truecolor") {
1902
- return 3;
1903
- }
1904
- if ("TERM_PROGRAM" in env) {
1905
- const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1906
- switch (env.TERM_PROGRAM) {
1907
- case "iTerm.app":
1908
- return version >= 3 ? 3 : 2;
1909
- case "Apple_Terminal":
1910
- return 2;
1911
- }
1912
- }
1913
- if (/-256(color)?$/i.test(env.TERM)) {
1914
- return 2;
1915
- }
1916
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1917
- return 1;
1918
- }
1919
- if ("COLORTERM" in env) {
1920
- return 1;
1921
- }
1922
- if (env.TERM === "dumb") {
1923
- return min;
1924
- }
1925
- return min;
1926
- }
1927
- function getSupportLevel(stream) {
1928
- const level = supportsColor(stream);
1929
- return translateLevel(level);
1930
- }
1931
- module2.exports = {
1932
- supportsColor: getSupportLevel,
1933
- stdout: getSupportLevel(process.stdout),
1934
- stderr: getSupportLevel(process.stderr)
1935
- };
1936
- }
1937
- });
1938
-
1939
1830
  // ../../node_modules/debug/src/node.js
1940
1831
  var require_node = __commonJS({
1941
1832
  "../../node_modules/debug/src/node.js"(exports2, module2) {
@@ -1954,7 +1845,7 @@ var require_node = __commonJS({
1954
1845
  );
1955
1846
  exports2.colors = [6, 2, 3, 4, 5, 1];
1956
1847
  try {
1957
- const supportsColor = require_supports_color();
1848
+ const supportsColor = require("supports-color");
1958
1849
  if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
1959
1850
  exports2.colors = [
1960
1851
  20,
@@ -78179,115 +78179,6 @@ var require_browser = __commonJS({
78179
78179
  }
78180
78180
  });
78181
78181
 
78182
- // ../../node_modules/has-flag/index.js
78183
- var require_has_flag2 = __commonJS({
78184
- "../../node_modules/has-flag/index.js"(exports2, module2) {
78185
- "use strict";
78186
- module2.exports = (flag, argv) => {
78187
- argv = argv || process.argv;
78188
- const prefix2 = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
78189
- const pos = argv.indexOf(prefix2 + flag);
78190
- const terminatorPos = argv.indexOf("--");
78191
- return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
78192
- };
78193
- }
78194
- });
78195
-
78196
- // ../../node_modules/supports-color/index.js
78197
- var require_supports_color2 = __commonJS({
78198
- "../../node_modules/supports-color/index.js"(exports2, module2) {
78199
- "use strict";
78200
- var os2 = require("os");
78201
- var hasFlag2 = require_has_flag2();
78202
- var env3 = process.env;
78203
- var forceColor;
78204
- if (hasFlag2("no-color") || hasFlag2("no-colors") || hasFlag2("color=false")) {
78205
- forceColor = false;
78206
- } else if (hasFlag2("color") || hasFlag2("colors") || hasFlag2("color=true") || hasFlag2("color=always")) {
78207
- forceColor = true;
78208
- }
78209
- if ("FORCE_COLOR" in env3) {
78210
- forceColor = env3.FORCE_COLOR.length === 0 || parseInt(env3.FORCE_COLOR, 10) !== 0;
78211
- }
78212
- function translateLevel2(level) {
78213
- if (level === 0) {
78214
- return false;
78215
- }
78216
- return {
78217
- level,
78218
- hasBasic: true,
78219
- has256: level >= 2,
78220
- has16m: level >= 3
78221
- };
78222
- }
78223
- function supportsColor2(stream4) {
78224
- if (forceColor === false) {
78225
- return 0;
78226
- }
78227
- if (hasFlag2("color=16m") || hasFlag2("color=full") || hasFlag2("color=truecolor")) {
78228
- return 3;
78229
- }
78230
- if (hasFlag2("color=256")) {
78231
- return 2;
78232
- }
78233
- if (stream4 && !stream4.isTTY && forceColor !== true) {
78234
- return 0;
78235
- }
78236
- const min = forceColor ? 1 : 0;
78237
- if (process.platform === "win32") {
78238
- const osRelease = os2.release().split(".");
78239
- if (Number(process.versions.node.split(".")[0]) >= 8 && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
78240
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
78241
- }
78242
- return 1;
78243
- }
78244
- if ("CI" in env3) {
78245
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI"].some((sign) => sign in env3) || env3.CI_NAME === "codeship") {
78246
- return 1;
78247
- }
78248
- return min;
78249
- }
78250
- if ("TEAMCITY_VERSION" in env3) {
78251
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env3.TEAMCITY_VERSION) ? 1 : 0;
78252
- }
78253
- if (env3.COLORTERM === "truecolor") {
78254
- return 3;
78255
- }
78256
- if ("TERM_PROGRAM" in env3) {
78257
- const version = parseInt((env3.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
78258
- switch (env3.TERM_PROGRAM) {
78259
- case "iTerm.app":
78260
- return version >= 3 ? 3 : 2;
78261
- case "Apple_Terminal":
78262
- return 2;
78263
- }
78264
- }
78265
- if (/-256(color)?$/i.test(env3.TERM)) {
78266
- return 2;
78267
- }
78268
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env3.TERM)) {
78269
- return 1;
78270
- }
78271
- if ("COLORTERM" in env3) {
78272
- return 1;
78273
- }
78274
- if (env3.TERM === "dumb") {
78275
- return min;
78276
- }
78277
- return min;
78278
- }
78279
- function getSupportLevel(stream4) {
78280
- const level = supportsColor2(stream4);
78281
- return translateLevel2(level);
78282
- }
78283
- module2.exports = {
78284
- supportsColor: getSupportLevel,
78285
- stdout: getSupportLevel(process.stdout),
78286
- stderr: getSupportLevel(process.stderr)
78287
- };
78288
- }
78289
- });
78290
-
78291
78182
  // ../../node_modules/debug/src/node.js
78292
78183
  var require_node = __commonJS({
78293
78184
  "../../node_modules/debug/src/node.js"(exports2, module2) {
@@ -78306,7 +78197,7 @@ var require_node = __commonJS({
78306
78197
  );
78307
78198
  exports2.colors = [6, 2, 3, 4, 5, 1];
78308
78199
  try {
78309
- const supportsColor2 = require_supports_color2();
78200
+ const supportsColor2 = require("supports-color");
78310
78201
  if (supportsColor2 && (supportsColor2.stderr || supportsColor2).level >= 2) {
78311
78202
  exports2.colors = [
78312
78203
  20,
@@ -86404,7 +86295,7 @@ var require_node2 = __commonJS({
86404
86295
  exports2.useColors = useColors;
86405
86296
  exports2.colors = [6, 2, 3, 4, 5, 1];
86406
86297
  try {
86407
- supportsColor2 = require_supports_color2();
86298
+ supportsColor2 = require("supports-color");
86408
86299
  if (supportsColor2 && (supportsColor2.stderr || supportsColor2).level >= 2) {
86409
86300
  exports2.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221];
86410
86301
  }
@@ -103299,7 +103190,7 @@ var yargs_default = Yargs;
103299
103190
  // package.json
103300
103191
  var package_default = {
103301
103192
  name: "edgeone",
103302
- version: "1.0.7",
103193
+ version: "1.0.8",
103303
103194
  description: "Command-line interface for TencentCloud Pages Functions",
103304
103195
  bin: {
103305
103196
  edgeone: "./edgeone-bin/edgeone.js"
@@ -106855,7 +106746,7 @@ var {
106855
106746
  var cookie = __toESM(require_dist2());
106856
106747
  var getHost = async () => {
106857
106748
  const region = await getLoginRegion();
106858
- if (region === "ap-singapore") {
106749
+ if (region === "global") {
106859
106750
  return "https://edgeone.tencentcloud.com/api/cli/proxy";
106860
106751
  }
106861
106752
  return "https://edgeone.cloud.tencent.com/api/cli/proxy";
@@ -106891,6 +106782,7 @@ async function capi(action, params, options, callback) {
106891
106782
  try {
106892
106783
  const res1 = await axios_default.post(
106893
106784
  // `https://siaas.cloud.tencent.com/cgi/capi?csrfCode=${await getCsrfCode()}`,
106785
+ // `https://siaas.tencentcloud.com/cgi/capi?csrfCode=${await getCsrfCode()}`,
106894
106786
  await getHost(),
106895
106787
  JSON.stringify(data.body),
106896
106788
  {
@@ -113626,6 +113518,7 @@ var path5 = require("path");
113626
113518
  var esbuild = require("esbuild");
113627
113519
  var FUNCTIONPATH = "./functions";
113628
113520
  var OUTPUTPATH = "./.edgeone/functions/index.js";
113521
+ var CSSOUTPUTPATH = "./.edgeone/assets/index.css";
113629
113522
  var OUTPUTMETA = "./.edgeone/meta.json";
113630
113523
  var regex1 = /^\/(?:[^/]+\/)*\[(.+?)\]$/;
113631
113524
  var regex2 = /^\/(?:[^/]+\/)*\[\[(.+?)\]\]$/;
@@ -113668,6 +113561,7 @@ var BuildFunctionGenerator = class {
113668
113561
  env;
113669
113562
  logicText;
113670
113563
  bundleText;
113564
+ cssText;
113671
113565
  functionList;
113672
113566
  functionIndex;
113673
113567
  constructor(props) {
@@ -113675,6 +113569,7 @@ var BuildFunctionGenerator = class {
113675
113569
  this.env = props.env;
113676
113570
  this.logicText = "";
113677
113571
  this.bundleText = "";
113572
+ this.cssText = "";
113678
113573
  this.functionList = [];
113679
113574
  this.functionIndex = 0;
113680
113575
  if (!props.env) {
@@ -113692,9 +113587,31 @@ var BuildFunctionGenerator = class {
113692
113587
  }
113693
113588
  async init() {
113694
113589
  await this.readIndexFiles(FUNCTIONPATH);
113590
+ if (this.cssText) {
113591
+ writeFileSync(CSSOUTPUTPATH, this.cssText);
113592
+ }
113695
113593
  if (this.logicText) {
113696
113594
  this.bundleText = `
113697
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
+
113698
113615
  let routeParams = {};
113699
113616
  let pagesFunctionResponse = null;
113700
113617
  async function handleRequest(context){
@@ -113818,7 +113735,7 @@ var BuildFunctionGenerator = class {
113818
113735
  let tempResult = stringMap.text;
113819
113736
  const onRequestRegex = /onRequest(?![a-zA-Z])/;
113820
113737
  if (onRequestRegex.test(tempResult)) {
113821
- tempResult = stringMap.text.replace(/\}\)\(\)\;\nresponseFoo/, `
113738
+ tempResult = stringMap.text.replace(/\}\)\(\)\;\n(\/\*\!(.|\n)*\*\/\n)*responseFoo/, `
113822
113739
  pagesFunctionResponse = onRequest;
113823
113740
  })();`);
113824
113741
  const routeParams = this.matchPath(`${stringMap.path}`);
@@ -113856,7 +113773,7 @@ var BuildFunctionGenerator = class {
113856
113773
  }
113857
113774
  methodList.forEach((item) => {
113858
113775
  if (tempResult.indexOf(item.funcName) > -1) {
113859
- tempResult = stringMap.text.replace(/\}\)\(\)\;\nresponseFoo/, `
113776
+ tempResult = stringMap.text.replace(/\}\)\(\)\;\n(\/\*\!(.|\n)*\*\/\n)*responseFoo/, `
113860
113777
  pagesFunctionResponse = ${item.funcName};
113861
113778
  })();`);
113862
113779
  const routeParams = this.matchPath(stringMap.path);
@@ -113922,19 +113839,30 @@ var BuildFunctionGenerator = class {
113922
113839
  const result = esbuild.buildSync({
113923
113840
  entryPoints: [filePath],
113924
113841
  bundle: true,
113842
+ // minify: true,
113925
113843
  // minifyWhitespace: true,
113926
- write: false
113844
+ // outdir: './.tef_dist/assets',
113845
+ write: false,
113927
113846
  // 禁止写入文件
113847
+ outfile: "./.tef_dist/assets.js"
113928
113848
  });
113929
- const regex = /\.(js|ts|cjs|tsx|jsx)$/;
113930
- const bundledCode = result.outputFiles[0].text;
113931
- filePath = filePath.replace(/\\/g, "/");
113932
- const extractedPath = filePath.replace(/\/index\.(js|ts|cjs|tsx|jsx)/, ".js").replace(regex, "").replace("functions", "");
113933
- return {
113934
- filePath: filePath.replace("functions/", ""),
113935
- path: extractedPath === "" ? "/" : extractedPath,
113936
- text: `${bundledCode}responseFoo`
113937
- };
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;
113938
113866
  }
113939
113867
  };
113940
113868
  async function PagesBuild(props) {
@@ -114525,7 +114453,7 @@ var path6 = require("path");
114525
114453
  var chokidar = require("chokidar");
114526
114454
  var listenFileTypes = ["js", "json", "html", "css", "jsx", "ts", "tsx", "vue", "md", "cjs"];
114527
114455
  async function remoteDevServer(jscontent, projectId, metaJSON) {
114528
- const res = await pagesCapi("DescribeDebugFunction", {
114456
+ const res = await pagesCapi("CreateDebugFunction", {
114529
114457
  JSContent: jscontent,
114530
114458
  ProjectId: projectId,
114531
114459
  MetaData: metaJSON
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edgeone",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Command-line interface for TencentCloud Pages Functions",
5
5
  "bin": {
6
6
  "edgeone": "./edgeone-bin/edgeone.js"