UNPKG

vue-files-preview-inno

Version:

A tool for previewing files such as doc, excel, pdf, image, markdown, txt, audio, and video and so on.

561 lines (560 loc) 13.1 kB
var O, v; function k() { if (v) return O; v = 1; function M(e) { const t = e.regex, I = /(?![A-Za-z0-9])(?![$])/, o = t.concat( /[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/, I ), r = t.concat( /(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/, I ), _ = { scope: "variable", match: "\\$+" + o }, N = { scope: "meta", variants: [ { begin: /<\?php/, relevance: 10 }, // boost for obvious PHP { begin: /<\?=/ }, // less relevant per PSR-1 which says not to use short-tags { begin: /<\?/, relevance: 0.1 }, { begin: /\?>/ } // end php tag ] }, g = { scope: "subst", variants: [ { begin: /\$\w+/ }, { begin: /\{\$/, end: /\}/ } ] }, y = e.inherit(e.APOS_STRING_MODE, { illegal: null }), h = e.inherit(e.QUOTE_STRING_MODE, { illegal: null, contains: e.QUOTE_STRING_MODE.contains.concat(g) }), w = { begin: /<<<[ \t]*(?:(\w+)|"(\w+)")\n/, end: /[ \t]*(\w+)\b/, contains: e.QUOTE_STRING_MODE.contains.concat(g), "on:begin": (n, a) => { a.data._beginMatch = n[1] || n[2]; }, "on:end": (n, a) => { a.data._beginMatch !== n[1] && a.ignoreMatch(); } }, x = e.END_SAME_AS_BEGIN({ begin: /<<<[ \t]*'(\w+)'\n/, end: /[ \t]*(\w+)\b/ }), S = `[ ]`, i = { scope: "string", variants: [ h, y, w, x ] }, s = { scope: "number", variants: [ { begin: "\\b0[bB][01]+(?:_[01]+)*\\b" }, // Binary w/ underscore support { begin: "\\b0[oO][0-7]+(?:_[0-7]+)*\\b" }, // Octals w/ underscore support { begin: "\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b" }, // Hex w/ underscore support // Decimals w/ underscore support, with optional fragments and scientific exponent (e) suffix. { begin: "(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?" } ], relevance: 0 }, E = [ "false", "null", "true" ], T = [ // Magic constants: // <https://www.php.net/manual/en/language.constants.predefined.php> "__CLASS__", "__DIR__", "__FILE__", "__FUNCTION__", "__COMPILER_HALT_OFFSET__", "__LINE__", "__METHOD__", "__NAMESPACE__", "__TRAIT__", // Function that look like language construct or language construct that look like function: // List of keywords that may not require parenthesis "die", "echo", "exit", "include", "include_once", "print", "require", "require_once", // These are not language construct (function) but operate on the currently-executing function and can access the current symbol table // 'compact extract func_get_arg func_get_args func_num_args get_called_class get_parent_class ' + // Other keywords: // <https://www.php.net/manual/en/reserved.php> // <https://www.php.net/manual/en/language.types.type-juggling.php> "array", "abstract", "and", "as", "binary", "bool", "boolean", "break", "callable", "case", "catch", "class", "clone", "const", "continue", "declare", "default", "do", "double", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif", "endswitch", "endwhile", "enum", "eval", "extends", "final", "finally", "float", "for", "foreach", "from", "global", "goto", "if", "implements", "instanceof", "insteadof", "int", "integer", "interface", "isset", "iterable", "list", "match|0", "mixed", "new", "never", "object", "or", "private", "protected", "public", "readonly", "real", "return", "string", "switch", "throw", "trait", "try", "unset", "use", "var", "void", "while", "xor", "yield" ], d = [ // Standard PHP library: // <https://www.php.net/manual/en/book.spl.php> "Error|0", "AppendIterator", "ArgumentCountError", "ArithmeticError", "ArrayIterator", "ArrayObject", "AssertionError", "BadFunctionCallException", "BadMethodCallException", "CachingIterator", "CallbackFilterIterator", "CompileError", "Countable", "DirectoryIterator", "DivisionByZeroError", "DomainException", "EmptyIterator", "ErrorException", "Exception", "FilesystemIterator", "FilterIterator", "GlobIterator", "InfiniteIterator", "InvalidArgumentException", "IteratorIterator", "LengthException", "LimitIterator", "LogicException", "MultipleIterator", "NoRewindIterator", "OutOfBoundsException", "OutOfRangeException", "OuterIterator", "OverflowException", "ParentIterator", "ParseError", "RangeException", "RecursiveArrayIterator", "RecursiveCachingIterator", "RecursiveCallbackFilterIterator", "RecursiveDirectoryIterator", "RecursiveFilterIterator", "RecursiveIterator", "RecursiveIteratorIterator", "RecursiveRegexIterator", "RecursiveTreeIterator", "RegexIterator", "RuntimeException", "SeekableIterator", "SplDoublyLinkedList", "SplFileInfo", "SplFileObject", "SplFixedArray", "SplHeap", "SplMaxHeap", "SplMinHeap", "SplObjectStorage", "SplObserver", "SplPriorityQueue", "SplQueue", "SplStack", "SplSubject", "SplTempFileObject", "TypeError", "UnderflowException", "UnexpectedValueException", "UnhandledMatchError", // Reserved interfaces: // <https://www.php.net/manual/en/reserved.interfaces.php> "ArrayAccess", "BackedEnum", "Closure", "Fiber", "Generator", "Iterator", "IteratorAggregate", "Serializable", "Stringable", "Throwable", "Traversable", "UnitEnum", "WeakReference", "WeakMap", // Reserved classes: // <https://www.php.net/manual/en/reserved.classes.php> "Directory", "__PHP_Incomplete_Class", "parent", "php_user_filter", "self", "static", "stdClass" ], p = { keyword: T, literal: ((n) => { const a = []; return n.forEach((c) => { a.push(c), c.toLowerCase() === c ? a.push(c.toUpperCase()) : a.push(c.toLowerCase()); }), a; })(E), built_in: d }, b = (n) => n.map((a) => a.replace(/\|\d+$/, "")), u = { variants: [ { match: [ /new/, t.concat(S, "+"), // to prevent built ins from being confused as the class constructor call t.concat("(?!", b(d).join("\\b|"), "\\b)"), r ], scope: { 1: "keyword", 4: "title.class" } } ] }, f = t.concat(o, "\\b(?!\\()"), l = { variants: [ { match: [ t.concat( /::/, t.lookahead(/(?!class\b)/) ), f ], scope: { 2: "variable.constant" } }, { match: [ /::/, /class/ ], scope: { 2: "variable.language" } }, { match: [ r, t.concat( /::/, t.lookahead(/(?!class\b)/) ), f ], scope: { 1: "title.class", 3: "variable.constant" } }, { match: [ r, t.concat( "::", t.lookahead(/(?!class\b)/) ) ], scope: { 1: "title.class" } }, { match: [ r, /::/, /class/ ], scope: { 1: "title.class", 3: "variable.language" } } ] }, C = { scope: "attr", match: t.concat(o, t.lookahead(":"), t.lookahead(/(?!::)/)) }, R = { relevance: 0, begin: /\(/, end: /\)/, keywords: p, contains: [ C, _, l, e.C_BLOCK_COMMENT_MODE, i, s, u ] }, A = { relevance: 0, match: [ /\b/, // to prevent keywords from being confused as the function title t.concat("(?!fn\\b|function\\b|", b(T).join("\\b|"), "|", b(d).join("\\b|"), "\\b)"), o, t.concat(S, "*"), t.lookahead(/(?=\()/) ], scope: { 3: "title.function.invoke" }, contains: [R] }; R.contains.push(A); const m = [ C, l, e.C_BLOCK_COMMENT_MODE, i, s, u ], D = { begin: t.concat(/#\[\s*/, r), beginScope: "meta", end: /]/, endScope: "meta", keywords: { literal: E, keyword: [ "new", "array" ] }, contains: [ { begin: /\[/, end: /]/, keywords: { literal: E, keyword: [ "new", "array" ] }, contains: [ "self", ...m ] }, ...m, { scope: "meta", match: r } ] }; return { case_insensitive: !1, keywords: p, contains: [ D, e.HASH_COMMENT_MODE, e.COMMENT("//", "$"), e.COMMENT( "/\\*", "\\*/", { contains: [ { scope: "doctag", match: "@[A-Za-z]+" } ] } ), { match: /__halt_compiler\(\);/, keywords: "__halt_compiler", starts: { scope: "comment", end: e.MATCH_NOTHING_RE, contains: [ { match: /\?>/, scope: "meta", endsParent: !0 } ] } }, N, { scope: "variable.language", match: /\$this\b/ }, _, A, l, { match: [ /const/, /\s/, o ], scope: { 1: "keyword", 3: "variable.constant" } }, u, { scope: "function", relevance: 0, beginKeywords: "fn function", end: /[;{]/, excludeEnd: !0, illegal: "[$%\\[]", contains: [ { beginKeywords: "use" }, e.UNDERSCORE_TITLE_MODE, { begin: "=>", // No markup, just a relevance booster endsParent: !0 }, { scope: "params", begin: "\\(", end: "\\)", excludeBegin: !0, excludeEnd: !0, keywords: p, contains: [ "self", _, l, e.C_BLOCK_COMMENT_MODE, i, s ] } ] }, { scope: "class", variants: [ { beginKeywords: "enum", illegal: /[($"]/ }, { beginKeywords: "class interface trait", illegal: /[:($"]/ } ], relevance: 0, end: /\{/, excludeEnd: !0, contains: [ { beginKeywords: "extends implements" }, e.UNDERSCORE_TITLE_MODE ] }, // both use and namespace still use "old style" rules (vs multi-match) // because the namespace name can include `\` and we still want each // element to be treated as its own *individual* title { beginKeywords: "namespace", relevance: 0, end: ";", illegal: /[.']/, contains: [e.inherit(e.UNDERSCORE_TITLE_MODE, { scope: "title.class" })] }, { beginKeywords: "use", relevance: 0, end: ";", contains: [ // TODO: title.function vs title.class { match: /\b(as|const|function)\b/, scope: "keyword" }, // TODO: could be title.class or title.function e.UNDERSCORE_TITLE_MODE ] }, i, s ] }; } return O = M, O; } export { k as __require }; //# sourceMappingURL=php.mjs.map