Skip to content

Commit

Permalink
[IMP] web: update owl from 2.0.9 to 2.1.1
Browse files Browse the repository at this point in the history
This update contains the following commits:

[FIX] components: solve missing update (concurrency issue)
[DOC] remove old references to comp for useRef hook
[FIX] devtools: Fix build commands for windows users
[FIX] devtools: Fix devtools in detached window
[IMP] devtools: Add a button to navigate to the doc
[IMP] devtools: Add devtools documentation
[IMP] Allow app to be mounted in shadow DOM
[IMP] playground: allow sharing playground links
[IMP] runtime: allow validating object values using a type description
[FIX] devtools: Increase vertical padding of the search bar
[FIX] devtools: Hide the collapse all button
[FIX] devtools: Fix bad computation of highlight boxes on the page
[FIX] package: Auto-update package-lock.json

closes odoo#118798

Notes: https://github.com/odoo/owl/releases/tag/v2.1.1
X-original-commit: a57cd7b
Signed-off-by: Aaron Bohy (aab) <[email protected]>
Signed-off-by: Géry Debongnie <[email protected]>
  • Loading branch information
ged-odoo committed Apr 17, 2023
1 parent f11ab40 commit 9a1dd53
Showing 1 changed file with 115 additions and 86 deletions.
201 changes: 115 additions & 86 deletions addons/web/static/lib/owl/owl.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,96 @@
}
}

/**
* Creates a batched version of a callback so that all calls to it in the same
* microtick will only call the original callback once.
*
* @param callback the callback to batch
* @returns a batched version of the original callback
*/
function batched(callback) {
let called = false;
return async () => {
// This await blocks all calls to the callback here, then releases them sequentially
// in the next microtick. This line decides the granularity of the batch.
await Promise.resolve();
if (!called) {
called = true;
// wait for all calls in this microtick to fall through before resetting "called"
// so that only the first call to the batched function calls the original callback.
// Schedule this before calling the callback so that calls to the batched function
// within the callback will proceed only after resetting called to false, and have
// a chance to execute the callback again
Promise.resolve().then(() => (called = false));
callback();
}
};
}
/**
* Determine whether the given element is contained in its ownerDocument:
* either directly or with a shadow root in between.
*/
function inOwnerDocument(el) {
if (!el) {
return false;
}
if (el.ownerDocument.contains(el)) {
return true;
}
const rootNode = el.getRootNode();
return rootNode instanceof ShadowRoot && el.ownerDocument.contains(rootNode.host);
}
function validateTarget(target) {
// Get the document and HTMLElement corresponding to the target to allow mounting in iframes
const document = target && target.ownerDocument;
if (document) {
const HTMLElement = document.defaultView.HTMLElement;
if (target instanceof HTMLElement || target instanceof ShadowRoot) {
if (!document.body.contains(target instanceof HTMLElement ? target : target.host)) {
throw new OwlError("Cannot mount a component on a detached dom node");
}
return;
}
}
throw new OwlError("Cannot mount component: the target is not a valid DOM element");
}
class EventBus extends EventTarget {
trigger(name, payload) {
this.dispatchEvent(new CustomEvent(name, { detail: payload }));
}
}
function whenReady(fn) {
return new Promise(function (resolve) {
if (document.readyState !== "loading") {
resolve(true);
}
else {
document.addEventListener("DOMContentLoaded", resolve, false);
}
}).then(fn || function () { });
}
async function loadFile(url) {
const result = await fetch(url);
if (!result.ok) {
throw new OwlError("Error while fetching xml templates");
}
return await result.text();
}
/*
* This class just transports the fact that a string is safe
* to be injected as HTML. Overriding a JS primitive is quite painful though
* so we need to redfine toString and valueOf.
*/
class Markup extends String {
}
/*
* Marks a value as safe, that is, a value that can be injected as HTML directly.
* It should be used to wrap the value passed to a t-out directive to allow a raw rendering.
*/
function markup(value) {
return new Markup(value);
}

function createEventHandler(rawEvent) {
const eventName = rawEvent.split(".")[0];
const capture = rawEvent.includes(".capture");
Expand All @@ -300,7 +390,7 @@
}
function listener(ev) {
const currentTarget = ev.currentTarget;
if (!currentTarget || !currentTarget.ownerDocument.contains(currentTarget))
if (!currentTarget || !inOwnerDocument(currentTarget))
return;
const data = currentTarget[eventKey];
if (!data)
Expand Down Expand Up @@ -2165,82 +2255,6 @@
});
}

