UNPKG

alapa

Version:

A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.

39 lines (38 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.includesRegex = exports.outputRegex = exports.noCodeRegex = exports.commentsRegex = exports.importRegex = exports.moduleRegex = exports.containerRegex = exports.htmlInlineTagsRegex = exports.htmlTagsRegex = exports.templateCommentRegex = exports.codeRegex = exports.attributeRegex = void 0; const utils_1 = require("../../utils"); exports.attributeRegex = /([a-zA-Z][a-zA-Z\d\-_]*)(\s*=\s*("([^"]*)")?)?/g; exports.codeRegex = /\{%([\s\S]*?)%\}/g; exports.templateCommentRegex = /\{#([\s\S]*?)#\}/g; exports.htmlTagsRegex = /<[xX]:(\w+)([^/>]*)>([\s\S]*?)<\/[xX]:(\1)>/g; exports.htmlInlineTagsRegex = /<[xX]:([\w.-:]+)(\s+[^>]*)?\s*\/>/g; exports.containerRegex = /<[Pp]ush\b([\s\S]*?)>([\s\S]*?)<\/[Pp]ush>/g; const moduleRegex = (isDefault, ...names) => { if (isDefault == "all") { return /<component\s*(default)?\s*([a-zA-Z0-9-:_.]*)\s*([^>]+)?\s*>\s*([\s\S]*?)\s*<\/component>/gi; } let not = "?!"; if (isDefault) not = ""; if (names.length === 0) { names.push("[a-zA-Z0-9-:_.]*"); } else { names = names.map(utils_1.escapeRegex); } const name = names.join("|"); // Join names with OR operator ///Matches all components without default // <component\s+(?!default\s)([a-zA-Z0-9-:_\.]*)\s*([^>]*)\s*>\s*([\s\S]*?)<\/component> //old pattern <component\s*(default)?\s*(input)\s*>\s*([\s\S]*?)<\/component> return new RegExp(`<component\\s+(${not}default\\s)(${name})\\s*([^>]*)\\s*>\\s*([\\s\\S]*?)<\\/component>`, "gi" // Flags for global and case-insensitive matching ); }; exports.moduleRegex = moduleRegex; ///<(x:\w+)([^/>]*)>([\s\S]*?)<\/(\1)>/g; //(<x:([\w.-:]+)(\s+[^>]*)?\s*\/>)| exports.importRegex = /import\s+((?:{[^{}]+}|.*?))\s*(?:from)?\s*['"](.*?)['"]|import\(['"](.*?)["']\)/g; exports.commentsRegex = /\/\/.*|\/\*[^]*\*\//gm; exports.noCodeRegex = /<no-code\s*>*\s*>\s*([\s\S]*?)<\/no-code>/g; exports.outputRegex = /(?!\\)(\{{2,3})([^\\%}]*?)(\}{2,3})(?!%)/g; exports.includesRegex = /(include|require)\s?\s*\(?['"](.*?)['"]\)?;?/g;