@odoo/owl 3.0.0-alpha.2 → 3.0.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +100 -110
  2. package/dist/compile_templates.mjs +2434 -2532
  3. package/dist/compiler.js +2371 -0
  4. package/dist/owl-devtools.zip +0 -0
  5. package/dist/owl.cjs.js +6709 -6616
  6. package/dist/owl.cjs.runtime.js +4480 -0
  7. package/dist/owl.es.js +6697 -6600
  8. package/dist/owl.es.runtime.js +4436 -0
  9. package/dist/owl.iife.js +6710 -6617
  10. package/dist/owl.iife.min.js +1 -1
  11. package/dist/owl.iife.runtime.js +4484 -0
  12. package/dist/owl.iife.runtime.min.js +1 -0
  13. package/dist/types/common/owl_error.d.ts +3 -3
  14. package/dist/types/common/types.d.ts +1 -29
  15. package/dist/types/common/utils.d.ts +8 -8
  16. package/dist/types/compiler/code_generator.d.ts +133 -152
  17. package/dist/types/compiler/index.d.ts +13 -13
  18. package/dist/types/compiler/inline_expressions.d.ts +41 -59
  19. package/dist/types/compiler/parser.d.ts +170 -178
  20. package/dist/types/compiler/standalone/index.d.ts +2 -2
  21. package/dist/types/compiler/standalone/setup_jsdom.d.ts +1 -1
  22. package/dist/types/index.d.ts +1 -1
  23. package/dist/types/owl.d.ts +709 -665
  24. package/dist/types/runtime/app.d.ts +55 -62
  25. package/dist/types/runtime/blockdom/attributes.d.ts +8 -6
  26. package/dist/types/runtime/blockdom/block_compiler.d.ts +21 -21
  27. package/dist/types/runtime/blockdom/config.d.ts +8 -8
  28. package/dist/types/runtime/blockdom/event_catcher.d.ts +7 -7
  29. package/dist/types/runtime/blockdom/events.d.ts +8 -8
  30. package/dist/types/runtime/blockdom/html.d.ts +17 -17
  31. package/dist/types/runtime/blockdom/index.d.ts +25 -26
  32. package/dist/types/runtime/blockdom/list.d.ts +18 -18
  33. package/dist/types/runtime/blockdom/multi.d.ts +17 -17
  34. package/dist/types/runtime/blockdom/text.d.ts +26 -26
  35. package/dist/types/runtime/blockdom/toggler.d.ts +17 -17
  36. package/dist/types/runtime/component.d.ts +17 -28
  37. package/dist/types/runtime/component_node.d.ts +59 -83
  38. package/dist/types/runtime/context.d.ts +36 -0
  39. package/dist/types/runtime/error_handling.d.ts +13 -13
  40. package/dist/types/runtime/event_handling.d.ts +1 -1
  41. package/dist/types/runtime/fibers.d.ts +37 -37
  42. package/dist/types/runtime/hooks.d.ts +32 -57
  43. package/dist/types/runtime/index.d.ts +46 -35
  44. package/dist/types/runtime/lifecycle_hooks.d.ts +10 -12
  45. package/dist/types/runtime/plugin_hooks.d.ts +6 -0
  46. package/dist/types/runtime/plugin_manager.d.ts +36 -0
  47. package/dist/types/runtime/props.d.ts +21 -0
  48. package/dist/types/runtime/reactivity/computations.d.ts +34 -0
  49. package/dist/types/runtime/reactivity/computed.d.ts +6 -0
  50. package/dist/types/runtime/reactivity/effect.d.ts +1 -0
  51. package/dist/types/runtime/reactivity/proxy.d.ts +47 -0
  52. package/dist/types/runtime/reactivity/signal.d.ts +31 -0
  53. package/dist/types/runtime/reactivity.d.ts +57 -46
  54. package/dist/types/runtime/registry.d.ts +24 -15
  55. package/dist/types/runtime/rendering/error_handling.d.ts +13 -0
  56. package/dist/types/runtime/rendering/fibers.d.ts +37 -0
  57. package/dist/types/runtime/rendering/scheduler.d.ts +21 -0
  58. package/dist/types/runtime/rendering/template_helpers.d.ts +51 -0
  59. package/dist/types/runtime/resource.d.ts +18 -0
  60. package/dist/types/runtime/scheduler.d.ts +21 -21
  61. package/dist/types/runtime/status.d.ts +11 -10
  62. package/dist/types/runtime/template_set.d.ts +36 -40
  63. package/dist/types/runtime/types.d.ts +70 -0
  64. package/dist/types/runtime/utils.d.ts +24 -25
  65. package/dist/types/runtime/validation.d.ts +19 -36
  66. package/dist/types/version.d.ts +1 -1
  67. package/package.json +45 -19
  68. package/dist/types/runtime/cancellableContext.d.ts +0 -15
  69. package/dist/types/runtime/cancellablePromise.d.ts +0 -15
  70. package/dist/types/runtime/executionContext.d.ts +0 -0
  71. package/dist/types/runtime/listOperation.d.ts +0 -1
  72. package/dist/types/runtime/plugins.d.ts +0 -39
  73. package/dist/types/runtime/relationalModel/discussModel.d.ts +0 -19
  74. package/dist/types/runtime/relationalModel/discussModelTypes.d.ts +0 -22
  75. package/dist/types/runtime/relationalModel/field.d.ts +0 -20
  76. package/dist/types/runtime/relationalModel/model.d.ts +0 -59
  77. package/dist/types/runtime/relationalModel/modelData.d.ts +0 -18
  78. package/dist/types/runtime/relationalModel/modelRegistry.d.ts +0 -3
  79. package/dist/types/runtime/relationalModel/modelUtils.d.ts +0 -4
  80. package/dist/types/runtime/relationalModel/store.d.ts +0 -16
  81. package/dist/types/runtime/relationalModel/types.d.ts +0 -83
  82. package/dist/types/runtime/relationalModel/util.d.ts +0 -1
  83. package/dist/types/runtime/relationalModel/web/WebDataPoint.d.ts +0 -25
  84. package/dist/types/runtime/relationalModel/web/WebRecord.d.ts +0 -131
  85. package/dist/types/runtime/relationalModel/web/WebStaticList.d.ts +0 -63
  86. package/dist/types/runtime/relationalModel/web/webModel.d.ts +0 -5
  87. package/dist/types/runtime/relationalModel/web/webModelTypes.d.ts +0 -139
  88. package/dist/types/runtime/signals.d.ts +0 -17
  89. package/dist/types/runtime/task.d.ts +0 -12
  90. package/dist/types/utils/registry.d.ts +0 -15
