Skip to content
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

Expose calculations in JS API #1988

Merged
merged 28 commits into from
Jul 19, 2023
Merged

Expose calculations in JS API #1988

merged 28 commits into from
Jul 19, 2023

Conversation

jerivas
Copy link
Contributor

@jerivas jerivas commented Jun 7, 2023

Copy link
Contributor Author

@jerivas jerivas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nex3 I'm getting a bunch of call stack errors, it sounds like I'm somehow messing up the methods and getters https://github.com/sass/dart-sass/actions/runs/5205889223/jobs/9391830839?pr=1988

lib/src/node/value/calculation.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Show resolved Hide resolved
lib/src/node/value/calculation.dart Show resolved Hide resolved
jgerigmeyer and others added 3 commits June 7, 2023 16:45
* main:
  Release 1.63.0 (sass#1987)
  Run embedded compilations across multiple isolates (sass#1981)
* main:
  Fix a few more deployment issues (sass#1998)
  Use the correct pub credential location for deploying sub-packages (sass#1997)
  Block release on all tests (sass#1996)
  Fix deploy configuration (sass#1994)
Co-authored-by: Jonny Gerig Meyer <[email protected]>
Copy link
Contributor

@nex3 nex3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nex3 I'm getting a bunch of call stack errors, it sounds like I'm somehow messing up the methods and getters https://github.com/sass/dart-sass/actions/runs/5205889223/jobs/9391830839?pr=1988

It's very frustrating that this doesn't actually include the stack trace! My suggestion would be to create a little test.js file that loads the compiled JS from build/npm and directly invokes the functions that are overflowing, and see if that gives more clarity on what the actual recursive call stack is.

lib/src/node/value/calculation.dart Show resolved Hide resolved
lib/src/node/value/calculation.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Show resolved Hide resolved
@jerivas
Copy link
Contributor Author

jerivas commented Jun 17, 2023

@nex3 I'm working on the changes to Options.functions, and from my understanding we need to simplify return values as explained here:

Return a copy of result.internal with all calculations it transitively contains (including the return value itself if it's a calculation) replaced with the result of simplifying those calculations.

It sounds like we need to modify _parseFunctions to simplify the result if it's a SassCalculation instance, something like this:

if (result is Value) {
  if (result is SassCalculation)
    return SassCalculation._simplify(result);
  return result;
}

But _simplify is a private static method. Should we make it public? Am I approaching this correctly?

@nex3
Copy link
Contributor

nex3 commented Jun 21, 2023

@jerivas Since we don't want _simplify to be used by users outside the Sass package (since they can never get ahold of an unsimplified calculation anyway), it may be simpler to just call SassCalculation.calc() instead, which will in practice simplify a calculation.

@jerivas jerivas marked this pull request as ready for review July 6, 2023 20:51
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Show resolved Hide resolved
lib/src/node/value/calculation.dart Show resolved Hide resolved
@jerivas jerivas requested a review from nex3 July 13, 2023 01:47
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Show resolved Hide resolved
lib/src/node/value/calculation.dart Outdated Show resolved Hide resolved
@jerivas jerivas requested a review from nex3 July 17, 2023 18:24
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/compile.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Outdated Show resolved Hide resolved
lib/src/node/value/calculation.dart Outdated Show resolved Hide resolved
lib/src/value/calculation.dart Outdated Show resolved Hide resolved
@jerivas jerivas requested a review from nex3 July 18, 2023 17:41
@nex3 nex3 merged commit ca2be2a into sass:main Jul 19, 2023
45 checks passed
@jerivas jerivas deleted the js-api-calculations branch July 20, 2023 16:47
@nex3 nex3 mentioned this pull request Dec 5, 2023
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants