@vuu-ui/vuu-data-react 0.13.73 → 0.13.75
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/cjs/datasource-provider/useAutoLoginToVuuServer.js +3 -7
- package/cjs/datasource-provider/useAutoLoginToVuuServer.js.map +1 -1
- package/cjs/hooks/useRemoteConnection.js +2 -9
- package/cjs/hooks/useRemoteConnection.js.map +1 -1
- package/esm/datasource-provider/useAutoLoginToVuuServer.js +3 -7
- package/esm/datasource-provider/useAutoLoginToVuuServer.js.map +1 -1
- package/esm/hooks/useRemoteConnection.js +2 -9
- package/esm/hooks/useRemoteConnection.js.map +1 -1
- package/package.json +15 -15
|
@@ -17,17 +17,13 @@ const useAutoLoginToVuuServer = ({
|
|
|
17
17
|
try {
|
|
18
18
|
let token = "no-token";
|
|
19
19
|
if (authenticate) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"xyz",
|
|
23
|
-
"/api/authn"
|
|
24
|
-
);
|
|
20
|
+
const response = await vuuDataRemote.authenticate("steve", "xyz", "/api/authn");
|
|
21
|
+
token = response.token;
|
|
25
22
|
}
|
|
26
23
|
const url = websocketUrl ?? `${secure ? "wss" : "ws"}://localhost/8090/websocket`;
|
|
27
24
|
vuuDataRemote.ConnectionManager.connect({
|
|
28
25
|
url,
|
|
29
|
-
token
|
|
30
|
-
username: "steve"
|
|
26
|
+
token
|
|
31
27
|
});
|
|
32
28
|
} catch (e) {
|
|
33
29
|
if (e instanceof Error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoLoginToVuuServer.js","sources":["../../../../packages/vuu-data-react/src/datasource-provider/useAutoLoginToVuuServer.tsx"],"sourcesContent":["import {\n authenticate as vuuAuthenticate,\n ConnectionManager,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useEffect, useState } from \"react\";\n\nexport const useAutoLoginToVuuServer = ({\n authenticate = true,\n autoConnect = true,\n // autoLogin = true,\n secure = true,\n websocketUrl,\n}: {\n authenticate?: boolean;\n autoConnect?: boolean;\n autoLogin?: boolean;\n secure?: boolean;\n websocketUrl?: string;\n} = {}) => {\n const [errorMessage, setErrorMessage] = useState(\"\");\n useEffect(() => {\n const connect = async () => {\n try {\n let token = \"no-token\";\n if (authenticate) {\n
|
|
1
|
+
{"version":3,"file":"useAutoLoginToVuuServer.js","sources":["../../../../packages/vuu-data-react/src/datasource-provider/useAutoLoginToVuuServer.tsx"],"sourcesContent":["import {\n authenticate as vuuAuthenticate,\n ConnectionManager,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useEffect, useState } from \"react\";\n\nexport const useAutoLoginToVuuServer = ({\n authenticate = true,\n autoConnect = true,\n // autoLogin = true,\n secure = true,\n websocketUrl,\n}: {\n authenticate?: boolean;\n autoConnect?: boolean;\n autoLogin?: boolean;\n secure?: boolean;\n websocketUrl?: string;\n} = {}) => {\n const [errorMessage, setErrorMessage] = useState(\"\");\n useEffect(() => {\n const connect = async () => {\n try {\n let token = \"no-token\";\n if (authenticate) {\n const response = await vuuAuthenticate(\"steve\", \"xyz\", \"/api/authn\");\n token = response.token;\n }\n\n const url =\n websocketUrl ?? `${secure ? \"wss\" : \"ws\"}://localhost/8090/websocket`;\n\n ConnectionManager.connect({\n url,\n token,\n });\n } catch (e: unknown) {\n if (e instanceof Error) {\n console.error(e.message);\n setErrorMessage(e.message);\n }\n }\n };\n if (autoConnect) {\n connect();\n }\n\n return () => {\n if (autoConnect) {\n ConnectionManager.disconnect();\n }\n };\n }, [authenticate, autoConnect, secure, websocketUrl]);\n\n if (errorMessage) {\n return (\n <p>\n Unable to authenticate against Vuu Server A Vuu Server instance must be\n running to show this example.\n </p>\n );\n }\n};\n"],"names":["useState","useEffect","vuuAuthenticate","ConnectionManager","jsx"],"mappings":";;;;;;AAMO,MAAM,0BAA0B,CAAC;AAAA,EACtC,YAAe,GAAA,IAAA;AAAA,EACf,WAAc,GAAA,IAAA;AAAA;AAAA,EAEd,MAAS,GAAA,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|
const connectionResult = await vuuDataRemote.ConnectionManager.connect({
|
|
35
35
|
token: user.token,
|
|
36
|
-
url: serverUrl
|
|
37
|
-
username: user.username
|
|
36
|
+
url: serverUrl
|
|
38
37
|
});
|
|
39
38
|
if (connectionResult === "rejected") {
|
|
40
39
|
showNotification({
|
|
@@ -45,13 +44,7 @@ const useRemoteConnection = ({
|
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
|
-
}, [
|
|
49
|
-
handleConnectionStatusChange,
|
|
50
|
-
showNotification,
|
|
51
|
-
serverUrl,
|
|
52
|
-
user.token,
|
|
53
|
-
user.username
|
|
54
|
-
]);
|
|
47
|
+
}, [handleConnectionStatusChange, showNotification, serverUrl, user.token]);
|
|
55
48
|
};
|
|
56
49
|
|
|
57
50
|
exports.useRemoteConnection = useRemoteConnection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRemoteConnection.js","sources":["../../../../packages/vuu-data-react/src/hooks/useRemoteConnection.tsx"],"sourcesContent":["import {\n ConnectionManager,\n WebSocketConnectionState,\n isConnected,\n} from \"@vuu-ui/vuu-data-remote\";\nimport type { VuuUser } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { useNotifications } from \"@vuu-ui/vuu-popups\";\nimport { LostConnectionIndicator } from \"../lost-connection-indicator/LostConnectionIndicator\";\n\nexport interface RemoteConnectionHookProps {\n serverUrl?: string;\n user: VuuUser;\n}\nexport const useRemoteConnection = ({\n serverUrl,\n user,\n}: RemoteConnectionHookProps) => {\n const { hideNotification, showNotification } = useNotifications();\n\n const isConnectedRef = useRef(false);\n\n const handleConnectionStatusChange = useCallback(\n (message: WebSocketConnectionState) => {\n const { current: wasConnected } = isConnectedRef;\n isConnectedRef.current = isConnected(message.connectionStatus);\n\n if (wasConnected && message.connectionStatus === \"disconnected\") {\n showNotification({\n content: <LostConnectionIndicator />,\n level: \"error\",\n type: \"workspace\",\n });\n } else if (!wasConnected && isConnectedRef.current) {\n hideNotification();\n }\n },\n [hideNotification, showNotification],\n );\n\n useMemo(async () => {\n if (serverUrl) {\n ConnectionManager.on(\"connection-status\", handleConnectionStatusChange);\n const connectionResult = await ConnectionManager.connect({\n token: user.token,\n url: serverUrl,\n
|
|
1
|
+
{"version":3,"file":"useRemoteConnection.js","sources":["../../../../packages/vuu-data-react/src/hooks/useRemoteConnection.tsx"],"sourcesContent":["import {\n ConnectionManager,\n WebSocketConnectionState,\n isConnected,\n} from \"@vuu-ui/vuu-data-remote\";\nimport type { VuuUser } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { useNotifications } from \"@vuu-ui/vuu-popups\";\nimport { LostConnectionIndicator } from \"../lost-connection-indicator/LostConnectionIndicator\";\n\nexport interface RemoteConnectionHookProps {\n serverUrl?: string;\n user: VuuUser;\n}\nexport const useRemoteConnection = ({\n serverUrl,\n user,\n}: RemoteConnectionHookProps) => {\n const { hideNotification, showNotification } = useNotifications();\n\n const isConnectedRef = useRef(false);\n\n const handleConnectionStatusChange = useCallback(\n (message: WebSocketConnectionState) => {\n const { current: wasConnected } = isConnectedRef;\n isConnectedRef.current = isConnected(message.connectionStatus);\n\n if (wasConnected && message.connectionStatus === \"disconnected\") {\n showNotification({\n content: <LostConnectionIndicator />,\n level: \"error\",\n type: \"workspace\",\n });\n } else if (!wasConnected && isConnectedRef.current) {\n hideNotification();\n }\n },\n [hideNotification, showNotification],\n );\n\n useMemo(async () => {\n if (serverUrl) {\n ConnectionManager.on(\"connection-status\", handleConnectionStatusChange);\n const connectionResult = await ConnectionManager.connect({\n token: user.token,\n url: serverUrl,\n });\n if (connectionResult === \"rejected\") {\n showNotification({\n level: \"error\",\n content: \"Unable to connect to VUU Server\",\n header: \"Error\",\n type: \"toast\",\n });\n }\n }\n }, [handleConnectionStatusChange, showNotification, serverUrl, user.token]);\n};\n"],"names":["useNotifications","useRef","useCallback","isConnected","LostConnectionIndicator","useMemo","ConnectionManager"],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AA,UACR,IAAM,EAAA;AAAA,SACP,CAAA;AAAA;AACH;AACF,KACC,CAAC,4BAAA,EAA8B,kBAAkB,SAAW,EAAA,IAAA,CAAK,KAAK,CAAC,CAAA;AAC5E;;;;"}
|
|
@@ -15,17 +15,13 @@ const useAutoLoginToVuuServer = ({
|
|
|
15
15
|
try {
|
|
16
16
|
let token = "no-token";
|
|
17
17
|
if (authenticate$1) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"xyz",
|
|
21
|
-
"/api/authn"
|
|
22
|
-
);
|
|
18
|
+
const response = await authenticate("steve", "xyz", "/api/authn");
|
|
19
|
+
token = response.token;
|
|
23
20
|
}
|
|
24
21
|
const url = websocketUrl ?? `${secure ? "wss" : "ws"}://localhost/8090/websocket`;
|
|
25
22
|
ConnectionManager.connect({
|
|
26
23
|
url,
|
|
27
|
-
token
|
|
28
|
-
username: "steve"
|
|
24
|
+
token
|
|
29
25
|
});
|
|
30
26
|
} catch (e) {
|
|
31
27
|
if (e instanceof Error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoLoginToVuuServer.js","sources":["../../../../packages/vuu-data-react/src/datasource-provider/useAutoLoginToVuuServer.tsx"],"sourcesContent":["import {\n authenticate as vuuAuthenticate,\n ConnectionManager,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useEffect, useState } from \"react\";\n\nexport const useAutoLoginToVuuServer = ({\n authenticate = true,\n autoConnect = true,\n // autoLogin = true,\n secure = true,\n websocketUrl,\n}: {\n authenticate?: boolean;\n autoConnect?: boolean;\n autoLogin?: boolean;\n secure?: boolean;\n websocketUrl?: string;\n} = {}) => {\n const [errorMessage, setErrorMessage] = useState(\"\");\n useEffect(() => {\n const connect = async () => {\n try {\n let token = \"no-token\";\n if (authenticate) {\n
|
|
1
|
+
{"version":3,"file":"useAutoLoginToVuuServer.js","sources":["../../../../packages/vuu-data-react/src/datasource-provider/useAutoLoginToVuuServer.tsx"],"sourcesContent":["import {\n authenticate as vuuAuthenticate,\n ConnectionManager,\n} from \"@vuu-ui/vuu-data-remote\";\nimport { useEffect, useState } from \"react\";\n\nexport const useAutoLoginToVuuServer = ({\n authenticate = true,\n autoConnect = true,\n // autoLogin = true,\n secure = true,\n websocketUrl,\n}: {\n authenticate?: boolean;\n autoConnect?: boolean;\n autoLogin?: boolean;\n secure?: boolean;\n websocketUrl?: string;\n} = {}) => {\n const [errorMessage, setErrorMessage] = useState(\"\");\n useEffect(() => {\n const connect = async () => {\n try {\n let token = \"no-token\";\n if (authenticate) {\n const response = await vuuAuthenticate(\"steve\", \"xyz\", \"/api/authn\");\n token = response.token;\n }\n\n const url =\n websocketUrl ?? `${secure ? \"wss\" : \"ws\"}://localhost/8090/websocket`;\n\n ConnectionManager.connect({\n url,\n token,\n });\n } catch (e: unknown) {\n if (e instanceof Error) {\n console.error(e.message);\n setErrorMessage(e.message);\n }\n }\n };\n if (autoConnect) {\n connect();\n }\n\n return () => {\n if (autoConnect) {\n ConnectionManager.disconnect();\n }\n };\n }, [authenticate, autoConnect, secure, websocketUrl]);\n\n if (errorMessage) {\n return (\n <p>\n Unable to authenticate against Vuu Server A Vuu Server instance must be\n running to show this example.\n </p>\n );\n }\n};\n"],"names":["authenticate","vuuAuthenticate"],"mappings":";;;;AAMO,MAAM,0BAA0B,CAAC;AAAA,gBACtCA,cAAe,GAAA,IAAA;AAAA,EACf,WAAc,GAAA,IAAA;AAAA;AAAA,EAEd,MAAS,GAAA,IAAA;AAAA,EACT;AACF,CAAA,GAMI,EAAO,KAAA;AACT,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,SAAS,EAAE,CAAA;AACnD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,UAAU,YAAY;AAC1B,MAAI,IAAA;AACF,QAAA,IAAI,KAAQ,GAAA,UAAA;AACZ,QAAA,IAAIA,cAAc,EAAA;AAChB,UAAA,MAAM,QAAW,GAAA,MAAMC,YAAgB,CAAA,OAAA,EAAS,OAAO,YAAY,CAAA;AACnE,UAAA,KAAA,GAAQ,QAAS,CAAA,KAAA;AAAA;AAGnB,QAAA,MAAM,GACJ,GAAA,YAAA,IAAgB,CAAG,EAAA,MAAA,GAAS,QAAQ,IAAI,CAAA,2BAAA,CAAA;AAE1C,QAAA,iBAAA,CAAkB,OAAQ,CAAA;AAAA,UACxB,GAAA;AAAA,UACA;AAAA,SACD,CAAA;AAAA,eACM,CAAY,EAAA;AACnB,QAAA,IAAI,aAAa,KAAO,EAAA;AACtB,UAAQ,OAAA,CAAA,KAAA,CAAM,EAAE,OAAO,CAAA;AACvB,UAAA,eAAA,CAAgB,EAAE,OAAO,CAAA;AAAA;AAC3B;AACF,KACF;AACA,IAAA,IAAI,WAAa,EAAA;AACf,MAAQ,OAAA,EAAA;AAAA;AAGV,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,WAAa,EAAA;AACf,QAAA,iBAAA,CAAkB,UAAW,EAAA;AAAA;AAC/B,KACF;AAAA,KACC,CAACD,cAAA,EAAc,WAAa,EAAA,MAAA,EAAQ,YAAY,CAAC,CAAA;AAEpD,EAAA,IAAI,YAAc,EAAA;AAChB,IACE,uBAAA,GAAA,CAAC,OAAE,QAGH,EAAA,uGAAA,EAAA,CAAA;AAAA;AAGN;;;;"}
|
|
@@ -31,8 +31,7 @@ const useRemoteConnection = ({
|
|
|
31
31
|
ConnectionManager.on("connection-status", handleConnectionStatusChange);
|
|
32
32
|
const connectionResult = await ConnectionManager.connect({
|
|
33
33
|
token: user.token,
|
|
34
|
-
url: serverUrl
|
|
35
|
-
username: user.username
|
|
34
|
+
url: serverUrl
|
|
36
35
|
});
|
|
37
36
|
if (connectionResult === "rejected") {
|
|
38
37
|
showNotification({
|
|
@@ -43,13 +42,7 @@ const useRemoteConnection = ({
|
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
}, [
|
|
47
|
-
handleConnectionStatusChange,
|
|
48
|
-
showNotification,
|
|
49
|
-
serverUrl,
|
|
50
|
-
user.token,
|
|
51
|
-
user.username
|
|
52
|
-
]);
|
|
45
|
+
}, [handleConnectionStatusChange, showNotification, serverUrl, user.token]);
|
|
53
46
|
};
|
|
54
47
|
|
|
55
48
|
export { useRemoteConnection };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRemoteConnection.js","sources":["../../../../packages/vuu-data-react/src/hooks/useRemoteConnection.tsx"],"sourcesContent":["import {\n ConnectionManager,\n WebSocketConnectionState,\n isConnected,\n} from \"@vuu-ui/vuu-data-remote\";\nimport type { VuuUser } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { useNotifications } from \"@vuu-ui/vuu-popups\";\nimport { LostConnectionIndicator } from \"../lost-connection-indicator/LostConnectionIndicator\";\n\nexport interface RemoteConnectionHookProps {\n serverUrl?: string;\n user: VuuUser;\n}\nexport const useRemoteConnection = ({\n serverUrl,\n user,\n}: RemoteConnectionHookProps) => {\n const { hideNotification, showNotification } = useNotifications();\n\n const isConnectedRef = useRef(false);\n\n const handleConnectionStatusChange = useCallback(\n (message: WebSocketConnectionState) => {\n const { current: wasConnected } = isConnectedRef;\n isConnectedRef.current = isConnected(message.connectionStatus);\n\n if (wasConnected && message.connectionStatus === \"disconnected\") {\n showNotification({\n content: <LostConnectionIndicator />,\n level: \"error\",\n type: \"workspace\",\n });\n } else if (!wasConnected && isConnectedRef.current) {\n hideNotification();\n }\n },\n [hideNotification, showNotification],\n );\n\n useMemo(async () => {\n if (serverUrl) {\n ConnectionManager.on(\"connection-status\", handleConnectionStatusChange);\n const connectionResult = await ConnectionManager.connect({\n token: user.token,\n url: serverUrl,\n
|
|
1
|
+
{"version":3,"file":"useRemoteConnection.js","sources":["../../../../packages/vuu-data-react/src/hooks/useRemoteConnection.tsx"],"sourcesContent":["import {\n ConnectionManager,\n WebSocketConnectionState,\n isConnected,\n} from \"@vuu-ui/vuu-data-remote\";\nimport type { VuuUser } from \"@vuu-ui/vuu-utils\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport { useNotifications } from \"@vuu-ui/vuu-popups\";\nimport { LostConnectionIndicator } from \"../lost-connection-indicator/LostConnectionIndicator\";\n\nexport interface RemoteConnectionHookProps {\n serverUrl?: string;\n user: VuuUser;\n}\nexport const useRemoteConnection = ({\n serverUrl,\n user,\n}: RemoteConnectionHookProps) => {\n const { hideNotification, showNotification } = useNotifications();\n\n const isConnectedRef = useRef(false);\n\n const handleConnectionStatusChange = useCallback(\n (message: WebSocketConnectionState) => {\n const { current: wasConnected } = isConnectedRef;\n isConnectedRef.current = isConnected(message.connectionStatus);\n\n if (wasConnected && message.connectionStatus === \"disconnected\") {\n showNotification({\n content: <LostConnectionIndicator />,\n level: \"error\",\n type: \"workspace\",\n });\n } else if (!wasConnected && isConnectedRef.current) {\n hideNotification();\n }\n },\n [hideNotification, showNotification],\n );\n\n useMemo(async () => {\n if (serverUrl) {\n ConnectionManager.on(\"connection-status\", handleConnectionStatusChange);\n const connectionResult = await ConnectionManager.connect({\n token: user.token,\n url: serverUrl,\n });\n if (connectionResult === \"rejected\") {\n showNotification({\n level: \"error\",\n content: \"Unable to connect to VUU Server\",\n header: \"Error\",\n type: \"toast\",\n });\n }\n }\n }, [handleConnectionStatusChange, showNotification, serverUrl, user.token]);\n};\n"],"names":[],"mappings":";;;;;;AAcO,MAAM,sBAAsB,CAAC;AAAA,EAClC,SAAA;AAAA,EACA;AACF,CAAiC,KAAA;AAC/B,EAAA,MAAM,EAAE,gBAAA,EAAkB,gBAAiB,EAAA,GAAI,gBAAiB,EAAA;AAEhE,EAAM,MAAA,cAAA,GAAiB,OAAO,KAAK,CAAA;AAEnC,EAAA,MAAM,4BAA+B,GAAA,WAAA;AAAA,IACnC,CAAC,OAAsC,KAAA;AACrC,MAAM,MAAA,EAAE,OAAS,EAAA,YAAA,EAAiB,GAAA,cAAA;AAClC,MAAe,cAAA,CAAA,OAAA,GAAU,WAAY,CAAA,OAAA,CAAQ,gBAAgB,CAAA;AAE7D,MAAI,IAAA,YAAA,IAAgB,OAAQ,CAAA,gBAAA,KAAqB,cAAgB,EAAA;AAC/D,QAAiB,gBAAA,CAAA;AAAA,UACf,OAAA,sBAAU,uBAAwB,EAAA,EAAA,CAAA;AAAA,UAClC,KAAO,EAAA,OAAA;AAAA,UACP,IAAM,EAAA;AAAA,SACP,CAAA;AAAA,OACQ,MAAA,IAAA,CAAC,YAAgB,IAAA,cAAA,CAAe,OAAS,EAAA;AAClD,QAAiB,gBAAA,EAAA;AAAA;AACnB,KACF;AAAA,IACA,CAAC,kBAAkB,gBAAgB;AAAA,GACrC;AAEA,EAAA,OAAA,CAAQ,YAAY;AAClB,IAAA,IAAI,SAAW,EAAA;AACb,MAAkB,iBAAA,CAAA,EAAA,CAAG,qBAAqB,4BAA4B,CAAA;AACtE,MAAM,MAAA,gBAAA,GAAmB,MAAM,iBAAA,CAAkB,OAAQ,CAAA;AAAA,QACvD,OAAO,IAAK,CAAA,KAAA;AAAA,QACZ,GAAK,EAAA;AAAA,OACN,CAAA;AACD,MAAA,IAAI,qBAAqB,UAAY,EAAA;AACnC,QAAiB,gBAAA,CAAA;AAAA,UACf,KAAO,EAAA,OAAA;AAAA,UACP,OAAS,EAAA,iCAAA;AAAA,UACT,MAAQ,EAAA,OAAA;AAAA,UACR,IAAM,EAAA;AAAA,SACP,CAAA;AAAA;AACH;AACF,KACC,CAAC,4BAAA,EAA8B,kBAAkB,SAAW,EAAA,IAAA,CAAK,KAAK,CAAC,CAAA;AAC5E;;;;"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.13.
|
|
2
|
+
"version": "0.13.75",
|
|
3
3
|
"author": "heswell",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@vuu-ui/vuu-data-types": "0.13.
|
|
7
|
-
"@vuu-ui/vuu-filter-types": "0.13.
|
|
8
|
-
"@vuu-ui/vuu-popups": "0.13.
|
|
9
|
-
"@vuu-ui/vuu-protocol-types": "0.13.
|
|
10
|
-
"@vuu-ui/vuu-table-types": "0.13.
|
|
6
|
+
"@vuu-ui/vuu-data-types": "0.13.75",
|
|
7
|
+
"@vuu-ui/vuu-filter-types": "0.13.75",
|
|
8
|
+
"@vuu-ui/vuu-popups": "0.13.75",
|
|
9
|
+
"@vuu-ui/vuu-protocol-types": "0.13.75",
|
|
10
|
+
"@vuu-ui/vuu-table-types": "0.13.75"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@vuu-ui/vuu-context-menu": "0.13.
|
|
14
|
-
"@vuu-ui/vuu-data-remote": "0.13.
|
|
15
|
-
"@vuu-ui/vuu-filter-parser": "0.13.
|
|
16
|
-
"@vuu-ui/vuu-filters": "0.13.
|
|
17
|
-
"@vuu-ui/vuu-layout": "0.13.
|
|
18
|
-
"@vuu-ui/vuu-popups": "0.13.
|
|
19
|
-
"@vuu-ui/vuu-ui-controls": "0.13.
|
|
20
|
-
"@vuu-ui/vuu-utils": "0.13.
|
|
21
|
-
"@vuu-ui/vuu-table": "0.13.
|
|
13
|
+
"@vuu-ui/vuu-context-menu": "0.13.75",
|
|
14
|
+
"@vuu-ui/vuu-data-remote": "0.13.75",
|
|
15
|
+
"@vuu-ui/vuu-filter-parser": "0.13.75",
|
|
16
|
+
"@vuu-ui/vuu-filters": "0.13.75",
|
|
17
|
+
"@vuu-ui/vuu-layout": "0.13.75",
|
|
18
|
+
"@vuu-ui/vuu-popups": "0.13.75",
|
|
19
|
+
"@vuu-ui/vuu-ui-controls": "0.13.75",
|
|
20
|
+
"@vuu-ui/vuu-utils": "0.13.75",
|
|
21
|
+
"@vuu-ui/vuu-table": "0.13.75",
|
|
22
22
|
"@salt-ds/core": "1.48.0",
|
|
23
23
|
"@salt-ds/styles": "0.2.1",
|
|
24
24
|
"@salt-ds/window": "0.1.1"
|