@wildwinter/app-shell 0.40.0 → 0.40.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/README.md +7 -0
- package/dist/{chunk-DS4XXAZS.js → chunk-4OAORWEM.js} +2 -2
- package/dist/chunk-4OAORWEM.js.map +1 -0
- package/dist/{chunk-SDOKZTAR.js → chunk-G2JT3HZH.js} +15 -2
- package/dist/chunk-G2JT3HZH.js.map +1 -0
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/link-status.cjs +13 -0
- package/dist/link-status.cjs.map +1 -1
- package/dist/link-status.js +1 -1
- package/dist/problems.cjs.map +1 -1
- package/dist/problems.js +1 -1
- package/dist/stepper.css +1 -0
- package/dist/stepper.css.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-DS4XXAZS.js.map +0 -1
- package/dist/chunk-SDOKZTAR.js.map +0 -1
package/README.md
CHANGED
|
@@ -131,6 +131,13 @@ needing and never had.
|
|
|
131
131
|
revealRow(document, "mood");
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
+
- **`--linkstatus-reserve`** - how much of the window's bottom-right corner the
|
|
135
|
+
live-link chip takes, published on the document while the chip is visible (`0px`
|
|
136
|
+
while hidden) and re-measured as its address comes and goes. The chip floats over
|
|
137
|
+
that corner, and both apps had things drawn under it. The stepper bar leaves the
|
|
138
|
+
room itself; a host strip that can end in the corner opts in with
|
|
139
|
+
`padding-right: calc(<its own> + var(--linkstatus-reserve, 0px))`.
|
|
140
|
+
|
|
134
141
|
- **`--ok`** joins `--danger` and `--warn` in `tokens.css`, with a `light-dark()`
|
|
135
142
|
default every palette should override in its own `theme.css`. It is the only
|
|
136
143
|
colour in the grammar layer, and it is there because it kept not being
|
|
@@ -52,5 +52,5 @@ var defaultProblemCopy = {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export { defaultProblemCopy, describeProblem, problemLine, problemName };
|
|
55
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AAA,EAAG,WAAA,CAAY,CAAC,CAAC,CAAA,cAAA,CAAA,EAAiB,CAAA;AAAA,EAClE,OAAA,EAAS,CAAC,CAAA,MAAO;AAAA,IACf,IAAA,EAAM,CAAA,EAAG,WAAA,CAAY,CAAC,CAAC,CAAA,UAAA,CAAA;AAAA,IACvB,IAAA,EAAM;AAAA,GACR,CAAA;AAAA,EACA,aAAA,EAAe,CAAC,CAAA,MAAO;AAAA,IACrB,IAAA,EAAM,sBAAsB,CAAA,CAAE,IAAA,GAAO,KAAK,CAAA,CAAE,IAAI,MAAM,EAAE,CAAA,gBAAA,CAAA;AAAA,IACxD,IAAA,EAAM;AAAA,GACR,CAAA;AAAA,EACA,gBAAA,EAAkB,CAAC,CAAA,MAAO;AAAA,IACxB,IAAA,EAAM,CAAA,EAAG,CAAA,CAAE,IAAA,IAAQ,WAAW,CAAA,8CAAA,CAAA;AAAA,IAC9B,IAAA,EAAM;AAAA,GACR;AACF","file":"chunk-4OAORWEM.js","sourcesContent":["// ---------------------------------------------------------------------------\n// Problem copy: a validator's diagnostic rewritten for the person at the\n// keyboard, through a table the app fills.\n//\n// Patterpad's `humanizeProblem` (its renderer.ts) proved the shape: a dozen\n// validator categories each mapped to a plain sentence with a next step, naming\n// things by their title, and a fallback that softens the technical residue.\n// Storyletter showed the raw compiler string and labelled it `path [where]`\n// (ui-review-2026-09, finding 17), the bracketed id that \"Diagnostics name what\n// the author can see\" (design-language.md) rules out for anything but a\n// DANGLING reference. This module is the translator; the tables are the\n// apps', because the codes are theirs. `defaultProblemCopy` covers the handful\n// of codes both validators raise in some form, as a floor an app spreads into\n// its own table.\n// ---------------------------------------------------------------------------\n\n/** What a translator needs to know about a problem. `code` is the app's own\n * category (Patterpad's `detail`, or a code Storyletter derives from its\n * compiler message); `title` is the author-facing name of the thing the\n * problem is about, when the app can resolve one; `where` is the raw\n * reference (an id) for when it cannot. */\nexport interface ProblemLike {\n code?: string;\n message: string;\n path?: string;\n where?: string;\n title?: string;\n}\n\nexport interface ProblemCopy {\n /** The sentence: what is wrong, in the author's words. */\n text: string;\n /** What to do about it, when there is one thing to do. */\n next?: string;\n /** The reference this problem is about no longer has a name to give, so the\n * raw id may be shown, written `(id ...)` so it cannot be mistaken for a\n * name. Set by the table entry; the translator never guesses it. */\n dangling?: boolean;\n}\n\nexport type ProblemCopyEntry = (problem: ProblemLike) => ProblemCopy;\nexport type ProblemCopyTable = Record<string, ProblemCopyEntry>;\n\n/** The name to call the thing a problem is about: its title in curly quotes,\n * \"(id ...)\" only when the reference dangles and there is nothing else,\n * and \"This\" otherwise, because the bar's \"go to\" shows the reader what\n * \"this\" is and an id is not something they can look for. */\nexport function problemName(p: ProblemLike, dangling = false): string {\n if (p.title) return `“${p.title}”`;\n if (dangling && p.where) return `(id ${p.where})`;\n return \"This\";\n}\n\n/**\n * Translate `problem` through `table`. A matching entry decides the copy; with\n * no entry the raw message is kept and prefixed by the title when there is one\n * (\"Burner Rig: duplicate id\"). Nothing here ever writes `[where]`; an id\n * appears only as `(id ...)`, only when the entry says the reference dangles,\n * and only when there is no title to say instead.\n */\nexport function describeProblem(problem: ProblemLike, table: ProblemCopyTable = {}): ProblemCopy {\n const entry = problem.code ? table[problem.code] : undefined;\n if (entry) {\n const copy = entry(problem);\n const text = copy.dangling && !problem.title && problem.where && !copy.text.includes(`(id ${problem.where})`)\n ? `${copy.text} (id ${problem.where})`\n : copy.text;\n return copy.next ? { text, next: copy.next } : { text };\n }\n const message = problem.message.replace(/\\s*\\[[^\\]]*\\]\\s*$/, \"\").trim();\n return { text: problem.title ? `${problem.title}: ${message}` : message };\n}\n\n/** `describeProblem` as one line for a bar that has room for one: the sentence,\n * then the next step after a space. */\nexport function problemLine(problem: ProblemLike, table?: ProblemCopyTable): string {\n const { text, next } = describeProblem(problem, table);\n return next ? `${text} ${next}` : text;\n}\n\n/**\n * The codes both validators raise in some form, in the family's voice. An app\n * spreads this into its own table and adds its own codes over it; a code an\n * app does not raise costs nothing.\n *\n * duplicate-gameid two things share one Game ID\n * invalid-gameid a Game ID that breaks the address rule\n * dangling-reference a jump / tag / property points at something gone\n * unknown-property a condition or effect names an undeclared property\n * missing-name a thing that needs a name has none\n * empty a container with nothing in it\n * stale-build the playable build is older than the source\n * merge-conflict a file still carries conflict markers\n */\nexport const defaultProblemCopy: ProblemCopyTable = {\n \"duplicate-gameid\": (p) => ({\n text: `The Game ID on ${problemName(p)} is already used elsewhere.`,\n next: \"Each one must be unique; change one of them.\",\n }),\n \"invalid-gameid\": (p) => ({\n text: `The Game ID on ${problemName(p)} isn't valid.`,\n next: \"Use lowercase letters, digits and hyphens.\",\n }),\n \"dangling-reference\": (p) => ({\n text: `${problemName(p, true)} points at something that no longer exists.`,\n next: \"Choose where it goes.\",\n dangling: true,\n }),\n \"unknown-property\": (p) => ({\n text: `${problemName(p)} uses a property that isn't set up yet.`,\n next: \"Declare it in the project settings, or fix the name.\",\n }),\n \"missing-name\": (p) => ({ text: `${problemName(p)} needs a name.` }),\n \"empty\": (p) => ({\n text: `${problemName(p)} is empty.`,\n next: \"Add something inside it, or remove it.\",\n }),\n \"stale-build\": (p) => ({\n text: `Your playable build${p.path ? ` (${p.path})` : \"\"} is out of date.`,\n next: \"It refreshes the next time you publish.\",\n }),\n \"merge-conflict\": (p) => ({\n text: `${p.path ?? \"This file\"} still has an unresolved merge conflict in it.`,\n next: \"Resolve it in your version control tool, then reopen the project.\",\n }),\n};\n"]}
|
|
@@ -27,6 +27,8 @@ function linkAddress(s) {
|
|
|
27
27
|
if (s.state !== "listening" && s.state !== "connected") return void 0;
|
|
28
28
|
return s.address ?? `ws://127.0.0.1:${s.port}`;
|
|
29
29
|
}
|
|
30
|
+
var CORNER_INSET = 14.5;
|
|
31
|
+
var CORNER_GAP = 12;
|
|
30
32
|
function mountLinkStatus(host, opts) {
|
|
31
33
|
const wrap = el("div", "linkstatus");
|
|
32
34
|
wrap.hidden = true;
|
|
@@ -40,6 +42,15 @@ function mountLinkStatus(host, opts) {
|
|
|
40
42
|
wrap.append(...opts.lead ?? [], url, toggle);
|
|
41
43
|
host.append(wrap);
|
|
42
44
|
let status = { state: "off" };
|
|
45
|
+
const root = host.ownerDocument.documentElement;
|
|
46
|
+
const publishReserve = () => {
|
|
47
|
+
const width = wrap.hidden ? 0 : wrap.getBoundingClientRect().width;
|
|
48
|
+
root.style.setProperty(
|
|
49
|
+
"--linkstatus-reserve",
|
|
50
|
+
width > 0 ? `${Math.ceil(width + CORNER_INSET + CORNER_GAP)}px` : "0px"
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
if (typeof ResizeObserver !== "undefined") new ResizeObserver(publishReserve).observe(wrap);
|
|
43
54
|
const render = () => {
|
|
44
55
|
toggle.className = `linkstatus-toggle ${linkStatusClass(status)}`;
|
|
45
56
|
const tip = linkStatusTip(status);
|
|
@@ -51,6 +62,7 @@ function mountLinkStatus(host, opts) {
|
|
|
51
62
|
url.dataset["tip"] = "Click to copy the live link address";
|
|
52
63
|
url.hidden = false;
|
|
53
64
|
} else url.hidden = true;
|
|
65
|
+
publishReserve();
|
|
54
66
|
};
|
|
55
67
|
const apply = (s) => {
|
|
56
68
|
status = s;
|
|
@@ -75,6 +87,7 @@ function mountLinkStatus(host, opts) {
|
|
|
75
87
|
status: () => status,
|
|
76
88
|
setVisible(on) {
|
|
77
89
|
wrap.hidden = !on;
|
|
90
|
+
publishReserve();
|
|
78
91
|
},
|
|
79
92
|
toggle() {
|
|
80
93
|
toggle.click();
|
|
@@ -83,5 +96,5 @@ function mountLinkStatus(host, opts) {
|
|
|
83
96
|
}
|
|
84
97
|
|
|
85
98
|
export { linkAddress, linkStatusClass, linkStatusTip, mountLinkStatus };
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
99
|
+
//# sourceMappingURL=chunk-G2JT3HZH.js.map
|
|
100
|
+
//# sourceMappingURL=chunk-G2JT3HZH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src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AAA,CAAI,gBAAA,CAAiB,SAAS,MAAM;AAClC,IAAA,MAAM,IAAA,GAAO,IAAI,WAAA,IAAe,EAAA;AAChC,IAAA,IAAI,CAAC,IAAA,EAAM;AACX,IAAA,KAAK,gBAAA,CAAiB,KAAK,IAAI,CAAA;AAC/B,IAAA,IAAA,CAAK,SAAS,IAAI,CAAA;AAAA,EACpB,CAAC,CAAA;AAED,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,IAAA;AAAA,IAAM,KAAA;AAAA,IACV,QAAQ,MAAM,MAAA;AAAA,IACd,WAAW,EAAA,EAAmB;AAAE,MAAA,IAAA,CAAK,SAAS,CAAC,EAAA;AAAI,MAAA,cAAA,EAAe;AAAA,IAAG,CAAA;AAAA,IACrE,MAAA,GAAe;AAAE,MAAA,MAAA,CAAO,KAAA,EAAM;AAAA,IAAG;AAAA,GACnC;AACF","file":"chunk-G2JT3HZH.js","sourcesContent":["// ---------------------------------------------------------------------------\n// The live-link status chip: a compact control in the bottom-right corner for\n// the loopback server a running game connects to. All the state collapses to\n// one coloured \"connect\" icon (grey off, amber listening, green connected and\n// in sync, red connected on a different build); click it to toggle the link\n// (off -> listening -> stop), and while the link is up the copiable ws://\n// address sits beside it. Patterpad's debug-panel.ts and Storyletter's\n// live-link.ts were this file twice, character for character down to the\n// 1000ms `.copied` revert. Styles ship as link-status.css.\n//\n// What the game sends is the app's business; this is the control and the\n// status only.\n// ---------------------------------------------------------------------------\n\nimport { el } from \"./dom.js\";\nimport { iconNode } from \"./icons.js\";\nimport { copyWithFeedback } from \"./util.js\";\n\nexport type LinkStatus =\n | { state: \"off\" }\n | { state: \"error\"; message: string }\n | { state: \"listening\"; port: number; address?: string }\n | {\n state: \"connected\"; port: number; address?: string;\n /** What connected, if it said. */\n project?: string;\n /** Whether the game's build matches the editor's. */\n build?: \"match\" | \"stale\" | \"unknown\";\n /** One extra sentence for the tip (Storyletter names the live boxes). */\n note?: string;\n };\n\n/** The chip's colour class for a state: the four. */\nexport type LinkStatusClass = \"off\" | \"listening\" | \"live\" | \"stale\";\n\nexport interface LinkStatusOptions {\n /** A word beside the chip (\"Live link\"), so a bottom-corner plug is not a\n * mystery. Omitted draws none. */\n label?: string;\n /** Start when off or failed, stop otherwise. A returned status is applied;\n * a status pushed later through `apply` works as well. */\n onToggle: (current: LinkStatus) => LinkStatus | void | Promise<LinkStatus | void>;\n /** Runs after the address is copied. The copy itself is the chip's. */\n onCopy?: (address: string) => void;\n /** Controls before the address (Patterpad's flow picker). */\n lead?: HTMLElement[];\n}\n\nexport interface LinkStatusChip {\n el: HTMLElement;\n apply(status: LinkStatus): void;\n status(): LinkStatus;\n /** Show / hide the control (shown when a project is open). */\n setVisible(on: boolean): void;\n /** Toggle the link (a menu item routes here). */\n toggle(): void;\n}\n\nexport function linkStatusClass(s: LinkStatus): LinkStatusClass {\n if (s.state === \"off\" || s.state === \"error\") return \"off\";\n if (s.state === \"listening\") return \"listening\";\n return s.build === \"stale\" ? \"stale\" : \"live\";\n}\n\n/** The tooltip, spelling the state out. One wording for the family. */\nexport function linkStatusTip(s: LinkStatus): string {\n switch (s.state) {\n case \"off\": return \"Live link is off. Click to start listening.\";\n case \"error\": return `Live link failed (${s.message}). Click to retry.`;\n case \"listening\": return \"Live link is listening for a game. Click to stop.\";\n case \"connected\": {\n const who = s.project !== undefined ? ` to ${s.project}` : \"\";\n const build = s.build === \"stale\" ? \" on a different build, so save or rebuild to re-sync\"\n : s.build === \"match\" ? \" and in sync\" : \"\";\n const note = s.note ? ` ${s.note}` : \"\";\n return `Live link is connected${who}${build}.${note} Click to stop.`;\n }\n }\n}\n\n/** The address a game connects to. */\nexport function linkAddress(s: LinkStatus): string | undefined {\n if (s.state !== \"listening\" && s.state !== \"connected\") return undefined;\n return s.address ?? `ws://127.0.0.1:${s.port}`;\n}\n\n/** Where the chip sits, which link-status.css says too: its right inset, and the\n * breathing room anything beside it keeps. Kept beside the reserve that uses\n * them, since the reserve is a promise about the CSS. */\nconst CORNER_INSET = 14.5;\nconst CORNER_GAP = 12;\n\n/** Mount the chip into `host` (document.body in both apps: it is fixed to the\n * window's corner). Hidden until `setVisible(true)`. */\nexport function mountLinkStatus(host: HTMLElement, opts: LinkStatusOptions): LinkStatusChip {\n const wrap = el(\"div\", \"linkstatus\"); wrap.hidden = true;\n const url = el(\"button\", \"linkstatus-url\"); url.type = \"button\"; url.hidden = true;\n const toggle = el(\"button\", \"linkstatus-toggle off\"); toggle.type = \"button\"; toggle.append(iconNode(\"connect\"));\n if (opts.label !== undefined) wrap.append(el(\"span\", \"linkstatus-word\", opts.label));\n wrap.append(...(opts.lead ?? []), url, toggle);\n host.append(wrap);\n\n let status: LinkStatus = { state: \"off\" };\n\n // The corner the chip floats over belongs to whatever the host put there: a\n // problems bar's error link and its buttons, a canvas strip's last control.\n // Both apps had it drawn under the chip (2026-09-17). So the chip publishes\n // how much of the corner it takes, as --linkstatus-reserve on the document,\n // and the things that can sit there leave that much room (the stepper bar\n // does, in stepper.css; a host's own strips opt in). 0px while hidden.\n // Re-measured on every render, because the address comes and goes, and on a\n // resize where the platform offers one, because a web font landing moves it.\n const root = host.ownerDocument.documentElement;\n const publishReserve = (): void => {\n const width = wrap.hidden ? 0 : wrap.getBoundingClientRect().width;\n root.style.setProperty(\"--linkstatus-reserve\",\n width > 0 ? `${Math.ceil(width + CORNER_INSET + CORNER_GAP)}px` : \"0px\");\n };\n if (typeof ResizeObserver !== \"undefined\") new ResizeObserver(publishReserve).observe(wrap);\n\n const render = (): void => {\n toggle.className = `linkstatus-toggle ${linkStatusClass(status)}`;\n const tip = linkStatusTip(status);\n toggle.dataset[\"tip\"] = tip;\n toggle.setAttribute(\"aria-label\", tip);\n // The copiable address means something once the server is up.\n const addr = linkAddress(status);\n if (addr !== undefined) {\n url.textContent = addr;\n url.dataset[\"tip\"] = \"Click to copy the live link address\";\n url.hidden = false;\n } else url.hidden = true;\n publishReserve();\n };\n const apply = (s: LinkStatus): void => { status = s; render(); };\n render();\n\n toggle.addEventListener(\"click\", () => {\n const out = opts.onToggle(status);\n void Promise.resolve(out).then((next) => { if (next) apply(next); });\n });\n url.addEventListener(\"click\", () => {\n const addr = url.textContent ?? \"\";\n if (!addr) return;\n void copyWithFeedback(url, addr);\n opts.onCopy?.(addr);\n });\n\n return {\n el: wrap, apply,\n status: () => status,\n setVisible(on: boolean): void { wrap.hidden = !on; publishReserve(); },\n toggle(): void { toggle.click(); },\n };\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -2789,6 +2789,8 @@ function linkAddress(s) {
|
|
|
2789
2789
|
if (s.state !== "listening" && s.state !== "connected") return void 0;
|
|
2790
2790
|
return s.address ?? `ws://127.0.0.1:${s.port}`;
|
|
2791
2791
|
}
|
|
2792
|
+
var CORNER_INSET = 14.5;
|
|
2793
|
+
var CORNER_GAP = 12;
|
|
2792
2794
|
function mountLinkStatus(host, opts) {
|
|
2793
2795
|
const wrap = el("div", "linkstatus");
|
|
2794
2796
|
wrap.hidden = true;
|
|
@@ -2802,6 +2804,15 @@ function mountLinkStatus(host, opts) {
|
|
|
2802
2804
|
wrap.append(...opts.lead ?? [], url, toggle);
|
|
2803
2805
|
host.append(wrap);
|
|
2804
2806
|
let status = { state: "off" };
|
|
2807
|
+
const root = host.ownerDocument.documentElement;
|
|
2808
|
+
const publishReserve = () => {
|
|
2809
|
+
const width = wrap.hidden ? 0 : wrap.getBoundingClientRect().width;
|
|
2810
|
+
root.style.setProperty(
|
|
2811
|
+
"--linkstatus-reserve",
|
|
2812
|
+
width > 0 ? `${Math.ceil(width + CORNER_INSET + CORNER_GAP)}px` : "0px"
|
|
2813
|
+
);
|
|
2814
|
+
};
|
|
2815
|
+
if (typeof ResizeObserver !== "undefined") new ResizeObserver(publishReserve).observe(wrap);
|
|
2805
2816
|
const render = () => {
|
|
2806
2817
|
toggle.className = `linkstatus-toggle ${linkStatusClass(status)}`;
|
|
2807
2818
|
const tip2 = linkStatusTip(status);
|
|
@@ -2813,6 +2824,7 @@ function mountLinkStatus(host, opts) {
|
|
|
2813
2824
|
url.dataset["tip"] = "Click to copy the live link address";
|
|
2814
2825
|
url.hidden = false;
|
|
2815
2826
|
} else url.hidden = true;
|
|
2827
|
+
publishReserve();
|
|
2816
2828
|
};
|
|
2817
2829
|
const apply = (s) => {
|
|
2818
2830
|
status = s;
|
|
@@ -2837,6 +2849,7 @@ function mountLinkStatus(host, opts) {
|
|
|
2837
2849
|
status: () => status,
|
|
2838
2850
|
setVisible(on) {
|
|
2839
2851
|
wrap.hidden = !on;
|
|
2852
|
+
publishReserve();
|
|
2840
2853
|
},
|
|
2841
2854
|
toggle() {
|
|
2842
2855
|
toggle.click();
|