@hia-doc/renderer-html 0.1.7 → 1.0.0-rc.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.
Files changed (45) hide show
  1. package/README.md +243 -0
  2. package/dist/index.d.ts +1623 -126
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +829 -159
  5. package/dist/index.js.map +1 -1
  6. package/dist/information-architecture.d.ts +284 -20
  7. package/dist/information-architecture.d.ts.map +1 -1
  8. package/dist/information-architecture.js +42 -15
  9. package/dist/information-architecture.js.map +1 -1
  10. package/dist/portal-ui-locale.d.ts +108 -20
  11. package/dist/portal-ui-locale.d.ts.map +1 -1
  12. package/dist/portal-ui-locale.js +103 -27
  13. package/dist/portal-ui-locale.js.map +1 -1
  14. package/dist/presentation-profile.d.ts +176 -16
  15. package/dist/presentation-profile.d.ts.map +1 -1
  16. package/dist/presentation-profile.js +40 -14
  17. package/dist/presentation-profile.js.map +1 -1
  18. package/dist/route-history.d.ts +193 -0
  19. package/dist/route-history.d.ts.map +1 -0
  20. package/dist/route-history.js +246 -0
  21. package/dist/route-history.js.map +1 -0
  22. package/dist/site-chrome.d.ts +173 -0
  23. package/dist/site-chrome.d.ts.map +1 -0
  24. package/dist/site-chrome.js +187 -0
  25. package/dist/site-chrome.js.map +1 -0
  26. package/dist/site-navigation-chrome.d.ts +36 -0
  27. package/dist/site-navigation-chrome.d.ts.map +1 -0
  28. package/dist/site-navigation-chrome.js +430 -0
  29. package/dist/site-navigation-chrome.js.map +1 -0
  30. package/dist/site-navigation.d.ts +175 -0
  31. package/dist/site-navigation.d.ts.map +1 -0
  32. package/dist/site-navigation.js +176 -0
  33. package/dist/site-navigation.js.map +1 -0
  34. package/dist/site-reading.d.ts +171 -0
  35. package/dist/site-reading.d.ts.map +1 -0
  36. package/dist/site-reading.js +534 -0
  37. package/dist/site-reading.js.map +1 -0
  38. package/dist/source-lines.d.ts +3 -2
  39. package/dist/source-lines.d.ts.map +1 -1
  40. package/dist/source-lines.js +15 -9
  41. package/dist/source-lines.js.map +1 -1
  42. package/dist/theme-assets.d.ts +12 -3
  43. package/dist/theme-assets.d.ts.map +1 -1
  44. package/dist/theme-assets.js.map +1 -1
  45. package/package.json +10 -5