package/README.md CHANGED
@@ -1,149 +1,139 @@
1
- <h1 align="center">🦉 <a href="https://odoo.github.io/owl/">Owl Framework</a> 🦉</h1>
1
+ <h1 align="center">🦉 <a href="https://odoo.github.io/owl/">Owl</a> 🦉</h1>
2
2
 
3
- [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
3
+ <p align="center">
4
+ <strong>A modern, lightweight UI framework for applications that scale</strong>
5
+ </p>
6
+
7
+ [![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
4
8
  [![npm version](https://badge.fury.io/js/@odoo%2Fowl.svg)](https://badge.fury.io/js/@odoo%2Fowl)
5
9
  [![Downloads](https://img.shields.io/npm/dm/@odoo%2Fowl.svg)](https://www.npmjs.com/package/@odoo/owl)
6
10
 
7
- _Class based components with hooks, reactive state and concurrent mode_
11
+ ---
8
12
 
9
- **Try it online!** you can experiment with the Owl framework in an online [playground](https://odoo.github.io/owl/playground).
13
+ > **Owl 3.0.0 Alpha:** This is an alpha release. The API and features are subject to change without notice.
10
14
 
11
- ## Project Overview
15
+ ---
12
16
 
13
- The Odoo Web Library (Owl) is a smallish (~<20kb gzipped) UI framework built by
14
- [Odoo](https://www.odoo.com/) for its products. Owl is a modern
15
- framework, written in Typescript, taking the best ideas from React and Vue in a
16
- simple and consistent way. Owl's main features are:
17
+ ## Try it now
17
18
 
18
- - a declarative component system,
19
- - a fine grained reactivity system similar to Vue,
20
- - hooks
21
- - fragments
22
- - asynchronous rendering
19
+ The fastest way to discover Owl is the **[online playground](https://odoo.github.io/owl/playground)**.
20
+ It features interactive examples, a live editor, and showcases all major features:
21
+ reactivity, components, plugins, and more. It also includes **guided tutorials**
22
+ and is the recommended way to learn about Owl.
23
23
 
24
- Owl components are defined with ES6 classes and xml templates, uses an
25
- underlying virtual DOM, integrates beautifully with hooks, and the rendering is
26
- asynchronous.
24
+ ## What is Owl?
27
25
 
28
- Quick links:
26
+ Owl is a modern UI framework (~20kb gzipped, zero dependencies) written in TypeScript,
27
+ built by [Odoo](https://www.odoo.com/). It powers Odoo's web client, one of the largest
28
+ open-source business applications, but is equally suited for small projects and prototypes.
29
29
 
30
- - [documentation](#documentation),
31
- - [changelog](CHANGELOG.md) (from Owl 1.x to 2.x),
32
- - [playground](https://odoo.github.io/owl/playground)
30
+ Key features:
33
31
 
34
- ## Example
32
+ - **Signal-based reactivity** — Explicit, composable, and debuggable state management
33
+ - **Plugin system** — Type-safe, composable sharing of state and services
34
+ - **Class-based components** — Familiar OOP patterns with ES6 classes
35
+ - **Declarative templates** — XML templates with a clean syntax
36
+ - **Async rendering** — Concurrent mode for smooth user experiences
35
37
 
36
- Here is a short example to illustrate interactive components:
38
+ ## Quick Example
37
39
 
38
40
  ```javascript
39
- const { Component, useState, mount, xml } = owl;
41
+ import { Component, signal, computed, mount, xml } from "@odoo/owl";
40
42
 
41
- class Counter extends Component {
43
+ class TodoList extends Component {
42
44
  static template = xml`
43
- <button t-on-click="() => state.value = state.value + props.increment">
44
- Click Me! [<t t-esc="state.value"/>]
45
- </button>`;
46
-
47
- state = useState({ value: 0 });
45
+ <input placeholder="Add todo..." t-on-keydown="this.onKeydown"/>
46
+ <ul>
47
+ <t t-foreach="this.todos()" t-as="todo" t-key="todo.id">
48
+ <li t-att-class="{ done: todo.done }">
49
+ <input type="checkbox" t-model="todo.done"/>
50
+ <t t-out="todo.text"/>
51
+ </li>
52
+ </t>
53
+ </ul>
54
+ <p t-if="this.remaining() > 0">
55
+ <t t-out="this.remaining()"/> item(s) remaining
56
+ </p>`;
57
+
58
+ todos = signal.Array([
59
+ { id: 1, text: "Learn Owl", done: false },
60
+ { id: 2, text: "Build something", done: false },
61
+ ]);
62
+
63
+ remaining = computed(() => this.todos().filter((t) => !t.done).length);
64
+
65
+ onKeydown(ev) {
66
+ if (ev.key === "Enter" && ev.target.value) {
67
+ this.todos.push({
68
+ id: Date.now(),
69
+ text: ev.target.value,
70
+ done: false,
71
+ });
72
+ ev.target.value = "";
73
+ }
74
+ }
48
75
  }
49
76
 
50
- class Root extends Component {
51
- static template = xml`
52
- <span>Hello Owl</span>
53
- <Counter increment="2"/>`;
54
-
55
- static components = { Counter };
56
- }
57
-
58
- mount(Root, document.body);
77
+ mount(TodoList, document.body);
59
78
  ```
60
79
 
61
- Note that the counter component is made reactive with the [`useState` hook](doc/reference/hooks.md#usestate).
62
- Also, all examples here uses the [`xml` helper](doc/reference/templates.md#inline-templates) to define inline templates.
63
- But this is not mandatory, many applications will load templates separately.
64
-
65
- More interesting examples can be found on the
66
- [playground](https://odoo.github.io/owl/playground) application.
80
+ This example demonstrates Owl's reactivity: `todos` is a signal, `remaining`
81
+ is a computed value that updates automatically, and the UI reacts to changes
82
+ without manual subscription management.
67
83
 
68
84
  ## Documentation
69
85
 
70
- ### Learning Owl
86
+ The documentation below is for **Owl 3**. For the Owl 2 documentation, see the
87
+ [owl-2.x branch](https://github.com/odoo/owl/tree/owl-2.x).
71
88
 
72
- Are you new to Owl? This is the place to start!
89
+ ### Getting Started
73
90
 
74
- - [Tutorial: create a TodoList application](doc/learning/tutorial_todoapp.md)
75
- - [How to start an Owl project](doc/learning/quick_start.md)
76
- - [How to test Components](doc/learning/how_to_test.md)
91
+ - **[Playground](https://odoo.github.io/owl/playground)** — Interactive examples and live coding
92
+ - [Tutorial: Getting Started](https://odoo.github.io/owl/playground#getting_started) — Learn Owl fundamentals step by step
93
+ - [Tutorial: Todo List](https://odoo.github.io/owl/playground#todo_list) — Build a full TodoMVC app
94
+ - [Tutorial: Hibou OS](https://odoo.github.io/owl/playground#hibou_os) — Build a desktop-like interface
77
95
 
78
96
  ### Reference
79
97
 
80
- - [Overview](doc/readme.md)
81
- - [App](doc/reference/app.md)
82
- - [Component](doc/reference/component.md)
83
- - [Component Lifecycle](doc/reference/component.md#lifecycle)
84
- - [Concurrency Model](doc/reference/concurrency_model.md)
85
- - [Dev mode](doc/reference/app.md#dev-mode)
86
- - [Dynamic sub components](doc/reference/component.md#dynamic-sub-components)
87
- - [Environment](doc/reference/environment.md)
88
- - [Error Handling](doc/reference/error_handling.md)
89
- - [Event Handling](doc/reference/event_handling.md)
90
- - [Form Input Bindings](doc/reference/input_bindings.md)
91
- - [Fragments](doc/reference/templates.md#fragments)
92
- - [Hooks](doc/reference/hooks.md)
93
- - [Loading Templates](doc/reference/app.md#loading-templates)
94
- - [Mounting a component](doc/reference/app.md#mount-helper)
95
- - [Portal](doc/reference/portal.md)
96
- - [Precompiling templates](doc/reference/precompiling_templates.md)
97
- - [Props](doc/reference/props.md)
98
- - [Props Validation](doc/reference/props.md#props-validation)
99
- - [Reactivity](doc/reference/reactivity.md)
100
- - [Rendering SVG](doc/reference/templates.md#rendering-svg)
101
- - [Refs](doc/reference/refs.md)
102
- - [Slots](doc/reference/slots.md)
103
- - [Sub components](doc/reference/component.md#sub-components)
104
- - [Sub templates](doc/reference/templates.md#sub-templates)
105
- - [Templates (Qweb)](doc/reference/templates.md)
106
- - [Translations](doc/reference/translations.md)
107
- - [Utils](doc/reference/utils.md)
108
-
109
- ### Other Topics
110
-
111
- - [Notes On Owl Architecture](doc/miscellaneous/architecture.md)
98
+ - [API Reference](doc/readme.md) — A complete list of everything exported by the Owl library
99
+ - [App](doc/reference/app.md) — Configure and mount an Owl application to the DOM
100
+ - [Component](doc/reference/component.md) — Define components with lifecycle methods and static properties
101
+ - [Error Handling](doc/reference/error_handling.md) — Catch and recover from errors in components
102
+ - [Event Handling](doc/reference/event_handling.md) — Handle DOM events with t-on directives
103
+ - [Form Bindings](doc/reference/form_bindings.md) — Bind form inputs to reactive state with t-model
104
+ - [Hooks](doc/reference/hooks.md) — Use lifecycle hooks and other built-in hooks in components
105
+ - [Plugins](doc/reference/plugins.md) — Share state and services across components with type-safe plugins
106
+ - [Props](doc/reference/props.md) — Pass data to child components with validation and defaults
107
+ - [Reactivity](doc/reference/reactivity.md) — Manage state with signals, computed values, and reactive objects
108
+ - [Refs](doc/reference/refs.md) — Access DOM elements from components with t-ref
109
+ - [Resources and Registries](doc/reference/resources_and_registries.md) — Ordered reactive collections for shared data
110
+ - [Slots](doc/reference/slots.md) — Compose components with named and dynamic slot content
111
+ - [Template Syntax](doc/reference/template_syntax.md) — Write XML templates with QWeb directives
112
+ - [Translations](doc/reference/translations.md) — Translate templates and dynamic strings
113
+ - [Types Validation](doc/reference/types_validation.md) — Validate data structures at runtime with a declarative schema
114
+
115
+ ### Misc
116
+
117
+ - [Owl 3.x Release Notes](release_notes.md) — Complete guide to all changes in Owl 3
118
+ - [Design Principles](doc/miscellaneous/design_principles.md)
119
+ - [Why we built Owl](doc/miscellaneous/why_owl.md)
120
+ - [Architecture Notes](doc/miscellaneous/architecture.md)
112
121
  - [Comparison with React/Vue](doc/miscellaneous/comparison.md)
113
- - [Why did Odoo build Owl?](doc/miscellaneous/why_owl.md)
114
- - [Changelog (from owl 1.x to 2.x)](CHANGELOG.md)
115
- - [Notes on compiled templates](doc/miscellaneous/compiled_template.md)
116
- - [Owl devtools extension](doc/tools/devtools.md)
117
122
 
118
- ## Installing Owl
123
+ ## Installation
119
124
 
120
- Owl is available on `npm` and can be installed with the following command:
121
-
122
- ```
125
+ ```bash
123
126
  npm install @odoo/owl
124
127
  ```
125
- If you want to use a simple `<script>` tag, the last release can be downloaded here:
126
-
127
- - [owl](https://github.com/odoo/owl/releases/latest)
128
-
129
- ## Installing Owl devtools
130
-
131
- The Owl devtools browser extension is also available in the [release](https://github.com/odoo/owl/releases/latest):
132
- Unzip the owl-devtools.zip file and follow the instructions depending on your browser:
133
-
134
- ### Chrome
135
128
 
136
- Go to your chrome extensions admin panel, activate developer mode and click on `Load unpacked`.
137
- Select the devtools-chrome folder and that's it, your extension is active!
138
- There is a convenient refresh button on the extension card (still on the same admin page) to update your code.
139
- Do note that if you got some problems, you may need to completly remove and reload the extension to completly refresh the extension.
129
+ Or download directly: [latest release](https://github.com/odoo/owl/releases/latest)
140
130
 
141
- ### Firefox
142
- Go to the address about:debugging#/runtime/this-firefox and click on `Load temporary Add-on...`.
143
- Select any file in the devtools-firefox folder and that's it, your extension is active!
144
- Here, you can use the reload button to refresh the extension.
131
+ ## Devtools
145
132
 
146
- Note that you may have to open another window or reload your tab to see the extension working.
147
- Also note that the extension will only be active on pages that have a sufficient version of owl.
133
+ The Owl devtools extension helps debug your applications with component tree
134
+ inspection, state visualization, and performance profiling. Download it from
135
+ the [releases page](https://github.com/odoo/owl/releases/latest).
148
136
 
137
+ ## License
149
138
 
139
+ Owl is released under the [LGPL v3](https://www.gnu.org/licenses/lgpl-3.0) license.