@spoosh/plugin-debounce 0.4.0 → 0.4.1
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.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/index.mjs +4 -4
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _spoosh_core from '@spoosh/core';
|
|
2
2
|
|
|
3
3
|
type PrevQueryField<TQuery> = [TQuery] extends [never] ? object : {
|
|
4
4
|
prevQuery?: TQuery;
|
|
@@ -55,7 +55,7 @@ declare module "@spoosh/core" {
|
|
|
55
55
|
* });
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
-
declare function debouncePlugin(): SpooshPlugin<{
|
|
58
|
+
declare function debouncePlugin(): _spoosh_core.SpooshPlugin<{
|
|
59
59
|
readOptions: DebounceReadOptions;
|
|
60
60
|
writeOptions: DebounceWriteOptions;
|
|
61
61
|
readResult: DebounceReadResult;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _spoosh_core from '@spoosh/core';
|
|
2
2
|
|
|
3
3
|
type PrevQueryField<TQuery> = [TQuery] extends [never] ? object : {
|
|
4
4
|
prevQuery?: TQuery;
|
|
@@ -55,7 +55,7 @@ declare module "@spoosh/core" {
|
|
|
55
55
|
* });
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
-
declare function debouncePlugin(): SpooshPlugin<{
|
|
58
|
+
declare function debouncePlugin(): _spoosh_core.SpooshPlugin<{
|
|
59
59
|
readOptions: DebounceReadOptions;
|
|
60
60
|
writeOptions: DebounceWriteOptions;
|
|
61
61
|
readResult: DebounceReadResult;
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(src_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(src_exports);
|
|
26
26
|
|
|
27
27
|
// src/plugin.ts
|
|
28
|
+
var import_core = require("@spoosh/core");
|
|
28
29
|
var PLUGIN_NAME = "spoosh:debounce";
|
|
29
30
|
function resolveDebounceMs(debounce, context) {
|
|
30
31
|
if (debounce === void 0) return 0;
|
|
@@ -36,7 +37,7 @@ function debouncePlugin() {
|
|
|
36
37
|
const latestQueryKeys = /* @__PURE__ */ new Map();
|
|
37
38
|
const prevRequests = /* @__PURE__ */ new Map();
|
|
38
39
|
const eventTracers = /* @__PURE__ */ new Map();
|
|
39
|
-
return {
|
|
40
|
+
return (0, import_core.createSpooshPlugin)({
|
|
40
41
|
name: PLUGIN_NAME,
|
|
41
42
|
operations: ["read"],
|
|
42
43
|
lifecycle: {
|
|
@@ -55,8 +56,7 @@ function debouncePlugin() {
|
|
|
55
56
|
middleware: async (context, next) => {
|
|
56
57
|
const t = context.tracer?.(PLUGIN_NAME);
|
|
57
58
|
const et = context.eventTracer?.(PLUGIN_NAME);
|
|
58
|
-
const
|
|
59
|
-
const debounceOption = pluginOptions?.debounce;
|
|
59
|
+
const debounceOption = context.pluginOptions?.debounce;
|
|
60
60
|
if (debounceOption === void 0 || context.forceRefetch) {
|
|
61
61
|
t?.skip("No debounce configured");
|
|
62
62
|
return next();
|
|
@@ -134,5 +134,5 @@ function debouncePlugin() {
|
|
|
134
134
|
t?.return("Debounced, no cached data", { color: "info" });
|
|
135
135
|
return { data: void 0, status: 0 };
|
|
136
136
|
}
|
|
137
|
-
};
|
|
137
|
+
});
|
|
138
138
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/plugin.ts
|
|
2
|
+
import { createSpooshPlugin } from "@spoosh/core";
|
|
2
3
|
var PLUGIN_NAME = "spoosh:debounce";
|
|
3
4
|
function resolveDebounceMs(debounce, context) {
|
|
4
5
|
if (debounce === void 0) return 0;
|
|
@@ -10,7 +11,7 @@ function debouncePlugin() {
|
|
|
10
11
|
const latestQueryKeys = /* @__PURE__ */ new Map();
|
|
11
12
|
const prevRequests = /* @__PURE__ */ new Map();
|
|
12
13
|
const eventTracers = /* @__PURE__ */ new Map();
|
|
13
|
-
return {
|
|
14
|
+
return createSpooshPlugin({
|
|
14
15
|
name: PLUGIN_NAME,
|
|
15
16
|
operations: ["read"],
|
|
16
17
|
lifecycle: {
|
|
@@ -29,8 +30,7 @@ function debouncePlugin() {
|
|
|
29
30
|
middleware: async (context, next) => {
|
|
30
31
|
const t = context.tracer?.(PLUGIN_NAME);
|
|
31
32
|
const et = context.eventTracer?.(PLUGIN_NAME);
|
|
32
|
-
const
|
|
33
|
-
const debounceOption = pluginOptions?.debounce;
|
|
33
|
+
const debounceOption = context.pluginOptions?.debounce;
|
|
34
34
|
if (debounceOption === void 0 || context.forceRefetch) {
|
|
35
35
|
t?.skip("No debounce configured");
|
|
36
36
|
return next();
|
|
@@ -108,7 +108,7 @@ function debouncePlugin() {
|
|
|
108
108
|
t?.return("Debounced, no cached data", { color: "info" });
|
|
109
109
|
return { data: void 0, status: 0 };
|
|
110
110
|
}
|
|
111
|
-
};
|
|
111
|
+
});
|
|
112
112
|
}
|
|
113
113
|
export {
|
|
114
114
|
debouncePlugin
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-debounce",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Request debouncing plugin for Spoosh - waits for inactivity before fetching",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"@spoosh/core": ">=0.15.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@spoosh/
|
|
40
|
-
"@spoosh/
|
|
39
|
+
"@spoosh/test-utils": "0.3.0",
|
|
40
|
+
"@spoosh/core": "0.15.1"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "tsup --watch",
|