sass-embedded 1.0.0-beta.1 → 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.
Files changed (116) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/README.md +3 -3
  3. package/dist/.gitignore +2 -1
  4. package/dist/lib/index.js +29 -2
  5. package/dist/lib/index.js.map +1 -1
  6. package/dist/lib/src/{embedded/compiler.js → async-compiler.js} +13 -13
  7. package/dist/lib/src/async-compiler.js.map +1 -0
  8. package/dist/lib/src/compile.js +170 -69
  9. package/dist/lib/src/compile.js.map +1 -1
  10. package/dist/lib/src/compiler-path.js +18 -0
  11. package/dist/lib/src/compiler-path.js.map +1 -0
  12. package/dist/lib/src/deprotofy-span.js +51 -0
  13. package/dist/lib/src/deprotofy-span.js.map +1 -0
  14. package/dist/lib/src/{embedded/dispatcher.js → dispatcher.js} +63 -57
  15. package/dist/lib/src/dispatcher.js.map +1 -0
  16. package/dist/lib/src/exception.js +20 -0
  17. package/dist/lib/src/exception.js.map +1 -0
  18. package/dist/lib/src/function-registry.js +81 -0
  19. package/dist/lib/src/function-registry.js.map +1 -0
  20. package/dist/lib/src/legacy.js +133 -0
  21. package/dist/lib/src/legacy.js.map +1 -0
  22. package/dist/lib/src/{embedded/message-transformer.js → message-transformer.js} +35 -34
  23. package/dist/lib/src/message-transformer.js.map +1 -0
  24. package/dist/lib/src/{embedded/packet-transformer.js → packet-transformer.js} +2 -1
  25. package/dist/lib/src/packet-transformer.js.map +1 -0
  26. package/dist/lib/src/protofier.js +205 -0
  27. package/dist/lib/src/protofier.js.map +1 -0
  28. package/dist/lib/src/{embedded/request-tracker.js → request-tracker.js} +1 -0
  29. package/dist/lib/src/request-tracker.js.map +1 -0
  30. package/dist/lib/src/sync-compiler.js +52 -0
  31. package/dist/lib/src/sync-compiler.js.map +1 -0
  32. package/dist/lib/src/{exception/span.js → sync-process/event.js} +2 -2
  33. package/dist/lib/src/sync-process/event.js.map +1 -0
  34. package/dist/lib/src/sync-process/index.js +122 -0
  35. package/dist/lib/src/sync-process/index.js.map +1 -0
  36. package/dist/lib/src/sync-process/sync-message-port.js +128 -0
  37. package/dist/lib/src/sync-process/sync-message-port.js.map +1 -0
  38. package/dist/lib/src/sync-process/worker.js +51 -0
  39. package/dist/lib/src/sync-process/worker.js.map +1 -0
  40. package/dist/lib/src/utils.js +64 -42
  41. package/dist/lib/src/utils.js.map +1 -1
  42. package/dist/lib/src/value/boolean.js +40 -0
  43. package/dist/lib/src/value/boolean.js.map +1 -0
  44. package/dist/lib/src/value/color.js +258 -0
  45. package/dist/lib/src/value/color.js.map +1 -0
  46. package/dist/lib/src/value/index.js +147 -0
  47. package/dist/lib/src/value/index.js.map +1 -0
  48. package/dist/lib/src/value/list.js +99 -0
  49. package/dist/lib/src/value/list.js.map +1 -0
  50. package/dist/lib/src/value/map.js +91 -0
  51. package/dist/lib/src/value/map.js.map +1 -0
  52. package/dist/lib/src/value/null.js +35 -0
  53. package/dist/lib/src/value/null.js.map +1 -0
  54. package/dist/lib/src/value/number.js +579 -0
  55. package/dist/lib/src/value/number.js.map +1 -0
  56. package/dist/lib/src/value/string.js +117 -0
  57. package/dist/lib/src/value/string.js.map +1 -0
  58. package/dist/lib/src/value/utils.js +120 -0
  59. package/dist/lib/src/value/utils.js.map +1 -0
  60. package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.js +1738 -261
  61. package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.js.map +1 -1
  62. package/dist/package.json +63 -0
  63. package/dist/tool/utils.js +78 -90
  64. package/dist/tool/utils.js.map +1 -1
  65. package/dist/types/compile.d.ts +152 -0
  66. package/dist/types/exception.d.ts +41 -0
  67. package/dist/types/importer.d.ts +294 -0
  68. package/dist/types/index.d.ts +76 -0
  69. package/dist/types/legacy/exception.d.ts +54 -0
  70. package/dist/types/legacy/function.d.ts +652 -0
  71. package/dist/types/legacy/importer.d.ts +168 -0
  72. package/dist/types/legacy/options.d.ts +642 -0
  73. package/dist/types/legacy/plugin_this.d.ts +70 -0
  74. package/dist/types/legacy/render.d.ts +139 -0
  75. package/dist/types/logger/index.d.ts +94 -0
  76. package/dist/types/logger/source_location.d.ts +21 -0
  77. package/dist/types/logger/source_span.d.ts +34 -0
  78. package/dist/types/options.d.ts +408 -0
  79. package/dist/types/util/promise_or.d.ts +17 -0
  80. package/dist/types/value/argument_list.d.ts +47 -0
  81. package/dist/types/value/boolean.d.ts +29 -0
  82. package/dist/types/value/color.d.ts +107 -0
  83. package/dist/types/value/function.d.ts +22 -0
  84. package/dist/types/value/index.d.ts +173 -0
  85. package/dist/types/value/list.d.ts +54 -0
  86. package/dist/types/value/map.d.ts +41 -0
  87. package/dist/types/value/number.d.ts +305 -0
  88. package/dist/types/value/string.d.ts +84 -0
  89. package/download-compiler-for-end-user.js +1 -6
  90. package/package.json +25 -21
  91. package/dist/lib/index.d.ts +0 -1
  92. package/dist/lib/src/compile.d.ts +0 -20
  93. package/dist/lib/src/embedded/compiler.d.ts +0 -19
  94. package/dist/lib/src/embedded/compiler.js.map +0 -1
  95. package/dist/lib/src/embedded/dispatcher.d.ts +0 -60
  96. package/dist/lib/src/embedded/dispatcher.js.map +0 -1
  97. package/dist/lib/src/embedded/message-transformer.d.ts +0 -47
  98. package/dist/lib/src/embedded/message-transformer.js.map +0 -1
  99. package/dist/lib/src/embedded/packet-transformer.d.ts +0 -34
  100. package/dist/lib/src/embedded/packet-transformer.js.map +0 -1
  101. package/dist/lib/src/embedded/request-tracker.d.ts +0 -20
  102. package/dist/lib/src/embedded/request-tracker.js.map +0 -1
  103. package/dist/lib/src/exception/exception.d.ts +0 -19
  104. package/dist/lib/src/exception/exception.js +0 -36
  105. package/dist/lib/src/exception/exception.js.map +0 -1
  106. package/dist/lib/src/exception/location.d.ts +0 -11
  107. package/dist/lib/src/exception/location.js +0 -6
  108. package/dist/lib/src/exception/location.js.map +0 -1
  109. package/dist/lib/src/exception/span.d.ts +0 -29
  110. package/dist/lib/src/exception/span.js.map +0 -1
  111. package/dist/lib/src/node-sass/render.d.ts +0 -60
  112. package/dist/lib/src/node-sass/render.js +0 -125
  113. package/dist/lib/src/node-sass/render.js.map +0 -1
  114. package/dist/lib/src/utils.d.ts +0 -14
  115. package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.d.ts +0 -1
  116. package/dist/tool/utils.d.ts +0 -29
