@master/css 2.0.0-rc.6 → 2.0.0-rc.60

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 (141) hide show
  1. package/README.md +4 -43
  2. package/dist/_virtual/_commonjsHelpers.cjs +10 -0
  3. package/dist/_virtual/_commonjsHelpers.mjs +7 -0
  4. package/dist/_virtual/css-escape.cjs +5 -0
  5. package/dist/_virtual/css-escape.mjs +3 -0
  6. package/dist/bin/index.cjs +11 -0
  7. package/dist/bin/index.d.ts +0 -1
  8. package/dist/bin/index.mjs +9 -0
  9. package/dist/common.cjs +159 -0
  10. package/dist/common.d.ts +26 -0
  11. package/dist/common.mjs +137 -0
  12. package/dist/config/animations.cjs +113 -0
  13. package/dist/config/animations.mjs +111 -0
  14. package/dist/config/at.cjs +16 -0
  15. package/dist/config/at.d.ts +13 -0
  16. package/dist/config/at.mjs +14 -0
  17. package/dist/config/functions.cjs +375 -0
  18. package/dist/config/functions.d.ts +1 -1
  19. package/dist/config/functions.mjs +373 -0
  20. package/dist/config/index.cjs +37 -0
  21. package/dist/config/index.d.ts +5 -62
  22. package/dist/config/index.mjs +27 -0
  23. package/dist/config/modes.cjs +8 -0
  24. package/dist/config/modes.d.ts +3 -0
  25. package/dist/config/modes.mjs +6 -0
  26. package/dist/config/rules.cjs +2330 -0
  27. package/dist/config/rules.d.ts +278 -274
  28. package/dist/config/rules.mjs +2328 -0
  29. package/dist/config/selectors.cjs +28 -0
  30. package/dist/config/selectors.d.ts +0 -1
  31. package/dist/config/selectors.mjs +26 -0
  32. package/dist/config/styles.cjs +2 -0
  33. package/dist/config/styles.d.ts +2 -2
  34. package/dist/config/styles.mjs +1 -0
  35. package/dist/config/utilities.cjs +204 -0
  36. package/dist/config/{semantics.d.ts → utilities.d.ts} +15 -5
  37. package/dist/config/utilities.mjs +202 -0
  38. package/dist/config/variables.cjs +484 -0
  39. package/dist/config/variables.d.ts +208 -312
  40. package/dist/config/variables.mjs +482 -0
  41. package/dist/core.cjs +739 -0
  42. package/dist/core.d.ts +97 -75
  43. package/dist/core.mjs +737 -0
  44. package/dist/factories/with-syntax-layer.cjs +308 -0
  45. package/dist/factories/with-syntax-layer.d.ts +26 -0
  46. package/dist/factories/with-syntax-layer.mjs +306 -0
  47. package/dist/index.cjs +82 -0
  48. package/dist/index.d.ts +21 -9
  49. package/dist/index.mjs +27 -0
  50. package/dist/layer.cjs +50 -0
  51. package/dist/layer.d.ts +14 -10
  52. package/dist/layer.mjs +48 -0
  53. package/dist/non-layer.cjs +64 -0
  54. package/dist/non-layer.d.ts +12 -0
  55. package/dist/non-layer.mjs +62 -0
  56. package/dist/polyfills/css-escape.cjs +9 -0
  57. package/dist/polyfills/css-escape.mjs +7 -0
  58. package/dist/polyfills/css-escape2.cjs +76 -0
  59. package/dist/polyfills/css-escape2.mjs +74 -0
  60. package/dist/register-global.cjs +7 -0
  61. package/dist/register-global.d.ts +5 -0
  62. package/dist/register-global.mjs +5 -0
  63. package/dist/rule.cjs +18 -0
  64. package/dist/rule.d.ts +9 -111
  65. package/dist/rule.mjs +16 -0
  66. package/dist/shared/utils/css-escape.cjs +56 -0
  67. package/dist/shared/utils/css-escape.mjs +54 -0
  68. package/dist/shared/utils/find-native-css-rule-index.cjs +12 -0
  69. package/dist/shared/utils/find-native-css-rule-index.mjs +10 -0
  70. package/dist/syntax-layer.cjs +8 -0
  71. package/dist/syntax-layer.d.ts +18 -0
  72. package/dist/syntax-layer.mjs +6 -0
  73. package/dist/syntax-rule-type.cjs +27 -0
  74. package/dist/syntax-rule-type.d.ts +28 -0
  75. package/dist/syntax-rule-type.mjs +25 -0
  76. package/dist/syntax-rule.cjs +644 -0
  77. package/dist/syntax-rule.d.ts +47 -0
  78. package/dist/syntax-rule.mjs +642 -0
  79. package/dist/types/common.cjs +2 -0
  80. package/dist/types/common.d.ts +1 -0
  81. package/dist/types/common.mjs +1 -0
  82. package/dist/types/config.cjs +2 -0
  83. package/dist/types/config.d.ts +70 -0
  84. package/dist/types/config.mjs +1 -0
  85. package/dist/types/syntax.cjs +2 -0
  86. package/dist/types/syntax.d.ts +106 -0
  87. package/dist/types/syntax.mjs +1 -0
  88. package/dist/utils/are-rule-at-equal.cjs +22 -0
  89. package/dist/utils/are-rule-at-equal.d.ts +2 -0
  90. package/dist/utils/are-rule-at-equal.mjs +20 -0
  91. package/dist/utils/are-rule-modes-equal.cjs +7 -0
  92. package/dist/utils/are-rule-modes-equal.d.ts +2 -0
  93. package/dist/utils/are-rule-modes-equal.mjs +5 -0
  94. package/dist/utils/are-rule-selectors-equal.cjs +29 -0
  95. package/dist/utils/are-rule-selectors-equal.d.ts +2 -0
  96. package/dist/utils/are-rule-selectors-equal.mjs +27 -0
  97. package/dist/utils/are-rule-states-equal.cjs +11 -0
  98. package/dist/utils/are-rule-states-equal.d.ts +2 -0
  99. package/dist/utils/are-rule-states-equal.mjs +9 -0
  100. package/dist/utils/are-rules-duplicated.cjs +17 -0
  101. package/dist/utils/are-rules-duplicated.d.ts +2 -0
  102. package/dist/utils/are-rules-duplicated.mjs +15 -0
  103. package/dist/utils/autofill-solid-style.cjs +31 -0
  104. package/dist/utils/autofill-solid-style.d.ts +3 -0
  105. package/dist/utils/autofill-solid-style.mjs +29 -0
  106. package/dist/utils/extend-config.cjs +59 -0
  107. package/dist/utils/extend-config.d.ts +2 -2
  108. package/dist/utils/extend-config.mjs +57 -0
  109. package/dist/utils/flatten-object.cjs +15 -0
  110. package/dist/utils/flatten-object.d.ts +1 -1
  111. package/dist/utils/flatten-object.mjs +13 -0
  112. package/dist/utils/generate-css.cjs +13 -0
  113. package/dist/utils/generate-css.d.ts +2 -0
  114. package/dist/utils/generate-css.mjs +11 -0
  115. package/dist/utils/hex-to-rgb.cjs +30 -0
  116. package/dist/utils/hex-to-rgb.d.ts +1 -1
  117. package/dist/utils/hex-to-rgb.mjs +28 -0
  118. package/dist/utils/is-core-rule.cjs +9 -0
  119. package/dist/utils/is-core-rule.d.ts +1 -0
  120. package/dist/utils/is-core-rule.mjs +7 -0
  121. package/dist/utils/reorder-for-readable-classes.cjs +62 -0
  122. package/dist/{functions → utils}/reorder-for-readable-classes.d.ts +2 -6
  123. package/dist/utils/reorder-for-readable-classes.mjs +60 -0
  124. package/package.json +1 -1
  125. package/dist/bin/index.bundle.js +0 -36
  126. package/dist/config/media-queries.d.ts +0 -1
  127. package/dist/constants/base-unit-regex.d.ts +0 -1
  128. package/dist/constants/config-esm-text.d.ts +0 -1
  129. package/dist/constants/config-text.d.ts +0 -1
  130. package/dist/constants/config-ts-text.d.ts +0 -1
  131. package/dist/constants/start-symbol.d.ts +0 -6
  132. package/dist/functions/transform-color-with-opacity.d.ts +0 -1
  133. package/dist/index.bundle.js +0 -35
  134. package/dist/index.bundle.mjs +0 -35
  135. package/dist/tokens/screen-sizes.d.ts +0 -14
  136. package/dist/types/global.d.ts +0 -5
  137. package/dist/utils/concat-arrays.d.ts +0 -1
  138. package/dist/utils/get-type.d.ts +0 -7
  139. package/dist/utils/is-plain-object.d.ts +0 -8
  140. package/dist/utils/is-symbol.d.ts +0 -7
  141. package/dist/utils/rgb-to-hex.d.ts +0 -1
