@xforge-dev/forge-kit 0.17.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/jobs-provider.d.ts +7 -0
- package/dist/jobs-provider.js +9 -0
- package/dist/jobs-server.d.ts +12 -0
- package/dist/jobs-server.js +29 -0
- package/dist/jobs-snapshot.d.ts +2 -0
- package/dist/jobs-snapshot.js +2839 -0
- package/dist/jobs.d.ts +59 -0
- package/dist/jobs.js +127 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +1 -0
- package/package.json +3 -2
package/dist/client.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export { ForgeLogo, type ForgeLogoProps } from './forge-logo.js';
|
|
|
12
12
|
export { ForgeSupportButton, BUY_ME_A_COFFEE_URL, BUY_ME_A_COFFEE_BUTTON, FORGE_SPONSOR_TIERS, ForgeSupporterBadge, type ForgeSupporterTier, type ForgeSupportButtonProps, } from './support-button.js';
|
|
13
13
|
export { ForgeIgnInput, FORGE_ACCENTED_LETTERS, FORGE_NO_AUTOFILL, type ForgeIgnInputProps, } from './ign-input.js';
|
|
14
14
|
export { ForgeFooter, type ForgeFooterProps } from './forge-footer.js';
|
|
15
|
+
export { ForgeJobsProvider } from './jobs-provider.js';
|
package/dist/client.js
CHANGED
|
@@ -13,3 +13,4 @@ export { ForgeLogo } from './forge-logo.js';
|
|
|
13
13
|
export { ForgeSupportButton, BUY_ME_A_COFFEE_URL, BUY_ME_A_COFFEE_BUTTON, FORGE_SPONSOR_TIERS, ForgeSupporterBadge, } from './support-button.js';
|
|
14
14
|
export { ForgeIgnInput, FORGE_ACCENTED_LETTERS, FORGE_NO_AUTOFILL, } from './ign-input.js';
|
|
15
15
|
export { ForgeFooter } from './forge-footer.js';
|
|
16
|
+
export { ForgeJobsProvider } from './jobs-provider.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export { isForgeAuthConfigured } from './config.js';
|
|
|
7
7
|
export * from './theme.js';
|
|
8
8
|
export { FORGE_BRANDS, FORGE_CDN, type ForgeBrand, type ForgeBrandId } from './brand.js';
|
|
9
9
|
export { HANDOFF_PATH, LEGACY_ORIGINS, LEGACY_ROOT_DOMAIN, decideLegacy, legacyReceiveHtml, legacySendHtml, type LegacyDecision } from './legacy.js';
|
|
10
|
+
export * from './jobs.js';
|
package/dist/index.js
CHANGED
|
@@ -7,3 +7,4 @@ export { isForgeAuthConfigured } from './config.js';
|
|
|
7
7
|
export * from './theme.js';
|
|
8
8
|
export { FORGE_BRANDS, FORGE_CDN } from './brand.js';
|
|
9
9
|
export { HANDOFF_PATH, LEGACY_ORIGINS, LEGACY_ROOT_DOMAIN, decideLegacy, legacyReceiveHtml, legacySendHtml } from './legacy.js';
|
|
10
|
+
export * from './jobs.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { type JobCatalog } from './jobs.js';
|
|
3
|
+
/** Installs the server-fetched catalog before the children render, so client lookups agree with the server. */
|
|
4
|
+
export declare function ForgeJobsProvider({ catalog, children }: {
|
|
5
|
+
catalog: JobCatalog;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}): ReactElement;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { getJobCatalog, setJobCatalog } from './jobs.js';
|
|
4
|
+
/** Installs the server-fetched catalog before the children render, so client lookups agree with the server. */
|
|
5
|
+
export function ForgeJobsProvider({ catalog, children }) {
|
|
6
|
+
if (catalog.updated !== getJobCatalog().updated)
|
|
7
|
+
setJobCatalog(catalog);
|
|
8
|
+
return _jsx(_Fragment, { children: children });
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type JobCatalog } from './jobs.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches the shared job catalog (Next's fetch cache, one hour by default), validates it and installs it
|
|
4
|
+
* as the registry. The fetch gives up after `timeoutMs` (default 3s). Any failure, timeout included, leaves the
|
|
5
|
+
* current catalog in place and warns once per distinct error.
|
|
6
|
+
*/
|
|
7
|
+
export declare function refreshJobCatalog(opts?: {
|
|
8
|
+
url?: string;
|
|
9
|
+
revalidate?: number;
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
}): Promise<JobCatalog>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { getJobCatalog, parseJobCatalog, setJobCatalog, JOB_CATALOG_URL } from './jobs.js';
|
|
2
|
+
const warned = new Set();
|
|
3
|
+
/**
|
|
4
|
+
* Fetches the shared job catalog (Next's fetch cache, one hour by default), validates it and installs it
|
|
5
|
+
* as the registry. The fetch gives up after `timeoutMs` (default 3s). Any failure, timeout included, leaves the
|
|
6
|
+
* current catalog in place and warns once per distinct error.
|
|
7
|
+
*/
|
|
8
|
+
export async function refreshJobCatalog(opts = {}) {
|
|
9
|
+
const doFetch = opts.fetch ?? fetch;
|
|
10
|
+
try {
|
|
11
|
+
const res = await doFetch(opts.url ?? JOB_CATALOG_URL, {
|
|
12
|
+
next: { revalidate: opts.revalidate ?? 3600 },
|
|
13
|
+
signal: AbortSignal.timeout(opts.timeoutMs ?? 3000),
|
|
14
|
+
});
|
|
15
|
+
if (!res.ok)
|
|
16
|
+
throw new Error(`job catalog: HTTP ${res.status}`);
|
|
17
|
+
const next = parseJobCatalog(await res.json());
|
|
18
|
+
setJobCatalog(next);
|
|
19
|
+
return next;
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
23
|
+
if (!warned.has(message)) {
|
|
24
|
+
warned.add(message);
|
|
25
|
+
console.warn(`[forge-kit] job catalog refresh failed: ${message}`);
|
|
26
|
+
}
|
|
27
|
+
return getJobCatalog();
|
|
28
|
+
}
|
|
29
|
+
}
|