@appthen/cli 1.2.6 → 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 +328 -224
  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:
@@ -40835,6 +40811,8 @@ var ShadowSpace = /** @class */ (function () {
40835
40811
  writtenContent = _g.sent();
40836
40812
  localHash = this.calculateHash(writtenContent);
40837
40813
  remoteHash = file.hash || localHash;
40814
+ // 🔍 检测哈希差异,帮助诊断编码问题
40815
+ if (file.hash && file.hash !== localHash) ;
40838
40816
  newFiles[file.path] = {
40839
40817
  path: file.path,
40840
40818
  hash: localHash,
@@ -40847,12 +40825,6 @@ var ShadowSpace = /** @class */ (function () {
40847
40825
  remoteModified: true,
40848
40826
  remoteModifiedTime: now,
40849
40827
  };
40850
- console.log("[ShadowSpace] \u540C\u6B65\u6587\u4EF6: ".concat(file.path), {
40851
- remoteHash: remoteHash.substring(0, 16),
40852
- localHash: localHash.substring(0, 16),
40853
- size: size,
40854
- version: newFiles[file.path].version,
40855
- });
40856
40828
  // 缓存内容用于diff
40857
40829
  this.contentCache.set(file.path, writtenContent);
40858
40830
  _g.label = 5;
@@ -40893,16 +40865,16 @@ var ShadowSpace = /** @class */ (function () {
40893
40865
  totalSize: totalSizeSum,
40894
40866
  lastSyncWithEditor: Date.now(),
40895
40867
  };
40896
- console.log("[ShadowSpace] \u66F4\u65B0\u540E\u7684\u6587\u4EF6\u7EDF\u8BA1:", {
40897
- totalFiles: totalFilesCount,
40898
- totalSize: totalSizeSum,
40899
- // fileList: Object.keys(this.state.files),
40900
- });
40868
+ // logger('[ShadowSpace] 更新后的文件统计:', {
40869
+ // totalFiles: totalFilesCount,
40870
+ // totalSize: totalSizeSum,
40871
+ // // fileList: Object.keys(this.state.files),
40872
+ // });
40901
40873
  this.state.lastUpdateTime = Date.now();
40902
40874
  return [4 /*yield*/, this.saveState()];
40903
40875
  case 10:
40904
40876
  _g.sent();
40905
- 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"));
40906
40878
  return [2 /*return*/];
40907
40879
  }
40908
40880
  });
@@ -40948,7 +40920,9 @@ var ShadowSpace = /** @class */ (function () {
40948
40920
  return [4 /*yield*/, this.saveState()];
40949
40921
  case 2:
40950
40922
  _a.sent();
40951
- 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
+ // );
40952
40926
  return [2 /*return*/, true];
40953
40927
  }
40954
40928
  });
@@ -40975,7 +40949,6 @@ var ShadowSpace = /** @class */ (function () {
40975
40949
  return [4 /*yield*/, fs__default$1["default"].unlink(fullPath)];
40976
40950
  case 2:
40977
40951
  _a.sent();
40978
- console.log("\u672C\u5730\u6587\u4EF6\u5DF2\u5220\u9664: ".concat(fullPath));
40979
40952
  return [3 /*break*/, 4];
40980
40953
  case 3:
40981
40954
  error_1 = _a.sent();
@@ -40989,7 +40962,6 @@ var ShadowSpace = /** @class */ (function () {
40989
40962
  return [4 /*yield*/, this.saveState()];
40990
40963
  case 5:
40991
40964
  _a.sent();
40992
- console.log("\u5F71\u5B50\u7A7A\u95F4\u6587\u4EF6\u5DF2\u5220\u9664: ".concat(filePath));
40993
40965
  return [2 /*return*/, true];
40994
40966
  }
40995
40967
  });
@@ -40997,64 +40969,60 @@ var ShadowSpace = /** @class */ (function () {
40997
40969
  };
40998
40970
  /**
40999
40971
  * 检测本地文件系统与影子空间的差异
40972
+ * 注意:跳过 remoteModified 标记的文件,避免与编辑器检测冲突
41000
40973
  */
41001
40974
  ShadowSpace.prototype.detectChanges = function () {
41002
- var _a;
41003
40975
  return __awaiter(this, void 0, void 0, function () {
41004
- var changes, _b, _c, _d, filePath, shadowEntry, localFilePath, localContent, localHash, _e, _f, _g, shadowContent, _h, _j, error_2, shadowContent, e_3_1, localFiles, localFiles_1, localFiles_1_1, localFile;
41005
- var e_3, _k, _l, _m, e_4, _o;
41006
- return __generator(this, function (_p) {
41007
- switch (_p.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) {
41008
40980
  case 0:
41009
40981
  changes = [];
41010
- _p.label = 1;
40982
+ _j.label = 1;
41011
40983
  case 1:
41012
- _p.trys.push([1, 16, 17, 18]);
41013
- _b = __values(Object.entries(this.state.files)), _c = _b.next();
41014
- _p.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;
41015
40987
  case 2:
41016
- if (!!_c.done) return [3 /*break*/, 15];
41017
- _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];
41018
40990
  localFilePath = path__default["default"].join(this.config.projectRoot, filePath);
41019
- _p.label = 3;
40991
+ _j.label = 3;
41020
40992
  case 3:
41021
- _p.trys.push([3, 11, , 14]);
40993
+ _j.trys.push([3, 11, , 14]);
41022
40994
  return [4 /*yield*/, fs__default$1["default"].readFile(localFilePath, 'utf8')];
41023
40995
  case 4:
41024
- localContent = _p.sent();
40996
+ localContent = _j.sent();
41025
40997
  localHash = this.calculateHash(localContent);
41026
40998
  if (!(localHash !== shadowEntry.hash)) return [3 /*break*/, 10];
41027
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u6587\u4EF6\u53D8\u66F4: ".concat(filePath), {
41028
- localHash: localHash.substring(0, 16),
41029
- shadowHash: shadowEntry.hash.substring(0, 16),
41030
- remoteHash: ((_a = shadowEntry.remoteHash) === null || _a === void 0 ? void 0 : _a.substring(0, 16)) || 'undefined',
41031
- remoteModified: shadowEntry.remoteModified || false,
41032
- version: shadowEntry.version,
41033
- });
41034
40999
  if (!shadowEntry.remoteModified) return [3 /*break*/, 7];
41035
- // 如果是远程修改,先更新影子空间记录并清除远程修改标记
41036
- console.log("\u68C0\u6D4B\u5230\u8FDC\u7A0B\u4FEE\u6539\u6587\u4EF6\u7684\u672C\u5730\u53D8\u5316: ".concat(filePath));
41037
- // 更新影子空间记录
41038
- _e = this.state.files;
41039
- _f = filePath;
41040
- _g = [__assign({}, shadowEntry)];
41041
- _l = { hash: localHash };
41042
41000
  return [4 /*yield*/, fs__default$1["default"].stat(localFilePath)];
41043
41001
  case 5:
41044
- _l.size = (_p.sent()).size, _l.lastSyncTime = Date.now(), _l.version = shadowEntry.version + 1;
41045
- return [4 /*yield*/, fs__default$1["default"].stat(localFilePath)];
41002
+ fileStat = _j.sent();
41003
+ fileModifyTime = fileStat.mtimeMs;
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
+ // });
41012
+ // 更新影子空间记录,清除远程修改标记
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 });
41014
+ // 保存状态
41015
+ return [4 /*yield*/, this.saveState()];
41046
41016
  case 6:
41047
- // 更新影子空间记录
41048
- _e[_f] = __assign.apply(void 0, _g.concat([(_l.mtime = (_p.sent()).mtimeMs, _l.remoteModified = false, _l)]));
41049
- // 如果本地内容与最初的远程内容不同,则认为是本地修改
41050
- // 这里我们简化处理:任何在远程修改基础上的本地变化都视为本地修改
41051
- console.log("\u6587\u4EF6 ".concat(filePath, " \u5728\u8FDC\u7A0B\u4FEE\u6539\u57FA\u7840\u4E0A\u53D1\u751F\u4E86\u672C\u5730\u53D8\u5316\uFF0C\u6807\u8BB0\u4E3A\u672C\u5730\u4FEE\u6539"));
41052
- _p.label = 7;
41017
+ // 保存状态
41018
+ _j.sent();
41019
+ // 🔥 跳过,不添加到 changes
41020
+ return [3 /*break*/, 14];
41053
41021
  case 7: return [4 /*yield*/, this.getShadowContent(filePath)];
41054
41022
  case 8:
41055
- shadowContent = _p.sent();
41056
- _j = (_h = changes).push;
41057
- _m = {
41023
+ shadowContent = _j.sent();
41024
+ _e = (_d = changes).push;
41025
+ _g = {
41058
41026
  id: this.generateId(),
41059
41027
  action: 'modify',
41060
41028
  path: filePath,
@@ -41062,21 +41030,21 @@ var ShadowSpace = /** @class */ (function () {
41062
41030
  };
41063
41031
  return [4 /*yield*/, fs__default$1["default"].stat(localFilePath)];
41064
41032
  case 9:
41065
- _j.apply(_h, [(_m.timestamp = (_p.sent()).mtime.getTime(),
41066
- _m.diff = {
41033
+ _e.apply(_d, [(_g.timestamp = (_j.sent()).mtime.getTime(),
41034
+ _g.diff = {
41067
41035
  before: shadowContent,
41068
41036
  after: localContent,
41069
41037
  },
41070
- _m.projectId = this.state.projectId,
41071
- _m)]);
41072
- _p.label = 10;
41038
+ _g.projectId = this.state.projectId,
41039
+ _g)]);
41040
+ _j.label = 10;
41073
41041
  case 10: return [3 /*break*/, 14];
41074
41042
  case 11:
41075
- error_2 = _p.sent();
41043
+ error_2 = _j.sent();
41076
41044
  if (!(error_2.code === 'ENOENT')) return [3 /*break*/, 13];
41077
41045
  return [4 /*yield*/, this.getShadowContent(filePath)];
41078
41046
  case 12:
41079
- shadowContent = _p.sent();
41047
+ shadowContent = _j.sent();
41080
41048
  changes.push({
41081
41049
  id: this.generateId(),
41082
41050
  action: 'delete',
@@ -41089,25 +41057,25 @@ var ShadowSpace = /** @class */ (function () {
41089
41057
  },
41090
41058
  projectId: this.state.projectId,
41091
41059
  });
41092
- _p.label = 13;
41060
+ _j.label = 13;
41093
41061
  case 13: return [3 /*break*/, 14];
41094
41062
  case 14:
41095
- _c = _b.next();
41063
+ _b = _a.next();
41096
41064
  return [3 /*break*/, 2];
41097
41065
  case 15: return [3 /*break*/, 18];
41098
41066
  case 16:
41099
- e_3_1 = _p.sent();
41067
+ e_3_1 = _j.sent();
41100
41068
  e_3 = { error: e_3_1 };
41101
41069
  return [3 /*break*/, 18];
41102
41070
  case 17:
41103
41071
  try {
41104
- if (_c && !_c.done && (_k = _b.return)) _k.call(_b);
41072
+ if (_b && !_b.done && (_f = _a.return)) _f.call(_a);
41105
41073
  }
41106
41074
  finally { if (e_3) throw e_3.error; }
41107
41075
  return [7 /*endfinally*/];
41108
41076
  case 18: return [4 /*yield*/, this.scanLocalFiles()];
41109
41077
  case 19:
41110
- localFiles = _p.sent();
41078
+ localFiles = _j.sent();
41111
41079
  try {
41112
41080
  for (localFiles_1 = __values(localFiles), localFiles_1_1 = localFiles_1.next(); !localFiles_1_1.done; localFiles_1_1 = localFiles_1.next()) {
41113
41081
  localFile = localFiles_1_1.value;
@@ -41130,7 +41098,7 @@ var ShadowSpace = /** @class */ (function () {
41130
41098
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
41131
41099
  finally {
41132
41100
  try {
41133
- if (localFiles_1_1 && !localFiles_1_1.done && (_o = localFiles_1.return)) _o.call(localFiles_1);
41101
+ if (localFiles_1_1 && !localFiles_1_1.done && (_h = localFiles_1.return)) _h.call(localFiles_1);
41134
41102
  }
41135
41103
  finally { if (e_4) throw e_4.error; }
41136
41104
  }
@@ -41188,7 +41156,7 @@ var ShadowSpace = /** @class */ (function () {
41188
41156
  finally { if (e_5) throw e_5.error; }
41189
41157
  return [7 /*endfinally*/];
41190
41158
  case 11:
41191
- 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"));
41192
41160
  return [2 /*return*/];
41193
41161
  }
41194
41162
  });
@@ -41200,7 +41168,7 @@ var ShadowSpace = /** @class */ (function () {
41200
41168
  ShadowSpace.prototype.getSpaceInfo = function () {
41201
41169
  var actualFileCount = Object.keys(this.state.files).length;
41202
41170
  var metadataFileCount = this.state.metadata.totalFiles;
41203
- 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));
41204
41172
  return {
41205
41173
  spaceId: this.state.spaceId,
41206
41174
  projectId: this.state.projectId,
@@ -41235,7 +41203,6 @@ var ShadowSpace = /** @class */ (function () {
41235
41203
  case 0:
41236
41204
  // 检查文件是否在影子空间中
41237
41205
  if (!this.hasFile(filePath)) {
41238
- console.log("[ShadowSpace] \u6587\u4EF6\u4E0D\u5728\u5F71\u5B50\u7A7A\u95F4\u4E2D: ".concat(filePath));
41239
41206
  return [2 /*return*/, null];
41240
41207
  }
41241
41208
  _a.label = 1;
@@ -41244,7 +41211,7 @@ var ShadowSpace = /** @class */ (function () {
41244
41211
  return [4 /*yield*/, this.getShadowContent(filePath)];
41245
41212
  case 2:
41246
41213
  content = _a.sent();
41247
- 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));
41248
41215
  return [2 /*return*/, content];
41249
41216
  case 3:
41250
41217
  error_3 = _a.sent();
@@ -41274,7 +41241,7 @@ var ShadowSpace = /** @class */ (function () {
41274
41241
  return [4 /*yield*/, fs__default$1["default"].readFile(fullPath, 'utf8')];
41275
41242
  case 2:
41276
41243
  content = _a.sent();
41277
- 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));
41278
41245
  // 可选:更新内存缓存以确保一致性
41279
41246
  this.contentCache.set(filePath, content);
41280
41247
  return [2 /*return*/, content];
@@ -41292,33 +41259,32 @@ var ShadowSpace = /** @class */ (function () {
41292
41259
  * 当编辑器通过WebSocket修改文件后调用此方法
41293
41260
  */
41294
41261
  ShadowSpace.prototype.markAsRemoteModified = function (filePaths) {
41295
- var _a;
41296
41262
  return __awaiter(this, void 0, void 0, function () {
41297
41263
  var now, hasChanges, filePaths_1, filePaths_1_1, filePath, fullPath, stats, content, hash, existingFile, remoteHash, error_5, e_6_1;
41298
- var e_6, _b;
41299
- return __generator(this, function (_c) {
41300
- switch (_c.label) {
41264
+ var e_6, _a;
41265
+ return __generator(this, function (_b) {
41266
+ switch (_b.label) {
41301
41267
  case 0:
41302
41268
  now = Date.now();
41303
41269
  hasChanges = false;
41304
- _c.label = 1;
41270
+ _b.label = 1;
41305
41271
  case 1:
41306
- _c.trys.push([1, 9, 10, 11]);
41272
+ _b.trys.push([1, 9, 10, 11]);
41307
41273
  filePaths_1 = __values(filePaths), filePaths_1_1 = filePaths_1.next();
41308
- _c.label = 2;
41274
+ _b.label = 2;
41309
41275
  case 2:
41310
41276
  if (!!filePaths_1_1.done) return [3 /*break*/, 8];
41311
41277
  filePath = filePaths_1_1.value;
41312
41278
  fullPath = path__default["default"].resolve(this.config.projectRoot, filePath);
41313
- _c.label = 3;
41279
+ _b.label = 3;
41314
41280
  case 3:
41315
- _c.trys.push([3, 6, , 7]);
41281
+ _b.trys.push([3, 6, , 7]);
41316
41282
  return [4 /*yield*/, fs__default$1["default"].stat(fullPath)];
41317
41283
  case 4:
41318
- stats = _c.sent();
41284
+ stats = _b.sent();
41319
41285
  return [4 /*yield*/, fs__default$1["default"].readFile(fullPath, 'utf8')];
41320
41286
  case 5:
41321
- content = _c.sent();
41287
+ content = _b.sent();
41322
41288
  hash = this.calculateHash(content);
41323
41289
  existingFile = this.state.files[filePath];
41324
41290
  remoteHash = (existingFile === null || existingFile === void 0 ? void 0 : existingFile.remoteHash) || hash;
@@ -41335,16 +41301,9 @@ var ShadowSpace = /** @class */ (function () {
41335
41301
  remoteModifiedTime: now,
41336
41302
  };
41337
41303
  hasChanges = true;
41338
- console.log("[ShadowSpace] \u6807\u8BB0\u8FDC\u7A0B\u4FEE\u6539: ".concat(filePath), {
41339
- 版本: this.state.files[filePath].version,
41340
- hash: hash.substring(0, 16),
41341
- remoteHash: remoteHash.substring(0, 16),
41342
- 旧remoteHash: ((_a = existingFile === null || existingFile === void 0 ? void 0 : existingFile.remoteHash) === null || _a === void 0 ? void 0 : _a.substring(0, 16)) || 'undefined',
41343
- remoteHashChanged: (existingFile === null || existingFile === void 0 ? void 0 : existingFile.remoteHash) !== remoteHash,
41344
- });
41345
41304
  return [3 /*break*/, 7];
41346
41305
  case 6:
41347
- error_5 = _c.sent();
41306
+ error_5 = _b.sent();
41348
41307
  console.warn("\u6807\u8BB0\u8FDC\u7A0B\u4FEE\u6539\u5931\u8D25 ".concat(filePath, ":"), error_5);
41349
41308
  return [3 /*break*/, 7];
41350
41309
  case 7:
@@ -41352,12 +41311,12 @@ var ShadowSpace = /** @class */ (function () {
41352
41311
  return [3 /*break*/, 2];
41353
41312
  case 8: return [3 /*break*/, 11];
41354
41313
  case 9:
41355
- e_6_1 = _c.sent();
41314
+ e_6_1 = _b.sent();
41356
41315
  e_6 = { error: e_6_1 };
41357
41316
  return [3 /*break*/, 11];
41358
41317
  case 10:
41359
41318
  try {
41360
- 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);
41361
41320
  }
41362
41321
  finally { if (e_6) throw e_6.error; }
41363
41322
  return [7 /*endfinally*/];
@@ -41366,9 +41325,8 @@ var ShadowSpace = /** @class */ (function () {
41366
41325
  this.updateMetadata();
41367
41326
  return [4 /*yield*/, this.saveState()];
41368
41327
  case 12:
41369
- _c.sent();
41370
- console.log("\u5DF2\u6807\u8BB0 ".concat(filePaths.length, " \u4E2A\u6587\u4EF6\u4E3A\u8FDC\u7A0B\u4FEE\u6539"));
41371
- _c.label = 13;
41328
+ _b.sent();
41329
+ _b.label = 13;
41372
41330
  case 13: return [2 /*return*/];
41373
41331
  }
41374
41332
  });
@@ -41409,7 +41367,7 @@ var ShadowSpace = /** @class */ (function () {
41409
41367
  return [4 /*yield*/, this.saveState()];
41410
41368
  case 1:
41411
41369
  _c.sent();
41412
- 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"));
41413
41371
  _c.label = 2;
41414
41372
  case 2: return [2 /*return*/];
41415
41373
  }
@@ -41422,7 +41380,7 @@ var ShadowSpace = /** @class */ (function () {
41422
41380
  */
41423
41381
  ShadowSpace.prototype.getSpaceSnapshots = function (_spaceId) {
41424
41382
  return __awaiter(this, void 0, void 0, function () {
41425
- var snapshots, _a, _b, _c, filePath, shadowEntry, error_6;
41383
+ var snapshots, _a, _b, _c, filePath, shadowEntry, modifyTime, error_6;
41426
41384
  var e_8, _d;
41427
41385
  return __generator(this, function (_e) {
41428
41386
  switch (_e.label) {
@@ -41438,12 +41396,13 @@ var ShadowSpace = /** @class */ (function () {
41438
41396
  // 遍历影子空间中的所有文件
41439
41397
  for (_a = __values(Object.entries(this.state.files)), _b = _a.next(); !_b.done; _b = _a.next()) {
41440
41398
  _c = __read(_b.value, 2), filePath = _c[0], shadowEntry = _c[1];
41399
+ modifyTime = shadowEntry.mtime ||
41400
+ shadowEntry.lastModified ||
41401
+ shadowEntry.lastSyncTime ||
41402
+ Date.now();
41441
41403
  snapshots.push({
41442
41404
  path: filePath,
41443
- modify: shadowEntry.lastModified ||
41444
- shadowEntry.mtime ||
41445
- shadowEntry.lastSyncTime ||
41446
- Date.now(),
41405
+ modify: modifyTime,
41447
41406
  hash: shadowEntry.hash,
41448
41407
  remoteHash: shadowEntry.remoteHash || shadowEntry.hash,
41449
41408
  updateBy: shadowEntry.remoteModified ? 'shadow-space' : 'local',
@@ -41459,11 +41418,11 @@ var ShadowSpace = /** @class */ (function () {
41459
41418
  }
41460
41419
  finally { if (e_8) throw e_8.error; }
41461
41420
  }
41462
- 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"));
41463
41422
  return [2 /*return*/, snapshots];
41464
41423
  case 2:
41465
41424
  error_6 = _e.sent();
41466
- console.error("[ShadowSpace] \u83B7\u53D6\u7A7A\u95F4\u5FEB\u7167\u5931\u8D25:", error_6);
41425
+ console.error('[ShadowSpace] 获取空间快照失败:', error_6);
41467
41426
  return [2 /*return*/, []]; // 返回空数组而不是 undefined
41468
41427
  case 3: return [2 /*return*/];
41469
41428
  }
@@ -41490,7 +41449,7 @@ var ShadowSpace = /** @class */ (function () {
41490
41449
  _a.sent();
41491
41450
  return [3 /*break*/, 4];
41492
41451
  case 4:
41493
- 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"));
41494
41453
  return [2 /*return*/];
41495
41454
  }
41496
41455
  });
@@ -41516,7 +41475,6 @@ var ShadowSpace = /** @class */ (function () {
41516
41475
  var dirName = path__default["default"].basename(absolutePath);
41517
41476
  // 组合生成空间ID: 目录名-路径hash
41518
41477
  var spaceId = "".concat(dirName, "-").concat(pathHash);
41519
- console.log("[ShadowSpace] \u751F\u6210\u7A7A\u95F4ID: ".concat(spaceId, " (\u8DEF\u5F84: ").concat(absolutePath, ")"));
41520
41478
  return spaceId;
41521
41479
  };
41522
41480
  /**
@@ -41546,11 +41504,10 @@ var ShadowSpace = /** @class */ (function () {
41546
41504
  return [4 /*yield*/, fs__default$1["default"].writeFile(configFile, JSON.stringify(config, null, 2))];
41547
41505
  case 3:
41548
41506
  _a.sent();
41549
- console.log("[ShadowSpace] \u7A7A\u95F4\u914D\u7F6E\u5DF2\u4FDD\u5B58: ".concat(configFile));
41550
41507
  return [3 /*break*/, 5];
41551
41508
  case 4:
41552
41509
  error_8 = _a.sent();
41553
- console.warn("[ShadowSpace] \u4FDD\u5B58\u7A7A\u95F4\u914D\u7F6E\u5931\u8D25:", error_8);
41510
+ console.warn('[ShadowSpace] 保存空间配置失败:', error_8);
41554
41511
  return [3 /*break*/, 5];
41555
41512
  case 5: return [2 /*return*/];
41556
41513
  }
@@ -41570,15 +41527,14 @@ var ShadowSpace = /** @class */ (function () {
41570
41527
  case 0:
41571
41528
  _b.trys.push([0, 12, , 13]);
41572
41529
  appthenDir = path__default["default"].join(this.config.projectRoot, '.appthen');
41573
- console.log("[ShadowSpace] \u68C0\u67E5\u8FC1\u79FB: ".concat(appthenDir));
41574
41530
  return [4 /*yield*/, fs__default$1["default"].readdir(appthenDir)];
41575
41531
  case 1:
41576
41532
  files = _b.sent();
41577
- console.log("[ShadowSpace] .appthen\u76EE\u5F55\u6587\u4EF6: ".concat(files.join(', ')));
41533
+ logger("[ShadowSpace] .appthen\u76EE\u5F55\u6587\u4EF6: ".concat(files.join(', ')));
41578
41534
  oldStateFiles = files.filter(function (file) {
41579
41535
  return file.startsWith('shadow-space-') &&
41580
41536
  file.endsWith('.json') &&
41581
- !file.includes(_this.config.spaceId);
41537
+ !file.includes(_this.config.spaceId || '');
41582
41538
  });
41583
41539
  _b.label = 2;
41584
41540
  case 2:
@@ -41595,7 +41551,7 @@ var ShadowSpace = /** @class */ (function () {
41595
41551
  if (!(oldState.projectId === this.config.projectId &&
41596
41552
  oldState.userId === this.config.userId &&
41597
41553
  Object.keys(oldState.files || {}).length > 0)) return [3 /*break*/, 7];
41598
- 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"));
41599
41555
  // 更新状态文件的spaceId
41600
41556
  oldState.spaceId = this.config.spaceId;
41601
41557
  // 合并到当前状态(优先使用旧状态的数据)
@@ -41609,8 +41565,7 @@ var ShadowSpace = /** @class */ (function () {
41609
41565
  return [4 /*yield*/, fs__default$1["default"].move(oldFilePath, backupFile)];
41610
41566
  case 6:
41611
41567
  _b.sent();
41612
- console.log("[ShadowSpace] \u5DF2\u8FC1\u79FB ".concat(Object.keys(this.state.files).length, " \u4E2A\u6587\u4EF6\u5230\u65B0\u7A7A\u95F4 ").concat(this.config.spaceId));
41613
- 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));
41614
41569
  return [3 /*break*/, 8]; // 只迁移第一个匹配的文件
41615
41570
  case 7:
41616
41571
  oldStateFiles_1_1 = oldStateFiles_1.next();
@@ -41629,7 +41584,7 @@ var ShadowSpace = /** @class */ (function () {
41629
41584
  case 11: return [3 /*break*/, 13];
41630
41585
  case 12:
41631
41586
  error_9 = _b.sent();
41632
- console.warn("[ShadowSpace] \u8FC1\u79FB\u65E7\u72B6\u6001\u6587\u4EF6\u5931\u8D25:", error_9);
41587
+ console.warn('[ShadowSpace] 迁移旧状态文件失败:', error_9);
41633
41588
  return [3 /*break*/, 13];
41634
41589
  case 13: return [2 /*return*/];
41635
41590
  }
@@ -41665,13 +41620,17 @@ var ShadowSpace = /** @class */ (function () {
41665
41620
  });
41666
41621
  };
41667
41622
  ShadowSpace.prototype.calculateHash = function (content) {
41668
- return crypto__default["default"].createHash('sha256').update(content, 'utf8').digest('hex');
41623
+ var normalizedContent = content.replace(/\r\n/g, '\n');
41624
+ return crypto__default["default"]
41625
+ .createHash('sha256')
41626
+ .update(normalizedContent, 'utf8')
41627
+ .digest('hex');
41669
41628
  };
41670
41629
  ShadowSpace.prototype.generateId = function () {
41671
41630
  return "change_".concat(Date.now(), "_").concat(Math.random().toString(36).substr(2, 9));
41672
41631
  };
41673
41632
  ShadowSpace.prototype.shouldIgnoreFile = function (filePath) {
41674
- // console.log(`[ShadowSpace] shouldIgnoreFile 检查: "${filePath}"`);
41633
+ // logger(`[ShadowSpace] shouldIgnoreFile 检查: "${filePath}"`);
41675
41634
  var e_10, _a;
41676
41635
  // 特殊处理:过滤掉特定的系统文件
41677
41636
  var fileName = filePath.split('/').pop() || '';
@@ -41681,9 +41640,6 @@ var ShadowSpace = /** @class */ (function () {
41681
41640
  if (fileName === 'assets.json') {
41682
41641
  return true;
41683
41642
  }
41684
- if (fileName === 'project.json') {
41685
- return true;
41686
- }
41687
41643
  if (fileName.endsWith('.doc')) {
41688
41644
  return true;
41689
41645
  }
@@ -41692,12 +41648,10 @@ var ShadowSpace = /** @class */ (function () {
41692
41648
  var isInDocs = filePath.startsWith('docs/');
41693
41649
  var isRootConfig = filePath.match(/^[^\/]+\.(json|md|yml|yaml|toml|js|ts|py|go|rs)$/);
41694
41650
  if (!isInSrc && !isInDocs && !isRootConfig) {
41695
- console.log("[ShadowSpace] \u6587\u4EF6\u4E0D\u5728\u767D\u540D\u5355\u76EE\u5F55\u4E2D: ".concat(filePath));
41696
41651
  return true;
41697
41652
  }
41698
41653
  // 特殊处理:不忽略其他 .json 文件(即使以 . 开头)
41699
41654
  if (filePath.endsWith('.json')) {
41700
- console.log("[ShadowSpace] JSON\u6587\u4EF6\u4E0D\u5FFD\u7565: ".concat(filePath));
41701
41655
  return false;
41702
41656
  }
41703
41657
  try {
@@ -41705,7 +41659,7 @@ var ShadowSpace = /** @class */ (function () {
41705
41659
  for (var _b = __values(this.config.ignorePatterns || []), _c = _b.next(); !_c.done; _c = _b.next()) {
41706
41660
  var pattern = _c.value;
41707
41661
  if (minimatch_1(filePath, pattern)) {
41708
- 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));
41709
41663
  return true;
41710
41664
  }
41711
41665
  }
@@ -41722,11 +41676,10 @@ var ShadowSpace = /** @class */ (function () {
41722
41676
  this.config.includeExtensions.length > 0) {
41723
41677
  var ext = path__default["default"].extname(filePath).toLowerCase();
41724
41678
  if (!this.config.includeExtensions.includes(ext)) {
41725
- console.log("[ShadowSpace] \u6587\u4EF6\u6269\u5C55\u540D\u4E0D\u5728\u767D\u540D\u5355: ".concat(filePath, " -> ").concat(ext));
41726
41679
  return true;
41727
41680
  }
41728
41681
  }
41729
- // console.log(`[ShadowSpace] 文件通过忽略检查: ${filePath}`);
41682
+ // logger(`[ShadowSpace] 文件通过忽略检查: ${filePath}`);
41730
41683
  return false;
41731
41684
  };
41732
41685
  ShadowSpace.prototype.writeLocalFile = function (filePath, content) {
@@ -41736,7 +41689,7 @@ var ShadowSpace = /** @class */ (function () {
41736
41689
  switch (_a.label) {
41737
41690
  case 0:
41738
41691
  fullPath = path__default["default"].join(this.config.projectRoot, filePath);
41739
- console.log("[ShadowSpace] \u5199\u5165\u6587\u4EF6:", {
41692
+ logger('[ShadowSpace] 写入文件:', {
41740
41693
  filePath: filePath,
41741
41694
  fullPath: fullPath,
41742
41695
  projectRoot: this.config.projectRoot,
@@ -41751,7 +41704,6 @@ var ShadowSpace = /** @class */ (function () {
41751
41704
  return [4 /*yield*/, fs__default$1["default"].writeFile(fullPath, content, 'utf8')];
41752
41705
  case 3:
41753
41706
  _a.sent();
41754
- console.log("[ShadowSpace] \u6587\u4EF6\u5199\u5165\u6210\u529F: ".concat(fullPath));
41755
41707
  return [3 /*break*/, 5];
41756
41708
  case 4:
41757
41709
  error_11 = _a.sent();
@@ -41875,8 +41827,6 @@ var ShadowSpace = /** @class */ (function () {
41875
41827
  return [3 /*break*/, 3];
41876
41828
  case 2:
41877
41829
  _a.sent();
41878
- // 文件不存在或解析失败,使用默认状态
41879
- console.log("\u5F71\u5B50\u7A7A\u95F4\u72B6\u6001\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u72B6\u6001");
41880
41830
  return [3 /*break*/, 3];
41881
41831
  case 3: return [2 /*return*/];
41882
41832
  }
@@ -41898,11 +41848,9 @@ var ShadowSpace = /** @class */ (function () {
41898
41848
  ShadowSpace.prototype.startWatching = function () {
41899
41849
  var _this = this;
41900
41850
  if (this.isWatching) {
41901
- console.log('[ShadowSpace] 文件监听已经在运行中');
41902
41851
  return;
41903
41852
  }
41904
- console.log('[ShadowSpace] 启动文件监听...');
41905
- console.log('[ShadowSpace] 监听目录:', this.config.projectRoot);
41853
+ logger('[ShadowSpace] 监听目录:', this.config.projectRoot);
41906
41854
  try {
41907
41855
  // 🔥 使用轮询模式 + ignored 函数过滤
41908
41856
  this.watcher = chokidar__default["default"].watch(this.config.projectRoot, {
@@ -41926,7 +41874,7 @@ var ShadowSpace = /** @class */ (function () {
41926
41874
  pollInterval: 100,
41927
41875
  },
41928
41876
  });
41929
- console.log('[ShadowSpace] chokidar.watch 已调用,等待 ready 事件...');
41877
+ logger('[ShadowSpace] chokidar.watch 已调用,等待 ready 事件...');
41930
41878
  }
41931
41879
  catch (error) {
41932
41880
  console.error('[ShadowSpace] 创建文件监听器失败:', error);
@@ -41947,8 +41895,7 @@ var ShadowSpace = /** @class */ (function () {
41947
41895
  })
41948
41896
  .on('ready', function () {
41949
41897
  _this.isWatching = true;
41950
- console.log('[ShadowSpace] 文件监听已启动,正在监听:', _this.config.projectRoot);
41951
- console.log('[ShadowSpace] 监听配置: 轮询模式 (interval: 2s)');
41898
+ logger('[ShadowSpace] 文件监听已启动,正在监听:', _this.config.projectRoot);
41952
41899
  });
41953
41900
  };
41954
41901
  /**
@@ -41960,16 +41907,13 @@ var ShadowSpace = /** @class */ (function () {
41960
41907
  switch (_a.label) {
41961
41908
  case 0:
41962
41909
  if (!this.isWatching || !this.watcher) {
41963
- console.log('[ShadowSpace] 文件监听未运行');
41964
41910
  return [2 /*return*/];
41965
41911
  }
41966
- console.log('[ShadowSpace] 停止文件监听...');
41967
41912
  return [4 /*yield*/, this.watcher.close()];
41968
41913
  case 1:
41969
41914
  _a.sent();
41970
41915
  this.watcher = null;
41971
41916
  this.isWatching = false;
41972
- console.log('[ShadowSpace] 文件监听已停止');
41973
41917
  return [2 /*return*/];
41974
41918
  }
41975
41919
  });
@@ -41991,7 +41935,6 @@ var ShadowSpace = /** @class */ (function () {
41991
41935
  * 触发变更事件
41992
41936
  */
41993
41937
  ShadowSpace.prototype.emitChangeEvent = function (event) {
41994
- console.log('[ShadowSpace] 触发变更事件:', event);
41995
41938
  this.changeListeners.forEach(function (listener) {
41996
41939
  try {
41997
41940
  listener(event);
@@ -42011,10 +41954,8 @@ var ShadowSpace = /** @class */ (function () {
42011
41954
  switch (_a.label) {
42012
41955
  case 0:
42013
41956
  relativePath = path__default["default"].relative(this.config.projectRoot, filePath);
42014
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u6587\u4EF6\u53D8\u66F4: ".concat(relativePath));
42015
41957
  shadowEntry = this.state.files[relativePath];
42016
41958
  if (!(shadowEntry === null || shadowEntry === void 0 ? void 0 : shadowEntry.remoteModified)) return [3 /*break*/, 2];
42017
- console.log("[ShadowSpace] \u8DF3\u8FC7\u8FDC\u7A0B\u4FEE\u6539\u7684\u6587\u4EF6: ".concat(relativePath));
42018
41959
  shadowEntry.remoteModified = false; // 清除标记
42019
41960
  return [4 /*yield*/, this.saveState()];
42020
41961
  case 1:
@@ -42058,7 +41999,6 @@ var ShadowSpace = /** @class */ (function () {
42058
41999
  switch (_a.label) {
42059
42000
  case 0:
42060
42001
  relativePath = path__default["default"].relative(this.config.projectRoot, filePath);
42061
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u6587\u4EF6\u65B0\u589E: ".concat(relativePath));
42062
42002
  _a.label = 1;
42063
42003
  case 1:
42064
42004
  _a.trys.push([1, 4, , 5]);
@@ -42098,10 +42038,8 @@ var ShadowSpace = /** @class */ (function () {
42098
42038
  switch (_a.label) {
42099
42039
  case 0:
42100
42040
  relativePath = path__default["default"].relative(this.config.projectRoot, filePath);
42101
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u6587\u4EF6\u5220\u9664: ".concat(relativePath));
42102
42041
  shadowEntry = this.state.files[relativePath];
42103
42042
  if (!(shadowEntry === null || shadowEntry === void 0 ? void 0 : shadowEntry.remoteModified)) return [3 /*break*/, 2];
42104
- console.log("[ShadowSpace] \u8DF3\u8FC7\u8FDC\u7A0B\u5220\u9664\u7684\u6587\u4EF6: ".concat(relativePath));
42105
42043
  shadowEntry.remoteModified = false; // 清除标记
42106
42044
  return [4 /*yield*/, this.saveState()];
42107
42045
  case 1:
@@ -42316,7 +42254,7 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42316
42254
  case 13:
42317
42255
  result = _j.sent();
42318
42256
  return [3 /*break*/, 27];
42319
- case 14: return [4 /*yield*/, this.syncFromEditor(message.message.files)];
42257
+ case 14: return [4 /*yield*/, this.syncFromEditor(message.files)];
42320
42258
  case 15:
42321
42259
  result = _j.sent();
42322
42260
  return [3 /*break*/, 27];
@@ -42733,19 +42671,22 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42733
42671
  */
42734
42672
  ShadowSpaceCommandHandler.prototype.deleteFile = function (filePath) {
42735
42673
  return __awaiter(this, void 0, void 0, function () {
42736
- var allFiles, deleted, result;
42674
+ var normalizedPath, allFiles, deleted, result;
42737
42675
  return __generator(this, function (_a) {
42738
42676
  switch (_a.label) {
42739
42677
  case 0:
42740
42678
  if (!filePath) {
42741
42679
  throw new Error('File path is required');
42742
42680
  }
42743
- 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));
42744
42685
  allFiles = this.shadowSpace.getAllFilePaths();
42745
42686
  console.log('[ShadowSpace] 当前影子空间中的文件: ', allFiles);
42746
- console.log("[ShadowSpace] \u8981\u5220\u9664\u7684\u6587\u4EF6\u8DEF\u5F84: \"".concat(filePath, "\""));
42747
- console.log('[ShadowSpace] 文件是否存在:', this.shadowSpace.hasFile(filePath) ? '是' : '否');
42748
- 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)];
42749
42690
  case 1:
42750
42691
  deleted = _a.sent();
42751
42692
  result = {
@@ -42754,7 +42695,7 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42754
42695
  deleted: deleted,
42755
42696
  timestamp: Date.now(),
42756
42697
  };
42757
- console.log("[ShadowSpace] \u6587\u4EF6\u5220\u9664".concat(deleted ? '成功' : '失败', ": ").concat(filePath));
42698
+ console.log("[ShadowSpace] \u6587\u4EF6\u5220\u9664".concat(deleted ? '成功' : '失败', ": ").concat(normalizedPath));
42758
42699
  return [2 /*return*/, result];
42759
42700
  }
42760
42701
  });
@@ -42809,7 +42750,7 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42809
42750
  filePaths: filePaths || null,
42810
42751
  timestamp: Date.now(),
42811
42752
  };
42812
- console.log("[ShadowSpace] \u8FDC\u7A0B\u4FEE\u6539\u6807\u8BB0\u6E05\u9664\u5B8C\u6210");
42753
+ console.log('[ShadowSpace] 远程修改标记清除完成');
42813
42754
  return [2 /*return*/, result];
42814
42755
  }
42815
42756
  });
@@ -42900,28 +42841,155 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42900
42841
  */
42901
42842
  ShadowSpaceCommandHandler.prototype.detectEditorChanges = function (spaceId, editorSnapshots) {
42902
42843
  return __awaiter(this, void 0, void 0, function () {
42903
- var safeEditorSnapshots, spaceSnapshots, changes, summary, error_3;
42844
+ var safeEditorSnapshots, localChanges, spaceSnapshots, spaceInfo, fs, spaceDir, spaceExists, files, error_3, snapshotChanges, localAddChanges, changes, summary, error_4;
42904
42845
  return __generator(this, function (_a) {
42905
42846
  switch (_a.label) {
42906
42847
  case 0:
42907
- _a.trys.push([0, 3, , 4]);
42848
+ _a.trys.push([0, 9, , 10]);
42908
42849
  safeEditorSnapshots = Array.isArray(editorSnapshots)
42909
42850
  ? editorSnapshots
42910
42851
  : [];
42911
- return [4 /*yield*/, this.shadowSpace.getSpaceSnapshots(spaceId)];
42852
+ // console.log(
42853
+ // `[ShadowSpace] 开始检测变更: 空间=${spaceId}, 编辑器文件=${safeEditorSnapshots.length}个`
42854
+ // );
42855
+ // 1. 🔥 先检测本地文件变更,更新影子空间状态,并获取本地变更列表(包括新增文件)
42856
+ console.log("\n\uD83D\uDD0D [DEBUG] \u6B63\u5728\u68C0\u6D4B\u672C\u5730\u6587\u4EF6\u53D8\u66F4...");
42857
+ return [4 /*yield*/, this.shadowSpace.detectChanges()];
42912
42858
  case 1:
42859
+ localChanges = _a.sent();
42860
+ console.log("\uD83D\uDD0D [DEBUG] \u672C\u5730\u6587\u4EF6\u53D8\u66F4\u68C0\u6D4B\u5B8C\u6210\uFF0C\u68C0\u6D4B\u5230 ".concat(localChanges.length, " \u4E2A\u672C\u5730\u53D8\u66F4"));
42861
+ // 2. 读取空间快照
42862
+ console.log("\n\uD83D\uDD0D [DEBUG] \u6B63\u5728\u83B7\u53D6\u7A7A\u95F4\u5FEB\u7167\uFF0C\u7A7A\u95F4ID: ".concat(spaceId));
42863
+ return [4 /*yield*/, this.shadowSpace.getSpaceSnapshots(spaceId)];
42864
+ case 2:
42913
42865
  spaceSnapshots = _a.sent();
42866
+ console.log("\uD83D\uDD0D [DEBUG] getSpaceSnapshots \u8FD4\u56DE\u7ED3\u679C\u7C7B\u578B: ".concat(typeof spaceSnapshots));
42867
+ console.log("\uD83D\uDD0D [DEBUG] getSpaceSnapshots \u662F\u5426\u4E3A\u6570\u7EC4: ".concat(Array.isArray(spaceSnapshots)));
42868
+ console.log("\uD83D\uDD0D [DEBUG] getSpaceSnapshots \u539F\u59CB\u7ED3\u679C:", spaceSnapshots);
42869
+ // 🔍 友好的调试输出
42870
+ console.log('\n=== 影子空间变更检测调试 ===');
42871
+ console.log('📁 空间ID:', spaceId);
42872
+ console.log('📊 编辑器快照数量:', safeEditorSnapshots.length);
42873
+ console.log('📁 空间快照数量:', Array.isArray(spaceSnapshots) ? spaceSnapshots.length : 0);
42874
+ spaceInfo = this.shadowSpace.getSpaceInfo();
42875
+ console.log('\n🏠 影子空间信息:');
42876
+ console.log(" \uD83D\uDCC2 \u9879\u76EE\u6839\u76EE\u5F55: ".concat(spaceInfo.projectRoot));
42877
+ console.log(" \uD83D\uDCC1 \u7A7A\u95F4\u76EE\u5F55: ".concat(spaceInfo.spaceRoot));
42878
+ console.log(" \uD83D\uDCCA \u6587\u4EF6\u6570\u91CF: ".concat(spaceInfo.fileCount));
42879
+ console.log(" \uD83D\uDCE6 \u603B\u5927\u5C0F: ".concat(spaceInfo.totalSize));
42880
+ console.log(" \uD83C\uDD94 \u7528\u6237ID: ".concat(spaceInfo.userId));
42881
+ console.log(" \u23F0 \u521B\u5EFA\u65F6\u95F4: ".concat(spaceInfo.createdAt));
42882
+ console.log(" \u23F0 \u66F4\u65B0\u65F6\u95F4: ".concat(spaceInfo.updatedAt));
42883
+ require('path');
42884
+ fs = require('fs-extra');
42885
+ spaceDir = spaceInfo.spaceRoot;
42886
+ return [4 /*yield*/, fs.pathExists(spaceDir)];
42887
+ case 3:
42888
+ spaceExists = _a.sent();
42889
+ console.log("\n\uD83D\uDCC1 \u7A7A\u95F4\u76EE\u5F55\u68C0\u67E5:");
42890
+ console.log(" \uD83D\uDCC2 \u8DEF\u5F84: ".concat(spaceDir));
42891
+ console.log(" \u2705 \u662F\u5426\u5B58\u5728: ".concat(spaceExists));
42892
+ if (!spaceExists) return [3 /*break*/, 7];
42893
+ _a.label = 4;
42894
+ case 4:
42895
+ _a.trys.push([4, 6, , 7]);
42896
+ return [4 /*yield*/, fs.readdir(spaceDir)];
42897
+ case 5:
42898
+ files = _a.sent();
42899
+ console.log(" \uD83D\uDCC4 \u76EE\u5F55\u5185\u5BB9: ".concat(files.slice(0, 10).join(', ')).concat(files.length > 10 ? '...' : ''));
42900
+ return [3 /*break*/, 7];
42901
+ case 6:
42902
+ error_3 = _a.sent();
42903
+ console.log(" \u274C \u8BFB\u53D6\u76EE\u5F55\u5931\u8D25: ".concat(error_3.message));
42904
+ return [3 /*break*/, 7];
42905
+ case 7:
42906
+ // 编辑器快照详情(显示前5个)
42907
+ if (safeEditorSnapshots.length > 0) {
42908
+ console.log('\n📝 编辑器快照详情 (前5个):');
42909
+ safeEditorSnapshots.slice(0, 5).forEach(function (file, index) {
42910
+ var _a;
42911
+ console.log(" [".concat(index + 1, "] ").concat(file.path));
42912
+ console.log(" \uD83D\uDD11 hash: ".concat((_a = file.hash) === null || _a === void 0 ? void 0 : _a.substring(0, 16), "..."));
42913
+ console.log(" \u23F0 modified: ".concat(file.lastModified));
42914
+ });
42915
+ if (safeEditorSnapshots.length > 5) {
42916
+ console.log(" ... \u8FD8\u6709 ".concat(safeEditorSnapshots.length - 5, " \u4E2A\u6587\u4EF6"));
42917
+ }
42918
+ }
42919
+ // 空间快照详情(显示前5个)
42920
+ if (Array.isArray(spaceSnapshots) && spaceSnapshots.length > 0) {
42921
+ console.log('\n💾 空间快照详情 (前5个):');
42922
+ spaceSnapshots.slice(0, 5).forEach(function (file, index) {
42923
+ var _a, _b;
42924
+ console.log(" [".concat(index + 1, "] ").concat(file.path));
42925
+ console.log(" \uD83D\uDD11 \u672C\u5730hash: ".concat((_a = file.hash) === null || _a === void 0 ? void 0 : _a.substring(0, 16), "..."));
42926
+ console.log(" \u2601\uFE0F \u4E91\u7AEFhash: ".concat((_b = file.remoteHash) === null || _b === void 0 ? void 0 : _b.substring(0, 16), "..."));
42927
+ console.log(" \u23F0 modified: ".concat(file.lastModified));
42928
+ });
42929
+ if (spaceSnapshots.length > 5) {
42930
+ console.log(" ... \u8FD8\u6709 ".concat(spaceSnapshots.length - 5, " \u4E2A\u6587\u4EF6"));
42931
+ }
42932
+ }
42914
42933
  Array.isArray(spaceSnapshots)
42915
42934
  ? spaceSnapshots.length
42916
42935
  : 0;
42917
42936
  return [4 /*yield*/, this.compareSnapshots(safeEditorSnapshots, spaceSnapshots)];
42918
- case 2:
42919
- changes = _a.sent();
42937
+ case 8:
42938
+ snapshotChanges = _a.sent();
42939
+ localAddChanges = localChanges
42940
+ .filter(function (change) { return change.action === 'add'; })
42941
+ .map(function (change) { return ({
42942
+ action: 'add',
42943
+ path: change.path,
42944
+ side: 'space',
42945
+ sourceLabel: 'shadow-space',
42946
+ targetLabel: 'editor',
42947
+ // 本地新增文件,编辑器中不存在,所以 editorHash 为空
42948
+ editorHash: undefined,
42949
+ // spaceHash 可以从文件内容计算,但这里我们不需要,因为前端只需要知道是新增文件
42950
+ spaceHash: undefined,
42951
+ }); });
42952
+ console.log("\uD83D\uDD0D [DEBUG] \u672C\u5730\u65B0\u589E\u6587\u4EF6\u6570\u91CF: ".concat(localAddChanges.length));
42953
+ if (localAddChanges.length > 0) {
42954
+ console.log("\uD83D\uDD0D [DEBUG] \u672C\u5730\u65B0\u589E\u6587\u4EF6\u5217\u8868:", localAddChanges.map(function (c) { return c.path; }));
42955
+ }
42956
+ changes = __spreadArray(__spreadArray([], __read(snapshotChanges), false), __read(localAddChanges), false);
42920
42957
  summary = {
42921
42958
  total: changes.length,
42922
42959
  needPush: changes.filter(function (c) { return c.side === 'editor'; }).length,
42923
42960
  needPull: changes.filter(function (c) { return c.side === 'space'; }).length,
42924
42961
  };
42962
+ // 🔍 变更结果详细分析
42963
+ console.log('\n📋 变更检测结果:');
42964
+ console.log(" \uD83D\uDCCA \u603B\u53D8\u66F4\u6570: ".concat(summary.total));
42965
+ console.log(" \u2B06\uFE0F \u9700\u8981\u63A8\u9001: ".concat(summary.needPush, " \u4E2A\u6587\u4EF6"));
42966
+ console.log(" \u2B07\uFE0F \u9700\u8981\u62C9\u53D6: ".concat(summary.needPull, " \u4E2A\u6587\u4EF6"));
42967
+ if (changes.length > 0) {
42968
+ console.log('\n📝 变更详情:');
42969
+ changes.forEach(function (change, index) {
42970
+ var _a, _b, _c, _d;
42971
+ var actionIcon = change.action === 'add'
42972
+ ? '➕'
42973
+ : change.action === 'modify'
42974
+ ? '🔄'
42975
+ : change.action === 'delete'
42976
+ ? '🗑️'
42977
+ : '❓';
42978
+ var directionIcon = change.side === 'editor' ? '⬆️' : '⬇️';
42979
+ console.log(" [".concat(index + 1, "] ").concat(actionIcon, " ").concat(change.action.toUpperCase(), ": ").concat(change.path));
42980
+ console.log(" ".concat(directionIcon, " \u65B9\u5411: ").concat(change.side === 'editor' ? '编辑器→空间' : '空间→编辑器'));
42981
+ if (change.action === 'modify') {
42982
+ console.log(" \uD83D\uDD11 \u6BD4\u5BF9: ".concat((_a = change.editorHash) === null || _a === void 0 ? void 0 : _a.substring(0, 16), "... vs ").concat((_b = change.spaceHash) === null || _b === void 0 ? void 0 : _b.substring(0, 16), "..."));
42983
+ }
42984
+ else if (change.action === 'add') {
42985
+ console.log(" \uD83D\uDD11 hash: ".concat((_c = change.editorHash) === null || _c === void 0 ? void 0 : _c.substring(0, 16), "..."));
42986
+ }
42987
+ else if (change.action === 'delete') {
42988
+ console.log(" \uD83D\uDD11 hash: ".concat((_d = change.spaceHash) === null || _d === void 0 ? void 0 : _d.substring(0, 16), "..."));
42989
+ }
42990
+ });
42991
+ }
42992
+ console.log('=== 调试信息结束 ===\n');
42925
42993
  // console.log(
42926
42994
  // `[ShadowSpace] 变更检测完成: 总计${summary.total}个变更, 需推送${summary.needPush}个, 需拉取${summary.needPull}个`
42927
42995
  // );
@@ -42935,27 +43003,29 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42935
43003
  summary: summary,
42936
43004
  },
42937
43005
  }];
42938
- case 3:
42939
- error_3 = _a.sent();
42940
- console.error("[ShadowSpace] \u68C0\u6D4B\u53D8\u66F4\u5931\u8D25:", error_3);
43006
+ case 9:
43007
+ error_4 = _a.sent();
43008
+ console.error('[ShadowSpace] 检测变更失败:', error_4);
42941
43009
  return [2 /*return*/, {
42942
43010
  success: false,
42943
- error: error_3 instanceof Error ? error_3.message : '检测变更失败',
43011
+ error: error_4 instanceof Error ? error_4.message : '检测变更失败',
42944
43012
  }];
42945
- case 4: return [2 /*return*/];
43013
+ case 10: return [2 /*return*/];
42946
43014
  }
42947
43015
  });
42948
43016
  });
42949
43017
  };
42950
43018
  /**
42951
43019
  * 比对编辑器和空间快照
43020
+ * 现在 hash 算法已统一,可以直接比对 hash
43021
+ * 当 hash 不同时,通过时间戳判断谁是最新版本
42952
43022
  */
42953
43023
  ShadowSpaceCommandHandler.prototype.compareSnapshots = function (editorSnapshots, spaceSnapshots) {
42954
- var _a, _b, _c;
43024
+ var _a, _b;
42955
43025
  return __awaiter(this, void 0, void 0, function () {
42956
- var changes, safeEditorSnapshots, safeSpaceSnapshots, editorMap, spaceMap, editorMap_1, editorMap_1_1, _d, path, editorFile, spaceFile, spaceMap_1, spaceMap_1_1, _e, path, spaceFile, editorFile;
42957
- var e_2, _f, e_3, _g;
42958
- return __generator(this, function (_h) {
43026
+ var changes, safeEditorSnapshots, safeSpaceSnapshots, editorMap, spaceMap, editorMap_1, editorMap_1_1, _c, path, editorFile, spaceFile, editorModify, spaceModify, spaceMap_1, spaceMap_1_1, _d, path, spaceFile, editorFile;
43027
+ var e_2, _e, e_3, _f;
43028
+ return __generator(this, function (_g) {
42959
43029
  changes = [];
42960
43030
  safeEditorSnapshots = Array.isArray(editorSnapshots)
42961
43031
  ? editorSnapshots
@@ -42968,10 +43038,10 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42968
43038
  try {
42969
43039
  // 检测编辑器的变更(新增、修改)
42970
43040
  for (editorMap_1 = __values(editorMap), editorMap_1_1 = editorMap_1.next(); !editorMap_1_1.done; editorMap_1_1 = editorMap_1.next()) {
42971
- _d = __read(editorMap_1_1.value, 2), path = _d[0], editorFile = _d[1];
43041
+ _c = __read(editorMap_1_1.value, 2), path = _c[0], editorFile = _c[1];
42972
43042
  spaceFile = spaceMap.get(path);
42973
43043
  if (!spaceFile) {
42974
- // 编辑器新增的文件
43044
+ // 编辑器新增的文件 → 推送到空间
42975
43045
  changes.push({
42976
43046
  action: 'add',
42977
43047
  path: path,
@@ -42982,58 +43052,91 @@ var ShadowSpaceCommandHandler = /** @class */ (function () {
42982
43052
  spaceHash: null,
42983
43053
  });
42984
43054
  }
42985
- else if (editorFile.hash !== spaceFile.remoteHash) {
42986
- // 编辑器修改的文件(基于云端哈希比对)
42987
- console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u7F16\u8F91\u5668\u4FEE\u6539: ".concat(path), {
43055
+ else if (editorFile.hash !== spaceFile.hash) {
43056
+ editorModify = editorFile.modify || 0;
43057
+ spaceModify = spaceFile.modify || 0;
43058
+ console.log("[ShadowSpace] \u68C0\u6D4B\u5230\u6587\u4EF6\u5DEE\u5F02: ".concat(path), {
42988
43059
  editorHash: (_a = editorFile.hash) === null || _a === void 0 ? void 0 : _a.substring(0, 16),
42989
- spaceRemoteHash: (_b = spaceFile.remoteHash) === null || _b === void 0 ? void 0 : _b.substring(0, 16),
42990
- spaceLocalHash: (_c = spaceFile.hash) === null || _c === void 0 ? void 0 : _c.substring(0, 16),
42991
- editorHashFull: editorFile.hash,
42992
- spaceRemoteHashFull: spaceFile.remoteHash,
42993
- });
42994
- changes.push({
42995
- action: 'modify',
42996
- path: path,
42997
- side: 'editor',
42998
- sourceLabel: 'editor',
42999
- targetLabel: 'shadow-space',
43000
- editorHash: editorFile.hash,
43001
- spaceHash: spaceFile.remoteHash,
43060
+ spaceHash: (_b = spaceFile.hash) === null || _b === void 0 ? void 0 : _b.substring(0, 16),
43061
+ editorModify: new Date(editorModify).toISOString(),
43062
+ spaceModify: new Date(spaceModify).toISOString(),
43063
+ editorUpdateBy: editorFile.updateBy,
43064
+ spaceUpdateBy: spaceFile.updateBy,
43002
43065
  });
43066
+ // 🔥 关键逻辑:根据时间戳判断方向
43067
+ if (editorModify > spaceModify) {
43068
+ // 编辑器更新 → 推送到空间
43069
+ console.log("[ShadowSpace] \u2192 \u7F16\u8F91\u5668\u66F4\u65B0\uFF0C\u9700\u8981\u63A8\u9001: ".concat(path));
43070
+ changes.push({
43071
+ action: 'modify',
43072
+ path: path,
43073
+ side: 'editor',
43074
+ sourceLabel: 'editor',
43075
+ targetLabel: 'shadow-space',
43076
+ editorHash: editorFile.hash,
43077
+ spaceHash: spaceFile.hash,
43078
+ });
43079
+ }
43080
+ else if (spaceModify > editorModify) {
43081
+ // 空间更新 → 拉取到编辑器
43082
+ console.log("[ShadowSpace] \u2190 \u7A7A\u95F4\u66F4\u65B0\uFF0C\u9700\u8981\u62C9\u53D6: ".concat(path));
43083
+ changes.push({
43084
+ action: 'modify',
43085
+ path: path,
43086
+ side: 'space',
43087
+ sourceLabel: 'shadow-space',
43088
+ targetLabel: 'editor',
43089
+ editorHash: editorFile.hash,
43090
+ spaceHash: spaceFile.hash,
43091
+ });
43092
+ }
43093
+ else {
43094
+ // 时间戳相同但 hash 不同 → 可能是冲突,默认以编辑器为准
43095
+ console.warn("[ShadowSpace] \u26A0\uFE0F \u65F6\u95F4\u6233\u76F8\u540C\u4F46\u5185\u5BB9\u4E0D\u540C\uFF0C\u9ED8\u8BA4\u4EE5\u7F16\u8F91\u5668\u4E3A\u51C6: ".concat(path));
43096
+ changes.push({
43097
+ action: 'modify',
43098
+ path: path,
43099
+ side: 'editor',
43100
+ sourceLabel: 'editor',
43101
+ targetLabel: 'shadow-space',
43102
+ editorHash: editorFile.hash,
43103
+ spaceHash: spaceFile.hash,
43104
+ conflict: true, // 标记为潜在冲突
43105
+ });
43106
+ }
43003
43107
  }
43004
43108
  }
43005
43109
  }
43006
43110
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
43007
43111
  finally {
43008
43112
  try {
43009
- if (editorMap_1_1 && !editorMap_1_1.done && (_f = editorMap_1.return)) _f.call(editorMap_1);
43113
+ if (editorMap_1_1 && !editorMap_1_1.done && (_e = editorMap_1.return)) _e.call(editorMap_1);
43010
43114
  }
43011
43115
  finally { if (e_2) throw e_2.error; }
43012
43116
  }
43013
43117
  try {
43014
- // 检测空间的变更(删除、空间独有的修改)
43118
+ // 检测空间独有的文件(编辑器已删除或空间新增)
43015
43119
  for (spaceMap_1 = __values(spaceMap), spaceMap_1_1 = spaceMap_1.next(); !spaceMap_1_1.done; spaceMap_1_1 = spaceMap_1.next()) {
43016
- _e = __read(spaceMap_1_1.value, 2), path = _e[0], spaceFile = _e[1];
43120
+ _d = __read(spaceMap_1_1.value, 2), path = _d[0], spaceFile = _d[1];
43017
43121
  editorFile = editorMap.get(path);
43018
43122
  if (!editorFile) {
43019
- // 空间独有的文件(编辑器已删除)
43123
+ // 编辑器中没有但空间中有,说明编辑器删除了文件 → 从编辑器推送删除操作到空间
43020
43124
  changes.push({
43021
43125
  action: 'delete',
43022
43126
  path: path,
43023
- side: 'space',
43024
- sourceLabel: 'shadow-space',
43025
- targetLabel: 'editor',
43127
+ side: 'editor',
43128
+ sourceLabel: 'editor',
43129
+ targetLabel: 'shadow-space',
43026
43130
  editorHash: null,
43027
- spaceHash: spaceFile.remoteHash,
43131
+ spaceHash: spaceFile.hash,
43028
43132
  });
43029
43133
  }
43030
- // 注意:空间的本地修改不在这里处理,因为我们主要关注编辑器 vs 云端哈希的比对
43031
43134
  }
43032
43135
  }
43033
43136
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
43034
43137
  finally {
43035
43138
  try {
43036
- if (spaceMap_1_1 && !spaceMap_1_1.done && (_g = spaceMap_1.return)) _g.call(spaceMap_1);
43139
+ if (spaceMap_1_1 && !spaceMap_1_1.done && (_f = spaceMap_1.return)) _f.call(spaceMap_1);
43037
43140
  }
43038
43141
  finally { if (e_3) throw e_3.error; }
43039
43142
  }
@@ -43403,7 +43506,8 @@ function startConnecting(options) {
43403
43506
  else if ((_b = data === null || data === void 0 ? void 0 : data.message) === null || _b === void 0 ? void 0 : _b.action) {
43404
43507
  // 嵌套格式(前端发送的格式)
43405
43508
  action = data.message.action;
43406
- message = data.message;
43509
+ // 🆕 对于嵌套格式,需要提取内层的 message
43510
+ message = data.message.message;
43407
43511
  }
43408
43512
  else {
43409
43513
  extracted = data || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appthen/cli",
3
- "version": "1.2.6",
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"