@podlite/publisher 0.0.51 → 0.0.53

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 (55) hide show
  1. package/CHANGELOG.podlite +40 -0
  2. package/esm/catalogue.d.ts +17 -0
  3. package/esm/catalogue.js +156 -0
  4. package/esm/catalogue.js.map +1 -0
  5. package/esm/images-plugin.js +3 -1
  6. package/esm/images-plugin.js.map +1 -1
  7. package/esm/include-resolve-plugin.d.ts +16 -1
  8. package/esm/include-resolve-plugin.js +238 -50
  9. package/esm/include-resolve-plugin.js.map +1 -1
  10. package/esm/links-plugin.d.ts +9 -1
  11. package/esm/links-plugin.js +144 -58
  12. package/esm/links-plugin.js.map +1 -1
  13. package/esm/node-utils.d.ts +5 -3
  14. package/esm/node-utils.js +81 -24
  15. package/esm/node-utils.js.map +1 -1
  16. package/esm/pubdate-plugin.js +7 -5
  17. package/esm/pubdate-plugin.js.map +1 -1
  18. package/esm/react-plugin.js +9 -1
  19. package/esm/react-plugin.js.map +1 -1
  20. package/esm/reading.d.ts +5 -0
  21. package/esm/reading.js +34 -0
  22. package/esm/reading.js.map +1 -0
  23. package/esm/record.d.ts +2 -0
  24. package/esm/record.js +1 -0
  25. package/esm/record.js.map +1 -1
  26. package/esm/site-data-plugin.d.ts +1 -0
  27. package/esm/site-data-plugin.js +12 -1
  28. package/esm/site-data-plugin.js.map +1 -1
  29. package/esm/source.d.ts +19 -0
  30. package/esm/source.js +85 -0
  31. package/esm/source.js.map +1 -0
  32. package/esm/version.d.ts +1 -1
  33. package/esm/version.js +1 -1
  34. package/lib/catalogue.d.ts +17 -0
  35. package/lib/catalogue.js +197 -0
  36. package/lib/images-plugin.js +3 -1
  37. package/lib/include-resolve-plugin.d.ts +16 -1
  38. package/lib/include-resolve-plugin.js +273 -49
  39. package/lib/links-plugin.d.ts +9 -1
  40. package/lib/links-plugin.js +177 -56
  41. package/lib/node-utils.d.ts +5 -3
  42. package/lib/node-utils.js +96 -37
  43. package/lib/pubdate-plugin.js +7 -5
  44. package/lib/react-plugin.js +9 -1
  45. package/lib/reading.d.ts +5 -0
  46. package/lib/reading.js +38 -0
  47. package/lib/record.d.ts +2 -0
  48. package/lib/record.js +6 -1
  49. package/lib/site-data-plugin.d.ts +1 -0
  50. package/lib/site-data-plugin.js +13 -1
  51. package/lib/source.d.ts +19 -0
  52. package/lib/source.js +94 -0
  53. package/lib/version.d.ts +1 -1
  54. package/lib/version.js +1 -1
  55. package/package.json +4 -4
package/CHANGELOG.podlite CHANGED
@@ -2,6 +2,46 @@
2
2
 
3
3
  =head1 Upcoming
4
4
 
