reboost
Version:
A super fast dev server for rapid web development
42 lines (41 loc) • 2.29 kB
TypeScript
/// <reference types="node" />
import { AcceptedPlugin } from 'postcss';
import { ExtractedICSS, Modes } from './modules';
import { RawSourceMap } from 'source-map';
import { ReboostConfig } from '../../index';
import { URLTester } from './index';
import { ParsedImport, ParsedURL } from './parsers';
export { Modes };
export declare const getPlugins: (options: {
filePath: string;
testers: {
import: URLTester;
url: URLTester;
};
handleImports: boolean;
handleURLS: boolean;
module: false | {
mode: Modes;
exportGlobals: boolean;
hasValues: boolean;
};
}) => {
plugins: AcceptedPlugin[];
extracted: {
imports: ParsedImport[];
urls: ParsedURL[];
icss: ExtractedICSS;
};
};
export declare const generateModuleCode: (data: {
filePath: string;
css: string;
config: ReboostConfig;
sourceMap: RawSourceMap;
imports: ParsedImport[];
urls: ParsedURL[];
module: false | {
icss: ExtractedICSS;
};
}) => string;
export declare const runtimeCode = "\n export const replaceReplacements = (str, replacements) => {\n Object.keys(replacements).forEach((toReplace) => {\n str = str.replace(new RegExp(toReplace, 'g'), replacements[toReplace]);\n });\n return str;\n }\n\n export const patchObject = (object, target) => {\n Object.keys(object).forEach((key) => {\n if (!(key in target)) delete object[key];\n });\n Object.assign(object, target);\n }\n\n // This function removes the default style injected by the module\n // and handles the style with media\n export const ImportedStyle = (module, media) => {\n let style;\n const listener = ({ toString }) => (style.textContent = toString());\n\n return {\n apply() {\n if (style) return;\n module.__removeStyle();\n style = document.createElement('style');\n style.textContent = module.toString();\n if (media) style.media = media;\n document.head.appendChild(style);\n module.__updateListeners.add(listener);\n },\n destroy() {\n if (!style) return;\n style.remove();\n module.__updateListeners.delete(listener);\n }\n }\n }\n";