mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-23 00:45:16 +00:00
1 line
5.3 KiB
Plaintext
1 line
5.3 KiB
Plaintext
|
{"version":3,"file":"jss-plugin-rule-value-function.js","sources":["../../../node_modules/tiny-warning/dist/tiny-warning.esm.js","../src/index.js"],"sourcesContent":["var isProduction = process.env.NODE_ENV === 'production';\nfunction warning(condition, message) {\n if (!isProduction) {\n if (condition) {\n return;\n }\n\n var text = \"Warning: \" + message;\n\n if (typeof console !== 'undefined') {\n console.warn(text);\n }\n\n try {\n throw Error(text);\n } catch (x) {}\n }\n}\n\nexport default warning;\n","// @flow\nimport warning from 'tiny-warning'\nimport {\n createRule,\n type Rule,\n type JssStyle,\n type RuleOptions,\n type UpdateOptions,\n type StyleRule,\n type StyleSheet,\n type Plugin\n} from 'jss'\n\n// A symbol replacement.\nlet now = Date.now()\nconst fnValuesNs = `fnValues${now}`\nconst fnRuleNs = `fnStyle${++now}`\n\ntype StyleRuleWithRuleFunction = StyleRule & {[key: string]: Function}\n\ntype FunctionPlugin = () => Plugin\n\nconst functionPlugin: FunctionPlugin = () => ({\n onCreateRule(name?: string, decl: JssStyle, options: RuleOptions): Rule | null {\n if (typeof decl !== 'function') return null\n const rule: StyleRuleWithRuleFunction = (createRule(name, {}, options): any)\n rule[fnRuleNs] = decl\n return rule\n },\n\n onProcessStyle(style: JssStyle, rule: Rule): JssStyle {\n // We need to extract function values from the declaration, so that we can keep core unaware of them.\n // We need to do that only once.\n // We don't need to extract functions on each style update, since this can happen only once.\n // We don't support function values inside of function rules.\n if (fnValuesNs in rule || fnRuleNs in rule) return style\n\n const fnValues = {}\n for (const prop in style) {\n const value = style[prop]\n if (typeof value !== 'function') continue\n delete style[prop]\n fnValues[prop] = value\n }\n // $FlowFixMe[prop-missing]\n rule[fnValuesNs] = fnValues\n return style\n },\n\n onUpdate(data: Object, rule: Rule, sheet?: StyleSheet, options: UpdateOptions) {\n const styleRule: StyleRule = (rule: any)\n\n // $FlowFixMe[prop-missing]\n const fnRule = styleRule[fnRuleNs]\n\n // If we have a style function, the entire rule is dynamic and style object\n // will be returned from that function.\n if (fnRule) {\n // Empty object will remove all currently defined props\n // in case function rule returns a falsy value.\n styleRule.style = fnRule(data) || {}\n\n if (process.env.NODE_ENV === 'development') {\n for (const prop in styleRule.style) {\n if (typeof styleRule.style[prop] === 'function') {\n warning(false, '[JSS] Function values inside function rules are not supported.')\n break\n }\n }\n }\n }\n\n // $FlowFixMe[prop-missing]\n const fnValues = styleRule[fnValuesNs]\n\n // If we have a fn values map, it is a rule with function values.\n if (fnValues) {\n for (const prop in fnValues) {\n styleRule.prop(prop, fnValues[prop](data), options)\n }\n }\n }\n})\n\nexport default functionPlugin\n"],"names":["now","Date","fnValuesNs","fnRuleNs","functionPlugin","onCreateRule","name","decl","options","rule","createRule","onProcessStyle","style","fnValues","prop","value","onUpdate","data","sheet","styleRule","fnRule","warning"],"mappings":";;;;;;EACA,SAAS,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE;EACrC,EAAqB;EACrB,IAAI,IAAI,SAAS,EAAE;EACnB,MAAM,OAAO;EACb,KAAK;AACL;EACA,IAAI,IAAI,IAAI,GAAG,WAAW,GAAG,OAAO,CAAC;AACrC;EACA,IAAI,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE;EACxC,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;EACzB,KAAK;AACL;EACA,IAAI,IAAI;EACR,MAAM,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC;EACxB,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE;EAClB,GAAG;EACH;;ECHA,IAAIA,GAAG,GAAGC,IAAI,CAACD,GAAL,EAAV;EACA,IAAME,UAAU,gBAAcF,GAA9B;EACA,IAAMG,QAAQ,eAAa,EAAEH,GAA7B;;MAMMI,cAA8B,GAAG,SAAjCA,cAAiC;EAAA,SAAO;EAC5CC,IAAAA,YAD4C,wBAC/BC,IAD+B,EAChBC,IADgB,EACAC,OADA,EACmC;EAC7E,UAAI,OAAOD,IAAP,KAAgB,UAApB,EAAgC,OAAO,IAAP;EACh
|