Skip to content
This repository was archived by the owner on May 18, 2023. It is now read-only.

Commit 4de6435

Browse files
authoredDec 8, 2022
Treat certain user-caused errors as compilation failures (#98)
See sass/dart-sass-embedded#117
1 parent 6e4c63c commit 4de6435

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed
 

‎CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## 1.2.0
2+
3+
* Have the compiler treat several user-generated invalid responses as
4+
compilation errors rather than `ProtocolError`s:
5+
6+
* Invalid function signatures in `CompileRequest.global_functions`.
7+
8+
* Non-absolute URLs in `CanonicalizeResponse.result.url`,
9+
`ImportSuccess.source_map_url`, and `FileImportResponse.result.file_url`.
10+
11+
* Clarify that an invalid signature in a `HostFunction` should treat the current
12+
function as failing, rather than the `HostFunction`.
13+
114
## 1.1.0
215

316
* Add a `charset` option that controls whether or not Sass emits a

‎README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ not limited to:
137137

138138
* Sending a message with a `null` value for a mandatory field.
139139

140-
The `ProtocolError` message must *not* be used to report Sass errors or errors
141-
running custom functions or importers.
140+
The `ProtocolError` message must *not* be used to report Sass language errors.
142141

143142
### Host Language API
144143

‎VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.2.0

‎embedded_sass.proto

+19-12
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,15 @@ message InboundMessage {
100100
repeated Importer importers = 6;
101101

102102
// Signatures for custom global functions whose behavior is defined by the
103-
// host. These must be valid Sass function signatures that could appear in
104-
// after `@function` in a Sass stylesheet, such as
105-
// `mix($color1, $color2, $weight: 50%)`.
103+
// host.
104+
//
105+
// If this is not a valid Sass function signature that could appear after
106+
// `@function` in a Sass stylesheet (such as `mix($color1, $color2, $weight:
107+
// 50%)`), or if it conflicts with a function name that's built into the
108+
// Sass language, the compiler must treat the compilation as failed.
106109
//
107110
// Compilers must ensure that pure-Sass functions take precedence over
108-
// custom global functions. They must also reject any custom function names
109-
// that conflict with function names built into the Sass language.
111+
// custom global functions.
110112
repeated string global_functions = 7;
111113

112114
// Whether to use terminal colors in the formatted message of errors and
@@ -141,8 +143,10 @@ message InboundMessage {
141143
// that the importer either did not recognize the URL, or could not find a
142144
// stylesheet at the location it referred to.
143145
oneof result {
144-
// The successfully canonicalized URL. This must be an absolute URL,
145-
// including scheme.
146+
// The successfully canonicalized URL.
147+
//
148+
// If this is not an absolute URL (including scheme), the compiler must
149+
// treat that as an error thrown by the importer.
146150
string url = 2;
147151

148152
// An error message explaining why canonicalization failed.
@@ -173,7 +177,8 @@ message InboundMessage {
173177
// acceptable as well. If no URL is supplied, a `data:` URL is generated
174178
// automatically from `contents`.
175179
//
176-
// If this is provided, it must be an absolute URL, including scheme.
180+
// If this is provided and is not an absolute URL (including scheme) the
181+
// compiler must treat that as an error thrown by the importer.
177182
string source_map_url = 3;
178183
}
179184

@@ -200,9 +205,10 @@ message InboundMessage {
200205
// The absolute `file:` URL to look for the file on the physical
201206
// filesystem.
202207
//
203-
// The host must ensure that this URL follows the format for an absolute
204-
// `file:` URL on the current operating system without a hostname, and the
205-
// compiler must verify this to the best of its ability. See
208+
// The compiler must verify to the best of its ability that this URL
209+
// follows the format for an absolute `file:` URL on the current operating
210+
// system without a hostname. If it doesn't, the compiler must treat that
211+
// as an error thrown by the importer. See
206212
// https://en.wikipedia.org/wiki/File_URI_scheme for details on the
207213
// format.
208214
//
@@ -836,7 +842,8 @@ message Value {
836842
//
837843
// If this isn't a valid Sass function signature that could appear after
838844
// `@function` in a Sass stylesheet (such as `mix($color1, $color2, $weight:
839-
// 50%)`), the compiler must treat the function's return value as invalid.
845+
// 50%)`), the compiler must treat it as though the function that returned
846+
// this `HostFunction` threw an error.
840847
//
841848
// > This ensures that the host doesn't need to be able to correctly parse
842849
// > the entire function declaration syntax.

0 commit comments

Comments
 (0)
This repository has been archived.