Skip to content

Commit aed850e

Browse files
authored
Merge pull request #54 from NativeScript/buhov/analytics
Google Analytics and Telerik Analytics monitoring of the extension
2 parents 08ed1c8 + f62d0bc commit aed850e

35 files changed

+811
-265
lines changed

.vscode/launch.json

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"version": "0.1.0",
3+
"configurations": [
4+
{
5+
"name": "launch as server",
6+
"type": "node",
7+
"request": "launch",
8+
"program": "${workspaceRoot}/out/debug-adapter/webKitDebug.js",
9+
"runtimeArgs": ["--nolazy"],
10+
"args": [ "--server=4712" ],
11+
"stopOnEntry": false,
12+
"sourceMaps": true,
13+
"outDir": "${workspaceRoot}/out",
14+
"cwd": "${workspaceRoot}"
15+
},
16+
{
17+
"name": "launch in extension host",
18+
"type": "extensionHost",
19+
"request": "launch",
20+
// Path to VSCode executable
21+
"runtimeExecutable": "${execPath}",
22+
"args": [
23+
"--extensionDevelopmentPath=${workspaceRoot}"
24+
],
25+
"stopOnEntry": true,
26+
"sourceMaps": true,
27+
"outDir": "${workspaceRoot}/out",
28+
"cwd": "${workspaceRoot}"
29+
},
30+
{
31+
"name": "run tests on mac",
32+
"type": "node",
33+
"request": "launch",
34+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
35+
"runtimeArgs": [ "--nolazy" ],
36+
"args": [
37+
"--opts", "${workspaceRoot}/src/tests/config/mocha.opts",
38+
"--config", "${workspaceRoot}/src/tests/config/mac.json",
39+
"${workspaceRoot}/out/tests/"
40+
],
41+
"stopOnEntry": false,
42+
"sourceMaps": true,
43+
"outDir": "${workspaceRoot}/out",
44+
"cwd": "${workspaceRoot}"
45+
},
46+
{
47+
"name": "run tests on win",
48+
"type": "node",
49+
"request": "launch",
50+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
51+
"runtimeArgs": [ "--nolazy" ],
52+
"args": [
53+
"--opts", "${workspaceRoot}/src/tests/config/mocha.opts",
54+
"--config", "${workspaceRoot}/src/tests/config/win.json",
55+
"${workspaceRoot}/out/tests/"
56+
],
57+
"stopOnEntry": false,
58+
"sourceMaps": true,
59+
"outDir": "${workspaceRoot}/out",
60+
"cwd": "${workspaceRoot}"
61+
},
62+
{
63+
"name": "run tests (custom)",
64+
"type": "node",
65+
"request": "launch",
66+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
67+
"runtimeArgs": [ "--nolazy" ],
68+
"args": [
69+
"--opts", "${workspaceRoot}/src/tests/config/mocha.opts",
70+
"--config", "${workspaceRoot}/src/tests/config/custom.json",
71+
"${workspaceRoot}/out/tests/"
72+
],
73+
"stopOnEntry": false,
74+
"sourceMaps": true,
75+
"outDir": "${workspaceRoot}/out",
76+
"cwd": "${workspaceRoot}"
77+
}
78+
]
79+
}

.vscode/settings.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"editor.insertSpaces": true,
3+
"files.trimTrailingWhitespace": true,
4+
"files.exclude": {
5+
".git": true,
6+
"bin": true,
7+
"node_modules": false
8+
},
9+
"search.exclude": {
10+
".git": true,
11+
"node_modules": true,
12+
"bin": true,
13+
"out": true
14+
}
15+
}

.vscode/tasks.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "0.1.0",
3+
"windows": {
4+
"command": ".\\node_modules\\.bin\\tsc"
5+
},
6+
"command": "./node_modules/.bin/tsc",
7+
"isShellCommand": true,
8+
"args": ["-p", "./src"],
9+
"problemMatcher": "$tsc"
10+
}

package.json

