Bug 1794693 - [devtools] Move devtools-source-map to regular mozilla-central code. r=bomsy,perftest-reviewers,jdescottes,sparky

This used to be a node package. Let's make it become regular commonjs devtools modules.
This will make it trivial to migrate this to ES Modules.
Also possibly make this code become the unique layer in m-c on top of the source-map package.

We no longer use webpack to build the two bundles (index.js and worker.js),
instead, we are using the toolkit worker loader (require.js) in order to load
all this code without any build step.

As this is no longer a node package, I removed node-specific modules (assertRoot/wasmAsset)
and simplify the definition of wasm file URIs as they are now fixed.

Also moving the debugger to load internal "devtools/client/shared/source-map/source-map.js"
module in jest as running the Web Worker instantiated by source-map/index.js is too complex.

Differential Revision: https://phabricator.services.mozilla.com/D159115
This commit is contained in:
Alexandre Poirot 2022-11-08 16:01:01 +00:00
Родитель 828625049b
Коммит ae7b6ea7e4
75 изменённых файлов: 370 добавлений и 9006 удалений

Просмотреть файл

@ -2,7 +2,6 @@
* 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/>. */
const sourceMapAssets = require("devtools-source-map/assets");
const path = require("path");
var fs = require("fs");
const rimraf = require("rimraf");
@ -31,11 +30,6 @@ function moveFile(src, dest) {
* - parser-worker.js, pretty-print-worker.js, search-worker:
* Workers used only by the debugger.
* Sources at devtools/client/debugger/src/workers/*
* - source-map-index and source-map-worker:
* Entry point and worker for handling source-maps used both by the debugger
* and the rest of DevTools. Built from the devtools-source-map package, the
* generated files are moved to devtools/client/shared/source-map and
* usually provided by the toolbox.
*/
(async function bundle() {
process.env.TARGET = "firefox-panel";
@ -60,27 +54,5 @@ function moveFile(src, dest) {
return;
}
console.log(`[bundle] Done bundling. Copy bundles to devtools/client/shared`);
moveFile(
path.join(bundlePath, "source-map-worker.js"),
path.join(clientPath, "shared/source-map/worker.js")
);
for (const filename of Object.keys(sourceMapAssets)) {
if (filename.startsWith("resource:")) {
continue;
}
moveFile(
path.join(bundlePath, "source-map-worker-assets", filename),
path.join(clientPath, "shared/source-map/assets", filename)
);
}
moveFile(
path.join(bundlePath, "source-map-index.js"),
path.join(clientPath, "shared/source-map/index.js")
);
console.log("[bundle] Task completed.");
console.log(`[bundle] Done bundling.`);
})();

Просмотреть файл

@ -2372,10 +2372,8 @@
"usedIds": {
"0": 0,
"1": 1,
"3": 3,
"4": 4,
"5": 5,
"6": 6
"5": 5
}
},
"extract-text-webpack-plugin ../../extract-text-webpack-plugin/dist ../../css-loader/index.js??ref--3-1!../../postcss-loader/lib/index.js!../../../packages/devtools-contextmenu/menu.css": [
@ -2499,7 +2497,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"1": 1
"0": 0
}
}
}
@ -2520,7 +2518,7 @@
"byName": {},
"byBlocks": {},
"usedIds": {
"1": 1
"0": 0
}
}
}

Просмотреть файл

@ -22,7 +22,6 @@ module.exports = {
"src/test/mochitest/examples/",
"<rootDir>/firefox",
"package.json",
"<rootDir>/packages",
],
modulePathIgnorePatterns: ["test/mochitest"],
collectCoverageFrom: [

Просмотреть файл

@ -11,8 +11,5 @@ const rootDir = resolve(__dirname);
module.exports = {
rootDir,
reporters: ["default"],
projects: [
"<rootDir>/jest-test.config.js",
"<rootDir>/packages/*/jest.config.js",
],
projects: ["<rootDir>/jest-test.config.js"],
};

Просмотреть файл

@ -1,362 +0,0 @@
Mozilla Public License, version 2.0
1. Definitions
1.1. "Contributor"
means each individual or legal entity that creates, contributes to the
creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used by a
Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached the
notice in Exhibit A, the Executable Form of such Source Code Form, and
Modifications of such Source Code Form, in each case including portions
thereof.
1.5. "Incompatible With Secondary Licenses"
means
a. that the initial Contributor has attached the notice described in
Exhibit B to the Covered Software; or
b. that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the terms of
a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in a
separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible, whether
at the time of the initial grant or subsequently, any and all of the
rights conveyed by this License.
1.10. "Modifications"
means any of the following:
a. any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered Software; or
b. any new file in Source Code Form that contains any Covered Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the License,
by the making, using, selling, offering for sale, having made, import,
or transfer of either its Contributions or its Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU Lesser
General Public License, Version 2.1, the GNU Affero General Public
License, Version 3.0, or any later versions of those licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that controls, is
controlled by, or is under common control with You. For purposes of this
definition, "control" means (a) the power, direct or indirect, to cause
the direction or management of such entity, whether by contract or
otherwise, or (b) ownership of more than fifty percent (50%) of the
outstanding shares or beneficial ownership of such entity.
2. License Grants and Conditions
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
a. under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
b. under Patent Claims of such Contributor to make, use, sell, offer for
sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
a. for any code that a Contributor has removed from Covered Software; or
b. for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
c. under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights to
grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
Section 2.1.
3. Responsibilities
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
a. such Covered Software must also be made available in Source Code Form,
as described in Section 3.1, and You must inform recipients of the
Executable Form how they can obtain a copy of such Source Code Form by
reasonable means in a timely manner, at a charge no more than the cost
of distribution to the recipient; and
b. You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter the
recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty, or
limitations of liability) contained within the Source Code Form of the
Covered Software, except that You may alter any license notices to the
extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
If it is impossible for You to comply with any of the terms of this License
with respect to some or all of the Covered Software due to statute,
judicial order, or regulation then You must: (a) comply with the terms of
this License to the maximum extent possible; and (b) describe the
limitations and the code they affect. Such description must be placed in a
text file included with all distributions of the Covered Software under
this License. Except to the extent prohibited by statute or regulation,
such description must be sufficiently detailed for a recipient of ordinary
skill to be able to understand it.
5. Termination
5.1. The rights granted under this License will terminate automatically if You
fail to comply with any of its terms. However, if You become compliant,
then the rights granted under this License from a particular Contributor
are reinstated (a) provisionally, unless and until such Contributor
explicitly and finally terminates Your grants, and (b) on an ongoing
basis, if such Contributor fails to notify You of the non-compliance by
some reasonable means prior to 60 days after You have come back into
compliance. Moreover, Your grants from a particular Contributor are
reinstated on an ongoing basis if such Contributor notifies You of the
non-compliance by some reasonable means, this is the first time You have
received notice of non-compliance with this License from such
Contributor, and You become compliant prior to 30 days after Your receipt
of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
license agreements (excluding distributors and resellers) which have been
validly granted by You or Your distributors under this License prior to
termination shall survive termination.
6. Disclaimer of Warranty
Covered Software is provided under this License on an "as is" basis,
without warranty of any kind, either expressed, implied, or statutory,
including, without limitation, warranties that the Covered Software is free
of defects, merchantable, fit for a particular purpose or non-infringing.
The entire risk as to the quality and performance of the Covered Software
is with You. Should any Covered Software prove defective in any respect,
You (not any Contributor) assume the cost of any necessary servicing,
repair, or correction. This disclaimer of warranty constitutes an essential
part of this License. No use of any Covered Software is authorized under
this License except under this disclaimer.
7. Limitation of Liability
Under no circumstances and under no legal theory, whether tort (including
negligence), contract, or otherwise, shall any Contributor, or anyone who
distributes Covered Software as permitted above, be liable to You for any
direct, indirect, special, incidental, or consequential damages of any
character including, without limitation, damages for lost profits, loss of
goodwill, work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses, even if such party shall have been
informed of the possibility of such damages. This limitation of liability
shall not apply to liability for death or personal injury resulting from
such party's negligence to the extent applicable law prohibits such
limitation. Some jurisdictions do not allow the exclusion or limitation of
incidental or consequential damages, so this exclusion and limitation may
not apply to You.
8. Litigation
Any litigation relating to this License may be brought only in the courts
of a jurisdiction where the defendant maintains its principal place of
business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions. Nothing
in this Section shall prevent a party's ability to bring cross-claims or
counter-claims.
9. Miscellaneous
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides that
the language of a contract shall be construed against the drafter shall not
be used to construe this License against a Contributor.
10. Versions of the License
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses If You choose to distribute Source Code Form that is
Incompatible With Secondary Licenses under the terms of this version of
the License, the notice described in Exhibit B of this License must be
attached.
Exhibit A - Source Code Form License Notice
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/.
If it is not possible or desirable to put the notice in a particular file,
then You may include the notice in a location (such as a LICENSE file in a
relevant directory) where a recipient would be likely to look for such a
notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
This Source Code Form is "Incompatible
With Secondary Licenses", as defined by
the Mozilla Public License, v. 2.0.

