@podlite/publisher 0.0.39 → 0.0.41
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 +4 -0
- package/esm/state-version-plugin.d.ts +1 -1
- package/esm/state-version-plugin.js +30 -3
- package/esm/state-version-plugin.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/state-version-plugin.d.ts +1 -1
- package/lib/state-version-plugin.js +32 -2
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.podlite
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
=head1 Upcoming
|
|
4
4
|
|
|
5
|
+
=head1 0.0.41
|
|
6
|
+
|
|
7
|
+
=item C<stateVersionPlugin> accepts optional C<indexFilePath>; C<globalStyles>, favicon and image files contribute to C<stateVersion>
|
|
8
|
+
|
|
5
9
|
=head1 0.0.39
|
|
6
10
|
|
|
7
11
|
=item shape the heading name into a url fragment when building an index anchor
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import * as CRC32 from 'crc-32';
|
|
2
|
-
import
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import pathFs from 'path';
|
|
4
|
+
import { getFromTree, getTextContentFromNode, makeAttrs } from '@podlite/schema';
|
|
3
5
|
import { version } from './version';
|
|
4
|
-
const plugin = (appVersion) => {
|
|
6
|
+
const plugin = (appVersion, indexFilePath) => {
|
|
5
7
|
const outCtx = {};
|
|
6
8
|
let crc_sum = '';
|
|
9
|
+
const records = [];
|
|
7
10
|
const onExit = ctx => {
|
|
8
|
-
outCtx.stateVersion =
|
|
11
|
+
outCtx.stateVersion =
|
|
12
|
+
CRC32.str(crc_sum + getAssetsVersion(ctx)) + '+v' + version + (appVersion ? '+app' + appVersion : '');
|
|
9
13
|
return { ...ctx, ...outCtx };
|
|
10
14
|
};
|
|
11
15
|
const getStateVersion = (allREcords) => {
|
|
@@ -13,8 +17,31 @@ const plugin = (appVersion) => {
|
|
|
13
17
|
return prev + CRC32.str(getTextContentFromNode(current.node));
|
|
14
18
|
}, '');
|
|
15
19
|
};
|
|
20
|
+
const getAssetPaths = (ctx) => {
|
|
21
|
+
const paths = Object.keys(ctx.imagesMap || {});
|
|
22
|
+
const indexPage = indexFilePath ? records.find(item => item.file === indexFilePath) : undefined;
|
|
23
|
+
if (indexPage) {
|
|
24
|
+
const [pod] = getFromTree(indexPage.node, 'pod');
|
|
25
|
+
const attr = makeAttrs(pod, {});
|
|
26
|
+
const indexDir = pathFs.dirname(indexFilePath);
|
|
27
|
+
for (const name of ['globalStyles', 'favicon']) {
|
|
28
|
+
const value = attr.getFirstValue(name);
|
|
29
|
+
if (value) {
|
|
30
|
+
paths.push(pathFs.join(indexDir, value));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return paths;
|
|
35
|
+
};
|
|
36
|
+
const getAssetsVersion = (ctx) => {
|
|
37
|
+
return getAssetPaths(ctx).reduce((prev, path) => {
|
|
38
|
+
// a missing file contributes its path, so adding the file later moves the sum
|
|
39
|
+
return prev + (fs.existsSync(path) ? CRC32.buf(new Uint8Array(fs.readFileSync(path))) : CRC32.str(path));
|
|
40
|
+
}, '');
|
|
41
|
+
};
|
|
16
42
|
const onProcess = (recs) => {
|
|
17
43
|
crc_sum += getStateVersion(recs);
|
|
44
|
+
records.push(...recs);
|
|
18
45
|
return recs;
|
|
19
46
|
};
|
|
20
47
|
return [onProcess, onExit];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-version-plugin.js","sourceRoot":"","sources":["../src/state-version-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"state-version-plugin.js","sourceRoot":"","sources":["../src/state-version-plugin.ts"],"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,CAAC,IAAI,CAAC,CAAA;QAChC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;QACrB,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
|
package/esm/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.41";
|
package/esm/version.js
CHANGED
|
@@ -32,15 +32,22 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
const CRC32 = __importStar(require("crc-32"));
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path_1 = __importDefault(require("path"));
|
|
37
42
|
const schema_1 = require("@podlite/schema");
|
|
38
43
|
const version_1 = require("./version");
|
|
39
|
-
const plugin = (appVersion) => {
|
|
44
|
+
const plugin = (appVersion, indexFilePath) => {
|
|
40
45
|
const outCtx = {};
|
|
41
46
|
let crc_sum = '';
|
|
47
|
+
const records = [];
|
|
42
48
|
const onExit = ctx => {
|
|
43
|
-
outCtx.stateVersion =
|
|
49
|
+
outCtx.stateVersion =
|
|
50
|
+
CRC32.str(crc_sum + getAssetsVersion(ctx)) + '+v' + version_1.version + (appVersion ? '+app' + appVersion : '');
|
|
44
51
|
return { ...ctx, ...outCtx };
|
|
45
52
|
};
|
|
46
53
|
const getStateVersion = (allREcords) => {
|
|
@@ -48,8 +55,31 @@ const plugin = (appVersion) => {
|
|
|
48
55
|
return prev + CRC32.str((0, schema_1.getTextContentFromNode)(current.node));
|
|
49
56
|
}, '');
|
|
50
57
|
};
|
|
58
|
+
const getAssetPaths = (ctx) => {
|
|
59
|
+
const paths = Object.keys(ctx.imagesMap || {});
|
|
60
|
+
const indexPage = indexFilePath ? records.find(item => item.file === indexFilePath) : undefined;
|
|
61
|
+
if (indexPage) {
|
|
62
|
+
const [pod] = (0, schema_1.getFromTree)(indexPage.node, 'pod');
|
|
63
|
+
const attr = (0, schema_1.makeAttrs)(pod, {});
|
|
64
|
+
const indexDir = path_1.default.dirname(indexFilePath);
|
|
65
|
+
for (const name of ['globalStyles', 'favicon']) {
|
|
66
|
+
const value = attr.getFirstValue(name);
|
|
67
|
+
if (value) {
|
|
68
|
+
paths.push(path_1.default.join(indexDir, value));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return paths;
|
|
73
|
+
};
|
|
74
|
+
const getAssetsVersion = (ctx) => {
|
|
75
|
+
return getAssetPaths(ctx).reduce((prev, path) => {
|
|
76
|
+
// a missing file contributes its path, so adding the file later moves the sum
|
|
77
|
+
return prev + (fs.existsSync(path) ? CRC32.buf(new Uint8Array(fs.readFileSync(path))) : CRC32.str(path));
|
|
78
|
+
}, '');
|
|
79
|
+
};
|
|
51
80
|
const onProcess = (recs) => {
|
|
52
81
|
crc_sum += getStateVersion(recs);
|
|
82
|
+
records.push(...recs);
|
|
53
83
|
return recs;
|
|
54
84
|
};
|
|
55
85
|
return [onProcess, onExit];
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.41";
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podlite/publisher",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"description": "Publishing toolkit for Podlite — transform documents to HTML, generate sites",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
"transform"
|
|
67
67
|
],
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@podlite/markdown": "0.0.
|
|
70
|
-
"@podlite/schema": "0.0.
|
|
69
|
+
"@podlite/markdown": "0.0.53",
|
|
70
|
+
"@podlite/schema": "0.0.60",
|
|
71
71
|
"crc-32": "^1.2.2",
|
|
72
72
|
"gray-matter": "^4.0.3",
|
|
73
73
|
"iso_9": "^1.0.4",
|
|
74
74
|
"newbase60": "^1.3.1",
|
|
75
|
-
"podlite": "0.0.
|
|
75
|
+
"podlite": "0.0.73"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@types/node": "^17.0.7",
|