@odoo/owl 2.0.9 → 2.1.1
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.
- package/README.md +22 -1
- package/dist/owl-devtools.zip +0 -0
- package/dist/owl.cjs.js +115 -86
- package/dist/owl.es.js +115 -87
- package/dist/owl.iife.js +115 -86
- package/dist/owl.iife.min.js +1 -1
- package/dist/types/owl.d.ts +11 -8
- package/dist/types/runtime/app.d.ts +2 -2
- package/dist/types/runtime/component_node.d.ts +1 -0
- package/dist/types/runtime/index.d.ts +1 -1
- package/dist/types/runtime/lifecycle_hooks.d.ts +3 -3
- package/dist/types/runtime/utils.d.ts +6 -1
- package/dist/types/runtime/validation.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +12 -3
package/dist/owl.iife.js
CHANGED
|
@@ -281,6 +281,96 @@
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Creates a batched version of a callback so that all calls to it in the same
|
|
286
|
+
* microtick will only call the original callback once.
|
|
287
|
+
*
|
|
288
|
+
* @param callback the callback to batch
|
|
289
|
+
* @returns a batched version of the original callback
|
|
290
|
+
*/
|
|
291
|
+
function batched(callback) {
|
|
292
|
+
let called = false;
|
|
293
|
+
return async () => {
|
|
294
|
+
// This await blocks all calls to the callback here, then releases them sequentially
|
|
295
|
+
// in the next microtick. This line decides the granularity of the batch.
|
|
296
|
+
await Promise.resolve();
|
|
297
|
+
if (!called) {
|
|
298
|
+
called = true;
|
|
299
|
+
// wait for all calls in this microtick to fall through before resetting "called"
|
|
300
|
+
// so that only the first call to the batched function calls the original callback.
|
|
301
|
+
// Schedule this before calling the callback so that calls to the batched function
|
|
302
|
+
// within the callback will proceed only after resetting called to false, and have
|
|
303
|
+
// a chance to execute the callback again
|
|
304
|
+
Promise.resolve().then(() => (called = false));
|
|
305
|
+
callback();
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Determine whether the given element is contained in its ownerDocument:
|
|
311
|
+
* either directly or with a shadow root in between.
|
|
312
|
+
*/
|
|
313
|
+
function inOwnerDocument(el) {
|
|
314
|
+
if (!el) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
if (el.ownerDocument.contains(el)) {
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
const rootNode = el.getRootNode();
|
|
321
|
+
return rootNode instanceof ShadowRoot && el.ownerDocument.contains(rootNode.host);
|
|
322
|
+
}
|
|
323
|
+
function validateTarget(target) {
|
|
324
|
+
// Get the document and HTMLElement corresponding to the target to allow mounting in iframes
|
|
325
|
+
const document = target && target.ownerDocument;
|
|
326
|
+
if (document) {
|
|
327
|
+
const HTMLElement = document.defaultView.HTMLElement;
|
|
328
|
+
if (target instanceof HTMLElement || target instanceof ShadowRoot) {
|
|
329
|
+
if (!document.body.contains(target instanceof HTMLElement ? target : target.host)) {
|
|
330
|
+
throw new OwlError("Cannot mount a component on a detached dom node");
|
|
331
|
+
}
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
throw new OwlError("Cannot mount component: the target is not a valid DOM element");
|
|
336
|
+
}
|
|
337
|
+
class EventBus extends EventTarget {
|
|
338
|
+
trigger(name, payload) {
|
|
339
|
+
this.dispatchEvent(new CustomEvent(name, { detail: payload }));
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function whenReady(fn) {
|
|
343
|
+
return new Promise(function (resolve) {
|
|
344
|
+
if (document.readyState !== "loading") {
|
|
345
|
+
resolve(true);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
document.addEventListener("DOMContentLoaded", resolve, false);
|
|
349
|
+
}
|
|
350
|
+
}).then(fn || function () { });
|
|
351
|
+
}
|
|
352
|
+
async function loadFile(url) {
|
|
353
|
+
const result = await fetch(url);
|
|
354
|
+
if (!result.ok) {
|
|
355
|
+
throw new OwlError("Error while fetching xml templates");
|
|
356
|
+
}
|
|
357
|
+
return await result.text();
|
|
358
|
+
}
|
|
359
|
+
/*
|
|
360
|
+
* This class just transports the fact that a string is safe
|
|
361
|
+
* to be injected as HTML. Overriding a JS primitive is quite painful though
|
|
362
|
+
* so we need to redfine toString and valueOf.
|
|
363
|
+
*/
|
|
364
|
+
class Markup extends String {
|
|
365
|
+
}
|
|
366
|
+
/*
|
|
367
|
+
* Marks a value as safe, that is, a value that can be injected as HTML directly.
|
|
368
|
+
* It should be used to wrap the value passed to a t-out directive to allow a raw rendering.
|
|
369
|
+
*/
|
|
370
|
+
function markup(value) {
|
|
371
|
+
return new Markup(value);
|
|
372
|
+
}
|
|
373
|
+
|
|
284
374
|
function createEventHandler(rawEvent) {
|
|
285
375
|
const eventName = rawEvent.split(".")[0];
|
|
286
376
|
const capture = rawEvent.includes(".capture");
|
|
@@ -300,7 +390,7 @@
|
|
|
300
390
|
}
|
|
301
391
|
function listener(ev) {
|
|
302
392
|
const currentTarget = ev.currentTarget;
|
|
303
|
-
if (!currentTarget || !
|
|
393
|
+
if (!currentTarget || !inOwnerDocument(currentTarget))
|
|
304
394
|
return;
|
|
305
395
|
const data = currentTarget[eventKey];
|
|
306
396
|
if (!data)
|
|
@@ -2165,82 +2255,6 @@
|
|
|
2165
2255
|
});
|
|
2166
2256
|
}
|
|
2167
2257
|
|
|
2168
|
-
/**
|
|
2169
|
-
* Creates a batched version of a callback so that all calls to it in the same
|
|
2170
|
-
* microtick will only call the original callback once.
|
|
2171
|
-
*
|
|
2172
|
-
* @param callback the callback to batch
|
|
2173
|
-
* @returns a batched version of the original callback
|
|
2174
|
-
*/
|
|
2175
|
-
function batched(callback) {
|
|
2176
|
-
let called = false;
|
|
2177
|
-
return async () => {
|
|
2178
|
-
// This await blocks all calls to the callback here, then releases them sequentially
|
|
2179
|
-
// in the next microtick. This line decides the granularity of the batch.
|
|
2180
|
-
await Promise.resolve();
|
|
2181
|
-
if (!called) {
|
|
2182
|
-
called = true;
|
|
2183
|
-
// wait for all calls in this microtick to fall through before resetting "called"
|
|
2184
|
-
// so that only the first call to the batched function calls the original callback.
|
|
2185
|
-
// Schedule this before calling the callback so that calls to the batched function
|
|
2186
|
-
// within the callback will proceed only after resetting called to false, and have
|
|
2187
|
-
// a chance to execute the callback again
|
|
2188
|
-
Promise.resolve().then(() => (called = false));
|
|
2189
|
-
callback();
|
|
2190
|
-
}
|
|
2191
|
-
};
|
|
2192
|
-
}
|
|
2193
|
-
function validateTarget(target) {
|
|
2194
|
-
// Get the document and HTMLElement corresponding to the target to allow mounting in iframes
|
|
2195
|
-
const document = target && target.ownerDocument;
|
|
2196
|
-
if (document) {
|
|
2197
|
-
const HTMLElement = document.defaultView.HTMLElement;
|
|
2198
|
-
if (target instanceof HTMLElement) {
|
|
2199
|
-
if (!document.body.contains(target)) {
|
|
2200
|
-
throw new OwlError("Cannot mount a component on a detached dom node");
|
|
2201
|
-
}
|
|
2202
|
-
return;
|
|
2203
|
-
}
|
|
2204
|
-
}
|
|
2205
|
-
throw new OwlError("Cannot mount component: the target is not a valid DOM element");
|
|
2206
|
-
}
|
|
2207
|
-
class EventBus extends EventTarget {
|
|
2208
|
-
trigger(name, payload) {
|
|
2209
|
-
this.dispatchEvent(new CustomEvent(name, { detail: payload }));
|
|
2210
|
-
}
|
|
2211
|
-
}
|
|
2212
|
-
function whenReady(fn) {
|
|
2213
|
-
return new Promise(function (resolve) {
|
|
2214
|
-
if (document.readyState !== "loading") {
|
|
2215
|
-
resolve(true);
|
|
2216
|
-
}
|
|
2217
|
-
else {
|
|
2218
|
-
document.addEventListener("DOMContentLoaded", resolve, false);
|
|
2219
|
-
}
|
|
2220
|
-
}).then(fn || function () { });
|
|
2221
|
-
}
|
|
2222
|
-
async function loadFile(url) {
|
|
2223
|
-
const result = await fetch(url);
|
|
2224
|
-
if (!result.ok) {
|
|
2225
|
-
throw new OwlError("Error while fetching xml templates");
|
|
2226
|
-
}
|
|
2227
|
-
return await result.text();
|
|
2228
|
-
}
|
|
2229
|
-
/*
|
|
2230
|
-
* This class just transports the fact that a string is safe
|
|
2231
|
-
* to be injected as HTML. Overriding a JS primitive is quite painful though
|
|
2232
|
-
* so we need to redfine toString and valueOf.
|
|
2233
|
-
*/
|
|
2234
|
-
class Markup extends String {
|
|
2235
|
-
}
|
|
2236
|
-
/*
|
|
2237
|
-
* Marks a value as safe, that is, a value that can be injected as HTML directly.
|
|
2238
|
-
* It should be used to wrap the value passed to a t-out directive to allow a raw rendering.
|
|
2239
|
-
*/
|
|
2240
|
-
function markup(value) {
|
|
2241
|
-
return new Markup(value);
|
|
2242
|
-
}
|
|
2243
|
-
|
|
2244
2258
|
let currentNode = null;
|
|
2245
2259
|
function getCurrent() {
|
|
2246
2260
|
if (!currentNode) {
|
|
@@ -2292,6 +2306,7 @@
|
|
|
2292
2306
|
this.bdom = null;
|
|
2293
2307
|
this.status = 0 /* NEW */;
|
|
2294
2308
|
this.forceNextRender = false;
|
|
2309
|
+
this.nextProps = null;
|
|
2295
2310
|
this.children = Object.create(null);
|
|
2296
2311
|
this.refs = {};
|
|
2297
2312
|
this.willStart = [];
|
|
@@ -2421,7 +2436,7 @@
|
|
|
2421
2436
|
this.status = 2 /* DESTROYED */;
|
|
2422
2437
|
}
|
|
2423
2438
|
async updateAndRender(props, parentFiber) {
|
|
2424
|
-
|
|
2439
|
+
this.nextProps = props;
|
|
2425
2440
|
props = Object.assign({}, props);
|
|
2426
2441
|
// update
|
|
2427
2442
|
const fiber = makeChildFiber(this, parentFiber);
|
|
@@ -2445,7 +2460,6 @@
|
|
|
2445
2460
|
return;
|
|
2446
2461
|
}
|
|
2447
2462
|
component.props = props;
|
|
2448
|
-
this.props = rawProps;
|
|
2449
2463
|
fiber.render();
|
|
2450
2464
|
const parentRoot = parentFiber.root;
|
|
2451
2465
|
if (this.willPatch.length) {
|
|
@@ -2520,6 +2534,7 @@
|
|
|
2520
2534
|
// by the component will be patched independently in the appropriate
|
|
2521
2535
|
// fiber.complete
|
|
2522
2536
|
this._patch();
|
|
2537
|
+
this.props = this.nextProps;
|
|
2523
2538
|
}
|
|
2524
2539
|
}
|
|
2525
2540
|
_patch() {
|
|
@@ -2870,14 +2885,27 @@
|
|
|
2870
2885
|
if ("element" in descr) {
|
|
2871
2886
|
result = validateArrayType(key, value, descr.element);
|
|
2872
2887
|
}
|
|
2873
|
-
else if ("shape" in descr
|
|
2888
|
+
else if ("shape" in descr) {
|
|
2874
2889
|
if (typeof value !== "object" || Array.isArray(value)) {
|
|
2875
2890
|
result = `'${key}' is not an object`;
|
|
2876
2891
|
}
|
|
2877
2892
|
else {
|
|
2878
2893
|
const errors = validateSchema(value, descr.shape);
|
|
2879
2894
|
if (errors.length) {
|
|
2880
|
-
result = `'${key}'
|
|
2895
|
+
result = `'${key}' doesn't have the correct shape (${errors.join(", ")})`;
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
else if ("values" in descr) {
|
|
2900
|
+
if (typeof value !== "object" || Array.isArray(value)) {
|
|
2901
|
+
result = `'${key}' is not an object`;
|
|
2902
|
+
}
|
|
2903
|
+
else {
|
|
2904
|
+
const errors = Object.entries(value)
|
|
2905
|
+
.map(([key, value]) => validateType(key, value, descr.values))
|
|
2906
|
+
.filter(Boolean);
|
|
2907
|
+
if (errors.length) {
|
|
2908
|
+
result = `some of the values in '${key}' are invalid (${errors.join(", ")})`;
|
|
2881
2909
|
}
|
|
2882
2910
|
}
|
|
2883
2911
|
}
|
|
@@ -5480,8 +5508,8 @@
|
|
|
5480
5508
|
return new Function("app, bdom, helpers", code);
|
|
5481
5509
|
}
|
|
5482
5510
|
|
|
5483
|
-
// do not modify manually. This
|
|
5484
|
-
const version = "2.
|
|
5511
|
+
// do not modify manually. This file is generated by the release script.
|
|
5512
|
+
const version = "2.1.1";
|
|
5485
5513
|
|
|
5486
5514
|
// -----------------------------------------------------------------------------
|
|
5487
5515
|
// Scheduler
|
|
@@ -5774,7 +5802,7 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
|
|
|
5774
5802
|
return {
|
|
5775
5803
|
get el() {
|
|
5776
5804
|
const el = refs[name];
|
|
5777
|
-
return (el
|
|
5805
|
+
return inOwnerDocument(el) ? el : null;
|
|
5778
5806
|
},
|
|
5779
5807
|
};
|
|
5780
5808
|
}
|
|
@@ -5924,14 +5952,15 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
|
|
|
5924
5952
|
exports.useState = useState;
|
|
5925
5953
|
exports.useSubEnv = useSubEnv;
|
|
5926
5954
|
exports.validate = validate;
|
|
5955
|
+
exports.validateType = validateType;
|
|
5927
5956
|
exports.whenReady = whenReady;
|
|
5928
5957
|
exports.xml = xml;
|
|
5929
5958
|
|
|
5930
5959
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5931
5960
|
|
|
5932
5961
|
|
|
5933
|
-
__info__.date = '2023-
|
|
5934
|
-
__info__.hash = '
|
|
5962
|
+
__info__.date = '2023-04-17T09:09:34.568Z';
|
|
5963
|
+
__info__.hash = '4b9e6ba';
|
|
5935
5964
|
__info__.url = 'https://github.com/odoo/owl';
|
|
5936
5965
|
|
|
5937
5966
|
|