codecane 1.0.171 → 1.0.172
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/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +8 -8
- package/dist/client.js +13 -11
- package/dist/client.js.map +1 -1
- package/dist/code-map/tsconfig.tsbuildinfo +1 -1
- package/dist/common/actions.d.ts +140 -140
- package/dist/common/browser-actions.d.ts +44 -44
- package/dist/common/types/agent-state.d.ts +22 -22
- package/dist/common/types/message.d.ts +22 -22
- package/dist/common/util/credentials.d.ts +2 -2
- package/dist/common/util/saxy.d.ts +150 -0
- package/dist/common/util/saxy.js +474 -0
- package/dist/common/util/saxy.js.map +1 -0
- package/dist/common/util/string.d.ts +8 -0
- package/dist/common/util/string.js +11 -2
- package/dist/common/util/string.js.map +1 -1
- package/dist/common/websockets/websocket-schema.d.ts +272 -272
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/__tests__/xml-stream-parser.test.d.ts +1 -0
- package/dist/utils/__tests__/xml-stream-parser.test.js +155 -0
- package/dist/utils/__tests__/xml-stream-parser.test.js.map +1 -0
- package/dist/utils/xml-stream-parser.d.ts +19 -0
- package/dist/utils/xml-stream-parser.js +202 -0
- package/dist/utils/xml-stream-parser.js.map +1 -0
- package/package.json +1 -1
- package/dist/utils/logger.d.ts +0 -1
- package/dist/utils/logger.js +0 -46
- package/dist/utils/logger.js.map +0 -1
- package/dist/utils/process-xml-chunks.d.ts +0 -37
- package/dist/utils/process-xml-chunks.js +0 -247
- package/dist/utils/process-xml-chunks.js.map +0 -1
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Saxy = exports.parseAttrs = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This is a modified version of the Saxy library that emits text nodes immediately
|
|
6
|
+
*/
|
|
7
|
+
const readable_stream_1 = require("readable-stream");
|
|
8
|
+
const string_decoder_1 = require("string_decoder");
|
|
9
|
+
const string_1 = require("./string");
|
|
10
|
+
/**
|
|
11
|
+
* Nodes that can be found inside an XML stream.
|
|
12
|
+
*/
|
|
13
|
+
const Node = {
|
|
14
|
+
text: 'text',
|
|
15
|
+
cdata: 'cdata',
|
|
16
|
+
comment: 'comment',
|
|
17
|
+
processingInstruction: 'processinginstruction',
|
|
18
|
+
tagOpen: 'tagopen',
|
|
19
|
+
tagClose: 'tagclose',
|
|
20
|
+
// markupDeclaration: 'markupDeclaration',
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Expand a piece of XML text by replacing all XML entities by
|
|
24
|
+
* their canonical value. Ignore invalid and unknown entities.
|
|
25
|
+
*
|
|
26
|
+
* @param input A string of XML text
|
|
27
|
+
* @return The input string, expanded
|
|
28
|
+
*/
|
|
29
|
+
const parseEntities = (input) => {
|
|
30
|
+
let position = 0, next = 0;
|
|
31
|
+
const parts = [];
|
|
32
|
+
while ((next = input.indexOf('&', position)) !== -1) {
|
|
33
|
+
// remember anything there was before the entity
|
|
34
|
+
if (next > position) {
|
|
35
|
+
parts.push(input.slice(position, next));
|
|
36
|
+
}
|
|
37
|
+
const end = input.indexOf(';', next);
|
|
38
|
+
// ignore unterminated entities
|
|
39
|
+
if (end === -1) {
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
const entity = input.slice(next, end);
|
|
43
|
+
if (entity === '"') {
|
|
44
|
+
parts.push('"');
|
|
45
|
+
}
|
|
46
|
+
else if (entity === '&') {
|
|
47
|
+
parts.push('&');
|
|
48
|
+
}
|
|
49
|
+
else if (entity === '&apos') {
|
|
50
|
+
parts.push("'");
|
|
51
|
+
}
|
|
52
|
+
else if (entity === '<') {
|
|
53
|
+
parts.push('<');
|
|
54
|
+
}
|
|
55
|
+
else if (entity === '>') {
|
|
56
|
+
parts.push('>');
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// ignore unrecognized character entities
|
|
60
|
+
if (entity[1] !== '#') {
|
|
61
|
+
parts.push(entity + ';');
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// hexadecimal numeric entities
|
|
65
|
+
if (entity[2] == 'x') {
|
|
66
|
+
const value = parseInt(entity.slice(3), 16);
|
|
67
|
+
// ignore non-numeric numeric entities
|
|
68
|
+
if (isNaN(value)) {
|
|
69
|
+
parts.push(entity + ';');
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
parts.push(String.fromCharCode(value));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// decimal numeric entities
|
|
77
|
+
const value = parseInt(entity.slice(2), 10);
|
|
78
|
+
// ignore non-numeric numeric entities
|
|
79
|
+
if (isNaN(value)) {
|
|
80
|
+
parts.push(entity + ';');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
parts.push(String.fromCharCode(value));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
position = end + 1;
|
|
89
|
+
}
|
|
90
|
+
if (position < input.length) {
|
|
91
|
+
parts.push(input.slice(position));
|
|
92
|
+
}
|
|
93
|
+
return parts.join('');
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Parse a string of XML attributes to a map of attribute names to their values.
|
|
97
|
+
*
|
|
98
|
+
* @param input A string of XML attributes
|
|
99
|
+
* @throws If the string is malformed
|
|
100
|
+
* @return A map of attribute names to their values
|
|
101
|
+
*/
|
|
102
|
+
const parseAttrs = (input) => {
|
|
103
|
+
const attrs = {};
|
|
104
|
+
const end = input.length;
|
|
105
|
+
let position = 0;
|
|
106
|
+
while (position < end) {
|
|
107
|
+
// Skip all whitespace
|
|
108
|
+
if ((0, string_1.isWhitespace)(input[position])) {
|
|
109
|
+
position += 1;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
// Check that the attribute name contains valid chars
|
|
113
|
+
const startName = position;
|
|
114
|
+
while (input[position] !== '=' && position < end) {
|
|
115
|
+
if ((0, string_1.isWhitespace)(input[position])) {
|
|
116
|
+
throw new Error('Attribute names may not contain whitespace');
|
|
117
|
+
}
|
|
118
|
+
position += 1;
|
|
119
|
+
}
|
|
120
|
+
// This is XML, so we need a value for the attribute
|
|
121
|
+
if (position === end) {
|
|
122
|
+
throw new Error('Expected a value for the attribute');
|
|
123
|
+
}
|
|
124
|
+
const attrName = input.slice(startName, position);
|
|
125
|
+
position += 1;
|
|
126
|
+
const startQuote = input[position];
|
|
127
|
+
position += 1;
|
|
128
|
+
if (startQuote !== '"' && startQuote !== "'") {
|
|
129
|
+
throw new Error('Attribute values should be quoted');
|
|
130
|
+
}
|
|
131
|
+
const endQuote = input.indexOf(startQuote, position);
|
|
132
|
+
if (endQuote === -1) {
|
|
133
|
+
throw new Error('Unclosed attribute value');
|
|
134
|
+
}
|
|
135
|
+
const attrValue = input.slice(position, endQuote);
|
|
136
|
+
attrs[attrName] = attrValue;
|
|
137
|
+
position = endQuote + 1;
|
|
138
|
+
}
|
|
139
|
+
return attrs;
|
|
140
|
+
};
|
|
141
|
+
exports.parseAttrs = parseAttrs;
|
|
142
|
+
/**
|
|
143
|
+
* Find the first character in a string that matches a predicate
|
|
144
|
+
* while being outside the given delimiters.
|
|
145
|
+
*
|
|
146
|
+
* @param haystack String to search in
|
|
147
|
+
* @param predicate Checks whether a character is permissible
|
|
148
|
+
* @param [delim=''] Delimiter inside which no match should be
|
|
149
|
+
* returned. If empty, all characters are considered.
|
|
150
|
+
* @param [fromIndex=0] Start the search from this index
|
|
151
|
+
* @return Index of the first match, or -1 if no match
|
|
152
|
+
*/
|
|
153
|
+
const findIndexOutside = (haystack, predicate, delim = '', fromIndex = 0) => {
|
|
154
|
+
const length = haystack.length;
|
|
155
|
+
let index = fromIndex;
|
|
156
|
+
let inDelim = false;
|
|
157
|
+
while (index < length && (inDelim || !predicate(haystack[index]))) {
|
|
158
|
+
if (haystack[index] === delim) {
|
|
159
|
+
inDelim = !inDelim;
|
|
160
|
+
}
|
|
161
|
+
++index;
|
|
162
|
+
}
|
|
163
|
+
return index === length ? -1 : index;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Parse an XML stream and emit events corresponding
|
|
167
|
+
* to the different tokens encountered.
|
|
168
|
+
*/
|
|
169
|
+
class Saxy extends readable_stream_1.Transform {
|
|
170
|
+
_decoder;
|
|
171
|
+
_tagStack;
|
|
172
|
+
_waiting;
|
|
173
|
+
/**
|
|
174
|
+
* Parse a string of XML attributes to a map of attribute names
|
|
175
|
+
* to their values
|
|
176
|
+
*
|
|
177
|
+
* @param input A string of XML attributes
|
|
178
|
+
* @throws If the string is malformed
|
|
179
|
+
* @return A map of attribute names to their values
|
|
180
|
+
*/
|
|
181
|
+
static parseAttrs = exports.parseAttrs;
|
|
182
|
+
/**
|
|
183
|
+
* Expand a piece of XML text by replacing all XML entities
|
|
184
|
+
* by their canonical value. Ignore invalid and unknown
|
|
185
|
+
* entities
|
|
186
|
+
*
|
|
187
|
+
* @param input A string of XML text
|
|
188
|
+
* @return The input string, expanded
|
|
189
|
+
*/
|
|
190
|
+
static parseEntities = parseEntities;
|
|
191
|
+
/**
|
|
192
|
+
* Create a new parser instance.
|
|
193
|
+
*/
|
|
194
|
+
constructor() {
|
|
195
|
+
super({ decodeStrings: false });
|
|
196
|
+
// String decoder instance
|
|
197
|
+
const state = this._writableState;
|
|
198
|
+
this._decoder = new string_decoder_1.StringDecoder(state.defaultEncoding);
|
|
199
|
+
// Stack of tags that were opened up until the current cursor position
|
|
200
|
+
this._tagStack = [];
|
|
201
|
+
// Not waiting initially
|
|
202
|
+
this._waiting = null;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Handle a chunk of data written into the stream.
|
|
206
|
+
*
|
|
207
|
+
* @param chunk Chunk of data.
|
|
208
|
+
* @param encoding Encoding of the string, or 'buffer'.
|
|
209
|
+
* @param callback Called when the chunk has been parsed, with
|
|
210
|
+
* an optional error argument.
|
|
211
|
+
*/
|
|
212
|
+
_write(chunk, encoding, callback) {
|
|
213
|
+
const data = encoding === 'buffer'
|
|
214
|
+
? this._decoder.write(chunk)
|
|
215
|
+
: chunk;
|
|
216
|
+
this._parseChunk(data, callback);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Handle the end of incoming data.
|
|
220
|
+
*
|
|
221
|
+
* @param callback
|
|
222
|
+
*/
|
|
223
|
+
_final(callback) {
|
|
224
|
+
// Make sure all data has been extracted from the decoder
|
|
225
|
+
this._parseChunk(this._decoder.end(), (err) => {
|
|
226
|
+
if (err) {
|
|
227
|
+
callback(err);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
// Handle unclosed nodes
|
|
231
|
+
if (this._waiting !== null) {
|
|
232
|
+
switch (this._waiting.token) {
|
|
233
|
+
case Node.text:
|
|
234
|
+
// Text nodes are implicitly closed
|
|
235
|
+
this.emit('text', { contents: this._waiting.data });
|
|
236
|
+
break;
|
|
237
|
+
case Node.cdata:
|
|
238
|
+
callback(new Error('Unclosed CDATA section'));
|
|
239
|
+
return;
|
|
240
|
+
case Node.comment:
|
|
241
|
+
callback(new Error('Unclosed comment'));
|
|
242
|
+
return;
|
|
243
|
+
case Node.processingInstruction:
|
|
244
|
+
callback(new Error('Unclosed processing instruction'));
|
|
245
|
+
return;
|
|
246
|
+
case Node.tagOpen:
|
|
247
|
+
case Node.tagClose:
|
|
248
|
+
// We do not distinguish between unclosed opening
|
|
249
|
+
// or unclosed closing tags
|
|
250
|
+
callback(new Error('Unclosed tag'));
|
|
251
|
+
return;
|
|
252
|
+
default:
|
|
253
|
+
// Pass
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (this._tagStack.length !== 0) {
|
|
257
|
+
// callback(new Error(`Unclosed tags: ${this._tagStack.join(',')}`))
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
callback();
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Immediately parse a complete chunk of XML and close the stream.
|
|
265
|
+
*
|
|
266
|
+
* @param input Input chunk.
|
|
267
|
+
*/
|
|
268
|
+
parse(input) {
|
|
269
|
+
this.end(input);
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Put the stream into waiting mode, which means we need more data
|
|
274
|
+
* to finish parsing the current token.
|
|
275
|
+
*
|
|
276
|
+
* @param token Type of token that is being parsed.
|
|
277
|
+
* @param data Pending data.
|
|
278
|
+
*/
|
|
279
|
+
_wait(token, data) {
|
|
280
|
+
this._waiting = { token, data };
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Put the stream out of waiting mode.
|
|
284
|
+
*
|
|
285
|
+
* @return Any data that was pending.
|
|
286
|
+
*/
|
|
287
|
+
_unwait() {
|
|
288
|
+
if (this._waiting === null) {
|
|
289
|
+
return '';
|
|
290
|
+
}
|
|
291
|
+
const data = this._waiting.data;
|
|
292
|
+
this._waiting = null;
|
|
293
|
+
return data;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Handle the opening of a tag in the text stream.
|
|
297
|
+
*
|
|
298
|
+
* Push the tag into the opened tag stack and emit the
|
|
299
|
+
* corresponding event on the event emitter.
|
|
300
|
+
*
|
|
301
|
+
* @param node Information about the opened tag.
|
|
302
|
+
*/
|
|
303
|
+
_handleTagOpening(node) {
|
|
304
|
+
if (!node.isSelfClosing) {
|
|
305
|
+
this._tagStack.push(node.name);
|
|
306
|
+
}
|
|
307
|
+
this.emit(Node.tagOpen, node);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Parse a XML chunk.
|
|
311
|
+
*
|
|
312
|
+
* @private
|
|
313
|
+
* @param input A string with the chunk data.
|
|
314
|
+
* @param callback Called when the chunk has been parsed, with
|
|
315
|
+
* an optional error argument.
|
|
316
|
+
*/
|
|
317
|
+
_parseChunk(input, callback) {
|
|
318
|
+
// Use pending data if applicable and get out of waiting mode
|
|
319
|
+
input = this._unwait() + input;
|
|
320
|
+
let chunkPos = 0;
|
|
321
|
+
const end = input.length;
|
|
322
|
+
while (chunkPos < end) {
|
|
323
|
+
if (input[chunkPos] !== '<') {
|
|
324
|
+
const nextTag = input.indexOf('<', chunkPos);
|
|
325
|
+
// We read a TEXT node but there might be some
|
|
326
|
+
// more text data left, so we wait
|
|
327
|
+
if (nextTag === -1) {
|
|
328
|
+
// this._wait(Node.text, input.slice(chunkPos))
|
|
329
|
+
let chunk = input.slice(chunkPos);
|
|
330
|
+
if (this._tagStack.length === 1) {
|
|
331
|
+
// Trim whitespace for text within top level tags
|
|
332
|
+
chunk = chunk.trim();
|
|
333
|
+
}
|
|
334
|
+
if (chunk.length > 0) {
|
|
335
|
+
// NOTE (James): We changed this to emit the partial text node immediately
|
|
336
|
+
this.emit(Node.text, { contents: chunk });
|
|
337
|
+
}
|
|
338
|
+
chunkPos = end;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
// A tag follows, so we can be confident that
|
|
342
|
+
// we have all the data needed for the TEXT node
|
|
343
|
+
let chunk = input.slice(chunkPos, nextTag);
|
|
344
|
+
if (this._tagStack.length === 1) {
|
|
345
|
+
// Trim whitespace for text within top level tags
|
|
346
|
+
chunk = chunk.trim();
|
|
347
|
+
}
|
|
348
|
+
// Only emit non-whitespace text or text within a single tag (not between tags)
|
|
349
|
+
if (chunk.length > 0) {
|
|
350
|
+
this.emit(Node.text, { contents: chunk });
|
|
351
|
+
}
|
|
352
|
+
chunkPos = nextTag;
|
|
353
|
+
}
|
|
354
|
+
// Invariant: the cursor now points on the name of a tag,
|
|
355
|
+
// after an opening angled bracket
|
|
356
|
+
chunkPos += 1;
|
|
357
|
+
const nextChar = input[chunkPos];
|
|
358
|
+
// Begin a DOCTYPE, CDATA or comment section
|
|
359
|
+
if (nextChar === '!') {
|
|
360
|
+
chunkPos += 1;
|
|
361
|
+
const nextNextChar = input[chunkPos];
|
|
362
|
+
// Unclosed markup declaration section of unknown type,
|
|
363
|
+
// we need to wait for upcoming data
|
|
364
|
+
if (nextNextChar === undefined) {
|
|
365
|
+
this._wait(Node.markupDeclaration, input.slice(chunkPos - 2));
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
if (nextNextChar === '[' &&
|
|
369
|
+
'CDATA['.indexOf(input.slice(chunkPos + 1, chunkPos + 7)) > -1) {
|
|
370
|
+
chunkPos += 7;
|
|
371
|
+
const cdataClose = input.indexOf(']]>', chunkPos);
|
|
372
|
+
// Incomplete CDATA section, we need to wait for upcoming data
|
|
373
|
+
if (cdataClose === -1) {
|
|
374
|
+
this._wait(Node.cdata, input.slice(chunkPos - 9));
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
this.emit(Node.cdata, {
|
|
378
|
+
contents: input.slice(chunkPos, cdataClose),
|
|
379
|
+
});
|
|
380
|
+
chunkPos = cdataClose + 3;
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (nextNextChar === '-' &&
|
|
384
|
+
(input[chunkPos + 1] === undefined || input[chunkPos + 1] === '-')) {
|
|
385
|
+
chunkPos += 2;
|
|
386
|
+
const commentClose = input.indexOf('--', chunkPos);
|
|
387
|
+
// Incomplete comment node, we need to wait for upcoming data
|
|
388
|
+
if (commentClose === -1 || input[commentClose + 2] === undefined) {
|
|
389
|
+
this._wait(Node.comment, input.slice(chunkPos - 4));
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
if (input[commentClose + 2] !== '>') {
|
|
393
|
+
callback(new Error(`Unexpected -- inside comment: \
|
|
394
|
+
'${input.slice(chunkPos - 4)}'`));
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
this.emit(Node.comment, {
|
|
398
|
+
contents: input.slice(chunkPos, commentClose),
|
|
399
|
+
});
|
|
400
|
+
chunkPos = commentClose + 3;
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
// TODO: recognize DOCTYPEs here
|
|
404
|
+
callback(new Error('Unrecognized sequence: <!' + nextNextChar));
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (nextChar === '?') {
|
|
408
|
+
chunkPos += 1;
|
|
409
|
+
const piClose = input.indexOf('?>', chunkPos);
|
|
410
|
+
// Unclosed processing instruction, we need to wait for upcoming data
|
|
411
|
+
if (piClose === -1) {
|
|
412
|
+
this._wait(Node.processingInstruction, input.slice(chunkPos - 2));
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
415
|
+
this.emit(Node.processingInstruction, {
|
|
416
|
+
contents: input.slice(chunkPos, piClose),
|
|
417
|
+
});
|
|
418
|
+
chunkPos = piClose + 2;
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
// Recognize regular tags (< ... >)
|
|
422
|
+
const tagClose = findIndexOutside(input, (char) => char === '>', '"', chunkPos);
|
|
423
|
+
if (tagClose === -1) {
|
|
424
|
+
this._wait(Node.tagOpen, input.slice(chunkPos - 1));
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
// Check if the tag is a closing tag
|
|
428
|
+
if (input[chunkPos] === '/') {
|
|
429
|
+
const tagName = input.slice(chunkPos + 1, tagClose);
|
|
430
|
+
let stackedTagName = this._tagStack.pop();
|
|
431
|
+
while (stackedTagName !== tagName) {
|
|
432
|
+
stackedTagName = this._tagStack.pop();
|
|
433
|
+
if (stackedTagName === undefined) {
|
|
434
|
+
stackedTagName = tagName;
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
this.emit(Node.tagClose, { name: tagName });
|
|
439
|
+
chunkPos = tagClose + 1;
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
// Check if the tag is self-closing
|
|
443
|
+
const isSelfClosing = input[tagClose - 1] === '/';
|
|
444
|
+
let realTagClose = isSelfClosing ? tagClose - 1 : tagClose;
|
|
445
|
+
// Extract the tag name and attributes
|
|
446
|
+
const whitespace = input.slice(chunkPos).search(/\s/);
|
|
447
|
+
if (whitespace === -1 || whitespace >= tagClose - chunkPos) {
|
|
448
|
+
// Tag without any attribute
|
|
449
|
+
this._handleTagOpening({
|
|
450
|
+
name: input.slice(chunkPos, realTagClose),
|
|
451
|
+
attrs: '',
|
|
452
|
+
isSelfClosing,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
else if (whitespace === 0) {
|
|
456
|
+
// console.log('Tag names may not start with whitespace:', input)
|
|
457
|
+
// callback(new Error('Tag names may not start with whitespace'))
|
|
458
|
+
// return
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
// Tag with attributes
|
|
462
|
+
this._handleTagOpening({
|
|
463
|
+
name: input.slice(chunkPos, chunkPos + whitespace),
|
|
464
|
+
attrs: input.slice(chunkPos + whitespace, realTagClose),
|
|
465
|
+
isSelfClosing,
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
chunkPos = tagClose + 1;
|
|
469
|
+
}
|
|
470
|
+
callback();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
exports.Saxy = Saxy;
|
|
474
|
+
//# sourceMappingURL=saxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saxy.js","sourceRoot":"","sources":["../../src/util/saxy.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,qDAA2C;AAC3C,mDAA8C;AAC9C,qCAAuC;AA2EvC;;GAEG;AACH,MAAM,IAAI,GAAG;IACX,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,qBAAqB,EAAE,uBAAuB;IAC9C,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;IACpB,0CAA0C;CACT,CAAA;AAEnC;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,EAAE;IACtC,IAAI,QAAQ,GAAG,CAAC,EACd,IAAI,GAAG,CAAC,CAAA;IACV,MAAM,KAAK,GAAG,EAAE,CAAA;IAEhB,OAAO,CAAC,IAAI,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AE,YAAY,CAAC;oBACvD,aAAa;iBACd,CAAC,CAAA;YACJ,CAAC;YAED,QAAQ,GAAG,QAAQ,GAAG,CAAC,CAAA;QACzB,CAAC;QAED,QAAQ,EAAE,CAAA;IACZ,CAAC;;AApXH,oBAqXC"}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
export declare const truncateString: (str: string, maxLength: number) => string;
|
|
2
2
|
export declare const truncateStringWithMessage: (str: string, maxLength: number, message?: string) => string;
|
|
3
|
+
/**
|
|
4
|
+
* Check if a character is a whitespace character according
|
|
5
|
+
* to the XML spec (space, carriage return, line feed or tab)
|
|
6
|
+
*
|
|
7
|
+
* @param character Character to check
|
|
8
|
+
* @return Whether the character is whitespace or not
|
|
9
|
+
*/
|
|
10
|
+
export declare const isWhitespace: (character: string) => boolean;
|
|
3
11
|
export declare const replaceNonStandardPlaceholderComments: (content: string, replacement: string) => string;
|
|
4
12
|
export declare const randBoolFromStr: (str: string) => boolean;
|
|
5
13
|
export declare const pluralize: (count: number, word: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateCompactId = exports.transformJsonInString = exports.hasLazyEdit = exports.safeReplace = exports.ensureUrlProtocol = exports.snakeToTitleCase = exports.capitalize = exports.pluralize = exports.randBoolFromStr = exports.replaceNonStandardPlaceholderComments = exports.truncateStringWithMessage = exports.truncateString = void 0;
|
|
3
|
+
exports.generateCompactId = exports.transformJsonInString = exports.hasLazyEdit = exports.safeReplace = exports.ensureUrlProtocol = exports.snakeToTitleCase = exports.capitalize = exports.pluralize = exports.randBoolFromStr = exports.replaceNonStandardPlaceholderComments = exports.isWhitespace = exports.truncateStringWithMessage = exports.truncateString = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const truncateString = (str, maxLength) => {
|
|
6
6
|
if (str.length <= maxLength) {
|
|
@@ -15,6 +15,15 @@ const truncateStringWithMessage = (str, maxLength, message = 'TRUNCATED_DUE_TO_L
|
|
|
15
15
|
: str;
|
|
16
16
|
};
|
|
17
17
|
exports.truncateStringWithMessage = truncateStringWithMessage;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a character is a whitespace character according
|
|
20
|
+
* to the XML spec (space, carriage return, line feed or tab)
|
|
21
|
+
*
|
|
22
|
+
* @param character Character to check
|
|
23
|
+
* @return Whether the character is whitespace or not
|
|
24
|
+
*/
|
|
25
|
+
const isWhitespace = (character) => /\s/.test(character);
|
|
26
|
+
exports.isWhitespace = isWhitespace;
|
|
18
27
|
const replaceNonStandardPlaceholderComments = (content, replacement) => {
|
|
19
28
|
const commentPatterns = [
|
|
20
29
|
// JSX comments (match this first)
|
|
@@ -101,7 +110,7 @@ exports.capitalize = capitalize;
|
|
|
101
110
|
const snakeToTitleCase = (str) => {
|
|
102
111
|
return str
|
|
103
112
|
.split('_')
|
|
104
|
-
.map(word => (0, exports.capitalize)(word))
|
|
113
|
+
.map((word) => (0, exports.capitalize)(word))
|
|
105
114
|
.join(' ');
|
|
106
115
|
};
|
|
107
116
|
exports.snakeToTitleCase = snakeToTitleCase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/util/string.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;AAEvB,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE,SAAiB,EAAE,EAAE;IAC/D,IAAI,GAAG,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC5B,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAA;AACxC,CAAC,CAAA;AALY,QAAA,cAAc,kBAK1B;AAEM,MAAM,yBAAyB,GAAG,CACvC,GAAW,EACX,SAAiB,EACjB,UAAkB,yBAAyB,EAC3C,EAAE;IACF,OAAO,GAAG,CAAC,MAAM,GAAG,SAAS;QAC3B,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