simplestyle-js 5.3.5 → 5.4.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.
@@ -33,6 +33,9 @@ function _interop_require_default(obj) {
33
33
  default: obj
34
34
  };
35
35
  }
36
+ function extractOptions(optionsOrCallback) {
37
+ return typeof optionsOrCallback === 'function' ? optionsOrCallback() : optionsOrCallback;
38
+ }
36
39
  function isNestedSelector(r) {
37
40
  return /&/g.test(r);
38
41
  }
@@ -137,7 +140,8 @@ function createSheet(ruleId, sheetContents) {
137
140
  out.styleTag = styleTag;
138
141
  return out;
139
142
  }
140
- function flushSheetContents(ruleId, sheetContents, options) {
143
+ function flushSheetContents(ruleId, sheetContents, optionsOrCallback) {
144
+ const options = extractOptions(optionsOrCallback);
141
145
  // In case we're in come weird test environment that doesn't support JSDom
142
146
  const { existing, styleTag } = createSheet(ruleId, sheetContents);
143
147
  // if the tag existed, DO NOT render it back out to the DOM.
@@ -152,12 +156,14 @@ function flushSheetContents(ruleId, sheetContents, options) {
152
156
  }
153
157
  return styleTag;
154
158
  }
155
- function coerceCreateStylesOptions(options) {
159
+ function coerceCreateStylesOptions(optionsOrCallback) {
160
+ const options = extractOptions(optionsOrCallback);
156
161
  return {
157
162
  flush: options && typeof options.flush === 'boolean' ? options.flush : true
158
163
  };
159
164
  }
160
- function imports(ruleId, rulesFnc, options) {
165
+ function imports(ruleId, rulesFnc, optionsOrCallback) {
166
+ const options = extractOptions(optionsOrCallback);
161
167
  const coerced = coerceCreateStylesOptions(options);
162
168
  const importRuleId = `${ruleId}_imports`;
163
169
  const rules = rulesFnc();
@@ -177,7 +183,8 @@ function imports(ruleId, rulesFnc, options) {
177
183
  flushSheetContents(importRuleId, sheetBuffer, options);
178
184
  }
179
185
  }
180
- function rawStyles(ruleId, rulesFnc, options) {
186
+ function rawStyles(ruleId, rulesFnc, optionsOrCallback) {
187
+ const options = extractOptions(optionsOrCallback);
181
188
  const rawStylesId = `${ruleId}_raw`;
182
189
  const coerced = coerceCreateStylesOptions(options);
183
190
  const rules = rulesFnc();
@@ -190,7 +197,8 @@ function rawStyles(ruleId, rulesFnc, options) {
190
197
  }
191
198
  return mergedContents;
192
199
  }
193
- function keyframes(ruleId, framesFnc, options) {
200
+ function keyframes(ruleId, framesFnc, optionsOrCallback) {
201
+ const options = extractOptions(optionsOrCallback);
194
202
  const coerced = coerceCreateStylesOptions(options);
195
203
  const keyframeId = (0, _generateClassName.generateClassName)(`${ruleId}_keyframes`);
196
204
  const frames = framesFnc();
@@ -206,7 +214,8 @@ function keyframes(ruleId, framesFnc, options) {
206
214
  stylesheet
207
215
  };
208
216
  }
209
- function createStyles(ruleId, rulesFnc, options) {
217
+ function createStyles(ruleId, rulesFnc, optionsOrCallback) {
218
+ const options = extractOptions(optionsOrCallback);
210
219
  const rules = rulesFnc();
211
220
  const coerced = coerceCreateStylesOptions(options);
212
221
  const { classes: out, sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(ruleId, rules, coerced, null);
@@ -1,6 +1,6 @@
1
1
  import type { SimpleStyleRegistry } from './simpleStyleRegistry.js';
2
2
  import type { ImportStringType, Nullish, Properties, SimpleStyleRules } from './types.js';
3
- export type CreateStylesOptions = Partial<{
3
+ export type BaselineCreateStylesOptions = Partial<{
4
4
  /**
5
5
  * If true, automatically renders generated styles
6
6
  * to the DOM in an injected <style /> tag
@@ -25,13 +25,14 @@ export type CreateStylesOptions = Partial<{
25
25
  */
26
26
  registry?: Nullish<SimpleStyleRegistry>;
27
27
  }>;
28
- export declare function imports(ruleId: string, rulesFnc: () => ImportStringType[], options?: CreateStylesOptions): void;
29
- export declare function rawStyles<T extends SimpleStyleRules>(ruleId: string, rulesFnc: () => T, options?: Partial<CreateStylesOptions>): string;
30
- export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, framesFnc: () => T, options?: CreateStylesOptions): {
28
+ export type CreateStylesOptions = BaselineCreateStylesOptions | (() => BaselineCreateStylesOptions);
29
+ export declare function imports(ruleId: string, rulesFnc: () => ImportStringType[], optionsOrCallback?: CreateStylesOptions): void;
30
+ export declare function rawStyles<T extends SimpleStyleRules>(ruleId: string, rulesFnc: () => T, optionsOrCallback?: Partial<CreateStylesOptions>): string;
31
+ export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, framesFnc: () => T, optionsOrCallback?: CreateStylesOptions): {
31
32
  keyframe: string;
32
33
  stylesheet: string;
33
34
  };
34
- export declare function createStyles<T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rulesFnc: () => T, options?: Partial<CreateStylesOptions>): {
35
+ export declare function createStyles<T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rulesFnc: () => T, optionsOrCallback?: Partial<CreateStylesOptions>): {
35
36
  classes: O;
36
37
  stylesheet: string;
37
38
  updateSheet: <T2 extends SimpleStyleRules>(updatedRulesFnc: () => Partial<T2>) => {
@@ -9,38 +9,42 @@ Object.defineProperty(exports, "makeCssFuncs", {
9
9
  }
10
10
  });
11
11
  const _createStyles = require("./createStyles.cjs");
12
- function makeCssFuncs(opts) {
13
- function wrappedCreateStyles(ruleId, rulesFnc, overrides) {
14
- return (0, _createStyles.createStyles)(ruleId, // @ts-expect-error - we've gotten the consumption types this far
15
- // so TSC can pound sand, because we know this operation is safe
16
- ()=>rulesFnc('variables' in opts ? opts.variables : undefined), {
17
- ...overrides,
18
- registry: 'registry' in opts ? opts.registry : overrides?.registry
19
- });
12
+ function extractOverridesAndOpts(optsOrCallback, overridesOrCallback) {
13
+ const opts = typeof optsOrCallback === 'function' ? optsOrCallback() : optsOrCallback;
14
+ const overrides = typeof overridesOrCallback === 'function' ? overridesOrCallback() : overridesOrCallback;
15
+ return {
16
+ ...opts,
17
+ ...overrides
18
+ };
19
+ }
20
+ function makeCssFuncs(optsOrCallback) {
21
+ function wrappedCreateStyles(ruleId, rulesFnc, overridesOrCallback) {
22
+ return (0, _createStyles.createStyles)(ruleId, ()=>{
23
+ const opts = extractOverridesAndOpts(optsOrCallback, overridesOrCallback);
24
+ return rulesFnc(// @ts-expect-error - this is a safe operation, even if tsc gets confused right here
25
+ 'variables' in opts ? opts.variables : undefined);
26
+ }, ()=>extractOverridesAndOpts(optsOrCallback, overridesOrCallback));
20
27
  }
21
- function wrappedCreateKeyframes(ruleId, rulesFnc, overrides) {
22
- return (0, _createStyles.keyframes)(ruleId, // @ts-expect-error - we've gotten the consumption types this far
23
- // so TSC can pound sand, because we know this operation is safe
24
- ()=>rulesFnc('variables' in opts ? opts.variables : undefined), {
25
- ...overrides,
26
- registry: 'registry' in opts ? opts.registry : overrides?.registry
27
- });
28
+ function wrappedCreateKeyframes(ruleId, rulesFnc, overridesOrCallback) {
29
+ return (0, _createStyles.keyframes)(ruleId, ()=>{
30
+ const opts = extractOverridesAndOpts(optsOrCallback, overridesOrCallback);
31
+ return rulesFnc(// @ts-expect-error - this is a safe operation, even if tsc gets confused right here
32
+ 'variables' in opts ? opts.variables : undefined);
33
+ }, ()=>extractOverridesAndOpts(optsOrCallback, overridesOrCallback));
28
34
  }
29
- function wrappedRawStyles(ruleId, rulesFnc, overrides) {
30
- return (0, _createStyles.rawStyles)(ruleId, // @ts-expect-error - we've gotten the consumption types this far
31
- // so TSC can pound sand, because we know this operation is safe
32
- ()=>rulesFnc('variables' in opts ? opts.variables : undefined), {
33
- ...overrides,
34
- registry: 'registry' in opts ? opts.registry : overrides?.registry
35
- });
35
+ function wrappedRawStyles(ruleId, rulesFnc, overridesOrCallback) {
36
+ return (0, _createStyles.rawStyles)(ruleId, ()=>{
37
+ const opts = extractOverridesAndOpts(optsOrCallback, overridesOrCallback);
38
+ return rulesFnc(// @ts-expect-error - this is a safe operation, even if tsc gets confused right here
39
+ 'variables' in opts ? opts.variables : undefined);
40
+ }, ()=>extractOverridesAndOpts(optsOrCallback, overridesOrCallback));
36
41
  }
37
- function wrappedImports(ruleId, rulesFnc, overrides) {
38
- return (0, _createStyles.imports)(ruleId, // @ts-expect-error - we've gotten the consumption types this far
39
- // so TSC can pound sand, because we know this operation is safe
40
- ()=>rulesFnc('variables' in opts ? opts.variables : undefined), {
41
- ...overrides,
42
- registry: 'registry' in opts ? opts.registry : overrides?.registry
43
- });
42
+ function wrappedImports(ruleId, rulesFnc, overridesOrCallback) {
43
+ return (0, _createStyles.imports)(ruleId, ()=>{
44
+ const opts = extractOverridesAndOpts(optsOrCallback, overridesOrCallback);
45
+ return rulesFnc(// @ts-expect-error - this is a safe operation, even if tsc gets confused right here
46
+ 'variables' in opts ? opts.variables : undefined);
47
+ }, ()=>extractOverridesAndOpts(optsOrCallback, overridesOrCallback));
44
48
  }
45
49
  return {
46
50
  createStyles: wrappedCreateStyles,
@@ -5,7 +5,10 @@ import type { Nullish, SimpleStyleRules } from './types.js';
5
5
  type MakeCssFuncsOpts<T extends object | undefined | null> = {
6
6
  registry?: Nullish<SimpleStyleRegistry>;
7
7
  variables?: T;
8
- };
8
+ } | (() => {
9
+ registry?: Nullish<SimpleStyleRegistry>;
10
+ variables?: T;
11
+ });
9
12
  /**
10
13
  * Creates all of your CSS functions, createStyles, keframes and rawStyles,
11
14
  * and scopes them all to your registry and variables definitions (both are optional).
@@ -13,8 +16,8 @@ type MakeCssFuncsOpts<T extends object | undefined | null> = {
13
16
  * they accept a function as the 2nd parameter, instead of the usual object.
14
17
  * The function will be provided with your variables
15
18
  */
16
- export declare function makeCssFuncs<V extends object | undefined | null | never = never>(opts: MakeCssFuncsOpts<V>): {
17
- createStyles: <T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overrides?: CreateStylesOptions) => {
19
+ export declare function makeCssFuncs<V extends object | undefined | null | never = never>(optsOrCallback: MakeCssFuncsOpts<V>): {
20
+ createStyles: <T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overridesOrCallback?: CreateStylesOptions) => {
18
21
  classes: O;
19
22
  stylesheet: string;
20
23
  updateSheet: <T2 extends SimpleStyleRules>(updatedRulesFnc: () => Partial<T2>) => {
@@ -22,11 +25,11 @@ export declare function makeCssFuncs<V extends object | undefined | null | never
22
25
  stylesheet: string;
23
26
  } | null;
24
27
  };
25
- imports: (ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => `@import ${string}`[], overrides?: CreateStylesOptions) => void;
26
- keyframes: <T extends Record<string, Properties>>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overrides?: CreateStylesOptions) => {
28
+ imports: (ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => `@import ${string}`[], overridesOrCallback?: CreateStylesOptions) => void;
29
+ keyframes: <T extends Record<string, Properties>>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overridesOrCallback?: CreateStylesOptions) => {
27
30
  keyframe: string;
28
31
  stylesheet: string;
29
32
  };
30
- rawStyles: <T extends SimpleStyleRules>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overrides?: CreateStylesOptions) => string;
33
+ rawStyles: <T extends SimpleStyleRules>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overridesOrCallback?: CreateStylesOptions) => string;
31
34
  };
32
35
  export {};
@@ -1,6 +1,6 @@
1
1
  import type { SimpleStyleRegistry } from './simpleStyleRegistry.js';
2
2
  import type { ImportStringType, Nullish, Properties, SimpleStyleRules } from './types.js';
3
- export type CreateStylesOptions = Partial<{
3
+ export type BaselineCreateStylesOptions = Partial<{
4
4
  /**
5
5
  * If true, automatically renders generated styles
6
6
  * to the DOM in an injected <style /> tag
@@ -25,13 +25,14 @@ export type CreateStylesOptions = Partial<{
25
25
  */
26
26
  registry?: Nullish<SimpleStyleRegistry>;
27
27
  }>;
28
- export declare function imports(ruleId: string, rulesFnc: () => ImportStringType[], options?: CreateStylesOptions): void;
29
- export declare function rawStyles<T extends SimpleStyleRules>(ruleId: string, rulesFnc: () => T, options?: Partial<CreateStylesOptions>): string;
30
- export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, framesFnc: () => T, options?: CreateStylesOptions): {
28
+ export type CreateStylesOptions = BaselineCreateStylesOptions | (() => BaselineCreateStylesOptions);
29
+ export declare function imports(ruleId: string, rulesFnc: () => ImportStringType[], optionsOrCallback?: CreateStylesOptions): void;
30
+ export declare function rawStyles<T extends SimpleStyleRules>(ruleId: string, rulesFnc: () => T, optionsOrCallback?: Partial<CreateStylesOptions>): string;
31
+ export declare function keyframes<T extends Record<string, Properties>>(ruleId: string, framesFnc: () => T, optionsOrCallback?: CreateStylesOptions): {
31
32
  keyframe: string;
32
33
  stylesheet: string;
33
34
  };
34
- export declare function createStyles<T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rulesFnc: () => T, options?: Partial<CreateStylesOptions>): {
35
+ export declare function createStyles<T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rulesFnc: () => T, optionsOrCallback?: Partial<CreateStylesOptions>): {
35
36
  classes: O;
36
37
  stylesheet: string;
37
38
  updateSheet: <T2 extends SimpleStyleRules>(updatedRulesFnc: () => Partial<T2>) => {
@@ -1,6 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-deprecated */ import merge from 'deepmerge';
2
2
  import { generateClassName } from './generateClassName.mjs';
3
3
  import { getPosthooks } from './plugins.mjs';
4
+ function extractOptions(optionsOrCallback) {
5
+ return typeof optionsOrCallback === 'function' ? optionsOrCallback() : optionsOrCallback;
6
+ }
4
7
  function isNestedSelector(r) {
5
8
  return /&/g.test(r);
6
9
  }
@@ -105,7 +108,8 @@ function createSheet(ruleId, sheetContents) {
105
108
  out.styleTag = styleTag;
106
109
  return out;
107
110
  }
108
- function flushSheetContents(ruleId, sheetContents, options) {
111
+ function flushSheetContents(ruleId, sheetContents, optionsOrCallback) {
112
+ const options = extractOptions(optionsOrCallback);
109
113
  // In case we're in come weird test environment that doesn't support JSDom
110
114
  const { existing, styleTag } = createSheet(ruleId, sheetContents);
111
115
  // if the tag existed, DO NOT render it back out to the DOM.
@@ -120,12 +124,14 @@ function flushSheetContents(ruleId, sheetContents, options) {
120
124
  }
121
125
  return styleTag;
122
126
  }
123
- function coerceCreateStylesOptions(options) {
127
+ function coerceCreateStylesOptions(optionsOrCallback) {
128
+ const options = extractOptions(optionsOrCallback);
124
129
  return {
125
130
  flush: options && typeof options.flush === 'boolean' ? options.flush : true
126
131
  };
127
132
  }
128
- export function imports(ruleId, rulesFnc, options) {
133
+ export function imports(ruleId, rulesFnc, optionsOrCallback) {
134
+ const options = extractOptions(optionsOrCallback);
129
135
  const coerced = coerceCreateStylesOptions(options);
130
136
  const importRuleId = `${ruleId}_imports`;
131
137
  const rules = rulesFnc();
@@ -145,7 +151,8 @@ export function imports(ruleId, rulesFnc, options) {
145
151
  flushSheetContents(importRuleId, sheetBuffer, options);
146
152
  }
147
153
  }
148
- export function rawStyles(ruleId, rulesFnc, options) {
154
+ export function rawStyles(ruleId, rulesFnc, optionsOrCallback) {
155
+ const options = extractOptions(optionsOrCallback);
149
156
  const rawStylesId = `${ruleId}_raw`;
150
157
  const coerced = coerceCreateStylesOptions(options);
151
158
  const rules = rulesFnc();
@@ -158,7 +165,8 @@ export function rawStyles(ruleId, rulesFnc, options) {
158
165
  }
159
166
  return mergedContents;
160
167
  }
161
- export function keyframes(ruleId, framesFnc, options) {
168
+ export function keyframes(ruleId, framesFnc, optionsOrCallback) {
169
+ const options = extractOptions(optionsOrCallback);
162
170
  const coerced = coerceCreateStylesOptions(options);
163
171
  const keyframeId = generateClassName(`${ruleId}_keyframes`);
164
172
  const frames = framesFnc();
@@ -174,7 +182,8 @@ export function keyframes(ruleId, framesFnc, options) {
174
182
  stylesheet
175
183
  };
176
184
  }
177
- export function createStyles(ruleId, rulesFnc, options) {
185
+ export function createStyles(ruleId, rulesFnc, optionsOrCallback) {
186
+ const options = extractOptions(optionsOrCallback);
178
187
  const rules = rulesFnc();
179
188
  const coerced = coerceCreateStylesOptions(options);
180
189
  const { classes: out, sheetBuffer: sheetContents, mediaQueriesBuffer: mediaQueriesContents } = execCreateStyles(ruleId, rules, coerced, null);
@@ -5,7 +5,10 @@ import type { Nullish, SimpleStyleRules } from './types.js';
5
5
  type MakeCssFuncsOpts<T extends object | undefined | null> = {
6
6
  registry?: Nullish<SimpleStyleRegistry>;
7
7
  variables?: T;
8
- };
8
+ } | (() => {
9
+ registry?: Nullish<SimpleStyleRegistry>;
10
+ variables?: T;
11
+ });
9
12
  /**
10
13
  * Creates all of your CSS functions, createStyles, keframes and rawStyles,
11
14
  * and scopes them all to your registry and variables definitions (both are optional).
@@ -13,8 +16,8 @@ type MakeCssFuncsOpts<T extends object | undefined | null> = {
13
16
  * they accept a function as the 2nd parameter, instead of the usual object.
14
17
  * The function will be provided with your variables
15
18
  */
16
- export declare function makeCssFuncs<V extends object | undefined | null | never = never>(opts: MakeCssFuncsOpts<V>): {
17
- createStyles: <T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overrides?: CreateStylesOptions) => {
19
+ export declare function makeCssFuncs<V extends object | undefined | null | never = never>(optsOrCallback: MakeCssFuncsOpts<V>): {
20
+ createStyles: <T extends SimpleStyleRules, K extends keyof T, O extends Record<K, string>>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overridesOrCallback?: CreateStylesOptions) => {
18
21
  classes: O;
19
22
  stylesheet: string;
20
23
  updateSheet: <T2 extends SimpleStyleRules>(updatedRulesFnc: () => Partial<T2>) => {
@@ -22,11 +25,11 @@ export declare function makeCssFuncs<V extends object | undefined | null | never
22
25
  stylesheet: string;
23
26
  } | null;
24
27
  };
25
- imports: (ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => `@import ${string}`[], overrides?: CreateStylesOptions) => void;
26
- keyframes: <T extends Record<string, Properties>>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overrides?: CreateStylesOptions) => {
28
+ imports: (ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => `@import ${string}`[], overridesOrCallback?: CreateStylesOptions) => void;
29
+ keyframes: <T extends Record<string, Properties>>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overridesOrCallback?: CreateStylesOptions) => {
27
30
  keyframe: string;
28
31
  stylesheet: string;
29
32
  };
30
- rawStyles: <T extends SimpleStyleRules>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overrides?: CreateStylesOptions) => string;
33
+ rawStyles: <T extends SimpleStyleRules>(ruleId: string, rulesFnc: (vars: V extends undefined | null | never ? never : V) => T, overridesOrCallback?: CreateStylesOptions) => string;
31
34
  };
32
35
  export {};
@@ -1,42 +1,46 @@
1
1
  import { createStyles, imports, keyframes, rawStyles } from './createStyles.mjs';
2
+ function extractOverridesAndOpts(optsOrCallback, overridesOrCallback) {
3
+ const opts = typeof optsOrCallback === 'function' ? optsOrCallback() : optsOrCallback;
4
+ const overrides = typeof overridesOrCallback === 'function' ? overridesOrCallback() : overridesOrCallback;
5
+ return {
6
+ ...opts,
7
+ ...overrides
8
+ };
9
+ }
2
10
  /**
3
11
  * Creates all of your CSS functions, createStyles, keframes and rawStyles,
4
12
  * and scopes them all to your registry and variables definitions (both are optional).
5
13
  * The variants of these functions differ slightly, in that
6
14
  * they accept a function as the 2nd parameter, instead of the usual object.
7
15
  * The function will be provided with your variables
8
- */ export function makeCssFuncs(opts) {
9
- function wrappedCreateStyles(ruleId, rulesFnc, overrides) {
10
- return createStyles(ruleId, // @ts-expect-error - we've gotten the consumption types this far
11
- // so TSC can pound sand, because we know this operation is safe
12
- ()=>rulesFnc('variables' in opts ? opts.variables : undefined), {
13
- ...overrides,
14
- registry: 'registry' in opts ? opts.registry : overrides?.registry
15
- });
16
+ */ export function makeCssFuncs(optsOrCallback) {
17
+ function wrappedCreateStyles(ruleId, rulesFnc, overridesOrCallback) {
18
+ return createStyles(ruleId, ()=>{
19
+ const opts = extractOverridesAndOpts(optsOrCallback, overridesOrCallback);
20
+ return rulesFnc(// @ts-expect-error - this is a safe operation, even if tsc gets confused right here
21
+ 'variables' in opts ? opts.variables : undefined);
22
+ }, ()=>extractOverridesAndOpts(optsOrCallback, overridesOrCallback));
16
23
  }
17
- function wrappedCreateKeyframes(ruleId, rulesFnc, overrides) {
18
- return keyframes(ruleId, // @ts-expect-error - we've gotten the consumption types this far
19
- // so TSC can pound sand, because we know this operation is safe
20
- ()=>rulesFnc('variables' in opts ? opts.variables : undefined), {
21
- ...overrides,
22
- registry: 'registry' in opts ? opts.registry : overrides?.registry
23
- });
24
+ function wrappedCreateKeyframes(ruleId, rulesFnc, overridesOrCallback) {
25
+ return keyframes(ruleId, ()=>{
26
+ const opts = extractOverridesAndOpts(optsOrCallback, overridesOrCallback);
27
+ return rulesFnc(// @ts-expect-error - this is a safe operation, even if tsc gets confused right here
28
+ 'variables' in opts ? opts.variables : undefined);
29
+ }, ()=>extractOverridesAndOpts(optsOrCallback, overridesOrCallback));
24
30
  }
25
- function wrappedRawStyles(ruleId, rulesFnc, overrides) {
26
- return rawStyles(ruleId, // @ts-expect-error - we've gotten the consumption types this far
27
- // so TSC can pound sand, because we know this operation is safe
28
- ()=>rulesFnc('variables' in opts ? opts.variables : undefined), {
29
- ...overrides,
30
- registry: 'registry' in opts ? opts.registry : overrides?.registry
31
- });
31
+ function wrappedRawStyles(ruleId, rulesFnc, overridesOrCallback) {
32
+ return rawStyles(ruleId, ()=>{
33
+ const opts = extractOverridesAndOpts(optsOrCallback, overridesOrCallback);
34
+ return rulesFnc(// @ts-expect-error - this is a safe operation, even if tsc gets confused right here
35
+ 'variables' in opts ? opts.variables : undefined);
36
+ }, ()=>extractOverridesAndOpts(optsOrCallback, overridesOrCallback));
32
37
  }
33
- function wrappedImports(ruleId, rulesFnc, overrides) {
34
- return imports(ruleId, // @ts-expect-error - we've gotten the consumption types this far
35
- // so TSC can pound sand, because we know this operation is safe
36
- ()=>rulesFnc('variables' in opts ? opts.variables : undefined), {
37
- ...overrides,
38
- registry: 'registry' in opts ? opts.registry : overrides?.registry
39
- });
38
+ function wrappedImports(ruleId, rulesFnc, overridesOrCallback) {
39
+ return imports(ruleId, ()=>{
40
+ const opts = extractOverridesAndOpts(optsOrCallback, overridesOrCallback);
41
+ return rulesFnc(// @ts-expect-error - this is a safe operation, even if tsc gets confused right here
42
+ 'variables' in opts ? opts.variables : undefined);
43
+ }, ()=>extractOverridesAndOpts(optsOrCallback, overridesOrCallback));
40
44
  }
41
45
  return {
42
46
  createStyles: wrappedCreateStyles,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simplestyle-js",
3
- "version": "5.3.5",
3
+ "version": "5.4.0",
4
4
  "description": "An incredibly straightforward and simple CSS-in-JS solution with zero runtime dependencies, and out-of-the-box TypeScript support",
5
5
  "type": "module",
6
6
  "repository": {