Skip to content

Commit 7dd79d9

Browse files
author
Taois
committed
feat: single avaliable
1 parent c16a51d commit 7dd79d9

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed

drpy-node-bundle/libs/localDsCore.bundled.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42355,7 +42355,7 @@ const constants$1 = Object.freeze(Object.assign(Object.create(null), {
4235542355
}, realZlibConstants));
4235642356
//#endregion
4235742357
//#region ../node_modules/minizlib/dist/esm/index.js
42358-
var esm_exports$1 = /* @__PURE__ */ __exportAll({
42358+
var esm_exports$2 = /* @__PURE__ */ __exportAll({
4235942359
BrotliCompress: () => BrotliCompress,
4236042360
BrotliDecompress: () => BrotliDecompress,
4236142361
Deflate: () => Deflate,
@@ -120424,7 +120424,7 @@ function isValidFeed(value) {
120424120424
}
120425120425
//#endregion
120426120426
//#region ../node_modules/domutils/lib/esm/index.js
120427-
var esm_exports = /* @__PURE__ */ __exportAll({
120427+
var esm_exports$1 = /* @__PURE__ */ __exportAll({
120428120428
DocumentPosition: () => DocumentPosition,
120429120429
append: () => append$1,
120430120430
appendChild: () => appendChild,
@@ -124223,13 +124223,13 @@ function reduceRules(a, b) {
124223124223
//#region ../node_modules/css-select/lib/esm/index.js
124224124224
const defaultEquals = (a, b) => a === b;
124225124225
const defaultOptions = {
124226-
adapter: esm_exports,
124226+
adapter: esm_exports$1,
124227124227
equals: defaultEquals
124228124228
};
124229124229
function convertOptionFormats(options) {
124230124230
var _a, _b, _c, _d;
124231124231
const opts = options !== null && options !== void 0 ? options : defaultOptions;
124232-
(_a = opts.adapter) !== null && _a !== void 0 || (opts.adapter = esm_exports);
124232+
(_a = opts.adapter) !== null && _a !== void 0 || (opts.adapter = esm_exports$1);
124233124233
(_b = opts.equals) !== null && _b !== void 0 || (opts.equals = (_d = (_c = opts.adapter) === null || _c === void 0 ? void 0 : _c.equals) !== null && _d !== void 0 ? _d : defaultEquals);
124234124234
return opts;
124235124235
}
@@ -124459,7 +124459,7 @@ function findFilterElements(root, selector, options, queryForSelector, totalLimi
124459124459
if (remainingHasTraversal) {
124460124460
if ((0, import_commonjs.isTraversal)(remainingSelector[0])) {
124461124461
const { type } = remainingSelector[0];
124462-
if (type === import_commonjs.SelectorType.Sibling || type === import_commonjs.SelectorType.Adjacent) result = prepareContext(result, esm_exports, true);
124462+
if (type === import_commonjs.SelectorType.Sibling || type === import_commonjs.SelectorType.Adjacent) result = prepareContext(result, esm_exports$1, true);
124463124463
remainingSelector.unshift(UNIVERSAL_SELECTOR);
124464124464
}
124465124465
options = {
@@ -124477,7 +124477,7 @@ function findElements(root, sel, options, limit) {
124477124477
return find$2(root, _compileToken(sel, options, root), limit);
124478124478
}
124479124479
function find$2(root, query, limit = Infinity) {
124480-
return find$3((node) => isTag(node) && query(node), prepareContext(root, esm_exports, query.shouldTestNextSiblings), true, limit);
124480+
return find$3((node) => isTag(node) && query(node), prepareContext(root, esm_exports$1, query.shouldTestNextSiblings), true, limit);
124481124481
}
124482124482
function filterElements(elements, sel, options) {
124483124483
const els = (Array.isArray(elements) ? elements : [elements]).filter(isTag);
@@ -164200,6 +164200,15 @@ var require_mime_type = /* @__PURE__ */ __commonJSMin(((exports, module) => {
164200164200
}));
164201164201
//#endregion
164202164202
//#region ../node_modules/cheerio/dist/esm/index.js
164203+
var esm_exports = /* @__PURE__ */ __exportAll({
164204+
contains: () => contains$1,
164205+
decodeStream: () => decodeStream,
164206+
fromURL: () => fromURL,
164207+
load: () => load,
164208+
loadBuffer: () => loadBuffer,
164209+
merge: () => merge,
164210+
stringStream: () => stringStream
164211+
});
164203164212
var import_undici = /* @__PURE__ */ __toESM(require_undici(), 1);
164204164213
var import_mime_type = /* @__PURE__ */ __toESM(require_mime_type(), 1);
164205164214
/**
@@ -374901,6 +374910,13 @@ const ROOT_DIR = path.resolve(__dirname$4, "../");
374901374910
const LIB_ROOT = path.join(ROOT_DIR, "spider/js");
374902374911
const customRequire = createRequire$1(import.meta.url);
374903374912
const rootRequire = (modulePath) => {
374913+
if (modulePath === "iconv-lite") return globalThis.iconv;
374914+
if (modulePath === "axios") return globalThis.axios;
374915+
if (modulePath === "cheerio") return globalThis.cheerio;
374916+
if (modulePath === "qs") return globalThis.qs;
374917+
if (modulePath === "crypto-js") return globalThis.CryptoJS;
374918+
if (modulePath === "fs" && globalThis.fs) return globalThis.fs;
374919+
if (modulePath === "path" && globalThis.path) return globalThis.path;
374904374920
if (modulePath.startsWith("./") || modulePath.startsWith("../")) return customRequire(path.resolve(LIB_ROOT, modulePath));
374905374921
return customRequire(modulePath);
374906374922
};
@@ -382298,6 +382314,7 @@ const batchFetch4 = async (items, maxWorkers = 5, timeoutConfig = 5e3) => {
382298382314
//#endregion
382299382315
//#region ../libs_drpy/drpyInject.js
382300382316
globalThis.iconv = import_lib$1.default;
382317+
globalThis.cheerio = esm_exports;
382301382318
globalThis.batchFetch = batchFetch3;
382302382319
globalThis.axios = axios$1;
382303382320
globalThis.axiosX = pt;
@@ -392864,13 +392881,15 @@ async function getSandbox(env = {}) {
392864392881
createFTPClient,
392865392882
DataBase,
392866392883
database,
392867-
require: __require,
392884+
require: rootRequire,
392868392885
WebSocket: wrapper_default,
392869392886
WebSocketServer: import_websocket_server.default,
392870392887
zlib,
392871392888
JSONbig: import_json_bigint.default,
392872392889
JsonBig,
392873-
minizlib: esm_exports$1
392890+
minizlib: esm_exports$2,
392891+
iconv: globalThis.iconv,
392892+
cheerio: globalThis.cheerio
392874392893
};
392875392894
const sandbox = {
392876392895
console,

libs/drpyS.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,15 @@ export async function getSandbox(env = {}) {
304304
createFTPClient,
305305
DataBase,
306306
database,
307-
require,
307+
require: rootRequire,
308308
WebSocket,
309309
WebSocketServer,
310310
zlib,
311311
JSONbig,
312312
JsonBig,
313313
minizlib,
314+
iconv: globalThis.iconv,
315+
cheerio: globalThis.cheerio,
314316
};
315317

316318
// 创建一个沙箱上下文,注入需要的全局变量和函数

libs_drpy/drpyInject.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import _ from './underscore-esm.min.js'
1010
import tunnel from "tunnel";
1111
import iconv from 'iconv-lite';
1212
globalThis.iconv = iconv;
13+
import * as cheerio from 'cheerio';
14+
globalThis.cheerio = cheerio;
1315
import {jsonpath, jsoup} from './htmlParser.js';
1416
import hlsParser from './hls-parser.js'
1517
import {keysToLowerCase} from '../utils/utils.js'

libs_drpy/moduleLoader.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ const customRequire = createRequire(import.meta.url);
1313

1414
// 导出 rootRequire
1515
export const rootRequire = (modulePath) => {
16+
// 处理内置模块或打包模块
17+
if (modulePath === 'iconv-lite') return globalThis.iconv;
18+
if (modulePath === 'axios') return globalThis.axios;
19+
if (modulePath === 'cheerio') return globalThis.cheerio;
20+
if (modulePath === 'qs') return globalThis.qs;
21+
if (modulePath === 'crypto-js') return globalThis.CryptoJS;
22+
if (modulePath === 'fs' && globalThis.fs) return globalThis.fs;
23+
if (modulePath === 'path' && globalThis.path) return globalThis.path;
24+
1625
if (modulePath.startsWith('./') || modulePath.startsWith('../')) {
1726
const absolutePath = path.resolve(LIB_ROOT, modulePath);
1827
return customRequire(absolutePath);

0 commit comments

Comments
 (0)