onejs-core 2.0.14 → 2.0.16
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/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "onejs-core",
|
|
3
3
|
"description": "The JS part of OneJS, a UI framework and Scripting Engine for Unity.",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.16",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/Singtaa/onejs-core"
|
|
8
|
+
},
|
|
5
9
|
"main": "./dist/index.js",
|
|
6
10
|
"types": "./typings.d.ts",
|
|
7
11
|
"bin": {
|
|
@@ -5,7 +5,7 @@ module.exports = () => {
|
|
|
5
5
|
'lg': 1024,
|
|
6
6
|
'xl': 1280,
|
|
7
7
|
'xxl': 1536,
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
return {
|
|
10
10
|
postcssPlugin: 'uss-transform',
|
|
11
11
|
Once(root, { result }) {
|
|
@@ -14,75 +14,79 @@ module.exports = () => {
|
|
|
14
14
|
rule.selectors = rule.selectors.map(selector =>
|
|
15
15
|
selector.replace(/(\\\.|\\#|\\%|\\:|\\\/|\\\[|\\\]|\\\(|\\\)|\\2c|\\&|\\>|\\<|\\\*|\\')/g, match => {
|
|
16
16
|
switch (match) {
|
|
17
|
-
case '\\.': return '_d_'
|
|
18
|
-
case '\\#': return '_n_'
|
|
19
|
-
case '\\%': return '_p_'
|
|
20
|
-
case '\\:': return '_c_'
|
|
21
|
-
case '\\/': return '_s_'
|
|
22
|
-
case '\\[': return '_lb_'
|
|
23
|
-
case '\\]': return '_rb_'
|
|
24
|
-
case '\\(': return '_lp_'
|
|
25
|
-
case '\\)': return '_rp_'
|
|
26
|
-
case '\\2c': return '_cm_'
|
|
27
|
-
case '\\&': return '_amp_'
|
|
28
|
-
case '\\>': return '_gt_'
|
|
29
|
-
case '\\<': return '_lt_'
|
|
30
|
-
case '\\*': return '_ast_'
|
|
31
|
-
case '\\\'': return '_sq_'
|
|
32
|
-
default: return match
|
|
17
|
+
case '\\.': return '_d_'
|
|
18
|
+
case '\\#': return '_n_'
|
|
19
|
+
case '\\%': return '_p_'
|
|
20
|
+
case '\\:': return '_c_'
|
|
21
|
+
case '\\/': return '_s_'
|
|
22
|
+
case '\\[': return '_lb_'
|
|
23
|
+
case '\\]': return '_rb_'
|
|
24
|
+
case '\\(': return '_lp_'
|
|
25
|
+
case '\\)': return '_rp_'
|
|
26
|
+
case '\\2c': return '_cm_'
|
|
27
|
+
case '\\&': return '_amp_'
|
|
28
|
+
case '\\>': return '_gt_'
|
|
29
|
+
case '\\<': return '_lt_'
|
|
30
|
+
case '\\*': return '_ast_'
|
|
31
|
+
case '\\\'': return '_sq_'
|
|
32
|
+
default: return match
|
|
33
33
|
}
|
|
34
34
|
})
|
|
35
|
-
)
|
|
36
|
-
})
|
|
35
|
+
)
|
|
36
|
+
})
|
|
37
37
|
|
|
38
38
|
// RGB to RGBA conversion
|
|
39
39
|
root.walkDecls(decl => {
|
|
40
40
|
if (decl.value.includes('rgb(')) {
|
|
41
|
-
decl.value = decl.value.replace(/rgb\((.*?) \/\s*(.*?)\)/g, 'rgba($1 $2)')
|
|
41
|
+
decl.value = decl.value.replace(/rgb\((.*?) \/\s*(.*?)\)/g, 'rgba($1 $2)')
|
|
42
42
|
}
|
|
43
|
-
})
|
|
43
|
+
})
|
|
44
44
|
|
|
45
45
|
// Handle hexadecimal colors with alpha value to RGBA conversion
|
|
46
46
|
root.walkDecls(decl => {
|
|
47
47
|
decl.value = decl.value.replace(/#([A-Fa-f0-9]{8})/g, (match, hex) => {
|
|
48
|
-
const r = parseInt(hex.slice(0, 2), 16)
|
|
49
|
-
const g = parseInt(hex.slice(2, 4), 16)
|
|
50
|
-
const b = parseInt(hex.slice(4, 6), 16)
|
|
51
|
-
const a = parseInt(hex.slice(6, 8), 16) / 255
|
|
52
|
-
return `rgba(${r}, ${g}, ${b}, ${a})
|
|
53
|
-
})
|
|
54
|
-
})
|
|
48
|
+
const r = parseInt(hex.slice(0, 2), 16)
|
|
49
|
+
const g = parseInt(hex.slice(2, 4), 16)
|
|
50
|
+
const b = parseInt(hex.slice(4, 6), 16)
|
|
51
|
+
const a = parseInt(hex.slice(6, 8), 16) / 255
|
|
52
|
+
return `rgba(${r}, ${g}, ${b}, ${a})`
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
55
|
|
|
56
56
|
// Media queries transformation
|
|
57
57
|
root.walkAtRules('media', atRule => {
|
|
58
58
|
// Extract the min-width value from the media query
|
|
59
|
-
const minWidthMatch = atRule.params.match(/min-width:\s*(\d+)px/)
|
|
59
|
+
const minWidthMatch = atRule.params.match(/min-width:\s*(\d+)px/)
|
|
60
60
|
if (minWidthMatch) {
|
|
61
|
-
const minWidthValue = parseInt(minWidthMatch[1], 10)
|
|
61
|
+
const minWidthValue = parseInt(minWidthMatch[1], 10)
|
|
62
62
|
|
|
63
63
|
// Determine the correct breakpoint
|
|
64
|
-
let appliedBreakpointName = null
|
|
64
|
+
let appliedBreakpointName = null
|
|
65
65
|
Object.entries(screenBreakpoints).forEach(([name, value]) => {
|
|
66
66
|
if (minWidthValue >= value) {
|
|
67
|
-
appliedBreakpointName = name
|
|
67
|
+
appliedBreakpointName = name
|
|
68
68
|
}
|
|
69
|
-
})
|
|
69
|
+
})
|
|
70
70
|
|
|
71
71
|
if (appliedBreakpointName) {
|
|
72
|
-
const className = `.onejs-media-${appliedBreakpointName}
|
|
72
|
+
const className = `.onejs-media-${appliedBreakpointName}`
|
|
73
73
|
|
|
74
74
|
// Prepend the class to each rule inside this media query
|
|
75
75
|
atRule.walkRules(rule => {
|
|
76
|
-
rule.selectors = rule.selectors.map(selector =>
|
|
77
|
-
|
|
76
|
+
rule.selectors = rule.selectors.map(selector =>
|
|
77
|
+
selector.startsWith(".root")
|
|
78
|
+
? selector.replace(/^\.root/, `.root${className}`)
|
|
79
|
+
: `${className} ${selector}`
|
|
80
|
+
)
|
|
81
|
+
})
|
|
78
82
|
|
|
79
83
|
// Remove the @media rule by replacing it with its contents
|
|
80
|
-
atRule.replaceWith(atRule.nodes)
|
|
84
|
+
atRule.replaceWith(atRule.nodes)
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
|
-
})
|
|
87
|
+
})
|
|
84
88
|
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
87
91
|
|
|
88
|
-
module.exports.postcss = true
|
|
92
|
+
module.exports.postcss = true
|