Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/jss/src/ drwxr-xr-x | |
| Viewing file: Select action/file-type: // @flow
import warning from 'tiny-warning'
import type StyleSheet from './StyleSheet'
import type {
Plugin,
Rule,
RuleOptions,
UpdateOptions,
JssStyle,
JssValue,
OnCreateRule,
OnProcessRule,
OnProcessStyle,
OnProcessSheet,
OnChangeValue,
OnUpdate
} from './types'
import type {StyleRule, BaseStyleRule} from './plugins/styleRule'
type Registry = {
onCreateRule: Array<OnCreateRule>,
onProcessRule: Array<OnProcessRule>,
onProcessStyle: Array<OnProcessStyle>,
onProcessSheet: Array<OnProcessSheet>,
onChangeValue: Array<OnChangeValue>,
onUpdate: Array<OnUpdate>
}
export default class PluginsRegistry {
plugins: {
internal: Array<Plugin>,
external: Array<Plugin>
} = {
internal: [],
external: []
}
registry: Registry
/**
* Call `onCreateRule` hooks and return an object if returned by a hook.
*/
onCreateRule(name: string, decl: JssStyle, options: RuleOptions): Rule | null {
for (let i = 0; i < this.registry.onCreateRule.length; i++) {
const rule = this.registry.onCreateRule[i](name, decl, options)
if (rule) return rule
}
return null
}
/**
* Call `onProcessRule` hooks.
*/
onProcessRule(rule: Rule): void {
if (rule.isProcessed) return
const {sheet} = rule.options
for (let i = 0; i < this.registry.onProcessRule.length; i++) {
this.registry.onProcessRule[i](rule, sheet)
}
if (rule.style) this.onProcessStyle(rule.style, rule, sheet)
rule.isProcessed = true
}
/**
* Call `onProcessStyle` hooks.
*/
onProcessStyle(style: JssStyle, rule: Rule, sheet?: StyleSheet): void {
for (let i = 0; i < this.registry.onProcessStyle.length; i++) {
// $FlowFixMe[prop-missing]
rule.style = this.registry.onProcessStyle[i](rule.style, rule, sheet)
}
}
/**
* Call `onProcessSheet` hooks.
*/
onProcessSheet(sheet: StyleSheet): void {
for (let i = 0; i < this.registry.onProcessSheet.length; i++) {
this.registry.onProcessSheet[i](sheet)
}
}
/**
* Call `onUpdate` hooks.
*/
onUpdate(data: Object, rule: Rule, sheet?: StyleSheet, options: UpdateOptions): void {
for (let i = 0; i < this.registry.onUpdate.length; i++) {
this.registry.onUpdate[i](data, rule, sheet, options)
}
}
/**
* Call `onChangeValue` hooks.
*/
onChangeValue(value: JssValue, prop: string, rule: StyleRule | BaseStyleRule): JssValue {
let processedValue = value
for (let i = 0; i < this.registry.onChangeValue.length; i++) {
processedValue = this.registry.onChangeValue[i](processedValue, prop, rule)
}
return processedValue
}
/**
* Register a plugin.
*/
use(newPlugin: Plugin, options: {queue: 'internal' | 'external'} = {queue: 'external'}): void {
const plugins = this.plugins[options.queue]
// Avoids applying same plugin twice, at least based on ref.
if (plugins.indexOf(newPlugin) !== -1) {
return
}
plugins.push(newPlugin)
this.registry = [...this.plugins.external, ...this.plugins.internal].reduce(
(registry: Registry, plugin: Plugin) => {
for (const name in plugin) {
if (name in registry) {
registry[name].push(plugin[name])
} else {
warning(false, `[JSS] Unknown hook "${name}".`)
}
}
return registry
},
{
onCreateRule: [],
onProcessRule: [],
onProcessStyle: [],
onProcessSheet: [],
onChangeValue: [],
onUpdate: []
}
)
}
}
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0071 ]-- |