@master/css 2.0.0-rc.68 → 2.0.0-rc.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/dist/common.cjs +0 -2
  2. package/dist/common.d.ts +0 -1
  3. package/dist/common.mjs +1 -2
  4. package/dist/config/functions.cjs +9 -243
  5. package/dist/config/functions.d.ts +137 -2
  6. package/dist/config/functions.mjs +9 -243
  7. package/dist/config/index.cjs +2 -2
  8. package/dist/config/index.mjs +2 -2
  9. package/dist/config/modes.cjs +307 -3
  10. package/dist/config/modes.d.ts +306 -2
  11. package/dist/config/modes.mjs +307 -3
  12. package/dist/config/rules.cjs +740 -782
  13. package/dist/config/rules.d.ts +692 -683
  14. package/dist/config/rules.mjs +741 -783
  15. package/dist/config/utilities.cjs +328 -97
  16. package/dist/config/utilities.d.ts +247 -16
  17. package/dist/config/utilities.mjs +328 -97
  18. package/dist/config/variables.cjs +88 -460
  19. package/dist/config/variables.d.ts +358 -369
  20. package/dist/config/variables.mjs +88 -460
  21. package/dist/core.cjs +234 -234
  22. package/dist/core.d.ts +5 -3
  23. package/dist/core.mjs +234 -234
  24. package/dist/create.cjs +10 -0
  25. package/dist/create.d.ts +3 -0
  26. package/dist/create.mjs +8 -0
  27. package/dist/declarers/core.group.cjs +99 -0
  28. package/dist/declarers/core.group.d.ts +2 -0
  29. package/dist/declarers/core.group.mjs +97 -0
  30. package/dist/declarers/core.variable.cjs +9 -0
  31. package/dist/declarers/core.variable.d.ts +4 -0
  32. package/dist/declarers/core.variable.mjs +7 -0
  33. package/dist/declarers/index.cjs +13 -0
  34. package/dist/declarers/index.d.ts +10 -0
  35. package/dist/declarers/index.mjs +11 -0
  36. package/dist/declarers/pair.cjs +12 -0
  37. package/dist/declarers/pair.d.ts +4 -0
  38. package/dist/declarers/pair.mjs +10 -0
  39. package/dist/factories/with-syntax-layer.cjs +0 -2
  40. package/dist/factories/with-syntax-layer.mjs +0 -2
  41. package/dist/function-transformers/core.calc.cjs +225 -0
  42. package/dist/function-transformers/core.calc.d.ts +2 -0
  43. package/dist/function-transformers/core.calc.mjs +223 -0
  44. package/dist/function-transformers/core.variable.cjs +23 -0
  45. package/dist/function-transformers/core.variable.d.ts +7 -0
  46. package/dist/function-transformers/core.variable.mjs +21 -0
  47. package/dist/function-transformers/index.cjs +11 -0
  48. package/dist/function-transformers/index.d.ts +8 -0
  49. package/dist/function-transformers/index.mjs +9 -0
  50. package/dist/index.cjs +10 -1
  51. package/dist/index.d.ts +8 -2
  52. package/dist/index.mjs +6 -1
  53. package/dist/layer.cjs +2 -4
  54. package/dist/layer.mjs +2 -4
  55. package/dist/non-layer.cjs +2 -4
  56. package/dist/non-layer.mjs +2 -4
  57. package/dist/syntax-rule-type.cjs +8 -7
  58. package/dist/syntax-rule-type.d.ts +7 -7
  59. package/dist/syntax-rule-type.mjs +8 -7
  60. package/dist/syntax-rule.cjs +305 -258
  61. package/dist/syntax-rule.d.ts +2 -2
  62. package/dist/syntax-rule.mjs +306 -259
  63. package/dist/{utils/autofill-solid-style.cjs → transformers/auto-fill-solid.cjs} +3 -3
  64. package/dist/transformers/auto-fill-solid.d.ts +2 -0
  65. package/dist/{utils/autofill-solid-style.mjs → transformers/auto-fill-solid.mjs} +3 -3
  66. package/dist/transformers/index.cjs +9 -0
  67. package/dist/transformers/index.d.ts +6 -0
  68. package/dist/transformers/index.mjs +7 -0
  69. package/dist/types/common.d.ts +0 -2
  70. package/dist/types/config.d.ts +24 -20
  71. package/dist/types/syntax.d.ts +10 -8
  72. package/dist/utils/equal-selectors.cjs +1 -2
  73. package/dist/utils/equal-selectors.mjs +1 -2
  74. package/dist/utils/extend-config.cjs +83 -44
  75. package/dist/utils/extend-config.d.ts +10 -1
  76. package/dist/utils/extend-config.mjs +83 -44
  77. package/dist/utils/flatten-meta-object.cjs +38 -0
  78. package/dist/utils/flatten-meta-object.d.ts +13 -0
  79. package/dist/utils/flatten-meta-object.mjs +36 -0
  80. package/dist/utils/flatten-object.cjs +13 -9
  81. package/dist/utils/flatten-object.d.ts +1 -1
  82. package/dist/utils/flatten-object.mjs +13 -9
  83. package/dist/utils/generate-css.cjs +2 -2
  84. package/dist/utils/generate-css.d.ts +1 -2
  85. package/dist/utils/generate-css.mjs +2 -2
  86. package/dist/utils/minify-extended-config.cjs +64 -0
  87. package/dist/utils/minify-extended-config.d.ts +9 -0
  88. package/dist/utils/minify-extended-config.mjs +62 -0
  89. package/dist/utils/nest-meta-object.cjs +25 -0
  90. package/dist/utils/nest-meta-object.d.ts +7 -0
  91. package/dist/utils/nest-meta-object.mjs +23 -0
  92. package/dist/utils/parse-at.cjs +1 -2
  93. package/dist/utils/parse-at.d.ts +2 -2
  94. package/dist/utils/parse-at.mjs +1 -2
  95. package/dist/utils/parse-pair.cjs +3 -6
  96. package/dist/utils/parse-pair.mjs +3 -6
  97. package/dist/utils/parse-selector.cjs +2 -4
  98. package/dist/utils/parse-selector.d.ts +2 -2
  99. package/dist/utils/parse-selector.mjs +2 -4
  100. package/dist/utils/sort-readable-classes.cjs +2 -2
  101. package/dist/utils/sort-readable-classes.d.ts +1 -2
  102. package/dist/utils/sort-readable-classes.mjs +2 -2
  103. package/dist/variable-rule.cjs +35 -29
  104. package/dist/variable-rule.d.ts +16 -6
  105. package/dist/variable-rule.mjs +35 -29
  106. package/package.json +1 -1
  107. package/dist/utils/autofill-solid-style.d.ts +0 -3
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var autoFillSolid = require('./auto-fill-solid.cjs');
4
+
5
+ const transformers = {
6
+ 'auto-fill-solid': autoFillSolid
7
+ };
8
+
9
+ module.exports = transformers;
@@ -0,0 +1,6 @@
1
+ import autoFillSolid from './auto-fill-solid';
2
+ declare const transformers: {
3
+ 'auto-fill-solid': typeof autoFillSolid;
4
+ };
5
+ export default transformers;
6
+ export type TransformerNames = keyof typeof transformers;
@@ -0,0 +1,7 @@
1
+ import autoFillSolid from './auto-fill-solid.mjs';
2
+
3
+ const transformers = {
4
+ 'auto-fill-solid': autoFillSolid
5
+ };
6
+
7
+ export { transformers as default };
@@ -1,3 +1 @@
1
- import SyntaxRuleType from '../syntax-rule-type';
2
1
  export type Vendors = 'webkit' | 'moz' | 'ms' | 'o';
