@lapis-notes/app-profile 0.2.2 → 0.2.4

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @lapis-notes/app-profile
2
2
 
3
+ ## 0.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#146](https://github.com/lapismd/lapis-notes/pull/146)
8
+ [`0f40b08`](https://github.com/lapismd/lapis-notes/commit/0f40b081424a2bd74c562a781a2a0c913c1d1e95)
9
+ Thanks
10
+ [@lapismd-dependency-bot](https://github.com/apps/lapismd-dependency-bot)! -
11
+ Refresh first-party Lapis dependencies to the published versions recorded in
12
+ this pull request.
13
+
14
+ ## 0.2.3
15
+
16
+ ### Patch Changes
17
+
18
+ - [#136](https://github.com/lapismd/lapis-notes/pull/136)
19
+ [`d51d6ac`](https://github.com/lapismd/lapis-notes/commit/d51d6acbabbbef1d6a04c187c696432705340661)
20
+ Thanks [@stevejuma](https://github.com/stevejuma)! - Fence and drain App-owned
21
+ native Sync calls before session writer protection, restore live leases after
22
+ refused leave, and await presentation transport detachment without closing
23
+ native-owned work.
24
+
25
+ - [#139](https://github.com/lapismd/lapis-notes/pull/139)
26
+ [`4e3407c`](https://github.com/lapismd/lapis-notes/commit/4e3407cac6daacecaea62618309e464a0517c2ab)
27
+ Thanks [@stevejuma](https://github.com/stevejuma)! - Expose a bounded
28
+ startup-operation marker so pending vault discovery, Sync readiness and
29
+ state-directory creation can be distinguished in browser acceptance
30
+ diagnostics.
31
+ - Updated dependencies
32
+ [[`d51d6ac`](https://github.com/lapismd/lapis-notes/commit/d51d6acbabbbef1d6a04c187c696432705340661)]:
33
+ - @lapis-notes/api@0.6.6
34
+
3
35
  ## 0.2.2
4
36
 
5
37
  ### Patch Changes
@@ -1,6 +1,5 @@
1
1
  <script lang="ts">
2
2
  import { provideApplicationState, type VaultProfile } from "@lapis-notes/api";
3
- import { DEFAULT_APP_STATE_DIRECTORY } from "@lapis-notes/api/path";
4
3
  import { getWorkspaceHostBinding } from "@lapis-notes/api/workspace-host";
5
4
  import { WorkspaceShell } from "@lapis-notes/workspace";
6
5
  import type { WorkspaceNavigation } from "@lapismd/design-core/workspace/app-shell";
@@ -17,6 +16,10 @@
17
16
  import { createNotesApplication } from "./application";
18
17
  import { registerSessionDatabaseStatus } from "./database-status";
19
18
  import { createNotesSessionLifecycle } from "./lifecycle";
19
+ import {
20
+ openSessionVault,
21
+ type VaultStartupOperation,
22
+ } from "./vault-startup";
20
23
  import type { NotesWorkspaceSessionProps } from "./types";
21
24
 
22
25
  let options: NotesWorkspaceSessionProps = $props();
@@ -33,6 +36,7 @@
33
36
  let ready = $state(false);
34
37
  let tasks = $state(structuredClone(startupTasks));
35
38
  let failure = $state<WorkspaceStartupFailure | null>(null);
39
+ let startupOperation = $state<VaultStartupOperation | "idle">("idle");
36
40
  let booting = false;
37
41
  let bootFlight: Promise<void> | undefined;
38
42
  let corePluginsRegistered = false;
@@ -157,9 +161,9 @@
157
161
  registerSessionNativeChat(app, options.nativeChat, options.runtime);
158
162
  corePluginsRegistered = true;
159
163
  }
160
- await app.vault.load();
161
- await application.syncHost.ready();
162
- await app.vault.mkpath(DEFAULT_APP_STATE_DIRECTORY);
164
+ await openSessionVault(app.vault, application.syncHost, (operation) => {
165
+ startupOperation = operation;
166
+ });
163
167
  if (!lifecycle.canRecoverLeave()) return;
164
168
  setTask(activeTask, "complete");
165
169
  activeTask = "configuration";
@@ -236,6 +240,7 @@
236
240
  <section
237
241
  class="notes-workspace-session"
238
242
  data-notes-session-ready={interactive}
243
+ data-notes-startup-operation={startupOperation}
239
244
  data-web-runtime={options.runtime}
240
245
  data-vault-id={options.profile.id}
241
246
  aria-label="Notes workspace"
@@ -5,6 +5,11 @@ import { createWorkspaceLeave } from "./leave";
5
5
  export function createNotesSessionLifecycle(options) {
6
6
  const { app, session } = options;
7
7
  let disposed = false;
8
+ let resumeSync;
9
+ const releaseSyncPreparation = () => {
10
+ resumeSync?.();
11
+ resumeSync = undefined;
12
+ };
8
13
  const persistLayout = async () => {
9
14
  if (disposed || !app.workspace.layoutReady)
10
15
  return;
@@ -17,6 +22,7 @@ export function createNotesSessionLifecycle(options) {
17
22
  const dispose = createWorkspaceLeave({
18
23
  isDisposed: () => disposed,
19
24
  preflight: async () => {
25
+ resumeSync = await app.nativeSync?.prepareLeave();
20
26
  await prepareNativeRepositoryLeave(app);
21
27
  await app.vaultChanges.stop();
22
28
  await app.workspace.flushPluginChanges();
@@ -25,6 +31,7 @@ export function createNotesSessionLifecycle(options) {
25
31
  await app.fileEditingSessions.preflightNativeRecovery();
26
32
  },
27
33
  onRefused: async (error) => {
34
+ releaseSyncPreparation();
28
35
  const resumed = await Promise.allSettled([
29
36
  resumeNativeRepositoryLeave(app),
30
37
  app.vaultChanges.start(),
@@ -46,37 +53,43 @@ export function createNotesSessionLifecycle(options) {
46
53
  commit: async (persist) => {
47
54
  if (disposed)
48
55
  return;
49
- const failures = [];
50
- const attempt = async (action) => {
51
- try {
52
- await action();
53
- }
54
- catch (error) {
55
- failures.push(error);
56
- }
57
- };
58
- await app.fileEditingSessions.guard(undefined, async () => {
59
- await app.workspace.flushLayout();
60
- if (persist)
61
- await persistLayout();
62
- disposed = true;
63
- await attempt(() => app.nativeTasks?.detach());
64
- await attempt(() => prepareNativeChatLeave(app, "detach"));
65
- options.fence();
66
- await attempt(() => app.workspace.disposeWorkspaceHost());
67
- await attempt(options.releaseObservers);
68
- await attempt(() => app.metadataCache.dispose());
69
- for (const plugin of [...app.plugins.plugins.values()].reverse()) {
70
- await attempt(() => plugin.disable());
71
- }
72
- });
73
- await attempt(() => app.fileEditingSessions.dispose());
74
- await attempt(options.releaseServices);
75
- await attempt(() => session.close());
76
- await attempt(options.releaseHostServices);
77
- if (failures.length)
78
- throw new AggregateError(failures, "Notes session cleanup did not complete");
79
- options.releaseApplication();
56
+ try {
57
+ const failures = [];
58
+ const attempt = async (action) => {
59
+ try {
60
+ await action();
61
+ }
62
+ catch (error) {
63
+ failures.push(error);
64
+ }
65
+ };
66
+ await app.fileEditingSessions.guard(undefined, async () => {
67
+ await app.workspace.flushLayout();
68
+ if (persist)
69
+ await persistLayout();
70
+ disposed = true;
71
+ await attempt(() => app.nativeTasks?.detach());
72
+ await attempt(() => prepareNativeChatLeave(app, "detach"));
73
+ options.fence();
74
+ await attempt(() => app.workspace.disposeWorkspaceHost());
75
+ await attempt(options.releaseObservers);
76
+ await attempt(() => app.metadataCache.dispose());
77
+ for (const plugin of [...app.plugins.plugins.values()].reverse()) {
78
+ await attempt(() => plugin.disable());
79
+ }
80
+ });
81
+ await attempt(() => app.fileEditingSessions.dispose());
82
+ await attempt(options.releaseServices);
83
+ await attempt(() => session.close());
84
+ await attempt(options.releaseHostServices);
85
+ if (failures.length)
86
+ throw new AggregateError(failures, "Notes session cleanup did not complete");
87
+ releaseSyncPreparation();
88
+ options.releaseApplication();
89
+ }
90
+ finally {
91
+ releaseSyncPreparation();
92
+ }
80
93
  },
81
94
  });
82
95
  return { persistLayout, dispose, canRecoverLeave: () => !disposed };
@@ -0,0 +1,4 @@
1
+ import type { App, SyncHostService } from "@lapis-notes/api";
2
+ export type VaultStartupOperation = "vault-discovery" | "sync-readiness" | "state-directory" | "complete";
3
+ /** Keep the existing startup order while identifying a pending operation. */
4
+ export declare function openSessionVault(vault: Pick<App["vault"], "load" | "mkpath">, sync: Pick<SyncHostService, "ready">, report: (operation: VaultStartupOperation) => void): Promise<void>;
@@ -0,0 +1,11 @@
1
+ import { DEFAULT_APP_STATE_DIRECTORY } from "@lapis-notes/api/path";
2
+ /** Keep the existing startup order while identifying a pending operation. */
3
+ export async function openSessionVault(vault, sync, report) {
4
+ report("vault-discovery");
5
+ await vault.load();
6
+ report("sync-readiness");
7
+ await sync.ready();
8
+ report("state-directory");
9
+ await vault.mkpath(DEFAULT_APP_STATE_DIRECTORY);
10
+ report("complete");
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lapis-notes/app-profile",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -35,15 +35,15 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@lapis-notes/api": "^0.6.5",
38
+ "@lapis-notes/api": "^0.6.6",
39
39
  "@lapis-notes/file-explorer": "^0.2.8",
40
- "@lapis-notes/markdown": "^0.3.1",
41
- "@lapis-notes/search": "^0.1.12",
42
- "@lapis-notes/source-editor": "^0.1.11",
40
+ "@lapis-notes/markdown": "^0.3.3",
41
+ "@lapis-notes/search": "^0.1.13",
42
+ "@lapis-notes/source-editor": "^0.1.12",
43
43
  "@lapis-notes/workspace": "^0.4.6",
44
- "@lapismd/agent-ui": "^0.2.6",
44
+ "@lapismd/agent-ui": "^0.2.8",
45
45
  "@lapismd/design-core": "^0.13.3",
46
- "@lapis-notes/history": "^0.5.0",
46
+ "@lapis-notes/history": "^0.5.1",
47
47
  "@lapismd/jj-history": "^0.1.0"
48
48
  },
49
49
  "devDependencies": {