mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-26 02:15:15 +00:00
1 line
16 KiB
Plaintext
1 line
16 KiB
Plaintext
|
{"version":3,"file":"index.esm.mjs","sources":["src/lib/util.js","src/lib/cssMap.js","src/lib/readFile.js","src/lib/parse.js","src/lib/postcssImportNormalize.js","src/lib/postcssNormalize.js","src/index.js"],"sourcesContent":["export const assign = (...objects) => Object.assign(...objects);\nexport const create = (...objects) => assign(Object.create(null), ...objects);\n","import { create } from './util';\nimport Module from 'module';\nimport path from 'path';\nimport { URL } from 'url';\n\n// get esm-compatible script metadata\nconst currentURL = import.meta.url;\nconst currentFilename = new URL(currentURL).pathname;\nconst currentDirname = path.dirname(currentFilename);\n\n// get resolved filenames for css libraries\nconst normalizeCSS = resolve('@csstools/normalize.css');\nconst normalizeOpinionatedCSS = resolve('@csstools/normalize.css/opinionated.css');\nconst sanitizeCSS = resolve('sanitize.css');\nconst sanitizeFormsCSS = resolve('sanitize.css/forms.css');\nconst sanitizePageCSS = resolve('sanitize.css/page.css');\nconst sanitizeTypographyCSS = resolve('sanitize.css/typography.css');\n\n// export a hashmap of css library filenames\nexport const parsableFilenames = create({\n\t[normalizeCSS]: true,\n\t[normalizeOpinionatedCSS]: true,\n\t[sanitizeCSS]: true,\n\t[sanitizeFormsCSS]: true,\n\t[sanitizePageCSS]: true,\n\t[sanitizeTypographyCSS]: true\n});\n\n// export a hashmap of css library filenames by id\nexport const resolvedFilenamesById = create({\n\t'normalize': [normalizeCSS],\n\t'normalize/opinionated': [normalizeOpinionatedCSS],\n\t'normalize/*': [normalizeOpinionatedCSS],\n\t'sanitize': [sanitizeCSS],\n\t'sanitize/forms': [sanitizeCSS, sanitizeFormsCSS],\n\t'sanitize/page': [sanitizeCSS, sanitizePageCSS],\n\t'sanitize/typography': [sanitizeCSS, sanitizeTypographyCSS],\n\t'sanitize/*': [sanitizeCSS, sanitizeFormsCSS, sanitizePageCSS, sanitizeTypographyCSS]\n});\n\n// get the resolved filename of a package/module\nfunction resolve (id) {\n\treturn resolve[id] = resolve[id] || Module._resolveFilename(id, {\n\t\tid: currentFilename,\n\t\tfilename: currentFilename,\n\t\tpaths: Module._nodeModulePaths(currentDirname)\n\t});\n}\n","import { create } from './util';\nimport path from 'path';\nimport fs from 'fs';\n\nconst cache = create();\n\nexport default async function readFile (filename) {\n\tfilename = path.resolve(filename);\n\n\tcache[filename] = cache[filename] || create();\n\n\treturn new Promise(\n\t\t(resolve, reject) => fs.stat(\n\t\t\tfilename,\n\t\t\t(statsError, { mtime }) => statsError\n\t\t\t\t? reject(statsError)\n\t\t\t: mtime === cache[filename].mtime\n\t\t\t\t? resolve(cache[filename].data)\n\t\t\t: fs.readFile(\n\t\t\t\tfilename,\n\t\t\t\t'utf8',\n\t\t\t\t(readFileError, data) => readFileError\n\t\t\t\t\t? reject(readFileError)\n\t\t\t\t: resolve(\n\t\t\t\t\t(cache[filename] = { data, mtime }).data\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t);\n}\n","import { create } from './util';\nimport readFile from './readFile';\nimport postcss from 'postcss';\n\nconst cache = create(null);\n\nexport default (filename, transformer) => readFile(filename).then(\n\t// cache the parsed css root\n\tcss => (cache[css] = cache[css] || postcss.parse(css, { from: filename }))\n).then(\n\t// clone the cached root\n\troot => root.clone()\n).then(\n\t// transform the cloned root\n\tclone => Promise.resolve(\n\t\ttransformer(clone)\n\t).then(\n\t\t// resolve the cloned root\n\t\t() => clone\n\t)\n);\n","import { create } from './util';\nimport { parsableFilenames, resolvedFilenamesById } from './cssMap';\nimport parse from './parse';\nimport readFile from './readFile';\n\nexport default commentsTransformer => opts => {\n\topts = create(opts);\n\n\t// return an postcss-import configuration\n\treturn create({\n\t\tload (filename, importOptions) {\n\t\t\treturn filename in parsableFilenames\n\t\t\t\t// parse the file (the file and css are conservatively cached)\n\t\t\t\t? parse(filename, commentsTransformer).then(\n\t\t\t\t\troot => root.toResult({ to: filename, map: true }).css\n\t\t\t\t)\n\t\t\t: typeof opts.load === 'function'\n\t
|