Просмотреть файл

@ -1,12 +0,0 @@
# Source Maps
This package contains DevTools utilities for working with source maps.
The toolbox inside Firefox loads this package and passes it down to interested tools so
that they can share a common instance of the utilities
# Application Requirements
This package assumes that an application using this code will make the
`worker.js`, and `dwarf_to_json.wasm` files available and call
`startSourceMapWorker(workerURL, wasmRoot)` to initialize the worker and specify
the location of the wasm asset.

Просмотреть файл

@ -1,8 +0,0 @@
/* 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/>. */
module.exports = {
"source-map-mappings.wasm": "resource://devtools/client/shared/vendor/source-map/lib/mappings.wasm",
"dwarf_to_json.wasm": require.resolve("./wasm/dwarf_to_json.wasm"),
};

Просмотреть файл

@ -1,16 +0,0 @@
/* 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/>. */
const { resolve } = require("path");
const rootDir = resolve(__dirname, "src");
module.exports = {
rootDir,
displayName: "devtools-source-map test",
testMatch: ["**/tests/**/*.js"],
testPathIgnorePatterns: ["/fixtures/", "helpers.js"],
transformIgnorePatterns: ["node_modules/(?!devtools-)"],
setupFiles: [],
testURL: "http://localhost/",
moduleNameMapper: {},
};

Просмотреть файл

@ -1,16 +0,0 @@
{
"name": "devtools-source-map",
"version": "0.16.0",
"description": "DevTools utilities for working with source maps",
"license": "MPL-2.0",
"author": "Jason Laster <jlaster@mozilla.com>",
"main": "src/index.js",
"browser": {
"./src/utils/assetRoot.js": "./src/utils/assetRootBrowser.js",
"./src/wasm-dwarf/wasmAsset.js": "./src/wasm-dwarf/wasmAssetBrowser.js"
},
"scripts": {
"license-check": "devtools-license-check",
"test": "jest --projects jest.config.js"
}
}

Просмотреть файл

@ -1,88 +0,0 @@
/* 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/>. */
const { WorkerDispatcher } = require("devtools/client/shared/worker-utils");
export const dispatcher = new WorkerDispatcher();
const _getGeneratedRanges = dispatcher.task("getGeneratedRanges", {
queue: true,
});
const _getGeneratedLocation = dispatcher.task("getGeneratedLocation", {
queue: true,
});
const _getAllGeneratedLocations = dispatcher.task("getAllGeneratedLocations", {
queue: true,
});
const _getOriginalLocation = dispatcher.task("getOriginalLocation", {
queue: true,
});
export const setAssetRootURL = async assetRoot =>
dispatcher.invoke("setAssetRootURL", assetRoot);
export const getOriginalURLs = async generatedSource =>
dispatcher.invoke("getOriginalURLs", generatedSource);
export const hasOriginalURL = async url =>
dispatcher.invoke("hasOriginalURL", url);
export const getOriginalRanges = async sourceId =>
dispatcher.invoke("getOriginalRanges", sourceId);
export const getGeneratedRanges = async location =>
_getGeneratedRanges(location);
export const getGeneratedLocation = async location =>
_getGeneratedLocation(location);
export const getAllGeneratedLocations = async location =>
_getAllGeneratedLocations(location);
export const getOriginalLocation = async (location, options = {}) =>
_getOriginalLocation(location, options);
export const getOriginalLocations = async (locations, options = {}) =>
dispatcher.invoke("getOriginalLocations", locations, options);
export const getGeneratedRangesForOriginal = async (
sourceId,
mergeUnmappedRegions
) =>
dispatcher.invoke(
"getGeneratedRangesForOriginal",
sourceId,
mergeUnmappedRegions
);
export const getFileGeneratedRange = async originalSourceId =>
dispatcher.invoke("getFileGeneratedRange", originalSourceId);
export const getOriginalSourceText = async originalSourceId =>
dispatcher.invoke("getOriginalSourceText", originalSourceId);
export const applySourceMap = async (generatedId, url, code, mappings) =>
dispatcher.invoke("applySourceMap", generatedId, url, code, mappings);
export const clearSourceMaps = async () => dispatcher.invoke("clearSourceMaps");
export const getOriginalStackFrames = async generatedLocation =>
dispatcher.invoke("getOriginalStackFrames", generatedLocation);
export {
originalToGeneratedId,
generatedToOriginalId,
isGeneratedId,
isOriginalId,
} from "./utils";
export const startSourceMapWorker = (url, assetRoot) => {
dispatcher.start(url);
setAssetRootURL(assetRoot);
};
export const stopSourceMapWorker = dispatcher.stop.bind(dispatcher);
import * as self from "devtools-source-map";
export default self;

Просмотреть файл

@ -1,11 +0,0 @@
/* 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/>. */
function setAssetRootURL(assetRoot) {
// No-op on Node
}
module.exports = {
setAssetRootURL,
};

Просмотреть файл

@ -1,23 +0,0 @@
/* 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/>. */
const { SourceMapConsumer } = require("devtools/client/shared/vendor/source-map/source-map.js");
const {
setAssetRootURL: wasmDwarfSetAssetRootURL,
} = require("../wasm-dwarf/wasmAsset");
function setAssetRootURL(assetRoot) {
// Remove any trailing slash so we don't generate a double-slash below.
const root = assetRoot.replace(/\/$/, "");
wasmDwarfSetAssetRootURL(root);
SourceMapConsumer.initialize({
"lib/mappings.wasm": `${root}/source-map-mappings.wasm`,
});
}
module.exports = {
setAssetRootURL,
};

Просмотреть файл

@ -1,35 +0,0 @@
/* 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/>. */
const InlineBase64JSON = "data:application/json;";
// opts is ignored because this is only used in local development and
// replaces a more powerful network request from Firefox that can be
// configured.
function networkRequest(url, opts) {
if (url.startsWith(InlineBase64JSON)) {
const content = atob(url.slice(url.indexOf("base64") + 7));
return Promise.resolve({ content });
}
return Promise.race([
fetch(`/get?url=${url}`).then(res => {
if (res.status >= 200 && res.status < 300) {
if (res.headers.get("Content-Type") === "application/wasm") {
return res.arrayBuffer().then(buffer => ({
content: buffer,
isDwarf: true,
}));
}
return res.text().then(text => ({ content: text }));
}
return Promise.reject(new Error(`failed to request ${url}`));
}),
new Promise((resolve, reject) => {
setTimeout(() => reject(new Error("Connect timeout error")), 6000);
}),
]);
}
module.exports = { networkRequest };

Просмотреть файл

@ -1,29 +0,0 @@
/* 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/>. */
const fs = require("fs");
const assets = require("../../assets");
function setAssetRootURL(assetRoot) {
// No-op on Node
}
async function getDwarfToWasmData() {
const data = await new Promise((res, rej) => {
fs.readFile(assets["dwarf_to_json.wasm"], (err, result) => {
if (err) {
return rej(err);
}
res(result);
});
});
return data.buffer;
}
module.exports = {
setAssetRootURL,
getDwarfToWasmData,
};

Просмотреть файл

@ -6,7 +6,7 @@ import {
isOriginalId,
isGeneratedId,
originalToGeneratedId,
} from "devtools/client/shared/source-map/index";
} from "devtools/client/shared/source-map-loader/index";
import {
getSource,

Просмотреть файл

@ -25,7 +25,7 @@ import {
disableBreakpoint,
} from "./modify";
import { isOriginalId } from "devtools/client/shared/source-map/index";
import { isOriginalId } from "devtools/client/shared/source-map-loader/index";
// this will need to be changed so that addCLientBreakpoint is removed
export * from "./breakpointPositions";

Просмотреть файл

@ -14,7 +14,7 @@ import { comparePosition, createLocation } from "../../utils/location";
import {
originalToGeneratedId,
isOriginalId,
} from "devtools/client/shared/source-map/index";
} from "devtools/client/shared/source-map-loader/index";
import { getSource } from "../../selectors";
import { addBreakpoint, removeBreakpointAtGeneratedLocation } from ".";

Просмотреть файл

