currentactivity 1.0.1 → 1.0.3

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/README.md CHANGED
@@ -116,6 +116,9 @@ That's it.
116
116
 
117
117
  ## Changelog
118
118
 
119
+ * 1.0.2
120
+ * Compatible with some Samsung phones
121
+
119
122
  * 1.0.1
120
123
  * Added more options for more flexible output
121
124
 
package/build/index.js CHANGED
@@ -136,9 +136,10 @@ function printAll() {
136
136
  if (stackId != undefined) {
137
137
  const stackLines = windowLines.filter((v) => {
138
138
  const s = v.trim();
139
- return s.startsWith("*") && s.indexOf(stackId) > 0;
139
+ return ((s.startsWith("*") || s.startsWith("Activity #")) &&
140
+ s.indexOf(stackId) > 0);
140
141
  });
141
- const stacks = stackLines.map((v) => v.trim().split(" ")[3]);
142
+ const stacks = stackLines.map((v) => v.trim().split(" ").last(1));
142
143
  if (stacks[0] != currentActivity) {
143
144
  stacks.shift();
144
145
  }
@@ -298,8 +299,13 @@ function findLines(lines, target) {
298
299
  return result;
299
300
  }
300
301
  function findFirstLines(lines, target) {
301
- var _a;
302
- return (_a = findLines(lines, target).at(0)) === null || _a === void 0 ? void 0 : _a.content;
302
+ const matchedLines = findLines(lines, target);
303
+ for (const line of matchedLines) {
304
+ if (line.content.indexOf("null") < 0) {
305
+ return line.content;
306
+ }
307
+ }
308
+ return undefined;
303
309
  }
304
310
  function findFirstLineIndex(lines, target) {
305
311
  const firstLine = findLines(lines, target).at(0);
@@ -417,9 +423,10 @@ function printCurrentActivityStack() {
417
423
  if (stackId != undefined) {
418
424
  const stackLines = windowLines.filter((v) => {
419
425
  const s = v.trim();
420
- return s.startsWith("*") && s.indexOf(stackId) > 0;
426
+ return ((s.startsWith("*") || s.startsWith("Activity #")) &&
427
+ s.indexOf(stackId) > 0);
421
428
  });
422
- const stacks = stackLines.map((v) => v.trim().split(" ")[3]);
429
+ const stacks = stackLines.map((v) => v.trim().split(" ").last(1));
423
430
  if (stacks[0] != currentActivity) {
424
431
  stacks.shift();
425
432
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "currentactivity",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A command line tool to display the current activity for android.",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -38,4 +38,4 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  }
41
- }
41
+ }
package/src/index.ts CHANGED
@@ -155,9 +155,12 @@ async function printAll() {
155
155
  if (stackId != undefined) {
156
156
  const stackLines = windowLines.filter((v) => {
157
157
  const s = v.trim();
158
- return s.startsWith("*") && s.indexOf(stackId) > 0;
158
+ return (
159
+ (s.startsWith("*") || s.startsWith("Activity #")) &&
160
+ s.indexOf(stackId) > 0
161
+ );
159
162
  });
160
- const stacks = stackLines.map((v) => v.trim().split(" ")[3]);
163
+ const stacks = stackLines.map((v) => v.trim().split(" ").last(1));
161
164
  if (stacks[0] != currentActivity) {
162
165
  stacks.shift();
163
166
  }
@@ -352,7 +355,13 @@ function findFirstLines(
352
355
  lines: Array<string>,
353
356
  target: string
354
357
  ): string | undefined {
355
- return findLines(lines, target).at(0)?.content;
358
+ const matchedLines = findLines(lines, target);
359
+ for (const line of matchedLines) {
360
+ if (line.content.indexOf("null") < 0) {
361
+ return line.content;
362
+ }
363
+ }
364
+ return undefined;
356
365
  }
357
366
 
358
367
  function findFirstLineIndex(lines: Array<string>, target: string): number {
@@ -495,9 +504,12 @@ async function printCurrentActivityStack() {
495
504
  if (stackId != undefined) {
496
505
  const stackLines = windowLines.filter((v) => {
497
506
  const s = v.trim();
498
- return s.startsWith("*") && s.indexOf(stackId) > 0;
507
+ return (
508
+ (s.startsWith("*") || s.startsWith("Activity #")) &&
509
+ s.indexOf(stackId) > 0
510
+ );
499
511
  });
500
- const stacks = stackLines.map((v) => v.trim().split(" ")[3]);
512
+ const stacks = stackLines.map((v) => v.trim().split(" ").last(1));
501
513
  if (stacks[0] != currentActivity) {
502
514
  stacks.shift();
503
515
  }