@navita/engine 0.0.8 → 0.0.10

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/index.d.ts CHANGED
@@ -11,6 +11,7 @@ type UsedIdCache = {
11
11
  [key in CacheKeys]?: (string | number)[];
12
12
  };
13
13
  type Options = {
14
+ context?: string;
14
15
  enableSourceMaps?: boolean;
15
16
  enableDebugIdentifiers?: boolean;
16
17
  };
package/index.js CHANGED
@@ -154,7 +154,8 @@ function printSourceMap(sourceMapReferences, content) {
154
154
  return content;
155
155
  }
156
156
  const sourceMap$1 = new sourceMap.SourceMapGenerator({
157
- file: "navita.css"
157
+ file: "navita.css",
158
+ skipValidation: true
158
159
  });
159
160
  const references = entries.flatMap(([filePath, references])=>references.map((reference)=>({
160
161
  filePath,
@@ -646,6 +647,10 @@ function processStyles({ cache , type }) {
646
647
  if (typeof value === "string") {
647
648
  newValue = value.trim().replace(/;[\n\s]*$/, "");
648
649
  }
650
+ // Check if value starts with --, if so, wrap in var()
651
+ if (typeof newValue === "string" && newValue.startsWith("--")) {
652
+ newValue = `var(${value})`;
653
+ }
649
654
  if (typeof value === "number") {
650
655
  newValue = pixelifyProperties(newProperty, value);
651
656
  }
@@ -752,10 +757,11 @@ class Engine {
752
757
  const { name } = path.parse(filePath);
753
758
  const extraClass = this.options.enableDebugIdentifiers ? `${name}_${identifier}` : '';
754
759
  const selector = '.' + classList.toString().split(' ').concat(extraClass).filter(Boolean).join('.');
755
- if (index === 0 || !this.sourceMapReferences[filePath]) {
756
- this.sourceMapReferences[filePath] = [];
760
+ const newFilePath = path.relative(this.options.context || process.cwd(), filePath);
761
+ if (index === 0 || !this.sourceMapReferences[newFilePath]) {
762
+ this.sourceMapReferences[newFilePath] = [];
757
763
  }
758
- this.sourceMapReferences[filePath][index] = {
764
+ this.sourceMapReferences[newFilePath][index] = {
759
765
  selector,
760
766
  line,
761
767
  column
package/index.mjs CHANGED
@@ -152,7 +152,8 @@ function printSourceMap(sourceMapReferences, content) {
152
152
  return content;
153
153
  }
154
154
  const sourceMap = new SourceMapGenerator({
155
- file: "navita.css"
155
+ file: "navita.css",
156
+ skipValidation: true
156
157
  });
157
158
  const references = entries.flatMap(([filePath, references])=>references.map((reference)=>({
158
159
  filePath,
@@ -644,6 +645,10 @@ function processStyles({ cache , type }) {
644
645
  if (typeof value === "string") {
645
646
  newValue = value.trim().replace(/;[\n\s]*$/, "");
646
647
  }
648
+ // Check if value starts with --, if so, wrap in var()
649
+ if (typeof newValue === "string" && newValue.startsWith("--")) {
650
+ newValue = `var(${value})`;
651
+ }
647
652
  if (typeof value === "number") {
648
653
  newValue = pixelifyProperties(newProperty, value);
649
654
  }
@@ -750,10 +755,11 @@ class Engine {
750
755
  const { name } = path.parse(filePath);
751
756
  const extraClass = this.options.enableDebugIdentifiers ? `${name}_${identifier}` : '';
752
757
  const selector = '.' + classList.toString().split(' ').concat(extraClass).filter(Boolean).join('.');
753
- if (index === 0 || !this.sourceMapReferences[filePath]) {
754
- this.sourceMapReferences[filePath] = [];
758
+ const newFilePath = path.relative(this.options.context || process.cwd(), filePath);
759
+ if (index === 0 || !this.sourceMapReferences[newFilePath]) {
760
+ this.sourceMapReferences[newFilePath] = [];
755
761
  }
756
- this.sourceMapReferences[filePath][index] = {
762
+ this.sourceMapReferences[newFilePath][index] = {
757
763
  selector,
758
764
  line,
759
765
  column
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navita/engine",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Navitas CSS-in-JS engine",
5
5
  "keywords": [
6
6
  "css-in-js",