@pierre/diffs 1.4.0 → 1.4.1

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 (43) hide show
  1. package/dist/components/CodeView.d.ts +2 -0
  2. package/dist/components/CodeView.d.ts.map +1 -1
  3. package/dist/components/CodeView.js +36 -1
  4. package/dist/components/CodeView.js.map +1 -1
  5. package/dist/components/File.d.ts +7 -3
  6. package/dist/components/File.d.ts.map +1 -1
  7. package/dist/components/File.js +70 -53
  8. package/dist/components/File.js.map +1 -1
  9. package/dist/components/FileDiff.d.ts +7 -3
  10. package/dist/components/FileDiff.d.ts.map +1 -1
  11. package/dist/components/FileDiff.js +79 -49
  12. package/dist/components/FileDiff.js.map +1 -1
  13. package/dist/components/FileStream.js +1 -1
  14. package/dist/components/VirtualizedFile.d.ts +1 -0
  15. package/dist/components/VirtualizedFile.d.ts.map +1 -1
  16. package/dist/components/VirtualizedFile.js +8 -8
  17. package/dist/components/VirtualizedFile.js.map +1 -1
  18. package/dist/components/VirtualizedFileDiff.d.ts +1 -0
  19. package/dist/components/VirtualizedFileDiff.d.ts.map +1 -1
  20. package/dist/components/VirtualizedFileDiff.js +8 -8
  21. package/dist/components/VirtualizedFileDiff.js.map +1 -1
  22. package/dist/editor/editor.d.ts +1 -1
  23. package/dist/editor/editor.d.ts.map +1 -1
  24. package/dist/editor/editor.js +8 -4
  25. package/dist/editor/editor.js.map +1 -1
  26. package/dist/highlighter/shared_highlighter.d.ts +6 -2
  27. package/dist/highlighter/shared_highlighter.d.ts.map +1 -1
  28. package/dist/highlighter/shared_highlighter.js +7 -3
  29. package/dist/highlighter/shared_highlighter.js.map +1 -1
  30. package/dist/highlighter/themes/areThemesAttached.js +1 -1
  31. package/dist/index.js +13 -13
  32. package/dist/renderers/DiffHunksRenderer.d.ts +1 -1
  33. package/dist/renderers/DiffHunksRenderer.d.ts.map +1 -1
  34. package/dist/renderers/DiffHunksRenderer.js +8 -9
  35. package/dist/renderers/DiffHunksRenderer.js.map +1 -1
  36. package/dist/renderers/FileRenderer.d.ts +1 -1
  37. package/dist/renderers/FileRenderer.d.ts.map +1 -1
  38. package/dist/renderers/FileRenderer.js +5 -5
  39. package/dist/renderers/FileRenderer.js.map +1 -1
  40. package/dist/worker/WorkerPoolManager.d.ts.map +1 -1
  41. package/dist/worker/WorkerPoolManager.js +11 -2
  42. package/dist/worker/WorkerPoolManager.js.map +1 -1
  43. package/package.json +1 -1
