sass-embedded 1.0.0-beta.5 → 1.0.0-beta.7
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 +18 -0
- package/dist/.gitignore +1 -1
- package/dist/lib/index.js +11 -4
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/src/{embedded-compiler/compiler.js → async-compiler.js} +9 -17
- package/dist/lib/src/async-compiler.js.map +1 -0
- package/dist/lib/src/compile.js +167 -79
- package/dist/lib/src/compile.js.map +1 -1
- package/dist/lib/src/compiler-path.js +18 -0
- package/dist/lib/src/compiler-path.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/utils.js → deprotofy-span.js} +16 -18
- package/dist/lib/src/deprotofy-span.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/dispatcher.js → dispatcher.js} +45 -40
- package/dist/lib/src/dispatcher.js.map +1 -0
- package/dist/lib/src/exception.js +20 -0
- package/dist/lib/src/exception.js.map +1 -0
- package/dist/lib/src/function-registry.js +81 -0
- package/dist/lib/src/function-registry.js.map +1 -0
- package/dist/lib/src/{node-sass/render.js → legacy.js} +45 -39
- package/dist/lib/src/legacy.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/message-transformer.js → message-transformer.js} +2 -2
- package/dist/lib/src/message-transformer.js.map +1 -0
- package/dist/lib/src/{embedded-compiler/packet-transformer.js → packet-transformer.js} +0 -0
- package/dist/lib/src/packet-transformer.js.map +1 -0
- package/dist/lib/src/protofier.js +205 -0
- package/dist/lib/src/protofier.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/request-tracker.js → request-tracker.js} +0 -0
- package/dist/lib/src/request-tracker.js.map +1 -0
- package/dist/lib/src/sync-compiler.js +52 -0
- package/dist/lib/src/sync-compiler.js.map +1 -0
- package/dist/lib/src/{exception/span.js → sync-process/event.js} +2 -2
- package/dist/lib/src/sync-process/event.js.map +1 -0
- package/dist/lib/src/sync-process/index.js +122 -0
- package/dist/lib/src/sync-process/index.js.map +1 -0
- package/dist/lib/src/sync-process/sync-message-port.js +128 -0
- package/dist/lib/src/sync-process/sync-message-port.js.map +1 -0
- package/dist/lib/src/sync-process/worker.js +51 -0
- package/dist/lib/src/sync-process/worker.js.map +1 -0
- package/dist/lib/src/utils.js +43 -1
- package/dist/lib/src/utils.js.map +1 -1
- package/dist/lib/src/value/boolean.js +3 -3
- package/dist/lib/src/value/boolean.js.map +1 -1
- package/dist/lib/src/value/color.js +89 -98
- package/dist/lib/src/value/color.js.map +1 -1
- package/dist/lib/src/value/{value.js → index.js} +5 -1
- package/dist/lib/src/value/index.js.map +1 -0
- package/dist/lib/src/value/list.js +15 -18
- package/dist/lib/src/value/list.js.map +1 -1
- package/dist/lib/src/value/map.js +17 -10
- package/dist/lib/src/value/map.js.map +1 -1
- package/dist/lib/src/value/null.js +2 -2
- package/dist/lib/src/value/number.js +20 -26
- package/dist/lib/src/value/number.js.map +1 -1
- package/dist/lib/src/value/string.js +14 -9
- package/dist/lib/src/value/string.js.map +1 -1
- package/dist/lib/src/value/utils.js +7 -1
- package/dist/lib/src/value/utils.js.map +1 -1
- package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.js +1395 -101
- package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.js.map +1 -1
- package/dist/package.json +6 -4
- package/dist/tool/utils.js +34 -9
- package/dist/tool/utils.js.map +1 -1
- package/dist/types/compile.d.ts +152 -0
- package/dist/types/exception.d.ts +41 -0
- package/dist/types/importer.d.ts +294 -0
- package/dist/types/index.d.ts +76 -0
- package/dist/types/legacy/exception.d.ts +54 -0
- package/dist/types/legacy/function.d.ts +652 -0
- package/dist/types/legacy/importer.d.ts +168 -0
- package/dist/types/legacy/options.d.ts +642 -0
- package/dist/types/legacy/plugin_this.d.ts +70 -0
- package/dist/types/legacy/render.d.ts +139 -0
- package/dist/types/logger/index.d.ts +94 -0
- package/dist/types/logger/source_location.d.ts +21 -0
- package/dist/types/logger/source_span.d.ts +34 -0
- package/dist/types/options.d.ts +408 -0
- package/dist/types/util/promise_or.d.ts +17 -0
- package/dist/types/value/argument_list.d.ts +47 -0
- package/dist/types/value/boolean.d.ts +29 -0
- package/dist/types/value/color.d.ts +107 -0
- package/dist/types/value/function.d.ts +22 -0
- package/dist/types/value/index.d.ts +173 -0
- package/dist/types/value/list.d.ts +54 -0
- package/dist/types/value/map.d.ts +41 -0
- package/dist/types/value/number.d.ts +305 -0
- package/dist/types/value/string.d.ts +84 -0
- package/package.json +6 -4
- package/dist/lib/index.d.ts +0 -10
- package/dist/lib/src/compile.d.ts +0 -22
- package/dist/lib/src/embedded-compiler/compiler.d.ts +0 -19
- package/dist/lib/src/embedded-compiler/compiler.js.map +0 -1
- package/dist/lib/src/embedded-compiler/packet-transformer.d.ts +0 -34
- package/dist/lib/src/embedded-compiler/packet-transformer.js.map +0 -1
- package/dist/lib/src/embedded-protocol/dispatcher.d.ts +0 -60
- package/dist/lib/src/embedded-protocol/dispatcher.js.map +0 -1
- package/dist/lib/src/embedded-protocol/message-transformer.d.ts +0 -47
- package/dist/lib/src/embedded-protocol/message-transformer.js.map +0 -1
- package/dist/lib/src/embedded-protocol/request-tracker.d.ts +0 -20
- package/dist/lib/src/embedded-protocol/request-tracker.js.map +0 -1
- package/dist/lib/src/embedded-protocol/utils.d.ts +0 -7
- package/dist/lib/src/embedded-protocol/utils.js.map +0 -1
- package/dist/lib/src/exception/exception.d.ts +0 -19
- package/dist/lib/src/exception/exception.js +0 -37
- package/dist/lib/src/exception/exception.js.map +0 -1
- package/dist/lib/src/exception/location.d.ts +0 -11
- package/dist/lib/src/exception/location.js +0 -6
- package/dist/lib/src/exception/location.js.map +0 -1
- package/dist/lib/src/exception/span.d.ts +0 -29
- package/dist/lib/src/exception/span.js.map +0 -1
- package/dist/lib/src/node-sass/render.d.ts +0 -61
- package/dist/lib/src/node-sass/render.js.map +0 -1
- package/dist/lib/src/utils.d.ts +0 -16
- package/dist/lib/src/value/boolean.d.ts +0 -25
- package/dist/lib/src/value/color.d.ts +0 -89
- package/dist/lib/src/value/list.d.ts +0 -41
- package/dist/lib/src/value/map.d.ts +0 -26
- package/dist/lib/src/value/null.d.ts +0 -12
- package/dist/lib/src/value/number.d.ts +0 -189
- package/dist/lib/src/value/string.d.ts +0 -56
- package/dist/lib/src/value/utils.d.ts +0 -44
- package/dist/lib/src/value/value.d.ts +0 -108
- package/dist/lib/src/value/value.js.map +0 -1
- package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.d.ts +0 -1
- package/dist/tool/utils.d.ts +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 1.0.0-beta.7
|
|
2
|
+
|
|
3
|
+
* Expose the `Exception` class and ensure that syntax errors match the official
|
|
4
|
+
JS API.
|
|
5
|
+
|
|
6
|
+
* Add support for the `style`, `alertColor`, `alertAscii`, `quietDeps`,
|
|
7
|
+
`verbose`, and `functions` options in `compile()`, `compileString()`,
|
|
8
|
+
`compileAsync()`, and `compileStringAsync()`.
|
|
9
|
+
|
|
10
|
+
* Add support for `CompileResult.loadedUrls`.
|
|
11
|
+
|
|
12
|
+
## 1.0.0-beta.6
|
|
13
|
+
|
|
14
|
+
* Expose (as yet incomplete) `compile()`, `compileString()`, `compileAsync()`,
|
|
15
|
+
and `compileStringAsync()` functions.
|
|
16
|
+
|
|
17
|
+
* Include the official TypeScript definition files.
|
|
18
|
+
|
|
1
19
|
## 1.0.0-beta.5
|
|
2
20
|
|
|
3
21
|
- Function and Values API
|
package/dist/.gitignore
CHANGED
package/dist/lib/index.js
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// MIT-style license that can be found in the LICENSE file or at
|
|
4
4
|
// https://opensource.org/licenses/MIT.
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.info = exports.render = exports.SassString = exports.SassNumber = exports.sassNull = exports.SassMap = exports.SassList = exports.SassColor = exports.sassTrue = exports.sassFalse = exports.Value = void 0;
|
|
6
|
+
exports.info = exports.render = exports.compileStringAsync = exports.compileAsync = exports.compileString = exports.compile = exports.Exception = exports.SassString = exports.SassNumber = exports.sassNull = exports.SassMap = exports.SassList = exports.SassColor = exports.sassTrue = exports.sassFalse = exports.Value = void 0;
|
|
7
7
|
const pkg = require("../package.json");
|
|
8
|
-
var value_1 = require("./src/value
|
|
8
|
+
var value_1 = require("./src/value");
|
|
9
9
|
Object.defineProperty(exports, "Value", { enumerable: true, get: function () { return value_1.Value; } });
|
|
10
10
|
var boolean_1 = require("./src/value/boolean");
|
|
11
11
|
Object.defineProperty(exports, "sassFalse", { enumerable: true, get: function () { return boolean_1.sassFalse; } });
|
|
@@ -22,7 +22,14 @@ var number_1 = require("./src/value/number");
|
|
|
22
22
|
Object.defineProperty(exports, "SassNumber", { enumerable: true, get: function () { return number_1.SassNumber; } });
|
|
23
23
|
var string_1 = require("./src/value/string");
|
|
24
24
|
Object.defineProperty(exports, "SassString", { enumerable: true, get: function () { return string_1.SassString; } });
|
|
25
|
-
var
|
|
26
|
-
Object.defineProperty(exports, "
|
|
25
|
+
var exception_1 = require("./src/exception");
|
|
26
|
+
Object.defineProperty(exports, "Exception", { enumerable: true, get: function () { return exception_1.Exception; } });
|
|
27
|
+
var compile_1 = require("./src/compile");
|
|
28
|
+
Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compile_1.compile; } });
|
|
29
|
+
Object.defineProperty(exports, "compileString", { enumerable: true, get: function () { return compile_1.compileString; } });
|
|
30
|
+
Object.defineProperty(exports, "compileAsync", { enumerable: true, get: function () { return compile_1.compileAsync; } });
|
|
31
|
+
Object.defineProperty(exports, "compileStringAsync", { enumerable: true, get: function () { return compile_1.compileStringAsync; } });
|
|
32
|
+
var legacy_1 = require("./src/legacy");
|
|
33
|
+
Object.defineProperty(exports, "render", { enumerable: true, get: function () { return legacy_1.render; } });
|
|
27
34
|
exports.info = `sass-embedded\t${pkg.version}`;
|
|
28
35
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,uCAAuC;AAEvC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,uCAAuC;AAEvC,qCAAkC;AAA1B,8FAAA,KAAK,OAAA;AACb,+CAAqE;AAAhD,oGAAA,SAAS,OAAA;AAAE,mGAAA,QAAQ,OAAA;AACxC,2CAA4C;AAApC,kGAAA,SAAS,OAAA;AACjB,yCAAyD;AAAlC,gGAAA,QAAQ,OAAA;AAC/B,uCAAwC;AAAhC,8FAAA,OAAO,OAAA;AACf,yCAA0C;AAAlC,gGAAA,QAAQ,OAAA;AAChB,6CAA8C;AAAtC,oGAAA,UAAU,OAAA;AAClB,6CAA8C;AAAtC,oGAAA,UAAU,OAAA;AAElB,6CAA0C;AAAlC,sGAAA,SAAS,OAAA;AACjB,yCAKuB;AAJrB,kGAAA,OAAO,OAAA;AACP,wGAAA,aAAa,OAAA;AACb,uGAAA,YAAY,OAAA;AACZ,6GAAA,kBAAkB,OAAA;AAEpB,uCAAoC;AAA5B,gGAAA,MAAM,OAAA;AAED,QAAA,IAAI,GAAG,kBAAkB,GAAG,CAAC,OAAO,EAAE,CAAC"}
|
|
@@ -3,27 +3,19 @@
|
|
|
3
3
|
// MIT-style license that can be found in the LICENSE file or at
|
|
4
4
|
// https://opensource.org/licenses/MIT.
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const fs = require("fs");
|
|
6
|
+
exports.AsyncEmbeddedCompiler = void 0;
|
|
8
7
|
const child_process_1 = require("child_process");
|
|
9
|
-
const path_1 = require("path");
|
|
10
8
|
const rxjs_1 = require("rxjs");
|
|
11
9
|
const operators_1 = require("rxjs/operators");
|
|
10
|
+
const compiler_path_1 = require("./compiler-path");
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* An asynchronous wrapper for the embedded Sass compiler that exposes its stdio
|
|
13
|
+
* streams as Observables.
|
|
15
14
|
*/
|
|
16
|
-
class
|
|
15
|
+
class AsyncEmbeddedCompiler {
|
|
17
16
|
constructor() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const executable = (0, path_1.resolve)(__dirname, path, `dart-sass-embedded/dart-sass-embedded${process.platform === 'win32' ? '.bat' : ''}`);
|
|
21
|
-
if (fs.existsSync(executable)) {
|
|
22
|
-
return (0, child_process_1.spawn)(executable, { windowsHide: true });
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
throw new Error("Embedded Dart Sass couldn't find the embedded compiler executable.");
|
|
26
|
-
})();
|
|
17
|
+
/** The underlying process that's being wrapped. */
|
|
18
|
+
this.process = (0, child_process_1.spawn)(compiler_path_1.compilerPath, { windowsHide: true });
|
|
27
19
|
/** The child process's exit event. */
|
|
28
20
|
this.exit$ = new Promise(resolve => {
|
|
29
21
|
this.process.on('exit', code => resolve(code));
|
|
@@ -46,5 +38,5 @@ class EmbeddedCompiler {
|
|
|
46
38
|
this.process.stdin.end();
|
|
47
39
|
}
|
|
48
40
|
}
|
|
49
|
-
exports.
|
|
50
|
-
//# sourceMappingURL=compiler.js.map
|
|
41
|
+
exports.AsyncEmbeddedCompiler = AsyncEmbeddedCompiler;
|
|
42
|
+
//# sourceMappingURL=async-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-compiler.js","sourceRoot":"","sources":["../../../lib/src/async-compiler.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,iDAAoC;AACpC,+BAAgC;AAChC,8CAAyC;AAEzC,mDAA6C;AAE7C;;;GAGG;AACH,MAAa,q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3,110 @@
|
|
|
3
3
|
// MIT-style license that can be found in the LICENSE file or at
|
|
4
4
|
// https://opensource.org/licenses/MIT.
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.compileString = exports.compile = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const packet_transformer_1 = require("./embedded-compiler/packet-transformer");
|
|
10
|
-
const message_transformer_1 = require("./embedded-protocol/message-transformer");
|
|
11
|
-
const dispatcher_1 = require("./embedded-protocol/dispatcher");
|
|
12
|
-
const utils_1 = require("./embedded-protocol/utils");
|
|
6
|
+
exports.compileStringAsync = exports.compileAsync = exports.compileString = exports.compile = void 0;
|
|
7
|
+
const p = require("path");
|
|
8
|
+
const supportsColor = require("supports-color");
|
|
13
9
|
const proto = require("./vendor/embedded-protocol/embedded_sass_pb");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
const utils = require("./utils");
|
|
11
|
+
const async_compiler_1 = require("./async-compiler");
|
|
12
|
+
const dispatcher_1 = require("./dispatcher");
|
|
13
|
+
const exception_1 = require("./exception");
|
|
14
|
+
const function_registry_1 = require("./function-registry");
|
|
15
|
+
const message_transformer_1 = require("./message-transformer");
|
|
16
|
+
const packet_transformer_1 = require("./packet-transformer");
|
|
17
|
+
const sync_compiler_1 = require("./sync-compiler");
|
|
18
|
+
function compile(path, options) {
|
|
19
19
|
// TODO(awjin): Create logger, importer, function registries.
|
|
20
|
-
|
|
21
|
-
path: options.path,
|
|
22
|
-
sourceMap: !!options.sourceMap,
|
|
23
|
-
});
|
|
24
|
-
const response = await compileRequest(request);
|
|
25
|
-
if (options.sourceMap) {
|
|
26
|
-
options.sourceMap(response.sourceMap);
|
|
27
|
-
}
|
|
28
|
-
return response.css;
|
|
20
|
+
return compileRequestSync(newCompilePathRequest(path, options), options);
|
|
29
21
|
}
|
|
30
22
|
exports.compile = compile;
|
|
31
|
-
|
|
32
|
-
* Compiles a string and returns the resulting css. Throws a SassException if
|
|
33
|
-
* the compilation failed.
|
|
34
|
-
*/
|
|
35
|
-
async function compileString(options) {
|
|
23
|
+
function compileString(source, options) {
|
|
36
24
|
// TODO(awjin): Create logger, importer, function registries.
|
|
37
|
-
|
|
38
|
-
const request = newCompileStringRequest({
|
|
39
|
-
source: options.source,
|
|
40
|
-
sourceMap: !!options.sourceMap,
|
|
41
|
-
url: options.url instanceof url_1.URL ? options.url.toString() : options.url,
|
|
42
|
-
syntax: (_a = options.syntax) !== null && _a !== void 0 ? _a : 'scss',
|
|
43
|
-
});
|
|
44
|
-
const response = await compileRequest(request);
|
|
45
|
-
if (options.sourceMap) {
|
|
46
|
-
options.sourceMap(response.sourceMap);
|
|
47
|
-
}
|
|
48
|
-
return response.css;
|
|
25
|
+
return compileRequestSync(newCompileStringRequest(source, options), options);
|
|
49
26
|
}
|
|
50
27
|
exports.compileString = compileString;
|
|
28
|
+
function compileAsync(path, options) {
|
|
29
|
+
// TODO(awjin): Create logger, importer, function registries.
|
|
30
|
+
return compileRequestAsync(newCompilePathRequest(path, options), options);
|
|
31
|
+
}
|
|
32
|
+
exports.compileAsync = compileAsync;
|
|
33
|
+
function compileStringAsync(source, options) {
|
|
34
|
+
// TODO(awjin): Create logger, importer, function registries.
|
|
35
|
+
return compileRequestAsync(newCompileStringRequest(source, options), options);
|
|
36
|
+
}
|
|
37
|
+
exports.compileStringAsync = compileStringAsync;
|
|
51
38
|
// Creates a request for compiling a file.
|
|
52
|
-
function
|
|
39
|
+
function newCompilePathRequest(path, options) {
|
|
53
40
|
// TODO(awjin): Populate request with importer/function IDs.
|
|
54
|
-
const request =
|
|
55
|
-
request.setPath(
|
|
56
|
-
request.setSourceMap(options.sourceMap);
|
|
41
|
+
const request = newCompileRequest(options);
|
|
42
|
+
request.setPath(path);
|
|
57
43
|
return request;
|
|
58
44
|
}
|
|
59
45
|
// Creates a request for compiling a string.
|
|
60
|
-
function newCompileStringRequest(options) {
|
|
46
|
+
function newCompileStringRequest(source, options) {
|
|
61
47
|
// TODO(awjin): Populate request with importer/function IDs.
|
|
48
|
+
var _a;
|
|
62
49
|
const input = new proto.InboundMessage.CompileRequest.StringInput();
|
|
63
|
-
input.setSource(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
50
|
+
input.setSource(source);
|
|
51
|
+
switch ((_a = options === null || options === void 0 ? void 0 : options.syntax) !== null && _a !== void 0 ? _a : 'scss') {
|
|
52
|
+
case 'scss':
|
|
53
|
+
input.setSyntax(proto.Syntax.SCSS);
|
|
54
|
+
break;
|
|
55
|
+
case 'indented':
|
|
56
|
+
input.setSyntax(proto.Syntax.INDENTED);
|
|
57
|
+
break;
|
|
58
|
+
case 'css':
|
|
59
|
+
input.setSyntax(proto.Syntax.CSS);
|
|
60
|
+
break;
|
|
61
|
+
default:
|
|
62
|
+
throw new Error(`Unknown options.syntax: "${options === null || options === void 0 ? void 0 : options.syntax}"`);
|
|
72
63
|
}
|
|
73
|
-
if (options.url)
|
|
64
|
+
if (options === null || options === void 0 ? void 0 : options.url)
|
|
74
65
|
input.setUrl(options.url.toString());
|
|
75
|
-
const request =
|
|
66
|
+
const request = newCompileRequest(options);
|
|
76
67
|
request.setString(input);
|
|
77
|
-
request
|
|
68
|
+
return request;
|
|
69
|
+
}
|
|
70
|
+
// Creates a compilation request for the given `options` without adding any
|
|
71
|
+
// input-specific options.
|
|
72
|
+
function newCompileRequest(options) {
|
|
73
|
+
var _a, _b, _c, _d;
|
|
74
|
+
const request = new proto.InboundMessage.CompileRequest();
|
|
75
|
+
request.setGlobalFunctionsList(Object.keys((_a = options === null || options === void 0 ? void 0 : options.functions) !== null && _a !== void 0 ? _a : {}));
|
|
76
|
+
request.setSourceMap(!!(options === null || options === void 0 ? void 0 : options.sourceMap));
|
|
77
|
+
request.setAlertColor((_b = options === null || options === void 0 ? void 0 : options.alertColor) !== null && _b !== void 0 ? _b : !!supportsColor.stdout);
|
|
78
|
+
request.setAlertAscii(!!(options === null || options === void 0 ? void 0 : options.alertAscii));
|
|
79
|
+
request.setQuietDeps(!!(options === null || options === void 0 ? void 0 : options.quietDeps));
|
|
80
|
+
request.setVerbose(!!(options === null || options === void 0 ? void 0 : options.verbose));
|
|
81
|
+
switch ((_c = options === null || options === void 0 ? void 0 : options.style) !== null && _c !== void 0 ? _c : 'expanded') {
|
|
82
|
+
case 'expanded':
|
|
83
|
+
request.setStyle(proto.OutputStyle.EXPANDED);
|
|
84
|
+
break;
|
|
85
|
+
case 'compressed':
|
|
86
|
+
request.setStyle(proto.OutputStyle.COMPRESSED);
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
throw new Error(`Unknown options.style: "${options === null || options === void 0 ? void 0 : options.style}"`);
|
|
90
|
+
}
|
|
91
|
+
for (const path of (_d = options === null || options === void 0 ? void 0 : options.loadPaths) !== null && _d !== void 0 ? _d : []) {
|
|
92
|
+
const importer = new proto.InboundMessage.CompileRequest.Importer();
|
|
93
|
+
importer.setPath(p.resolve(path));
|
|
94
|
+
request.addImporters(importer);
|
|
95
|
+
}
|
|
78
96
|
return request;
|
|
79
97
|
}
|
|
80
98
|
// Spins up a compiler, then sends it a compile request. Returns a promise that
|
|
81
99
|
// resolves with the CompileResult. Throws if there were any protocol or
|
|
82
100
|
// compilation errors. Shuts down the compiler after compilation.
|
|
83
|
-
async function
|
|
84
|
-
const
|
|
101
|
+
async function compileRequestAsync(request, options) {
|
|
102
|
+
const functionRegistry = new function_registry_1.FunctionRegistry(options === null || options === void 0 ? void 0 : options.functions);
|
|
103
|
+
const embeddedCompiler = new async_compiler_1.AsyncEmbeddedCompiler();
|
|
85
104
|
try {
|
|
86
|
-
const packetTransformer = new packet_transformer_1.PacketTransformer(embeddedCompiler.stdout$, buffer => embeddedCompiler.writeStdin(buffer));
|
|
87
|
-
const messageTransformer = new message_transformer_1.MessageTransformer(packetTransformer.outboundProtobufs$, packet => packetTransformer.writeInboundProtobuf(packet));
|
|
88
105
|
// TODO(awjin): Pass import and function registries' handler functions to
|
|
89
106
|
// dispatcher.
|
|
90
|
-
const dispatcher =
|
|
107
|
+
const dispatcher = createDispatcher(embeddedCompiler.stdout$, buffer => {
|
|
108
|
+
embeddedCompiler.writeStdin(buffer);
|
|
109
|
+
}, {
|
|
91
110
|
handleImportRequest: () => {
|
|
92
111
|
throw Error('Custom importers not yet implemented.');
|
|
93
112
|
},
|
|
@@ -97,33 +116,102 @@ async function compileRequest(request) {
|
|
|
97
116
|
handleCanonicalizeRequest: () => {
|
|
98
117
|
throw Error('Canonicalize not yet implemented.');
|
|
99
118
|
},
|
|
100
|
-
handleFunctionCallRequest:
|
|
101
|
-
|
|
119
|
+
handleFunctionCallRequest: request => functionRegistry.call(request),
|
|
120
|
+
});
|
|
121
|
+
// TODO(awjin): Subscribe logger to dispatcher's log events.
|
|
122
|
+
return handleCompileResponse(await new Promise((resolve, reject) => dispatcher.sendCompileRequest(request, (err, response) => {
|
|
123
|
+
if (err) {
|
|
124
|
+
reject(err);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
resolve(response);
|
|
128
|
+
}
|
|
129
|
+
})));
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
embeddedCompiler.close();
|
|
133
|
+
await embeddedCompiler.exit$;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Spins up a compiler, then sends it a compile request. Returns a promise that
|
|
137
|
+
// resolves with the CompileResult. Throws if there were any protocol or
|
|
138
|
+
// compilation errors. Shuts down the compiler after compilation.
|
|
139
|
+
function compileRequestSync(request, options) {
|
|
140
|
+
const functionRegistry = new function_registry_1.FunctionRegistry(options === null || options === void 0 ? void 0 : options.functions);
|
|
141
|
+
const embeddedCompiler = new sync_compiler_1.SyncEmbeddedCompiler();
|
|
142
|
+
try {
|
|
143
|
+
// TODO(awjin): Pass import and function registries' handler functions to
|
|
144
|
+
// dispatcher.
|
|
145
|
+
const dispatcher = createDispatcher(embeddedCompiler.stdout$, buffer => {
|
|
146
|
+
embeddedCompiler.writeStdin(buffer);
|
|
147
|
+
}, {
|
|
148
|
+
handleImportRequest: () => {
|
|
149
|
+
throw Error('Custom importers not yet implemented.');
|
|
150
|
+
},
|
|
151
|
+
handleFileImportRequest: () => {
|
|
152
|
+
throw Error('Custom file importers not yet implemented.');
|
|
153
|
+
},
|
|
154
|
+
handleCanonicalizeRequest: () => {
|
|
155
|
+
throw Error('Canonicalize not yet implemented.');
|
|
102
156
|
},
|
|
157
|
+
handleFunctionCallRequest: request => functionRegistry.call(request),
|
|
103
158
|
});
|
|
104
159
|
// TODO(awjin): Subscribe logger to dispatcher's log events.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
throw Error('Compiler did not provide sourceMap.');
|
|
160
|
+
let error;
|
|
161
|
+
let response;
|
|
162
|
+
dispatcher.sendCompileRequest(request, (error_, response_) => {
|
|
163
|
+
if (error_) {
|
|
164
|
+
error = error_;
|
|
111
165
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
166
|
+
else {
|
|
167
|
+
response = response_;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
for (;;) {
|
|
171
|
+
if (!embeddedCompiler.yield()) {
|
|
172
|
+
throw utils.compilerError('Embedded compiler exited unexpectedly.');
|
|
173
|
+
}
|
|
174
|
+
if (error)
|
|
175
|
+
throw error;
|
|
176
|
+
if (response)
|
|
177
|
+
return handleCompileResponse(response);
|
|
122
178
|
}
|
|
123
179
|
}
|
|
124
180
|
finally {
|
|
125
181
|
embeddedCompiler.close();
|
|
126
|
-
|
|
182
|
+
embeddedCompiler.yieldUntilExit();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Creates a dispatcher that dispatches messages from the given `stdout` stream.
|
|
187
|
+
*/
|
|
188
|
+
function createDispatcher(stdout, writeStdin, handlers) {
|
|
189
|
+
const packetTransformer = new packet_transformer_1.PacketTransformer(stdout, writeStdin);
|
|
190
|
+
const messageTransformer = new message_transformer_1.MessageTransformer(packetTransformer.outboundProtobufs$, packet => packetTransformer.writeInboundProtobuf(packet));
|
|
191
|
+
return new dispatcher_1.Dispatcher(messageTransformer.outboundMessages$, message => messageTransformer.writeInboundMessage(message), handlers);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Converts a `CompileResponse` into a `CompileResult`.
|
|
195
|
+
*
|
|
196
|
+
* Throws a `SassException` if the compilation failed.
|
|
197
|
+
*/
|
|
198
|
+
function handleCompileResponse(response) {
|
|
199
|
+
if (response.getSuccess()) {
|
|
200
|
+
const success = response.getSuccess();
|
|
201
|
+
const result = {
|
|
202
|
+
css: success.getCss(),
|
|
203
|
+
loadedUrls: success.getLoadedUrlsList().map(url => new URL(url)),
|
|
204
|
+
};
|
|
205
|
+
const sourceMap = success.getSourceMap();
|
|
206
|
+
if (sourceMap)
|
|
207
|
+
result.sourceMap = JSON.parse(sourceMap);
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
else if (response.getFailure()) {
|
|
211
|
+
throw new exception_1.Exception(response.getFailure());
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
throw utils.compilerError('Compiler sent empty CompileResponse.');
|
|
127
215
|
}
|
|
128
216
|
}
|
|
129
217
|
//# sourceMappingURL=compile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../../lib/src/compile.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../../lib/src/compile.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,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C,QAAQ,CAAC,UAAU,EAAG,CAAC,CAAC;KAC7C;SAAM;QACL,MAAM,KAAK,CAAC,aAAa,CAAC,sCAAsC,CAAC,CAAC;KACnE;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021 Google LLC. Use of this source code is governed by an
|
|
3
|
+
// MIT-style license that can be found in the LICENSE file or at
|
|
4
|
+
// https://opensource.org/licenses/MIT.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.compilerPath = void 0;
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const p = require("path");
|
|
9
|
+
/** The path to the embedded compiler executable. */
|
|
10
|
+
exports.compilerPath = (() => {
|
|
11
|
+
for (const path of ['vendor', '../../../lib/src/vendor']) {
|
|
12
|
+
const executable = p.resolve(__dirname, path, `dart-sass-embedded/dart-sass-embedded${process.platform === 'win32' ? '.bat' : ''}`);
|
|
13
|
+
if (fs.existsSync(executable))
|
|
14
|
+
return executable;
|
|
15
|
+
}
|
|
16
|
+
throw new Error("Embedded Dart Sass couldn't find the embedded compiler executable.");
|
|
17
|
+
})();
|
|
18
|
+
//# sourceMappingURL=compiler-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler-path.js","sourceRoot":"","sources":["../../../lib/src/compiler-path.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,yBAAyB;AACzB,0BAA0B;AAE1B,oDAAoD;AACvC,QAAA,YAAY,GAAG,CAAC,GAAG,EAAE;IAChC,KAAK,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,yBAAyB,CAAC,EAAE;QACxD,MAAM,UAAU,GAAG,CAAC,CAAC,OAAO,CAC1B,SAAS,EACT,IAAI,EACJ,wCACE,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAC1C,EAAE,CACH,CAAC;QAEF,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,OAAO,UAAU,CAAC;KAClD;IAED,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// Copyright 2021 Google LLC. Use of this source code is governed by an
|
|
3
|
+
// MIT-style license that can be found in the LICENSE file or at
|
|
4
|
+
// https://opensource.org/licenses/MIT.
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
/**
|
|
7
|
-
* Creates a SassException from the given protocol `buffer`. Throws if the
|
|
8
|
-
* buffer has invalid fields.
|
|
9
|
-
*/
|
|
10
|
-
function deprotifyException(buffer) {
|
|
11
|
-
const span = buffer.getSpan();
|
|
12
|
-
return new exception_1.SassException(buffer.getMessage(), buffer.getFormatted(), span ? deprotifySourceSpan(span) : undefined, buffer.getStackTrace());
|
|
13
|
-
}
|
|
14
|
-
exports.deprotifyException = deprotifyException;
|
|
6
|
+
exports.deprotofySourceSpan = void 0;
|
|
7
|
+
const url_1 = require("url");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
15
9
|
// Creates a SourceSpan from the given protocol `buffer`. Throws if the buffer
|
|
16
10
|
// has invalid fields.
|
|
17
|
-
function
|
|
11
|
+
function deprotofySourceSpan(buffer) {
|
|
18
12
|
const text = buffer.getText();
|
|
19
13
|
if (buffer.getStart() === undefined) {
|
|
20
14
|
throw (0, utils_1.compilerError)('Expected SourceSpan to have start.');
|
|
21
15
|
}
|
|
22
|
-
const start =
|
|
16
|
+
const start = deprotofySourceLocation(buffer.getStart());
|
|
23
17
|
let end;
|
|
24
18
|
if (buffer.getEnd() === undefined) {
|
|
25
19
|
if (text !== '') {
|
|
26
20
|
throw (0, utils_1.compilerError)('Expected SourceSpan text to be empty.');
|
|
27
21
|
}
|
|
22
|
+
else {
|
|
23
|
+
end = start;
|
|
24
|
+
}
|
|
28
25
|
}
|
|
29
26
|
else {
|
|
30
|
-
end =
|
|
27
|
+
end = deprotofySourceLocation(buffer.getEnd());
|
|
31
28
|
if (end.offset < start.offset) {
|
|
32
29
|
throw (0, utils_1.compilerError)('Expected SourceSpan end to be after start.');
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
|
-
const url = buffer.getUrl() === '' ? undefined : buffer.getUrl();
|
|
32
|
+
const url = buffer.getUrl() === '' ? undefined : new url_1.URL(buffer.getUrl());
|
|
36
33
|
const context = buffer.getContext() === '' ? undefined : buffer.getContext();
|
|
37
34
|
return {
|
|
38
35
|
text,
|
|
@@ -42,12 +39,13 @@ function deprotifySourceSpan(buffer) {
|
|
|
42
39
|
context,
|
|
43
40
|
};
|
|
44
41
|
}
|
|
42
|
+
exports.deprotofySourceSpan = deprotofySourceSpan;
|
|
45
43
|
// Creates a SourceLocation from the given protocol `buffer`.
|
|
46
|
-
function
|
|
44
|
+
function deprotofySourceLocation(buffer) {
|
|
47
45
|
return {
|
|
48
46
|
offset: buffer.getOffset(),
|
|
49
47
|
line: buffer.getLine(),
|
|
50
48
|
column: buffer.getColumn(),
|
|
51
49
|
};
|
|
52
50
|
}
|
|
53
|
-
//# sourceMappingURL=
|
|
51
|
+
//# sourceMappingURL=deprotofy-span.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprotofy-span.js","sourceRoot":"","sources":["../../../lib/src/deprotofy-span.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,6BAAwB;AAIxB,mCAAsC;AAEtC,8EAA8E;AAC9E,sBAAsB;AACtB,SAAgB,mBAAmB,CAAC,MAAwB;IAC1D,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAE9B,IAAI,MAAM,CAAC,QAAQ,EAAE,KAAK,SAAS,EA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