node-sass-json-functions 4.0.2 → 5.0.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/CHANGELOG.md CHANGED
@@ -2,62 +2,77 @@
2
2
 
3
3
  ## [Unreleased][]
4
4
 
5
+ ## [5.0.0][] - 2026-02-10
6
+
7
+ ### Changed
8
+
9
+ - **Breaking**: This module is now ESM only and requires Node >=18
10
+ - Update color API usage ([#10](https://github.com/niksy/node-sass-json-functions/issues/10))
11
+
12
+ ### Added
13
+
14
+ - **Breaking**: Support for passing Sass implementation (`sass` or `sass-embedded`)
15
+
16
+ ## [4.1.0][] - 2023-09-20
17
+
18
+ ### Changed
19
+
20
+ - Parse calc values to true values instead of null
21
+ ([#7](https://github.com/niksy/node-sass-json-functions/issues/7))
22
+
5
23
  ## [4.0.2][] - 2023-08-16
6
24
 
7
25
  ### Fixed
8
26
 
9
- - Quoted strings for map keys
10
- ([#9](https://github.com/niksy/node-sass-json-functions/issues/9))
27
+ - Quoted strings for map keys ([#9](https://github.com/niksy/node-sass-json-functions/issues/9))
11
28
 
12
29
  ## [4.0.1][] - 2023-06-13
13
30
 
14
31
  ### Fixed
15
32
 
16
- - ES module import implementation
33
+ - ES module import implementation
17
34
 
18
35
  ## [4.0.0][] - 2023-05-01
19
36
 
20
37
  ### Changed
21
38
 
22
- - Use [new Sass API](https://sass-lang.com/documentation/js-api)
39
+ - Use [new Sass API](https://sass-lang.com/documentation/js-api)
23
40
 
24
41
  ### Removed
25
42
 
26
- - **Node 10 support, lowest version is 12.22**
27
- - **Legacy Sass support, lowest version is 1.45**
28
- - Precision option; Dart Sass defaults to a sufficiently high precision for
29
- all existing browsers
43
+ - **Node 10 support, lowest version is 12.22**
44
+ - **Legacy Sass support, lowest version is 1.45**
45
+ - Precision option; Dart Sass defaults to a sufficiently high precision for all existing browsers
30
46
 
31
47
  ## [3.3.0][] - 2022-01-11
32
48
 
33
49
  ### Added
34
50
 
35
- - Precision option
36
- ([#6](https://github.com/niksy/node-sass-json-functions/issues/6))
51
+ - Precision option ([#6](https://github.com/niksy/node-sass-json-functions/issues/6))
37
52
 
38
53
  ## [3.2.0][] - 2021-11-10
39
54
 
40
55
  ### Added
41
56
 
42
- - TypeScript typings
57
+ - TypeScript typings
43
58
 
44
59
  ## [3.1.0][] - 2021-01-14
45
60
 
46
61
  ### Removed
47
62
 
48
- - Lodash as dependancy
63
+ - Lodash as dependancy
49
64
 
50
65
  ## [3.0.0][] - 2021-01-14
51
66
 
52
67
  ### Changed
53
68
 
54
- - Switch to Dart Sass
55
- - Upgrade package
69
+ - Switch to Dart Sass
70
+ - Upgrade package
56
71
 
57
72
  ### Removed
58
73
 
59
- - **Node 4 support, lowest version is 10**
60
- - Precision option
74
+ - **Node 4 support, lowest version is 10**
75
+ - Precision option
61
76
 
62
77
  <!-- prettier-ignore-start -->
63
78
 
@@ -67,6 +82,10 @@
67
82
  [3.3.0]: https://github.com/niksy/node-sass-json-functions/tree/v3.3.0
68
83
  [4.0.1]: https://github.com/niksy/node-sass-json-functions/tree/v4.0.1
69
84
  [4.0.0]: https://github.com/niksy/node-sass-json-functions/tree/v4.0.0
70
- [Unreleased]:
71
- https://github.com/niksy/node-sass-json-functions/compare/v4.0.2...HEAD
85
+ [Unreleased]: https://github.com/niksy/node-sass-json-functions/compare/v5.0.0...HEAD
86
+ [5.0.0]: https://github.com/niksy/node-sass-json-functions/compare/v4.1.0...v5.0.0
87
+ [4.1.0]: https://github.com/niksy/node-sass-json-functions/tree/v4.1.0
88
+
89
+ https://github.com/niksy/node-sass-json-functions/compare/v4.0.2...HEAD
90
+
72
91
  [4.0.2]: https://github.com/niksy/node-sass-json-functions/tree/v4.0.2
package/README.md CHANGED
@@ -2,36 +2,42 @@
2
2
 
3
3
  [![Build Status][ci-img]][ci]
4
4
 
5
- JSON encode and decode functions for [sass][sass].
5
+ JSON encode and decode functions for [`sass` and `sass-embedded`][sass].
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```sh
10
- npm install sass node-sass-json-functions --save
10
+ npm install node-sass-json-functions --save
11
11
  ```
12
12
 
13
+ `sass` and `sass-embedded` are optional peer dependencies so you need to install either of them
14
+ separately.
15
+
13
16
  ## Usage
14
17
 
15
18
  ```js
16
- import * as sass from 'sass';
17
- import jsonFns from 'node-sass-json-functions';
19
+ import * as sass from 'sass'; // or `sass-embedded`
20
+ import createJsonFunctions from 'node-sass-json-functions';
18
21
 
19
22
  (async () => {
20
23
  const result = await sass.compileAsync('./index.scss', {
21
- functions: { ...jsonFns }
24
+ functions: { ...createJsonFunctions(sass) }
22
25
  });
23
26
  // ...
24
27
  })();
25
28
  ```
26
29
 
27
- Module exports object with prepared functions `json-encode` and `json-decode`.
30
+ Module exports a factory function. Pass Sass or Sass Embedded binary reference to get an object with
31
+ prepared functions `json-encode` and `json-decode`.
28
32
 
29
33
  ### Encode
30
34
 
31
35
  Input:
32
36
 
33
37
  ```scss
34
- $list: 1, 2, '3', (4, 5, 6), (
38
+ $list:
39
+ 1, 2, '3', (4, 5, 6),
40
+ (
35
41
  foo: 'bar baz'
36
42
  );
37
43
  $map: (
@@ -55,7 +61,10 @@ $map: (
55
61
  bag: 'foo bar'
56
62
  ),
57
63
  qux: rgba(255, 255, 255, 0.5),
58
- corgle: red
64
+ corgle: red,
65
+ george: calc(42px + 42%),
66
+ lexi: calc(42px / 2),
67
+ oliver: calc(42px + 10px + 10px)
59
68
  );
60
69
 
61
70
  body {
@@ -73,7 +82,7 @@ body {
73
82
  content: '[1,2,"3",[4,5,6],{"foo":"bar baz"}]';
74
83
  content: '{"foo":1,"bar":[2,3],"baz":"3 3 3","bad":{"foo":11,"bar":22,"baz":[5,4,6,null,1,"1.23457px"],"bag":"foo bar"},"qux":"rgba(255,255,255,0.5)","corgle":"#f00"}';
75
84
  content: [1,2,"3",[4,5,6],{"foo":"bar baz"}];
76
- content: {"foo":1,"bar":[2,3],"baz":"3 3 3","bad":{"foo":11,"bar":22,"baz":[5,4,6,null,1,"1.23457px"],"bag":"foo bar"},"qux":"rgba(255,255,255,0.5)","corgle":"#f00"};
85
+ content: {"foo":1,"bar":[2,3],"baz":"3 3 3","bad":{"foo":11,"bar":22,"baz":[5,4,6,null,1,"1.23457px"],"bag":"foo bar"},"qux":"rgba(255,255,255,0.5)","corgle":"#f00","george":"calc(42px + 42%)","lexi":"21px","oliver":"62px"};
77
86
  }
78
87
  ```
79
88
 
@@ -83,7 +92,7 @@ Input:
83
92
 
84
93
  ```scss
85
94
  $array: '[1,2,"3",[4,5,6],{"foo":"bar baz"}]';
86
- $object: '{"foo":1,"bar":[2,3],"baz":"3 3 3","bad":{"foo":11,"bar":22,"baz":[5,4,6,null,1,"1.23456789px"],"bag":"foo bar"},"qux":"rgba(255,255,255,0.5)","corgle":"#f00"}';
95
+ $object: '{"foo":1,"bar":[2,3],"baz":"3 3 3","bad":{"foo":11,"bar":22,"baz":[5,4,6,null,1,"1.23456789px"],"bag":"foo bar"},"qux":"rgba(255,255,255,0.5)","corgle":"#f00","george":"calc(42px + 42%)","lexi":"21px","oliver":"calc(42px + 10px + 10px)"}';
87
96
 
88
97
  @debug json-decode($array);
89
98
  @debug json-decode($object);
@@ -93,7 +102,7 @@ Output:
93
102
 
94
103
  ```sh
95
104
  DEBUG: 1, 2, 3, 4, 5, 6, (foo: bar baz)
96
- DEBUG: (foo: 1, bar: 2, 3, baz: 3 3 3, bad: (foo: 11, bar: 22, baz: 5, 4, 6, null, 1, 1.23456789px, bag: foo bar), qux: rgba(255, 255, 255, 0.5), corgle: red)
105
+ DEBUG: (foo: 1, bar: 2, 3, baz: 3 3 3, bad: (foo: 11, bar: 22, baz: 5, 4, 6, null, 1, 1.23456789px, bag: foo bar), qux: rgba(255, 255, 255, 0.5), corgle: red, george: calc(42px + 42%), lexi: 21px, oliver: "calc(42px + 10px + 10px)")
97
106
  ```
98
107
 
99
108
  ## API
@@ -102,20 +111,19 @@ DEBUG: (foo: 1, bar: 2, 3, baz: 3 3 3, bad: (foo: 11, bar: 22, baz: 5, 4, 6, nul
102
111
 
103
112
  Returns: `sass.SassString`
104
113
 
105
- Encodes (`JSON.stringify`) data and returns [Sass string][sass-string]. By
106
- default, string is quoted with single quotes so that it can be easily used in
107
- standard CSS values.
108
-
109
- - [Sass lists][sass-list] are transformed to arrays
110
- - [Sass maps][sass-map] are transformed to objects
111
- - [Sass colors][sass-color] are transformed to `rgba()` syntax if they have
112
- alpha value, otherwise they are transformed to hex value (and it’s shorther
113
- version if possible)
114
- - [Sass strings][sass-string] are transformed to strings
115
- - [Sass numbers][sass-number] are transformed to numbers
116
- - [Sass booleans][sass-boolean] are transformed to booleans
117
- - [Sass null][sass-null] values and anything unresolved is transformed to null
118
- values
114
+ Encodes (`JSON.stringify`) data and returns [Sass string][sass-string]. By default, string is quoted
115
+ with single quotes so that it can be easily used in standard CSS values.
116
+
117
+ - [Sass lists][sass-list] are transformed to arrays
118
+ - [Sass maps][sass-map] are transformed to objects
119
+ - [Sass colors][sass-color] are transformed to `rgba()` syntax if they have alpha value, otherwise
120
+ they are transformed to hex value (and it’s shorther version if possible)
121
+ - [Sass calculations][sass-calculation] are transformed to values corresponding to calculation
122
+ result (string or number)
123
+ - [Sass strings][sass-string] are transformed to strings
124
+ - [Sass numbers][sass-number] are transformed to numbers
125
+ - [Sass booleans][sass-boolean] are transformed to booleans
126
+ - [Sass null][sass-null] values and anything unresolved is transformed to null values
119
127
 
120
128
  #### data
121
129
 
@@ -134,20 +142,20 @@ Should output string be quoted with single quotes.
134
142
 
135
143
  Returns: `sass.Value`
136
144
 
137
- Decodes (`JSON.parse`) string and returns one of [available Sass
138
- types][sass-types].
139
-
140
- - Arrays are transformed to [Sass lists][sass-list]
141
- - Objects are transformed to [Sass maps][sass-map]
142
- - Anything properly parsed with [parse-color][parse-color] is transformed to
143
- [Sass color][sass-color]
144
- - Strings are transformed to Sass numbers with units if they can be properly
145
- parsed with [parse-css-dimension][parse-css-dimension], otherwise they are
146
- transformed to [Sass strings][sass-string]
147
- - Numbers are transformed to [Sass numbers][sass-number]
148
- - Booleans are transformed to [Sass booleans][sass-boolean]
149
- - Null values and anything unresolved is transformed to [Sass null][sass-null]
150
- values
145
+ Decodes (`JSON.parse`) string and returns one of [available Sass types][sass-types].
146
+
147
+ - Arrays are transformed to [Sass lists][sass-list]
148
+ - Objects are transformed to [Sass maps][sass-map]
149
+ - Anything properly parsed with [parse-color][parse-color] is transformed to [Sass
150
+ color][sass-color]
151
+ - Calculations (`calc()` values) are transformed to [Sass calculations][sass-calculation] for simple
152
+ operations and to [Sass strings][sass-string] for everything else
153
+ - Strings are transformed to Sass numbers with units if they can be properly parsed with
154
+ [parse-css-dimension][parse-css-dimension], otherwise they are transformed to [Sass
155
+ strings][sass-string]
156
+ - Numbers are transformed to [Sass numbers][sass-number]
157
+ - Booleans are transformed to [Sass booleans][sass-boolean]
158
+ - Null values and anything unresolved is transformed to [Sass null][sass-null] values
151
159
 
152
160
  #### string
153
161
 
@@ -162,7 +170,7 @@ MIT © [Ivan Nikolić](http://ivannikolic.com)
162
170
  <!-- prettier-ignore-start -->
163
171
 
164
172
  [ci]: https://github.com/niksy/node-sass-json-functions/actions?query=workflow%3ACI
165
- [ci-img]: https://github.com/niksy/node-sass-json-functions/workflows/CI/badge.svg?branch=master
173
+ [ci-img]: https://github.com/niksy/node-sass-json-functions/actions/workflows/ci.yml/badge.svg?branch=master
166
174
  [sass]: https://github.com/sass/dart-sass
167
175
  [sass-types]: https://sass-lang.com/documentation/js-api/classes/Value
168
176
  [sass-list]: https://sass-lang.com/documentation/values/lists
@@ -172,6 +180,7 @@ MIT © [Ivan Nikolić](http://ivannikolic.com)
172
180
  [sass-string]: https://sass-lang.com/documentation/values/strings
173
181
  [sass-null]: https://sass-lang.com/documentation/values/null
174
182
  [sass-boolean]: https://sass-lang.com/documentation/values/booleans
183
+ [sass-calculation]: https://sass-lang.com/documentation/values/calculations
175
184
  [parse-color]: https://github.com/substack/parse-color
176
185
  [parse-css-dimension]: https://github.com/jedmao/parse-css-dimension
177
186
 
@@ -0,0 +1,60 @@
1
+ import * as sass0 from "sass";
2
+ import SassPackage from "sass";
3
+ import * as sass_embedded0 from "sass-embedded";
4
+ import SassEmbeddedPackage from "sass-embedded";
5
+
6
+ //#region lib/types.d.ts
7
+ type SassPackageType = typeof sass0;
8
+ type SassEmbeddedPackageType = typeof sass_embedded0;
9
+ type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
10
+ declare namespace Sass {
11
+ type Exception = IsAny<SassEmbeddedPackage.Exception> extends false ? SassEmbeddedPackage.Exception : SassPackage.Exception;
12
+ type Logger = IsAny<SassEmbeddedPackage.Logger> extends false ? SassEmbeddedPackage.Logger : SassPackage.Logger;
13
+ type LoggerWarnOptions = IsAny<SassEmbeddedPackage.LoggerWarnOptions> extends false ? SassEmbeddedPackage.LoggerWarnOptions : SassPackage.LoggerWarnOptions;
14
+ type CompileResult = IsAny<SassEmbeddedPackage.CompileResult> extends false ? SassEmbeddedPackage.CompileResult : SassPackage.CompileResult;
15
+ type Options<T extends 'sync' | 'async'> = IsAny<SassEmbeddedPackage.Options<T>> extends false ? SassEmbeddedPackage.Options<T> : SassPackage.Options<T>;
16
+ type StringOptions<T extends 'sync' | 'async'> = IsAny<SassEmbeddedPackage.StringOptions<T>> extends false ? SassEmbeddedPackage.StringOptions<T> : SassPackage.StringOptions<T>;
17
+ type Value = IsAny<SassEmbeddedPackage.Value> extends false ? SassEmbeddedPackage.Value : SassPackage.Value;
18
+ type SassString = IsAny<SassEmbeddedPackage.SassString> extends false ? SassEmbeddedPackage.SassString : SassPackage.SassString;
19
+ type SassList = IsAny<SassEmbeddedPackage.SassList> extends false ? SassEmbeddedPackage.SassList : SassPackage.SassList;
20
+ type SassMap = IsAny<SassEmbeddedPackage.SassMap> extends false ? SassEmbeddedPackage.SassMap : SassPackage.SassMap;
21
+ type CalculationOperator = IsAny<SassEmbeddedPackage.CalculationOperator> extends false ? SassEmbeddedPackage.CalculationOperator : SassPackage.CalculationOperator;
22
+ type CalculationValue = IsAny<SassEmbeddedPackage.CalculationValue> extends false ? SassEmbeddedPackage.CalculationValue : SassPackage.CalculationValue;
23
+ }
24
+ type SassModule = IsAny<SassEmbeddedPackageType> extends false ? SassEmbeddedPackageType : SassPackageType;
25
+ //#endregion
26
+ //#region index.d.ts
27
+ /**
28
+ * @import {SassModule, Sass} from './lib/types.js'
29
+ */
30
+ /**
31
+ * @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue
32
+ * @typedef {JsonValue[]} JsonArray
33
+ * @typedef {string | number | boolean | null} JsonPrimitive
34
+ * @typedef {{[Key in string]?: JsonValue}} JsonObject
35
+ */
36
+ /**
37
+ * @param {SassModule} sass
38
+ */
39
+ declare function createJsonFunctions(sass: SassModule): {
40
+ /**
41
+ * Encodes (`JSON.stringify`) data and returns Sass string. By default, string is quoted with single quotes so that it can be easily used in standard CSS values.
42
+ *
43
+ * @param $data `sass.Value` - Data to encode (stringify).
44
+ * @param $qoutes `sass.SassBoolean` - Should output string be quoted with single quotes.
45
+ */
46
+ 'json-encode($data, $quotes: true)': (encodeArguments: Sass.Value[]) => Sass.SassString;
47
+ /**
48
+ * Decodes (`JSON.parse`) string and returns one of available Sass types.
49
+ *
50
+ * @param $string `sass.SassString` - String to decode (parse).
51
+ */
52
+ 'json-decode($string)': (decodeArguments: Sass.Value[]) => Sass.Value;
53
+ };
54
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
55
+ type JsonArray = JsonValue[];
56
+ type JsonPrimitive = string | number | boolean | null;
57
+ type JsonObject = { [Key in string]?: JsonValue };
58
+ //#endregion
59
+ export { JsonArray, JsonObject, JsonPrimitive, JsonValue, createJsonFunctions as default };
60
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../lib/types.ts","../index.js"],"sourcesContent":[],"mappings":";;;;;;KAMK,eAAA,UAAe;KAEf,uBAAA,UAAuB;KAEvB,4BAA4B;kBAEhB,IAAA;EANZ,K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,280 @@
1
+ import rgbHex from "rgb-hex";
2
+ import shortHexColor from "shorten-css-hex";
3
+ import isPlainObject from "is-plain-obj";
4
+ import parseColor from "parse-color";
5
+ import parseUnit from "parse-css-dimension";
6
+ import { OrderedMap } from "immutable";
7
+ import { parse } from "postcss-values-parser";
8
+
9
+ //#region lib/sass-to-json.js
10
+ /**
11
+ * @import {JsonObject, JsonArray} from '../index.js'
12
+ * @import {SassModule, Sass} from '../lib/types.js'
13
+ */
14
+ /**
15
+ * @param {SassModule} sass
16
+ */
17
+ function createGetJsonValueFromSassValue(sass) {
18
+ /**
19
+ * @param {Sass.Value|undefined} value
20
+ */
21
+ function getJsonValueFromSassValue(value) {
22
+ let resolvedValue;
23
+ if (value instanceof sass.SassList) resolvedValue = listToArray(value);
24
+ else if (value instanceof sass.SassMap) resolvedValue = mapToObject(value);
25
+ else if (value instanceof sass.SassColor) {
26
+ /** @type {[number, number, number]} */
27
+ const rgbValue = [
28
+ value.channel("red"),
29
+ value.channel("green"),
30
+ value.channel("blue")
31
+ ];
32
+ const alphaValue = value.alpha;
33
+ if (alphaValue === 1) resolvedValue = shortHexColor(`#${rgbHex.apply(null, rgbValue)}`);
34
+ else resolvedValue = `rgba(${rgbValue.join(",")},${alphaValue})`;
35
+ } else if (value instanceof sass.SassNumber) if (value.hasUnits) resolvedValue = String(value.value) + value.numeratorUnits.last();
36
+ else resolvedValue = Number(value.value);
37
+ else if (value instanceof sass.SassString) resolvedValue = String(value.text);
38
+ else if (value instanceof sass.SassBoolean) resolvedValue = Boolean(value.value);
39
+ else if (value instanceof sass.SassCalculation) resolvedValue = sass.info.includes("sass-embedded") ? toSassString(sass, value).toString() : value.toString();
40
+ else if (typeof value === "undefined") resolvedValue = null;
41
+ else if (value.isTruthy) resolvedValue = value.toString();
42
+ else if (value.realNull) resolvedValue = null;
43
+ return resolvedValue ?? null;
44
+ }
45
+ /**
46
+ * Use Sass compiler to convert SassValue to SassString.
47
+ *
48
+ * Ref. Https://github.com/sass/embedded-host-node/issues/419#issuecomment-3872994933.
49
+ *
50
+ * @param {SassModule} sass
51
+ * @param {Sass.Value} sassValue
52
+ */
53
+ function toSassString(sass, sassValue) {
54
+ let result;
55
+ sass.compileString("$_: o(#{i()});", { functions: {
56
+ "i()": (_) => sassValue,
57
+ "o($i)": (arguments_) => {
58
+ result = arguments_[0];
59
+ return result;
60
+ }
61
+ } });
62
+ return result;
63
+ }
64
+ /**
65
+ * @param {Sass.SassList} list
66
+ */
67
+ function listToArray(list) {
68
+ const length = list.asList.size;
69
+ /** @type {JsonArray} */
70
+ const data = [];
71
+ for (const index of Array.from({ length }).keys()) {
72
+ const value = getJsonValueFromSassValue(list.get(index));
73
+ data.push(value);
74
+ }
75
+ return data;
76
+ }
77
+ /**
78
+ * @param {Sass.SassMap} map
79
+ */
80
+ function mapToObject(map) {
81
+ const length = map.contents.size;
82
+ /** @type {JsonObject} */
83
+ const data = {};
84
+ for (const index of Array.from({ length }).keys()) {
85
+ const resolvedValue = map.get(index);
86
+ if (typeof resolvedValue !== "undefined") {
87
+ const key = String(getJsonValueFromSassValue(resolvedValue.get(0)));
88
+ data[key] = getJsonValueFromSassValue(resolvedValue.get(1));
89
+ }
90
+ }
91
+ return data;
92
+ }
93
+ return getJsonValueFromSassValue;
94
+ }
95
+
96
+ //#endregion
97
+ //#region lib/json-to-sass.js
98
+ /**
99
+ * @import {JsonValue, JsonObject, JsonArray} from '../index.js'
100
+ * @import {SassModule, Sass} from '../lib/types.js'
101
+ */
102
+ const unitTypes = [
103
+ "length",
104
+ "angle",
105
+ "resolution",
106
+ "frequency",
107
+ "time"
108
+ ];
109
+ /**
110
+ * @param {string} value
111
+ */
112
+ function isColor(value) {
113
+ return typeof parseColor(value).rgba !== "undefined";
114
+ }
115
+ /**
116
+ * @param {string} value
117
+ */
118
+ function isCalculation(value) {
119
+ if (!value.includes("calc")) return false;
120
+ try {
121
+ const node = parse(value).first;
122
+ return node?.type === "func" && node.name === "calc";
123
+ } catch {
124
+ return false;
125
+ }
126
+ }
127
+ /**
128
+ * @param {SassModule} sass
129
+ */
130
+ function createSetJsonValueToSassValue(sass) {
131
+ /**
132
+ * @param {string} value
133
+ * @param {{forceNumber: boolean}=} options
134
+ */
135
+ function parseValueToStringOrNumber(value, options) {
136
+ const { forceNumber = false } = options ?? {};
137
+ let resolvedValue;
138
+ try {
139
+ const { value: parsedValue, unit, type } = parseUnit(value);
140
+ if (unitTypes.includes(type)) resolvedValue = new sass.SassNumber(parsedValue, unit);
141
+ else if (type === "percentage") resolvedValue = new sass.SassNumber(parsedValue, "%");
142
+ else if (forceNumber && !Number.isNaN(Number(value))) resolvedValue = new sass.SassNumber(Number(value));
143
+ else resolvedValue = new sass.SassString(value);
144
+ } catch (error) {
145
+ resolvedValue = new sass.SassString(value);
146
+ }
147
+ return resolvedValue;
148
+ }
149
+ /**
150
+ * @param {string} value
151
+ */
152
+ function parseValueToColor(value) {
153
+ const [red, green, blue, alpha] = parseColor(value).rgba;
154
+ return new sass.SassColor({
155
+ red,
156
+ green,
157
+ blue,
158
+ alpha
159
+ });
160
+ }
161
+ /**
162
+ * @typedef {object} CalculationContainer
163
+ * @property {?Sass.CalculationOperator} operator
164
+ * @property {?Sass.CalculationValue} left
165
+ * @property {?Sass.CalculationValue} right
166
+ */
167
+ /**
168
+ * @param {string} value
169
+ */
170
+ function parseValueToCalculation(value) {
171
+ const node = parse(value).first;
172
+ let calc = {
173
+ operator: null,
174
+ left: null,
175
+ right: null
176
+ };
177
+ if (node?.type === "func" && node.name === "calc") {
178
+ if (node.nodes.length > 3) return parseValueToStringOrNumber(value);
179
+ node.nodes.forEach((node, index) => {
180
+ if (node.type === "operator") calc.operator = node.value;
181
+ else if (index === 0) calc.left = parseValueToStringOrNumber(node.toString());
182
+ else calc.right = parseValueToStringOrNumber(node.toString(), { forceNumber: true });
183
+ });
184
+ }
185
+ try {
186
+ return sass.SassCalculation.calc(new sass.CalculationOperation(calc.operator, calc.left, calc.right));
187
+ } catch {
188
+ return parseValueToStringOrNumber(value);
189
+ }
190
+ }
191
+ /**
192
+ * @param {JsonValue} value
193
+ */
194
+ function setJsonValueToSassValue(value) {
195
+ let resolvedValue;
196
+ if (Array.isArray(value)) resolvedValue = arrayToList(value);
197
+ else if (isPlainObject(value)) resolvedValue = objectToMap(value);
198
+ else if (isColor(String(value))) resolvedValue = parseValueToColor(String(value));
199
+ else if (isCalculation(String(value))) resolvedValue = parseValueToCalculation(String(value));
200
+ else if (typeof value === "string") resolvedValue = parseValueToStringOrNumber(value);
201
+ else if (typeof value === "number") resolvedValue = new sass.SassNumber(value);
202
+ else if (typeof value === "boolean") resolvedValue = value ? sass.sassTrue : sass.sassFalse;
203
+ else resolvedValue = sass.sassNull;
204
+ return resolvedValue;
205
+ }
206
+ /**
207
+ * @param {JsonArray} array
208
+ */
209
+ function arrayToList(array) {
210
+ /** @type {Sass.Value[]} */
211
+ const data = [];
212
+ for (const item of array) data.push(setJsonValueToSassValue(item));
213
+ return new sass.SassList(data);
214
+ }
215
+ /**
216
+ * @param {JsonObject} object
217
+ */
218
+ function objectToMap(object) {
219
+ /** @type {[Sass.Value, Sass.Value][]} */
220
+ const data = [];
221
+ for (const [property, value = null] of Object.entries(object)) data.push([setJsonValueToSassValue(property), setJsonValueToSassValue(value)]);
222
+ return new sass.SassMap(OrderedMap(data));
223
+ }
224
+ return setJsonValueToSassValue;
225
+ }
226
+
227
+ //#endregion
228
+ //#region index.js
229
+ /**
230
+ * @import {SassModule, Sass} from './lib/types.js'
231
+ */
232
+ /**
233
+ * @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue
234
+ * @typedef {JsonValue[]} JsonArray
235
+ * @typedef {string | number | boolean | null} JsonPrimitive
236
+ * @typedef {{[Key in string]?: JsonValue}} JsonObject
237
+ */
238
+ /**
239
+ * @param {SassModule} sass
240
+ */
241
+ function createJsonFunctions(sass) {
242
+ const getJsonValueFromSassValue = createGetJsonValueFromSassValue(sass);
243
+ const setJsonValueToSassValue = createSetJsonValueToSassValue(sass);
244
+ /**
245
+ * @param {Sass.Value[]} encodeArguments
246
+ * @returns {Sass.SassString}
247
+ */
248
+ function encode(encodeArguments) {
249
+ const [data, quotes_] = encodeArguments;
250
+ const quotes = quotes_?.assertBoolean("quotes");
251
+ const shouldQuote = Boolean(quotes?.value);
252
+ let resolvedValue = JSON.stringify(getJsonValueFromSassValue(data));
253
+ if (shouldQuote) resolvedValue = `'${resolvedValue}'`;
254
+ return new sass.SassString(resolvedValue);
255
+ }
256
+ /**
257
+ * @param {Sass.Value[]} decodeArguments
258
+ * @returns {Sass.Value}
259
+ */
260
+ function decode(decodeArguments) {
261
+ const [string_] = decodeArguments;
262
+ const string = string_?.assertString("string");
263
+ /** @type {JsonValue?} */
264
+ let resolvedValue = {};
265
+ try {
266
+ resolvedValue = string ? JSON.parse(string.text) : null;
267
+ } catch (error) {
268
+ resolvedValue = null;
269
+ }
270
+ return setJsonValueToSassValue(resolvedValue);
271
+ }
272
+ return {
273
+ "json-encode($data, $quotes: true)": encode,
274
+ "json-decode($string)": decode
275
+ };
276
+ }
277
+
278
+ //#endregion
279
+ export { createJsonFunctions as default };
280
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../lib/sass-to-json.js","../lib/json-to-sass.js","../index.js"],"sourcesContent":["import rgbHex from 'rgb-hex';\nimport shortHexColor from 'shorten-css-hex';\n\n/**\n * @import {JsonObject, JsonArray} from '../index.js'\n * @import {SassModule, Sass} from '../lib/types.js'\n */\n\n/**\n * @param {SassModule} sass\n */\nfunction createGetJsonValueFromSassValue(sass) {\n\t/**\n\t * @param {Sass.Value|undefined} value\n\t */\n\tfunction getJsonValueFromSassValue(value) {\n\t\tlet resolvedValue;\n\t\tif (value instanceof sass.SassList) {\n\t\t\tresolvedValue = listToArray(value);\n\t\t} else if (value instanceof sass.SassMap) {\n\t\t\tresolvedValue = mapToObject(value);\n\t\t} else if (value instanceof sass.SassColor) {\n\t\t\t/** @type {[number, number, number]} */\n\t\t\tconst rgbValue = [value.channel('red'), value.channel('green'), value.channel('blue')];\n\t\t\tconst alphaValue = value.alpha;\n\t\t\tif (alphaValue === 1) {\n\t\t\t\tresolvedValue = shortHexColor(`#${rgbHex.apply(null, rgbValue)}`);\n\t\t\t} else {\n\t\t\t\tresolvedValue = `rgba(${rgbValue.join(',')},${alphaValue})`;\n\t\t\t}\n\t\t} else if (value instanceof sass.SassNumber) {\n\t\t\tif (value.hasUnits) {\n\t\t\t\tresolvedValue = String(value.value) + value.numeratorUnits.last();\n\t\t\t} else {\n\t\t\t\tresolvedValue = Number(value.value);\n\t\t\t}\n\t\t} else if (value instanceof sass.SassString) {\n\t\t\tresolvedValue = String(value.text);\n\t\t} else if (value instanceof sass.SassBoolean) {\n\t\t\tresolvedValue = Boolean(value.value);\n\t\t} else if (value instanceof sass.SassCalculation) {\n\t\t\tresolvedValue = sass.info.includes('sass-embedded')\n\t\t\t\t? toSassString(sass, value).toString()\n\t\t\t\t: value.toString();\n\t\t} else if (typeof value === 'undefined') {\n\t\t\tresolvedValue = null;\n\t\t} else if (value.isTruthy) {\n\t\t\tresolvedValue = value.toString();\n\t\t} else if (value.realNull) {\n\t\t\tresolvedValue = null;\n\t\t}\n\t\treturn resolvedValue ?? null;\n\t}\n\n\t/**\n\t * Use Sass compiler to convert SassValue to SassString.\n\t *\n\t * Ref. Https://github.com/sass/embedded-host-node/issues/419#issuecomment-3872994933.\n\t *\n\t * @param {SassModule} sass\n\t * @param {Sass.Value} sassValue\n\t */\n\tfunction toSassString(sass, sassValue) {\n\t\tlet result;\n\t\tsass.compileString('$_: o(#{i()});', {\n\t\t\tfunctions: {\n\t\t\t\t'i()': (_) => sassValue,\n\t\t\t\t'o($i)': (arguments_) => {\n\t\t\t\t\tresult = /** @type {Sass.SassString} */ (arguments_[0]);\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn /** @type {Sass.SassString} */ (/** @type {unknown} */ (result));\n\t}\n\n\t/**\n\t * @param {Sass.SassList} list\n\t */\n\tfunction listToArray(list) {\n\t\tconst length = list.asList.size;\n\t\t/** @type {JsonArray} */\n\t\tconst data = [];\n\t\tfor (const index of Array.from({ length }).keys()) {\n\t\t\tconst value = getJsonValueFromSassValue(list.get(index));\n\t\t\tdata.push(value);\n\t\t}\n\t\treturn data;\n\t}\n\n\t/**\n\t * @param {Sass.SassMap} map\n\t */\n\tfunction mapToObject(map) {\n\t\tconst length = map.contents.size;\n\t\t/** @type {JsonObject} */\n\t\tconst data = {};\n\t\tfor (const index of Array.from({ length }).keys()) {\n\t\t\tconst resolvedValue = map.get(index);\n\t\t\tif (typeof resolvedValue !== 'undefined') {\n\t\t\t\tconst key = String(getJsonValueFromSassValue(resolvedValue.get(0)));\n\t\t\t\tconst value = getJsonValueFromSassValue(resolvedValue.get(1));\n\t\t\t\tdata[key] = value;\n\t\t\t}\n\t\t}\n\t\treturn data;\n\t}\n\n\treturn getJsonValueFromSassValue;\n}\n\nexport default createGetJsonValueFromSassValue;\n","import isPlainObject from 'is-plain-obj';\nimport parseColor from 'parse-color';\nimport parseUnit from 'parse-css-dimension';\nimport { OrderedMap } from 'immutable';\nimport { parse } from 'postcss-values-parser';\n\n/**\n * @import {JsonValue, JsonObject, JsonArray} from '../index.js'\n * @import {SassModule, Sass} from '../lib/types.js'\n */\n\nconst unitTypes = ['length', 'angle', 'resolution', 'frequency', 'time'];\n\n/**\n * @param {string} value\n */\nfunction isColor(value) {\n\treturn typeof parseColor(value).rgba !== 'undefined';\n}\n\n/**\n * @param {string} value\n */\nfunction isCalculation(value) {\n\tif (!value.includes('calc')) {\n\t\treturn false;\n\t}\n\ttry {\n\t\tconst root = parse(value);\n\t\tconst node = root.first;\n\t\treturn node?.type === 'func' && node.name === 'calc';\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * @param {SassModule} sass\n */\nfunction createSetJsonValueToSassValue(sass) {\n\t/**\n\t * @param {string} value\n\t * @param {{forceNumber: boolean}=} options\n\t */\n\tfunction parseValueToStringOrNumber(value, options) {\n\t\tconst { forceNumber = false } = options ?? {};\n\t\tlet resolvedValue;\n\t\ttry {\n\t\t\tconst { value: parsedValue, unit, type } = parseUnit(value);\n\t\t\tif (unitTypes.includes(type)) {\n\t\t\t\tresolvedValue = new sass.SassNumber(parsedValue, unit);\n\t\t\t} else if (type === 'percentage') {\n\t\t\t\tresolvedValue = new sass.SassNumber(parsedValue, '%');\n\t\t\t} else if (forceNumber && !Number.isNaN(Number(value))) {\n\t\t\t\tresolvedValue = new sass.SassNumber(Number(value));\n\t\t\t} else {\n\t\t\t\tresolvedValue = new sass.SassString(value);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tresolvedValue = new sass.SassString(value);\n\t\t}\n\t\treturn resolvedValue;\n\t}\n\n\t/**\n\t * @param {string} value\n\t */\n\tfunction parseValueToColor(value) {\n\t\tconst [red, green, blue, alpha] = parseColor(value).rgba;\n\t\treturn new sass.SassColor({\n\t\t\tred,\n\t\t\tgreen,\n\t\t\tblue,\n\t\t\talpha\n\t\t});\n\t}\n\n\t/**\n\t * @typedef {object} CalculationContainer\n\t * @property {?Sass.CalculationOperator} operator\n\t * @property {?Sass.CalculationValue} left\n\t * @property {?Sass.CalculationValue} right\n\t */\n\n\t/**\n\t * @param {string} value\n\t */\n\tfunction parseValueToCalculation(value) {\n\t\tconst root = parse(value);\n\t\tconst node = root.first;\n\n\t\tlet calc = /** @type {CalculationContainer} */ ({\n\t\t\toperator: null,\n\t\t\tleft: null,\n\t\t\tright: null\n\t\t});\n\t\tif (node?.type === 'func' && node.name === 'calc') {\n\t\t\tif (node.nodes.length > 3) {\n\t\t\t\treturn parseValueToStringOrNumber(value);\n\t\t\t}\n\t\t\tnode.nodes.forEach((node, index) => {\n\t\t\t\tif (node.type === 'operator') {\n\t\t\t\t\tcalc.operator = /** @type {Sass.CalculationOperator} */ (node.value);\n\t\t\t\t} else if (index === 0) {\n\t\t\t\t\tcalc.left = parseValueToStringOrNumber(node.toString());\n\t\t\t\t} else {\n\t\t\t\t\tcalc.right = parseValueToStringOrNumber(node.toString(), {\n\t\t\t\t\t\tforceNumber: true\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\ttry {\n\t\t\treturn sass.SassCalculation.calc(\n\t\t\t\tnew sass.CalculationOperation(\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tcalc.operator,\n\t\t\t\t\tcalc.left,\n\t\t\t\t\tcalc.right\n\t\t\t\t)\n\t\t\t);\n\t\t} catch {\n\t\t\treturn parseValueToStringOrNumber(value);\n\t\t}\n\t}\n\n\t/**\n\t * @param {JsonValue} value\n\t */\n\tfunction setJsonValueToSassValue(value) {\n\t\tlet resolvedValue;\n\t\tif (Array.isArray(value)) {\n\t\t\tresolvedValue = arrayToList(value);\n\t\t} else if (isPlainObject(value)) {\n\t\t\tresolvedValue = objectToMap(value);\n\t\t} else if (isColor(String(value))) {\n\t\t\tresolvedValue = parseValueToColor(String(value));\n\t\t} else if (isCalculation(String(value))) {\n\t\t\tresolvedValue = parseValueToCalculation(String(value));\n\t\t} else if (typeof value === 'string') {\n\t\t\tresolvedValue = parseValueToStringOrNumber(value);\n\t\t} else if (typeof value === 'number') {\n\t\t\tresolvedValue = new sass.SassNumber(value);\n\t\t} else if (typeof value === 'boolean') {\n\t\t\tresolvedValue = value ? sass.sassTrue : sass.sassFalse;\n\t\t} else {\n\t\t\tresolvedValue = sass.sassNull;\n\t\t}\n\t\treturn resolvedValue;\n\t}\n\n\t/**\n\t * @param {JsonArray} array\n\t */\n\tfunction arrayToList(array) {\n\t\t/** @type {Sass.Value[]} */\n\t\tconst data = [];\n\t\tfor (const item of array) {\n\t\t\tdata.push(setJsonValueToSassValue(item));\n\t\t}\n\t\treturn new sass.SassList(data);\n\t}\n\n\t/**\n\t * @param {JsonObject} object\n\t */\n\tfunction objectToMap(object) {\n\t\t/** @type {[Sass.Value, Sass.Value][]} */\n\t\tconst data = [];\n\t\tfor (const [property, value = null] of Object.entries(object)) {\n\t\t\tdata.push([setJsonValueToSassValue(property), setJsonValueToSassValue(value)]);\n\t\t}\n\t\t// eslint-disable-next-line new-cap\n\t\treturn new sass.SassMap(OrderedMap(data));\n\t}\n\n\treturn setJsonValueToSassValue;\n}\n\nexport default createSetJsonValueToSassValue;\n","import createGetJsonValueFromSassValue from './lib/sass-to-json.js';\nimport createSetJsonValueToSassValue from './lib/json-to-sass.js';\n\n/**\n * @import {SassModule, Sass} from './lib/types.js'\n */\n\n/**\n * @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue\n * @typedef {JsonValue[]} JsonArray\n * @typedef {string | number | boolean | null} JsonPrimitive\n * @typedef {{[Key in string]?: JsonValue}} JsonObject\n */\n\n/**\n * @param {SassModule} sass\n */\nexport default function createJsonFunctions(sass) {\n\tconst getJsonValueFromSassValue = createGetJsonValueFromSassValue(sass);\n\tconst setJsonValueToSassValue = createSetJsonValueToSassValue(sass);\n\n\t/**\n\t * @param {Sass.Value[]} encodeArguments\n\t * @returns {Sass.SassString}\n\t */\n\tfunction encode(encodeArguments) {\n\t\tconst [data, quotes_] = encodeArguments;\n\t\tconst quotes = quotes_?.assertBoolean('quotes');\n\t\tconst shouldQuote = Boolean(quotes?.value);\n\t\tlet resolvedValue = JSON.stringify(getJsonValueFromSassValue(data));\n\t\tif (shouldQuote) {\n\t\t\tresolvedValue = `'${resolvedValue}'`;\n\t\t}\n\t\treturn new sass.SassString(resolvedValue);\n\t}\n\n\t/**\n\t * @param {Sass.Value[]} decodeArguments\n\t * @returns {Sass.Value}\n\t */\n\tfunction decode(decodeArguments) {\n\t\tconst [string_] = decodeArguments;\n\t\tconst string = string_?.assertString('string');\n\t\t/** @type {JsonValue?} */\n\t\tlet resolvedValue = {};\n\t\ttry {\n\t\t\tresolvedValue = string ? JSON.parse(string.text) : null;\n\t\t} catch (error) {\n\t\t\tresolvedValue = null;\n\t\t}\n\t\treturn setJsonValueToSassValue(resolvedValue);\n\t}\n\n\treturn {\n\t\t/**\n\t\t * Encodes (`JSON.stringify`) data and returns Sass string. By default, string is quoted with single quotes so that it can be easily used in standard CSS values.\n\t\t *\n\t\t * @param $data `sass.Value` - Data to encode (stringify).\n\t\t * @param $qoutes `sass.SassBoolean` - Should output string be quoted with single quotes.\n\t\t */\n\t\t'json-encode($data, $quotes: true)': encode,\n\t\t/**\n\t\t * Decodes (`JSON.parse`) string and returns one of available Sass types.\n\t\t *\n\t\t * @param $string `sass.SassString` - String to decode (parse).\n\t\t */\n\t\t'json-decode($string)': decode\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,SAAS,gCAAgC,MAAM;;;;CAI9C,SAAS,0BAA0B,OAAO;EACzC,IAAI;AACJ,MAAI,iBAAiB,KAAK,SACzB,iBAAgB,YAAY,MAAM;WACxB,iBAAiB,KAAK,QAChC,iBAAgB,YAAY,MAAM;WACxB,iBAAiB,KAAK,WAAW;;GAE3C,MAAM,WAAW;IAAC,MAAM,QAAQ,MAAM;IAAE,MAAM,QAAQ,QAAQ;IAAE,MAAM,QAAQ,OAAO;IAAC;GACtF,MAAM,aAAa,MAAM;AACzB,OAAI,eAAe,EAClB,iBAAgB,cAAc,IAAI,OAAO,MAAM,MAAM,SAAS,GAAG;OAEjE,iBAAgB,QAAQ,SAAS,KAAK,IAAI,CAAC,GAAG,WAAW;aAEhD,iBAAiB,KAAK,WAChC,KAAI,MAAM,SACT,iBAAgB,OAAO,MAAM,MAAM,GAAG,MAAM,eAAe,MAAM;MAEjE,iBAAgB,OAAO,MAAM,MAAM;WAE1B,iBAAiB,KAAK,WAChC,iBAAgB,OAAO,MAAM,KAAK;WACxB,iBAAiB,KAAK,YAChC,iBAAgB,QAAQ,MAAM,MAAM;WAC1B,iBAAiB,KAAK,gBAChC,iBAAgB,KAAK,KAAK,SAAS,gBAAgB,GAChD,aAAa,MAAM,MAAM,CAAC,UAAU,GACpC,MAAM,UAAU;WACT,OAAO,UAAU,YAC3B,iBAAgB;WACN,MAAM,SAChB,iBAAg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