fishpi 0.0.21 → 0.0.23
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/lib/article.d.ts +71 -0
- package/lib/article.js +271 -0
- package/lib/breezemoon.d.ts +25 -0
- package/lib/breezemoon.js +116 -0
- package/lib/chat.d.ts +66 -0
- package/lib/chat.js +324 -0
- package/lib/chatroom.d.ts +90 -0
- package/lib/chatroom.js +516 -0
- package/lib/comment.d.ts +31 -0
- package/lib/comment.js +192 -0
- package/lib/emoji.d.ts +201 -0
- package/lib/emoji.js +381 -0
- package/lib/index.d.ts +78 -0
- package/lib/index.js +309 -0
- package/lib/notice.d.ts +31 -0
- package/lib/notice.js +157 -0
- package/lib/typing.d.ts +2073 -0
- package/lib/typing.js +446 -0
- package/lib/user.d.ts +35 -0
- package/lib/user.js +225 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +152 -0
- package/package.json +2 -2
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Metal, MetalList } from './typing';
|
|
2
|
+
declare let domain: string;
|
|
3
|
+
declare function setDomain(d: string): void;
|
|
4
|
+
declare function request(opt: any): Promise<any>;
|
|
5
|
+
declare function analyzeMetalAttr(m: any): Metal;
|
|
6
|
+
declare function toMetal(sysMetal: string): MetalList;
|
|
7
|
+
declare const isBrowse: boolean;
|
|
8
|
+
export { request, domain, toMetal, analyzeMetalAttr, isBrowse, setDomain };
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.setDomain = exports.isBrowse = exports.analyzeMetalAttr = exports.toMetal = exports.domain = exports.request = void 0;
|
|
63
|
+
var domain = 'fishpi.cn';
|
|
64
|
+
exports.domain = domain;
|
|
65
|
+
function setDomain(d) {
|
|
66
|
+
exports.domain = domain = d;
|
|
67
|
+
}
|
|
68
|
+
exports.setDomain = setDomain;
|
|
69
|
+
function request(opt) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
+
var url, _a, method, _b, headers, data, body, _c, options, rsp;
|
|
72
|
+
return __generator(this, function (_d) {
|
|
73
|
+
switch (_d.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
url = opt.url, _a = opt.method, method = _a === void 0 ? 'get' : _a, _b = opt.headers, headers = _b === void 0 ? {} : _b, data = opt.data;
|
|
76
|
+
if (!isBrowse) {
|
|
77
|
+
headers['User-Agent'] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36";
|
|
78
|
+
headers['Referer'] = "https://".concat(domain, "/");
|
|
79
|
+
}
|
|
80
|
+
body = undefined;
|
|
81
|
+
if (!(!isBrowse && !globalThis.FormData)) return [3 /*break*/, 2];
|
|
82
|
+
_c = globalThis;
|
|
83
|
+
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('form-data')); })];
|
|
84
|
+
case 1:
|
|
85
|
+
_c.FormData = (_d.sent()).default;
|
|
86
|
+
_d.label = 2;
|
|
87
|
+
case 2:
|
|
88
|
+
if (data instanceof FormData) {
|
|
89
|
+
body = data;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
body = JSON.stringify(data);
|
|
93
|
+
}
|
|
94
|
+
options = {
|
|
95
|
+
method: method,
|
|
96
|
+
headers: headers,
|
|
97
|
+
body: body
|
|
98
|
+
};
|
|
99
|
+
try {
|
|
100
|
+
rsp = fetch("https://".concat(domain, "/").concat(url), options)
|
|
101
|
+
.then(function (res) { return res.text(); })
|
|
102
|
+
.then(function (res) {
|
|
103
|
+
try {
|
|
104
|
+
return JSON.parse(res);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
return res;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return [2 /*return*/, rsp];
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
if (err.response.status === 401) {
|
|
114
|
+
return [2 /*return*/, err.response];
|
|
115
|
+
}
|
|
116
|
+
throw (err);
|
|
117
|
+
}
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
exports.request = request;
|
|
124
|
+
function analyzeMetalAttr(m) {
|
|
125
|
+
if (!m)
|
|
126
|
+
return m;
|
|
127
|
+
if (typeof m.attr != 'string')
|
|
128
|
+
return m;
|
|
129
|
+
var attr = m.attr.split('&');
|
|
130
|
+
var src = m.attr;
|
|
131
|
+
m.attr = { src: src };
|
|
132
|
+
attr.forEach(function (a) { return m.attr[a.split('=')[0]] = a.split('=')[1]; });
|
|
133
|
+
m.url = "https://".concat(domain, "/gen?txt=").concat(m.description, "&url=").concat(m.attr.src);
|
|
134
|
+
m.icon = "https://".concat(domain, "/gen?txt=&").concat(m.attr.src);
|
|
135
|
+
return m;
|
|
136
|
+
}
|
|
137
|
+
exports.analyzeMetalAttr = analyzeMetalAttr;
|
|
138
|
+
function toMetal(sysMetal) {
|
|
139
|
+
try {
|
|
140
|
+
var metal = JSON.parse(sysMetal);
|
|
141
|
+
metal.list.forEach(function (m, i, list) {
|
|
142
|
+
list[i] = analyzeMetalAttr(m);
|
|
143
|
+
});
|
|
144
|
+
return metal.list;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
return [];
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.toMetal = toMetal;
|
|
151
|
+
var isBrowse = typeof window !== 'undefined';
|
|
152
|
+
exports.isBrowse = isBrowse;
|
package/package.json
CHANGED