@teamvortexsoftware/vortex-react-native 1.0.0 → 1.0.1
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/InviteFormCore-D4HkMMo0.d.mts +721 -0
- package/dist/InviteFormCore-D9oUCbu7.d.ts +721 -0
- package/dist/VortexClient.js +192 -0
- package/dist/VortexClient.js.map +1 -0
- package/dist/VortexDeferredLinks.js +127 -0
- package/dist/VortexDeferredLinks.js.map +1 -0
- package/dist/clientInfo.js +45 -0
- package/dist/clientInfo.js.map +1 -0
- package/dist/components/ContactsPickerModal.js +182 -0
- package/dist/components/ContactsPickerModal.js.map +1 -0
- package/dist/components/InviteFormCore.js +2141 -0
- package/dist/components/InviteFormCore.js.map +1 -0
- package/dist/components/InviteFormMobile.js +463 -0
- package/dist/components/InviteFormMobile.js.map +1 -0
- package/dist/components/InviteFormWeb.js +295 -0
- package/dist/components/InviteFormWeb.js.map +1 -0
- package/dist/components/PlacedItemToolbar.js +147 -0
- package/dist/components/PlacedItemToolbar.js.map +1 -0
- package/dist/components/ShareButtons.js +181 -0
- package/dist/components/ShareButtons.js.map +1 -0
- package/dist/components/VrtxContactsImport.js +234 -0
- package/dist/components/VrtxContactsImport.js.map +1 -0
- package/dist/components/VrtxEmailInvitations.js +341 -0
- package/dist/components/VrtxEmailInvitations.js.map +1 -0
- package/dist/components/VrtxFindFriends.js +400 -0
- package/dist/components/VrtxFindFriends.js.map +1 -0
- package/dist/components/VrtxHeading.js +58 -0
- package/dist/components/VrtxHeading.js.map +1 -0
- package/dist/components/VrtxIncomingInvitations.js +657 -0
- package/dist/components/VrtxIncomingInvitations.js.map +1 -0
- package/dist/components/VrtxInvitationSuggestions.js +506 -0
- package/dist/components/VrtxInvitationSuggestions.js.map +1 -0
- package/dist/components/VrtxInviteContacts.js +512 -0
- package/dist/components/VrtxInviteContacts.js.map +1 -0
- package/dist/components/VrtxOutgoingInvitations.js +572 -0
- package/dist/components/VrtxOutgoingInvitations.js.map +1 -0
- package/dist/components/VrtxSearchBox.js +487 -0
- package/dist/components/VrtxSearchBox.js.map +1 -0
- package/dist/components/VrtxSelect.js +27 -0
- package/dist/components/VrtxSelect.js.map +1 -0
- package/dist/components/VrtxShareOptions.js +435 -0
- package/dist/components/VrtxShareOptions.js.map +1 -0
- package/dist/components/VrtxSubmit.js +132 -0
- package/dist/components/VrtxSubmit.js.map +1 -0
- package/dist/components/VrtxText.js +146 -0
- package/dist/components/VrtxText.js.map +1 -0
- package/dist/constants/mockData.d.mts +7 -0
- package/dist/constants/mockData.d.ts +7 -0
- package/dist/constants/mockData.js +48 -0
- package/dist/constants/mockData.js.map +1 -0
- package/dist/constants/mockData.mjs +22 -0
- package/dist/constants/mockData.mjs.map +1 -0
- package/dist/context/VortexModulesContext.js +135 -0
- package/dist/context/VortexModulesContext.js.map +1 -0
- package/dist/hooks/useInvitationFormLogic.d.mts +2 -0
- package/dist/hooks/useInvitationFormLogic.d.ts +2 -0
- package/dist/hooks/useInvitationFormLogic.js +300 -0
- package/dist/hooks/useInvitationFormLogic.js.map +1 -0
- package/dist/hooks/useInvitationFormLogic.mjs +276 -0
- package/dist/hooks/useInvitationFormLogic.mjs.map +1 -0
- package/dist/hooks/usePrefetchWidgetConfiguration.js +117 -0
- package/dist/hooks/usePrefetchWidgetConfiguration.js.map +1 -0
- package/dist/hooks/useThemeStyles.js +41 -0
- package/dist/hooks/useThemeStyles.js.map +1 -0
- package/dist/hooks/useVortexInvite.js +732 -0
- package/dist/hooks/useVortexInvite.js.map +1 -0
- package/dist/index-web.d.mts +93 -0
- package/dist/index-web.d.ts +93 -0
- package/dist/index-web.js +7397 -0
- package/dist/index-web.js.map +1 -0
- package/dist/index-web.mjs +7445 -0
- package/dist/index-web.mjs.map +1 -0
- package/dist/index.d.mts +656 -0
- package/dist/index.d.ts +656 -0
- package/dist/index.js +10206 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +10244 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/VortexClient.d.ts +106 -0
- package/dist/types/VortexClient.d.ts.map +1 -0
- package/dist/types/VortexDeferredLinks.d.ts +73 -0
- package/dist/types/VortexDeferredLinks.d.ts.map +1 -0
- package/dist/types/clientInfo.d.ts +5 -0
- package/dist/types/clientInfo.d.ts.map +1 -0
- package/dist/types/components/ContactsPickerModal.d.ts +18 -0
- package/dist/types/components/ContactsPickerModal.d.ts.map +1 -0
- package/dist/types/components/InviteFormCore.d.ts +166 -0
- package/dist/types/components/InviteFormCore.d.ts.map +1 -0
- package/dist/types/components/InviteFormMobile.d.ts +42 -0
- package/dist/types/components/InviteFormMobile.d.ts.map +1 -0
- package/dist/types/components/InviteFormWeb.d.ts +87 -0
- package/dist/types/components/InviteFormWeb.d.ts.map +1 -0
- package/dist/types/components/PlacedItemToolbar.d.ts +16 -0
- package/dist/types/components/PlacedItemToolbar.d.ts.map +1 -0
- package/dist/types/components/ShareButtons.d.ts +29 -0
- package/dist/types/components/ShareButtons.d.ts.map +1 -0
- package/dist/types/components/VrtxContactsImport.d.ts +14 -0
- package/dist/types/components/VrtxContactsImport.d.ts.map +1 -0
- package/dist/types/components/VrtxEmailInvitations.d.ts +31 -0
- package/dist/types/components/VrtxEmailInvitations.d.ts.map +1 -0
- package/dist/types/components/VrtxFindFriends.d.ts +25 -0
- package/dist/types/components/VrtxFindFriends.d.ts.map +1 -0
- package/dist/types/components/VrtxHeading.d.ts +6 -0
- package/dist/types/components/VrtxHeading.d.ts.map +1 -0
- package/dist/types/components/VrtxIncomingInvitations.d.ts +27 -0
- package/dist/types/components/VrtxIncomingInvitations.d.ts.map +1 -0
- package/dist/types/components/VrtxInvitationSuggestions.d.ts +25 -0
- package/dist/types/components/VrtxInvitationSuggestions.d.ts.map +1 -0
- package/dist/types/components/VrtxInviteContacts.d.ts +24 -0
- package/dist/types/components/VrtxInviteContacts.d.ts.map +1 -0
- package/dist/types/components/VrtxOutgoingInvitations.d.ts +27 -0
- package/dist/types/components/VrtxOutgoingInvitations.d.ts.map +1 -0
- package/dist/types/components/VrtxSearchBox.d.ts +28 -0
- package/dist/types/components/VrtxSearchBox.d.ts.map +1 -0
- package/dist/types/components/VrtxSelect.d.ts +6 -0
- package/dist/types/components/VrtxSelect.d.ts.map +1 -0
- package/dist/types/components/VrtxShareOptions.d.ts +41 -0
- package/dist/types/components/VrtxShareOptions.d.ts.map +1 -0
- package/dist/types/components/VrtxSubmit.d.ts +18 -0
- package/dist/types/components/VrtxSubmit.d.ts.map +1 -0
- package/dist/types/components/VrtxText.d.ts +8 -0
- package/dist/types/components/VrtxText.d.ts.map +1 -0
- package/dist/types/constants/mockData.d.ts +4 -0
- package/dist/types/constants/mockData.d.ts.map +1 -0
- package/dist/types/context/VortexModulesContext.d.ts +238 -0
- package/dist/types/context/VortexModulesContext.d.ts.map +1 -0
- package/dist/types/findFriends.js +10 -0
- package/dist/types/findFriends.js.map +1 -0
- package/dist/types/hooks/useInvitationFormLogic.d.ts +55 -0
- package/dist/types/hooks/useInvitationFormLogic.d.ts.map +1 -0
- package/dist/types/hooks/usePrefetchWidgetConfiguration.d.ts +39 -0
- package/dist/types/hooks/usePrefetchWidgetConfiguration.d.ts.map +1 -0
- package/dist/types/hooks/useThemeStyles.d.ts +35 -0
- package/dist/types/hooks/useThemeStyles.d.ts.map +1 -0
- package/dist/types/hooks/useVortexInvite.d.ts +86 -0
- package/dist/types/hooks/useVortexInvite.d.ts.map +1 -0
- package/dist/types/index-web.d.ts +23 -0
- package/dist/types/index-web.d.ts.map +1 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/invitations.js +13 -0
- package/dist/types/invitations.js.map +1 -0
- package/dist/types/inviteContacts.js +14 -0
- package/dist/types/inviteContacts.js.map +1 -0
- package/dist/types/platformOperations.js +3 -0
- package/dist/types/platformOperations.js.map +1 -0
- package/dist/types/searchBox.js +11 -0
- package/dist/types/searchBox.js.map +1 -0
- package/dist/types/types/findFriends.d.ts +101 -0
- package/dist/types/types/findFriends.d.ts.map +1 -0
- package/dist/types/types/invitations.d.ts +301 -0
- package/dist/types/types/invitations.d.ts.map +1 -0
- package/dist/types/types/inviteContacts.d.ts +86 -0
- package/dist/types/types/inviteContacts.d.ts.map +1 -0
- package/dist/types/types/platformOperations.d.ts +185 -0
- package/dist/types/types/platformOperations.d.ts.map +1 -0
- package/dist/types/types/searchBox.d.ts +69 -0
- package/dist/types/types/searchBox.d.ts.map +1 -0
- package/dist/types/types/unfurlConfig.d.ts +34 -0
- package/dist/types/types/unfurlConfig.d.ts.map +1 -0
- package/dist/types/unfurlConfig.js +21 -0
- package/dist/types/unfurlConfig.js.map +1 -0
- package/dist/types/utils/analytics.d.ts +54 -0
- package/dist/types/utils/analytics.d.ts.map +1 -0
- package/dist/types/utils/configCache.d.ts +34 -0
- package/dist/types/utils/configCache.d.ts.map +1 -0
- package/dist/types/utils/contactUtils.d.ts +9 -0
- package/dist/types/utils/contactUtils.d.ts.map +1 -0
- package/dist/types/utils/featureWarnings.d.ts +56 -0
- package/dist/types/utils/featureWarnings.d.ts.map +1 -0
- package/dist/types/utils/formUtils.d.ts +93 -0
- package/dist/types/utils/formUtils.d.ts.map +1 -0
- package/dist/types/utils/gradientUtils.d.ts +67 -0
- package/dist/types/utils/gradientUtils.d.ts.map +1 -0
- package/dist/types/utils/invitationEvents.d.ts +21 -0
- package/dist/types/utils/invitationEvents.d.ts.map +1 -0
- package/dist/types/utils/moduleLoaders.d.ts +115 -0
- package/dist/types/utils/moduleLoaders.d.ts.map +1 -0
- package/dist/types/utils/moduleLoaders.web.d.ts +73 -0
- package/dist/types/utils/moduleLoaders.web.d.ts.map +1 -0
- package/dist/types/utils/nameUtils.d.ts +15 -0
- package/dist/types/utils/nameUtils.d.ts.map +1 -0
- package/dist/types/utils/themeUtils.d.ts +38 -0
- package/dist/types/utils/themeUtils.d.ts.map +1 -0
- package/dist/types/vortexInvite.d.ts +165 -0
- package/dist/types/vortexInvite.d.ts.map +1 -0
- package/dist/useInvitationFormLogic-Ct73M19B.d.mts +242 -0
- package/dist/useInvitationFormLogic-Ct73M19B.d.ts +242 -0
- package/dist/utils/analytics.js +92 -0
- package/dist/utils/analytics.js.map +1 -0
- package/dist/utils/configCache.js +68 -0
- package/dist/utils/configCache.js.map +1 -0
- package/dist/utils/contactUtils.d.mts +12 -0
- package/dist/utils/contactUtils.d.ts +12 -0
- package/dist/utils/contactUtils.js +37 -0
- package/dist/utils/contactUtils.js.map +1 -0
- package/dist/utils/contactUtils.mjs +12 -0
- package/dist/utils/contactUtils.mjs.map +1 -0
- package/dist/utils/featureWarnings.js +214 -0
- package/dist/utils/featureWarnings.js.map +1 -0
- package/dist/utils/formUtils.js +284 -0
- package/dist/utils/formUtils.js.map +1 -0
- package/dist/utils/gradientUtils.js +120 -0
- package/dist/utils/gradientUtils.js.map +1 -0
- package/dist/utils/invitationEvents.js +45 -0
- package/dist/utils/invitationEvents.js.map +1 -0
- package/dist/utils/moduleLoaders.js +275 -0
- package/dist/utils/moduleLoaders.js.map +1 -0
- package/dist/utils/moduleLoaders.web.js +72 -0
- package/dist/utils/moduleLoaders.web.js.map +1 -0
- package/dist/utils/nameUtils.js +51 -0
- package/dist/utils/nameUtils.js.map +1 -0
- package/dist/utils/themeUtils.js +141 -0
- package/dist/utils/themeUtils.js.map +1 -0
- package/dist/vortexInvite.js +83 -0
- package/dist/vortexInvite.js.map +1 -0
- package/package.json +21 -56
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.usePrefetchWidgetConfiguration = usePrefetchWidgetConfiguration;
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const vortex_shared_ui_1 = require("@teamvortexsoftware/vortex-shared-ui");
|
|
18
|
+
const react_native_uuid_1 = __importDefault(require("react-native-uuid"));
|
|
19
|
+
const configCache_1 = require("../utils/configCache");
|
|
20
|
+
/**
|
|
21
|
+
* Hook to prefetch widget configuration for instant rendering.
|
|
22
|
+
* This hook fetches the configuration early (e.g., when JWT becomes available)
|
|
23
|
+
* so the VortexInvite component can render immediately without showing a loading spinner.
|
|
24
|
+
*
|
|
25
|
+
* The hook will still refetch in the background when VortexInvite mounts to ensure
|
|
26
|
+
* the configuration is up-to-date (stale-while-revalidate pattern).
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* const { widgetConfiguration } = usePrefetchWidgetConfiguration({
|
|
31
|
+
* componentId: 'your-component-id',
|
|
32
|
+
* vortexApiUrl: 'https://client-api.vortexsoftware.com',
|
|
33
|
+
* jwt,
|
|
34
|
+
* enabled: !!jwt, // Only prefetch when JWT is ready
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* <VortexInvite
|
|
38
|
+
* componentId={componentId}
|
|
39
|
+
* jwt={jwt}
|
|
40
|
+
* widgetConfiguration={widgetConfiguration} // Pass prefetched config
|
|
41
|
+
* // ... other props
|
|
42
|
+
* />
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
function usePrefetchWidgetConfiguration({ componentId, vortexApiUrl, jwt, user, enabled = true, }) {
|
|
46
|
+
// Read from module-level cache instead of local state
|
|
47
|
+
const widgetConfiguration = configCache_1.configCache.get(componentId);
|
|
48
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
49
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
50
|
+
// Generate effective JWT (same logic as useVortexInvite)
|
|
51
|
+
const effectiveJwt = (0, react_1.useMemo)(() => {
|
|
52
|
+
if (jwt)
|
|
53
|
+
return jwt;
|
|
54
|
+
if (user) {
|
|
55
|
+
if (typeof user === 'string')
|
|
56
|
+
return user;
|
|
57
|
+
const payload = Object.assign(Object.assign({}, user), { componentId });
|
|
58
|
+
const jsonString = JSON.stringify(payload);
|
|
59
|
+
const base64Encoded = Buffer.from(jsonString).toString('base64');
|
|
60
|
+
return `raw-data:${base64Encoded}`;
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}, [jwt, user, componentId]);
|
|
64
|
+
const vortexClient = (0, react_1.useMemo)(() => {
|
|
65
|
+
const clientInfo = (0, vortex_shared_ui_1.getClientInfo)();
|
|
66
|
+
const sessionId = react_native_uuid_1.default.v4();
|
|
67
|
+
return new vortex_shared_ui_1.VortexClient(vortexApiUrl, clientInfo.name, clientInfo.version, sessionId);
|
|
68
|
+
}, [vortexApiUrl]);
|
|
69
|
+
(0, react_1.useEffect)(() => {
|
|
70
|
+
if (!enabled) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!effectiveJwt) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (widgetConfiguration) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
let cancelled = false;
|
|
80
|
+
const fetchConfig = () => __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
var _a;
|
|
82
|
+
setIsLoading(true);
|
|
83
|
+
setError(null);
|
|
84
|
+
try {
|
|
85
|
+
console.log('[Vortex] Prefetching widget configuration...');
|
|
86
|
+
const result = yield vortexClient.getWidgetConfiguration(componentId, effectiveJwt);
|
|
87
|
+
if (!cancelled && ((_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.widgetConfiguration)) {
|
|
88
|
+
const config = result.data.widgetConfiguration;
|
|
89
|
+
configCache_1.configCache.set(componentId, config); // Write to shared cache
|
|
90
|
+
console.log('[Vortex] Widget configuration prefetched successfully');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (err) {
|
|
94
|
+
if (!cancelled) {
|
|
95
|
+
const error = err instanceof Error ? err : new Error('Failed to prefetch configuration');
|
|
96
|
+
setError(error);
|
|
97
|
+
console.error('[Vortex] Failed to prefetch widget configuration:', error);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
if (!cancelled) {
|
|
102
|
+
setIsLoading(false);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
fetchConfig();
|
|
107
|
+
return () => {
|
|
108
|
+
cancelled = true;
|
|
109
|
+
};
|
|
110
|
+
}, [componentId, effectiveJwt, vortexClient, enabled, widgetConfiguration]);
|
|
111
|
+
return {
|
|
112
|
+
widgetConfiguration,
|
|
113
|
+
error,
|
|
114
|
+
isLoading,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=usePrefetchWidgetConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrefetchWidgetConfiguration.js","sourceRoot":"","sources":["../../src/hooks/usePrefetchWidgetConfiguration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAuCA,wEAoFC;AA3HD,iCAAqD;AACrD,2EAAsG;AAEtG,0EAAqC;AACrC,sDAAmD;AAUnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,8BAA8B,CAAC,EAC7C,WAAW,EACX,YAAY,EACZ,GAAG,EACH,IAAI,EACJ,OAAO,GAAG,IAAI,GACwB;IACtC,sDAAsD;IACtD,MAAM,mBAAmB,GAAG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,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAE5E,OAAO;QACL,mBAAmB;QACnB,KAAK;QACL,SAAS;KACV,CAAC;AACJ,CAAC","sourcesContent":["import { useState, useEffect, useMemo } from 'react';\nimport { VortexClient, getClientInfo, VortexWidgetError } from '@teamvortexsoftware/vortex-shared-ui';\nimport { WidgetConfiguration, UnsignedData } from '@teamvortexsoftware/vortex-types';\nimport uuid from 'react-native-uuid';\nimport { configCache } from '../utils/configCache';\n\nexport interface UsePrefetchWidgetConfigurationOptions {\n componentId: string;\n vortexApiUrl: string;\n jwt?: string;\n user?: string | UnsignedData;\n enabled?: boolean; // Allow conditional prefetching\n}\n\n/**\n * Hook to prefetch widget configuration for instant rendering.\n * This hook fetches the configuration early (e.g., when JWT becomes available)\n * so the VortexInvite component can render immediately without showing a loading spinner.\n * \n * The hook will still refetch in the background when VortexInvite mounts to ensure\n * the configuration is up-to-date (stale-while-revalidate pattern).\n * \n * @example\n * ```tsx\n * const { widgetConfiguration } = usePrefetchWidgetConfiguration({\n * componentId: 'your-component-id',\n * vortexApiUrl: 'https://client-api.vortexsoftware.com',\n * jwt,\n * enabled: !!jwt, // Only prefetch when JWT is ready\n * });\n * \n * <VortexInvite\n * componentId={componentId}\n * jwt={jwt}\n * widgetConfiguration={widgetConfiguration} // Pass prefetched config\n * // ... other props\n * />\n * ```\n */\nexport function usePrefetchWidgetConfiguration({\n componentId,\n vortexApiUrl,\n jwt,\n user,\n enabled = true,\n}: UsePrefetchWidgetConfigurationOptions) {\n // Read from module-level cache instead of local state\n const widgetConfiguration = configCache.get(componentId);\n const [error, setError] = useState<Error | null>(null);\n const [isLoading, setIsLoading] = useState(false);\n\n // Generate effective JWT (same logic as useVortexInvite)\n const effectiveJwt = useMemo(() => {\n if (jwt) return jwt;\n if (user) {\n if (typeof user === 'string') return user;\n const payload = { ...user, componentId };\n const jsonString = JSON.stringify(payload);\n const base64Encoded = Buffer.from(jsonString).toString('base64');\n return `raw-data:${base64Encoded}`;\n }\n return undefined;\n }, [jwt, user, componentId]);\n\n const vortexClient = useMemo(() => {\n const clientInfo = getClientInfo();\n const sessionId = uuid.v4() as string;\n return new VortexClient(vortexApiUrl, clientInfo.name, clientInfo.version, sessionId);\n }, [vortexApiUrl]);\n\n useEffect(() => {\n if (!enabled) {\n return;\n }\n\n if (!effectiveJwt) {\n return;\n }\n\n if (widgetConfiguration) {\n return;\n }\n\n let cancelled = false;\n\n const fetchConfig = async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n console.log('[Vortex] Prefetching widget configuration...');\n const result = await vortexClient.getWidgetConfiguration(componentId, effectiveJwt);\n\n if (!cancelled && result?.data?.widgetConfiguration) {\n const config = result.data.widgetConfiguration as unknown as WidgetConfiguration;\n configCache.set(componentId, config); // Write to shared cache\n console.log('[Vortex] Widget configuration prefetched successfully');\n }\n } catch (err) {\n if (!cancelled) {\n const error = err instanceof Error ? err : new Error('Failed to prefetch configuration');\n setError(error);\n console.error('[Vortex] Failed to prefetch widget configuration:', error);\n }\n } finally {\n if (!cancelled) {\n setIsLoading(false);\n }\n }\n };\n\n fetchConfig();\n\n return () => {\n cancelled = true;\n };\n }, [componentId, effectiveJwt, vortexClient, enabled, widgetConfiguration]);\n\n return {\n widgetConfiguration,\n error,\n isLoading,\n };\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useThemeStyles = useThemeStyles;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Hook to generate dynamic styles based on theme colors
|
|
7
|
+
* @param themeColors The theme colors object
|
|
8
|
+
* @returns Object containing styled components based on the theme
|
|
9
|
+
*/
|
|
10
|
+
function useThemeStyles(themeColors) {
|
|
11
|
+
const themeStyles = (0, react_1.useMemo)(() => ({
|
|
12
|
+
primaryButton: {
|
|
13
|
+
backgroundColor: themeColors.primaryButtonBackground,
|
|
14
|
+
borderColor: themeColors.primaryButtonBorder,
|
|
15
|
+
},
|
|
16
|
+
primaryButtonText: {
|
|
17
|
+
color: themeColors.primaryButtonForeground,
|
|
18
|
+
},
|
|
19
|
+
secondaryButton: {
|
|
20
|
+
backgroundColor: themeColors.secondaryButtonBackground,
|
|
21
|
+
borderColor: themeColors.secondaryButtonBorder,
|
|
22
|
+
},
|
|
23
|
+
secondaryButtonText: {
|
|
24
|
+
color: themeColors.secondaryButtonForeground,
|
|
25
|
+
},
|
|
26
|
+
containerStyles: {
|
|
27
|
+
backgroundColor: themeColors.containerBackground,
|
|
28
|
+
borderColor: themeColors.containerBorder,
|
|
29
|
+
},
|
|
30
|
+
textStyles: {
|
|
31
|
+
color: themeColors.containerForeground,
|
|
32
|
+
},
|
|
33
|
+
inputStyles: {
|
|
34
|
+
borderColor: themeColors.containerBorder,
|
|
35
|
+
color: themeColors.containerForeground,
|
|
36
|
+
backgroundColor: themeColors.containerBackground,
|
|
37
|
+
},
|
|
38
|
+
}), [themeColors]);
|
|
39
|
+
return themeStyles;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=useThemeStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeStyles.js","sourceRoot":"","sources":["../../src/hooks/useThemeStyles.ts"],"names":[],"mappings":";;AAQA,wCAkCC;AA1CD,iCAAgC;AAGhC;;;;GAIG;AACH,SAAgB,cAAc,CAAC,WAAwB;IACrD,MAAM,WAAW,GAAG,IAAA,eAAO,EACzB,GAAG,EAAE,CAAC,CAAC;QACL,aAAa,EAAE;YACb,eAAe,EAAE,WAAW,CAAC,uBAAuB;YACpD,WAAW,EAAE,WAAW,CAAC,mBAAmB;SAC7C;QACD,iBAAiB,EAAE;YACjB,KAAK,EAAE,WAAW,CAAC,uBAAuB;SAC3C;QACD,eAAe,EAAE;YACf,eAAe,EAAE,WAAW,CAAC,yBAAyB;YACtD,WAAW,EAAE,WAAW,CAAC,qBAAqB;SAC/C;QACD,mBAAmB,EAAE;YACnB,KAAK,EAAE,WAAW,CAAC,yBAAyB;SAC7C;QACD,eAAe,EAAE;YACf,eAAe,EAAE,WAAW,CAAC,mBAAmB;YAChD,WAAW,EAAE,WAAW,CAAC,eAAe;SACzC;QACD,UAAU,EAAE;YACV,KAAK,EAAE,WAAW,CAAC,mBAAmB;SACvC;QACD,WAAW,EAAE;YACX,WAAW,EAAE,WAAW,CAAC,eAAe;YACxC,KAAK,EAAE,WAAW,CAAC,mBAAmB;YACtC,eAAe,EAAE,WAAW,CAAC,mBAAmB;SACjD;KACF,CAAC,EACF,CAAC,WAAW,CAAC,CACd,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import { useMemo } from \"react\";\nimport { ThemeColors } from \"../utils/themeUtils\";\n\n/**\n * Hook to generate dynamic styles based on theme colors\n * @param themeColors The theme colors object\n * @returns Object containing styled components based on the theme\n */\nexport function useThemeStyles(themeColors: ThemeColors) {\n const themeStyles = useMemo(\n () => ({\n primaryButton: {\n backgroundColor: themeColors.primaryButtonBackground,\n borderColor: themeColors.primaryButtonBorder,\n },\n primaryButtonText: {\n color: themeColors.primaryButtonForeground,\n },\n secondaryButton: {\n backgroundColor: themeColors.secondaryButtonBackground,\n borderColor: themeColors.secondaryButtonBorder,\n },\n secondaryButtonText: {\n color: themeColors.secondaryButtonForeground,\n },\n containerStyles: {\n backgroundColor: themeColors.containerBackground,\n borderColor: themeColors.containerBorder,\n },\n textStyles: {\n color: themeColors.containerForeground,\n },\n inputStyles: {\n borderColor: themeColors.containerBorder,\n color: themeColors.containerForeground,\n backgroundColor: themeColors.containerBackground,\n },\n }),\n [themeColors],\n );\n\n return themeStyles;\n}\n"]}
|