+20-6
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,48 @@
2525
],
2626
"license": "SEE LICENSE IN LICENSE.txt",
2727
"dependencies": {
28+
"node-ipc": "^7.0.0",
2829
"source-map": "^0.5.3",
29-
"vscode-debugprotocol": "^1.7.0",
30-
"vscode-debugadapter": "^1.7.0"
30+
"xmlhttprequest": "https://github.com/telerik/node-XMLHttpRequest/tarball/master",
31+
"universal-analytics": "^0.3.11",
32+
"vscode-debugadapter": "^1.7.0",
33+
"vscode-debugprotocol": "^1.7.0"
3134
},
3235
"devDependencies": {
3336
"mocha": "^2.4.5",
3437
"tslint": "^3.5.0",
3538
"typescript": "^1.8.2",
36-
"typings": "^0.7.9",
39+
"typings": "^1.0.4",
3740
"vsce": "^1.0.0",
3841
"vscode": "^0.11.x",
3942
"vscode-debugadapter-testsupport": "^1.7.0"
4043
},
4144
"scripts": {
4245
"postinstall": "node ./node_modules/vscode/bin/install && cd src && typings install",
4346
"clean": "git clean -fdx",
44-
"build": "tsc -p ./src",
47+
"build": "tsc -p ./src && cp ./src/services/analytics/EqatecMonitor.min.js ./out/services/analytics/EqatecMonitor.min.js",
4548
"package": "vsce package",
4649
"launch-as-server": "node --nolazy ./out/webkit/webKitDebug.js --server=4712",
4750
"test-mac": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/mac.json ./out/tests",
4851
"test-win": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/win.json ./out/tests",
4952
"test-custom": "mocha --opts ./src/tests/config/mocha.opts --config ../../src/tests/config/custom.json ./out/tests"
5053
},
51-
"main": "./out/nativescript/nsMain",
54+
"main": "./out/main",
5255
"activationEvents": [
5356
"*"
5457
],
5558
"contributes": {
59+
"configuration": {
60+
"type": "object",
61+
"title": "NativeScript Extension Configurations",
62+
"properties": {
63+
"nativescript.analytics.enabled": {
64+
"type": "boolean",
65+
"default": true,
66+
"description": "Enables the extension tracking."
67+
}
68+
}
69+
},
5670
"commands": [
5771
{
5872
"command": "nativescript.runIos",
@@ -87,7 +101,7 @@
87101
"typescript"
88102
]
89103
},
90-
"program": "./out/webkit/webKitDebug.js",
104+
"program": "./out/debug-adapter/webKitDebug.js",
91105
"runtime": "node",
92106
"initialConfigurations": [
93107
{

src/.vscode/launch.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "launch as server",
66
"type": "node",
77
"request": "launch",
8-
"program": "${workspaceRoot}/../out/webkit/webKitDebug.js",
8+
"program": "${workspaceRoot}/../out/debug-adapter/webKitDebug.js",
99
"runtimeArgs": ["--nolazy"],
1010
"args": [ "--server=4712" ],
1111
"stopOnEntry": true,
@@ -20,7 +20,7 @@
2020
// Path to VSCode executable
2121
"runtimeExecutable": "${execPath}",
2222
"args": [
23-
"--extensionDevelopmentPath=${workspaceRoot}"
23+
"--extensionDevelopmentPath=${workspaceRoot}/.."
2424
],
2525
"stopOnEntry": false,
2626
"sourceMaps": true,

src/common/Version.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export class Version {
2+
public static parse(versionStr: string): number[] {
3+
if (versionStr === null) {
4+
return null;
5+
}
6+
let version: number[] = versionStr.split('.').map<number>((str, index, array) => parseInt(str));
7+
for(let i = version.length; i < 3; i++) {
8+
version.push(0);
9+
}
10+
return version;
11+
}
12+
13+
public static stringify(version: number[]): string {
14+
return `${version[0]}.${version[1]}.${version[2]}`;
15+
}
16+
17+
public static compareBySubminor(v1, v2): number {
18+
return (v1[0] - v2[0] != 0) ? (v1[0] - v2[0]) : (v1[1] - v2[1] != 0) ? v1[1] - v2[1] : v1[2] - v2[2];
19+
}
20+
}

src/adapter/adapterProxy.ts renamed to src/debug-adapter/adapter/adapterProxy.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import * as utils from '../webkit/utilities';
5+
import * as utils from '../utilities';
66
import {DebugProtocol} from 'vscode-debugprotocol';
7-
import {IDebugTransformer, IDebugAdapter} from '../webkit/WebKitAdapterInterfaces';
7+
import {IDebugTransformer, IDebugAdapter} from '../WebKitAdapterInterfaces';
88

99
export type EventHandler = (event: DebugProtocol.Event) => void;
1010

src/adapter/lineNumberTransformer.ts renamed to src/debug-adapter/adapter/lineNumberTransformer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*--------------------------------------------------------*/
44

55
import {DebugProtocol} from 'vscode-debugprotocol';
6-
import {IDebugTransformer, ISetBreakpointsResponseBody, IStackTraceResponseBody} from '../webkit/WebKitAdapterInterfaces';
6+
import {IDebugTransformer, ISetBreakpointsResponseBody, IStackTraceResponseBody} from '../WebKitAdapterInterfaces';
77

88
/**
99
* Converts from 1 based lines on the client side to 0 based lines on the target side

src/adapter/pathTransformer.ts renamed to src/debug-adapter/adapter/pathTransformer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5-
import * as utils from '../webkit/utilities';
5+
import * as utils from '../utilities';
66
import {DebugProtocol} from 'vscode-debugprotocol';
77
import * as path from 'path';
8-
import {ISetBreakpointsArgs, IDebugTransformer, ILaunchRequestArgs, IAttachRequestArgs, IStackTraceResponseBody} from '../webkit/WebKitAdapterInterfaces';
8+
import {ISetBreakpointsArgs, IDebugTransformer, ILaunchRequestArgs, IAttachRequestArgs, IStackTraceResponseBody} from '../WebKitAdapterInterfaces';
99

1010
interface IPendingBreakpoint {
1111
resolve: () => void;

src/adapter/sourceMaps/pathUtilities.ts renamed to src/debug-adapter/adapter/sourceMaps/pathUtilities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import * as Path from 'path';
88
import * as URL from 'url';
99

10-
import * as utils from '../../webkit/utilities';
10+
import * as utils from '../../utilities';
1111

1212
export function getPathRoot(p: string) {
1313
if (p) {

src/adapter/sourceMaps/sourceMapTransformer.ts renamed to src/debug-adapter/adapter/sourceMaps/sourceMapTransformer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import * as path from 'path';
66
import * as fs from 'fs';
77
import {DebugProtocol} from 'vscode-debugprotocol';
88
import {ISourceMaps, SourceMaps} from './sourceMaps';
9-
import {ISetBreakpointsArgs, IDebugTransformer, ILaunchRequestArgs, IAttachRequestArgs, ISetBreakpointsResponseBody, IStackTraceResponseBody} from '../../webkit/WebKitAdapterInterfaces';
10-
import * as utils from '../../webkit/utilities';
9+
import {ISetBreakpointsArgs, IDebugTransformer, ILaunchRequestArgs, IAttachRequestArgs, ISetBreakpointsResponseBody, IStackTraceResponseBody} from '../../WebKitAdapterInterfaces';
10+
import * as utils from '../../utilities';
1111

1212
interface IPendingBreakpoint {
1313
resolve: () => void;

src/adapter/sourceMaps/sourceMaps.ts renamed to src/debug-adapter/adapter/sourceMaps/sourceMaps.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import * as URL from 'url';
99
import * as FS from 'fs';
1010
import {SourceMapConsumer} from 'source-map';
1111
import * as PathUtils from './pathUtilities';
12-
import * as utils from '../../webkit/utilities';
13-
import {Logger} from '../../webkit/utilities';
12+
import * as utils from '../../utilities';
13+
import {Logger} from '../../utilities';
1414

1515

1616
export interface MappingResult {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export interface INSDebugConnection {
2+
on(eventName: string, handler: (msg: any) => void): void;
3+
4+
close(): void;
5+
6+
debugger_setBreakpointByUrl(url: string, lineNumber: number, columnNumber: number, condition?: string): Promise<WebKitProtocol.Debugger.SetBreakpointByUrlResponse>
7+
8+
debugger_removeBreakpoint(breakpointId: string): Promise<WebKitProtocol.Response>
9+
10+
debugger_stepOver(): Promise<WebKitProtocol.Response>;
11+
12+
debugger_stepIn(): Promise<WebKitProtocol.Response>;
13+
14+
debugger_stepOut(): Promise<WebKitProtocol.Response>;
15+
16+
debugger_resume(): Promise<WebKitProtocol.Response>;
17+
18+
debugger_pause(): Promise<WebKitProtocol.Response>;
19+
20+
debugger_evaluateOnCallFrame(callFrameId: string, expression: string, objectGroup?, returnByValue?: boolean): Promise<WebKitProtocol.Debugger.EvaluateOnCallFrameResponse>;
21+
22+
debugger_setPauseOnExceptions(state: string): Promise<WebKitProtocol.Response>;
23+
24+
debugger_getScriptSource(scriptId: WebKitProtocol.Debugger.ScriptId): Promise<WebKitProtocol.Debugger.GetScriptSourceResponse>;
25+
26+
runtime_getProperties(objectId: string, ownProperties: boolean, accessorPropertiesOnly: boolean): Promise<WebKitProtocol.Runtime.GetPropertiesResponse>;
27+
28+
runtime_evaluate(expression: string, objectGroup?: any, contextId?: number, returnByValue?: boolean): Promise<WebKitProtocol.Runtime.EvaluateResponse>;
29+
}

src/nativescript/android/androidDebugConnection.ts renamed to src/debug-adapter/connection/androidConnection.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as http from 'http';
22
import {EventEmitter} from 'events';
3-
import * as utils from '../../webkit/utilities';
4-
import {Logger} from '../../webkit/utilities';
3+
import * as utils from '../utilities';
4+
import {Logger} from '../utilities';
55
import * as Net from 'net';
6-
import * as ns from '../nativescript'
6+
import * as ns from '../../services/NsCliService';
7+
import { INSDebugConnection } from './INSDebugConnection';
78

89

910
interface IMessageWithId {
@@ -39,7 +40,6 @@ class Callbacks {
3940

4041
}
4142

42-
4343
class ResReqNetSocket extends EventEmitter {
4444
private _pendingRequests = new Map<number, any>();
4545

@@ -213,7 +213,7 @@ class ResReqNetSocket extends EventEmitter {
213213
}
214214

215215

216-
export class AndroidDebugConnection implements ns.INSDebugConnection {
216+
export class AndroidConnection implements INSDebugConnection {
217217
private _nextId = 1;
218218
//private _socket: ResReqWebSocket;
219219
//private _socket: ResReqHttpSocket;

src/webkit/webKitConnection.ts renamed to src/debug-adapter/connection/iosConnection.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import * as net from 'net';
66
import * as stream from 'stream';
77
import {EventEmitter} from 'events';
8-
import * as utils from './utilities';
9-
import {Logger} from './utilities';
10-
import * as ns from '../nativescript/nativescript';
8+
import {INSDebugConnection} from './INSDebugConnection';
9+
import * as utils from '../utilities';
10+
import {Logger} from '../utilities';
11+
import * as ns from '../../services/NsCliService';
1112

1213
interface IMessageWithId {
1314
id: number;
@@ -139,7 +140,7 @@ class ResReqTcpSocket extends EventEmitter {
139140
/**
140141
* Connects to a target supporting the webkit protocol and sends and receives messages
141142
*/
142-
export class WebKitConnection implements ns.INSDebugConnection {
143+
export class IosConnection implements INSDebugConnection {
143144
private _nextId = 1;
144145
private _socket: ResReqTcpSocket;
145146

File renamed without changes.

src/webkit/utilities.ts renamed to src/debug-adapter/utilities.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
* Copyright (C) Microsoft Corporation. All rights reserved.
33
*--------------------------------------------------------*/
44

5+
// TODO: Some functions can be moved to common.
6+
57
import * as http from 'http';
68
import * as os from 'os';
79
import * as fs from 'fs';
810
import * as url from 'url';
911
import * as path from 'path';
10-
import {ILaunchRequestArgs, IAttachRequestArgs} from '../webkit/WebKitAdapterInterfaces';
12+
import {ILaunchRequestArgs, IAttachRequestArgs} from './WebKitAdapterInterfaces';
1113

1214
const DEFAULT_CHROME_PATH = {
1315
OSX: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
File renamed without changes.

0 commit comments

Comments
 (0)