obsidian-plugin-dev-kit 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +223 -2
- package/bin/opdk.js +34 -0
- package/dist/build/args.d.ts +10 -0
- package/dist/build/args.js +45 -0
- package/dist/build/bundle-check.d.ts +17 -0
- package/dist/build/bundle-check.js +42 -0
- package/dist/build/bundle-file.d.ts +4 -0
- package/dist/build/bundle-file.js +29 -0
- package/dist/build/commands.d.ts +5 -0
- package/dist/build/commands.js +109 -0
- package/dist/build/config.d.ts +3 -0
- package/dist/build/config.js +103 -0
- package/dist/build/css-imports.d.ts +23 -0
- package/dist/build/css-imports.js +50 -0
- package/dist/build/css-step.d.ts +10 -0
- package/dist/build/css-step.js +27 -0
- package/dist/build/css.d.ts +24 -0
- package/dist/build/css.js +47 -0
- package/dist/build/options.d.ts +55 -0
- package/dist/build/options.js +70 -0
- package/dist/build/release.d.ts +5 -0
- package/dist/build/release.js +34 -0
- package/dist/build/report.d.ts +7 -0
- package/dist/build/report.js +16 -0
- package/dist/build/vault.d.ts +26 -0
- package/dist/build/vault.js +290 -0
- package/dist/build-info.json +1 -0
- package/dist/cli/argv.d.ts +14 -0
- package/dist/cli/argv.js +18 -0
- package/dist/cli/commands.d.ts +3 -0
- package/dist/cli/commands.js +7 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +23 -0
- package/dist/cli/process-reporter.d.ts +5 -0
- package/dist/cli/process-reporter.js +15 -0
- package/dist/cli/registry.d.ts +4 -0
- package/dist/cli/registry.js +15 -0
- package/dist/cli/reporter.d.ts +53 -0
- package/dist/cli/reporter.js +100 -0
- package/dist/cli/run.d.ts +9 -0
- package/dist/cli/run.js +61 -0
- package/dist/cli/types.d.ts +27 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/version.d.ts +13 -0
- package/dist/cli/version.js +61 -0
- package/dist/config/define-config.d.ts +3 -0
- package/dist/config/define-config.js +4 -0
- package/dist/config/load-config.d.ts +6 -0
- package/dist/config/load-config.js +70 -0
- package/dist/config/manifest.d.ts +3 -0
- package/dist/config/manifest.js +72 -0
- package/dist/config/types.d.ts +146 -0
- package/dist/config/types.js +23 -0
- package/dist/demo/args.d.ts +4 -0
- package/dist/demo/args.js +13 -0
- package/dist/demo/checks.d.ts +56 -0
- package/dist/demo/checks.js +124 -0
- package/dist/demo/commands.d.ts +3 -0
- package/dist/demo/commands.js +65 -0
- package/dist/demo/config.d.ts +57 -0
- package/dist/demo/config.js +337 -0
- package/dist/demo/ffmpeg-run.d.ts +18 -0
- package/dist/demo/ffmpeg-run.js +59 -0
- package/dist/demo/ffmpeg.d.ts +63 -0
- package/dist/demo/ffmpeg.js +111 -0
- package/dist/demo/films.d.ts +46 -0
- package/dist/demo/films.js +134 -0
- package/dist/demo/phone-layout.d.ts +38 -0
- package/dist/demo/phone-layout.js +98 -0
- package/dist/demo/phone-render.d.ts +28 -0
- package/dist/demo/phone-render.js +124 -0
- package/dist/demo/published.d.ts +16 -0
- package/dist/demo/published.js +72 -0
- package/dist/demo/run.d.ts +31 -0
- package/dist/demo/run.js +397 -0
- package/dist/demo/stills.d.ts +21 -0
- package/dist/demo/stills.js +62 -0
- package/dist/e2e/artifacts.d.ts +27 -0
- package/dist/e2e/artifacts.js +90 -0
- package/dist/e2e/cleanup.d.ts +54 -0
- package/dist/e2e/cleanup.js +109 -0
- package/dist/e2e/config.d.ts +9 -0
- package/dist/e2e/config.js +42 -0
- package/dist/e2e/create-test.d.ts +37 -0
- package/dist/e2e/create-test.js +109 -0
- package/dist/e2e/demo/clip.d.ts +21 -0
- package/dist/e2e/demo/clip.js +44 -0
- package/dist/e2e/demo/create-demo.d.ts +42 -0
- package/dist/e2e/demo/create-demo.js +439 -0
- package/dist/e2e/demo/manifest.d.ts +76 -0
- package/dist/e2e/demo/manifest.js +168 -0
- package/dist/e2e/demo/names.d.ts +18 -0
- package/dist/e2e/demo/names.js +44 -0
- package/dist/e2e/demo/options.d.ts +22 -0
- package/dist/e2e/demo/options.js +59 -0
- package/dist/e2e/demo/ownership.d.ts +27 -0
- package/dist/e2e/demo/ownership.js +65 -0
- package/dist/e2e/demo/page-scripts.d.ts +82 -0
- package/dist/e2e/demo/page-scripts.js +250 -0
- package/dist/e2e/demo/png.d.ts +8 -0
- package/dist/e2e/demo/png.js +23 -0
- package/dist/e2e/demo/presets.d.ts +43 -0
- package/dist/e2e/demo/presets.js +20 -0
- package/dist/e2e/demo/privacy.d.ts +18 -0
- package/dist/e2e/demo/privacy.js +30 -0
- package/dist/e2e/demo/still-options.d.ts +22 -0
- package/dist/e2e/demo/still-options.js +68 -0
- package/dist/e2e/demo/types.d.ts +184 -0
- package/dist/e2e/demo/types.js +1 -0
- package/dist/e2e/electron-binary.d.ts +15 -0
- package/dist/e2e/electron-binary.js +30 -0
- package/dist/e2e/fixtures.d.ts +62 -0
- package/dist/e2e/fixtures.js +68 -0
- package/dist/e2e/gate.d.ts +4 -0
- package/dist/e2e/gate.js +8 -0
- package/dist/e2e/global-setup.d.ts +11 -0
- package/dist/e2e/global-setup.js +17 -0
- package/dist/e2e/helpers/commands.d.ts +14 -0
- package/dist/e2e/helpers/commands.js +56 -0
- package/dist/e2e/helpers/create-helpers.d.ts +24 -0
- package/dist/e2e/helpers/create-helpers.js +582 -0
- package/dist/e2e/helpers/device-metrics.d.ts +21 -0
- package/dist/e2e/helpers/device-metrics.js +25 -0
- package/dist/e2e/helpers/ime.d.ts +13 -0
- package/dist/e2e/helpers/ime.js +19 -0
- package/dist/e2e/helpers/layout-page-scripts.d.ts +103 -0
- package/dist/e2e/helpers/layout-page-scripts.js +224 -0
- package/dist/e2e/helpers/layout.d.ts +83 -0
- package/dist/e2e/helpers/layout.js +148 -0
- package/dist/e2e/helpers/mobile.d.ts +31 -0
- package/dist/e2e/helpers/mobile.js +26 -0
- package/dist/e2e/helpers/page-scripts.d.ts +194 -0
- package/dist/e2e/helpers/page-scripts.js +467 -0
- package/dist/e2e/helpers/settings.d.ts +8 -0
- package/dist/e2e/helpers/settings.js +16 -0
- package/dist/e2e/helpers/settle.d.ts +28 -0
- package/dist/e2e/helpers/settle.js +33 -0
- package/dist/e2e/helpers/types.d.ts +193 -0
- package/dist/e2e/helpers/types.js +1 -0
- package/dist/e2e/helpers/view-mode.d.ts +23 -0
- package/dist/e2e/helpers/view-mode.js +35 -0
- package/dist/e2e/index.d.ts +14 -0
- package/dist/e2e/index.js +4 -0
- package/dist/e2e/internals.d.ts +155 -0
- package/dist/e2e/internals.js +8 -0
- package/dist/e2e/obsidian-path.d.ts +17 -0
- package/dist/e2e/obsidian-path.js +31 -0
- package/dist/e2e/options.d.ts +123 -0
- package/dist/e2e/options.js +244 -0
- package/dist/e2e/page-scripts.d.ts +45 -0
- package/dist/e2e/page-scripts.js +53 -0
- package/dist/e2e/peers.d.ts +9 -0
- package/dist/e2e/peers.js +19 -0
- package/dist/e2e/plugins.d.ts +32 -0
- package/dist/e2e/plugins.js +119 -0
- package/dist/e2e/process-tree.d.ts +33 -0
- package/dist/e2e/process-tree.js +133 -0
- package/dist/e2e/readiness.d.ts +23 -0
- package/dist/e2e/readiness.js +63 -0
- package/dist/e2e/seed.d.ts +34 -0
- package/dist/e2e/seed.js +122 -0
- package/dist/e2e/session.d.ts +71 -0
- package/dist/e2e/session.js +266 -0
- package/dist/e2e/vault.d.ts +52 -0
- package/dist/e2e/vault.js +146 -0
- package/dist/e2e/version.d.ts +25 -0
- package/dist/e2e/version.js +40 -0
- package/dist/eslint/index.d.ts +2 -0
- package/dist/eslint/index.js +1 -0
- package/dist/eslint/obsidian-plugin.d.ts +49 -0
- package/dist/eslint/obsidian-plugin.js +115 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/kit/args.d.ts +7 -0
- package/dist/kit/args.js +21 -0
- package/dist/kit/commands.d.ts +3 -0
- package/dist/kit/commands.js +52 -0
- package/dist/kit/files.d.ts +3 -0
- package/dist/kit/files.js +24 -0
- package/dist/kit/pins.d.ts +89 -0
- package/dist/kit/pins.js +178 -0
- package/dist/kit/remote.d.ts +13 -0
- package/dist/kit/remote.js +33 -0
- package/dist/kit/runners.d.ts +11 -0
- package/dist/kit/runners.js +53 -0
- package/dist/kit/terminal-text.d.ts +6 -0
- package/dist/kit/terminal-text.js +20 -0
- package/dist/kit/upgrade.d.ts +26 -0
- package/dist/kit/upgrade.js +162 -0
- package/dist/peers/resolve.d.ts +8 -0
- package/dist/peers/resolve.js +28 -0
- package/dist/peers/versions.d.ts +30 -0
- package/dist/peers/versions.js +32 -0
- package/dist/release/api-check.d.ts +27 -0
- package/dist/release/api-check.js +119 -0
- package/dist/release/args.d.ts +40 -0
- package/dist/release/args.js +120 -0
- package/dist/release/assets.d.ts +21 -0
- package/dist/release/assets.js +35 -0
- package/dist/release/build-check.d.ts +43 -0
- package/dist/release/build-check.js +184 -0
- package/dist/release/build-script.d.ts +12 -0
- package/dist/release/build-script.js +30 -0
- package/dist/release/build-tagged.d.ts +26 -0
- package/dist/release/build-tagged.js +52 -0
- package/dist/release/bump.d.ts +24 -0
- package/dist/release/bump.js +58 -0
- package/dist/release/changelog.d.ts +25 -0
- package/dist/release/changelog.js +148 -0
- package/dist/release/check.d.ts +38 -0
- package/dist/release/check.js +150 -0
- package/dist/release/commands.d.ts +3 -0
- package/dist/release/commands.js +154 -0
- package/dist/release/committed-tree.d.ts +63 -0
- package/dist/release/committed-tree.js +118 -0
- package/dist/release/config.d.ts +3 -0
- package/dist/release/config.js +28 -0
- package/dist/release/gh-access.d.ts +14 -0
- package/dist/release/gh-access.js +45 -0
- package/dist/release/gh.d.ts +10 -0
- package/dist/release/gh.js +33 -0
- package/dist/release/git.d.ts +49 -0
- package/dist/release/git.js +111 -0
- package/dist/release/interrupt.d.ts +30 -0
- package/dist/release/interrupt.js +60 -0
- package/dist/release/json.d.ts +33 -0
- package/dist/release/json.js +81 -0
- package/dist/release/kit-check.d.ts +8 -0
- package/dist/release/kit-check.js +51 -0
- package/dist/release/manifest-rules.d.ts +23 -0
- package/dist/release/manifest-rules.js +255 -0
- package/dist/release/preflight.d.ts +10 -0
- package/dist/release/preflight.js +65 -0
- package/dist/release/problems.d.ts +24 -0
- package/dist/release/problems.js +11 -0
- package/dist/release/project-files.d.ts +14 -0
- package/dist/release/project-files.js +16 -0
- package/dist/release/publish-command.d.ts +21 -0
- package/dist/release/publish-command.js +83 -0
- package/dist/release/publish-git.d.ts +37 -0
- package/dist/release/publish-git.js +108 -0
- package/dist/release/publish-state.d.ts +29 -0
- package/dist/release/publish-state.js +70 -0
- package/dist/release/publish-verify.d.ts +41 -0
- package/dist/release/publish-verify.js +112 -0
- package/dist/release/publish-wait.d.ts +25 -0
- package/dist/release/publish-wait.js +56 -0
- package/dist/release/publish.d.ts +35 -0
- package/dist/release/publish.js +181 -0
- package/dist/release/release-assets.d.ts +39 -0
- package/dist/release/release-assets.js +68 -0
- package/dist/release/release.d.ts +37 -0
- package/dist/release/release.js +179 -0
- package/dist/release/remote.d.ts +12 -0
- package/dist/release/remote.js +15 -0
- package/dist/release/reproducible.d.ts +16 -0
- package/dist/release/reproducible.js +34 -0
- package/dist/release/run-tests.d.ts +5 -0
- package/dist/release/run-tests.js +17 -0
- package/dist/release/semver.d.ts +8 -0
- package/dist/release/semver.js +60 -0
- package/dist/release/version-rules.d.ts +28 -0
- package/dist/release/version-rules.js +63 -0
- package/dist/release/versions-json.d.ts +15 -0
- package/dist/release/versions-json.js +88 -0
- package/dist/release/workflow-run.d.ts +44 -0
- package/dist/release/workflow-run.js +71 -0
- package/dist/scanner/code-checks.d.ts +41 -0
- package/dist/scanner/code-checks.js +82 -0
- package/dist/scanner/commands.d.ts +3 -0
- package/dist/scanner/commands.js +43 -0
- package/dist/scanner/config.d.ts +7 -0
- package/dist/scanner/config.js +25 -0
- package/dist/scanner/css-check.d.ts +26 -0
- package/dist/scanner/css-check.js +63 -0
- package/dist/scanner/eslint-nesting.d.ts +16 -0
- package/dist/scanner/eslint-nesting.js +45 -0
- package/dist/scanner/findings.d.ts +23 -0
- package/dist/scanner/findings.js +21 -0
- package/dist/scanner/git-files.d.ts +16 -0
- package/dist/scanner/git-files.js +73 -0
- package/dist/scanner/lint.d.ts +47 -0
- package/dist/scanner/lint.js +163 -0
- package/dist/scanner/meta-checks.d.ts +8 -0
- package/dist/scanner/meta-checks.js +22 -0
- package/dist/scanner/outside-project.d.ts +19 -0
- package/dist/scanner/outside-project.js +20 -0
- package/dist/scanner/run.d.ts +19 -0
- package/dist/scanner/run.js +78 -0
- package/dist/scanner/scanner-config.d.ts +114 -0
- package/dist/scanner/scanner-config.js +207 -0
- package/dist/scanner/typescript-gate.d.ts +30 -0
- package/dist/scanner/typescript-gate.js +73 -0
- package/dist/vitest/build-config.d.ts +17 -0
- package/dist/vitest/build-config.js +106 -0
- package/dist/vitest/define-unit-config.d.ts +27 -0
- package/dist/vitest/define-unit-config.js +45 -0
- package/dist/vitest/dom/elements.d.ts +87 -0
- package/dist/vitest/dom/elements.js +291 -0
- package/dist/vitest/dom/index.d.ts +1 -0
- package/dist/vitest/dom/index.js +1 -0
- package/dist/vitest/dom/install.d.ts +8 -0
- package/dist/vitest/dom/install.js +261 -0
- package/dist/vitest/dom/setup.d.ts +1 -0
- package/dist/vitest/dom/setup.js +3 -0
- package/dist/vitest/index.d.ts +3 -0
- package/dist/vitest/index.js +2 -0
- package/dist/vitest/options.d.ts +92 -0
- package/dist/vitest/options.js +136 -0
- package/dist/vitest/peers.d.ts +10 -0
- package/dist/vitest/peers.js +51 -0
- package/dist/vitest/workspace-root.d.ts +7 -0
- package/dist/vitest/workspace-root.js +39 -0
- package/docs/build.md +232 -0
- package/docs/ci.md +182 -0
- package/docs/demo.md +364 -0
- package/docs/e2e.md +563 -0
- package/docs/release.md +374 -0
- package/docs/scanner.md +204 -0
- package/docs/unit.md +291 -0
- package/package.json +100 -4
- package/plugins/opdk/skills/audit/SKILL.md +81 -0
- package/plugins/opdk/skills/build/SKILL.md +79 -0
- package/plugins/opdk/skills/demo/SKILL.md +102 -0
- package/plugins/opdk/skills/e2e/SKILL.md +132 -0
- package/plugins/opdk/skills/release/SKILL.md +84 -0
- package/plugins/opdk/skills/scanner/SKILL.md +60 -0
- package/plugins/opdk/skills/unit/SKILL.md +90 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** The error for a settings modal that did not appear in the main window. */
|
|
2
|
+
export function settingsNotOpenedMessage(params) {
|
|
3
|
+
if (params.popoutConfigured || params.windows > 1) {
|
|
4
|
+
return ("Settings did not open in the main window: Obsidian opened it in a second window. " +
|
|
5
|
+
"The kit sets settingsPopoutWindow to false in the vault's .obsidian/app.json, but a value in the seed vault's app.json wins. " +
|
|
6
|
+
"Set it to false in the seed's .obsidian/app.json, or remove the key.");
|
|
7
|
+
}
|
|
8
|
+
return (`The settings modal did not appear in the main window within ${String(params.timeoutMs)} ms. ` +
|
|
9
|
+
"Is a dialog covering the workspace? Raise timeouts.helpers.ui if the window is slow.");
|
|
10
|
+
}
|
|
11
|
+
/** The error for a settings tab id that is not registered, with the ids that are. */
|
|
12
|
+
export function settingsTabNotFoundMessage(tab, registered, timeoutMs) {
|
|
13
|
+
const listed = registered.length > 0 ? registered.join(", ") : "none";
|
|
14
|
+
return (`No settings tab with id "${tab}" appeared within ${String(timeoutMs)} ms. Registered tabs: ${listed}. ` +
|
|
15
|
+
`Use the plugin id (the "id" in manifest.json) for a plugin's tab, or a core tab id such as "editor".`);
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long the page must stay free of DOM changes to count as settled. Longer than the 100 ms debounce that
|
|
3
|
+
* Obsidian's views and many plugins use for a refresh, so a refresh that a change schedules still lands inside the
|
|
4
|
+
* wait; short enough that a settled page costs a fraction of a second, which is what the fixed sleeps it replaces
|
|
5
|
+
* were guessing at.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_SETTLE_QUIET_MS = 150;
|
|
8
|
+
export interface SettleOptions {
|
|
9
|
+
/** Milliseconds without a DOM mutation (inside `root`) that count as quiet. Default 150. Must be below `timeouts.helpers.ui`. */
|
|
10
|
+
quietMs?: number;
|
|
11
|
+
/** CSS selector of the part of the page to watch for changes and images. Default: the whole `<body>` (the demo overlay lives outside it). */
|
|
12
|
+
root?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ResolvedSettle {
|
|
15
|
+
readonly quietMs: number;
|
|
16
|
+
/** Null watches the whole body. */
|
|
17
|
+
readonly root: string | null;
|
|
18
|
+
}
|
|
19
|
+
/** Checks the options of `settle()` against the budget it will wait under. */
|
|
20
|
+
export declare function resolveSettleOptions(options: SettleOptions, budgetMs: number): ResolvedSettle;
|
|
21
|
+
export declare function settleRootMissingMessage(root: string): string;
|
|
22
|
+
/** Why the wait ended without a quiet page. `reasons` come from the page (`unsettledReasons`). */
|
|
23
|
+
export declare function settleTimeoutMessage(params: {
|
|
24
|
+
budgetMs: number;
|
|
25
|
+
quietMs: number;
|
|
26
|
+
root: string | null;
|
|
27
|
+
reasons: readonly string[];
|
|
28
|
+
}): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long the page must stay free of DOM changes to count as settled. Longer than the 100 ms debounce that
|
|
3
|
+
* Obsidian's views and many plugins use for a refresh, so a refresh that a change schedules still lands inside the
|
|
4
|
+
* wait; short enough that a settled page costs a fraction of a second, which is what the fixed sleeps it replaces
|
|
5
|
+
* were guessing at.
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_SETTLE_QUIET_MS = 150;
|
|
8
|
+
/** Checks the options of `settle()` against the budget it will wait under. */
|
|
9
|
+
export function resolveSettleOptions(options, budgetMs) {
|
|
10
|
+
const quietMs = options.quietMs ?? DEFAULT_SETTLE_QUIET_MS;
|
|
11
|
+
if (!Number.isFinite(quietMs) || quietMs < 0) {
|
|
12
|
+
throw new RangeError(`settle(): quietMs must be a number of milliseconds from 0, got ${String(quietMs)}.`);
|
|
13
|
+
}
|
|
14
|
+
if (quietMs >= budgetMs) {
|
|
15
|
+
throw new RangeError(`settle(): quietMs (${String(quietMs)} ms) is not below the wait budget timeouts.helpers.ui (${String(budgetMs)} ms), so the page could never be quiet long enough. ` +
|
|
16
|
+
`Lower quietMs, or raise timeouts.helpers.ui.`);
|
|
17
|
+
}
|
|
18
|
+
if (options.root !== undefined && (typeof options.root !== "string" || options.root === "")) {
|
|
19
|
+
throw new TypeError(`settle(): root must be a non-empty CSS selector, got ${JSON.stringify(options.root)}.`);
|
|
20
|
+
}
|
|
21
|
+
return { quietMs, root: options.root ?? null };
|
|
22
|
+
}
|
|
23
|
+
export function settleRootMissingMessage(root) {
|
|
24
|
+
return `settle(): nothing matches root "${root}", so there is nothing to watch. Check the selector, and that the part of the page it names is on screen.`;
|
|
25
|
+
}
|
|
26
|
+
/** Why the wait ended without a quiet page. `reasons` come from the page (`unsettledReasons`). */
|
|
27
|
+
export function settleTimeoutMessage(params) {
|
|
28
|
+
const where = params.root === null ? "the page" : `"${params.root}"`;
|
|
29
|
+
const why = params.reasons.length > 0 ? params.reasons.join("; ") : "it settled just after the budget ran out";
|
|
30
|
+
return (`settle(): ${where} was not quiet for ${String(params.quietMs)} ms within ${String(params.budgetMs)} ms (${why}). ` +
|
|
31
|
+
`Raise timeouts.helpers.ui if the app is slow, pass root to watch only the part that matters (something elsewhere keeps changing), ` +
|
|
32
|
+
`or lower quietMs.`);
|
|
33
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import type { Locator } from "@playwright/test";
|
|
2
|
+
import type { CompositionChunking } from "./ime.js";
|
|
3
|
+
import type { FocusRingOptions, LayoutCheckName, LayoutCheckOptions, LayoutProblem, OverflowOptions, TouchTargetOptions } from "./layout.js";
|
|
4
|
+
import type { MobileOptions } from "./mobile.js";
|
|
5
|
+
import type { SettleOptions } from "./settle.js";
|
|
6
|
+
import type { ViewMode } from "./view-mode.js";
|
|
7
|
+
export type { CompositionChunking, FocusRingOptions, LayoutCheckName, LayoutCheckOptions, LayoutProblem, MobileOptions, OverflowOptions, SettleOptions, TouchTargetOptions, ViewMode };
|
|
8
|
+
/** A position in a note; both numbers start at 0. */
|
|
9
|
+
export interface EditorPosition {
|
|
10
|
+
line: number;
|
|
11
|
+
ch: number;
|
|
12
|
+
}
|
|
13
|
+
export interface EditorSelection {
|
|
14
|
+
/** The selected text; empty when the cursor is a caret. */
|
|
15
|
+
text: string;
|
|
16
|
+
/** Where the selection started. */
|
|
17
|
+
anchor: EditorPosition;
|
|
18
|
+
/** Where the cursor is: the moving end of the selection. */
|
|
19
|
+
head: EditorPosition;
|
|
20
|
+
}
|
|
21
|
+
/** The editor of the active note. All of it works on the real CodeMirror in the page. */
|
|
22
|
+
export interface EditorHelpers {
|
|
23
|
+
/**
|
|
24
|
+
* Types `text` key by key, so per-keystroke listeners (a snippet expander) fire; `fill()` would set the text in one
|
|
25
|
+
* mutation. Clicks the editor to focus it only when it is not focused yet: clicking again would move the cursor
|
|
26
|
+
* to the click point and break a typing sequence that depends on where the previous step left it.
|
|
27
|
+
*/
|
|
28
|
+
type(text: string): Promise<void>;
|
|
29
|
+
/** The whole document, read through `getValue()`: CodeMirror only keeps the visible lines in the DOM. */
|
|
30
|
+
text(): Promise<string>;
|
|
31
|
+
/** Selects everything with the keyboard, deletes it and waits until the document is empty. */
|
|
32
|
+
clear(): Promise<void>;
|
|
33
|
+
/** Focuses the editor and puts the cursor at `line`, `ch` (both from 0). A position past the end is clamped. */
|
|
34
|
+
setCursor(line: number, ch: number): Promise<void>;
|
|
35
|
+
selection(): Promise<EditorSelection>;
|
|
36
|
+
/**
|
|
37
|
+
* Enters `text` the way an input method does, through real composition events: `Input.imeSetComposition` while it
|
|
38
|
+
* grows, `Input.insertText` to commit it. With `chunking: "word"` (the default) each word is composed and
|
|
39
|
+
* committed with its trailing space; with `"character"` each character is its own composition. Inserts at the
|
|
40
|
+
* cursor, and fails when the document did not change.
|
|
41
|
+
*/
|
|
42
|
+
compose(text: string, options?: {
|
|
43
|
+
chunking?: CompositionChunking;
|
|
44
|
+
}): Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
export interface ThemeOptions {
|
|
47
|
+
mode: "light" | "dark";
|
|
48
|
+
/** The name of an installed community theme; `""` selects the default theme. Leave out to keep the current one. */
|
|
49
|
+
theme?: string;
|
|
50
|
+
}
|
|
51
|
+
/** The handle `replace()` returns. */
|
|
52
|
+
export interface FakeHandle {
|
|
53
|
+
/** The arguments of every call so far, oldest first. Works after `restore()` too. */
|
|
54
|
+
calls(): Promise<unknown[][]>;
|
|
55
|
+
/**
|
|
56
|
+
* Puts the original value back. Calling it twice is harmless. Fails when the window has been reloaded since
|
|
57
|
+
* `replace()` (`mobile()`, `desktop()`, a reload): the page forgot the replacement, and `calls()` fails the same way.
|
|
58
|
+
*/
|
|
59
|
+
restore(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
/** The function that replaces a property: what `replace()` installs, and what its factory returns. */
|
|
62
|
+
export type PageFunction = (...args: never[]) => unknown;
|
|
63
|
+
/**
|
|
64
|
+
* What a test hands to `replace()`: a factory that runs once in the page, gets the `arg` of `replace()` and returns
|
|
65
|
+
* the replacement. It is serialised as source text, so it cannot close over variables of the test (a reference to one
|
|
66
|
+
* fails in the page with a ReferenceError); everything it needs goes through `arg`.
|
|
67
|
+
*/
|
|
68
|
+
export type PageFactory<A> = (arg: A) => PageFunction;
|
|
69
|
+
/** The helpers of the `obsidian` fixture, bound to the test's window. */
|
|
70
|
+
export interface ObsidianHelpers {
|
|
71
|
+
/**
|
|
72
|
+
* Opens Settings in the main window and returns the content of the open tab. `tab` is a plugin id or a core tab id
|
|
73
|
+
* (for example `"editor"`); without it the modal opens on its default tab. A plugin may register its tab a moment
|
|
74
|
+
* after the window is up, so the helper polls `app.setting.pluginTabs` and `settingTabs` and fails, listing the
|
|
75
|
+
* registered ids, when the tab does not appear.
|
|
76
|
+
*/
|
|
77
|
+
openSettings(tab?: string): Promise<Locator>;
|
|
78
|
+
closeSettings(): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Runs a command by id (`pluginId:command-id`). Fails with the close matches when the id does not exist, and when
|
|
81
|
+
* the command declined to run (its `checkCallback` returned false: the command needs a state that is not there,
|
|
82
|
+
* such as an open note).
|
|
83
|
+
*/
|
|
84
|
+
runCommand(id: string): Promise<void>;
|
|
85
|
+
/** Opens the command palette (`Mod+P`) and returns its input. */
|
|
86
|
+
openCommandPalette(): Promise<Locator>;
|
|
87
|
+
/** Runs a command through the palette: types `name`, waits for the entry to be selected, presses Enter. */
|
|
88
|
+
runCommandFromPalette(name: string): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Opens a note by vault path in the active tab. With `mode` it also makes sure the note is shown that way, also
|
|
91
|
+
* when it is already open in the tab (where `openFile` alone keeps the mode it has).
|
|
92
|
+
*/
|
|
93
|
+
openFile(path: string, options?: {
|
|
94
|
+
mode?: ViewMode;
|
|
95
|
+
}): Promise<void>;
|
|
96
|
+
/** The editor of the active note. */
|
|
97
|
+
editor(): EditorHelpers;
|
|
98
|
+
/** Presses a key or combination. `Mod` is Cmd on macOS and Ctrl elsewhere: `press("Mod+P")`. */
|
|
99
|
+
press(keys: string): Promise<void>;
|
|
100
|
+
/** Switches light or dark, and optionally the community theme, and waits until the page carries the class. */
|
|
101
|
+
setTheme(options: ThemeOptions): Promise<void>;
|
|
102
|
+
/** Waits until every markdown file in the vault has its metadata cached. */
|
|
103
|
+
waitForMetadataCache(): Promise<void>;
|
|
104
|
+
/** Removes the notices on screen (such as "Indexing complete.") and returns how many there were. */
|
|
105
|
+
clearNotices(): Promise<number>;
|
|
106
|
+
/**
|
|
107
|
+
* Fails with the list of everything wrong in the layout of `options.root`: horizontal overflow, touch targets under
|
|
108
|
+
* 44 px (by default only in the mobile emulation) and, when asked, a Tab stop without a focus ring. The checks read
|
|
109
|
+
* the page as it is, so open and settle it first. Each can be turned off; see `LayoutCheckOptions`.
|
|
110
|
+
*/
|
|
111
|
+
checkLayout(options: LayoutCheckOptions): Promise<void>;
|
|
112
|
+
/** The same checks as `checkLayout()`, returned as a list (empty when all is well) instead of thrown, for `expect.soft` or a report. */
|
|
113
|
+
layoutProblems(options: LayoutCheckOptions): Promise<LayoutProblem[]>;
|
|
114
|
+
/**
|
|
115
|
+
* Hides the properties block of notes, a display setting; the notes are unchanged. It saves the setting to the
|
|
116
|
+
* vault's `.obsidian/app.json` at once (`vault.saveConfig()`), so a later settings save does not bring the block
|
|
117
|
+
* back. It throws on an Obsidian that has no `vault.setConfig` or `vault.saveConfig`, because it would not stick.
|
|
118
|
+
*/
|
|
119
|
+
hideProperties(): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Scrolls a reading view from top to bottom so blocks that draw when visible are drawn. It stays at the bottom
|
|
122
|
+
* and does not scroll back: the reading view drops the sections that leave the viewport, and scrolling back would
|
|
123
|
+
* drop the drawn blocks.
|
|
124
|
+
*/
|
|
125
|
+
scrollThrough(selector?: string): Promise<void>;
|
|
126
|
+
/** Shows a note in reading view (the active note when `path` is left out). */
|
|
127
|
+
readingView(path?: string): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Collapses the left and right side panels and waits until both are collapsed, so the note pane gets the whole
|
|
130
|
+
* window (a 390 px viewport is then 390 px of note, not of sidebars). It is a helper of its own, not an option of
|
|
131
|
+
* `readingView()`, because it is about the window layout and also serves source and live mode and screenshots.
|
|
132
|
+
* It then writes the workspace layout to disk, so a `reload()` right after it keeps the panels folded.
|
|
133
|
+
*/
|
|
134
|
+
collapseSidebars(): Promise<void>;
|
|
135
|
+
/** The inverse of `collapseSidebars()`: expands both side panels and waits until they are expanded. */
|
|
136
|
+
expandSidebars(): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Waits until the page stops changing: no DOM mutation for `quietMs` (default 150 ms), no font loading, and every
|
|
139
|
+
* image in the viewport loaded. Use it in place of a fixed sleep before a picture or an assertion that cannot say
|
|
140
|
+
* what it waits for. It sees changes that are happening, not ones only scheduled: a gap between two changes longer than
|
|
141
|
+
* `quietMs` counts as quiet. CSS animations and transitions are not DOM changes, so an endless one does not hold it up.
|
|
142
|
+
* `root` limits the watch to a part of the page (default: the `<body>`). The wait takes `timeouts.helpers.ui`;
|
|
143
|
+
* when it runs out the error names `settle()`, says what was still changing and how to raise the budget.
|
|
144
|
+
*/
|
|
145
|
+
settle(options?: SettleOptions): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Switches Obsidian to its mobile interface in a phone-sized viewport (390 x 844 CSS pixels at scale 2 unless
|
|
148
|
+
* given), waits until the window and every plugin have loaded again, and keeps the viewport phone-sized.
|
|
149
|
+
* Plugins with `isDesktopOnly: true` do not load on mobile, so the wait fails naming them.
|
|
150
|
+
*/
|
|
151
|
+
mobile(options?: MobileOptions): Promise<void>;
|
|
152
|
+
/** Undoes `mobile()`. */
|
|
153
|
+
desktop(): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Reloads the window with Obsidian's own "Reload app without saving" command (`app:reload`) and waits until the
|
|
156
|
+
* new page is up and every enabled plugin has loaded again, so the next line can use the editor or a plugin
|
|
157
|
+
* without racing the load. Everything installed in the old page is gone afterwards, the fakes of `replace()`
|
|
158
|
+
* included. Fails naming the command when this Obsidian has none, and with its own message when Obsidian refuses to run it. The command reloads without saving: wait until text typed just before it is written to the file.
|
|
159
|
+
*/
|
|
160
|
+
reload(): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Runs `fn(app, arg)` in the page, where `app` is `window.app`, and returns its result (a promise is awaited). The
|
|
163
|
+
* generics let a spec annotate `app` with Obsidian's own type without the kit depending on the `obsidian` package:
|
|
164
|
+
*
|
|
165
|
+
* import type { App } from "obsidian";
|
|
166
|
+
* const count = await obsidian.evaluate((app: App, folder: string) => app.vault.getFiles().filter((f) => f.path.startsWith(folder)).length, "Notes/");
|
|
167
|
+
*
|
|
168
|
+
* `fn` is serialised as source text and rebuilt in the page, so it cannot close over variables of the test or use
|
|
169
|
+
* imports; pass what it needs as `arg`. `arg` and the result must be serialisable (as for `page.evaluate`): a
|
|
170
|
+
* `TFile` or a DOM node does not survive, return the fields you need. An exception thrown by `fn` fails the test.
|
|
171
|
+
* Fails with its own message when `window.app` is missing or `fn` cannot be rebuilt (a method shorthand such as
|
|
172
|
+
* `{ run() {} }.run` is not a function expression).
|
|
173
|
+
*/
|
|
174
|
+
evaluate<R, App = unknown>(fn: (app: App) => R | Promise<R>): Promise<R>;
|
|
175
|
+
/** The same with an `arg`: a function that declares a second parameter must be given it. */
|
|
176
|
+
evaluate<R, A, App = unknown>(fn: (app: App, arg: A) => R | Promise<R>, arg: A): Promise<R>;
|
|
177
|
+
/**
|
|
178
|
+
* Replaces `pluginId`'s property at `propertyPath` (dotted for nested ones) on the live plugin instance. `impl` is
|
|
179
|
+
* a factory: it runs once in the page with `arg` and returns the function that becomes the property, so it can
|
|
180
|
+
* keep state between calls in its closure:
|
|
181
|
+
*
|
|
182
|
+
* await obsidian.replace("my-plugin", "client.fetch", (days: number) => async (path: string) => ({ days, path }), 7);
|
|
183
|
+
*
|
|
184
|
+
* `impl` is serialised as source text and rebuilt in the page, so it cannot close over variables of the test or
|
|
185
|
+
* use imports; pass what it needs as `arg`, which must be serialisable (as for `page.evaluate`). The handle records
|
|
186
|
+
* the arguments of each call to the replacement and puts the original back with `restore()`. Failure modes and
|
|
187
|
+
* delays belong in the function `impl` returns. Fails when the plugin is not loaded, the property does not exist
|
|
188
|
+
* or `impl` does not return a function.
|
|
189
|
+
*/
|
|
190
|
+
replace(pluginId: string, propertyPath: string, impl: PageFactory<undefined>): Promise<FakeHandle>;
|
|
191
|
+
/** The same with an `arg`: a factory that declares a parameter must be given it. */
|
|
192
|
+
replace<A>(pluginId: string, propertyPath: string, impl: PageFactory<A>, arg: A): Promise<FakeHandle>;
|
|
193
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a note is shown: `source` is the plain Markdown editor, `live` is Live Preview and `preview` is reading view.
|
|
3
|
+
* Obsidian stores source and live as the same `mode: "source"` and tells them apart by a `source` flag.
|
|
4
|
+
*/
|
|
5
|
+
export type ViewMode = "source" | "preview" | "live";
|
|
6
|
+
/** The `mode` and `source` fields of a markdown view's state. */
|
|
7
|
+
export interface ViewModeState {
|
|
8
|
+
readonly mode: "source" | "preview";
|
|
9
|
+
readonly source: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function viewModeState(mode: ViewMode): ViewModeState;
|
|
12
|
+
/** True when the view's actual state is the requested mode. Reading view ignores the `source` flag. */
|
|
13
|
+
export declare function viewModeMatches(actual: {
|
|
14
|
+
mode?: string;
|
|
15
|
+
source?: boolean;
|
|
16
|
+
} | null, wanted: ViewMode): boolean;
|
|
17
|
+
/** The error for a note that stays in the wrong mode after every attempt. */
|
|
18
|
+
export declare function viewModeFailureMessage(path: string, wanted: ViewMode, actual: {
|
|
19
|
+
mode?: string;
|
|
20
|
+
source?: boolean;
|
|
21
|
+
} | null, attempts: number): string;
|
|
22
|
+
/** A selector for the active tab's DOM in the wanted mode, to wait for the view to be drawn. */
|
|
23
|
+
export declare function viewModeSelector(mode: ViewMode): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function viewModeState(mode) {
|
|
2
|
+
switch (mode) {
|
|
3
|
+
case "preview":
|
|
4
|
+
return { mode: "preview", source: false };
|
|
5
|
+
case "source":
|
|
6
|
+
return { mode: "source", source: true };
|
|
7
|
+
case "live":
|
|
8
|
+
return { mode: "source", source: false };
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/** True when the view's actual state is the requested mode. Reading view ignores the `source` flag. */
|
|
12
|
+
export function viewModeMatches(actual, wanted) {
|
|
13
|
+
if (actual === null) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const target = viewModeState(wanted);
|
|
17
|
+
return actual.mode === target.mode && (target.mode === "preview" || actual.source === target.source);
|
|
18
|
+
}
|
|
19
|
+
/** The error for a note that stays in the wrong mode after every attempt. */
|
|
20
|
+
export function viewModeFailureMessage(path, wanted, actual, attempts) {
|
|
21
|
+
const seen = actual === null ? "no markdown view is active" : `mode ${String(actual.mode)}, source ${String(actual.source)}`;
|
|
22
|
+
return `${path} did not switch to ${wanted} mode after ${String(attempts)} attempts (${seen}). Is another leaf holding the note in a locked state?`;
|
|
23
|
+
}
|
|
24
|
+
/** A selector for the active tab's DOM in the wanted mode, to wait for the view to be drawn. */
|
|
25
|
+
export function viewModeSelector(mode) {
|
|
26
|
+
const leaf = ".workspace-leaf.mod-active";
|
|
27
|
+
switch (mode) {
|
|
28
|
+
case "preview":
|
|
29
|
+
return `${leaf} .markdown-reading-view`;
|
|
30
|
+
case "source":
|
|
31
|
+
return `${leaf} .markdown-source-view.mod-cm6:not(.is-live-preview)`;
|
|
32
|
+
case "live":
|
|
33
|
+
return `${leaf} .markdown-source-view.mod-cm6.is-live-preview`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { defineObsidianConfig } from "./config.js";
|
|
2
|
+
export { createObsidianTest } from "./create-test.js";
|
|
3
|
+
export type { ObsidianFixtures, ObsidianTest, ObsidianTestKit, ObsidianTestUse } from "./create-test.js";
|
|
4
|
+
export type { VaultSeed } from "./seed.js";
|
|
5
|
+
export type { HelperTimeouts, ObsidianTestOptions, PluginOption, TimeoutOptions, WindowOption } from "./options.js";
|
|
6
|
+
export { sweepLeftovers } from "./cleanup.js";
|
|
7
|
+
export type { SweepOptions, SweepResult } from "./cleanup.js";
|
|
8
|
+
export type { VaultHandle } from "./vault.js";
|
|
9
|
+
export type { AppWithInternals, CommandEntry, InternalPluginEntry, PluginInstance, SettingTabEntry, } from "./internals.js";
|
|
10
|
+
export type { CompositionChunking, EditorHelpers, EditorPosition, EditorSelection, FocusRingOptions, FakeHandle, LayoutCheckName, LayoutCheckOptions, LayoutProblem, MobileOptions, ObsidianHelpers, OverflowOptions, PageFactory, PageFunction, SettleOptions, ThemeOptions, TouchTargetOptions, ViewMode, } from "./helpers/types.js";
|
|
11
|
+
export type { CleanUiOptions, DemoHelpers, DemoPresetName, DemoRect, Film, FilmFrame, FilmKind, FilmOptions, ShotOptions, StillOptions, StillResult, TapOptions, ThemeMode, TypeSlowlyOptions, } from "./demo/types.js";
|
|
12
|
+
export type { DemoOptions } from "./demo/options.js";
|
|
13
|
+
export { parseFilmManifest } from "./demo/manifest.js";
|
|
14
|
+
export type { FilmManifest } from "./demo/manifest.js";
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Obsidian's `app` as the specs and the kit's page scripts reach it: the internal API that is not in the `obsidian`
|
|
3
|
+
* typings (`app.plugins.enablePlugin`, `app.setting`, `app.commands`, `vault.getConfig`, ...). The kit's TypeScript has
|
|
4
|
+
* no DOM and no `obsidian` types, so these are narrow structural types of what is used, not a copy of Obsidian's.
|
|
5
|
+
* Verified on Obsidian 1.14.5; a newer Obsidian may rename a member, and the code that reads it then fails with its
|
|
6
|
+
* own message. A member that only some versions have is optional here.
|
|
7
|
+
*/
|
|
8
|
+
/** A position in a note; both numbers start at 0. */
|
|
9
|
+
export interface PagePosition {
|
|
10
|
+
line: number;
|
|
11
|
+
ch: number;
|
|
12
|
+
}
|
|
13
|
+
/** The editor of a note (`app.workspace.activeEditor.editor`). */
|
|
14
|
+
export interface PageEditor {
|
|
15
|
+
getValue(): string;
|
|
16
|
+
getSelection(): string;
|
|
17
|
+
listSelections(): {
|
|
18
|
+
anchor: PagePosition;
|
|
19
|
+
head: PagePosition;
|
|
20
|
+
}[];
|
|
21
|
+
setCursor(position: PagePosition): void;
|
|
22
|
+
focus(): void;
|
|
23
|
+
/** The CodeMirror 6 view behind the editor. */
|
|
24
|
+
cm?: {
|
|
25
|
+
composing?: boolean;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface PageView {
|
|
29
|
+
getState?(): Record<string, unknown>;
|
|
30
|
+
setState?(state: Record<string, unknown>, result: {
|
|
31
|
+
history: boolean;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export interface PageLeaf {
|
|
35
|
+
view: PageView;
|
|
36
|
+
openFile(file: unknown, state: Record<string, unknown>): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/** One of the two side panels of the workspace (`app.workspace.leftSplit` and `rightSplit`). */
|
|
39
|
+
export interface PageSidebar {
|
|
40
|
+
collapsed?: boolean;
|
|
41
|
+
collapse?(): void;
|
|
42
|
+
expand?(): void;
|
|
43
|
+
}
|
|
44
|
+
/** A plugin instance from `app.plugins.plugins`. What a plugin adds to itself is `unknown` until the spec narrows it. */
|
|
45
|
+
export interface PluginInstance {
|
|
46
|
+
manifest: {
|
|
47
|
+
id: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
version?: string;
|
|
50
|
+
};
|
|
51
|
+
[member: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
/** An entry of `app.commands.commands`. */
|
|
54
|
+
export interface CommandEntry {
|
|
55
|
+
id: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
checkCallback?: (checking: boolean) => unknown;
|
|
58
|
+
}
|
|
59
|
+
/** A settings tab registered with `app.setting`. */
|
|
60
|
+
export interface SettingTabEntry {
|
|
61
|
+
id: string;
|
|
62
|
+
}
|
|
63
|
+
/** An entry of `app.internalPlugins.plugins`: a core plugin such as `daily-notes` or `templates`. */
|
|
64
|
+
export interface InternalPluginEntry {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
instance?: Record<string, unknown>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The `app` object of the Obsidian window (`globalThis.app`). Use it as the type of the first parameter of
|
|
70
|
+
* `obsidian.evaluate((app: AppWithInternals) => ...)`, or in a `win.evaluate` that reads `globalThis`.
|
|
71
|
+
* `P` is the type of a plugin instance: `AppWithInternals<PluginInstance & { settings: MySettings }>` types
|
|
72
|
+
* `app.plugins.plugins[id].settings` without a cast.
|
|
73
|
+
*/
|
|
74
|
+
export interface AppWithInternals<P extends PluginInstance = PluginInstance> {
|
|
75
|
+
plugins: {
|
|
76
|
+
/** Loaded community plugins by id. A plugin appears here before its `onload()` has finished. */
|
|
77
|
+
plugins: Record<string, P | undefined>;
|
|
78
|
+
/** The ids of the plugins that are switched on in the vault. */
|
|
79
|
+
enabledPlugins: Set<string>;
|
|
80
|
+
/** The id of the plugin whose `onload()` is running now, or `null`. */
|
|
81
|
+
loadingPluginId: string | null;
|
|
82
|
+
enablePlugin(id: string): Promise<unknown>;
|
|
83
|
+
disablePlugin(id: string): Promise<unknown>;
|
|
84
|
+
};
|
|
85
|
+
setting: {
|
|
86
|
+
open(): void;
|
|
87
|
+
close(): void;
|
|
88
|
+
openTabById(id: string): void;
|
|
89
|
+
/** The tab that is shown; absent while the modal is closed. */
|
|
90
|
+
activeTab?: SettingTabEntry | null;
|
|
91
|
+
pluginTabs: SettingTabEntry[];
|
|
92
|
+
settingTabs: SettingTabEntry[];
|
|
93
|
+
};
|
|
94
|
+
commands: {
|
|
95
|
+
commands: Record<string, CommandEntry | undefined>;
|
|
96
|
+
/** False when no command has this id, or when its `checkCallback` is not satisfied. */
|
|
97
|
+
executeCommandById(id: string): boolean;
|
|
98
|
+
};
|
|
99
|
+
internalPlugins: {
|
|
100
|
+
plugins: Record<string, InternalPluginEntry | undefined>;
|
|
101
|
+
};
|
|
102
|
+
metadataCache: {
|
|
103
|
+
getFileCache(file: unknown): unknown;
|
|
104
|
+
/** How many files are still queued for indexing; 0 once the cache is complete. */
|
|
105
|
+
inProgressTaskCount?: number;
|
|
106
|
+
};
|
|
107
|
+
vault: {
|
|
108
|
+
/** The settings of `.obsidian/app.json`, by key. `undefined` for a key that was never set. */
|
|
109
|
+
getConfig(key: string): unknown;
|
|
110
|
+
/** Changes the setting in memory; `saveConfig()` writes it to disk. */
|
|
111
|
+
setConfig(key: string, value: unknown): void;
|
|
112
|
+
saveConfig(): Promise<void>;
|
|
113
|
+
getMarkdownFiles(): {
|
|
114
|
+
path: string;
|
|
115
|
+
}[];
|
|
116
|
+
getAbstractFileByPath(path: string): {
|
|
117
|
+
path: string;
|
|
118
|
+
extension?: unknown;
|
|
119
|
+
} | null;
|
|
120
|
+
/** The e2e runs on the desktop app, where `basePath` is the absolute path of the vault. */
|
|
121
|
+
adapter: {
|
|
122
|
+
basePath: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
workspace: {
|
|
126
|
+
layoutReady: boolean;
|
|
127
|
+
getLeaf(newLeaf: boolean): PageLeaf;
|
|
128
|
+
setActiveLeaf(leaf: PageLeaf, options: {
|
|
129
|
+
focus: boolean;
|
|
130
|
+
}): void;
|
|
131
|
+
getActiveFile(): {
|
|
132
|
+
path: string;
|
|
133
|
+
} | null;
|
|
134
|
+
activeEditor: {
|
|
135
|
+
editor?: PageEditor;
|
|
136
|
+
} | null;
|
|
137
|
+
trigger(name: string): void;
|
|
138
|
+
saveLayout(): Promise<void>;
|
|
139
|
+
leftSplit: PageSidebar;
|
|
140
|
+
rightSplit: PageSidebar;
|
|
141
|
+
};
|
|
142
|
+
customCss: {
|
|
143
|
+
themes: Record<string, unknown>;
|
|
144
|
+
setTheme(name: string): void;
|
|
145
|
+
};
|
|
146
|
+
changeTheme(name: string): void;
|
|
147
|
+
emulateMobile(on: boolean): void;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* What a page script can count on: `window.app` may not exist yet, and any member may be missing in another Obsidian
|
|
151
|
+
* version, so every level is optional. For the kit's own scripts; a spec uses `AppWithInternals`.
|
|
152
|
+
*/
|
|
153
|
+
export type PartialApp = {
|
|
154
|
+
[Key in keyof AppWithInternals]?: AppWithInternals[Key] extends (...args: never[]) => unknown ? AppWithInternals[Key] : Partial<AppWithInternals[Key]>;
|
|
155
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Obsidian's `app` as the specs and the kit's page scripts reach it: the internal API that is not in the `obsidian`
|
|
3
|
+
* typings (`app.plugins.enablePlugin`, `app.setting`, `app.commands`, `vault.getConfig`, ...). The kit's TypeScript has
|
|
4
|
+
* no DOM and no `obsidian` types, so these are narrow structural types of what is used, not a copy of Obsidian's.
|
|
5
|
+
* Verified on Obsidian 1.14.5; a newer Obsidian may rename a member, and the code that reads it then fails with its
|
|
6
|
+
* own message. A member that only some versions have is optional here.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Where the macOS installer puts Obsidian's bootstrap asar. */
|
|
2
|
+
export declare const DEFAULT_MAC_APP_ASAR = "/Applications/Obsidian.app/Contents/Resources/app.asar";
|
|
3
|
+
export interface ObsidianPathInputs {
|
|
4
|
+
/** `obsidianPath` option. */
|
|
5
|
+
readonly option?: string | undefined;
|
|
6
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
7
|
+
readonly platform: NodeJS.Platform;
|
|
8
|
+
readonly exists: (file: string) => boolean;
|
|
9
|
+
/** Resolves a relative `option`/`OBSIDIAN_PATH` against this directory. */
|
|
10
|
+
readonly cwd: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Finds Obsidian's `app.asar`. Order: `OBSIDIAN_PATH`, the `obsidianPath` option, the macOS default. The first
|
|
14
|
+
* source that is set wins and must exist; there is no silent fall-through to the next one, because a typo in an
|
|
15
|
+
* explicit path would otherwise test a different Obsidian than the one you asked for.
|
|
16
|
+
*/
|
|
17
|
+
export declare function findObsidianAsar(inputs: ObsidianPathInputs): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
/** Where the macOS installer puts Obsidian's bootstrap asar. */
|
|
3
|
+
export const DEFAULT_MAC_APP_ASAR = "/Applications/Obsidian.app/Contents/Resources/app.asar";
|
|
4
|
+
/**
|
|
5
|
+
* Finds Obsidian's `app.asar`. Order: `OBSIDIAN_PATH`, the `obsidianPath` option, the macOS default. The first
|
|
6
|
+
* source that is set wins and must exist; there is no silent fall-through to the next one, because a typo in an
|
|
7
|
+
* explicit path would otherwise test a different Obsidian than the one you asked for.
|
|
8
|
+
*/
|
|
9
|
+
export function findObsidianAsar(inputs) {
|
|
10
|
+
const fromEnv = inputs.env.OBSIDIAN_PATH;
|
|
11
|
+
const explicit = fromEnv !== undefined && fromEnv !== "" ? { source: "OBSIDIAN_PATH", value: fromEnv } : undefined;
|
|
12
|
+
const fromOption = inputs.option !== undefined && inputs.option !== "" ? { source: "obsidianPath", value: inputs.option } : undefined;
|
|
13
|
+
const chosen = explicit ?? fromOption;
|
|
14
|
+
if (chosen !== undefined) {
|
|
15
|
+
const file = path.resolve(inputs.cwd, chosen.value);
|
|
16
|
+
if (!inputs.exists(file)) {
|
|
17
|
+
throw new Error(`${chosen.source} points to ${file}, which does not exist. ` +
|
|
18
|
+
`Set it to Obsidian's app.asar (on macOS: ${DEFAULT_MAC_APP_ASAR}).`);
|
|
19
|
+
}
|
|
20
|
+
return file;
|
|
21
|
+
}
|
|
22
|
+
if (inputs.platform !== "darwin") {
|
|
23
|
+
throw new Error(`No default Obsidian location for platform "${inputs.platform}". ` +
|
|
24
|
+
`Set OBSIDIAN_PATH or the obsidianPath option to Obsidian's app.asar.`);
|
|
25
|
+
}
|
|
26
|
+
if (!inputs.exists(DEFAULT_MAC_APP_ASAR)) {
|
|
27
|
+
throw new Error(`Obsidian is not installed at ${DEFAULT_MAC_APP_ASAR}. ` +
|
|
28
|
+
`Install Obsidian, or set OBSIDIAN_PATH or the obsidianPath option to its app.asar.`);
|
|
29
|
+
}
|
|
30
|
+
return DEFAULT_MAC_APP_ASAR;
|
|
31
|
+
}
|