@wordpress/block-serialization-default-parser 4.39.0 → 4.40.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.40.0 (2023-08-16)
6
+
5
7
  ## 4.39.0 (2023-08-10)
6
8
 
7
9
  ## 4.38.0 (2023-07-20)
package/build/index.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.parse = void 0;
7
-
8
7
  /**
9
8
  * @type {string}
10
9
  */
@@ -12,18 +11,16 @@ let document;
12
11
  /**
13
12
  * @type {number}
14
13
  */
15
-
16
14
  let offset;
17
15
  /**
18
16
  * @type {ParsedBlock[]}
19
17
  */
20
-
21
18
  let output;
22
19
  /**
23
20
  * @type {ParsedFrame[]}
24
21
  */
25
-
26
22
  let stack;
23
+
27
24
  /**
28
25
  * @typedef {Object|null} Attributes
29
26
  */
@@ -95,8 +92,8 @@ let stack;
95
92
  * @since 3.8.0
96
93
  * @since 4.6.1 added optimization to prevent backtracking on attribute parsing
97
94
  */
98
-
99
95
  const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/g;
96
+
100
97
  /**
101
98
  * Constructs a block object.
102
99
  *
@@ -107,7 +104,6 @@ const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?
107
104
  * @param {string[]} innerContent
108
105
  * @return {ParsedBlock} The block object.
109
106
  */
110
-
111
107
  function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
112
108
  return {
113
109
  blockName,
@@ -117,17 +113,17 @@ function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
117
113
  innerContent
118
114
  };
119
115
  }
116
+
120
117
  /**
121
118
  * Constructs a freeform block object.
122
119
  *
123
120
  * @param {string} innerHTML
124
121
  * @return {ParsedBlock} The freeform block object.
125
122
  */
126
-
127
-
128
123
  function Freeform(innerHTML) {
129
124
  return Block(null, {}, [], innerHTML, [innerHTML]);
130
125
  }
126
+
131
127
  /**
132
128
  * Constructs a frame object.
133
129
  *
@@ -138,8 +134,6 @@ function Freeform(innerHTML) {
138
134
  * @param {number|null} leadingHtmlStart
139
135
  * @return {ParsedFrame} The frame object.
140
136
  */
141
-
142
-
143
137
  function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
144
138
  return {
145
139
  block,
@@ -149,6 +143,7 @@ function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
149
143
  leadingHtmlStart
150
144
  };
151
145
  }
146
+
152
147
  /**
153
148
  * Parser function, that converts input HTML into a block based structure.
154
149
  *
@@ -226,64 +221,58 @@ function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
226
221
  * ```
227
222
  * @return {ParsedBlock[]} A block-based representation of the input HTML.
228
223
  */
229
-
230
-
231
224
  const parse = doc => {
232
225
  document = doc;
233
226
  offset = 0;
234
227
  output = [];
235
228
  stack = [];
236
229
  tokenizer.lastIndex = 0;
237
-
238
- do {// twiddle our thumbs
230
+ do {
231
+ // twiddle our thumbs
239
232
  } while (proceed());
240
-
241
233
  return output;
242
234
  };
235
+
243
236
  /**
244
237
  * Parses the next token in the input document.
245
238
  *
246
239
  * @return {boolean} Returns true when there is more tokens to parse.
247
240
  */
248
-
249
-
250
241
  exports.parse = parse;
251
-
252
242
  function proceed() {
253
243
  const stackDepth = stack.length;
254
244
  const next = nextToken();
255
- const [tokenType, blockName, attrs, startOffset, tokenLength] = next; // We may have some HTML soup before the next block.
245
+ const [tokenType, blockName, attrs, startOffset, tokenLength] = next;
256
246
 
247
+ // We may have some HTML soup before the next block.
257
248
  const leadingHtmlStart = startOffset > offset ? offset : null;
258
-
259
249
  switch (tokenType) {
260
250
  case 'no-more-tokens':
261
251
  // If not in a block then flush output.
262
252
  if (0 === stackDepth) {
263
253
  addFreeform();
264
254
  return false;
265
- } // Otherwise we have a problem
255
+ }
256
+
257
+ // Otherwise we have a problem
266
258
  // This is an error
267
259
  // we have options
268
260
  // - treat it all as freeform text
269
261
  // - assume an implicit closer (easiest when not nesting)
270
- // For the easy case we'll assume an implicit closer.
271
-
272
262
 
263
+ // For the easy case we'll assume an implicit closer.
273
264
  if (1 === stackDepth) {
274
265
  addBlockFromStack();
275
266
  return false;
276
- } // For the nested case where it's more difficult we'll
267
+ }
268
+
269
+ // For the nested case where it's more difficult we'll
277
270
  // have to assume that multiple closers are missing
278
271
  // and so we'll collapse the whole stack piecewise.
279
-
280
-
281
272
  while (0 < stack.length) {
282
273
  addBlockFromStack();
283
274
  }
284
-
285
275
  return false;
286
-
287
276
  case 'void-block':
288
277
  // easy case is if we stumbled upon a void block
289
278
  // in the top-level of the document.
@@ -291,23 +280,20 @@ function proceed() {
291
280
  if (null !== leadingHtmlStart) {
292
281
  output.push(Freeform(document.substr(leadingHtmlStart, startOffset - leadingHtmlStart)));
293
282
  }
294
-
295
283
  output.push(Block(blockName, attrs, [], '', []));
296
284
  offset = startOffset + tokenLength;
297
285
  return true;
298
- } // Otherwise we found an inner block.
299
-
286
+ }
300
287
 
288
+ // Otherwise we found an inner block.
301
289
  addInnerBlock(Block(blockName, attrs, [], '', []), startOffset, tokenLength);
302
290
  offset = startOffset + tokenLength;
303
291
  return true;
304
-
305
292
  case 'block-opener':
306
293
  // Track all newly-opened blocks on the stack.
307
294
  stack.push(Frame(Block(blockName, attrs, [], '', []), startOffset, tokenLength, startOffset + tokenLength, leadingHtmlStart));
308
295
  offset = startOffset + tokenLength;
309
296
  return true;
310
-
311
297
  case 'block-closer':
312
298
  // If we're missing an opener we're in trouble
313
299
  // This is an error.
@@ -318,20 +304,18 @@ function proceed() {
318
304
  // - give up and close out the document.
319
305
  addFreeform();
320
306
  return false;
321
- } // If we're not nesting then this is easy - close the block.
322
-
307
+ }
323
308
 
309
+ // If we're not nesting then this is easy - close the block.
324
310
  if (1 === stackDepth) {
325
311
  addBlockFromStack(startOffset);
326
312
  offset = startOffset + tokenLength;
327
313
  return true;
328
- } // Otherwise we're nested and we have to close out the current
329
- // block and add it as a innerBlock to the parent.
330
-
314
+ }
331
315
 
332
- const stackTop =
333
- /** @type {ParsedFrame} */
334
- stack.pop();
316
+ // Otherwise we're nested and we have to close out the current
317
+ // block and add it as a innerBlock to the parent.
318
+ const stackTop = /** @type {ParsedFrame} */stack.pop();
335
319
  const html = document.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
336
320
  stackTop.block.innerHTML += html;
337
321
  stackTop.block.innerContent.push(html);
@@ -339,13 +323,13 @@ function proceed() {
339
323
  addInnerBlock(stackTop.block, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
340
324
  offset = startOffset + tokenLength;
341
325
  return true;
342
-
343
326
  default:
344
327
  // This is an error.
345
328
  addFreeform();
346
329
  return false;
347
330
  }
348
331
  }
332
+
349
333
  /**
350
334
  * Parse JSON if valid, otherwise return null
351
335
  *
@@ -356,8 +340,6 @@ function proceed() {
356
340
  * @param {string} input JSON input string to parse
357
341
  * @return {Object|null} parsed JSON if valid
358
342
  */