3
- export type SyntaxRuleTypeValue = typeof SyntaxRuleType[keyof typeof SyntaxRuleType];
@@ -1,33 +1,30 @@
1
1
  import type { PropertiesHyphen } from 'csstype';
2
- import type { SyntaxRule } from '../syntax-rule';
3
- import type { ValueComponent } from './syntax';
4
2
  import type { rules, utilities } from '../config';
5
3
  import { AT_IDENTIFIERS } from '../common';
6
- import { SyntaxRuleTypeValue } from './common';
4
+ import { DeclarerNames } from '../declarers';
5
+ import { TransformerNames } from '../transformers';
6
+ import { FunctionTransformerNames } from '../function-transformers';
7
+ import SyntaxRuleType from '../syntax-rule-type';
7
8
  export interface SyntaxRuleDefinition {
8
- type?: SyntaxRuleTypeValue;
9
- matcher?: RegExp;
9
+ type?: SyntaxRuleType;
10
+ matcher?: RegExp | string;
10
11
  sign?: string;
11
12
  key?: string;
12
13
  subkey?: string;
13
- ambiguousKeys?: string[];
14
- ambiguousValues?: (RegExp | string)[];
15
- variables?: string[];
14
+ aliasGroups?: string[];
15
+ values?: string[];
16
+ kind?: 'number' | 'color' | 'image';
17
+ namespaces?: string[];
16
18
  separators?: string[];
17
19
  unit?: any;
18
- declarations?: PropertiesHyphen;
20
+ declarations?: PropertiesHyphen | Record<string, string | undefined | (string | undefined)[]> | (keyof PropertiesHyphen)[];
19
21
  includeAnimations?: boolean;
20
- analyze?: (this: SyntaxRule, className: string) => [valueToken: string, prefixToken?: string];
21
- transformValue?(this: SyntaxRule, value: string): string;
22
- transformValueComponents?(this: SyntaxRule, valueComponents: ValueComponent[]): ValueComponent[];
23
- declare?(this: SyntaxRule, value: string, valueComponents: ValueComponent[]): PropertiesHyphen;
24
- delete?(this: SyntaxRule, className: string): void;
25
- create?(this: SyntaxRule, className: string): void;
26
- insert?(this: SyntaxRule): void;
22
+ declarer?: DeclarerNames | [DeclarerNames, any];
23
+ transformer?: TransformerNames | [TransformerNames, any];
27
24
  }
