@lvce-editor/renderer-process 30.63.2 → 30.64.0

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.
@@ -12254,7 +12254,7 @@ const flushPendingData = state => {
12254
12254
  terminal
12255
12255
  } = state;
12256
12256
  for (const data of pendingData) {
12257
- terminal.write(data);
12257
+ if (data?.restore) restore(state, data.restore);else terminal.write(data);
12258
12258
  }
12259
12259
  pendingData.length = 0;
12260
12260
  };
@@ -12286,6 +12286,7 @@ const mountTerminal = async (state, uid) => {
12286
12286
  cols,
12287
12287
  rows
12288
12288
  }) => {
12289
+ if (state.restoring) return;
12289
12290
  resize(uid, {
12290
12291
  columns: cols,
12291
12292
  rows
@@ -12293,6 +12294,7 @@ const mountTerminal = async (state, uid) => {
12293
12294
  });
12294
12295
  terminal.open(state.$Viewlet);
12295
12296
  const resizeObserver = new ResizeObserver(() => {
12297
+ if (state.restoring) return;
12296
12298
  fitAddon.fit();
12297
12299
  focusIfConnected(state);
12298
12300
  });
@@ -12318,6 +12320,7 @@ const create = () => {
12318
12320
  pendingData: [],
12319
12321
  pendingFocus: false,
12320
12322
  resizeObserver: undefined,
12323
+ restoring: false,
12321
12324
  terminal: undefined
12322
12325
  };
12323
12326
  };
@@ -12342,6 +12345,35 @@ const write = (state, data) => {
12342
12345
  }
12343
12346
  terminal.write(data);
12344
12347
  };
12348
+ const restore = (state, snapshot) => {
12349
+ if (state.disposed) return;
12350
+ const {
12351
+ columns,
12352
+ data,
12353
+ rows
12354
+ } = snapshot;
12355
+ if (!Number.isSafeInteger(columns) || !Number.isSafeInteger(rows) || columns < 2 || columns > 500 || rows < 1 || rows > 200 || typeof data !== 'string') {
12356
+ throw new Error('Invalid terminal snapshot');
12357
+ }
12358
+ const {
12359
+ terminal
12360
+ } = state;
12361
+ if (!terminal) {
12362
+ state.pendingData.push({
12363
+ restore: snapshot
12364
+ });
12365
+ return;
12366
+ }
12367
+ state.restoring = true;
12368
+ terminal.reset();
12369
+ terminal.resize(columns, rows);
12370
+ terminal.write(data, () => {
12371
+ if (state.disposed) return;
12372
+ state.restoring = false;
12373
+ state.fitAddon.fit();
12374
+ focusIfConnected(state);
12375
+ });
12376
+ };
12345
12377
  const focus = state => {
12346
12378
  object(state);
12347
12379
  const {
@@ -12391,6 +12423,7 @@ const ViewletTerminal2 = {
12391
12423
  dispose,
12392
12424
  focus,
12393
12425
  handleMouseDown,
12426
+ restore,
12394
12427
  setTerminal,
12395
12428
  write
12396
12429
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/renderer-process",
3
- "version": "30.63.2",
3
+ "version": "30.64.0",
4
4
  "keywords": [
5
5
  "lvce-editor",
6
6
  "renderer-process"