bigstate.client.vue 0.0.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 +51 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +46 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { IState, BSHttpOptions, BSDeliveryWsOptions } from 'bigstate.client.javascript';
|
|
3
|
+
|
|
4
|
+
type State<TMap extends Record<string, any> = Record<string, any>> = {
|
|
5
|
+
[K in keyof TMap]?: SidState<TMap[K]>;
|
|
6
|
+
};
|
|
7
|
+
interface SidState<T> {
|
|
8
|
+
prevState: IState<T> | null;
|
|
9
|
+
currState: IState<T> | null;
|
|
10
|
+
error: IState<T> | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare function useBigState<TMap extends Record<string, any>>(deliveryIds: string[], sids: (keyof TMap & string)[], optionsHttp: BSHttpOptions, optionsWs: BSDeliveryWsOptions): {
|
|
14
|
+
bigState: State<TMap>;
|
|
15
|
+
lastChanged: vue.Ref<{
|
|
16
|
+
sid: vue.UnwrapRef<keyof TMap & string>;
|
|
17
|
+
value: {
|
|
18
|
+
currState: {
|
|
19
|
+
at: string;
|
|
20
|
+
value: vue.UnwrapRef<TMap[keyof TMap]>;
|
|
21
|
+
} | null;
|
|
22
|
+
error: {
|
|
23
|
+
at: string;
|
|
24
|
+
value: any;
|
|
25
|
+
} | null;
|
|
26
|
+
};
|
|
27
|
+
} | null, {
|
|
28
|
+
sid: keyof TMap & string;
|
|
29
|
+
value: {
|
|
30
|
+
currState: IState<TMap[keyof TMap]> | null;
|
|
31
|
+
error: IState | null;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
sid: vue.UnwrapRef<keyof TMap & string>;
|
|
35
|
+
value: {
|
|
36
|
+
currState: {
|
|
37
|
+
at: string;
|
|
38
|
+
value: vue.UnwrapRef<TMap[keyof TMap]>;
|
|
39
|
+
} | null;
|
|
40
|
+
error: {
|
|
41
|
+
at: string;
|
|
42
|
+
value: any;
|
|
43
|
+
} | null;
|
|
44
|
+
};
|
|
45
|
+
} | null>;
|
|
46
|
+
retry: () => void;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
declare const matchPattern: (pattern: string, input: string) => boolean;
|
|
50
|
+
|
|
51
|
+
export { type SidState, type State, matchPattern, useBigState };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { IState, BSHttpOptions, BSDeliveryWsOptions } from 'bigstate.client.javascript';
|
|
3
|
+
|
|
4
|
+
type State<TMap extends Record<string, any> = Record<string, any>> = {
|
|
5
|
+
[K in keyof TMap]?: SidState<TMap[K]>;
|
|
6
|
+
};
|
|
7
|
+
interface SidState<T> {
|
|
8
|
+
prevState: IState<T> | null;
|
|
9
|
+
currState: IState<T> | null;
|
|
10
|
+
error: IState<T> | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare function useBigState<TMap extends Record<string, any>>(deliveryIds: string[], sids: (keyof TMap & string)[], optionsHttp: BSHttpOptions, optionsWs: BSDeliveryWsOptions): {
|
|
14
|
+
bigState: State<TMap>;
|
|
15
|
+
lastChanged: vue.Ref<{
|
|
16
|
+
sid: vue.UnwrapRef<keyof TMap & string>;
|
|
17
|
+
value: {
|
|
18
|
+
currState: {
|
|
19
|
+
at: string;
|
|
20
|
+
value: vue.UnwrapRef<TMap[keyof TMap]>;
|
|
21
|
+
} | null;
|
|
22
|
+
error: {
|
|
23
|
+
at: string;
|
|
24
|
+
value: any;
|
|
25
|
+
} | null;
|
|
26
|
+
};
|
|
27
|
+
} | null, {
|
|
28
|
+
sid: keyof TMap & string;
|
|
29
|
+
value: {
|
|
30
|
+
currState: IState<TMap[keyof TMap]> | null;
|
|
31
|
+
error: IState | null;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
sid: vue.UnwrapRef<keyof TMap & string>;
|
|
35
|
+
value: {
|
|
36
|
+
currState: {
|
|
37
|
+
at: string;
|
|
38
|
+
value: vue.UnwrapRef<TMap[keyof TMap]>;
|
|
39
|
+
} | null;
|
|
40
|
+
error: {
|
|
41
|
+
at: string;
|
|
42
|
+
value: any;
|
|
43
|
+
} | null;
|
|
44
|
+
};
|
|
45
|
+
} | null>;
|
|
46
|
+
retry: () => void;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
declare const matchPattern: (pattern: string, input: string) => boolean;
|
|
50
|
+
|
|
51
|
+
export { type SidState, type State, matchPattern, useBigState };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var v=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var H=(t,e)=>{for(var i in e)v(t,i,{get:e[i],enumerable:!0})},T=(t,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of B(e))!b.call(t,n)&&n!==i&&v(t,n,{get:()=>e[n],enumerable:!(s=y(e,n))||s.enumerable});return t};var k=t=>T(v({},"__esModule",{value:!0}),t);var C={};H(C,{matchPattern:()=>h,useBigState:()=>M});module.exports=k(C);var a=require("vue");var d=require("bigstate.client.javascript"),W=class{constructor(){}init(e,i){this.isInitClients()||(this.clientWs=new d.BigStateWsDeliveryClient(i),this.clientHttp=new d.BigStateHttpClient(e))}isInitClients(){return!!this.clientWs&&!!this.clientHttp}},o=new W;var h=(t,e)=>{if(!t)return!1;if(t==="*")return!0;let i=t.endsWith(":"),s=t.split(":"),n=e.split(":");if(!i&&!t.endsWith("*")&&s.length!==n.length||!i&&s.length>n.length)return!1;for(let l=0;l<s.length;l++){let c=s[l],p=n[l];if(c===void 0)return!1;if(!p&&c==="")return!0;if(!(c==="*"||c===p))return!1}return!0};function M(t,e,i,s){let n=(0,a.reactive)({}),l=(0,a.ref)(null),c=async r=>{if(!r?.sid)return null;let f=r.sid;if(!e.some(m=>h(m,f)))return null;let u=r?.value?{data:{at:r.rec??"",value:r.value}}:await o.clientHttp?.stateGet({sid:r.sid,version:r?.version??""});return u?.data?.value?[r.sid,{prevState:null,currState:r?.error?null:u.data,error:r?.error||null}]:null},p=async r=>{let f=await c(r);if(!f)return;let[S,u]=f;n[S]={prevState:n[S]?.currState??null,currState:u.currState,error:u.error},l.value={sid:S,value:{currState:u.currState,error:u.error}}},g=()=>{if(o.clientWs?.isSocketConnected()){o.clientWs.subscribeStateUpdate(t),o.clientWs.addWsEventListener(p,t[0]);return}o.clientWs?.subscribeStateUpdate(t,p)};return(0,a.onMounted)(()=>{o.init(i,s),g()}),(0,a.onUnmounted)(()=>{o.clientWs?.removeWsEventListener(p,t[0])}),{bigState:n,lastChanged:l,retry:g}}0&&(module.exports={matchPattern,useBigState});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ref as M,onMounted as m,onUnmounted as y,reactive as B}from"vue";import{BigStateHttpClient as h,BigStateWsDeliveryClient as g}from"bigstate.client.javascript";var S=class{constructor(){}init(c,o){this.isInitClients()||(this.clientWs=new g(o),this.clientHttp=new h(c))}isInitClients(){return!!this.clientWs&&!!this.clientHttp}},n=new S;var v=(e,c)=>{if(!e)return!1;if(e==="*")return!0;let o=e.endsWith(":"),a=e.split(":"),r=c.split(":");if(!o&&!e.endsWith("*")&&a.length!==r.length||!o&&a.length>r.length)return!1;for(let i=0;i<a.length;i++){let l=a[i],u=r[i];if(l===void 0)return!1;if(!u&&l==="")return!0;if(!(l==="*"||l===u))return!1}return!0};function b(e,c,o,a){let r=B({}),i=M(null),l=async t=>{if(!t?.sid)return null;let p=t.sid;if(!c.some(W=>v(W,p)))return null;let s=t?.value?{data:{at:t.rec??"",value:t.value}}:await n.clientHttp?.stateGet({sid:t.sid,version:t?.version??""});return s?.data?.value?[t.sid,{prevState:null,currState:t?.error?null:s.data,error:t?.error||null}]:null},u=async t=>{let p=await l(t);if(!p)return;let[f,s]=p;r[f]={prevState:r[f]?.currState??null,currState:s.currState,error:s.error},i.value={sid:f,value:{currState:s.currState,error:s.error}}},d=()=>{if(n.clientWs?.isSocketConnected()){n.clientWs.subscribeStateUpdate(e),n.clientWs.addWsEventListener(u,e[0]);return}n.clientWs?.subscribeStateUpdate(e,u)};return m(()=>{n.init(o,a),d()}),y(()=>{n.clientWs?.removeWsEventListener(u,e[0])}),{bigState:r,lastChanged:i,retry:d}}export{v as matchPattern,b as useBigState};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bigstate.client.vue",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./dist/index": "./dist/index.js",
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
19
|
+
"build": "npm run format && tsup",
|
|
20
|
+
"pack": "npm run build && npm pack",
|
|
21
|
+
"versionPatch": "npm version patch",
|
|
22
|
+
"versionMinor": "npm version minor",
|
|
23
|
+
"versionMajor": "npm version major",
|
|
24
|
+
"publish:package": "npm publish --access public",
|
|
25
|
+
"pack:publish": "npm run build && npm pack && npm publish --access public",
|
|
26
|
+
"test:watch": "vitest"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [],
|
|
29
|
+
"author": "bigstate",
|
|
30
|
+
"license": "ISC",
|
|
31
|
+
"private": false,
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"vue": ">=3.2.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"bigstate.client.javascript": "0.0.4"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "^5.0.0",
|
|
40
|
+
"tsup": "^8.5.1",
|
|
41
|
+
"prettier": "^3.3.2"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
]
|
|
46
|
+
}
|