@dao42/d42paas-front 0.5.50 → 0.5.55

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.
@@ -14724,6 +14724,9 @@ async function setReplaySource(val) {
14724
14724
  file: lodash$2.exports.omit(val.file, "value")
14725
14725
  }), val.timestamp + "." + v4$1().split("-")[0]);
14726
14726
  }
14727
+ async function getLocalFile(key) {
14728
+ return (await daopaasDB).get("files", key);
14729
+ }
14727
14730
  async function getLocalReplayFile(key) {
14728
14731
  return (await daopaasDB).get("replayFiles", key);
14729
14732
  }
@@ -14942,14 +14945,15 @@ const oTStore = create$3((set2) => ({
14942
14945
  },
14943
14946
  messageId: "",
14944
14947
  playgroundId: "",
14945
- result: ""
14948
+ result: "",
14949
+ dockerInfos: new Map([])
14946
14950
  },
14947
14951
  playgroundStatus: "EMPTY",
14948
14952
  dockerStatus: "STOP",
14949
14953
  queryObject: {},
14950
14954
  globalData: {
14951
14955
  isRecording: false,
14952
- syncCursor: true,
14956
+ syncCursor: false,
14953
14957
  useLsp: true
14954
14958
  },
14955
14959
  fileSaved: true,
@@ -28413,6 +28417,9 @@ const PlaygroundInit = (arg) => {
28413
28417
  avatar: avatarGenerator(lodash$2.exports.random(0, 6), userData.uuid)
28414
28418
  }), "coUsers");
28415
28419
  setUserInfo(originUser);
28420
+ if (oTStore.getState().playgroundStatus === "INACTIVE") {
28421
+ io == null ? void 0 : io.emit("active");
28422
+ }
28416
28423
  }
