зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1625957: Implement ResourceWatcher for CSS changes. r=ochameau,rcaliman
Differential Revision: https://phabricator.services.mozilla.com/D74599
This commit is contained in:
Родитель
2905f20adf
Коммит
9c6fbf21be
|
@ -0,0 +1,26 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const {
|
||||
ResourceWatcher,
|
||||
} = require("devtools/shared/resources/resource-watcher");
|
||||
|
||||
module.exports = async function({ targetFront, onAvailable }) {
|
||||
const changesFront = await targetFront.getFront("changes");
|
||||
|
||||
// Get all changes collected up to this point by the ChangesActor on the server,
|
||||
// then fire each change as "add-change".
|
||||
const changes = await changesFront.allChanges();
|
||||
await onAvailable(changes.map(change => toResource(change)));
|
||||
|
||||
changesFront.on("add-change", change => onAvailable([toResource(change)]));
|
||||
};
|
||||
|
||||
function toResource(change) {
|
||||
return Object.assign(change, {
|
||||
resourceType: ResourceWatcher.TYPES.CSS_CHANGE,
|
||||
});
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
DevToolsModules(
|
||||
'console-messages.js',
|
||||
'css-changes.js',
|
||||
'error-messages.js',
|
||||
'platform-messages.js',
|
||||
'root-node.js',
|
||||
|
|
|
@ -421,6 +421,7 @@ class ResourceWatcher {
|
|||
|
||||
ResourceWatcher.TYPES = ResourceWatcher.prototype.TYPES = {
|
||||
CONSOLE_MESSAGE: "console-message",
|
||||
CSS_CHANGE: "css-change",
|
||||
ERROR_MESSAGE: "error-message",
|
||||
PLATFORM_MESSAGE: "platform-message",
|
||||
DOCUMENT_EVENT: "document-event",
|
||||
|
@ -434,6 +435,8 @@ module.exports = { ResourceWatcher };
|
|||
const LegacyListeners = {
|
||||
[ResourceWatcher.TYPES
|
||||
.CONSOLE_MESSAGE]: require("devtools/shared/resources/legacy-listeners/console-messages"),
|
||||
[ResourceWatcher.TYPES
|
||||
.CSS_CHANGE]: require("devtools/shared/resources/legacy-listeners/css-changes"),
|
||||
[ResourceWatcher.TYPES
|
||||
.ERROR_MESSAGE]: require("devtools/shared/resources/legacy-listeners/error-messages"),
|
||||
[ResourceWatcher.TYPES
|
||||
|
|
Загрузка…
Ссылка в новой задаче