@lark-apaas/devtool-kits 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/error.html CHANGED
@@ -277,23 +277,23 @@
277
277
  // 发送 postMessage
278
278
  function sendPostMessage(message, targetOrigin) {
279
279
  const origin = targetOrigin || getPreviewParentOrigin();
280
+ console.log('sendPostMessage', message, origin);
280
281
  window.parent.postMessage(message, origin);
281
282
  }
282
283
 
283
284
  // 获取父窗口 origin
284
285
  function getPreviewParentOrigin() {
285
- // 优先使用 document.referrer
286
- if (document.referrer) {
287
- try {
288
- const url = new URL(document.referrer);
289
- return url.origin;
290
- } catch (e) {
291
- console.error('解析 referrer 失败:', e);
292
- }
286
+ const { origin } = window.location;
287
+ // 线上环境
288
+ if (origin.includes('feishuapp.cn') || origin.includes('miaoda.feishuapp.net')) {
289
+ return 'https://miaoda.feishu.cn';
293
290
  }
294
-
295
- // 降级方案:使用通配符(不安全,仅用于开发环境)
296
- return '*';
291
+ // PRE 环境
292
+ if (origin.includes('fsapp.kundou.cn') || origin.includes('miaoda-pre.feishuapp.net')) {
293
+ return 'https://miaoda.feishu-pre.cn';
294
+ }
295
+ // BOE 环境
296
+ return 'https://miaoda.feishu-boe.cn';
297
297
  }
298
298
 
299
299
  // 复制到剪贴板
package/dist/index.cjs CHANGED
@@ -19110,6 +19110,45 @@ var require_get_proto = __commonJS({
19110
19110
  }
19111
19111
  });
19112
19112
 
19113
+ // ../../../node_modules/async-function/index.js
19114
+ var require_async_function = __commonJS({
19115
+ "../../../node_modules/async-function/index.js"(exports2, module2) {
19116
+ "use strict";
19117
+ var cached = (
19118
+ /** @type {import('.').AsyncFunctionConstructor} */
19119
+ (async function() {
19120
+ }).constructor
19121
+ );
19122
+ module2.exports = () => cached;
19123
+ }
19124
+ });
19125
+
19126
+ // ../../../node_modules/generator-function/index.js
19127
+ var require_generator_function = __commonJS({
19128
+ "../../../node_modules/generator-function/index.js"(exports2, module2) {
19129
+ "use strict";
19130
+ var cached = (
19131
+ /** @type {GeneratorFunctionConstructor} */
19132
+ (function* () {
19133
+ }).constructor
19134
+ );
19135
+ module2.exports = () => cached;
19136
+ }
19137
+ });
19138
+
19139
+ // ../../../node_modules/async-generator-function/index.js
19140
+ var require_async_generator_function = __commonJS({
19141
+ "../../../node_modules/async-generator-function/index.js"(exports2, module2) {
19142
+ "use strict";
19143
+ var cached = (
19144
+ /** @type {import('.').AsyncGeneratorFunctionConstructor} */
19145
+ (async function* () {
19146
+ }).constructor
19147
+ );
19148
+ module2.exports = () => cached;
19149
+ }
19150
+ });
19151
+
19113
19152
  // ../../../node_modules/hasown/index.js
