sass-embedded 1.0.0-beta.4 → 1.0.0-rc.1
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 +40 -0
- package/dist/.gitignore +1 -0
- package/dist/lib/index.js +40 -11
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/src/{embedded-compiler/compiler.js → async-compiler.js} +13 -13
- package/dist/lib/src/async-compiler.js.map +1 -0
- package/dist/lib/src/compile.js +187 -85
- 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/deprotofy-span.js +51 -0
- package/dist/lib/src/deprotofy-span.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/dispatcher.js → dispatcher.js} +47 -41
- 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 +92 -0
- package/dist/lib/src/function-registry.js.map +1 -0
- package/dist/lib/src/importer-registry.js +127 -0
- package/dist/lib/src/importer-registry.js.map +1 -0
- package/dist/lib/src/legacy/importer.js +186 -0
- package/dist/lib/src/legacy/importer.js.map +1 -0
- package/dist/lib/src/legacy/index.js +261 -0
- package/dist/lib/src/legacy/index.js.map +1 -0
- package/dist/lib/src/legacy/resolve-path.js +101 -0
- package/dist/lib/src/legacy/resolve-path.js.map +1 -0
- package/dist/lib/src/legacy/value/base.js +17 -0
- package/dist/lib/src/legacy/value/base.js.map +1 -0
- package/dist/lib/src/legacy/value/color.js +64 -0
- package/dist/lib/src/legacy/value/color.js.map +1 -0
- package/dist/lib/src/legacy/value/index.js +23 -0
- package/dist/lib/src/legacy/value/index.js.map +1 -0
- package/dist/lib/src/legacy/value/list.js +50 -0
- package/dist/lib/src/legacy/value/list.js.map +1 -0
- package/dist/lib/src/legacy/value/map.js +74 -0
- package/dist/lib/src/legacy/value/map.js.map +1 -0
- package/dist/lib/src/legacy/value/number.js +60 -0
- package/dist/lib/src/legacy/value/number.js.map +1 -0
- package/dist/lib/src/legacy/value/string.js +27 -0
- package/dist/lib/src/legacy/value/string.js.map +1 -0
- package/dist/lib/src/legacy/value/wrap.js +83 -0
- package/dist/lib/src/legacy/value/wrap.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/message-transformer.js → message-transformer.js} +11 -10
- package/dist/lib/src/message-transformer.js.map +1 -0
- package/dist/lib/src/{embedded-compiler/packet-transformer.js → packet-transformer.js} +2 -1
- package/dist/lib/src/packet-transformer.js.map +1 -0
- package/dist/lib/src/protofier.js +272 -0
- package/dist/lib/src/protofier.js.map +1 -0
- package/dist/lib/src/{embedded-protocol/request-tracker.js → request-tracker.js} +1 -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 +96 -1
- package/dist/lib/src/utils.js.map +1 -1
- package/dist/lib/src/value/argument-list.js +31 -0
- package/dist/lib/src/value/argument-list.js.map +1 -0
- package/dist/lib/src/value/boolean.js +22 -5
- package/dist/lib/src/value/boolean.js.map +1 -1
- package/dist/lib/src/value/color.js +258 -0
- package/dist/lib/src/value/color.js.map +1 -0
- package/dist/lib/src/value/function.js +34 -0
- package/dist/lib/src/value/function.js.map +1 -0
- package/dist/lib/src/value/{value.js → index.js} +28 -14
- package/dist/lib/src/value/index.js.map +1 -0
- package/dist/lib/src/value/list.js +99 -0
- package/dist/lib/src/value/list.js.map +1 -0
- package/dist/lib/src/value/map.js +91 -0
- package/dist/lib/src/value/map.js.map +1 -0
- package/dist/lib/src/value/null.js +16 -3
- package/dist/lib/src/value/null.js.map +1 -1
- package/dist/lib/src/value/number.js +41 -46
- package/dist/lib/src/value/number.js.map +1 -1
- package/dist/lib/src/value/string.js +18 -12
- package/dist/lib/src/value/string.js.map +1 -1
- package/dist/lib/src/value/utils.js +27 -2
- 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 +23 -20
- package/dist/tool/utils.js +50 -18
- 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 +80 -0
- package/dist/types/legacy/exception.d.ts +54 -0
- package/dist/types/legacy/function.d.ts +756 -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 +73 -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 +418 -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 +23 -20
- package/dist/lib/index.d.ts +0 -7
- package/dist/lib/src/compile.d.ts +0 -20
- 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 +0 -52
- 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 -36
- 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 -60
- package/dist/lib/src/node-sass/render.js +0 -126
- package/dist/lib/src/node-sass/render.js.map +0 -1
- package/dist/lib/src/utils.d.ts +0 -12
- package/dist/lib/src/value/boolean.d.ts +0 -25
- 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 -36
- package/dist/lib/src/value/value.d.ts +0 -103
- 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
|
@@ -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("
|
|
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(
|
|
60
|
-
|
|
61
|
-
return
|
|
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.
|
|
70
|
-
*
|
|
71
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
93
|
+
handleOutboundMessage(message) {
|
|
87
94
|
switch (message.type) {
|
|
88
95
|
case embedded_sass_pb_1.OutboundMessage.MessageCase.LOG_EVENT:
|
|
89
|
-
|
|
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
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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,YAC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 @@
|
|
|
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;AACH,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB;;;GAGG;AACH,MAAa,gBAAgB;IAK3B,YAAY,oBAA2D;QAJtD,oBAAe,GAAG,IAAI,GAAG,EAAgC,CAAC;QAC1D,kBAAa,GAAG,IAAI,GAAG,EAAgC,CAAC;QACxD,kBAAa,GAAG,IAAI,GAAG,EAAgC,CAAC;QAGvE,KAAK,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,oBAAoB,aAApB,oBAAoB,cAApB,oBAAoB,GAAI,EAAE,CAAC,EAAE;YACxE,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACzC,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE;gBACpB,MAAM,IAAI,KAAK,CAAC,uBAAuB,SAAS,kBAAkB,CAAC,CAAC;aACrE;YAED,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;SACjE;IACH,CAAC;IAED,6EAA6E;IAC7E,QAAQ,CAAC,EAAwB;QAC/B,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,GAAG,EAAE;YACp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CAAc,CAAC,oBAAoB,EAAE,CAAC;YAC3D,QAAQ,CAAC,QAAQ,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;YAC9B,OAAO,QAAQ,CAAC;QAClB,CAAC,CACF,CAAC;IACJ,CAAC;IAED,sDAAsD;IAC9C,GAAG,CACT,OAA4C;QAE5C,IACE,OAAO,CAAC,iBAAiB,EAAE;YAC3B,kCAAe,CAAC,mBAAmB,CAAC,cAAc,CAAC,IAAI,EACvD;YACA,MAAM,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;YACvD,IAAI,EAAE;gBAAE,OAAO,EAAE,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,GAA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AC,OAAO,CAAC,MAAM,EAAE,EAAE;gBACrC,UAAU,EAAE,OAAO,CAAC,aAAa,EAAE;aACpC,CAAC,EACF,GAAG,CAAC,EAAE;gBACJ,MAAM,KAAK,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,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 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.LegacyImporterWrapper = exports.legacyImporterProtocol = exports.endOfLoadProtocol = void 0;
|
|
7
|
+
const assert_1 = require("assert");
|
|
8
|
+
const url_1 = require("url");
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const p = require("path");
|
|
11
|
+
const resolve_path_1 = require("./resolve-path");
|
|
12
|
+
const utils_1 = require("../utils");
|
|
13
|
+
/**
|
|
14
|
+
* A special URL protocol we use to signal when a stylesheet has finished
|
|
15
|
+
* loading. This allows us to determine which stylesheet is "current" when
|
|
16
|
+
* resolving a new load, which in turn allows us to pass in an accurate `prev`
|
|
17
|
+
* parameter to the legacy callback.
|
|
18
|
+
*/
|
|
19
|
+
exports.endOfLoadProtocol = 'sass-embedded-legacy-load-done:';
|
|
20
|
+
/**
|
|
21
|
+
* The URL protocol to use for URLs canonicalized using `LegacyImporterWrapper`.
|
|
22
|
+
*/
|
|
23
|
+
exports.legacyImporterProtocol = 'legacy-importer:';
|
|
24
|
+
// A count of `endOfLoadProtocol` imports that have been generated. Each one
|
|
25
|
+
// must be a different URL to ensure that the importer results aren't cached.
|
|
26
|
+
let endOfLoadCount = 0;
|
|
27
|
+
/**
|
|
28
|
+
* A wrapper around a `LegacyImporter` callback that exposes it as a new-API
|
|
29
|
+
* `Importer`.
|
|
30
|
+
*/
|
|
31
|
+
class LegacyImporterWrapper {
|
|
32
|
+
// TODO: Support prev from a load path
|
|
33
|
+
constructor(self, callbacks, loadPaths, initialPrev, sync) {
|
|
34
|
+
this.self = self;
|
|
35
|
+
this.callbacks = callbacks;
|
|
36
|
+
this.loadPaths = loadPaths;
|
|
37
|
+
this.sync = sync;
|
|
38
|
+
// A stack of previous URLs passed to `this.callbacks`.
|
|
39
|
+
this.prev = [];
|
|
40
|
+
// Whether we're expecting the next call to `canonicalize()` to be a relative
|
|
41
|
+
// load. The legacy importer API doesn't handle these loads in the same way as
|
|
42
|
+
// the modern API, so we always return `null` in this case.
|
|
43
|
+
this.expectingRelativeLoad = true;
|
|
44
|
+
const path = initialPrev !== 'stdin';
|
|
45
|
+
this.prev.push({ url: path ? p.resolve(initialPrev) : 'stdin', path });
|
|
46
|
+
}
|
|
47
|
+
canonicalize(url, options) {
|
|
48
|
+
if (url.startsWith(exports.endOfLoadProtocol))
|
|
49
|
+
return new URL(url);
|
|
50
|
+
// Since there's only ever one modern importer in legacy mode, we can be
|
|
51
|
+
// sure that all normal loads are preceded by exactly one relative load.
|
|
52
|
+
if (this.expectingRelativeLoad) {
|
|
53
|
+
if (url.startsWith('file:')) {
|
|
54
|
+
const resolved = (0, resolve_path_1.resolvePath)((0, utils_1.fileUrlToPathCrossPlatform)(url), options.fromImport);
|
|
55
|
+
if (resolved !== null)
|
|
56
|
+
return (0, url_1.pathToFileURL)(resolved);
|
|
57
|
+
}
|
|
58
|
+
this.expectingRelativeLoad = false;
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.expectingRelativeLoad = true;
|
|
63
|
+
}
|
|
64
|
+
const prev = this.prev[this.prev.length - 1];
|
|
65
|
+
return (0, utils_1.thenOr)((0, utils_1.thenOr)(this.invokeCallbacks(url, prev.url, options), result => {
|
|
66
|
+
var _a;
|
|
67
|
+
if (result instanceof Error)
|
|
68
|
+
throw result;
|
|
69
|
+
if (result === null)
|
|
70
|
+
return null;
|
|
71
|
+
if ('contents' in result || !('file' in result)) {
|
|
72
|
+
this.lastContents = (_a = result.contents) !== null && _a !== void 0 ? _a : '';
|
|
73
|
+
if ('file' in result) {
|
|
74
|
+
return new URL(exports.legacyImporterProtocol +
|
|
75
|
+
encodeURI(result.file));
|
|
76
|
+
}
|
|
77
|
+
else if (/^[A-Za-z+.-]+:/.test(url)) {
|
|
78
|
+
return new URL(url);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return new URL(exports.legacyImporterProtocol + encodeURI(url));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
if (p.isAbsolute(result.file)) {
|
|
86
|
+
const resolved = (0, resolve_path_1.resolvePath)(result.file, options.fromImport);
|
|
87
|
+
return resolved ? (0, url_1.pathToFileURL)(resolved) : null;
|
|
88
|
+
}
|
|
89
|
+
const prefixes = [...this.loadPaths, '.'];
|
|
90
|
+
if (prev.path)
|
|
91
|
+
prefixes.unshift(p.dirname(prev.url));
|
|
92
|
+
for (const prefix of prefixes) {
|
|
93
|
+
const resolved = (0, resolve_path_1.resolvePath)(p.join(prefix, result.file), options.fromImport);
|
|
94
|
+
if (resolved !== null)
|
|
95
|
+
return (0, url_1.pathToFileURL)(resolved);
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
}), result => {
|
|
100
|
+
if (result !== null) {
|
|
101
|
+
const path = result.protocol === 'file:';
|
|
102
|
+
this.prev.push({
|
|
103
|
+
url: path ? (0, utils_1.fileUrlToPathCrossPlatform)(result) : url,
|
|
104
|
+
path,
|
|
105
|
+
});
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
for (const loadPath of this.loadPaths) {
|
|
110
|
+
const resolved = (0, resolve_path_1.resolvePath)(p.join(loadPath, url), options.fromImport);
|
|
111
|
+
if (resolved !== null)
|
|
112
|
+
return (0, url_1.pathToFileURL)(resolved);
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
load(canonicalUrl) {
|
|
119
|
+
var _a;
|
|
120
|
+
if (canonicalUrl.protocol === exports.endOfLoadProtocol) {
|
|
121
|
+
this.prev.pop();
|
|
122
|
+
return { contents: '', syntax: 'scss' };
|
|
123
|
+
}
|
|
124
|
+
if (canonicalUrl.protocol === 'file:') {
|
|
125
|
+
const syntax = canonicalUrl.pathname.endsWith('.sass')
|
|
126
|
+
? 'indented'
|
|
127
|
+
: canonicalUrl.pathname.endsWith('.css')
|
|
128
|
+
? 'css'
|
|
129
|
+
: 'scss';
|
|
130
|
+
let contents = (_a = this.lastContents) !== null && _a !== void 0 ? _a : fs.readFileSync((0, utils_1.fileUrlToPathCrossPlatform)(canonicalUrl), 'utf-8');
|
|
131
|
+
this.lastContents = undefined;
|
|
132
|
+
if (syntax === 'scss') {
|
|
133
|
+
contents += this.endOfLoadImport;
|
|
134
|
+
}
|
|
135
|
+
else if (syntax === 'indented') {
|
|
136
|
+
contents += `\n@import "${exports.endOfLoadProtocol}${endOfLoadCount++}"`;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.prev.pop();
|
|
140
|
+
}
|
|
141
|
+
return { contents, syntax };
|
|
142
|
+
}
|
|
143
|
+
const lastContents = this.lastContents;
|
|
144
|
+
assert_1.strict.notEqual(lastContents, undefined);
|
|
145
|
+
this.lastContents = undefined;
|
|
146
|
+
return {
|
|
147
|
+
contents: lastContents + this.endOfLoadImport,
|
|
148
|
+
syntax: 'scss',
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
// Invokes each callback in `this.callbacks` until one returns a non-null
|
|
152
|
+
// `LegacyImporterResult`, then returns that result. Returns `null` if all
|
|
153
|
+
// callbacks return `null`.
|
|
154
|
+
invokeCallbacks(url, prev, { fromImport }) {
|
|
155
|
+
const self = { ...this.self, fromImport };
|
|
156
|
+
self.options = { ...self.options, context: self };
|
|
157
|
+
const invokeNthCallback = (n) => (0, utils_1.thenOr)(this.invokeCallback(this.callbacks[n], self, url, prev), result => {
|
|
158
|
+
if (result !== null)
|
|
159
|
+
return result;
|
|
160
|
+
if (n === this.callbacks.length - 1)
|
|
161
|
+
return null;
|
|
162
|
+
return invokeNthCallback(n + 1);
|
|
163
|
+
});
|
|
164
|
+
return invokeNthCallback(0);
|
|
165
|
+
}
|
|
166
|
+
// Invokes `callback` and converts its return value into a `PromiseOr`.
|
|
167
|
+
invokeCallback(callback, self, url, prev) {
|
|
168
|
+
if (this.sync) {
|
|
169
|
+
return callback.call(self, url, prev);
|
|
170
|
+
}
|
|
171
|
+
return new Promise(resolve => {
|
|
172
|
+
// The cast here is necesary to work around microsoft/TypeScript#33815.
|
|
173
|
+
const syncResult = callback.call(self, url, prev, resolve);
|
|
174
|
+
if (syncResult !== undefined)
|
|
175
|
+
resolve(syncResult);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
// The `@import` statement to inject after the contents of files to ensure
|
|
179
|
+
// that we know when a load has completed so we can pass the correct `prev`
|
|
180
|
+
// argument to callbacks.
|
|
181
|
+
get endOfLoadImport() {
|
|
182
|
+
return `\n;@import "${exports.endOfLoadProtocol}${endOfLoadCount++}";`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.LegacyImporterWrapper = LegacyImporterWrapper;
|
|
186
|
+
//# sourceMappingURL=importer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importer.js","sourceRoot":"","sources":["../../../../lib/src/legacy/importer.ts"],"names":[],"mappings":";AAAA,uEAAuE;AACvE,gEAAgE;AAChE,uCAAuC;;;AAEvC,mCAAwC;AACxC,6BAAkD;AAClD,yBAAyB;AACzB,0BAA0B;AAE1B,iDAA2C;AAC3C,oCAKkB;AAYlB;;;;;GAKG;AACU,QAAA,iBAAiB,GAAG,iCAAiC,CAAC;AAEnE;;GAEG;AACU,QAAA,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD,4EAA4E;AAC5E,6EAA6E;AAC7E,IAAI,cAAc,GAAG,CAAC,CAAC;AAYvB;;;GAGG;AACH,MAAa,qBAAqB;IAehC,sCAAsC;IAEtC,YACmB,IAAsB,EACtB,SAAsC,EACtC,SAAmB,EACpC,WAAmB,EACF,IAAuB;QAJvB,SAAI,GAAJ,IAAI,CAAkB;QACtB,cAAS,GAAT,SAAS,CAA6B;QACtC,cAAS,GAAT,SAAS,CAAU;QAEnB,SAAI,GAAJ,IAAI,CAAmB;QAnB1C,uDAAuD;QACtC,SAAI,GAAkB,EAAE,CAAC;QAM1C,6EAA6E;QAC7E,8EAA8E;QAC9E,2DAA2D;QACnD,0BAAqB,GAAG,IAAI,CAAC;QAWnC,MAAM,IAAI,GAAG,WAAW,KAAK,OAAO,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;IACvE,CAAC;IA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