@starci/gallery 0.0.0-stage → 0.1.0
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 +13 -0
- package/LICENSE +21 -0
- package/README.md +38 -2
- package/dist/app/App.d.ts +2 -0
- package/dist/app/App.js +77 -0
- package/dist/app/ExplainPanel.d.ts +13 -0
- package/dist/app/ExplainPanel.js +35 -0
- package/dist/app/FlowMap.d.ts +9 -0
- package/dist/app/FlowMap.js +14 -0
- package/dist/app/Legend.d.ts +6 -0
- package/dist/app/Legend.js +9 -0
- package/dist/app/Lightbox.d.ts +18 -0
- package/dist/app/Lightbox.js +66 -0
- package/dist/app/States.d.ts +10 -0
- package/dist/app/States.js +23 -0
- package/dist/app/Tree.d.ts +11 -0
- package/dist/app/Tree.js +30 -0
- package/dist/app/Viewer.d.ts +44 -0
- package/dist/app/Viewer.js +114 -0
- package/dist/app/app.css +415 -0
- package/dist/app/cap.d.ts +2 -0
- package/dist/app/cap.js +4 -0
- package/dist/app/data.d.ts +9 -0
- package/dist/app/data.js +3 -0
- package/dist/app/inline.d.ts +5 -0
- package/dist/app/inline.js +13 -0
- package/dist/app/main.d.ts +1 -0
- package/dist/app/main.js +9 -0
- package/dist/app/media.d.ts +3 -0
- package/dist/app/media.js +17 -0
- package/dist/app/route.d.ts +15 -0
- package/dist/app/route.js +29 -0
- package/dist/app/status.d.ts +8 -0
- package/dist/app/status.js +9 -0
- package/dist/explain.d.ts +45 -0
- package/dist/explain.js +132 -0
- package/dist/frames.d.ts +2 -0
- package/dist/frames.js +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/labels.d.ts +252 -0
- package/dist/labels.js +177 -0
- package/dist/load.d.ts +35 -0
- package/dist/load.js +163 -0
- package/dist/model.d.ts +92 -0
- package/dist/model.js +112 -0
- package/dist/views.d.ts +6 -0
- package/dist/views.js +12 -0
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +110 -0
- package/package.json +89 -4
package/dist/explain.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Reads one explain.md: a front matter (title, route, area) and one "## <Region>" per visible region, each with the lines "Vì sao:", "Luật:" and "Grammar:".
|
|
2
|
+
// A region is a bug when it lacks a Vì sao or Grammar value, or when a value starts with CHƯA RÕ or SAI. `starci app check` judges the same file by the same rules
|
|
3
|
+
// (HFS_APP_GALLERY_*, packages/hfs/runtime/scripts/hfs/gallery-explain.mts); the hfs specs keep the two readers answering alike.
|
|
4
|
+
export const FIELDS = ["Vì sao", "Luật", "Grammar"];
|
|
5
|
+
const REQUIRED = ["Vì sao", "Grammar"];
|
|
6
|
+
const UNCLEAR = /^(?:CHƯA RÕ|SAI)(?![\p{L}\p{N}])/u;
|
|
7
|
+
const fieldPattern = (field) => new RegExp(`^\\s*(?:[-*]\\s*)?\\*{0,2}${field}\\*{0,2}:\\*{0,2}[ \\t]*`, "iu");
|
|
8
|
+
const PATTERNS = FIELDS.map((field) => [field, fieldPattern(field)]);
|
|
9
|
+
/** The only widths a screen is shot at; a state or an agent variant is its own screen folder. */
|
|
10
|
+
export const SHOT_WIDTHS = ["1440", "390"];
|
|
11
|
+
export function parseExplain(markdown) {
|
|
12
|
+
let body = markdown.normalize("NFC").replace(/\r\n/gu, "\n");
|
|
13
|
+
const meta = {};
|
|
14
|
+
const front = /^---\n([\s\S]*?)\n---\n?/u.exec(body);
|
|
15
|
+
if (front) {
|
|
16
|
+
for (const line of (front[1] ?? "").split("\n")) {
|
|
17
|
+
const pair = /^(\w+):\s*(.*)$/u.exec(line);
|
|
18
|
+
if (pair?.[1] !== undefined)
|
|
19
|
+
meta[pair[1]] = (pair[2] ?? "").replace(/^["']|["']$/gu, "").trim();
|
|
20
|
+
}
|
|
21
|
+
body = body.slice(front[0].length);
|
|
22
|
+
}
|
|
23
|
+
const regions = [];
|
|
24
|
+
const intro = [];
|
|
25
|
+
let current = null;
|
|
26
|
+
let last = null;
|
|
27
|
+
for (const line of body.split("\n")) {
|
|
28
|
+
const heading = /^##\s+(.+?)\s*$/u.exec(line);
|
|
29
|
+
if (heading?.[1] !== undefined) {
|
|
30
|
+
current = { name: heading[1], fields: {}, problems: [] };
|
|
31
|
+
regions.push(current);
|
|
32
|
+
last = null;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (!current) {
|
|
36
|
+
intro.push(line);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const hit = PATTERNS.find(([, pattern]) => pattern.test(line));
|
|
40
|
+
if (hit) {
|
|
41
|
+
current.fields[hit[0]] = line.replace(hit[1], "").trim();
|
|
42
|
+
last = hit[0];
|
|
43
|
+
}
|
|
44
|
+
else if (last !== null && line.trim() !== "") {
|
|
45
|
+
current.fields[last] = `${current.fields[last] ?? ""} ${line.trim()}`.trim();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for (const region of regions) {
|
|
49
|
+
for (const field of FIELDS) {
|
|
50
|
+
const value = region.fields[field];
|
|
51
|
+
if (REQUIRED.includes(field) && !value)
|
|
52
|
+
region.problems.push({ kind: "missing", field });
|
|
53
|
+
else if (value && UNCLEAR.test(value))
|
|
54
|
+
region.problems.push({ kind: "unclear", field });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { meta, intro: intro.join("\n").trim(), regions };
|
|
58
|
+
}
|
|
59
|
+
const plain = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
60
|
+
/** links.json of a screen: an array, or { links: [...] }, of { to, x, y, w, h } hotspots (fractions of the shot); empty when malformed. */
|
|
61
|
+
export function linkList(json) {
|
|
62
|
+
const list = Array.isArray(json) ? json : plain(json) && Array.isArray(json.links) ? json.links : null;
|
|
63
|
+
if (!list?.every((link) => plain(link) && typeof link.to === "string" && link.to !== ""))
|
|
64
|
+
return [];
|
|
65
|
+
return list;
|
|
66
|
+
}
|
|
67
|
+
/** flows.json: { "<name>": ["<area>/<screen>", ...] } or [{ name, screens }]; empty when malformed. */
|
|
68
|
+
export function flowList(json) {
|
|
69
|
+
const entries = Array.isArray(json)
|
|
70
|
+
? json.map((flow) => (plain(flow) ? [flow.name, flow.screens] : [undefined, undefined]))
|
|
71
|
+
: plain(json)
|
|
72
|
+
? Object.entries(json)
|
|
73
|
+
: [];
|
|
74
|
+
const ok = entries.every(([name, screens]) => typeof name === "string" && name !== "" && Array.isArray(screens) && screens.every((id) => typeof id === "string" && id !== ""));
|
|
75
|
+
return ok ? entries.map(([name, screens]) => ({ name: name, screens: screens })) : [];
|
|
76
|
+
}
|
|
77
|
+
const ENTITIES = { "&": "&", "<": "<", ">": ">", """: '"', "'": "'", " ": " " };
|
|
78
|
+
/** The inline markup of a canvas note as markdown: code and bold kept, every other tag dropped, entities decoded. */
|
|
79
|
+
const inlineMarkdown = (html) => html
|
|
80
|
+
.replace(/<br\s*\/?>/giu, " ")
|
|
81
|
+
.replace(/<code[^>]*>([\s\S]*?)<\/code>/giu, "`$1`")
|
|
82
|
+
.replace(/<(?:b|strong)[^>]*>([\s\S]*?)<\/(?:b|strong)>/giu, "**$1**")
|
|
83
|
+
.replace(/<[^>]+>/gu, "")
|
|
84
|
+
.replace(/&(?:amp|lt|gt|quot|#39|nbsp);/gu, (entity) => ENTITIES[entity] ?? entity)
|
|
85
|
+
.replace(/\s+/gu, " ")
|
|
86
|
+
.trim();
|
|
87
|
+
/**
|
|
88
|
+
* The note of a canvas fragment (`<div class="note">`, skills/claude-design references/format.md) as the explain.md it copies: `.fm` is the front matter
|
|
89
|
+
* (`title: … · route: … · area: …`), `.intro` the introduction, each `<h4>` a region and the `<p>` lines under it its Vì sao, Luật and Grammar lines.
|
|
90
|
+
*/
|
|
91
|
+
export function noteToMarkdown(noteHtml) {
|
|
92
|
+
const lines = [];
|
|
93
|
+
const fm = /<div class="fm"[^>]*>([\s\S]*?)<\/div>/u.exec(noteHtml)?.[1];
|
|
94
|
+
if (fm !== undefined) {
|
|
95
|
+
lines.push("---");
|
|
96
|
+
for (const part of inlineMarkdown(fm).split(" · ")) {
|
|
97
|
+
const pair = /^(\w+):\s*(.*)$/u.exec(part.trim());
|
|
98
|
+
if (pair?.[1] !== undefined)
|
|
99
|
+
lines.push(`${pair[1]}: ${pair[2] ?? ""}`);
|
|
100
|
+
}
|
|
101
|
+
lines.push("---", "");
|
|
102
|
+
}
|
|
103
|
+
const rest = fm === undefined ? noteHtml : noteHtml.replace(/<div class="fm"[^>]*>[\s\S]*?<\/div>/u, "");
|
|
104
|
+
for (const [, tag, inner] of rest.matchAll(/<(p|h4)\b[^>]*>([\s\S]*?)<\/\1>/giu)) {
|
|
105
|
+
const text = inlineMarkdown(inner ?? "");
|
|
106
|
+
if (text === "")
|
|
107
|
+
continue;
|
|
108
|
+
if (tag?.toLowerCase() === "h4")
|
|
109
|
+
lines.push("", `## ${text}`);
|
|
110
|
+
else
|
|
111
|
+
lines.push(text);
|
|
112
|
+
}
|
|
113
|
+
return lines.join("\n");
|
|
114
|
+
}
|
|
115
|
+
const CLAUSES = ["Mục tiêu", "Thao tác", "Bố cục", "Nút chính", "Lọc", "Khác bản hiện tại", "Lưu ý xung đột"];
|
|
116
|
+
/** The introduction split at its clauses (`Mục tiêu:`, `Thao tác:` …) so it reads as rows; one unnamed row when it holds fewer than two. */
|
|
117
|
+
export function introClauses(intro) {
|
|
118
|
+
const pattern = new RegExp(`(?:^|\\s)(?:\\*\\*)?(${CLAUSES.join("|")}):(?:\\*\\*)?\\s*`, "gu");
|
|
119
|
+
const hits = [...intro.matchAll(pattern)];
|
|
120
|
+
if (hits.length < 2)
|
|
121
|
+
return intro === "" ? [] : [{ label: null, text: intro }];
|
|
122
|
+
const rows = [];
|
|
123
|
+
const head = intro.slice(0, hits[0]?.index ?? 0).trim();
|
|
124
|
+
if (head !== "")
|
|
125
|
+
rows.push({ label: null, text: head });
|
|
126
|
+
hits.forEach((hit, index) => {
|
|
127
|
+
const start = hit.index + hit[0].length;
|
|
128
|
+
const end = hits[index + 1]?.index ?? intro.length;
|
|
129
|
+
rows.push({ label: hit[1] ?? null, text: intro.slice(start, end).trim() });
|
|
130
|
+
});
|
|
131
|
+
return rows;
|
|
132
|
+
}
|
package/dist/frames.d.ts
ADDED
package/dist/frames.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { FIELDS, SHOT_WIDTHS, flowList, introClauses, linkList, noteToMarkdown, parseExplain } from "./explain.js";
|
|
2
|
+
export type { Explain, Field, Flow, Link, Problem, Region, Width } from "./explain.js";
|
|
3
|
+
export { LABELS, capitalize, fill, galleryLocale } from "./labels.js";
|
|
4
|
+
export type { Labels } from "./labels.js";
|
|
5
|
+
export { STATE_KINDS, buildModel, devPath, splitState, statusOf } from "./model.js";
|
|
6
|
+
export type { Area, Counts, Model, RawFrame, RawGallery, RawScreen, Screen, StateKind, Status } from "./model.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// The pure side of @starci/gallery: the explain.md reader, the model of screens, statuses and states, the words. The Vite config of an app is `@starci/gallery/vite`.
|
|
2
|
+
export { FIELDS, SHOT_WIDTHS, flowList, introClauses, linkList, noteToMarkdown, parseExplain } from "./explain.js";
|
|
3
|
+
export { LABELS, capitalize, fill, galleryLocale } from "./labels.js";
|
|
4
|
+
export { STATE_KINDS, buildModel, devPath, splitState, statusOf } from "./model.js";
|
package/dist/labels.d.ts
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
export interface Labels {
|
|
2
|
+
readonly title: string;
|
|
3
|
+
readonly counts: string;
|
|
4
|
+
readonly countsMatches: string;
|
|
5
|
+
readonly countsNotCoded: string;
|
|
6
|
+
readonly countsUnrecorded: string;
|
|
7
|
+
readonly countsDiffers: string;
|
|
8
|
+
readonly countsStale: string;
|
|
9
|
+
readonly hidden: string;
|
|
10
|
+
readonly width: string;
|
|
11
|
+
readonly view: string;
|
|
12
|
+
readonly viewSide: string;
|
|
13
|
+
readonly viewSlider: string;
|
|
14
|
+
readonly viewShot: string;
|
|
15
|
+
readonly viewDesign: string;
|
|
16
|
+
readonly viewCompare: string;
|
|
17
|
+
readonly viewOnion: string;
|
|
18
|
+
readonly viewDiff: string;
|
|
19
|
+
readonly onionOpacity: string;
|
|
20
|
+
readonly reasonNoDesign: string;
|
|
21
|
+
readonly reasonNoShot: string;
|
|
22
|
+
readonly statusDrafted: string;
|
|
23
|
+
readonly statusApproved: string;
|
|
24
|
+
readonly screens: string;
|
|
25
|
+
readonly flows: string;
|
|
26
|
+
readonly search: string;
|
|
27
|
+
readonly noScreens: string;
|
|
28
|
+
readonly empty: string;
|
|
29
|
+
readonly statusMatches: string;
|
|
30
|
+
readonly statusDiffers: string;
|
|
31
|
+
readonly statusStale: string;
|
|
32
|
+
readonly statusNotBuilt: string;
|
|
33
|
+
readonly statusUnrecorded: string;
|
|
34
|
+
readonly statusCodedOnly: string;
|
|
35
|
+
readonly unrecordedHint: string;
|
|
36
|
+
readonly designApproved: string;
|
|
37
|
+
readonly legend: string;
|
|
38
|
+
readonly statusNone: string;
|
|
39
|
+
readonly design: string;
|
|
40
|
+
readonly shot: string;
|
|
41
|
+
readonly noDesign: string;
|
|
42
|
+
readonly noShot: string;
|
|
43
|
+
readonly noShotAtWidth: string;
|
|
44
|
+
readonly slider: string;
|
|
45
|
+
readonly states: string;
|
|
46
|
+
readonly stateBase: string;
|
|
47
|
+
readonly stateDetail: string;
|
|
48
|
+
readonly stateEmpty: string;
|
|
49
|
+
readonly stateFirstVisit: string;
|
|
50
|
+
readonly stateLoading: string;
|
|
51
|
+
readonly stateError: string;
|
|
52
|
+
readonly stateNoMatch: string;
|
|
53
|
+
readonly stateEditing: string;
|
|
54
|
+
readonly explain: string;
|
|
55
|
+
readonly hideExplain: string;
|
|
56
|
+
readonly paneDesign: string;
|
|
57
|
+
readonly paneShot: string;
|
|
58
|
+
readonly regions: string;
|
|
59
|
+
readonly problems: string;
|
|
60
|
+
readonly close: string;
|
|
61
|
+
readonly zoomIn: string;
|
|
62
|
+
readonly zoomOut: string;
|
|
63
|
+
readonly zoomFit: string;
|
|
64
|
+
readonly openFrame: string;
|
|
65
|
+
readonly pane: string;
|
|
66
|
+
readonly showExplain: string;
|
|
67
|
+
readonly noExplain: string;
|
|
68
|
+
readonly noRegions: string;
|
|
69
|
+
readonly problemMissing: string;
|
|
70
|
+
readonly problemUnclear: string;
|
|
71
|
+
readonly intro: string;
|
|
72
|
+
readonly openDev: string;
|
|
73
|
+
readonly board: string;
|
|
74
|
+
readonly route: string;
|
|
75
|
+
readonly galleryId: string;
|
|
76
|
+
readonly noFlows: string;
|
|
77
|
+
readonly linksHeading: string;
|
|
78
|
+
readonly openScreen: string;
|
|
79
|
+
readonly clear: string;
|
|
80
|
+
readonly back: string;
|
|
81
|
+
}
|
|
82
|
+
export declare const LABELS: Readonly<{
|
|
83
|
+
en: {
|
|
84
|
+
title: string;
|
|
85
|
+
counts: string;
|
|
86
|
+
countsMatches: string;
|
|
87
|
+
countsNotCoded: string;
|
|
88
|
+
countsUnrecorded: string;
|
|
89
|
+
countsDiffers: string;
|
|
90
|
+
countsStale: string;
|
|
91
|
+
hidden: string;
|
|
92
|
+
width: string;
|
|
93
|
+
view: string;
|
|
94
|
+
viewSide: string;
|
|
95
|
+
viewSlider: string;
|
|
96
|
+
viewShot: string;
|
|
97
|
+
viewDesign: string;
|
|
98
|
+
viewCompare: string;
|
|
99
|
+
viewOnion: string;
|
|
100
|
+
viewDiff: string;
|
|
101
|
+
onionOpacity: string;
|
|
102
|
+
reasonNoDesign: string;
|
|
103
|
+
reasonNoShot: string;
|
|
104
|
+
statusDrafted: string;
|
|
105
|
+
statusApproved: string;
|
|
106
|
+
screens: string;
|
|
107
|
+
flows: string;
|
|
108
|
+
search: string;
|
|
109
|
+
noScreens: string;
|
|
110
|
+
empty: string;
|
|
111
|
+
statusMatches: string;
|
|
112
|
+
statusDiffers: string;
|
|
113
|
+
statusStale: string;
|
|
114
|
+
statusNotBuilt: string;
|
|
115
|
+
statusUnrecorded: string;
|
|
116
|
+
statusCodedOnly: string;
|
|
117
|
+
unrecordedHint: string;
|
|
118
|
+
designApproved: string;
|
|
119
|
+
legend: string;
|
|
120
|
+
statusNone: string;
|
|
121
|
+
design: string;
|
|
122
|
+
shot: string;
|
|
123
|
+
noDesign: string;
|
|
124
|
+
noShot: string;
|
|
125
|
+
noShotAtWidth: string;
|
|
126
|
+
slider: string;
|
|
127
|
+
states: string;
|
|
128
|
+
stateBase: string;
|
|
129
|
+
stateDetail: string;
|
|
130
|
+
stateEmpty: string;
|
|
131
|
+
stateFirstVisit: string;
|
|
132
|
+
stateLoading: string;
|
|
133
|
+
stateError: string;
|
|
134
|
+
stateNoMatch: string;
|
|
135
|
+
stateEditing: string;
|
|
136
|
+
explain: string;
|
|
137
|
+
hideExplain: string;
|
|
138
|
+
paneDesign: string;
|
|
139
|
+
paneShot: string;
|
|
140
|
+
regions: string;
|
|
141
|
+
problems: string;
|
|
142
|
+
close: string;
|
|
143
|
+
zoomIn: string;
|
|
144
|
+
zoomOut: string;
|
|
145
|
+
zoomFit: string;
|
|
146
|
+
openFrame: string;
|
|
147
|
+
pane: string;
|
|
148
|
+
showExplain: string;
|
|
149
|
+
noExplain: string;
|
|
150
|
+
noRegions: string;
|
|
151
|
+
problemMissing: string;
|
|
152
|
+
problemUnclear: string;
|
|
153
|
+
intro: string;
|
|
154
|
+
openDev: string;
|
|
155
|
+
board: string;
|
|
156
|
+
route: string;
|
|
157
|
+
galleryId: string;
|
|
158
|
+
noFlows: string;
|
|
159
|
+
linksHeading: string;
|
|
160
|
+
openScreen: string;
|
|
161
|
+
clear: string;
|
|
162
|
+
back: string;
|
|
163
|
+
};
|
|
164
|
+
vi: {
|
|
165
|
+
title: string;
|
|
166
|
+
counts: string;
|
|
167
|
+
countsMatches: string;
|
|
168
|
+
countsNotCoded: string;
|
|
169
|
+
countsUnrecorded: string;
|
|
170
|
+
countsDiffers: string;
|
|
171
|
+
countsStale: string;
|
|
172
|
+
hidden: string;
|
|
173
|
+
width: string;
|
|
174
|
+
view: string;
|
|
175
|
+
viewSide: string;
|
|
176
|
+
viewSlider: string;
|
|
177
|
+
viewShot: string;
|
|
178
|
+
viewDesign: string;
|
|
179
|
+
viewCompare: string;
|
|
180
|
+
viewOnion: string;
|
|
181
|
+
viewDiff: string;
|
|
182
|
+
onionOpacity: string;
|
|
183
|
+
reasonNoDesign: string;
|
|
184
|
+
reasonNoShot: string;
|
|
185
|
+
statusDrafted: string;
|
|
186
|
+
statusApproved: string;
|
|
187
|
+
screens: string;
|
|
188
|
+
flows: string;
|
|
189
|
+
search: string;
|
|
190
|
+
noScreens: string;
|
|
191
|
+
empty: string;
|
|
192
|
+
statusMatches: string;
|
|
193
|
+
statusDiffers: string;
|
|
194
|
+
statusStale: string;
|
|
195
|
+
statusNotBuilt: string;
|
|
196
|
+
statusUnrecorded: string;
|
|
197
|
+
statusCodedOnly: string;
|
|
198
|
+
unrecordedHint: string;
|
|
199
|
+
designApproved: string;
|
|
200
|
+
legend: string;
|
|
201
|
+
statusNone: string;
|
|
202
|
+
design: string;
|
|
203
|
+
shot: string;
|
|
204
|
+
noDesign: string;
|
|
205
|
+
noShot: string;
|
|
206
|
+
noShotAtWidth: string;
|
|
207
|
+
slider: string;
|
|
208
|
+
states: string;
|
|
209
|
+
stateBase: string;
|
|
210
|
+
stateDetail: string;
|
|
211
|
+
stateEmpty: string;
|
|
212
|
+
stateFirstVisit: string;
|
|
213
|
+
stateLoading: string;
|
|
214
|
+
stateError: string;
|
|
215
|
+
stateNoMatch: string;
|
|
216
|
+
stateEditing: string;
|
|
217
|
+
explain: string;
|
|
218
|
+
hideExplain: string;
|
|
219
|
+
paneDesign: string;
|
|
220
|
+
paneShot: string;
|
|
221
|
+
regions: string;
|
|
222
|
+
problems: string;
|
|
223
|
+
close: string;
|
|
224
|
+
zoomIn: string;
|
|
225
|
+
zoomOut: string;
|
|
226
|
+
zoomFit: string;
|
|
227
|
+
openFrame: string;
|
|
228
|
+
pane: string;
|
|
229
|
+
showExplain: string;
|
|
230
|
+
noExplain: string;
|
|
231
|
+
noRegions: string;
|
|
232
|
+
problemMissing: string;
|
|
233
|
+
problemUnclear: string;
|
|
234
|
+
intro: string;
|
|
235
|
+
openDev: string;
|
|
236
|
+
board: string;
|
|
237
|
+
route: string;
|
|
238
|
+
galleryId: string;
|
|
239
|
+
noFlows: string;
|
|
240
|
+
linksHeading: string;
|
|
241
|
+
openScreen: string;
|
|
242
|
+
clear: string;
|
|
243
|
+
back: string;
|
|
244
|
+
};
|
|
245
|
+
}>;
|
|
246
|
+
/** The words of a locale (`en` when it has no table). */
|
|
247
|
+
export declare const labelsFor: (locale: string) => Labels;
|
|
248
|
+
/** The supported gallery language for a declared default locale (`vi-VN` reads as `vi`); `en` when the locale is undeclared or not in the table. */
|
|
249
|
+
export declare function galleryLocale(declared: string | null | undefined): string;
|
|
250
|
+
export declare const fill: (text: string, values: Readonly<Record<string, string | number>>) => string;
|
|
251
|
+
/** A label for display with its first letter in capitals, by the locale's own rules (`đăng nhập` reads `Đăng nhập`); the folder name or id it came from is never changed. */
|
|
252
|
+
export declare function capitalize(text: string, locale: string): string;
|
package/dist/labels.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
export const LABELS = Object.freeze({
|
|
2
|
+
en: {
|
|
3
|
+
title: "{app} gallery",
|
|
4
|
+
counts: "{total} screens",
|
|
5
|
+
countsMatches: "{n} match",
|
|
6
|
+
countsNotCoded: "{n} not coded",
|
|
7
|
+
countsUnrecorded: "{n} not recorded",
|
|
8
|
+
countsDiffers: "{n} differ",
|
|
9
|
+
countsStale: "{n} stale",
|
|
10
|
+
hidden: "{n} screens hidden (no explain.md)",
|
|
11
|
+
width: "Width",
|
|
12
|
+
view: "View",
|
|
13
|
+
viewSide: "Side by side",
|
|
14
|
+
viewSlider: "Slider",
|
|
15
|
+
viewShot: "Shot",
|
|
16
|
+
viewDesign: "Design",
|
|
17
|
+
viewCompare: "Compare",
|
|
18
|
+
viewOnion: "Onion skin",
|
|
19
|
+
viewDiff: "Difference",
|
|
20
|
+
onionOpacity: "Shot opacity",
|
|
21
|
+
reasonNoDesign: "No design frame at this width, so there is nothing to compare with.",
|
|
22
|
+
reasonNoShot: "No shot at this width yet, so there is nothing to compare with.",
|
|
23
|
+
statusDrafted: "Drawn, awaiting approval",
|
|
24
|
+
statusApproved: "Approved, not coded",
|
|
25
|
+
screens: "Screens",
|
|
26
|
+
flows: "Flow map",
|
|
27
|
+
search: "Search screens",
|
|
28
|
+
noScreens: "No screens match.",
|
|
29
|
+
empty: "No screens yet. Put the shots and explain.md in gallery/pages/<area>/<screen>/",
|
|
30
|
+
statusMatches: "Matches the design",
|
|
31
|
+
statusDiffers: "Built, differs",
|
|
32
|
+
statusStale: "Stale shot",
|
|
33
|
+
statusNotBuilt: "Drawn, not coded",
|
|
34
|
+
statusUnrecorded: "Coded, not recorded",
|
|
35
|
+
statusCodedOnly: "Coded, no design drawn",
|
|
36
|
+
unrecordedHint: "Drawn and coded, but design.json has no entry for this page: record it (PROJECT-GALLERY-6, PROJECT-GALLERY-7).",
|
|
37
|
+
designApproved: "Approved design",
|
|
38
|
+
legend: "Legend",
|
|
39
|
+
statusNone: "No design yet",
|
|
40
|
+
design: "Design",
|
|
41
|
+
shot: "Real shot",
|
|
42
|
+
noDesign: "No design frame for this screen.",
|
|
43
|
+
noShot: "No shot yet.",
|
|
44
|
+
noShotAtWidth: "No shot at this width.",
|
|
45
|
+
slider: "Compare design and shot",
|
|
46
|
+
states: "States",
|
|
47
|
+
stateBase: "list",
|
|
48
|
+
stateDetail: "detail",
|
|
49
|
+
stateEmpty: "empty",
|
|
50
|
+
stateFirstVisit: "first visit",
|
|
51
|
+
stateLoading: "loading",
|
|
52
|
+
stateError: "error",
|
|
53
|
+
stateNoMatch: "no match",
|
|
54
|
+
stateEditing: "editing",
|
|
55
|
+
explain: "Explanation",
|
|
56
|
+
hideExplain: "Hide explanation",
|
|
57
|
+
paneDesign: "Design",
|
|
58
|
+
paneShot: "Shot",
|
|
59
|
+
regions: "Regions",
|
|
60
|
+
problems: "{n} to fix",
|
|
61
|
+
close: "Close",
|
|
62
|
+
zoomIn: "Zoom in",
|
|
63
|
+
zoomOut: "Zoom out",
|
|
64
|
+
zoomFit: "Fit",
|
|
65
|
+
openFrame: "Open full size",
|
|
66
|
+
pane: "Show",
|
|
67
|
+
showExplain: "Show explanation",
|
|
68
|
+
noExplain: "This screen has no explanation yet.",
|
|
69
|
+
noRegions: "BUG: no region yet",
|
|
70
|
+
problemMissing: "missing {field}",
|
|
71
|
+
problemUnclear: "{field} is unclear or wrong",
|
|
72
|
+
intro: "Overview",
|
|
73
|
+
openDev: "Open on dev",
|
|
74
|
+
board: "Design board",
|
|
75
|
+
route: "Route",
|
|
76
|
+
galleryId: "Gallery id",
|
|
77
|
+
noFlows: "No flow yet. Name flows in gallery/flows.json and mark hotspots in a screen links.json.",
|
|
78
|
+
linksHeading: "Links between screens",
|
|
79
|
+
openScreen: "Open {to}",
|
|
80
|
+
clear: "Clear",
|
|
81
|
+
back: "Back to screens",
|
|
82
|
+
},
|
|
83
|
+
vi: {
|
|
84
|
+
title: "Thư viện ảnh {app}",
|
|
85
|
+
counts: "{total} màn",
|
|
86
|
+
countsMatches: "{n} khớp",
|
|
87
|
+
countsNotCoded: "{n} chưa code",
|
|
88
|
+
countsUnrecorded: "{n} chưa ghi duyệt",
|
|
89
|
+
countsDiffers: "{n} lệch",
|
|
90
|
+
countsStale: "{n} ảnh cũ",
|
|
91
|
+
hidden: "{n} màn bị ẩn (thiếu explain.md)",
|
|
92
|
+
width: "Độ rộng",
|
|
93
|
+
view: "Xem",
|
|
94
|
+
viewSide: "Cạnh nhau",
|
|
95
|
+
viewSlider: "Trượt so",
|
|
96
|
+
viewShot: "Ảnh thật",
|
|
97
|
+
viewDesign: "Bản vẽ",
|
|
98
|
+
viewCompare: "Đối chiếu",
|
|
99
|
+
viewOnion: "Phủ mờ",
|
|
100
|
+
viewDiff: "Chênh lệch",
|
|
101
|
+
onionOpacity: "Độ mờ của ảnh thật",
|
|
102
|
+
reasonNoDesign: "Chưa có khung bản vẽ ở độ rộng này nên chưa đối chiếu được.",
|
|
103
|
+
reasonNoShot: "Chưa có ảnh ở độ rộng này nên chưa đối chiếu được.",
|
|
104
|
+
statusDrafted: "Bản vẽ, chờ duyệt",
|
|
105
|
+
statusApproved: "Đã duyệt, chưa code",
|
|
106
|
+
screens: "Màn hình",
|
|
107
|
+
flows: "Bản đồ luồng",
|
|
108
|
+
search: "Tìm màn hình",
|
|
109
|
+
noScreens: "Không có màn hình nào khớp.",
|
|
110
|
+
empty: "Chưa có màn hình nào. Đặt ảnh và explain.md vào gallery/pages/<area>/<screen>/",
|
|
111
|
+
statusMatches: "Khớp bản vẽ",
|
|
112
|
+
statusDiffers: "Đã code, còn lệch",
|
|
113
|
+
statusStale: "Ảnh đã cũ",
|
|
114
|
+
statusNotBuilt: "Có bản vẽ, chưa code",
|
|
115
|
+
statusUnrecorded: "Đã code, chưa ghi duyệt",
|
|
116
|
+
statusCodedOnly: "Đã code, chưa có bản vẽ",
|
|
117
|
+
unrecordedHint: "Đã có bản vẽ và đã code, nhưng design.json chưa có mục cho trang này: hãy ghi lại (PROJECT-GALLERY-6, PROJECT-GALLERY-7).",
|
|
118
|
+
designApproved: "Bản vẽ đã duyệt",
|
|
119
|
+
legend: "Chú giải",
|
|
120
|
+
statusNone: "Chưa có bản vẽ",
|
|
121
|
+
design: "Bản vẽ",
|
|
122
|
+
shot: "Ảnh thật",
|
|
123
|
+
noDesign: "Màn này chưa có khung vẽ.",
|
|
124
|
+
noShot: "Chưa có ảnh.",
|
|
125
|
+
noShotAtWidth: "Không có ảnh ở độ rộng này.",
|
|
126
|
+
slider: "So bản vẽ và ảnh",
|
|
127
|
+
states: "Trạng thái",
|
|
128
|
+
stateBase: "danh sách",
|
|
129
|
+
stateDetail: "chi tiết",
|
|
130
|
+
stateEmpty: "trống",
|
|
131
|
+
stateFirstVisit: "lần đầu",
|
|
132
|
+
stateLoading: "đang tải",
|
|
133
|
+
stateError: "lỗi",
|
|
134
|
+
stateNoMatch: "không khớp",
|
|
135
|
+
stateEditing: "đang soạn",
|
|
136
|
+
explain: "Giải thích",
|
|
137
|
+
hideExplain: "Ẩn giải thích",
|
|
138
|
+
paneDesign: "Bản vẽ",
|
|
139
|
+
paneShot: "Ảnh thật",
|
|
140
|
+
regions: "Các vùng",
|
|
141
|
+
problems: "{n} chỗ cần sửa",
|
|
142
|
+
close: "Đóng",
|
|
143
|
+
zoomIn: "Phóng to",
|
|
144
|
+
zoomOut: "Thu nhỏ",
|
|
145
|
+
zoomFit: "Vừa khung",
|
|
146
|
+
openFrame: "Mở cỡ đầy đủ",
|
|
147
|
+
pane: "Hiện",
|
|
148
|
+
showExplain: "Hiện giải thích",
|
|
149
|
+
noExplain: "Màn này chưa có giải thích.",
|
|
150
|
+
noRegions: "LỖI: chưa có vùng nào",
|
|
151
|
+
problemMissing: "thiếu {field}",
|
|
152
|
+
problemUnclear: "{field} chưa rõ hoặc sai",
|
|
153
|
+
intro: "Tổng quan",
|
|
154
|
+
openDev: "Mở trên dev",
|
|
155
|
+
board: "Bảng thiết kế",
|
|
156
|
+
route: "Route",
|
|
157
|
+
galleryId: "Mã gallery",
|
|
158
|
+
noFlows: "Chưa có luồng. Đặt tên luồng trong gallery/flows.json và đánh dấu vùng bấm trong links.json của màn hình.",
|
|
159
|
+
linksHeading: "Liên kết giữa các màn hình",
|
|
160
|
+
openScreen: "Mở {to}",
|
|
161
|
+
clear: "Xóa",
|
|
162
|
+
back: "Về danh sách màn",
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
/** The words of a locale (`en` when it has no table). */
|
|
166
|
+
export const labelsFor = (locale) => (locale === "vi" ? LABELS.vi : LABELS.en);
|
|
167
|
+
/** The supported gallery language for a declared default locale (`vi-VN` reads as `vi`); `en` when the locale is undeclared or not in the table. */
|
|
168
|
+
export function galleryLocale(declared) {
|
|
169
|
+
const primary = (declared ?? "").trim().toLowerCase().split(/[-_]/u)[0] ?? "";
|
|
170
|
+
return Object.hasOwn(LABELS, primary) ? primary : "en";
|
|
171
|
+
}
|
|
172
|
+
export const fill = (text, values) => text.replace(/\{(\w+)\}/gu, (_all, key) => String(values[key] ?? ""));
|
|
173
|
+
/** A label for display with its first letter in capitals, by the locale's own rules (`đăng nhập` reads `Đăng nhập`); the folder name or id it came from is never changed. */
|
|
174
|
+
export function capitalize(text, locale) {
|
|
175
|
+
const [first = ""] = text;
|
|
176
|
+
return first === "" ? text : first.toLocaleUpperCase(locale) + text.slice(first.length);
|
|
177
|
+
}
|
package/dist/load.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { RawGallery } from "./model.js";
|
|
2
|
+
export interface LoadOptions {
|
|
3
|
+
/** The gallery root (the Vite root). */
|
|
4
|
+
readonly root: string;
|
|
5
|
+
/** The folder of the pages, relative to the root. */
|
|
6
|
+
readonly pages: string;
|
|
7
|
+
/** The folder of the design canvas, relative to the root. */
|
|
8
|
+
readonly canvas: string;
|
|
9
|
+
}
|
|
10
|
+
/** One frame served as a page of its own: `<area>__<screen>__<width>.html`. */
|
|
11
|
+
export interface FrameDoc {
|
|
12
|
+
readonly file: string;
|
|
13
|
+
readonly html: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Loaded {
|
|
16
|
+
readonly raw: RawGallery;
|
|
17
|
+
/** The stylesheet every frame shares: the canvas tokens, the board and every fragment's own style. */
|
|
18
|
+
readonly frameCss: string;
|
|
19
|
+
readonly frames: readonly FrameDoc[];
|
|
20
|
+
}
|
|
21
|
+
/** The element that opens at `start` (a `<tag`), up to its matching close tag, counting nested tags of the same name; null when it never closes. */
|
|
22
|
+
export declare function balanced(html: string, start: number, tag: string): string | null;
|
|
23
|
+
interface Section {
|
|
24
|
+
readonly pid: string;
|
|
25
|
+
readonly route: string | undefined;
|
|
26
|
+
readonly title: string | undefined;
|
|
27
|
+
readonly scr: Partial<Record<"1440" | "390", string>>;
|
|
28
|
+
readonly note: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
/** The screens of one fragment: each `<section class="page" data-pid=…>` with its 1440 and 390 frames (`.scr`) and its note. */
|
|
31
|
+
export declare function fragmentSections(html: string): Section[];
|
|
32
|
+
export declare function loadGallery(options: LoadOptions): Loaded;
|
|
33
|
+
/** The files the loader reads, for the watcher: the pages folder, the canvas folder and the flows file. */
|
|
34
|
+
export declare const watchedPaths: (options: LoadOptions) => string[];
|
|
35
|
+
export {};
|