359
-
360
-
361
343
  function parseJSON(input) {
362
344
  try {
363
345
  return JSON.parse(input);
@@ -365,13 +347,12 @@ function parseJSON(input) {
365
347
  return null;
366
348
  }
367
349
  }
350
+
368
351
  /**
369
352
  * Finds the next token in the document.
370
353
  *
371
354
  * @return {Token} The next matched token.
372
355
  */
373
-
374
-
375
356
  function nextToken() {
376
357
  // Aye the magic
377
358
  // we're using a single RegExp to tokenize the block comment delimiters
@@ -379,55 +360,50 @@ function nextToken() {
379
360
  // block opener and a block closer is the leading `/` before `wp:` (and
380
361
  // a closer has no attributes). we can trap them both and process the
381
362
  // match back in JavaScript to see which one it was.
382
- const matches = tokenizer.exec(document); // We have no more tokens.
363
+ const matches = tokenizer.exec(document);
383
364
 
365
+ // We have no more tokens.
384
366
  if (null === matches) {
385
367
  return ['no-more-tokens', '', null, 0, 0];
386
368
  }
387
-
388
369
  const startedAt = matches.index;
389
- const [match, closerMatch, namespaceMatch, nameMatch, attrsMatch
390
- /* Internal/unused. */
391
- ,, voidMatch] = matches;
370
+ const [match, closerMatch, namespaceMatch, nameMatch, attrsMatch /* Internal/unused. */,, voidMatch] = matches;
392
371
  const length = match.length;
393
372
  const isCloser = !!closerMatch;
394
373
  const isVoid = !!voidMatch;
395
374
  const namespace = namespaceMatch || 'core/';
396
375
  const name = namespace + nameMatch;
397
376
  const hasAttrs = !!attrsMatch;
398
- const attrs = hasAttrs ? parseJSON(attrsMatch) : {}; // This state isn't allowed
399
- // This is an error.
377
+ const attrs = hasAttrs ? parseJSON(attrsMatch) : {};
400
378
 
401
- if (isCloser && (isVoid || hasAttrs)) {// We can ignore them since they don't hurt anything
379
+ // This state isn't allowed
380
+ // This is an error.
381
+ if (isCloser && (isVoid || hasAttrs)) {
382
+ // We can ignore them since they don't hurt anything
402
383
  // we may warn against this at some point or reject it.
403
384
  }
404
-
405
385
  if (isVoid) {
406
386
  return ['void-block', name, attrs, startedAt, length];
407
387
  }
408
-
409
388
  if (isCloser) {
410
389
  return ['block-closer', name, null, startedAt, length];
411
390
  }
412
-
413
391
  return ['block-opener', name, attrs, startedAt, length];
414
392
  }
393
+
415
394
  /**
416
395
  * Adds a freeform block to the output.
417
396
  *
418
397
  * @param {number} [rawLength]
419
398
  */
420
-
421
-
422
399
  function addFreeform(rawLength) {
423
400
  const length = rawLength ? rawLength : document.length - offset;
424
-
425
401
  if (0 === length) {
426
402
  return;
427
403
  }
428
-
429
404
  output.push(Freeform(document.substr(offset, length)));
430
405
  }
406
+
431
407
  /**
432
408
  * Adds inner block to the parent block.
433
409
  *
@@ -436,48 +412,38 @@ function addFreeform(rawLength) {
436
412
  * @param {number} tokenLength
437
413
  * @param {number} [lastOffset]
438
414
  */
439
-
440
-
441
415
  function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
442
416
  const parent = stack[stack.length - 1];
443
417
  parent.block.innerBlocks.push(block);
444
418
  const html = document.substr(parent.prevOffset, tokenStart - parent.prevOffset);
445
-
446
419
  if (html) {
447
420
  parent.block.innerHTML += html;
448
421
  parent.block.innerContent.push(html);
449
422
  }
450
-
451
423
  parent.block.innerContent.push(null);
452
424
  parent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;
453
425
  }
426
+
454
427
  /**
455
428
  * Adds block from the stack to the output.
456
429
  *
457
430
  * @param {number} [endOffset]
458
431
  */
459
-
460
-
461
432
  function addBlockFromStack(endOffset) {
462
433
  const {
463
434
  block,
464
435
  leadingHtmlStart,
465
436
  prevOffset,
466
437
  tokenStart
467
- } =
468
- /** @type {ParsedFrame} */
469
- stack.pop();
438
+ } = /** @type {ParsedFrame} */stack.pop();
470
439
  const html = endOffset ? document.substr(prevOffset, endOffset - prevOffset) : document.substr(prevOffset);
471
-
472
440
  if (html) {
473
441
  block.innerHTML += html;
474
442
  block.innerContent.push(html);
475
443
  }
476
-
477
444
  if (null !== leadingHtmlStart) {
478
445
  output.push(Freeform(document.substr(leadingHtmlStart, tokenStart - leadingHtmlStart)));
479
446
  }
480
-
481
447
  output.push(block);
482
448
  }
483
449
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-serialization-default-parser/src/index.js"],"names":["document","offset","output","stack","tokenizer","Block","blockName","attrs","innerBlocks","innerHTML","innerContent","Freeform","Frame","block","tokenStart","tokenLength","prevOffset","leadingHtmlStart","parse","doc","lastIndex","proceed","stackDepth","length","next","nextToken","tokenType","startOffset","addFreeform","addBlockFromStack","push","substr","addInnerBlock","stackTop","pop","html","parseJSON","input","JSON","e","matches","exec","startedAt","index","match","closerMatch","namespaceMatch","nameMatch","attrsMatch","voidMatch","isCloser","isVoid","namespace","name","hasAttrs","rawLength","lastOffset","parent","endOffset"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA,IAAIA,QAAJ;AACA;AACA;AACA;;AACA,IAAIC,MAAJ;AACA;AACA;AACA;;AACA,IAAIC,MAAJ;AACA;AACA;AACA;;AACA,IAAIC,KAAJ;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,SAAS,GACd,8HADD;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,KAAT,CAAgBC,SAAhB,EAA2BC,KAA3B,EAAkCC,WAAlC,EAA+CC,SAA/C,EAA0DC,YAA1D,EAAyE;AACxE,SAAO;AACNJ,IAAAA,SADM;AAENC,IAAAA,KAFM;AAGNC,IAAAA,WAHM;AAINC,IAAAA,SAJM;AAKNC,IAAAA;AALM,GAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,QAAT,CAAmBF,SAAnB,EAA+B;AAC9B,SAAOJ,KAAK,CAAE,IAAF,EAAQ,EAAR,EAAY,EAAZ,EAAgBI,SAAhB,EAA2B,CAAEA,SAAF,CAA3B,CAAZ;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASG,KAAT,CAAgBC,KAAhB,EAAuBC,UAAvB,EAAmCC,WAAnC,EAAgDC,UAAhD,EAA4DC,gBAA5D,EAA+E;AAC9E,SAAO;AACNJ,IAAAA,KADM;AAENC,IAAAA,UAFM;AAGNC,IAAAA,WAHM;AAINC,IAAAA,UAAU,EAAEA,UAAU,IAAIF,UAAU,GAAGC,WAJjC;AAKNE,IAAAA;AALM,GAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,KAAK,GAAKC,GAAF,IAAW;AAC/BnB,EAAAA,QAAQ,GAAGmB,GAAX;AACAlB,EAAAA,MAAM,GAAG,CAAT;AACAC,EAAAA,MAAM,GAAG,EAAT;AACAC,EAAAA,KAAK,GAAG,EAAR;AACAC,EAAAA,SAAS,CAACgB,SAAV,GAAsB,CAAtB;;AAEA,KAAG,CACF;AACA,GAFD,QAEUC,OAAO,EAFjB;;AAIA,SAAOnB,MAAP;AACA,CAZM;AAcP;AACA;AACA;AACA;AACA;;;;;AACA,SAASmB,OAAT,GAAmB;AAClB,QAAMC,UAAU,GAAGnB,KAAK,CAACoB,MAAzB;AACA,QAAMC,IAAI,GAAGC,SAAS,EAAtB;AACA,QAAM,CAAEC,SAAF,EAAapB,SAAb,EAAwBC,KAAxB,EAA+BoB,WAA/B,EAA4CZ,WAA5C,IAA4DS,IAAlE,CAHkB,CAKlB;;AACA,QAAMP,gBAAgB,GAAGU,WAAW,GAAG1B,MAAd,GAAuBA,MAAvB,GAAgC,IAAzD;;AAEA,UAASyB,SAAT;AACC,SAAK,gBAAL;AACC;AACA,UAAK,MAAMJ,UAAX,EAAwB;AACvBM,QAAAA,WAAW;AACX,eAAO,KAAP;AACA,OALF,CAOC;AACA;AACA;AACA;AACA;AA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AGuB,SAAS,GACnB1D,QAAQ,CAAC+B,MAAT,CAAiBf,UAAjB,EAA6B0C,SAAS,GAAG1C,UAAzC,CADmB,GAEnBhB,QAAQ,CAAC+B,MAAT,CAAiBf,UAAjB,CAFH;;AAIA,MAAKmB,IAAL,EAAY;AACXtB,IAAAA,KAAK,CAACJ,SAAN,IAAmB0B,IAAnB;AACAtB,IAAAA,KAAK,CAACH,YAAN,CAAmBoB,IAAnB,CAAyBK,IAAzB;AACA;;AAED,MAAK,SAASlB,gBAAd,EAAiC;AAChCf,IAAAA,MAAM,CAAC4B,IAAP,CACCnB,QAAQ,CACPX,QAAQ,CAAC+B,MAAT,CACCd,gBADD,EAECH,UAAU,GAAGG,gBAFd,CADO,CADT;AAQA;;AAEDf,EAAAA,MAAM,CAAC4B,IAAP,CAAajB,KAAb;AACA","sourcesContent":["/**\n * @type {string}\n */\nlet document;\n/**\n * @type {number}\n */\nlet offset;\n/**\n * @type {ParsedBlock[]}\n */\nlet output;\n/**\n * @type {ParsedFrame[]}\n */\nlet stack;\n\n/**\n * @typedef {Object|null} Attributes\n */\n\n/**\n * @typedef {Object} ParsedBlock\n * @property {string|null} blockName Block name.\n * @property {Attributes} attrs Block attributes.\n * @property {ParsedBlock[]} innerBlocks Inner blocks.\n * @property {string} innerHTML Inner HTML.\n * @property {Array<string|null>} innerContent Inner content.\n */\n\n/**\n * @typedef {Object} ParsedFrame\n * @property {ParsedBlock} block Block.\n * @property {number} tokenStart Token start.\n * @property {number} tokenLength Token length.\n * @property {number} prevOffset Previous offset.\n * @property {number|null} leadingHtmlStart Leading HTML start.\n */\n\n/**\n * @typedef {'no-more-tokens'|'void-block'|'block-opener'|'block-closer'} TokenType\n */\n\n/**\n * @typedef {[TokenType, string, Attributes, number, number]} Token\n */\n\n/**\n * Matches block comment delimiters\n *\n * While most of this pattern is straightforward the attribute parsing\n * incorporates a tricks to make sure we don't choke on specific input\n *\n * - since JavaScript has no possessive quantifier or atomic grouping\n * we are emulating it with a trick\n *\n * we want a possessive quantifier or atomic group to prevent backtracking\n * on the `}`s should we fail to match the remainder of the pattern\n *\n * we can emulate this with a positive lookahead and back reference\n * (a++)*c === ((?=(a+))\\1)*c\n *\n * let's examine an example:\n * - /(a+)*c/.test('aaaaaaaaaaaaad') fails after over 49,000 steps\n * - /(a++)*c/.test('aaaaaaaaaaaaad') fails after 85 steps\n * - /(?>a+)*c/.test('aaaaaaaaaaaaad') fails after 126 steps\n *\n * this is because the possessive `++` and the atomic group `(?>)`\n * tell the engine that all those `a`s belong together as a single group\n * and so it won't split it up when stepping backwards to try and match\n *\n * if we use /((?=(a+))\\1)*c/ then we get the same behavior as the atomic group\n * or possessive and prevent the backtracking because the `a+` is matched but\n * not captured. thus, we find the long string of `a`s and remember it, then\n * reference it as a whole unit inside our pattern\n *\n * @see http://instanceof.me/post/52245507631/regex-emulate-atomic-grouping-with-lookahead\n * @see http://blog.stevenlevithan.com/archives/mimic-atomic-groups\n * @see https://javascript.info/regexp-infinite-backtracking-problem\n *\n * once browsers reliably support atomic grouping or possessive\n * quantifiers natively we should remove this trick and simplify\n *\n * @type {RegExp}\n *\n * @since 3.8.0\n * @since 4.6.1 added optimization to prevent backtracking on attribute parsing\n */\nconst tokenizer =\n\t/<!--\\s+(\\/)?wp:([a-z][a-z0-9_-]*\\/)?([a-z][a-z0-9_-]*)\\s+({(?:(?=([^}]+|}+(?=})|(?!}\\s+\\/?-->)[^])*)\\5|[^]*?)}\\s+)?(\\/)?-->/g;\n\n/**\n * Constructs a block object.\n *\n * @param {string|null} blockName\n * @param {Attributes} attrs\n * @param {ParsedBlock[]} innerBlocks\n * @param {string} innerHTML\n * @param {string[]} innerContent\n * @return {ParsedBlock} The block object.\n */\nfunction Block( blockName, attrs, innerBlocks, innerHTML, innerContent ) {\n\treturn {\n\t\tblockName,\n\t\tattrs,\n\t\tinnerBlocks,\n\t\tinnerHTML,\n\t\tinnerContent,\n\t};\n}\n\n/**\n * Constructs a freeform block object.\n *\n * @param {string} innerHTML\n * @return {ParsedBlock} The freeform block object.\n */\nfunction Freeform( innerHTML ) {\n\treturn Block( null, {}, [], innerHTML, [ innerHTML ] );\n}\n\n/**\n * Constructs a frame object.\n *\n * @param {ParsedBlock} block\n * @param {number} tokenStart\n * @param {number} tokenLength\n * @param {number} prevOffset\n * @param {number|null} leadingHtmlStart\n * @return {ParsedFrame} The frame object.\n */\nfunction Frame( block, tokenStart, tokenLength, prevOffset, leadingHtmlStart ) {\n\treturn {\n\t\tblock,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset: prevOffset || tokenStart + tokenLength,\n\t\tleadingHtmlStart,\n\t};\n}\n\n/**\n * Parser function, that converts input HTML into a block based structure.\n *\n * @param {string} doc The HTML document to parse.\n *\n * @example\n * Input post:\n * ```html\n * <!-- wp:columns {\"columns\":3} -->\n * <div class=\"wp-block-columns has-3-columns\"><!-- wp:column -->\n * <div class=\"wp-block-column\"><!-- wp:paragraph -->\n * <p>Left</p>\n * <!-- /wp:paragraph --></div>\n * <!-- /wp:column -->\n *\n * <!-- wp:column -->\n * <div class=\"wp-block-column\"><!-- wp:paragraph -->\n * <p><strong>Middle</strong></p>\n * <!-- /wp:paragraph --></div>\n * <!-- /wp:column -->\n *\n * <!-- wp:column -->\n * <div class=\"wp-block-column\"></div>\n * <!-- /wp:column --></div>\n * <!-- /wp:columns -->\n * ```\n *\n * Parsing code:\n * ```js\n * import { parse } from '@wordpress/block-serialization-default-parser';\n *\n * parse( post ) === [\n * {\n * blockName: \"core/columns\",\n * attrs: {\n * columns: 3\n * },\n * innerBlocks: [\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [\n * {\n * blockName: \"core/paragraph\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: \"\\n<p>Left</p>\\n\"\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * },\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [\n * {\n * blockName: \"core/paragraph\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: \"\\n<p><strong>Middle</strong></p>\\n\"\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * },\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-columns has-3-columns\">\\n\\n\\n\\n</div>\\n'\n * }\n * ];\n * ```\n * @return {ParsedBlock[]} A block-based representation of the input HTML.\n */\nexport const parse = ( doc ) => {\n\tdocument = doc;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed() );\n\n\treturn output;\n};\n\n/**\n * Parses the next token in the input document.\n *\n * @return {boolean} Returns true when there is more tokens to parse.\n */\nfunction proceed() {\n\tconst stackDepth = stack.length;\n\tconst next = nextToken();\n\tconst [ tokenType, blockName, attrs, startOffset, tokenLength ] = next;\n\n\t// We may have some HTML soup before the next block.\n\tconst leadingHtmlStart = startOffset > offset ? offset : null;\n\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\t// If not in a block then flush output.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\taddFreeform();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Otherwise we have a problem\n\t\t\t// This is an error\n\t\t\t// we have options\n\t\t\t// - treat it all as freeform text\n\t\t\t// - assume an implicit closer (easiest when not nesting)\n\n\t\t\t// For the easy case we'll assume an implicit closer.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\taddBlockFromStack();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// For the nested case where it's more difficult we'll\n\t\t\t// have to assume that multiple closers are missing\n\t\t\t// and so we'll collapse the whole stack piecewise.\n\t\t\twhile ( 0 < stack.length ) {\n\t\t\t\taddBlockFromStack();\n\t\t\t}\n\t\t\treturn false;\n\t\tcase 'void-block':\n\t\t\t// easy case is if we stumbled upon a void block\n\t\t\t// in the top-level of the document.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingHtmlStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tFreeform(\n\t\t\t\t\t\t\tdocument.substr(\n\t\t\t\t\t\t\t\tleadingHtmlStart,\n\t\t\t\t\t\t\t\tstartOffset - leadingHtmlStart\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( Block( blockName, attrs, [], '', [] ) );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner block.\n\t\t\taddInnerBlock(\n\t\t\t\tBlock( blockName, attrs, [], '', [] ),\n\t\t\t\tstartOffset,\n\t\t\t\ttokenLength\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'block-opener':\n\t\t\t// Track all newly-opened blocks on the stack.\n\t\t\tstack.push(\n\t\t\t\tFrame(\n\t\t\t\t\tBlock( blockName, attrs, [], '', [] ),\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingHtmlStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'block-closer':\n\t\t\t// If we're missing an opener we're in trouble\n\t\t\t// This is an error.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\t// We have options\n\t\t\t\t// - assume an implicit opener\n\t\t\t\t// - assume _this_ is the opener\n\t\t\t\t// - give up and close out the document.\n\t\t\t\taddFreeform();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\taddBlockFromStack( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = /** @type {ParsedFrame} */ ( stack.pop() );\n\t\t\tconst html = document.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.block.innerHTML += html;\n\t\t\tstackTop.block.innerContent.push( html );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\n\t\t\taddInnerBlock(\n\t\t\t\tstackTop.block,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\t// This is an error.\n\t\t\taddFreeform();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Parse JSON if valid, otherwise return null\n *\n * Note that JSON coming from the block comment\n * delimiters is constrained to be an object\n * and cannot be things like `true` or `null`\n *\n * @param {string} input JSON input string to parse\n * @return {Object|null} parsed JSON if valid\n */\nfunction parseJSON( input ) {\n\ttry {\n\t\treturn JSON.parse( input );\n\t} catch ( e ) {\n\t\treturn null;\n\t}\n}\n\n/**\n * Finds the next token in the document.\n *\n * @return {Token} The next matched token.\n */\nfunction nextToken() {\n\t// Aye the magic\n\t// we're using a single RegExp to tokenize the block comment delimiters\n\t// we're also using a trick here because the only difference between a\n\t// block opener and a block closer is the leading `/` before `wp:` (and\n\t// a closer has no attributes). we can trap them both and process the\n\t// match back in JavaScript to see which one it was.\n\tconst matches = tokenizer.exec( document );\n\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens', '', null, 0, 0 ];\n\t}\n\n\tconst startedAt = matches.index;\n\tconst [\n\t\tmatch,\n\t\tcloserMatch,\n\t\tnamespaceMatch,\n\t\tnameMatch,\n\t\tattrsMatch /* Internal/unused. */,\n\t\t,\n\t\tvoidMatch,\n\t] = matches;\n\n\tconst length = match.length;\n\tconst isCloser = !! closerMatch;\n\tconst isVoid = !! voidMatch;\n\tconst namespace = namespaceMatch || 'core/';\n\tconst name = namespace + nameMatch;\n\tconst hasAttrs = !! attrsMatch;\n\tconst attrs = hasAttrs ? parseJSON( attrsMatch ) : {};\n\n\t// This state isn't allowed\n\t// This is an error.\n\tif ( isCloser && ( isVoid || hasAttrs ) ) {\n\t\t// We can ignore them since they don't hurt anything\n\t\t// we may warn against this at some point or reject it.\n\t}\n\n\tif ( isVoid ) {\n\t\treturn [ 'void-block', name, attrs, startedAt, length ];\n\t}\n\n\tif ( isCloser ) {\n\t\treturn [ 'block-closer', name, null, startedAt, length ];\n\t}\n\n\treturn [ 'block-opener', name, attrs, startedAt, length ];\n}\n\n/**\n * Adds a freeform block to the output.\n *\n * @param {number} [rawLength]\n */\nfunction addFreeform( rawLength ) {\n\tconst length = rawLength ? rawLength : document.length - offset;\n\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\n\toutput.push( Freeform( document.substr( offset, length ) ) );\n}\n\n/**\n * Adds inner block to the parent block.\n *\n * @param {ParsedBlock} block\n * @param {number} tokenStart\n * @param {number} tokenLength\n * @param {number} [lastOffset]\n */\nfunction addInnerBlock( block, tokenStart, tokenLength, lastOffset ) {\n\tconst parent = stack[ stack.length - 1 ];\n\tparent.block.innerBlocks.push( block );\n\tconst html = document.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( html ) {\n\t\tparent.block.innerHTML += html;\n\t\tparent.block.innerContent.push( html );\n\t}\n\n\tparent.block.innerContent.push( null );\n\tparent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;\n}\n\n/**\n * Adds block from the stack to the output.\n *\n * @param {number} [endOffset]\n */\nfunction addBlockFromStack( endOffset ) {\n\tconst { block, leadingHtmlStart, prevOffset, tokenStart } =\n\t\t/** @type {ParsedFrame} */ ( stack.pop() );\n\n\tconst html = endOffset\n\t\t? document.substr( prevOffset, endOffset - prevOffset )\n\t\t: document.substr( prevOffset );\n\n\tif ( html ) {\n\t\tblock.innerHTML += html;\n\t\tblock.innerContent.push( html );\n\t}\n\n\tif ( null !== leadingHtmlStart ) {\n\t\toutput.push(\n\t\t\tFreeform(\n\t\t\t\tdocument.substr(\n\t\t\t\t\tleadingHtmlStart,\n\t\t\t\t\ttokenStart - leadingHtmlStart\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n\n\toutput.push( block );\n}\n"]}
1
+ {"version":3,"names":["document","offset","output","stack","tokenizer","Block","blockName","attrs","innerBlocks","innerHTML","innerContent","Freeform","Frame","block","tokenStart","tokenLength","prevOffset","leadingHtmlStart","parse","doc","lastIndex","proceed","exports","stackDepth","length","next","nextToken","tokenType","startOffset","addFreeform","addBlockFromStack","push","substr","addInnerBlock","stackTop","pop","html","parseJSON","input","JSON","e","matches","exec","startedAt","index","match","closerMatch","namespaceMatch","nameMatch","attrsMatch","voidMatch","isCloser","isVoid","namespace","name","hasAttrs","rawLength","lastOffset","parent","endOffset"],"sources":["@wordpress/block-serialization-default-parser/src/index.js"],"sourcesContent":["/**\n * @type {string}\n */\nlet document;\n/**\n * @type {number}\n */\nlet offset;\n/**\n * @type {ParsedBlock[]}\n */\nlet output;\n/**\n * @type {ParsedFrame[]}\n */\nlet stack;\n\n/**\n * @typedef {Object|null} Attributes\n */\n\n/**\n * @typedef {Object} ParsedBlock\n * @property {string|null} blockName Block name.\n * @property {Attributes} attrs Block attributes.\n * @property {ParsedBlock[]} innerBlocks Inner blocks.\n * @property {string} innerHTML Inner HTML.\n * @property {Array<string|null>} innerContent Inner content.\n */\n\n/**\n * @typedef {Object} ParsedFrame\n * @property {ParsedBlock} block Block.\n * @property {number} tokenStart Token start.\n * @property {number} tokenLength Token length.\n * @property {number} prevOffset Previous offset.\n * @property {number|null} leadingHtmlStart Leading HTML start.\n */\n\n/**\n * @typedef {'no-more-tokens'|'void-block'|'block-opener'|'block-closer'} TokenType\n */\n\n/**\n * @typedef {[TokenType, string, Attributes, number, number]} Token\n */\n\n/**\n * Matches block comment delimiters\n *\n * While most of this pattern is straightforward the attribute parsing\n * incorporates a tricks to make sure we don't choke on specific input\n *\n * - since JavaScript has no possessive quantifier or atomic grouping\n * we are emulating it with a trick\n *\n * we want a possessive quantifier or atomic group to prevent backtracking\n * on the `}`s should we fail to match the remainder of the pattern\n *\n * we can emulate this with a positive lookahead and back reference\n * (a++)*c === ((?=(a+))\\1)*c\n *\n * let's examine an example:\n * - /(a+)*c/.test('aaaaaaaaaaaaad') fails after over 49,000 steps\n * - /(a++)*c/.test('aaaaaaaaaaaaad') fails after 85 steps\n * - /(?>a+)*c/.test('aaaaaaaaaaaaad') fails after 126 steps\n *\n * this is because the possessive `++` and the atomic group `(?>)`\n * tell the engine that all those `a`s belong together as a single group\n * and so it won't split it up when stepping backwards to try and match\n *\n * if we use /((?=(a+))\\1)*c/ then we get the same behavior as the atomic group\n * or possessive and prevent the backtracking because the `a+` is matched but\n * not captured. thus, we find the long string of `a`s and remember it, then\n * reference it as a whole unit inside our pattern\n *\n * @see http://instanceof.me/post/52245507631/regex-emulate-atomic-grouping-with-lookahead\n * @see http://blog.stevenlevithan.com/archives/mimic-atomic-groups\n * @see https://javascript.info/regexp-infinite-backtracking-problem\n *\n * once browsers reliably support atomic grouping or possessive\n * quantifiers natively we should remove this trick and simplify\n *\n * @type {RegExp}\n *\n * @since 3.8.0\n * @since 4.6.1 added optimization to prevent backtracking on attribute parsing\n */\nconst tokenizer =\n\t/<!--\\s+(\\/)?wp:([a-z][a-z0-9_-]*\\/)?([a-z][a-z0-9_-]*)\\s+({(?:(?=([^}]+|}+(?=})|(?!}\\s+\\/?-->)[^])*)\\5|[^]*?)}\\s+)?(\\/)?-->/g;\n\n/**\n * Constructs a block object.\n *\n * @param {string|null} blockName\n * @param {Attributes} attrs\n * @param {ParsedBlock[]} innerBlocks\n * @param {string} innerHTML\n * @param {string[]} innerContent\n * @return {ParsedBlock} The block object.\n */\nfunction Block( blockName, attrs, innerBlocks, innerHTML, innerContent ) {\n\treturn {\n\t\tblockName,\n\t\tattrs,\n\t\tinnerBlocks,\n\t\tinnerHTML,\n\t\tinnerContent,\n\t};\n}\n\n/**\n * Constructs a freeform block object.\n *\n * @param {string} innerHTML\n * @return {ParsedBlock} The freeform block object.\n */\nfunction Freeform( innerHTML ) {\n\treturn Block( null, {}, [], innerHTML, [ innerHTML ] );\n}\n\n/**\n * Constructs a frame object.\n *\n * @param {ParsedBlock} block\n * @param {number} tokenStart\n * @param {number} tokenLength\n * @param {number} prevOffset\n * @param {number|null} leadingHtmlStart\n * @return {ParsedFrame} The frame object.\n */\nfunction Frame( block, tokenStart, tokenLength, prevOffset, leadingHtmlStart ) {\n\treturn {\n\t\tblock,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset: prevOffset || tokenStart + tokenLength,\n\t\tleadingHtmlStart,\n\t};\n}\n\n/**\n * Parser function, that converts input HTML into a block based structure.\n *\n * @param {string} doc The HTML document to parse.\n *\n * @example\n * Input post:\n * ```html\n * <!-- wp:columns {\"columns\":3} -->\n * <div class=\"wp-block-columns has-3-columns\"><!-- wp:column -->\n * <div class=\"wp-block-column\"><!-- wp:paragraph -->\n * <p>Left</p>\n * <!-- /wp:paragraph --></div>\n * <!-- /wp:column -->\n *\n * <!-- wp:column -->\n * <div class=\"wp-block-column\"><!-- wp:paragraph -->\n * <p><strong>Middle</strong></p>\n * <!-- /wp:paragraph --></div>\n * <!-- /wp:column -->\n *\n * <!-- wp:column -->\n * <div class=\"wp-block-column\"></div>\n * <!-- /wp:column --></div>\n * <!-- /wp:columns -->\n * ```\n *\n * Parsing code:\n * ```js\n * import { parse } from '@wordpress/block-serialization-default-parser';\n *\n * parse( post ) === [\n * {\n * blockName: \"core/columns\",\n * attrs: {\n * columns: 3\n * },\n * innerBlocks: [\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [\n * {\n * blockName: \"core/paragraph\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: \"\\n<p>Left</p>\\n\"\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * },\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [\n * {\n * blockName: \"core/paragraph\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: \"\\n<p><strong>Middle</strong></p>\\n\"\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * },\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-columns has-3-columns\">\\n\\n\\n\\n</div>\\n'\n * }\n * ];\n * ```\n * @return {ParsedBlock[]} A block-based representation of the input HTML.\n */\nexport const parse = ( doc ) => {\n\tdocument = doc;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed() );\n\n\treturn output;\n};\n\n/**\n * Parses the next token in the input document.\n *\n * @return {boolean} Returns true when there is more tokens to parse.\n */\nfunction proceed() {\n\tconst stackDepth = stack.length;\n\tconst next = nextToken();\n\tconst [ tokenType, blockName, attrs, startOffset, tokenLength ] = next;\n\n\t// We may have some HTML soup before the next block.\n\tconst leadingHtmlStart = startOffset > offset ? offset : null;\n\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\t// If not in a block then flush output.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\taddFreeform();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Otherwise we have a problem\n\t\t\t// This is an error\n\t\t\t// we have options\n\t\t\t// - treat it all as freeform text\n\t\t\t// - assume an implicit closer (easiest when not nesting)\n\n\t\t\t// For the easy case we'll assume an implicit closer.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\taddBlockFromStack();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// For the nested case where it's more difficult we'll\n\t\t\t// have to assume that multiple closers are missing\n\t\t\t// and so we'll collapse the whole stack piecewise.\n\t\t\twhile ( 0 < stack.length ) {\n\t\t\t\taddBlockFromStack();\n\t\t\t}\n\t\t\treturn false;\n\t\tcase 'void-block':\n\t\t\t// easy case is if we stumbled upon a void block\n\t\t\t// in the top-level of the document.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingHtmlStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tFreeform(\n\t\t\t\t\t\t\tdocument.substr(\n\t\t\t\t\t\t\t\tleadingHtmlStart,\n\t\t\t\t\t\t\t\tstartOffset - leadingHtmlStart\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( Block( blockName, attrs, [], '', [] ) );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner block.\n\t\t\taddInnerBlock(\n\t\t\t\tBlock( blockName, attrs, [], '', [] ),\n\t\t\t\tstartOffset,\n\t\t\t\ttokenLength\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'block-opener':\n\t\t\t// Track all newly-opened blocks on the stack.\n\t\t\tstack.push(\n\t\t\t\tFrame(\n\t\t\t\t\tBlock( blockName, attrs, [], '', [] ),\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingHtmlStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'block-closer':\n\t\t\t// If we're missing an opener we're in trouble\n\t\t\t// This is an error.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\t// We have options\n\t\t\t\t// - assume an implicit opener\n\t\t\t\t// - assume _this_ is the opener\n\t\t\t\t// - give up and close out the document.\n\t\t\t\taddFreeform();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\taddBlockFromStack( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = /** @type {ParsedFrame} */ ( stack.pop() );\n\t\t\tconst html = document.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.block.innerHTML += html;\n\t\t\tstackTop.block.innerContent.push( html );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\n\t\t\taddInnerBlock(\n\t\t\t\tstackTop.block,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\t// This is an error.\n\t\t\taddFreeform();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Parse JSON if valid, otherwise return null\n *\n * Note that JSON coming from the block comment\n * delimiters is constrained to be an object\n * and cannot be things like `true` or `null`\n *\n * @param {string} input JSON input string to parse\n * @return {Object|null} parsed JSON if valid\n */\nfunction parseJSON( input ) {\n\ttry {\n\t\treturn JSON.parse( input );\n\t} catch ( e ) {\n\t\treturn null;\n\t}\n}\n\n/**\n * Finds the next token in the document.\n *\n * @return {Token} The next matched token.\n */\nfunction nextToken() {\n\t// Aye the magic\n\t// we're using a single RegExp to tokenize the block comment delimiters\n\t// we're also using a trick here because the only difference between a\n\t// block opener and a block closer is the leading `/` before `wp:` (and\n\t// a closer has no attributes). we can trap them both and process the\n\t// match back in JavaScript to see which one it was.\n\tconst matches = tokenizer.exec( document );\n\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens', '', null, 0, 0 ];\n\t}\n\n\tconst startedAt = matches.index;\n\tconst [\n\t\tmatch,\n\t\tcloserMatch,\n\t\tnamespaceMatch,\n\t\tnameMatch,\n\t\tattrsMatch /* Internal/unused. */,\n\t\t,\n\t\tvoidMatch,\n\t] = matches;\n\n\tconst length = match.length;\n\tconst isCloser = !! closerMatch;\n\tconst isVoid = !! voidMatch;\n\tconst namespace = namespaceMatch || 'core/';\n\tconst name = namespace + nameMatch;\n\tconst hasAttrs = !! attrsMatch;\n\tconst attrs = hasAttrs ? parseJSON( attrsMatch ) : {};\n\n\t// This state isn't allowed\n\t// This is an error.\n\tif ( isCloser && ( isVoid || hasAttrs ) ) {\n\t\t// We can ignore them since they don't hurt anything\n\t\t// we may warn against this at some point or reject it.\n\t}\n\n\tif ( isVoid ) {\n\t\treturn [ 'void-block', name, attrs, startedAt, length ];\n\t}\n\n\tif ( isCloser ) {\n\t\treturn [ 'block-closer', name, null, startedAt, length ];\n\t}\n\n\treturn [ 'block-opener', name, attrs, startedAt, length ];\n}\n\n/**\n * Adds a freeform block to the output.\n *\n * @param {number} [rawLength]\n */\nfunction addFreeform( rawLength ) {\n\tconst length = rawLength ? rawLength : document.length - offset;\n\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\n\toutput.push( Freeform( document.substr( offset, length ) ) );\n}\n\n/**\n * Adds inner block to the parent block.\n *\n * @param {ParsedBlock} block\n * @param {number} tokenStart\n * @param {number} tokenLength\n * @param {number} [lastOffset]\n */\nfunction addInnerBlock( block, tokenStart, tokenLength, lastOffset ) {\n\tconst parent = stack[ stack.length - 1 ];\n\tparent.block.innerBlocks.push( block );\n\tconst html = document.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( html ) {\n\t\tparent.block.innerHTML += html;\n\t\tparent.block.innerContent.push( html );\n\t}\n\n\tparent.block.innerContent.push( null );\n\tparent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;\n}\n\n/**\n * Adds block from the stack to the output.\n *\n * @param {number} [endOffset]\n */\nfunction addBlockFromStack( endOffset ) {\n\tconst { block, leadingHtmlStart, prevOffset, tokenStart } =\n\t\t/** @type {ParsedFrame} */ ( stack.pop() );\n\n\tconst html = endOffset\n\t\t? document.substr( prevOffset, endOffset - prevOffset )\n\t\t: document.substr( prevOffset );\n\n\tif ( html ) {\n\t\tblock.innerHTML += html;\n\t\tblock.innerContent.push( html );\n\t}\n\n\tif ( null !== leadingHtmlStart ) {\n\t\toutput.push(\n\t\t\tFreeform(\n\t\t\t\tdocument.substr(\n\t\t\t\t\tleadingHtmlStart,\n\t\t\t\t\ttokenStart - leadingHtmlStart\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n\n\toutput.push( block );\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA,IAAIA,QAAQ;AACZ;AACA;AACA;AACA,IAAIC,MAAM;AACV;AACA;AACA;AACA,IAAIC,MAAM;AACV;AACA;AACA;AACA,IAAIC,KAAK;;AAET;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,GACd,8HAA8H;;AAE/H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,KAAKA,CAAEC,SAAS,EAAEC,KAAK,EAAEC,WAAW,EAAEC,SAAS,EAAEC,YAAY,EAAG;EACxE,OAAO;IACNJ,SAAS;IACTC,KAAK;IACLC,WAAW;IACXC,SAAS;IACTC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAAEF,SAAS,EAAG;EAC9B,OAAOJ,KAAK,CAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,EAAEI,SAAS,EAAE,CAAEA,SAAS,CAAG,CAAC;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,KAAKA,CAAEC,KAAK,EAAEC,UAAU,EAAEC,WAAW,EAAEC,UAAU,EAAEC,gBAAgB,EAAG;EAC9E,OAAO;IACNJ,KAAK;IACLC,UAAU;IACVC,WAAW;IACXC,UAAU,EAAEA,UAAU,IAAIF,UAAU,GAAGC,WAAW;IAClDE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,KAAK,GAAKC,GAAG,IAAM;EAC/BnB,QAAQ,GAAGmB,GAAG;EACdlB,MAAM,GAAG,CAAC;EACVC,MAAM,GAAG,EAAE;EACXC,KAAK,GAAG,EAAE;EACVC,SAAS,CAACgB,SAAS,GAAG,CAAC;EAEvB,GAAG;IACF;EAAA,CACA,QAASC,OAAO,CAAC,CAAC;EAEnB,OAAOnB,MAAM;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAoB,OAAA,CAAAJ,KAAA,GAAAA,KAAA;AAKA,SAASG,OAAOA,CAAA,E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UAAU,GAAGC,WAAW;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASe,iBAAiBA,CAAE6B,SAAS,EAAG;EACvC,MAAM;IAAE9C,KAAK;IAAEI,gBAAgB;IAAED,UAAU;IAAEF;EAAW,CAAC,GACxD,0BAA6BX,KAAK,CAACgC,GAAG,CAAC,CAAG;EAE3C,MAAMC,IAAI,GAAGuB,SAAS,GACnB3D,QAAQ,CAACgC,MAAM,CAAEhB,UAAU,EAAE2C,SAAS,GAAG3C,UAAW,CAAC,GACrDhB,QAAQ,CAACgC,MAAM,CAAEhB,UAAW,CAAC;EAEhC,IAAKoB,IAAI,EAAG;IACXvB,KAAK,CAACJ,SAAS,IAAI2B,IAAI;IACvBvB,KAAK,CAACH,YAAY,CAACqB,IAAI,CAAEK,IAAK,CAAC;EAChC;EAEA,IAAK,IAAI,KAAKnB,gBAAgB,EAAG;IAChCf,MAAM,CAAC6B,IAAI,CACVpB,QAAQ,CACPX,QAAQ,CAACgC,MAAM,CACdf,gBAAgB,EAChBH,UAAU,GAAGG,gBACd,CACD,CACD,CAAC;EACF;EAEAf,MAAM,CAAC6B,IAAI,CAAElB,KAAM,CAAC;AACrB"}
@@ -5,18 +5,16 @@ let document;
5
5
  /**
6
6
  * @type {number}
7
7
  */
8
-
9
8
  let offset;
10
9
  /**
11
10
  * @type {ParsedBlock[]}
12
11
  */
13
-
14
12
  let output;
15
13
  /**
16
14
  * @type {ParsedFrame[]}
17
15
  */
18
-
19
16
  let stack;
17
+
20
18
  /**
21
19
  * @typedef {Object|null} Attributes
22
20
  */
@@ -88,8 +86,8 @@ let stack;
88
86
  * @since 3.8.0
89
87
  * @since 4.6.1 added optimization to prevent backtracking on attribute parsing
90
88
  */
91
-
92
89
  const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/g;
90
+
93
91
  /**
94
92
  * Constructs a block object.
95
93
  *
@@ -100,7 +98,6 @@ const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?
100
98
  * @param {string[]} innerContent
101
99
  * @return {ParsedBlock} The block object.
102
100
  */
103
-
104
101
  function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
105
102
  return {
106
103
  blockName,
@@ -110,17 +107,17 @@ function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
110
107
  innerContent
111
108
  };
112
109
  }
