Commit graph

264 commits

Author SHA1 Message Date
JiaLiPassion
aebf165359 fix(zone.js): should ignore multiple resolve call (#45283)
Close #44913

The following case is not handled correctly by `zone.js`.
```
const delayedPromise = new Promise((resolve) => {
  setTimeout(resolve, 1, 'timeout');
});

new Promise((resolve) => {
  resolve(delayedPromise);
  resolve('second call');
}).then(console.log);
```

It should output `timeout`, since the promise is resolved by the
1st resolve, the `second call` should be ignored.

So this is a bug that the original implementation not ensure the
`resolve` is only called once.

PR Close #45283
2022-03-25 17:31:03 -07:00
arturovt
4ea70e36b9 fix(zone.js): swallow the error when the element callback is not patchable (#45400)
The `patchCallbacks` is used for patching the `document.registerElement` and
`customElements.define`. We explicitly wrap the patching code into try-catch since
callbacks may be already patched by other web components frameworks (e.g. LWC), and they
make those properties non-writable. This means that patching callback will throw an error
`cannot assign to read-only property`. See this code as an example:
https://github.com/salesforce/lwc/blob/master/packages/@lwc/engine-core/src/framework/base-bridge-element.ts#L180-L186
We don't want to stop the application rendering if we couldn't patch some
callback, e.g. `attributeChangedCallback`.

PR Close #42546

PR Close #45400
2022-03-25 16:31:09 -07:00
Renovate Bot
010a39f856 build: update bazel (#45431)
Update `@bazel` packages to the latest 5.x version.

Some of the changes here are modeled after
angular/dev-infra@40c0ac8559.

Co-Authored-By: George Kalpakas <[email protected]>

PR Close #45431
2022-03-25 12:18:33 -07:00
arturovt
e2eaac34b0 fix(zone.js): read Symbol.species safely (#45369)
We must read `Symbol.species` safely because `this` may be anything. For instance, `this`
may be an object without a prototype (created through `Object.create(null)`); thus
`this.constructor` will be undefined. One of the use cases is SystemJS creating
prototype-less objects (modules) via `Object.create(null)`. The SystemJS creates an empty
object and copies promise properties into that object (within the `getOrCreateLoad`
function). The zone.js then checks if the resolved value has the `then` method and invokes
it with the `value` context. Otherwise, this will throw an error: `TypeError: Cannot read
properties of undefined (reading 'Symbol(Symbol.species)')`.

PR Close #45369
2022-03-24 18:56:36 -07:00
Tobias Speicher
4ddcf81e61 refactor: replace deprecated String.prototype.substr() (#45397)
.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated

Signed-off-by: Tobias Speicher <[email protected]>

PR Close #45397
2022-03-24 11:48:09 -07:00
Renovate Bot
8198bb92c9 build: lock file maintenance (#45402)
PR Close #45402
2022-03-24 10:57:25 -07:00
Krzysztof Platis
f19b36f462 fix(zone.js): in TaskTrackingZoneSpec track a periodic task until it is cancelled (#45391)
Before this change, the macrotask for `setInterval(callback, ms)` was no
longer tracked by `TaskTrackingZoneSpec` after the `callback` was
invoked for the first time. Now the periodic macrotask is tracked until
it is cancelled, e.g. `clearInterval(id)`.

BREAKING CHANGE: in TaskTrackingZoneSpec track a periodic task until it is cancelled

The breaking change is scoped only to the plugin
`zone.js/plugins/task-tracking`. If you used `TaskTrackingZoneSpec` and
checked the pending macroTasks e.g. using `(this.ngZone as any)._inner
._parent._properties.TaskTrackingZone.getTasksFor('macroTask')`, then
its behavior slightly changed for periodic macrotasks. For example,
previously the `setInterval` macrotask was no longer tracked after its
callback was executed for the first time. Now it's tracked until
the task is explicitly cancelled, e.g  with `clearInterval(id)`.

fixes 45350

PR Close #45391
2022-03-24 10:53:36 -07:00
arturovt
c7bcc1b501 fix(zone.js): check if process is defined when patching the GlobalErrors.install (#45392)
Jasmine checks internally if `process` and `process.on` is defined. Otherwise,
it installs the browser rejection handler through the `global.addEventListener`.
This code may be run in the browser environment where `process` is not defined, and
this will lead to a runtime exception since Webpack 5 removed automatic Node.js polyfills.

PR Close #42260

PR Close #45392
2022-03-24 10:52:34 -07:00
Renovate Bot
9d5ad672b4 build: lock file maintenance (#45341)
PR Close #45341
2022-03-16 14:36:28 -07:00
Renovate Bot
6d240c49b7 build: lock file maintenance (#45289)
Refreshes the lock file through Renovate.

PR Close #45289
2022-03-08 13:15:13 -08:00
Renovate Bot
1a5cd06d92 build: update dependency google-closure-compiler to v20220301 (#45260)
PR Close #45260
2022-03-07 14:30:45 -08:00
Kristiyan Kostadinov
94bba76a4a feat(core): support TypeScript 4.6 (#45190)
Adds support for TypeScript 4.6.

PR Close #45190
2022-03-07 11:31:39 -08:00
JiaLiPassion
9b1e9c0bd7 release: cut the zone.js-0.11.5 release (#45256)
PR Close #45256
2022-03-03 15:49:46 -08:00
JiaLiPassion
b437d1238d fix(zone.js): defineProperties should also set symbol props (#45098)
Close #44095

Fix `defineProperties` patch not set `symbol` props issue.

Co-authored-by: varomodt<[email protected]>
Co-authored-by: AndrewKushnir<[email protected]>

PR Close #45098
2022-03-03 12:22:05 -08:00
JiaLiPassion
1b85811c00 refactor(zone.js): for legacy browser, still use hard coding eventNames (#40962)
For legacy browsers, we still use the eventNames array to patch event instead of
using `Object.getOwnPropertyNames()` to keep backward compatibility.

PR Close #40962
2022-03-01 18:41:15 +00:00
JiaLiPassion
0f298a13db refactor(zone.js): remove onProp eventNames array to reduce the bundle size (#40962)
Zone.js supports the google closure compiler in the advance optimization mode,
to prevent closure compiler modify the `onProperty` name such as `Element.prototype.onclick`,
Zone.js implements the `onProperty` patch logic by declaring all the
event names in the source code, this increases the bundle size and also require
updating the event names array to keep the information updated.

Now google closure compiler has the required event names defined in the built-in
externs files, so zone.js can use more simple implementation and decrease the bundle size
of zone.js (about 4k).

PR Close #40962
2022-03-01 18:41:15 +00:00
JiaLiPassion
4d494d24cc feat(zone.js): add Promise.any() implementation (#45064)
Implements `Promise.any()` introduced in ES2021.

Close #44393

PR Close #45064
2022-02-28 17:39:28 +00:00
Renovate Bot
aae07c338f build: lock file maintenance (#45071)
PR Close #45071
2022-02-24 23:56:13 +00:00
JiaLiPassion
d65706a3b2 feat(zone.js): update electron patch to support electron/remote 14 (#45073)
Close #43346

From electron 14, the `CallbacksRegistry` is moved to `@electron/remote` package,
so all `remote` call between `main` process and `renderer` process is
not being patched since the new version of electron released.
Also `CallbacksRegistry` is not exported outside, so this commit make a
`hack` patch to load `CallbacksRegistry` from
`@electron/remote/dist/src/renderer/callbacks-registry` for patching.

PR Close #45073
2022-02-23 08:57:12 -08:00
JiaLiPassion
8efbdb57c1 fix(zone.js): patch global instead of Mocha object (#45047)
Close #42834

In the new version fo Mocha, all global test functions are from `global`
object instead of `Mocha` object. Adn the current `zone.js` Mocha
patch's logic looks like this.

```
global.describe = Mocha.describe = function() {
  return originalMochaDescribe.apply(this, arguments);
}
```

and `originalMochaDescribe` is the unpathced Mocha implementation
looks like this

```
function describe() {
  return context.describe(...);
}
```

And the `context` will finally delegate to `global.describe()`,
so the current `zone.js` patch causes infinite loop.

This commit will not patch function of `Mocha` object any longer.

PR Close #45047
2022-02-16 13:51:51 -08:00
JiaLiPassion
d5565ccdb4 fix(zone.js): fix several test cases which trigger done() multiple times (#45025)
Several test cases trigger the `done()` multiple times and cause warning
from jasmine. This commit fixes these test cases.

PR Close #45025
2022-02-09 10:18:56 -08:00
JiaLiPassion
dea7234a76 fix(zone.js): async-test should only call done once (#45025)
`AsyncTestZoneSpec` triggers jasmine `done()` function multiple times
and causes warning

```
An asynchronous function called its 'done' callback more than once. This is a bug in the spec, beforeAll, beforeEach, afterAll, or afterEach function in question. This will be treated as an error in a future version. See<https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0#deprecations-due-to-calling-done-multiple-times> for more information
```

The reproduce case will be running some `Zone.run()` inside
`waitForAsync()`.

```
it('multiple done', waitForAsync(() => {
  Zone.current.run(() => {});
  Zone.current.run(() => {});
}));
```

The reason the `done()` is called in the `onInvoke()` hook is to handle
the case that the testBody is totally sync, but we should only do this
check for the entry function not for all `Zone.run()` scenario.

Another issue is if we run nested zone inside `waitForAsync()`, the
`onHasTask()` hook will be triggered multiple times, and cause `done()`
be triggered multiple times, so we need to only trigger the `done()`
when the zone is `AsyncTestZone`.

PR Close #45025
2022-02-09 10:18:56 -08:00
Renovate Bot
c88e87d833 build: lock file maintenance (#44993)
PR Close #44993
2022-02-08 11:18:28 -08:00
Renovate Bot
a599fa8d7f build: update dependency google-closure-compiler to v20220202 (#45013)
PR Close #45013
2022-02-08 11:16:07 -08:00
Andrew Scott
fdfcef5a0a build: enable useUnknownInCatchVariables (#44679)
This unblocks the internal migration to turn the option on in g3.

PR Close #44679
2022-02-01 18:17:29 +00:00
Paul Gschwendtner
10092f24fc build: fix formatting in zone.js BUILD file (#44912)
Fixes formatting in one of the Zone BUILD files.
The lint check on the renovate branch did not check
formatting as it seems. Needs more investigation as
the PR was green.

PR Close #44912
2022-01-31 17:35:45 +00:00
Paul Gschwendtner
8817b08219 build: update postinstall patch to account for benchmark macro changes (#44830)
Updates the postinstall patch for the benchmark macro rule from dev-infra.
We moved the ZoneJS setup to the bundler. This was necessary in order to
switch away from the Go-based (windows-incompatible, m1-incompatible)
concatjs devserver to a rather basic HTTP server (also provided by dev-infra now).

PR Close #44830
2022-01-31 17:00:18 +00:00
Renovate Bot
d12d7f2c3f build: lock file maintenance (#44735)
PR Close #44735
2022-01-27 21:51:28 +00:00
JiaLiPassion
25a83eb264 fix(zone.js): update several flaky cases (#41526)
Related to #41434

Fix several flaky cases.

1. should restore `window.onerror` in test cases.
2. expect().toThrow() should pass a function.

PR Close #41526
2022-01-24 10:40:42 -08:00
Renovate Bot
13d5f64f39 build: update dependency google-closure-compiler to v20220104 (#44655)
PR Close #44655
2022-01-07 19:16:52 +00:00
Paul Gschwendtner
c46d533b22 build: switch devmode output to es2015 (#44505)
To make our test output i.e. devmode output more aligned
with what we produce in the NPM packages, or to be more
aligned with what Angular applications will usually consume,
the devmode output is switched from ES5 to ES2015.

Additionally various tsconfigs (outside of Bazel) have been
updated to match with the other parts of the build. The rules
are:

ES2015 for test configurations, ES2020 for actual code that will
end up being shipped (this includes the IDE-only tsconfigs).

PR Close #44505
2022-01-05 23:20:20 +00:00
Adam Plumer
79d1afaf5b build: bump license year (#44590)
The year has advanced by one cycle. In accordance with this
practice, we increment the value of the bounding set of our
license year by one.

PR Close #44590
2022-01-04 12:05:25 -08:00
Renovate Bot
78bdb1f977 build: update dependency google-closure-compiler to v20211201 (#44392)
PR Close #44392
2021-12-10 16:39:42 -05:00
Kristiyan Kostadinov
d56e3f43a1 feat(core): support TypeScript 4.5 (#44164)
Adds support for TypeScript 4.5. Includes the following changes:
* Bumping the package versions.
* Fixing a few calls to `createExportSpecifier` and `createImportSpecifier` that require an extra parameter.
* Adding some missing methods to the TS compiler hosts.
* Fixing an issue in the TS mocks for the ngcc tests where a regex was too agressive and was trying to match a path like `/node_modules/@typescript/lib-es5`.
* Accounting for type-only import specifiers when reporting DI errors (see #43620).

Fixes #43620.

PR Close #44164
2021-11-30 11:59:02 -05:00
Renovate Bot
89aa94b7a2 build: lock file maintenance (#44111)
PR Close #44111
2021-11-10 18:22:57 +00:00
Renovate Bot
725a1a49ec build: lock file maintenance (#44003)
PR Close #44003
2021-11-05 20:05:41 +00:00
Renovate Bot
58beafb29b build: lock file maintenance (#43937)
PR Close #43937
2021-10-26 20:12:00 +00:00
Joey Perrott
9f40d2a0ea ci: remove browserstack configuration (#43881)
Remove browserstack configuration from the repo as it is not used for our CI.

PR Close #43881
2021-10-18 15:00:22 -07:00
Alan Agius
607f14db74 build: update rollup dependencies (#43737)
With this change we update `rollup` and remove the usage of no longer maintained `rollup-plugin-commonjs` and `rollup-plugin-node-resolve` plugins.

PR Close #43737
2021-10-13 16:56:42 +00:00
Renovate Bot
16e5a314b1 build: lock file maintenance (#43793)
PR Close #43793
2021-10-12 17:48:28 +00:00
Renovate Bot
5b1b2fd2f9 build: update dependency google-closure-compiler to v20211006 (#43754)
PR Close #43754
2021-10-07 20:55:49 +00:00
Renovate Bot
3d4432874c build: update dependency google-closure-compiler to v20210907 (#43398)
PR Close #43398
2021-10-04 16:33:13 -07:00
Renovate Bot
353d699766 build: lock file maintenance (#43607)
PR Close #43607
2021-10-04 16:29:49 -07:00
Kristiyan Kostadinov
ea61ec2562 feat(core): support TypeScript 4.4 (#43281)
Adds support for TypeScript 4.4. High-level overview of the changes made in this PR:

* Bumps the various packages to `[email protected]` and `[email protected]`.
* The `useUnknownInCatchVariables` compiler option has been disabled so that we don't have to cast error objects explicitly everywhere.
* TS now passes in a third argument to the `__spreadArray` call inside child class constructors. I had to update a couple of places in the runtime and ngcc to be able to pick up the calls correctly.
* TS now generates code like `(0, foo)(arg1, arg2)` for imported function calls. I had to update a few of our tests to account for it. See https://github.com/microsoft/TypeScript/pull/44624.
* Our `ngtsc` test setup calls the private `matchFiles` function from TS. I had to update our usage, because a new parameter was added.
* There was one place where we were setting the readonly `hasTrailingComma` property. I updated the usage to pass in the value when constructing the object instead.
* Some browser types were updated which meant that I had to resolve some trivial type errors.
* The downlevel decorators tranform was running into an issue where the Closure synthetic comments were being emitted twice. I've worked around it by recreating the class declaration node instead of cloning it.

PR Close #43281
2021-09-23 14:49:19 -07:00
Renovate Bot
6ce6beb1d6 build: lock file maintenance (#43513)
PR Close #43513
2021-09-21 17:44:00 +00:00
Renovate Bot
71e432305b build: lock file maintenance (#43285)
PR Close #43285
2021-09-14 11:08:59 -07:00
Pei Wang
d12d068c37 build: Turn tsec checks into bazel tests. (#43108)
Introduce two new bazel rules: tsec_test and tsec_config, for
describing the tsec checks and the tsconfig file needed for such
checks, respectively. Currently, tsec_test only checks the srcs
of a ts_library or ng_module. It does not check direct or transitive
dependencies. Also, tsconfig files need to be manually maintained
to make sure tsec can read all necessary input (including global
symbols).

PR Close #43108
2021-09-13 14:45:57 -07:00
Pei Wang
509031c734 build: Enable tsec checks for critical packages. (#43108)
tsec is a static analyzer that discovers Trusted Types violations.
Deploy tsec to make sure there will be no TT regression in several
critical packages, including core, platform-browser, platform-server
and their dependencies. Existing violations have been reviewed and
exempted in packages/tsec-exemption.json. Future changes to the
exemption list requires security review.

PR Close #43108
2021-09-13 14:45:57 -07:00
nickreid
ac59b990fc refactor(zone.js): Rename class ZoneDelegate to _ZoneDelegate to differentiate it from the ZoneDelgate interface (#43019)
The current naming causes tsickle to emit `/** @implements {ZoneDelegate} */ class ZoneDelegate ...`, which is a cyclic definition error in Closure Compiler. Additionally, the name shadowing is also confusing to humans.

PR Close angular#43019

PR Close #43019
2021-08-25 15:12:00 -07:00
Renovate Bot
ec4dcdfbd7 build: lock file maintenance (#43015)
PR Close #43015
2021-08-17 09:22:34 -07:00