ddan-js 2.9.4 → 2.9.6

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.
Files changed (131) hide show
  1. package/bin/types/browser.d.ts +1 -1
  2. package/bin/types/index.d.ts +1 -1
  3. package/bin/types/modules/node/aliyun.d.ts +1 -1
  4. package/bin/types/upload.d.ts +2 -0
  5. package/bin/upload.js +1 -0
  6. package/package.json +18 -13
  7. package/bin/lib/browser.js +0 -111
  8. package/bin/lib/class/event.js +0 -104
  9. package/bin/lib/class/getset.js +0 -12
  10. package/bin/lib/class/icon.js +0 -94
  11. package/bin/lib/class/joker.js +0 -121
  12. package/bin/lib/class/kvalue.js +0 -29
  13. package/bin/lib/class/mapping.js +0 -82
  14. package/bin/lib/class/persist.js +0 -65
  15. package/bin/lib/class/pipeTask.js +0 -42
  16. package/bin/lib/class/pipeparallel.js +0 -24
  17. package/bin/lib/class/store.js +0 -87
  18. package/bin/lib/class/tracker.js +0 -125
  19. package/bin/lib/class/watermark.js +0 -63
  20. package/bin/lib/common/_Symbol.js +0 -5
  21. package/bin/lib/common/_freeGlobal.js +0 -5
  22. package/bin/lib/common/_object.js +0 -40
  23. package/bin/lib/common/_root.js +0 -10
  24. package/bin/lib/common/internal/asciiToArray.js +0 -13
  25. package/bin/lib/common/internal/castSlice.js +0 -18
  26. package/bin/lib/common/internal/createCaseFirst.js +0 -30
  27. package/bin/lib/common/internal/hasUnicode.js +0 -26
  28. package/bin/lib/common/internal/nodeTypes.js +0 -26
  29. package/bin/lib/common/internal/slice.js +0 -46
  30. package/bin/lib/common/internal/stringToArray.js +0 -18
  31. package/bin/lib/common/internal/unicodeToArray.js +0 -40
  32. package/bin/lib/common/internal/unicodeWords.js +0 -67
  33. package/bin/lib/index.js +0 -114
  34. package/bin/lib/modules/browser/ecdh.js +0 -124
  35. package/bin/lib/modules/browser/index.js +0 -4
  36. package/bin/lib/modules/cdn.js +0 -62
  37. package/bin/lib/modules/convert/base.js +0 -125
  38. package/bin/lib/modules/convert/base64.js +0 -114
  39. package/bin/lib/modules/convert/index.js +0 -99
  40. package/bin/lib/modules/convert/md5.js +0 -222
  41. package/bin/lib/modules/convert/pkcs.js +0 -16
  42. package/bin/lib/modules/convert/utf8.js +0 -106
  43. package/bin/lib/modules/crypto/base64.js +0 -14
  44. package/bin/lib/modules/crypto/const.js +0 -7
  45. package/bin/lib/modules/crypto/index.js +0 -30
  46. package/bin/lib/modules/crypto/rsa.js +0 -143
  47. package/bin/lib/modules/crypto/tea.js +0 -79
  48. package/bin/lib/modules/crypto/uuid.js +0 -34
  49. package/bin/lib/modules/css.js +0 -137
  50. package/bin/lib/modules/decorator.js +0 -14
  51. package/bin/lib/modules/fetch.js +0 -82
  52. package/bin/lib/modules/gbk.js +0 -46
  53. package/bin/lib/modules/hook/base.js +0 -60
  54. package/bin/lib/modules/hook/hooker.js +0 -39
  55. package/bin/lib/modules/hook/index.js +0 -49
  56. package/bin/lib/modules/hook/log.js +0 -54
  57. package/bin/lib/modules/hook/modules/bezier.js +0 -121
  58. package/bin/lib/modules/hook/modules/debounce.js +0 -127
  59. package/bin/lib/modules/hook/modules/mutex.js +0 -22
  60. package/bin/lib/modules/hook/modules/pipeline.js +0 -59
  61. package/bin/lib/modules/hook/modules/polling.js +0 -20
  62. package/bin/lib/modules/hook/modules/safeTask.js +0 -25
  63. package/bin/lib/modules/hook/modules/throttle.js +0 -30
  64. package/bin/lib/modules/html.js +0 -293
  65. package/bin/lib/modules/http/index.js +0 -171
  66. package/bin/lib/modules/http/interceptor.js +0 -22
  67. package/bin/lib/modules/list/base.js +0 -37
  68. package/bin/lib/modules/list/index.js +0 -90
  69. package/bin/lib/modules/logger.js +0 -55
  70. package/bin/lib/modules/math/index.js +0 -118
  71. package/bin/lib/modules/mini/diff.js +0 -97
  72. package/bin/lib/modules/mini/http/index.js +0 -155
  73. package/bin/lib/modules/mini/index.js +0 -71
  74. package/bin/lib/modules/node/aliyun.js +0 -156
  75. package/bin/lib/modules/node/brotli.js +0 -46
  76. package/bin/lib/modules/node/child.js +0 -18
  77. package/bin/lib/modules/node/ecdh-web.js +0 -11
  78. package/bin/lib/modules/node/ecdh.js +0 -115
  79. package/bin/lib/modules/node/file.js +0 -25
  80. package/bin/lib/modules/node/index.js +0 -11
  81. package/bin/lib/modules/node/proxy.js +0 -147
  82. package/bin/lib/modules/node/rsa-web.js +0 -19
  83. package/bin/lib/modules/node/socks5.js +0 -424
  84. package/bin/lib/modules/obj/index.js +0 -184
  85. package/bin/lib/modules/qs/base.js +0 -5
  86. package/bin/lib/modules/qs/decode.js +0 -45
  87. package/bin/lib/modules/qs/encode.js +0 -53
  88. package/bin/lib/modules/qs/index.js +0 -152
  89. package/bin/lib/modules/regex.js +0 -16
  90. package/bin/lib/modules/rsa.js +0 -18
  91. package/bin/lib/modules/rule/async-validator/index.js +0 -306
  92. package/bin/lib/modules/rule/async-validator/interface.js +0 -2
  93. package/bin/lib/modules/rule/async-validator/messages.js +0 -59
  94. package/bin/lib/modules/rule/async-validator/rule/enum.js +0 -13
  95. package/bin/lib/modules/rule/async-validator/rule/index.js +0 -16
  96. package/bin/lib/modules/rule/async-validator/rule/pattern.js +0 -27
  97. package/bin/lib/modules/rule/async-validator/rule/range.js +0 -54
  98. package/bin/lib/modules/rule/async-validator/rule/required.js +0 -12
  99. package/bin/lib/modules/rule/async-validator/rule/type.js +0 -98
  100. package/bin/lib/modules/rule/async-validator/rule/url.js +0 -55
  101. package/bin/lib/modules/rule/async-validator/rule/whitespace.js +0 -20
  102. package/bin/lib/modules/rule/async-validator/util.js +0 -255
  103. package/bin/lib/modules/rule/async-validator/validator/any.js +0 -16
  104. package/bin/lib/modules/rule/async-validator/validator/array.js +0 -19
  105. package/bin/lib/modules/rule/async-validator/validator/boolean.js +0 -20
  106. package/bin/lib/modules/rule/async-validator/validator/date.js +0 -31
  107. package/bin/lib/modules/rule/async-validator/validator/enum.js +0 -20
  108. package/bin/lib/modules/rule/async-validator/validator/float.js +0 -20
  109. package/bin/lib/modules/rule/async-validator/validator/index.js +0 -36
  110. package/bin/lib/modules/rule/async-validator/validator/integer.js +0 -20
  111. package/bin/lib/modules/rule/async-validator/validator/method.js +0 -19
  112. package/bin/lib/modules/rule/async-validator/validator/number.js +0 -23
  113. package/bin/lib/modules/rule/async-validator/validator/object.js +0 -19
  114. package/bin/lib/modules/rule/async-validator/validator/pattern.js +0 -19
  115. package/bin/lib/modules/rule/async-validator/validator/regexp.js +0 -19
  116. package/bin/lib/modules/rule/async-validator/validator/required.js +0 -10
  117. package/bin/lib/modules/rule/async-validator/validator/string.js +0 -24
  118. package/bin/lib/modules/rule/async-validator/validator/type.js +0 -20
  119. package/bin/lib/modules/rule/index.js +0 -67
  120. package/bin/lib/modules/string/index.js +0 -121
  121. package/bin/lib/modules/string/words.js +0 -33
  122. package/bin/lib/modules/time/const.js +0 -11
  123. package/bin/lib/modules/time/dtime.js +0 -132
  124. package/bin/lib/modules/time/frame.js +0 -49
  125. package/bin/lib/modules/time/index.js +0 -84
  126. package/bin/lib/typings/index.js +0 -2
  127. package/bin/lib/util/function.js +0 -33
  128. package/bin/lib/util/includes.js +0 -96
  129. package/bin/lib/util/index.js +0 -26
  130. package/bin/lib/util/is.js +0 -148
  131. package/bin/lib/util/to.js +0 -47
