sass-embedded-go 1.104.0-alpha0

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 (161) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/lib/index.js +100 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/index.mjs +215 -0
  6. package/lib/src/canonicalize-context.js +31 -0
  7. package/lib/src/canonicalize-context.js.map +1 -0
  8. package/lib/src/compile.js +51 -0
  9. package/lib/src/compile.js.map +1 -0
  10. package/lib/src/compiler/async.js +187 -0
  11. package/lib/src/compiler/async.js.map +1 -0
  12. package/lib/src/compiler/sync.js +204 -0
  13. package/lib/src/compiler/sync.js.map +1 -0
  14. package/lib/src/compiler/utils.js +210 -0
  15. package/lib/src/compiler/utils.js.map +1 -0
  16. package/lib/src/compiler-module.js +64 -0
  17. package/lib/src/compiler-module.js.map +1 -0
  18. package/lib/src/compiler-path.js +82 -0
  19. package/lib/src/compiler-path.js.map +1 -0
  20. package/lib/src/deprecations.js +121 -0
  21. package/lib/src/deprecations.js.map +1 -0
  22. package/lib/src/deprotofy-span.js +41 -0
  23. package/lib/src/deprotofy-span.js.map +1 -0
  24. package/lib/src/dispatcher.js +241 -0
  25. package/lib/src/dispatcher.js.map +1 -0
  26. package/lib/src/elf.js +114 -0
  27. package/lib/src/elf.js.map +1 -0
  28. package/lib/src/exception.js +23 -0
  29. package/lib/src/exception.js.map +1 -0
  30. package/lib/src/function-registry.js +127 -0
  31. package/lib/src/function-registry.js.map +1 -0
  32. package/lib/src/importer-registry.js +201 -0
  33. package/lib/src/importer-registry.js.map +1 -0
  34. package/lib/src/legacy/importer.js +296 -0
  35. package/lib/src/legacy/importer.js.map +1 -0
  36. package/lib/src/legacy/index.js +329 -0
  37. package/lib/src/legacy/index.js.map +1 -0
  38. package/lib/src/legacy/resolve-path.js +133 -0
  39. package/lib/src/legacy/resolve-path.js.map +1 -0
  40. package/lib/src/legacy/utils.js +58 -0
  41. package/lib/src/legacy/utils.js.map +1 -0
  42. package/lib/src/legacy/value/base.js +18 -0
  43. package/lib/src/legacy/value/base.js.map +1 -0
  44. package/lib/src/legacy/value/color.js +65 -0
  45. package/lib/src/legacy/value/color.js.map +1 -0
  46. package/lib/src/legacy/value/index.js +23 -0
  47. package/lib/src/legacy/value/index.js.map +1 -0
  48. package/lib/src/legacy/value/list.js +50 -0
  49. package/lib/src/legacy/value/list.js.map +1 -0
  50. package/lib/src/legacy/value/map.js +74 -0
  51. package/lib/src/legacy/value/map.js.map +1 -0
  52. package/lib/src/legacy/value/number.js +60 -0
  53. package/lib/src/legacy/value/number.js.map +1 -0
  54. package/lib/src/legacy/value/string.js +27 -0
  55. package/lib/src/legacy/value/string.js.map +1 -0
  56. package/lib/src/legacy/value/wrap.js +115 -0
  57. package/lib/src/legacy/value/wrap.js.map +1 -0
  58. package/lib/src/logger.js +10 -0
  59. package/lib/src/logger.js.map +1 -0
  60. package/lib/src/message-transformer.js +108 -0
  61. package/lib/src/message-transformer.js.map +1 -0
  62. package/lib/src/messages.js +6 -0
  63. package/lib/src/messages.js.map +1 -0
  64. package/lib/src/packet-transformer.js +171 -0
  65. package/lib/src/packet-transformer.js.map +1 -0
  66. package/lib/src/protofier.js +492 -0
  67. package/lib/src/protofier.js.map +1 -0
  68. package/lib/src/request-tracker.js +52 -0
  69. package/lib/src/request-tracker.js.map +1 -0
  70. package/lib/src/utils.js +177 -0
  71. package/lib/src/utils.js.map +1 -0
  72. package/lib/src/value/argument-list.js +66 -0
  73. package/lib/src/value/argument-list.js.map +1 -0
  74. package/lib/src/value/boolean.js +69 -0
  75. package/lib/src/value/boolean.js.map +1 -0
  76. package/lib/src/value/calculations.js +114 -0
  77. package/lib/src/value/calculations.js.map +1 -0
  78. package/lib/src/value/color.js +869 -0
  79. package/lib/src/value/color.js.map +1 -0
  80. package/lib/src/value/function.js +74 -0
  81. package/lib/src/value/function.js.map +1 -0
  82. package/lib/src/value/index.js +166 -0
  83. package/lib/src/value/index.js.map +1 -0
  84. package/lib/src/value/list.js +101 -0
  85. package/lib/src/value/list.js.map +1 -0
  86. package/lib/src/value/map.js +92 -0
  87. package/lib/src/value/map.js.map +1 -0
  88. package/lib/src/value/mixin.js +50 -0
  89. package/lib/src/value/mixin.js.map +1 -0
  90. package/lib/src/value/null.js +49 -0
  91. package/lib/src/value/null.js.map +1 -0
  92. package/lib/src/value/number.js +583 -0
  93. package/lib/src/value/number.js.map +1 -0
  94. package/lib/src/value/string.js +118 -0
  95. package/lib/src/value/string.js.map +1 -0
  96. package/lib/src/value/utils.js +124 -0
  97. package/lib/src/value/utils.js.map +1 -0
  98. package/lib/src/vendor/deprecations.js +216 -0
  99. package/lib/src/vendor/deprecations.js.map +1 -0
  100. package/lib/src/vendor/embedded_sass_pb.js +432 -0
  101. package/lib/src/vendor/embedded_sass_pb.js.map +1 -0
  102. package/lib/src/vendor/sass/README.md +162 -0
  103. package/lib/src/vendor/sass/compile.d.ts +342 -0
  104. package/lib/src/vendor/sass/deprecations.d.ts +312 -0
  105. package/lib/src/vendor/sass/exception.d.ts +41 -0
  106. package/lib/src/vendor/sass/importer.d.ts +471 -0
  107. package/lib/src/vendor/sass/index.d.ts +122 -0
  108. package/lib/src/vendor/sass/index.m.d.ts +122 -0
  109. package/lib/src/vendor/sass/legacy/exception.d.ts +55 -0
  110. package/lib/src/vendor/sass/legacy/function.d.ts +757 -0
  111. package/lib/src/vendor/sass/legacy/importer.d.ts +169 -0
  112. package/lib/src/vendor/sass/legacy/options.d.ts +700 -0
  113. package/lib/src/vendor/sass/legacy/plugin_this.d.ts +74 -0
  114. package/lib/src/vendor/sass/legacy/render.d.ts +144 -0
  115. package/lib/src/vendor/sass/logger/index.d.ts +115 -0
  116. package/lib/src/vendor/sass/logger/source_location.d.ts +21 -0
  117. package/lib/src/vendor/sass/logger/source_span.d.ts +34 -0
  118. package/lib/src/vendor/sass/options.d.ts +468 -0
  119. package/lib/src/vendor/sass/util/promise_or.d.ts +17 -0
  120. package/lib/src/vendor/sass/value/argument_list.d.ts +47 -0
  121. package/lib/src/vendor/sass/value/boolean.d.ts +29 -0
  122. package/lib/src/vendor/sass/value/calculation.d.ts +137 -0
  123. package/lib/src/vendor/sass/value/color.d.ts +567 -0
  124. package/lib/src/vendor/sass/value/function.d.ts +22 -0
  125. package/lib/src/vendor/sass/value/index.d.ts +219 -0
  126. package/lib/src/vendor/sass/value/list.d.ts +54 -0
  127. package/lib/src/vendor/sass/value/map.d.ts +41 -0
  128. package/lib/src/vendor/sass/value/mixin.d.ts +14 -0
  129. package/lib/src/vendor/sass/value/number.d.ts +305 -0
  130. package/lib/src/vendor/sass/value/string.d.ts +84 -0
  131. package/lib/src/version.js +28 -0
  132. package/lib/src/version.js.map +1 -0
  133. package/package.json +36 -0
  134. package/types/compile.d.ts +342 -0
  135. package/types/deprecations.d.ts +312 -0
  136. package/types/exception.d.ts +41 -0
  137. package/types/importer.d.ts +471 -0
  138. package/types/index.d.ts +122 -0
  139. package/types/index.m.d.ts +122 -0
  140. package/types/legacy/exception.d.ts +55 -0
  141. package/types/legacy/function.d.ts +757 -0
  142. package/types/legacy/importer.d.ts +169 -0
  143. package/types/legacy/options.d.ts +700 -0
  144. package/types/legacy/plugin_this.d.ts +74 -0
  145. package/types/legacy/render.d.ts +144 -0
  146. package/types/logger/index.d.ts +115 -0
  147. package/types/logger/source_location.d.ts +21 -0
  148. package/types/logger/source_span.d.ts +34 -0
  149. package/types/options.d.ts +468 -0
  150. package/types/util/promise_or.d.ts +17 -0
  151. package/types/value/argument_list.d.ts +47 -0
  152. package/types/value/boolean.d.ts +29 -0
  153. package/types/value/calculation.d.ts +137 -0
  154. package/types/value/color.d.ts +567 -0
  155. package/types/value/function.d.ts +22 -0
  156. package/types/value/index.d.ts +219 -0
  157. package/types/value/list.d.ts +54 -0
  158. package/types/value/map.d.ts +41 -0
  159. package/types/value/mixin.d.ts +14 -0
  160. package/types/value/number.d.ts +305 -0
  161. package/types/value/string.d.ts +84 -0
