Commit graph

26736 commits

Author SHA1 Message Date
Danilo Bassi
ab5e2d9387 fix(http): prevent headers from throwing an error when initializing numerical values (#49379)
Some libraries could use numbers in headers. this fix prevents Angular from
throwing an error by casting those numerical values into strings.

Fixes #49353

PR Close #49379
2023-04-13 14:00:16 +00:00
Kristiyan Kostadinov
5ac8ca4f55 fix(core): error if document body is null (#49818)
Fixes an error that came up internally which was being thrown, because in some cases the `document.body` might be null.

PR Close #49818
2023-04-12 12:51:53 -07:00
Andrew Kushnir
577374f05e docs: release notes for the v16.0.0-rc.0 release 2023-04-12 12:18:12 -07:00
Andrew Kushnir
a900a0d94a docs: release notes for the v15.2.7 release 2023-04-12 12:08:24 -07:00
Alan Agius
71e9532d5d test: improve testing of HTTP and transfer state cache (#49810)
This commit improves the HTTP transfer state integration test by using `provideClientHydration` method and validates that no HTTP calls are performed during the client bootstrapping.

PR Close #49810
2023-04-12 09:45:34 -07:00
Andrew Scott
1dddb78786 fix(core): toObservable should allow writes to signals in the effect (#49769)
`toObservable` creates an `effect` that watches for updates to the
source signal. We should allow writes to signals in this effect, which
would be consumed by downstream observers.

PR Close #49769
2023-04-12 09:35:55 -07:00
Andrew Scott
53d019ab7d fix(core): catch errors from source signals outside of .next (#49769)
From Ben:

> When dealing with any reactive function call you don't control
> like `observer.next()` (or anything similar), you want to catch the error
> in the producer call, in this case `signal()`. You don't want to catch errors
> in the `observer.next` call itself.

PR Close #49769
2023-04-12 09:35:55 -07:00
Andrew Scott
f1d5896ff3 refactor(core): rename from[Observable/Signal] => to[Signal/Observable] (#49769)
Based on feedback in the RFC, most would prefer `toSignal` and
`toObservable`.

PR Close #49769
2023-04-12 09:35:55 -07:00
Andrew Scott
5c415e9dae refactor(core): Update signal signature with respect to initial values (#49769)
The initial value used for signals by default is now `undefined`. In
addition, there is a new option to express that the signal should emit a
value synchronously (`requireSync: true`). When this value is specified,
the function will throw _on creation_ if the subscribing to the
`Observable` does not result in a synchronous emit.

PR Close #49769
2023-04-12 09:35:55 -07:00
Andrew Scott
d966fdd438 refactor(router): Ensure data is bound to components in change detection following navigation (#49741)
`RouterOutlet` components can initialize _during_ change detection (for
example, if they exist in an embedded view). When this happens, data
from the router should be bound immediately to the routed components
rather than not being available until the next round of change
detection. This is mostly just a problem for testing because change
detection is triggered manually. It would be surprising to have to
detect changes _twice_ on the fixture in order to get data bound to the
routed component.

PR Close #49741
2023-04-12 09:33:11 -07:00
Andrew Scott
332f0b870d refactor(router): Correct types of ActivatedRoute Observables (#49741)
The `ActivatedRoute` exposes several `Observable` members that are
`BehaviorSubject` under the hood. In order to update the values of those
subjects, we cast the `Observable` type internally. Instead, the
`BehaviorSubject` should be kept and re-exposed as public API
separately.

PR Close #49741
2023-04-12 09:33:11 -07:00
Angular Robot
c190fbb15c build: update dependency rimraf to v5 (#49757)
See associated pull request for more information.

PR Close #49757
2023-04-12 09:28:25 -07:00
Angular Robot
85c1a6463f build: update github/codeql-action action to v2.2.11 (#49775)
See associated pull request for more information.

PR Close #49775
2023-04-12 09:26:02 -07:00
Paul Gschwendtner
7e8b968b7c ci: update pullapprove config to reflect currrent availability (#49786)
Updates the pullapprove config to reflect the current availability.

PR Close #49786
2023-04-12 09:25:22 -07:00
Jessica Janiuk
1f7f7598d5 docs: add information on how to run universal in conjunction with service worker (#49795)
PR Close #49795
2023-04-12 09:24:49 -07:00
Alan Agius
a1e0f86c1e docs: remove preboot reference from universal doc (#49808)
This package is no longer actively maintained and in general is not needed.

PR Close #49808
2023-04-12 09:24:04 -07:00
Alan Agius
f9b821f07d fix(http): delay accessing pendingTasks.whenAllTasksComplete (#49784)
Accessing `pendingTasks.whenAllTasksComplete` too early causes the `InitialRenderPendingTasks` to return a resolved promise too early. This commit changes the way we access `whenAllTasksComplete` to only happen when the application is stabilized.

PR Close #49784
2023-04-11 14:12:38 -07:00
Alan Agius
1026552c01 fix(core): resolve InitialRenderPendingTasks promise on complete (#49784)
Current in the `InitialRenderPendingTasks` when the `collection` size is 0 a new promise is created a the status is changed to completed. This causes the promise that is created during the class initialization phase to never be resolved which causes SSR to hang indefinitely.

PR Close #49784
2023-04-11 14:12:37 -07:00
Andrew Scott
e949548561 fix(compiler): Produce diagnositc if directive used in host binding is not exported (#49527)
The compiler currently does not check to make sure that directives in
the host bindings are exported. These directives are part of the public
API of the component so they do have to be.

PR Close #49527
2023-04-11 14:02:51 -07:00
Andrew Scott
8a75a8ad26 fix(compiler-cli): Catch FatalDiagnosticError during template type checking (#49527)
This commit updates the type checking operation to catch
`FatalDiagnosticError` and surface them as diagnostics rather than
crashing.

Fixes https://github.com/angular/vscode-ng-language-service/issues/1881

PR Close #49527
2023-04-11 14:02:51 -07:00
Alan Agius
079f4bc1ef fix(http): wait for all XHR requests to finish before stabilizing application (#49776)
Previously, since the `HttpXhrBackend` is a singleton, the macrotask was created and completed only for the initial request since it was stored as in property in the class instance. This commit replaces this logic to create a macro task for every XHR request.

Closes #49730

PR Close #49776
2023-04-11 13:44:30 -07:00
Pawel Kozlowski
ce38be03ce fix(core): allow async functions in effects (#49783)
This change makes is possible to use async functions
(ones returning a promise) as effect run functions.

To make it possible, the signature of the effect function
changed: effect cleanup function is registered now
(using a dedicated callback passed to the effect creation)
instead of being returned from the effect function.

PR Close #49783
2023-04-11 12:49:10 -07:00
Alex Rickabaugh
b8a4075187 refactor(core): fix privately imported symbol from signals package (#49789)
The signals package is a separate target, and imports from it should go
through its index.ts entrypoint.

PR Close #49789
2023-04-11 12:47:53 -07:00
Andrew Kushnir
7ee542d263 refactor(platform-server): include info about enabled features into ng-server-context (#49773)
This commit updates the logic that adds the "ng-server-context" attribute to the root elements to also include information about SSR feature enabled got an application.

PR Close #49773
2023-04-11 12:46:09 -07:00
Matthieu Riegler
1da3e5f0bd refactor(platform-browser-dynamic): Drop IE related workarounds. (#49761)
IE is not supported by Angular anymore, we can drop IE specific code !

PR Close #49761
2023-04-11 12:45:10 -07:00
Kristiyan Kostadinov
8020347f26 fix(compiler): incorrectly matching directives on attribute bindings (#49713)
Fixes that the compiler was matching directives based on `attr` bindings which doesn't correspond to the runtime behavior. This wasn't a problem until now because the matched directives would basically be a noop, but they can cause issues with required inputs.

PR Close #49713
2023-04-11 12:40:57 -07:00
Alex Rickabaugh
4e41d127db build(compiler): add a flag to conditionally build with the template pipeline (#48580)
This commit adds a Bazel flag which controls a constant in the compiler code.
When this flag (`--//packages/compiler:use_template_pipeline`) is specified, the
prototype template pipeline code is enabled.

This is not used in any production workflows and only works in the local Angular
repository. It will be used to develop the template pipeline against the
existing compliance tests.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
cb7fa593c7 refactor(compiler): emit operation for the template pipeline (#48580)
This commit adds `transformTemplate` and `emitTemplateFn()` to the template
pipeline. These operations respectively apply all template compilation phases
in the right order, and then generate a final template function AST from the
template IR.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
a15c400fe9 refactor(compiler): pipeline phase to convert semantic operations to statements (#48580)
This commit introduces `phaseReify()` which performs "reification" of IR
operations. This converts previously semantic operations (e.g. `ir.Element`)
into generated instruction calls (`element(...)`). At the end of reification,
all operations have been converted into `ir.StatementOp`s, and the IR AST should
be suitable for emitting as generated code.

Note that after reification, more transformations may still be applied. For
example, instruction chaining will be performed post-reification, since it
depends on the exact selected instructions for each operation.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
2a0982661c refactor(compiler): pipeline phase to name functions/variables in generated code (#48580)
This commit introduces a new pipeline phase `phaseNaming()`, which tags
operations that generate function and variable declarations with generated names
to use when emitting those operations.

Currently this phase is using placeholder names. Eventually, we will want to
align its output with the current `TemplateDefinitionBuilder` names, in order to
pass the existing tests.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
98d9626746 refactor(compiler): pipeline phase to generate advance() instructions (#48580)
When executing the template update pass, the runtime keeps an internal
declaration slot pointer for which declaration (element, template, etc) is
the current subject of any binding or interpolation instructions. In between
update operations which reference different declarations, this pointer needs to
be adjusted, which is the job of the `advance()` instruction.

This commit introduces `phaseGenerateAdvance()` which inserts `advance()`
operations wherever necessary to satisfy this runtime requirement.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
a2bfed4661 refactor(compiler): pipeline phase to count variable slots (#48580)
Operations and expressions in component update blocks can make use of variable
slots for storing data between executions (for example, the previous values of
expressions to use in change detection comparisons). The runtime must be told
how many variable slots to allocate for each view in a component declaration.

This commit adds a `phaseVarCounting()` phase to count the number of variables
used in different operations and expressions in a view. It makes uses of a new
marker trait `ConsumesVarsTrait` to determine which operations & expressions to
consider.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
4c0dc352fa refactor(compiler): pipeline phase to handle declaration slot allocations (#48580)
Every declaration a template is stored in a data slot in the runtime. The
indices of these slots are passed to the declaration instructions in the
creation mode. In the update mode, several instructions (like `reference()` for
local references) also use the slot indices to reference declared items.

This commit introduces `phaseSlotAllocation()` to the template pipeline, which
allocates slots for declarations which need them, and propagates those slot
indices to other instructions which need to reference declared items via their
slot indices. To perform this association, the `XrefId` of the declared items
is used to link declarations with usages.

Slot allocation is abstracted from operations by the way of a new concept in the
pipeline: traits. A trait is a "mixin" on an operation, expression, or both that
allows phases to process any operation/expression which implements the trait
without needing specific logic for each concrete implementing type. Two traits
are introduced to support slot allocation: the `ConsumesSlotOpTrait` for
declarations which require a slot to be allocated, and the
`UsesSlotIndexExprTrait` for expressions which reference a declaration by its
slot index.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
64df0efcca refactor(compiler): pipeline phase to lift element attributes into const arrays (#48580)
This commit serializes the attributes on element-like structures in the template
and converts them to constant arrays, which it lifts into the `consts` array for
the entire component compilation.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
deae02ecef refactor(compiler): pipeline phase to merge sequential elementstart/elementend (#48580)
As an optimization, the runtime provides an `element()` instruction to use in
place of `elementStart()` and `elementEnd()` when there are no instructions
between them. This commit merges `ElementStart` and `ElementEnd` IR operations
into `Element` operations in that special case.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
199569d9ec refactor(compiler): pipeline phase to extract localref constants (#48580)
Local references declared on elements need to be represented in element/template
instructions via an index into the `consts` array. This commit adds the
`phaseLocalRefs()` phase to lift local reference declarations into the `consts`
array accordingly.

PR Close #48580
2023-04-11 11:46:52 -07:00
Alex Rickabaugh
be46d2b9b7 refactor(compiler): pipeline phase to resolve view contexts (#48580)
`phaseResolveContexts()` resolves `ir.ContextExpr` expressions within views.
Each `ir.ContextExpr` represents a reference to a particular view context. For
the context of the view being compiled, this is available in the view's template
function `ctx` parameter. For parent views, this is available in context
variables which were added previously.

`phaseResolveContexts()` replaces these `ir.ContextExpr` operations with
resolved references to the requested views.

PR Close #48580
2023-04-11 11:46:51 -07:00
Alex Rickabaugh
2ced721460 refactor(compiler): pipeline phase to lexically resolve names in a view (#48580)
This commit introduces `phaseResolveNames()` to the template pipeline. This
phase processes any `ir.LexicalReadExpr`s, which represent unresolved
identifiers from the user's expressions in the template, and attempts to match
them to concepts in the lexical scope of the template (such as local refs) or
to a property read of a component or embedded view context.

PR Close #48580
2023-04-11 11:46:51 -07:00
Alex Rickabaugh
369fd7a540 refactor(compiler): pipeline phase to generate variables (#48580)
This commit implements the first "phase" of the template pipeline. Phases are
individual steps in compilation that perform a transformation of the IR in order
to move closer to generating runtime code for the template.

This first phase is `phaseGenerateVariables()`. This phase introduces variable
definition operations into the IR to define variables in each view. These
variables either represent internal operations (saving/restoring the view
context for listeners, for example) or variables created from user-defined names
such as local references or template context properties.

Every view has all possibly-referenced variables generated, regardless of
whether they're actually referenced by other operations. A future phase will
optimize the variables in each view, inlining those which are only read once and
removing those which are not referenced at all.

PR Close #48580
2023-04-11 11:46:51 -07:00
Alex Rickabaugh
99a2068a5b refactor(compiler): ingest() operation for a template into the template pipeline (#48580)
This commit implements `ingest()`, which converts a parsed template AST into
template pipeline IR. This is the first step of template compilation.

PR Close #48580
2023-04-11 11:46:51 -07:00
Alex Rickabaugh
874d156e67 refactor(compiler): template pipeline ops/exprs to represent input templates (#48580)
This commit adds the IR operations and expressions required to "ingest" a
template into the template pipeline. They form the starting point for template
compilation.

Ingestion is implemented in a following commit.

PR Close #48580
2023-04-11 11:46:51 -07:00
Alex Rickabaugh
4348d26b6a refactor(compiler): introduce custom o.Expression types for template pipeline (#48580)
This commit adds support for custom derived `o.Expression` types in the template
pipeline. A base class is added with one current implementor
(`ir.LexicalReadExpr`). `ir.Expression`s encode semantic operations within
expression ASTs of IR operations.

PR Close #48580
2023-04-11 11:46:51 -07:00
Alex Rickabaugh
7e977d99e0 refactor(compiler): introduce the core of the template pipeline (#48580)
This commit introduces the "template pipeline", a new compilation flow for
template compilation. This new flow is intended to eventually replace the
`TemplateDefinitionBuilder`. For now, it's being implemented in parallel with
the existing system with the goal of eventually passing all of the existing
compliance tests.

The new pipeline is based on an "intermediate representation" of a template -
operations which semantically encode what needs to happen at runtime to render
and change-detect the template. Using an IR allows for different concerns of
template compilation to be processed independently, which solves the biggest
problem with `TemplateDefinitionBuilder` today (the lack of separation of
concerns).

This commit introduces the IR concept of an operation and related typings, as
well as the structures used to represent templates and views during compilation.
Future commits will expand on this foundation as work on the pipeline proceeds.

PR Close #48580
2023-04-11 11:46:51 -07:00
Andrew Kushnir
cf46dfb215 ci: disable size tracking CI job in favor of integration tests size checks (#49788)
Currently we have multiple integration apps which are instrumented with the payload size checks. In addition to that, there is a separate CI job that performs similar checks. The checks in CI job are redundant, thus this commit disables a separate CI job.

PR Close #49788
2023-04-11 10:48:00 -07:00
Brandon Roberts
0b3677e149 fix(http): ensure new cache state is returned on each request (#49749)
The cache state is only used only the first server request. Restarting the server uses the cache on first request.

Subsequent requests skip the cache because the value is mutated.

This change ensures a new cache state is returned on every request.

PR Close #49749
2023-04-11 10:40:04 -07:00
Nikola Kološnjaji
8272b5b3e6 docs: Typo (#49781)
PR Close #49781
2023-04-11 10:27:51 -07:00
Paul Gschwendtner
d5e02427ea build: create script to update integration lock files (#49787)
* Adds a small script to conveniently re-generate lock files for
  integration tests.
* Updates the `.gitignore` for integration tests to ignore node
  modules. Some tests do not have a `.gitignore` (like the CLI
  boilerplate tests).

PR Close #49787
2023-04-11 10:26:43 -07:00
Paul Gschwendtner
4238ed8fb6 build: sort integration package.json dependencies (#49787)
This commits contains changes proposes by running `yarn install`
for these integration tests.

PR Close #49787
2023-04-11 10:26:43 -07:00
Paul Gschwendtner
63673ddd3f build: re-add lock files for integration tests (#49787)
The lock files for integration tests have been accidentally
removed with: 612eaca3c5

This commit re-adds them.

PR Close #49787
2023-04-11 10:26:42 -07:00
De Wildt
ee816e171f revert "fixup! fix(router): fix = not parsed in router segment name" (#47332)
This reverts commit 2279f4d4620eba083a9832ed096890b69a25ec42.

Reverting that commit based off PR feedback that this change should only affect the parsing of sergments and node encoding of the url

PR Close #47332
2023-04-11 09:16:31 -07:00