style Dashboard

This commit is contained in:
Lieu Le
2019-09-13 11:27:52 +07:00
parent 558fb07261
commit 07322c9084
17151 changed files with 1686347 additions and 103 deletions

81
node_modules/rtlcss/lib/config-loader.js generated vendored Executable file
View File

@@ -0,0 +1,81 @@
/* global process */
'use strict'
var fs = require('fs')
var path = require('path')
var findup = require('findup')
var stripJSONComments = require('strip-json-comments')
var config = {}
var configSources = ['package.json', '.rtlcssrc', '.rtlcss.json']
module.exports.load = function (configFilePath, cwd, overrides) {
if (configFilePath) {
return override(
JSON.parse(
stripJSONComments(
fs.readFileSync(configFilePath, 'utf-8').trim())), overrides)
}
var directory = cwd || process.cwd()
config = loadConfig(directory)
if (!config) {
var evns = [process.env.USERPROFILE, process.env.HOMEPATH, process.env.HOME]
for (var x = 0; x < evns.length; x++) {
if (!evns[x]) {
continue
}
config = loadConfig(evns[x])
if (config) {
break
}
}
}
if (config) {
override(config, overrides)
}
return config
}
function loadConfig (dir) {
for (var x = 0; x < configSources.length; x++) {
var found
var source = configSources[x]
try {
found = findup.sync(dir, source)
} catch (e) {
continue
}
if (found) {
var configFilePath = path.normalize(path.join(found, source))
try {
config = JSON.parse(
stripJSONComments(
fs.readFileSync(configFilePath, 'utf-8').trim()))
} catch (e) {
throw new Error(e + ' ' + configFilePath)
}
if (source === 'package.json') {
config = config.rtlcssConfig
}
if (config) {
return config
}
}
}
}
function override (to, from) {
if (to && from) {
for (var p in from) {
if (typeof to[p] === 'object') {
override(to[p], from[p])
} else {
to[p] = from[p]
}
}
}
return to
}

86
node_modules/rtlcss/lib/config.js generated vendored Executable file
View File

@@ -0,0 +1,86 @@
'use strict'
var options
var config = {}
var corePlugin = require('./plugin.js')
function optionOrDefault (option, def) {
return option in options ? options[option] : def
}
function addKey (key, def) {
config[key] = optionOrDefault(key, def)
}
function main (opts, plugins, hooks) {
options = opts || {}
hooks = hooks || {}
addKey('autoRename', false)
addKey('autoRenameStrict', false)
addKey('blacklist', {})
addKey('clean', true)
addKey('greedy', false)
addKey('processUrls', false)
addKey('stringMap', [])
addKey('useCalc', false)
// default strings map
if (Array.isArray(config.stringMap)) {
var hasLeftRight, hasLtrRtl
for (var x = 0; x < config.stringMap.length; x++) {
var map = config.stringMap[x]
if (hasLeftRight && hasLtrRtl) {
break
} else if (map.name === 'left-right') {
hasLeftRight = true
} else if (map.name === 'ltr-rtl') {
hasLtrRtl = true
}
}
if (!hasLeftRight) {
config.stringMap.push({
'name': 'left-right',
'priority': 100,
'exclusive': false,
'search': ['left', 'Left', 'LEFT'],
'replace': ['right', 'Right', 'RIGHT'],
'options': { 'scope': '*', 'ignoreCase': false }
})
}
if (!hasLtrRtl) {
config.stringMap.push({
'name': 'ltr-rtl',
'priority': 100,
'exclusive': false,
'search': ['ltr', 'Ltr', 'LTR'],
'replace': ['rtl', 'Rtl', 'RTL'],
'options': { 'scope': '*', 'ignoreCase': false }
})
}
config.stringMap.sort(function (a, b) { return a.priority - b.priority })
}
// plugins
config.plugins = []
if (Array.isArray(plugins)) {
if (!plugins.some(function (plugin) { return plugin.name === 'rtlcss' })) {
config.plugins.push(corePlugin)
}
config.plugins = config.plugins.concat(plugins)
} else if (!plugins || plugins.name !== 'rtlcss') {
config.plugins.push(corePlugin)
}
config.plugins.sort(function (a, b) { return a.priority - b.priority })
// hooks
config.hooks = { pre: function () {}, post: function () {} }
if (typeof hooks.pre === 'function') {
config.hooks.pre = hooks.pre
}
if (typeof hooks.post === 'function') {
config.hooks.post = hooks.post
}
return config
}
module.exports.configure = main

43
node_modules/rtlcss/lib/directive-parser.js generated vendored Executable file
View File

