@appthen/cli 1.2.7 → 1.2.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.
Files changed (2) hide show
  1. package/dist/index.js +116 -217
  2. package/package.json +1 -2
package/dist/index.js CHANGED
@@ -40667,6 +40667,7 @@ function regExpEscape (s) {
40667
40667
  return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
40668
40668
  }
40669
40669
 
40670
+ var logger = function () { };
40670
40671
  /**
40671
40672
  * 影子空间管理器
40672
40673
  * 维护编辑器状态的本地镜像,用于检测文件变更
@@ -40764,34 +40765,13 @@ var ShadowSpace = /** @class */ (function () {
40764
40765
  // 尝试迁移旧的状态文件
40765
40766
  _a.sent();
40766
40767
  // 初始化时扫描并同步项目文件
40767
- return [4 /*yield*/, this.initialSync()];
40768
- case 5:
40769
- // 初始化时扫描并同步项目文件
40770
- _a.sent();
40771
- console.log("\u5F71\u5B50\u7A7A\u95F4 [".concat(this.config.spaceId, "] \u5DF2\u521D\u59CB\u5316"));
40768
+ // await this.initialSync();
40769
+ logger("\u5F71\u5B50\u7A7A\u95F4 [".concat(this.config.spaceId, "] \u5DF2\u521D\u59CB\u5316"));
40772
40770
  return [2 /*return*/];
40773
40771
  }
40774
40772
  });
40775
40773
  });
40776
40774
  };
40777
- /**
40778
- * 初始化时扫描项目目录并同步文件
40779
- */
40780
- ShadowSpace.prototype.initialSync = function () {
40781
- return __awaiter(this, void 0, void 0, function () {
40782
- return __generator(this, function (_a) {
40783
- try {
40784
- console.log('开始初始化文件同步...');
40785
- // 暂时跳过初始化文件扫描,避免glob相关错误
40786
- console.log('跳过初始化文件扫描(功能开发中)');
40787
- }
40788
- catch (error) {
40789
- console.warn('初始化文件同步失败:', error);
40790
- }
40791
- return [2 /*return*/];
40792
- });
40793
- });
40794
- };
40795
40775
  // 暂时移除scanProjectFiles方法,避免glob相关错误
