@pawover/kit 0.0.0-alpha.17 → 0.0.0-alpha.19

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.
@@ -96,7 +96,7 @@ function objectKeys(obj) {
96
96
  }
97
97
 
98
98
  //#endregion
99
- //#region node_modules/.pnpm/radashi@12.7.0/node_modules/radashi/dist/radashi.js
99
+ //#region node_modules/.pnpm/radashi@12.7.1/node_modules/radashi/dist/radashi.js
100
100
  function assign(initial, override) {
101
101
  if (!initial || !override) return initial ?? override ?? {};
102
102
  const proto = Object.getPrototypeOf(initial);
@@ -104,58 +104,6 @@ function assign(initial, override) {
104
104
  for (const key of Object.keys(override)) merged[key] = isPlainObject(initial[key]) && isPlainObject(override[key]) ? assign(initial[key], override[key]) : override[key];
105
105
  return merged;
106
106
  }
107
- var QuantityParser = class {
108
- constructor({ units, short }) {
109
- this.units = units;
110
- this.short = short;
111
- }
112
- /**
113
- * Parse a quantity string into its numeric value
114
- *
115
- * @throws {Error} If the quantity string is invalid or contains an unknown unit
116
- */
117
- parse(quantity) {
118
- var _a;
119
- const match = quantity.match(/^(-?\d+(?:\.\d+)?) ?(\w+)?s?$/);
120
- if (!match) throw new Error(`Invalid quantity, cannot parse: ${quantity}`);
121
- let unit = match[2];
122
- unit = ((_a = this.short) == null ? void 0 : _a[unit]) || unit;
123
- const count = Number.parseFloat(match[1]);
124
- if (Math.abs(count) > 1 && unit.endsWith("s")) unit = unit.substring(0, unit.length - 1);
125
- if (!this.units[unit]) throw new Error(`Invalid unit: ${unit}, makes sure it is one of: ${Object.keys(this.units).join(", ")}`);
126
- return count * this.units[unit];
127
- }
128
- };
129
- var _DurationParser = class _DurationParser$1 extends QuantityParser {
130
- constructor(options) {
131
- super({
132
- units: {
133
- ..._DurationParser$1.units,
134
- ...options == null ? void 0 : options.units
135
- },
136
- short: {
137
- ..._DurationParser$1.shortUnits,
138
- ...options == null ? void 0 : options.short
139
- }
140
- });
141
- }
142
- };
143
- _DurationParser.units = {
144
- week: 6048e5,
145
- day: 864e5,
146
- hour: 36e5,
147
- minute: 6e4,
148
- second: 1e3,
149
- millisecond: 1
150
- };
151
- _DurationParser.shortUnits = {
152
- w: "week",
153
- d: "day",
154
- h: "hour",
155
- m: "minute",
156
- s: "second",
157
- ms: "millisecond"
158
- };
159
107
  function isPlainObject(value) {
160
108
  if (typeof value !== "object" || value === null) return false;
161
109
  const prototype = Object.getPrototypeOf(value);
package/dist/index.d.ts CHANGED
@@ -2,6 +2,12 @@ import { Class, NonEmptyObject, Replace, SetOptional, UnionToTuple, ValueOf } fr
2
2
  import { assign } from "radashi";
3
3
 
4
4
  //#region src/utils/array/arrayCast.d.ts
5
+
6
+ /**
7
+ * 构造数组
8
+ * @param candidate 待构造项
9
+ * @param checkEmpty 是否检查 `undefined` 和 `null`
10
+ */
5
11
  declare function arrayCast<T>(candidate: T | T[], checkEmpty?: boolean): T[];
6
12
  //#endregion
7
13
  //#region src/utils/array/arrayCompete.d.ts
@@ -24,8 +30,15 @@ declare function arrayCompete<T>(initialList: readonly T[], match: (a: T, b: T)
24
30
  */
25
31
  declare function arrayCounting<T, K extends PropertyKey>(initialList: readonly T[], match: (row: T) => K): Record<string, number>;
26
32
  //#endregion
27
- //#region src/utils/array/arrayDiff.d.ts
28
- declare function arrayDiff<T>(initialList: readonly T[], diffList: readonly T[], match: (row: T) => PropertyKey): T[];
33
+ //#region src/utils/array/arrayDifference.d.ts
34
+ /**
35
+ * 求数组差集
36
+ *
37
+ * @param initialList 初始数组
38
+ * @param diffList 对比数组
39
+ * @param match 匹配函数
40
+ */
41
+ declare function arrayDifference<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T) => unknown): T[];
29
42
  //#endregion
30
43
  //#region src/utils/array/arrayFirst.d.ts
31
44
  /**
@@ -46,6 +59,16 @@ declare function arrayFirst<T>(initialList: readonly T[], saveValue?: T): T | un
46
59
  */
47
60
  declare function arrayFork<T>(initialList: readonly T[], match: (item: T) => boolean): [T[], T[]];
48
61
  //#endregion
62
+ //#region src/utils/array/arrayIntersection.d.ts
63
+ /**
64
+ * 求数组交集
65
+ *
66
+ * @param initialList 初始数组
67
+ * @param diffList 对比数组
68
+ * @param match 匹配函数
69
+ */
70
+ declare function arrayIntersection<T>(initialList: readonly T[], diffList: readonly T[], match?: (row: T) => unknown): T[];
71
+ //#endregion
49
72
  //#region src/utils/array/arrayLast.d.ts
50
73
  /**
51
74
  * 获取数组最后一项
@@ -64,7 +87,7 @@ declare function arrayLast<T>(initialList: readonly T[], saveValue?: T): T | und
64
87
  * @param mergeList 待合并数组
65
88
  * @param match 匹配函数
66
89
  */
67
- declare function arrayMerge<T>(initialList: readonly T[], mergeList: readonly T[], match: (item: T) => unknown): T[];
90
+ declare function arrayMerge<T>(initialList: readonly T[], mergeList: readonly T[], match?: (item: T) => unknown): T[];
68
91
  //#endregion
69
92
  //#region src/utils/array/arrayPick.d.ts
70
93
  /**
@@ -356,33 +379,4 @@ declare function isWebSocket<T extends WebSocket>(value: unknown): value is T;
356
379
  //#region src/utils/typeof/isWindow.d.ts
357
380
  declare function isWindow<T extends Window>(value: unknown): value is T;
358
381
  //#endregion
359
- //#region src/utils/typeof/types.d.ts
360
- declare const prototypeStrings: {
361
- readonly string: "[object String]";
362
- readonly number: "[object Number]";
363
- readonly boolean: "[object Boolean]";
364
- readonly object: "[object Object]";
365
- readonly array: "[object Array]";
366
- readonly bigInt: "[object BigInt]";
367
- readonly symbol: "[object Symbol]";
368
- readonly function: "[object Function]";
369
- readonly generatorFunction: "[object GeneratorFunction]";
370
- readonly asyncFunction: "[object AsyncFunction]";
371
- readonly promise: "[object Promise]";
372
- readonly null: "[object Null]";
373
- readonly undefined: "[object Undefined]";
374
- readonly date: "[object Date]";
375
- readonly regExp: "[object RegExp]";
376
- readonly error: "[object Error]";
377
- readonly file: "[object File]";
378
- readonly map: "[object Map]";
379
- readonly weakMap: "[object WeakMap]";
380
- readonly set: "[object Set]";
381
- readonly weakSet: "[object WeakSet]";
382
- readonly window: "[object Window]";
383
- readonly webSocket: "[object WebSocket]";
384
- readonly URLSearchParams: "[object URLSearchParams]";
385
- };
386
- declare function resolvePrototypeString(value: unknown): string;
387
- //#endregion
388
- export { arrayCast, arrayCompete, arrayCounting, arrayDiff, arrayFirst, arrayFork, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isArray, isAsyncFunction, isBigInt, isBoolean, isClass, isDate, isEqual, isError, isFile, isFunction, isGeneratorFunction, isInteger, isIterable, isMap, isNull, isNumber, isObject, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, prototypeStrings, resolvePrototypeString, rowsToTree, stringInitialCase, stringReplace, stringToJson, stringToValues, to, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
382
+ export { arrayCast, arrayCompete, arrayCounting, arrayDifference, arrayFirst, arrayFork, arrayIntersection, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isArray, isAsyncFunction, isBigInt, isBoolean, isClass, isDate, isEqual, isError, isFile, isFunction, isGeneratorFunction, isInteger, isIterable, isMap, isNull, isNumber, isObject, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, rowsToTree, stringInitialCase, stringReplace, stringToJson, stringToValues, to, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
package/dist/index.js CHANGED
@@ -227,6 +227,11 @@ function isWindow(value) {
227
227
 
228
228
  //#endregion
229
229
  //#region src/utils/array/arrayCast.ts
230
+ /**
231
+ * 构造数组
232
+ * @param candidate 待构造项
233
+ * @param checkEmpty 是否检查 `undefined` 和 `null`
234
+ */
230
235
  function arrayCast(candidate, checkEmpty = true) {
231
236
  if (checkEmpty && (isUndefined(candidate) || isNull(candidate))) return [];
232
237
  return isArray(candidate) ? [...candidate] : [candidate];
@@ -265,17 +270,27 @@ function arrayCounting(initialList, match) {
265
270
  }
266
271
 
267
272
  //#endregion
268
- //#region src/utils/array/arrayDiff.ts
269
- function arrayDiff(initialList, diffList, match) {
273
+ //#region src/utils/array/arrayDifference.ts
274
+ /**
275
+ * 求数组差集
276
+ *
277
+ * @param initialList 初始数组
278
+ * @param diffList 对比数组
279
+ * @param match 匹配函数
280
+ */
281
+ function arrayDifference(initialList, diffList, match) {
270
282
  if (!isArray(initialList) && !isArray(diffList)) return [];
271
283
  if (!isArray(initialList) || !initialList.length) return [...diffList];
272
284
  if (!isArray(diffList) || !diffList.length) return [...initialList];
273
- if (!isFunction(match)) return [];
274
- const keys = diffList.reduce((prev, curr) => {
275
- prev[match(curr)] = true;
276
- return prev;
277
- }, {});
278
- return initialList.filter((a) => !keys[match(a)]);
285
+ if (!isFunction(match)) {
286
+ const arraySet = new Set(diffList);
287
+ return Array.from(new Set(initialList.filter((item) => !arraySet.has(item))));
288
+ }
289
+ const map = /* @__PURE__ */ new Map();
290
+ diffList.forEach((item) => {
291
+ map.set(match(item), true);
292
+ });
293
+ return initialList.filter((a) => !map.get(match(a)));
279
294
  }
280
295
 
281
296
  //#endregion
@@ -306,6 +321,30 @@ function arrayFork(initialList, match) {
306
321
  return forked;
307
322
  }
308
323
 
324
+ //#endregion
325
+ //#region src/utils/array/arrayIntersection.ts
326
+ /**
327
+ * 求数组交集
328
+ *
329
+ * @param initialList 初始数组
330
+ * @param diffList 对比数组
331
+ * @param match 匹配函数
332
+ */
333
+ function arrayIntersection(initialList, diffList, match) {
334
+ if (!isArray(initialList) && !isArray(diffList)) return [];
335
+ if (!isArray(initialList) || !initialList.length) return [...diffList];
336
+ if (!isArray(diffList) || !diffList.length) return [...initialList];
337
+ if (!isFunction(match)) {
338
+ const arraySet = new Set(diffList);
339
+ return Array.from(new Set(initialList.filter((item) => arraySet.has(item))));
340
+ }
341
+ const map = /* @__PURE__ */ new Map();
342
+ diffList.forEach((item) => {
343
+ map.set(match(item), true);
344
+ });
345
+ return initialList.filter((a) => map.get(match(a)));
346
+ }
347
+
309
348
  //#endregion
310
349
  //#region src/utils/array/arrayLast.ts
311
350
  /**
@@ -332,7 +371,7 @@ function arrayLast(initialList, saveValue) {
332
371
  function arrayMerge(initialList, mergeList, match) {
333
372
  if (!isArray(initialList)) return [];
334
373
  if (!isArray(mergeList)) return [...initialList];
335
- if (!isFunction(match)) return [...initialList];
374
+ if (!isFunction(match)) return Array.from(new Set([...initialList, ...mergeList]));
336
375
  const keys = /* @__PURE__ */ new Map();
337
376
  for (const item of mergeList) keys.set(match(item), item);
338
377
  return initialList.map((prevItem) => {
@@ -580,7 +619,7 @@ function mapEntries(obj, toEntry) {
580
619
  }
581
620
 
582
621
  //#endregion
583
- //#region node_modules/.pnpm/radashi@12.7.0/node_modules/radashi/dist/radashi.js
622
+ //#region node_modules/.pnpm/radashi@12.7.1/node_modules/radashi/dist/radashi.js
584
623
  function assign(initial, override) {
585
624
  if (!initial || !override) return initial ?? override ?? {};
586
625
  const proto = Object.getPrototypeOf(initial);
@@ -588,58 +627,6 @@ function assign(initial, override) {
588
627
  for (const key of Object.keys(override)) merged[key] = isPlainObject(initial[key]) && isPlainObject(override[key]) ? assign(initial[key], override[key]) : override[key];
589
628
  return merged;
590
629
  }
591
- var QuantityParser = class {
592
- constructor({ units, short }) {
593
- this.units = units;
594
- this.short = short;
595
- }
596
- /**
597
- * Parse a quantity string into its numeric value
598
- *
599
- * @throws {Error} If the quantity string is invalid or contains an unknown unit
600
- */
601
- parse(quantity) {
602
- var _a;
603
- const match = quantity.match(/^(-?\d+(?:\.\d+)?) ?(\w+)?s?$/);
604
- if (!match) throw new Error(`Invalid quantity, cannot parse: ${quantity}`);
605
- let unit = match[2];
606
- unit = ((_a = this.short) == null ? void 0 : _a[unit]) || unit;
607
- const count = Number.parseFloat(match[1]);
608
- if (Math.abs(count) > 1 && unit.endsWith("s")) unit = unit.substring(0, unit.length - 1);
609
- if (!this.units[unit]) throw new Error(`Invalid unit: ${unit}, makes sure it is one of: ${Object.keys(this.units).join(", ")}`);
610
- return count * this.units[unit];
611
- }
612
- };
613
- var _DurationParser = class _DurationParser$1 extends QuantityParser {
614
- constructor(options) {
615
- super({
616
- units: {
617
- ..._DurationParser$1.units,
618
- ...options == null ? void 0 : options.units
619
- },
620
- short: {
621
- ..._DurationParser$1.shortUnits,
622
- ...options == null ? void 0 : options.short
623
- }
624
- });
625
- }
626
- };
627
- _DurationParser.units = {
628
- week: 6048e5,
629
- day: 864e5,
630
- hour: 36e5,
631
- minute: 6e4,
632
- second: 1e3,
633
- millisecond: 1
634
- };
635
- _DurationParser.shortUnits = {
636
- w: "week",
637
- d: "day",
638
- h: "hour",
639
- m: "minute",
640
- s: "second",
641
- ms: "millisecond"
642
- };
643
630
  function isPlainObject(value) {
644
631
  if (typeof value !== "object" || value === null) return false;
645
632
  const prototype = Object.getPrototypeOf(value);
@@ -1133,4 +1120,4 @@ function treeToRows(tree, options = {}) {
1133
1120
  }
1134
1121
 
1135
1122
  //#endregion
1136
- export { arrayCast, arrayCompete, arrayCounting, arrayDiff, arrayFirst, arrayFork, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isArray, isAsyncFunction, isBigInt, isBoolean, isClass, isDate, isEqual, isError, isFile, isFunction, isGeneratorFunction, isInteger, isIterable, isMap, isNull, isNumber, isObject, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, prototypeStrings, resolvePrototypeString, rowsToTree, stringInitialCase, stringReplace, stringToJson, stringToValues, to, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
1123
+ export { arrayCast, arrayCompete, arrayCounting, arrayDifference, arrayFirst, arrayFork, arrayIntersection, arrayLast, arrayMerge, arrayPick, arrayReplace, arraySplit, cloneDeep, enumEntries, enumKeys, enumTypeCheck, enumValues, isArray, isAsyncFunction, isBigInt, isBoolean, isClass, isDate, isEqual, isError, isFile, isFunction, isGeneratorFunction, isInteger, isIterable, isMap, isNull, isNumber, isObject, isPromise, isPromiseLike, isRegExp, isSet, isString, isSymbol, isURLSearchParams, isUndefined, isWeakMap, isWeakSet, isWebSocket, isWindow, mapEntries, objectAssign, objectEntries, objectKeys, objectPick, objectSwitch, objectValues, rowsToTree, stringInitialCase, stringReplace, stringToJson, stringToValues, to, treeFilter, treeFind, treeForEach, treeMap, treeToRows };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { ProxyOptions } from "vite";
2
+
3
+ //#region src/vite/proxy.d.ts
4
+
5
+ /**
6
+ * 开发服务器反向代理配置
7
+ *
8
+ * @param proxyList 代理配置项
9
+ */
10
+ declare function resolveViteProxy<L extends [string, string][]>(proxyList: L): Record<string, ProxyOptions>;
11
+ //#endregion
12
+ export { resolveViteProxy };
package/dist/vite.js ADDED
@@ -0,0 +1,21 @@
1
+ //#region src/vite/proxy.ts
2
+ /**
3
+ * 开发服务器反向代理配置
4
+ *
5
+ * @param proxyList 代理配置项
6
+ */
7
+ function resolveViteProxy(proxyList) {
8
+ const httpsRE = /^https:\/\//;
9
+ const result = {};
10
+ if (typeof proxyList === "object") for (const [prefix, target] of proxyList) result[prefix] = {
11
+ target,
12
+ changeOrigin: true,
13
+ ws: true,
14
+ rewrite: (path) => path.replace(/* @__PURE__ */ new RegExp(`^${prefix}`), ""),
15
+ ...httpsRE.test(target) ? { secure: false } : {}
16
+ };
17
+ return result;
18
+ }
19
+
20
+ //#endregion
21
+ export { resolveViteProxy };
package/metadata.json CHANGED
@@ -3,9 +3,10 @@
3
3
  "arrayCast",
4
4
  "arrayCompete",
5
5
  "arrayCounting",
6
- "arrayDiff",
6
+ "arrayDifference",
7
7
  "arrayFirst",
8
8
  "arrayFork",
9
+ "arrayIntersection",
9
10
  "arrayLast",
10
11
  "arrayMerge",
11
12
  "arrayPick",
@@ -52,8 +53,6 @@
52
53
  "objectPick",
53
54
  "objectSwitch",
54
55
  "objectValues",
55
- "prototypeStrings",
56
- "resolvePrototypeString",
57
56
  "rowsToTree",
58
57
  "stringInitialCase",
59
58
  "stringReplace",
@@ -66,6 +65,9 @@
66
65
  "treeMap",
67
66
  "treeToRows"
68
67
  ],
68
+ "vite": [
69
+ "resolveViteProxy"
70
+ ],
69
71
  "zod": [
70
72
  "ID",
71
73
  "IMEI",
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "pawover's kit",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.0.0-alpha.17",
7
+ "version": "0.0.0-alpha.19",
8
8
  "packageManager": "pnpm@10.20.0",
9
9
  "engines": {
10
10
  "node": ">=22.20.0"
@@ -28,6 +28,7 @@
28
28
  "exports": {
29
29
  ".": "./dist/index.js",
30
30
  "./enums": "./dist/enums.js",
31
+ "./vite": "./dist/vite.js",
31
32
  "./zod": "./dist/zod.js",
32
33
  "./hooks-alova": "./dist/hooks-alova.js",
33
34
  "./hooks-react": "./dist/hooks-react.js",
@@ -50,35 +51,38 @@
50
51
  "lib:up": "taze -I -r --exclude pnpm"
51
52
  },
52
53
  "dependencies": {
53
- "alova": "^3.3.4",
54
- "vue": "^3.5.24",
55
- "zod": "^4.1.12"
54
+ "alova": "^3.4.0",
55
+ "react": "^19.2.0",
56
+ "vite": "^7.2.4",
57
+ "vue": "^3.5.25",
58
+ "zod": "^4.1.13"
56
59
  },
57
60
  "devDependencies": {
58
61
  "@pawover/eslint-rules": "0.0.0-alpha.8",
59
62
  "@pawover/types": "0.0.0-alpha.6",
60
- "@stylistic/eslint-plugin": "^5.5.0",
63
+ "@stylistic/eslint-plugin": "^5.6.1",
61
64
  "@types/fs-extra": "^11.0.4",
62
65
  "@types/node": "^24.10.1",
63
- "@types/react": "^19.2.5",
66
+ "@types/react": "^19.2.7",
64
67
  "eslint": "^9.39.1",
65
68
  "eslint-plugin-antfu": "^3.1.1",
66
69
  "fs-extra": "^11.3.2",
67
70
  "globals": "^16.5.0",
68
- "prettier": "^3.6.2",
69
- "radashi": "^12.7.0",
70
- "rimraf": "^6.1.0",
71
- "taze": "^19.9.0",
72
- "tsdown": "^0.16.5",
71
+ "prettier": "^3.7.3",
72
+ "radashi": "^12.7.1",
73
+ "rimraf": "^6.1.2",
74
+ "taze": "^19.9.2",
75
+ "tsdown": "^0.16.8",
73
76
  "type-fest": "^5.2.0",
74
77
  "typescript": "^5.9.3",
75
- "typescript-eslint": "^8.46.4"
78
+ "typescript-eslint": "^8.48.0"
76
79
  },
77
80
  "peerDependencies": {
78
- "alova": ">=3.3.4",
81
+ "alova": ">=3.3.0",
79
82
  "react": ">=19.2.0",
80
- "vue": ">=3.5.24",
81
- "zod": ">=4.1.12"
83
+ "vite": ">=6.0",
84
+ "vue": ">=3.5.0",
85
+ "zod": ">=4.1.0"
82
86
  },
83
87
  "peerDependenciesMeta": {
84
88
  "alova": {
@@ -87,6 +91,9 @@
87
91
  "react": {
88
92
  "optional": true
89
93
  },
94
+ "vite": {
95
+ "optional": true
96
+ },
90
97
  "vue": {
91
98
  "optional": true
92
99
  },