5
+ =head1 0.0.53
6
+
7
+ =item B<Breaking:> the include plugin assembles C<=include> with the assembler of C<podlite>. The blocks an include finds take the place of the directive, and no C<include> node is left around them. They are read from the text of their source, with the settings in effect where the directive stands, and the includes inside them are assembled as well. The plugin takes C<catalogue>, the records the site read before the plugins ran: an include finds its source there, as well as among the documents plugins make later in the chain. Without it the plugin says so and looks among the records at hand. A relative path in a C<file:> source is resolved from the file the directive is written in; before, the source was the record whose path ended with the written one. A C<doc:> name that two documents answer to resolves to neither, and the refusal names both. With C<bounds>, a path written in one of those directories does not lead out of it
8
+
9
+ =item a C<=set> before an include that brings no block reaches the next block
10
+
11
+ =item B<Breaking:> an include that does not place what it names stops the build with C<IncludeError>, one line for each such include, with the file and the line of the directive and the files it came through. It stops on a missing source or address; a selector that cannot be read; a scheme the site does not read; a name that answers to two documents; a file that includes itself. It was a warning, and the page was published without the included text
12
+
13
+ =item C<includePasses> gives the include plugin in two passes over one catalogue. C<first> goes before the plugins of images, links and React and places what it can; an include of a document a plugin makes later in the chain, the site data or a name given in C<late>, waits there. C<last> goes after them and places only such documents; one that holds an include, or brings a picture or a link, stops the build. The site data plugin exports the name of its document as C<SITE_DATA_DOCUMENT>
14
+
15
+ =item a record is read with the body of C<=React> as Podlite in its place, by the reader an include reads the texts it brings with: an include inside the body is assembled, and the React plugin keeps the blocks of the body as the content of the block rather than reading the body again into a nested list
16
+
17
+ =item the tables of contents written in a record are built again once the includes are in, and take in the headings of a C<=React> body; a table an include brought stays as its own file built it
18
+
19
+ =item the header, the footer and the description of a record are assembled as well, each from the file it was written in. A template is assembled as a record of the chain; a template a record carries is left as it is
20
+
21
+ =item the images, links and React plugins find a path written in a block an include brought from the file the block was written in, not from the file of the record: a picture, a C<file:> link and a component import of an included chapter work as they do in the chapter itself
22
+
23
+ =item a link to a file placed at more than one address goes to the address a search engine is told to index: the current version of a document, not its permanent address marked C<:noindex>. The map of addresses is keyed by the absolute path of a file
24
+
25
+ =item B<Breaking:> a C<doc:> link whose name no published document answers to, or that two documents answer to, stops the build with C<LinkError>, naming the file and the line. So does a link to a section the document does not have; a link to a section goes to the address the page gives that section. The link was replaced by the words "not found", and of two documents the last one won. The links plugin takes C<documents>, the files the include plugin finds a name in (C<includePasses> gives it), so that a link and an include read a name alike, and C<home>, the file of the home page, whose address C</> the site data plugin gives only later. A link to the section a document is named by goes to the page itself. C<doc:#section> goes to a section of the page the link is on. A name an include brought into a document is not a name of that document
26
+
27
+ =item C<nodeOrigin> gives the file a node of a record was written in, when an include brought it there. The mark is held under a symbol key on the node, so a copy made by spreading the node keeps it and JSON does not carry it
28
+
29
+ =item C<=Include> is no longer read as C<=include>: by the specification it is a named block. The lint of C<podlite> warns about it
30
+
31
+ =head1 0.0.52
32
+
33
+ =item a record keeps the text it was read from: C<recordSource> returns the text, the file name and the type given for it, C<recordOrigin> returns the same for a record the pubdate plugin cut out of a file, and C<isParsedTree> tells whether the tree is still the one that was parsed. C<parseText> parses a given text as a file of that name is read. The source is held under a symbol key, so it is absent from JSON and from C<Object.keys>, and present when a record is printed or compared deeply
34
+
35
+ =item on the first block an C<=include> brings, a C<=set> of the included file wins over a C<=set> written before the include for the same key; the one before the include won
36
+
37
+ =item a C<=set> written before C<=include> reaches the first block the include places, and the record the block comes from is left unchanged; the block after the include received it. When the include fails, the warning names the assignment it lost. When it places no block, or its first block is an include inside what was placed, a warning says the assignment has no target. An include whose selector cannot be read, or whose scheme is neither C<doc:> nor C<file:>, says so; it was reported as not found
38
+
39
+ =item C<=include> whose source or address does not resolve is left in place with one warning; it gave two. An address is found by the text of a heading as well as by C<:id>
40
+
41
+ =item C<=include> places a found block once: a block inside another found block comes with it and is not placed again
42
+
43
+ =item an include whose selector has an operand of C<in> that does not resolve is left in place with a warning, rather than stopping the run
44
+
5
45
  =head1 0.0.51
6
46
 
7
47
  =item the C<./node> entry can be reached with C<import> as well. Its ESM build called C<require>, which a module does not have, so loading it died on the first line