110
+
113
111
  /**
114
112
  * Constructs a freeform block object.
115
113
  *
116
114
  * @param {string} innerHTML
117
115
  * @return {ParsedBlock} The freeform block object.
118
116
  */
119
-
120
-
121
117
  function Freeform(innerHTML) {
122
118
  return Block(null, {}, [], innerHTML, [innerHTML]);
123
119
  }
120
+
124
121
  /**
125
122
  * Constructs a frame object.
126
123
  *
@@ -131,8 +128,6 @@ function Freeform(innerHTML) {
131
128
  * @param {number|null} leadingHtmlStart
132
129
  * @return {ParsedFrame} The frame object.
133
130
  */
134
-
135
-
136
131
  function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
137
132
  return {
138
133
  block,
@@ -142,6 +137,7 @@ function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
142
137
  leadingHtmlStart
143
138
  };
144
139
  }
140
+
145
141
  /**
146
142
  * Parser function, that converts input HTML into a block based structure.
147
143
  *
@@ -219,61 +215,57 @@ function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
219
215
  * ```
220
216
  * @return {ParsedBlock[]} A block-based representation of the input HTML.
221
217
  */
222
-
223
-
224
218
  export const parse = doc => {
225
219
  document = doc;
226
220
  offset = 0;
227
221
  output = [];
228
222
  stack = [];
229
223
  tokenizer.lastIndex = 0;
230
-
231
- do {// twiddle our thumbs
224
+ do {
225
+ // twiddle our thumbs
232
226
  } while (proceed());
233
-
234
227
  return output;
235
228
  };
229
+
236
230
  /**
237
231
  * Parses the next token in the input document.
238
232
  *
239
233
  * @return {boolean} Returns true when there is more tokens to parse.
240
234
  */
241
-
242
235
  function proceed() {
243
236
  const stackDepth = stack.length;
244
237
  const next = nextToken();
245
- const [tokenType, blockName, attrs, startOffset, tokenLength] = next; // We may have some HTML soup before the next block.
238
+ const [tokenType, blockName, attrs, startOffset, tokenLength] = next;
246
239
 
240
+ // We may have some HTML soup before the next block.
247
241
  const leadingHtmlStart = startOffset > offset ? offset : null;
248
-
249
242
  switch (tokenType) {
250
243
  case 'no-more-tokens':
251
244
  // If not in a block then flush output.
252
245
  if (0 === stackDepth) {
253
246
  addFreeform();
254
247
  return false;
255
- } // Otherwise we have a problem
248
+ }
249
+
250
+ // Otherwise we have a problem
256
251
  // This is an error
257
252
  // we have options
258
253
  // - treat it all as freeform text
259
254
  // - assume an implicit closer (easiest when not nesting)
260
- // For the easy case we'll assume an implicit closer.
261
-
262
255
 
256
+ // For the easy case we'll assume an implicit closer.
263
257
  if (1 === stackDepth) {
264
258
  addBlockFromStack();
265
259
  return false;
266
- } // For the nested case where it's more difficult we'll
260
+ }
261
+
262
+ // For the nested case where it's more difficult we'll
267
263
  // have to assume that multiple closers are missing
268
264
  // and so we'll collapse the whole stack piecewise.
269
-
270
-
271
265
  while (0 < stack.length) {
272
266
  addBlockFromStack();
273
267
  }
274
-
275
268
  return false;
276
-
277
269
  case 'void-block':
278
270
  // easy case is if we stumbled upon a void block
279
271
  // in the top-level of the document.
@@ -281,23 +273,20 @@ function proceed() {
281
273
  if (null !== leadingHtmlStart) {
282
274
  output.push(Freeform(document.substr(leadingHtmlStart, startOffset - leadingHtmlStart)));
283
275
  }
284
-
285
276
  output.push(Block(blockName, attrs, [], '', []));
286
277
  offset = startOffset + tokenLength;
287
278
  return true;
288
- } // Otherwise we found an inner block.
289
-
279
+ }
290
280
 
