@wastech-mdlint/viewer 0.0.0-stage → 0.4.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 (189) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -2
  3. package/assets/favicon.ico +0 -0
  4. package/assets/viewer.css +4184 -0
  5. package/dist/asset-routes.d.ts +4 -0
  6. package/dist/asset-routes.js +107 -0
  7. package/dist/blame.d.ts +8 -0
  8. package/dist/blame.js +54 -0
  9. package/dist/branch-changes.d.ts +8 -0
  10. package/dist/branch-changes.js +49 -0
  11. package/dist/candidate-lint-worker.d.ts +1 -0
  12. package/dist/candidate-lint-worker.js +67 -0
  13. package/dist/candidate-lint.d.ts +39 -0
  14. package/dist/candidate-lint.js +115 -0
  15. package/dist/change-banner.d.ts +38 -0
  16. package/dist/change-banner.js +108 -0
  17. package/dist/change-diff.d.ts +23 -0
  18. package/dist/change-diff.js +140 -0
  19. package/dist/change-marks.d.ts +32 -0
  20. package/dist/change-marks.js +363 -0
  21. package/dist/changes-article.d.ts +15 -0
  22. package/dist/changes-article.js +244 -0
  23. package/dist/changes-routes.d.ts +12 -0
  24. package/dist/changes-routes.js +271 -0
  25. package/dist/changes.d.ts +113 -0
  26. package/dist/changes.js +324 -0
  27. package/dist/cli-args.d.ts +21 -0
  28. package/dist/cli-args.js +93 -0
  29. package/dist/client/banner-height.d.ts +1 -0
  30. package/dist/client/banner-height.js +33 -0
  31. package/dist/client/change-marks.d.ts +1 -0
  32. package/dist/client/change-marks.js +56 -0
  33. package/dist/client/changes.d.ts +1 -0
  34. package/dist/client/changes.js +183 -0
  35. package/dist/client/chart-option.d.ts +3 -0
  36. package/dist/client/chart-option.js +76 -0
  37. package/dist/client/charts.d.ts +1 -0
  38. package/dist/client/charts.js +54 -0
  39. package/dist/client/clipboard.d.ts +1 -0
  40. package/dist/client/clipboard.js +43 -0
  41. package/dist/client/code-copy.d.ts +1 -0
  42. package/dist/client/code-copy.js +29 -0
  43. package/dist/client/column-resize.d.ts +1 -0
  44. package/dist/client/column-resize.js +120 -0
  45. package/dist/client/config-dom.d.ts +13 -0
  46. package/dist/client/config-dom.js +47 -0
  47. package/dist/client/config-draft.d.ts +73 -0
  48. package/dist/client/config-draft.js +218 -0
  49. package/dist/client/config-editor.d.ts +3 -0
  50. package/dist/client/config-editor.js +677 -0
  51. package/dist/client/config-fields.d.ts +35 -0
  52. package/dist/client/config-fields.js +339 -0
  53. package/dist/client/config-json.d.ts +18 -0
  54. package/dist/client/config-json.js +96 -0
  55. package/dist/client/config-preview.d.ts +9 -0
  56. package/dist/client/config-preview.js +91 -0
  57. package/dist/client/config-rules.d.ts +14 -0
  58. package/dist/client/config-rules.js +202 -0
  59. package/dist/client/config-types.d.ts +91 -0
  60. package/dist/client/config-types.js +4 -0
  61. package/dist/client/copy-path.d.ts +1 -0
  62. package/dist/client/copy-path.js +32 -0
  63. package/dist/client/dashboard-requests.d.ts +11 -0
  64. package/dist/client/dashboard-requests.js +28 -0
  65. package/dist/client/dashboard.d.ts +1 -0
  66. package/dist/client/dashboard.js +119 -0
  67. package/dist/client/diagnostics.d.ts +1 -0
  68. package/dist/client/diagnostics.js +164 -0
  69. package/dist/client/diagrams.d.ts +1 -0
  70. package/dist/client/diagrams.js +81 -0
  71. package/dist/client/diff-expand.d.ts +1 -0
  72. package/dist/client/diff-expand.js +42 -0
  73. package/dist/client/display-settings-model.d.ts +74 -0
  74. package/dist/client/display-settings-model.js +229 -0
  75. package/dist/client/display-settings.d.ts +1 -0
  76. package/dist/client/display-settings.js +411 -0
  77. package/dist/client/echarts.d.ts +30 -0
  78. package/dist/client/echarts.js +14 -0
  79. package/dist/client/graph-layout.d.ts +88 -0
  80. package/dist/client/graph-layout.js +198 -0
  81. package/dist/client/graph.d.ts +2 -0
  82. package/dist/client/graph.js +566 -0
  83. package/dist/client/history.d.ts +21 -0
  84. package/dist/client/history.js +86 -0
  85. package/dist/client/live-reload-model.d.ts +28 -0
  86. package/dist/client/live-reload-model.js +52 -0
  87. package/dist/client/live-reload.d.ts +9 -0
  88. package/dist/client/live-reload.js +138 -0
  89. package/dist/client/menu.d.ts +14 -0
  90. package/dist/client/menu.js +176 -0
  91. package/dist/client/navigation-feedback.d.ts +1 -0
  92. package/dist/client/navigation-feedback.js +141 -0
  93. package/dist/client/open-config.d.ts +1 -0
  94. package/dist/client/open-config.js +48 -0
  95. package/dist/client/outline-spy.d.ts +1 -0
  96. package/dist/client/outline-spy.js +60 -0
  97. package/dist/client/prompts.d.ts +7 -0
  98. package/dist/client/prompts.js +65 -0
  99. package/dist/client/review.d.ts +1 -0
  100. package/dist/client/review.js +379 -0
  101. package/dist/client/search.d.ts +1 -0
  102. package/dist/client/search.js +199 -0
  103. package/dist/client/segmented.d.ts +13 -0
  104. package/dist/client/segmented.js +70 -0
  105. package/dist/client/source-lines.d.ts +16 -0
  106. package/dist/client/source-lines.js +47 -0
  107. package/dist/client/theme-toggle.d.ts +10 -0
  108. package/dist/client/theme-toggle.js +100 -0
  109. package/dist/client/theme.d.ts +0 -0
  110. package/dist/client/theme.js +50 -0
  111. package/dist/client/tree-marks.d.ts +31 -0
  112. package/dist/client/tree-marks.js +102 -0
  113. package/dist/client/tree-state.d.ts +0 -0
  114. package/dist/client/tree-state.js +179 -0
  115. package/dist/client/viewer.d.ts +1 -0
  116. package/dist/client/viewer.js +53 -0
  117. package/dist/config-editor.d.ts +166 -0
  118. package/dist/config-editor.js +378 -0
  119. package/dist/config-routes.d.ts +18 -0
  120. package/dist/config-routes.js +213 -0
  121. package/dist/context-view.d.ts +41 -0
  122. package/dist/context-view.js +295 -0
  123. package/dist/corpus-routes.d.ts +31 -0
  124. package/dist/corpus-routes.js +258 -0
  125. package/dist/corpus.d.ts +134 -0
  126. package/dist/corpus.js +653 -0
  127. package/dist/dashboard-article.d.ts +14 -0
  128. package/dist/dashboard-article.js +290 -0
  129. package/dist/dashboard.d.ts +94 -0
  130. package/dist/dashboard.js +468 -0
  131. package/dist/diagnostics.d.ts +23 -0
  132. package/dist/diagnostics.js +44 -0
  133. package/dist/document-routes.d.ts +39 -0
  134. package/dist/document-routes.js +396 -0
  135. package/dist/event-hub.d.ts +39 -0
  136. package/dist/event-hub.js +120 -0
  137. package/dist/findings-panel.d.ts +4 -0
  138. package/dist/findings-panel.js +74 -0
  139. package/dist/folder-page.d.ts +8 -0
  140. package/dist/folder-page.js +74 -0
  141. package/dist/graph-view.d.ts +66 -0
  142. package/dist/graph-view.js +236 -0
  143. package/dist/highlight.d.ts +24 -0
  144. package/dist/highlight.js +100 -0
  145. package/dist/http-send.d.ts +9 -0
  146. package/dist/http-send.js +53 -0
  147. package/dist/index.d.ts +2 -0
  148. package/dist/index.js +72 -0
  149. package/dist/open-file.d.ts +36 -0
  150. package/dist/open-file.js +87 -0
  151. package/dist/page-tree.d.ts +3 -0
  152. package/dist/page-tree.js +105 -0
  153. package/dist/page.d.ts +73 -0
  154. package/dist/page.js +478 -0
  155. package/dist/prompts.d.ts +25 -0
  156. package/dist/prompts.js +82 -0
  157. package/dist/render-cache.d.ts +23 -0
  158. package/dist/render-cache.js +38 -0
  159. package/dist/render-document.d.ts +60 -0
  160. package/dist/render-document.js +440 -0
  161. package/dist/request-path.d.ts +17 -0
  162. package/dist/request-path.js +51 -0
  163. package/dist/review-context.d.ts +24 -0
  164. package/dist/review-context.js +109 -0
  165. package/dist/review-queries.d.ts +26 -0
  166. package/dist/review-queries.js +69 -0
  167. package/dist/review-state.d.ts +106 -0
  168. package/dist/review-state.js +251 -0
  169. package/dist/review-store.d.ts +145 -0
  170. package/dist/review-store.js +530 -0
  171. package/dist/router.d.ts +28 -0
  172. package/dist/router.js +294 -0
  173. package/dist/search.d.ts +22 -0
  174. package/dist/search.js +164 -0
  175. package/dist/security.d.ts +95 -0
  176. package/dist/security.js +196 -0
  177. package/dist/server.d.ts +21 -0
  178. package/dist/server.js +224 -0
  179. package/dist/speculation-rules.d.ts +4 -0
  180. package/dist/speculation-rules.js +49 -0
  181. package/dist/state-dir.d.ts +6 -0
  182. package/dist/state-dir.js +31 -0
  183. package/dist/tree-marks.d.ts +49 -0
  184. package/dist/tree-marks.js +108 -0
  185. package/dist/viewer-context.d.ts +37 -0
  186. package/dist/viewer-context.js +74 -0
  187. package/dist/watch.d.ts +41 -0
  188. package/dist/watch.js +135 -0
  189. package/package.json +57 -4
