@flamingo-stack/openframe-frontend-core 0.0.203 → 0.0.204-snapshot.20260523020255
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/chunk-27APPAJN.cjs +24 -0
- package/dist/chunk-27APPAJN.cjs.map +1 -0
- package/dist/{chunk-XGL5FKIK.js → chunk-D6BNDYZK.js} +114 -4
- package/dist/chunk-D6BNDYZK.js.map +1 -0
- package/dist/chunk-MJNXIEV2.js +24 -0
- package/dist/chunk-MJNXIEV2.js.map +1 -0
- package/dist/{chunk-25LVV26X.cjs → chunk-NLXY4QZE.cjs} +114 -4
- package/dist/chunk-NLXY4QZE.cjs.map +1 -0
- package/dist/{chunk-E6Q6UGDK.js → chunk-OFCRX24Y.js} +383 -569
- package/dist/chunk-OFCRX24Y.js.map +1 -0
- package/dist/{chunk-3YH2M76N.cjs → chunk-RDXOQWBY.cjs} +556 -742
- package/dist/chunk-RDXOQWBY.cjs.map +1 -0
- package/dist/components/announcement-bar.d.ts.map +1 -1
- package/dist/components/features/index.cjs +4 -3
- package/dist/components/features/index.cjs.map +1 -1
- package/dist/components/features/index.js +3 -2
- package/dist/components/index.cjs +4 -3
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +3 -2
- package/dist/components/navigation/index.cjs +4 -3
- package/dist/components/navigation/index.cjs.map +1 -1
- package/dist/components/navigation/index.js +3 -2
- package/dist/components/navigation/navigation-sidebar.d.ts.map +1 -1
- package/dist/components/shared/product-release/product-release-card-skeleton.d.ts +1 -1
- package/dist/components/shared/product-release/product-release-card-skeleton.d.ts.map +1 -1
- package/dist/components/shared/product-release/product-release-card.d.ts +19 -12
- package/dist/components/shared/product-release/product-release-card.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +4 -3
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +3 -2
- package/dist/contexts/endpoints-runtime-context.d.ts +28 -0
- package/dist/contexts/endpoints-runtime-context.d.ts.map +1 -0
- package/dist/contexts/index.cjs +13 -0
- package/dist/contexts/index.cjs.map +1 -0
- package/dist/contexts/index.d.ts +24 -0
- package/dist/contexts/index.d.ts.map +1 -0
- package/dist/contexts/index.js +13 -0
- package/dist/contexts/index.js.map +1 -0
- package/dist/hooks/index.cjs +5 -2
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +4 -1
- package/dist/hooks/use-access-code-integration.d.ts +48 -0
- package/dist/hooks/use-access-code-integration.d.ts.map +1 -0
- package/dist/hooks/use-contact-submission.d.ts.map +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -6
- package/dist/utils/access-code-client.d.ts +21 -37
- package/dist/utils/access-code-client.d.ts.map +1 -1
- package/dist/utils/index.cjs +10 -51
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js +11 -47
- package/dist/utils/index.js.map +1 -1
- package/package.json +7 -1
- package/src/components/announcement-bar.tsx +25 -3
- package/src/components/navigation/navigation-sidebar.tsx +3 -1
- package/src/components/shared/product-release/product-release-card-skeleton.tsx +66 -70
- package/src/components/shared/product-release/product-release-card.tsx +194 -242
- package/src/contexts/endpoints-runtime-context.tsx +68 -0
- package/src/contexts/index.ts +29 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/use-access-code-integration.ts +107 -0
- package/src/hooks/use-contact-submission.ts +6 -2
- package/src/utils/access-code-client.ts +32 -75
- package/dist/chunk-25LVV26X.cjs.map +0 -1
- package/dist/chunk-3YH2M76N.cjs.map +0 -1
- package/dist/chunk-E6Q6UGDK.js.map +0 -1
- package/dist/chunk-XGL5FKIK.js.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
|
|
3
|
+
// src/contexts/endpoints-runtime-context.tsx
|
|
4
|
+
var _react = require('react');
|
|
5
|
+
var EndpointsRuntimeContext = _react.createContext.call(void 0, null);
|
|
6
|
+
function useEndpointsRuntime() {
|
|
7
|
+
return _react.useContext.call(void 0, EndpointsRuntimeContext);
|
|
8
|
+
}
|
|
9
|
+
function useRequiredEndpointsRuntime() {
|
|
10
|
+
const v = _react.useContext.call(void 0, EndpointsRuntimeContext);
|
|
11
|
+
if (!v) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
"[endpoints-runtime] hook called outside an <EndpointsRuntimeContext.Provider>. Hub: mount <HubRuntimeProvider> in your providers tree. Embedded app: mount your own provider with proxied URLs at the tree root. Tests/Storybook: wrap render() in <EndpointsRuntimeContext.Provider value={mocked}>."
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
return v;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
exports.EndpointsRuntimeContext = EndpointsRuntimeContext; exports.useEndpointsRuntime = useEndpointsRuntime; exports.useRequiredEndpointsRuntime = useRequiredEndpointsRuntime;
|
|
24
|
+
//# sourceMappingURL=chunk-27APPAJN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-27APPAJN.cjs","../src/contexts/endpoints-runtime-context.tsx"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACA;ACqBA,8BAA0C;AAenC,IAAM,wBAAA,EAA0B,kCAAA,IAA2C,CAAA;AAO3E,SAAS,mBAAA,CAAA,EAA+C;AAC7D,EAAA,OAAO,+BAAA,uBAAkC,CAAA;AAC3C;AASO,SAAS,2BAAA,CAAA,EAAgD;AAC9D,EAAA,MAAM,EAAA,EAAI,+BAAA,uBAAkC,CAAA;AAC5C,EAAA,GAAA,CAAI,CAAC,CAAA,EAAG;AACN,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,IAIF,CAAA;AAAA,EACF;AACA,EAAA,OAAO,CAAA;AACT;ADlDA;AACA;AACE;AACA;AACA;AACF,gLAAC","file":"/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-27APPAJN.cjs","sourcesContent":[null,"'use client'\n\n/**\n * Endpoints runtime — sibling of ChatRuntime. Carries the API path\n * literals consumed by oss-lib components/hooks/utils so a host\n * application can override them (e.g. when running behind a reverse\n * proxy as `user1.openframe.ai` → `/api/mingo-guide/*`).\n *\n * The hub mounts `<HubRuntimeProvider>` at root with the\n * canonical hub paths; an embedded app mounts its own provider with\n * remapped paths. The pattern mirrors ChatRuntimeContext exactly:\n *\n * - `useEndpointsRuntime()` returns null when no provider is mounted.\n * For optional consumers that should gracefully no-op without one.\n * - `useRequiredEndpointsRuntime()` throws on missing provider — for\n * hooks/components that cannot function without endpoints.\n *\n * IMPORTANT for embedders: memoize the value passed to\n * `<EndpointsRuntimeContext.Provider value={...}>` (e.g. React.useMemo).\n * Reference changes invalidate downstream effect dependency arrays and\n * trigger unnecessary re-fetches.\n */\n\nimport { createContext, useContext } from 'react'\n\nexport interface EndpointsRuntime {\n /** GET active announcement (used by `<AnnouncementBar>` polling). */\n announcementsUrl: string\n accessCode: {\n /** POST validate access code. */\n validateUrl: string\n /** POST consume / redeem access code after registration. */\n consumeUrl: string\n }\n /** POST contact-form submission. */\n contactUrl: string\n}\n\nexport const EndpointsRuntimeContext = createContext<EndpointsRuntime | null>(null)\n\n/**\n * Optional read — returns null when no provider is mounted. Use for\n * surfaces that should silently skip the fetch (e.g. announcement\n * polling on a page rendered outside the provider tree).\n */\nexport function useEndpointsRuntime(): EndpointsRuntime | null {\n return useContext(EndpointsRuntimeContext)\n}\n\n/**\n * Strict variant — throws on missing provider. Use for consumers that\n * cannot function without an endpoint (form submission, code\n * validation). In tests/Storybook, wrap with the hub's\n * `<HubRuntimeProvider>` or a stub\n * `<EndpointsRuntimeContext.Provider value={mockedEndpoints}>`.\n */\nexport function useRequiredEndpointsRuntime(): EndpointsRuntime {\n const v = useContext(EndpointsRuntimeContext)\n if (!v) {\n throw new Error(\n '[endpoints-runtime] hook called outside an <EndpointsRuntimeContext.Provider>. ' +\n 'Hub: mount <HubRuntimeProvider> in your providers tree. ' +\n 'Embedded app: mount your own provider with proxied URLs at the tree root. ' +\n 'Tests/Storybook: wrap render() in <EndpointsRuntimeContext.Provider value={mocked}>.',\n )\n }\n return v\n}\n"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useRequiredEndpointsRuntime
|
|
4
|
+
} from "./chunk-MJNXIEV2.js";
|
|
2
5
|
import {
|
|
3
6
|
FlamingoLogo,
|
|
4
7
|
MiamiCyberGangLogoFaceOnly,
|
|
@@ -1404,13 +1407,14 @@ function useContactSubmission(options = {}) {
|
|
|
1404
1407
|
const { userId, successRedirectUrl, successToastMessage, onSuccess } = options;
|
|
1405
1408
|
const { toast: toast2 } = useToast();
|
|
1406
1409
|
const router = useRouter();
|
|
1410
|
+
const { contactUrl } = useRequiredEndpointsRuntime();
|
|
1407
1411
|
const [isSubmitting, setIsSubmitting] = useState13(false);
|
|
1408
1412
|
const [isSuccess, setIsSuccess] = useState13(false);
|
|
1409
1413
|
const submit = useCallback6(async (formData) => {
|
|
1410
1414
|
if (isSubmitting) return;
|
|
1411
1415
|
setIsSubmitting(true);
|
|
1412
1416
|
try {
|
|
1413
|
-
const response = await fetch(
|
|
1417
|
+
const response = await fetch(contactUrl, {
|
|
1414
1418
|
method: "POST",
|
|
1415
1419
|
headers: { "Content-Type": "application/json" },
|
|
1416
1420
|
body: JSON.stringify({
|
|
@@ -1440,7 +1444,7 @@ function useContactSubmission(options = {}) {
|
|
|
1440
1444
|
} finally {
|
|
1441
1445
|
setIsSubmitting(false);
|
|
1442
1446
|
}
|
|
1443
|
-
}, [isSubmitting, toast2, userId, successToastMessage]);
|
|
1447
|
+
}, [isSubmitting, toast2, userId, successToastMessage, contactUrl]);
|
|
1444
1448
|
useEffect9(() => {
|
|
1445
1449
|
if (isSuccess && successRedirectUrl) {
|
|
1446
1450
|
console.log("\u{1F680} Contact submission successful, redirecting to:", successRedirectUrl);
|
|
@@ -3184,6 +3188,108 @@ function useNearViewport(rootMargin = "500px") {
|
|
|
3184
3188
|
return { ref, isNear };
|
|
3185
3189
|
}
|
|
3186
3190
|
|
|
3191
|
+
// src/hooks/use-access-code-integration.ts
|
|
3192
|
+
import React2 from "react";
|
|
3193
|
+
|
|
3194
|
+
// src/utils/access-code-client.ts
|
|
3195
|
+
async function validateAccessCode(email, code, endpoints) {
|
|
3196
|
+
try {
|
|
3197
|
+
const response = await fetch(endpoints.validateUrl, {
|
|
3198
|
+
method: "POST",
|
|
3199
|
+
headers: {
|
|
3200
|
+
"Content-Type": "application/json"
|
|
3201
|
+
},
|
|
3202
|
+
body: JSON.stringify({ email, code })
|
|
3203
|
+
});
|
|
3204
|
+
if (!response.ok) {
|
|
3205
|
+
const error = await response.json().catch(() => ({}));
|
|
3206
|
+
throw new Error(error.error || "Validation request failed");
|
|
3207
|
+
}
|
|
3208
|
+
return await response.json();
|
|
3209
|
+
} catch (error) {
|
|
3210
|
+
return {
|
|
3211
|
+
valid: false,
|
|
3212
|
+
message: error instanceof Error ? error.message : "Validation failed"
|
|
3213
|
+
};
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
async function consumeAccessCode(email, code, endpoints) {
|
|
3217
|
+
try {
|
|
3218
|
+
const response = await fetch(endpoints.consumeUrl, {
|
|
3219
|
+
method: "POST",
|
|
3220
|
+
headers: {
|
|
3221
|
+
"Content-Type": "application/json"
|
|
3222
|
+
},
|
|
3223
|
+
body: JSON.stringify({ email, code })
|
|
3224
|
+
});
|
|
3225
|
+
if (!response.ok) {
|
|
3226
|
+
const error = await response.json().catch(() => ({}));
|
|
3227
|
+
throw new Error(error.error || "Consumption request failed");
|
|
3228
|
+
}
|
|
3229
|
+
return await response.json();
|
|
3230
|
+
} catch (error) {
|
|
3231
|
+
return {
|
|
3232
|
+
success: false,
|
|
3233
|
+
consumed: false,
|
|
3234
|
+
message: error instanceof Error ? error.message : "Consumption failed"
|
|
3235
|
+
};
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
async function validateAndConsumeAccessCode(email, code, endpoints) {
|
|
3239
|
+
const validation = await validateAccessCode(email, code, endpoints);
|
|
3240
|
+
if (!validation.valid) {
|
|
3241
|
+
return validation;
|
|
3242
|
+
}
|
|
3243
|
+
const consumption = await consumeAccessCode(email, code, endpoints);
|
|
3244
|
+
return {
|
|
3245
|
+
...validation,
|
|
3246
|
+
consumed: consumption.consumed,
|
|
3247
|
+
message: consumption.consumed ? `Access granted for ${validation.cohort_name}` : consumption.message || validation.message
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
// src/hooks/use-access-code-integration.ts
|
|
3252
|
+
function useAccessCodeIntegration() {
|
|
3253
|
+
const runtime = useRequiredEndpointsRuntime();
|
|
3254
|
+
const endpoints = runtime.accessCode;
|
|
3255
|
+
const [isValidating, setIsValidating] = React2.useState(false);
|
|
3256
|
+
const [isConsuming, setIsConsuming] = React2.useState(false);
|
|
3257
|
+
const validate = async (email, code) => {
|
|
3258
|
+
setIsValidating(true);
|
|
3259
|
+
try {
|
|
3260
|
+
return await validateAccessCode(email, code, endpoints);
|
|
3261
|
+
} finally {
|
|
3262
|
+
setIsValidating(false);
|
|
3263
|
+
}
|
|
3264
|
+
};
|
|
3265
|
+
const consume = async (email, code) => {
|
|
3266
|
+
setIsConsuming(true);
|
|
3267
|
+
try {
|
|
3268
|
+
return await consumeAccessCode(email, code, endpoints);
|
|
3269
|
+
} finally {
|
|
3270
|
+
setIsConsuming(false);
|
|
3271
|
+
}
|
|
3272
|
+
};
|
|
3273
|
+
const validateAndConsume = async (email, code) => {
|
|
3274
|
+
setIsValidating(true);
|
|
3275
|
+
setIsConsuming(true);
|
|
3276
|
+
try {
|
|
3277
|
+
return await validateAndConsumeAccessCode(email, code, endpoints);
|
|
3278
|
+
} finally {
|
|
3279
|
+
setIsValidating(false);
|
|
3280
|
+
setIsConsuming(false);
|
|
3281
|
+
}
|
|
3282
|
+
};
|
|
3283
|
+
return {
|
|
3284
|
+
validate,
|
|
3285
|
+
consume,
|
|
3286
|
+
validateAndConsume,
|
|
3287
|
+
isValidating,
|
|
3288
|
+
isConsuming,
|
|
3289
|
+
isProcessing: isValidating || isConsuming
|
|
3290
|
+
};
|
|
3291
|
+
}
|
|
3292
|
+
|
|
3187
3293
|
export {
|
|
3188
3294
|
useAutoLimitTags,
|
|
3189
3295
|
platformIcons,
|
|
@@ -3203,6 +3309,9 @@ export {
|
|
|
3203
3309
|
getPlatformSlogan,
|
|
3204
3310
|
getSmallPlatformIcon,
|
|
3205
3311
|
getPlatformIconComponent,
|
|
3312
|
+
validateAccessCode,
|
|
3313
|
+
consumeAccessCode,
|
|
3314
|
+
validateAndConsumeAccessCode,
|
|
3206
3315
|
ToolTypeValues,
|
|
3207
3316
|
toolLabels,
|
|
3208
3317
|
useDebounce,
|
|
@@ -3266,6 +3375,7 @@ export {
|
|
|
3266
3375
|
useCursorPaginationState,
|
|
3267
3376
|
createNatsClient,
|
|
3268
3377
|
useNatsClient,
|
|
3269
|
-
useNearViewport
|
|
3378
|
+
useNearViewport,
|
|
3379
|
+
useAccessCodeIntegration
|
|
3270
3380
|
};
|
|
3271
|
-
//# sourceMappingURL=chunk-
|
|
3381
|
+
//# sourceMappingURL=chunk-D6BNDYZK.js.map
|