@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
@@ -0,0 +1,59 @@
1
+ /** What a run intends to do, and what it did. */
2
+ import type { Issue } from '../util/issues';
3
+ /** One thing a run did, or would do. */
4
+ export interface Action {
5
+ /** What kind of change this is. */
6
+ op: 'create-root' | 'create' | 'update' | 'unchanged' | 'prune' | 'upload-media' | 'reuse-media';
7
+ /** Full path within the published tree, for every operation. */
8
+ path: string;
9
+ /** Target id, once it is known. */
10
+ id?: number | null;
11
+ /** Fields that differ, for an update. */
12
+ changed?: string[];
13
+ /** Source file, when the action belongs to a document. */
14
+ file?: string | null;
15
+ /** Locale this action belongs to. */
16
+ locale?: string;
17
+ /** Version this action belongs to. */
18
+ versionName?: string;
19
+ /** Whether a removal was actually carried out. */
20
+ applied?: boolean;
21
+ }
22
+ /** The record of a run. */
23
+ export interface Plan {
24
+ /** When the run started. */
25
+ generatedAt: string;
26
+ /** Versions involved, for reproducing a report. */
27
+ versions: {
28
+ pterodoc: string;
29
+ docusaurus: string | null;
30
+ node: string;
31
+ };
32
+ /** True when nothing was written. */
33
+ dryRun: boolean;
34
+ /** True when nothing was even read from the target. */
35
+ offline: boolean;
36
+ /** The target site, when there is one. */
37
+ site: string | null;
38
+ /** Where the documentation was published. */
39
+ rootPath: string;
40
+ /** Locales published. */
41
+ locales: string[];
42
+ /** Versions published. */
43
+ versionNames: string[];
44
+ /** Everything the run did, or would do. */
45
+ actions: Action[];
46
+ /** Everything worth telling the user. */
47
+ issues: Issue[];
48
+ /** How many of each operation. */
49
+ summary: Record<string, number>;
50
+ /** How many requests were made. */
51
+ requests: number;
52
+ /** How many files still need uploading; non-zero only on a dry run. */
53
+ mediaPending: number;
54
+ /** Set when writing the artefacts itself failed. */
55
+ artifactError: string | null;
56
+ }
57
+ /** Count the actions by operation. */
58
+ export declare function summarise(actions: Action[]): Record<string, number>;
59
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/sync/plan.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,KAAK,EAAE,KAAK,EAAE,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AAM,EAAE,MAAM,CAAC,CAAC;IAChC,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,sCAAsC;AACtC,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAInE"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The reconciler.
3
+ *
4
+ * Two phases, because WordPress's navigation block needs a page id before any
5
+ * body can reference it: first make sure every page exists, then render every
6
+ * body against the real ids and write only what differs.
7
+ */
8
+ import { type Issue } from '../util/issues';
9
+ import type { SourceReader } from '../model/reader';
10
+ import type { Target } from '../target/target';
11
+ import type { ResolvedConfig } from '../config/load';
12
+ import { type Plan } from './plan';
13
+ import { type Artifacts } from './artifacts';
14
+ /** What a run needs beyond its configuration. */
15
+ export interface RunSyncDeps {
16
+ /** Where the site model comes from. */
17
+ reader: SourceReader;
18
+ /**
19
+ * Where pages are published.
20
+ *
21
+ * Always supplied, even for a run that publishes nothing: the target owns
22
+ * URL policy, so rendering needs it to know what a page's address will be.
23
+ */
24
+ target?: Target | undefined;
25
+ /** Render only: build no session and contact nothing. */
26
+ renderOnly?: boolean | undefined;
27
+ /** Progress worth seeing under `--verbose`. */
28
+ log?: (message: string) => void;
29
+ }
30
+ /** What a run produced. */
31
+ export interface RunResult {
32
+ plan: Plan;
33
+ artifacts: Artifacts;
34
+ }
35
+ /** Run the sync. */
36
+ export declare function runSync(config: ResolvedConfig, deps: RunSyncDeps): Promise<RunResult>;
37
+ /** Issues, for callers that want them without the plan. */
38
+ export type { Issue };
39
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/sync/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAM5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAMpD,OAAO,KAAK,EAA0B,MAAM,EAAiB,MAAM,kBAAkB,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAA0B,KAAK,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAkB,KAAK,SAAS,EAAsB,MAAM,aAAa,CAAC;AAEjF,iDAAiD;AACjD,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,MAAM,EAAE,YAAY,CAAC;IACrB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,yDAAyD;IACzD,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,+CAA+C;IAC/C,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,2BAA2B;AAC3B,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,SAAS,CAAC;CACtB;AAUD,oBAAoB;AACpB,wBAAsB,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,CA4F3F;AAseD,2DAA2D;AAC3D,YAAY,EAAE,KAAK,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The target contract: what a place pages are published to must provide.
3
+ *
4
+ * Implementations live beside this, or in their own package; the reconciler
5
+ * only ever sees what is declared here.
6
+ */
7
+ export type { EnsureRequest, EnsureResult, MediaRef, MediaUpload, RemotePage, RenderedPage, Target, TargetCapabilities, TargetSession, } from './target';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/target/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,YAAY,EACZ,MAAM,EACN,kBAAkB,EAClB,aAAa,GACd,MAAM,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * What a publishing target has to be able to do.
3
+ *
4
+ * WordPress is the only implementation today, but keeping the contract
5
+ * explicit is what stops target vocabulary leaking into the renderer and the
6
+ * reconciler.
7
+ */
8
+ /** What a target can and cannot do. */
9
+ export interface TargetCapabilities {
10
+ /** Page ids must exist before bodies can be rendered, as WordPress's page list needs. */
11
+ needsIdsBeforeRender: boolean;
12
+ /** Files can be uploaded and referenced. */
13
+ supportsMedia: boolean;
14
+ /** Pages with no source can be removed. */
15
+ supportsPrune: boolean;
16
+ /** Pages nest; a flat target gets its whole path as one name. */
17
+ supportsHierarchy: boolean;
18
+ /** There is a separate summary field. */
19
+ supportsExcerpt: boolean;
20
+ /** Arbitrary key/value metadata can be written. */
21
+ supportsMeta: boolean;
22
+ /** A page can be given a template. */
23
+ supportsTemplates: boolean;
24
+ /** A page can be created unpublished. */
25
+ supportsDrafts: boolean;
26
+ }
27
+ /** A page as it exists on the target. */
28
+ export interface RemotePage {
29
+ id: number;
30
+ parent: number;
31
+ slug: string;
32
+ status: string;
33
+ link: string;
34
+ title: string;
35
+ content?: string;
36
+ excerpt?: string;
37
+ menuOrder: number;
38
+ template: string;
39
+ meta?: Record<string, unknown> | undefined;
40
+ }
41
+ /** A page as pterodoc would publish it. */
42
+ export interface RenderedPage {
43
+ /** Path within the published tree. */
44
+ path: string;
45
+ /** Slug of the last path segment. */
46
+ slug: string;
47
+ /** Page title. */
48
+ title: string;
49
+ /** The composed body. */
50
+ content: string;
51
+ /** Short summary. */
52
+ excerpt: string;
53
+ /** Position among siblings. */
54
+ menuOrder: number;
55
+ /** Metadata to write, when the target supports it. */
56
+ meta: Record<string, string>;
57
+ /** Source file, for messages. */
58
+ file?: string | undefined;
59
+ /** Version this page belongs to. */
60
+ versionName?: string | undefined;
61
+ }
62
+ /** A file to upload. */
63
+ export interface MediaUpload {
64
+ bytes: Uint8Array;
65
+ filename: string;
66
+ hash: string;
67
+ mime: string;
68
+ alt: string;
69
+ title: string;
70
+ }
71
+ /** An uploaded file. */
72
+ export interface MediaRef {
73
+ id: number;
74
+ hash: string;
75
+ url: string;
76
+ filename: string;
77
+ mime: string;
78
+ }
79
+ /** Asking the target to make sure a page exists. */
80
+ export interface EnsureRequest {
81
+ path: string;
82
+ slug: string;
83
+ parentId: number | null;
84
+ title: string;
85
+ menuOrder: number;
86
+ isRoot: boolean;
87
+ }
88
+ /** What came of that. */
89
+ export interface EnsureResult {
90
+ id: number | null;
91
+ created: boolean;
92
+ warnings: string[];
93
+ }
94
+ /** An open connection to a target. */
95
+ export interface TargetSession {
96
+ /** Every page under the target's namespace, fetched once. */
97
+ loadIndex(): Promise<RemotePage[]>;
98
+ /**
99
+ * Make sure everything above the documentation root exists.
100
+ *
101
+ * The target owns this because only it knows what a path is made of. Pages
102
+ * it has to create are reported so the plan can show them; pages that were
103
+ * already there are never touched.
104
+ */
105
+ ensureRootParent(): Promise<{
106
+ id: number | null;
107
+ created: {
108
+ path: string;
109
+ id: number | null;
110
+ }[];
111
+ }>;
112
+ /** Make sure a page exists at this position, and give back its id. */
113
+ ensurePage(request: EnsureRequest): Promise<EnsureResult>;
114
+ /** Fetch a page with the fields needed to compare it. */
115
+ fetchPage(id: number): Promise<RemotePage>;
116
+ /** Which fields of an existing page differ from the rendered one. */
117
+ diffPage(remote: RemotePage, rendered: RenderedPage, parentId: number): string[];
118
+ /** Write a rendered page, returning warnings for anything the target refused. */
119
+ writePage(id: number, page: RenderedPage, parentId: number): Promise<{
120
+ warnings: string[];
121
+ }>;
122
+ /** Pages below a root that no rendered page accounts for, deepest first. */
123
+ computePrune(index: RemotePage[], rootId: number, keepIds: Set<number>): RemotePage[];
124
+ /** Remove a page. Never a permanent delete. */
125
+ removePage(page: RemotePage): Promise<void>;
126
+ /** Files already uploaded, by content hash. */
127
+ loadMediaIndex(): Promise<Map<string, MediaRef>>;
128
+ /** Upload one file. */
129
+ uploadMedia(upload: MediaUpload): Promise<MediaRef>;
130
+ /** How many requests this session has made. */
131
+ requestCount(): number;
132
+ }
133
+ /** A place documentation can be published. */
134
+ export interface Target {
135
+ /** Name used in messages and in the plan. */
136
+ readonly name: string;
137
+ /** What this target can do. */
138
+ readonly capabilities: TargetCapabilities;
139
+ /** Absolute site path for a tree path: the target owns URL policy. */
140
+ hrefFor(treePath: string, context: {
141
+ versionName: string;
142
+ locale: string;
143
+ }): string;
144
+ /** The path pages are published under, for messages. */
145
+ readonly rootPath: string;
146
+ /** Open a session. */
147
+ open(context: {
148
+ locale: string;
149
+ dryRun: boolean;
150
+ }): Promise<TargetSession>;
151
+ }
152
+ //# sourceMappingURL=target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../src/target/target.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,yFAAyF;IACzF,oBAAoB,EAAE,OAAO,CAAC;IAC9B,4CAA4C;IAC5C,aAAa,EAAE,OAAO,CAAC;IACvB,2CAA2C;IAC3C,aAAa,EAAE,OAAO,CAAC;IACvB,iEAAiE;IACjE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,yCAAyC;IACzC,eAAe,EAAE,OAAO,CAAC;IACzB,mDAAmD;IACnD,YAAY,EAAE,OAAO,CAAC;IACtB,sCAAsC;IACtC,iBAAiB,EAAE,OAAO,CAAC;IAC3B,yCAAyC;IACzC,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,yCAAyC;AACzC,MAAM,WAAW,UAAU;IAC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,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC7F,4EAA4E;IAC5E,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACtF,+CAA+C;IAC/C,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,+CAA+C;IAC/C,cAAc,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACjD,uBAAuB;IACvB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpD,+CAA+C;IAC/C,YAAY,IAAI,MAAM,CAAC;CACxB;AAED,8CAA8C;AAC9C,MAAM,WAAW,MAAM;IACrB,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAC1C,sEAAsE;IACtE,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC;IACpF,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,sBAAsB;IACtB,IAAI,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC5E"}
@@ -0,0 +1,10 @@
1
+ /** Content hashing, used to give an uploaded asset a stable identity. */
2
+ /**
3
+ * A short content hash.
4
+ *
5
+ * Sixteen hex characters of SHA-256: long enough that a collision across one
6
+ * site's assets is not a practical concern, short enough to sit inside a
7
+ * WordPress slug without dominating it.
8
+ */
9
+ export declare function contentHash(bytes: Uint8Array | string): string;
10
+ //# sourceMappingURL=hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/util/hash.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAIzE;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAE9D"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared helpers with no domain knowledge, and the errors every layer throws.
3
+ *
4
+ * Nothing here imports another layer, which is what makes it safe for all of
5
+ * them to import it.
6
+ */
7
+ export { EXIT, PterodocError, ConfigError, TargetError, UnsupportedContentError } from '../errors';
8
+ export { VERSION, USER_AGENT } from '../version';
9
+ export { contentHash } from './hash';
10
+ export { compareSeverity, formatIssue, IssueCollector } from './issues';
11
+ export type { Issue, Severity } from './issues';
12
+ export { mimeTypeFor, isBlockedByDefault } from './mime';
13
+ export { joinPath, relativeToPrefix, resolveAliasedPath, segments, slugify, titleCase, toPosix, toSlugSegments, } from './paths';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACnG,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACxE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,QAAQ,EACR,OAAO,EACP,SAAS,EACT,OAAO,EACP,cAAc,GACf,MAAM,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { C as ConfigError, E as EXIT, P as PterodocError, T as TargetError, U as USER_AGENT, a as UnsupportedContentError, V as VERSION, j as joinPath, r as relativeToPrefix, b as resolveAliasedPath, s as segments, c as slugify, t as titleCase, d as toPosix, e as toSlugSegments } from '../chunks/paths-Bh6UsRI9.js';
2
+ export { c as contentHash, i as isBlockedByDefault, m as mimeTypeFor } from '../chunks/mime-2SUyOolJ.js';
3
+ export { I as IssueCollector, c as compareSeverity, f as formatIssue } from '../chunks/issues-DBsPh6ek.js';
4
+ import 'node:fs';
5
+ import 'node:path';
6
+ import 'node:crypto';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,52 @@
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
+ /** How much a reader should care. */
9
+ export type Severity = 'info' | 'warning' | 'error';
10
+ /** One thing worth telling the user about. */
11
+ export interface Issue {
12
+ /** Stable identifier, e.g. `mdx-unknown-component`. Never localised. */
13
+ code: string;
14
+ /** How much a reader should care. */
15
+ severity: Severity;
16
+ /** One sentence, in English, naming what happened. */
17
+ message: string;
18
+ /** Source file the issue came from, relative to the site directory. */
19
+ file?: string | undefined;
20
+ /** One-based line within `file`. */
21
+ line?: number | undefined;
22
+ /** One-based column within `line`. */
23
+ column?: number | undefined;
24
+ /** Document id, when the issue belongs to a document. */
25
+ docId?: string | undefined;
26
+ /** Page path within the target tree, when the issue belongs to a page. */
27
+ path?: string | undefined;
28
+ }
29
+ /** Accumulates issues during a run. */
30
+ export declare class IssueCollector {
31
+ readonly issues: Issue[];
32
+ /** Record an issue. */
33
+ add(issue: Issue): void;
34
+ /** Record an issue that inherits a document's file and id. */
35
+ addFor(doc: {
36
+ id: string;
37
+ sourceRelativePath?: string;
38
+ } | undefined, issue: Omit<Issue, 'docId' | 'file'> & {
39
+ file?: string;
40
+ }): void;
41
+ /** True when any issue is at least as severe as `severity`. */
42
+ hasAtLeast(severity: Severity): boolean;
43
+ /** Issues at least as severe as `severity`. */
44
+ atLeast(severity: Severity): Issue[];
45
+ /** How many issues carry each code, for a compact summary. */
46
+ countByCode(): Record<string, number>;
47
+ }
48
+ /** Compare two severities; positive when `a` is more severe than `b`. */
49
+ export declare function compareSeverity(a: Severity, b: Severity): number;
50
+ /** Render an issue as one line, with its position when it has one. */
51
+ export declare function formatIssue(issue: Issue): string;
52
+ //# sourceMappingURL=issues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issues.d.ts","sourceRoot":"","sources":["../../src/util/issues.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,qCAAqC;AACrC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAIpD,8CAA8C;AAC9C,MAAM,WAAW,KAAK;IACpB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,QAAQ,EAAE,QAAQ,CAAC;IACnB,sDAAsD;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,uCAAuC;AACvC,qBAAa,cAAc;IACzB,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,CAAM;IAE9B,uBAAuB;IACvB,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAIvB,8DAA8D;IAC9D,MAAM,CACJ,GAAG,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,EAC5D,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,GAAG;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GACvD,IAAI;IAQP,+DAA+D;IAC/D,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO;IAIvC,+CAA+C;IAC/C,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE;IAIpC,8DAA8D;IAC9D,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAKtC;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CAEhE;AAED,sEAAsE;AACtE,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAOhD"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Extension to media type.
3
+ *
4
+ * A twenty-entry table rather than a dependency: these are the types a
5
+ * documentation site actually embeds, and WordPress rejects most others.
6
+ */
7
+ /** The media type for a file name, or undefined when we do not recognise it. */
8
+ export declare function mimeTypeFor(fileName: string): string | undefined;
9
+ /**
10
+ * True for types WordPress refuses by default.
11
+ *
12
+ * SVG is the one that surprises people: it is blocked unless a plugin allows
13
+ * it, because an SVG can carry script.
14
+ */
15
+ export declare function isBlockedByDefault(mime: string): boolean;
16
+ //# sourceMappingURL=mime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mime.d.ts","sourceRoot":"","sources":["../../src/util/mime.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA0BH,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIhE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Path helpers shared by the source reader and the targets.
3
+ *
4
+ * Everything here is POSIX-shaped: a documentation tree is addressed by URL
5
+ * paths, not by the host's separators.
6
+ */
7
+ /**
8
+ * Resolve a Docusaurus `@site/...` path to an absolute one.
9
+ *
10
+ * @param aliased The path as Docusaurus records it, e.g. `@site/docs/intro.md`.
11
+ * @param siteDir Absolute path of the Docusaurus site directory.
12
+ */
13
+ export declare function resolveAliasedPath(aliased: string, siteDir: string): string;
14
+ /** Turn a host path into the POSIX form used for ids and messages. */
15
+ export declare function toPosix(value: string): string;
16
+ /** Split a URL-ish path into its non-empty segments. */
17
+ export declare function segments(value: string): string[];
18
+ /**
19
+ * Split a configured path into slug segments, rejecting anything WordPress
20
+ * would not accept as a page slug.
21
+ *
22
+ * @param value A path such as `/products/docstack`.
23
+ * @param label The setting's name, used in the error message.
24
+ */
25
+ export declare function toSlugSegments(value: string, label: string): string[];
26
+ /**
27
+ * Make a slug out of arbitrary text, for path segments we derive ourselves
28
+ * (a version name, for instance) rather than receive from Docusaurus.
29
+ */
30
+ export declare function slugify(value: string): string;
31
+ /** Title-case a slug, for a page that has no better label available. */
32
+ export declare function titleCase(slug: string): string;
33
+ /**
34
+ * The path a URL points at below a prefix.
35
+ *
36
+ * Returns undefined when `url` is not under `prefix`, which is how the link
37
+ * resolver decides whether a link belongs to the documentation at all.
38
+ */
39
+ export declare function relativeToPrefix(url: string, prefix: string): string | undefined;
40
+ /** Join path segments into an absolute URL path with a trailing slash. */
41
+ export declare function joinPath(parts: string[], trailingSlash?: boolean): string;
42
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/util/paths.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAO3E;AAED,sEAAsE;AACtE,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wDAAwD;AACxD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEhD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAUrE;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO7C;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOhF;AAED,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,aAAa,UAAO,GAAG,MAAM,CAItE"}
@@ -0,0 +1,6 @@
1
+ /** The tool's own version, stamped into the build. */
2
+ /** Semantic version of this package. */
3
+ export declare const VERSION: string;
4
+ /** The User-Agent every outbound request identifies itself with. */
5
+ export declare const USER_AGENT: string;
6
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,sDAAsD;AA0BtD,wCAAwC;AACxC,eAAO,MAAM,OAAO,QAAgB,CAAC;AAErC,oEAAoE;AACpE,eAAO,MAAM,UAAU,QAA+D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@pterodoc/core",
3
+ "version": "0.2.0",
4
+ "description": "Rendering, the site model, the target contract and the reconciler behind pterodoc.",
5
+ "type": "module",
6
+ "main": "./lib/index.js",
7
+ "types": "./lib/index.d.ts",
8
+ "exports": {
9
+ ".": { "types": "./lib/index.d.ts", "default": "./lib/index.js" },
10
+ "./model": { "types": "./lib/model/index.d.ts", "default": "./lib/model/index.js" },
11
+ "./render": { "types": "./lib/render/index.d.ts", "default": "./lib/render/index.js" },
12
+ "./target": { "types": "./lib/target/index.d.ts", "default": "./lib/target/index.js" },
13
+ "./util": { "types": "./lib/util/index.d.ts", "default": "./lib/util/index.js" },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": ["lib", "src", "README.md", "LICENCE.md"],
17
+ "engines": { "node": ">=20.11" },
18
+ "scripts": {
19
+ "build": "tsc -b --force && rollup -c",
20
+ "test": "node ../../scripts/tests.mjs unit"
21
+ },
22
+ "dependencies": {
23
+ "@types/github-slugger": "^1.3.0",
24
+ "@types/hast": "^3.0.4",
25
+ "@types/mdast": "^4.0.4",
26
+ "dotenv": "^16.4.5",
27
+ "github-slugger": "1.5.0",
28
+ "gray-matter": "^4.0.3",
29
+ "hast-util-to-html": "^9.0.5",
30
+ "mdast-util-to-hast": "^13.2.0",
31
+ "mdast-util-to-string": "^4.0.0",
32
+ "remark-directive": "^3.0.1",
33
+ "remark-frontmatter": "^5.0.0",
34
+ "remark-gfm": "^4.0.1",
35
+ "remark-mdx": "^3.1.0",
36
+ "remark-parse": "^11.0.0",
37
+ "unified": "^11.0.5",
38
+ "unist-util-visit": "^5.1.0"
39
+ },
40
+ "repository": { "type": "git", "url": "git+https://github.com/onyx-ac/pterodoc.git" },
41
+ "license": "CC-BY-SA-4.0",
42
+ "publishConfig": { "access": "public" }
43
+ }