@umber-style/react 0.0.0 → 0.1.0-alpha.0

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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -1
  3. package/dist/ThemeProvider.cjs +37 -0
  4. package/dist/ThemeProvider.mjs +37 -0
  5. package/dist/ThemeProvider.server.cjs +35 -0
  6. package/dist/ThemeProvider.server.mjs +35 -0
  7. package/dist/ThemeValue.cjs +32 -0
  8. package/dist/ThemeValue.mjs +32 -0
  9. package/dist/createStyle.cjs +56 -0
  10. package/dist/createStyle.d.cts +7 -0
  11. package/dist/createStyle.d.mts +7 -0
  12. package/dist/createStyle.mjs +55 -0
  13. package/dist/createStyle.server.cjs +53 -0
  14. package/dist/createStyle.server.d.cts +8 -0
  15. package/dist/createStyle.server.d.mts +8 -0
  16. package/dist/createStyle.server.mjs +52 -0
  17. package/dist/defaultStyle.cjs +44 -0
  18. package/dist/defaultStyle.d.cts +22 -0
  19. package/dist/defaultStyle.d.mts +22 -0
  20. package/dist/defaultStyle.mjs +44 -0
  21. package/dist/defaultStyle.server.cjs +44 -0
  22. package/dist/defaultStyle.server.d.cts +22 -0
  23. package/dist/defaultStyle.server.d.mts +22 -0
  24. package/dist/defaultStyle.server.mjs +44 -0
  25. package/dist/index.cjs +61 -0
  26. package/dist/index.d.cts +18 -0
  27. package/dist/index.d.mts +18 -0
  28. package/dist/index.mjs +5 -0
  29. package/dist/index.server.cjs +61 -0
  30. package/dist/index.server.d.cts +18 -0
  31. package/dist/index.server.d.mts +18 -0
  32. package/dist/index.server.mjs +5 -0
  33. package/dist/serverContext.cjs +32 -0
  34. package/dist/serverContext.d.cts +2 -0
  35. package/dist/serverContext.d.mts +3 -0
  36. package/dist/serverContext.mjs +31 -0
  37. package/dist/styleElements.cjs +33 -0
  38. package/dist/styleElements.mjs +32 -0
  39. package/dist/styled.cjs +30 -0
  40. package/dist/styled.mjs +30 -0
  41. package/dist/styled.server.cjs +22 -0
  42. package/dist/styled.server.mjs +22 -0
  43. package/dist/styledParts.cjs +37 -0
  44. package/dist/styledParts.mjs +37 -0
  45. package/dist/types.d.cts +101 -0
  46. package/dist/types.d.mts +101 -0
  47. package/package.json +88 -5
