| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,6 @@ | |||
| 1 | - import * as application from "tns-core-modules/application"; | ||
| 1 | + console.log("####### ------ APP MODULES START ") | ||
| 2 | + | ||
| 3 | + import * as application from "tns-core-modules/application"; | ||
| 2 | 4 | import * as trace from "tns-core-modules/trace"; | |
| 3 | 5 | trace.enable(); | |
| 4 | 6 | trace.setCategories(trace.categories.concat( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,20 @@ | |||
| 1 | - import { unsetValue } from "../ui/core/properties"; | ||
| 2 | - import { ViewBase } from "../ui/core/view-base"; | ||
| 3 | - import { topmost } from "../ui/frame"; | ||
| 4 | 1 | import { getNodeById } from "./dom-node"; | |
| 5 | 2 | ||
| 3 | + // Needed for typings only | ||
| 4 | + import { ViewBase } from "../ui/core/view-base"; | ||
| 5 | + | ||
| 6 | + // Use lazy requires for core modules | ||
| 7 | + const frameTopmost = () => { return require("../ui/frame").topmost(); }; | ||
| 8 | + | ||
| 9 | + let unsetValue; | ||
| 10 | + function unsetViewValue(view, name) { | ||
| 11 | + if (!unsetValue) { | ||
| 12 | + unsetValue = require("../ui/core/properties").unsetValue; | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + view[name] = unsetValue; | ||
| 16 | + } | ||
| 17 | + | ||
| 6 | 18 | function getViewById(nodeId: number): ViewBase { | |
| 7 | 19 | const node = getNodeById(nodeId); | |
| 8 | 20 | let view; | |
@@ -14,13 +26,17 @@ function getViewById(nodeId: number): ViewBase { | |||
| 14 | 26 | } | |
| 15 | 27 | ||
| 16 | 28 | export function getDocument() { | |
| 17 | - const topMostFrame = topmost(); | ||
| 18 | - topMostFrame.ensureDomNode(); | ||
| 19 | - | ||
| 29 | + const topMostFrame = frameTopmost(); | ||
| 30 | + try { | ||
| 31 | + topMostFrame.ensureDomNode(); | ||
| 32 | + | ||
| 33 | + } catch (e) { | ||
| 34 | + console.log("ERROR in getDocument(): " + e); | ||
| 35 | + } | ||
| 20 | 36 | return topMostFrame.domNode.toObject(); | |
| 21 | 37 | } | |
| 22 | 38 | ||
| 23 | - export function getComputedStylesForNode(nodeId): Array<{ name: string, value: string}> { | ||
| 39 | + export function getComputedStylesForNode(nodeId): Array<{ name: string, value: string }> { | ||
| 24 | 40 | const view = getViewById(nodeId); | |
| 25 | 41 | if (view) { | |
| 26 | 42 | return view.domNode.getComputedProperties(); | |
@@ -60,15 +76,15 @@ export function setAttributeAsText(nodeId, text, name) { | |||
| 60 | 76 | ||
| 61 | 77 | // if attr name is being replaced with another | |
| 62 | 78 | if (name !== attrName && hasOriginalAttribute) { | |
| 63 | - view[name] = unsetValue; | ||
| 79 | + unsetViewValue(view, name); | ||
| 64 | 80 | view[attrName] = attrValue; | |
| 65 | 81 | } else { | |
| 66 | 82 | view[hasOriginalAttribute ? name : attrName] = attrValue; | |
| 67 | 83 | } | |
| 68 | 84 | } | |
| 69 | 85 | } else { | |
| 70 | 86 | // delete attribute | |
| 71 | - view[name] = unsetValue; | ||
| 87 | + unsetViewValue(view, name); | ||
| 72 | 88 | } | |
| 73 | 89 | ||
| 74 | 90 | view.domNode.loadAttributes(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,9 @@ | |||
| 1 | - import { getSetProperties, getComputedCssValues } from "../ui/core/properties"; | ||
| 2 | - import { PercentLength } from "../ui/styling/style-properties"; | ||
| 3 | - import { ViewBase } from "../ui/core/view"; | ||
| 4 | - import { Color } from "../color"; | ||
| 5 | 1 | import { CSSComputedStyleProperty } from "./css-agent"; | |
| 6 | 2 | import { InspectorEvents } from "./devtools-elements"; | |
| 7 | 3 | ||
| 4 | + // Needed for typings only | ||
| 5 | + import { ViewBase } from "../ui/core/view"; | ||
| 6 | + | ||
| 8 | 7 | const registeredDomNodes = {}; | |
| 9 | 8 | const ELEMENT_NODE_TYPE = 1; | |
| 10 | 9 | const ROOT_NODE_TYPE = 9; | |
@@ -36,12 +35,19 @@ const propertyBlacklist = [ | |||
| 36 | 35 | "nativeView" | |
| 37 | 36 | ]; | |
| 38 | 37 | ||
| 39 | - let inspectorFrontendInstance: any; | ||
| 38 | + function lazy<T>(action: () => T): () => T { | ||
| 39 | + let _value: T; | ||
| 40 | + return () => _value || (_value = action()); | ||
| 41 | + } | ||
| 42 | + const percentLengthToStringLazy = lazy<(length) => string>(() => require("../ui/styling/style-properties").PercentLength.convertToString); | ||
| 43 | + const getSetPropertiesLazy = lazy<(view: ViewBase) => [string, any][]>(() => require("../ui/core/properties").getSetProperties); | ||
| 44 | + const getComputedCssValuesLazy = lazy<(view: ViewBase) => [string, any][]>(() => require("../ui/core/properties").getComputedCssValues); | ||
| 40 | 45 | ||
| 41 | 46 | export function registerInspectorEvents(inspector: InspectorEvents) { | |
| 42 | 47 | inspectorFrontendInstance = inspector; | |
| 43 | 48 | } | |
| 44 | 49 | ||
| 50 | + let inspectorFrontendInstance: any; | ||
| 45 | 51 | function notifyInspector(callback: (inspector: InspectorEvents) => void) { | |
| 46 | 52 | if (inspectorFrontendInstance) { | |
| 47 | 53 | callback(inspectorFrontendInstance); | |
@@ -51,10 +57,8 @@ function notifyInspector(callback: (inspector: InspectorEvents) => void) { | |||
| 51 | 57 | function valueToString(value: any): string { | |
| 52 | 58 | if (typeof value === "undefined" || value === null) { | |
| 53 | 59 | return ""; | |
| 54 | - } else if (value instanceof Color) { | ||
| 55 | - return value.toString(); | ||
| 56 | 60 | } else if (typeof value === "object" && value.unit) { | |
| 57 | - return PercentLength.convertToString(value); | ||
| 61 | + return percentLengthToStringLazy()(value); | ||
| 58 | 62 | } else { | |
| 59 | 63 | return value + ""; | |
| 60 | 64 | } | |
@@ -112,7 +116,7 @@ export class DOMNode { | |||
| 112 | 116 | ||
| 113 | 117 | public loadAttributes() { | |
| 114 | 118 | this.attributes = []; | |
| 115 | - getSetProperties(this.viewRef.get()) | ||
| 119 | + getSetPropertiesLazy()(this.viewRef.get()) | ||
| 116 | 120 | .filter(propertyFilter) | |
| 117 | 121 | .forEach(pair => this.attributes.push(pair[0], pair[1] + "")); | |
| 118 | 122 | ||
@@ -182,7 +186,7 @@ export class DOMNode { | |||
| 182 | 186 | return []; | |
| 183 | 187 | } | |
| 184 | 188 | ||
| 185 | - const result = getComputedCssValues(view) | ||
| 189 | + const result = getComputedCssValuesLazy()(view) | ||
| 186 | 190 | .filter(pair => pair[0][0] !== "_") | |
| 187 | 191 | .map((pair) => { | |
| 188 | 192 | return { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,6 @@ | |||
| 1 | + console.log("Loading inspector modules..."); | ||
| 1 | 2 | require("./globals/decorators"); | |
| 2 | 3 | require("./debugger/webinspector-network"); | |
| 3 | 4 | require("./debugger/webinspector-dom"); | |
| 4 | 5 | require("./debugger/webinspector-css"); | |
| 6 | + console.log("Finished loading inspector modules."); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments