Chrome Debugger extension in VS Code will not display a html file - angularjs

I started to learn angular and created a simple project in Visual Studio and it ran fine there. It is only one html file and a separate JS file. I decided to try Visual Studio Code as this looks like a better environment to code in for front end work.
But for the life of me I cannot get the Chrome debugger to display the page.
Here is the current launch.json (tried several changes to url and webroot to no luck):
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:9222/index.html",
"webRoot": "${workspaceRoot}"
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"webRoot": "${workspaceRoot}"
}
]
}
I can get chrome to launch and connect but I get a completely blank page. I can then go to Localhost/json which gives me this:
[ {
"description": "",
"id": "2c0aed08-5bf3-4186-9ad6-9af1bc9e500c",
"title": "localhost:9222/index.html",
"type": "page",
"url": "http://localhost:9222/json"
}, {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/ccfbea86-ec75-434e-9ae0-749eba4cbf2b",
"id": "ccfbea86-ec75-434e-9ae0-749eba4cbf2b",
"title": "Chrome Media Router",
"type": "background_page",
"url": "chrome-extension://pkedcjkdefgpdelpbcmbmeomcjbeemfm/_generated_background_page.html",
"webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/ccfbea86-ec75-434e-9ae0-749eba4cbf2b"
} ]
I have no clue at this point what to try or really how to debug or look at what might be causing this. Any help or direction would be greatly appreciated.

I am not sure this is the correct answer. But changing the launch.json to include the file itself worked. I can now debug and view my pager in the browser window. Also turning on the diagnosticLogging allowed me to see the how it was doing some of the mapping.
{
"name": "Launch Chrome",
"type": "chrome",
"request": "launch",
"url": "http://localhost:9222/",
"webRoot": "${workspaceRoot}\\",
"file": "${workspaceRoot}/index.html",
"diagnosticLogging": true
}

Related

Alexa Smarthome Skill "Waiting for <Manufacturer Name>" on HVAC with retrievable set to false

I'm currently working on an Alexa Smarthome skill which can handle a multitude of device types, one of which type is an HVAC device. The server handling Skill requests is unable to handle multiple requests at a time, so instead of letting Alexa call "ReportState", I instead give it a "ChangeReport" when values change.
I'm using an Alexa.ThermostatController interface v3 capability as well as a PowerController, a TemperatureSensor, and an EndpointHealth capability to build the device. An example Discovery response looks like the following:
{
"endpointId": "12-34",
"manufacturerName": "Sample Manufacturer",
"description": "HVAC Control",
"friendlyName": "Office Test HVAC",
"additionalAttributes": {
"manufacturer": "Sample Manufacturer",
"model": "unknown",
"serialNumber": "unknown",
"firmwareVersion": "unknown",
"softwareVersion": "unknown",
"customIdentifier": "12-34"
},
"displayCategories": [
"THERMOSTAT",
"TEMPERATURE_SENSOR"
],
"cookie": {},
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
},
{
"type": "AlexaInterface",
"interface": "Alexa.EndpointHealth",
"version": "3",
"properties": {
"supported": [
{
"name": "connectivity"
}
],
"proactivelyReported": true,
"retrievable": false
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.ThermostatController",
"version": "3.1",
"properties": {
"supported": [
{
"name": "upperSetpoint"
},
{
"name": "lowerSetpoint"
},
{
"name": "thermostatMode"
}
],
"proactivelyReported": true,
"retrievable": false
},
"configuration": {
"supportedModes": [
"OFF",
"HEAT",
"COOL",
"AUTO"
]
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.TemperatureSensor",
"version": "3",
"properties": {
"supported": [
{
"name": "temperature"
}
],
"proactivelyReported": true,
"retrievable": false
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.PowerController",
"version": "3",
"properties": {
"supported": [
{
"name": "powerState"
}
],
"proactivelyReported": true,
"retrievable": false
}
}
]
}
Discovery will find the device and add it to the Alexa Home. However, when I go to the device in the app, it will not display the interface and instead say something along the lines of "Waiting for " and show a loading icon. When I go to set the thermostat by voice, such as "Set Office Test HVAC to 74 Degrees Fahrenheit", it says that the device "doesn't support that".
Does anyone know what's going on or how to fix this?
I checked the Cloudwatch logs to see if there was anything being sent from Alexa such as a ReportState directive, but could not find anything. I also tried setting a value on the thermostat to force a ChangeReport, and the ChangeReport seems to have been sent, but there's no update in the app. I have also been unable to find any errors in the Cloudwatch logs. I've checked over the responses and the Discovery message several times just to be sure, and I'm still not sure what the problem is.
I'm trying to get the HVAC device to show up in the app with the proper interface and allow users to control the device.
I had this issue with the version 3.1. I would suggest to change the version of Alexa.ThermostatController capability from 3.1 to 3.0. Also remember that the smart home capabilities used for your skill should mimic and map to physical buttons on your device.

Run bat file with npx command in visual code

I am getting this error in visual studio code:
The above error shows whenever I launch my progam due to this launch.json script:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Attach using Process Id",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}",
"justMyCode": true,
"preLaunchTask": "kill_process"
},
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true,
"preLaunchTask": "kill_process"
}
]
}
And here is my tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": "build",
"label": "tsc: build - tsconfig.json"
},
{
"label": "kill_process",
"type": "shell",
"command": ".\\script\\kill_process.bat"
}
]
}
This is the content of kill_process.bat file:
npx kill-port 8000
However, when I run the script from powershell it executes without any problem, here is the proof:
Does someone perhaps know how I can run the kill_process.bat file without any error in visual studio code?
Strangely it is now fixed but I don't know how because now I am reading this in my console in visual studio code:
* Executing task: .\script\kill_process.bat
D:\documents\leerplek\python\Wpark>npx kill-port 8000
Process on port 8000 killed
* Terminal will be reused by tasks, press any key to close it.

