Skip to content

feat: add zone configuration to typescript interface#35329

Closed
JiaLiPassion wants to merge 1 commit intoangular:masterfrom
JiaLiPassion:zone-module-api
Closed

feat: add zone configuration to typescript interface#35329
JiaLiPassion wants to merge 1 commit intoangular:masterfrom
JiaLiPassion:zone-module-api

Conversation

@JiaLiPassion
Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

Add all zone.js configuration to interface, so we can define those flags in polyfills.ts like this.

const config = window as ZoneGlobalConfiguration;
config.__Zone_disable_requestAnimationFrame = true;

@pullapprove pullapprove Bot requested a review from mhevery February 11, 2020 10:16
@JiaLiPassion JiaLiPassion added area: zones Issues related to zone.js target: patch This PR is targeted for the next patch release and removed cla: yes labels Feb 11, 2020
@ngbot ngbot Bot added this to the needsTriage milestone Feb 11, 2020
@googlebot
Copy link
Copy Markdown

☹️ Sorry, but only Googlers may change the label cla: yes.

Comment thread packages/zone.js/lib/zone.configuration.api.ts Outdated
Comment thread packages/zone.js/lib/zone.configuration.api.ts Outdated
Comment thread packages/zone.js/lib/zone.configuration.api.ts Outdated
@mhevery mhevery added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Feb 11, 2020
@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

@mhevery, thanks for the review, I have updated the doc.
@kapunahelewong , could you also help me to check the comments in the src file? Basically I will use the same text to write a doc later to explain all the configurations in aio. Thanks.

Copy link
Copy Markdown
Contributor

@kapunahelewong kapunahelewong left a comment

Choose a reason for hiding this comment

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

Just small adjustments. Stoppping here to see if all the comments will go through.

Note: For context, last time I had too many comments and had to duplicate my work in the file itself because github wouldn't post my review.

Comment thread packages/zone.js/lib/zone.configuration.api.ts Outdated
Comment thread packages/zone.js/lib/zone.configuration.api.ts Outdated
Comment thread packages/zone.js/lib/zone.configuration.api.ts Outdated
Comment thread packages/zone.js/lib/zone.configuration.api.ts Outdated
Comment thread packages/zone.js/lib/zone.configuration.api.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Zone.js will not monkey patch Object.defineProperty API and will not
* Zone.js does not monkey patch the `Object.defineProperty` API and does not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* try to modify desc.configurable to true.
* try to modify desc.configurable to `true`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Disable registerElement monkey patch.
* Disable the `registerElement` monkey patch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Only available in legacy bundle (dist/zone.js), this defineProperty module will not be
* Only available in the legacy bundle (`dist/zone.js`), `this defineProperty` module is not

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* available in evergreen bundle (zone-evergreen.js).
* available in the evergreen bundle (`zone-evergreen.js`).

Copy link
Copy Markdown
Contributor

@kapunahelewong kapunahelewong left a comment

Choose a reason for hiding this comment

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

Just small adjustments. Stoppping here to see if all the comments will go through.

Note: For context, last time I had too many comments and had to duplicate my work in the file itself because github wouldn't post my review.

@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

@kapunahelewong , thank you for the detailed review, I have updated the PR, please review.

@JiaLiPassion JiaLiPassion removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Feb 20, 2020
@JiaLiPassion JiaLiPassion force-pushed the zone-module-api branch 2 times, most recently from bac83f6 to 807f3c9 Compare February 24, 2020 04:23
Copy link
Copy Markdown
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

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

With nits.

Comment thread packages/zone.js/lib/zone.configurations.api.ts Outdated
Comment thread packages/zone.js/lib/zone.configurations.api.ts Outdated
Comment thread packages/zone.js/lib/zone.configurations.api.ts Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this called timers not setTimeout? What other times are we disabling?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in this module, we disable setTimeout/setInterval/setImmediate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

really why is registerElement not available in evergreen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because registerElement is deprecated, and we now only including customElement.define monkey patch for web component.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here, why is it not available in evergreen Could you add explanation to the reasoning behind it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, I will add more doc here, the reason we don't monkey patch legacy EventTarget like APIs here because in modern browsers, the EventTarget is available, so we only need to monkey patch EventTarget, we don't need to monkey patch such as HTMLDivElement class one by one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there other timeres besides setTimeout? if not why not __Zone_disable_setTimeout?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in nodejs, we also patch setTimeout/setInterval/setImmediate.

Comment thread packages/zone.js/lib/zone.configurations.api.ts Outdated
@JiaLiPassion JiaLiPassion force-pushed the zone-module-api branch 2 times, most recently from 33b6100 to 17263e1 Compare February 25, 2020 14:36
@mhevery mhevery added the action: merge The PR is ready for merge by the caretaker label Feb 26, 2020
@ngbot
Copy link
Copy Markdown

ngbot Bot commented Feb 26, 2020

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "ci/circleci: legacy-unit-tests-saucelabs" is failing
    pending status "google3" is pending
    pending missing required status "ci/circleci: publish_snapshot"

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

JiaLiPassion commented Feb 26, 2020

@mhevery, I have rebased the PR, the CI is red because the early other PRs changed the payload size in aio, #35702

@mhevery
Copy link
Copy Markdown
Contributor

mhevery commented Feb 27, 2020

presubmit

@atscott atscott added target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Feb 27, 2020
@atscott atscott closed this in 03d88c7 Feb 27, 2020
@atscott
Copy link
Copy Markdown
Contributor

atscott commented Feb 27, 2020

Hi @JiaLiPassion, there was a conflict with the patch branch so I modified this PR to target master only. Can you create a follow-up PR that targets patch-only?

@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

@atscott , got it, thanks, I will create a separate PR, and will DM you for the details.

Copy link
Copy Markdown
Contributor

@aikithoughts aikithoughts left a comment

Choose a reason for hiding this comment

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

Edit pass for readability.

Comment thread packages/zone.js/lib/zone.configurations.api.ts
Comment thread packages/zone.js/lib/zone.configurations.api.ts
Comment thread packages/zone.js/lib/zone.configurations.api.ts
Comment thread packages/zone.js/lib/zone.configurations.api.ts
Comment thread packages/zone.js/lib/zone.configurations.api.ts
Comment thread packages/zone.js/lib/zone.configurations.api.ts
Comment thread packages/zone.js/lib/zone.configurations.api.ts
Comment thread packages/zone.js/lib/zone.configurations.api.ts
Comment thread packages/zone.js/lib/zone.configurations.api.ts
Comment thread packages/zone.js/lib/zone.configurations.api.ts
@kara
Copy link
Copy Markdown
Contributor

kara commented Mar 4, 2020

@JiaLiPassion Can you open a follow-up PR to address @aikidave's comments?

@JiaLiPassion
Copy link
Copy Markdown
Contributor Author

@kara, sure, will do it now. thanks.

* Users can achieve this goal by defining `__zone_symbol__UNPATCHED_EVENTS = ['scroll',
* 'mousemove'];` before imporing `zone.js`.
*/
__zone_symbol__UNPATCHED_EVENTS?: boolean;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@JiaLiPassion __zone_symbol__UNPATCHED_EVENTS and __zone_symbol__PASSIVE_EVENTS should be a string[] instead of boolean, shouldn't?

Thanks for add types to zone.js, it's awesome 🎉

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes, you are right, thanks for finding this issue, will create PR to resolve it.

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: zones Issues related to zone.js cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants