@compiled/react 0.11.4 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/css/index.js +1 -5
- package/dist/browser/css/index.js.map +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/keyframes/__fixtures__/index.js +2 -2
- package/dist/browser/keyframes/__fixtures__/index.js.map +1 -1
- package/dist/browser/keyframes/index.js +1 -5
- package/dist/browser/keyframes/index.js.map +1 -1
- package/dist/browser/runtime/ac.d.ts +47 -0
- package/dist/browser/runtime/ac.js +118 -0
- package/dist/browser/runtime/ac.js.flow +56 -0
- package/dist/browser/runtime/ac.js.map +1 -0
- package/dist/browser/runtime/ax.js +12 -12
- package/dist/browser/runtime/ax.js.map +1 -1
- package/dist/browser/runtime/cache.js +1 -1
- package/dist/browser/runtime/cache.js.map +1 -1
- package/dist/browser/runtime/dev-warnings.js +19 -21
- package/dist/browser/runtime/dev-warnings.js.map +1 -1
- package/dist/browser/runtime/index.d.ts +1 -0
- package/dist/browser/runtime/index.js +9 -0
- package/dist/browser/runtime/index.js.flow +1 -0
- package/dist/browser/runtime/index.js.map +1 -1
- package/dist/browser/runtime/is-server-environment.js +4 -6
- package/dist/browser/runtime/is-server-environment.js.map +1 -1
- package/dist/browser/runtime/sheet.js +11 -11
- package/dist/browser/runtime/sheet.js.map +1 -1
- package/dist/browser/runtime/style-cache.js +6 -6
- package/dist/browser/runtime/style-cache.js.map +1 -1
- package/dist/browser/runtime/style.js +10 -10
- package/dist/browser/runtime/style.js.map +1 -1
- package/dist/browser/runtime.d.ts +1 -1
- package/dist/browser/runtime.js +1 -1
- package/dist/browser/runtime.js.flow +1 -1
- package/dist/browser/runtime.js.map +1 -1
- package/dist/browser/styled/index.js +3 -3
- package/dist/browser/styled/index.js.map +1 -1
- package/dist/browser/utils/error.js +18 -2
- package/dist/browser/utils/error.js.map +1 -1
- package/dist/cjs/class-names/index.js +1 -1
- package/dist/cjs/class-names/index.js.map +1 -1
- package/dist/cjs/css/index.js +2 -6
- package/dist/cjs/css/index.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/keyframes/__fixtures__/index.js +1 -1
- package/dist/cjs/keyframes/__fixtures__/index.js.map +1 -1
- package/dist/cjs/keyframes/index.js +2 -6
- package/dist/cjs/keyframes/index.js.map +1 -1
- package/dist/cjs/runtime/ac.d.ts +47 -0
- package/dist/cjs/runtime/ac.js +125 -0
- package/dist/cjs/runtime/ac.js.flow +56 -0
- package/dist/cjs/runtime/ac.js.map +1 -0
- package/dist/cjs/runtime/ax.js +12 -12
- package/dist/cjs/runtime/ax.js.map +1 -1
- package/dist/cjs/runtime/cache.js +1 -1
- package/dist/cjs/runtime/cache.js.map +1 -1
- package/dist/cjs/runtime/dev-warnings.js +19 -21
- package/dist/cjs/runtime/dev-warnings.js.map +1 -1
- package/dist/cjs/runtime/index.d.ts +1 -0
- package/dist/cjs/runtime/index.js +12 -1
- package/dist/cjs/runtime/index.js.flow +1 -0
- package/dist/cjs/runtime/index.js.map +1 -1
- package/dist/cjs/runtime/is-server-environment.js +4 -6
- package/dist/cjs/runtime/is-server-environment.js.map +1 -1
- package/dist/cjs/runtime/sheet.js +11 -11
- package/dist/cjs/runtime/sheet.js.map +1 -1
- package/dist/cjs/runtime/style-cache.js +10 -10
- package/dist/cjs/runtime/style-cache.js.map +1 -1
- package/dist/cjs/runtime/style.js +15 -15
- package/dist/cjs/runtime/style.js.map +1 -1
- package/dist/cjs/runtime.d.ts +1 -1
- package/dist/cjs/runtime.js +3 -1
- package/dist/cjs/runtime.js.flow +1 -1
- package/dist/cjs/runtime.js.map +1 -1
- package/dist/cjs/styled/index.js +3 -3
- package/dist/cjs/styled/index.js.map +1 -1
- package/dist/cjs/utils/error.js +18 -2
- package/dist/cjs/utils/error.js.map +1 -1
- package/dist/esm/css/index.js +1 -5
- package/dist/esm/css/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/keyframes/__fixtures__/index.js +2 -2
- package/dist/esm/keyframes/__fixtures__/index.js.map +1 -1
- package/dist/esm/keyframes/index.js +1 -5
- package/dist/esm/keyframes/index.js.map +1 -1
- package/dist/esm/runtime/ac.d.ts +47 -0
- package/dist/esm/runtime/ac.js +118 -0
- package/dist/esm/runtime/ac.js.flow +56 -0
- package/dist/esm/runtime/ac.js.map +1 -0
- package/dist/esm/runtime/ax.js +12 -12
- package/dist/esm/runtime/ax.js.map +1 -1
- package/dist/esm/runtime/cache.js +1 -1
- package/dist/esm/runtime/cache.js.map +1 -1
- package/dist/esm/runtime/dev-warnings.js +19 -21
- package/dist/esm/runtime/dev-warnings.js.map +1 -1
- package/dist/esm/runtime/index.d.ts +1 -0
- package/dist/esm/runtime/index.js +9 -0
- package/dist/esm/runtime/index.js.flow +1 -0
- package/dist/esm/runtime/index.js.map +1 -1
- package/dist/esm/runtime/is-server-environment.js +4 -6
- package/dist/esm/runtime/is-server-environment.js.map +1 -1
- package/dist/esm/runtime/sheet.js +11 -11
- package/dist/esm/runtime/sheet.js.map +1 -1
- package/dist/esm/runtime/style-cache.js +6 -6
- package/dist/esm/runtime/style-cache.js.map +1 -1
- package/dist/esm/runtime/style.js +10 -10
- package/dist/esm/runtime/style.js.map +1 -1
- package/dist/esm/runtime.d.ts +1 -1
- package/dist/esm/runtime.js +1 -1
- package/dist/esm/runtime.js.flow +1 -1
- package/dist/esm/runtime.js.map +1 -1
- package/dist/esm/styled/index.js +3 -3
- package/dist/esm/styled/index.js.map +1 -1
- package/dist/esm/utils/error.js +18 -2
- package/dist/esm/utils/error.js.map +1 -1
- package/package.json +8 -4
- package/src/__tests__/browser.test.tsx +9 -9
- package/src/__tests__/server-side-hydrate.test.tsx +1 -1
- package/src/__tests__/ssr.test.tsx +7 -7
- package/src/global.d.ts +7 -0
- package/src/runtime/__perf__/ac.test.ts +97 -0
- package/src/runtime/__perf__/ax.test.ts +19 -17
- package/src/runtime/__tests__/ac.test.ts +112 -0
- package/src/runtime/__tests__/ax.test.ts +51 -65
- package/src/runtime/__tests__/style-ssr.test.tsx +1 -1
- package/src/runtime/ac.js.flow +56 -0
- package/src/runtime/ac.ts +143 -0
- package/src/runtime/index.js.flow +1 -0
- package/src/runtime/index.ts +12 -0
- package/src/runtime.js.flow +1 -1
- package/src/runtime.ts +1 -1
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/* eslint-disable import/export */
|
|
2
2
|
import { createSetupError } from '../utils/error';
|
|
3
|
-
export default function css(_styles) {
|
|
4
|
-
var _interpolations = [];
|
|
5
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6
|
-
_interpolations[_i - 1] = arguments[_i];
|
|
7
|
-
}
|
|
3
|
+
export default function css(_styles, ..._interpolations) {
|
|
8
4
|
throw createSetupError();
|
|
9
5
|
}
|
|
10
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAqClD,MAAM,CAAC,OAAO,UAAU,GAAG,CACzB,OAA6D
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/css/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAGlC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAqClD,MAAM,CAAC,OAAO,UAAU,GAAG,CACzB,OAA6D,EAC7D,GAAG,eAA8B;IAEjC,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
|
package/dist/browser/index.js
CHANGED
|
@@ -5,5 +5,5 @@ export { ClassNames } from './class-names';
|
|
|
5
5
|
export { default as css } from './css';
|
|
6
6
|
// Pass through the (classic) jsx runtime.
|
|
7
7
|
// Compiled currently doesn't define its own and uses this purely to enable a local jsx namespace.
|
|
8
|
-
export
|
|
8
|
+
export const jsx = createElement;
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAOtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AAEvC,0CAA0C;AAC1C,kGAAkG;AAClG,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAOtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AAEvC,0CAA0C;AAC1C,kGAAkG;AAClG,MAAM,CAAC,MAAM,GAAG,GAAG,aAAa,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
import { keyframes } from '@compiled/react';
|
|
3
|
-
export
|
|
3
|
+
export const fadeOut = keyframes({
|
|
4
4
|
from: {
|
|
5
5
|
opacity: 1,
|
|
6
6
|
},
|
|
@@ -8,6 +8,6 @@ export var fadeOut = keyframes({
|
|
|
8
8
|
opacity: 0,
|
|
9
9
|
},
|
|
10
10
|
});
|
|
11
|
-
export
|
|
11
|
+
export const namedFadeOut = fadeOut;
|
|
12
12
|
export default fadeOut;
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/keyframes/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/keyframes/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;IAC/B,IAAI,EAAE;QACJ,OAAO,EAAE,CAAC;KACX;IACD,EAAE,EAAE;QACF,OAAO,EAAE,CAAC;KACX;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,OAAO,CAAC;AAEpC,eAAe,OAAO,CAAC"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { createSetupError } from '../utils/error';
|
|
2
|
-
export function keyframes(_stringsOrSteps) {
|
|
3
|
-
var _interpolations = [];
|
|
4
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
5
|
-
_interpolations[_i - 1] = arguments[_i];
|
|
6
|
-
}
|
|
2
|
+
export function keyframes(_stringsOrSteps, ..._interpolations) {
|
|
7
3
|
throw createSetupError();
|
|
8
4
|
}
|
|
9
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keyframes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAkDlD,MAAM,UAAU,SAAS,CACvB,eAAqD
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keyframes/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAkDlD,MAAM,UAAU,SAAS,CACvB,eAAqD,EACrD,GAAG,eAA8C;IAEjD,MAAM,gBAAgB,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memoize the result of ac so if it is called with the same args, it returns immediately.
|
|
3
|
+
* Also, to prevent useless React rerenders
|
|
4
|
+
*/
|
|
5
|
+
declare const cache: Map<any, any>;
|
|
6
|
+
/**
|
|
7
|
+
* `ac` returns an instance of AtomicGroups. The instance holds the knowledge of Atomic Group so we can chain `ac`.
|
|
8
|
+
* e.g. <div className={ax([ax(['_aaaa_b']), '_aaaa_c'])} />
|
|
9
|
+
*/
|
|
10
|
+
declare class AtomicGroups {
|
|
11
|
+
values: Map<string, string>;
|
|
12
|
+
constructor(values: Map<string, string>);
|
|
13
|
+
toString(): string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Joins classes together and ensures atomic declarations of a single group exist.
|
|
17
|
+
* Atomic declarations take the form of `_{group}{value}` (always prefixed with an underscore),
|
|
18
|
+
* where both `group` and `value` are hashes **four characters long**.
|
|
19
|
+
* Class names can be of any length,
|
|
20
|
+
* this function can take both atomic declarations and class names.
|
|
21
|
+
*
|
|
22
|
+
* Input:
|
|
23
|
+
*
|
|
24
|
+
* ```
|
|
25
|
+
* ax(['_aaaabbbb', '_aaaacccc'])
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* Output:
|
|
29
|
+
*
|
|
30
|
+
* ```
|
|
31
|
+
* '_aaaacccc'
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param classes
|
|
35
|
+
*/
|
|
36
|
+
export declare function ac(classNames: (AtomicGroups | string | undefined | false)[]): AtomicGroups | undefined;
|
|
37
|
+
export declare function memoizedAc(classNames: (AtomicGroups | string | undefined | false)[]): AtomicGroups | undefined;
|
|
38
|
+
declare const _default: typeof ac;
|
|
39
|
+
export default _default;
|
|
40
|
+
/**
|
|
41
|
+
* Provide an opportunity to clear the cache to prevent memory leak.
|
|
42
|
+
*/
|
|
43
|
+
export declare function clearCache(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Expose cache
|
|
46
|
+
*/
|
|
47
|
+
export declare function getCache(): typeof cache;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { isServerEnvironment } from './is-server-environment';
|
|
2
|
+
const UNDERSCORE_UNICODE = 95;
|
|
3
|
+
/**
|
|
4
|
+
* This length includes the underscore,
|
|
5
|
+
* e.g. `"_1s4A"` would be a valid atomic group hash.
|
|
6
|
+
*/
|
|
7
|
+
const ATOMIC_GROUP_LENGTH = 5;
|
|
8
|
+
/**
|
|
9
|
+
* Memoize the result of ac so if it is called with the same args, it returns immediately.
|
|
10
|
+
* Also, to prevent useless React rerenders
|
|
11
|
+
*/
|
|
12
|
+
const cache = new Map();
|
|
13
|
+
/**
|
|
14
|
+
* `ac` returns an instance of AtomicGroups. The instance holds the knowledge of Atomic Group so we can chain `ac`.
|
|
15
|
+
* e.g. <div className={ax([ax(['_aaaa_b']), '_aaaa_c'])} />
|
|
16
|
+
*/
|
|
17
|
+
class AtomicGroups {
|
|
18
|
+
constructor(values) {
|
|
19
|
+
// An object stores the relation between Atomic group and actual class name
|
|
20
|
+
// e.g. { "aaaa": "a" } `aaaa` is the Atomic group and `a` is the actual class name
|
|
21
|
+
this.values = values;
|
|
22
|
+
}
|
|
23
|
+
toString() {
|
|
24
|
+
let str = '';
|
|
25
|
+
for (const [, value] of this.values) {
|
|
26
|
+
str += value + ' ';
|
|
27
|
+
}
|
|
28
|
+
return str.slice(0, -1);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Joins classes together and ensures atomic declarations of a single group exist.
|
|
33
|
+
* Atomic declarations take the form of `_{group}{value}` (always prefixed with an underscore),
|
|
34
|
+
* where both `group` and `value` are hashes **four characters long**.
|
|
35
|
+
* Class names can be of any length,
|
|
36
|
+
* this function can take both atomic declarations and class names.
|
|
37
|
+
*
|
|
38
|
+
* Input:
|
|
39
|
+
*
|
|
40
|
+
* ```
|
|
41
|
+
* ax(['_aaaabbbb', '_aaaacccc'])
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Output:
|
|
45
|
+
*
|
|
46
|
+
* ```
|
|
47
|
+
* '_aaaacccc'
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param classes
|
|
51
|
+
*/
|
|
52
|
+
export function ac(classNames) {
|
|
53
|
+
// short circuit if there's no class names.
|
|
54
|
+
if (classNames.length <= 1 && !classNames[0])
|
|
55
|
+
return undefined;
|
|
56
|
+
const atomicGroups = new Map();
|
|
57
|
+
for (let i = 0; i < classNames.length; i++) {
|
|
58
|
+
const cls = classNames[i];
|
|
59
|
+
if (!cls) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (typeof cls === 'string') {
|
|
63
|
+
const groups = cls.split(' ');
|
|
64
|
+
for (let x = 0; x < groups.length; x++) {
|
|
65
|
+
const atomic = groups[x];
|
|
66
|
+
const isAtomic = atomic.charCodeAt(0) === UNDERSCORE_UNICODE;
|
|
67
|
+
const isCompressed = isAtomic && atomic.charCodeAt(5) === UNDERSCORE_UNICODE;
|
|
68
|
+
const atomicGroupName = isAtomic ? atomic.slice(0, ATOMIC_GROUP_LENGTH) : atomic;
|
|
69
|
+
atomicGroups.set(atomicGroupName, isCompressed ? atomic.slice(ATOMIC_GROUP_LENGTH + 1) : atomic);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// if cls is an instance of AtomicGroups, transfer its values to `atomicGroups`
|
|
74
|
+
for (const [key, value] of cls.values) {
|
|
75
|
+
atomicGroups.set(key, value);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return new AtomicGroups(atomicGroups);
|
|
80
|
+
}
|
|
81
|
+
export function memoizedAc(classNames) {
|
|
82
|
+
// short circuit if there's no class names.
|
|
83
|
+
if (classNames.length <= 1 && !classNames[0])
|
|
84
|
+
return undefined;
|
|
85
|
+
// build the cacheKey based on the function argument
|
|
86
|
+
// e.g. if the argument is ["_aaaabbbb", "_aaaa_a", "some-class-name"],
|
|
87
|
+
// then the cacheKey is "_aaaabbbb _aaaa_a some-class-name"
|
|
88
|
+
let cacheKey = '';
|
|
89
|
+
for (let i = 0; i < classNames.length; i += 1) {
|
|
90
|
+
const current = classNames[i];
|
|
91
|
+
// continue if current is undefined, false, or ""
|
|
92
|
+
if (!current)
|
|
93
|
+
continue;
|
|
94
|
+
cacheKey += current + ' ';
|
|
95
|
+
}
|
|
96
|
+
cacheKey = cacheKey.slice(0, -1);
|
|
97
|
+
if (cache.has(cacheKey))
|
|
98
|
+
return cache.get(cacheKey);
|
|
99
|
+
const result = ac(classNames);
|
|
100
|
+
cache.set(cacheKey, result);
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
// Memoization is primarily used to prevent React from unncessary re-rendering.
|
|
104
|
+
// Use unmemoizedAc on server-side because We don't need to worry about re-rendering on server-side.
|
|
105
|
+
export default false ? ac : memoizedAc;
|
|
106
|
+
/**
|
|
107
|
+
* Provide an opportunity to clear the cache to prevent memory leak.
|
|
108
|
+
*/
|
|
109
|
+
export function clearCache() {
|
|
110
|
+
cache.clear();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Expose cache
|
|
114
|
+
*/
|
|
115
|
+
export function getCache() {
|
|
116
|
+
return cache;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=ac.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flowtype definitions for ac
|
|
3
|
+
* Generated by Flowgen from a Typescript Definition
|
|
4
|
+
* Flowgen v1.20.1
|
|
5
|
+
* @flow
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Memoize the result of ac so if it is called with the same args, it returns immediately.
|
|
9
|
+
* Also, to prevent useless React rerenders
|
|
10
|
+
*/
|
|
11
|
+
declare var cache: Map<any, any>;
|
|
12
|
+
/**
|
|
13
|
+
* `ac` returns an instance of AtomicGroups. The instance holds the knowledge of Atomic Group so we can chain `ac`.
|
|
14
|
+
* e.g. <div className={ax([ax(['_aaaa_b']), '_aaaa_c'])} />
|
|
15
|
+
*/
|
|
16
|
+
declare class AtomicGroups {
|
|
17
|
+
values: Map<string, string>;
|
|
18
|
+
constructor(values: Map<string, string>): this;
|
|
19
|
+
toString(): string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Joins classes together and ensures atomic declarations of a single group exist.
|
|
23
|
+
* Atomic declarations take the form of `_{group}{value}` (always prefixed with an underscore),
|
|
24
|
+
* where both `group` and `value` are hashes **four characters long**.
|
|
25
|
+
* Class names can be of any length,
|
|
26
|
+
* this function can take both atomic declarations and class names.
|
|
27
|
+
*
|
|
28
|
+
* Input:
|
|
29
|
+
*
|
|
30
|
+
* ```
|
|
31
|
+
* ax(['_aaaabbbb', '_aaaacccc'])
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Output:
|
|
35
|
+
*
|
|
36
|
+
* ```
|
|
37
|
+
* '_aaaacccc'
|
|
38
|
+
* ```
|
|
39
|
+
* @param classes
|
|
40
|
+
*/
|
|
41
|
+
declare export function ac(
|
|
42
|
+
classNames: (AtomicGroups | string | void | false)[]
|
|
43
|
+
): AtomicGroups | void;
|
|
44
|
+
declare export function memoizedAc(
|
|
45
|
+
classNames: (AtomicGroups | string | void | false)[]
|
|
46
|
+
): AtomicGroups | void;
|
|
47
|
+
declare var _default: typeof ac;
|
|
48
|
+
declare export default typeof _default;
|
|
49
|
+
/**
|
|
50
|
+
* Provide an opportunity to clear the cache to prevent memory leak.
|
|
51
|
+
*/
|
|
52
|
+
declare export function clearCache(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Expose cache
|
|
55
|
+
*/
|
|
56
|
+
declare export function getCache(): typeof cache;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ac.js","sourceRoot":"","sources":["../../../src/runtime/ac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B;;;GAGG;AACH,MAAM,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;AAExB;;;GAGG;AACH,MAAM,YAAY;IAEhB,YAAY,MAA2B;QACrC,2EAA2E;QAC3E,mFAAmF;QACnF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IACD,QAAQ;QACN,IAAI,GAAG,GAAG,EAAE,CAAC;QAEb,KAAK,MAAM,CAAC,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE;YACnC,GAAG,IAAI,KAAK,GAAG,GAAG,CAAC;SACpB;QAED,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,EAAE,CAChB,UAAyD;IAEzD,2CAA2C;IAC3C,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAE/D,MAAM,YAAY,GAAwB,IAAI,GAAG,EAAE,CAAC;IAEpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,GAAG,EAAE;YACR,SAAS;SACV;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,MAAM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C,IAAI,CAAC,EAAE;QAC7C,MAAM,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC9B,iDAAiD;QACjD,IAAI,CAAC,OAAO;YAAE,SAAS;QACvB,QAAQ,IAAI,OAAO,GAAG,GAAG,CAAC;KAC3B;IAED,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEjC,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEpD,MAAM,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;IAE9B,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE5B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+EAA+E;AAC/E,oGAAoG;AACpG,eAAe,MAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,KAAK,CAAC,KAAK,EAAE,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ;IACtB,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
const UNDERSCORE_UNICODE = 95;
|
|
2
2
|
/**
|
|
3
3
|
* This length includes the underscore,
|
|
4
4
|
* e.g. `"_1s4A"` would be a valid atomic group hash.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const ATOMIC_GROUP_LENGTH = 5;
|
|
7
7
|
/**
|
|
8
8
|
* Joins classes together and ensures atomic declarations of a single group exist.
|
|
9
9
|
* Atomic declarations take the form of `_{group}{value}` (always prefixed with an underscore),
|
|
@@ -30,22 +30,22 @@ export default function ax(classNames) {
|
|
|
30
30
|
// short circuit if there's no custom class names.
|
|
31
31
|
return classNames[0] || undefined;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
for (
|
|
35
|
-
|
|
33
|
+
const atomicGroups = {};
|
|
34
|
+
for (let i = 0; i < classNames.length; i++) {
|
|
35
|
+
const cls = classNames[i];
|
|
36
36
|
if (!cls) {
|
|
37
37
|
continue;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
for (
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const groups = cls.split(' ');
|
|
40
|
+
for (let x = 0; x < groups.length; x++) {
|
|
41
|
+
const atomic = groups[x];
|
|
42
|
+
const atomicGroupName = atomic.slice(0, atomic.charCodeAt(0) === UNDERSCORE_UNICODE ? ATOMIC_GROUP_LENGTH : undefined);
|
|
43
43
|
atomicGroups[atomicGroupName] = atomic;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
for (
|
|
48
|
-
|
|
46
|
+
let str = '';
|
|
47
|
+
for (const key in atomicGroups) {
|
|
48
|
+
const value = atomicGroups[key];
|
|
49
49
|
str += value + ' ';
|
|
50
50
|
}
|
|
51
51
|
return str.slice(0, -1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ax.js","sourceRoot":"","sources":["../../../src/runtime/ax.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"ax.js","sourceRoot":"","sources":["../../../src/runtime/ax.ts"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,EAAE,CAAC,UAA0C;IACnE,IAAI,UAAU,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACnF,kDAAkD;QAClD,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;KACnC;IAED,MAAM,YAAY,GAA2B,EAAE,CAAC;IAEhD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC1B,IAAI,CAAC,GAAG,EAAE;YACR,SAAS;SACV;QAED,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACzB,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAClC,CAAC,EACD,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAC9E,CAAC;YACF,YAAY,CAAC,eAAe,CAAC,GAAG,MAAM,CAAC;SACxC;KACF;IAED,IAAI,GAAG,GAAG,EAAE,CAAC;IAEb,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE;QAC9B,MAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAChC,GAAG,IAAI,KAAK,GAAG,GAAG,CAAC;KACpB;IAED,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/runtime/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/runtime/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAY,EAAE;IAC3C,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,OAAO,CAAC;AAC1E,CAAC,CAAC"}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return console.error.apply(console, __spreadArray(["\n \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557\n\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\n\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\n\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551\n\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\n \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u255D\n\n @compiled/react/runtime - DEV WARNING\n\n ".concat(str, "\n")], args, false));
|
|
18
|
-
};
|
|
19
|
-
export var analyzeCssInDev = function (sheet) {
|
|
1
|
+
const selectorsToWarn = [':first-child', ':nth-child'];
|
|
2
|
+
const hasWarned = {};
|
|
3
|
+
const warn = (str, ...args) => console.error(`
|
|
4
|
+
██████╗ ██████╗ ███╗ ███╗██████╗ ██╗██╗ ███████╗██████╗
|
|
5
|
+
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██║██║ ██╔════╝██╔══██╗
|
|
6
|
+
██║ ██║ ██║██╔████╔██║██████╔╝██║██║ █████╗ ██║ ██║
|
|
7
|
+
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║██║ ██╔══╝ ██║ ██║
|
|
8
|
+
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ██║███████╗███████╗██████╔╝
|
|
9
|
+
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚══════╝╚═════╝
|
|
10
|
+
|
|
11
|
+
@compiled/react/runtime - DEV WARNING
|
|
12
|
+
|
|
13
|
+
${str}
|
|
14
|
+
`, ...args);
|
|
15
|
+
export const analyzeCssInDev = (sheet) => {
|
|
20
16
|
if (hasWarned[sheet]) {
|
|
21
17
|
return;
|
|
22
18
|
}
|
|
23
|
-
|
|
19
|
+
const shouldWarnAboutSelectors = selectorsToWarn.map((selector) => sheet.includes(selector)).filter(Boolean).length > 0;
|
|
24
20
|
if (shouldWarnAboutSelectors) {
|
|
25
|
-
warn(
|
|
21
|
+
warn(`Selectors "${selectorsToWarn.join(', ')}" are dangerous to use when server side rendering.
|
|
22
|
+
Alternatively try and use ":nth-of-type", or placing data attributes and targetting those instead.
|
|
23
|
+
Read https://compiledcssinjs.com/docs/server-side-rendering for more advice.`);
|
|
26
24
|
}
|
|
27
25
|
hasWarned[sheet] = true;
|
|
28
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-warnings.js","sourceRoot":"","sources":["../../../src/runtime/dev-warnings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev-warnings.js","sourceRoot":"","sources":["../../../src/runtime/dev-warnings.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;AACvD,MAAM,SAAS,GAAyB,EAAE,CAAC;AAE3C,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,GAAG,IAAW,EAAQ,EAAE,CACjD,OAAO,CAAC,KAAK,CACX;;;;;;;;;;IAUA,GAAG;CACN,EACG,GAAG,IAAI,CACR,CAAC;AAEJ,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAQ,EAAE;IACrD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE;QACpB,OAAO;KACR;IAED,MAAM,wBAAwB,GAC5B,eAAe,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAEzF,IAAI,wBAAwB,EAAE;QAC5B,IAAI,CACF,cAAc,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;;+EAEiC,CAC1E,CAAC;KACH;IAED,SAAS,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
export { default as CS } from './style';
|
|
2
2
|
export { default as CC } from './style-cache';
|
|
3
3
|
export { default as ax } from './ax';
|
|
4
|
+
export { default as ac, clearCache as clearAcCache } from './ac';
|
|
4
5
|
export { default as ix } from './css-custom-property';
|
|
6
|
+
// Ensure only one `@compiled/runtime` exist in the bundle.
|
|
7
|
+
// This is because `ac` and `style-cache` need to access a singlton.
|
|
8
|
+
if (typeof window !== 'undefined') {
|
|
9
|
+
if (typeof window.__COMPILED_IMPORTED__ !== 'undefined') {
|
|
10
|
+
throw new Error('Multiple instances of Compiled Runtime have been found on the page. A likely cause is that muliple versions of `@compiled/react` exist in JS bundle.');
|
|
11
|
+
}
|
|
12
|
+
window.__COMPILED_IMPORTED__ = true;
|
|
13
|
+
}
|
|
5
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -7,4 +7,5 @@
|
|
|
7
7
|
declare export { default as CS } from './style';
|
|
8
8
|
declare export { default as CC } from './style-cache';
|
|
9
9
|
declare export { default as ax } from './ax';
|
|
10
|
+
declare export { default as ac, clearCache as clearAcCache } from './ac';
|
|
10
11
|
declare export { default as ix } from './css-custom-property';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,MAAM,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAEtD,2DAA2D;AAC3D,oEAAoE;AACpE,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IACjC,IAAI,OAAO,MAAM,CAAC,qBAAqB,KAAK,WAAW,EAAE;QACvD,MAAM,IAAI,KAAK,CACb,sJAAsJ,CACvJ,CAAC;KACH;IACD,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC;CACrC"}
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* @see https://github.com/jsdom/jsdom/releases/tag/12.0.0
|
|
3
3
|
* @see https://github.com/jsdom/jsdom/issues/1537
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(navigator === null || navigator === void 0 ? void 0 : navigator.userAgent.includes('jsdom'));
|
|
9
|
-
};
|
|
5
|
+
const isJsDomEnvironment = () => window.name === 'nodejs' ||
|
|
6
|
+
(navigator === null || navigator === void 0 ? void 0 : navigator.userAgent.includes('Node.js')) ||
|
|
7
|
+
(navigator === null || navigator === void 0 ? void 0 : navigator.userAgent.includes('jsdom'));
|
|
10
8
|
/**
|
|
11
9
|
* Returns `true` when inside a node environment,
|
|
12
10
|
* else `false`.
|
|
@@ -19,7 +17,7 @@ var isJsDomEnvironment = function () {
|
|
|
19
17
|
* }
|
|
20
18
|
* ```
|
|
21
19
|
*/
|
|
22
|
-
export
|
|
20
|
+
export const isServerEnvironment = () => {
|
|
23
21
|
if (typeof window === 'undefined' ||
|
|
24
22
|
(typeof process !== 'undefined' && process.versions != null && process.versions.node != null)) {
|
|
25
23
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-server-environment.js","sourceRoot":"","sources":["../../../src/runtime/is-server-environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"is-server-environment.js","sourceRoot":"","sources":["../../../src/runtime/is-server-environment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAC9B,MAAM,CAAC,IAAI,KAAK,QAAQ;KACxB,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;KACxC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA,CAAC;AACzC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAY,EAAE;IAC/C,IACE,OAAO,MAAM,KAAK,WAAW;QAC7B,CAAC,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,EAC7F;QACA,OAAO,IAAI,CAAC;KACb;IACD,IAAI,kBAAkB,EAAE,EAAE;QACxB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { isCacheDisabled } from './cache';
|
|
|
3
3
|
* Ordered style buckets using their short psuedo name.
|
|
4
4
|
* If changes are needed make sure that it aligns with the definition in `sort-at-rule-pseudos.tsx`.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export const styleBucketOrdering = [
|
|
7
7
|
// catch-all
|
|
8
8
|
'',
|
|
9
9
|
// link
|
|
@@ -26,7 +26,7 @@ export var styleBucketOrdering = [
|
|
|
26
26
|
/**
|
|
27
27
|
* Holds all style buckets in memory that have been added to the head.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
const styleBucketsInHead = {};
|
|
30
30
|
/**
|
|
31
31
|
* Maps the long pseudo name to the short pseudo name.
|
|
32
32
|
* Pseudos that match here will be ordered,
|
|
@@ -34,7 +34,7 @@ var styleBucketsInHead = {};
|
|
|
34
34
|
* We reduce the pseduo name to save bundlesize.
|
|
35
35
|
* Thankfully there aren't any overlaps, see: https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
const pseudosMap = {
|
|
38
38
|
// link
|
|
39
39
|
k: 'l',
|
|
40
40
|
// visited
|
|
@@ -58,17 +58,17 @@ var pseudosMap = {
|
|
|
58
58
|
*/
|
|
59
59
|
function lazyAddStyleBucketToHead(bucketName, opts) {
|
|
60
60
|
if (!styleBucketsInHead[bucketName]) {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
let currentBucketIndex = styleBucketOrdering.indexOf(bucketName) + 1;
|
|
62
|
+
let nextBucketFromCache = null;
|
|
63
63
|
// Find the next bucket which we will add our new style bucket before.
|
|
64
64
|
for (; currentBucketIndex < styleBucketOrdering.length; currentBucketIndex++) {
|
|
65
|
-
|
|
65
|
+
const nextBucket = styleBucketsInHead[styleBucketOrdering[currentBucketIndex]];
|
|
66
66
|
if (nextBucket) {
|
|
67
67
|
nextBucketFromCache = nextBucket;
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
const tag = document.createElement('style');
|
|
72
72
|
opts.nonce && tag.setAttribute('nonce', opts.nonce);
|
|
73
73
|
tag.appendChild(document.createTextNode(''));
|
|
74
74
|
document.head.insertBefore(tag, nextBucketFromCache);
|
|
@@ -97,7 +97,7 @@ function lazyAddStyleBucketToHead(bucketName, opts) {
|
|
|
97
97
|
*
|
|
98
98
|
* @param sheet styles for which we are getting the bucket
|
|
99
99
|
*/
|
|
100
|
-
export
|
|
100
|
+
export const getStyleBucketName = (sheet) => {
|
|
101
101
|
// We are grouping all the at-rules like @media, @supports etc under `m` bucket.
|
|
102
102
|
if (sheet.charCodeAt(0) === 64 /* "@" */) {
|
|
103
103
|
return 'm';
|
|
@@ -122,10 +122,10 @@ export var getStyleBucketName = function (sheet) {
|
|
|
122
122
|
* @param opts StyleSheetOpts
|
|
123
123
|
*/
|
|
124
124
|
export default function insertRule(css, opts) {
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
const bucketName = getStyleBucketName(css);
|
|
126
|
+
const style = lazyAddStyleBucketToHead(bucketName, opts);
|
|
127
127
|
if (process.env.NODE_ENV === 'production') {
|
|
128
|
-
|
|
128
|
+
const sheet = style.sheet;
|
|
129
129
|
// Used to avoid unhandled exceptions across browsers with prefixed selectors such as -moz-placeholder.
|
|
130
130
|
try {
|
|
131
131
|
sheet.insertRule(css, sheet.cssRules.length);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet.js","sourceRoot":"","sources":["../../../src/runtime/sheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C;;;GAGG;AACH,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"sheet.js","sourceRoot":"","sources":["../../../src/runtime/sheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG1C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAa;IAC3C,YAAY;IACZ,EAA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,CAAC,MAAM,CAAC,CAAC;SAC9C;QAAC,WAAM,GAAE;KACX;SAAM;QACL,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;KACjD;AACH,CAAC"}
|
|
@@ -6,15 +6,15 @@ import { isServerEnvironment } from './is-server-environment';
|
|
|
6
6
|
* Cache to hold already used styles.
|
|
7
7
|
* React Context on the server - singleton object on the client.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
const Cache = false ? createContext(null) : {};
|
|
10
10
|
if (!false) {
|
|
11
11
|
/**
|
|
12
12
|
* Iterates through all found style elements generated when server side rendering.
|
|
13
13
|
*
|
|
14
14
|
* @param cb
|
|
15
15
|
*/
|
|
16
|
-
|
|
17
|
-
for (
|
|
16
|
+
const ssrStyles = document.querySelectorAll('style[data-cmpld]');
|
|
17
|
+
for (let i = 0; i < ssrStyles.length; i++) {
|
|
18
18
|
// Move all found server-side rendered style elements to the head before React hydration happens.
|
|
19
19
|
document.head.appendChild(ssrStyles[i]);
|
|
20
20
|
}
|
|
@@ -22,7 +22,7 @@ if (!false) {
|
|
|
22
22
|
/**
|
|
23
23
|
* Hook using the cache created on the server or client.
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export const useCache = () => {
|
|
26
26
|
if (isCacheDisabled()) {
|
|
27
27
|
return {};
|
|
28
28
|
}
|
|
@@ -41,11 +41,11 @@ export var useCache = function () {
|
|
|
41
41
|
*
|
|
42
42
|
* On the browser this turns into a fragment with no React Context.
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
const StyleCacheProvider = (props) => {
|
|
45
45
|
if (false) {
|
|
46
46
|
// This code path isn't conditionally called at build time - safe to ignore.
|
|
47
47
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
48
|
-
|
|
48
|
+
const inserted = useCache();
|
|
49
49
|
return React.createElement(Cache.Provider, { value: inserted }, props.children);
|
|
50
50
|
}
|
|
51
51
|
return props.children;
|