281
+ // Otherwise we found an inner block.
291
282
  addInnerBlock(Block(blockName, attrs, [], '', []), startOffset, tokenLength);
292
283
  offset = startOffset + tokenLength;
293
284
  return true;
294
-
295
285
  case 'block-opener':
296
286
  // Track all newly-opened blocks on the stack.
297
287
  stack.push(Frame(Block(blockName, attrs, [], '', []), startOffset, tokenLength, startOffset + tokenLength, leadingHtmlStart));
298
288
  offset = startOffset + tokenLength;
299
289
  return true;
300
-
301
290
  case 'block-closer':
302
291
  // If we're missing an opener we're in trouble
303
292
  // This is an error.
@@ -308,20 +297,18 @@ function proceed() {
308
297
  // - give up and close out the document.
309
298
  addFreeform();
310
299
  return false;
311
- } // If we're not nesting then this is easy - close the block.
312
-
300
+ }
313
301
 
302
+ // If we're not nesting then this is easy - close the block.
314
303
  if (1 === stackDepth) {
315
304
  addBlockFromStack(startOffset);
316
305
  offset = startOffset + tokenLength;
317
306
  return true;
318
- } // Otherwise we're nested and we have to close out the current
319
- // block and add it as a innerBlock to the parent.
320
-
307
+ }
321
308
 