package/dist/index.cjs ADDED
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var index = require('./config/index.cjs');
6
+ var common = require('./common.cjs');
7
+ var core = require('./core.cjs');
8
+ var syntaxRule = require('./syntax-rule.cjs');
9
+ var rule = require('./rule.cjs');
10
+ var layer = require('./layer.cjs');
11
+ var syntaxLayer = require('./syntax-layer.cjs');
12
+ var nonLayer = require('./non-layer.cjs');
13
+ var syntaxRuleType = require('./syntax-rule-type.cjs');
14
+ var withSyntaxLayer = require('./factories/with-syntax-layer.cjs');
15
+ var extendConfig = require('./utils/extend-config.cjs');
16
+ var reorderForReadableClasses = require('./utils/reorder-for-readable-classes.cjs');
17
+ var areRuleModesEqual = require('./utils/are-rule-modes-equal.cjs');
18
+ var areRuleAtEqual = require('./utils/are-rule-at-equal.cjs');
19
+ var areRuleSelectorsEqual = require('./utils/are-rule-selectors-equal.cjs');
20
+ var areRuleStatesEqual = require('./utils/are-rule-states-equal.cjs');
21
+ var areRulesDuplicated = require('./utils/are-rules-duplicated.cjs');
22
+ var generateCss = require('./utils/generate-css.cjs');
23
+ var isCoreRule = require('./utils/is-core-rule.cjs');
24
+ var at = require('./config/at.cjs');
25
+ var selectors = require('./config/selectors.cjs');
26
+ var utilities = require('./config/utilities.cjs');
27
+ var rules = require('./config/rules.cjs');
28
+ var functions = require('./config/functions.cjs');
29
+ var animations = require('./config/animations.cjs');
30
+ var variables = require('./config/variables.cjs');
31
+ var modes = require('./config/modes.cjs');
32
+
33
+
34
+
35
+ exports.config = index.config;
36
+ exports.ANIMATION_SIGN = common.ANIMATION_SIGN;
37
+ exports.AT_SIGN = common.AT_SIGN;
38
+ exports.BASE_UNIT_REGEX = common.BASE_UNIT_REGEX;
39
+ exports.BORDER_STYLE_VALUES = common.BORDER_STYLE_VALUES;
40
+ exports.CLASS_ATTRIBUTES = common.CLASS_ATTRIBUTES;
41
+ exports.CLASS_DECLARATIONS = common.CLASS_DECLARATIONS;
42
+ exports.CLASS_FUNCTIONS = common.CLASS_FUNCTIONS;
43
+ exports.COLOR_VALUE_REGEX = common.COLOR_VALUE_REGEX;
44
+ exports.DELIMITER_SIGN = common.DELIMITER_SIGN;
45
+ exports.IMAGE_VALUE_REGEX = common.IMAGE_VALUE_REGEX;
46
+ exports.NUMBER_VALUE_REGEX = common.NUMBER_VALUE_REGEX;
47
+ exports.OFFICIAL_URL = common.OFFICIAL_URL;
48
+ exports.QUERY_COMPARISON_OPERATORS = common.QUERY_COMPARISON_OPERATORS;
49
+ exports.QUERY_LOGICAL_OPERATORS = common.QUERY_LOGICAL_OPERATORS;
50
+ exports.SELECTOR_SIGNS = common.SELECTOR_SIGNS;
51
+ exports.SEPARATOR_SIGN = common.SEPARATOR_SIGN;
52
+ exports.SEPARATOR_SIGNS = common.SEPARATOR_SIGNS;
53
+ exports.TRANSITION_SIGN = common.TRANSITION_SIGN;
54
+ exports.UNIT_REGEX = common.UNIT_REGEX;
55
+ exports.VALUE_DELIMITERS = common.VALUE_DELIMITERS;
56
+ exports.VALUE_UNITS = common.VALUE_UNITS;
57
+ exports.MasterCSS = core;
58
+ exports.default = core;
59
+ exports.SyntaxRule = syntaxRule.SyntaxRule;
60
+ exports.Rule = rule.Rule;
61
+ exports.Layer = layer;
62
+ exports.SyntaxLayer = syntaxLayer;
63
+ exports.NonLayer = nonLayer;
64
+ exports.SyntaxRuleType = syntaxRuleType;
65
+ exports.withSyntaxLayer = withSyntaxLayer;
66
+ exports.extendConfig = extendConfig;
67
+ exports.reorderForReadableClasses = reorderForReadableClasses;
68
+ exports.areRuleModesEqual = areRuleModesEqual;
69
+ exports.areRuleAtEqual = areRuleAtEqual;
70
+ exports.areRuleSelectorsEqual = areRuleSelectorsEqual;
71
+ exports.areRuleStatesEqual = areRuleStatesEqual;
72
+ exports.areRulesDuplicated = areRulesDuplicated;
73
+ exports.generateCSS = generateCss;
74
+ exports.isCoreRule = isCoreRule;
75
+ exports.at = at;
76
+ exports.selectors = selectors;
77
+ exports.utilities = utilities;
78
+ exports.rules = rules;
79
+ exports.functions = functions;
80
+ exports.animations = animations;
81
+ exports.variables = variables;
82
+ exports.modes = modes;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,22 @@
1
- export { MasterCSS, MasterCSS as default } from './core';
2
- export { Rule } from './rule';
3
- export type { NativeRule, MediaFeatureComponent, MediaQuery } from './rule';
4
- export { CONFIG_TEXT } from './constants/config-text';
5
- export { CONFIG_ESM_TEXT } from './constants/config-esm-text';
6
- export { CONFIG_TS_TEXT } from './constants/config-ts-text';
7
- export { Layer } from './layer';
8
- export { default as extend } from '@techor/extend';
9
- export { default as reorderForReadableClasses } from './functions/reorder-for-readable-classes';
10
1
  export * from './config';