@@ -0,0 +1,43 @@
module.exports = function (comment) {
var pos = 0
var value = comment.text
var prefix = value.charAt(0) === '!' ? '!rtl:' : 'rtl:'
var meta
if (value.indexOf(prefix) === 0) {
meta = {
'source': comment,
'name': '',
'param': '',
'begin': true,
'end': true,
'blacklist': false,
'preserve': false
}
value = value.slice(prefix.length)
pos = value.indexOf(':')
if (pos > -1) {
meta.name = value.slice(0, pos)
// begin/end are always true, unless one of them actually exists.
meta.begin = meta.name !== 'end'
meta.end = meta.name !== 'begin'
if (meta.name === 'begin' || meta.name === 'end') {
value = value.slice(meta.name.length + 1)
pos = value.indexOf(':')
if (pos > -1) {
meta.name = value.slice(0, pos)
value = value.slice(pos)
meta.param = value.slice(1)
} else {
meta.name = value
}
} else {
meta.param = value.slice(pos + 1)
}
} else {
meta.name = value
}
}
return meta
}

518
node_modules/rtlcss/lib/plugin.js generated vendored Executable file
View File

@@ -0,0 +1,518 @@
'use strict'
var config = require('./config.js')
var util = require('./util.js')
module.exports = {
'name': 'rtlcss',
'priority': 100,
'directives': {
'control': {
'ignore': {
'expect': { 'atrule': true, 'comment': true, 'decl': true, 'rule': true },
'endNode': null,
'begin': function (node, metadata, context) {
// find the ending node in case of self closing directive
if (!this.endNode && metadata.begin && metadata.end) {
var n = node
while (n && n.nodes) {
n = n.nodes[n.nodes.length - 1]
}
this.endNode = n
}
var prevent = true
if (node.type === 'comment' && (node.text === '!rtl:end:ignore' || node.text === 'rtl:end:ignore')) {
prevent = false
}
return prevent
},
'end': function (node, metadata, context) {
// end if:
// 1. block directive and the node is comment
// 2. self closing directive and node is endNode
if (metadata.begin !== metadata.end && node.type === 'comment' || metadata.begin && metadata.end && node === this.endNode) {
// clear ending node
this.endNode = null
return true
}
return false
}
},
'rename': {
'expect': {'rule': true},
'begin': function (node, metadata, context) {
node.selector = context.util.applyStringMap(node.selector, false)
return false
},
'end': function (node, context) {
return true
}
},
'raw': {
'expect': {'self': true},
'begin': function (node, metadata, context) {
var nodes = context.postcss.parse(metadata.param)
node.parent.insertBefore(node, nodes)
return true
},
'end': function (node, context) {
return true
}
},
'remove': {
'expect': {'atrule': true, 'rule': true, 'decl': true},
'begin': function (node, metadata, context) {
var prevent = false
switch (node.type) {
case 'atrule':
case 'rule':
case 'decl':
prevent = true
node.remove()
}
return prevent
},
'end': function (node, metadata, context) {
return true
}
},
'options': {
'expect': {'self': true},
'stack': [],
'begin': function (node, metadata, context) {
this.stack.push(util.extend({}, context.config))
var options
try {
options = JSON.parse(metadata.param)
} catch (e) {
throw node.error('Invlaid options object', { 'details': e })
}
context.config = config.configure(options, context.config.plugins)
context.util = util.configure(context.config)
return true
},
'end': function (node, metadata, context) {
var config = this.stack.pop()
if (config && !metadata.begin) {
context.config = config
context.util = util.configure(context.config)
}
return true
}
},
'config': {
'expect': {'self': true},
'expr': {
'fn': /function([^\(]*)\(([^\(\)]*?)\)[^\{]*\{([^]*)\}/ig,
'rx': /\/([^\/]*)\/(.*)/ig
},
'stack': [],
'begin': function (node, metadata, context) {
this.stack.push(util.extend({}, context.config))
var configuration
try {
configuration = eval('(' + metadata.param + ')') // eslint-disable-line no-eval
} catch (e) {
throw node.error('Invlaid config object', { 'details': e })
}
context.config = config.configure(configuration.options, configuration.plugins)
context.util = util.configure(context.config)
return true
},
'end': function (node, metadata, context) {
var config = this.stack.pop()
if (config && !metadata.begin) {
context.config = config
context.util = util.configure(context.config)
}
return true
}
}
},
'value': [
{
'name': 'ignore',
'action': function (decl, expr, context) {
return true
}
},
{
'name': 'prepend',
'action': function (decl, expr, context) {
var prefix = ''
decl.raws.value.raw.replace(expr, function (m, v) {
prefix += v
})
decl.value = decl.raws.value.raw = prefix + decl.raws.value.raw
return true
}
},
{
'name': 'append',
'action': function (decl, expr, context) {
decl.value = decl.raws.value.raw = decl.raws.value.raw.replace(expr, function (match, value) {
return match + value
})
return true
}
},
{
'name': 'insert',
'action': function (decl, expr, context) {
decl.value = decl.raws.value.raw = decl.raws.value.raw.replace(expr, function (match, value) {
return value + match
})
return true
}
},
{
'name': '',
'action': function (decl, expr, context) {
decl.raws.value.raw.replace(expr, function (match, value) {
decl.value = decl.raws.value.raw = value + match
})
return true
}
}
]
},
'processors': [
{
'name': 'variable',
'expr': /^--/im,
'action': function (prop, value) {
return { 'prop': prop, 'value': value }
}
},
{
'name': 'direction',
'expr': /direction/im,
'action': function (prop, value, context) {
return { 'prop': prop, 'value': context.util.swapLtrRtl(value) }
}
},
{
'name': 'left',
'expr': /left/im,
'action': function (prop, value, context) {
return { 'prop': prop.replace(this.expr, function () { return 'right' }), 'value': value }
}
},
{
'name': 'right',
'expr': /right/im,
'action': function (prop, value, context) {
return { 'prop': prop.replace(this.expr, function () { return 'left' }), 'value': value }
}
},
{
'name': 'four-value syntax',
'expr': /^(margin|padding|border-(color|style|width))$/ig,
'cache': null,
'action': function (prop, value, context) {
if (this.cache === null) {
this.cache = {
'match': /[^\s\uFFFD]+/g
}
}
var state = context.util.guardFunctions(value)
var result = state.value.match(this.cache.match)
if (result && result.length === 4 && (state.store.length > 0 || result[1] !== result[3])) {
var i = 0
state.value = state.value.replace(this.cache.match, function () {
return result[(4 - i++) % 4]
})
}
return { 'prop': prop, 'value': context.util.unguardFunctions(state) }
}
},
{
'name': 'border radius',
'expr': /border-radius/ig,
'cache': null,
'flip': function (value) {
var parts = value.match(this.cache.match)
var i
if (parts) {
switch (parts.length) {
case 2:
i = 1
if (parts[0] !== parts[1]) {
value = value.replace(this.cache.match, function () {
return parts[i--]
})
}
break
case 3:
// preserve leading whitespace.
value = value.replace(this.cache.white, function (m) {
return m + parts[1] + ' '
})
break
case 4:
i = 0
if (parts[0] !== parts[1] || parts[2] !== parts[3]) {
value = value.replace(this.cache.match, function () {
return parts[(5 - i++) % 4]
})
}
break
}
}
return value
},
'action': function (prop, value, context) {
if (this.cache === null) {
this.cache = {
'match': /[^\s\uFFFD]+/g,
'slash': /[^\/]+/g,
'white': /(^\s*)/
}
}
var state = context.util.guardFunctions(value)
state.value = state.value.replace(this.cache.slash, function (m) {
return this.flip(m)
}.bind(this))
return { 'prop': prop, 'value': context.util.unguardFunctions(state) }
}
},
{
'name': 'shadow',
'expr': /shadow/ig,
'cache': null,
'action': function (prop, value, context) {
if (this.cache === null) {
this.cache = {
'replace': /[^,]+/g
}
}
var colorSafe = context.util.guardHexColors(value)
var funcSafe = context.util.guardFunctions(colorSafe.value)
funcSafe.value = funcSafe.value.replace(this.cache.replace, function (m) { return context.util.negate(m) })
colorSafe.value = context.util.unguardFunctions(funcSafe)
return { 'prop': prop, 'value': context.util.unguardHexColors(colorSafe) }
}
},
{
'name': 'transform origin',
'expr': /transform-origin/ig,
'cache': null,
'flip': function (value, context) {
if (value === '0') {
value = '100%'
} else if (value.match(this.cache.percent)) {
value = context.util.complement(value)
}
return value
},
'action': function (prop, value, context) {
if (this.cache === null) {
this.cache = {
'match': context.util.regex(['calc', 'percent', 'length'], 'g'),
'percent': context.util.regex(['calc', 'percent'], 'i'),
'xKeyword': /(left|right)/i
}
}
if (value.match(this.cache.xKeyword)) {
value = context.util.swapLeftRight(value)
} else {
var state = context.util.guardFunctions(value)
var parts = state.value.match(this.cache.match)
if (parts && parts.length > 0) {
parts[0] = this.flip(parts[0], context)
state.value = state.value.replace(this.cache.match, function () { return parts.shift() })
value = context.util.unguardFunctions(state)
}
}
return { 'prop': prop, 'value': value }
}
},
{
'name': 'transform',
'expr': /^(?!text\-).*?transform$/ig,
'cache': null,
'flip': function (value, process, context) {
var i = 0
return value.replace(this.cache.unit, function (num) {
return process(++i, num)
})
},
'flipMatrix': function (value, context) {
return this.flip(value, function (i, num) {
if (i === 2 || i === 3 || i === 5) {
return context.util.negate(num)
}
return num
}, context)
},
'flipMatrix3D': function (value, context) {
return this.flip(value, function (i, num) {
if (i === 2 || i === 4 || i === 5 || i === 13) {
return context.util.negate(num)
}
return num
}, context)
},
'flipRotate3D': function (value, context) {
return this.flip(value, function (i, num) {
if (i === 2 || i === 4) {
return context.util.negate(num)
}
return num
}, context)
},
'action': function (prop, value, context) {
if (this.cache === null) {
this.cache = {
'negatable': /((translate)(x|3d)?|rotate(z)?)$/ig,
'unit': context.util.regex(['calc', 'number'], 'g'),
'matrix': /matrix$/i,
'matrix3D': /matrix3d$/i,
'skewXY': /skew(x|y)?$/i,
'rotate3D': /rotate3d$/i
}
}
var state = context.util.guardFunctions(value)
return {
'prop': prop,
'value': context.util.unguardFunctions(state, function (v, n) {
if (n.length) {
if (n.match(this.cache.matrix3D)) {
v = this.flipMatrix3D(v, context)
} else if (n.match(this.cache.matrix)) {
v = this.flipMatrix(v, context)
} else if (n.match(this.cache.rotate3D)) {
v = this.flipRotate3D(v, context)
} else if (n.match(this.cache.skewXY)) {
v = context.util.negateAll(v)
} else if (n.match(this.cache.negatable)) {
v = context.util.negate(v)
}
}
return v
}.bind(this))
}
}
},
{
'name': 'transition',
'expr': /transition(-property)?$/i,
'action': function (prop, value, context) {
return { 'prop': prop, 'value': context.util.swapLeftRight(value) }
}
},
{
'name': 'background',
'expr': /background(-position(-x)?|-image)?$/i,
'cache': null,
'flip': function (value, context, isPosition) {
var state = util.saveTokens(value, true)
var parts = state.value.match(this.cache.match)
if (parts && parts.length > 0) {
var keywords = (state.value.match(this.cache.position) || '').length
if (isPosition && (/* edge offsets */ parts.length >= 3 || /* keywords only */ keywords === 2)) {
state.value = util.swapLeftRight(state.value)
} else {
parts[0] = parts[0] === '0'
? '100%'
: (parts[0].match(this.cache.percent)
? context.util.complement(parts[0])
: (parts[0].match(this.cache.length)
? this.flipLength(parts[0], context)
: context.util.swapLeftRight(parts[0])))
state.value = state.value.replace(this.cache.match, function () { return parts.shift() })
}
}
return util.restoreTokens(state)
},
'flipLength': function (value, context) {
if (context.config.useCalc) {
return 'calc(100% - ' + value + ')'
}
return context.util.swapLeftRight(value)
},
'update': function (context, value, name) {
if (name.match(this.cache.gradient)) {
value = context.util.swapLeftRight(value)
if (value.match(this.cache.angle)) {
value = context.util.negate(value)
}
} else if (context.config.processUrls === true || context.config.processUrls.decl === true && name.match(this.cache.url)) {
value = context.util.applyStringMap(value, true)
}
return value
},
'action': function (prop, value, context) {
if (this.cache === null) {
this.cache = {
'match': context.util.regex(['position', 'percent', 'length', 'calc'], 'ig'),
'percent': context.util.regex(['calc', 'percent'], 'i'),
'position': context.util.regex(['position'], 'g'),
'length': context.util.regex(['length'], 'gi'),
'gradient': /gradient$/i,
'angle': /\d+(deg|g?rad|turn)/i,
'url': /^url/i
}
}
var colorSafe = context.util.guardHexColors(value)
var funcSafe = context.util.guardFunctions(colorSafe.value)
var parts = funcSafe.value.split(',')
var lprop = prop.toLowerCase()
if (lprop !== 'background-image') {
var isPosition = lprop === 'background-position'
for (var x = 0; x < parts.length; x++) {
parts[x] = this.flip(parts[x], context, isPosition)
}
}
funcSafe.value = parts.join(',')
colorSafe.value = context.util.unguardFunctions(funcSafe, this.update.bind(this, context))
return {
'prop': prop,
'value': context.util.unguardHexColors(colorSafe)
}
}
},
{
'name': 'keyword',
'expr': /float|clear|text-align/i,
'action': function (prop, value, context) {
return { 'prop': prop, 'value': context.util.swapLeftRight(value) }
}
},
{
'name': 'cursor',
'expr': /cursor/i,
'cache': null,
'update': function (context, value, name) {
if (context.config.processUrls === true || context.config.processUrls.decl === true && name.match(this.cache.url)) {
value = context.util.applyStringMap(value, true)
}
return value
},
'flip': function (value) {
return value.replace(this.cache.replace, function (s, m) {
return s.replace(m, m.replace(this.cache.e, '*').replace(this.cache.w, 'e').replace(this.cache.star, 'w'))
}.bind(this))
},
'action': function (prop, value, context) {
if (this.cache === null) {
this.cache = {
'replace': /\b(ne|nw|se|sw|nesw|nwse)-resize/ig,
'url': /^url/i,
'e': /e/i,
'w': /w/i,
'star': /\*/i
}
}
var state = context.util.guardFunctions(value)
var parts = state.value.split(',')
for (var x = 0; x < parts.length; x++) {
parts[x] = this.flip(parts[x])
}
state.value = parts.join(',')
return {
'prop': prop,
'value': context.util.unguardFunctions(state, this.update.bind(this, context))
}
}
}
]
}

189
node_modules/rtlcss/lib/rtlcss.js generated vendored Executable file
View File

@@ -0,0 +1,189 @@
/*
* RTLCSS https://github.com/MohammadYounes/rtlcss
* Framework for transforming Cascading Style Sheets (CSS) from Left-To-Right (LTR) to Right-To-Left (RTL).
* Copyright 2017 Mohammad Younes.
* Licensed under MIT <http://opensource.org/licenses/mit-license.php>
* */
'use strict'
var postcss = require('postcss')
var state = require('./state.js')
var config = require('./config.js')
var util = require('./util.js')
module.exports = postcss.plugin('rtlcss', function (options, plugins, hooks) {
var configuration = config.configure(options, plugins, hooks)
var context = {
// provides access to postcss
'postcss': postcss,
// provides access to the current configuration
'config': configuration,
// provides access to utilities object
'util': util.configure(configuration)
}
return function (css, result) {
var flipped = 0
var toBeRenamed = {}
context.config.hooks.pre(css, postcss)
css.walk(function (node) {
var prevent = false
state.walk(function (current) {
// check if current directive is expecting this node
if (!current.metadata.blacklist && current.directive.expect[node.type]) {
// perform action and prevent further processing if result equals true
if (current.directive.begin(node, current.metadata, context)) {
prevent = true
}
// if should end? end it.
if (current.metadata.end && current.directive.end(node, current.metadata, context)) {
state.pop(current)
}
}
})
if (prevent === false) {
switch (node.type) {
case 'atrule':
// @rules requires url flipping only
if (context.config.processUrls === true || context.config.processUrls.atrule === true) {
var params = context.util.applyStringMap(node.params, true)
node.params = params
}
break
case 'comment':
state.parse(node, result, function (current) {
var push = true
if (current.directive === null) {
current.preserve = !context.config.clean
context.util.each(context.config.plugins, function (plugin) {
var blacklist = context.config.blacklist[plugin.name]
if (blacklist && blacklist[current.metadata.name] === true) {
current.metadata.blacklist = true
if (current.metadata.end) {
push = false
}
if (current.metadata.begin) {
result.warn('directive "' + plugin.name + '.' + current.metadata.name + '" is blacklisted.', {node: current.source})
}
// break each
return false
}
current.directive = plugin.directives.control[current.metadata.name]
if (current.directive) {
// break each
return false
}
})
}
if (current.directive) {
if (!current.metadata.begin && current.metadata.end) {
if (current.directive.end(node, current.metadata, context)) {
state.pop(current)
}
push = false
} else if (current.directive.expect.self && current.directive.begin(node, current.metadata, context)) {
if (current.metadata.end && current.directive.end(node, current.metadata, context)) {
push = false
}
}
} else if (!current.metadata.blacklist) {
push = false
result.warn('unsupported directive "' + current.metadata.name + '".', {node: current.source})
}
return push
})
break
case 'decl':
// if broken by a matching value directive .. break
if (!context.util.each(context.config.plugins,
function (plugin) {
return context.util.each(plugin.directives.value, function (directive) {
if (node.raws.value && node.raws.value.raw) {
var expr = context.util.regexDirective(directive.name)
if (expr.test(node.raws.value.raw)) {
expr.lastIndex = 0
if (directive.action(node, expr, context)) {
if (context.config.clean) {
node.value = node.raws.value.raw = context.util.trimDirective(node.raws.value.raw)
}
flipped++
// break
return false
}
}
}
})
})) break
// loop over all plugins/property processors
context.util.each(context.config.plugins, function (plugin) {
return context.util.each(plugin.processors, function (directive) {
if (node.prop.match(directive.expr)) {
var raw = node.raws.value && node.raws.value.raw ? node.raws.value.raw : node.value
var state = context.util.saveComments(raw)
var pair = directive.action(node.prop, state.value, context)
state.value = pair.value
pair.value = context.util.restoreComments(state)
if (pair.prop !== node.prop || pair.value !== raw) {
flipped++
node.prop = pair.prop
node.value = pair.value
}
// match found, break
return false
}
})
})
// if last decl, apply auto rename
// decl. may be found inside @rules
if (context.config.autoRename && !flipped && node.parent.type === 'rule' && context.util.isLastOfType(node)) {
var renamed = context.util.applyStringMap(node.parent.selector)
if (context.config.autoRenameStrict === true) {
var pair = toBeRenamed[renamed]
if (pair) {
pair.selector = node.parent.selector
node.parent.selector = renamed
} else {
toBeRenamed[node.parent.selector] = node.parent
}
} else {
node.parent.selector = renamed
}
}
break
case 'rule':
// new rule, reset flipped decl count to zero
flipped = 0
break
}
}
})
state.walk(function (item) {
result.warn('unclosed directive "' + item.metadata.name + '".', {node: item.source})
})
Object.keys(toBeRenamed).forEach(function (key) {
result.warn('renaming skipped due to lack of a matching pair.', {node: toBeRenamed[key]})
})
context.config.hooks.post(css, postcss)
}
})
/**
* Creates a new RTLCSS instance, process the input and return its result.
* @param {String} css A string containing input CSS.
* @param {Object} options An object containing RTLCSS settings.
* @param {Object|Array} plugins An array containing a list of RTLCSS plugins or a single RTLCSS plugin.
* @param {Object} hooks An object containing pre/post hooks.
* @returns {String} A string contining the RTLed css.
*/
module.exports.process = function (css, options, plugins, hooks) {
return postcss([this(options, plugins, hooks)]).process(css).css
}
/**
* Creates a new instance of RTLCSS using the passed configuration object
* @param {Object} config An object containing RTLCSS options, plugins and hooks.
* @returns {Object} A new RTLCSS instance.
*/
module.exports.configure = function (config) {
config = config || {}
return postcss([this(config.options, config.plugins, config.hooks)])
}

47
node_modules/rtlcss/lib/state.js generated vendored Executable file
View File

@@ -0,0 +1,47 @@
'use strict'
var directiveParser = require('./directive-parser.js')
module.exports = {
stack: [],
pop: function (current) {
var index = this.stack.indexOf(current)
if (index !== -1) {
this.stack.splice(index, 1)
}
if (!current.preserve) {
current.source.remove()
}
},
parse: function (node, lazyResult, callback) {
var current
var metadata = directiveParser(node)
if (metadata) {
if (!metadata.begin && metadata.end) {
this.walk(function (item) {
if (metadata.name === item.metadata.name) {
this.pop(item)
current = {'metadata': metadata, 'directive': item.directive, 'source': node, 'preserve': item.preserve}
return false
}
}.bind(this))
} else {
current = {'metadata': metadata, 'directive': null, 'source': node, 'preserve': null}
}
if (current === undefined) {
lazyResult.warn('found end "' + metadata.name + '" without a matching begin.', {node: node})
} else if (callback(current)) {
this.stack.push(current)
} else if (!current.preserve) {
current.source.remove()
}
}
},
walk: function (callback) {
var len = this.stack.length
while (--len > -1) {
if (!callback(this.stack[len])) {
break
}
}
}
}

264
node_modules/rtlcss/lib/util.js generated vendored Executable file
View File

@@ -0,0 +1,264 @@
'use strict'
var config
var CHAR_COMMENT_REPLACEMENT = '\uFFFD' // <20>
var CHAR_TOKEN_REPLACEMENT = '\u00A4'// ¤
var CHAR_TOKEN_START = '\u00AB' // «
var CHAR_TOKEN_END = '\u00BB' // »
var REGEX_COMMENT_REPLACEMENT = new RegExp(CHAR_COMMENT_REPLACEMENT, 'ig')
var REGEX_TOKEN_REPLACEMENT = new RegExp(CHAR_TOKEN_REPLACEMENT, 'ig')
var PATTERN_NUMBER = '\\-?(\\d*?\\.\\d+|\\d+)'
var PATTERN_NUMBER_WITH_CALC = '(calc' + CHAR_TOKEN_REPLACEMENT + ')|(' + PATTERN_NUMBER + ')(?!d\\()'
var PATTERN_TOKEN = CHAR_TOKEN_START + '\\d+:\\d+' + CHAR_TOKEN_END // «offset:index»
var PATTERN_TOKEN_WITH_NAME = '\\w*?' + CHAR_TOKEN_START + '\\d+:\\d+' + CHAR_TOKEN_END // «offset:index»
var REGEX_COMMENT = /\/\*[^]*?\*\//igm // none-greedy
var REGEX_DIRECTIVE = /\/\*(?:!)?rtl:[^]*?\*\//img
var REGEX_ESCAPE = /[.*+?^${}()|[\]\\]/g
var REGEX_FUNCTION = /\([^\(\)]+\)/i
var REGEX_HEX_COLOR = /#[a-f0-9]{3,6}/ig
var REGEX_CALC = /calc/
var REGEX_TOKENS = new RegExp(PATTERN_TOKEN, 'ig')
var REGEX_TOKENS_WITH_NAME = new RegExp(PATTERN_TOKEN_WITH_NAME, 'ig')
var REGEX_COMPLEMENT = new RegExp(PATTERN_NUMBER_WITH_CALC, 'i')
var REGEX_NEGATE_ALL = new RegExp(PATTERN_NUMBER_WITH_CALC, 'ig')
var REGEX_NEGATE_ONE = new RegExp(PATTERN_NUMBER_WITH_CALC, 'i')
var DEFAULT_STRING_MAP_OPTIONS = { scope: '*', ignoreCase: true }
var TOKEN_ID = 0
function compare (what, to, ignoreCase) {
if (ignoreCase) {
return what.toLowerCase() === to.toLowerCase()
}
return what === to
}
function escapeRegExp (string) {
return string.replace(REGEX_ESCAPE, '\\$&')
}
module.exports = {
extend: function (dest, src) {
if (typeof dest === 'undefined' || typeof dest !== 'object') {
dest = {}
}
for (var prop in src) {
if (!dest.hasOwnProperty(prop)) {
dest[prop] = src[prop]
}
}
return dest
},
swap: function (value, a, b, options) {
var expr = escapeRegExp(a) + '|' + escapeRegExp(b)
options = options || DEFAULT_STRING_MAP_OPTIONS
var greedy = options.hasOwnProperty('greedy') ? options.greedy : config.greedy
if (!greedy) {
expr = '\\b(' + expr + ')\\b'
}
var flags = options.ignoreCase ? 'img' : 'mg'
return value.replace(new RegExp(expr, flags), function (m) { return compare(m, a, options.ignoreCase) ? b : a })
},
swapLeftRight: function (value) {
return this.swap(value, 'left', 'right')
},
swapLtrRtl: function (value) {
return this.swap(value, 'ltr', 'rtl')
},
applyStringMap: function (value, isUrl) {
var result = value
for (var x = 0; x < config.stringMap.length; x++) {
var map = config.stringMap[x]
var options = this.extend(map.options, DEFAULT_STRING_MAP_OPTIONS)
if (options.scope === '*' || (isUrl && options.scope === 'url') || (!isUrl && options.scope === 'selector')) {
if (Array.isArray(map.search) && Array.isArray(map.replace)) {
for (var mapIndex = 0; mapIndex < map.search.length; mapIndex++) {
result = this.swap(result, map.search[mapIndex], map.replace[mapIndex % map.search.length], options)
}
} else {
result = this.swap(result, map.search, map.replace, options)
}
if (map.exclusive === true) {
break
}
}
}
return result
},
negate: function (value) {
var state = this.saveTokens(value)
state.value = state.value.replace(REGEX_NEGATE_ONE, function (num) {
return REGEX_TOKEN_REPLACEMENT.test(num) ? num.replace(REGEX_TOKEN_REPLACEMENT, function (m) { return '(-1*' + m + ')' }) : parseFloat(num, 10) * -1
})
return this.restoreTokens(state)
},
negateAll: function (value) {
var state = this.saveTokens(value)
state.value = state.value.replace(REGEX_NEGATE_ALL, function (num) {
return REGEX_TOKEN_REPLACEMENT.test(num) ? num.replace(REGEX_TOKEN_REPLACEMENT, function (m) { return '(-1*' + m + ')' }) : parseFloat(num, 10) * -1
})
return this.restoreTokens(state)
},
complement: function (value) {
var state = this.saveTokens(value)
state.value = state.value.replace(REGEX_COMPLEMENT, function (num) {
return REGEX_TOKEN_REPLACEMENT.test(num) ? num.replace(REGEX_TOKEN_REPLACEMENT, function (m) { return '(100% - ' + m + ')' }) : 100 - parseFloat(num, 10)
})
return this.restoreTokens(state)
},
save: function (what, who, replacement, restorer, exclude) {
var state = {
value: who,
store: [],
replacement: replacement,
restorer: restorer
}
state.value = state.value.replace(what, function (c) {
if (exclude && c.match(exclude)) {
return c
} else {
state.store.push(c); return state.replacement
}
})
return state
},
restore: function (state) {
var index = 0
var result = state.value.replace(state.restorer, function () {
return state.store[index++]
})
state.store.length = 0
return result
},
saveComments: function (value) {
return this.save(REGEX_COMMENT, value, CHAR_COMMENT_REPLACEMENT, REGEX_COMMENT_REPLACEMENT)
},
restoreComments: function (state) {
return this.restore(state)
},
saveTokens: function (value, excludeCalc) {
return excludeCalc === true
? this.save(REGEX_TOKENS_WITH_NAME, value, CHAR_TOKEN_REPLACEMENT, REGEX_TOKEN_REPLACEMENT, REGEX_CALC)
: this.save(REGEX_TOKENS, value, CHAR_TOKEN_REPLACEMENT, REGEX_TOKEN_REPLACEMENT)
},
restoreTokens: function (state) {
return this.restore(state)
},
guard: function (what, who, indexed) {
var state = {
value: who,
store: [],
offset: TOKEN_ID++,
token: CHAR_TOKEN_START + TOKEN_ID,
indexed: indexed === true
}
if (state.indexed === true) {
while (what.test(state.value)) {
state.value = state.value.replace(what, function (m) { state.store.push(m); return state.token + ':' + state.store.length + CHAR_TOKEN_END })
}
} else {
state.value = state.value.replace(what, function (m) { state.store.push(m); return state.token + CHAR_TOKEN_END })
}
return state
},
unguard: function (state, callback) {
if (state.indexed === true) {
var detokenizer = new RegExp('(\\w*?)' + state.token + ':(\\d+)' + CHAR_TOKEN_END, 'i')
while (detokenizer.test(state.value)) {
state.value = state.value.replace(detokenizer, function (match, name, index) {
var value = state.store[index - 1]
if (typeof callback === 'function') {
return name + callback(value, name)
}
return name + value
})
}
return state.value
} else {
return state.value.replace(new RegExp('(\\w*?)' + state.token + CHAR_TOKEN_END, 'i'), function (match, name) {
var value = state.store.shift()
if (typeof callback === 'function') {
return name + callback(value, name)
}
return name + value
})
}
},
guardHexColors: function (value) {
return this.guard(REGEX_HEX_COLOR, value, true)
},
unguardHexColors: function (state, callback) {
return this.unguard(state, callback)
},
guardFunctions: function (value) {
return this.guard(REGEX_FUNCTION, value, true)
},
unguardFunctions: function (state, callback) {
return this.unguard(state, callback)
},
trimDirective: function (value) {
return value.replace(REGEX_DIRECTIVE, '')
},
regexCache: {},
regexDirective: function (name) {
// /(?:\/\*(?:!)?rtl:ignore(?::)?)([^]*?)(?:\*\/)/img
this.regexCache[name] = this.regexCache[name] || new RegExp('(?:\\/\\*(?:!)?rtl:' + (name ? escapeRegExp(name) + '(?::)?' : '') + ')([^]*?)(?:\\*\\/)', 'img')
return this.regexCache[name]
},
regex: function (what, options) {
what = what || []
var expression = ''
for (var x = 0; x < what.length; x++) {
switch (what[x]) {
case 'percent':
expression += '|(' + PATTERN_NUMBER + '%)'
break
case 'length':
expression += '|(' + PATTERN_NUMBER + ')(?:ex|ch|r?em|vh|vw|vmin|vmax|px|mm|cm|in|pt|pc)?'
break
case 'number':
expression += '|(' + PATTERN_NUMBER + ')'
break
case 'position':
expression += '|(left|center|right|top|bottom)'
break
case 'calc':
expression += '|(calc' + PATTERN_TOKEN + ')'
break
}
}
return new RegExp(expression.slice(1), options)
},
isLastOfType: function (node) {
var isLast = true
var next = node.next()
while (next) {
if (next && next.type === node.type) {
isLast = false
break
}
next = next.next()
}
return isLast
},
/**
* Simple breakable each: returning false in the callback will break the loop
* returns false if the loop was broken, otherwise true
*/
each: function (array, callback) {
for (var len = 0; len < array.length; len++) {
if (callback(array[len]) === false) {
return false
}
}
return true
}
}
module.exports.configure = function (configuration) {
config = configuration
return this
}