obsidian-integration-testing 8.3.0 → 9.0.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 (97) hide show
  1. package/README.md +52 -11
  2. package/dist/lib/cjs/asar-fallback-detection.cjs +48 -0
  3. package/dist/lib/cjs/asar-fallback-detection.d.cts +75 -0
  4. package/dist/lib/cjs/avd-list.cjs +36 -0
  5. package/dist/lib/cjs/avd-list.d.cts +38 -0
  6. package/dist/lib/cjs/compatibility-options.cjs +18 -1
  7. package/dist/lib/cjs/compatibility-options.d.cts +41 -0
  8. package/dist/lib/cjs/connect-to-cdp.cjs +17 -18
  9. package/dist/lib/cjs/connect-to-cdp.d.cts +25 -0
  10. package/dist/lib/cjs/demo-vault-tree.cjs +52 -0
  11. package/dist/lib/cjs/demo-vault-tree.d.cts +34 -0
  12. package/dist/lib/cjs/ecmascript-version.cjs +63 -0
  13. package/dist/lib/cjs/ecmascript-version.d.cts +28 -0
  14. package/dist/lib/cjs/global-setup-core.cjs +44 -27
  15. package/dist/lib/cjs/global-setup-core.d.cts +15 -3
  16. package/dist/lib/cjs/index.cjs +10 -1
  17. package/dist/lib/cjs/index.d.cts +7 -1
  18. package/dist/lib/cjs/installer-asset.cjs +18 -3
  19. package/dist/lib/cjs/installer-asset.d.cts +26 -0
  20. package/dist/lib/cjs/jest/global-setup-no-plugin.cjs +41 -0
  21. package/dist/lib/cjs/jest/global-setup-no-plugin.d.cts +26 -0
  22. package/dist/lib/cjs/jest/global-setup.cjs +2 -2
  23. package/dist/lib/cjs/jest/global-setup.d.cts +11 -1
  24. package/dist/lib/cjs/jest/global-teardown-no-plugin.cjs +26 -0
  25. package/dist/lib/cjs/jest/global-teardown-no-plugin.d.cts +11 -0
  26. package/dist/lib/cjs/library.cjs +1 -1
  27. package/dist/lib/cjs/namespace-bootstrap.cjs +44 -7
  28. package/dist/lib/cjs/normalize-optional-properties.cjs +31 -0
  29. package/dist/lib/cjs/normalize-optional-properties.d.cts +26 -0
  30. package/dist/lib/cjs/obsidian-installer.cjs +6 -1
  31. package/dist/lib/cjs/obsidian-metadata.cjs +3775 -302
  32. package/dist/lib/cjs/obsidian-metadata.d.cts +71 -0
  33. package/dist/lib/cjs/obsidian-version-switch.cjs +5 -2
  34. package/dist/lib/cjs/owned-vault-seed.cjs +38 -0
  35. package/dist/lib/cjs/owned-vault-seed.d.cts +67 -0
  36. package/dist/lib/cjs/process-exit-message.cjs +47 -0
  37. package/dist/lib/cjs/process-exit-message.d.cts +48 -0
  38. package/dist/lib/cjs/silent-asar-fallback-error.cjs +48 -0
  39. package/dist/lib/cjs/silent-asar-fallback-error.d.cts +40 -0
  40. package/dist/lib/cjs/transport-desktop-cdp.cjs +197 -73
  41. package/dist/lib/cjs/transport-desktop-cdp.d.cts +74 -15
  42. package/dist/lib/cjs/transport-factory.cjs +135 -34
  43. package/dist/lib/cjs/transport-options.cjs +1 -1
  44. package/dist/lib/cjs/transport-options.d.cts +16 -0
  45. package/dist/lib/cjs/vitest/global-setup-no-plugin.cjs +37 -0
  46. package/dist/lib/cjs/vitest/global-setup-no-plugin.d.cts +26 -0
  47. package/dist/lib/cjs/vitest/global-setup.cjs +2 -2
  48. package/dist/lib/cjs/vitest/global-setup.d.cts +11 -1
  49. package/dist/lib/esm/asar-fallback-detection.d.mts +75 -0
  50. package/dist/lib/esm/asar-fallback-detection.mjs +24 -0
  51. package/dist/lib/esm/avd-list.d.mts +38 -0
  52. package/dist/lib/esm/avd-list.mjs +11 -0
  53. package/dist/lib/esm/compatibility-options.d.mts +41 -0
  54. package/dist/lib/esm/compatibility-options.mjs +16 -1
  55. package/dist/lib/esm/connect-to-cdp.d.mts +25 -0
  56. package/dist/lib/esm/connect-to-cdp.mjs +17 -18
  57. package/dist/lib/esm/demo-vault-tree.d.mts +34 -0
  58. package/dist/lib/esm/demo-vault-tree.mjs +35 -0
  59. package/dist/lib/esm/ecmascript-version.d.mts +28 -0
  60. package/dist/lib/esm/ecmascript-version.mjs +39 -0
  61. package/dist/lib/esm/global-setup-core.d.mts +15 -3
  62. package/dist/lib/esm/global-setup-core.mjs +44 -27
  63. package/dist/lib/esm/index.d.mts +7 -1
  64. package/dist/lib/esm/index.mjs +7 -1
  65. package/dist/lib/esm/installer-asset.d.mts +26 -0
  66. package/dist/lib/esm/installer-asset.mjs +16 -2
  67. package/dist/lib/esm/jest/global-setup-no-plugin.d.mts +26 -0
  68. package/dist/lib/esm/jest/global-setup-no-plugin.mjs +17 -0
  69. package/dist/lib/esm/jest/global-setup.d.mts +11 -1
  70. package/dist/lib/esm/jest/global-setup.mjs +2 -2
  71. package/dist/lib/esm/jest/global-teardown-no-plugin.d.mts +11 -0
  72. package/dist/lib/esm/jest/global-teardown-no-plugin.mjs +6 -0
  73. package/dist/lib/esm/library.mjs +1 -1
  74. package/dist/lib/esm/namespace-bootstrap.mjs +44 -7
  75. package/dist/lib/esm/normalize-optional-properties.d.mts +26 -0
  76. package/dist/lib/esm/normalize-optional-properties.mjs +7 -0
  77. package/dist/lib/esm/obsidian-installer.mjs +8 -2
  78. package/dist/lib/esm/obsidian-metadata.d.mts +71 -0
  79. package/dist/lib/esm/obsidian-metadata.mjs +3775 -302
  80. package/dist/lib/esm/obsidian-version-switch.mjs +5 -2
  81. package/dist/lib/esm/owned-vault-seed.d.mts +67 -0
  82. package/dist/lib/esm/owned-vault-seed.mjs +14 -0
  83. package/dist/lib/esm/process-exit-message.d.mts +48 -0
  84. package/dist/lib/esm/process-exit-message.mjs +23 -0
  85. package/dist/lib/esm/silent-asar-fallback-error.d.mts +40 -0
  86. package/dist/lib/esm/silent-asar-fallback-error.mjs +24 -0
  87. package/dist/lib/esm/transport-desktop-cdp.d.mts +74 -15
  88. package/dist/lib/esm/transport-desktop-cdp.mjs +197 -73
  89. package/dist/lib/esm/transport-factory.mjs +139 -34
  90. package/dist/lib/esm/transport-options.d.mts +16 -0
  91. package/dist/lib/esm/vitest/global-setup-no-plugin.d.mts +26 -0
  92. package/dist/lib/esm/vitest/global-setup-no-plugin.mjs +11 -0
  93. package/dist/lib/esm/vitest/global-setup.d.mts +11 -1
  94. package/dist/lib/esm/vitest/global-setup.mjs +2 -2
  95. package/dist/obsidian-integration-testing-9.0.0.tgz +0 -0
  96. package/package.json +40 -8
  97. package/dist/obsidian-integration-testing-8.3.0.tgz +0 -0
