@sylphx/sdk 0.3.6 → 0.4.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/index.d.cts +376 -1
- package/dist/index.d.ts +376 -1
- package/dist/index.js +127 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -3
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs/index.js +7 -2
- package/dist/nextjs/index.js.map +1 -1
- package/dist/nextjs/index.mjs +7 -2
- package/dist/nextjs/index.mjs.map +1 -1
- package/dist/react/index.d.cts +330 -1
- package/dist/react/index.d.ts +330 -1
- package/dist/react/index.js +710 -543
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +384 -221
- package/dist/react/index.mjs.map +1 -1
- package/dist/server/index.js +30 -11
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +30 -11
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -582,11 +582,13 @@ __export(react_exports, {
|
|
|
582
582
|
useFormTracking: () => useFormTracking,
|
|
583
583
|
useGlobalErrorHandler: () => useGlobalErrorHandler,
|
|
584
584
|
useGoogleConsentMode: () => useGoogleConsentMode,
|
|
585
|
+
useHasPermission: () => useHasPermission,
|
|
585
586
|
useInbox: () => useInbox,
|
|
586
587
|
useIsInTreatment: () => useIsInTreatment,
|
|
587
588
|
useIsInVariant: () => useIsInVariant,
|
|
588
589
|
useKv: () => useKv,
|
|
589
590
|
useLeaderboard: () => useLeaderboard,
|
|
591
|
+
useMemberPermissions: () => useMemberPermissions,
|
|
590
592
|
useMobilePush: () => useMobilePush,
|
|
591
593
|
useModal: () => useModal,
|
|
592
594
|
useModels: () => useModels,
|
|
@@ -597,12 +599,14 @@ __export(react_exports, {
|
|
|
597
599
|
useOAuthProviders: () => useOAuthProviders2,
|
|
598
600
|
useOrganization: () => useOrganization,
|
|
599
601
|
usePageView: () => usePageView,
|
|
602
|
+
usePermissions: () => usePermissions,
|
|
600
603
|
usePlans: () => usePlans,
|
|
601
604
|
useProtect: () => useProtect,
|
|
602
605
|
useRealtime: () => useRealtime,
|
|
603
606
|
useRealtimeChannels: () => useRealtimeChannels,
|
|
604
607
|
useReferral: () => useReferral,
|
|
605
608
|
useResetPasswordForm: () => useResetPasswordForm,
|
|
609
|
+
useRoles: () => useRoles,
|
|
606
610
|
useRouterContext: () => useRouterContext,
|
|
607
611
|
useSafeAchievements: () => useSafeAchievements,
|
|
608
612
|
useSafeAnalytics: () => useSafeAnalytics,
|
|
@@ -42284,6 +42288,13 @@ var SylphxError = class _SylphxError extends Error {
|
|
|
42284
42288
|
static isRateLimited(err) {
|
|
42285
42289
|
return err instanceof _SylphxError && err.code === "TOO_MANY_REQUESTS";
|
|
42286
42290
|
}
|
|
42291
|
+
/**
|
|
42292
|
+
* Check if error is an account lockout error (too many failed login attempts).
|
|
42293
|
+
* When true, `error.data?.lockoutUntil` contains the ISO 8601 timestamp when the lockout expires.
|
|
42294
|
+
*/
|
|
42295
|
+
static isAccountLocked(err) {
|
|
42296
|
+
return err instanceof _SylphxError && err.code === "TOO_MANY_REQUESTS" && err.data?.code === "ACCOUNT_LOCKED";
|
|
42297
|
+
}
|
|
42287
42298
|
/**
|
|
42288
42299
|
* Check if error is a quota exceeded error (plan limit reached)
|
|
42289
42300
|
*/
|
|
@@ -43301,6 +43312,13 @@ function createConfig(input) {
|
|
|
43301
43312
|
accessToken: input.accessToken
|
|
43302
43313
|
});
|
|
43303
43314
|
}
|
|
43315
|
+
function withToken(config2, accessToken) {
|
|
43316
|
+
return Object.freeze({
|
|
43317
|
+
...config2,
|
|
43318
|
+
accessToken
|
|
43319
|
+
// Preserve baseUrl and ref from original config
|
|
43320
|
+
});
|
|
43321
|
+
}
|
|
43304
43322
|
function buildHeaders(config2) {
|
|
43305
43323
|
const headers = {
|
|
43306
43324
|
"Content-Type": "application/json"
|
|
@@ -44835,7 +44853,7 @@ function useOrganization() {
|
|
|
44835
44853
|
mounted = false;
|
|
44836
44854
|
};
|
|
44837
44855
|
}, [config2?.baseUrl, getStoredOrgSlug, selectOrganization, organization, config2]);
|
|
44838
|
-
const
|
|
44856
|
+
const hasPermission2 = (0, import_react76.useCallback)(
|
|
44839
44857
|
(permission) => {
|
|
44840
44858
|
if (!role) return false;
|
|
44841
44859
|
const rolePermissions = {
|
|
@@ -44963,7 +44981,7 @@ function useOrganization() {
|
|
|
44963
44981
|
isLoading,
|
|
44964
44982
|
error: error2,
|
|
44965
44983
|
role,
|
|
44966
|
-
hasPermission,
|
|
44984
|
+
hasPermission: hasPermission2,
|
|
44967
44985
|
setOrganization: selectOrganization,
|
|
44968
44986
|
createOrganization: createOrg,
|
|
44969
44987
|
updateOrganization: updateOrg,
|
|
@@ -46354,7 +46372,7 @@ function InviteMemberInner({
|
|
|
46354
46372
|
className,
|
|
46355
46373
|
showRoleDescriptions = true
|
|
46356
46374
|
}) {
|
|
46357
|
-
const { organization, inviteMember, hasPermission } = useOrganization();
|
|
46375
|
+
const { organization, inviteMember, hasPermission: hasPermission2 } = useOrganization();
|
|
46358
46376
|
const styles2 = baseStyles(theme);
|
|
46359
46377
|
const [email, setEmail] = (0, import_react83.useState)("");
|
|
46360
46378
|
const [role, setRole] = (0, import_react83.useState)(defaultRole);
|
|
@@ -46362,7 +46380,7 @@ function InviteMemberInner({
|
|
|
46362
46380
|
const [error2, setError] = (0, import_react83.useState)(null);
|
|
46363
46381
|
const [success, setSuccess] = (0, import_react83.useState)(false);
|
|
46364
46382
|
const [focusedField, setFocusedField] = (0, import_react83.useState)(null);
|
|
46365
|
-
const canInvite =
|
|
46383
|
+
const canInvite = hasPermission2("manage_members");
|
|
46366
46384
|
(0, import_react83.useEffect)(() => {
|
|
46367
46385
|
injectGlobalStyles();
|
|
46368
46386
|
}, []);
|
|
@@ -46741,7 +46759,7 @@ function MembersListInner({
|
|
|
46741
46759
|
organization,
|
|
46742
46760
|
members: serverMembers,
|
|
46743
46761
|
isLoading,
|
|
46744
|
-
hasPermission,
|
|
46762
|
+
hasPermission: hasPermission2,
|
|
46745
46763
|
updateMemberRole,
|
|
46746
46764
|
removeMember
|
|
46747
46765
|
} = useOrganization();
|
|
@@ -46751,7 +46769,7 @@ function MembersListInner({
|
|
|
46751
46769
|
const [error2, setError] = (0, import_react84.useState)(null);
|
|
46752
46770
|
const [showAll, setShowAll] = (0, import_react84.useState)(false);
|
|
46753
46771
|
const [pendingAction, setPendingAction] = (0, import_react84.useState)(null);
|
|
46754
|
-
const canManageMembers =
|
|
46772
|
+
const canManageMembers = hasPermission2("manage_members");
|
|
46755
46773
|
(0, import_react84.useEffect)(() => {
|
|
46756
46774
|
injectGlobalStyles();
|
|
46757
46775
|
}, []);
|
|
@@ -54361,7 +54379,12 @@ function SylphxProviderInner({
|
|
|
54361
54379
|
authPrefix = "/auth"
|
|
54362
54380
|
}) {
|
|
54363
54381
|
const appId = validateAndSanitizeAppId(appIdProp);
|
|
54364
|
-
const
|
|
54382
|
+
const resolvedRef = (() => {
|
|
54383
|
+
if (providedRef) return providedRef;
|
|
54384
|
+
const parts = appId?.split("_") ?? [];
|
|
54385
|
+
return parts.length === 4 && /^[a-z0-9]{12}$/.test(parts[2] ?? "") ? parts[2] : void 0;
|
|
54386
|
+
})();
|
|
54387
|
+
const platformUrl = resolvedRef ? `https://${resolvedRef}.${DEFAULT_SDK_API_HOST}` : providedPlatformUrl?.trim() || `https://${DEFAULT_SDK_API_HOST}`;
|
|
54365
54388
|
const storage2 = (0, import_react109.useMemo)(() => new SylphxStorage(appId), [appId]);
|
|
54366
54389
|
const [anonymousId, setAnonymousId] = (0, import_react109.useState)("");
|
|
54367
54390
|
(0, import_react109.useEffect)(() => {
|
|
@@ -54436,10 +54459,10 @@ function SylphxProviderInner({
|
|
|
54436
54459
|
}
|
|
54437
54460
|
const wasAnonymous = !prevIsSignedIn.current;
|
|
54438
54461
|
const isNowAuthenticated = authState.isSignedIn && authState.user?.id;
|
|
54439
|
-
if (wasAnonymous && isNowAuthenticated && authState.user && anonymousId &&
|
|
54462
|
+
if (wasAnonymous && isNowAuthenticated && authState.user && anonymousId && resolvedRef) {
|
|
54440
54463
|
const config3 = createConfig({
|
|
54441
54464
|
secretKey: appId,
|
|
54442
|
-
ref:
|
|
54465
|
+
ref: resolvedRef
|
|
54443
54466
|
});
|
|
54444
54467
|
linkAnonymousConsents(config3, {
|
|
54445
54468
|
userId: authState.user.id,
|
|
@@ -56078,7 +56101,7 @@ function SylphxProviderInner({
|
|
|
56078
56101
|
() => ({
|
|
56079
56102
|
appId,
|
|
56080
56103
|
platformUrl,
|
|
56081
|
-
ref:
|
|
56104
|
+
ref: resolvedRef,
|
|
56082
56105
|
anonymousId,
|
|
56083
56106
|
queryClient,
|
|
56084
56107
|
clickIds,
|
|
@@ -56217,23 +56240,163 @@ function SylphxProviderInner({
|
|
|
56217
56240
|
return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(AuthContext.Provider, { value: authValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(SdkAuthContext.Provider, { value: sdkAuthValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(UserContext.Provider, { value: userValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(SecurityContext.Provider, { value: securityValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(PlatformContext.Provider, { value: platformValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(StorageContext.Provider, { value: storageValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(AIContext.Provider, { value: aiValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(TasksContext.Provider, { value: tasksValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(MonitoringContext.Provider, { value: monitoringValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(ConsentContext.Provider, { value: consentValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(DatabaseContext.Provider, { value: databaseValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(EmailContext.Provider, { value: emailValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(NewsletterContext.Provider, { value: newsletterValue, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(WebhooksContext.Provider, { value: webhooksValue, children }) }) }) }) }) }) }) }) }) }) }) }) }) });
|
|
56218
56241
|
}
|
|
56219
56242
|
|
|
56220
|
-
// src/react/
|
|
56243
|
+
// src/react/rbac-hooks.ts
|
|
56244
|
+
var import_react_query7 = require("@tanstack/react-query");
|
|
56221
56245
|
var import_react110 = require("react");
|
|
56246
|
+
|
|
56247
|
+
// src/permissions.ts
|
|
56248
|
+
async function listPermissions(config2) {
|
|
56249
|
+
return callApi(config2, "/permissions");
|
|
56250
|
+
}
|
|
56251
|
+
async function getMemberPermissions(config2, orgIdOrSlug, memberId) {
|
|
56252
|
+
return callApi(
|
|
56253
|
+
config2,
|
|
56254
|
+
`/orgs/${orgIdOrSlug}/members/${memberId}/permissions`
|
|
56255
|
+
);
|
|
56256
|
+
}
|
|
56257
|
+
function hasPermission(permissions, required) {
|
|
56258
|
+
return permissions.includes(required);
|
|
56259
|
+
}
|
|
56260
|
+
function hasAnyPermission(permissions, required) {
|
|
56261
|
+
return required.some((perm) => permissions.includes(perm));
|
|
56262
|
+
}
|
|
56263
|
+
function hasAllPermissions(permissions, required) {
|
|
56264
|
+
return required.every((perm) => permissions.includes(perm));
|
|
56265
|
+
}
|
|
56266
|
+
|
|
56267
|
+
// src/roles.ts
|
|
56268
|
+
async function listRoles(config2) {
|
|
56269
|
+
return callApi(config2, "/roles");
|
|
56270
|
+
}
|
|
56271
|
+
|
|
56272
|
+
// src/react/rbac-hooks.ts
|
|
56273
|
+
function useSdkConfig() {
|
|
56274
|
+
const platform3 = (0, import_react110.useContext)(PlatformContext);
|
|
56275
|
+
const auth = (0, import_react110.useContext)(AuthContext);
|
|
56276
|
+
return (0, import_react110.useMemo)(() => {
|
|
56277
|
+
if (!platform3?.ref) return null;
|
|
56278
|
+
let config2 = createConfig({
|
|
56279
|
+
secretKey: platform3.appId,
|
|
56280
|
+
ref: platform3.ref
|
|
56281
|
+
});
|
|
56282
|
+
if (auth?.accessToken) {
|
|
56283
|
+
config2 = withToken(config2, auth.accessToken);
|
|
56284
|
+
}
|
|
56285
|
+
return config2;
|
|
56286
|
+
}, [platform3?.ref, platform3?.appId, auth?.accessToken]);
|
|
56287
|
+
}
|
|
56288
|
+
var rbacKeys = {
|
|
56289
|
+
all: ["rbac"],
|
|
56290
|
+
permissions: () => [...rbacKeys.all, "permissions"],
|
|
56291
|
+
roles: () => [...rbacKeys.all, "roles"],
|
|
56292
|
+
memberPermissions: (orgIdOrSlug, memberId) => [...rbacKeys.all, "memberPermissions", orgIdOrSlug, memberId]
|
|
56293
|
+
};
|
|
56294
|
+
function usePermissions() {
|
|
56295
|
+
const config2 = useSdkConfig();
|
|
56296
|
+
const queryClient = (0, import_react_query7.useQueryClient)();
|
|
56297
|
+
const { data, isLoading, error: error2 } = (0, import_react_query7.useQuery)({
|
|
56298
|
+
queryKey: rbacKeys.permissions(),
|
|
56299
|
+
queryFn: async () => {
|
|
56300
|
+
if (!config2) throw new Error("SDK not configured \u2014 wrap your app in SylphxProvider");
|
|
56301
|
+
return listPermissions(config2);
|
|
56302
|
+
},
|
|
56303
|
+
enabled: !!config2,
|
|
56304
|
+
staleTime: 3e4
|
|
56305
|
+
// 30s — permissions change rarely
|
|
56306
|
+
});
|
|
56307
|
+
const refresh = (0, import_react110.useCallback)(async () => {
|
|
56308
|
+
await queryClient.invalidateQueries({ queryKey: rbacKeys.permissions() });
|
|
56309
|
+
}, [queryClient]);
|
|
56310
|
+
return {
|
|
56311
|
+
permissions: data?.permissions ?? [],
|
|
56312
|
+
isLoading,
|
|
56313
|
+
error: error2,
|
|
56314
|
+
refresh
|
|
56315
|
+
};
|
|
56316
|
+
}
|
|
56317
|
+
function useRoles() {
|
|
56318
|
+
const config2 = useSdkConfig();
|
|
56319
|
+
const queryClient = (0, import_react_query7.useQueryClient)();
|
|
56320
|
+
const { data, isLoading, error: error2 } = (0, import_react_query7.useQuery)({
|
|
56321
|
+
queryKey: rbacKeys.roles(),
|
|
56322
|
+
queryFn: async () => {
|
|
56323
|
+
if (!config2) throw new Error("SDK not configured \u2014 wrap your app in SylphxProvider");
|
|
56324
|
+
return listRoles(config2);
|
|
56325
|
+
},
|
|
56326
|
+
enabled: !!config2,
|
|
56327
|
+
staleTime: 3e4
|
|
56328
|
+
// 30s — roles change rarely
|
|
56329
|
+
});
|
|
56330
|
+
const refresh = (0, import_react110.useCallback)(async () => {
|
|
56331
|
+
await queryClient.invalidateQueries({ queryKey: rbacKeys.roles() });
|
|
56332
|
+
}, [queryClient]);
|
|
56333
|
+
return {
|
|
56334
|
+
roles: data?.roles ?? [],
|
|
56335
|
+
isLoading,
|
|
56336
|
+
error: error2,
|
|
56337
|
+
refresh
|
|
56338
|
+
};
|
|
56339
|
+
}
|
|
56340
|
+
function useMemberPermissions(orgIdOrSlug, memberId) {
|
|
56341
|
+
const config2 = useSdkConfig();
|
|
56342
|
+
const queryClient = (0, import_react_query7.useQueryClient)();
|
|
56343
|
+
const enabled = !!config2 && !!orgIdOrSlug && !!memberId;
|
|
56344
|
+
const { data, isLoading, error: error2 } = (0, import_react_query7.useQuery)({
|
|
56345
|
+
queryKey: rbacKeys.memberPermissions(orgIdOrSlug ?? "", memberId ?? ""),
|
|
56346
|
+
queryFn: async () => {
|
|
56347
|
+
if (!config2 || !orgIdOrSlug || !memberId) {
|
|
56348
|
+
throw new Error("Missing required parameters");
|
|
56349
|
+
}
|
|
56350
|
+
return getMemberPermissions(config2, orgIdOrSlug, memberId);
|
|
56351
|
+
},
|
|
56352
|
+
enabled,
|
|
56353
|
+
staleTime: 15e3
|
|
56354
|
+
// 15s — member permissions may change more frequently
|
|
56355
|
+
});
|
|
56356
|
+
const refresh = (0, import_react110.useCallback)(async () => {
|
|
56357
|
+
if (orgIdOrSlug && memberId) {
|
|
56358
|
+
await queryClient.invalidateQueries({
|
|
56359
|
+
queryKey: rbacKeys.memberPermissions(orgIdOrSlug, memberId)
|
|
56360
|
+
});
|
|
56361
|
+
}
|
|
56362
|
+
}, [queryClient, orgIdOrSlug, memberId]);
|
|
56363
|
+
return {
|
|
56364
|
+
memberId: data?.memberId ?? null,
|
|
56365
|
+
role: data?.role ?? null,
|
|
56366
|
+
permissions: data?.permissions ?? [],
|
|
56367
|
+
isLoading: enabled ? isLoading : false,
|
|
56368
|
+
error: error2,
|
|
56369
|
+
refresh
|
|
56370
|
+
};
|
|
56371
|
+
}
|
|
56372
|
+
function useHasPermission(permissions, required) {
|
|
56373
|
+
return (0, import_react110.useMemo)(() => {
|
|
56374
|
+
const requiredArray = Array.isArray(required) ? required : [required];
|
|
56375
|
+
return {
|
|
56376
|
+
allowed: Array.isArray(required) ? hasAllPermissions(permissions, requiredArray) : hasPermission(permissions, required),
|
|
56377
|
+
allowedAny: hasAnyPermission(permissions, requiredArray),
|
|
56378
|
+
allowedAll: hasAllPermissions(permissions, requiredArray)
|
|
56379
|
+
};
|
|
56380
|
+
}, [permissions, required]);
|
|
56381
|
+
}
|
|
56382
|
+
|
|
56383
|
+
// src/react/storage-hooks.ts
|
|
56384
|
+
var import_react111 = require("react");
|
|
56222
56385
|
function useStorage() {
|
|
56223
56386
|
const ctx = useStorageContext();
|
|
56224
|
-
const [isUploading, setIsUploading] = (0,
|
|
56225
|
-
const [progress2, setProgress] = (0,
|
|
56226
|
-
const [bytesUploaded, setBytesUploaded] = (0,
|
|
56227
|
-
const [bytesTotal, setBytesTotal] = (0,
|
|
56228
|
-
const [uploadError, setUploadError] = (0,
|
|
56229
|
-
const [wasCancelled, setWasCancelled] = (0,
|
|
56230
|
-
const abortControllerRef = (0,
|
|
56231
|
-
const handleProgress = (0,
|
|
56387
|
+
const [isUploading, setIsUploading] = (0, import_react111.useState)(false);
|
|
56388
|
+
const [progress2, setProgress] = (0, import_react111.useState)(0);
|
|
56389
|
+
const [bytesUploaded, setBytesUploaded] = (0, import_react111.useState)(0);
|
|
56390
|
+
const [bytesTotal, setBytesTotal] = (0, import_react111.useState)(0);
|
|
56391
|
+
const [uploadError, setUploadError] = (0, import_react111.useState)(null);
|
|
56392
|
+
const [wasCancelled, setWasCancelled] = (0, import_react111.useState)(false);
|
|
56393
|
+
const abortControllerRef = (0, import_react111.useRef)(null);
|
|
56394
|
+
const handleProgress = (0, import_react111.useCallback)((event2) => {
|
|
56232
56395
|
setProgress(event2.progress);
|
|
56233
56396
|
setBytesUploaded(event2.loaded);
|
|
56234
56397
|
setBytesTotal(event2.total);
|
|
56235
56398
|
}, []);
|
|
56236
|
-
const cancel = (0,
|
|
56399
|
+
const cancel = (0, import_react111.useCallback)(() => {
|
|
56237
56400
|
if (abortControllerRef.current) {
|
|
56238
56401
|
abortControllerRef.current.abort();
|
|
56239
56402
|
abortControllerRef.current = null;
|
|
@@ -56241,7 +56404,7 @@ function useStorage() {
|
|
|
56241
56404
|
setIsUploading(false);
|
|
56242
56405
|
}
|
|
56243
56406
|
}, []);
|
|
56244
|
-
const upload = (0,
|
|
56407
|
+
const upload = (0, import_react111.useCallback)(
|
|
56245
56408
|
async (file, options) => {
|
|
56246
56409
|
const controller = new AbortController();
|
|
56247
56410
|
abortControllerRef.current = controller;
|
|
@@ -56275,7 +56438,7 @@ function useStorage() {
|
|
|
56275
56438
|
},
|
|
56276
56439
|
[ctx, handleProgress]
|
|
56277
56440
|
);
|
|
56278
|
-
const uploadAvatar = (0,
|
|
56441
|
+
const uploadAvatar = (0, import_react111.useCallback)(
|
|
56279
56442
|
async (file) => {
|
|
56280
56443
|
const controller = new AbortController();
|
|
56281
56444
|
abortControllerRef.current = controller;
|
|
@@ -56306,13 +56469,13 @@ function useStorage() {
|
|
|
56306
56469
|
},
|
|
56307
56470
|
[ctx, handleProgress]
|
|
56308
56471
|
);
|
|
56309
|
-
const deleteFile = (0,
|
|
56472
|
+
const deleteFile = (0, import_react111.useCallback)(
|
|
56310
56473
|
async (fileId) => {
|
|
56311
56474
|
await ctx.deleteFile(fileId);
|
|
56312
56475
|
},
|
|
56313
56476
|
[ctx]
|
|
56314
56477
|
);
|
|
56315
|
-
const getUrl = (0,
|
|
56478
|
+
const getUrl = (0, import_react111.useCallback)(
|
|
56316
56479
|
async (fileId) => {
|
|
56317
56480
|
return ctx.getUrl(fileId);
|
|
56318
56481
|
},
|
|
@@ -56334,20 +56497,20 @@ function useStorage() {
|
|
|
56334
56497
|
}
|
|
56335
56498
|
function useFileUpload(options = {}) {
|
|
56336
56499
|
const ctx = useStorageContext();
|
|
56337
|
-
const [isUploading, setIsUploading] = (0,
|
|
56338
|
-
const [progress2, setProgress] = (0,
|
|
56339
|
-
const [bytesUploaded, setBytesUploaded] = (0,
|
|
56340
|
-
const [bytesTotal, setBytesTotal] = (0,
|
|
56341
|
-
const [error2, setError] = (0,
|
|
56342
|
-
const [wasCancelled, setWasCancelled] = (0,
|
|
56343
|
-
const [url, setUrl] = (0,
|
|
56344
|
-
const abortControllerRef = (0,
|
|
56345
|
-
const handleProgress = (0,
|
|
56500
|
+
const [isUploading, setIsUploading] = (0, import_react111.useState)(false);
|
|
56501
|
+
const [progress2, setProgress] = (0, import_react111.useState)(0);
|
|
56502
|
+
const [bytesUploaded, setBytesUploaded] = (0, import_react111.useState)(0);
|
|
56503
|
+
const [bytesTotal, setBytesTotal] = (0, import_react111.useState)(0);
|
|
56504
|
+
const [error2, setError] = (0, import_react111.useState)(null);
|
|
56505
|
+
const [wasCancelled, setWasCancelled] = (0, import_react111.useState)(false);
|
|
56506
|
+
const [url, setUrl] = (0, import_react111.useState)(null);
|
|
56507
|
+
const abortControllerRef = (0, import_react111.useRef)(null);
|
|
56508
|
+
const handleProgress = (0, import_react111.useCallback)((event2) => {
|
|
56346
56509
|
setProgress(event2.progress);
|
|
56347
56510
|
setBytesUploaded(event2.loaded);
|
|
56348
56511
|
setBytesTotal(event2.total);
|
|
56349
56512
|
}, []);
|
|
56350
|
-
const cancel = (0,
|
|
56513
|
+
const cancel = (0, import_react111.useCallback)(() => {
|
|
56351
56514
|
if (abortControllerRef.current) {
|
|
56352
56515
|
abortControllerRef.current.abort();
|
|
56353
56516
|
abortControllerRef.current = null;
|
|
@@ -56356,7 +56519,7 @@ function useFileUpload(options = {}) {
|
|
|
56356
56519
|
options.onCancel?.();
|
|
56357
56520
|
}
|
|
56358
56521
|
}, [options]);
|
|
56359
|
-
const upload = (0,
|
|
56522
|
+
const upload = (0, import_react111.useCallback)(
|
|
56360
56523
|
async (file) => {
|
|
56361
56524
|
if (options.accept && options.accept.length > 0) {
|
|
56362
56525
|
const isAccepted = options.accept.some((type) => {
|
|
@@ -56416,7 +56579,7 @@ function useFileUpload(options = {}) {
|
|
|
56416
56579
|
},
|
|
56417
56580
|
[ctx, options, handleProgress]
|
|
56418
56581
|
);
|
|
56419
|
-
const reset = (0,
|
|
56582
|
+
const reset = (0, import_react111.useCallback)(() => {
|
|
56420
56583
|
setIsUploading(false);
|
|
56421
56584
|
setProgress(0);
|
|
56422
56585
|
setBytesUploaded(0);
|
|
@@ -56441,13 +56604,13 @@ function useFileUpload(options = {}) {
|
|
|
56441
56604
|
}
|
|
56442
56605
|
|
|
56443
56606
|
// src/react/task-hooks.ts
|
|
56444
|
-
var
|
|
56445
|
-
var
|
|
56607
|
+
var import_react_query8 = require("@tanstack/react-query");
|
|
56608
|
+
var import_react112 = require("react");
|
|
56446
56609
|
function useTasks() {
|
|
56447
56610
|
const ctx = useTasksContext();
|
|
56448
|
-
const [isLoading, setIsLoading] = (0,
|
|
56449
|
-
const [error2, setError] = (0,
|
|
56450
|
-
const isAvailable = (0,
|
|
56611
|
+
const [isLoading, setIsLoading] = (0, import_react112.useState)(false);
|
|
56612
|
+
const [error2, setError] = (0, import_react112.useState)(null);
|
|
56613
|
+
const isAvailable = (0, import_react112.useCallback)(async () => {
|
|
56451
56614
|
try {
|
|
56452
56615
|
const status = await ctx.checkStatus();
|
|
56453
56616
|
return status.available;
|
|
@@ -56455,7 +56618,7 @@ function useTasks() {
|
|
|
56455
56618
|
return false;
|
|
56456
56619
|
}
|
|
56457
56620
|
}, [ctx]);
|
|
56458
|
-
const schedule = (0,
|
|
56621
|
+
const schedule = (0, import_react112.useCallback)(
|
|
56459
56622
|
async (options) => {
|
|
56460
56623
|
setIsLoading(true);
|
|
56461
56624
|
setError(null);
|
|
@@ -56471,7 +56634,7 @@ function useTasks() {
|
|
|
56471
56634
|
},
|
|
56472
56635
|
[ctx]
|
|
56473
56636
|
);
|
|
56474
|
-
const createCron = (0,
|
|
56637
|
+
const createCron = (0, import_react112.useCallback)(
|
|
56475
56638
|
async (options) => {
|
|
56476
56639
|
setIsLoading(true);
|
|
56477
56640
|
setError(null);
|
|
@@ -56487,7 +56650,7 @@ function useTasks() {
|
|
|
56487
56650
|
},
|
|
56488
56651
|
[ctx]
|
|
56489
56652
|
);
|
|
56490
|
-
const pauseCron = (0,
|
|
56653
|
+
const pauseCron = (0, import_react112.useCallback)(
|
|
56491
56654
|
async (scheduleId) => {
|
|
56492
56655
|
setIsLoading(true);
|
|
56493
56656
|
setError(null);
|
|
@@ -56503,7 +56666,7 @@ function useTasks() {
|
|
|
56503
56666
|
},
|
|
56504
56667
|
[ctx]
|
|
56505
56668
|
);
|
|
56506
|
-
const resumeCron = (0,
|
|
56669
|
+
const resumeCron = (0, import_react112.useCallback)(
|
|
56507
56670
|
async (scheduleId) => {
|
|
56508
56671
|
setIsLoading(true);
|
|
56509
56672
|
setError(null);
|
|
@@ -56519,7 +56682,7 @@ function useTasks() {
|
|
|
56519
56682
|
},
|
|
56520
56683
|
[ctx]
|
|
56521
56684
|
);
|
|
56522
|
-
const deleteCron = (0,
|
|
56685
|
+
const deleteCron = (0, import_react112.useCallback)(
|
|
56523
56686
|
async (scheduleId) => {
|
|
56524
56687
|
setIsLoading(true);
|
|
56525
56688
|
setError(null);
|
|
@@ -56535,7 +56698,7 @@ function useTasks() {
|
|
|
56535
56698
|
},
|
|
56536
56699
|
[ctx]
|
|
56537
56700
|
);
|
|
56538
|
-
const getJob = (0,
|
|
56701
|
+
const getJob = (0, import_react112.useCallback)(
|
|
56539
56702
|
async (jobId) => {
|
|
56540
56703
|
try {
|
|
56541
56704
|
return await ctx.getJob(jobId);
|
|
@@ -56547,7 +56710,7 @@ function useTasks() {
|
|
|
56547
56710
|
},
|
|
56548
56711
|
[ctx]
|
|
56549
56712
|
);
|
|
56550
|
-
const listJobs = (0,
|
|
56713
|
+
const listJobs = (0, import_react112.useCallback)(
|
|
56551
56714
|
async (options = {}) => {
|
|
56552
56715
|
try {
|
|
56553
56716
|
const result = await ctx.listJobs(options);
|
|
@@ -56560,7 +56723,7 @@ function useTasks() {
|
|
|
56560
56723
|
},
|
|
56561
56724
|
[ctx]
|
|
56562
56725
|
);
|
|
56563
|
-
const cancelJob = (0,
|
|
56726
|
+
const cancelJob = (0, import_react112.useCallback)(
|
|
56564
56727
|
async (jobId) => {
|
|
56565
56728
|
setIsLoading(true);
|
|
56566
56729
|
setError(null);
|
|
@@ -56592,20 +56755,20 @@ function useTasks() {
|
|
|
56592
56755
|
}
|
|
56593
56756
|
|
|
56594
56757
|
// src/react/webhooks-hooks.ts
|
|
56595
|
-
var
|
|
56596
|
-
var
|
|
56758
|
+
var import_react_query9 = require("@tanstack/react-query");
|
|
56759
|
+
var import_react113 = require("react");
|
|
56597
56760
|
init_constants();
|
|
56598
56761
|
function useWebhooks() {
|
|
56599
56762
|
const ctx = useWebhooksContext();
|
|
56600
|
-
const queryClient = (0,
|
|
56601
|
-
const configQuery = (0,
|
|
56763
|
+
const queryClient = (0, import_react_query9.useQueryClient)();
|
|
56764
|
+
const configQuery = (0, import_react_query9.useQuery)({
|
|
56602
56765
|
queryKey: ["sylphx", "webhooks", "config"],
|
|
56603
56766
|
queryFn: () => ctx.getConfig(),
|
|
56604
56767
|
staleTime: STALE_TIME_STABLE_MS
|
|
56605
56768
|
// 5 min - config rarely changes
|
|
56606
56769
|
});
|
|
56607
56770
|
const config2 = configQuery.data;
|
|
56608
|
-
const updateConfig = (0,
|
|
56771
|
+
const updateConfig = (0, import_react113.useCallback)(
|
|
56609
56772
|
async (options) => {
|
|
56610
56773
|
const result = await ctx.updateConfig(options);
|
|
56611
56774
|
await queryClient.invalidateQueries({
|
|
@@ -56615,7 +56778,7 @@ function useWebhooks() {
|
|
|
56615
56778
|
},
|
|
56616
56779
|
[ctx, queryClient]
|
|
56617
56780
|
);
|
|
56618
|
-
const refresh = (0,
|
|
56781
|
+
const refresh = (0, import_react113.useCallback)(async () => {
|
|
56619
56782
|
await queryClient.invalidateQueries({
|
|
56620
56783
|
queryKey: ["sylphx", "webhooks", "config"]
|
|
56621
56784
|
});
|
|
@@ -56632,8 +56795,8 @@ function useWebhooks() {
|
|
|
56632
56795
|
function useWebhookDeliveries(options = {}) {
|
|
56633
56796
|
const { status, event: event2, limit = 50, skip = false, refetchInterval } = options;
|
|
56634
56797
|
const ctx = useWebhooksContext();
|
|
56635
|
-
const queryClient = (0,
|
|
56636
|
-
const deliveriesQuery = (0,
|
|
56798
|
+
const queryClient = (0, import_react_query9.useQueryClient)();
|
|
56799
|
+
const deliveriesQuery = (0, import_react_query9.useInfiniteQuery)({
|
|
56637
56800
|
queryKey: ["sylphx", "webhooks", "deliveries", { status, event: event2, limit }],
|
|
56638
56801
|
queryFn: async ({ pageParam = 0 }) => {
|
|
56639
56802
|
return ctx.getDeliveries({ status, event: event2, limit, offset: pageParam });
|
|
@@ -56653,7 +56816,7 @@ function useWebhookDeliveries(options = {}) {
|
|
|
56653
56816
|
});
|
|
56654
56817
|
const deliveries = deliveriesQuery.data?.pages.flatMap((page) => page.deliveries) ?? [];
|
|
56655
56818
|
const total = deliveriesQuery.data?.pages[0]?.total ?? 0;
|
|
56656
|
-
const replay = (0,
|
|
56819
|
+
const replay = (0, import_react113.useCallback)(
|
|
56657
56820
|
async (deliveryId) => {
|
|
56658
56821
|
const result = await ctx.replayDelivery(deliveryId);
|
|
56659
56822
|
await queryClient.invalidateQueries({
|
|
@@ -56663,12 +56826,12 @@ function useWebhookDeliveries(options = {}) {
|
|
|
56663
56826
|
},
|
|
56664
56827
|
[ctx, queryClient]
|
|
56665
56828
|
);
|
|
56666
|
-
const refresh = (0,
|
|
56829
|
+
const refresh = (0, import_react113.useCallback)(async () => {
|
|
56667
56830
|
await queryClient.invalidateQueries({
|
|
56668
56831
|
queryKey: ["sylphx", "webhooks", "deliveries"]
|
|
56669
56832
|
});
|
|
56670
56833
|
}, [queryClient]);
|
|
56671
|
-
const loadMore = (0,
|
|
56834
|
+
const loadMore = (0, import_react113.useCallback)(async () => {
|
|
56672
56835
|
if (deliveriesQuery.hasNextPage && !deliveriesQuery.isFetchingNextPage) {
|
|
56673
56836
|
await deliveriesQuery.fetchNextPage();
|
|
56674
56837
|
}
|
|
@@ -56687,14 +56850,14 @@ function useWebhookDeliveries(options = {}) {
|
|
|
56687
56850
|
}
|
|
56688
56851
|
function useWebhookStats(period = "week") {
|
|
56689
56852
|
const ctx = useWebhooksContext();
|
|
56690
|
-
const queryClient = (0,
|
|
56691
|
-
const statsQuery = (0,
|
|
56853
|
+
const queryClient = (0, import_react_query9.useQueryClient)();
|
|
56854
|
+
const statsQuery = (0, import_react_query9.useQuery)({
|
|
56692
56855
|
queryKey: ["sylphx", "webhooks", "stats", period],
|
|
56693
56856
|
queryFn: () => ctx.getStats(period),
|
|
56694
56857
|
staleTime: STALE_TIME_MODERATE_MS
|
|
56695
56858
|
// 2 min - stats aggregate data
|
|
56696
56859
|
});
|
|
56697
|
-
const refresh = (0,
|
|
56860
|
+
const refresh = (0, import_react113.useCallback)(async () => {
|
|
56698
56861
|
await queryClient.invalidateQueries({
|
|
56699
56862
|
queryKey: ["sylphx", "webhooks", "stats", period]
|
|
56700
56863
|
});
|
|
@@ -56708,7 +56871,7 @@ function useWebhookStats(period = "week") {
|
|
|
56708
56871
|
}
|
|
56709
56872
|
|
|
56710
56873
|
// src/react/ui/account-section.tsx
|
|
56711
|
-
var
|
|
56874
|
+
var import_react114 = require("react");
|
|
56712
56875
|
init_constants();
|
|
56713
56876
|
var import_jsx_runtime130 = require("react/jsx-runtime");
|
|
56714
56877
|
function AccountSection(props) {
|
|
@@ -56729,26 +56892,26 @@ function AccountSectionInner({
|
|
|
56729
56892
|
const userContext = useUserContext();
|
|
56730
56893
|
const securityContext = useSecurityContext();
|
|
56731
56894
|
const styles2 = baseStyles(theme);
|
|
56732
|
-
const [error2, setError] = (0,
|
|
56733
|
-
const [success, setSuccess] = (0,
|
|
56734
|
-
const [showEmailChangeForm, setShowEmailChangeForm] = (0,
|
|
56735
|
-
const [newEmail, setNewEmail] = (0,
|
|
56736
|
-
const [emailPassword, setEmailPassword] = (0,
|
|
56737
|
-
const [isChangingEmail, setIsChangingEmail] = (0,
|
|
56738
|
-
const [isExporting, setIsExporting] = (0,
|
|
56739
|
-
const [exportUrl, setExportUrl] = (0,
|
|
56740
|
-
const [showDeleteConfirm, setShowDeleteConfirm] = (0,
|
|
56741
|
-
const [deleteConfirmText, setDeleteConfirmText] = (0,
|
|
56742
|
-
const [deletePassword, setDeletePassword] = (0,
|
|
56743
|
-
const [delete2FACode, setDelete2FACode] = (0,
|
|
56744
|
-
const [isDeleting, setIsDeleting] = (0,
|
|
56745
|
-
const [deleteStep, setDeleteStep] = (0,
|
|
56746
|
-
const [has2FAEnabled, setHas2FAEnabled] = (0,
|
|
56747
|
-
const [isChecking2FA, setIsChecking2FA] = (0,
|
|
56748
|
-
(0,
|
|
56895
|
+
const [error2, setError] = (0, import_react114.useState)(null);
|
|
56896
|
+
const [success, setSuccess] = (0, import_react114.useState)(null);
|
|
56897
|
+
const [showEmailChangeForm, setShowEmailChangeForm] = (0, import_react114.useState)(false);
|
|
56898
|
+
const [newEmail, setNewEmail] = (0, import_react114.useState)("");
|
|
56899
|
+
const [emailPassword, setEmailPassword] = (0, import_react114.useState)("");
|
|
56900
|
+
const [isChangingEmail, setIsChangingEmail] = (0, import_react114.useState)(false);
|
|
56901
|
+
const [isExporting, setIsExporting] = (0, import_react114.useState)(false);
|
|
56902
|
+
const [exportUrl, setExportUrl] = (0, import_react114.useState)(null);
|
|
56903
|
+
const [showDeleteConfirm, setShowDeleteConfirm] = (0, import_react114.useState)(false);
|
|
56904
|
+
const [deleteConfirmText, setDeleteConfirmText] = (0, import_react114.useState)("");
|
|
56905
|
+
const [deletePassword, setDeletePassword] = (0, import_react114.useState)("");
|
|
56906
|
+
const [delete2FACode, setDelete2FACode] = (0, import_react114.useState)("");
|
|
56907
|
+
const [isDeleting, setIsDeleting] = (0, import_react114.useState)(false);
|
|
56908
|
+
const [deleteStep, setDeleteStep] = (0, import_react114.useState)("confirm");
|
|
56909
|
+
const [has2FAEnabled, setHas2FAEnabled] = (0, import_react114.useState)(false);
|
|
56910
|
+
const [isChecking2FA, setIsChecking2FA] = (0, import_react114.useState)(false);
|
|
56911
|
+
(0, import_react114.useEffect)(() => {
|
|
56749
56912
|
injectGlobalStyles();
|
|
56750
56913
|
}, []);
|
|
56751
|
-
(0,
|
|
56914
|
+
(0, import_react114.useEffect)(() => {
|
|
56752
56915
|
if (success || error2) {
|
|
56753
56916
|
const timer = setTimeout(() => {
|
|
56754
56917
|
setSuccess(null);
|
|
@@ -56798,7 +56961,7 @@ function AccountSectionInner({
|
|
|
56798
56961
|
setIsExporting(false);
|
|
56799
56962
|
}
|
|
56800
56963
|
};
|
|
56801
|
-
const checkSecurityStatus = (0,
|
|
56964
|
+
const checkSecurityStatus = (0, import_react114.useCallback)(async () => {
|
|
56802
56965
|
setIsChecking2FA(true);
|
|
56803
56966
|
try {
|
|
56804
56967
|
const status = await securityContext.getTwoFactorStatus();
|
|
@@ -57326,7 +57489,7 @@ function ShieldIcon({ size: size4 = 24, color: color2 = "currentColor" }) {
|
|
|
57326
57489
|
}
|
|
57327
57490
|
|
|
57328
57491
|
// src/react/ui/analytics-dashboard.tsx
|
|
57329
|
-
var
|
|
57492
|
+
var import_react115 = require("react");
|
|
57330
57493
|
var import_jsx_runtime131 = require("react/jsx-runtime");
|
|
57331
57494
|
function EventViewer({
|
|
57332
57495
|
theme = defaultTheme,
|
|
@@ -57340,10 +57503,10 @@ function EventViewer({
|
|
|
57340
57503
|
emptyMessage = "No events recorded yet",
|
|
57341
57504
|
title = "Recent Events"
|
|
57342
57505
|
}) {
|
|
57343
|
-
const [search2, setSearch] = (0,
|
|
57344
|
-
const [expandedId, setExpandedId] = (0,
|
|
57506
|
+
const [search2, setSearch] = (0, import_react115.useState)("");
|
|
57507
|
+
const [expandedId, setExpandedId] = (0, import_react115.useState)(null);
|
|
57345
57508
|
const styles2 = baseStyles(theme);
|
|
57346
|
-
(0,
|
|
57509
|
+
(0, import_react115.useEffect)(() => {
|
|
57347
57510
|
injectGlobalStyles();
|
|
57348
57511
|
}, []);
|
|
57349
57512
|
const filteredEvents = events.filter((e2) => !search2 || e2.name.toLowerCase().includes(search2.toLowerCase())).slice(0, maxEvents);
|
|
@@ -57517,7 +57680,7 @@ function StatsCard({
|
|
|
57517
57680
|
isLoading = false
|
|
57518
57681
|
}) {
|
|
57519
57682
|
const styles2 = baseStyles(theme);
|
|
57520
|
-
(0,
|
|
57683
|
+
(0, import_react115.useEffect)(() => {
|
|
57521
57684
|
injectGlobalStyles();
|
|
57522
57685
|
}, []);
|
|
57523
57686
|
const containerStyle = {
|
|
@@ -57658,7 +57821,7 @@ function SimpleChart({
|
|
|
57658
57821
|
isLoading = false
|
|
57659
57822
|
}) {
|
|
57660
57823
|
const styles2 = baseStyles(theme);
|
|
57661
|
-
(0,
|
|
57824
|
+
(0, import_react115.useEffect)(() => {
|
|
57662
57825
|
injectGlobalStyles();
|
|
57663
57826
|
}, []);
|
|
57664
57827
|
const maxValue = Math.max(...data.map((d2) => d2.value), 1);
|
|
@@ -57959,7 +58122,7 @@ function ChartIcon({ color: color2 }) {
|
|
|
57959
58122
|
}
|
|
57960
58123
|
|
|
57961
58124
|
// src/react/ui/api-key-manager.tsx
|
|
57962
|
-
var
|
|
58125
|
+
var import_react116 = require("react");
|
|
57963
58126
|
init_constants();
|
|
57964
58127
|
var import_jsx_runtime132 = require("react/jsx-runtime");
|
|
57965
58128
|
var DEFAULT_SCOPES = [
|
|
@@ -57982,20 +58145,20 @@ function APIKeyManager({
|
|
|
57982
58145
|
emptyMessage = "No API keys created",
|
|
57983
58146
|
showEnvironment = true
|
|
57984
58147
|
}) {
|
|
57985
|
-
const [showCreate, setShowCreate] = (0,
|
|
57986
|
-
const [name, setName] = (0,
|
|
57987
|
-
const [selectedScopes, setSelectedScopes] = (0,
|
|
57988
|
-
const [expiresIn, setExpiresIn] = (0,
|
|
57989
|
-
const [isCreating, setIsCreating] = (0,
|
|
57990
|
-
const [error2, setError] = (0,
|
|
57991
|
-
const [newKey, setNewKey] = (0,
|
|
57992
|
-
const [revokingId, setRevokingId] = (0,
|
|
57993
|
-
const [copied, setCopied] = (0,
|
|
58148
|
+
const [showCreate, setShowCreate] = (0, import_react116.useState)(false);
|
|
58149
|
+
const [name, setName] = (0, import_react116.useState)("");
|
|
58150
|
+
const [selectedScopes, setSelectedScopes] = (0, import_react116.useState)([]);
|
|
58151
|
+
const [expiresIn, setExpiresIn] = (0, import_react116.useState)(void 0);
|
|
58152
|
+
const [isCreating, setIsCreating] = (0, import_react116.useState)(false);
|
|
58153
|
+
const [error2, setError] = (0, import_react116.useState)(null);
|
|
58154
|
+
const [newKey, setNewKey] = (0, import_react116.useState)(null);
|
|
58155
|
+
const [revokingId, setRevokingId] = (0, import_react116.useState)(null);
|
|
58156
|
+
const [copied, setCopied] = (0, import_react116.useState)(false);
|
|
57994
58157
|
const styles2 = baseStyles(theme);
|
|
57995
|
-
(0,
|
|
58158
|
+
(0, import_react116.useEffect)(() => {
|
|
57996
58159
|
injectGlobalStyles();
|
|
57997
58160
|
}, []);
|
|
57998
|
-
(0,
|
|
58161
|
+
(0, import_react116.useEffect)(() => {
|
|
57999
58162
|
if (copied) {
|
|
58000
58163
|
const timer = setTimeout(() => setCopied(false), UI_COPY_FEEDBACK_MS);
|
|
58001
58164
|
return () => clearTimeout(timer);
|
|
@@ -58566,7 +58729,7 @@ function CheckIcon10({ color: color2 }) {
|
|
|
58566
58729
|
}
|
|
58567
58730
|
|
|
58568
58731
|
// src/react/ui/billing-management.tsx
|
|
58569
|
-
var
|
|
58732
|
+
var import_react117 = require("react");
|
|
58570
58733
|
var import_jsx_runtime133 = require("react/jsx-runtime");
|
|
58571
58734
|
function InvoiceHistory({
|
|
58572
58735
|
theme = defaultTheme,
|
|
@@ -58578,10 +58741,10 @@ function InvoiceHistory({
|
|
|
58578
58741
|
pageSize = 10,
|
|
58579
58742
|
emptyMessage = "No invoices yet"
|
|
58580
58743
|
}) {
|
|
58581
|
-
const [invoices] = (0,
|
|
58582
|
-
const [currentPage, setCurrentPage] = (0,
|
|
58744
|
+
const [invoices] = (0, import_react117.useState)(propInvoices ?? []);
|
|
58745
|
+
const [currentPage, setCurrentPage] = (0, import_react117.useState)(1);
|
|
58583
58746
|
const styles2 = baseStyles(theme);
|
|
58584
|
-
(0,
|
|
58747
|
+
(0, import_react117.useEffect)(() => {
|
|
58585
58748
|
injectGlobalStyles();
|
|
58586
58749
|
}, []);
|
|
58587
58750
|
const totalPages = Math.ceil(invoices.length / pageSize);
|
|
@@ -58801,7 +58964,7 @@ function PaymentMethodManager({
|
|
|
58801
58964
|
isAddingPaymentMethod = false
|
|
58802
58965
|
}) {
|
|
58803
58966
|
const styles2 = baseStyles(theme);
|
|
58804
|
-
(0,
|
|
58967
|
+
(0, import_react117.useEffect)(() => {
|
|
58805
58968
|
injectGlobalStyles();
|
|
58806
58969
|
}, []);
|
|
58807
58970
|
const getBrandIcon = (brand) => {
|
|
@@ -58980,7 +59143,7 @@ function UsageOverview({
|
|
|
58980
59143
|
currency = "USD"
|
|
58981
59144
|
}) {
|
|
58982
59145
|
const _styles = baseStyles(theme);
|
|
58983
|
-
(0,
|
|
59146
|
+
(0, import_react117.useEffect)(() => {
|
|
58984
59147
|
injectGlobalStyles();
|
|
58985
59148
|
}, []);
|
|
58986
59149
|
const formatCurrency = (amount) => {
|
|
@@ -59194,7 +59357,7 @@ function PlusIcon4({ color: color2 }) {
|
|
|
59194
59357
|
}
|
|
59195
59358
|
|
|
59196
59359
|
// src/react/ui/billing-section.tsx
|
|
59197
|
-
var
|
|
59360
|
+
var import_react118 = require("react");
|
|
59198
59361
|
init_constants();
|
|
59199
59362
|
var import_jsx_runtime134 = require("react/jsx-runtime");
|
|
59200
59363
|
function BillingSection(props) {
|
|
@@ -59222,14 +59385,14 @@ function BillingSectionInner({
|
|
|
59222
59385
|
refresh: _refresh
|
|
59223
59386
|
} = useBilling();
|
|
59224
59387
|
const styles2 = baseStyles(theme);
|
|
59225
|
-
const [selectedInterval, setSelectedInterval] = (0,
|
|
59226
|
-
const [processingPlan, setProcessingPlan] = (0,
|
|
59227
|
-
const [error2, setError] = (0,
|
|
59228
|
-
const [success, setSuccess] = (0,
|
|
59229
|
-
(0,
|
|
59388
|
+
const [selectedInterval, setSelectedInterval] = (0, import_react118.useState)("monthly");
|
|
59389
|
+
const [processingPlan, setProcessingPlan] = (0, import_react118.useState)(null);
|
|
59390
|
+
const [error2, setError] = (0, import_react118.useState)(null);
|
|
59391
|
+
const [success, setSuccess] = (0, import_react118.useState)(null);
|
|
59392
|
+
(0, import_react118.useEffect)(() => {
|
|
59230
59393
|
injectGlobalStyles();
|
|
59231
59394
|
}, []);
|
|
59232
|
-
(0,
|
|
59395
|
+
(0, import_react118.useEffect)(() => {
|
|
59233
59396
|
if (success || error2) {
|
|
59234
59397
|
const timer = setTimeout(() => {
|
|
59235
59398
|
setSuccess(null);
|
|
@@ -59610,7 +59773,7 @@ function CheckIcon11({ color: color2 }) {
|
|
|
59610
59773
|
}
|
|
59611
59774
|
|
|
59612
59775
|
// src/react/ui/chat-interface.tsx
|
|
59613
|
-
var
|
|
59776
|
+
var import_react119 = require("react");
|
|
59614
59777
|
var import_jsx_runtime135 = require("react/jsx-runtime");
|
|
59615
59778
|
function ChatInterface({
|
|
59616
59779
|
theme = defaultTheme,
|
|
@@ -59634,19 +59797,19 @@ function ChatInterface({
|
|
|
59634
59797
|
...chatOptions
|
|
59635
59798
|
}) {
|
|
59636
59799
|
const { messages, send: send2, isLoading, error: error2, clear, retry } = useChat(chatOptions);
|
|
59637
|
-
const [input, setInput] = (0,
|
|
59638
|
-
const messagesEndRef = (0,
|
|
59639
|
-
const inputRef = (0,
|
|
59800
|
+
const [input, setInput] = (0, import_react119.useState)("");
|
|
59801
|
+
const messagesEndRef = (0, import_react119.useRef)(null);
|
|
59802
|
+
const inputRef = (0, import_react119.useRef)(null);
|
|
59640
59803
|
const styles2 = baseStyles(theme);
|
|
59641
|
-
(0,
|
|
59804
|
+
(0, import_react119.useEffect)(() => {
|
|
59642
59805
|
injectGlobalStyles();
|
|
59643
59806
|
}, []);
|
|
59644
|
-
(0,
|
|
59807
|
+
(0, import_react119.useEffect)(() => {
|
|
59645
59808
|
if (autoScroll && messagesEndRef.current) {
|
|
59646
59809
|
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
|
|
59647
59810
|
}
|
|
59648
59811
|
}, [autoScroll]);
|
|
59649
|
-
(0,
|
|
59812
|
+
(0, import_react119.useEffect)(() => {
|
|
59650
59813
|
if (inputRef.current) {
|
|
59651
59814
|
inputRef.current.style.height = "auto";
|
|
59652
59815
|
inputRef.current.style.height = `${Math.min(inputRef.current.scrollHeight, 150)}px`;
|
|
@@ -60012,8 +60175,8 @@ function ChatInput({
|
|
|
60012
60175
|
onSubmit,
|
|
60013
60176
|
isLoading = false
|
|
60014
60177
|
}) {
|
|
60015
|
-
const [input, setInput] = (0,
|
|
60016
|
-
const inputRef = (0,
|
|
60178
|
+
const [input, setInput] = (0, import_react119.useState)("");
|
|
60179
|
+
const inputRef = (0, import_react119.useRef)(null);
|
|
60017
60180
|
const handleSubmit = (e2) => {
|
|
60018
60181
|
e2?.preventDefault();
|
|
60019
60182
|
if (!input.trim() || disabled2 || isLoading) return;
|
|
@@ -60110,7 +60273,7 @@ function SendIcon2({ color: color2 }) {
|
|
|
60110
60273
|
}
|
|
60111
60274
|
|
|
60112
60275
|
// src/react/ui/consent-preferences.tsx
|
|
60113
|
-
var
|
|
60276
|
+
var import_react120 = require("react");
|
|
60114
60277
|
init_constants();
|
|
60115
60278
|
var import_jsx_runtime136 = require("react/jsx-runtime");
|
|
60116
60279
|
var CATEGORY_INFO = {
|
|
@@ -60164,13 +60327,13 @@ function ConsentPreferences({
|
|
|
60164
60327
|
isLoading,
|
|
60165
60328
|
hasConsented
|
|
60166
60329
|
} = useConsent();
|
|
60167
|
-
const [isSaving, setIsSaving] = (0,
|
|
60168
|
-
const [saveSuccess, setSaveSuccess] = (0,
|
|
60330
|
+
const [isSaving, setIsSaving] = (0, import_react120.useState)(false);
|
|
60331
|
+
const [saveSuccess, setSaveSuccess] = (0, import_react120.useState)(false);
|
|
60169
60332
|
const styles2 = baseStyles(theme);
|
|
60170
|
-
(0,
|
|
60333
|
+
(0, import_react120.useEffect)(() => {
|
|
60171
60334
|
injectGlobalStyles();
|
|
60172
60335
|
}, []);
|
|
60173
|
-
(0,
|
|
60336
|
+
(0, import_react120.useEffect)(() => {
|
|
60174
60337
|
if (saveSuccess) {
|
|
60175
60338
|
const timer = setTimeout(() => setSaveSuccess(false), UI_FORM_SUCCESS_MS);
|
|
60176
60339
|
return () => clearTimeout(timer);
|
|
@@ -60592,7 +60755,7 @@ function CheckIcon12({ color: color2 }) {
|
|
|
60592
60755
|
}
|
|
60593
60756
|
|
|
60594
60757
|
// src/react/ui/cookie-banner.tsx
|
|
60595
|
-
var
|
|
60758
|
+
var import_react121 = require("react");
|
|
60596
60759
|
init_constants();
|
|
60597
60760
|
var import_jsx_runtime137 = require("react/jsx-runtime");
|
|
60598
60761
|
function CookieBanner({
|
|
@@ -60621,13 +60784,13 @@ function CookieBanner({
|
|
|
60621
60784
|
closeBanner,
|
|
60622
60785
|
isLoading
|
|
60623
60786
|
} = useConsent();
|
|
60624
|
-
const [showCustomize, setShowCustomize] = (0,
|
|
60625
|
-
const [isVisible, setIsVisible] = (0,
|
|
60787
|
+
const [showCustomize, setShowCustomize] = (0, import_react121.useState)(false);
|
|
60788
|
+
const [isVisible, setIsVisible] = (0, import_react121.useState)(false);
|
|
60626
60789
|
const styles2 = baseStyles(theme);
|
|
60627
|
-
(0,
|
|
60790
|
+
(0, import_react121.useEffect)(() => {
|
|
60628
60791
|
injectGlobalStyles();
|
|
60629
60792
|
}, []);
|
|
60630
|
-
(0,
|
|
60793
|
+
(0, import_react121.useEffect)(() => {
|
|
60631
60794
|
if (showBanner || forceShow) {
|
|
60632
60795
|
const timer = setTimeout(() => setIsVisible(true), 50);
|
|
60633
60796
|
return () => clearTimeout(timer);
|
|
@@ -60989,10 +61152,10 @@ function CloseIcon2() {
|
|
|
60989
61152
|
}
|
|
60990
61153
|
|
|
60991
61154
|
// src/react/ui/error-boundary.tsx
|
|
60992
|
-
var
|
|
61155
|
+
var import_react122 = require("react");
|
|
60993
61156
|
init_constants();
|
|
60994
61157
|
var import_jsx_runtime138 = require("react/jsx-runtime");
|
|
60995
|
-
var SylphxErrorBoundary = class extends
|
|
61158
|
+
var SylphxErrorBoundary = class extends import_react122.Component {
|
|
60996
61159
|
constructor(props) {
|
|
60997
61160
|
super(props);
|
|
60998
61161
|
this.state = {
|
|
@@ -61077,7 +61240,7 @@ function DefaultErrorFallback({
|
|
|
61077
61240
|
showDetails = process.env.NODE_ENV === "development"
|
|
61078
61241
|
}) {
|
|
61079
61242
|
const styles2 = baseStyles(theme);
|
|
61080
|
-
(0,
|
|
61243
|
+
(0, import_react122.useEffect)(() => {
|
|
61081
61244
|
injectGlobalStyles();
|
|
61082
61245
|
}, []);
|
|
61083
61246
|
const containerStyle = mergeStyles(styles2.container, {
|
|
@@ -61223,15 +61386,15 @@ function FeedbackWidget({
|
|
|
61223
61386
|
position = "bottom-right",
|
|
61224
61387
|
defaultOpen = false
|
|
61225
61388
|
}) {
|
|
61226
|
-
const [isOpen, setIsOpen] = (0,
|
|
61227
|
-
const [message, setMessage] = (0,
|
|
61228
|
-
const [email, setEmail] = (0,
|
|
61229
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
61230
|
-
const [isSuccess, setIsSuccess] = (0,
|
|
61231
|
-
const [error2, setError] = (0,
|
|
61389
|
+
const [isOpen, setIsOpen] = (0, import_react122.useState)(defaultOpen);
|
|
61390
|
+
const [message, setMessage] = (0, import_react122.useState)("");
|
|
61391
|
+
const [email, setEmail] = (0, import_react122.useState)("");
|
|
61392
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react122.useState)(false);
|
|
61393
|
+
const [isSuccess, setIsSuccess] = (0, import_react122.useState)(false);
|
|
61394
|
+
const [error2, setError] = (0, import_react122.useState)(null);
|
|
61232
61395
|
const { captureMessage } = useErrorTracking();
|
|
61233
61396
|
const styles2 = baseStyles(theme);
|
|
61234
|
-
(0,
|
|
61397
|
+
(0, import_react122.useEffect)(() => {
|
|
61235
61398
|
injectGlobalStyles();
|
|
61236
61399
|
}, []);
|
|
61237
61400
|
const handleSubmit = async (e2) => {
|
|
@@ -61437,7 +61600,7 @@ function CheckCircleIcon({ color: color2 }) {
|
|
|
61437
61600
|
}
|
|
61438
61601
|
|
|
61439
61602
|
// src/react/ui/feature-gate.tsx
|
|
61440
|
-
var
|
|
61603
|
+
var import_react123 = require("react");
|
|
61441
61604
|
init_constants();
|
|
61442
61605
|
var import_jsx_runtime139 = require("react/jsx-runtime");
|
|
61443
61606
|
function FeatureGate({
|
|
@@ -61506,8 +61669,8 @@ function FlagDevTools({
|
|
|
61506
61669
|
defaultCollapsed = true,
|
|
61507
61670
|
className
|
|
61508
61671
|
}) {
|
|
61509
|
-
const [isCollapsed, setIsCollapsed] = (0,
|
|
61510
|
-
const context = (0,
|
|
61672
|
+
const [isCollapsed, setIsCollapsed] = (0, import_react123.useState)(defaultCollapsed);
|
|
61673
|
+
const context = (0, import_react123.useContext)(FeatureFlagContext);
|
|
61511
61674
|
const styles2 = baseStyles(theme);
|
|
61512
61675
|
if (!context) {
|
|
61513
61676
|
return null;
|
|
@@ -61736,7 +61899,7 @@ function CloseIcon4() {
|
|
|
61736
61899
|
}
|
|
61737
61900
|
|
|
61738
61901
|
// src/react/ui/file-upload.tsx
|
|
61739
|
-
var
|
|
61902
|
+
var import_react124 = require("react");
|
|
61740
61903
|
init_constants();
|
|
61741
61904
|
var import_jsx_runtime140 = require("react/jsx-runtime");
|
|
61742
61905
|
function FileUpload(props) {
|
|
@@ -61754,19 +61917,19 @@ function FileUploadInner({
|
|
|
61754
61917
|
placeholder = "Drop files here or click to upload",
|
|
61755
61918
|
showFileList = true
|
|
61756
61919
|
}) {
|
|
61757
|
-
const [isDragging2, setIsDragging] = (0,
|
|
61758
|
-
const [uploadedFiles, setUploadedFiles] = (0,
|
|
61759
|
-
const inputRef = (0,
|
|
61920
|
+
const [isDragging2, setIsDragging] = (0, import_react124.useState)(false);
|
|
61921
|
+
const [uploadedFiles, setUploadedFiles] = (0, import_react124.useState)([]);
|
|
61922
|
+
const inputRef = (0, import_react124.useRef)(null);
|
|
61760
61923
|
const { upload, isUploading, progress: progress2, error: error2 } = useFileUpload({
|
|
61761
61924
|
accept,
|
|
61762
61925
|
maxSize,
|
|
61763
61926
|
onError
|
|
61764
61927
|
});
|
|
61765
61928
|
const styles2 = baseStyles(theme);
|
|
61766
|
-
(0,
|
|
61929
|
+
(0, import_react124.useEffect)(() => {
|
|
61767
61930
|
injectGlobalStyles();
|
|
61768
61931
|
}, []);
|
|
61769
|
-
const handleFiles = (0,
|
|
61932
|
+
const handleFiles = (0, import_react124.useCallback)(
|
|
61770
61933
|
async (files) => {
|
|
61771
61934
|
if (!files || files.length === 0) return;
|
|
61772
61935
|
const fileArray = Array.from(files);
|
|
@@ -61785,7 +61948,7 @@ function FileUploadInner({
|
|
|
61785
61948
|
},
|
|
61786
61949
|
[upload, onUpload]
|
|
61787
61950
|
);
|
|
61788
|
-
const handleDrop = (0,
|
|
61951
|
+
const handleDrop = (0, import_react124.useCallback)(
|
|
61789
61952
|
(e2) => {
|
|
61790
61953
|
e2.preventDefault();
|
|
61791
61954
|
e2.stopPropagation();
|
|
@@ -61795,7 +61958,7 @@ function FileUploadInner({
|
|
|
61795
61958
|
},
|
|
61796
61959
|
[handleFiles, disabled2]
|
|
61797
61960
|
);
|
|
61798
|
-
const handleDragOver = (0,
|
|
61961
|
+
const handleDragOver = (0, import_react124.useCallback)(
|
|
61799
61962
|
(e2) => {
|
|
61800
61963
|
e2.preventDefault();
|
|
61801
61964
|
e2.stopPropagation();
|
|
@@ -61803,7 +61966,7 @@ function FileUploadInner({
|
|
|
61803
61966
|
},
|
|
61804
61967
|
[disabled2]
|
|
61805
61968
|
);
|
|
61806
|
-
const handleDragLeave = (0,
|
|
61969
|
+
const handleDragLeave = (0, import_react124.useCallback)((e2) => {
|
|
61807
61970
|
e2.preventDefault();
|
|
61808
61971
|
e2.stopPropagation();
|
|
61809
61972
|
setIsDragging(false);
|
|
@@ -61957,18 +62120,18 @@ function ImageUploaderInner({
|
|
|
61957
62120
|
aspectRatio: aspectRatio2 = "1:1",
|
|
61958
62121
|
placeholder = "Click to upload image"
|
|
61959
62122
|
}) {
|
|
61960
|
-
const [previewUrl, setPreviewUrl] = (0,
|
|
61961
|
-
const inputRef = (0,
|
|
62123
|
+
const [previewUrl, setPreviewUrl] = (0, import_react124.useState)(value || null);
|
|
62124
|
+
const inputRef = (0, import_react124.useRef)(null);
|
|
61962
62125
|
const { upload, isUploading, progress: progress2, error: error2 } = useFileUpload({
|
|
61963
62126
|
accept: ["image/*"],
|
|
61964
62127
|
maxSize,
|
|
61965
62128
|
onError
|
|
61966
62129
|
});
|
|
61967
62130
|
const styles2 = baseStyles(theme);
|
|
61968
|
-
(0,
|
|
62131
|
+
(0, import_react124.useEffect)(() => {
|
|
61969
62132
|
setPreviewUrl(value || null);
|
|
61970
62133
|
}, [value]);
|
|
61971
|
-
(0,
|
|
62134
|
+
(0, import_react124.useEffect)(() => {
|
|
61972
62135
|
injectGlobalStyles();
|
|
61973
62136
|
}, []);
|
|
61974
62137
|
const handleFile = async (file) => {
|
|
@@ -62131,14 +62294,14 @@ function AvatarUploadInner({
|
|
|
62131
62294
|
size: size4 = 96,
|
|
62132
62295
|
placeholder = ""
|
|
62133
62296
|
}) {
|
|
62134
|
-
const [previewUrl, setPreviewUrl] = (0,
|
|
62135
|
-
const inputRef = (0,
|
|
62297
|
+
const [previewUrl, setPreviewUrl] = (0, import_react124.useState)(value || null);
|
|
62298
|
+
const inputRef = (0, import_react124.useRef)(null);
|
|
62136
62299
|
const { uploadAvatar, isUploading, uploadError } = useStorage();
|
|
62137
62300
|
const styles2 = baseStyles(theme);
|
|
62138
|
-
(0,
|
|
62301
|
+
(0, import_react124.useEffect)(() => {
|
|
62139
62302
|
setPreviewUrl(value || null);
|
|
62140
62303
|
}, [value]);
|
|
62141
|
-
(0,
|
|
62304
|
+
(0, import_react124.useEffect)(() => {
|
|
62142
62305
|
injectGlobalStyles();
|
|
62143
62306
|
}, []);
|
|
62144
62307
|
const handleFile = async (file) => {
|
|
@@ -62338,18 +62501,18 @@ function CloseIcon5() {
|
|
|
62338
62501
|
}
|
|
62339
62502
|
|
|
62340
62503
|
// src/react/ui/job-scheduler.tsx
|
|
62341
|
-
var
|
|
62342
|
-
var
|
|
62504
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
62505
|
+
var import_react126 = require("react");
|
|
62343
62506
|
init_constants();
|
|
62344
62507
|
|
|
62345
62508
|
// src/react/job-hooks.ts
|
|
62346
|
-
var
|
|
62347
|
-
var
|
|
62509
|
+
var import_react_query10 = require("@tanstack/react-query");
|
|
62510
|
+
var import_react125 = require("react");
|
|
62348
62511
|
function useJobs() {
|
|
62349
62512
|
const ctx = useJobsContext();
|
|
62350
|
-
const [isLoading, setIsLoading] = (0,
|
|
62351
|
-
const [error2, setError] = (0,
|
|
62352
|
-
const isAvailable = (0,
|
|
62513
|
+
const [isLoading, setIsLoading] = (0, import_react125.useState)(false);
|
|
62514
|
+
const [error2, setError] = (0, import_react125.useState)(null);
|
|
62515
|
+
const isAvailable = (0, import_react125.useCallback)(async () => {
|
|
62353
62516
|
try {
|
|
62354
62517
|
const status = await ctx.checkStatus();
|
|
62355
62518
|
return status.available;
|
|
@@ -62357,7 +62520,7 @@ function useJobs() {
|
|
|
62357
62520
|
return false;
|
|
62358
62521
|
}
|
|
62359
62522
|
}, [ctx]);
|
|
62360
|
-
const schedule = (0,
|
|
62523
|
+
const schedule = (0, import_react125.useCallback)(
|
|
62361
62524
|
async (options) => {
|
|
62362
62525
|
setIsLoading(true);
|
|
62363
62526
|
setError(null);
|
|
@@ -62373,7 +62536,7 @@ function useJobs() {
|
|
|
62373
62536
|
},
|
|
62374
62537
|
[ctx]
|
|
62375
62538
|
);
|
|
62376
|
-
const createCron = (0,
|
|
62539
|
+
const createCron = (0, import_react125.useCallback)(
|
|
62377
62540
|
async (options) => {
|
|
62378
62541
|
setIsLoading(true);
|
|
62379
62542
|
setError(null);
|
|
@@ -62389,7 +62552,7 @@ function useJobs() {
|
|
|
62389
62552
|
},
|
|
62390
62553
|
[ctx]
|
|
62391
62554
|
);
|
|
62392
|
-
const pauseCron = (0,
|
|
62555
|
+
const pauseCron = (0, import_react125.useCallback)(
|
|
62393
62556
|
async (scheduleId) => {
|
|
62394
62557
|
setIsLoading(true);
|
|
62395
62558
|
setError(null);
|
|
@@ -62405,7 +62568,7 @@ function useJobs() {
|
|
|
62405
62568
|
},
|
|
62406
62569
|
[ctx]
|
|
62407
62570
|
);
|
|
62408
|
-
const resumeCron = (0,
|
|
62571
|
+
const resumeCron = (0, import_react125.useCallback)(
|
|
62409
62572
|
async (scheduleId) => {
|
|
62410
62573
|
setIsLoading(true);
|
|
62411
62574
|
setError(null);
|
|
@@ -62421,7 +62584,7 @@ function useJobs() {
|
|
|
62421
62584
|
},
|
|
62422
62585
|
[ctx]
|
|
62423
62586
|
);
|
|
62424
|
-
const deleteCron = (0,
|
|
62587
|
+
const deleteCron = (0, import_react125.useCallback)(
|
|
62425
62588
|
async (scheduleId) => {
|
|
62426
62589
|
setIsLoading(true);
|
|
62427
62590
|
setError(null);
|
|
@@ -62437,7 +62600,7 @@ function useJobs() {
|
|
|
62437
62600
|
},
|
|
62438
62601
|
[ctx]
|
|
62439
62602
|
);
|
|
62440
|
-
const getJob = (0,
|
|
62603
|
+
const getJob = (0, import_react125.useCallback)(
|
|
62441
62604
|
async (jobId) => {
|
|
62442
62605
|
try {
|
|
62443
62606
|
return await ctx.getJob(jobId);
|
|
@@ -62449,7 +62612,7 @@ function useJobs() {
|
|
|
62449
62612
|
},
|
|
62450
62613
|
[ctx]
|
|
62451
62614
|
);
|
|
62452
|
-
const listJobs = (0,
|
|
62615
|
+
const listJobs = (0, import_react125.useCallback)(
|
|
62453
62616
|
async (options = {}) => {
|
|
62454
62617
|
try {
|
|
62455
62618
|
const result = await ctx.listJobs(options);
|
|
@@ -62462,7 +62625,7 @@ function useJobs() {
|
|
|
62462
62625
|
},
|
|
62463
62626
|
[ctx]
|
|
62464
62627
|
);
|
|
62465
|
-
const cancelJob = (0,
|
|
62628
|
+
const cancelJob = (0, import_react125.useCallback)(
|
|
62466
62629
|
async (jobId) => {
|
|
62467
62630
|
setIsLoading(true);
|
|
62468
62631
|
setError(null);
|
|
@@ -62503,19 +62666,19 @@ function JobScheduler({
|
|
|
62503
62666
|
showCronTab = true
|
|
62504
62667
|
}) {
|
|
62505
62668
|
const { schedule, createCron, isLoading, error: error2 } = useJobs();
|
|
62506
|
-
const [activeTab, setActiveTab] = (0,
|
|
62507
|
-
const [name, setName] = (0,
|
|
62508
|
-
const [callbackUrl, setCallbackUrl] = (0,
|
|
62509
|
-
const [payload, setPayload] = (0,
|
|
62510
|
-
const [delay3, setDelay] = (0,
|
|
62511
|
-
const [delayUnit, setDelayUnit] = (0,
|
|
62512
|
-
const [cronExpression, setCronExpression] = (0,
|
|
62513
|
-
const [scheduleSuccess, setScheduleSuccess] = (0,
|
|
62669
|
+
const [activeTab, setActiveTab] = (0, import_react126.useState)("one-time");
|
|
62670
|
+
const [name, setName] = (0, import_react126.useState)("");
|
|
62671
|
+
const [callbackUrl, setCallbackUrl] = (0, import_react126.useState)(defaultCallbackUrl);
|
|
62672
|
+
const [payload, setPayload] = (0, import_react126.useState)("{}");
|
|
62673
|
+
const [delay3, setDelay] = (0, import_react126.useState)(60);
|
|
62674
|
+
const [delayUnit, setDelayUnit] = (0, import_react126.useState)("seconds");
|
|
62675
|
+
const [cronExpression, setCronExpression] = (0, import_react126.useState)("0 9 * * *");
|
|
62676
|
+
const [scheduleSuccess, setScheduleSuccess] = (0, import_react126.useState)(false);
|
|
62514
62677
|
const styles2 = baseStyles(theme);
|
|
62515
|
-
(0,
|
|
62678
|
+
(0, import_react126.useEffect)(() => {
|
|
62516
62679
|
injectGlobalStyles();
|
|
62517
62680
|
}, []);
|
|
62518
|
-
(0,
|
|
62681
|
+
(0, import_react126.useEffect)(() => {
|
|
62519
62682
|
if (scheduleSuccess) {
|
|
62520
62683
|
const timer = setTimeout(() => setScheduleSuccess(false), UI_FORM_SUCCESS_MS);
|
|
62521
62684
|
return () => clearTimeout(timer);
|
|
@@ -62852,13 +63015,13 @@ function JobList({
|
|
|
62852
63015
|
emptyMessage = "No jobs scheduled"
|
|
62853
63016
|
}) {
|
|
62854
63017
|
const ctx = useJobsContext();
|
|
62855
|
-
const queryClient = (0,
|
|
62856
|
-
const [filter2, setFilter] = (0,
|
|
63018
|
+
const queryClient = (0, import_react_query11.useQueryClient)();
|
|
63019
|
+
const [filter2, setFilter] = (0, import_react126.useState)("all");
|
|
62857
63020
|
const styles2 = baseStyles(theme);
|
|
62858
|
-
(0,
|
|
63021
|
+
(0, import_react126.useEffect)(() => {
|
|
62859
63022
|
injectGlobalStyles();
|
|
62860
63023
|
}, []);
|
|
62861
|
-
const jobsQuery = (0,
|
|
63024
|
+
const jobsQuery = (0, import_react_query11.useQuery)({
|
|
62862
63025
|
queryKey: ["sylphx", "jobs", "list", filter2],
|
|
62863
63026
|
queryFn: async () => {
|
|
62864
63027
|
const apiStatus = filter2 === "all" || filter2 === "cancelled" ? void 0 : filter2;
|
|
@@ -62874,13 +63037,13 @@ function JobList({
|
|
|
62874
63037
|
const jobs = propJobs ?? jobsQuery.data ?? [];
|
|
62875
63038
|
const isLoading = !propJobs && jobsQuery.isLoading;
|
|
62876
63039
|
const filteredJobs = filter2 === "all" ? jobs : jobs.filter((j) => j.status === filter2);
|
|
62877
|
-
const cancelMutation = (0,
|
|
63040
|
+
const cancelMutation = (0, import_react_query11.useMutation)({
|
|
62878
63041
|
mutationFn: (jobId) => ctx.cancelJob(jobId),
|
|
62879
63042
|
onSuccess: () => {
|
|
62880
63043
|
queryClient.invalidateQueries({ queryKey: ["sylphx", "jobs", "list"] });
|
|
62881
63044
|
}
|
|
62882
63045
|
});
|
|
62883
|
-
const handleCancel = (0,
|
|
63046
|
+
const handleCancel = (0, import_react126.useCallback)(
|
|
62884
63047
|
async (jobId) => {
|
|
62885
63048
|
if (onCancel) {
|
|
62886
63049
|
onCancel(jobId);
|
|
@@ -63070,11 +63233,11 @@ function CronBuilder({
|
|
|
63070
63233
|
onCreate,
|
|
63071
63234
|
defaultCallbackUrl = ""
|
|
63072
63235
|
}) {
|
|
63073
|
-
const [expression, setExpression] = (0,
|
|
63074
|
-
const [callbackUrl, setCallbackUrl] = (0,
|
|
63075
|
-
const [name, setName] = (0,
|
|
63236
|
+
const [expression, setExpression] = (0, import_react126.useState)("0 9 * * *");
|
|
63237
|
+
const [callbackUrl, setCallbackUrl] = (0, import_react126.useState)(defaultCallbackUrl);
|
|
63238
|
+
const [name, setName] = (0, import_react126.useState)("");
|
|
63076
63239
|
const styles2 = baseStyles(theme);
|
|
63077
|
-
(0,
|
|
63240
|
+
(0, import_react126.useEffect)(() => {
|
|
63078
63241
|
injectGlobalStyles();
|
|
63079
63242
|
}, []);
|
|
63080
63243
|
const handleSubmit = (e2) => {
|
|
@@ -63313,7 +63476,7 @@ function JobIcon({ color: color2, size: size4 = 24 }) {
|
|
|
63313
63476
|
var TaskScheduler = JobScheduler;
|
|
63314
63477
|
|
|
63315
63478
|
// src/react/ui/model-selector.tsx
|
|
63316
|
-
var
|
|
63479
|
+
var import_react127 = require("react");
|
|
63317
63480
|
var import_jsx_runtime142 = require("react/jsx-runtime");
|
|
63318
63481
|
function ModelSelector({
|
|
63319
63482
|
theme = defaultTheme,
|
|
@@ -63328,20 +63491,20 @@ function ModelSelector({
|
|
|
63328
63491
|
compact = false
|
|
63329
63492
|
}) {
|
|
63330
63493
|
const styles2 = baseStyles(theme);
|
|
63331
|
-
const [isOpen, setIsOpen] = (0,
|
|
63332
|
-
const [searchValue, setSearchValue] = (0,
|
|
63333
|
-
const containerRef = (0,
|
|
63334
|
-
const inputRef = (0,
|
|
63494
|
+
const [isOpen, setIsOpen] = (0, import_react127.useState)(false);
|
|
63495
|
+
const [searchValue, setSearchValue] = (0, import_react127.useState)("");
|
|
63496
|
+
const containerRef = (0, import_react127.useRef)(null);
|
|
63497
|
+
const inputRef = (0, import_react127.useRef)(null);
|
|
63335
63498
|
const { models, isLoading, error: error2, setSearch, hasMore, loadMore } = useModels({
|
|
63336
63499
|
capability,
|
|
63337
63500
|
fetchOnMount: true,
|
|
63338
63501
|
pageSize: 50
|
|
63339
63502
|
});
|
|
63340
63503
|
const selectedModel = models.find((m3) => m3.id === value);
|
|
63341
|
-
(0,
|
|
63504
|
+
(0, import_react127.useEffect)(() => {
|
|
63342
63505
|
injectGlobalStyles();
|
|
63343
63506
|
}, []);
|
|
63344
|
-
(0,
|
|
63507
|
+
(0, import_react127.useEffect)(() => {
|
|
63345
63508
|
const handleClickOutside = (event2) => {
|
|
63346
63509
|
if (containerRef.current && !containerRef.current.contains(event2.target)) {
|
|
63347
63510
|
setIsOpen(false);
|
|
@@ -63835,9 +63998,9 @@ function ModelGrid({
|
|
|
63835
63998
|
fetchOnMount: true,
|
|
63836
63999
|
pageSize: 24
|
|
63837
64000
|
});
|
|
63838
|
-
const [searchValue, setSearchValue] = (0,
|
|
63839
|
-
const [filterCapability, setFilterCapability] = (0,
|
|
63840
|
-
(0,
|
|
64001
|
+
const [searchValue, setSearchValue] = (0, import_react127.useState)("");
|
|
64002
|
+
const [filterCapability, setFilterCapability] = (0, import_react127.useState)(capability);
|
|
64003
|
+
(0, import_react127.useEffect)(() => {
|
|
63841
64004
|
injectGlobalStyles();
|
|
63842
64005
|
}, []);
|
|
63843
64006
|
const handleSearchChange = (e2) => {
|
|
@@ -63939,7 +64102,7 @@ function ModelGrid({
|
|
|
63939
64102
|
}
|
|
63940
64103
|
|
|
63941
64104
|
// src/react/ui/newsletter-form.tsx
|
|
63942
|
-
var
|
|
64105
|
+
var import_react128 = require("react");
|
|
63943
64106
|
var import_jsx_runtime143 = require("react/jsx-runtime");
|
|
63944
64107
|
function NewsletterForm({
|
|
63945
64108
|
theme = defaultTheme,
|
|
@@ -63970,16 +64133,16 @@ function NewsletterForm({
|
|
|
63970
64133
|
reset
|
|
63971
64134
|
} = useSubscriberForm();
|
|
63972
64135
|
const styles2 = baseStyles(theme);
|
|
63973
|
-
const [localError, setLocalError] = (0,
|
|
63974
|
-
(0,
|
|
64136
|
+
const [localError, setLocalError] = (0, import_react128.useState)(null);
|
|
64137
|
+
(0, import_react128.useEffect)(() => {
|
|
63975
64138
|
injectGlobalStyles();
|
|
63976
64139
|
}, []);
|
|
63977
|
-
(0,
|
|
64140
|
+
(0, import_react128.useEffect)(() => {
|
|
63978
64141
|
if (success && onSuccess) {
|
|
63979
64142
|
onSuccess(email);
|
|
63980
64143
|
}
|
|
63981
64144
|
}, [success, email, onSuccess]);
|
|
63982
|
-
(0,
|
|
64145
|
+
(0, import_react128.useEffect)(() => {
|
|
63983
64146
|
if (formError && onError) {
|
|
63984
64147
|
onError(formError.message);
|
|
63985
64148
|
}
|
|
@@ -64151,7 +64314,7 @@ function NewsletterForm({
|
|
|
64151
64314
|
}
|
|
64152
64315
|
|
|
64153
64316
|
// src/react/ui/notification-settings.tsx
|
|
64154
|
-
var
|
|
64317
|
+
var import_react129 = require("react");
|
|
64155
64318
|
init_constants();
|
|
64156
64319
|
var import_jsx_runtime144 = require("react/jsx-runtime");
|
|
64157
64320
|
function NotificationSettings({
|
|
@@ -64172,21 +64335,21 @@ function NotificationSettings({
|
|
|
64172
64335
|
updatePreferences
|
|
64173
64336
|
} = useNotifications();
|
|
64174
64337
|
const styles2 = baseStyles(theme);
|
|
64175
|
-
const [error2, setError] = (0,
|
|
64176
|
-
const [success, setSuccess] = (0,
|
|
64177
|
-
const [isTogglingPush, setIsTogglingPush] = (0,
|
|
64178
|
-
const [localPrefs, setLocalPrefs] = (0,
|
|
64338
|
+
const [error2, setError] = (0, import_react129.useState)(null);
|
|
64339
|
+
const [success, setSuccess] = (0, import_react129.useState)(null);
|
|
64340
|
+
const [isTogglingPush, setIsTogglingPush] = (0, import_react129.useState)(false);
|
|
64341
|
+
const [localPrefs, setLocalPrefs] = (0, import_react129.useState)(
|
|
64179
64342
|
() => preferences?.categories ?? {}
|
|
64180
64343
|
);
|
|
64181
|
-
(0,
|
|
64344
|
+
(0, import_react129.useEffect)(() => {
|
|
64182
64345
|
injectGlobalStyles();
|
|
64183
64346
|
}, []);
|
|
64184
|
-
(0,
|
|
64347
|
+
(0, import_react129.useEffect)(() => {
|
|
64185
64348
|
if (preferences?.categories) {
|
|
64186
64349
|
setLocalPrefs(preferences.categories);
|
|
64187
64350
|
}
|
|
64188
64351
|
}, [preferences]);
|
|
64189
|
-
(0,
|
|
64352
|
+
(0, import_react129.useEffect)(() => {
|
|
64190
64353
|
if (success || error2) {
|
|
64191
64354
|
const timer = setTimeout(() => {
|
|
64192
64355
|
setSuccess(null);
|
|
@@ -64418,7 +64581,7 @@ function BellOffIcon({ size: size4 = 24 }) {
|
|
|
64418
64581
|
}
|
|
64419
64582
|
|
|
64420
64583
|
// src/react/ui/organization-management.tsx
|
|
64421
|
-
var
|
|
64584
|
+
var import_react130 = require("react");
|
|
64422
64585
|
init_constants();
|
|
64423
64586
|
var import_jsx_runtime145 = require("react/jsx-runtime");
|
|
64424
64587
|
function OrganizationProfile(props) {
|
|
@@ -64437,23 +64600,23 @@ function OrganizationProfileInner({
|
|
|
64437
64600
|
const hookResult = useOrganization();
|
|
64438
64601
|
const org = propOrg ?? hookResult.organization;
|
|
64439
64602
|
const members = hookResult.members;
|
|
64440
|
-
const [name, setName] = (0,
|
|
64441
|
-
const [slug, setSlug] = (0,
|
|
64442
|
-
const [isSaving, setIsSaving] = (0,
|
|
64443
|
-
const [isDeleting, setIsDeleting] = (0,
|
|
64444
|
-
const [saveSuccess, setSaveSuccess] = (0,
|
|
64445
|
-
const [deleteConfirm, setDeleteConfirm] = (0,
|
|
64603
|
+
const [name, setName] = (0, import_react130.useState)(org?.name ?? "");
|
|
64604
|
+
const [slug, setSlug] = (0, import_react130.useState)(org?.slug ?? "");
|
|
64605
|
+
const [isSaving, setIsSaving] = (0, import_react130.useState)(false);
|
|
64606
|
+
const [isDeleting, setIsDeleting] = (0, import_react130.useState)(false);
|
|
64607
|
+
const [saveSuccess, setSaveSuccess] = (0, import_react130.useState)(false);
|
|
64608
|
+
const [deleteConfirm, setDeleteConfirm] = (0, import_react130.useState)("");
|
|
64446
64609
|
const styles2 = baseStyles(theme);
|
|
64447
|
-
(0,
|
|
64610
|
+
(0, import_react130.useEffect)(() => {
|
|
64448
64611
|
injectGlobalStyles();
|
|
64449
64612
|
}, []);
|
|
64450
|
-
(0,
|
|
64613
|
+
(0, import_react130.useEffect)(() => {
|
|
64451
64614
|
if (org) {
|
|
64452
64615
|
setName(org.name);
|
|
64453
64616
|
setSlug(org.slug ?? "");
|
|
64454
64617
|
}
|
|
64455
64618
|
}, [org]);
|
|
64456
|
-
(0,
|
|
64619
|
+
(0, import_react130.useEffect)(() => {
|
|
64457
64620
|
if (saveSuccess) {
|
|
64458
64621
|
const timer = setTimeout(() => setSaveSuccess(false), UI_FORM_SUCCESS_MS);
|
|
64459
64622
|
return () => clearTimeout(timer);
|
|
@@ -64802,15 +64965,15 @@ function CreateOrganization({
|
|
|
64802
64965
|
onCancel,
|
|
64803
64966
|
showCancel = true
|
|
64804
64967
|
}) {
|
|
64805
|
-
const [name, setName] = (0,
|
|
64806
|
-
const [slug, setSlug] = (0,
|
|
64807
|
-
const [isCreating, setIsCreating] = (0,
|
|
64808
|
-
const [error2, setError] = (0,
|
|
64968
|
+
const [name, setName] = (0, import_react130.useState)("");
|
|
64969
|
+
const [slug, setSlug] = (0, import_react130.useState)("");
|
|
64970
|
+
const [isCreating, setIsCreating] = (0, import_react130.useState)(false);
|
|
64971
|
+
const [error2, setError] = (0, import_react130.useState)(null);
|
|
64809
64972
|
const styles2 = baseStyles(theme);
|
|
64810
|
-
(0,
|
|
64973
|
+
(0, import_react130.useEffect)(() => {
|
|
64811
64974
|
injectGlobalStyles();
|
|
64812
64975
|
}, []);
|
|
64813
|
-
(0,
|
|
64976
|
+
(0, import_react130.useEffect)(() => {
|
|
64814
64977
|
if (name && !slug) {
|
|
64815
64978
|
const generatedSlug = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
64816
64979
|
setSlug(generatedSlug);
|
|
@@ -64978,7 +65141,7 @@ function OrganizationList({
|
|
|
64978
65141
|
emptyMessage = "No organizations"
|
|
64979
65142
|
}) {
|
|
64980
65143
|
const styles2 = baseStyles(theme);
|
|
64981
|
-
(0,
|
|
65144
|
+
(0, import_react130.useEffect)(() => {
|
|
64982
65145
|
injectGlobalStyles();
|
|
64983
65146
|
}, []);
|
|
64984
65147
|
const containerStyle = {
|
|
@@ -65148,7 +65311,7 @@ function PlusIcon5({ color: color2 }) {
|
|
|
65148
65311
|
}
|
|
65149
65312
|
|
|
65150
65313
|
// src/react/ui/push-notifications.tsx
|
|
65151
|
-
var
|
|
65314
|
+
var import_react131 = require("react");
|
|
65152
65315
|
init_constants();
|
|
65153
65316
|
var import_jsx_runtime146 = require("react/jsx-runtime");
|
|
65154
65317
|
function PushPrompt({
|
|
@@ -65165,14 +65328,14 @@ function PushPrompt({
|
|
|
65165
65328
|
autoShow = true,
|
|
65166
65329
|
showDelay = UI_PROMPT_DELAY_MS
|
|
65167
65330
|
}) {
|
|
65168
|
-
const [isVisible, setIsVisible] = (0,
|
|
65169
|
-
const [isAnimatingOut, setIsAnimatingOut] = (0,
|
|
65331
|
+
const [isVisible, setIsVisible] = (0, import_react131.useState)(false);
|
|
65332
|
+
const [isAnimatingOut, setIsAnimatingOut] = (0, import_react131.useState)(false);
|
|
65170
65333
|
const { isSupported, isSubscribed, subscribe, error: error2 } = useNotifications();
|
|
65171
65334
|
const styles2 = baseStyles(theme);
|
|
65172
|
-
(0,
|
|
65335
|
+
(0, import_react131.useEffect)(() => {
|
|
65173
65336
|
injectGlobalStyles();
|
|
65174
65337
|
}, []);
|
|
65175
|
-
(0,
|
|
65338
|
+
(0, import_react131.useEffect)(() => {
|
|
65176
65339
|
if (!autoShow || !isSupported || isSubscribed) return;
|
|
65177
65340
|
const timer = setTimeout(() => {
|
|
65178
65341
|
setIsVisible(true);
|
|
@@ -65412,7 +65575,7 @@ function NotificationList({
|
|
|
65412
65575
|
}) {
|
|
65413
65576
|
const styles2 = baseStyles(theme);
|
|
65414
65577
|
const unreadCount = notifications.filter((n2) => !n2.read).length;
|
|
65415
|
-
(0,
|
|
65578
|
+
(0, import_react131.useEffect)(() => {
|
|
65416
65579
|
injectGlobalStyles();
|
|
65417
65580
|
}, []);
|
|
65418
65581
|
const containerStyle = {
|
|
@@ -65504,7 +65667,7 @@ function NotificationItem({
|
|
|
65504
65667
|
onDelete
|
|
65505
65668
|
}) {
|
|
65506
65669
|
const styles2 = baseStyles(theme);
|
|
65507
|
-
const [showActions, setShowActions] = (0,
|
|
65670
|
+
const [showActions, setShowActions] = (0, import_react131.useState)(false);
|
|
65508
65671
|
const itemStyle = {
|
|
65509
65672
|
display: "flex",
|
|
65510
65673
|
alignItems: "flex-start",
|
|
@@ -65692,7 +65855,7 @@ function TrashIcon3({ color: color2 }) {
|
|
|
65692
65855
|
}
|
|
65693
65856
|
|
|
65694
65857
|
// src/react/ui/referral-card.tsx
|
|
65695
|
-
var
|
|
65858
|
+
var import_react132 = require("react");
|
|
65696
65859
|
init_constants();
|
|
65697
65860
|
var import_jsx_runtime147 = require("react/jsx-runtime");
|
|
65698
65861
|
function ReferralCard(props) {
|
|
@@ -65720,13 +65883,13 @@ function ReferralCardInner({
|
|
|
65720
65883
|
regenerateCode
|
|
65721
65884
|
} = useReferral();
|
|
65722
65885
|
const styles2 = baseStyles(theme);
|
|
65723
|
-
const [copied, setCopied] = (0,
|
|
65724
|
-
const [isRegenerating, setIsRegenerating] = (0,
|
|
65725
|
-
const [error2, setError] = (0,
|
|
65726
|
-
(0,
|
|
65886
|
+
const [copied, setCopied] = (0, import_react132.useState)(null);
|
|
65887
|
+
const [isRegenerating, setIsRegenerating] = (0, import_react132.useState)(false);
|
|
65888
|
+
const [error2, setError] = (0, import_react132.useState)(null);
|
|
65889
|
+
(0, import_react132.useEffect)(() => {
|
|
65727
65890
|
injectGlobalStyles();
|
|
65728
65891
|
}, []);
|
|
65729
|
-
(0,
|
|
65892
|
+
(0, import_react132.useEffect)(() => {
|
|
65730
65893
|
if (copied) {
|
|
65731
65894
|
const timer = setTimeout(() => setCopied(null), UI_COPY_FEEDBACK_MS);
|
|
65732
65895
|
return () => clearTimeout(timer);
|
|
@@ -66126,8 +66289,8 @@ function EmailIcon({ size: size4 = 24 }) {
|
|
|
66126
66289
|
}
|
|
66127
66290
|
|
|
66128
66291
|
// src/react/ui/security-settings.tsx
|
|
66129
|
-
var
|
|
66130
|
-
var
|
|
66292
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
66293
|
+
var import_react133 = require("react");
|
|
66131
66294
|
init_constants();
|
|
66132
66295
|
var import_jsx_runtime148 = require("react/jsx-runtime");
|
|
66133
66296
|
function SecuritySettings({
|
|
@@ -66142,22 +66305,22 @@ function SecuritySettings({
|
|
|
66142
66305
|
}) {
|
|
66143
66306
|
const userContext = useUserContext();
|
|
66144
66307
|
const securityContext = useSecurityContext();
|
|
66145
|
-
const queryClient = (0,
|
|
66308
|
+
const queryClient = (0, import_react_query12.useQueryClient)();
|
|
66146
66309
|
const styles2 = baseStyles(theme);
|
|
66147
|
-
const [error2, setError] = (0,
|
|
66148
|
-
const [success, setSuccess] = (0,
|
|
66149
|
-
const [showSetup2FA, setShowSetup2FA] = (0,
|
|
66150
|
-
const [totpSecret, setTotpSecret] = (0,
|
|
66151
|
-
const [totpQrCode, setTotpQrCode] = (0,
|
|
66152
|
-
const [verifyCode, setVerifyCode] = (0,
|
|
66153
|
-
const [showPasswordChange, setShowPasswordChange] = (0,
|
|
66154
|
-
const [currentPassword, setCurrentPassword] = (0,
|
|
66155
|
-
const [newPassword, setNewPassword] = (0,
|
|
66156
|
-
const [confirmPassword, setConfirmPassword] = (0,
|
|
66157
|
-
(0,
|
|
66310
|
+
const [error2, setError] = (0, import_react133.useState)(null);
|
|
66311
|
+
const [success, setSuccess] = (0, import_react133.useState)(null);
|
|
66312
|
+
const [showSetup2FA, setShowSetup2FA] = (0, import_react133.useState)(false);
|
|
66313
|
+
const [totpSecret, setTotpSecret] = (0, import_react133.useState)(null);
|
|
66314
|
+
const [totpQrCode, setTotpQrCode] = (0, import_react133.useState)(null);
|
|
66315
|
+
const [verifyCode, setVerifyCode] = (0, import_react133.useState)("");
|
|
66316
|
+
const [showPasswordChange, setShowPasswordChange] = (0, import_react133.useState)(false);
|
|
66317
|
+
const [currentPassword, setCurrentPassword] = (0, import_react133.useState)("");
|
|
66318
|
+
const [newPassword, setNewPassword] = (0, import_react133.useState)("");
|
|
66319
|
+
const [confirmPassword, setConfirmPassword] = (0, import_react133.useState)("");
|
|
66320
|
+
(0, import_react133.useEffect)(() => {
|
|
66158
66321
|
injectGlobalStyles();
|
|
66159
66322
|
}, []);
|
|
66160
|
-
const twoFactorQuery = (0,
|
|
66323
|
+
const twoFactorQuery = (0, import_react_query12.useQuery)({
|
|
66161
66324
|
queryKey: ["sylphx", "security", "2fa-status"],
|
|
66162
66325
|
queryFn: async () => {
|
|
66163
66326
|
const data = await securityContext.getTwoFactorStatus();
|
|
@@ -66170,7 +66333,7 @@ function SecuritySettings({
|
|
|
66170
66333
|
staleTime: STALE_TIME_STABLE_MS
|
|
66171
66334
|
// 5 min
|
|
66172
66335
|
});
|
|
66173
|
-
const sessionsQuery = (0,
|
|
66336
|
+
const sessionsQuery = (0, import_react_query12.useQuery)({
|
|
66174
66337
|
queryKey: ["sylphx", "security", "sessions"],
|
|
66175
66338
|
queryFn: async () => {
|
|
66176
66339
|
const data = await userContext.getSessions();
|
|
@@ -66189,7 +66352,7 @@ function SecuritySettings({
|
|
|
66189
66352
|
staleTime: STALE_TIME_FREQUENT_MS
|
|
66190
66353
|
// 1 min - sessions can change
|
|
66191
66354
|
});
|
|
66192
|
-
const loginHistoryQuery = (0,
|
|
66355
|
+
const loginHistoryQuery = (0, import_react_query12.useQuery)({
|
|
66193
66356
|
queryKey: ["sylphx", "security", "login-history"],
|
|
66194
66357
|
queryFn: async () => {
|
|
66195
66358
|
const data = await userContext.getLoginHistory({ limit: 10 });
|
|
@@ -66212,14 +66375,14 @@ function SecuritySettings({
|
|
|
66212
66375
|
const loginHistory = loginHistoryQuery.data ?? [];
|
|
66213
66376
|
const isLoading = twoFactorQuery.isLoading || sessionsQuery.isLoading || loginHistoryQuery.isLoading;
|
|
66214
66377
|
const queryError = twoFactorQuery.error || sessionsQuery.error || loginHistoryQuery.error;
|
|
66215
|
-
(0,
|
|
66378
|
+
(0, import_react133.useEffect)(() => {
|
|
66216
66379
|
if (queryError) {
|
|
66217
66380
|
const message = queryError instanceof Error ? queryError.message : "Failed to load security settings";
|
|
66218
66381
|
setError(message);
|
|
66219
66382
|
onError?.(message);
|
|
66220
66383
|
}
|
|
66221
66384
|
}, [queryError, onError]);
|
|
66222
|
-
(0,
|
|
66385
|
+
(0, import_react133.useEffect)(() => {
|
|
66223
66386
|
if (success || error2) {
|
|
66224
66387
|
const timer = setTimeout(() => {
|
|
66225
66388
|
setSuccess(null);
|
|
@@ -66228,7 +66391,7 @@ function SecuritySettings({
|
|
|
66228
66391
|
return () => clearTimeout(timer);
|
|
66229
66392
|
}
|
|
66230
66393
|
}, [success, error2]);
|
|
66231
|
-
const setup2FAMutation = (0,
|
|
66394
|
+
const setup2FAMutation = (0, import_react_query12.useMutation)({
|
|
66232
66395
|
mutationFn: () => securityContext.twoFactorSetup(),
|
|
66233
66396
|
onSuccess: (data) => {
|
|
66234
66397
|
setTotpSecret(data.secret);
|
|
@@ -66241,7 +66404,7 @@ function SecuritySettings({
|
|
|
66241
66404
|
onError?.(message);
|
|
66242
66405
|
}
|
|
66243
66406
|
});
|
|
66244
|
-
const enable2FAMutation = (0,
|
|
66407
|
+
const enable2FAMutation = (0, import_react_query12.useMutation)({
|
|
66245
66408
|
mutationFn: (code) => securityContext.twoFactorVerify(code),
|
|
66246
66409
|
onSuccess: () => {
|
|
66247
66410
|
queryClient.setQueryData(["sylphx", "security", "2fa-status"], {
|
|
@@ -66259,7 +66422,7 @@ function SecuritySettings({
|
|
|
66259
66422
|
onError?.(message);
|
|
66260
66423
|
}
|
|
66261
66424
|
});
|
|
66262
|
-
const disable2FAMutation = (0,
|
|
66425
|
+
const disable2FAMutation = (0, import_react_query12.useMutation)({
|
|
66263
66426
|
mutationFn: (code) => securityContext.twoFactorDisable(code),
|
|
66264
66427
|
onSuccess: () => {
|
|
66265
66428
|
queryClient.setQueryData(["sylphx", "security", "2fa-status"], {
|
|
@@ -66274,7 +66437,7 @@ function SecuritySettings({
|
|
|
66274
66437
|
onError?.(message);
|
|
66275
66438
|
}
|
|
66276
66439
|
});
|
|
66277
|
-
const changePasswordMutation = (0,
|
|
66440
|
+
const changePasswordMutation = (0, import_react_query12.useMutation)({
|
|
66278
66441
|
mutationFn: ({ current, newPwd }) => userContext.changePassword(current, newPwd),
|
|
66279
66442
|
onSuccess: () => {
|
|
66280
66443
|
setShowPasswordChange(false);
|
|
@@ -66290,7 +66453,7 @@ function SecuritySettings({
|
|
|
66290
66453
|
onError?.(message);
|
|
66291
66454
|
}
|
|
66292
66455
|
});
|
|
66293
|
-
const revokeSessionMutation = (0,
|
|
66456
|
+
const revokeSessionMutation = (0, import_react_query12.useMutation)({
|
|
66294
66457
|
mutationFn: (sessionId) => userContext.revokeSession(sessionId),
|
|
66295
66458
|
onSuccess: (_data, sessionId) => {
|
|
66296
66459
|
queryClient.setQueryData(
|
|
@@ -66306,7 +66469,7 @@ function SecuritySettings({
|
|
|
66306
66469
|
onError?.(message);
|
|
66307
66470
|
}
|
|
66308
66471
|
});
|
|
66309
|
-
const revokeAllSessionsMutation = (0,
|
|
66472
|
+
const revokeAllSessionsMutation = (0, import_react_query12.useMutation)({
|
|
66310
66473
|
mutationFn: () => userContext.revokeAllSessions(),
|
|
66311
66474
|
onSuccess: () => {
|
|
66312
66475
|
queryClient.setQueryData(
|
|
@@ -66322,10 +66485,10 @@ function SecuritySettings({
|
|
|
66322
66485
|
onError?.(message);
|
|
66323
66486
|
}
|
|
66324
66487
|
});
|
|
66325
|
-
const handleStart2FASetup = (0,
|
|
66488
|
+
const handleStart2FASetup = (0, import_react133.useCallback)(() => {
|
|
66326
66489
|
setup2FAMutation.mutate();
|
|
66327
66490
|
}, [setup2FAMutation]);
|
|
66328
|
-
const handleEnable2FA = (0,
|
|
66491
|
+
const handleEnable2FA = (0, import_react133.useCallback)(
|
|
66329
66492
|
(e2) => {
|
|
66330
66493
|
e2.preventDefault();
|
|
66331
66494
|
if (!verifyCode || verifyCode.length !== 6) {
|
|
@@ -66336,12 +66499,12 @@ function SecuritySettings({
|
|
|
66336
66499
|
},
|
|
66337
66500
|
[verifyCode, enable2FAMutation]
|
|
66338
66501
|
);
|
|
66339
|
-
const handleDisable2FA = (0,
|
|
66502
|
+
const handleDisable2FA = (0, import_react133.useCallback)(() => {
|
|
66340
66503
|
const code = prompt("Enter your 2FA code to disable two-factor authentication:");
|
|
66341
66504
|
if (!code) return;
|
|
66342
66505
|
disable2FAMutation.mutate(code);
|
|
66343
66506
|
}, [disable2FAMutation]);
|
|
66344
|
-
const handlePasswordChange = (0,
|
|
66507
|
+
const handlePasswordChange = (0, import_react133.useCallback)(
|
|
66345
66508
|
(e2) => {
|
|
66346
66509
|
e2.preventDefault();
|
|
66347
66510
|
if (newPassword !== confirmPassword) {
|
|
@@ -66359,13 +66522,13 @@ function SecuritySettings({
|
|
|
66359
66522
|
},
|
|
66360
66523
|
[newPassword, confirmPassword, currentPassword, changePasswordMutation]
|
|
66361
66524
|
);
|
|
66362
|
-
const handleRevokeSession = (0,
|
|
66525
|
+
const handleRevokeSession = (0, import_react133.useCallback)(
|
|
66363
66526
|
(sessionId) => {
|
|
66364
66527
|
revokeSessionMutation.mutate(sessionId);
|
|
66365
66528
|
},
|
|
66366
66529
|
[revokeSessionMutation]
|
|
66367
66530
|
);
|
|
66368
|
-
const handleRevokeAllSessions = (0,
|
|
66531
|
+
const handleRevokeAllSessions = (0, import_react133.useCallback)(() => {
|
|
66369
66532
|
if (!confirm("Are you sure you want to sign out all other devices?")) {
|
|
66370
66533
|
return;
|
|
66371
66534
|
}
|
|
@@ -66897,8 +67060,8 @@ function DeviceIcon({ device, theme }) {
|
|
|
66897
67060
|
}
|
|
66898
67061
|
|
|
66899
67062
|
// src/react/ui/subscriber-preferences.tsx
|
|
66900
|
-
var
|
|
66901
|
-
var
|
|
67063
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
67064
|
+
var import_react134 = require("react");
|
|
66902
67065
|
init_constants();
|
|
66903
67066
|
var import_jsx_runtime149 = require("react/jsx-runtime");
|
|
66904
67067
|
function SubscriberPreferences({
|
|
@@ -66916,17 +67079,17 @@ function SubscriberPreferences({
|
|
|
66916
67079
|
unsubscribeButtonText = "Unsubscribe from All"
|
|
66917
67080
|
}) {
|
|
66918
67081
|
const { getPreferences, updatePreferences } = useNewsletter();
|
|
66919
|
-
const queryClient = (0,
|
|
67082
|
+
const queryClient = (0, import_react_query13.useQueryClient)();
|
|
66920
67083
|
const styles2 = baseStyles(theme);
|
|
66921
|
-
const [selectedPreferences, setSelectedPreferences] = (0,
|
|
66922
|
-
const [saving, setSaving] = (0,
|
|
66923
|
-
const [unsubscribing, setUnsubscribing] = (0,
|
|
66924
|
-
const [error2, setError] = (0,
|
|
66925
|
-
const [success, setSuccess] = (0,
|
|
66926
|
-
(0,
|
|
67084
|
+
const [selectedPreferences, setSelectedPreferences] = (0, import_react134.useState)([]);
|
|
67085
|
+
const [saving, setSaving] = (0, import_react134.useState)(false);
|
|
67086
|
+
const [unsubscribing, setUnsubscribing] = (0, import_react134.useState)(false);
|
|
67087
|
+
const [error2, setError] = (0, import_react134.useState)(null);
|
|
67088
|
+
const [success, setSuccess] = (0, import_react134.useState)(null);
|
|
67089
|
+
(0, import_react134.useEffect)(() => {
|
|
66927
67090
|
injectGlobalStyles();
|
|
66928
67091
|
}, []);
|
|
66929
|
-
const prefsQuery = (0,
|
|
67092
|
+
const prefsQuery = (0, import_react_query13.useQuery)({
|
|
66930
67093
|
queryKey: ["sylphx", "newsletter", "preferences", email],
|
|
66931
67094
|
queryFn: async () => {
|
|
66932
67095
|
const prefs = await getPreferences(email);
|
|
@@ -66935,7 +67098,7 @@ function SubscriberPreferences({
|
|
|
66935
67098
|
staleTime: STALE_TIME_STABLE_MS
|
|
66936
67099
|
// 5 min
|
|
66937
67100
|
});
|
|
66938
|
-
(0,
|
|
67101
|
+
(0, import_react134.useEffect)(() => {
|
|
66939
67102
|
if (prefsQuery.data) {
|
|
66940
67103
|
setSelectedPreferences(prefsQuery.data);
|
|
66941
67104
|
}
|
|
@@ -67136,7 +67299,7 @@ function SubscriberPreferences({
|
|
|
67136
67299
|
}
|
|
67137
67300
|
|
|
67138
67301
|
// src/react/ui/unsubscribe-confirm.tsx
|
|
67139
|
-
var
|
|
67302
|
+
var import_react135 = require("react");
|
|
67140
67303
|
init_constants();
|
|
67141
67304
|
var import_jsx_runtime150 = require("react/jsx-runtime");
|
|
67142
67305
|
var DEFAULT_REASONS = [
|
|
@@ -67163,13 +67326,13 @@ function UnsubscribeConfirm({
|
|
|
67163
67326
|
}) {
|
|
67164
67327
|
const { unsubscribe, subscribe } = useNewsletter();
|
|
67165
67328
|
const styles2 = baseStyles(theme);
|
|
67166
|
-
const [status, setStatus] = (0,
|
|
67167
|
-
const [selectedReason, setSelectedReason] = (0,
|
|
67168
|
-
const [error2, setError] = (0,
|
|
67169
|
-
(0,
|
|
67329
|
+
const [status, setStatus] = (0, import_react135.useState)(() => token ? "pending" : "missing_token");
|
|
67330
|
+
const [selectedReason, setSelectedReason] = (0, import_react135.useState)("");
|
|
67331
|
+
const [error2, setError] = (0, import_react135.useState)(null);
|
|
67332
|
+
(0, import_react135.useEffect)(() => {
|
|
67170
67333
|
injectGlobalStyles();
|
|
67171
67334
|
}, []);
|
|
67172
|
-
(0,
|
|
67335
|
+
(0, import_react135.useEffect)(() => {
|
|
67173
67336
|
if (status === "success" && redirectUrl) {
|
|
67174
67337
|
const timer = setTimeout(() => {
|
|
67175
67338
|
safeRedirect(redirectUrl, { fallback: "/" });
|
|
@@ -67512,7 +67675,7 @@ function UnsubscribeConfirm({
|
|
|
67512
67675
|
}
|
|
67513
67676
|
|
|
67514
67677
|
// src/react/ui/user-profile.tsx
|
|
67515
|
-
var
|
|
67678
|
+
var import_react136 = require("react");
|
|
67516
67679
|
init_constants();
|
|
67517
67680
|
var import_jsx_runtime151 = require("react/jsx-runtime");
|
|
67518
67681
|
function UserProfile(props) {
|
|
@@ -67533,16 +67696,16 @@ function UserProfileInner({
|
|
|
67533
67696
|
const userContext = useUserContext();
|
|
67534
67697
|
const { uploadAvatar, isUploading: isUploadingAvatar, uploadError } = useStorage();
|
|
67535
67698
|
const styles2 = baseStyles(theme);
|
|
67536
|
-
const [activeSection, setActiveSection] = (0,
|
|
67537
|
-
const [form, setForm] = (0,
|
|
67538
|
-
const [error2, setError] = (0,
|
|
67539
|
-
const [success, setSuccess] = (0,
|
|
67540
|
-
const [isLoading, setIsLoading] = (0,
|
|
67541
|
-
const fileInputRef = (0,
|
|
67542
|
-
(0,
|
|
67699
|
+
const [activeSection, setActiveSection] = (0, import_react136.useState)(sections[0]);
|
|
67700
|
+
const [form, setForm] = (0, import_react136.useState)({ name: "", image: "" });
|
|
67701
|
+
const [error2, setError] = (0, import_react136.useState)(null);
|
|
67702
|
+
const [success, setSuccess] = (0, import_react136.useState)(null);
|
|
67703
|
+
const [isLoading, setIsLoading] = (0, import_react136.useState)(false);
|
|
67704
|
+
const fileInputRef = (0, import_react136.useRef)(null);
|
|
67705
|
+
(0, import_react136.useEffect)(() => {
|
|
67543
67706
|
injectGlobalStyles();
|
|
67544
67707
|
}, []);
|
|
67545
|
-
(0,
|
|
67708
|
+
(0, import_react136.useEffect)(() => {
|
|
67546
67709
|
if (user) {
|
|
67547
67710
|
setForm({
|
|
67548
67711
|
name: user.name || "",
|
|
@@ -67550,7 +67713,7 @@ function UserProfileInner({
|
|
|
67550
67713
|
});
|
|
67551
67714
|
}
|
|
67552
67715
|
}, [user]);
|
|
67553
|
-
(0,
|
|
67716
|
+
(0, import_react136.useEffect)(() => {
|
|
67554
67717
|
if (success || error2) {
|
|
67555
67718
|
const timer = setTimeout(() => {
|
|
67556
67719
|
setSuccess(null);
|
|
@@ -67559,7 +67722,7 @@ function UserProfileInner({
|
|
|
67559
67722
|
return () => clearTimeout(timer);
|
|
67560
67723
|
}
|
|
67561
67724
|
}, [success, error2]);
|
|
67562
|
-
const handleProfileUpdate = (0,
|
|
67725
|
+
const handleProfileUpdate = (0, import_react136.useCallback)(
|
|
67563
67726
|
async (e2) => {
|
|
67564
67727
|
e2.preventDefault();
|
|
67565
67728
|
setIsLoading(true);
|
|
@@ -67583,7 +67746,7 @@ function UserProfileInner({
|
|
|
67583
67746
|
},
|
|
67584
67747
|
[form, userContext, refreshUser, onSuccess, onError]
|
|
67585
67748
|
);
|
|
67586
|
-
const handleAvatarUpload = (0,
|
|
67749
|
+
const handleAvatarUpload = (0, import_react136.useCallback)(
|
|
67587
67750
|
async (file) => {
|
|
67588
67751
|
setError(null);
|
|
67589
67752
|
try {
|
|
@@ -67878,7 +68041,7 @@ function CloseIcon6({ color: color2 }) {
|
|
|
67878
68041
|
}
|
|
67879
68042
|
|
|
67880
68043
|
// src/react/ui/webhook-manager.tsx
|
|
67881
|
-
var
|
|
68044
|
+
var import_react137 = require("react");
|
|
67882
68045
|
var import_jsx_runtime152 = require("react/jsx-runtime");
|
|
67883
68046
|
var DEFAULT_EVENTS = [
|
|
67884
68047
|
"user.created",
|
|
@@ -67904,15 +68067,15 @@ function WebhookManager({
|
|
|
67904
68067
|
isLoading = false,
|
|
67905
68068
|
emptyMessage = "No webhooks configured"
|
|
67906
68069
|
}) {
|
|
67907
|
-
const [showCreate, setShowCreate] = (0,
|
|
67908
|
-
const [url, setUrl] = (0,
|
|
67909
|
-
const [selectedEvents, setSelectedEvents] = (0,
|
|
67910
|
-
const [isCreating, setIsCreating] = (0,
|
|
67911
|
-
const [error2, setError] = (0,
|
|
67912
|
-
const [testingId, setTestingId] = (0,
|
|
67913
|
-
const [deletingId, setDeletingId] = (0,
|
|
68070
|
+
const [showCreate, setShowCreate] = (0, import_react137.useState)(false);
|
|
68071
|
+
const [url, setUrl] = (0, import_react137.useState)("");
|
|
68072
|
+
const [selectedEvents, setSelectedEvents] = (0, import_react137.useState)([]);
|
|
68073
|
+
const [isCreating, setIsCreating] = (0, import_react137.useState)(false);
|
|
68074
|
+
const [error2, setError] = (0, import_react137.useState)(null);
|
|
68075
|
+
const [testingId, setTestingId] = (0, import_react137.useState)(null);
|
|
68076
|
+
const [deletingId, setDeletingId] = (0, import_react137.useState)(null);
|
|
67914
68077
|
const styles2 = baseStyles(theme);
|
|
67915
|
-
(0,
|
|
68078
|
+
(0, import_react137.useEffect)(() => {
|
|
67916
68079
|
injectGlobalStyles();
|
|
67917
68080
|
}, []);
|
|
67918
68081
|
const handleCreate = async (e2) => {
|
|
@@ -68297,9 +68460,9 @@ function WebhookDeliveryLog({
|
|
|
68297
68460
|
emptyMessage = "No deliveries yet",
|
|
68298
68461
|
maxDeliveries = 50
|
|
68299
68462
|
}) {
|
|
68300
|
-
const [expandedId, setExpandedId] = (0,
|
|
68463
|
+
const [expandedId, setExpandedId] = (0, import_react137.useState)(null);
|
|
68301
68464
|
const styles2 = baseStyles(theme);
|
|
68302
|
-
(0,
|
|
68465
|
+
(0, import_react137.useEffect)(() => {
|
|
68303
68466
|
injectGlobalStyles();
|
|
68304
68467
|
}, []);
|
|
68305
68468
|
const displayedDeliveries = deliveries.slice(0, maxDeliveries);
|
|
@@ -74180,7 +74343,7 @@ function isWebVitalsInitialized() {
|
|
|
74180
74343
|
}
|
|
74181
74344
|
|
|
74182
74345
|
// src/react/hooks/use-session-replay.tsx
|
|
74183
|
-
var
|
|
74346
|
+
var import_react138 = require("react");
|
|
74184
74347
|
init_constants();
|
|
74185
74348
|
var import_jsx_runtime153 = require("react/jsx-runtime");
|
|
74186
74349
|
function useSessionReplay(options = {}) {
|
|
@@ -74194,14 +74357,14 @@ function useSessionReplay(options = {}) {
|
|
|
74194
74357
|
api,
|
|
74195
74358
|
...recorderConfig
|
|
74196
74359
|
} = options;
|
|
74197
|
-
const apiRef = (0,
|
|
74198
|
-
(0,
|
|
74360
|
+
const apiRef = (0, import_react138.useRef)(api);
|
|
74361
|
+
(0, import_react138.useEffect)(() => {
|
|
74199
74362
|
apiRef.current = api;
|
|
74200
74363
|
}, [api]);
|
|
74201
|
-
const recorderRef = (0,
|
|
74202
|
-
const currentSessionIdRef = (0,
|
|
74203
|
-
const [sessionId, setSessionId] = (0,
|
|
74204
|
-
const [status, setStatus] = (0,
|
|
74364
|
+
const recorderRef = (0, import_react138.useRef)(null);
|
|
74365
|
+
const currentSessionIdRef = (0, import_react138.useRef)(null);
|
|
74366
|
+
const [sessionId, setSessionId] = (0, import_react138.useState)(null);
|
|
74367
|
+
const [status, setStatus] = (0, import_react138.useState)({
|
|
74205
74368
|
state: "idle",
|
|
74206
74369
|
sessionId: null,
|
|
74207
74370
|
eventCount: 0,
|
|
@@ -74209,7 +74372,7 @@ function useSessionReplay(options = {}) {
|
|
|
74209
74372
|
duration: 0,
|
|
74210
74373
|
bytesRecorded: 0
|
|
74211
74374
|
});
|
|
74212
|
-
(0,
|
|
74375
|
+
(0, import_react138.useEffect)(() => {
|
|
74213
74376
|
if (typeof window === "undefined") return;
|
|
74214
74377
|
recorderRef.current = new SessionRecorder(recorderConfig);
|
|
74215
74378
|
const uploadHandler = customUpload ? customUpload : api ? createApiUploadHandler(apiRef) : createDefaultUploadHandler(uploadEndpoint);
|
|
@@ -74246,7 +74409,7 @@ function useSessionReplay(options = {}) {
|
|
|
74246
74409
|
}
|
|
74247
74410
|
};
|
|
74248
74411
|
}, [api, autoStart, customUpload, onError, stopOnUnmount, uploadEndpoint]);
|
|
74249
|
-
(0,
|
|
74412
|
+
(0, import_react138.useEffect)(() => {
|
|
74250
74413
|
if (userId && recorderRef.current) {
|
|
74251
74414
|
recorderRef.current.addMarker("custom", {
|
|
74252
74415
|
type: "user-identified",
|
|
@@ -74254,7 +74417,7 @@ function useSessionReplay(options = {}) {
|
|
|
74254
74417
|
});
|
|
74255
74418
|
}
|
|
74256
74419
|
}, [userId]);
|
|
74257
|
-
const start = (0,
|
|
74420
|
+
const start = (0, import_react138.useCallback)(() => {
|
|
74258
74421
|
if (!recorderRef.current) {
|
|
74259
74422
|
throw new Error("Recorder not initialized");
|
|
74260
74423
|
}
|
|
@@ -74262,29 +74425,29 @@ function useSessionReplay(options = {}) {
|
|
|
74262
74425
|
setSessionId(id3);
|
|
74263
74426
|
return id3;
|
|
74264
74427
|
}, []);
|
|
74265
|
-
const pause = (0,
|
|
74428
|
+
const pause = (0, import_react138.useCallback)(() => {
|
|
74266
74429
|
recorderRef.current?.pause();
|
|
74267
74430
|
}, []);
|
|
74268
|
-
const resume = (0,
|
|
74431
|
+
const resume = (0, import_react138.useCallback)(() => {
|
|
74269
74432
|
recorderRef.current?.resume();
|
|
74270
74433
|
}, []);
|
|
74271
|
-
const stop = (0,
|
|
74434
|
+
const stop = (0, import_react138.useCallback)(async () => {
|
|
74272
74435
|
await recorderRef.current?.stop();
|
|
74273
74436
|
setSessionId(null);
|
|
74274
74437
|
}, []);
|
|
74275
|
-
const markError = (0,
|
|
74438
|
+
const markError = (0, import_react138.useCallback)(
|
|
74276
74439
|
(errorId, error2, metadata) => {
|
|
74277
74440
|
recorderRef.current?.markError(errorId, error2, metadata);
|
|
74278
74441
|
},
|
|
74279
74442
|
[]
|
|
74280
74443
|
);
|
|
74281
|
-
const markNavigation = (0,
|
|
74444
|
+
const markNavigation = (0, import_react138.useCallback)((from, to) => {
|
|
74282
74445
|
recorderRef.current?.markNavigation(from, to);
|
|
74283
74446
|
}, []);
|
|
74284
|
-
const markConversion = (0,
|
|
74447
|
+
const markConversion = (0, import_react138.useCallback)((name, value) => {
|
|
74285
74448
|
recorderRef.current?.markConversion(name, value);
|
|
74286
74449
|
}, []);
|
|
74287
|
-
const addMarker = (0,
|
|
74450
|
+
const addMarker = (0, import_react138.useCallback)((type, payload) => {
|
|
74288
74451
|
recorderRef.current?.addMarker(type, payload);
|
|
74289
74452
|
}, []);
|
|
74290
74453
|
return {
|
|
@@ -74333,13 +74496,13 @@ function createDefaultUploadHandler(endpoint) {
|
|
|
74333
74496
|
};
|
|
74334
74497
|
}
|
|
74335
74498
|
function useSessionReplayErrorMarker() {
|
|
74336
|
-
const recorderRef = (0,
|
|
74337
|
-
(0,
|
|
74499
|
+
const recorderRef = (0, import_react138.useRef)(null);
|
|
74500
|
+
(0, import_react138.useEffect)(() => {
|
|
74338
74501
|
if (typeof window !== "undefined" && window.__sylphxRecorder) {
|
|
74339
74502
|
recorderRef.current = window.__sylphxRecorder;
|
|
74340
74503
|
}
|
|
74341
74504
|
}, []);
|
|
74342
|
-
const markError = (0,
|
|
74505
|
+
const markError = (0, import_react138.useCallback)((error2, errorInfo) => {
|
|
74343
74506
|
const errorId = `err_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
74344
74507
|
recorderRef.current?.markError(errorId, error2, {
|
|
74345
74508
|
componentStack: errorInfo?.componentStack?.slice(0, STACK_TRACE_MAX_LENGTH)
|
|
@@ -74358,12 +74521,12 @@ function withSessionReplay(Component4, options) {
|
|
|
74358
74521
|
}
|
|
74359
74522
|
|
|
74360
74523
|
// src/react/hooks/use-web-vitals.ts
|
|
74361
|
-
var
|
|
74524
|
+
var import_react139 = require("react");
|
|
74362
74525
|
function useWebVitals(options = {}) {
|
|
74363
74526
|
const { autoInit = true, onReport, ...config2 } = options;
|
|
74364
|
-
const [report, setReport] = (0,
|
|
74365
|
-
const initRef = (0,
|
|
74366
|
-
(0,
|
|
74527
|
+
const [report, setReport] = (0, import_react139.useState)(null);
|
|
74528
|
+
const initRef = (0, import_react139.useRef)(false);
|
|
74529
|
+
(0, import_react139.useEffect)(() => {
|
|
74367
74530
|
if (!autoInit || initRef.current) return;
|
|
74368
74531
|
if (typeof window === "undefined") return;
|
|
74369
74532
|
initRef.current = true;
|
|
@@ -74378,10 +74541,10 @@ function useWebVitals(options = {}) {
|
|
|
74378
74541
|
return () => {
|
|
74379
74542
|
};
|
|
74380
74543
|
}, [autoInit, onReport]);
|
|
74381
|
-
const refresh = (0,
|
|
74544
|
+
const refresh = (0, import_react139.useCallback)(() => {
|
|
74382
74545
|
setReport(getWebVitalsReport());
|
|
74383
74546
|
}, []);
|
|
74384
|
-
const reset = (0,
|
|
74547
|
+
const reset = (0, import_react139.useCallback)(() => {
|
|
74385
74548
|
resetWebVitals();
|
|
74386
74549
|
setReport(null);
|
|
74387
74550
|
initRef.current = false;
|
|
@@ -74425,7 +74588,7 @@ function useWebVital({ metric }) {
|
|
|
74425
74588
|
}
|
|
74426
74589
|
function useWebVitalsAnalytics(options) {
|
|
74427
74590
|
const { track, eventPrefix = "web_vital", reportOnHide = true } = options;
|
|
74428
|
-
const reportedRef = (0,
|
|
74591
|
+
const reportedRef = (0, import_react139.useRef)(false);
|
|
74429
74592
|
const webVitals = useWebVitals({
|
|
74430
74593
|
onReport: (metric) => {
|
|
74431
74594
|
track(`${eventPrefix}_${metric.name.toLowerCase()}`, {
|
|
@@ -74438,7 +74601,7 @@ function useWebVitalsAnalytics(options) {
|
|
|
74438
74601
|
});
|
|
74439
74602
|
}
|
|
74440
74603
|
});
|
|
74441
|
-
(0,
|
|
74604
|
+
(0, import_react139.useEffect)(() => {
|
|
74442
74605
|
if (!reportOnHide) return;
|
|
74443
74606
|
const handleVisibilityChange = () => {
|
|
74444
74607
|
if (document.visibilityState === "hidden" && !reportedRef.current && webVitals.report) {
|
|
@@ -74467,7 +74630,7 @@ function useWebVitalsAnalytics(options) {
|
|
|
74467
74630
|
}
|
|
74468
74631
|
|
|
74469
74632
|
// src/react/hooks/use-error-tracking.ts
|
|
74470
|
-
var
|
|
74633
|
+
var import_react140 = require("react");
|
|
74471
74634
|
init_constants();
|
|
74472
74635
|
function useEnhancedErrorTracking(options = {}) {
|
|
74473
74636
|
const {
|
|
@@ -74478,9 +74641,9 @@ function useEnhancedErrorTracking(options = {}) {
|
|
|
74478
74641
|
autoInit = true,
|
|
74479
74642
|
...trackerConfig
|
|
74480
74643
|
} = options;
|
|
74481
|
-
const trackerRef = (0,
|
|
74482
|
-
const replaySessionIdRef = (0,
|
|
74483
|
-
(0,
|
|
74644
|
+
const trackerRef = (0, import_react140.useRef)(null);
|
|
74645
|
+
const replaySessionIdRef = (0, import_react140.useRef)(null);
|
|
74646
|
+
(0, import_react140.useEffect)(() => {
|
|
74484
74647
|
if (typeof window === "undefined") return;
|
|
74485
74648
|
const tracker = getTracker({
|
|
74486
74649
|
...trackerConfig,
|
|
@@ -74507,7 +74670,7 @@ function useEnhancedErrorTracking(options = {}) {
|
|
|
74507
74670
|
}
|
|
74508
74671
|
trackerRef.current = tracker;
|
|
74509
74672
|
}, [attachReplay, autoInit, customUpload, uploadEndpoint]);
|
|
74510
|
-
(0,
|
|
74673
|
+
(0, import_react140.useEffect)(() => {
|
|
74511
74674
|
if (!attachReplay || typeof window === "undefined") return;
|
|
74512
74675
|
const checkReplaySession = () => {
|
|
74513
74676
|
try {
|
|
@@ -74523,7 +74686,7 @@ function useEnhancedErrorTracking(options = {}) {
|
|
|
74523
74686
|
const interval = setInterval(checkReplaySession, SESSION_REPLAY_STATUS_CHECK_MS);
|
|
74524
74687
|
return () => clearInterval(interval);
|
|
74525
74688
|
}, [attachReplay]);
|
|
74526
|
-
const captureException = (0,
|
|
74689
|
+
const captureException = (0, import_react140.useCallback)(
|
|
74527
74690
|
async (error2, opts = {}) => {
|
|
74528
74691
|
if (!trackerRef.current) {
|
|
74529
74692
|
return { eventId: "" };
|
|
@@ -74551,7 +74714,7 @@ function useEnhancedErrorTracking(options = {}) {
|
|
|
74551
74714
|
},
|
|
74552
74715
|
[attachReplay, onCapture]
|
|
74553
74716
|
);
|
|
74554
|
-
const captureMessage = (0,
|
|
74717
|
+
const captureMessage = (0, import_react140.useCallback)(
|
|
74555
74718
|
async (message, opts = {}) => {
|
|
74556
74719
|
if (!trackerRef.current) {
|
|
74557
74720
|
return { eventId: "" };
|
|
@@ -74562,20 +74725,20 @@ function useEnhancedErrorTracking(options = {}) {
|
|
|
74562
74725
|
},
|
|
74563
74726
|
[onCapture]
|
|
74564
74727
|
);
|
|
74565
|
-
const addBreadcrumb2 = (0,
|
|
74728
|
+
const addBreadcrumb2 = (0, import_react140.useCallback)((breadcrumb) => {
|
|
74566
74729
|
trackerRef.current?.addBreadcrumb(breadcrumb);
|
|
74567
74730
|
}, []);
|
|
74568
|
-
const setUser = (0,
|
|
74731
|
+
const setUser = (0, import_react140.useCallback)((user) => {
|
|
74569
74732
|
trackerRef.current?.setUser(user);
|
|
74570
74733
|
}, []);
|
|
74571
|
-
const clearUser = (0,
|
|
74734
|
+
const clearUser = (0, import_react140.useCallback)(() => {
|
|
74572
74735
|
trackerRef.current?.clearUser();
|
|
74573
74736
|
}, []);
|
|
74574
|
-
const linkReplaySession = (0,
|
|
74737
|
+
const linkReplaySession = (0, import_react140.useCallback)((sessionId) => {
|
|
74575
74738
|
replaySessionIdRef.current = sessionId;
|
|
74576
74739
|
trackerRef.current?.setSessionReplayId(sessionId);
|
|
74577
74740
|
}, []);
|
|
74578
|
-
const getReplaySessionId = (0,
|
|
74741
|
+
const getReplaySessionId = (0, import_react140.useCallback)(() => {
|
|
74579
74742
|
return replaySessionIdRef.current;
|
|
74580
74743
|
}, []);
|
|
74581
74744
|
return {
|
|
@@ -75779,12 +75942,12 @@ var DEFAULT_FLAGS_CONFIG = {
|
|
|
75779
75942
|
};
|
|
75780
75943
|
|
|
75781
75944
|
// src/react/hooks/use-flag.ts
|
|
75782
|
-
var
|
|
75945
|
+
var import_react142 = require("react");
|
|
75783
75946
|
|
|
75784
75947
|
// src/react/hooks/use-flags.tsx
|
|
75785
|
-
var
|
|
75948
|
+
var import_react141 = require("react");
|
|
75786
75949
|
var import_jsx_runtime154 = require("react/jsx-runtime");
|
|
75787
|
-
var FeatureFlagsContext = (0,
|
|
75950
|
+
var FeatureFlagsContext = (0, import_react141.createContext)(null);
|
|
75788
75951
|
function FeatureFlagsProvider({
|
|
75789
75952
|
children,
|
|
75790
75953
|
config: config2 = {},
|
|
@@ -75794,14 +75957,14 @@ function FeatureFlagsProvider({
|
|
|
75794
75957
|
onReady,
|
|
75795
75958
|
onError
|
|
75796
75959
|
}) {
|
|
75797
|
-
const [isReady, setIsReady] = (0,
|
|
75798
|
-
const [isLoading, setIsLoading] = (0,
|
|
75799
|
-
const [error2, setError] = (0,
|
|
75800
|
-
const [updateVersion, setUpdateVersion] = (0,
|
|
75801
|
-
const evaluatorRef = (0,
|
|
75802
|
-
const streamRef = (0,
|
|
75803
|
-
const experimentsRef = (0,
|
|
75804
|
-
const handleStreamEvent = (0,
|
|
75960
|
+
const [isReady, setIsReady] = (0, import_react141.useState)(!!initialFlags?.length);
|
|
75961
|
+
const [isLoading, setIsLoading] = (0, import_react141.useState)(!initialFlags?.length);
|
|
75962
|
+
const [error2, setError] = (0, import_react141.useState)(null);
|
|
75963
|
+
const [updateVersion, setUpdateVersion] = (0, import_react141.useState)(0);
|
|
75964
|
+
const evaluatorRef = (0, import_react141.useRef)(null);
|
|
75965
|
+
const streamRef = (0, import_react141.useRef)(null);
|
|
75966
|
+
const experimentsRef = (0, import_react141.useRef)(null);
|
|
75967
|
+
const handleStreamEvent = (0, import_react141.useCallback)(
|
|
75805
75968
|
(event2) => {
|
|
75806
75969
|
switch (event2.type) {
|
|
75807
75970
|
case "ready":
|
|
@@ -75828,7 +75991,7 @@ function FeatureFlagsProvider({
|
|
|
75828
75991
|
},
|
|
75829
75992
|
[onReady, onError]
|
|
75830
75993
|
);
|
|
75831
|
-
(0,
|
|
75994
|
+
(0, import_react141.useEffect)(() => {
|
|
75832
75995
|
if (evaluatorRef.current) return;
|
|
75833
75996
|
const evaluator = initFeatureFlags({
|
|
75834
75997
|
...config2,
|
|
@@ -75868,12 +76031,12 @@ function FeatureFlagsProvider({
|
|
|
75868
76031
|
setIsLoading(false);
|
|
75869
76032
|
}
|
|
75870
76033
|
}, [config2, context, enableStreaming, handleStreamEvent, initialFlags]);
|
|
75871
|
-
(0,
|
|
76034
|
+
(0, import_react141.useEffect)(() => {
|
|
75872
76035
|
if (context && evaluatorRef.current) {
|
|
75873
76036
|
evaluatorRef.current.setContext(context);
|
|
75874
76037
|
}
|
|
75875
76038
|
}, [context]);
|
|
75876
|
-
const value = (0,
|
|
76039
|
+
const value = (0, import_react141.useMemo)(
|
|
75877
76040
|
() => ({
|
|
75878
76041
|
evaluator: evaluatorRef.current,
|
|
75879
76042
|
stream: streamRef.current,
|
|
@@ -75892,53 +76055,53 @@ function FeatureFlagsProvider({
|
|
|
75892
76055
|
return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(FeatureFlagsContext.Provider, { value, children });
|
|
75893
76056
|
}
|
|
75894
76057
|
function useFeatureFlags2() {
|
|
75895
|
-
const ctx = (0,
|
|
76058
|
+
const ctx = (0, import_react141.useContext)(FeatureFlagsContext);
|
|
75896
76059
|
if (!ctx) {
|
|
75897
76060
|
throw new Error("useFeatureFlags must be used within a FeatureFlagsProvider");
|
|
75898
76061
|
}
|
|
75899
76062
|
const { evaluator, isReady, isLoading, error: error2, flags, updateVersion } = ctx;
|
|
75900
|
-
const isEnabled = (0,
|
|
76063
|
+
const isEnabled = (0, import_react141.useCallback)(
|
|
75901
76064
|
(flagKey, defaultValue = false) => {
|
|
75902
76065
|
void updateVersion;
|
|
75903
76066
|
return evaluator.isEnabled(flagKey, defaultValue);
|
|
75904
76067
|
},
|
|
75905
76068
|
[evaluator, updateVersion]
|
|
75906
76069
|
);
|
|
75907
|
-
const getString = (0,
|
|
76070
|
+
const getString = (0, import_react141.useCallback)(
|
|
75908
76071
|
(flagKey, defaultValue = "") => {
|
|
75909
76072
|
void updateVersion;
|
|
75910
76073
|
return evaluator.getString(flagKey, defaultValue);
|
|
75911
76074
|
},
|
|
75912
76075
|
[evaluator, updateVersion]
|
|
75913
76076
|
);
|
|
75914
|
-
const getNumber = (0,
|
|
76077
|
+
const getNumber = (0, import_react141.useCallback)(
|
|
75915
76078
|
(flagKey, defaultValue = 0) => {
|
|
75916
76079
|
void updateVersion;
|
|
75917
76080
|
return evaluator.getNumber(flagKey, defaultValue);
|
|
75918
76081
|
},
|
|
75919
76082
|
[evaluator, updateVersion]
|
|
75920
76083
|
);
|
|
75921
|
-
const getJSON = (0,
|
|
76084
|
+
const getJSON = (0, import_react141.useCallback)(
|
|
75922
76085
|
(flagKey, defaultValue) => {
|
|
75923
76086
|
void updateVersion;
|
|
75924
76087
|
return evaluator.getJSON(flagKey, defaultValue);
|
|
75925
76088
|
},
|
|
75926
76089
|
[evaluator, updateVersion]
|
|
75927
76090
|
);
|
|
75928
|
-
const evaluate2 = (0,
|
|
76091
|
+
const evaluate2 = (0, import_react141.useCallback)(
|
|
75929
76092
|
(flagKey, defaultValue, contextOverride) => {
|
|
75930
76093
|
void updateVersion;
|
|
75931
76094
|
return evaluator.evaluate(flagKey, defaultValue, contextOverride);
|
|
75932
76095
|
},
|
|
75933
76096
|
[evaluator, updateVersion]
|
|
75934
76097
|
);
|
|
75935
|
-
const setContext = (0,
|
|
76098
|
+
const setContext = (0, import_react141.useCallback)(
|
|
75936
76099
|
(context) => {
|
|
75937
76100
|
evaluator.setContext(context);
|
|
75938
76101
|
},
|
|
75939
76102
|
[evaluator]
|
|
75940
76103
|
);
|
|
75941
|
-
const updateContext = (0,
|
|
76104
|
+
const updateContext = (0, import_react141.useCallback)(
|
|
75942
76105
|
(partial) => {
|
|
75943
76106
|
evaluator.updateContext(partial);
|
|
75944
76107
|
},
|
|
@@ -75960,7 +76123,7 @@ function useFeatureFlags2() {
|
|
|
75960
76123
|
}
|
|
75961
76124
|
function useFlag(flagKey, defaultValue = false) {
|
|
75962
76125
|
const { isEnabled, updateVersion } = useFeatureFlagsContext();
|
|
75963
|
-
return (0,
|
|
76126
|
+
return (0, import_react141.useMemo)(
|
|
75964
76127
|
() => isEnabled(flagKey, defaultValue),
|
|
75965
76128
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75966
76129
|
[flagKey, defaultValue, isEnabled]
|
|
@@ -75968,7 +76131,7 @@ function useFlag(flagKey, defaultValue = false) {
|
|
|
75968
76131
|
}
|
|
75969
76132
|
function useFlagString(flagKey, defaultValue = "") {
|
|
75970
76133
|
const { getString, updateVersion } = useFeatureFlagsContext();
|
|
75971
|
-
return (0,
|
|
76134
|
+
return (0, import_react141.useMemo)(
|
|
75972
76135
|
() => getString(flagKey, defaultValue),
|
|
75973
76136
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75974
76137
|
[flagKey, defaultValue, getString]
|
|
@@ -75976,7 +76139,7 @@ function useFlagString(flagKey, defaultValue = "") {
|
|
|
75976
76139
|
}
|
|
75977
76140
|
function useFlagNumber(flagKey, defaultValue = 0) {
|
|
75978
76141
|
const { getNumber, updateVersion } = useFeatureFlagsContext();
|
|
75979
|
-
return (0,
|
|
76142
|
+
return (0, import_react141.useMemo)(
|
|
75980
76143
|
() => getNumber(flagKey, defaultValue),
|
|
75981
76144
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75982
76145
|
[flagKey, defaultValue, getNumber]
|
|
@@ -75984,7 +76147,7 @@ function useFlagNumber(flagKey, defaultValue = 0) {
|
|
|
75984
76147
|
}
|
|
75985
76148
|
function useFlagJSON(flagKey, defaultValue) {
|
|
75986
76149
|
const { getJSON, updateVersion } = useFeatureFlagsContext();
|
|
75987
|
-
return (0,
|
|
76150
|
+
return (0, import_react141.useMemo)(
|
|
75988
76151
|
() => getJSON(flagKey, defaultValue),
|
|
75989
76152
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75990
76153
|
[flagKey, defaultValue, getJSON]
|
|
@@ -75992,19 +76155,19 @@ function useFlagJSON(flagKey, defaultValue) {
|
|
|
75992
76155
|
}
|
|
75993
76156
|
function useFlagEvaluation(flagKey, defaultValue, contextOverride) {
|
|
75994
76157
|
const { evaluate: evaluate2, updateVersion } = useFeatureFlagsContext();
|
|
75995
|
-
return (0,
|
|
76158
|
+
return (0, import_react141.useMemo)(
|
|
75996
76159
|
() => evaluate2(flagKey, defaultValue, contextOverride),
|
|
75997
76160
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75998
76161
|
[flagKey, defaultValue, contextOverride, evaluate2]
|
|
75999
76162
|
);
|
|
76000
76163
|
}
|
|
76001
76164
|
function useExperiment(experimentKey) {
|
|
76002
|
-
const ctx = (0,
|
|
76165
|
+
const ctx = (0, import_react141.useContext)(FeatureFlagsContext);
|
|
76003
76166
|
if (!ctx) {
|
|
76004
76167
|
throw new Error("useExperiment must be used within a FeatureFlagsProvider");
|
|
76005
76168
|
}
|
|
76006
76169
|
const { experiments, updateVersion } = ctx;
|
|
76007
|
-
return (0,
|
|
76170
|
+
return (0, import_react141.useMemo)(() => {
|
|
76008
76171
|
const result = experiments.getVariant(experimentKey);
|
|
76009
76172
|
return {
|
|
76010
76173
|
variant: result.variant,
|
|
@@ -76022,7 +76185,7 @@ function useIsInTreatment(experimentKey) {
|
|
|
76022
76185
|
return inExperiment && variant !== "control";
|
|
76023
76186
|
}
|
|
76024
76187
|
function useFeatureFlagsContext() {
|
|
76025
|
-
const ctx = (0,
|
|
76188
|
+
const ctx = (0, import_react141.useContext)(FeatureFlagsContext);
|
|
76026
76189
|
if (!ctx) {
|
|
76027
76190
|
throw new Error("Feature flags hooks must be used within a FeatureFlagsProvider");
|
|
76028
76191
|
}
|
|
@@ -76037,7 +76200,7 @@ function useFeatureFlagsContext() {
|
|
|
76037
76200
|
};
|
|
76038
76201
|
}
|
|
76039
76202
|
function useFlagsReady() {
|
|
76040
|
-
const ctx = (0,
|
|
76203
|
+
const ctx = (0, import_react141.useContext)(FeatureFlagsContext);
|
|
76041
76204
|
if (!ctx) {
|
|
76042
76205
|
return { isReady: false, isLoading: true, error: null };
|
|
76043
76206
|
}
|
|
@@ -76057,22 +76220,22 @@ function useFlagStatus(key, options) {
|
|
|
76057
76220
|
pollInterval = DEFAULT_POLL_INTERVAL_MS2,
|
|
76058
76221
|
context: contextOverride
|
|
76059
76222
|
} = options ?? {};
|
|
76060
|
-
const ctx = (0,
|
|
76061
|
-
const [enabled, setEnabled] = (0,
|
|
76062
|
-
const [loading, setLoading] = (0,
|
|
76063
|
-
const [error2, setError] = (0,
|
|
76064
|
-
const mountedRef = (0,
|
|
76065
|
-
const evalContext = (0,
|
|
76223
|
+
const ctx = (0, import_react142.useContext)(FeatureFlagsContext);
|
|
76224
|
+
const [enabled, setEnabled] = (0, import_react142.useState)(false);
|
|
76225
|
+
const [loading, setLoading] = (0, import_react142.useState)(!ctx?.isReady);
|
|
76226
|
+
const [error2, setError] = (0, import_react142.useState)(null);
|
|
76227
|
+
const mountedRef = (0, import_react142.useRef)(true);
|
|
76228
|
+
const evalContext = (0, import_react142.useMemo)(() => {
|
|
76066
76229
|
if (contextOverride) return contextOverride;
|
|
76067
76230
|
if (userId || attributes) return { userId, ...attributes };
|
|
76068
76231
|
return void 0;
|
|
76069
76232
|
}, [contextOverride, userId, attributes]);
|
|
76070
|
-
const evaluateLocally = (0,
|
|
76233
|
+
const evaluateLocally = (0, import_react142.useCallback)(() => {
|
|
76071
76234
|
if (!ctx?.evaluator) return false;
|
|
76072
76235
|
const result = ctx.evaluator.evaluate(key, false, evalContext);
|
|
76073
76236
|
return result.value;
|
|
76074
76237
|
}, [ctx, key, evalContext]);
|
|
76075
|
-
const refetch = (0,
|
|
76238
|
+
const refetch = (0, import_react142.useCallback)(async () => {
|
|
76076
76239
|
if (!mountedRef.current) return;
|
|
76077
76240
|
setError(null);
|
|
76078
76241
|
try {
|
|
@@ -76090,13 +76253,13 @@ function useFlagStatus(key, options) {
|
|
|
76090
76253
|
}
|
|
76091
76254
|
}
|
|
76092
76255
|
}, [ctx, evaluateLocally]);
|
|
76093
|
-
(0,
|
|
76256
|
+
(0, import_react142.useEffect)(() => {
|
|
76094
76257
|
mountedRef.current = true;
|
|
76095
76258
|
return () => {
|
|
76096
76259
|
mountedRef.current = false;
|
|
76097
76260
|
};
|
|
76098
76261
|
}, []);
|
|
76099
|
-
(0,
|
|
76262
|
+
(0, import_react142.useEffect)(() => {
|
|
76100
76263
|
if (ctx?.isReady) {
|
|
76101
76264
|
setEnabled(evaluateLocally());
|
|
76102
76265
|
setLoading(false);
|
|
@@ -76104,18 +76267,18 @@ function useFlagStatus(key, options) {
|
|
|
76104
76267
|
setLoading(false);
|
|
76105
76268
|
}
|
|
76106
76269
|
}, [ctx?.isReady, evaluateLocally, ctx]);
|
|
76107
|
-
(0,
|
|
76270
|
+
(0, import_react142.useEffect)(() => {
|
|
76108
76271
|
if (!ctx?.isReady) return;
|
|
76109
76272
|
setEnabled(evaluateLocally());
|
|
76110
76273
|
}, [evaluateLocally, ctx?.isReady]);
|
|
76111
|
-
(0,
|
|
76274
|
+
(0, import_react142.useEffect)(() => {
|
|
76112
76275
|
if (ctx?.error) {
|
|
76113
76276
|
setError(
|
|
76114
76277
|
ctx.error instanceof SylphxError ? ctx.error : new SylphxError(ctx.error.message, { code: "SERVICE_UNAVAILABLE" })
|
|
76115
76278
|
);
|
|
76116
76279
|
}
|
|
76117
76280
|
}, [ctx?.error]);
|
|
76118
|
-
(0,
|
|
76281
|
+
(0, import_react142.useEffect)(() => {
|
|
76119
76282
|
if (!pollInterval || pollInterval <= 0) return;
|
|
76120
76283
|
const id3 = setInterval(() => {
|
|
76121
76284
|
if (mountedRef.current) {
|
|
@@ -78248,19 +78411,19 @@ function resetAnalyticsTracker() {
|
|
|
78248
78411
|
}
|
|
78249
78412
|
|
|
78250
78413
|
// src/react/hooks/use-analytics.tsx
|
|
78251
|
-
var
|
|
78414
|
+
var import_react143 = __toESM(require("react"), 1);
|
|
78252
78415
|
init_constants();
|
|
78253
78416
|
var import_jsx_runtime155 = require("react/jsx-runtime");
|
|
78254
|
-
var AnalyticsContext = (0,
|
|
78417
|
+
var AnalyticsContext = (0, import_react143.createContext)(null);
|
|
78255
78418
|
function AnalyticsProvider({
|
|
78256
78419
|
children,
|
|
78257
78420
|
config: config2 = {},
|
|
78258
78421
|
user,
|
|
78259
78422
|
disabled: disabled2 = false
|
|
78260
78423
|
}) {
|
|
78261
|
-
const trackerRef = (0,
|
|
78262
|
-
const [isReady, setIsReady] =
|
|
78263
|
-
(0,
|
|
78424
|
+
const trackerRef = (0, import_react143.useRef)(null);
|
|
78425
|
+
const [isReady, setIsReady] = import_react143.default.useState(false);
|
|
78426
|
+
(0, import_react143.useEffect)(() => {
|
|
78264
78427
|
if (disabled2 || typeof window === "undefined") return;
|
|
78265
78428
|
const tracker = initAnalytics(config2);
|
|
78266
78429
|
trackerRef.current = tracker;
|
|
@@ -78269,12 +78432,12 @@ function AnalyticsProvider({
|
|
|
78269
78432
|
tracker.shutdown();
|
|
78270
78433
|
};
|
|
78271
78434
|
}, [disabled2, config2]);
|
|
78272
|
-
(0,
|
|
78435
|
+
(0, import_react143.useEffect)(() => {
|
|
78273
78436
|
if (user && trackerRef.current) {
|
|
78274
78437
|
trackerRef.current.identify(user.id, user.properties);
|
|
78275
78438
|
}
|
|
78276
78439
|
}, [user]);
|
|
78277
|
-
const value = (0,
|
|
78440
|
+
const value = (0, import_react143.useMemo)(() => {
|
|
78278
78441
|
if (!trackerRef.current || disabled2) return null;
|
|
78279
78442
|
return {
|
|
78280
78443
|
tracker: trackerRef.current,
|
|
@@ -78287,25 +78450,25 @@ function AnalyticsProvider({
|
|
|
78287
78450
|
return /* @__PURE__ */ (0, import_jsx_runtime155.jsx)(AnalyticsContext.Provider, { value, children });
|
|
78288
78451
|
}
|
|
78289
78452
|
function useAnalyticsHook() {
|
|
78290
|
-
const ctx = (0,
|
|
78291
|
-
const noopTrack = (0,
|
|
78453
|
+
const ctx = (0, import_react143.useContext)(AnalyticsContext);
|
|
78454
|
+
const noopTrack = (0, import_react143.useCallback)(() => {
|
|
78292
78455
|
}, []);
|
|
78293
|
-
const noopIdentify = (0,
|
|
78456
|
+
const noopIdentify = (0, import_react143.useCallback)(() => {
|
|
78294
78457
|
}, []);
|
|
78295
|
-
const noopReset = (0,
|
|
78458
|
+
const noopReset = (0, import_react143.useCallback)(() => {
|
|
78296
78459
|
}, []);
|
|
78297
|
-
const noopSetUserProperties = (0,
|
|
78460
|
+
const noopSetUserProperties = (0, import_react143.useCallback)(() => {
|
|
78298
78461
|
}, []);
|
|
78299
|
-
const noopSetUserPropertiesOnce = (0,
|
|
78462
|
+
const noopSetUserPropertiesOnce = (0, import_react143.useCallback)(() => {
|
|
78300
78463
|
}, []);
|
|
78301
|
-
const noopIncrementUserProperty = (0,
|
|
78464
|
+
const noopIncrementUserProperty = (0, import_react143.useCallback)(() => {
|
|
78302
78465
|
}, []);
|
|
78303
|
-
const noopGroup = (0,
|
|
78466
|
+
const noopGroup = (0, import_react143.useCallback)(() => {
|
|
78304
78467
|
}, []);
|
|
78305
|
-
const noopRegister = (0,
|
|
78468
|
+
const noopRegister = (0, import_react143.useCallback)(() => {
|
|
78306
78469
|
}, []);
|
|
78307
|
-
const noopGetDistinctId = (0,
|
|
78308
|
-
const noopFlush = (0,
|
|
78470
|
+
const noopGetDistinctId = (0, import_react143.useCallback)(() => null, []);
|
|
78471
|
+
const noopFlush = (0, import_react143.useCallback)(async () => {
|
|
78309
78472
|
}, []);
|
|
78310
78473
|
if (!ctx) {
|
|
78311
78474
|
return {
|
|
@@ -78324,64 +78487,64 @@ function useAnalyticsHook() {
|
|
|
78324
78487
|
}
|
|
78325
78488
|
const { tracker, isReady } = ctx;
|
|
78326
78489
|
return {
|
|
78327
|
-
track: (0,
|
|
78490
|
+
track: (0, import_react143.useCallback)(
|
|
78328
78491
|
(eventName, properties) => {
|
|
78329
78492
|
tracker.track(eventName, properties);
|
|
78330
78493
|
},
|
|
78331
78494
|
[tracker]
|
|
78332
78495
|
),
|
|
78333
|
-
identify: (0,
|
|
78496
|
+
identify: (0, import_react143.useCallback)(
|
|
78334
78497
|
(userId, properties) => {
|
|
78335
78498
|
tracker.identify(userId, properties);
|
|
78336
78499
|
},
|
|
78337
78500
|
[tracker]
|
|
78338
78501
|
),
|
|
78339
|
-
reset: (0,
|
|
78502
|
+
reset: (0, import_react143.useCallback)(() => {
|
|
78340
78503
|
tracker.reset();
|
|
78341
78504
|
}, [tracker]),
|
|
78342
|
-
setUserProperties: (0,
|
|
78505
|
+
setUserProperties: (0, import_react143.useCallback)(
|
|
78343
78506
|
(properties) => {
|
|
78344
78507
|
tracker.setUserProperties(properties);
|
|
78345
78508
|
},
|
|
78346
78509
|
[tracker]
|
|
78347
78510
|
),
|
|
78348
|
-
setUserPropertiesOnce: (0,
|
|
78511
|
+
setUserPropertiesOnce: (0, import_react143.useCallback)(
|
|
78349
78512
|
(properties) => {
|
|
78350
78513
|
tracker.setUserPropertiesOnce(properties);
|
|
78351
78514
|
},
|
|
78352
78515
|
[tracker]
|
|
78353
78516
|
),
|
|
78354
|
-
incrementUserProperty: (0,
|
|
78517
|
+
incrementUserProperty: (0, import_react143.useCallback)(
|
|
78355
78518
|
(property, value) => {
|
|
78356
78519
|
tracker.incrementUserProperty(property, value);
|
|
78357
78520
|
},
|
|
78358
78521
|
[tracker]
|
|
78359
78522
|
),
|
|
78360
|
-
group: (0,
|
|
78523
|
+
group: (0, import_react143.useCallback)(
|
|
78361
78524
|
(groupType, groupKey, properties) => {
|
|
78362
78525
|
tracker.group(groupType, groupKey, properties);
|
|
78363
78526
|
},
|
|
78364
78527
|
[tracker]
|
|
78365
78528
|
),
|
|
78366
|
-
register: (0,
|
|
78529
|
+
register: (0, import_react143.useCallback)(
|
|
78367
78530
|
(properties) => {
|
|
78368
78531
|
tracker.register(properties);
|
|
78369
78532
|
},
|
|
78370
78533
|
[tracker]
|
|
78371
78534
|
),
|
|
78372
|
-
getDistinctId: (0,
|
|
78535
|
+
getDistinctId: (0, import_react143.useCallback)(() => {
|
|
78373
78536
|
return tracker.getDistinctId();
|
|
78374
78537
|
}, [tracker]),
|
|
78375
78538
|
isReady,
|
|
78376
|
-
flush: (0,
|
|
78539
|
+
flush: (0, import_react143.useCallback)(async () => {
|
|
78377
78540
|
await tracker.flush();
|
|
78378
78541
|
}, [tracker])
|
|
78379
78542
|
};
|
|
78380
78543
|
}
|
|
78381
78544
|
function usePageView(pageName, properties) {
|
|
78382
78545
|
const { track, isReady } = useAnalyticsHook();
|
|
78383
|
-
const hasTracked = (0,
|
|
78384
|
-
(0,
|
|
78546
|
+
const hasTracked = (0, import_react143.useRef)(false);
|
|
78547
|
+
(0, import_react143.useEffect)(() => {
|
|
78385
78548
|
if (!isReady || hasTracked.current) return;
|
|
78386
78549
|
hasTracked.current = true;
|
|
78387
78550
|
track("$pageview", {
|
|
@@ -78392,9 +78555,9 @@ function usePageView(pageName, properties) {
|
|
|
78392
78555
|
}
|
|
78393
78556
|
function useComponentTracking(componentName, properties) {
|
|
78394
78557
|
const { track, isReady } = useAnalyticsHook();
|
|
78395
|
-
const mountTime = (0,
|
|
78396
|
-
const hasTracked = (0,
|
|
78397
|
-
(0,
|
|
78558
|
+
const mountTime = (0, import_react143.useRef)(Date.now());
|
|
78559
|
+
const hasTracked = (0, import_react143.useRef)(false);
|
|
78560
|
+
(0, import_react143.useEffect)(() => {
|
|
78398
78561
|
if (!isReady || hasTracked.current) return;
|
|
78399
78562
|
hasTracked.current = true;
|
|
78400
78563
|
track("component_viewed", {
|
|
@@ -78412,7 +78575,7 @@ function useComponentTracking(componentName, properties) {
|
|
|
78412
78575
|
}
|
|
78413
78576
|
function useFeatureTracking(featureName) {
|
|
78414
78577
|
const { track } = useAnalyticsHook();
|
|
78415
|
-
const trackUsed = (0,
|
|
78578
|
+
const trackUsed = (0, import_react143.useCallback)(
|
|
78416
78579
|
(properties) => {
|
|
78417
78580
|
track("feature_used", {
|
|
78418
78581
|
feature: featureName,
|
|
@@ -78421,7 +78584,7 @@ function useFeatureTracking(featureName) {
|
|
|
78421
78584
|
},
|
|
78422
78585
|
[track, featureName]
|
|
78423
78586
|
);
|
|
78424
|
-
const trackError = (0,
|
|
78587
|
+
const trackError = (0, import_react143.useCallback)(
|
|
78425
78588
|
(error2, properties) => {
|
|
78426
78589
|
track("feature_error", {
|
|
78427
78590
|
feature: featureName,
|
|
@@ -78436,13 +78599,13 @@ function useFeatureTracking(featureName) {
|
|
|
78436
78599
|
}
|
|
78437
78600
|
function useFormTracking(formName) {
|
|
78438
78601
|
const { track } = useAnalyticsHook();
|
|
78439
|
-
const startTime = (0,
|
|
78440
|
-
const fieldsFilledRef = (0,
|
|
78441
|
-
const trackStarted = (0,
|
|
78602
|
+
const startTime = (0, import_react143.useRef)(null);
|
|
78603
|
+
const fieldsFilledRef = (0, import_react143.useRef)(/* @__PURE__ */ new Set());
|
|
78604
|
+
const trackStarted = (0, import_react143.useCallback)(() => {
|
|
78442
78605
|
startTime.current = Date.now();
|
|
78443
78606
|
track("form_started", { form: formName });
|
|
78444
78607
|
}, [track, formName]);
|
|
78445
|
-
const trackCompleted = (0,
|
|
78608
|
+
const trackCompleted = (0, import_react143.useCallback)(
|
|
78446
78609
|
(properties) => {
|
|
78447
78610
|
const duration2 = startTime.current ? Date.now() - startTime.current : void 0;
|
|
78448
78611
|
track("form_completed", {
|
|
@@ -78454,7 +78617,7 @@ function useFormTracking(formName) {
|
|
|
78454
78617
|
},
|
|
78455
78618
|
[track, formName]
|
|
78456
78619
|
);
|
|
78457
|
-
const trackAbandoned = (0,
|
|
78620
|
+
const trackAbandoned = (0, import_react143.useCallback)(() => {
|
|
78458
78621
|
const duration2 = startTime.current ? Date.now() - startTime.current : void 0;
|
|
78459
78622
|
track("form_abandoned", {
|
|
78460
78623
|
form: formName,
|
|
@@ -78462,7 +78625,7 @@ function useFormTracking(formName) {
|
|
|
78462
78625
|
fields_filled: fieldsFilledRef.current.size
|
|
78463
78626
|
});
|
|
78464
78627
|
}, [track, formName]);
|
|
78465
|
-
const trackFieldFilled = (0,
|
|
78628
|
+
const trackFieldFilled = (0, import_react143.useCallback)(
|
|
78466
78629
|
(fieldName) => {
|
|
78467
78630
|
if (!fieldsFilledRef.current.has(fieldName)) {
|
|
78468
78631
|
fieldsFilledRef.current.add(fieldName);
|
|
@@ -78474,7 +78637,7 @@ function useFormTracking(formName) {
|
|
|
78474
78637
|
},
|
|
78475
78638
|
[track, formName]
|
|
78476
78639
|
);
|
|
78477
|
-
const trackError = (0,
|
|
78640
|
+
const trackError = (0, import_react143.useCallback)(
|
|
78478
78641
|
(fieldName, error2) => {
|
|
78479
78642
|
track("form_field_error", {
|
|
78480
78643
|
form: formName,
|
|
@@ -78494,18 +78657,18 @@ function useFormTracking(formName) {
|
|
|
78494
78657
|
}
|
|
78495
78658
|
function useTimeTracking(name, options) {
|
|
78496
78659
|
const { track } = useAnalyticsHook();
|
|
78497
|
-
const startTime = (0,
|
|
78498
|
-
const trackedIntervals = (0,
|
|
78499
|
-
const getTimeSpent = (0,
|
|
78660
|
+
const startTime = (0, import_react143.useRef)(Date.now());
|
|
78661
|
+
const trackedIntervals = (0, import_react143.useRef)(/* @__PURE__ */ new Set());
|
|
78662
|
+
const getTimeSpent = (0, import_react143.useCallback)(() => {
|
|
78500
78663
|
return Date.now() - startTime.current;
|
|
78501
78664
|
}, []);
|
|
78502
|
-
const trackNow = (0,
|
|
78665
|
+
const trackNow = (0, import_react143.useCallback)(() => {
|
|
78503
78666
|
track("time_spent", {
|
|
78504
78667
|
name,
|
|
78505
78668
|
duration_ms: getTimeSpent()
|
|
78506
78669
|
});
|
|
78507
78670
|
}, [track, name, getTimeSpent]);
|
|
78508
|
-
(0,
|
|
78671
|
+
(0, import_react143.useEffect)(() => {
|
|
78509
78672
|
if (!options?.trackIntervals) return;
|
|
78510
78673
|
const checkIntervals = () => {
|
|
78511
78674
|
const elapsed = getTimeSpent();
|
|
@@ -78523,7 +78686,7 @@ function useTimeTracking(name, options) {
|
|
|
78523
78686
|
const intervalId = setInterval(checkIntervals, ANALYTICS_INTERVAL_CHECK_MS);
|
|
78524
78687
|
return () => clearInterval(intervalId);
|
|
78525
78688
|
}, [track, name, getTimeSpent, options?.trackIntervals]);
|
|
78526
|
-
(0,
|
|
78689
|
+
(0, import_react143.useEffect)(() => {
|
|
78527
78690
|
if (!options?.trackOnUnmount) return;
|
|
78528
78691
|
return () => {
|
|
78529
78692
|
track("time_spent", {
|
|
@@ -78536,8 +78699,8 @@ function useTimeTracking(name, options) {
|
|
|
78536
78699
|
}
|
|
78537
78700
|
|
|
78538
78701
|
// src/react/hooks/use-destination-router.tsx
|
|
78539
|
-
var import_react143 = require("react");
|
|
78540
78702
|
var import_react144 = require("react");
|
|
78703
|
+
var import_react145 = require("react");
|
|
78541
78704
|
var import_jsx_runtime156 = require("react/jsx-runtime");
|
|
78542
78705
|
function useDestinationRouter(options) {
|
|
78543
78706
|
const {
|
|
@@ -78547,11 +78710,11 @@ function useDestinationRouter(options) {
|
|
|
78547
78710
|
autoInit = true,
|
|
78548
78711
|
debug = false
|
|
78549
78712
|
} = options;
|
|
78550
|
-
const routerRef = (0,
|
|
78551
|
-
const initializedRef = (0,
|
|
78713
|
+
const routerRef = (0, import_react144.useRef)(null);
|
|
78714
|
+
const initializedRef = (0, import_react144.useRef)(false);
|
|
78552
78715
|
const { hasConsent: checkConsent } = useConsent();
|
|
78553
78716
|
const { user } = useUser();
|
|
78554
|
-
const router = (0,
|
|
78717
|
+
const router = (0, import_react144.useMemo)(() => {
|
|
78555
78718
|
if (!autoInit || typeof window === "undefined") return null;
|
|
78556
78719
|
const newRouter = createDestinationRouter({
|
|
78557
78720
|
destinations,
|
|
@@ -78564,11 +78727,11 @@ function useDestinationRouter(options) {
|
|
|
78564
78727
|
initializedRef.current = true;
|
|
78565
78728
|
return newRouter;
|
|
78566
78729
|
}, [destinations, autoInit, syncConsent, checkConsent, debug, syncUser, user?.id]);
|
|
78567
|
-
(0,
|
|
78730
|
+
(0, import_react144.useEffect)(() => {
|
|
78568
78731
|
if (!syncConsent || !routerRef.current) return;
|
|
78569
78732
|
routerRef.current.setConsentChecker((category) => checkConsent(category));
|
|
78570
78733
|
}, [syncConsent, checkConsent]);
|
|
78571
|
-
(0,
|
|
78734
|
+
(0, import_react144.useEffect)(() => {
|
|
78572
78735
|
if (!syncUser || !routerRef.current || !user?.id) return;
|
|
78573
78736
|
routerRef.current.setDistinctId(user.id);
|
|
78574
78737
|
routerRef.current.identify(user.id, {
|
|
@@ -78576,46 +78739,46 @@ function useDestinationRouter(options) {
|
|
|
78576
78739
|
name: user.name
|
|
78577
78740
|
});
|
|
78578
78741
|
}, [syncUser, user?.id, user?.email, user?.name]);
|
|
78579
|
-
const track = (0,
|
|
78742
|
+
const track = (0, import_react144.useCallback)(
|
|
78580
78743
|
(event2, properties) => {
|
|
78581
78744
|
router?.track(event2, properties);
|
|
78582
78745
|
},
|
|
78583
78746
|
[router]
|
|
78584
78747
|
);
|
|
78585
|
-
const trackTo = (0,
|
|
78748
|
+
const trackTo = (0, import_react144.useCallback)(
|
|
78586
78749
|
(destinationType, event2, properties) => {
|
|
78587
78750
|
router?.trackTo(destinationType, event2, properties);
|
|
78588
78751
|
},
|
|
78589
78752
|
[router]
|
|
78590
78753
|
);
|
|
78591
|
-
const identify = (0,
|
|
78754
|
+
const identify = (0, import_react144.useCallback)(
|
|
78592
78755
|
(userId, traits) => {
|
|
78593
78756
|
router?.identify(userId, traits);
|
|
78594
78757
|
},
|
|
78595
78758
|
[router]
|
|
78596
78759
|
);
|
|
78597
|
-
const page = (0,
|
|
78760
|
+
const page = (0, import_react144.useCallback)(
|
|
78598
78761
|
(name, properties) => {
|
|
78599
78762
|
router?.page(name, properties);
|
|
78600
78763
|
},
|
|
78601
78764
|
[router]
|
|
78602
78765
|
);
|
|
78603
|
-
const getEnabledDestinations = (0,
|
|
78766
|
+
const getEnabledDestinations = (0, import_react144.useCallback)(() => {
|
|
78604
78767
|
return router?.getEnabledDestinations() || [];
|
|
78605
78768
|
}, [router]);
|
|
78606
|
-
const setDestinationEnabled = (0,
|
|
78769
|
+
const setDestinationEnabled = (0, import_react144.useCallback)(
|
|
78607
78770
|
(type, enabled) => {
|
|
78608
78771
|
router?.setDestinationEnabled(type, enabled);
|
|
78609
78772
|
},
|
|
78610
78773
|
[router]
|
|
78611
78774
|
);
|
|
78612
|
-
const setConsentChecker = (0,
|
|
78775
|
+
const setConsentChecker = (0, import_react144.useCallback)(
|
|
78613
78776
|
(fn) => {
|
|
78614
78777
|
router?.setConsentChecker(fn);
|
|
78615
78778
|
},
|
|
78616
78779
|
[router]
|
|
78617
78780
|
);
|
|
78618
|
-
const setDistinctId = (0,
|
|
78781
|
+
const setDistinctId = (0, import_react144.useCallback)(
|
|
78619
78782
|
(id3) => {
|
|
78620
78783
|
router?.setDistinctId(id3);
|
|
78621
78784
|
},
|
|
@@ -78634,7 +78797,7 @@ function useDestinationRouter(options) {
|
|
|
78634
78797
|
setDistinctId
|
|
78635
78798
|
};
|
|
78636
78799
|
}
|
|
78637
|
-
var DestinationRouterContext = (0,
|
|
78800
|
+
var DestinationRouterContext = (0, import_react145.createContext)(null);
|
|
78638
78801
|
function DestinationRouterProvider({
|
|
78639
78802
|
children,
|
|
78640
78803
|
...options
|
|
@@ -78643,7 +78806,7 @@ function DestinationRouterProvider({
|
|
|
78643
78806
|
return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(DestinationRouterContext.Provider, { value: router, children });
|
|
78644
78807
|
}
|
|
78645
78808
|
function useRouterContext() {
|
|
78646
|
-
return (0,
|
|
78809
|
+
return (0, import_react145.useContext)(DestinationRouterContext);
|
|
78647
78810
|
}
|
|
78648
78811
|
|
|
78649
78812
|
// src/lib/tasks/handler.ts
|
|
@@ -79428,7 +79591,7 @@ function validateWorkflow(workflow) {
|
|
|
79428
79591
|
var job = task;
|
|
79429
79592
|
|
|
79430
79593
|
// src/react/hooks/use-realtime.ts
|
|
79431
|
-
var
|
|
79594
|
+
var import_react146 = require("react");
|
|
79432
79595
|
init_constants();
|
|
79433
79596
|
function useRealtime(channel, options = {}) {
|
|
79434
79597
|
const {
|
|
@@ -79441,17 +79604,17 @@ function useRealtime(channel, options = {}) {
|
|
|
79441
79604
|
enabled = true,
|
|
79442
79605
|
platformUrl: customPlatformUrl
|
|
79443
79606
|
} = options;
|
|
79444
|
-
const [messages, setMessages] = (0,
|
|
79445
|
-
const [status, setStatus] = (0,
|
|
79446
|
-
const platformContext = (0,
|
|
79607
|
+
const [messages, setMessages] = (0, import_react146.useState)([]);
|
|
79608
|
+
const [status, setStatus] = (0, import_react146.useState)("disconnected");
|
|
79609
|
+
const platformContext = (0, import_react146.useContext)(PlatformContext);
|
|
79447
79610
|
const appId = platformContext?.appId || "";
|
|
79448
|
-
const lastAckRef = (0,
|
|
79449
|
-
const eventSourceRef = (0,
|
|
79450
|
-
const reconnectTimeoutRef = (0,
|
|
79451
|
-
const reconnectAttemptRef = (0,
|
|
79452
|
-
const mountedRef = (0,
|
|
79611
|
+
const lastAckRef = (0, import_react146.useRef)("0");
|
|
79612
|
+
const eventSourceRef = (0, import_react146.useRef)(null);
|
|
79613
|
+
const reconnectTimeoutRef = (0, import_react146.useRef)(null);
|
|
79614
|
+
const reconnectAttemptRef = (0, import_react146.useRef)(0);
|
|
79615
|
+
const mountedRef = (0, import_react146.useRef)(true);
|
|
79453
79616
|
const platformUrl = customPlatformUrl || platformContext?.platformUrl || `https://${DEFAULT_SDK_API_HOST}`;
|
|
79454
|
-
const buildUrl = (0,
|
|
79617
|
+
const buildUrl = (0, import_react146.useCallback)(() => {
|
|
79455
79618
|
const url = new URL(`${platformUrl}${SDK_API_PATH}/realtime/subscribe`);
|
|
79456
79619
|
url.searchParams.set("channel", channel);
|
|
79457
79620
|
if (lastAckRef.current !== "0") {
|
|
@@ -79459,7 +79622,7 @@ function useRealtime(channel, options = {}) {
|
|
|
79459
79622
|
}
|
|
79460
79623
|
return url.toString();
|
|
79461
79624
|
}, [platformUrl, channel]);
|
|
79462
|
-
const sdkHeaders = (0,
|
|
79625
|
+
const sdkHeaders = (0, import_react146.useMemo)(
|
|
79463
79626
|
() => ({
|
|
79464
79627
|
"Content-Type": "application/json",
|
|
79465
79628
|
"x-app-secret": appId,
|
|
@@ -79468,7 +79631,7 @@ function useRealtime(channel, options = {}) {
|
|
|
79468
79631
|
}),
|
|
79469
79632
|
[appId]
|
|
79470
79633
|
);
|
|
79471
|
-
const fetchHistory = (0,
|
|
79634
|
+
const fetchHistory = (0, import_react146.useCallback)(async () => {
|
|
79472
79635
|
if (!history2) return;
|
|
79473
79636
|
const historyLimit = typeof history2 === "number" ? history2 : history2.limit ?? 100;
|
|
79474
79637
|
const historyStart = typeof history2 === "object" ? history2.start : void 0;
|
|
@@ -79492,7 +79655,7 @@ function useRealtime(channel, options = {}) {
|
|
|
79492
79655
|
} catch {
|
|
79493
79656
|
}
|
|
79494
79657
|
}, [platformUrl, sdkHeaders, channel, history2]);
|
|
79495
|
-
const connect = (0,
|
|
79658
|
+
const connect = (0, import_react146.useCallback)(() => {
|
|
79496
79659
|
if (!enabled || !appId) return;
|
|
79497
79660
|
if (eventSourceRef.current) {
|
|
79498
79661
|
eventSourceRef.current.close();
|
|
@@ -79563,7 +79726,7 @@ function useRealtime(channel, options = {}) {
|
|
|
79563
79726
|
onReconnect,
|
|
79564
79727
|
onError
|
|
79565
79728
|
]);
|
|
79566
|
-
const disconnect = (0,
|
|
79729
|
+
const disconnect = (0, import_react146.useCallback)(() => {
|
|
79567
79730
|
if (eventSourceRef.current) {
|
|
79568
79731
|
eventSourceRef.current.close();
|
|
79569
79732
|
eventSourceRef.current = null;
|
|
@@ -79574,7 +79737,7 @@ function useRealtime(channel, options = {}) {
|
|
|
79574
79737
|
}
|
|
79575
79738
|
setStatus("disconnected");
|
|
79576
79739
|
}, []);
|
|
79577
|
-
const emit = (0,
|
|
79740
|
+
const emit = (0, import_react146.useCallback)(
|
|
79578
79741
|
async (event2, data) => {
|
|
79579
79742
|
const response = await fetch(`${platformUrl}${SDK_API_PATH}/realtime/emit`, {
|
|
79580
79743
|
method: "POST",
|
|
@@ -79606,11 +79769,11 @@ function useRealtime(channel, options = {}) {
|
|
|
79606
79769
|
},
|
|
79607
79770
|
[platformUrl, sdkHeaders, channel]
|
|
79608
79771
|
);
|
|
79609
|
-
const clear = (0,
|
|
79772
|
+
const clear = (0, import_react146.useCallback)(() => {
|
|
79610
79773
|
setMessages([]);
|
|
79611
79774
|
lastAckRef.current = "0";
|
|
79612
79775
|
}, []);
|
|
79613
|
-
(0,
|
|
79776
|
+
(0, import_react146.useEffect)(() => {
|
|
79614
79777
|
mountedRef.current = true;
|
|
79615
79778
|
if (enabled && appId) {
|
|
79616
79779
|
connect();
|
|
@@ -79640,14 +79803,14 @@ function useRealtimeChannels(channels, options = {}) {
|
|
|
79640
79803
|
enabled = true,
|
|
79641
79804
|
platformUrl: customPlatformUrl
|
|
79642
79805
|
} = options;
|
|
79643
|
-
const [messages, setMessages] = (0,
|
|
79644
|
-
const [statuses, setStatuses] = (0,
|
|
79645
|
-
const platformContext = (0,
|
|
79806
|
+
const [messages, setMessages] = (0, import_react146.useState)([]);
|
|
79807
|
+
const [statuses, setStatuses] = (0, import_react146.useState)({});
|
|
79808
|
+
const platformContext = (0, import_react146.useContext)(PlatformContext);
|
|
79646
79809
|
const appId = platformContext?.appId || "";
|
|
79647
79810
|
const platformUrl = customPlatformUrl || platformContext?.platformUrl || `https://${DEFAULT_SDK_API_HOST}`;
|
|
79648
|
-
const lastAcksRef = (0,
|
|
79649
|
-
const eventSourcesRef = (0,
|
|
79650
|
-
const mountedRef = (0,
|
|
79811
|
+
const lastAcksRef = (0, import_react146.useRef)({});
|
|
79812
|
+
const eventSourcesRef = (0, import_react146.useRef)({});
|
|
79813
|
+
const mountedRef = (0, import_react146.useRef)(true);
|
|
79651
79814
|
const status = (() => {
|
|
79652
79815
|
const statusValues = Object.values(statuses);
|
|
79653
79816
|
if (statusValues.length === 0) return "disconnected";
|
|
@@ -79656,7 +79819,7 @@ function useRealtimeChannels(channels, options = {}) {
|
|
|
79656
79819
|
if (statusValues.every((s2) => s2 === "connected")) return "connected";
|
|
79657
79820
|
return "disconnected";
|
|
79658
79821
|
})();
|
|
79659
|
-
const connectChannel = (0,
|
|
79822
|
+
const connectChannel = (0, import_react146.useCallback)(
|
|
79660
79823
|
(channel) => {
|
|
79661
79824
|
if (!enabled || !appId) return;
|
|
79662
79825
|
if (eventSourcesRef.current[channel]) {
|
|
@@ -79706,15 +79869,15 @@ function useRealtimeChannels(channels, options = {}) {
|
|
|
79706
79869
|
},
|
|
79707
79870
|
[enabled, appId, platformUrl, events, onConnect, onMessage, onReconnect, onError]
|
|
79708
79871
|
);
|
|
79709
|
-
const connect = (0,
|
|
79872
|
+
const connect = (0, import_react146.useCallback)(() => {
|
|
79710
79873
|
channels.forEach(connectChannel);
|
|
79711
79874
|
}, [channels, connectChannel]);
|
|
79712
|
-
const disconnect = (0,
|
|
79875
|
+
const disconnect = (0, import_react146.useCallback)(() => {
|
|
79713
79876
|
Object.values(eventSourcesRef.current).forEach((es) => es.close());
|
|
79714
79877
|
eventSourcesRef.current = {};
|
|
79715
79878
|
setStatuses({});
|
|
79716
79879
|
}, []);
|
|
79717
|
-
const sdkHeaders = (0,
|
|
79880
|
+
const sdkHeaders = (0, import_react146.useMemo)(
|
|
79718
79881
|
() => ({
|
|
79719
79882
|
"Content-Type": "application/json",
|
|
79720
79883
|
"x-app-secret": appId,
|
|
@@ -79723,7 +79886,7 @@ function useRealtimeChannels(channels, options = {}) {
|
|
|
79723
79886
|
}),
|
|
79724
79887
|
[appId]
|
|
79725
79888
|
);
|
|
79726
|
-
const emit = (0,
|
|
79889
|
+
const emit = (0, import_react146.useCallback)(
|
|
79727
79890
|
async (event2, data, targetChannel) => {
|
|
79728
79891
|
const channel = targetChannel || channels[0];
|
|
79729
79892
|
if (!channel) throw new SylphxError("No channel specified", { code: "BAD_REQUEST" });
|
|
@@ -79750,11 +79913,11 @@ function useRealtimeChannels(channels, options = {}) {
|
|
|
79750
79913
|
},
|
|
79751
79914
|
[channels, platformUrl, sdkHeaders]
|
|
79752
79915
|
);
|
|
79753
|
-
const clear = (0,
|
|
79916
|
+
const clear = (0, import_react146.useCallback)(() => {
|
|
79754
79917
|
setMessages([]);
|
|
79755
79918
|
lastAcksRef.current = {};
|
|
79756
79919
|
}, []);
|
|
79757
|
-
(0,
|
|
79920
|
+
(0, import_react146.useEffect)(() => {
|
|
79758
79921
|
mountedRef.current = true;
|
|
79759
79922
|
if (enabled && appId && channels.length > 0) {
|
|
79760
79923
|
connect();
|
|
@@ -79775,14 +79938,14 @@ function useRealtimeChannels(channels, options = {}) {
|
|
|
79775
79938
|
}
|
|
79776
79939
|
|
|
79777
79940
|
// src/react/hooks/use-kv.ts
|
|
79778
|
-
var
|
|
79941
|
+
var import_react147 = require("react");
|
|
79779
79942
|
init_constants();
|
|
79780
79943
|
function useKv(options = {}) {
|
|
79781
79944
|
const { platformUrl: customPlatformUrl } = options;
|
|
79782
|
-
const platformContext = (0,
|
|
79945
|
+
const platformContext = (0, import_react147.useContext)(PlatformContext);
|
|
79783
79946
|
const appId = platformContext?.appId || "";
|
|
79784
79947
|
const platformUrl = customPlatformUrl || platformContext?.platformUrl || `https://${DEFAULT_SDK_API_HOST}`;
|
|
79785
|
-
const headers = (0,
|
|
79948
|
+
const headers = (0, import_react147.useMemo)(
|
|
79786
79949
|
() => ({
|
|
79787
79950
|
"Content-Type": "application/json",
|
|
79788
79951
|
"x-app-secret": appId,
|
|
@@ -79791,7 +79954,7 @@ function useKv(options = {}) {
|
|
|
79791
79954
|
}),
|
|
79792
79955
|
[appId]
|
|
79793
79956
|
);
|
|
79794
|
-
const request = (0,
|
|
79957
|
+
const request = (0, import_react147.useCallback)(
|
|
79795
79958
|
async (method, path, body) => {
|
|
79796
79959
|
let lastError;
|
|
79797
79960
|
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
@@ -79847,13 +80010,13 @@ function useKv(options = {}) {
|
|
|
79847
80010
|
},
|
|
79848
80011
|
[platformUrl, headers]
|
|
79849
80012
|
);
|
|
79850
|
-
const get = (0,
|
|
80013
|
+
const get = (0, import_react147.useCallback)(
|
|
79851
80014
|
async (key) => {
|
|
79852
80015
|
return request("GET", `/${encodeURIComponent(key)}`);
|
|
79853
80016
|
},
|
|
79854
80017
|
[request]
|
|
79855
80018
|
);
|
|
79856
|
-
const set3 = (0,
|
|
80019
|
+
const set3 = (0, import_react147.useCallback)(
|
|
79857
80020
|
async (key, value, options2) => {
|
|
79858
80021
|
const result = await request("POST", "", {
|
|
79859
80022
|
key,
|
|
@@ -79864,28 +80027,28 @@ function useKv(options = {}) {
|
|
|
79864
80027
|
},
|
|
79865
80028
|
[request]
|
|
79866
80029
|
);
|
|
79867
|
-
const del = (0,
|
|
80030
|
+
const del = (0, import_react147.useCallback)(
|
|
79868
80031
|
async (key) => {
|
|
79869
80032
|
const result = await request("DELETE", `/${encodeURIComponent(key)}`);
|
|
79870
80033
|
return result.deleted;
|
|
79871
80034
|
},
|
|
79872
80035
|
[request]
|
|
79873
80036
|
);
|
|
79874
|
-
const exists = (0,
|
|
80037
|
+
const exists = (0, import_react147.useCallback)(
|
|
79875
80038
|
async (key) => {
|
|
79876
80039
|
const result = await request("GET", `/exists/${encodeURIComponent(key)}`);
|
|
79877
80040
|
return result.exists;
|
|
79878
80041
|
},
|
|
79879
80042
|
[request]
|
|
79880
80043
|
);
|
|
79881
|
-
const mget = (0,
|
|
80044
|
+
const mget = (0, import_react147.useCallback)(
|
|
79882
80045
|
async (keys) => {
|
|
79883
80046
|
const result = await request("POST", "/mget", { keys });
|
|
79884
80047
|
return result.values;
|
|
79885
80048
|
},
|
|
79886
80049
|
[request]
|
|
79887
80050
|
);
|
|
79888
|
-
const mset = (0,
|
|
80051
|
+
const mset = (0, import_react147.useCallback)(
|
|
79889
80052
|
async (entries, options2) => {
|
|
79890
80053
|
await request("POST", "/mset", {
|
|
79891
80054
|
entries,
|
|
@@ -79894,7 +80057,7 @@ function useKv(options = {}) {
|
|
|
79894
80057
|
},
|
|
79895
80058
|
[request]
|
|
79896
80059
|
);
|
|
79897
|
-
const incr = (0,
|
|
80060
|
+
const incr = (0, import_react147.useCallback)(
|
|
79898
80061
|
async (key, by = 1) => {
|
|
79899
80062
|
const result = await request("POST", "/incr", {
|
|
79900
80063
|
key,
|
|
@@ -79904,7 +80067,7 @@ function useKv(options = {}) {
|
|
|
79904
80067
|
},
|
|
79905
80068
|
[request]
|
|
79906
80069
|
);
|
|
79907
|
-
const expire = (0,
|
|
80070
|
+
const expire = (0, import_react147.useCallback)(
|
|
79908
80071
|
async (key, seconds) => {
|
|
79909
80072
|
const result = await request("POST", "/expire", {
|
|
79910
80073
|
key,
|
|
@@ -79914,7 +80077,7 @@ function useKv(options = {}) {
|
|
|
79914
80077
|
},
|
|
79915
80078
|
[request]
|
|
79916
80079
|
);
|
|
79917
|
-
const ratelimit = (0,
|
|
80080
|
+
const ratelimit = (0, import_react147.useCallback)(
|
|
79918
80081
|
async (key, options2) => {
|
|
79919
80082
|
return request("POST", "/ratelimit", {
|
|
79920
80083
|
key,
|
|
@@ -79923,7 +80086,7 @@ function useKv(options = {}) {
|
|
|
79923
80086
|
},
|
|
79924
80087
|
[request]
|
|
79925
80088
|
);
|
|
79926
|
-
const hset = (0,
|
|
80089
|
+
const hset = (0, import_react147.useCallback)(
|
|
79927
80090
|
async (key, fields) => {
|
|
79928
80091
|
const result = await request("POST", "/hset", {
|
|
79929
80092
|
key,
|
|
@@ -79933,7 +80096,7 @@ function useKv(options = {}) {
|
|
|
79933
80096
|
},
|
|
79934
80097
|
[request]
|
|
79935
80098
|
);
|
|
79936
|
-
const hget = (0,
|
|
80099
|
+
const hget = (0, import_react147.useCallback)(
|
|
79937
80100
|
async (key, field) => {
|
|
79938
80101
|
const result = await request("POST", "/hget", {
|
|
79939
80102
|
key,
|
|
@@ -79943,7 +80106,7 @@ function useKv(options = {}) {
|
|
|
79943
80106
|
},
|
|
79944
80107
|
[request]
|
|
79945
80108
|
);
|
|
79946
|
-
const hgetall = (0,
|
|
80109
|
+
const hgetall = (0, import_react147.useCallback)(
|
|
79947
80110
|
async (key) => {
|
|
79948
80111
|
const result = await request("POST", "/hgetall", {
|
|
79949
80112
|
key
|
|
@@ -79952,7 +80115,7 @@ function useKv(options = {}) {
|
|
|
79952
80115
|
},
|
|
79953
80116
|
[request]
|
|
79954
80117
|
);
|
|
79955
|
-
const lpush = (0,
|
|
80118
|
+
const lpush = (0, import_react147.useCallback)(
|
|
79956
80119
|
async (key, ...values) => {
|
|
79957
80120
|
const result = await request("POST", "/lpush", {
|
|
79958
80121
|
key,
|
|
@@ -79962,7 +80125,7 @@ function useKv(options = {}) {
|
|
|
79962
80125
|
},
|
|
79963
80126
|
[request]
|
|
79964
80127
|
);
|
|
79965
|
-
const lrange = (0,
|
|
80128
|
+
const lrange = (0, import_react147.useCallback)(
|
|
79966
80129
|
async (key, start = 0, stop = -1) => {
|
|
79967
80130
|
const result = await request("POST", "/lrange", {
|
|
79968
80131
|
key,
|
|
@@ -79973,7 +80136,7 @@ function useKv(options = {}) {
|
|
|
79973
80136
|
},
|
|
79974
80137
|
[request]
|
|
79975
80138
|
);
|
|
79976
|
-
const zadd = (0,
|
|
80139
|
+
const zadd = (0, import_react147.useCallback)(
|
|
79977
80140
|
async (key, ...members) => {
|
|
79978
80141
|
const result = await request("POST", "/zadd", {
|
|
79979
80142
|
key,
|
|
@@ -79983,7 +80146,7 @@ function useKv(options = {}) {
|
|
|
79983
80146
|
},
|
|
79984
80147
|
[request]
|
|
79985
80148
|
);
|
|
79986
|
-
const zrange = (0,
|
|
80149
|
+
const zrange = (0, import_react147.useCallback)(
|
|
79987
80150
|
async (key, start = 0, stop = 9, options2) => {
|
|
79988
80151
|
const result = await request("POST", "/zrange", {
|
|
79989
80152
|
key,
|
|
@@ -79996,7 +80159,7 @@ function useKv(options = {}) {
|
|
|
79996
80159
|
},
|
|
79997
80160
|
[request]
|
|
79998
80161
|
);
|
|
79999
|
-
return (0,
|
|
80162
|
+
return (0, import_react147.useMemo)(
|
|
80000
80163
|
() => ({
|
|
80001
80164
|
get,
|
|
80002
80165
|
set: set3,
|
|
@@ -80037,7 +80200,7 @@ function useKv(options = {}) {
|
|
|
80037
80200
|
}
|
|
80038
80201
|
|
|
80039
80202
|
// src/react/hooks/use-search.ts
|
|
80040
|
-
var
|
|
80203
|
+
var import_react148 = require("react");
|
|
80041
80204
|
|
|
80042
80205
|
// src/search.ts
|
|
80043
80206
|
async function search(config2, input) {
|
|
@@ -80071,19 +80234,19 @@ function useSearch(config2, options = {}) {
|
|
|
80071
80234
|
initialQuery = "",
|
|
80072
80235
|
...searchOptions
|
|
80073
80236
|
} = options;
|
|
80074
|
-
const [query, setQueryState] = (0,
|
|
80075
|
-
const [results, setResults] = (0,
|
|
80076
|
-
const [total, setTotal] = (0,
|
|
80077
|
-
const [loading, setLoading] = (0,
|
|
80078
|
-
const [error2, setError] = (0,
|
|
80079
|
-
const [response, setResponse] = (0,
|
|
80080
|
-
const debounceTimer = (0,
|
|
80081
|
-
const abortController = (0,
|
|
80082
|
-
const searchOptionsRef = (0,
|
|
80083
|
-
(0,
|
|
80237
|
+
const [query, setQueryState] = (0, import_react148.useState)(initialQuery);
|
|
80238
|
+
const [results, setResults] = (0, import_react148.useState)([]);
|
|
80239
|
+
const [total, setTotal] = (0, import_react148.useState)(0);
|
|
80240
|
+
const [loading, setLoading] = (0, import_react148.useState)(false);
|
|
80241
|
+
const [error2, setError] = (0, import_react148.useState)(null);
|
|
80242
|
+
const [response, setResponse] = (0, import_react148.useState)(null);
|
|
80243
|
+
const debounceTimer = (0, import_react148.useRef)(null);
|
|
80244
|
+
const abortController = (0, import_react148.useRef)(null);
|
|
80245
|
+
const searchOptionsRef = (0, import_react148.useRef)(searchOptions);
|
|
80246
|
+
(0, import_react148.useEffect)(() => {
|
|
80084
80247
|
searchOptionsRef.current = searchOptions;
|
|
80085
80248
|
});
|
|
80086
|
-
const executeSearch = (0,
|
|
80249
|
+
const executeSearch = (0, import_react148.useCallback)(
|
|
80087
80250
|
async (q2) => {
|
|
80088
80251
|
if (!q2 || q2.length < minLength) {
|
|
80089
80252
|
setResults([]);
|
|
@@ -80115,7 +80278,7 @@ function useSearch(config2, options = {}) {
|
|
|
80115
80278
|
},
|
|
80116
80279
|
[config2, minLength]
|
|
80117
80280
|
);
|
|
80118
|
-
const setQuery = (0,
|
|
80281
|
+
const setQuery = (0, import_react148.useCallback)(
|
|
80119
80282
|
(q2) => {
|
|
80120
80283
|
setQueryState(q2);
|
|
80121
80284
|
if (debounceTimer.current) {
|
|
@@ -80135,7 +80298,7 @@ function useSearch(config2, options = {}) {
|
|
|
80135
80298
|
},
|
|
80136
80299
|
[executeSearch, debounceMs, minLength]
|
|
80137
80300
|
);
|
|
80138
|
-
const clear = (0,
|
|
80301
|
+
const clear = (0, import_react148.useCallback)(() => {
|
|
80139
80302
|
if (debounceTimer.current) clearTimeout(debounceTimer.current);
|
|
80140
80303
|
abortController.current?.abort();
|
|
80141
80304
|
setQueryState("");
|
|
@@ -80145,17 +80308,17 @@ function useSearch(config2, options = {}) {
|
|
|
80145
80308
|
setLoading(false);
|
|
80146
80309
|
setError(null);
|
|
80147
80310
|
}, []);
|
|
80148
|
-
const refetch = (0,
|
|
80311
|
+
const refetch = (0, import_react148.useCallback)(() => {
|
|
80149
80312
|
executeSearch(query);
|
|
80150
80313
|
}, [executeSearch, query]);
|
|
80151
|
-
const trackResultClick = (0,
|
|
80314
|
+
const trackResultClick = (0, import_react148.useCallback)((_documentId, _resultRank) => {
|
|
80152
80315
|
}, []);
|
|
80153
|
-
(0,
|
|
80316
|
+
(0, import_react148.useEffect)(() => {
|
|
80154
80317
|
if (initialQuery && initialQuery.length >= minLength) {
|
|
80155
80318
|
executeSearch(initialQuery);
|
|
80156
80319
|
}
|
|
80157
80320
|
}, []);
|
|
80158
|
-
(0,
|
|
80321
|
+
(0, import_react148.useEffect)(() => {
|
|
80159
80322
|
return () => {
|
|
80160
80323
|
if (debounceTimer.current) clearTimeout(debounceTimer.current);
|
|
80161
80324
|
abortController.current?.abort();
|
|
@@ -80176,7 +80339,7 @@ function useSearch(config2, options = {}) {
|
|
|
80176
80339
|
}
|
|
80177
80340
|
|
|
80178
80341
|
// src/react/components/web-analytics.tsx
|
|
80179
|
-
var
|
|
80342
|
+
var import_react149 = require("react");
|
|
80180
80343
|
|
|
80181
80344
|
// src/lib/analytics/web-analytics.ts
|
|
80182
80345
|
init_constants();
|
|
@@ -80373,7 +80536,7 @@ function WebAnalytics({
|
|
|
80373
80536
|
hashMode = false,
|
|
80374
80537
|
debug = false
|
|
80375
80538
|
}) {
|
|
80376
|
-
(0,
|
|
80539
|
+
(0, import_react149.useEffect)(() => {
|
|
80377
80540
|
if (!appKey) {
|
|
80378
80541
|
if (debug) {
|
|
80379
80542
|
console.warn("[WebAnalytics] No appKey provided, tracking disabled");
|
|
@@ -80403,7 +80566,7 @@ function useWebAnalytics() {
|
|
|
80403
80566
|
}
|
|
80404
80567
|
|
|
80405
80568
|
// src/react/components/speed-insights.tsx
|
|
80406
|
-
var
|
|
80569
|
+
var import_react150 = require("react");
|
|
80407
80570
|
function sendVital(url, appKey, payload) {
|
|
80408
80571
|
const data = JSON.stringify(payload);
|
|
80409
80572
|
const headers = {
|
|
@@ -80432,7 +80595,7 @@ function SpeedInsights({
|
|
|
80432
80595
|
debug = false,
|
|
80433
80596
|
reportAllChanges = false
|
|
80434
80597
|
}) {
|
|
80435
|
-
(0,
|
|
80598
|
+
(0, import_react150.useEffect)(() => {
|
|
80436
80599
|
if (typeof window === "undefined") return;
|
|
80437
80600
|
const reportUrl = `${endpoint}/api/sdk/v1/analytics/vitals`;
|
|
80438
80601
|
initWebVitals({
|
|
@@ -80721,11 +80884,13 @@ function SpeedInsights({
|
|
|
80721
80884
|
useFormTracking,
|
|
80722
80885
|
useGlobalErrorHandler,
|
|
80723
80886
|
useGoogleConsentMode,
|
|
80887
|
+
useHasPermission,
|
|
80724
80888
|
useInbox,
|
|
80725
80889
|
useIsInTreatment,
|
|
80726
80890
|
useIsInVariant,
|
|
80727
80891
|
useKv,
|
|
80728
80892
|
useLeaderboard,
|
|
80893
|
+
useMemberPermissions,
|
|
80729
80894
|
useMobilePush,
|
|
80730
80895
|
useModal,
|
|
80731
80896
|
useModels,
|
|
@@ -80736,12 +80901,14 @@ function SpeedInsights({
|
|
|
80736
80901
|
useOAuthProviders,
|
|
80737
80902
|
useOrganization,
|
|
80738
80903
|
usePageView,
|
|
80904
|
+
usePermissions,
|
|
80739
80905
|
usePlans,
|
|
80740
80906
|
useProtect,
|
|
80741
80907
|
useRealtime,
|
|
80742
80908
|
useRealtimeChannels,
|
|
80743
80909
|
useReferral,
|
|
80744
80910
|
useResetPasswordForm,
|
|
80911
|
+
useRoles,
|
|
80745
80912
|
useRouterContext,
|
|
80746
80913
|
useSafeAchievements,
|
|
80747
80914
|
useSafeAnalytics,
|