@darajs/core 1.25.5 → 1.26.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/api/events.d.ts +2 -0
- package/dist/api/events.d.ts.map +1 -0
- package/dist/api/events.js +2 -0
- package/dist/api/events.js.map +1 -0
- package/dist/api/http.d.ts.map +1 -1
- package/dist/api/http.js +19 -20
- package/dist/api/http.js.map +1 -1
- package/dist/api/websocket.d.ts +8 -17
- package/dist/api/websocket.d.ts.map +1 -1
- package/dist/api/websocket.js +64 -48
- package/dist/api/websocket.js.map +1 -1
- package/dist/auth/auth.d.ts +4 -4
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/auth/auth.js +40 -21
- package/dist/auth/auth.js.map +1 -1
- package/dist/auth/basic/basic-auth-login.d.ts.map +1 -1
- package/dist/auth/basic/basic-auth-login.js +11 -19
- package/dist/auth/basic/basic-auth-login.js.map +1 -1
- package/dist/auth/basic/basic-auth-logout.js +2 -2
- package/dist/auth/basic/basic-auth-logout.js.map +1 -1
- package/dist/auth/default/default-auth-login.d.ts +1 -1
- package/dist/auth/default/default-auth-login.d.ts.map +1 -1
- package/dist/auth/default/default-auth-login.js +13 -22
- package/dist/auth/default/default-auth-login.js.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/oidc/oidc-login.d.ts.map +1 -1
- package/dist/auth/oidc/oidc-login.js +10 -25
- package/dist/auth/oidc/oidc-login.js.map +1 -1
- package/dist/auth/oidc/oidc-logout.js +3 -3
- package/dist/auth/oidc/oidc-logout.js.map +1 -1
- package/dist/auth/oidc/sso-callback.d.ts +3 -4
- package/dist/auth/oidc/sso-callback.d.ts.map +1 -1
- package/dist/auth/oidc/sso-callback.js +4 -8
- package/dist/auth/oidc/sso-callback.js.map +1 -1
- package/dist/auth/session-state.d.ts +44 -0
- package/dist/auth/session-state.d.ts.map +1 -0
- package/dist/auth/session-state.js +194 -0
- package/dist/auth/session-state.js.map +1 -0
- package/dist/dara_core-1.26.0-py3-none-any.whl +0 -0
- package/dist/router/create-router.d.ts.map +1 -1
- package/dist/router/create-router.js +4 -5
- package/dist/router/create-router.js.map +1 -1
- package/dist/shared/interactivity/persistence.js +4 -4
- package/dist/shared/interactivity/persistence.js.map +1 -1
- package/dist/shared/interactivity/plain-variable.js +1 -1
- package/dist/shared/interactivity/plain-variable.js.map +1 -1
- package/dist/shared/root/authenticated-root.d.ts.map +1 -1
- package/dist/shared/root/authenticated-root.js +8 -22
- package/dist/shared/root/authenticated-root.js.map +1 -1
- package/dist/shared/utils/clean-session-cache.d.ts +2 -2
- package/dist/shared/utils/clean-session-cache.d.ts.map +1 -1
- package/dist/shared/utils/clean-session-cache.js +3 -3
- package/dist/shared/utils/clean-session-cache.js.map +1 -1
- package/dist/shared/utils/iframe.d.ts +5 -0
- package/dist/shared/utils/iframe.d.ts.map +1 -0
- package/dist/shared/utils/iframe.js +9 -0
- package/dist/shared/utils/iframe.js.map +1 -0
- package/dist/shared/utils/index.d.ts +1 -1
- package/dist/shared/utils/index.d.ts.map +1 -1
- package/dist/shared/utils/index.js +1 -1
- package/dist/shared/utils/index.js.map +1 -1
- package/dist/umd/dara.core.umd.cjs +3906 -3857
- package/dist/vitest-setup.js +88 -0
- package/dist/vitest-setup.js.map +1 -1
- package/package.json +10 -9
- package/dist/auth/use-session-token.d.ts +0 -19
- package/dist/auth/use-session-token.d.ts.map +0 -1
- package/dist/auth/use-session-token.js +0 -30
- package/dist/auth/use-session-token.js.map +0 -1
- package/dist/shared/global-state-store.d.ts +0 -54
- package/dist/shared/global-state-store.d.ts.map +0 -1
- package/dist/shared/global-state-store.js +0 -169
- package/dist/shared/global-state-store.js.map +0 -1
- package/dist/shared/utils/embed.d.ts +0 -22
- package/dist/shared/utils/embed.d.ts.map +0 -1
- package/dist/shared/utils/embed.js +0 -47
- package/dist/shared/utils/embed.js.map +0 -1
package/dist/vitest-setup.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
11
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
12
|
import '@testing-library/jest-dom/vitest';
|
|
@@ -26,4 +35,83 @@ global.jest = {
|
|
|
26
35
|
// @ts-expect-error vi is globally available
|
|
27
36
|
advanceTimersByTime: (ms) => vi.advanceTimersByTime(ms),
|
|
28
37
|
};
|
|
38
|
+
// Use an in-memory BroadcastChannel polyfill for tests to avoid cross-worker
|
|
39
|
+
// traffic (which can leak session-state between Vitest workers), while still
|
|
40
|
+
// supporting libs like msw that require BroadcastChannel to exist.
|
|
41
|
+
class InMemoryBroadcastChannel extends EventTarget {
|
|
42
|
+
constructor(name) {
|
|
43
|
+
var _a;
|
|
44
|
+
super();
|
|
45
|
+
this.onmessage = null;
|
|
46
|
+
this.name = name;
|
|
47
|
+
const peers = (_a = InMemoryBroadcastChannel.channels.get(name)) !== null && _a !== void 0 ? _a : new Set();
|
|
48
|
+
peers.add(this);
|
|
49
|
+
InMemoryBroadcastChannel.channels.set(name, peers);
|
|
50
|
+
}
|
|
51
|
+
postMessage(message) {
|
|
52
|
+
const peers = InMemoryBroadcastChannel.channels.get(this.name);
|
|
53
|
+
if (!peers) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const peer of peers) {
|
|
57
|
+
if (peer === this) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
peer.dispatchMessage(message);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
close() {
|
|
64
|
+
const peers = InMemoryBroadcastChannel.channels.get(this.name);
|
|
65
|
+
if (!peers) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
peers.delete(this);
|
|
69
|
+
if (peers.size === 0) {
|
|
70
|
+
InMemoryBroadcastChannel.channels.delete(this.name);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
dispatchMessage(message) {
|
|
74
|
+
var _a;
|
|
75
|
+
const event = new MessageEvent('message', { data: message });
|
|
76
|
+
(_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, event);
|
|
77
|
+
this.dispatchEvent(event);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
InMemoryBroadcastChannel.channels = new Map();
|
|
81
|
+
Object.defineProperty(globalThis, 'BroadcastChannel', {
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: InMemoryBroadcastChannel,
|
|
85
|
+
});
|
|
86
|
+
// jsdom does not currently expose navigator.locks, provide a deterministic test polyfill.
|
|
87
|
+
if (!navigator.locks) {
|
|
88
|
+
const lockTails = new Map();
|
|
89
|
+
const lockManager = {
|
|
90
|
+
request(name, callback) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
var _a;
|
|
93
|
+
const previousTail = (_a = lockTails.get(name)) !== null && _a !== void 0 ? _a : Promise.resolve();
|
|
94
|
+
let release;
|
|
95
|
+
const nextTail = new Promise((resolve) => {
|
|
96
|
+
release = resolve;
|
|
97
|
+
});
|
|
98
|
+
lockTails.set(name, previousTail.then(() => nextTail));
|
|
99
|
+
yield previousTail;
|
|
100
|
+
try {
|
|
101
|
+
return yield callback();
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
release();
|
|
105
|
+
if (lockTails.get(name) === nextTail) {
|
|
106
|
+
lockTails.delete(name);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
Object.defineProperty(navigator, 'locks', {
|
|
113
|
+
configurable: true,
|
|
114
|
+
value: lockManager,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
29
117
|
//# sourceMappingURL=vitest-setup.js.map
|
package/dist/vitest-setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-setup.js","sourceRoot":"","sources":["../js/vitest-setup.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,6DAA6D;AAC7D,OAAO,kCAAkC,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,0DAA0D;AAC1D,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,cAAc,CAAC;AAEtD,6EAA6E;AAC7E,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;AAErB,yFAAyF;AACzF,+GAA+G;AAC/G,SAAS,CAAC,0CAA0C,GAAG,KAAK,CAAC;AAE7D,4BAA4B;AAE5B,sDAAsD;AACtD,6FAA6F;AAC7F,wFAAwF;AACxF,MAAM,CAAC,KAAK,GAAG,CAAC,KAAK,EAAE,IAAK,EAAE,EAAE;IAC5B,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC7B,OAAO,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,8BAA8B;AAC9B,6HAA6H;AAC7H,+HAA+H;AAC/H,MAAM,CAAC,IAAI,GAAG;IACV,4CAA4C;IAC5C,mBAAmB,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,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"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Dara Framework core",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.23.0",
|
|
40
40
|
"@babel/preset-react": "^7.22.15",
|
|
41
41
|
"@babel/preset-typescript": "^7.23.0",
|
|
42
|
-
"@darajs/eslint-config": "1.
|
|
43
|
-
"@darajs/prettier-config": "1.
|
|
44
|
-
"@darajs/stylelint-config": "1.
|
|
42
|
+
"@darajs/eslint-config": "1.26.0",
|
|
43
|
+
"@darajs/prettier-config": "1.26.0",
|
|
44
|
+
"@darajs/stylelint-config": "1.26.0",
|
|
45
45
|
"@rollup/plugin-inject": "^4.0.4",
|
|
46
46
|
"@testing-library/dom": "^9.3.0",
|
|
47
47
|
"@testing-library/jest-dom": "^6.0.0",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
"whatwg-fetch": "^3.6.20"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@darajs/styled-components": "1.
|
|
79
|
-
"@darajs/ui-components": "1.
|
|
80
|
-
"@darajs/ui-notifications": "1.
|
|
81
|
-
"@darajs/ui-utils": "1.
|
|
78
|
+
"@darajs/styled-components": "1.26.0",
|
|
79
|
+
"@darajs/ui-components": "1.26.0",
|
|
80
|
+
"@darajs/ui-notifications": "1.26.0",
|
|
81
|
+
"@darajs/ui-utils": "1.26.0",
|
|
82
82
|
"@fortawesome/fontawesome-free": "~6.4.0",
|
|
83
83
|
"@microsoft/fetch-event-source": "^2.0.1",
|
|
84
84
|
"@recoiljs/refine": "^0.1.1",
|
|
@@ -117,5 +117,6 @@
|
|
|
117
117
|
},
|
|
118
118
|
"engines": {
|
|
119
119
|
"node": ">=20.19.0"
|
|
120
|
-
}
|
|
120
|
+
},
|
|
121
|
+
"gitHead": "974079910954da26cec92b8cb22bff86221adfcf"
|
|
121
122
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subscribe to token changes
|
|
3
|
-
*
|
|
4
|
-
* @param cb callback to call when the token changes
|
|
5
|
-
*/
|
|
6
|
-
export declare function onTokenChange(cb: (val: string | null) => void): () => void;
|
|
7
|
-
/**
|
|
8
|
-
* Retrieve the current session token
|
|
9
|
-
*/
|
|
10
|
-
export declare function getSessionToken(): string | null;
|
|
11
|
-
/**
|
|
12
|
-
* Set the session token
|
|
13
|
-
*/
|
|
14
|
-
export declare function setSessionToken(token: string | null): void;
|
|
15
|
-
/**
|
|
16
|
-
* Helper hook that synchronizes with the current session token from store
|
|
17
|
-
*/
|
|
18
|
-
export declare function useSessionToken(): string | null;
|
|
19
|
-
//# sourceMappingURL=use-session-token.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-session-token.d.ts","sourceRoot":"","sources":["../../js/auth/use-session-token.tsx"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI,CAE1E;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE1D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,GAAG,IAAI,CAE/C"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import globalStore from '../shared/global-state-store';
|
|
3
|
-
import { getTokenKey } from '../shared/utils/embed';
|
|
4
|
-
/**
|
|
5
|
-
* Subscribe to token changes
|
|
6
|
-
*
|
|
7
|
-
* @param cb callback to call when the token changes
|
|
8
|
-
*/
|
|
9
|
-
export function onTokenChange(cb) {
|
|
10
|
-
return globalStore.subscribe(getTokenKey(), cb);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Retrieve the current session token
|
|
14
|
-
*/
|
|
15
|
-
export function getSessionToken() {
|
|
16
|
-
return globalStore.getValueSync(getTokenKey());
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Set the session token
|
|
20
|
-
*/
|
|
21
|
-
export function setSessionToken(token) {
|
|
22
|
-
globalStore.setValue(getTokenKey(), token);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Helper hook that synchronizes with the current session token from store
|
|
26
|
-
*/
|
|
27
|
-
export function useSessionToken() {
|
|
28
|
-
return React.useSyncExternalStore(onTokenChange, getSessionToken);
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=use-session-token.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-session-token.js","sourceRoot":"","sources":["../../js/auth/use-session-token.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,WAAW,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,EAAgC;IAC1D,OAAO,WAAW,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC3B,OAAO,WAAW,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAoB;IAChD,WAAW,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC3B,OAAO,KAAK,CAAC,oBAAoB,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Global state store. Acts as a wrapper around localStorage.
|
|
3
|
-
*
|
|
4
|
-
* Supports a simple key-value store with subscriptions and async value replacement,
|
|
5
|
-
* while ensuring that only one replacement is in progress at a time.
|
|
6
|
-
*/
|
|
7
|
-
declare class GlobalStore {
|
|
8
|
-
#private;
|
|
9
|
-
constructor();
|
|
10
|
-
/**
|
|
11
|
-
* Clear the store.
|
|
12
|
-
* Removes all values and subscribers.
|
|
13
|
-
*/
|
|
14
|
-
clear(): void;
|
|
15
|
-
/**
|
|
16
|
-
* Get the value for a key.
|
|
17
|
-
* If the value is being replaced, the promise for the new value is returned.
|
|
18
|
-
*
|
|
19
|
-
* @param key - key to get value for
|
|
20
|
-
*/
|
|
21
|
-
getValue(key: string): Promise<string | null>;
|
|
22
|
-
/**
|
|
23
|
-
* Get the value for a key synchronously.
|
|
24
|
-
* Even if the value is being replaced, the current value is returned.
|
|
25
|
-
*
|
|
26
|
-
* @param key - key to get value for
|
|
27
|
-
*/
|
|
28
|
-
getValueSync(key: string): string | null;
|
|
29
|
-
/**
|
|
30
|
-
* Set the value for a key.
|
|
31
|
-
*
|
|
32
|
-
* @param key - key to set value for
|
|
33
|
-
* @param value - value to set
|
|
34
|
-
*/
|
|
35
|
-
setValue(key: string, value: string | null): void;
|
|
36
|
-
/**
|
|
37
|
-
* Replace the value for a key.
|
|
38
|
-
* If the value is being replaced, the promise for the new value is returned.
|
|
39
|
-
*
|
|
40
|
-
* @param key - key to replace value for
|
|
41
|
-
* @param fn - function to get the new value
|
|
42
|
-
*/
|
|
43
|
-
replaceValue(key: string, fn: () => Promise<string>): Promise<string | null>;
|
|
44
|
-
/**
|
|
45
|
-
* Subscribe to changes to a key.
|
|
46
|
-
*
|
|
47
|
-
* @param key - key to subscribe to changes to
|
|
48
|
-
* @param callback - callback invoked when the value is updated
|
|
49
|
-
*/
|
|
50
|
-
subscribe(key: string, callback: (val: string | null) => void): () => void;
|
|
51
|
-
}
|
|
52
|
-
declare const store: GlobalStore;
|
|
53
|
-
export default store;
|
|
54
|
-
//# sourceMappingURL=global-state-store.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global-state-store.d.ts","sourceRoot":"","sources":["../../js/shared/global-state-store.tsx"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,cAAM,WAAW;;;IAiBb;;;OAGG;IACI,KAAK,IAAI,IAAI;IAKpB;;;;;OAKG;IACU,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQ1D;;;;;OAKG;IACI,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAI/C;;;;;OAKG;IACI,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAaxD;;;;;;OAMG;IACU,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAwCzF;;;;;OAKG;IACI,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI;CA6BpF;AAED,QAAA,MAAM,KAAK,aAAoB,CAAC;AAEhC,eAAe,KAAK,CAAC"}
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
11
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
12
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
|
-
};
|
|
16
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
17
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
18
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
19
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
|
-
};
|
|
21
|
-
var _GlobalStore_locks, _GlobalStore_subscribers;
|
|
22
|
-
/* eslint-disable class-methods-use-this */
|
|
23
|
-
/**
|
|
24
|
-
* Global state store. Acts as a wrapper around localStorage.
|
|
25
|
-
*
|
|
26
|
-
* Supports a simple key-value store with subscriptions and async value replacement,
|
|
27
|
-
* while ensuring that only one replacement is in progress at a time.
|
|
28
|
-
*/
|
|
29
|
-
class GlobalStore {
|
|
30
|
-
constructor() {
|
|
31
|
-
/**
|
|
32
|
-
* Locks for each key to ensure only one replacement is in progress at a time.
|
|
33
|
-
* Each promise represents an ongoing replacement which will resolve to the new value or reject if replacement fails.
|
|
34
|
-
*/
|
|
35
|
-
_GlobalStore_locks.set(this, void 0);
|
|
36
|
-
/**
|
|
37
|
-
* Subscribers for each key.
|
|
38
|
-
*/
|
|
39
|
-
_GlobalStore_subscribers.set(this, void 0);
|
|
40
|
-
__classPrivateFieldSet(this, _GlobalStore_locks, {}, "f");
|
|
41
|
-
__classPrivateFieldSet(this, _GlobalStore_subscribers, {}, "f");
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Clear the store.
|
|
45
|
-
* Removes all values and subscribers.
|
|
46
|
-
*/
|
|
47
|
-
clear() {
|
|
48
|
-
__classPrivateFieldSet(this, _GlobalStore_locks, {}, "f");
|
|
49
|
-
__classPrivateFieldSet(this, _GlobalStore_subscribers, {}, "f");
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get the value for a key.
|
|
53
|
-
* If the value is being replaced, the promise for the new value is returned.
|
|
54
|
-
*
|
|
55
|
-
* @param key - key to get value for
|
|
56
|
-
*/
|
|
57
|
-
getValue(key) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
if (__classPrivateFieldGet(this, _GlobalStore_locks, "f")[key]) {
|
|
60
|
-
return __classPrivateFieldGet(this, _GlobalStore_locks, "f")[key];
|
|
61
|
-
}
|
|
62
|
-
return localStorage.getItem(key);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get the value for a key synchronously.
|
|
67
|
-
* Even if the value is being replaced, the current value is returned.
|
|
68
|
-
*
|
|
69
|
-
* @param key - key to get value for
|
|
70
|
-
*/
|
|
71
|
-
getValueSync(key) {
|
|
72
|
-
return localStorage.getItem(key);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Set the value for a key.
|
|
76
|
-
*
|
|
77
|
-
* @param key - key to set value for
|
|
78
|
-
* @param value - value to set
|
|
79
|
-
*/
|
|
80
|
-
setValue(key, value) {
|
|
81
|
-
if (value === null) {
|
|
82
|
-
localStorage.removeItem(key);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
localStorage.setItem(key, value);
|
|
86
|
-
}
|
|
87
|
-
// Notify any local subscribers of a change in the value
|
|
88
|
-
if (__classPrivateFieldGet(this, _GlobalStore_subscribers, "f")[key]) {
|
|
89
|
-
__classPrivateFieldGet(this, _GlobalStore_subscribers, "f")[key].forEach((cb) => cb(value));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Replace the value for a key.
|
|
94
|
-
* If the value is being replaced, the promise for the new value is returned.
|
|
95
|
-
*
|
|
96
|
-
* @param key - key to replace value for
|
|
97
|
-
* @param fn - function to get the new value
|
|
98
|
-
*/
|
|
99
|
-
replaceValue(key, fn) {
|
|
100
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
// If there's already a replacement in progress, return the promise of the ongoing replacement
|
|
102
|
-
if (__classPrivateFieldGet(this, _GlobalStore_locks, "f")[key]) {
|
|
103
|
-
return __classPrivateFieldGet(this, _GlobalStore_locks, "f")[key];
|
|
104
|
-
}
|
|
105
|
-
// Create a new Promise to resolve to the replaced value
|
|
106
|
-
// TODO: this can be Promise.withResolvers once it's more widely supported
|
|
107
|
-
let unlock;
|
|
108
|
-
let unlockError;
|
|
109
|
-
const lockPromise = new Promise((resolve, reject) => {
|
|
110
|
-
unlock = resolve;
|
|
111
|
-
unlockError = reject;
|
|
112
|
-
});
|
|
113
|
-
// Store it for the given key so we can resolve other replacements/retrievals to the same promise
|
|
114
|
-
__classPrivateFieldGet(this, _GlobalStore_locks, "f")[key] = lockPromise;
|
|
115
|
-
let result;
|
|
116
|
-
try {
|
|
117
|
-
// Run the provided function to get the new value
|
|
118
|
-
result = yield fn();
|
|
119
|
-
// On success - set the value (notifying subscribers) and resolve the 'lock' promise.
|
|
120
|
-
// This resolves both the caller and other ongoing requests blocking on the lock to the new value.
|
|
121
|
-
this.setValue(key, result);
|
|
122
|
-
unlock(result);
|
|
123
|
-
}
|
|
124
|
-
catch (e) {
|
|
125
|
-
// On error - error out the 'lock' promise.
|
|
126
|
-
// This errors both the caller and other ongoing requests blocking on the lock.
|
|
127
|
-
unlockError(e);
|
|
128
|
-
}
|
|
129
|
-
finally {
|
|
130
|
-
// Clear the lock for the key so future replaceValue calls call the `fn` again
|
|
131
|
-
delete __classPrivateFieldGet(this, _GlobalStore_locks, "f")[key];
|
|
132
|
-
}
|
|
133
|
-
return lockPromise;
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Subscribe to changes to a key.
|
|
138
|
-
*
|
|
139
|
-
* @param key - key to subscribe to changes to
|
|
140
|
-
* @param callback - callback invoked when the value is updated
|
|
141
|
-
*/
|
|
142
|
-
subscribe(key, callback) {
|
|
143
|
-
if (!__classPrivateFieldGet(this, _GlobalStore_subscribers, "f")[key]) {
|
|
144
|
-
__classPrivateFieldGet(this, _GlobalStore_subscribers, "f")[key] = [];
|
|
145
|
-
}
|
|
146
|
-
// create a subscription scoped to the key
|
|
147
|
-
const subFunc = (e) => {
|
|
148
|
-
if (e.storageArea === localStorage && e.key === key) {
|
|
149
|
-
callback(e.newValue);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
// Add the callback to the local subscribers list
|
|
153
|
-
// The storage event only fires when localStorage is changed from another document so we need to track changes
|
|
154
|
-
// locally as well.
|
|
155
|
-
__classPrivateFieldGet(this, _GlobalStore_subscribers, "f")[key].push(callback);
|
|
156
|
-
// Add a listener to the storage event for changes coming from other tabs
|
|
157
|
-
window.addEventListener('storage', subFunc);
|
|
158
|
-
// Cleanup the subscriptions
|
|
159
|
-
return () => {
|
|
160
|
-
var _a;
|
|
161
|
-
window.removeEventListener('storage', subFunc);
|
|
162
|
-
(_a = __classPrivateFieldGet(this, _GlobalStore_subscribers, "f")[key]) === null || _a === void 0 ? void 0 : _a.splice(__classPrivateFieldGet(this, _GlobalStore_subscribers, "f")[key].findIndex((val) => val === callback), 1);
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
_GlobalStore_locks = new WeakMap(), _GlobalStore_subscribers = new WeakMap();
|
|
167
|
-
const store = new GlobalStore();
|
|
168
|
-
export default store;
|
|
169
|
-
//# sourceMappingURL=global-state-store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global-state-store.js","sourceRoot":"","sources":["../../js/shared/global-state-store.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAA2C;AAC3C;;;;;GAKG;AACH,MAAM,WAAW;IAYb;QAXA;;;WAGG;QACH,qCAA+C;QAE/C;;WAEG;QACH,2CAA+D;QAG3D,uBAAA,IAAI,sBAAU,EAAqC,MAAA,CAAC;QACpD,uBAAA,IAAI,4BAAgB,EAAsD,MAAA,CAAC;IAC/E,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,uBAAA,IAAI,sBAAU,EAAqC,MAAA,CAAC;QACpD,uBAAA,IAAI,4BAAgB,EAAsD,MAAA,CAAC;IAC/E,CAAC;IAED;;;;;OAKG;IACU,QAAQ,CAAC,GAAW;;YAC7B,IAAI,uBAAA,IAAI,0BAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnB,OAAO,uBAAA,IAAI,0BAAO,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;YAED,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;KAAA;IAED;;;;;OAKG;IACI,YAAY,CAAC,GAAW;QAC3B,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACI,QAAQ,CAAC,GAAW,EAAE,KAAoB;QAC7C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACjB,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACJ,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;QAED,wDAAwD;QACxD,IAAI,uBAAA,IAAI,gCAAa,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,uBAAA,IAAI,gCAAa,CAAC,GAAG,CAAC,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GAAG,CAAC,EAAE,CAAC;YAC1B,uBAAA,IAAI,gCAAa,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QAChC,CAAC;QAED,0CAA0C;QAC1C,MAAM,OAAO,GAAG,CAAC,CAAe,EAAQ,EAAE;YACtC,IAAI,CAAC,CAAC,WAAW,KAAK,YAAY,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBAClD,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;YACzB,CAAC;QACL,CAAC,CAAC;QAEF,iDAAiD;QACjD,8GAA8G;QAC9G,mBAAmB;QACnB,uBAAA,IAAI,gCAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEtC,yEAAyE;QACzE,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE5C,4BAA4B;QAC5B,OAAO,GAAG,EAAE;;YACR,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC/C,MAAA,uBAAA,IAAI,gCAAa,CAAC,GAAG,CAAC,0CAAE,MAAM,CAC1B,uBAAA,IAAI,gCAAa,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,QAAQ,CAAC,EAC3D,CAAC,CACJ,CAAC;QACN,CAAC,CAAC;IACN,CAAC;CACJ;;AAED,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC;AAEhC,eAAe,KAAK,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const DARA_JWT_TOKEN = "dara-jwt-token";
|
|
2
|
-
/**
|
|
3
|
-
* Whether the Dara app is embedded within an IFrame
|
|
4
|
-
*/
|
|
5
|
-
export declare function isEmbedded(): boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Get the token key used to persist the embedded token
|
|
8
|
-
*/
|
|
9
|
-
export declare function getEmbedTokenKey(): string;
|
|
10
|
-
/**
|
|
11
|
-
* Get token for the embedded Dara app
|
|
12
|
-
*/
|
|
13
|
-
export declare function getEmbedToken(): string | null;
|
|
14
|
-
/**
|
|
15
|
-
* Get the jwt token. Uses the embedded token if the app is embedded.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getToken(): string | null;
|
|
18
|
-
/**
|
|
19
|
-
* Get the token key used to persist the jwt token. Uses the embedded token key if the app is embedded.
|
|
20
|
-
*/
|
|
21
|
-
export declare function getTokenKey(): string;
|
|
22
|
-
//# sourceMappingURL=embed.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../../js/shared/utils/embed.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAGpC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAGzC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAM7C;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,MAAM,GAAG,IAAI,CAOxC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAMpC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export const DARA_JWT_TOKEN = 'dara-jwt-token';
|
|
2
|
-
/**
|
|
3
|
-
* Whether the Dara app is embedded within an IFrame
|
|
4
|
-
*/
|
|
5
|
-
export function isEmbedded() {
|
|
6
|
-
var _a;
|
|
7
|
-
const frame = window.frameElement;
|
|
8
|
-
return frame && ((_a = frame === null || frame === void 0 ? void 0 : frame.dataset) === null || _a === void 0 ? void 0 : _a.daraPageId) !== '';
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Get the token key used to persist the embedded token
|
|
12
|
-
*/
|
|
13
|
-
export function getEmbedTokenKey() {
|
|
14
|
-
var _a;
|
|
15
|
-
const frame = window.frameElement;
|
|
16
|
-
return (_a = frame === null || frame === void 0 ? void 0 : frame.dataset) === null || _a === void 0 ? void 0 : _a.daraPageId;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Get token for the embedded Dara app
|
|
20
|
-
*/
|
|
21
|
-
export function getEmbedToken() {
|
|
22
|
-
const key = getEmbedTokenKey();
|
|
23
|
-
if (!key) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
return localStorage.getItem(key);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Get the jwt token. Uses the embedded token if the app is embedded.
|
|
30
|
-
*/
|
|
31
|
-
export function getToken() {
|
|
32
|
-
if (isEmbedded()) {
|
|
33
|
-
const embedToken = getEmbedToken();
|
|
34
|
-
return embedToken;
|
|
35
|
-
}
|
|
36
|
-
return localStorage.getItem(DARA_JWT_TOKEN);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Get the token key used to persist the jwt token. Uses the embedded token key if the app is embedded.
|
|
40
|
-
*/
|
|
41
|
-
export function getTokenKey() {
|
|
42
|
-
if (isEmbedded()) {
|
|
43
|
-
return getEmbedTokenKey();
|
|
44
|
-
}
|
|
45
|
-
return DARA_JWT_TOKEN;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=embed.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"embed.js","sourceRoot":"","sources":["../../../js/shared/utils/embed.tsx"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,UAAU;;IACtB,MAAM,KAAK,GAAG,MAAM,CAAC,YAAiC,CAAC;IACvD,OAAO,KAAK,IAAI,CAAA,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,UAAU,MAAK,EAAE,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,YAAiC,CAAC;IACvD,OAAO,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,0CAAE,UAAoB,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IACzB,MAAM,GAAG,GAAG,gBAAgB,EAAE,CAAC;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;QACP,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ;IACpB,IAAI,UAAU,EAAE,EAAE,CAAC;QACf,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,OAAO,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW;IACvB,IAAI,UAAU,EAAE,EAAE,CAAC;QACf,OAAO,gBAAgB,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC"}
|