28417
28424
  const userInfoList = [originUser, ...userData.coUsers.filter((f2) => f2.uuid !== originUser.uuid).map((user) => {
28418
28425
  return __spreadProps(__spreadValues({}, user), {
@@ -28423,17 +28430,22 @@ const PlaygroundInit = (arg) => {
28423
28430
  setUserList(userInfoList);
28424
28431
  });
28425
28432
  io.on("playgroundInfo", (data) => {
28433
+ var _a2;
28426
28434
  const {
28427
28435
  playgroundInfo,
28428
28436
  crdt,
28429
28437
  dockerInfo: dockerInfo2
28430
28438
  } = JSON.parse(data);
28431
- setPlaygroundInfo(playgroundInfo);
28439
+ setCRDTInfo2(crdt);
28440
+ const otPlaygroundInfo = oTStore.getState().playgroundInfo;
28441
+ setPlaygroundInfo(__spreadProps(__spreadValues(__spreadValues({}, playgroundInfo), otPlaygroundInfo), {
28442
+ activeDockerId: dockerInfo2.dockerId
28443
+ }));
28444
+ (_a2 = otPlaygroundInfo == null ? void 0 : otPlaygroundInfo.dockerInfos) == null ? void 0 : _a2.set(dockerInfo2.dockerId, dockerInfo2);
28432
28445
  setDockerInfo(__spreadValues(__spreadValues({}, oTStore.getState().dockerInfo), dockerInfo2));
28433
28446
  dockerInfo2.fileTree && switchFileTree({
28434
28447
  data: dockerInfo2.fileTree
28435
28448
  });
28436
- setCRDTInfo2(crdt);
28437
28449
  });
28438
28450
  io.on("playgroundStatus", (data) => {
28439
28451
  setPlaygroundStatus(data);
@@ -28499,10 +28511,14 @@ const PlaygroundInit = (arg) => {
28499
28511
  }
28500
28512
  });
28501
28513
  io.on("serverAck", (d2) => {
28514
+ var _a2;
28502
28515
  const _d2 = JSON.parse(d2);
28503
28516
  setAsyncType("editor");
28504
28517
  setReplaySource(__spreadProps(__spreadValues({}, _d2), {
28505
- event: "editor"
28518
+ event: "editor",
28519
+ editor: __spreadProps(__spreadValues({}, _d2.editor), {
28520
+ revision: ((_a2 = _d2.editor) == null ? void 0 : _a2.revision) + 1
28521
+ })
28506
28522
  }));
28507
28523
  setServerAck();
28508
28524
  });
@@ -30582,11 +30598,11 @@ const replay = async (item) => {
30582
30598
  const filterReplayList = replayList.filter((replayItem) => replayItem.userInfo.uuid === item.userId);
30583
30599
  const filterReplaySource = filterReplayList.find((f2) => f2.timestamp === item.timestamp);
30584
30600
  if (filterReplaySource.file) {
30585
- const file = await getLocalReplayFile(filterReplaySource.file.path);
30586
- filterReplaySource.file.value = file;
30587
- if ((doc == null ? void 0 : doc.path) !== filterReplaySource.file.path) {
30601
+ const doc2 = await getLocalFile(filterReplaySource.file.path);
30602
+ filterReplaySource.file.value = doc2;
30603
+ if ((doc2 == null ? void 0 : doc2.path) !== filterReplaySource.file.path) {
30588
30604
  switchDoc == null ? void 0 : switchDoc({
30589
- value: file,
30605
+ value: doc2.value,
30590
30606
  path: filterReplaySource.file.path
30591
30607
  });
30592
30608
  }
@@ -42240,7 +42256,7 @@ const GuiComponent = () => {
42240
42256
  };
42241
42257
  useControls({
42242
42258
  lsp: {
42243
- value: true,
42259
+ value: oTStore.getState().globalData.useLsp,
42244
42260
  onChange: (v2) => {
42245
42261
  oTStore.getState().setGlobalData({
42246
42262
  useLsp: v2
@@ -42253,7 +42269,7 @@ const GuiComponent = () => {
42253
42269
  },
42254
42270
  syncCursor: {
42255
42271
  label: "\u5149\u6807\u540C\u6B65",
42256
- value: true,
42272
+ value: oTStore.getState().globalData.syncCursor,
42257
42273
  onChange: (v2) => {
42258
42274
  oTStore.getState().setGlobalData({
42259
42275
  syncCursor: v2
@@ -42434,7 +42450,10 @@ class DaoPaaS {
42434
42450
  };
42435
42451
  }
42436
42452
  replay(arg) {
42437
- replay(arg);
42453
+ replay({
42454
+ userId: arg.userInfo.uuid,
42455
+ timestamp: arg.timestamp
42456
+ });
42438
42457
  }
42439
42458
  setIgnoreReplayers(arg) {
42440
42459
  ignoreReplayerStore.getState().setIgnoreReplayer(arg);
@@ -44595,9 +44614,11 @@ AwaitingConfirm.prototype.applyClient = function(client2, operation) {
44595
44614
  return new AwaitingWithBuffer(this.outstanding, operation);
44596
44615
  };
44597
44616
  AwaitingConfirm.prototype.applyServer = function(client2, operation) {
44598
- const pair = operation.constructor.transform(this.outstanding, operation);
44599
- client2.applyOperation(pair[1]);
44600
- return new AwaitingConfirm(pair[0]);
44617
+ if (this.outstanding.baseLength === operation.baseLength) {
44618
+ const pair = operation.constructor.transform(this.outstanding, operation);
44619
+ client2.applyOperation(pair[1]);
44620
+ return new AwaitingConfirm(pair[0]);
44621
+ }
44601
44622
  };
44602
44623
  AwaitingConfirm.prototype.serverAck = function(client2) {
44603
44624
  return synchronized_;
@@ -187608,6 +187629,51 @@ function WorkerWrapper() {
187608
187629
  "type": "module"
187609
187630
  });
187610
187631
  }
187632
+ const EditorLayout = newStyled.div`
187633
+ width: 100%;
187634
+ .contentWidgets {
187635
+ visibility: hidden;
187636
+ }
187637
+ .monaco-label {
187638
+ font-size: 12px;
187639
+ border-radius: 2px;
187640
+ padding: 2px 10px;
187641
+ transform: scale(0.8);
187642
+ visibility: hidden;
187643
+ }
187644
+ .label-visible {
187645
+ visibility: visible !important;
187646
+ }
187647
+
187648
+ .stack-list {
187649
+ width: 100%;
187650
+ height: 40px;
187651
+ transform: translate(0, -1px);
187652
+ overflow-x: auto;
187653
+ flex-wrap: nowrap;
187654
+ li {
187655
+ /* width: 100px; */
187656
+ height: 100%;
187657
+ padding: 15px;
187658
+ color: #fff;
187659
+ font-size: 12px;
187660
+ flex: 0 0 auto;
187661
+ }
187662
+
187663
+ .active {
187664
+ background: #1e1e1e;
187665
+ box-shadow: 0px 1px 0px 0 #333;
187666
+ /* border-left: 1px solid rgb(42 96 231);
187667
+ border-right: 1px solid rgb(42 96 231); */
187668
+ /* background: red; */
187669
+ }
187670
+ }
187671
+ `;
187672
+ const ContentLayout = newStyled.div`
187673
+ flex: 1;
187674
+ ${(props2) => props2.userList.map((u2) => "." + u2.role + "{background:" + u2.color + ";width: 2px !important;}")}
187675
+ ${(props2) => props2.userList.map((u2) => "." + u2.role + "-selection{background:" + u2.color + "a6;color: #fff;width: 2px !important;}")}
187676
+ `;
187611
187677
  self.MonacoEnvironment = {
187612
187678
  getWorker(_2, label) {
187613
187679
  if (label === "json") {
@@ -187664,51 +187730,6 @@ const useValue = create$3((set2) => ({
187664
187730
  }))
187665
187731
  }));
187666
187732
  let editor;
187667
- const EditorLayout = newStyled.div`
187668
- width: 100%;
187669
- .contentWidgets {
187670
- visibility: hidden;
187671
- }
187672
- .monaco-label {
187673
- font-size: 12px;
187674
- border-radius: 2px;
187675
- padding: 2px 10px;
187676
- transform: scale(0.8);
187677
- visibility: hidden;
187678
- }
187679
- .label-visible {
187680
- visibility: visible !important;
187681
- }
187682
-
187683
- .stack-list {
187684
- width: 100%;
187685
- height: 40px;
187686
- transform: translate(0, -1px);
187687
- overflow-x: auto;
187688
- flex-wrap: nowrap;
187689
- li {
187690
- /* width: 100px; */
187691
- height: 100%;
187692
- padding: 15px;
187693
- color: #fff;
187694
- font-size: 12px;
187695
- flex: 0 0 auto;
187696
- }
187697
-
187698
- .active {
187699
- background: #1e1e1e;
187700
- box-shadow: 0px 1px 0px 0 #333;
187701
- /* border-left: 1px solid rgb(42 96 231);
187702
- border-right: 1px solid rgb(42 96 231); */
187703
- /* background: red; */
187704
- }
187705
- }
187706
- `;
187707
- const ContentLayout = newStyled.div`
187708
- flex: 1;
187709
- ${(props2) => props2.userList.map((u2) => "." + u2.role + "{background:" + u2.color + ";width: 2px !important;}")}
187710
- ${(props2) => props2.userList.map((u2) => "." + u2.role + "-selection{background:" + u2.color + "a6;color: #fff;width: 2px !important;}")}
187711
- `;
187712
187733
  const Editor = ({
187713
187734
  doc: doc2,
187714
187735
  containerStyle,
@@ -187725,26 +187746,9 @@ const Editor = ({
187725
187746
  const setValue2 = useValue((state) => state.setValue);
187726
187747
  useValue((state) => state.setDelta);
187727
187748
  const [FileTreeStack, setFileTreeStack] = react.exports.useState([]);
187728
- const throttled = lodash$2.exports.throttle((callback) => {
187749
+ const debounced = lodash$2.exports.debounce((callback) => {
187729
187750
  callback();
187730
187751
  }, 300);
187731
- const cursorTool = (evt) => {
187732
- var _a2, _b2, _c2, _d2;
187733
- const {
187734
- userInfo
187735
- } = userStore.getState();
187736
- const selection2 = [[evt.selection.startLineNumber, evt.selection.startColumn, evt.selection.endLineNumber, evt.selection.endColumn, evt.selection.selectionStartLineNumber, evt.selection.selectionStartColumn, evt.selection.positionColumn, evt.selection.positionLineNumber], ...evt.secondarySelections.map((s2) => [s2.startLineNumber, s2.startColumn, s2.endLineNumber, s2.endColumn, s2.selectionStartLineNumber, s2.selectionStartColumn, s2.positionColumn, s2.positionLineNumber])];
187737
- const crdt = {
187738
- timestamp: Date.now().toString(),
187739
- selection: selection2,
187740
- file: {
187741
- action: "Update",
187742
- path: (_b2 = (_a2 = oTStore.getState()) == null ? void 0 : _a2.doc) == null ? void 0 : _b2.path
187743
- },
187744
- userInfo: lodash$2.exports.pick(userInfo, "uuid", "role")
187745
- };
187746
- (_d2 = (_c2 = useOT.getState()) == null ? void 0 : _c2.socket) == null ? void 0 : _d2.emit("selection", JSON.stringify(crdt));
187747
- };
187748
187752
  const receiveOperation = (revision, operation, _path) => {
187749
187753
  client2.receiveOperation = operation;
187750
187754
  return {
@@ -187759,18 +187763,8 @@ const Editor = ({
187759
187763
  }
187760
187764
  });
187761
187765
  editor.onDidChangeCursorSelection((evt) => {
187762
- if (oTStore.getState().appStatus === "replay")
187763
- return;
187764
- if (evt.source === "api") {
187765
- throttled(() => {
187766
- cursorTool(evt);
187767
- });
187768
- }
187769
- if (evt.reason === 0 || evt.source === "model")
187770
- return;
187771
- throttled(() => {
187772
- cursorTool(evt);
187773
- });
187766
+ oTStore.getState();
187767
+ return;
187774
187768
  });
187775
187769
  editor.onDidChangeModelContent((evt) => {
187776
187770
  const {
@@ -187789,9 +187783,6 @@ const Editor = ({
187789
187783
  } = evt;
187790
187784
  if (!isFlush) {
187791
187785
  setPosition(editor.getPosition());
187792
- let keepString = 0;
187793
- let rangeLengthamount = 0;
187794
- let rangeOffsetthamount = 0;
187795
187786
  let preOffset = 0;
187796
187787
  const valuelength = editorValue.length - changes.reduce((change, nextChange, i2) => change - nextChange.rangeLength + nextChange.text.length, 0);
187797
187788
  const operation = new TextOperation();
@@ -187801,17 +187792,18 @@ const Editor = ({
187801
187792
  operation.retain(valuelength - change.rangeLength - change.rangeOffset);
187802
187793
  }
187803
187794
  preOffset = change.rangeOffset + change.rangeLength;
187804
- rangeLengthamount += change.rangeLength;
187805
- keepString += change.text.length;
187806
- rangeOffsetthamount += change.rangeOffset;
187807
187795
  });
187808
- setLocalFile((doc22 == null ? void 0 : doc22.path) ? doc22 == null ? void 0 : doc22.path : "singleFile", editor.getValue());
187809
187796
  client2.applyClient(operation);
187797
+ setLocalFile((doc22 == null ? void 0 : doc22.path) ? doc22 == null ? void 0 : doc22.path : "singleFile", {
187798
+ value: editor.getValue(),
187799
+ revision: client2.revision + 1
187800
+ });
187810
187801
  } else {
187811
187802
  setValue2(changes[0].text);
187812
187803
  }
187813
187804
  });
187814
187805
  editor.onDidScrollChange((evt) => {
187806
+ var _a2, _b2;
187815
187807
  if (!evt.scrollLeftChanged && !evt.scrollTopChanged)
187816
187808
  return;
187817
187809
  const {
@@ -187828,10 +187820,7 @@ const Editor = ({
187828
187820
  leftPercent
187829
187821
  }
187830
187822
  };
187831
- throttled(() => {
187832
- var _a2, _b2;
187833
- (_b2 = (_a2 = useOT.getState()) == null ? void 0 : _a2.socket) == null ? void 0 : _b2.emit("extraSync", JSON.stringify(crdt));
187834
- });
187823
+ (_b2 = (_a2 = useOT.getState()) == null ? void 0 : _a2.socket) == null ? void 0 : _b2.emit("extraSync", JSON.stringify(crdt));
187835
187824
  });
187836
187825
  editor.createContextKey("save", true);
187837
187826
  editor.addCommand(KeyMod.CtrlCmd | KeyCode.KeyS, () => {
@@ -187869,7 +187858,7 @@ const Editor = ({
187869
187858
  path: doc22 == null ? void 0 : doc22.path
187870
187859
  }
187871
187860
  };
187872
- throttled(() => {
187861
+ debounced(() => {
187873
187862
  var _a2, _b2;
187874
187863
  (_b2 = (_a2 = useOT.getState()) == null ? void 0 : _a2.socket) == null ? void 0 : _b2.emit("editFile", JSON.stringify(crdt));
187875
187864
  });
@@ -187900,7 +187889,10 @@ const Editor = ({
187900
187889
  revision: client2.revision,
187901
187890
  value: file.value
187902
187891
  });
187903
- oTStore.getState().appStatus !== "replay" && setLocalFile(doc22 == null ? void 0 : doc22.path, file.value);
187892
+ oTStore.getState().appStatus !== "replay" && setLocalFile(doc22 == null ? void 0 : doc22.path, {
187893
+ value: file.value,
187894
+ revision: client2.revision
187895
+ });
187904
187896
  }
187905
187897
  };
187906
187898
  const lspServerInject = (_lan, useLsp) => {
@@ -187909,6 +187901,11 @@ const Editor = ({
187909
187901
  extensions: [".rb"],
187910
187902
  aliases: ["ruby", "RUBY"]
187911
187903
  });
187904
+ languages.register({
187905
+ id: "python",
187906
+ extensions: [".py"],
187907
+ aliases: ["python", "PYTHON"]
187908
+ });
187912
187909
  languages.register({
187913
187910
  id: "java",
187914
187911
  extensions: [".java"],
@@ -187942,7 +187939,7 @@ const Editor = ({
187942
187939
  const languageClient = new lib.MonacoLanguageClient({
187943
187940
  name: "Language Client",
187944
187941
  clientOptions: {
187945
- documentSelector: ["java", "ruby"],
187942
+ documentSelector: ["java", "ruby", "python"],
187946
187943
  errorHandler: {
187947
187944
  error: () => lib.ErrorAction.Continue,
187948
187945
  closed: () => lib.CloseAction.DoNotRestart
@@ -188019,8 +188016,11 @@ const Editor = ({
188019
188016
  }
188020
188017
  return result;
188021
188018
  };
188019
+ window.ot = __spreadProps(__spreadValues({}, ot), {
188020
+ oTStore,
188021
+ editor
188022
+ });
188022
188023
  }
188023
- window.ot = ot;
188024
188024
  };
188025
188025
  react.exports.useEffect(() => {
188026
188026
  editorInit();
@@ -188158,6 +188158,14 @@ const Editor = ({
188158
188158
  if (!editor)
188159
188159
  return;
188160
188160
  }, [OTSTATE.fileSaved]);
188161
+ react.exports.useEffect(() => {
188162
+ if (!editor)
188163
+ return;
188164
+ if (IsMe(OTSTATE.CRDTInfo.userInfo)) {
188165
+ editor$1.getModels().forEach((model) => model.dispose());
188166
+ setFileTreeStack([]);
188167
+ }
188168
+ }, [OTSTATE.dockerInfo]);
188161
188169
  react.exports.useEffect(() => {
188162
188170
  if (!editor || !file)
188163
188171
  return;
@@ -195692,7 +195700,7 @@ const TerminalComponent = (_i) => {
195692
195700
  if (postUser && !IsMe(CRDTInfo.userInfo)) {
195693
195701
  const helperContainer = (_c2 = terminal == null ? void 0 : terminal._core) == null ? void 0 : _c2._helperContainer;
195694
195702
  const childNode = helperContainer == null ? void 0 : helperContainer.firstChild;
195695
- userLabel.innerText = postUser.name;
195703
+ userLabel.innerText = postUser.username;
195696
195704
  userLabel.style.backgroundColor = postUser.color;
195697
195705
  userLabel.style.top = childNode.style.top;
195698
195706
  userLabel.style.left = childNode.style.left;
@@ -196323,6 +196331,11 @@ const MultiPlayerCursor = () => {
196323
196331
  userInfo
196324
196332
  } = userStore.getState();
196325
196333
  window.addEventListener("mousemove", (evt) => {
196334
+ const {
196335
+ globalData
196336
+ } = oTStore.getState();
196337
+ if (!globalData.syncCursor)
196338
+ return;
196326
196339
  const crdt = {
196327
196340
  timestamp: Date.now().toString(),
196328
196341
  userInfo: lodash$2.exports.pick(userInfo, "uuid", "role"),