worked on GarageApp stuff
This commit is contained in:
parent
60aaf17af3
commit
eb606572b0
51919 changed files with 2168177 additions and 18 deletions
1
node_modules/@emotion/cache/src/conditions/false.ts
generated
vendored
Normal file
1
node_modules/@emotion/cache/src/conditions/false.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export default false
|
||||
1
node_modules/@emotion/cache/src/conditions/is-browser.ts
generated
vendored
Normal file
1
node_modules/@emotion/cache/src/conditions/is-browser.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export default typeof document !== 'undefined'
|
||||
1
node_modules/@emotion/cache/src/conditions/true.ts
generated
vendored
Normal file
1
node_modules/@emotion/cache/src/conditions/true.ts
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
export default true
|
||||
259
node_modules/@emotion/cache/src/index.ts
generated
vendored
Normal file
259
node_modules/@emotion/cache/src/index.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
import { StyleSheet } from '@emotion/sheet'
|
||||
import type { EmotionCache, SerializedStyles } from '@emotion/utils'
|
||||
import {
|
||||
serialize,
|
||||
compile,
|
||||
middleware,
|
||||
rulesheet,
|
||||
stringify,
|
||||
COMMENT
|
||||
} from 'stylis'
|
||||
import type { Element as StylisElement } from 'stylis'
|
||||
import weakMemoize from '@emotion/weak-memoize'
|
||||
import memoize from '@emotion/memoize'
|
||||
import isDevelopment from '#is-development'
|
||||
import isBrowser from '#is-browser'
|
||||
import {
|
||||
compat,
|
||||
removeLabel,
|
||||
createUnsafeSelectorsAlarm,
|
||||
incorrectImportAlarm
|
||||
} from './stylis-plugins'
|
||||
import { prefixer } from './prefixer'
|
||||
import { StylisPlugin } from './types'
|
||||
|
||||
export interface Options {
|
||||
nonce?: string
|
||||
stylisPlugins?: Array<StylisPlugin>
|
||||
key: string
|
||||
container?: Node
|
||||
speedy?: boolean
|
||||
/** @deprecate use `insertionPoint` instead */
|
||||
prepend?: boolean
|
||||
insertionPoint?: HTMLElement
|
||||
}
|
||||
|
||||
let getServerStylisCache = isBrowser
|
||||
? undefined
|
||||
: weakMemoize(() => memoize<Record<string, string>>(() => ({})))
|
||||
|
||||
const defaultStylisPlugins = [prefixer]
|
||||
|
||||
let getSourceMap: ((styles: string) => string | undefined) | undefined
|
||||
if (isDevelopment) {
|
||||
let sourceMapPattern =
|
||||
/\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g
|
||||
getSourceMap = styles => {
|
||||
let matches = styles.match(sourceMapPattern)
|
||||
if (!matches) return
|
||||
return matches[matches.length - 1]
|
||||
}
|
||||
}
|
||||
|
||||
let createCache = (options: Options): EmotionCache => {
|
||||
let key = options.key
|
||||
|
||||
if (isDevelopment && !key) {
|
||||
throw new Error(
|
||||
"You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\n" +
|
||||
`If multiple caches share the same key they might "fight" for each other's style elements.`
|
||||
)
|
||||
}
|
||||
|
||||
if (isBrowser && key === 'css') {
|
||||
const ssrStyles = document.querySelectorAll(
|
||||
`style[data-emotion]:not([data-s])`
|
||||
)
|
||||
|
||||
// get SSRed styles out of the way of React's hydration
|
||||
// document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
|
||||
// note this very very intentionally targets all style elements regardless of the key to ensure
|
||||
// that creating a cache works inside of render of a React component
|
||||
Array.prototype.forEach.call(ssrStyles, (node: HTMLStyleElement) => {
|
||||
// we want to only move elements which have a space in the data-emotion attribute value
|
||||
// because that indicates that it is an Emotion 11 server-side rendered style elements
|
||||
// while we will already ignore Emotion 11 client-side inserted styles because of the :not([data-s]) part in the selector
|
||||
// Emotion 10 client-side inserted styles did not have data-s (but importantly did not have a space in their data-emotion attributes)
|
||||
// so checking for the space ensures that loading Emotion 11 after Emotion 10 has inserted some styles
|
||||
// will not result in the Emotion 10 styles being destroyed
|
||||
const dataEmotionAttribute = node.getAttribute('data-emotion')!
|
||||
if (dataEmotionAttribute.indexOf(' ') === -1) {
|
||||
return
|
||||
}
|
||||
|
||||
document.head.appendChild(node)
|
||||
node.setAttribute('data-s', '')
|
||||
})
|
||||
}
|
||||
|
||||
const stylisPlugins = options.stylisPlugins || defaultStylisPlugins
|
||||
|
||||
if (isDevelopment) {
|
||||
if (/[^a-z-]/.test(key)) {
|
||||
throw new Error(
|
||||
`Emotion key must only contain lower case alphabetical characters and - but "${key}" was passed`
|
||||
)
|
||||
}
|
||||
}
|
||||
let inserted: EmotionCache['inserted'] = {}
|
||||
let container: Node
|
||||
const nodesToHydrate: HTMLStyleElement[] = []
|
||||
if (isBrowser) {
|
||||
container = options.container || document.head
|
||||
|
||||
Array.prototype.forEach.call(
|
||||
// this means we will ignore elements which don't have a space in them which
|
||||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements
|
||||
document.querySelectorAll(`style[data-emotion^="${key} "]`),
|
||||
(node: HTMLStyleElement) => {
|
||||
const attrib = node.getAttribute(`data-emotion`)!.split(' ')
|
||||
for (let i = 1; i < attrib.length; i++) {
|
||||
inserted[attrib[i]] = true
|
||||
}
|
||||
nodesToHydrate.push(node)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
let insert: (
|
||||
selector: string,
|
||||
serialized: SerializedStyles,
|
||||
sheet: StyleSheet,
|
||||
shouldCache: boolean
|
||||
) => string | void
|
||||
const omnipresentPlugins = [compat, removeLabel]
|
||||
|
||||
if (isDevelopment) {
|
||||
omnipresentPlugins.push(
|
||||
createUnsafeSelectorsAlarm({
|
||||
get compat() {
|
||||
return cache.compat
|
||||
}
|
||||
}),
|
||||
incorrectImportAlarm
|
||||
)
|
||||
}
|
||||
|
||||
if (!getServerStylisCache) {
|
||||
let currentSheet: Pick<StyleSheet, 'insert'>
|
||||
|
||||
const finalizingPlugins = [
|
||||
stringify,
|
||||
isDevelopment
|
||||
? (element: StylisElement) => {
|
||||
if (!element.root) {
|
||||
if (element.return) {
|
||||
currentSheet.insert(element.return)
|
||||
} else if (element.value && element.type !== COMMENT) {
|
||||
// insert empty rule in non-production environments
|
||||
// so @emotion/jest can grab `key` from the (JS)DOM for caches without any rules inserted yet
|
||||
currentSheet.insert(`${element.value}{}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
: rulesheet(rule => {
|
||||
currentSheet.insert(rule)
|
||||
})
|
||||
]
|
||||
|
||||
const serializer = middleware(
|
||||
omnipresentPlugins.concat(stylisPlugins, finalizingPlugins)
|
||||
)
|
||||
const stylis = (styles: string) => serialize(compile(styles), serializer)
|
||||
|
||||
insert = (selector, serialized, sheet, shouldCache) => {
|
||||
currentSheet = sheet
|
||||
|
||||
if (getSourceMap) {
|
||||
let sourceMap = getSourceMap(serialized.styles)
|
||||
if (sourceMap) {
|
||||
currentSheet = {
|
||||
insert: rule => {
|
||||
sheet.insert(rule + sourceMap)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stylis(selector ? `${selector}{${serialized.styles}}` : serialized.styles)
|
||||
|
||||
if (shouldCache) {
|
||||
cache.inserted[serialized.name] = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const finalizingPlugins = [stringify]
|
||||
const serializer = middleware(
|
||||
omnipresentPlugins.concat(stylisPlugins, finalizingPlugins)
|
||||
)
|
||||
const stylis = (styles: string) => serialize(compile(styles), serializer)
|
||||
|
||||
let serverStylisCache = getServerStylisCache(stylisPlugins)(key)
|
||||
let getRules = (selector: string, serialized: SerializedStyles): string => {
|
||||
let name = serialized.name
|
||||
if (serverStylisCache[name] === undefined) {
|
||||
serverStylisCache[name] = stylis(
|
||||
selector ? `${selector}{${serialized.styles}}` : serialized.styles
|
||||
)
|
||||
}
|
||||
return serverStylisCache[name]
|
||||
}
|
||||
insert = (selector, serialized, sheet, shouldCache) => {
|
||||
let name = serialized.name
|
||||
let rules = getRules(selector, serialized)
|
||||
if (cache.compat === undefined) {
|
||||
// in regular mode, we don't set the styles on the inserted cache
|
||||
// since we don't need to and that would be wasting memory
|
||||
// we return them so that they are rendered in a style tag
|
||||
if (shouldCache) {
|
||||
cache.inserted[name] = true
|
||||
}
|
||||
if (getSourceMap) {
|
||||
let sourceMap = getSourceMap(serialized.styles)
|
||||
if (sourceMap) {
|
||||
return rules + sourceMap
|
||||
}
|
||||
}
|
||||
return rules
|
||||
} else {
|
||||
// in compat mode, we put the styles on the inserted cache so
|
||||
// that emotion-server can pull out the styles
|
||||
// except when we don't want to cache it which was in Global but now
|
||||
// is nowhere but we don't want to do a major right now
|
||||
// and just in case we're going to leave the case here
|
||||
// it's also not affecting client side bundle size
|
||||
// so it's really not a big deal
|
||||
|
||||
if (shouldCache) {
|
||||
cache.inserted[name] = rules
|
||||
} else {
|
||||
return rules
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const cache: EmotionCache = {
|
||||
key,
|
||||
sheet: new StyleSheet({
|
||||
key,
|
||||
container: container!,
|
||||
nonce: options.nonce,
|
||||
speedy: options.speedy,
|
||||
prepend: options.prepend,
|
||||
insertionPoint: options.insertionPoint
|
||||
}),
|
||||
nonce: options.nonce,
|
||||
inserted,
|
||||
registered: {},
|
||||
insert
|
||||
}
|
||||
|
||||
cache.sheet.hydrate(nodesToHydrate)
|
||||
|
||||
return cache
|
||||
}
|
||||
|
||||
export default createCache
|
||||
export type { EmotionCache }
|
||||
export type { StylisElement, StylisPlugin, StylisPluginCallback } from './types'
|
||||
347
node_modules/@emotion/cache/src/prefixer.ts
generated
vendored
Normal file
347
node_modules/@emotion/cache/src/prefixer.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,347 @@
|
|||
/* eslint-disable no-fallthrough */
|
||||
/* eslint-disable eqeqeq */
|
||||
import {
|
||||
charat,
|
||||
combine,
|
||||
copy,
|
||||
DECLARATION,
|
||||
hash,
|
||||
indexof,
|
||||
KEYFRAMES,
|
||||
match,
|
||||
MOZ,
|
||||
MS,
|
||||
replace,
|
||||
RULESET,
|
||||
serialize,
|
||||
strlen,
|
||||
WEBKIT,
|
||||
Element,
|
||||
Middleware
|
||||
} from 'stylis'
|
||||
|
||||
// this is a copy of stylis@4.0.13 prefixer, the latter version introduced grid prefixing which we don't want
|
||||
|
||||
function prefix(value: string, length: number): string {
|
||||
switch (hash(value, length)) {
|
||||
// color-adjust
|
||||
case 5103:
|
||||
return WEBKIT + 'print-' + value + value
|
||||
// animation, animation-(delay|direction|duration|fill-mode|iteration-count|name|play-state|timing-function)
|
||||
case 5737:
|
||||
case 4201:
|
||||
case 3177:
|
||||
case 3433:
|
||||
case 1641:
|
||||
case 4457:
|
||||
case 2921:
|
||||
// text-decoration, filter, clip-path, backface-visibility, column, box-decoration-break
|
||||
case 5572:
|
||||
case 6356:
|
||||
case 5844:
|
||||
case 3191:
|
||||
case 6645:
|
||||
case 3005:
|
||||
// mask, mask-image, mask-(mode|clip|size), mask-(repeat|origin), mask-position, mask-composite,
|
||||
case 6391:
|
||||
case 5879:
|
||||
case 5623:
|
||||
case 6135:
|
||||
case 4599:
|
||||
case 4855:
|
||||
// background-clip, columns, column-(count|fill|gap|rule|rule-color|rule-style|rule-width|span|width)
|
||||
case 4215:
|
||||
case 6389:
|
||||
case 5109:
|
||||
case 5365:
|
||||
case 5621:
|
||||
case 3829:
|
||||
return WEBKIT + value + value
|
||||
// appearance, user-select, transform, hyphens, text-size-adjust
|
||||
case 5349:
|
||||
case 4246:
|
||||
case 4810:
|
||||
case 6968:
|
||||
case 2756:
|
||||
return WEBKIT + value + MOZ + value + MS + value + value
|
||||
// flex, flex-direction
|
||||
case 6828:
|
||||
case 4268:
|
||||
return WEBKIT + value + MS + value + value
|
||||
// order
|
||||
case 6165:
|
||||
return WEBKIT + value + MS + 'flex-' + value + value
|
||||
// align-items
|
||||
case 5187:
|
||||
return (
|
||||
WEBKIT +
|
||||
value +
|
||||
replace(
|
||||
value,
|
||||
/(\w+).+(:[^]+)/,
|
||||
WEBKIT + 'box-$1$2' + MS + 'flex-$1$2'
|
||||
) +
|
||||
value
|
||||
)
|
||||
// align-self
|
||||
case 5443:
|
||||
return (
|
||||
WEBKIT +
|
||||
value +
|
||||
MS +
|
||||
'flex-item-' +
|
||||
replace(value, /flex-|-self/, '') +
|
||||
value
|
||||
)
|
||||
// align-content
|
||||
case 4675:
|
||||
return (
|
||||
WEBKIT +
|
||||
value +
|
||||
MS +
|
||||
'flex-line-pack' +
|
||||
replace(value, /align-content|flex-|-self/, '') +
|
||||
value
|
||||
)
|
||||
// flex-shrink
|
||||
case 5548:
|
||||
return WEBKIT + value + MS + replace(value, 'shrink', 'negative') + value
|
||||
// flex-basis
|
||||
case 5292:
|
||||
return (
|
||||
WEBKIT + value + MS + replace(value, 'basis', 'preferred-size') + value
|
||||
)
|
||||
// flex-grow
|
||||
case 6060:
|
||||
return (
|
||||
WEBKIT +
|
||||
'box-' +
|
||||
replace(value, '-grow', '') +
|
||||
WEBKIT +
|
||||
value +
|
||||
MS +
|
||||
replace(value, 'grow', 'positive') +
|
||||
value
|
||||
)
|
||||
// transition
|
||||
case 4554:
|
||||
return (
|
||||
WEBKIT +
|
||||
replace(value, /([^-])(transform)/g, '$1' + WEBKIT + '$2') +
|
||||
value
|
||||
)
|
||||
// cursor
|
||||
case 6187:
|
||||
return (
|
||||
replace(
|
||||
replace(
|
||||
replace(value, /(zoom-|grab)/, WEBKIT + '$1'),
|
||||
/(image-set)/,
|
||||
WEBKIT + '$1'
|
||||
),
|
||||
value,
|
||||
''
|
||||
) + value
|
||||
)
|
||||
// background, background-image
|
||||
case 5495:
|
||||
case 3959:
|
||||
return replace(value, /(image-set\([^]*)/, WEBKIT + '$1' + '$`$1')
|
||||
// justify-content
|
||||
case 4968:
|
||||
return (
|
||||
replace(
|
||||
replace(
|
||||
value,
|
||||
/(.+:)(flex-)?(.*)/,
|
||||
WEBKIT + 'box-pack:$3' + MS + 'flex-pack:$3'
|
||||
),
|
||||
/s.+-b[^;]+/,
|
||||
'justify'
|
||||
) +
|
||||
WEBKIT +
|
||||
value +
|
||||
value
|
||||
)
|
||||
// (margin|padding)-inline-(start|end)
|
||||
case 4095:
|
||||
case 3583:
|
||||
case 4068:
|
||||
case 2532:
|
||||
return replace(value, /(.+)-inline(.+)/, WEBKIT + '$1$2') + value
|
||||
// (min|max)?(width|height|inline-size|block-size)
|
||||
case 8116:
|
||||
case 7059:
|
||||
case 5753:
|
||||
case 5535:
|
||||
case 5445:
|
||||
case 5701:
|
||||
case 4933:
|
||||
case 4677:
|
||||
case 5533:
|
||||
case 5789:
|
||||
case 5021:
|
||||
case 4765:
|
||||
// stretch, max-content, min-content, fill-available
|
||||
if (strlen(value) - 1 - length > 6)
|
||||
switch (charat(value, length + 1)) {
|
||||
// (m)ax-content, (m)in-content
|
||||
case 109:
|
||||
// -
|
||||
if (charat(value, length + 4) !== 45) break
|
||||
// (f)ill-available, (f)it-content
|
||||
case 102:
|
||||
return (
|
||||
replace(
|
||||
value,
|
||||
/(.+:)(.+)-([^]+)/,
|
||||
'$1' +
|
||||
WEBKIT +
|
||||
'$2-$3' +
|
||||
'$1' +
|
||||
MOZ +
|
||||
(charat(value, length + 3) == 108 ? '$3' : '$2-$3')
|
||||
) + value
|
||||
)
|
||||
// (s)tretch
|
||||
case 115:
|
||||
return ~indexof(value, 'stretch')
|
||||
? prefix(replace(value, 'stretch', 'fill-available'), length) +
|
||||
value
|
||||
: value
|
||||
}
|
||||
break
|
||||
// position: sticky
|
||||
case 4949:
|
||||
// (s)ticky?
|
||||
if (charat(value, length + 1) !== 115) break
|
||||
// display: (flex|inline-flex)
|
||||
case 6444:
|
||||
switch (
|
||||
charat(value, strlen(value) - 3 - (~indexof(value, '!important') && 10))
|
||||
) {
|
||||
// stic(k)y
|
||||
case 107:
|
||||
return replace(value, ':', ':' + WEBKIT) + value
|
||||
// (inline-)?fl(e)x
|
||||
case 101:
|
||||
return (
|
||||
replace(
|
||||
value,
|
||||
/(.+:)([^;!]+)(;|!.+)?/,
|
||||
'$1' +
|
||||
WEBKIT +
|
||||
(charat(value, 14) === 45 ? 'inline-' : '') +
|
||||
'box$3' +
|
||||
'$1' +
|
||||
WEBKIT +
|
||||
'$2$3' +
|
||||
'$1' +
|
||||
MS +
|
||||
'$2box$3'
|
||||
) + value
|
||||
)
|
||||
}
|
||||
break
|
||||
// writing-mode
|
||||
case 5936:
|
||||
switch (charat(value, length + 11)) {
|
||||
// vertical-l(r)
|
||||
case 114:
|
||||
return (
|
||||
WEBKIT +
|
||||
value +
|
||||
MS +
|
||||
replace(value, /[svh]\w+-[tblr]{2}/, 'tb') +
|
||||
value
|
||||
)
|
||||
// vertical-r(l)
|
||||
case 108:
|
||||
return (
|
||||
WEBKIT +
|
||||
value +
|
||||
MS +
|
||||
replace(value, /[svh]\w+-[tblr]{2}/, 'tb-rl') +
|
||||
value
|
||||
)
|
||||
// horizontal(-)tb
|
||||
case 45:
|
||||
return (
|
||||
WEBKIT +
|
||||
value +
|
||||
MS +
|
||||
replace(value, /[svh]\w+-[tblr]{2}/, 'lr') +
|
||||
value
|
||||
)
|
||||
}
|
||||
|
||||
return WEBKIT + value + MS + value + value
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
export let prefixer = (
|
||||
element: Element,
|
||||
index: number,
|
||||
children: Element[],
|
||||
callback: Middleware
|
||||
) => {
|
||||
if (element.length > -1)
|
||||
if (!element.return)
|
||||
switch (element.type) {
|
||||
case DECLARATION:
|
||||
element.return = prefix(element.value, element.length)
|
||||
break
|
||||
case KEYFRAMES:
|
||||
return serialize(
|
||||
[
|
||||
copy(element, {
|
||||
value: replace(element.value, '@', '@' + WEBKIT)
|
||||
})
|
||||
],
|
||||
callback
|
||||
)
|
||||
case RULESET:
|
||||
if (element.length)
|
||||
return combine(element.props as string[], function (value) {
|
||||
switch (match(value, /(::plac\w+|:read-\w+)/)) {
|
||||
// :read-(only|write)
|
||||
case ':read-only':
|
||||
case ':read-write':
|
||||
return serialize(
|
||||
[
|
||||
copy(element, {
|
||||
props: [replace(value, /:(read-\w+)/, ':' + MOZ + '$1')]
|
||||
})
|
||||
],
|
||||
callback
|
||||
)
|
||||
// :placeholder
|
||||
case '::placeholder':
|
||||
return serialize(
|
||||
[
|
||||
copy(element, {
|
||||
props: [
|
||||
replace(
|
||||
value,
|
||||
/:(plac\w+)/,
|
||||
':' + WEBKIT + 'input-$1'
|
||||
)
|
||||
]
|
||||
}),
|
||||
copy(element, {
|
||||
props: [replace(value, /:(plac\w+)/, ':' + MOZ + '$1')]
|
||||
}),
|
||||
copy(element, {
|
||||
props: [replace(value, /:(plac\w+)/, MS + 'input-$1')]
|
||||
})
|
||||
],
|
||||
callback
|
||||
)
|
||||
}
|
||||
|
||||
return ''
|
||||
})
|
||||
}
|
||||
}
|
||||
277
node_modules/@emotion/cache/src/stylis-plugins.ts
generated
vendored
Normal file
277
node_modules/@emotion/cache/src/stylis-plugins.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,277 @@
|
|||
import { EmotionCache } from '@emotion/utils'
|
||||
import {
|
||||
alloc,
|
||||
dealloc,
|
||||
delimit,
|
||||
Element,
|
||||
from,
|
||||
Middleware,
|
||||
next,
|
||||
peek,
|
||||
position,
|
||||
slice,
|
||||
token
|
||||
} from 'stylis'
|
||||
|
||||
// based on https://github.com/thysultan/stylis.js/blob/e6843c373ebcbbfade25ebcc23f540ed8508da0a/src/Tokenizer.js#L239-L244
|
||||
const identifierWithPointTracking = (
|
||||
begin: number,
|
||||
points: number[],
|
||||
index: number
|
||||
) => {
|
||||
let previous = 0
|
||||
let character = 0
|
||||
|
||||
while (true) {
|
||||
previous = character
|
||||
character = peek()
|
||||
|
||||
// &\f
|
||||
if (previous === 38 && character === 12) {
|
||||
points[index] = 1
|
||||
}
|
||||
|
||||
if (token(character)) {
|
||||
break
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
|
||||
return slice(begin, position)
|
||||
}
|
||||
|
||||
const toRules = (parsed: string[], points: number[]) => {
|
||||
// pretend we've started with a comma
|
||||
let index = -1
|
||||
let character = 44
|
||||
|
||||
do {
|
||||
switch (token(character)) {
|
||||
case 0:
|
||||
// &\f
|
||||
if (character === 38 && peek() === 12) {
|
||||
// this is not 100% correct, we don't account for literal sequences here - like for example quoted strings
|
||||
// stylis inserts \f after & to know when & where it should replace this sequence with the context selector
|
||||
// and when it should just concatenate the outer and inner selectors
|
||||
// it's very unlikely for this sequence to actually appear in a different context, so we just leverage this fact here
|
||||
points[index] = 1
|
||||
}
|
||||
parsed[index] += identifierWithPointTracking(
|
||||
position - 1,
|
||||
points,
|
||||
index
|
||||
)
|
||||
break
|
||||
case 2:
|
||||
parsed[index] += delimit(character)
|
||||
break
|
||||
case 4:
|
||||
// comma
|
||||
if (character === 44) {
|
||||
// colon
|
||||
parsed[++index] = peek() === 58 ? '&\f' : ''
|
||||
points[index] = parsed[index].length
|
||||
break
|
||||
}
|
||||
// fallthrough
|
||||
default:
|
||||
parsed[index] += from(character)
|
||||
}
|
||||
} while ((character = next()))
|
||||
|
||||
return parsed
|
||||
}
|
||||
|
||||
const getRules = (value: string, points: number[]) =>
|
||||
dealloc(toRules(alloc(value) as string[], points))
|
||||
|
||||
// WeakSet would be more appropriate, but only WeakMap is supported in IE11
|
||||
const fixedElements = /* #__PURE__ */ new WeakMap()
|
||||
|
||||
export let compat: Middleware = element => {
|
||||
if (
|
||||
element.type !== 'rule' ||
|
||||
!element.parent ||
|
||||
// positive .length indicates that this rule contains pseudo
|
||||
// negative .length indicates that this rule has been already prefixed
|
||||
element.length < 1
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
let value = element.value
|
||||
let parent: Element | null = element.parent
|
||||
let isImplicitRule =
|
||||
element.column === parent.column && element.line === parent.line
|
||||
|
||||
while (parent.type !== 'rule') {
|
||||
parent = parent.parent
|
||||
if (!parent) return
|
||||
}
|
||||
|
||||
// short-circuit for the simplest case
|
||||
if (
|
||||
element.props.length === 1 &&
|
||||
value.charCodeAt(0) !== 58 /* colon */ &&
|
||||
!fixedElements.get(parent)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
// if this is an implicitly inserted rule (the one eagerly inserted at the each new nested level)
|
||||
// then the props has already been manipulated beforehand as they that array is shared between it and its "rule parent"
|
||||
if (isImplicitRule) {
|
||||
return
|
||||
}
|
||||
|
||||
fixedElements.set(element, true)
|
||||
|
||||
const points: number[] = []
|
||||
const rules = getRules(value, points)
|
||||
const parentRules = parent.props
|
||||
|
||||
for (let i = 0, k = 0; i < rules.length; i++) {
|
||||
for (let j = 0; j < parentRules.length; j++, k++) {
|
||||
;(element.props as string[])[k] = points[i]
|
||||
? rules[i].replace(/&\f/g, parentRules[j])
|
||||
: `${parentRules[j]} ${rules[i]}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let removeLabel: Middleware = element => {
|
||||
if (element.type === 'decl') {
|
||||
const value = element.value
|
||||
if (
|
||||
// charcode for l
|
||||
value.charCodeAt(0) === 108 &&
|
||||
// charcode for b
|
||||
value.charCodeAt(2) === 98
|
||||
) {
|
||||
// this ignores label
|
||||
element.return = ''
|
||||
element.value = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ignoreFlag =
|
||||
'emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason'
|
||||
|
||||
const isIgnoringComment = (element: Element) =>
|
||||
element.type === 'comm' &&
|
||||
(element.children as string).indexOf(ignoreFlag) > -1
|
||||
|
||||
export let createUnsafeSelectorsAlarm =
|
||||
(cache: Pick<EmotionCache, 'compat'>): Middleware =>
|
||||
(element, index, children) => {
|
||||
if (element.type !== 'rule' || cache.compat) return
|
||||
|
||||
const unsafePseudoClasses = element.value.match(
|
||||
/(:first|:nth|:nth-last)-child/g
|
||||
)
|
||||
|
||||
if (unsafePseudoClasses) {
|
||||
const isNested = !!element.parent
|
||||
// in nested rules comments become children of the "auto-inserted" rule and that's always the `element.parent`
|
||||
//
|
||||
// considering this input:
|
||||
// .a {
|
||||
// .b /* comm */ {}
|
||||
// color: hotpink;
|
||||
// }
|
||||
// we get output corresponding to this:
|
||||
// .a {
|
||||
// & {
|
||||
// /* comm */
|
||||
// color: hotpink;
|
||||
// }
|
||||
// .b {}
|
||||
// }
|
||||
const commentContainer = isNested
|
||||
? element.parent!.children
|
||||
: // global rule at the root level
|
||||
children
|
||||
|
||||
for (let i = commentContainer.length - 1; i >= 0; i--) {
|
||||
const node = commentContainer[i] as Element
|
||||
|
||||
if (node.line < element.line) {
|
||||
break
|
||||
}
|
||||
|
||||
// it is quite weird but comments are *usually* put at `column: element.column - 1`
|
||||
// so we seek *from the end* for the node that is earlier than the rule's `element` and check that
|
||||
// this will also match inputs like this:
|
||||
// .a {
|
||||
// /* comm */
|
||||
// .b {}
|
||||
// }
|
||||
//
|
||||
// but that is fine
|
||||
//
|
||||
// it would be the easiest to change the placement of the comment to be the first child of the rule:
|
||||
// .a {
|
||||
// .b { /* comm */ }
|
||||
// }
|
||||
// with such inputs we wouldn't have to search for the comment at all
|
||||
// TODO: consider changing this comment placement in the next major version
|
||||
if (node.column < element.column) {
|
||||
if (isIgnoringComment(node)) {
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
unsafePseudoClasses.forEach(unsafePseudoClass => {
|
||||
console.error(
|
||||
`The pseudo class "${unsafePseudoClass}" is potentially unsafe when doing server-side rendering. Try changing it to "${
|
||||
unsafePseudoClass.split('-child')[0]
|
||||
}-of-type".`
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
let isImportRule = (element: Element) =>
|
||||
element.type.charCodeAt(1) === 105 && element.type.charCodeAt(0) === 64
|
||||
|
||||
const isPrependedWithRegularRules = (index: number, children: Element[]) => {
|
||||
for (let i = index - 1; i >= 0; i--) {
|
||||
if (!isImportRule(children[i])) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// use this to remove incorrect elements from further processing
|
||||
// so they don't get handed to the `sheet` (or anything else)
|
||||
// as that could potentially lead to additional logs which in turn could be overhelming to the user
|
||||
const nullifyElement = (element: Element) => {
|
||||
element.type = ''
|
||||
element.value = ''
|
||||
element.return = ''
|
||||
element.children = ''
|
||||
element.props = ''
|
||||
}
|
||||
|
||||
export let incorrectImportAlarm: Middleware = (element, index, children) => {
|
||||
if (!isImportRule(element)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (element.parent) {
|
||||
console.error(
|
||||
"`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles."
|
||||
)
|
||||
nullifyElement(element)
|
||||
} else if (isPrependedWithRegularRules(index, children)) {
|
||||
console.error(
|
||||
"`@import` rules can't be after other rules. Please put your `@import` rules before your other rules."
|
||||
)
|
||||
nullifyElement(element)
|
||||
}
|
||||
}
|
||||
25
node_modules/@emotion/cache/src/types.ts
generated
vendored
Normal file
25
node_modules/@emotion/cache/src/types.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
export interface StylisElement {
|
||||
type: string
|
||||
value: string
|
||||
props: Array<string> | string
|
||||
root: StylisElement | null
|
||||
parent: StylisElement | null
|
||||
children: Array<StylisElement> | string
|
||||
line: number
|
||||
column: number
|
||||
length: number
|
||||
return: string
|
||||
}
|
||||
export type StylisPluginCallback = (
|
||||
element: StylisElement,
|
||||
index: number,
|
||||
children: Array<StylisElement>,
|
||||
callback: StylisPluginCallback
|
||||
) => string | void
|
||||
|
||||
export type StylisPlugin = (
|
||||
element: StylisElement,
|
||||
index: number,
|
||||
children: Array<StylisElement>,
|
||||
callback: StylisPluginCallback
|
||||
) => string | void
|
||||
Loading…
Add table
Add a link
Reference in a new issue