/**
* Creates a batched version of a callback so that all calls to it in the same
* microtick will only call the original callback once.
*
* @param callback the callback to batch
* @returns a batched version of the original callback
*/
function batched(callback) {
let called = false;
return async () => {
// This await blocks all calls to the callback here, then releases them sequentially
// in the next microtick. This line decides the granularity of the batch.
await Promise.resolve();
if (!called) {
called = true;
// wait for all calls in this microtick to fall through before resetting "called"
// so that only the first call to the batched function calls the original callback.
// Schedule this before calling the callback so that calls to the batched function
// within the callback will proceed only after resetting called to false, and have
// a chance to execute the callback again
Promise.resolve().then(() => (called = false));
callback();
}
};
}
function validateTarget(target) {
// Get the document and HTMLElement corresponding to the target to allow mounting in iframes
const document = target && target.ownerDocument;
if (document) {
const HTMLElement = document.defaultView.HTMLElement;
if (target instanceof HTMLElement) {
if (!document.body.contains(target)) {
throw new OwlError("Cannot mount a component on a detached dom node");
}
return;
}
}
throw new OwlError("Cannot mount component: the target is not a valid DOM element");
}
class EventBus extends EventTarget {
trigger(name, payload) {
this.dispatchEvent(new CustomEvent(name, { detail: payload }));
}
}
function whenReady(fn) {
return new Promise(function (resolve) {
if (document.readyState !== "loading") {
resolve(true);
}
else {
document.addEventListener("DOMContentLoaded", resolve, false);
}
}).then(fn || function () { });
}
async function loadFile(url) {
const result = await fetch(url);
if (!result.ok) {
throw new OwlError("Error while fetching xml templates");
}
return await result.text();
}
/*
* This class just transports the fact that a string is safe
* to be injected as HTML. Overriding a JS primitive is quite painful though
* so we need to redfine toString and valueOf.
*/
class Markup extends String {
}
/*
* Marks a value as safe, that is, a value that can be injected as HTML directly.
* It should be used to wrap the value passed to a t-out directive to allow a raw rendering.
*/
function markup(value) {
return new Markup(value);
}

let currentNode = null;
function getCurrent() {
if (!currentNode) {
Expand Down Expand Up @@ -2292,6 +2306,7 @@
this.bdom = null;
this.status = 0 /* NEW */;
this.forceNextRender = false;
this.nextProps = null;
this.children = Object.create(null);
this.refs = {};
this.willStart = [];
Expand Down Expand Up @@ -2421,7 +2436,7 @@
this.status = 2 /* DESTROYED */;
}
async updateAndRender(props, parentFiber) {
const rawProps = props;
this.nextProps = props;
props = Object.assign({}, props);
// update
const fiber = makeChildFiber(this, parentFiber);
Expand All @@ -2445,7 +2460,6 @@
return;
}
component.props = props;
this.props = rawProps;
fiber.render();
const parentRoot = parentFiber.root;
if (this.willPatch.length) {
Expand Down Expand Up @@ -2520,6 +2534,7 @@
// by the component will be patched independently in the appropriate
// fiber.complete
this._patch();
this.props = this.nextProps;
}
}
_patch() {
Expand Down Expand Up @@ -2870,14 +2885,27 @@
if ("element" in descr) {
result = validateArrayType(key, value, descr.element);
}
else if ("shape" in descr && !result) {
else if ("shape" in descr) {
if (typeof value !== "object" || Array.isArray(value)) {
result = `'${key}' is not an object`;
}
else {
const errors = validateSchema(value, descr.shape);
if (errors.length) {
result = `'${key}' has not the correct shape (${errors.join(", ")})`;
result = `'${key}' doesn't have the correct shape (${errors.join(", ")})`;
}
}
}
else if ("values" in descr) {
if (typeof value !== "object" || Array.isArray(value)) {
result = `'${key}' is not an object`;
}
else {
const errors = Object.entries(value)
.map(([key, value]) => validateType(key, value, descr.values))
.filter(Boolean);
if (errors.length) {
result = `some of the values in '${key}' are invalid (${errors.join(", ")})`;
}
}
}
Expand Down Expand Up @@ -5480,8 +5508,8 @@
return new Function("app, bdom, helpers", code);
}

// do not modify manually. This value is updated by the release script.
const version = "2.0.9";
// do not modify manually. This file is generated by the release script.
const version = "2.1.1";

// -----------------------------------------------------------------------------
// Scheduler
Expand Down Expand Up @@ -5774,7 +5802,7 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
return {
get el() {
const el = refs[name];
return (el === null || el === void 0 ? void 0 : el.ownerDocument.contains(el)) ? el : null;
return inOwnerDocument(el) ? el : null;
},
};
}
Expand Down Expand Up @@ -5924,14 +5952,15 @@ See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration
exports.useState = useState;
exports.useSubEnv = useSubEnv;
exports.validate = validate;
exports.validateType = validateType;
exports.whenReady = whenReady;
exports.xml = xml;

Object.defineProperty(exports, '__esModule', { value: true });


__info__.date = '2023-03-13T09:56:54.968Z';
__info__.hash = '8893e02';
__info__.date = '2023-04-17T09:18:31.682Z';
__info__.hash = '4b9e6ba';
__info__.url = 'https://github.com/odoo/owl';


Expand Down

0 comments on commit 9a1dd53

Please sign in to comment.