40796
40776
  /**
40797
40777
  * 从编辑器同步项目文件到影子空间
@@ -40804,7 +40784,7 @@ var ShadowSpace = /** @class */ (function () {
40804
40784
  return __generator(this, function (_g) {
40805
40785
  switch (_g.label) {
40806
40786
  case 0:
40807
- console.log("\u5F00\u59CB\u4ECE\u7F16\u8F91\u5668\u540C\u6B65 ".concat(projectFiles.length, " \u4E2A\u6587\u4EF6..."));
40787
+ logger("\u5F00\u59CB\u4ECE\u7F16\u8F91\u5668\u540C\u6B65 ".concat(projectFiles.length, " \u4E2A\u6587\u4EF6..."));
40808
40788
  newFiles = {};
40809
40789
  _g.label = 1;
40810
40790
  case 1:
@@ -40815,15 +40795,11 @@ var ShadowSpace = /** @class */ (function () {
40815
40795
  if (!!projectFiles_1_1.done) return [3 /*break*/, 6];
40816
40796
  file = projectFiles_1_1.value;
40817
40797
  if (this.shouldIgnoreFile(file.path)) {
40818
- console.log("[ShadowSpace] \u6587\u4EF6\u88AB\u5FFD\u7565: ".concat(file.path));
40798
+ logger("[ShadowSpace] \u6587\u4EF6\u88AB\u5FFD\u7565: ".concat(file.path));
40819
40799
  return [3 /*break*/, 5];
40820
40800
  }
40821
40801
  size = Buffer.byteLength(file.content, 'utf8');
40822
40802
  now = Date.now();
40823
- // 记录空内容文件
40824
- if (file.content === '') {
40825
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u7A7A\u5185\u5BB9\u6587\u4EF6: ".concat(file.path, " (size: ").concat(size, ")"));
40826
- }
40827
40803
  // 写入本地文件
40828
40804
  return [4 /*yield*/, this.writeLocalFile(file.path, file.content)];
40829
40805
  case 3:
@@ -40834,31 +40810,9 @@ var ShadowSpace = /** @class */ (function () {
40834
40810
  case 4:
40835
40811
  writtenContent = _g.sent();
40836
40812
  localHash = this.calculateHash(writtenContent);
40837
- console.log('localHash: ', localHash);
40838
40813
  remoteHash = file.hash || localHash;
40839
40814
  // 🔍 检测哈希差异,帮助诊断编码问题
40840
- if (file.hash && file.hash !== localHash) {
40841
- console.warn("[ShadowSpace] \u68C0\u6D4B\u5230\u54C8\u5E0C\u4E0D\u4E00\u81F4: ".concat(file.path), {
40842
- editorHash: file.hash.substring(0, 16),
40843
- localHash: localHash.substring(0, 16),
40844
- editorHashFull: file.hash,
40845
- localHashFull: localHash,
40846
- contentLength: file.content.length,
40847
- writtenLength: writtenContent.length,
40848
- contentSame: file.content === writtenContent,
40849
- filePath: file.path,
40850
- });
40851
- // 如果内容相同但哈希不同,可能是编码问题
40852
- if (file.content === writtenContent) {
40853
- console.error("[ShadowSpace] \u26A0\uFE0F \u5185\u5BB9\u76F8\u540C\u4F46\u54C8\u5E0C\u4E0D\u540C\uFF0C\u53EF\u80FD\u5B58\u5728\u7F16\u7801\u95EE\u9898: ".concat(file.path));
40854
- }
40855
- else {
40856
- console.error("[ShadowSpace] \u26A0\uFE0F \u5185\u5BB9\u4E0D\u540C\uFF0C\u53EF\u80FD\u662F\u6587\u4EF6\u5199\u5165\u8FC7\u7A0B\u4E2D\u7684\u8F6C\u6362\u95EE\u9898: ".concat(file.path));
40857
- // 显示前100个字符的差异
40858
- console.log("\u7F16\u8F91\u5668\u5185\u5BB9\u524D100\u5B57\u7B26: ".concat(JSON.stringify(file.content.substring(0, 100))));
40859
- console.log("\u5199\u5165\u5185\u5BB9\u524D100\u5B57\u7B26: ".concat(JSON.stringify(writtenContent.substring(0, 100))));
40860
- }
40861
- }
40815
+ if (file.hash && file.hash !== localHash) ;
40862
40816
  newFiles[file.path] = {
40863
40817
  path: file.path,
40864
40818
  hash: localHash,
@@ -40871,12 +40825,6 @@ var ShadowSpace = /** @class */ (function () {
40871
40825
  remoteModified: true,
40872
40826
  remoteModifiedTime: now,
40873
40827
  };
40874
- console.log("[ShadowSpace] \u540C\u6B65\u6587\u4EF6: ".concat(file.path), {
40875
- remoteHash: remoteHash.substring(0, 16),
40876
- localHash: localHash.substring(0, 16),
40877
- size: size,
40878
- version: newFiles[file.path].version,
40879
- });
40880
40828
  // 缓存内容用于diff
40881
40829
  this.contentCache.set(file.path, writtenContent);
40882
40830
  _g.label = 5;
@@ -40917,16 +40865,16 @@ var ShadowSpace = /** @class */ (function () {
40917
40865
  totalSize: totalSizeSum,
40918
40866
  lastSyncWithEditor: Date.now(),
40919
40867
  };
40920
- console.log("[ShadowSpace] \u66F4\u65B0\u540E\u7684\u6587\u4EF6\u7EDF\u8BA1:", {
40921
- totalFiles: totalFilesCount,
40922
- totalSize: totalSizeSum,
40923
- // fileList: Object.keys(this.state.files),
40924
- });
40868
+ // logger('[ShadowSpace] 更新后的文件统计:', {
40869
+ // totalFiles: totalFilesCount,
40870
+ // totalSize: totalSizeSum,
40871
+ // // fileList: Object.keys(this.state.files),
40872
+ // });
40925
40873
  this.state.lastUpdateTime = Date.now();
40926
40874
  return [4 /*yield*/, this.saveState()];
40927
40875
  case 10:
40928
40876
  _g.sent();
40929
- console.log("\u5F71\u5B50\u7A7A\u95F4\u540C\u6B65\u5B8C\u6210: ".concat(this.state.metadata.totalFiles, " \u4E2A\u6587\u4EF6"));
40877
+ logger("\u5F71\u5B50\u7A7A\u95F4\u540C\u6B65\u5B8C\u6210: ".concat(this.state.metadata.totalFiles, " \u4E2A\u6587\u4EF6"));
40930
40878
  return [2 /*return*/];
40931
40879
  }
40932
40880
  });
@@ -40972,7 +40920,9 @@ var ShadowSpace = /** @class */ (function () {
40972
40920
  return [4 /*yield*/, this.saveState()];
40973
40921
  case 2:
40974
40922
  _a.sent();
40975
- console.log("\u5F71\u5B50\u7A7A\u95F4\u6587\u4EF6\u5DF2\u66F4\u65B0: ".concat(filePath, " (v").concat(this.state.files[filePath].version, ")"));
40923
+ // logger(
40924
+ // `影子空间文件已更新: ${filePath} (v${this.state.files[filePath].version})`
40925
+ // );
40976
40926
  return [2 /*return*/, true];
40977
40927
  }
40978
40928
  });
@@ -40999,7 +40949,6 @@ var ShadowSpace = /** @class */ (function () {
40999
40949
  return [4 /*yield*/, fs__default$1["default"].unlink(fullPath)];
41000
40950
  case 2:
41001
40951
  _a.sent();
41002
- console.log("\u672C\u5730\u6587\u4EF6\u5DF2\u5220\u9664: ".concat(fullPath));
41003
40952
  return [3 /*break*/, 4];
41004
40953
  case 3:
41005
40954
  error_1 = _a.sent();
@@ -41013,7 +40962,6 @@ var ShadowSpace = /** @class */ (function () {
41013
40962
  return [4 /*yield*/, this.saveState()];
41014
40963
  case 5:
41015
40964
  _a.sent();
41016
- console.log("\u5F71\u5B50\u7A7A\u95F4\u6587\u4EF6\u5DF2\u5220\u9664: ".concat(filePath));
41017
40965
  return [2 /*return*/, true];
41018
40966
  }
41019
40967
  });
@@ -41024,64 +40972,57 @@ var ShadowSpace = /** @class */ (function () {
41024
40972
  * 注意:跳过 remoteModified 标记的文件,避免与编辑器检测冲突
41025
40973
  */
41026
40974
  ShadowSpace.prototype.detectChanges = function () {
41027
- var _a;
41028
40975
  return __awaiter(this, void 0, void 0, function () {
41029
- var changes, _b, _c, _d, filePath, shadowEntry, localFilePath, localContent, localHash, fileStat, fileModifyTime, shadowContent, _e, _f, error_2, shadowContent, e_3_1, localFiles, localFiles_1, localFiles_1_1, localFile;
41030
- var e_3, _g, _h, e_4, _j;
41031
- return __generator(this, function (_k) {
41032
- switch (_k.label) {
40976
+ var changes, _a, _b, _c, filePath, shadowEntry, localFilePath, localContent, localHash, fileStat, fileModifyTime, shadowContent, _d, _e, error_2, shadowContent, e_3_1, localFiles, localFiles_1, localFiles_1_1, localFile;
40977
+ var e_3, _f, _g, e_4, _h;
40978
+ return __generator(this, function (_j) {
40979
+ switch (_j.label) {
41033
40980
  case 0:
41034
40981
  changes = [];
41035
- _k.label = 1;
40982
+ _j.label = 1;
41036
40983
  case 1:
41037
- _k.trys.push([1, 16, 17, 18]);
41038
- _b = __values(Object.entries(this.state.files)), _c = _b.next();
41039
- _k.label = 2;
40984
+ _j.trys.push([1, 16, 17, 18]);
40985
+ _a = __values(Object.entries(this.state.files)), _b = _a.next();
40986
+ _j.label = 2;
41040
40987
  case 2:
41041
- if (!!_c.done) return [3 /*break*/, 15];
41042
- _d = __read(_c.value, 2), filePath = _d[0], shadowEntry = _d[1];
40988
+ if (!!_b.done) return [3 /*break*/, 15];
40989
+ _c = __read(_b.value, 2), filePath = _c[0], shadowEntry = _c[1];
41043
40990
  localFilePath = path__default["default"].join(this.config.projectRoot, filePath);
41044
- _k.label = 3;
40991
+ _j.label = 3;
41045
40992
  case 3:
41046
- _k.trys.push([3, 11, , 14]);
40993
+ _j.trys.push([3, 11, , 14]);
41047
40994
  return [4 /*yield*/, fs__default$1["default"].readFile(localFilePath, 'utf8')];
41048
40995
  case 4:
41049
- localContent = _k.sent();
40996
+ localContent = _j.sent();
41050
40997
  localHash = this.calculateHash(localContent);
41051
40998
  if (!(localHash !== shadowEntry.hash)) return [3 /*break*/, 10];
41052
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u6587\u4EF6\u53D8\u66F4: ".concat(filePath), {
41053
- localHash: localHash.substring(0, 16),
41054
- shadowHash: shadowEntry.hash.substring(0, 16),
41055
- remoteHash: ((_a = shadowEntry.remoteHash) === null || _a === void 0 ? void 0 : _a.substring(0, 16)) || 'undefined',
41056
- remoteModified: shadowEntry.remoteModified || false,
41057
- version: shadowEntry.version,
41058
- });
41059
40999
  if (!shadowEntry.remoteModified) return [3 /*break*/, 7];
41060
- console.log("[ShadowSpace] \u8DF3\u8FC7\u8FDC\u7A0B\u4FEE\u6539\u6587\u4EF6\u7684\u672C\u5730\u68C0\u6D4B: ".concat(filePath, "\uFF0C\u5C06\u7531\u65F6\u95F4\u6233\u6BD4\u5BF9\u51B3\u5B9A\u65B9\u5411"));
41061
41000
  return [4 /*yield*/, fs__default$1["default"].stat(localFilePath)];
41062
41001
  case 5:
41063
- fileStat = _k.sent();
41002
+ fileStat = _j.sent();
41064
41003
  fileModifyTime = fileStat.mtimeMs;
41065
- console.log("[ShadowSpace] \uD83D\uDD0D \u66F4\u65B0\u6587\u4EF6\u65F6\u95F4\u6233: ".concat(filePath), {
41066
- 旧lastModified: new Date(shadowEntry.lastModified || 0).toISOString(),
41067
- 旧mtime: new Date(shadowEntry.mtime || 0).toISOString(),
41068
- 新fileModifyTime: new Date(fileModifyTime).toISOString(),
41069
- 时间戳是否变化: fileModifyTime !== shadowEntry.lastModified,
41070
- });
41004
+ // logger(`[ShadowSpace] 🔍 更新文件时间戳: ${filePath}`, {
41005
+ // 旧lastModified: new Date(
41006
+ // shadowEntry.lastModified || 0
41007
+ // ).toISOString(),
41008
+ // 旧mtime: new Date(shadowEntry.mtime || 0).toISOString(),
41009
+ // 新fileModifyTime: new Date(fileModifyTime).toISOString(),
41010
+ // 时间戳是否变化: fileModifyTime !== shadowEntry.lastModified,
41011
+ // });
41071
41012
  // 更新影子空间记录,清除远程修改标记
41072
41013
  this.state.files[filePath] = __assign(__assign({}, shadowEntry), { hash: localHash, size: fileStat.size, lastSyncTime: Date.now(), version: shadowEntry.version + 1, mtime: fileModifyTime, lastModified: fileModifyTime, remoteModified: false });
41073
41014
  // 保存状态
41074
41015
  return [4 /*yield*/, this.saveState()];
41075
41016
  case 6:
41076
41017
  // 保存状态
41077
- _k.sent();
41018
+ _j.sent();
41078
41019
  // 🔥 跳过,不添加到 changes
41079
41020
  return [3 /*break*/, 14];
41080
41021
  case 7: return [4 /*yield*/, this.getShadowContent(filePath)];
41081
41022
  case 8:
41082
- shadowContent = _k.sent();
41083
- _f = (_e = changes).push;
41084
- _h = {
41023
+ shadowContent = _j.sent();
41024
+ _e = (_d = changes).push;
41025
+ _g = {
41085
41026
  id: this.generateId(),
41086
41027
  action: 'modify',
41087
41028
  path: filePath,
@@ -41089,21 +41030,21 @@ var ShadowSpace = /** @class */ (function () {
41089
41030
  };
41090
41031
  return [4 /*yield*/, fs__default$1["default"].stat(localFilePath)];
41091
41032
  case 9:
41092
- _f.apply(_e, [(_h.timestamp = (_k.sent()).mtime.getTime(),
41093
- _h.diff = {
41033
+ _e.apply(_d, [(_g.timestamp = (_j.sent()).mtime.getTime(),
41034
+ _g.diff = {
41094
41035
  before: shadowContent,
41095
41036
  after: localContent,
41096
41037
  },
41097
- _h.projectId = this.state.projectId,
41098
- _h)]);
41099
- _k.label = 10;
41038
+ _g.projectId = this.state.projectId,
41039
+ _g)]);
41040
+ _j.label = 10;
41100
41041
  case 10: return [3 /*break*/, 14];
41101
41042
  case 11:
41102
- error_2 = _k.sent();
41043
+ error_2 = _j.sent();
41103
41044
  if (!(error_2.code === 'ENOENT')) return [3 /*break*/, 13];
41104
41045
  return [4 /*yield*/, this.getShadowContent(filePath)];
41105
41046
  case 12:
41106
- shadowContent = _k.sent();
41047
+ shadowContent = _j.sent();
41107
41048
  changes.push({
41108
41049
  id: this.generateId(),
41109
41050
  action: 'delete',
@@ -41116,25 +41057,25 @@ var ShadowSpace = /** @class */ (function () {
41116
41057
  },
41117
41058
  projectId: this.state.projectId,
41118
41059
  });
41119
- _k.label = 13;
41060
+ _j.label = 13;
41120
41061
  case 13: return [3 /*break*/, 14];
41121
41062
  case 14:
41122
- _c = _b.next();
41063
+ _b = _a.next();
41123
41064
  return [3 /*break*/, 2];
41124
41065
  case 15: return [3 /*break*/, 18];
41125
41066
  case 16:
41126
- e_3_1 = _k.sent();
41067
+ e_3_1 = _j.sent();
41127
41068
  e_3 = { error: e_3_1 };
41128
41069
  return [3 /*break*/, 18];
41129
41070
  case 17:
41130
41071
  try {
41131
- if (_c && !_c.done && (_g = _b.return)) _g.call(_b);
41072
+ if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
41132
41073
  }
41133
41074
  finally { if (e_3) throw e_3.error; }
41134
41075
  return [7 /*endfinally*/];
41135
41076
  case 18: return [4 /*yield*/, this.scanLocalFiles()];
41136
41077
  case 19:
41137
- localFiles = _k.sent();
41078
+ localFiles = _j.sent();
41138
41079
  try {
41139
41080
  for (localFiles_1 = __values(localFiles), localFiles_1_1 = localFiles_1.next(); !localFiles_1_1.done; localFiles_1_1 = localFiles_1.next()) {
41140
41081
  localFile = localFiles_1_1.value;
@@ -41157,7 +41098,7 @@ var ShadowSpace = /** @class */ (function () {
41157
41098
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
41158
41099
  finally {
41159
41100
  try {
41160
- if (localFiles_1_1 && !localFiles_1_1.done && (_j = localFiles_1.return)) _j.call(localFiles_1);
41101
+ if (localFiles_1_1 && !localFiles_1_1.done && (_h = localFiles_1.return)) _h.call(localFiles_1);
41161
41102
  }
41162
41103
  finally { if (e_4) throw e_4.error; }
41163
41104
  }
@@ -41215,7 +41156,7 @@ var ShadowSpace = /** @class */ (function () {
41215
41156
  finally { if (e_5) throw e_5.error; }
41216
41157
  return [7 /*endfinally*/];
41217
41158
  case 11:
41218
- console.log("\u5F71\u5B50\u7A7A\u95F4\u5DF2\u5E94\u7528 ".concat(changes.length, " \u4E2A\u53D8\u66F4"));
41159
+ logger("\u5F71\u5B50\u7A7A\u95F4\u5DF2\u5E94\u7528 ".concat(changes.length, " \u4E2A\u53D8\u66F4"));
41219
41160
  return [2 /*return*/];
41220
41161
  }
41221
41162
  });
@@ -41227,7 +41168,7 @@ var ShadowSpace = /** @class */ (function () {
41227
41168
  ShadowSpace.prototype.getSpaceInfo = function () {
41228
41169
  var actualFileCount = Object.keys(this.state.files).length;
41229
41170
  var metadataFileCount = this.state.metadata.totalFiles;
41230
- console.log("[ShadowSpace] getSpaceInfo: spaceId=".concat(this.state.spaceId, ", metadata.totalFiles=").concat(metadataFileCount, ", actual files=").concat(actualFileCount));
41171
+ logger("[ShadowSpace] getSpaceInfo: spaceId=".concat(this.state.spaceId, ", metadata.totalFiles=").concat(metadataFileCount, ", actual files=").concat(actualFileCount));
41231
41172
  return {
41232
41173
  spaceId: this.state.spaceId,
41233
41174
  projectId: this.state.projectId,
@@ -41262,7 +41203,6 @@ var ShadowSpace = /** @class */ (function () {
41262
41203
  case 0:
41263
41204
  // 检查文件是否在影子空间中
41264
41205
  if (!this.hasFile(filePath)) {
41265
- console.log("[ShadowSpace] \u6587\u4EF6\u4E0D\u5728\u5F71\u5B50\u7A7A\u95F4\u4E2D: ".concat(filePath));
41266
41206
  return [2 /*return*/, null];
41267
41207
  }
41268
41208
  _a.label = 1;
@@ -41271,7 +41211,7 @@ var ShadowSpace = /** @class */ (function () {
41271
41211
  return [4 /*yield*/, this.getShadowContent(filePath)];
41272
41212
  case 2:
41273
41213
  content = _a.sent();
41274
- console.log("[ShadowSpace] \u6210\u529F\u8BFB\u53D6\u6587\u4EF6: ".concat(filePath, ", \u957F\u5EA6: ").concat(content.length));
41214
+ logger("[ShadowSpace] \u6210\u529F\u8BFB\u53D6\u6587\u4EF6: ".concat(filePath, ", \u957F\u5EA6: ").concat(content.length));
41275
41215
  return [2 /*return*/, content];
41276
41216
  case 3:
41277
41217
  error_3 = _a.sent();
@@ -41301,7 +41241,7 @@ var ShadowSpace = /** @class */ (function () {
41301
41241
  return [4 /*yield*/, fs__default$1["default"].readFile(fullPath, 'utf8')];
41302
41242
  case 2:
41303
41243
  content = _a.sent();
41304
- console.log("[ShadowSpace] \u5B9E\u65F6\u8BFB\u53D6\u6587\u4EF6\u6210\u529F: ".concat(filePath, ", \u957F\u5EA6: ").concat(content.length));
41244
+ logger("[ShadowSpace] \u5B9E\u65F6\u8BFB\u53D6\u6587\u4EF6\u6210\u529F: ".concat(filePath, ", \u957F\u5EA6: ").concat(content.length));
41305
41245
  // 可选:更新内存缓存以确保一致性
41306
41246
  this.contentCache.set(filePath, content);
41307
41247
  return [2 /*return*/, content];
@@ -41319,33 +41259,32 @@ var ShadowSpace = /** @class */ (function () {
41319
41259
  * 当编辑器通过WebSocket修改文件后调用此方法
41320
41260
  */
41321
41261
  ShadowSpace.prototype.markAsRemoteModified = function (filePaths) {
41322
- var _a;
41323
41262
  return __awaiter(this, void 0, void 0, function () {
41324
41263
  var now, hasChanges, filePaths_1, filePaths_1_1, filePath, fullPath, stats, content, hash, existingFile, remoteHash, error_5, e_6_1;
41325
- var e_6, _b;
41326
- return __generator(this, function (_c) {
41327
- switch (_c.label) {
41264
+ var e_6, _a;
41265
+ return __generator(this, function (_b) {
41266
+ switch (_b.label) {
41328
41267
  case 0:
41329
41268
  now = Date.now();
41330
41269
  hasChanges = false;
41331
- _c.label = 1;
41270
+ _b.label = 1;
41332
41271
  case 1:
41333
- _c.trys.push([1, 9, 10, 11]);
41272
+ _b.trys.push([1, 9, 10, 11]);
41334
41273
  filePaths_1 = __values(filePaths), filePaths_1_1 = filePaths_1.next();
41335
- _c.label = 2;
41274
+ _b.label = 2;
41336
41275
  case 2:
41337
41276
  if (!!filePaths_1_1.done) return [3 /*break*/, 8];
41338
41277
  filePath = filePaths_1_1.value;
41339
41278
  fullPath = path__default["default"].resolve(this.config.projectRoot, filePath);
41340
- _c.label = 3;
41279
+ _b.label = 3;
41341
41280
  case 3:
41342
- _c.trys.push([3, 6, , 7]);
41281
+ _b.trys.push([3, 6, , 7]);
41343
41282
  return [4 /*yield*/, fs__default$1["default"].stat(fullPath)];
41344
41283
  case 4:
41345
- stats = _c.sent();
41284
+ stats = _b.sent();
41346
41285
  return [4 /*yield*/, fs__default$1["default"].readFile(fullPath, 'utf8')];
41347
41286
  case 5:
41348
- content = _c.sent();
41287
+ content = _b.sent();
41349
41288
  hash = this.calculateHash(content);
41350
41289
  existingFile = this.state.files[filePath];
41351
41290
  remoteHash = (existingFile === null || existingFile === void 0 ? void 0 : existingFile.remoteHash) || hash;
@@ -41362,16 +41301,9 @@ var ShadowSpace = /** @class */ (function () {
41362
41301
  remoteModifiedTime: now,
41363
41302
  };
41364
41303
  hasChanges = true;
41365
- console.log("[ShadowSpace] \u6807\u8BB0\u8FDC\u7A0B\u4FEE\u6539: ".concat(filePath), {
41366
- 版本: this.state.files[filePath].version,
41367
- hash: hash.substring(0, 16),
41368
- remoteHash: remoteHash.substring(0, 16),
41369
- 旧remoteHash: ((_a = existingFile === null || existingFile === void 0 ? void 0 : existingFile.remoteHash) === null || _a === void 0 ? void 0 : _a.substring(0, 16)) || 'undefined',
41370
- remoteHashChanged: (existingFile === null || existingFile === void 0 ? void 0 : existingFile.remoteHash) !== remoteHash,
41371
- });
41372
41304
  return [3 /*break*/, 7];
41373
41305
  case 6:
41374
- error_5 = _c.sent();
41306
+ error_5 = _b.sent();
41375
41307
  console.warn("\u6807\u8BB0\u8FDC\u7A0B\u4FEE\u6539\u5931\u8D25 ".concat(filePath, ":"), error_5);
41376
41308
  return [3 /*break*/, 7];
41377
41309
  case 7:
@@ -41379,12 +41311,12 @@ var ShadowSpace = /** @class */ (function () {
41379
41311
  return [3 /*break*/, 2];
41380
41312
  case 8: return [3 /*break*/, 11];
41381
41313
  case 9:
41382
- e_6_1 = _c.sent();
41314
+ e_6_1 = _b.sent();
41383
41315
  e_6 = { error: e_6_1 };
41384
41316
  return [3 /*break*/, 11];
41385
41317
  case 10:
41386
41318
  try {
41387
- if (filePaths_1_1 && !filePaths_1_1.done && (_b = filePaths_1.return)) _b.call(filePaths_1);
41319
+ if (filePaths_1_1 && !filePaths_1_1.done && (_a = filePaths_1.return)) _a.call(filePaths_1);
41388
41320
  }
41389
41321
  finally { if (e_6) throw e_6.error; }
41390
41322
  return [7 /*endfinally*/];
@@ -41393,9 +41325,8 @@ var ShadowSpace = /** @class */ (function () {
41393
41325
  this.updateMetadata();
41394
41326
  return [4 /*yield*/, this.saveState()];
41395
41327
  case 12:
41396
- _c.sent();
41397
- console.log("\u5DF2\u6807\u8BB0 ".concat(filePaths.length, " \u4E2A\u6587\u4EF6\u4E3A\u8FDC\u7A0B\u4FEE\u6539"));
41398
- _c.label = 13;
41328
+ _b.sent();
41329
+ _b.label = 13;
41399
41330
  case 13: return [2 /*return*/];
41400
41331
  }
41401
41332
  });
@@ -41436,7 +41367,7 @@ var ShadowSpace = /** @class */ (function () {
41436
41367
  return [4 /*yield*/, this.saveState()];
41437
41368
  case 1:
41438
41369
  _c.sent();
41439
- console.log("\u5DF2\u6E05\u9664 ".concat(pathsToProcess.length, " \u4E2A\u6587\u4EF6\u7684\u8FDC\u7A0B\u4FEE\u6539\u6807\u8BB0"));
41370
+ logger("\u5DF2\u6E05\u9664 ".concat(pathsToProcess.length, " \u4E2A\u6587\u4EF6\u7684\u8FDC\u7A0B\u4FEE\u6539\u6807\u8BB0"));
41440
41371
  _c.label = 2;
41441
41372
  case 2: return [2 /*return*/];
41442
41373
  }
@@ -41448,34 +41379,23 @@ var ShadowSpace = /** @class */ (function () {
41448
41379
  * 用于与编辑器快照进行比对
41449
41380
  */
41450
41381
  ShadowSpace.prototype.getSpaceSnapshots = function (_spaceId) {
41451
- var _a, _b;
41452
41382
  return __awaiter(this, void 0, void 0, function () {
41453
- var snapshots, _c, _d, _e, filePath, shadowEntry, modifyTime, error_6;
41454
- var e_8, _f;
41455
- return __generator(this, function (_g) {
41456
- switch (_g.label) {
41383
+ var snapshots, _a, _b, _c, filePath, shadowEntry, modifyTime, error_6;
41384
+ var e_8, _d;
41385
+ return __generator(this, function (_e) {
41386
+ switch (_e.label) {
41457
41387
  case 0:
41458
- _g.trys.push([0, 2, , 3]);
41388
+ _e.trys.push([0, 2, , 3]);
41459
41389
  // 确保状态已加载
41460
41390
  return [4 /*yield*/, this.loadState()];
41461
41391
  case 1:
41462
41392
  // 确保状态已加载
41463
- _g.sent();
41393
+ _e.sent();
41464
41394
  snapshots = [];
41465
41395
  try {
41466
41396
  // 遍历影子空间中的所有文件
41467
- for (_c = __values(Object.entries(this.state.files)), _d = _c.next(); !_d.done; _d = _c.next()) {
41468
- _e = __read(_d.value, 2), filePath = _e[0], shadowEntry = _e[1];
41469
- // 🔍 调试哈希差异
41470
- if (shadowEntry.hash !== shadowEntry.remoteHash) {
41471
- console.log("[ShadowSpace] \u5FEB\u7167\u4E2D\u7684\u54C8\u5E0C\u5DEE\u5F02: ".concat(filePath), {
41472
- localHash: (_a = shadowEntry.hash) === null || _a === void 0 ? void 0 : _a.substring(0, 16),
41473
- remoteHash: (_b = shadowEntry.remoteHash) === null || _b === void 0 ? void 0 : _b.substring(0, 16),
41474
- localHashFull: shadowEntry.hash,
41475
- remoteHashFull: shadowEntry.remoteHash,
41476
- remoteModified: shadowEntry.remoteModified,
41477
- });
41478
- }
41397
+ for (_a = __values(Object.entries(this.state.files)), _b = _a.next(); !_b.done; _b = _a.next()) {
41398
+ _c = __read(_b.value, 2), filePath = _c[0], shadowEntry = _c[1];
41479
41399
  modifyTime = shadowEntry.mtime ||
41480
41400
  shadowEntry.lastModified ||
41481
41401
  shadowEntry.lastSyncTime ||
@@ -41494,15 +41414,15 @@ var ShadowSpace = /** @class */ (function () {
41494
41414
  catch (e_8_1) { e_8 = { error: e_8_1 }; }
41495
41415
  finally {
41496
41416
  try {
41497
- if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
41417
+ if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
41498
41418
  }
41499
41419
  finally { if (e_8) throw e_8.error; }
41500
41420
  }
41501
- console.log("[ShadowSpace] \u83B7\u53D6\u7A7A\u95F4\u5FEB\u7167: ".concat(snapshots.length, " \u4E2A\u6587\u4EF6"));
41421
+ logger("[ShadowSpace] \u83B7\u53D6\u7A7A\u95F4\u5FEB\u7167: ".concat(snapshots.length, " \u4E2A\u6587\u4EF6"));
41502
41422
  return [2 /*return*/, snapshots];
41503
41423
  case 2:
41504
- error_6 = _g.sent();
41505
- console.error("[ShadowSpace] \u83B7\u53D6\u7A7A\u95F4\u5FEB\u7167\u5931\u8D25:", error_6);
41424
+ error_6 = _e.sent();
41425
+ console.error('[ShadowSpace] 获取空间快照失败:', error_6);
41506
41426
  return [2 /*return*/, []]; // 返回空数组而不是 undefined
41507
41427
  case 3: return [2 /*return*/];
41508
41428
  }
@@ -41529,7 +41449,7 @@ var ShadowSpace = /** @class */ (function () {
41529
41449
  _a.sent();
41530
41450
  return [3 /*break*/, 4];
41531
41451
  case 4:
41532
- console.log("\u5F71\u5B50\u7A7A\u95F4 [".concat(this.config.spaceId, "] \u5DF2\u6E05\u7406"));
41452
+ logger("\u5F71\u5B50\u7A7A\u95F4 [".concat(this.config.spaceId, "] \u5DF2\u6E05\u7406"));
41533
41453
  return [2 /*return*/];
41534
41454
  }
41535
41455
  });
@@ -41555,7 +41475,6 @@ var ShadowSpace = /** @class */ (function () {
41555
41475
  var dirName = path__default["default"].basename(absolutePath);
41556
41476
  // 组合生成空间ID: 目录名-路径hash
41557
41477
  var spaceId = "".concat(dirName, "-").concat(pathHash);
41558
- console.log("[ShadowSpace] \u751F\u6210\u7A7A\u95F4ID: ".concat(spaceId, " (\u8DEF\u5F84: ").concat(absolutePath, ")"));
41559
41478
  return spaceId;
41560
41479
  };
41561
41480
  /**
@@ -41585,11 +41504,10 @@ var ShadowSpace = /** @class */ (function () {
41585
41504
  return [4 /*yield*/, fs__default$1["default"].writeFile(configFile, JSON.stringify(config, null, 2))];
41586
41505
  case 3:
41587
41506
  _a.sent();
41588
- console.log("[ShadowSpace] \u7A7A\u95F4\u914D\u7F6E\u5DF2\u4FDD\u5B58: ".concat(configFile));
41589
41507
  return [3 /*break*/, 5];
41590
41508
  case 4:
41591
41509
  error_8 = _a.sent();
41592
- console.warn("[ShadowSpace] \u4FDD\u5B58\u7A7A\u95F4\u914D\u7F6E\u5931\u8D25:", error_8);
41510
+ console.warn('[ShadowSpace] 保存空间配置失败:', error_8);
41593
41511
  return [3 /*break*/, 5];
41594
41512
  case 5: return [2 /*return*/];
41595
41513
  }
@@ -41609,15 +41527,14 @@ var ShadowSpace = /** @class */ (function () {
41609
41527
  case 0:
41610
41528
  _b.trys.push([0, 12, , 13]);
41611
41529
  appthenDir = path__default["default"].join(this.config.projectRoot, '.appthen');
41612
- console.log("[ShadowSpace] \u68C0\u67E5\u8FC1\u79FB: ".concat(appthenDir));
41613
41530
  return [4 /*yield*/, fs__default$1["default"].readdir(appthenDir)];
41614
41531
  case 1:
41615
41532
  files = _b.sent();
41616
- console.log("[ShadowSpace] .appthen\u76EE\u5F55\u6587\u4EF6: ".concat(files.join(', ')));
41533
+ logger("[ShadowSpace] .appthen\u76EE\u5F55\u6587\u4EF6: ".concat(files.join(', ')));
41617
41534
  oldStateFiles = files.filter(function (file) {
41618
41535
  return file.startsWith('shadow-space-') &&
41619
41536
  file.endsWith('.json') &&
41620
- !file.includes(_this.config.spaceId);
41537
+ !file.includes(_this.config.spaceId || '');
41621
41538
  });
41622
41539
  _b.label = 2;
41623
41540
  case 2:
@@ -41634,7 +41551,7 @@ var ShadowSpace = /** @class */ (function () {
41634
41551
  if (!(oldState.projectId === this.config.projectId &&
41635
41552
  oldState.userId === this.config.userId &&
41636
41553
  Object.keys(oldState.files || {}).length > 0)) return [3 /*break*/, 7];
41637
- console.log("[ShadowSpace] \u53D1\u73B0\u65E7\u72B6\u6001\u6587\u4EF6: ".concat(oldFile, "\uFF0C\u5305\u542B ").concat(Object.keys(oldState.files).length, " \u4E2A\u6587\u4EF6"));
41554
+ logger("[ShadowSpace] \u53D1\u73B0\u65E7\u72B6\u6001\u6587\u4EF6: ".concat(oldFile, "\uFF0C\u5305\u542B ").concat(Object.keys(oldState.files).length, " \u4E2A\u6587\u4EF6"));
41638
41555
  // 更新状态文件的spaceId
41639
41556
  oldState.spaceId = this.config.spaceId;
41640
41557
  // 合并到当前状态(优先使用旧状态的数据)
@@ -41648,8 +41565,7 @@ var ShadowSpace = /** @class */ (function () {
41648
41565
  return [4 /*yield*/, fs__default$1["default"].move(oldFilePath, backupFile)];
41649
41566
  case 6:
41650
41567
  _b.sent();
41651
- console.log("[ShadowSpace] \u5DF2\u8FC1\u79FB ".concat(Object.keys(this.state.files).length, " \u4E2A\u6587\u4EF6\u5230\u65B0\u7A7A\u95F4 ").concat(this.config.spaceId));
41652
- console.log("[ShadowSpace] \u65E7\u6587\u4EF6\u5DF2\u5907\u4EFD\u4E3A: ".concat(backupFile));
41568
+ logger("[ShadowSpace] \u5DF2\u8FC1\u79FB ".concat(Object.keys(this.state.files).length, " \u4E2A\u6587\u4EF6\u5230\u65B0\u7A7A\u95F4 ").concat(this.config.spaceId));
41653
41569
  return [3 /*break*/, 8]; // 只迁移第一个匹配的文件
41654
41570
  case 7:
41655
41571
  oldStateFiles_1_1 = oldStateFiles_1.next();
@@ -41668,7 +41584,7 @@ var ShadowSpace = /** @class */ (function () {
41668
41584
  case 11: return [3 /*break*/, 13];
41669
41585
  case 12:
41670
41586
  error_9 = _b.sent();
41671
- console.warn("[ShadowSpace] \u8FC1\u79FB\u65E7\u72B6\u6001\u6587\u4EF6\u5931\u8D25:", error_9);
41587
+ console.warn('[ShadowSpace] 迁移旧状态文件失败:', error_9);
41672
41588
  return [3 /*break*/, 13];
41673
41589
  case 13: return [2 /*return*/];
41674
41590
  }
@@ -41714,7 +41630,7 @@ var ShadowSpace = /** @class */ (function () {
41714
41630
  return "change_".concat(Date.now(), "_").concat(Math.random().toString(36).substr(2, 9));
41715
41631
  };
41716
41632
  ShadowSpace.prototype.shouldIgnoreFile = function (filePath) {
41717
- // console.log(`[ShadowSpace] shouldIgnoreFile 检查: "${filePath}"`);
41633
+ // logger(`[ShadowSpace] shouldIgnoreFile 检查: "${filePath}"`);
41718
41634
  var e_10, _a;
41719
41635
  // 特殊处理:过滤掉特定的系统文件
41720
41636
  var fileName = filePath.split('/').pop() || '';
@@ -41724,9 +41640,6 @@ var ShadowSpace = /** @class */ (function () {
41724
41640
  if (fileName === 'assets.json') {
41725
41641
  return true;
41726
41642
  }
41727
- if (fileName === 'project.json') {
41728
- return true;
41729
- }
41730
41643
  if (fileName.endsWith('.doc')) {
41731
41644
  return true;
41732
41645
  }
@@ -41735,12 +41648,10 @@ var ShadowSpace = /** @class */ (function () {
41735
41648
  var isInDocs = filePath.startsWith('docs/');
41736
41649
  var isRootConfig = filePath.match(/^[^\/]+\.(json|md|yml|yaml|toml|js|ts|py|go|rs)$/);
41737
41650
  if (!isInSrc && !isInDocs && !isRootConfig) {
41738
- console.log("[ShadowSpace] \u6587\u4EF6\u4E0D\u5728\u767D\u540D\u5355\u76EE\u5F55\u4E2D: ".concat(filePath));
41739
41651
  return true;
41740
41652
  }
41741
41653
  // 特殊处理:不忽略其他 .json 文件(即使以 . 开头)
41742
41654
  if (filePath.endsWith('.json')) {
41743
- console.log("[ShadowSpace] JSON\u6587\u4EF6\u4E0D\u5FFD\u7565: ".concat(filePath));
41744
41655
  return false;
41745
41656
  }
41746
41657
  try {
@@ -41748,7 +41659,7 @@ var ShadowSpace = /** @class */ (function () {
41748
41659
  for (var _b = __values(this.config.ignorePatterns || []), _c = _b.next(); !_c.done; _c = _b.next()) {
41749
41660
  var pattern = _c.value;
41750
41661
  if (minimatch_1(filePath, pattern)) {
41751
- console.log("[ShadowSpace] \u6587\u4EF6\u5339\u914D\u5FFD\u7565\u6A21\u5F0F: ".concat(filePath, " -> ").concat(pattern));
41662
+ logger("[ShadowSpace] \u6587\u4EF6\u5339\u914D\u5FFD\u7565\u6A21\u5F0F: ".concat(filePath, " -> ").concat(pattern));
41752
41663
  return true;
41753
41664
  }
41754
41665
  }
@@ -41765,11 +41676,10 @@ var ShadowSpace = /** @class */ (function () {
41765
41676
  this.config.includeExtensions.length > 0) {
41766
41677
  var ext = path__default["default"].extname(filePath).toLowerCase();
41767
41678
  if (!this.config.includeExtensions.includes(ext)) {
41768
- console.log("[ShadowSpace] \u6587\u4EF6\u6269\u5C55\u540D\u4E0D\u5728\u767D\u540D\u5355: ".concat(filePath, " -> ").concat(ext));
41769
41679
  return true;
41770
41680
  }
41771
41681
  }
41772
- // console.log(`[ShadowSpace] 文件通过忽略检查: ${filePath}`);
41682
+ // logger(`[ShadowSpace] 文件通过忽略检查: ${filePath}`);
41773
41683
  return false;
41774
41684
  };
41775
41685
  ShadowSpace.prototype.writeLocalFile = function (filePath, content) {
@@ -41779,7 +41689,7 @@ var ShadowSpace = /** @class */ (function () {
41779
41689
  switch (_a.label) {
41780
41690
  case 0:
41781
41691
  fullPath = path__default["default"].join(this.config.projectRoot, filePath);
41782
- console.log("[ShadowSpace] \u5199\u5165\u6587\u4EF6:", {
41692
+ logger('[ShadowSpace] 写入文件:', {
41783
41693
  filePath: filePath,
41784
41694
  fullPath: fullPath,
41785
41695
  projectRoot: this.config.projectRoot,
@@ -41794,7 +41704,6 @@ var ShadowSpace = /** @class */ (function () {
41794
41704
  return [4 /*yield*/, fs__default$1["default"].writeFile(fullPath, content, 'utf8')];
41795
41705
  case 3:
41796
41706
  _a.sent();
41797
- console.log("[ShadowSpace] \u6587\u4EF6\u5199\u5165\u6210\u529F: ".concat(fullPath));
41798
41707
  return [3 /*break*/, 5];
41799
41708
  case 4:
41800
41709
  error_11 = _a.sent();
@@ -41918,8 +41827,6 @@ var ShadowSpace = /** @class */ (function () {
41918
41827
  return [3 /*break*/, 3];
41919
41828
  case 2:
41920
41829
  _a.sent();
41921
- // 文件不存在或解析失败,使用默认状态
41922
- console.log("\u5F71\u5B50\u7A7A\u95F4\u72B6\u6001\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u72B6\u6001");
41923
41830
  return [3 /*break*/, 3];
41924
41831
  case 3: return [2 /*return*/];
41925
41832
  }
@@ -41941,11 +41848,9 @@ var ShadowSpace = /** @class */ (function () {
41941
41848
  ShadowSpace.prototype.startWatching = function () {
41942
41849
  var _this = this;
41943
41850
  if (this.isWatching) {
41944
- console.log('[ShadowSpace] 文件监听已经在运行中');
41945
41851
  return;
41946
41852
  }
41947
- console.log('[ShadowSpace] 启动文件监听...');
41948
- console.log('[ShadowSpace] 监听目录:', this.config.projectRoot);
41853
+ logger('[ShadowSpace] 监听目录:', this.config.projectRoot);
41949
41854
  try {
41950
41855
  // 🔥 使用轮询模式 + ignored 函数过滤
41951
41856
  this.watcher = chokidar__default["default"].watch(this.config.projectRoot, {
@@ -41969,7 +41874,7 @@ var ShadowSpace = /** @class */ (function () {
41969
41874
  pollInterval: 100,
41970
41875
  },
41971
41876
  });
41972
- console.log('[ShadowSpace] chokidar.watch 已调用,等待 ready 事件...');
41877
+ logger('[ShadowSpace] chokidar.watch 已调用,等待 ready 事件...');
41973
41878
  }
41974
41879
  catch (error) {
41975
41880
  console.error('[ShadowSpace] 创建文件监听器失败:', error);
@@ -41990,8 +41895,7 @@ var ShadowSpace = /** @class */ (function () {
41990
41895
  })
41991
41896
  .on('ready', function () {
41992
41897
  _this.isWatching = true;
41993
- console.log('[ShadowSpace] 文件监听已启动,正在监听:', _this.config.projectRoot);
41994
- console.log('[ShadowSpace] 监听配置: 轮询模式 (interval: 2s)');
41898
+ logger('[ShadowSpace] 文件监听已启动,正在监听:', _this.config.projectRoot);
41995
41899
  });
41996
41900
  };
41997
41901
  /**
@@ -42003,16 +41907,13 @@ var ShadowSpace = /** @class */ (function () {
42003
41907
  switch (_a.label) {
42004
41908
  case 0:
42005
41909
  if (!this.isWatching || !this.watcher) {
42006
- console.log('[ShadowSpace] 文件监听未运行');
42007
41910
  return [2 /*return*/];
42008
41911
  }
42009
- console.log('[ShadowSpace] 停止文件监听...');
42010
41912
  return [4 /*yield*/, this.watcher.close()];
42011
41913
  case 1:
42012
41914
  _a.sent();
42013
41915
  this.watcher = null;
42014
41916
  this.isWatching = false;
42015
- console.log('[ShadowSpace] 文件监听已停止');
42016
41917
  return [2 /*return*/];
42017
41918
  }
42018
41919
  });
@@ -42034,7 +41935,6 @@ var ShadowSpace = /** @class */ (function () {
42034
41935
  * 触发变更事件
42035
41936
  */
42036
41937
  ShadowSpace.prototype.emitChangeEvent = function (event) {
42037
- console.log('[ShadowSpace] 触发变更事件:', event);
42038
41938
  this.changeListeners.forEach(function (listener) {
42039
41939
  try {
42040
41940
  listener(event);
@@ -42054,10 +41954,8 @@ var ShadowSpace = /** @class */ (function () {
42054
41954
  switch (_a.label) {
42055
41955
  case 0:
42056
41956
  relativePath = path__default["default"].relative(this.config.projectRoot, filePath);
42057
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u6587\u4EF6\u53D8\u66F4: ".concat(relativePath));
42058
41957
  shadowEntry = this.state.files[relativePath];
42059
41958
  if (!(shadowEntry === null || shadowEntry === void 0 ? void 0 : shadowEntry.remoteModified)) return [3 /*break*/, 2];
42060
- console.log("[ShadowSpace] \u8DF3\u8FC7\u8FDC\u7A0B\u4FEE\u6539\u7684\u6587\u4EF6: ".concat(relativePath));
42061
41959
  shadowEntry.remoteModified = false; // 清除标记
42062
41960
  return [4 /*yield*/, this.saveState()];
42063
41961
  case 1:
@@ -42101,7 +41999,6 @@ var ShadowSpace = /** @class */ (function () {
42101
41999
  switch (_a.label) {
42102
42000
  case 0:
42103
42001
  relativePath = path__default["default"].relative(this.config.projectRoot, filePath);
42104
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u6587\u4EF6\u65B0\u589E: ".concat(relativePath));
42105
42002
  _a.label = 1;
42106
42003
  case 1:
42107
42004
  _a.trys.push([1, 4, , 5]);
@@ -42141,10 +42038,8 @@ var ShadowSpace = /** @class */ (function () {
42141
42038
  switch (_a.label) {
42142
42039
  case 0:
42143
42040
  relativePath = path__default["default"].relative(this.config.projectRoot, filePath);
42144
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u6587\u4EF6\u5220\u9664: ".concat(relativePath));
42145
42041
  shadowEntry = this.state.files[relativePath];
42146
42042
  if (!(shadowEntry === null || shadowEntry === void 0 ? void 0 : shadowEntry.remoteModified)) return [3 /*break*/, 2];
42147
- console.log("[ShadowSpace] \u8DF3\u8FC7\u8FDC\u7A0B\u5220\u9664\u7684\u6587\u4EF6: ".concat(relativePath));
42148
42043
  shadowEntry.remoteModified = false; // 清除标记
42149
42044
  return [4 /*yield*/, this.saveState()];
42150
42045
  case 1:
@@ -42359,7 +42254,7 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42359
42254
  case 13:
42360
42255
  result = _j.sent();
42361
42256
  return [3 /*break*/, 27];
42362
- case 14: return [4 /*yield*/, this.syncFromEditor(message.message.files)];
42257
+ case 14: return [4 /*yield*/, this.syncFromEditor(message.files)];
42363
42258
  case 15:
42364
42259
  result = _j.sent();
42365
42260
  return [3 /*break*/, 27];
@@ -42776,19 +42671,22 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42776
42671
  */
42777
42672
  ShadowSpaceCommandHandler.prototype.deleteFile = function (filePath) {
42778
42673
  return __awaiter(this, void 0, void 0, function () {
42779
- var allFiles, deleted, result;
42674
+ var normalizedPath, allFiles, deleted, result;
42780
42675
  return __generator(this, function (_a) {
42781
42676
  switch (_a.label) {
42782
42677
  case 0:
42783
42678
  if (!filePath) {
42784
42679
  throw new Error('File path is required');
42785
42680
  }
42786
- console.log("[ShadowSpace] \u5220\u9664\u6587\u4EF6: ".concat(filePath));
42681
+ normalizedPath = filePath.startsWith('/')
42682
+ ? filePath.substring(1)
42683
+ : filePath;
42684
+ console.log("[ShadowSpace] \u5220\u9664\u6587\u4EF6: ".concat(filePath, " -> \u6807\u51C6\u5316\u4E3A: ").concat(normalizedPath));
42787
42685
  allFiles = this.shadowSpace.getAllFilePaths();
42788
42686
  console.log('[ShadowSpace] 当前影子空间中的文件: ', allFiles);
42789
- console.log("[ShadowSpace] \u8981\u5220\u9664\u7684\u6587\u4EF6\u8DEF\u5F84: \"".concat(filePath, "\""));
42790
- console.log('[ShadowSpace] 文件是否存在:', this.shadowSpace.hasFile(filePath) ? '是' : '否');
42791
- return [4 /*yield*/, this.shadowSpace.deleteFile(filePath)];
42687
+ console.log("[ShadowSpace] \u8981\u5220\u9664\u7684\u6587\u4EF6\u8DEF\u5F84: \"".concat(normalizedPath, "\""));
42688
+ console.log('[ShadowSpace] 文件是否存在:', this.shadowSpace.hasFile(normalizedPath) ? '是' : '否');
42689
+ return [4 /*yield*/, this.shadowSpace.deleteFile(normalizedPath)];
42792
42690
  case 1:
42793
42691
  deleted = _a.sent();
42794
42692
  result = {
@@ -42797,7 +42695,7 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42797
42695
  deleted: deleted,
42798
42696
  timestamp: Date.now(),
42799
42697
  };
42800
- console.log("[ShadowSpace] \u6587\u4EF6\u5220\u9664".concat(deleted ? '成功' : '失败', ": ").concat(filePath));
42698
+ console.log("[ShadowSpace] \u6587\u4EF6\u5220\u9664".concat(deleted ? '成功' : '失败', ": ").concat(normalizedPath));
42801
42699
  return [2 /*return*/, result];
42802
42700
  }
42803
42701
  });
@@ -43222,13 +43120,13 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
43222
43120
  _d = __read(spaceMap_1_1.value, 2), path = _d[0], spaceFile = _d[1];
43223
43121
  editorFile = editorMap.get(path);
43224
43122
  if (!editorFile) {
43225
- // 空间独有的文件拉取到编辑器(或编辑器已删除)
43123
+ // 编辑器中没有但空间中有,说明编辑器删除了文件从编辑器推送删除操作到空间
43226
43124
  changes.push({
43227
43125
  action: 'delete',
43228
43126
  path: path,
43229
- side: 'space',
43230
- sourceLabel: 'shadow-space',
43231
- targetLabel: 'editor',
43127
+ side: 'editor',
43128
+ sourceLabel: 'editor',
43129
+ targetLabel: 'shadow-space',
43232
43130
  editorHash: null,
43233
43131
  spaceHash: spaceFile.hash,
43234
43132
  });
@@ -43608,7 +43506,8 @@ function startConnecting(options) {
43608
43506
  else if ((_b = data === null || data === void 0 ? void 0 : data.message) === null || _b === void 0 ? void 0 : _b.action) {
43609
43507
  // 嵌套格式(前端发送的格式)
43610
43508
  action = data.message.action;
43611
- message = data.message;
43509
+ // 🆕 对于嵌套格式,需要提取内层的 message
43510
+ message = data.message.message;
43612
43511
  }
43613
43512
  else {
43614
43513
  extracted = data || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appthen/cli",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Appthen Cli Tool",
5
5
  "files": [
6
6
  "dist",
@@ -39,7 +39,6 @@
39
39
  "dev": "build-scripts start",
40
40
  "lint": "eslint --ext .tsx,.ts,.js,.jsx src",
41
41
  "lintfix": "eslint --fix --color --ext .tsx,.ts,.js,.jsx src",
42
- "postpublish": "git push origin master --tags",
43
42
  "test": "jest",
44
43
  "test:watch": "jest --watch",
45
44
  "test:update-snapshots": "cross-env UPDATE_EXPECTED=true npx jest"