@el3um4s/svelte-get-component-info
Version:
Typescript NPM Package Starter
50 lines (49 loc) • 1.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCSS_asInFile = exports.hasCSS = exports.getSlots_asInFile = exports.hasSlots = exports.getActions_asInFile = exports.hasActions = exports.getProps_asInFile = exports.hasProps = void 0;
const regex = {
propsGeneric: /export let [\s\S]*?;/gi,
actionsGeneric: /(?<=dispatch[.(])(.*?)(?=[,)])/gi,
slotsGeneric: /<slot[\s\S]*?>/gi,
cssGeneric: /(?=--)(.*?)(?=[,=)>:;\n\r\t\0])/gi
};
function hasProps(component) {
const content = component.match(regex.propsGeneric);
return content != null;
}
exports.hasProps = hasProps;
function getProps_asInFile(component) {
const content = component.match(regex.propsGeneric);
return content != null ? content : [];
}
exports.getProps_asInFile = getProps_asInFile;
function hasActions(component) {
const content = component.match(regex.actionsGeneric);
return content != null;
}
exports.hasActions = hasActions;
function getActions_asInFile(component) {
const content = component.match(regex.actionsGeneric);
return content != null ? content : [];
}
exports.getActions_asInFile = getActions_asInFile;
function hasSlots(component) {
const content = component.match(regex.slotsGeneric);
return content != null;
}
exports.hasSlots = hasSlots;
function getSlots_asInFile(component) {
const content = component.match(regex.slotsGeneric);
return content != null ? content : [];
}
exports.getSlots_asInFile = getSlots_asInFile;
function hasCSS(component) {
const content = component.match(regex.cssGeneric);
return content != null;
}
exports.hasCSS = hasCSS;
function getCSS_asInFile(component) {
const content = component.match(regex.cssGeneric);
return content != null ? content : [];
}
exports.getCSS_asInFile = getCSS_asInFile;