simplestyle-js 4.1.1 → 4.1.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.
|
@@ -161,10 +161,15 @@ function coerceCreateStylesOptions(options) {
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
function rawStyles(ruleId, rules, options) {
|
|
164
|
+
const rawStylesId = `${ruleId}_raw`;
|
|
164
165
|
const coerced = coerceCreateStylesOptions(options);
|
|
165
|
-
const { sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(
|
|
166
|
+
const { sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(rawStylesId, rules, coerced, null, true);
|
|
166
167
|
const mergedContents = `${sheetContents}${mediaQueriesContents}`;
|
|
167
|
-
if (
|
|
168
|
+
if (options?.registry) {
|
|
169
|
+
options.registry.add(rawStylesId, mergedContents);
|
|
170
|
+
} else if (coerced.flush) {
|
|
171
|
+
flushSheetContents(rawStylesId, mergedContents, options);
|
|
172
|
+
}
|
|
168
173
|
return mergedContents;
|
|
169
174
|
}
|
|
170
175
|
function makeRawStyles(registry) {
|
|
@@ -176,14 +181,18 @@ function makeRawStyles(registry) {
|
|
|
176
181
|
}
|
|
177
182
|
function keyframes(ruleId, frames, options) {
|
|
178
183
|
const coerced = coerceCreateStylesOptions(options);
|
|
179
|
-
const keyframeName = (0, _generateClassName.generateClassName)(`${ruleId}
|
|
184
|
+
const keyframeName = (0, _generateClassName.generateClassName)(`${ruleId}_keyframes`);
|
|
180
185
|
const { sheetBuffer: keyframesContents } = execCreateStyles(ruleId, frames, coerced, null, true);
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
|
|
186
|
+
const stylesheet = `@keyframes ${keyframeName}{${keyframesContents}}`;
|
|
187
|
+
if (options?.registry) {
|
|
188
|
+
options.registry.add(keyframeName, keyframesContents);
|
|
189
|
+
} else if (coerced.flush) {
|
|
190
|
+
flushSheetContents(ruleId, stylesheet);
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
184
193
|
keyframeName,
|
|
185
|
-
|
|
186
|
-
|
|
194
|
+
stylesheet
|
|
195
|
+
};
|
|
187
196
|
}
|
|
188
197
|
function makeKeyframes(registry) {
|
|
189
198
|
return function wrappedCreateKeyframes(ruleId, rules) {
|
|
@@ -28,8 +28,14 @@ export type CreateStylesOptions = Partial<{
|
|
|
28
28
|
}>;
|
|
29
29
|
export declare function rawStyles<T extends SimpleStyleRules>(ruleId: string, rules: T, options?: Partial<CreateStylesOptions>): string;
|
|
30
30
|
export declare function makeRawStyles(registry: SimpleStyleRegistry): <T extends SimpleStyleRules>(ruleId: string, rules: T) => string;
|
|
31
|
-
export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, frames: T, options?: CreateStylesOptions):
|
|
32
|
-
|
|
31
|
+
export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, frames: T, options?: CreateStylesOptions): {
|
|
32
|
+
keyframeName: string;
|
|
33
|
+
stylesheet: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function makeKeyframes(registry: SimpleStyleRegistry): <T extends Record<string, Properties>>(ruleId: string, rules: T) => {
|
|
36
|
+
keyframeName: string;
|
|
37
|
+
stylesheet: string;
|
|
38
|
+
};
|
|
33
39
|
export declare function makeCreateStyles(registry: SimpleStyleRegistry): <T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rules: T) => {
|
|
34
40
|
classes: O;
|
|
35
41
|
stylesheet: string;
|
|
@@ -28,8 +28,14 @@ export type CreateStylesOptions = Partial<{
|
|
|
28
28
|
}>;
|
|
29
29
|
export declare function rawStyles<T extends SimpleStyleRules>(ruleId: string, rules: T, options?: Partial<CreateStylesOptions>): string;
|
|
30
30
|
export declare function makeRawStyles(registry: SimpleStyleRegistry): <T extends SimpleStyleRules>(ruleId: string, rules: T) => string;
|
|
31
|
-
export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, frames: T, options?: CreateStylesOptions):
|
|
32
|
-
|
|
31
|
+
export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, frames: T, options?: CreateStylesOptions): {
|
|
32
|
+
keyframeName: string;
|
|
33
|
+
stylesheet: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function makeKeyframes(registry: SimpleStyleRegistry): <T extends Record<string, Properties>>(ruleId: string, rules: T) => {
|
|
36
|
+
keyframeName: string;
|
|
37
|
+
stylesheet: string;
|
|
38
|
+
};
|
|
33
39
|
export declare function makeCreateStyles(registry: SimpleStyleRegistry): <T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rules: T) => {
|
|
34
40
|
classes: O;
|
|
35
41
|
stylesheet: string;
|
|
@@ -126,10 +126,15 @@ function coerceCreateStylesOptions(options) {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
export function rawStyles(ruleId, rules, options) {
|
|
129
|
+
const rawStylesId = `${ruleId}_raw`;
|
|
129
130
|
const coerced = coerceCreateStylesOptions(options);
|
|
130
|
-
const { sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(
|
|
131
|
+
const { sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(rawStylesId, rules, coerced, null, true);
|
|
131
132
|
const mergedContents = `${sheetContents}${mediaQueriesContents}`;
|
|
132
|
-
if (
|
|
133
|
+
if (options?.registry) {
|
|
134
|
+
options.registry.add(rawStylesId, mergedContents);
|
|
135
|
+
} else if (coerced.flush) {
|
|
136
|
+
flushSheetContents(rawStylesId, mergedContents, options);
|
|
137
|
+
}
|
|
133
138
|
return mergedContents;
|
|
134
139
|
}
|
|
135
140
|
export function makeRawStyles(registry) {
|
|
@@ -141,14 +146,18 @@ export function makeRawStyles(registry) {
|
|
|
141
146
|
}
|
|
142
147
|
export function keyframes(ruleId, frames, options) {
|
|
143
148
|
const coerced = coerceCreateStylesOptions(options);
|
|
144
|
-
const keyframeName = generateClassName(`${ruleId}
|
|
149
|
+
const keyframeName = generateClassName(`${ruleId}_keyframes`);
|
|
145
150
|
const { sheetBuffer: keyframesContents } = execCreateStyles(ruleId, frames, coerced, null, true);
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
-
|
|
151
|
+
const stylesheet = `@keyframes ${keyframeName}{${keyframesContents}}`;
|
|
152
|
+
if (options?.registry) {
|
|
153
|
+
options.registry.add(keyframeName, keyframesContents);
|
|
154
|
+
} else if (coerced.flush) {
|
|
155
|
+
flushSheetContents(ruleId, stylesheet);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
149
158
|
keyframeName,
|
|
150
|
-
|
|
151
|
-
|
|
159
|
+
stylesheet
|
|
160
|
+
};
|
|
152
161
|
}
|
|
153
162
|
export function makeKeyframes(registry) {
|
|
154
163
|
return function wrappedCreateKeyframes(ruleId, rules) {
|
package/package.json
CHANGED