зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1541631 - Part 2: Convert Source to be a generic minimal Source interface. r=jlast
Differential Revision: https://phabricator.services.mozilla.com/D42027 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
ec00db2167
Коммит
0d284b2f54
|
@ -66,7 +66,7 @@ export function createPrettySource(cx: Context, sourceId: string) {
|
|||
const url = getPrettySourceURL(source.url);
|
||||
const id = generatedToOriginalId(sourceId, url);
|
||||
|
||||
const prettySource: Source = {
|
||||
const prettySource = {
|
||||
id,
|
||||
url,
|
||||
relativeUrl: url,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import type { SourceId, Source, SourceLocation, Context } from "../../types";
|
||||
import type { PromiseAction } from "../utils/middleware/promise";
|
||||
import type { SourceBase } from "../../reducers/sources";
|
||||
|
||||
export type LoadSourceAction = PromiseAction<
|
||||
{|
|
||||
|
@ -24,12 +25,12 @@ export type SourceAction =
|
|||
| {|
|
||||
+type: "ADD_SOURCE",
|
||||
+cx: Context,
|
||||
+source: Source,
|
||||
+source: SourceBase,
|
||||
|}
|
||||
| {|
|
||||
+type: "ADD_SOURCES",
|
||||
+cx: Context,
|
||||
+sources: Array<Source>,
|
||||
+sources: Array<SourceBase>,
|
||||
|}
|
||||
| {|
|
||||
+type: "CLEAR_SOURCE_MAP_URL",
|
||||
|
|
|
@ -77,8 +77,22 @@ type SourceActorMap = { [SourceId]: Array<SourceActorId> };
|
|||
type UrlsMap = { [string]: SourceId[] };
|
||||
type PlainUrlsMap = { [string]: string[] };
|
||||
|
||||
export type SourceBase = {|
|
||||
+id: SourceId,
|
||||
+url: string,
|
||||
+sourceMapURL?: string,
|
||||
+isBlackBoxed: boolean,
|
||||
+isPrettyPrinted: boolean,
|
||||
+relativeUrl: string,
|
||||
+introductionUrl: ?string,
|
||||
+introductionType: ?string,
|
||||
+extensionName: ?string,
|
||||
+isExtension: boolean,
|
||||
+isWasm: boolean,
|
||||
|};
|
||||
|
||||
type SourceResource = Resource<{
|
||||
...Source,
|
||||
...SourceBase,
|
||||
}>;
|
||||
export type SourceResourceState = ResourceState<SourceResource>;
|
||||
|
||||
|
@ -241,7 +255,7 @@ function update(
|
|||
}
|
||||
|
||||
function resourceAsSource(r: SourceResource): Source {
|
||||
return r;
|
||||
return { ...r };
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -249,7 +263,7 @@ function resourceAsSource(r: SourceResource): Source {
|
|||
* - Add the source to the sources store
|
||||
* - Add the source URL to the urls map
|
||||
*/
|
||||
function addSources(state: SourcesState, sources: Source[]): SourcesState {
|
||||
function addSources(state: SourcesState, sources: SourceBase[]): SourcesState {
|
||||
state = {
|
||||
...state,
|
||||
content: { ...state.content },
|
||||
|
@ -353,7 +367,7 @@ function updateProjectDirectoryRoot(state: SourcesState, root: string) {
|
|||
|
||||
function updateRootRelativeValues(
|
||||
state: SourcesState,
|
||||
sources?: Array<Source>
|
||||
sources?: $ReadOnlyArray<Source>
|
||||
) {
|
||||
const ids = sources
|
||||
? sources.map(source => source.id)
|
||||
|
|
|
@ -10,7 +10,7 @@ declare var expect: (value: any) => any;
|
|||
import update, { initialSourcesState, getDisplayedSources } from "../sources";
|
||||
import { initialDebuggeeState } from "../debuggee";
|
||||
import updateSourceActors from "../source-actors";
|
||||
import type { Source, SourceActor } from "../../types";
|
||||
import type { SourceActor } from "../../types";
|
||||
import { prefs } from "../../utils/prefs";
|
||||
import { makeMockSource, mockcx } from "../../utils/test-mockup";
|
||||
import { getResourceIds } from "../../utils/resource";
|
||||
|
@ -82,7 +82,7 @@ describe("sources selectors", () => {
|
|||
sources: update(state, {
|
||||
type: "ADD_SOURCES",
|
||||
cx: mockcx,
|
||||
sources: ((mockedSources: any): Source[]),
|
||||
sources: mockedSources,
|
||||
}),
|
||||
sourceActors: undefined,
|
||||
};
|
||||
|
@ -106,7 +106,7 @@ describe("sources selectors", () => {
|
|||
sources: update(state, {
|
||||
type: "ADD_SOURCES",
|
||||
cx: mockcx,
|
||||
sources: ((mockedSources: any): Source[]),
|
||||
sources: mockedSources,
|
||||
}),
|
||||
sourceActors: undefined,
|
||||
};
|
||||
|
|
|
@ -397,7 +397,7 @@ export type SourceWithContentAndType<+Content: SourceContent> = {|
|
|||
* @static
|
||||
*/
|
||||
|
||||
export type Source = {|
|
||||
export type Source = {
|
||||
+id: SourceId,
|
||||
+url: string,
|
||||
+sourceMapURL?: string,
|
||||
|
@ -409,7 +409,7 @@ export type Source = {|
|
|||
+extensionName: ?string,
|
||||
+isExtension: boolean,
|
||||
+isWasm: boolean,
|
||||
|};
|
||||
};
|
||||
|
||||
/**
|
||||
* Script
|
||||
|
|
|
@ -27,8 +27,12 @@ import type {
|
|||
Why,
|
||||
} from "../types";
|
||||
import * as asyncValue from "./async-value";
|
||||
import type { SourceBase } from "../reducers/sources";
|
||||
|
||||
function makeMockSource(url: string = "url", id: SourceId = "source"): Source {
|
||||
function makeMockSource(
|
||||
url: string = "url",
|
||||
id: SourceId = "source"
|
||||
): SourceBase {
|
||||
return {
|
||||
id,
|
||||
url,
|
||||
|
|
Загрузка…
Ссылка в новой задаче