@phnx-labs/artifacts-cli 0.4.3 → 0.4.5
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 +18 -1
- package/README.md +32 -14
- package/dist/lib/creator-cover.d.ts +1 -1
- package/dist/lib/creator-cover.js +9 -7
- package/dist/lib/creator-cover.js.map +1 -1
- package/dist/lib/metadata-menu.d.ts +34 -3
- package/dist/lib/metadata-menu.js +103 -26
- package/dist/lib/metadata-menu.js.map +1 -1
- package/dist/lib/reader-theme.d.ts +2 -0
- package/dist/lib/reader-theme.js +36 -0
- package/dist/lib/reader-theme.js.map +1 -0
- package/dist/lib/render.js +55 -57
- package/dist/lib/render.js.map +1 -1
- package/dist/lib/templates.d.ts +5 -0
- package/dist/lib/templates.js +33 -1
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/validate.js +4 -2
- package/dist/lib/validate.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- **Simpler reader chrome (PHNX-3978).** Created/Updated timestamps replace
|
|
6
|
+
revision codes and open timestamp-led history. Device and session are direct
|
|
7
|
+
copy controls with complete recorded context, including a known local-registry
|
|
8
|
+
address. The header shows the artifact kind; custom header text moves into
|
|
9
|
+
Details. The cover has one logo/model attribution, without bottom freshness
|
|
10
|
+
or a repeated product name. System theme follows live OS changes by default;
|
|
11
|
+
reader overrides persist and can cycle back to System. Tab separators use `|`.
|
|
12
|
+
|
|
5
13
|
- **Copyable origin and automatic local revisions (PHNX-3978).** A compact
|
|
6
14
|
upper-right menu shows device/session and copies full values, combined context,
|
|
7
15
|
agent CLI version, and platform. Scaffolds retain the full session UUID. Missing
|
|
@@ -10,7 +18,16 @@
|
|
|
10
18
|
local snapshots automatically, deduplicate unchanged renders, and expose revision
|
|
11
19
|
history with non-destructive open commands. Previous content never travels with
|
|
12
20
|
a shared page; concurrent saves serialize and failed renders preserve prior state.
|
|
13
|
-
|
|
21
|
+
- **The cover no longer headlines the agent.** The creating harness's mark is the
|
|
22
|
+
cover artwork; the product and model name ("Codex GPT-5") moved from a 36px
|
|
23
|
+
block in the cover's top row to the creator line under the summary, at the
|
|
24
|
+
same size as the human and the freshness stamps. The cover's top row keeps
|
|
25
|
+
only the linked project.
|
|
26
|
+
- **The human's picture in the creator line.** A new `avatar` frontmatter field
|
|
27
|
+
(https only) renders the author's profile picture beside their name, with
|
|
28
|
+
`referrerpolicy="no-referrer"`. `artifacts new` pre-fills it from
|
|
29
|
+
`AGENTS_ACTOR_AVATAR`, the Phoenix ID profile picture agents-cli stamps into
|
|
30
|
+
the launch env; anonymized (published) scaffolds leave it empty.
|
|
14
31
|
- **Creator covers, project identity, and freshness (PHNX-3978).** Artifacts now
|
|
15
32
|
have a large creator logo, a built-in brand palette and background motif, and
|
|
16
33
|
a matching favicon. Known marks are bundled; unknown harnesses use a neutral
|
package/README.md
CHANGED
|
@@ -40,14 +40,19 @@ artifacts check plan.md # validate without rendering
|
|
|
40
40
|
|
|
41
41
|
## Origin and revision history
|
|
42
42
|
|
|
43
|
-
The
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
version, and
|
|
47
|
-
|
|
43
|
+
The header shows the document type, a clickable Created/Updated timestamp,
|
|
44
|
+
and compact device/session copy controls. Clicking the device copies its full
|
|
45
|
+
recorded context: canonical name, available address, OS/architecture, agent CLI
|
|
46
|
+
version, and session. Clicking the short session copies the complete UUID.
|
|
47
|
+
There is no origin dropdown or visible table of missing fields. Clipboard failure
|
|
48
|
+
exposes selectable text instead of claiming success. Resume remains in Details.
|
|
48
49
|
|
|
49
50
|
New scaffolds preserve `sessionId`, `harnessVersion`, `hostPlatform`, and
|
|
50
|
-
`hostArch
|
|
51
|
+
`hostArch`, and `hostAddress` when this device has an exact-match Tailscale entry
|
|
52
|
+
in the local Agents device registry. No DNS lookup or guessed address is used.
|
|
53
|
+
Anonymized defaults omit addresses as well as session/device identity; explicit
|
|
54
|
+
metadata remains embedded in the HTML, so do not publish private addresses.
|
|
55
|
+
The version comes from `AGENTS_RUN_VERSION`, not whichever binary is
|
|
51
56
|
currently installed. Any already-recorded origin owns the entire origin tuple:
|
|
52
57
|
missing fields remain unrecorded rather than being borrowed from today's renderer.
|
|
53
58
|
Legacy short-only sessions are labeled honestly; the full UUID cannot be invented.
|
|
@@ -55,15 +60,16 @@ Legacy short-only sessions are labeled honestly; the full UUID cannot be invente
|
|
|
55
60
|
Every successful Markdown compile to an output path participates in local history:
|
|
56
61
|
|
|
57
62
|
```bash
|
|
58
|
-
artifacts render plan.md # first saved
|
|
59
|
-
artifacts render plan.md # unchanged render:
|
|
63
|
+
artifacts render plan.md # first saved version: Created just now
|
|
64
|
+
artifacts render plan.md # unchanged render: no new version
|
|
60
65
|
artifacts history plan.md # list local snapshots
|
|
61
66
|
artifacts history plan.md --open 1 # view saved HTML; never overwrite source
|
|
62
67
|
artifacts history plan.md --json
|
|
63
68
|
```
|
|
64
69
|
|
|
65
70
|
Changing source content, embedded assets, design, or visible metadata creates the
|
|
66
|
-
next revision. Merely touching the source mtime does not.
|
|
71
|
+
next revision. Merely touching the source mtime does not. Click the timestamp for
|
|
72
|
+
History; entries use Created/Updated dates, not internal revision codes. It shows
|
|
67
73
|
the latest ten saved entries and copies an open command using the artifact ID,
|
|
68
74
|
so an agent does not need to keep track of a source path or maintain a version field.
|
|
69
75
|
Run that command on the rendering device. Complete history remains available via
|
|
@@ -88,10 +94,21 @@ Provenance (project, repository, branch, harness, agent, human, host, session, d
|
|
|
88
94
|
|
|
89
95
|
Additional frontmatter carries into the artifact header:
|
|
90
96
|
|
|
91
|
-
The built-in cover shows the creating harness's logo
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
the
|
|
97
|
+
The built-in cover shows the creating harness's logo as its background artwork,
|
|
98
|
+
a brand-colored palette, a linked project, and the title. The creator line has
|
|
99
|
+
one small logo and the recorded model, next to the human. The product name stays
|
|
100
|
+
in the logo's accessible label and tooltip, not repeated in visible text. Missing
|
|
101
|
+
models are not guessed. Freshness lives in the header; exact source dates and
|
|
102
|
+
any authored custom `header` text remain under Details. The same mark
|
|
103
|
+
becomes the tab's favicon, embedded in the HTML for offline use. Known harness
|
|
104
|
+
aliases resolve to the same mark; unknown harnesses use a neutral cover and
|
|
105
|
+
terminal glyph.
|
|
106
|
+
|
|
107
|
+
When `avatar` is an https URL the creator line shows it as the human's picture
|
|
108
|
+
beside their name (with no referrer sent to the image host). `artifacts new`
|
|
109
|
+
pre-fills it from `AGENTS_ACTOR_AVATAR`, which agents-cli sets from the Phoenix
|
|
110
|
+
ID session signed in on the device; a published artifact is scaffolded without
|
|
111
|
+
it, like the other anonymized provenance.
|
|
95
112
|
|
|
96
113
|
When `project` exactly matches a registered `agents projects` ID, the page uses
|
|
97
114
|
its `linear.name` as the readable label and its `linear.url` when available.
|
|
@@ -126,6 +143,7 @@ status: implementing
|
|
|
126
143
|
harness: codex
|
|
127
144
|
agent: gpt-5
|
|
128
145
|
human: Ada Lovelace
|
|
146
|
+
avatar: https://lh3.googleusercontent.com/a/example=s96-c # optional; https only. The human's picture in the creator line.
|
|
129
147
|
host: yosemite-s1
|
|
130
148
|
session: fcd64597
|
|
131
149
|
date: "2026-08-03" # date-only, absolute
|
|
@@ -178,7 +196,7 @@ answers to an underscore spelling (`_estimate`, `_decompile`, `_pdf`).
|
|
|
178
196
|
|
|
179
197
|
`DESIGN.md` is the single style source. Artifact-specific fields live in each Markdown file's frontmatter.
|
|
180
198
|
|
|
181
|
-
Define both palettes and layout defaults once.
|
|
199
|
+
Define both palettes and layout defaults once. The reader always starts with the operating-system preference, regardless of `theme.default`. The theme button cycles through explicit light/dark overrides and back to System; only reader overrides persist. System mode follows live OS changes. `artifact.printTheme` still selects the static palette used for PDF and print output. A legacy `colors` block is migrated to `themes.dark` with a warning so existing brand colors are not discarded.
|
|
182
200
|
|
|
183
201
|
```yaml
|
|
184
202
|
theme:
|
|
@@ -4,4 +4,4 @@ export declare function coverClass(harness: string): string;
|
|
|
4
4
|
export declare function creatorMark(harness: string): string;
|
|
5
5
|
export declare function coverArtwork(harness: string): string;
|
|
6
6
|
export declare function creatorFavicon(harness: string): string;
|
|
7
|
-
export declare const COVER_CSS = "\n.hero.creator-cover{--cover-bg:#edf0ec;--cover-fg:#23332b;--cover-muted:#566c5e;--cover-accent:#629b77;--cover-glow:#c9dccd;position:relative;isolation:isolate;overflow:hidden;margin-top:24px;padding:32px 36px 26px;border:1px solid color-mix(in srgb,var(--cover-accent) 22%,var(--cover-bg));border-radius:18px;background:radial-gradient(ellipse at 100% 0%,var(--cover-glow),transparent 65%),var(--cover-bg);color:var(--cover-fg)}\n.hero.cover-codex,.hero.cover-cursor{--cover-bg:#141c1b;--cover-fg:#f5f7f4;--cover-muted:#b4c5bf;--cover-accent:#9ddbbb;--cover-glow:#29463d}\n.hero.cover-claude{--cover-bg:#f4e9db;--cover-fg:#3c2c24;--cover-muted:#80634e;--cover-accent:#ba6042;--cover-glow:#efd0b9}\n.hero.cover-gemini,.hero.cover-copilot{--cover-bg:#edf1fc;--cover-fg:#273452;--cover-muted:#58688b;--cover-accent:#617cdf;--cover-glow:#d9d1f4}\n.cover-top{display:flex;flex-wrap:wrap;align-items:center;justify-content:
|
|
7
|
+
export declare const COVER_CSS = "\n.hero.creator-cover{--cover-bg:#edf0ec;--cover-fg:#23332b;--cover-muted:#566c5e;--cover-accent:#629b77;--cover-glow:#c9dccd;position:relative;isolation:isolate;overflow:hidden;margin-top:24px;padding:32px 36px 26px;border:1px solid color-mix(in srgb,var(--cover-accent) 22%,var(--cover-bg));border-radius:18px;background:radial-gradient(ellipse at 100% 0%,var(--cover-glow),transparent 65%),var(--cover-bg);color:var(--cover-fg)}\n.hero.cover-codex,.hero.cover-cursor{--cover-bg:#141c1b;--cover-fg:#f5f7f4;--cover-muted:#b4c5bf;--cover-accent:#9ddbbb;--cover-glow:#29463d}\n.hero.cover-claude{--cover-bg:#f4e9db;--cover-fg:#3c2c24;--cover-muted:#80634e;--cover-accent:#ba6042;--cover-glow:#efd0b9}\n.hero.cover-gemini,.hero.cover-copilot{--cover-bg:#edf1fc;--cover-fg:#273452;--cover-muted:#58688b;--cover-accent:#617cdf;--cover-glow:#d9d1f4}\n.cover-top{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:20px;margin-bottom:34px;position:relative;z-index:1}\n.cover-project{display:inline-flex;align-items:center;gap:9px;max-width:60%;padding:7px 14px;border:1px solid color-mix(in srgb,var(--cover-accent) 32%,transparent);border-radius:18px;background:color-mix(in srgb,var(--cover-bg) 75%,transparent);color:var(--cover-fg);font:600 13px/1.4 var(--font-body);overflow-wrap:anywhere}\n.cover-project:hover{color:var(--cover-fg);border-color:var(--cover-accent)}\n.cover-project:focus-visible{outline:2px solid var(--cover-accent);outline-offset:3px}\n.hero.creator-cover .kicker{color:var(--cover-muted);font-size:10px;letter-spacing:.09em;position:relative;z-index:1}\n.hero.creator-cover .kicker-part{color:var(--cover-muted)}\n.hero.creator-cover .status-badge{color:var(--cover-fg);border-color:color-mix(in srgb,var(--cover-accent) 32%,transparent);background:color-mix(in srgb,var(--cover-accent) 12%,transparent)}\n.hero.creator-cover h1{position:relative;z-index:1;max-width:850px;margin:18px 0 18px;color:var(--cover-fg);font-size:clamp(30px,4vw,49px);line-height:1.12;font-weight:750;letter-spacing:-.035em;overflow-wrap:anywhere;text-wrap:balance}\n.hero.creator-cover .summary{position:relative;z-index:1;max-width:780px;color:var(--cover-muted);font-size:17px;line-height:1.6}\n.hero.creator-cover .summary a{color:var(--cover-fg)}\n.hero.creator-cover .creator-line{position:relative;z-index:1;display:flex;flex-wrap:wrap;align-items:center;gap:10px 22px;margin:28px 0 0;padding-top:18px;border-top:1px solid color-mix(in srgb,var(--cover-accent) 23%,transparent);color:var(--cover-muted);font:400 12px/1.5 var(--font-body)}\n.hero.creator-cover .creator-agent{display:inline-flex;align-items:center;color:var(--cover-fg);font-weight:600}\n.hero.creator-cover .creator-agent .chip-icon{width:16px;height:16px;margin:0 7px 0 0;flex:0 0 16px;fill:currentColor}\n.hero.creator-cover .creator-agent img.chip-icon{object-fit:contain;background:#faf9f6;border-radius:4px;padding:1px}\n.hero.creator-cover .creator-time,.hero.creator-cover .creator-human{color:var(--cover-muted)}\n.hero.creator-cover .creator-human{display:inline-flex;align-items:center;gap:8px}\n.creator-avatar{display:inline-block;width:22px;height:22px;border-radius:50%;object-fit:cover;flex:0 0 22px;background:color-mix(in srgb,var(--cover-accent) 25%,transparent)}\n.creator-time[title]{cursor:help}.creator-line .meta-sep{display:none}\n.cover-art{position:absolute;z-index:0;right:-10px;top:30px;width:340px;height:340px;opacity:.13;pointer-events:none;color:var(--cover-accent)}\n.cover-art .chip-icon{position:absolute;inset:50px;width:240px;height:240px;margin:0;fill:currentColor}\n.cover-art span{position:absolute;inset:0;border:1px solid currentColor;border-radius:50%}.cover-art span+span{inset:-45px}\n.hero-metadata{padding:0 2px 22px;border-bottom:1px solid var(--line)}.hero-metadata .meta{gap:12px;margin-top:20px}\n@media(max-width:720px){.hero.creator-cover{margin-top:18px;padding:24px 22px;border-radius:14px}.cover-top{gap:16px;margin-bottom:28px}.cover-project{max-width:100%}.cover-art{right:-90px;top:90px;opacity:.07}.hero.creator-cover h1{text-wrap:wrap}.hero.creator-cover .summary{font-size:16px}.hero.creator-cover .creator-line{gap:8px 18px}}\n@media print{.hero.creator-cover{break-inside:avoid;margin-top:0}.cover-art{opacity:.05}.hero-metadata details>p{display:block!important}.hero.creator-cover a{color:var(--cover-fg)}}\n";
|
|
@@ -42,10 +42,7 @@ export const COVER_CSS = `
|
|
|
42
42
|
.hero.cover-codex,.hero.cover-cursor{--cover-bg:#141c1b;--cover-fg:#f5f7f4;--cover-muted:#b4c5bf;--cover-accent:#9ddbbb;--cover-glow:#29463d}
|
|
43
43
|
.hero.cover-claude{--cover-bg:#f4e9db;--cover-fg:#3c2c24;--cover-muted:#80634e;--cover-accent:#ba6042;--cover-glow:#efd0b9}
|
|
44
44
|
.hero.cover-gemini,.hero.cover-copilot{--cover-bg:#edf1fc;--cover-fg:#273452;--cover-muted:#58688b;--cover-accent:#617cdf;--cover-glow:#d9d1f4}
|
|
45
|
-
.cover-top{display:flex;flex-wrap:wrap;align-items:center;justify-content:
|
|
46
|
-
.hero.creator-cover .cover-creator{display:flex;align-items:center;gap:12px;min-width:0;color:var(--cover-fg);font:650 17px/1.3 var(--font-body);overflow-wrap:anywhere}
|
|
47
|
-
.cover-creator .chip-icon{width:36px;height:36px;margin:0;flex:0 0 36px;fill:currentColor}
|
|
48
|
-
.cover-creator img.chip-icon{object-fit:contain;background:#faf9f6;border-radius:7px;padding:3px}
|
|
45
|
+
.cover-top{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:20px;margin-bottom:34px;position:relative;z-index:1}
|
|
49
46
|
.cover-project{display:inline-flex;align-items:center;gap:9px;max-width:60%;padding:7px 14px;border:1px solid color-mix(in srgb,var(--cover-accent) 32%,transparent);border-radius:18px;background:color-mix(in srgb,var(--cover-bg) 75%,transparent);color:var(--cover-fg);font:600 13px/1.4 var(--font-body);overflow-wrap:anywhere}
|
|
50
47
|
.cover-project:hover{color:var(--cover-fg);border-color:var(--cover-accent)}
|
|
51
48
|
.cover-project:focus-visible{outline:2px solid var(--cover-accent);outline-offset:3px}
|
|
@@ -56,13 +53,18 @@ export const COVER_CSS = `
|
|
|
56
53
|
.hero.creator-cover .summary{position:relative;z-index:1;max-width:780px;color:var(--cover-muted);font-size:17px;line-height:1.6}
|
|
57
54
|
.hero.creator-cover .summary a{color:var(--cover-fg)}
|
|
58
55
|
.hero.creator-cover .creator-line{position:relative;z-index:1;display:flex;flex-wrap:wrap;align-items:center;gap:10px 22px;margin:28px 0 0;padding-top:18px;border-top:1px solid color-mix(in srgb,var(--cover-accent) 23%,transparent);color:var(--cover-muted);font:400 12px/1.5 var(--font-body)}
|
|
56
|
+
.hero.creator-cover .creator-agent{display:inline-flex;align-items:center;color:var(--cover-fg);font-weight:600}
|
|
57
|
+
.hero.creator-cover .creator-agent .chip-icon{width:16px;height:16px;margin:0 7px 0 0;flex:0 0 16px;fill:currentColor}
|
|
58
|
+
.hero.creator-cover .creator-agent img.chip-icon{object-fit:contain;background:#faf9f6;border-radius:4px;padding:1px}
|
|
59
59
|
.hero.creator-cover .creator-time,.hero.creator-cover .creator-human{color:var(--cover-muted)}
|
|
60
|
+
.hero.creator-cover .creator-human{display:inline-flex;align-items:center;gap:8px}
|
|
61
|
+
.creator-avatar{display:inline-block;width:22px;height:22px;border-radius:50%;object-fit:cover;flex:0 0 22px;background:color-mix(in srgb,var(--cover-accent) 25%,transparent)}
|
|
60
62
|
.creator-time[title]{cursor:help}.creator-line .meta-sep{display:none}
|
|
61
|
-
.cover-art{position:absolute;z-index:0;right:-
|
|
62
|
-
.cover-art .chip-icon{position:absolute;inset:
|
|
63
|
+
.cover-art{position:absolute;z-index:0;right:-10px;top:30px;width:340px;height:340px;opacity:.13;pointer-events:none;color:var(--cover-accent)}
|
|
64
|
+
.cover-art .chip-icon{position:absolute;inset:50px;width:240px;height:240px;margin:0;fill:currentColor}
|
|
63
65
|
.cover-art span{position:absolute;inset:0;border:1px solid currentColor;border-radius:50%}.cover-art span+span{inset:-45px}
|
|
64
66
|
.hero-metadata{padding:0 2px 22px;border-bottom:1px solid var(--line)}.hero-metadata .meta{gap:12px;margin-top:20px}
|
|
65
|
-
@media(max-width:720px){.hero.creator-cover{margin-top:18px;padding:24px 22px;border-radius:14px}.cover-top{gap:16px;margin-bottom:28px}.cover-project{max-width:100%}.cover-
|
|
67
|
+
@media(max-width:720px){.hero.creator-cover{margin-top:18px;padding:24px 22px;border-radius:14px}.cover-top{gap:16px;margin-bottom:28px}.cover-project{max-width:100%}.cover-art{right:-90px;top:90px;opacity:.07}.hero.creator-cover h1{text-wrap:wrap}.hero.creator-cover .summary{font-size:16px}.hero.creator-cover .creator-line{gap:8px 18px}}
|
|
66
68
|
@media print{.hero.creator-cover{break-inside:avoid;margin-top:0}.cover-art{opacity:.05}.hero-metadata details>p{display:block!important}.hero.creator-cover a{color:var(--cover-fg)}}
|
|
67
69
|
`;
|
|
68
70
|
//# sourceMappingURL=creator-cover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creator-cover.js","sourceRoot":"","sources":["../../src/lib/creator-cover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,OAAO,GAA2B;IACtC,aAAa,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO;IAC5F,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ;IAC5E,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS;IACpE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IACjF,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ;CACjG,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxC,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACvD,CAAC;AAED,kFAAkF;AAClF,M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AW,CAAC,OAAO,CAAC;SAC7B,OAAO,CAAC,OAAO,EAAE,0CAA0C,CAAC;SAC5D,OAAO,CAAC,qBAAqB,EAAE,uBAAuB,CAAC;SACvD,OAAO,CAAC,oBAAoB,EAAE,0BAA0B,CAAC;SACzD,OAAO,CAAC,GAAG,EAAE,qEAAqE,CAAC,CAAC;IACvF,OAAO,+CAA+C,UAAU,CAAC,qBAAqB,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;AACxH,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BxB,CAAC"}
|
|
@@ -2,6 +2,8 @@ export interface OriginMetadata {
|
|
|
2
2
|
agent: string;
|
|
3
3
|
version: string;
|
|
4
4
|
host: string;
|
|
5
|
+
/** Optional reachable address for the device: a DNS name or an IP. Copied, never displayed. */
|
|
6
|
+
address?: string;
|
|
5
7
|
platform: string;
|
|
6
8
|
arch: string;
|
|
7
9
|
session: string;
|
|
@@ -14,9 +16,38 @@ export interface ReaderRevision {
|
|
|
14
16
|
createdAt: string;
|
|
15
17
|
}[];
|
|
16
18
|
}
|
|
19
|
+
/** A page timestamp the reader can fall back on when no saved history exists yet. */
|
|
20
|
+
export interface ReaderTimestamp {
|
|
21
|
+
/** "Created", "Updated", or "Source updated" - the honest provenance of the time. */
|
|
22
|
+
label: string;
|
|
23
|
+
iso: string;
|
|
24
|
+
/** True when the instant carries a real time of day and may be shown as "10 minutes ago". */
|
|
25
|
+
relative: boolean;
|
|
26
|
+
/** Absolute, date-only display (YYYY-MM-DD) used before the freshness script runs. */
|
|
27
|
+
display: string;
|
|
28
|
+
}
|
|
17
29
|
export declare const REVISION_START = "<!--artifact-revision-start-->";
|
|
18
30
|
export declare const REVISION_END = "<!--artifact-revision-end-->";
|
|
31
|
+
/** "yosemite-m4" reads as "Yosemite M4". The canonical id is what gets copied. */
|
|
32
|
+
export declare function humanDevice(canonical: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* The complete device record a reader gets on the clipboard. Lines are only
|
|
35
|
+
* written for values that were actually recorded; the raw host stays even when
|
|
36
|
+
* the visible label is shortened to a device name.
|
|
37
|
+
*/
|
|
38
|
+
export declare function deviceDetails(origin: OriginMetadata): string;
|
|
39
|
+
/**
|
|
40
|
+
* Compact inline controls for the document header: a device chip that copies
|
|
41
|
+
* the full device record and a session chip that copies the full session id.
|
|
42
|
+
* Controls for values that were not recorded are omitted rather than invented.
|
|
43
|
+
*/
|
|
19
44
|
export declare function originMenu(origin: OriginMetadata): string;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The history control. With saved history the trigger reads "Created just now"
|
|
47
|
+
* or "Updated 10 minutes ago" from the stored snapshot timestamp; without it,
|
|
48
|
+
* the latest page timestamp keeps its own label (for example "Source updated").
|
|
49
|
+
* The copied commands keep their numeric revisions.
|
|
50
|
+
*/
|
|
51
|
+
export declare function revisionMenu(history?: ReaderRevision, timestamps?: ReaderTimestamp[]): string;
|
|
52
|
+
export declare const METADATA_CSS = "\n.document-header{position:relative;flex-wrap:wrap;gap:8px;padding-bottom:10px}.artifact-menu,.origin-inline{font:12px/1.5 var(--font-body);color:var(--muted)}.artifact-menu>summary{display:flex;align-items:center;gap:7px;cursor:pointer;list-style:none;border:1px solid var(--line);border-radius:999px;background:var(--surface);padding:5px 11px;max-width:270px;overflow-wrap:anywhere}.artifact-menu>summary::-webkit-details-marker{display:none}.artifact-menu>summary:hover{color:var(--accent);border-color:var(--accent)}.artifact-menu>summary:focus-visible,.metadata-copy:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.metadata-popover{position:absolute;z-index:80;right:0;top:calc(100% + 6px);width:min(370px,100%);max-height:70vh;overflow:auto;padding:20px;background:var(--surface);color:var(--text);border:1px solid var(--line);border-radius:14px;box-shadow:0 12px 34px #0002}.metadata-popover h2{font:650 17px/1.4 var(--font-body);margin:0 0 16px;padding:0;border:0}.metadata-copy{display:flex;justify-content:space-between;align-items:center;gap:12px;min-height:34px;width:100%;border:0;border-radius:6px;padding:7px 8px;background:transparent;color:var(--text);font:inherit;text-align:left;cursor:pointer;overflow-wrap:anywhere}.metadata-copy:hover{background:var(--surface-alt)}.metadata-copy>.copy-affordance{font-size:10px;color:var(--muted);flex:0 0 auto}.origin-inline{display:flex;flex-wrap:wrap;align-items:center;gap:6px;min-width:0;max-width:100%}.metadata-chip{width:auto;max-width:220px;min-height:0;gap:6px;border:1px solid var(--line);border-radius:999px;background:var(--surface);padding:5px 11px;color:var(--muted);white-space:nowrap}.metadata-chip .metadata-value{min-width:0;overflow:hidden;text-overflow:ellipsis}.header-label{text-transform:capitalize}.metadata-chip:hover{color:var(--accent);border-color:var(--accent);background:var(--surface)}.origin-inline>.metadata-feedback{margin:0;flex:0 0 auto}.origin-inline>.metadata-fallback{position:absolute;right:0;top:calc(100% + 6px);z-index:80;width:min(370px,100%);margin:0;padding:10px;border-radius:14px;box-shadow:0 12px 34px #0002}.metadata-note{color:var(--muted);font-size:12px}.metadata-feedback:empty{display:none}.metadata-feedback{color:var(--accent);font-size:12px;margin:8px 0 0}.metadata-fallback{width:100%;min-height:110px;color:var(--text);background:var(--bg);border:1px solid var(--line);font:12px/1.5 var(--font-mono);margin-top:8px;resize:vertical}.revision-list{list-style:none;padding:0;margin:0}.revision-list li{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:4px 12px;padding:9px 0;border-bottom:1px solid var(--line)}.revision-list time{color:var(--muted);font-size:12px}.revision-list .metadata-copy{width:auto;font-size:12px;padding:4px 8px;min-height:0}.metadata-popover [hidden],.origin-inline [hidden]{display:none!important}@media(max-width:480px){.artifact-menu>summary{max-width:220px}.metadata-chip{max-width:160px}.metadata-popover{padding:16px}}@media print{.artifact-menu,.origin-inline{display:none}}\n";
|
|
53
|
+
export declare const METADATA_SCRIPT = "<script>\n(() => {\n const menus = [...document.querySelectorAll('.artifact-menu')];\n const scopes = [...document.querySelectorAll('[data-copy-scope]')];\n const reset = scope => {\n const status = scope.querySelector('.metadata-feedback');\n const fallback = scope.querySelector('.metadata-fallback');\n if (status) status.textContent = '';\n if (fallback) fallback.hidden = true;\n };\n for (const menu of menus) menu.querySelector('summary').addEventListener('click', () => menus.forEach(other => { if (other !== menu) other.open = false; }));\n for (const scope of scopes) {\n const status = scope.querySelector('.metadata-feedback');\n const fallback = scope.querySelector('.metadata-fallback');\n let timer;\n scope.querySelectorAll('[data-copy-value]').forEach(button => button.addEventListener('click', async () => {\n const value = button.dataset.copyValue;\n clearTimeout(timer); reset(scope);\n try {\n if (!navigator.clipboard || !navigator.clipboard.writeText) throw new Error('Clipboard unavailable');\n await navigator.clipboard.writeText(value);\n status.textContent = 'Copied';\n timer = setTimeout(() => { if (status.textContent === 'Copied') status.textContent = ''; }, 4000);\n } catch {\n status.textContent = 'Could not copy. Select and copy the full value below.';\n fallback.value = value; fallback.hidden = false;\n fallback.focus(); fallback.select();\n }\n }));\n }\n document.addEventListener('click', event => {\n menus.forEach(menu => { if (!menu.contains(event.target)) menu.open = false; });\n scopes.forEach(scope => { if (!scope.contains(event.target)) reset(scope); });\n });\n document.addEventListener('keydown', event => {\n if (event.key !== 'Escape') return;\n scopes.forEach(reset);\n menus.forEach(menu => { if (menu.open) { menu.open = false; menu.querySelector('summary').focus(); } });\n });\n})();\n</script>";
|
|
@@ -3,50 +3,127 @@ import { shortHost } from './templates.js';
|
|
|
3
3
|
export const REVISION_START = '<!--artifact-revision-start-->';
|
|
4
4
|
export const REVISION_END = '<!--artifact-revision-end-->';
|
|
5
5
|
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
6
|
-
const copy = (label, value, display = label) => `<button type="button" class="
|
|
7
|
-
|
|
6
|
+
const copy = (label, value, display = label, className = 'metadata-copy', title = value) => `<button type="button" class="${className}" data-copy-value="${escapeHtml(value)}" aria-label="${escapeHtml(label)}" title="${escapeHtml(title)}"><span class="metadata-value">${escapeHtml(display)}</span><span class="copy-affordance" aria-hidden="true">Copy</span></button>`;
|
|
7
|
+
/** Shared status line plus the selectable full-text fallback shown only when the clipboard actually refuses. */
|
|
8
8
|
const fallback = '<p class="metadata-feedback" role="status" aria-live="polite"></p><textarea class="metadata-fallback" aria-label="Select and copy full value" readonly hidden></textarea>';
|
|
9
|
+
/** "yosemite-m4" reads as "Yosemite M4". The canonical id is what gets copied. */
|
|
10
|
+
export function humanDevice(canonical) {
|
|
11
|
+
return canonical.split(/[-_]+/).filter(Boolean)
|
|
12
|
+
.map((part) => (/^[a-z]{1,2}\d+$/.test(part) ? part.toUpperCase() : part[0].toUpperCase() + part.slice(1)))
|
|
13
|
+
.join(' ');
|
|
14
|
+
}
|
|
15
|
+
const platformLabel = (origin) => [origin.platform === 'macos' ? 'macOS' : origin.platform, origin.arch].filter(Boolean).join(' ');
|
|
16
|
+
const sessionOf = (origin) => {
|
|
17
|
+
const id = origin.sessionId || origin.session;
|
|
18
|
+
return { id, full: Boolean(origin.sessionId) || uuid.test(id), short: uuid.test(id) ? id.split('-')[0] : id.slice(0, 12) };
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The complete device record a reader gets on the clipboard. Lines are only
|
|
22
|
+
* written for values that were actually recorded; the raw host stays even when
|
|
23
|
+
* the visible label is shortened to a device name.
|
|
24
|
+
*/
|
|
25
|
+
export function deviceDetails(origin) {
|
|
26
|
+
const canonical = shortHost(origin.host);
|
|
27
|
+
const raw = origin.host.trim();
|
|
28
|
+
const address = origin.address?.trim() ?? '';
|
|
29
|
+
const platform = platformLabel(origin);
|
|
30
|
+
const session = sessionOf(origin);
|
|
31
|
+
return [
|
|
32
|
+
canonical ? `Device: ${canonical}` : '',
|
|
33
|
+
raw && raw.toLowerCase() !== canonical ? `Host: ${raw}` : '',
|
|
34
|
+
address ? `Address: ${address}` : '',
|
|
35
|
+
platform ? `Platform: ${platform}` : '',
|
|
36
|
+
origin.agent ? `Agent: ${origin.agent}` : '',
|
|
37
|
+
origin.version ? `Agent CLI version: ${origin.version}` : '',
|
|
38
|
+
session.id ? `Session${session.full ? '' : ' (short ID only)'}: ${session.id}` : '',
|
|
39
|
+
].filter(Boolean).join('\n');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Compact inline controls for the document header: a device chip that copies
|
|
43
|
+
* the full device record and a session chip that copies the full session id.
|
|
44
|
+
* Controls for values that were not recorded are omitted rather than invented.
|
|
45
|
+
*/
|
|
9
46
|
export function originMenu(origin) {
|
|
10
|
-
const
|
|
11
|
-
const session = origin
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
47
|
+
const canonical = shortHost(origin.host);
|
|
48
|
+
const session = sessionOf(origin);
|
|
49
|
+
const chip = 'metadata-copy metadata-chip';
|
|
50
|
+
const controls = [
|
|
51
|
+
canonical ? copy('Copy device details', deviceDetails(origin), humanDevice(canonical), chip) : '',
|
|
52
|
+
session.id
|
|
53
|
+
? copy(session.full ? 'Copy full session ID' : 'Copy recorded short session ID', session.id, session.short, chip, session.full ? session.id : `${session.id}\nShort ID only. The full session was not recorded.`)
|
|
54
|
+
: '',
|
|
55
|
+
].join('');
|
|
56
|
+
return controls ? `<div class="origin-inline" data-copy-scope>${controls}${fallback}</div>` : '';
|
|
19
57
|
}
|
|
20
|
-
|
|
58
|
+
const stamp = (label, iso, display, relative = true) => `<time${relative ? ' data-relative="true"' : ''} data-label="${escapeHtml(label)}" datetime="${escapeHtml(iso)}" title="${escapeHtml(iso)}">${escapeHtml(label)} ${escapeHtml(display)}</time>`;
|
|
59
|
+
const revisionLabel = (number) => (number === 1 ? 'Created' : 'Updated');
|
|
60
|
+
const latestTimestamp = (stamps) => stamps.reduce((best, next) => (!best || Date.parse(next.iso) >= Date.parse(best.iso) ? next : best), undefined);
|
|
61
|
+
/**
|
|
62
|
+
* The history control. With saved history the trigger reads "Created just now"
|
|
63
|
+
* or "Updated 10 minutes ago" from the stored snapshot timestamp; without it,
|
|
64
|
+
* the latest page timestamp keeps its own label (for example "Source updated").
|
|
65
|
+
* The copied commands keep their numeric revisions.
|
|
66
|
+
*/
|
|
67
|
+
export function revisionMenu(history, timestamps = []) {
|
|
21
68
|
const latest = history?.revisions.at(-1);
|
|
22
|
-
|
|
23
|
-
|
|
69
|
+
let summary;
|
|
70
|
+
let content;
|
|
71
|
+
if (history && latest) {
|
|
72
|
+
const count = history.revisions.length;
|
|
73
|
+
summary = stamp(revisionLabel(latest.number), latest.createdAt, latest.createdAt.slice(0, 10));
|
|
74
|
+
const entries = history.revisions.slice(-10).reverse().map((revision) => `<li>${stamp(revisionLabel(revision.number), revision.createdAt, revision.createdAt.slice(0, 10))}${copy(`Copy command to open revision ${revision.number}`, `artifacts history ${history.id} --open ${revision.number}`, revision === latest ? 'This version' : 'Copy open command')}</li>`);
|
|
75
|
+
content = `<p class="metadata-note">${count === 1 ? '1 version' : `${count} versions`}, saved on the rendering device. Copy an open command to run it there; it never overwrites the source.</p><ol class="revision-list">${entries.join('')}</ol>${count > 10 ? copy('Copy complete history command', `artifacts history ${history.id}`, 'All versions') : ''}`;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const newest = latestTimestamp(timestamps);
|
|
79
|
+
summary = newest ? stamp(newest.label, newest.iso, newest.display, newest.relative) : 'History';
|
|
80
|
+
const known = timestamps.length ? `<ul class="revision-list">${timestamps.map((time) => `<li>${stamp(time.label, time.iso, time.display, time.relative)}</li>`).join('')}</ul>` : '';
|
|
81
|
+
content = `${known}<p class="metadata-note">No saved versions yet. Render a Markdown file to an output path to start tracking versions.</p>`;
|
|
82
|
+
}
|
|
83
|
+
return `${REVISION_START}<details class="artifact-menu revision-menu"><summary aria-label="Revision history">${summary} <span aria-hidden="true">▾</span></summary><div class="metadata-popover" data-copy-scope><h2>History</h2>${content}${fallback}</div></details>${REVISION_END}`;
|
|
24
84
|
}
|
|
25
85
|
export const METADATA_CSS = `
|
|
26
|
-
.document-header{position:relative;flex-wrap:wrap;gap:8px;padding-bottom:10px}.artifact-menu{font:12px/1.5 var(--font-body);color:var(--muted)}.artifact-menu>summary{display:flex;align-items:center;gap:7px;cursor:pointer;list-style:none;border:1px solid var(--line);border-radius:999px;background:var(--surface);padding:5px 11px;max-width:270px;overflow-wrap:anywhere}.artifact-menu>summary::-webkit-details-marker{display:none}.artifact-menu>summary:hover{color:var(--accent);border-color:var(--accent)}.artifact-menu>summary:focus-visible,.metadata-copy:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.metadata-popover{position:absolute;z-index:80;right:0;top:calc(100% + 6px);width:min(370px,100%);max-height:70vh;overflow:auto;padding:20px;background:var(--surface);color:var(--text);border:1px solid var(--line);border-radius:14px;box-shadow:0 12px 34px #0002}.metadata-popover h2{font:650 17px/1.4 var(--font-body);margin:0 0 16px;padding:0;border:0}.metadata-
|
|
86
|
+
.document-header{position:relative;flex-wrap:wrap;gap:8px;padding-bottom:10px}.artifact-menu,.origin-inline{font:12px/1.5 var(--font-body);color:var(--muted)}.artifact-menu>summary{display:flex;align-items:center;gap:7px;cursor:pointer;list-style:none;border:1px solid var(--line);border-radius:999px;background:var(--surface);padding:5px 11px;max-width:270px;overflow-wrap:anywhere}.artifact-menu>summary::-webkit-details-marker{display:none}.artifact-menu>summary:hover{color:var(--accent);border-color:var(--accent)}.artifact-menu>summary:focus-visible,.metadata-copy:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.metadata-popover{position:absolute;z-index:80;right:0;top:calc(100% + 6px);width:min(370px,100%);max-height:70vh;overflow:auto;padding:20px;background:var(--surface);color:var(--text);border:1px solid var(--line);border-radius:14px;box-shadow:0 12px 34px #0002}.metadata-popover h2{font:650 17px/1.4 var(--font-body);margin:0 0 16px;padding:0;border:0}.metadata-copy{display:flex;justify-content:space-between;align-items:center;gap:12px;min-height:34px;width:100%;border:0;border-radius:6px;padding:7px 8px;background:transparent;color:var(--text);font:inherit;text-align:left;cursor:pointer;overflow-wrap:anywhere}.metadata-copy:hover{background:var(--surface-alt)}.metadata-copy>.copy-affordance{font-size:10px;color:var(--muted);flex:0 0 auto}.origin-inline{display:flex;flex-wrap:wrap;align-items:center;gap:6px;min-width:0;max-width:100%}.metadata-chip{width:auto;max-width:220px;min-height:0;gap:6px;border:1px solid var(--line);border-radius:999px;background:var(--surface);padding:5px 11px;color:var(--muted);white-space:nowrap}.metadata-chip .metadata-value{min-width:0;overflow:hidden;text-overflow:ellipsis}.header-label{text-transform:capitalize}.metadata-chip:hover{color:var(--accent);border-color:var(--accent);background:var(--surface)}.origin-inline>.metadata-feedback{margin:0;flex:0 0 auto}.origin-inline>.metadata-fallback{position:absolute;right:0;top:calc(100% + 6px);z-index:80;width:min(370px,100%);margin:0;padding:10px;border-radius:14px;box-shadow:0 12px 34px #0002}.metadata-note{color:var(--muted);font-size:12px}.metadata-feedback:empty{display:none}.metadata-feedback{color:var(--accent);font-size:12px;margin:8px 0 0}.metadata-fallback{width:100%;min-height:110px;color:var(--text);background:var(--bg);border:1px solid var(--line);font:12px/1.5 var(--font-mono);margin-top:8px;resize:vertical}.revision-list{list-style:none;padding:0;margin:0}.revision-list li{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:4px 12px;padding:9px 0;border-bottom:1px solid var(--line)}.revision-list time{color:var(--muted);font-size:12px}.revision-list .metadata-copy{width:auto;font-size:12px;padding:4px 8px;min-height:0}.metadata-popover [hidden],.origin-inline [hidden]{display:none!important}@media(max-width:480px){.artifact-menu>summary{max-width:220px}.metadata-chip{max-width:160px}.metadata-popover{padding:16px}}@media print{.artifact-menu,.origin-inline{display:none}}
|
|
27
87
|
`;
|
|
28
88
|
export const METADATA_SCRIPT = `<script>
|
|
29
89
|
(() => {
|
|
30
90
|
const menus = [...document.querySelectorAll('.artifact-menu')];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
91
|
+
const scopes = [...document.querySelectorAll('[data-copy-scope]')];
|
|
92
|
+
const reset = scope => {
|
|
93
|
+
const status = scope.querySelector('.metadata-feedback');
|
|
94
|
+
const fallback = scope.querySelector('.metadata-fallback');
|
|
95
|
+
if (status) status.textContent = '';
|
|
96
|
+
if (fallback) fallback.hidden = true;
|
|
97
|
+
};
|
|
98
|
+
for (const menu of menus) menu.querySelector('summary').addEventListener('click', () => menus.forEach(other => { if (other !== menu) other.open = false; }));
|
|
99
|
+
for (const scope of scopes) {
|
|
100
|
+
const status = scope.querySelector('.metadata-feedback');
|
|
101
|
+
const fallback = scope.querySelector('.metadata-fallback');
|
|
102
|
+
let timer;
|
|
103
|
+
scope.querySelectorAll('[data-copy-value]').forEach(button => button.addEventListener('click', async () => {
|
|
104
|
+
const value = button.dataset.copyValue;
|
|
105
|
+
clearTimeout(timer); reset(scope);
|
|
37
106
|
try {
|
|
38
|
-
if (!navigator.clipboard
|
|
39
|
-
await navigator.clipboard.writeText(
|
|
107
|
+
if (!navigator.clipboard || !navigator.clipboard.writeText) throw new Error('Clipboard unavailable');
|
|
108
|
+
await navigator.clipboard.writeText(value);
|
|
40
109
|
status.textContent = 'Copied';
|
|
110
|
+
timer = setTimeout(() => { if (status.textContent === 'Copied') status.textContent = ''; }, 4000);
|
|
41
111
|
} catch {
|
|
42
112
|
status.textContent = 'Could not copy. Select and copy the full value below.';
|
|
43
|
-
fallback.value =
|
|
113
|
+
fallback.value = value; fallback.hidden = false;
|
|
44
114
|
fallback.focus(); fallback.select();
|
|
45
115
|
}
|
|
46
116
|
}));
|
|
47
117
|
}
|
|
48
|
-
document.addEventListener('click', event =>
|
|
49
|
-
|
|
118
|
+
document.addEventListener('click', event => {
|
|
119
|
+
menus.forEach(menu => { if (!menu.contains(event.target)) menu.open = false; });
|
|
120
|
+
scopes.forEach(scope => { if (!scope.contains(event.target)) reset(scope); });
|
|
121
|
+
});
|
|
122
|
+
document.addEventListener('keydown', event => {
|
|
123
|
+
if (event.key !== 'Escape') return;
|
|
124
|
+
scopes.forEach(reset);
|
|
125
|
+
menus.forEach(menu => { if (menu.open) { menu.open = false; menu.querySelector('summary').focus(); } });
|
|
126
|
+
});
|
|
50
127
|
})();
|
|
51
128
|
</script>`;
|
|
52
129
|
//# sourceMappingURL=metadata-menu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata-menu.js","sourceRoot":"","sources":["../../src/lib/metadata-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"metadata-menu.js","sourceRoot":"","sources":["../../src/lib/metadata-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA8B3C,MAAM,CAAC,MAAM,cAAc,GAAG,gCAAgC,CAAC;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAG,8BAA8B,CAAC;AAC3D,MAAM,IAAI,GAAG,iEAAiE,CAAC;AAC/E,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,KAAa,EAAE,OAAO,GAAG,KAAK,EAAE,SAAS,GAAG,eAAe,EAAE,KAAK,GAAG,KAAK,EAAU,EAAE,CACjH,gCAAgC,SAAS,sBAAsB,UAAU,CAAC,KAAK,CAAC,iBAAiB,UAAU,CAAC,KAAK,CAAC,YAAY,UAAU,CAAC,KAAK,CAAC,kCAAkC,UAAU,CAAC,OAAO,CAAC,8EAA8E,CAAC;AACrR,gHAAgH;AAChH,MAAM,QAAQ,GAAG,2KAA2K,CAAC;AAE7L,kFAAkF;AAClF,MAAM,UAAU,WAAW,CAAC,SAAiB;IAC3C,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;SAC5C,GAAG,CAAC,CAAC,IAAI,EAAE,EAA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CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,+BAA+B,EAAE,qBAAqB,OAAO,CAAC,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACnW,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAChG,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,6BAA6B,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACrL,OAAO,GAAG,GAAG,KAAK,0HAA0H,CAAC;IAC/I,CAAC;IACD,OAAO,GAAG,cAAc,uFAAuF,OAAO,mHAAmH,OAAO,GAAG,QAAQ,mBAAmB,YAAY,EAAE,CAAC;AAC/R,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG;;CAE3B,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAwCrB,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Reader preference belongs to the reader, not the source document's design. */
|
|
2
|
+
export declare const READER_THEME_SCRIPT = "<script>\n(() => {\n const root = document.documentElement;\n const button = document.querySelector('.theme-toggle');\n const media = window.matchMedia('(prefers-color-scheme: dark)');\n let mode = 'system';\n try { const saved = localStorage.getItem('artifacts-theme'); if (saved === 'light' || saved === 'dark') mode = saved; } catch {}\n const apply = () => {\n const theme = mode === 'system' ? (media.matches ? 'dark' : 'light') : mode;\n root.dataset.theme = theme;\n root.style.colorScheme = theme;\n root.dataset.themeMode = mode;\n button.querySelector('.theme-label').textContent = mode.charAt(0).toUpperCase() + mode.slice(1);\n button.setAttribute('aria-label', 'Color theme: ' + mode + '. Click to change.');\n button.setAttribute('title', mode === 'system' ? 'Following system theme. Click to override.' : 'Reader override. Cycle back to System to follow your device.');\n button.setAttribute('aria-pressed', mode !== 'system' ? 'true' : 'false');\n };\n apply();\n button.addEventListener('click', () => {\n // First click always makes a visible change, then cycles through both fixed\n // palettes and back to System. The mode survives a blocked storage API too.\n const opposite = media.matches ? 'light' : 'dark';\n mode = mode === 'system' ? opposite : mode === opposite ? (media.matches ? 'dark' : 'light') : 'system';\n try { if (mode === 'system') localStorage.removeItem('artifacts-theme'); else localStorage.setItem('artifacts-theme', mode); } catch {}\n apply();\n });\n media.addEventListener('change', () => { if (mode === 'system') apply(); });\n addEventListener('storage', event => {\n if (event.key !== 'artifacts-theme' && event.key !== null) return;\n mode = event.newValue === 'light' || event.newValue === 'dark' ? event.newValue : 'system';\n apply();\n });\n})();\n</script>";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Reader preference belongs to the reader, not the source document's design. */
|
|
2
|
+
export const READER_THEME_SCRIPT = `<script>
|
|
3
|
+
(() => {
|
|
4
|
+
const root = document.documentElement;
|
|
5
|
+
const button = document.querySelector('.theme-toggle');
|
|
6
|
+
const media = window.matchMedia('(prefers-color-scheme: dark)');
|
|
7
|
+
let mode = 'system';
|
|
8
|
+
try { const saved = localStorage.getItem('artifacts-theme'); if (saved === 'light' || saved === 'dark') mode = saved; } catch {}
|
|
9
|
+
const apply = () => {
|
|
10
|
+
const theme = mode === 'system' ? (media.matches ? 'dark' : 'light') : mode;
|
|
11
|
+
root.dataset.theme = theme;
|
|
12
|
+
root.style.colorScheme = theme;
|
|
13
|
+
root.dataset.themeMode = mode;
|
|
14
|
+
button.querySelector('.theme-label').textContent = mode.charAt(0).toUpperCase() + mode.slice(1);
|
|
15
|
+
button.setAttribute('aria-label', 'Color theme: ' + mode + '. Click to change.');
|
|
16
|
+
button.setAttribute('title', mode === 'system' ? 'Following system theme. Click to override.' : 'Reader override. Cycle back to System to follow your device.');
|
|
17
|
+
button.setAttribute('aria-pressed', mode !== 'system' ? 'true' : 'false');
|
|
18
|
+
};
|
|
19
|
+
apply();
|
|
20
|
+
button.addEventListener('click', () => {
|
|
21
|
+
// First click always makes a visible change, then cycles through both fixed
|
|
22
|
+
// palettes and back to System. The mode survives a blocked storage API too.
|
|
23
|
+
const opposite = media.matches ? 'light' : 'dark';
|
|
24
|
+
mode = mode === 'system' ? opposite : mode === opposite ? (media.matches ? 'dark' : 'light') : 'system';
|
|
25
|
+
try { if (mode === 'system') localStorage.removeItem('artifacts-theme'); else localStorage.setItem('artifacts-theme', mode); } catch {}
|
|
26
|
+
apply();
|
|
27
|
+
});
|
|
28
|
+
media.addEventListener('change', () => { if (mode === 'system') apply(); });
|
|
29
|
+
addEventListener('storage', event => {
|
|
30
|
+
if (event.key !== 'artifacts-theme' && event.key !== null) return;
|
|
31
|
+
mode = event.newValue === 'light' || event.newValue === 'dark' ? event.newValue : 'system';
|
|
32
|
+
apply();
|
|
33
|
+
});
|
|
34
|
+
})();
|
|
35
|
+
</script>`;
|
|
36
|
+
//# sourceMappingURL=reader-theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader-theme.js","sourceRoot":"","sources":["../../src/lib/reader-theme.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiCzB,CAAC"}
|