@tenphi/tasty 0.0.0-snapshot.1f1c00a → 0.0.0-snapshot.1feecc6
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/README.md +403 -380
- package/dist/babel-types-Dc5zghyE.d.ts +18 -0
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/build-config-D9Iq8QQm.js +60 -0
- package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
- package/dist/chunks/{collector-D2ARGT2L.js → collector-Cb8ah2JF.js} +8 -6
- package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
- package/dist/chunks/{config-engine-DEmmPPdp.js → config-engine-CMYFZYQh.js} +5 -5
- package/dist/chunks/config-engine-CMYFZYQh.js.map +1 -0
- package/dist/chunks/config-file-DlZXJMj8.js +25 -0
- package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
- package/dist/chunks/{css-definitions-DotDkIXt.js → css-definitions-B4aWBkH3.js} +130 -96
- package/dist/chunks/css-definitions-B4aWBkH3.js.map +1 -0
- package/dist/chunks/{debug-D8pg9RGI.js → debug-D2Pu7Xhy.js} +6 -6
- package/dist/chunks/{debug-D8pg9RGI.js.map → debug-D2Pu7Xhy.js.map} +1 -1
- package/dist/chunks/{dsl-DRhFWQzo.js → dsl-CsFl9LGn.js} +132 -52
- package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
- package/dist/chunks/{react-runtime-BpxlOTbO.js → react-runtime-DHiopXCu.js} +193 -64
- package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
- package/dist/chunks/{runtime-engine-CKFXUH-A.js → runtime-engine-NGCofNXy.js} +72 -53
- package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
- package/dist/chunks/{runtime-state-BxaLhVdP.js → runtime-state-lZjMbvwV.js} +28 -3
- package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
- package/dist/chunks/{style-engine-BBbBuSkT.js → style-engine-DnkV_4Jg.js} +488 -146
- package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
- package/dist/chunks/{zero-engine-gJrKBRiw.js → zero-engine-DcwaCvFs.js} +62 -27
- package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
- package/dist/{collector-w4mBj5gd.d.ts → collector-D2OT6I2G.d.ts} +2 -2
- package/dist/{config-CZWCzBr6.d.ts → config-C4ftFxgI.d.ts} +41 -23
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +7 -7
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/{index-G9JuwM9p.d.ts → index-DxQNRj50.d.ts} +65 -21
- package/dist/index.d.ts +5 -5
- package/dist/index.js +8 -8
- package/dist/{merge-styles-VXwJ0Frr.d.ts → merge-styles-D39qBtox.d.ts} +2 -2
- package/dist/ssr/astro.js +4 -4
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +3 -22
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +1 -1
- package/dist/ssr/next-config.js +13 -18
- package/dist/ssr/next-config.js.map +1 -1
- package/dist/ssr/next.d.ts +1 -1
- package/dist/ssr/next.js +3 -3
- package/dist/static/index.d.ts +2 -2
- package/dist/{types-JEY8PVYP.d.ts → types-CYQIhUg1.d.ts} +10 -8
- package/dist/zero/babel.d.ts +73 -2
- package/dist/zero/babel.js +51 -48
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +59 -3
- package/dist/zero/index.js +25 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +2 -1
- package/dist/zero/next.js +3 -7
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +4 -1
- package/docs/adoption.md +25 -17
- package/docs/ai-agents.md +43 -34
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +187 -69
- package/docs/debug.md +3 -2
- package/docs/design-system.md +117 -15
- package/docs/dsl.md +262 -116
- package/docs/getting-started.md +81 -24
- package/docs/injector.md +41 -40
- package/docs/methodology.md +46 -21
- package/docs/migration-v3.md +3 -3
- package/docs/pipeline.md +22 -19
- package/docs/plugins.md +21 -41
- package/docs/react-api.md +74 -11
- package/docs/runtime-benchmarks.md +11 -11
- package/docs/ssr.md +92 -66
- package/docs/styles.md +85 -19
- package/docs/tasty-static.md +175 -57
- package/package.json +45 -32
- package/tasty.config.ts +1 -0
- package/dist/babel-rZcEwPLM.d.ts +0 -82
- package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
- package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
- package/dist/chunks/build-config-CL4eRu2z.js +0 -42
- package/dist/chunks/build-config-CL4eRu2z.js.map +0 -1
- package/dist/chunks/collector-D2ARGT2L.js.map +0 -1
- package/dist/chunks/config-engine-DEmmPPdp.js.map +0 -1
- package/dist/chunks/css-definitions-DotDkIXt.js.map +0 -1
- package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
- package/dist/chunks/react-runtime-BpxlOTbO.js.map +0 -1
- package/dist/chunks/runtime-engine-CKFXUH-A.js.map +0 -1
- package/dist/chunks/runtime-state-BxaLhVdP.js.map +0 -1
- package/dist/chunks/style-engine-BBbBuSkT.js.map +0 -1
- package/dist/chunks/zero-engine-gJrKBRiw.js.map +0 -1
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { n as isSelector, t as mergeStyles } from "./shared-utils-y-HjvPN4.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { K as parseFunctionName, N as hashString, O as makeCounterStyleName, S as formatFontFaceRule, W as formatFunctionRule, _ as formatCounterStyleRule, b as fontFaceContentHash, i as formatKeyframesCSS, k as makeKeyframeName, m as resolveSelectorKeyframes, n as formatGlobalRules, o as formatPropertyCSS, q as registerFunctionPolyfill } from "./css-definitions-B4aWBkH3.js";
|
|
3
|
+
import { b as renderStyles, i as baseStylePropsRegistry, q as isFunctionsPolyfillEnabled, s as BASE_STYLES } from "./style-engine-DnkV_4Jg.js";
|
|
4
|
+
import { u as getGlobalKeyframes } from "./runtime-state-lZjMbvwV.js";
|
|
5
|
+
import { $ as openBatchWindow, B as getGlobalInjector, F as touch, H as getNamePrefix, M as keyframes, O as injectGlobal, X as closeBatchWindow, c as hasKeys, d as checkRequestScope, f as getRSCCache, h as queueRSCCSS, i as modAttrs, k as injectRawCSS, l as collectAutoInferredProperties, m as pushRSCCSS, n as createClientState, o as computeStyles, p as getStyleTarget, r as processTokens, s as resolveRecipes, t as depsEqual, tt as propHandlerRegistry, u as collectAutoInferredPropertiesRSC, z as getConfig } from "./runtime-engine-NGCofNXy.js";
|
|
6
|
+
import React, { Fragment, createElement, forwardRef } from "react";
|
|
6
7
|
//#region src/utils/get-display-name.ts
|
|
7
8
|
const DEFAULT_NAME = "Anonymous";
|
|
9
|
+
function nameOf(type) {
|
|
10
|
+
if (typeof type === "string") return type;
|
|
11
|
+
if (!type || typeof type !== "function" && typeof type !== "object") return;
|
|
12
|
+
const { displayName, name, render, type: inner } = type;
|
|
13
|
+
if (displayName) return displayName;
|
|
14
|
+
if (typeof type === "function") return name || void 0;
|
|
15
|
+
return nameOf(render) ?? nameOf(inner);
|
|
16
|
+
}
|
|
8
17
|
function getDisplayName(Component, fallbackName = DEFAULT_NAME) {
|
|
9
|
-
|
|
10
|
-
return fallbackName;
|
|
18
|
+
return nameOf(Component) ?? fallbackName;
|
|
11
19
|
}
|
|
12
20
|
//#endregion
|
|
13
21
|
//#region src/utils/is-valid-element-type.ts
|
|
@@ -36,7 +44,7 @@ function createSubElement(elementName, definition) {
|
|
|
36
44
|
const defaultQa = config.qa;
|
|
37
45
|
const defaultQaVal = config.qaVal;
|
|
38
46
|
const SubElement = forwardRef((props, ref) => {
|
|
39
|
-
const { qa, qaVal, mods, tokens, isDisabled, isHidden, isChecked, className, style, ...htmlProps } = props;
|
|
47
|
+
const { qa, qaVal, mods, tokens, isDisabled, isHidden, isChecked, theme, className, style, ...htmlProps } = props;
|
|
40
48
|
let modDataAttrs;
|
|
41
49
|
if (mods) modDataAttrs = modAttrs(mods);
|
|
42
50
|
const tokenStyle = tokens ? processTokens(tokens) : void 0;
|
|
@@ -49,6 +57,7 @@ function createSubElement(elementName, definition) {
|
|
|
49
57
|
"data-element": elementName,
|
|
50
58
|
"data-qa": qa ?? defaultQa,
|
|
51
59
|
"data-qaval": qaVal ?? defaultQaVal,
|
|
60
|
+
"data-theme": theme,
|
|
52
61
|
...modDataAttrs || {},
|
|
53
62
|
...htmlProps,
|
|
54
63
|
className,
|
|
@@ -61,11 +70,90 @@ function createSubElement(elementName, definition) {
|
|
|
61
70
|
handleIsProperties(elementProps);
|
|
62
71
|
if (elementProps["data-qa"] === void 0) delete elementProps["data-qa"];
|
|
63
72
|
if (elementProps["data-qaval"] === void 0) delete elementProps["data-qaval"];
|
|
73
|
+
if (elementProps["data-theme"] === void 0) delete elementProps["data-theme"];
|
|
64
74
|
return createElement(tag, elementProps);
|
|
65
75
|
});
|
|
66
76
|
SubElement.displayName = `SubElement(${elementName})`;
|
|
67
77
|
return SubElement;
|
|
68
78
|
}
|
|
79
|
+
function createSubElements(elements) {
|
|
80
|
+
const subElements = {};
|
|
81
|
+
for (const [name, definition] of Object.entries(elements)) subElements[name] = createSubElement(name, definition);
|
|
82
|
+
return subElements;
|
|
83
|
+
}
|
|
84
|
+
const REACT_STATICS = /* @__PURE__ */ new Set([
|
|
85
|
+
"$$typeof",
|
|
86
|
+
"render",
|
|
87
|
+
"type",
|
|
88
|
+
"compare",
|
|
89
|
+
"displayName",
|
|
90
|
+
"defaultProps",
|
|
91
|
+
"propTypes",
|
|
92
|
+
"contextType",
|
|
93
|
+
"contextTypes",
|
|
94
|
+
"childContextTypes",
|
|
95
|
+
"getDerivedStateFromProps",
|
|
96
|
+
"getDerivedStateFromError"
|
|
97
|
+
]);
|
|
98
|
+
function hoistComponentStatics(target, source) {
|
|
99
|
+
for (const key of Object.keys(source)) {
|
|
100
|
+
if (REACT_STATICS.has(key) || key in target) continue;
|
|
101
|
+
const value = source[key];
|
|
102
|
+
if (typeof value !== "string" && isValidElementType(value)) target[key] = value;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function buildVariantStylesMap(defaultStyles, variants) {
|
|
106
|
+
let baseStyles = defaultStyles;
|
|
107
|
+
let extensionStyles;
|
|
108
|
+
if (defaultStyles) for (const key of Object.keys(defaultStyles)) {
|
|
109
|
+
if (isSelector(key)) continue;
|
|
110
|
+
const value = defaultStyles[key];
|
|
111
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value) && !("" in value)) {
|
|
112
|
+
if (!extensionStyles) {
|
|
113
|
+
baseStyles = { ...defaultStyles };
|
|
114
|
+
extensionStyles = {};
|
|
115
|
+
}
|
|
116
|
+
extensionStyles[key] = value;
|
|
117
|
+
delete baseStyles[key];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const variantStylesMap = {};
|
|
121
|
+
for (const [variant, variantStyles] of Object.entries(variants)) variantStylesMap[variant] = extensionStyles ? mergeStyles(baseStyles, variantStyles, extensionStyles) : mergeStyles(baseStyles, variantStyles);
|
|
122
|
+
if (!variantStylesMap["default"]) variantStylesMap["default"] = defaultStyles;
|
|
123
|
+
return variantStylesMap;
|
|
124
|
+
}
|
|
125
|
+
function getMergedStyles(cache, base, extra) {
|
|
126
|
+
let entry = cache.get(extra);
|
|
127
|
+
if (!entry || entry.base !== base) {
|
|
128
|
+
entry = {
|
|
129
|
+
base,
|
|
130
|
+
styles: mergeStyles(base, extra)
|
|
131
|
+
};
|
|
132
|
+
cache.set(extra, entry);
|
|
133
|
+
}
|
|
134
|
+
return entry;
|
|
135
|
+
}
|
|
136
|
+
function takeProps(props, keys) {
|
|
137
|
+
let taken;
|
|
138
|
+
for (const key of keys) if (key in props) {
|
|
139
|
+
if (!taken) taken = {};
|
|
140
|
+
taken[key] = props[key];
|
|
141
|
+
delete props[key];
|
|
142
|
+
}
|
|
143
|
+
return taken;
|
|
144
|
+
}
|
|
145
|
+
function takeTokenProps(props, mapping) {
|
|
146
|
+
let tokens;
|
|
147
|
+
for (const [propName, tokenKey] of mapping) if (propName in props) {
|
|
148
|
+
if (!tokens) tokens = {};
|
|
149
|
+
tokens[tokenKey] = props[propName];
|
|
150
|
+
delete props[propName];
|
|
151
|
+
}
|
|
152
|
+
return tokens;
|
|
153
|
+
}
|
|
154
|
+
function getModPropsKeys(def) {
|
|
155
|
+
return Array.isArray(def) ? def : Object.keys(def);
|
|
156
|
+
}
|
|
69
157
|
function buildTokenPropsMapping(def) {
|
|
70
158
|
if (Array.isArray(def)) return def.map((propName) => {
|
|
71
159
|
if (propName.endsWith("Color") && propName.length > 5) return [propName, `#${propName.slice(0, -5)}`];
|
|
@@ -78,17 +166,30 @@ function tasty(Component, options) {
|
|
|
78
166
|
return tastyElement(Component);
|
|
79
167
|
}
|
|
80
168
|
function tastyWrap(Component, options) {
|
|
81
|
-
const { as: extendTag, element: extendElement, styleProps
|
|
169
|
+
const { as: extendTag, element: extendElement, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, variant: defaultVariant, elements, ...defaultProps } = options ?? {};
|
|
170
|
+
const defaultStyles = defaultProps.styles;
|
|
171
|
+
const variantStylesMap = variants ? buildVariantStylesMap(defaultStyles, variants) : void 0;
|
|
172
|
+
const fallbackVariant = defaultVariant ?? "default";
|
|
173
|
+
const stylePropNames = styleProps;
|
|
174
|
+
const modPropsKeys = modPropsDef ? getModPropsKeys(modPropsDef) : void 0;
|
|
175
|
+
const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
|
|
82
176
|
const propsWithStyles = ["styles"];
|
|
83
177
|
for (const prop of Object.keys(defaultProps)) if (prop.endsWith("Styles")) propsWithStyles.push(prop);
|
|
178
|
+
const mergedCache = /* @__PURE__ */ new WeakMap();
|
|
84
179
|
const _WrappedComponent = forwardRef((props, ref) => {
|
|
85
180
|
const { as, element, ...restProps } = props;
|
|
181
|
+
const propStyles = stylePropNames ? takeProps(restProps, stylePropNames) : void 0;
|
|
182
|
+
const propMods = modPropsKeys ? takeProps(restProps, modPropsKeys) : void 0;
|
|
183
|
+
const propTokens = tokenPropsMapping ? takeTokenProps(restProps, tokenPropsMapping) : void 0;
|
|
184
|
+
const variant = restProps.variant ?? defaultVariant;
|
|
185
|
+
const baseStyles = variantStylesMap ? variantStylesMap[variant || fallbackVariant] ?? variantStylesMap[fallbackVariant] ?? variantStylesMap["default"] : defaultStyles;
|
|
86
186
|
const mergedStylesMap = {};
|
|
87
187
|
for (const prop of propsWithStyles) {
|
|
88
188
|
const restValue = restProps[prop];
|
|
89
|
-
const defaultValue = defaultProps[prop];
|
|
90
|
-
mergedStylesMap[prop] = restValue != null && defaultValue != null ?
|
|
189
|
+
const defaultValue = prop === "styles" ? baseStyles : defaultProps[prop];
|
|
190
|
+
mergedStylesMap[prop] = restValue != null && defaultValue != null ? getMergedStyles(mergedCache, defaultValue, restValue).styles : restValue ?? defaultValue;
|
|
91
191
|
}
|
|
192
|
+
if (propStyles) mergedStylesMap.styles = mergeStyles(mergedStylesMap.styles, propStyles);
|
|
92
193
|
const elementProps = {
|
|
93
194
|
...defaultProps,
|
|
94
195
|
...restProps,
|
|
@@ -97,40 +198,36 @@ function tastyWrap(Component, options) {
|
|
|
97
198
|
element: element || extendElement,
|
|
98
199
|
ref
|
|
99
200
|
};
|
|
201
|
+
if (variant !== void 0) elementProps.variant = variant;
|
|
202
|
+
if (propMods) elementProps.mods = {
|
|
203
|
+
...elementProps.mods,
|
|
204
|
+
...propMods
|
|
205
|
+
};
|
|
206
|
+
if (propTokens) elementProps.tokens = {
|
|
207
|
+
...elementProps.tokens,
|
|
208
|
+
...propTokens
|
|
209
|
+
};
|
|
100
210
|
return createElement(Component, elementProps);
|
|
101
211
|
});
|
|
102
212
|
_WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(Component, defaultProps.qa ?? extendTag ?? "Anonymous")})`;
|
|
213
|
+
hoistComponentStatics(_WrappedComponent, Component);
|
|
214
|
+
if (elements) Object.assign(_WrappedComponent, createSubElements(elements));
|
|
103
215
|
return _WrappedComponent;
|
|
104
216
|
}
|
|
105
217
|
function tastyElement(tastyOptions) {
|
|
106
|
-
const { as: originalAs = "div", element: defaultElement, styles: defaultStyles, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, tokens: defaultTokens, elements, ...defaultProps } = tastyOptions;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
let baseStyles = defaultStyles;
|
|
110
|
-
let extensionStyles;
|
|
111
|
-
if (defaultStyles) for (const key of Object.keys(defaultStyles)) {
|
|
112
|
-
if (isSelector(key)) continue;
|
|
113
|
-
const value = defaultStyles[key];
|
|
114
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value) && !("" in value)) {
|
|
115
|
-
if (!extensionStyles) {
|
|
116
|
-
baseStyles = { ...defaultStyles };
|
|
117
|
-
extensionStyles = {};
|
|
118
|
-
}
|
|
119
|
-
extensionStyles[key] = value;
|
|
120
|
-
delete baseStyles[key];
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
variantStylesMap = {};
|
|
124
|
-
for (const [variant, variantStyles] of Object.entries(variants)) variantStylesMap[variant] = extensionStyles ? mergeStyles(baseStyles, variantStyles, extensionStyles) : mergeStyles(baseStyles, variantStyles);
|
|
125
|
-
if (!variantStylesMap["default"]) variantStylesMap["default"] = defaultStyles;
|
|
126
|
-
}
|
|
218
|
+
const { as: originalAs = "div", element: defaultElement, styles: defaultStyles, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, variant: defaultVariant, tokens: defaultTokens, elements, ...defaultProps } = tastyOptions;
|
|
219
|
+
const variantStylesMap = variants ? buildVariantStylesMap(defaultStyles, variants) : void 0;
|
|
220
|
+
const fallbackStyles = variantStylesMap ? variantStylesMap[defaultVariant ?? "default"] ?? variantStylesMap["default"] : defaultStyles;
|
|
127
221
|
const { qa: defaultQa, qaVal: defaultQaVal, ...otherDefaultProps } = defaultProps;
|
|
128
222
|
const ownPropsToCheck = styleProps ? styleProps.concat(BASE_STYLES) : BASE_STYLES;
|
|
129
223
|
let propsToCheck = ownPropsToCheck;
|
|
130
224
|
let propsToCheckVersion = -1;
|
|
131
|
-
const modPropsKeys = modPropsDef ?
|
|
225
|
+
const modPropsKeys = modPropsDef ? getModPropsKeys(modPropsDef) : void 0;
|
|
132
226
|
const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
|
|
133
|
-
|
|
227
|
+
let classNameCache = /* @__PURE__ */ new Map();
|
|
228
|
+
let mergedCache = /* @__PURE__ */ new WeakMap();
|
|
229
|
+
let cacheInjector;
|
|
230
|
+
let cacheEvictions = 0;
|
|
134
231
|
const STABLE_STYLES = { stableStyles: true };
|
|
135
232
|
const _TastyComponent = forwardRef((incomingProps, ref) => {
|
|
136
233
|
const applyPropHandlers = propHandlerRegistry.apply;
|
|
@@ -151,33 +248,42 @@ function tastyElement(tastyOptions) {
|
|
|
151
248
|
delete otherProps[key];
|
|
152
249
|
}
|
|
153
250
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
251
|
+
const propMods = modPropsKeys ? takeProps(otherProps, modPropsKeys) : void 0;
|
|
252
|
+
const propTokens = tokenPropsMapping ? takeTokenProps(otherProps, tokenPropsMapping) : void 0;
|
|
253
|
+
const baseStyles = variantStylesMap ? variant && variantStylesMap[variant] || fallbackStyles : defaultStyles;
|
|
254
|
+
const hasInstanceStyles = !!styles && hasKeys(styles);
|
|
255
|
+
const useFactoryCache = typeof document !== "undefined";
|
|
256
|
+
if (useFactoryCache) {
|
|
257
|
+
const injector = getGlobalInjector();
|
|
258
|
+
if (injector !== cacheInjector || injector.evictions !== cacheEvictions) {
|
|
259
|
+
classNameCache = /* @__PURE__ */ new Map();
|
|
260
|
+
mergedCache = /* @__PURE__ */ new WeakMap();
|
|
261
|
+
cacheInjector = injector;
|
|
262
|
+
cacheEvictions = injector.evictions;
|
|
160
263
|
}
|
|
161
264
|
}
|
|
162
|
-
let
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
265
|
+
let allStyles;
|
|
266
|
+
let generatedClassName;
|
|
267
|
+
let mergedEntry;
|
|
268
|
+
if (propStyles) allStyles = mergeStyles(baseStyles, styles, propStyles);
|
|
269
|
+
else if (hasInstanceStyles) {
|
|
270
|
+
if (useFactoryCache) {
|
|
271
|
+
mergedEntry = getMergedStyles(mergedCache, baseStyles, styles);
|
|
272
|
+
allStyles = mergedEntry.styles;
|
|
273
|
+
generatedClassName = mergedEntry.className;
|
|
274
|
+
} else allStyles = mergeStyles(baseStyles, styles);
|
|
275
|
+
} else {
|
|
276
|
+
allStyles = baseStyles;
|
|
277
|
+
if (useFactoryCache) generatedClassName = classNameCache.get(baseStyles);
|
|
169
278
|
}
|
|
170
|
-
const baseStyles = variantStylesMap ? variantStylesMap[variant || "default"] ?? variantStylesMap["default"] : defaultStyles;
|
|
171
|
-
const allStyles = styles && hasKeys(styles) || !!propStyles ? mergeStyles(baseStyles, styles, propStyles) : baseStyles;
|
|
172
|
-
const useFactoryCache = typeof document !== "undefined";
|
|
173
|
-
let generatedClassName = useFactoryCache && allStyles === baseStyles ? classNameCache.get(allStyles) : void 0;
|
|
174
279
|
let rscCSS;
|
|
175
280
|
if (generatedClassName !== void 0) touch(generatedClassName);
|
|
176
281
|
else {
|
|
177
282
|
const result = computeStyles(allStyles, !useFactoryCache && allStyles === baseStyles ? STABLE_STYLES : void 0);
|
|
178
283
|
generatedClassName = result.className;
|
|
179
284
|
rscCSS = result.css;
|
|
180
|
-
if (
|
|
285
|
+
if (mergedEntry) mergedEntry.className = generatedClassName;
|
|
286
|
+
else if (useFactoryCache && allStyles === baseStyles) classNameCache.set(allStyles, generatedClassName);
|
|
181
287
|
}
|
|
182
288
|
let mergedTokens;
|
|
183
289
|
if (defaultTokens || tokens || propTokens) {
|
|
@@ -223,6 +329,7 @@ function tastyElement(tastyOptions) {
|
|
|
223
329
|
if (elementProps["data-theme"] === void 0) delete elementProps["data-theme"];
|
|
224
330
|
const el = createElement(as ?? originalAs, elementProps);
|
|
225
331
|
if (rscCSS) {
|
|
332
|
+
checkRequestScope();
|
|
226
333
|
const nonce = getConfig().nonce;
|
|
227
334
|
return createElement(Fragment, null, createElement("style", {
|
|
228
335
|
"data-tasty-rsc": "",
|
|
@@ -233,11 +340,7 @@ function tastyElement(tastyOptions) {
|
|
|
233
340
|
return el;
|
|
234
341
|
});
|
|
235
342
|
_TastyComponent.displayName = `TastyComponent(${defaultProps.qa || originalAs})`;
|
|
236
|
-
if (elements)
|
|
237
|
-
const subElements = {};
|
|
238
|
-
for (const [name, definition] of Object.entries(elements)) subElements[name] = createSubElement(name, definition);
|
|
239
|
-
return Object.assign(_TastyComponent, subElements);
|
|
240
|
-
}
|
|
343
|
+
if (elements) return Object.assign(_TastyComponent, createSubElements(elements));
|
|
241
344
|
return _TastyComponent;
|
|
242
345
|
}
|
|
243
346
|
const Element = /* @__PURE__ */ tasty({});
|
|
@@ -245,16 +348,23 @@ const Element = /* @__PURE__ */ tasty({});
|
|
|
245
348
|
//#region src/ssr/context.ts
|
|
246
349
|
let _ctx;
|
|
247
350
|
function getTastySSRContext() {
|
|
248
|
-
if (!_ctx) _ctx = createContext(null);
|
|
351
|
+
if (!_ctx) _ctx = React.createContext(null);
|
|
249
352
|
return _ctx;
|
|
250
353
|
}
|
|
251
354
|
//#endregion
|
|
252
355
|
//#region src/hooks/useStyles.ts
|
|
356
|
+
const useContextCollector = typeof React.useContext === "function" ? () => React.useContext(getTastySSRContext()) : () => null;
|
|
253
357
|
function useStyles(styles, options) {
|
|
254
|
-
|
|
255
|
-
ssrCollector:
|
|
358
|
+
const result = computeStyles(styles, {
|
|
359
|
+
ssrCollector: useContextCollector(),
|
|
256
360
|
root: options?.root
|
|
257
361
|
});
|
|
362
|
+
if (result.css) {
|
|
363
|
+
checkRequestScope();
|
|
364
|
+
queueRSCCSS(getRSCCache(), result.css);
|
|
365
|
+
return { className: result.className };
|
|
366
|
+
}
|
|
367
|
+
return result;
|
|
258
368
|
}
|
|
259
369
|
//#endregion
|
|
260
370
|
//#region src/hooks/useGlobalStyles.ts
|
|
@@ -273,8 +383,8 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
273
383
|
const existing = slots?.get(slotKey);
|
|
274
384
|
if (existing && existing.stylesKey === stylesKey) return;
|
|
275
385
|
const resolvedStyles = resolveRecipes(styles);
|
|
276
|
-
const
|
|
277
|
-
if (
|
|
386
|
+
const rendered = renderStyles(resolvedStyles, selector);
|
|
387
|
+
if (rendered.length === 0) {
|
|
278
388
|
if (slots) {
|
|
279
389
|
existing?.dispose();
|
|
280
390
|
slots.set(slotKey, {
|
|
@@ -284,8 +394,10 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
284
394
|
}
|
|
285
395
|
return;
|
|
286
396
|
}
|
|
397
|
+
const { rules: styleResults, keyframes } = resolveSelectorKeyframes(resolvedStyles, rendered, getGlobalKeyframes());
|
|
287
398
|
if (target.mode === "ssr") {
|
|
288
399
|
target.collector.collectInternals();
|
|
400
|
+
if (keyframes) for (const [name, steps] of keyframes) target.collector.collectKeyframes(name, formatKeyframesCSS(name, steps));
|
|
289
401
|
const css = formatGlobalRules(styleResults);
|
|
290
402
|
if (css) {
|
|
291
403
|
const key = options?.id ? `global:${options.id}` : `global:${selector}:${hashString(css)}`;
|
|
@@ -295,6 +407,7 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
295
407
|
return;
|
|
296
408
|
}
|
|
297
409
|
if (target.mode === "rsc") {
|
|
410
|
+
if (keyframes) for (const [name, steps] of keyframes) pushRSCCSS(target.cache, `__kf:${name}`, formatKeyframesCSS(name, steps));
|
|
298
411
|
const css = formatGlobalRules(styleResults);
|
|
299
412
|
if (css) {
|
|
300
413
|
const key = options?.id ? `__global:${options.id}` : `__global:${selector}:${hashString(css)}`;
|
|
@@ -304,14 +417,30 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
304
417
|
return;
|
|
305
418
|
}
|
|
306
419
|
if (slots) {
|
|
420
|
+
const releaseKeyframes = holdKeyframes(keyframes, options?.root);
|
|
307
421
|
existing?.dispose();
|
|
308
422
|
const { dispose } = injectGlobal(styleResults, { root: options?.root });
|
|
309
423
|
slots.set(slotKey, {
|
|
310
424
|
stylesKey,
|
|
311
|
-
dispose
|
|
425
|
+
dispose: () => {
|
|
426
|
+
dispose();
|
|
427
|
+
releaseKeyframes();
|
|
428
|
+
}
|
|
312
429
|
});
|
|
313
430
|
}
|
|
314
431
|
}
|
|
432
|
+
function holdKeyframes(keyframes, root) {
|
|
433
|
+
if (!keyframes) return noop;
|
|
434
|
+
const injector = getGlobalInjector();
|
|
435
|
+
const disposers = [...keyframes].map(([name, steps]) => injector.keyframes(steps, {
|
|
436
|
+
name,
|
|
437
|
+
root,
|
|
438
|
+
distinctByName: true
|
|
439
|
+
}).dispose);
|
|
440
|
+
return () => {
|
|
441
|
+
for (const dispose of disposers) dispose();
|
|
442
|
+
};
|
|
443
|
+
}
|
|
315
444
|
//#endregion
|
|
316
445
|
//#region src/hooks/useRawCSS.ts
|
|
317
446
|
const getClientState$1 = /* @__PURE__ */ createClientState(() => ({
|
|
@@ -551,7 +680,7 @@ function useFunction(name, definition, options) {
|
|
|
551
680
|
//#region src/batch-provider.tsx
|
|
552
681
|
function TastyBatchProvider({ children }) {
|
|
553
682
|
openBatchWindow();
|
|
554
|
-
useInsertionEffect(() => {
|
|
683
|
+
React.useInsertionEffect(() => {
|
|
555
684
|
closeBatchWindow();
|
|
556
685
|
});
|
|
557
686
|
return children;
|
|
@@ -559,4 +688,4 @@ function TastyBatchProvider({ children }) {
|
|
|
559
688
|
//#endregion
|
|
560
689
|
export { useProperty as a, useGlobalStyles as c, Element as d, tasty as f, useFontFace as i, useStyles as l, useFunction as n, useKeyframes as o, getDisplayName as p, useCounterStyle as r, useRawCSS as s, TastyBatchProvider as t, getTastySSRContext as u };
|
|
561
690
|
|
|
562
|
-
//# sourceMappingURL=react-runtime-
|
|
691
|
+
//# sourceMappingURL=react-runtime-DHiopXCu.js.map
|