refactor: circular deps part 14

This commit is contained in:
Nathan Walker
2025-07-10 15:47:29 -07:00
parent cebc78406b
commit e7ab426ee2
87 changed files with 2667 additions and 3403 deletions

View File

@ -1,7 +1,8 @@
import { InspectorEvents } from './devtools-elements-interfaces';
import { CSSComputedStyleProperty } from './css-agent';
import { ViewBase } from '../ui/core/view-base';
import type { ViewBase } from '../ui/core/view-base';
import { PercentLength } from '../ui/styling/length-shared';
import { getSetProperties, getComputedCssValues } from '../ui/core/properties';
const ELEMENT_NODE_TYPE = 1;
const ROOT_NODE_TYPE = 9;
const propertyBlacklist = ['effectivePaddingLeft', 'effectivePaddingBottom', 'effectivePaddingRight', 'effectivePaddingTop', 'effectiveBorderTopWidth', 'effectiveBorderRightWidth', 'effectiveBorderBottomWidth', 'effectiveBorderLeftWidth', 'effectiveMinWidth', 'effectiveMinHeight', 'effectiveWidth', 'effectiveHeight', 'effectiveMarginLeft', 'effectiveMarginTop', 'effectiveMarginRight', 'effectiveMarginBottom', 'nodeName', 'nodeType', 'decodeWidth', 'decodeHeight', 'ng-reflect-items', 'domNode', 'touchListenerIsSet', 'bindingContext', 'nativeView'];
@ -10,9 +11,9 @@ function lazy<T>(action: () => T): () => T {
let _value: T;
return () => _value || (_value = action());
}
const percentLengthToStringLazy = lazy<(length) => string>(() => require('../ui/styling/style-properties').PercentLength.convertToString);
const getSetPropertiesLazy = lazy<(view: ViewBase) => [string, any][]>(() => require('../ui/core/properties').getSetProperties);
const getComputedCssValuesLazy = lazy<(view: ViewBase) => [string, any][]>(() => require('../ui/core/properties').getComputedCssValues);
const percentLengthToStringLazy = lazy<(length) => string>(() => PercentLength.convertToString);
const getSetPropertiesLazy = lazy<(view: ViewBase) => [string, any][]>(() => getSetProperties);
const getComputedCssValuesLazy = lazy<(view: ViewBase) => [string, any][]>(() => getComputedCssValues);
const registeredDomNodes = {};
export function getNodeById(id: number): DOMNode {

View File

@ -1,14 +1,13 @@
import * as inspectorCommandTypes from './InspectorBackendCommands';
const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands');
import * as inspectorCommands from './InspectorBackendCommands';
import * as debuggerDomains from '.';
import { attachCSSInspectorCommandCallbacks } from './devtools-elements';
@inspectorCommands.DomainDispatcher('CSS')
export class CSSDomainDebugger implements inspectorCommandTypes.CSSDomain.CSSDomainDispatcher {
export class CSSDomainDebugger implements inspectorCommands.CSSDomain.CSSDomainDispatcher {
private _enabled: boolean;
public events: inspectorCommandTypes.CSSDomain.CSSFrontend;
public events: inspectorCommands.CSSDomain.CSSFrontend;
public commands: any;
constructor() {
@ -46,33 +45,33 @@ export class CSSDomainDebugger implements inspectorCommandTypes.CSSDomain.CSSDom
this._enabled = false;
}
getMatchedStylesForNode(params: inspectorCommandTypes.CSSDomain.GetMatchedStylesForNodeMethodArguments): {
inlineStyle?: inspectorCommandTypes.CSSDomain.CSSStyle;
attributesStyle?: inspectorCommandTypes.CSSDomain.CSSStyle;
matchedCSSRules?: inspectorCommandTypes.CSSDomain.RuleMatch[];
pseudoElements?: inspectorCommandTypes.CSSDomain.PseudoElementMatches[];
inherited?: inspectorCommandTypes.CSSDomain.InheritedStyleEntry[];
cssKeyframesRules?: inspectorCommandTypes.CSSDomain.CSSKeyframesRule[];
getMatchedStylesForNode(params: inspectorCommands.CSSDomain.GetMatchedStylesForNodeMethodArguments): {
inlineStyle?: inspectorCommands.CSSDomain.CSSStyle;
attributesStyle?: inspectorCommands.CSSDomain.CSSStyle;
matchedCSSRules?: inspectorCommands.CSSDomain.RuleMatch[];
pseudoElements?: inspectorCommands.CSSDomain.PseudoElementMatches[];
inherited?: inspectorCommands.CSSDomain.InheritedStyleEntry[];
cssKeyframesRules?: inspectorCommands.CSSDomain.CSSKeyframesRule[];
} {
return {};
}
// Returns the styles defined inline (explicitly in the "style" attribute and implicitly, using DOM attributes) for a DOM node identified by <code>nodeId</code>.
getInlineStylesForNode(params: inspectorCommandTypes.CSSDomain.GetInlineStylesForNodeMethodArguments): {
inlineStyle?: inspectorCommandTypes.CSSDomain.CSSStyle;
attributesStyle?: inspectorCommandTypes.CSSDomain.CSSStyle;
getInlineStylesForNode(params: inspectorCommands.CSSDomain.GetInlineStylesForNodeMethodArguments): {
inlineStyle?: inspectorCommands.CSSDomain.CSSStyle;
attributesStyle?: inspectorCommands.CSSDomain.CSSStyle;
} {
return {};
}
// Returns the computed style for a DOM node identified by <code>nodeId</code>.
getComputedStyleForNode(params: inspectorCommandTypes.CSSDomain.GetComputedStyleForNodeMethodArguments): {
computedStyle: inspectorCommandTypes.CSSDomain.CSSComputedStyleProperty[];
getComputedStyleForNode(params: inspectorCommands.CSSDomain.GetComputedStyleForNodeMethodArguments): {
computedStyle: inspectorCommands.CSSDomain.CSSComputedStyleProperty[];
} {
return {
computedStyle: this.commands.getComputedStylesForNode(params.nodeId),
};
}
// Requests information about platform fonts which we used to render child TextNodes in the given node.
getPlatformFontsForNode(params: inspectorCommandTypes.CSSDomain.GetPlatformFontsForNodeMethodArguments): { fonts: inspectorCommandTypes.CSSDomain.PlatformFontUsage[] } {
getPlatformFontsForNode(params: inspectorCommands.CSSDomain.GetPlatformFontsForNodeMethodArguments): { fonts: inspectorCommands.CSSDomain.PlatformFontUsage[] } {
return {
fonts: [
{
@ -87,7 +86,7 @@ export class CSSDomainDebugger implements inspectorCommandTypes.CSSDomain.CSSDom
};
}
// Returns the current textual content and the URL for a stylesheet.
getStyleSheetText(params: inspectorCommandTypes.CSSDomain.GetStyleSheetTextMethodArguments): { text: string } {
getStyleSheetText(params: inspectorCommands.CSSDomain.GetStyleSheetTextMethodArguments): { text: string } {
return null;
}
}

View File

@ -1,14 +1,13 @@
import * as inspectorCommandTypes from './InspectorBackendCommands';
const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands');
import * as inspectorCommands from './InspectorBackendCommands';
import * as debuggerDomains from '.';
import { attachDOMInspectorEventCallbacks, attachDOMInspectorCommandCallbacks } from './devtools-elements';
@inspectorCommands.DomainDispatcher('DOM')
export class DOMDomainDebugger implements inspectorCommandTypes.DOMDomain.DOMDomainDispatcher {
export class DOMDomainDebugger implements inspectorCommands.DOMDomain.DOMDomainDispatcher {
private _enabled: boolean;
public events: inspectorCommandTypes.DOMDomain.DOMFrontend;
public events: inspectorCommands.DOMDomain.DOMFrontend;
public commands: any;
constructor() {
@ -47,41 +46,41 @@ export class DOMDomainDebugger implements inspectorCommandTypes.DOMDomain.DOMDom
this._enabled = false;
}
getDocument(): { root: inspectorCommandTypes.DOMDomain.Node } {
getDocument(): { root: inspectorCommands.DOMDomain.Node } {
const domNode = this.commands.getDocument();
return { root: domNode };
}
removeNode(params: inspectorCommandTypes.DOMDomain.RemoveNodeMethodArguments): void {
removeNode(params: inspectorCommands.DOMDomain.RemoveNodeMethodArguments): void {
this.commands.removeNode(params.nodeId);
}
setAttributeValue(params: inspectorCommandTypes.DOMDomain.SetAttributeValueMethodArguments): void {
setAttributeValue(params: inspectorCommands.DOMDomain.SetAttributeValueMethodArguments): void {
throw new Error('Method not implemented.');
}
setAttributesAsText(params: inspectorCommandTypes.DOMDomain.SetAttributesAsTextMethodArguments): void {
setAttributesAsText(params: inspectorCommands.DOMDomain.SetAttributesAsTextMethodArguments): void {
this.commands.setAttributeAsText(params.nodeId, params.text, params.name);
}
removeAttribute(params: inspectorCommandTypes.DOMDomain.RemoveAttributeMethodArguments): void {
removeAttribute(params: inspectorCommands.DOMDomain.RemoveAttributeMethodArguments): void {
throw new Error('Method not implemented.');
}
performSearch(params: inspectorCommandTypes.DOMDomain.PerformSearchMethodArguments): { searchId: string; resultCount: number } {
performSearch(params: inspectorCommands.DOMDomain.PerformSearchMethodArguments): { searchId: string; resultCount: number } {
return null;
}
getSearchResults(params: inspectorCommandTypes.DOMDomain.GetSearchResultsMethodArguments): { nodeIds: inspectorCommandTypes.DOMDomain.NodeId[] } {
getSearchResults(params: inspectorCommands.DOMDomain.GetSearchResultsMethodArguments): { nodeIds: inspectorCommands.DOMDomain.NodeId[] } {
return null;
}
discardSearchResults(params: inspectorCommandTypes.DOMDomain.DiscardSearchResultsMethodArguments): void {
discardSearchResults(params: inspectorCommands.DOMDomain.DiscardSearchResultsMethodArguments): void {
return;
}
highlightNode(params: inspectorCommandTypes.DOMDomain.HighlightNodeMethodArguments): void {
highlightNode(params: inspectorCommands.DOMDomain.HighlightNodeMethodArguments): void {
return;
}
@ -89,7 +88,7 @@ export class DOMDomainDebugger implements inspectorCommandTypes.DOMDomain.DOMDom
return;
}
resolveNode(params: inspectorCommandTypes.DOMDomain.ResolveNodeMethodArguments): { object: inspectorCommandTypes.RuntimeDomain.RemoteObject } {
resolveNode(params: inspectorCommands.DOMDomain.ResolveNodeMethodArguments): { object: inspectorCommands.RuntimeDomain.RemoteObject } {
return null;
}
}

View File

@ -1,8 +1,7 @@
import * as inspectorCommandTypes from './InspectorBackendCommands';
const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands');
import * as inspectorCommands from './InspectorBackendCommands';
import { getNativeApp } from '../application/helpers-common';
import * as debuggerDomains from '.';
const getApplicationContext = () => require('../utils/android').getApplicationContext();
declare let __inspectorSendEvent;
@ -103,7 +102,7 @@ export class Request {
}
}
public responseReceived(response: inspectorCommandTypes.NetworkDomain.Response): void {
public responseReceived(response: inspectorCommands.NetworkDomain.Response): void {
if (this._networkDomainDebugger.enabled) {
this._networkDomainDebugger.events.responseReceived(this.requestID, frameId, loaderId, __inspectorTimestamp(), <any>this.resourceType, response);
}
@ -115,7 +114,7 @@ export class Request {
}
}
public requestWillBeSent(request: inspectorCommandTypes.NetworkDomain.Request): void {
public requestWillBeSent(request: inspectorCommands.NetworkDomain.Request): void {
if (this._networkDomainDebugger.enabled) {
this._networkDomainDebugger.events.requestWillBeSent(this.requestID, frameId, loaderId, request.url, request, __inspectorTimestamp(), { type: 'Script' });
}
@ -123,9 +122,9 @@ export class Request {
}
@inspectorCommands.DomainDispatcher('Network')
export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomain.NetworkDomainDispatcher {
export class NetworkDomainDebugger implements inspectorCommands.NetworkDomain.NetworkDomainDispatcher {
private _enabled: boolean;
public events: inspectorCommandTypes.NetworkDomain.NetworkFrontend;
public events: inspectorCommands.NetworkDomain.NetworkFrontend;
constructor() {
this.events = new inspectorCommands.NetworkDomain.NetworkFrontend();
@ -164,14 +163,14 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
/**
* Specifies whether to always send extra HTTP headers with the requests from this page.
*/
setExtraHTTPHeaders(params: inspectorCommandTypes.NetworkDomain.SetExtraHTTPHeadersMethodArguments): void {
setExtraHTTPHeaders(params: inspectorCommands.NetworkDomain.SetExtraHTTPHeadersMethodArguments): void {
//
}
/**
* Returns content served for the given request.
*/
getResponseBody(params: inspectorCommandTypes.NetworkDomain.GetResponseBodyMethodArguments): { body: string; base64Encoded: boolean } {
getResponseBody(params: inspectorCommands.NetworkDomain.GetResponseBodyMethodArguments): { body: string; base64Encoded: boolean } {
const resource_data = resources_datas[params.requestId];
// java.io.ByteArrayOutputStream
const body = resource_data.hasTextContent ? resource_data.data.toString('UTF-8') : android.util.Base64.encodeToString(resource_data.data?.buf?.(), android.util.Base64.NO_WRAP);
@ -218,15 +217,15 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
/**
* Toggles ignoring cache for each request. If <code>true</code>, cache will not be used.
*/
setCacheDisabled(params: inspectorCommandTypes.NetworkDomain.SetCacheDisabledMethodArguments): void {
setCacheDisabled(params: inspectorCommands.NetworkDomain.SetCacheDisabledMethodArguments): void {
//
}
/**
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
*/
loadResource(params: inspectorCommandTypes.NetworkDomain.LoadResourceMethodArguments): { content: string; mimeType: string; status: number } {
const appPath = getApplicationContext().getFilesDir().getCanonicalPath() + '/app';
loadResource(params: inspectorCommands.NetworkDomain.LoadResourceMethodArguments): { content: string; mimeType: string; status: number } {
const appPath = (getNativeApp() as android.app.Application).getApplicationContext().getFilesDir().getCanonicalPath() + '/app';
const pathUrl = params.url.replace('file://', appPath);
const file = new java.io.File(pathUrl);
const is = file.exists() ? new java.io.FileInputStream(file) : undefined;

View File

@ -1,5 +1,4 @@
import * as inspectorCommandTypes from './InspectorBackendCommands';
const inspectorCommands: typeof inspectorCommandTypes = require('./InspectorBackendCommands');
import * as inspectorCommands from './InspectorBackendCommands';
import * as debuggerDomains from '.';
@ -102,7 +101,7 @@ export class Request {
}
}
public responseReceived(response: inspectorCommandTypes.NetworkDomain.Response): void {
public responseReceived(response: inspectorCommands.NetworkDomain.Response): void {
if (this._networkDomainDebugger.enabled) {
this._networkDomainDebugger.events.responseReceived(this.requestID, frameId, loaderId, __inspectorTimestamp(), <any>this.resourceType, response);
}
@ -114,7 +113,7 @@ export class Request {
}
}
public requestWillBeSent(request: inspectorCommandTypes.NetworkDomain.Request): void {
public requestWillBeSent(request: inspectorCommands.NetworkDomain.Request): void {
if (this._networkDomainDebugger.enabled) {
this._networkDomainDebugger.events.requestWillBeSent(this.requestID, frameId, loaderId, request.url, request, __inspectorTimestamp(), { type: 'Script' });
}
@ -122,9 +121,9 @@ export class Request {
}
@inspectorCommands.DomainDispatcher('Network')
export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomain.NetworkDomainDispatcher {
export class NetworkDomainDebugger implements inspectorCommands.NetworkDomain.NetworkDomainDispatcher {
private _enabled: boolean;
public events: inspectorCommandTypes.NetworkDomain.NetworkFrontend;
public events: inspectorCommands.NetworkDomain.NetworkFrontend;
constructor() {
this.events = new inspectorCommands.NetworkDomain.NetworkFrontend();
@ -163,14 +162,14 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
/**
* Specifies whether to always send extra HTTP headers with the requests from this page.
*/
setExtraHTTPHeaders(params: inspectorCommandTypes.NetworkDomain.SetExtraHTTPHeadersMethodArguments): void {
setExtraHTTPHeaders(params: inspectorCommands.NetworkDomain.SetExtraHTTPHeadersMethodArguments): void {
//
}
/**
* Returns content served for the given request.
*/
getResponseBody(params: inspectorCommandTypes.NetworkDomain.GetResponseBodyMethodArguments): { body: string; base64Encoded: boolean } {
getResponseBody(params: inspectorCommands.NetworkDomain.GetResponseBodyMethodArguments): { body: string; base64Encoded: boolean } {
const resource_data = resources_datas[params.requestId];
const body = resource_data.hasTextContent ? NSString.alloc().initWithDataEncoding(resource_data.data, 4).toString() : resource_data.data.base64EncodedStringWithOptions(0);
@ -217,14 +216,14 @@ export class NetworkDomainDebugger implements inspectorCommandTypes.NetworkDomai
/**
* Toggles ignoring cache for each request. If <code>true</code>, cache will not be used.
*/
setCacheDisabled(params: inspectorCommandTypes.NetworkDomain.SetCacheDisabledMethodArguments): void {
setCacheDisabled(params: inspectorCommands.NetworkDomain.SetCacheDisabledMethodArguments): void {
//
}
/**
* Loads a resource in the context of a frame on the inspected page without cross origin checks.
*/
loadResource(params: inspectorCommandTypes.NetworkDomain.LoadResourceMethodArguments): { content: string; mimeType: string; status: number } {
loadResource(params: inspectorCommands.NetworkDomain.LoadResourceMethodArguments): { content: string; mimeType: string; status: number } {
const appPath = NSBundle.mainBundle.bundlePath;
const pathUrl = params.url.replace('file://', appPath);
const fileManager = NSFileManager.defaultManager;