diff --git a/dist/browser-umd.js b/dist/browser-umd.js index 770161e..ad94070 100644 --- a/dist/browser-umd.js +++ b/dist/browser-umd.js @@ -1,12 +1,34 @@ var critical = (function (exports) { 'use strict'; + /** + * + * @param {string[]} content + * @param {string} filename + * @param {string} mimetype + * @return {Promise} + */ + async function download(content, filename, mimetype = 'application/octet-stream; charset=utf-8') { + // + const url = URL.createObjectURL(new Blob(content, { type: mimetype })); + // + const a = document.createElement('a'); + document.body.append(a); + a.style.display = 'none'; + a.download = filename; + a.href = url; + // + a.dispatchEvent(new MouseEvent('click')); + URL.revokeObjectURL(url); + return content; + } + function resolve(path, from) { if (path.match(/^['"]?data:/)) { return path; } // @ts-ignore - const baseURL = new URL(from, window?.location); + const baseURL = new URL(from, window.location); const pathURL = new URL(path, baseURL); if (baseURL.protocol != pathURL.protocol || baseURL.host != pathURL.host || @@ -379,28 +401,6 @@ var critical = (function (exports) { return result; } - /** - * - * @param {string[]} content - * @param {string} filename - * @param {string} mimetype - * @return {Promise} - */ - async function download(content, filename, mimetype = 'application/octet-stream; charset=utf-8') { - // - const url = URL.createObjectURL(new Blob(content, { type: mimetype })); - // - const a = document.createElement('a'); - document.body.append(a); - a.style.display = 'none'; - a.download = filename; - a.href = url; - // - a.dispatchEvent(new MouseEvent('click')); - URL.revokeObjectURL(url); - return content; - } - async function extractAndDownload(filename = 'critical.css', options = {}) { return extract(options). then(async (content) => download(content.styles, filename, 'text/css; charset=utf-8'). diff --git a/dist/browser-umd.js.map b/dist/browser-umd.js.map index 478ff3d..834078e 100644 --- a/dist/browser-umd.js.map +++ b/dist/browser-umd.js.map @@ -1 +1 @@ -{"version":3,"file":"browser-umd.js","sources":["../src/file/path.ts","../src/critical/fontscript.ts","../src/critical/extract.ts","../src/file/download.ts","../src/browser.ts"],"sourcesContent":["\nexport function resolve(path: string, from: string): string {\n\n if (path.match(/^['\"]?data:/)) {\n\n return path;\n }\n\n // @ts-ignore\n const baseURL: URL = new URL(from, window?.location);\n const pathURL: URL = new URL(path, baseURL);\n\n if (baseURL.protocol != pathURL.protocol ||\n baseURL.host != pathURL.host ||\n pathURL.host != window.location.host ||\n baseURL.port != pathURL.port ||\n pathURL.port != window.location.port ||\n baseURL.port != pathURL.port ||\n pathURL.protocol != window.location.protocol\n ) {\n\n return pathURL.toString();\n }\n\n return pathURL.pathname + pathURL.search + pathURL.hash;\n}","import {FontObject} from \"../@types\";\n\nexport function fontscript(fonts: FontObject[]): string {\n\n return '/* font preloader script: ' + fonts.length + ' */\\n\"fonts\" in document && ' + JSON.stringify([...fonts], null, 1) + '.forEach(font => new FontFace(font.fontFamily, font.src, font.properties).load().then(font => document.fonts.add(font)))'\n}","import {resolve} from \"../file/path\";\nimport {fontscript} from \"./fontscript\";\nimport {\n CriticalExtractOptions,\n CriticalResult,\n FileMapObject,\n FontObject,\n MatchCSSStyleSheet,\n RuleList\n} from \"../@types\";\n\nexport async function extract(options: CriticalExtractOptions = {}) {\n\n const document: Document = window.document;\n const location: Location = window.location;\n const styles: Set = new Set;\n const excluded = ['all', 'print', ''];\n const allStylesheets: MatchCSSStyleSheet[] = [];\n\n // Get a list of all the elements in the view.\n const height = window.innerHeight;\n const walker = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, {acceptNode: () => NodeFilter.SHOW_ELEMENT});\n\n const fonts: Set = new Set;\n const fontFamilies: Set = new Set;\n const files: Map = new Map;\n const weakMap: WeakMap = new WeakMap;\n const nodeMap: Set = new Set;\n let nodeCount: number = 0;\n let k: number;\n let rule: CSSMediaRule | CSSStyleRule;\n let rules;\n\n performance.mark('filterStylesheets');\n\n for (k = 0; k < document.styleSheets.length; k++) {\n\n // @ts-ignore\n rule = document.styleSheets[k];\n\n if (rule.media.mediaText === 'print' || (rule.media.mediaText !== '' && !window.matchMedia(rule.media.mediaText).matches)) {\n\n continue;\n }\n\n try {\n\n\n // @ts-ignore\n rules = (rule).cssRules ?? (rule).rules;\n\n for (let l = 0; l < rules.length; l++) {\n\n allStylesheets.push({rule: rules[l], match: false})\n }\n\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify({'message': e.message, stylesheet: rule.href}, null, 1));\n }\n }\n\n performance.measure('filter stylesheets', 'filterStylesheets');\n\n if (allStylesheets.length === 0) {\n\n return {styles: [], fonts: [], stats: {}};\n }\n\n let node;\n let rect;\n let allStylesLength = allStylesheets.length;\n\n performance.mark('nodeWalking');\n\n while ((node = walker.nextNode())) {\n\n if (options && options.signal && options.signal.aborted) {\n\n return Promise.reject('Aborted');\n }\n\n if (['SCRIPT', 'LINK', 'HEAD', 'META', 'TITLE', 'NOSCRIPT'].includes(node.tagName)) {\n\n continue;\n }\n\n nodeCount++;\n rect = node.getBoundingClientRect();\n\n if (rect.top < height) {\n\n nodeMap.add(node);\n }\n }\n\n for (k = 0; k < allStylesLength; k++) {\n\n if (allStylesheets[k].match || weakMap.has(allStylesheets[k].rule)) {\n\n continue;\n }\n\n weakMap.set(allStylesheets[k].rule, 1);\n\n if (allStylesheets[k].rule instanceof CSSStyleRule) {\n\n // @ts-ignore\n let selector = allStylesheets[k].rule.selectorText;\n let match;\n\n // detect pseudo selectors\n if (selector.match(/(^|,|\\s)::?((before)|(after))/)) {\n\n match = true\n } else {\n\n if (selector.match(/::?((before)|(after))/)) {\n\n selector = selector.replace(/::?((before)|(after))\\s*((,)|$)/g, '$5');\n }\n\n try {\n\n match = nodeMap.has(document.querySelector(selector));\n } catch (e) {\n\n // @ts-ignore\n match = nodeMap.has(document.querySelector(allStylesheets[k].rule.selectorText));\n }\n }\n\n if (match) {\n\n allStylesheets[k].match = true;\n\n // @ts-ignore\n if (allStylesheets[k].rule.style.getPropertyValue('font-family')) {\n\n // @ts-ignore\n allStylesheets[k].rule.style.getPropertyValue('font-family').split(/\\s*,\\s*/).forEach(fontFamily => fontFamily !== 'inherit' && fontFamilies.add(fontFamily.replace(/(['\"])([^\\1\\s]+)\\1/, '$2')));\n }\n }\n\n } else if (allStylesheets[k].rule instanceof CSSMediaRule || allStylesheets[k].rule instanceof CSSImportRule || allStylesheets[k].rule instanceof CSSConditionRule) {\n\n // @ts-ignore\n if ((allStylesheets[k].rule instanceof CSSMediaRule || allStylesheets[k].rule instanceof CSSImportRule) && (allStylesheets[k].rule.media.mediaText === 'print' || (allStylesheets[k].rule.media.mediaText !== '' && !window.matchMedia(allStylesheets[k].rule.media.mediaText).matches))) {\n continue;\n }\n\n try {\n\n const rule = allStylesheets[k].rule;\n const rules = [];\n // @ts-ignore\n const sheet = rule instanceof CSSImportRule ? rule.styleSheet.cssRules || rule.styleSheet.rules : rule.cssRules || rule.rules;\n\n for (let l = 0; l < sheet.length; l++) {\n\n if (!weakMap.has(sheet[l])) {\n\n rules.push({rule: sheet[l], match: false})\n }\n }\n\n if (rules.length > 0) {\n\n // @ts-ignore\n allStylesheets.splice.apply(allStylesheets, [k + 1, 0].concat(rules))\n allStylesLength = allStylesheets.length\n }\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify({'message': e.message, stylesheet: rule.href}, null, 1));\n }\n } else if (allStylesheets[k].rule instanceof CSSFontFaceRule) {\n\n // @ts-ignore\n if (allStylesheets[k].rule.style.getPropertyValue('font-family') && allStylesheets[k].rule.style.getPropertyValue('src')) {\n\n // @ts-ignore\n fonts.add(allStylesheets[k].rule);\n }\n }\n }\n\n performance.measure('node walking', 'nodeWalking');\n\n let css;\n let file = '';\n let inlineCount = -1;\n\n performance.mark('rulesExtraction');\n\n loop1:\n for (let k = 0; k < allStylesLength; k++) {\n\n if (!allStylesheets[k].match) {\n\n continue;\n }\n\n // @ts-ignore\n rule = allStylesheets[k].rule;\n let fileUpdate = false;\n\n // @ts-ignore\n if (!files.has(rule.parentStyleSheet)) {\n\n //\n // @ts-ignore\n files.set(rule.parentStyleSheet, {\n\n // @ts-ignore\n base: (rule.parentStyleSheet.href && rule.parentStyleSheet.href.replace(/[?#].*/, '') || location.pathname).replace(/([^/]+)$/, ''),\n // @ts-ignore\n file: rule.parentStyleSheet.href || `inline style #${++inlineCount}`\n });\n\n fileUpdate = true;\n } else { // @ts-ignore\n if (file != null && file !== files.get(rule.parentStyleSheet).file) {\n\n fileUpdate = true;\n }\n }\n\n if (fileUpdate) {\n\n try {\n\n // @ts-ignore\n console.error('analysing ' + files.get(rule.parentStyleSheet).file);\n // @ts-ignore\n styles.add('/* file: ' + files.get(rule.parentStyleSheet).file + ' */');\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify(e.message, null, 1));\n console.error(JSON.stringify(rule?.parentStyleSheet?.href, null, 1));\n }\n }\n\n file = (files.get(rule.parentStyleSheet)).file;\n css = rule.cssText;\n\n if (file !== 'inline') {\n\n // resolve url()\n css = css.replace(/url\\(([^)%\\s]*?)\\)/g, function (all, one) {\n\n one = one.trim();\n\n if (one.match(/^['\"]?data:/)) {\n\n return all;\n }\n\n one = one.replace(/^(['\"])([^\\1\\s]+)\\1/, '$2');\n\n // @ts-ignore\n return 'url(' + resolve(one, files.get(rule.parentStyleSheet).base) + ')';\n })\n }\n\n while (rule.parentRule) {\n\n /**\n *\n * @type {CSSMediaRule}\n */\n // @ts-ignore\n rule = rule.parentRule;\n\n // @ts-ignore\n if (rule.conditionText == 'print') {\n\n continue loop1;\n }\n\n // @ts-ignore\n if (!excluded.includes(rule.conditionText)) {\n\n // @ts-ignore\n css = '@' + rule.constructor.name.replace(/^CSS(.*?)Rule/, '$1').toLowerCase() + ' ' + rule.conditionText + ' {' + css + '}';\n }\n\n if (!rule.parentRule) {\n\n break;\n }\n }\n\n if (rule.parentStyleSheet) {\n\n let media = rule.parentStyleSheet.media.mediaText;\n\n if (media === 'print') {\n\n continue;\n }\n\n if (media !== '') {\n\n css = '@media ' + media + ' {' + css + '}';\n }\n }\n\n if (styles.has(css)) {\n\n styles.delete(css);\n }\n\n styles.add(css);\n }\n\n performance.measure('rules extraction', 'rulesExtraction');\n\n const usedFonts = new Map;\n\n if (options.fonts) {\n\n let j;\n let name;\n let value;\n let font: CSSFontFaceRule;\n let fontObject;\n let src;\n\n performance.mark('fontsExtraction');\n\n for (font of fonts) {\n\n if (font.style.getPropertyValue('font-family').split(/\\s*,\\s*/).some(token => {\n\n return fontFamilies.has(token.replace(/(['\"])([^\\1\\s]+)\\1/, '$2'));\n })) {\n\n src = font.style.getPropertyValue('src');\n\n if (!src) {\n\n continue;\n }\n\n fontObject = {\n 'fontFamily': font.style.getPropertyValue('font-family').replace(/(['\"])([^\\1\\s]+)\\1/, '$2'),\n src: src.replace(/(^|[,\\s*])local\\([^)]+\\)\\s*,?\\s*?/g, '').replace(/url\\(([^)%\\s]+)\\)([^,]*)(,?)\\s*/g, (all, one, two, three) => {\n\n one = one.replace(/(['\"])([^\\1\\s]+)\\1/, '$2');\n\n // @ts-ignore\n if (!files.has(font.parentStyleSheet)) {\n\n // @ts-ignore\n if (!font.parentStyleSheet.href) {\n\n return all;\n }\n\n // @ts-ignore\n files.set(font.parentStyleSheet, {\n\n // @ts-ignore\n base: font.parentStyleSheet.href.replace(/([^/]+)$/, ''),\n // @ts-ignore\n file: font.parentStyleSheet.href\n })\n }\n\n // @ts-ignore\n return 'url(' + resolve(one, files.get(font.parentStyleSheet).base) + ')' + three;\n }).trim(),\n properties: {}\n }\n\n j = font.style.length;\n\n while (j--) {\n\n name = font.style.item(j);\n value = font.style.getPropertyValue(name);\n\n name !== 'font-family' &&\n name !== 'src' &&\n value !== '' &&\n value !== undefined &&\n // @ts-ignore\n (fontObject.properties[name.replace(/([A-Z])/g, (all, name) => '-' + name.toLowerCase())] = value)\n }\n\n usedFonts.set(JSON.stringify(fontObject), fontObject)\n }\n }\n\n performance.measure('fonts extraction', 'fontsExtraction');\n }\n\n const stats = performance.getEntriesByType(\"measure\").filter(entry => ['filter stylesheets', 'node walking', 'rules extraction', 'fonts extraction'].includes(entry.name)).map(entry => {\n\n return {\n\n name: entry.name,\n\n duration: (entry.duration / 1000).toFixed(3) + 's'\n }\n });\n\n\n const result: CriticalResult = {\n styles: [...styles],\n fonts: [...usedFonts.values()],\n nodeCount,\n stats: {nodeCount, stats}\n };\n\n if (options.html) {\n\n if (!document.querySelector('base')) {\n\n const base: HTMLBaseElement = document.createElement('base');\n\n base.href = options.base ?? (location.protocol + '//' + location.host + location.pathname);\n document.head.insertBefore(base, document.querySelector('meta[charset]')?.nextElementSibling || document.head.firstChild)\n }\n\n if (!document.querySelector('meta[charset]')) {\n\n const meta = document.createElement('meta');\n meta.setAttribute('charset', 'utf-8');\n document.head.insertBefore(meta, document.head.firstChild)\n }\n\n // @ts-ignore\n Array.from(document.querySelectorAll('style,link[rel=stylesheet]')).forEach((node: HTMLLinkElement | HTMLStyleElement) => {\n\n document.body.append(node);\n\n if (node.tagName === 'LINK') {\n\n if (node.media === 'print') {\n\n return\n }\n\n if (node.hasAttribute('media')) {\n\n node.setAttribute('data-media', node.media);\n }\n\n node.media = 'print';\n node.dataset.async = '';\n }\n });\n\n const script: HTMLScriptElement = document.createElement('script');\n\n script.textContent = `\n window.addEventListener('DOMContentLoaded', () => Array.from(document.querySelectorAll('link[data-async]')).forEach(node => {\n\n if(!node.hasAttribute('data-media')) {\n node.removeAttribute('media');\n }\n else {\n node.media=node.dataset.media;\n node.removeAttribute('data-media')\n }\n \n node.removeAttribute('data-async');\n }))`;\n\n document.head.append(script);\n\n // add data-attribute\n const style: HTMLStyleElement = document.createElement('style');\n // @ts-ignore\n style.dataset.critical = true;\n style.textContent = [...usedFonts.values()].map((entry) => {\n\n return '@font-face {' + '\\n ' + Object.entries(entry).map(entry => {\n\n // @ts-ignore\n return typeof entry[1] == 'string' ? `${entry[0] + ': ' + entry[1]}` : Object.entries(entry[1]).map(entry => `${entry[0] + ': ' + entry[1]}`).join(';\\n ') + '\\n}'\n }).join(';\\n')\n }).join('\\n') +\n '\\n' + (result.styles).join('\\n');\n\n if (style.textContent.trim() !== '') {\n\n document.head.insertBefore(style, document.querySelector('base')?.nextElementSibling);\n }\n\n if ((result.fonts).length > 0) {\n\n const script = document.createElement('script');\n script.textContent = fontscript(result.fonts);\n document.head.append(script);\n }\n\n const doctype: DocumentType = document.doctype as DocumentType;\n\n result.html = `` + '\\n' + document.documentElement.outerHTML\n }\n\n return result;\n}","/**\n *\n * @param {string[]} content\n * @param {string} filename\n * @param {string} mimetype\n * @return {Promise}\n */\nexport async function download(content: Array, filename: string, mimetype: string = 'application/octet-stream; charset=utf-8'): Promise> {\n\n //\n const url: string = URL.createObjectURL(new Blob(content, {type: mimetype}));\n //\n const a: HTMLAnchorElement = document.createElement('a');\n document.body.append(a);\n a.style.display = 'none';\n a.download = filename;\n a.href = url;\n\n //\n a.dispatchEvent(new MouseEvent('click'));\n URL.revokeObjectURL(url);\n\n return content;\n}","import {extract} from \"./critical/extract\";\nimport {download} from \"./file/download\";\nimport {fontscript} from \"./critical/fontscript\";\nimport {CriticalExtractOptions, CriticalResult} from \"./@types\";\n\nasync function extractAndDownload(filename: string = 'critical.css', options: CriticalExtractOptions = {}): Promise {\n\n return extract(options).\n then(async (content : CriticalResult): Promise => download(content.styles, filename, 'text/css; charset=utf-8').\n then(async () => {\n\n if ((content.fonts).length > 0) {\n\n // @ts-ignore\n return download([fontscript(content.fonts)], filename.replace(/\\.css$/, '.js'), 'text/javascript; charset=utf-8');\n }\n }).\n then(() => content)\n );\n}\n\nexport {extract, fontscript, extractAndDownload as download}"],"names":[],"mappings":";;;IACgB,SAAA,OAAO,CAAC,IAAY,EAAE,IAAY,EAAA;IAE9C,IAAA,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;IAE3B,QAAA,OAAO,IAAI,CAAC;SACf;;QAGD,MAAM,OAAO,GAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QACrD,MAAM,OAAO,GAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE5C,IAAA,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ;IACpC,QAAA,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI;IAC5B,QAAA,OAA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AAE,yBAAyB,CAAC;YACrI,IAAI,CAAC,YAAW;YAEZ,IAAe,OAAO,CAAC,KAAM,CAAC,MAAM,GAAG,CAAC,EAAE;;gBAGtC,OAAO,QAAQ,CAAC,CAAC,UAAU,CAAW,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,gCAAgC,CAAC,CAAC;aAC/H;IACT,KAAC,CAAC;IACF,QAAA,IAAI,CAAC,MAAM,OAAO,CAAC,CACtB,CAAC;IACN;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"browser-umd.js","sources":["../src/file/download.ts","../src/file/path.ts","../src/critical/fontscript.ts","../src/critical/extract.ts","../src/browser.ts"],"sourcesContent":["/**\n *\n * @param {string[]} content\n * @param {string} filename\n * @param {string} mimetype\n * @return {Promise}\n */\nexport async function download(content: Array, filename: string, mimetype: string = 'application/octet-stream; charset=utf-8'): Promise> {\n\n //\n const url: string = URL.createObjectURL(new Blob(content, {type: mimetype}));\n //\n const a: HTMLAnchorElement = document.createElement('a');\n document.body.append(a);\n a.style.display = 'none';\n a.download = filename;\n a.href = url;\n\n //\n a.dispatchEvent(new MouseEvent('click'));\n URL.revokeObjectURL(url);\n\n return content;\n}","\nexport function resolve(path: string, from: string): string {\n\n if (path.match(/^['\"]?data:/)) {\n\n return path;\n }\n\n // @ts-ignore\n const baseURL: URL = new URL(from, window.location);\n const pathURL: URL = new URL(path, baseURL);\n\n if (baseURL.protocol != pathURL.protocol ||\n baseURL.host != pathURL.host ||\n pathURL.host != window.location.host ||\n baseURL.port != pathURL.port ||\n pathURL.port != window.location.port ||\n baseURL.port != pathURL.port ||\n pathURL.protocol != window.location.protocol\n ) {\n\n return pathURL.toString();\n }\n\n return pathURL.pathname + pathURL.search + pathURL.hash;\n}","import type {FontObject} from \"../@types\";\n\nexport function fontscript(fonts: FontObject[]): string {\n\n return '/* font preloader script: ' + fonts.length + ' */\\n\"fonts\" in document && ' + JSON.stringify([...fonts], null, 1) + '.forEach(font => new FontFace(font.fontFamily, font.src, font.properties).load().then(font => document.fonts.add(font)))'\n}","import {resolve} from \"../file\";\nimport {fontscript} from \"./fontscript\";\nimport type {\n CriticalExtractOptions,\n CriticalResult,\n FileMapObject,\n FontObject,\n MatchCSSStyleSheet,\n RuleList\n} from \"../@types\";\n\nexport async function extract(options: CriticalExtractOptions = {}) {\n\n const document: Document = window.document;\n const location: Location = window.location;\n const styles: Set = new Set;\n const excluded = ['all', 'print', ''];\n const allStylesheets: MatchCSSStyleSheet[] = [];\n\n // Get a list of all the elements in the view.\n const height = window.innerHeight;\n const walker = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, {acceptNode: () => NodeFilter.SHOW_ELEMENT});\n\n const fonts: Set = new Set;\n const fontFamilies: Set = new Set;\n const files: Map = new Map;\n const weakMap: WeakMap = new WeakMap;\n const nodeMap: Set = new Set;\n let nodeCount: number = 0;\n let k: number;\n let rule: CSSMediaRule | CSSStyleRule;\n let rules;\n\n performance.mark('filterStylesheets');\n\n for (k = 0; k < document.styleSheets.length; k++) {\n\n // @ts-ignore\n rule = document.styleSheets[k];\n\n if (rule.media.mediaText === 'print' || (rule.media.mediaText !== '' && !window.matchMedia(rule.media.mediaText).matches)) {\n\n continue;\n }\n\n try {\n\n\n // @ts-ignore\n rules = (rule).cssRules ?? (rule).rules;\n\n for (let l = 0; l < rules.length; l++) {\n\n allStylesheets.push({rule: rules[l], match: false})\n }\n\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify({'message': e.message, stylesheet: rule.href}, null, 1));\n }\n }\n\n performance.measure('filter stylesheets', 'filterStylesheets');\n\n if (allStylesheets.length === 0) {\n\n return {styles: [], fonts: [], stats: {}};\n }\n\n let node;\n let rect;\n let allStylesLength = allStylesheets.length;\n\n performance.mark('nodeWalking');\n\n while ((node = walker.nextNode())) {\n\n if (options && options.signal && options.signal.aborted) {\n\n return Promise.reject('Aborted');\n }\n\n if (['SCRIPT', 'LINK', 'HEAD', 'META', 'TITLE', 'NOSCRIPT'].includes(node.tagName)) {\n\n continue;\n }\n\n nodeCount++;\n rect = node.getBoundingClientRect();\n\n if (rect.top < height) {\n\n nodeMap.add(node);\n }\n }\n\n for (k = 0; k < allStylesLength; k++) {\n\n if (allStylesheets[k].match || weakMap.has(allStylesheets[k].rule)) {\n\n continue;\n }\n\n weakMap.set(allStylesheets[k].rule, 1);\n\n if (allStylesheets[k].rule instanceof CSSStyleRule) {\n\n // @ts-ignore\n let selector = allStylesheets[k].rule.selectorText;\n let match;\n\n // detect pseudo selectors\n if (selector.match(/(^|,|\\s)::?((before)|(after))/)) {\n\n match = true\n } else {\n\n if (selector.match(/::?((before)|(after))/)) {\n\n selector = selector.replace(/::?((before)|(after))\\s*((,)|$)/g, '$5');\n }\n\n try {\n\n match = nodeMap.has(document.querySelector(selector));\n } catch (e) {\n\n // @ts-ignore\n match = nodeMap.has(document.querySelector(allStylesheets[k].rule.selectorText));\n }\n }\n\n if (match) {\n\n allStylesheets[k].match = true;\n\n // @ts-ignore\n if (allStylesheets[k].rule.style.getPropertyValue('font-family')) {\n\n // @ts-ignore\n allStylesheets[k].rule.style.getPropertyValue('font-family').split(/\\s*,\\s*/).forEach(fontFamily => fontFamily !== 'inherit' && fontFamilies.add(fontFamily.replace(/(['\"])([^\\1\\s]+)\\1/, '$2')));\n }\n }\n\n } else if (allStylesheets[k].rule instanceof CSSMediaRule || allStylesheets[k].rule instanceof CSSImportRule || allStylesheets[k].rule instanceof CSSConditionRule) {\n\n // @ts-ignore\n if ((allStylesheets[k].rule instanceof CSSMediaRule || allStylesheets[k].rule instanceof CSSImportRule) && (allStylesheets[k].rule.media.mediaText === 'print' || (allStylesheets[k].rule.media.mediaText !== '' && !window.matchMedia(allStylesheets[k].rule.media.mediaText).matches))) {\n continue;\n }\n\n try {\n\n const rule = allStylesheets[k].rule;\n const rules = [];\n // @ts-ignore\n const sheet = rule instanceof CSSImportRule ? rule.styleSheet.cssRules || rule.styleSheet.rules : rule.cssRules || rule.rules;\n\n for (let l = 0; l < sheet.length; l++) {\n\n if (!weakMap.has(sheet[l])) {\n\n rules.push({rule: sheet[l], match: false})\n }\n }\n\n if (rules.length > 0) {\n\n // @ts-ignore\n allStylesheets.splice.apply(allStylesheets, [k + 1, 0].concat(rules))\n allStylesLength = allStylesheets.length\n }\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify({'message': e.message, stylesheet: rule.href}, null, 1));\n }\n } else if (allStylesheets[k].rule instanceof CSSFontFaceRule) {\n\n // @ts-ignore\n if (allStylesheets[k].rule.style.getPropertyValue('font-family') && allStylesheets[k].rule.style.getPropertyValue('src')) {\n\n // @ts-ignore\n fonts.add(allStylesheets[k].rule);\n }\n }\n }\n\n performance.measure('node walking', 'nodeWalking');\n\n let css;\n let file = '';\n let inlineCount = -1;\n\n performance.mark('rulesExtraction');\n\n loop1:\n for (let k = 0; k < allStylesLength; k++) {\n\n if (!allStylesheets[k].match) {\n\n continue;\n }\n\n // @ts-ignore\n rule = allStylesheets[k].rule;\n let fileUpdate = false;\n\n // @ts-ignore\n if (!files.has(rule.parentStyleSheet)) {\n\n //\n // @ts-ignore\n files.set(rule.parentStyleSheet, {\n\n // @ts-ignore\n base: (rule.parentStyleSheet.href && rule.parentStyleSheet.href.replace(/[?#].*/, '') || location.pathname).replace(/([^/]+)$/, ''),\n // @ts-ignore\n file: rule.parentStyleSheet.href || `inline style #${++inlineCount}`\n });\n\n fileUpdate = true;\n } else { // @ts-ignore\n if (file != null && file !== files.get(rule.parentStyleSheet).file) {\n\n fileUpdate = true;\n }\n }\n\n if (fileUpdate) {\n\n try {\n\n // @ts-ignore\n console.error('analysing ' + files.get(rule.parentStyleSheet).file);\n // @ts-ignore\n styles.add('/* file: ' + files.get(rule.parentStyleSheet).file + ' */');\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify(e.message, null, 1));\n console.error(JSON.stringify(rule?.parentStyleSheet?.href, null, 1));\n }\n }\n\n file = (files.get(rule.parentStyleSheet)).file;\n css = rule.cssText;\n\n if (file !== 'inline') {\n\n // resolve url()\n css = css.replace(/url\\(([^)%\\s]*?)\\)/g, function (all, one) {\n\n one = one.trim();\n\n if (one.match(/^['\"]?data:/)) {\n\n return all;\n }\n\n one = one.replace(/^(['\"])([^\\1\\s]+)\\1/, '$2');\n\n // @ts-ignore\n return 'url(' + resolve(one, files.get(rule.parentStyleSheet).base) + ')';\n })\n }\n\n while (rule.parentRule) {\n\n /**\n *\n * @type {CSSMediaRule}\n */\n // @ts-ignore\n rule = rule.parentRule;\n\n // @ts-ignore\n if (rule.conditionText == 'print') {\n\n continue loop1;\n }\n\n // @ts-ignore\n if (!excluded.includes(rule.conditionText)) {\n\n // @ts-ignore\n css = '@' + rule.constructor.name.replace(/^CSS(.*?)Rule/, '$1').toLowerCase() + ' ' + rule.conditionText + ' {' + css + '}';\n }\n\n if (!rule.parentRule) {\n\n break;\n }\n }\n\n if (rule.parentStyleSheet) {\n\n let media = rule.parentStyleSheet.media.mediaText;\n\n if (media === 'print') {\n\n continue;\n }\n\n if (media !== '') {\n\n css = '@media ' + media + ' {' + css + '}';\n }\n }\n\n if (styles.has(css)) {\n\n styles.delete(css);\n }\n\n styles.add(css);\n }\n\n performance.measure('rules extraction', 'rulesExtraction');\n\n const usedFonts = new Map;\n\n if (options.fonts) {\n\n let j;\n let name;\n let value;\n let font: CSSFontFaceRule;\n let fontObject;\n let src;\n\n performance.mark('fontsExtraction');\n\n for (font of fonts) {\n\n if (font.style.getPropertyValue('font-family').split(/\\s*,\\s*/).some(token => {\n\n return fontFamilies.has(token.replace(/(['\"])([^\\1\\s]+)\\1/, '$2'));\n })) {\n\n src = font.style.getPropertyValue('src');\n\n if (!src) {\n\n continue;\n }\n\n fontObject = {\n 'fontFamily': font.style.getPropertyValue('font-family').replace(/(['\"])([^\\1\\s]+)\\1/, '$2'),\n src: src.replace(/(^|[,\\s*])local\\([^)]+\\)\\s*,?\\s*?/g, '').replace(/url\\(([^)%\\s]+)\\)([^,]*)(,?)\\s*/g, (all, one, two, three) => {\n\n one = one.replace(/(['\"])([^\\1\\s]+)\\1/, '$2');\n\n // @ts-ignore\n if (!files.has(font.parentStyleSheet)) {\n\n // @ts-ignore\n if (!font.parentStyleSheet.href) {\n\n return all;\n }\n\n // @ts-ignore\n files.set(font.parentStyleSheet, {\n\n // @ts-ignore\n base: font.parentStyleSheet.href.replace(/([^/]+)$/, ''),\n // @ts-ignore\n file: font.parentStyleSheet.href\n })\n }\n\n // @ts-ignore\n return 'url(' + resolve(one, files.get(font.parentStyleSheet).base) + ')' + three;\n }).trim(),\n properties: {}\n }\n\n j = font.style.length;\n\n while (j--) {\n\n name = font.style.item(j);\n value = font.style.getPropertyValue(name);\n\n name !== 'font-family' &&\n name !== 'src' &&\n value !== '' &&\n value !== undefined &&\n // @ts-ignore\n (fontObject.properties[name.replace(/([A-Z])/g, (all, name) => '-' + name.toLowerCase())] = value)\n }\n\n usedFonts.set(JSON.stringify(fontObject), fontObject)\n }\n }\n\n performance.measure('fonts extraction', 'fontsExtraction');\n }\n\n const stats = performance.getEntriesByType(\"measure\").filter(entry => ['filter stylesheets', 'node walking', 'rules extraction', 'fonts extraction'].includes(entry.name)).map(entry => {\n\n return {\n\n name: entry.name,\n\n duration: (entry.duration / 1000).toFixed(3) + 's'\n }\n });\n\n\n const result: CriticalResult = {\n styles: [...styles],\n fonts: [...usedFonts.values()],\n nodeCount,\n stats: {nodeCount, stats}\n };\n\n if (options.html) {\n\n if (!document.querySelector('base')) {\n\n const base: HTMLBaseElement = document.createElement('base');\n\n base.href = options.base ?? (location.protocol + '//' + location.host + location.pathname);\n document.head.insertBefore(base, document.querySelector('meta[charset]')?.nextElementSibling || document.head.firstChild)\n }\n\n if (!document.querySelector('meta[charset]')) {\n\n const meta = document.createElement('meta');\n meta.setAttribute('charset', 'utf-8');\n document.head.insertBefore(meta, document.head.firstChild)\n }\n\n // @ts-ignore\n Array.from(document.querySelectorAll('style,link[rel=stylesheet]')).forEach((node: HTMLLinkElement | HTMLStyleElement) => {\n\n document.body.append(node);\n\n if (node.tagName === 'LINK') {\n\n if (node.media === 'print') {\n\n return\n }\n\n if (node.hasAttribute('media')) {\n\n node.setAttribute('data-media', node.media);\n }\n\n node.media = 'print';\n node.dataset.async = '';\n }\n });\n\n const script: HTMLScriptElement = document.createElement('script');\n\n script.textContent = `\n window.addEventListener('DOMContentLoaded', () => Array.from(document.querySelectorAll('link[data-async]')).forEach(node => {\n\n if(!node.hasAttribute('data-media')) {\n node.removeAttribute('media');\n }\n else {\n node.media=node.dataset.media;\n node.removeAttribute('data-media')\n }\n \n node.removeAttribute('data-async');\n }))`;\n\n document.head.append(script);\n\n // add data-attribute\n const style: HTMLStyleElement = document.createElement('style');\n // @ts-ignore\n style.dataset.critical = true;\n style.textContent = [...usedFonts.values()].map((entry) => {\n\n return '@font-face {' + '\\n ' + Object.entries(entry).map(entry => {\n\n // @ts-ignore\n return typeof entry[1] == 'string' ? `${entry[0] + ': ' + entry[1]}` : Object.entries(entry[1]).map(entry => `${entry[0] + ': ' + entry[1]}`).join(';\\n ') + '\\n}'\n }).join(';\\n')\n }).join('\\n') +\n '\\n' + (result.styles).join('\\n');\n\n if (style.textContent.trim() !== '') {\n\n document.head.insertBefore(style, document.querySelector('base')?.nextElementSibling);\n }\n\n if ((result.fonts).length > 0) {\n\n const script = document.createElement('script');\n script.textContent = fontscript(result.fonts);\n document.head.append(script);\n }\n\n const doctype: DocumentType = document.doctype as DocumentType;\n\n result.html = `` + '\\n' + document.documentElement.outerHTML\n }\n\n return result;\n}","import {extract} from \"./critical/extract\";\nimport {download} from \"./file/download\";\nimport {fontscript} from \"./critical/fontscript\";\nimport {CriticalExtractOptions, CriticalResult} from \"./@types\";\n\nasync function extractAndDownload(filename: string = 'critical.css', options: CriticalExtractOptions = {}): Promise {\n\n return extract(options).\n then(async (content : CriticalResult): Promise => download(content.styles, filename, 'text/css; charset=utf-8').\n then(async () => {\n\n if ((content.fonts).length > 0) {\n\n // @ts-ignore\n return download([fontscript(content.fonts)], filename.replace(/\\.css$/, '.js'), 'text/javascript; charset=utf-8');\n }\n }).\n then(() => content)\n );\n}\n\nexport {extract, fontscript, extractAndDownload as download}"],"names":[],"mappings":";;;IAAA;;;;;;IAMG;IACI,eAAe,QAAQ,CAAC,OAAsB,EAAE,QAAgB,EAAE,QAAA,GAAmB,yCAAyC,EAAA;;IAGjI,IAAA,MAAM,GAAG,GAAW,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;;QAE7E,MAAM,CAAC,GAAsB,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACzD,IAAA,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,IAAA,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACzB,IAAA,CAAC,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACtB,IAAA,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC;;QAGb,CAAC,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;IACzC,IAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAEzB,IAAA,OAAO,OAAO,CAAC;IACnB;;ICtBgB,SAAA,OAAO,CAAC,IAAY,EAAE,IAAY,EAAA;IAE9C,IAAA,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;IAE3B,QAAA,OAAO,IAAI,CAAC;SACf;;QAGD,MAAM,OAAO,GAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QACpD,MAAM,OAAO,GAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE5C,IAAA,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ;IACpC,QAA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E,CAAA;IACnC,eAAC,OAAO,CAAC,QAAQ,GAAG,CAAA,SAAA,EAAY,OAAO,CAAC,QAAQ,CAAG,CAAA,CAAA,GAAG,EAAE,CAAC;mBACxD,OAAO,CAAC,QAAQ;IACf,kBAAE,CAAC,OAAO,CAAC,QAAQ,GAAG,CAAA,CAAE,GAAG,SAAS,IAAI,KAAK,OAAO,CAAC,QAAQ,CAAG,CAAA,CAAA;sBAC9D,EAAE,CAAC;kBACP,CAAG,CAAA,CAAA,GAAG,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAA;SACxD;IAED,IAAA,OAAO,MAAM,CAAC;IAClB;;IC5fA,eAAe,kBAAkB,CAAC,WAAmB,cAAc,EAAE,UAAkC,EAAE,EAAA;QAErG,OAAO,OAAO,CAAC,OAAO,CAAC;IACnB,QAAA,IAAI,CAAC,OAAO,OAAwB,KAA8B,QAAQ,CAAW,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,yBAAyB,CAAC;YACrI,IAAI,CAAC,YAAW;YAEZ,IAAe,OAAO,CAAC,KAAM,CAAC,MAAM,GAAG,CAAC,EAAE;;gBAGtC,OAAO,QAAQ,CAAC,CAAC,UAAU,CAAW,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,gCAAgC,CAAC,CAAC;aAC/H;IACT,KAAC,CAAC;IACF,QAAA,IAAI,CAAC,MAAM,OAAO,CAAC,CACtB,CAAC;IACN;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/browser.js b/dist/browser.js index 6593547..185e65b 100644 --- a/dist/browser.js +++ b/dist/browser.js @@ -1,9 +1,31 @@ +/** + * + * @param {string[]} content + * @param {string} filename + * @param {string} mimetype + * @return {Promise} + */ +async function download(content, filename, mimetype = 'application/octet-stream; charset=utf-8') { + // + const url = URL.createObjectURL(new Blob(content, { type: mimetype })); + // + const a = document.createElement('a'); + document.body.append(a); + a.style.display = 'none'; + a.download = filename; + a.href = url; + // + a.dispatchEvent(new MouseEvent('click')); + URL.revokeObjectURL(url); + return content; +} + function resolve(path, from) { if (path.match(/^['"]?data:/)) { return path; } // @ts-ignore - const baseURL = new URL(from, window?.location); + const baseURL = new URL(from, window.location); const pathURL = new URL(path, baseURL); if (baseURL.protocol != pathURL.protocol || baseURL.host != pathURL.host || @@ -376,28 +398,6 @@ async function extract(options = {}) { return result; } -/** - * - * @param {string[]} content - * @param {string} filename - * @param {string} mimetype - * @return {Promise} - */ -async function download(content, filename, mimetype = 'application/octet-stream; charset=utf-8') { - // - const url = URL.createObjectURL(new Blob(content, { type: mimetype })); - // - const a = document.createElement('a'); - document.body.append(a); - a.style.display = 'none'; - a.download = filename; - a.href = url; - // - a.dispatchEvent(new MouseEvent('click')); - URL.revokeObjectURL(url); - return content; -} - async function extractAndDownload(filename = 'critical.css', options = {}) { return extract(options). then(async (content) => download(content.styles, filename, 'text/css; charset=utf-8'). diff --git a/dist/browser.js.map b/dist/browser.js.map index a356a40..36986f6 100644 --- a/dist/browser.js.map +++ b/dist/browser.js.map @@ -1 +1 @@ -{"version":3,"file":"browser.js","sources":["../src/file/path.ts","../src/critical/fontscript.ts","../src/critical/extract.ts","../src/file/download.ts","../src/browser.ts"],"sourcesContent":["\nexport function resolve(path: string, from: string): string {\n\n if (path.match(/^['\"]?data:/)) {\n\n return path;\n }\n\n // @ts-ignore\n const baseURL: URL = new URL(from, window?.location);\n const pathURL: URL = new URL(path, baseURL);\n\n if (baseURL.protocol != pathURL.protocol ||\n baseURL.host != pathURL.host ||\n pathURL.host != window.location.host ||\n baseURL.port != pathURL.port ||\n pathURL.port != window.location.port ||\n baseURL.port != pathURL.port ||\n pathURL.protocol != window.location.protocol\n ) {\n\n return pathURL.toString();\n }\n\n return pathURL.pathname + pathURL.search + pathURL.hash;\n}","import {FontObject} from \"../@types\";\n\nexport function fontscript(fonts: FontObject[]): string {\n\n return '/* font preloader script: ' + fonts.length + ' */\\n\"fonts\" in document && ' + JSON.stringify([...fonts], null, 1) + '.forEach(font => new FontFace(font.fontFamily, font.src, font.properties).load().then(font => document.fonts.add(font)))'\n}","import {resolve} from \"../file/path\";\nimport {fontscript} from \"./fontscript\";\nimport {\n CriticalExtractOptions,\n CriticalResult,\n FileMapObject,\n FontObject,\n MatchCSSStyleSheet,\n RuleList\n} from \"../@types\";\n\nexport async function extract(options: CriticalExtractOptions = {}) {\n\n const document: Document = window.document;\n const location: Location = window.location;\n const styles: Set = new Set;\n const excluded = ['all', 'print', ''];\n const allStylesheets: MatchCSSStyleSheet[] = [];\n\n // Get a list of all the elements in the view.\n const height = window.innerHeight;\n const walker = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, {acceptNode: () => NodeFilter.SHOW_ELEMENT});\n\n const fonts: Set = new Set;\n const fontFamilies: Set = new Set;\n const files: Map = new Map;\n const weakMap: WeakMap = new WeakMap;\n const nodeMap: Set = new Set;\n let nodeCount: number = 0;\n let k: number;\n let rule: CSSMediaRule | CSSStyleRule;\n let rules;\n\n performance.mark('filterStylesheets');\n\n for (k = 0; k < document.styleSheets.length; k++) {\n\n // @ts-ignore\n rule = document.styleSheets[k];\n\n if (rule.media.mediaText === 'print' || (rule.media.mediaText !== '' && !window.matchMedia(rule.media.mediaText).matches)) {\n\n continue;\n }\n\n try {\n\n\n // @ts-ignore\n rules = (rule).cssRules ?? (rule).rules;\n\n for (let l = 0; l < rules.length; l++) {\n\n allStylesheets.push({rule: rules[l], match: false})\n }\n\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify({'message': e.message, stylesheet: rule.href}, null, 1));\n }\n }\n\n performance.measure('filter stylesheets', 'filterStylesheets');\n\n if (allStylesheets.length === 0) {\n\n return {styles: [], fonts: [], stats: {}};\n }\n\n let node;\n let rect;\n let allStylesLength = allStylesheets.length;\n\n performance.mark('nodeWalking');\n\n while ((node = walker.nextNode())) {\n\n if (options && options.signal && options.signal.aborted) {\n\n return Promise.reject('Aborted');\n }\n\n if (['SCRIPT', 'LINK', 'HEAD', 'META', 'TITLE', 'NOSCRIPT'].includes(node.tagName)) {\n\n continue;\n }\n\n nodeCount++;\n rect = node.getBoundingClientRect();\n\n if (rect.top < height) {\n\n nodeMap.add(node);\n }\n }\n\n for (k = 0; k < allStylesLength; k++) {\n\n if (allStylesheets[k].match || weakMap.has(allStylesheets[k].rule)) {\n\n continue;\n }\n\n weakMap.set(allStylesheets[k].rule, 1);\n\n if (allStylesheets[k].rule instanceof CSSStyleRule) {\n\n // @ts-ignore\n let selector = allStylesheets[k].rule.selectorText;\n let match;\n\n // detect pseudo selectors\n if (selector.match(/(^|,|\\s)::?((before)|(after))/)) {\n\n match = true\n } else {\n\n if (selector.match(/::?((before)|(after))/)) {\n\n selector = selector.replace(/::?((before)|(after))\\s*((,)|$)/g, '$5');\n }\n\n try {\n\n match = nodeMap.has(document.querySelector(selector));\n } catch (e) {\n\n // @ts-ignore\n match = nodeMap.has(document.querySelector(allStylesheets[k].rule.selectorText));\n }\n }\n\n if (match) {\n\n allStylesheets[k].match = true;\n\n // @ts-ignore\n if (allStylesheets[k].rule.style.getPropertyValue('font-family')) {\n\n // @ts-ignore\n allStylesheets[k].rule.style.getPropertyValue('font-family').split(/\\s*,\\s*/).forEach(fontFamily => fontFamily !== 'inherit' && fontFamilies.add(fontFamily.replace(/(['\"])([^\\1\\s]+)\\1/, '$2')));\n }\n }\n\n } else if (allStylesheets[k].rule instanceof CSSMediaRule || allStylesheets[k].rule instanceof CSSImportRule || allStylesheets[k].rule instanceof CSSConditionRule) {\n\n // @ts-ignore\n if ((allStylesheets[k].rule instanceof CSSMediaRule || allStylesheets[k].rule instanceof CSSImportRule) && (allStylesheets[k].rule.media.mediaText === 'print' || (allStylesheets[k].rule.media.mediaText !== '' && !window.matchMedia(allStylesheets[k].rule.media.mediaText).matches))) {\n continue;\n }\n\n try {\n\n const rule = allStylesheets[k].rule;\n const rules = [];\n // @ts-ignore\n const sheet = rule instanceof CSSImportRule ? rule.styleSheet.cssRules || rule.styleSheet.rules : rule.cssRules || rule.rules;\n\n for (let l = 0; l < sheet.length; l++) {\n\n if (!weakMap.has(sheet[l])) {\n\n rules.push({rule: sheet[l], match: false})\n }\n }\n\n if (rules.length > 0) {\n\n // @ts-ignore\n allStylesheets.splice.apply(allStylesheets, [k + 1, 0].concat(rules))\n allStylesLength = allStylesheets.length\n }\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify({'message': e.message, stylesheet: rule.href}, null, 1));\n }\n } else if (allStylesheets[k].rule instanceof CSSFontFaceRule) {\n\n // @ts-ignore\n if (allStylesheets[k].rule.style.getPropertyValue('font-family') && allStylesheets[k].rule.style.getPropertyValue('src')) {\n\n // @ts-ignore\n fonts.add(allStylesheets[k].rule);\n }\n }\n }\n\n performance.measure('node walking', 'nodeWalking');\n\n let css;\n let file = '';\n let inlineCount = -1;\n\n performance.mark('rulesExtraction');\n\n loop1:\n for (let k = 0; k < allStylesLength; k++) {\n\n if (!allStylesheets[k].match) {\n\n continue;\n }\n\n // @ts-ignore\n rule = allStylesheets[k].rule;\n let fileUpdate = false;\n\n // @ts-ignore\n if (!files.has(rule.parentStyleSheet)) {\n\n //\n // @ts-ignore\n files.set(rule.parentStyleSheet, {\n\n // @ts-ignore\n base: (rule.parentStyleSheet.href && rule.parentStyleSheet.href.replace(/[?#].*/, '') || location.pathname).replace(/([^/]+)$/, ''),\n // @ts-ignore\n file: rule.parentStyleSheet.href || `inline style #${++inlineCount}`\n });\n\n fileUpdate = true;\n } else { // @ts-ignore\n if (file != null && file !== files.get(rule.parentStyleSheet).file) {\n\n fileUpdate = true;\n }\n }\n\n if (fileUpdate) {\n\n try {\n\n // @ts-ignore\n console.error('analysing ' + files.get(rule.parentStyleSheet).file);\n // @ts-ignore\n styles.add('/* file: ' + files.get(rule.parentStyleSheet).file + ' */');\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify(e.message, null, 1));\n console.error(JSON.stringify(rule?.parentStyleSheet?.href, null, 1));\n }\n }\n\n file = (files.get(rule.parentStyleSheet)).file;\n css = rule.cssText;\n\n if (file !== 'inline') {\n\n // resolve url()\n css = css.replace(/url\\(([^)%\\s]*?)\\)/g, function (all, one) {\n\n one = one.trim();\n\n if (one.match(/^['\"]?data:/)) {\n\n return all;\n }\n\n one = one.replace(/^(['\"])([^\\1\\s]+)\\1/, '$2');\n\n // @ts-ignore\n return 'url(' + resolve(one, files.get(rule.parentStyleSheet).base) + ')';\n })\n }\n\n while (rule.parentRule) {\n\n /**\n *\n * @type {CSSMediaRule}\n */\n // @ts-ignore\n rule = rule.parentRule;\n\n // @ts-ignore\n if (rule.conditionText == 'print') {\n\n continue loop1;\n }\n\n // @ts-ignore\n if (!excluded.includes(rule.conditionText)) {\n\n // @ts-ignore\n css = '@' + rule.constructor.name.replace(/^CSS(.*?)Rule/, '$1').toLowerCase() + ' ' + rule.conditionText + ' {' + css + '}';\n }\n\n if (!rule.parentRule) {\n\n break;\n }\n }\n\n if (rule.parentStyleSheet) {\n\n let media = rule.parentStyleSheet.media.mediaText;\n\n if (media === 'print') {\n\n continue;\n }\n\n if (media !== '') {\n\n css = '@media ' + media + ' {' + css + '}';\n }\n }\n\n if (styles.has(css)) {\n\n styles.delete(css);\n }\n\n styles.add(css);\n }\n\n performance.measure('rules extraction', 'rulesExtraction');\n\n const usedFonts = new Map;\n\n if (options.fonts) {\n\n let j;\n let name;\n let value;\n let font: CSSFontFaceRule;\n let fontObject;\n let src;\n\n performance.mark('fontsExtraction');\n\n for (font of fonts) {\n\n if (font.style.getPropertyValue('font-family').split(/\\s*,\\s*/).some(token => {\n\n return fontFamilies.has(token.replace(/(['\"])([^\\1\\s]+)\\1/, '$2'));\n })) {\n\n src = font.style.getPropertyValue('src');\n\n if (!src) {\n\n continue;\n }\n\n fontObject = {\n 'fontFamily': font.style.getPropertyValue('font-family').replace(/(['\"])([^\\1\\s]+)\\1/, '$2'),\n src: src.replace(/(^|[,\\s*])local\\([^)]+\\)\\s*,?\\s*?/g, '').replace(/url\\(([^)%\\s]+)\\)([^,]*)(,?)\\s*/g, (all, one, two, three) => {\n\n one = one.replace(/(['\"])([^\\1\\s]+)\\1/, '$2');\n\n // @ts-ignore\n if (!files.has(font.parentStyleSheet)) {\n\n // @ts-ignore\n if (!font.parentStyleSheet.href) {\n\n return all;\n }\n\n // @ts-ignore\n files.set(font.parentStyleSheet, {\n\n // @ts-ignore\n base: font.parentStyleSheet.href.replace(/([^/]+)$/, ''),\n // @ts-ignore\n file: font.parentStyleSheet.href\n })\n }\n\n // @ts-ignore\n return 'url(' + resolve(one, files.get(font.parentStyleSheet).base) + ')' + three;\n }).trim(),\n properties: {}\n }\n\n j = font.style.length;\n\n while (j--) {\n\n name = font.style.item(j);\n value = font.style.getPropertyValue(name);\n\n name !== 'font-family' &&\n name !== 'src' &&\n value !== '' &&\n value !== undefined &&\n // @ts-ignore\n (fontObject.properties[name.replace(/([A-Z])/g, (all, name) => '-' + name.toLowerCase())] = value)\n }\n\n usedFonts.set(JSON.stringify(fontObject), fontObject)\n }\n }\n\n performance.measure('fonts extraction', 'fontsExtraction');\n }\n\n const stats = performance.getEntriesByType(\"measure\").filter(entry => ['filter stylesheets', 'node walking', 'rules extraction', 'fonts extraction'].includes(entry.name)).map(entry => {\n\n return {\n\n name: entry.name,\n\n duration: (entry.duration / 1000).toFixed(3) + 's'\n }\n });\n\n\n const result: CriticalResult = {\n styles: [...styles],\n fonts: [...usedFonts.values()],\n nodeCount,\n stats: {nodeCount, stats}\n };\n\n if (options.html) {\n\n if (!document.querySelector('base')) {\n\n const base: HTMLBaseElement = document.createElement('base');\n\n base.href = options.base ?? (location.protocol + '//' + location.host + location.pathname);\n document.head.insertBefore(base, document.querySelector('meta[charset]')?.nextElementSibling || document.head.firstChild)\n }\n\n if (!document.querySelector('meta[charset]')) {\n\n const meta = document.createElement('meta');\n meta.setAttribute('charset', 'utf-8');\n document.head.insertBefore(meta, document.head.firstChild)\n }\n\n // @ts-ignore\n Array.from(document.querySelectorAll('style,link[rel=stylesheet]')).forEach((node: HTMLLinkElement | HTMLStyleElement) => {\n\n document.body.append(node);\n\n if (node.tagName === 'LINK') {\n\n if (node.media === 'print') {\n\n return\n }\n\n if (node.hasAttribute('media')) {\n\n node.setAttribute('data-media', node.media);\n }\n\n node.media = 'print';\n node.dataset.async = '';\n }\n });\n\n const script: HTMLScriptElement = document.createElement('script');\n\n script.textContent = `\n window.addEventListener('DOMContentLoaded', () => Array.from(document.querySelectorAll('link[data-async]')).forEach(node => {\n\n if(!node.hasAttribute('data-media')) {\n node.removeAttribute('media');\n }\n else {\n node.media=node.dataset.media;\n node.removeAttribute('data-media')\n }\n \n node.removeAttribute('data-async');\n }))`;\n\n document.head.append(script);\n\n // add data-attribute\n const style: HTMLStyleElement = document.createElement('style');\n // @ts-ignore\n style.dataset.critical = true;\n style.textContent = [...usedFonts.values()].map((entry) => {\n\n return '@font-face {' + '\\n ' + Object.entries(entry).map(entry => {\n\n // @ts-ignore\n return typeof entry[1] == 'string' ? `${entry[0] + ': ' + entry[1]}` : Object.entries(entry[1]).map(entry => `${entry[0] + ': ' + entry[1]}`).join(';\\n ') + '\\n}'\n }).join(';\\n')\n }).join('\\n') +\n '\\n' + (result.styles).join('\\n');\n\n if (style.textContent.trim() !== '') {\n\n document.head.insertBefore(style, document.querySelector('base')?.nextElementSibling);\n }\n\n if ((result.fonts).length > 0) {\n\n const script = document.createElement('script');\n script.textContent = fontscript(result.fonts);\n document.head.append(script);\n }\n\n const doctype: DocumentType = document.doctype as DocumentType;\n\n result.html = `` + '\\n' + document.documentElement.outerHTML\n }\n\n return result;\n}","/**\n *\n * @param {string[]} content\n * @param {string} filename\n * @param {string} mimetype\n * @return {Promise}\n */\nexport async function download(content: Array, filename: string, mimetype: string = 'application/octet-stream; charset=utf-8'): Promise> {\n\n //\n const url: string = URL.createObjectURL(new Blob(content, {type: mimetype}));\n //\n const a: HTMLAnchorElement = document.createElement('a');\n document.body.append(a);\n a.style.display = 'none';\n a.download = filename;\n a.href = url;\n\n //\n a.dispatchEvent(new MouseEvent('click'));\n URL.revokeObjectURL(url);\n\n return content;\n}","import {extract} from \"./critical/extract\";\nimport {download} from \"./file/download\";\nimport {fontscript} from \"./critical/fontscript\";\nimport {CriticalExtractOptions, CriticalResult} from \"./@types\";\n\nasync function extractAndDownload(filename: string = 'critical.css', options: CriticalExtractOptions = {}): Promise {\n\n return extract(options).\n then(async (content : CriticalResult): Promise => download(content.styles, filename, 'text/css; charset=utf-8').\n then(async () => {\n\n if ((content.fonts).length > 0) {\n\n // @ts-ignore\n return download([fontscript(content.fonts)], filename.replace(/\\.css$/, '.js'), 'text/javascript; charset=utf-8');\n }\n }).\n then(() => content)\n );\n}\n\nexport {extract, fontscript, extractAndDownload as download}"],"names":[],"mappings":"AACgB,SAAA,OAAO,CAAC,IAAY,EAAE,IAAY,EAAA;AAE9C,IAAA,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;AAE3B,QAAA,OAAO,IAAI,CAAC;KACf;;IAGD,MAAM,OAAO,GAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrD,MAAM,OAAO,GAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAE5C,IAAA,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ;AACpC,QAAA,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI;AAC5B,QAAA,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI;AACpC,QAAA,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI;AAC5B,QAAA,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI;AACpC,QAAA,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI;QAC5B,OAAO,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAC9C;AAEE,QAAA,OAAO,O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"browser.js","sources":["../src/file/download.ts","../src/file/path.ts","../src/critical/fontscript.ts","../src/critical/extract.ts","../src/browser.ts"],"sourcesContent":["/**\n *\n * @param {string[]} content\n * @param {string} filename\n * @param {string} mimetype\n * @return {Promise}\n */\nexport async function download(content: Array, filename: string, mimetype: string = 'application/octet-stream; charset=utf-8'): Promise> {\n\n //\n const url: string = URL.createObjectURL(new Blob(content, {type: mimetype}));\n //\n const a: HTMLAnchorElement = document.createElement('a');\n document.body.append(a);\n a.style.display = 'none';\n a.download = filename;\n a.href = url;\n\n //\n a.dispatchEvent(new MouseEvent('click'));\n URL.revokeObjectURL(url);\n\n return content;\n}","\nexport function resolve(path: string, from: string): string {\n\n if (path.match(/^['\"]?data:/)) {\n\n return path;\n }\n\n // @ts-ignore\n const baseURL: URL = new URL(from, window.location);\n const pathURL: URL = new URL(path, baseURL);\n\n if (baseURL.protocol != pathURL.protocol ||\n baseURL.host != pathURL.host ||\n pathURL.host != window.location.host ||\n baseURL.port != pathURL.port ||\n pathURL.port != window.location.port ||\n baseURL.port != pathURL.port ||\n pathURL.protocol != window.location.protocol\n ) {\n\n return pathURL.toString();\n }\n\n return pathURL.pathname + pathURL.search + pathURL.hash;\n}","import type {FontObject} from \"../@types\";\n\nexport function fontscript(fonts: FontObject[]): string {\n\n return '/* font preloader script: ' + fonts.length + ' */\\n\"fonts\" in document && ' + JSON.stringify([...fonts], null, 1) + '.forEach(font => new FontFace(font.fontFamily, font.src, font.properties).load().then(font => document.fonts.add(font)))'\n}","import {resolve} from \"../file\";\nimport {fontscript} from \"./fontscript\";\nimport type {\n CriticalExtractOptions,\n CriticalResult,\n FileMapObject,\n FontObject,\n MatchCSSStyleSheet,\n RuleList\n} from \"../@types\";\n\nexport async function extract(options: CriticalExtractOptions = {}) {\n\n const document: Document = window.document;\n const location: Location = window.location;\n const styles: Set = new Set;\n const excluded = ['all', 'print', ''];\n const allStylesheets: MatchCSSStyleSheet[] = [];\n\n // Get a list of all the elements in the view.\n const height = window.innerHeight;\n const walker = document.createNodeIterator(document, NodeFilter.SHOW_ELEMENT, {acceptNode: () => NodeFilter.SHOW_ELEMENT});\n\n const fonts: Set = new Set;\n const fontFamilies: Set = new Set;\n const files: Map = new Map;\n const weakMap: WeakMap = new WeakMap;\n const nodeMap: Set = new Set;\n let nodeCount: number = 0;\n let k: number;\n let rule: CSSMediaRule | CSSStyleRule;\n let rules;\n\n performance.mark('filterStylesheets');\n\n for (k = 0; k < document.styleSheets.length; k++) {\n\n // @ts-ignore\n rule = document.styleSheets[k];\n\n if (rule.media.mediaText === 'print' || (rule.media.mediaText !== '' && !window.matchMedia(rule.media.mediaText).matches)) {\n\n continue;\n }\n\n try {\n\n\n // @ts-ignore\n rules = (rule).cssRules ?? (rule).rules;\n\n for (let l = 0; l < rules.length; l++) {\n\n allStylesheets.push({rule: rules[l], match: false})\n }\n\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify({'message': e.message, stylesheet: rule.href}, null, 1));\n }\n }\n\n performance.measure('filter stylesheets', 'filterStylesheets');\n\n if (allStylesheets.length === 0) {\n\n return {styles: [], fonts: [], stats: {}};\n }\n\n let node;\n let rect;\n let allStylesLength = allStylesheets.length;\n\n performance.mark('nodeWalking');\n\n while ((node = walker.nextNode())) {\n\n if (options && options.signal && options.signal.aborted) {\n\n return Promise.reject('Aborted');\n }\n\n if (['SCRIPT', 'LINK', 'HEAD', 'META', 'TITLE', 'NOSCRIPT'].includes(node.tagName)) {\n\n continue;\n }\n\n nodeCount++;\n rect = node.getBoundingClientRect();\n\n if (rect.top < height) {\n\n nodeMap.add(node);\n }\n }\n\n for (k = 0; k < allStylesLength; k++) {\n\n if (allStylesheets[k].match || weakMap.has(allStylesheets[k].rule)) {\n\n continue;\n }\n\n weakMap.set(allStylesheets[k].rule, 1);\n\n if (allStylesheets[k].rule instanceof CSSStyleRule) {\n\n // @ts-ignore\n let selector = allStylesheets[k].rule.selectorText;\n let match;\n\n // detect pseudo selectors\n if (selector.match(/(^|,|\\s)::?((before)|(after))/)) {\n\n match = true\n } else {\n\n if (selector.match(/::?((before)|(after))/)) {\n\n selector = selector.replace(/::?((before)|(after))\\s*((,)|$)/g, '$5');\n }\n\n try {\n\n match = nodeMap.has(document.querySelector(selector));\n } catch (e) {\n\n // @ts-ignore\n match = nodeMap.has(document.querySelector(allStylesheets[k].rule.selectorText));\n }\n }\n\n if (match) {\n\n allStylesheets[k].match = true;\n\n // @ts-ignore\n if (allStylesheets[k].rule.style.getPropertyValue('font-family')) {\n\n // @ts-ignore\n allStylesheets[k].rule.style.getPropertyValue('font-family').split(/\\s*,\\s*/).forEach(fontFamily => fontFamily !== 'inherit' && fontFamilies.add(fontFamily.replace(/(['\"])([^\\1\\s]+)\\1/, '$2')));\n }\n }\n\n } else if (allStylesheets[k].rule instanceof CSSMediaRule || allStylesheets[k].rule instanceof CSSImportRule || allStylesheets[k].rule instanceof CSSConditionRule) {\n\n // @ts-ignore\n if ((allStylesheets[k].rule instanceof CSSMediaRule || allStylesheets[k].rule instanceof CSSImportRule) && (allStylesheets[k].rule.media.mediaText === 'print' || (allStylesheets[k].rule.media.mediaText !== '' && !window.matchMedia(allStylesheets[k].rule.media.mediaText).matches))) {\n continue;\n }\n\n try {\n\n const rule = allStylesheets[k].rule;\n const rules = [];\n // @ts-ignore\n const sheet = rule instanceof CSSImportRule ? rule.styleSheet.cssRules || rule.styleSheet.rules : rule.cssRules || rule.rules;\n\n for (let l = 0; l < sheet.length; l++) {\n\n if (!weakMap.has(sheet[l])) {\n\n rules.push({rule: sheet[l], match: false})\n }\n }\n\n if (rules.length > 0) {\n\n // @ts-ignore\n allStylesheets.splice.apply(allStylesheets, [k + 1, 0].concat(rules))\n allStylesLength = allStylesheets.length\n }\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify({'message': e.message, stylesheet: rule.href}, null, 1));\n }\n } else if (allStylesheets[k].rule instanceof CSSFontFaceRule) {\n\n // @ts-ignore\n if (allStylesheets[k].rule.style.getPropertyValue('font-family') && allStylesheets[k].rule.style.getPropertyValue('src')) {\n\n // @ts-ignore\n fonts.add(allStylesheets[k].rule);\n }\n }\n }\n\n performance.measure('node walking', 'nodeWalking');\n\n let css;\n let file = '';\n let inlineCount = -1;\n\n performance.mark('rulesExtraction');\n\n loop1:\n for (let k = 0; k < allStylesLength; k++) {\n\n if (!allStylesheets[k].match) {\n\n continue;\n }\n\n // @ts-ignore\n rule = allStylesheets[k].rule;\n let fileUpdate = false;\n\n // @ts-ignore\n if (!files.has(rule.parentStyleSheet)) {\n\n //\n // @ts-ignore\n files.set(rule.parentStyleSheet, {\n\n // @ts-ignore\n base: (rule.parentStyleSheet.href && rule.parentStyleSheet.href.replace(/[?#].*/, '') || location.pathname).replace(/([^/]+)$/, ''),\n // @ts-ignore\n file: rule.parentStyleSheet.href || `inline style #${++inlineCount}`\n });\n\n fileUpdate = true;\n } else { // @ts-ignore\n if (file != null && file !== files.get(rule.parentStyleSheet).file) {\n\n fileUpdate = true;\n }\n }\n\n if (fileUpdate) {\n\n try {\n\n // @ts-ignore\n console.error('analysing ' + files.get(rule.parentStyleSheet).file);\n // @ts-ignore\n styles.add('/* file: ' + files.get(rule.parentStyleSheet).file + ' */');\n } catch (e) {\n\n // @ts-ignore\n console.error(JSON.stringify(e.message, null, 1));\n console.error(JSON.stringify(rule?.parentStyleSheet?.href, null, 1));\n }\n }\n\n file = (files.get(rule.parentStyleSheet)).file;\n css = rule.cssText;\n\n if (file !== 'inline') {\n\n // resolve url()\n css = css.replace(/url\\(([^)%\\s]*?)\\)/g, function (all, one) {\n\n one = one.trim();\n\n if (one.match(/^['\"]?data:/)) {\n\n return all;\n }\n\n one = one.replace(/^(['\"])([^\\1\\s]+)\\1/, '$2');\n\n // @ts-ignore\n return 'url(' + resolve(one, files.get(rule.parentStyleSheet).base) + ')';\n })\n }\n\n while (rule.parentRule) {\n\n /**\n *\n * @type {CSSMediaRule}\n */\n // @ts-ignore\n rule = rule.parentRule;\n\n // @ts-ignore\n if (rule.conditionText == 'print') {\n\n continue loop1;\n }\n\n // @ts-ignore\n if (!excluded.includes(rule.conditionText)) {\n\n // @ts-ignore\n css = '@' + rule.constructor.name.replace(/^CSS(.*?)Rule/, '$1').toLowerCase() + ' ' + rule.conditionText + ' {' + css + '}';\n }\n\n if (!rule.parentRule) {\n\n break;\n }\n }\n\n if (rule.parentStyleSheet) {\n\n let media = rule.parentStyleSheet.media.mediaText;\n\n if (media === 'print') {\n\n continue;\n }\n\n if (media !== '') {\n\n css = '@media ' + media + ' {' + css + '}';\n }\n }\n\n if (styles.has(css)) {\n\n styles.delete(css);\n }\n\n styles.add(css);\n }\n\n performance.measure('rules extraction', 'rulesExtraction');\n\n const usedFonts = new Map;\n\n if (options.fonts) {\n\n let j;\n let name;\n let value;\n let font: CSSFontFaceRule;\n let fontObject;\n let src;\n\n performance.mark('fontsExtraction');\n\n for (font of fonts) {\n\n if (font.style.getPropertyValue('font-family').split(/\\s*,\\s*/).some(token => {\n\n return fontFamilies.has(token.replace(/(['\"])([^\\1\\s]+)\\1/, '$2'));\n })) {\n\n src = font.style.getPropertyValue('src');\n\n if (!src) {\n\n continue;\n }\n\n fontObject = {\n 'fontFamily': font.style.getPropertyValue('font-family').replace(/(['\"])([^\\1\\s]+)\\1/, '$2'),\n src: src.replace(/(^|[,\\s*])local\\([^)]+\\)\\s*,?\\s*?/g, '').replace(/url\\(([^)%\\s]+)\\)([^,]*)(,?)\\s*/g, (all, one, two, three) => {\n\n one = one.replace(/(['\"])([^\\1\\s]+)\\1/, '$2');\n\n // @ts-ignore\n if (!files.has(font.parentStyleSheet)) {\n\n // @ts-ignore\n if (!font.parentStyleSheet.href) {\n\n return all;\n }\n\n // @ts-ignore\n files.set(font.parentStyleSheet, {\n\n // @ts-ignore\n base: font.parentStyleSheet.href.replace(/([^/]+)$/, ''),\n // @ts-ignore\n file: font.parentStyleSheet.href\n })\n }\n\n // @ts-ignore\n return 'url(' + resolve(one, files.get(font.parentStyleSheet).base) + ')' + three;\n }).trim(),\n properties: {}\n }\n\n j = font.style.length;\n\n while (j--) {\n\n name = font.style.item(j);\n value = font.style.getPropertyValue(name);\n\n name !== 'font-family' &&\n name !== 'src' &&\n value !== '' &&\n value !== undefined &&\n // @ts-ignore\n (fontObject.properties[name.replace(/([A-Z])/g, (all, name) => '-' + name.toLowerCase())] = value)\n }\n\n usedFonts.set(JSON.stringify(fontObject), fontObject)\n }\n }\n\n performance.measure('fonts extraction', 'fontsExtraction');\n }\n\n const stats = performance.getEntriesByType(\"measure\").filter(entry => ['filter stylesheets', 'node walking', 'rules extraction', 'fonts extraction'].includes(entry.name)).map(entry => {\n\n return {\n\n name: entry.name,\n\n duration: (entry.duration / 1000).toFixed(3) + 's'\n }\n });\n\n\n const result: CriticalResult = {\n styles: [...styles],\n fonts: [...usedFonts.values()],\n nodeCount,\n stats: {nodeCount, stats}\n };\n\n if (options.html) {\n\n if (!document.querySelector('base')) {\n\n const base: HTMLBaseElement = document.createElement('base');\n\n base.href = options.base ?? (location.protocol + '//' + location.host + location.pathname);\n document.head.insertBefore(base, document.querySelector('meta[charset]')?.nextElementSibling || document.head.firstChild)\n }\n\n if (!document.querySelector('meta[charset]')) {\n\n const meta = document.createElement('meta');\n meta.setAttribute('charset', 'utf-8');\n document.head.insertBefore(meta, document.head.firstChild)\n }\n\n // @ts-ignore\n Array.from(document.querySelectorAll('style,link[rel=stylesheet]')).forEach((node: HTMLLinkElement | HTMLStyleElement) => {\n\n document.body.append(node);\n\n if (node.tagName === 'LINK') {\n\n if (node.media === 'print') {\n\n return\n }\n\n if (node.hasAttribute('media')) {\n\n node.setAttribute('data-media', node.media);\n }\n\n node.media = 'print';\n node.dataset.async = '';\n }\n });\n\n const script: HTMLScriptElement = document.createElement('script');\n\n script.textContent = `\n window.addEventListener('DOMContentLoaded', () => Array.from(document.querySelectorAll('link[data-async]')).forEach(node => {\n\n if(!node.hasAttribute('data-media')) {\n node.removeAttribute('media');\n }\n else {\n node.media=node.dataset.media;\n node.removeAttribute('data-media')\n }\n \n node.removeAttribute('data-async');\n }))`;\n\n document.head.append(script);\n\n // add data-attribute\n const style: HTMLStyleElement = document.createElement('style');\n // @ts-ignore\n style.dataset.critical = true;\n style.textContent = [...usedFonts.values()].map((entry) => {\n\n return '@font-face {' + '\\n ' + Object.entries(entry).map(entry => {\n\n // @ts-ignore\n return typeof entry[1] == 'string' ? `${entry[0] + ': ' + entry[1]}` : Object.entries(entry[1]).map(entry => `${entry[0] + ': ' + entry[1]}`).join(';\\n ') + '\\n}'\n }).join(';\\n')\n }).join('\\n') +\n '\\n' + (result.styles).join('\\n');\n\n if (style.textContent.trim() !== '') {\n\n document.head.insertBefore(style, document.querySelector('base')?.nextElementSibling);\n }\n\n if ((result.fonts).length > 0) {\n\n const script = document.createElement('script');\n script.textContent = fontscript(result.fonts);\n document.head.append(script);\n }\n\n const doctype: DocumentType = document.doctype as DocumentType;\n\n result.html = `` + '\\n' + document.documentElement.outerHTML\n }\n\n return result;\n}","import {extract} from \"./critical/extract\";\nimport {download} from \"./file/download\";\nimport {fontscript} from \"./critical/fontscript\";\nimport {CriticalExtractOptions, CriticalResult} from \"./@types\";\n\nasync function extractAndDownload(filename: string = 'critical.css', options: CriticalExtractOptions = {}): Promise {\n\n return extract(options).\n then(async (content : CriticalResult): Promise => download(content.styles, filename, 'text/css; charset=utf-8').\n then(async () => {\n\n if ((content.fonts).length > 0) {\n\n // @ts-ignore\n return download([fontscript(content.fonts)], filename.replace(/\\.css$/, '.js'), 'text/javascript; charset=utf-8');\n }\n }).\n then(() => content)\n );\n}\n\nexport {extract, fontscript, extractAndDownload as download}"],"names":[],"mappings":"AAAA;;;;;;AAMG;AACI,eAAe,QAAQ,CAAC,OAAsB,EAAE,QAAgB,EAAE,QAAA,GAAmB,yCAAyC,EAAA;;AAGjI,IAAA,MAAM,GAAG,GAAW,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;;IAE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EAAE,UAAkC,EAAE,EAAA;IAErG,OAAO,OAAO,CAAC,OAAO,CAAC;AACnB,QAAA,IAAI,CAAC,OAAO,OAAwB,KAA8B,QAAQ,CAAW,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,yBAAyB,CAAC;QACrI,IAAI,CAAC,YAAW;QAEZ,IAAe,OAAO,CAAC,KAAM,CAAC,MAAM,GAAG,CAAC,EAAE;;YAGtC,OAAO,QAAQ,CAAC,CAAC,UAAU,CAAW,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,gCAAgC,CAAC,CAAC;SAC/H;AACT,KAAC,CAAC;AACF,QAAA,IAAI,CAAC,MAAM,OAAO,CAAC,CACtB,CAAC;AACN;;;;"} \ No newline at end of file diff --git a/dist/critical/fontscript.js.map b/dist/critical/fontscript.js.map index dc458f9..2d82725 100644 --- a/dist/critical/fontscript.js.map +++ b/dist/critical/fontscript.js.map @@ -1 +1 @@ -{"version":3,"file":"fontscript.js","sources":["../../src/critical/fontscript.ts"],"sourcesContent":["import {FontObject} from \"../@types\";\n\nexport function fontscript(fonts: FontObject[]): string {\n\n return '/* font preloader script: ' + fonts.length + ' */\\n\"fonts\" in document && ' + JSON.stringify([...fonts], null, 1) + '.forEach(font => new FontFace(font.fontFamily, font.src, font.properties).load().then(font => document.fonts.add(font)))'\n}"],"names":[],"mappings":"AAEM,SAAU,UAAU,CAAC,KAAmB,EAAA;IAE1C,OAAO,4BAA4B,GAAG,KAAK,CAAC,MAAM,GAAG,8BAA8B,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,0HAA0H,CAAA;AAC1P;;;;"} \ No newline at end of file +{"version":3,"file":"fontscript.js","sources":["../../src/critical/fontscript.ts"],"sourcesContent":["import type {FontObject} from \"../@types\";\n\nexport function fontscript(fonts: FontObject[]): string {\n\n return '/* font preloader script: ' + fonts.length + ' */\\n\"fonts\" in document && ' + JSON.stringify([...fonts], null, 1) + '.forEach(font => new FontFace(font.fontFamily, font.src, font.properties).load().then(font => document.fonts.add(font)))'\n}"],"names":[],"mappings":"AAEM,SAAU,UAAU,CAAC,KAAmB,EAAA;IAE1C,OAAO,4BAA4B,GAAG,KAAK,CAAC,MAAM,GAAG,8BAA8B,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,0HAA0H,CAAA;AAC1P;;;;"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts index 4b20ff8..d24ebd1 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -47,6 +47,19 @@ interface CriticalCliStats { interface CriticalCliResult { fonts: Array, stats: Array, + + files: { + + html?: string; + fonts?: string; + css: { + + min?: string; + raw?: string; + nested?: string; + minNested?: string; + } + }, styles: any[]; html: string } diff --git a/dist/index.js b/dist/index.js index b01bc31..b271328 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,9 +1,9 @@ import * as playwright from 'playwright'; import { devices } from 'playwright'; -import { dirname, resolve, basename } from 'path'; +import { dirname, resolve, basename } from 'node:path'; import { readFileSync } from 'node:fs'; -import { fontscript } from './critical/fontscript.js'; import { size } from './file/size.js'; +import { fontscript } from './critical/fontscript.js'; import chalk from 'chalk'; import { transform, render } from '@tbela99/css-parser'; import { createRequire } from 'node:module'; @@ -69,6 +69,7 @@ async function critical(url, options = {}) { await browser.close(); } if (['"', "'"].includes(url.charAt(0))) { + // @ts-ignore url = url.replace(/^(['"])([^\1\s]+)\1$/, '$2'); } if (!url.match(/^([a-zA-Z]+:)?\/\//)) { @@ -287,6 +288,12 @@ async function critical(url, options = {}) { await sleep(options.pause); } } + let htmlFile = undefined; + let fontJS = undefined; + let minCssFile = undefined; + let rawCssFile = undefined; + let nestedCssFile = undefined; + let minNestedCssFile = undefined; if (options.filename) { const rawCSS = [...styles].join('\n'); const { code, unminified } = (await transform(rawCSS).then(result => { @@ -299,10 +306,10 @@ async function critical(url, options = {}) { if (cssFile.slice(-4) != '.css') { cssFile += '.css'; } - const minCssFile = cssFile.slice(0, -4) + '.min.css'; - const rawCssFile = cssFile.slice(0, -4) + '.raw.css'; - const minNestedCssFile = cssFile.slice(0, -4) + '.nested.min.css'; - const nestedCssFile = cssFile.slice(0, -4) + '.nested.css'; + minCssFile = cssFile.slice(0, -4) + '.min.css'; + rawCssFile = cssFile.slice(0, -4) + '.raw.css'; + minNestedCssFile = cssFile.slice(0, -4) + '.nested.min.css'; + nestedCssFile = cssFile.slice(0, -4) + '.nested.css'; console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(minCssFile + ' [' + size(code.length) + ']')); // @ts-ignore await writeFile(minCssFile, code); @@ -323,8 +330,9 @@ async function critical(url, options = {}) { if (match) { html = html.replace(match[0], ``); } + htmlFile = options.filename + '.html'; // @ts-ignore - await writeFile(`${options.filename}.html`, html); + await writeFile(htmlFile, html); } const fontObjects = new Set([...fonts].map((font) => JSON.parse(font))); if (options.fonts) { @@ -344,7 +352,19 @@ async function critical(url, options = {}) { // @ts-ignore await writeFile(fontJS, data); } - return { styles: [...styles], fonts: [...fonts], stats, html }; + return { + styles: [...styles], + files: { + html: htmlFile, + fonts: fontJS, + css: { + min: minCssFile, + raw: rawCssFile, + nested: nestedCssFile, + minNested: minNestedCssFile + } + }, fonts: [...fonts], stats, html + }; } export { critical }; diff --git a/dist/index.js.map b/dist/index.js.map index 5190511..b3e1e46 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import * as playwright from \"playwright\";\nimport {Browser, BrowserContext, BrowserType, ConsoleMessage, devices, LaunchOptions, Page, Request} from \"playwright\";\nimport {basename, dirname, resolve} from \"path\";\nimport {readFileSync} from \"node:fs\";\nimport {fontscript} from \"./critical/fontscript.js\";\nimport {size} from \"./file/size.js\";\nimport {\n BrowserOptions,\n CriticalCliResult,\n CriticalCliStats,\n CriticalDimension,\n CriticalExtractOptions,\n CriticalOptions,\n CriticalResult,\n FontObject\n} from \"./@types\";\nimport chalk from \"chalk\";\nimport {render, transform} from \"@tbela99/css-parser\";\nimport {createRequire} from 'node:module';\nimport {mkdir, mkdtemp, rm, writeFile} from 'node:fs/promises';\nimport {tmpdir} from 'node:os';\nimport process from \"node:process\";\n\nconst __dirname: string = dirname(new URL(import.meta.url).pathname);\nconst require = createRequire(import.meta.url);\n\nconst script: string = readFileSync(require.resolve('@tbela99/critical/umd'), {encoding: \"utf-8\"});\n\n// @ts-ignore\nconst deviceNames: Array<{\n userAgent: string;\n viewport: any[];\n screen: any[];\n deviceScaleFactor: number;\n isMobile: boolean;\n hasTouch: boolean;\n defaultBrowserType: string;\n}> = Object.values(devices);\n\nasync function sleep(duration: number) {\n\n return new Promise(resolve => setTimeout(resolve, duration + Math.ceil(Math.random() * 10)));\n}\n\nexport async function critical(options: CriticalOptions): Promise;\nexport async function critical(url: string, options: CriticalOptions): Promise\nexport async function critical(url: string | CriticalOptions, options: CriticalOptions = {}): Promise {\n\n if (typeof url === 'object') {\n\n options = url;\n url = options.url;\n }\n\n let html: string = '';\n let fonts: Set = new Set;\n\n const styles: Set = new Set;\n const stats: CriticalCliStats[] = [];\n const browserName: BrowserOptions = (options.randomBrowser ? ['chromium', 'firefox', 'webkit', 'edge', 'chrome'][Math.floor(Math.random() * 5)] : options.browser ?? 'chromium');\n const chromium: BrowserType = (['chromium', 'firefox', 'webkit', 'edge', 'chrome'].includes(browserName) &&\n // @ts-ignore\n playwright[browserName]) ?? playwright.chromium ?? 'chromium';\n\n if (options.input != null) {\n\n const browser: Browser = await chromium.launch({headless: true});\n const context: BrowserContext = await browser.newContext();\n\n const page: Page = await context.newPage();\n\n await page.goto(options.input.startsWith('data:') ? options.input : 'data:text/html;base64,' + Buffer.from(options.input).toString('base64'), {waitUntil: 'networkidle'});\n\n let base = options.base ?? 'file://' + process.cwd();\n\n if (!base.endsWith('/')) {\n\n base += '/';\n }\n\n if (!base.match(/^(([a-zA-Z]+:)?\\/)?\\//)) {\n\n base = 'file://' + process.cwd() + '/' + base;\n }\n\n options.input = await page.evaluate((base: string) => {\n\n const baseElement = (document.querySelector('base') ?? document.head.insertBefore(document.createElement('base'), document.head.firstChild)) as HTMLBaseElement;\n baseElement.href = base;\n\n const doctype = document.doctype as DocumentType;\n return `` + '\\n' + document.documentElement.outerHTML\n }, base) as string;\n\n const dir: string = await mkdtemp(tmpdir() + '/');\n\n await writeFile(dir + '/index.html', options.input);\n url = 'file://' + dir + '/index.html';\n\n // @ts-ignore\n process.on('exit', async () => await rm(dir, {recursive: true}));\n // @ts-ignore\n process.on('uncaughtException', async () => await rm(dir, {recursive: true}));\n // @ts-ignore\n process.on('unhandledRejection', async () => await rm(dir, {recursive: true}));\n\n await page.close();\n await context.close();\n await browser.close();\n }\n\n if (['\"', \"'\"].includes(url.charAt(0))) {\n\n url = url.replace(/^(['\"])([^\\1\\s]+)\\1$/, '$2');\n }\n\n if (!url.match(/^([a-zA-Z]+:)?\\/\\//)) {\n\n url = 'file://' + (url.charAt(0) == '/' ? url : resolve(__dirname + '/' + url));\n }\n\n options = {\n\n headless: true,\n randomBrowser: false,\n fonts: true,\n screenshot: false,\n console: false,\n secure: false,\n filename: '',\n container: false,\n html: false,\n pause: 30,\n verbose: false,\n colorScheme: 'dark',\n output: 'output/', ...options, browser: browserName\n };\n\n let theUrl: URL = new URL(url);\n let filePath: string = options.output + ((options.output).endsWith('/') ? '' : '/') + browserName + (options.browserType != null ? '-' + options.browserType : '') + ('/' + options.colorScheme);\n let shortUrl: string = theUrl.protocol == 'data:' ? 'data.html' : (theUrl.protocol == 'file:' ? basename(theUrl.pathname) : theUrl.protocol + '//' + theUrl.host + theUrl.pathname);\n let dimensions: string | string[] | Array;\n\n if (filePath.slice(-1) != '/') {\n\n filePath += '/';\n }\n\n if (theUrl.host !== '') {\n\n filePath += theUrl.host.replace(':', '@') + '/';\n } else {\n\n filePath += 'local_files/';\n }\n\n if (theUrl.pathname != '/') {\n\n filePath += basename(theUrl.pathname).replace(/\\.[a-z]{1,4}$/, '').replace(/^[^a-zA-Z0-9_-]+/, '').replace(/[^a-zA-Z0-9_-]+/, '-');\n } else {\n\n filePath += 'index'\n }\n\n // @ts-ignore\n filePath = filePath.replace(/[/]+$/, '');\n\n await mkdir(dirname(filePath), {recursive: true});\n\n options.filename = filePath;\n\n if (options.base != null) {\n\n if (!options.base.match(/^([a-z]+:\\/)?\\//)) {\n\n const parts1: string[] = (filePath.endsWith('/') ? filePath.slice(0, -1) : filePath).split('/');\n const parts2: string[] = (options.base.endsWith('/') ? options.base.slice(0, -1) : options.base).split('/');\n\n const result: string[] = [];\n\n parts1.pop();\n\n while (parts1.shift()) {\n\n result.push('..');\n }\n\n result.push(...parts2);\n\n options.base = result.join('/');\n }\n }\n\n if ('dimensions' in options) {\n\n dimensions = >options.dimensions;\n } else {\n\n dimensions = Number.isInteger(options.width) && Number.isInteger(options.height) ? [{\n width: +options.width,\n height: +options.height\n }] : ['1920x1080', '1440x900', '1366x768', '1024x768', '768x1024', '320x480'];\n }\n\n if (typeof dimensions == 'string') {\n\n dimensions = (dimensions).split(/\\s/)\n } else if (!Array.isArray(dimensions)) {\n\n dimensions = [dimensions];\n }\n\n dimensions = dimensions.map((dimension: string | CriticalDimension): CriticalDimension => {\n\n if (typeof dimension == 'string') {\n\n const parts: string[] = dimension.split(/[xX\"']/g);\n\n return {\n\n width: +parts[0],\n height: +parts[1]\n }\n }\n\n return dimension;\n });\n dimensions.sort(() => [-1, 0, 1][Math.floor(3 * Math.random())]);\n\n // @ts-ignore\n for (const dimension of dimensions) {\n\n const launchOptions: LaunchOptions = {\n headless: options.headless,\n bypassCSP: !options.secure,\n defaultViewport: {\n isMobile: true,\n isLandscape: false,\n },\n waitForInitialPage: false,\n args: [],\n ignoreDefaultArgs: ['--enable-automation']\n };\n\n const size: string = ` (${dimension.width}x${dimension.height})`\n\n launchOptions.args = [\n '--test-type',\n '--no-startup-window',\n `--window-size=${(dimension).width},${(dimension).height}`\n ];\n\n if (!options.secure) {\n\n launchOptions.args.push(\n '--disable-web-security',\n '--allow-running-insecure-content',\n '--no-default-browser-check',\n '--ignore-certificate-errors',\n '--disable-site-isolation-trials'\n )\n }\n\n if (options.container) {\n\n launchOptions.args.push(\n \"--disable-gpu\",\n \"--disable-dev-shm-usage\",\n \"--disable-setuid-sandbox\",\n \"--no-sandbox\"\n )\n }\n\n if (options.verbose || options.console) {\n\n console.error(chalk.blue(`[${shortUrl}]> selected browser `) + chalk.green(chromium.name()));\n console.error(chalk.blue(`[${shortUrl}${size}]> set viewport to `) + chalk.green(`${dimension.width}x${dimension.height}`));\n }\n\n let contextData = {};\n\n if (options.browserType != null || options.randomUserAgent || options.randomBrowser) {\n\n contextData = deviceNames.slice().sort(() => [-1, 0, 1][Math.floor(3 * Math.random())]).filter(d => {\n\n if (browserName != d.defaultBrowserType) {\n\n return false;\n }\n\n if (options.browserType != null) {\n\n if (options.browserType == 'mobile') {\n\n return d.isMobile;\n } else {\n\n return !d.isMobile;\n }\n }\n\n return true;\n })[0];\n }\n\n const browser: Browser = await chromium.launch(launchOptions);\n const context: BrowserContext = await browser.newContext({\n ...contextData,\n bypassCSP: !options.secure,\n viewport: dimension\n });\n\n if (options.randomUserAgent) {\n\n // antibot evasion\n await context.addInitScript(() => {\n\n Object.defineProperty(navigator, 'webdriver', {get: () => undefined});\n });\n }\n\n await context.addInitScript(script + ';window.critical=critical;');\n const page: Page = await context.newPage();\n\n try {\n\n await page.emulateMedia({\n colorScheme: options.colorScheme,\n });\n\n if (options.console) {\n\n page.on('console', (message: ConsoleMessage) =>\n // @ts-ignore\n console.error(chalk.yellow(`[${shortUrl}${size}]> ${message.type().replace(/^([a-z])/, (all: string, one: string) => one.toUpperCase())} ${message.text()}`)))\n // @ts-ignore\n .on('pageerror', ({message}) => console.error(chalk.red(`[${shortUrl}${size}]> ${message}`)))\n .on('requestfailed', (request: Request) => {\n\n const failure = request.failure();\n console.error(chalk.red(`[${shortUrl}${size}]> ${failure && failure.errorText} ${request.url()}`))\n });\n }\n\n console.error(chalk.blue(`[${shortUrl}${size}]> open `) + url);\n\n if (options.input != null) {\n\n const dir: string = await mkdtemp(tmpdir() + '/');\n\n await writeFile(dir + '/index.html', options.input);\n url = 'file://' + dir + '/index.html';\n\n // @ts-ignore\n process.on('exit', async () => await rm(dir, {recursive: true}));\n // @ts-ignore\n process.on('uncaughtException', async () => await rm(dir, {recursive: true}));\n // @ts-ignore\n process.on('unhandledRejection', async () => await rm(dir, {recursive: true}));\n }\n\n await page.goto(url, {waitUntil: 'networkidle'});\n\n if (options.screenshot) {\n\n const screenshot: {\n path: string\n } = typeof options.screenshot == 'object' && Object.assign({}, options.screenshot) || {path: typeof options.screenshot == 'string' && options.screenshot || options.filename + '.png' || 'screenshot.png'}\n\n if (dimensions.length > 1) {\n\n screenshot.path = screenshot.path.replace(/\\.([^.]+)$/, `_${dimension.width}x${dimension.height}.\\$1`)\n }\n\n if (options.verbose) {\n\n console.error(chalk.blue(`[${shortUrl}${size}]> generating screenshot at `) + chalk.green(screenshot.path));\n }\n\n await page.screenshot(screenshot);\n }\n\n if (options.verbose) {\n\n console.error(chalk.blue(`[${shortUrl}${size}]> collect critical data`));\n }\n\n const data = await page.evaluate(async (param: { options: CriticalExtractOptions }) => {\n\n // @ts-ignore\n return await critical.extract(param.options).then((result: CriticalResult) => {\n\n if (Array.isArray(result.fonts)) {\n\n // @ts-ignore\n result.fonts = (result.fonts).map((font: FontObject) => JSON.stringify(font));\n }\n\n // @ts-ignore\n if (param.options.verbose) {\n\n console.error(JSON.stringify({result}, null, 1));\n }\n\n return result;\n });\n }, {options});\n\n if (data.styles != null) {\n\n data.styles.forEach((line: string) => styles.add(line));\n data.fonts.forEach((line: string) => fonts.add(line));\n stats.push({width: dimension.width, height: dimension.height, stats: data.stats});\n\n if (options.html != null && html === '') {\n\n html = data.html ?? '';\n }\n }\n\n } catch (error: any) {\n\n console.error(error);\n } finally {\n\n await page.close();\n await context.close();\n await browser.close();\n }\n\n if (options.pause > 0) {\n\n await sleep(options.pause);\n }\n }\n\n if (options.filename) {\n\n const rawCSS: string = [...styles].join('\\n');\n const {code, unminified}: { code: string; unminified: string } = (await transform(rawCSS).then(result => {\n\n return {code: result.code, unminified: render(result.ast, {minify: false}).code}\n }));\n const {code: nestedCSS, unminified: nestedUnminified}: {\n code: string;\n unminified: string\n } = (await transform(rawCSS, {nestingRules: true}).then(result => {\n\n return {code: result.code, unminified: render(result.ast, {minify: false}).code}\n }));\n\n let cssFile: string = options.filename;\n\n if (cssFile.slice(-4) != '.css') {\n\n cssFile += '.css';\n }\n\n const minCssFile: string = cssFile.slice(0, -4) + '.min.css';\n const rawCssFile: string = cssFile.slice(0, -4) + '.raw.css';\n\n const minNestedCssFile: string = cssFile.slice(0, -4) + '.nested.min.css';\n const nestedCssFile: string = cssFile.slice(0, -4) + '.nested.css';\n\n console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(minCssFile + ' [' + size(code.length) + ']'));\n // @ts-ignore\n await writeFile(minCssFile, code);\n\n console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(cssFile + ' [' + size(unminified.length) + ']'));\n\n await writeFile(cssFile, unminified);\n\n // @ts-ignore\n await writeFile(rawCssFile, rawCSS);\n\n console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(minNestedCssFile + ' [' + size(nestedCSS.length) + ']'));\n // @ts-ignore\n await writeFile(minNestedCssFile, nestedCSS);\n\n console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(nestedCssFile + ' [' + size(nestedUnminified.length) + ']'));\n\n await writeFile(nestedCssFile, nestedUnminified);\n\n // @ts-ignore\n await writeFile(rawCssFile, rawCSS);\n }\n\n if (options.html != null && html != null && html !== '') {\n\n const match: RegExpMatchArray | null = html.match(/`);\n }\n\n // @ts-ignore\n await writeFile(`${options.filename}.html`, html);\n }\n\n const fontObjects: Set = >new Set([...fonts].map((font: string) => JSON.parse(font)));\n\n if (options.fonts) {\n\n let fontJS: string = options.filename;\n let data: string = '/* no font found! */';\n\n if (fontJS.slice(-3) != '.js') {\n\n fontJS += '.js';\n }\n\n if (fontObjects.size == 0) {\n\n console.error(chalk.yellow(`[${shortUrl}]> no preload font found`));\n } else {\n\n data = fontscript([...fontObjects]);\n console.error(chalk.blue(`[${shortUrl}]> writing `) + chalk.green(fontObjects.size.toString()) + chalk.blue(` preload font script at `) +\n chalk.green(`${fontJS} [` + size(data.length) + ']'));\n }\n\n // @ts-ignore\n await writeFile(fontJS, data);\n }\n\n return {styles: [...styles], fonts: [...fonts], stats, html};\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,SAAS,GAAW,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AACrE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,MAAM,GAAW,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC;AAEnG;AACA,MAAM,WAAW,GAQZ,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAE5B,eAAe,KAAK,CAAC,QAAgB,EAAA;IAEjC,OAAO,IAAI,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACjG,CAAC;AAIM,eAAe,QAAQ,CAAC,GAA6B,EAAE,UAA2B,EAAE,EAAA;AAEvF,IAAA,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAEzB,OAAO,GAAoB,GAAG,CAA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,EAAE,KAAK,EAAE,IAAI,EAAC,CAAC;AACjE;;;;"} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import * as playwright from \"playwright\";\nimport {Browser, BrowserContext, BrowserType, ConsoleMessage, devices, LaunchOptions, Page, Request} from \"playwright\";\nimport {basename, dirname, resolve} from \"node:path\";\nimport {readFileSync} from \"node:fs\";\nimport {fontscript} from \"./critical\";\nimport {size} from \"./file\";\nimport type {\n BrowserOptions,\n CriticalCliResult,\n CriticalCliStats,\n CriticalDimension,\n CriticalExtractOptions,\n CriticalOptions,\n CriticalResult,\n FontObject\n} from \"./@types\";\nimport chalk from \"chalk\";\nimport {render, transform} from \"@tbela99/css-parser\";\nimport {createRequire} from 'node:module';\nimport {mkdir, mkdtemp, rm, writeFile} from 'node:fs/promises';\nimport {tmpdir} from 'node:os';\nimport process from \"node:process\";\n\nconst __dirname: string = dirname(new URL(import.meta.url).pathname);\nconst require = createRequire(import.meta.url);\n\nconst script: string = readFileSync(require.resolve('@tbela99/critical/umd'), {encoding: \"utf-8\"});\n\n// @ts-ignore\nconst deviceNames: Array<{\n userAgent: string;\n viewport: any[];\n screen: any[];\n deviceScaleFactor: number;\n isMobile: boolean;\n hasTouch: boolean;\n defaultBrowserType: string;\n}> = Object.values(devices);\n\nasync function sleep(duration: number) {\n\n return new Promise(resolve => setTimeout(resolve, duration + Math.ceil(Math.random() * 10)));\n}\n\nexport async function critical(options: CriticalOptions): Promise;\nexport async function critical(url: string, options: CriticalOptions): Promise\nexport async function critical(url: string | CriticalOptions, options: CriticalOptions = {}): Promise {\n\n if (typeof url === 'object') {\n\n options = url;\n url = options.url;\n }\n\n let html: string = '';\n let fonts: Set = new Set;\n\n const styles: Set = new Set;\n const stats: CriticalCliStats[] = [];\n const browserName: BrowserOptions = (options.randomBrowser ? ['chromium', 'firefox', 'webkit', 'edge', 'chrome'][Math.floor(Math.random() * 5)] : options.browser ?? 'chromium');\n const chromium: BrowserType = (['chromium', 'firefox', 'webkit', 'edge', 'chrome'].includes(browserName) &&\n // @ts-ignore\n playwright[browserName]) ?? playwright.chromium ?? 'chromium';\n\n if (options.input != null) {\n\n const browser: Browser = await chromium.launch({headless: true});\n const context: BrowserContext = await browser.newContext();\n\n const page: Page = await context.newPage();\n\n await page.goto(options.input.startsWith('data:') ? options.input : 'data:text/html;base64,' + Buffer.from(options.input).toString('base64'), {waitUntil: 'networkidle'});\n\n let base: string = options.base ?? 'file://' + process.cwd();\n\n if (!base.endsWith('/')) {\n\n base += '/';\n }\n\n if (!base.match(/^(([a-zA-Z]+:)?\\/)?\\//)) {\n\n base = 'file://' + process.cwd() + '/' + base;\n }\n\n options.input = await page.evaluate((base: string) => {\n\n const baseElement = (document.querySelector('base') ?? document.head.insertBefore(document.createElement('base'), document.head.firstChild)) as HTMLBaseElement;\n baseElement.href = base;\n\n const doctype = document.doctype as DocumentType;\n return `` + '\\n' + document.documentElement.outerHTML\n }, base) as string;\n\n const dir: string = await mkdtemp(tmpdir() + '/');\n\n await writeFile(dir + '/index.html', options.input);\n url = 'file://' + dir + '/index.html';\n\n // @ts-ignore\n process.on('exit', async () => await rm(dir, {recursive: true}));\n // @ts-ignore\n process.on('uncaughtException', async () => await rm(dir, {recursive: true}));\n // @ts-ignore\n process.on('unhandledRejection', async () => await rm(dir, {recursive: true}));\n\n await page.close();\n await context.close();\n await browser.close();\n }\n\n if (['\"', \"'\"].includes(url.charAt(0))) {\n\n // @ts-ignore\n url = url.replace(/^(['\"])([^\\1\\s]+)\\1$/, '$2');\n }\n\n if (!url.match(/^([a-zA-Z]+:)?\\/\\//)) {\n\n url = 'file://' + (url.charAt(0) == '/' ? url : resolve(__dirname + '/' + url));\n }\n\n options = {\n\n headless: true,\n randomBrowser: false,\n fonts: true,\n screenshot: false,\n console: false,\n secure: false,\n filename: '',\n container: false,\n html: false,\n pause: 30,\n verbose: false,\n colorScheme: 'dark',\n output: 'output/', ...options, browser: browserName\n };\n\n let theUrl: URL = new URL(url);\n let filePath: string = options.output + ((options.output).endsWith('/') ? '' : '/') + browserName + (options.browserType != null ? '-' + options.browserType : '') + ('/' + options.colorScheme);\n let shortUrl: string = theUrl.protocol == 'data:' ? 'data.html' : (theUrl.protocol == 'file:' ? basename(theUrl.pathname) : theUrl.protocol + '//' + theUrl.host + theUrl.pathname);\n let dimensions: string | string[] | Array;\n\n if (filePath.slice(-1) != '/') {\n\n filePath += '/';\n }\n\n if (theUrl.host !== '') {\n\n filePath += theUrl.host.replace(':', '@') + '/';\n } else {\n\n filePath += 'local_files/';\n }\n\n if (theUrl.pathname != '/') {\n\n filePath += basename(theUrl.pathname).replace(/\\.[a-z]{1,4}$/, '').replace(/^[^a-zA-Z0-9_-]+/, '').replace(/[^a-zA-Z0-9_-]+/, '-');\n } else {\n\n filePath += 'index'\n }\n\n // @ts-ignore\n filePath = filePath.replace(/[/]+$/, '');\n\n await mkdir(dirname(filePath), {recursive: true});\n\n options.filename = filePath;\n\n if (options.base != null) {\n\n if (!options.base.match(/^([a-z]+:\\/)?\\//)) {\n\n const parts1: string[] = (filePath.endsWith('/') ? filePath.slice(0, -1) : filePath).split('/');\n const parts2: string[] = (options.base.endsWith('/') ? options.base.slice(0, -1) : options.base).split('/');\n\n const result: string[] = [];\n\n parts1.pop();\n\n while (parts1.shift()) {\n\n result.push('..');\n }\n\n result.push(...parts2);\n\n options.base = result.join('/');\n }\n }\n\n if ('dimensions' in options) {\n\n dimensions = >options.dimensions;\n } else {\n\n dimensions = Number.isInteger(options.width) && Number.isInteger(options.height) ? [{\n width: +options.width,\n height: +options.height\n }] : ['1920x1080', '1440x900', '1366x768', '1024x768', '768x1024', '320x480'];\n }\n\n if (typeof dimensions == 'string') {\n\n dimensions = (dimensions).split(/\\s/)\n } else if (!Array.isArray(dimensions)) {\n\n dimensions = [dimensions];\n }\n\n dimensions = dimensions.map((dimension: string | CriticalDimension): CriticalDimension => {\n\n if (typeof dimension == 'string') {\n\n const parts: string[] = dimension.split(/[xX\"']/g);\n\n return {\n\n width: +parts[0],\n height: +parts[1]\n }\n }\n\n return dimension;\n });\n dimensions.sort(() => [-1, 0, 1][Math.floor(3 * Math.random())]);\n\n // @ts-ignore\n for (const dimension of dimensions) {\n\n const launchOptions: LaunchOptions = {\n headless: options.headless,\n bypassCSP: !options.secure,\n defaultViewport: {\n isMobile: true,\n isLandscape: false,\n },\n waitForInitialPage: false,\n args: [],\n ignoreDefaultArgs: ['--enable-automation']\n };\n\n const size: string = ` (${dimension.width}x${dimension.height})`\n\n launchOptions.args = [\n '--test-type',\n '--no-startup-window',\n `--window-size=${(dimension).width},${(dimension).height}`\n ];\n\n if (!options.secure) {\n\n launchOptions.args.push(\n '--disable-web-security',\n '--allow-running-insecure-content',\n '--no-default-browser-check',\n '--ignore-certificate-errors',\n '--disable-site-isolation-trials'\n )\n }\n\n if (options.container) {\n\n launchOptions.args.push(\n \"--disable-gpu\",\n \"--disable-dev-shm-usage\",\n \"--disable-setuid-sandbox\",\n \"--no-sandbox\"\n )\n }\n\n if (options.verbose || options.console) {\n\n console.error(chalk.blue(`[${shortUrl}]> selected browser `) + chalk.green(chromium.name()));\n console.error(chalk.blue(`[${shortUrl}${size}]> set viewport to `) + chalk.green(`${dimension.width}x${dimension.height}`));\n }\n\n let contextData = {};\n\n if (options.browserType != null || options.randomUserAgent || options.randomBrowser) {\n\n contextData = deviceNames.slice().sort(() => [-1, 0, 1][Math.floor(3 * Math.random())]).filter(d => {\n\n if (browserName != d.defaultBrowserType) {\n\n return false;\n }\n\n if (options.browserType != null) {\n\n if (options.browserType == 'mobile') {\n\n return d.isMobile;\n } else {\n\n return !d.isMobile;\n }\n }\n\n return true;\n })[0];\n }\n\n const browser: Browser = await chromium.launch(launchOptions);\n const context: BrowserContext = await browser.newContext({\n ...contextData,\n bypassCSP: !options.secure,\n viewport: dimension\n });\n\n if (options.randomUserAgent) {\n\n // antibot evasion\n await context.addInitScript(() => {\n\n Object.defineProperty(navigator, 'webdriver', {get: () => undefined});\n });\n }\n\n await context.addInitScript(script + ';window.critical=critical;');\n const page: Page = await context.newPage();\n\n try {\n\n await page.emulateMedia({\n colorScheme: options.colorScheme,\n });\n\n if (options.console) {\n\n page.on('console', (message: ConsoleMessage) =>\n // @ts-ignore\n console.error(chalk.yellow(`[${shortUrl}${size}]> ${message.type().replace(/^([a-z])/, (all: string, one: string) => one.toUpperCase())} ${message.text()}`)))\n // @ts-ignore\n .on('pageerror', ({message}) => console.error(chalk.red(`[${shortUrl}${size}]> ${message}`)))\n .on('requestfailed', (request: Request) => {\n\n const failure = request.failure();\n console.error(chalk.red(`[${shortUrl}${size}]> ${failure && failure.errorText} ${request.url()}`))\n });\n }\n\n console.error(chalk.blue(`[${shortUrl}${size}]> open `) + url);\n\n if (options.input != null) {\n\n const dir: string = await mkdtemp(tmpdir() + '/');\n\n await writeFile(dir + '/index.html', options.input);\n url = 'file://' + dir + '/index.html';\n\n // @ts-ignore\n process.on('exit', async () => await rm(dir, {recursive: true}));\n // @ts-ignore\n process.on('uncaughtException', async () => await rm(dir, {recursive: true}));\n // @ts-ignore\n process.on('unhandledRejection', async () => await rm(dir, {recursive: true}));\n }\n\n await page.goto(url, {waitUntil: 'networkidle'});\n\n if (options.screenshot) {\n\n const screenshot: {\n path: string\n } = typeof options.screenshot == 'object' && Object.assign({}, options.screenshot) || {path: typeof options.screenshot == 'string' && options.screenshot || options.filename + '.png' || 'screenshot.png'}\n\n if (dimensions.length > 1) {\n\n screenshot.path = screenshot.path.replace(/\\.([^.]+)$/, `_${dimension.width}x${dimension.height}.\\$1`)\n }\n\n if (options.verbose) {\n\n console.error(chalk.blue(`[${shortUrl}${size}]> generating screenshot at `) + chalk.green(screenshot.path));\n }\n\n await page.screenshot(screenshot);\n }\n\n if (options.verbose) {\n\n console.error(chalk.blue(`[${shortUrl}${size}]> collect critical data`));\n }\n\n const data = await page.evaluate(async (param: { options: CriticalExtractOptions }) => {\n\n // @ts-ignore\n return await critical.extract(param.options).then((result: CriticalResult) => {\n\n if (Array.isArray(result.fonts)) {\n\n // @ts-ignore\n result.fonts = (result.fonts).map((font: FontObject) => JSON.stringify(font));\n }\n\n // @ts-ignore\n if (param.options.verbose) {\n\n console.error(JSON.stringify({result}, null, 1));\n }\n\n return result;\n });\n }, {options});\n\n if (data.styles != null) {\n\n data.styles.forEach((line: string) => styles.add(line));\n data.fonts.forEach((line: string) => fonts.add(line));\n stats.push({width: dimension.width, height: dimension.height, stats: data.stats});\n\n if (options.html != null && html === '') {\n\n html = data.html ?? '';\n }\n }\n\n } catch (error: any) {\n\n console.error(error);\n } finally {\n\n await page.close();\n await context.close();\n await browser.close();\n }\n\n if (options.pause > 0) {\n\n await sleep(options.pause);\n }\n }\n\n let htmlFile: string | undefined = undefined;\n let fontJS: string | undefined = undefined;\n let minCssFile: string | undefined = undefined;\n let rawCssFile: string | undefined = undefined;\n let nestedCssFile: string | undefined = undefined;\n let minNestedCssFile: string | undefined = undefined;\n\n if (options.filename) {\n\n const rawCSS: string = [...styles].join('\\n');\n const {code, unminified}: { code: string; unminified: string } = (await transform(rawCSS).then(result => {\n\n return {code: result.code, unminified: render(result.ast, {minify: false}).code}\n }));\n const {code: nestedCSS, unminified: nestedUnminified}: {\n code: string;\n unminified: string\n } = (await transform(rawCSS, {nestingRules: true}).then(result => {\n\n return {code: result.code, unminified: render(result.ast, {minify: false}).code}\n }));\n\n let cssFile: string = options.filename;\n\n if (cssFile.slice(-4) != '.css') {\n\n cssFile += '.css';\n }\n\n minCssFile = cssFile.slice(0, -4) + '.min.css' as string;\n rawCssFile = cssFile.slice(0, -4) + '.raw.css' as string;\n\n minNestedCssFile = cssFile.slice(0, -4) + '.nested.min.css' as string;\n nestedCssFile = cssFile.slice(0, -4) + '.nested.css' as string;\n\n console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(minCssFile + ' [' + size(code.length) + ']'));\n // @ts-ignore\n await writeFile(minCssFile, code);\n\n console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(cssFile + ' [' + size(unminified.length) + ']'));\n\n await writeFile(cssFile, unminified);\n\n // @ts-ignore\n await writeFile(rawCssFile, rawCSS);\n\n console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(minNestedCssFile + ' [' + size(nestedCSS.length) + ']'));\n // @ts-ignore\n await writeFile(minNestedCssFile, nestedCSS);\n\n console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(nestedCssFile + ' [' + size(nestedUnminified.length) + ']'));\n\n await writeFile(nestedCssFile, nestedUnminified);\n\n // @ts-ignore\n await writeFile(rawCssFile, rawCSS);\n }\n\n if (options.html != null && html != null && html !== '') {\n\n const match: RegExpMatchArray | null = html.match(/`);\n }\n\n htmlFile = options.filename + '.html';\n // @ts-ignore\n await writeFile(htmlFile, html);\n }\n\n const fontObjects: Set = >new Set([...fonts].map((font: string) => JSON.parse(font)));\n\n if (options.fonts) {\n\n let fontJS: string = options.filename;\n let data: string = '/* no font found! */';\n\n if (fontJS.slice(-3) != '.js') {\n\n fontJS += '.js';\n }\n\n if (fontObjects.size == 0) {\n\n console.error(chalk.yellow(`[${shortUrl}]> no preload font found`));\n } else {\n\n data = fontscript([...fontObjects]);\n console.error(chalk.blue(`[${shortUrl}]> writing `) + chalk.green(fontObjects.size.toString()) + chalk.blue(` preload font script at `) +\n chalk.green(`${fontJS} [` + size(data.length) + ']'));\n }\n\n // @ts-ignore\n await writeFile(fontJS, data);\n }\n\n return {\n styles: [...styles],\n files: {\n\n html: htmlFile,\n fonts: fontJS,\n css: {\n\n min: minCssFile,\n raw: rawCssFile,\n nested: nestedCssFile,\n minNested: minNestedCssFile\n }\n\n }, fonts: [...fonts], stats, html\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,SAAS,GAAW,OAAO,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;AACrE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,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AAC;SACnB;AAED,QAAA,IAAI,WAAW,CAAC,IAAI,IAAI,CAAC,EAAE;AAEvB,YAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA,CAAA,EAAI,QAAQ,CAAA,wBAAA,CAA0B,CAAC,CAAC,CAAC;SACvE;aAAM;YAEH,IAAI,GAAG,UAAU,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;AACpC,YAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA,CAAA,EAAI,QAAQ,CAAA,WAAA,CAAa,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,0BAA0B,CAAC;AACnI,gBAAA,KAAK,CAAC,KAAK,CAAC,CAAG,EAAA,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;SAC7D;;AAGD,QAAA,MAAM,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;KACjC;IAED,OAAO;AACH,QAAA,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC;AACnB,QAAA,KAAK,EAAE;AAEH,YAAA,IAAI,EAAE,QAAQ;AACd,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,GAAG,EAAE;AAED,gBAAA,GAAG,EAAE,UAAU;AACf,gBAAA,GAAG,EAAE,UAAU;AACf,gBAAA,MAAM,EAAE,aAAa;AACrB,gBAAA,SAAS,EAAE,gBAAgB;AAC9B,aAAA;SAEJ,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI;KACpC,CAAC;AACN;;;;"} \ No newline at end of file diff --git a/src/@types/index.d.ts b/src/@types/index.d.ts index 35fcb08..535f06b 100644 --- a/src/@types/index.d.ts +++ b/src/@types/index.d.ts @@ -77,6 +77,19 @@ export interface CriticalCliStats { export interface CriticalCliResult { fonts: Array, stats: Array, + + files: { + + html?: string; + fonts?: string; + css: { + + min?: string; + raw?: string; + nested?: string; + minNested?: string; + } + }, styles: any[]; html: string } diff --git a/src/critical/extract.ts b/src/critical/extract.ts index ef943da..be57bd7 100644 --- a/src/critical/extract.ts +++ b/src/critical/extract.ts @@ -1,6 +1,6 @@ -import {resolve} from "../file/path"; +import {resolve} from "../file"; import {fontscript} from "./fontscript"; -import { +import type { CriticalExtractOptions, CriticalResult, FileMapObject, diff --git a/src/critical/fontscript.ts b/src/critical/fontscript.ts index 013d0de..654bb6b 100644 --- a/src/critical/fontscript.ts +++ b/src/critical/fontscript.ts @@ -1,4 +1,4 @@ -import {FontObject} from "../@types"; +import type {FontObject} from "../@types"; export function fontscript(fonts: FontObject[]): string { diff --git a/src/critical/index.ts b/src/critical/index.ts new file mode 100644 index 0000000..23a8b52 --- /dev/null +++ b/src/critical/index.ts @@ -0,0 +1,3 @@ + +export * from './extract'; +export * from './fontscript'; \ No newline at end of file diff --git a/src/file/index.ts b/src/file/index.ts new file mode 100644 index 0000000..2fa6c89 --- /dev/null +++ b/src/file/index.ts @@ -0,0 +1,4 @@ + +export * from './download'; +export * from './path'; +export * from './size'; \ No newline at end of file diff --git a/src/file/path.ts b/src/file/path.ts index 1140567..b3d7e2c 100644 --- a/src/file/path.ts +++ b/src/file/path.ts @@ -7,7 +7,7 @@ export function resolve(path: string, from: string): string { } // @ts-ignore - const baseURL: URL = new URL(from, window?.location); + const baseURL: URL = new URL(from, window.location); const pathURL: URL = new URL(path, baseURL); if (baseURL.protocol != pathURL.protocol || diff --git a/src/index.ts b/src/index.ts index 7228d34..fbd5ece 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ import * as playwright from "playwright"; import {Browser, BrowserContext, BrowserType, ConsoleMessage, devices, LaunchOptions, Page, Request} from "playwright"; -import {basename, dirname, resolve} from "path"; +import {basename, dirname, resolve} from "node:path"; import {readFileSync} from "node:fs"; -import {fontscript} from "./critical/fontscript.js"; -import {size} from "./file/size.js"; -import { +import {fontscript} from "./critical"; +import {size} from "./file"; +import type { BrowserOptions, CriticalCliResult, CriticalCliStats, @@ -71,7 +71,7 @@ export async function critical(url: string | CriticalOptions, options: CriticalO await page.goto(options.input.startsWith('data:') ? options.input : 'data:text/html;base64,' + Buffer.from(options.input).toString('base64'), {waitUntil: 'networkidle'}); - let base = options.base ?? 'file://' + process.cwd(); + let base: string = options.base ?? 'file://' + process.cwd(); if (!base.endsWith('/')) { @@ -116,6 +116,7 @@ export async function critical(url: string | CriticalOptions, options: CriticalO if (['"', "'"].includes(url.charAt(0))) { + // @ts-ignore url = url.replace(/^(['"])([^\1\s]+)\1$/, '$2'); } @@ -439,6 +440,13 @@ export async function critical(url: string | CriticalOptions, options: CriticalO } } + let htmlFile: string | undefined = undefined; + let fontJS: string | undefined = undefined; + let minCssFile: string | undefined = undefined; + let rawCssFile: string | undefined = undefined; + let nestedCssFile: string | undefined = undefined; + let minNestedCssFile: string | undefined = undefined; + if (options.filename) { const rawCSS: string = [...styles].join('\n'); @@ -461,11 +469,11 @@ export async function critical(url: string | CriticalOptions, options: CriticalO cssFile += '.css'; } - const minCssFile: string = cssFile.slice(0, -4) + '.min.css'; - const rawCssFile: string = cssFile.slice(0, -4) + '.raw.css'; + minCssFile = cssFile.slice(0, -4) + '.min.css' as string; + rawCssFile = cssFile.slice(0, -4) + '.raw.css' as string; - const minNestedCssFile: string = cssFile.slice(0, -4) + '.nested.min.css'; - const nestedCssFile: string = cssFile.slice(0, -4) + '.nested.css'; + minNestedCssFile = cssFile.slice(0, -4) + '.nested.min.css' as string; + nestedCssFile = cssFile.slice(0, -4) + '.nested.css' as string; console.error(chalk.blue(`[${shortUrl}]> writing css at `) + chalk.green(minCssFile + ' [' + size(code.length) + ']')); // @ts-ignore @@ -499,8 +507,9 @@ export async function critical(url: string | CriticalOptions, options: CriticalO html = html.replace(match[0], ``); } + htmlFile = options.filename + '.html'; // @ts-ignore - await writeFile(`${options.filename}.html`, html); + await writeFile(htmlFile, html); } const fontObjects: Set = >new Set([...fonts].map((font: string) => JSON.parse(font))); @@ -529,5 +538,20 @@ export async function critical(url: string | CriticalOptions, options: CriticalO await writeFile(fontJS, data); } - return {styles: [...styles], fonts: [...fonts], stats, html}; + return { + styles: [...styles], + files: { + + html: htmlFile, + fonts: fontJS, + css: { + + min: minCssFile, + raw: rawCssFile, + nested: nestedCssFile, + minNested: minNestedCssFile + } + + }, fonts: [...fonts], stats, html + }; }