package/CHANGELOG.md CHANGED
@@ -1,6 +1,54 @@
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
+
19
+ ## 1.0.0-beta.5
20
+
21
+ - Function and Values API
22
+ - Add `SassColor` class.
23
+ - Add `SassList` and `SassMap` classes.
24
+
25
+ - Add `indentedSyntax` option to `render()`
26
+
27
+ ## 1.0.0-beta.4
28
+
29
+ - Allow installing on arm64.
30
+
31
+ - Function and Values API
32
+ - Add `sassTrue` and `sassFalse` singletons.
33
+ - Add `SassColor` class.
34
+ - Add `SassNumber` class.
35
+ - Add `SassString` class.
36
+
37
+ ## 1.0.0-beta.3
38
+
39
+ - Properly handle `data:` URIs in sourceMap sources.
40
+
41
+ - Function and Values API
42
+ - Add `Value` abstract class.
43
+ - Add `sassNull` singleton.
44
+
45
+ ## 1.0.0-beta.2
46
+
47
+ - No user visible changes.
48
+
1
49
  ## 1.0.0-beta.1
2
50
 
3
- - Downlaod the compiler binary to the correct directory on Windows.
51
+ - Download the compiler binary to the correct directory on Windows.
4
52
 
5
53
  ## 1.0.0-beta.0
