Skip to content

Commit eba6ed0

Browse files
committed
Add ios support
1 parent 6cb8583 commit eba6ed0

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

adapter/pathTransformer.ts

+4-22
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class PathTransformer implements IDebugTransformer {
2727
public launch(args: ILaunchRequestArgs): void {
2828
this._webRoot = utils.getAppRoot(args);
2929
this._platform = args.platform;
30+
this.inferedDeviceRoot = (this._platform === 'ios') ? 'file://' : this.inferedDeviceRoot;
3031
}
3132

3233
public attach(args: IAttachRequestArgs): void {
@@ -55,18 +56,7 @@ export class PathTransformer implements IDebugTransformer {
5556
resolve();
5657
}
5758
else if (this.inferedDeviceRoot) {
58-
utils.Logger.log(`Paths.setBP: No target url cached for client path: ${url}. Using inffered device root to set breakpoint`);
59-
60-
let inferedUrl = null;
61-
if (this._platform == "android") {
62-
inferedUrl = url.replace(this._webRoot, this.inferedDeviceRoot).replace(/\\/g, "/");
63-
}
64-
else if (this._platform === "ios") {
65-
inferedUrl = url.replace(this._webRoot, "").replace(/\\/g, "/");
66-
}
67-
else {
68-
throw new Error("Not supported platform");
69-
}
59+
let inferedUrl = url.replace(this._webRoot, this.inferedDeviceRoot).replace(/\\/g, "/");
7060

7161
//change device path if {N} core module or {N} module
7262
if (inferedUrl.indexOf("/node_modules/tns-core-modules/") != -1)
@@ -79,18 +69,10 @@ export class PathTransformer implements IDebugTransformer {
7969
}
8070

8171
//change platform specific paths
82-
if (inferedUrl.indexOf(".android.") != -1)
83-
{
84-
inferedUrl = inferedUrl.replace(".android.", ".");
85-
}
86-
else if (inferedUrl.indexOf(".ios.") != -1)
87-
{
88-
inferedUrl = inferedUrl.replace(".ios.", ".");
89-
}
72+
inferedUrl = inferedUrl.replace(`.${this._platform}.`, '.');
9073

9174
args.source.path = inferedUrl;
92-
this._pendingBreakpointsByPath.set(args.source.path, { resolve, reject, args });
93-
utils.Logger.log("resolving infered promise on path " + url);
75+
utils.Logger.log(`Paths.setBP: Resolved (by infering) ${url} to ${args.source.path}`);
9476
resolve();
9577
}
9678
else {

adapter/sourceMaps/sourceMapTransformer.ts

-12
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,8 @@ export class SourceMapTransformer implements IDebugTransformer {
4545
this._authoredPathsToMappedBPLines = new Map<string, number[]>();
4646
this._authoredPathsToMappedBPCols = new Map<string, number[]>();
4747
}
48-
49-
let stringProto: any = String.prototype;
50-
if (!stringProto.endsWith)
51-
{
52-
stringProto.endsWith = function(str)
53-
{
54-
var lastIndex = this.lastIndexOf(str);
55-
return (lastIndex !== -1) && (lastIndex + str.length === this.length);
56-
}
57-
}
5848
}
5949

60-
61-
6250
public clearTargetContext(): void {
6351
this._allRuntimeScriptPaths = new Set<string>();
6452
}

webkit/utilities.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,14 @@ export function webkitUrlToClientPath(webRoot: string, additionalFileExtension:
261261
return nsProjectFile;
262262
}
263263

264-
let shiftedParts = [];
265264
let pathParts = pathName.split(path.sep);
266265
while (pathParts.length > 0) {
267266
const clientPath = path.join(webRoot, pathParts.join(path.sep));
268267
if (existsSync(clientPath)) {
269268
return canonicalizeUrl(clientPath);
270269
}
271270

272-
let shifted = pathParts.shift();
273-
shiftedParts.push(shifted);
271+
pathParts.shift();
274272
}
275273

276274
//check for {N} android internal files

0 commit comments

Comments
 (0)