@wordpress/shortcode
Advanced tools
+229
| "use strict"; | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| // packages/shortcode/src/index.js | ||
| var index_exports = {}; | ||
| __export(index_exports, { | ||
| attrs: () => attrs, | ||
| default: () => index_default, | ||
| fromMatch: () => fromMatch, | ||
| next: () => next, | ||
| regexp: () => regexp, | ||
| replace: () => replace, | ||
| string: () => string | ||
| }); | ||
| module.exports = __toCommonJS(index_exports); | ||
| var import_memize = __toESM(require("memize"), 1); | ||
| __reExport(index_exports, require("./types.cjs"), module.exports); | ||
| function next(tag, text, index = 0) { | ||
| const re = regexp(tag); | ||
| re.lastIndex = index; | ||
| const match = re.exec(text); | ||
| if (!match) { | ||
| return; | ||
| } | ||
| if ("[" === match[1] && "]" === match[7]) { | ||
| return next(tag, text, re.lastIndex); | ||
| } | ||
| const result = { | ||
| index: match.index, | ||
| content: match[0], | ||
| shortcode: fromMatch(match) | ||
| }; | ||
| if (match[1]) { | ||
| result.content = result.content.slice(1); | ||
| result.index++; | ||
| } | ||
| if (match[7]) { | ||
| result.content = result.content.slice(0, -1); | ||
| } | ||
| return result; | ||
| } | ||
| function replace(tag, text, callback) { | ||
| return text.replace( | ||
| regexp(tag), | ||
| function(match, left, $3, attrs2, slash, content, closing, right) { | ||
| if (left === "[" && right === "]") { | ||
| return match; | ||
| } | ||
| const result = callback(fromMatch(arguments)); | ||
| return result || result === "" ? left + result + right : match; | ||
| } | ||
| ); | ||
| } | ||
| function string(options) { | ||
| return new shortcode(options).string(); | ||
| } | ||
| function regexp(tag) { | ||
| return new RegExp( | ||
| "\\[(\\[?)(" + tag + ")(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)", | ||
| "g" | ||
| ); | ||
| } | ||
| var attrs = (0, import_memize.default)((text) => { | ||
| const named = {}; | ||
| const numeric = []; | ||
| const pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g; | ||
| text = text.replace(/[\u00a0\u200b]/g, " "); | ||
| let match; | ||
| while (match = pattern.exec(text)) { | ||
| if (match[1]) { | ||
| named[match[1].toLowerCase()] = match[2]; | ||
| } else if (match[3]) { | ||
| named[match[3].toLowerCase()] = match[4]; | ||
| } else if (match[5]) { | ||
| named[match[5].toLowerCase()] = match[6]; | ||
| } else if (match[7]) { | ||
| numeric.push(match[7]); | ||
| } else if (match[8]) { | ||
| numeric.push(match[8]); | ||
| } else if (match[9]) { | ||
| numeric.push(match[9]); | ||
| } | ||
| } | ||
| return { named, numeric }; | ||
| }); | ||
| function fromMatch(match) { | ||
| let type; | ||
| if (match[4]) { | ||
| type = "self-closing"; | ||
| } else if (match[6]) { | ||
| type = "closed"; | ||
| } else { | ||
| type = "single"; | ||
| } | ||
| return new shortcode({ | ||
| tag: match[2], | ||
| attrs: match[3], | ||
| type, | ||
| content: match[5] | ||
| }); | ||
| } | ||
| var shortcode = Object.assign( | ||
| function(options) { | ||
| const { tag, attrs: attributes, type, content } = options || {}; | ||
| Object.assign(this, { tag, type, content }); | ||
| this.attrs = { | ||
| named: {}, | ||
| numeric: [] | ||
| }; | ||
| if (!attributes) { | ||
| return; | ||
| } | ||
| const attributeTypes = ["named", "numeric"]; | ||
| if (typeof attributes === "string") { | ||
| this.attrs = attrs(attributes); | ||
| } else if (attributes.length === attributeTypes.length && attributeTypes.every((t, key) => t === attributes[key])) { | ||
| this.attrs = attributes; | ||
| } else { | ||
| Object.entries(attributes).forEach(([key, value]) => { | ||
| this.set(key, value); | ||
| }); | ||
| } | ||
| }, | ||
| { | ||
| next, | ||
| replace, | ||
| string, | ||
| regexp, | ||
| attrs, | ||
| fromMatch | ||
| } | ||
| ); | ||
| Object.assign(shortcode.prototype, { | ||
| /** | ||
| * Get a shortcode attribute. | ||
| * | ||
| * Automatically detects whether `attr` is named or numeric and routes it | ||
| * accordingly. | ||
| * | ||
| * @param {(number|string)} attr Attribute key. | ||
| * | ||
| * @return {string} Attribute value. | ||
| */ | ||
| get(attr) { | ||
| return this.attrs[typeof attr === "number" ? "numeric" : "named"][attr]; | ||
| }, | ||
| /** | ||
| * Set a shortcode attribute. | ||
| * | ||
| * Automatically detects whether `attr` is named or numeric and routes it | ||
| * accordingly. | ||
| * | ||
| * @param {(number|string)} attr Attribute key. | ||
| * @param {string} value Attribute value. | ||
| * | ||
| * @return {InstanceType< import('./types').shortcode >} Shortcode instance. | ||
| */ | ||
| set(attr, value) { | ||
| this.attrs[typeof attr === "number" ? "numeric" : "named"][attr] = value; | ||
| return this; | ||
| }, | ||
| /** | ||
| * Transform the shortcode into a string. | ||
| * | ||
| * @return {string} String representation of the shortcode. | ||
| */ | ||
| string() { | ||
| let text = "[" + this.tag; | ||
| this.attrs.numeric.forEach((value) => { | ||
| if (/\s/.test(value)) { | ||
| text += ' "' + value + '"'; | ||
| } else { | ||
| text += " " + value; | ||
| } | ||
| }); | ||
| Object.entries(this.attrs.named).forEach(([name, value]) => { | ||
| text += " " + name + '="' + value + '"'; | ||
| }); | ||
| if ("single" === this.type) { | ||
| return text + "]"; | ||
| } else if ("self-closing" === this.type) { | ||
| return text + " /]"; | ||
| } | ||
| text += "]"; | ||
| if (this.content) { | ||
| text += this.content; | ||
| } | ||
| return text + "[/" + this.tag + "]"; | ||
| } | ||
| }); | ||
| var index_default = shortcode; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| attrs, | ||
| fromMatch, | ||
| next, | ||
| regexp, | ||
| replace, | ||
| string, | ||
| ...require("./types.cjs") | ||
| }); | ||
| //# sourceMappingURL=index.cjs.map |
| { | ||
| "version": 3, | ||
| "sources": ["../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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAmB;AAEnB,0BAAc,wBALd;AAgBO,SAAS,KAAM,KAAK,MAAM,QAAQ,GAAI;AAC5C,QAAM,KAAK,OAAQ,GAAI;AAEvB,KAAG,YAAY;AAEf,QAAM,QAAQ,GAAG,KAAM,IAAK;AAE5B,MAAK,CAAE,OAAQ;AACd;AAAA,EACD;AAGA,MAAK,QAAQ,MAAO,CAAE,KAAK,QAAQ,MAAO,CAAE,GAAI;AAC/C,WAAO,KAAM,KAAK,MAAM,GAAG,SAAU;AAAA,EACtC;AAEA,QAAM,SAAS;AAAA,IACd,OAAO,MAAM;AAAA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strict"; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| // packages/shortcode/src/types.ts | ||
| var types_exports = {}; | ||
| module.exports = __toCommonJS(types_exports); | ||
| //# sourceMappingURL=types.cjs.map |
| { | ||
| "version": 3, | ||
| "sources": ["../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": ";;;;;;;;;;;;;;;;AAAA;AAAA;", | ||
| "names": [] | ||
| } |
| // packages/shortcode/src/index.js | ||
| import memize from "memize"; | ||
| export * from "./types"; | ||
| export * from "./types.js"; | ||
| function next(tag, text, index = 0) { | ||
@@ -5,0 +5,0 @@ const re = regexp(tag); |
+12
-4
| { | ||
| "name": "@wordpress/shortcode", | ||
| "version": "4.36.1-next.6deb34194.0", | ||
| "version": "4.36.1-next.738bb1424.0", | ||
| "description": "Shortcode module for WordPress.", | ||
@@ -25,3 +25,11 @@ "author": "The WordPress Contributors", | ||
| }, | ||
| "main": "build/index.js", | ||
| "files": [ | ||
| "src", | ||
| "build", | ||
| "build-module", | ||
| "build-types", | ||
| "*.md" | ||
| ], | ||
| "type": "module", | ||
| "main": "build/index.cjs", | ||
| "module": "build-module/index.js", | ||
@@ -32,3 +40,3 @@ "exports": { | ||
| "import": "./build-module/index.js", | ||
| "require": "./build/index.js" | ||
| "require": "./build/index.cjs" | ||
| }, | ||
@@ -47,3 +55,3 @@ "./package.json": "./package.json" | ||
| }, | ||
| "gitHead": "457096e9e9b3896d2d4fe54fc19d7fb571ee9a44" | ||
| "gitHead": "ab1b004c0d61c295aa34bc86ea07f979343983ce" | ||
| } |
-229
| "use strict"; | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __export = (target, all) => { | ||
| for (var name in all) | ||
| __defProp(target, name, { get: all[name], enumerable: true }); | ||
| }; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
| // If the importer is in node compatibility mode or this is not an ESM | ||
| // file that has been converted to a CommonJS file using a Babel- | ||
| // compatible transform (i.e. "__esModule" has not been set), then set | ||
| // "default" to the CommonJS "module.exports" for node compatibility. | ||
| isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
| mod | ||
| )); | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| // packages/shortcode/src/index.js | ||
| var index_exports = {}; | ||
| __export(index_exports, { | ||
| attrs: () => attrs, | ||
| default: () => index_default, | ||
| fromMatch: () => fromMatch, | ||
| next: () => next, | ||
| regexp: () => regexp, | ||
| replace: () => replace, | ||
| string: () => string | ||
| }); | ||
| module.exports = __toCommonJS(index_exports); | ||
| var import_memize = __toESM(require("memize")); | ||
| __reExport(index_exports, require("./types"), module.exports); | ||
| function next(tag, text, index = 0) { | ||
| const re = regexp(tag); | ||
| re.lastIndex = index; | ||
| const match = re.exec(text); | ||
| if (!match) { | ||
| return; | ||
| } | ||
| if ("[" === match[1] && "]" === match[7]) { | ||
| return next(tag, text, re.lastIndex); | ||
| } | ||
| const result = { | ||
| index: match.index, | ||
| content: match[0], | ||
| shortcode: fromMatch(match) | ||
| }; | ||
| if (match[1]) { | ||
| result.content = result.content.slice(1); | ||
| result.index++; | ||
| } | ||
| if (match[7]) { | ||
| result.content = result.content.slice(0, -1); | ||
| } | ||
| return result; | ||
| } | ||
| function replace(tag, text, callback) { | ||
| return text.replace( | ||
| regexp(tag), | ||
| function(match, left, $3, attrs2, slash, content, closing, right) { | ||
| if (left === "[" && right === "]") { | ||
| return match; | ||
| } | ||
| const result = callback(fromMatch(arguments)); | ||
| return result || result === "" ? left + result + right : match; | ||
| } | ||
| ); | ||
| } | ||
| function string(options) { | ||
| return new shortcode(options).string(); | ||
| } | ||
| function regexp(tag) { | ||
| return new RegExp( | ||
| "\\[(\\[?)(" + tag + ")(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)", | ||
| "g" | ||
| ); | ||
| } | ||
| var attrs = (0, import_memize.default)((text) => { | ||
| const named = {}; | ||
| const numeric = []; | ||
| const pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g; | ||
| text = text.replace(/[\u00a0\u200b]/g, " "); | ||
| let match; | ||
| while (match = pattern.exec(text)) { | ||
| if (match[1]) { | ||
| named[match[1].toLowerCase()] = match[2]; | ||
| } else if (match[3]) { | ||
| named[match[3].toLowerCase()] = match[4]; | ||
| } else if (match[5]) { | ||
| named[match[5].toLowerCase()] = match[6]; | ||
| } else if (match[7]) { | ||
| numeric.push(match[7]); | ||
| } else if (match[8]) { | ||
| numeric.push(match[8]); | ||
| } else if (match[9]) { | ||
| numeric.push(match[9]); | ||
| } | ||
| } | ||
| return { named, numeric }; | ||
| }); | ||
| function fromMatch(match) { | ||
| let type; | ||
| if (match[4]) { | ||
| type = "self-closing"; | ||
| } else if (match[6]) { | ||
| type = "closed"; | ||
| } else { | ||
| type = "single"; | ||
| } | ||
| return new shortcode({ | ||
| tag: match[2], | ||
| attrs: match[3], | ||
| type, | ||
| content: match[5] | ||
| }); | ||
| } | ||
| var shortcode = Object.assign( | ||
| function(options) { | ||
| const { tag, attrs: attributes, type, content } = options || {}; | ||
| Object.assign(this, { tag, type, content }); | ||
| this.attrs = { | ||
| named: {}, | ||
| numeric: [] | ||
| }; | ||
| if (!attributes) { | ||
| return; | ||
| } | ||
| const attributeTypes = ["named", "numeric"]; | ||
| if (typeof attributes === "string") { | ||
| this.attrs = attrs(attributes); | ||
| } else if (attributes.length === attributeTypes.length && attributeTypes.every((t, key) => t === attributes[key])) { | ||
| this.attrs = attributes; | ||
| } else { | ||
| Object.entries(attributes).forEach(([key, value]) => { | ||
| this.set(key, value); | ||
| }); | ||
| } | ||
| }, | ||
| { | ||
| next, | ||
| replace, | ||
| string, | ||
| regexp, | ||
| attrs, | ||
| fromMatch | ||
| } | ||
| ); | ||
| Object.assign(shortcode.prototype, { | ||
| /** | ||
| * Get a shortcode attribute. | ||
| * | ||
| * Automatically detects whether `attr` is named or numeric and routes it | ||
| * accordingly. | ||
| * | ||
| * @param {(number|string)} attr Attribute key. | ||
| * | ||
| * @return {string} Attribute value. | ||
| */ | ||
| get(attr) { | ||
| return this.attrs[typeof attr === "number" ? "numeric" : "named"][attr]; | ||
| }, | ||
| /** | ||
| * Set a shortcode attribute. | ||
| * | ||
| * Automatically detects whether `attr` is named or numeric and routes it | ||
| * accordingly. | ||
| * | ||
| * @param {(number|string)} attr Attribute key. | ||
| * @param {string} value Attribute value. | ||
| * | ||
| * @return {InstanceType< import('./types').shortcode >} Shortcode instance. | ||
| */ | ||
| set(attr, value) { | ||
| this.attrs[typeof attr === "number" ? "numeric" : "named"][attr] = value; | ||
| return this; | ||
| }, | ||
| /** | ||
| * Transform the shortcode into a string. | ||
| * | ||
| * @return {string} String representation of the shortcode. | ||
| */ | ||
| string() { | ||
| let text = "[" + this.tag; | ||
| this.attrs.numeric.forEach((value) => { | ||
| if (/\s/.test(value)) { | ||
| text += ' "' + value + '"'; | ||
| } else { | ||
| text += " " + value; | ||
| } | ||
| }); | ||
| Object.entries(this.attrs.named).forEach(([name, value]) => { | ||
| text += " " + name + '="' + value + '"'; | ||
| }); | ||
| if ("single" === this.type) { | ||
| return text + "]"; | ||
| } else if ("self-closing" === this.type) { | ||
| return text + " /]"; | ||
| } | ||
| text += "]"; | ||
| if (this.content) { | ||
| text += this.content; | ||
| } | ||
| return text + "[/" + this.tag + "]"; | ||
| } | ||
| }); | ||
| var index_default = shortcode; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| attrs, | ||
| fromMatch, | ||
| next, | ||
| regexp, | ||
| replace, | ||
| string, | ||
| ...require("./types") | ||
| }); | ||
| //# sourceMappingURL=index.js.map |
| { | ||
| "version": 3, | ||
| "sources": ["../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": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAmB;AAEnB,0BAAc,oBALd;AAgBO,SAAS,KAAM,KAAK,MAAM,QAAQ,GAAI;AAC5C,QAAM,KAAK,OAAQ,GAAI;AAEvB,KAAG,YAAY;AAEf,QAAM,QAAQ,GAAG,KAAM,IAAK;AAE5B,MAAK,CAAE,OAAQ;AACd;AAAA,EACD;AAGA,MAAK,QAAQ,MAAO,CAAE,KAAK,QAAQ,MAAO,CAAE,GAAI;AAC/C,WAAO,KAAM,KAAK,MAAM,GAAG,SAAU;AAAA,EACtC;AAEA,QAAM,SAAS;AAAA,IACd,OAAO,MAAM;AAAA,IACb,SAAS,MAAO,CAAE;AAAA,IAClB,WAAW,UAAW,KAAM;AAAA,EAC7B;AAIA,MAAK,MAAO,CAAE,GAAI;AACjB,WAAO,UAAU,OAAO,QAAQ,MAAO,CAAE;AACzC,WAAO;AAAA,EACR;AAGA,MAAK,MAAO,CAAE,GAAI;AACjB,WAAO,UAAU,OAAO,QAAQ,MAAO,GAAG,EAAG;AAAA,EAC9C;AAEA,SAAO;AACR;AAYO,SAAS,QAAS,KAAK,MAAM,UAAW;AAC9C,SAAO,KAAK;AAAA,IACX,OAAQ,GAAI;AAAA,IACZ,SAAW,OAAO,MAAM,IAAIA,QAAO,OAAO,SAAS,SAAS,OAAQ;AAGnE,UAAK,SAAS,OAAO,UAAU,KAAM;AACpC,eAAO;AAAA,MACR;AAGA,YAAM,SAAS,SAAU,UAAW,SAAU,CAAE;AAIhD,aAAO,UAAU,WAAW,KAAK,OAAO,SA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A;AAAA;AAAA;AAAA,EAOA,SAAS;AACR,QAAI,OAAO,MAAM,KAAK;AAEtB,SAAK,MAAM,QAAQ,QAAS,CAAE,UAAW;AACxC,UAAK,KAAK,KAAM,KAAM,GAAI;AACzB,gBAAQ,OAAO,QAAQ;AAAA,MACxB,OAAO;AACN,gBAAQ,MAAM;AAAA,MACf;AAAA,IACD,CAAE;AAEF,WAAO,QAAS,KAAK,MAAM,KAAM,EAAE,QAAS,CAAE,CAAE,MAAM,KAAM,MAAO;AAClE,cAAQ,MAAM,OAAO,OAAO,QAAQ;AAAA,IACrC,CAAE;AAIF,QAAK,aAAa,KAAK,MAAO;AAC7B,aAAO,OAAO;AAAA,IACf,WAAY,mBAAmB,KAAK,MAAO;AAC1C,aAAO,OAAO;AAAA,IACf;AAGA,YAAQ;AAER,QAAK,KAAK,SAAU;AACnB,cAAQ,KAAK;AAAA,IACd;AAGA,WAAO,OAAO,OAAO,KAAK,MAAM;AAAA,EACjC;AACD,CAAE;AAEF,IAAO,gBAAQ;", | ||
| "names": ["attrs", "memize"] | ||
| } |
| "use strict"; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (let key of __getOwnPropNames(from)) | ||
| if (!__hasOwnProp.call(to, key) && key !== except) | ||
| __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
| // packages/shortcode/src/types.ts | ||
| var types_exports = {}; | ||
| module.exports = __toCommonJS(types_exports); | ||
| //# sourceMappingURL=types.js.map |
| { | ||
| "version": 3, | ||
| "sources": ["../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": ";;;;;;;;;;;;;;;;AAAA;AAAA;", | ||
| "names": [] | ||
| } |
| { | ||
| "$schema": "https://json.schemastore.org/tsconfig.json", | ||
| "extends": "../../tsconfig.base.json", | ||
| "compilerOptions": { | ||
| "checkJs": false | ||
| } | ||
| } |
Sorry, the diff of this file is not supported yet
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Yes
NaN124661
-11.18%19
-9.52%1482
-0.47%