@deephaven/jsapi-utils 0.37.4-logout.2 → 0.37.4-logout.21
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/MessageUtils.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ export declare const LOGIN_OPTIONS_REQUEST = "io.deephaven.message.LoginOptions.
|
|
|
2
2
|
export declare const SESSION_DETAILS_REQUEST = "io.deephaven.message.SessionDetails.request";
|
|
3
3
|
/**
|
|
4
4
|
* Use a BroadcastChannel for sending messages between tabs, such as when the user logs out.
|
|
5
|
-
* Something that isn't clear from the docs - for inter-browser communication, you must use `postMessage` and `onmessage`.
|
|
6
|
-
* `BroadcastChannel` is an `EventTarget`, and does support `addEventListener`/`dispatchEvent` etc... but that's only within the same instance of that object!
|
|
7
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API
|
|
8
5
|
*/
|
|
9
6
|
export declare const BROADCAST_CHANNEL_NAME = "io.deephaven.broadcast";
|
|
10
7
|
/**
|
|
@@ -15,7 +12,7 @@ export declare const BROADCAST_LOGIN_MESSAGE = "io.deephaven.broadcast.Login";
|
|
|
15
12
|
* Event emitted when the user has logged out
|
|
16
13
|
*/
|
|
17
14
|
export declare const BROADCAST_LOGOUT_MESSAGE = "io.deephaven.broadcast.Logout";
|
|
18
|
-
export interface Message<T> {
|
|
15
|
+
export interface Message<T = unknown> {
|
|
19
16
|
id: string;
|
|
20
17
|
message: string;
|
|
21
18
|
payload?: T;
|
|
@@ -26,14 +23,14 @@ export interface BroadcastLoginMessage extends Message<void> {
|
|
|
26
23
|
export interface BroadcastLogoutMessage extends Message<void> {
|
|
27
24
|
message: typeof BROADCAST_LOGOUT_MESSAGE;
|
|
28
25
|
}
|
|
29
|
-
export interface Response<T> {
|
|
26
|
+
export interface Response<T = unknown> {
|
|
30
27
|
id: string;
|
|
31
28
|
payload: T;
|
|
32
29
|
}
|
|
33
|
-
export declare function isMessage
|
|
30
|
+
export declare function isMessage(obj: unknown): obj is Message;
|
|
34
31
|
export declare function isBroadcastLoginMessage(obj: unknown): obj is BroadcastLoginMessage;
|
|
35
32
|
export declare function isBroadcastLogoutMessage(obj: unknown): obj is BroadcastLogoutMessage;
|
|
36
|
-
export declare function isResponse
|
|
33
|
+
export declare function isResponse(obj: unknown): obj is Response;
|
|
37
34
|
/**
|
|
38
35
|
* Make message object with optional payload
|
|
39
36
|
* @param message Message string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageUtils.d.ts","sourceRoot":"","sources":["../src/MessageUtils.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,8CACW,CAAC;AAE9C,eAAO,MAAM,uBAAuB,gDACW,CAAC;AAEhD
|
|
1
|
+
{"version":3,"file":"MessageUtils.d.ts","sourceRoot":"","sources":["../src/MessageUtils.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,qBAAqB,8CACW,CAAC;AAE9C,eAAO,MAAM,uBAAuB,gDACW,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,sBAAsB,2BAA2B,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,uBAAuB,iCAAiC,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,wBAAwB,kCAAkC,CAAC;AAExE,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,OAAO;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,CAAC,CAAC;CACb;AAED,MAAM,WAAW,qBAAsB,SAAQ,OAAO,CAAC,IAAI,CAAC;IAC1D,OAAO,EAAE,OAAO,uBAAuB,CAAC;CACzC;AAED,MAAM,WAAW,sBAAuB,SAAQ,OAAO,CAAC,IAAI,CAAC;IAC3D,OAAO,EAAE,OAAO,wBAAwB,CAAC;CAC1C;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC,GAAG,OAAO;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,OAAO,CAOtD;AAED,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,qBAAqB,CAE9B;AAED,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,sBAAsB,CAE/B;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,QAAQ,CAGxD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,OAAO,EAAE,MAAM,EACf,EAAE,SAAY,EACd,OAAO,CAAC,EAAE,CAAC,GACV,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAE1E;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAC3C,OAAO,EAAE,MAAM,EACf,OAAO,SAAQ,GACd,OAAO,CAAC,CAAC,CAAC,CA6BZ"}
|
package/dist/MessageUtils.js
CHANGED
|
@@ -9,9 +9,6 @@ export var SESSION_DETAILS_REQUEST = 'io.deephaven.message.SessionDetails.reques
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Use a BroadcastChannel for sending messages between tabs, such as when the user logs out.
|
|
12
|
-
* Something that isn't clear from the docs - for inter-browser communication, you must use `postMessage` and `onmessage`.
|
|
13
|
-
* `BroadcastChannel` is an `EventTarget`, and does support `addEventListener`/`dispatchEvent` etc... but that's only within the same instance of that object!
|
|
14
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API
|
|
15
12
|
*/
|
|
16
13
|
export var BROADCAST_CHANNEL_NAME = 'io.deephaven.broadcast';
|
|
17
14
|
|
package/dist/MessageUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageUtils.js","names":["shortid","Log","TimeoutError","log","module","LOGIN_OPTIONS_REQUEST","SESSION_DETAILS_REQUEST","BROADCAST_CHANNEL_NAME","BROADCAST_LOGIN_MESSAGE","BROADCAST_LOGOUT_MESSAGE","isMessage","obj","message","id","isBroadcastLoginMessage","isBroadcastLogoutMessage","isResponse","response","makeMessage","payload","makeResponse","messageId","requestParentResponse","request","timeout","window","opener","Error","Promise","resolve","reject","timeoutId","listener","event","data","debug","clearTimeout","removeEventListener","addEventListener","setTimeout","postMessage"],"sources":["../src/MessageUtils.ts"],"sourcesContent":["import shortid from 'shortid';\nimport Log from '@deephaven/log';\nimport { TimeoutError } from '@deephaven/utils';\n\nconst log = Log.module('MessageUtils');\n\nexport const LOGIN_OPTIONS_REQUEST =\n 'io.deephaven.message.LoginOptions.request';\n\nexport const SESSION_DETAILS_REQUEST =\n 'io.deephaven.message.SessionDetails.request';\n\n/**\n * Use a BroadcastChannel for sending messages between tabs, such as when the user logs out.\n
|
|
1
|
+
{"version":3,"file":"MessageUtils.js","names":["shortid","Log","TimeoutError","log","module","LOGIN_OPTIONS_REQUEST","SESSION_DETAILS_REQUEST","BROADCAST_CHANNEL_NAME","BROADCAST_LOGIN_MESSAGE","BROADCAST_LOGOUT_MESSAGE","isMessage","obj","message","id","isBroadcastLoginMessage","isBroadcastLogoutMessage","isResponse","response","makeMessage","payload","makeResponse","messageId","requestParentResponse","request","timeout","window","opener","Error","Promise","resolve","reject","timeoutId","listener","event","data","debug","clearTimeout","removeEventListener","addEventListener","setTimeout","postMessage"],"sources":["../src/MessageUtils.ts"],"sourcesContent":["import shortid from 'shortid';\nimport Log from '@deephaven/log';\nimport { TimeoutError } from '@deephaven/utils';\n\nconst log = Log.module('MessageUtils');\n\nexport const LOGIN_OPTIONS_REQUEST =\n 'io.deephaven.message.LoginOptions.request';\n\nexport const SESSION_DETAILS_REQUEST =\n 'io.deephaven.message.SessionDetails.request';\n\n/**\n * Use a BroadcastChannel for sending messages between tabs, such as when the user logs out.\n */\nexport const BROADCAST_CHANNEL_NAME = 'io.deephaven.broadcast';\n\n/**\n * Event emitted when the user has logged in successfully\n */\nexport const BROADCAST_LOGIN_MESSAGE = 'io.deephaven.broadcast.Login';\n\n/**\n * Event emitted when the user has logged out\n */\nexport const BROADCAST_LOGOUT_MESSAGE = 'io.deephaven.broadcast.Logout';\n\nexport interface Message<T = unknown> {\n id: string;\n message: string;\n payload?: T;\n}\n\nexport interface BroadcastLoginMessage extends Message<void> {\n message: typeof BROADCAST_LOGIN_MESSAGE;\n}\n\nexport interface BroadcastLogoutMessage extends Message<void> {\n message: typeof BROADCAST_LOGOUT_MESSAGE;\n}\n\nexport interface Response<T = unknown> {\n id: string;\n payload: T;\n}\n\nexport function isMessage(obj: unknown): obj is Message {\n const message = obj as Message;\n return (\n message != null &&\n typeof message.id === 'string' &&\n typeof message.message === 'string'\n );\n}\n\nexport function isBroadcastLoginMessage(\n obj: unknown\n): obj is BroadcastLoginMessage {\n return isMessage(obj) && obj.message === BROADCAST_LOGIN_MESSAGE;\n}\n\nexport function isBroadcastLogoutMessage(\n obj: unknown\n): obj is BroadcastLogoutMessage {\n return isMessage(obj) && obj.message === BROADCAST_LOGOUT_MESSAGE;\n}\n\nexport function isResponse(obj: unknown): obj is Response {\n const response = obj as Response;\n return response != null && typeof response.id === 'string';\n}\n\n/**\n * Make message object with optional payload\n * @param message Message string\n * @param id Unique message id\n * @param payload Payload to send\n * @returns Message\n */\nexport function makeMessage<T>(\n message: string,\n id = shortid(),\n payload?: T\n): Message<T> {\n return { message, id, payload };\n}\n\n/**\n * Make response object for given message id\n * @param messageId Id of the request message to respond to\n * @param payload Payload to respond with\n * @returns Response\n */\nexport function makeResponse<T>(messageId: string, payload: T): Response<T> {\n return { id: messageId, payload };\n}\n\n/**\n * Request data from the parent window and wait for response\n * @param request Request message to send to the parent window\n * @param timeout Timeout in ms\n * @returns Payload of the given type, or undefined\n */\nexport async function requestParentResponse<T>(\n request: string,\n timeout = 30000\n): Promise<T> {\n if (window.opener == null) {\n throw new Error('window.opener is null, unable to send request.');\n }\n return new Promise((resolve, reject) => {\n let timeoutId: number;\n const id = shortid();\n const listener = (event: MessageEvent) => {\n const { data } = event;\n if (!isResponse(data)) {\n log.debug('Ignoring non-deephaven response', data);\n return;\n }\n log.debug('Received message', data);\n if (data?.id !== id) {\n log.debug(\"Ignore message, id doesn't match\", data);\n return;\n }\n window.clearTimeout(timeoutId);\n window.removeEventListener('message', listener);\n resolve(data.payload as T);\n };\n window.addEventListener('message', listener);\n timeoutId = window.setTimeout(() => {\n window.removeEventListener('message', listener);\n reject(new TimeoutError('Request timed out'));\n }, timeout);\n window.opener.postMessage(makeMessage(request, id), '*');\n });\n}\n"],"mappings":";;AAAA,OAAOA,OAAO,MAAM,SAAS;AAC7B,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAASC,YAAY,QAAQ,kBAAkB;AAE/C,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAM,CAAC,cAAc,CAAC;AAEtC,OAAO,IAAMC,qBAAqB,GAChC,2CAA2C;AAE7C,OAAO,IAAMC,uBAAuB,GAClC,6CAA6C;;AAE/C;AACA;AACA;AACA,OAAO,IAAMC,sBAAsB,GAAG,wBAAwB;;AAE9D;AACA;AACA;AACA,OAAO,IAAMC,uBAAuB,GAAG,8BAA8B;;AAErE;AACA;AACA;AACA,OAAO,IAAMC,wBAAwB,GAAG,+BAA+B;AAqBvE,OAAO,SAASC,SAAS,CAACC,GAAY,EAAkB;EACtD,IAAMC,OAAO,GAAGD,GAAc;EAC9B,OACEC,OAAO,IAAI,IAAI,IACf,OAAOA,OAAO,CAACC,EAAE,KAAK,QAAQ,IAC9B,OAAOD,OAAO,CAACA,OAAO,KAAK,QAAQ;AAEvC;AAEA,OAAO,SAASE,uBAAuB,CACrCH,GAAY,EACkB;EAC9B,OAAOD,SAAS,CAACC,GAAG,CAAC,IAAIA,GAAG,C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,IAAI,CAAC;UAClD;QACF;QACA/B,GAAG,CAACgC,KAAK,CAAC,kBAAkB,EAAED,IAAI,CAAC;QACnC,IAAI,CAAAA,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAErB,EAAE,MAAKA,EAAE,EAAE;UACnBV,GAAG,CAACgC,KAAK,CAAC,kCAAkC,EAAED,IAAI,CAAC;UACnD;QACF;QACAT,MAAM,CAACW,YAAY,CAACL,SAAS,CAAC;QAC9BN,MAAM,CAACY,mBAAmB,CAAC,SAAS,EAAEL,QAAQ,CAAC;QAC/CH,OAAO,CAACK,IAAI,CAACf,OAAO,CAAM;MAC5B,CAAC;MACDM,MAAM,CAACa,gBAAgB,CAAC,SAAS,EAAEN,QAAQ,CAAC;MAC5CD,SAAS,GAAGN,MAAM,CAACc,UAAU,CAAC,MAAM;QAClCd,MAAM,CAACY,mBAAmB,CAAC,SAAS,EAAEL,QAAQ,CAAC;QAC/CF,MAAM,CAAC,IAAI5B,YAAY,CAAC,mBAAmB,CAAC,CAAC;MAC/C,CAAC,EAAEsB,OAAO,CAAC;MACXC,MAAM,CAACC,MAAM,CAACc,WAAW,CAACtB,WAAW,CAACK,OAAO,EAAEV,EAAE,CAAC,EAAE,GAAG,CAAC;IAC1D,CAAC,CAAC;EACJ,CAAC;EAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/jsapi-utils",
|
|
3
|
-
"version": "0.37.4-logout.
|
|
3
|
+
"version": "0.37.4-logout.21+ae439be8",
|
|
4
4
|
"description": "Deephaven JSAPI Utils",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,17 +21,17 @@
|
|
|
21
21
|
"build:babel": "babel ./src --out-dir ./dist --extensions \".ts,.tsx,.js,.jsx\" --source-maps --root-mode upward"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@deephaven/filters": "^0.37.4-logout.
|
|
25
|
-
"@deephaven/jsapi-shim": "^0.37.4-logout.
|
|
26
|
-
"@deephaven/jsapi-types": "^0.37.4-logout.
|
|
27
|
-
"@deephaven/log": "^0.37.4-logout.
|
|
28
|
-
"@deephaven/utils": "^0.37.4-logout.
|
|
24
|
+
"@deephaven/filters": "^0.37.4-logout.21+ae439be8",
|
|
25
|
+
"@deephaven/jsapi-shim": "^0.37.4-logout.21+ae439be8",
|
|
26
|
+
"@deephaven/jsapi-types": "^0.37.4-logout.21+ae439be8",
|
|
27
|
+
"@deephaven/log": "^0.37.4-logout.21+ae439be8",
|
|
28
|
+
"@deephaven/utils": "^0.37.4-logout.21+ae439be8",
|
|
29
29
|
"@react-stately/data": "^3.9.1",
|
|
30
30
|
"lodash.clamp": "^4.0.3",
|
|
31
31
|
"shortid": "^2.2.16"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@deephaven/tsconfig": "^0.37.4-logout.
|
|
34
|
+
"@deephaven/tsconfig": "^0.37.4-logout.21+ae439be8"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"dist"
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "ae439be89da6d61abc3e6f86ec734ddda74e67e3"
|
|
44
44
|
}
|