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/utils/ drwxr-xr-x | |
| Viewing file: Select action/file-type: // @flow
import warning from 'tiny-warning'
import type {Rule} from '../types'
import StyleSheet from '../StyleSheet'
import moduleId from './moduleId'
const maxRules = 1e10
export type CreateGenerateIdOptions = {|
minify: boolean
|}
export type GenerateId = (rule: Rule, sheet?: StyleSheet) => string
export type CreateGenerateId = (options?: CreateGenerateIdOptions) => GenerateId
/**
* Returns a function which generates unique class names based on counters.
* When new generator function is created, rule counter is reseted.
* We need to reset the rule counter for SSR for each request.
*/
const createGenerateId: CreateGenerateId = (options = {}) => {
let ruleCounter = 0
const generateId: GenerateId = (rule, sheet) => {
ruleCounter += 1
if (ruleCounter > maxRules) {
warning(false, `[JSS] You might have a memory leak. Rule counter is at ${ruleCounter}.`)
}
let jssId = ''
let prefix = ''
if (sheet) {
if (sheet.options.classNamePrefix) {
prefix = sheet.options.classNamePrefix
}
if (sheet.options.jss.id != null) {
jssId = String(sheet.options.jss.id)
}
}
if (options.minify) {
// Using "c" because a number can't be the first char in a class name.
return `${prefix || 'c'}${moduleId}${jssId}${ruleCounter}`
}
return `${prefix + rule.key}-${moduleId}${jssId ? `-${jssId}` : ''}-${ruleCounter}`
}
return generateId
}
export default createGenerateId
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0421 ]-- |