@@ -1,4 +1,4 @@
1
- export { Ddan } from './typings';
1
+ export type { Ddan } from './typings';
2
2
  import Http from './modules/http';
3
3
  import Event from './class/event';
4
4
  import Store from './class/store';
@@ -1,4 +1,4 @@
1
- export { Ddan } from './typings';
1
+ export type { Ddan } from './typings';
2
2
  import Http from './modules/http';
3
3
  import Event from './class/event';
4
4
  import Store from './class/store';
@@ -5,7 +5,7 @@ export default class Aliyun {
5
5
  accessKeyId: string;
6
6
  accessKeySecret: string;
7
7
  region: string;
8
- __oss: OSS;
8
+ __oss?: OSS;
9
9
  __cdn: any;
10
10
  constructor({ bucket, accessKeyId, accessKeySecret, region }: {
11
11
  bucket: any;
@@ -0,0 +1,2 @@
1
+ import Aliyun from './modules/node/aliyun';
2
+ export { Aliyun };
package/bin/upload.js ADDED
@@ -0,0 +1 @@
1
+ import e from"ali-oss";import t from"@alicloud/pop-core";class r{bucket;accessKeyId;accessKeySecret;region;__oss;__cdn;constructor({bucket:e,accessKeyId:t,accessKeySecret:r,region:c}){this.bucket=e,this.accessKeyId=t,this.accessKeySecret=r,this.region=c}get client(){return this.__oss||(this.__oss=this._getOSS()),this.__oss}_getOSS(){return new e({region:this.region,accessKeyId:this.accessKeyId,accessKeySecret:this.accessKeySecret,bucket:this.bucket})}async read(e){try{if(!await this.exist(e))return"";const t=await this.client.get(e);return t.content?.toString()||""}catch(t){return void console.log(`aliyun read ${e} error`,t)}}async delete(e){try{return await this.client.delete(e),!0}catch(t){return console.log(`aliyun delete ${e} error`,t),!1}}async exist(e,t={}){try{return await this.client.head(e,t),!0}catch(e){return!1}}async upload(e,t){try{return!(!e||!t)&&(await this.client.put(e,t),!0)}catch(e){return console.log(`aliyun upload ${t} error`,e),!1}}async put(e,t){try{return!(!e||!t)&&(await this.client.put(e,Buffer.from(t)),!0)}catch(t){return console.log(`aliyun put content ${e} error`,t),!1}}async putSymlink(e,t){try{if(!e||!t)return!1;return await this.client.putSymlink(e,t)}catch(e){return!1}}async browse(e,t){let r,c=!1;const s=e.endsWith("/")?e:`${e}/`;try{do{const e=await this.client.listV2({prefix:s,"continuation-token":r,"max-keys":"50"},{});for(let r of e.objects||[])t&&await t(r.name);r=e.nextContinuationToken,c=e.isTruncated}while(c);return!0}catch(t){return console.log(`aliyun browse ${e} error`,t),!1}}get cdn(){return this.__cdn||(this.__cdn=new t({accessKeyId:this.accessKeyId,accessKeySecret:this.accessKeySecret,endpoint:"https://cdn.aliyuncs.com",apiVersion:"2018-05-10"})),this.__cdn}async refreshCDN(e,t="File"){try{let r={ObjectPath:e,ObjectType:t};const c={method:"POST",formatParams:!1};return await this.cdn.request("RefreshObjectCaches",r,c),!0}catch(t){return console.log(`aliyun refreshCDN ${e} err`,t),!1}}}export{r as Aliyun};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ddan-js",
3
- "version": "2.9.4",
3
+ "version": "2.9.6",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "ddan-js",
@@ -41,18 +41,11 @@
41
41
  "scripts": {
42
42
  "lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
43
43
  "prebuild": "rimraf bin",
44
- "build": "tsc --module commonjs && rollup -c rollup.config.ts && typedoc --out docs src/index.ts --theme default",
44
+ "build": "rollup -c rollup.config.ts",
45
45
  "start": "rollup -c rollup.config.ts -w",
46
46
  "test": "jest --coverage",
47
- "test:watch": "jest --coverage --watch",
48
47
  "test:prod": "npm run lint && npm run test -- --no-cache",
49
- "deploy-docs": "ts-node tools/gh-pages-publish",
50
- "report-coverage": "cat ./coverage/lcov.info | coveralls",
51
- "commit": "git-cz",
52
- "semantic-release": "semantic-release",
53
- "semantic-release-prepare": "ts-node tools/semantic-release-prepare",
54
- "precommit": "lint-staged",
55
- "travis-deploy-once": "travis-deploy-once"
48
+ "precommit": "lint-staged"
56
49
  },
57
50
  "lint-staged": {
58
51
  "{src,test}/**/*.ts": [
@@ -66,8 +59,11 @@
66
59
  }
67
60
  },
68
61
  "jest": {
62
+ "preset": "ts-jest",
69
63
  "transform": {
70
- ".(ts|tsx)": "ts-jest"
64
+ "^.+\\.(ts|tsx)$": ["ts-jest", {
65
+ "isolatedModules": true
66
+ }]
71
67
  },
72
68
  "testEnvironment": "node",
73
69
  "testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
@@ -90,6 +86,12 @@
90
86
  },
91
87
  "collectCoverageFrom": [
92
88
  "src/*.{js,ts}"
89
+ ],
90
+ "transformIgnorePatterns": [
91
+ "/node_modules/(?!ali-oss)"
92
+ ],
93
+ "testPathIgnorePatterns": [
94
+ "/node_modules/"
93
95
  ]
94
96
  },
95
97
  "prettier": {
@@ -103,15 +105,18 @@
103
105
  },
104
106
  "devDependencies": {
105
107
  "@alicloud/pop-core": "^1.7.12",
106
- "ali-oss": "^6.17.1",
107
- "@types/ali-oss": "^6.16.7",
108
+ "@babel/core": "^7.26.0",
109
+ "@babel/preset-env": "^7.26.0",
110
+ "@babel/preset-typescript": "^7.26.0",
108
111
  "@commitlint/cli": "^17.6.1",
109
112
  "@commitlint/config-conventional": "^17.6.1",
110
113
  "@rollup/plugin-node-resolve": "^15.1.0",
114
+ "@types/ali-oss": "^6.16.7",
111
115
  "@types/babel__core": "7.1.19",
112
116
  "@types/babel__traverse": "7.17.1",
113
117
  "@types/jest": "^23.3.2",
114
118
  "@types/node": "^16.18.0",
119
+ "ali-oss": "^6.17.1",
115
120
  "colors": "^1.4.0",
116
121
  "commitizen": "^4.3.0",
117
122
  "coveralls": "^3.1.1",
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Mapping = exports.KValue = exports.Event = exports.dLogger = exports.dTracker = exports.dJoker = exports.dStore = exports.dCdn = exports.dMini = exports.dWeb = exports.dHook = exports.dUtil = void 0;
4
- const gbk_1 = require("./modules/gbk");
5
- const time_1 = require("./modules/time");
6
- const hook_1 = require("./modules/hook");
7
- const math_1 = require("./modules/math");
8
- const util_1 = require("./util");
9
- const list_1 = require("./modules/list");
10
- const mini_1 = require("./modules/mini");
11
- const qs_1 = require("./modules/qs");
12
- const rule_1 = require("./modules/rule");
13
- const regex_1 = require("./modules/regex");
14
- const string_1 = require("./modules/string");
15
- const obj_1 = require("./modules/obj");
16
- const crypto_1 = require("./modules/crypto");
17
- const css_1 = require("./modules/css");
18
- const html_1 = require("./modules/html");
19
- const cdn_1 = require("./modules/cdn");
20
- const convert_1 = require("./modules/convert");
21
- const http_1 = require("./modules/http");
22
- const logger_1 = require("./modules/logger");
23
- const fetch_1 = require("./modules/fetch");
24
- const icon_1 = require("./class/icon");
25
- const event_1 = require("./class/event");
26
- exports.Event = event_1.default;
27
- const store_1 = require("./class/store");
28
- const persist_1 = require("./class/persist");
29
- const watermark_1 = require("./class/watermark");
30
- const joker_1 = require("./class/joker");
31
- const tracker_1 = require("./class/tracker");
32
- const rsa_1 = require("./modules/rsa");
33
- const browser_1 = require("./modules/browser");
34
- const kvalue_1 = require("./class/kvalue");
35
- exports.KValue = kvalue_1.default;
36
- const mapping_1 = require("./class/mapping");
37
- exports.Mapping = mapping_1.default;
38
- const dUtil = {
39
- gbk: gbk_1.default,
40
- math: math_1.default,
41
- list: list_1.default,
42
- string: string_1.default,
43
- time: time_1.default,
44
- obj: obj_1.default,
45
- rule: rule_1.default,
46
- regex: regex_1.default,
47
- ...convert_1.default,
48
- ...crypto_1.default,
49
- ...util_1.default,
50
- Event: event_1.default,
51
- };
52
- exports.dUtil = dUtil;
53
- const singleton = util_1.default.singleton;
54
- const dHook = {
55
- ...convert_1.default,
56
- ...crypto_1.default,
57
- ...hook_1.default,
58
- ...string_1.default,
59
- ...math_1.default,
60
- qs: qs_1.default,
61
- singleton,
62
- };
63
- exports.dHook = dHook;
64
- const dMini = { mini: mini_1.default, css: css_1.default, qs: qs_1.default, icon: icon_1.default, html: html_1.default };
65
- exports.dMini = dMini;
66
- const dCdn = { cdn: cdn_1.default, watermark: watermark_1.default };
67
- exports.dCdn = dCdn;
68
- const dStore = { Store: store_1.default, storeRef: store_1.storeRef, Persist: persist_1.default, persistConfig: persist_1.persistConfig };
69
- exports.dStore = dStore;
70
- const dJoker = joker_1.default;
71
- exports.dJoker = dJoker;
72
- const dTracker = tracker_1.default;
73
- exports.dTracker = dTracker;
74
- const dLogger = logger_1.default;
75
- exports.dLogger = dLogger;
76
- const dWeb = { fetch: fetch_1.default, Http: http_1.default, css: css_1.default, qs: qs_1.default, icon: icon_1.default, html: html_1.default, rsa: rsa_1.default, ...browser_1.default };
77
- exports.dWeb = dWeb;
78
- exports.default = {
79
- gbk: gbk_1.default,
80
- time: time_1.default,
81
- hook: hook_1.default,
82
- math: math_1.default,
83
- util: util_1.default,
84
- list: list_1.default,
85
- string: string_1.default,
86
- obj: obj_1.default,
87
- crypto: crypto_1.default,
88
- mini: mini_1.default,
89
- qs: qs_1.default,
90
- css: css_1.default,
91
- cdn: cdn_1.default,
92
- html: html_1.default,
93
- icon: icon_1.default,
94
- rule: rule_1.default,
95
- regex: regex_1.default,
96
- convert: convert_1.default,
97
- KValue: kvalue_1.default,
98
- Mapping: mapping_1.default,
99
- Event: event_1.default,
100
- Http: http_1.default,
101
- Store: store_1.default,
102
- storeRef: store_1.storeRef,
103
- Persist: persist_1.default,
104
- persistConfig: persist_1.persistConfig,
105
- watermark: watermark_1.default,
106
- joker: joker_1.default,
107
- tracker: tracker_1.default,
108
- logger: logger_1.default,
109
- fetch: fetch_1.default,
110
- rsa: rsa_1.default,
111
- };
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const uuid_1 = require("../modules/crypto/uuid");
4
- class DEvent {
5
- __map;
6
- __tagList;
7
- __eventId = '';
8
- constructor() {
9
- this.__map = new Map();
10
- this.__tagList = [];
11
- this.__eventId = (0, uuid_1.default)();
12
- }
13
- clear() {
14
- this.__map.clear();
15
- return this;
16
- }
17
- /**
18
- * 监听
19
- * @param name
20
- * @param listener
21
- * @returns
22
- */
23
- on(name, listener, tag = '') {
24
- if (!name || !listener)
25
- return this;
26
- let handlers = this.__map.get(name);
27
- if (!handlers) {
28
- handlers = new Set();
29
- this.__map.set(name, handlers);
30
- }
31
- handlers.add(listener);
32
- tag && this.__tagList.push({ name, listener, tag });
33
- return this;
34
- }
35
- emit(name, ...args) {
36
- if (!name)
37
- return this;
38
- const set = this.__map.get(name);
39
- if (!set)
40
- return this;
41
- const copied = [...set];
42
- copied.forEach((fn) => fn && fn(...args));
43
- return this;
44
- }
45
- /**
46
- * 取消监听
47
- * @param name
48
- * @param listener
49
- * @returns
50
- */
51
- off(name, listener) {
52
- if (!name || !listener)
53
- return this;
54
- this.__tagList = this.__tagList.filter((e) => e.name !== name || e.listener !== listener);
55
- const handlers = this.__map.get(name);
56
- if (!handlers)
57
- return this;
58
- handlers.delete(listener);
59
- if (handlers.size <= 0) {
60
- this.__map.delete(name);
61
- }
62
- return this;
63
- }
64
- /**
65
- * 移除
66
- * @param name
67
- * @returns
68
- */
69
- remove(name) {
70
- if (!name)
71
- return this;
72
- this.__tagList = this.__tagList.filter((e) => e.name !== name);
73
- this.__map.delete(name);
74
- return this;
75
- }
76
- removeByTag(tag) {
77
- if (!tag)
78
- return this;
79
- const _list = this.__tagList.filter((e) => e.tag === tag);
80
- _list.forEach((e) => {
81
- this.off(e.name, e.listener);
82
- });
83
- this.__tagList = this.__tagList.filter((e) => e.tag !== tag);
84
- return this;
85
- }
86
- /**
87
- * 一次性监听
88
- * @param name
89
- * @param listener
90
- * @returns
91
- */
92
- once(name, listener) {
93
- const warpper = (...args) => {
94
- listener(...args);
95
- this.off(name, warpper);
96
- };
97
- this.on(name, warpper);
98
- return this;
99
- }
100
- has(name) {
101
- return this.__map.has(name);
102
- }
103
- }
104
- exports.default = DEvent;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class Getset {
4
- __value = undefined;
5
- set(value) {
6
- this.__value = value;
7
- }
8
- get() {
9
- return this.__value;
10
- }
11
- }
12
- exports.default = Getset;
@@ -1,94 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DIcon = void 0;
4
- const base64_1 = require("../modules/crypto/base64");
5
- class DIcon {
6
- __defStyle = 'vertical-align: middle; mask-position: 50% 50%; mask-repeat: no-repeat; mask-size: 100%; -webkit-mask-position: 50% 50%; -webkit-mask-repeat: no-repeat; -webkit-mask-size: 100%; background-color: currentColor;';
7
- __map = {
8
- back: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M609.408 149.376L277.76 489.6a32 32 0 0 0 0 44.672l331.648 340.352a29.12 29.12 0 0 0 41.728 0 30.592 30.592 0 0 0 0-42.752L339.264 511.936l311.872-319.872a30.592 30.592 0 0 0 0-42.688 29.12 29.12 0 0 0-41.728 0z"/></svg>',
9
- right: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M340.864 149.312a30.592 30.592 0 0 0 0 42.752L652.736 512 340.864 831.872a30.592 30.592 0 0 0 0 42.752 29.12 29.12 0 0 0 41.728 0L714.24 534.336a32 32 0 0 0 0-44.672L382.592 149.376a29.12 29.12 0 0 0-41.728 0z"/></svg>',
10
- home: '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13 19.8h3.8v-7h3.303L12 4.697 3.897 12.8H7.2v7H11V17h2v2.8zm5 .2a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-6H3.414a1 1 0 0 1-.707-1.707l8.586-8.586a1 1 0 0 1 1.414 0l8.586 8.586A1 1 0 0 1 20.586 14H18v6z" fill-rule="evenodd" fill-opacity=".9"/></svg>',
11
- close: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M764.288 214.592L512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"/></svg>',
12
- close_circle: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M466.752 512l-90.496-90.496a32 32 0 0 1 45.248-45.248L512 466.752l90.496-90.496a32 32 0 1 1 45.248 45.248L557.248 512l90.496 90.496a32 32 0 1 1-45.248 45.248L512 557.248l-90.496 90.496a32 32 0 0 1-45.248-45.248L466.752 512z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',
13
- close_circle_fill: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm0 393.664L407.936 353.6a38.4 38.4 0 1 0-54.336 54.336L457.664 512 353.6 616.064a38.4 38.4 0 1 0 54.336 54.336L512 566.336 616.064 670.4a38.4 38.4 0 1 0 54.336-54.336L566.336 512 670.4 407.936a38.4 38.4 0 1 0-54.336-54.336L512 457.664z"/></svg>',
14
- warning: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M928.99 755.83L574.6 203.25c-12.89-20.16-36.76-32.58-62.6-32.58s-49.71 12.43-62.6 32.58L95.01 755.83c-12.91 20.12-12.9 44.91.01 65.03 12.92 20.12 36.78 32.51 62.59 32.49h708.78c25.82.01 49.68-12.37 62.59-32.49 12.91-20.12 12.92-44.91.01-65.03zM554.67 768h-85.33v-85.33h85.33V768zm0-426.67v298.66h-85.33V341.32l85.33.01z" fill="currentColor"/></svg>',
15
- play: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M512 1024A512 512 0 1 1 512 0a512 512 0 0 1 0 1024zm3.008-92.992a416 416 0 1 0 0-832 416 416 0 0 0 0 832zM383.232 287.616l384 224.896-384 223.104v-448z" fill="currentColor"/></svg>',
16
- lock: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M224 448a32 32 0 0 0-32 32v384a32 32 0 0 0 32 32h576a32 32 0 0 0 32-32V480a32 32 0 0 0-32-32H224zm0-64h576a96 96 0 0 1 96 96v384a96 96 0 0 1-96 96H224a96 96 0 0 1-96-96V480a96 96 0 0 1 96-96z"/><path fill="currentColor" d="M512 544a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V576a32 32 0 0 1 32-32zm192-160v-64a192 192 0 1 0-384 0v64h384zM512 64a256 256 0 0 1 256 256v128H256V320A256 256 0 0 1 512 64z"/></svg>',
17
- lock_fill: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path d="M467.2 713.92v115.968a44.8 44.8 0 0 0 89.6 0V713.92c26.752-14.72 44.8-42.304 44.8-73.92 0-47.104-40.128-85.312-89.6-85.312-49.472 0-89.6 38.208-89.6 85.312 0 31.616 18.048 59.136 44.8 73.92zM64 384h896v640H64V384zm268.8 0h358.4V256c0-94.272-80.256-170.688-179.2-170.688-98.944 0-179.2 76.416-179.2 170.688v128zM512 0c148.48 0 268.8 114.56 268.8 256v128H243.2V256C243.2 114.56 363.52 0 512 0z" fill="currentColor"/></svg>',
18
- plus: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M480 480V128a32 32 0 0 1 64 0v352h352a32 32 0 1 1 0 64H544v352a32 32 0 1 1-64 0V544H128a32 32 0 0 1 0-64h352z"/></svg>',
19
- plus_circle: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M352 480h320a32 32 0 1 1 0 64H352a32 32 0 0 1 0-64z"/><path fill="currentColor" d="M480 672V352a32 32 0 1 1 64 0v320a32 32 0 0 1-64 0z"/><path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768zm0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896z"/></svg>',
20
- plus_circle_fill: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896zm-38.4 409.6H326.4a38.4 38.4 0 1 0 0 76.8h147.2v147.2a38.4 38.4 0 0 0 76.8 0V550.4h147.2a38.4 38.4 0 0 0 0-76.8H550.4V326.4a38.4 38.4 0 1 0-76.8 0v147.2z"/></svg>',
21
- star: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M512 747.84l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72L512 747.84zM313.6 924.48a70.4 70.4 0 0 1-102.144-74.24l37.888-220.928L88.96 472.96A70.4 70.4 0 0 1 128 352.896l221.76-32.256 99.2-200.96a70.4 70.4 0 0 1 126.208 0l99.2 200.96 221.824 32.256a70.4 70.4 0 0 1 39.04 120.064L774.72 629.376l37.888 220.928a70.4 70.4 0 0 1-102.144 74.24L512 820.096l-198.4 104.32z"/></svg>',
22
- star_fill: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M283.84 867.84L512 747.776l228.16 119.936a6.4 6.4 0 0 0 9.28-6.72l-43.52-254.08 184.512-179.904a6.4 6.4 0 0 0-3.52-10.88l-255.104-37.12L517.76 147.904a6.4 6.4 0 0 0-11.52 0L392.192 379.072l-255.104 37.12a6.4 6.4 0 0 0-3.52 10.88L318.08 606.976l-43.584 254.08a6.4 6.4 0 0 0 9.28 6.72z"/></svg>',
23
- share: '<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg"><path fill="currentColor" d="M679.872 348.8l-301.76 188.608a127.808 127.808 0 0 1 5.12 52.16l279.936 104.96a128 128 0 1 1-22.464 59.904l-279.872-104.96a128 128 0 1 1-16.64-166.272l301.696-188.608a128 128 0 1 1 33.92 54.272z"/></svg>',
24
- love: '<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M171.712 571.648l.352.32 287.904 252.8a64 64 0 0 0 82.912 1.344l296.832-244.544a215.584 215.584 0 1 0-301.824-300.576L512 316.672l-25.888-35.616a215.584 215.584 0 1 0-314.4 290.624zM32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512l-295.36 243.392a128 128 0 0 1-165.888-2.592L129.984 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>',
25
- love_fill: '<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M32 407.584A279.584 279.584 0 0 1 512 212.64a279.584 279.584 0 0 1 480 194.944 278.144 278.144 0 0 1-113.024 224.512L562.592 892.8a96 96 0 0 1-124.416-1.952L130.016 620.16A278.976 278.976 0 0 1 32 407.584z"/></svg>'
26
- };
27
- getBase64 = (svgType) => {
28
- const _svg = this.getSVG(svgType);
29
- return _svg?.url || "";
30
- };
31
- getSVG = (svgType) => {
32
- if (!svgType)
33
- return undefined;
34
- const _svg = this.__map[svgType];
35
- if (!_svg)
36
- return undefined;
37
- const url = this.toBase64(_svg);
38
- const escape = this.toEscape(_svg);
39
- return { url, escape };
40
- };
41
- toBase64 = (svgxml) => {
42
- if (!svgxml)
43
- return "";
44
- const _svg = this._tiny(svgxml);
45
- return `data:image/svg+xml;base64,${base64_1.default.encode(_svg)}`;
46
- };
47
- _tiny = (svgxml) => {
48
- if (!svgxml)
49
- return "";
50
- return svgxml
51
- .replace(/<!--(.*)-->/g, "") // 必须去掉注释
52
- .replace(/[\r\n]/g, " ") // 去掉换行
53
- .replace(/"/g, `'`); // 单引号是保留字符,双引号改成单引号减少编码
54
- };
55
- toEscape = (svgxml) => {
56
- if (!svgxml)
57
- return "";
58
- const _svg = this._tiny(svgxml)
59
- .replace(/%/g, "%25")
60
- .replace(/&/g, "%26")
61
- .replace(/#/g, "%23")
62
- .replace(/{/g, "%7B")
63
- .replace(/}/g, "%7D")
64
- .replace(/</g, "%3C")
65
- .replace(/>/g, "%3E");
66
- return `data:image/svg+xml,${_svg}`;
67
- };
68
- getStyle(svgType, options = {}) {
69
- if (!svgType)
70
- return "";
71
- const _svg = this.__map[svgType];
72
- if (!_svg)
73
- return "";
74
- return this.toStyle(_svg, options);
75
- }
76
- toStyle(svgxml, options = {}) {
77
- if (!svgxml)
78
- return "";
79
- const url = this.toBase64(svgxml);
80
- if (!url)
81
- return "";
82
- return this.getStyleByUrl(url, options);
83
- }
84
- getStyleByUrl(urlData, options = {}) {
85
- if (!urlData)
86
- return "";
87
- const { key = "mask-image", gradientValue = "radial-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5))", gradient = false, defStyle = this.__defStyle } = options;
88
- const _value = (gradient && gradientValue) ? `${gradientValue}, url("${urlData}")` : `url("${urlData}")`;
89
- return `${key}:${_value};-webkit-${key}:${_value};${defStyle}`;
90
- }
91
- }
92
- exports.DIcon = DIcon;
93
- const icon = new DIcon();
94
- exports.default = icon;
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Joker = void 0;
4
- const store_1 = require("./store");
5
- const frame_1 = require("../modules/time/frame");
6
- const time_1 = require("../modules/time");
7
- const util_1 = require("../util");
8
- const pipeparallel_1 = require("./pipeparallel");
9
- class Joker {
10
- state = (0, store_1.storeRef)(new store_1.default());
11
- frame = new frame_1.default();
12
- cache = new Map();
13
- cacheTime = new Map();
14
- setCache = (cacheId, cached) => {
15
- if (cached === null || cached === undefined)
16
- return false;
17
- if (!cacheId)
18
- return false;
19
- this.cache.set(cacheId, cached);
20
- this.cacheTime.set(cacheId, Date.now());
21
- return true;
22
- };
23
- hasCache = (id) => {
24
- if (!id)
25
- return false;
26
- this.cache.has(id);
27
- };
28
- getCache = (id) => {
29
- if (!id)
30
- return undefined;
31
- return this.cache.get(id);
32
- };
33
- getCacheTime = (id) => {
34
- if (!id)
35
- return 0;
36
- return this.cacheTime.get(id) || 0;
37
- };
38
- removeCache = (id) => {
39
- if (!id)
40
- return;
41
- this.cache.delete(id);
42
- this.cacheTime.delete(id);
43
- };
44
- cacheId = (prefix) => `_${prefix}_cache_`;
45
- /**
46
- * 触发次数记录
47
- * @param id
48
- * @param options
49
- * @returns
50
- */
51
- timesRecord = (id, options = {}) => {
52
- if (!id)
53
- return undefined;
54
- const { mode = "running", cycle = "day" } = options || {};
55
- const cacheId = this.cacheId(mode);
56
- const _cacheRecord = this.getCache(cacheId) || {};
57
- const _now = Date.now();
58
- const _data = _cacheRecord[id];
59
- const newData = { time: _now, count: 1, cycle };
60
- if (_data) {
61
- if (cycle === "day" && !time_1.default.isToday(_data.time || 0)) {
62
- }
63
- else {
64
- newData.count = 1 + (_data.count || 0);
65
- }
66
- }
67
- _cacheRecord[id] = newData;
68
- this.setCache(cacheId, _cacheRecord);
69
- return _cacheRecord;
70
- };
71
- /**
72
- * 检测是否可以触发
73
- * @param id
74
- * @param options
75
- * @returns
76
- */
77
- timesValid = (id, options = {}) => {
78
- if (!id)
79
- return false;
80
- const { max = 1, interval = 0, mode = "running", cycle = "day" } = options || {};
81
- const cacheId = this.cacheId(mode);
82
- let _cacheRecord = this.getCache(cacheId);
83
- if (!_cacheRecord)
84
- return true;
85
- const _data = _cacheRecord[id];
86
- if (!_data)
87
- return true;
88
- if (cycle === "day" && !time_1.default.isToday(_data.time || 0))
89
- return true;
90
- if (max <= (_data.count || 0))
91
- return false;
92
- const delta = Date.now() - (_data.time || 0);
93
- if (delta < interval)
94
- return false;
95
- return true;
96
- };
97
- /**
98
- * 清理触发次数数据
99
- * @param mode
100
- * @returns
101
- */
102
- timesClean = (mode = "running") => {
103
- const cacheId = this.cacheId(mode);
104
- const _cacheRecord = this.getCache(cacheId);
105
- if (!_cacheRecord)
106
- return;
107
- const _temp = util_1.default.copy(_cacheRecord);
108
- util_1.default.forof(_temp, (k, v) => {
109
- if (v.cycle === "day" || v.cycle === undefined) {
110
- if (!time_1.default.isToday(v.time || 0)) {
111
- delete _cacheRecord[k];
112
- }
113
- }
114
- });
115
- this.setCache(cacheId, _cacheRecord);
116
- };
117
- parallel = () => new pipeparallel_1.default();
118
- }
119
- exports.Joker = Joker;
120
- const joker = new Joker();
121
- exports.default = joker;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class KValue {
4
- timestamp = 0;
5
- _key = '';
6
- _value;
7
- constructor(key, value) {
8
- this._key = key;
9
- this._value = value;
10
- this.updateAt();
11
- }
12
- get key() {
13
- return this._key;
14
- }
15
- get value() {
16
- return this._value;
17
- }
18
- set(value) {
19
- this._value = value;
20
- this.updateAt();
21
- }
22
- updateAt() {
23
- this.timestamp = Date.now();
24
- }
25
- clear() {
26
- this.set(undefined);
27
- }
28
- }
29
- exports.default = KValue;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const kvalue_1 = require("./kvalue");
4
- class Mapping {
5
- _map = new Map();
6
- constructor() {
7
- this._map.clear();
8
- }
9
- get keys() {
10
- return Array.from(this._map.keys());
11
- }
12
- get values() {
13
- return Array.from(this._map.values());
14
- }
15
- get(key) {
16
- if (!key)
17
- return undefined;
18
- const kv = this._map.get(key);
19
- if (!kv)
20
- return undefined;
21
- return kv.value;
22
- }
23
- getKV(key) {
24
- if (!key)
25
- return undefined;
26
- return this._map.get(key);
27
- }
28
- set(key, value) {
29
- if (!key)
30
- return;
31
- const kv = this._map.get(key);
32
- if (!kv) {
33
- this._map.set(key, new kvalue_1.default(key, value));
34
- return;
35
- }
36
- else {
37
- kv.set(value);
38
- }
39
- this.clean();
40
- }
41
- delete(key, cb) {
42
- if (!key)
43
- return;
44
- const kv = this._map.get(key);
45
- cb && cb(kv?.value);
46
- this._map.delete(key);
47
- }
48
- clear() {
49
- this._map.clear();
50
- }
51
- clean(max = 100, cb) {
52
- try {
53
- if (this._map.size <= max)
54
- return;
55
- const temps = this.keys.filter(key => {
56
- if (!this._map.has(key))
57
- return false;
58
- const kv = this._map.get(key);
59
- if (!kv)
60
- return true;
61
- return !kv.value;
62
- });
63
- temps.forEach(key => {
64
- this._map.delete(key);
65
- });
66
- if (this._map.size <= max)
67
- return;
68
- const vals = this.values.sort((kvA, kvB) => kvA.timestamp - kvB.timestamp);
69
- const count = vals.length - max;
70
- if (count <= 0)
71
- return;
72
- const removed = vals.splice(0, count);
73
- removed.forEach(kv => {
74
- this.delete(kv.key, cb);
75
- });
76
- }
77
- catch (error) {
78
- console.log(`mapping clean`, error);
79
- }
80
- }
81
- }
82
- exports.default = Mapping;