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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sourcesFromFiles = void 0;
|
|
4
|
+
/*
|
|
5
|
+
=begin pod :kind<module>
|
|
6
|
+
|
|
7
|
+
=head2 files
|
|
8
|
+
|
|
9
|
+
Sources kept in memory: a set of texts by path, for tests and for a host that
|
|
10
|
+
holds its files itself.
|
|
11
|
+
|
|
12
|
+
=end pod
|
|
13
|
+
*/
|
|
14
|
+
const schema_1 = require("@podlite/schema");
|
|
15
|
+
const isMask = (path) => /[*?]/.test(path);
|
|
16
|
+
// a path with its . and .. steps taken, as a file system would take them
|
|
17
|
+
const normalize = (path) => {
|
|
18
|
+
const out = [];
|
|
19
|
+
for (const part of path.split('/')) {
|
|
20
|
+
if (part === '' || part === '.')
|
|
21
|
+
continue;
|
|
22
|
+
if (part === '..')
|
|
23
|
+
out.pop();
|
|
24
|
+
else
|
|
25
|
+
out.push(part);
|
|
26
|
+
}
|
|
27
|
+
return (path.startsWith('/') ? '/' : '') + out.join('/');
|
|
28
|
+
};
|
|
29
|
+
const join = (dir, path) => normalize(path.startsWith('/') ? path : `${dir}/${path}`);
|
|
30
|
+
// a set of texts is a root of its own: a leading slash in a path does not change the place it names
|
|
31
|
+
const placeOf = (path) => normalize(path).replace(/^\/+/, '');
|
|
32
|
+
const dirOf = (path) => {
|
|
33
|
+
const at = path.lastIndexOf('/');
|
|
34
|
+
return at <= 0 ? (at === 0 ? '/' : '') : path.slice(0, at);
|
|
35
|
+
};
|
|
36
|
+
/*
|
|
37
|
+
=begin pod :kind<export>
|
|
38
|
+
|
|
39
|
+
=head2 sourcesFromFiles
|
|
40
|
+
|
|
41
|
+
Sources over texts given by path. A written path is resolved against the
|
|
42
|
+
directory of the text the directive is written in; the context of the document
|
|
43
|
+
itself is its directory, a string, empty for the root of the set. The set is a
|
|
44
|
+
root of its own: C<a.podlite> and C</a.podlite> name one place, and of two such
|
|
45
|
+
paths the later one holds. A mask of C<*> and C<?> names the files that match
|
|
46
|
+
it, in the order of their paths: it is resolved like a path first, and C<*> does
|
|
47
|
+
not go down into a directory while C<**> does.
|
|
48
|
+
|
|
49
|
+
=end pod
|
|
50
|
+
*/
|
|
51
|
+
const sourcesFromFiles = (files) => {
|
|
52
|
+
const texts = new Map(Object.keys(files).map((path) => [placeOf(path), files[path]]));
|
|
53
|
+
const sourceAt = (id, name) => ({ id, name, context: dirOf(id) });
|
|
54
|
+
return {
|
|
55
|
+
locate: (written, context, plain) => {
|
|
56
|
+
const dir = String(context ?? '');
|
|
57
|
+
if (plain || !isMask(written))
|
|
58
|
+
return { masked: false, sources: [sourceAt(join(dir, written), written)] };
|
|
59
|
+
// The mask is resolved like a path first, its . and .. steps taken, and then
|
|
60
|
+
// matched against whole paths of the set with the slash kept in front, so
|
|
61
|
+
// that it stays anchored: * does not go down into a directory, ** does.
|
|
62
|
+
const absolute = written.startsWith('/');
|
|
63
|
+
const pattern = placeOf(absolute ? written : join(dir, written));
|
|
64
|
+
const base = placeOf(dir);
|
|
65
|
+
const prefix = base === '' ? '' : `${base}/`;
|
|
66
|
+
const rooted = dir === '' || dir.startsWith('/');
|
|
67
|
+
const keys = [...texts.keys()].filter(key => (0, schema_1.filePathMatches)(`/${key}`, `/${pattern}`)).sort();
|
|
68
|
+
return {
|
|
69
|
+
masked: true,
|
|
70
|
+
sources: keys.map(key => {
|
|
71
|
+
// named as written: from the directory of the text, or from the root when outside it
|
|
72
|
+
const name = !absolute && key.startsWith(prefix) ? key.slice(prefix.length) : `/${key}`;
|
|
73
|
+
return sourceAt(rooted ? `/${key}` : key, name);
|
|
74
|
+
}),
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
read: source => texts.get(placeOf(source.id)) ?? null,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
exports.sourcesFromFiles = sourcesFromFiles;
|
|
81
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/assemble/files.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;EASE;AACF,4CAAiD;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;;YAC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CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;oBACtB,qFAAqF;oBACrF,MAAM,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAA;oBACvF,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,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;AA3BY,QAAA,gBAAgB,oBA2B5B"}
|
|
@@ -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';
|