@lapis-notes/app-profile 0.2.1 → 0.2.3

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.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#136](https://github.com/lapismd/lapis-notes/pull/136)
8
+ [`d51d6ac`](https://github.com/lapismd/lapis-notes/commit/d51d6acbabbbef1d6a04c187c696432705340661)
9
+ Thanks [@stevejuma](https://github.com/stevejuma)! - Fence and drain App-owned
10
+ native Sync calls before session writer protection, restore live leases after
11
+ refused leave, and await presentation transport detachment without closing
12
+ native-owned work.
13
+
14
+ - [#139](https://github.com/lapismd/lapis-notes/pull/139)
15
+ [`4e3407c`](https://github.com/lapismd/lapis-notes/commit/4e3407cac6daacecaea62618309e464a0517c2ab)
16
+ Thanks [@stevejuma](https://github.com/stevejuma)! - Expose a bounded
17
+ startup-operation marker so pending vault discovery, Sync readiness and
18
+ state-directory creation can be distinguished in browser acceptance
19
+ diagnostics.
20
+ - Updated dependencies
21
+ [[`d51d6ac`](https://github.com/lapismd/lapis-notes/commit/d51d6acbabbbef1d6a04c187c696432705340661)]:
22
+ - @lapis-notes/api@0.6.6
23
+
24
+ ## 0.2.2
25
+
26
+ ### Patch Changes
27
+
28
+ - [#133](https://github.com/lapismd/lapis-notes/pull/133)
29
+ [`ea9e45b`](https://github.com/lapismd/lapis-notes/commit/ea9e45b69f7d2dbf01404afa09894684881d16c0)
30
+ Thanks [@stevejuma](https://github.com/stevejuma)! - Consume History 0.5's
31
+ passive native synchronization observer alongside shared repository remotes
32
+ and credentials. Hosts retain transport, custody and native operation
33
+ ownership.
34
+
3
35
  ## 0.2.1
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.1",
3
+ "version": "0.2.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -35,7 +35,7 @@
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
40
  "@lapis-notes/markdown": "^0.3.1",
41
41
  "@lapis-notes/search": "^0.1.12",
@@ -43,7 +43,7 @@
43
43
  "@lapis-notes/workspace": "^0.4.6",
44
44
  "@lapismd/agent-ui": "^0.2.6",
45
45
  "@lapismd/design-core": "^0.13.3",
46
- "@lapis-notes/history": "^0.4.0",
46
+ "@lapis-notes/history": "^0.5.0",
47
47
  "@lapismd/jj-history": "^0.1.0"
48
48
  },
49
49
  "devDependencies": {