@@ -16,6 +16,7 @@
16
16
  *
17
17
  * Requirements: Node.js 22+ (uses built-in `WebSocket` and `fetch` globals).
18
18
  */
19
+ import type { AsarFallback } from './asar-fallback-detection.cjs';
19
20
  import type { ElectronCompatibility } from './electron-compatibility.cjs';
20
21
  import type { InstallerCompatibility } from './installer-compatibility.cjs';
21
22
  import type { ObsidianTransport, TransportEvalOptions } from './transport.cjs';
@@ -75,6 +76,16 @@ export interface DesktopCdpTransportConfig {
75
76
  * @default `false`
76
77
  */
77
78
  shouldDisableSandbox?: boolean;
79
+ /**
80
+ * Whether a post-boot **silent asar fallback** (the running app version differs
81
+ * from the swapped-in pin) fails fast with {@link SilentAsarFallbackError}. The
82
+ * verdict is always computed and surfaced via
83
+ * {@link DesktopCdpTransport.getAsarFallback}; this gates only the throw. Only
84
+ * meaningful in owned mode running a swapped-in asar.
85
+ *
86
+ * @default `true`
87
+ */
88
+ shouldThrowOnSilentAsarFallback?: boolean;
78
89
  /**
79
90
  * Whether the post-boot runtime-Electron compatibility nag warning is emitted
80
91
  * when the live Electron is below the app's recommended minimum. The verdict is
@@ -141,6 +152,7 @@ export declare class DesktopCdpTransport implements ObsidianTransport {
141
152
  */
142
153
  readonly isMobile = false;
143
154
  private activeVaultPath;
155
+ private asarFallback;
144
156
  private readonly cdpHost;
145
157
  private cdpPort;
146
158
  private cdpUrl;
@@ -153,6 +165,7 @@ export declare class DesktopCdpTransport implements ObsidianTransport {
153
165
  private readonly ownedConfig;
154
166
  private ownedInstance;
155
167
  private readonly shouldDisableSandbox;
168
+ private readonly shouldThrowOnSilentAsarFallback;
156
169
  private readonly shouldWarnOnCompatibilityIssues;
157
170
  private ws;
158
171
  /**
@@ -185,6 +198,19 @@ export declare class DesktopCdpTransport implements ObsidianTransport {
185
198
  * @returns The normalized result string.
186
199
  */
187
200
  evaluate(expression: string, options: TransportEvalOptions): Promise<string>;
201
+ /**
202
+ * Returns the silent-asar-fallback verdict for this owned instance — whether the
203
+ * app version it is actually running matches the swapped-in pin, or the installer
204
+ * silently reverted to its own bundled asar (read live post-boot). Returns
205
+ * `undefined` when this is not an owned instance, the instance has not booted
206
+ * yet, or the verdict could not be determined (no asar was swapped, or the live
207
+ * version was unreadable). A `'fallback'` verdict reaches this surface only when
208
+ * the throw is disabled ({@link DesktopCdpTransportConfig.shouldThrowOnSilentAsarFallback}
209
+ * `false`); otherwise it throws `SilentAsarFallbackError`.
210
+ *
211
+ * @returns The silent-asar-fallback verdict, or `undefined`.
212
+ */
213
+ getAsarFallback(): AsarFallback | undefined;
188
214
  /**
189
215
  * Returns the resolved installer↔app compatibility verdict for this owned
190
216
  * instance, so callers can assert on it. Returns `undefined` when this is not
@@ -239,24 +265,46 @@ export declare class DesktopCdpTransport implements ObsidianTransport {
239
265
  */
240
266
  unregisterVault(vaultPath: string): Promise<void>;
241
267
  /**
242
- * Best-effort tier-2 runtime nag: reads the live Electron version and running
243
- * app version from the booted owned renderer and warns when the Electron the
244
- * instance is actually running is older than the app's recommended minimum.
245
- * Stores the verdict on {@link getElectronCompatibility}.
246
- *
247
- * The app version is read **live** — the running app version from the main
248
- * process (`ipcRenderer.sendSync('version')`, the same IPC channel the namespace
249
- * bootstrap uses) rather than from the resolved config — so the nag reflects the
250
- * version genuinely running across every owned sub-path (asar-swap / downgrade /
251
- * own-installer) and stays truthful even under a silent asar fallback.
252
- * `process.versions.electron` gives the shell's live Electron. Both are read at
253
- * the renderer top level (no `require('obsidian')`, which resolves only inside a
254
- * plugin-load context). Never throws a read failure is logged and ignored, so
255
- * it cannot break an otherwise-ready boot.
268
+ * Computes and stores the runtime-Electron compatibility verdict (on
269
+ * {@link getElectronCompatibility}) from an already-read version pair, warning
270
+ * when the live Electron is below the app's recommended minimum. Never throws; a
271
+ * boot whose running app version was unreadable is skipped (nothing to judge).
272
+ *
273
+ * @param appVersion - The live running app version, or `undefined` when unreadable.
274
+ * @param actualElectronVersion - The live Electron version, or `undefined` when unreadable.
275
+ */
276
+ private applyElectronCompatibility;
277
+ /**
278
+ * Verifies the running app (asar) version matches the swapped-in pin, storing the
279
+ * verdict on {@link getAsarFallback}. On a **silent fallback** (the installer ran
280
+ * its own bundled asar instead of the pin) it throws {@link SilentAsarFallbackError}
281
+ * when the throw is enabled, otherwise warns (when warnings are on) and lets the
282
+ * boot proceed. A boot with no swapped-in asar, or an unreadable running version,
283
+ * is `'unknown'` — nothing is thrown or warned. This is the healthy-UI companion to
284
+ * the black-screen {@link RendererFailedToInitializeError} dead-boot fast-fail.
285
+ *
286
+ * @param runningApiVersion - The live running app version, or `undefined` when unreadable.
287
+ */
288
+ private checkRuntimeAsarFallback;
289
+ /**
290
+ * Runs the post-boot runtime compatibility checks for an owned instance, once the
291
+ * vault is ready. Reads the live running app version and Electron version **once**
292
+ * from the booted renderer's main process, then: (1) verifies the running app
293
+ * version matches the swapped-in pin — throwing {@link SilentAsarFallbackError} on
294
+ * a silent fallback (when enabled); and (2) runs the best-effort runtime-Electron
295
+ * nag. Only the asar-fallback check can throw, so this must run outside the
296
+ * readiness poll's try/catch (a swallowed throw would loop until timeout).
297
+ *
298
+ * Both are read at the renderer top level: `ipcRenderer.sendSync('version')` (the
299
+ * running app version, truthful even under a silent asar fallback) and
300
+ * `process.versions.electron` (the live shell Electron); neither uses
301
+ * `require('obsidian')`, which resolves only inside a plugin-load context. A read
302
+ * failure leaves both unknown (logged, non-fatal) — an unreadable running version
303
+ * cannot be judged a fallback, so the boot is not broken by a flaky read.
256
304
  *
257
305
  * @param vaultPath - The vault path to evaluate in.
258
306
  */
259
- private checkRuntimeElectronCompatibility;
307
+ private checkRuntimeCompatibility;
260
308
  /**
261
309
  * Connects to a CDP target's WebSocket endpoint.
262
310
  *
@@ -320,6 +368,17 @@ export declare class DesktopCdpTransport implements ObsidianTransport {
320
368
  * @returns The list of page targets.
321
369
  */
322
370
  private getPageTargets;
371
+ /**
372
+ * Kills the currently-running owned instance (if any) and waits for it to exit,
373
+ * so the next launch gets a pristine single-window instance.
374
+ *
375
+ * Relaunching over a live instance is forwarded by Electron's single-instance
376
+ * lock on the shared user-data dir and surfaces the vault picker, and opening a
377
+ * second window via IPC leaves stale windows that break vault-target routing —
378
+ * hence a full kill + wait-for-exit (releasing the lock) between launches. A
379
+ * no-op on the first attempt, when no instance is running yet.
380
+ */
381
+ private killRunningOwnedInstance;
323
382
  /**
324
383
  * Moves the owned instance's window off-screen so a hidden run never steals
325
384
  * focus. Uses Electron's remote bridge (`window.electron.remote`) — the only