6
54
 
package/README.md CHANGED
@@ -6,8 +6,8 @@ Sass][] executable. It's much faster than running [Dart Sass compiled to
6
6
  JavaScript][] while still providing a full JS API, with the ability to define
7
7
  custom functions and importers.
8
8
 
9
- [Embedded Sass protocol]: https://github.com/sass/sass-embedded-protocol/blob/master/README.md#readme
10
- [Dart Sass]: https://sass-lang.com/dart-sass
11
- [Dart Sass compiled to JavaScript]: https://www.npmjs.com/package/sass
9
+ [embedded sass protocol]: https://github.com/sass/sass-embedded-protocol/blob/main/README.md#readme
10
+ [dart sass]: https://sass-lang.com/dart-sass
11
+ [dart sass compiled to javascript]: https://www.npmjs.com/package/sass
12
12
 
13
13
  Disclaimer: this is not an official Google product.
package/dist/.gitignore CHANGED
@@ -1,10 +1,11 @@
1
1
  .DS_Store
2
+ build
2
3
  dist
3
4
  lib/src/vendor
4
5
  node_modules
5
6
  npm-debug.log*
6
7
  package-lock.json
7
- build/
8
+ test/sandbox
8
9
 
9
10
  # Editors
10
11
  .idea
package/dist/lib/index.js CHANGED
@@ -3,6 +3,33 @@
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
- var render_1 = require("./src/node-sass/render");
7
- exports.render = render_1.render;
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
+ const pkg = require("../package.json");
8
+ var value_1 = require("./src/value");
9
+ Object.defineProperty(exports, "Value", { enumerable: true, get: function () { return value_1.Value; } });
10
+ var boolean_1 = require("./src/value/boolean");
11
+ Object.defineProperty(exports, "sassFalse", { enumerable: true, get: function () { return boolean_1.sassFalse; } });
12
+ Object.defineProperty(exports, "sassTrue", { enumerable: true, get: function () { return boolean_1.sassTrue; } });
13
+ var color_1 = require("./src/value/color");
14
+ Object.defineProperty(exports, "SassColor", { enumerable: true, get: function () { return color_1.SassColor; } });
15
+ var list_1 = require("./src/value/list");
16
+ Object.defineProperty(exports, "SassList", { enumerable: true, get: function () { return list_1.SassList; } });
17
+ var map_1 = require("./src/value/map");
18
+ Object.defineProperty(exports, "SassMap", { enumerable: true, get: function () { return map_1.SassMap; } });
19
+ var null_1 = require("./src/value/null");
20
+ Object.defineProperty(exports, "sassNull", { enumerable: true, get: function () { return null_1.sassNull; } });
21
+ var number_1 = require("./src/value/number");
22
+ Object.defineProperty(exports, "SassNumber", { enumerable: true, get: function () { return number_1.SassNumber; } });
23
+ var string_1 = require("./src/value/string");
24
+ Object.defineProperty(exports, "SassString", { enumerable: true, get: function () { return string_1.SassString; } });
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; } });
34
+ exports.info = `sass-embedded\t${pkg.version}`;
8
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;AAEvC,iDAKgC;AAJ9B,0BAAA,MAAM,CAAA"}
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,31 +3,31 @@
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.AsyncEmbeddedCompiler = void 0;
6
7
  const child_process_1 = require("child_process");
7
- const path_1 = require("path");
8
8
  const rxjs_1 = require("rxjs");
9
9
  const operators_1 = require("rxjs/operators");
10
+ const compiler_path_1 = require("./compiler-path");
10
11
  /**
11
- * Invokes the Embedded Sass Compiler as a Node child process, exposing its
12
- * stdio as Observables.
12
+ * An asynchronous wrapper for the embedded Sass compiler that exposes its stdio
13
+ * streams as Observables.
13
14
  */
