@poveste/vendors 0.14.0 → 0.15.0
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/client/b-floating-vue.js +1 -1
- package/dist/client/b-iconify.js +1429 -1416
- package/dist/client/b-pinia.js +1359 -1936
- package/dist/client/b-vue-router.js +787 -502
- package/dist/client/b-vue-use.js +497 -367
- package/dist/client/b-vue.js +1 -1
- package/dist/client/devtools-api.js +6568 -0
- package/dist/client/index.js +178 -162
- package/dist/client/node_modules/@iconify/vue/dist/iconify.d.ts +17 -72
- package/dist/client/node_modules/@iconify/vue/dist/offline.d.ts +7 -12
- package/dist/client/node_modules/@iconify/vue/offline/package.json +2 -2
- package/dist/client/node_modules/@iconify/vue/package.json +13 -16
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts +88 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/set-array.d.ts +32 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts +12 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts +43 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/package.json +67 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/gen-mapping.d.mts +89 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/set-array.d.mts +33 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/sourcemap-segment.d.mts +13 -0
- package/dist/client/node_modules/@jridgewell/gen-mapping/types/types.d.mts +44 -0
- package/dist/client/node_modules/@jridgewell/remapping/package.json +71 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/build-source-map-tree.d.mts +15 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/remapping.d.mts +21 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/source-map-tree.d.mts +46 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/source-map.d.mts +19 -0
- package/dist/client/node_modules/@jridgewell/remapping/types/types.d.mts +16 -0
- package/dist/client/node_modules/@jridgewell/resolve-uri/dist/types/resolve-uri.d.ts +4 -0
- package/dist/client/node_modules/@jridgewell/resolve-uri/package.json +69 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/package.json +67 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/binary-search.d.mts +33 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/by-source.d.mts +4 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/flatten-map.d.mts +9 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/resolve.d.mts +4 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/sort.d.mts +4 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/sourcemap-segment.d.mts +17 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/strip-filename.d.mts +5 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/trace-mapping.d.mts +80 -0
- package/dist/client/node_modules/@jridgewell/trace-mapping/types/types.d.mts +107 -0
- package/dist/client/node_modules/@vue/devtools-api/dist/index-node.d.ts +11 -0
- package/dist/client/node_modules/@vue/devtools-api/dist/index.d.ts +2 -0
- package/dist/client/node_modules/@vue/devtools-api/package.json +25 -24
- package/dist/client/node_modules/@vue/devtools-kit/dist/index.d.ts +1170 -0
- package/dist/client/node_modules/@vue/devtools-kit/global.d.ts +20 -0
- package/dist/client/node_modules/@vue/devtools-kit/package.json +44 -0
- package/dist/client/node_modules/@vue/devtools-kit/types.d.ts +2 -0
- package/dist/client/node_modules/@vue/devtools-shared/dist/index.d.ts +40 -0
- package/dist/client/node_modules/@vue/devtools-shared/package.json +33 -0
- package/dist/client/node_modules/@vue-macros/common/dist/index.d.ts +124 -0
- package/dist/client/node_modules/@vue-macros/common/package.json +63 -0
- package/dist/client/node_modules/@vueuse/core/dist/index.d.ts +223 -111
- package/dist/client/node_modules/@vueuse/core/package.json +10 -3
- package/dist/client/node_modules/@vueuse/metadata/package.json +4 -1
- package/dist/client/node_modules/@vueuse/shared/dist/index.d.ts +2 -2
- package/dist/client/node_modules/@vueuse/shared/package.json +4 -1
- package/dist/client/node_modules/acorn/dist/acorn.d.mts +897 -0
- package/dist/client/node_modules/acorn/dist/acorn.d.ts +897 -0
- package/dist/client/node_modules/acorn/package.json +50 -0
- package/dist/client/node_modules/ast-kit/dist/index.d.ts +380 -0
- package/dist/client/node_modules/ast-kit/package.json +63 -0
- package/dist/client/node_modules/ast-walker-scope/dist/index.d.mts +51 -0
- package/dist/client/node_modules/ast-walker-scope/package.json +60 -0
- package/dist/client/node_modules/birpc/dist/index.d.mts +215 -0
- package/dist/client/node_modules/birpc/dist/index.d.ts +215 -0
- package/dist/client/node_modules/birpc/package.json +57 -0
- package/dist/client/node_modules/chokidar/handler.d.ts +90 -0
- package/dist/client/node_modules/chokidar/index.d.ts +217 -0
- package/dist/client/node_modules/chokidar/package.json +63 -0
- package/dist/client/node_modules/confbox/dist/_chunks/_format.d.mts +25 -0
- package/dist/client/node_modules/confbox/dist/index.d.mts +34 -0
- package/dist/client/node_modules/confbox/dist/ini.d.mts +62 -0
- package/dist/client/node_modules/confbox/dist/json5.d.mts +59 -0
- package/dist/client/node_modules/confbox/dist/jsonc.d.mts +41 -0
- package/dist/client/node_modules/confbox/dist/toml.d.mts +23 -0
- package/dist/client/node_modules/confbox/dist/yaml.d.mts +96 -0
- package/dist/client/node_modules/confbox/package.json +67 -0
- package/dist/client/node_modules/exsolve/dist/index.d.mts +66 -0
- package/dist/client/node_modules/exsolve/package.json +42 -0
- package/dist/client/node_modules/fdir/dist/index.d.mts +155 -0
- package/dist/client/node_modules/fdir/package.json +103 -0
- package/dist/client/node_modules/hookable/dist/index.d.ts +103 -0
- package/dist/client/node_modules/hookable/package.json +49 -0
- package/dist/client/node_modules/local-pkg/dist/index.d.mts +42 -0
- package/dist/client/node_modules/local-pkg/dist/index.d.ts +42 -0
- package/dist/client/node_modules/local-pkg/package.json +65 -0
- package/dist/client/node_modules/magic-string-ast/dist/index.d.ts +67 -0
- package/dist/client/node_modules/magic-string-ast/package.json +64 -0
- package/dist/client/node_modules/mlly/dist/index.d.mts +564 -0
- package/dist/client/node_modules/mlly/dist/index.d.ts +564 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/index.d.mts +32 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/index.d.ts +32 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/json5.d.mts +58 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/json5.d.ts +58 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/jsonc.d.mts +41 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/jsonc.d.ts +41 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/shared/confbox.9745c98f.d.mts +24 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/shared/confbox.9745c98f.d.ts +24 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/toml.d.mts +22 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/toml.d.ts +22 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/yaml.d.mts +95 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/dist/yaml.d.ts +95 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/json5.d.ts +2 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/jsonc.d.ts +2 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/package.json +86 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/toml.d.ts +2 -0
- package/dist/client/node_modules/mlly/node_modules/confbox/yaml.d.ts +2 -0
- package/dist/client/node_modules/mlly/node_modules/pkg-types/dist/index.d.mts +411 -0
- package/dist/client/node_modules/mlly/node_modules/pkg-types/dist/index.d.ts +411 -0
- package/dist/client/node_modules/mlly/node_modules/pkg-types/package.json +47 -0
- package/dist/client/node_modules/mlly/package.json +55 -0
- package/dist/client/node_modules/muggle-string/out/base.d.ts +6 -0
- package/dist/client/node_modules/muggle-string/out/basic.d.ts +6 -0
- package/dist/client/node_modules/muggle-string/out/binarySearch.d.ts +1 -0
- package/dist/client/node_modules/muggle-string/out/common.d.ts +9 -0
- package/dist/client/node_modules/muggle-string/out/getLength.d.ts +2 -0
- package/dist/client/node_modules/muggle-string/out/index.d.ts +10 -0
- package/dist/client/node_modules/muggle-string/out/map.d.ts +3 -0
- package/dist/client/node_modules/muggle-string/out/overwriteSource.d.ts +3 -0
- package/dist/client/node_modules/muggle-string/out/replace.d.ts +3 -0
- package/dist/client/node_modules/muggle-string/out/segment.d.ts +6 -0
- package/dist/client/node_modules/muggle-string/out/sourceBased.d.ts +3 -0
- package/dist/client/node_modules/muggle-string/out/toString.d.ts +2 -0
- package/dist/client/node_modules/muggle-string/out/track.d.ts +6 -0
- package/dist/client/node_modules/muggle-string/out/types.d.ts +16 -0
- package/dist/client/node_modules/muggle-string/package.json +22 -0
- package/dist/client/node_modules/nostics/dist/diagnostic-wduO7saY.d.mts +295 -0
- package/dist/client/node_modules/nostics/dist/formatters/ansi.d.mts +15 -0
- package/dist/client/node_modules/nostics/dist/formatters/json.d.mts +7 -0
- package/dist/client/node_modules/nostics/dist/index.d.mts +51 -0
- package/dist/client/node_modules/nostics/dist/reporters/dev.d.mts +13 -0
- package/dist/client/node_modules/nostics/dist/reporters/fetch.d.mts +11 -0
- package/dist/client/node_modules/nostics/dist/reporters/node.d.mts +43 -0
- package/dist/client/node_modules/nostics/package.json +125 -0
- package/dist/client/node_modules/pathe/dist/index.d.mts +47 -0
- package/dist/client/node_modules/pathe/dist/index.d.ts +47 -0
- package/dist/client/node_modules/pathe/dist/utils.d.mts +32 -0
- package/dist/client/node_modules/pathe/dist/utils.d.ts +32 -0
- package/dist/client/node_modules/pathe/package.json +61 -0
- package/dist/client/node_modules/pathe/utils.d.ts +1 -0
- package/dist/client/node_modules/perfect-debounce/dist/index.d.mts +49 -0
- package/dist/client/node_modules/perfect-debounce/package.json +41 -0
- package/dist/client/node_modules/picomatch/package.json +83 -0
- package/dist/client/node_modules/pinia/dist/pinia.d.ts +937 -1056
- package/dist/client/node_modules/pinia/package.json +53 -67
- package/dist/client/node_modules/pkg-types/dist/index.d.mts +695 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/_chunks/_format.d.mts +22 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/_chunks/libs/js-yaml.d.mts +33 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/index.d.mts +7 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/ini.d.mts +59 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/json.d.mts +25 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/json5.d.mts +55 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/jsonc.d.mts +29 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/toml.d.mts +20 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/dist/yaml.d.mts +101 -0
- package/dist/client/node_modules/pkg-types/node_modules/confbox/package.json +68 -0
- package/dist/client/node_modules/pkg-types/package.json +47 -0
- package/dist/client/node_modules/quansync/dist/index.d.mts +22 -0
- package/dist/client/node_modules/quansync/dist/index.d.ts +22 -0
- package/dist/client/node_modules/quansync/dist/macro.d.mts +18 -0
- package/dist/client/node_modules/quansync/dist/macro.d.ts +18 -0
- package/dist/client/node_modules/quansync/dist/types.d.mts +27 -0
- package/dist/client/node_modules/quansync/dist/types.d.ts +27 -0
- package/dist/client/node_modules/quansync/package.json +95 -0
- package/dist/client/node_modules/readdirp/index.d.ts +117 -0
- package/dist/client/node_modules/readdirp/package.json +62 -0
- package/dist/client/node_modules/scule/dist/index.d.mts +57 -0
- package/dist/client/node_modules/scule/dist/index.d.ts +57 -0
- package/dist/client/node_modules/scule/package.json +43 -0
- package/dist/client/node_modules/tinyglobby/dist/index.d.mts +148 -0
- package/dist/client/node_modules/tinyglobby/package.json +70 -0
- package/dist/client/node_modules/ufo/dist/index.d.mts +714 -0
- package/dist/client/node_modules/ufo/dist/index.d.ts +714 -0
- package/dist/client/node_modules/ufo/package.json +48 -0
- package/dist/client/node_modules/unplugin/dist/index.d.mts +241 -0
- package/dist/client/node_modules/unplugin/dist/rspack/loaders/load.d.mts +4 -0
- package/dist/client/node_modules/unplugin/dist/rspack/loaders/transform.d.mts +4 -0
- package/dist/client/node_modules/unplugin/dist/webpack/loaders/load.d.mts +4 -0
- package/dist/client/node_modules/unplugin/dist/webpack/loaders/transform.d.mts +4 -0
- package/dist/client/node_modules/unplugin/package.json +146 -0
- package/dist/client/node_modules/unplugin-utils/dist/index.d.ts +31 -0
- package/dist/client/node_modules/unplugin-utils/package.json +61 -0
- package/dist/client/node_modules/vue-router/dist/experimental/index.d.ts +7 -0
- package/dist/client/node_modules/vue-router/dist/experimental/pinia-colada.d.ts +151 -0
- package/dist/client/node_modules/vue-router/dist/{router-CWoNjPRp.d.mts → index-D7ja2BKs.d.ts} +2480 -1160
- package/dist/client/node_modules/vue-router/dist/options-CwYZKRl4.d.mts +2923 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/esbuild.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/index.d.mts +62 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/options.d.mts +7 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/rolldown.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/rollup.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/types.d.mts +7 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/vite.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/unplugin/webpack.d.mts +10 -0
- package/dist/client/node_modules/vue-router/dist/vue-router.d.ts +7 -0
- package/dist/client/node_modules/vue-router/package.json +153 -95
- package/dist/client/node_modules/vue-router/vue-router-auto-resolver.d.mts +22 -17
- package/dist/client/node_modules/vue-router/vue-router-auto-routes.d.mts +53 -0
- package/dist/client/node_modules/vue-router/vue-router-auto.d.ts +2 -1
- package/dist/client/node_modules/webpack-virtual-modules/lib/index.d.ts +15 -0
- package/dist/client/node_modules/webpack-virtual-modules/lib/virtual-stats.d.ts +11 -0
- package/dist/client/node_modules/webpack-virtual-modules/package.json +82 -0
- package/dist/client/vue.runtime.esm-bundler.js +1 -176
- package/package.json +8 -7
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/api.d.ts +0 -108
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/app.d.ts +0 -1
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/component.d.ts +0 -78
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/context.d.ts +0 -5
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/hooks.d.ts +0 -180
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/index.d.ts +0 -6
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/api/util.d.ts +0 -4
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/const.d.ts +0 -2
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/env.d.ts +0 -15
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/index.d.ts +0 -18
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/plugin.d.ts +0 -47
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/proxy.d.ts +0 -20
- package/dist/client/node_modules/@vue/devtools-api/lib/esm/time.d.ts +0 -2
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/index.d.ts +0 -22
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2/index.d.ts +0 -33
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v2.7/index.d.ts +0 -38
- package/dist/client/node_modules/pinia/node_modules/vue-demi/lib/v3/index.d.ts +0 -22
- package/dist/client/node_modules/pinia/node_modules/vue-demi/package.json +0 -47
- package/dist/client/node_modules/vue-router/dist/experimental/index.d.mts +0 -38
- package/dist/client/node_modules/vue-router/dist/vue-router.d.mts +0 -361
- package/dist/client/node_modules/vue-router/vue-router-auto-routes.d.ts +0 -4
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
2
|
+
type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
|
|
3
|
+
type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
4
|
+
type Thenable<T> = T | PromiseLike<T>;
|
|
5
|
+
type BirpcResolver<This> = (this: This, name: string, resolved: (...args: unknown[]) => unknown) => Thenable<((...args: any[]) => any) | undefined>;
|
|
6
|
+
interface ChannelOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Function to post raw message
|
|
9
|
+
*/
|
|
10
|
+
post: (data: any, ...extras: any[]) => any | Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Listener to receive raw message
|
|
13
|
+
*/
|
|
14
|
+
on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Clear the listener when `$close` is called
|
|
17
|
+
*/
|
|
18
|
+
off?: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Custom function to serialize data
|
|
21
|
+
*
|
|
22
|
+
* by default it passes the data as-is
|
|
23
|
+
*/
|
|
24
|
+
serialize?: (data: any) => any;
|
|
25
|
+
/**
|
|
26
|
+
* Custom function to deserialize data
|
|
27
|
+
*
|
|
28
|
+
* by default it passes the data as-is
|
|
29
|
+
*/
|
|
30
|
+
deserialize?: (data: any) => any;
|
|
31
|
+
/**
|
|
32
|
+
* Call the methods with the RPC context or the original functions object
|
|
33
|
+
*/
|
|
34
|
+
bind?: 'rpc' | 'functions';
|
|
35
|
+
/**
|
|
36
|
+
* Custom meta data to attached to the RPC instance's `$meta` property
|
|
37
|
+
*/
|
|
38
|
+
meta?: any;
|
|
39
|
+
}
|
|
40
|
+
interface EventOptions<RemoteFunctions, LocalFunctions extends object = Record<string, never>> {
|
|
41
|
+
/**
|
|
42
|
+
* Names of remote functions that do not need response.
|
|
43
|
+
*/
|
|
44
|
+
eventNames?: (keyof RemoteFunctions)[];
|
|
45
|
+
/**
|
|
46
|
+
* Maximum timeout for waiting for response, in milliseconds.
|
|
47
|
+
*
|
|
48
|
+
* @default 60_000
|
|
49
|
+
*/
|
|
50
|
+
timeout?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Custom resolver to resolve function to be called
|
|
53
|
+
*
|
|
54
|
+
* For advanced use cases only
|
|
55
|
+
*/
|
|
56
|
+
resolver?: BirpcResolver<BirpcReturn<RemoteFunctions, LocalFunctions>>;
|
|
57
|
+
/**
|
|
58
|
+
* Hook triggered before an event is sent to the remote
|
|
59
|
+
*
|
|
60
|
+
* @param req - Request parameters
|
|
61
|
+
* @param next - Function to continue the request
|
|
62
|
+
* @param resolve - Function to resolve the response directly
|
|
63
|
+
*/
|
|
64
|
+
onRequest?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, req: Request, next: (req?: Request) => Promise<any>, resolve: (res: any) => void) => void | Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Custom error handler
|
|
67
|
+
*
|
|
68
|
+
* @deprecated use `onFunctionError` and `onGeneralError` instead
|
|
69
|
+
*/
|
|
70
|
+
onError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, error: Error, functionName: string, args: any[]) => boolean | void;
|
|
71
|
+
/**
|
|
72
|
+
* Custom error handler for errors occurred in local functions being called
|
|
73
|
+
*
|
|
74
|
+
* @returns `true` to prevent the error from being thrown
|
|
75
|
+
*/
|
|
76
|
+
onFunctionError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, error: Error, functionName: string, args: any[]) => boolean | void;
|
|
77
|
+
/**
|
|
78
|
+
* Custom error handler for errors occurred during serialization or messsaging
|
|
79
|
+
*
|
|
80
|
+
* @returns `true` to prevent the error from being thrown
|
|
81
|
+
*/
|
|
82
|
+
onGeneralError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, error: Error, functionName?: string, args?: any[]) => boolean | void;
|
|
83
|
+
/**
|
|
84
|
+
* Custom error handler for timeouts
|
|
85
|
+
*
|
|
86
|
+
* @returns `true` to prevent the error from being thrown
|
|
87
|
+
*/
|
|
88
|
+
onTimeoutError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, functionName: string, args: any[]) => boolean | void;
|
|
89
|
+
}
|
|
90
|
+
type BirpcOptions<RemoteFunctions, LocalFunctions extends object = Record<string, never>> = EventOptions<RemoteFunctions, LocalFunctions> & ChannelOptions;
|
|
91
|
+
type BirpcFn<T> = PromisifyFn<T> & {
|
|
92
|
+
/**
|
|
93
|
+
* Send event without asking for response
|
|
94
|
+
*/
|
|
95
|
+
asEvent: (...args: ArgumentsType<T>) => Promise<void>;
|
|
96
|
+
};
|
|
97
|
+
interface BirpcGroupFn<T> {
|
|
98
|
+
/**
|
|
99
|
+
* Call the remote function and wait for the result.
|
|
100
|
+
*/
|
|
101
|
+
(...args: ArgumentsType<T>): Promise<Awaited<ReturnType<T>>[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Send event without asking for response
|
|
104
|
+
*/
|
|
105
|
+
asEvent: (...args: ArgumentsType<T>) => Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
interface BirpcReturnBuiltin<RemoteFunctions, LocalFunctions = Record<string, never>> {
|
|
108
|
+
/**
|
|
109
|
+
* Raw functions object
|
|
110
|
+
*/
|
|
111
|
+
$functions: LocalFunctions;
|
|
112
|
+
/**
|
|
113
|
+
* Whether the RPC is closed
|
|
114
|
+
*/
|
|
115
|
+
readonly $closed: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Custom meta data attached to the RPC instance
|
|
118
|
+
*/
|
|
119
|
+
readonly $meta: any;
|
|
120
|
+
/**
|
|
121
|
+
* Close the RPC connection
|
|
122
|
+
*/
|
|
123
|
+
$close: (error?: Error) => void;
|
|
124
|
+
/**
|
|
125
|
+
* Reject pending calls
|
|
126
|
+
*/
|
|
127
|
+
$rejectPendingCalls: (handler?: PendingCallHandler) => Promise<void>[];
|
|
128
|
+
/**
|
|
129
|
+
* Call the remote function and wait for the result.
|
|
130
|
+
* An alternative to directly calling the function
|
|
131
|
+
*/
|
|
132
|
+
$call: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]>>>;
|
|
133
|
+
/**
|
|
134
|
+
* Same as `$call`, but returns `undefined` if the function is not defined on the remote side.
|
|
135
|
+
*/
|
|
136
|
+
$callOptional: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]> | undefined>>;
|
|
137
|
+
/**
|
|
138
|
+
* Send event without asking for response
|
|
139
|
+
*/
|
|
140
|
+
$callEvent: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Call the remote function with the raw options.
|
|
143
|
+
*/
|
|
144
|
+
$callRaw: (options: {
|
|
145
|
+
method: string;
|
|
146
|
+
args: unknown[];
|
|
147
|
+
event?: boolean;
|
|
148
|
+
optional?: boolean;
|
|
149
|
+
}) => Promise<Awaited<ReturnType<any>>[]>;
|
|
150
|
+
}
|
|
151
|
+
type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
|
|
152
|
+
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
153
|
+
} & BirpcReturnBuiltin<RemoteFunctions, LocalFunctions>;
|
|
154
|
+
type PendingCallHandler = (options: Pick<PromiseEntry, 'method' | 'reject'>) => void | Promise<void>;
|
|
155
|
+
interface BirpcGroupReturnBuiltin<RemoteFunctions> {
|
|
156
|
+
/**
|
|
157
|
+
* Call the remote function and wait for the result.
|
|
158
|
+
* An alternative to directly calling the function
|
|
159
|
+
*/
|
|
160
|
+
$call: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]>>>;
|
|
161
|
+
/**
|
|
162
|
+
* Same as `$call`, but returns `undefined` if the function is not defined on the remote side.
|
|
163
|
+
*/
|
|
164
|
+
$callOptional: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]> | undefined>>;
|
|
165
|
+
/**
|
|
166
|
+
* Send event without asking for response
|
|
167
|
+
*/
|
|
168
|
+
$callEvent: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<void>;
|
|
169
|
+
}
|
|
170
|
+
type BirpcGroupReturn<RemoteFunctions> = {
|
|
171
|
+
[K in keyof RemoteFunctions]: BirpcGroupFn<RemoteFunctions[K]>;
|
|
172
|
+
} & BirpcGroupReturnBuiltin<RemoteFunctions>;
|
|
173
|
+
interface BirpcGroup<RemoteFunctions, LocalFunctions = Record<string, never>> {
|
|
174
|
+
readonly clients: BirpcReturn<RemoteFunctions, LocalFunctions>[];
|
|
175
|
+
readonly functions: LocalFunctions;
|
|
176
|
+
readonly broadcast: BirpcGroupReturn<RemoteFunctions>;
|
|
177
|
+
updateChannels: (fn?: ((channels: ChannelOptions[]) => void)) => BirpcReturn<RemoteFunctions, LocalFunctions>[];
|
|
178
|
+
}
|
|
179
|
+
interface PromiseEntry {
|
|
180
|
+
resolve: (arg: any) => void;
|
|
181
|
+
reject: (error: any) => void;
|
|
182
|
+
method: string;
|
|
183
|
+
timeoutId?: ReturnType<typeof setTimeout>;
|
|
184
|
+
}
|
|
185
|
+
declare const TYPE_REQUEST: "q";
|
|
186
|
+
interface Request {
|
|
187
|
+
/**
|
|
188
|
+
* Type
|
|
189
|
+
*/
|
|
190
|
+
t: typeof TYPE_REQUEST;
|
|
191
|
+
/**
|
|
192
|
+
* ID
|
|
193
|
+
*/
|
|
194
|
+
i?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Method
|
|
197
|
+
*/
|
|
198
|
+
m: string;
|
|
199
|
+
/**
|
|
200
|
+
* Arguments
|
|
201
|
+
*/
|
|
202
|
+
a: any[];
|
|
203
|
+
/**
|
|
204
|
+
* Optional
|
|
205
|
+
*/
|
|
206
|
+
o?: boolean;
|
|
207
|
+
}
|
|
208
|
+
declare const DEFAULT_TIMEOUT = 60000;
|
|
209
|
+
declare const setTimeout: typeof globalThis.setTimeout;
|
|
210
|
+
declare function createBirpc<RemoteFunctions = Record<string, never>, LocalFunctions extends object = Record<string, never>>($functions: LocalFunctions, options: BirpcOptions<RemoteFunctions, LocalFunctions>): BirpcReturn<RemoteFunctions, LocalFunctions>;
|
|
211
|
+
declare function cachedMap<T, R>(items: T[], fn: ((i: T) => R)): R[];
|
|
212
|
+
declare function createBirpcGroup<RemoteFunctions = Record<string, never>, LocalFunctions extends object = Record<string, never>>(functions: LocalFunctions, channels: ChannelOptions[] | (() => ChannelOptions[]), options?: EventOptions<RemoteFunctions, LocalFunctions>): BirpcGroup<RemoteFunctions, LocalFunctions>;
|
|
213
|
+
|
|
214
|
+
export { DEFAULT_TIMEOUT, cachedMap, createBirpc, createBirpcGroup };
|
|
215
|
+
export type { ArgumentsType, BirpcFn, BirpcGroup, BirpcGroupFn, BirpcGroupReturn, BirpcGroupReturnBuiltin, BirpcOptions, BirpcResolver, BirpcReturn, BirpcReturnBuiltin, ChannelOptions, EventOptions, PromisifyFn, ReturnType, Thenable };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
2
|
+
type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
|
|
3
|
+
type PromisifyFn<T> = ReturnType<T> extends Promise<any> ? T : (...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
4
|
+
type Thenable<T> = T | PromiseLike<T>;
|
|
5
|
+
type BirpcResolver<This> = (this: This, name: string, resolved: (...args: unknown[]) => unknown) => Thenable<((...args: any[]) => any) | undefined>;
|
|
6
|
+
interface ChannelOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Function to post raw message
|
|
9
|
+
*/
|
|
10
|
+
post: (data: any, ...extras: any[]) => any | Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Listener to receive raw message
|
|
13
|
+
*/
|
|
14
|
+
on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* Clear the listener when `$close` is called
|
|
17
|
+
*/
|
|
18
|
+
off?: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Custom function to serialize data
|
|
21
|
+
*
|
|
22
|
+
* by default it passes the data as-is
|
|
23
|
+
*/
|
|
24
|
+
serialize?: (data: any) => any;
|
|
25
|
+
/**
|
|
26
|
+
* Custom function to deserialize data
|
|
27
|
+
*
|
|
28
|
+
* by default it passes the data as-is
|
|
29
|
+
*/
|
|
30
|
+
deserialize?: (data: any) => any;
|
|
31
|
+
/**
|
|
32
|
+
* Call the methods with the RPC context or the original functions object
|
|
33
|
+
*/
|
|
34
|
+
bind?: 'rpc' | 'functions';
|
|
35
|
+
/**
|
|
36
|
+
* Custom meta data to attached to the RPC instance's `$meta` property
|
|
37
|
+
*/
|
|
38
|
+
meta?: any;
|
|
39
|
+
}
|
|
40
|
+
interface EventOptions<RemoteFunctions, LocalFunctions extends object = Record<string, never>> {
|
|
41
|
+
/**
|
|
42
|
+
* Names of remote functions that do not need response.
|
|
43
|
+
*/
|
|
44
|
+
eventNames?: (keyof RemoteFunctions)[];
|
|
45
|
+
/**
|
|
46
|
+
* Maximum timeout for waiting for response, in milliseconds.
|
|
47
|
+
*
|
|
48
|
+
* @default 60_000
|
|
49
|
+
*/
|
|
50
|
+
timeout?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Custom resolver to resolve function to be called
|
|
53
|
+
*
|
|
54
|
+
* For advanced use cases only
|
|
55
|
+
*/
|
|
56
|
+
resolver?: BirpcResolver<BirpcReturn<RemoteFunctions, LocalFunctions>>;
|
|
57
|
+
/**
|
|
58
|
+
* Hook triggered before an event is sent to the remote
|
|
59
|
+
*
|
|
60
|
+
* @param req - Request parameters
|
|
61
|
+
* @param next - Function to continue the request
|
|
62
|
+
* @param resolve - Function to resolve the response directly
|
|
63
|
+
*/
|
|
64
|
+
onRequest?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, req: Request, next: (req?: Request) => Promise<any>, resolve: (res: any) => void) => void | Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Custom error handler
|
|
67
|
+
*
|
|
68
|
+
* @deprecated use `onFunctionError` and `onGeneralError` instead
|
|
69
|
+
*/
|
|
70
|
+
onError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, error: Error, functionName: string, args: any[]) => boolean | void;
|
|
71
|
+
/**
|
|
72
|
+
* Custom error handler for errors occurred in local functions being called
|
|
73
|
+
*
|
|
74
|
+
* @returns `true` to prevent the error from being thrown
|
|
75
|
+
*/
|
|
76
|
+
onFunctionError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, error: Error, functionName: string, args: any[]) => boolean | void;
|
|
77
|
+
/**
|
|
78
|
+
* Custom error handler for errors occurred during serialization or messsaging
|
|
79
|
+
*
|
|
80
|
+
* @returns `true` to prevent the error from being thrown
|
|
81
|
+
*/
|
|
82
|
+
onGeneralError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, error: Error, functionName?: string, args?: any[]) => boolean | void;
|
|
83
|
+
/**
|
|
84
|
+
* Custom error handler for timeouts
|
|
85
|
+
*
|
|
86
|
+
* @returns `true` to prevent the error from being thrown
|
|
87
|
+
*/
|
|
88
|
+
onTimeoutError?: (this: BirpcReturn<RemoteFunctions, LocalFunctions>, functionName: string, args: any[]) => boolean | void;
|
|
89
|
+
}
|
|
90
|
+
type BirpcOptions<RemoteFunctions, LocalFunctions extends object = Record<string, never>> = EventOptions<RemoteFunctions, LocalFunctions> & ChannelOptions;
|
|
91
|
+
type BirpcFn<T> = PromisifyFn<T> & {
|
|
92
|
+
/**
|
|
93
|
+
* Send event without asking for response
|
|
94
|
+
*/
|
|
95
|
+
asEvent: (...args: ArgumentsType<T>) => Promise<void>;
|
|
96
|
+
};
|
|
97
|
+
interface BirpcGroupFn<T> {
|
|
98
|
+
/**
|
|
99
|
+
* Call the remote function and wait for the result.
|
|
100
|
+
*/
|
|
101
|
+
(...args: ArgumentsType<T>): Promise<Awaited<ReturnType<T>>[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Send event without asking for response
|
|
104
|
+
*/
|
|
105
|
+
asEvent: (...args: ArgumentsType<T>) => Promise<void>;
|
|
106
|
+
}
|
|
107
|
+
interface BirpcReturnBuiltin<RemoteFunctions, LocalFunctions = Record<string, never>> {
|
|
108
|
+
/**
|
|
109
|
+
* Raw functions object
|
|
110
|
+
*/
|
|
111
|
+
$functions: LocalFunctions;
|
|
112
|
+
/**
|
|
113
|
+
* Whether the RPC is closed
|
|
114
|
+
*/
|
|
115
|
+
readonly $closed: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Custom meta data attached to the RPC instance
|
|
118
|
+
*/
|
|
119
|
+
readonly $meta: any;
|
|
120
|
+
/**
|
|
121
|
+
* Close the RPC connection
|
|
122
|
+
*/
|
|
123
|
+
$close: (error?: Error) => void;
|
|
124
|
+
/**
|
|
125
|
+
* Reject pending calls
|
|
126
|
+
*/
|
|
127
|
+
$rejectPendingCalls: (handler?: PendingCallHandler) => Promise<void>[];
|
|
128
|
+
/**
|
|
129
|
+
* Call the remote function and wait for the result.
|
|
130
|
+
* An alternative to directly calling the function
|
|
131
|
+
*/
|
|
132
|
+
$call: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]>>>;
|
|
133
|
+
/**
|
|
134
|
+
* Same as `$call`, but returns `undefined` if the function is not defined on the remote side.
|
|
135
|
+
*/
|
|
136
|
+
$callOptional: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]> | undefined>>;
|
|
137
|
+
/**
|
|
138
|
+
* Send event without asking for response
|
|
139
|
+
*/
|
|
140
|
+
$callEvent: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Call the remote function with the raw options.
|
|
143
|
+
*/
|
|
144
|
+
$callRaw: (options: {
|
|
145
|
+
method: string;
|
|
146
|
+
args: unknown[];
|
|
147
|
+
event?: boolean;
|
|
148
|
+
optional?: boolean;
|
|
149
|
+
}) => Promise<Awaited<ReturnType<any>>[]>;
|
|
150
|
+
}
|
|
151
|
+
type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
|
|
152
|
+
[K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
|
|
153
|
+
} & BirpcReturnBuiltin<RemoteFunctions, LocalFunctions>;
|
|
154
|
+
type PendingCallHandler = (options: Pick<PromiseEntry, 'method' | 'reject'>) => void | Promise<void>;
|
|
155
|
+
interface BirpcGroupReturnBuiltin<RemoteFunctions> {
|
|
156
|
+
/**
|
|
157
|
+
* Call the remote function and wait for the result.
|
|
158
|
+
* An alternative to directly calling the function
|
|
159
|
+
*/
|
|
160
|
+
$call: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]>>>;
|
|
161
|
+
/**
|
|
162
|
+
* Same as `$call`, but returns `undefined` if the function is not defined on the remote side.
|
|
163
|
+
*/
|
|
164
|
+
$callOptional: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<Awaited<ReturnType<RemoteFunctions[K]> | undefined>>;
|
|
165
|
+
/**
|
|
166
|
+
* Send event without asking for response
|
|
167
|
+
*/
|
|
168
|
+
$callEvent: <K extends keyof RemoteFunctions>(method: K, ...args: ArgumentsType<RemoteFunctions[K]>) => Promise<void>;
|
|
169
|
+
}
|
|
170
|
+
type BirpcGroupReturn<RemoteFunctions> = {
|
|
171
|
+
[K in keyof RemoteFunctions]: BirpcGroupFn<RemoteFunctions[K]>;
|
|
172
|
+
} & BirpcGroupReturnBuiltin<RemoteFunctions>;
|
|
173
|
+
interface BirpcGroup<RemoteFunctions, LocalFunctions = Record<string, never>> {
|
|
174
|
+
readonly clients: BirpcReturn<RemoteFunctions, LocalFunctions>[];
|
|
175
|
+
readonly functions: LocalFunctions;
|
|
176
|
+
readonly broadcast: BirpcGroupReturn<RemoteFunctions>;
|
|
177
|
+
updateChannels: (fn?: ((channels: ChannelOptions[]) => void)) => BirpcReturn<RemoteFunctions, LocalFunctions>[];
|
|
178
|
+
}
|
|
179
|
+
interface PromiseEntry {
|
|
180
|
+
resolve: (arg: any) => void;
|
|
181
|
+
reject: (error: any) => void;
|
|
182
|
+
method: string;
|
|
183
|
+
timeoutId?: ReturnType<typeof setTimeout>;
|
|
184
|
+
}
|
|
185
|
+
declare const TYPE_REQUEST: "q";
|
|
186
|
+
interface Request {
|
|
187
|
+
/**
|
|
188
|
+
* Type
|
|
189
|
+
*/
|
|
190
|
+
t: typeof TYPE_REQUEST;
|
|
191
|
+
/**
|
|
192
|
+
* ID
|
|
193
|
+
*/
|
|
194
|
+
i?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Method
|
|
197
|
+
*/
|
|
198
|
+
m: string;
|
|
199
|
+
/**
|
|
200
|
+
* Arguments
|
|
201
|
+
*/
|
|
202
|
+
a: any[];
|
|
203
|
+
/**
|
|
204
|
+
* Optional
|
|
205
|
+
*/
|
|
206
|
+
o?: boolean;
|
|
207
|
+
}
|
|
208
|
+
declare const DEFAULT_TIMEOUT = 60000;
|
|
209
|
+
declare const setTimeout: typeof globalThis.setTimeout;
|
|
210
|
+
declare function createBirpc<RemoteFunctions = Record<string, never>, LocalFunctions extends object = Record<string, never>>($functions: LocalFunctions, options: BirpcOptions<RemoteFunctions, LocalFunctions>): BirpcReturn<RemoteFunctions, LocalFunctions>;
|
|
211
|
+
declare function cachedMap<T, R>(items: T[], fn: ((i: T) => R)): R[];
|
|
212
|
+
declare function createBirpcGroup<RemoteFunctions = Record<string, never>, LocalFunctions extends object = Record<string, never>>(functions: LocalFunctions, channels: ChannelOptions[] | (() => ChannelOptions[]), options?: EventOptions<RemoteFunctions, LocalFunctions>): BirpcGroup<RemoteFunctions, LocalFunctions>;
|
|
213
|
+
|
|
214
|
+
export { DEFAULT_TIMEOUT, cachedMap, createBirpc, createBirpcGroup };
|
|
215
|
+
export type { ArgumentsType, BirpcFn, BirpcGroup, BirpcGroupFn, BirpcGroupReturn, BirpcGroupReturnBuiltin, BirpcOptions, BirpcResolver, BirpcReturn, BirpcReturnBuiltin, ChannelOptions, EventOptions, PromisifyFn, ReturnType, Thenable };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "birpc",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "2.9.0",
|
|
5
|
+
"description": "Message based Two-way remote procedure call",
|
|
6
|
+
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"funding": "https://github.com/sponsors/antfu",
|
|
9
|
+
"homepage": "https://github.com/antfu-collective/birpc#readme",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/antfu-collective/birpc.git"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/antfu-collective/birpc/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"rpc",
|
|
19
|
+
"messages"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"require": "./dist/index.cjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/index.cjs",
|
|
30
|
+
"module": "./dist/index.mjs",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@antfu/eslint-config": "^6.3.0",
|
|
37
|
+
"@antfu/ni": "^28.0.0",
|
|
38
|
+
"@types/node": "^24.10.1",
|
|
39
|
+
"@vitest/coverage-v8": "3.0.9",
|
|
40
|
+
"bumpp": "^10.3.2",
|
|
41
|
+
"eslint": "^9.39.1",
|
|
42
|
+
"tsx": "^4.21.0",
|
|
43
|
+
"typescript": "^5.9.3",
|
|
44
|
+
"unbuild": "^3.6.1",
|
|
45
|
+
"vite": "^7.2.6",
|
|
46
|
+
"vitest": "^4.0.15"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "unbuild",
|
|
50
|
+
"dev": "unbuild --stub",
|
|
51
|
+
"lint": "eslint .",
|
|
52
|
+
"release": "bumpp",
|
|
53
|
+
"start": "tsx src/index.ts",
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"test": "vitest"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { FSWatcher as NativeFsWatcher, Stats, WatchEventType } from 'node:fs';
|
|
2
|
+
import type { EntryInfo } from 'readdirp';
|
|
3
|
+
import type { FSWatcher, Throttler, WatchHelper } from './index.js';
|
|
4
|
+
export type Path = string;
|
|
5
|
+
export declare const STR_DATA = "data";
|
|
6
|
+
export declare const STR_END = "end";
|
|
7
|
+
export declare const STR_CLOSE = "close";
|
|
8
|
+
export declare const EMPTY_FN: () => void;
|
|
9
|
+
export declare const IDENTITY_FN: (val: unknown) => unknown;
|
|
10
|
+
export declare const isWindows: boolean;
|
|
11
|
+
export declare const isMacos: boolean;
|
|
12
|
+
export declare const isLinux: boolean;
|
|
13
|
+
export declare const isFreeBSD: boolean;
|
|
14
|
+
export declare const isIBMi: boolean;
|
|
15
|
+
export declare const EVENTS: {
|
|
16
|
+
readonly ALL: "all";
|
|
17
|
+
readonly READY: "ready";
|
|
18
|
+
readonly ADD: "add";
|
|
19
|
+
readonly CHANGE: "change";
|
|
20
|
+
readonly ADD_DIR: "addDir";
|
|
21
|
+
readonly UNLINK: "unlink";
|
|
22
|
+
readonly UNLINK_DIR: "unlinkDir";
|
|
23
|
+
readonly RAW: "raw";
|
|
24
|
+
readonly ERROR: "error";
|
|
25
|
+
};
|
|
26
|
+
export type EventName = (typeof EVENTS)[keyof typeof EVENTS];
|
|
27
|
+
export type FsWatchContainer = {
|
|
28
|
+
listeners: (path: string) => void | Set<any>;
|
|
29
|
+
errHandlers: (err: unknown) => void | Set<any>;
|
|
30
|
+
rawEmitters: (ev: WatchEventType, path: string, opts: unknown) => void | Set<any>;
|
|
31
|
+
watcher: NativeFsWatcher;
|
|
32
|
+
watcherUnusable?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export interface WatchHandlers {
|
|
35
|
+
listener: (path: string) => void;
|
|
36
|
+
errHandler: (err: unknown) => void;
|
|
37
|
+
rawEmitter: (ev: WatchEventType, path: string, opts: unknown) => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @mixin
|
|
41
|
+
*/
|
|
42
|
+
export declare class NodeFsHandler {
|
|
43
|
+
fsw: FSWatcher;
|
|
44
|
+
_boundHandleError: (error: unknown) => void;
|
|
45
|
+
constructor(fsW: FSWatcher);
|
|
46
|
+
/**
|
|
47
|
+
* Watch file for changes with fs_watchFile or fs_watch.
|
|
48
|
+
* @param path to file or dir
|
|
49
|
+
* @param listener on fs change
|
|
50
|
+
* @returns closer for the watcher instance
|
|
51
|
+
*/
|
|
52
|
+
_watchWithNodeFs(path: string, listener: (path: string, newStats?: any) => void | Promise<void>): (() => void) | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Watch a file and emit add event if warranted.
|
|
55
|
+
* @returns closer for the watcher instance
|
|
56
|
+
*/
|
|
57
|
+
_handleFile(file: Path, stats: Stats, initialAdd: boolean): (() => void) | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Handle symlinks encountered while reading a dir.
|
|
60
|
+
* @param entry returned by readdirp
|
|
61
|
+
* @param directory path of dir being read
|
|
62
|
+
* @param path of this item
|
|
63
|
+
* @param item basename of this item
|
|
64
|
+
* @returns true if no more processing is needed for this entry.
|
|
65
|
+
*/
|
|
66
|
+
_handleSymlink(entry: EntryInfo, directory: string, path: Path, item: string): Promise<boolean | undefined>;
|
|
67
|
+
_handleRead(directory: string, initialAdd: boolean, wh: WatchHelper, target: Path | undefined, dir: Path, depth: number, throttler: Throttler): Promise<unknown> | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Read directory to add / remove files from `@watched` list and re-read it on change.
|
|
70
|
+
* @param dir fs path
|
|
71
|
+
* @param stats
|
|
72
|
+
* @param initialAdd
|
|
73
|
+
* @param depth relative to user-supplied path
|
|
74
|
+
* @param target child path targeted for watch
|
|
75
|
+
* @param wh Common watch helpers for this path
|
|
76
|
+
* @param realpath
|
|
77
|
+
* @returns closer for the watcher instance.
|
|
78
|
+
*/
|
|
79
|
+
_handleDir(dir: string, stats: Stats, initialAdd: boolean, depth: number, target: string | undefined, wh: WatchHelper, realpath: string): Promise<(() => void) | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* Handle added file, directory, or glob pattern.
|
|
82
|
+
* Delegates call to _handleFile / _handleDir after checks.
|
|
83
|
+
* @param path to file or ir
|
|
84
|
+
* @param initialAdd was the file added at watch instantiation?
|
|
85
|
+
* @param priorWh depth relative to user-supplied path
|
|
86
|
+
* @param depth Child path actually targeted for watch
|
|
87
|
+
* @param target Child path actually targeted for watch
|
|
88
|
+
*/
|
|
89
|
+
_addToNodeFs(path: string, initialAdd: boolean, priorWh: WatchHelper | undefined, depth: number, target?: string): Promise<string | false | undefined>;
|
|
90
|
+
}
|