Merge branch 'dev' into cl/hexclave-pr3

This commit is contained in:
Konsti Wohlwend 2026-05-29 15:21:29 -07:00 committed by GitHub
commit fe62423567
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 6 deletions

View File

@ -571,3 +571,6 @@ A: Use `jiti` to import the user's config module, matching `stack config push`,
## Q: What is needed to put the legacy Fumadocs `docs/` app back into the Hexclave pnpm workspace?
A: Add `docs` to `pnpm-workspace.yaml`, keep the package named `@hexclave/docs`, use `workspace:*` for `@hexclave/next` and `@hexclave/shared`, and update actual app imports from `@stackframe/stack`/`@stackframe/stack-shared` to `@hexclave/next`/`@hexclave/shared`. Docs app runtime env reads should prefer `NEXT_PUBLIC_HEXCLAVE_*`/`HEXCLAVE_*` while retaining legacy `STACK_*` fallbacks.
## Q: How should template React contexts avoid duplicate client-bundle context identities?
A: Define exported provider contexts such as `StackContext` and `TranslationContext` through `createGlobal` from `@stackframe/stack-shared/dist/utils/globals`, not direct `React.createContext(...)` exports. That helper stores the React context under `globalThis[Symbol.for("__hexclave-globals")]`, so duplicated SDK bundles still share the same provider/consumer context object.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,8 +1,15 @@
"use client";
import React from "react";
import { createGlobal } from "@stackframe/stack-shared/dist/utils/globals";
import type { StackClientApp } from "../lib/stack-app/apps/interfaces/client-app";
export const StackContext = React.createContext<null | {
type StackContextValue = {
app: StackClientApp<true>,
}>(null);
};
export const StackContext = createGlobal<React.Context<StackContextValue | null>>(
"StackContext",
() => React.createContext<StackContextValue | null>(null),
);
StackContext.displayName ??= "StackContext";

View File

@ -1,11 +1,18 @@
"use client";
import { createContext, useContext } from "react";
import React from "react";
import { createGlobal } from "@stackframe/stack-shared/dist/utils/globals";
export const TranslationContext = createContext<null | {
type TranslationContextValue = {
quetzalKeys: Map<string, string>,
quetzalLocale: Map<string, string>,
}>(null);
};
export const TranslationContext = createGlobal<React.Context<TranslationContextValue | null>>(
"TranslationContext",
() => React.createContext<TranslationContextValue | null>(null),
);
TranslationContext.displayName ??= "TranslationContext";
export function TranslationProviderClient(props: {
children: React.ReactNode,