@ks-web/use 0.0.4 → 0.0.5
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/dist/index.cjs.js +36 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.mjs +36 -2
- package/dist/useRaf/index.d.ts +6 -0
- package/package.json +5 -11
package/dist/index.cjs.js
CHANGED
|
@@ -2352,6 +2352,7 @@ __export(src_exports, {
|
|
|
2352
2352
|
useHttp: () => useHttp,
|
|
2353
2353
|
usePageVisibility: () => usePageVisibility,
|
|
2354
2354
|
useParent: () => useParent,
|
|
2355
|
+
useRaf: () => useRaf,
|
|
2355
2356
|
useRect: () => useRect,
|
|
2356
2357
|
useScrollParent: () => useScrollParent,
|
|
2357
2358
|
useToggle: () => useToggle,
|
|
@@ -2793,6 +2794,39 @@ function useCustomFieldValue(customValue) {
|
|
|
2793
2794
|
}
|
|
2794
2795
|
}
|
|
2795
2796
|
|
|
2797
|
+
// src/useRaf/index.ts
|
|
2798
|
+
function useRaf(fn, options) {
|
|
2799
|
+
if (inBrowser) {
|
|
2800
|
+
const { interval = 0, isLoop = false } = options || {};
|
|
2801
|
+
let start;
|
|
2802
|
+
let isStopped = false;
|
|
2803
|
+
let rafId;
|
|
2804
|
+
const stop = () => {
|
|
2805
|
+
isStopped = true;
|
|
2806
|
+
cancelAnimationFrame(rafId);
|
|
2807
|
+
};
|
|
2808
|
+
const frameWrapper = (timestamp) => {
|
|
2809
|
+
if (isStopped)
|
|
2810
|
+
return;
|
|
2811
|
+
if (start === void 0) {
|
|
2812
|
+
start = timestamp;
|
|
2813
|
+
} else if (timestamp - start > interval) {
|
|
2814
|
+
fn(timestamp);
|
|
2815
|
+
start = timestamp;
|
|
2816
|
+
if (!isLoop) {
|
|
2817
|
+
stop();
|
|
2818
|
+
return;
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
rafId = requestAnimationFrame(frameWrapper);
|
|
2822
|
+
};
|
|
2823
|
+
rafId = requestAnimationFrame(frameWrapper);
|
|
2824
|
+
return stop;
|
|
2825
|
+
}
|
|
2826
|
+
return () => {
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
|
|
2796
2830
|
// ../../node_modules/.pnpm/axios@1.3.3/node_modules/axios/lib/helpers/bind.js
|
|
2797
2831
|
function bind(fn, thisArg) {
|
|
2798
2832
|
return function wrap() {
|
|
@@ -4660,7 +4694,7 @@ utils_default.forEach(["post", "put", "patch"], function forEachMethodWithData2(
|
|
|
4660
4694
|
var Axios_default = Axios;
|
|
4661
4695
|
|
|
4662
4696
|
// ../../node_modules/.pnpm/axios@1.3.3/node_modules/axios/lib/cancel/CancelToken.js
|
|
4663
|
-
var CancelToken = class {
|
|
4697
|
+
var CancelToken = class _CancelToken {
|
|
4664
4698
|
constructor(executor) {
|
|
4665
4699
|
if (typeof executor !== "function") {
|
|
4666
4700
|
throw new TypeError("executor must be a function.");
|
|
@@ -4738,7 +4772,7 @@ var CancelToken = class {
|
|
|
4738
4772
|
*/
|
|
4739
4773
|
static source() {
|
|
4740
4774
|
let cancel;
|
|
4741
|
-
const token = new
|
|
4775
|
+
const token = new _CancelToken(function executor(c) {
|
|
4742
4776
|
cancel = c;
|
|
4743
4777
|
});
|
|
4744
4778
|
return {
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './useEventListener';
|
|
|
10
10
|
export * from './usePageVisibility';
|
|
11
11
|
export * from './useCustomFieldValue';
|
|
12
12
|
export * from './onMountedOrActivated';
|
|
13
|
+
export * from './useRaf';
|
|
13
14
|
export * from './useHttp';
|
|
14
15
|
export * from './useError';
|
|
15
16
|
export * from './useWaterMark';
|
package/dist/index.esm.mjs
CHANGED
|
@@ -2776,6 +2776,39 @@ function useCustomFieldValue(customValue) {
|
|
|
2776
2776
|
}
|
|
2777
2777
|
}
|
|
2778
2778
|
|
|
2779
|
+
// src/useRaf/index.ts
|
|
2780
|
+
function useRaf(fn, options) {
|
|
2781
|
+
if (inBrowser) {
|
|
2782
|
+
const { interval = 0, isLoop = false } = options || {};
|
|
2783
|
+
let start;
|
|
2784
|
+
let isStopped = false;
|
|
2785
|
+
let rafId;
|
|
2786
|
+
const stop = () => {
|
|
2787
|
+
isStopped = true;
|
|
2788
|
+
cancelAnimationFrame(rafId);
|
|
2789
|
+
};
|
|
2790
|
+
const frameWrapper = (timestamp) => {
|
|
2791
|
+
if (isStopped)
|
|
2792
|
+
return;
|
|
2793
|
+
if (start === void 0) {
|
|
2794
|
+
start = timestamp;
|
|
2795
|
+
} else if (timestamp - start > interval) {
|
|
2796
|
+
fn(timestamp);
|
|
2797
|
+
start = timestamp;
|
|
2798
|
+
if (!isLoop) {
|
|
2799
|
+
stop();
|
|
2800
|
+
return;
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
rafId = requestAnimationFrame(frameWrapper);
|
|
2804
|
+
};
|
|
2805
|
+
rafId = requestAnimationFrame(frameWrapper);
|
|
2806
|
+
return stop;
|
|
2807
|
+
}
|
|
2808
|
+
return () => {
|
|
2809
|
+
};
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2779
2812
|
// ../../node_modules/.pnpm/axios@1.3.3/node_modules/axios/lib/helpers/bind.js
|
|
2780
2813
|
function bind(fn, thisArg) {
|
|
2781
2814
|
return function wrap() {
|
|
@@ -4643,7 +4676,7 @@ utils_default.forEach(["post", "put", "patch"], function forEachMethodWithData2(
|
|
|
4643
4676
|
var Axios_default = Axios;
|
|
4644
4677
|
|
|
4645
4678
|
// ../../node_modules/.pnpm/axios@1.3.3/node_modules/axios/lib/cancel/CancelToken.js
|
|
4646
|
-
var CancelToken = class {
|
|
4679
|
+
var CancelToken = class _CancelToken {
|
|
4647
4680
|
constructor(executor) {
|
|
4648
4681
|
if (typeof executor !== "function") {
|
|
4649
4682
|
throw new TypeError("executor must be a function.");
|
|
@@ -4721,7 +4754,7 @@ var CancelToken = class {
|
|
|
4721
4754
|
*/
|
|
4722
4755
|
static source() {
|
|
4723
4756
|
let cancel;
|
|
4724
|
-
const token = new
|
|
4757
|
+
const token = new _CancelToken(function executor(c) {
|
|
4725
4758
|
cancel = c;
|
|
4726
4759
|
});
|
|
4727
4760
|
return {
|
|
@@ -5488,6 +5521,7 @@ export {
|
|
|
5488
5521
|
useHttp,
|
|
5489
5522
|
usePageVisibility,
|
|
5490
5523
|
useParent,
|
|
5524
|
+
useRaf,
|
|
5491
5525
|
useRect,
|
|
5492
5526
|
useScrollParent,
|
|
5493
5527
|
useToggle,
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ks-web/use",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Vant Composition API",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.mjs",
|
|
7
|
-
"
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"build:types": "tsc -p ./tsconfig.json --emitDeclarationOnly",
|
|
23
23
|
"build:bundle": "node ./build.js",
|
|
24
24
|
"build": "pnpm clean && pnpm build:bundle && pnpm build:types",
|
|
25
|
-
"release": "
|
|
25
|
+
"release": "ks-cli release",
|
|
26
26
|
"prepare": "pnpm build"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
@@ -41,21 +41,15 @@
|
|
|
41
41
|
"@types/js-md5": "0.7.0",
|
|
42
42
|
"@types/qs": "6.9.7",
|
|
43
43
|
"axios": "1.3.3",
|
|
44
|
-
"esbuild": "^0.
|
|
44
|
+
"esbuild": "^0.18.11",
|
|
45
45
|
"js-md5": "0.7.3",
|
|
46
46
|
"qs": "6.11.0",
|
|
47
|
-
"release-it": "^
|
|
47
|
+
"release-it": "^16.1.3",
|
|
48
48
|
"rimraf": "^5.0.0",
|
|
49
49
|
"typescript": "^5.0.4",
|
|
50
50
|
"vue": "^3.3.4"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"vue": "^3.0.0"
|
|
54
|
-
},
|
|
55
|
-
"release-it": {
|
|
56
|
-
"git": {
|
|
57
|
-
"tag": false,
|
|
58
|
-
"commitMessage": "release: @ks-web/use v${version}"
|
|
59
|
-
}
|
|
60
54
|
}
|
|
61
55
|
}
|