28
25
  export type VariableValue = number | string | false | (number | string)[];
29
26
  export type VariableDefinition = {
30
- [key in '' | `@${string}` | string]?: VariableValue | VariableDefinition;
27
+ [key in '' | string]?: VariableValue | VariableDefinition;
31
28
  } | VariableValue;
32
29
  export type CSSKeyframes = Record<'from' | 'to' | string, PropertiesHyphen>;
33
30
  export type AnimationDefinitions = Record<string, CSSKeyframes>;
@@ -48,10 +45,10 @@ export type VariableDefinitions = {
48
45
  export type UtilityDefinitions = {
49
46
  [key in keyof typeof utilities]?: PropertiesHyphen;
50
47
  } & Record<string, PropertiesHyphen>;
51
- export type ModeDefinitions = Record<string, 'class' | 'media' | 'host' | false>;
48
+ export type ModeDefinitions = Record<string, VariableDefinitions>;
52
49
  export interface FunctionDefinition {
53
50
  unit?: string;
54
- transform?(this: SyntaxRule, value: string, bypassVariableNames: string[]): string | ValueComponent[];
51
+ transformer?: FunctionTransformerNames | [FunctionTransformerNames, any];
55
52
  }
56
53
  export type FunctionDefinitions = Record<string, FunctionDefinition>;
57
54
  export interface Config {
@@ -68,8 +65,15 @@ export interface Config {
68
65
  defaultMode?: 'light' | 'dark' | string | false;
69
66
  scope?: string;
70
67
  important?: boolean;
71
- override?: boolean;
72
68
  functions?: FunctionDefinitions;
73
69
  animations?: AnimationDefinitions;
74
70
  modes?: ModeDefinitions;
71
+ modeTrigger?: 'class' | 'media' | 'host';
72
+ }
73
+ declare module 'csstype' {
74
+ interface PropertiesHyphen {
75
+ '-webkit-user-drag'?: 'auto' | 'element' | 'none' | 'inherit';
76
+ 'user-drag'?: 'auto' | 'element' | 'none' | 'inherit';
77
+ '-webkit-text-decoration'?: string;
78
+ }
75
79
  }
@@ -27,7 +27,7 @@ export interface VariableValueComponent {
27
27
  token: string;
28
28
  type: 'variable';
29
29
  name: string;
30
- alpha?: string;
30
+ alpha?: number;
31
31
  fallback?: string;
32
32
  variable?: Variable;
33
33
  }
@@ -47,7 +47,7 @@ export interface DefinedRule {
47
47
  value?: RegExp;
48
48
  arbitrary?: RegExp;
49
49
  };
50
- variables: Record<string, Variable>;
50
+ variables?: Map<string, Variable>;
51
51
  order: number;
52
52
  definition: SyntaxRuleDefinition;
53
53
  }
@@ -64,24 +64,26 @@ export interface MediaQuery {
64
64
  type?: string;
65
65
  }
66
66
  type VariableCommon = {
67
+ namespace?: string;
67
68
  group?: string;
68
69
  name: string;
69
70
  key: string;
70
71
  modes?: Record<string, LiteralVariable>;
71
72
  };
72
- export interface StringVariable {
73
+ export type StringVariable = {
73
74
  type: 'string';
74
75
  value: string;
75
- }
76
- export interface NumberVariable {
76
+ };
77
+ export type NumberVariable = {
77
78
  type: 'number';
78
79
  value: number;
79
- }
80
- export interface ColorVariable {
80
+ };
81
+ export type ColorVariable = {
81
82
  type: 'color';
82
83
  value: string;
83
84
  space: 'rgb' | 'hsl';
84
- }
85
+ alpha?: number;
86
+ };
85
87
  export type LiteralVariable = StringVariable | NumberVariable | ColorVariable;
86
88
  export type Variable = LiteralVariable & VariableCommon;
87
89
  export {};
@@ -36,8 +36,7 @@ function splitByCombinators(nodes) {
36
36
  parts.push(buffer);
37
37
  buffer = [];
38
38
  }
39
- parts.push(node) // push combinator as-is
40
- ;
39
+ parts.push(node); // push combinator as-is
41
40
  } else {
42
41
  buffer.push(node);
43
42
  }
