Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

chore: sync main and preserve combined Find regression coverage

Tw934dd82afbfc9c
diff --cc AGENTS.md
index 87bafdd7,d72c3218..bffad250
--- a/AGENTS.md
+++ b/AGENTS.md
@@@ -90,11 -90,10 +90,12 @@@ Proactive latent-bug sweeps use `.agent
## Current Risk Areas
+- Injected CSS uses `src-tauri/src/inject/styles.js`: preserve DOM stylesheet order on ordinary pages; use constructable sheets only when CSP blocks the style element. `replaceSync` silently drops `@import`, so keep import-bearing CSS on its original DOM path, including escaped/case-insensitive at-keywords. Strict CSP plus imports remains unsupported. Run `node tests/browser/style-injection.mjs` with an installed Playwright runtime; mock CSSStyleSheet tests do not validate CSP or cascade behavior.
+
- CLI options are user-facing and must stay synchronized across `bin/helpers/cli-program.ts`, `bin/types.ts`, `bin/defaults.ts`, `bin/helpers/merge.ts`, generated `dist/cli.js`, `schema/pake.schema.json`, and `docs/cli-usage*.md`. Schema-to-CLI sync is enforced by `tests/unit/config-file.test.ts`; the rest is manual discipline.
- The `--json` machine contract is public API for agents: stdout carries exactly one JSON result (nothing else may write to stdout in machine mode), and the exit codes (0/2/3/4/1) plus error codes (`INVALID_INPUT`, `ENV_MISSING`, `BUILD_FAILED`, `UNEXPECTED`, plus `NETWORK` which is reserved and currently unused, since network failures report under the phase code) must stay stable. `logger.warn` feeds the JSON `warnings` array, so warn is for real warnings only, not status lines. Owners: `bin/utils/output.ts`, `bin/cli.ts`, `bin/utils/shell.ts`.
- - Local file/directory packaging stages user content into the package's own `dist/` (moving it to `dist_bak` and restoring only `cli.js`). A crashed local-input run can strand `dev.js` and test fixtures in `dist_bak`; `restoreLocalTree()` heals that at the top of every CLI action, so it needs no manual cleanup. Owners: `stageLocalTree` and `restoreLocalTree` in `bin/helpers/merge.ts`.
+ - Packaging CLI builds use a private temporary workspace for configs, injected code, icons, entitlements, and local content. The installed package is the template, not a writable staging area. Complete installed Tauri dependencies are reused without reinstalling; incomplete dependencies are installed only in the private workspace. Owners: `bin/utils/build-workspace.ts`, `bin/utils/dir.ts`, and `bin/helpers/merge.ts`. `restoreLocalTree()` at CLI startup remains only to recover a `dist_bak` left by the published 3.15.7 implementation. The repository's `bin/dev.ts` intentionally retains source-based Tauri development/watch behavior.
+ - Shared Cargo caches are locked until artifact copying finishes; Cargo's own compilation lock alone does not protect that interval. Never reclaim a stale PID lock with read-then-delete, which can delete a new owner's lock. An abandoned lock fails with a recovery hint rather than risking concurrent artifacts. Cancellation and failed subprocesses must stop the compiler tree before releasing the lock; preserve the workspace and lock if termination cannot be confirmed. Ordinary success and failure discard the workspace, with cleanup warnings included before the JSON result. Verify with `node tests/integration/build-workspace.mjs` on macOS and the cross-platform workspace unit tests.
- New user-visible CLI surface (a new flag, alias, subcommand, or extra help variant) needs a stated justification before implementation: name the user problem and why an existing flag, config key, or default cannot cover it, then get maintainer sign-off. Prefer quieter defaults over new options; never split help output into parallel variants.
- Window/runtime options with platform-sensitive behavior include `--incognito`, `--new-window`, `--min-width`, `--min-height`, `--maximize`, multi-window behavior, notification click handling, and Linux/Wayland WebKit compositing defaults.
- `--incognito` intentionally trades persistence for clean private sessions; be careful around login, cookies, local storage, and WeChat-style WebView detection.
diff --cc tests/unit/find-shortcuts.test.js
index 0b2ac2d7,b14c1c5b..0e3a2b4c
--- a/tests/unit/find-shortcuts.test.js
+++ b/tests/unit/find-shortcuts.test.js
@@@ -176,10 -174,17 +181,21 @@@ function loadFindScript(
path.join(process.cwd(), "src-tauri/src/inject/find.js"),
"utf-8",
);
+ const styleSource = fs.readFileSync(
+ path.join(process.cwd(), "src-tauri/src/inject/styles.js"),
+ "utf-8",
+ );
+ const observers = new Set();
+ const notifyMutation = (record) => {
+ for (const observer of observers) {
+ observer.records.push(record);
+ queueMicrotask(() => {
+ if (observer.records.length) {
+ observer.callback(observer.records.splice(0));
+ }
+ });
+ }
+ };
const context = {
console,
setTimeout,
@@@ -193,20 -198,29 +209,35 @@@
},
window: {
pakeConfig: { enable_find: enabled },
+ CSSStyleSheet: class CSSStyleSheet {
+ replaceSync(css) {
+ this.cssText = css;
+ }
+ },
},
- document: createDocument(nodes),
+ document: createDocument(nodes, notifyMutation),
};
+ if (observeMutations) {
+ context.MutationObserver = class {
+ constructor(callback) {
+ this.callback = callback;
+ this.records = [];
+ }
+ observe() {
+ observers.add(this);
+ }
+ disconnect() {
+ observers.delete(this);
+ this.records = [];
+ }
+ };
+ }
context.window.NodeFilter = context.NodeFilter;
context.window.navigator = context.navigator;
+ runInNewContext(styleSource, context);
runInNewContext(source, context);
- return context;
+ return { ...context, notifyMutation };
}
describe("Find injection", () => {