@plumeria/core 0.24.2 → 0.24.4

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/index.d.ts CHANGED
@@ -9,11 +9,41 @@ declare const rx: (className: string, varSet: RxVariableSet) => {
9
9
 
10
10
  declare class StyleSheet {
11
11
  private constructor();
12
+ /**
13
+ * Returns an object whose values can be used with `css.props`.
14
+ * @param object A style object containing CSS properties.
15
+ * @see https://plumeria.dev/docs/api-reference/create
16
+ */
12
17
  static create<const T extends Record<string, CSSProperties>>(object: CreateStyleType<T>): ReturnType<T>;
18
+ /**
19
+ * Returns unique hashes based on properties.
20
+ * @param objects Style objects containing CSS properties.
21
+ * @see https://plumeria.dev/docs/api-reference/props
22
+ */
13
23
  static props(...objects: (false | Readonly<CSSProperties> | null | undefined)[]): string;
24
+ /**
25
+ * Returns a unique hash identifier that can be used in keyframes animation.
26
+ * @param object A style object containing keyframes properties.
27
+ * @see https://plumeria.dev/docs/api-reference/keyframes
28
+ */
14
29
  static keyframes(object: CreateKeyframes): string;
30
+ /**
31
+ * Returns the unique name for the viewTransition.
32
+ * @param object A style object containing viewTransition properties.
33
+ * @see https://plumeria.dev/docs/api-reference/viewTransition
34
+ */
15
35
  static viewTransition(object: ViewTransitionOptions): string;
36
+ /**
37
+ * Returns the same object, with its type narrowed for better autocompletion.
38
+ * @param object A map of keys to constant string or number values.
39
+ * @see https://plumeria.dev/docs/api-reference/defineConsts
40
+ */
16
41
  static defineConsts<const T extends CreateValues>(object: T): T;
42
+ /**
43
+ * Returns an object containing CSS variable names and the original token values.
44
+ * @param object A nested object defining design tokens.
45
+ * @see https://plumeria.dev/docs/api-reference/defineTokens
46
+ */
17
47
  static defineTokens<const T extends CreateTokens>(object: T): ReturnVariableType<T>;
18
48
  }
19
49
  declare const css: typeof StyleSheet;
package/dist/index.js CHANGED
@@ -8,38 +8,7 @@ function create(object) {
8
8
  const flat = {};
9
9
  const nonFlat = {};
10
10
  (0, zss_engine.splitAtomicAndNested)(styleObj, flat, nonFlat);
11
- const overrideLonghand = (style) => {
12
- const props$1 = Object.keys(style);
13
- const propsToRemove = new Set();
14
- const plainProps = [];
15
- for (let i = 0; i < props$1.length; i++) if (!props$1[i].startsWith("@")) plainProps.push({
16
- key: props$1[i],
17
- index: i
18
- });
19
- const shorthandsInStyle = {};
20
- for (const { key: key$1, index } of plainProps) {
21
- const kebab = (0, zss_engine.camelToKebabCase)(key$1);
22
- if (zss_engine.SHORTHAND_PROPERTIES[kebab]) shorthandsInStyle[kebab] = index;
23
- }
24
- for (const { key: key$1, index } of plainProps) {
25
- const kebab = (0, zss_engine.camelToKebabCase)(key$1);
26
- if (!zss_engine.SHORTHAND_PROPERTIES[kebab]) {
27
- const longhands = zss_engine.LONG_TO_SHORT[kebab] || [];
28
- for (const shorthand of longhands) if (shorthandsInStyle[shorthand] > index) {
29
- propsToRemove.add(key$1);
30
- break;
31
- }
32
- }
33
- }
34
- const finalStyle = {};
35
- for (const prop of props$1) {
36
- if (propsToRemove.has(prop)) continue;
37
- if (prop.startsWith("@")) finalStyle[prop] = overrideLonghand(style[prop]);
38
- else finalStyle[prop] = style[prop];
39
- }
40
- return finalStyle;
41
- };
42
- const finalFlat = overrideLonghand(flat);
11
+ const finalFlat = (0, zss_engine.overrideLonghand)(flat);
43
12
  const records = [];
44
13
  Object.entries(finalFlat).forEach(([prop, value]) => {
45
14
  const hashes = new Set();
@@ -74,14 +43,10 @@ function create(object) {
74
43
  });
75
44
  });
76
45
  if (Object.keys(nonFlat).length > 0) {
77
- const finalNonFlat = {};
78
- Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
79
- finalNonFlat[atRule] = overrideLonghand(nestedObj);
80
- });
81
- const nonFlatObj = { [key]: finalNonFlat };
46
+ const nonFlatObj = { [key]: nonFlat };
82
47
  const nonFlatHash = (0, zss_engine.genBase36Hash)(nonFlatObj, 1, 7);
