fixing imports and ssr support + updated remix/nextjs/astro examples

This commit is contained in:
dswbx
2024-12-07 19:31:12 +01:00
parent 94cc4042d3
commit 3932396084
40 changed files with 125 additions and 130 deletions

View File

@@ -1,4 +1,3 @@
//import { notifications } from "@mantine/notifications";
import { getDefaultConfig, getDefaultSchema } from "modules/ModuleManager";
import { createContext, startTransition, useContext, useEffect, useRef, useState } from "react";
import type { ModuleConfigs, ModuleSchemas } from "../../modules";
@@ -101,20 +100,6 @@ export function BkndProvider({
);
}
type BkndWindowContext = {
user?: object;
logout_route: string;
};
export function useBkndWindowContext(): BkndWindowContext {
if (typeof window !== "undefined" && window.__BKND__) {
return window.__BKND__ as any;
} else {
return {
logout_route: "/api/auth/logout"
};
}
}
export function useBknd({ withSecrets }: { withSecrets?: boolean } = {}): BkndContext {
const ctx = useContext(BkndContext);
if (withSecrets) ctx.requireSecrets();

View File

@@ -1,7 +1,7 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import type { TApiUser } from "Api";
import { createContext, useContext, useEffect, useState } from "react";
import { useBkndWindowContext } from "ui/client/BkndProvider";
//import { useBkndWindowContext } from "ui/client/BkndProvider";
import { AppQueryClient } from "./utils/AppQueryClient";
const ClientContext = createContext<{ baseUrl: string; client: AppQueryClient }>({
@@ -89,3 +89,17 @@ export const useBaseUrl = () => {
const context = useContext(ClientContext);
return context.baseUrl;
};
type BkndWindowContext = {
user?: object;
logout_route: string;
};
export function useBkndWindowContext(): BkndWindowContext {
if (typeof window !== "undefined" && window.__BKND__) {
return window.__BKND__ as any;
} else {
return {
logout_route: "/api/auth/logout"
};
}
}

View File

@@ -0,0 +1 @@
export { BkndProvider, useBknd } from "./BkndProvider";

View File

@@ -1,5 +1,10 @@
export { ClientProvider, type ClientProviderProps, useClient, useBaseUrl } from "./ClientProvider";
export { BkndProvider, useBknd } from "./BkndProvider";
export {
ClientProvider,
useBkndWindowContext,
type ClientProviderProps,
useClient,
useBaseUrl
} from "./ClientProvider";
export { useAuth } from "./schema/auth/use-auth";
export { Api } from "../../Api";

View File

@@ -1,4 +1,4 @@
import { useBknd } from "ui/client";
import { useBknd } from "ui/client/bknd";
export function useBkndAuth() {
//const client = useClient();

View File

@@ -11,7 +11,7 @@ import {
fieldsSchema,
relationsSchema
} from "data/data-schema";
import { useBknd } from "ui/client";
import { useBknd } from "ui/client/bknd";
import type { TSchemaActions } from "ui/client/schema/actions";
export function useBkndData() {

View File

@@ -1,4 +1,4 @@
import { useBknd } from "ui/client";
import { useBknd } from "ui/client/bknd";
export function useBkndSystem() {
const { config, schema, actions: bkndActions } = useBknd();

View File

@@ -1,4 +1,4 @@
import { useBknd } from "ui";
import { useBknd } from "ui/client/bknd";
export function useTheme(): { theme: "light" | "dark" } {
const b = useBknd();