14
- class EmbeddedCompiler {
15
+ class AsyncEmbeddedCompiler {
15
16
  constructor() {
16
- this.process = child_process_1.spawn(path_1.resolve(__dirname, `../vendor/dart-sass-embedded/dart-sass-embedded${process.platform === 'win32' ? '.bat' : ''}`), {
17
- windowsHide: true,
18
- });
17
+ /** The underlying process that's being wrapped. */
18
+ this.process = (0, child_process_1.spawn)(compiler_path_1.compilerPath, { windowsHide: true });
19
19
  /** The child process's exit event. */
20
- this.exit$ = new rxjs_1.Observable(observer => {
21
- this.process.on('exit', code => observer.next(code));
20
+ this.exit$ = new Promise(resolve => {
21
+ this.process.on('exit', code => resolve(code));
22
22
  });
23
23
  /** The buffers emitted by the child process's stdout. */
24
24
  this.stdout$ = new rxjs_1.Observable(observer => {
25
25
  this.process.stdout.on('data', buffer => observer.next(buffer));
26
- }).pipe(operators_1.takeUntil(this.exit$));
26
+ }).pipe((0, operators_1.takeUntil)(this.exit$));
27
27
  /** The buffers emitted by the child process's stderr. */
28
28
  this.stderr$ = new rxjs_1.Observable(observer => {
29
29
  this.process.stderr.on('data', buffer => observer.next(buffer));
30
- }).pipe(operators_1.takeUntil(this.exit$));
30
+ }).pipe((0, operators_1.takeUntil)(this.exit$));
31
31
  }
32
32
  /** Writes `buffer` to the child process's stdin. */
33
33
  writeStdin(buffer) {
@@ -38,5 +38,5 @@ class EmbeddedCompiler {
38
38
  this.process.stdin.end();
39
39
  }
40
40
  }
41
- exports.EmbeddedCompiler = EmbeddedCompiler;
42
- //# 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,qBAAqB;IAAlC;QACE,mDAAmD;QAClC,YAAO,GAAG,IAAA,qBAAK,EAAC,4BAAY,EAAE,EAAC,WAAW,EAAE,IAAI,EAAC,CAAC,CAAC;QAEpE,sCAAsC;QAC7B,UAAK,GAAG,IAAI,OAAO,CAAgB,OAAO,CAAC,EAAE;YACpD,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,yDAAyD;QAChD,YAAO,GAAG,IAAI,iBAAU,CAAS,QAAQ,CAAC,EAAE;YACnD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,qBAAS,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAE/B,yDAAyD;QAChD,YAAO,GAAG,IAAI,iBAAU,CAAS,QAAQ,CAAC,EAAE;YACnD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAA,qBAAS,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAWjC,CAAC;IATC,oDAAoD;IACpD,UAAU,CAAC,MAAc;QACvB,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,uEAAuE;IACvE,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IAC3B,CAAC;CACF;AA5BD,sDA4BC"}
@@ -3,79 +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
- const url_1 = require("url");
7
- const compiler_1 = require("./embedded/compiler");
8
- const dispatcher_1 = require("./embedded/dispatcher");
9
- const message_transformer_1 = require("./embedded/message-transformer");
10
- const packet_transformer_1 = require("./embedded/packet-transformer");
11
- const utils_1 = require("./utils");
12
- const embedded_sass_pb_1 = require("./vendor/embedded-protocol/embedded_sass_pb");
13
- /**
14
- * Compiles a path and returns the resulting css. Throws a SassException if the
15
- * compilation failed.
16
- */
17
- async function compile(options) {
6
+ exports.compileStringAsync = exports.compileAsync = exports.compileString = exports.compile = void 0;
7
+ const p = require("path");
8
+ const supportsColor = require("supports-color");
9
+ const proto = require("./vendor/embedded-protocol/embedded_sass_pb");
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) {
18
19
  // TODO(awjin): Create logger, importer, function registries.
19
- const request = newCompileRequest({
20
- path: options.path,
21
- sourceMap: !!options.sourceMap,
22
- });
23
- const response = await compileRequest(request);
24
- if (options.sourceMap) {
25
- options.sourceMap(response.sourceMap);
26
- }
27
- return response.css;
20
+ return compileRequestSync(newCompilePathRequest(path, options), options);
28
21
  }
29
22
  exports.compile = compile;
