@hienlh/ppm 0.24.0 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.24.1] - 2026-11-12
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **An HTML page that saves settings in `localStorage` no longer opens blank in Preview.** The preview now gives it a storage that lasts until the page is reloaded.
|
|
8
|
+
|
|
3
9
|
## [0.24.0] - 2026-11-10
|
|
4
10
|
|
|
5
11
|
### Added
|
|
@@ -83,4 +83,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
|
|
|
83
83
|
- Third-party extensions (inspect via `ppm ext list`).
|
|
84
84
|
- The Claude Agent SDK internals (separate skill).
|
|
85
85
|
|
|
86
|
-
<!-- Generated for PPM v0.24.
|
|
86
|
+
<!-- Generated for PPM v0.24.1 at build time. Re-run `ppm export skill --install` to refresh. -->
|
|
@@ -788,4 +788,4 @@ Authenticate with `?token=<token>` (see Authentication).
|
|
|
788
788
|
- `/ws/android`
|
|
789
789
|
- `/ws/project/<project>/<type>/<id>` — `<type>`: `terminal`, `chat`, `group`, `lsp` (for `chat`, `<id>` is the session id)
|
|
790
790
|
|
|
791
|
-
<!-- Generated from src/server/routes/ for PPM v0.24.
|
|
791
|
+
<!-- Generated from src/server/routes/ for PPM v0.24.1 -->
|
package/package.json
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { BridgeApi } from "./bridge-core.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gives the HTML file preview a `localStorage` and `sessionStorage` that work.
|
|
5
|
+
*
|
|
6
|
+
* The preview's iframe is `sandbox="allow-scripts"` with no `allow-same-origin`, so the page
|
|
7
|
+
* has an opaque origin and merely *reading* `window.localStorage` throws a SecurityError.
|
|
8
|
+
* A page that remembers a setting at the top of its script (a docs site keeping the reader's
|
|
9
|
+
* language, a theme toggle) therefore died on its first line and rendered blank. The bridge
|
|
10
|
+
* runs first in `<head>`, so when the real store is refused it puts an in-memory one in its
|
|
11
|
+
* place: the page runs, and what it saves lasts until the frame reloads. Where the real
|
|
12
|
+
* store is reachable nothing is replaced.
|
|
13
|
+
*
|
|
14
|
+
* Both method calls and property access (`localStorage.theme = "dark"`) are honoured, as
|
|
15
|
+
* they are on a real `Storage`. Shipped as source like the core, so it may only use what it
|
|
16
|
+
* is handed in `ppm`.
|
|
17
|
+
*/
|
|
18
|
+
export function installMemoryStorage(ppm: BridgeApi): void {
|
|
19
|
+
const win = ppm.win as unknown as Record<string, unknown>;
|
|
20
|
+
|
|
21
|
+
function memoryStorage(): Storage {
|
|
22
|
+
const items = new Map<string, string>();
|
|
23
|
+
const methods: Record<string, unknown> = {
|
|
24
|
+
getItem: (key: unknown) => (items.has(String(key)) ? items.get(String(key)) : null),
|
|
25
|
+
setItem: (key: unknown, value: unknown) => { items.set(String(key), String(value)); },
|
|
26
|
+
removeItem: (key: unknown) => { items.delete(String(key)); },
|
|
27
|
+
clear: () => { items.clear(); },
|
|
28
|
+
key: (index: number) => { const keys = Array.from(items.keys()); return index >= 0 && index < keys.length ? keys[index] : null; },
|
|
29
|
+
};
|
|
30
|
+
return new Proxy({} as Record<string, unknown>, {
|
|
31
|
+
get(_target, prop) {
|
|
32
|
+
if (prop === "length") return items.size;
|
|
33
|
+
if (typeof prop !== "string") return undefined;
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(methods, prop)) return methods[prop];
|
|
35
|
+
return items.has(prop) ? items.get(prop) : undefined;
|
|
36
|
+
},
|
|
37
|
+
set(_target, prop, value) {
|
|
38
|
+
if (typeof prop === "string") items.set(prop, String(value));
|
|
39
|
+
return true;
|
|
40
|
+
},
|
|
41
|
+
has(_target, prop) {
|
|
42
|
+
return typeof prop === "string" && (items.has(prop) || Object.prototype.hasOwnProperty.call(methods, prop) || prop === "length");
|
|
43
|
+
},
|
|
44
|
+
deleteProperty(_target, prop) {
|
|
45
|
+
if (typeof prop === "string") items.delete(prop);
|
|
46
|
+
return true;
|
|
47
|
+
},
|
|
48
|
+
ownKeys() {
|
|
49
|
+
return Array.from(items.keys());
|
|
50
|
+
},
|
|
51
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
52
|
+
if (typeof prop !== "string" || !items.has(prop)) return undefined;
|
|
53
|
+
return { value: items.get(prop), writable: true, enumerable: true, configurable: true };
|
|
54
|
+
},
|
|
55
|
+
}) as unknown as Storage;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
for (const name of ["localStorage", "sessionStorage"]) {
|
|
59
|
+
let refused = false;
|
|
60
|
+
try {
|
|
61
|
+
void win[name];
|
|
62
|
+
} catch (e) {
|
|
63
|
+
refused = true;
|
|
64
|
+
}
|
|
65
|
+
if (!refused) continue;
|
|
66
|
+
try {
|
|
67
|
+
Object.defineProperty(win, name, { value: memoryStorage(), configurable: true, enumerable: true, writable: false });
|
|
68
|
+
} catch (e) {
|
|
69
|
+
// Nothing better to offer: the page meets the browser's own refusal, reported as usual.
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assembleBridge, assertInlineScript, bridgeTag } from "./bridge-script.ts";
|
|
2
2
|
import { installLayoutCheck } from "./bridge-layout-check.ts";
|
|
3
3
|
import { installLinkOut } from "./bridge-link-out.ts";
|
|
4
|
+
import { installMemoryStorage } from "./bridge-memory-storage.ts";
|
|
4
5
|
import { checkLabel, gridImplicitFindings } from "./bridge-layout-grid.ts";
|
|
5
6
|
import { boxFindings } from "./bridge-layout-boxes.ts";
|
|
6
7
|
import { captureScreenshot } from "./bridge-layout-screenshot.ts";
|
|
@@ -9,11 +10,12 @@ import { captureScreenshot } from "./bridge-layout-screenshot.ts";
|
|
|
9
10
|
* The bridge an HTML file preview gets: the design bridge's core (script errors, failed
|
|
10
11
|
* loads and CSP violations reported to the parent, then `ready`) and the self-check that
|
|
11
12
|
* measures the page and draws a screenshot, plus the link hand-off that lets a link leaving
|
|
12
|
-
* the page open in a PPM or browser tab (the sandbox would otherwise swallow it)
|
|
13
|
+
* the page open in a PPM or browser tab (the sandbox would otherwise swallow it), plus an in-memory web storage
|
|
14
|
+
* for a page the sandbox would otherwise kill by refusing `localStorage`. Nothing
|
|
13
15
|
* that selects or edits: the preview shows a file as it is, and the self-check is what lets
|
|
14
16
|
* the AI's `open_preview` tool report how the page rendered.
|
|
15
17
|
*/
|
|
16
|
-
export const HTML_PREVIEW_BRIDGE_JS = assembleBridge([installLayoutCheck, installLinkOut], {
|
|
18
|
+
export const HTML_PREVIEW_BRIDGE_JS = assembleBridge([installMemoryStorage, installLayoutCheck, installLinkOut], {
|
|
17
19
|
checkLabel, gridImplicitFindings, boxFindings, captureScreenshot,
|
|
18
20
|
});
|
|
19
21
|
|