@wordpress/shortcode 4.12.1-next.082ed6819.0 → 4.13.1-next.a9f418477.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## Enhancements
6
+
7
+ - The package now has built-in TypeScript definitions 🎉 ([#67416](https://github.com/WordPress/gutenberg/pull/67416))
8
+
9
+ ## 4.13.0 (2024-11-27)
10
+
5
11
  ## 4.12.0 (2024-11-16)
6
12
 
7
13
  ## 4.11.0 (2024-10-30)
package/README.md CHANGED
@@ -32,7 +32,7 @@ _Parameters_
32
32
 
33
33
  _Returns_
34
34
 
35
- - `WPShortcodeAttrs`: Parsed shortcode attributes.
35
+ - `import('./types').ShortcodeAttrs`: Parsed shortcode attributes.
36
36
 
37
37
  ### default
38
38
 
@@ -40,13 +40,9 @@ Creates a shortcode instance.
40
40
 
41
41
  To access a raw representation of a shortcode, pass an `options` object, containing a `tag` string, a string or object of `attrs`, a string indicating the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a `content` string.
42
42
 
43
- _Parameters_
44
-
45
- - _options_ `Object`: Options as described.
46
-
47
- _Returns_
43
+ _Type_
48
44
 
49
- - `WPShortcode`: Shortcode instance.
45
+ - `import('./types').shortcode`Shortcode instance.
50
46
 
51
47
  ### fromMatch
52
48
 
@@ -56,11 +52,11 @@ Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated by
56
52
 
57
53
  _Parameters_
58
54
 
59
- - _match_ `Array`: Match array.
55
+ - _match_ `import('./types').Match`: Match array.
60
56
 
61
57
  _Returns_
62
58
 
63
- - `WPShortcode`: Shortcode instance.
59
+ - `InstanceType<import('./types').shortcode>`: Shortcode instance.
64
60
 
65
61
  ### next
66
62
 
@@ -74,7 +70,7 @@ _Parameters_
74
70
 
75
71
  _Returns_
76
72
 
77
- - `WPShortcodeMatch | undefined`: Matched information.
73
+ - `import('./types').ShortcodeMatch | undefined`: Matched information.
78
74
 
79
75
  ### regexp
80
76
 
@@ -108,7 +104,7 @@ _Parameters_
108
104
 
109
105
  - _tag_ `string`: Shortcode tag.
110
106
  - _text_ `string`: Text to search.
111
- - _callback_ `Function`: Function to process the match and return replacement string.
107
+ - _callback_ `import('./types').ReplaceCallback`: Function to process the match and return replacement string.
112
108
 
113
109
  _Returns_
114
110
 
package/build/index.js CHANGED
@@ -4,6 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ var _exportNames = {
8
+ next: true,
9
+ replace: true,
10
+ string: true,
11
+ regexp: true,
12
+ attrs: true,
13
+ fromMatch: true
14
+ };
7
15
  exports.default = exports.attrs = void 0;
8
16
  exports.fromMatch = fromMatch;
9
17
  exports.next = next;
@@ -11,39 +19,22 @@ exports.regexp = regexp;
11
19
  exports.replace = replace;
12
20
  exports.string = string;
13
21
  var _memize = _interopRequireDefault(require("memize"));
22
+ var _types = require("./types");
23
+ Object.keys(_types).forEach(function (key) {
24
+ if (key === "default" || key === "__esModule") return;
25
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
26
+ if (key in exports && exports[key] === _types[key]) return;
27
+ Object.defineProperty(exports, key, {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _types[key];
31
+ }
32
+ });
33
+ });
14
34
  /**
15
35
  * External dependencies
16
36
  */
17
37
 
18
- /**
19
- * Shortcode attributes object.
20
- *
21
- * @typedef {Object} WPShortcodeAttrs
22
- *
23
- * @property {Object} named Object with named attributes.
24
- * @property {Array} numeric Array with numeric attributes.
25
- */
26
-
27
- /**
28
- * Shortcode object.
29
- *
30
- * @typedef {Object} WPShortcode
31
- *
32
- * @property {string} tag Shortcode tag.
33
- * @property {WPShortcodeAttrs} attrs Shortcode attributes.
34
- * @property {string} content Shortcode content.
35
- * @property {string} type Shortcode type: `self-closing`,
36
- * `closed`, or `single`.
37
- */
38
-
39
- /**
40
- * @typedef {Object} WPShortcodeMatch
41
- *
42
- * @property {number} index Index the shortcode is found at.
43
- * @property {string} content Matched content.
44
- * @property {WPShortcode} shortcode Shortcode instance of the match.
45
- */
46
-
47
38
  /**
48
39
  * Find the next matching shortcode.
49
40
  *
@@ -51,7 +42,7 @@ var _memize = _interopRequireDefault(require("memize"));
51
42
  * @param {string} text Text to search.
52
43
  * @param {number} index Index to start search from.
53
44
  *
54
- * @return {WPShortcodeMatch | undefined} Matched information.
45
+ * @return {import('./types').ShortcodeMatch | undefined} Matched information.
55
46
  */
56
47
  function next(tag, text, index = 0) {
57
48
  const re = regexp(tag);
@@ -88,10 +79,10 @@ function next(tag, text, index = 0) {
88
79
  /**
89
80
  * Replace matching shortcodes in a block of text.
90
81
  *
91
- * @param {string} tag Shortcode tag.
92
- * @param {string} text Text to search.
93
- * @param {Function} callback Function to process the match and return
94
- * replacement string.
82
+ * @param {string} tag Shortcode tag.
83
+ * @param {string} text Text to search.
84
+ * @param {import('./types').ReplaceCallback} callback Function to process the match and return
85
+ * replacement string.
95
86
  *
96
87
  * @return {string} Text with shortcodes replaced.
97
88
  */
@@ -168,7 +159,7 @@ function regexp(tag) {
168
159
  *
169
160
  * @param {string} text Serialised shortcode attributes.
170
161
  *
171
- * @return {WPShortcodeAttrs} Parsed shortcode attributes.
162
+ * @return {import('./types').ShortcodeAttrs} Parsed shortcode attributes.
172
163
  */
173
164
  const attrs = exports.attrs = (0, _memize.default)(text => {
174
165
  const named = {};
@@ -223,9 +214,9 @@ const attrs = exports.attrs = (0, _memize.default)(text => {
223
214
  * by `regexp()`. `match` can also be set to the `arguments` from a callback
224
215
  * passed to `regexp.replace()`.
225
216
  *
226
- * @param {Array} match Match array.
217
+ * @param {import('./types').Match} match Match array.
227
218
  *
228
- * @return {WPShortcode} Shortcode instance.
219
+ * @return {InstanceType<import('./types').shortcode>} Shortcode instance.
229
220
  */
230
221
  function fromMatch(match) {
231
222
  let type;
@@ -252,9 +243,7 @@ function fromMatch(match) {
252
243
  * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a
253
244
  * `content` string.
254
245
  *
255
- * @param {Object} options Options as described.
256
- *
257
- * @return {WPShortcode} Shortcode instance.
246
+ * @type {import('./types').shortcode} Shortcode instance.
258
247
  */
259
248
  const shortcode = Object.assign(function (options) {
260
249
  const {
@@ -322,7 +311,7 @@ Object.assign(shortcode.prototype, {
322
311
  * @param {(number|string)} attr Attribute key.
323
312
  * @param {string} value Attribute value.
324
313
  *
325
- * @return {WPShortcode} Shortcode instance.
314
+ * @return {InstanceType< import('./types').shortcode >} Shortcode instance.
326
315
  */
327
316
  set(attr, value) {
328
317
  this.attrs[typeof attr === 'number' ? 'numeric' : 'named'][attr] = value;
@@ -1 +1 @@
1
- {"version":3,"names":["_memize","_interopRequireDefault","require","next","tag","text","index","re","regexp","lastIndex","match","exec","result","content","shortcode","fromMatch","slice","replace","callback","left","$3","attrs","slash","closing","right","arguments","string","options","RegExp","exports","memize","named","numeric","pattern","toLowerCase","push","type","Object","assign","attributes","attributeTypes","length","every","t","key","entries","forEach","value","set","prototype","get","attr","test","name","_default","default"],"sources":["@wordpress/shortcode/src/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\n\n/**\n * Shortcode attributes object.\n *\n * @typedef {Object} WPShortcodeAttrs\n *\n * @property {Object} named Object with named attributes.\n * @property {Array} numeric Array with numeric attributes.\n */\n\n/**\n * Shortcode object.\n *\n * @typedef {Object} WPShortcode\n *\n * @property {string} tag Shortcode tag.\n * @property {WPShortcodeAttrs} attrs Shortcode attributes.\n * @property {string} content Shortcode content.\n * @property {string} type Shortcode type: `self-closing`,\n * `closed`, or `single`.\n */\n\n/**\n * @typedef {Object} WPShortcodeMatch\n *\n * @property {number} index Index the shortcode is found at.\n * @property {string} content Matched content.\n * @property {WPShortcode} shortcode Shortcode instance of the match.\n */\n\n/**\n * Find the next matching shortcode.\n *\n * @param {string} tag Shortcode tag.\n * @param {string} text Text to search.\n * @param {number} index Index to start search from.\n *\n * @return {WPShortcodeMatch | undefined} Matched information.\n */\nexport function next( tag, text, index = 0 ) {\n\tconst re = regexp( tag );\n\n\tre.lastIndex = index;\n\n\tconst match = re.exec( text );\n\n\tif ( ! match ) {\n\t\treturn;\n\t}\n\n\t// If we matched an escaped shortcode, try again.\n\tif ( '[' === match[ 1 ] && ']' === match[ 7 ] ) {\n\t\treturn next( tag, text, re.lastIndex );\n\t}\n\n\tconst result = {\n\t\tindex: match.index,\n\t\tcontent: match[ 0 ],\n\t\tshortcode: fromMatch( match ),\n\t};\n\n\t// If we matched a leading `[`, strip it from the match and increment the\n\t// index accordingly.\n\tif ( match[ 1 ] ) {\n\t\tresult.content = result.content.slice( 1 );\n\t\tresult.index++;\n\t}\n\n\t// If we matched a trailing `]`, strip it from the match.\n\tif ( match[ 7 ] ) {\n\t\tresult.content = result.content.slice( 0, -1 );\n\t}\n\n\treturn result;\n}\n\n/**\n * Replace matching shortcodes in a block of text.\n *\n * @param {string} tag Shortcode tag.\n * @param {string} text Text to search.\n * @param {Function} callback Function to process the match and return\n * replacement string.\n *\n * @return {string} Text with shortcodes replaced.\n */\nexport function replace( tag, text, callback ) {\n\treturn text.replace(\n\t\tregexp( tag ),\n\t\tfunction ( match, left, $3, attrs, slash, content, closing, right ) {\n\t\t\t// If both extra brackets exist, the shortcode has been properly\n\t\t\t// escaped.\n\t\t\tif ( left === '[' && right === ']' ) {\n\t\t\t\treturn match;\n\t\t\t}\n\n\t\t\t// Create the match object and pass it through the callback.\n\t\t\tconst result = callback( fromMatch( arguments ) );\n\n\t\t\t// Make sure to return any of the extra brackets if they weren't used to\n\t\t\t// escape the shortcode.\n\t\t\treturn result || result === '' ? left + result + right : match;\n\t\t}\n\t);\n}\n\n/**\n * Generate a string from shortcode parameters.\n *\n * Creates a shortcode instance and returns a string.\n *\n * Accepts the same `options` as the `shortcode()` constructor, containing a\n * `tag` string, a string or object of `attrs`, a boolean indicating whether to\n * format the shortcode using a `single` tag, and a `content` string.\n *\n * @param {Object} options\n *\n * @return {string} String representation of the shortcode.\n */\nexport function string( options ) {\n\treturn new shortcode( options ).string();\n}\n\n/**\n * Generate a RegExp to identify a shortcode.\n *\n * The base regex is functionally equivalent to the one found in\n * `get_shortcode_regex()` in `wp-includes/shortcodes.php`.\n *\n * Capture groups:\n *\n * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`\n * 2. The shortcode name\n * 3. The shortcode argument list\n * 4. The self closing `/`\n * 5. The content of a shortcode when it wraps some content.\n * 6. The closing tag.\n * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`\n *\n * @param {string} tag Shortcode tag.\n *\n * @return {RegExp} Shortcode RegExp.\n */\nexport function regexp( tag ) {\n\treturn new RegExp(\n\t\t'\\\\[(\\\\[?)(' +\n\t\t\ttag +\n\t\t\t')(?![\\\\w-])([^\\\\]\\\\/]*(?:\\\\/(?!\\\\])[^\\\\]\\\\/]*)*?)(?:(\\\\/)\\\\]|\\\\](?:([^\\\\[]*(?:\\\\[(?!\\\\/\\\\2\\\\])[^\\\\[]*)*)(\\\\[\\\\/\\\\2\\\\]))?)(\\\\]?)',\n\t\t'g'\n\t);\n}\n\n/**\n * Parse shortcode attributes.\n *\n * Shortcodes accept many types of attributes. These can chiefly be divided into\n * named and numeric attributes:\n *\n * Named attributes are assigned on a key/value basis, while numeric attributes\n * are treated as an array.\n *\n * Named attributes can be formatted as either `name=\"value\"`, `name='value'`,\n * or `name=value`. Numeric attributes can be formatted as `\"value\"` or just\n * `value`.\n *\n * @param {string} text Serialised shortcode attributes.\n *\n * @return {WPShortcodeAttrs} Parsed shortcode attributes.\n */\nexport const attrs = memize( ( text ) => {\n\tconst named = {};\n\tconst numeric = [];\n\n\t// This regular expression is reused from `shortcode_parse_atts()` in\n\t// `wp-includes/shortcodes.php`.\n\t//\n\t// Capture groups:\n\t//\n\t// 1. An attribute name, that corresponds to...\n\t// 2. a value in double quotes.\n\t// 3. An attribute name, that corresponds to...\n\t// 4. a value in single quotes.\n\t// 5. An attribute name, that corresponds to...\n\t// 6. an unquoted value.\n\t// 7. A numeric attribute in double quotes.\n\t// 8. A numeric attribute in single quotes.\n\t// 9. An unquoted numeric attribute.\n\tconst pattern =\n\t\t/([\\w-]+)\\s*=\\s*\"([^\"]*)\"(?:\\s|$)|([\\w-]+)\\s*=\\s*'([^']*)'(?:\\s|$)|([\\w-]+)\\s*=\\s*([^\\s'\"]+)(?:\\s|$)|\"([^\"]*)\"(?:\\s|$)|'([^']*)'(?:\\s|$)|(\\S+)(?:\\s|$)/g;\n\n\t// Map zero-width spaces to actual spaces.\n\ttext = text.replace( /[\\u00a0\\u200b]/g, ' ' );\n\n\tlet match;\n\n\t// Match and normalize attributes.\n\twhile ( ( match = pattern.exec( text ) ) ) {\n\t\tif ( match[ 1 ] ) {\n\t\t\tnamed[ match[ 1 ].toLowerCase() ] = match[ 2 ];\n\t\t} else if ( match[ 3 ] ) {\n\t\t\tnamed[ match[ 3 ].toLowerCase() ] = match[ 4 ];\n\t\t} else if ( match[ 5 ] ) {\n\t\t\tnamed[ match[ 5 ].toLowerCase() ] = match[ 6 ];\n\t\t} else if ( match[ 7 ] ) {\n\t\t\tnumeric.push( match[ 7 ] );\n\t\t} else if ( match[ 8 ] ) {\n\t\t\tnumeric.push( match[ 8 ] );\n\t\t} else if ( match[ 9 ] ) {\n\t\t\tnumeric.push( match[ 9 ] );\n\t\t}\n\t}\n\n\treturn { named, numeric };\n} );\n\n/**\n * Generate a Shortcode Object from a RegExp match.\n *\n * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated\n * by `regexp()`. `match` can also be set to the `arguments` from a callback\n * passed to `regexp.replace()`.\n *\n * @param {Array} match Match array.\n *\n * @return {WPShortcode} Shortcode instance.\n */\nexport function fromMatch( match ) {\n\tlet type;\n\n\tif ( match[ 4 ] ) {\n\t\ttype = 'self-closing';\n\t} else if ( match[ 6 ] ) {\n\t\ttype = 'closed';\n\t} else {\n\t\ttype = 'single';\n\t}\n\n\treturn new shortcode( {\n\t\ttag: match[ 2 ],\n\t\tattrs: match[ 3 ],\n\t\ttype,\n\t\tcontent: match[ 5 ],\n\t} );\n}\n\n/**\n * Creates a shortcode instance.\n *\n * To access a raw representation of a shortcode, pass an `options` object,\n * containing a `tag` string, a string or object of `attrs`, a string indicating\n * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a\n * `content` string.\n *\n * @param {Object} options Options as described.\n *\n * @return {WPShortcode} Shortcode instance.\n */\nconst shortcode = Object.assign(\n\tfunction ( options ) {\n\t\tconst { tag, attrs: attributes, type, content } = options || {};\n\t\tObject.assign( this, { tag, type, content } );\n\n\t\t// Ensure we have a correctly formatted `attrs` object.\n\t\tthis.attrs = {\n\t\t\tnamed: {},\n\t\t\tnumeric: [],\n\t\t};\n\n\t\tif ( ! attributes ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst attributeTypes = [ 'named', 'numeric' ];\n\n\t\t// Parse a string of attributes.\n\t\tif ( typeof attributes === 'string' ) {\n\t\t\tthis.attrs = attrs( attributes );\n\t\t\t// Identify a correctly formatted `attrs` object.\n\t\t} else if (\n\t\t\tattributes.length === attributeTypes.length &&\n\t\t\tattributeTypes.every( ( t, key ) => t === attributes[ key ] )\n\t\t) {\n\t\t\tthis.attrs = attributes;\n\t\t\t// Handle a flat object of attributes.\n\t\t} else {\n\t\t\tObject.entries( attributes ).forEach( ( [ key, value ] ) => {\n\t\t\t\tthis.set( key, value );\n\t\t\t} );\n\t\t}\n\t},\n\t{\n\t\tnext,\n\t\treplace,\n\t\tstring,\n\t\tregexp,\n\t\tattrs,\n\t\tfromMatch,\n\t}\n);\n\nObject.assign( shortcode.prototype, {\n\t/**\n\t * Get a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param {(number|string)} attr Attribute key.\n\t *\n\t * @return {string} Attribute value.\n\t */\n\tget( attr ) {\n\t\treturn this.attrs[ typeof attr === 'number' ? 'numeric' : 'named' ][\n\t\t\tattr\n\t\t];\n\t},\n\n\t/**\n\t * Set a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param {(number|string)} attr Attribute key.\n\t * @param {string} value Attribute value.\n\t *\n\t * @return {WPShortcode} Shortcode instance.\n\t */\n\tset( attr, value ) {\n\t\tthis.attrs[ typeof attr === 'number' ? 'numeric' : 'named' ][ attr ] =\n\t\t\tvalue;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Transform the shortcode into a string.\n\t *\n\t * @return {string} String representation of the shortcode.\n\t */\n\tstring() {\n\t\tlet text = '[' + this.tag;\n\n\t\tthis.attrs.numeric.forEach( ( value ) => {\n\t\t\tif ( /\\s/.test( value ) ) {\n\t\t\t\ttext += ' \"' + value + '\"';\n\t\t\t} else {\n\t\t\t\ttext += ' ' + value;\n\t\t\t}\n\t\t} );\n\n\t\tObject.entries( this.attrs.named ).forEach( ( [ name, value ] ) => {\n\t\t\ttext += ' ' + name + '=\"' + value + '\"';\n\t\t} );\n\n\t\t// If the tag is marked as `single` or `self-closing`, close the tag and\n\t\t// ignore any additional content.\n\t\tif ( 'single' === this.type ) {\n\t\t\treturn text + ']';\n\t\t} else if ( 'self-closing' === this.type ) {\n\t\t\treturn text + ' /]';\n\t\t}\n\n\t\t// Complete the opening tag.\n\t\ttext += ']';\n\n\t\tif ( this.content ) {\n\t\t\ttext += this.content;\n\t\t}\n\n\t\t// Add the closing tag.\n\t\treturn text + '[/' + this.tag + ']';\n\t},\n} );\n\nexport default shortcode;\n"],"mappings":";;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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CAAE,KAAM;MAClE1C,IAAI,IAAI,GAAG,GAAGgD,IAAI,GAAG,IAAI,GAAGN,KAAK,GAAG,GAAG;IACxC,CAAE,CAAC;;IAEH;IACA;IACA,IAAK,QAAQ,KAAK,IAAI,CAACX,IAAI,EAAG;MAC7B,OAAO/B,IAAI,GAAG,GAAG;IAClB,CAAC,MAAM,IAAK,cAAc,KAAK,IAAI,CAAC+B,IAAI,EAAG;MAC1C,OAAO/B,IAAI,GAAG,KAAK;IACpB;;IAEA;IACAA,IAAI,IAAI,GAAG;IAEX,IAAK,IAAI,CAACQ,OAAO,EAAG;MACnBR,IAAI,IAAI,IAAI,CAACQ,OAAO;IACrB;;IAEA;IACA,OAAOR,IAAI,GAAG,IAAI,GAAG,IAAI,CAACD,GAAG,GAAG,GAAG;EACpC;AACD,CAAE,CAAC;AAAC,IAAAkD,QAAA,GAAAzB,OAAA,CAAA0B,OAAA,GAEWzC,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["_memize","_interopRequireDefault","require","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","next","tag","text","index","re","regexp","lastIndex","match","exec","result","content","shortcode","fromMatch","slice","replace","callback","left","$3","attrs","slash","closing","right","arguments","string","options","RegExp","memize","named","numeric","pattern","toLowerCase","push","type","assign","attributes","attributeTypes","length","every","t","entries","value","set","attr","test","name","_default","default"],"sources":["@wordpress/shortcode/src/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\n\nexport * from './types';\n\n/**\n * Find the next matching shortcode.\n *\n * @param {string} tag Shortcode tag.\n * @param {string} text Text to search.\n * @param {number} index Index to start search from.\n *\n * @return {import('./types').ShortcodeMatch | undefined} Matched information.\n */\nexport function next( tag, text, index = 0 ) {\n\tconst re = regexp( tag );\n\n\tre.lastIndex = index;\n\n\tconst match = re.exec( text );\n\n\tif ( ! match ) {\n\t\treturn;\n\t}\n\n\t// If we matched an escaped shortcode, try again.\n\tif ( '[' === match[ 1 ] && ']' === match[ 7 ] ) {\n\t\treturn next( tag, text, re.lastIndex );\n\t}\n\n\tconst result = {\n\t\tindex: match.index,\n\t\tcontent: match[ 0 ],\n\t\tshortcode: fromMatch( match ),\n\t};\n\n\t// If we matched a leading `[`, strip it from the match and increment the\n\t// index accordingly.\n\tif ( match[ 1 ] ) {\n\t\tresult.content = result.content.slice( 1 );\n\t\tresult.index++;\n\t}\n\n\t// If we matched a trailing `]`, strip it from the match.\n\tif ( match[ 7 ] ) {\n\t\tresult.content = result.content.slice( 0, -1 );\n\t}\n\n\treturn result;\n}\n\n/**\n * Replace matching shortcodes in a block of text.\n *\n * @param {string} tag Shortcode tag.\n * @param {string} text Text to search.\n * @param {import('./types').ReplaceCallback} callback Function to process the match and return\n * replacement string.\n *\n * @return {string} Text with shortcodes replaced.\n */\nexport function replace( tag, text, callback ) {\n\treturn text.replace(\n\t\tregexp( tag ),\n\t\tfunction ( match, left, $3, attrs, slash, content, closing, right ) {\n\t\t\t// If both extra brackets exist, the shortcode has been properly\n\t\t\t// escaped.\n\t\t\tif ( left === '[' && right === ']' ) {\n\t\t\t\treturn match;\n\t\t\t}\n\n\t\t\t// Create the match object and pass it through the callback.\n\t\t\tconst result = callback( fromMatch( arguments ) );\n\n\t\t\t// Make sure to return any of the extra brackets if they weren't used to\n\t\t\t// escape the shortcode.\n\t\t\treturn result || result === '' ? left + result + right : match;\n\t\t}\n\t);\n}\n\n/**\n * Generate a string from shortcode parameters.\n *\n * Creates a shortcode instance and returns a string.\n *\n * Accepts the same `options` as the `shortcode()` constructor, containing a\n * `tag` string, a string or object of `attrs`, a boolean indicating whether to\n * format the shortcode using a `single` tag, and a `content` string.\n *\n * @param {Object} options\n *\n * @return {string} String representation of the shortcode.\n */\nexport function string( options ) {\n\treturn new shortcode( options ).string();\n}\n\n/**\n * Generate a RegExp to identify a shortcode.\n *\n * The base regex is functionally equivalent to the one found in\n * `get_shortcode_regex()` in `wp-includes/shortcodes.php`.\n *\n * Capture groups:\n *\n * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`\n * 2. The shortcode name\n * 3. The shortcode argument list\n * 4. The self closing `/`\n * 5. The content of a shortcode when it wraps some content.\n * 6. The closing tag.\n * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`\n *\n * @param {string} tag Shortcode tag.\n *\n * @return {RegExp} Shortcode RegExp.\n */\nexport function regexp( tag ) {\n\treturn new RegExp(\n\t\t'\\\\[(\\\\[?)(' +\n\t\t\ttag +\n\t\t\t')(?![\\\\w-])([^\\\\]\\\\/]*(?:\\\\/(?!\\\\])[^\\\\]\\\\/]*)*?)(?:(\\\\/)\\\\]|\\\\](?:([^\\\\[]*(?:\\\\[(?!\\\\/\\\\2\\\\])[^\\\\[]*)*)(\\\\[\\\\/\\\\2\\\\]))?)(\\\\]?)',\n\t\t'g'\n\t);\n}\n\n/**\n * Parse shortcode attributes.\n *\n * Shortcodes accept many types of attributes. These can chiefly be divided into\n * named and numeric attributes:\n *\n * Named attributes are assigned on a key/value basis, while numeric attributes\n * are treated as an array.\n *\n * Named attributes can be formatted as either `name=\"value\"`, `name='value'`,\n * or `name=value`. Numeric attributes can be formatted as `\"value\"` or just\n * `value`.\n *\n * @param {string} text Serialised shortcode attributes.\n *\n * @return {import('./types').ShortcodeAttrs} Parsed shortcode attributes.\n */\nexport const attrs = memize( ( text ) => {\n\tconst named = {};\n\tconst numeric = [];\n\n\t// This regular expression is reused from `shortcode_parse_atts()` in\n\t// `wp-includes/shortcodes.php`.\n\t//\n\t// Capture groups:\n\t//\n\t// 1. An attribute name, that corresponds to...\n\t// 2. a value in double quotes.\n\t// 3. An attribute name, that corresponds to...\n\t// 4. a value in single quotes.\n\t// 5. An attribute name, that corresponds to...\n\t// 6. an unquoted value.\n\t// 7. A numeric attribute in double quotes.\n\t// 8. A numeric attribute in single quotes.\n\t// 9. An unquoted numeric attribute.\n\tconst pattern =\n\t\t/([\\w-]+)\\s*=\\s*\"([^\"]*)\"(?:\\s|$)|([\\w-]+)\\s*=\\s*'([^']*)'(?:\\s|$)|([\\w-]+)\\s*=\\s*([^\\s'\"]+)(?:\\s|$)|\"([^\"]*)\"(?:\\s|$)|'([^']*)'(?:\\s|$)|(\\S+)(?:\\s|$)/g;\n\n\t// Map zero-width spaces to actual spaces.\n\ttext = text.replace( /[\\u00a0\\u200b]/g, ' ' );\n\n\tlet match;\n\n\t// Match and normalize attributes.\n\twhile ( ( match = pattern.exec( text ) ) ) {\n\t\tif ( match[ 1 ] ) {\n\t\t\tnamed[ match[ 1 ].toLowerCase() ] = match[ 2 ];\n\t\t} else if ( match[ 3 ] ) {\n\t\t\tnamed[ match[ 3 ].toLowerCase() ] = match[ 4 ];\n\t\t} else if ( match[ 5 ] ) {\n\t\t\tnamed[ match[ 5 ].toLowerCase() ] = match[ 6 ];\n\t\t} else if ( match[ 7 ] ) {\n\t\t\tnumeric.push( match[ 7 ] );\n\t\t} else if ( match[ 8 ] ) {\n\t\t\tnumeric.push( match[ 8 ] );\n\t\t} else if ( match[ 9 ] ) {\n\t\t\tnumeric.push( match[ 9 ] );\n\t\t}\n\t}\n\n\treturn { named, numeric };\n} );\n\n/**\n * Generate a Shortcode Object from a RegExp match.\n *\n * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated\n * by `regexp()`. `match` can also be set to the `arguments` from a callback\n * passed to `regexp.replace()`.\n *\n * @param {import('./types').Match} match Match array.\n *\n * @return {InstanceType<import('./types').shortcode>} Shortcode instance.\n */\nexport function fromMatch( match ) {\n\tlet type;\n\n\tif ( match[ 4 ] ) {\n\t\ttype = 'self-closing';\n\t} else if ( match[ 6 ] ) {\n\t\ttype = 'closed';\n\t} else {\n\t\ttype = 'single';\n\t}\n\n\treturn new shortcode( {\n\t\ttag: match[ 2 ],\n\t\tattrs: match[ 3 ],\n\t\ttype,\n\t\tcontent: match[ 5 ],\n\t} );\n}\n\n/**\n * Creates a shortcode instance.\n *\n * To access a raw representation of a shortcode, pass an `options` object,\n * containing a `tag` string, a string or object of `attrs`, a string indicating\n * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a\n * `content` string.\n *\n * @type {import('./types').shortcode} Shortcode instance.\n */\nconst shortcode = Object.assign(\n\tfunction ( options ) {\n\t\tconst { tag, attrs: attributes, type, content } = options || {};\n\t\tObject.assign( this, { tag, type, content } );\n\n\t\t// Ensure we have a correctly formatted `attrs` object.\n\t\tthis.attrs = {\n\t\t\tnamed: {},\n\t\t\tnumeric: [],\n\t\t};\n\n\t\tif ( ! attributes ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst attributeTypes = [ 'named', 'numeric' ];\n\n\t\t// Parse a string of attributes.\n\t\tif ( typeof attributes === 'string' ) {\n\t\t\tthis.attrs = attrs( attributes );\n\t\t\t// Identify a correctly formatted `attrs` object.\n\t\t} else if (\n\t\t\tattributes.length === attributeTypes.length &&\n\t\t\tattributeTypes.every( ( t, key ) => t === attributes[ key ] )\n\t\t) {\n\t\t\tthis.attrs = attributes;\n\t\t\t// Handle a flat object of attributes.\n\t\t} else {\n\t\t\tObject.entries( attributes ).forEach( ( [ key, value ] ) => {\n\t\t\t\tthis.set( key, value );\n\t\t\t} );\n\t\t}\n\t},\n\t{\n\t\tnext,\n\t\treplace,\n\t\tstring,\n\t\tregexp,\n\t\tattrs,\n\t\tfromMatch,\n\t}\n);\n\nObject.assign( shortcode.prototype, {\n\t/**\n\t * Get a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param {(number|string)} attr Attribute key.\n\t *\n\t * @return {string} Attribute value.\n\t */\n\tget( attr ) {\n\t\treturn this.attrs[ typeof attr === 'number' ? 'numeric' : 'named' ][\n\t\t\tattr\n\t\t];\n\t},\n\n\t/**\n\t * Set a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param {(number|string)} attr Attribute key.\n\t * @param {string} value Attribute value.\n\t *\n\t * @return {InstanceType< import('./types').shortcode >} Shortcode instance.\n\t */\n\tset( attr, value ) {\n\t\tthis.attrs[ typeof attr === 'number' ? 'numeric' : 'named' ][ attr ] =\n\t\t\tvalue;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Transform the shortcode into a string.\n\t *\n\t * @return {string} String representation of the shortcode.\n\t */\n\tstring() {\n\t\tlet text = '[' + this.tag;\n\n\t\tthis.attrs.numeric.forEach( ( value ) => {\n\t\t\tif ( /\\s/.test( value ) ) {\n\t\t\t\ttext += ' \"' + value + '\"';\n\t\t\t} else {\n\t\t\t\ttext += ' ' + value;\n\t\t\t}\n\t\t} );\n\n\t\tObject.entries( this.attrs.named ).forEach( ( [ name, value ] ) => {\n\t\t\ttext += ' ' + name + '=\"' + value + '\"';\n\t\t} );\n\n\t\t// If the tag is marked as `single` or `self-closing`, close the tag and\n\t\t// ignore any additional content.\n\t\tif ( 'single' === this.type ) {\n\t\t\treturn text + ']';\n\t\t} else if ( 'self-closing' === this.type ) {\n\t\t\treturn text + ' /]';\n\t\t}\n\n\t\t// Complete the opening tag.\n\t\ttext += ']';\n\n\t\tif ( this.content ) {\n\t\t\ttext += this.content;\n\t\t}\n\n\t\t// Add the closing tag.\n\t\treturn text + '[/' + this.tag + ']';\n\t},\n} );\n\nexport default shortcode;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAA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IACD,CAAE,CAAC;IAEHpD,MAAM,CAACmD,OAAO,CAAE,IAAI,CAACrB,KAAK,CAACS,KAAM,CAAC,CAACrC,OAAO,CAAE,CAAE,CAAEsD,IAAI,EAAEJ,KAAK,CAAE,KAAM;MAClEtC,IAAI,IAAI,GAAG,GAAG0C,IAAI,GAAG,IAAI,GAAGJ,KAAK,GAAG,GAAG;IACxC,CAAE,CAAC;;IAEH;IACA;IACA,IAAK,QAAQ,KAAK,IAAI,CAACR,IAAI,EAAG;MAC7B,OAAO9B,IAAI,GAAG,GAAG;IAClB,CAAC,MAAM,IAAK,cAAc,KAAK,IAAI,CAAC8B,IAAI,EAAG;MAC1C,OAAO9B,IAAI,GAAG,KAAK;IACpB;;IAEA;IACAA,IAAI,IAAI,GAAG;IAEX,IAAK,IAAI,CAACQ,OAAO,EAAG;MACnBR,IAAI,IAAI,IAAI,CAACQ,OAAO;IACrB;;IAEA;IACA,OAAOR,IAAI,GAAG,IAAI,GAAG,IAAI,CAACD,GAAG,GAAG,GAAG;EACpC;AACD,CAAE,CAAC;AAAC,IAAA4C,QAAA,GAAAjD,OAAA,CAAAkD,OAAA,GAEWnC,SAAS","ignoreList":[]}
package/build/types.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["@wordpress/shortcode/src/types.ts"],"sourcesContent":["/**\n * Shortcode attributes object.\n */\nexport type ShortcodeAttrs = {\n\t/**\n\t * Object with named attributes.\n\t */\n\tnamed: Record< string, string | undefined >;\n\n\t/**\n\t * Array with numeric attributes.\n\t */\n\tnumeric: string[];\n};\n\nexport type ShortcodeMatch = {\n\t/**\n\t * Index the shortcode is found at.\n\t */\n\tindex: number;\n\n\t/**\n\t * Matched content.\n\t */\n\tcontent: string;\n\n\t/**\n\t * Shortcode instance of the match.\n\t */\n\tshortcode: Shortcode;\n};\n\n/**\n * Shortcode options.\n */\nexport interface ShortcodeOptions {\n\t/**\n\t * Shortcode tag.\n\t */\n\ttag: string;\n\n\t/**\n\t * Shortcode attributes.\n\t */\n\tattrs?: Partial< ShortcodeAttrs > | string;\n\n\t/**\n\t * Shortcode content.\n\t */\n\tcontent?: string;\n\n\t/**\n\t * Shortcode type: `self-closing`, `closed`, or `single`.\n\t */\n\ttype?: 'self-closing' | 'closed' | 'single';\n}\n\n/**\n * Shortcode object.\n */\nexport interface Shortcode extends ShortcodeOptions {\n\t/**\n\t * Shortcode attributes.\n\t */\n\tattrs: ShortcodeAttrs;\n}\n\nexport type Match =\n\t| NonNullable< ReturnType< RegExp[ 'exec' ] > >\n\t| Array< string >;\n\nexport type ReplaceCallback = ( shortcode: Shortcode ) => string;\n\n/**\n * WordPress Shortcode instance.\n */\nexport interface shortcode {\n\tnew ( options: Partial< ShortcodeOptions > ): Shortcode & {\n\t\t/**\n\t\t * Transform the shortcode into a string.\n\t\t *\n\t\t * @return {string} String representation of the shortcode.\n\t\t */\n\t\tstring: () => string;\n\n\t\t/**\n\t\t * Get a shortcode attribute.\n\t\t *\n\t\t * Automatically detects whether `attr` is named or numeric and routes it\n\t\t * accordingly.\n\t\t *\n\t\t * @param {(number|string)} attr Attribute key.\n\t\t *\n\t\t * @return {string} Attribute value.\n\t\t */\n\t\tget: ( attr: string | number ) => string | undefined;\n\n\t\t/**\n\t\t * Set a shortcode attribute.\n\t\t *\n\t\t * Automatically detects whether `attr` is named or numeric and routes it\n\t\t * accordingly.\n\t\t *\n\t\t * @param {(number|string)} attr Attribute key.\n\t\t * @param {string} value Attribute value.\n\t\t *\n\t\t * @return {InstanceType< shortcode >} Shortcode instance.\n\t\t */\n\t\tset: (\n\t\t\tattr: string | number,\n\t\t\tvalue: string\n\t\t) => InstanceType< shortcode >;\n\t};\n\n\t/**\n\t * Parse shortcode attributes.\n\t *\n\t * Shortcodes accept many types of attributes. These can chiefly be divided into\n\t * named and numeric attributes:\n\t *\n\t * Named attributes are assigned on a key/value basis, while numeric attributes\n\t * are treated as an array.\n\t *\n\t * Named attributes can be formatted as either `name=\"value\"`, `name='value'`,\n\t * or `name=value`. Numeric attributes can be formatted as `\"value\"` or just\n\t * `value`.\n\t *\n\t * @param text Serialised shortcode attributes.\n\t *\n\t * @return Parsed shortcode attributes.\n\t */\n\tattrs: ( text: string ) => ShortcodeAttrs;\n\n\t/**\n\t * Generate a Shortcode Object from a RegExp match.\n\t *\n\t * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated\n\t * by `regexp()`. `match` can also be set to the `arguments` from a callback\n\t * passed to `regexp.replace()`.\n\t *\n\t * @param match Match array.\n\t *\n\t * @return Shortcode instance.\n\t */\n\tfromMatch: ( match: Match ) => InstanceType< shortcode >;\n\n\t/**\n\t * Find the next matching shortcode.\n\t *\n\t * @param tag Shortcode tag.\n\t * @param text Text to search.\n\t * @param index Index to start search from.\n\t *\n\t * @return Matched information.\n\t */\n\tnext: (\n\t\ttag: string,\n\t\ttext: string,\n\t\tindex?: number\n\t) => ShortcodeMatch | undefined;\n\n\t/**\n\t * Generate a RegExp to identify a shortcode.\n\t *\n\t * The base regex is functionally equivalent to the one found in\n\t * `get_shortcode_regex()` in `wp-includes/shortcodes.php`.\n\t *\n\t * Capture groups:\n\t *\n\t * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`\n\t * 2. The shortcode name\n\t * 3. The shortcode argument list\n\t * 4. The self closing `/`\n\t * 5. The content of a shortcode when it wraps some content.\n\t * 6. The closing tag.\n\t * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`\n\t *\n\t * @param tag Shortcode tag.\n\t *\n\t * @return Shortcode RegExp.\n\t */\n\tregexp: ( tag: string ) => RegExp;\n\n\t/**\n\t * Replace matching shortcodes in a block of text.\n\t *\n\t * @param tag Shortcode tag.\n\t * @param text Text to search.\n\t * @param callback Function to process the match and return\n\t * replacement string.\n\t *\n\t * @return Text with shortcodes replaced.\n\t */\n\treplace: ( tag: string, text: string, callback: ReplaceCallback ) => string;\n\n\t/**\n\t * Generate a string from shortcode parameters.\n\t *\n\t * Creates a shortcode instance and returns a string.\n\t *\n\t * Accepts the same `options` as the `shortcode()` constructor, containing a\n\t * `tag` string, a string or object of `attrs`, a boolean indicating whether to\n\t * format the shortcode using a `single` tag, and a `content` string.\n\t *\n\t * @param options\n\t *\n\t * @return String representation of the shortcode.\n\t */\n\tstring: ( options: ShortcodeOptions ) => string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -2,35 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import memize from 'memize';
5
-
6
- /**
7
- * Shortcode attributes object.
8
- *
9
- * @typedef {Object} WPShortcodeAttrs
10
- *
11
- * @property {Object} named Object with named attributes.
12
- * @property {Array} numeric Array with numeric attributes.
13
- */
14
-
15
- /**
16
- * Shortcode object.
17
- *
18
- * @typedef {Object} WPShortcode
19
- *
20
- * @property {string} tag Shortcode tag.
21
- * @property {WPShortcodeAttrs} attrs Shortcode attributes.
22
- * @property {string} content Shortcode content.
23
- * @property {string} type Shortcode type: `self-closing`,
24
- * `closed`, or `single`.
25
- */
26
-
27
- /**
28
- * @typedef {Object} WPShortcodeMatch
29
- *
30
- * @property {number} index Index the shortcode is found at.
31
- * @property {string} content Matched content.
32
- * @property {WPShortcode} shortcode Shortcode instance of the match.
33
- */
5
+ export * from './types';
34
6
 
35
7
  /**
36
8
  * Find the next matching shortcode.
@@ -39,7 +11,7 @@ import memize from 'memize';
39
11
  * @param {string} text Text to search.
40
12
  * @param {number} index Index to start search from.
41
13
  *
42
- * @return {WPShortcodeMatch | undefined} Matched information.
14
+ * @return {import('./types').ShortcodeMatch | undefined} Matched information.
43
15
  */
44
16
  export function next(tag, text, index = 0) {
45
17
  const re = regexp(tag);
@@ -76,10 +48,10 @@ export function next(tag, text, index = 0) {
76
48
  /**
77
49
  * Replace matching shortcodes in a block of text.
78
50
  *
79
- * @param {string} tag Shortcode tag.
80
- * @param {string} text Text to search.
81
- * @param {Function} callback Function to process the match and return
82
- * replacement string.
51
+ * @param {string} tag Shortcode tag.
52
+ * @param {string} text Text to search.
53
+ * @param {import('./types').ReplaceCallback} callback Function to process the match and return
54
+ * replacement string.
83
55
  *
84
56
  * @return {string} Text with shortcodes replaced.
85
57
  */
@@ -156,7 +128,7 @@ export function regexp(tag) {
156
128
  *
157
129
  * @param {string} text Serialised shortcode attributes.
158
130
  *
159
- * @return {WPShortcodeAttrs} Parsed shortcode attributes.
131
+ * @return {import('./types').ShortcodeAttrs} Parsed shortcode attributes.
160
132
  */
161
133
  export const attrs = memize(text => {
162
134
  const named = {};
@@ -211,9 +183,9 @@ export const attrs = memize(text => {
211
183
  * by `regexp()`. `match` can also be set to the `arguments` from a callback
212
184
  * passed to `regexp.replace()`.
213
185
  *
214
- * @param {Array} match Match array.
186
+ * @param {import('./types').Match} match Match array.
215
187
  *
216
- * @return {WPShortcode} Shortcode instance.
188
+ * @return {InstanceType<import('./types').shortcode>} Shortcode instance.
217
189
  */
218
190
  export function fromMatch(match) {
219
191
  let type;
@@ -240,9 +212,7 @@ export function fromMatch(match) {
240
212
  * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a
241
213
  * `content` string.
242
214
  *
243
- * @param {Object} options Options as described.
244
- *
245
- * @return {WPShortcode} Shortcode instance.
215
+ * @type {import('./types').shortcode} Shortcode instance.
246
216
  */
247
217
  const shortcode = Object.assign(function (options) {
248
218
  const {
@@ -310,7 +280,7 @@ Object.assign(shortcode.prototype, {
310
280
  * @param {(number|string)} attr Attribute key.
311
281
  * @param {string} value Attribute value.
312
282
  *
313
- * @return {WPShortcode} Shortcode instance.
283
+ * @return {InstanceType< import('./types').shortcode >} Shortcode instance.
314
284
  */
315
285
  set(attr, value) {
316
286
  this.attrs[typeof attr === 'number' ? 'numeric' : 'named'][attr] = value;
@@ -1 +1 @@
1
- {"version":3,"names":["memize","next","tag","text","index","re","regexp","lastIndex","match","exec","result","content","shortcode","fromMatch","slice","replace","callback","left","$3","attrs","slash","closing","right","arguments","string","options","RegExp","named","numeric","pattern","toLowerCase","push","type","Object","assign","attributes","attributeTypes","length","every","t","key","entries","forEach","value","set","prototype","get","attr","test","name"],"sources":["@wordpress/shortcode/src/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\n\n/**\n * Shortcode attributes object.\n *\n * @typedef {Object} WPShortcodeAttrs\n *\n * @property {Object} named Object with named attributes.\n * @property {Array} numeric Array with numeric attributes.\n */\n\n/**\n * Shortcode object.\n *\n * @typedef {Object} WPShortcode\n *\n * @property {string} tag Shortcode tag.\n * @property {WPShortcodeAttrs} attrs Shortcode attributes.\n * @property {string} content Shortcode content.\n * @property {string} type Shortcode type: `self-closing`,\n * `closed`, or `single`.\n */\n\n/**\n * @typedef {Object} WPShortcodeMatch\n *\n * @property {number} index Index the shortcode is found at.\n * @property {string} content Matched content.\n * @property {WPShortcode} shortcode Shortcode instance of the match.\n */\n\n/**\n * Find the next matching shortcode.\n *\n * @param {string} tag Shortcode tag.\n * @param {string} text Text to search.\n * @param {number} index Index to start search from.\n *\n * @return {WPShortcodeMatch | undefined} Matched information.\n */\nexport function next( tag, text, index = 0 ) {\n\tconst re = regexp( tag );\n\n\tre.lastIndex = index;\n\n\tconst match = re.exec( text );\n\n\tif ( ! match ) {\n\t\treturn;\n\t}\n\n\t// If we matched an escaped shortcode, try again.\n\tif ( '[' === match[ 1 ] && ']' === match[ 7 ] ) {\n\t\treturn next( tag, text, re.lastIndex );\n\t}\n\n\tconst result = {\n\t\tindex: match.index,\n\t\tcontent: match[ 0 ],\n\t\tshortcode: fromMatch( match ),\n\t};\n\n\t// If we matched a leading `[`, strip it from the match and increment the\n\t// index accordingly.\n\tif ( match[ 1 ] ) {\n\t\tresult.content = result.content.slice( 1 );\n\t\tresult.index++;\n\t}\n\n\t// If we matched a trailing `]`, strip it from the match.\n\tif ( match[ 7 ] ) {\n\t\tresult.content = result.content.slice( 0, -1 );\n\t}\n\n\treturn result;\n}\n\n/**\n * Replace matching shortcodes in a block of text.\n *\n * @param {string} tag Shortcode tag.\n * @param {string} text Text to search.\n * @param {Function} callback Function to process the match and return\n * replacement string.\n *\n * @return {string} Text with shortcodes replaced.\n */\nexport function replace( tag, text, callback ) {\n\treturn text.replace(\n\t\tregexp( tag ),\n\t\tfunction ( match, left, $3, attrs, slash, content, closing, right ) {\n\t\t\t// If both extra brackets exist, the shortcode has been properly\n\t\t\t// escaped.\n\t\t\tif ( left === '[' && right === ']' ) {\n\t\t\t\treturn match;\n\t\t\t}\n\n\t\t\t// Create the match object and pass it through the callback.\n\t\t\tconst result = callback( fromMatch( arguments ) );\n\n\t\t\t// Make sure to return any of the extra brackets if they weren't used to\n\t\t\t// escape the shortcode.\n\t\t\treturn result || result === '' ? left + result + right : match;\n\t\t}\n\t);\n}\n\n/**\n * Generate a string from shortcode parameters.\n *\n * Creates a shortcode instance and returns a string.\n *\n * Accepts the same `options` as the `shortcode()` constructor, containing a\n * `tag` string, a string or object of `attrs`, a boolean indicating whether to\n * format the shortcode using a `single` tag, and a `content` string.\n *\n * @param {Object} options\n *\n * @return {string} String representation of the shortcode.\n */\nexport function string( options ) {\n\treturn new shortcode( options ).string();\n}\n\n/**\n * Generate a RegExp to identify a shortcode.\n *\n * The base regex is functionally equivalent to the one found in\n * `get_shortcode_regex()` in `wp-includes/shortcodes.php`.\n *\n * Capture groups:\n *\n * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`\n * 2. The shortcode name\n * 3. The shortcode argument list\n * 4. The self closing `/`\n * 5. The content of a shortcode when it wraps some content.\n * 6. The closing tag.\n * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`\n *\n * @param {string} tag Shortcode tag.\n *\n * @return {RegExp} Shortcode RegExp.\n */\nexport function regexp( tag ) {\n\treturn new RegExp(\n\t\t'\\\\[(\\\\[?)(' +\n\t\t\ttag +\n\t\t\t')(?![\\\\w-])([^\\\\]\\\\/]*(?:\\\\/(?!\\\\])[^\\\\]\\\\/]*)*?)(?:(\\\\/)\\\\]|\\\\](?:([^\\\\[]*(?:\\\\[(?!\\\\/\\\\2\\\\])[^\\\\[]*)*)(\\\\[\\\\/\\\\2\\\\]))?)(\\\\]?)',\n\t\t'g'\n\t);\n}\n\n/**\n * Parse shortcode attributes.\n *\n * Shortcodes accept many types of attributes. These can chiefly be divided into\n * named and numeric attributes:\n *\n * Named attributes are assigned on a key/value basis, while numeric attributes\n * are treated as an array.\n *\n * Named attributes can be formatted as either `name=\"value\"`, `name='value'`,\n * or `name=value`. Numeric attributes can be formatted as `\"value\"` or just\n * `value`.\n *\n * @param {string} text Serialised shortcode attributes.\n *\n * @return {WPShortcodeAttrs} Parsed shortcode attributes.\n */\nexport const attrs = memize( ( text ) => {\n\tconst named = {};\n\tconst numeric = [];\n\n\t// This regular expression is reused from `shortcode_parse_atts()` in\n\t// `wp-includes/shortcodes.php`.\n\t//\n\t// Capture groups:\n\t//\n\t// 1. An attribute name, that corresponds to...\n\t// 2. a value in double quotes.\n\t// 3. An attribute name, that corresponds to...\n\t// 4. a value in single quotes.\n\t// 5. An attribute name, that corresponds to...\n\t// 6. an unquoted value.\n\t// 7. A numeric attribute in double quotes.\n\t// 8. A numeric attribute in single quotes.\n\t// 9. An unquoted numeric attribute.\n\tconst pattern =\n\t\t/([\\w-]+)\\s*=\\s*\"([^\"]*)\"(?:\\s|$)|([\\w-]+)\\s*=\\s*'([^']*)'(?:\\s|$)|([\\w-]+)\\s*=\\s*([^\\s'\"]+)(?:\\s|$)|\"([^\"]*)\"(?:\\s|$)|'([^']*)'(?:\\s|$)|(\\S+)(?:\\s|$)/g;\n\n\t// Map zero-width spaces to actual spaces.\n\ttext = text.replace( /[\\u00a0\\u200b]/g, ' ' );\n\n\tlet match;\n\n\t// Match and normalize attributes.\n\twhile ( ( match = pattern.exec( text ) ) ) {\n\t\tif ( match[ 1 ] ) {\n\t\t\tnamed[ match[ 1 ].toLowerCase() ] = match[ 2 ];\n\t\t} else if ( match[ 3 ] ) {\n\t\t\tnamed[ match[ 3 ].toLowerCase() ] = match[ 4 ];\n\t\t} else if ( match[ 5 ] ) {\n\t\t\tnamed[ match[ 5 ].toLowerCase() ] = match[ 6 ];\n\t\t} else if ( match[ 7 ] ) {\n\t\t\tnumeric.push( match[ 7 ] );\n\t\t} else if ( match[ 8 ] ) {\n\t\t\tnumeric.push( match[ 8 ] );\n\t\t} else if ( match[ 9 ] ) {\n\t\t\tnumeric.push( match[ 9 ] );\n\t\t}\n\t}\n\n\treturn { named, numeric };\n} );\n\n/**\n * Generate a Shortcode Object from a RegExp match.\n *\n * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated\n * by `regexp()`. `match` can also be set to the `arguments` from a callback\n * passed to `regexp.replace()`.\n *\n * @param {Array} match Match array.\n *\n * @return {WPShortcode} Shortcode instance.\n */\nexport function fromMatch( match ) {\n\tlet type;\n\n\tif ( match[ 4 ] ) {\n\t\ttype = 'self-closing';\n\t} else if ( match[ 6 ] ) {\n\t\ttype = 'closed';\n\t} else {\n\t\ttype = 'single';\n\t}\n\n\treturn new shortcode( {\n\t\ttag: match[ 2 ],\n\t\tattrs: match[ 3 ],\n\t\ttype,\n\t\tcontent: match[ 5 ],\n\t} );\n}\n\n/**\n * Creates a shortcode instance.\n *\n * To access a raw representation of a shortcode, pass an `options` object,\n * containing a `tag` string, a string or object of `attrs`, a string indicating\n * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a\n * `content` string.\n *\n * @param {Object} options Options as described.\n *\n * @return {WPShortcode} Shortcode instance.\n */\nconst shortcode = Object.assign(\n\tfunction ( options ) {\n\t\tconst { tag, attrs: attributes, type, content } = options || {};\n\t\tObject.assign( this, { tag, type, content } );\n\n\t\t// Ensure we have a correctly formatted `attrs` object.\n\t\tthis.attrs = {\n\t\t\tnamed: {},\n\t\t\tnumeric: [],\n\t\t};\n\n\t\tif ( ! attributes ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst attributeTypes = [ 'named', 'numeric' ];\n\n\t\t// Parse a string of attributes.\n\t\tif ( typeof attributes === 'string' ) {\n\t\t\tthis.attrs = attrs( attributes );\n\t\t\t// Identify a correctly formatted `attrs` object.\n\t\t} else if (\n\t\t\tattributes.length === attributeTypes.length &&\n\t\t\tattributeTypes.every( ( t, key ) => t === attributes[ key ] )\n\t\t) {\n\t\t\tthis.attrs = attributes;\n\t\t\t// Handle a flat object of attributes.\n\t\t} else {\n\t\t\tObject.entries( attributes ).forEach( ( [ key, value ] ) => {\n\t\t\t\tthis.set( key, value );\n\t\t\t} );\n\t\t}\n\t},\n\t{\n\t\tnext,\n\t\treplace,\n\t\tstring,\n\t\tregexp,\n\t\tattrs,\n\t\tfromMatch,\n\t}\n);\n\nObject.assign( shortcode.prototype, {\n\t/**\n\t * Get a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param {(number|string)} attr Attribute key.\n\t *\n\t * @return {string} Attribute value.\n\t */\n\tget( attr ) {\n\t\treturn this.attrs[ typeof attr === 'number' ? 'numeric' : 'named' ][\n\t\t\tattr\n\t\t];\n\t},\n\n\t/**\n\t * Set a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param {(number|string)} attr Attribute key.\n\t * @param {string} value Attribute value.\n\t *\n\t * @return {WPShortcode} Shortcode instance.\n\t */\n\tset( attr, value ) {\n\t\tthis.attrs[ typeof attr === 'number' ? 'numeric' : 'named' ][ attr ] =\n\t\t\tvalue;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Transform the shortcode into a string.\n\t *\n\t * @return {string} String representation of the shortcode.\n\t */\n\tstring() {\n\t\tlet text = '[' + this.tag;\n\n\t\tthis.attrs.numeric.forEach( ( value ) => {\n\t\t\tif ( /\\s/.test( value ) ) {\n\t\t\t\ttext += ' \"' + value + '\"';\n\t\t\t} else {\n\t\t\t\ttext += ' ' + value;\n\t\t\t}\n\t\t} );\n\n\t\tObject.entries( this.attrs.named ).forEach( ( [ name, value ] ) => {\n\t\t\ttext += ' ' + name + '=\"' + value + '\"';\n\t\t} );\n\n\t\t// If the tag is marked as `single` or `self-closing`, close the tag and\n\t\t// ignore any additional content.\n\t\tif ( 'single' === this.type ) {\n\t\t\treturn text + ']';\n\t\t} else if ( 'self-closing' === this.type ) {\n\t\t\treturn text + ' /]';\n\t\t}\n\n\t\t// Complete the opening tag.\n\t\ttext += ']';\n\n\t\tif ( this.content ) {\n\t\t\ttext += this.content;\n\t\t}\n\n\t\t// Add the closing tag.\n\t\treturn text + '[/' + this.tag + ']';\n\t},\n} );\n\nexport default shortcode;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,QAAQ;;AAE3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,IAAIA,CAAEC,GAAG,EAAEC,IAAI,EAAEC,KAAK,GAAG,CAAC,EAAG;EAC5C,MAAMC,EAAE,GAAGC,MAAM,CAAEJ,GAAI,CAAC;EAExBG,EAAE,CAACE,SAAS,GAAGH,KAAK;EAEpB,MAAMI,KAAK,GAAGH,EAAE,CAACI,IAAI,CAAEN,IAAK,CAAC;EAE7B,IAAK,CAAEK,KAAK,EAAG;IACd;EACD;;EAEA;EACA,IAAK,GAAG,KAAKA,KAAK,CAAE,CAAC,CAAE,IAAI,GAAG,KAAKA,KAAK,CAAE,CAAC,CAAE,EAAG;IAC/C,OAAOP,IAAI,CAAEC,GAAG,EAAEC,IAAI,EAAEE,EAAE,CAACE,SAAU,CAAC;EACvC;EAEA,MAAMG,MAAM,GAAG;IACdN,KAAK,EAAEI,KAAK,CAACJ,KAAK;IAClBO,OAAO,EAAEH,KAAK,CAAE,CAAC,CAAE;IACnBI,SAAS,EAAEC,SAAS,CAAEL,KAAM;EAC7B,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OAAO4B,IAAI,KAAK,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAE,CAAEA,IAAI,CAAE,GACnEJ,KAAK;IACN,OAAO,IAAI;EACZ,CAAC;EAED;AACD;AACA;AACA;AACA;EACCnB,MAAMA,CAAA,EAAG;IACR,IAAIrB,IAAI,GAAG,GAAG,GAAG,IAAI,CAACD,GAAG;IAEzB,IAAI,CAACiB,KAAK,CAACS,OAAO,CAACc,OAAO,CAAIC,KAAK,IAAM;MACxC,IAAK,IAAI,CAACK,IAAI,CAAEL,KAAM,CAAC,EAAG;QACzBxC,IAAI,IAAI,IAAI,GAAGwC,KAAK,GAAG,GAAG;MAC3B,CAAC,MAAM;QACNxC,IAAI,IAAI,GAAG,GAAGwC,KAAK;MACpB;IACD,CAAE,CAAC;IAEHV,MAAM,CAACQ,OAAO,CAAE,IAAI,CAACtB,KAAK,CAACQ,KAAM,CAAC,CAACe,OAAO,CAAE,CAAE,CAAEO,IAAI,EAAEN,KAAK,CAAE,KAAM;MAClExC,IAAI,IAAI,GAAG,GAAG8C,IAAI,GAAG,IAAI,GAAGN,KAAK,GAAG,GAAG;IACxC,CAAE,CAAC;;IAEH;IACA;IACA,IAAK,QAAQ,KAAK,IAAI,CAACX,IAAI,EAAG;MAC7B,OAAO7B,IAAI,GAAG,GAAG;IAClB,CAAC,MAAM,IAAK,cAAc,KAAK,IAAI,CAAC6B,IAAI,EAAG;MAC1C,OAAO7B,IAAI,GAAG,KAAK;IACpB;;IAEA;IACAA,IAAI,IAAI,GAAG;IAEX,IAAK,IAAI,CAACQ,OAAO,EAAG;MACnBR,IAAI,IAAI,IAAI,CAACQ,OAAO;IACrB;;IAEA;IACA,OAAOR,IAAI,GAAG,IAAI,GAAG,IAAI,CAACD,GAAG,GAAG,GAAG;EACpC;AACD,CAAE,CAAC;AAEH,eAAeU,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["memize","next","tag","text","index","re","regexp","lastIndex","match","exec","result","content","shortcode","fromMatch","slice","replace","callback","left","$3","attrs","slash","closing","right","arguments","string","options","RegExp","named","numeric","pattern","toLowerCase","push","type","Object","assign","attributes","attributeTypes","length","every","t","key","entries","forEach","value","set","prototype","get","attr","test","name"],"sources":["@wordpress/shortcode/src/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\n\nexport * from './types';\n\n/**\n * Find the next matching shortcode.\n *\n * @param {string} tag Shortcode tag.\n * @param {string} text Text to search.\n * @param {number} index Index to start search from.\n *\n * @return {import('./types').ShortcodeMatch | undefined} Matched information.\n */\nexport function next( tag, text, index = 0 ) {\n\tconst re = regexp( tag );\n\n\tre.lastIndex = index;\n\n\tconst match = re.exec( text );\n\n\tif ( ! match ) {\n\t\treturn;\n\t}\n\n\t// If we matched an escaped shortcode, try again.\n\tif ( '[' === match[ 1 ] && ']' === match[ 7 ] ) {\n\t\treturn next( tag, text, re.lastIndex );\n\t}\n\n\tconst result = {\n\t\tindex: match.index,\n\t\tcontent: match[ 0 ],\n\t\tshortcode: fromMatch( match ),\n\t};\n\n\t// If we matched a leading `[`, strip it from the match and increment the\n\t// index accordingly.\n\tif ( match[ 1 ] ) {\n\t\tresult.content = result.content.slice( 1 );\n\t\tresult.index++;\n\t}\n\n\t// If we matched a trailing `]`, strip it from the match.\n\tif ( match[ 7 ] ) {\n\t\tresult.content = result.content.slice( 0, -1 );\n\t}\n\n\treturn result;\n}\n\n/**\n * Replace matching shortcodes in a block of text.\n *\n * @param {string} tag Shortcode tag.\n * @param {string} text Text to search.\n * @param {import('./types').ReplaceCallback} callback Function to process the match and return\n * replacement string.\n *\n * @return {string} Text with shortcodes replaced.\n */\nexport function replace( tag, text, callback ) {\n\treturn text.replace(\n\t\tregexp( tag ),\n\t\tfunction ( match, left, $3, attrs, slash, content, closing, right ) {\n\t\t\t// If both extra brackets exist, the shortcode has been properly\n\t\t\t// escaped.\n\t\t\tif ( left === '[' && right === ']' ) {\n\t\t\t\treturn match;\n\t\t\t}\n\n\t\t\t// Create the match object and pass it through the callback.\n\t\t\tconst result = callback( fromMatch( arguments ) );\n\n\t\t\t// Make sure to return any of the extra brackets if they weren't used to\n\t\t\t// escape the shortcode.\n\t\t\treturn result || result === '' ? left + result + right : match;\n\t\t}\n\t);\n}\n\n/**\n * Generate a string from shortcode parameters.\n *\n * Creates a shortcode instance and returns a string.\n *\n * Accepts the same `options` as the `shortcode()` constructor, containing a\n * `tag` string, a string or object of `attrs`, a boolean indicating whether to\n * format the shortcode using a `single` tag, and a `content` string.\n *\n * @param {Object} options\n *\n * @return {string} String representation of the shortcode.\n */\nexport function string( options ) {\n\treturn new shortcode( options ).string();\n}\n\n/**\n * Generate a RegExp to identify a shortcode.\n *\n * The base regex is functionally equivalent to the one found in\n * `get_shortcode_regex()` in `wp-includes/shortcodes.php`.\n *\n * Capture groups:\n *\n * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`\n * 2. The shortcode name\n * 3. The shortcode argument list\n * 4. The self closing `/`\n * 5. The content of a shortcode when it wraps some content.\n * 6. The closing tag.\n * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`\n *\n * @param {string} tag Shortcode tag.\n *\n * @return {RegExp} Shortcode RegExp.\n */\nexport function regexp( tag ) {\n\treturn new RegExp(\n\t\t'\\\\[(\\\\[?)(' +\n\t\t\ttag +\n\t\t\t')(?![\\\\w-])([^\\\\]\\\\/]*(?:\\\\/(?!\\\\])[^\\\\]\\\\/]*)*?)(?:(\\\\/)\\\\]|\\\\](?:([^\\\\[]*(?:\\\\[(?!\\\\/\\\\2\\\\])[^\\\\[]*)*)(\\\\[\\\\/\\\\2\\\\]))?)(\\\\]?)',\n\t\t'g'\n\t);\n}\n\n/**\n * Parse shortcode attributes.\n *\n * Shortcodes accept many types of attributes. These can chiefly be divided into\n * named and numeric attributes:\n *\n * Named attributes are assigned on a key/value basis, while numeric attributes\n * are treated as an array.\n *\n * Named attributes can be formatted as either `name=\"value\"`, `name='value'`,\n * or `name=value`. Numeric attributes can be formatted as `\"value\"` or just\n * `value`.\n *\n * @param {string} text Serialised shortcode attributes.\n *\n * @return {import('./types').ShortcodeAttrs} Parsed shortcode attributes.\n */\nexport const attrs = memize( ( text ) => {\n\tconst named = {};\n\tconst numeric = [];\n\n\t// This regular expression is reused from `shortcode_parse_atts()` in\n\t// `wp-includes/shortcodes.php`.\n\t//\n\t// Capture groups:\n\t//\n\t// 1. An attribute name, that corresponds to...\n\t// 2. a value in double quotes.\n\t// 3. An attribute name, that corresponds to...\n\t// 4. a value in single quotes.\n\t// 5. An attribute name, that corresponds to...\n\t// 6. an unquoted value.\n\t// 7. A numeric attribute in double quotes.\n\t// 8. A numeric attribute in single quotes.\n\t// 9. An unquoted numeric attribute.\n\tconst pattern =\n\t\t/([\\w-]+)\\s*=\\s*\"([^\"]*)\"(?:\\s|$)|([\\w-]+)\\s*=\\s*'([^']*)'(?:\\s|$)|([\\w-]+)\\s*=\\s*([^\\s'\"]+)(?:\\s|$)|\"([^\"]*)\"(?:\\s|$)|'([^']*)'(?:\\s|$)|(\\S+)(?:\\s|$)/g;\n\n\t// Map zero-width spaces to actual spaces.\n\ttext = text.replace( /[\\u00a0\\u200b]/g, ' ' );\n\n\tlet match;\n\n\t// Match and normalize attributes.\n\twhile ( ( match = pattern.exec( text ) ) ) {\n\t\tif ( match[ 1 ] ) {\n\t\t\tnamed[ match[ 1 ].toLowerCase() ] = match[ 2 ];\n\t\t} else if ( match[ 3 ] ) {\n\t\t\tnamed[ match[ 3 ].toLowerCase() ] = match[ 4 ];\n\t\t} else if ( match[ 5 ] ) {\n\t\t\tnamed[ match[ 5 ].toLowerCase() ] = match[ 6 ];\n\t\t} else if ( match[ 7 ] ) {\n\t\t\tnumeric.push( match[ 7 ] );\n\t\t} else if ( match[ 8 ] ) {\n\t\t\tnumeric.push( match[ 8 ] );\n\t\t} else if ( match[ 9 ] ) {\n\t\t\tnumeric.push( match[ 9 ] );\n\t\t}\n\t}\n\n\treturn { named, numeric };\n} );\n\n/**\n * Generate a Shortcode Object from a RegExp match.\n *\n * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated\n * by `regexp()`. `match` can also be set to the `arguments` from a callback\n * passed to `regexp.replace()`.\n *\n * @param {import('./types').Match} match Match array.\n *\n * @return {InstanceType<import('./types').shortcode>} Shortcode instance.\n */\nexport function fromMatch( match ) {\n\tlet type;\n\n\tif ( match[ 4 ] ) {\n\t\ttype = 'self-closing';\n\t} else if ( match[ 6 ] ) {\n\t\ttype = 'closed';\n\t} else {\n\t\ttype = 'single';\n\t}\n\n\treturn new shortcode( {\n\t\ttag: match[ 2 ],\n\t\tattrs: match[ 3 ],\n\t\ttype,\n\t\tcontent: match[ 5 ],\n\t} );\n}\n\n/**\n * Creates a shortcode instance.\n *\n * To access a raw representation of a shortcode, pass an `options` object,\n * containing a `tag` string, a string or object of `attrs`, a string indicating\n * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a\n * `content` string.\n *\n * @type {import('./types').shortcode} Shortcode instance.\n */\nconst shortcode = Object.assign(\n\tfunction ( options ) {\n\t\tconst { tag, attrs: attributes, type, content } = options || {};\n\t\tObject.assign( this, { tag, type, content } );\n\n\t\t// Ensure we have a correctly formatted `attrs` object.\n\t\tthis.attrs = {\n\t\t\tnamed: {},\n\t\t\tnumeric: [],\n\t\t};\n\n\t\tif ( ! attributes ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst attributeTypes = [ 'named', 'numeric' ];\n\n\t\t// Parse a string of attributes.\n\t\tif ( typeof attributes === 'string' ) {\n\t\t\tthis.attrs = attrs( attributes );\n\t\t\t// Identify a correctly formatted `attrs` object.\n\t\t} else if (\n\t\t\tattributes.length === attributeTypes.length &&\n\t\t\tattributeTypes.every( ( t, key ) => t === attributes[ key ] )\n\t\t) {\n\t\t\tthis.attrs = attributes;\n\t\t\t// Handle a flat object of attributes.\n\t\t} else {\n\t\t\tObject.entries( attributes ).forEach( ( [ key, value ] ) => {\n\t\t\t\tthis.set( key, value );\n\t\t\t} );\n\t\t}\n\t},\n\t{\n\t\tnext,\n\t\treplace,\n\t\tstring,\n\t\tregexp,\n\t\tattrs,\n\t\tfromMatch,\n\t}\n);\n\nObject.assign( shortcode.prototype, {\n\t/**\n\t * Get a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param {(number|string)} attr Attribute key.\n\t *\n\t * @return {string} Attribute value.\n\t */\n\tget( attr ) {\n\t\treturn this.attrs[ typeof attr === 'number' ? 'numeric' : 'named' ][\n\t\t\tattr\n\t\t];\n\t},\n\n\t/**\n\t * Set a shortcode attribute.\n\t *\n\t * Automatically detects whether `attr` is named or numeric and routes it\n\t * accordingly.\n\t *\n\t * @param {(number|string)} attr Attribute key.\n\t * @param {string} value Attribute value.\n\t *\n\t * @return {InstanceType< import('./types').shortcode >} Shortcode instance.\n\t */\n\tset( attr, value ) {\n\t\tthis.attrs[ typeof attr === 'number' ? 'numeric' : 'named' ][ attr ] =\n\t\t\tvalue;\n\t\treturn this;\n\t},\n\n\t/**\n\t * Transform the shortcode into a string.\n\t *\n\t * @return {string} String representation of the shortcode.\n\t */\n\tstring() {\n\t\tlet text = '[' + this.tag;\n\n\t\tthis.attrs.numeric.forEach( ( value ) => {\n\t\t\tif ( /\\s/.test( value ) ) {\n\t\t\t\ttext += ' \"' + value + '\"';\n\t\t\t} else {\n\t\t\t\ttext += ' ' + value;\n\t\t\t}\n\t\t} );\n\n\t\tObject.entries( this.attrs.named ).forEach( ( [ name, value ] ) => {\n\t\t\ttext += ' ' + name + '=\"' + value + '\"';\n\t\t} );\n\n\t\t// If the tag is marked as `single` or `self-closing`, close the tag and\n\t\t// ignore any additional content.\n\t\tif ( 'single' === this.type ) {\n\t\t\treturn text + ']';\n\t\t} else if ( 'self-closing' === this.type ) {\n\t\t\treturn text + ' /]';\n\t\t}\n\n\t\t// Complete the opening tag.\n\t\ttext += ']';\n\n\t\tif ( this.content ) {\n\t\t\ttext += this.content;\n\t\t}\n\n\t\t// Add the closing tag.\n\t\treturn text + '[/' +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,KAAK;MACpB;IACD,CAAE,CAAC;IAEHV,MAAM,CAACQ,OAAO,CAAE,IAAI,CAACtB,KAAK,CAACQ,KAAM,CAAC,CAACe,OAAO,CAAE,CAAE,CAAEO,IAAI,EAAEN,KAAK,CAAE,KAAM;MAClExC,IAAI,IAAI,GAAG,GAAG8C,IAAI,GAAG,IAAI,GAAGN,KAAK,GAAG,GAAG;IACxC,CAAE,CAAC;;IAEH;IACA;IACA,IAAK,QAAQ,KAAK,IAAI,CAACX,IAAI,EAAG;MAC7B,OAAO7B,IAAI,GAAG,GAAG;IAClB,CAAC,MAAM,IAAK,cAAc,KAAK,IAAI,CAAC6B,IAAI,EAAG;MAC1C,OAAO7B,IAAI,GAAG,KAAK;IACpB;;IAEA;IACAA,IAAI,IAAI,GAAG;IAEX,IAAK,IAAI,CAACQ,OAAO,EAAG;MACnBR,IAAI,IAAI,IAAI,CAACQ,OAAO;IACrB;;IAEA;IACA,OAAOR,IAAI,GAAG,IAAI,GAAG,IAAI,CAACD,GAAG,GAAG,GAAG;EACpC;AACD,CAAE,CAAC;AAEH,eAAeU,SAAS","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["@wordpress/shortcode/src/types.ts"],"sourcesContent":["/**\n * Shortcode attributes object.\n */\nexport type ShortcodeAttrs = {\n\t/**\n\t * Object with named attributes.\n\t */\n\tnamed: Record< string, string | undefined >;\n\n\t/**\n\t * Array with numeric attributes.\n\t */\n\tnumeric: string[];\n};\n\nexport type ShortcodeMatch = {\n\t/**\n\t * Index the shortcode is found at.\n\t */\n\tindex: number;\n\n\t/**\n\t * Matched content.\n\t */\n\tcontent: string;\n\n\t/**\n\t * Shortcode instance of the match.\n\t */\n\tshortcode: Shortcode;\n};\n\n/**\n * Shortcode options.\n */\nexport interface ShortcodeOptions {\n\t/**\n\t * Shortcode tag.\n\t */\n\ttag: string;\n\n\t/**\n\t * Shortcode attributes.\n\t */\n\tattrs?: Partial< ShortcodeAttrs > | string;\n\n\t/**\n\t * Shortcode content.\n\t */\n\tcontent?: string;\n\n\t/**\n\t * Shortcode type: `self-closing`, `closed`, or `single`.\n\t */\n\ttype?: 'self-closing' | 'closed' | 'single';\n}\n\n/**\n * Shortcode object.\n */\nexport interface Shortcode extends ShortcodeOptions {\n\t/**\n\t * Shortcode attributes.\n\t */\n\tattrs: ShortcodeAttrs;\n}\n\nexport type Match =\n\t| NonNullable< ReturnType< RegExp[ 'exec' ] > >\n\t| Array< string >;\n\nexport type ReplaceCallback = ( shortcode: Shortcode ) => string;\n\n/**\n * WordPress Shortcode instance.\n */\nexport interface shortcode {\n\tnew ( options: Partial< ShortcodeOptions > ): Shortcode & {\n\t\t/**\n\t\t * Transform the shortcode into a string.\n\t\t *\n\t\t * @return {string} String representation of the shortcode.\n\t\t */\n\t\tstring: () => string;\n\n\t\t/**\n\t\t * Get a shortcode attribute.\n\t\t *\n\t\t * Automatically detects whether `attr` is named or numeric and routes it\n\t\t * accordingly.\n\t\t *\n\t\t * @param {(number|string)} attr Attribute key.\n\t\t *\n\t\t * @return {string} Attribute value.\n\t\t */\n\t\tget: ( attr: string | number ) => string | undefined;\n\n\t\t/**\n\t\t * Set a shortcode attribute.\n\t\t *\n\t\t * Automatically detects whether `attr` is named or numeric and routes it\n\t\t * accordingly.\n\t\t *\n\t\t * @param {(number|string)} attr Attribute key.\n\t\t * @param {string} value Attribute value.\n\t\t *\n\t\t * @return {InstanceType< shortcode >} Shortcode instance.\n\t\t */\n\t\tset: (\n\t\t\tattr: string | number,\n\t\t\tvalue: string\n\t\t) => InstanceType< shortcode >;\n\t};\n\n\t/**\n\t * Parse shortcode attributes.\n\t *\n\t * Shortcodes accept many types of attributes. These can chiefly be divided into\n\t * named and numeric attributes:\n\t *\n\t * Named attributes are assigned on a key/value basis, while numeric attributes\n\t * are treated as an array.\n\t *\n\t * Named attributes can be formatted as either `name=\"value\"`, `name='value'`,\n\t * or `name=value`. Numeric attributes can be formatted as `\"value\"` or just\n\t * `value`.\n\t *\n\t * @param text Serialised shortcode attributes.\n\t *\n\t * @return Parsed shortcode attributes.\n\t */\n\tattrs: ( text: string ) => ShortcodeAttrs;\n\n\t/**\n\t * Generate a Shortcode Object from a RegExp match.\n\t *\n\t * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated\n\t * by `regexp()`. `match` can also be set to the `arguments` from a callback\n\t * passed to `regexp.replace()`.\n\t *\n\t * @param match Match array.\n\t *\n\t * @return Shortcode instance.\n\t */\n\tfromMatch: ( match: Match ) => InstanceType< shortcode >;\n\n\t/**\n\t * Find the next matching shortcode.\n\t *\n\t * @param tag Shortcode tag.\n\t * @param text Text to search.\n\t * @param index Index to start search from.\n\t *\n\t * @return Matched information.\n\t */\n\tnext: (\n\t\ttag: string,\n\t\ttext: string,\n\t\tindex?: number\n\t) => ShortcodeMatch | undefined;\n\n\t/**\n\t * Generate a RegExp to identify a shortcode.\n\t *\n\t * The base regex is functionally equivalent to the one found in\n\t * `get_shortcode_regex()` in `wp-includes/shortcodes.php`.\n\t *\n\t * Capture groups:\n\t *\n\t * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`\n\t * 2. The shortcode name\n\t * 3. The shortcode argument list\n\t * 4. The self closing `/`\n\t * 5. The content of a shortcode when it wraps some content.\n\t * 6. The closing tag.\n\t * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`\n\t *\n\t * @param tag Shortcode tag.\n\t *\n\t * @return Shortcode RegExp.\n\t */\n\tregexp: ( tag: string ) => RegExp;\n\n\t/**\n\t * Replace matching shortcodes in a block of text.\n\t *\n\t * @param tag Shortcode tag.\n\t * @param text Text to search.\n\t * @param callback Function to process the match and return\n\t * replacement string.\n\t *\n\t * @return Text with shortcodes replaced.\n\t */\n\treplace: ( tag: string, text: string, callback: ReplaceCallback ) => string;\n\n\t/**\n\t * Generate a string from shortcode parameters.\n\t *\n\t * Creates a shortcode instance and returns a string.\n\t *\n\t * Accepts the same `options` as the `shortcode()` constructor, containing a\n\t * `tag` string, a string or object of `attrs`, a boolean indicating whether to\n\t * format the shortcode using a `single` tag, and a `content` string.\n\t *\n\t * @param options\n\t *\n\t * @return String representation of the shortcode.\n\t */\n\tstring: ( options: ShortcodeOptions ) => string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Find the next matching shortcode.
3
+ *
4
+ * @param {string} tag Shortcode tag.
5
+ * @param {string} text Text to search.
6
+ * @param {number} index Index to start search from.
7
+ *
8
+ * @return {import('./types').ShortcodeMatch | undefined} Matched information.
9
+ */
10
+ export function next(tag: string, text: string, index?: number): import("./types").ShortcodeMatch | undefined;
11
+ /**
12
+ * Replace matching shortcodes in a block of text.
13
+ *
14
+ * @param {string} tag Shortcode tag.
15
+ * @param {string} text Text to search.
16
+ * @param {import('./types').ReplaceCallback} callback Function to process the match and return
17
+ * replacement string.
18
+ *
19
+ * @return {string} Text with shortcodes replaced.
20
+ */
21
+ export function replace(tag: string, text: string, callback: import("./types").ReplaceCallback): string;
22
+ /**
23
+ * Generate a string from shortcode parameters.
24
+ *
25
+ * Creates a shortcode instance and returns a string.
26
+ *
27
+ * Accepts the same `options` as the `shortcode()` constructor, containing a
28
+ * `tag` string, a string or object of `attrs`, a boolean indicating whether to
29
+ * format the shortcode using a `single` tag, and a `content` string.
30
+ *
31
+ * @param {Object} options
32
+ *
33
+ * @return {string} String representation of the shortcode.
34
+ */
35
+ export function string(options: Object): string;
36
+ /**
37
+ * Generate a RegExp to identify a shortcode.
38
+ *
39
+ * The base regex is functionally equivalent to the one found in
40
+ * `get_shortcode_regex()` in `wp-includes/shortcodes.php`.
41
+ *
42
+ * Capture groups:
43
+ *
44
+ * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`
45
+ * 2. The shortcode name
46
+ * 3. The shortcode argument list
47
+ * 4. The self closing `/`
48
+ * 5. The content of a shortcode when it wraps some content.
49
+ * 6. The closing tag.
50
+ * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`
51
+ *
52
+ * @param {string} tag Shortcode tag.
53
+ *
54
+ * @return {RegExp} Shortcode RegExp.
55
+ */
56
+ export function regexp(tag: string): RegExp;
57
+ /**
58
+ * Generate a Shortcode Object from a RegExp match.
59
+ *
60
+ * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated
61
+ * by `regexp()`. `match` can also be set to the `arguments` from a callback
62
+ * passed to `regexp.replace()`.
63
+ *
64
+ * @param {import('./types').Match} match Match array.
65
+ *
66
+ * @return {InstanceType<import('./types').shortcode>} Shortcode instance.
67
+ */
68
+ export function fromMatch(match: import("./types").Match): InstanceType<import("./types").shortcode>;
69
+ export * from "./types";
70
+ /**
71
+ * Parse shortcode attributes.
72
+ *
73
+ * Shortcodes accept many types of attributes. These can chiefly be divided into
74
+ * named and numeric attributes:
75
+ *
76
+ * Named attributes are assigned on a key/value basis, while numeric attributes
77
+ * are treated as an array.
78
+ *
79
+ * Named attributes can be formatted as either `name="value"`, `name='value'`,
80
+ * or `name=value`. Numeric attributes can be formatted as `"value"` or just
81
+ * `value`.
82
+ *
83
+ * @param {string} text Serialised shortcode attributes.
84
+ *
85
+ * @return {import('./types').ShortcodeAttrs} Parsed shortcode attributes.
86
+ */
87
+ export const attrs: ((text?: any) => {
88
+ named: {};
89
+ numeric: string[];
90
+ }) & import("memize").MemizeMemoizedFunction;
91
+ export default shortcode;
92
+ /**
93
+ * Creates a shortcode instance.
94
+ *
95
+ * To access a raw representation of a shortcode, pass an `options` object,
96
+ * containing a `tag` string, a string or object of `attrs`, a string indicating
97
+ * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a
98
+ * `content` string.
99
+ *
100
+ * @type {import('./types').shortcode} Shortcode instance.
101
+ */
102
+ declare const shortcode: import("./types").shortcode;
103
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAOA;;;;;;;;GAQG;AACH,0BANW,MAAM,QACN,MAAM,UACN,MAAM,GAEL,OAAO,SAAS,EAAE,cAAc,GAAG,SAAS,CAqCvD;AAED;;;;;;;;;GASG;AACH,6BAPW,MAAM,QACN,MAAM,YACN,OAAO,SAAS,EAAE,eAAe,GAGhC,MAAM,CAoBjB;AAED;;;;;;;;;;;;GAYG;AACH,gCAJW,MAAM,GAEL,MAAM,CAIjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,4BAJW,MAAM,GAEL,MAAM,CASjB;AAiED;;;;;;;;;;GAUG;AACH,iCAJW,OAAO,SAAS,EAAE,KAAK,GAEtB,YAAY,CAAC,OAAO,SAAS,EAAE,SAAS,CAAC,CAmBpD;;AA3FD;;;;;;;;;;;;;;;;GAgBG;AACH;;;6CA4CI;;AAgCJ;;;;;;;;;GASG;AACH,yBAFU,OAAO,SAAS,EAAE,SAAS,CA2CnC"}
@@ -0,0 +1,182 @@
1
+ /**
2
+ * Shortcode attributes object.
3
+ */
4
+ export type ShortcodeAttrs = {
5
+ /**
6
+ * Object with named attributes.
7
+ */
8
+ named: Record<string, string | undefined>;
9
+ /**
10
+ * Array with numeric attributes.
11
+ */
12
+ numeric: string[];
13
+ };
14
+ export type ShortcodeMatch = {
15
+ /**
16
+ * Index the shortcode is found at.
17
+ */
18
+ index: number;
19
+ /**
20
+ * Matched content.
21
+ */
22
+ content: string;
23
+ /**
24
+ * Shortcode instance of the match.
25
+ */
26
+ shortcode: Shortcode;
27
+ };
28
+ /**
29
+ * Shortcode options.
30
+ */
31
+ export interface ShortcodeOptions {
32
+ /**
33
+ * Shortcode tag.
34
+ */
35
+ tag: string;
36
+ /**
37
+ * Shortcode attributes.
38
+ */
39
+ attrs?: Partial<ShortcodeAttrs> | string;
40
+ /**
41
+ * Shortcode content.
42
+ */
43
+ content?: string;
44
+ /**
45
+ * Shortcode type: `self-closing`, `closed`, or `single`.
46
+ */
47
+ type?: 'self-closing' | 'closed' | 'single';
48
+ }
49
+ /**
50
+ * Shortcode object.
51
+ */
52
+ export interface Shortcode extends ShortcodeOptions {
53
+ /**
54
+ * Shortcode attributes.
55
+ */
56
+ attrs: ShortcodeAttrs;
57
+ }
58
+ export type Match = NonNullable<ReturnType<RegExp['exec']>> | Array<string>;
59
+ export type ReplaceCallback = (shortcode: Shortcode) => string;
60
+ /**
61
+ * WordPress Shortcode instance.
62
+ */
63
+ export interface shortcode {
64
+ new (options: Partial<ShortcodeOptions>): Shortcode & {
65
+ /**
66
+ * Transform the shortcode into a string.
67
+ *
68
+ * @return {string} String representation of the shortcode.
69
+ */
70
+ string: () => string;
71
+ /**
72
+ * Get a shortcode attribute.
73
+ *
74
+ * Automatically detects whether `attr` is named or numeric and routes it
75
+ * accordingly.
76
+ *
77
+ * @param {(number|string)} attr Attribute key.
78
+ *
79
+ * @return {string} Attribute value.
80
+ */
81
+ get: (attr: string | number) => string | undefined;
82
+ /**
83
+ * Set a shortcode attribute.
84
+ *
85
+ * Automatically detects whether `attr` is named or numeric and routes it
86
+ * accordingly.
87
+ *
88
+ * @param {(number|string)} attr Attribute key.
89
+ * @param {string} value Attribute value.
90
+ *
91
+ * @return {InstanceType< shortcode >} Shortcode instance.
92
+ */
93
+ set: (attr: string | number, value: string) => InstanceType<shortcode>;
94
+ };
95
+ /**
96
+ * Parse shortcode attributes.
97
+ *
98
+ * Shortcodes accept many types of attributes. These can chiefly be divided into
99
+ * named and numeric attributes:
100
+ *
101
+ * Named attributes are assigned on a key/value basis, while numeric attributes
102
+ * are treated as an array.
103
+ *
104
+ * Named attributes can be formatted as either `name="value"`, `name='value'`,
105
+ * or `name=value`. Numeric attributes can be formatted as `"value"` or just
106
+ * `value`.
107
+ *
108
+ * @param text Serialised shortcode attributes.
109
+ *
110
+ * @return Parsed shortcode attributes.
111
+ */
112
+ attrs: (text: string) => ShortcodeAttrs;
113
+ /**
114
+ * Generate a Shortcode Object from a RegExp match.
115
+ *
116
+ * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated
117
+ * by `regexp()`. `match` can also be set to the `arguments` from a callback
118
+ * passed to `regexp.replace()`.
119
+ *
120
+ * @param match Match array.
121
+ *
122
+ * @return Shortcode instance.
123
+ */
124
+ fromMatch: (match: Match) => InstanceType<shortcode>;
125
+ /**
126
+ * Find the next matching shortcode.
127
+ *
128
+ * @param tag Shortcode tag.
129
+ * @param text Text to search.
130
+ * @param index Index to start search from.
131
+ *
132
+ * @return Matched information.
133
+ */
134
+ next: (tag: string, text: string, index?: number) => ShortcodeMatch | undefined;
135
+ /**
136
+ * Generate a RegExp to identify a shortcode.
137
+ *
138
+ * The base regex is functionally equivalent to the one found in
139
+ * `get_shortcode_regex()` in `wp-includes/shortcodes.php`.
140
+ *
141
+ * Capture groups:
142
+ *
143
+ * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`
144
+ * 2. The shortcode name
145
+ * 3. The shortcode argument list
146
+ * 4. The self closing `/`
147
+ * 5. The content of a shortcode when it wraps some content.
148
+ * 6. The closing tag.
149
+ * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`
150
+ *
151
+ * @param tag Shortcode tag.
152
+ *
153
+ * @return Shortcode RegExp.
154
+ */
155
+ regexp: (tag: string) => RegExp;
156
+ /**
157
+ * Replace matching shortcodes in a block of text.
158
+ *
159
+ * @param tag Shortcode tag.
160
+ * @param text Text to search.
161
+ * @param callback Function to process the match and return
162
+ * replacement string.
163
+ *
164
+ * @return Text with shortcodes replaced.
165
+ */
166
+ replace: (tag: string, text: string, callback: ReplaceCallback) => string;
167
+ /**
168
+ * Generate a string from shortcode parameters.
169
+ *
170
+ * Creates a shortcode instance and returns a string.
171
+ *
172
+ * Accepts the same `options` as the `shortcode()` constructor, containing a
173
+ * `tag` string, a string or object of `attrs`, a boolean indicating whether to
174
+ * format the shortcode using a `single` tag, and a `content` string.
175
+ *
176
+ * @param options
177
+ *
178
+ * @return String representation of the shortcode.
179
+ */
180
+ string: (options: ShortcodeOptions) => string;
181
+ }
182
+ //# sourceMappingURL=types.d.ts.map
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AAI,EAAE,MAAM,GAAG,MAAM,KAAM,MAAM,GAAG,SAAS,CAAC;QAErD;;;;;;;;;;WAUG;QACH,GAAG,EAAE,CACJ,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,KAAK,EAAE,MAAM,KACT,YAAY,CAAE,SAAS,CAAE,CAAC;KAC/B,CAAC;IAEF;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,EAAE,CAAE,IAAI,EAAE,MAAM,KAAM,cAAc,CAAC;IAE1C;;;;;;;;;;OAUG;IACH,SAAS,EAAE,CAAE,KAAK,EAAE,KAAK,KAAM,YAAY,CAAE,SAAS,CAAE,CAAC;IAEzD;;;;;;;;OAQG;IACH,IAAI,EAAE,CACL,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,KACV,cAAc,GAAG,SAAS,CAAC;IAEhC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,EAAE,CAAE,GAAG,EAAE,MAAM,KAAM,MAAM,CAAC;IAElC;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,KAAM,MAAM,CAAC;IAE5E;;;;;;;;;;;;OAYG;IACH,MAAM,EAAE,CAAE,OAAO,EAAE,gBAAgB,KAAM,MAAM,CAAC;CAChD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/shortcode",
3
- "version": "4.12.1-next.082ed6819.0",
3
+ "version": "4.13.1-next.a9f418477.0",
4
4
  "description": "Shortcode module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -26,6 +26,7 @@
26
26
  "module": "build-module/index.js",
27
27
  "react-native": "src/index",
28
28
  "wpScript": true,
29
+ "types": "build-types",
29
30
  "dependencies": {
30
31
  "@babel/runtime": "7.25.7",
31
32
  "memize": "^2.0.1"
@@ -33,5 +34,5 @@
33
34
  "publishConfig": {
34
35
  "access": "public"
35
36
  },
36
- "gitHead": "2bb7bad15ddb8e88210fab7d4a1ef1565466e424"
37
+ "gitHead": "c1a8f3e9cada3b7d8342d1d2595c2dac0433111d"
37
38
  }
package/src/index.js CHANGED
@@ -3,34 +3,7 @@
3
3
  */
4
4
  import memize from 'memize';
5
5
 
6
- /**
7
- * Shortcode attributes object.
8
- *
9
- * @typedef {Object} WPShortcodeAttrs
10
- *
11
- * @property {Object} named Object with named attributes.
12
- * @property {Array} numeric Array with numeric attributes.
13
- */
14
-
15
- /**
16
- * Shortcode object.
17
- *
18
- * @typedef {Object} WPShortcode
19
- *
20
- * @property {string} tag Shortcode tag.
21
- * @property {WPShortcodeAttrs} attrs Shortcode attributes.
22
- * @property {string} content Shortcode content.
23
- * @property {string} type Shortcode type: `self-closing`,
24
- * `closed`, or `single`.
25
- */
26
-
27
- /**
28
- * @typedef {Object} WPShortcodeMatch
29
- *
30
- * @property {number} index Index the shortcode is found at.
31
- * @property {string} content Matched content.
32
- * @property {WPShortcode} shortcode Shortcode instance of the match.
33
- */
6
+ export * from './types';
34
7
 
35
8
  /**
36
9
  * Find the next matching shortcode.
@@ -39,7 +12,7 @@ import memize from 'memize';
39
12
  * @param {string} text Text to search.
40
13
  * @param {number} index Index to start search from.
41
14
  *
42
- * @return {WPShortcodeMatch | undefined} Matched information.
15
+ * @return {import('./types').ShortcodeMatch | undefined} Matched information.
43
16
  */
44
17
  export function next( tag, text, index = 0 ) {
45
18
  const re = regexp( tag );
@@ -81,10 +54,10 @@ export function next( tag, text, index = 0 ) {
81
54
  /**
82
55
  * Replace matching shortcodes in a block of text.
83
56
  *
84
- * @param {string} tag Shortcode tag.
85
- * @param {string} text Text to search.
86
- * @param {Function} callback Function to process the match and return
87
- * replacement string.
57
+ * @param {string} tag Shortcode tag.
58
+ * @param {string} text Text to search.
59
+ * @param {import('./types').ReplaceCallback} callback Function to process the match and return
60
+ * replacement string.
88
61
  *
89
62
  * @return {string} Text with shortcodes replaced.
90
63
  */
@@ -169,7 +142,7 @@ export function regexp( tag ) {
169
142
  *
170
143
  * @param {string} text Serialised shortcode attributes.
171
144
  *
172
- * @return {WPShortcodeAttrs} Parsed shortcode attributes.
145
+ * @return {import('./types').ShortcodeAttrs} Parsed shortcode attributes.
173
146
  */
174
147
  export const attrs = memize( ( text ) => {
175
148
  const named = {};
@@ -224,9 +197,9 @@ export const attrs = memize( ( text ) => {
224
197
  * by `regexp()`. `match` can also be set to the `arguments` from a callback
225
198
  * passed to `regexp.replace()`.
226
199
  *
227
- * @param {Array} match Match array.
200
+ * @param {import('./types').Match} match Match array.
228
201
  *
229
- * @return {WPShortcode} Shortcode instance.
202
+ * @return {InstanceType<import('./types').shortcode>} Shortcode instance.
230
203
  */
231
204
  export function fromMatch( match ) {
232
205
  let type;
@@ -255,9 +228,7 @@ export function fromMatch( match ) {
255
228
  * the `type` of the shortcode ('single', 'self-closing', or 'closed'), and a
256
229
  * `content` string.
257
230
  *
258
- * @param {Object} options Options as described.
259
- *
260
- * @return {WPShortcode} Shortcode instance.
231
+ * @type {import('./types').shortcode} Shortcode instance.
261
232
  */
262
233
  const shortcode = Object.assign(
263
234
  function ( options ) {
@@ -328,7 +299,7 @@ Object.assign( shortcode.prototype, {
328
299
  * @param {(number|string)} attr Attribute key.
329
300
  * @param {string} value Attribute value.
330
301
  *
331
- * @return {WPShortcode} Shortcode instance.
302
+ * @return {InstanceType< import('./types').shortcode >} Shortcode instance.
332
303
  */
333
304
  set( attr, value ) {
334
305
  this.attrs[ typeof attr === 'number' ? 'numeric' : 'named' ][ attr ] =
package/src/types.ts ADDED
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Shortcode attributes object.
3
+ */
4
+ export type ShortcodeAttrs = {
5
+ /**
6
+ * Object with named attributes.
7
+ */
8
+ named: Record< string, string | undefined >;
9
+
10
+ /**
11
+ * Array with numeric attributes.
12
+ */
13
+ numeric: string[];
14
+ };
15
+
16
+ export type ShortcodeMatch = {
17
+ /**
18
+ * Index the shortcode is found at.
19
+ */
20
+ index: number;
21
+
22
+ /**
23
+ * Matched content.
24
+ */
25
+ content: string;
26
+
27
+ /**
28
+ * Shortcode instance of the match.
29
+ */
30
+ shortcode: Shortcode;
31
+ };
32
+
33
+ /**
34
+ * Shortcode options.
35
+ */
36
+ export interface ShortcodeOptions {
37
+ /**
38
+ * Shortcode tag.
39
+ */
40
+ tag: string;
41
+
42
+ /**
43
+ * Shortcode attributes.
44
+ */
45
+ attrs?: Partial< ShortcodeAttrs > | string;
46
+
47
+ /**
48
+ * Shortcode content.
49
+ */
50
+ content?: string;
51
+
52
+ /**
53
+ * Shortcode type: `self-closing`, `closed`, or `single`.
54
+ */
55
+ type?: 'self-closing' | 'closed' | 'single';
56
+ }
57
+
58
+ /**
59
+ * Shortcode object.
60
+ */
61
+ export interface Shortcode extends ShortcodeOptions {
62
+ /**
63
+ * Shortcode attributes.
64
+ */
65
+ attrs: ShortcodeAttrs;
66
+ }
67
+
68
+ export type Match =
69
+ | NonNullable< ReturnType< RegExp[ 'exec' ] > >
70
+ | Array< string >;
71
+
72
+ export type ReplaceCallback = ( shortcode: Shortcode ) => string;
73
+
74
+ /**
75
+ * WordPress Shortcode instance.
76
+ */
77
+ export interface shortcode {
78
+ new ( options: Partial< ShortcodeOptions > ): Shortcode & {
79
+ /**
80
+ * Transform the shortcode into a string.
81
+ *
82
+ * @return {string} String representation of the shortcode.
83
+ */
84
+ string: () => string;
85
+
86
+ /**
87
+ * Get a shortcode attribute.
88
+ *
89
+ * Automatically detects whether `attr` is named or numeric and routes it
90
+ * accordingly.
91
+ *
92
+ * @param {(number|string)} attr Attribute key.
93
+ *
94
+ * @return {string} Attribute value.
95
+ */
96
+ get: ( attr: string | number ) => string | undefined;
97
+
98
+ /**
99
+ * Set a shortcode attribute.
100
+ *
101
+ * Automatically detects whether `attr` is named or numeric and routes it
102
+ * accordingly.
103
+ *
104
+ * @param {(number|string)} attr Attribute key.
105
+ * @param {string} value Attribute value.
106
+ *
107
+ * @return {InstanceType< shortcode >} Shortcode instance.
108
+ */
109
+ set: (
110
+ attr: string | number,
111
+ value: string
112
+ ) => InstanceType< shortcode >;
113
+ };
114
+
115
+ /**
116
+ * Parse shortcode attributes.
117
+ *
118
+ * Shortcodes accept many types of attributes. These can chiefly be divided into
119
+ * named and numeric attributes:
120
+ *
121
+ * Named attributes are assigned on a key/value basis, while numeric attributes
122
+ * are treated as an array.
123
+ *
124
+ * Named attributes can be formatted as either `name="value"`, `name='value'`,
125
+ * or `name=value`. Numeric attributes can be formatted as `"value"` or just
126
+ * `value`.
127
+ *
128
+ * @param text Serialised shortcode attributes.
129
+ *
130
+ * @return Parsed shortcode attributes.
131
+ */
132
+ attrs: ( text: string ) => ShortcodeAttrs;
133
+
134
+ /**
135
+ * Generate a Shortcode Object from a RegExp match.
136
+ *
137
+ * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` generated
138
+ * by `regexp()`. `match` can also be set to the `arguments` from a callback
139
+ * passed to `regexp.replace()`.
140
+ *
141
+ * @param match Match array.
142
+ *
143
+ * @return Shortcode instance.
144
+ */
145
+ fromMatch: ( match: Match ) => InstanceType< shortcode >;
146
+
147
+ /**
148
+ * Find the next matching shortcode.
149
+ *
150
+ * @param tag Shortcode tag.
151
+ * @param text Text to search.
152
+ * @param index Index to start search from.
153
+ *
154
+ * @return Matched information.
155
+ */
156
+ next: (
157
+ tag: string,
158
+ text: string,
159
+ index?: number
160
+ ) => ShortcodeMatch | undefined;
161
+
162
+ /**
163
+ * Generate a RegExp to identify a shortcode.
164
+ *
165
+ * The base regex is functionally equivalent to the one found in
166
+ * `get_shortcode_regex()` in `wp-includes/shortcodes.php`.
167
+ *
168
+ * Capture groups:
169
+ *
170
+ * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`
171
+ * 2. The shortcode name
172
+ * 3. The shortcode argument list
173
+ * 4. The self closing `/`
174
+ * 5. The content of a shortcode when it wraps some content.
175
+ * 6. The closing tag.
176
+ * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`
177
+ *
178
+ * @param tag Shortcode tag.
179
+ *
180
+ * @return Shortcode RegExp.
181
+ */
182
+ regexp: ( tag: string ) => RegExp;
183
+
184
+ /**
185
+ * Replace matching shortcodes in a block of text.
186
+ *
187
+ * @param tag Shortcode tag.
188
+ * @param text Text to search.
189
+ * @param callback Function to process the match and return
190
+ * replacement string.
191
+ *
192
+ * @return Text with shortcodes replaced.
193
+ */
194
+ replace: ( tag: string, text: string, callback: ReplaceCallback ) => string;
195
+
196
+ /**
197
+ * Generate a string from shortcode parameters.
198
+ *
199
+ * Creates a shortcode instance and returns a string.
200
+ *
201
+ * Accepts the same `options` as the `shortcode()` constructor, containing a
202
+ * `tag` string, a string or object of `attrs`, a boolean indicating whether to
203
+ * format the shortcode using a `single` tag, and a `content` string.
204
+ *
205
+ * @param options
206
+ *
207
+ * @return String representation of the shortcode.
208
+ */
209
+ string: ( options: ShortcodeOptions ) => string;
210
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig.json",
3
+ "extends": "../../tsconfig.base.json",
4
+ "compilerOptions": {
5
+ "rootDir": "src",
6
+ "declarationDir": "build-types",
7
+ "checkJs": false
8
+ },
9
+ "references": [],
10
+ "include": [ "src" ]
11
+ }
@@ -0,0 +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","../../node_modules/memize/dist/index.d.ts","./src/types.ts","./src/index.js"],"fileIdsList":[[79,80]],"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":"e824690c25b4d469af83e8fe10d15811d06d588c1b31eae795390b98b888dfc3","impliedFormat":99},{"version":"9fa94085ba2e0695a28fe6c6edadb871bea335374b10a4ff8f708a3de0cffc00","signature":"fd492d31cf68be503e92dd112d6c4fba02ba9c2bb8552c0b103bffd583b89bb8"},{"version":"b1cef1e11d6f0c15395449557fafb63ea0f853f1e168b4605127ad2cb2d503f6","signature":"c0dadadb986c325f2677ba92def14c1576d7cf28e08fcb1ae1d524bb6016c5c7"}],"root":[80,81],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"checkJs":false,"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},"referencedMap":[[81,1]],"latestChangedDtsFile":"./build-types/index.d.ts","version":"5.7.2"}