Repository navigation
Conversation
Scopes carry the application they belong to, so that plugins and components can reach it (e.g. to create new roots). The concrete App lives in owl-runtime, so core typed it as `any`. Core actually only reads two things from it: its plugin manager and its dev mode. This describes them in a `ScopeApp` interface, used by Scope, PluginManager and core's `useApp`. owl-runtime narrows it back: ComponentNode declares its `app` as an App, and runtime's `useApp` still returns an App.
A compiled template is created with `(app, bdom, helpers)` and calls the blockdom functions and helpers it receives. Which functions exist and how they are called was only an agreement between the code generator and owl-runtime: renaming a helper or changing its arguments on one side broke only when a template using it was rendered. The contract is now described by two types in owl-compiler, TemplateBlockDom and TemplateHelpers, and used on both sides: - the code generator only accepts helper and blockdom names from them; - owl-runtime's helpers and bdom objects must satisfy them. Values the generated code only passes along (contexts, nodes, blocks, the app) stay `any`: their shape belongs to the runtime. The generated code is unchanged.
Compiled templates used it for t-memo, which was removed in Owl 3: the compiler no longer emits it.
…te's app Compiled templates receive the app (the TemplateSet that compiled them) and passed it to `createComponent`, which gave it to the new ComponentNode. The parent node already knows its app, and it is the same one, since the parent got its template from it. `createComponent` now takes the app from the parent node, and the compiler no longer passes it. A compiled template now only uses its `app` argument to find the templates it calls with t-call: it no longer needs to be an App, which prepares splitting TemplateSet from App. The generated code changes accordingly (snapshots), and templates compiled before this change must be compiled again.
TemplateSet imported ComponentNode only to name the component in the "Missing template" error, by looking at the current scope. A scope is only active there when a component gets its own template, in its constructor. The component node now gets its template itself and adds its name to the error. The message is unchanged.
In dev mode, the props of a component were stored in a variable before creating it. In Owl 2, that variable was then given to `helpers.validateProps`, which was removed in Owl 3: the variable now only changed the shape of the generated code. In dev mode, the compiler now only adds the check for duplicate keys in t-foreach.
An App was a TemplateSet: the template registry and the application were one object. The App now creates a TemplateSet from its configuration and holds it in `app.templates`. Its configuration is unchanged, and the App still owns `dev`, which it gives to its template set. `app.getTemplate`, `app.addTemplate`, `app.addTemplates` and the static `App.registerTemplate` are kept, deprecated, and forward to the template set (resp. `TemplateSet.registerTemplate`). The fields of the template set (`rawTemplates`, `translateFn`, ...) are no longer on the App. Components get their template from `app.templates`, and the `callTemplate` helper receives the template set (the `app` argument of compiled templates, which no longer is an App). The devtools read the templates from `app.templates` when it is a template set, and from the app itself for older versions.
Now that an App holds a TemplateSet instead of being one, its configuration no longer extends the one of the template set: AppConfig lists the template options it accepts (with the same names and types), and the App gives exactly these to its template set. An option added to TemplateSetConfig is no longer accepted by the App without being declared there.
… components The helpers compiled templates call are now described by two types: TemplateHelpers for everything but components, and ComponentHelpers (createComponent, callSlot and toSignal) for components and their slots. Compiled templates still receive both. This prepares template sets that render templates without components.
…e helpers The helpers of compiled templates were all in one object, which every TemplateSet gave to its templates. Those about components (createComponent, callSlot, toSignal) depend on component nodes and fibers, so a TemplateSet depended on all the component code. They now are in their own file (component_helpers.ts). A TemplateSet uses the template helpers, and the component helpers given by the new `componentHelpers` option, which an App gives to its template set. A template set without component helpers can still render templates that contain components, as long as these are not rendered. Rendering a component, a slot or a signal prop throws a clear error: it already failed before (with a TypeError), since a component can only be rendered by an App. TemplateSet no longer imports any component code.
…ents The agent reference now says where an app's templates are (`app.templates`), how to add more after creation, that the template methods of the App are deprecated, and how to render a template outside any component with a standalone TemplateSet, which renders no components.
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Depends on #2081: this branch is based on it, so its first
three commits belong to that PR. Only the last eight commits are part of this
one.
This is the third step of the series that clarifies the boundaries between the
packages. An
Appwas aTemplateSet: the template registry and theapplication were one object, and the template set depended on all the
component code. After this PR, an
Appholds aTemplateSet, and aTemplateSetno longer depends on components. The next PR moves thegenerated-code tests to owl-compiler and keeps the rendering tests in
owl-runtime.
Compiled templates no longer need an App
createComponenttakes the app from the parent node instead of receiving itfrom the template. Compiled templates now only use their
appargument tofind the templates called with
t-call, so it can be a plain template set.TemplateSetno longer importsComponentNode. It used it only to name thecomponent in the "Missing template" error; the component node now adds its
name itself. The message is unchanged.
App holds a TemplateSet
app.templates.AppConfigno longer extendsTemplateSetConfig. It lists the templateoptions it accepts, with the same names and types, and passes exactly these
to its template set. Existing configurations keep working.
devstays on the App, which passes it to its template set.app.getTemplate,app.addTemplate,app.addTemplatesand the staticApp.registerTemplateare kept, deprecated, and forward toapp.templates(resp.
TemplateSet.registerTemplate).Template sets render components only when given the helpers
TemplateHelpersfromComponentHelpers(
createComponent,callSlot,toSignal).through the new
componentHelpersoption, which the App sets.as long as these are not rendered. Rendering a component, a slot or a
.signalprop throws a clearOwlError. This already failed before (with aTypeError), since a component can only be rendered by an App.Other changes
was a leftover of the props validation of Owl 2. In dev mode, the compiler
now only adds the duplicate-key check of
t-foreach.app.templates, and from the app itselffor older versions.
(
owl.llm.md) describeapp.templatesand the deprecated aliases. The agentreference also explains how to render a template with a standalone
TemplateSet.Breaking changes
createComponent(name, …)instead ofcreateComponent(app, name, …).Appis no longer aTemplateSet.app instanceof TemplateSetis false,and the template set's fields (
rawTemplates,translateFn,customDirectives, …) are no longer on the App.app.templatesis now the template set. It used to be the cache ofcompiled templates.
In Odoo (odoo, enterprise, o-spreadsheet), nothing reads the moved fields or
app.templates. o-spreadsheet's tooltip usesapp.getTemplate, which keepsworking (deprecated): it should eventually use a
TemplateSet. The templatemock of Odoo's test framework keeps working: it is called with the template set
as
this, which still hasrawTemplatesand_compileTemplate.Review notes
Many snapshot files change. These diffs only remove the
appargument ofcreateComponentand, in dev mode, the props variable.Checks
npm run build,npm run build:types,npm test(all packages),npm run test:types,npm run check-formattingandnpm run test:doc-linkspass. New tests cover the deprecated App methods and template sets without
component helpers.