@octane-xplat/smooth-corners 0.14.0 → 0.15.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/package.json +11 -11
- package/src/layout-child.ts +2 -10
- package/src/layout-child.web.ts +1 -7
- package/dist/native/index.js +0 -2
- package/dist/native/node_modules/.pnpm/@lisse_core@0.7.2/node_modules/@lisse/core/dist/chunk-BL6ZAFLB.js +0 -477
- package/dist/native/octane-client-build.json +0 -8
- package/dist/native/packages/smooth-corners/src/SmoothCorners.tsrx.js +0 -77
- package/dist/native/packages/smooth-corners/src/apply.android.js +0 -95
- package/dist/native/packages/smooth-corners/src/apply.ios.js +0 -92
- package/dist/native/packages/smooth-corners/src/layout-child.js +0 -61
- package/dist/native/packages/smooth-corners/src/path.js +0 -424
- package/dist/web/index.js +0 -2
- package/dist/web/node_modules/.pnpm/@lisse_core@0.7.2/node_modules/@lisse/core/dist/chunk-BL6ZAFLB.js +0 -477
- package/dist/web/octane-client-build.json +0 -8
- package/dist/web/packages/smooth-corners/src/SmoothCorners.web.tsrx.js +0 -69
- package/dist/web/packages/smooth-corners/src/layout-child.web.js +0 -94
- package/dist/web/packages/smooth-corners/src/path.js +0 -453
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octane-xplat/smooth-corners",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Exact-match smooth corners for Octane xplat — one generated curve (Rosenfeld continuous, Figma squircle, superellipse, clothoid) clipped natively on web, iOS, Android, and macOS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"clip-path",
|
|
@@ -20,18 +20,19 @@
|
|
|
20
20
|
"directory": "packages/smooth-corners"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
|
-
"dist",
|
|
24
23
|
"types",
|
|
25
|
-
"src"
|
|
24
|
+
"src",
|
|
25
|
+
"!src/**/*.test.*",
|
|
26
|
+
"!src/**/*.spec.*"
|
|
26
27
|
],
|
|
27
28
|
"type": "module",
|
|
28
29
|
"exports": {
|
|
29
30
|
".": {
|
|
30
31
|
"types": "./types/index.d.ts",
|
|
31
32
|
"macos": "./src/index.macos.ts",
|
|
32
|
-
"web": "./
|
|
33
|
-
"native": "./
|
|
34
|
-
"default": "./
|
|
33
|
+
"web": "./src/index.web.ts",
|
|
34
|
+
"native": "./src/index.ts",
|
|
35
|
+
"default": "./src/index.ts"
|
|
35
36
|
}
|
|
36
37
|
},
|
|
37
38
|
"publishConfig": {
|
|
@@ -41,13 +42,13 @@
|
|
|
41
42
|
"@lisse/core": "0.7.2"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@nativescript-community/octane": "0.2.
|
|
45
|
+
"@nativescript-community/octane": "0.2.5",
|
|
45
46
|
"@nativescript/core": "9.1.3",
|
|
46
|
-
"@octane-xplat/macos-renderer": "0.
|
|
47
|
+
"@octane-xplat/macos-renderer": "0.15.0",
|
|
47
48
|
"@octanejs/vite-plugin": "0.1.61",
|
|
48
49
|
"@tsrx/typescript-plugin": "0.4.11",
|
|
49
50
|
"octane": "0.11.0",
|
|
50
|
-
"tsrx-typegen": "0.
|
|
51
|
+
"tsrx-typegen": "0.3.0",
|
|
51
52
|
"typescript": "5.9.3",
|
|
52
53
|
"vite": "8.3.0"
|
|
53
54
|
},
|
|
@@ -65,10 +66,9 @@
|
|
|
65
66
|
}
|
|
66
67
|
},
|
|
67
68
|
"scripts": {
|
|
68
|
-
"build": "vite build && vite build --mode native && pnpm typegen && node ../../scripts/check-native-dist.mjs",
|
|
69
69
|
"typegen": "tsc -p tsconfig.types.json",
|
|
70
70
|
"pack:check": "tsrx-typegen --pack-check",
|
|
71
71
|
"test": "node --test tests/*.test.mjs",
|
|
72
|
-
"typecheck": "
|
|
72
|
+
"typecheck": "node ../../scripts/typecheck.mjs"
|
|
73
73
|
}
|
|
74
74
|
}
|
package/src/layout-child.ts
CHANGED
|
@@ -18,13 +18,7 @@ const OUTER_STYLE_KEYS = [
|
|
|
18
18
|
'marginLeft',
|
|
19
19
|
] as const
|
|
20
20
|
|
|
21
|
-
const MARGIN_KEYS = [
|
|
22
|
-
'margin',
|
|
23
|
-
'marginTop',
|
|
24
|
-
'marginRight',
|
|
25
|
-
'marginBottom',
|
|
26
|
-
'marginLeft',
|
|
27
|
-
] as const
|
|
21
|
+
const MARGIN_KEYS = ['margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft'] as const
|
|
28
22
|
|
|
29
23
|
/** The inner box's `style` — everything except margins, which belong to the
|
|
30
24
|
* element's border box and move out to the wrapper. Width/height stay: the
|
|
@@ -109,9 +103,7 @@ export function innerLayoutProps(
|
|
|
109
103
|
: (FLEX_JUSTIFY[props.justifyContent] ?? props.justifyContent)
|
|
110
104
|
|
|
111
105
|
result.alignItems =
|
|
112
|
-
props.alignItems === undefined
|
|
113
|
-
? undefined
|
|
114
|
-
: (FLEX_ALIGN[props.alignItems] ?? props.alignItems)
|
|
106
|
+
props.alignItems === undefined ? undefined : (FLEX_ALIGN[props.alignItems] ?? props.alignItems)
|
|
115
107
|
|
|
116
108
|
result.flexWrap =
|
|
117
109
|
props.flexWrap === undefined
|
package/src/layout-child.web.ts
CHANGED
|
@@ -33,13 +33,7 @@ const OUTER_STYLE_KEYS = [
|
|
|
33
33
|
'marginLeft',
|
|
34
34
|
] as const
|
|
35
35
|
|
|
36
|
-
const MARGIN_KEYS = [
|
|
37
|
-
'margin',
|
|
38
|
-
'marginTop',
|
|
39
|
-
'marginRight',
|
|
40
|
-
'marginBottom',
|
|
41
|
-
'marginLeft',
|
|
42
|
-
] as const
|
|
36
|
+
const MARGIN_KEYS = ['margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft'] as const
|
|
43
37
|
|
|
44
38
|
/** The inner box's `style` — everything except margins, which belong to the
|
|
45
39
|
* element's border box and move out to the wrapper. */
|
package/dist/native/index.js
DELETED
|
@@ -1,477 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@lisse+core@0.7.2/node_modules/@lisse/core/dist/chunk-BL6ZAFLB.js
|
|
2
|
-
function V(e, t, r, n, s, o, i) {
|
|
3
|
-
let p = e === 0 && t === 0 ? 0 : r >= 0 ? n - r : e / (e + t) * n, g = e === 0 && s === 0 ? 0 : o >= 0 ? i - o : e / (e + s) * i;
|
|
4
|
-
return Math.min(p, g);
|
|
5
|
-
}
|
|
6
|
-
function st({ topLeftCornerRadius: e, topRightCornerRadius: t, bottomRightCornerRadius: r, bottomLeftCornerRadius: n, width: s, height: o }) {
|
|
7
|
-
if (e === t && t === r && r === n && e > 0 && s > 0 && o > 0) {
|
|
8
|
-
let f = Math.min(s, o) / 2, M = {
|
|
9
|
-
radius: Math.min(e, f),
|
|
10
|
-
roundingAndSmoothingBudget: f
|
|
11
|
-
};
|
|
12
|
-
return {
|
|
13
|
-
topLeft: M,
|
|
14
|
-
topRight: M,
|
|
15
|
-
bottomLeft: M,
|
|
16
|
-
bottomRight: M
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
let i = (t > e ? 1 : 0) + (n > e ? 1 : 0) + (r > e ? 1 : 0), p = (e >= t ? 1 : 0) + (n > t ? 1 : 0) + (r > t ? 1 : 0), g = (e >= n ? 1 : 0) + (t >= n ? 1 : 0) + (r > n ? 1 : 0), $ = e, x = t, u = n, c = r, a = -1, m = -1, l = -1, d = -1;
|
|
20
|
-
for (let f = 0; f < 4; f++) {
|
|
21
|
-
let S = i === f ? 0 : p === f ? 1 : g === f ? 2 : 3;
|
|
22
|
-
S === 0 ? (a = V(e, x, m, s, u, l, o), $ = Math.min(e, a)) : S === 1 ? (m = V(t, $, a, s, c, d, o), x = Math.min(t, m)) : S === 2 ? (l = V(n, c, d, s, $, a, o), u = Math.min(n, l)) : (d = V(r, u, l, s, x, m, o), c = Math.min(r, d));
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
topLeft: {
|
|
26
|
-
radius: $,
|
|
27
|
-
roundingAndSmoothingBudget: a
|
|
28
|
-
},
|
|
29
|
-
topRight: {
|
|
30
|
-
radius: x,
|
|
31
|
-
roundingAndSmoothingBudget: m
|
|
32
|
-
},
|
|
33
|
-
bottomLeft: {
|
|
34
|
-
radius: u,
|
|
35
|
-
roundingAndSmoothingBudget: l
|
|
36
|
-
},
|
|
37
|
-
bottomRight: {
|
|
38
|
-
radius: c,
|
|
39
|
-
roundingAndSmoothingBudget: d
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function G(e) {
|
|
44
|
-
return e * Math.PI / 180;
|
|
45
|
-
}
|
|
46
|
-
function y(e) {
|
|
47
|
-
let t = e * 1e4, r = Math.round(t), n = t - r;
|
|
48
|
-
if (n > .4999999 || n < -.4999999 || !Number.isSafeInteger(r)) return e.toFixed(4);
|
|
49
|
-
let s = e < 0, o = s ? -r : r, i = o % 1e4, p = (o - i) / 1e4, g = i < 10 ? "000" : i < 100 ? "00" : i < 1e3 ? "0" : "";
|
|
50
|
-
return (s ? "-" : "") + p + "." + g + i;
|
|
51
|
-
}
|
|
52
|
-
var q = {
|
|
53
|
-
p: 0,
|
|
54
|
-
pathSegment: () => ""
|
|
55
|
-
};
|
|
56
|
-
function L(e, t) {
|
|
57
|
-
return e === 0 || Number.isNaN(e) ? t : t.charCodeAt(0) === 45 ? t.slice(1) : "-" + t;
|
|
58
|
-
}
|
|
59
|
-
function k(e, t, r, n, s, o) {
|
|
60
|
-
let i = y(e), p = y(t), g = y(r), h = y(n), $ = y(s), x = y(o);
|
|
61
|
-
return {
|
|
62
|
-
x1: i,
|
|
63
|
-
x1n: L(e, i),
|
|
64
|
-
y1: p,
|
|
65
|
-
y1n: L(t, p),
|
|
66
|
-
x2: g,
|
|
67
|
-
x2n: L(r, g),
|
|
68
|
-
y2: h,
|
|
69
|
-
y2n: L(n, h),
|
|
70
|
-
x3: $,
|
|
71
|
-
x3n: L(s, $),
|
|
72
|
-
y3: x,
|
|
73
|
-
y3n: L(o, x)
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function z(e, t) {
|
|
77
|
-
switch (t) {
|
|
78
|
-
case "TR": return `c ${e.x1} ${e.y1} ${e.x2} ${e.y2} ${e.x3} ${e.y3}`;
|
|
79
|
-
case "BR": return `c ${e.y1n} ${e.x1} ${e.y2n} ${e.x2} ${e.y3n} ${e.x3}`;
|
|
80
|
-
case "BL": return `c ${e.x1n} ${e.y1n} ${e.x2n} ${e.y2n} ${e.x3n} ${e.y3n}`;
|
|
81
|
-
case "TL": return `c ${e.y1} ${e.x1n} ${e.y2} ${e.x2n} ${e.y3} ${e.x3n}`;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function W(e, t) {
|
|
85
|
-
switch (t) {
|
|
86
|
-
case "TR": return `a ${e.radius} ${e.radius} 0 0 1 ${e.d} ${e.d}`;
|
|
87
|
-
case "BR": return `a ${e.radius} ${e.radius} 0 0 1 ${e.dn} ${e.d}`;
|
|
88
|
-
case "BL": return `a ${e.radius} ${e.radius} 0 0 1 ${e.dn} ${e.dn}`;
|
|
89
|
-
case "TL": return `a ${e.radius} ${e.radius} 0 0 1 ${e.d} ${e.dn}`;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
var it = ({ cornerRadius: e, roundingAndSmoothingBudget: t }) => {
|
|
93
|
-
let r = Math.min(e, t);
|
|
94
|
-
if (r <= 0) return q;
|
|
95
|
-
let n = y(r), s = {
|
|
96
|
-
radius: n,
|
|
97
|
-
d: n,
|
|
98
|
-
dn: L(r, n)
|
|
99
|
-
};
|
|
100
|
-
return {
|
|
101
|
-
p: r,
|
|
102
|
-
pathSegment: (o) => W(s, o)
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
function Y({ cornerRadius: e, cornerSmoothing: t, preserveSmoothing: r, roundingAndSmoothingBudget: n }) {
|
|
106
|
-
if (e <= 0) return {
|
|
107
|
-
a: 0,
|
|
108
|
-
b: 0,
|
|
109
|
-
c: 0,
|
|
110
|
-
d: 0,
|
|
111
|
-
p: 0,
|
|
112
|
-
arcSectionLength: 0,
|
|
113
|
-
cornerRadius: 0
|
|
114
|
-
};
|
|
115
|
-
let s = (1 + t) * e;
|
|
116
|
-
if (!r) {
|
|
117
|
-
let a = n / e - 1;
|
|
118
|
-
t = Math.min(t, a), s = Math.min(s, n);
|
|
119
|
-
}
|
|
120
|
-
let o = 90 * (1 - t), i = Math.sin(G(o / 2)) * e * Math.sqrt(2), p = (90 - o) / 2, g = e * Math.tan(G(p / 2)), h = 45 * t, $ = g * Math.cos(G(h)), x = $ * Math.tan(G(h)), u = (s - i - $ - x) / 3, c = 2 * u;
|
|
121
|
-
if (r && s > n) {
|
|
122
|
-
let a = n - x - i - $, l = a - a / 6;
|
|
123
|
-
u = Math.min(u, l), c = a - u, s = Math.min(s, n);
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
a: c,
|
|
127
|
-
b: u,
|
|
128
|
-
c: $,
|
|
129
|
-
d: x,
|
|
130
|
-
p: s,
|
|
131
|
-
arcSectionLength: i,
|
|
132
|
-
cornerRadius: e
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
var at = ({ cornerRadius: e, smoothing: t, preserveSmoothing: r, roundingAndSmoothingBudget: n }) => {
|
|
136
|
-
let s = Y({
|
|
137
|
-
cornerRadius: e,
|
|
138
|
-
cornerSmoothing: t,
|
|
139
|
-
preserveSmoothing: r,
|
|
140
|
-
roundingAndSmoothingBudget: n
|
|
141
|
-
});
|
|
142
|
-
if (s.cornerRadius <= 0) return q;
|
|
143
|
-
let o = _t(s);
|
|
144
|
-
return {
|
|
145
|
-
p: s.p,
|
|
146
|
-
pathSegment: (i) => {
|
|
147
|
-
switch (i) {
|
|
148
|
-
case "TR": return `c ${o.a} 0 ${o.ab} 0 ${o.abc} ${o.d} a ${o.r} ${o.r} 0 0 1 ${o.arc} ${o.arc} c ${o.d} ${o.c} ${o.d} ${o.bc} ${o.d} ${o.abc}`;
|
|
149
|
-
case "BR": return `c 0 ${o.a} 0 ${o.ab} ${o.dn} ${o.abc} a ${o.r} ${o.r} 0 0 1 ${o.arcn} ${o.arc} c ${o.cn} ${o.d} ${o.bcn} ${o.d} ${o.abcn} ${o.d}`;
|
|
150
|
-
case "BL": return `c ${o.an} 0 ${o.abn} 0 ${o.abcn} ${o.dn} a ${o.r} ${o.r} 0 0 1 ${o.arcn} ${o.arcn} c ${o.dn} ${o.cn} ${o.dn} ${o.bcn} ${o.dn} ${o.abcn}`;
|
|
151
|
-
case "TL": return `c 0 ${o.an} 0 ${o.abn} ${o.d} ${o.abcn} a ${o.r} ${o.r} 0 0 1 ${o.arc} ${o.arcn} c ${o.c} ${o.dn} ${o.bc} ${o.dn} ${o.abc} ${o.dn}`;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
function _t({ cornerRadius: e, a: t, b: r, c: n, d: s, arcSectionLength: o }) {
|
|
157
|
-
let i = t + r, p = i + n, g = r + n, h = y(t), $ = y(i), x = y(p), u = y(n), c = y(g), a = y(s), m = y(o);
|
|
158
|
-
return {
|
|
159
|
-
a: h,
|
|
160
|
-
an: L(t, h),
|
|
161
|
-
ab: $,
|
|
162
|
-
abn: L(i, $),
|
|
163
|
-
abc: x,
|
|
164
|
-
abcn: L(p, x),
|
|
165
|
-
c: u,
|
|
166
|
-
cn: L(n, u),
|
|
167
|
-
bc: c,
|
|
168
|
-
bcn: L(g, c),
|
|
169
|
-
d: a,
|
|
170
|
-
dn: L(s, a),
|
|
171
|
-
r: y(e),
|
|
172
|
-
arc: m,
|
|
173
|
-
arcn: "-" + m
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
var P = [
|
|
177
|
-
0,
|
|
178
|
-
Math.PI / 6,
|
|
179
|
-
Math.PI / 3,
|
|
180
|
-
Math.PI / 2
|
|
181
|
-
];
|
|
182
|
-
var tt = P.map((e) => Math.sin(e));
|
|
183
|
-
var et = P.map((e) => Math.cos(e));
|
|
184
|
-
var ut = [
|
|
185
|
-
(P[0] + P[1]) / 2,
|
|
186
|
-
(P[1] + P[2]) / 2,
|
|
187
|
-
(P[2] + P[3]) / 2
|
|
188
|
-
];
|
|
189
|
-
var Ft = ut.map((e) => Math.sin(e));
|
|
190
|
-
var Ot = ut.map((e) => Math.cos(e));
|
|
191
|
-
var ct = ({ cornerRadius: e, exponent: t, roundingAndSmoothingBudget: r }) => {
|
|
192
|
-
let n = Math.min(e, r);
|
|
193
|
-
if (n <= 0) return q;
|
|
194
|
-
let s = Number.isFinite(t) ? Math.max(2, t) : 4, o = 2 / s, i = s === 2 ? (u) => u : s === 4 ? Math.sqrt : s === 8 ? (u) => Math.sqrt(Math.sqrt(u)) : (u) => Math.pow(u, o), p = o - 1, g = s === 2 ? () => 1 : s === 4 ? (u) => 1 / Math.sqrt(u) : (u) => Math.pow(u, p), h = P.map((u, c) => c === 0 ? [0, 0] : c === P.length - 1 ? [n, n] : [n * i(tt[c]), n * (1 - i(et[c]))]), $ = P.map((u, c) => {
|
|
195
|
-
if (c === 0) return [1, 0];
|
|
196
|
-
if (c === P.length - 1) return [0, 1];
|
|
197
|
-
let a = o * g(tt[c]) * et[c] * n, m = o * g(et[c]) * tt[c] * n, l = Math.sqrt(a * a + m * m) || 1;
|
|
198
|
-
return [a / l, m / l];
|
|
199
|
-
}), x = [];
|
|
200
|
-
for (let u = 0; u < P.length - 1; u++) {
|
|
201
|
-
let [c, a] = h[u], [m, l] = h[u + 1], [d, f] = $[u], [S, M] = $[u + 1], v = n * i(Ft[u]), b = n * (1 - i(Ot[u])), N = 8 / 3 * (v - (c + m) / 2), B = 8 / 3 * (b - (a + l) / 2), F = S * f - M * d, D = F !== 0 ? (-M * N + S * B) / F : 0, O = F !== 0 ? (d * B - f * N) / F : 0, I = c + D * d, R = a + D * f, _ = m - O * S, H = l - O * M, w = I - c, j = R - a, At = _ - c, Et = H - a, Nt = m - c, It = l - a;
|
|
202
|
-
x.push(k(w, j, At, Et, Nt, It));
|
|
203
|
-
}
|
|
204
|
-
return {
|
|
205
|
-
p: n,
|
|
206
|
-
pathSegment: (u) => {
|
|
207
|
-
let c = z(x[0], u);
|
|
208
|
-
for (let a = 1; a < x.length; a++) c += " " + z(x[a], u);
|
|
209
|
-
return c;
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
function nt(e, t, r, n) {
|
|
214
|
-
if (n <= 0) return {
|
|
215
|
-
x: 0,
|
|
216
|
-
y: 0,
|
|
217
|
-
theta: e
|
|
218
|
-
};
|
|
219
|
-
let o = n / 32, i = 0, p = 0;
|
|
220
|
-
for (let h = 1; h <= 32; h++) {
|
|
221
|
-
let $ = (h - 1) * o, x = $ + o, u = ($ + x) / 2, c = e + t * $ + r / 2 * $ * $, a = e + t * x + r / 2 * x * x, m = e + t * u + r / 2 * u * u;
|
|
222
|
-
i += o / 6 * (Math.cos(c) + 4 * Math.cos(m) + Math.cos(a)), p += o / 6 * (Math.sin(c) + 4 * Math.sin(m) + Math.sin(a));
|
|
223
|
-
}
|
|
224
|
-
let g = e + t * n + r / 2 * n * n;
|
|
225
|
-
return {
|
|
226
|
-
x: i,
|
|
227
|
-
y: p,
|
|
228
|
-
theta: g
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
var qt = 1e-6;
|
|
232
|
-
var pt = ({ cornerRadius: e, smoothing: t, roundingAndSmoothingBudget: r }) => {
|
|
233
|
-
if (e <= 0) return q;
|
|
234
|
-
let n = Math.max(0, Math.min(1, t)), s = e, o = Math.PI / 4 * n, i = Math.PI / 2 * s * n, p = i > 0 ? 1 / (s * i) : 0, { x: g, y: h } = i > 0 ? nt(0, 0, p, i) : {
|
|
235
|
-
x: 0,
|
|
236
|
-
y: 0
|
|
237
|
-
}, { x: $, y: x } = i > 0 ? nt(0, 0, p, i / 2) : {
|
|
238
|
-
x: 0,
|
|
239
|
-
y: 0
|
|
240
|
-
}, a = g - s * Math.sin(o) + (h + s * Math.cos(o)), m = a, l = s, d = g, f = h, S = $, M = x;
|
|
241
|
-
if (a > r && a > 0) {
|
|
242
|
-
let R = r / a;
|
|
243
|
-
m = r, l = s * R, d = g * R, f = h * R, S = $ * R, M = x * R;
|
|
244
|
-
}
|
|
245
|
-
if (m <= 0) return q;
|
|
246
|
-
let v = Math.cos(o), b = Math.sin(o), N = 0, B = 0;
|
|
247
|
-
i > 0 && (b > 1e-12 && (B = 8 / 3 * (f / 2 - M) / b), N = 8 / 3 * (S - d / 2) + B * v);
|
|
248
|
-
let F = Math.PI / 2 - 2 * o, D = Math.abs(F) > qt, O = i > 0 ? {
|
|
249
|
-
head: k(N, 0, d - B * v, f - B * b, d, f),
|
|
250
|
-
tail: k(B * b, B * v, f, d - N, f, d)
|
|
251
|
-
} : null, I = null;
|
|
252
|
-
if (D) {
|
|
253
|
-
let R = m - d - f, _ = y(R);
|
|
254
|
-
I = {
|
|
255
|
-
radius: y(l),
|
|
256
|
-
d: _,
|
|
257
|
-
dn: L(R, _)
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
return {
|
|
261
|
-
p: m,
|
|
262
|
-
pathSegment: (R) => {
|
|
263
|
-
if (O === null) return I === null ? "" : W(I, R);
|
|
264
|
-
let _ = z(O.head, R), H = z(O.tail, R);
|
|
265
|
-
return I === null ? _ + " " + H : _ + " " + W(I, R) + " " + H;
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
};
|
|
269
|
-
var dt = {
|
|
270
|
-
arc: it,
|
|
271
|
-
squircle: at,
|
|
272
|
-
superellipse: ct,
|
|
273
|
-
clothoid: pt
|
|
274
|
-
};
|
|
275
|
-
Object.keys(dt);
|
|
276
|
-
function ft(e) {
|
|
277
|
-
return dt[e];
|
|
278
|
-
}
|
|
279
|
-
var U = /* @__PURE__ */ new Map();
|
|
280
|
-
var Z = null;
|
|
281
|
-
function Ht(e, t) {
|
|
282
|
-
return e + "|" + t.cornerRadius + "|" + t.smoothing + "|" + t.exponent + "|" + (t.preserveSmoothing ? 1 : 0) + "|" + t.roundingAndSmoothingBudget;
|
|
283
|
-
}
|
|
284
|
-
function Ut(e) {
|
|
285
|
-
return !Number.isFinite(e.cornerRadius) || !Number.isFinite(e.smoothing) || !Number.isFinite(e.exponent) || !Number.isFinite(e.roundingAndSmoothingBudget);
|
|
286
|
-
}
|
|
287
|
-
function Dt(e) {
|
|
288
|
-
let t = {};
|
|
289
|
-
return {
|
|
290
|
-
p: e.p,
|
|
291
|
-
pathSegment: (r) => {
|
|
292
|
-
let n = t[r];
|
|
293
|
-
if (n !== void 0) return n;
|
|
294
|
-
let s = e.pathSegment(r);
|
|
295
|
-
return t[r] = s, s;
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
function lt(e, t, r) {
|
|
300
|
-
if (Ut(r)) return t(r);
|
|
301
|
-
let n = Ht(e, r), s = U.get(n);
|
|
302
|
-
if (s) return n !== Z && (U.delete(n), U.set(n, s), Z = n), s;
|
|
303
|
-
let o = Dt(t(r));
|
|
304
|
-
return U.size >= 64 && U.delete(U.keys().next().value), U.set(n, o), Z = n, o;
|
|
305
|
-
}
|
|
306
|
-
function X(e, t, r, n) {
|
|
307
|
-
let o = Y({
|
|
308
|
-
cornerRadius: e,
|
|
309
|
-
cornerSmoothing: Math.min(t, n / e - 1),
|
|
310
|
-
preserveSmoothing: r,
|
|
311
|
-
roundingAndSmoothingBudget: n
|
|
312
|
-
}), i = o.a + o.b + o.c;
|
|
313
|
-
return {
|
|
314
|
-
p: o.p,
|
|
315
|
-
a: o.a,
|
|
316
|
-
b: o.b,
|
|
317
|
-
c: o.c,
|
|
318
|
-
d: o.d,
|
|
319
|
-
e: i,
|
|
320
|
-
ax: o.p - i,
|
|
321
|
-
ay: e - o.d,
|
|
322
|
-
R: e
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
function K({ a: e, b: t, c: r, d: n, e: s, ax: o, ay: i, R: p }) {
|
|
326
|
-
let g = e + t, h = t + r, $ = y(e), x = y(g), u = y(s), c = y(r), a = y(h), m = y(n), l = y(o), d = y(i);
|
|
327
|
-
return {
|
|
328
|
-
a: $,
|
|
329
|
-
an: L(e, $),
|
|
330
|
-
ab: x,
|
|
331
|
-
abn: L(g, x),
|
|
332
|
-
e: u,
|
|
333
|
-
en: L(s, u),
|
|
334
|
-
c,
|
|
335
|
-
cn: L(r, c),
|
|
336
|
-
bc: a,
|
|
337
|
-
bcn: L(h, a),
|
|
338
|
-
d: m,
|
|
339
|
-
dn: L(n, m),
|
|
340
|
-
r: y(p),
|
|
341
|
-
ax: l,
|
|
342
|
-
axn: L(o, l),
|
|
343
|
-
ay: d,
|
|
344
|
-
ayn: L(i, d)
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
function bt(e) {
|
|
348
|
-
let t = K(e);
|
|
349
|
-
return `c ${t.a} 0 ${t.ab} 0 ${t.e} ${t.d} a ${t.r} ${t.r} 0 0 1 ${t.ax} ${t.ay} a ${t.r} ${t.r} 0 0 1 ${t.axn} ${t.ay} c ${t.cn} ${t.d} ${t.bcn} ${t.d} ${t.en} ${t.d}`;
|
|
350
|
-
}
|
|
351
|
-
function gt(e) {
|
|
352
|
-
let t = K(e);
|
|
353
|
-
return `c ${t.an} 0 ${t.abn} 0 ${t.en} ${t.dn} a ${t.r} ${t.r} 0 0 1 ${t.axn} ${t.ayn} a ${t.r} ${t.r} 0 0 1 ${t.ax} ${t.ayn} c ${t.c} ${t.dn} ${t.bc} ${t.dn} ${t.e} ${t.dn}`;
|
|
354
|
-
}
|
|
355
|
-
function ht(e) {
|
|
356
|
-
let t = K(e);
|
|
357
|
-
return `c 0 ${t.an} 0 ${t.abn} ${t.d} ${t.en} a ${t.r} ${t.r} 0 0 1 ${t.ay} ${t.axn} a ${t.r} ${t.r} 0 0 1 ${t.ay} ${t.ax} c ${t.d} ${t.c} ${t.d} ${t.bc} ${t.d} ${t.e}`;
|
|
358
|
-
}
|
|
359
|
-
function $t(e) {
|
|
360
|
-
let t = K(e);
|
|
361
|
-
return `c 0 ${t.a} 0 ${t.ab} ${t.dn} ${t.e} a ${t.r} ${t.r} 0 0 1 ${t.ayn} ${t.ax} a ${t.r} ${t.r} 0 0 1 ${t.ayn} ${t.axn} c ${t.dn} ${t.cn} ${t.dn} ${t.bcn} ${t.dn} ${t.en}`;
|
|
362
|
-
}
|
|
363
|
-
function xt(e, t, r, n) {
|
|
364
|
-
let s = Y({
|
|
365
|
-
cornerRadius: e,
|
|
366
|
-
cornerSmoothing: t,
|
|
367
|
-
preserveSmoothing: r,
|
|
368
|
-
roundingAndSmoothingBudget: n
|
|
369
|
-
}), o = G(45 * t);
|
|
370
|
-
return {
|
|
371
|
-
a: s.a,
|
|
372
|
-
b: s.b,
|
|
373
|
-
p: s.p,
|
|
374
|
-
sin: Math.sin(o),
|
|
375
|
-
cos: Math.cos(o)
|
|
376
|
-
};
|
|
377
|
-
}
|
|
378
|
-
var Ct = (e, t, r) => Math.max(0, Math.min(e / t - 1, r));
|
|
379
|
-
var T = (e) => y(Object.is(e, -0) ? 0 : e);
|
|
380
|
-
function yt(e, t, r, n, s) {
|
|
381
|
-
let o = xt(r, Ct(e / 2, r, n), s, e / 2), i = xt(r, Ct(t / 2, r, n), s, t / 2), p = (u, c, a, m, l, d) => {
|
|
382
|
-
let f = m === 0 ? o : i, S = d === 0 ? o : i, M = u + (a + l) * r, v = c + (m + d) * r, b = M - l * r * f.cos - a * r * f.sin, N = v - d * r * f.cos - m * r * f.sin, B = M - a * r * S.cos - l * r * S.sin, F = v - m * r * S.cos - d * r * S.sin, D = u + a * f.p, O = c + m * f.p, I = Math.hypot(B - b, F - N) > 1e-6, R = I ? B : b, _ = I ? F : N, H = u + l * S.p, w = c + d * S.p, j = `L ${T(D)} ${T(O)} `;
|
|
383
|
-
return j += `c ${T(-a * f.a)} ${T(-m * f.a)} ${T(-a * (f.a + f.b))} ${T(-m * (f.a + f.b))} ${T(b - D)} ${T(N - O)} `, I && (j += `a ${T(r)} ${T(r)} 0 0 1 ${T(B - b)} ${T(F - N)} `), j += `c ${T(H - l * (S.a + S.b) - R)} ${T(w - d * (S.a + S.b) - _)} ${T(H - l * S.a - R)} ${T(w - d * S.a - _)} ${T(H - R)} ${T(w - _)}`, j;
|
|
384
|
-
}, g = p(e, 0, -1, 0, 0, 1), h = p(e, t, 0, -1, -1, 0), $ = p(0, t, 1, 0, 0, -1), x = p(0, 0, 0, 1, 1, 0);
|
|
385
|
-
return `M ${T(o.p)} 0 ${g} ${h} ${$} ${x} Z`;
|
|
386
|
-
}
|
|
387
|
-
var Gt = .65;
|
|
388
|
-
var zt = "squircle";
|
|
389
|
-
var C = y;
|
|
390
|
-
function Lt(e) {
|
|
391
|
-
return {
|
|
392
|
-
radius: e.radius,
|
|
393
|
-
curve: e.curve ?? "squircle",
|
|
394
|
-
smoothing: e.smoothing ?? .65,
|
|
395
|
-
exponent: e.exponent ?? 4,
|
|
396
|
-
preserveSmoothing: e.preserveSmoothing ?? true
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
function J(e) {
|
|
400
|
-
return Lt(typeof e == "number" ? { radius: e } : e ?? { radius: 0 });
|
|
401
|
-
}
|
|
402
|
-
function Yt(e) {
|
|
403
|
-
if ("radius" in e) {
|
|
404
|
-
let t = Lt(e);
|
|
405
|
-
return {
|
|
406
|
-
topLeft: t,
|
|
407
|
-
topRight: t,
|
|
408
|
-
bottomRight: t,
|
|
409
|
-
bottomLeft: t
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
return {
|
|
413
|
-
topLeft: J(e.topLeft),
|
|
414
|
-
topRight: J(e.topRight),
|
|
415
|
-
bottomRight: J(e.bottomRight),
|
|
416
|
-
bottomLeft: J(e.bottomLeft)
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
function A(e) {
|
|
420
|
-
return e.length > 0 ? " " + e : "";
|
|
421
|
-
}
|
|
422
|
-
function E(e, t) {
|
|
423
|
-
let r = ft(e.curve);
|
|
424
|
-
return lt(e.curve, r, {
|
|
425
|
-
cornerRadius: t.radius,
|
|
426
|
-
smoothing: e.smoothing,
|
|
427
|
-
exponent: e.exponent,
|
|
428
|
-
preserveSmoothing: e.preserveSmoothing,
|
|
429
|
-
roundingAndSmoothingBudget: t.roundingAndSmoothingBudget
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
var St = 1e-9;
|
|
433
|
-
function Q(e, t, r, n, s) {
|
|
434
|
-
return e.curve === "squircle" && t.curve === "squircle" && Math.abs(r.radius - s) < St && Math.abs(n.radius - s) < St && e.smoothing === t.smoothing && e.preserveSmoothing === t.preserveSmoothing;
|
|
435
|
-
}
|
|
436
|
-
function rt(e, t, r, n) {
|
|
437
|
-
return (e === r || e.curve === r.curve && e.smoothing === r.smoothing && e.exponent === r.exponent && e.preserveSmoothing === r.preserveSmoothing) && (t === n || t.radius === n.radius && t.roundingAndSmoothingBudget === n.roundingAndSmoothingBudget);
|
|
438
|
-
}
|
|
439
|
-
function ot(e, t, r) {
|
|
440
|
-
if (e <= 0 || t <= 0) return "M 0 0 H 0 V 0 H 0 Z";
|
|
441
|
-
let n = Yt(r);
|
|
442
|
-
if (n.topLeft.radius <= 0 && n.topRight.radius <= 0 && n.bottomRight.radius <= 0 && n.bottomLeft.radius <= 0) return `M 0 0 H ${e} V ${t} H 0 Z`;
|
|
443
|
-
let s = st({
|
|
444
|
-
topLeftCornerRadius: n.topLeft.radius,
|
|
445
|
-
topRightCornerRadius: n.topRight.radius,
|
|
446
|
-
bottomRightCornerRadius: n.bottomRight.radius,
|
|
447
|
-
bottomLeftCornerRadius: n.bottomLeft.radius,
|
|
448
|
-
width: e,
|
|
449
|
-
height: t
|
|
450
|
-
}), o = n.topLeft;
|
|
451
|
-
if (wt(n)) {
|
|
452
|
-
let c = Math.min(o.radius, e / 2, t / 2), a = Math.min(e, t) / 2, m = 1e-9;
|
|
453
|
-
if (c > 0 && a > c + m && a < (1 + o.smoothing) * c - m) return yt(e, t, c, o.smoothing, o.preserveSmoothing);
|
|
454
|
-
}
|
|
455
|
-
let i = e >= t, p = i ? t / 2 : e / 2;
|
|
456
|
-
if (i) {
|
|
457
|
-
let c = Q(n.topRight, n.bottomRight, s.topRight, s.bottomRight, p), a = Q(n.topLeft, n.bottomLeft, s.topLeft, s.bottomLeft, p);
|
|
458
|
-
if (c || a) {
|
|
459
|
-
let m = e / 2, l = c ? X(p, n.topRight.smoothing, n.topRight.preserveSmoothing, m) : null, d = a ? X(p, n.topLeft.smoothing, n.topLeft.preserveSmoothing, m) : null, f = d ? null : E(n.topLeft, s.topLeft), S = l ? null : E(n.topRight, s.topRight), M = l ? null : E(n.bottomRight, s.bottomRight), v = d ? null : E(n.bottomLeft, s.bottomLeft), b = "M " + C(d ? d.p : f.p) + " 0";
|
|
460
|
-
return b += " L " + C(e - (l ? l.p : S.p)) + " 0", l ? b += " " + bt(l) : (b += A(S.pathSegment("TR")), b += " L " + C(e) + " " + C(M.p), b += " L " + C(e) + " " + C(t - M.p), b += A(M.pathSegment("BR"))), d ? (b += " L " + C(d.p) + " " + C(t), b += " " + gt(d)) : (b += " L " + C(e - v.p) + " " + C(t), b += " L " + C(v.p) + " " + C(t), b += A(v.pathSegment("BL")), b += " L 0 " + C(t - f.p), b += " L 0 " + C(f.p), b += A(f.pathSegment("TL"))), b + " Z";
|
|
461
|
-
}
|
|
462
|
-
} else {
|
|
463
|
-
let c = Q(n.topLeft, n.topRight, s.topLeft, s.topRight, p), a = Q(n.bottomLeft, n.bottomRight, s.bottomLeft, s.bottomRight, p);
|
|
464
|
-
if (c || a) {
|
|
465
|
-
let m = t / 2, l = c ? X(p, n.topLeft.smoothing, n.topLeft.preserveSmoothing, m) : null, d = a ? X(p, n.bottomLeft.smoothing, n.bottomLeft.preserveSmoothing, m) : null, f = l ? null : E(n.topLeft, s.topLeft), S = l ? null : E(n.topRight, s.topRight), M = d ? null : E(n.bottomRight, s.bottomRight), v = d ? null : E(n.bottomLeft, s.bottomLeft), b;
|
|
466
|
-
return l ? b = "M 0 " + C(l.p) + " " + ht(l) : (b = "M " + C(f.p) + " 0", b += " L " + C(e - S.p) + " 0", b += A(S.pathSegment("TR"))), b += " L " + C(e) + " " + C(t - (d ? d.p : M.p)), d ? b += " " + $t(d) : (b += A(M.pathSegment("BR")), b += " L " + C(v.p) + " " + C(t), b += A(v.pathSegment("BL"))), l ? b += " L 0 " + C(l.p) : (b += " L 0 " + C(t - f.p), b += " L 0 " + C(f.p), b += A(f.pathSegment("TL"))), b + " Z";
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
let g = E(n.topLeft, s.topLeft), h = rt(n.topLeft, s.topLeft, n.topRight, s.topRight) && rt(n.topLeft, s.topLeft, n.bottomRight, s.bottomRight) && rt(n.topLeft, s.topLeft, n.bottomLeft, s.bottomLeft), $ = h ? g : E(n.topRight, s.topRight), x = h ? g : E(n.bottomRight, s.bottomRight), u = h ? g : E(n.bottomLeft, s.bottomLeft);
|
|
470
|
-
return "M " + C(g.p) + " 0 L " + C(e - $.p) + " 0" + A($.pathSegment("TR")) + " L " + C(e) + " " + C(x.p) + " L " + C(e) + " " + C(t - x.p) + A(x.pathSegment("BR")) + " L " + C(e - u.p) + " " + C(t) + " L " + C(u.p) + " " + C(t) + A(u.pathSegment("BL")) + " L 0 " + C(t - g.p) + " L 0 " + C(g.p) + A(g.pathSegment("TL")) + " Z";
|
|
471
|
-
}
|
|
472
|
-
function wt(e) {
|
|
473
|
-
let t = e.topLeft, r = e.topRight, n = e.bottomRight, s = e.bottomLeft;
|
|
474
|
-
return t.curve === "squircle" && r.curve === "squircle" && r.radius === t.radius && r.smoothing === t.smoothing && r.preserveSmoothing === t.preserveSmoothing && n.curve === "squircle" && n.radius === t.radius && n.smoothing === t.smoothing && n.preserveSmoothing === t.preserveSmoothing && s.curve === "squircle" && s.radius === t.radius && s.smoothing === t.smoothing && s.preserveSmoothing === t.preserveSmoothing;
|
|
475
|
-
}
|
|
476
|
-
//#endregion
|
|
477
|
-
export { st as a, it as b, Y as c, at as d, ct as e, pt as f, ft as i, Gt as m, zt as o, ot as p };
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { applySmoothClip, applySmoothShadow } from "./apply.ios.js";
|
|
2
|
-
import { applySmoothClip as applySmoothClip$1, applySmoothShadow as applySmoothShadow$1 } from "./apply.android.js";
|
|
3
|
-
import { outerLayoutProps, paintedStyle } from "./layout-child.js";
|
|
4
|
-
import { defineUniversalComponent, hookSlots, universalPlan, universalProps, universalValue, useCallback, useEffect, useRef } from "@nativescript-community/octane";
|
|
5
|
-
import { isIOS } from "@nativescript/core";
|
|
6
|
-
//#region src/SmoothCorners.tsrx
|
|
7
|
-
var _hs$ = /* @__PURE__ */ hookSlots(6);
|
|
8
|
-
var _h$0 = /* @__PURE__ */ Symbol(_hs$);
|
|
9
|
-
var _h$1 = /* @__PURE__ */ Symbol(_hs$ + 1);
|
|
10
|
-
var _h$2 = /* @__PURE__ */ Symbol(_hs$ + 2);
|
|
11
|
-
var _h$3 = /* @__PURE__ */ Symbol(_hs$ + 3);
|
|
12
|
-
var _h$4 = /* @__PURE__ */ Symbol(_hs$ + 4);
|
|
13
|
-
var _h$5 = /* @__PURE__ */ Symbol(_hs$ + 5);
|
|
14
|
-
var __octaneUniversalPlan0 = universalPlan("nativescript", {
|
|
15
|
-
"kind": "host",
|
|
16
|
-
"type": "gridlayout",
|
|
17
|
-
"propsSlot": 0,
|
|
18
|
-
"children": [{
|
|
19
|
-
"kind": "host",
|
|
20
|
-
"type": "gridlayout",
|
|
21
|
-
"bindings": [
|
|
22
|
-
["ref", 1],
|
|
23
|
-
["id", 2],
|
|
24
|
-
["className", 3],
|
|
25
|
-
["style", 4]
|
|
26
|
-
],
|
|
27
|
-
"children": [{
|
|
28
|
-
"kind": "slot",
|
|
29
|
-
"slot": 5
|
|
30
|
-
}]
|
|
31
|
-
}]
|
|
32
|
-
});
|
|
33
|
-
var applyClip = isIOS ? applySmoothClip : applySmoothClip$1;
|
|
34
|
-
var applyShadow = isIOS ? applySmoothShadow : applySmoothShadow$1;
|
|
35
|
-
var SmoothCorners = defineUniversalComponent("nativescript", function SmoothCorners(props) {
|
|
36
|
-
const state = useRef({
|
|
37
|
-
inner: null,
|
|
38
|
-
outer: null,
|
|
39
|
-
props
|
|
40
|
-
}, _h$0);
|
|
41
|
-
state.current.props = props;
|
|
42
|
-
const apply = useCallback(() => {
|
|
43
|
-
const s = state.current;
|
|
44
|
-
if (s.inner) applyClip(s.inner, s.props);
|
|
45
|
-
if (s.outer) applyShadow(s.outer, s.props);
|
|
46
|
-
}, [], _h$1);
|
|
47
|
-
const bind = useCallback((which) => (view) => {
|
|
48
|
-
const s = state.current;
|
|
49
|
-
const prev = s[which];
|
|
50
|
-
if (prev && prev !== view) {
|
|
51
|
-
prev.off?.("loaded", apply);
|
|
52
|
-
prev.off?.("layoutChanged", apply);
|
|
53
|
-
}
|
|
54
|
-
s[which] = view;
|
|
55
|
-
if (!view) return;
|
|
56
|
-
view.on?.("loaded", apply);
|
|
57
|
-
view.on?.("layoutChanged", apply);
|
|
58
|
-
apply();
|
|
59
|
-
}, [apply], _h$2);
|
|
60
|
-
const bindInner = useRef(bind("inner"), _h$3);
|
|
61
|
-
const bindOuter = useRef(bind("outer"), _h$4);
|
|
62
|
-
useEffect(() => apply(), [apply], _h$5);
|
|
63
|
-
return universalValue(__octaneUniversalPlan0, [
|
|
64
|
-
universalProps([[
|
|
65
|
-
"set",
|
|
66
|
-
"ref",
|
|
67
|
-
bindOuter.current
|
|
68
|
-
], ["spread", outerLayoutProps(props)]]),
|
|
69
|
-
bindInner.current,
|
|
70
|
-
props.id,
|
|
71
|
-
props.className,
|
|
72
|
-
paintedStyle(props.style),
|
|
73
|
-
props.children
|
|
74
|
-
]);
|
|
75
|
-
}, { "module": "@nativescript-community/octane" });
|
|
76
|
-
//#endregion
|
|
77
|
-
export { SmoothCorners };
|