@podlite/publisher 0.0.2

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 (74) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +22 -0
  3. package/README.md +41 -0
  4. package/esm/breadcrumb-plugin.d.ts +3 -0
  5. package/esm/breadcrumb-plugin.js +34 -0
  6. package/esm/breadcrumb-plugin.js.map +1 -0
  7. package/esm/constants.d.ts +27 -0
  8. package/esm/constants.js +28 -0
  9. package/esm/constants.js.map +1 -0
  10. package/esm/images-plugin.d.ts +3 -0
  11. package/esm/images-plugin.js +60 -0
  12. package/esm/images-plugin.js.map +1 -0
  13. package/esm/index.d.ts +4 -0
  14. package/esm/index.js +5 -0
  15. package/esm/index.js.map +1 -0
  16. package/esm/links-plugin.d.ts +3 -0
  17. package/esm/links-plugin.js +87 -0
  18. package/esm/links-plugin.js.map +1 -0
  19. package/esm/node-utils.d.ts +50 -0
  20. package/esm/node-utils.js +376 -0
  21. package/esm/node-utils.js.map +1 -0
  22. package/esm/plugins.d.ts +138 -0
  23. package/esm/plugins.js +147 -0
  24. package/esm/plugins.js.map +1 -0
  25. package/esm/pubdate-plugin.d.ts +9 -0
  26. package/esm/pubdate-plugin.js +137 -0
  27. package/esm/pubdate-plugin.js.map +1 -0
  28. package/esm/react-plugin.d.ts +3 -0
  29. package/esm/react-plugin.js +109 -0
  30. package/esm/react-plugin.js.map +1 -0
  31. package/esm/shared.d.ts +36 -0
  32. package/esm/shared.js +157 -0
  33. package/esm/shared.js.map +1 -0
  34. package/esm/site-data-plugin.d.ts +25 -0
  35. package/esm/site-data-plugin.js +135 -0
  36. package/esm/site-data-plugin.js.map +1 -0
  37. package/esm/state-version-plugin.d.ts +3 -0
  38. package/esm/state-version-plugin.js +23 -0
  39. package/esm/state-version-plugin.js.map +1 -0
  40. package/esm/template-plugin.d.ts +3 -0
  41. package/esm/template-plugin.js +10 -0
  42. package/esm/template-plugin.js.map +1 -0
  43. package/esm/terms-index-plugin.d.ts +5 -0
  44. package/esm/terms-index-plugin.js +108 -0
  45. package/esm/terms-index-plugin.js.map +1 -0
  46. package/lib/breadcrumb-plugin.d.ts +3 -0
  47. package/lib/breadcrumb-plugin.js +36 -0
  48. package/lib/constants.d.ts +27 -0
  49. package/lib/constants.js +34 -0
  50. package/lib/images-plugin.d.ts +3 -0
  51. package/lib/images-plugin.js +84 -0
  52. package/lib/index.d.ts +4 -0
  53. package/lib/index.js +17 -0
  54. package/lib/links-plugin.d.ts +3 -0
  55. package/lib/links-plugin.js +89 -0
  56. package/lib/node-utils.d.ts +50 -0
  57. package/lib/node-utils.js +412 -0
  58. package/lib/plugins.d.ts +138 -0
  59. package/lib/plugins.js +153 -0
  60. package/lib/pubdate-plugin.d.ts +9 -0
  61. package/lib/pubdate-plugin.js +143 -0
  62. package/lib/react-plugin.d.ts +3 -0
  63. package/lib/react-plugin.js +130 -0
  64. package/lib/shared.d.ts +36 -0
  65. package/lib/shared.js +169 -0
  66. package/lib/site-data-plugin.d.ts +25 -0
  67. package/lib/site-data-plugin.js +159 -0
  68. package/lib/state-version-plugin.d.ts +3 -0
  69. package/lib/state-version-plugin.js +44 -0
  70. package/lib/template-plugin.d.ts +3 -0
  71. package/lib/template-plugin.js +12 -0
  72. package/lib/terms-index-plugin.d.ts +5 -0
  73. package/lib/terms-index-plugin.js +129 -0
  74. package/package.json +52 -0
