@salty-css/core 0.1.0-alpha.0 → 0.1.0-alpha.2

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.
@@ -16,7 +16,8 @@ const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
16
16
  return value;
17
17
  };
18
18
  const saltyFileExtensions = ["salty", "css", "styles", "styled"];
19
- const saltyFileRegExp = (additional = []) => new RegExp(`\\.(${[...saltyFileExtensions, ...additional].join("|")})\\.`);
19
+ const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
20
+ const saltyFileRegExp = (additional = []) => new RegExp(`\\.(${[...saltyFileExtensions, ...additional].map(escapeRegExp).join("|")})\\.`);
20
21
  const isSaltyFile = (file, additional = []) => saltyFileRegExp(additional).test(file);
21
22
  exports.getCorePackageRoot = getCorePackageRoot;
22
23
  exports.isSaltyFile = isSaltyFile;
@@ -13,7 +13,8 @@ const resolveExportValue = async (value, maxLevel = 10, _level = 0) => {
13
13
  return value;
14
14
  };
15
15
  const saltyFileExtensions = ["salty", "css", "styles", "styled"];
16
- const saltyFileRegExp = (additional = []) => new RegExp(`\\.(${[...saltyFileExtensions, ...additional].join("|")})\\.`);
16
+ const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17
+ const saltyFileRegExp = (additional = []) => new RegExp(`\\.(${[...saltyFileExtensions, ...additional].map(escapeRegExp).join("|")})\\.`);
17
18
  const isSaltyFile = (file, additional = []) => saltyFileRegExp(additional).test(file);
18
19
  export {
19
20
  getCorePackageRoot,
package/css/keyframes.cjs CHANGED
@@ -26,7 +26,7 @@ const keyframes = ({ animationName: _name, params: _params, appendInitialStyles,
26
26
  const promises = entries.map(async ([key, value]) => {
27
27
  if (!value) return "";
28
28
  const styles = await parseStyles.parseAndJoinStyles(value, "");
29
- const keyStr = typeof key === "number" ? `${key}%` : key;
29
+ const keyStr = /^-?\d+$/.test(key) ? `${key}%` : key;
30
30
  return `${keyStr}{${styles}}`;
31
31
  });
32
32
  const resolved = await Promise.all(promises);
package/css/keyframes.js CHANGED
@@ -24,7 +24,7 @@ const keyframes = ({ animationName: _name, params: _params, appendInitialStyles,
24
24
  const promises = entries.map(async ([key, value]) => {
25
25
  if (!value) return "";
26
26
  const styles = await parseAndJoinStyles(value, "");
27
- const keyStr = typeof key === "number" ? `${key}%` : key;
27
+ const keyStr = /^-?\d+$/.test(key) ? `${key}%` : key;
28
28
  return `${keyStr}{${styles}}`;
29
29
  });
30
30
  const resolved = await Promise.all(promises);
package/css/merge.cjs CHANGED
@@ -2,7 +2,12 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const mergeObjects = (...styles) => {
4
4
  return styles.flat().reduce((acc, style) => {
5
- if (style == null ? void 0 : style._current) return { ...acc, ...style._current };
5
+ if (!style || typeof style !== "object") return acc;
6
+ if ("_current" in style) {
7
+ let _style = style._current || {};
8
+ if (typeof _style !== "object") _style = {};
9
+ return { ...acc, ..._style };
10
+ }
6
11
  return { ...acc, ...style };
7
12
  }, {});
8
13
  };
package/css/merge.js CHANGED
@@ -1,6 +1,11 @@
1
1
  const mergeObjects = (...styles) => {
2
2
  return styles.flat().reduce((acc, style) => {
3
- if (style == null ? void 0 : style._current) return { ...acc, ...style._current };
3
+ if (!style || typeof style !== "object") return acc;
4
+ if ("_current" in style) {
5
+ let _style = style._current || {};
6
+ if (typeof _style !== "object") _style = {};
7
+ return { ...acc, ..._style };
8
+ }
4
9
  return { ...acc, ...style };
5
10
  }, {});
6
11
  };
@@ -11,7 +11,7 @@ class StyledGenerator extends classNameGenerator.StylesGenerator {
11
11
  get priority() {
12
12
  var _a;
13
13
  if (this.params.priority) return this.params.priority;
14
- if (typeof this.tagName === "function" || typeof this.tagName === "object") {
14
+ if (this.tagName && (typeof this.tagName === "function" || typeof this.tagName === "object")) {
15
15
  const prev = ((_a = this.tagName.generator) == null ? void 0 : _a.priority) || 0;
16
16
  return prev + 1;
17
17
  }
@@ -10,7 +10,7 @@ class StyledGenerator extends StylesGenerator {
10
10
  get priority() {
11
11
  var _a;
12
12
  if (this.params.priority) return this.params.priority;
13
- if (typeof this.tagName === "function" || typeof this.tagName === "object") {
13
+ if (this.tagName && (typeof this.tagName === "function" || typeof this.tagName === "object")) {
14
14
  const prev = ((_a = this.tagName.generator) == null ? void 0 : _a.priority) || 0;
15
15
  return prev + 1;
16
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",