@wordpress/block-serialization-default-parser 5.26.1-next.719a03cbe.0 → 5.27.1-next.46f643fa0.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 +2 -0
- package/build/index.js +30 -73
- package/build/index.js.map +1 -1
- package/build-module/index.js +30 -73
- package/build-module/index.js.map +1 -1
- package/build-types/index.d.ts +81 -42
- package/build-types/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/{index.js → index.ts} +84 -83
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/build/index.js
CHANGED
|
@@ -4,53 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.parse = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* @type {string}
|
|
9
|
-
*/
|
|
10
7
|
let document;
|
|
11
|
-
/**
|
|
12
|
-
* @type {number}
|
|
13
|
-
*/
|
|
14
8
|
let offset;
|
|
15
|
-
/**
|
|
16
|
-
* @type {ParsedBlock[]}
|
|
17
|
-
*/
|
|
18
9
|
let output;
|
|
19
|
-
/**
|
|
20
|
-
* @type {ParsedFrame[]}
|
|
21
|
-
*/
|
|
22
10
|
let stack;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @typedef {Object|null} Attributes
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @typedef {Object} ParsedBlock
|
|
30
|
-
* @property {string|null} blockName Block name.
|
|
31
|
-
* @property {Attributes} attrs Block attributes.
|
|
32
|
-
* @property {ParsedBlock[]} innerBlocks Inner blocks.
|
|
33
|
-
* @property {string} innerHTML Inner HTML.
|
|
34
|
-
* @property {Array<string|null>} innerContent Inner content.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @typedef {Object} ParsedFrame
|
|
39
|
-
* @property {ParsedBlock} block Block.
|
|
40
|
-
* @property {number} tokenStart Token start.
|
|
41
|
-
* @property {number} tokenLength Token length.
|
|
42
|
-
* @property {number} prevOffset Previous offset.
|
|
43
|
-
* @property {number|null} leadingHtmlStart Leading HTML start.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @typedef {'no-more-tokens'|'void-block'|'block-opener'|'block-closer'} TokenType
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @typedef {[TokenType, string, Attributes, number, number]} Token
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
11
|
/**
|
|
55
12
|
* Matches block comment delimiters
|
|
56
13
|
*
|
|
@@ -87,8 +44,6 @@ let stack;
|
|
|
87
44
|
* once browsers reliably support atomic grouping or possessive
|
|
88
45
|
* quantifiers natively we should remove this trick and simplify
|
|
89
46
|
*
|
|
90
|
-
* @type {RegExp}
|
|
91
|
-
*
|
|
92
47
|
* @since 3.8.0
|
|
93
48
|
* @since 4.6.1 added optimization to prevent backtracking on attribute parsing
|
|
94
49
|
*/
|
|
@@ -97,12 +52,13 @@ const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?
|
|
|
97
52
|
/**
|
|
98
53
|
* Constructs a block object.
|
|
99
54
|
*
|
|
100
|
-
* @param
|
|
101
|
-
*
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @
|
|
55
|
+
* @param blockName Either the abbreviated core types, e.g. "paragraph", or the fully-qualified
|
|
56
|
+
* block type with namespace and type, e.g. "core/paragraph" or "my-plugin/csv-table".
|
|
57
|
+
* @param attrs The attributes for the block, or null if there are no attributes.
|
|
58
|
+
* @param innerBlocks An array of inner blocks.
|
|
59
|
+
* @param innerHTML The inner HTML of the block.
|
|
60
|
+
* @param innerContent An array of inner content strings.
|
|
61
|
+
* @return The block object.
|
|
106
62
|
*/
|
|
107
63
|
function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
|
|
108
64
|
return {
|
|
@@ -117,8 +73,8 @@ function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
|
|
|
117
73
|
/**
|
|
118
74
|
* Constructs a freeform block object.
|
|
119
75
|
*
|
|
120
|
-
* @param
|
|
121
|
-
* @return
|
|
76
|
+
* @param innerHTML The inner HTML of the block.
|
|
77
|
+
* @return The freeform block object.
|
|
122
78
|
*/
|
|
123
79
|
function Freeform(innerHTML) {
|
|
124
80
|
return Block(null, {}, [], innerHTML, [innerHTML]);
|
|
@@ -127,12 +83,12 @@ function Freeform(innerHTML) {
|
|
|
127
83
|
/**
|
|
128
84
|
* Constructs a frame object.
|
|
129
85
|
*
|
|
130
|
-
* @param
|
|
131
|
-
* @param
|
|
132
|
-
* @param
|
|
133
|
-
* @param
|
|
134
|
-
* @param
|
|
135
|
-
* @return
|
|
86
|
+
* @param block The block object.
|
|
87
|
+
* @param tokenStart The start offset of the token in the document.
|
|
88
|
+
* @param tokenLength The length of the token in the document.
|
|
89
|
+
* @param prevOffset The offset of the previous token in the document.
|
|
90
|
+
* @param leadingHtmlStart The start offset of leading HTML before the block.
|
|
91
|
+
* @return The frame object.
|
|
136
92
|
*/
|
|
137
93
|
function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
|
138
94
|
return {
|
|
@@ -147,7 +103,7 @@ function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
|
|
147
103
|
/**
|
|
148
104
|
* Parser function, that converts input HTML into a block based structure.
|
|
149
105
|
*
|
|
150
|
-
* @param
|
|
106
|
+
* @param doc The HTML document to parse.
|
|
151
107
|
*
|
|
152
108
|
* @example
|
|
153
109
|
* Input post:
|
|
@@ -219,7 +175,7 @@ function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
|
|
219
175
|
* }
|
|
220
176
|
* ];
|
|
221
177
|
* ```
|
|
222
|
-
* @return
|
|
178
|
+
* @return A block-based representation of the input HTML.
|
|
223
179
|
*/
|
|
224
180
|
const parse = doc => {
|
|
225
181
|
document = doc;
|
|
@@ -236,7 +192,7 @@ const parse = doc => {
|
|
|
236
192
|
/**
|
|
237
193
|
* Parses the next token in the input document.
|
|
238
194
|
*
|
|
239
|
-
* @return
|
|
195
|
+
* @return Returns true when there is more tokens to parse.
|
|
240
196
|
*/
|
|
241
197
|
exports.parse = parse;
|
|
242
198
|
function proceed() {
|
|
@@ -315,7 +271,7 @@ function proceed() {
|
|
|
315
271
|
|
|
316
272
|
// Otherwise we're nested and we have to close out the current
|
|
317
273
|
// block and add it as a innerBlock to the parent.
|
|
318
|
-
const stackTop =
|
|
274
|
+
const stackTop = stack.pop();
|
|
319
275
|
const html = document.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
|
|
320
276
|
stackTop.block.innerHTML += html;
|
|
321
277
|
stackTop.block.innerContent.push(html);
|
|
@@ -337,8 +293,8 @@ function proceed() {
|
|
|
337
293
|
* delimiters is constrained to be an object
|
|
338
294
|
* and cannot be things like `true` or `null`
|
|
339
295
|
*
|
|
340
|
-
* @param
|
|
341
|
-
* @return
|
|
296
|
+
* @param input JSON input string to parse
|
|
297
|
+
* @return parsed JSON if valid or null if invalid
|
|
342
298
|
*/
|
|
343
299
|
function parseJSON(input) {
|
|
344
300
|
try {
|
|
@@ -351,7 +307,7 @@ function parseJSON(input) {
|
|
|
351
307
|
/**
|
|
352
308
|
* Finds the next token in the document.
|
|
353
309
|
*
|
|
354
|
-
* @return
|
|
310
|
+
* @return The next matched token.
|
|
355
311
|
*/
|
|
356
312
|
function nextToken() {
|
|
357
313
|
// Aye the magic
|
|
@@ -394,7 +350,7 @@ function nextToken() {
|
|
|
394
350
|
/**
|
|
395
351
|
* Adds a freeform block to the output.
|
|
396
352
|
*
|
|
397
|
-
* @param
|
|
353
|
+
* @param rawLength Optional length of the raw HTML to include as freeform content.
|
|
398
354
|
*/
|
|
399
355
|
function addFreeform(rawLength) {
|
|
400
356
|
const length = rawLength ? rawLength : document.length - offset;
|
|
@@ -407,10 +363,11 @@ function addFreeform(rawLength) {
|
|
|
407
363
|
/**
|
|
408
364
|
* Adds inner block to the parent block.
|
|
409
365
|
*
|
|
410
|
-
* @param
|
|
411
|
-
* @param
|
|
412
|
-
* @param
|
|
413
|
-
* @param
|
|
366
|
+
* @param block The inner block to be added to the parent.
|
|
367
|
+
* @param tokenStart The start offset of the block token in the document.
|
|
368
|
+
* @param tokenLength The total length of the block token.
|
|
369
|
+
* @param lastOffset Optional offset marking the end of the current block,
|
|
370
|
+
* used to update the parent's HTML content boundaries.
|
|
414
371
|
*/
|
|
415
372
|
function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
|
|
416
373
|
const parent = stack[stack.length - 1];
|
|
@@ -427,7 +384,7 @@ function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
|
|
|
427
384
|
/**
|
|
428
385
|
* Adds block from the stack to the output.
|
|
429
386
|
*
|
|
430
|
-
* @param
|
|
387
|
+
* @param endOffset Optional offset marking the end of the block's HTML content.
|
|
431
388
|
*/
|
|
432
389
|
function addBlockFromStack(endOffset) {
|
|
433
390
|
const {
|
|
@@ -435,7 +392,7 @@ function addBlockFromStack(endOffset) {
|
|
|
435
392
|
leadingHtmlStart,
|
|
436
393
|
prevOffset,
|
|
437
394
|
tokenStart
|
|
438
|
-
} =
|
|
395
|
+
} = stack.pop();
|
|
439
396
|
const html = endOffset ? document.substr(prevOffset, endOffset - prevOffset) : document.substr(prevOffset);
|
|
440
397
|
if (html) {
|
|
441
398
|
block.innerHTML += html;
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AAC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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","ignoreList":[]}
|
|
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.ts"],"sourcesContent":["let document: string;\nlet offset: number;\nlet output: ParsedBlock[];\nlet stack: ParsedFrame[];\n\ntype Attributes = Record< string, any > | null;\n\ntype ParsedBlock = {\n\tblockName: string | null;\n\tattrs: Attributes;\n\tinnerBlocks: ParsedBlock[];\n\tinnerHTML: string;\n\tinnerContent: Array< string | null >;\n};\n\ntype ParsedFrame = {\n\tblock: ParsedBlock;\n\ttokenStart: number;\n\ttokenLength: number;\n\tprevOffset: number;\n\tleadingHtmlStart: number | null;\n};\n\ntype TokenType =\n\t| 'no-more-tokens'\n\t| 'void-block'\n\t| 'block-opener'\n\t| 'block-closer';\n\ntype Token = [ TokenType, string, Attributes, number, number ];\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 * @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 blockName Either the abbreviated core types, e.g. \"paragraph\", or the fully-qualified\n * block type with namespace and type, e.g. \"core/paragraph\" or \"my-plugin/csv-table\".\n * @param attrs The attributes for the block, or null if there are no attributes.\n * @param innerBlocks An array of inner blocks.\n * @param innerHTML The inner HTML of the block.\n * @param innerContent An array of inner content strings.\n * @return The block object.\n */\nfunction Block(\n\tblockName: string | null,\n\tattrs: Attributes,\n\tinnerBlocks: ParsedBlock[],\n\tinnerHTML: string,\n\tinnerContent: string[]\n): ParsedBlock {\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 innerHTML The inner HTML of the block.\n * @return The freeform block object.\n */\nfunction Freeform( innerHTML: string ): ParsedBlock {\n\treturn Block( null, {}, [], innerHTML, [ innerHTML ] );\n}\n\n/**\n * Constructs a frame object.\n *\n * @param block The block object.\n * @param tokenStart The start offset of the token in the document.\n * @param tokenLength The length of the token in the document.\n * @param prevOffset The offset of the previous token in the document.\n * @param leadingHtmlStart The start offset of leading HTML before the block.\n * @return The frame object.\n */\nfunction Frame(\n\tblock: ParsedBlock,\n\ttokenStart: number,\n\ttokenLength: number,\n\tprevOffset: number | null,\n\tleadingHtmlStart: number | null\n): ParsedFrame {\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 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 A block-based representation of the input HTML.\n */\nexport const parse = ( doc: string ): ParsedBlock[] => {\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 Returns true when there is more tokens to parse.\n */\nfunction proceed(): boolean {\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 = stack.pop() as ParsedFrame;\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 input JSON input string to parse\n * @return parsed JSON if valid or null if invalid\n */\nfunction parseJSON( input: string ): Object | null {\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 The next matched token.\n */\nfunction nextToken(): Token {\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 rawLength Optional length of the raw HTML to include as freeform content.\n */\nfunction addFreeform( rawLength?: number ) {\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 block The inner block to be added to the parent.\n * @param tokenStart The start offset of the block token in the document.\n * @param tokenLength The total length of the block token.\n * @param lastOffset Optional offset marking the end of the current block,\n * used to update the parent's HTML content boundaries.\n */\nfunction addInnerBlock(\n\tblock: ParsedBlock,\n\ttokenStart: number,\n\ttokenLength: number,\n\tlastOffset?: number\n) {\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 endOffset Optional offset marking the end of the block's HTML content.\n */\nfunction addBlockFromStack( endOffset?: number ) {\n\tconst { block, leadingHtmlStart, prevOffset, tokenStart } =\n\t\tstack.pop() as ParsedFrame;\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,IAAIA,QAAgB;AACpB,IAAIC,MAAc;AAClB,IAAIC,MAAqB;AACzB,IAAIC,KAAoB;AA4BxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA,SAASC,KAAKA,CACbC,SAAwB,EACxBC,KAAiB,EACjBC,WAA0B,EAC1BC,SAAiB,EACjBC,YAAsB,EACR;EACd,OAAO;IACNJ,SAAS;IACTC,KAAK;IACLC,WAAW;IACXC,SAAS;IACTC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAAEF,SAAiB,EAAgB;EACnD,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,CACbC,KAAkB,EAClBC,UAAkB,EAClBC,WAAmB,EACnBC,UAAyB,EACzBC,gBAA+B,EACjB;EACd,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,GAAW,IAAqB;EACtDnB,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,EAAY;EAC3B,MAAME,UAAU,GAAGpB,KAAK,CAACqB,MAAM;EAC/B,MAAMC,IAAI,GAAGC,SAAS,CAAC,CAAC;EACxB,MAAM,CAAEC,SAAS,EAAErB,SAAS,EAAEC,KAAK,EAAEqB,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EF;EAAW,CAAC,GACxDX,KAAK,CAACgC,GAAG,CAAC,CAAgB;EAE3B,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","ignoreList":[]}
|
package/build-module/index.js
CHANGED
|
@@ -1,50 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @type {string}
|
|
3
|
-
*/
|
|
4
1
|
let document;
|
|
5
|
-
/**
|
|
6
|
-
* @type {number}
|
|
7
|
-
*/
|
|
8
2
|
let offset;
|
|
9
|
-
/**
|
|
10
|
-
* @type {ParsedBlock[]}
|
|
11
|
-
*/
|
|
12
3
|
let output;
|
|
13
|
-
/**
|
|
14
|
-
* @type {ParsedFrame[]}
|
|
15
|
-
*/
|
|
16
4
|
let stack;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Object|null} Attributes
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {Object} ParsedBlock
|
|
24
|
-
* @property {string|null} blockName Block name.
|
|
25
|
-
* @property {Attributes} attrs Block attributes.
|
|
26
|
-
* @property {ParsedBlock[]} innerBlocks Inner blocks.
|
|
27
|
-
* @property {string} innerHTML Inner HTML.
|
|
28
|
-
* @property {Array<string|null>} innerContent Inner content.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @typedef {Object} ParsedFrame
|
|
33
|
-
* @property {ParsedBlock} block Block.
|
|
34
|
-
* @property {number} tokenStart Token start.
|
|
35
|
-
* @property {number} tokenLength Token length.
|
|
36
|
-
* @property {number} prevOffset Previous offset.
|
|
37
|
-
* @property {number|null} leadingHtmlStart Leading HTML start.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @typedef {'no-more-tokens'|'void-block'|'block-opener'|'block-closer'} TokenType
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @typedef {[TokenType, string, Attributes, number, number]} Token
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
5
|
/**
|
|
49
6
|
* Matches block comment delimiters
|
|
50
7
|
*
|
|
@@ -81,8 +38,6 @@ let stack;
|
|
|
81
38
|
* once browsers reliably support atomic grouping or possessive
|
|
82
39
|
* quantifiers natively we should remove this trick and simplify
|
|
83
40
|
*
|
|
84
|
-
* @type {RegExp}
|
|
85
|
-
*
|
|
86
41
|
* @since 3.8.0
|
|
87
42
|
* @since 4.6.1 added optimization to prevent backtracking on attribute parsing
|
|
88
43
|
*/
|
|
@@ -91,12 +46,13 @@ const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?
|
|
|
91
46
|
/**
|
|
92
47
|
* Constructs a block object.
|
|
93
48
|
*
|
|
94
|
-
* @param
|
|
95
|
-
*
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
98
|
-
* @param
|
|
99
|
-
* @
|
|
49
|
+
* @param blockName Either the abbreviated core types, e.g. "paragraph", or the fully-qualified
|
|
50
|
+
* block type with namespace and type, e.g. "core/paragraph" or "my-plugin/csv-table".
|
|
51
|
+
* @param attrs The attributes for the block, or null if there are no attributes.
|
|
52
|
+
* @param innerBlocks An array of inner blocks.
|
|
53
|
+
* @param innerHTML The inner HTML of the block.
|
|
54
|
+
* @param innerContent An array of inner content strings.
|
|
55
|
+
* @return The block object.
|
|
100
56
|
*/
|
|
101
57
|
function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
|
|
102
58
|
return {
|
|
@@ -111,8 +67,8 @@ function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
|
|
|
111
67
|
/**
|
|
112
68
|
* Constructs a freeform block object.
|
|
113
69
|
*
|
|
114
|
-
* @param
|
|
115
|
-
* @return
|
|
70
|
+
* @param innerHTML The inner HTML of the block.
|
|
71
|
+
* @return The freeform block object.
|
|
116
72
|
*/
|
|
117
73
|
function Freeform(innerHTML) {
|
|
118
74
|
return Block(null, {}, [], innerHTML, [innerHTML]);
|
|
@@ -121,12 +77,12 @@ function Freeform(innerHTML) {
|
|
|
121
77
|
/**
|
|
122
78
|
* Constructs a frame object.
|
|
123
79
|
*
|
|
124
|
-
* @param
|
|
125
|
-
* @param
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
* @return
|
|
80
|
+
* @param block The block object.
|
|
81
|
+
* @param tokenStart The start offset of the token in the document.
|
|
82
|
+
* @param tokenLength The length of the token in the document.
|
|
83
|
+
* @param prevOffset The offset of the previous token in the document.
|
|
84
|
+
* @param leadingHtmlStart The start offset of leading HTML before the block.
|
|
85
|
+
* @return The frame object.
|
|
130
86
|
*/
|
|
131
87
|
function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
|
132
88
|
return {
|
|
@@ -141,7 +97,7 @@ function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
|
|
141
97
|
/**
|
|
142
98
|
* Parser function, that converts input HTML into a block based structure.
|
|
143
99
|
*
|
|
144
|
-
* @param
|
|
100
|
+
* @param doc The HTML document to parse.
|
|
145
101
|
*
|
|
146
102
|
* @example
|
|
147
103
|
* Input post:
|
|
@@ -213,7 +169,7 @@ function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
|
|
213
169
|
* }
|
|
214
170
|
* ];
|
|
215
171
|
* ```
|
|
216
|
-
* @return
|
|
172
|
+
* @return A block-based representation of the input HTML.
|
|
217
173
|
*/
|
|
218
174
|
export const parse = doc => {
|
|
219
175
|
document = doc;
|
|
@@ -230,7 +186,7 @@ export const parse = doc => {
|
|
|
230
186
|
/**
|
|
231
187
|
* Parses the next token in the input document.
|
|
232
188
|
*
|
|
233
|
-
* @return
|
|
189
|
+
* @return Returns true when there is more tokens to parse.
|
|
234
190
|
*/
|
|
235
191
|
function proceed() {
|
|
236
192
|
const stackDepth = stack.length;
|
|
@@ -308,7 +264,7 @@ function proceed() {
|
|
|
308
264
|
|
|
309
265
|
// Otherwise we're nested and we have to close out the current
|
|
310
266
|
// block and add it as a innerBlock to the parent.
|
|
311
|
-
const stackTop =
|
|
267
|
+
const stackTop = stack.pop();
|
|
312
268
|
const html = document.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
|
|
313
269
|
stackTop.block.innerHTML += html;
|
|
314
270
|
stackTop.block.innerContent.push(html);
|
|
@@ -330,8 +286,8 @@ function proceed() {
|
|
|
330
286
|
* delimiters is constrained to be an object
|
|
331
287
|
* and cannot be things like `true` or `null`
|
|
332
288
|
*
|
|
333
|
-
* @param
|
|
334
|
-
* @return
|
|
289
|
+
* @param input JSON input string to parse
|
|
290
|
+
* @return parsed JSON if valid or null if invalid
|
|
335
291
|
*/
|
|
336
292
|
function parseJSON(input) {
|
|
337
293
|
try {
|
|
@@ -344,7 +300,7 @@ function parseJSON(input) {
|
|
|
344
300
|
/**
|
|
345
301
|
* Finds the next token in the document.
|
|
346
302
|
*
|
|
347
|
-
* @return
|
|
303
|
+
* @return The next matched token.
|
|
348
304
|
*/
|
|
349
305
|
function nextToken() {
|
|
350
306
|
// Aye the magic
|
|
@@ -387,7 +343,7 @@ function nextToken() {
|
|
|
387
343
|
/**
|
|
388
344
|
* Adds a freeform block to the output.
|
|
389
345
|
*
|
|
390
|
-
* @param
|
|
346
|
+
* @param rawLength Optional length of the raw HTML to include as freeform content.
|
|
391
347
|
*/
|
|
392
348
|
function addFreeform(rawLength) {
|
|
393
349
|
const length = rawLength ? rawLength : document.length - offset;
|
|
@@ -400,10 +356,11 @@ function addFreeform(rawLength) {
|
|
|
400
356
|
/**
|
|
401
357
|
* Adds inner block to the parent block.
|
|
402
358
|
*
|
|
403
|
-
* @param
|
|
404
|
-
* @param
|
|
405
|
-
* @param
|
|
406
|
-
* @param
|
|
359
|
+
* @param block The inner block to be added to the parent.
|
|
360
|
+
* @param tokenStart The start offset of the block token in the document.
|
|
361
|
+
* @param tokenLength The total length of the block token.
|
|
362
|
+
* @param lastOffset Optional offset marking the end of the current block,
|
|
363
|
+
* used to update the parent's HTML content boundaries.
|
|
407
364
|
*/
|
|
408
365
|
function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
|
|
409
366
|
const parent = stack[stack.length - 1];
|
|
@@ -420,7 +377,7 @@ function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
|
|
|
420
377
|
/**
|
|
421
378
|
* Adds block from the stack to the output.
|
|
422
379
|
*
|
|
423
|
-
* @param
|
|
380
|
+
* @param endOffset Optional offset marking the end of the block's HTML content.
|
|
424
381
|
*/
|
|
425
382
|
function addBlockFromStack(endOffset) {
|
|
426
383
|
const {
|
|
@@ -428,7 +385,7 @@ function addBlockFromStack(endOffset) {
|
|
|
428
385
|
leadingHtmlStart,
|
|
429
386
|
prevOffset,
|
|
430
387
|
tokenStart
|
|
431
|
-
} =
|
|
388
|
+
} = stack.pop();
|
|
432
389
|
const html = endOffset ? document.substr(prevOffset, endOffset - prevOffset) : document.substr(prevOffset);
|
|
433
390
|
if (html) {
|
|
434
391
|
block.innerHTML += html;
|
|
@@ -1 +1 @@
|
|
|
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,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;AACA,SAASmB,OAAOA,CAAA,EAAG;EAClB,MAAMC,UAAU,GAAGnB,KAAK,CAACoB,MAAM;EAC/B,MAAMC,IAAI,GAAGC,SAAS,CAAC,CAAC;EACxB,MAAM,CAAEC,SAAS,EAAEpB,SAAS,EAAEC,KAAK,EAAEoB,WAAW,EAAEZ,WAAW,CAAE,GAAGS,IAAI;;EAEtE;EACA,MAAMP,gBAAgB,GAAGU,WAAW,GAAG1B,MAAM,GAAGA,MAAM,GAAG,IAAI;EAE7D,QAASyB,SAAS;IACjB,KAAK,gBAAgB;MACpB;MACA,IAAK,CAAC,KAAKJ,UAAU,EAAG;QACvBM,WAAW,CAAC,CAAC;QACb,OAAO,KAAK;MACb;;MAEA;MACA;MACA;MACA;MACA;;MAEA;MACA,IAAK,CAAC,KAAKN,UAAU,EAAG;QACvBO,iBAA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,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","ignoreList":[]}
|
|
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.ts"],"sourcesContent":["let document: string;\nlet offset: number;\nlet output: ParsedBlock[];\nlet stack: ParsedFrame[];\n\ntype Attributes = Record< string, any > | null;\n\ntype ParsedBlock = {\n\tblockName: string | null;\n\tattrs: Attributes;\n\tinnerBlocks: ParsedBlock[];\n\tinnerHTML: string;\n\tinnerContent: Array< string | null >;\n};\n\ntype ParsedFrame = {\n\tblock: ParsedBlock;\n\ttokenStart: number;\n\ttokenLength: number;\n\tprevOffset: number;\n\tleadingHtmlStart: number | null;\n};\n\ntype TokenType =\n\t| 'no-more-tokens'\n\t| 'void-block'\n\t| 'block-opener'\n\t| 'block-closer';\n\ntype Token = [ TokenType, string, Attributes, number, number ];\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 * @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 blockName Either the abbreviated core types, e.g. \"paragraph\", or the fully-qualified\n * block type with namespace and type, e.g. \"core/paragraph\" or \"my-plugin/csv-table\".\n * @param attrs The attributes for the block, or null if there are no attributes.\n * @param innerBlocks An array of inner blocks.\n * @param innerHTML The inner HTML of the block.\n * @param innerContent An array of inner content strings.\n * @return The block object.\n */\nfunction Block(\n\tblockName: string | null,\n\tattrs: Attributes,\n\tinnerBlocks: ParsedBlock[],\n\tinnerHTML: string,\n\tinnerContent: string[]\n): ParsedBlock {\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 innerHTML The inner HTML of the block.\n * @return The freeform block object.\n */\nfunction Freeform( innerHTML: string ): ParsedBlock {\n\treturn Block( null, {}, [], innerHTML, [ innerHTML ] );\n}\n\n/**\n * Constructs a frame object.\n *\n * @param block The block object.\n * @param tokenStart The start offset of the token in the document.\n * @param tokenLength The length of the token in the document.\n * @param prevOffset The offset of the previous token in the document.\n * @param leadingHtmlStart The start offset of leading HTML before the block.\n * @return The frame object.\n */\nfunction Frame(\n\tblock: ParsedBlock,\n\ttokenStart: number,\n\ttokenLength: number,\n\tprevOffset: number | null,\n\tleadingHtmlStart: number | null\n): ParsedFrame {\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 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 A block-based representation of the input HTML.\n */\nexport const parse = ( doc: string ): ParsedBlock[] => {\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 Returns true when there is more tokens to parse.\n */\nfunction proceed(): boolean {\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 = stack.pop() as ParsedFrame;\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 input JSON input string to parse\n * @return parsed JSON if valid or null if invalid\n */\nfunction parseJSON( input: string ): Object | null {\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 The next matched token.\n */\nfunction nextToken(): Token {\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 rawLength Optional length of the raw HTML to include as freeform content.\n */\nfunction addFreeform( rawLength?: number ) {\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 block The inner block to be added to the parent.\n * @param tokenStart The start offset of the block token in the document.\n * @param tokenLength The total length of the block token.\n * @param lastOffset Optional offset marking the end of the current block,\n * used to update the parent's HTML content boundaries.\n */\nfunction addInnerBlock(\n\tblock: ParsedBlock,\n\ttokenStart: number,\n\ttokenLength: number,\n\tlastOffset?: number\n) {\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 endOffset Optional offset marking the end of the block's HTML content.\n */\nfunction addBlockFromStack( endOffset?: number ) {\n\tconst { block, leadingHtmlStart, prevOffset, tokenStart } =\n\t\tstack.pop() as ParsedFrame;\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,IAAIA,QAAgB;AACpB,IAAIC,MAAc;AAClB,IAAIC,MAAqB;AACzB,IAAIC,KAAoB;AA4BxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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;AACA,SAASC,KAAKA,CACbC,SAAwB,EACxBC,KAAiB,EACjBC,WAA0B,EAC1BC,SAAiB,EACjBC,YAAsB,EACR;EACd,OAAO;IACNJ,SAAS;IACTC,KAAK;IACLC,WAAW;IACXC,SAAS;IACTC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,QAAQA,CAAEF,SAAiB,EAAgB;EACnD,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,CACbC,KAAkB,EAClBC,UAAkB,EAClBC,WAAmB,EACnBC,UAAyB,EACzBC,gBAA+B,EACjB;EACd,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,GAAW,IAAqB;EACtDnB,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;AACA,SAASmB,OAAOA,CAAA,EAAY;EAC3B,MAAMC,UAAU,GAAGnB,KAAK,CAACoB,MAAM;EAC/B,MAAMC,IAAI,GAAGC,SAAS,CAAC,CAAC;EACxB,MAAM,CAA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EAChD,MAAM;IAAE7C,KAAK;IAAEI,gBAAgB;IAAED,UAAU;IAAEF;EAAW,CAAC,GACxDX,KAAK,CAAC+B,GAAG,CAAC,CAAgB;EAE3B,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","ignoreList":[]}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1,49 +1,88 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type ParsedBlock = {
|
|
4
|
-
/**
|
|
5
|
-
* Block name.
|
|
6
|
-
*/
|
|
1
|
+
type Attributes = Record<string, any> | null;
|
|
2
|
+
type ParsedBlock = {
|
|
7
3
|
blockName: string | null;
|
|
8
|
-
/**
|
|
9
|
-
* Block attributes.
|
|
10
|
-
*/
|
|
11
4
|
attrs: Attributes;
|
|
12
|
-
/**
|
|
13
|
-
* Inner blocks.
|
|
14
|
-
*/
|
|
15
5
|
innerBlocks: ParsedBlock[];
|
|
16
|
-
/**
|
|
17
|
-
* Inner HTML.
|
|
18
|
-
*/
|
|
19
6
|
innerHTML: string;
|
|
20
|
-
/**
|
|
21
|
-
* Inner content.
|
|
22
|
-
*/
|
|
23
7
|
innerContent: Array<string | null>;
|
|
24
8
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Parser function, that converts input HTML into a block based structure.
|
|
11
|
+
*
|
|
12
|
+
* @param doc The HTML document to parse.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* Input post:
|
|
16
|
+
* ```html
|
|
17
|
+
* <!-- wp:columns {"columns":3} -->
|
|
18
|
+
* <div class="wp-block-columns has-3-columns"><!-- wp:column -->
|
|
19
|
+
* <div class="wp-block-column"><!-- wp:paragraph -->
|
|
20
|
+
* <p>Left</p>
|
|
21
|
+
* <!-- /wp:paragraph --></div>
|
|
22
|
+
* <!-- /wp:column -->
|
|
23
|
+
*
|
|
24
|
+
* <!-- wp:column -->
|
|
25
|
+
* <div class="wp-block-column"><!-- wp:paragraph -->
|
|
26
|
+
* <p><strong>Middle</strong></p>
|
|
27
|
+
* <!-- /wp:paragraph --></div>
|
|
28
|
+
* <!-- /wp:column -->
|
|
29
|
+
*
|
|
30
|
+
* <!-- wp:column -->
|
|
31
|
+
* <div class="wp-block-column"></div>
|
|
32
|
+
* <!-- /wp:column --></div>
|
|
33
|
+
* <!-- /wp:columns -->
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Parsing code:
|
|
37
|
+
* ```js
|
|
38
|
+
* import { parse } from '@wordpress/block-serialization-default-parser';
|
|
39
|
+
*
|
|
40
|
+
* parse( post ) === [
|
|
41
|
+
* {
|
|
42
|
+
* blockName: "core/columns",
|
|
43
|
+
* attrs: {
|
|
44
|
+
* columns: 3
|
|
45
|
+
* },
|
|
46
|
+
* innerBlocks: [
|
|
47
|
+
* {
|
|
48
|
+
* blockName: "core/column",
|
|
49
|
+
* attrs: null,
|
|
50
|
+
* innerBlocks: [
|
|
51
|
+
* {
|
|
52
|
+
* blockName: "core/paragraph",
|
|
53
|
+
* attrs: null,
|
|
54
|
+
* innerBlocks: [],
|
|
55
|
+
* innerHTML: "\n<p>Left</p>\n"
|
|
56
|
+
* }
|
|
57
|
+
* ],
|
|
58
|
+
* innerHTML: '\n<div class="wp-block-column"></div>\n'
|
|
59
|
+
* },
|
|
60
|
+
* {
|
|
61
|
+
* blockName: "core/column",
|
|
62
|
+
* attrs: null,
|
|
63
|
+
* innerBlocks: [
|
|
64
|
+
* {
|
|
65
|
+
* blockName: "core/paragraph",
|
|
66
|
+
* attrs: null,
|
|
67
|
+
* innerBlocks: [],
|
|
68
|
+
* innerHTML: "\n<p><strong>Middle</strong></p>\n"
|
|
69
|
+
* }
|
|
70
|
+
* ],
|
|
71
|
+
* innerHTML: '\n<div class="wp-block-column"></div>\n'
|
|
72
|
+
* },
|
|
73
|
+
* {
|
|
74
|
+
* blockName: "core/column",
|
|
75
|
+
* attrs: null,
|
|
76
|
+
* innerBlocks: [],
|
|
77
|
+
* innerHTML: '\n<div class="wp-block-column"></div>\n'
|
|
78
|
+
* }
|
|
79
|
+
* ],
|
|
80
|
+
* innerHTML: '\n<div class="wp-block-columns has-3-columns">\n\n\n\n</div>\n'
|
|
81
|
+
* }
|
|
82
|
+
* ];
|
|
83
|
+
* ```
|
|
84
|
+
* @return A block-based representation of the input HTML.
|
|
85
|
+
*/
|
|
86
|
+
export declare const parse: (doc: string) => ParsedBlock[];
|
|
87
|
+
export {};
|
|
49
88
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG,MAAM,CAAE,MAAM,EAAE,GAAG,CAAE,GAAG,IAAI,CAAC;AAE/C,KAAK,WAAW,GAAG;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,KAAK,CAAE,MAAM,GAAG,IAAI,CAAE,CAAC;CACrC,CAAC;AA2HF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,eAAO,MAAM,KAAK,QAAU,MAAM,KAAI,WAAW,EAYhD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-serialization-default-parser",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.27.1-next.46f643fa0.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",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "17e600e091675c5e3d809adfea23ac456bbeae19"
|
|
39
39
|
}
|
|
@@ -1,49 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
let stack;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @typedef {Object|null} Attributes
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {Object} ParsedBlock
|
|
24
|
-
* @property {string|null} blockName Block name.
|
|
25
|
-
* @property {Attributes} attrs Block attributes.
|
|
26
|
-
* @property {ParsedBlock[]} innerBlocks Inner blocks.
|
|
27
|
-
* @property {string} innerHTML Inner HTML.
|
|
28
|
-
* @property {Array<string|null>} innerContent Inner content.
|
|
29
|
-
*/
|
|
1
|
+
let document: string;
|
|
2
|
+
let offset: number;
|
|
3
|
+
let output: ParsedBlock[];
|
|
4
|
+
let stack: ParsedFrame[];
|
|
5
|
+
|
|
6
|
+
type Attributes = Record< string, any > | null;
|
|
7
|
+
|
|
8
|
+
type ParsedBlock = {
|
|
9
|
+
blockName: string | null;
|
|
10
|
+
attrs: Attributes;
|
|
11
|
+
innerBlocks: ParsedBlock[];
|
|
12
|
+
innerHTML: string;
|
|
13
|
+
innerContent: Array< string | null >;
|
|
14
|
+
};
|
|
30
15
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*/
|
|
16
|
+
type ParsedFrame = {
|
|
17
|
+
block: ParsedBlock;
|
|
18
|
+
tokenStart: number;
|
|
19
|
+
tokenLength: number;
|
|
20
|
+
prevOffset: number;
|
|
21
|
+
leadingHtmlStart: number | null;
|
|
22
|
+
};
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
24
|
+
type TokenType =
|
|
25
|
+
| 'no-more-tokens'
|
|
26
|
+
| 'void-block'
|
|
27
|
+
| 'block-opener'
|
|
28
|
+
| 'block-closer';
|
|
43
29
|
|
|
44
|
-
|
|
45
|
-
* @typedef {[TokenType, string, Attributes, number, number]} Token
|
|
46
|
-
*/
|
|
30
|
+
type Token = [ TokenType, string, Attributes, number, number ];
|
|
47
31
|
|
|
48
32
|
/**
|
|
49
33
|
* Matches block comment delimiters
|
|
@@ -81,8 +65,6 @@ let stack;
|
|
|
81
65
|
* once browsers reliably support atomic grouping or possessive
|
|
82
66
|
* quantifiers natively we should remove this trick and simplify
|
|
83
67
|
*
|
|
84
|
-
* @type {RegExp}
|
|
85
|
-
*
|
|
86
68
|
* @since 3.8.0
|
|
87
69
|
* @since 4.6.1 added optimization to prevent backtracking on attribute parsing
|
|
88
70
|
*/
|
|
@@ -92,14 +74,21 @@ const tokenizer =
|
|
|
92
74
|
/**
|
|
93
75
|
* Constructs a block object.
|
|
94
76
|
*
|
|
95
|
-
* @param
|
|
96
|
-
*
|
|
97
|
-
* @param
|
|
98
|
-
* @param
|
|
99
|
-
* @param
|
|
100
|
-
* @
|
|
77
|
+
* @param blockName Either the abbreviated core types, e.g. "paragraph", or the fully-qualified
|
|
78
|
+
* block type with namespace and type, e.g. "core/paragraph" or "my-plugin/csv-table".
|
|
79
|
+
* @param attrs The attributes for the block, or null if there are no attributes.
|
|
80
|
+
* @param innerBlocks An array of inner blocks.
|
|
81
|
+
* @param innerHTML The inner HTML of the block.
|
|
82
|
+
* @param innerContent An array of inner content strings.
|
|
83
|
+
* @return The block object.
|
|
101
84
|
*/
|
|
102
|
-
function Block(
|
|
85
|
+
function Block(
|
|
86
|
+
blockName: string | null,
|
|
87
|
+
attrs: Attributes,
|
|
88
|
+
innerBlocks: ParsedBlock[],
|
|
89
|
+
innerHTML: string,
|
|
90
|
+
innerContent: string[]
|
|
91
|
+
): ParsedBlock {
|
|
103
92
|
return {
|
|
104
93
|
blockName,
|
|
105
94
|
attrs,
|
|
@@ -112,24 +101,30 @@ function Block( blockName, attrs, innerBlocks, innerHTML, innerContent ) {
|
|
|
112
101
|
/**
|
|
113
102
|
* Constructs a freeform block object.
|
|
114
103
|
*
|
|
115
|
-
* @param
|
|
116
|
-
* @return
|
|
104
|
+
* @param innerHTML The inner HTML of the block.
|
|
105
|
+
* @return The freeform block object.
|
|
117
106
|
*/
|
|
118
|
-
function Freeform( innerHTML ) {
|
|
107
|
+
function Freeform( innerHTML: string ): ParsedBlock {
|
|
119
108
|
return Block( null, {}, [], innerHTML, [ innerHTML ] );
|
|
120
109
|
}
|
|
121
110
|
|
|
122
111
|
/**
|
|
123
112
|
* Constructs a frame object.
|
|
124
113
|
*
|
|
125
|
-
* @param
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
129
|
-
* @param
|
|
130
|
-
* @return
|
|
114
|
+
* @param block The block object.
|
|
115
|
+
* @param tokenStart The start offset of the token in the document.
|
|
116
|
+
* @param tokenLength The length of the token in the document.
|
|
117
|
+
* @param prevOffset The offset of the previous token in the document.
|
|
118
|
+
* @param leadingHtmlStart The start offset of leading HTML before the block.
|
|
119
|
+
* @return The frame object.
|
|
131
120
|
*/
|
|
132
|
-
function Frame(
|
|
121
|
+
function Frame(
|
|
122
|
+
block: ParsedBlock,
|
|
123
|
+
tokenStart: number,
|
|
124
|
+
tokenLength: number,
|
|
125
|
+
prevOffset: number | null,
|
|
126
|
+
leadingHtmlStart: number | null
|
|
127
|
+
): ParsedFrame {
|
|
133
128
|
return {
|
|
134
129
|
block,
|
|
135
130
|
tokenStart,
|
|
@@ -142,7 +137,7 @@ function Frame( block, tokenStart, tokenLength, prevOffset, leadingHtmlStart ) {
|
|
|
142
137
|
/**
|
|
143
138
|
* Parser function, that converts input HTML into a block based structure.
|
|
144
139
|
*
|
|
145
|
-
* @param
|
|
140
|
+
* @param doc The HTML document to parse.
|
|
146
141
|
*
|
|
147
142
|
* @example
|
|
148
143
|
* Input post:
|
|
@@ -214,9 +209,9 @@ function Frame( block, tokenStart, tokenLength, prevOffset, leadingHtmlStart ) {
|
|
|
214
209
|
* }
|
|
215
210
|
* ];
|
|
216
211
|
* ```
|
|
217
|
-
* @return
|
|
212
|
+
* @return A block-based representation of the input HTML.
|
|
218
213
|
*/
|
|
219
|
-
export const parse = ( doc ) => {
|
|
214
|
+
export const parse = ( doc: string ): ParsedBlock[] => {
|
|
220
215
|
document = doc;
|
|
221
216
|
offset = 0;
|
|
222
217
|
output = [];
|
|
@@ -233,9 +228,9 @@ export const parse = ( doc ) => {
|
|
|
233
228
|
/**
|
|
234
229
|
* Parses the next token in the input document.
|
|
235
230
|
*
|
|
236
|
-
* @return
|
|
231
|
+
* @return Returns true when there is more tokens to parse.
|
|
237
232
|
*/
|
|
238
|
-
function proceed() {
|
|
233
|
+
function proceed(): boolean {
|
|
239
234
|
const stackDepth = stack.length;
|
|
240
235
|
const next = nextToken();
|
|
241
236
|
const [ tokenType, blockName, attrs, startOffset, tokenLength ] = next;
|
|
@@ -333,7 +328,7 @@ function proceed() {
|
|
|
333
328
|
|
|
334
329
|
// Otherwise we're nested and we have to close out the current
|
|
335
330
|
// block and add it as a innerBlock to the parent.
|
|
336
|
-
const stackTop =
|
|
331
|
+
const stackTop = stack.pop() as ParsedFrame;
|
|
337
332
|
const html = document.substr(
|
|
338
333
|
stackTop.prevOffset,
|
|
339
334
|
startOffset - stackTop.prevOffset
|
|
@@ -365,10 +360,10 @@ function proceed() {
|
|
|
365
360
|
* delimiters is constrained to be an object
|
|
366
361
|
* and cannot be things like `true` or `null`
|
|
367
362
|
*
|
|
368
|
-
* @param
|
|
369
|
-
* @return
|
|
363
|
+
* @param input JSON input string to parse
|
|
364
|
+
* @return parsed JSON if valid or null if invalid
|
|
370
365
|
*/
|
|
371
|
-
function parseJSON( input ) {
|
|
366
|
+
function parseJSON( input: string ): Object | null {
|
|
372
367
|
try {
|
|
373
368
|
return JSON.parse( input );
|
|
374
369
|
} catch ( e ) {
|
|
@@ -379,9 +374,9 @@ function parseJSON( input ) {
|
|
|
379
374
|
/**
|
|
380
375
|
* Finds the next token in the document.
|
|
381
376
|
*
|
|
382
|
-
* @return
|
|
377
|
+
* @return The next matched token.
|
|
383
378
|
*/
|
|
384
|
-
function nextToken() {
|
|
379
|
+
function nextToken(): Token {
|
|
385
380
|
// Aye the magic
|
|
386
381
|
// we're using a single RegExp to tokenize the block comment delimiters
|
|
387
382
|
// we're also using a trick here because the only difference between a
|
|
@@ -435,9 +430,9 @@ function nextToken() {
|
|
|
435
430
|
/**
|
|
436
431
|
* Adds a freeform block to the output.
|
|
437
432
|
*
|
|
438
|
-
* @param
|
|
433
|
+
* @param rawLength Optional length of the raw HTML to include as freeform content.
|
|
439
434
|
*/
|
|
440
|
-
function addFreeform( rawLength ) {
|
|
435
|
+
function addFreeform( rawLength?: number ) {
|
|
441
436
|
const length = rawLength ? rawLength : document.length - offset;
|
|
442
437
|
|
|
443
438
|
if ( 0 === length ) {
|
|
@@ -450,12 +445,18 @@ function addFreeform( rawLength ) {
|
|
|
450
445
|
/**
|
|
451
446
|
* Adds inner block to the parent block.
|
|
452
447
|
*
|
|
453
|
-
* @param
|
|
454
|
-
* @param
|
|
455
|
-
* @param
|
|
456
|
-
* @param
|
|
448
|
+
* @param block The inner block to be added to the parent.
|
|
449
|
+
* @param tokenStart The start offset of the block token in the document.
|
|
450
|
+
* @param tokenLength The total length of the block token.
|
|
451
|
+
* @param lastOffset Optional offset marking the end of the current block,
|
|
452
|
+
* used to update the parent's HTML content boundaries.
|
|
457
453
|
*/
|
|
458
|
-
function addInnerBlock(
|
|
454
|
+
function addInnerBlock(
|
|
455
|
+
block: ParsedBlock,
|
|
456
|
+
tokenStart: number,
|
|
457
|
+
tokenLength: number,
|
|
458
|
+
lastOffset?: number
|
|
459
|
+
) {
|
|
459
460
|
const parent = stack[ stack.length - 1 ];
|
|
460
461
|
parent.block.innerBlocks.push( block );
|
|
461
462
|
const html = document.substr(
|
|
@@ -475,11 +476,11 @@ function addInnerBlock( block, tokenStart, tokenLength, lastOffset ) {
|
|
|
475
476
|
/**
|
|
476
477
|
* Adds block from the stack to the output.
|
|
477
478
|
*
|
|
478
|
-
* @param
|
|
479
|
+
* @param endOffset Optional offset marking the end of the block's HTML content.
|
|
479
480
|
*/
|
|
480
|
-
function addBlockFromStack( endOffset ) {
|
|
481
|
+
function addBlockFromStack( endOffset?: number ) {
|
|
481
482
|
const { block, leadingHtmlStart, prevOffset, tokenStart } =
|
|
482
|
-
|
|
483
|
+
stack.pop() as ParsedFrame;
|
|
483
484
|
|
|
484
485
|
const html = endOffset
|
|
485
486
|
? document.substr( prevOffset, endOffset - prevOffset )
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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.es2024.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.dom.iterable.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.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2017.date.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.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.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.es2023.intl.d.ts","../../node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2024.collection.d.ts","../../node_modules/typescript/lib/lib.es2024.object.d.ts","../../node_modules/typescript/lib/lib.es2024.promise.d.ts","../../node_modules/typescript/lib/lib.es2024.regexp.d.ts","../../node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2024.string.d.ts","../../node_modules/typescript/lib/lib.esnext.array.d.ts","../../node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.esnext.iterator.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","./src/index.js"],"fileInfos":[{"version":"e41c290ef7dd7dab3493e6cbe5909e0148edf4a8dad0271be08edec368a0f7b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","impliedFormat":1},{"version":"8fd575e12870e9944c7e1d62e1f5a73fcf23dd8d3a321f2a2c74c20d022283fe","impliedFormat":1},{"version":"e12a46ce14b817d4c9e6b2b478956452330bf00c9801b79de46f7a1815b5bd40","impliedFormat":1},{"version":"4fd3f3422b2d2a3dfd5cdd0f387b3a8ec45f006c6ea896a4cb41264c2100bb2c","affectsGlobalScope":true,"impliedFormat":1},{"version":"69e65d976bf166ce4a9e6f6c18f94d2424bf116e90837ace179610dbccad9b42","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"62bb211266ee48b2d0edf0d8d1b191f0c24fc379a82bd4c1692a082c540bc6b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"fef8cfad2e2dc5f5b3d97a6f4f2e92848eb1b88e897bb7318cef0e2820bceaab","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"f1e2a172204962276504466a6393426d2ca9c54894b1ad0a6c9dad867a65f876","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"b5ce7a470bc3628408429040c4e3a53a27755022a32fd05e2cb694e7015386c7","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"bab26767638ab3557de12c900f0b91f710c7dc40ee9793d5a27d32c04f0bf646","affectsGlobalScope":true,"impliedFormat":1},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true,"impliedFormat":1},{"version":"87dc0f382502f5bbce5129bdc0aea21e19a3abbc19259e0b43ae038a9fc4e326","affectsGlobalScope":true,"impliedFormat":1},{"version":"b1cb28af0c891c8c96b2d6b7be76bd394fddcfdb4709a20ba05a7c1605eea0f9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true,"impliedFormat":1},{"version":"56e4ed5aab5f5920980066a9409bfaf53e6d21d3f8d020c17e4de584d29600ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ece9f17b3866cc077099c73f4983bddbcb1dc7ddb943227f1ec070f529dedd1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a6282c8827e4b9a95f4bf4f5c205673ada31b982f50572d27103df8ceb8013c","affectsGlobalScope":true,"impliedFormat":1},{"version":"1c9319a09485199c1f7b0498f2988d6d2249793ef67edda49d1e584746be9032","affectsGlobalScope":true,"impliedFormat":1},{"version":"e3a2a0cee0f03ffdde24d89660eba2685bfbdeae955a6c67e8c4c9fd28928eeb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"51ad4c928303041605b4d7ae32e0c1ee387d43a24cd6f1ebf4a2699e1076d4fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true,"impliedFormat":1},{"version":"61d6a2092f48af66dbfb220e31eea8b10bc02b6932d6e529005fd2d7b3281290","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"58952a7b2f2f6addeef2d390abb23d8b4f054070c7683966bad06595fa1f27e6","signature":"9ecbde4e7833c05a81d858ded751a383a9bf4626ad73d0f60d59becca59cbdeb"}],"root":[79],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"checkJs":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"rootDir":"./src","skipDefaultLibCheck":true,"strict":true,"target":99},"latestChangedDtsFile":"./build-types/index.d.ts","version":"5.7.2"}
|
|
1
|
+
{"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.es2024.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.dom.iterable.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.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2017.date.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.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.es2023.collection.d.ts","../../node_modules/typescript/lib/lib.es2023.intl.d.ts","../../node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2024.collection.d.ts","../../node_modules/typescript/lib/lib.es2024.object.d.ts","../../node_modules/typescript/lib/lib.es2024.promise.d.ts","../../node_modules/typescript/lib/lib.es2024.regexp.d.ts","../../node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2024.string.d.ts","../../node_modules/typescript/lib/lib.esnext.array.d.ts","../../node_modules/typescript/lib/lib.esnext.collection.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../../node_modules/typescript/lib/lib.esnext.iterator.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","./src/index.ts"],"fileInfos":[{"version":"e41c290ef7dd7dab3493e6cbe5909e0148edf4a8dad0271be08edec368a0f7b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"27bdc30a0e32783366a5abeda841bc22757c1797de8681bbe81fbc735eeb1c10","impliedFormat":1},{"version":"8fd575e12870e9944c7e1d62e1f5a73fcf23dd8d3a321f2a2c74c20d022283fe","impliedFormat":1},{"version":"e12a46ce14b817d4c9e6b2b478956452330bf00c9801b79de46f7a1815b5bd40","impliedFormat":1},{"version":"4fd3f3422b2d2a3dfd5cdd0f387b3a8ec45f006c6ea896a4cb41264c2100bb2c","affectsGlobalScope":true,"impliedFormat":1},{"version":"69e65d976bf166ce4a9e6f6c18f94d2424bf116e90837ace179610dbccad9b42","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"62bb211266ee48b2d0edf0d8d1b191f0c24fc379a82bd4c1692a082c540bc6b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"fef8cfad2e2dc5f5b3d97a6f4f2e92848eb1b88e897bb7318cef0e2820bceaab","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"f1e2a172204962276504466a6393426d2ca9c54894b1ad0a6c9dad867a65f876","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"b5ce7a470bc3628408429040c4e3a53a27755022a32fd05e2cb694e7015386c7","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"bab26767638ab3557de12c900f0b91f710c7dc40ee9793d5a27d32c04f0bf646","affectsGlobalScope":true,"impliedFormat":1},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e3c06ea092138bf9fa5e874a1fdbc9d54805d074bee1de31b99a11e2fec239d","affectsGlobalScope":true,"impliedFormat":1},{"version":"87dc0f382502f5bbce5129bdc0aea21e19a3abbc19259e0b43ae038a9fc4e326","affectsGlobalScope":true,"impliedFormat":1},{"version":"b1cb28af0c891c8c96b2d6b7be76bd394fddcfdb4709a20ba05a7c1605eea0f9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2fef54945a13095fdb9b84f705f2b5994597640c46afeb2ce78352fab4cb3279","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac77cb3e8c6d3565793eb90a8373ee8033146315a3dbead3bde8db5eaf5e5ec6","affectsGlobalScope":true,"impliedFormat":1},{"version":"56e4ed5aab5f5920980066a9409bfaf53e6d21d3f8d020c17e4de584d29600ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ece9f17b3866cc077099c73f4983bddbcb1dc7ddb943227f1ec070f529dedd1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a6282c8827e4b9a95f4bf4f5c205673ada31b982f50572d27103df8ceb8013c","affectsGlobalScope":true,"impliedFormat":1},{"version":"1c9319a09485199c1f7b0498f2988d6d2249793ef67edda49d1e584746be9032","affectsGlobalScope":true,"impliedFormat":1},{"version":"e3a2a0cee0f03ffdde24d89660eba2685bfbdeae955a6c67e8c4c9fd28928eeb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811c71eee4aa0ac5f7adf713323a5c41b0cf6c4e17367a34fbce379e12bbf0a4","affectsGlobalScope":true,"impliedFormat":1},{"version":"51ad4c928303041605b4d7ae32e0c1ee387d43a24cd6f1ebf4a2699e1076d4fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true,"impliedFormat":1},{"version":"61d6a2092f48af66dbfb220e31eea8b10bc02b6932d6e529005fd2d7b3281290","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"3c19cad39d75fd23bd945804bff86e99db7d67e623602b3062b35258ee99b72a","signature":"0a63381be482e48e24b91af38c2c62af01e2bdb50caab2578987928b417efacb"}],"root":[79],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"checkJs":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"rootDir":"./src","skipDefaultLibCheck":true,"strict":true,"target":99},"latestChangedDtsFile":"./build-types/index.d.ts","version":"5.7.2"}
|