@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.
- package/CHANGELOG.podlite +40 -0
- package/esm/catalogue.d.ts +17 -0
- package/esm/catalogue.js +156 -0
- package/esm/catalogue.js.map +1 -0
- package/esm/images-plugin.js +3 -1
- package/esm/images-plugin.js.map +1 -1
- package/esm/include-resolve-plugin.d.ts +16 -1
- package/esm/include-resolve-plugin.js +238 -50
- package/esm/include-resolve-plugin.js.map +1 -1
- package/esm/links-plugin.d.ts +9 -1
- package/esm/links-plugin.js +144 -58
- package/esm/links-plugin.js.map +1 -1
- package/esm/node-utils.d.ts +5 -3
- package/esm/node-utils.js +81 -24
- package/esm/node-utils.js.map +1 -1
- package/esm/pubdate-plugin.js +7 -5
- package/esm/pubdate-plugin.js.map +1 -1
- package/esm/react-plugin.js +9 -1
- package/esm/react-plugin.js.map +1 -1
- package/esm/reading.d.ts +5 -0
- package/esm/reading.js +34 -0
- package/esm/reading.js.map +1 -0
- package/esm/record.d.ts +2 -0
- package/esm/record.js +1 -0
- package/esm/record.js.map +1 -1
- package/esm/site-data-plugin.d.ts +1 -0
- package/esm/site-data-plugin.js +12 -1
- package/esm/site-data-plugin.js.map +1 -1
- package/esm/source.d.ts +19 -0
- package/esm/source.js +85 -0
- package/esm/source.js.map +1 -0
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/catalogue.d.ts +17 -0
- package/lib/catalogue.js +197 -0
- package/lib/images-plugin.js +3 -1
- package/lib/include-resolve-plugin.d.ts +16 -1
- package/lib/include-resolve-plugin.js +273 -49
- package/lib/links-plugin.d.ts +9 -1
- package/lib/links-plugin.js +177 -56
- package/lib/node-utils.d.ts +5 -3
- package/lib/node-utils.js +96 -37
- package/lib/pubdate-plugin.js +7 -5
- package/lib/react-plugin.js +9 -1
- package/lib/reading.d.ts +5 -0
- package/lib/reading.js +38 -0
- package/lib/record.d.ts +2 -0
- package/lib/record.js +6 -1
- package/lib/site-data-plugin.d.ts +1 -0
- package/lib/site-data-plugin.js +13 -1
- package/lib/source.d.ts +19 -0
- package/lib/source.js +94 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pubdate-plugin.js","sourceRoot":"","sources":["../src/pubdate-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,SAAS,EAAE,WAAW,EAAW,MAAM,iBAAiB,CAAA;AACtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"pubdate-plugin.js","sourceRoot":"","sources":["../src/pubdate-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,SAAS,EAAE,WAAW,EAAW,MAAM,iBAAiB,CAAA;AACtG,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAMrC,MAAM,UAAU,WAAW,CAAC,IAAmB;IAC7C,IAAI,QAAQ,GAAoB,EAAE,CAAA;IAClC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;IACrB,MAAM,YAAY,GAAG,KAAK,CAAC,EAAE;QAC3B,mBAAmB;QACnB,uDAAuD;QACvD,8BAA8B;QAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,CAAA;QAE7E,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5C,OAAO,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zC,IAAI,QAAQ,GAAG,iBAAiB;aAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;aAC1B,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;aACxB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;QAE1C,IAAI,KAAK,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QAC9G,MAAM,wBAAwB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;QACjD,MAAM,UAAU,GAAG,CAAC,GAAG,wBAAwB,EAAE,GAAG,KAAK,CAAC,CAAA;QAC1D,OAAO,UAAU,CAAA;IACnB,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/esm/react-plugin.js
CHANGED
|
@@ -3,6 +3,7 @@ import { COMPONENTS_LIB } from './constants.js';
|
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import { getPathToOpen } from './node-utils.js';
|
|
5
5
|
import { makeAstFromSrc } from './shared.js';
|
|
6
|
+
import { nodeOrigin } from './source.js';
|
|
6
7
|
const plugin = () => {
|
|
7
8
|
const componensMap = new Map();
|
|
8
9
|
const processedNodes = new WeakSet();
|
|
@@ -39,7 +40,9 @@ export default {}
|
|
|
39
40
|
const { component, source } = (importMatchResult || {
|
|
40
41
|
groups: { component: undefined, source: undefined },
|
|
41
42
|
}).groups;
|
|
42
|
-
|
|
43
|
+
// an import an include brought is found from the file it was written in
|
|
44
|
+
const from = nodeOrigin(node)?.file ?? file;
|
|
45
|
+
const { path } = source.match(/^\.{0,2}\//) ? getPathToOpen(source, from) : { path: source };
|
|
43
46
|
// save absolute Component path and Component name
|
|
44
47
|
const notDefaultImport = component.match(/{(.*)}/);
|
|
45
48
|
if (notDefaultImport) {
|
|
@@ -68,6 +71,11 @@ export default {}
|
|
|
68
71
|
return;
|
|
69
72
|
},
|
|
70
73
|
React: (node, ctx, interator) => {
|
|
74
|
+
// the reader of the record has read the body in its place; a body it left
|
|
75
|
+
// as text, its lines not found in the file, is read here as before
|
|
76
|
+
const raw = Array.isArray(node.content) && node.content.every(part => part && part.type === 'verbatim');
|
|
77
|
+
if (!raw)
|
|
78
|
+
return { ...node, content: interator(node.content, ctx) };
|
|
71
79
|
const text = getTextContentFromNode(node);
|
|
72
80
|
const doc = makeAstFromSrc(text);
|
|
73
81
|
return { ...node, content: [interator(doc.content, ctx)] };
|
package/esm/react-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-plugin.js","sourceRoot":"","sources":["../src/react-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAA;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAG5C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"react-plugin.js","sourceRoot":"","sources":["../src/react-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAA4B,MAAM,iBAAiB,CAAA;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc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,CAAC,QAAQ,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;gBACjE,CAAC;gBACD,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACnC,CAAC;YACD,iCAAiC;YACjC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;YAC/B,IAAI,MAAM,EAAE,CAAC;gBACX,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;YAC/C,CAAC;YACD,IAAI,MAAM,EAAE,CAAC;gBACX,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;YAC/C,CAAC;YAED,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,CAAA;QACpC,CAAC,CAAC,CAAA;QACF,OAAO,GAAG,CAAA;IACZ,CAAC,CAAA;IACD,0CAA0C;IAC1C,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/esm/reading.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ScopedBlock } from '@podlite/schema';
|
|
2
|
+
export declare const isReadBody: (block: ScopedBlock) => boolean;
|
|
3
|
+
export declare const readRecordText: (text: string, file: string, config?: import("@podlite/schema").ConfigScope, extras?: Pick<import("@podlite/schema").parseOpt, "recognition" | "diagnostics"> & {
|
|
4
|
+
format?: import("podlite").ReadFormat;
|
|
5
|
+
}) => import("@podlite/schema").RootBlock | import("@podlite/schema").AstTree;
|
package/esm/reading.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { podlite, readerFor } from 'podlite';
|
|
2
|
+
/*
|
|
3
|
+
=begin pod :kind<module>
|
|
4
|
+
|
|
5
|
+
=head2 reading
|
|
6
|
+
|
|
7
|
+
How the publisher reads a record, and the text an include brings into it.
|
|
8
|
+
|
|
9
|
+
=end pod
|
|
10
|
+
*/
|
|
11
|
+
/*
|
|
12
|
+
=begin pod :kind<export>
|
|
13
|
+
|
|
14
|
+
=head2 isReadBody
|
|
15
|
+
|
|
16
|
+
Whether the raw body of a block is Podlite text to be read in its place: the
|
|
17
|
+
body of C<=React> is.
|
|
18
|
+
|
|
19
|
+
=end pod
|
|
20
|
+
*/
|
|
21
|
+
export const isReadBody = (block) => block.name === 'React';
|
|
22
|
+
/*
|
|
23
|
+
=begin pod :kind<export>
|
|
24
|
+
|
|
25
|
+
=head2 readRecordText
|
|
26
|
+
|
|
27
|
+
Reads a text as a record of that file name is read, with the body of C<=React>
|
|
28
|
+
read in its place. An include is given the same reader, so the body of
|
|
29
|
+
C<=React> in an included file is read as well.
|
|
30
|
+
|
|
31
|
+
=end pod
|
|
32
|
+
*/
|
|
33
|
+
export const readRecordText = readerFor(podlite({ importPlugins: true }), { body: isReadBody });
|
|
34
|
+
//# sourceMappingURL=reading.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reading.js","sourceRoot":"","sources":["../src/reading.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAE5C;;;;;;;;EAQE;AAEF;;;;;;;;;EASE;AACF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAkB,EAAW,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAA;AAEjF;;;;;;;;;;EAUE;AACF,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAA"}
|
package/esm/record.d.ts
CHANGED
package/esm/record.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { recordSource, recordOrigin, isParsedTree, nodeOrigin } from './source.js';
|
|
1
2
|
// The record's `type` cannot answer this: it says whether the address was declared
|
|
2
3
|
// or built, and it is the letter the short url is made of. Only the author can call
|
|
3
4
|
// a document a page, with :type('page'); a document with no date is not published.
|
package/esm/record.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA0B/E,mFAAmF;AACnF,oFAAoF;AACpF,mFAAmF;AACnF,iFAAiF;AACjF,qFAAqF;AACrF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,MAAoE,EAAW,EAAE,CACvG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { publishRecord } from './record';
|
|
2
2
|
import { PodliteWebPlugin } from './plugins';
|
|
3
3
|
export declare function buildStylesContent(theme: string | undefined, globalStylesPath: string | undefined): string;
|
|
4
|
+
export declare const SITE_DATA_DOCUMENT = "PLUGIN_DATA";
|
|
4
5
|
export interface SiteInfo {
|
|
5
6
|
redirects: {
|
|
6
7
|
source: string;
|
package/esm/site-data-plugin.js
CHANGED
|
@@ -14,6 +14,17 @@ export function buildStylesContent(theme, globalStylesPath) {
|
|
|
14
14
|
imports.push(`@import '@Styles/default';`);
|
|
15
15
|
return imports.map(i => `\n ${i}\n `).join('');
|
|
16
16
|
}
|
|
17
|
+
/*
|
|
18
|
+
=begin pod :kind<export>
|
|
19
|
+
|
|
20
|
+
=head2 SITE_DATA_DOCUMENT
|
|
21
|
+
|
|
22
|
+
The name an include finds the document this plugin makes by. The document is
|
|
23
|
+
made after the other plugins ran, so the include plugin waits for it.
|
|
24
|
+
|
|
25
|
+
=end pod
|
|
26
|
+
*/
|
|
27
|
+
export const SITE_DATA_DOCUMENT = 'PLUGIN_DATA';
|
|
17
28
|
const plugin = ({ public_path = PUBLIC_PATH, indexFilePath = `${POSTS_PATH}/${INDEX_PATH}`, built_path = BUILT_PATH, site_url, }) => {
|
|
18
29
|
let indexPage;
|
|
19
30
|
let redirects = [];
|
|
@@ -117,7 +128,7 @@ const plugin = ({ public_path = PUBLIC_PATH, indexFilePath = `${POSTS_PATH}/${IN
|
|
|
117
128
|
const articlesJSON = JSON.stringify(recs.filter(i => i.publishUrl).filter(isEntry));
|
|
118
129
|
const storeFile = `
|
|
119
130
|
=begin pod
|
|
120
|
-
=for NAME :id
|
|
131
|
+
=for NAME :id<${SITE_DATA_DOCUMENT}>
|
|
121
132
|
SITE DATA
|
|
122
133
|
=begin data :id<articles>
|
|
123
134
|
${articlesJSON}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-data-plugin.js","sourceRoot":"","sources":["../src/site-data-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC7E,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE,OAAO,EAAiB,MAAM,UAAU,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAoB,MAAM,cAAc,CAAA;AAC5D,OAAO,MAAM,MAAM,MAAM,CAAA;AAEzB,MAAM,UAAU,kBAAkB,CAAC,KAAyB,EAAE,gBAAoC;IAChG,MAAM,OAAO,GAAa,EAAE,CAAA;IA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AA;QACJ,CAAC,CAAC,CAAA;QAEF,gCAAgC;QAEhC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC,CAAA;QAC1D,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CACZ,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EACrB,IAAI,EACJ,CAAC,CACF,CACF,CAAA;YACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,aAAa,CAAC,CAAA;QACtE,CAAC;QACD,SAAS,CAAC,UAAU,GAAG,GAAG,CAAA;QAE1B,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;QAEnF,MAAM,SAAS,GAAG;;iBAEL,kBAAkB;;;EAGjC,YAAY;;;CAGb,CAAA;QACG,MAAM,QAAQ,GAAG,WAAW,CAAC,kCAAkC,EAAE,SAAS,CAAC,CAAA;QAC3E,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAA;QAClC,OAAO,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC5B,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/esm/source.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MimeTypes } from './node-utils';
|
|
2
|
+
export type RecordSource = {
|
|
3
|
+
readonly file: string;
|
|
4
|
+
readonly mime?: MimeTypes;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const sourceKey: unique symbol;
|
|
8
|
+
export declare const originKey: unique symbol;
|
|
9
|
+
export declare const withSource: <T extends object>(record: T, file: string, text: string, mime?: MimeTypes) => T;
|
|
10
|
+
export declare const withOrigin: <T extends object>(record: T, from: object) => T;
|
|
11
|
+
export declare const recordSource: (record: object) => RecordSource | undefined;
|
|
12
|
+
export declare const recordOrigin: (record: object) => RecordSource | undefined;
|
|
13
|
+
export declare const isParsedTree: (record: object) => boolean;
|
|
14
|
+
export declare const nodeOriginKey: unique symbol;
|
|
15
|
+
export type NodeOrigin = {
|
|
16
|
+
readonly file: string;
|
|
17
|
+
readonly via?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const nodeOrigin: (node: object) => NodeOrigin | undefined;
|
package/esm/source.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Symbol.for shares the key between copies of the package in one process, so the
|
|
2
|
+
// shape of the value is fixed by the number in the name
|
|
3
|
+
export const sourceKey = Symbol.for('@podlite/publisher:source/1');
|
|
4
|
+
export const originKey = Symbol.for('@podlite/publisher:origin/1');
|
|
5
|
+
// the keys stay out of the record type: a declaration that spreads a record would have to name them
|
|
6
|
+
const held = (record) => record;
|
|
7
|
+
const hold = (file, text, mime, tree) => {
|
|
8
|
+
const source = { file, ...(mime ? { mime } : {}), text, parsed: (node) => node === tree };
|
|
9
|
+
Object.defineProperty(source, 'text', { enumerable: false });
|
|
10
|
+
Object.defineProperty(source, 'parsed', { enumerable: false });
|
|
11
|
+
return Object.freeze(source);
|
|
12
|
+
};
|
|
13
|
+
export const withSource = (record, file, text, mime) => ({
|
|
14
|
+
...record,
|
|
15
|
+
[sourceKey]: hold(file, text, mime, held(record).node),
|
|
16
|
+
});
|
|
17
|
+
export const withOrigin = (record, from) => {
|
|
18
|
+
const origin = held(from)[originKey] ?? held(from)[sourceKey];
|
|
19
|
+
return origin ? { ...record, [originKey]: origin } : record;
|
|
20
|
+
};
|
|
21
|
+
/*
|
|
22
|
+
=begin pod :kind<export>
|
|
23
|
+
|
|
24
|
+
=head2 recordSource
|
|
25
|
+
|
|
26
|
+
The source of a record that was read from a text, and of every copy of it. A
|
|
27
|
+
record a plugin built out of parts of another one has no source of its own; see
|
|
28
|
+
C<recordOrigin>. A plugin that replaces the tree of a record leaves the source
|
|
29
|
+
in place, so having a source does not mean the tree still matches it; see
|
|
30
|
+
C<isParsedTree>.
|
|
31
|
+
|
|
32
|
+
=end pod
|
|
33
|
+
*/
|
|
34
|
+
export const recordSource = (record) => held(record)[sourceKey];
|
|
35
|
+
/*
|
|
36
|
+
=begin pod :kind<export>
|
|
37
|
+
|
|
38
|
+
=head2 recordOrigin
|
|
39
|
+
|
|
40
|
+
The reading a record comes from: its own source, or the source of the record it
|
|
41
|
+
was cut from. Several records cut from one file share one origin, and that
|
|
42
|
+
origin holds the text of the whole file, not of the record.
|
|
43
|
+
|
|
44
|
+
=end pod
|
|
45
|
+
*/
|
|
46
|
+
export const recordOrigin = (record) => held(record)[originKey] ?? held(record)[sourceKey];
|
|
47
|
+
/*
|
|
48
|
+
=begin pod :kind<export>
|
|
49
|
+
|
|
50
|
+
=head2 isParsedTree
|
|
51
|
+
|
|
52
|
+
Whether the tree of the record is the very object its source was parsed into.
|
|
53
|
+
A tree changed in place still answers yes.
|
|
54
|
+
|
|
55
|
+
=end pod
|
|
56
|
+
*/
|
|
57
|
+
export const isParsedTree = (record) => held(record)[sourceKey]?.parsed(held(record).node) ?? false;
|
|
58
|
+
/*
|
|
59
|
+
=begin pod :kind<export>
|
|
60
|
+
|
|
61
|
+
=head2 nodeOriginKey
|
|
62
|
+
|
|
63
|
+
The key a node holds its C<NodeOrigin> under. Every copy made by spreading the
|
|
64
|
+
node keeps it, and JSON does not carry it. Read it with C<nodeOrigin>.
|
|
65
|
+
|
|
66
|
+
=end pod
|
|
67
|
+
*/
|
|
68
|
+
export const nodeOriginKey = Symbol.for('@podlite/publisher:node-origin/1');
|
|
69
|
+
/*
|
|
70
|
+
=begin pod :kind<export>
|
|
71
|
+
|
|
72
|
+
=head2 nodeOrigin
|
|
73
|
+
|
|
74
|
+
The file a node of a record was written in, when the include plugin knows it:
|
|
75
|
+
the paths written in the node are resolved from that file. A node without one
|
|
76
|
+
was written in the file of the record.
|
|
77
|
+
|
|
78
|
+
=end pod
|
|
79
|
+
*/
|
|
80
|
+
const isNodeOrigin = (value) => typeof value === 'object' && value !== null && 'file' in value && typeof value.file === 'string';
|
|
81
|
+
export const nodeOrigin = (node) => {
|
|
82
|
+
const mark = Reflect.get(node, nodeOriginKey);
|
|
83
|
+
return isNodeOrigin(mark) ? mark : undefined;
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAyBA,iFAAiF;AACjF,wDAAwD;AACxD,MAAM,CAAC,MAAM,SAAS,GAAkB,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;AACjF,MAAM,CAAC,MAAM,SAAS,GAAkB,MAAM,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;AAQjF,oGAAoG;AACpG,MAAM,IAAI,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,CAAA;AAEhD,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,IAA2B,EAAE,IAAa,EAAc,EAAE;IAClG,MAAM,MAAM,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,IAAa,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,EAAE,CAAA;IAClG,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAA;IAC5D,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,UAAU,E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AK,CAAA;AAEpH;;;;;;;;;EASE;AACF,MAAM,CAAC,MAAM,aAAa,GAAkB,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;AAkB1F;;;;;;;;;;EAUE;AACF,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuB,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAA;AAElG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAA0B,EAAE;IACjE,MAAM,IAAI,GAAY,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;IACtD,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AAC9C,CAAC,CAAA"}
|
package/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.53";
|
package/esm/version.js
CHANGED
|
@@ -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;
|
package/lib/catalogue.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.catalogueOf = exports.idOfFile = void 0;
|
|
40
|
+
/*
|
|
41
|
+
=begin pod :kind<module>
|
|
42
|
+
|
|
43
|
+
=head2 catalogue
|
|
44
|
+
|
|
45
|
+
This module holds the texts an include on a site can bring. They are the
|
|
46
|
+
records the site read before the plugins ran, and the documents plugins make
|
|
47
|
+
later in the chain. Several records read from one file are one source. The
|
|
48
|
+
current version of a document and its permanent address are one source. A page
|
|
49
|
+
cut out of a file is that file.
|
|
50
|
+
|
|
51
|
+
The id of a source is the absolute path of the file it was read from. A
|
|
52
|
+
document a plugin makes is known by the name it was made under, resolved the
|
|
53
|
+
same way.
|
|
54
|
+
|
|
55
|
+
A path in a C<file:> source is resolved from the directory of the file it is
|
|
56
|
+
written in. A mask is matched against the files of the catalogue. A C<doc:>
|
|
57
|
+
source is the document whose C<=NAME> or C<=TITLE> answers to the name. When two
|
|
58
|
+
sources answer to a name, it resolves to neither, and the answer names both.
|
|
59
|
+
When no document answers to a name yet and the host says it will be made later,
|
|
60
|
+
an include of it is left for a later pass.
|
|
61
|
+
|
|
62
|
+
=end pod
|
|
63
|
+
*/
|
|
64
|
+
const path = __importStar(require("path"));
|
|
65
|
+
const gray_matter_1 = __importDefault(require("gray-matter"));
|
|
66
|
+
const schema_1 = require("@podlite/schema");
|
|
67
|
+
const podlite_1 = require("podlite");
|
|
68
|
+
const node_utils_1 = require("./node-utils");
|
|
69
|
+
const source_1 = require("./source");
|
|
70
|
+
const isMask = (written) => /[*?]/.test(written);
|
|
71
|
+
const isUnder = (file, dir) => {
|
|
72
|
+
const relative = path.relative(dir, file);
|
|
73
|
+
return relative !== '' && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
74
|
+
};
|
|
75
|
+
/*
|
|
76
|
+
=begin pod :kind<export>
|
|
77
|
+
|
|
78
|
+
=head2 idOfFile
|
|
79
|
+
|
|
80
|
+
The id of a file as a source: its absolute path, from the working directory.
|
|
81
|
+
|
|
82
|
+
=end pod
|
|
83
|
+
*/
|
|
84
|
+
const idOfFile = (file) => path.resolve(file);
|
|
85
|
+
exports.idOfFile = idOfFile;
|
|
86
|
+
// a Markdown text is read without its front matter, as the record was
|
|
87
|
+
const readable = (source) => (0, node_utils_1.getParserTypeforFile)(source.file, source.mime) === node_utils_1.PARSER_TYPES.MARKDOWN ? (0, gray_matter_1.default)(source.text).content : source.text;
|
|
88
|
+
/*
|
|
89
|
+
=begin pod :kind<export>
|
|
90
|
+
|
|
91
|
+
=head2 catalogueOf
|
|
92
|
+
|
|
93
|
+
A catalogue over the readings of the records given. Records added later bring
|
|
94
|
+
the readings it does not hold; a reading it holds already is not taken twice.
|
|
95
|
+
|
|
96
|
+
=end pod
|
|
97
|
+
*/
|
|
98
|
+
const catalogueOf = (records = [], options = {}) => {
|
|
99
|
+
const entries = new Map();
|
|
100
|
+
const held = new WeakSet();
|
|
101
|
+
const bounds = (options.bounds ?? []).map(dir => path.resolve(dir));
|
|
102
|
+
let names;
|
|
103
|
+
const add = (list) => {
|
|
104
|
+
for (const record of list) {
|
|
105
|
+
const source = (0, source_1.recordOrigin)(record);
|
|
106
|
+
if (!source || held.has(source))
|
|
107
|
+
continue;
|
|
108
|
+
held.add(source);
|
|
109
|
+
const id = (0, exports.idOfFile)(source.file);
|
|
110
|
+
if (entries.has(id))
|
|
111
|
+
continue;
|
|
112
|
+
const own = (0, source_1.recordSource)(record) === source && (0, source_1.isParsedTree)(record);
|
|
113
|
+
const entry = { id, source, tree: own ? record.node : undefined };
|
|
114
|
+
entries.set(id, entry);
|
|
115
|
+
if (names)
|
|
116
|
+
index(names, entry);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const index = (into, entry) => {
|
|
120
|
+
const tree = entry.tree ?? options.parse?.(readable(entry.source), entry.source.file);
|
|
121
|
+
if (!tree)
|
|
122
|
+
return;
|
|
123
|
+
const node = Array.isArray(tree) ? (0, schema_1.mkRootBlock)({}, tree) : tree;
|
|
124
|
+
for (const name of new Set((0, schema_1.getDocIDs)({ file: entry.source.file, node }))) {
|
|
125
|
+
into.set(name, [...(into.get(name) ?? []), entry.id]);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
// the names each document answers to, built on the first question
|
|
129
|
+
const namesOf = () => {
|
|
130
|
+
if (names)
|
|
131
|
+
return names;
|
|
132
|
+
names = new Map();
|
|
133
|
+
for (const entry of entries.values())
|
|
134
|
+
index(names, entry);
|
|
135
|
+
return names;
|
|
136
|
+
};
|
|
137
|
+
// the directory a path written in that place does not lead out of
|
|
138
|
+
const boundOf = (dir) => bounds.filter(bound => dir === bound || isUnder(dir, bound)).sort((a, b) => b.length - a.length)[0];
|
|
139
|
+
const sourceAt = (id, name) => {
|
|
140
|
+
const entry = entries.get(id);
|
|
141
|
+
const format = entry?.source.mime ? (0, podlite_1.formatOfType)(entry.source.mime) : (0, podlite_1.formatOfFile)(id);
|
|
142
|
+
return { id, name, context: path.dirname(id), ...(format ? { format } : {}) };
|
|
143
|
+
};
|
|
144
|
+
const locateFile = (written, context, plain) => {
|
|
145
|
+
const dir = path.resolve(String(context ?? ''));
|
|
146
|
+
const bound = boundOf(dir);
|
|
147
|
+
const inside = (id) => bound === undefined || isUnder(id, bound);
|
|
148
|
+
if (plain || !isMask(written)) {
|
|
149
|
+
const id = path.resolve(dir, written);
|
|
150
|
+
if (!inside(id))
|
|
151
|
+
return {
|
|
152
|
+
masked: false,
|
|
153
|
+
sources: [],
|
|
154
|
+
failed: `the path leads out of ${path.relative(process.cwd(), bound) || '.'}`,
|
|
155
|
+
};
|
|
156
|
+
return { masked: false, sources: [sourceAt(id, written)] };
|
|
157
|
+
}
|
|
158
|
+
const pattern = path.resolve(dir, written);
|
|
159
|
+
const found = [...entries.keys()].filter(id => inside(id) && (0, schema_1.filePathMatches)(id, pattern)).sort();
|
|
160
|
+
return {
|
|
161
|
+
masked: true,
|
|
162
|
+
// named the way the mask is written, for the selection to match it back
|
|
163
|
+
sources: found.map(id => sourceAt(id, path.isAbsolute(written) ? id : path.relative(dir, id))),
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
const locateDoc = (written) => {
|
|
167
|
+
const ids = namesOf().get(written) ?? [];
|
|
168
|
+
if (!ids.length && options.waits?.(written))
|
|
169
|
+
return undefined;
|
|
170
|
+
if (ids.length > 1) {
|
|
171
|
+
const files = ids.map(id => entries.get(id).source.file).join(', ');
|
|
172
|
+
return { masked: false, sources: [], failed: `more than one document is named ${written}: ${files}` };
|
|
173
|
+
}
|
|
174
|
+
return { masked: false, sources: ids.map(id => ({ ...sourceAt(id, written) })) };
|
|
175
|
+
};
|
|
176
|
+
const sources = {
|
|
177
|
+
schemes: ['file', 'doc'],
|
|
178
|
+
locate: (written, context, plain, _at, scheme) => scheme === 'doc' ? locateDoc(written) : locateFile(written, context, plain),
|
|
179
|
+
read: source => {
|
|
180
|
+
const entry = entries.get(source.id);
|
|
181
|
+
return entry ? readable(entry.source) : null;
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
const idOf = (record) => {
|
|
185
|
+
const source = (0, source_1.recordOrigin)(record);
|
|
186
|
+
return source ? (0, exports.idOfFile)(source.file) : undefined;
|
|
187
|
+
};
|
|
188
|
+
const named = (name) => namesOf().get(name) ?? [];
|
|
189
|
+
const textOf = (id) => {
|
|
190
|
+
const entry = entries.get(id);
|
|
191
|
+
return entry ? readable(entry.source) : undefined;
|
|
192
|
+
};
|
|
193
|
+
add(records);
|
|
194
|
+
return { sources, add, idOf, named, textOf };
|
|
195
|
+
};
|
|
196
|
+
exports.catalogueOf = catalogueOf;
|
|
197
|
+
//# sourceMappingURL=catalogue.js.map
|
package/lib/images-plugin.js
CHANGED
|
@@ -42,6 +42,7 @@ const constants_1 = require("./constants");
|
|
|
42
42
|
const path_1 = __importDefault(require("path"));
|
|
43
43
|
const fs = __importStar(require("fs"));
|
|
44
44
|
const node_utils_1 = require("./node-utils");
|
|
45
|
+
const source_1 = require("./source");
|
|
45
46
|
const ORIENTATION_TAG = 0x0112;
|
|
46
47
|
const readOrientation = (file) => {
|
|
47
48
|
let bytes;
|
|
@@ -122,7 +123,8 @@ export default {}
|
|
|
122
123
|
':image': node => {
|
|
123
124
|
// process copy files to assets
|
|
124
125
|
// '../assets/'
|
|
125
|
-
|
|
126
|
+
// a picture an include brought is found from the file it was written in
|
|
127
|
+
const { path } = (0, node_utils_1.getPathToOpen)(node.src, (0, source_1.nodeOrigin)(node)?.file ?? file);
|
|
126
128
|
const { name, ext, dir } = path_1.default.parse(path);
|
|
127
129
|
const variable_name = 'i' + path.split('/').slice(1).join('_').replace(/\W+/g, '_').toLowerCase();
|
|
128
130
|
const newFileName = `${variable_name}${ext}`;
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
import { publishRecord } from './record';
|
|
1
2
|
import { PodliteWebPlugin } from './plugins';
|
|
2
|
-
|
|
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;
|