@@ -0,0 +1,412 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.streamWriteArray = exports.parseSources = exports.processFile = exports.getPublishAttributes = exports.getDocumentAttributes = exports.parseFile = exports.getParserTypeforFile = exports.parseFiles = exports.convertFileLinksToUrl = exports.makeLinksMap = exports.getPathToOpen = void 0;
26
+ const schema_1 = require("@podlite/schema");
27
+ const fs = __importStar(require("fs"));
28
+ const path_1 = __importDefault(require("path"));
29
+ const shared_1 = require("./shared");
30
+ const markdown_1 = require("@podlite/markdown");
31
+ const podlite_1 = require("podlite");
32
+ const gray_matter_1 = __importDefault(require("gray-matter"));
33
+ const glob = require('glob');
34
+ const getPathToOpen = (filepath, parentDocPath) => {
35
+ const isRemoteReg = new RegExp(/^(https?|ftp):/);
36
+ const isRemote = isRemoteReg.test(filepath);
37
+ if (isRemote) {
38
+ return { isRemote, path: filepath };
39
+ }
40
+ const path = require('path');
41
+ const docDirPath = path.dirname(parentDocPath);
42
+ return {
43
+ isRemote,
44
+ path: path.isAbsolute(filepath) ? filepath : path.normalize(path.join(docDirPath, filepath)),
45
+ };
46
+ };
47
+ exports.getPathToOpen = getPathToOpen;
48
+ const makeLinksMap = (records) => {
49
+ const linksMap = {
50
+ ...Object.fromEntries(records.map(({ publishUrl = '', file }) => [(0, exports.getPathToOpen)(file, './').path, publishUrl])),
51
+ };
52
+ return linksMap;
53
+ };
54
+ exports.makeLinksMap = makeLinksMap;
55
+ const convertFileLinksToUrl = (records, additinalMap = {}) => {
56
+ const linksMap = { ...additinalMap, ...(0, exports.makeLinksMap)(records) };
57
+ const processed = records.map(item => {
58
+ const converter = (0, schema_1.makeInterator)({
59
+ 'L<>': (node, ctx, interator) => {
60
+ const { content, meta } = node;
61
+ const link = meta ? meta : (0, schema_1.getTextContentFromNode)(content);
62
+ const r = link.match(/file:\s*(?<path>(.+))\s*$/);
63
+ const convertFileToUrl = filePath => {
64
+ const { isRemote, path } = (0, exports.getPathToOpen)(filePath, item.file);
65
+ return isRemote ? null : linksMap[path];
66
+ };
67
+ const newLink = r?.groups?.path ? convertFileToUrl(r.groups.path) : link;
68
+ const newContent = {
69
+ type: 'text',
70
+ value: newLink,
71
+ };
72
+ const updated = meta ? { meta: newLink } : { content: newContent };
73
+ return { ...node, ...updated };
74
+ },
75
+ });
76
+ const res = converter(item.node, {});
77
+ // process images inside description
78
+ let extra = {};
79
+ // process item description header and footer
80
+ const { footer, header, description } = item;
81
+ if (description) {
82
+ extra.description = converter(description, {});
83
+ }
84
+ if (footer) {
85
+ extra.footer = converter(footer, {});
86
+ }
87
+ if (header) {
88
+ extra.header = converter(header, {});
89
+ }
90
+ return { ...item, node: res, ...extra };
91
+ });
92
+ return processed;
93
+ };
94
+ exports.convertFileLinksToUrl = convertFileLinksToUrl;
95
+ function parseFiles(path) {
96
+ let count = 0;
97
+ const allFiles = glob
98
+ .sync(path)
99
+ .map((f) => {
100
+ count++;
101
+ const testData = fs.readFileSync(f).toString();
102
+ const asAst = (0, shared_1.makeAstFromSrc)(testData);
103
+ // now check if tree contains block with :pubdate attribute
104
+ // '* :pubdate'
105
+ if (!(0, shared_1.isExistsPubdate)(asAst)) {
106
+ return;
107
+ }
108
+ // extract notes
109
+ const notes = (0, schema_1.getFromTree)(asAst, 'para')
110
+ .filter(n => (0, schema_1.makeAttrs)(n, {}).exists('pubdate'))
111
+ .map((n) => {
112
+ const a_pubdate = (0, schema_1.makeAttrs)(n, {}).getFirstValue('pubdate');
113
+ // Due to cover some cases whan new Date fail on safari, i.e.
114
+ // new Date("2022-05-07 10:00:00").getFullYear() -> NaN
115
+ // convert to ISO 8601 "2022-05-07 10:00:00" -> "2022-05-07T10:00:00"
116
+ const pubdate = a_pubdate.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/)
117
+ ? a_pubdate.replace(' ', 'T')
118
+ : a_pubdate;
119
+ return {
120
+ pubdate,
121
+ type: 'note',
122
+ node: n,
123
+ description: n,
124
+ file: f,
125
+ };
126
+ });
127
+ const articles = (0, shared_1.getAllArticles)([asAst]).map(({ ...all }) => ({ ...all, file: f }));
128
+ // note get full posts
129
+ const pages = (0, schema_1.getFromTree)(asAst, 'pod')
130
+ .filter(n => (0, schema_1.makeAttrs)(n, {}).exists('pubdate'))
131
+ .map((n) => {
132
+ const a_pubdate = (0, schema_1.makeAttrs)(n, {}).getFirstValue('pubdate');
133
+ // Due to cover some cases whan new Date fail on safari, i.e.
134
+ // new Date("2022-05-07 10:00:00").getFullYear() -> NaN
135
+ // convert to ISO 8601 "2022-05-07 10:00:00" -> "2022-05-07T10:00:00"
136
+ const pubdate = a_pubdate.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/)
137
+ ? a_pubdate.replace(' ', 'T')
138
+ : a_pubdate;
139
+ return {
140
+ pubdate,
141
+ type: 'page',
142
+ node: n,
143
+ file: f,
144
+ };
145
+ });
146
+ console.warn(` pages: ${pages.length} articles: ${articles.length}, notes: ${notes.length} from ${f}`);
147
+ return [...pages, ...articles, ...notes].map(item => {
148
+ return { ...item, file: f };
149
+ });
150
+ })
151
+ .flat()
152
+ .filter(Boolean);
153
+ return allFiles;
154
+ }
155
+ exports.parseFiles = parseFiles;
156
+ const PARSER_TYPES = {
157
+ MARKDOWN: 'markdown',
158
+ PODLITE: 'podlite',
159
+ DEFAULT: 'default',
160
+ ERROR: 'error',
161
+ };
162
+ const MIME_TYPES_EXTENSIONS = {
163
+ 'text/podlite': ['.podlite', '.pod6'],
164
+ 'text/markdown': ['.md', '.markdown'],
165
+ 'text/plain': ['.txt'],
166
+ 'audio/mpeg': ['.mp3'],
167
+ };
168
+ const PARSER_TYPE_MIME_TYPES = {
169
+ [PARSER_TYPES.PODLITE]: ['text/podlite'],
170
+ [PARSER_TYPES.MARKDOWN]: ['text/markdown'],
171
+ [PARSER_TYPES.DEFAULT]: ['text/plain'],
172
+ [PARSER_TYPES.ERROR]: ['audio/mpeg'],
173
+ };
174
+ function getParserTypeforFile(filePath, mime) {
175
+ // get parser type using PARSER_TYPE_MIME_TYPES
176
+ if (mime) {
177
+ for (const [key, value] of Object.entries(PARSER_TYPE_MIME_TYPES)) {
178
+ if (value.includes(mime)) {
179
+ return key;
180
+ }
181
+ }
182
+ // if not found return default TODO: possible change to error
183
+ console.warn(`Mime type ${mime} not found, using default parser`);
184
+ return PARSER_TYPES.DEFAULT;
185
+ }
186
+ const ext = path_1.default.extname(filePath).toLowerCase();
187
+ const parserTypeMap = {
188
+ '.md': PARSER_TYPES.MARKDOWN,
189
+ '.markdown': PARSER_TYPES.MARKDOWN,
190
+ '.podlite': PARSER_TYPES.PODLITE,
191
+ '.rakudoc': PARSER_TYPES.PODLITE,
192
+ '.pod6': PARSER_TYPES.PODLITE,
193
+ };
194
+ return parserTypeMap[ext] || PARSER_TYPES.DEFAULT;
195
+ }
196
+ exports.getParserTypeforFile = getParserTypeforFile;
197
+ function parseFile(filePath, fileContent, mime) {
198
+ // check extension of file and parse it deepnds on mime type
199
+ const parser_type = getParserTypeforFile(filePath, mime);
200
+ const typeToParserMap = {
201
+ [PARSER_TYPES.PODLITE]: (src) => {
202
+ const podlite_processor = (0, podlite_1.podlite)({ importPlugins: true }).use({});
203
+ const tree = podlite_processor.parse(src, { skipChain: 0, podMode: 1 });
204
+ return podlite_processor.toAstResult(tree).interator;
205
+ },
206
+ //@ts-ignore TODO: fix this
207
+ [PARSER_TYPES.MARKDOWN]: (src) => {
208
+ const { content } = (0, gray_matter_1.default)(src);
209
+ return (0, markdown_1.parseMd)(content);
210
+ },
211
+ [PARSER_TYPES.DEFAULT]: (src) => {
212
+ const podlite_processor = (0, podlite_1.podlite)({ importPlugins: true }).use({});
213
+ const tree = podlite_processor.parse(src, { skipChain: 0, podMode: 0 });
214
+ return podlite_processor.toAstResult(tree).interator;
215
+ },
216
+ };
217
+ const src = fileContent || fs.readFileSync(filePath).toString();
218
+ return typeToParserMap[parser_type](src);
219
+ }
220
+ exports.parseFile = parseFile;
221
+ function getDocumentAttributes(node) {
222
+ // filling title
223
+ let title = '';
224
+ let description = '';
225
+ let subtitle;
226
+ let author;
227
+ let footer = '';
228
+ let header = null;
229
+ (0, schema_1.makeInterator)({
230
+ NAME: (node, ctx, interator) => {
231
+ title = (0, schema_1.getTextContentFromNode)(node);
232
+ },
233
+ TITLE: (node, ctx, interator) => {
234
+ title = (0, schema_1.getTextContentFromNode)(node);
235
+ },
236
+ DESCRIPTION: (node, ctx, interator) => {
237
+ description = node.content;
238
+ },
239
+ SUBTITLE: (node, ctx, interator) => {
240
+ subtitle = (0, schema_1.getTextContentFromNode)(node);
241
+ },
242
+ AUTHOR: (node, ctx, interator) => {
243
+ const attr = (0, schema_1.makeAttrs)(node, ctx);
244
+ author = Object.fromEntries(Object.keys(attr.asHash()).map(k => [k, attr.getFirstValue(k)]));
245
+ },
246
+ FOOTER: (node, ctx, interator) => {
247
+ footer = node.content;
248
+ },
249
+ HEADER: (node, ctx, interator) => {
250
+ header = node.content;
251
+ },
252
+ })(node, {});
253
+ const props = {
254
+ title,
255
+ description,
256
+ subtitle,
257
+ author,
258
+ footer,
259
+ puburl: undefined,
260
+ pubdate: undefined,
261
+ ...(header && { header }),
262
+ };
263
+ const [podnode] = (0, schema_1.getFromTree)(node.content, 'pod');
264
+ if (podnode) {
265
+ // prepare publishUrl
266
+ const conf = (0, schema_1.makeAttrs)(podnode, {});
267
+ props.puburl = conf.exists('puburl')
268
+ ? conf.getFirstValue('puburl')
269
+ : // check old publishUrl attribute
270
+ conf.exists('publishUrl')
271
+ ? conf.getFirstValue('publishUrl')
272
+ : undefined;
273
+ const a_pubdate = conf.getFirstValue('pubdate');
274
+ // Due to cover some cases whan new Date fail on safari, i.e.
275
+ // new Date("2022-05-07 10:00:00").getFullYear() -> NaN
276
+ // convert to ISO 8601 "2022-05-07 10:00:00" -> "2022-05-07T10:00:00"
277
+ props.pubdate = a_pubdate?.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/)
278
+ ? a_pubdate.replace(' ', 'T')
279
+ : a_pubdate;
280
+ }
281
+ return props;
282
+ }
283
+ exports.getDocumentAttributes = getDocumentAttributes;
284
+ function getPublishAttributes(node) {
285
+ // filling title
286
+ let title = '';
287
+ let description = '';
288
+ let subtitle;
289
+ let author;
290
+ let footer = '';
291
+ (0, schema_1.makeInterator)({
292
+ NAME: (node, ctx, interator) => {
293
+ title = (0, schema_1.getTextContentFromNode)(node);
294
+ },
295
+ TITLE: (node, ctx, interator) => {
296
+ title = (0, schema_1.getTextContentFromNode)(node);
297
+ },
298
+ DESCRIPTION: (node, ctx, interator) => {
299
+ description = node.content;
300
+ },
301
+ SUBTITLE: (node, ctx, interator) => {
302
+ subtitle = (0, schema_1.getTextContentFromNode)(node);
303
+ },
304
+ AUTHOR: (node, ctx, interator) => {
305
+ const attr = (0, schema_1.makeAttrs)(node, ctx);
306
+ author = Object.fromEntries(Object.keys(attr.asHash()).map(k => [k, attr.getFirstValue(k)]));
307
+ },
308
+ FOOTER: (node, ctx, interator) => {
309
+ footer = node.content;
310
+ },
311
+ })(node, {});
312
+ const props = {
313
+ title,
314
+ description,
315
+ subtitle,
316
+ author,
317
+ footer,
318
+ puburl: undefined,
319
+ pubdate: undefined,
320
+ };
321
+ const podnode = node;
322
+ if (podnode) {
323
+ // prepare publishUrl
324
+ const conf = (0, schema_1.makeAttrs)(podnode, {});
325
+ props.puburl = conf.exists('puburl')
326
+ ? conf.getFirstValue('puburl')
327
+ : // check old publishUrl attribute
328
+ conf.exists('publishUrl')
329
+ ? conf.getFirstValue('publishUrl')
330
+ : undefined;
331
+ const a_pubdate = conf.getFirstValue('pubdate');
332
+ // Due to cover some cases whan new Date fail on safari, i.e.
333
+ // new Date("2022-05-07 10:00:00").getFullYear() -> NaN
334
+ // convert to ISO 8601 "2022-05-07 10:00:00" -> "2022-05-07T10:00:00"
335
+ props.pubdate = a_pubdate?.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/)
336
+ ? a_pubdate.replace(' ', 'T')
337
+ : a_pubdate;
338
+ }
339
+ return props;
340
+ }
341
+ exports.getPublishAttributes = getPublishAttributes;
342
+ function processFile(f, content, mime) {
343
+ const podlite_document = parseFile(f, content, mime);
344
+ // now extract some extra meta inforamtion, like pubdate, puburl
345
+ const attr = ((f, node) => {
346
+ if (getParserTypeforFile(f, mime) === PARSER_TYPES.MARKDOWN) {
347
+ // try to extract from markdown front matter
348
+ const { data } = (0, gray_matter_1.default)(content || fs.readFileSync(f).toString());
349
+ return data;
350
+ }
351
+ else {
352
+ return getDocumentAttributes(podlite_document);
353
+ }
354
+ })(f, podlite_document);
355
+ // prepare attributes
356
+ const { title, description, subtitle, author, footer, puburl, pubdate, header } = attr;
357
+ return {
358
+ type: 'page',
359
+ title,
360
+ description,
361
+ subtitle,
362
+ author,
363
+ ...(header && { header }),
364
+ footer,
365
+ publishUrl: puburl,
366
+ pubdate,
367
+ file: f,
368
+ sources: [],
369
+ node: podlite_document,
370
+ };
371
+ }
372
+ exports.processFile = processFile;
373
+ function parseSources(path) {
374
+ let count = 0;
375
+ const allFiles = glob
376
+ .sync(path)
377
+ .map((f) => {
378
+ count++;
379
+ return processFile(f);
380
+ })
381
+ .flat()
382
+ .filter(Boolean);
383
+ return allFiles;
384
+ }
385
+ exports.parseSources = parseSources;
386
+ function streamWriteArray(array, outputPath) {
387
+ return new Promise((resolve, reject) => {
388
+ const writeStream = fs.createWriteStream(outputPath);
389
+ writeStream.write('[');
390
+ const writeItem = index => {
391
+ if (index >= array.length) {
392
+ writeStream.write(']');
393
+ writeStream.end();
394
+ resolve(1);
395
+ return;
396
+ }
397
+ const item = array[index];
398
+ const json = JSON.stringify(item);
399
+ const data = index === 0 ? json : ',' + json;
400
+ if (writeStream.write(data)) {
401
+ setImmediate(() => writeItem(index + 1));
402
+ }
403
+ else {
404
+ writeStream.once('drain', () => writeItem(index + 1));
405
+ }
406
+ };
407
+ writeItem(0);
408
+ writeStream.on('error', reject);
409
+ });
410
+ }
411
+ exports.streamWriteArray = streamWriteArray;
412
+ //# sourceMappingURL=node-utils.js.map
@@ -0,0 +1,138 @@
1
+ import { PodliteDocument, PodNode } from '@podlite/schema';
2
+ export declare type pubRecord = {
3
+ type: string;
4
+ pubdate: string;
5
+ node: PodNode;
6
+ description?: PodNode;
7
+ file: string;
8
+ };
9
+ export declare type publishRecord = pubRecord & {
10
+ title: string | null;
11
+ publishUrl: string;
12
+ sources: string[];
13
+ node: PodliteDocument;
14
+ pubdate: string | undefined;
15
+ template?: publishRecord | null;
16
+ header?: PodNode | null;
17
+ footer?: PodNode | null;
18
+ subtitle?: string | null;
19
+ pluginsData?: {
20
+ [name: string]: any;
21
+ };
22
+ template_file?: string;
23
+ };
24
+ export interface PodliteWebPluginContext {
25
+ [name: string]: any;
26
+ }
27
+ export declare type PodliteWebPlugin = [
28
+ (rects: publishRecord[]) => publishRecord[],
29
+ (ctx: PodliteWebPluginContext) => {
30
+ [name: string]: any;
31
+ }
32
+ ];
33
+ export interface PluginConfig {
34
+ name?: string;
35
+ plugin: PodliteWebPlugin;
36
+ includePatterns?: string | string[];
37
+ excludePatterns?: string | string[];
38
+ }
39
+ /**
40
+ =begin pod
41
+ =head1 filterFiles
42
+
43
+ This function filters an array of file names based on provided include and exclude patterns. It first converts the includePatterns and excludePatterns arguments into arrays, if they aren't already. The function then filters through the files array, including a file if it matches any of the include patterns (or if no include patterns are provided) and excluding it if it matches any of the exclude patterns. The function returns a new array containing the files that match the include criteria and do not match the exclude criteria.
44
+
45
+ =head2 Parameters
46
+
47
+ =begin item
48
+ B<files>
49
+
50
+ An array of strings, each representing a file name to be filtered.
51
+ =end item
52
+ =begin item
53
+ B<includePatterns>
54
+
55
+ Optional. A string or an array of strings representing the pattern(s) files must match to be included. If not provided, all files are considered to match the include criteria.
56
+ =end item
57
+ =begin item
58
+ B<excludePatterns>
59
+
60
+ Optional. A string or an array of strings representing the pattern(s) files must match to be excluded. If not provided, no files are excluded based on patterns.
61
+ =end item
62
+
63
+ =head2 Returns
64
+
65
+ An array of strings, each representing a file name that matched the include criteria and did not match the exclude criteria.
66
+
67
+ =end pod
68
+ */
69
+ export declare function filterFiles(files: string[], includePatterns?: string | string[], excludePatterns?: string | string[]): string[];
70
+ /**
71
+ =begin pod
72
+ =head1 processPlugin
73
+
74
+ The function `processPlugin` processes a collection of publishing records based on a given
75
+ plugin configuration. It filters the items to determine which ones match specified inclusion
76
+ and exclusion patterns. Items that match are processed by the provided plugin function, while
77
+ items that do not match are passed through unchanged. Finally, it returns a tuple containing
78
+ the processed items and the result of calling the `onClose` function with a context object.
79
+
80
+ =head2 Parameters
81
+
82
+ =begin item
83
+ B<pluginConf>
84
+
85
+ An object of type `PluginConfig` that provides configuration for the plugin, including
86
+ the plugin processing function, inclusion patterns, and exclusion patterns.
87
+ =end item
88
+ =begin item
89
+ B<items>
90
+
91
+ An array of `publishRecord` objects representing the items to be processed by the plugin.
92
+ =end item
93
+
94
+ =head2 Returns
95
+
96
+ A tuple where the first element is an array of `publishRecord` objects representing
97
+ the processed and unprocessed items, and the second element is an object resulting
98
+ from calling the plugin's `onClose` function with a context object. This object may
99
+ contain arbitrary data based on the plugin's implementation.
100
+
101
+ =end pod
102
+ */
103
+ export declare const processPlugin: (pluginConf: PluginConfig, items: publishRecord[], ctx?: {
104
+ [name: string]: any;
105
+ }) => [publishRecord[], {
106
+ [name: string]: any;
107
+ }];
108
+ /**
109
+ =begin pod
110
+ =head1 composePlugins
111
+
112
+ This function takes an array of PluginConfig objects and combines them into a single PluginConfig.
113
+ It does this by sequentially processing each PluginConfig in the array with the next,
114
+ effectively composing their behaviors into a single plugin configuration.
115
+ Each PluginConfig is expected to modify a shared state and context. The composition
116
+ is achieved by chaining the plugin functions within each PluginConfig, so that the
117
+ output (both state and context) of one plugin function becomes the input to the next.
118
+
119
+ =head2 Parameters
120
+
121
+ =begin item
122
+ B<configs>
123
+
124
+ An array of PluginConfig objects. Each PluginConfig is an object that represents
125
+ configuration for a plugin, which includes a plugin processing function and
126
+ potentially other settings.
127
+ =end item
128
+
129
+ =head2 Returns
130
+
131
+ Returns a single PluginConfig object that represents the composed configuration
132
+ of all the PluginConfig objects passed in the 'configs' array. This resulting
133
+ PluginConfig can be used to process items with the combined logic of all the
134
+ plugins defined in the input array.
135
+
136
+ =end pod
137
+ */
138
+ export declare const composePlugins: (configs: PluginConfig[], inintCtx?: {}) => PluginConfig;