@@ -108,9 +108,7 @@ declare class File<LAnnotation = undefined, Caret = undefined> {
108
108
  protected lineAnnotations: LineAnnotation<LAnnotation>[];
109
109
  protected managersDirty: boolean;
110
110
  file: FileContents | undefined;
111
- private editSessionFile;
112
- private editSessionAnnotations;
113
- private outgoingSessionFile;
111
+ private editSession;
114
112
  protected renderedFile: FileContents | undefined;
115
113
  protected renderRange: RenderRange | undefined;
116
114
  protected enabled: boolean;
@@ -119,6 +117,7 @@ declare class File<LAnnotation = undefined, Caret = undefined> {
119
117
  getAnnotationSlotName: (annotation: LineAnnotation<LAnnotation> | DiffLineAnnotation<LAnnotation>) => string;
120
118
  private handleHighlightRender;
121
119
  rerender(): void;
120
+ private getTheme;
122
121
  protected getLatestFile(file?: FileContents | undefined): FileContents | undefined;
123
122
  protected getRenderedFile(): FileContents | undefined;
124
123
  protected getLatestAnnotations(): LineAnnotation<LAnnotation>[];
@@ -153,6 +152,10 @@ declare class File<LAnnotation = undefined, Caret = undefined> {
153
152
  getOrCreateLineCache(file?: FileContents | undefined): string[];
154
153
  protected updateBuffers(renderRange: RenderRange): void;
155
154
  private syncRenderViewToEditor;
155
+ /** @internal The editor applied or edited past the pending external replacement. */
156
+ __acknowledgeDocumentUpdate(): void;
157
+ /** @internal Settle annotations */
158
+ __acceptEditorChange(event: EditorChangeEvent<'file', LAnnotation, Caret>): void;
156
159
  emitEditChange(event: EditorChangeEvent<'file', LAnnotation, Caret>): void;
157
160
  /** @internal Plain files have no component-owned diff session state. */
158
161
  __captureDocumentSessionState(): undefined;
@@ -191,6 +194,7 @@ declare class File<LAnnotation = undefined, Caret = undefined> {
191
194
  lineAnnotations,
192
195
  renderRange
193
196
  }: FileRenderProps<LAnnotation>): boolean;
197
+ protected finalizeRender(): void;
194
198
  private emitPostRender;
195
199
  private removeRenderedCode;
196
200
  private clearAuxiliaryNodes;
@@ -1 +1 @@
1
- {"version":3,"file":"File.d.ts","names":[],"sources":["../../src/components/File.ts"],"mappings":";;;;;;;;;;UAoFiB,eAAA;EACf,IAAA,EAAM,YAAA;EACN,aAAA,GAAgB,WAAA;EAChB,gBAAA,GAAmB,WAAA;EACnB,aAAA;EACA,WAAA;EACA,WAAA;EACA,eAAA,GAAkB,cAAA,CAAe,WAAA;EACjC,WAAA,GAAc,WAAA;AAAA;AAAA,UAGC,gBAAA,sBAAsC,IAAA,CACrD,eAAA,CAAgB,WAAA;EAGhB,aAAA,EAAe,WAAA;EACf,eAAA;AAAA;AAAA,KAGU,qBAAA,wBACV,KAAA,EAAO,iBAAA,SAA0B,WAAA,EAAa,KAAA;;;;;;;;;KAWpC,uBAAA,wBACV,KAAA,EAAO,qBAAA,CAAsB,WAAA,EAAa,KAAA,MACvC,sBAAA;AAAA,UAEY,WAAA,6BACP,eAAA,EAAiB,6BAAA;EACzB,iBAAA;EACA,kBAAA,GAAqB,kBAAA;EACrB,0BAAA,GAA6B,kBAAA;EAC7B,oBAAA,GAAuB,kBAAA;EACvB,kBAAA,GAAqB,kBAAA;EA9BN;;;;;EAoCf,oBAAA;EACA,gBAAA,EACE,UAAA,EAAY,cAAA,CAAe,WAAA,IAC1B,WAAA;EACH,mBAAA,EACE,aAAA,QAAqB,oBAAA,uBACpB,WAAA;EAEH,YAAA,EACE,IAAA,EAAM,WAAA,EACN,QAAA,EAAU,IAAA,CAAK,WAAA,EAAa,KAAA,GAC5B,KAAA,EAAO,eAAA;EA/CuB;;;;;;EAwDhC,YAAA,GAAe,qBAAA,CAAsB,WAAA,EAAa,KAAA;EAnDnC;AAAA;AAGjB;;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T_ID, HEADER_PREFIX_SLOT_ID } from "../constants.js";
2
+ import { getThemes } from "../utils/getThemes.js";
3
+ import { getHighlighterIfLoaded, getSharedHighlighter } from "../highlighter/shared_highlighter.js";
2
4
  import { areThemesEqual } from "../utils/areThemesEqual.js";
3
5
  import { isStyleNode } from "../utils/isStyleNode.js";
4
6
  import { areFileTargetsEqual } from "../utils/areFileTargetsEqual.js";
@@ -34,11 +36,6 @@ function createEditSessionFile(file) {
34
36
  delete editSessionFile.cacheKey;
35
37
  return editSessionFile;
36
38
  }
37
- function shouldResetUndoState(previousFile, nextFile) {
38
- const previousLanguage = previousFile.lang ?? getFiletypeFromFileName(previousFile.name);
39
- const nextLanguage = nextFile.lang ?? getFiletypeFromFileName(nextFile.name);
40
- return previousFile.name !== nextFile.name || previousLanguage !== nextLanguage;
41
- }
42
39
  let instanceId = -1;
43
40
  var File = class {
44
41
  options;
@@ -78,9 +75,7 @@ var File = class {
78
75
  lineAnnotations = [];
79
76
  managersDirty = false;
80
77
  file;
81
- editSessionFile;
82
- editSessionAnnotations;
83
- outgoingSessionFile;
78
+ editSession;
84
79
  renderedFile;
85
80
  renderRange;
86
81
  enabled = true;
@@ -95,7 +90,7 @@ var File = class {
95
90
  this.workerManager?.subscribeToThemeChanges(this);
96
91
  }
97
92
  getAnnotationSlotName = (annotation) => {
98
- return resolveEditSessionSlotName(this.editSessionAnnotations, annotation, getLineAnnotationName);
93
+ return resolveEditSessionSlotName(this.editSession?.annotations, annotation, getLineAnnotationName);
99
94
  };
100
95
  handleHighlightRender = () => {
101
96
  this.rerender();
@@ -108,40 +103,44 @@ var File = class {
108
103
  renderRange: this.renderRange
109
104
  });
110
105
  }
106
+ getTheme() {
107
+ return this.workerManager?.getFileRenderOptions().theme ?? this.options.theme ?? DEFAULT_THEMES;
108
+ }
111
109
  getLatestFile(file = this.file) {
112
- return this.editSessionFile ?? file;
110
+ return this.editSession?.file ?? file;
113
111
  }
114
112
  getRenderedFile() {
115
113
  return this.renderedFile;
116
114
  }
117
115
  getLatestAnnotations() {
118
- return this.editSessionAnnotations?.current ?? this.lineAnnotations;
116
+ return this.editSession?.annotations?.current ?? this.lineAnnotations;
119
117
  }
120
118
  isNewAnnotations(lineAnnotations) {
121
- const { editSessionAnnotations: session, lineAnnotations: externalAnnotations } = this;
122
- if (lineAnnotations === externalAnnotations) return false;
119
+ const session = this.editSession?.annotations;
120
+ if (lineAnnotations === this.lineAnnotations) return false;
123
121
  return session == null || lineAnnotations !== session.provided && lineAnnotations !== session.current;
124
122
  }
125
123
  updateExternalFile(incomingFile, lineAnnotations) {
126
124
  if (areFileTargetsEqual(this.file, incomingFile)) return false;
127
- const previousEditSessionFile = this.outgoingSessionFile ?? this.editSessionFile;
125
+ const hadSession = this.editSession != null;
128
126
  this.file = incomingFile;
129
- this.outgoingSessionFile = void 0;
130
- if (previousEditSessionFile != null || this.editor != null) {
131
- this.outgoingSessionFile = previousEditSessionFile;
132
- this.installEditSession(incomingFile, previousEditSessionFile == null ? this.editor?.__getDocumentContents(incomingFile) : void 0);
133
- } else this.editSessionFile = void 0;
134
- if (this.editSessionAnnotations != null && lineAnnotations != null) {
127
+ if (hadSession || this.editor != null) this.installEditSession(incomingFile, hadSession ? void 0 : this.editor?.__getDocumentContents(incomingFile), true);
128
+ else this.editSession = void 0;
129
+ if (this.editSession?.annotations != null && lineAnnotations != null) {
135
130
  this.lineAnnotations = lineAnnotations;
136
- this.editSessionAnnotations = adoptEditSessionAnnotations(lineAnnotations, getLineAnnotationName, this.editSessionAnnotations);
131
+ this.editSession.annotations = adoptEditSessionAnnotations(lineAnnotations, getLineAnnotationName, this.editSession.annotations);
137
132
  }
138
133
  return true;
139
134
  }
140
- installEditSession(externalFile, retainedDocument) {
135
+ installEditSession(externalFile, retainedDocument, hostReplacement = false) {
141
136
  const usesExternalDocument = retainedDocument == null || retainedDocument.name === externalFile.name && retainedDocument.lang === externalFile.lang && retainedDocument.contents === externalFile.contents;
142
- const editSessionFile = createEditSessionFile(retainedDocument ?? externalFile);
143
- this.editSessionFile = editSessionFile;
144
- this.fileRenderer.beginEditSession(editSessionFile, usesExternalDocument ? externalFile : void 0);
137
+ const file = createEditSessionFile(retainedDocument ?? externalFile);
138
+ this.editSession = {
139
+ file,
140
+ externalReplacement: hostReplacement && usesExternalDocument,
141
+ annotations: this.editSession?.annotations ?? adoptEditSessionAnnotations(this.lineAnnotations, getLineAnnotationName)
142
+ };
143
+ this.fileRenderer.beginEditSession(file, usesExternalDocument ? externalFile : void 0);
145
144
  }
146
145
  onThemeChange() {
147
146
  this.fileRenderer.clearRenderCache();
@@ -175,13 +174,13 @@ var File = class {
175
174
  return true;
176
175
  }
177
176
  hasThemeChanged() {
178
- return this.appliedThemeCSS != null && !areThemesEqual(this.appliedThemeCSS.theme, this.options.theme ?? DEFAULT_THEMES);
177
+ return this.appliedThemeCSS != null && !areThemesEqual(this.appliedThemeCSS.theme, this.getTheme());
179
178
  }
180
179
  getHoveredLine = () => {
181
180
  return this.interactionManager.getHoveredLine();
182
181
  };
183
182
  setLineAnnotations(lineAnnotations) {
184
- const { editSessionAnnotations: sessionAnnotations } = this;
183
+ const sessionAnnotations = this.editSession?.annotations;
185
184
  if (sessionAnnotations == null) {
186
185
  this.lineAnnotations = lineAnnotations;
187
186
  return;
@@ -191,7 +190,7 @@ var File = class {
191
190
  writeEditSessionAnnotations(sessionAnnotations, lineAnnotations, getLineAnnotationName);
192
191
  }
193
192
  syncEditSessionAnnotationsFromEditor(lineAnnotations) {
194
- const { editSessionAnnotations: session } = this;
193
+ const session = this.editSession?.annotations;
195
194
  if (session == null || lineAnnotations === session.current) return false;
196
195
  session.current = lineAnnotations;
197
196
  this.fileRenderer.setLineAnnotations(lineAnnotations);
@@ -280,9 +279,7 @@ var File = class {
280
279
  this.fileRenderer.cleanUp();
281
280
  this.workerManager = void 0;
282
281
  this.file = void 0;
283
- this.editSessionFile = void 0;
284
- this.editSessionAnnotations = void 0;
285
- this.outgoingSessionFile = void 0;
282
+ this.editSession = void 0;
286
283
  this.renderedFile = void 0;
287
284
  }
288
285
  this.enabled = false;
@@ -369,26 +366,40 @@ var File = class {
369
366
  const lineAnnotations = this.getLatestAnnotations();
370
367
  const file = this.getLatestFile();
371
368
  if (editor == null || fileContainer == null || file == null) return;
372
- this.fileRenderer.initializeHighlighter().then((highlighter) => {
369
+ const syncEditor = (highlighter) => {
373
370
  if (!this.enabled || this.editor !== editor || this.fileContainer !== fileContainer || this.getLatestFile() !== file) return;
374
- const { outgoingSessionFile: replacement, file: externalFile } = this;
375
- const externalDocument = replacement != null && externalFile != null && replacement !== file;
376
- const resetHistory = externalDocument ? shouldResetUndoState(replacement, externalFile) : false;
377
- if (externalDocument) this.outgoingSessionFile = void 0;
378
371
  editor.__syncRenderView({
379
372
  highlighter,
380
373
  fileContainer,
381
374
  file,
382
375
  lineAnnotations,
383
376
  renderRange,
384
- externalDocument,
385
- resetHistory
377
+ externalDocument: this.editSession?.externalReplacement === true
386
378
  });
379
+ };
380
+ const theme = this.getTheme();
381
+ const lang = file.lang ?? getFiletypeFromFileName(file.name);
382
+ const highlighter = getHighlighterIfLoaded({
383
+ theme,
384
+ lang
387
385
  });
388
- }
389
- emitEditChange(event) {
386
+ if (highlighter != null) syncEditor(highlighter);
387
+ else getSharedHighlighter({
388
+ themes: getThemes(theme),
389
+ langs: Array.from(/* @__PURE__ */ new Set(["text", lang])),
390
+ preferredHighlighter: this.workerManager?.getPreferredHighlighter() ?? this.options.preferredHighlighter
391
+ }).then(syncEditor);
392
+ }
393
+ /** @internal The editor applied or edited past the pending external replacement. */
394
+ __acknowledgeDocumentUpdate() {
395
+ if (this.editSession != null) this.editSession.externalReplacement = false;
396
+ }
397
+ /** @internal Settle annotations */
398
+ __acceptEditorChange(event) {
390
399
  const { lineAnnotations } = event;
391
400
  if (lineAnnotations != null) this.syncEditSessionAnnotationsFromEditor(lineAnnotations);
401
+ }
402
+ emitEditChange(event) {
392
403
  const { onEditChange } = this.options;
393
404
  onEditChange?.(event);
394
405
  }
@@ -416,11 +427,11 @@ var File = class {
416
427
  this.resumeEditorRendering(editor);
417
428
  }
418
429
  resumeEditorRendering(editor) {
419
- this.editSessionAnnotations ??= adoptEditSessionAnnotations(this.lineAnnotations, getLineAnnotationName);
420
- if (this.editSessionFile == null && this.file != null) this.installEditSession(this.file, editor.__getDocumentContents(this.file));
421
- else this.fileRenderer.beginEditSession(this.editSessionFile);
430
+ if (this.editSession != null) this.fileRenderer.beginEditSession(this.editSession.file);
431
+ else if (this.file != null) this.installEditSession(this.file, editor.__getDocumentContents(this.file));
432
+ const editSessionFile = this.editSession?.file;
422
433
  if (this.fileRenderer.editorRenderReady()) {
423
- if (this.fileRenderer.fileCache === this.editSessionFile) this.renderedFile = this.editSessionFile;
434
+ if (this.fileRenderer.fileCache === editSessionFile) this.renderedFile = editSessionFile;
424
435
  this.syncRenderViewToEditor();
425
436
  } else this.rerender();
426
437
  }
@@ -442,8 +453,9 @@ var File = class {
442
453
  this.settleEditSession(mode === "install", editor);
443
454
  }
444
455
  settleEditSession(installResult, editor) {
445
- const { editSessionFile, editSessionAnnotations, file: externalFile, lineAnnotations: externalAnnotations } = this;
446
- if (editSessionFile == null || externalFile == null) return;
456
+ const { editSession, file: externalFile, lineAnnotations: externalAnnotations } = this;
457
+ if (editSession == null || externalFile == null) return;
458
+ const { file: editSessionFile, annotations: editSessionAnnotations } = editSession;
447
459
  if (this.editor != null) throw new Error("File.__completeEditSession: detach the editor before completing the session");
448
460
  const sessionAnnotationsCurrent = editSessionAnnotations?.current;
449
461
  let acceptedFile;
@@ -473,9 +485,7 @@ var File = class {
473
485
  this.file = acceptedFile;
474
486
  if (sessionAnnotationsCurrent != null) this.lineAnnotations = sessionAnnotationsCurrent;
475
487
  }
476
- this.editSessionFile = void 0;
477
- this.editSessionAnnotations = void 0;
478
- this.outgoingSessionFile = void 0;
488
+ this.editSession = void 0;
479
489
  const { renderedFile, file: settledFile } = this;
480
490
  this.fileRenderer.endEditSession(settledFile);
481
491
  if (renderedFile != null && settledFile != null && renderedFile !== settledFile && areFileTargetsEqual(renderedFile, settledFile)) this.renderedFile = settledFile;
@@ -483,14 +493,14 @@ var File = class {
483
493
  if (failed) throw failure;
484
494
  }
485
495
  applyDocumentChange(textDocument, newLineAnnotations) {
486
- const { editSessionFile } = this;
496
+ const editSessionFile = this.editSession?.file;
487
497
  if (editSessionFile == null) throw new Error("File.applyDocumentChange: requires an active edit session");
488
498
  this.fileRenderer.beginEditSession(editSessionFile);
489
499
  this.fileRenderer.applyDocumentChange(textDocument);
490
500
  if (newLineAnnotations != null) this.syncEditSessionAnnotationsFromEditor(newLineAnnotations);
491
501
  }
492
502
  updateRenderCache(dirtyLines, themeType, options) {
493
- const { editSessionFile } = this;
503
+ const editSessionFile = this.editSession?.file;
494
504
  if (editSessionFile == null) throw new Error("File.updateRenderCache: requires an active edit session");
495
505
  this.fileRenderer.beginEditSession(editSessionFile);
496
506
  this.fileRenderer.updateRenderCache(dirtyLines, themeType, options?.lineCountChangeInFlight);
@@ -506,7 +516,11 @@ var File = class {
506
516
  const didFileChange = !areFileTargetsEqual(this.file, file);
507
517
  if (didFileChange) this.updateExternalFile(file, lineAnnotations);
508
518
  const latestFile = this.getLatestFile(file) ?? file;
509
- if (!collapsed && !forceRender && areRenderRangesEqual(nextRenderRange, this.renderRange) && !didFileChange && !annotationsChanged && !themeChanged) return this.applyCachedThemeState(themeType);
519
+ if (!collapsed && !forceRender && areRenderRangesEqual(nextRenderRange, this.renderRange) && !didFileChange && !annotationsChanged && !themeChanged) {
520
+ const rendered = this.applyCachedThemeState(themeType);
521
+ if (rendered) this.finalizeRender();
522
+ return rendered;
523
+ }
510
524
  this.renderRange = nextRenderRange;
511
525
  if (didFileChange) this.cachedHeaderHTML = void 0;
512
526
  this.fileRenderer.setOptions(getFileRendererOptions(this.options));
@@ -538,6 +552,7 @@ var File = class {
538
552
  console.error(error);
539
553
  if (error instanceof Error) this.applyErrorToDOM(error, fileContainer);
540
554
  }
555
+ this.finalizeRender();
541
556
  if (!preventEmit) this.emitPostRender();
542
557
  return true;
543
558
  }
@@ -560,6 +575,7 @@ var File = class {
560
575
  this.renderGutterUtility();
561
576
  this.managersDirty = true;
562
577
  if (!deferManagers) this.flushManagers();
578
+ this.finalizeRender();
563
579
  if (this.editor != null) this.syncRenderViewToEditor();
564
580
  } catch (error) {
565
581
  if (disableErrorHandling) throw error;
@@ -569,6 +585,7 @@ var File = class {
569
585
  if (!preventEmit) this.emitPostRender();
570
586
  return true;
571
587
  }
588
+ finalizeRender() {}
572
589
  emitPostRender(unmount = false) {
573
590
  const { fileContainer, options: { onPostRender } } = this;
574
591
  if (unmount) {
@@ -738,7 +755,7 @@ var File = class {
738
755
  applyThemeState(container, themeStyles, themeType, baseThemeType) {
739
756
  const shadowRoot = container.shadowRoot ?? container.attachShadow({ mode: "open" });
740
757
  const effectiveThemeType = baseThemeType ?? themeType;
741
- const currentTheme = this.options.theme ?? DEFAULT_THEMES;
758
+ const currentTheme = this.getTheme();
742
759
  const theme = typeof currentTheme === "string" ? currentTheme : { ...currentTheme };
743
760
  const scrollbarGutter = getMeasuredScrollbarGutter(shadowRoot);
744
761
  if (this.themeCSSStyle?.parentNode === shadowRoot && this.appliedThemeCSS?.themeStyles === themeStyles && this.appliedThemeCSS.themeType === effectiveThemeType && this.appliedThemeCSS.scrollbarGutter === scrollbarGutter) {