19114
19153
  var require_hasown = __commonJS({
19115
19154
  "../../../node_modules/hasown/index.js"(exports2, module2) {
@@ -19141,13 +19180,6 @@ var require_get_intrinsic = __commonJS({
19141
19180
  var pow = require_pow();
19142
19181
  var round = require_round();
19143
19182
  var sign = require_sign();
19144
- var $Function = Function;
19145
- var getEvalledConstructor = /* @__PURE__ */ __name(function(expressionSyntax) {
19146
- try {
19147
- return $Function('"use strict"; return (' + expressionSyntax + ").constructor;")();
19148
- } catch (e) {
19149
- }
19150
- }, "getEvalledConstructor");
19151
19183
  var $gOPD = require_gopd();
19152
19184
  var $defineProperty = require_es_define_property();
19153
19185
  var throwTypeError = /* @__PURE__ */ __name(function() {
@@ -19202,7 +19234,7 @@ var require_get_intrinsic = __commonJS({
19202
19234
  "%Float32Array%": typeof Float32Array === "undefined" ? undefined2 : Float32Array,
19203
19235
  "%Float64Array%": typeof Float64Array === "undefined" ? undefined2 : Float64Array,
19204
19236
  "%FinalizationRegistry%": typeof FinalizationRegistry === "undefined" ? undefined2 : FinalizationRegistry,
19205
- "%Function%": $Function,
19237
+ "%Function%": Function,
19206
19238
  "%GeneratorFunction%": needsEval,
19207
19239
  "%Int8Array%": typeof Int8Array === "undefined" ? undefined2 : Int8Array,
19208
19240
  "%Int16Array%": typeof Int16Array === "undefined" ? undefined2 : Int16Array,
@@ -19265,14 +19297,17 @@ var require_get_intrinsic = __commonJS({
19265
19297
  }
19266
19298
  }
19267
19299
  var errorProto;
19300
+ var getAsyncFunction = require_async_function();
19301
+ var getGeneratorFunction = require_generator_function();
19302
+ var getAsyncGeneratorFunction = require_async_generator_function();
19268
19303
  var doEval = /* @__PURE__ */ __name(function doEval2(name) {
19269
19304
  var value;
19270
19305
  if (name === "%AsyncFunction%") {
19271
- value = getEvalledConstructor("async function () {}");
19306
+ value = getAsyncFunction() || void undefined2;
19272
19307
  } else if (name === "%GeneratorFunction%") {
19273
- value = getEvalledConstructor("function* () {}");
19308
+ value = getGeneratorFunction() || void undefined2;
19274
19309
  } else if (name === "%AsyncGeneratorFunction%") {
19275
- value = getEvalledConstructor("async function* () {}");
19310
+ value = getAsyncGeneratorFunction() || void undefined2;
19276
19311
  } else if (name === "%AsyncGenerator%") {
19277
19312
  var fn = doEval2("%AsyncGeneratorFunction%");
19278
19313
  if (fn) {
@@ -28624,7 +28659,7 @@ function handleDevProxyError(err, req, res, options) {
28624
28659
  }
28625
28660
  const template = getErrorHtmlTemplate();
28626
28661
  const html = injectErrorData(template, errorLogs, clientBasePathWithoutSlash);
28627
- res.writeHead(200, {
28662
+ res.writeHead(502, {
28628
28663
  "Content-Type": "text/html; charset=utf-8",
28629
28664
  "Cache-Control": "no-cache, no-store, must-revalidate",
28630
28665
  "X-Proxy-Error-Page": "true"
@@ -28709,6 +28744,25 @@ async function buildSourceMap(controllerFiles, processFile) {
28709
28744
  return sourceMap;
28710
28745
  }
28711
28746
  __name(buildSourceMap, "buildSourceMap");
28747
+ function findSourceInfo(operationId, sourceMap) {
28748
+ const directMatch = sourceMap.get(operationId);
28749
+ if (directMatch) {
28750
+ return directMatch;
28751
+ }
28752
+ for (const [key, value] of sourceMap.entries()) {
28753
+ const [className, methodName] = key.split("_");
28754
+ if (!className || !methodName) continue;
28755
+ const camelCaseId = className.charAt(0).toLowerCase() + className.slice(1) + methodName.charAt(0).toUpperCase() + methodName.slice(1);
28756
+ if (operationId === camelCaseId) {
28757
+ return value;
28758
+ }
28759
+ if (operationId === methodName) {
28760
+ return value;
28761
+ }
28762
+ }
28763
+ return void 0;
28764
+ }
28765
+ __name(findSourceInfo, "findSourceInfo");
28712
28766
  function enhanceOpenApiPaths(openapi, sourceMap) {
28713
28767
  let enhancedCount = 0;
28714
28768
  if (!openapi.paths) {
@@ -28718,7 +28772,7 @@ function enhanceOpenApiPaths(openapi, sourceMap) {
28718
28772
  if (!pathItem || typeof pathItem !== "object") continue;
28719
28773
  for (const operation of Object.values(pathItem)) {
28720
28774
  if (operation && typeof operation === "object" && "operationId" in operation) {
28721
- const sourceInfo = sourceMap.get(operation.operationId);
28775
+ const sourceInfo = findSourceInfo(operation.operationId, sourceMap);
28722
28776
  if (sourceInfo) {
28723
28777
  operation["x-source"] = {
28724
28778
  file: sourceInfo.file,
@@ -28790,6 +28844,7 @@ __name(processControllerFile, "processControllerFile");
28790
28844
  function extractControllerMetadata(sourceFile, filePath) {
28791
28845
  const metadata = /* @__PURE__ */ new Map();
28792
28846
  let controllerPath = "";
28847
+ let className = "";
28793
28848
  function getDecorators(node) {
28794
28849
  if ("modifiers" in node && Array.isArray(node.modifiers)) {
28795
28850
  return node.modifiers.filter((mod) => mod.kind === import_typescript.default.SyntaxKind.Decorator);
@@ -28803,6 +28858,9 @@ function extractControllerMetadata(sourceFile, filePath) {
28803
28858
  function visit(node) {
28804
28859
  if (import_typescript.default.isClassDeclaration(node)) {
28805
28860
  const decorators = getDecorators(node);
28861
+ if (node.name) {
28862
+ className = node.name.getText(sourceFile);
28863
+ }
28806
28864
  for (const decorator of decorators) {
28807
28865
  if (import_typescript.default.isCallExpression(decorator.expression)) {
28808
28866
  const expression = decorator.expression;
@@ -28847,8 +28905,9 @@ function extractControllerMetadata(sourceFile, filePath) {
28847
28905
  }
28848
28906
  }
28849
28907
  }
28850
- if (httpMethod && methodName) {
28851
- metadata.set(methodName, {
28908
+ if (httpMethod && methodName && className) {
28909
+ const operationId = `${className}_${methodName}`;
28910
+ metadata.set(operationId, {
28852
28911
  file: filePath,
28853
28912
  line: line + 1,
28854
28913
  method: httpMethod,