Skip to content

Commit 6e03698

Browse files
author
Taois
committed
feat: 更新drpy-core轻量打包
1 parent 6c649d9 commit 6e03698

16 files changed

+5840
-15
lines changed

dist/drpy-core-lite.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "drpy-webpack",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"main": "webpack.config.js",
5-
"type": "module",
5+
66
"scripts": {
77
"build": "webpack --config webpack.config.js"
88
},

readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
## drpy_webpack
22

3-
drpy2框架的打包项目。所有依赖打包成一个drpy-core.min.js
3+
drpy2框架的打包项目。所有依赖打包成一个`drpy-core.min.js` `drpy-core-lite.min.js`
44

5-
当前版本号: `3.9.52beta2 20250729`
5+
[drpyS项目传送门](https://github.com/hjdhnx/drpy-node)
6+
7+
当前版本号: `3.9.52beta3 20250801`
68

79
注意复制到drpyS项目 `public/drpy` 目录前需要把 init_test里的一些调试日志注释掉
810

src/drpy-core-lite.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// drpy-core.js
2+
import template from './libs/模板.js'; // 使用英文名导入
3+
4+
// 轻量依赖
5+
import './libs-lite/EncoderDecoder.min.js'
6+
// import './libs-lite/jsencrypt.min.js'; // 此库亲自不行
7+
// 导入所有依赖库
8+
import './libs/jsencrypt.min.js';
9+
import './libs/gb18030.min.js';
10+
import './libs/crypto-js.min.js';
11+
import './libs/node-rsa.min.js';
12+
import './libs/pako.min.js';
13+
import './libs/json5.min.js';
14+
import './libs/jsonpathplus.min.js';
15+
import './libs/jinja.min.js';
16+
import './libs/polywasm.min.js';
17+
import './libs/xxhash-wasm.min.js';
18+
19+
20+
// 确保全局依赖可用
21+
22+
const gbkTool = globalThis.gbkTool;
23+
const CryptoJS = globalThis.CryptoJS;
24+
const JSEncrypt = globalThis.JSEncrypt;
25+
const NODERSA = globalThis.NODERSA; // lite版弃用
26+
const pako = globalThis.pako;
27+
const JSON5 = globalThis.JSON5;
28+
const JSONPath = globalThis.JSONPath;
29+
const jinja = globalThis.jinja;
30+
const WebAssembly = globalThis.WebAssembly;
31+
const TextEncoder = globalThis.TextEncoder;
32+
const TextDecoder = globalThis.TextDecoder;
33+
34+
/*
35+
patch打补丁开始
36+
1. cheerio对象 只保留在用的jinja2和jp函数,其他pdf系列交给壳子
37+
2. JSEncrypt换库但是保留encryptUnicodeLong和decryptUnicodeLong函数
38+
*/
39+
const cheerio = {
40+
jinja2(template, obj) {
41+
return jinja.render(template, obj);
42+
},
43+
jp(path, json) {
44+
return JSONPath.JSONPath({
45+
path,
46+
json
47+
})[0];
48+
}
49+
}
50+
// JSEncrypt.encryptUnicodeLong = JSEncrypt.encryptLong;
51+
// JSEncrypt.decryptUnicodeLong = JSEncrypt.decryptLong;
52+
/*
53+
patch打补丁结束
54+
*/
55+
56+
// 导出所有需要暴露的内容
57+
export {
58+
cheerio,
59+
template as 模板, // 使用别名导出中文标识符
60+
gbkTool,
61+
CryptoJS,
62+
JSEncrypt,
63+
NODERSA,
64+
pako,
65+
JSON5,
66+
JSONPath,
67+
jinja,
68+
WebAssembly,
69+
TextEncoder,
70+
TextDecoder,
71+
};

src/drpy-test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import {cheerio, 模板} from '../dist/drpy-core.min.js';
1+
// import {cheerio, 模板} from '../dist/drpy-core.min.js';
2+
import {cheerio, 模板} from '../dist/drpy-core-lite.min.js';
23
// import {cheerio, JSONPath, TextDecoder, TextEncoder, 模板} from './drpy-core.js';
34

45
console.log('typeof 模板:', typeof (模板))

src/drpy2.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
import {cheerio, 模板} from '../dist/drpy-core.min.js';
1+
// import {cheerio, 模板} from '../dist/drpy-core.min.js';
2+
import {cheerio, 模板} from '../dist/drpy-core-lite.min.js';
23

34
let vercode = typeof (pdfl) === 'function' ? 'drpy2.1' : 'drpy2';
4-
const VERSION = vercode + ' 3.9.52beta2 20250729';
5+
const VERSION = vercode + ' 3.9.52beta3 20250801';
56
const UpdateInfo = [
7+
{
8+
date: '20250801',
9+
title: 'drpy依赖更新,使用drpy-core-lite.min.js',
10+
version: '3.9.52beta3 20250801',
11+
msg: `
12+
drpy-core.min.js 更换为更小的drpy-core-lite.min.js
13+
14+
`
15+
},
616
{
717
date: '20250729',
818
title: 'drpy更新,所有依赖打包成一个js文件',
@@ -64,10 +74,10 @@ function init_test() {
6474
// print(模板);
6575
// print(typeof(模板.getMubans));
6676
console.log("当前版本号:" + VERSION);
67-
77+
/*
6878
console.log('typeof 模板:', typeof (模板))
6979
console.log('typeof cheerio:', typeof (cheerio))
70-
// console.log(模板)
80+
// console.log(模板)
7181
console.log('typeof gbkTool:', typeof gbkTool);
7282
console.log('typeof CryptoJS:', typeof CryptoJS);
7383
console.log('typeof JSEncrypt:', typeof JSEncrypt);
@@ -91,7 +101,7 @@ function init_test() {
91101
92102
console.log(cheerio.jinja2('渲染一个变量{{hash}}', {hash}));
93103
console.log('jsonpath取值测试:', cheerio.jp('$.name', {name: '道长', project: 'drpys'}));
94-
104+
*/
95105

96106
console.log('本地代理地址:' + getProxyUrl());
97107
console.log(RKEY);

src/drpy2.min.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/gbk-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import './libs/gb18030.min.js';
2+
import './libs/encoding.min.js';
3+
import gbkTool1 from './libs-test/encoding-gbk.min.js';
4+
5+
console.log(gbkTool.encode('你好'));
6+
console.log(gbkTool.decode('%C4%E3%BA%C3'));
7+
8+
9+
console.log(gbkTool1.encode('你好'));
10+
console.log(gbkTool1.decode('%C4%E3%BA%C3'));

0 commit comments

Comments
 (0)