ios-jsc icon indicating copy to clipboard operation
ios-jsc copied to clipboard

Chrome Dev Tools Integration

Open KristinaKoeva opened this issue 9 years ago • 3 comments

Enable the following domains

  • [x] Debugger
  • [x] Source maps
  • [x] Log/Console https://github.com/NativeScript/ios-runtime/issues/701
  • [x] Network
  • [x] CSS
  • [ ] DOM
  • [ ] Conditional Breakpoints

KristinaKoeva avatar Dec 01 '16 11:12 KristinaKoeva

Debugger Domain was implemented with these PRs https://github.com/NativeScript/ios-runtime/pull/693 https://github.com/NativeScript/nativescript-cli/pull/2248

KristinaKoeva avatar Dec 01 '16 11:12 KristinaKoeva

Proof of concept to list CSS files in the resources pane:

__registerDomainDispatcher("CSS",
    class CSSDomainDebugger {
        enable() {
            var bundlePath = NSBundle.mainBundle.bundlePath;
            var cssFilePaths = NSBundle.pathsForResourcesOfTypeInDirectory("css", NSString.pathWithComponents([bundlePath, "app"])); // TODO: Search recursively

            for (var cssFilePath of cssFilePaths) {
                var relativePath = cssFilePath.substring(bundlePath.length);
                __inspectorSendEvent(JSON.stringify({
                    "method": "CSS.styleSheetAdded",
                    "params": {
                        "header": {
                            "styleSheetId": relativePath,
                            "frameId": "NativeScriptMainFrameIdentifier",
                            "sourceURL": "file://" + relativePath,
                            "origin": "regular",
                            "title": "",
                            "disabled": false,
                            "isInline": false,
                            "startLine": 0,
                            "startColumn": 0
                        }
                    }
                }));
            }
        }

        getStyleSheetText(params) {
            var styleSheetId = params.styleSheetId;
            var absolutePath = NSString.pathWithComponents([NSBundle.mainBundle.bundlePath, styleSheetId]);
            return { "text": NSString.stringWithContentsOfFileEncodingError(absolutePath, NSUTF8StringEncoding, null).toString() };
        }
    }
);

ping @pkoleva

jasssonpet avatar Jan 16 '17 16:01 jasssonpet

Related issue https://github.com/NativeScript/ios-runtime/issues/788

pkoleva avatar Aug 18 '17 13:08 pkoleva