30
- /**
31
- * Compiles a string and returns the resulting css. Throws a SassException if
32
- * the compilation failed.
33
- */
34
- async function compileString(options) {
23
+ function compileString(source, options) {
35
24
  // TODO(awjin): Create logger, importer, function registries.
36
- const request = newCompileStringRequest({
37
- source: options.source,
38
- sourceMap: !!options.sourceMap,
39
- url: options.url instanceof url_1.URL ? options.url.toString() : options.url,
40
- });
41
- const response = await compileRequest(request);
42
- if (options.sourceMap) {
43
- options.sourceMap(response.sourceMap);
44
- }
45
- return response.css;
25
+ return compileRequestSync(newCompileStringRequest(source, options), options);
46
26
  }
47
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;
48
38
  // Creates a request for compiling a file.
49
- function newCompileRequest(options) {
39
+ function newCompilePathRequest(path, options) {
50
40
  // TODO(awjin): Populate request with importer/function IDs.
51
- const request = new embedded_sass_pb_1.InboundMessage.CompileRequest();
52
- request.setPath(options.path);
53
- request.setSourceMap(options.sourceMap);
41
+ const request = newCompileRequest(options);
42
+ request.setPath(path);
54
43
  return request;
55
44
  }
56
45
  // Creates a request for compiling a string.
57
- function newCompileStringRequest(options) {
46
+ function newCompileStringRequest(source, options) {
58
47
  // TODO(awjin): Populate request with importer/function IDs.
59
- const input = new embedded_sass_pb_1.InboundMessage.CompileRequest.StringInput();
60
- input.setSource(options.source);
61
- if (options.url)
48
+ var _a;
49
+ const input = new proto.InboundMessage.CompileRequest.StringInput();
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}"`);
63
+ }
64
+ if (options === null || options === void 0 ? void 0 : options.url)
62
65
  input.setUrl(options.url.toString());
63
- const request = new embedded_sass_pb_1.InboundMessage.CompileRequest();
66
+ const request = newCompileRequest(options);
64
67
  request.setString(input);
65
- request.setSourceMap(options.sourceMap);
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
+ }
66
96
  return request;
67
97
  }
68
98
  // Spins up a compiler, then sends it a compile request. Returns a promise that
69
99
  // resolves with the CompileResult. Throws if there were any protocol or
70
100
  // compilation errors. Shuts down the compiler after compilation.
