UNPKG

@stylable/core

Version:

CSS for Components

32 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.globalValueFromFunctionNode = exports.globalValue = exports.GLOBAL_FUNC = exports.PROPERTY = void 0; exports.PROPERTY = `-st-global`; exports.GLOBAL_FUNC = 'st-global'; const globalValueRegExp = new RegExp(`^${exports.GLOBAL_FUNC}\\((.*?)\\)$`); function globalValue(str) { const match = str.match(globalValueRegExp); return match?.[1]; } exports.globalValue = globalValue; function globalValueFromFunctionNode(funcNode) { if (funcNode.value !== exports.GLOBAL_FUNC) { return; } let globalValue = ''; let unknownInput = false; for (const { type, value } of funcNode.nodes) { if (type === 'word') { globalValue = value; } else if (type === 'comment' || type === 'space') { // allow comments & spaced: do nothing } else { unknownInput = true; } } return unknownInput ? undefined : globalValue; } exports.globalValueFromFunctionNode = globalValueFromFunctionNode; //# sourceMappingURL=global.js.map