@typestyles/next 0.0.0-unstable.015bb9921923

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/index.js ADDED
@@ -0,0 +1,57 @@
1
+ // src/server.ts
2
+ import { collectStyles, getRegisteredCss } from "typestyles/server";
3
+ async function collectStylesFromComponent(component) {
4
+ const { renderToString } = await import("react-dom/server");
5
+ const { css } = collectStyles(() => renderToString(component));
6
+ return css;
7
+ }
8
+ async function getTypestylesMetadata(component) {
9
+ return collectStylesFromComponent(component);
10
+ }
11
+
12
+ // src/client.tsx
13
+ import { useState, useEffect, useServerInsertedHTML, useSyncExternalStore } from "react";
14
+ import { getRegisteredCss as getRegisteredCss2 } from "typestyles/server";
15
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
+ function useTypestyles() {
17
+ return useSyncExternalStore(
18
+ () => () => {
19
+ },
20
+ () => getRegisteredCss2(),
21
+ () => ""
22
+ );
23
+ }
24
+ function TypestylesStylesheet({ children }) {
25
+ const [css, setCss] = useState("");
26
+ useServerInsertedHTML(() => {
27
+ const registeredCss = getRegisteredCss2();
28
+ if (registeredCss) {
29
+ return /* @__PURE__ */ jsx("style", { id: "typestyles", dangerouslySetInnerHTML: { __html: registeredCss } });
30
+ }
31
+ return null;
32
+ });
33
+ useEffect(() => {
34
+ setCss(getRegisteredCss2());
35
+ }, []);
36
+ if (children) {
37
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
38
+ children,
39
+ /* @__PURE__ */ jsx("style", { id: "typestyles-client", dangerouslySetInnerHTML: { __html: css } })
40
+ ] });
41
+ }
42
+ return null;
43
+ }
44
+ function createTypestylesLayout(layout) {
45
+ return function TypestylesLayout(props) {
46
+ return /* @__PURE__ */ jsx(TypestylesStylesheet, { children: layout(props) });
47
+ };
48
+ }
49
+ export {
50
+ TypestylesStylesheet,
51
+ collectStylesFromComponent,
52
+ createTypestylesLayout,
53
+ getRegisteredCss,
54
+ getTypestylesMetadata,
55
+ useServerInsertedHTML,
56
+ useTypestyles
57
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/server.ts
31
+ var server_exports = {};
32
+ __export(server_exports, {
33
+ collectStylesFromComponent: () => collectStylesFromComponent,
34
+ getRegisteredCss: () => import_server.getRegisteredCss,
35
+ getTypestylesMetadata: () => getTypestylesMetadata
36
+ });
37
+ module.exports = __toCommonJS(server_exports);
38
+ var import_server = require("typestyles/server");
39
+ async function collectStylesFromComponent(component) {
40
+ const { renderToString } = await import("react-dom/server");
41
+ const { css } = (0, import_server.collectStyles)(() => renderToString(component));
42
+ return css;
43
+ }
44
+ async function getTypestylesMetadata(component) {
45
+ return collectStylesFromComponent(component);
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ collectStylesFromComponent,
50
+ getRegisteredCss,
51
+ getTypestylesMetadata
52
+ });
package/dist/server.js ADDED
@@ -0,0 +1,15 @@
1
+ // src/server.ts
2
+ import { collectStyles, getRegisteredCss } from "typestyles/server";
3
+ async function collectStylesFromComponent(component) {
4
+ const { renderToString } = await import("react-dom/server");
5
+ const { css } = collectStyles(() => renderToString(component));
6
+ return css;
7
+ }
8
+ async function getTypestylesMetadata(component) {
9
+ return collectStylesFromComponent(component);
10
+ }
11
+ export {
12
+ collectStylesFromComponent,
13
+ getRegisteredCss,
14
+ getTypestylesMetadata
15
+ };
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@typestyles/next",
3
+ "version": "0.0.0-unstable.015bb9921923",
4
+ "description": "Next.js integration for typestyles SSR",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./src/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./src/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ },
15
+ "./server": {
16
+ "types": "./src/server.d.ts",
17
+ "import": "./dist/server.js",
18
+ "require": "./dist/server.cjs"
19
+ },
20
+ "./client": {
21
+ "types": "./src/client.d.ts",
22
+ "import": "./dist/client.js",
23
+ "require": "./dist/client.cjs",
24
+ "default": "./dist/client.js"
25
+ },
26
+ "./build": {
27
+ "types": "./src/build.d.ts",
28
+ "import": "./dist/build.js",
29
+ "require": "./dist/build.cjs"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "src"
35
+ ],
36
+ "keywords": [
37
+ "next",
38
+ "nextjs",
39
+ "typestyles",
40
+ "ssr",
41
+ "react"
42
+ ],
43
+ "license": "MIT",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "https://github.com/dbanksdesign/typestyles",
47
+ "directory": "packages/next"
48
+ },
49
+ "peerDependencies": {
50
+ "next": ">=13.0.0",
51
+ "react": ">=18.0.0",
52
+ "react-dom": ">=18.0.0",
53
+ "typestyles": ">=0.1.0",
54
+ "webpack": ">=5.0.0"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "next": {
58
+ "optional": false
59
+ },
60
+ "react": {
61
+ "optional": false
62
+ },
63
+ "react-dom": {
64
+ "optional": false
65
+ },
66
+ "webpack": {
67
+ "optional": true
68
+ }
69
+ },
70
+ "devDependencies": {
71
+ "vitest": "^3.0.0",
72
+ "@types/node": "^25.2.1",
73
+ "@types/react": "^18.3.12",
74
+ "@types/react-dom": "^18.3.1",
75
+ "next": "^14.0.0",
76
+ "react": "^18.0.0",
77
+ "react-dom": "^18.0.0",
78
+ "tsup": "^8.0.0",
79
+ "typestyles": "0.0.0-unstable.015bb9921923",
80
+ "typescript": "^5.4.0",
81
+ "webpack": "^5.97.1"
82
+ },
83
+ "scripts": {
84
+ "build": "tsup",
85
+ "test": "vitest run",
86
+ "typecheck": "tsc --noEmit"
87
+ }
88
+ }
package/src/build.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { NextConfig } from 'next';
2
+
3
+ export interface TypestylesExtractManifestV1 {
4
+ version: 1;
5
+ css: string;
6
+ }
7
+
8
+ export interface BuildTypestylesForNextOptions {
9
+ root: string;
10
+ modules: string[];
11
+ cssOutFile: string;
12
+ manifestOutFile?: string;
13
+ manifestCssPath?: string;
14
+ }
15
+
16
+ export declare function buildTypestylesForNext(
17
+ options: BuildTypestylesForNextOptions,
18
+ ): Promise<void>;
19
+
20
+ export interface WithTypestylesExtractOptions {
21
+ disableClientRuntime?: boolean;
22
+ }
23
+
24
+ export declare function withTypestylesExtract(
25
+ nextConfig?: NextConfig,
26
+ options?: WithTypestylesExtractOptions,
27
+ ): NextConfig;
@@ -0,0 +1,58 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import type { NextConfig } from 'next';
3
+ import type { Configuration } from 'webpack';
4
+ import { withTypestylesExtract } from './build.js';
5
+
6
+ type WebpackContext = Parameters<NonNullable<NextConfig['webpack']>>[1];
7
+
8
+ describe('withTypestylesExtract', () => {
9
+ it('merges NEXT_PUBLIC_TYPESTYLES_RUNTIME_DISABLED into env for Turbopack + webpack', () => {
10
+ const merged = withTypestylesExtract(
11
+ { env: { CUSTOM: 'x' } },
12
+ { disableClientRuntime: true },
13
+ );
14
+ expect(merged.env).toEqual({
15
+ CUSTOM: 'x',
16
+ NEXT_PUBLIC_TYPESTYLES_RUNTIME_DISABLED: 'true',
17
+ });
18
+ });
19
+
20
+ it('does not override env when disableClientRuntime is false', () => {
21
+ const merged = withTypestylesExtract(
22
+ { env: { CUSTOM: 'x' } },
23
+ { disableClientRuntime: false },
24
+ );
25
+ expect(merged.env).toEqual({ CUSTOM: 'x' });
26
+ });
27
+
28
+ it('chains user webpack() and adds DefinePlugin on the client', async () => {
29
+ const webpackMod = await import('webpack');
30
+ const userWebpack = vi.fn((cfg: { plugins: unknown[] }) => {
31
+ cfg.plugins.push('user-marker');
32
+ return cfg;
33
+ });
34
+ const merged = withTypestylesExtract({ webpack: userWebpack });
35
+ const config = { plugins: [] as unknown[] };
36
+ const result = merged.webpack!(config as Configuration, {
37
+ isServer: false,
38
+ } as WebpackContext);
39
+ expect(userWebpack).toHaveBeenCalled();
40
+ const hasDefine = result.plugins?.some(
41
+ (p: unknown) => p instanceof webpackMod.default.DefinePlugin,
42
+ );
43
+ expect(hasDefine).toBe(true);
44
+ });
45
+
46
+ it('does not add DefinePlugin for server bundles', async () => {
47
+ const webpackMod = await import('webpack');
48
+ const merged = withTypestylesExtract({});
49
+ const config = { plugins: [] as unknown[] };
50
+ const result = merged.webpack!(config as Configuration, {
51
+ isServer: true,
52
+ } as WebpackContext);
53
+ const hasDefine = result.plugins?.some(
54
+ (p: unknown) => p instanceof webpackMod.default.DefinePlugin,
55
+ );
56
+ expect(hasDefine).toBe(false);
57
+ });
58
+ });
package/src/build.ts ADDED
@@ -0,0 +1,112 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { collectStylesFromModules } from 'typestyles/build';
6
+ import type { NextConfig } from 'next';
7
+
8
+ /** Manifest shape written next to extracted CSS (optional). */
9
+ export interface TypestylesExtractManifestV1 {
10
+ version: 1;
11
+ css: string;
12
+ }
13
+
14
+ /** Shape of `require('webpack')` for `DefinePlugin` only (webpack is an optional peer). */
15
+ type WebpackWithDefinePlugin = {
16
+ DefinePlugin: new (definitions: Record<string, string>) => unknown;
17
+ };
18
+
19
+ export interface BuildTypestylesForNextOptions {
20
+ root: string;
21
+ modules: string[];
22
+ cssOutFile: string;
23
+ manifestOutFile?: string;
24
+ manifestCssPath?: string;
25
+ }
26
+
27
+ /**
28
+ * Extract TypeStyles CSS for a Next.js app (run from a script before `next build`, or in CI).
29
+ * Loads each module path (relative to `root`) so side-effect registrations run, then writes CSS.
30
+ */
31
+ export async function buildTypestylesForNext(options: BuildTypestylesForNextOptions): Promise<void> {
32
+ const { root, modules, cssOutFile, manifestOutFile, manifestCssPath } = options;
33
+ const loaders = modules.map((mod) => {
34
+ const abs = resolve(root, mod);
35
+ const href = pathToFileURL(abs).href;
36
+ return () => import(href);
37
+ });
38
+ const css = await collectStylesFromModules(loaders);
39
+ const outAbs = resolve(root, cssOutFile);
40
+ await mkdir(dirname(outAbs), { recursive: true });
41
+ await writeFile(outAbs, css, 'utf8');
42
+ if (manifestOutFile) {
43
+ const manifest: TypestylesExtractManifestV1 = {
44
+ version: 1,
45
+ css: manifestCssPath ?? cssOutFile,
46
+ };
47
+ const manAbs = resolve(root, manifestOutFile);
48
+ await mkdir(dirname(manAbs), { recursive: true });
49
+ await writeFile(manAbs, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8');
50
+ }
51
+ }
52
+
53
+ export interface WithTypestylesExtractOptions {
54
+ /**
55
+ * When true (default), client bundles skip DOM style injection (`__TYPESTYLES_RUNTIME_DISABLED__`).
56
+ * Pair with a global stylesheet from {@link buildTypestylesForNext}.
57
+ */
58
+ disableClientRuntime?: boolean;
59
+ }
60
+
61
+ /**
62
+ * Merge Next.js config so client bundles use pre-extracted CSS only (no runtime `<style>` injection).
63
+ *
64
+ * - **Webpack**: adds `DefinePlugin` for `__TYPESTYLES_RUNTIME_DISABLED__` on client bundles.
65
+ * - **Turbopack** (`next dev --turbo` / Turbopack production): webpack hooks do not run; the same
66
+ * `next.config` `env` entry `NEXT_PUBLIC_TYPESTYLES_RUNTIME_DISABLED` is merged so the client
67
+ * bundle still disables runtime insertion (see `typestyles` `sheet` implementation).
68
+ */
69
+ export function withTypestylesExtract(
70
+ nextConfig: NextConfig = {},
71
+ options: WithTypestylesExtractOptions = {},
72
+ ): NextConfig {
73
+ const disableClientRuntime = options.disableClientRuntime !== false;
74
+
75
+ return {
76
+ ...nextConfig,
77
+ ...(disableClientRuntime
78
+ ? {
79
+ env: {
80
+ ...(typeof nextConfig.env === 'object' &&
81
+ nextConfig.env !== null &&
82
+ !Array.isArray(nextConfig.env)
83
+ ? (nextConfig.env as Record<string, string>)
84
+ : {}),
85
+ NEXT_PUBLIC_TYPESTYLES_RUNTIME_DISABLED: 'true',
86
+ },
87
+ }
88
+ : {}),
89
+ webpack(config, context) {
90
+ const nextWebpack =
91
+ typeof nextConfig.webpack === 'function' ? nextConfig.webpack(config, context) : config;
92
+
93
+ if (disableClientRuntime && !context.isServer) {
94
+ try {
95
+ const require = createRequire(join(process.cwd(), 'package.json'));
96
+ const webpackLib = require('webpack') as WebpackWithDefinePlugin;
97
+ nextWebpack.plugins.push(
98
+ new webpackLib.DefinePlugin({
99
+ __TYPESTYLES_RUNTIME_DISABLED__: JSON.stringify('true'),
100
+ }),
101
+ );
102
+ } catch {
103
+ console.warn(
104
+ '[@typestyles/next/build] Could not load webpack; client bundles may still inject <style>.',
105
+ );
106
+ }
107
+ }
108
+
109
+ return nextWebpack;
110
+ },
111
+ };
112
+ }
@@ -0,0 +1,37 @@
1
+ import type * as React from 'react';
2
+ import type { useSyncExternalStore } from 'react';
3
+
4
+ /**
5
+ * Subscribe to typestyles CSS changes. Use this in client components
6
+ * that need to stay up-to-date with dynamically registered styles.
7
+ */
8
+ export function useTypestyles(): ReturnType<typeof useSyncExternalStore<string>>;
9
+
10
+ /**
11
+ * Re-export of React’s `useServerInsertedHTML` (App Router / streaming SSR).
12
+ * Declared here so consumers get a stable signature even when their `@types/react` predates the hook.
13
+ */
14
+ export function useServerInsertedHTML(
15
+ callback: () => React.ReactNode | null,
16
+ ): void;
17
+
18
+ /**
19
+ * Props for the TypestylesStylesheet component.
20
+ */
21
+ export interface TypestylesStylesheetProps {
22
+ children?: React.ReactNode;
23
+ }
24
+
25
+ /**
26
+ * A React component that renders typestyles CSS.
27
+ */
28
+ export function TypestylesStylesheet(
29
+ props: TypestylesStylesheetProps,
30
+ ): React.JSX.Element | null;
31
+
32
+ /**
33
+ * Create a Next.js layout export that includes typestyles.
34
+ */
35
+ export function createTypestylesLayout<P extends { children?: React.ReactNode }>(
36
+ layout: (props: P) => React.ReactNode,
37
+ ): (props: P) => React.JSX.Element;
package/src/client.tsx ADDED
@@ -0,0 +1,143 @@
1
+ 'use client';
2
+
3
+ import React, { useState, useEffect, useServerInsertedHTML, useSyncExternalStore } from 'react';
4
+ import { getRegisteredCss } from 'typestyles/server';
5
+
6
+ /**
7
+ * Subscribe to typestyles CSS changes. Use this in client components
8
+ * that need to stay up-to-date with dynamically registered styles.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * // components/Styles.tsx
13
+ * 'use client';
14
+ * import { useTypestyles } from '@typestyles/next/client';
15
+ *
16
+ * export function Styles() {
17
+ * useTypestyles();
18
+ * return null;
19
+ * }
20
+ * ```
21
+ */
22
+ export function useTypestyles() {
23
+ return useSyncExternalStore(
24
+ () => () => {},
25
+ () => getRegisteredCss(),
26
+ () => '',
27
+ );
28
+ }
29
+
30
+ /**
31
+ * Collect styles during server rendering for App Router.
32
+ * Use this in a Client Component wrapper that collects styles from its children.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * // components/TypestylesProvider.tsx
37
+ * 'use client';
38
+ *
39
+ * import { useServerInsertedHTML, getRegisteredCss } from '@typestyles/next/client';
40
+ *
41
+ * export function TypestylesProvider({ children }: { children: React.ReactNode }) {
42
+ * useServerInsertedHTML(() => {
43
+ * return (
44
+ * <style
45
+ * id="typestyles"
46
+ * dangerouslySetInnerHTML={{ __html: getRegisteredCss() }}
47
+ * />
48
+ * );
49
+ * });
50
+ * return <>{children}</>;
51
+ * }
52
+ * ```
53
+ */
54
+ export { useServerInsertedHTML };
55
+
56
+ /**
57
+ * Props for the TypestylesStylesheet component.
58
+ */
59
+ export interface TypestylesStylesheetProps {
60
+ /**
61
+ * The children to render (styles will be collected from these).
62
+ * If not provided, only the existing registered CSS will be included.
63
+ */
64
+ children?: React.ReactNode;
65
+ }
66
+
67
+ /**
68
+ * A React component that renders typestyles CSS.
69
+ *
70
+ * For App Router: Use this in your root layout to collect and render styles.
71
+ * Works with both Client Components and React Server Components.
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * // app/layout.tsx
76
+ * import { TypestylesStylesheet } from '@typestyles/next/client';
77
+ *
78
+ * export default function RootLayout({ children }) {
79
+ * return (
80
+ * <html>
81
+ * <head>
82
+ * <TypestylesStylesheet />
83
+ * </head>
84
+ * <body>{children}</body>
85
+ * </html>
86
+ * );
87
+ * }
88
+ * ```
89
+ */
90
+ export function TypestylesStylesheet({ children }: TypestylesStylesheetProps) {
91
+ const [css, setCss] = useState('');
92
+
93
+ useServerInsertedHTML(() => {
94
+ const registeredCss = getRegisteredCss();
95
+ if (registeredCss) {
96
+ return <style id="typestyles" dangerouslySetInnerHTML={{ __html: registeredCss }} />;
97
+ }
98
+ return null;
99
+ });
100
+
101
+ useEffect(() => {
102
+ setCss(getRegisteredCss());
103
+ }, []);
104
+
105
+ if (children) {
106
+ return (
107
+ <>
108
+ {children}
109
+ <style id="typestyles-client" dangerouslySetInnerHTML={{ __html: css }} />
110
+ </>
111
+ );
112
+ }
113
+
114
+ return null;
115
+ }
116
+
117
+ /**
118
+ * Create a Next.js layout export that includes typestyles.
119
+ *
120
+ * @example
121
+ * ```tsx
122
+ * // app/layout.tsx
123
+ * import { createTypestylesLayout } from '@typestyles/next/client';
124
+ *
125
+ * export default createTypestylesLayout(function RootLayout({ children }) {
126
+ * return (
127
+ * <html>
128
+ * <head>
129
+ * <title>My App</title>
130
+ * </head>
131
+ * <body>{children}</body>
132
+ * </html>
133
+ * );
134
+ * });
135
+ * ```
136
+ */
137
+ export function createTypestylesLayout<P extends { children?: React.ReactNode }>(
138
+ layout: (props: P) => React.ReactNode,
139
+ ): (props: P) => React.ReactNode {
140
+ return function TypestylesLayout(props: P) {
141
+ return <TypestylesStylesheet>{layout(props)}</TypestylesStylesheet>;
142
+ };
143
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+
3
+ export { getRegisteredCss } from 'typestyles/server';
4
+
5
+ export interface TypestylesStylesheetProps {
6
+ children?: ReactNode;
7
+ }
8
+
9
+ export function TypestylesStylesheet(props: TypestylesStylesheetProps): React.JSX.Element;
10
+
11
+ export function collectStylesFromComponent(component: ReactElement): Promise<string>;
12
+
13
+ export function createTypestylesLayout<P extends { children?: ReactNode }>(
14
+ layout: (props: P) => ReactNode,
15
+ ): (props: P) => React.JSX.Element;
package/src/index.tsx ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @typestyles/next - Next.js integration for typestyles
3
+ *
4
+ * This package provides two entry points:
5
+ *
6
+ * 1. Main entry (this file) - Re-exports everything
7
+ * 2. `/server` - Server-safe utilities (getRegisteredCss, collectStylesFromComponent, getTypestylesMetadata)
8
+ * 3. `/client` - Client components (TypestylesStylesheet, useTypestyles, useServerInsertedHTML)
9
+ *
10
+ * For App Router, prefer using the client entry for components:
11
+ * import { TypestylesStylesheet } from '@typestyles/next/client';
12
+ *
13
+ * Or use server utilities for SSR:
14
+ * import { getRegisteredCss } from '@typestyles/next/server';
15
+ */
16
+
17
+ // Re-export server-safe utilities
18
+ export { getRegisteredCss, collectStylesFromComponent, getTypestylesMetadata } from './server';
19
+
20
+ // Re-export client components and hooks
21
+ export {
22
+ TypestylesStylesheet,
23
+ useTypestyles,
24
+ useServerInsertedHTML,
25
+ createTypestylesLayout,
26
+ type TypestylesStylesheetProps,
27
+ } from './client';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `useServerInsertedHTML` exists at runtime in Next.js App Router / React 18.3+ client builds,
3
+ * but some `@types/react` releases omit it. Augment `react` so local `tsc` and tooling match runtime.
4
+ *
5
+ * @see https://react.dev/reference/react-dom/server/useServerInsertedHTML
6
+ */
7
+ import type { ReactNode } from 'react';
8
+
9
+ declare module 'react' {
10
+ export function useServerInsertedHTML(callback: () => ReactNode | null): void;
11
+ }
12
+
13
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ReactElement } from 'react';
2
+
3
+ export { getRegisteredCss } from 'typestyles/server';
4
+
5
+ export declare function collectStylesFromComponent(component: ReactElement): Promise<string>;
6
+
7
+ export declare function getTypestylesMetadata(component: ReactElement): Promise<string>;