@@ -0,0 +1,44 @@
1
+ let _umber_style_core = require("@umber-style/core");
2
+ const require_createStyle_server = require("./createStyle.server.cjs");
3
+ // src/defaultStyle.server.ts
4
+ /** Makes the default styling for server components: one engine, made on first use. */
5
+ function createDefaultStyle() {
6
+ let pending = {};
7
+ let bound;
8
+ const getStyle = () => {
9
+ if (!bound) {
10
+ const engine = pending.engine ?? (0, _umber_style_core.createLazyEngine)(pending);
11
+ if (pending.theme) engine.setTheme(pending.theme);
12
+ bound = require_createStyle_server.bindEngine(engine);
13
+ }
14
+ return bound;
15
+ };
16
+ /** Sets the options of the default engine, and gives it a base theme or an engine to share. Throws once the default style was used. */
17
+ function configure(options) {
18
+ if (bound) throw new Error("configure must be called before the default style is used.");
19
+ pending = options;
20
+ }
21
+ const styled = ((tag, options) => getStyle().styled(tag, options));
22
+ const StyleSheet = { create: ((styles) => typeof styles === "function" ? getStyle().StyleSheet.create(styles) : (0, _umber_style_core.createDeferredRecord)(styles, () => getStyle().StyleSheet.create(styles))) };
23
+ const useStyle = ((sheet) => getStyle().useStyle(sheet));
24
+ function readTheme() {
25
+ return getStyle().readTheme();
26
+ }
27
+ function ThemeProvider(props) {
28
+ return getStyle().ThemeProvider(props);
29
+ }
30
+ return {
31
+ configure,
32
+ getEngine: () => getStyle().engine,
33
+ styled,
34
+ StyleSheet,
35
+ useStyle,
36
+ readTheme,
37
+ ThemeProvider,
38
+ apply: ((...entries) => getStyle().apply(...entries)),
39
+ when: ((theme, colorScheme) => getStyle().when(theme, colorScheme)),
40
+ whenScheme: ((scheme) => getStyle().whenScheme(scheme)),
41
+ themeClass: ((theme, colorScheme) => getStyle().themeClass(theme, colorScheme))
42
+ };
43
+ }
44
+ exports.createDefaultStyle = createDefaultStyle;
@@ -0,0 +1,22 @@
1
+ import { DefaultStyleOptions, ServerStyle, SheetDefinition, Styled, WebThemeProviderProps } from "./types.cjs";
2
+ import { Theme, WebStyleObject } from "@umber-style/core";
3
+ /** Makes the default styling for server components: one engine, made on first use. */
4
+ export declare function createDefaultStyle(): {
5
+ configure: (options: DefaultStyleOptions) => void;
6
+ getEngine: () => import("@umber-style/core").Engine<Theme>;
7
+ styled: Styled<Theme>;
8
+ StyleSheet: {
9
+ create<K extends string>(styles: import("@umber-style/core").ObjectSheet<K>): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
10
+ create<K extends string>(styles: (theme: Theme) => Record<K, WebStyleObject>): SheetDefinition<Record<K, WebStyleObject>, import("@umber-style/core").SheetEntry>;
11
+ };
12
+ useStyle: {
13
+ <K extends string>(sheet: { readonly [P in K]: import("@umber-style/core").SheetEntry; }): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
14
+ <S extends import("@umber-style/core").SheetStyles>(sheet: SheetDefinition<S, import("@umber-style/core").SheetEntry>): { [K in keyof S]: import("@umber-style/core").SheetEntry; };
15
+ };
16
+ readTheme: () => Theme;
17
+ ThemeProvider: (props: WebThemeProviderProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
18
+ apply: ServerStyle<Theme>['apply'];
19
+ when: ServerStyle<Theme>['when'];
20
+ whenScheme: ServerStyle<Theme>['whenScheme'];
21
+ themeClass: ServerStyle<Theme>['themeClass'];
22
+ };
@@ -0,0 +1,22 @@
1
+ import { DefaultStyleOptions, ServerStyle, SheetDefinition, Styled, WebThemeProviderProps } from "./types.mjs";
2
+ import { Theme, WebStyleObject } from "@umber-style/core";
3
+ /** Makes the default styling for server components: one engine, made on first use. */
4
+ export declare function createDefaultStyle(): {
5
+ configure: (options: DefaultStyleOptions) => void;
6
+ getEngine: () => import("@umber-style/core").Engine<Theme>;
7
+ styled: Styled<Theme>;
8
+ StyleSheet: {
9
+ create<K extends string>(styles: import("@umber-style/core").ObjectSheet<K>): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
10
+ create<K extends string>(styles: (theme: Theme) => Record<K, WebStyleObject>): SheetDefinition<Record<K, WebStyleObject>, import("@umber-style/core").SheetEntry>;
11
+ };
12
+ useStyle: {
13
+ <K extends string>(sheet: { readonly [P in K]: import("@umber-style/core").SheetEntry; }): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
14
+ <S extends import("@umber-style/core").SheetStyles>(sheet: SheetDefinition<S, import("@umber-style/core").SheetEntry>): { [K in keyof S]: import("@umber-style/core").SheetEntry; };
15
+ };
16
+ readTheme: () => Theme;
17
+ ThemeProvider: (props: WebThemeProviderProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
18
+ apply: ServerStyle<Theme>['apply'];
19
+ when: ServerStyle<Theme>['when'];
20
+ whenScheme: ServerStyle<Theme>['whenScheme'];
21
+ themeClass: ServerStyle<Theme>['themeClass'];
22
+ };
@@ -0,0 +1,44 @@
1
+ import { createDeferredRecord, createLazyEngine } from "@umber-style/core";
2
+ import { bindEngine } from "./createStyle.server.mjs";
3
+ // src/defaultStyle.server.ts
4
+ /** Makes the default styling for server components: one engine, made on first use. */
5
+ function createDefaultStyle() {
6
+ let pending = {};
7
+ let bound;
8
+ const getStyle = () => {
9
+ if (!bound) {
10
+ const engine = pending.engine ?? createLazyEngine(pending);
11
+ if (pending.theme) engine.setTheme(pending.theme);
12
+ bound = bindEngine(engine);
13
+ }
14
+ return bound;
15
+ };
16
+ /** Sets the options of the default engine, and gives it a base theme or an engine to share. Throws once the default style was used. */
17
+ function configure(options) {
18
+ if (bound) throw new Error("configure must be called before the default style is used.");
19
+ pending = options;
20
+ }
21
+ const styled = ((tag, options) => getStyle().styled(tag, options));
22
+ const StyleSheet = { create: ((styles) => typeof styles === "function" ? getStyle().StyleSheet.create(styles) : createDeferredRecord(styles, () => getStyle().StyleSheet.create(styles))) };
23
+ const useStyle = ((sheet) => getStyle().useStyle(sheet));
24
+ function readTheme() {
25
+ return getStyle().readTheme();
26
+ }
27
+ function ThemeProvider(props) {
28
+ return getStyle().ThemeProvider(props);
29
+ }
30
+ return {
31
+ configure,
32
+ getEngine: () => getStyle().engine,
33
+ styled,
34
+ StyleSheet,
35
+ useStyle,
36
+ readTheme,
37
+ ThemeProvider,
38
+ apply: ((...entries) => getStyle().apply(...entries)),
39
+ when: ((theme, colorScheme) => getStyle().when(theme, colorScheme)),
40
+ whenScheme: ((scheme) => getStyle().whenScheme(scheme)),
41
+ themeClass: ((theme, colorScheme) => getStyle().themeClass(theme, colorScheme))
42
+ };
43
+ }
44
+ export { createDefaultStyle };
package/dist/index.cjs ADDED
@@ -0,0 +1,61 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_defaultStyle = require("./defaultStyle.cjs");
3
+ let _umber_style_core = require("@umber-style/core");
4
+ const require_createStyle = require("./createStyle.cjs");
5
+ const { configure, getEngine, styled, StyleSheet, useStyle, useTheme, ThemeProvider, apply, themeClass, when, whenScheme } = require_defaultStyle.createDefaultStyle();
6
+ exports.StyleSheet = StyleSheet;
7
+ exports.ThemeProvider = ThemeProvider;
8
+ Object.defineProperty(exports, "add", {
9
+ enumerable: true,
10
+ get: function() {
11
+ return _umber_style_core.add;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "alpha", {
15
+ enumerable: true,
16
+ get: function() {
17
+ return _umber_style_core.alpha;
18
+ }
19
+ });
20
+ exports.apply = apply;
21
+ Object.defineProperty(exports, "at", {
22
+ enumerable: true,
23
+ get: function() {
24
+ return _umber_style_core.at;
25
+ }
26
+ });
27
+ exports.bindEngine = require_createStyle.bindEngine;
28
+ exports.configure = configure;
29
+ exports.createDefaultStyle = require_defaultStyle.createDefaultStyle;
30
+ exports.createStyle = require_createStyle.createStyle;
31
+ Object.defineProperty(exports, "divide", {
32
+ enumerable: true,
33
+ get: function() {
34
+ return _umber_style_core.divide;
35
+ }
36
+ });
37
+ exports.getEngine = getEngine;
38
+ Object.defineProperty(exports, "multiply", {
39
+ enumerable: true,
40
+ get: function() {
41
+ return _umber_style_core.multiply;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "negate", {
45
+ enumerable: true,
46
+ get: function() {
47
+ return _umber_style_core.negate;
48
+ }
49
+ });
50
+ exports.styled = styled;
51
+ Object.defineProperty(exports, "subtract", {
52
+ enumerable: true,
53
+ get: function() {
54
+ return _umber_style_core.subtract;
55
+ }
56
+ });
57
+ exports.themeClass = themeClass;
58
+ exports.useStyle = useStyle;
59
+ exports.useTheme = useTheme;
60
+ exports.when = when;
61
+ exports.whenScheme = whenScheme;
@@ -0,0 +1,18 @@
1
+ import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
2
+ import { AlphaColor, DefaultStyleOptions, NestedKey, SchemeKey, SchemeName, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledComponent, StyledOptions, StyledStatics, ThemeKey, ThemeProviderProps, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.cjs";
3
+ import { bindEngine, createStyle } from "./createStyle.cjs";
4
+ import { createDefaultStyle } from "./defaultStyle.cjs";
5
+ export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<import("@umber-style/core").Theme>, styled: Styled<import("@umber-style/core").Theme>, StyleSheet: {
6
+ create<K extends string>(styles: import("@umber-style/core").ObjectSheet<K>): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
7
+ create<K extends string>(styles: (theme: import("@umber-style/core").Theme) => Record<K, import("@umber-style/core").WebStyleObject>): SheetDefinition<Record<K, import("@umber-style/core").WebStyleObject>, import("@umber-style/core").SheetEntry>;
8
+ }, useStyle: {
9
+ <K extends string>(sheet: { readonly [P in K]: import("@umber-style/core").SheetEntry; }): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
10
+ <S extends import("@umber-style/core").SheetStyles>(sheet: SheetDefinition<S, import("@umber-style/core").SheetEntry>): { [K in keyof S]: import("@umber-style/core").SheetEntry; };
11
+ }, useTheme: () => import("@umber-style/core").Theme, ThemeProvider: (props: WebThemeProviderProps<import("@umber-style/core").Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, apply: (...entries: (import("@umber-style/core").SheetEntry | string | null | undefined | false)[]) => {
12
+ className?: string;
13
+ }, themeClass: (theme: {
14
+ readonly _theme?: never;
15
+ }, colorScheme?: import("@umber-style/core").ColorScheme) => string, when: (theme: {
16
+ readonly _theme?: never;
17
+ }, colorScheme?: import("@umber-style/core").ColorScheme) => import("@umber-style/core").ThemeKey, whenScheme: (scheme: import("@umber-style/core").SchemeName) => import("@umber-style/core").SchemeKey;
18
+ export { type AlphaColor, DefaultStyleOptions, type NestedKey, type SchemeKey, type SchemeName, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledComponent, StyledOptions, StyledStatics, type ThemeKey, ThemeProviderProps, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
@@ -0,0 +1,18 @@
1
+ import { AlphaColor, DefaultStyleOptions, NestedKey, SchemeKey, SchemeName, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledComponent, StyledOptions, StyledStatics, ThemeKey, ThemeProviderProps, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.mjs";
2
+ import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
3
+ import { bindEngine, createStyle } from "./createStyle.mjs";
4
+ import { createDefaultStyle } from "./defaultStyle.mjs";
5
+ export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<import("@umber-style/core").Theme>, styled: Styled<import("@umber-style/core").Theme>, StyleSheet: {
6
+ create<K extends string>(styles: import("@umber-style/core").ObjectSheet<K>): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
7
+ create<K extends string>(styles: (theme: import("@umber-style/core").Theme) => Record<K, import("@umber-style/core").WebStyleObject>): SheetDefinition<Record<K, import("@umber-style/core").WebStyleObject>, import("@umber-style/core").SheetEntry>;
8
+ }, useStyle: {
9
+ <K extends string>(sheet: { readonly [P in K]: import("@umber-style/core").SheetEntry; }): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
10
+ <S extends import("@umber-style/core").SheetStyles>(sheet: SheetDefinition<S, import("@umber-style/core").SheetEntry>): { [K in keyof S]: import("@umber-style/core").SheetEntry; };
11
+ }, useTheme: () => import("@umber-style/core").Theme, ThemeProvider: (props: WebThemeProviderProps<import("@umber-style/core").Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, apply: (...entries: (import("@umber-style/core").SheetEntry | string | null | undefined | false)[]) => {
12
+ className?: string;
13
+ }, themeClass: (theme: {
14
+ readonly _theme?: never;
15
+ }, colorScheme?: import("@umber-style/core").ColorScheme) => string, when: (theme: {
16
+ readonly _theme?: never;
17
+ }, colorScheme?: import("@umber-style/core").ColorScheme) => import("@umber-style/core").ThemeKey, whenScheme: (scheme: import("@umber-style/core").SchemeName) => import("@umber-style/core").SchemeKey;
18
+ export { type AlphaColor, DefaultStyleOptions, type NestedKey, type SchemeKey, type SchemeName, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledComponent, StyledOptions, StyledStatics, type ThemeKey, ThemeProviderProps, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import { createDefaultStyle } from "./defaultStyle.mjs";
2
+ import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
3
+ import { bindEngine, createStyle } from "./createStyle.mjs";
4
+ const { configure, getEngine, styled, StyleSheet, useStyle, useTheme, ThemeProvider, apply, themeClass, when, whenScheme } = createDefaultStyle();
5
+ export { StyleSheet, ThemeProvider, add, alpha, apply, at, bindEngine, configure, createDefaultStyle, createStyle, divide, getEngine, multiply, negate, styled, subtract, themeClass, useStyle, useTheme, when, whenScheme };
@@ -0,0 +1,61 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_defaultStyle_server = require("./defaultStyle.server.cjs");
3
+ let _umber_style_core = require("@umber-style/core");
4
+ const require_createStyle_server = require("./createStyle.server.cjs");
5
+ const { configure, getEngine, styled, StyleSheet, useStyle, readTheme, ThemeProvider, apply, themeClass, when, whenScheme } = require_defaultStyle_server.createDefaultStyle();
6
+ exports.StyleSheet = StyleSheet;
7
+ exports.ThemeProvider = ThemeProvider;
8
+ Object.defineProperty(exports, "add", {
9
+ enumerable: true,
10
+ get: function() {
11
+ return _umber_style_core.add;
12
+ }
13
+ });
14
+ Object.defineProperty(exports, "alpha", {
15
+ enumerable: true,
16
+ get: function() {
17
+ return _umber_style_core.alpha;
18
+ }
19
+ });
20
+ exports.apply = apply;
21
+ Object.defineProperty(exports, "at", {
22
+ enumerable: true,
23
+ get: function() {
24
+ return _umber_style_core.at;
25
+ }
26
+ });
27
+ exports.bindEngine = require_createStyle_server.bindEngine;
28
+ exports.configure = configure;
29
+ exports.createDefaultStyle = require_defaultStyle_server.createDefaultStyle;
30
+ exports.createStyle = require_createStyle_server.createStyle;
31
+ Object.defineProperty(exports, "divide", {
32
+ enumerable: true,
33
+ get: function() {
34
+ return _umber_style_core.divide;
35
+ }
36
+ });
37
+ exports.getEngine = getEngine;
38
+ Object.defineProperty(exports, "multiply", {
39
+ enumerable: true,
40
+ get: function() {
41
+ return _umber_style_core.multiply;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "negate", {
45
+ enumerable: true,
46
+ get: function() {
47
+ return _umber_style_core.negate;
48
+ }
49
+ });
50
+ exports.readTheme = readTheme;
51
+ exports.styled = styled;
52
+ Object.defineProperty(exports, "subtract", {
53
+ enumerable: true,
54
+ get: function() {
55
+ return _umber_style_core.subtract;
56
+ }
57
+ });
58
+ exports.themeClass = themeClass;
59
+ exports.useStyle = useStyle;
60
+ exports.when = when;
61
+ exports.whenScheme = whenScheme;
@@ -0,0 +1,18 @@
1
+ import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
2
+ import { AlphaColor, DefaultStyleOptions, NestedKey, SchemeKey, SchemeName, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledComponent, StyledOptions, StyledStatics, ThemeKey, ThemeProviderProps, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.cjs";
3
+ import { bindEngine, createStyle } from "./createStyle.server.cjs";
4
+ import { createDefaultStyle } from "./defaultStyle.server.cjs";
5
+ export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<import("@umber-style/core").Theme>, styled: Styled<import("@umber-style/core").Theme>, StyleSheet: {
6
+ create<K extends string>(styles: import("@umber-style/core").ObjectSheet<K>): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
7
+ create<K extends string>(styles: (theme: import("@umber-style/core").Theme) => Record<K, import("@umber-style/core").WebStyleObject>): SheetDefinition<Record<K, import("@umber-style/core").WebStyleObject>, import("@umber-style/core").SheetEntry>;
8
+ }, useStyle: {
9
+ <K extends string>(sheet: { readonly [P in K]: import("@umber-style/core").SheetEntry; }): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
10
+ <S extends import("@umber-style/core").SheetStyles>(sheet: SheetDefinition<S, import("@umber-style/core").SheetEntry>): { [K in keyof S]: import("@umber-style/core").SheetEntry; };
11
+ }, readTheme: () => import("@umber-style/core").Theme, ThemeProvider: (props: WebThemeProviderProps<import("@umber-style/core").Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, apply: (...entries: (import("@umber-style/core").SheetEntry | string | null | undefined | false)[]) => {
12
+ className?: string;
13
+ }, themeClass: (theme: {
14
+ readonly _theme?: never;
15
+ }, colorScheme?: import("@umber-style/core").ColorScheme) => string, when: (theme: {
16
+ readonly _theme?: never;
17
+ }, colorScheme?: import("@umber-style/core").ColorScheme) => import("@umber-style/core").ThemeKey, whenScheme: (scheme: import("@umber-style/core").SchemeName) => import("@umber-style/core").SchemeKey;
18
+ export { type AlphaColor, DefaultStyleOptions, type NestedKey, type SchemeKey, type SchemeName, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledComponent, StyledOptions, StyledStatics, type ThemeKey, ThemeProviderProps, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
@@ -0,0 +1,18 @@
1
+ import { AlphaColor, DefaultStyleOptions, NestedKey, SchemeKey, SchemeName, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledComponent, StyledOptions, StyledStatics, ThemeKey, ThemeProviderProps, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.mjs";
2
+ import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
3
+ import { bindEngine, createStyle } from "./createStyle.server.mjs";
4
+ import { createDefaultStyle } from "./defaultStyle.server.mjs";
5
+ export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<import("@umber-style/core").Theme>, styled: Styled<import("@umber-style/core").Theme>, StyleSheet: {
6
+ create<K extends string>(styles: import("@umber-style/core").ObjectSheet<K>): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
7
+ create<K extends string>(styles: (theme: import("@umber-style/core").Theme) => Record<K, import("@umber-style/core").WebStyleObject>): SheetDefinition<Record<K, import("@umber-style/core").WebStyleObject>, import("@umber-style/core").SheetEntry>;
8
+ }, useStyle: {
9
+ <K extends string>(sheet: { readonly [P in K]: import("@umber-style/core").SheetEntry; }): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
10
+ <S extends import("@umber-style/core").SheetStyles>(sheet: SheetDefinition<S, import("@umber-style/core").SheetEntry>): { [K in keyof S]: import("@umber-style/core").SheetEntry; };
11
+ }, readTheme: () => import("@umber-style/core").Theme, ThemeProvider: (props: WebThemeProviderProps<import("@umber-style/core").Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, apply: (...entries: (import("@umber-style/core").SheetEntry | string | null | undefined | false)[]) => {
12
+ className?: string;
13
+ }, themeClass: (theme: {
14
+ readonly _theme?: never;
15
+ }, colorScheme?: import("@umber-style/core").ColorScheme) => string, when: (theme: {
16
+ readonly _theme?: never;
17
+ }, colorScheme?: import("@umber-style/core").ColorScheme) => import("@umber-style/core").ThemeKey, whenScheme: (scheme: import("@umber-style/core").SchemeName) => import("@umber-style/core").SchemeKey;
18
+ export { type AlphaColor, DefaultStyleOptions, type NestedKey, type SchemeKey, type SchemeName, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledComponent, StyledOptions, StyledStatics, type ThemeKey, ThemeProviderProps, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
@@ -0,0 +1,5 @@
1
+ import { createDefaultStyle } from "./defaultStyle.server.mjs";
2
+ import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
3
+ import { bindEngine, createStyle } from "./createStyle.server.mjs";
4
+ const { configure, getEngine, styled, StyleSheet, useStyle, readTheme, ThemeProvider, apply, themeClass, when, whenScheme } = createDefaultStyle();
5
+ export { StyleSheet, ThemeProvider, add, alpha, apply, at, bindEngine, configure, createDefaultStyle, createStyle, divide, getEngine, multiply, negate, readTheme, styled, subtract, themeClass, useStyle, when, whenScheme };
@@ -0,0 +1,32 @@
1
+ let react = require("react");
2
+ // src/serverContext.ts
3
+ /**
4
+ * A context for server components, which have no React context: its value is a slot that
5
+ * `React.cache` keeps for the length of one request. A server component can render out of order,
6
+ * and a nested provider must not change what the root gave, so only the first provider that renders
7
+ * in a request writes the slot; the later ones leave it as it is.
8
+ */
9
+ function createServerOnlyContext(defaultValue, cache = react.cache) {
10
+ const slot = cache(() => ({
11
+ current: defaultValue,
12
+ isSet: false
13
+ }));
14
+ function Provider({ value, children }) {
15
+ const state = slot();
16
+ if (!state.isSet) {
17
+ state.current = value;
18
+ state.isSet = true;
19
+ }
20
+ return children;
21
+ }
22
+ return {
23
+ Provider,
24
+ slot
25
+ };
26
+ }
27
+ /** The value of the slot of the current request: the default until a provider has written it. */
28
+ function readServerContext(context) {
29
+ return context.slot().current;
30
+ }
31
+ exports.createServerOnlyContext = createServerOnlyContext;
32
+ exports.readServerContext = readServerContext;
@@ -0,0 +1,2 @@
1
+ /** What makes the slot of a request: `React.cache`, or a function with the same contract. */
2
+ export type CacheFunction = <R>(make: () => R) => () => R;
@@ -0,0 +1,3 @@
1
+ import "react";
2
+ /** What makes the slot of a request: `React.cache`, or a function with the same contract. */
3
+ export type CacheFunction = <R>(make: () => R) => () => R;
@@ -0,0 +1,31 @@
1
+ import { cache } from "react";
2
+ // src/serverContext.ts
3
+ /**
4
+ * A context for server components, which have no React context: its value is a slot that
5
+ * `React.cache` keeps for the length of one request. A server component can render out of order,
6
+ * and a nested provider must not change what the root gave, so only the first provider that renders
7
+ * in a request writes the slot; the later ones leave it as it is.
8
+ */
9
+ function createServerOnlyContext(defaultValue, cache$1 = cache) {
10
+ const slot = cache$1(() => ({
11
+ current: defaultValue,
12
+ isSet: false
13
+ }));
14
+ function Provider({ value, children }) {
15
+ const state = slot();
16
+ if (!state.isSet) {
17
+ state.current = value;
18
+ state.isSet = true;
19
+ }
20
+ return children;
21
+ }
22
+ return {
23
+ Provider,
24
+ slot
25
+ };
26
+ }
27
+ /** The value of the slot of the current request: the default until a provider has written it. */
28
+ function readServerContext(context) {
29
+ return context.slot().current;
30
+ }
31
+ export { createServerOnlyContext, readServerContext };
@@ -0,0 +1,33 @@
1
+ let react = require("react");
2
+ // src/styleElements.ts
3
+ /**
4
+ * The `<style href precedence>` elements for the classes in `className`: React 19 moves them to the
5
+ * head and renders each `href` once. The precedence is the prefix of the cache. Each one starts with the order statement of the layers (none without layers), so that it is right on its own: declaring a layer again does not change the order. A name that the
6
+ * cache made no rules for (a class of someone else) gets none. A theme class comes with every variable it has, used or not: its element is sent before the elements that use them, so it cannot know which are used.
7
+ */
8
+ function createStyleElements(cache, className) {
9
+ return (className ?? "").split(/\s+/).filter(Boolean).flatMap((name) => {
10
+ const rules = cache.getFullRules(name);
11
+ if (rules.length === 0) return [];
12
+ const props = {
13
+ key: name,
14
+ href: name,
15
+ precedence: cache.prefix
16
+ };
17
+ return [(0, react.createElement)("style", props, [cache.layerOrder, ...rules].join(""))];
18
+ });
19
+ }
20
+ /**
21
+ * The element that carries the options of the cache, for the browser to compare with its own: a `<meta>`
22
+ * named `<prefix>-options`, which React moves to the head. It is not a style element, because a server
23
+ * render merges the style elements of one precedence into one and keeps the attributes of none of them.
24
+ */
25
+ function createStampElement(cache) {
26
+ return (0, react.createElement)("meta", {
27
+ key: `${cache.prefix}-options`,
28
+ name: `${cache.prefix}-options`,
29
+ content: cache.fingerprint
30
+ });
31
+ }
32
+ exports.createStampElement = createStampElement;
33
+ exports.createStyleElements = createStyleElements;
@@ -0,0 +1,32 @@
1
+ import { createElement } from "react";
2
+ // src/styleElements.ts
3
+ /**
4
+ * The `<style href precedence>` elements for the classes in `className`: React 19 moves them to the
5
+ * head and renders each `href` once. The precedence is the prefix of the cache. Each one starts with the order statement of the layers (none without layers), so that it is right on its own: declaring a layer again does not change the order. A name that the
6
+ * cache made no rules for (a class of someone else) gets none. A theme class comes with every variable it has, used or not: its element is sent before the elements that use them, so it cannot know which are used.
7
+ */
8
+ function createStyleElements(cache, className) {
9
+ return (className ?? "").split(/\s+/).filter(Boolean).flatMap((name) => {
10
+ const rules = cache.getFullRules(name);
11
+ if (rules.length === 0) return [];
12
+ const props = {
13
+ key: name,
14
+ href: name,
15
+ precedence: cache.prefix
16
+ };
17
+ return [createElement("style", props, [cache.layerOrder, ...rules].join(""))];
18
+ });
19
+ }
20
+ /**
21
+ * The element that carries the options of the cache, for the browser to compare with its own: a `<meta>`
22
+ * named `<prefix>-options`, which React moves to the head. It is not a style element, because a server
23
+ * render merges the style elements of one precedence into one and keeps the attributes of none of them.
24
+ */
25
+ function createStampElement(cache) {
26
+ return createElement("meta", {
27
+ key: `${cache.prefix}-options`,
28
+ name: `${cache.prefix}-options`,
29
+ content: cache.fingerprint
30
+ });
31
+ }
32
+ export { createStampElement, createStyleElements };
@@ -0,0 +1,30 @@
1
+ let react = require("react");
2
+ const require_styledParts = require("./styledParts.cjs");
3
+ // src/styled.ts
4
+ /**
5
+ * Makes `styled` over an engine. A component with a function style reads the theme of the nearest
6
+ * provider through `useThemeView`; one with only object styles reads no context. `createStyleElements`
7
+ * gives the style elements of a class where the build sends them (a server render), and none in the browser.
8
+ */
9
+ function createStyled(engine, useThemeView, createStyleElements) {
10
+ /** The element, with the style elements of its class in front of it where there are any. */
11
+ const render = (element, forwarded, className) => {
12
+ const styles = createStyleElements(className);
13
+ const rendered = (0, react.createElement)(element, forwarded);
14
+ return styles.length === 0 ? rendered : (0, react.createElement)(react.Fragment, null, ...styles, rendered);
15
+ };
16
+ const styled = (tag, options = {}) => (...styles) => {
17
+ const { styler, resolve, statics } = require_styledParts.prepareStyled(engine, tag, options, styles);
18
+ const StaticStyled = (props) => {
19
+ const { element, forwarded, className } = resolve(props);
20
+ return render(element, forwarded, className);
21
+ };
22
+ const DynamicStyled = (props) => {
23
+ const { element, forwarded, className } = resolve(props, useThemeView());
24
+ return render(element, forwarded, className);
25
+ };
26
+ return Object.assign(styler.isDynamic ? DynamicStyled : StaticStyled, statics);
27
+ };
28
+ return styled;
29
+ }
30
+ exports.createStyled = createStyled;
@@ -0,0 +1,30 @@
1
+ import { Fragment, createElement } from "react";
2
+ import { prepareStyled } from "./styledParts.mjs";
3
+ // src/styled.ts
4
+ /**
5
+ * Makes `styled` over an engine. A component with a function style reads the theme of the nearest
6
+ * provider through `useThemeView`; one with only object styles reads no context. `createStyleElements`
7
+ * gives the style elements of a class where the build sends them (a server render), and none in the browser.
8
+ */
9
+ function createStyled(engine, useThemeView, createStyleElements) {
10
+ /** The element, with the style elements of its class in front of it where there are any. */
11
+ const render = (element, forwarded, className) => {
12
+ const styles = createStyleElements(className);
13
+ const rendered = createElement(element, forwarded);
14
+ return styles.length === 0 ? rendered : createElement(Fragment, null, ...styles, rendered);
15
+ };
16
+ const styled = (tag, options = {}) => (...styles) => {
17
+ const { styler, resolve, statics } = prepareStyled(engine, tag, options, styles);
18
+ const StaticStyled = (props) => {
19
+ const { element, forwarded, className } = resolve(props);
20
+ return render(element, forwarded, className);
21
+ };
22
+ const DynamicStyled = (props) => {
23
+ const { element, forwarded, className } = resolve(props, useThemeView());
24
+ return render(element, forwarded, className);
25
+ };
26
+ return Object.assign(styler.isDynamic ? DynamicStyled : StaticStyled, statics);
27
+ };
28
+ return styled;
29
+ }
30
+ export { createStyled };
@@ -0,0 +1,22 @@
1
+ let react = require("react");
2
+ const require_styleElements = require("./styleElements.cjs");
3
+ const require_styledParts = require("./styledParts.cjs");
4
+ // src/styled.server.ts
5
+ /**
6
+ * Makes `styled` for server components: no hook, no context. A function style reads the view of the
7
+ * theme that `readTheme` gives, which is the root theme of the request. Each element comes with the
8
+ * `<style>` of its class.
9
+ */
10
+ function createStyled(engine, readTheme) {
11
+ const styled = (tag, options = {}) => (...styles) => {
12
+ const { styler, resolve, statics } = require_styledParts.prepareStyled(engine, tag, options, styles);
13
+ const Styled = (props) => {
14
+ const theme = styler.isDynamic ? engine.createThemeView(readTheme()) : void 0;
15
+ const { element, forwarded, className } = resolve(props, theme);
16
+ return (0, react.createElement)(react.Fragment, null, ...require_styleElements.createStyleElements(engine.cache, className), (0, react.createElement)(element, forwarded));
17
+ };
18
+ return Object.assign(Styled, statics);
19
+ };
20
+ return styled;
21
+ }
22
+ exports.createStyled = createStyled;
@@ -0,0 +1,22 @@
1
+ import { Fragment, createElement } from "react";
2
+ import { createStyleElements } from "./styleElements.mjs";
3
+ import { prepareStyled } from "./styledParts.mjs";
4
+ // src/styled.server.ts
5
+ /**
6
+ * Makes `styled` for server components: no hook, no context. A function style reads the view of the
7
+ * theme that `readTheme` gives, which is the root theme of the request. Each element comes with the
8
+ * `<style>` of its class.
9
+ */
10
+ function createStyled(engine, readTheme) {
11
+ const styled = (tag, options = {}) => (...styles) => {
12
+ const { styler, resolve, statics } = prepareStyled(engine, tag, options, styles);
13
+ const Styled = (props) => {
14
+ const theme = styler.isDynamic ? engine.createThemeView(readTheme()) : void 0;
15
+ const { element, forwarded, className } = resolve(props, theme);
16
+ return createElement(Fragment, null, ...createStyleElements(engine.cache, className), createElement(element, forwarded));
17
+ };
18
+ return Object.assign(Styled, statics);
19
+ };
20
+ return styled;
21
+ }
22
+ export { createStyled };