chrome-devtools-frontend 1.0.980332 → 1.0.980472

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.
@@ -87,19 +87,17 @@ export function createTokenizer(mimeType: string): (
87
87
  export const AbortTokenization = {};
88
88
 
89
89
  export function evaluatableJavaScriptSubstring(content: string): string {
90
- const tokenizer = Acorn.tokenizer(content, {ecmaVersion: ECMA_VERSION});
91
- let result = '';
92
90
  try {
91
+ const tokenizer = Acorn.tokenizer(content, {ecmaVersion: ECMA_VERSION});
93
92
  let token = tokenizer.getToken();
94
- while (token.type !== Acorn.tokTypes.eof && AcornTokenizer.punctuator(token)) {
93
+ while (AcornTokenizer.punctuator(token)) {
95
94
  token = tokenizer.getToken();
96
95
  }
97
96
 
98
97
  const startIndex = token.start;
99
- let endIndex: number = token.end;
100
- let openBracketsCounter = 0;
98
+ let endIndex = token.end;
101
99
  while (token.type !== Acorn.tokTypes.eof) {
102
- const isIdentifier = AcornTokenizer.identifier(token);
100
+ const isIdentifier = token.type === Acorn.tokTypes.name || token.type === Acorn.tokTypes.privateId;
103
101
  const isThis = AcornTokenizer.keyword(token, 'this');
104
102
  const isString = token.type === Acorn.tokTypes.string;
105
103
  if (!isThis && !isIdentifier && !isString) {
@@ -108,24 +106,35 @@ export function evaluatableJavaScriptSubstring(content: string): string {
108
106
 
109
107
  endIndex = token.end;
110
108
  token = tokenizer.getToken();
111
- while (AcornTokenizer.punctuator(token, '.[]')) {
112
- if (AcornTokenizer.punctuator(token, '[')) {
113
- openBracketsCounter++;
114
- }
115
109
 
116
- if (AcornTokenizer.punctuator(token, ']')) {
117
- endIndex = openBracketsCounter > 0 ? token.end : endIndex;
118
- openBracketsCounter--;
119
- }
110
+ while (AcornTokenizer.punctuator(token, '[')) {
111
+ let openBracketCounter = 0;
112
+ do {
113
+ if (AcornTokenizer.punctuator(token, '[')) {
114
+ ++openBracketCounter;
115
+ }
116
+ token = tokenizer.getToken();
117
+ if (AcornTokenizer.punctuator(token, ']')) {
118
+ if (--openBracketCounter === 0) {
119
+ endIndex = token.end;
120
+ token = tokenizer.getToken();
121
+ break;
122
+ }
123
+ }
124
+ } while (token.type !== Acorn.tokTypes.eof);
125
+ }
120
126
 
121
- token = tokenizer.getToken();
127
+ if (!AcornTokenizer.punctuator(token, '.')) {
128
+ break;
122
129
  }
130
+
131
+ token = tokenizer.getToken();
123
132
  }
124
- result = content.substring(startIndex, endIndex);
133
+ return content.substring(startIndex, endIndex);
125
134
  } catch (e) {
126
135
  console.error(e);
136
+ return '';
127
137
  }
128
- return result;
129
138
  }
130
139
 
131
140
  export function javaScriptIdentifiers(content: string): {
package/package.json CHANGED
@@ -54,5 +54,5 @@
54
54
  "unittest": "scripts/test/run_unittests.py --no-text-coverage",
55
55
  "watch": "third_party/node/node.py --output scripts/watch_build.js"
56
56
  },
57
- "version": "1.0.980332"
57
+ "version": "1.0.980472"
58
58
  }