@plumeria/core 3.0.0 → 3.1.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.
package/dist/css.d.ts CHANGED
@@ -61,18 +61,19 @@ type ViewTransition = {
61
61
  old?: CSSProperties;
62
62
  };
63
63
 
64
- declare class _css {
65
- static create<const T extends Record<string, CSSProperties>>(rule: CreateStyleType<T>): ReturnType<T>;
66
- static props(...rules: (false | Readonly<CSSProperties> | null | undefined)[]): string;
67
- static createTheme<const T extends CreateTheme>(rule: T): ReturnVariableType<T>;
68
- static createStatic<const T extends CreateStatic>(rule: T): T;
69
- static keyframes(rule: Keyframes): string;
70
- static viewTransition(rule: ViewTransition): string;
71
- }
64
+ declare function props(...rules: (false | CSSProperties | null | undefined)[]): string;
65
+ declare const css: {
66
+ new (): {};
67
+ create<const T extends Record<string, CSSProperties>>(_rule: CreateStyleType<T>): ReturnType<T>;
68
+ props: typeof props;
69
+ createTheme<const T extends CreateTheme>(_rule: T): ReturnVariableType<T>;
70
+ createStatic<const T extends CreateStatic>(_rule: T): T;
71
+ keyframes(_rule: Keyframes): string;
72
+ viewTransition(_rule: ViewTransition): string;
73
+ };
72
74
  declare const x: (className: string, styles: Styles) => {
73
75
  className: string;
74
76
  styles: Styles;
75
77
  };
76
- declare const css: typeof _css;
77
78
 
78
79
  export { type CSSProperties, type CreateStyle, css, x };
package/dist/css.js CHANGED
@@ -1,50 +1,62 @@
1
1
 
2
2
  function errorFn(fn) {
3
- throw new Error("Using the \"css." + fn + "\" is runtime not supported. Make sure you have setup bundler-plugin correctly.");
4
- }
5
- function create(_rule) {
6
- throw errorFn("create");
3
+ throw new Error(`css.${fn} requires bundler-plugin setup`);
7
4
  }
