insite-client 2.2.3 → 2.3.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/InSite.d.ts +2 -3
- package/dist/InSite.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/package.json +38 -38
package/dist/InSite.d.ts
CHANGED
|
@@ -4,12 +4,11 @@ import type { AbilitiesSchema } from "insite-common";
|
|
|
4
4
|
import { CookieSetter } from "insite-cookie/client";
|
|
5
5
|
import { UsersSubscriptionGroup, type CurrentUser, type Orgs, type OrgsExtended, type Roles, type Users, type UsersExtended } from "insite-users-client";
|
|
6
6
|
import { IncomingTransport, OutgoingTransport } from "insite-ws-transfers/browser";
|
|
7
|
-
import { WS } from "insite-ws/client";
|
|
8
7
|
import type { OmitRedundant, Options, WSWithActualProps } from "./types";
|
|
9
8
|
/** @this InSite */
|
|
10
|
-
declare function login<O extends Options<any>>(this: InSite<O>, email: string, password: string):
|
|
9
|
+
declare function login<O extends Options<any>>(this: InSite<O>, email: string, password: string): Promise<unknown>;
|
|
11
10
|
/** @this InSite */
|
|
12
|
-
declare function logout<O extends Options<any>>(this: InSite<O>):
|
|
11
|
+
declare function logout<O extends Options<any>>(this: InSite<O>): Promise<unknown>;
|
|
13
12
|
export declare class InSite<O extends Options<any>, AS extends AbilitiesSchema = O extends Options<infer A> ? A : never> extends EventEmitter {
|
|
14
13
|
#private;
|
|
15
14
|
constructor(options?: O);
|
package/dist/InSite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InSite.d.ts","sourceRoot":"","sources":["../src/InSite.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,C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configurable:!0,writable:!0,value:e}):t[r]=e;var i=(t,r,e)=>W(t,typeof r!="symbol"?r+"":r,e),L=(t,r,e)=>r.has(t)||$("Cannot "+e);var T=(t,r,e)=>(L(t,r,"read from private field"),e?e.call(t):r.get(t)),j=(t,r,e)=>r.has(t)?$("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(t):r.set(t,e);import D from"eventemitter3";function x(){}var g=new WeakMap,d=class t extends Promise{constructor(e,o){let n,f;super((s,c)=>{n=s,f=c});i(this,"isPending",!0);i(this,"isFulfilled",!1);i(this,"isRejected",!1);i(this,"state","pending");i(this,"result");i(this,"resolve",e=>{if(this.isPending){this.isPending=!1,this.isFulfilled=!0,this.state="fulfilled",this.result=e;let o=g.get(this);o&&(o.resolve.call(this,e),g.delete(this))}});i(this,"reject",e=>{if(this.isPending){this.isPending=!1,this.isRejected=!0,this.state="rejected",this.result=e;let o=g.get(this);o&&(o.reject.call(this,e),g.delete(this))}});if(g.set(this,{resolve:n,reject:f}),o?.signal)if(o.signal.aborted)this.reject(new DOMException("Aborted","AbortError"));else{let s=()=>this.reject(new DOMException("Aborted","AbortError"));o.signal.addEventListener("abort",s),this.finally(()=>o.signal?.removeEventListener("abort",s))}if(typeof o?.timeout=="number"&&Number.isFinite(o.timeout)){let s=setTimeout(()=>this.reject(new DOMException("Timeout exceeded","TimeoutError")),o.timeout);this.finally(()=>clearTimeout(s))}e?.(this.resolve,this.reject)}static resolved(e){return new t(o=>o(e))}static rejected(e){return new t((o,n)=>n(e))}};function B(t,r=0,e={}){let{leading:o=!1,trailing:n=!0}=e,{maxWait:f=1/0}=e,s,c,m,y,w,l,u,S,b=async()=>{let a=Date.now();a>=m?(s=void 0,m=void 0,clearTimeout(c),c=void 0,typeof u=="function"&&await u(),p.resolve(S),l=o):(clearTimeout(s),s=setTimeout(b,m-a))},I=Number.isFinite(f)?()=>{u===h&&(u=!1),h(),c=setTimeout(I,f)}:null;async function h(){try{return S=await t.apply(y,w),S}catch(a){throw p.reject(a),a}}o&&typeof o=="boolean"&&(o=h),l=o,n&&typeof n=="boolean"&&(n=h),u=n;let p=Object.assign(function(...a){return w=a,y=this,m=Date.now()+r,u=n,p.promise.isPending||(p.promise=new d((A,R)=>{p.resolve=A,p.reject=R,typeof l=="function"&&(l(),l=!1,u===h&&(u=!1)),s||(s=setTimeout(b,r),I&&(c=setTimeout(I,f)))})),p.promise},{callback:t,promise:d.resolved(void 0),resolve:x,reject:x,run:h,clear:async a=>{clearTimeout(s),s=void 0,clearTimeout(c),c=void 0,p.resolve(a?await h():S)}});return p}B.noop=Object.assign(()=>{},{callback:x,promise:d.resolved(void 0),resolve:x,reject:x,run:x,clear:x});function E(t,r,e,o,n=!0){return Array.isArray(t)&&(t=t.length),typeof o!="string"&&(n=o??!0,o=e),(n?`${t}\xA0`:"")+E.raw(t,r,e,o)}E.raw=(t,r,e,o=e)=>{t=Math.abs(t);let n=t%10,f=t%100;return n===1&&f!==11?r:n>=2&&n<=4&&!(f>=12&&f<=15)?e:o};import{CookieSetter as C}from"insite-cookie/client";import{Subscription as k}from"insite-subscriptions-client";import{UsersSubscriptionGroup as F}from"insite-users-client";import{IncomingTransport as U,OutgoingTransport as N}from"insite-ws-transfers/browser";import{WS as G}from"insite-ws/client";function q(t,r){return this.ws.sendRequest("login",t,r)}function _(){return this.ws.sendRequest("logout")}var O,v=class v extends D{constructor(e){super();i(this,"ws");i(this,"incomingTransport");i(this,"outgoingTransport");i(this,"cookie");i(this,"usersSubscriptionGroup");i(this,"user");i(this,"users");i(this,"orgs");i(this,"roles");i(this,"isLoggedIn",!1);i(this,"login");i(this,"logout");i(this,"isReady",!1);j(this,O,new d);e&&this.init(e)}async init(e){if(!this.isReady){let{ws:o={},cookie:n,users:f,public:s}=e??{},{subscriptions:c,incomingTransport:m,outgoingTransport:y,...w}=o;this.ws=new G(w),c!==null&&k.bindTo(this.ws),m&&(this.incomingTransport=new U(this.ws,typeof m=="object"?m:{})),y&&(this.outgoingTransport=new N(this.ws)),n!==null&&(this.cookie=new C(this.ws,n)),f!==null&&c!==null&&n!==null&&(this.user=null,this.login=q,this.logout=_,s?await new Promise(l=>{new k("object","user",[!0],u=>{this.user=u,this.user?this.isLoggedIn||(this.isLoggedIn=!0,this.emit("login",!0)):this.isLoggedIn&&(this.isLoggedIn=!1,this.emit("logout",!1)),this.isReady||l()})}):(this.usersSubscriptionGroup=new F({target:this}),await new Promise(l=>{this.usersSubscriptionGroup.once("init",()=>{this.isLoggedIn=!!this.user,this.usersSubscriptionGroup.on("update.user",u=>{u.valueOf()?this.isLoggedIn||(this.isLoggedIn=!0,this.emit("login",!0)):this.isLoggedIn&&(this.isLoggedIn=!1,this.emit("logout",!1))}),l(),this.isLoggedIn&&this.emit("login",!0)})}))),this.isReady=!0,this.emit("ready",!0),T(this,O).resolve(this)}}whenReady(){return T(this,O)}static init(e,o=!1){let n=new v(e);return o?n.whenReady():n}};O=new WeakMap;var P=v;export*from"insite-common/frontend";export*from"insite-cookie/client";export*from"insite-subscriptions-client";export*from"insite-users-client";export*from"insite-ws-transfers/browser";export*from"insite-ws/client";export{P as InSite};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/InSite.ts", "../../../../@nesvet/npm/n/src/noop.ts", "../../../../@nesvet/npm/n/src/
|
|
4
|
-
"sourcesContent": ["import EventEmitter from \"eventemitter3\";\nimport { StatefulPromise } from \"@nesvet/n\";\nimport type { AbilitiesSchema } from \"insite-common\";\nimport { CookieSetter } from \"insite-cookie/client\";\nimport { Subscription } from \"insite-subscriptions-client\";\nimport {\n\tUsersSubscriptionGroup,\n\ttype CurrentUser,\n\ttype Orgs,\n\ttype OrgsExtended,\n\ttype Roles,\n\ttype Users,\n\ttype UsersExtended\n} from \"insite-users-client\";\nimport { IncomingTransport, OutgoingTransport } from \"insite-ws-transfers/browser\";\nimport { WS } from \"insite-ws/client\";\nimport type { OmitRedundant, Options, WSWithActualProps } from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\n/** @this InSite */\nfunction login<O extends Options<any>>(this: InSite<O>, email: string, password: string) {\n\treturn this.ws.sendRequest(\"login\", email, password);\n}\n\n/** @this InSite */\nfunction logout<O extends Options<any>>(this: InSite<O>) {\n\treturn this.ws.sendRequest(\"logout\");\n}\n\n\nexport class InSite<\n\tO extends Options<any>,\n\tAS extends AbilitiesSchema = O extends Options<infer A> ? A : never\n> extends EventEmitter {\n\tconstructor(options?: O) {\n\t\tsuper();\n\t\t\n\t\tif (options)\n\t\t\tvoid this.init(options);\n\t\t\n\t}\n\t\n\tws!: WSWithActualProps<O>;\n\tincomingTransport!: IncomingTransport;\n\toutgoingTransport!: OutgoingTransport;\n\tcookie!: CookieSetter;\n\tusersSubscriptionGroup!: UsersSubscriptionGroup;\n\tuser!: CurrentUser<AS> | null;\n\tusers!: Users | UsersExtended;\n\torgs!: Orgs | OrgsExtended;\n\troles!: Roles;\n\tisLoggedIn = false;\n\t\n\tlogin!: typeof login<O>;\n\tlogout!: typeof logout<O>;\n\t\n\tisReady = false;\n\t\n\tprotected async init(options?: O) {\n\t\t\n\t\tif (!this.isReady) {\n\t\t\tconst {\n\t\t\t\tws: wsWithOtherOptions = {},\n\t\t\t\tcookie: cookieOptions,\n\t\t\t\tusers,\n\t\t\t\tpublic: isPublic\n\t\t\t} = options ?? {};\n\t\t\t\n\t\t\tconst {\n\t\t\t\tsubscriptions,\n\t\t\t\tincomingTransport,\n\t\t\t\toutgoingTransport,\n\t\t\t\t...wsOptions\n\t\t\t} = wsWithOtherOptions;\n\t\t\t\n\t\t\tthis.ws = new WS(wsOptions) as WSWithActualProps<O>;\n\t\t\t\n\t\t\tif (subscriptions !== null)\n\t\t\t\tSubscription.bindTo(this.ws);\n\t\t\t\n\t\t\tif (incomingTransport)\n\t\t\t\tthis.incomingTransport = new IncomingTransport(this.ws, typeof incomingTransport == \"object\" ? incomingTransport : {});\n\t\t\t\n\t\t\tif (outgoingTransport)\n\t\t\t\tthis.outgoingTransport = new OutgoingTransport(this.ws);\n\t\t\t\n\t\t\tif (cookieOptions !== null)\n\t\t\t\tthis.cookie = new CookieSetter(this.ws, cookieOptions);\n\t\t\t\n\t\t\tif (users !== null && subscriptions !== null && cookieOptions !== null) {\n\t\t\t\tthis.user = null;\n\t\t\t\tthis.login = login<O>;\n\t\t\t\tthis.logout = logout<O>;\n\t\t\t\t\n\t\t\t\tif (isPublic)\n\t\t\t\t\tawait new Promise<void>(resolve => {\n\t\t\t\t\t\t\n\t\t\t\t\t\tnew Subscription(\"object\", \"user\", [ true ], user => {\n\t\t\t\t\t\t\tthis.user = user;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.user) {\n\t\t\t\t\t\t\t\tif (!this.isLoggedIn) {\n\t\t\t\t\t\t\t\t\tthis.isLoggedIn = true;\n\t\t\t\t\t\t\t\t\tthis.emit(\"login\", true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (this.isLoggedIn) {\n\t\t\t\t\t\t\t\tthis.isLoggedIn = false;\n\t\t\t\t\t\t\t\tthis.emit(\"logout\", false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (!this.isReady)\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\telse {\n\t\t\t\t\tthis.usersSubscriptionGroup = new UsersSubscriptionGroup({ target: this });\n\t\t\t\t\t\n\t\t\t\t\tawait new Promise<void>(resolve => {\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.usersSubscriptionGroup.once(\"init\", () => {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tthis.isLoggedIn = !!this.user;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tthis.usersSubscriptionGroup.on(\"update.user\", (user: CurrentUser) => {\n\t\t\t\t\t\t\t\tif (user.valueOf()) {\n\t\t\t\t\t\t\t\t\tif (!this.isLoggedIn) {\n\t\t\t\t\t\t\t\t\t\tthis.isLoggedIn = true;\n\t\t\t\t\t\t\t\t\t\tthis.emit(\"login\", true);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else if (this.isLoggedIn) {\n\t\t\t\t\t\t\t\t\tthis.isLoggedIn = false;\n\t\t\t\t\t\t\t\t\tthis.emit(\"logout\", false);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.isLoggedIn)\n\t\t\t\t\t\t\t\tthis.emit(\"login\", true);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tthis.isReady = true;\n\t\t\tthis.emit(\"ready\", true);\n\t\t\t\n\t\t\tthis.#initPromise.resolve(this);\n\t\t}\n\t\t\n\t}\n\t\n\t#initPromise = new StatefulPromise<this>();\n\t\n\twhenReady() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\t\n\tstatic init<IO extends Options<any>, IS extends InSite<IO>>(options: IO, asPromise: true): Promise<OmitRedundant<IS, IO>>;\n\tstatic init<IO extends Options<any>, IS extends InSite<IO>>(options?: IO, asPromise?: false): OmitRedundant<IS, IO>;\n\tstatic init<IO extends Options<any>, IS extends InSite<IO>>(options?: IO, asPromise = false) {\n\t\tconst inSite = new InSite(options) as IS;\n\t\t\n\t\treturn asPromise ?\n\t\t\tinSite.whenReady() :\n\t\t\tinSite;\n\t}\n\t\n}\n", "export function noop() { /**/ }\n", "import { noop } from \"./noop.js\";\n\n\ntype Callback<Result> = (...args: unknown[]) => Result;\ntype FunctionOrBoolean = (() => unknown) | boolean;\ntype Options = { leading?: FunctionOrBoolean; maxWait?: number; trailing?: FunctionOrBoolean };\ntype NumberOrUndefined = number | undefined;\n\ntype DebouncedFunction<Result> = {\n\t(this: unknown, ..._args: unknown[]): Promise<Result>;\n};\n\nexport type Debounced<Result> = {\n\tcallback: Callback<Result>;\n\tpromise: {\n\t\tisResolved: boolean;\n\t} & Promise<unknown>;\n\tresolve: (value: Result) => void;\n\trun(): Promise<Result>;\n\tclear(shouldRun?: boolean): Promise<void>;\n} & DebouncedFunction<Result>;\n\n\nexport function debounce<Result>(callback: Callback<Result>, limit = 0, options: Options = {}) {\n\tlet { leading = false, trailing = true } = options;\n\tconst { maxWait = Infinity } = options;\n\t\n\tlet timeout: NumberOrUndefined;\n\tlet maxWaitTimeout: NumberOrUndefined;\n\tlet end: NumberOrUndefined;\n\tlet context: unknown;\n\tlet args: unknown[];\n\tlet initial: FunctionOrBoolean;\n\tlet final: FunctionOrBoolean;\n\tlet result: Result;\n\t\n\tconst expired = async () => {\n\t\t\n\t\tconst n = Date.now();\n\t\t\n\t\tif (n >= end!) {\n\t\t\ttimeout = undefined;\n\t\t\tend = undefined;\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tif (typeof final == \"function\")\n\t\t\t\tawait final();\n\t\t\tdebounced.resolve(result);\n\t\t\tdebounced.promise.isResolved = true;\n\t\t\tinitial = leading;\n\t\t} else {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = setTimeout(expired, end! - n);\n\t\t}\n\t\t\n\t};\n\t\n\tconst maxWaitExpired = Number.isFinite(maxWait) ? () => {\n\t\t\n\t\tif (final === run)\n\t\t\tfinal = false;\n\t\trun();\n\t\tmaxWaitTimeout = setTimeout(maxWaitExpired as TimerHandler, maxWait);\n\t\t\n\t} : null;\n\t\n\tasync function run() {\n\t\treturn (result = await callback.apply(context, args));\n\t}\n\t\n\tif (leading && typeof leading == \"boolean\")\n\t\tleading = run;\n\tinitial = leading;\n\t\n\tif (trailing && typeof trailing == \"boolean\")\n\t\ttrailing = run;\n\tfinal = trailing;\n\t\n\tconst debounced: Debounced<Result> = Object.assign(function (..._args) {\n\t\targs = _args;\n\t\tcontext = this;// eslint-disable-line no-invalid-this\n\t\t\n\t\tend = Date.now() + limit;\n\t\tfinal = trailing;\n\t\t\n\t\tif (debounced.promise.isResolved)\n\t\t\tdebounced.promise = Object.assign(new Promise(resolve => {\n\t\t\t\tdebounced.resolve = resolve;\n\t\t\t\t\n\t\t\t\tif (typeof initial == \"function\") {\n\t\t\t\t\tinitial();\n\t\t\t\t\tinitial = false;\n\t\t\t\t\tif (final === run)\n\t\t\t\t\t\tfinal = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!timeout) {\n\t\t\t\t\ttimeout = setTimeout(expired, limit);\n\t\t\t\t\tif (maxWaitExpired)\n\t\t\t\t\t\tmaxWaitTimeout = setTimeout(maxWaitExpired, maxWait);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}), {\n\t\t\t\tisResolved: false\n\t\t\t});\n\t\t\n\t\treturn debounced.promise;\n\t} as DebouncedFunction<Result>, {\n\t\tcallback,\n\t\tpromise: Object.assign(Promise.resolve(), {\n\t\t\tisResolved: true\n\t\t}),\n\t\tresolve: noop,\n\t\trun,\n\t\tclear: async (shouldRun?: boolean) => {\n\t\t\t\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\t\n\t\t\tdebounced.promise.isResolved = true;\n\t\t\tdebounced.resolve(shouldRun ? await run() : result);\n\t\t\t\n\t\t}\n\t});\n\t\n\treturn debounced;\n}\n\n\ndebounce.noop = Object.assign(() => { /**/ }, {\n\tcallback: noop,\n\tpromise: Object.assign(Promise.resolve(), {\n\t\tisResolved: true\n\t}),\n\tresolve: noop,\n\trun: noop,\n\tclear: noop\n}) as unknown as Debounced<void>;\n\n\nexport function throttle<Result>(callback: Callback<Result>, limit?: number, options?: Options) {\n\treturn debounce(callback, limit, {\n\t\tmaxWait: limit,\n\t\tleading: true,\n\t\ttrailing: true,\n\t\t...options\n\t});\n}\n", "export function howmuch(number: [] | number, one: string, two: string, five: boolean | string, shouldPrintNumber = true) {\n\tif (Array.isArray(number))\n\t\tnumber = number.length;\n\t\n\tif (typeof five != \"string\") {\n\t\tshouldPrintNumber = five ?? true;\n\t\tfive = two;\n\t}\n\t\n\t\n\treturn (shouldPrintNumber ? `${number}\u00A0` : \"\") + howmuch.raw(number, one, two, five);\n}\n\nhowmuch.raw = (number: number, one: string, two: string, five = two) => {\n\tnumber = Math.abs(number);\n\tconst u = number % 10;\n\tconst d = number % 100;\n\t\n\treturn (\n\t\t(u === 1 && d !== 11) ?\n\t\t\tone :\n\t\t\t((u >= 2 && u <= 4) && !(d >= 12 && d <= 15)) ?\n\t\t\t\ttwo :\n\t\t\t\tfive\n\t);\n};\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype Value<T> = PromiseLike<T> | T;\ntype Resolve<T> = (value: Value<T>) => void;\ntype Reject = (reason?: any) => void;\n\nconst nativesMap = new WeakMap<StatefulPromise<any>, { resolve: Resolve<any>; reject: Reject }>();\n\n\nexport class StatefulPromise<T> extends Promise<T> {\n\tconstructor(executor?: (resolve: Resolve<T>, reject: Reject) => void) {\n\t\t\n\t\tlet nativeResolve: Resolve<T>;\n\t\tlet nativeReject: Reject;\n\t\t\n\t\tsuper((resolve, reject) => {\n\t\t\tnativeResolve = resolve;\n\t\t\tnativeReject = reject;\n\t\t\t\n\t\t});\n\t\t\n\t\tnativesMap.set(this, { resolve: nativeResolve!, reject: nativeReject! });\n\t\t\n\t\texecutor?.(this.resolve, this.reject);\n\t\t\n\t}\n\t\n\tisPending = true;\n\tisFulfilled = false;\n\tisRejected = false;\n\t\n\tstate: \"fulfilled\" | \"pending\" | \"rejected\" = \"pending\";\n\t\n\tresult?: any;\n\t\n\tresolve = (value: Value<T>) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isFulfilled = true;\n\t\t\tthis.state = \"fulfilled\";\n\t\t\tthis.result = value;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.resolve.call(this, value);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\treject = (reason?: any) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isRejected = true;\n\t\t\tthis.state = \"rejected\";\n\t\t\tthis.result = reason;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.reject.call(this, reason);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n}\n", "export * from \"./InSite\";\nexport type { Options } from \"./types\";\nexport * from \"insite-common/frontend\";\nexport type { Options as CookieOptions } from \"insite-cookie/client\";\nexport * from \"insite-cookie/client\";\nexport * from \"insite-subscriptions-client\";\nexport * from \"insite-users-client\";\nexport * from \"insite-ws-transfers/browser\";\nexport type { Options as WSOptions } from \"insite-ws/client\";\nexport * from \"insite-ws/client\";\n"],
|
|
5
|
-
"mappings": "iaAAA,OAAOA,MAAkB,gBCAnB,SAAUC,GAAI,CAAU,
|
|
6
|
-
"names": ["EventEmitter", "noop", "
|
|
3
|
+
"sources": ["../src/InSite.ts", "../../../../@nesvet/npm/n/src/noop.ts", "../../../../@nesvet/npm/n/src/StatefulPromise.ts", "../../../../@nesvet/npm/n/src/debounce.ts", "../../../../@nesvet/npm/n/src/howmuch.ts", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import EventEmitter from \"eventemitter3\";\nimport { StatefulPromise } from \"@nesvet/n\";\nimport type { AbilitiesSchema } from \"insite-common\";\nimport { CookieSetter } from \"insite-cookie/client\";\nimport { Subscription } from \"insite-subscriptions-client\";\nimport {\n\tUsersSubscriptionGroup,\n\ttype CurrentUser,\n\ttype Orgs,\n\ttype OrgsExtended,\n\ttype Roles,\n\ttype Users,\n\ttype UsersExtended\n} from \"insite-users-client\";\nimport { IncomingTransport, OutgoingTransport } from \"insite-ws-transfers/browser\";\nimport { WS } from \"insite-ws/client\";\nimport type { OmitRedundant, Options, WSWithActualProps } from \"./types\";\n\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n\n/** @this InSite */\nfunction login<O extends Options<any>>(this: InSite<O>, email: string, password: string) {\n\treturn this.ws.sendRequest(\"login\", email, password);\n}\n\n/** @this InSite */\nfunction logout<O extends Options<any>>(this: InSite<O>) {\n\treturn this.ws.sendRequest(\"logout\");\n}\n\n\nexport class InSite<\n\tO extends Options<any>,\n\tAS extends AbilitiesSchema = O extends Options<infer A> ? A : never\n> extends EventEmitter {\n\tconstructor(options?: O) {\n\t\tsuper();\n\t\t\n\t\tif (options)\n\t\t\tvoid this.init(options);\n\t\t\n\t}\n\t\n\tws!: WSWithActualProps<O>;\n\tincomingTransport!: IncomingTransport;\n\toutgoingTransport!: OutgoingTransport;\n\tcookie!: CookieSetter;\n\tusersSubscriptionGroup!: UsersSubscriptionGroup;\n\tuser!: CurrentUser<AS> | null;\n\tusers!: Users | UsersExtended;\n\torgs!: Orgs | OrgsExtended;\n\troles!: Roles;\n\tisLoggedIn = false;\n\t\n\tlogin!: typeof login<O>;\n\tlogout!: typeof logout<O>;\n\t\n\tisReady = false;\n\t\n\tprotected async init(options?: O) {\n\t\t\n\t\tif (!this.isReady) {\n\t\t\tconst {\n\t\t\t\tws: wsWithOtherOptions = {},\n\t\t\t\tcookie: cookieOptions,\n\t\t\t\tusers,\n\t\t\t\tpublic: isPublic\n\t\t\t} = options ?? {};\n\t\t\t\n\t\t\tconst {\n\t\t\t\tsubscriptions,\n\t\t\t\tincomingTransport,\n\t\t\t\toutgoingTransport,\n\t\t\t\t...wsOptions\n\t\t\t} = wsWithOtherOptions;\n\t\t\t\n\t\t\tthis.ws = new WS(wsOptions) as WSWithActualProps<O>;\n\t\t\t\n\t\t\tif (subscriptions !== null)\n\t\t\t\tSubscription.bindTo(this.ws);\n\t\t\t\n\t\t\tif (incomingTransport)\n\t\t\t\tthis.incomingTransport = new IncomingTransport(this.ws, typeof incomingTransport == \"object\" ? incomingTransport : {});\n\t\t\t\n\t\t\tif (outgoingTransport)\n\t\t\t\tthis.outgoingTransport = new OutgoingTransport(this.ws);\n\t\t\t\n\t\t\tif (cookieOptions !== null)\n\t\t\t\tthis.cookie = new CookieSetter(this.ws, cookieOptions);\n\t\t\t\n\t\t\tif (users !== null && subscriptions !== null && cookieOptions !== null) {\n\t\t\t\tthis.user = null;\n\t\t\t\tthis.login = login<O>;\n\t\t\t\tthis.logout = logout<O>;\n\t\t\t\t\n\t\t\t\tif (isPublic)\n\t\t\t\t\tawait new Promise<void>(resolve => {\n\t\t\t\t\t\t\n\t\t\t\t\t\tnew Subscription(\"object\", \"user\", [ true ], user => {\n\t\t\t\t\t\t\tthis.user = user;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.user) {\n\t\t\t\t\t\t\t\tif (!this.isLoggedIn) {\n\t\t\t\t\t\t\t\t\tthis.isLoggedIn = true;\n\t\t\t\t\t\t\t\t\tthis.emit(\"login\", true);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else if (this.isLoggedIn) {\n\t\t\t\t\t\t\t\tthis.isLoggedIn = false;\n\t\t\t\t\t\t\t\tthis.emit(\"logout\", false);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (!this.isReady)\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\telse {\n\t\t\t\t\tthis.usersSubscriptionGroup = new UsersSubscriptionGroup({ target: this });\n\t\t\t\t\t\n\t\t\t\t\tawait new Promise<void>(resolve => {\n\t\t\t\t\t\t\n\t\t\t\t\t\tthis.usersSubscriptionGroup.once(\"init\", () => {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tthis.isLoggedIn = !!this.user;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tthis.usersSubscriptionGroup.on(\"update.user\", (user: CurrentUser) => {\n\t\t\t\t\t\t\t\tif (user.valueOf()) {\n\t\t\t\t\t\t\t\t\tif (!this.isLoggedIn) {\n\t\t\t\t\t\t\t\t\t\tthis.isLoggedIn = true;\n\t\t\t\t\t\t\t\t\t\tthis.emit(\"login\", true);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else if (this.isLoggedIn) {\n\t\t\t\t\t\t\t\t\tthis.isLoggedIn = false;\n\t\t\t\t\t\t\t\t\tthis.emit(\"logout\", false);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (this.isLoggedIn)\n\t\t\t\t\t\t\t\tthis.emit(\"login\", true);\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tthis.isReady = true;\n\t\t\tthis.emit(\"ready\", true);\n\t\t\t\n\t\t\tthis.#initPromise.resolve(this);\n\t\t}\n\t\t\n\t}\n\t\n\t#initPromise = new StatefulPromise<this>();\n\t\n\twhenReady() {\n\t\treturn this.#initPromise;\n\t}\n\t\n\t\n\tstatic init<IO extends Options<any>, IS extends InSite<IO>>(options: IO, asPromise: true): Promise<OmitRedundant<IS, IO>>;\n\tstatic init<IO extends Options<any>, IS extends InSite<IO>>(options?: IO, asPromise?: false): OmitRedundant<IS, IO>;\n\tstatic init<IO extends Options<any>, IS extends InSite<IO>>(options?: IO, asPromise = false) {\n\t\tconst inSite = new InSite(options) as IS;\n\t\t\n\t\treturn asPromise ?\n\t\t\tinSite.whenReady() :\n\t\t\tinSite;\n\t}\n\t\n}\n", "export function noop() { /**/ }\n", "/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype Value<T> = PromiseLike<T> | T;\ntype Resolve<T> = (value: Value<T>) => void;\ntype Reject = (reason?: any) => void;\n\ntype Options = {\n\tsignal?: AbortSignal;\n\ttimeout?: number;\n};\n\nconst nativesMap = new WeakMap<StatefulPromise<any>, { resolve: Resolve<any>; reject: Reject }>();\n\n\nexport class StatefulPromise<T> extends Promise<T> {\n\tconstructor(\n\t\texecutor?: (resolve: Resolve<T>, reject: Reject) => void,\n\t\toptions?: Options\n\t) {\n\t\tlet nativeResolve: Resolve<T>;\n\t\tlet nativeReject: Reject;\n\t\t\n\t\tsuper((resolve, reject) => {\n\t\t\tnativeResolve = resolve;\n\t\t\tnativeReject = reject;\n\t\t\t\n\t\t});\n\t\t\n\t\tnativesMap.set(this, { resolve: nativeResolve!, reject: nativeReject! });\n\t\t\n\t\tif (options?.signal)\n\t\t\tif (options.signal.aborted)\n\t\t\t\tthis.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\telse {\n\t\t\t\tconst abortListener = () => this.reject(new DOMException(\"Aborted\", \"AbortError\"));\n\t\t\t\t\n\t\t\t\toptions.signal.addEventListener(\"abort\", abortListener);\n\t\t\t\t\n\t\t\t\tthis.finally(() => options.signal?.removeEventListener(\"abort\", abortListener));\n\t\t\t}\n\t\t\n\t\tif (typeof options?.timeout === \"number\" && Number.isFinite(options.timeout)) {\n\t\t\tconst timeout = setTimeout(() => this.reject(new DOMException(\"Timeout exceeded\", \"TimeoutError\")), options.timeout);\n\t\t\t\n\t\t\tthis.finally(() => clearTimeout(timeout));\n\t\t}\n\t\t\n\t\texecutor?.(this.resolve, this.reject);\n\t\t\n\t}\n\t\n\tisPending = true;\n\tisFulfilled = false;\n\tisRejected = false;\n\t\n\tstate: \"fulfilled\" | \"pending\" | \"rejected\" = \"pending\";\n\t\n\tresult?: T | unknown;\n\t\n\treadonly resolve = (value: Value<T>) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isFulfilled = true;\n\t\t\tthis.state = \"fulfilled\";\n\t\t\tthis.result = value;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.resolve.call(this, value);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\treadonly reject = (reason?: any) => {\n\t\t\n\t\tif (this.isPending) {\n\t\t\tthis.isPending = false;\n\t\t\tthis.isRejected = true;\n\t\t\tthis.state = \"rejected\";\n\t\t\tthis.result = reason;\n\t\t\t\n\t\t\tconst native = nativesMap.get(this);\n\t\t\t\n\t\t\tif (native) {\n\t\t\t\tnative.reject.call(this, reason);\n\t\t\t\tnativesMap.delete(this);\n\t\t\t}\n\t\t}\n\t\t\n\t};\n\t\n\t\n\tstatic resolved<U>(value: U): StatefulPromise<U> {\n\t\treturn new StatefulPromise<U>(resolve => resolve(value));\n\t}\n\t\n\tstatic rejected(reason: unknown): StatefulPromise<never> {\n\t\treturn new StatefulPromise((_, reject) => reject(reason));\n\t}\n\t\n}\n", "import { noop } from \"./noop.js\";\nimport { StatefulPromise } from \"./StatefulPromise.js\";\n\n\ntype Callback = (...args: any[]) => unknown;// eslint-disable-line @typescript-eslint/no-explicit-any\ntype FunctionOrBoolean = (() => unknown) | boolean;\ntype Options = { leading?: FunctionOrBoolean; maxWait?: number; trailing?: FunctionOrBoolean };\n\ntype DebouncedFunction<C extends Callback> = {\n\t(this: ThisParameterType<C>, ...args: Parameters<C>): Promise<Awaited<ReturnType<C>>>;\n};\n\nexport type Debounced<C extends Callback, R extends ReturnType<C>> = DebouncedFunction<C> & {\n\tcallback: C;\n\tpromise: StatefulPromise<R>;\n\tresolve: (value: R) => void;\n\treject: (reason?: unknown) => void;\n\trun(): Promise<R>;\n\tclear(shouldRun?: boolean): Promise<void>;\n};\n\n\nexport function debounce<C extends Callback, R extends ReturnType<C>>(callback: C, limit = 0, options: Options = {}) {\n\tlet { leading = false, trailing = true } = options;\n\tconst { maxWait = Infinity } = options;\n\t\n\tlet timeout: ReturnType<typeof setTimeout> | undefined;\n\tlet maxWaitTimeout: ReturnType<typeof setTimeout> | undefined;\n\tlet end: number | undefined;\n\tlet context: ThisParameterType<C>;\n\tlet args: unknown[];\n\tlet initial: FunctionOrBoolean;\n\tlet final: FunctionOrBoolean;\n\tlet result: R;\n\t\n\tconst expired = async () => {\n\t\t\n\t\tconst n = Date.now();\n\t\t\n\t\tif (n >= end!) {\n\t\t\ttimeout = undefined;\n\t\t\tend = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tif (typeof final == \"function\")\n\t\t\t\tawait final();\n\t\t\t\n\t\t\tdebounced.resolve(result);\n\t\t\t\n\t\t\tinitial = leading;\n\t\t} else {\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = setTimeout(expired, end! - n);\n\t\t}\n\t\t\n\t};\n\t\n\tconst maxWaitExpired = Number.isFinite(maxWait) ? () => {\n\t\t\n\t\tif (final === run)\n\t\t\tfinal = false;\n\t\t\n\t\trun();\n\t\t\n\t\tmaxWaitTimeout = setTimeout(maxWaitExpired as TimerHandler, maxWait);\n\t\t\n\t} : null;\n\t\n\tasync function run() {\n\t\ttry {\n\t\t\tresult = await callback.apply(context, args) as R;\n\t\t\t\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tdebounced.reject(error);\n\t\t\t\n\t\t\tthrow error;\n\t\t}\n\t}\n\t\n\tif (leading && typeof leading == \"boolean\")\n\t\tleading = run;\n\tinitial = leading;\n\t\n\tif (trailing && typeof trailing == \"boolean\")\n\t\ttrailing = run;\n\tfinal = trailing;\n\t\n\tconst debounced: Debounced<C, R> = Object.assign(function (..._args) {\n\t\targs = _args;\n\t\tcontext = this;// eslint-disable-line no-invalid-this\n\t\t\n\t\tend = Date.now() + limit;\n\t\tfinal = trailing;\n\t\t\n\t\tif (!debounced.promise.isPending)\n\t\t\tdebounced.promise = new StatefulPromise<R>((resolve, reject) => {\n\t\t\t\tdebounced.resolve = resolve;\n\t\t\t\tdebounced.reject = reject;\n\t\t\t\t\n\t\t\t\tif (typeof initial == \"function\") {\n\t\t\t\t\tinitial();\n\t\t\t\t\t\n\t\t\t\t\tinitial = false;\n\t\t\t\t\t\n\t\t\t\t\tif (final === run)\n\t\t\t\t\t\tfinal = false;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (!timeout) {\n\t\t\t\t\ttimeout = setTimeout(expired, limit);\n\t\t\t\t\t\n\t\t\t\t\tif (maxWaitExpired)\n\t\t\t\t\t\tmaxWaitTimeout = setTimeout(maxWaitExpired, maxWait);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t});\n\t\t\n\t\treturn debounced.promise;\n\t} as DebouncedFunction<C>, {\n\t\tcallback,\n\t\tpromise: StatefulPromise.resolved(undefined as unknown as R),\n\t\tresolve: noop,\n\t\treject: noop,\n\t\trun,\n\t\tclear: async (shouldRun?: boolean) => {\n\t\t\t\n\t\t\tclearTimeout(timeout);\n\t\t\ttimeout = undefined;\n\t\t\t\n\t\t\tclearTimeout(maxWaitTimeout);\n\t\t\tmaxWaitTimeout = undefined;\n\t\t\t\n\t\t\tdebounced.resolve(shouldRun ? await run() : result);\n\t\t\t\n\t\t}\n\t});\n\t\n\treturn debounced;\n}\n\n\ndebounce.noop = Object.assign(() => { /**/ }, {\n\tcallback: noop,\n\tpromise: StatefulPromise.resolved(undefined), // eslint-disable-line unicorn/no-useless-undefined\n\tresolve: noop,\n\treject: noop,\n\trun: noop,\n\tclear: noop\n}) as Debounced<() => void, void>;\n\n\nexport function throttle(callback: Callback, limit?: number, options?: Options) {\n\treturn debounce(callback, limit, {\n\t\tmaxWait: limit,\n\t\tleading: true,\n\t\ttrailing: true,\n\t\t...options\n\t});\n}\n", "export function howmuch(number: [] | number, one: string, two: string, five: boolean | string, shouldPrintNumber = true) {\n\tif (Array.isArray(number))\n\t\tnumber = number.length;\n\t\n\tif (typeof five != \"string\") {\n\t\tshouldPrintNumber = five ?? true;\n\t\tfive = two;\n\t}\n\t\n\t\n\treturn (shouldPrintNumber ? `${number}\u00A0` : \"\") + howmuch.raw(number, one, two, five);\n}\n\nhowmuch.raw = (number: number, one: string, two: string, five = two) => {\n\tnumber = Math.abs(number);\n\tconst u = number % 10;\n\tconst d = number % 100;\n\t\n\treturn (\n\t\t(u === 1 && d !== 11) ?\n\t\t\tone :\n\t\t\t((u >= 2 && u <= 4) && !(d >= 12 && d <= 15)) ?\n\t\t\t\ttwo :\n\t\t\t\tfive\n\t);\n};\n", "export * from \"./InSite\";\nexport type { Options } from \"./types\";\nexport * from \"insite-common/frontend\";\nexport type { Options as CookieOptions } from \"insite-cookie/client\";\nexport * from \"insite-cookie/client\";\nexport * from \"insite-subscriptions-client\";\nexport * from \"insite-users-client\";\nexport * from \"insite-ws-transfers/browser\";\nexport type { Options as WSOptions } from \"insite-ws/client\";\nexport * from \"insite-ws/client\";\n"],
|
|
5
|
+
"mappings": "iaAAA,OAAOA,MAAkB,gBCAnB,SAAUC,GAAI,CAAU,CCW9B,IAAMC,EAAa,IAAI,QAGVC,EAAP,MAAOC,UAA2B,OAAU,CACjD,YACCC,EACAC,EAAiB,CAEjB,IAAIC,EACAC,EAEJ,MAAM,CAACC,EAASC,IAAU,CACzBH,EAAgBE,EAChBD,EAAeE,CAEhB,CAAC,EAyBFC,EAAA,iBAAY,IACZA,EAAA,mBAAc,IACdA,EAAA,kBAAa,IAEbA,EAAA,aAA8C,WAE9CA,EAAA,eAESA,EAAA,eAAWC,GAAmB,CAEtC,GAAI,KAAK,UAAW,CACnB,KAAK,UAAY,GACjB,KAAK,YAAc,GACnB,KAAK,MAAQ,YACb,KAAK,OAASA,EAEd,IAAMC,EAASX,EAAW,IAAI,IAAI,EAE9BW,IACHA,EAAO,QAAQ,KAAK,KAAMD,CAAK,EAC/BV,EAAW,OAAO,IAAI,EAExB,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AAK,CAAC,EAEzE,MAAM,IAAI,QAAcF,GAAW,CAElC,KAAK,uBAAuB,KAAK,OAAQ,IAAM,CAE9C,KAAK,WAAa,CAAC,CAAC,KAAK,KAEzB,KAAK,uBAAuB,GAAG,cAAgBC,GAAsB,CAChEA,EAAK,QAAQ,EACX,KAAK,aACT,KAAK,WAAa,GAClB,KAAK,KAAK,QAAS,EAAI,GAEd,KAAK,aACf,KAAK,WAAa,GAClB,KAAK,KAAK,SAAU,EAAK,EAG3B,CAAC,EAEDD,EAAQ,EAEJ,KAAK,YACR,KAAK,KAAK,QAAS,EAAI,CAEzB,CAAC,CAEF,CAAC,IAIH,KAAK,QAAU,GACf,KAAK,KAAK,QAAS,EAAI,EAEvBG,EAAA,KAAKvB,GAAa,QAAQ,IAAI,CAC/B,CAED,CAIA,WAAY,CACX,OAAOuB,EAAA,KAAKvB,EACb,CAKA,OAAO,KAAqDG,EAAcqB,EAAY,GAAO,CAC5F,IAAMC,EAAS,IAAIxB,EAAOE,CAAO,EAEjC,OAAOqB,EACNC,EAAO,UAAU,EACjBA,CACF,CAED,EAjBCzB,EAAA,YA/HM,IAAM0B,EAANzB,EK/BP,WAAc,yBAEd,WAAc,uBACd,WAAc,8BACd,WAAc,sBACd,WAAc,8BAEd,WAAc",
|
|
6
|
+
"names": ["EventEmitter", "noop", "nativesMap", "StatefulPromise", "_StatefulPromise", "executor", "options", "nativeResolve", "nativeReject", "resolve", "reject", "__publicField", "value", "native", "reason", "abortListener", "timeout", "_", "debounce", "callback", "limit", "options", "leading", "trailing", "maxWait", "timeout", "maxWaitTimeout", "end", "context", "args", "initial", "final", "result", "expired", "n", "debounced", "maxWaitExpired", "run", "error", "_args", "StatefulPromise", "resolve", "reject", "noop", "shouldRun", "howmuch", "number", "one", "two", "five", "shouldPrintNumber", "u", "d", "CookieSetter", "Subscription", "UsersSubscriptionGroup", "IncomingTransport", "OutgoingTransport", "WS", "login", "email", "password", "logout", "_initPromise", "_InSite", "EventEmitter", "options", "__publicField", "__privateAdd", "StatefulPromise", "wsWithOtherOptions", "cookieOptions", "users", "isPublic", "subscriptions", "incomingTransport", "outgoingTransport", "wsOptions", "WS", "Subscription", "IncomingTransport", "OutgoingTransport", "CookieSetter", "resolve", "user", "UsersSubscriptionGroup", "__privateGet", "asPromise", "inSite", "InSite"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
2
|
+
"name": "insite-client",
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "Client-side inSite app",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"packageManager": "bun@1.2.11",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
+
"build": "bun .conveyer.js",
|
|
12
|
+
"postbuild": "tsc -p ."
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/nesvet/insite-client.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"insite",
|
|
20
|
+
"client",
|
|
21
|
+
"app"
|
|
22
|
+
],
|
|
23
|
+
"author": "Eugene Nesvetaev <dev@nesvet.dev> (https://nesvet.dev/)",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@nesvet/n": "^1.2.0",
|
|
27
|
+
"eventemitter3": "^5.0.1",
|
|
28
|
+
"insite-common": "^2.3.0",
|
|
29
|
+
"insite-cookie": "^2.3.0",
|
|
30
|
+
"insite-subscriptions-client": "^2.3.0",
|
|
31
|
+
"insite-users-client": "^2.3.0",
|
|
32
|
+
"insite-ws": "^2.3.0",
|
|
33
|
+
"insite-ws-transfers": "^2.3.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@nesvet/conveyer": "^2.5.2",
|
|
37
|
+
"@nesvet/eslint-config": "^2.1.1",
|
|
38
|
+
"typescript": "^5.8.3"
|
|
39
|
+
}
|
|
40
40
|
}
|