sass-embedded 1.0.0-beta.3 → 1.0.0-beta.8

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 (127) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/.gitignore +1 -0
  3. package/dist/lib/index.js +36 -2
  4. package/dist/lib/index.js.map +1 -1
  5. package/dist/lib/src/{embedded-compiler/compiler.js → async-compiler.js} +13 -13
  6. package/dist/lib/src/async-compiler.js.map +1 -0
  7. package/dist/lib/src/compile.js +187 -85
  8. package/dist/lib/src/compile.js.map +1 -1
  9. package/dist/lib/src/compiler-path.js +18 -0
  10. package/dist/lib/src/compiler-path.js.map +1 -0
  11. package/dist/lib/src/deprotofy-span.js +51 -0
  12. package/dist/lib/src/deprotofy-span.js.map +1 -0
  13. package/dist/lib/src/{embedded-protocol/dispatcher.js → dispatcher.js} +47 -41
  14. package/dist/lib/src/dispatcher.js.map +1 -0
  15. package/dist/lib/src/exception.js +20 -0
  16. package/dist/lib/src/exception.js.map +1 -0
  17. package/dist/lib/src/function-registry.js +92 -0
  18. package/dist/lib/src/function-registry.js.map +1 -0
  19. package/dist/lib/src/importer-registry.js +127 -0
  20. package/dist/lib/src/importer-registry.js.map +1 -0
  21. package/dist/lib/src/legacy.js +133 -0
  22. package/dist/lib/src/legacy.js.map +1 -0
  23. package/dist/lib/src/{embedded-protocol/message-transformer.js → message-transformer.js} +11 -10
  24. package/dist/lib/src/message-transformer.js.map +1 -0
  25. package/dist/lib/src/{embedded-compiler/packet-transformer.js → packet-transformer.js} +2 -1
  26. package/dist/lib/src/packet-transformer.js.map +1 -0
  27. package/dist/lib/src/protofier.js +272 -0
  28. package/dist/lib/src/protofier.js.map +1 -0
  29. package/dist/lib/src/{embedded-protocol/request-tracker.js → request-tracker.js} +1 -0
  30. package/dist/lib/src/request-tracker.js.map +1 -0
  31. package/dist/lib/src/sync-compiler.js +52 -0
  32. package/dist/lib/src/sync-compiler.js.map +1 -0
  33. package/dist/lib/src/{exception/span.js → sync-process/event.js} +2 -2
  34. package/dist/lib/src/sync-process/event.js.map +1 -0
  35. package/dist/lib/src/sync-process/index.js +122 -0
  36. package/dist/lib/src/sync-process/index.js.map +1 -0
  37. package/dist/lib/src/sync-process/sync-message-port.js +128 -0
  38. package/dist/lib/src/sync-process/sync-message-port.js.map +1 -0
  39. package/dist/lib/src/sync-process/worker.js +51 -0
  40. package/dist/lib/src/sync-process/worker.js.map +1 -0
  41. package/dist/lib/src/utils.js +88 -0
  42. package/dist/lib/src/utils.js.map +1 -1
  43. package/dist/lib/src/value/argument-list.js +31 -0
  44. package/dist/lib/src/value/argument-list.js.map +1 -0
  45. package/dist/lib/src/value/boolean.js +40 -0
  46. package/dist/lib/src/value/boolean.js.map +1 -0
  47. package/dist/lib/src/value/color.js +258 -0
  48. package/dist/lib/src/value/color.js.map +1 -0
  49. package/dist/lib/src/value/function.js +34 -0
  50. package/dist/lib/src/value/function.js.map +1 -0
  51. package/dist/lib/src/value/{value.js → index.js} +28 -17
  52. package/dist/lib/src/value/index.js.map +1 -0
  53. package/dist/lib/src/value/list.js +99 -0
  54. package/dist/lib/src/value/list.js.map +1 -0
  55. package/dist/lib/src/value/map.js +91 -0
  56. package/dist/lib/src/value/map.js.map +1 -0
  57. package/dist/lib/src/value/null.js +10 -6
  58. package/dist/lib/src/value/null.js.map +1 -1
  59. package/dist/lib/src/value/number.js +579 -0
  60. package/dist/lib/src/value/number.js.map +1 -0
  61. package/dist/lib/src/value/string.js +117 -0
  62. package/dist/lib/src/value/string.js.map +1 -0
  63. package/dist/lib/src/value/utils.js +120 -0
  64. package/dist/lib/src/value/utils.js.map +1 -0
  65. package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.js +994 -8
  66. package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.js.map +1 -1
  67. package/dist/package.json +63 -0
  68. package/dist/tool/utils.js +85 -91
  69. package/dist/tool/utils.js.map +1 -1
  70. package/dist/types/compile.d.ts +152 -0
  71. package/dist/types/exception.d.ts +41 -0
  72. package/dist/types/importer.d.ts +294 -0
  73. package/dist/types/index.d.ts +76 -0
  74. package/dist/types/legacy/exception.d.ts +54 -0
  75. package/dist/types/legacy/function.d.ts +700 -0
  76. package/dist/types/legacy/importer.d.ts +168 -0
  77. package/dist/types/legacy/options.d.ts +642 -0
  78. package/dist/types/legacy/plugin_this.d.ts +73 -0
  79. package/dist/types/legacy/render.d.ts +139 -0
  80. package/dist/types/logger/index.d.ts +94 -0
  81. package/dist/types/logger/source_location.d.ts +21 -0
  82. package/dist/types/logger/source_span.d.ts +34 -0
  83. package/dist/types/options.d.ts +408 -0
  84. package/dist/types/util/promise_or.d.ts +17 -0
  85. package/dist/types/value/argument_list.d.ts +47 -0
  86. package/dist/types/value/boolean.d.ts +29 -0
  87. package/dist/types/value/color.d.ts +107 -0
  88. package/dist/types/value/function.d.ts +22 -0
  89. package/dist/types/value/index.d.ts +173 -0
  90. package/dist/types/value/list.d.ts +54 -0
  91. package/dist/types/value/map.d.ts +41 -0
  92. package/dist/types/value/number.d.ts +305 -0
  93. package/dist/types/value/string.d.ts +84 -0
  94. package/download-compiler-for-end-user.js +1 -6
  95. package/package.json +23 -19
  96. package/dist/lib/index.d.ts +0 -1
  97. package/dist/lib/src/compile.d.ts +0 -20
  98. package/dist/lib/src/embedded-compiler/compiler.d.ts +0 -19
  99. package/dist/lib/src/embedded-compiler/compiler.js.map +0 -1
  100. package/dist/lib/src/embedded-compiler/packet-transformer.d.ts +0 -34
  101. package/dist/lib/src/embedded-compiler/packet-transformer.js.map +0 -1
  102. package/dist/lib/src/embedded-protocol/dispatcher.d.ts +0 -60
  103. package/dist/lib/src/embedded-protocol/dispatcher.js.map +0 -1
  104. package/dist/lib/src/embedded-protocol/message-transformer.d.ts +0 -47
  105. package/dist/lib/src/embedded-protocol/message-transformer.js.map +0 -1
  106. package/dist/lib/src/embedded-protocol/request-tracker.d.ts +0 -20
  107. package/dist/lib/src/embedded-protocol/request-tracker.js.map +0 -1
  108. package/dist/lib/src/embedded-protocol/utils.d.ts +0 -7
  109. package/dist/lib/src/embedded-protocol/utils.js +0 -52
  110. package/dist/lib/src/embedded-protocol/utils.js.map +0 -1
  111. package/dist/lib/src/exception/exception.d.ts +0 -19
  112. package/dist/lib/src/exception/exception.js +0 -36
  113. package/dist/lib/src/exception/exception.js.map +0 -1
  114. package/dist/lib/src/exception/location.d.ts +0 -11
  115. package/dist/lib/src/exception/location.js +0 -6
  116. package/dist/lib/src/exception/location.js.map +0 -1
  117. package/dist/lib/src/exception/span.d.ts +0 -29
  118. package/dist/lib/src/exception/span.js.map +0 -1
  119. package/dist/lib/src/node-sass/render.d.ts +0 -60
  120. package/dist/lib/src/node-sass/render.js +0 -126
  121. package/dist/lib/src/node-sass/render.js.map +0 -1
  122. package/dist/lib/src/utils.d.ts +0 -9
  123. package/dist/lib/src/value/null.d.ts +0 -11
  124. package/dist/lib/src/value/value.d.ts +0 -98
  125. package/dist/lib/src/value/value.js.map +0 -1
  126. package/dist/lib/src/vendor/embedded-protocol/embedded_sass_pb.d.ts +0 -1
  127. package/dist/tool/utils.d.ts +0 -29
