narou 0.8.1 → 0.9.1
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/dist/chunk-3L6BVCEQ.js +3065 -0
- package/dist/chunk-3L6BVCEQ.js.map +1 -0
- package/dist/chunk-5M7JXPW3.js +1 -0
- package/dist/chunk-5M7JXPW3.js.map +1 -0
- package/dist/chunk-AUZ3RYOM.js +50 -0
- package/dist/chunk-AUZ3RYOM.js.map +1 -0
- package/dist/chunk-ELL5TDE4.js +94 -0
- package/dist/chunk-ELL5TDE4.js.map +1 -0
- package/dist/chunk-H4TVIA56.js +83 -0
- package/dist/chunk-H4TVIA56.js.map +1 -0
- package/dist/chunk-JMTNQTNC.js +24 -0
- package/dist/chunk-JMTNQTNC.js.map +1 -0
- package/dist/chunk-M2JOQXK7.js +15 -0
- package/dist/chunk-M2JOQXK7.js.map +1 -0
- package/dist/chunk-M5TG4H6A.js +1 -0
- package/dist/chunk-M5TG4H6A.js.map +1 -0
- package/dist/chunk-PH7RAXIZ.js +397 -0
- package/dist/chunk-PH7RAXIZ.js.map +1 -0
- package/dist/chunk-SKRVT2TT.js +44 -0
- package/dist/chunk-SKRVT2TT.js.map +1 -0
- package/dist/chunk-SUVA6EFY.js +26 -0
- package/dist/chunk-SUVA6EFY.js.map +1 -0
- package/dist/chunk-TNDGN3EF.js +39 -0
- package/dist/chunk-TNDGN3EF.js.map +1 -0
- package/dist/chunk-TZ3HVU6L.js +72 -0
- package/dist/chunk-TZ3HVU6L.js.map +1 -0
- package/dist/chunk-VHDE4QIZ.js +37 -0
- package/dist/chunk-VHDE4QIZ.js.map +1 -0
- package/dist/chunk-VHXJSFYZ.js +372 -0
- package/dist/chunk-VHXJSFYZ.js.map +1 -0
- package/dist/index.browser.cjs +1222 -0
- package/dist/index.browser.cjs.map +1 -0
- package/dist/index.browser.d.cts +40 -0
- package/dist/index.browser.d.ts +20 -16
- package/dist/index.browser.js +116 -71
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +4306 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.common.cjs +1033 -0
- package/dist/index.common.cjs.map +1 -0
- package/dist/index.common.d.cts +6 -0
- package/dist/index.common.d.ts +6 -15
- package/dist/index.common.js +73 -33
- package/dist/index.common.js.map +1 -1
- package/dist/index.d.cts +47 -0
- package/dist/index.d.ts +21 -17
- package/dist/index.js +121 -79
- package/dist/index.js.map +1 -1
- package/dist/narou-61329eea.d.ts +298 -0
- package/dist/narou-98ededc8.d.ts +298 -0
- package/dist/narou-fetch.cjs +3191 -0
- package/dist/narou-fetch.cjs.map +1 -0
- package/dist/narou-fetch.d.cts +16 -0
- package/dist/narou-fetch.d.ts +10 -7
- package/dist/narou-fetch.js +10 -45
- package/dist/narou-fetch.js.map +1 -1
- package/dist/narou-jsonp.cjs +159 -0
- package/dist/narou-jsonp.cjs.map +1 -0
- package/dist/narou-jsonp.d.cts +13 -0
- package/dist/narou-jsonp.d.ts +8 -5
- package/dist/narou-jsonp.js +10 -23
- package/dist/narou-jsonp.js.map +1 -1
- package/dist/narou-ranking-results.cjs +19 -0
- package/dist/narou-ranking-results.cjs.map +1 -0
- package/dist/narou-ranking-results.d.cts +4 -0
- package/dist/narou-ranking-results.d.ts +4 -10
- package/dist/narou-ranking-results.js +1 -2
- package/dist/narou-ranking-results.js.map +1 -1
- package/dist/narou-search-results-6727b1ce.d.ts +716 -0
- package/dist/narou-search-results-b7c10db0.d.ts +716 -0
- package/dist/narou-search-results.cjs +62 -0
- package/dist/narou-search-results.cjs.map +1 -0
- package/dist/narou-search-results.d.cts +2 -0
- package/dist/narou-search-results.d.ts +2 -131
- package/dist/narou-search-results.js +10 -61
- package/dist/narou-search-results.js.map +1 -1
- package/dist/narou.cjs +109 -0
- package/dist/narou.cjs.map +1 -0
- package/dist/narou.d.cts +4 -0
- package/dist/narou.d.ts +4 -26
- package/dist/narou.js +8 -29
- package/dist/narou.js.map +1 -1
- package/dist/params.cjs +437 -0
- package/dist/params.cjs.map +1 -0
- package/dist/params.d.cts +2 -0
- package/dist/params.d.ts +2 -324
- package/dist/params.js +38 -245
- package/dist/params.js.map +1 -1
- package/dist/ranking-history.cjs +39 -0
- package/dist/ranking-history.cjs.map +1 -0
- package/dist/ranking-history.d.cts +17 -0
- package/dist/ranking-history.d.ts +8 -5
- package/dist/ranking-history.js +7 -13
- package/dist/ranking-history.js.map +1 -1
- package/dist/ranking.cjs +660 -0
- package/dist/ranking.cjs.map +1 -0
- package/dist/ranking.d.cts +47 -0
- package/dist/ranking.d.ts +8 -7
- package/dist/ranking.js +9 -86
- package/dist/ranking.js.map +1 -1
- package/dist/search-builder-r18.cjs +474 -0
- package/dist/search-builder-r18.cjs.map +1 -0
- package/dist/search-builder-r18.d.cts +32 -0
- package/dist/search-builder-r18.d.ts +9 -6
- package/dist/search-builder-r18.js +9 -44
- package/dist/search-builder-r18.js.map +1 -1
- package/dist/search-builder.cjs +511 -0
- package/dist/search-builder.cjs.map +1 -0
- package/dist/search-builder.d.cts +4 -0
- package/dist/search-builder.d.ts +4 -220
- package/dist/search-builder.js +12 -380
- package/dist/search-builder.js.map +1 -1
- package/dist/user-search.cjs +301 -0
- package/dist/user-search.cjs.map +1 -0
- package/{dist.esm/user-search.js → dist/user-search.d.cts} +18 -46
- package/dist/user-search.d.ts +8 -5
- package/dist/user-search.js +9 -93
- package/dist/user-search.js.map +1 -1
- package/dist/util/jsonp.cjs +63 -0
- package/dist/util/jsonp.cjs.map +1 -0
- package/dist/util/jsonp.d.cts +13 -0
- package/dist/util/jsonp.d.ts +4 -8
- package/dist/util/jsonp.js +7 -45
- package/dist/util/jsonp.js.map +1 -1
- package/dist/util/type.cjs +19 -0
- package/dist/util/type.cjs.map +1 -0
- package/dist/util/type.d.cts +4 -0
- package/dist/util/type.d.ts +4 -4
- package/dist/util/type.js +0 -2
- package/dist/util/type.js.map +1 -1
- package/dist/util/unzipp.cjs +48 -0
- package/dist/util/unzipp.cjs.map +1 -0
- package/dist/util/unzipp.d.cts +3 -0
- package/dist/util/unzipp.d.ts +3 -4
- package/dist/util/unzipp.js +7 -11
- package/dist/util/unzipp.js.map +1 -1
- package/package.json +38 -36
- package/src/narou-fetch.ts +6 -16
- package/src/narou-jsonp.ts +0 -2
- package/src/narou-ranking-results.ts +10 -0
- package/src/narou-search-results.ts +118 -63
- package/src/narou.ts +42 -3
- package/src/params.ts +220 -61
- package/src/util/unzipp.ts +13 -3
- package/dist/index.browser.d.ts.map +0 -1
- package/dist/index.common.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/narou-fetch.d.ts.map +0 -1
- package/dist/narou-jsonp.d.ts.map +0 -1
- package/dist/narou-ranking-results.d.ts.map +0 -1
- package/dist/narou-search-results.d.ts.map +0 -1
- package/dist/narou.d.ts.map +0 -1
- package/dist/params.d.ts.map +0 -1
- package/dist/ranking-history.d.ts.map +0 -1
- package/dist/ranking.d.ts.map +0 -1
- package/dist/search-builder-r18.d.ts.map +0 -1
- package/dist/search-builder.d.ts.map +0 -1
- package/dist/user-search.d.ts.map +0 -1
- package/dist/util/jsonp.d.ts.map +0 -1
- package/dist/util/type.d.ts.map +0 -1
- package/dist/util/unzipp.d.ts.map +0 -1
- package/dist.esm/index.browser.js +0 -86
- package/dist.esm/index.browser.js.map +0 -1
- package/dist.esm/index.common.js +0 -38
- package/dist.esm/index.common.js.map +0 -1
- package/dist.esm/index.js +0 -94
- package/dist.esm/index.js.map +0 -1
- package/dist.esm/narou-fetch.js +0 -49
- package/dist.esm/narou-fetch.js.map +0 -1
- package/dist.esm/narou-jsonp.js +0 -27
- package/dist.esm/narou-jsonp.js.map +0 -1
- package/dist.esm/narou-ranking-results.js +0 -3
- package/dist.esm/narou-ranking-results.js.map +0 -1
- package/dist.esm/narou-search-results.js +0 -63
- package/dist.esm/narou-search-results.js.map +0 -1
- package/dist.esm/narou.js +0 -33
- package/dist.esm/narou.js.map +0 -1
- package/dist.esm/params.js +0 -247
- package/dist.esm/params.js.map +0 -1
- package/dist.esm/ranking-history.js +0 -14
- package/dist.esm/ranking-history.js.map +0 -1
- package/dist.esm/ranking.js +0 -90
- package/dist.esm/ranking.js.map +0 -1
- package/dist.esm/search-builder-r18.js +0 -45
- package/dist.esm/search-builder-r18.js.map +0 -1
- package/dist.esm/search-builder.js +0 -381
- package/dist.esm/search-builder.js.map +0 -1
- package/dist.esm/user-search.js.map +0 -1
- package/dist.esm/util/jsonp.js +0 -46
- package/dist.esm/util/jsonp.js.map +0 -1
- package/dist.esm/util/type.js +0 -3
- package/dist.esm/util/type.js.map +0 -1
- package/dist.esm/util/unzipp.js +0 -12
- package/dist.esm/util/unzipp.js.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/util/jsonp.ts
|
|
21
|
+
var jsonp_exports = {};
|
|
22
|
+
__export(jsonp_exports, {
|
|
23
|
+
jsonp: () => jsonp
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(jsonp_exports);
|
|
26
|
+
var count = 0;
|
|
27
|
+
var noop = function() {
|
|
28
|
+
};
|
|
29
|
+
function jsonp(url, { prefix = "__jp", param = "callback", timeout = 15e3 } = {}) {
|
|
30
|
+
return new Promise(function(resolve, reject) {
|
|
31
|
+
const targetChild = document.getElementsByTagName("script").item(0);
|
|
32
|
+
const target = targetChild?.parentNode ?? document.head;
|
|
33
|
+
const id = `${prefix}${count++}`;
|
|
34
|
+
const cleanup = function() {
|
|
35
|
+
if (script && script.parentNode) {
|
|
36
|
+
script.parentNode.removeChild(script);
|
|
37
|
+
}
|
|
38
|
+
window[id] = noop;
|
|
39
|
+
if (timer) {
|
|
40
|
+
clearTimeout(timer);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const timer = timeout > 0 ? setTimeout(() => {
|
|
44
|
+
cleanup();
|
|
45
|
+
reject(new Error("Timeout"));
|
|
46
|
+
}, timeout) : void 0;
|
|
47
|
+
const callback = (data) => {
|
|
48
|
+
cleanup();
|
|
49
|
+
resolve(data);
|
|
50
|
+
};
|
|
51
|
+
window[id] = callback;
|
|
52
|
+
const script = document.createElement("script");
|
|
53
|
+
const urlObj = new URL(url);
|
|
54
|
+
urlObj.searchParams.set(param, id);
|
|
55
|
+
script.setAttribute("src", urlObj.toString());
|
|
56
|
+
target.insertBefore(script, targetChild);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
jsonp
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=jsonp.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/jsonp.ts"],"sourcesContent":["/**\n * MIT license\n */\n\n// Callback index.\nlet count = 0;\n\ntype CallbackId<Prefix extends string = string> = `${Prefix}${number}`;\n\ndeclare global {\n interface Window {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: CallbackId]: (data: any) => void;\n }\n}\nexport type JsonpOption = {\n prefix?: string;\n param?: string;\n timeout?: number;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = function () {};\n\nexport function jsonp<T>(\n url: string,\n { prefix = \"__jp\", param = \"callback\", timeout = 15000 }: JsonpOption = {}\n): Promise<T> {\n return new Promise(function (resolve, reject) {\n const targetChild = document.getElementsByTagName(\"script\").item(0);\n const target = targetChild?.parentNode ?? document.head;\n\n const id: CallbackId = `${prefix}${count++}`;\n const cleanup = function () {\n // Remove the script tag.\n if (script && script.parentNode) {\n script.parentNode.removeChild(script);\n }\n\n window[id] = noop;\n\n if (timer) {\n clearTimeout(timer);\n }\n };\n\n const timer =\n timeout > 0\n ? setTimeout(() => {\n cleanup();\n reject(new Error(\"Timeout\"));\n }, timeout)\n : undefined;\n\n const callback = (data: T) => {\n cleanup();\n resolve(data);\n };\n window[id] = callback;\n\n // Create script.\n const script = document.createElement(\"script\");\n const urlObj = new URL(url);\n urlObj.searchParams.set(param, id);\n script.setAttribute(\"src\", urlObj.toString());\n target.insertBefore(script, targetChild);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAI,QAAQ;AAiBZ,IAAM,OAAO,WAAY;AAAC;AAEnB,SAAS,MACd,KACA,EAAE,SAAS,QAAQ,QAAQ,YAAY,UAAU,KAAM,IAAiB,CAAC,GAC7D;AACZ,SAAO,IAAI,QAAQ,SAAU,SAAS,QAAQ;AAC5C,UAAM,cAAc,SAAS,qBAAqB,QAAQ,EAAE,KAAK,CAAC;AAClE,UAAM,SAAS,aAAa,cAAc,SAAS;AAEnD,UAAM,KAAiB,GAAG,MAAM,GAAG,OAAO;AAC1C,UAAM,UAAU,WAAY;AAE1B,UAAI,UAAU,OAAO,YAAY;AAC/B,eAAO,WAAW,YAAY,MAAM;AAAA,MACtC;AAEA,aAAO,EAAE,IAAI;AAEb,UAAI,OAAO;AACT,qBAAa,KAAK;AAAA,MACpB;AAAA,IACF;AAEA,UAAM,QACJ,UAAU,IACN,WAAW,MAAM;AACf,cAAQ;AACR,aAAO,IAAI,MAAM,SAAS,CAAC;AAAA,IAC7B,GAAG,OAAO,IACV;AAEN,UAAM,WAAW,CAAC,SAAY;AAC5B,cAAQ;AACR,cAAQ,IAAI;AAAA,IACd;AACA,WAAO,EAAE,IAAI;AAGb,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,UAAM,SAAS,IAAI,IAAI,GAAG;AAC1B,WAAO,aAAa,IAAI,OAAO,EAAE;AACjC,WAAO,aAAa,OAAO,OAAO,SAAS,CAAC;AAC5C,WAAO,aAAa,QAAQ,WAAW;AAAA,EACzC,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
[key: CallbackId]: (data: any) => void;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
type JsonpOption = {
|
|
7
|
+
prefix?: string;
|
|
8
|
+
param?: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
};
|
|
11
|
+
declare function jsonp<T>(url: string, { prefix, param, timeout }?: JsonpOption): Promise<T>;
|
|
12
|
+
|
|
13
|
+
export { JsonpOption, jsonp };
|
package/dist/util/jsonp.d.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MIT license
|
|
3
|
-
*/
|
|
4
|
-
declare type CallbackId<Prefix extends string = string> = `${Prefix}${number}`;
|
|
5
1
|
declare global {
|
|
6
2
|
interface Window {
|
|
7
3
|
[key: CallbackId]: (data: any) => void;
|
|
8
4
|
}
|
|
9
5
|
}
|
|
10
|
-
|
|
6
|
+
type JsonpOption = {
|
|
11
7
|
prefix?: string;
|
|
12
8
|
param?: string;
|
|
13
9
|
timeout?: number;
|
|
14
10
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
declare function jsonp<T>(url: string, { prefix, param, timeout }?: JsonpOption): Promise<T>;
|
|
12
|
+
|
|
13
|
+
export { JsonpOption, jsonp };
|
package/dist/util/jsonp.js
CHANGED
|
@@ -1,46 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let count = 0;
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
10
|
-
const noop = function () { };
|
|
11
|
-
function jsonp(url, { prefix = "__jp", param = "callback", timeout = 15000 } = {}) {
|
|
12
|
-
return new Promise(function (resolve, reject) {
|
|
13
|
-
const targetChild = document.getElementsByTagName("script").item(0);
|
|
14
|
-
const target = targetChild?.parentNode ?? document.head;
|
|
15
|
-
const id = `${prefix}${count++}`;
|
|
16
|
-
const cleanup = function () {
|
|
17
|
-
// Remove the script tag.
|
|
18
|
-
if (script && script.parentNode) {
|
|
19
|
-
script.parentNode.removeChild(script);
|
|
20
|
-
}
|
|
21
|
-
window[id] = noop;
|
|
22
|
-
if (timer) {
|
|
23
|
-
clearTimeout(timer);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const timer = timeout > 0
|
|
27
|
-
? setTimeout(() => {
|
|
28
|
-
cleanup();
|
|
29
|
-
reject(new Error("Timeout"));
|
|
30
|
-
}, timeout)
|
|
31
|
-
: undefined;
|
|
32
|
-
const callback = (data) => {
|
|
33
|
-
cleanup();
|
|
34
|
-
resolve(data);
|
|
35
|
-
};
|
|
36
|
-
window[id] = callback;
|
|
37
|
-
// Create script.
|
|
38
|
-
const script = document.createElement("script");
|
|
39
|
-
const urlObj = new URL(url);
|
|
40
|
-
urlObj.searchParams.set(param, id);
|
|
41
|
-
script.setAttribute("src", urlObj.toString());
|
|
42
|
-
target.insertBefore(script, targetChild);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
exports.jsonp = jsonp;
|
|
1
|
+
import {
|
|
2
|
+
jsonp
|
|
3
|
+
} from "../chunk-TNDGN3EF.js";
|
|
4
|
+
import "../chunk-AUZ3RYOM.js";
|
|
5
|
+
export {
|
|
6
|
+
jsonp
|
|
7
|
+
};
|
|
46
8
|
//# sourceMappingURL=jsonp.js.map
|
package/dist/util/jsonp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/util/type.ts
|
|
17
|
+
var type_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(type_exports);
|
|
19
|
+
//# sourceMappingURL=type.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/type.ts"],"sourcesContent":["type Stringable = string | number | bigint | boolean | null | undefined;\n\nexport type Join<T extends Stringable> = `${T}-${T}` | `${T}`;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/util/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type Stringable = string | number | bigint | boolean | null | undefined;
|
|
2
|
+
type Join<T extends Stringable> = `${T}-${T}` | `${T}`;
|
|
3
|
+
|
|
4
|
+
export { Join };
|
package/dist/util/type.js
CHANGED
package/dist/util/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/util/unzipp.ts
|
|
21
|
+
var unzipp_exports = {};
|
|
22
|
+
__export(unzipp_exports, {
|
|
23
|
+
unzipp: () => unzipp
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(unzipp_exports);
|
|
26
|
+
var import_zlib = require("zlib");
|
|
27
|
+
var import_util = require("util");
|
|
28
|
+
var gunzipAsync = (0, import_util.promisify)(import_zlib.gunzip);
|
|
29
|
+
var decoder = new TextDecoder();
|
|
30
|
+
async function unzipp(data) {
|
|
31
|
+
try {
|
|
32
|
+
const buffer = await gunzipAsync(data);
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(decoder.decode(buffer));
|
|
35
|
+
} catch {
|
|
36
|
+
throw decoder.decode(buffer);
|
|
37
|
+
}
|
|
38
|
+
} catch (e) {
|
|
39
|
+
if (typeof e === "string")
|
|
40
|
+
throw e;
|
|
41
|
+
throw decoder.decode(data);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
unzipp
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=unzipp.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/util/unzipp.ts"],"sourcesContent":["import { gunzip, InputType } from \"zlib\";\nimport { promisify } from \"util\";\n\nconst gunzipAsync = promisify<InputType, Buffer>(gunzip);\n\nconst decoder = new TextDecoder()\nexport async function unzipp(data: ArrayBuffer) {\n try {\n const buffer = await gunzipAsync(data);\n try {\n return JSON.parse(decoder.decode(buffer));\n } catch {\n throw decoder.decode(buffer);\n }\n } catch (e) {\n if (typeof e === \"string\") throw e;\n throw decoder.decode(data);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAkC;AAClC,kBAA0B;AAE1B,IAAM,kBAAc,uBAA6B,kBAAM;AAEvD,IAAM,UAAU,IAAI,YAAY;AAChC,eAAsB,OAAO,MAAmB;AAC9C,MAAI;AACF,UAAM,SAAS,MAAM,YAAY,IAAI;AACrC,QAAI;AACF,aAAO,KAAK,MAAM,QAAQ,OAAO,MAAM,CAAC;AAAA,IAC1C,QAAQ;AACN,YAAM,QAAQ,OAAO,MAAM;AAAA,IAC7B;AAAA,EACF,SAAS,GAAG;AACV,QAAI,OAAO,MAAM;AAAU,YAAM;AACjC,UAAM,QAAQ,OAAO,IAAI;AAAA,EAC3B;AACF;","names":[]}
|
package/dist/util/unzipp.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
//# sourceMappingURL=unzipp.d.ts.map
|
|
1
|
+
declare function unzipp(data: ArrayBuffer): Promise<any>;
|
|
2
|
+
|
|
3
|
+
export { unzipp };
|
package/dist/util/unzipp.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const buffer = await gunzipAsync(data);
|
|
9
|
-
return JSON.parse(buffer.toString());
|
|
10
|
-
}
|
|
11
|
-
exports.unzipp = unzipp;
|
|
1
|
+
import {
|
|
2
|
+
unzipp
|
|
3
|
+
} from "../chunk-JMTNQTNC.js";
|
|
4
|
+
import "../chunk-AUZ3RYOM.js";
|
|
5
|
+
export {
|
|
6
|
+
unzipp
|
|
7
|
+
};
|
|
12
8
|
//# sourceMappingURL=unzipp.js.map
|
package/dist/util/unzipp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "narou",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Narou API Wrapper",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"module": "dist/index.js",
|
|
7
9
|
"exports": {
|
|
8
10
|
".": {
|
|
9
11
|
"browser": {
|
|
10
|
-
"require": "./dist/index.browser.
|
|
11
|
-
"import": "./dist
|
|
12
|
+
"require": "./dist/index.browser.cjs",
|
|
13
|
+
"import": "./dist/index.browser.js",
|
|
14
|
+
"types": "./dist/index.browser.d.ts"
|
|
12
15
|
},
|
|
13
16
|
"node": {
|
|
14
|
-
"require": "./dist/index.
|
|
15
|
-
"import": "./dist
|
|
17
|
+
"require": "./dist/index.cjs",
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
16
20
|
}
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
|
-
"engines": {
|
|
20
|
-
"node": ">=16.0.0"
|
|
21
|
-
},
|
|
22
23
|
"files": [
|
|
23
24
|
"dist",
|
|
24
|
-
"dist.*",
|
|
25
25
|
"src",
|
|
26
|
-
"package
|
|
26
|
+
"package.json",
|
|
27
|
+
"package-lock.json",
|
|
28
|
+
"README.md"
|
|
27
29
|
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=16.0.0"
|
|
32
|
+
},
|
|
28
33
|
"author": "deflis <deflis@gmail.com>",
|
|
29
34
|
"license": "MIT",
|
|
30
35
|
"repository": {
|
|
@@ -32,42 +37,39 @@
|
|
|
32
37
|
"url": "https://github.com/deflis/node-narou.git"
|
|
33
38
|
},
|
|
34
39
|
"dependencies": {
|
|
35
|
-
"date-fns": "^2.
|
|
40
|
+
"date-fns": "^2.30.0"
|
|
36
41
|
},
|
|
37
42
|
"devDependencies": {
|
|
38
|
-
"@types/jest": "^
|
|
39
|
-
"@types/node": "^
|
|
40
|
-
"@types/node-fetch": "^2.
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
42
|
-
"@typescript-eslint/parser": "^
|
|
43
|
-
"eslint": "^8.
|
|
44
|
-
"eslint-config-prettier": "^
|
|
45
|
-
"eslint-plugin-prettier": "^
|
|
46
|
-
"jest": "^
|
|
47
|
-
"node-fetch": "^2.
|
|
48
|
-
"npm-run-all": "^4.1.
|
|
49
|
-
"prettier": "^
|
|
50
|
-
"ts-jest": "^
|
|
51
|
-
"
|
|
43
|
+
"@types/jest": "^29.5.8",
|
|
44
|
+
"@types/node": "^20.9.0",
|
|
45
|
+
"@types/node-fetch": "^2.6.9",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
|
47
|
+
"@typescript-eslint/parser": "^6.10.0",
|
|
48
|
+
"eslint": "^8.53.0",
|
|
49
|
+
"eslint-config-prettier": "^9.0.0",
|
|
50
|
+
"eslint-plugin-prettier": "^5.0.1",
|
|
51
|
+
"jest": "^29.7.0",
|
|
52
|
+
"node-fetch": "^2.7.0",
|
|
53
|
+
"npm-run-all": "^4.1.5",
|
|
54
|
+
"prettier": "^3.0.3",
|
|
55
|
+
"ts-jest": "^29.1.1",
|
|
56
|
+
"tsup": "^7.2.0",
|
|
57
|
+
"typescript": "^5.2.2"
|
|
52
58
|
},
|
|
53
59
|
"optionalDependencies": {
|
|
54
60
|
"node-fetch": "^2.6.7"
|
|
55
61
|
},
|
|
56
62
|
"scripts": {
|
|
57
|
-
"build": "npm-run-all check
|
|
58
|
-
"build:tsc": "
|
|
59
|
-
"build:tsc:cjs": "tsc -p ./tsconfig.cjs.json",
|
|
60
|
-
"build:tsc:esm": "tsc -p ./tsconfig.esm.json",
|
|
63
|
+
"build": "npm-run-all check build:tsc",
|
|
64
|
+
"build:tsc": "tsup ./src",
|
|
61
65
|
"check": "npm-run-all --parallel check:lint check:build test",
|
|
62
66
|
"check:lint": "eslint src/** test/**",
|
|
63
67
|
"check:build": "tsc --noEmit",
|
|
64
|
-
"
|
|
68
|
+
"prepack": "npm-run-all format build",
|
|
65
69
|
"format": "eslint --fix src/** test/**",
|
|
66
70
|
"test": "jest",
|
|
67
|
-
"
|
|
68
|
-
"docs": "npm-run-all docs:clean docs:typedoc docs:nojekyll",
|
|
71
|
+
"docs": "npm-run-all docs:clean docs:typedoc",
|
|
69
72
|
"docs:clean": "npx rimraf docs",
|
|
70
|
-
"docs:typedoc": "npx typedoc --out ./docs src/index.ts"
|
|
71
|
-
"docs:nojekyll": "npx touch ./docs/.nojekyll"
|
|
73
|
+
"docs:typedoc": "npx typedoc --out ./docs src/index.ts"
|
|
72
74
|
}
|
|
73
75
|
}
|
package/src/narou-fetch.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import nodeFetch from "node-fetch";
|
|
2
|
-
|
|
3
1
|
import { unzipp } from "./util/unzipp";
|
|
4
2
|
import NarouNovel, { NarouParams } from "./narou";
|
|
5
3
|
|
|
4
|
+
type Fetch = typeof fetch;
|
|
5
|
+
|
|
6
6
|
/**
|
|
7
7
|
* なろう小説APIへのリクエストを実行する
|
|
8
|
-
* @class NarouNovel
|
|
9
|
-
* @private
|
|
10
8
|
*/
|
|
11
9
|
export default class NarouNovelFetch extends NarouNovel {
|
|
12
|
-
constructor(private fetch =
|
|
10
|
+
constructor(private fetch: Fetch = require('node-fetch')) {
|
|
13
11
|
super();
|
|
14
12
|
}
|
|
15
13
|
|
|
@@ -33,18 +31,10 @@ export default class NarouNovelFetch extends NarouNovel {
|
|
|
33
31
|
const res = await this.fetch(url);
|
|
34
32
|
|
|
35
33
|
if (query.gzip === 0) {
|
|
36
|
-
return await res.json();
|
|
34
|
+
return (await res.json()) as T;
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
const buffer = await res.
|
|
40
|
-
|
|
41
|
-
return await unzipp(buffer);
|
|
42
|
-
} catch {
|
|
43
|
-
try {
|
|
44
|
-
throw JSON.stringify(buffer.toString());
|
|
45
|
-
} catch {
|
|
46
|
-
throw buffer.toString();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
37
|
+
const buffer = await res.arrayBuffer();
|
|
38
|
+
return await unzipp(buffer);
|
|
49
39
|
}
|
|
50
40
|
}
|
package/src/narou-jsonp.ts
CHANGED
|
@@ -2,12 +2,22 @@ import { PickedNarouSearchResult } from "./narou-search-results";
|
|
|
2
2
|
import { SearchResultFieldNames } from "./params";
|
|
3
3
|
import { DefaultSearchResultFields } from "./search-builder";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* ランキングAPIの結果
|
|
7
|
+
* @see https://dev.syosetu.com/man/rankapi/#output
|
|
8
|
+
*/
|
|
5
9
|
export interface NarouRankingResult {
|
|
10
|
+
/** Nコード */
|
|
6
11
|
ncode: string;
|
|
12
|
+
/** 順位 */
|
|
7
13
|
rank: number;
|
|
14
|
+
/** ポイント */
|
|
8
15
|
pt: number;
|
|
9
16
|
}
|
|
10
17
|
|
|
18
|
+
/**
|
|
19
|
+
* ランキングと小説情報をマージした結果
|
|
20
|
+
*/
|
|
11
21
|
export type RankingResult<
|
|
12
22
|
T extends SearchResultFieldNames = DefaultSearchResultFields
|
|
13
23
|
> = Partial<PickedNarouSearchResult<T>> & NarouRankingResult;
|