podlite 0.0.83 → 0.0.84

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 (168) hide show
  1. package/CHANGELOG.podlite +90 -0
  2. package/esm/assemble/async.d.ts +31 -0
  3. package/esm/assemble/async.js +113 -0
  4. package/esm/assemble/async.js.map +1 -0
  5. package/esm/assemble/files.d.ts +2 -0
  6. package/esm/assemble/files.js +77 -0
  7. package/esm/assemble/files.js.map +1 -0
  8. package/esm/assemble/index.d.ts +59 -0
  9. package/esm/assemble/index.js +1003 -0
  10. package/esm/assemble/index.js.map +1 -0
  11. package/esm/cli.js +151 -26
  12. package/esm/cli.js.map +1 -1
  13. package/esm/file-format.d.ts +3 -0
  14. package/esm/file-format.js +53 -0
  15. package/esm/file-format.js.map +1 -0
  16. package/esm/index.d.ts +4 -0
  17. package/esm/index.js +3 -0
  18. package/esm/index.js.map +1 -1
  19. package/esm/lint/grammar/scan.d.ts +1 -1
  20. package/esm/lint/grammar/scan.js +2 -1
  21. package/esm/lint/grammar/scan.js.map +1 -1
  22. package/esm/lint/index.d.ts +1 -1
  23. package/esm/lint/index.js +3 -3
  24. package/esm/lint/index.js.map +1 -1
  25. package/esm/lint/loader.js +5 -4
  26. package/esm/lint/loader.js.map +1 -1
  27. package/esm/lint/mute.js +2 -1
  28. package/esm/lint/mute.js.map +1 -1
  29. package/esm/lint/rules/include-resolves.d.ts +6 -0
  30. package/esm/lint/rules/include-resolves.js +89 -0
  31. package/esm/lint/rules/include-resolves.js.map +1 -0
  32. package/esm/lint/rules/index.js +2 -0
  33. package/esm/lint/rules/index.js.map +1 -1
  34. package/esm/lint/rules/table-shape.js +7 -1
  35. package/esm/lint/rules/table-shape.js.map +1 -1
  36. package/esm/lint/types.d.ts +6 -1
  37. package/esm/lint/types.js.map +1 -1
  38. package/esm/query-blocks.d.ts +6 -0
  39. package/esm/query-blocks.js +127 -0
  40. package/esm/query-blocks.js.map +1 -0
  41. package/esm/query.d.ts +2 -0
  42. package/esm/query.js +233 -26
  43. package/esm/query.js.map +1 -1
  44. package/esm/reader.d.ts +15 -0
  45. package/esm/reader.js +119 -0
  46. package/esm/reader.js.map +1 -0
  47. package/esm/refresh-tocs.d.ts +2 -0
  48. package/esm/refresh-tocs.js +52 -0
  49. package/esm/refresh-tocs.js.map +1 -0
  50. package/esm/resolve-includes.d.ts +27 -1
  51. package/esm/resolve-includes.js +80 -40
  52. package/esm/resolve-includes.js.map +1 -1
  53. package/esm/test/collect.d.ts +16 -0
  54. package/esm/test/collect.js +368 -0
  55. package/esm/test/collect.js.map +1 -0
  56. package/esm/test/documents.d.ts +47 -0
  57. package/esm/test/documents.js +211 -0
  58. package/esm/test/documents.js.map +1 -0
  59. package/esm/test/evaluate.d.ts +41 -0
  60. package/esm/test/evaluate.js +104 -0
  61. package/esm/test/evaluate.js.map +1 -0
  62. package/esm/test/formatters/json.d.ts +2 -0
  63. package/esm/test/formatters/json.js +11 -0
  64. package/esm/test/formatters/json.js.map +1 -0
  65. package/esm/test/formatters/text.d.ts +2 -0
  66. package/esm/test/formatters/text.js +104 -0
  67. package/esm/test/formatters/text.js.map +1 -0
  68. package/esm/test/index.d.ts +11 -0
  69. package/esm/test/index.js +19 -0
  70. package/esm/test/index.js.map +1 -0
  71. package/esm/test/resources.d.ts +5 -0
  72. package/esm/test/resources.js +45 -0
  73. package/esm/test/resources.js.map +1 -0
  74. package/esm/test/run.d.ts +52 -0
  75. package/esm/test/run.js +91 -0
  76. package/esm/test/run.js.map +1 -0
  77. package/esm/test/sources.d.ts +48 -0
  78. package/esm/test/sources.js +162 -0
  79. package/esm/test/sources.js.map +1 -0
  80. package/esm/test/types.d.ts +104 -0
  81. package/esm/test/types.js +3 -0
  82. package/esm/test/types.js.map +1 -0
  83. package/esm/version.d.ts +1 -1
  84. package/esm/version.js +1 -1
  85. package/lib/assemble/async.d.ts +31 -0
  86. package/lib/assemble/async.js +118 -0
  87. package/lib/assemble/async.js.map +1 -0
  88. package/lib/assemble/files.d.ts +2 -0
  89. package/lib/assemble/files.js +81 -0
  90. package/lib/assemble/files.js.map +1 -0
  91. package/lib/assemble/index.d.ts +59 -0
  92. package/lib/assemble/index.js +1013 -0
  93. package/lib/assemble/index.js.map +1 -0
  94. package/lib/cli.js +149 -24
  95. package/lib/cli.js.map +1 -1
  96. package/lib/file-format.d.ts +3 -0
  97. package/lib/file-format.js +58 -0
  98. package/lib/file-format.js.map +1 -0
  99. package/lib/index.d.ts +4 -0
  100. package/lib/index.js +22 -1
  101. package/lib/index.js.map +1 -1
  102. package/lib/lint/grammar/scan.d.ts +1 -1
  103. package/lib/lint/grammar/scan.js +2 -1
  104. package/lib/lint/grammar/scan.js.map +1 -1
  105. package/lib/lint/index.d.ts +1 -1
  106. package/lib/lint/index.js +3 -3
  107. package/lib/lint/index.js.map +1 -1
  108. package/lib/lint/loader.js +5 -4
  109. package/lib/lint/loader.js.map +1 -1
  110. package/lib/lint/mute.js +2 -1
  111. package/lib/lint/mute.js.map +1 -1
  112. package/lib/lint/rules/include-resolves.d.ts +6 -0
  113. package/lib/lint/rules/include-resolves.js +92 -0
  114. package/lib/lint/rules/include-resolves.js.map +1 -0
  115. package/lib/lint/rules/index.js +2 -0
  116. package/lib/lint/rules/index.js.map +1 -1
  117. package/lib/lint/rules/table-shape.js +7 -1
  118. package/lib/lint/rules/table-shape.js.map +1 -1
  119. package/lib/lint/types.d.ts +6 -1
  120. package/lib/lint/types.js.map +1 -1
  121. package/lib/query-blocks.d.ts +6 -0
  122. package/lib/query-blocks.js +136 -0
  123. package/lib/query-blocks.js.map +1 -0
  124. package/lib/query.d.ts +2 -0
  125. package/lib/query.js +232 -25
  126. package/lib/query.js.map +1 -1
  127. package/lib/reader.d.ts +15 -0
  128. package/lib/reader.js +124 -0
  129. package/lib/reader.js.map +1 -0
  130. package/lib/refresh-tocs.d.ts +2 -0
  131. package/lib/refresh-tocs.js +56 -0
  132. package/lib/refresh-tocs.js.map +1 -0
  133. package/lib/resolve-includes.d.ts +27 -1
  134. package/lib/resolve-includes.js +84 -40
  135. package/lib/resolve-includes.js.map +1 -1
  136. package/lib/test/collect.d.ts +16 -0
  137. package/lib/test/collect.js +374 -0
  138. package/lib/test/collect.js.map +1 -0
  139. package/lib/test/documents.d.ts +47 -0
  140. package/lib/test/documents.js +250 -0
  141. package/lib/test/documents.js.map +1 -0
  142. package/lib/test/evaluate.d.ts +41 -0
  143. package/lib/test/evaluate.js +142 -0
  144. package/lib/test/evaluate.js.map +1 -0
  145. package/lib/test/formatters/json.d.ts +2 -0
  146. package/lib/test/formatters/json.js +15 -0
  147. package/lib/test/formatters/json.js.map +1 -0
  148. package/lib/test/formatters/text.d.ts +2 -0
  149. package/lib/test/formatters/text.js +141 -0
  150. package/lib/test/formatters/text.js.map +1 -0
  151. package/lib/test/index.d.ts +11 -0
  152. package/lib/test/index.js +31 -0
  153. package/lib/test/index.js.map +1 -0
  154. package/lib/test/resources.d.ts +5 -0
  155. package/lib/test/resources.js +83 -0
  156. package/lib/test/resources.js.map +1 -0
  157. package/lib/test/run.d.ts +52 -0
  158. package/lib/test/run.js +95 -0
  159. package/lib/test/run.js.map +1 -0
  160. package/lib/test/sources.d.ts +48 -0
  161. package/lib/test/sources.js +200 -0
  162. package/lib/test/sources.js.map +1 -0
  163. package/lib/test/types.d.ts +104 -0
  164. package/lib/test/types.js +8 -0
  165. package/lib/test/types.js.map +1 -0
  166. package/lib/version.d.ts +1 -1
  167. package/lib/version.js +1 -1
  168. 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;;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,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,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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,59 @@
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
+ };
53
+ export declare const isWarning: (problem: IncludeProblem) => boolean;
54
+ export declare const externalMessage: (sources: Source[], written: string) => string;
55
+ export declare const silently: <T>(work: () => T) => T;
56
+ export declare const assembleIncludes: (tree: any, opts: AssembleOptions) => any;
57
+ export { sourcesFromFiles } from './files';
58
+ export { assembleAsync, createSourceStore } from './async';
59
+ export type { AsyncSources, SourceStore, AssembleAsyncOptions } from './async';