@@ -34,8 +34,7 @@ function splitByCombinators(nodes) {
34
34
  parts.push(buffer);
35
35
  buffer = [];
36
36
  }
37
- parts.push(node) // push combinator as-is
38
- ;
37
+ parts.push(node); // push combinator as-is
39
38
  } else {
40
39
  buffer.push(node);
41
40
  }
@@ -1,58 +1,97 @@
1
1
  'use strict';
2
2
 
3
- var extend = require('@techor/extend');
3
+ var extend = require('json-safe-extend');
4
+ var flattenObject = require('./flatten-object.cjs');
5
+ var flattenMetaObject = require('./flatten-meta-object.cjs');
4
6
 
5
- // todo: split resolveConfig into a function
6
7
  function extendConfig(...configs) {
7
- const formatConfig = (config)=>{
8
- const clonedConfig = extend({}, config);
9
- const formatDeeply = (obj)=>{
10
- Object.entries(obj).forEach(([key, value])=>{
11
- if (typeof value === 'object' && !Array.isArray(value)) {
12
- formatDeeply(value);
13
- } else if (key && !key.startsWith('@')) {
14
- obj[key] = {
15
- '': value
16
- };
17
- }
18
- });
19
- };
20
- [
21
- 'components',
22
- 'variables'
23
- ].forEach((key)=>{
24
- if (clonedConfig[key]) {
25
- formatDeeply(clonedConfig[key]);
26
- }
27
- });
28
- return clonedConfig;
29
- };
30
8
  const collectConfigs = (config, result = [])=>{
31
9
  if (!config) return result;
32
10
  if (config.extends?.length) {
33
- config.extends.forEach((ext)=>collectConfigs('config' in ext ? ext.config : ext, result));
11
+ for (const ext of config.extends){
12
+ collectConfigs('config' in ext ? ext.config : ext, result);
13
+ }
34
14
  }
35
- result.push(formatConfig(config));
15
+ const cleanConfig = {
16
+ ...config
17
+ };
18
+ delete cleanConfig.extends;
19
+ result.push(cleanConfig);
36
20
  return result;
37
21
  };
38
- const formattedConfigs = configs.reduce((acc, config)=>collectConfigs(config, acc), []);
39
- return formattedConfigs.reduce((extendedConfig, currentConfig)=>{
40
- Object.entries(currentConfig).forEach(([key, value])=>{
41
- if (key === 'animations' && value) {
42
- Object.assign(extendedConfig.animations, value);
43
- } else if (value) {
44
- extendedConfig = extend(extendedConfig, {
45
- [key]: value
46
- });
22
+ const allConfigs = configs.reduce((acc, config)=>collectConfigs(config, acc), []);
23
+ let extendedConfig = {
24
+ __extended: true
25
+ };
26
+ for (const { variables, modes, components, animations, at, rules, utilities, selectors, functions, ...rest } of allConfigs){
27
+ const isExtended = '__extended' in rest;
28
+ if (isExtended) delete rest.__extended;
29
+ // variables
30
+ if (variables) {
31
+ extendedConfig.variables ??= {};
32
+ const flattened = isExtended ? {
33
+ ...variables
34
+ } : flattenMetaObject(variables, [], {});
35
+ Object.assign(extendedConfig.variables, flattened);
36
+ }
37
+ // modes
38
+ if (modes) {
39
+ extendedConfig.modes ??= {};
40
+ for (const [modeName, modeVars] of Object.entries(modes)){
41
+ const flattenedMode = isExtended ? {
42
+ ...modeVars
43
+ } : flattenMetaObject(modeVars, [], {});
44
+ extendedConfig.modes[modeName] = {
45
+ ...extendedConfig.modes[modeName],
46
+ ...flattenedMode
47
+ };
47
48
  }
48
- });
49
- return extendedConfig;
50
- }, {
51
- animations: {},
52
- components: {},
53
- at: {},
54
- variables: {}
55
- });
49
+ }
50
+ // components
51
+ if (components) {
52
+ extendedConfig.components ??= {};
53
+ const flattened = isExtended ? {
54
+ ...components
55
+ } : flattenObject(components);
56
+ Object.assign(extendedConfig.components, flattened);
57
+ }
58
+ // at
59
+ if (at) {
60
+ extendedConfig.at ??= {};
61
+ const flattened = isExtended ? {
62
+ ...at
63
+ } : flattenObject(at);
64
+ Object.assign(extendedConfig.at, flattened);
65
+ }
66
+ // animations
67
+ if (animations) {
68
+ extendedConfig.animations ??= {};
69
+ Object.assign(extendedConfig.animations, animations);
70
+ }
71
+ // rules
72
+ if (rules) {
73
+ extendedConfig.rules ??= {};
74
+ Object.assign(extendedConfig.rules, rules);
75
+ }
76
+ // utilities
77
+ if (utilities) {
78
+ extendedConfig.utilities ??= {};
79
+ Object.assign(extendedConfig.utilities, utilities);
80
+ }
81
+ // selectors
82
+ if (selectors) {
83
+ extendedConfig.selectors ??= {};
84
+ Object.assign(extendedConfig.selectors, selectors);
85
+ }
86
+ // functions
87
+ if (functions) {
88
+ extendedConfig.functions ??= {};
89
+ Object.assign(extendedConfig.functions, functions);
90
+ }
91
+ // merge the rest (non-structured fields)
92
+ extendedConfig = extend({}, extendedConfig, rest);
93
+ }
94
+ return extendedConfig;
56
95
  }
57
96
 
58
97
  module.exports = extendConfig;
@@ -1,2 +1,11 @@
1
1
  import type { Config } from '../types/config';
2
- export default function extendConfig(...configs: (Config | undefined)[]): Config;
2
+ import { Variable } from '../types/syntax';
3
+ export declare type ExtendedConfig = {
4
+ __extended?: boolean;
5
+ variables?: Record<string, Variable>;
6
+ modes?: Record<string, Record<string, Variable>>;
7
+ at?: Record<string, string>;
8
+ selectors?: Record<string, string>;
9
+ components?: Record<string, string>;
10
+ } & Omit<Config, 'variables' | 'modes'>;
11
+ export default function extendConfig(...configs: (Config | undefined)[]): ExtendedConfig;
@@ -1,56 +1,95 @@
1
- import extend from '@techor/extend';
1
+ import extend from 'json-safe-extend';
2
+ import flattenObject from './flatten-object.mjs';
3
+ import flattenMetaObject from './flatten-meta-object.mjs';
2
4
 
3
- // todo: split resolveConfig into a function
4
5
  function extendConfig(...configs) {
5
- const formatConfig = (config)=>{
6
- const clonedConfig = extend({}, config);
7
- const formatDeeply = (obj)=>{
8
- Object.entries(obj).forEach(([key, value])=>{
9
- if (typeof value === 'object' && !Array.isArray(value)) {
10
- formatDeeply(value);
11
- } else if (key && !key.startsWith('@')) {
12
- obj[key] = {
13
- '': value
14
- };
15
- }
16
- });
17
- };
18
- [
19
- 'components',
20
- 'variables'
21
- ].forEach((key)=>{
22
- if (clonedConfig[key]) {
23
- formatDeeply(clonedConfig[key]);
24
- }
25
- });
26
- return clonedConfig;
27
- };
28
6
  const collectConfigs = (config, result = [])=>{
29
7
  if (!config) return result;
30
8
  if (config.extends?.length) {
31
- config.extends.forEach((ext)=>collectConfigs('config' in ext ? ext.config : ext, result));
9
+ for (const ext of config.extends){
10
+ collectConfigs('config' in ext ? ext.config : ext, result);
11
+ }
32
12
  }
33
- result.push(formatConfig(config));
13
+ const cleanConfig = {
14
+ ...config
15
+ };
16
+ delete cleanConfig.extends;
17
+ result.push(cleanConfig);
34
18
  return result;
35
19
  };
36
- const formattedConfigs = configs.reduce((acc, config)=>collectConfigs(config, acc), []);
37
- return formattedConfigs.reduce((extendedConfig, currentConfig)=>{
38
- Object.entries(currentConfig).forEach(([key, value])=>{
39
- if (key === 'animations' && value) {
40
- Object.assign(extendedConfig.animations, value);
41
- } else if (value) {
42
- extendedConfig = extend(extendedConfig, {
43
- [key]: value
44
- });
20
+ const allConfigs = configs.reduce((acc, config)=>collectConfigs(config, acc), []);
21
+ let extendedConfig = {
22
+ __extended: true
23
+ };
24
+ for (const { variables, modes, components, animations, at, rules, utilities, selectors, functions, ...rest } of allConfigs){
25
+ const isExtended = '__extended' in rest;
26
+ if (isExtended) delete rest.__extended;
27
+ // variables
28
+ if (variables) {
29
+ extendedConfig.variables ??= {};
30
+ const flattened = isExtended ? {
31
+ ...variables
32
+ } : flattenMetaObject(variables, [], {});
33
+ Object.assign(extendedConfig.variables, flattened);
34
+ }
35
+ // modes
36
+ if (modes) {
37
+ extendedConfig.modes ??= {};
38
+ for (const [modeName, modeVars] of Object.entries(modes)){
39
+ const flattenedMode = isExtended ? {
40
+ ...modeVars
41
+ } : flattenMetaObject(modeVars, [], {});
42
+ extendedConfig.modes[modeName] = {
43
+ ...extendedConfig.modes[modeName],
44
+ ...flattenedMode
45
+ };
45
46
  }
46
- });
47
- return extendedConfig;
48
- }, {
49
- animations: {},
50
- components: {},
51
- at: {},
52
- variables: {}
53
- });
47
+ }
48
+ // components
49
+ if (components) {
50
+ extendedConfig.components ??= {};
51
+ const flattened = isExtended ? {
52
+ ...components
53
+ } : flattenObject(components);
54
+ Object.assign(extendedConfig.components, flattened);
55
+ }
56
+ // at
57
+ if (at) {
58
+ extendedConfig.at ??= {};
59
+ const flattened = isExtended ? {
60
+ ...at
61
+ } : flattenObject(at);
62
+ Object.assign(extendedConfig.at, flattened);
63
+ }
64
+ // animations
65
+ if (animations) {
66
+ extendedConfig.animations ??= {};
67
+ Object.assign(extendedConfig.animations, animations);
68
+ }
69
+ // rules
70
+ if (rules) {
71
+ extendedConfig.rules ??= {};
72
+ Object.assign(extendedConfig.rules, rules);
73
+ }
74
+ // utilities
75
+ if (utilities) {
76
+ extendedConfig.utilities ??= {};
77
+ Object.assign(extendedConfig.utilities, utilities);
78
+ }
79
+ // selectors
80
+ if (selectors) {
81
+ extendedConfig.selectors ??= {};
82
+ Object.assign(extendedConfig.selectors, selectors);
83
+ }
84
+ // functions
85
+ if (functions) {
86
+ extendedConfig.functions ??= {};
87
+ Object.assign(extendedConfig.functions, functions);
88
+ }
89
+ // merge the rest (non-structured fields)
90
+ extendedConfig = extend({}, extendedConfig, rest);
91
+ }
92
+ return extendedConfig;
54
93
  }
55
94
 
56
95
  export { extendConfig as default };
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ function flattenMetaObject(obj, name = [], result = {}) {
4
+ for (const [rawKey, rawValue] of Object.entries(obj)){
5
+ const key = rawKey || name[0] || '';
6
+ const path = [
7
+ ...name,
8
+ rawKey
9
+ ].filter(Boolean);
10
+ const flatKey = path.join('-');
11
+ const groupPath = path.slice(0, -1).join('.');
12
+ const namespace = path[0];
13
+ const isObject = rawValue && typeof rawValue === 'object' && !Array.isArray(rawValue);
14
+ const isSelfObject = isObject && Object.keys(rawValue).length === 1 && '' in rawValue;
15
+ if (isSelfObject) {
16
+ result[flatKey] = {
17
+ name: flatKey,
18
+ key,
19
+ value: rawValue[''],
20
+ group: path.length > 1 ? groupPath : undefined,
21
+ namespace: path.length > 1 ? namespace : undefined
22
+ };
23
+ } else if (!isObject) {
24
+ result[flatKey] = {
25
+ name: flatKey,
26
+ key,
27
+ value: Array.isArray(rawValue) ? rawValue.join(',') : rawValue,
28
+ group: path.length > 1 ? groupPath : undefined,
29
+ namespace: path.length > 1 ? namespace : undefined
30
+ };
31
+ } else {
32
+ flattenMetaObject(rawValue, path, result);
33
+ }
34
+ }
35
+ return result;
36
+ }
37
+
38
+ module.exports = flattenMetaObject;
@@ -0,0 +1,13 @@
1
+ export default function flattenMetaObject(obj: Record<string, any>, name?: string[], result?: Record<string, {
2
+ name: string;
3
+ value: any;
4
+ key: string;
5
+ group?: string;
6
+ namespace?: string;
7
+ }>): Record<string, {
8
+ name: string;
9
+ value: any;
10
+ key: string;
11
+ group?: string;
12
+ namespace?: string;
13
+ }>;
@@ -0,0 +1,36 @@
1
+ function flattenMetaObject(obj, name = [], result = {}) {
2
+ for (const [rawKey, rawValue] of Object.entries(obj)){
3
+ const key = rawKey || name[0] || '';
4
+ const path = [
5
+ ...name,
6
+ rawKey
7
+ ].filter(Boolean);
8
+ const flatKey = path.join('-');
9
+ const groupPath = path.slice(0, -1).join('.');
10
+ const namespace = path[0];
11
+ const isObject = rawValue && typeof rawValue === 'object' && !Array.isArray(rawValue);
12
+ const isSelfObject = isObject && Object.keys(rawValue).length === 1 && '' in rawValue;
13
+ if (isSelfObject) {
14
+ result[flatKey] = {
15
+ name: flatKey,
16
+ key,
17
+ value: rawValue[''],
18
+ group: path.length > 1 ? groupPath : undefined,
19
+ namespace: path.length > 1 ? namespace : undefined
20
+ };
21
+ } else if (!isObject) {
22
+ result[flatKey] = {
23
+ name: flatKey,
24
+ key,
25
+ value: Array.isArray(rawValue) ? rawValue.join(',') : rawValue,
26
+ group: path.length > 1 ? groupPath : undefined,
27
+ namespace: path.length > 1 ? namespace : undefined
28
+ };
29
+ } else {
30
+ flattenMetaObject(rawValue, path, result);
31
+ }
32
+ }
33
+ return result;
34
+ }
35
+
36
+ export { flattenMetaObject as default };
@@ -1,15 +1,19 @@
1
1
  'use strict';
2
2
 
3
- function flattenObject(obj, parentKey = '') {
4
- return Object.entries(obj).reduce((acc, [key, value])=>{
5
- const currentKey = parentKey ? `${parentKey}${key ? '-' + key : ''}` : key;
6
- if (typeof value === 'object' && !Array.isArray(value)) {
7
- Object.assign(acc, flattenObject(value, currentKey));
3
+ function flattenObject(obj, name = [], result = {}) {
4
+ for (const [key, value] of Object.entries(obj)){
5
+ const nextName = [
6
+ ...name,
7
+ key
8
+ ].filter(Boolean);
9
+ const flatKey = nextName.join('-');
10
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
11
+ flattenObject(value, nextName, result);
8
12
  } else {
9
- acc[currentKey] = value;
13
+ result[flatKey] = Array.isArray(value) ? value.join(',') : value;
10
14
  }
11
- return acc;
12
- }, {});
15
+ }
16
+ return result;
13
17
  }
14
18
 
15
- exports.flattenObject = flattenObject;
19
+ module.exports = flattenObject;
@@ -1 +1 @@
1
- export declare function flattenObject(obj: Map<string, any> | Record<string, any>, parentKey?: string): Record<string, any>;
1
+ export default function flattenObject(obj: Record<string, any>, name?: string[], result?: Record<string, any>): Record<string, any>;
@@ -1,13 +1,17 @@
1
- function flattenObject(obj, parentKey = '') {
2
- return Object.entries(obj).reduce((acc, [key, value])=>{
3
- const currentKey = parentKey ? `${parentKey}${key ? '-' + key : ''}` : key;
4
- if (typeof value === 'object' && !Array.isArray(value)) {
5
- Object.assign(acc, flattenObject(value, currentKey));
1
+ function flattenObject(obj, name = [], result = {}) {
2
+ for (const [key, value] of Object.entries(obj)){
3
+ const nextName = [
4
+ ...name,
5
+ key
6
+ ].filter(Boolean);
7
+ const flatKey = nextName.join('-');
8
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
9
+ flattenObject(value, nextName, result);
6
10
  } else {
7
- acc[currentKey] = value;
11
+ result[flatKey] = Array.isArray(value) ? value.join(',') : value;
8
12
  }
9
- return acc;
10
- }, {});
13
+ }
14
+ return result;
11
15
  }
12
16
 
13
- export { flattenObject };
17
+ export { flattenObject as default };
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var core = require('../core.cjs');
3
+ var create = require('../create.cjs');
4
4
 
5
- function generateCSS(classes, css = new core()) {
5
+ function generateCSS(classes, css = create()) {
6
6
  let text = '';
7
7
  css.add(...classes);
8
8
  text = css.text;
@@ -1,2 +1 @@
1
- import MasterCSS from '../core';
2
- export default function generateCSS(classes: string[], css?: MasterCSS): string;
1
+ export default function generateCSS(classes: string[], css?: import("..").MasterCSS): string;
@@ -1,6 +1,6 @@
1
- import MasterCSS from '../core.mjs';
1
+ import createCSS from '../create.mjs';
2
2
 
3
- function generateCSS(classes, css = new MasterCSS()) {
3
+ function generateCSS(classes, css = createCSS()) {
4
4
  let text = '';
5
5
  css.add(...classes);
6
6
  text = css.text;