@pterodoc/core 0.2.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.
Files changed (130) hide show
  1. package/LICENCE.md +10 -0
  2. package/README.md +12 -0
  3. package/lib/chunks/capture-BhdvHwrN.js +428 -0
  4. package/lib/chunks/capture-BhdvHwrN.js.map +1 -0
  5. package/lib/chunks/issues-DBsPh6ek.js +55 -0
  6. package/lib/chunks/issues-DBsPh6ek.js.map +1 -0
  7. package/lib/chunks/mime-2SUyOolJ.js +62 -0
  8. package/lib/chunks/mime-2SUyOolJ.js.map +1 -0
  9. package/lib/chunks/paths-Bh6UsRI9.js +177 -0
  10. package/lib/chunks/paths-Bh6UsRI9.js.map +1 -0
  11. package/lib/config/load.d.ts +123 -0
  12. package/lib/config/load.d.ts.map +1 -0
  13. package/lib/config/types.d.ts +136 -0
  14. package/lib/config/types.d.ts.map +1 -0
  15. package/lib/errors.d.ts +53 -0
  16. package/lib/errors.d.ts.map +1 -0
  17. package/lib/index.d.ts +23 -0
  18. package/lib/index.d.ts.map +1 -0
  19. package/lib/index.js +807 -0
  20. package/lib/index.js.map +1 -0
  21. package/lib/model/capture.d.ts +37 -0
  22. package/lib/model/capture.d.ts.map +1 -0
  23. package/lib/model/index.d.ts +13 -0
  24. package/lib/model/index.d.ts.map +1 -0
  25. package/lib/model/index.js +7 -0
  26. package/lib/model/index.js.map +1 -0
  27. package/lib/model/reader.d.ts +25 -0
  28. package/lib/model/reader.d.ts.map +1 -0
  29. package/lib/model/tree.d.ts +81 -0
  30. package/lib/model/tree.d.ts.map +1 -0
  31. package/lib/model/types.d.ts +166 -0
  32. package/lib/model/types.d.ts.map +1 -0
  33. package/lib/render/admonitions.d.ts +26 -0
  34. package/lib/render/admonitions.d.ts.map +1 -0
  35. package/lib/render/blocks.d.ts +39 -0
  36. package/lib/render/blocks.d.ts.map +1 -0
  37. package/lib/render/code.d.ts +37 -0
  38. package/lib/render/code.d.ts.map +1 -0
  39. package/lib/render/components.d.ts +49 -0
  40. package/lib/render/components.d.ts.map +1 -0
  41. package/lib/render/excerpt.d.ts +9 -0
  42. package/lib/render/excerpt.d.ts.map +1 -0
  43. package/lib/render/images.d.ts +58 -0
  44. package/lib/render/images.d.ts.map +1 -0
  45. package/lib/render/index.d.ts +80 -0
  46. package/lib/render/index.d.ts.map +1 -0
  47. package/lib/render/index.js +1336 -0
  48. package/lib/render/index.js.map +1 -0
  49. package/lib/render/inline.d.ts +25 -0
  50. package/lib/render/inline.d.ts.map +1 -0
  51. package/lib/render/links.d.ts +45 -0
  52. package/lib/render/links.d.ts.map +1 -0
  53. package/lib/render/mdx.d.ts +37 -0
  54. package/lib/render/mdx.d.ts.map +1 -0
  55. package/lib/render/page.d.ts +85 -0
  56. package/lib/render/page.d.ts.map +1 -0
  57. package/lib/render/parse.d.ts +27 -0
  58. package/lib/render/parse.d.ts.map +1 -0
  59. package/lib/render/references.d.ts +20 -0
  60. package/lib/render/references.d.ts.map +1 -0
  61. package/lib/render/renderers.d.ts +57 -0
  62. package/lib/render/renderers.d.ts.map +1 -0
  63. package/lib/render/slug.d.ts +34 -0
  64. package/lib/render/slug.d.ts.map +1 -0
  65. package/lib/render/theme.d.ts +62 -0
  66. package/lib/render/theme.d.ts.map +1 -0
  67. package/lib/sync/artifacts.d.ts +46 -0
  68. package/lib/sync/artifacts.d.ts.map +1 -0
  69. package/lib/sync/plan.d.ts +59 -0
  70. package/lib/sync/plan.d.ts.map +1 -0
  71. package/lib/sync/run.d.ts +39 -0
  72. package/lib/sync/run.d.ts.map +1 -0
  73. package/lib/target/index.d.ts +8 -0
  74. package/lib/target/index.d.ts.map +1 -0
  75. package/lib/target/index.js +2 -0
  76. package/lib/target/index.js.map +1 -0
  77. package/lib/target/target.d.ts +152 -0
  78. package/lib/target/target.d.ts.map +1 -0
  79. package/lib/util/hash.d.ts +10 -0
  80. package/lib/util/hash.d.ts.map +1 -0
  81. package/lib/util/index.d.ts +14 -0
  82. package/lib/util/index.d.ts.map +1 -0
  83. package/lib/util/index.js +7 -0
  84. package/lib/util/index.js.map +1 -0
  85. package/lib/util/issues.d.ts +52 -0
  86. package/lib/util/issues.d.ts.map +1 -0
  87. package/lib/util/mime.d.ts +16 -0
  88. package/lib/util/mime.d.ts.map +1 -0
  89. package/lib/util/paths.d.ts +42 -0
  90. package/lib/util/paths.d.ts.map +1 -0
  91. package/lib/version.d.ts +6 -0
  92. package/lib/version.d.ts.map +1 -0
  93. package/package.json +43 -0
  94. package/src/config/load.ts +387 -0
  95. package/src/config/types.ts +137 -0
  96. package/src/errors.ts +77 -0
  97. package/src/globals.d.ts +10 -0
  98. package/src/index.ts +31 -0
  99. package/src/model/capture.ts +92 -0
  100. package/src/model/index.ts +25 -0
  101. package/src/model/reader.ts +37 -0
  102. package/src/model/tree.ts +416 -0
  103. package/src/model/types.ts +167 -0
  104. package/src/render/admonitions.ts +74 -0
  105. package/src/render/blocks.ts +79 -0
  106. package/src/render/code.ts +112 -0
  107. package/src/render/components.ts +230 -0
  108. package/src/render/excerpt.ts +16 -0
  109. package/src/render/images.ts +113 -0
  110. package/src/render/index.ts +129 -0
  111. package/src/render/inline.ts +62 -0
  112. package/src/render/links.ts +94 -0
  113. package/src/render/mdx.ts +178 -0
  114. package/src/render/page.ts +289 -0
  115. package/src/render/parse.ts +65 -0
  116. package/src/render/references.ts +69 -0
  117. package/src/render/renderers.ts +346 -0
  118. package/src/render/slug.ts +63 -0
  119. package/src/render/theme.ts +92 -0
  120. package/src/sync/artifacts.ts +70 -0
  121. package/src/sync/plan.ts +69 -0
  122. package/src/sync/run.ts +641 -0
  123. package/src/target/index.ts +18 -0
  124. package/src/target/target.ts +146 -0
  125. package/src/util/hash.ts +14 -0
  126. package/src/util/index.ts +23 -0
  127. package/src/util/issues.ts +86 -0
  128. package/src/util/mime.ts +47 -0
  129. package/src/util/paths.ts +101 -0
  130. package/src/version.ts +31 -0
