@deephaven/jsapi-utils 0.37.4-logout.21 → 0.37.4-relative-links.2
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
|
@@ -52,5 +52,5 @@ export declare function makeResponse<T>(messageId: string, payload: T): Response
|
|
|
52
52
|
* @param timeout Timeout in ms
|
|
53
53
|
* @returns Payload of the given type, or undefined
|
|
54
54
|
*/
|
|
55
|
-
export declare function requestParentResponse
|
|
55
|
+
export declare function requestParentResponse(request: string, timeout?: number): Promise<unknown>;
|
|
56
56
|
//# sourceMappingURL=MessageUtils.d.ts.map
|
|
@@ -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;;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,w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Q,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,CACzC,OAAO,EAAE,MAAM,EACf,OAAO,SAAQ,GACd,OAAO,CAAC,OAAO,CAAC,CA6BlB"}
|
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 */\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
|
|
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(\n request: string,\n timeout = 30000\n): Promise<unknown> {\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);\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,CAACC,OAAO,KAAKJ,uBAAuB;AAClE;AAEA,OAAO,SAASO,wBAAwB,CACtCJ,GAAY,EACmB;EAC/B,OAAOD,SAAS,CAACC,GAAG,CAAC,IAAIA,GAAG,CAACC,OAAO,KAAKH,wBAAwB;AACnE;AAEA,OAAO,SAASO,UAAU,CAACL,GAAY,EAAmB;EACxD,IAAMM,QAAQ,GAAGN,GAAe;EAChC,OAAOM,QAAQ,IAAI,IAAI,IAAI,OAAOA,QAAQ,CAACJ,EAAE,KAAK,QAAQ;AAC5D;;AAEA;AACA;AACA;AACA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EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAIZ;
|
|
1
|
+
{"version":3,"file":"SessionUtils.d.ts","sourceRoot":"","sources":["../src/SessionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,UAAU,EACV,aAAa,EACb,UAAU,EACX,MAAM,wBAAwB,CAAC;AAWhC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,EAAE,aAAa,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAIpE;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CA2BzB;AAED,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAIZ;AAcD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC,CAOjE;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,aAAa,EACzB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAWrC"}
|
package/dist/SessionUtils.js
CHANGED
|
@@ -49,12 +49,19 @@ export function createCoreClient(websocketUrl, options) {
|
|
|
49
49
|
log.info('createCoreClient', websocketUrl);
|
|
50
50
|
return new dh.CoreClient(websocketUrl, options);
|
|
51
51
|
}
|
|
52
|
+
function isSessionDetails(obj) {
|
|
53
|
+
return obj != null && typeof obj === 'object';
|
|
54
|
+
}
|
|
52
55
|
function requestParentSessionDetails() {
|
|
53
56
|
return _requestParentSessionDetails.apply(this, arguments);
|
|
54
57
|
}
|
|
55
58
|
function _requestParentSessionDetails() {
|
|
56
59
|
_requestParentSessionDetails = _asyncToGenerator(function* () {
|
|
57
|
-
|
|
60
|
+
var response = yield requestParentResponse(SESSION_DETAILS_REQUEST);
|
|
61
|
+
if (!isSessionDetails(response)) {
|
|
62
|
+
throw new Error("Unexpected session details response: ".concat(response));
|
|
63
|
+
}
|
|
64
|
+
return response;
|
|
58
65
|
});
|
|
59
66
|
return _requestParentSessionDetails.apply(this, arguments);
|
|
60
67
|
}
|
package/dist/SessionUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionUtils.js","names":["requestParentResponse","SESSION_DETAILS_REQUEST","Log","shortid","NoConsolesError","isNoConsolesError","log","module","createConnection","websocketUrl","info","dh","IdeConnection","createSessionWrapper","connection","details","types","getConsoleTypes","length","type","session","startSession","config","id","generate","createCoreClient","options","CoreClient","requestParentSessionDetails","getSessionDetails","searchParams","URLSearchParams","window","location","search","get","loadSessionWrapper","sessionDetails","sessionWrapper","e"],"sources":["../src/SessionUtils.ts"],"sourcesContent":["import {\n ConnectOptions,\n CoreClient,\n IdeConnection,\n IdeSession,\n} from '@deephaven/jsapi-types';\nimport {\n requestParentResponse,\n SESSION_DETAILS_REQUEST,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport shortid from 'shortid';\nimport NoConsolesError, { isNoConsolesError } from './NoConsolesError';\n\nconst log = Log.module('SessionUtils');\n\nexport interface SessionConfig {\n type: string;\n id: string;\n}\n\nexport interface SessionDetails {\n workerName?: string;\n processInfoId?: string;\n}\n\nexport interface SessionWrapper {\n session: IdeSession;\n connection: IdeConnection;\n config: SessionConfig;\n details?: SessionDetails;\n}\n\n/**\n * @returns New connection to the server\n */\nexport function createConnection(websocketUrl: string): IdeConnection {\n log.info(`Starting connection to '${websocketUrl}'...`);\n\n return new dh.IdeConnection(websocketUrl);\n}\n\n/**\n * Create a new session using the default URL\n * @returns A session and config that is ready to use\n */\nexport async function createSessionWrapper(\n connection: IdeConnection,\n details: SessionDetails\n): Promise<SessionWrapper> {\n log.info('Getting console types...');\n\n const types = await connection.getConsoleTypes();\n\n if (types.length === 0) {\n throw new NoConsolesError('No console types available');\n }\n\n log.info('Available types:', types);\n\n const type = types[0];\n\n log.info('Starting session with type', type);\n\n const session = await connection.startSession(type);\n\n const config = { type, id: shortid.generate() };\n\n log.info('Console session established', config);\n\n return {\n session,\n config,\n connection,\n details,\n };\n}\n\nexport function createCoreClient(\n websocketUrl: string,\n options?: ConnectOptions\n): CoreClient {\n log.info('createCoreClient', websocketUrl);\n\n return new dh.CoreClient(websocketUrl, options);\n}\n\nasync function requestParentSessionDetails(): Promise<SessionDetails> {\n
|
|
1
|
+
{"version":3,"file":"SessionUtils.js","names":["requestParentResponse","SESSION_DETAILS_REQUEST","Log","shortid","NoConsolesError","isNoConsolesError","log","module","createConnection","websocketUrl","info","dh","IdeConnection","createSessionWrapper","connection","details","types","getConsoleTypes","length","type","session","startSession","config","id","generate","createCoreClient","options","CoreClient","isSessionDetails","obj","requestParentSessionDetails","response","Error","getSessionDetails","searchParams","URLSearchParams","window","location","search","get","loadSessionWrapper","sessionDetails","sessionWrapper","e"],"sources":["../src/SessionUtils.ts"],"sourcesContent":["import {\n ConnectOptions,\n CoreClient,\n IdeConnection,\n IdeSession,\n} from '@deephaven/jsapi-types';\nimport {\n requestParentResponse,\n SESSION_DETAILS_REQUEST,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport shortid from 'shortid';\nimport NoConsolesError, { isNoConsolesError } from './NoConsolesError';\n\nconst log = Log.module('SessionUtils');\n\nexport interface SessionConfig {\n type: string;\n id: string;\n}\n\nexport interface SessionDetails {\n workerName?: string;\n processInfoId?: string;\n}\n\nexport interface SessionWrapper {\n session: IdeSession;\n connection: IdeConnection;\n config: SessionConfig;\n details?: SessionDetails;\n}\n\n/**\n * @returns New connection to the server\n */\nexport function createConnection(websocketUrl: string): IdeConnection {\n log.info(`Starting connection to '${websocketUrl}'...`);\n\n return new dh.IdeConnection(websocketUrl);\n}\n\n/**\n * Create a new session using the default URL\n * @returns A session and config that is ready to use\n */\nexport async function createSessionWrapper(\n connection: IdeConnection,\n details: SessionDetails\n): Promise<SessionWrapper> {\n log.info('Getting console types...');\n\n const types = await connection.getConsoleTypes();\n\n if (types.length === 0) {\n throw new NoConsolesError('No console types available');\n }\n\n log.info('Available types:', types);\n\n const type = types[0];\n\n log.info('Starting session with type', type);\n\n const session = await connection.startSession(type);\n\n const config = { type, id: shortid.generate() };\n\n log.info('Console session established', config);\n\n return {\n session,\n config,\n connection,\n details,\n };\n}\n\nexport function createCoreClient(\n websocketUrl: string,\n options?: ConnectOptions\n): CoreClient {\n log.info('createCoreClient', websocketUrl);\n\n return new dh.CoreClient(websocketUrl, options);\n}\n\nfunction isSessionDetails(obj: unknown): obj is SessionDetails {\n return obj != null && typeof obj === 'object';\n}\n\nasync function requestParentSessionDetails(): Promise<SessionDetails> {\n const response = await requestParentResponse(SESSION_DETAILS_REQUEST);\n if (!isSessionDetails(response)) {\n throw new Error(`Unexpected session details response: ${response}`);\n }\n return response;\n}\n\nexport async function getSessionDetails(): Promise<SessionDetails> {\n const searchParams = new URLSearchParams(window.location.search);\n switch (searchParams.get('authProvider')) {\n case 'parent':\n return requestParentSessionDetails();\n }\n return {};\n}\n\nexport async function loadSessionWrapper(\n connection: IdeConnection,\n sessionDetails: SessionDetails\n): Promise<SessionWrapper | undefined> {\n let sessionWrapper: SessionWrapper | undefined;\n try {\n sessionWrapper = await createSessionWrapper(connection, sessionDetails);\n } catch (e) {\n // Consoles may be disabled on the server, but we should still be able to start up and open existing objects\n if (!isNoConsolesError(e)) {\n throw e;\n }\n }\n return sessionWrapper;\n}\n"],"mappings":";;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|
2
2
|
"name": "@deephaven/jsapi-utils",
|
|
3
|
-
"version": "0.37.4-
|
|
3
|
+
"version": "0.37.4-relative-links.2+2189ddfe",
|
|
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-
|
|
25
|
-
"@deephaven/jsapi-shim": "^0.37.4-
|
|
26
|
-
"@deephaven/jsapi-types": "^0.37.4-
|
|
27
|
-
"@deephaven/log": "^0.37.4-
|
|
28
|
-
"@deephaven/utils": "^0.37.4-
|
|
24
|
+
"@deephaven/filters": "^0.37.4-relative-links.2+2189ddfe",
|
|
25
|
+
"@deephaven/jsapi-shim": "^0.37.4-relative-links.2+2189ddfe",
|
|
26
|
+
"@deephaven/jsapi-types": "^0.37.4-relative-links.2+2189ddfe",
|
|
27
|
+
"@deephaven/log": "^0.37.4-relative-links.2+2189ddfe",
|
|
28
|
+
"@deephaven/utils": "^0.37.4-relative-links.2+2189ddfe",
|
|
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-
|
|
34
|
+
"@deephaven/tsconfig": "^0.37.4-relative-links.2+2189ddfe"
|
|
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": "2189ddfe7d10310de1be036201d39b0f969338a5"
|
|
44
44
|
}
|