@master/css 2.0.0-rc.53 → 2.0.0-rc.55

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.
@@ -919,6 +919,9 @@ const rules = {
919
919
  type: syntaxRuleType.Native,
920
920
  unit: 'em'
921
921
  },
922
+ hyphens: {
923
+ type: syntaxRuleType.Native
924
+ },
922
925
  'user-drag': {
923
926
  type: syntaxRuleType.Native,
924
927
  declare (value) {
@@ -103,6 +103,7 @@ declare const rules: {
103
103
  'touch-action': SyntaxRuleDefinition;
104
104
  'word-break': SyntaxRuleDefinition;
105
105
  'word-spacing': SyntaxRuleDefinition;
106
+ hyphens: SyntaxRuleDefinition;
106
107
  'user-drag': SyntaxRuleDefinition;
107
108
  'user-select': SyntaxRuleDefinition;
108
109
  'text-shadow': SyntaxRuleDefinition;
@@ -917,6 +917,9 @@ const rules = {
917
917
  type: SyntaxRuleType.Native,
918
918
  unit: 'em'
919
919
  },
920
+ hyphens: {
921
+ type: SyntaxRuleType.Native
922
+ },
920
923
  'user-drag': {
921
924
  type: SyntaxRuleType.Native,
922
925
  declare (value) {
package/dist/core.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var syntaxRule = require('./syntax-rule.cjs');
6
4
  var index = require('./config/index.cjs');
7
5
  var hexToRgb = require('./utils/hex-to-rgb.cjs');
@@ -12,13 +10,14 @@ var rule = require('./rule.cjs');
12
10
  var syntaxRuleType = require('./syntax-rule-type.cjs');
13
11
  var layer = require('./layer.cjs');
14
12
  var nonLayer = require('./non-layer.cjs');
13
+ var registerGlobal = require('./register-global.cjs');
15
14
 
16
15
  class MasterCSS {
17
16
  customConfig;
18
17
  static config = index.config;
19
18
  definedRules;
20
19
  config;
21
- classUsages;
20
+ classCounts;
22
21
  layerStatementRule;
23
22
  rules;
24
23
  animationsNonLayer;
@@ -45,7 +44,7 @@ class MasterCSS {
45
44
  constructor(customConfig){
46
45
  this.customConfig = customConfig;
47
46
  this.definedRules = [];
48
- this.classUsages = new Map();
47
+ this.classCounts = new Map();
49
48
  this.layerStatementRule = new rule.Rule('layer-statement', [
50
49
  {
51
50
  text: '@layer base,theme,preset,components,general;'
@@ -62,9 +61,6 @@ class MasterCSS {
62
61
  this.generalLayer = new syntaxLayer('general', this);
63
62
  this.config = customConfig?.override ? extendConfig(customConfig) : extendConfig(index.config, customConfig);
64
63
  this.resolve();
65
- if (this.constructor === MasterCSS) {
66
- masterCSSs.push(this);
67
- }
68
64
  }
69
65
  resolve() {
70
66
  this.components = {};
@@ -656,7 +652,6 @@ class MasterCSS {
656
652
  if (syntaxRules.length) return syntaxRules;
657
653
  }
658
654
  }
659
- return [];
660
655
  }
661
656
  /**
662
657
  * 根據蒐集到的所有 DOM class 重新 create
@@ -673,7 +668,7 @@ class MasterCSS {
673
668
  /**
674
669
  * 拿當前所有的 classNames 按照最新的 colors, config.rules 匹配並生成新的 style
675
670
  * 所以 refresh 過後 rules 可能會變多也可能會變少
676
- */ this.classUsages.forEach((_, className)=>{
671
+ */ this.classCounts.forEach((_, className)=>{
677
672
  this.add(className);
678
673
  });
679
674
  return this;
@@ -689,8 +684,7 @@ class MasterCSS {
689
684
  }
690
685
  destroy() {
691
686
  this.reset();
692
- this.classUsages.clear();
693
- masterCSSs.splice(masterCSSs.indexOf(this), 1);
687
+ this.classCounts.clear();
694
688
  return this;
695
689
  }
696
690
  add(...classNames) {
@@ -738,11 +732,8 @@ class MasterCSS {
738
732
  }
739
733
  }
740
734
  }
741
- const masterCSSs = [];
742
- (()=>{
743
- globalThis.MasterCSS = MasterCSS;
744
- globalThis.masterCSSs = masterCSSs;
745
- })();
735
+ (function(MasterCSS) {
736
+ registerGlobal(MasterCSS);
737
+ })(MasterCSS);
746
738
 
747
- exports.default = MasterCSS;
748
- exports.masterCSSs = masterCSSs;
739
+ module.exports = MasterCSS;
package/dist/core.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { SyntaxRule } from './syntax-rule';
2
- import './types/global';
3
2
  import SyntaxLayer from './syntax-layer';
4
3
  import { Rule } from './rule';
5
4
  import Layer from './layer';
@@ -12,7 +11,7 @@ export default class MasterCSS {
12
11
  static config: Config;
13
12
  readonly definedRules: DefinedRule[];
14
13
  readonly config: Config;
15
- readonly classUsages: Map<string, number>;
14
+ readonly classCounts: Map<string, number>;
16
15
  readonly layerStatementRule: Rule;
17
16
  readonly rules: (Layer | Rule)[];
18
17
  readonly animationsNonLayer: NonLayer;
@@ -47,7 +46,7 @@ export default class MasterCSS {
47
46
  * Create syntax rule from given selector text
48
47
  * @param selectorText
49
48
  */
50
- createFromSelectorText(selectorText: string): SyntaxRule[];
49
+ createFromSelectorText(selectorText: string): SyntaxRule[] | undefined;
51
50
  /**
52
51
  * 根據蒐集到的所有 DOM class 重新 create
53
52
  */
@@ -58,7 +57,6 @@ export default class MasterCSS {
58
57
  remove(...classNames: string[]): void;
59
58
  getModeSelector(modeName: string): string | undefined;
60
59
  }
61
- export declare const masterCSSs: MasterCSS[];
62
60
  export default interface MasterCSS {
63
61
  supportVendors: Set<Vendors>;
64
62
  style: HTMLStyleElement | null;
package/dist/core.mjs CHANGED
@@ -8,13 +8,14 @@ import { Rule } from './rule.mjs';
8
8
  import SyntaxRuleType from './syntax-rule-type.mjs';
9
9
  import Layer from './layer.mjs';
10
10
  import NonLayer from './non-layer.mjs';
11
+ import registerGlobal from './register-global.mjs';
11
12
 
12
13
  class MasterCSS {
13
14
  customConfig;
14
15
  static config = config;
15
16
  definedRules;
16
17
  config;
17
- classUsages;
18
+ classCounts;
18
19
  layerStatementRule;
19
20
  rules;
20
21
  animationsNonLayer;
@@ -41,7 +42,7 @@ class MasterCSS {
41
42
  constructor(customConfig){
42
43
  this.customConfig = customConfig;
43
44
  this.definedRules = [];
44
- this.classUsages = new Map();
45
+ this.classCounts = new Map();
45
46
  this.layerStatementRule = new Rule('layer-statement', [
46
47
  {
47
48
  text: '@layer base,theme,preset,components,general;'
@@ -58,9 +59,6 @@ class MasterCSS {
58
59
  this.generalLayer = new SyntaxLayer('general', this);
59
60
  this.config = customConfig?.override ? extendConfig(customConfig) : extendConfig(config, customConfig);
60
61
  this.resolve();
61
- if (this.constructor === MasterCSS) {
62
- masterCSSs.push(this);
63
- }
64
62
  }
65
63
  resolve() {
66
64
  this.components = {};
@@ -652,7 +650,6 @@ class MasterCSS {
652
650
  if (syntaxRules.length) return syntaxRules;
653
651
  }
654
652
  }
655
- return [];
656
653
  }
657
654
  /**
658
655
  * 根據蒐集到的所有 DOM class 重新 create
@@ -669,7 +666,7 @@ class MasterCSS {
669
666
  /**
670
667
  * 拿當前所有的 classNames 按照最新的 colors, config.rules 匹配並生成新的 style
671
668
  * 所以 refresh 過後 rules 可能會變多也可能會變少
672
- */ this.classUsages.forEach((_, className)=>{
669
+ */ this.classCounts.forEach((_, className)=>{
673
670
  this.add(className);
674
671
  });
675
672
  return this;
@@ -685,8 +682,7 @@ class MasterCSS {
685
682
  }
686
683
  destroy() {
687
684
  this.reset();
688
- this.classUsages.clear();
689
- masterCSSs.splice(masterCSSs.indexOf(this), 1);
685
+ this.classCounts.clear();
690
686
  return this;
691
687
  }
692
688
  add(...classNames) {
@@ -734,10 +730,8 @@ class MasterCSS {
734
730
  }
735
731
  }
736
732
  }
737
- const masterCSSs = [];
738
- (()=>{
739
- globalThis.MasterCSS = MasterCSS;
740
- globalThis.masterCSSs = masterCSSs;
741
- })();
733
+ (function(MasterCSS) {
734
+ registerGlobal(MasterCSS);
735
+ })(MasterCSS);
742
736
 
743
- export { MasterCSS as default, masterCSSs };
737
+ export { MasterCSS as default };
package/dist/index.cjs CHANGED
@@ -53,9 +53,8 @@ exports.TRANSITION_SIGN = common.TRANSITION_SIGN;
53
53
  exports.UNIT_REGEX = common.UNIT_REGEX;
54
54
  exports.VALUE_DELIMITERS = common.VALUE_DELIMITERS;
55
55
  exports.VALUE_UNITS = common.VALUE_UNITS;
56
- exports.MasterCSS = core.default;
57
- exports.default = core.default;
58
- exports.masterCSSs = core.masterCSSs;
56
+ exports.MasterCSS = core;
57
+ exports.default = core;
59
58
  exports.SyntaxRule = syntaxRule.SyntaxRule;
60
59
  exports.Rule = rule.Rule;
61
60
  exports.Layer = layer;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { config } from './config/index.mjs';
2
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, masterCSSs } from './core.mjs';
3
+ export { default as MasterCSS, default } from './core.mjs';
4
4
  export { SyntaxRule } from './syntax-rule.mjs';
5
5
  export { Rule } from './rule.mjs';
6
6
  export { default as Layer } from './layer.mjs';
@@ -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 };
@@ -2,7 +2,7 @@
2
2
 
3
3
  var core = require('../core.cjs');
4
4
 
5
- function generateCSS(classes, css = new core.default()) {
5
+ function generateCSS(classes, css = new core()) {
6
6
  let text = '';
7
7
  css.add(...classes);
8
8
  text = css.text;
@@ -8,7 +8,7 @@ var core = require('../core.cjs');
8
8
  * @param classes
9
9
  * @param options
10
10
  * @returns consistent classes
11
- */ function reorderForReadableClasses(classes, css = new core.default()) {
11
+ */ function reorderForReadableClasses(classes, css = new core()) {
12
12
  css.add(...classes);
13
13
  const orderedClasses = css.generalLayer.rules// 只保留樣式語法相關的 rules, 排除 keyframes 與 variables 在外
14
14
  .filter((eachRule)=>eachRule.type).sort((a, b)=>{
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@master/css","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","test":"vitest","type-check":"tsc --noEmit","lint":"eslint"},"license":"MIT","description":"The CSS language and framework for rapidly building modern and high-performance websites","author":"Aoyue Design LLC.","funding":"https://rc.css.master.co/sponsor","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/core"},"keywords":["style","styles","html","variants","virtual","virtual-css","utility","css","ui","lightweight","class","webpack","plugin","integration","vite","parcel","build-tools","mastercss"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.cjs","import":"./dist/index.mjs"}},"bin":"./dist/bin/index.mjs","files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/colors":"^2.1.0","@master/normal.css":"^3.1.0","@techor/extend":"^3.1.7","csstype":"^3.1.3"},"devDependencies":{"shared":"^2.0.0-rc.53"},"version":"2.0.0-rc.53"}
1
+ {"name":"@master/css","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","test":"vitest","type-check":"tsc --noEmit","lint":"eslint"},"license":"MIT","description":"The CSS language and framework for rapidly building modern and high-performance websites","author":"Aoyue Design LLC.","funding":"https://rc.css.master.co/sponsor","homepage":"https://css.master.co","bugs":{"url":"https://github.com/master-co/css/issues"},"repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/core"},"keywords":["style","styles","html","variants","virtual","virtual-css","utility","css","ui","lightweight","class","webpack","plugin","integration","vite","parcel","build-tools","mastercss"],"sideEffects":false,"main":"./dist/index.cjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.cjs","import":"./dist/index.mjs"}},"bin":"./dist/bin/index.mjs","files":["dist"],"publishConfig":{"access":"public","provenance":true},"dependencies":{"@master/colors":"^2.1.0","@master/normal.css":"^3.1.0","@techor/extend":"^3.2.0","csstype":"^3.1.3"},"devDependencies":{"shared":"^2.0.0-rc.55"},"version":"2.0.0-rc.55"}
@@ -1,2 +0,0 @@
1
- 'use strict';
2
-
@@ -1,5 +0,0 @@
1
- import type Core from '../core';
2
- declare global {
3
- var masterCSSs: Core[];
4
- var MasterCSS: typeof Core;
5
- }
@@ -1 +0,0 @@
1
-