@@ -0,0 +1,134 @@
1
+ import { type CorpusMembership, type ContextGraph, type LintResult, type LoadedConfiguration, type ParsedDocument } from "@wastech-mdlint/core";
2
+ export type ResolvedTarget = {
3
+ kind: "document";
4
+ path: string;
5
+ } | {
6
+ kind: "file";
7
+ path: string;
8
+ } | {
9
+ kind: "folder";
10
+ path: string;
11
+ } | {
12
+ kind: "missing";
13
+ };
14
+ /** Whether a link target leaves the repository (a URL, `mailto:`, a protocol-relative `//host`). */
15
+ export declare function isExternalTarget(target: string): boolean;
16
+ export declare class Corpus {
17
+ private readonly root;
18
+ private readonly configPathOption;
19
+ private state;
20
+ private readonly embedded;
21
+ private readonly folderSets;
22
+ private constructor();
23
+ static load(params: {
24
+ cwd: string;
25
+ configPath?: string;
26
+ }): Promise<Corpus>;
27
+ get rootDir(): string;
28
+ get documents(): ReadonlyMap<string, ParsedDocument>;
29
+ get graph(): ContextGraph;
30
+ /**
31
+ * Every folder that holds a document, directly or further down, with `""` for the root of a
32
+ * corpus that has any. Worked out once per set of documents, as every folder link asks it.
33
+ */
34
+ get folders(): ReadonlySet<string>;
35
+ private foldersOfState;
36
+ /** The configuration the corpus was loaded with, replaced with it on a full reload. */
37
+ get configuration(): LoadedConfiguration;
38
+ /**
39
+ * The corpus as core judges a change set against it: the documents held now, the scope a deleted
40
+ * document is tested with, and the config's repository-relative path — which matches no changed
41
+ * path when the config lives outside the repository.
42
+ */
43
+ membership(): CorpusMembership;
44
+ /** Reload configuration and every document from disk. */
45
+ reload(): Promise<void>;
46
+ /**
47
+ * Bring the corpus up to date with a set of changed repo-relative paths.
48
+ *
49
+ * A full reload costs a walk and a parse of every document — seconds on a repository with a few
50
+ * hundred of them — while re-parsing the one file that was saved and rebuilding the graph costs
51
+ * milliseconds. So an edit to a known document is applied in place, and only what can change
52
+ * *which* files are documents pays for a full reload, because deciding membership means re-running
53
+ * core's include/exclude/gitignore discovery: the config or a `.gitignore`, a new Markdown file the
54
+ * scope takes in, a folder of documents that is gone, or a folder holding new ones. A watcher
55
+ * reports a moved or deleted folder as that one path and nothing for the files inside it, which is
56
+ * why folders are judged here at all.
57
+ *
58
+ * A path documents link to — an image that has just been saved, a file deleted — changes those
59
+ * documents' pages without changing the documents, so they are reported as changed too.
60
+ *
61
+ * `structural` reports that the set of documents may have changed, which every open page needs to
62
+ * know because each one shows the document tree.
63
+ */
64
+ applyChanges(paths: readonly string[]): Promise<{
65
+ changed: string[];
66
+ structural: boolean;
67
+ }>;
68
+ /**
69
+ * Where a local link or image target written in `fromPath` points.
70
+ *
71
+ * Candidates come from core's `resolveTargetCandidates`, the helper the context graph and the REF
72
+ * rules share, so a link the viewer can follow is a link REF-001 accepts and the reverse. Images
73
+ * resolve without the site router for the same reason core gives: a router maps URLs to Markdown
74
+ * sources, never to assets. A directory falls through to its README, which REF-001 does not do; a
75
+ * folder link that opens its README is what a reader expects from GitHub. A folder without one
76
+ * opens as a listing when it holds documents: REF-001 accepts any folder that exists, so marking
77
+ * such a link missing would contradict the linter over a link that works on GitHub.
78
+ */
79
+ resolve(fromPath: string, target: string, isImage: boolean): ResolvedTarget;
80
+ /**
81
+ * Where a target in a document's raw HTML points, by the same candidates as `resolve`, checking on
82
+ * disk whether a file there may be served. A file it finds is recorded against the document, which
83
+ * is what lets `/file/` serve it: core reads no raw HTML, so these targets are not among the links
84
+ * collected when the corpus loads.
85
+ */
86
+ resolveEmbedded(document: ParsedDocument, target: string, isImage: boolean): Promise<ResolvedTarget>;
87
+ isLinkedFile(relPath: string): boolean;
88
+ /** Documents that link to `relPath`, each once, in stable order. */
89
+ backlinks(relPath: string): string[];
90
+ /**
91
+ * The absolute path of the linked file at `relPath` if the viewer may hand it out now — judged
92
+ * again as it is served rather than trusted from when the link was collected, since a symlink can
93
+ * be pointed elsewhere in between and what it points at is what would be sent.
94
+ */
95
+ resolveFile(relPath: string): Promise<string | undefined>;
96
+ /**
97
+ * Lint the corpus as it is in memory now, with the configured rules.
98
+ *
99
+ * Through core's `lintContext`, which gives exactly what `wastech-mdlint lint` gives for the same
100
+ * tree but reuses the parsed documents and graph instead of discovering and parsing everything
101
+ * again — a fraction of a second after an edit rather than the seconds a fresh run takes.
102
+ */
103
+ lint(): LintResult;
104
+ /**
105
+ * Whether a candidate configuration selects the same documents as the loaded one.
106
+ *
107
+ * Parsing a document does not depend on the config, so a candidate that keeps `include`,
108
+ * `exclude` and `respectGitignore` is linted over the documents already parsed — new rules in a
109
+ * fraction of a second, new link settings after a rebuild of the graph. Only a new scope pays for
110
+ * core's discovery and a parse of the corpus it selects, because that is the one change that
111
+ * decides which files are documents.
112
+ */
113
+ sharesScope(candidate: LoadedConfiguration): boolean;
114
+ /** Whether an absolute path is, through any symlinks, inside the repository. */
115
+ contains(absolutePath: string): Promise<boolean>;
116
+ /**
117
+ * Whether any of `paths`, none of them a document, can change which files are documents.
118
+ *
119
+ * Every judgment is core's scope: a Markdown path `include` takes in and nothing excludes, and a
120
+ * folder no `exclude` or `.gitignore` prunes. A folder event alone says little — some platforms
121
+ * report a folder whenever a file inside it is created — so a folder that still exists counts only
122
+ * when it holds a document the corpus lacks, and one that is gone only when documents lived in it.
123
+ */
124
+ private changesMembership;
125
+ private holdsNewDocuments;
126
+ /**
127
+ * The documents whose pages change because a file appeared or disappeared at one of `paths`, or
128
+ * under one of them when it names a folder: those with a link target there whose answer to "may
129
+ * this file be served?" is no longer the one recorded.
130
+ */
131
+ private documentsReachingChangedFiles;
132
+ private absolute;
133
+ private statOf;
134
+ }