@umber-style/react 0.1.0-alpha.0 → 0.1.0-alpha.2
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/CacheProvider.cjs +23 -0
- package/dist/CacheProvider.d.cts +10 -0
- package/dist/CacheProvider.d.mts +11 -0
- package/dist/CacheProvider.mjs +22 -0
- package/dist/Global.cjs +52 -0
- package/dist/Global.mjs +52 -0
- package/dist/Global.server.cjs +27 -0
- package/dist/Global.server.mjs +27 -0
- package/dist/GlobalRelease.cjs +32 -0
- package/dist/GlobalRelease.mjs +30 -0
- package/dist/ProviderScope.cjs +201 -0
- package/dist/ProviderScope.d.cts +14 -0
- package/dist/ProviderScope.d.mts +15 -0
- package/dist/ProviderScope.mjs +190 -0
- package/dist/ThemeProvider.cjs +94 -27
- package/dist/ThemeProvider.mjs +95 -28
- package/dist/ThemeProvider.server.cjs +130 -25
- package/dist/ThemeProvider.server.mjs +131 -26
- package/dist/ThemeValue.cjs +52 -20
- package/dist/ThemeValue.d.cts +3 -0
- package/dist/ThemeValue.d.mts +4 -0
- package/dist/ThemeValue.mjs +53 -23
- package/dist/_virtual/_rolldown/runtime.cjs +22 -0
- package/dist/createStyle.cjs +30 -20
- package/dist/createStyle.d.cts +4 -2
- package/dist/createStyle.d.mts +4 -2
- package/dist/createStyle.mjs +32 -22
- package/dist/createStyle.server.cjs +29 -22
- package/dist/createStyle.server.mjs +31 -24
- package/dist/defaultStyle.cjs +27 -3
- package/dist/defaultStyle.d.cts +18 -11
- package/dist/defaultStyle.d.mts +18 -11
- package/dist/defaultStyle.mjs +28 -4
- package/dist/defaultStyle.server.cjs +13 -5
- package/dist/defaultStyle.server.d.cts +16 -11
- package/dist/defaultStyle.server.d.mts +16 -11
- package/dist/defaultStyle.server.mjs +14 -6
- package/dist/domProps.cjs +27 -0
- package/dist/domProps.mjs +27 -0
- package/dist/index.cjs +12 -1
- package/dist/index.d.cts +17 -7
- package/dist/index.d.mts +17 -7
- package/dist/index.mjs +4 -2
- package/dist/index.server.cjs +6 -1
- package/dist/index.server.d.cts +15 -7
- package/dist/index.server.d.mts +15 -7
- package/dist/index.server.mjs +2 -2
- package/dist/plainTheme.cjs +49 -0
- package/dist/plainTheme.mjs +49 -0
- package/dist/serverContext.cjs +6 -24
- package/dist/serverContext.d.mts +0 -1
- package/dist/serverContext.mjs +6 -23
- package/dist/styleElements.cjs +75 -9
- package/dist/styleElements.d.cts +1 -0
- package/dist/styleElements.d.mts +2 -0
- package/dist/styleElements.mjs +73 -10
- package/dist/styled.cjs +32 -11
- package/dist/styled.mjs +33 -12
- package/dist/styled.server.cjs +6 -4
- package/dist/styled.server.mjs +6 -4
- package/dist/styledParts.cjs +36 -6
- package/dist/styledParts.mjs +37 -7
- package/dist/types.d.cts +225 -19
- package/dist/types.d.mts +225 -19
- package/dist/useMediaQuery.cjs +20 -0
- package/dist/useMediaQuery.d.cts +13 -0
- package/dist/useMediaQuery.d.mts +13 -0
- package/dist/useMediaQuery.mjs +20 -0
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
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";
|
|
1
|
+
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.mjs";
|
|
2
2
|
import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
|
|
3
|
+
import { CacheProvider } from "./CacheProvider.mjs";
|
|
4
|
+
import { MediaQueryOptions, useMediaQuery } from "./useMediaQuery.mjs";
|
|
3
5
|
import { bindEngine, createStyle } from "./createStyle.mjs";
|
|
4
6
|
import { createDefaultStyle } from "./defaultStyle.mjs";
|
|
5
|
-
export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<
|
|
7
|
+
export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<Theme>, styled: Styled<Theme>, StyleSheet: {
|
|
6
8
|
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:
|
|
9
|
+
create<K extends string>(styles: (theme: Theme) => Record<K, import("@umber-style/core").WebStyleObject>): SheetDefinition<Record<K, import("@umber-style/core").WebStyleObject>, import("@umber-style/core").SheetEntry>;
|
|
8
10
|
}, useStyle: {
|
|
9
11
|
<K extends string>(sheet: { readonly [P in K]: import("@umber-style/core").SheetEntry; }): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
|
|
10
12
|
<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: () =>
|
|
13
|
+
}, useTheme: () => Theme, ThemeProvider: (props: WebThemeProviderProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, ThemeScope: (props: ThemeScopeProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, useThemeClass: () => string | undefined, ThemeContext: import("react").Context<Theme | undefined>, apply: (...entries: (import("@umber-style/core").SheetEntry | string | null | undefined | false)[]) => {
|
|
12
14
|
className?: string;
|
|
13
|
-
}, themeClass: (theme: {
|
|
15
|
+
}, css: CssFunction, themeClass: (theme: {
|
|
14
16
|
readonly _theme?: never;
|
|
15
17
|
}, colorScheme?: import("@umber-style/core").ColorScheme) => string, when: (theme: {
|
|
16
18
|
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
|
-
|
|
19
|
+
}, colorScheme?: import("@umber-style/core").ColorScheme) => import("@umber-style/core").ThemeKey, whenScheme: (scheme: import("@umber-style/core").SchemeName) => import("@umber-style/core").SchemeKey, keyframes: {
|
|
20
|
+
(steps: (theme: Theme) => import("@umber-style/core").KeyframesSteps, options?: import("@umber-style/core").KeyframesOptions): import("@umber-style/core").Keyframes;
|
|
21
|
+
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").Keyframes;
|
|
22
|
+
(steps: import("@umber-style/core").KeyframesInput<Theme>, options?: import("@umber-style/core").KeyframesOptions): import("@umber-style/core").Keyframes;
|
|
23
|
+
}, globalStyles: {
|
|
24
|
+
(styles: (theme: Theme) => import("@umber-style/core").GlobalStyleObject): import("@umber-style/core").GlobalStyles<Theme>;
|
|
25
|
+
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").GlobalStyles<Theme>;
|
|
26
|
+
(styles: import("@umber-style/core").GlobalStylesInput<Theme>): import("@umber-style/core").GlobalStyles<Theme>;
|
|
27
|
+
}, Global: (props: GlobalProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
28
|
+
export { type AlphaColor, type CSSObject, CacheProvider, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type MediaQueryOptions, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract, useMediaQuery };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createDefaultStyle } from "./defaultStyle.mjs";
|
|
2
2
|
import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
|
|
3
|
+
import { CacheProvider } from "./CacheProvider.mjs";
|
|
4
|
+
import { useMediaQuery } from "./useMediaQuery.mjs";
|
|
3
5
|
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 };
|
|
6
|
+
const { configure, getEngine, styled, StyleSheet, useStyle, useTheme, ThemeProvider, ThemeScope, useThemeClass, ThemeContext, apply, css, themeClass, when, whenScheme, keyframes, globalStyles, Global } = createDefaultStyle();
|
|
7
|
+
export { CacheProvider, Global, StyleSheet, ThemeContext, ThemeProvider, ThemeScope, add, alpha, apply, at, bindEngine, configure, createDefaultStyle, createStyle, css, divide, getEngine, globalStyles, keyframes, multiply, negate, styled, subtract, themeClass, useMediaQuery, useStyle, useTheme, useThemeClass, when, whenScheme };
|
package/dist/index.server.cjs
CHANGED
|
@@ -2,7 +2,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_defaultStyle_server = require("./defaultStyle.server.cjs");
|
|
3
3
|
let _umber_style_core = require("@umber-style/core");
|
|
4
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();
|
|
5
|
+
const { configure, getEngine, styled, StyleSheet, useStyle, useTheme, readTheme, ThemeProvider, apply, css, themeClass, when, whenScheme, keyframes, globalStyles, Global } = require_defaultStyle_server.createDefaultStyle();
|
|
6
|
+
exports.Global = Global;
|
|
6
7
|
exports.StyleSheet = StyleSheet;
|
|
7
8
|
exports.ThemeProvider = ThemeProvider;
|
|
8
9
|
Object.defineProperty(exports, "add", {
|
|
@@ -28,6 +29,7 @@ exports.bindEngine = require_createStyle_server.bindEngine;
|
|
|
28
29
|
exports.configure = configure;
|
|
29
30
|
exports.createDefaultStyle = require_defaultStyle_server.createDefaultStyle;
|
|
30
31
|
exports.createStyle = require_createStyle_server.createStyle;
|
|
32
|
+
exports.css = css;
|
|
31
33
|
Object.defineProperty(exports, "divide", {
|
|
32
34
|
enumerable: true,
|
|
33
35
|
get: function() {
|
|
@@ -35,6 +37,8 @@ Object.defineProperty(exports, "divide", {
|
|
|
35
37
|
}
|
|
36
38
|
});
|
|
37
39
|
exports.getEngine = getEngine;
|
|
40
|
+
exports.globalStyles = globalStyles;
|
|
41
|
+
exports.keyframes = keyframes;
|
|
38
42
|
Object.defineProperty(exports, "multiply", {
|
|
39
43
|
enumerable: true,
|
|
40
44
|
get: function() {
|
|
@@ -57,5 +61,6 @@ Object.defineProperty(exports, "subtract", {
|
|
|
57
61
|
});
|
|
58
62
|
exports.themeClass = themeClass;
|
|
59
63
|
exports.useStyle = useStyle;
|
|
64
|
+
exports.useTheme = useTheme;
|
|
60
65
|
exports.when = when;
|
|
61
66
|
exports.whenScheme = whenScheme;
|
package/dist/index.server.d.cts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
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";
|
|
2
|
+
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.cjs";
|
|
3
3
|
import { bindEngine, createStyle } from "./createStyle.server.cjs";
|
|
4
4
|
import { createDefaultStyle } from "./defaultStyle.server.cjs";
|
|
5
|
-
export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<
|
|
5
|
+
export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<Theme>, styled: Styled<Theme>, StyleSheet: {
|
|
6
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:
|
|
7
|
+
create<K extends string>(styles: (theme: Theme) => Record<K, import("@umber-style/core").WebStyleObject>): SheetDefinition<Record<K, import("@umber-style/core").WebStyleObject>, import("@umber-style/core").SheetEntry>;
|
|
8
8
|
}, useStyle: {
|
|
9
9
|
<K extends string>(sheet: { readonly [P in K]: import("@umber-style/core").SheetEntry; }): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
|
|
10
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
|
-
},
|
|
11
|
+
}, useTheme: () => Theme, readTheme: () => Theme, ThemeProvider: (props: WebThemeProviderProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, apply: (...entries: (import("@umber-style/core").SheetEntry | string | null | undefined | false)[]) => {
|
|
12
12
|
className?: string;
|
|
13
|
-
}, themeClass: (theme: {
|
|
13
|
+
}, css: CssFunction, themeClass: (theme: {
|
|
14
14
|
readonly _theme?: never;
|
|
15
15
|
}, colorScheme?: import("@umber-style/core").ColorScheme) => string, when: (theme: {
|
|
16
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
|
-
|
|
17
|
+
}, colorScheme?: import("@umber-style/core").ColorScheme) => import("@umber-style/core").ThemeKey, whenScheme: (scheme: import("@umber-style/core").SchemeName) => import("@umber-style/core").SchemeKey, keyframes: {
|
|
18
|
+
(steps: (theme: Theme) => import("@umber-style/core").KeyframesSteps, options?: import("@umber-style/core").KeyframesOptions): import("@umber-style/core").Keyframes;
|
|
19
|
+
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").Keyframes;
|
|
20
|
+
(steps: import("@umber-style/core").KeyframesInput<Theme>, options?: import("@umber-style/core").KeyframesOptions): import("@umber-style/core").Keyframes;
|
|
21
|
+
}, globalStyles: {
|
|
22
|
+
(styles: (theme: Theme) => import("@umber-style/core").GlobalStyleObject): import("@umber-style/core").GlobalStyles<Theme>;
|
|
23
|
+
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").GlobalStyles<Theme>;
|
|
24
|
+
(styles: import("@umber-style/core").GlobalStylesInput<Theme>): import("@umber-style/core").GlobalStyles<Theme>;
|
|
25
|
+
}, Global: (props: GlobalProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
26
|
+
export { type AlphaColor, type CSSObject, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
|
package/dist/index.server.d.mts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
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";
|
|
1
|
+
import { AlphaColor, CSSObject, CacheProviderProps, ComponentSelector, CreateStyled, CreateStyledComponent, CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, GlobalInput, GlobalProps, GlobalStyleObject, GlobalStyles, Interpolation, InterpolationResult, Keyframes, KeyframesSteps, NestedKey, PropsOf, SchemeKey, SchemeName, SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, SheetEntry, StaticTemplateValue, Style, StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, TemplateValue, Theme, ThemeInput, ThemeKey, ThemeProviderProps, ThemeScopeProps, UmberCache, WebNested, WebProperties, WebStyle, WebStyleObject, WebThemeProviderProps } from "./types.mjs";
|
|
2
2
|
import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
|
|
3
3
|
import { bindEngine, createStyle } from "./createStyle.server.mjs";
|
|
4
4
|
import { createDefaultStyle } from "./defaultStyle.server.mjs";
|
|
5
|
-
export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<
|
|
5
|
+
export declare const configure: (options: DefaultStyleOptions) => void, getEngine: () => import("@umber-style/core").Engine<Theme>, styled: Styled<Theme>, StyleSheet: {
|
|
6
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:
|
|
7
|
+
create<K extends string>(styles: (theme: Theme) => Record<K, import("@umber-style/core").WebStyleObject>): SheetDefinition<Record<K, import("@umber-style/core").WebStyleObject>, import("@umber-style/core").SheetEntry>;
|
|
8
8
|
}, useStyle: {
|
|
9
9
|
<K extends string>(sheet: { readonly [P in K]: import("@umber-style/core").SheetEntry; }): { readonly [P in K]: import("@umber-style/core").SheetEntry; };
|
|
10
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
|
-
},
|
|
11
|
+
}, useTheme: () => Theme, readTheme: () => Theme, ThemeProvider: (props: WebThemeProviderProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>, apply: (...entries: (import("@umber-style/core").SheetEntry | string | null | undefined | false)[]) => {
|
|
12
12
|
className?: string;
|
|
13
|
-
}, themeClass: (theme: {
|
|
13
|
+
}, css: CssFunction, themeClass: (theme: {
|
|
14
14
|
readonly _theme?: never;
|
|
15
15
|
}, colorScheme?: import("@umber-style/core").ColorScheme) => string, when: (theme: {
|
|
16
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
|
-
|
|
17
|
+
}, colorScheme?: import("@umber-style/core").ColorScheme) => import("@umber-style/core").ThemeKey, whenScheme: (scheme: import("@umber-style/core").SchemeName) => import("@umber-style/core").SchemeKey, keyframes: {
|
|
18
|
+
(steps: (theme: Theme) => import("@umber-style/core").KeyframesSteps, options?: import("@umber-style/core").KeyframesOptions): import("@umber-style/core").Keyframes;
|
|
19
|
+
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").Keyframes;
|
|
20
|
+
(steps: import("@umber-style/core").KeyframesInput<Theme>, options?: import("@umber-style/core").KeyframesOptions): import("@umber-style/core").Keyframes;
|
|
21
|
+
}, globalStyles: {
|
|
22
|
+
(styles: (theme: Theme) => import("@umber-style/core").GlobalStyleObject): import("@umber-style/core").GlobalStyles<Theme>;
|
|
23
|
+
(template: TemplateStringsArray, ...values: import("@umber-style/core").TemplateValue<unknown, Theme>[]): import("@umber-style/core").GlobalStyles<Theme>;
|
|
24
|
+
(styles: import("@umber-style/core").GlobalStylesInput<Theme>): import("@umber-style/core").GlobalStyles<Theme>;
|
|
25
|
+
}, Global: (props: GlobalProps<Theme>) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
|
26
|
+
export { type AlphaColor, type CSSObject, CacheProviderProps, type ComponentSelector, CreateStyled, CreateStyledComponent, type CssArgument, CssFunction, DefaultStyleOptions, FilteringStyledOptions, type GlobalInput, GlobalProps, type GlobalStyleObject, type GlobalStyles, Interpolation, type InterpolationResult, type Keyframes, type KeyframesSteps, type NestedKey, PropsOf, type SchemeKey, type SchemeName, type SerializedStyles, ServerStyle, ServerStyleOptions, SheetDefinition, type SheetEntry, type StaticTemplateValue, Style, type StyleObject, StyleOptions, StyleProp, Styled, StyledCall, StyledComponent, StyledFactory, StyledOptions, StyledStatics, StyledTags, type TemplateValue, Theme, type ThemeInput, type ThemeKey, ThemeProviderProps, ThemeScopeProps, type UmberCache, type WebNested, type WebProperties, WebStyle, type WebStyleObject, WebThemeProviderProps, add, alpha, at, bindEngine, createDefaultStyle, createStyle, divide, multiply, negate, subtract };
|
package/dist/index.server.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDefaultStyle } from "./defaultStyle.server.mjs";
|
|
2
2
|
import { add, alpha, at, divide, multiply, negate, subtract } from "@umber-style/core";
|
|
3
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 };
|
|
4
|
+
const { configure, getEngine, styled, StyleSheet, useStyle, useTheme, readTheme, ThemeProvider, apply, css, themeClass, when, whenScheme, keyframes, globalStyles, Global } = createDefaultStyle();
|
|
5
|
+
export { Global, StyleSheet, ThemeProvider, add, alpha, apply, at, bindEngine, configure, createDefaultStyle, createStyle, css, divide, getEngine, globalStyles, keyframes, multiply, negate, readTheme, styled, subtract, themeClass, useStyle, useTheme, when, whenScheme };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/plainTheme.ts
|
|
2
|
+
/** What `toPlain` returns for a value that cannot cross. */
|
|
3
|
+
const DROPPED = Symbol("dropped");
|
|
4
|
+
/** Whether `value` is an object made by a literal, or with no prototype. */
|
|
5
|
+
function isPlainObject(value) {
|
|
6
|
+
const prototype = Object.getPrototypeOf(value);
|
|
7
|
+
return prototype === Object.prototype || prototype === null;
|
|
8
|
+
}
|
|
9
|
+
/** `value` as plain data, the same value when it already is; `DROPPED` for a value that cannot cross. */
|
|
10
|
+
function toPlain(value, path, dropped) {
|
|
11
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
12
|
+
dropped.push(path);
|
|
13
|
+
return DROPPED;
|
|
14
|
+
}
|
|
15
|
+
if (typeof value !== "object" || value === null) return value;
|
|
16
|
+
const joinPath = (key) => path === "" ? String(key) : `${path}.${key}`;
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
const plain = value.map((item, index) => toPlain(item, joinPath(index), dropped)).map((item) => item === DROPPED ? void 0 : item);
|
|
19
|
+
return plain.every((item, index) => item === value[index]) ? value : plain;
|
|
20
|
+
}
|
|
21
|
+
if (!isPlainObject(value)) {
|
|
22
|
+
dropped.push(path);
|
|
23
|
+
return DROPPED;
|
|
24
|
+
}
|
|
25
|
+
const entries = Object.entries(value).map(([key, member]) => [key, toPlain(member, joinPath(key), dropped)]);
|
|
26
|
+
const kept = entries.filter(([, member]) => member !== DROPPED);
|
|
27
|
+
return Object.getPrototypeOf(value) === Object.prototype && kept.length === entries.length && kept.every(([key, member]) => member === value[key]) ? value : Object.fromEntries(kept);
|
|
28
|
+
}
|
|
29
|
+
const plainThemes = /* @__PURE__ */ new WeakMap();
|
|
30
|
+
/**
|
|
31
|
+
* The plain data of `theme`: strings, numbers, booleans, `null`, `undefined`, lists and plain objects,
|
|
32
|
+
* deeply. A function, a symbol and an object that is not plain (a class instance, a `Date`, a `Map`) are
|
|
33
|
+
* left out, and their paths listed. Only own enumerable members are read. Made once for each theme
|
|
34
|
+
* object, so a payload that names one theme in several places holds it once.
|
|
35
|
+
*/
|
|
36
|
+
function toPlainTheme(theme) {
|
|
37
|
+
let found = plainThemes.get(theme);
|
|
38
|
+
if (found === void 0) {
|
|
39
|
+
const dropped = [];
|
|
40
|
+
const plain = toPlain(theme, "", dropped);
|
|
41
|
+
found = {
|
|
42
|
+
theme: plain === DROPPED ? {} : plain,
|
|
43
|
+
dropped
|
|
44
|
+
};
|
|
45
|
+
plainThemes.set(theme, found);
|
|
46
|
+
}
|
|
47
|
+
return found;
|
|
48
|
+
}
|
|
49
|
+
exports.toPlainTheme = toPlainTheme;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/plainTheme.ts
|
|
2
|
+
/** What `toPlain` returns for a value that cannot cross. */
|
|
3
|
+
const DROPPED = Symbol("dropped");
|
|
4
|
+
/** Whether `value` is an object made by a literal, or with no prototype. */
|
|
5
|
+
function isPlainObject(value) {
|
|
6
|
+
const prototype = Object.getPrototypeOf(value);
|
|
7
|
+
return prototype === Object.prototype || prototype === null;
|
|
8
|
+
}
|
|
9
|
+
/** `value` as plain data, the same value when it already is; `DROPPED` for a value that cannot cross. */
|
|
10
|
+
function toPlain(value, path, dropped) {
|
|
11
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
12
|
+
dropped.push(path);
|
|
13
|
+
return DROPPED;
|
|
14
|
+
}
|
|
15
|
+
if (typeof value !== "object" || value === null) return value;
|
|
16
|
+
const joinPath = (key) => path === "" ? String(key) : `${path}.${key}`;
|
|
17
|
+
if (Array.isArray(value)) {
|
|
18
|
+
const plain = value.map((item, index) => toPlain(item, joinPath(index), dropped)).map((item) => item === DROPPED ? void 0 : item);
|
|
19
|
+
return plain.every((item, index) => item === value[index]) ? value : plain;
|
|
20
|
+
}
|
|
21
|
+
if (!isPlainObject(value)) {
|
|
22
|
+
dropped.push(path);
|
|
23
|
+
return DROPPED;
|
|
24
|
+
}
|
|
25
|
+
const entries = Object.entries(value).map(([key, member]) => [key, toPlain(member, joinPath(key), dropped)]);
|
|
26
|
+
const kept = entries.filter(([, member]) => member !== DROPPED);
|
|
27
|
+
return Object.getPrototypeOf(value) === Object.prototype && kept.length === entries.length && kept.every(([key, member]) => member === value[key]) ? value : Object.fromEntries(kept);
|
|
28
|
+
}
|
|
29
|
+
const plainThemes = /* @__PURE__ */ new WeakMap();
|
|
30
|
+
/**
|
|
31
|
+
* The plain data of `theme`: strings, numbers, booleans, `null`, `undefined`, lists and plain objects,
|
|
32
|
+
* deeply. A function, a symbol and an object that is not plain (a class instance, a `Date`, a `Map`) are
|
|
33
|
+
* left out, and their paths listed. Only own enumerable members are read. Made once for each theme
|
|
34
|
+
* object, so a payload that names one theme in several places holds it once.
|
|
35
|
+
*/
|
|
36
|
+
function toPlainTheme(theme) {
|
|
37
|
+
let found = plainThemes.get(theme);
|
|
38
|
+
if (found === void 0) {
|
|
39
|
+
const dropped = [];
|
|
40
|
+
const plain = toPlain(theme, "", dropped);
|
|
41
|
+
found = {
|
|
42
|
+
theme: plain === DROPPED ? {} : plain,
|
|
43
|
+
dropped
|
|
44
|
+
};
|
|
45
|
+
plainThemes.set(theme, found);
|
|
46
|
+
}
|
|
47
|
+
return found;
|
|
48
|
+
}
|
|
49
|
+
export { toPlainTheme };
|
package/dist/serverContext.cjs
CHANGED
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
let react = require("react");
|
|
2
2
|
// src/serverContext.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* in a request writes the slot; the later ones leave it as it is.
|
|
4
|
+
* The slot of the current request, for server components, which have no React context: `React.cache`
|
|
5
|
+
* keeps it for the length of one request, starting at `defaultValue`. It is never shared between two
|
|
6
|
+
* requests, so nothing written there depends on the order in which requests come.
|
|
8
7
|
*/
|
|
9
|
-
function
|
|
10
|
-
|
|
8
|
+
function createRequestSlot(defaultValue, cache = react.cache) {
|
|
9
|
+
return cache(() => ({
|
|
11
10
|
current: defaultValue,
|
|
12
11
|
isSet: false
|
|
13
12
|
}));
|
|
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
13
|
}
|
|
27
|
-
|
|
28
|
-
function readServerContext(context) {
|
|
29
|
-
return context.slot().current;
|
|
30
|
-
}
|
|
31
|
-
exports.createServerOnlyContext = createServerOnlyContext;
|
|
32
|
-
exports.readServerContext = readServerContext;
|
|
14
|
+
exports.createRequestSlot = createRequestSlot;
|
package/dist/serverContext.d.mts
CHANGED
package/dist/serverContext.mjs
CHANGED
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
import { cache } from "react";
|
|
2
2
|
// src/serverContext.ts
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* in a request writes the slot; the later ones leave it as it is.
|
|
4
|
+
* The slot of the current request, for server components, which have no React context: `React.cache`
|
|
5
|
+
* keeps it for the length of one request, starting at `defaultValue`. It is never shared between two
|
|
6
|
+
* requests, so nothing written there depends on the order in which requests come.
|
|
8
7
|
*/
|
|
9
|
-
function
|
|
10
|
-
|
|
8
|
+
function createRequestSlot(defaultValue, cache$1 = cache) {
|
|
9
|
+
return cache$1(() => ({
|
|
11
10
|
current: defaultValue,
|
|
12
11
|
isSet: false
|
|
13
12
|
}));
|
|
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
13
|
}
|
|
27
|
-
|
|
28
|
-
function readServerContext(context) {
|
|
29
|
-
return context.slot().current;
|
|
30
|
-
}
|
|
31
|
-
export { createServerOnlyContext, readServerContext };
|
|
14
|
+
export { createRequestSlot };
|
package/dist/styleElements.cjs
CHANGED
|
@@ -1,22 +1,85 @@
|
|
|
1
1
|
let react = require("react");
|
|
2
|
+
let _umber_style_core = require("@umber-style/core");
|
|
2
3
|
// src/styleElements.ts
|
|
4
|
+
/** The `<style href precedence>` element of `style`, in the precedence of the prefix of `cache`. */
|
|
5
|
+
const toElement = (cache) => ({ href, text }) => (0, react.createElement)("style", {
|
|
6
|
+
key: href,
|
|
7
|
+
href,
|
|
8
|
+
precedence: cache.prefix
|
|
9
|
+
}, text);
|
|
3
10
|
/**
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
11
|
+
* The style elements of the animations in `names` that `sent` does not hold yet, which it adds them to:
|
|
12
|
+
* the `@keyframes` rule that the cache wrote, with the animation name as `href`, so that React sends an
|
|
13
|
+
* animation that many classes use once. The rule is outside every layer, so the element needs no order
|
|
14
|
+
* statement.
|
|
7
15
|
*/
|
|
8
|
-
function
|
|
16
|
+
function collectKeyframesTexts(cache, names, sent) {
|
|
17
|
+
const texts = [];
|
|
18
|
+
for (const name of names) {
|
|
19
|
+
if (sent.has(name)) continue;
|
|
20
|
+
sent.add(name);
|
|
21
|
+
texts.push({
|
|
22
|
+
href: name,
|
|
23
|
+
text: cache.getRules(name).join("")
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return texts;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The style elements, as data, of the classes in `className`: React 19 moves them to the head and renders
|
|
30
|
+
* each `href` once. Each one starts with the order statement of the layers (none without layers), so
|
|
31
|
+
* that it is right on its own: declaring a layer again does not change the order. A name that the cache
|
|
32
|
+
* made no rules for (a class of someone else) gets none. A theme class comes with every variable it has,
|
|
33
|
+
* used or not: its element is sent before the elements that use them, so it cannot know which are used. A
|
|
34
|
+
* class that uses animations comes after the element of each of them, once.
|
|
35
|
+
*/
|
|
36
|
+
function collectStyleTexts(cache, className) {
|
|
37
|
+
const sent = /* @__PURE__ */ new Set();
|
|
9
38
|
return (className ?? "").split(/\s+/).filter(Boolean).flatMap((name) => {
|
|
10
39
|
const rules = cache.getFullRules(name);
|
|
11
40
|
if (rules.length === 0) return [];
|
|
12
|
-
|
|
13
|
-
key: name,
|
|
41
|
+
return [...collectKeyframesTexts(cache, cache.getAnimations(name), sent), {
|
|
14
42
|
href: name,
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
return [(0, react.createElement)("style", props, [cache.layerOrder, ...rules].join(""))];
|
|
43
|
+
text: [cache.layerOrder, ...rules].join("")
|
|
44
|
+
}];
|
|
18
45
|
});
|
|
19
46
|
}
|
|
47
|
+
/** The `<style href precedence>` elements for the classes in `className` (see `collectStyleTexts`); the precedence is the prefix of the cache. */
|
|
48
|
+
function createStyleElements(cache, className) {
|
|
49
|
+
return collectStyleTexts(cache, className).map(toElement(cache));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The `<style href precedence>` elements of global rules that the cache wrote (`insertGlobal`): for each set
|
|
53
|
+
* with rules, the elements of the animations it uses, then its own, with its id as `href` and the order
|
|
54
|
+
* statement of the layers first. Each `href` once.
|
|
55
|
+
*/
|
|
56
|
+
function createGlobalElements(cache, sets) {
|
|
57
|
+
const sent = /* @__PURE__ */ new Set();
|
|
58
|
+
return sets.flatMap(({ id, rules, animations }) => {
|
|
59
|
+
if (rules.length === 0 || sent.has(id)) return [];
|
|
60
|
+
sent.add(id);
|
|
61
|
+
return [...collectKeyframesTexts(cache, animations, sent), {
|
|
62
|
+
href: id,
|
|
63
|
+
text: [cache.layerOrder, ...rules].join("")
|
|
64
|
+
}];
|
|
65
|
+
}).map(toElement(cache));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The marker of global rules that a server render sends in place of their style elements (none is sent
|
|
69
|
+
* under a cache provider, or without `hasServerStyleElements`): a `<meta name="<prefix>-global">` whose
|
|
70
|
+
* `content` is the ids of the sets that have rules. React moves it to the head, and `extractPageStyles`
|
|
71
|
+
* reads it, so that the CSS of this page holds the sets and the CSS of another page does not. Like the
|
|
72
|
+
* stamp, it is rendered where there is no document only; a hydration skips it. None when no set has rules.
|
|
73
|
+
*/
|
|
74
|
+
function createGlobalMarkerElements(cache, sets) {
|
|
75
|
+
const marker = (0, _umber_style_core.createGlobalMarker)(cache.prefix, sets);
|
|
76
|
+
if (marker === void 0) return [];
|
|
77
|
+
return [(0, react.createElement)("meta", {
|
|
78
|
+
key: marker.name,
|
|
79
|
+
name: marker.name,
|
|
80
|
+
content: marker.ids
|
|
81
|
+
})];
|
|
82
|
+
}
|
|
20
83
|
/**
|
|
21
84
|
* The element that carries the options of the cache, for the browser to compare with its own: a `<meta>`
|
|
22
85
|
* named `<prefix>-options`, which React moves to the head. It is not a style element, because a server
|
|
@@ -29,5 +92,8 @@ function createStampElement(cache) {
|
|
|
29
92
|
content: cache.fingerprint
|
|
30
93
|
});
|
|
31
94
|
}
|
|
95
|
+
exports.collectStyleTexts = collectStyleTexts;
|
|
96
|
+
exports.createGlobalElements = createGlobalElements;
|
|
97
|
+
exports.createGlobalMarkerElements = createGlobalMarkerElements;
|
|
32
98
|
exports.createStampElement = createStampElement;
|
|
33
99
|
exports.createStyleElements = createStyleElements;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/styleElements.mjs
CHANGED
|
@@ -1,22 +1,85 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
|
+
import { createGlobalMarker } from "@umber-style/core";
|
|
2
3
|
// src/styleElements.ts
|
|
4
|
+
/** The `<style href precedence>` element of `style`, in the precedence of the prefix of `cache`. */
|
|
5
|
+
const toElement = (cache) => ({ href, text }) => createElement("style", {
|
|
6
|
+
key: href,
|
|
7
|
+
href,
|
|
8
|
+
precedence: cache.prefix
|
|
9
|
+
}, text);
|
|
3
10
|
/**
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
11
|
+
* The style elements of the animations in `names` that `sent` does not hold yet, which it adds them to:
|
|
12
|
+
* the `@keyframes` rule that the cache wrote, with the animation name as `href`, so that React sends an
|
|
13
|
+
* animation that many classes use once. The rule is outside every layer, so the element needs no order
|
|
14
|
+
* statement.
|
|
7
15
|
*/
|
|
8
|
-
function
|
|
16
|
+
function collectKeyframesTexts(cache, names, sent) {
|
|
17
|
+
const texts = [];
|
|
18
|
+
for (const name of names) {
|
|
19
|
+
if (sent.has(name)) continue;
|
|
20
|
+
sent.add(name);
|
|
21
|
+
texts.push({
|
|
22
|
+
href: name,
|
|
23
|
+
text: cache.getRules(name).join("")
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return texts;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The style elements, as data, of the classes in `className`: React 19 moves them to the head and renders
|
|
30
|
+
* each `href` once. Each one starts with the order statement of the layers (none without layers), so
|
|
31
|
+
* that it is right on its own: declaring a layer again does not change the order. A name that the cache
|
|
32
|
+
* made no rules for (a class of someone else) gets none. A theme class comes with every variable it has,
|
|
33
|
+
* used or not: its element is sent before the elements that use them, so it cannot know which are used. A
|
|
34
|
+
* class that uses animations comes after the element of each of them, once.
|
|
35
|
+
*/
|
|
36
|
+
function collectStyleTexts(cache, className) {
|
|
37
|
+
const sent = /* @__PURE__ */ new Set();
|
|
9
38
|
return (className ?? "").split(/\s+/).filter(Boolean).flatMap((name) => {
|
|
10
39
|
const rules = cache.getFullRules(name);
|
|
11
40
|
if (rules.length === 0) return [];
|
|
12
|
-
|
|
13
|
-
key: name,
|
|
41
|
+
return [...collectKeyframesTexts(cache, cache.getAnimations(name), sent), {
|
|
14
42
|
href: name,
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
return [createElement("style", props, [cache.layerOrder, ...rules].join(""))];
|
|
43
|
+
text: [cache.layerOrder, ...rules].join("")
|
|
44
|
+
}];
|
|
18
45
|
});
|
|
19
46
|
}
|
|
47
|
+
/** The `<style href precedence>` elements for the classes in `className` (see `collectStyleTexts`); the precedence is the prefix of the cache. */
|
|
48
|
+
function createStyleElements(cache, className) {
|
|
49
|
+
return collectStyleTexts(cache, className).map(toElement(cache));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The `<style href precedence>` elements of global rules that the cache wrote (`insertGlobal`): for each set
|
|
53
|
+
* with rules, the elements of the animations it uses, then its own, with its id as `href` and the order
|
|
54
|
+
* statement of the layers first. Each `href` once.
|
|
55
|
+
*/
|
|
56
|
+
function createGlobalElements(cache, sets) {
|
|
57
|
+
const sent = /* @__PURE__ */ new Set();
|
|
58
|
+
return sets.flatMap(({ id, rules, animations }) => {
|
|
59
|
+
if (rules.length === 0 || sent.has(id)) return [];
|
|
60
|
+
sent.add(id);
|
|
61
|
+
return [...collectKeyframesTexts(cache, animations, sent), {
|
|
62
|
+
href: id,
|
|
63
|
+
text: [cache.layerOrder, ...rules].join("")
|
|
64
|
+
}];
|
|
65
|
+
}).map(toElement(cache));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The marker of global rules that a server render sends in place of their style elements (none is sent
|
|
69
|
+
* under a cache provider, or without `hasServerStyleElements`): a `<meta name="<prefix>-global">` whose
|
|
70
|
+
* `content` is the ids of the sets that have rules. React moves it to the head, and `extractPageStyles`
|
|
71
|
+
* reads it, so that the CSS of this page holds the sets and the CSS of another page does not. Like the
|
|
72
|
+
* stamp, it is rendered where there is no document only; a hydration skips it. None when no set has rules.
|
|
73
|
+
*/
|
|
74
|
+
function createGlobalMarkerElements(cache, sets) {
|
|
75
|
+
const marker = createGlobalMarker(cache.prefix, sets);
|
|
76
|
+
if (marker === void 0) return [];
|
|
77
|
+
return [createElement("meta", {
|
|
78
|
+
key: marker.name,
|
|
79
|
+
name: marker.name,
|
|
80
|
+
content: marker.ids
|
|
81
|
+
})];
|
|
82
|
+
}
|
|
20
83
|
/**
|
|
21
84
|
* The element that carries the options of the cache, for the browser to compare with its own: a `<meta>`
|
|
22
85
|
* named `<prefix>-options`, which React moves to the head. It is not a style element, because a server
|
|
@@ -29,4 +92,4 @@ function createStampElement(cache) {
|
|
|
29
92
|
content: cache.fingerprint
|
|
30
93
|
});
|
|
31
94
|
}
|
|
32
|
-
export { createStampElement, createStyleElements };
|
|
95
|
+
export { collectStyleTexts, createGlobalElements, createGlobalMarkerElements, createStampElement, createStyleElements };
|