podlite 0.0.83 → 0.0.85
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.
- package/CHANGELOG.podlite +96 -0
- package/esm/assemble/async.d.ts +31 -0
- package/esm/assemble/async.js +113 -0
- package/esm/assemble/async.js.map +1 -0
- package/esm/assemble/files.d.ts +2 -0
- package/esm/assemble/files.js +77 -0
- package/esm/assemble/files.js.map +1 -0
- package/esm/assemble/index.d.ts +60 -0
- package/esm/assemble/index.js +1011 -0
- package/esm/assemble/index.js.map +1 -0
- package/esm/cli.js +151 -26
- package/esm/cli.js.map +1 -1
- package/esm/file-format.d.ts +3 -0
- package/esm/file-format.js +53 -0
- package/esm/file-format.js.map +1 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -1
- package/esm/lint/grammar/scan.d.ts +1 -1
- package/esm/lint/grammar/scan.js +2 -1
- package/esm/lint/grammar/scan.js.map +1 -1
- package/esm/lint/index.d.ts +1 -1
- package/esm/lint/index.js +3 -3
- package/esm/lint/index.js.map +1 -1
- package/esm/lint/loader.js +5 -4
- package/esm/lint/loader.js.map +1 -1
- package/esm/lint/mute.js +2 -1
- package/esm/lint/mute.js.map +1 -1
- package/esm/lint/rules/include-resolves.d.ts +6 -0
- package/esm/lint/rules/include-resolves.js +89 -0
- package/esm/lint/rules/include-resolves.js.map +1 -0
- package/esm/lint/rules/index.js +5 -0
- package/esm/lint/rules/index.js.map +1 -1
- package/esm/lint/rules/named-blocks.d.ts +5 -0
- package/esm/lint/rules/named-blocks.js +29 -0
- package/esm/lint/rules/named-blocks.js.map +1 -0
- package/esm/lint/rules/table-shape.js +7 -1
- package/esm/lint/rules/table-shape.js.map +1 -1
- package/esm/lint/types.d.ts +6 -1
- package/esm/lint/types.js.map +1 -1
- package/esm/query-blocks.d.ts +6 -0
- package/esm/query-blocks.js +127 -0
- package/esm/query-blocks.js.map +1 -0
- package/esm/query.d.ts +2 -0
- package/esm/query.js +233 -26
- package/esm/query.js.map +1 -1
- package/esm/reader.d.ts +15 -0
- package/esm/reader.js +119 -0
- package/esm/reader.js.map +1 -0
- package/esm/refresh-tocs.d.ts +2 -0
- package/esm/refresh-tocs.js +52 -0
- package/esm/refresh-tocs.js.map +1 -0
- package/esm/resolve-includes.d.ts +27 -1
- package/esm/resolve-includes.js +80 -40
- package/esm/resolve-includes.js.map +1 -1
- package/esm/test/collect.d.ts +16 -0
- package/esm/test/collect.js +368 -0
- package/esm/test/collect.js.map +1 -0
- package/esm/test/documents.d.ts +47 -0
- package/esm/test/documents.js +211 -0
- package/esm/test/documents.js.map +1 -0
- package/esm/test/evaluate.d.ts +41 -0
- package/esm/test/evaluate.js +104 -0
- package/esm/test/evaluate.js.map +1 -0
- package/esm/test/formatters/json.d.ts +2 -0
- package/esm/test/formatters/json.js +11 -0
- package/esm/test/formatters/json.js.map +1 -0
- package/esm/test/formatters/text.d.ts +2 -0
- package/esm/test/formatters/text.js +104 -0
- package/esm/test/formatters/text.js.map +1 -0
- package/esm/test/index.d.ts +11 -0
- package/esm/test/index.js +19 -0
- package/esm/test/index.js.map +1 -0
- package/esm/test/resources.d.ts +5 -0
- package/esm/test/resources.js +45 -0
- package/esm/test/resources.js.map +1 -0
- package/esm/test/run.d.ts +52 -0
- package/esm/test/run.js +91 -0
- package/esm/test/run.js.map +1 -0
- package/esm/test/sources.d.ts +48 -0
- package/esm/test/sources.js +162 -0
- package/esm/test/sources.js.map +1 -0
- package/esm/test/types.d.ts +104 -0
- package/esm/test/types.js +3 -0
- package/esm/test/types.js.map +1 -0
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/assemble/async.d.ts +31 -0
- package/lib/assemble/async.js +118 -0
- package/lib/assemble/async.js.map +1 -0
- package/lib/assemble/files.d.ts +2 -0
- package/lib/assemble/files.js +81 -0
- package/lib/assemble/files.js.map +1 -0
- package/lib/assemble/index.d.ts +60 -0
- package/lib/assemble/index.js +1021 -0
- package/lib/assemble/index.js.map +1 -0
- package/lib/cli.js +149 -24
- package/lib/cli.js.map +1 -1
- package/lib/file-format.d.ts +3 -0
- package/lib/file-format.js +58 -0
- package/lib/file-format.js.map +1 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +22 -1
- package/lib/index.js.map +1 -1
- package/lib/lint/grammar/scan.d.ts +1 -1
- package/lib/lint/grammar/scan.js +2 -1
- package/lib/lint/grammar/scan.js.map +1 -1
- package/lib/lint/index.d.ts +1 -1
- package/lib/lint/index.js +3 -3
- package/lib/lint/index.js.map +1 -1
- package/lib/lint/loader.js +5 -4
- package/lib/lint/loader.js.map +1 -1
- package/lib/lint/mute.js +2 -1
- package/lib/lint/mute.js.map +1 -1
- package/lib/lint/rules/include-resolves.d.ts +6 -0
- package/lib/lint/rules/include-resolves.js +92 -0
- package/lib/lint/rules/include-resolves.js.map +1 -0
- package/lib/lint/rules/index.js +5 -0
- package/lib/lint/rules/index.js.map +1 -1
- package/lib/lint/rules/named-blocks.d.ts +5 -0
- package/lib/lint/rules/named-blocks.js +32 -0
- package/lib/lint/rules/named-blocks.js.map +1 -0
- package/lib/lint/rules/table-shape.js +7 -1
- package/lib/lint/rules/table-shape.js.map +1 -1
- package/lib/lint/types.d.ts +6 -1
- package/lib/lint/types.js.map +1 -1
- package/lib/query-blocks.d.ts +6 -0
- package/lib/query-blocks.js +136 -0
- package/lib/query-blocks.js.map +1 -0
- package/lib/query.d.ts +2 -0
- package/lib/query.js +232 -25
- package/lib/query.js.map +1 -1
- package/lib/reader.d.ts +15 -0
- package/lib/reader.js +124 -0
- package/lib/reader.js.map +1 -0
- package/lib/refresh-tocs.d.ts +2 -0
- package/lib/refresh-tocs.js +56 -0
- package/lib/refresh-tocs.js.map +1 -0
- package/lib/resolve-includes.d.ts +27 -1
- package/lib/resolve-includes.js +84 -40
- package/lib/resolve-includes.js.map +1 -1
- package/lib/test/collect.d.ts +16 -0
- package/lib/test/collect.js +374 -0
- package/lib/test/collect.js.map +1 -0
- package/lib/test/documents.d.ts +47 -0
- package/lib/test/documents.js +250 -0
- package/lib/test/documents.js.map +1 -0
- package/lib/test/evaluate.d.ts +41 -0
- package/lib/test/evaluate.js +142 -0
- package/lib/test/evaluate.js.map +1 -0
- package/lib/test/formatters/json.d.ts +2 -0
- package/lib/test/formatters/json.js +15 -0
- package/lib/test/formatters/json.js.map +1 -0
- package/lib/test/formatters/text.d.ts +2 -0
- package/lib/test/formatters/text.js +141 -0
- package/lib/test/formatters/text.js.map +1 -0
- package/lib/test/index.d.ts +11 -0
- package/lib/test/index.js +31 -0
- package/lib/test/index.js.map +1 -0
- package/lib/test/resources.d.ts +5 -0
- package/lib/test/resources.js +83 -0
- package/lib/test/resources.js.map +1 -0
- package/lib/test/run.d.ts +52 -0
- package/lib/test/run.js +95 -0
- package/lib/test/run.js.map +1 -0
- package/lib/test/sources.d.ts +48 -0
- package/lib/test/sources.js +200 -0
- package/lib/test/sources.js.map +1 -0
- package/lib/test/types.d.ts +104 -0
- package/lib/test/types.js +8 -0
- package/lib/test/types.js.map +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +28 -7
package/CHANGELOG.podlite
CHANGED
|
@@ -2,6 +2,102 @@
|
|
|
2
2
|
|
|
3
3
|
=head1 Upcoming
|
|
4
4
|
|
|
5
|
+
=head1 0.0.85
|
|
6
|
+
|
|
7
|
+
=item C<lint> warns about a block named C<=Include>, C<=Set>, C<=Config> or C<=Alias>, which is a named block and not the directive (rule C<directive-named-block>), and about C<=Image>, which the specification writes as C<=picture> (rule C<image-named-block>); each rule can be turned off on its own
|
|
8
|
+
|
|
9
|
+
=item C<assembleIncludes> takes C<reportCycles>: an include whose path names a source already on the way in is then reported as C<cycle> even when it loses no C<=set>; a mask that finds the file it is written in still passes it by without a word
|
|
10
|
+
|
|
11
|
+
=head1 0.0.84
|
|
12
|
+
|
|
13
|
+
=item a C<=set> before C<=include> reaches a paragraph or code written without a marker that the include brings first, and an include failing after such a paragraph no longer reports the assignment lost
|
|
14
|
+
|
|
15
|
+
=item C<podlite test> runs a test under each configuration that reaches a paragraph or code written without a marker in it
|
|
16
|
+
|
|
17
|
+
=item a file is read in the format its name gives: C<.podlite> and C<.pod6> as Podlite, C<.md> and C<.markdown> as Markdown, any other extension or none in the default mode, where text outside blocks is ambient; the extension is compared without regard to case. This holds for an included file, for the document C<convert>, C<query> and C<podlite test> are given, and for C<lint>; text from the standard input stays Podlite. A C<.md> file brought by C<=include> was read as Podlite, and a C<.txt> file as Podlite paragraphs
|
|
18
|
+
|
|
19
|
+
=item a C<:mime-type> written on the C<=include> line after the address of the source, before a selection, decides how that file is read: C<text/podlite>, C<text/markdown>, and any other C<text/> type in the default mode; a type that is not text is an error of the new kind C<format>, and the include brings nothing. A configuration that does not read whole leaves the line unread. It was taken as part of the file name
|
|
20
|
+
|
|
21
|
+
=item an included Markdown file gets the C<=config> of the including file on its blocks
|
|
22
|
+
|
|
23
|
+
=item C<formatOfFile>, C<formatOfType> and C<writtenTree> are exported; C<ReadFormat> has the value C<default>. A source may carry C<format>; the fourth argument of the reader and of C<parse> in an include assembly may carry C<format> for that one reading
|
|
24
|
+
|
|
25
|
+
=item C<podlite convert> and C<podlite query> warn when an included file comes from outside the root: the directory of each input file, or the current directory for stdin. C<--root> sets one root for every input. A file is outside by its real path, with links followed. The warning names the directive and the path as written, gives a mask the number of its files that are outside, and is given only when blocks of such a file stand in the assembled document; C<query> gives it only for blocks it prints
|
|
26
|
+
|
|
27
|
+
=item C<podlite convert> prints the file and line of the directive in front of every include warning
|
|
28
|
+
|
|
29
|
+
=item a source may carry C<external>, the reason it is external; an include whose blocks from such sources stand in the assembled document is reported once as an C<external> warning, with those sources in C<sources>; a comment counts, as it stands in the document. C<externalMessage> gives the text of such a warning for the sources a host shows. The origin of a node lists the directives it came through in C<steps>. C<resolveIncludes> takes C<root>, and a C<SourceProvider> may give C<real>, the path of a file with links followed
|
|
30
|
+
|
|
31
|
+
=item a mask of C<sourcesFromFiles> is resolved like a path, its C<.> and C<..> steps taken, and stays in its directory: C<*.podlite> no longer names files in directories below, as on disk; C<**> goes down
|
|
32
|
+
|
|
33
|
+
=item C<sourcesFromFiles> is a root of its own: a path with or without a leading slash names the same text, so a host can give its files by plain relative paths; a source keeps the identity it had
|
|
34
|
+
|
|
35
|
+
=item the lint context takes C<sources>, C<context> and C<self>: the C<include-resolves> rule checks a text that is not read from disk against the sources a host gives
|
|
36
|
+
|
|
37
|
+
=item C<podlite/lib/refresh-tocs> is exported
|
|
38
|
+
|
|
39
|
+
=item C<readerFor> takes C<body>: a block the host says yes to has its raw body read as Podlite in its place, with the settings in effect where the block stands; the blocks of the body stand at their places in the text, and an include assembly given the same reader brings what an C<=include> written in the body names
|
|
40
|
+
|
|
41
|
+
=item a provider of include sources names the address schemes it resolves in C<schemes>, C<file> alone when it names none, and C<locate> is given the scheme as its last argument: C<=include doc:Name> and an operand C<in doc:Name> reach a provider that lists C<doc>. A path that is not a mask names one source. When a provider says in C<failed> why it cannot give one, the problem carries the address and that reason and the directive stays in the tree; two sources with different ids for such a path are refused the same way. A source that is not found, with no reason given, is reported as before. A document that includes itself is told from its id before it is read. C<SourceStore.located> takes the scheme as its last argument
|
|
42
|
+
|
|
43
|
+
=item C<podlite lint> reads an included Podlite file with the Markdown and table of contents plugins and with the settings in effect at the directive: a heading written in a Markdown section of an included file is found by its address; it was reported as not found. A warning a plugin prints while an included file is read stays off the console, and an included file that cannot be read costs one finding and leaves the others in place
|
|
44
|
+
|
|
45
|
+
=item C<readerFor> makes the reading an include assembly asks for out of a parser, so a host need not write it; its fourth argument hands the parser the lists it fills with recognition events and diagnostics
|
|
46
|
+
|
|
47
|
+
=item the assembly of includes is exported from C<podlite> as well as from C<podlite/assemble>. C<locate> may say why a mask could not be expanded, in C<failed>; with C<tolerant> a text that fails to parse is a source that cannot be had
|
|
48
|
+
|
|
49
|
+
=item a table of contents written in an included file lists what that file includes: it is built again over the file once its own includes are in, also when the table alone is brought in by a selector. It listed the file as it was before them
|
|
50
|
+
|
|
51
|
+
=item C<podlite/assemble> gives C<sourcesFromFiles>, sources over texts held in memory by path, and C<assembleAsync>, which assembles a document whose sources answer through promises: it asks for what is missing and assembles again until nothing is. C<createSourceStore> keeps the answers between assemblies. Sources may answer C<undefined> for what is not known yet; the include then stays in place with its C<=set> assignments and nothing is reported
|
|
52
|
+
|
|
53
|
+
=item the assembly of includes is given as C<podlite/assemble>, an entry with no module of Node in it: C<assembleIncludes> takes the included text from C<sources> the host gives, where C<locate> finds the sources a written path names and C<read> gives the text of one. C<resolveIncludes> reads the disk through it and is not changed. An include problem that loses C<=set> assignments names them in C<lost>
|
|
54
|
+
|
|
55
|
+
=item a file an C<=include> brings whole stays in a C<root> block in the assembled document, so its C<=config> and C<=alias> end with it: in HTML and Markdown they acted on the blocks after the include. A selection goes through the block and does not find it
|
|
56
|
+
|
|
57
|
+
=item C<podlite test> runs a test brought in by several files once for each configuration it is brought in under; it ran it once whatever the configuration
|
|
58
|
+
|
|
59
|
+
=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
|
|
60
|
+
|
|
61
|
+
=item a C<=config> written before C<=include> reaches the blocks the include places, as it reaches the blocks written after it; an included file kept to its own C<=config>. The nearer file decides an option: the file of the block, then the files including it, nearest first. The included text is read with those settings, so a C<:allow> they give opens its blocks to markup codes. C<convert>, C<query> and C<test> follow the rule
|
|
62
|
+
|
|
63
|
+
=item the selector of an C<=include> still reads the file without the settings of the including file. A found block those settings read as something else is placed as its file reads on its own, with the warning C<include-reading-differs>
|
|
64
|
+
|
|
65
|
+
=item C<resolveIncludes> hands C<parse> the settings in effect at the directive as a third argument
|
|
66
|
+
|
|
67
|
+
=item a C<=set> written before C<=include> reaches the first block the include brings, in C<convert>, C<query> and C<podlite test>; the block after the include received it. When the include brings no block, the assignment goes on to the next block of the same list, and to the end of the list without one it is reported with the kind C<set-target>. When the include fails, it goes nowhere, and the message of the failure names it; an include that brings nothing because its file is already being included says so with the kind C<cycle>, and does so only when it loses an assignment. Both kinds are warnings, and C<isWarning> is exported. An include that fails inside the included content, before any block, stops the search the same way: the assignment goes nowhere and its message names it. C<podlite lint> reads the document without its includes, so a link to an address a C<=set> gives an included block is reported as not found; before, the address landed on the block after the include
|
|
68
|
+
|
|
69
|
+
=item C<podlite query> reads a file its selector names, relative to the working directory, as it reads a file an operand of C<in> names: C<podlite query 'file:x.podlite | para'> needs no input files, a mask is expanded on disk as C<=include> expands it, and the files and input given are not read, with a warning. A source that does not resolve, and an address no file holds, is reported once and exits with 1; it used to give 0 matches. A file given is no longer taken for a source that only shares its tail, and a C<doc:> source is looked for among the files given
|
|
70
|
+
|
|
71
|
+
=item an include by a selector places a found block once: a block inside another found block comes with it and is not placed again, so C<=include part.podlite | *> brings a heading inside a C<=pod> once, and one table of contents. With C<*> the include brings no C<=alias> written at the top of the file, and an C<A<>> code that relies on it is left as written; an include without a selector still brings the whole file
|
|
72
|
+
|
|
73
|
+
=item C<podlite query> selects from the tree C<convert> and C<podlite test> read: a Markdown section is read into blocks, a table from C<data:> into rows and cells, and tables of contents are made again after the includes. A block with no place of its own in the file is given in C<--to podlite> as its Markdown, a row of such a table as one line of cells; in C<--to json> a block of a Markdown section carries the place of the section and C<precision: section>. The root inside a section and a folded section are not counted as found. C<--to md> and C<--to html> hide what the document hides. A query loads the Markdown, image and table of contents plugins when it runs, not the diagram renderer. The rules are shared through the entry C<podlite/lib/query-blocks>
|
|
74
|
+
|
|
75
|
+
=item tables of contents are made again after the includes inside the block that holds them, and C<podlite test> finds a C<=toc> block
|
|
76
|
+
|
|
77
|
+
=item C<podlite query>, C<=include> and C<podlite test> read a C<file:> operand of C<in> relative to where the selector is written: the working directory, the file of the directive, the file of the test. An operand that does not resolve is reported: the query exits with 1, the include brings nothing in and C<podlite lint> reports it as an error, and the assertion does not hold
|
|
78
|
+
|
|
79
|
+
=item podlite test runs the tests written in Podlite files: each C<=test> is reported as passed, failed or skipped, with the assertion that did not hold, the document it read and where a found block is written. C<--against> examines a document with the tests, C<--format json> writes the report as one JSON document, and C<--allow-skipped> lets skipped tests alone pass the run. The exit code is 0 when every test passed, 1 when a test failed or was skipped, no test was found or an include lost tests, and 2 on wrong arguments or a failure of the implementation
|
|
80
|
+
|
|
81
|
+
=item podlite/test gives the runner to programs: C<runTests> returns the report as data, and C<collectTests>, C<planRuns>, C<inputsFor> and C<evaluateAssertion> are its parts
|
|
82
|
+
|
|
83
|
+
=item an include whose selector cannot be read, or whose scheme is not C<file:>, is now a warning in podlite convert, podlite query and the include-resolves rule of podlite lint; it used to be left in place without a word
|
|
84
|
+
|
|
85
|
+
=item podlite --version prints the version of the package
|
|
86
|
+
|
|
87
|
+
=item podlite convert keeps a table of contents hidden when it is rebuilt after the includes are in
|
|
88
|
+
|
|
89
|
+
=item podlite convert builds a table of contents of the document after its includes are in, so the table lists the blocks they bring
|
|
90
|
+
|
|
91
|
+
=item C<:lint-ignore> on a block no longer silences a finding at the first line of the block after it
|
|
92
|
+
|
|
93
|
+
=item podlite query selects through C<=include>: blocks an include brings in are found, their text and the file in the json output are those of the file they are written in, and a selection of C<include> no longer finds a directive that resolved. An include that is not there is reported with the file and line of the directive, the other matches are still written, and the exit code is 1; the report is not silenced by --quiet
|
|
94
|
+
|
|
95
|
+
=item podlite convert stops on an include whose address is not in the file, as it already did on a missing file, and on a source that is a directory. The address is found the way a link finds its target: by C<:id>, or by a heading under its name or the form an output gives it
|
|
96
|
+
|
|
97
|
+
=item when two blocks of an included file share the address, the first is taken and podlite convert warns; the last one used to be taken
|
|
98
|
+
|
|
99
|
+
=item podlite lint adds the include-resolves rule: an include whose source or address is not there is an error at the directive, a problem inside an included file is reported at the directive that brought it in, and an address that names two blocks is a warning. A selection that finds nothing is not reported. The rule runs on files read from disk only
|
|
100
|
+
|
|
5
101
|
=head1 0.0.83
|
|
6
102
|
|
|
7
103
|
=item the C<./lint> entry can be reached with C<import>. Its ESM build called C<require> in two places, and a module does not have that word, so the entry died on load. Reading a config written as code stays synchronous, so C<readConfig> and C<resolveConfig> keep their shape
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AssembleOptions, IncludeStep, Located, Source, Sources } from './index';
|
|
2
|
+
export type AsyncSources = {
|
|
3
|
+
schemes?: readonly string[];
|
|
4
|
+
locate: (path: string, context: unknown, plain?: boolean, at?: IncludeStep, scheme?: string) => Located | Promise<Located>;
|
|
5
|
+
read: (source: Source) => string | null | Promise<string | null>;
|
|
6
|
+
};
|
|
7
|
+
type Wanted = {
|
|
8
|
+
kind: 'locate';
|
|
9
|
+
path: string;
|
|
10
|
+
context: unknown;
|
|
11
|
+
plain: boolean;
|
|
12
|
+
at?: IncludeStep;
|
|
13
|
+
scheme?: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'read';
|
|
16
|
+
source: Source;
|
|
17
|
+
};
|
|
18
|
+
export type SourceStore = {
|
|
19
|
+
sources: () => Sources;
|
|
20
|
+
wanted: () => Wanted[];
|
|
21
|
+
located: (path: string, context: unknown, plain: boolean, at: IncludeStep | undefined, answer: Located, scheme?: string) => void;
|
|
22
|
+
text: (source: Source, answer: string | null) => void;
|
|
23
|
+
drop: (id?: string) => void;
|
|
24
|
+
};
|
|
25
|
+
export declare const createSourceStore: () => SourceStore;
|
|
26
|
+
export type AssembleAsyncOptions = Omit<AssembleOptions, 'sources'> & {
|
|
27
|
+
sources: AsyncSources;
|
|
28
|
+
store?: SourceStore;
|
|
29
|
+
};
|
|
30
|
+
export declare const assembleAsync: (tree: any, opts: AssembleAsyncOptions) => Promise<any>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*
|
|
2
|
+
=begin pod :kind<module>
|
|
3
|
+
|
|
4
|
+
=head2 async
|
|
5
|
+
|
|
6
|
+
Assembly over sources that answer later: a host that reads files through a
|
|
7
|
+
promise gives its answers to a store, and the assembly runs over the store until
|
|
8
|
+
nothing is left to ask.
|
|
9
|
+
|
|
10
|
+
=end pod
|
|
11
|
+
*/
|
|
12
|
+
import { assembleIncludes, silently } from './index.js';
|
|
13
|
+
export const createSourceStore = () => {
|
|
14
|
+
const places = new Map();
|
|
15
|
+
const texts = new Map();
|
|
16
|
+
let asked = [];
|
|
17
|
+
// A path read as written and the same path read as a mask are two questions,
|
|
18
|
+
// and so is the same path at two directives: a host may answer by the place.
|
|
19
|
+
const keyOf = (path, plain, at, scheme = 'file') => `${plain ? 'plain' : 'mask'}\u0000${scheme}\u0000${path}\u0000${at ? `${at.file}@${at.location?.start?.offset ?? ''}` : ''}`;
|
|
20
|
+
const want = (item, same) => {
|
|
21
|
+
if (!asked.some(same))
|
|
22
|
+
asked.push(item);
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
sources: () => ({
|
|
26
|
+
locate: (path, context, plain = false, at, scheme) => {
|
|
27
|
+
const key = keyOf(path, plain, at, scheme);
|
|
28
|
+
const known = places.get(context)?.get(key);
|
|
29
|
+
if (known)
|
|
30
|
+
return known;
|
|
31
|
+
want({ kind: 'locate', path, context, plain, at, scheme }, o => o.kind === 'locate' && o.context === context && keyOf(o.path, o.plain, o.at, o.scheme) === key);
|
|
32
|
+
return undefined;
|
|
33
|
+
},
|
|
34
|
+
read: source => {
|
|
35
|
+
if (texts.has(source.id))
|
|
36
|
+
return texts.get(source.id) ?? null;
|
|
37
|
+
want({ kind: 'read', source }, o => o.kind === 'read' && o.source.id === source.id);
|
|
38
|
+
return undefined;
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
wanted: () => {
|
|
42
|
+
const out = asked;
|
|
43
|
+
asked = [];
|
|
44
|
+
return out;
|
|
45
|
+
},
|
|
46
|
+
located: (path, context, plain, at, answer, scheme) => {
|
|
47
|
+
const known = places.get(context) ?? new Map();
|
|
48
|
+
known.set(keyOf(path, plain, at, scheme), answer);
|
|
49
|
+
places.set(context, known);
|
|
50
|
+
},
|
|
51
|
+
text: (source, answer) => {
|
|
52
|
+
texts.set(source.id, answer);
|
|
53
|
+
},
|
|
54
|
+
drop: id => {
|
|
55
|
+
if (id === undefined) {
|
|
56
|
+
places.clear();
|
|
57
|
+
texts.clear();
|
|
58
|
+
}
|
|
59
|
+
else
|
|
60
|
+
texts.delete(id);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
// more rounds than any document needs: each one must bring a new answer
|
|
65
|
+
const maxRounds = 1000;
|
|
66
|
+
/*
|
|
67
|
+
=begin pod :kind<export>
|
|
68
|
+
|
|
69
|
+
=head2 assembleAsync
|
|
70
|
+
|
|
71
|
+
Assembles a document whose sources answer through promises. The document is
|
|
72
|
+
assembled over the answers at hand; what was missing is asked of C<sources>, and
|
|
73
|
+
the assembly is run again from the document as given, until nothing is missing.
|
|
74
|
+
Only that last assembly reports problems, fills C<origin> and calls C<onCopy>. A
|
|
75
|
+
source that fails to answer is taken as one that cannot be had.
|
|
76
|
+
|
|
77
|
+
=end pod
|
|
78
|
+
*/
|
|
79
|
+
export const assembleAsync = async (tree, opts) => {
|
|
80
|
+
const { sources, store = createSourceStore(), ...rest } = opts;
|
|
81
|
+
const ignore = () => { };
|
|
82
|
+
// the store answers for the host, so it knows the schemes the host knows
|
|
83
|
+
const known = () => ({ ...store.sources(), schemes: sources.schemes });
|
|
84
|
+
for (let round = 0; round < maxRounds; round++) {
|
|
85
|
+
silently(() => assembleIncludes(tree, {
|
|
86
|
+
...rest,
|
|
87
|
+
sources: known(),
|
|
88
|
+
origin: new WeakMap(),
|
|
89
|
+
onCopy: undefined,
|
|
90
|
+
onError: ignore,
|
|
91
|
+
onWarning: ignore,
|
|
92
|
+
}));
|
|
93
|
+
const wanted = store.wanted();
|
|
94
|
+
if (wanted.length === 0)
|
|
95
|
+
return assembleIncludes(tree, { ...rest, sources: known() });
|
|
96
|
+
await Promise.all(wanted.map(async (item) => {
|
|
97
|
+
if (item.kind === 'locate') {
|
|
98
|
+
const answer = await Promise.resolve()
|
|
99
|
+
.then(() => sources.locate(item.path, item.context, item.plain, item.at, item.scheme))
|
|
100
|
+
.catch(() => ({ masked: false, sources: [] }));
|
|
101
|
+
store.located(item.path, item.context, item.plain, item.at, answer, item.scheme);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const answer = await Promise.resolve()
|
|
105
|
+
.then(() => sources.read(item.source))
|
|
106
|
+
.catch(() => null);
|
|
107
|
+
store.text(item.source, answer);
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
throw new Error('include sources keep asking for more');
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/assemble/async.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AA8CpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAgB,EAAE;IACjD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiC,CAAA;IACvD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAA;IAC9C,IAAI,KAAK,GAAa,EAAE,CAAA;IACxB,6EAA6E;IAC7E,6EAA6E;IAC7E,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,KAAc,EAAE,EAAgB,EAAE,MAAM,GAAG,MAAM,EAAU,EAAE,CACxF,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,SAAS,MAAM,SAAS,IAAI,SACrD,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAC1D,EAAE,CAAA;IACJ,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,IAAgC,EAAQ,EAAE;QACpE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,KAAK,CAAC,IAAI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CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;YAClF,CAAC;iBAAM,CAAC;gBACN,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE;qBACnC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;qBACrC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;gBACpB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;YACjC,CAAC;QACH,CAAC,CAAC,CACH,CAAA;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;AACzD,CAAC,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
=begin pod :kind<module>
|
|
3
|
+
|
|
4
|
+
=head2 files
|
|
5
|
+
|
|
6
|
+
Sources kept in memory: a set of texts by path, for tests and for a host that
|
|
7
|
+
holds its files itself.
|
|
8
|
+
|
|
9
|
+
=end pod
|
|
10
|
+
*/
|
|
11
|
+
import { filePathMatches } from '@podlite/schema';
|
|
12
|
+
const isMask = (path) => /[*?]/.test(path);
|
|
13
|
+
// a path with its . and .. steps taken, as a file system would take them
|
|
14
|
+
const normalize = (path) => {
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const part of path.split('/')) {
|
|
17
|
+
if (part === '' || part === '.')
|
|
18
|
+
continue;
|
|
19
|
+
if (part === '..')
|
|
20
|
+
out.pop();
|
|
21
|
+
else
|
|
22
|
+
out.push(part);
|
|
23
|
+
}
|
|
24
|
+
return (path.startsWith('/') ? '/' : '') + out.join('/');
|
|
25
|
+
};
|
|
26
|
+
const join = (dir, path) => normalize(path.startsWith('/') ? path : `${dir}/${path}`);
|
|
27
|
+
// a set of texts is a root of its own: a leading slash in a path does not change the place it names
|
|
28
|
+
const placeOf = (path) => normalize(path).replace(/^\/+/, '');
|
|
29
|
+
const dirOf = (path) => {
|
|
30
|
+
const at = path.lastIndexOf('/');
|
|
31
|
+
return at <= 0 ? (at === 0 ? '/' : '') : path.slice(0, at);
|
|
32
|
+
};
|
|
33
|
+
/*
|
|
34
|
+
=begin pod :kind<export>
|
|
35
|
+
|
|
36
|
+
=head2 sourcesFromFiles
|
|
37
|
+
|
|
38
|
+
Sources over texts given by path. A written path is resolved against the
|
|
39
|
+
directory of the text the directive is written in; the context of the document
|
|
40
|
+
itself is its directory, a string, empty for the root of the set. The set is a
|
|
41
|
+
root of its own: C<a.podlite> and C</a.podlite> name one place, and of two such
|
|
42
|
+
paths the later one holds. A mask of C<*> and C<?> names the files that match
|
|
43
|
+
it, in the order of their paths: it is resolved like a path first, and C<*> does
|
|
44
|
+
not go down into a directory while C<**> does.
|
|
45
|
+
|
|
46
|
+
=end pod
|
|
47
|
+
*/
|
|
48
|
+
export const sourcesFromFiles = (files) => {
|
|
49
|
+
const texts = new Map(Object.keys(files).map((path) => [placeOf(path), files[path]]));
|
|
50
|
+
const sourceAt = (id, name) => ({ id, name, context: dirOf(id) });
|
|
51
|
+
return {
|
|
52
|
+
locate: (written, context, plain) => {
|
|
53
|
+
const dir = String(context ?? '');
|
|
54
|
+
if (plain || !isMask(written))
|
|
55
|
+
return { masked: false, sources: [sourceAt(join(dir, written), written)] };
|
|
56
|
+
// The mask is resolved like a path first, its . and .. steps taken, and then
|
|
57
|
+
// matched against whole paths of the set with the slash kept in front, so
|
|
58
|
+
// that it stays anchored: * does not go down into a directory, ** does.
|
|
59
|
+
const absolute = written.startsWith('/');
|
|
60
|
+
const pattern = placeOf(absolute ? written : join(dir, written));
|
|
61
|
+
const base = placeOf(dir);
|
|
62
|
+
const prefix = base === '' ? '' : `${base}/`;
|
|
63
|
+
const rooted = dir === '' || dir.startsWith('/');
|
|
64
|
+
const keys = [...texts.keys()].filter(key => filePathMatches(`/${key}`, `/${pattern}`)).sort();
|
|
65
|
+
return {
|
|
66
|
+
masked: true,
|
|
67
|
+
sources: keys.map(key => {
|
|
68
|
+
// named as written: from the directory of the text, or from the root when outside it
|
|
69
|
+
const name = !absolute && key.startsWith(prefix) ? key.slice(prefix.length) : `/${key}`;
|
|
70
|
+
return sourceAt(rooted ? `/${key}` : key, name);
|
|
71
|
+
}),
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
read: source => texts.get(placeOf(source.id)) ?? null,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/assemble/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;EASE;AACF,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAGjD,MAAM,MAAM,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAE3D,yEAAyE;AACzE,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE;IACzC,MAAM,GAAG,GAAa,EAAE,CAAA;IACxB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,GAAG;YAAE,SAAQ;QACzC,IAAI,IAAI,KAAK,IAAI;YAAE,GAAG,CAAC,GAAG,EAAE,CAAA;;YACvB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACrB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC1D,CAAC,CAAA;AAED,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,IAAY,EAAU,E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AC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;gBACjD,CAAC,CAAC;aACH,CAAA;QACH,CAAC;QACD,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI;KACtD,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ConfigScope, Location } from '@podlite/schema';
|
|
2
|
+
import type { ReadFormat } from '../file-format';
|
|
3
|
+
export type IncludeStep = {
|
|
4
|
+
file: string;
|
|
5
|
+
location?: Location;
|
|
6
|
+
};
|
|
7
|
+
export type IncludeProblem = {
|
|
8
|
+
kind: 'source' | 'address' | 'ambiguous' | 'unparsed-selector' | 'unsupported-scheme' | 'operand' | 'cycle' | 'set-target' | 'include-reading-differs' | 'external' | 'format';
|
|
9
|
+
target: string;
|
|
10
|
+
message: string;
|
|
11
|
+
lost?: string[];
|
|
12
|
+
chain: IncludeStep[];
|
|
13
|
+
sources?: Source[];
|
|
14
|
+
};
|
|
15
|
+
export type IncludeOrigin = {
|
|
16
|
+
file: string;
|
|
17
|
+
text: string;
|
|
18
|
+
via?: string;
|
|
19
|
+
steps?: IncludeStep[];
|
|
20
|
+
};
|
|
21
|
+
export type Source = {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
context: unknown;
|
|
25
|
+
format?: ReadFormat;
|
|
26
|
+
external?: string;
|
|
27
|
+
};
|
|
28
|
+
export type Located = {
|
|
29
|
+
masked: boolean;
|
|
30
|
+
sources: Source[];
|
|
31
|
+
failed?: string;
|
|
32
|
+
};
|
|
33
|
+
export type Sources = {
|
|
34
|
+
schemes?: readonly string[];
|
|
35
|
+
locate: (path: string, context: unknown, plain?: boolean, at?: IncludeStep, scheme?: string) => Located | undefined;
|
|
36
|
+
read: (source: Source) => string | null | undefined;
|
|
37
|
+
};
|
|
38
|
+
export type AssembleOptions = {
|
|
39
|
+
sources: Sources;
|
|
40
|
+
context: unknown;
|
|
41
|
+
parse: (source: string, file: string, config?: ConfigScope, how?: {
|
|
42
|
+
format?: ReadFormat;
|
|
43
|
+
}) => any;
|
|
44
|
+
file?: string;
|
|
45
|
+
text?: string;
|
|
46
|
+
self?: string;
|
|
47
|
+
onError?: (problem: IncludeProblem) => void;
|
|
48
|
+
onWarning?: (problem: IncludeProblem) => void;
|
|
49
|
+
origin?: WeakMap<object, IncludeOrigin>;
|
|
50
|
+
onCopy?: (from: object, to: object) => void;
|
|
51
|
+
tolerant?: boolean;
|
|
52
|
+
reportCycles?: boolean;
|
|
53
|
+
};
|
|
54
|
+
export declare const isWarning: (problem: IncludeProblem) => boolean;
|
|
55
|
+
export declare const externalMessage: (sources: Source[], written: string) => string;
|
|
56
|
+
export declare const silently: <T>(work: () => T) => T;
|
|
57
|
+
export declare const assembleIncludes: (tree: any, opts: AssembleOptions) => any;
|
|
58
|
+
export { sourcesFromFiles } from './files';
|
|
59
|
+
export { assembleAsync, createSourceStore } from './async';
|
|
60
|
+
export type { AsyncSources, SourceStore, AssembleAsyncOptions } from './async';
|