@@ -0,0 +1,246 @@
1
+ /**
2
+ * @lang zh-CN 独立发布历史契约身份。
3
+ * @lang en Independent publication-history contract identity.
4
+ */
5
+ export const DOCUMENTATION_PROJECT_ROUTE_HISTORY_CONTRACT = "documentation-project-route-history";
6
+ /**
7
+ * @lang zh-CN 首个显式草案,旧工件不会隐式重标。
8
+ * @lang en First explicit draft, without implicit relabeling of older artifacts.
9
+ */
10
+ export const DOCUMENTATION_PROJECT_ROUTE_HISTORY_CONTRACT_VERSION = "0.1.0-draft";
11
+ /**
12
+ * @lang zh-CN 统一拒绝身份,保持解析失败可诊断。
13
+ * @lang en Uniform rejection identity retaining diagnosable parsing failures.
14
+ */
15
+ function invalid(detail) {
16
+ throw new TypeError(`HIA_PROJECT_ROUTE_HISTORY_INVALID: ${detail}`);
17
+ }
18
+ /** @lang zh-CN 核普通记录和封闭字段,不容许未知配置被静默忽略。
19
+ * @lang en Check ordinary records and closed fields, preventing silently ignored configuration.
20
+ */
21
+ function record(value, fields, location) {
22
+ if (!value || typeof value !== "object" || Array.isArray(value))
23
+ invalid(location);
24
+ const result = value;
25
+ if (Object.keys(result).some(key => !fields.includes(key)))
26
+ invalid(location);
27
+ return result;
28
+ }
29
+ /** @lang zh-CN 身份保留原字符,拒绝空白、控制字符和无界长度。
30
+ * @lang en Preserve identity spelling while rejecting blank values, control characters and unbounded length.
31
+ */
32
+ function text(value, location) {
33
+ if (typeof value !== "string" || !value.trim() || value.length > 4096 || /[\u0000-\u001f\u007f]/u.test(value))
34
+ invalid(location);
35
+ }
36
+ /** @lang zh-CN 每类记录使用相同显式数量上限。
37
+ * @lang en Apply the same explicit record-count bound to each collection.
38
+ */
39
+ function records(value, location) {
40
+ if (!Array.isArray(value) || value.length > 100_000)
41
+ invalid(location);
42
+ return value;
43
+ }
44
+ /** @lang zh-CN 采用UTF-16词序,避免机器语言设置影响工件顺序。
45
+ * @lang en Use UTF-16 lexical order so host language preferences cannot change artifact order.
46
+ */
47
+ function compareText(left, right) {
48
+ return left < right ? -1 : left > right ? 1 : 0;
49
+ }
50
+ /**
51
+ * @lang zh-CN 校验独立历史的结构、版本、限额和直接别名;当前条目与实际锚点由渲染前置核验负责。
52
+ * @lang en Validate independent history structure, version, limits and direct aliases, leaving current-entry and actual-anchor checks to render preflight.
53
+ * @param value <lang><zh-CN>调用方提供的内存数据,不读取文件或网络。</zh-CN><en>Caller-supplied in-memory data, without file or network reads.</en></lang>
54
+ * @returns <lang><zh-CN>通过时收窄类型,不修改输入。</zh-CN><en>Narrows the type on success without mutating input.</en></lang>
55
+ * @throws <lang><zh-CN>未知身份、字段、越界、冲突或非法路径。</zh-CN><en>Unknown identities/fields, exceeded bounds, collisions or unsafe paths.</en></lang>
56
+ */
57
+ export function assertDocumentationProjectRouteHistory(value) {
58
+ const root = record(value, ["contract", "contractVersion", "projectId", "sources", "bindings", "entryAliases", "pathAliases"], "root");
59
+ if (root.contract !== DOCUMENTATION_PROJECT_ROUTE_HISTORY_CONTRACT || root.contractVersion !== DOCUMENTATION_PROJECT_ROUTE_HISTORY_CONTRACT_VERSION)
60
+ invalid("contract/version");
61
+ text(root.projectId, "projectId");
62
+ const sources = records(root.sources, "sources");
63
+ if (!sources.length)
64
+ invalid("sources");
65
+ const sourceKeys = new Set();
66
+ for (const item of sources) {
67
+ const source = record(item, ["repository", "commit", "locale", "indexSha256"], "source");
68
+ text(source.repository, "source.repository");
69
+ text(source.locale, "source.locale");
70
+ if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u.test(source.repository) || typeof source.commit !== "string" || !/^[a-f0-9]{40}$/u.test(source.commit) || typeof source.indexSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(source.indexSha256))
71
+ invalid("source provenance");
72
+ const key = JSON.stringify([source.repository, source.commit, source.locale]);
73
+ if (sourceKeys.has(key))
74
+ invalid("duplicate source");
75
+ sourceKeys.add(key);
76
+ }
77
+ const bindings = records(root.bindings, "bindings");
78
+ const bindingKeys = new Set();
79
+ const publishedIds = new Set();
80
+ for (const item of bindings) {
81
+ const binding = record(item, ["identityScope", "view", "symbolId", "entryId"], "binding");
82
+ for (const field of ["view", "symbolId", "entryId"])
83
+ text(binding[field], `binding.${field}`);
84
+ if (!["all", "js", "css", "html", "dotnet", "powershell", "other"].includes(binding.view))
85
+ invalid("binding.view");
86
+ if (binding.identityScope !== undefined && (typeof binding.identityScope !== "string" || !/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/u.test(binding.identityScope)))
87
+ invalid("binding.identityScope");
88
+ const key = JSON.stringify([binding.identityScope ?? null, binding.view, binding.symbolId]);
89
+ if (bindingKeys.has(key) || publishedIds.has(binding.entryId))
90
+ invalid("duplicate binding/publication");
91
+ bindingKeys.add(key);
92
+ publishedIds.add(binding.entryId);
93
+ }
94
+ const aliases = records(root.entryAliases, "entryAliases");
95
+ const aliasIds = new Set();
96
+ for (const item of aliases) {
97
+ const alias = record(item, ["entryId", "canonicalEntryId"], "entry alias");
98
+ text(alias.entryId, "alias.entryId");
99
+ text(alias.canonicalEntryId, "alias.canonicalEntryId");
100
+ if (aliasIds.has(alias.entryId) || alias.entryId === alias.canonicalEntryId)
101
+ invalid("duplicate/self alias");
102
+ aliasIds.add(alias.entryId);
103
+ }
104
+ for (const item of aliases)
105
+ if (aliasIds.has(item.canonicalEntryId))
106
+ invalid("alias chain/cycle");
107
+ const paths = new Set();
108
+ for (const item of records(root.pathAliases, "pathAliases")) {
109
+ const route = record(item, ["path", "kind", "entryId", "uiLocale", "anchors"], "path alias");
110
+ text(route.path, "path");
111
+ text(route.entryId, "path.entryId");
112
+ if (!["fragment", "page"].includes(route.kind) || !/^(entries|pages)\/(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9][A-Za-z0-9._-]*\.html$/u.test(route.path) || route.path.split("/").some(part => part === "." || part === "..") || route.path.toLowerCase().endsWith("/index.html"))
113
+ invalid("path spelling");
114
+ if (!route.path.startsWith(route.kind === "fragment" ? "entries/" : "pages/"))
115
+ invalid("path role");
116
+ const shape = route.kind === "fragment" ? /^entries\/[A-Za-z0-9][A-Za-z0-9._-]*\.html$/u : /^pages\/(?:(?:en|zh-CN)\/)?[A-Za-z0-9][A-Za-z0-9._-]*\.html$/u;
117
+ if (!shape.test(route.path))
118
+ invalid("generated path shape");
119
+ if (route.uiLocale !== undefined && (route.kind !== "page" || !["en", "zh-CN"].includes(route.uiLocale)))
120
+ invalid("path.uiLocale");
121
+ const localized = route.path.match(/^pages\/(en|zh-CN)\//u)?.[1];
122
+ if (localized && route.uiLocale !== localized)
123
+ invalid("path locale mismatch");
124
+ // <lang><zh-CN>发布文件须可安全落盘到大小写不敏感的文件系统,原路径拼写仍原样保存。</zh-CN><en>Publication files must remain safe on case-insensitive filesystems while retaining their original path spelling.</en></lang>
125
+ if (paths.has(route.path.toLowerCase()))
126
+ invalid("duplicate path");
127
+ paths.add(route.path.toLowerCase());
128
+ const anchors = new Set();
129
+ const targets = new Set();
130
+ for (const item of records(route.anchors, "anchors")) {
131
+ const anchor = record(item, ["id", "targetId"], "anchor");
132
+ text(anchor.id, "anchor.id");
133
+ text(anchor.targetId, "anchor.targetId");
134
+ if (anchors.has(anchor.id) || targets.has(anchor.targetId))
135
+ invalid("ambiguous anchor");
136
+ anchors.add(anchor.id);
137
+ targets.add(anchor.targetId);
138
+ }
139
+ }
140
+ // <lang><zh-CN>结构和单值先有界;序列化期间累计字符串,避免超大调用方对象先分配整份JSON。</zh-CN><en>Bound structure and individual values first, counting strings during serialization before allocating oversized caller JSON.</en></lang>
141
+ let characters = 0;
142
+ try {
143
+ const serialized = JSON.stringify(value, (_key, item) => {
144
+ if (typeof item === "string")
145
+ characters += item.length;
146
+ if (characters > 16 * 1024 * 1024)
147
+ invalid("size");
148
+ return item;
149
+ });
150
+ if (new TextEncoder().encode(serialized).byteLength > 16 * 1024 * 1024)
151
+ invalid("size");
152
+ }
153
+ catch {
154
+ invalid("size/serialization");
155
+ }
156
+ }
157
+ /**
158
+ * @lang zh-CN 在任何输出前复制并应用宿主显式绑定,保留原生符号/地图及调用方数据。
159
+ * @lang en Snapshot and apply explicit host bindings before output, preserving native symbols/maps and caller-owned data.
160
+ * @param input <lang><zh-CN>当前项目及实际声明。</zh-CN><en>Current project and actual declarations.</en></lang>
161
+ * @param value <lang><zh-CN>待校验历史登记。</zh-CN><en>History registry to validate.</en></lang>
162
+ * @returns <lang><zh-CN>独立历史快照与持久条目投影。</zh-CN><en>Isolated history snapshot and persistent-entry projection.</en></lang>
163
+ * @throws <lang><zh-CN>项目、原生绑定、持久身份或别名目标矛盾。</zh-CN><en>Contradictory project, native binding, persistent identity or alias target.</en></lang>
164
+ */
165
+ export function prepareProjectRouteHistory(input, value) {
166
+ assertDocumentationProjectRouteHistory(value);
167
+ const history = structuredClone(value);
168
+ // <lang><zh-CN>声明顺序不参与登记身份或兼容文件顺序;本地化正文顺序仍由正常渲染器决定。</zh-CN><en>Registry identity and compatibility-file order ignore record order; normal rendering still determines localized prose order.</en></lang>
169
+ history.sources.sort((left, right) => compareText(JSON.stringify(left), JSON.stringify(right)));
170
+ history.bindings.sort((left, right) => compareText(left.entryId, right.entryId));
171
+ history.entryAliases.sort((left, right) => compareText(left.entryId, right.entryId));
172
+ history.pathAliases.sort((left, right) => compareText(left.path, right.path));
173
+ for (const route of history.pathAliases)
174
+ route.anchors.sort((left, right) => compareText(left.id, right.id));
175
+ if (history.projectId !== (input.project.id ?? `project:${input.project.name}`))
176
+ invalid("project identity");
177
+ // <lang><zh-CN>同作用域/视图下的原生符号必须唯一,避免从多个同名声明中挑选。</zh-CN><en>Require a unique native symbol within scope/view instead of choosing among matching declarations.</en></lang>
178
+ const nativeEntries = new Map();
179
+ const originalIds = new Map(input.entries.map((entry, index) => [entry.id, index]));
180
+ input.entries.forEach((entry, index) => {
181
+ if (!entry.symbolId)
182
+ return;
183
+ const key = JSON.stringify([entry.identityScope ?? null, entry.view, entry.symbolId]);
184
+ nativeEntries.set(key, [...(nativeEntries.get(key) ?? []), index]);
185
+ });
186
+ const replacements = new Map();
187
+ for (const binding of history.bindings) {
188
+ const matches = nativeEntries.get(JSON.stringify([binding.identityScope ?? null, binding.view, binding.symbolId]));
189
+ if (matches?.length !== 1)
190
+ invalid("native binding missing/ambiguous");
191
+ const index = matches[0];
192
+ if (originalIds.has(binding.entryId) && originalIds.get(binding.entryId) !== index)
193
+ invalid("publication captures another entry");
194
+ replacements.set(index, binding.entryId);
195
+ }
196
+ const entries = input.entries.map((entry, index) => replacements.has(index) ? { ...entry, id: replacements.get(index) } : entry);
197
+ const entryIds = new Set(entries.map(entry => entry.id));
198
+ if (entryIds.size !== entries.length)
199
+ invalid("duplicate publication identity");
200
+ for (const alias of history.entryAliases)
201
+ if (entryIds.has(alias.entryId) || !entryIds.has(alias.canonicalEntryId))
202
+ invalid("entry alias target/shadow");
203
+ for (const route of history.pathAliases)
204
+ if (!entryIds.has(route.entryId))
205
+ invalid("path entry missing");
206
+ // <lang><zh-CN>显式关系图的entryId同步投影,调用方图节点身份与原生symbolId保持。</zh-CN><en>Project explicit graph entry references while retaining caller-owned graph-node and native-symbol identities.</en></lang>
207
+ const publicationIds = new Map(input.entries.map((entry, index) => [entry.id, entries[index].id]));
208
+ const relationGraph = input.relationGraph ? { ...input.relationGraph, nodes: input.relationGraph.nodes.map(node => node.entryId && publicationIds.has(node.entryId) ? { ...node, entryId: publicationIds.get(node.entryId) } : node) } : undefined;
209
+ return { input: { ...input, entries, ...(relationGraph ? { relationGraph } : {}) }, history };
210
+ }
211
+ /**
212
+ * @lang zh-CN 每站一份的渐进恢复脚本,禁脚本时页面普通链接仍可阅读。
213
+ * @lang en One progressive-recovery script per site, retaining ordinary readable links when scripts are disabled.
214
+ */
215
+ export const PROJECT_ROUTE_HISTORY_SCRIPT = String.raw `/**
216
+ * @lang zh-CN 只消费同页已生成登记,已知小节精确恢复;未知小节保留普通链接。
217
+ * @lang en Consume same-page generated records only, restoring known sections while retaining links for unknown sections.
218
+ */
219
+ (() => {
220
+ const record = document.querySelector('[data-hia-route-history-page]');
221
+ if (!record) return;
222
+ const config = JSON.parse(record.textContent);
223
+ const target = new URL(config.target, location.href);
224
+ if (target.origin !== location.origin) return;
225
+ const status = document.querySelector('[data-hia-route-status]');
226
+ const anchors = new Map(config.anchors);
227
+ let requested;
228
+ try {
229
+ requested = decodeURIComponent(location.hash.slice(1));
230
+ } catch {
231
+ status.textContent = config.missing;
232
+ return;
233
+ }
234
+ if (requested) {
235
+ const current = anchors.get(requested);
236
+ if (!current) {
237
+ status.textContent = config.missing;
238
+ return;
239
+ }
240
+ target.hash = current;
241
+ }
242
+ target.search = location.search;
243
+ location.replace(target.href);
244
+ })();
245
+ `;
246
+ //# sourceMappingURL=route-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-history.js","sourceRoot":"","sources":["../src/route-history.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,CAAC,MAAM,4CAA4C,GAAG,qCAAqC,CAAC;AAClG;;;GAGG;AACH,MAAM,CAAC,MAAM,oDAAoD,GAAG,aAAa,CAAC;AA+JlF;;;GAGG;AACH,SAAS,OAAO,CAAC,MAAc;IAC7B,MAAM,IAAI,SAAS,CAAC,sCAAsC,MAAM,EAAE,CAAC,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,SAAS,MAAM,CAAC,KAAc,EAAE,MAAyB,EAAE,QAAgB;IACzE,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnF,MAAM,MAAM,GAAG,KAAgC,CAAC;IAChD,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE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KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,CAAC,KAAK,CAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpG,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,IAAI,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACpP,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC;AAChG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BrD,CAAC"}
@@ -0,0 +1,173 @@
1
+ import type { DocumentationPortalUiLocale } from "./information-architecture.js";
2
+ export { assertDocumentationSiteNavigation, type DocumentationSiteNavigation } from "./site-navigation.js";
3
+ export { renderSourceLines } from "./source-lines.js";
4
+ /**
5
+ * @lang zh-CN 实际生成的本页语言对应路径,缺语言时保持缺页。
6
+ * @lang en Actual generated locale counterparts, preserving absent locales.
7
+ */
8
+ export type SiteChromeLocalePages = Partial<Record<DocumentationPortalUiLocale, string>>;
9
+ /**
10
+ * @lang zh-CN 同次生成的公开检索条目,不含源码正文或读取权限。
11
+ * @lang en Public search entry from this generation, without source bodies or read authority.
12
+ */
13
+ export interface SiteChromeEntry {
14
+ /**
15
+ * @lang zh-CN 原生稳定身份,站内唯一。
16
+ * @lang en Native stable identity, unique within this site.
17
+ */
18
+ id: string;
19
+ /**
20
+ * @lang zh-CN 可公开名称。
21
+ * @lang en Public name.
22
+ */
23
+ name: string;
24
+ /**
25
+ * @lang zh-CN 可公开条目类别。
26
+ * @lang en Public entry kind.
27
+ */
28
+ kind: string;
29
+ /**
30
+ * @lang zh-CN 生成根相对的真实页面及可选锚点。
31
+ * @lang en Actual generation-root-relative page and optional fragment.
32
+ */
33
+ page: string;
34
+ /**
35
+ * @lang zh-CN 公开检索文字,不由框架反读正文。
36
+ * @lang en Public search text, never derived by rereading bodies.
37
+ */
38
+ searchText: string;
39
+ /**
40
+ * @lang zh-CN 已存在语言页,缺失语言不推测。
41
+ * @lang en Existing locale pages, without inferred counterparts.
42
+ */
43
+ localePages?: SiteChromeLocalePages;
44
+ }
45
+ /**
46
+ * @lang zh-CN 真实正文小节,身份必须出现在本页可信slot中。
47
+ * @lang en Actual prose section whose identity must exist in this page's trusted slot.
48
+ */
49
+ export interface SiteChromeSection {
50
+ /**
51
+ * @lang zh-CN 原生小节锚点。
52
+ * @lang en Native section anchor.
53
+ */
54
+ id: string;
55
+ /**
56
+ * @lang zh-CN 当前界面语言的纯文本标题。
57
+ * @lang en Plain-text heading in the current UI locale.
58
+ */
59
+ label: string;
60
+ }
61
+ /**
62
+ * @lang zh-CN 单页显式上下文及生成器负责安全处理的HTML slot。
63
+ * @lang en Explicit page context and generator-owned sanitized HTML slots.
64
+ */
65
+ export interface SiteChromePage {
66
+ /**
67
+ * @lang zh-CN 目录、条目或源码页角色,源码页保持无脚本。
68
+ * @lang en Index, entry, or source role, with source pages remaining script-free.
69
+ */
70
+ role: "index" | "entry" | "source";
71
+ /**
72
+ * @lang zh-CN 生成根相对HTML路径。
73
+ * @lang en Generation-root-relative HTML path.
74
+ */
75
+ outputPath: string;
76
+ /**
77
+ * @lang zh-CN 显式界面语言。
78
+ * @lang en Explicit UI locale.
79
+ */
80
+ uiLocale: DocumentationPortalUiLocale;
81
+ /**
82
+ * @lang zh-CN 实际同页语言对应路径。
83
+ * @lang en Actual same-page locale counterparts.
84
+ */
85
+ localePages: SiteChromeLocalePages;
86
+ /**
87
+ * @lang zh-CN HTML标题的纯文本。
88
+ * @lang en Plain-text document title.
89
+ */
90
+ title: string;
91
+ /**
92
+ * @lang zh-CN 原生生成器已安全处理的正文,框架不重写其身份与字段。
93
+ * @lang en Native generator's sanitized prose, retaining original identities and fields.
94
+ */
95
+ bodyHtml: string;
96
+ /**
97
+ * @lang zh-CN 原生生成器的可信目录HTML,链接相对此页。
98
+ * @lang en Native generator's trusted directory HTML, with page-relative links.
99
+ */
100
+ directoryHtml: string;
101
+ /**
102
+ * @lang zh-CN 本页实际小节。
103
+ * @lang en Actual sections of this page.
104
+ */
105
+ sections: readonly SiteChromeSection[];
106
+ /**
107
+ * @lang zh-CN 原生生成器静态样式路径,相对生成根。
108
+ * @lang en Native generator stylesheets relative to the generation root.
109
+ */
110
+ stylesheets?: readonly string[];
111
+ /**
112
+ * @lang zh-CN 原生生成器脚本路径,相对生成根;源码角色不接受。
113
+ * @lang en Native generator scripts relative to the generation root, forbidden for the source role.
114
+ */
115
+ scripts?: readonly string[];
116
+ /**
117
+ * @lang zh-CN 原生生成器可信JSON数据slot,仅用于非源码页。
118
+ * @lang en Native generator's trusted JSON-data slot, for non-source pages only.
119
+ */
120
+ dataHtml?: string;
121
+ /**
122
+ * @lang zh-CN 本页初始外观,默认system且偏好不持久化。
123
+ * @lang en Initial appearance, defaulting to system without persistent preferences.
124
+ */
125
+ scheme?: "system" | "light" | "dark";
126
+ }
127
+ /**
128
+ * @lang zh-CN 一次生成只写一份的确定性资产。
129
+ * @lang en Deterministic asset written once per generation.
130
+ */
131
+ export interface SiteChromeAsset {
132
+ /**
133
+ * @lang zh-CN 固定生成根相对路径。
134
+ * @lang en Fixed generation-root-relative path.
135
+ */
136
+ readonly path: string;
137
+ /**
138
+ * @lang zh-CN UTF-8资产正文。
139
+ * @lang en UTF-8 asset contents.
140
+ */
141
+ readonly contents: string;
142
+ }
143
+ /**
144
+ * @lang zh-CN 无I/O的站点快照与同步页面渲染服务。
145
+ * @lang en I/O-free site snapshot and synchronous page-rendering service.
146
+ */
147
+ export interface SiteChrome {
148
+ /**
149
+ * @lang zh-CN 共享资产只读清单。
150
+ * @lang en Read-only shared asset list.
151
+ */
152
+ readonly assets: readonly SiteChromeAsset[];
153
+ /**
154
+ * @lang zh-CN 验证显式页面并返回完整HTML,不写文件或改变输入。
155
+ * @lang en Validates an explicit page and returns complete HTML without file writes or input mutation.
156
+ * @param page <lang><zh-CN>本次实际页面、可信slot及语言对应。</zh-CN><en>Actual page, trusted slots and locale counterparts.</en></lang>
157
+ * @returns <lang><zh-CN>UTF-8完整HTML字符串,资产由服务清单另行写出。</zh-CN><en>Complete UTF-8 HTML string, with assets written separately from the service inventory.</en></lang>
158
+ * @throws {TypeError} <lang><zh-CN>无效页面上下文,公开错误省略输入正文。</zh-CN><en>Invalid page context, omitting input contents from public errors.</en></lang>
159
+ */
160
+ renderPage(page: SiteChromePage): string;
161
+ }
162
+ /**
163
+ * @lang zh-CN 建立导航与条目的独立快照;返回同步页面服务及一份共享资产清单,零文件I/O。
164
+ * @lang en Snapshots navigation and entries independently, returning a synchronous page service and shared assets with zero file I/O.
165
+ * @param options <lang><zh-CN>现有导航契约和实际公开条目。</zh-CN><en>Existing navigation contract and actual public entries.</en></lang>
166
+ * @returns <lang><zh-CN>可由CommonJS同步require或ESM import调用的服务。</zh-CN><en>Service usable through synchronous CommonJS require or ESM import.</en></lang>
167
+ * @throws {TypeError} <lang><zh-CN>输入或页面不合法,错误不含拒绝输入正文。</zh-CN><en>Invalid input or page, without rejected values in error messages.</en></lang>
168
+ */
169
+ export declare function createSiteChrome(options: {
170
+ navigation: unknown;
171
+ entries: readonly SiteChromeEntry[];
172
+ }): SiteChrome;
173
+ //# sourceMappingURL=site-chrome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-chrome.d.ts","sourceRoot":"","sources":["../src/site-chrome.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAEjF,OAAO,EAAE,iCAAiC,EAAE,KAAK,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAC3G,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC,CAAC;AAEzF;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,qBAAqB,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;IACnC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,EAAE,2BAA2B,CAAC;IACtC;;;OAGG;IACH,WAAW,EAAE,qBAAqB,CAAC;IACnC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACvC;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAC5C;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAA;CAAE,GAAG,UAAU,CAqBlH"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * @file
3
+ * @lang zh-CN 独立生成器的同步公共站点框架,以显式页面和可信正文slot复用导航/阅读组件,不读取源码或文件。
4
+ * @lang en Synchronous public site frame for independent generators, reusing navigation/reading components through explicit pages and trusted slots without source or file reads.
5
+ */
6
+ import { header, SITE_STYLE } from "./site-navigation-chrome.js";
7
+ import { renderSiteReadingDialogs, SITE_READING_MESSAGES, SITE_READING_SCRIPT, SITE_READING_STYLE } from "./site-reading.js";
8
+ import { assertDocumentationSiteNavigation } from "./site-navigation.js";
9
+ export { assertDocumentationSiteNavigation } from "./site-navigation.js";
10
+ export { renderSourceLines } from "./source-lines.js";
11
+ /**
12
+ * @lang zh-CN 建立导航与条目的独立快照;返回同步页面服务及一份共享资产清单,零文件I/O。
13
+ * @lang en Snapshots navigation and entries independently, returning a synchronous page service and shared assets with zero file I/O.
14
+ * @param options <lang><zh-CN>现有导航契约和实际公开条目。</zh-CN><en>Existing navigation contract and actual public entries.</en></lang>
15
+ * @returns <lang><zh-CN>可由CommonJS同步require或ESM import调用的服务。</zh-CN><en>Service usable through synchronous CommonJS require or ESM import.</en></lang>
16
+ * @throws {TypeError} <lang><zh-CN>输入或页面不合法,错误不含拒绝输入正文。</zh-CN><en>Invalid input or page, without rejected values in error messages.</en></lang>
17
+ */
18
+ export function createSiteChrome(options) {
19
+ if (!options || !Array.isArray(options.entries))
20
+ invalid();
21
+ assertDocumentationSiteNavigation(options.navigation);
22
+ // <lang><zh-CN>已通过既有纯数据校验的导航可安全复制,调用方后续修改不改变本服务。</zh-CN><en>Navigation already admitted by the existing pure-data validator can be copied safely, isolating later caller mutation.</en></lang>
23
+ const navigation = JSON.parse(JSON.stringify(options.navigation));
24
+ const identities = new Set();
25
+ const entries = Array.from(options.entries, entry => {
26
+ if (!entry || typeof entry.id !== "string" || !entry.id || identities.has(entry.id))
27
+ invalid();
28
+ identities.add(entry.id);
29
+ if (![entry.name, entry.kind, entry.searchText].every(value => typeof value === "string"))
30
+ invalid();
31
+ relative(entry.page, true);
32
+ const localePages = copyLocalePages(entry.localePages ?? {});
33
+ return { id: entry.id, name: entry.name, kind: entry.kind, page: entry.page, searchText: entry.searchText, localePages };
34
+ });
35
+ // <lang><zh-CN>只生成一份正文外检索索引,避免每个条目页重复整个站点目录。</zh-CN><en>Emit one body-free search index rather than duplicating the whole directory on every entry page.</en></lang>
36
+ const assets = Object.freeze([
37
+ Object.freeze({ path: "assets/hia-site-navigation.css", contents: SITE_STYLE + SITE_CHROME_STYLE + SITE_READING_STYLE }),
38
+ Object.freeze({ path: "assets/hia-site-reading.js", contents: SITE_READING_SCRIPT }),
39
+ Object.freeze({ path: "assets/hia-site-search.json", contents: JSON.stringify({ entries }) })
40
+ ]);
41
+ return Object.freeze({ assets, renderPage: (page) => renderPage(navigation, page) });
42
+ }
43
+ /**
44
+ * @lang zh-CN 根据显式页面上下文组合共享框架与可信slot。
45
+ * @lang en Combines shared chrome and trusted slots using explicit page context.
46
+ */
47
+ function renderPage(navigation, page) {
48
+ if (!page || !["index", "entry", "source"].includes(page.role) || !["zh-CN", "en"].includes(page.uiLocale))
49
+ invalid();
50
+ relative(page.outputPath);
51
+ if (!page.outputPath.endsWith(".html") || ![page.title, page.bodyHtml, page.directoryHtml].every(value => typeof value === "string"))
52
+ invalid();
53
+ if (!Array.isArray(page.sections) || [page.stylesheets, page.scripts].some(value => value !== undefined && !Array.isArray(value)) || page.dataHtml !== undefined && typeof page.dataHtml !== "string")
54
+ invalid();
55
+ // <lang><zh-CN>语言目标按实际页面独立复制,防止构造顶部时引用调用方可变对象。</zh-CN><en>Copy actual locale targets independently so header construction never retains caller-mutable objects.</en></lang>
56
+ const localePages = copyLocalePages(page.localePages);
57
+ const scheme = page.scheme ?? "system";
58
+ if (!["system", "light", "dark"].includes(scheme))
59
+ invalid();
60
+ if (page.role === "source" && (page.dataHtml || page.scripts?.length || /<script\b/iu.test(page.bodyHtml + page.directoryHtml)))
61
+ invalid();
62
+ // <lang><zh-CN>资产始终相对同一生成根,嵌套页面只增加所需上溯层数。</zh-CN><en>Assets remain relative to the same generation root; nested pages add only the required parent depth.</en></lang>
63
+ const prefix = "../".repeat(page.outputPath.split("/").length - 1);
64
+ const localeTargets = Object.fromEntries(Object.entries(localePages).map(([locale, path]) => [locale, prefix + path]));
65
+ const text = (id) => `<span data-hia-ui-message="${id}">${escape(SITE_READING_MESSAGES[id][page.uiLocale === "zh-CN" ? 0 : 1])}</span>`;
66
+ // <lang><zh-CN>本页小节按真实锚点去重与核对,再生成桌面/手机共享的链接。</zh-CN><en>Check and deduplicate actual page anchors before producing shared desktop/mobile outline links.</en></lang>
67
+ const sections = new Set();
68
+ const outline = page.sections.map(section => {
69
+ if (!/^[a-zA-Z][\w.:-]*$/u.test(section.id) || sections.has(section.id) || !page.bodyHtml.includes(`id="${section.id}"`) || typeof section.label !== "string")
70
+ invalid();
71
+ sections.add(section.id);
72
+ return `<a href="#${encodeURIComponent(section.id)}">${escape(section.label)}</a>`;
73
+ }).join("");
74
+ const outlineNav = `<nav data-hia-reading-outline>${outline}</nav>`;
75
+ const styles = (page.stylesheets ?? []).map(path => { relative(path); return `<link rel="stylesheet" href="${escape(prefix + path)}">`; }).join("");
76
+ const scripts = (page.scripts ?? []).map(path => { relative(path); return `<script src="${escape(prefix + path)}" defer></script>`; }).join("");
77
+ // <lang><zh-CN>源码页采用同一原生菜单与静态目录,不附加脚本按钮或正文数据。</zh-CN><en>Source pages use the same native menus and static directory without script controls or prose data.</en></lang>
78
+ const interactive = page.role !== "source";
79
+ let top = header(navigation, page.uiLocale, localeTargets);
80
+ if (!interactive)
81
+ top = top.replace(/<button\b[^>]*data-hia-reading-dialog[^>]*>[\s\S]*?<\/button>/gu, "");
82
+ const messages = escape(JSON.stringify(SITE_READING_MESSAGES));
83
+ const enhancement = interactive ? `${renderSiteReadingDialogs(text)}${page.dataHtml ?? ""}${scripts}<script src="${prefix}assets/hia-site-reading.js" data-hia-reading-messages="${messages}" data-hia-reading-pages="[]" data-hia-reading-static="${prefix}assets/hia-site-search.json" data-hia-reading-base="${prefix || "./"}" data-hia-reading-initial-scheme="${scheme}" data-hia-reading-initial-skin="portal.classic" defer></script>` : "";
84
+ const policy = interactive ? "" : '<meta http-equiv="Content-Security-Policy" content="default-src \'none\'; style-src \'self\' \'unsafe-inline\'; img-src data:; base-uri \'none\'; form-action \'none\'">';
85
+ return `<!doctype html>
86
+ <html lang="${page.uiLocale}" data-hia-site-navigation data-hia-site-chrome data-hia-scheme="${scheme}">
87
+ <head>
88
+ <meta charset="utf-8">
89
+ <meta name="viewport" content="width=device-width,initial-scale=1">
90
+ <meta name="color-scheme" content="light dark">
91
+ ${policy}
92
+ <title>${escape(page.title)}</title>
93
+ <link rel="icon" href="data:">
94
+ ${styles}
95
+ <link rel="stylesheet" href="${prefix}assets/hia-site-navigation.css">
96
+ </head>
97
+ <body>
98
+ ${top}
99
+ <div class="hia-shell hia-project-shell">
100
+ <details id="hia-site-directory" class="hia-site-directory" open>
101
+ <summary>${text("site.reading.directory")}</summary>
102
+ <aside class="hia-sidebar">${page.directoryHtml}</aside>
103
+ </details>
104
+ ${interactive ? '<script data-hia-directory-init>document.getElementById("hia-site-directory").open=!matchMedia("(max-width:800px)").matches;</script>' : ""}
105
+ <main id="hia-site-main" class="hia-main" tabindex="-1">
106
+ <details class="hia-site-mobile-outline"><summary>${text("site.reading.outline")}</summary>${outlineNav}</details>
107
+ <div data-hia-project-content>${page.bodyHtml}</div>
108
+ </main>
109
+ <aside class="hia-site-toc"><strong>${text("site.reading.outline")}</strong>${outlineNav}</aside>
110
+ </div>
111
+ ${enhancement}
112
+ </body>
113
+ </html>`;
114
+ }
115
+ /**
116
+ * @lang zh-CN 复制实际存在的语言路径,拒绝未知语言及不安全目标。
117
+ * @lang en Copies existing locale paths, rejecting unknown locales and unsafe targets.
118
+ */
119
+ function copyLocalePages(value) {
120
+ if (!value || typeof value !== "object" || Array.isArray(value))
121
+ invalid();
122
+ const result = {};
123
+ for (const [locale, path] of Object.entries(value)) {
124
+ if (locale !== "zh-CN" && locale !== "en")
125
+ invalid();
126
+ relative(path, true);
127
+ result[locale] = path;
128
+ }
129
+ return result;
130
+ }
131
+ /**
132
+ * @lang zh-CN 校验生成根相对路径,拒绝编码分隔符、逃逸、查询和外部协议。
133
+ * @lang en Validates root-relative output paths, rejecting encoded separators, traversal, queries, and external protocols.
134
+ */
135
+ function relative(value, fragment = false) {
136
+ if (typeof value !== "string" || !value || /[\\\u0000-\u0020<>"']/u.test(value) || value.startsWith("/"))
137
+ invalid();
138
+ const [pathname, ...hashes] = value.split("#");
139
+ if (hashes.length && (!fragment || hashes.length > 1 || !hashes[0]))
140
+ invalid();
141
+ // <lang><zh-CN>冒号和问号可属于原生不透明片段,但文件路径中的协议/查询仍拒绝。</zh-CN><en>Colons and question marks may belong to native opaque fragments, while path protocols and queries remain forbidden.</en></lang>
142
+ if (/[:?]/u.test(pathname))
143
+ invalid();
144
+ if (hashes.length) {
145
+ try {
146
+ if (/[\u0000-\u001f\u007f]/u.test(decodeURIComponent(hashes[0])))
147
+ invalid();
148
+ }
149
+ catch {
150
+ invalid();
151
+ }
152
+ }
153
+ for (const part of pathname.split("/")) {
154
+ let decoded;
155
+ try {
156
+ decoded = decodeURIComponent(part);
157
+ }
158
+ catch {
159
+ invalid();
160
+ }
161
+ if (!decoded || decoded === "." || decoded === ".." || /[\\/:?#\u0000-\u0020]/u.test(decoded))
162
+ invalid();
163
+ }
164
+ }
165
+ /**
166
+ * @lang zh-CN 统一转义纯文本,不处理可信HTML slot。
167
+ * @lang en Escapes plain text while leaving trusted HTML slots to their generator.
168
+ */
169
+ function escape(value) {
170
+ return value.replace(/[&<>"']/gu, character => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[character]);
171
+ }
172
+ /**
173
+ * @lang zh-CN 拒绝消息不包含路径或调用者输入。
174
+ * @lang en Refusal messages contain no paths or caller values.
175
+ */
176
+ function invalid() { throw new TypeError("HIA_SITE_CHROME_INVALID: Invalid site page context."); }
177
+ /**
178
+ * @lang zh-CN 独立页面的基础布局,不依赖通用文档主题的隐式CSS前置条件。
179
+ * @lang en Base layout for independent pages without implicit generic-document theme CSS prerequisites.
180
+ */
181
+ const SITE_CHROME_STYLE = `
182
+ [data-hia-site-chrome]{--hia-accent:#0047ab}
183
+ [data-hia-site-chrome] *,[data-hia-site-chrome] *::before,[data-hia-site-chrome] *::after{box-sizing:border-box}
184
+ [data-hia-site-chrome] .hia-shell{display:grid;align-items:start}
185
+ [data-hia-site-chrome] .hia-main{min-width:0}
186
+ `;
187
+ //# sourceMappingURL=site-chrome.js.map