@farthershore/farthershore-js 0.1.2 → 0.1.3
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/components/root.tsx"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/components/root.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/D,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,kBAAkB,CAAC;IAC3B;gEAC4D;IAC5D,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B;2CACuC;IACvC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,yEAAyE;IACzE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC;IAC1C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAOD;gEACgE;AAChE,wBAAgB,OAAO,IAAI,SAAS,CAMnC;AA2CD,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,qBAAqB,2CAM1E"}
|
package/dist/components/root.js
CHANGED
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
// <FartherShoreRoot> — the batteries-included mount point. One wrapper gives a
|
|
3
|
+
// host app everything self-managed:
|
|
4
|
+
//
|
|
5
|
+
// const fs = createFartherShoreClient({ coreUrl });
|
|
6
|
+
// <FartherShoreRoot client={fs} clerk={{ publishableKey }}>
|
|
7
|
+
// <YourApp/> // useFsAuth(), useBoot(), data components — all live
|
|
8
|
+
// </FartherShoreRoot>
|
|
9
|
+
//
|
|
10
|
+
// It owns: the client provider, the bootstrap gate (one cached resolve round-
|
|
11
|
+
// trip, splash + error states), the theme root (brand color from the product's
|
|
12
|
+
// branding), and the auth layer (Clerk satellite or persona — picked from the
|
|
13
|
+
// environment's auth strategy automatically). No host glue.
|
|
14
|
+
import { createContext, useContext } from "react";
|
|
15
|
+
import { FartherShoreProvider, useBootstrap } from "../react/index.js";
|
|
3
16
|
import { FsThemeProvider } from "./theme.js";
|
|
4
17
|
import { FsAuthProvider } from "./auth.js";
|
|
18
|
+
// The resolved Bootstrap, provided by the Root's gate once resolve succeeds —
|
|
19
|
+
// a single source of truth (NOT a second async read, whose state would start
|
|
20
|
+
// null on a consumer's first render even with the client's promise memoized).
|
|
21
|
+
const BootCtx = createContext(null);
|
|
5
22
|
/** The resolved Bootstrap. Children of `<FartherShoreRoot>` render only after
|
|
6
23
|
* resolve succeeds, so this never suspends or returns null. */
|
|
7
24
|
export function useBoot() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (!boot.data) {
|
|
12
|
-
throw new Error("useBoot must be used inside <FartherShoreRoot> (after resolve)");
|
|
25
|
+
const boot = useContext(BootCtx);
|
|
26
|
+
if (!boot) {
|
|
27
|
+
throw new Error("useBoot must be used inside <FartherShoreRoot>");
|
|
13
28
|
}
|
|
14
|
-
return boot
|
|
29
|
+
return boot;
|
|
15
30
|
}
|
|
16
31
|
function DefaultSplash({ label }) {
|
|
17
32
|
return _jsx("div", { className: "fs-app fs-splash", children: label });
|
|
18
33
|
}
|
|
19
34
|
function Gate({ appearance, clerk, splash, renderError, children, }) {
|
|
20
|
-
const fs = useFartherShore();
|
|
21
|
-
void fs;
|
|
22
35
|
const boot = useBootstrap();
|
|
23
36
|
if (boot.loading)
|
|
24
37
|
return _jsx(_Fragment, { children: splash ?? _jsx(DefaultSplash, { label: "Loading\u2026" }) });
|
|
@@ -33,7 +46,7 @@ function Gate({ appearance, clerk, splash, renderError, children, }) {
|
|
|
33
46
|
// `environment` is null on hosts with no env record (defensive: treat as
|
|
34
47
|
// Clerk, the platform default strategy).
|
|
35
48
|
const strategy = boot.data.environment?.authStrategy ?? "clerk";
|
|
36
|
-
return (_jsx(FsThemeProvider, { appearance: merged, children: _jsx(FsAuthProvider, { strategy: strategy, clerk: clerk, children: children }) }));
|
|
49
|
+
return (_jsx(BootCtx.Provider, { value: boot.data, children: _jsx(FsThemeProvider, { appearance: merged, children: _jsx(FsAuthProvider, { strategy: strategy, clerk: clerk, children: children }) }) }));
|
|
37
50
|
}
|
|
38
51
|
export function FartherShoreRoot({ client, ...rest }) {
|
|
39
52
|
return (_jsx(FartherShoreProvider, { client: client, children: _jsx(Gate, { ...rest }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/components/root.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/components/root.tsx"],"names":[],"mappings":";AAAA,+EAA+E;AAC/E,oCAAoC;AACpC,EAAE;AACF,sDAAsD;AACtD,8DAA8D;AAC9D,kFAAkF;AAClF,wBAAwB;AACxB,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,4DAA4D;AAE5D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAqB,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,cAAc,EAAsB,MAAM,WAAW,CAAC;AAiB/D,8EAA8E;AAC9E,6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,OAAO,CAAC;IAEhE,OAAO,CACL,KAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,CAAC,IAAI,YAChC,KAAC,eAAe,IAAC,UAAU,EAAE,MAAM,YACjC,KAAC,cAAc,IAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,YAC7C,QAAQ,GACM,GACD,GACD,CACpB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAyB;IACzE,OAAO,CACL,KAAC,oBAAoB,IAAC,MAAM,EAAE,MAAM,YAClC,KAAC,IAAI,OAAK,IAAI,GAAI,GACG,CACxB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farthershore/farthershore-js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Farther Shore Frontend SDK — the browser integration layer between static frontends and the Farther Shore platform (Core + Gateway).",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|