@ -13,7 +13,7 @@ import { isFrameBlackBoxed } from "../../utils/source";
import assert from "../../utils/assert";
import { isGeneratedId } from "devtools/client/shared/source-map/index";
import { isGeneratedId } from "devtools/client/shared/source-map-loader/index";
function getSelectedFrameId(state, thread, frames) {
let selectedFrame = getSelectedFrame(state, thread);

Просмотреть файл

@ -166,7 +166,12 @@ describe("pause", () => {
await dispatch(actions.paused(mockPauseInfo));
expect(selectors.getFrames(getState(), "FakeThread")).toEqual([
{
generatedLocation: { column: 0, line: 1, sourceId: "foo" },
generatedLocation: {
column: 0,
line: 1,
sourceId: "foo",
sourceActorId: "foo-1-actor",
},
id: mockFrameId,
location: {
column: 0,

Просмотреть файл

@ -10,7 +10,7 @@
import {
isOriginalId,
originalToGeneratedId,
} from "devtools/client/shared/source-map/index";
} from "devtools/client/shared/source-map-loader/index";
import { recordEvent } from "../../utils/telemetry";
import { getSourceActorsForSource, isSourceBlackBoxed } from "../../selectors";
@ -31,13 +31,16 @@ async function blackboxSourceActors(
// (which might be a bundle including other files).
if (isOriginalId(source.id)) {
sourceId = originalToGeneratedId(source.id);
ranges = [await sourceMaps.getFileGeneratedRange(source.id)];
if (ranges.length) {
// TODO: Investigate blackboxing lines in original files,
const range = await sourceMaps.getFileGeneratedRange(source.id);
ranges = [];
if (range) {
ranges.push(range);
// TODO bug 1752108: Investigate blackboxing lines in original files,
// there is likely to be issues as the whole genrated file
// representing the original file will always be blackboxed.
console.warn(
"The might be unxpected issues when ignoring lines in an original file."
"The might be unxpected issues when ignoring lines in an original file. " +
"The whole original source is being blackboxed."
);
}
}

Просмотреть файл

@ -2,7 +2,7 @@
* 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/>. */
import { isOriginalId } from "devtools/client/shared/source-map/index";
import { isOriginalId } from "devtools/client/shared/source-map-loader/index";
import { getSourceActorsForSource, getBreakableLines } from "../../selectors";
import { setBreakpointPositions } from "../breakpoints/breakpointPositions";
import { loadSourceActorBreakableLines } from "../source-actors";

Просмотреть файл

@ -2,7 +2,7 @@
* 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/>. */
import { generatedToOriginalId } from "devtools/client/shared/source-map/index";
import { generatedToOriginalId } from "devtools/client/shared/source-map-loader/index";
import assert from "../../utils/assert";
import { recordEvent } from "../../utils/telemetry";

Просмотреть файл

@ -7,7 +7,7 @@
* @module actions/sources
*/
import { isOriginalId } from "devtools/client/shared/source-map/index";
import { isOriginalId } from "devtools/client/shared/source-map-loader/index";
import { setSymbols } from "./symbols";
import { setInScopeLines } from "../ast";

Просмотреть файл

@ -18,7 +18,7 @@ const {
getSourceByURL,
} = selectors;
import sourceQueue from "../../../utils/source-queue";
import { generatedToOriginalId } from "devtools/client/shared/source-map/index";
import { generatedToOriginalId } from "devtools/client/shared/source-map-loader/index";
import { mockCommandClient } from "../../tests/helpers/mockCommandClient";

Просмотреть файл

@ -42,7 +42,7 @@ import {
waitForState,
} from "../../utils/test-head";
import sourceMaps from "devtools/client/shared/source-map/index";
import sourceMaps from "devtools/client/shared/source-map-loader/index";
import { makePendingLocationId } from "../../utils/breakpoint";
function mockClient(bpPos = {}) {

Просмотреть файл

@ -7,7 +7,7 @@ const SplitBox = require("devtools/client/shared/components/splitter/SplitBox");
import React, { Component } from "react";
import PropTypes from "prop-types";
import classnames from "classnames";
import { isGeneratedId } from "devtools/client/shared/source-map/index";
import { isGeneratedId } from "devtools/client/shared/source-map-loader/index";
import { connect } from "../../utils/connect";
import actions from "../../actions";

Просмотреть файл

@ -7,7 +7,7 @@
* @module reducers/tabs
*/
import { isOriginalId } from "devtools/client/shared/source-map/index";
import { isOriginalId } from "devtools/client/shared/source-map-loader/index";
import { isSimilarTab, persistTabs } from "../utils/tabs";

Просмотреть файл

@ -4,7 +4,7 @@
import { createSelector } from "reselect";
import { isGeneratedId } from "devtools/client/shared/source-map/index";
import { isGeneratedId } from "devtools/client/shared/source-map-loader/index";
import { makeBreakpointId } from "../utils/breakpoint";
// This method is only used from the main test helper

Просмотреть файл

@ -5,7 +5,7 @@
import {
originalToGeneratedId,
isOriginalId,
} from "devtools/client/shared/source-map/index";
} from "devtools/client/shared/source-map-loader/index";
import { getSelectedFrame, getSelectedLocation, getCurrentThread } from ".";
function getGeneratedId(sourceId) {

Просмотреть файл

@ -5,7 +5,7 @@
import { getThreadPauseState } from "../reducers/pause";
import { getSelectedSourceId, getSelectedLocation } from "./sources";
import { isGeneratedId } from "devtools/client/shared/source-map/index";
import { isGeneratedId } from "devtools/client/shared/source-map-loader/index";
// eslint-disable-next-line
import { getSelectedLocation as _getSelectedLocation } from "../utils/selected-location";

Просмотреть файл

@ -15,7 +15,7 @@ import {
import { findPosition } from "../utils/breakpoint/breakpointPositions";
import { isFulfilled } from "../utils/async-value";
import { originalToGeneratedId } from "devtools/client/shared/source-map/index";
import { originalToGeneratedId } from "devtools/client/shared/source-map-loader/index";
import { prefs } from "../utils/prefs";
import {

Просмотреть файл

@ -11,7 +11,7 @@ import {
getSpecificSourceByURL,
getSourcesMap,
} from "./sources";
import { isOriginalId } from "devtools/client/shared/source-map/index";
import { isOriginalId } from "devtools/client/shared/source-map-loader/index";
import { isSimilarTab } from "../utils/tabs";
export const getTabs = state => state.tabs.tabs;

Просмотреть файл

@ -10,11 +10,6 @@ import Adapter from "enzyme-adapter-react-16";
import { setupHelper } from "../utils/dbg";
import { prefs } from "../utils/prefs";
import {
startSourceMapWorker,
stopSourceMapWorker,
} from "devtools/client/shared/source-map/index";
import {
start as startPrettyPrintWorker,
stop as stopPrettyPrintWorker,
@ -41,10 +36,6 @@ export const parserWorker = new ParserDispatcher();
export const evaluationsParser = new ParserDispatcher();
beforeAll(() => {
startSourceMapWorker(
path.join(rootPath, "node_modules/devtools-source-map/src/worker.js"),
""
);
startPrettyPrintWorker(
path.join(rootPath, "src/workers/pretty-print/worker.js")
);
@ -55,7 +46,6 @@ beforeAll(() => {
});
afterAll(() => {
stopSourceMapWorker();
stopPrettyPrintWorker();
parserWorker.stop();
evaluationsParser.stop();

Просмотреть файл

@ -2,7 +2,7 @@
* 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/>. */
import { isOriginalId } from "devtools/client/shared/source-map/index";
import { isOriginalId } from "devtools/client/shared/source-map-loader/index";
export function getSelectedLocation(mappedLocation, context) {
if (!context) {

Просмотреть файл

@ -2,7 +2,7 @@
* 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/>. */
import { isOriginalId } from "devtools/client/shared/source-map/index";
import { isOriginalId } from "devtools/client/shared/source-map-loader/index";
import { getSource, getLocationSource } from "../selectors";
export async function getGeneratedLocation(

Просмотреть файл

@ -8,7 +8,6 @@
*/
import { combineReducers } from "redux";
import sourceMaps from "devtools/client/shared/source-map/index";
import reducers from "../reducers";
import actions from "../actions";
import * as selectors from "../selectors";
@ -16,6 +15,12 @@ import { parserWorker, evaluationsParser } from "../test/tests-setup";
import configureStore from "../actions/utils/create-store";
import sourceQueue from "../utils/source-queue";
import { setupCreate } from "../client/firefox/create";
// Import the internal module used by the source-map worker
// as node doesn't have Web Worker support and require path mapping
// doesn't work from nodejs worker thread and break mappings to devtools/ folder.
import sourceMaps from "devtools/client/shared/source-map-loader/source-map";
/**
* This file contains older interfaces used by tests that have not been
* converted to use test-mockup.js

Просмотреть файл

@ -50,7 +50,7 @@ const {
isGeneratedId,
isOriginalId,
originalToGeneratedId,
} = require("devtools/client/shared/source-map/index");
} = require("devtools/client/shared/source-map-loader/index");
/**
* Waits for `predicate()` to be true. `state` is the redux app state.

Просмотреть файл

@ -2,7 +2,6 @@
* 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/>. */
const sourceMapAssets = require("devtools-source-map/assets");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
@ -31,8 +30,6 @@ module.exports = {
"parser-worker": getEntry("src/workers/parser/worker.js"),
"pretty-print-worker": getEntry("src/workers/pretty-print/worker.js"),
"search-worker": getEntry("src/workers/search/worker.js"),
"source-map-worker": getEntry("packages/devtools-source-map/src/worker.js"),
"source-map-index": getEntry("packages/devtools-source-map/src/index.js"),
vendors: getEntry("src/vendors.js"),
},
@ -44,12 +41,6 @@ module.exports = {
},
plugins: [
new CopyWebpackPlugin(
Object.entries(sourceMapAssets).filter(([name, filePath]) => !filePath.startsWith("resource:")).map(([name, filePath]) => ({
from: filePath,
to: `source-map-worker-assets/${name}`,
}))
),
new webpack.BannerPlugin({
banner: `/* 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
@ -59,16 +50,6 @@ module.exports = {
}),
new ObjectRestSpreadPlugin(),
new ExtractTextPlugin("[name].css"),
new webpack.NormalModuleReplacementPlugin(
/\.\/utils\/network-request/,
"./utils/privileged-network-request"
),
// This additional NormalModuleReplacementPlugin is for files in the same
// folder as network-request which use require("./network-request");
new webpack.NormalModuleReplacementPlugin(
/\.\/network-request/,
"./privileged-network-request"
),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || "production"),

Просмотреть файл

@ -42,7 +42,11 @@ add_task(async function() {
"resource://devtools/client/shared/redux/subscriber.js",
"resource://devtools/client/shared/worker-utils.js",
"resource://devtools/client/debugger/src/workers/parser/index.js",
"resource://devtools/client/shared/source-map/index.js",
"resource://devtools/client/shared/source-map-loader/index.js",
"resource://devtools/client/shared/source-map-loader/utils/index.js",
"resource://devtools/client/shared/vendor/md5.js",
"resource://devtools/client/shared/components/menu/MenuButton.js",
"resource://devtools/client/shared/components/menu/MenuItem.js",
"resource://devtools/client/shared/components/menu/MenuList.js",

Просмотреть файл

@ -5,9 +5,7 @@
"use strict";
const SOURCE_MAP_WORKER =
"resource://devtools/client/shared/source-map/worker.js";
const SOURCE_MAP_WORKER_ASSETS =
"resource://devtools/client/shared/source-map/assets/";
"resource://devtools/client/shared/source-map-loader/worker.js";
const MAX_ORDINAL = 99;
const SPLITCONSOLE_ENABLED_PREF = "devtools.toolbox.splitconsoleEnabled";
@ -1385,7 +1383,7 @@ Toolbox.prototype = {
}
// Uses browser loader to access the `Worker` global.
const service = this.browserRequire(
"devtools/client/shared/source-map/index"
"devtools/client/shared/source-map-loader/index"
);
// Provide a wrapper for the service that reports errors more nicely.
@ -1455,10 +1453,7 @@ Toolbox.prototype = {
},
});
this._sourceMapService.startSourceMapWorker(
SOURCE_MAP_WORKER,
SOURCE_MAP_WORKER_ASSETS
);
this._sourceMapService.startSourceMapWorker(SOURCE_MAP_WORKER);
return this._sourceMapService;
},

Просмотреть файл

@ -13,6 +13,7 @@ const TEST_LIB_BABEL = URL_ROOT_SSL + "lib_babel_6.21.0_min.js";
const TEST_EXTERNAL_LISTENERS = URL_ROOT_SSL + "react_external_listeners.js";
const TEST_URL =
URL_ROOT_SSL + "doc_markup_events_react_development_15.4.1_jsx.html";
const TEST_INLINE_BABEL_ORIGINAL = URL_ROOT_SSL + "Inline%20Babel%20script:9";
loadHelperScript("helper_events_test_runner.js");
@ -20,6 +21,7 @@ loadHelperScript("helper_events_test_runner.js");
const TEST_DATA = [
{
selector: "#inlinejsx",
isSourceMapped: true,
expected: [
{
type: "click",
@ -29,7 +31,7 @@ const TEST_DATA = [
},
{
type: "onClick",
filename: TEST_LIB_BABEL + ":11:41",
filename: TEST_INLINE_BABEL_ORIGINAL,
attributes: ["React", "Bubbling"],
handler: `
function inlineFunction() {

Просмотреть файл

@ -13,6 +13,7 @@ const TEST_LIB_BABEL = URL_ROOT_SSL + "lib_babel_6.21.0_min.js";
const TEST_EXTERNAL_LISTENERS = URL_ROOT_SSL + "react_external_listeners.js";
const TEST_URL =
URL_ROOT_SSL + "doc_markup_events_react_production_15.3.1_jsx.html";
const TEST_INLINE_BABEL_ORIGINAL = URL_ROOT_SSL + "Inline%20Babel%20script:9";
loadHelperScript("helper_events_test_runner.js");
@ -20,6 +21,7 @@ loadHelperScript("helper_events_test_runner.js");
const TEST_DATA = [
{
selector: "#inlinejsx",
isSourceMapped: true,
expected: [
{
type: "click",
@ -29,7 +31,7 @@ const TEST_DATA = [
},
{
type: "onClick",
filename: TEST_LIB_BABEL + ":11:41",
filename: TEST_INLINE_BABEL_ORIGINAL,
attributes: ["React", "Bubbling"],
handler: `
function() {

Просмотреть файл

@ -15,7 +15,7 @@ DIRS += [
"fluent-l10n",
"redux",
"remote-debugging",
"source-map",
"source-map-loader",
"sourceeditor",
"vendor",
"widgets",

Просмотреть файл

@ -0,0 +1,117 @@
/* 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 {
WorkerDispatcher,
} = require("resource://devtools/client/shared/worker-utils.js");
const dispatcher = new WorkerDispatcher();
const _getGeneratedRanges = dispatcher.task("getGeneratedRanges", {
queue: true,
});
const _getGeneratedLocation = dispatcher.task("getGeneratedLocation", {
queue: true,
});
const _getAllGeneratedLocations = dispatcher.task("getAllGeneratedLocations", {
queue: true,
});
const _getOriginalLocation = dispatcher.task("getOriginalLocation", {
queue: true,
});
const {
originalToGeneratedId,
generatedToOriginalId,
isGeneratedId,
isOriginalId,
} = require("resource://devtools/client/shared/source-map-loader/utils/index.js");
module.exports = {
originalToGeneratedId,
generatedToOriginalId,
isGeneratedId,
isOriginalId,
setAssetRootURL() {
return dispatcher.invoke("setAssetRootURL");
},
getOriginalURLs(generatedSource) {
return dispatcher.invoke("getOriginalURLs", generatedSource);
},
hasOriginalURL(url) {
return dispatcher.invoke("hasOriginalURL", url);
},
getOriginalRanges(sourceId) {
return dispatcher.invoke("getOriginalRanges", sourceId);
},
getGeneratedRanges(location) {
return _getGeneratedRanges(location);
},
getGeneratedLocation(location) {
return _getGeneratedLocation(location);
},
getAllGeneratedLocations(location) {
return _getAllGeneratedLocations(location);
},
getOriginalLocation(location, options = {}) {
return _getOriginalLocation(location, options);
},
getOriginalLocations(locations, options = {}) {
return dispatcher.invoke("getOriginalLocations", locations, options);
},
getGeneratedRangesForOriginal(sourceId, mergeUnmappedRegions) {
return dispatcher.invoke(
"getGeneratedRangesForOriginal",
sourceId,
mergeUnmappedRegions
);
},
getFileGeneratedRange(originalSourceId) {
return dispatcher.invoke("getFileGeneratedRange", originalSourceId);
},
getOriginalSourceText(originalSourceId) {
return dispatcher.invoke("getOriginalSourceText", originalSourceId);
},
applySourceMap(generatedId, url, code, mappings) {
return dispatcher.invoke(
"applySourceMap",
generatedId,
url,
code,
mappings
);
},
clearSourceMaps() {
return dispatcher.invoke("clearSourceMaps");
},
getOriginalStackFrames(generatedLocation) {
return dispatcher.invoke("getOriginalStackFrames", generatedLocation);
},
startSourceMapWorker(url) {
dispatcher.start(url);
module.exports.setAssetRootURL();
},
stopSourceMapWorker: dispatcher.stop.bind(dispatcher),
};

Просмотреть файл

@ -0,0 +1,16 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
DIRS += [
"utils",
"wasm-dwarf",
]
DevToolsModules(
"index.js",
"source-map.js",
"worker.js",
)

Просмотреть файл

@ -2,35 +2,46 @@
* 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";
/**
* Source Map Worker
* @module utils/source-map-worker
*/
const { networkRequest } = require("./utils/network-request");
const { SourceMapConsumer, SourceMapGenerator } = require("devtools/client/shared/vendor/source-map/source-map.js");
const {
networkRequest,
} = require("resource://devtools/client/shared/source-map-loader/utils/network-request.js");
const {
SourceMapConsumer,
SourceMapGenerator,
} = require("resource://devtools/client/shared/vendor/source-map/source-map.js");
const { createConsumer } = require("./utils/createConsumer");
const assert = require("./utils/assert");
const {
createConsumer,
} = require("resource://devtools/client/shared/source-map-loader/utils/createConsumer.js");
const assert = require("resource://devtools/client/shared/source-map-loader/utils/assert.js");
const {
fetchSourceMap,
hasOriginalURL,
clearOriginalURLs,
} = require("./utils/fetchSourceMap");
} = require("resource://devtools/client/shared/source-map-loader/utils/fetchSourceMap.js");
const {
getSourceMap,
getSourceMapWithMetadata,
setSourceMap,
clearSourceMaps: clearSourceMapsRequests,
} = require("./utils/sourceMapRequests");
} = require("resource://devtools/client/shared/source-map-loader/utils/sourceMapRequests.js");
const {
originalToGeneratedId,
generatedToOriginalId,
isGeneratedId,
isOriginalId,
getContentType,
} = require("./utils");
const { clearWasmXScopes } = require("./wasm-dwarf/wasmXScopes");
} = require("resource://devtools/client/shared/source-map-loader/utils/index.js");
const {
clearWasmXScopes,
} = require("resource://devtools/client/shared/source-map-loader/wasm-dwarf/wasmXScopes.js");
async function getOriginalURLs(generatedSource) {
await fetchSourceMap(generatedSource);
@ -396,10 +407,7 @@ async function getGeneratedRangesForOriginal(
column: mapping.lastGeneratedColumn + 1,
},
});
} else if (
typeof mapping.source === "string" &&
currentGroup.length > 0
) {
} else if (typeof mapping.source === "string" && currentGroup.length) {
// If there is a URL, but it is for a _different_ file, we create a
// new group of mappings so that we can tell
currentGroup = [];
@ -416,7 +424,7 @@ async function getGeneratedRangesForOriginal(
// create a range that is the fully encompasses each group, ignoring the
// empty space between each individual range.
for (const group of originalGroups) {
if (group.length > 0) {
if (group.length) {
generatedMappingsForOriginal.push({
start: group[0].start,
end: group[group.length - 1].end,
@ -474,7 +482,7 @@ async function getFileGeneratedRange(originalSourceId) {
originalToGeneratedId(originalSourceId)
);
if (!data) {
return;
return null;
}
const { urlsById, map } = data;

Просмотреть файл

@ -2,6 +2,8 @@
* 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";
function assert(condition, message) {
if (!condition) {
throw new Error(`Assertion failure: ${message}`);

Просмотреть файл

@ -0,0 +1,20 @@
/* 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 {
SourceMapConsumer,
} = require("resource://devtools/client/shared/vendor/source-map/source-map.js");
function setAssetRootURL() {
SourceMapConsumer.initialize({
"lib/mappings.wasm":
"resource://devtools/client/shared/vendor/source-map/lib/mappings.wasm",
});
}
module.exports = {
setAssetRootURL,
};

Просмотреть файл

@ -2,7 +2,11 @@
* 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/>. */
const { SourceMapConsumer } = require("devtools/client/shared/vendor/source-map/source-map.js");
"use strict";
const {
SourceMapConsumer,
} = require("resource://devtools/client/shared/vendor/source-map/source-map.js");
async function createConsumer(map, sourceMapUrl) {
return new SourceMapConsumer(map, sourceMapUrl);

Просмотреть файл

@ -2,12 +2,25 @@
* 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/>. */
const { networkRequest } = require("./network-request");
"use strict";
const { getSourceMap, setSourceMap } = require("./sourceMapRequests");
const { WasmRemap } = require("./wasmRemap");
const { convertToJSON } = require("../wasm-dwarf/convertToJSON");
const { createConsumer } = require("./createConsumer");
const {
networkRequest,
} = require("resource://devtools/client/shared/source-map-loader/utils/network-request");
const {
getSourceMap,
setSourceMap,
} = require("resource://devtools/client/shared/source-map-loader/utils/sourceMapRequests");
const {
WasmRemap,
} = require("resource://devtools/client/shared/source-map-loader/utils/wasmRemap");
const {
convertToJSON,
} = require("resource://devtools/client/shared/source-map-loader/wasm-dwarf/convertToJSON");
const {
createConsumer,
} = require("resource://devtools/client/shared/source-map-loader/utils/createConsumer");
// URLs which have been seen in a completed source map request.
const originalURLs = new Set();

Просмотреть файл

@ -2,9 +2,17 @@
* 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/>. */
const { getWasmXScopes } = require("../wasm-dwarf/wasmXScopes");
const { getSourceMap } = require("./sourceMapRequests");
const { generatedToOriginalId } = require("./index");
"use strict";
const {
getWasmXScopes,
} = require("resource://devtools/client/shared/source-map-loader/wasm-dwarf/wasmXScopes");
const {
getSourceMap,
} = require("resource://devtools/client/shared/source-map-loader/utils/sourceMapRequests");
const {
generatedToOriginalId,
} = require("resource://devtools/client/shared/source-map-loader/utils/index");
// Returns expanded stack frames details based on the generated location.
// The function return null if not information was found.

Просмотреть файл

@ -2,6 +2,8 @@
* 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 md5 = require("resource://devtools/client/shared/vendor/md5.js");
function originalToGeneratedId(sourceId) {

Просмотреть файл

@ -0,0 +1,17 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
DevToolsModules(
"assert.js",
"assetRoot.js",
"createConsumer.js",
"fetchSourceMap.js",
"getOriginalStackFrames.js",
"index.js",
"network-request.js",
"sourceMapRequests.js",
"wasmRemap.js",
)

Просмотреть файл

@ -2,6 +2,8 @@
* 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";
function networkRequest(url, opts) {
const supportedProtocols = ["http:", "https:", "data:"];

Просмотреть файл

@ -2,7 +2,11 @@
* 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/>. */
const { generatedToOriginalId } = require(".");
"use strict";
const {
generatedToOriginalId,
} = require("resource://devtools/client/shared/source-map-loader/utils/index.js");
const sourceMapRequests = new Map();

Просмотреть файл

@ -2,6 +2,8 @@
* 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";
/**
* SourceMapConsumer for WebAssembly source maps. It transposes columns with
* lines, which allows mapping data to be used with SpiderMonkey Debugger API.

Просмотреть файл

@ -4,7 +4,11 @@
/* eslint camelcase: 0*/
const { getDwarfToWasmData } = require("./wasmAsset.js");
"use strict";
const {
getDwarfToWasmData,
} = require("resource://devtools/client/shared/source-map-loader/wasm-dwarf/wasmAsset.js");
let cachedWasmModule;
let utf8Decoder;

Просмотреть файл

@ -5,6 +5,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DevToolsModules(
'dwarf_to_json.wasm',
'source-map-mappings.wasm',
"convertToJSON.js",
"wasmAsset.js",
"wasmDwarfExpressions.js",
"wasmXScopes.js",
)

Просмотреть файл

@ -2,22 +2,16 @@
* 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/>. */
let root;
function setAssetRootURL(assetRoot) {
root = assetRoot;
}
"use strict";
async function getDwarfToWasmData(name) {
if (!root) {
throw new Error(`No wasm path - Unable to resolve ${name}`);
}
const response = await fetch(`${root}/dwarf_to_json.wasm`);
const response = await fetch(
"resource://devtools/client/shared/source-map-loader/wasm-dwarf/dwarf_to_json.wasm"
);
return response.arrayBuffer();
}
module.exports = {
setAssetRootURL,
getDwarfToWasmData,
};

Просмотреть файл

@ -5,6 +5,8 @@
/* eslint camelcase: 0*/
/* eslint-disable no-inline-comments */
"use strict";
class Value {
val;

Просмотреть файл

@ -4,14 +4,18 @@
/* eslint camelcase: 0*/
const { decodeExpr } = require("./wasmDwarfExpressions");
"use strict";
const {
decodeExpr,
} = require("resource://devtools/client/shared/source-map-loader/wasm-dwarf/wasmDwarfExpressions");
const xScopes = new Map();
function indexLinkingNames(items) {
const result = new Map();
let queue = [...items];
while (queue.length > 0) {
while (queue.length) {
const item = queue.shift();
if ("uid" in item) {
result.set(item.uid, item);

Просмотреть файл

@ -2,6 +2,12 @@
* 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/>. */
/* eslint-env worker */
"use strict";
importScripts("resource://gre/modules/workers/require.js");
const {
getOriginalURLs,
hasOriginalURL,
@ -16,12 +22,18 @@ const {
getFileGeneratedRange,
clearSourceMaps,
applySourceMap,
} = require("./source-map");
} = require("resource://devtools/client/shared/source-map-loader/source-map.js");
const { getOriginalStackFrames } = require("./utils/getOriginalStackFrames");
const { setAssetRootURL } = require("./utils/assetRoot");
const {
getOriginalStackFrames,
} = require("resource://devtools/client/shared/source-map-loader/utils/getOriginalStackFrames.js");
const {
setAssetRootURL,
} = require("resource://devtools/client/shared/source-map-loader/utils/assetRoot.js");
const { workerHandler } = require("devtools/client/shared/worker-utils");
const {
workerHandler,
} = require("resource://devtools/client/shared/worker-utils.js");
// The interface is implemented in source-map to be
// easier to unit test.

Просмотреть файл

@ -1,11 +0,0 @@
THIS FOLDER ONLY CONTAINS GENERATED FILES, NEVER UPDATE MANUALLY!
The source files for the source-map shared helpers can be found under
devtools/client/debugger/packages/devtools-source-map
After modifying the sources in debugger/packages/devtools-source-map, regenerate
the files in this folder by running:
> cd devtools/client/debugger
> yarn && node bin/bundle.js

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -1,704 +0,0 @@
/* 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/. */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else {
var a = factory();
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(typeof self !== 'undefined' ? self : this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/assets/build";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 928);
/******/ })
/************************************************************************/
/******/ ({
/***/ 1059:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* 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/>. */
function WorkerDispatcher() {
this.msgId = 1;
this.worker = null; // Map of message ids -> promise resolution functions, for dispatching worker responses
this.pendingCalls = new Map();
this._onMessage = this._onMessage.bind(this);
}
WorkerDispatcher.prototype = {
start(url, win = window) {
this.worker = new win.Worker(url);
this.worker.onerror = err => {
console.error(`Error in worker ${url}`, err.message);
};
this.worker.addEventListener("message", this._onMessage);
},
stop() {
if (!this.worker) {
return;
}
this.worker.removeEventListener("message", this._onMessage);
this.worker.terminate();
this.worker = null;
this.pendingCalls.clear();
},
task(method, {
queue = false
} = {}) {
const calls = [];
const push = args => {
return new Promise((resolve, reject) => {
if (queue && calls.length === 0) {
Promise.resolve().then(flush);
}
calls.push({
args,
resolve,
reject
});
if (!queue) {
flush();
}
});
};
const flush = () => {
const items = calls.slice();
calls.length = 0;
if (!this.worker) {
return;
}
const id = this.msgId++;
this.worker.postMessage({
id,
method,
calls: items.map(item => item.args)
});
this.pendingCalls.set(id, items);
};
return (...args) => push(args);
},
invoke(method, ...args) {
return this.task(method)(...args);
},
_onMessage({
data: result
}) {
const items = this.pendingCalls.get(result.id);
this.pendingCalls.delete(result.id);
if (!items) {
return;
}
if (!this.worker) {
return;
}
result.results.forEach((resultData, i) => {
const {
resolve,
reject
} = items[i];
if (resultData.error) {
const err = new Error(resultData.message);
err.metadata = resultData.metadata;
reject(err);
} else {
resolve(resultData.response);
}
});
}
};
function workerHandler(publicInterface) {
return function (msg) {
const {
id,
method,
calls
} = msg.data;
Promise.all(calls.map(args => {
try {
const response = publicInterface[method].apply(undefined, args);
if (response instanceof Promise) {
return response.then(val => ({
response: val
}), err => asErrorMessage(err));
}
return {
response
};
} catch (error) {
return asErrorMessage(error);
}
})).then(results => {
globalThis.postMessage({
id,
results
});
});
};
}
function asErrorMessage(error) {
if (typeof error === "object" && error && "message" in error) {
// Error can't be sent via postMessage, so be sure to convert to
// string.
return {
error: true,
message: error.message,
metadata: error.metadata
};
}
return {
error: true,
message: error == null ? error : error.toString(),
metadata: undefined
};
} // Might be loaded within a worker thread where `module` isn't available.
if (true) {
module.exports = {
WorkerDispatcher,
workerHandler
};
}
/***/ }),
/***/ 1084:
/***/ (function(module, exports, __webpack_require__) {
!function (t, n) {
true ? module.exports = n() : "function" == typeof define && define.amd ? define([], n) : "object" == typeof exports ? exports.MD5 = n() : t.MD5 = n();
}(this, function () {
return function (t) {
function n(o) {
if (r[o]) return r[o].exports;
var e = r[o] = {
i: o,
l: !1,
exports: {}
};
return t[o].call(e.exports, e, e.exports, n), e.l = !0, e.exports;
}
var r = {};
return n.m = t, n.c = r, n.i = function (t) {
return t;
}, n.d = function (t, r, o) {
n.o(t, r) || Object.defineProperty(t, r, {
configurable: !1,
enumerable: !0,
get: o
});
}, n.n = function (t) {
var r = t && t.__esModule ? function () {
return t.default;
} : function () {
return t;
};
return n.d(r, "a", r), r;
}, n.o = function (t, n) {
return Object.prototype.hasOwnProperty.call(t, n);
}, n.p = "", n(n.s = 4);
}([function (t, n) {
var r = {
utf8: {
stringToBytes: function (t) {
return r.bin.stringToBytes(unescape(encodeURIComponent(t)));
},
bytesToString: function (t) {
return decodeURIComponent(escape(r.bin.bytesToString(t)));
}
},
bin: {
stringToBytes: function (t) {
for (var n = [], r = 0; r < t.length; r++) n.push(255 & t.charCodeAt(r));
return n;
},
bytesToString: function (t) {
for (var n = [], r = 0; r < t.length; r++) n.push(String.fromCharCode(t[r]));
return n.join("");
}
}
};
t.exports = r;
}, function (t, n, r) {
!function () {
var n = r(2),
o = r(0).utf8,
e = r(3),
u = r(0).bin,
i = function (t, r) {
t.constructor == String ? t = r && "binary" === r.encoding ? u.stringToBytes(t) : o.stringToBytes(t) : e(t) ? t = Array.prototype.slice.call(t, 0) : Array.isArray(t) || t.constructor === Uint8Array || (t = t.toString());
for (var f = n.bytesToWords(t), s = 8 * t.length, c = 1732584193, a = -271733879, p = -1732584194, l = 271733878, g = 0; g < f.length; g++) f[g] = 16711935 & (f[g] << 8 | f[g] >>> 24) | 4278255360 & (f[g] << 24 | f[g] >>> 8);
f[s >>> 5] |= 128 << s % 32, f[14 + (s + 64 >>> 9 << 4)] = s;
for (var h = i._ff, y = i._gg, d = i._hh, v = i._ii, g = 0; g < f.length; g += 16) {
var b = c,
x = a,
T = p,
B = l;
c = h(c, a, p, l, f[g + 0], 7, -680876936), l = h(l, c, a, p, f[g + 1], 12, -389564586), p = h(p, l, c, a, f[g + 2], 17, 606105819), a = h(a, p, l, c, f[g + 3], 22, -1044525330), c = h(c, a, p, l, f[g + 4], 7, -176418897), l = h(l, c, a, p, f[g + 5], 12, 1200080426), p = h(p, l, c, a, f[g + 6], 17, -1473231341), a = h(a, p, l, c, f[g + 7], 22, -45705983), c = h(c, a, p, l, f[g + 8], 7, 1770035416), l = h(l, c, a, p, f[g + 9], 12, -1958414417), p = h(p, l, c, a, f[g + 10], 17, -42063), a = h(a, p, l, c, f[g + 11], 22, -1990404162), c = h(c, a, p, l, f[g + 12], 7, 1804603682), l = h(l, c, a, p, f[g + 13], 12, -40341101), p = h(p, l, c, a, f[g + 14], 17, -1502002290), a = h(a, p, l, c, f[g + 15], 22, 1236535329), c = y(c, a, p, l, f[g + 1], 5, -165796510), l = y(l, c, a, p, f[g + 6], 9, -1069501632), p = y(p, l, c, a, f[g + 11], 14, 643717713), a = y(a, p, l, c, f[g + 0], 20, -373897302), c = y(c, a, p, l, f[g + 5], 5, -701558691), l = y(l, c, a, p, f[g + 10], 9, 38016083), p = y(p, l, c, a, f[g + 15], 14, -660478335), a = y(a, p, l, c, f[g + 4], 20, -405537848), c = y(c, a, p, l, f[g + 9], 5, 568446438), l = y(l, c, a, p, f[g + 14], 9, -1019803690), p = y(p, l, c, a, f[g + 3], 14, -187363961), a = y(a, p, l, c, f[g + 8], 20, 1163531501), c = y(c, a, p, l, f[g + 13], 5, -1444681467), l = y(l, c, a, p, f[g + 2], 9, -51403784), p = y(p, l, c, a, f[g + 7], 14, 1735328473), a = y(a, p, l, c, f[g + 12], 20, -1926607734), c = d(c, a, p, l, f[g + 5], 4, -378558), l = d(l, c, a, p, f[g + 8], 11, -2022574463), p = d(p, l, c, a, f[g + 11], 16, 1839030562), a = d(a, p, l, c, f[g + 14], 23, -35309556), c = d(c, a, p, l, f[g + 1], 4, -1530992060), l = d(l, c, a, p, f[g + 4], 11, 1272893353), p = d(p, l, c, a, f[g + 7], 16, -155497632), a = d(a, p, l, c, f[g + 10], 23, -1094730640), c = d(c, a, p, l, f[g + 13], 4, 681279174), l = d(l, c, a, p, f[g + 0], 11, -358537222), p = d(p, l, c, a, f[g + 3], 16, -722521979), a = d(a, p, l, c, f[g + 6], 23, 76029189), c = d(c, a, p, l, f[g + 9], 4, -640364487), l = d(l, c, a, p, f[g + 12], 11, -421815835), p = d(p, l, c, a, f[g + 15], 16, 530742520), a = d(a, p, l, c, f[g + 2], 23, -995338651), c = v(c, a, p, l, f[g + 0], 6, -198630844), l = v(l, c, a, p, f[g + 7], 10, 1126891415), p = v(p, l, c, a, f[g + 14], 15, -1416354905), a = v(a, p, l, c, f[g + 5], 21, -57434055), c = v(c, a, p, l, f[g + 12], 6, 1700485571), l = v(l, c, a, p, f[g + 3], 10, -1894986606), p = v(p, l, c, a, f[g + 10], 15, -1051523), a = v(a, p, l, c, f[g + 1], 21, -2054922799), c = v(c, a, p, l, f[g + 8], 6, 1873313359), l = v(l, c, a, p, f[g + 15], 10, -30611744), p = v(p, l, c, a, f[g + 6], 15, -1560198380), a = v(a, p, l, c, f[g + 13], 21, 1309151649), c = v(c, a, p, l, f[g + 4], 6, -145523070), l = v(l, c, a, p, f[g + 11], 10, -1120210379), p = v(p, l, c, a, f[g + 2], 15, 718787259), a = v(a, p, l, c, f[g + 9], 21, -343485551), c = c + b >>> 0, a = a + x >>> 0, p = p + T >>> 0, l = l + B >>> 0;
}
return n.endian([c, a, p, l]);
};
i._ff = function (t, n, r, o, e, u, i) {
var f = t + (n & r | ~n & o) + (e >>> 0) + i;
return (f << u | f >>> 32 - u) + n;
}, i._gg = function (t, n, r, o, e, u, i) {
var f = t + (n & o | r & ~o) + (e >>> 0) + i;
return (f << u | f >>> 32 - u) + n;
}, i._hh = function (t, n, r, o, e, u, i) {
var f = t + (n ^ r ^ o) + (e >>> 0) + i;
return (f << u | f >>> 32 - u) + n;
}, i._ii = function (t, n, r, o, e, u, i) {
var f = t + (r ^ (n | ~o)) + (e >>> 0) + i;
return (f << u | f >>> 32 - u) + n;
}, i._blocksize = 16, i._digestsize = 16, t.exports = function (t, r) {
if (void 0 === t || null === t) throw new Error("Illegal argument " + t);
var o = n.wordsToBytes(i(t, r));
return r && r.asBytes ? o : r && r.asString ? u.bytesToString(o) : n.bytesToHex(o);
};
}();
}, function (t, n) {
!function () {
var n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
r = {
rotl: function (t, n) {
return t << n | t >>> 32 - n;
},
rotr: function (t, n) {
return t << 32 - n | t >>> n;
},
endian: function (t) {
if (t.constructor == Number) return 16711935 & r.rotl(t, 8) | 4278255360 & r.rotl(t, 24);
for (var n = 0; n < t.length; n++) t[n] = r.endian(t[n]);
return t;
},
randomBytes: function (t) {
for (var n = []; t > 0; t--) n.push(Math.floor(256 * Math.random()));
return n;
},
bytesToWords: function (t) {
for (var n = [], r = 0, o = 0; r < t.length; r++, o += 8) n[o >>> 5] |= t[r] << 24 - o % 32;
return n;
},
wordsToBytes: function (t) {
for (var n = [], r = 0; r < 32 * t.length; r += 8) n.push(t[r >>> 5] >>> 24 - r % 32 & 255);
return n;
},
bytesToHex: function (t) {
for (var n = [], r = 0; r < t.length; r++) n.push((t[r] >>> 4).toString(16)), n.push((15 & t[r]).toString(16));
return n.join("");
},
hexToBytes: function (t) {
for (var n = [], r = 0; r < t.length; r += 2) n.push(parseInt(t.substr(r, 2), 16));
return n;
},
bytesToBase64: function (t) {
for (var r = [], o = 0; o < t.length; o += 3) for (var e = t[o] << 16 | t[o + 1] << 8 | t[o + 2], u = 0; u < 4; u++) 8 * o + 6 * u <= 8 * t.length ? r.push(n.charAt(e >>> 6 * (3 - u) & 63)) : r.push("=");
return r.join("");
},
base64ToBytes: function (t) {
t = t.replace(/[^A-Z0-9+\/]/gi, "");
for (var r = [], o = 0, e = 0; o < t.length; e = ++o % 4) 0 != e && r.push((n.indexOf(t.charAt(o - 1)) & Math.pow(2, -2 * e + 8) - 1) << 2 * e | n.indexOf(t.charAt(o)) >>> 6 - 2 * e);
return r;
}
};
t.exports = r;
}();
}, function (t, n) {
function r(t) {
return !!t.constructor && "function" == typeof t.constructor.isBuffer && t.constructor.isBuffer(t);
}
function o(t) {
return "function" == typeof t.readFloatLE && "function" == typeof t.slice && r(t.slice(0, 0));
}
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
t.exports = function (t) {
return null != t && (r(t) || o(t) || !!t._isBuffer);
};
}, function (t, n, r) {
t.exports = r(1);
}]);
});
/***/ }),
/***/ 584:
/***/ (function(module, exports, __webpack_require__) {
/* 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/>. */
const md5 = __webpack_require__(1084);
function originalToGeneratedId(sourceId) {
if (isGeneratedId(sourceId)) {
return sourceId;
}
const lastIndex = sourceId.lastIndexOf("/originalSource");
return lastIndex !== -1 ? sourceId.slice(0, lastIndex) : "";
}
const getMd5 = memoize(url => md5(url));
function generatedToOriginalId(generatedId, url) {
return `${generatedId}/originalSource-${getMd5(url)}`;
}
function isOriginalId(id) {
return id.includes("/originalSource");
}
function isGeneratedId(id) {
return !isOriginalId(id);
}
/**
* Trims the query part or reference identifier of a URL string, if necessary.
*/
function trimUrlQuery(url) {
const length = url.length;
for (let i = 0; i < length; ++i) {
if (url[i] === "?" || url[i] === "&" || url[i] === "#") {
return url.slice(0, i);
}
}
return url;
} // Map suffix to content type.
const contentMap = {
js: "text/javascript",
jsm: "text/javascript",
mjs: "text/javascript",
ts: "text/typescript",
tsx: "text/typescript-jsx",
jsx: "text/jsx",
vue: "text/vue",
coffee: "text/coffeescript",
elm: "text/elm",
cljc: "text/x-clojure",
cljs: "text/x-clojurescript"
};
/**
* Returns the content type for the specified URL. If no specific
* content type can be determined, "text/plain" is returned.
*
* @return String
* The content type.
*/
function getContentType(url) {
url = trimUrlQuery(url);
const dot = url.lastIndexOf(".");
if (dot >= 0) {
const name = url.substring(dot + 1);
if (name in contentMap) {
return contentMap[name];
}
}
return "text/plain";
}
function memoize(func) {
const map = new Map();
return arg => {
if (map.has(arg)) {
return map.get(arg);
}
const result = func(arg);
map.set(arg, result);
return result;
};
}
module.exports = {
originalToGeneratedId,
generatedToOriginalId,
isOriginalId,
isGeneratedId,
getContentType,
contentMapForTesting: contentMap
};
/***/ }),
/***/ 708:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "originalToGeneratedId", {
enumerable: true,
get: function () {
return _utils.originalToGeneratedId;
}
});
Object.defineProperty(exports, "generatedToOriginalId", {
enumerable: true,
get: function () {
return _utils.generatedToOriginalId;
}
});
Object.defineProperty(exports, "isGeneratedId", {
enumerable: true,
get: function () {
return _utils.isGeneratedId;
}
});
Object.defineProperty(exports, "isOriginalId", {
enumerable: true,
get: function () {
return _utils.isOriginalId;
}
});
exports.default = exports.stopSourceMapWorker = exports.startSourceMapWorker = exports.getOriginalStackFrames = exports.clearSourceMaps = exports.applySourceMap = exports.getOriginalSourceText = exports.getFileGeneratedRange = exports.getGeneratedRangesForOriginal = exports.getOriginalLocations = exports.getOriginalLocation = exports.getAllGeneratedLocations = exports.getGeneratedLocation = exports.getGeneratedRanges = exports.getOriginalRanges = exports.hasOriginalURL = exports.getOriginalURLs = exports.setAssetRootURL = exports.dispatcher = void 0;
var _utils = __webpack_require__(584);
var self = _interopRequireWildcard(__webpack_require__(708));
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/* 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/>. */
const {
WorkerDispatcher
} = __webpack_require__(1059);
const dispatcher = new WorkerDispatcher();
exports.dispatcher = dispatcher;
const _getGeneratedRanges = dispatcher.task("getGeneratedRanges", {
queue: true
});
const _getGeneratedLocation = dispatcher.task("getGeneratedLocation", {
queue: true
});
const _getAllGeneratedLocations = dispatcher.task("getAllGeneratedLocations", {
queue: true
});
const _getOriginalLocation = dispatcher.task("getOriginalLocation", {
queue: true
});
const setAssetRootURL = async assetRoot => dispatcher.invoke("setAssetRootURL", assetRoot);
exports.setAssetRootURL = setAssetRootURL;
const getOriginalURLs = async generatedSource => dispatcher.invoke("getOriginalURLs", generatedSource);
exports.getOriginalURLs = getOriginalURLs;
const hasOriginalURL = async url => dispatcher.invoke("hasOriginalURL", url);
exports.hasOriginalURL = hasOriginalURL;
const getOriginalRanges = async sourceId => dispatcher.invoke("getOriginalRanges", sourceId);
exports.getOriginalRanges = getOriginalRanges;
const getGeneratedRanges = async location => _getGeneratedRanges(location);
exports.getGeneratedRanges = getGeneratedRanges;
const getGeneratedLocation = async location => _getGeneratedLocation(location);
exports.getGeneratedLocation = getGeneratedLocation;
const getAllGeneratedLocations = async location => _getAllGeneratedLocations(location);
exports.getAllGeneratedLocations = getAllGeneratedLocations;
const getOriginalLocation = async (location, options = {}) => _getOriginalLocation(location, options);
exports.getOriginalLocation = getOriginalLocation;
const getOriginalLocations = async (locations, options = {}) => dispatcher.invoke("getOriginalLocations", locations, options);
exports.getOriginalLocations = getOriginalLocations;
const getGeneratedRangesForOriginal = async (sourceId, mergeUnmappedRegions) => dispatcher.invoke("getGeneratedRangesForOriginal", sourceId, mergeUnmappedRegions);
exports.getGeneratedRangesForOriginal = getGeneratedRangesForOriginal;
const getFileGeneratedRange = async originalSourceId => dispatcher.invoke("getFileGeneratedRange", originalSourceId);
exports.getFileGeneratedRange = getFileGeneratedRange;
const getOriginalSourceText = async originalSourceId => dispatcher.invoke("getOriginalSourceText", originalSourceId);
exports.getOriginalSourceText = getOriginalSourceText;
const applySourceMap = async (generatedId, url, code, mappings) => dispatcher.invoke("applySourceMap", generatedId, url, code, mappings);
exports.applySourceMap = applySourceMap;
const clearSourceMaps = async () => dispatcher.invoke("clearSourceMaps");
exports.clearSourceMaps = clearSourceMaps;
const getOriginalStackFrames = async generatedLocation => dispatcher.invoke("getOriginalStackFrames", generatedLocation);
exports.getOriginalStackFrames = getOriginalStackFrames;
const startSourceMapWorker = (url, assetRoot) => {
dispatcher.start(url);
setAssetRootURL(assetRoot);
};
exports.startSourceMapWorker = startSourceMapWorker;
const stopSourceMapWorker = dispatcher.stop.bind(dispatcher);
exports.stopSourceMapWorker = stopSourceMapWorker;
var _default = self;
exports.default = _default;
/***/ }),
/***/ 928:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(708);
/***/ })
/******/ });
});

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

4
devtools/client/shared/vendor/moz.build поставляемый
Просмотреть файл

@ -4,6 +4,10 @@
# 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/.
DIRS += [
"source-map",
]
DevToolsModules(
'fluent-react.js',
'immutable.js',

21
devtools/client/shared/vendor/source-map/lib/moz.build поставляемый Normal file
Просмотреть файл

@ -0,0 +1,21 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
DevToolsModules(
"array-set.js",
"base64-vlq.js",
"base64.js",
"binary-search.js",
"mapping-list.js",
"mappings.wasm",
"read-wasm.js",
"source-map-consumer.js",
"source-map-generator.js",
"source-node.js",
"url.js",
"util.js",
"wasm.js",
)

Просмотреть файл

@ -5,10 +5,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += [
'assets',
"lib",
]
DevToolsModules(
'index.js',
'worker.js',
"source-map.js",
)

Просмотреть файл

@ -186,7 +186,7 @@ function waitForSourceMapWorker(hud) {
const onAvailable = ({ targetFront }) => {
if (
targetFront.url.endsWith(
"devtools/client/shared/source-map/worker.js"
"devtools/client/shared/source-map-loader/worker.js"
) &&
!seenWorkerTargets.has(targetFront)
) {

Просмотреть файл

@ -35,7 +35,7 @@ const BROWSER_BASED_DIRS = [
"resource://devtools/client/jsonview",
"resource://devtools/client/netmonitor/src/utils",
"resource://devtools/client/shared/fluent-l10n",
"resource://devtools/client/shared/source-map",
"resource://devtools/client/shared/source-map-loader",
"resource://devtools/client/shared/redux",
"resource://devtools/client/shared/vendor",
"resource://devtools/client/shared/worker-utils",

Просмотреть файл

@ -34,6 +34,7 @@ this.damp = class extends ExtensionAPI {
// Expose the window to modules loaded for DAMP.
loader.loader.globals.dampWindow = context.appWindow;
loader.loader.globals.fetch = context.appWindow.fetch;
dump("[damp-api] Retrieve the DAMP runner and start the test\n");
const { damp } = require("damp-test/damp");

Просмотреть файл

@ -20,17 +20,17 @@ const { require: browserRequire } = BrowserLoader({
baseURI: "resource://devtools/client/shared/",
window: dampWindow,
});
const sourceMap = browserRequire("devtools/client/shared/source-map/index");
const sourceMap = browserRequire(
"devtools/client/shared/source-map-loader/index"
);
const SOURCE_MAP_WORKER =
"resource://devtools/client/shared/source-map/worker.js";
const SOURCE_MAP_WORKER_ASSETS =
"resource://devtools/client/shared/source-map/assets/";
"resource://devtools/client/shared/source-map-loader/worker.js";
module.exports = async function() {
await testSetup("data:text/html,source-map");
sourceMap.startSourceMapWorker(SOURCE_MAP_WORKER, SOURCE_MAP_WORKER_ASSETS);
sourceMap.startSourceMapWorker(SOURCE_MAP_WORKER);
const fakeGeneratedSource = {
id: "fake-id",
url: