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,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Functions Playwright serializes and runs inside Obsidian, for the `demo` fixture. Like `../helpers/page-scripts.ts`,
|
|
3
|
+
* each one must be self-contained: only its source text crosses into the page. The kit's TypeScript has no DOM types,
|
|
4
|
+
* hence the small interfaces below.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The look of the overlays and of the freeze, in one place so the tests can check what the page gets. No transition
|
|
8
|
+
* or animation on the overlays: a CDP capture does not wait for them (a tap dot caught mid-shrink showed in a spike
|
|
9
|
+
* frame), so every state change must land at once.
|
|
10
|
+
*/
|
|
11
|
+
export const OVERLAY_CSS = [
|
|
12
|
+
// The caption sits one level below the pointers: a cursor or a tap dot over the bar stays visible.
|
|
13
|
+
"#opdk-cursor,#opdk-tap,#opdk-caption{position:fixed;display:none;pointer-events:none;z-index:2147483646;transition:none;animation:none}",
|
|
14
|
+
"#opdk-cursor,#opdk-tap{z-index:2147483647}",
|
|
15
|
+
"#opdk-cursor{left:0;top:0;width:22px;height:22px;transform-origin:0 0;filter:drop-shadow(1px 1px 2px rgba(0,0,0,.35))}",
|
|
16
|
+
"#opdk-cursor.opdk-down{transform:scale(.85)}",
|
|
17
|
+
"#opdk-tap{width:44px;height:44px;margin:-22px 0 0 -22px;border-radius:50%;box-sizing:border-box;background:rgba(128,128,140,.38);border:1.5px solid rgba(128,128,140,.55)}",
|
|
18
|
+
"#opdk-tap.opdk-down{width:36px;height:36px;margin:-18px 0 0 -18px}",
|
|
19
|
+
"#opdk-caption{left:50%;bottom:24px;transform:translateX(-50%);max-width:min(720px,80vw);padding:10px 22px;border-radius:10px;background:rgba(15,15,18,.82);color:#fff;font:500 17px/1.4 system-ui,-apple-system,sans-serif;text-align:center}",
|
|
20
|
+
"html.opdk-hide-status-bar .status-bar{display:none !important}",
|
|
21
|
+
"html.opdk-hide-tab-headers .workspace-tab-header-container{display:none !important}",
|
|
22
|
+
"html.opdk-shooting *,html.opdk-shooting *::before,html.opdk-shooting *::after{transition:none !important;caret-color:transparent !important}",
|
|
23
|
+
"html.opdk-shooting .cm-cursorLayer{visibility:hidden !important}",
|
|
24
|
+
].join("\n");
|
|
25
|
+
/** The arrow of the demo cursor. */
|
|
26
|
+
export const CURSOR_SVG = '<svg width="22" height="22" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">' +
|
|
27
|
+
'<path d="M5 3L19 12L12 13L9 20L5 3Z" fill="#ffffff" stroke="#1a1a1a" stroke-width="1.4" stroke-linejoin="round"/></svg>';
|
|
28
|
+
/**
|
|
29
|
+
* Init script of the Obsidian window (`context.addInitScript`), also run once in the page that is already up. It
|
|
30
|
+
* draws the cursor, the tap dot and the caption bar into `<html>`, outside Obsidian's `<body>`, above every modal. The
|
|
31
|
+
* state (pointer position and kind, caption, hidden UI parts) lives in `sessionStorage`, so a document that replaces
|
|
32
|
+
* this one (`reload()`, `mobile()`, `desktop()`) restores it. Captions go in through `textContent`: markup shows literally.
|
|
33
|
+
* Idempotent. The look comes in as the argument because only the function's own source text reaches the page.
|
|
34
|
+
*/
|
|
35
|
+
export function installOverlay(assets) {
|
|
36
|
+
const globals = globalThis;
|
|
37
|
+
if (globals.__opdkDemo !== undefined || globals.document === undefined) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const doc = globals.document;
|
|
41
|
+
const KEY = "opdk-demo-state";
|
|
42
|
+
const read = () => {
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(globals.sessionStorage?.getItem(KEY) ?? "{}");
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
let state = read();
|
|
51
|
+
const save = (patch) => {
|
|
52
|
+
state = { ...state, ...patch };
|
|
53
|
+
try {
|
|
54
|
+
globals.sessionStorage?.setItem(KEY, JSON.stringify(state));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Storage refused (a private window, a quota): the overlays still work for this document, they just do not survive a reload.
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
let cursor = null;
|
|
61
|
+
let tap = null;
|
|
62
|
+
let caption = null;
|
|
63
|
+
const render = () => {
|
|
64
|
+
if (cursor === null || tap === null || caption === null) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const placed = state.x !== undefined && state.y !== undefined && state.hidden !== true;
|
|
68
|
+
const x = `${String(state.x ?? 0)}px`;
|
|
69
|
+
const y = `${String(state.y ?? 0)}px`;
|
|
70
|
+
cursor.style.left = tap.style.left = x;
|
|
71
|
+
cursor.style.top = tap.style.top = y;
|
|
72
|
+
cursor.style.display = placed && state.kind !== "tap" && state.cursorOff !== true ? "block" : "none";
|
|
73
|
+
tap.style.display = placed && state.kind === "tap" ? "block" : "none";
|
|
74
|
+
caption.textContent = state.caption ?? "";
|
|
75
|
+
caption.style.display = state.caption !== undefined && state.caption !== "" ? "block" : "none";
|
|
76
|
+
const root = doc.documentElement;
|
|
77
|
+
root?.classList.toggle("opdk-hide-status-bar", state.hideStatusBar === true);
|
|
78
|
+
root?.classList.toggle("opdk-hide-tab-headers", state.hideTabHeaders === true);
|
|
79
|
+
};
|
|
80
|
+
const mount = () => {
|
|
81
|
+
const root = doc.documentElement;
|
|
82
|
+
if (root === null || doc.getElementById("opdk-cursor") !== null) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const style = doc.createElement("style");
|
|
86
|
+
style.id = "opdk-overlay-style";
|
|
87
|
+
style.textContent = assets.cssText;
|
|
88
|
+
cursor = doc.createElement("div");
|
|
89
|
+
cursor.id = "opdk-cursor";
|
|
90
|
+
cursor.innerHTML = assets.cursorSvg;
|
|
91
|
+
tap = doc.createElement("div");
|
|
92
|
+
tap.id = "opdk-tap";
|
|
93
|
+
caption = doc.createElement("div");
|
|
94
|
+
caption.id = "opdk-caption";
|
|
95
|
+
// Caption first: among equal layers the later element is on top, and the pointers must be.
|
|
96
|
+
root.append(style, caption, cursor, tap);
|
|
97
|
+
render();
|
|
98
|
+
};
|
|
99
|
+
globals.addEventListener?.("mousemove", (event) => {
|
|
100
|
+
save({ x: event.clientX, y: event.clientY, hidden: false });
|
|
101
|
+
render();
|
|
102
|
+
}, true);
|
|
103
|
+
globals.addEventListener?.("mousedown", () => {
|
|
104
|
+
cursor?.classList.add("opdk-down");
|
|
105
|
+
tap?.classList.add("opdk-down");
|
|
106
|
+
}, true);
|
|
107
|
+
globals.addEventListener?.("mouseup", () => {
|
|
108
|
+
cursor?.classList.remove("opdk-down");
|
|
109
|
+
tap?.classList.remove("opdk-down");
|
|
110
|
+
}, true);
|
|
111
|
+
globals.__opdkDemo = {
|
|
112
|
+
caption: (text) => {
|
|
113
|
+
save({ caption: text ?? "" });
|
|
114
|
+
render();
|
|
115
|
+
},
|
|
116
|
+
pointer: (kind) => {
|
|
117
|
+
save({ kind });
|
|
118
|
+
render();
|
|
119
|
+
},
|
|
120
|
+
hidePointer: () => {
|
|
121
|
+
save({ hidden: true });
|
|
122
|
+
render();
|
|
123
|
+
},
|
|
124
|
+
cursorEnabled: (enabled) => {
|
|
125
|
+
save({ cursorOff: !enabled });
|
|
126
|
+
render();
|
|
127
|
+
},
|
|
128
|
+
clean: (hide) => {
|
|
129
|
+
save({ hideStatusBar: hide.statusBar, hideTabHeaders: hide.tabHeaders });
|
|
130
|
+
render();
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
if (doc.readyState === "loading") {
|
|
134
|
+
doc.addEventListener("DOMContentLoaded", mount, { once: true });
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
mount();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/** Runs one overlay command in the page. False when the overlay is not there (the init script did not run in this document). */
|
|
141
|
+
export function runOverlay(call) {
|
|
142
|
+
const api = globalThis.__opdkDemo;
|
|
143
|
+
if (api === undefined) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
switch (call.method) {
|
|
147
|
+
case "caption":
|
|
148
|
+
api.caption(call.arg);
|
|
149
|
+
break;
|
|
150
|
+
case "pointer":
|
|
151
|
+
api.pointer(call.arg);
|
|
152
|
+
break;
|
|
153
|
+
case "hidePointer":
|
|
154
|
+
api.hidePointer();
|
|
155
|
+
break;
|
|
156
|
+
case "cursorEnabled":
|
|
157
|
+
api.cursorEnabled(call.arg);
|
|
158
|
+
break;
|
|
159
|
+
case "clean":
|
|
160
|
+
api.clean(call.arg);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Makes the page hold still for one capture. A CDP screenshot does not wait for anything, so: the class
|
|
167
|
+
* `opdk-shooting` ends CSS transitions at once and hides the caret; running animations jump to their end (an endless
|
|
168
|
+
* one cannot finish, so it is paused and `releaseShot()` plays it again; a finite one that finished stays finished);
|
|
169
|
+
* two frames are awaited so the result is drawn, with a timer as the fallback for a window that draws no frames.
|
|
170
|
+
* `releaseShot()` removes the class.
|
|
171
|
+
*/
|
|
172
|
+
export async function freezeForShot() {
|
|
173
|
+
const globals = globalThis;
|
|
174
|
+
const doc = globals.document;
|
|
175
|
+
doc?.documentElement?.classList.add("opdk-shooting");
|
|
176
|
+
const result = { finished: 0, paused: 0 };
|
|
177
|
+
const paused = (globals.__opdkPaused ??= []);
|
|
178
|
+
for (const animation of doc?.getAnimations?.() ?? []) {
|
|
179
|
+
if (animation.effect?.getComputedTiming().endTime === Infinity) {
|
|
180
|
+
// One the page paused itself stays paused after the shot.
|
|
181
|
+
if (animation.playState === "running") {
|
|
182
|
+
animation.pause();
|
|
183
|
+
paused.push(animation);
|
|
184
|
+
result.paused += 1;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
animation.finish();
|
|
189
|
+
result.finished += 1;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
await new Promise((resolve) => {
|
|
193
|
+
let done = false;
|
|
194
|
+
const settle = () => {
|
|
195
|
+
if (!done) {
|
|
196
|
+
done = true;
|
|
197
|
+
resolve();
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
globals.requestAnimationFrame?.(() => globals.requestAnimationFrame?.(settle));
|
|
201
|
+
globals.setTimeout?.(settle, 100);
|
|
202
|
+
});
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
/** Ends the freeze: removes the class and plays the endless animations that `freezeForShot()` paused. */
|
|
206
|
+
export function releaseShot() {
|
|
207
|
+
const globals = globalThis;
|
|
208
|
+
globals.document?.documentElement?.classList.remove("opdk-shooting");
|
|
209
|
+
const paused = globals.__opdkPaused ?? [];
|
|
210
|
+
globals.__opdkPaused = [];
|
|
211
|
+
for (const animation of paused) {
|
|
212
|
+
animation.play();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** Whether the focused element takes typed text: a text input, a textarea or a contenteditable (Obsidian's editor is one). */
|
|
216
|
+
export function hasEditableFocus() {
|
|
217
|
+
const element = globalThis.document?.activeElement;
|
|
218
|
+
if (element === null || element === undefined) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
if (element.isContentEditable === true || element.tagName === "TEXTAREA") {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
const notText = ["button", "checkbox", "color", "file", "hidden", "image", "radio", "range", "reset", "submit"];
|
|
225
|
+
return element.tagName === "INPUT" && !notText.includes(element.type ?? "text");
|
|
226
|
+
}
|
|
227
|
+
export function readViewport() {
|
|
228
|
+
const globals = globalThis;
|
|
229
|
+
return { width: globals.innerWidth ?? 0, height: globals.innerHeight ?? 0, scale: globals.devicePixelRatio ?? 0 };
|
|
230
|
+
}
|
|
231
|
+
export function hasViewport(want) {
|
|
232
|
+
const globals = globalThis;
|
|
233
|
+
return globals.innerWidth === want.width && globals.innerHeight === want.height && globals.devicePixelRatio === want.scale;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The parts of the UI that Obsidian itself can hide. True means shown. The settings are saved at once: Obsidian writes
|
|
237
|
+
* them on a delay, and `reload()` reloads without saving, so a reload right after would bring the old values back
|
|
238
|
+
* (found in the kit's live spec). Returns false when this Obsidian cannot be configured.
|
|
239
|
+
*/
|
|
240
|
+
export async function applyObsidianUi(show) {
|
|
241
|
+
const vault = globalThis.app?.vault;
|
|
242
|
+
if (vault?.setConfig === undefined) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
for (const [key, value] of Object.entries(show)) {
|
|
246
|
+
vault.setConfig(key, value);
|
|
247
|
+
}
|
|
248
|
+
await vault.saveConfig?.();
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Size } from "./clip.js";
|
|
2
|
+
/** Width and height in pixels, from the IHDR chunk. Fails on anything that is not a PNG. */
|
|
3
|
+
export declare function readPngSize(png: Buffer): Size;
|
|
4
|
+
/**
|
|
5
|
+
* The pixel-density guard: the frame must be exactly the CSS size times the scale. A frame that is half the expected
|
|
6
|
+
* size means the capture ran at the display's density instead of the requested one, and would encode into a blurry film.
|
|
7
|
+
*/
|
|
8
|
+
export declare function assertFrameSize(png: Buffer, expected: Size, scale: number, what: string): Size;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
2
|
+
/** Signature (8), IHDR length (4), "IHDR" (4), width (4), height (4). */
|
|
3
|
+
const HEADER_BYTES = 24;
|
|
4
|
+
/** Width and height in pixels, from the IHDR chunk. Fails on anything that is not a PNG. */
|
|
5
|
+
export function readPngSize(png) {
|
|
6
|
+
if (png.length < HEADER_BYTES || !png.subarray(0, SIGNATURE.length).equals(SIGNATURE) || png.toString("latin1", 12, 16) !== "IHDR") {
|
|
7
|
+
throw new Error("The capture is not a PNG (no PNG signature and IHDR chunk). The page may have closed during the screenshot.");
|
|
8
|
+
}
|
|
9
|
+
return { width: png.readUInt32BE(16), height: png.readUInt32BE(20) };
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The pixel-density guard: the frame must be exactly the CSS size times the scale. A frame that is half the expected
|
|
13
|
+
* size means the capture ran at the display's density instead of the requested one, and would encode into a blurry film.
|
|
14
|
+
*/
|
|
15
|
+
export function assertFrameSize(png, expected, scale, what) {
|
|
16
|
+
const actual = readPngSize(png);
|
|
17
|
+
if (actual.width !== expected.width || actual.height !== expected.height) {
|
|
18
|
+
throw new Error(`${what}: the frame is ${String(actual.width)} x ${String(actual.height)} px, expected ${String(expected.width)} x ${String(expected.height)} ` +
|
|
19
|
+
`(the shot area at scale ${String(scale)}). The capture did not run at the requested pixel density; ` +
|
|
20
|
+
`check that nothing else resets the window's device metrics (a second CDP session, for one).`);
|
|
21
|
+
}
|
|
22
|
+
return actual;
|
|
23
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** The picture size a destination wants, in pixels, and the pixel density it is shot at. */
|
|
2
|
+
export interface DemoPreset {
|
|
3
|
+
readonly width: number;
|
|
4
|
+
readonly height: number;
|
|
5
|
+
/** Device pixels per CSS pixel. The window is `width / scale` x `height / scale` CSS pixels. */
|
|
6
|
+
readonly scale: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Destinations a still can be shot for. The PNG has exactly these pixels:
|
|
10
|
+
* - `readme`: 1000 px wide, the widest a README picture is shown (GitHub scales anything larger down).
|
|
11
|
+
* - `listing-desktop`: 1200 x 800, the community plugin listing, desktop.
|
|
12
|
+
* - `listing-phone`: 900 x 1600, the listing, phone (a 450 x 800 window at twice the density).
|
|
13
|
+
* - `social`: 1200 x 630, a link preview card.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEMO_PRESETS: {
|
|
16
|
+
readonly readme: {
|
|
17
|
+
readonly width: 1000;
|
|
18
|
+
readonly height: 640;
|
|
19
|
+
readonly scale: 1;
|
|
20
|
+
};
|
|
21
|
+
readonly "listing-desktop": {
|
|
22
|
+
readonly width: 1200;
|
|
23
|
+
readonly height: 800;
|
|
24
|
+
readonly scale: 1;
|
|
25
|
+
};
|
|
26
|
+
readonly "listing-phone": {
|
|
27
|
+
readonly width: 900;
|
|
28
|
+
readonly height: 1600;
|
|
29
|
+
readonly scale: 2;
|
|
30
|
+
};
|
|
31
|
+
readonly social: {
|
|
32
|
+
readonly width: 1200;
|
|
33
|
+
readonly height: 630;
|
|
34
|
+
readonly scale: 1;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export type DemoPresetName = keyof typeof DEMO_PRESETS;
|
|
38
|
+
/** The preset with the CSS size of the window that produces its pixels. */
|
|
39
|
+
export interface PresetViewport extends DemoPreset {
|
|
40
|
+
readonly cssWidth: number;
|
|
41
|
+
readonly cssHeight: number;
|
|
42
|
+
}
|
|
43
|
+
export declare function presetViewport(name: string): PresetViewport;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Destinations a still can be shot for. The PNG has exactly these pixels:
|
|
3
|
+
* - `readme`: 1000 px wide, the widest a README picture is shown (GitHub scales anything larger down).
|
|
4
|
+
* - `listing-desktop`: 1200 x 800, the community plugin listing, desktop.
|
|
5
|
+
* - `listing-phone`: 900 x 1600, the listing, phone (a 450 x 800 window at twice the density).
|
|
6
|
+
* - `social`: 1200 x 630, a link preview card.
|
|
7
|
+
*/
|
|
8
|
+
export const DEMO_PRESETS = {
|
|
9
|
+
readme: { width: 1000, height: 640, scale: 1 },
|
|
10
|
+
"listing-desktop": { width: 1200, height: 800, scale: 1 },
|
|
11
|
+
"listing-phone": { width: 900, height: 1600, scale: 2 },
|
|
12
|
+
social: { width: 1200, height: 630, scale: 1 },
|
|
13
|
+
};
|
|
14
|
+
export function presetViewport(name) {
|
|
15
|
+
if (!Object.hasOwn(DEMO_PRESETS, name)) {
|
|
16
|
+
throw new Error(`Unknown still preset ${JSON.stringify(name)}. Known presets: ${Object.keys(DEMO_PRESETS).join(", ")}.`);
|
|
17
|
+
}
|
|
18
|
+
const preset = DEMO_PRESETS[name];
|
|
19
|
+
return { ...preset, cssWidth: preset.width / preset.scale, cssHeight: preset.height / preset.scale };
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Where the seed vault of a run came from: the `seedVault` option, or the `OPDK_E2E_VAULT` env override. */
|
|
2
|
+
export type SeedVaultSource = "option" | "env";
|
|
3
|
+
/**
|
|
4
|
+
* Pictures and films are published. A run aimed at someone's real vault through `OPDK_E2E_VAULT`, or at a seed vault
|
|
5
|
+
* outside the plugin's own folder, would photograph private notes, so capture refuses unless the spec says it is
|
|
6
|
+
* meant (`allowForeignVault: true`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function assertCaptureAllowed(params: {
|
|
9
|
+
source: SeedVaultSource;
|
|
10
|
+
seedVault: string;
|
|
11
|
+
/** The plugin folder the run started in; the seed vault is expected inside it. */
|
|
12
|
+
cwd: string;
|
|
13
|
+
allowForeignVault: boolean | undefined;
|
|
14
|
+
action: string;
|
|
15
|
+
}): void;
|
|
16
|
+
/** The configured selectors plus the ones of this call, each once. */
|
|
17
|
+
export declare function mergeSelectors(configured: readonly string[], extra: readonly string[] | undefined): string[];
|
|
18
|
+
export declare function forbiddenMessage(selector: string, action: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
function isInside(parent, child) {
|
|
3
|
+
const relative = path.relative(parent, child);
|
|
4
|
+
return relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Pictures and films are published. A run aimed at someone's real vault through `OPDK_E2E_VAULT`, or at a seed vault
|
|
8
|
+
* outside the plugin's own folder, would photograph private notes, so capture refuses unless the spec says it is
|
|
9
|
+
* meant (`allowForeignVault: true`).
|
|
10
|
+
*/
|
|
11
|
+
export function assertCaptureAllowed(params) {
|
|
12
|
+
if (params.source === "env" && params.allowForeignVault !== true) {
|
|
13
|
+
throw new Error(`${params.action} refused: OPDK_E2E_VAULT points this run at ${params.seedVault}, not at the plugin's own seed vault, ` +
|
|
14
|
+
`and a picture or film of someone's real notes could be published by mistake. ` +
|
|
15
|
+
`Unset OPDK_E2E_VAULT, or pass allowForeignVault: true if you mean to shoot that vault.`);
|
|
16
|
+
}
|
|
17
|
+
if (params.allowForeignVault !== true && !isInside(params.cwd, params.seedVault)) {
|
|
18
|
+
throw new Error(`${params.action} refused: the seed vault ${params.seedVault} lies outside the plugin folder ${params.cwd}, ` +
|
|
19
|
+
`and a picture or film of a vault that is not the plugin's own could show private notes. ` +
|
|
20
|
+
`Move the seed vault into the plugin folder, or pass allowForeignVault: true if you mean to shoot that vault.`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** The configured selectors plus the ones of this call, each once. */
|
|
24
|
+
export function mergeSelectors(configured, extra) {
|
|
25
|
+
return [...new Set([...configured, ...(extra ?? [])])];
|
|
26
|
+
}
|
|
27
|
+
export function forbiddenMessage(selector, action) {
|
|
28
|
+
return (`${action} refused: an element matching the forbidden selector ${JSON.stringify(selector)} is visible, so it would be in the picture. ` +
|
|
29
|
+
`Close or hide it before the shot, or remove the selector from demo.forbiddenSelectors if it is allowed here.`);
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Folder under the output folder with one file per still that says how `opdk demo` treats it (`<name>.json`). */
|
|
2
|
+
export declare const STILL_OPTIONS_DIR: string;
|
|
3
|
+
/** What the spec asked for a still beyond its pixels: where `opdk demo` puts it, if anywhere. */
|
|
4
|
+
export interface StillPublishing {
|
|
5
|
+
/** False: the PNG stays in `<outDir>/stills` for another tool to read, and `opdk demo` does not copy it. */
|
|
6
|
+
readonly publish: boolean;
|
|
7
|
+
/** The key of `demo.outputs` in `opdk.config.mjs` whose folder gets the PNG instead of the default one. */
|
|
8
|
+
readonly out?: string;
|
|
9
|
+
}
|
|
10
|
+
/** The treatment of a still whose spec says nothing, and of one recorded before these options existed. */
|
|
11
|
+
export declare const DEFAULT_PUBLISHING: StillPublishing;
|
|
12
|
+
/** Checks the `publish` and `out` options of `demo.still()`. Throws naming the still. */
|
|
13
|
+
export declare function resolveStillPublishing(options: {
|
|
14
|
+
publish?: unknown;
|
|
15
|
+
out?: unknown;
|
|
16
|
+
}, what: string): StillPublishing;
|
|
17
|
+
export declare function serializeStillPublishing(value: StillPublishing): string;
|
|
18
|
+
/** Reads the file the fixture wrote; throws a message that says what is wrong with it. */
|
|
19
|
+
export declare function parseStillPublishing(text: string, file: string): StillPublishing;
|
|
20
|
+
export declare function writeStillPublishing(outDir: string, name: string, value: StillPublishing): void;
|
|
21
|
+
/** The treatment recorded for a still; the default when there is no file (a still from an earlier kit version). */
|
|
22
|
+
export declare function readStillPublishing(outDir: string, name: string): StillPublishing;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { assertName } from "./names.js";
|
|
4
|
+
/** Folder under the output folder with one file per still that says how `opdk demo` treats it (`<name>.json`). */
|
|
5
|
+
export const STILL_OPTIONS_DIR = path.join(".owners", "still-options");
|
|
6
|
+
/** The treatment of a still whose spec says nothing, and of one recorded before these options existed. */
|
|
7
|
+
export const DEFAULT_PUBLISHING = { publish: true };
|
|
8
|
+
/** Checks the `publish` and `out` options of `demo.still()`. Throws naming the still. */
|
|
9
|
+
export function resolveStillPublishing(options, what) {
|
|
10
|
+
const { publish, out } = options;
|
|
11
|
+
if (publish !== undefined && typeof publish !== "boolean") {
|
|
12
|
+
throw new Error(`${what}: publish must be true (copy it to the output folder) or false (keep it in the stills folder), got ${JSON.stringify(publish)}.`);
|
|
13
|
+
}
|
|
14
|
+
if (out === undefined) {
|
|
15
|
+
return { publish: publish ?? true };
|
|
16
|
+
}
|
|
17
|
+
if (typeof out !== "string") {
|
|
18
|
+
throw new Error(`${what}: out must be the name of a folder in demo.outputs of opdk.config.mjs, got ${JSON.stringify(out)}.`);
|
|
19
|
+
}
|
|
20
|
+
if (publish === false) {
|
|
21
|
+
throw new Error(`${what}: out has no effect with publish: false, because the still is not copied anywhere. Remove one of them.`);
|
|
22
|
+
}
|
|
23
|
+
return { publish: true, out: assertName(out, `${what}: out`) };
|
|
24
|
+
}
|
|
25
|
+
export function serializeStillPublishing(value) {
|
|
26
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
27
|
+
}
|
|
28
|
+
/** Reads the file the fixture wrote; throws a message that says what is wrong with it. */
|
|
29
|
+
export function parseStillPublishing(text, file) {
|
|
30
|
+
let value;
|
|
31
|
+
try {
|
|
32
|
+
value = JSON.parse(text);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw new Error(`${file} is not valid JSON (${error instanceof Error ? error.message : String(error)}). Record the still again.`, { cause: error });
|
|
36
|
+
}
|
|
37
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
38
|
+
throw new Error(`${file} must be an object { publish, out? }. Record the still again.`);
|
|
39
|
+
}
|
|
40
|
+
const { publish, out } = value;
|
|
41
|
+
if (typeof publish !== "boolean" || (out !== undefined && typeof out !== "string")) {
|
|
42
|
+
throw new Error(`${file} must be { "publish": boolean, "out"?: string }. Record the still again.`);
|
|
43
|
+
}
|
|
44
|
+
if (!publish && out !== undefined) {
|
|
45
|
+
throw new Error(`${file} has "out" with "publish": false, which the fixture never writes. Record the still again.`);
|
|
46
|
+
}
|
|
47
|
+
return out === undefined ? { publish } : { publish, out };
|
|
48
|
+
}
|
|
49
|
+
export function writeStillPublishing(outDir, name, value) {
|
|
50
|
+
const dir = path.join(outDir, STILL_OPTIONS_DIR);
|
|
51
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
52
|
+
fs.writeFileSync(path.join(dir, `${name}.json`), serializeStillPublishing(value));
|
|
53
|
+
}
|
|
54
|
+
/** The treatment recorded for a still; the default when there is no file (a still from an earlier kit version). */
|
|
55
|
+
export function readStillPublishing(outDir, name) {
|
|
56
|
+
const file = path.join(outDir, STILL_OPTIONS_DIR, `${name}.json`);
|
|
57
|
+
let text;
|
|
58
|
+
try {
|
|
59
|
+
text = fs.readFileSync(file, "utf8");
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
63
|
+
return DEFAULT_PUBLISHING;
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
return parseStillPublishing(text, file);
|
|
68
|
+
}
|