@lapis-notes/api 0.1.3 → 0.2.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.
Files changed (199) hide show
  1. package/CHANGELOG.md +304 -13
  2. package/README.md +19 -0
  3. package/dist/__tests__/fixtures/indexed-mutations.json +6862 -0
  4. package/dist/__tests__/fixtures/memory-storage.json +309 -0
  5. package/dist/__tests__/fixtures/native-facade-contract.json +3224 -0
  6. package/dist/__tests__/fixtures/projection-query.json +195 -0
  7. package/dist/__tests__/fixtures/projection-values.json +60 -0
  8. package/dist/__tests__/fixtures/search-preparation.json +1513 -0
  9. package/dist/__tests__/fixtures/search-retrieval.json +15409 -0
  10. package/dist/__tests__/fixtures/search-semantic-model.json +3691 -0
  11. package/dist/__tests__/fixtures/search-semantic-retrieval.json +6603 -0
  12. package/dist/__tests__/fixtures/search-storage.json +409 -0
  13. package/dist/__tests__/fixtures/task-projection.json +428 -0
  14. package/dist/__tests__/indexed-mutation-support.js +262 -0
  15. package/dist/__tests__/projection-query-support.js +40 -0
  16. package/dist/__tests__/search-retrieval-support.js +47 -0
  17. package/dist/app-database-host.d.ts +1 -0
  18. package/dist/app-shell-plugin-persistence.d.ts +3 -2
  19. package/dist/app-shell-plugin-persistence.js +37 -3
  20. package/dist/cache.svelte.d.ts +8 -1
  21. package/dist/cache.svelte.js +103 -5
  22. package/dist/command.svelte.js +29 -2
  23. package/dist/components/editor/editor.css +4 -0
  24. package/dist/components/editor/editor.svelte +24 -11
  25. package/dist/components/editor/embedded-editor-surface.js +3 -1
  26. package/dist/components/editor/inline-title-alignment.d.ts +3 -0
  27. package/dist/components/editor/inline-title-alignment.js +57 -0
  28. package/dist/configuration.svelte.d.ts +270 -206
  29. package/dist/configuration.svelte.js +161 -86
  30. package/dist/context.svelte.d.ts +23 -3
  31. package/dist/context.svelte.js +68 -30
  32. package/dist/diagnostics.d.ts +8 -0
  33. package/dist/diagnostics.js +6 -0
  34. package/dist/editor-save-context.d.ts +35 -0
  35. package/dist/editor-save-context.js +132 -0
  36. package/dist/editor-view-registry.d.ts +10 -0
  37. package/dist/editor-view-registry.js +44 -4
  38. package/dist/editor.svelte.d.ts +19 -1
  39. package/dist/editor.svelte.js +528 -55
  40. package/dist/embed-registry.d.ts +10 -0
  41. package/dist/embed-registry.js +15 -0
  42. package/dist/file-editing-failures.d.ts +2 -0
  43. package/dist/file-editing-failures.js +29 -0
  44. package/dist/file-editing-native-issues.d.ts +19 -0
  45. package/dist/file-editing-native-issues.js +65 -0
  46. package/dist/file-editing-sessions.d.ts +76 -0
  47. package/dist/file-editing-sessions.js +367 -0
  48. package/dist/file-manager.d.ts +9 -1
  49. package/dist/file-manager.js +45 -3
  50. package/dist/file-state-store.d.ts +5 -0
  51. package/dist/file-state-store.js +34 -0
  52. package/dist/file-text-conflicts.d.ts +25 -0
  53. package/dist/file-text-conflicts.js +35 -0
  54. package/dist/file-text-mutation.d.ts +13 -0
  55. package/dist/file-text-mutation.js +100 -0
  56. package/dist/file-text-persistence.d.ts +36 -0
  57. package/dist/file-text-persistence.js +234 -0
  58. package/dist/file-text-state-writer.d.ts +34 -0
  59. package/dist/file-text-state-writer.js +183 -0
  60. package/dist/files-configuration.d.ts +20 -0
  61. package/dist/files-configuration.js +47 -0
  62. package/dist/generated/plugin-host-modules.schema.generated.d.ts +114 -34
  63. package/dist/generated/plugin-host-modules.schema.generated.js +132 -34
  64. package/dist/glob.d.ts +3 -0
  65. package/dist/glob.js +2 -1
  66. package/dist/icons/changes.d.ts +3 -0
  67. package/dist/icons/changes.js +16 -0
  68. package/dist/icons/index.d.ts +5 -1
  69. package/dist/icons/index.js +44 -3
  70. package/dist/icons/registry.d.ts +35 -0
  71. package/dist/icons/registry.js +154 -0
  72. package/dist/icons/safe-svg.d.ts +2 -0
  73. package/dist/icons/safe-svg.js +44 -0
  74. package/dist/index.d.ts +6 -1
  75. package/dist/index.js +4 -1
  76. package/dist/lapis-extension.d.ts +6 -2
  77. package/dist/lapis-extension.js +2 -0
  78. package/dist/metadata-store.d.ts +23 -0
  79. package/dist/metadata-store.js +1 -0
  80. package/dist/metadata.svelte.js +45 -2
  81. package/dist/native-background-indexing.d.ts +48 -0
  82. package/dist/native-background-indexing.js +208 -0
  83. package/dist/native-database-protocol.d.ts +29 -0
  84. package/dist/native-database-protocol.js +1 -0
  85. package/dist/native-editing-intent-lease.d.ts +17 -0
  86. package/dist/native-editing-intent-lease.js +188 -0
  87. package/dist/native-editing-intents-protocol.d.ts +70 -0
  88. package/dist/native-editing-intents-protocol.js +1 -0
  89. package/dist/native-editing-intents.d.ts +8 -0
  90. package/dist/native-editing-intents.js +1 -0
  91. package/dist/native-editing-problems.d.ts +3 -0
  92. package/dist/native-editing-problems.js +180 -0
  93. package/dist/native-editing-recovery.d.ts +24 -0
  94. package/dist/native-editing-recovery.js +198 -0
  95. package/dist/native-editing-session.d.ts +51 -0
  96. package/dist/native-editing-session.js +251 -0
  97. package/dist/native-history-index-protocol.d.ts +80 -0
  98. package/dist/native-history-index-protocol.js +1 -0
  99. package/dist/native-history-index.d.ts +6 -0
  100. package/dist/native-history-index.js +1 -0
  101. package/dist/native-indexing-protocol.d.ts +63 -0
  102. package/dist/native-indexing-protocol.js +1 -0
  103. package/dist/native-participant-protocol.d.ts +67 -0
  104. package/dist/native-participant-protocol.js +3 -0
  105. package/dist/native-queue-protocol.d.ts +73 -0
  106. package/dist/native-queue-protocol.js +3 -0
  107. package/dist/native-tasks-protocol.d.ts +264 -0
  108. package/dist/native-tasks-protocol.js +1 -0
  109. package/dist/native-tasks.d.ts +35 -0
  110. package/dist/native-tasks.js +79 -0
  111. package/dist/native-turn-protocol.d.ts +81 -0
  112. package/dist/native-turn-protocol.js +1 -0
  113. package/dist/native-turns.d.ts +29 -0
  114. package/dist/native-turns.js +2 -0
  115. package/dist/plugin-asset-server.js +3 -2
  116. package/dist/plugin-dependency-resolver.d.ts +1 -1
  117. package/dist/plugin-distribution/compatibility.d.ts +1 -1
  118. package/dist/plugin-distribution/compatibility.js +10 -5
  119. package/dist/plugin-distribution/installed-plugin-state.js +2 -1
  120. package/dist/plugin-distribution/installer.d.ts +6 -0
  121. package/dist/plugin-distribution/installer.js +90 -37
  122. package/dist/plugin-distribution/manager.d.ts +4 -1
  123. package/dist/plugin-distribution/manager.js +12 -5
  124. package/dist/plugin-distribution/registry-cache.js +2 -1
  125. package/dist/plugin-distribution/registry-source-state.js +2 -1
  126. package/dist/plugin-distribution/schemas.d.ts +26 -8
  127. package/dist/plugin-distribution/schemas.js +2 -1
  128. package/dist/plugin-distribution/types.d.ts +4 -0
  129. package/dist/plugin-manager.d.ts +21 -5
  130. package/dist/plugin-manager.js +228 -64
  131. package/dist/plugin-runtime-entry.d.ts +1 -1
  132. package/dist/plugin-runtime-entry.js +16 -0
  133. package/dist/plugin.d.ts +19 -3
  134. package/dist/plugin.js +110 -44
  135. package/dist/registry-schema/catalog-v1.d.ts +60 -9
  136. package/dist/registry-schema/catalog-v1.js +2 -1
  137. package/dist/registry-schema/catalog-v2.d.ts +60 -9
  138. package/dist/registry-schema/catalog-v2.js +1 -1
  139. package/dist/search-result-provider.d.ts +95 -0
  140. package/dist/search-result-provider.js +42 -0
  141. package/dist/status-bar.svelte.d.ts +26 -20
  142. package/dist/status-bar.svelte.js +1 -0
  143. package/dist/storage/app-database.d.ts +9 -23
  144. package/dist/storage/app-database.js +41 -34
  145. package/dist/storage/desktop-native.d.ts +5 -3
  146. package/dist/storage/desktop-native.js +59 -6
  147. package/dist/storage/directory-watcher.d.ts +27 -0
  148. package/dist/storage/directory-watcher.js +201 -0
  149. package/dist/storage/fs.d.ts +14 -27
  150. package/dist/storage/fs.js +2 -168
  151. package/dist/storage/index-projection.js +33 -15
  152. package/dist/storage/memory-vault-adapter.d.ts +2 -0
  153. package/dist/storage/memory-vault-adapter.js +14 -1
  154. package/dist/storage/path.d.ts +6 -2
  155. package/dist/storage/path.js +8 -2
  156. package/dist/storage/projection-query-candidates.d.ts +3 -0
  157. package/dist/storage/projection-query-candidates.js +69 -0
  158. package/dist/storage/remote-app-database.d.ts +2 -2
  159. package/dist/storage/remote-app-database.js +1 -1
  160. package/dist/storage/runtime.d.ts +3 -0
  161. package/dist/storage/runtime.js +3 -0
  162. package/dist/storage/search-embedding-record.d.ts +3 -0
  163. package/dist/storage/search-embedding-record.js +18 -0
  164. package/dist/storage/turso-app-database.d.ts +2 -0
  165. package/dist/storage/turso-app-database.js +67 -30
  166. package/dist/storage/vault-listing.d.ts +3 -0
  167. package/dist/storage/vault-listing.js +36 -0
  168. package/dist/storage/vault-reconciliation.d.ts +19 -0
  169. package/dist/storage/vault-reconciliation.js +137 -0
  170. package/dist/storage/vault-session.d.ts +8 -0
  171. package/dist/storage/vault-session.js +10 -2
  172. package/dist/storage/vault.svelte.d.ts +53 -4
  173. package/dist/storage/vault.svelte.js +223 -87
  174. package/dist/sync-editor-flush.d.ts +6 -0
  175. package/dist/sync-editor-flush.js +22 -0
  176. package/dist/sync-host-local.d.ts +15 -0
  177. package/dist/sync-host-local.js +228 -0
  178. package/dist/sync-host-security.d.ts +24 -9
  179. package/dist/sync-host-security.js +47 -14
  180. package/dist/sync-host.d.ts +33 -4
  181. package/dist/sync-host.js +160 -10
  182. package/dist/sync-repository.d.ts +106 -0
  183. package/dist/sync-repository.js +18 -0
  184. package/dist/vault-change-views.d.ts +4 -0
  185. package/dist/vault-change-views.js +43 -0
  186. package/dist/vault-changes.d.ts +37 -0
  187. package/dist/vault-changes.js +228 -0
  188. package/dist/view.svelte.d.ts +182 -149
  189. package/dist/view.svelte.js +39 -21
  190. package/dist/workspace-close-guard.d.ts +3 -0
  191. package/dist/workspace-close-guard.js +35 -0
  192. package/dist/workspace-host-internal.js +10 -2
  193. package/dist/workspace-layout-normalizer.d.ts +4 -2
  194. package/dist/workspace-layout-normalizer.js +5 -5
  195. package/dist/workspace-view-document.d.ts +3 -0
  196. package/dist/workspace-view-document.js +12 -0
  197. package/dist/workspace.svelte.d.ts +13 -2
  198. package/dist/workspace.svelte.js +371 -82
  199. package/package.json +61 -8
