node-sass-json-functions 2.0.1 → 3.3.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 ADDED
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ ## [Unreleased][]
4
+
5
+ ## [3.3.0][] - 2022-01-11
6
+
7
+ ### Added
8
+
9
+ - Precision option
10
+ ([#6](https://github.com/niksy/node-sass-json-functions/issues/6))
11
+
12
+ ## [3.2.0][] - 2021-11-10
13
+
14
+ ### Added
15
+
16
+ - TypeScript typings
17
+
18
+ ## [3.1.0][] - 2021-01-14
19
+
20
+ ### Removed
21
+
22
+ - Lodash as dependancy
23
+
24
+ ## [3.0.0][] - 2021-01-14
25
+
26
+ ### Changed
27
+
28
+ - Switch to Dart Sass
29
+ - Upgrade package
30
+
31
+ ### Removed
32
+
33
+ - **Node 4 support, lowest version is 10**
34
+ - Precision option
35
+
36
+ <!-- prettier-ignore-start -->
37
+
38
+ [3.0.0]: https://github.com/niksy/node-sass-json-functions/tree/v3.0.0
39
+ [3.1.0]: https://github.com/niksy/node-sass-json-functions/tree/v3.1.0
40
+ [3.2.0]: https://github.com/niksy/node-sass-json-functions/tree/v3.2.0
41
+
42
+ <!-- prettier-ignore-end -->
43
+
44
+ [unreleased]:
45
+ https://github.com/niksy/node-sass-json-functions/compare/v3.3.0...HEAD
46
+ [3.3.0]: https://github.com/niksy/node-sass-json-functions/tree/v3.3.0
package/README.md CHANGED
@@ -2,49 +2,62 @@
2
2
 
3
3
  [![Build Status][ci-img]][ci]
4
4
 
5
- JSON encode and decode functions for [node-sass][node-sass].
5
+ JSON encode and decode functions for [sass][sass].
6
6
 
7
7
  ## Install
8
8
 
9
9
  ```sh
10
- npm install node-sass-json-functions --save
10
+ npm install sass node-sass-json-functions --save
11
11
  ```
12
12
 
13
13
  ## Usage
14
14
 
15
15
  ```js
16
- var sass = require('node-sass');
17
- var jsonFns = require('node-sass-json-functions');
18
-
19
- sass.render({
20
- file: './index.scss',
21
- functions: Object.assign({}, jsonFns)
22
- }, function ( err, res ) {
23
- // ...
24
- });
16
+ import sass from 'sass';
17
+ import jsonFns from 'node-sass-json-functions';
18
+
19
+ sass.render(
20
+ {
21
+ file: './index.scss',
22
+ functions: { ...jsonFns }
23
+ },
24
+ (err, res) => {
25
+ // ...
26
+ }
27
+ );
25
28
  ```
26
29
 
27
- Module exports object with prepared functions `json-encode` and `json-decode`. If you need functions as separate entities, they are available as static properties `encode` and `decode`.
30
+ Module exports object with prepared functions `json-encode` and `json-decode`.
28
31
 
29
32
  ### Encode
30
33
 
31
34
  Input:
32
35
 
33
36
  ```scss
34
- $list: 1, 2, "3", (4,5,6), (foo: "bar baz");
37
+ $list: 1, 2, '3', (4, 5, 6), (
38
+ foo: 'bar baz'
39
+ );
35
40
  $map: (
36
41
  foo: 1,
37
- bar: (2, 3),
38
- baz: "3 3 3",
42
+ bar: (
43
+ 2,
44
+ 3
45
+ ),
46
+ baz: '3 3 3',
39
47
  bad: (
40
48
  foo: 11,
41
49
  bar: 22,
42
50
  baz: (
43
- 5, 4, 6, null, 1, 1.23456789px
51
+ 5,
52
+ 4,
53
+ 6,
54
+ null,
55
+ 1,
56
+ 1.23456789px
44
57
  ),
45
- bag: "foo bar"
58
+ bag: 'foo bar'
46
59
  ),
47
- qux: rgba(255,255,255,0.5),
60
+ qux: rgba(255, 255, 255, 0.5),
48
61
  corgle: red
49
62
  );
50
63
 
@@ -88,48 +101,65 @@ DEBUG: (foo: 1, bar: 2, 3, baz: 3 3 3, bad: (foo: 11, bar: 22, baz: 5, 4, 6, nul
88
101
 
89
102
  ## API
90
103
 
91
- ### json-encode(data, [quotes])
104
+ ### json-encode(data[, quotes, precision])
92
105
 
93
106
  Returns: `sass.types.String`
94
107
 
95
- Encodes (`JSON.stringify`) data and returns [Sass string][sass-string]. By default, string is quoted with single quotes so that it can be easily used in standard CSS values.
108
+ Encodes (`JSON.stringify`) data and returns [Sass string][sass-string]. By
109
+ default, string is quoted with single quotes so that it can be easily used in
110
+ standard CSS values.
96
111
 
97
- * [Sass lists][sass-list] are transformed to arrays
98
- * [Sass maps][sass-map] are transformed to objects
99
- * [Sass colors][sass-color] are transformed to `rgba()` syntax if they have alpha value, otherwise they are transformed to hex value (and it’s shorther version if possible)
100
- * [Sass strings][sass-string] are transformed to strings
101
- * Sass numbers are transformed to numbers
102
- * Sass null values and anything unresolved is transformed to null values
112
+ - [Sass lists][sass-list] are transformed to arrays
113
+ - [Sass maps][sass-map] are transformed to objects
114
+ - [Sass colors][sass-color] are transformed to `rgba()` syntax if they have
115
+ alpha value, otherwise they are transformed to hex value (and it’s shorther
116
+ version if possible)
117
+ - [Sass strings][sass-string] are transformed to strings
118
+ - Sass numbers are transformed to numbers
119
+ - Sass null values and anything unresolved is transformed to null values
103
120
 
104
121
  #### data
105
122
 
106
- Type: `sass.types.*`
123
+ Type:
124
+ `sass.types.Null|sass.types.Number|sass.types.String|sass.types.Boolean|sass.types.Color|sass.types.List|sass.types.Map`
107
125
 
108
126
  Data to encode (stringify).
109
127
 
110
128
  #### quotes
111
129
 
112
- Type: `Boolean|sass.types.Boolean`
130
+ Type: `sass.types.Boolean`
113
131
  Default: `true`
114
132
 
115
133
  Should output string be quoted with single quotes.
116
134
 
135
+ #### precision
136
+
137
+ Type: `sass.types.Number`
138
+ Default: `5`
139
+
140
+ Number of digits after the decimal.
141
+
117
142
  ### json-decode(data)
118
143
 
119
- Returns: `sass.types.*`
144
+ Returns:
145
+ `sass.types.Null|sass.types.Number|sass.types.String|sass.types.Boolean|sass.types.Color|sass.types.List|sass.types.Map`
120
146
 
121
- Decodes (`JSON.parse`) string and returns one of [available Sass types][sass-types].
147
+ Decodes (`JSON.parse`) string and returns one of [available Sass
148
+ types][sass-types].
122
149
 
123
- * Arrays are transformed to [Sass lists][sass-list]
124
- * Objects are transformed to [Sass maps][sass-map]
125
- * Anything properly parsed with [parse-color][parse-color] is transformed to [Sass color][sass-color]
126
- * Strings are transformed to Sass numbers with units if they can be properly parsed with [parse-css-dimension][parse-css-dimension], otherwise they are transformed to [Sass strings][sass-string]
127
- * Numbers are transformed to Sass numbers
128
- * Null values and anything unresolved is transformed to Sass null values
150
+ - Arrays are transformed to [Sass lists][sass-list]
151
+ - Objects are transformed to [Sass maps][sass-map]
152
+ - Anything properly parsed with [parse-color][parse-color] is transformed to
153
+ [Sass color][sass-color]
154
+ - Strings are transformed to Sass numbers with units if they can be properly
155
+ parsed with [parse-css-dimension][parse-css-dimension], otherwise they are
156
+ transformed to [Sass strings][sass-string]
157
+ - Numbers are transformed to Sass numbers
158
+ - Null values and anything unresolved is transformed to Sass null values
129
159
 
130
160
  #### data
131
161
 
132
- Type: `sass.types.String|sass.types.Number|sass.types.Boolean|sass.types.Null`
162
+ Type: `sass.types.String`
133
163
 
134
164
  String to decode (parse).
135
165
 
@@ -137,9 +167,11 @@ String to decode (parse).
137
167
 
138
168
  MIT © [Ivan Nikolić](http://ivannikolic.com)
139
169
 
140
- [ci]: https://travis-ci.org/niksy/node-sass-json-functions
141
- [ci-img]: https://travis-ci.org/niksy/node-sass-json-functions.svg?branch=master
142
- [node-sass]: https://github.com/sass/node-sass
170
+ <!-- prettier-ignore-start -->
171
+
172
+ [ci]: https://github.com/niksy/node-sass-json-functions/actions?query=workflow%3ACI
173
+ [ci-img]: https://github.com/niksy/node-sass-json-functions/workflows/CI/badge.svg?branch=master
174
+ [sass]: https://github.com/sass/dart-sass
143
175
  [sass-types]: https://github.com/sass/node-sass#functions--v300---experimental
144
176
  [sass-list]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#lists
145
177
  [sass-map]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#maps
@@ -147,3 +179,5 @@ MIT © [Ivan Nikolić](http://ivannikolic.com)
147
179
  [sass-string]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#sass-script-strings
148
180
  [parse-color]: https://github.com/substack/parse-color
149
181
  [parse-css-dimension]: https://github.com/jedmao/parse-css-dimension
182
+
183
+ <!-- prettier-ignore-end -->
package/cjs/index.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ export default api;
2
+ export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
3
+ export type JsonArray = JsonValue[];
4
+ export type JsonPrimitive = string | number | boolean | null;
5
+ export type JsonObject = {
6
+ [x: string]: JsonValue | undefined;
7
+ };
8
+ /** @type {{ 'json-encode($value, $quotes: true, $precision: 5)': typeof encode, 'json-decode($value)': typeof decode }} */
9
+ declare const api: {
10
+ 'json-encode($value, $quotes: true, $precision: 5)': typeof encode;
11
+ 'json-decode($value)': typeof decode;
12
+ };
13
+ /**
14
+ * @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue
15
+ * @typedef {JsonValue[]} JsonArray
16
+ * @typedef {string | number | boolean | null} JsonPrimitive
17
+ * @typedef {{[Key in string]?: JsonValue}} JsonObject
18
+ */
19
+ /**
20
+ * 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.
21
+ *
22
+ * @param {sass.LegacyValue} value Data to encode (stringify).
23
+ * @param {sass.types.Boolean} quotes Should output string be quoted with single quotes.
24
+ * @param {sass.types.Number} precision Number of digits after the decimal.
25
+ */
26
+ declare function encode(value: sass.LegacyValue, quotes: sass.types.Boolean, precision: sass.types.Number): sass.types.String;
27
+ /**
28
+ * Decodes (`JSON.parse`) string and returns one of available Sass types.
29
+ *
30
+ * @param {sass.types.String} value String to decode (parse).
31
+ */
32
+ declare function decode(value: sass.types.String): sass.types.Null | sass.types.Number | sass.types.String | sass.types.Color | sass.types.List | sass.types.Map | sass.types.Boolean<true> | sass.types.Boolean<false>;
33
+ import sass from "sass";
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";wBAKa,aAAa,GAAG,UAAU,cAAY;wBACtC,SAAS,EAAE;4BACX,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI;;;;AAsC7C,2HAA2H;AAC3H,mBADW;IAAE,mDAAmD,EAAE,aAAa,CAAC;IAAC,qBAAqB,EAAE,aAAa,CAAA;CAAE,CAIrH;AA7CF;;;;;GAKG;AAEH;;;;;;GAMG;AACH,+BAJW,KAAK,WAAW,UAChB,KAAK,KAAK,QAAQ,aAClB,KAAK,KAAK,OAAO,qBAW3B;AAED;;;;GAIG;AACH,+BAFW,KAAK,KAAK,OAAO,wKAW3B"}
package/cjs/index.js ADDED
@@ -0,0 +1,249 @@
1
+ 'use strict';
2
+
3
+ var sass = require('sass');
4
+ var round = require('round-to');
5
+ var rgbHex = require('rgb-hex');
6
+ var shortHexColor = require('shorten-css-hex');
7
+ var isPlainObject = require('is-plain-obj');
8
+ var parseColor = require('parse-color');
9
+ var parseUnit = require('parse-css-dimension');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ var sass__default = /*#__PURE__*/_interopDefaultLegacy(sass);
14
+ var round__default = /*#__PURE__*/_interopDefaultLegacy(round);
15
+ var rgbHex__default = /*#__PURE__*/_interopDefaultLegacy(rgbHex);
16
+ var shortHexColor__default = /*#__PURE__*/_interopDefaultLegacy(shortHexColor);
17
+ var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
18
+ var parseColor__default = /*#__PURE__*/_interopDefaultLegacy(parseColor);
19
+ var parseUnit__default = /*#__PURE__*/_interopDefaultLegacy(parseUnit);
20
+
21
+ /**
22
+ * @typedef {object} Options
23
+ * @property {number} precision Number of digits after the decimal.
24
+ */
25
+
26
+ /**
27
+ * @typedef {import('../index').JsonValue} JsonValue
28
+ * @typedef {import('../index').JsonObject} JsonObject
29
+ * @typedef {import('../index').JsonArray} JsonArray
30
+ */
31
+
32
+ /**
33
+ * @param {sass.LegacyValue|undefined} value
34
+ * @param {Options} options
35
+ */
36
+ function getJsonValueFromSassValue(value, options) {
37
+ let resolvedValue;
38
+ if (value instanceof sass__default["default"].types.List) {
39
+ resolvedValue = listToArray(value, options);
40
+ } else if (value instanceof sass__default["default"].types.Map) {
41
+ resolvedValue = mapToObject(value, options);
42
+ } else if (value instanceof sass__default["default"].types.Color) {
43
+ /** @type {[number, number, number]} */
44
+ const rgbValue = [value.getR(), value.getG(), value.getB()];
45
+ const alphaValue = value.getA();
46
+ if (alphaValue === 1) {
47
+ resolvedValue = shortHexColor__default["default"](`#${rgbHex__default["default"].apply(null, rgbValue)}`);
48
+ } else {
49
+ resolvedValue = `rgba(${rgbValue.join(',')},${alphaValue})`;
50
+ }
51
+ } else if (value instanceof sass__default["default"].types.Number) {
52
+ if (value.getUnit() !== '') {
53
+ resolvedValue = String(
54
+ round__default["default"](Number(value.getValue()), options.precision) +
55
+ value.getUnit()
56
+ );
57
+ } else {
58
+ resolvedValue = round__default["default"](Number(value.getValue()), options.precision);
59
+ }
60
+ } else {
61
+ try {
62
+ if (typeof value !== 'undefined' && 'getValue' in value) {
63
+ resolvedValue = value.getValue();
64
+ } else {
65
+ resolvedValue = null;
66
+ }
67
+ } catch (error) {
68
+ resolvedValue = null;
69
+ }
70
+ }
71
+ return resolvedValue;
72
+ }
73
+
74
+ /**
75
+ * @param {sass.types.List} list
76
+ * @param {Options} options
77
+ */
78
+ function listToArray(list, options) {
79
+ const length = list.getLength();
80
+ /** @type {JsonArray} */
81
+ const data = [];
82
+ for (const index of Array.from({ length }).keys()) {
83
+ const value = getJsonValueFromSassValue(list.getValue(index), options);
84
+ data.push(value);
85
+ }
86
+ return data;
87
+ }
88
+
89
+ /**
90
+ * @param {sass.types.Map} map
91
+ * @param {Options} options
92
+ */
93
+ function mapToObject(map, options) {
94
+ const length = map.getLength();
95
+ /** @type {JsonObject} */
96
+ const data = {};
97
+ for (const index of Array.from({ length }).keys()) {
98
+ // @ts-ignore
99
+ const key = String(map.getKey(index).getValue());
100
+ const value = getJsonValueFromSassValue(map.getValue(index), options);
101
+ data[key] = value;
102
+ }
103
+ return data;
104
+ }
105
+
106
+ /**
107
+ * @typedef {import('../index').JsonValue} JsonValue
108
+ * @typedef {import('../index').JsonObject} JsonObject
109
+ * @typedef {import('../index').JsonArray} JsonArray
110
+ */
111
+
112
+ const unitTypes = ['length', 'angle', 'resolution', 'frequency', 'time'];
113
+
114
+ /**
115
+ * @param {string} value
116
+ */
117
+ function isColor(value) {
118
+ return typeof parseColor__default["default"](value).rgba !== 'undefined';
119
+ }
120
+
121
+ /**
122
+ * @param {string} value
123
+ */
124
+ function parseValueToStringOrNumber(value) {
125
+ let resolvedValue;
126
+ try {
127
+ const { value: parsedValue, unit, type } = parseUnit__default["default"](value);
128
+ if (unitTypes.includes(type)) {
129
+ resolvedValue = new sass__default["default"].types.Number(parsedValue, unit);
130
+ } else if (type === 'percentage') {
131
+ resolvedValue = new sass__default["default"].types.Number(parsedValue, '%');
132
+ } else {
133
+ resolvedValue = new sass__default["default"].types.String(value);
134
+ }
135
+ } catch (error) {
136
+ resolvedValue = new sass__default["default"].types.String(value);
137
+ }
138
+ return resolvedValue;
139
+ }
140
+
141
+ /**
142
+ * @param {string} value
143
+ */
144
+ function parseValueToColor(value) {
145
+ const [r, g, b, a] = parseColor__default["default"](value).rgba;
146
+ return new sass__default["default"].types.Color(r, g, b, a);
147
+ }
148
+
149
+ /**
150
+ * @param {JsonValue} value
151
+ */
152
+ function setJsonValueToSassValue(value) {
153
+ let resolvedValue;
154
+ if (Array.isArray(value)) {
155
+ resolvedValue = arrayToList(value);
156
+ } else if (isPlainObject__default["default"](value)) {
157
+ resolvedValue = objectToMap(value);
158
+ } else if (isColor(String(value))) {
159
+ resolvedValue = parseValueToColor(String(value));
160
+ } else if (typeof value === 'string') {
161
+ resolvedValue = parseValueToStringOrNumber(value);
162
+ } else if (typeof value === 'number') {
163
+ resolvedValue = new sass__default["default"].types.Number(value);
164
+ } else if (typeof value === 'boolean') {
165
+ resolvedValue = value
166
+ ? sass__default["default"].types.Boolean.TRUE
167
+ : sass__default["default"].types.Boolean.FALSE;
168
+ } else {
169
+ resolvedValue = sass__default["default"].types.Null.NULL;
170
+ }
171
+ return resolvedValue;
172
+ }
173
+
174
+ /**
175
+ * @param {JsonArray} array
176
+ */
177
+ function arrayToList(array) {
178
+ const length = array.length;
179
+ const data = new sass__default["default"].types.List(length);
180
+ for (const [index, item] of array.entries()) {
181
+ data.setValue(index, setJsonValueToSassValue(item));
182
+ }
183
+ return data;
184
+ }
185
+
186
+ /**
187
+ * @param {JsonObject} object
188
+ */
189
+ function objectToMap(object) {
190
+ const length = Object.keys(object).length;
191
+ const data = new sass__default["default"].types.Map(length);
192
+ for (const [index, [property, value = null]] of Object.entries(
193
+ object
194
+ ).entries()) {
195
+ data.setKey(index, setJsonValueToSassValue(property));
196
+ data.setValue(index, setJsonValueToSassValue(value));
197
+ }
198
+ return data;
199
+ }
200
+
201
+ /**
202
+ * @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue
203
+ * @typedef {JsonValue[]} JsonArray
204
+ * @typedef {string | number | boolean | null} JsonPrimitive
205
+ * @typedef {{[Key in string]?: JsonValue}} JsonObject
206
+ */
207
+
208
+ /**
209
+ * 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.
210
+ *
211
+ * @param {sass.LegacyValue} value Data to encode (stringify).
212
+ * @param {sass.types.Boolean} quotes Should output string be quoted with single quotes.
213
+ * @param {sass.types.Number} precision Number of digits after the decimal.
214
+ */
215
+ function encode(value, quotes, precision) {
216
+ const shouldQuote = quotes.getValue();
217
+ let resolvedValue = JSON.stringify(
218
+ getJsonValueFromSassValue(value, { precision: precision.getValue() })
219
+ );
220
+ if (shouldQuote) {
221
+ resolvedValue = `'${resolvedValue}'`;
222
+ }
223
+ return new sass__default["default"].types.String(resolvedValue);
224
+ }
225
+
226
+ /**
227
+ * Decodes (`JSON.parse`) string and returns one of available Sass types.
228
+ *
229
+ * @param {sass.types.String} value String to decode (parse).
230
+ */
231
+ function decode(value) {
232
+ /** @type {JsonValue?} */
233
+ let resolvedValue = {};
234
+ try {
235
+ resolvedValue = JSON.parse(value.getValue());
236
+ } catch (error) {
237
+ resolvedValue = null;
238
+ }
239
+ return setJsonValueToSassValue(resolvedValue);
240
+ }
241
+
242
+ /** @type {{ 'json-encode($value, $quotes: true, $precision: 5)': typeof encode, 'json-decode($value)': typeof decode }} */
243
+ const api = {
244
+ 'json-encode($value, $quotes: true, $precision: 5)': encode,
245
+ 'json-decode($value)': decode
246
+ };
247
+
248
+ module.exports = api;
249
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../lib/sass-to-json.js","../lib/json-to-sass.js","../index.js"],"sourcesContent":["import sass from 'sass';\nimport round from 'round-to';\nimport rgbHex from 'rgb-hex';\nimport shortHexColor from 'shorten-css-hex';\n\n/**\n * @typedef {object} Options\n * @property {number} precision Number of digits after the decimal.\n */\n\n/**\n * @typedef {import('../index').JsonValue} JsonValue\n * @typedef {import('../index').JsonObject} JsonObject\n * @typedef {import('../index').JsonArray} JsonArray\n */\n\n/**\n * @param {sass.LegacyValue|undefined} value\n * @param {Options} options\n */\nfunction getJsonValueFromSassValue(value, options) {\n\tlet resolvedValue;\n\tif (value instanceof sass.types.List) {\n\t\tresolvedValue = listToArray(value, options);\n\t} else if (value instanceof sass.types.Map) {\n\t\tresolvedValue = mapToObject(value, options);\n\t} else if (value instanceof sass.types.Color) {\n\t\t/** @type {[number, number, number]} */\n\t\tconst rgbValue = [value.getR(), value.getG(), value.getB()];\n\t\tconst alphaValue = value.getA();\n\t\tif (alphaValue === 1) {\n\t\t\tresolvedValue = shortHexColor(`#${rgbHex.apply(null, rgbValue)}`);\n\t\t} else {\n\t\t\tresolvedValue = `rgba(${rgbValue.join(',')},${alphaValue})`;\n\t\t}\n\t} else if (value instanceof sass.types.Number) {\n\t\tif (value.getUnit() !== '') {\n\t\t\tresolvedValue = String(\n\t\t\t\tround(Number(value.getValue()), options.precision) +\n\t\t\t\t\tvalue.getUnit()\n\t\t\t);\n\t\t} else {\n\t\t\tresolvedValue = round(Number(value.getValue()), options.precision);\n\t\t}\n\t} else {\n\t\ttry {\n\t\t\tif (typeof value !== 'undefined' && 'getValue' in value) {\n\t\t\t\tresolvedValue = value.getValue();\n\t\t\t} else {\n\t\t\t\tresolvedValue = null;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tresolvedValue = null;\n\t\t}\n\t}\n\treturn resolvedValue;\n}\n\n/**\n * @param {sass.types.List} list\n * @param {Options} options\n */\nfunction listToArray(list, options) {\n\tconst length = list.getLength();\n\t/** @type {JsonArray} */\n\tconst data = [];\n\tfor (const index of Array.from({ length }).keys()) {\n\t\tconst value = getJsonValueFromSassValue(list.getValue(index), options);\n\t\tdata.push(value);\n\t}\n\treturn data;\n}\n\n/**\n * @param {sass.types.Map} map\n * @param {Options} options\n */\nfunction mapToObject(map, options) {\n\tconst length = map.getLength();\n\t/** @type {JsonObject} */\n\tconst data = {};\n\tfor (const index of Array.from({ length }).keys()) {\n\t\t// @ts-ignore\n\t\tconst key = String(map.getKey(index).getValue());\n\t\tconst value = getJsonValueFromSassValue(map.getValue(index), options);\n\t\tdata[key] = value;\n\t}\n\treturn data;\n}\n\nexport default getJsonValueFromSassValue;\n","import sass from 'sass';\nimport isPlainObject from 'is-plain-obj';\nimport parseColor from 'parse-color';\nimport parseUnit from 'parse-css-dimension';\n\n/**\n * @typedef {import('../index').JsonValue} JsonValue\n * @typedef {import('../index').JsonObject} JsonObject\n * @typedef {import('../index').JsonArray} JsonArray\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 parseValueToStringOrNumber(value) {\n\tlet resolvedValue;\n\ttry {\n\t\tconst { value: parsedValue, unit, type } = parseUnit(value);\n\t\tif (unitTypes.includes(type)) {\n\t\t\tresolvedValue = new sass.types.Number(parsedValue, unit);\n\t\t} else if (type === 'percentage') {\n\t\t\tresolvedValue = new sass.types.Number(parsedValue, '%');\n\t\t} else {\n\t\t\tresolvedValue = new sass.types.String(value);\n\t\t}\n\t} catch (error) {\n\t\tresolvedValue = new sass.types.String(value);\n\t}\n\treturn resolvedValue;\n}\n\n/**\n * @param {string} value\n */\nfunction parseValueToColor(value) {\n\tconst [r, g, b, a] = parseColor(value).rgba;\n\treturn new sass.types.Color(r, g, b, a);\n}\n\n/**\n * @param {JsonValue} value\n */\nfunction setJsonValueToSassValue(value) {\n\tlet resolvedValue;\n\tif (Array.isArray(value)) {\n\t\tresolvedValue = arrayToList(value);\n\t} else if (isPlainObject(value)) {\n\t\tresolvedValue = objectToMap(value);\n\t} else if (isColor(String(value))) {\n\t\tresolvedValue = parseValueToColor(String(value));\n\t} else if (typeof value === 'string') {\n\t\tresolvedValue = parseValueToStringOrNumber(value);\n\t} else if (typeof value === 'number') {\n\t\tresolvedValue = new sass.types.Number(value);\n\t} else if (typeof value === 'boolean') {\n\t\tresolvedValue = value\n\t\t\t? sass.types.Boolean.TRUE\n\t\t\t: sass.types.Boolean.FALSE;\n\t} else {\n\t\tresolvedValue = sass.types.Null.NULL;\n\t}\n\treturn resolvedValue;\n}\n\n/**\n * @param {JsonArray} array\n */\nfunction arrayToList(array) {\n\tconst length = array.length;\n\tconst data = new sass.types.List(length);\n\tfor (const [index, item] of array.entries()) {\n\t\tdata.setValue(index, setJsonValueToSassValue(item));\n\t}\n\treturn data;\n}\n\n/**\n * @param {JsonObject} object\n */\nfunction objectToMap(object) {\n\tconst length = Object.keys(object).length;\n\tconst data = new sass.types.Map(length);\n\tfor (const [index, [property, value = null]] of Object.entries(\n\t\tobject\n\t).entries()) {\n\t\tdata.setKey(index, setJsonValueToSassValue(property));\n\t\tdata.setValue(index, setJsonValueToSassValue(value));\n\t}\n\treturn data;\n}\n\nexport default setJsonValueToSassValue;\n","import sass from 'sass';\nimport getJsonValueFromSassValue from './lib/sass-to-json';\nimport setJsonValueToSassValue from './lib/json-to-sass';\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 * 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 *\n * @param {sass.LegacyValue} value Data to encode (stringify).\n * @param {sass.types.Boolean} quotes Should output string be quoted with single quotes.\n * @param {sass.types.Number} precision Number of digits after the decimal.\n */\nfunction encode(value, quotes, precision) {\n\tconst shouldQuote = quotes.getValue();\n\tlet resolvedValue = JSON.stringify(\n\t\tgetJsonValueFromSassValue(value, { precision: precision.getValue() })\n\t);\n\tif (shouldQuote) {\n\t\tresolvedValue = `'${resolvedValue}'`;\n\t}\n\treturn new sass.types.String(resolvedValue);\n}\n\n/**\n * Decodes (`JSON.parse`) string and returns one of available Sass types.\n *\n * @param {sass.types.String} value String to decode (parse).\n */\nfunction decode(value) {\n\t/** @type {JsonValue?} */\n\tlet resolvedValue = {};\n\ttry {\n\t\tresolvedValue = JSON.parse(value.getValue());\n\t} catch (error) {\n\t\tresolvedValue = null;\n\t}\n\treturn setJsonValueToSassValue(resolvedValue);\n}\n\n/** @type {{ 'json-encode($value, $quotes: true, $precision: 5)': typeof encode, 'json-decode($value)': typeof decode }} */\nconst api = {\n\t'json-encode($value, $quotes: true, $precision: 5)': encode,\n\t'json-decode($value)': decode\n};\n\nexport default api;\n"],"names":["sass","shortHexColor","rgbHex","round","parseColor","parseUnit","isPlainObject"],"mappings":";;;;;;;;;;;;;;;;;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE;AACnD,CAAC,IAAI,aAAa,CAAC;AACnB,CAAC,IAAI,KAAK,YAAYA,wBAAI,CAAC,KAAK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sonValue;
3
+ export type JsonObject = import('../index').JsonObject;
4
+ export type JsonArray = import('../index').JsonArray;
5
+ /**
6
+ * @param {JsonValue} value
7
+ */
8
+ declare function setJsonValueToSassValue(value: JsonValue): sass.types.Null | sass.types.Number | sass.types.String | sass.types.Color | sass.types.List | sass.types.Map | sass.types.Boolean<true> | sass.types.Boolean<false>;
9
+ import sass from "sass";
10
+ //# sourceMappingURL=json-to-sass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-to-sass.d.ts","sourceRoot":"","sources":["../../lib/json-to-sass.js"],"names":[],"mappings":";wBAMa,OAAO,UAAU,EAAE,SAAS;yBAC5B,OAAO,UAAU,EAAE,UAAU;wBAC7B,OAAO,UAAU,EAAE,SAAS;AAwCzC;;GAEG;AACH,gDAFW,SAAS,wKAsBnB"}
@@ -0,0 +1,26 @@
1
+ export default getJsonValueFromSassValue;
2
+ export type Options = {
3
+ /**
4
+ * Number of digits after the decimal.
5
+ */
6
+ precision: number;
7
+ };
8
+ export type JsonValue = import('../index').JsonValue;
9
+ export type JsonObject = import('../index').JsonObject;
10
+ export type JsonArray = import('../index').JsonArray;
11
+ /**
12
+ * @typedef {object} Options
13
+ * @property {number} precision Number of digits after the decimal.
14
+ */
15
+ /**
16
+ * @typedef {import('../index').JsonValue} JsonValue
17
+ * @typedef {import('../index').JsonObject} JsonObject
18
+ * @typedef {import('../index').JsonArray} JsonArray
19
+ */
20
+ /**
21
+ * @param {sass.LegacyValue|undefined} value
22
+ * @param {Options} options
23
+ */
24
+ declare function getJsonValueFromSassValue(value: sass.LegacyValue | undefined, options: Options): string | number | boolean | import("../index").JsonObject | import("../index").JsonArray | null;
25
+ import sass from "sass";
26
+ //# sourceMappingURL=sass-to-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sass-to-json.d.ts","sourceRoot":"","sources":["../../lib/sass-to-json.js"],"names":[],"mappings":";;;;;eAOc,MAAM;;wBAIP,OAAO,UAAU,EAAE,SAAS;yBAC5B,OAAO,UAAU,EAAE,UAAU;wBAC7B,OAAO,UAAU,EAAE,SAAS;AARzC;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AACH,kDAHW,KAAK,WAAW,GAAC,SAAS,WAC1B,OAAO,mGAsCjB"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,14 @@
1
+ declare module 'shorten-css-hex' {
2
+ function main (string: string): string
3
+ export = main;
4
+ }
5
+
6
+ declare module 'parse-css-dimension' {
7
+ type ParsedValue = {
8
+ value: number,
9
+ unit: string,
10
+ type: string,
11
+ };
12
+ function main (value: string): ParsedValue
13
+ export = main;
14
+ }
package/esm/index.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ export default api;
2
+ export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
3
+ export type JsonArray = JsonValue[];
4
+ export type JsonPrimitive = string | number | boolean | null;
5
+ export type JsonObject = {
6
+ [x: string]: JsonValue | undefined;
7
+ };
8
+ /** @type {{ 'json-encode($value, $quotes: true, $precision: 5)': typeof encode, 'json-decode($value)': typeof decode }} */
9
+ declare const api: {
10
+ 'json-encode($value, $quotes: true, $precision: 5)': typeof encode;
11
+ 'json-decode($value)': typeof decode;
12
+ };
13
+ /**
14
+ * @typedef {JsonPrimitive | JsonObject | JsonArray} JsonValue
15
+ * @typedef {JsonValue[]} JsonArray
16
+ * @typedef {string | number | boolean | null} JsonPrimitive
17
+ * @typedef {{[Key in string]?: JsonValue}} JsonObject
18
+ */
19
+ /**
20
+ * 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.
21
+ *
22
+ * @param {sass.LegacyValue} value Data to encode (stringify).
23
+ * @param {sass.types.Boolean} quotes Should output string be quoted with single quotes.
24
+ * @param {sass.types.Number} precision Number of digits after the decimal.
25
+ */
26
+ declare function encode(value: sass.LegacyValue, quotes: sass.types.Boolean, precision: sass.types.Number): sass.types.String;
27
+ /**
28
+ * Decodes (`JSON.parse`) string and returns one of available Sass types.
29
+ *
30
+ * @param {sass.types.String} value String to decode (parse).
31
+ */
32
+ declare function decode(value: sass.types.String): sass.types.Null | sass.types.Number | sass.types.String | sass.types.Color | sass.types.List | sass.types.Map | sass.types.Boolean<true> | sass.types.Boolean<false>;
33
+ import sass from "sass";
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.js"],"names":[],"mappings":";wBAKa,aAAa,GAAG,UAAU,cAAY;wBACtC,SAAS,EAAE;4BACX,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI;;;;AAsC7C,2HAA2H;AAC3H,mBADW;IAAE,mDAAmD,EAAE,aAAa,CAAC;IAAC,qBAAqB,EAAE,aAAa,CAAA;CAAE,CAIrH;AA7CF;;;;;GAKG;AAEH;;;;;;GAMG;AACH,+BAJW,KAAK,WAAW,UAChB,KAAK,KAAK,QAAQ,aAClB,KAAK,KAAK,OAAO,qBAW3B;AAED;;;;GAIG;AACH,+BAFW,KAAK,KAAK,OAAO,wKAW3B"}