322
- const stackTop =
323
- /** @type {ParsedFrame} */
324
- stack.pop();
309
+ // Otherwise we're nested and we have to close out the current
310
+ // block and add it as a innerBlock to the parent.
311
+ const stackTop = /** @type {ParsedFrame} */stack.pop();
325
312
  const html = document.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
326
313
  stackTop.block.innerHTML += html;
327
314
  stackTop.block.innerContent.push(html);
@@ -329,13 +316,13 @@ function proceed() {
329
316
  addInnerBlock(stackTop.block, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
330
317
  offset = startOffset + tokenLength;
331
318
  return true;
332
-
333
319
  default:
334
320
  // This is an error.
335
321
  addFreeform();
336
322
  return false;
337
323
  }
338
324
  }
325
+
339
326
  /**
340
327
  * Parse JSON if valid, otherwise return null
341
328
  *
@@ -346,8 +333,6 @@ function proceed() {
346
333
  * @param {string} input JSON input string to parse
347
334
  * @return {Object|null} parsed JSON if valid
348
335
  */
349
-
350
-
351
336
  function parseJSON(input) {
352
337
  try {
353
338
  return JSON.parse(input);
@@ -355,13 +340,12 @@ function parseJSON(input) {
355
340
  return null;
356
341
  }
357
342
  }
343
+
358
344
  /**
359
345
  * Finds the next token in the document.
360
346
  *
361
347
  * @return {Token} The next matched token.
362
348
  */
363
-
364
-
365
349
  function nextToken() {
366
350
  // Aye the magic
367
351
  // we're using a single RegExp to tokenize the block comment delimiters
@@ -369,55 +353,50 @@ function nextToken() {
369
353
  // block opener and a block closer is the leading `/` before `wp:` (and
370
354
  // a closer has no attributes). we can trap them both and process the
371
355
  // match back in JavaScript to see which one it was.
372
- const matches = tokenizer.exec(document); // We have no more tokens.
356
+ const matches = tokenizer.exec(document);
373
357
 
358
+ // We have no more tokens.
374
359
  if (null === matches) {
375
360
  return ['no-more-tokens', '', null, 0, 0];
376
361
  }
377
-
378
362
  const startedAt = matches.index;
379
- const [match, closerMatch, namespaceMatch, nameMatch, attrsMatch
380
- /* Internal/unused. */
381
- ,, voidMatch] = matches;
363
+ const [match, closerMatch, namespaceMatch, nameMatch, attrsMatch /* Internal/unused. */,, voidMatch] = matches;
382
364
  const length = match.length;
383
365
  const isCloser = !!closerMatch;
384
366
  const isVoid = !!voidMatch;
385
367
  const namespace = namespaceMatch || 'core/';
386
368
  const name = namespace + nameMatch;
387
369
  const hasAttrs = !!attrsMatch;
388
- const attrs = hasAttrs ? parseJSON(attrsMatch) : {}; // This state isn't allowed
389
- // This is an error.
370
+ const attrs = hasAttrs ? parseJSON(attrsMatch) : {};
390
371
 
391
- if (isCloser && (isVoid || hasAttrs)) {// We can ignore them since they don't hurt anything
372
+ // This state isn't allowed
373
+ // This is an error.
374
+ if (isCloser && (isVoid || hasAttrs)) {
375
+ // We can ignore them since they don't hurt anything
392
376
  // we may warn against this at some point or reject it.
393
377
  }
394
-
395
378
  if (isVoid) {
396
379
  return ['void-block', name, attrs, startedAt, length];
397
380
  }
398
-
399
381
  if (isCloser) {
400
382
  return ['block-closer', name, null, startedAt, length];
401
383
  }
402
-
403
384
  return ['block-opener', name, attrs, startedAt, length];
404
385
  }
386
+
405
387
  /**
406
388
  * Adds a freeform block to the output.
407
389
  *
408
390
  * @param {number} [rawLength]
409
391
  */
410
-
411
-
412
392
  function addFreeform(rawLength) {
413
393
  const length = rawLength ? rawLength : document.length - offset;
414
-
415
394
  if (0 === length) {
416
395
  return;
417
396
  }
418
-
419
397
  output.push(Freeform(document.substr(offset, length)));
420
398
  }
399
+
421
400
  /**
422
401
  * Adds inner block to the parent block.
423
402
  *
@@ -426,48 +405,38 @@ function addFreeform(rawLength) {
426
405
  * @param {number} tokenLength
427
406
  * @param {number} [lastOffset]
428
407
  */
429
-
430
-
431
408
  function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
432
409
  const parent = stack[stack.length - 1];
433
410
  parent.block.innerBlocks.push(block);
434
411
  const html = document.substr(parent.prevOffset, tokenStart - parent.prevOffset);
435
-
436
412
  if (html) {
437
413
  parent.block.innerHTML += html;
438
414
  parent.block.innerContent.push(html);
439
415
  }
440
-
441
416
  parent.block.innerContent.push(null);
442
417
  parent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;
443
418
  }
419
+
444
420
  /**
445
421
  * Adds block from the stack to the output.
446
422
  *
447
423
  * @param {number} [endOffset]
448
424
  */
449
-
450
-
451
425
  function addBlockFromStack(endOffset) {
452
426
  const {
453
427
  block,
454
428
  leadingHtmlStart,
455
429
  prevOffset,
456
430
  tokenStart
457
- } =
458
- /** @type {ParsedFrame} */
459
- stack.pop();
431
+ } = /** @type {ParsedFrame} */stack.pop();
460
432
  const html = endOffset ? document.substr(prevOffset, endOffset - prevOffset) : document.substr(prevOffset);
461
-
462
433
  if (html) {
463
434
  block.innerHTML += html;
464
435
  block.innerContent.push(html);
465
436
  }
466
-
467
437
  if (null !== leadingHtmlStart) {
468
438
  output.push(Freeform(document.substr(leadingHtmlStart, tokenStart - leadingHtmlStart)));
469
439
  }
470
-
471
440
  output.push(block);
472
441
  }
473
442
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-serialization-default-parser/src/index.js"],"names":["document","offset","output","stack","tokenizer","Block","blockName","attrs","innerBlocks","innerHTML","innerContent","Freeform","Frame","block","tokenStart","tokenLength","prevOffset","leadingHtmlStart","parse","doc","lastIndex","proceed","stackDepth","length","next","nextToken","tokenType","startOffset","addFreeform","addBlockFromStack","push","substr","addInnerBlock","stackTop","pop","html","parseJSON","input","JSON","e","matches","exec","startedAt","index","match","closerMatch","namespaceMatch","nameMatch","attrsMatch","voidMatch","isCloser","isVoid","namespace","name","hasAttrs","rawLength","lastOffset","parent","endOffset"],"mappings":"AAAA;AACA;AACA;AACA,IAAIA,QAAJ;AACA;AACA;AACA;;AACA,IAAIC,MAAJ;AACA;AACA;AACA;;AACA,IAAIC,MAAJ;AACA;AACA;AACA;;AACA,IAAIC,KAAJ;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,SAAS,GACd,8HADD;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,KAAT,CAAgBC,SAAhB,EAA2BC,KAA3B,EAAkCC,WAAlC,EAA+CC,SAA/C,EAA0DC,YAA1D,EAAyE;AACxE,SAAO;AACNJ,IAAAA,SADM;AAENC,IAAAA,KAFM;AAGNC,IAAAA,WAHM;AAINC,IAAAA,SAJM;AAKNC,IAAAA;AALM,GAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,QAAT,CAAmBF,SAAnB,EAA+B;AAC9B,SAAOJ,KAAK,CAAE,IAAF,EAAQ,EAAR,EAAY,EAAZ,EAAgBI,SAAhB,EAA2B,CAAEA,SAAF,CAA3B,CAAZ;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASG,KAAT,CAAgBC,KAAhB,EAAuBC,UAAvB,EAAmCC,WAAnC,EAAgDC,UAAhD,EAA4DC,gBAA5D,EAA+E;AAC9E,SAAO;AACNJ,IAAAA,KADM;AAENC,IAAAA,UAFM;AAGNC,IAAAA,WAHM;AAINC,IAAAA,UAAU,EAAEA,UAAU,IAAIF,UAAU,GAAGC,WAJjC;AAKNE,IAAAA;AALM,GAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,MAAMC,KAAK,GAAKC,GAAF,IAAW;AAC/BnB,EAAAA,QAAQ,GAAGmB,GAAX;AACAlB,EAAAA,MAAM,GAAG,CAAT;AACAC,EAAAA,MAAM,GAAG,EAAT;AACAC,EAAAA,KAAK,GAAG,EAAR;AACAC,EAAAA,SAAS,CAACgB,SAAV,GAAsB,CAAtB;;AAEA,KAAG,CACF;AACA,GAFD,QAEUC,OAAO,EAFjB;;AAIA,SAAOnB,MAAP;AACA,CAZM;AAcP;AACA;AACA;AACA;AACA;;AACA,SAASmB,OAAT,GAAmB;AAClB,QAAMC,UAAU,GAAGnB,KAAK,CAACoB,MAAzB;AACA,QAAMC,IAAI,GAAGC,SAAS,EAAtB;AACA,QAAM,CAAEC,SAAF,EAAapB,SAAb,EAAwBC,KAAxB,EAA+BoB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AAGA,UAAH,GAAgB1C,UAAU,GAAGC,WAA3D;AACA;AAED;AACA;AACA;AACA;AACA;;;AACA,SAASc,iBAAT,CAA4B6B,SAA5B,EAAwC;AACvC,QAAM;AAAE7C,IAAAA,KAAF;AAASI,IAAAA,gBAAT;AAA2BD,IAAAA,UAA3B;AAAuCF,IAAAA;AAAvC;AACL;AAA6BX,EAAAA,KAAK,CAAC+B,GAAN,EAD9B;AAGA,QAAMC,IAAI,GAAGuB,SAAS,GACnB1D,QAAQ,CAAC+B,MAAT,CAAiBf,UAAjB,EAA6B0C,SAAS,GAAG1C,UAAzC,CADmB,GAEnBhB,QAAQ,CAAC+B,MAAT,CAAiBf,UAAjB,CAFH;;AAIA,MAAKmB,IAAL,EAAY;AACXtB,IAAAA,KAAK,CAACJ,SAAN,IAAmB0B,IAAnB;AACAtB,IAAAA,KAAK,CAACH,YAAN,CAAmBoB,IAAnB,CAAyBK,IAAzB;AACA;;AAED,MAAK,SAASlB,gBAAd,EAAiC;AAChCf,IAAAA,MAAM,CAAC4B,IAAP,CACCnB,QAAQ,CACPX,QAAQ,CAAC+B,MAAT,CACCd,gBADD,EAECH,UAAU,GAAGG,gBAFd,CADO,CADT;AAQA;;AAEDf,EAAAA,MAAM,CAAC4B,IAAP,CAAajB,KAAb;AACA","sourcesContent":["/**\n * @type {string}\n */\nlet document;\n/**\n * @type {number}\n */\nlet offset;\n/**\n * @type {ParsedBlock[]}\n */\nlet output;\n/**\n * @type {ParsedFrame[]}\n */\nlet stack;\n\n/**\n * @typedef {Object|null} Attributes\n */\n\n/**\n * @typedef {Object} ParsedBlock\n * @property {string|null} blockName Block name.\n * @property {Attributes} attrs Block attributes.\n * @property {ParsedBlock[]} innerBlocks Inner blocks.\n * @property {string} innerHTML Inner HTML.\n * @property {Array<string|null>} innerContent Inner content.\n */\n\n/**\n * @typedef {Object} ParsedFrame\n * @property {ParsedBlock} block Block.\n * @property {number} tokenStart Token start.\n * @property {number} tokenLength Token length.\n * @property {number} prevOffset Previous offset.\n * @property {number|null} leadingHtmlStart Leading HTML start.\n */\n\n/**\n * @typedef {'no-more-tokens'|'void-block'|'block-opener'|'block-closer'} TokenType\n */\n\n/**\n * @typedef {[TokenType, string, Attributes, number, number]} Token\n */\n\n/**\n * Matches block comment delimiters\n *\n * While most of this pattern is straightforward the attribute parsing\n * incorporates a tricks to make sure we don't choke on specific input\n *\n * - since JavaScript has no possessive quantifier or atomic grouping\n * we are emulating it with a trick\n *\n * we want a possessive quantifier or atomic group to prevent backtracking\n * on the `}`s should we fail to match the remainder of the pattern\n *\n * we can emulate this with a positive lookahead and back reference\n * (a++)*c === ((?=(a+))\\1)*c\n *\n * let's examine an example:\n * - /(a+)*c/.test('aaaaaaaaaaaaad') fails after over 49,000 steps\n * - /(a++)*c/.test('aaaaaaaaaaaaad') fails after 85 steps\n * - /(?>a+)*c/.test('aaaaaaaaaaaaad') fails after 126 steps\n *\n * this is because the possessive `++` and the atomic group `(?>)`\n * tell the engine that all those `a`s belong together as a single group\n * and so it won't split it up when stepping backwards to try and match\n *\n * if we use /((?=(a+))\\1)*c/ then we get the same behavior as the atomic group\n * or possessive and prevent the backtracking because the `a+` is matched but\n * not captured. thus, we find the long string of `a`s and remember it, then\n * reference it as a whole unit inside our pattern\n *\n * @see http://instanceof.me/post/52245507631/regex-emulate-atomic-grouping-with-lookahead\n * @see http://blog.stevenlevithan.com/archives/mimic-atomic-groups\n * @see https://javascript.info/regexp-infinite-backtracking-problem\n *\n * once browsers reliably support atomic grouping or possessive\n * quantifiers natively we should remove this trick and simplify\n *\n * @type {RegExp}\n *\n * @since 3.8.0\n * @since 4.6.1 added optimization to prevent backtracking on attribute parsing\n */\nconst tokenizer =\n\t/<!--\\s+(\\/)?wp:([a-z][a-z0-9_-]*\\/)?([a-z][a-z0-9_-]*)\\s+({(?:(?=([^}]+|}+(?=})|(?!}\\s+\\/?-->)[^])*)\\5|[^]*?)}\\s+)?(\\/)?-->/g;\n\n/**\n * Constructs a block object.\n *\n * @param {string|null} blockName\n * @param {Attributes} attrs\n * @param {ParsedBlock[]} innerBlocks\n * @param {string} innerHTML\n * @param {string[]} innerContent\n * @return {ParsedBlock} The block object.\n */\nfunction Block( blockName, attrs, innerBlocks, innerHTML, innerContent ) {\n\treturn {\n\t\tblockName,\n\t\tattrs,\n\t\tinnerBlocks,\n\t\tinnerHTML,\n\t\tinnerContent,\n\t};\n}\n\n/**\n * Constructs a freeform block object.\n *\n * @param {string} innerHTML\n * @return {ParsedBlock} The freeform block object.\n */\nfunction Freeform( innerHTML ) {\n\treturn Block( null, {}, [], innerHTML, [ innerHTML ] );\n}\n\n/**\n * Constructs a frame object.\n *\n * @param {ParsedBlock} block\n * @param {number} tokenStart\n * @param {number} tokenLength\n * @param {number} prevOffset\n * @param {number|null} leadingHtmlStart\n * @return {ParsedFrame} The frame object.\n */\nfunction Frame( block, tokenStart, tokenLength, prevOffset, leadingHtmlStart ) {\n\treturn {\n\t\tblock,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset: prevOffset || tokenStart + tokenLength,\n\t\tleadingHtmlStart,\n\t};\n}\n\n/**\n * Parser function, that converts input HTML into a block based structure.\n *\n * @param {string} doc The HTML document to parse.\n *\n * @example\n * Input post:\n * ```html\n * <!-- wp:columns {\"columns\":3} -->\n * <div class=\"wp-block-columns has-3-columns\"><!-- wp:column -->\n * <div class=\"wp-block-column\"><!-- wp:paragraph -->\n * <p>Left</p>\n * <!-- /wp:paragraph --></div>\n * <!-- /wp:column -->\n *\n * <!-- wp:column -->\n * <div class=\"wp-block-column\"><!-- wp:paragraph -->\n * <p><strong>Middle</strong></p>\n * <!-- /wp:paragraph --></div>\n * <!-- /wp:column -->\n *\n * <!-- wp:column -->\n * <div class=\"wp-block-column\"></div>\n * <!-- /wp:column --></div>\n * <!-- /wp:columns -->\n * ```\n *\n * Parsing code:\n * ```js\n * import { parse } from '@wordpress/block-serialization-default-parser';\n *\n * parse( post ) === [\n * {\n * blockName: \"core/columns\",\n * attrs: {\n * columns: 3\n * },\n * innerBlocks: [\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [\n * {\n * blockName: \"core/paragraph\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: \"\\n<p>Left</p>\\n\"\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * },\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [\n * {\n * blockName: \"core/paragraph\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: \"\\n<p><strong>Middle</strong></p>\\n\"\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * },\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-columns has-3-columns\">\\n\\n\\n\\n</div>\\n'\n * }\n * ];\n * ```\n * @return {ParsedBlock[]} A block-based representation of the input HTML.\n */\nexport const parse = ( doc ) => {\n\tdocument = doc;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed() );\n\n\treturn output;\n};\n\n/**\n * Parses the next token in the input document.\n *\n * @return {boolean} Returns true when there is more tokens to parse.\n */\nfunction proceed() {\n\tconst stackDepth = stack.length;\n\tconst next = nextToken();\n\tconst [ tokenType, blockName, attrs, startOffset, tokenLength ] = next;\n\n\t// We may have some HTML soup before the next block.\n\tconst leadingHtmlStart = startOffset > offset ? offset : null;\n\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\t// If not in a block then flush output.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\taddFreeform();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Otherwise we have a problem\n\t\t\t// This is an error\n\t\t\t// we have options\n\t\t\t// - treat it all as freeform text\n\t\t\t// - assume an implicit closer (easiest when not nesting)\n\n\t\t\t// For the easy case we'll assume an implicit closer.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\taddBlockFromStack();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// For the nested case where it's more difficult we'll\n\t\t\t// have to assume that multiple closers are missing\n\t\t\t// and so we'll collapse the whole stack piecewise.\n\t\t\twhile ( 0 < stack.length ) {\n\t\t\t\taddBlockFromStack();\n\t\t\t}\n\t\t\treturn false;\n\t\tcase 'void-block':\n\t\t\t// easy case is if we stumbled upon a void block\n\t\t\t// in the top-level of the document.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingHtmlStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tFreeform(\n\t\t\t\t\t\t\tdocument.substr(\n\t\t\t\t\t\t\t\tleadingHtmlStart,\n\t\t\t\t\t\t\t\tstartOffset - leadingHtmlStart\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( Block( blockName, attrs, [], '', [] ) );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner block.\n\t\t\taddInnerBlock(\n\t\t\t\tBlock( blockName, attrs, [], '', [] ),\n\t\t\t\tstartOffset,\n\t\t\t\ttokenLength\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'block-opener':\n\t\t\t// Track all newly-opened blocks on the stack.\n\t\t\tstack.push(\n\t\t\t\tFrame(\n\t\t\t\t\tBlock( blockName, attrs, [], '', [] ),\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingHtmlStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'block-closer':\n\t\t\t// If we're missing an opener we're in trouble\n\t\t\t// This is an error.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\t// We have options\n\t\t\t\t// - assume an implicit opener\n\t\t\t\t// - assume _this_ is the opener\n\t\t\t\t// - give up and close out the document.\n\t\t\t\taddFreeform();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\taddBlockFromStack( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = /** @type {ParsedFrame} */ ( stack.pop() );\n\t\t\tconst html = document.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.block.innerHTML += html;\n\t\t\tstackTop.block.innerContent.push( html );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\n\t\t\taddInnerBlock(\n\t\t\t\tstackTop.block,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\t// This is an error.\n\t\t\taddFreeform();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Parse JSON if valid, otherwise return null\n *\n * Note that JSON coming from the block comment\n * delimiters is constrained to be an object\n * and cannot be things like `true` or `null`\n *\n * @param {string} input JSON input string to parse\n * @return {Object|null} parsed JSON if valid\n */\nfunction parseJSON( input ) {\n\ttry {\n\t\treturn JSON.parse( input );\n\t} catch ( e ) {\n\t\treturn null;\n\t}\n}\n\n/**\n * Finds the next token in the document.\n *\n * @return {Token} The next matched token.\n */\nfunction nextToken() {\n\t// Aye the magic\n\t// we're using a single RegExp to tokenize the block comment delimiters\n\t// we're also using a trick here because the only difference between a\n\t// block opener and a block closer is the leading `/` before `wp:` (and\n\t// a closer has no attributes). we can trap them both and process the\n\t// match back in JavaScript to see which one it was.\n\tconst matches = tokenizer.exec( document );\n\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens', '', null, 0, 0 ];\n\t}\n\n\tconst startedAt = matches.index;\n\tconst [\n\t\tmatch,\n\t\tcloserMatch,\n\t\tnamespaceMatch,\n\t\tnameMatch,\n\t\tattrsMatch /* Internal/unused. */,\n\t\t,\n\t\tvoidMatch,\n\t] = matches;\n\n\tconst length = match.length;\n\tconst isCloser = !! closerMatch;\n\tconst isVoid = !! voidMatch;\n\tconst namespace = namespaceMatch || 'core/';\n\tconst name = namespace + nameMatch;\n\tconst hasAttrs = !! attrsMatch;\n\tconst attrs = hasAttrs ? parseJSON( attrsMatch ) : {};\n\n\t// This state isn't allowed\n\t// This is an error.\n\tif ( isCloser && ( isVoid || hasAttrs ) ) {\n\t\t// We can ignore them since they don't hurt anything\n\t\t// we may warn against this at some point or reject it.\n\t}\n\n\tif ( isVoid ) {\n\t\treturn [ 'void-block', name, attrs, startedAt, length ];\n\t}\n\n\tif ( isCloser ) {\n\t\treturn [ 'block-closer', name, null, startedAt, length ];\n\t}\n\n\treturn [ 'block-opener', name, attrs, startedAt, length ];\n}\n\n/**\n * Adds a freeform block to the output.\n *\n * @param {number} [rawLength]\n */\nfunction addFreeform( rawLength ) {\n\tconst length = rawLength ? rawLength : document.length - offset;\n\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\n\toutput.push( Freeform( document.substr( offset, length ) ) );\n}\n\n/**\n * Adds inner block to the parent block.\n *\n * @param {ParsedBlock} block\n * @param {number} tokenStart\n * @param {number} tokenLength\n * @param {number} [lastOffset]\n */\nfunction addInnerBlock( block, tokenStart, tokenLength, lastOffset ) {\n\tconst parent = stack[ stack.length - 1 ];\n\tparent.block.innerBlocks.push( block );\n\tconst html = document.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( html ) {\n\t\tparent.block.innerHTML += html;\n\t\tparent.block.innerContent.push( html );\n\t}\n\n\tparent.block.innerContent.push( null );\n\tparent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;\n}\n\n/**\n * Adds block from the stack to the output.\n *\n * @param {number} [endOffset]\n */\nfunction addBlockFromStack( endOffset ) {\n\tconst { block, leadingHtmlStart, prevOffset, tokenStart } =\n\t\t/** @type {ParsedFrame} */ ( stack.pop() );\n\n\tconst html = endOffset\n\t\t? document.substr( prevOffset, endOffset - prevOffset )\n\t\t: document.substr( prevOffset );\n\n\tif ( html ) {\n\t\tblock.innerHTML += html;\n\t\tblock.innerContent.push( html );\n\t}\n\n\tif ( null !== leadingHtmlStart ) {\n\t\toutput.push(\n\t\t\tFreeform(\n\t\t\t\tdocument.substr(\n\t\t\t\t\tleadingHtmlStart,\n\t\t\t\t\ttokenStart - leadingHtmlStart\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n\n\toutput.push( block );\n}\n"]}
1
+ {"version":3,"names":["document","offset","output","stack","tokenizer","Block","blockName","attrs","innerBlocks","innerHTML","innerContent","Freeform","Frame","block","tokenStart","tokenLength","prevOffset","leadingHtmlStart","parse","doc","lastIndex","proceed","stackDepth","length","next","nextToken","tokenType","startOffset","addFreeform","addBlockFromStack","push","substr","addInnerBlock","stackTop","pop","html","parseJSON","input","JSON","e","matches","exec","startedAt","index","match","closerMatch","namespaceMatch","nameMatch","attrsMatch","voidMatch","isCloser","isVoid","namespace","name","hasAttrs","rawLength","lastOffset","parent","endOffset"],"sources":["@wordpress/block-serialization-default-parser/src/index.js"],"sourcesContent":["/**\n * @type {string}\n */\nlet document;\n/**\n * @type {number}\n */\nlet offset;\n/**\n * @type {ParsedBlock[]}\n */\nlet output;\n/**\n * @type {ParsedFrame[]}\n */\nlet stack;\n\n/**\n * @typedef {Object|null} Attributes\n */\n\n/**\n * @typedef {Object} ParsedBlock\n * @property {string|null} blockName Block name.\n * @property {Attributes} attrs Block attributes.\n * @property {ParsedBlock[]} innerBlocks Inner blocks.\n * @property {string} innerHTML Inner HTML.\n * @property {Array<string|null>} innerContent Inner content.\n */\n\n/**\n * @typedef {Object} ParsedFrame\n * @property {ParsedBlock} block Block.\n * @property {number} tokenStart Token start.\n * @property {number} tokenLength Token length.\n * @property {number} prevOffset Previous offset.\n * @property {number|null} leadingHtmlStart Leading HTML start.\n */\n\n/**\n * @typedef {'no-more-tokens'|'void-block'|'block-opener'|'block-closer'} TokenType\n */\n\n/**\n * @typedef {[TokenType, string, Attributes, number, number]} Token\n */\n\n/**\n * Matches block comment delimiters\n *\n * While most of this pattern is straightforward the attribute parsing\n * incorporates a tricks to make sure we don't choke on specific input\n *\n * - since JavaScript has no possessive quantifier or atomic grouping\n * we are emulating it with a trick\n *\n * we want a possessive quantifier or atomic group to prevent backtracking\n * on the `}`s should we fail to match the remainder of the pattern\n *\n * we can emulate this with a positive lookahead and back reference\n * (a++)*c === ((?=(a+))\\1)*c\n *\n * let's examine an example:\n * - /(a+)*c/.test('aaaaaaaaaaaaad') fails after over 49,000 steps\n * - /(a++)*c/.test('aaaaaaaaaaaaad') fails after 85 steps\n * - /(?>a+)*c/.test('aaaaaaaaaaaaad') fails after 126 steps\n *\n * this is because the possessive `++` and the atomic group `(?>)`\n * tell the engine that all those `a`s belong together as a single group\n * and so it won't split it up when stepping backwards to try and match\n *\n * if we use /((?=(a+))\\1)*c/ then we get the same behavior as the atomic group\n * or possessive and prevent the backtracking because the `a+` is matched but\n * not captured. thus, we find the long string of `a`s and remember it, then\n * reference it as a whole unit inside our pattern\n *\n * @see http://instanceof.me/post/52245507631/regex-emulate-atomic-grouping-with-lookahead\n * @see http://blog.stevenlevithan.com/archives/mimic-atomic-groups\n * @see https://javascript.info/regexp-infinite-backtracking-problem\n *\n * once browsers reliably support atomic grouping or possessive\n * quantifiers natively we should remove this trick and simplify\n *\n * @type {RegExp}\n *\n * @since 3.8.0\n * @since 4.6.1 added optimization to prevent backtracking on attribute parsing\n */\nconst tokenizer =\n\t/<!--\\s+(\\/)?wp:([a-z][a-z0-9_-]*\\/)?([a-z][a-z0-9_-]*)\\s+({(?:(?=([^}]+|}+(?=})|(?!}\\s+\\/?-->)[^])*)\\5|[^]*?)}\\s+)?(\\/)?-->/g;\n\n/**\n * Constructs a block object.\n *\n * @param {string|null} blockName\n * @param {Attributes} attrs\n * @param {ParsedBlock[]} innerBlocks\n * @param {string} innerHTML\n * @param {string[]} innerContent\n * @return {ParsedBlock} The block object.\n */\nfunction Block( blockName, attrs, innerBlocks, innerHTML, innerContent ) {\n\treturn {\n\t\tblockName,\n\t\tattrs,\n\t\tinnerBlocks,\n\t\tinnerHTML,\n\t\tinnerContent,\n\t};\n}\n\n/**\n * Constructs a freeform block object.\n *\n * @param {string} innerHTML\n * @return {ParsedBlock} The freeform block object.\n */\nfunction Freeform( innerHTML ) {\n\treturn Block( null, {}, [], innerHTML, [ innerHTML ] );\n}\n\n/**\n * Constructs a frame object.\n *\n * @param {ParsedBlock} block\n * @param {number} tokenStart\n * @param {number} tokenLength\n * @param {number} prevOffset\n * @param {number|null} leadingHtmlStart\n * @return {ParsedFrame} The frame object.\n */\nfunction Frame( block, tokenStart, tokenLength, prevOffset, leadingHtmlStart ) {\n\treturn {\n\t\tblock,\n\t\ttokenStart,\n\t\ttokenLength,\n\t\tprevOffset: prevOffset || tokenStart + tokenLength,\n\t\tleadingHtmlStart,\n\t};\n}\n\n/**\n * Parser function, that converts input HTML into a block based structure.\n *\n * @param {string} doc The HTML document to parse.\n *\n * @example\n * Input post:\n * ```html\n * <!-- wp:columns {\"columns\":3} -->\n * <div class=\"wp-block-columns has-3-columns\"><!-- wp:column -->\n * <div class=\"wp-block-column\"><!-- wp:paragraph -->\n * <p>Left</p>\n * <!-- /wp:paragraph --></div>\n * <!-- /wp:column -->\n *\n * <!-- wp:column -->\n * <div class=\"wp-block-column\"><!-- wp:paragraph -->\n * <p><strong>Middle</strong></p>\n * <!-- /wp:paragraph --></div>\n * <!-- /wp:column -->\n *\n * <!-- wp:column -->\n * <div class=\"wp-block-column\"></div>\n * <!-- /wp:column --></div>\n * <!-- /wp:columns -->\n * ```\n *\n * Parsing code:\n * ```js\n * import { parse } from '@wordpress/block-serialization-default-parser';\n *\n * parse( post ) === [\n * {\n * blockName: \"core/columns\",\n * attrs: {\n * columns: 3\n * },\n * innerBlocks: [\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [\n * {\n * blockName: \"core/paragraph\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: \"\\n<p>Left</p>\\n\"\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * },\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [\n * {\n * blockName: \"core/paragraph\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: \"\\n<p><strong>Middle</strong></p>\\n\"\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * },\n * {\n * blockName: \"core/column\",\n * attrs: null,\n * innerBlocks: [],\n * innerHTML: '\\n<div class=\"wp-block-column\"></div>\\n'\n * }\n * ],\n * innerHTML: '\\n<div class=\"wp-block-columns has-3-columns\">\\n\\n\\n\\n</div>\\n'\n * }\n * ];\n * ```\n * @return {ParsedBlock[]} A block-based representation of the input HTML.\n */\nexport const parse = ( doc ) => {\n\tdocument = doc;\n\toffset = 0;\n\toutput = [];\n\tstack = [];\n\ttokenizer.lastIndex = 0;\n\n\tdo {\n\t\t// twiddle our thumbs\n\t} while ( proceed() );\n\n\treturn output;\n};\n\n/**\n * Parses the next token in the input document.\n *\n * @return {boolean} Returns true when there is more tokens to parse.\n */\nfunction proceed() {\n\tconst stackDepth = stack.length;\n\tconst next = nextToken();\n\tconst [ tokenType, blockName, attrs, startOffset, tokenLength ] = next;\n\n\t// We may have some HTML soup before the next block.\n\tconst leadingHtmlStart = startOffset > offset ? offset : null;\n\n\tswitch ( tokenType ) {\n\t\tcase 'no-more-tokens':\n\t\t\t// If not in a block then flush output.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\taddFreeform();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// Otherwise we have a problem\n\t\t\t// This is an error\n\t\t\t// we have options\n\t\t\t// - treat it all as freeform text\n\t\t\t// - assume an implicit closer (easiest when not nesting)\n\n\t\t\t// For the easy case we'll assume an implicit closer.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\taddBlockFromStack();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// For the nested case where it's more difficult we'll\n\t\t\t// have to assume that multiple closers are missing\n\t\t\t// and so we'll collapse the whole stack piecewise.\n\t\t\twhile ( 0 < stack.length ) {\n\t\t\t\taddBlockFromStack();\n\t\t\t}\n\t\t\treturn false;\n\t\tcase 'void-block':\n\t\t\t// easy case is if we stumbled upon a void block\n\t\t\t// in the top-level of the document.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\tif ( null !== leadingHtmlStart ) {\n\t\t\t\t\toutput.push(\n\t\t\t\t\t\tFreeform(\n\t\t\t\t\t\t\tdocument.substr(\n\t\t\t\t\t\t\t\tleadingHtmlStart,\n\t\t\t\t\t\t\t\tstartOffset - leadingHtmlStart\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\toutput.push( Block( blockName, attrs, [], '', [] ) );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we found an inner block.\n\t\t\taddInnerBlock(\n\t\t\t\tBlock( blockName, attrs, [], '', [] ),\n\t\t\t\tstartOffset,\n\t\t\t\ttokenLength\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'block-opener':\n\t\t\t// Track all newly-opened blocks on the stack.\n\t\t\tstack.push(\n\t\t\t\tFrame(\n\t\t\t\t\tBlock( blockName, attrs, [], '', [] ),\n\t\t\t\t\tstartOffset,\n\t\t\t\t\ttokenLength,\n\t\t\t\t\tstartOffset + tokenLength,\n\t\t\t\t\tleadingHtmlStart\n\t\t\t\t)\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tcase 'block-closer':\n\t\t\t// If we're missing an opener we're in trouble\n\t\t\t// This is an error.\n\t\t\tif ( 0 === stackDepth ) {\n\t\t\t\t// We have options\n\t\t\t\t// - assume an implicit opener\n\t\t\t\t// - assume _this_ is the opener\n\t\t\t\t// - give up and close out the document.\n\t\t\t\taddFreeform();\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\t// If we're not nesting then this is easy - close the block.\n\t\t\tif ( 1 === stackDepth ) {\n\t\t\t\taddBlockFromStack( startOffset );\n\t\t\t\toffset = startOffset + tokenLength;\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\t// Otherwise we're nested and we have to close out the current\n\t\t\t// block and add it as a innerBlock to the parent.\n\t\t\tconst stackTop = /** @type {ParsedFrame} */ ( stack.pop() );\n\t\t\tconst html = document.substr(\n\t\t\t\tstackTop.prevOffset,\n\t\t\t\tstartOffset - stackTop.prevOffset\n\t\t\t);\n\t\t\tstackTop.block.innerHTML += html;\n\t\t\tstackTop.block.innerContent.push( html );\n\t\t\tstackTop.prevOffset = startOffset + tokenLength;\n\n\t\t\taddInnerBlock(\n\t\t\t\tstackTop.block,\n\t\t\t\tstackTop.tokenStart,\n\t\t\t\tstackTop.tokenLength,\n\t\t\t\tstartOffset + tokenLength\n\t\t\t);\n\t\t\toffset = startOffset + tokenLength;\n\t\t\treturn true;\n\n\t\tdefault:\n\t\t\t// This is an error.\n\t\t\taddFreeform();\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Parse JSON if valid, otherwise return null\n *\n * Note that JSON coming from the block comment\n * delimiters is constrained to be an object\n * and cannot be things like `true` or `null`\n *\n * @param {string} input JSON input string to parse\n * @return {Object|null} parsed JSON if valid\n */\nfunction parseJSON( input ) {\n\ttry {\n\t\treturn JSON.parse( input );\n\t} catch ( e ) {\n\t\treturn null;\n\t}\n}\n\n/**\n * Finds the next token in the document.\n *\n * @return {Token} The next matched token.\n */\nfunction nextToken() {\n\t// Aye the magic\n\t// we're using a single RegExp to tokenize the block comment delimiters\n\t// we're also using a trick here because the only difference between a\n\t// block opener and a block closer is the leading `/` before `wp:` (and\n\t// a closer has no attributes). we can trap them both and process the\n\t// match back in JavaScript to see which one it was.\n\tconst matches = tokenizer.exec( document );\n\n\t// We have no more tokens.\n\tif ( null === matches ) {\n\t\treturn [ 'no-more-tokens', '', null, 0, 0 ];\n\t}\n\n\tconst startedAt = matches.index;\n\tconst [\n\t\tmatch,\n\t\tcloserMatch,\n\t\tnamespaceMatch,\n\t\tnameMatch,\n\t\tattrsMatch /* Internal/unused. */,\n\t\t,\n\t\tvoidMatch,\n\t] = matches;\n\n\tconst length = match.length;\n\tconst isCloser = !! closerMatch;\n\tconst isVoid = !! voidMatch;\n\tconst namespace = namespaceMatch || 'core/';\n\tconst name = namespace + nameMatch;\n\tconst hasAttrs = !! attrsMatch;\n\tconst attrs = hasAttrs ? parseJSON( attrsMatch ) : {};\n\n\t// This state isn't allowed\n\t// This is an error.\n\tif ( isCloser && ( isVoid || hasAttrs ) ) {\n\t\t// We can ignore them since they don't hurt anything\n\t\t// we may warn against this at some point or reject it.\n\t}\n\n\tif ( isVoid ) {\n\t\treturn [ 'void-block', name, attrs, startedAt, length ];\n\t}\n\n\tif ( isCloser ) {\n\t\treturn [ 'block-closer', name, null, startedAt, length ];\n\t}\n\n\treturn [ 'block-opener', name, attrs, startedAt, length ];\n}\n\n/**\n * Adds a freeform block to the output.\n *\n * @param {number} [rawLength]\n */\nfunction addFreeform( rawLength ) {\n\tconst length = rawLength ? rawLength : document.length - offset;\n\n\tif ( 0 === length ) {\n\t\treturn;\n\t}\n\n\toutput.push( Freeform( document.substr( offset, length ) ) );\n}\n\n/**\n * Adds inner block to the parent block.\n *\n * @param {ParsedBlock} block\n * @param {number} tokenStart\n * @param {number} tokenLength\n * @param {number} [lastOffset]\n */\nfunction addInnerBlock( block, tokenStart, tokenLength, lastOffset ) {\n\tconst parent = stack[ stack.length - 1 ];\n\tparent.block.innerBlocks.push( block );\n\tconst html = document.substr(\n\t\tparent.prevOffset,\n\t\ttokenStart - parent.prevOffset\n\t);\n\n\tif ( html ) {\n\t\tparent.block.innerHTML += html;\n\t\tparent.block.innerContent.push( html );\n\t}\n\n\tparent.block.innerContent.push( null );\n\tparent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;\n}\n\n/**\n * Adds block from the stack to the output.\n *\n * @param {number} [endOffset]\n */\nfunction addBlockFromStack( endOffset ) {\n\tconst { block, leadingHtmlStart, prevOffset, tokenStart } =\n\t\t/** @type {ParsedFrame} */ ( stack.pop() );\n\n\tconst html = endOffset\n\t\t? document.substr( prevOffset, endOffset - prevOffset )\n\t\t: document.substr( prevOffset );\n\n\tif ( html ) {\n\t\tblock.innerHTML += html;\n\t\tblock.innerContent.push( html );\n\t}\n\n\tif ( null !== leadingHtmlStart ) {\n\t\toutput.push(\n\t\t\tFreeform(\n\t\t\t\tdocument.substr(\n\t\t\t\t\tleadingHtmlStart,\n\t\t\t\t\ttokenStart - leadingHtmlStart\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n\n\toutput.push( block );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,IAAIA,QAAQ;AACZ;AACA;AACA;AACA,IAAIC,MAAM;AACV;AACA;AACA;AACA,IAAIC,MAAM;AACV;AACA;AACA;AACA,IAAIC,KAAK;;AAET;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,GACd,8HAA8H;;AAE/H;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,KAAKA,CAAEC,SAAS,EAAEC,KAAK,EAAEC,WAAW,EAAEC,SAAS,EAAEC,YAAY,EAAG;EACxE,OAAO;IACNJ,SAAS;IACTC,KAAK;IACLC,WAAW;IACXC,SAAS;IACTC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAAEF,SAAS,EAAG;EAC9B,OAAOJ,KAAK,CAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,EAAEI,SAAS,EAAE,CAAEA,SAAS,CAAG,CAAC;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASG,KAAKA,CAAEC,KAAK,EAAEC,UAAU,EAAEC,WAAW,EAAEC,UAAU,EAAEC,gBAAgB,EAAG;EAC9E,OAAO;IACNJ,KAAK;IACLC,UAAU;IACVC,WAAW;IACXC,UAAU,EAAEA,UAAU,IAAIF,UAAU,GAAGC,WAAW;IAClDE;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAKC,GAAG,IAAM;EAC/BnB,QAAQ,GAAGmB,GAAG;EACdlB,M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C5C,KAAK,CAACJ,SAAS,IAAI0B,IAAI;IAC9BsB,MAAM,CAAC5C,KAAK,CAACH,YAAY,CAACoB,IAAI,CAAEK,IAAK,CAAC;EACvC;EAEAsB,MAAM,CAAC5C,KAAK,CAACH,YAAY,CAACoB,IAAI,CAAE,IAAK,CAAC;EACtC2B,MAAM,CAACzC,UAAU,GAAGwC,UAAU,GAAGA,UAAU,GAAG1C,UAAU,GAAGC,WAAW;AACvE;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASc,iBAAiBA,CAAE6B,SAAS,EAAG;EACvC,MAAM;IAAE7C,KAAK;IAAEI,gBAAgB;IAAED,UAAU;IAAEF;EAAW,CAAC,GACxD,0BAA6BX,KAAK,CAAC+B,GAAG,CAAC,CAAG;EAE3C,MAAMC,IAAI,GAAGuB,SAAS,GACnB1D,QAAQ,CAAC+B,MAAM,CAAEf,UAAU,EAAE0C,SAAS,GAAG1C,UAAW,CAAC,GACrDhB,QAAQ,CAAC+B,MAAM,CAAEf,UAAW,CAAC;EAEhC,IAAKmB,IAAI,EAAG;IACXtB,KAAK,CAACJ,SAAS,IAAI0B,IAAI;IACvBtB,KAAK,CAACH,YAAY,CAACoB,IAAI,CAAEK,IAAK,CAAC;EAChC;EAEA,IAAK,IAAI,KAAKlB,gBAAgB,EAAG;IAChCf,MAAM,CAAC4B,IAAI,CACVnB,QAAQ,CACPX,QAAQ,CAAC+B,MAAM,CACdd,gBAAgB,EAChBH,UAAU,GAAGG,gBACd,CACD,CACD,CAAC;EACF;EAEAf,MAAM,CAAC4B,IAAI,CAAEjB,KAAM,CAAC;AACrB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-serialization-default-parser",
3
- "version": "4.39.0",
3
+ "version": "4.40.0",
4
4
  "description": "Block serialization specification parser for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "b898cf1dc8e70841d1647ea0994ac6278acc18a7"
36
+ "gitHead": "78a288d55b83a713b2f7d98d5a855c0771a2afc6"
37
37
  }
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","./src/index.js"],"fileInfos":[{"version":"8730f4bf322026ff5229336391a18bcaa1f94d4f82416c8b2f3954e2ccaae2ba","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","4b421cbfb3a38a27c279dec1e9112c3d1da296f77a1a85ddadf7e7a425d45d18","1fc5ab7a764205c68fa10d381b08417795fc73111d6dd16b5b1ed36badb743d9","746d62152361558ea6d6115cf0da4dd10ede041d14882ede3568bce5dc4b4f1f","d11a03592451da2d1065e09e61f4e2a9bf68f780f4f6623c18b57816a9679d17","aea179452def8a6152f98f63b191b84e7cbd69b0e248c91e61fb2e52328abe8c",{"version":"3aafcb693fe5b5c3bd277bd4c3a617b53db474fe498fc5df067c5603b1eebde7","affectsGlobalScope":true},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"8cc8c5a3bac513368b0157f3d8b31cfdcfe78b56d3724f30f80ed9715e404af8","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"5f406584aef28a331c36523df688ca3650288d14f39c5d2e555c95f0d2ff8f6f","affectsGlobalScope":true},{"version":"22f230e544b35349cfb3bd9110b6ef37b41c6d6c43c3314a31bd0d9652fcec72","affectsGlobalScope":true},{"version":"7ea0b55f6b315cf9ac2ad622b0a7813315bb6e97bf4bb3fbf8f8affbca7dc695","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"eb26de841c52236d8222f87e9e6a235332e0788af8c87a71e9e210314300410a","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"81cac4cbc92c0c839c70f8ffb94eb61e2d32dc1c3cf6d95844ca099463cf37ea","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"5e5e095c4470c8bab227dbbc61374878ecead104c74ab9960d3adcccfee23205","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"d7f680a43f8cd12a6b6122c07c54ba40952b0c8aa140dcfcf32eb9e6cb028596","affectsGlobalScope":true},{"version":"3787b83e297de7c315d55d4a7c546ae28e5f6c0a361b7a1dcec1f1f50a54ef11","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"2768ef564cfc0689a1b76106c421a2909bdff0acbe87da010785adab80efdd5c","affectsGlobalScope":true},{"version":"b248e32ca52e8f5571390a4142558ae4f203ae2f94d5bac38a3084d529ef4e58","affectsGlobalScope":true},{"version":"6c55633c733c8378db65ac3da7a767c3cf2cf3057f0565a9124a16a3a2019e87","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"34c839eaaa6d78c8674ae2c37af2236dee6831b13db7b4ef4df3ec889a04d4f2","affectsGlobalScope":true},{"version":"34478567f8a80171f88f2f30808beb7da15eac0538ae91282dd33dce928d98ed","affectsGlobalScope":true},{"version":"ab7d58e6161a550ff92e5aff755dc37fe896245348332cd5f1e1203479fe0ed1","affectsGlobalScope":true},{"version":"6bda95ea27a59a276e46043b7065b55bd4b316c25e70e29b572958fa77565d43","affectsGlobalScope":true},{"version":"aedb8de1abb2ff1095c153854a6df7deae4a5709c37297f9d6e9948b6806fa66","affectsGlobalScope":true},{"version":"a4da0551fd39b90ca7ce5f68fb55d4dc0c1396d589b612e1902f68ee090aaada","affectsGlobalScope":true},{"version":"11ffe3c281f375fff9ffdde8bbec7669b4dd671905509079f866f2354a788064","affectsGlobalScope":true},{"version":"52d1bb7ab7a3306fd0375c8bff560feed26ed676a5b0457fa8027b563aecb9a4","affectsGlobalScope":true},{"version":"58952a7b2f2f6addeef2d390abb23d8b4f054070c7683966bad06595fa1f27e6","signature":"60c3c76700403b9c3d9398b279b86256c7d79df5096899a34f76c9530bb57ff2"}],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[11,13,12,2,14,15,16,17,18,19,20,21,3,4,25,22,23,24,26,27,28,5,29,30,31,32,6,36,33,34,35,37,7,38,43,44,39,40,41,42,8,48,45,46,47,49,9,50,51,52,53,54,1,10,55,56],"latestChangedDtsFile":"./build-types/index.d.ts"},"version":"4.9.5"}
1
+ {"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.es2022.d.ts","../../node_modules/typescript/lib/lib.es2023.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../node_modules/typescript/lib/lib.es2023.array.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","./src/index.js"],"fileInfos":[{"version":"f59215c5f1d886b05395ee7aca73e0ac69ddfad2843aa88530e797879d511bad","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","f4e736d6c8d69ae5b3ab0ddfcaa3dc365c3e76909d6660af5b4e979b3934ac20","eeeb3aca31fbadef8b82502484499dfd1757204799a6f5b33116201c810676ec",{"version":"3dda5344576193a4ae48b8d03f105c86f20b2f2aff0a1d1fd7935f5d68649654","affectsGlobalScope":true},{"version":"9d9885c728913c1d16e0d2831b40341d6ad9a0ceecaabc55209b306ad9c736a5","affectsGlobalScope":true},{"version":"17bea081b9c0541f39dd1ae9bc8c78bdd561879a682e60e2f25f688c0ecab248","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"f06948deb2a51aae25184561c9640fb66afeddb34531a9212d011792b1d19e0a","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"709efdae0cb5df5f49376cde61daacc95cdd44ae4671da13a540da5088bf3f30","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"61ed9b6d07af959e745fb11f9593ecd743b279418cc8a99448ea3cd5f3b3eb22","affectsGlobalScope":true},{"version":"038a2f66a34ee7a9c2fbc3584c8ab43dff2995f8c68e3f566f4c300d2175e31e","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"f5c92f2c27b06c1a41b88f6db8299205aee52c2a2943f7ed29bd585977f254e8","affectsGlobalScope":true},{"version":"930b0e15811f84e203d3c23508674d5ded88266df4b10abee7b31b2ac77632d2","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"b9ea5778ff8b50d7c04c9890170db34c26a5358cccba36844fe319f50a43a61a","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"25de46552b782d43cb7284df22fe2a265de387cf0248b747a7a1b647d81861f6","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},{"version":"58952a7b2f2f6addeef2d390abb23d8b4f054070c7683966bad06595fa1f27e6","signature":"60c3c76700403b9c3d9398b279b86256c7d79df5096899a34f76c9530bb57ff2"}],"root":[61],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[59,60,12,14,13,2,15,16,17,18,19,20,21,22,3,4,26,23,24,25,27,28,29,5,30,31,32,33,6,37,34,35,36,38,7,39,44,45,40,41,42,43,8,49,46,47,48,50,9,51,52,53,56,54,55,57,10,1,11,58,61],"latestChangedDtsFile":"./build-types/index.d.ts"},"version":"5.1.6"}