@@ -0,0 +1,17 @@
1
+ import type { AstTree, PodliteDocument } from '@podlite/schema';
2
+ import type { Sources } from 'podlite';
3
+ import { publishRecord } from './record';
4
+ export type CatalogueOptions = {
5
+ bounds?: string[];
6
+ parse?: (text: string, file: string) => PodliteDocument | AstTree;
7
+ waits?: (name: string) => boolean;
8
+ };
9
+ export type Catalogue = {
10
+ sources: Sources;
11
+ add: (records: publishRecord[]) => void;
12
+ idOf: (record: object) => string | undefined;
13
+ named: (name: string) => string[];
14
+ textOf: (id: string) => string | undefined;
15
+ };
16
+ export declare const idOfFile: (file: string) => string;
17
+ export declare const catalogueOf: (records?: publishRecord[], options?: CatalogueOptions) => Catalogue;
@@ -0,0 +1,156 @@
1
+ /*
2
+ =begin pod :kind<module>
3
+
4
+ =head2 catalogue
5
+
6
+ This module holds the texts an include on a site can bring. They are the
7
+ records the site read before the plugins ran, and the documents plugins make
8
+ later in the chain. Several records read from one file are one source. The
9
+ current version of a document and its permanent address are one source. A page
10
+ cut out of a file is that file.
11
+
12
+ The id of a source is the absolute path of the file it was read from. A
13
+ document a plugin makes is known by the name it was made under, resolved the
14
+ same way.
15
+
16
+ A path in a C<file:> source is resolved from the directory of the file it is
17
+ written in. A mask is matched against the files of the catalogue. A C<doc:>
18
+ source is the document whose C<=NAME> or C<=TITLE> answers to the name. When two
19
+ sources answer to a name, it resolves to neither, and the answer names both.
20
+ When no document answers to a name yet and the host says it will be made later,
21
+ an include of it is left for a later pass.
22
+
23
+ =end pod
24
+ */
25
+ import * as path from 'path';
26
+ import matter from 'gray-matter';
27
+ import { filePathMatches, getDocIDs, mkRootBlock } from '@podlite/schema';
28
+ import { formatOfFile, formatOfType } from 'podlite';
29
+ import { getParserTypeforFile, PARSER_TYPES } from './node-utils.js';
30
+ import { isParsedTree, recordOrigin, recordSource } from './source.js';
31
+ const isMask = (written) => /[*?]/.test(written);
32
+ const isUnder = (file, dir) => {
33
+ const relative = path.relative(dir, file);
34
+ return relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
35
+ };
36
+ /*
37
+ =begin pod :kind<export>
38
+
39
+ =head2 idOfFile
40
+
41
+ The id of a file as a source: its absolute path, from the working directory.
42
+
43
+ =end pod
44
+ */
45
+ export const idOfFile = (file) => path.resolve(file);
46
+ // a Markdown text is read without its front matter, as the record was
47
+ const readable = (source) => getParserTypeforFile(source.file, source.mime) === PARSER_TYPES.MARKDOWN ? matter(source.text).content : source.text;
48
+ /*
49
+ =begin pod :kind<export>
50
+
51
+ =head2 catalogueOf
52
+
53
+ A catalogue over the readings of the records given. Records added later bring
54
+ the readings it does not hold; a reading it holds already is not taken twice.
55
+
56
+ =end pod
57
+ */
58
+ export const catalogueOf = (records = [], options = {}) => {
59
+ const entries = new Map();
60
+ const held = new WeakSet();
61
+ const bounds = (options.bounds ?? []).map(dir => path.resolve(dir));
62
+ let names;
63
+ const add = (list) => {
64
+ for (const record of list) {
65
+ const source = recordOrigin(record);
66
+ if (!source || held.has(source))
67
+ continue;
68
+ held.add(source);
69
+ const id = idOfFile(source.file);
70
+ if (entries.has(id))
71
+ continue;
72
+ const own = recordSource(record) === source && isParsedTree(record);
73
+ const entry = { id, source, tree: own ? record.node : undefined };
74
+ entries.set(id, entry);
75
+ if (names)
76
+ index(names, entry);
77
+ }
78
+ };
79
+ const index = (into, entry) => {
80
+ const tree = entry.tree ?? options.parse?.(readable(entry.source), entry.source.file);
81
+ if (!tree)
82
+ return;
83
+ const node = Array.isArray(tree) ? mkRootBlock({}, tree) : tree;
84
+ for (const name of new Set(getDocIDs({ file: entry.source.file, node }))) {
85
+ into.set(name, [...(into.get(name) ?? []), entry.id]);
86
+ }
87
+ };
88
+ // the names each document answers to, built on the first question
89
+ const namesOf = () => {
90
+ if (names)
91
+ return names;
92
+ names = new Map();
93
+ for (const entry of entries.values())
94
+ index(names, entry);
95
+ return names;
96
+ };
97
+ // the directory a path written in that place does not lead out of
98
+ const boundOf = (dir) => bounds.filter(bound => dir === bound || isUnder(dir, bound)).sort((a, b) => b.length - a.length)[0];
99
+ const sourceAt = (id, name) => {
100
+ const entry = entries.get(id);
101
+ const format = entry?.source.mime ? formatOfType(entry.source.mime) : formatOfFile(id);
102
+ return { id, name, context: path.dirname(id), ...(format ? { format } : {}) };
103
+ };
104
+ const locateFile = (written, context, plain) => {
105
+ const dir = path.resolve(String(context ?? ''));
106
+ const bound = boundOf(dir);
107
+ const inside = (id) => bound === undefined || isUnder(id, bound);
108
+ if (plain || !isMask(written)) {
109
+ const id = path.resolve(dir, written);
110
+ if (!inside(id))
111
+ return {
112
+ masked: false,
113
+ sources: [],
114
+ failed: `the path leads out of ${path.relative(process.cwd(), bound) || '.'}`,
115
+ };
116
+ return { masked: false, sources: [sourceAt(id, written)] };
117
+ }
118
+ const pattern = path.resolve(dir, written);
119
+ const found = [...entries.keys()].filter(id => inside(id) && filePathMatches(id, pattern)).sort();
120
+ return {
121
+ masked: true,
122
+ // named the way the mask is written, for the selection to match it back
123
+ sources: found.map(id => sourceAt(id, path.isAbsolute(written) ? id : path.relative(dir, id))),
124
+ };
125
+ };
126
+ const locateDoc = (written) => {
127
+ const ids = namesOf().get(written) ?? [];
128
+ if (!ids.length && options.waits?.(written))
129
+ return undefined;
130
+ if (ids.length > 1) {
131
+ const files = ids.map(id => entries.get(id).source.file).join(', ');
132
+ return { masked: false, sources: [], failed: `more than one document is named ${written}: ${files}` };
133
+ }
134
+ return { masked: false, sources: ids.map(id => ({ ...sourceAt(id, written) })) };
135
+ };
136
+ const sources = {
137
+ schemes: ['file', 'doc'],
138
+ locate: (written, context, plain, _at, scheme) => scheme === 'doc' ? locateDoc(written) : locateFile(written, context, plain),
139
+ read: source => {
140
+ const entry = entries.get(source.id);
141
+ return entry ? readable(entry.source) : null;
142
+ },
143
+ };
144
+ const idOf = (record) => {
145
+ const source = recordOrigin(record);
146
+ return source ? idOfFile(source.file) : undefined;
147
+ };
148
+ const named = (name) => namesOf().get(name) ?? [];
149
+ const textOf = (id) => {
150
+ const entry = entries.get(id);
151
+ return entry ? readable(entry.source) : undefined;
152
+ };
153
+ add(records);
154
+ return { sources, add, idOf, named, textOf };
155
+ };
156
+ //# sourceMappingURL=catalogue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogue.js","sourceRoot":"","sources":["../src/catalogue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEzE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAEjE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGnE,MAAM,MAAM,GAAG,CAAC,OAAe,EAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAEjE,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,GAAW,EAAW,EAAE;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACzC,OAAO,QAAQ,KAAK,EAAE,IAAI,QAAQ,KAAK,IAAI,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AAC,EAAE;YACb,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YACpC,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC9C,CAAC;KACF,CAAA;IAED,MAAM,IAAI,GAAG,CAAC,MAAc,EAAsB,EAAE;QAClD,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAA;QACnC,OAAO,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACnD,CAAC,CAAA;IAED,MAAM,KAAK,GAAG,CAAC,IAAY,EAAY,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IACnE,MAAM,MAAM,GAAG,CAAC,EAAU,EAAsB,EAAE;QAChD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAC7B,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IACnD,CAAC,CAAA;IAED,GAAG,CAAC,OAAO,CAAC,CAAA;IACZ,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAC9C,CAAC,CAAA"}
@@ -3,6 +3,7 @@ import { ASSETS_PATH, IMAGE_LIB } from './constants.js';
3
3
  import pathMod from 'path';
