-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement first class mixins #2073
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
ef23769
initial impl of first class mixins
connorskees 0b9f3a8
add mixin type to js api
connorskees 63c1f5e
add first class mixins to embedded protocol
connorskees f9badfa
support AsyncBuiltInCallable in accepts-content
connorskees 010ad35
generate evaluate file
connorskees b908e27
bump ci
connorskees 7d6757c
merge main
connorskees f715c22
revert embedded protocol changes
connorskees c0eced3
Style nits
nex3 91ac279
some pr review
connorskees 194e171
Revert "revert embedded protocol changes"
connorskees 154e12e
remove redundant content cast
connorskees ca57cb0
correctly pass content through meta.apply
connorskees 4093914
correctly pass through acceptsContent value
connorskees eb33c56
pr review
connorskees eeb14ee
refactor embedded registry
connorskees 1cfd14b
merge main
connorskees 5e1774c
merge main
connorskees faba24a
await _applyMixin
connorskees 52a1e6f
Merge branch 'main' of https://github.com/sass/dart-sass into feat/fi…
connorskees ff3d80e
Merge branch 'main' of https://github.com/sass/dart-sass into feat/fi…
connorskees 89ef731
add doc comment to _applyMixin
connorskees 93b812a
run synchronize
connorskees 6e85d50
bump ci
connorskees 2738c00
merge main
connorskees 80fd8bb
Update pubspec and changelog
nex3 9485b4f
merge main
connorskees 3144e02
nits
connorskees f1c1d5a
lazily evaluate file spans
connorskees 895b2ca
Merge branch 'main' of https://github.com/sass/dart-sass into feat/fi…
connorskees 96bbca2
bump ci
connorskees 679e1bd
bump ci
connorskees 65f2d2d
Merge branch 'main' of https://github.com/sass/dart-sass into feat/fi…
connorskees 75ccdfb
take Object self in JS constructor
connorskees 6277d5d
bump ci
connorskees f1b4ff3
add SassMixin to ESM export
connorskees File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2019 Google Inc. Use of this source code is governed by an | ||
// MIT-style license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
/// A registry of some `T` indexed by ID so that the host can invoke | ||
/// them. | ||
final class OpaqueRegistry<T> { | ||
/// Instantiations of `T` that have been sent to the host. | ||
/// | ||
/// The values are located at indexes in the list matching their IDs. | ||
final _elementsById = <T>[]; | ||
|
||
/// A reverse map from elements to their indexes in [_elementsById]. | ||
final _idsByElement = <T, int>{}; | ||
|
||
/// Returns the compiler-side id associated with [element]. | ||
int getId(T element) { | ||
var id = _idsByElement.putIfAbsent(element, () { | ||
_elementsById.add(element); | ||
return _elementsById.length - 1; | ||
}); | ||
|
||
return id; | ||
} | ||
|
||
/// Returns the compiler-side element associated with [id]. | ||
/// | ||
/// If no such element exists, returns `null`. | ||
T? operator [](int id) => _elementsById[id]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2021 Google Inc. Use of this source code is governed by an | ||
// MIT-style license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
import 'package:node_interop/js.dart'; | ||
|
||
import '../../callable.dart'; | ||
import '../../value.dart'; | ||
import '../reflection.dart'; | ||
import '../utils.dart'; | ||
|
||
/// The JavaScript `SassMixin` class. | ||
final JSClass mixinClass = () { | ||
var jsClass = createJSClass('sass.SassMixin', (Object self) { | ||
jsThrow(JsError( | ||
'It is not possible to construct a SassMixin through the JavaScript API')); | ||
}); | ||
|
||
getJSClass(SassMixin(Callable('f', '', (_) => sassNull))) | ||
.injectSuperclass(jsClass); | ||
return jsClass; | ||
}(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this does not make much sense. If I understand it correctly the reason we have this for Sass Function type is to allow the "JS" type to inherit the prototype of dart-converted-JS type? If so here the argument passed into SassMixin (the dart type) should be some argument necessary to construct an actual Mixin object.
@nex3 I don't fully understand how the JS-interop works so please correct me if I'm wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind. Looks like Mixin just takes AsyncCallable so this is probably fine.