@@ -58,9 +58,15 @@ export function bindRuntimePluginDiagnostics(plugins, diagnostics) {
58
58
  return;
59
59
  publish();
60
60
  });
61
+ const unloadedRef = plugins.on("plugin-unloaded", (id) => {
62
+ if (!pluginFailures.delete(id))
63
+ return;
64
+ publish();
65
+ });
61
66
  return () => {
62
67
  plugins.offref(errorRef);
63
68
  plugins.offref(enabledRef);
69
+ plugins.offref(unloadedRef);
64
70
  };
65
71
  }
66
72
  export function diagnosticResourceForPath(path) {
@@ -0,0 +1,35 @@
1
+ export interface EditorSaveSnapshot {
2
+ content: string;
3
+ sequence: number;
4
+ documentGeneration: number;
5
+ }
6
+ /**
7
+ * One document's queued saves and failures; the editor supplies shared
8
+ * serialization.
9
+ */
10
+ export declare class EditorSaveContext {
11
+ #private;
12
+ private readonly options;
13
+ constructor(options: {
14
+ serialize(run: () => Promise<void>): Promise<void>;
15
+ persist(snapshot: EditorSaveSnapshot): Promise<void>;
16
+ saved(snapshot: EditorSaveSnapshot): void;
17
+ unownedExternal: boolean;
18
+ released(): void;
19
+ });
20
+ get dirty(): boolean;
21
+ get latest(): EditorSaveSnapshot | undefined;
22
+ /** A protected explicit recovery may acknowledge the latest retained snapshot. */
23
+ accept(snapshot: EditorSaveSnapshot): void;
24
+ /**
25
+ * Discard only after the recovery owner has revalidated the external
26
+ * snapshot.
27
+ */
28
+ discard(): void;
29
+ queue(snapshot: EditorSaveSnapshot, explicit?: boolean): Promise<void> | undefined;
30
+ flushSave(): Promise<void> | undefined;
31
+ cancelSave(): void;
32
+ cancelChange(): void;
33
+ flush(retryFailed?: boolean): Promise<void>;
34
+ retire(): void;
35
+ }
@@ -0,0 +1,132 @@
1
+ import debounce from "lodash-es/debounce";
2
+ /**
3
+ * One document's queued saves and failures; the editor supplies shared
4
+ * serialization.
5
+ */
6
+ export class EditorSaveContext {
7
+ options;
8
+ #latest;
9
+ #completed = 0;
10
+ #failure;
11
+ #waitingChange;
12
+ #waitingSave;
13
+ #pending = new Set();
14
+ #retired = false;
15
+ #unverified = false;
16
+ #change = debounce((snapshot) => {
17
+ this.#waitingChange = undefined;
18
+ return this.#enqueue(snapshot);
19
+ }, 500);
20
+ #save = debounce((snapshot) => {
21
+ this.#waitingSave = undefined;
22
+ return this.#enqueue(snapshot);
23
+ }, 500);
24
+ constructor(options) {
25
+ this.options = options;
26
+ }
27
+ get dirty() {
28
+ return (!!this.#waitingChange ||
29
+ !!this.#waitingSave ||
30
+ this.#pending.size > 0 ||
31
+ !!this.#failure ||
32
+ this.#unverified);
33
+ }
34
+ get latest() {
35
+ return this.#latest;
36
+ }
37
+ /** A protected explicit recovery may acknowledge the latest retained snapshot. */
38
+ accept(snapshot) {
39
+ this.#reset();
40
+ this.#completed = Math.max(this.#completed, snapshot.sequence);
41
+ this.options.saved(snapshot);
42
+ this.#releaseIfClean();
43
+ }
44
+ /**
45
+ * Discard only after the recovery owner has revalidated the external
46
+ * snapshot.
47
+ */
48
+ discard() {
49
+ this.#reset();
50
+ this.#completed = Math.max(this.#completed, this.#latest?.sequence ?? 0);
51
+ this.#latest = undefined;
52
+ this.#releaseIfClean();
53
+ }
54
+ #reset() {
55
+ if (this.#pending.size)
56
+ throw new Error("Editor recovery requires settled saves");
57
+ this.cancelChange();
58
+ this.cancelSave();
59
+ this.#failure = undefined;
60
+ this.#unverified = false;
61
+ }
62
+ queue(snapshot, explicit = false) {
63
+ this.#latest = snapshot;
64
+ if (this.options.unownedExternal)
65
+ this.#unverified = true;
66
+ if (explicit) {
67
+ this.#waitingSave = snapshot;
68
+ return this.#save(snapshot);
69
+ }
70
+ this.#waitingChange = snapshot;
71
+ return this.#change(snapshot);
72
+ }
73
+ flushSave() {
74
+ return this.#save.flush();
75
+ }
76
+ cancelSave() {
77
+ this.#save.cancel();
78
+ this.#waitingSave = undefined;
79
+ }
80
+ cancelChange() {
81
+ this.#change.cancel();
82
+ this.#waitingChange = undefined;
83
+ }
84
+ #flushPending() {
85
+ this.#change.flush();
86
+ this.#save.flush();
87
+ }
88
+ #enqueue(snapshot) {
89
+ const flight = this.options.serialize(async () => {
90
+ if (snapshot.sequence <= this.#completed)
91
+ return;
92
+ await this.options.persist(snapshot);
93
+ this.options.saved(snapshot);
94
+ this.#completed = snapshot.sequence;
95
+ if (this.#failure && this.#failure.snapshot.sequence <= snapshot.sequence)
96
+ this.#failure = undefined;
97
+ });
98
+ this.#pending.add(flight);
99
+ // Observe failures even when a debounce caller does not await its result.
100
+ void flight.then(() => {
101
+ this.#pending.delete(flight);
102
+ this.#releaseIfClean();
103
+ }, (error) => {
104
+ this.#failure = { snapshot, error };
105
+ this.#pending.delete(flight);
106
+ });
107
+ return flight;
108
+ }
109
+ async flush(retryFailed = true) {
110
+ const retry = this.#failure;
111
+ this.#flushPending();
112
+ if (retryFailed && retry && this.#latest === retry.snapshot)
113
+ this.#enqueue(retry.snapshot);
114
+ do {
115
+ await Promise.allSettled([...this.#pending]);
116
+ this.#flushPending();
117
+ } while (this.#pending.size > 0);
118
+ if (this.#failure)
119
+ throw this.#failure.error;
120
+ this.#releaseIfClean();
121
+ }
122
+ retire() {
123
+ this.#retired = true;
124
+ // Retiring a context never replaces another context's debounce payload.
125
+ this.#flushPending();
126
+ this.#releaseIfClean();
127
+ }
128
+ #releaseIfClean() {
129
+ if (this.#retired && !this.dirty)
130
+ this.options.released();
131
+ }
132
+ }
@@ -1,10 +1,15 @@
1
1
  import { EventDispatcher } from "./events";
2
+ export type ExtensionRegistrationOptions = {
3
+ fileIcon?: string;
4
+ };
2
5
  export type EditorViewPriority = "default" | "option" | "exclusive";
3
6
  export type EditorViewContribution = {
4
7
  id: string;
5
8
  viewType?: string;
6
9
  label: string;
7
10
  description?: string;
11
+ /** Registered API icon ID used for matching file rows. */
12
+ fileIcon?: string;
8
13
  filenamePatterns?: string[];
9
14
  priority?: EditorViewPriority;
10
15
  pluginId?: string;
@@ -23,8 +28,13 @@ export type EditorViewRegistryChange = {
23
28
  export declare class EditorViewRegistry extends EventDispatcher<{
24
29
  changed: [change: EditorViewRegistryChange];
25
30
  }> {
31
+ private readonly layers;
26
32
  private readonly views;
27
33
  register(contribution: EditorViewContribution): () => void;
34
+ /** Overlay runtime metadata on the same plugin's admitted manifest entry. */
35
+ overlay(contribution: EditorViewContribution): () => void;
36
+ private removeLayer;
37
+ private setVisible;
28
38
  upsert(contribution: EditorViewContribution): () => void;
29
39
  update(id: string, contribution: Partial<EditorViewContribution>): boolean;
30
40
  removeFilenamePatterns(id: string, patterns: readonly string[]): boolean;
@@ -19,6 +19,7 @@ function normalizeContribution(contribution) {
19
19
  id,
20
20
  viewType: normalizeString(contribution.viewType ?? id),
21
21
  label,
22
+ fileIcon: contribution.fileIcon?.trim() || undefined,
22
23
  filenamePatterns: uniqueStrings(contribution.filenamePatterns),
23
24
  priority: contribution.priority ?? "option",
24
25
  };
@@ -35,6 +36,7 @@ function mergeContribution(current, next) {
35
36
  };
36
37
  }
37
38
  export class EditorViewRegistry extends EventDispatcher {
39
+ layers = new Map();
38
40
  views = new Map();
39
41
  register(contribution) {
40
42
  const normalized = normalizeContribution(contribution);
@@ -42,12 +44,48 @@ export class EditorViewRegistry extends EventDispatcher {
42
44
  console.warn(`Editor view ${normalized.id} is already registered.`);
43
45
  return () => { };
44
46
  }
47
+ const owner = {};
48
+ this.layers.set(normalized.id, [{ owner, contribution: normalized }]);
45
49
  this.views.set(normalized.id, normalized);
46
50
  this.emit("changed", { id: normalized.id, action: "registered" });
47
51
  return () => {
48
- this.unregister(normalized.id);
52
+ this.removeLayer(normalized.id, owner);
49
53
  };
50
54
  }
55
+ /** Overlay runtime metadata on the same plugin's admitted manifest entry. */
56
+ overlay(contribution) {
57
+ const current = this.views.get(contribution.id);
58
+ if (!current)
59
+ return this.register(contribution);
60
+ const normalized = mergeContribution(current, contribution);
61
+ const owner = {};
62
+ this.layers.get(normalized.id).push({ owner, contribution: normalized });
63
+ this.views.set(normalized.id, normalized);
64
+ this.emit("changed", { id: normalized.id, action: "updated" });
65
+ return () => this.removeLayer(normalized.id, owner);
66
+ }
67
+ removeLayer(id, owner) {
68
+ const entries = this.layers.get(id);
69
+ const index = entries?.findIndex((entry) => entry.owner === owner) ?? -1;
70
+ if (!entries || index < 0)
71
+ return;
72
+ const visible = index === entries.length - 1;
73
+ entries.splice(index, 1);
74
+ if (!entries.length) {
75
+ this.unregister(id);
76
+ return;
77
+ }
78
+ if (visible) {
79
+ this.views.set(id, entries.at(-1).contribution);
80
+ this.emit("changed", { id, action: "updated" });
81
+ }
82
+ }
83
+ setVisible(id, contribution) {
84
+ this.views.set(id, contribution);
85
+ const top = this.layers.get(id)?.at(-1);
86
+ if (top)
87
+ top.contribution = contribution;
88
+ }
51
89
  upsert(contribution) {
52
90
  const normalized = normalizeContribution(contribution);
53
91
  const existing = this.views.get(normalized.id);
@@ -55,7 +93,7 @@ export class EditorViewRegistry extends EventDispatcher {
55
93
  return this.register(normalized);
56
94
  }
57
95
  const merged = mergeContribution(existing, normalized);
58
- this.views.set(merged.id, merged);
96
+ this.setVisible(merged.id, merged);
59
97
  this.emit("changed", { id: merged.id, action: "updated" });
60
98
  return () => { };
61
99
  }
@@ -70,7 +108,7 @@ export class EditorViewRegistry extends EventDispatcher {
70
108
  id: existing.id,
71
109
  label: contribution.label ?? existing.label,
72
110
  });
73
- this.views.set(existing.id, merged);
111
+ this.setVisible(existing.id, merged);
74
112
  this.emit("changed", { id: existing.id, action: "updated" });
75
113
  return true;
76
114
  }
@@ -86,14 +124,16 @@ export class EditorViewRegistry extends EventDispatcher {
86
124
  }
87
125
  if (filenamePatterns.length === 0 && existing.source === "compat") {
88
126
  this.views.delete(id);
127
+ this.layers.delete(id);
89
128
  this.emit("changed", { id, action: "unregistered" });
90
129
  return true;
91
130
  }
92
- this.views.set(id, { ...existing, filenamePatterns });
131
+ this.setVisible(id, { ...existing, filenamePatterns });
93
132
  this.emit("changed", { id, action: "updated" });
94
133
  return true;
95
134
  }
96
135
  unregister(id) {
136
+ this.layers.delete(id);
97
137
  const deleted = this.views.delete(id);
98
138
  if (deleted) {
99
139
  this.emit("changed", { id, action: "unregistered" });
@@ -43,6 +43,12 @@ export interface EditorTransaction {
43
43
  }
44
44
  /** Controls whether an editor persists its own debounced document changes. */
45
45
  export type EditorPersistence = "vault" | "external";
46
+ export interface EditorPersistenceRequest {
47
+ readonly content: string;
48
+ readonly file: TFile | null;
49
+ readonly application: App;
50
+ }
51
+ export type EditorPersistenceWriter = (request: EditorPersistenceRequest) => Promise<void>;
46
52
  export interface MarkdownFileInfo {
47
53
  /** @public */
48
54
  app: App;
@@ -70,10 +76,20 @@ export declare class Editor extends EventDispatcher<{
70
76
  readonly id: `${string}-${string}-${string}-${string}-${string}`;
71
77
  private destroyed;
72
78
  private application;
73
- private readonly pendingChange;
74
79
  constructor(data?: string, extensions?: Extension[], application?: App);
75
80
  /** Bind this editor to the application that owns its view. */
76
81
  bindApplication(application: App): this;
82
+ /** Capture an explicit asynchronous owner for external-mode persistence. */
83
+ setExternalPersistenceWriter(writer?: EditorPersistenceWriter): this;
84
+ get hasUnsavedChanges(): boolean;
85
+ get editingProtected(): boolean;
86
+ get refreshError(): unknown;
87
+ /** Protect the current document and drain its captured persistence. */
88
+ protect(): Promise<() => void>;
89
+ /** Register and protect a target, then publish its file and contents atomically. */
90
+ loadDocument(file: TFile, read: () => Promise<string>, publish?: (contents: string) => void): Promise<boolean>;
91
+ /** Cancel a pending publication while observing any late read result. */
92
+ cancelDocumentLoad(): void;
77
93
  /** The owning application, with the global alias retained as fallback. */
78
94
  get app(): App;
79
95
  readonly save: import("lodash-es").DebouncedFunc<() => Promise<void>>;
@@ -88,6 +104,8 @@ export declare class Editor extends EventDispatcher<{
88
104
  getValue(): string;
89
105
  refresh(): void;
90
106
  destroy(): void;
107
+ /** Stop editing immediately and await all retained document persistence. */
108
+ dispose(): Promise<void>;
91
109
  trackChanges(callback?: (data: string, editor: Editor) => void): () => void;
92
110
  updateExtensions(extensions: Extension[], context?: Record<string, any>): this;
93
111
  setValue(content: string): void;