71
- async function compileRequest(request) {
72
- const embeddedCompiler = new compiler_1.EmbeddedCompiler();
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();
73
104
  try {
74
- const packetTransformer = new packet_transformer_1.PacketTransformer(embeddedCompiler.stdout$, buffer => embeddedCompiler.writeStdin(buffer));
75
- const messageTransformer = new message_transformer_1.MessageTransformer(packetTransformer.outboundProtobufs$, packet => packetTransformer.writeInboundProtobuf(packet));
76
105
  // TODO(awjin): Pass import and function registries' handler functions to
77
106
  // dispatcher.
78
- const dispatcher = new dispatcher_1.Dispatcher(messageTransformer.outboundMessages$, message => messageTransformer.writeInboundMessage(message), {
107
+ const dispatcher = createDispatcher(embeddedCompiler.stdout$, buffer => {
108
+ embeddedCompiler.writeStdin(buffer);
109
+ }, {
79
110
  handleImportRequest: () => {
80
111
  throw Error('Custom importers not yet implemented.');
81
112
  },
@@ -85,32 +116,102 @@ async function compileRequest(request) {
85
116
  handleCanonicalizeRequest: () => {
86
117
  throw Error('Canonicalize not yet implemented.');
87
118
  },
88
- handleFunctionCallRequest: () => {
89
- throw Error('Custom functions not yet implemented.');
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.');
90
153
  },
154
+ handleCanonicalizeRequest: () => {
155
+ throw Error('Canonicalize not yet implemented.');
156
+ },
157
+ handleFunctionCallRequest: request => functionRegistry.call(request),
91
158
  });
92
159
  // TODO(awjin): Subscribe logger to dispatcher's log events.
93
- const response = await dispatcher.sendCompileRequest(request);
94
- if (response.getSuccess()) {
95
- const success = response.getSuccess();
96
- const sourceMap = success.getSourceMap();
97
- if (request.getSourceMap() && sourceMap === undefined) {
98
- 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_;
99
165
  }
100
- return {
101
- css: success.getCss(),
102
- sourceMap: sourceMap ? JSON.parse(sourceMap) : undefined,
103
- };
104
- }
105
- else if (response.getFailure()) {
106
- throw utils_1.deprotifyException(response.getFailure());
107
- }
108
- else {
109
- throw Error('Compiler sent empty CompileResponse.');
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);
110
178
  }
111
179
  }
112
180
  finally {
113
181
  embeddedCompiler.close();
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.');
114
215
  }
115
216
  }
116
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;;AAGvC,6BAAwB;AAExB,kDAAqD;AACrD,sDAAiD;AACjD,wEAAkE;AAClE,sEAAgE;AAChE,mCAA2C;AAC3C,kFAA2E;AAE3E;;;GAGG;AACI,KAAK,UAAU,OAAO,CAAC,OAG7B;IACC,6DAA6D;IAE7D,MAAM,OAAO,GAAG,iBAAiB,CAAC;QAChC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS;KAC/B,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC;IAC/C,IAAI,OAAO,CAAC,SAAS,EAAE;QACrB,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAU,CAAC,CAAC;KACxC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC;AACtB,CAAC;AAhBD,0BAgBC;AAED;;;GAGG;AACI,KAAK,UAAU,aAAa,CAAC,OAInC;IACC,6DAA6D;IAE7D,MAAM,OAAO,GAAG,uBAAuB,CAAC;QACtC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS;QAC9B,GAAG,EAAE,OAAO,CAAC,GAAG,YAAY,SAAG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AqB,CAC5B,QAA+C;IAE/C,IAAI,QAAQ,CAAC,UAAU,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAG,CAAC;QACvC,MAAM,MAAM,GAAkB;YAC5B,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE;YACrB,UAAU,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;SACjE,CAAC;QAEF,MAAM,SAAS,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;QACzC,IAAI,SAAS;YAAE,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC;KACf;SAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,EAAE;QAChC,MAAM,IAAI,qBAAS,CAAC,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"}
@@ -0,0 +1,51 @@
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.deprotofySourceSpan = void 0;
7
+ const url_1 = require("url");
8
+ const utils_1 = require("./utils");
9
+ // Creates a SourceSpan from the given protocol `buffer`. Throws if the buffer
10
+ // has invalid fields.
11
+ function deprotofySourceSpan(buffer) {
12
+ const text = buffer.getText();
13
+ if (buffer.getStart() === undefined) {
14
+ throw (0, utils_1.compilerError)('Expected SourceSpan to have start.');
15
+ }
16
+ const start = deprotofySourceLocation(buffer.getStart());
17
+ let end;
18
+ if (buffer.getEnd() === undefined) {
19
+ if (text !== '') {
20
+ throw (0, utils_1.compilerError)('Expected SourceSpan text to be empty.');
21
+ }
22
+ else {
23
+ end = start;
24
+ }
25
+ }
26
+ else {
27
+ end = deprotofySourceLocation(buffer.getEnd());
28
+ if (end.offset < start.offset) {
29
+ throw (0, utils_1.compilerError)('Expected SourceSpan end to be after start.');
30
+ }
31
+ }
32
+ const url = buffer.getUrl() === '' ? undefined : new url_1.URL(buffer.getUrl());
33
+ const context = buffer.getContext() === '' ? undefined : buffer.getContext();
34
+ return {
35
+ text,
36
+ start,
37
+ end,
38
+ url,
39
+ context,
40
+ };
41
+ }
42
+ exports.deprotofySourceSpan = deprotofySourceSpan;
43
+ // Creates a SourceLocation from the given protocol `buffer`.
44
+ function deprotofySourceLocation(buffer) {
45
+ return {
46
+ offset: buffer.getOffset(),
47
+ line: buffer.getLine(),
48
+ column: buffer.getColumn(),
49
+ };
50
+ }
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,EAAE;QACnC,MAAM,IAAA,qBAAa,EAAC,oCAAoC,CAAC,CAAC;KAC3D;IACD,MAAM,KAAK,GAAG,uBAAuB,CAAC,MAAM,CAAC,QAAQ,EAAG,CAAC,CAAC;IAE1D,IAAI,GAAG,CAAC;IACR,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,SAAS,EAAE;QACjC,IAAI,IAAI,KAAK,EAAE,EAAE;YACf,MAAM,IAAA,qBAAa,EAAC,uCAAuC,CAAC,CAAC;SAC9D;aAAM;YACL,GAAG,GAAG,KAAK,CAAC;SACb;KACF;SAAM;QACL,GAAG,GAAG,uBAAuB,CAAC,MAAM,CAAC,MAAM,EAAG,CAAC,CAAC;QAChD,IAAI,GAAG,CAAC,MA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