@@ -3,10 +3,12 @@
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.Dispatcher = void 0;
6
7
  const rxjs_1 = require("rxjs");
7
8
  const operators_1 = require("rxjs/operators");
8
- const embedded_sass_pb_1 = require("../vendor/embedded-protocol/embedded_sass_pb");
9
+ const embedded_sass_pb_1 = require("./vendor/embedded-protocol/embedded_sass_pb");
9
10
  const request_tracker_1 = require("./request-tracker");
11
+ const utils_1 = require("./utils");
10
12
  /**
11
13
  * Dispatches requests, responses, and events.
12
14
  *
@@ -54,11 +56,13 @@ class Dispatcher {
54
56
  * Outbound log events. If an error occurs, the dispatcher closes this
55
57
  * silently.
56
58
  */
57
- this.logEvents$ = this.messages$.pipe(operators_1.filter(message => message.type === embedded_sass_pb_1.OutboundMessage.MessageCase.LOG_EVENT), operators_1.map(message => message.payload));
59
+ this.logEvents$ = this.messages$.pipe((0, operators_1.filter)(message => message.type === embedded_sass_pb_1.OutboundMessage.MessageCase.LOG_EVENT), (0, operators_1.map)(message => message.payload));
58
60
  this.outboundMessages$
59
- .pipe(operators_1.mergeMap(async (message) => {
60
- await this.handleOutboundMessage(message);
61
- return message;
61
+ .pipe((0, operators_1.mergeMap)(message => {
62
+ const result = this.handleOutboundMessage(message);
63
+ return result instanceof Promise
64
+ ? result.then(() => message)
65
+ : [message];
62
66
  }))
63
67
  .subscribe(message => this.messages$.next(message), error => this.throwAndClose(error), () => {
64
68
  this.messages$.complete();
@@ -66,12 +70,15 @@ class Dispatcher {
66
70
  });
67
71
  }
68
72
  /**
69
- * Sends a CompileRequest inbound. Returns a promise that will either resolve
70
- * with the corresponding outbound CompileResponse, or error if any Protocol
71
- * Errors were encountered.
73
+ * Sends a CompileRequest inbound. Passes the corresponding outbound
74
+ * CompileResponse or an error to `callback`.
75
+ *
76
+ * This uses an old-style callback argument so that it can work either
77
+ * synchronously or asynchronously. If the underlying stdout stream emits
78
+ * events synchronously, `callback` will be called synchronously.
72
79
  */
73
- sendCompileRequest(request) {
74
- return this.handleInboundRequest(request, embedded_sass_pb_1.InboundMessage.MessageCase.COMPILE_REQUEST, embedded_sass_pb_1.OutboundMessage.MessageCase.COMPILE_RESPONSE);
80
+ sendCompileRequest(request, callback) {
81
+ this.handleInboundRequest(request, embedded_sass_pb_1.InboundMessage.MessageCase.COMPILE_REQUEST, embedded_sass_pb_1.OutboundMessage.MessageCase.COMPILE_RESPONSE, callback);
75
82
  }
76
83
  // Rejects with `error` all promises awaiting an outbound response, and
77
84
  // silently closes all subscriptions awaiting outbound events.
@@ -83,48 +90,48 @@ class Dispatcher {
83
90
  // request or response, registers it with pendingOutboundRequests. If it
84
91
  // contains a request, runs the appropriate callback to generate an inbound
85
92
  // response, and then sends it inbound.
86
- async handleOutboundMessage(message) {
93
+ handleOutboundMessage(message) {
87
94
  switch (message.type) {
88
95
  case embedded_sass_pb_1.OutboundMessage.MessageCase.LOG_EVENT:
89
- break;
96
+ return undefined;
90
97
  case embedded_sass_pb_1.OutboundMessage.MessageCase.COMPILE_RESPONSE:
91
98
  this.pendingInboundRequests.resolve(message.payload.getId(), message.type);
92
- break;
99
+ return undefined;
93
100
  case embedded_sass_pb_1.OutboundMessage.MessageCase.IMPORT_REQUEST: {
94
101
  const request = message.payload;
95
102
  const id = request.getId();
96
103
  const type = embedded_sass_pb_1.InboundMessage.MessageCase.IMPORT_RESPONSE;
97
104
  this.pendingOutboundRequests.add(id, type);
98
- const response = await this.outboundRequestHandlers.handleImportRequest(request);
99
- this.sendInboundMessage(id, response, type);
100
- break;
105
+ return (0, utils_1.thenOr)(this.outboundRequestHandlers.handleImportRequest(request), response => {
106
+ this.sendInboundMessage(id, response, type);
107
+ });
101
108
  }
102
109
  case embedded_sass_pb_1.OutboundMessage.MessageCase.FILE_IMPORT_REQUEST: {
103
110
  const request = message.payload;
104
111
  const id = request.getId();
105
112
  const type = embedded_sass_pb_1.InboundMessage.MessageCase.FILE_IMPORT_RESPONSE;
106
113
  this.pendingOutboundRequests.add(id, type);
107
- const response = await this.outboundRequestHandlers.handleFileImportRequest(request);
108
- this.sendInboundMessage(id, response, type);
109
- break;
114
+ return (0, utils_1.thenOr)(this.outboundRequestHandlers.handleFileImportRequest(request), response => {
115
+ this.sendInboundMessage(id, response, type);
116
+ });
110
117
  }
111
118
  case embedded_sass_pb_1.OutboundMessage.MessageCase.CANONICALIZE_REQUEST: {
112
119
  const request = message.payload;
113
120
  const id = request.getId();
114
121
  const type = embedded_sass_pb_1.InboundMessage.MessageCase.CANONICALIZE_RESPONSE;
115
122
  this.pendingOutboundRequests.add(id, type);
116
- const response = await this.outboundRequestHandlers.handleCanonicalizeRequest(request);
117
- this.sendInboundMessage(id, response, type);
118
- break;
123
+ return (0, utils_1.thenOr)(this.outboundRequestHandlers.handleCanonicalizeRequest(request), response => {
124
+ this.sendInboundMessage(id, response, type);
125
+ });
119
126
  }
120
127
  case embedded_sass_pb_1.OutboundMessage.MessageCase.FUNCTION_CALL_REQUEST: {
121
128
  const request = message.payload;
122
129
  const id = request.getId();
123
130
  const type = embedded_sass_pb_1.InboundMessage.MessageCase.FUNCTION_CALL_RESPONSE;
124
131
  this.pendingOutboundRequests.add(id, type);
125
- const response = await this.outboundRequestHandlers.handleFunctionCallRequest(request);
126
- this.sendInboundMessage(id, response, type);
127
- break;
132
+ return (0, utils_1.thenOr)(this.outboundRequestHandlers.handleFunctionCallRequest(request), response => {
133
+ this.sendInboundMessage(id, response, type);
134
+ });
128
135
  }
129
136
  default:
130
137
  throw Error(`Unknown message type ${message.type}`);
@@ -133,22 +140,21 @@ class Dispatcher {
133
140
  // Sends a `request` of type `requestType` inbound. Returns a promise that
134
141
  // will either resolve with the corresponding outbound response of type
135
142
  // `responseType`, or error if any Protocol Errors were encountered.
136
- handleInboundRequest(request, requestType, responseType) {
137
- return new Promise((resolve, reject) => {
138
- if (this.messages$.isStopped) {
139
- reject(Error('Tried writing to closed dispatcher'));
140
- }
141
- this.messages$
142
- .pipe(operators_1.filter(message => message.type === responseType), operators_1.map(message => message.payload), operators_1.filter(response => response.getId() === request.getId()))
143
- .subscribe({ next: resolve });
144
- this.error$.subscribe({ error: reject });
145
- try {
146
- this.sendInboundMessage(this.pendingInboundRequests.nextId, request, requestType);
147
- }
148
- catch (error) {
149
- this.throwAndClose(error);
150
- }
151
- });
143
+ handleInboundRequest(request, requestType, responseType, callback) {
144
+ if (this.messages$.isStopped) {
145
+ callback(new Error('Tried writing to closed dispatcher'), undefined);
146
+ return;
147
+ }
148
+ this.messages$
149
+ .pipe((0, operators_1.filter)(message => message.type === responseType), (0, operators_1.map)(message => message.payload), (0, operators_1.filter)(response => response.getId() === request.getId()))
150
+ .subscribe({ next: response => callback(null, response) });
151
+ this.error$.subscribe({ error: error => callback(error, undefined) });
152
+ try {
153
+ this.sendInboundMessage(this.pendingInboundRequests.nextId, request, requestType);
154
+ }
155
+ catch (error) {
156
+ this.throwAndClose(error);
157
+ }
152
158
  }
153
159
  // Sends a message inbound. Keeps track of all pending inbound requests.
154
160
  sendInboundMessage(id, payload, type) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../../lib/src/dispatcher.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,+BAAyC;AACzC,8CAAqD;AAErD,kFAGqD;AAWrD,uDAAiD;AACjD,mCAA0C;AAE1C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAa,UAAU;IAiCrB,YACmB,iBAAmD,EACnD,mBAER,EACQ,uBAAiD;QAJjD,sBAAiB,GAAjB,iBAAiB,CAAkC;QACnD,wBAAmB,GAAnB,mBAAmB,CAE3B;QACQ,4BAAuB,GAAvB,uBAAuB,CAA0B;QArCpE,6EAA6E;QAC7E,kCAAkC;QACjB,2BAAsB,GAAG,IAAI,gCAAc,EAAE,CAAC;QAE/D,6EAA6E;QAC7E,kCAAkC;QACjB,4BAAuB,GAAG,IAAI,gCAAc,EAAE,CAAC;QAEhE,6EAA6E;QAC7E,kBAAkB;QACD,cAAS,GAAG,IAAI,cAAO,EAAwB,CAAC;QAEjE,yEAAyE;QACzE,oCAAoC;QACnB,mBAAc,GAAG,IAAI,cAAO,EAAQ,CAAC;QAEtD;;;;WAIG;QACM,WAAM,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;QAE7C;;;WAGG;QACM,eAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CACvC,IAAA,kBAAM,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,kCAAe,CAAC,WAAW,CAAC,SAAS,CAAC,EACzE,IAAA,eAAG,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAmC,CAAC,CAC5D,CAAC;QASA,IAAI,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ACnD,IAAI,KAAK,iCAAc,CAAC,WAAW,CAAC,oBAAoB;YACxD,IAAI,KAAK,iCAAc,CAAC,WAAW,CAAC,qBAAqB;YACzD,IAAI,KAAK,iCAAc,CAAC,WAAW,CAAC,sBAAsB,EAC1D;YACA,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;SAChD;aAAM;YACL,MAAM,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;SAC7C;QAED,IAAI,CAAC,mBAAmB,CAAC;YACvB,OAAO;YACP,IAAI;SACL,CAAC,CAAC;IACL,CAAC;CACF;AArOD,gCAqOC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // Copyright 2020 Google Inc. 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.Exception = void 0;
7
+ const deprotofy_span_1 = require("./deprotofy-span");
8
+ class Exception extends Error {
9
+ constructor(failure) {
10
+ super(failure.getFormatted());
11
+ this.sassMessage = failure.getMessage();
12
+ this.sassStack = failure.getStackTrace();
13
+ this.span = (0, deprotofy_span_1.deprotofySourceSpan)(failure.getSpan());
14
+ }
15
+ toString() {
16
+ return this.message;
17
+ }
18
+ }
19
+ exports.Exception = Exception;
20
+ //# sourceMappingURL=exception.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception.js","sourceRoot":"","sources":["../../../lib/src/exception.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAIvC,qDAAqD;AAErD,MAAa,SAAU,SAAQ,KAAK;IAKlC,YAAY,OAA6D;QACvE,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;QAE9B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACxC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAA,oCAAmB,EAAC,OAAO,CAAC,OAAO,EAAG,CAAC,CAAC;IACtD,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAhBD,8BAgBC"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ // Copyright 2021 Google Inc. 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.FunctionRegistry = void 0;
7
+ const util_1 = require("util");
8
+ const utils = require("./utils");
9
+ const embedded_sass_pb_1 = require("./vendor/embedded-protocol/embedded_sass_pb");
10
+ const utils_1 = require("./utils");
11
+ const protofier_1 = require("./protofier");
12
+ const value_1 = require("./value");
13
+ /**
14
+ * The next ID to use for a function. The embedded protocol requires that
15
+ * function IDs be globally unique.
16
+ */
17
+ let nextFunctionID = 0;
18
+ /**
19
+ * Tracks functions that are defined on the host so that the compiler can
20
+ * execute them.
21
+ */
22
+ class FunctionRegistry {
23
+ constructor(functionsBySignature) {
24
+ this.functionsByName = new Map();
25
+ this.functionsById = new Map();
26
+ this.idsByFunction = new Map();
27
+ for (const [signature, fn] of Object.entries(functionsBySignature !== null && functionsBySignature !== void 0 ? functionsBySignature : {})) {
28
+ const openParen = signature.indexOf('(');
29
+ if (openParen === -1) {
30
+ throw new Error(`options.functions: "${signature}" is missing "("`);
31
+ }
32
+ this.functionsByName.set(signature.substring(0, openParen), fn);
33
+ }
34
+ }
35
+ /** Registers `fn` as a function that can be called using the returned ID. */
36
+ register(fn) {
37
+ return utils.putIfAbsent(this.idsByFunction, fn, () => {
38
+ const id = nextFunctionID;
39
+ nextFunctionID += 1;
40
+ this.functionsById.set(id, fn);
41
+ return id;
42
+ });
43
+ }
44
+ /**
45
+ * Returns the function to which `request` refers and returns its response.
46
+ */
47
+ call(request) {
48
+ const protofier = new protofier_1.Protofier(this);
49
+ const fn = this.get(request);
50
+ return (0, utils_1.catchOr)(() => {
51
+ return (0, utils_1.thenOr)(fn(request
52
+ .getArgumentsList()
53
+ .map(value => protofier.deprotofy(value))), result => {
54
+ if (!(result instanceof value_1.Value)) {
55
+ const name = request.getName().length === 0
56
+ ? 'anonymous function'
57
+ : `"${request.getName()}"`;
58
+ throw (`options.functions: ${name} returned non-Value: ` +
59
+ (0, util_1.inspect)(result));
60
+ }
61
+ const response = new embedded_sass_pb_1.InboundMessage.FunctionCallResponse();
62
+ response.setSuccess(protofier.protofy(result));
63
+ response.setAccessedArgumentListsList(protofier.accessedArgumentLists);
64
+ return response;
65
+ });
66
+ }, error => {
67
+ const response = new embedded_sass_pb_1.InboundMessage.FunctionCallResponse();
68
+ response.setError(`${error}`);
69
+ return response;
70
+ });
71
+ }
72
+ /** Returns the function to which `request` refers. */
73
+ get(request) {
74
+ if (request.getIdentifierCase() ===
75
+ embedded_sass_pb_1.OutboundMessage.FunctionCallRequest.IdentifierCase.NAME) {
76
+ const fn = this.functionsByName.get(request.getName());
77
+ if (fn)
78
+ return fn;
79
+ throw new Error('Invalid OutboundMessage.FunctionCallRequest: there is no function ' +
80
+ `named "${request.getName()}"`);
81
+ }
82
+ else {
83
+ const fn = this.functionsById.get(request.getFunctionId());
84
+ if (fn)
85
+ return fn;
86
+ throw new Error('Invalid OutboundMessage.FunctionCallRequest: there is no function ' +
87
+ `with ID "${request.getFunctionId()}"`);
88
+ }
89
+ }
90
+ }
91
+ exports.FunctionRegistry = FunctionRegistry;
92
+ //# sourceMappingURL=function-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-registry.js","sourceRoot":"","sources":["../../../lib/src/function-registry.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,+BAA6B;AAG7B,iCAAiC;AAEjC,kFAGqD;AACrD,mCAAmD;AACnD,2CAAsC;AACtC,mCAA8B;AAE9B;;;GAGG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AE,CAAC;YAElB,MAAM,IAAI,KAAK,CACb,oEAAoE;gBAClE,UAAU,OAAO,CAAC,OAAO,EAAE,GAAG,CACjC,CAAC;SACH;aAAM;YACL,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;YAC3D,IAAI,EAAE;gBAAE,OAAO,EAAE,CAAC;YAElB,MAAM,IAAI,KAAK,CACb,oEAAoE;gBAClE,YAAY,OAAO,CAAC,aAAa,EAAE,GAAG,CACzC,CAAC;SACH;IACH,CAAC;CACF;AAjGD,4CAiGC"}
@@ -0,0 +1,127 @@
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.ImporterRegistry = void 0;
7
+ const p = require("path");
8
+ const url_1 = require("url");
9
+ const util_1 = require("util");
10
+ const utils = require("./utils");
11
+ const embedded_sass_pb_1 = require("./vendor/embedded-protocol/embedded_sass_pb");
12
+ const utils_1 = require("./utils");
13
+ /**
14
+ * A registry of importers defined in the host that can be invoked by the
15
+ * compiler.
16
+ */
17
+ class ImporterRegistry {
18
+ constructor(options) {
19
+ var _a, _b;
20
+ /** A map from importer IDs to their corresponding importers. */
21
+ this.importersById = new Map();
22
+ /** A map from file importer IDs to their corresponding importers. */
23
+ this.fileImportersById = new Map();
24
+ /** The next ID to use for an importer. */
25
+ this.id = 0;
26
+ this.importers = ((_a = options === null || options === void 0 ? void 0 : options.importers) !== null && _a !== void 0 ? _a : [])
27
+ .map(importer => this.register(importer))
28
+ .concat(((_b = options === null || options === void 0 ? void 0 : options.loadPaths) !== null && _b !== void 0 ? _b : []).map(path => {
29
+ const proto = new embedded_sass_pb_1.InboundMessage.CompileRequest.Importer();
30
+ proto.setPath(p.resolve(path));
31
+ return proto;
32
+ }));
33
+ }
34
+ /** Converts an importer to a proto without adding it to `this.importers`. */
35
+ register(importer) {
36
+ const proto = new embedded_sass_pb_1.InboundMessage.CompileRequest.Importer();
37
+ if ('canonicalize' in importer) {
38
+ if ('findFileUrl' in importer) {
39
+ throw new Error('Importer may not contain both canonicalize() and findFileUrl(): ' +
40
+ (0, util_1.inspect)(importer));
41
+ }
42
+ proto.setImporterId(this.id);
43
+ this.importersById.set(this.id, importer);
44
+ }
45
+ else {
46
+ proto.setFileImporterId(this.id);
47
+ this.fileImportersById.set(this.id, importer);
48
+ }
49
+ this.id += 1;
50
+ return proto;
51
+ }
52
+ /** Handles a canonicalization request. */
53
+ canonicalize(request) {
54
+ const importer = this.importersById.get(request.getImporterId());
55
+ if (!importer) {
56
+ throw utils.compilerError('Unknown CanonicalizeRequest.importer_id');
57
+ }
58
+ return (0, utils_1.catchOr)(() => {
59
+ return (0, utils_1.thenOr)(importer.canonicalize(request.getUrl(), {
60
+ fromImport: request.getFromImport(),
61
+ }), url => {
62
+ const proto = new embedded_sass_pb_1.InboundMessage.CanonicalizeResponse();
63
+ if (url !== null)
64
+ proto.setUrl(url.toString());
65
+ return proto;
66
+ });
67
+ }, error => {
68
+ const proto = new embedded_sass_pb_1.InboundMessage.CanonicalizeResponse();
69
+ proto.setError(`${error}`);
70
+ return proto;
71
+ });
72
+ }
73
+ /** Handles an import request. */
74
+ import(request) {
75
+ const importer = this.importersById.get(request.getImporterId());
76
+ if (!importer) {
77
+ throw utils.compilerError('Unknown ImportRequest.importer_id');
78
+ }
79
+ return (0, utils_1.catchOr)(() => {
80
+ return (0, utils_1.thenOr)(importer.load(new url_1.URL(request.getUrl())), result => {
81
+ const proto = new embedded_sass_pb_1.InboundMessage.ImportResponse();
82
+ if (result) {
83
+ const success = new embedded_sass_pb_1.InboundMessage.ImportResponse.ImportSuccess();
84
+ success.setContents(result.contents);
85
+ success.setSyntax(utils.protofySyntax(result.syntax));
86
+ if (result.sourceMapUrl) {
87
+ success.setSourceMapUrl(result.sourceMapUrl.toString());
88
+ }
89
+ proto.setSuccess(success);
90
+ }
91
+ return proto;
92
+ });
93
+ }, error => {
94
+ const proto = new embedded_sass_pb_1.InboundMessage.ImportResponse();
95
+ proto.setError(`${error}`);
96
+ return proto;
97
+ });
98
+ }
99
+ /** Handles a file import request. */
100
+ fileImport(request) {
101
+ const importer = this.fileImportersById.get(request.getImporterId());
102
+ if (!importer) {
103
+ throw utils.compilerError('Unknown FileImportRequest.importer_id');
104
+ }
105
+ return (0, utils_1.catchOr)(() => {
106
+ return (0, utils_1.thenOr)(importer.findFileUrl(request.getUrl(), {
107
+ fromImport: request.getFromImport(),
108
+ }), url => {
109
+ const proto = new embedded_sass_pb_1.InboundMessage.FileImportResponse();
110
+ if (url) {
111
+ if (url.protocol !== 'file:') {
112
+ throw (`FileImporter ${(0, util_1.inspect)(importer)} returned non-file: URL ` +
113
+ +`"${url}" for URL "${request.getUrl()}".`);
114
+ }
115
+ proto.setFileUrl(url.toString());
116
+ }
117
+ return proto;
118
+ });
119
+ }, error => {
120
+ const proto = new embedded_sass_pb_1.InboundMessage.FileImportResponse();
121
+ proto.setError(`${error}`);
122
+ return proto;
123
+ });
124
+ }
125
+ }
126
+ exports.ImporterRegistry = ImporterRegistry;
127
+ //# sourceMappingURL=importer-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importer-registry.js","sourceRoot":"","sources":["../../../lib/src/importer-registry.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,0BAA0B;AAC1B,6BAAwB;AACxB,+BAA6B;AAE7B,iCAAiC;AAEjC,kFAGqD;AACrD,mCAAmD;AAEnD;;;GAGG;AACH,MAAa,gBAAgB;IAa3B,YAAY,OAAuB;;QATnC,gEAAgE;QAC/C,kBAAa,GAAG,IAAI,GAAG,EAA0B,CAAC;QAEnE,qEAAqE;QACpD,sBAAiB,GAAG,IAAI,GAAG,EAA8B,CAAC;QAE3E,0CAA0C;QAClC,OAAE,GAAG,CAAC,C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,GAAG,IAAI,iCAAc,CAAC,kBAAkB,EAAE,CAAC;gBACtD,IAAI,GAAG,EAAE;oBACP,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,EAAE;wBAC5B,MAAM,CACJ,gBAAgB,IAAA,cAAO,EAAC,QAAQ,CAAC,0BAA0B;4BAC3D,CAAC,IAAI,GAAG,cAAc,OAAO,CAAC,MAAM,EAAE,IAAI,CAC3C,CAAC;qBACH;oBACD,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAClC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC,CACF,CAAC;QACJ,CAAC,EACD,KAAK,CAAC,EAAE;YACN,MAAM,KAAK,GAAG,IAAI,iCAAc,CAAC,kBAAkB,EAAE,CAAC;YACtD,KAAK,CAAC,QAAQ,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AApJD,4CAoJC"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ // Copyright 2021 Google Inc. 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.render = void 0;
7
+ const p = require("path");
8
+ const url_1 = require("url");
9
+ const exception_1 = require("./exception");
10
+ const compile_1 = require("./compile");
11
+ const utils_1 = require("./utils");
12
+ function render(options, callback) {
13
+ if (!('file' in options && options.file) && !('data' in options)) {
14
+ callback(newLegacyException(new Error('Either options.data or options.file must be set.')));
15
+ return;
16
+ }
17
+ const start = Date.now();
18
+ const compileSass = isStringOptions(options)
19
+ ? (0, compile_1.compileStringAsync)(options.data, {
20
+ sourceMap: wasSourceMapRequested(options),
21
+ url: options.file ? (0, url_1.pathToFileURL)(options.file) : undefined,
22
+ syntax: options.indentedSyntax ? 'indented' : 'scss',
23
+ })
24
+ : (0, compile_1.compileAsync)(options.file, {
25
+ sourceMap: wasSourceMapRequested(options),
26
+ loadPaths: options.includePaths,
27
+ });
28
+ compileSass.then(result => callback(undefined, newLegacyResult(options, start, result)), error => callback(newLegacyException(error)));
29
+ }
30
+ exports.render = render;
31
+ // Returns whether `options` is a `LegacyStringOptions`.
32
+ function isStringOptions(options) {
33
+ return 'data' in options;
34
+ }
35
+ // Determines whether a sourceMap was requested by the call to `render()`.
36
+ function wasSourceMapRequested(options) {
37
+ return (typeof options.sourceMap === 'string' ||
38
+ (options.sourceMap === true && !!options.outFile));
39
+ }
40
+ // Transforms the compilation result into an object that mimics the Node Sass
41
+ // API format.
42
+ function newLegacyResult(options, start, result) {
43
+ var _a, _b;
44
+ const end = Date.now();
45
+ let css = result.css;
46
+ let sourceMapBytes;
47
+ if (result.sourceMap) {
48
+ const sourceMap = result.sourceMap;
49
+ sourceMap.sourceRoot = (_a = options.sourceMapRoot) !== null && _a !== void 0 ? _a : '';
50
+ const sourceMapPath = typeof options.sourceMap === 'string'
51
+ ? options.sourceMap
52
+ : options.outFile + '.map';
53
+ const sourceMapDir = p.dirname(sourceMapPath);
54
+ if (options.outFile) {
55
+ sourceMap.file = (0, utils_1.pathToUrlString)(p.relative(sourceMapDir, options.outFile));
56
+ }
57
+ else if (options.file) {
58
+ sourceMap.file = (0, utils_1.pathToUrlString)(p.relative(sourceMapDir, (0, utils_1.withoutExtension)(options.file) + '.css'));
59
+ }
60
+ else {
61
+ sourceMap.file = 'stdin.css';
62
+ }
63
+ sourceMap.sources = sourceMap.sources.map(source => {
64
+ if (source.startsWith('file://')) {
65
+ return (0, utils_1.pathToUrlString)(p.relative(sourceMapDir, (0, url_1.fileURLToPath)(source)));
66
+ }
67
+ else if (source.startsWith('data:')) {
68
+ return 'stdin';
69
+ }
70
+ else {
71
+ return source;
72
+ }
73
+ });
74
+ sourceMapBytes = Buffer.from(JSON.stringify(sourceMap));
75
+ if (!options.omitSourceMapUrl) {
76
+ let url;
77
+ if (options.sourceMapEmbed) {
78
+ url = `data:application/json;base64,${sourceMapBytes.toString('base64')}`;
79
+ }
80
+ else if (options.outFile) {
81
+ url = (0, utils_1.pathToUrlString)(p.relative(p.dirname(options.outFile), sourceMapPath));
82
+ }
83
+ else {
84
+ url = (0, utils_1.pathToUrlString)(sourceMapPath);
85
+ }
86
+ css += `\n\n/*# sourceMappingURL=${url} */`;
87
+ }
88
+ }
89
+ return {
90
+ css: Buffer.from(css),
91
+ map: sourceMapBytes,
92
+ stats: {
93
+ entry: (_b = options.file) !== null && _b !== void 0 ? _b : 'data',
94
+ start,
95
+ end,
96
+ duration: end - start,
97
+ includedFiles: result.loadedUrls.map(url => url.toString()),
98
+ },
99
+ };
100
+ }
101
+ // Decorates an Error with additional fields so that it behaves like a Node Sass
102
+ // error.
103
+ function newLegacyException(error) {
104
+ var _a, _b, _c, _d;
105
+ if (!(error instanceof exception_1.Exception)) {
106
+ return Object.assign(error, {
107
+ formatted: error.toString(),
108
+ status: 3,
109
+ });
110
+ }
111
+ const file = ((_a = error.span) === null || _a === void 0 ? void 0 : _a.url)
112
+ ? // We have to cast to Node's URL type here because the specified type is the
113
+ // standard URL type which is slightly less featureful. `fileURLToPath()`
114
+ // does work with standard URL objects in practice, but we know that we
115
+ // generate Node URLs here regardless.
116
+ (0, url_1.fileURLToPath)((_b = error.span) === null || _b === void 0 ? void 0 : _b.url)
117
+ : 'stdin';
118
+ return Object.assign(new Error(), {
119
+ status: 1,
120
+ message: error.toString().replace(/^Error: /, ''),
121
+ formatted: error.toString(),
122
+ toString: () => error.toString(),
123
+ stack: error.stack,
124
+ line: (0, utils_1.isNullOrUndefined)((_c = error.span) === null || _c === void 0 ? void 0 : _c.start.line)
125
+ ? undefined
126
+ : error.span.start.line + 1,
127
+ column: (0, utils_1.isNullOrUndefined)((_d = error.span) === null || _d === void 0 ? void 0 : _d.start.column)
128
+ ? undefined
129
+ : error.span.start.column + 1,
130
+ file,
131
+ });
132
+ }
133
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1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K,CAAC,IAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC;QAC9B,MAAM,EAAE,IAAA,yBAAiB,EAAC,MAAA,KAAK,CAAC,IAAI,0CAAE,KAAK,CAAC,MAAM,CAAC;YACjD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,KAAK,CAAC,IAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;QAChC,IAAI;KACL,CAAC,CAAC;AACL,CAAC"}
@@ -3,10 +3,11 @@
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.MessageTransformer = void 0;
6
7
  const rxjs_1 = require("rxjs");
7
8
  const operators_1 = require("rxjs/operators");
8
- const utils_1 = require("../utils");
9
- const embedded_sass_pb_1 = require("../vendor/embedded-protocol/embedded_sass_pb");
9
+ const utils_1 = require("./utils");
10
+ const embedded_sass_pb_1 = require("./vendor/embedded-protocol/embedded_sass_pb");
10
11
  /**
11
12
  * Encodes InboundTypedMessages into protocol buffers and decodes protocol
12
13
  * buffers into OutboundTypedMessages. Any Embedded Protocol violations that can
@@ -31,7 +32,7 @@ class MessageTransformer {
31
32
  */
32
33
  this.outboundMessages$ = this.outboundMessagesInternal$.pipe();
33
34
  this.outboundProtobufs$
34
- .pipe(operators_1.map(decode))
35
+ .pipe((0, operators_1.map)(decode))
35
36
  .subscribe(this.outboundMessagesInternal$);
36
37
  }
37
38
  /**
@@ -57,7 +58,7 @@ function decode(buffer) {
57
58
  message = embedded_sass_pb_1.OutboundMessage.deserializeBinary(buffer);
58
59
  }
59
60
  catch (error) {
60
- throw utils_1.compilerError('Invalid buffer');
61
+ throw (0, utils_1.compilerError)('Invalid buffer');
61
62
  }
62
63
  let payload;
63
64
  const type = message.getMessageCase();
@@ -68,7 +69,7 @@ function decode(buffer) {
68
69
  case embedded_sass_pb_1.OutboundMessage.MessageCase.COMPILE_RESPONSE:
69
70
  if (((_a = message.getCompileResponse()) === null || _a === void 0 ? void 0 : _a.getResultCase()) ===
70
71
  embedded_sass_pb_1.OutboundMessage.CompileResponse.ResultCase.RESULT_NOT_SET) {
71
- throw utils_1.compilerError('OutboundMessage.CompileResponse.result is not set');
72
+ throw (0, utils_1.compilerError)('OutboundMessage.CompileResponse.result is not set');
72
73
  }
73
74
  payload = message.getCompileResponse();
74
75
  break;
@@ -84,19 +85,19 @@ function decode(buffer) {
84
85
  case embedded_sass_pb_1.OutboundMessage.MessageCase.FUNCTION_CALL_REQUEST:
85
86
  if (((_b = message.getFunctionCallRequest()) === null || _b === void 0 ? void 0 : _b.getIdentifierCase()) ===
86
87
  embedded_sass_pb_1.OutboundMessage.FunctionCallRequest.IdentifierCase.IDENTIFIER_NOT_SET) {
87
- throw utils_1.compilerError('OutboundMessage.FunctionCallRequest.identifier is not set');
88
+ throw (0, utils_1.compilerError)('OutboundMessage.FunctionCallRequest.identifier is not set');
88
89
  }
89
90
  payload = message.getFunctionCallRequest();
90
91
  break;
91
92
  case embedded_sass_pb_1.OutboundMessage.MessageCase.ERROR:
92
- throw utils_1.hostError(`${(_c = message.getError()) === null || _c === void 0 ? void 0 : _c.getMessage()}`);
93
+ throw (0, utils_1.hostError)(`${(_c = message.getError()) === null || _c === void 0 ? void 0 : _c.getMessage()}`);
93
94
  case embedded_sass_pb_1.OutboundMessage.MessageCase.MESSAGE_NOT_SET:
94
- throw utils_1.compilerError('OutboundMessage.message is not set');
95
+ throw (0, utils_1.compilerError)('OutboundMessage.message is not set');
95
96
  default:
96
- throw utils_1.compilerError(`Unknown message type ${message.toString()}`);
97
+ throw (0, utils_1.compilerError)(`Unknown message type ${message.toString()}`);
97
98
  }
98
99
  if (!payload)
99
- throw utils_1.compilerError('OutboundMessage missing payload');
100
+ throw (0, utils_1.compilerError)('OutboundMessage missing payload');
100
101
  return {
101
102
  payload,
102
103
  type,