2
+ export * from './common';
3
+ export * from './core';
4
+ export * from './syntax-rule';
5
+ export * from './rule';
6
+ export { default as Layer } from './layer';
7
+ export { default as SyntaxLayer } from './syntax-layer';
8
+ export { default as NonLayer } from './non-layer';
9
+ export { default as SyntaxRuleType } from './syntax-rule-type';
10
+ export { default as MasterCSS, default } from './core';
11
+ export * from './types/config';
12
+ export * from './types/syntax';
13
+ export { default as withSyntaxLayer } from './factories/with-syntax-layer';
14
+ export { default as extendConfig } from './utils/extend-config';
15
+ export { default as reorderForReadableClasses } from './utils/reorder-for-readable-classes';
16
+ export { default as areRuleModesEqual } from './utils/are-rule-modes-equal';
17
+ export { default as areRuleAtEqual } from './utils/are-rule-at-equal';
18
+ export { default as areRuleSelectorsEqual } from './utils/are-rule-selectors-equal';
19
+ export { default as areRuleStatesEqual } from './utils/are-rule-states-equal';
20
+ export { default as areRulesDuplicated } from './utils/are-rules-duplicated';
21
+ export { default as generateCSS } from './utils/generate-css';
22
+ export { default as isCoreRule } from './utils/is-core-rule';
package/dist/index.mjs ADDED
@@ -0,0 +1,27 @@
1
+ export { config } from './config/index.mjs';
2
+ export { ANIMATION_SIGN, AT_SIGN, BASE_UNIT_REGEX, BORDER_STYLE_VALUES, CLASS_ATTRIBUTES, CLASS_DECLARATIONS, CLASS_FUNCTIONS, COLOR_VALUE_REGEX, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS } from './common.mjs';
3
+ export { default as MasterCSS, default } from './core.mjs';
4
+ export { SyntaxRule } from './syntax-rule.mjs';
5
+ export { Rule } from './rule.mjs';
6
+ export { default as Layer } from './layer.mjs';
7
+ export { default as SyntaxLayer } from './syntax-layer.mjs';
8
+ export { default as NonLayer } from './non-layer.mjs';
9
+ export { default as SyntaxRuleType } from './syntax-rule-type.mjs';
10
+ export { default as withSyntaxLayer } from './factories/with-syntax-layer.mjs';
11
+ export { default as extendConfig } from './utils/extend-config.mjs';
12
+ export { default as reorderForReadableClasses } from './utils/reorder-for-readable-classes.mjs';
13
+ export { default as areRuleModesEqual } from './utils/are-rule-modes-equal.mjs';
14
+ export { default as areRuleAtEqual } from './utils/are-rule-at-equal.mjs';
15
+ export { default as areRuleSelectorsEqual } from './utils/are-rule-selectors-equal.mjs';
16
+ export { default as areRuleStatesEqual } from './utils/are-rule-states-equal.mjs';
17
+ export { default as areRulesDuplicated } from './utils/are-rules-duplicated.mjs';
18
+ export { default as generateCSS } from './utils/generate-css.mjs';
19
+ export { default as isCoreRule } from './utils/is-core-rule.mjs';
20
+ export { default as at } from './config/at.mjs';
21
+ export { default as selectors } from './config/selectors.mjs';
22
+ export { default as utilities } from './config/utilities.mjs';
23
+ export { default as rules } from './config/rules.mjs';
24
+ export { default as functions } from './config/functions.mjs';
25
+ export { default as animations } from './config/animations.mjs';
26
+ export { default as variables } from './config/variables.mjs';
27
+ export { default as modes } from './config/modes.mjs';
package/dist/layer.cjs ADDED
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ class Layer {
4
+ name;
5
+ css;
6
+ rules;
7
+ tokenCounts;
8
+ constructor(name, css){
9
+ this.name = name;
10
+ this.css = css;
11
+ this.rules = [];
12
+ this.tokenCounts = new Map();
13
+ }
14
+ attach() {
15
+ this.css.rules.push(this);
16
+ }
17
+ detach() {
18
+ this.css.rules.splice(this.css.rules.indexOf(this), 1);
19
+ }
20
+ insert(rule, index = this.rules.length) {
21
+ if (this.rules.find(({ key })=>key === rule.key)) return;
22
+ if (!this.css.rules.includes(this)) {
23
+ this.attach();
24
+ }
25
+ this.rules.splice(index, 0, rule);
26
+ return index;
27
+ }
28
+ delete(key) {
29
+ const rule = this.rules.find((rule)=>rule.key === key);
30
+ if (!rule) return;
31
+ if (this.rules.length === 1) {
32
+ this.detach();
33
+ }
34
+ this.rules.splice(this.rules.indexOf(rule), 1);
35
+ return rule;
36
+ }
37
+ reset() {
38
+ this.rules.length = 0;
39
+ const indexOfLayer = this.css.rules.indexOf(this);
40
+ if (indexOfLayer !== -1) {
41
+ this.css.rules.splice(indexOfLayer, 1);
42
+ }
43
+ this.tokenCounts.clear();
44
+ }
45
+ get text() {
46
+ return '@layer ' + this.name + '{' + this.rules.map(({ text })=>text).join('') + '}';
47
+ }
48
+ }
49
+
50
+ module.exports = Layer;
package/dist/layer.d.ts CHANGED
@@ -1,11 +1,15 @@
1
- export declare const enum Layer {
2
- Semantic = -8,
3
- CoreNativeShorthand = -7,
4
- NativeShorthand = -6,
5
- CoreShorthand = -5,
6
- Shorthand = -4,
7
- CoreNative = -3,
8
- Native = -2,
9
- Core = -1,
10
- Normal = 0
1
+ import { Rule } from './rule';
2
+ import MasterCSS from './core';
3
+ export default class Layer {
4
+ name: string;
5
+ css: MasterCSS;
6
+ readonly rules: Rule[];
7
+ readonly tokenCounts: Map<string, number>;
8
+ constructor(name: string, css: MasterCSS);
9
+ attach(): void;
10
+ detach(): void;
11
+ insert(rule: Rule, index?: number): number | undefined;
12
+ delete(key: string): Rule | undefined;
13
+ reset(): void;
14
+ get text(): string;
11
15
  }
package/dist/layer.mjs ADDED
@@ -0,0 +1,48 @@
1
+ class Layer {
2
+ name;
3
+ css;
4
+ rules;
5
+ tokenCounts;
6
+ constructor(name, css){
7
+ this.name = name;
8
+ this.css = css;
9
+ this.rules = [];
10
+ this.tokenCounts = new Map();
11
+ }
12
+ attach() {
13
+ this.css.rules.push(this);
14
+ }
15
+ detach() {
16
+ this.css.rules.splice(this.css.rules.indexOf(this), 1);
17
+ }
18
+ insert(rule, index = this.rules.length) {
19
+ if (this.rules.find(({ key })=>key === rule.key)) return;
20
+ if (!this.css.rules.includes(this)) {
21
+ this.attach();
22
+ }
23
+ this.rules.splice(index, 0, rule);
24
+ return index;
25
+ }
26
+ delete(key) {
27
+ const rule = this.rules.find((rule)=>rule.key === key);
28
+ if (!rule) return;
29
+ if (this.rules.length === 1) {
30
+ this.detach();
31
+ }
32
+ this.rules.splice(this.rules.indexOf(rule), 1);
33
+ return rule;
34
+ }
35
+ reset() {
36
+ this.rules.length = 0;
37
+ const indexOfLayer = this.css.rules.indexOf(this);
38
+ if (indexOfLayer !== -1) {
39
+ this.css.rules.splice(indexOfLayer, 1);
40
+ }
41
+ this.tokenCounts.clear();
42
+ }
43
+ get text() {
44
+ return '@layer ' + this.name + '{' + this.rules.map(({ text })=>text).join('') + '}';
45
+ }
46
+ }
47
+
48
+ export { Layer as default };
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ var findNativeCssRuleIndex = require('./shared/utils/find-native-css-rule-index.cjs');
4
+
5
+ class NonLayer {
6
+ css;
7
+ rules;
8
+ tokenCounts;
9
+ constructor(css){
10
+ this.css = css;
11
+ this.rules = [];
12
+ this.tokenCounts = new Map();
13
+ }
14
+ insert(rule) {
15
+ if (this.rules.includes(rule)) return;
16
+ const sheet = this.css.style?.sheet;
17
+ if (sheet) {
18
+ for(let i = 0; i < rule.nodes.length;){
19
+ try {
20
+ const nativeRule = rule.nodes[i];
21
+ const insertedIndex = sheet.insertRule(nativeRule.text, sheet.cssRules.length);
22
+ nativeRule.native = sheet.cssRules[insertedIndex];
23
+ i++;
24
+ } catch (error) {
25
+ console.error(error);
26
+ rule.nodes.splice(i, 1);
27
+ }
28
+ }
29
+ }
30
+ this.rules.push(rule);
31
+ this.css.rules.push(rule);
32
+ }
33
+ delete(key) {
34
+ const rule = this.rules.find((rule)=>rule.key === key);
35
+ if (!rule) return;
36
+ const sheet = this.css.style?.sheet;
37
+ if (sheet) {
38
+ for (const node of rule.nodes){
39
+ const foundIndex = findNativeCssRuleIndex(sheet.cssRules, node.native);
40
+ if (foundIndex !== -1) {
41
+ sheet.deleteRule(foundIndex);
42
+ }
43
+ }
44
+ }
45
+ this.rules.splice(this.rules.indexOf(rule), 1);
46
+ this.css.rules.splice(this.css.rules.indexOf(rule), 1);
47
+ return rule;
48
+ }
49
+ get text() {
50
+ return this.rules.map(({ text })=>text).join('');
51
+ }
52
+ reset() {
53
+ for (const rule of this.rules){
54
+ const foundIndex = this.css.rules.indexOf(rule);
55
+ if (foundIndex !== -1) {
56
+ this.css.rules.splice(foundIndex, 1);
57
+ }
58
+ }
59
+ this.rules.length = 0;
60
+ this.tokenCounts.clear();
61
+ }
62
+ }
63
+
64
+ module.exports = NonLayer;
@@ -0,0 +1,12 @@
1
+ import MasterCSS from './core';
2
+ import { Rule } from './rule';
3
+ export default class NonLayer {
4
+ css: MasterCSS;
5
+ readonly rules: Rule[];
6
+ readonly tokenCounts: Map<string, number>;
7
+ constructor(css: MasterCSS);
8
+ insert(rule: Rule): void;
9
+ delete(key: string): Rule | undefined;
10
+ get text(): string;
11
+ reset(): void;
12
+ }
@@ -0,0 +1,62 @@
1
+ import findNativeCSSRuleIndex from './shared/utils/find-native-css-rule-index.mjs';
2
+
3
+ class NonLayer {
4
+ css;
5
+ rules;
6
+ tokenCounts;
7
+ constructor(css){
8
+ this.css = css;
9
+ this.rules = [];
10
+ this.tokenCounts = new Map();
11
+ }
12
+ insert(rule) {
13
+ if (this.rules.includes(rule)) return;
14
+ const sheet = this.css.style?.sheet;
15
+ if (sheet) {
16
+ for(let i = 0; i < rule.nodes.length;){
17
+ try {
18
+ const nativeRule = rule.nodes[i];
19
+ const insertedIndex = sheet.insertRule(nativeRule.text, sheet.cssRules.length);
20
+ nativeRule.native = sheet.cssRules[insertedIndex];
21
+ i++;
22
+ } catch (error) {
23
+ console.error(error);
24
+ rule.nodes.splice(i, 1);
25
+ }
26
+ }
27
+ }
28
+ this.rules.push(rule);
29
+ this.css.rules.push(rule);
30
+ }
31
+ delete(key) {
32
+ const rule = this.rules.find((rule)=>rule.key === key);
33
+ if (!rule) return;
34
+ const sheet = this.css.style?.sheet;
35
+ if (sheet) {
36
+ for (const node of rule.nodes){
37
+ const foundIndex = findNativeCSSRuleIndex(sheet.cssRules, node.native);
38
+ if (foundIndex !== -1) {
39
+ sheet.deleteRule(foundIndex);
40
+ }
41
+ }
42
+ }
43
+ this.rules.splice(this.rules.indexOf(rule), 1);
44
+ this.css.rules.splice(this.css.rules.indexOf(rule), 1);
45
+ return rule;
46
+ }
47
+ get text() {
48
+ return this.rules.map(({ text })=>text).join('');
49
+ }
50
+ reset() {
51
+ for (const rule of this.rules){
52
+ const foundIndex = this.css.rules.indexOf(rule);
53
+ if (foundIndex !== -1) {
54
+ this.css.rules.splice(foundIndex, 1);
55
+ }
56
+ }
57
+ this.rules.length = 0;
58
+ this.tokenCounts.clear();
59
+ }
60
+ }
61
+
62
+ export { NonLayer as default };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var _commonjsHelpers = require('../_virtual/_commonjsHelpers.cjs');
4
+ var cssEscape$1 = require('./css-escape2.cjs');
5
+
6
+ var cssEscapeExports = cssEscape$1.__require();
7
+ var cssEscape = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(cssEscapeExports);
8
+
9
+ module.exports = cssEscape;
@@ -0,0 +1,7 @@
1
+ import { getDefaultExportFromCjs } from '../_virtual/_commonjsHelpers.mjs';
2
+ import { __require as requireCssEscape } from './css-escape2.mjs';
3
+
4
+ var cssEscapeExports = requireCssEscape();
5
+ var cssEscape = /*@__PURE__*/getDefaultExportFromCjs(cssEscapeExports);
6
+
7
+ export { cssEscape as default };
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ var _commonjsHelpers = require('../_virtual/_commonjsHelpers.cjs');
4
+ var cssEscape = require('../_virtual/css-escape.cjs');
5
+
6
+ var hasRequiredCssEscape;
7
+
8
+ function requireCssEscape () {
9
+ if (hasRequiredCssEscape) return cssEscape.__exports;
10
+ hasRequiredCssEscape = 1;
11
+ (()=>{
12
+ const root = typeof _commonjsHelpers.commonjsGlobal !== 'undefined' ? _commonjsHelpers.commonjsGlobal : window;
13
+ if (!root.CSS && !root.CSS?.escape) {
14
+ // https://drafts.csswg.org/cssom/#serialize-an-identifier
15
+ const cssEscape = function(value) {
16
+ if (arguments.length == 0) {
17
+ throw new TypeError('`CSS.escape` requires an argument.');
18
+ }
19
+ const string = String(value);
20
+ const length = string.length;
21
+ let index = -1;
22
+ let result = '';
23
+ let codeUnit;
24
+ const firstCodeUnit = string.charCodeAt(0);
25
+ if (// If the character is the first character and is a `-` (U+002D), and
26
+ // there is no second character, […]
27
+ length == 1 && firstCodeUnit == 0x002D) {
28
+ return '\\' + string;
29
+ }
30
+ while(++index < length){
31
+ codeUnit = string.charCodeAt(index);
32
+ // Note: there’s no need to special-case astral symbols, surrogate
33
+ // pairs, or lone surrogates.
34
+ // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
35
+ // (U+FFFD).
36
+ if (codeUnit == 0x0000) {
37
+ result += '\uFFFD';
38
+ continue;
39
+ }
40
+ if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
41
+ // U+007F, […]
42
+ codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
43
+ // (U+0030 to U+0039), […]
44
+ index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
45
+ // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
46
+ index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
47
+ // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
48
+ result += '\\' + codeUnit.toString(16) + ' ';
49
+ continue;
50
+ }
51
+ // If the character is not handled by one of the above syntaxes and is
52
+ // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
53
+ // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
54
+ // U+005A), or [a-z] (U+0061 to U+007A), […]
55
+ if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
56
+ // the character itself
57
+ result += string.charAt(index);
58
+ continue;
59
+ }
60
+ // Otherwise, the escaped character.
61
+ // https://drafts.csswg.org/cssom/#escape-a-character
62
+ result += '\\' + string.charAt(index);
63
+ }
64
+ return result;
65
+ };
66
+ if (!root.CSS) {
67
+ root.CSS = {};
68
+ }
69
+ root.CSS.escape = cssEscape;
70
+ globalThis.CSS.escape = cssEscape;
71
+ }
72
+ })();
73
+ return cssEscape.__exports;
74
+ }
75
+
76
+ exports.__require = requireCssEscape;
@@ -0,0 +1,74 @@
1
+ import { commonjsGlobal } from '../_virtual/_commonjsHelpers.mjs';
2
+ import { __exports as cssEscape } from '../_virtual/css-escape.mjs';
3
+
4
+ var hasRequiredCssEscape;
5
+
6
+ function requireCssEscape () {
7
+ if (hasRequiredCssEscape) return cssEscape;
8
+ hasRequiredCssEscape = 1;
9
+ (()=>{
10
+ const root = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : window;
11
+ if (!root.CSS && !root.CSS?.escape) {
12
+ // https://drafts.csswg.org/cssom/#serialize-an-identifier
13
+ const cssEscape = function(value) {
14
+ if (arguments.length == 0) {
15
+ throw new TypeError('`CSS.escape` requires an argument.');
16
+ }
17
+ const string = String(value);
18
+ const length = string.length;
19
+ let index = -1;
20
+ let result = '';
21
+ let codeUnit;
22
+ const firstCodeUnit = string.charCodeAt(0);
23
+ if (// If the character is the first character and is a `-` (U+002D), and
24
+ // there is no second character, […]
25
+ length == 1 && firstCodeUnit == 0x002D) {
26
+ return '\\' + string;
27
+ }
28
+ while(++index < length){
29
+ codeUnit = string.charCodeAt(index);
30
+ // Note: there’s no need to special-case astral symbols, surrogate
31
+ // pairs, or lone surrogates.
32
+ // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
33
+ // (U+FFFD).
34
+ if (codeUnit == 0x0000) {
35
+ result += '\uFFFD';
36
+ continue;
37
+ }
38
+ if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
39
+ // U+007F, […]
40
+ codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
41
+ // (U+0030 to U+0039), […]
42
+ index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
43
+ // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
44
+ index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
45
+ // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
46
+ result += '\\' + codeUnit.toString(16) + ' ';
47
+ continue;
48
+ }
49
+ // If the character is not handled by one of the above syntaxes and is
50
+ // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
51
+ // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
52
+ // U+005A), or [a-z] (U+0061 to U+007A), […]
53
+ if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
54
+ // the character itself
55
+ result += string.charAt(index);
56
+ continue;
57
+ }
58
+ // Otherwise, the escaped character.
59
+ // https://drafts.csswg.org/cssom/#escape-a-character
60
+ result += '\\' + string.charAt(index);
61
+ }
62
+ return result;
63
+ };
64
+ if (!root.CSS) {
65
+ root.CSS = {};
66
+ }
67
+ root.CSS.escape = cssEscape;
68
+ globalThis.CSS.escape = cssEscape;
69
+ }
70
+ })();
71
+ return cssEscape;
72
+ }
73
+
74
+ export { requireCssEscape as __require };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ function registerGlobal(MasterCSS) {
4
+ if (!globalThis.MasterCSS) globalThis.MasterCSS = MasterCSS;
5
+ }
6
+
7
+ module.exports = registerGlobal;
@@ -0,0 +1,5 @@
1
+ import type Core from './core';
2
+ declare global {
3
+ var MasterCSS: typeof Core;
4
+ }
5
+ export default function registerGlobal(MasterCSS: typeof Core): void;
@@ -0,0 +1,5 @@
1
+ function registerGlobal(MasterCSS) {
2
+ if (!globalThis.MasterCSS) globalThis.MasterCSS = MasterCSS;
3
+ }
4
+
5
+ export { registerGlobal as default };
package/dist/rule.cjs ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ class Rule {
4
+ name;
5
+ nodes;
6
+ constructor(name, nodes = []){
7
+ this.name = name;
8
+ this.nodes = nodes;
9
+ }
10
+ get key() {
11
+ return this.name;
12
+ }
13
+ get text() {
14
+ return this.nodes.map(({ text })=>text).join('');
15
+ }
16
+ }
17
+
18
+ exports.Rule = Rule;