PromoCursed/node_modules/.cache/babel-loader/22bb18ac427a8c921a94e7d69a4acbdedc143977f408e6cc4f88dddff34e484e.json

1 line
12 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import { MS, MOZ, WEBKIT, RULESET, KEYFRAMES, DECLARATION } from './Enum.js';\nimport { match, charat, substr, strlen, sizeof, replace, combine, filter, assign } from './Utility.js';\nimport { copy, lift, tokenize } from './Tokenizer.js';\nimport { serialize } from './Serializer.js';\nimport { prefix } from './Prefixer.js';\n\n/**\n * @param {function[]} collection\n * @return {function}\n */\nexport function middleware(collection) {\n var length = sizeof(collection);\n return function (element, index, children, callback) {\n var output = '';\n for (var i = 0; i < length; i++) output += collection[i](element, index, children, callback) || '';\n return output;\n };\n}\n\n/**\n * @param {function} callback\n * @return {function}\n */\nexport function rulesheet(callback) {\n return function (element) {\n if (!element.root) if (element = element.return) callback(element);\n };\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n */\nexport function prefixer(element, index, children, callback) {\n if (element.length > -1) if (!element.return) switch (element.type) {\n case DECLARATION:\n element.return = prefix(element.value, element.length, children);\n return;\n case KEYFRAMES:\n return serialize([copy(element, {\n value: replace(element.value, '@', '@' + WEBKIT)\n })], callback);\n case RULESET:\n if (element.length) return combine(children = element.props, function (value) {\n switch (match(value, callback = /(::plac\\w+|:read-\\w+)/)) {\n // :read-(only|write)\n case ':read-only':\n case ':read-write':\n lift(copy(element, {\n props: [replace(value, /:(read-\\w+)/, ':' + MOZ + '$1')]\n }));\n lift(copy(element, {\n props: [value]\n }));\n assign(element, {\n props: filter(children, callback)\n });\n break;\n // :placeholder\n case '::placeholder':\n lift(copy(element, {\n props: [replace(value, /:(plac\\w+)/, ':' + WEBKIT + 'input-$1')]\n }));\n lift(copy(element, {\n props: [replace(value, /:(plac\\w+)/, ':' + MOZ + '$1')]\n }));\n lift(copy(element, {\n props: [replace(value, /:(plac\\w+)/, MS + 'input-$1')]\n }));\n lift(copy(element, {\n props: [value]\n }));\n assign(element, {\n props: filter(children, callback)\n });\n break;\n }\n return '';\n });\n }\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n */\nexport function namespace(element) {\n switch (element.type) {\n case RULESET:\n element.props = element.props.map(function (value) {\n return combine(tokenize(value), function (value, index, children) {\n switch (charat(value, 0)) {\n // \\f\n case 12:\n return substr(value, 1, strlen(value));\n // \\0 ( + > ~\n case 0:\n case 40:\n case 43:\n case 62:\n case 126:\n return value;\n // :\n case 58:\n if (children[++index] === 'global') children[index] = '', children[++index] = '\\f' + substr(children[index], index = 1, -1);\n // \\s\n case 32:\n return index === 1 ? '' : value;\n default:\n switch (index) {\n case 0:\n element = value;\n return sizeof(children) > 1 ? '' : value;\n case index = sizeof(children) - 1:\n case 2:\n return index === 2 ? value + element + element : value + element;\n default:\n return value;\n }\n }\n });\n });\n }\n}","map":{"versio