83
48
  const { styleSheet } = (0, zss_engine.transpile)(nonFlatObj, nonFlatHash);
84
- Object.entries(finalNonFlat).forEach(([atRule, nestedObj]) => {
49
+ Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
85
50
  Object.keys(nestedObj).forEach((prop) => {
86
51
  records.push({
87
52
  key: atRule + prop,
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { globalPromise_1, globalPromise_2, initPromise_1, initPromise_2, resolvePromise_1, resolvePromise_2 } from "./css.mjs";
2
- import { LONG_TO_SHORT, SHORTHAND_PROPERTIES, camelToKebabCase, genBase36Hash, injectClientCSS, injectClientGlobalCSS, injectClientQuery, isHashInStyleSheets, isServer, isTestingDevelopment, processAtomicProps, splitAtomicAndNested, transpile } from "zss-engine";
2
+ import { camelToKebabCase, genBase36Hash, injectClientCSS, injectClientGlobalCSS, injectClientQuery, isHashInStyleSheets, isServer, isTestingDevelopment, overrideLonghand, processAtomicProps, splitAtomicAndNested, transpile } from "zss-engine";
3
3
 
4
4
  const styleAtomMap = new WeakMap();
5
5
  function create(object) {
@@ -8,37 +8,6 @@ function create(object) {
8
8
  const flat = {};
9
9
  const nonFlat = {};
10
10
  splitAtomicAndNested(styleObj, flat, nonFlat);
11
- const overrideLonghand = (style) => {
12
- const props$1 = Object.keys(style);
13
- const propsToRemove = new Set();
14
- const plainProps = [];
15
- for (let i = 0; i < props$1.length; i++) if (!props$1[i].startsWith("@")) plainProps.push({
16
- key: props$1[i],
17
- index: i
18
- });
19
- const shorthandsInStyle = {};
20
- for (const { key: key$1, index } of plainProps) {
21
- const kebab = camelToKebabCase(key$1);
22
- if (SHORTHAND_PROPERTIES[kebab]) shorthandsInStyle[kebab] = index;
23
- }
24
- for (const { key: key$1, index } of plainProps) {
25
- const kebab = camelToKebabCase(key$1);
26
- if (!SHORTHAND_PROPERTIES[kebab]) {
27
- const longhands = LONG_TO_SHORT[kebab] || [];
28
- for (const shorthand of longhands) if (shorthandsInStyle[shorthand] > index) {
29
- propsToRemove.add(key$1);
30
- break;
31
- }
32
- }
33
- }
34
- const finalStyle = {};
35
- for (const prop of props$1) {
36
- if (propsToRemove.has(prop)) continue;
37
- if (prop.startsWith("@")) finalStyle[prop] = overrideLonghand(style[prop]);
38
- else finalStyle[prop] = style[prop];
39
- }
40
- return finalStyle;
41
- };
42
11
  const finalFlat = overrideLonghand(flat);
43
12
  const records = [];
44
13
  Object.entries(finalFlat).forEach(([prop, value]) => {
@@ -74,14 +43,10 @@ function create(object) {
74
43
  });
75
44
  });
76
45
  if (Object.keys(nonFlat).length > 0) {
77
- const finalNonFlat = {};
78
- Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
79
- finalNonFlat[atRule] = overrideLonghand(nestedObj);
80
- });
81
- const nonFlatObj = { [key]: finalNonFlat };
46
+ const nonFlatObj = { [key]: nonFlat };
82
47
  const nonFlatHash = genBase36Hash(nonFlatObj, 1, 7);
83
48
  const { styleSheet } = transpile(nonFlatObj, nonFlatHash);
84
- Object.entries(finalNonFlat).forEach(([atRule, nestedObj]) => {
49
+ Object.entries(nonFlat).forEach(([atRule, nestedObj]) => {
85
50
  Object.keys(nestedObj).forEach((prop) => {
86
51
  records.push({
87
52
  key: atRule + prop,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/core",
3
- "version": "0.24.2",
3
+ "version": "0.24.4",
4
4
  "description": "The atomic on-demand CSS-in-JS.",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",
@@ -45,12 +45,12 @@
45
45
  "stylesheet.css"
46
46
  ],
47
47
  "dependencies": {
48
- "zss-engine": "0.2.94"
48
+ "zss-engine": "0.2.96"
49
49
  },
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
53
  "scripts": {
54
- "build": "tsdown && node strip-comments"
54
+ "build": "tsdown && node strip-comments.ts && node tsdocs.ts"
55
55
  }
56
56
  }