nativescript 9.0.6-rc.2 → 9.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/.d.ts +0 -2
- package/lib/bootstrap.js +0 -1
- package/lib/controllers/run-controller.js +1 -3
- package/lib/helpers/livesync-command-helper.js +1 -13
- package/lib/services/bundler/bundler-compiler-service.js +1 -6
- package/package.json +1 -1
- package/lib/definitions/devtools-host-service.d.ts +0 -44
- package/lib/services/devtools-host-service.js +0 -178
package/lib/.d.ts
CHANGED
|
@@ -256,7 +256,6 @@
|
|
|
256
256
|
/// <reference path="definitions/data.d.ts" />
|
|
257
257
|
/// <reference path="definitions/debug.d.ts" />
|
|
258
258
|
/// <reference path="definitions/deploy.d.ts" />
|
|
259
|
-
/// <reference path="definitions/devtools-host-service.d.ts" />
|
|
260
259
|
/// <reference path="definitions/file-log-service.d.ts" />
|
|
261
260
|
/// <reference path="definitions/files-hash-service.d.ts" />
|
|
262
261
|
/// <reference path="definitions/gradle.d.ts" />
|
|
@@ -357,7 +356,6 @@
|
|
|
357
356
|
/// <reference path="services/debug-data-service.ts" />
|
|
358
357
|
/// <reference path="services/debug-service-base.ts" />
|
|
359
358
|
/// <reference path="services/device/device-install-app-service.ts" />
|
|
360
|
-
/// <reference path="services/devtools-host-service.ts" />
|
|
361
359
|
/// <reference path="services/doctor-service.ts" />
|
|
362
360
|
/// <reference path="services/extensibility-service.ts" />
|
|
363
361
|
/// <reference path="services/files-hash-service.ts" />
|
package/lib/bootstrap.js
CHANGED
|
@@ -191,7 +191,6 @@ yok_1.injector.require("testInitializationService", "./services/test-initializat
|
|
|
191
191
|
yok_1.injector.require("networkConnectivityValidator", "./helpers/network-connectivity-validator");
|
|
192
192
|
yok_1.injector.requirePublic("cleanupService", "./services/cleanup-service");
|
|
193
193
|
yok_1.injector.require("bundlerCompilerService", "./services/bundler/bundler-compiler-service");
|
|
194
|
-
yok_1.injector.require("devtoolsHostService", "./services/devtools-host-service");
|
|
195
194
|
yok_1.injector.require("applePortalSessionService", "./services/apple-portal/apple-portal-session-service");
|
|
196
195
|
yok_1.injector.require("applePortalCookieService", "./services/apple-portal/apple-portal-cookie-service");
|
|
197
196
|
yok_1.injector.require("applePortalApplicationService", "./services/apple-portal/apple-portal-application-service");
|
|
@@ -15,7 +15,7 @@ const util = require("util");
|
|
|
15
15
|
const _ = require("lodash");
|
|
16
16
|
const yok_1 = require("../common/yok");
|
|
17
17
|
class RunController extends events_1.EventEmitter {
|
|
18
|
-
constructor($analyticsService, $buildController, $debugController, $deviceInstallAppService, $devicesService, $errors, $injector, $hmrStatusService, $hooksService, $liveSyncServiceResolver, $liveSyncProcessDataService, $logger, $mobileHelper, $platformsDataService, $pluginsService, $prepareController, $prepareDataService, $prepareNativePlatformService, $projectChangesService, $projectDataService
|
|
18
|
+
constructor($analyticsService, $buildController, $debugController, $deviceInstallAppService, $devicesService, $errors, $injector, $hmrStatusService, $hooksService, $liveSyncServiceResolver, $liveSyncProcessDataService, $logger, $mobileHelper, $platformsDataService, $pluginsService, $prepareController, $prepareDataService, $prepareNativePlatformService, $projectChangesService, $projectDataService) {
|
|
19
19
|
super();
|
|
20
20
|
this.$analyticsService = $analyticsService;
|
|
21
21
|
this.$buildController = $buildController;
|
|
@@ -37,7 +37,6 @@ class RunController extends events_1.EventEmitter {
|
|
|
37
37
|
this.$prepareNativePlatformService = $prepareNativePlatformService;
|
|
38
38
|
this.$projectChangesService = $projectChangesService;
|
|
39
39
|
this.$projectDataService = $projectDataService;
|
|
40
|
-
this.$devtoolsHostService = $devtoolsHostService;
|
|
41
40
|
this.prepareReadyEventHandler = null;
|
|
42
41
|
}
|
|
43
42
|
async run(runData) {
|
|
@@ -110,7 +109,6 @@ class RunController extends events_1.EventEmitter {
|
|
|
110
109
|
await liveSyncProcessInfo.actionsChain;
|
|
111
110
|
}
|
|
112
111
|
liveSyncProcessInfo.deviceDescriptors = [];
|
|
113
|
-
await this.$devtoolsHostService.stopAll();
|
|
114
112
|
if (this.prepareReadyEventHandler) {
|
|
115
113
|
this.$prepareController.removeListener(constants_2.PREPARE_READY_EVENT_NAME, this.prepareReadyEventHandler);
|
|
116
114
|
this.prepareReadyEventHandler = null;
|
|
@@ -5,7 +5,7 @@ const _ = require("lodash");
|
|
|
5
5
|
const yok_1 = require("../common/yok");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
class LiveSyncCommandHelper {
|
|
8
|
-
constructor($androidBundleValidatorHelper, $buildDataService, $projectData, $options, $deployController, $iosDeviceOperations, $mobileHelper, $devicesService, $injector, $buildController, $analyticsService, $errors, $iOSSimulatorLogProvider, $cleanupService, $runController
|
|
8
|
+
constructor($androidBundleValidatorHelper, $buildDataService, $projectData, $options, $deployController, $iosDeviceOperations, $mobileHelper, $devicesService, $injector, $buildController, $analyticsService, $errors, $iOSSimulatorLogProvider, $cleanupService, $runController) {
|
|
9
9
|
this.$androidBundleValidatorHelper = $androidBundleValidatorHelper;
|
|
10
10
|
this.$buildDataService = $buildDataService;
|
|
11
11
|
this.$projectData = $projectData;
|
|
@@ -21,7 +21,6 @@ class LiveSyncCommandHelper {
|
|
|
21
21
|
this.$iOSSimulatorLogProvider = $iOSSimulatorLogProvider;
|
|
22
22
|
this.$cleanupService = $cleanupService;
|
|
23
23
|
this.$runController = $runController;
|
|
24
|
-
this.$devtoolsHostService = $devtoolsHostService;
|
|
25
24
|
}
|
|
26
25
|
get $platformsDataService() {
|
|
27
26
|
return this.$injector.resolve("platformsDataService");
|
|
@@ -126,7 +125,6 @@ class LiveSyncCommandHelper {
|
|
|
126
125
|
return;
|
|
127
126
|
}
|
|
128
127
|
else {
|
|
129
|
-
await this.startDevtoolsHostIfDebugging(deviceDescriptors);
|
|
130
128
|
await this.$runController.run({
|
|
131
129
|
liveSyncInfo,
|
|
132
130
|
deviceDescriptors,
|
|
@@ -152,16 +150,6 @@ class LiveSyncCommandHelper {
|
|
|
152
150
|
}
|
|
153
151
|
return result;
|
|
154
152
|
}
|
|
155
|
-
async startDevtoolsHostIfDebugging(deviceDescriptors) {
|
|
156
|
-
const platforms = _.uniq(deviceDescriptors
|
|
157
|
-
.filter((d) => { var _a; return d.debuggingEnabled && ((_a = d.buildData) === null || _a === void 0 ? void 0 : _a.platform); })
|
|
158
|
-
.map((d) => d.buildData.platform.toLowerCase()));
|
|
159
|
-
for (const platform of platforms) {
|
|
160
|
-
// DevtoolsHostService swallows port/bind failures and returns null;
|
|
161
|
-
// a missing source-map origin degrades DevTools gracefully.
|
|
162
|
-
await this.$devtoolsHostService.start(this.$projectData, platform);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
153
|
async executeLiveSyncOperationCore(devices, platform, additionalOptions) {
|
|
166
154
|
if (!devices || !devices.length) {
|
|
167
155
|
if (platform) {
|
|
@@ -19,7 +19,7 @@ const package_path_helper_1 = require("../../helpers/package-path-helper");
|
|
|
19
19
|
const debugLog = false;
|
|
20
20
|
class BundlerCompilerService extends events_1.EventEmitter {
|
|
21
21
|
constructor($options, $errors, $childProcess, $fs, $hooksService, $hostInfo, $logger, $mobileHelper, $cleanupService, $packageManager, $packageInstallationManager, // private $sharedEventBus: ISharedEventBus
|
|
22
|
-
$projectConfigService
|
|
22
|
+
$projectConfigService) {
|
|
23
23
|
super();
|
|
24
24
|
this.$options = $options;
|
|
25
25
|
this.$errors = $errors;
|
|
@@ -33,7 +33,6 @@ class BundlerCompilerService extends events_1.EventEmitter {
|
|
|
33
33
|
this.$packageManager = $packageManager;
|
|
34
34
|
this.$packageInstallationManager = $packageInstallationManager;
|
|
35
35
|
this.$projectConfigService = $projectConfigService;
|
|
36
|
-
this.$devtoolsHostService = $devtoolsHostService;
|
|
37
36
|
this.bundlerProcesses = {};
|
|
38
37
|
this.expectedHashes = {};
|
|
39
38
|
}
|
|
@@ -363,10 +362,6 @@ class BundlerCompilerService extends events_1.EventEmitter {
|
|
|
363
362
|
if (prepareData.uniqueBundle > 0) {
|
|
364
363
|
envData.uniqueBundle = prepareData.uniqueBundle;
|
|
365
364
|
}
|
|
366
|
-
const devtoolsOrigin = this.$devtoolsHostService.getOrigin(platform);
|
|
367
|
-
if (devtoolsOrigin) {
|
|
368
|
-
envData.devtoolsHost = devtoolsOrigin;
|
|
369
|
-
}
|
|
370
365
|
return envData;
|
|
371
366
|
}
|
|
372
367
|
async buildEnvCommandLineParams(envData, platformData, projectData, prepareData) {
|
package/package.json
CHANGED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { IProjectData } from "./project";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Origin of a running loopback HTTP server for a single platform,
|
|
5
|
-
* e.g. "http://127.0.0.1:41500".
|
|
6
|
-
*/
|
|
7
|
-
export interface IDevtoolsHostOrigin {
|
|
8
|
-
platform: string;
|
|
9
|
-
origin: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Loopback HTTP server (per platform) that serves the webpack output
|
|
14
|
-
* directory with CORS so Chrome DevTools (served from
|
|
15
|
-
* https://chrome-devtools-frontend.appspot.com) can fetch .map / .js
|
|
16
|
-
* files while a debug session is active.
|
|
17
|
-
*
|
|
18
|
-
* Bound to 127.0.0.1 only; never exposed to the network.
|
|
19
|
-
*/
|
|
20
|
-
export interface IDevtoolsHostService {
|
|
21
|
-
/**
|
|
22
|
-
* Start (or return existing) HTTP server for a platform. Idempotent
|
|
23
|
-
* per platform — subsequent calls return the same origin.
|
|
24
|
-
*/
|
|
25
|
-
start(
|
|
26
|
-
projectData: IProjectData,
|
|
27
|
-
platform: string,
|
|
28
|
-
): Promise<IDevtoolsHostOrigin | null>;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Stop the server for a single platform. Quiet no-op if nothing running.
|
|
32
|
-
*/
|
|
33
|
-
stop(platform: string): Promise<void>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Stop all running servers.
|
|
37
|
-
*/
|
|
38
|
-
stopAll(): Promise<void>;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Current origin for a platform, or null if not running.
|
|
42
|
-
*/
|
|
43
|
-
getOrigin(platform: string): string | null;
|
|
44
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DevtoolsHostService = void 0;
|
|
4
|
-
const http = require("http");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const constants_1 = require("../constants");
|
|
8
|
-
const yok_1 = require("../common/yok");
|
|
9
|
-
const LOOPBACK_HOST = "127.0.0.1";
|
|
10
|
-
const PORT_RANGE_START = 41500;
|
|
11
|
-
const PORT_RANGE_END = 41999;
|
|
12
|
-
// Allowed Chrome DevTools origins. Bundled DevTools (devtools://devtools)
|
|
13
|
-
// is the default flow opened by chrome://inspect; the appspot frontend is
|
|
14
|
-
// used when the CLI prints a hosted URL. Any other origin (including
|
|
15
|
-
// custom NS DevTools forks) gets a permissive ACAO since loopback bind
|
|
16
|
-
// is the real security boundary anyway.
|
|
17
|
-
const KNOWN_DEVTOOLS_ORIGINS = new Set([
|
|
18
|
-
"devtools://devtools",
|
|
19
|
-
"https://chrome-devtools-frontend.appspot.com",
|
|
20
|
-
]);
|
|
21
|
-
const CONTENT_TYPES = {
|
|
22
|
-
".map": "application/json; charset=utf-8",
|
|
23
|
-
".json": "application/json; charset=utf-8",
|
|
24
|
-
".js": "application/javascript; charset=utf-8",
|
|
25
|
-
".mjs": "application/javascript; charset=utf-8",
|
|
26
|
-
".css": "text/css; charset=utf-8",
|
|
27
|
-
};
|
|
28
|
-
class DevtoolsHostService {
|
|
29
|
-
constructor($net, $logger, $platformsDataService) {
|
|
30
|
-
this.$net = $net;
|
|
31
|
-
this.$logger = $logger;
|
|
32
|
-
this.$platformsDataService = $platformsDataService;
|
|
33
|
-
this.servers = new Map();
|
|
34
|
-
}
|
|
35
|
-
async start(projectData, platform) {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
const key = platform.toLowerCase();
|
|
38
|
-
const existing = this.servers.get(key);
|
|
39
|
-
if (existing) {
|
|
40
|
-
return { platform: key, origin: this.formatOrigin(existing.port) };
|
|
41
|
-
}
|
|
42
|
-
const platformData = this.$platformsDataService.getPlatformData(platform, projectData);
|
|
43
|
-
// Webpack writes to <appDestinationDirectoryPath>/app on both iOS
|
|
44
|
-
// (platforms/ios/<appName>/app) and Android
|
|
45
|
-
// (platforms/android/app/src/main/assets/app). Match that exactly so
|
|
46
|
-
// requests for /bundle.mjs.map resolve to the actual emitted file.
|
|
47
|
-
const rootDir = (platformData === null || platformData === void 0 ? void 0 : platformData.appDestinationDirectoryPath)
|
|
48
|
-
? path.join(platformData.appDestinationDirectoryPath, constants_1.APP_FOLDER_NAME)
|
|
49
|
-
: null;
|
|
50
|
-
if (!rootDir) {
|
|
51
|
-
this.$logger.warn(`DevTools host: unable to resolve output directory for ${platform}.`);
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
let port;
|
|
55
|
-
try {
|
|
56
|
-
port = await this.$net.getAvailablePortInRange(PORT_RANGE_START, PORT_RANGE_END);
|
|
57
|
-
}
|
|
58
|
-
catch (err) {
|
|
59
|
-
this.$logger.warn(`DevTools host: no free port in ${PORT_RANGE_START}-${PORT_RANGE_END}. Source maps will not load in Chrome DevTools. (${(err === null || err === void 0 ? void 0 : err.message) || err})`);
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
const server = http.createServer((req, res) => this.handleRequest(req, res, rootDir));
|
|
63
|
-
try {
|
|
64
|
-
await new Promise((resolve, reject) => {
|
|
65
|
-
const onError = (err) => reject(err);
|
|
66
|
-
server.once("error", onError);
|
|
67
|
-
server.listen(port, LOOPBACK_HOST, () => {
|
|
68
|
-
server.off("error", onError);
|
|
69
|
-
resolve();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
this.$logger.warn(`DevTools host: failed to bind ${LOOPBACK_HOST}:${port} (${(err === null || err === void 0 ? void 0 : err.message) || err}).`);
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
// `.unref()` so a lingering server doesn't keep the CLI process alive.
|
|
78
|
-
server.unref();
|
|
79
|
-
const actualPort = (_b = (_a = server.address()) === null || _a === void 0 ? void 0 : _a.port) !== null && _b !== void 0 ? _b : port;
|
|
80
|
-
const entry = { server, port: actualPort, rootDir };
|
|
81
|
-
this.servers.set(key, entry);
|
|
82
|
-
const origin = this.formatOrigin(actualPort);
|
|
83
|
-
this.$logger.info(`DevTools host (${platform}) serving ${rootDir} at ${origin}`);
|
|
84
|
-
return { platform: key, origin };
|
|
85
|
-
}
|
|
86
|
-
async stop(platform) {
|
|
87
|
-
const key = platform.toLowerCase();
|
|
88
|
-
const entry = this.servers.get(key);
|
|
89
|
-
if (!entry) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
this.servers.delete(key);
|
|
93
|
-
await new Promise((resolve) => {
|
|
94
|
-
entry.server.close(() => resolve());
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
async stopAll() {
|
|
98
|
-
const platforms = Array.from(this.servers.keys());
|
|
99
|
-
await Promise.all(platforms.map((p) => this.stop(p)));
|
|
100
|
-
}
|
|
101
|
-
getOrigin(platform) {
|
|
102
|
-
const entry = this.servers.get(platform.toLowerCase());
|
|
103
|
-
return entry ? this.formatOrigin(entry.port) : null;
|
|
104
|
-
}
|
|
105
|
-
formatOrigin(port) {
|
|
106
|
-
return `http://${LOOPBACK_HOST}:${port}`;
|
|
107
|
-
}
|
|
108
|
-
handleRequest(req, res, rootDir) {
|
|
109
|
-
const requestOrigin = req.headers.origin;
|
|
110
|
-
const allowOrigin = requestOrigin && KNOWN_DEVTOOLS_ORIGINS.has(requestOrigin)
|
|
111
|
-
? requestOrigin
|
|
112
|
-
: "*";
|
|
113
|
-
res.setHeader("Access-Control-Allow-Origin", allowOrigin);
|
|
114
|
-
res.setHeader("Vary", "Origin");
|
|
115
|
-
res.setHeader("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS");
|
|
116
|
-
res.setHeader("Access-Control-Allow-Headers", "*");
|
|
117
|
-
res.setHeader("Cache-Control", "no-cache");
|
|
118
|
-
if (req.method === "OPTIONS") {
|
|
119
|
-
res.writeHead(204);
|
|
120
|
-
res.end();
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
124
|
-
res.writeHead(405);
|
|
125
|
-
res.end();
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
let urlPath;
|
|
129
|
-
try {
|
|
130
|
-
urlPath = decodeURIComponent(new URL(req.url || "/", "http://x").pathname);
|
|
131
|
-
}
|
|
132
|
-
catch (_a) {
|
|
133
|
-
res.writeHead(400);
|
|
134
|
-
res.end();
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const ext = path.extname(urlPath).toLowerCase();
|
|
138
|
-
if (!CONTENT_TYPES[ext]) {
|
|
139
|
-
res.writeHead(403);
|
|
140
|
-
res.end();
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
const resolvedRoot = path.resolve(rootDir);
|
|
144
|
-
const filePath = path.resolve(resolvedRoot, "." + urlPath);
|
|
145
|
-
if (filePath !== resolvedRoot &&
|
|
146
|
-
!filePath.startsWith(resolvedRoot + path.sep)) {
|
|
147
|
-
res.writeHead(403);
|
|
148
|
-
res.end();
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
fs.stat(filePath, (statErr, stats) => {
|
|
152
|
-
if (statErr || !stats.isFile()) {
|
|
153
|
-
res.writeHead(404);
|
|
154
|
-
res.end();
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
res.setHeader("Content-Type", CONTENT_TYPES[ext]);
|
|
158
|
-
res.setHeader("Content-Length", String(stats.size));
|
|
159
|
-
if (req.method === "HEAD") {
|
|
160
|
-
res.writeHead(200);
|
|
161
|
-
res.end();
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const stream = fs.createReadStream(filePath);
|
|
165
|
-
stream.on("error", () => {
|
|
166
|
-
if (!res.headersSent) {
|
|
167
|
-
res.writeHead(500);
|
|
168
|
-
}
|
|
169
|
-
res.end();
|
|
170
|
-
});
|
|
171
|
-
res.writeHead(200);
|
|
172
|
-
stream.pipe(res);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.DevtoolsHostService = DevtoolsHostService;
|
|
177
|
-
yok_1.injector.register("devtoolsHostService", DevtoolsHostService);
|
|
178
|
-
//# sourceMappingURL=devtools-host-service.js.map
|