@@ -0,0 +1,127 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.FunctionRegistry = void 0;
40
+ const util_1 = require("util");
41
+ const protobuf_1 = require("@bufbuild/protobuf");
42
+ const utils = __importStar(require("./utils"));
43
+ const proto = __importStar(require("./vendor/embedded_sass_pb"));
44
+ const utils_1 = require("./utils");
45
+ const protofier_1 = require("./protofier");
46
+ const value_1 = require("./value");
47
+ /**
48
+ * Tracks functions that are defined on the host so that the compiler can
49
+ * execute them.
50
+ */
51
+ class FunctionRegistry {
52
+ /**
53
+ * The globally unique identifier of the current compilation used for tracking
54
+ * the ownership of CompilerFunction and CompilerMixin objects.
55
+ */
56
+ compileContext = Symbol();
57
+ functionsByName = new Map();
58
+ functionsById = new Map();
59
+ idsByFunction = new Map();
60
+ /** The next ID to use for a function. */
61
+ id = 0;
62
+ constructor(functionsBySignature) {
63
+ for (const [signature, fn] of Object.entries(functionsBySignature ?? {})) {
64
+ const openParen = signature.indexOf('(');
65
+ if (openParen === -1) {
66
+ throw new Error(`options.functions: "${signature}" is missing "("`);
67
+ }
68
+ this.functionsByName.set(signature.substring(0, openParen), fn);
69
+ }
70
+ }
71
+ /** Registers `fn` as a function that can be called using the returned ID. */
72
+ register(fn) {
73
+ return utils.putIfAbsent(this.idsByFunction, fn, () => {
74
+ const id = this.id;
75
+ this.id += 1;
76
+ this.functionsById.set(id, fn);
77
+ return id;
78
+ });
79
+ }
80
+ /**
81
+ * Returns the function to which `request` refers and returns its response.
82
+ */
83
+ call(request) {
84
+ const protofier = new protofier_1.Protofier(this);
85
+ const fn = this.get(request);
86
+ return (0, utils_1.catchOr)(() => {
87
+ return (0, utils_1.thenOr)(fn(request.arguments.map(value => protofier.deprotofy(value))), result => {
88
+ if (!(result instanceof value_1.Value)) {
89
+ const name = request.identifier.case === 'name'
90
+ ? `"${request.identifier.value}"`
91
+ : 'anonymous function';
92
+ throw (`options.functions: ${name} returned non-Value: ` +
93
+ (0, util_1.inspect)(result));
94
+ }
95
+ return (0, protobuf_1.create)(proto.InboundMessage_FunctionCallResponseSchema, {
96
+ result: { case: 'success', value: protofier.protofy(result) },
97
+ accessedArgumentLists: protofier.accessedArgumentLists,
98
+ });
99
+ });
100
+ }, error => (0, protobuf_1.create)(proto.InboundMessage_FunctionCallResponseSchema, {
101
+ result: { case: 'error', value: `${error}` },
102
+ }));
103
+ }
104
+ /** Returns the function to which `request` refers. */
105
+ get(request) {
106
+ if (request.identifier.case === 'name') {
107
+ const fn = this.functionsByName.get(request.identifier.value);
108
+ if (fn)
109
+ return fn;
110
+ throw (0, utils_1.compilerError)('Invalid OutboundMessage_FunctionCallRequest: there is no function ' +
111
+ `named "${request.identifier.value}"`);
112
+ }
113
+ else if (request.identifier.case === 'functionId') {
114
+ const fn = this.functionsById.get(request.identifier.value);
115
+ if (fn)
116
+ return fn;
117
+ throw (0, utils_1.compilerError)('Invalid OutboundMessage_FunctionCallRequest: there is no function ' +
118
+ `with ID "${request.identifier.value}"`);
119
+ }
120
+ else {
121
+ throw (0, utils_1.compilerError)('Invalid OutboundMessage_FunctionCallRequest: function identifier is ' +
122
+ 'unset');
123
+ }
124
+ }
125
+ }
126
+ exports.FunctionRegistry = FunctionRegistry;
127
+ //# 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;AAC7B,iDAA0C;AAG1C,MAAY,KAAK,oCAAgB;AAEjC,MAAY,KAAK,sDAAkC;AACnD,mCAAkE;AAClE,2CAAsC;AACtC,mCAA8B;AAE9B;;;GAGG;AACH;IACE;;;OAGG;IACa,cAAc,GAAG,MAAM,EAAE,CAAC;IACzB,eAAe,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC1D,aAAa,GAAG,IAAI,GAAG,EAAgC,CAAC;IACxD,aAAa,GAAG,IAAI,GAAG,EAAgC,CAAC;IAEzE,yCAAyC;IACjC,EAAE,GAAG,CAAC,CAAC;IAEf,YAAY,oBAA2D;QACrE,KAAK,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAAE,CAAC;YACzE,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAA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M,CAAC;YACN,MAAM,IAAA,qBAAa,EACjB,sEAAsE;gBACpE,OAAO,CACV,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,201 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ImporterRegistry = exports.NodePackageImporter = void 0;
40
+ const module_1 = require("module");
41
+ const p = __importStar(require("path"));
42
+ const url_1 = require("url");
43
+ const util_1 = require("util");
44
+ const protobuf_1 = require("@bufbuild/protobuf");
45
+ const canonicalize_context_1 = require("./canonicalize-context");
46
+ const utils = __importStar(require("./utils"));
47
+ const proto = __importStar(require("./vendor/embedded_sass_pb"));
48
+ const utils_1 = require("./utils");
49
+ const entryPointDirectoryKey = Symbol();
50
+ class NodePackageImporter {
51
+ [entryPointDirectoryKey];
52
+ constructor(entryPointDirectory) {
53
+ entryPointDirectory = entryPointDirectory
54
+ ? p.resolve(entryPointDirectory)
55
+ : require.main?.filename
56
+ ? p.dirname(require.main.filename)
57
+ : // TODO: Find a way to use `import.meta.main` once
58
+ // https://github.com/nodejs/node/issues/49440 is done.
59
+ process.argv[1]
60
+ ? (0, module_1.createRequire)(process.argv[1]).resolve(process.argv[1])
61
+ : undefined;
62
+ if (!entryPointDirectory) {
63
+ throw new Error('The Node package importer cannot determine an entry point ' +
64
+ 'because `require.main.filename` is not defined. ' +
65
+ 'Please provide an `entryPointDirectory` to the `NodePackageImporter`.');
66
+ }
67
+ this[entryPointDirectoryKey] = entryPointDirectory;
68
+ }
69
+ }
70
+ exports.NodePackageImporter = NodePackageImporter;
71
+ /**
72
+ * A registry of importers defined in the host that can be invoked by the
73
+ * compiler.
74
+ */
75
+ class ImporterRegistry {
76
+ /** Protocol buffer representations of the registered importers. */
77
+ importers;
78
+ /** A map from importer IDs to their corresponding importers. */
79
+ importersById = new Map();
80
+ /** A map from file importer IDs to their corresponding importers. */
81
+ fileImportersById = new Map();
82
+ /** The next ID to use for an importer. */
83
+ id = 0;
84
+ constructor(options) {
85
+ this.importers = (options?.importers ?? [])
86
+ .map(importer => this.register(importer))
87
+ .concat((options?.loadPaths ?? []).map(path => (0, protobuf_1.create)(proto.InboundMessage_CompileRequest_ImporterSchema, {
88
+ importer: { case: 'path', value: p.resolve(path) },
89
+ })));
90
+ }
91
+ /** Converts an importer to a proto without adding it to `this.importers`. */
92
+ register(importer) {
93
+ const message = (0, protobuf_1.create)(proto.InboundMessage_CompileRequest_ImporterSchema, {});
94
+ if (importer instanceof NodePackageImporter) {
95
+ const importerMessage = (0, protobuf_1.create)(proto.NodePackageImporterSchema, {
96
+ entryPointDirectory: importer[entryPointDirectoryKey],
97
+ });
98
+ message.importer = {
99
+ case: 'nodePackageImporter',
100
+ value: importerMessage,
101
+ };
102
+ }
103
+ else if ('canonicalize' in importer) {
104
+ if ('findFileUrl' in importer) {
105
+ throw new Error('Importer may not contain both canonicalize() and findFileUrl(): ' +
106
+ (0, util_1.inspect)(importer));
107
+ }
108
+ message.importer = { case: 'importerId', value: this.id };
109
+ message.nonCanonicalScheme =
110
+ typeof importer.nonCanonicalScheme === 'string'
111
+ ? [importer.nonCanonicalScheme]
112
+ : (importer.nonCanonicalScheme ?? []);
113
+ this.importersById.set(this.id, importer);
114
+ }
115
+ else {
116
+ message.importer = { case: 'fileImporterId', value: this.id };
117
+ this.fileImportersById.set(this.id, importer);
118
+ }
119
+ this.id += 1;
120
+ return message;
121
+ }
122
+ /** Handles a canonicalization request. */
123
+ canonicalize(request) {
124
+ const importer = this.importersById.get(request.importerId);
125
+ if (!importer) {
126
+ throw utils.compilerError('Unknown CanonicalizeRequest.importer_id');
127
+ }
128
+ const canonicalizeContext = new canonicalize_context_1.CanonicalizeContext(request.containingUrl ? new url_1.URL(request.containingUrl) : null, request.fromImport);
129
+ return (0, utils_1.catchOr)(() => {
130
+ return (0, utils_1.thenOr)(importer.canonicalize(request.url, canonicalizeContext), url => (0, protobuf_1.create)(proto.InboundMessage_CanonicalizeResponseSchema, {
131
+ result: url === null
132
+ ? { case: undefined }
133
+ : { case: 'url', value: url.toString() },
134
+ containingUrlUnused: !canonicalizeContext.containingUrlAccessed,
135
+ }));
136
+ }, error => (0, protobuf_1.create)(proto.InboundMessage_CanonicalizeResponseSchema, {
137
+ result: { case: 'error', value: `${error}` },
138
+ }));
139
+ }
140
+ /** Handles an import request. */
141
+ import(request) {
142
+ const importer = this.importersById.get(request.importerId);
143
+ if (!importer) {
144
+ throw utils.compilerError('Unknown ImportRequest.importer_id');
145
+ }
146
+ return (0, utils_1.catchOr)(() => {
147
+ return (0, utils_1.thenOr)(importer.load(new url_1.URL(request.url)), result => {
148
+ if (!result)
149
+ return (0, protobuf_1.create)(proto.InboundMessage_ImportResponseSchema, {});
150
+ if (typeof result.contents !== 'string') {
151
+ throw Error(`Invalid argument (contents): must be a string but was: ${result.contents.constructor.name}`);
152
+ }
153
+ if (result.sourceMapUrl && !result.sourceMapUrl.protocol) {
154
+ throw Error('Invalid argument (sourceMapUrl): must be absolute but was: ' +
155
+ result.sourceMapUrl);
156
+ }
157
+ return (0, protobuf_1.create)(proto.InboundMessage_ImportResponseSchema, {
158
+ result: {
159
+ case: 'success',
160
+ value: {
161
+ contents: result.contents,
162
+ syntax: utils.protofySyntax(result.syntax),
163
+ sourceMapUrl: result.sourceMapUrl?.toString() ?? '',
164
+ },
165
+ },
166
+ });
167
+ });
168
+ }, error => (0, protobuf_1.create)(proto.InboundMessage_ImportResponseSchema, {
169
+ result: { case: 'error', value: `${error}` },
170
+ }));
171
+ }
172
+ /** Handles a file import request. */
173
+ fileImport(request) {
174
+ const importer = this.fileImportersById.get(request.importerId);
175
+ if (!importer) {
176
+ throw utils.compilerError('Unknown FileImportRequest.importer_id');
177
+ }
178
+ const canonicalizeContext = new canonicalize_context_1.CanonicalizeContext(request.containingUrl ? new url_1.URL(request.containingUrl) : null, request.fromImport);
179
+ return (0, utils_1.catchOr)(() => {
180
+ return (0, utils_1.thenOr)(importer.findFileUrl(request.url, canonicalizeContext), url => {
181
+ if (!url) {
182
+ return (0, protobuf_1.create)(proto.InboundMessage_FileImportResponseSchema, {
183
+ containingUrlUnused: !canonicalizeContext.containingUrlAccessed,
184
+ });
185
+ }
186
+ if (url.protocol !== 'file:') {
187
+ throw (`FileImporter ${(0, util_1.inspect)(importer)} returned non-file: URL ` +
188
+ +`"${url}" for URL "${request.url}".`);
189
+ }
190
+ return (0, protobuf_1.create)(proto.InboundMessage_FileImportResponseSchema, {
191
+ result: { case: 'fileUrl', value: url.toString() },
192
+ containingUrlUnused: !canonicalizeContext.containingUrlAccessed,
193
+ });
194
+ });
195
+ }, error => (0, protobuf_1.create)(proto.InboundMessage_FileImportResponseSchema, {
196
+ result: { case: 'error', value: `${error}` },
197
+ }));
198
+ }
199
+ }
200
+ exports.ImporterRegistry = ImporterRegistry;
201
+ //# 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,mCAAqC;AACrC,MAAY,CAAC,iCAAa;AAC1B,6BAAwB;AACxB,+BAA6B;AAC7B,iDAA0C;AAE1C,iEAA2D;AAC3D,MAAY,KAAK,oCAAgB;AAEjC,MAAY,KAAK,sDAAkC;AACnD,mCAAmD;AAEnD,MAAM,sBAAsB,GAAG,MAAM,EAAE,CAAC;AAExC;IACW,CAAC,sBAAsB,CAAC,CAAS;IAE1C,YAAY,mBAA4B;QACtC,mBAAmB,GAAG,mBAAmB;YACvC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;YAChC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ;gBACtB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAClC,CAAC,CAAC,kDAAkD;oBAClD,uDAAuD;oBACvD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;wBACf,CAAC,CAAC,IAAA,sBAAa,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;wBACzD,CAAC,CAAC,SAAS,CAAC;QAClB,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,4DAA4D;gBAC1D,kDAAkD;gBAClD,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Aa,CAAC,CAAC,CAAC,CAAC,IAAI,EAC7D,OAAO,CAAC,UAAU,CACnB,CAAC;QAEF,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE;YACH,OAAO,IAAA,cAAM,EACX,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,mBAAmB,CAAC,EACtD,GAAG,CAAC,EAAE;gBACJ,IAAI,CAAC,GAAG,EAAE,CAAC;oBACT,OAAO,IAAA,iBAAM,EAAC,KAAK,CAAC,uCAAuC,EAAE;wBAC3D,mBAAmB,EAAE,CAAC,mBAAmB,CAAC,qBAAqB;qBAChE,CAAC,CAAC;gBACL,CAAC;gBACD,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;oBAC7B,MAAM,CACJ,gBAAgB,IAAA,cAAO,EAAC,QAAQ,CAAC,0BAA0B;wBAC3D,CAAC,IAAI,GAAG,cAAc,OAAO,CAAC,GAAG,IAAI,CACtC,CAAC;gBACJ,CAAC;gBACD,OAAO,IAAA,iBAAM,EAAC,KAAK,CAAC,uCAAuC,EAAE;oBAC3D,MAAM,EAAE,EAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE,EAAC;oBAChD,mBAAmB,EAAE,CAAC,mBAAmB,CAAC,qBAAqB;iBAChE,CAAC,CAAC;YACL,CAAC,CACF,CAAC;QACJ,CAAC,EACD,KAAK,CAAC,EAAE,CACN,IAAA,iBAAM,EAAC,KAAK,CAAC,uCAAuC,EAAE;YACpD,MAAM,EAAE,EAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,EAAC;SAC3C,CAAC,CACL,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,296 @@
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.LegacyImporterWrapper = exports.metaNamespace = exports.legacyImporterFileProtocol = exports.endOfLoadProtocol = void 0;
40
+ const assert_1 = require("assert");
41
+ const fs = __importStar(require("fs"));
42
+ const p = __importStar(require("path"));
43
+ const util = __importStar(require("util"));
44
+ const resolve_path_1 = require("./resolve-path");
45
+ const utils_1 = require("../utils");
46
+ const utils_2 = require("./utils");
47
+ /**
48
+ * A special URL protocol we use to signal when a stylesheet has finished
49
+ * loading. This allows us to determine which stylesheet is "current" when
50
+ * resolving a new load, which in turn allows us to pass in an accurate `prev`
51
+ * parameter to the legacy callback.
52
+ */
53
+ exports.endOfLoadProtocol = 'sass-embedded-legacy-load-done:';
54
+ /**
55
+ * The `file:` URL protocol with [legacyImporterProtocolPrefix] at the beginning.
56
+ */
57
+ exports.legacyImporterFileProtocol = 'legacy-importer-file:';
58
+ /**
59
+ * A random namespace for `sass:meta`, so we can use `meta.load-css()` at the end
60
+ * of the file to signal that a load has finished without polluting a namespace
61
+ * a user might actually use.
62
+ */
63
+ exports.metaNamespace = `---${Math.random().toString(36).substring(2)}`;
64
+ // A count of `endOfLoadProtocol` imports that have been generated. Each one
65
+ // must be a different URL to ensure that the importer results aren't cached.
66
+ let endOfLoadCount = 0;
67
+ /**
68
+ * A wrapper around a `LegacyImporter` callback that exposes it as a new-API
69
+ * `Importer`.
70
+ */
71
+ class LegacyImporterWrapper {
72
+ self;
73
+ callbacks;
74
+ loadPaths;
75
+ sync;
76
+ // A stack of previous URLs passed to `this.callbacks`.
77
+ prev = [];
78
+ // The `contents` field returned by the last successful invocation of
79
+ // `this.callbacks`, if it returned one.
80
+ lastContents;
81
+ constructor(self, callbacks, loadPaths, initialPrev, sync) {
82
+ this.self = self;
83
+ this.callbacks = callbacks;
84
+ this.loadPaths = loadPaths;
85
+ this.sync = sync;
86
+ const path = initialPrev !== 'stdin';
87
+ this.prev.push({ url: path ? p.resolve(initialPrev) : 'stdin', path });
88
+ }
89
+ canonicalize(url, options) {
90
+ if (url.startsWith(exports.endOfLoadProtocol))
91
+ return new URL(url);
92
+ // Emulate a base importer instead of using a real base importer,
93
+ // because we want to mark containingUrl as used, which is impossible
94
+ // in a real base importer.
95
+ if (options.containingUrl !== null) {
96
+ try {
97
+ const absoluteUrl = new URL(url, options.containingUrl).toString();
98
+ const resolved = this.canonicalize(absoluteUrl, {
99
+ fromImport: options.fromImport,
100
+ containingUrl: null,
101
+ });
102
+ if (resolved !== null)
103
+ return resolved;
104
+ }
105
+ catch (error) {
106
+ if (error instanceof TypeError &&
107
+ (0, utils_1.isErrnoException)(error) &&
108
+ error.code === 'ERR_INVALID_URL') {
109
+ // ignore
110
+ }
111
+ else {
112
+ throw error;
113
+ }
114
+ }
115
+ }
116
+ if (url.startsWith(utils_2.legacyImporterProtocolPrefix) ||
117
+ url.startsWith(utils_2.legacyImporterProtocol)) {
118
+ // A load starts with `legacyImporterProtocolPrefix` if and only if it's a
119
+ // relative load for the current importer rather than an absolute load.
120
+ // For the most part, we want to ignore these, but for `file:` URLs
121
+ // specifically we want to resolve them on the filesystem to ensure
122
+ // locality.
123
+ const urlWithoutPrefix = url.substring(utils_2.legacyImporterProtocolPrefix.length);
124
+ if (urlWithoutPrefix.startsWith('file:')) {
125
+ let resolved = null;
126
+ try {
127
+ const path = (0, utils_1.fileUrlToPathCrossPlatform)(urlWithoutPrefix);
128
+ resolved = (0, resolve_path_1.resolvePath)(path, options.fromImport);
129
+ }
130
+ catch (error) {
131
+ if (error instanceof TypeError &&
132
+ (0, utils_1.isErrnoException)(error) &&
133
+ (error.code === 'ERR_INVALID_URL' ||
134
+ error.code === 'ERR_INVALID_FILE_URL_PATH')) {
135
+ // It's possible for `url` to represent an invalid path for the
136
+ // current platform. For example, `@import "/foo/bar/baz"` will
137
+ // resolve to `file:///foo/bar/baz` which is an invalid URL on
138
+ // Windows. In that case, we treat it as though the file doesn't
139
+ // exist so that the user's custom importer can still handle the
140
+ // URL.
141
+ }
142
+ else {
143
+ throw error;
144
+ }
145
+ }
146
+ if (resolved !== null) {
147
+ this.prev.push({ url: resolved, path: true });
148
+ return (0, utils_2.pathToLegacyFileUrl)(resolved);
149
+ }
150
+ }
151
+ return null;
152
+ }
153
+ const prev = this.prev[this.prev.length - 1];
154
+ return (0, utils_1.thenOr)((0, utils_1.thenOr)(this.invokeCallbacks(url, prev.url, options), result => {
155
+ if (result instanceof Error)
156
+ throw result;
157
+ if (result === null)
158
+ return null;
159
+ if (typeof result !== 'object') {
160
+ throw ('Expected importer to return an object, got ' +
161
+ `${util.inspect(result)}.`);
162
+ }
163
+ if ('contents' in result || !('file' in result)) {
164
+ this.lastContents = result.contents ?? '';
165
+ if ('file' in result) {
166
+ return new URL(utils_2.legacyImporterProtocol +
167
+ encodeURI(result.file));
168
+ }
169
+ else if (/^[A-Za-z+.-]+:/.test(url)) {
170
+ return new URL(`${utils_2.legacyImporterProtocolPrefix}${url}`);
171
+ }
172
+ else {
173
+ return new URL(utils_2.legacyImporterProtocol + encodeURI(url));
174
+ }
175
+ }
176
+ else {
177
+ if (p.isAbsolute(result.file)) {
178
+ const resolved = (0, resolve_path_1.resolvePath)(result.file, options.fromImport);
179
+ return resolved ? (0, utils_2.pathToLegacyFileUrl)(resolved) : null;
180
+ }
181
+ const prefixes = [...this.loadPaths, '.'];
182
+ if (prev.path)
183
+ prefixes.unshift(p.dirname(prev.url));
184
+ for (const prefix of prefixes) {
185
+ const resolved = (0, resolve_path_1.resolvePath)(p.join(prefix, result.file), options.fromImport);
186
+ if (resolved !== null)
187
+ return (0, utils_2.pathToLegacyFileUrl)(resolved);
188
+ }
189
+ return null;
190
+ }
191
+ }), result => {
192
+ if (result !== null) {
193
+ const path = result.protocol === exports.legacyImporterFileProtocol;
194
+ this.prev.push({
195
+ url: path ? (0, utils_2.legacyFileUrlToPath)(result) : url,
196
+ path,
197
+ });
198
+ return result;
199
+ }
200
+ else {
201
+ for (const loadPath of this.loadPaths) {
202
+ const resolved = (0, resolve_path_1.resolvePath)(p.join(loadPath, url), options.fromImport);
203
+ if (resolved !== null)
204
+ return (0, utils_2.pathToLegacyFileUrl)(resolved);
205
+ }
206
+ return null;
207
+ }
208
+ });
209
+ }
210
+ load(canonicalUrl) {
211
+ if (canonicalUrl.protocol === exports.endOfLoadProtocol) {
212
+ this.prev.pop();
213
+ return {
214
+ contents: '',
215
+ syntax: 'scss',
216
+ sourceMapUrl: new URL(exports.endOfLoadProtocol),
217
+ };
218
+ }
219
+ if (canonicalUrl.protocol === exports.legacyImporterFileProtocol) {
220
+ const syntax = canonicalUrl.pathname.endsWith('.sass')
221
+ ? 'indented'
222
+ : canonicalUrl.pathname.endsWith('.css')
223
+ ? 'css'
224
+ : 'scss';
225
+ let contents = this.lastContents ??
226
+ fs.readFileSync((0, utils_2.legacyFileUrlToPath)(canonicalUrl), 'utf-8');
227
+ this.lastContents = undefined;
228
+ if (syntax === 'css') {
229
+ this.prev.pop();
230
+ }
231
+ else {
232
+ contents = this.wrapContents(contents, syntax);
233
+ }
234
+ return { contents, syntax, sourceMapUrl: canonicalUrl };
235
+ }
236
+ const lastContents = this.lastContents;
237
+ assert_1.strict.notEqual(lastContents, undefined);
238
+ this.lastContents = undefined;
239
+ return {
240
+ contents: this.wrapContents(lastContents, 'scss'),
241
+ syntax: 'scss',
242
+ sourceMapUrl: canonicalUrl,
243
+ };
244
+ }
245
+ // Invokes each callback in `this.callbacks` until one returns a non-null
246
+ // `LegacyImporterResult`, then returns that result. Returns `null` if all
247
+ // callbacks return `null`.
248
+ invokeCallbacks(url, prev, { fromImport }) {
249
+ (0, assert_1.strict)(this.callbacks.length > 0);
250
+ const self = { ...this.self, fromImport };
251
+ self.options = { ...self.options, context: self };
252
+ const invokeNthCallback = (n) => (0, utils_1.thenOr)(this.invokeCallback(this.callbacks[n], self, url, prev), result => {
253
+ if (result === null) {
254
+ if (n === this.callbacks.length - 1)
255
+ return null;
256
+ return invokeNthCallback(n + 1);
257
+ }
258
+ if ('contents' in result &&
259
+ result.contents &&
260
+ typeof result.contents !== 'string') {
261
+ throw new Error(`Invalid argument (contents): must be a string but was: ${result.contents.constructor.name}`);
262
+ }
263
+ return result;
264
+ });
265
+ return invokeNthCallback(0);
266
+ }
267
+ // Invokes `callback` and converts its return value into a `PromiseOr`.
268
+ invokeCallback(callback, self, url, prev) {
269
+ if (this.sync) {
270
+ return callback.call(self, url, prev);
271
+ }
272
+ return new Promise(resolve => {
273
+ // The cast here is necesary to work around microsoft/TypeScript#33815.
274
+ const syncResult = callback.call(self, url, prev, resolve);
275
+ if (syncResult !== undefined)
276
+ resolve(syncResult);
277
+ });
278
+ }
279
+ // Modifies {@link contents} to ensure that we know when a load has completed
280
+ // so we can pass the correct `prev` argument to callbacks.
281
+ wrapContents(contents, syntax) {
282
+ const url = `"${exports.endOfLoadProtocol}${endOfLoadCount++}"`;
283
+ if (syntax === 'scss') {
284
+ return (`@use "sass:meta" as ${exports.metaNamespace};` +
285
+ contents +
286
+ `\n;@include ${exports.metaNamespace}.load-css(${url});`);
287
+ }
288
+ else {
289
+ return (`@use "sass:meta" as ${exports.metaNamespace}\n` +
290
+ contents +
291
+ `\n@include ${exports.metaNamespace}.load-css(${url})`);
292
+ }
293
+ }
294
+ }
295
+ exports.LegacyImporterWrapper = LegacyImporterWrapper;
296
+ //# 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,MAAY,EAAE,+BAAW;AACzB,MAAY,CAAC,iCAAa;AAC1B,MAAY,IAAI,iCAAa;AAE7B,iDAA2C;AAC3C,oCAMkB;AAWlB,mCAKiB;AAEjB;;;;;GAKG;AACU,QAAA,iBAAiB,GAAG,iCAAiC,CAAC;AAEnE;;GAEG;AACU,QAAA,0BAA0B,GAAG,uBAAuB,CAAC;AAElE;;;;GAIG;AACU,QAAA,aAAa,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;AAE7E,4EAA4E;AAC5E,6EAA6E;AAC7E,IAAI,cAAc,GAAG,CAAC,CAAC;AAYvB;;;GAGG;AACH;IAWqB,IAAI;IACJ,SAAS;IACT,SAAS;IAET,IAAI;IAZvB,uDAAuD;IACtC,IAAI,GAAkB,EAAE,CAAC;IAE1C,qEAAqE;IACrE,wCAAwC;IAChC,YAAY,CAAqB;IAEzC,YACmB,IAAsB,EACtB,SAAsC,EACtC,SAAmB,E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