8
5
  function props(...rules) {
9
- return rules.filter(Boolean).join(" ");
10
- }
11
- function createStatic(_rule) {
12
- throw errorFn("createStatic");
13
- }
14
- function createTheme(_rule) {
15
- throw errorFn("createTheme");
16
- }
17
- function keyframes(_rule) {
18
- throw errorFn("keyframes");
19
- }
20
- function viewTransition(_rule) {
21
- throw errorFn("viewTransition");
22
- }
23
- var _css = class {
24
- static create(rule) {
25
- return create(rule);
6
+ const chosen = new Map();
7
+ const classList = [];
8
+ const orderedKeys = [];
9
+ const rightmostKeys = [];
10
+ for (let i = rules.length - 1; i >= 0; i--) {
11
+ const arg = rules[i];
12
+ if (!arg || typeof arg === "string") continue;
13
+ for (const [key, hash] of Object.entries(arg)) if (!chosen.has(key)) chosen.set(key, {
14
+ hash,
15
+ propsIdx: i
16
+ });
26
17
  }
27
- static props(...rules) {
28
- return props(...rules);
18
+ for (let i = 0; i < rules.length; i++) {
19
+ const arg = rules[i];
20
+ if (!arg) continue;
21
+ if (typeof arg === "string") {
22
+ classList.push(arg);
23
+ continue;
24
+ }
25
+ for (const [key] of Object.entries(arg)) {
26
+ const info = chosen.get(key);
27
+ if (info && info.propsIdx === i) {
28
+ if (i === rules.length - 1) rightmostKeys.push(info);
29
+ else orderedKeys.push(info);
30
+ chosen.delete(key);
31
+ }
32
+ }
33
+ }
34
+ for (const { hash } of orderedKeys) classList.push(hash);
35
+ for (const { hash } of rightmostKeys) classList.push(hash);
36
+ return classList.join(" ");
37
+ }
38
+ const css = class _css {
39
+ static create(_rule) {
40
+ throw errorFn("create");
29
41
  }
30
- static createTheme(rule) {
31
- return createTheme(rule);
42
+ static props = props;
43
+ static createTheme(_rule) {
44
+ throw errorFn("createTheme");
32
45
  }
33
- static createStatic(rule) {
34
- return createStatic(rule);
46
+ static createStatic(_rule) {
47
+ throw errorFn("createStatic");
35
48
  }
36
- static keyframes(rule) {
37
- return keyframes(rule);
49
+ static keyframes(_rule) {
50
+ throw errorFn("keyframes");
38
51
  }
39
- static viewTransition(rule) {
40
- return viewTransition(rule);
52
+ static viewTransition(_rule) {
53
+ throw errorFn("viewTransition");
41
54
  }
42
55
  };
43
56
  const x = (className, styles) => ({
44
57
  className,
45
58
  styles
46
59
  });
47
- const css = _css;
48
60
 
49
61
  exports.css = css;
50
62
  exports.x = x;
package/dist/css.mjs CHANGED
@@ -1,49 +1,61 @@
1
1
 
2
2
  function errorFn(fn) {
3
- throw new Error("Using the \"css." + fn + "\" is runtime not supported. Make sure you have setup bundler-plugin correctly.");
4
- }
5
- function create(_rule) {
6
- throw errorFn("create");
3
+ throw new Error(`css.${fn} requires bundler-plugin setup`);
7
4
  }
8
5
  function props(...rules) {
9
- return rules.filter(Boolean).join(" ");
10
- }
11
- function createStatic(_rule) {
12
- throw errorFn("createStatic");
13
- }
14
- function createTheme(_rule) {
15
- throw errorFn("createTheme");
16
- }
17
- function keyframes(_rule) {
18
- throw errorFn("keyframes");
19
- }
20
- function viewTransition(_rule) {
21
- throw errorFn("viewTransition");
22
- }
23
- var _css = class {
24
- static create(rule) {
25
- return create(rule);
6
+ const chosen = new Map();
7
+ const classList = [];
8
+ const orderedKeys = [];
9
+ const rightmostKeys = [];
10
+ for (let i = rules.length - 1; i >= 0; i--) {
11
+ const arg = rules[i];
12
+ if (!arg || typeof arg === "string") continue;
13
+ for (const [key, hash] of Object.entries(arg)) if (!chosen.has(key)) chosen.set(key, {
14
+ hash,
15
+ propsIdx: i
16
+ });
26
17
  }
27
- static props(...rules) {
28
- return props(...rules);
18
+ for (let i = 0; i < rules.length; i++) {
19
+ const arg = rules[i];
20
+ if (!arg) continue;
21
+ if (typeof arg === "string") {
22
+ classList.push(arg);
23
+ continue;
24
+ }
25
+ for (const [key] of Object.entries(arg)) {
26
+ const info = chosen.get(key);
27
+ if (info && info.propsIdx === i) {
28
+ if (i === rules.length - 1) rightmostKeys.push(info);
29
+ else orderedKeys.push(info);
30
+ chosen.delete(key);
31
+ }
32
+ }
33
+ }
34
+ for (const { hash } of orderedKeys) classList.push(hash);
35
+ for (const { hash } of rightmostKeys) classList.push(hash);
36
+ return classList.join(" ");
37
+ }
38
+ const css = class _css {
39
+ static create(_rule) {
40
+ throw errorFn("create");
29
41
  }
30
- static createTheme(rule) {
31
- return createTheme(rule);
42
+ static props = props;
43
+ static createTheme(_rule) {
44
+ throw errorFn("createTheme");
32
45
  }
33
- static createStatic(rule) {
34
- return createStatic(rule);
46
+ static createStatic(_rule) {
47
+ throw errorFn("createStatic");
35
48
  }
36
- static keyframes(rule) {
37
- return keyframes(rule);
49
+ static keyframes(_rule) {
50
+ throw errorFn("keyframes");
38
51
  }
39
- static viewTransition(rule) {
40
- return viewTransition(rule);
52
+ static viewTransition(_rule) {
53
+ throw errorFn("viewTransition");
41
54
  }
42
55
  };
43
56
  const x = (className, styles) => ({
44
57
  className,
45
58
  styles
46
59
  });
47
- const css = _css;
48
60
 
49
61
  export { css, x };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "An atomic CSS runtime designed to disappear.",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",