4
4
  import * as fs from 'fs';
5
5
  import { getPathToOpen } from './node-utils.js';
6
+ import { nodeOrigin } from './source.js';
6
7
  const ORIENTATION_TAG = 0x0112;
7
8
  export const readOrientation = (file) => {
8
9
  let bytes;
@@ -82,7 +83,8 @@ export default {}
82
83
  ':image': node => {
83
84
  // process copy files to assets
84
85
  // '../assets/'
85
- const { path } = getPathToOpen(node.src, file);
86
+ // a picture an include brought is found from the file it was written in
87
+ const { path } = getPathToOpen(node.src, nodeOrigin(node)?.file ?? file);
86
88
  const { name, ext, dir } = pathMod.parse(path);
87
89
  const variable_name = 'i' + path.split('/').slice(1).join('_').replace(/\W+/g, '_').toLowerCase();
88
90
  const newFileName = `${variable_name}${ext}`;
@@ -1 +1 @@
1
- {"version":3,"file":"images-plugin.js","sourceRoot":"","sources":["../src/images-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAW,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,OAAO,MAAM,MAAM,CAAA;AAC1B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAG5C,MAAM,eAAe,GAAG,MAAM,CAAA;AAE9B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAiB,EAAE;IAC7D,IAAI,KAAa,CAAA;IACjB,IAAI,CAAC;QACH,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,MAAM;QAAE,OAAO,IAAI,CAAA;IACrE,IAAI,EAAE,GAAG,CAAC,CAAA;IACV,OAAO,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;QACnC,MAAM,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;QACrC,MAAM,IAAI,GAAG,KAAK,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,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AAW,GAAG,GAAG,aAAa,GAAG,GAAG,EAAE,CAAA;gBAC5C,MAAM,WAAW,GAAG,WAAW,GAAG,GAAG,GAAG,WAAW,CAAA;gBACnD,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;gBAElC,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,aAAa,EAAE,CAAA;YACxC,CAAC;SACF,CAAA;QACD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IACvC,CAAC,CAAA;IACD,MAAM,SAAS,GAAG,CAAC,IAAqB,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC1B,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;YAC9C,oCAAoC;YACpC,IAAI,KAAK,GAAG,EAA+B,CAAA;YAC3C,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,KAAK,CAAC,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;YAC9D,CAAC;YAED,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,CAAA;QACpC,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,CAAA;IACZ,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -1,3 +1,18 @@
1
+ import { publishRecord } from './record';
1
2
  import { PodliteWebPlugin } from './plugins';
2
- declare const plugin: () => PodliteWebPlugin;
3
+ export type IncludeResolveOptions = {
4
+ catalogue?: publishRecord[];
5
+ bounds?: string[];
6
+ late?: string[];
7
+ };
8
+ export declare class IncludeError extends Error {
9
+ readonly problems: string[];
10
+ constructor(problems: string[]);
11
+ }
12
+ export declare const includePasses: (options?: IncludeResolveOptions) => {
13
+ first: PodliteWebPlugin;
14
+ last: PodliteWebPlugin;
15
+ documents: (name: string) => string[];
16
+ };
17
+ declare const plugin: (options?: IncludeResolveOptions) => PodliteWebPlugin;
3
18
  export default plugin;
@@ -1,61 +1,249 @@
1
- import { getTextContentFromNode, makeInterator } from '@podlite/schema';
2
- import { runSelector } from './shared.js';
3
- const plugin = () => {
4
- const outCtx = {};
5
- const docsMap = new Map();
6
- const onExit = ctx => ({ ...ctx, ...outCtx });
7
- const processNode = (node, recs) => {
8
- const rules = {
9
- // TODO: remove 'Include' due to duplicate to 'include'
10
- Include: node => {
11
- const { content } = node;
12
- const selector = getTextContentFromNode(content).trim();
13
- console.warn(`[include] start resolve selector: ${selector}`);
14
- if (selector) {
15
- // try to resolve selector
16
- const [block] = runSelector(selector, recs);
17
- if (typeof block === 'object' && !('file' in block)) {
18
- const updated = { content: block };
19
- return { ...node, ...updated };
20
- }
21
- if (!block) {
22
- console.warn(`[plugin: resolve ] selector ${selector} not found`);
1
+ import * as path from 'path';
2
+ import { getFromTree } from '@podlite/schema';
3
+ import { assembleIncludes, podlite, writtenTree } from 'podlite';
4
+ import { refreshTocs } from 'podlite/lib/refresh-tocs';
5
+ import { catalogueOf, idOfFile } from './catalogue.js';
6
+ import { getParserTypeforFile, PARSER_TYPES } from './node-utils.js';
7
+ import { readRecordText } from './reading.js';
8
+ import { SITE_DATA_DOCUMENT } from './site-data-plugin.js';
9
+ import { nodeOriginKey, recordOrigin } from './source.js';
10
+ /*
11
+ =begin pod :kind<export>
12
+
13
+ =head2 IncludeError
14
+
15
+ The build stops when an include cannot place what it names:
16
+
17
+ =item the source or the address is not found;
18
+ =item the selector cannot be read;
19
+ =item the scheme is not one the site reads;
20
+ =item a name answers to two documents;
21
+ =item a file includes itself, directly or through other files.
22
+
23
+ C<problems> holds one line for each, with the file and the line of the directive.
24
+
25
+ =end pod
26
+ */
27
+ export class IncludeError extends Error {
28
+ problems;
29
+ constructor(problems) {
30
+ super(`an include is not placed:\n${problems.map(line => ` ${line}`).join('\n')}`);
31
+ this.name = 'IncludeError';
32
+ this.problems = problems;
33
+ }
34
+ }
35
+ // lose what the include names, though the assembler reports them as warnings
36
+ const stopping = new Set(['unsupported-scheme', 'unparsed-selector', 'cycle', 'ambiguous']);
37
+ const shown = (file) => (path.isAbsolute(file) ? path.relative(process.cwd(), file) : file);
38
+ const isNode = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
39
+ const nodesOf = (tree, ...queries) => getFromTree(tree, ...queries).flatMap(node => (isNode(node) ? [node] : []));
40
+ const isToc = (node) => node.type === 'block' && (node.name === 'toc' || node.name === 'Toc');
41
+ const hasToc = (tree) => nodesOf(tree, 'toc', 'Toc').some(isToc);
42
+ // the format a table of contents of the record is built again from; none for Markdown
43
+ const writtenFormat = (source) => {
44
+ const type = getParserTypeforFile(source.file, source.mime);
45
+ return type === PARSER_TYPES.MARKDOWN ? undefined : type === PARSER_TYPES.PODLITE ? 'podlite' : 'default';
46
+ };
47
+ const passes = (options) => {
48
+ const late = new Set([SITE_DATA_DOCUMENT, ...(options.late ?? [])]);
49
+ let waiting = false;
50
+ const catalogue = catalogueOf(options.catalogue ?? [], {
51
+ bounds: options.bounds,
52
+ parse: (text, file) => readRecordText(text, file),
53
+ waits: name => waiting && late.has(name),
54
+ });
55
+ const parser = podlite({ importPlugins: true });
56
+ // the file a directive was written in, by the place a problem shares with it
57
+ const fileAt = new WeakMap();
58
+ const describe = (problem) => {
59
+ const steps = problem.chain.map(step => {
60
+ const file = (step.location && fileAt.get(step.location)) || step.file;
61
+ return `${shown(file)}${step.location ? `:${step.location.start.line}` : ''}`;
62
+ });
63
+ const at = steps.pop() ?? '<document>';
64
+ return `${at}: ${problem.message}${steps.length ? ` (included through ${steps.reverse().join(', ')})` : ''}`;
65
+ };
66
+ const stampOf = (where) => where.via ? { file: where.file, via: where.via } : { file: where.file };
67
+ // The file each node was written in goes onto the node itself, where a copy
68
+ // keeps it; the assembler's own table is lost on the first copy a plugin makes.
69
+ const stamp = (tree, origin) => {
70
+ const visit = (node) => {
71
+ if (Array.isArray(node))
72
+ return node.forEach(visit);
73
+ if (!isNode(node))
74
+ return;
75
+ const where = origin.get(node);
76
+ if (where && !node[nodeOriginKey])
77
+ node[nodeOriginKey] = stampOf(where);
78
+ const file = node[nodeOriginKey]?.file;
79
+ if (file && isNode(node.location))
80
+ fileAt.set(node.location, file);
81
+ visit(node.content);
82
+ };
83
+ visit(tree);
84
+ };
85
+ // what the nodes say of themselves is told to the assembler, so that a block an
86
+ // earlier pass brought is not taken for one of the record
87
+ const seed = (tree, origin) => {
88
+ const visit = (node) => {
89
+ if (Array.isArray(node))
90
+ return node.forEach(visit);
91
+ if (!isNode(node))
92
+ return;
93
+ const mark = node[nodeOriginKey];
94
+ if (mark)
95
+ origin.set(node, { file: mark.file, text: '', ...(mark.via ? { via: mark.via } : {}) });
96
+ visit(node.content);
97
+ };
98
+ visit(tree);
99
+ };
100
+ const run = (pass) => {
101
+ const outCtx = {};
102
+ const onExit = ctx => ({ ...ctx, ...outCtx });
103
+ const onProcess = (recs) => {
104
+ if (!options.catalogue && pass !== 'last') {
105
+ console.warn('[plugin: resolve ] no catalogue of the site is given; an include is looked for among the records at hand');
106
+ }
107
+ // a document a plugin made earlier in the chain is a source too
108
+ catalogue.add(recs);
109
+ waiting = pass === 'first';
110
+ const problems = [];
111
+ // directives already said why they are left in place
112
+ const told = new WeakSet();
113
+ const fail = (problem) => {
114
+ const at = problem.chain[problem.chain.length - 1]?.location;
115
+ if (at)
116
+ told.add(at);
117
+ problems.push(describe(problem));
118
+ };
119
+ const warn = (problem) => {
120
+ if (stopping.has(problem.kind))
121
+ fail(problem);
122
+ else
123
+ console.warn(`[plugin: resolve ] ${describe(problem)}`);
124
+ };
125
+ // a document placed last is placed as it is: an include in it would need a third pass
126
+ const lateFiles = new Set();
127
+ if (pass !== 'first') {
128
+ for (const name of late) {
129
+ for (const id of catalogue.named(name)) {
130
+ lateFiles.add(id);
131
+ const text = catalogue.textOf(id);
132
+ if (text !== undefined && nodesOf(readRecordText(text, id), 'include').length) {
133
+ problems.push(`${shown(id)}: ${name} is placed after the other plugins, so it may not hold an include`);
134
+ }
23
135
  }
24
136
  }
137
+ if (problems.length)
138
+ throw new IncludeError(problems);
139
+ }
140
+ // one field of a record, read from one file
141
+ const assemble = (tree, record) => {
142
+ if (typeof tree !== 'object' || tree === null)
143
+ return tree;
144
+ // the tables of contents are built again in the passes that place the record's
145
+ // own text; the last one only adds documents plugins made
146
+ if (!nodesOf(tree, 'include').length && (pass === 'last' || !hasToc(tree)))
147
+ return tree;
148
+ const self = catalogue.idOf(record);
149
+ const source = recordOrigin(record);
150
+ const file = self ?? idOfFile(record.file);
151
+ const origin = new WeakMap();
152
+ seed(tree, origin);
153
+ let node = assembleIncludes(tree, {
154
+ sources: catalogue.sources,
155
+ context: path.dirname(file),
156
+ parse: readRecordText,
157
+ file,
158
+ ...(source ? { text: source.text } : {}),
159
+ self,
160
+ origin,
161
+ reportCycles: true,
162
+ onError: fail,
163
+ onWarning: warn,
164
+ });
165
+ // the record's own tables of contents reach what the includes brought
166
+ const format = source && writtenFormat(source);
167
+ if (source && format && hasToc(node)) {
168
+ node = refreshTocs(node, writtenTree(parser, source.text, format), file, origin);
169
+ }
170
+ stamp(node, origin);
25
171
  return node;
26
- },
27
- include: node => {
28
- const { content } = node;
29
- const selector = getTextContentFromNode(content).trim();
30
- console.warn(`[include] start resolve selector: ${selector}`);
31
- if (selector) {
32
- const result = runSelector(selector, recs);
33
- const blocks = [];
34
- for (const item of result) {
35
- if (typeof item === 'object' && item !== null && !('file' in item)) {
36
- blocks.push(item);
172
+ };
173
+ // two records of one reading share their tree
174
+ const trees = new WeakMap();
175
+ const assembleTree = (record) => {
176
+ const known = trees.get(record.node);
177
+ if (known)
178
+ return known;
179
+ const made = assemble(record.node, record);
180
+ trees.set(record.node, made);
181
+ return made;
182
+ };
183
+ // a template is a record of the chain and is assembled as one; a template a record
184
+ // carries is left as it is, as the plugins of images and links leave it
185
+ const out = recs.map(record => {
186
+ const node = assembleTree(record);
187
+ const description = assemble(record.description, record);
188
+ const header = assemble(record.header, record);
189
+ const footer = assemble(record.footer, record);
190
+ const same = node === record.node &&
191
+ description === record.description &&
192
+ header === record.header &&
193
+ footer === record.footer;
194
+ return same ? record : { ...record, node, description, header, footer };
195
+ });
196
+ if (pass !== 'first') {
197
+ for (const record of out) {
198
+ for (const tree of [record.node, record.description, record.header, record.footer]) {
199
+ for (const left of nodesOf(tree, 'include')) {
200
+ if (left.location && told.has(left.location))
201
+ continue;
202
+ const file = left[nodeOriginKey]?.file ?? record.file;
203
+ const line = left.location ? `:${left.location.start.line}` : '';
204
+ problems.push(`${shown(file)}${line}: the include is left in place`);
205
+ }
206
+ // a picture or a link placed now comes after the plugins that make them work
207
+ for (const node of nodesOf(tree, () => true)) {
208
+ const from = node[nodeOriginKey]?.file;
209
+ if (!from || !lateFiles.has(from))
210
+ continue;
211
+ const what = node.type === 'image' ? 'a picture' : node.type === 'fcode' && node.name === 'L' ? 'a link' : '';
212
+ if (what)
213
+ problems.push(`${shown(from)}: ${what} is placed after the plugins that handle it`);
37
214
  }
38
215
  }
39
- if (blocks.length > 0) {
40
- return { ...node, content: blocks };
41
- }
42
- console.warn(`[plugin: resolve ] selector ${selector} not found`);
43
216
  }
44
- return node;
45
- },
217
+ }
218
+ if (problems.length)
219
+ throw new IncludeError([...new Set(problems)]);
220
+ return out;
46
221
  };
47
- return makeInterator(rules)(node, {});
48
- };
49
- const onProcess = (recs) => {
50
- // convert all doc: links to file:: links
51
- const docsWithIncludesResolves = recs.map(item => {
52
- const node = processNode(item.node, recs);
53
- // const node = item.node
54
- return { ...item, node };
55
- });
56
- return docsWithIncludesResolves;
222
+ return [onProcess, onExit];
57
223
  };
58
- return [onProcess, onExit];
224
+ return { run, documents: (name) => catalogue.named(name) };
225
+ };
226
+ /*
227
+ =begin pod :kind<export>
228
+
229
+ =head2 includePasses
230
+
231
+ Gives the include plugin as two passes over one catalogue. C<first> goes before the
232
+ plugins of images, links and React and places all it can; an include of a
233
+ document a plugin makes later in the chain (the site data, and the names in
234
+ C<late>) waits there. C<last> goes after those plugins and places only such
235
+ documents. An include left after it stops the build. C<documents> gives the files
236
+ of the documents that answer to a name, for the links plugin to find a C<doc:>
237
+ link by the same names.
238
+
239
+ =end pod
240
+ */
241
+ export const includePasses = (options = {}) => {
242
+ const { run, documents } = passes(options);
243
+ return { first: run('first'), last: run('last'), documents };
59
244
  };
245
+ // One pass over the records: nothing waits, and an include that does not place
246
+ // what it names stops the build.
247
+ const plugin = (options = {}) => passes(options).run('only');
60
248
  export default plugin;
61
249
  //# sourceMappingURL=include-resolve-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"include-resolve-plugin.js","sourceRoot":"","sources":["../src/include-resolve-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,sBAAsB,EAAa,aAAa,EAAW,MAAM,iBAAiB,CAAA;AAGnH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,MAAM,MAAM,GAAG,GAAqB,EAAE;IACpC,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAE,CAAA;IACzB,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;IAC7C,MAAM,WAAW,GAAG,CAAC,IAAa,EAAE,IAAqB,EAAE,EAAE;QAC3D,MAAM,KAAK,GAAG;YACZ,uDAAuD;YACvD,OAAO,EAAE,IAAI,CAAC,EAAE;gBACd,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;gBACxB,MAAM,QAAQ,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;gBACvD,OAAO,CAAC,IAAI,CAAC,qCAAqC,QAAQ,EAAE,CAAC,CAAA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