package/LICENCE.md ADDED
@@ -0,0 +1,10 @@
1
+ Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
2
+
3
+ Copyright (c) Onyx <hello@onyx.ac> (https://onyx.ac)
4
+
5
+ This work is licensed under the Creative Commons Attribution-ShareAlike 4.0
6
+ International License. You are free to share and adapt this work, including
7
+ commercially, provided you give appropriate attribution and distribute any
8
+ derivative works under the same license.
9
+
10
+ Full legal text: https://creativecommons.org/licenses/by-sa/4.0/legalcode
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # @pterodoc/core
2
+
3
+ The parts of [pterodoc](https://github.com/onyx-ac/pterodoc) that know neither where a
4
+ documentation model came from nor where it is going: markdown and MDX rendering to
5
+ Gutenberg blocks, the site model and page tree, the target contract, configuration, and
6
+ the reconciler.
7
+
8
+ You probably want the [`pterodoc`](https://www.npmjs.com/package/pterodoc) package
9
+ instead. This one is what a source package (`@pterodoc/docusaurus`) or a target package
10
+ (`@pterodoc/wordpress`) builds on.
11
+
12
+ Licensed CC-BY-SA-4.0.
@@ -0,0 +1,428 @@
1
+ import 'node:fs';
2
+ import 'node:crypto';
3
+ import { t as titleCase, C as ConfigError, V as VERSION } from './paths-Bh6UsRI9.js';
4
+ import fs from 'node:fs/promises';
5
+ import path from 'node:path';
6
+
7
+ /**
8
+ * The page tree.
9
+ *
10
+ * Docusaurus hands over resolved sidebars — autogenerated ones already
11
+ * expanded — and documents that already know their permalink and their
12
+ * neighbours. This turns that into the tree of pages the target will mirror:
13
+ * one node per page, ordered as the sidebar orders them.
14
+ */
15
+ /** The longest directory prefix shared by a set of tree paths. */
16
+ function commonDirectory(paths) {
17
+ if (paths.length === 0)
18
+ return '';
19
+ const dirOf = (value) => {
20
+ const parts = value.split('/').filter(Boolean);
21
+ return parts.slice(0, -1);
22
+ };
23
+ let common = dirOf(paths[0]);
24
+ for (const value of paths.slice(1)) {
25
+ const parts = dirOf(value);
26
+ let index = 0;
27
+ while (index < common.length && index < parts.length && common[index] === parts[index])
28
+ index += 1;
29
+ common = common.slice(0, index);
30
+ if (common.length === 0)
31
+ break;
32
+ }
33
+ return common.join('/');
34
+ }
35
+ /**
36
+ * Walk resolved sidebars into document order and the categories that can name
37
+ * a directory.
38
+ */
39
+ function flattenSidebars(items, docsById, issues) {
40
+ const order = [];
41
+ const categories = [];
42
+ const pathOf = (id) => docsById.get(id)?.treePath;
43
+ const walk = (nodes, deep, direct) => {
44
+ for (const node of nodes) {
45
+ if (node.type === 'ref') {
46
+ // A ref points into a different sidebar. It is a cross-reference, not a
47
+ // page of this one, so it never becomes a page here.
48
+ issues.add({
49
+ code: 'sidebar-ref-item',
50
+ severity: 'info',
51
+ message: `The sidebar cross-references "${node.id}", which belongs to another sidebar and was not published here.`,
52
+ });
53
+ continue;
54
+ }
55
+ if (node.type === 'doc') {
56
+ const treePath = pathOf(node.id);
57
+ if (treePath === undefined) {
58
+ issues.add({
59
+ code: 'sidebar-doc-missing',
60
+ severity: 'warning',
61
+ message: `The sidebar lists "${node.id}", but no such document was loaded.`,
62
+ });
63
+ continue;
64
+ }
65
+ order.push(treePath);
66
+ deep?.push(treePath);
67
+ direct?.push(treePath);
68
+ continue;
69
+ }
70
+ if (node.type === 'category') {
71
+ const category = node;
72
+ const deepPaths = [];
73
+ const directPaths = [];
74
+ let linkPath;
75
+ if (category.link?.type === 'doc') {
76
+ // The category's own page comes before its members. It is deliberately
77
+ // kept out of `deepPaths`: it sits one level above them, and counting
78
+ // it as a member would drag the shared directory up with it.
79
+ linkPath = pathOf(category.link.id);
80
+ if (linkPath !== undefined)
81
+ order.push(linkPath);
82
+ }
83
+ walk(category.items ?? [], deepPaths, directPaths);
84
+ categories.push({ label: category.label, linkPath, deepPaths, directPaths });
85
+ // The parent does see it, because it really is one of the parent's pages.
86
+ if (linkPath !== undefined)
87
+ deep?.push(linkPath);
88
+ deep?.push(...deepPaths);
89
+ continue;
90
+ }
91
+ // `link` and `html` entries are navigation furniture, not pages.
92
+ issues.add({
93
+ code: node.type === 'link' ? 'sidebar-link-item' : 'sidebar-html-item',
94
+ severity: 'info',
95
+ message: node.type === 'link'
96
+ ? `The sidebar link "${node.label}" has no page to publish.`
97
+ : 'A raw HTML sidebar entry has no page to publish.',
98
+ });
99
+ }
100
+ };
101
+ walk(items, null, null);
102
+ return { order, categories };
103
+ }
104
+ /**
105
+ * Build one version's page tree.
106
+ */
107
+ function buildPageTree(input) {
108
+ const { version, issues } = input;
109
+ const sidebarNames = input.sidebars === 'all' ? Object.keys(version.sidebars) : input.sidebars;
110
+ const publishable = version.docs.filter((doc) => {
111
+ if (doc.unlisted && input.includeUnlisted !== true) {
112
+ issues.addFor(doc, {
113
+ code: 'doc-unlisted',
114
+ severity: 'info',
115
+ message: `"${doc.id}" is unlisted and was not published.`,
116
+ });
117
+ return false;
118
+ }
119
+ return true;
120
+ });
121
+ const docsById = new Map(publishable.map((doc) => [doc.id, doc]));
122
+ const order = [];
123
+ const categories = [];
124
+ for (const name of sidebarNames) {
125
+ const items = version.sidebars[name];
126
+ if (!items) {
127
+ issues.add({
128
+ code: 'sidebar-missing',
129
+ severity: 'warning',
130
+ message: `This version has no sidebar called "${name}".`,
131
+ });
132
+ continue;
133
+ }
134
+ const flattened = flattenSidebars(items, docsById, issues);
135
+ order.push(...flattened.order);
136
+ categories.push(...flattened.categories);
137
+ }
138
+ // Outermost category wins a directory; the rest become section labels.
139
+ const claimed = new Map();
140
+ const virtual = [];
141
+ for (const category of categories) {
142
+ if (category.deepPaths.length === 0 && category.linkPath === undefined) {
143
+ issues.add({
144
+ code: 'sidebar-category-empty',
145
+ severity: 'info',
146
+ message: `The sidebar category "${category.label}" has no published documents.`,
147
+ });
148
+ continue;
149
+ }
150
+ const directory = category.linkPath ?? commonDirectory(category.deepPaths);
151
+ if (directory && !claimed.has(directory))
152
+ claimed.set(directory, category.label);
153
+ else
154
+ virtual.push(category);
155
+ }
156
+ const byPath = new Map();
157
+ const root = {
158
+ path: '',
159
+ slug: '',
160
+ kind: 'root',
161
+ title: input.rootTitle,
162
+ children: [],
163
+ menuOrder: 0,
164
+ navIndex: -1,
165
+ sections: [],
166
+ versionName: version.name,
167
+ inSidebar: true,
168
+ };
169
+ byPath.set('', root);
170
+ const parentPathOf = (value) => {
171
+ const parts = value.split('/').filter(Boolean);
172
+ return parts.slice(0, -1).join('/');
173
+ };
174
+ const ensureDir = (dirPath) => {
175
+ if (dirPath === '')
176
+ return root;
177
+ const existing = byPath.get(dirPath);
178
+ if (existing)
179
+ return existing;
180
+ const parent = ensureDir(parentPathOf(dirPath));
181
+ const slug = dirPath.slice(dirPath.lastIndexOf('/') + 1);
182
+ const node = {
183
+ path: dirPath,
184
+ slug,
185
+ kind: 'dir',
186
+ title: claimed.get(dirPath) ?? titleCase(slug),
187
+ parent,
188
+ children: [],
189
+ menuOrder: 0,
190
+ navIndex: -1,
191
+ sections: [],
192
+ versionName: version.name,
193
+ inSidebar: false,
194
+ };
195
+ byPath.set(dirPath, node);
196
+ return node;
197
+ };
198
+ // Only what a published sidebar reaches becomes a page. A document that
199
+ // belongs to another sidebar — a generated API reference, say — is not
200
+ // orphaned, it simply is not part of what was asked for.
201
+ const reachable = new Set(order);
202
+ const included = publishable.filter((doc) => {
203
+ if (doc.treePath === '' || reachable.has(doc.treePath))
204
+ return true;
205
+ if (doc.sidebarName === undefined && input.includeOrphans === true)
206
+ return true;
207
+ return false;
208
+ });
209
+ // The version root can be a document too, when one has the version's own slug.
210
+ const rootDoc = included.find((doc) => doc.treePath === '');
211
+ if (rootDoc) {
212
+ root.doc = rootDoc;
213
+ if (!input.rootTitle)
214
+ root.title = rootDoc.title;
215
+ }
216
+ for (const doc of included) {
217
+ if (doc.treePath === '')
218
+ continue;
219
+ const existing = byPath.get(doc.treePath);
220
+ if (existing) {
221
+ // A directory page and a document at the same path: the document wins,
222
+ // which is how an `index.md` or a front-matter slug takes over a folder.
223
+ existing.doc = doc;
224
+ existing.description = doc.description;
225
+ if (!claimed.has(doc.treePath))
226
+ existing.title = doc.title;
227
+ continue;
228
+ }
229
+ const parent = ensureDir(parentPathOf(doc.treePath));
230
+ const slug = doc.treePath.slice(doc.treePath.lastIndexOf('/') + 1);
231
+ byPath.set(doc.treePath, {
232
+ path: doc.treePath,
233
+ slug,
234
+ kind: 'doc',
235
+ // A category that names this page wins the title: on WordPress the page
236
+ // title is also its navigation label, and the sidebar label is what a
237
+ // reader saw in the navigation on Docusaurus.
238
+ title: claimed.get(doc.treePath) ?? doc.title,
239
+ description: doc.description,
240
+ doc,
241
+ parent,
242
+ children: [],
243
+ menuOrder: 0,
244
+ navIndex: -1,
245
+ sections: [],
246
+ versionName: version.name,
247
+ inSidebar: false,
248
+ });
249
+ }
250
+ // Sidebar order first: placing a node places any ancestor not yet placed, so
251
+ // a directory lands at the position of its first member.
252
+ const placed = new Set(['']);
253
+ const place = (node) => {
254
+ if (placed.has(node.path))
255
+ return;
256
+ const parent = node.parent ?? root;
257
+ place(parent);
258
+ parent.children.push(node);
259
+ placed.add(node.path);
260
+ };
261
+ for (const treePath of order) {
262
+ const node = byPath.get(treePath);
263
+ if (!node)
264
+ continue;
265
+ node.inSidebar = true;
266
+ if (node !== root)
267
+ place(node);
268
+ }
269
+ for (const node of [...byPath.values()].sort((a, b) => a.path.localeCompare(b.path))) {
270
+ if (placed.has(node.path))
271
+ continue;
272
+ place(node);
273
+ issues.addFor(node.doc, {
274
+ code: 'doc-not-in-sidebar',
275
+ severity: 'info',
276
+ message: `"${node.path}" is not in a published sidebar; it was placed after the pages that are.`,
277
+ path: node.path,
278
+ });
279
+ }
280
+ // Grouping for generated indexes.
281
+ const sectionLabelOf = new Map();
282
+ for (const category of virtual) {
283
+ for (const treePath of category.directPaths)
284
+ sectionLabelOf.set(treePath, category.label);
285
+ }
286
+ const chain = [];
287
+ const finish = (node) => {
288
+ node.children.forEach((child, index) => {
289
+ child.menuOrder = index * 10;
290
+ });
291
+ const sections = [];
292
+ for (const child of node.children) {
293
+ const label = sectionLabelOf.get(child.path);
294
+ const last = sections[sections.length - 1];
295
+ if (last && last.label === label)
296
+ last.children.push(child);
297
+ else
298
+ sections.push({ label, children: [child] });
299
+ }
300
+ node.sections = sections;
301
+ for (const child of node.children) {
302
+ child.navIndex = chain.length;
303
+ chain.push(child);
304
+ finish(child);
305
+ }
306
+ };
307
+ finish(root);
308
+ // Pagination walks the pages that exist here.
309
+ //
310
+ // Docusaurus's own previous/next skip a category that has no document of its
311
+ // own, because on that site such a category is not a page. Here it is one:
312
+ // it has a URL a reader can land on, so sending them past it would be wrong.
313
+ chain.forEach((node, index) => {
314
+ const previous = chain[index - 1];
315
+ const next = chain[index + 1];
316
+ if (previous)
317
+ node.previousPath = previous.path;
318
+ if (next)
319
+ node.nextPath = next.path;
320
+ });
321
+ const byPermalink = new Map();
322
+ const bySourcePath = new Map();
323
+ for (const node of byPath.values()) {
324
+ if (!node.doc)
325
+ continue;
326
+ byPermalink.set(node.doc.permalink, node);
327
+ byPermalink.set(node.doc.permalink.replace(/\/$/, ''), node);
328
+ bySourcePath.set(node.doc.sourceRelativePath, node);
329
+ }
330
+ return { root, chain, byPath, byPermalink, bySourcePath };
331
+ }
332
+
333
+ /**
334
+ * Where a site model comes from.
335
+ *
336
+ * The rest of the tool takes a reader rather than calling a source directly,
337
+ * which is what lets it be tested against a captured model, driven by a build,
338
+ * or pointed at a real site. The interface lives here, with the model it
339
+ * produces; each source implements it in its own package.
340
+ */
341
+ /**
342
+ * Read from a model already in hand, which is what a build-time plugin does.
343
+ *
344
+ * @param model The model to serve.
345
+ */
346
+ function createMemoryReader(model) {
347
+ return {
348
+ kind: 'memory',
349
+ async locales() {
350
+ return [model.locale];
351
+ },
352
+ async read() {
353
+ return model;
354
+ },
355
+ };
356
+ }
357
+
358
+ /**
359
+ * Capturing a site model to disk.
360
+ *
361
+ * A captured model is how the tests avoid needing a Docusaurus install, how a
362
+ * user files a reproducible bug, and how a site whose Docusaurus version this
363
+ * tool cannot load can still be rendered.
364
+ */
365
+ /** Serialise a model. */
366
+ function serializeModel(model) {
367
+ const captured = {
368
+ capture: 1,
369
+ pterodoc: VERSION,
370
+ capturedAt: new Date().toISOString(),
371
+ model,
372
+ };
373
+ return `${JSON.stringify(captured, null, 2)}\n`;
374
+ }
375
+ /** Write a model to a file, creating its directory. */
376
+ async function writeCapture(file, model) {
377
+ await fs.mkdir(path.dirname(path.resolve(file)), { recursive: true });
378
+ await fs.writeFile(file, serializeModel(model), 'utf8');
379
+ }
380
+ /**
381
+ * Read a captured model.
382
+ *
383
+ * @param file Path of the capture.
384
+ */
385
+ async function readCapture(file) {
386
+ let raw;
387
+ try {
388
+ raw = await fs.readFile(file, 'utf8');
389
+ }
390
+ catch {
391
+ throw new ConfigError(`Could not read the model at ${file}.`);
392
+ }
393
+ let parsed;
394
+ try {
395
+ parsed = JSON.parse(raw);
396
+ }
397
+ catch {
398
+ throw new ConfigError(`${file} is not valid JSON.`);
399
+ }
400
+ if (parsed.capture !== 1 || !parsed.model) {
401
+ throw new ConfigError(`${file} is not a pterodoc model capture. Produce one with \`pterodoc capture\`.`);
402
+ }
403
+ return parsed.model;
404
+ }
405
+ /**
406
+ * Read from a model captured earlier.
407
+ *
408
+ * @param file Path to the capture.
409
+ */
410
+ function createCaptureReader(file) {
411
+ let cached;
412
+ const load = async () => {
413
+ cached ??= await readCapture(file);
414
+ return cached;
415
+ };
416
+ return {
417
+ kind: 'captured',
418
+ async locales() {
419
+ return [(await load()).locale];
420
+ },
421
+ async read() {
422
+ return load();
423
+ },
424
+ };
425
+ }
426
+
427
+ export { createMemoryReader as a, buildPageTree as b, createCaptureReader as c, readCapture as r, serializeModel as s, writeCapture as w };
428
+ //# sourceMappingURL=capture-BhdvHwrN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture-BhdvHwrN.js","sources":["../../src/model/tree.ts","../../src/model/reader.ts","../../src/model/capture.ts"],"sourcesContent":[null,null,null],"names":[],"mappings":";;;;;;AAAA;;;;;;;AAOG;AAwEH;AACA,SAAS,eAAe,CAAC,KAAe,EAAA;AACtC,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;AAAE,QAA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I,WAAW,CAAC,GAAG,IAAI,CAAA,mBAAA,CAAqB,CAAC;IACrD;IAEA,IAAI,MAAM,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;AACzC,QAAA,MAAM,IAAI,WAAW,CACnB,GAAG,IAAI,CAAA,wEAAA,CAA0E,CAClF;IACH;IACA,OAAO,MAAM,CAAC,KAAK;AACrB;AAEA;;;;AAIG;AACG,SAAU,mBAAmB,CAAC,IAAY,EAAA;AAC9C,IAAA,IAAI,MAA6B;AACjC,IAAA,MAAM,IAAI,GAAG,YAA+B;AAC1C,QAAA,MAAM,KAAK,MAAM,WAAW,CAAC,IAAI,CAAC;AAClC,QAAA,OAAO,MAAM;AACf,IAAA,CAAC;IACD,OAAO;AACL,QAAA,IAAI,EAAE,UAAU;AAChB,QAAA,MAAM,OAAO,GAAA;YACX,OAAO,CAAC,CAAC,MAAM,IAAI,EAAE,EAAE,MAAM,CAAC;QAChC,CAAC;AACD,QAAA,MAAM,IAAI,GAAA;YACR,OAAO,IAAI,EAAE;QACf,CAAC;KACF;AACH;;"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Structured diagnostics.
3
+ *
4
+ * Everything a run wants to tell the user goes through here rather than into
5
+ * free-form strings, so the CLI can group them, `--json` can emit them, and
6
+ * `--strict` can decide whether they should fail the run.
7
+ */
8
+ const ORDER = { info: 0, warning: 1, error: 2 };
9
+ /** Accumulates issues during a run. */
10
+ class IssueCollector {
11
+ issues = [];
12
+ /** Record an issue. */
13
+ add(issue) {
14
+ this.issues.push(issue);
15
+ }
16
+ /** Record an issue that inherits a document's file and id. */
17
+ addFor(doc, issue) {
18
+ this.add({
19
+ ...issue,
20
+ docId: doc?.id,
21
+ file: issue.file ?? doc?.sourceRelativePath,
22
+ });
23
+ }
24
+ /** True when any issue is at least as severe as `severity`. */
25
+ hasAtLeast(severity) {
26
+ return this.issues.some((issue) => ORDER[issue.severity] >= ORDER[severity]);
27
+ }
28
+ /** Issues at least as severe as `severity`. */
29
+ atLeast(severity) {
30
+ return this.issues.filter((issue) => ORDER[issue.severity] >= ORDER[severity]);
31
+ }
32
+ /** How many issues carry each code, for a compact summary. */
33
+ countByCode() {
34
+ const counts = {};
35
+ for (const issue of this.issues)
36
+ counts[issue.code] = (counts[issue.code] ?? 0) + 1;
37
+ return counts;
38
+ }
39
+ }
40
+ /** Compare two severities; positive when `a` is more severe than `b`. */
41
+ function compareSeverity(a, b) {
42
+ return ORDER[a] - ORDER[b];
43
+ }
44
+ /** Render an issue as one line, with its position when it has one. */
45
+ function formatIssue(issue) {
46
+ const where = issue.file
47
+ ? `${issue.file}${issue.line ? `:${issue.line}${issue.column ? `:${issue.column}` : ''}` : ''}: `
48
+ : issue.path
49
+ ? `${issue.path || '(root)'}: `
50
+ : '';
51
+ return `${where}${issue.message}`;
52
+ }
53
+
54
+ export { IssueCollector as I, compareSeverity as c, formatIssue as f };
55
+ //# sourceMappingURL=issues-DBsPh6ek.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issues-DBsPh6ek.js","sources":["../../src/util/issues.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;AAMG;AAKH,MAAM,KAAK,GAA6B,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;AAsBzE;MACa,cAAc,CAAA;IAChB,MAAM,GAAY,EAAE;;AAG7B,IAAA,GAAG,CAAC,KAAY,EAAA;AACd,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB;;IAGA,MAAM,CACJ,GAA4D,EAC5D,KAAwD,EAAA;QAExD,IAAI,CAAC,GAAG,CAAC;AACP,YAAA,GAAG,KAAK;YACR,KAAK,EAAE,GAAG,EAAE,EAAE;AACd,YAAA,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,GAAG,EAAE,kBAAkB;AAC5C,SAAA,CAAC;IACJ;;AAGA,IAAA,UAAU,CAAC,QA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0 +1,62 @@
1
+ import { createHash } from 'node:crypto';
2
+
3
+ /** Content hashing, used to give an uploaded asset a stable identity. */
4
+ /**
5
+ * A short content hash.
6
+ *
7
+ * Sixteen hex characters of SHA-256: long enough that a collision across one
8
+ * site's assets is not a practical concern, short enough to sit inside a
9
+ * WordPress slug without dominating it.
10
+ */
11
+ function contentHash(bytes) {
12
+ return createHash('sha256').update(bytes).digest('hex').slice(0, 16);
13
+ }
14
+
15
+ /**
16
+ * Extension to media type.
17
+ *
18
+ * A twenty-entry table rather than a dependency: these are the types a
19
+ * documentation site actually embeds, and WordPress rejects most others.
20
+ */
21
+ const TYPES = {
22
+ '.apng': 'image/apng',
23
+ '.avif': 'image/avif',
24
+ '.bmp': 'image/bmp',
25
+ '.gif': 'image/gif',
26
+ '.ico': 'image/x-icon',
27
+ '.jpeg': 'image/jpeg',
28
+ '.jpg': 'image/jpeg',
29
+ '.png': 'image/png',
30
+ '.svg': 'image/svg+xml',
31
+ '.tif': 'image/tiff',
32
+ '.tiff': 'image/tiff',
33
+ '.webp': 'image/webp',
34
+ '.mp4': 'video/mp4',
35
+ '.webm': 'video/webm',
36
+ '.ogv': 'video/ogg',
37
+ '.mp3': 'audio/mpeg',
38
+ '.wav': 'audio/wav',
39
+ '.pdf': 'application/pdf',
40
+ '.zip': 'application/zip',
41
+ '.json': 'application/json',
42
+ '.txt': 'text/plain',
43
+ };
44
+ /** The media type for a file name, or undefined when we do not recognise it. */
45
+ function mimeTypeFor(fileName) {
46
+ const dot = fileName.lastIndexOf('.');
47
+ if (dot === -1)
48
+ return undefined;
49
+ return TYPES[fileName.slice(dot).toLowerCase()];
50
+ }
51
+ /**
52
+ * True for types WordPress refuses by default.
53
+ *
54
+ * SVG is the one that surprises people: it is blocked unless a plugin allows
55
+ * it, because an SVG can carry script.
56
+ */
57
+ function isBlockedByDefault(mime) {
58
+ return mime === 'image/svg+xml';
59
+ }
60
+
61
+ export { contentHash as c, isBlockedByDefault as i, mimeTypeFor as m };
62
+ //# sourceMappingURL=mime-2SUyOolJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mime-2SUyOolJ.js","sources":["../../src/util/hash.ts","../../src/util/mime.ts"],"sourcesContent":[null,null],"names":[],"mappings":";;AAAA;AAIA;;;;;;AAMG;AACG,SAAU,WAAW,CAAC,KAA0B,EAAA;IACpD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;AACtE;;ACbA;;;;;AAKG;AAEH,MAAM,KAAK,GAA2B;AACpC,IAAA,OAAO,EAAE,YAAY;AACrB,IAAA,OAAO,EAAE,YAAY;AACrB,IAAA,MAAM,EAAE,WAAW;AACnB,IAAA,MAAM,EAAE,WAAW;AACnB,IAAA,MAAM,EAAE,cAAc;AACtB,IAAA,OAAO,EAAE,YAAY;AACrB,IAAA,MAAM,EAAE,YAAY;AACpB,IAAA,MAAM,EAAE,WAAW;AACnB,IAAA,MAAM,EAAE,eAAe;AACvB,IAAA,MAAM,EAAE,YAAY;AACpB,IAAA,OAAO,EAAE,YAAY;AACrB,IAAA,OAAO,EAAE,YAAY;AACrB,IAAA,MAAM,EAAE,WAAW;AACnB,IAAA,OAAO,EAAE,YAAY;AACrB,IAAA,MAAM,EAAE,WAAW;AACnB,IAAA,MAAM,EAAE,YAAY;AACpB,IAAA,MAAM,EAAE,WAAW;AACnB,IAAA,MAAM,EAAE,iBAAiB;AACzB,IAAA,MAAM,EAAE,iBAAiB;AACzB,IAAA,OAAO,EAAE,kBAAkB;AAC3B,IAAA,MAAM,EAAE,YAAY;CACrB;AAED;AACM,SAAU,WAAW,CAAC,QAAgB,EAAA;IAC1C,MAAM,GAAG,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC;IACrC,IAAI,GAAG,KAAK,EAAE;AAAE,QAAA,OAAO,SAAS;AAChC,IAAA,OAAO,KAAK,CAAC,QA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