docs+framework: canon, system-profile, gdd, registry, 6a framework

This commit is contained in:
2026-09-30 12:57:28 +08:00
commit e030f69591
31 changed files with 1334 additions and 0 deletions
+130
View File
@@ -0,0 +1,130 @@
/* base.css — the shared skeleton of a make-my-arg project.
*
* Structure only: the persistent top bar, the page column, the document kit, the gate form, the
* entry shell, x-cloak. Every colour, font and surface lives in surface.css (and secret.css on
* deep pages, M5) — a project edits the skin, never this file's layout, per page.
*
* Conventions this file owes the rest of the system:
* · header is sticky and opaque, site-wide, deep pages included (base.md §2)
* · every input names its field; nothing here hints at an answer (R4)
* · .hidden-text / .blurred are the M11 texture kit: black-on-black selectable text, redaction
* as a clue. Client-side masking is not privacy — anything hidden this way is public (R12)
*/
/* ── Alpine: hide a component until it initializes, so no raw template flashes ── */
[x-cloak] { display: none !important; }
/* ── Reset ── */
* { box-sizing: border-box; }
body { margin: 0; }
img { max-width: 100%; }
ul, ol { padding-left: 1.4em; }
/* ── Persistent top bar ─────────────────────────────────────────────────────────
Sticky to the viewport top; background must stay opaque so long-page body text never shows
through. The nav links are this organization's own IA — together with the footer links (and the
M1 search box) they are the only cross-page links a public page carries (R7). */
header {
position: sticky; top: 0; z-index: 10;
background: var(--bar, #f3e2d0);
border-bottom: 1px solid var(--rule, #d8c4b0);
}
header nav {
max-width: 60rem; margin: 0 auto; padding: .55rem 1rem;
display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem 1.1rem;
font-family: var(--sans, system-ui, sans-serif); font-size: .9rem;
}
header nav a { color: var(--ink, #4a4a4a); text-decoration: none; }
header nav a:hover { color: var(--accent, #c1440e); text-decoration: underline; }
header nav .brand { font-weight: 700; letter-spacing: .02em; }
header nav form { display: flex; gap: .35rem; margin-left: auto; }
/* ── Page column: one document per page ── */
main {
max-width: 60rem; margin: 0 auto; padding: 1.6rem 1rem 3rem;
line-height: 1.75;
}
main > h1 { font-size: 1.5rem; margin: 0 0 1rem; }
main > h2 { font-size: 1.15rem; margin: 1.8rem 0 .6rem; }
main p { margin: .6rem 0; }
/* ── Footer: the site's own links + the M7 progress number ── */
footer {
border-top: 1px solid var(--rule, #d8c4b0);
font-family: var(--sans, system-ui, sans-serif); font-size: .8rem; color: var(--ink-2, #6b6b6b);
}
footer .footer-inner { max-width: 60rem; margin: 0 auto; padding: .9rem 1rem; display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
footer a { color: var(--ink-2, #6b6b6b); }
.progress { margin-left: auto; font-family: var(--mono, monospace); letter-spacing: .04em; }
/* ── Document kit: what a real system prints ─────────────────────────────────────
.sheet is a formal document (R6: issuing body, number, date, addressee, body, seal,
distribution list); .narrow tightens it to a memo or a single record. */
.sheet { border: 1px solid var(--rule, #d8c4b0); background: var(--paper-2, #fffdf9); padding: 1.4rem 1.6rem; }
.sheet.narrow { max-width: 34rem; margin: 0 auto; }
.sheet .doc-head { border-bottom: 2px solid var(--ink, #4a4a4a); padding-bottom: .5rem; margin-bottom: 1rem; }
.sheet .doc-no { float: right; font-family: var(--mono, monospace); font-size: .85rem; }
.sheet .doc-meta { font-size: .85rem; color: var(--ink-2, #6b6b6b); }
.sheet .doc-seal { margin-top: 1.2rem; text-align: right; color: var(--stamp, #a11212); font-weight: 700; letter-spacing: .15em; }
.sheet table { width: 100%; border-collapse: collapse; margin: .8rem 0; }
.sheet th, .sheet td { border: 1px solid var(--rule, #d8c4b0); padding: .35rem .6rem; text-align: left; }
.sheet th { background: var(--wash, #f7f1e8); }
.doc-list { list-style: none; padding: 0; }
.doc-list li { display: flex; gap: .8rem; padding: .35rem 0; border-bottom: 1px dashed var(--rule, #d8c4b0); }
.doc-list time { color: var(--ink-2, #6b6b6b); font-family: var(--mono, monospace); font-size: .85rem; white-space: nowrap; }
/* ── M11 world texture ── */
.handwrite { font-family: var(--hand, "Kaiti SC", "STKaiti", cursive); color: var(--stamp, #a11212); }
.hidden-text { background: #000; color: #000; user-select: text; }
.hidden-text::selection { color: #f00; background: #333; } /* visible only when selected */
.blurred { filter: blur(6px); user-select: none; } /* redaction is itself a clue */
.spacer { height: 180px; } /* whitespace as pacing */
/* ── Gate form (M2) ─────────────────────────────────────────────────────────────
The input names its field and stops there: a placeholder that carries the answer leaks it (R4).
Failure copy points at the source obliquely ("密码错误 🎂"), never at the derivation. */
.gate { max-width: 22rem; margin: 2rem auto; }
.gate label { display: block; font-family: var(--sans, system-ui, sans-serif); font-size: .85rem; margin: .9rem 0 .25rem; }
.gate input, .gate select {
width: 100%; padding: .45rem .6rem; font: inherit;
border: 1px solid var(--rule, #d8c4b0); background: var(--paper-2, #fffdf9); color: var(--ink, #4a4a4a);
}
.gate input:focus-visible, .gate select:focus-visible { outline: 2px solid var(--accent, #c1440e); outline-offset: 1px; }
.gate-error { color: var(--stamp, #a11212); font-size: .85rem; min-height: 1.2em; margin: .5rem 0 0; }
.btn {
display: inline-block; padding: .45rem 1.4rem; font: inherit; cursor: pointer;
border: 1px solid var(--accent, #c1440e); background: var(--accent, #c1440e); color: var(--paper, #f9ebde);
text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent, #c1440e); }
/* ── Entry shell (M9): the cover before the site ───────────────────────────────
No site header here — the player has not entered yet. Copy stays light: role assignment, the
system's own one-liner, and the start button. */
.entry { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem 1rem; }
.entry h1 { font-size: 2rem; margin: 0 0 .6rem; letter-spacing: .04em; }
.entry .entry-lede { max-width: 30rem; color: var(--ink-2, #6b6b6b); margin: 0 0 2rem; }
.entry .entry-role { font-family: var(--sans, system-ui, sans-serif); font-size: .9rem; color: var(--ink-2, #6b6b6b); margin: -1rem 0 2rem; }
/* The entry's about link: quiet, below the start button. */
.entry .entry-meta { margin: 1.4rem 0 0; font-family: var(--sans, system-ui, sans-serif); font-size: .78rem; }
.entry .entry-meta a { color: var(--ink-2, #6b6b6b); }
/* ── About page: a plain column, no document pretense ── */
.about { max-width: 40rem; }
.about h2 { font-size: 1.05rem; margin: 1.8rem 0 .5rem; }
.about p { margin: .6rem 0; }
/* ── Staging (M12): full-page overlays own the viewport while they hold it ── */
.blackout {
position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
background: #000; color: #bbb; font-family: var(--mono, monospace); letter-spacing: .1em;
}
/* ── Small screens: the bar wraps, the column narrows, nothing clips ── */
@media (max-width: 820px) {
header nav { gap: .2rem .7rem; }
header nav form { margin-left: 0; width: 100%; }
main { padding: 1.1rem .9rem 2.4rem; }
.sheet { padding: 1rem; }
}
+15
View File
@@ -0,0 +1,15 @@
/* secret.css — M5 deep-layer skin. Linked by deep pages only (or applied via the session reskin
* token; references/structure/components.md §5). Retunes the custom properties base.css reads, so
* layout stays in base.css and the whole page shifts together: background, text, rules, accents.
* The fiction's own palette goes here — the values below are a placeholder for a cold archive mood. */
:root {
--ink: #9e9e9e; --ink-2: #6f6f6f;
--paper: #1a1a1c; --paper-2: #232326;
--rule: #3a3a3e; --wash: #202023;
--accent: #b3261e; --stamp: #db1400;
--bar: #141416;
}
body { background: #1a1a1c; color: #9e9e9e; } /* the visible whole-page shift (step 8) */
body.secret { background: #1a1a1c; color: #9e9e9e; } /* class applied by session.skin() at boot */
body.secret h2 { color: #db1400; }
body.secret a { color: #b3261e; }
+48
View File
@@ -0,0 +1,48 @@
/* surface.css — the public skin of a make-my-arg project.
*
* The ONE file that carries the fiction's palette and type; base.css above stays structure-only.
* Set these tokens from the system's own era and register (a county gazette, a hospital intranet, a
* 1990s BBS), then leave them alone — a page that needs its own colour is a page that has left the
* disguise. Deep pages link secret.css instead (M5); when the profile did not select M5, this file
* is the whole skin.
*
* Palette vocabulary, shared with the site-graph viewer so a generated graph reads as the same
* paper: --paper --ink --rule --stamp. */
:root {
--paper: #f9ebde; /* page ground */
--paper-2: #fffdf9; /* document ground, one step off the page */
--wash: #f7f1e8; /* table headers, quiet fills */
--ink: #4a4a4a; /* body text */
--ink-2: #6b6b6b; /* secondary text, footer */
--rule: #d8c4b0; /* hairlines and borders */
--accent: #c1440e; /* links, buttons, the one warm accent */
--stamp: #a11212; /* seals, warnings, forbidden-state copy */
--bar: #f3e2d0; /* sticky header ground — must stay opaque */
--serif: "Songti SC", "SimSun", "Noto Serif CJK SC", Georgia, serif; /* prose */
--sans: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif; /* nav, data, UI */
--mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; /* numbers, dockets */
--hand: "Kaiti SC", "STKaiti", "KaiTi", cursive; /* hand-copied notes */
}
body {
background: var(--paper);
color: var(--ink);
font-family: var(--serif);
font-size: 16px;
-webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
a:hover { text-decoration: none; }
/* Headings sit in the same serif as the body: a real system does not set its own notices in a
display face. Weight and size carry the hierarchy instead. */
h1, h2, h3 { font-weight: 700; line-height: 1.35; }
/* Quiet, tabular figures anywhere the system prints a number: dockets, dates, counts. */
time, .num, .progress, .doc-no { font-family: var(--mono, monospace); font-variant-numeric: tabular-nums; }
/* Selection keeps the paper register; the M11 black-on-black text overrides it deliberately. */
::selection { background: var(--rule); color: var(--ink); }
+326
View File
@@ -0,0 +1,326 @@
// components.js — the shared kernel every page of a make-my-arg project loads.
//
// Loaded by every page BEFORE the vendored Alpine runtime (script order: base.md §2). It carries
// only what never changes between projects: the md5 primitive, the hash helper, the session store,
// and the readState store. The module components themselves are registered on alpine:init from the
// template files in the skill repo (assets/templates/js/modules/) — copy in ONLY the components
// docs/system-profile.md selected and delete the rest: shipping machinery the profile did not
// select is a module drift (references/common-mistakes.md §6). Never redefine hash / session /
// readState inside a copied body — this file is their single home.
//
// Hash contract (four sides, byte-identical — references/structure/tooling.md §3 item 4):
// this helper · tools/hash.mjs · tools/build-keywords.mjs · tools/check-credentials.mjs
// String(w).trim().toLowerCase() -> md5 -> base64
// Switching algorithms means editing all of them in one change, then re-generating every table
// built under the old rule (R3).
/* ── md5 (RFC 1321) ──────────────────────────────────────────────────────────────
Synchronous and dependency-free: WebCrypto has no MD5, so the primitive lives here. The output
is byte-identical to node:crypto's md5, which is what the tools above compute. */
const md5 = (input) => {
const msg = new TextEncoder().encode(String(input));
const blocks = Math.ceil((msg.length + 9) / 64); // 0x80 pad + 8-byte length
const buf = new Uint8Array(blocks * 64);
buf.set(msg);
buf[msg.length] = 0x80;
const view = new DataView(buf.buffer);
const bits = msg.length * 8; // safe below 2^53 bits
view.setUint32(buf.length - 8, bits >>> 0, true);
view.setUint32(buf.length - 4, Math.floor(bits / 4294967296), true);
// Per-step rotate amounts and the sine-derived constant table (RFC 1321 T[1..64]).
const S = [7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21];
const K = Array.from({ length: 64 }, (_, i) => Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296));
let a0 = 0x67452301, b0 = 0xefcdab89, c0 = 0x98badcfe, d0 = 0x10325476;
for (let off = 0; off < buf.length; off += 64) {
const M = Array.from({ length: 16 }, (_, i) => view.getUint32(off + i * 4, true));
let A = a0, B = b0, C = c0, D = d0;
for (let i = 0; i < 64; i++) {
let F, g;
if (i < 16) { F = (B & C) | (~B & D); g = i; }
else if (i < 32) { F = (D & B) | (~D & C); g = (5 * i + 1) % 16; }
else if (i < 48) { F = B ^ C ^ D; g = (3 * i + 5) % 16; }
else { F = C ^ (B | ~D); g = (7 * i) % 16; }
F = (F + A + K[i] + M[g]) | 0;
A = D; D = C; C = B;
B = (B + ((F << S[i]) | (F >>> (32 - S[i])))) | 0; // rotate left, then add
}
a0 = (a0 + A) | 0; b0 = (b0 + B) | 0; c0 = (c0 + C) | 0; d0 = (d0 + D) | 0;
}
const hex = [];
for (const v of [a0, b0, c0, d0])
for (let i = 0; i < 4; i++) hex.push(((v >>> (i * 8)) & 0xff).toString(16).padStart(2, '0'));
return hex.join('');
};
/* ── hash: the one helper gate inputs and keyword tables are keyed by ─────────────
Mirrors tools/hash.mjs exactly. md5 is hex here, base64 out — never mix the two forms. */
const hash = (w) => btoa(String.fromCharCode(...md5(String(w).trim().toLowerCase()).match(/../g).map((h) => parseInt(h, 16))));
/* ── Session store ──────────────────────────────────────────────────────────────
Access state MUST survive a result opened in a new tab (target="_blank"): per-tab
sessionStorage does not, so the state lives in a session cookie (no max-age/expires → cleared
when the browser closes) with sessionStorage as the private-mode fallback. Rename ACCESS_KEY
per project. Session state is technical, never explained to the player. */
const ACCESS_KEY = 'access', SKIN_KEY = 'skin';
const session = {
_read(key) {
const m = document.cookie.match(new RegExp('(?:^|; )' + key + '=([^;]*)'));
if (m) { try { return JSON.parse(decodeURIComponent(m[1])); } catch (e) { /* fall through */ } }
try { return JSON.parse(sessionStorage.getItem(key) || 'null'); } catch (e) { return null; }
},
_write(key, val) {
const v = encodeURIComponent(JSON.stringify(val));
document.cookie = `${key}=${v}; path=/; SameSite=Lax`; // session cookie: deliberately no expiry
try { sessionStorage.setItem(key, JSON.stringify(val)); } catch (e) { /* private mode */ }
},
access() { return this._read(ACCESS_KEY) || []; },
grant(ids) { this._write(ACCESS_KEY, [...new Set([...this.access(), ...ids])]); },
reskin(name) { if (name) this._write(SKIN_KEY, name); }, // optional: a skin token deep pages apply
skin() { return this._read(SKIN_KEY); },
};
/* ── Read-state store (M14) ─────────────────────────────────────────────────
World-response state (references/guardrails.md R13): an entry appears once its source page was
read. Persist ONLY when docs/system-profile.md records the persistent/world-response contract
(references/structure/form-device.md §3); on a remote system swap localStorage for sessionStorage.
The checker-visible contract is the data-after attribute on the anchor — this store is what the
DOM render reads. Storage is technical, never explained to the player. */
const READ_KEY = 'read'; // rename per project
const readState = {
mark(page) {
try { const s = new Set(JSON.parse(localStorage.getItem(READ_KEY) || '[]')); s.add(page);
localStorage.setItem(READ_KEY, JSON.stringify([...s])); } catch (e) { /* private mode */ }
},
has(page) {
try { return JSON.parse(localStorage.getItem(READ_KEY) || '[]').includes(page); } catch (e) { return false; }
},
};
/* ── Component registration ─────────────────────────────────────────────────────
The vendored runtime auto-starts right after its own script tag, so registrations queue on the
alpine:init event it dispatches before the DOM walk. Register ONLY what the profile selected;
each component body ships as a real file in the skill repo under assets/templates/js/modules/
(step 6a copies the selected bodies into this listener; mount markup: assets/templates/html/, rules:
references/structure/components.md):
search.js (M1) · x-data="search", data-index="data/keywords.surface.json"
gate.js (M2) · x-data="gate", data-expect-hash on each input, data-next / x-show="unlocked"
access.js (M3) · x-data="access", data-access on the protected page (references/structure/form-system.md)
staging.js (M12) · blackout / typewriter / reveal — timers released in destroy()
progress.js (M7) · footer span, data-page / data-total on <body>
read-state.js (M14) · x-data="markRead(page)" on the source page; anchors carry data-after
(references/structure/form-device.md §3–§4)
phone.js (device class phone) · x-data="phone" on the shell
M5 reskin needs no component here: deep pages link secret.css directly and session.reskin() above
carries the token. The stores above (hash / session / readState) are THIS file — copied bodies
depend on them; never redefine one inside a component. No component may route or switch scenes:
Alpine owns in-page lifecycle only (R1). */
/* Project registrations — docs/system-profile.md (Container A + nested D, pure-web):
search (M1) · gate (M2, shapes A/B/C incl. login-multi) · access (M3) · staging (M12) ·
progress (M7, SESSION MODE) · markRead (M14).
State contract: login = kernel session cookie; progress = none persistent — the M7 footer
numbering runs off a session-scoped seen list (the template's localStorage swapped to
sessionStorage per references/structure/form-device.md §3 / components.md §6: remote system,
cleared on browser close, no save/continue/wipe boot surface); world-response = kernel readState
store + markRead + data-after anchors (2 edges, landed in 6b).
Out of the game per the profile: phone.js (pure-web), forbidden.css (M6 off — data/forbidden.json
ships as an empty zero-entry table ONLY because the verbatim search.js fetches it unconditionally;
no forbidden state can fire and no M6 skin is linked). Bodies below are copied verbatim from
assets/templates/js/modules/ except the one sanctioned storage swap in progress.
No component routes or switches scenes (R1). */
document.addEventListener('alpine:init', () => {
// M1 search — Alpine component body. Depends on the starter kernel's hash()
// (assets/starter/assets/js/components.js, byte-identical to tools/hash.mjs).
// Copy into the project's components.js inside the alpine:init listener when the profile selects M1.
// Mount shape: assets/templates/html/search.html (layer scoping, R8; result titles are catalog
// entries, R9; see references/structure/components.md §2).
Alpine.data('search', () => ({
q: '',
state: 'empty', // empty | forbidden | hit | miss
results: [],
forbidden: null,
async init() { // Alpine lifecycle: runs before the component renders
this.q = new URLSearchParams(location.search).get('q')?.trim().toLowerCase() ?? '';
if (!this.q) return;
const enc = hash(this.q);
const forbiddenTable = await (await fetch('data/forbidden.json')).json();
const hit = Object.values(forbiddenTable).find(f => f.keywords.includes(enc));
if (hit) { // State 3: forbidden — full-page reskin (background/title/logo/footer)
this.forbidden = hit;
this.state = 'forbidden';
document.body.classList.add('body-forbidden');
document.querySelector('.progress').textContent = 'ex/36';
return;
}
const map = await (await fetch(this.$el.dataset.index)).json();
this.results = map[enc] ?? [];
this.state = this.results.length ? 'hit' : 'miss';
},
}));
// M2 gate — Alpine component body. Depends on the starter kernel's hash() and session store
// (assets/starter/assets/js/components.js) — do NOT redefine them here; the session cookie helper
// and ACCESS_KEY/SKIN_KEY live in the kernel, shared with the access component (references/structure/components.md §3).
// Shapes and mount markup: assets/templates/html/gate-a.html (navigate on success),
// gate-b.html (unlock in place — the post-gate block must carry x-show="unlocked", the marker
// check-solvable.mjs keys on), login-multi.html (system containers, data-grants map).
// Credential triad + design rules (R3, R4): references/structure/components.md §3.
Alpine.data('gate', () => ({
error: '', busy: false, unlocked: false, successText: '', _t: null,
init() { this.successText = this.$el.dataset.successText || ''; },
submit() {
const el = this.$root; // data-* live on the component root; the submit event's target is the <form>
const inputs = Array.from(el.querySelectorAll('input[data-expect-hash],input[data-expect-any]'));
// Single-box multi-identity (login-multi.html). data-grants is a JSON map on the root:
// { "<account-hash>": { "id": "intern", "pw": ["<pw-hash>", …], "reskin": "secret" }, … }
// It resolves WHICH identity the typed account grants and validates the password against that identity,
// so one login box can serve several roles without splitting into several forms on the page. data-grant
// stays on the root as the flat list of identities check-solvable walks; data-grants is the runtime truth.
let ok, grantIds = [];
if (el.dataset.grants) {
const map = JSON.parse(el.dataset.grants);
const acc = inputs.find((i) => i.type !== 'password');
const pw = inputs.find((i) => i.type === 'password');
const entry = acc ? map[hash(acc.value || '')] : null;
ok = !!entry && (!pw || (entry.pw || []).includes(hash(pw.value || ''))); // account+password are paired
if (ok) { grantIds = entry.id ? [entry.id] : []; session.reskin(entry.reskin); }
} else {
// Legacy / multi-field gates: every data-expect-hash input must match; data-expect-any accepts any
// non-empty value (a declared wildcard, references/structure/form-device.md §4); data-grant is unconditional.
ok = inputs.length > 0 && inputs.every((inp) => {
if (inp.dataset.expectAny) return (inp.value || '').trim() !== '';
const expects = (inp.dataset.expectHash || '').split(',').map((s) => s.trim()).filter(Boolean);
return expects.includes(hash(inp.value || ''));
});
grantIds = (el.dataset.grant || '').split(',').map((s) => s.trim()).filter(Boolean);
}
if (ok) {
if (grantIds.length) session.grant(grantIds);
const next = el.dataset.next;
const hold = parseInt(el.dataset.successHold || '0', 10);
const staged = this.successText && hold > 0;
const finish = () => { if (next) location.href = next; else { this.busy = false; this.unlocked = true; } };
if (staged) { this.busy = true; this._t = setTimeout(finish, hold); } else finish();
return;
}
this.error = el.dataset.failHint || 'Verification failed.'; // inline red text; a bare alert breaks the facade
el.animate([{ transform: 'translateX(0)' }, { transform: 'translateX(-6px)' },
{ transform: 'translateX(6px)' }, { transform: 'translateX(0)' }], 320);
},
destroy() { clearTimeout(this._t); },
}));
// M3 access — Alpine component body. Depends on the starter kernel's session store
// (assets/starter/assets/js/components.js — cookie-first, sessionStorage fallback in private mode);
// do NOT redefine session or hash here. Copy into the project's components.js inside the
// alpine:init listener when the profile selects M3 (system containers B/C/D).
// Mount shape: assets/templates/html/access-protected.html (references/structure/form-system.md §3).
// The x-show="unlocked" block is the marker check-solvable.mjs keys on; a page opens ONLY to the
// accounts it names — no privilege ladder (R10).
Alpine.data('access', () => ({
unlocked: false,
init() {
const held = session.access(); // kernel helper: cross-tab session cookie
const need = (this.$el.dataset.access || '').split(',').map((s) => s.trim()).filter(Boolean);
this.unlocked = need.some((r) => (r === '*' ? held.length > 0 : held.includes(r)));
const skin = session.skin(); // optional reskin token granted at login (M5)
if (skin) document.body.classList.add(skin);
},
}));
// M12 interaction staging — Alpine component bodies: blackout / typewriter / reveal.
// All timers and observers are registered in init() and released in destroy(), so a staged
// effect survives or dies with its component. Copy the selected bodies into the project's
// components.js inside the alpine:init listener when the profile selects M12.
// Sensory variants (audio puzzle, flashlight mask) live in the fiction's own page; the same
// lifecycle rule holds. references/design-playbook.md §2 M12; declare hardware on the entry page (step 8).
// "The system has noticed you": delayed blackout after unlock; optional `next` navigates 5s later.
Alpine.data('blackout', (delay = 3000, text = '', next = null) => ({
visible: false, text, showTimer: null, exitTimer: null,
init() {
this.showTimer = setTimeout(() => {
this.visible = true;
if (next) this.exitTimer = setTimeout(() => (location.href = next), 5000);
}, delay);
},
destroy() { clearTimeout(this.showTimer); clearTimeout(this.exitTimer); },
}));
// mount: <div class="blackout" x-data="blackout(4000, 'The system has noticed you')" x-show="visible" x-transition x-cloak x-text="text"></div>
// Delete the element's original text character by character, then retype newText — ceremonial effect.
Alpine.data('typewriter', (newText, speed = 60) => ({
output: '', timer: null,
init() {
const original = this.$el.textContent;
let i = original.length;
this.output = original;
this.timer = setInterval(() => {
this.output = original.slice(0, --i);
if (i > 0) return;
clearInterval(this.timer);
let j = 0;
this.timer = setInterval(() => {
this.output = newText.slice(0, ++j);
if (j >= newText.length) clearInterval(this.timer);
}, speed);
}, speed);
},
destroy() { clearInterval(this.timer); },
}));
// mount: <p x-data="typewriter('Access granted. Do not look back.')" x-text="output"></p>
// Scroll reveal: IntersectionObserver owned by the component, controlling reading pace.
Alpine.data('reveal', () => ({
shown: false, observer: null,
init() {
this.observer = new IntersectionObserver(([entry]) => {
if (!entry.isIntersecting) return;
this.shown = true;
this.observer.disconnect();
});
this.observer.observe(this.$el);
},
destroy() { this.observer?.disconnect(); },
}));
// mount: <div class="reveal" :class="{ shown }" x-data="reveal">…</div> .reveal{opacity:0;transition:opacity .6s}.reveal.shown{opacity:1}
// M14 read-state — the runtime side of world-response state (references/guardrails.md R13): an entry
// appears once its source page was read. The STORE (readState + READ_KEY) lives in the starter kernel
// (assets/starter/assets/js/components.js) — never redefine it here. This file adds only the mount
// component: the SOURCE page marks itself as read by carrying it.
// The CHECKER-visible contract is the data-after attribute on the entry anchor
// (assets/templates/html/read-entry.html): keep the page path written in data-after and in the
// markRead(...) argument identical, or the walk proves an order the DOM does not render
// (references/structure/form-device.md §4).
// Persist ONLY when docs/system-profile.md records the persistent/world-response contract; the kernel
// store is where `progress: session` swaps localStorage for sessionStorage.
//
// Mount on the SOURCE page's <main> so opening it marks the read:
// <main x-data="markRead('pages/forum/thread-fenglou.html')">
Alpine.data('markRead', (page) => ({ init() { readState.mark(page); } }));
// M7 collection progress — Alpine component body (assets/templates/js/modules/progress.js).
// State contract: NO persistence — this is the template's verbatim body with the single
// sanctioned storage swap localStorage -> sessionStorage (references/structure/form-device.md §3:
// session-only or none for a remote system; docs/system-profile.md records `none`).
// Mount on the shared footer: <footer x-data="progress"> … <span class="progress"
// x-text="seen.length + '/' + document.body.dataset.total">. <body data-page data-total> carries
// the numbering. The static span text stays as the no-JS / pre-boot fallback.
Alpine.data('progress', () => ({
seen: [],
init() {
this.seen = JSON.parse(sessionStorage.getItem('seen') ?? '[]');
const n = document.body.dataset.page;
if (n && !this.seen.includes(n)) this.seen.push(n);
sessionStorage.setItem('seen', JSON.stringify(this.seen));
},
}));
});
+21
View File
File diff suppressed because one or more lines are too long