Enabling "justMyCode" in Visual Studio Code for React JS Code Debugging

I want to enable "justMyCode" option in Visual Studio Code to debug just my code in React. Currently when I debug debugger steps also in files like;
fmkadmapgofadopljbjfkapdkoienihi/build/injectGlobalHook.js
\\node_modules\\scheduler\\cjs\\scheduler.development.js
\\node_modules\\lottie-web\\build\\player\\lottie.js
ect...
I have already tried;
{
"version": "0.2.0",
"configurations": [
{
"name": "React",
"type": "chrome",
"request": "launch",
"justMyCode":true,
"url": "http://localhost:5173",
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides":
{
"webpack:///src*": "${webroot}/*",
},
]
},
]
}
This throws "Property justMyCode is not allowed." error.
Then I tried;
{
"version": "0.2.0",
"configurations": \[
{
"name": "React",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5173",
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides":
{
"webpack:///src*": "${webroot}/*",
},
"skipFiles": [
"${workspaceFolder}/bvars/<node_internals>/**",
"${workspaceFolder}/bvars/node_modules/**",
]
},
]
}
This seems to skip node files but this time an;
<eval>\VM4697589
file appeared as well as;
\src\client\client.ts
fmkadmapgofadopljbjfkapdkoienihi/build/injectGlobalHook.js
files ect...
How can I bypass all these system files and debug step only my code ?
Also is there a way to even not open any external files at all (including my own files) and debug only current file ?
I am quite new so sorry if these are too basic. Thank you in advance...

How to pass arguments in visual studio code for gdb debug

I want to use the arguments when I debug my C program using visual studio code. In the following example, I would like to execute the program with "-e1" as an argument. Please can you help with the correct modifications of the launch.json file?
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/prog/prog",
"args": ["-e1"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"miDebuggerPath": "/home/rafik/gdb",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
What you want is to pass arguments to the debuggee, not the debugger. Add another setup command for GDB, presumably like this:
{
// ...
"configurations": [
{
"name": "(gdb) Launch",
// ...
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set arguments to debuggee",
"text": "set args -e1",
"ignoreFailures": true
}
]
}
]
}
Disclaimer: I don't use VSC and so my answer might be wrong in details. You are invited to correct it.
It appears using 'args' is correct.
According to https://code.visualstudio.com/docs/cpp/launch-json-reference
args
JSON array of command-line arguments to pass to the program when it is launched. Example ["arg1", "arg2"]. If you are escaping characters, you will need to double escape them. For example, ["{\\\"arg1\\\": true}"] will send {"arg1": true} to your application

Chrome Extension using React limited to popover

I'm currently building a chrome extension using React. The problem is, react only runs if I clicked the popup. Also when I tried to modify the page by inserting something, it only shows in popover. Did I missed something? If I tried it in content_script, it works fine. Here's my manifest.json.
"short_name": "Extension",
"name": "My Extension",
"permissions": ["activeTab", "storage", "tabs", "*://*/*"],
"manifest_version": 2,
"version": "0.0.1",
"browser_action": {
"default_popup": "index.html",
"default_title": "My Extension"
},
"content_scripts": [
{
"run_at": "document_idle",
"matches": ["http://*/*", "https://*/*"],
"js": [
"content_script.js"
"static/js/main.js"
]
}
],
"background": {
"scripts": [""background.js"],
"persistent": false
}
}
fyi: static/js/main.js is a minified file. I modified the webpack so it will stay as main.js.

Resources