mvw-search-index 2.3.5 → 2.3.7
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/README.md +1 -1
- package/js/cli.js +38 -7
- package/js/cli.js.map +1 -1
- package/js/index.d.ts +3 -3
- package/js/index.js +59 -27
- package/js/index.js.map +1 -1
- package/package.json +11 -12
- package/vitest.config.ts +8 -0
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ This serves the content from [./docs](docs), featuring a simple static site with
|
|
|
109
109
|
|
|
110
110
|
## Releases
|
|
111
111
|
|
|
112
|
-
- **2.3.2**: Dependency updates.
|
|
112
|
+
- **2.3.2 – 2.3.6**: Dependency updates.
|
|
113
113
|
- **2.3.0**: Added attribute support for metadata extraction.
|
|
114
114
|
- **2.2.10 - 2.2.16**: Dependency updates.
|
|
115
115
|
- **2.2.9**: Removed `vinyl`; introduced demo application.
|
package/js/cli.js
CHANGED
|
@@ -1,16 +1,47 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
3
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
37
|
+
const commander_1 = require("commander");
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const index_1 = require("./index");
|
|
7
40
|
commander_1.program
|
|
8
41
|
.version("2.2.8")
|
|
9
42
|
.arguments("<glob> <dest> [bodySelector]")
|
|
10
|
-
.action(
|
|
11
|
-
index_1.SearchIndex.createFromGlob(glob, bodySelector,
|
|
12
|
-
return fs.writeFileSync(dest || "./index.json", JSON.stringify(index));
|
|
13
|
-
});
|
|
43
|
+
.action((glob, dest, bodySelector) => {
|
|
44
|
+
index_1.SearchIndex.createFromGlob(glob, bodySelector, (index) => fs.writeFileSync(dest || "./index.json", JSON.stringify(index)));
|
|
14
45
|
})
|
|
15
46
|
.parse(process.argv);
|
|
16
47
|
//# sourceMappingURL=cli.js.map
|
package/js/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../ts/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../ts/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAAoC;AACpC,uCAAyB;AAEzB,mCAAsC;AAEtC,mBAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,SAAS,CAAC,8BAA8B,CAAC;KACzC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE;IACnC,mBAAW,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CACvD,EAAE,CAAC,aAAa,CAAC,IAAI,IAAI,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAChE,CAAC;AACJ,CAAC,CAAC;KACD,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/js/index.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import * as lunr from "lunr";
|
|
|
2
2
|
export declare interface IResultStore {
|
|
3
3
|
[key: string]: {
|
|
4
4
|
title: string;
|
|
5
|
-
description: string;
|
|
5
|
+
description: string | undefined;
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
export declare interface IFileInformation {
|
|
9
9
|
body: string;
|
|
10
|
-
description: string;
|
|
10
|
+
description: string | undefined;
|
|
11
11
|
href: string;
|
|
12
|
-
keywords: string;
|
|
12
|
+
keywords: string | undefined;
|
|
13
13
|
title: string;
|
|
14
14
|
}
|
|
15
15
|
export declare interface ISearchIndexResult {
|
package/js/index.js
CHANGED
|
@@ -1,22 +1,56 @@
|
|
|
1
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
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.SearchIndex = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
37
|
+
const cheerio = __importStar(require("cheerio"));
|
|
38
|
+
const glob_1 = require("glob");
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const lunr = __importStar(require("lunr"));
|
|
41
|
+
class SearchIndex {
|
|
42
|
+
store;
|
|
43
|
+
index;
|
|
44
|
+
constructor(files) {
|
|
11
45
|
this.store = {};
|
|
12
|
-
|
|
46
|
+
const builder = new lunr.Builder();
|
|
13
47
|
builder.field("title");
|
|
14
48
|
builder.field("keywords");
|
|
15
49
|
builder.field("description");
|
|
16
50
|
builder.field("body");
|
|
17
51
|
builder.ref("href");
|
|
18
|
-
files.forEach(
|
|
19
|
-
|
|
52
|
+
files.forEach((info) => {
|
|
53
|
+
this.store[info.href] = {
|
|
20
54
|
description: info.description,
|
|
21
55
|
title: info.title,
|
|
22
56
|
};
|
|
@@ -24,14 +58,13 @@ var SearchIndex = /** @class */ (function () {
|
|
|
24
58
|
}, builder);
|
|
25
59
|
this.index = builder.build();
|
|
26
60
|
}
|
|
27
|
-
|
|
61
|
+
static createFromInfo(files) {
|
|
28
62
|
return new SearchIndex(files).getResult();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var infos = files.map(function (file) {
|
|
63
|
+
}
|
|
64
|
+
static createFromHtml(files, bodySelector = "body") {
|
|
65
|
+
const infos = files.map((file) => {
|
|
33
66
|
console.info(file.relative);
|
|
34
|
-
|
|
67
|
+
const dom = cheerio.load(file.contents.toString());
|
|
35
68
|
return {
|
|
36
69
|
body: dom(bodySelector || "body").text().replace(/\s\s+/g, " "),
|
|
37
70
|
href: file.relative,
|
|
@@ -41,27 +74,26 @@ var SearchIndex = /** @class */ (function () {
|
|
|
41
74
|
};
|
|
42
75
|
});
|
|
43
76
|
return SearchIndex.createFromInfo(infos);
|
|
44
|
-
}
|
|
45
|
-
|
|
77
|
+
}
|
|
78
|
+
static createFromGlob(pattern, bodySelector, cb) {
|
|
46
79
|
(0, glob_1.glob)(pattern, {
|
|
47
80
|
dotRelative: false
|
|
48
|
-
}).then(
|
|
49
|
-
|
|
81
|
+
}).then(files => {
|
|
82
|
+
const readFiles = files.map((file) => ({
|
|
50
83
|
relative: file,
|
|
51
84
|
contents: fs.readFileSync(file)
|
|
52
|
-
})
|
|
85
|
+
}));
|
|
53
86
|
cb(SearchIndex.createFromHtml(readFiles, bodySelector));
|
|
54
|
-
}).catch(
|
|
87
|
+
}).catch(err => {
|
|
55
88
|
throw err;
|
|
56
89
|
});
|
|
57
|
-
}
|
|
58
|
-
|
|
90
|
+
}
|
|
91
|
+
getResult() {
|
|
59
92
|
return {
|
|
60
93
|
index: this.index,
|
|
61
94
|
store: this.store,
|
|
62
95
|
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
}());
|
|
96
|
+
}
|
|
97
|
+
}
|
|
66
98
|
exports.SearchIndex = SearchIndex;
|
|
67
99
|
//# sourceMappingURL=index.js.map
|
package/js/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,+BAA0B;AAC1B,uCAAyB;AACzB,2CAA6B;AA4B7B,MAAa,WAAW;IACL,KAAK,CAAe;IACpB,KAAK,CAAa;IAEnC,YAAoB,KAAyB;QAC3C,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,MAAM,OAAO,GAAiB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC1B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEpB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAsB,EAAQ,EAAE;YAC7C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;gBACtB,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC;YACF,OAAO,CAAC,GAAG,C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,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC7D,QAAQ,EAAE,IAAI;gBACd,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;aAChC,CAAC,CAAC,CAAC;YACJ,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;QAC1D,CAAC,CACF,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YACZ,MAAM,GAAG,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,SAAS;QACf,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;CACF;AAlED,kCAkEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mvw-search-index",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.7",
|
|
4
4
|
"description": "Module to generate the search index using lunr.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"website",
|
|
@@ -23,26 +23,25 @@
|
|
|
23
23
|
"main": "js/index.js",
|
|
24
24
|
"types": "js/index.d.ts",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/cheerio": "1.0.0
|
|
27
|
-
"@types/jasmine": "6.0.0",
|
|
26
|
+
"@types/cheerio": "1.0.0",
|
|
28
27
|
"@types/lunr": "2.3.7",
|
|
29
|
-
"@types/node": "25.2
|
|
30
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
31
|
-
"@typescript-eslint/parser": "8.
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"typescript": "
|
|
35
|
-
"
|
|
28
|
+
"@types/node": "25.5.2",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "8.58.0",
|
|
30
|
+
"@typescript-eslint/parser": "8.58.0",
|
|
31
|
+
"eslint": "10.2.0",
|
|
32
|
+
"serve": "14.2.6",
|
|
33
|
+
"typescript": "6.0.2",
|
|
34
|
+
"vitest": "4.1.2"
|
|
36
35
|
},
|
|
37
36
|
"dependencies": {
|
|
38
37
|
"cheerio": "1.2.0",
|
|
39
38
|
"commander": "14.0.3",
|
|
40
|
-
"glob": "13.0.
|
|
39
|
+
"glob": "13.0.6",
|
|
41
40
|
"lunr": "2.3.9"
|
|
42
41
|
},
|
|
43
42
|
"scripts": {
|
|
44
43
|
"build": "tsc -p ./ts",
|
|
45
|
-
"test": "npx eslint . && npm run build &&
|
|
44
|
+
"test": "npx eslint . && npm run build && npx vitest run",
|
|
46
45
|
"preserve": "cd docs && node ../js/cli.js './**/*.html' index.json 'body.to-be-indexed'",
|
|
47
46
|
"serve": "serve docs"
|
|
48
47
|
},
|