ws-cleanup-types: archive, audio, data, font, image, layered, music, playlist, subtitle, vector, video: annotations, casts, one value per re-assignment where the solver loses the type
This commit is contained in:
1 parent
dc98aec2ec
commit
f459b2dcdf
44 files changed
+172
-119
No files matched your search
@@ -48,7 +48,7 @@ local LOCAL: { [string]: boolean } = {
|
||||
filter = true,
|
||||
}
|
||||
|
||||
local UNSUPPORTED = { text = true, image = true, pattern = true, mask = true, marker = true, filter = true, foreignObject = true, textPath = true, tspan = true }
|
||||
local UNSUPPORTED: { [string]: boolean } = { text = true, image = true, pattern = true, mask = true, marker = true, filter = true, foreignObject = true, textPath = true, tspan = true }
|
||||
local CONTAINERS = { g = true, a = true, switch = true }
|
||||
local SHAPES = { path = true, rect = true, circle = true, ellipse = true, line = true, polyline = true, polygon = true }
|
||||
|
||||
@@ -103,7 +103,7 @@ local function specified(n: Node, ctx: Ctx): { [string]: string }
|
||||
for c in string.gmatch(attr(n, "class") or "", "%S+") do
|
||||
classes[c] = true
|
||||
end
|
||||
local hits = {}
|
||||
local hits: { Style.Rule } = {}
|
||||
for _, r in ctx.rules do
|
||||
if Style.matches(r.selector, local_(n), attr(n, "id"), classes) then
|
||||
table.insert(hits, r)
|
||||
@@ -296,7 +296,7 @@ local function shape(n: Node, st: { [string]: string }, ctx: Ctx): { PathData.Cm
|
||||
if w <= 0 or h <= 0 then
|
||||
return nil
|
||||
end
|
||||
local rx, ry = len(attr(n, "rx"), vw, st), len(attr(n, "ry"), vh, st)
|
||||
local rx: number?, ry: number? = len(attr(n, "rx"), vw, st), len(attr(n, "ry"), vh, st)
|
||||
if rx and rx < 0 then
|
||||
rx = nil
|
||||
end
|
||||
@@ -305,9 +305,9 @@ local function shape(n: Node, st: { [string]: string }, ctx: Ctx): { PathData.Cm
|
||||
end
|
||||
rx = rx or ry or 0
|
||||
ry = ry or rx
|
||||
rx, ry = math.min(rx :: number, w / 2), math.min(ry :: number, h / 2)
|
||||
local rx: number, ry: number = math.min(rx :: number, w / 2), math.min(ry :: number, h / 2)
|
||||
if rx <= 0 or ry <= 0 then
|
||||
return { { op = "M", x, y }, { op = "L", x + w, y }, { op = "L", x + w, y + h }, { op = "L", x, y + h }, { op = "Z" } }
|
||||
return { { op = "M", x, y }, { op = "L", x + w, y }, { op = "L", x + w, y + h }, { op = "L", x, y + h }, { op = "Z" } } :: { PathData.Cmd }
|
||||
end
|
||||
local out: { PathData.Cmd } = { { op = "M", x + rx, y }, { op = "L", x + w - rx, y } }
|
||||
PathData.arc(x + w - rx, y, rx, ry, 0, false, true, x + w, y + ry, out)
|
||||
@@ -317,7 +317,7 @@ local function shape(n: Node, st: { [string]: string }, ctx: Ctx): { PathData.Cm
|
||||
PathData.arc(x + rx, y + h, rx, ry, 0, false, true, x, y + h - ry, out)
|
||||
table.insert(out, { op = "L", x, y + ry })
|
||||
PathData.arc(x, y + ry, rx, ry, 0, false, true, x + rx, y, out)
|
||||
table.insert(out, { op = "Z" })
|
||||
table.insert(out, { op = "Z" } :: PathData.Cmd)
|
||||
return out
|
||||
elseif kind == "circle" or kind == "ellipse" then
|
||||
local cx, cy = len(attr(n, "cx"), vw, st, 0) :: number, len(attr(n, "cy"), vh, st, 0) :: number
|
||||
@@ -338,12 +338,12 @@ local function shape(n: Node, st: { [string]: string }, ctx: Ctx): { PathData.Cm
|
||||
PathData.arc(cx, cy + ry, rx, ry, 0, false, true, cx - rx, cy, out)
|
||||
PathData.arc(cx - rx, cy, rx, ry, 0, false, true, cx, cy - ry, out)
|
||||
PathData.arc(cx, cy - ry, rx, ry, 0, false, true, cx + rx, cy, out)
|
||||
table.insert(out, { op = "Z" })
|
||||
table.insert(out, { op = "Z" } :: PathData.Cmd)
|
||||
return out
|
||||
elseif kind == "line" then
|
||||
local x1, y1 = len(attr(n, "x1"), vw, st, 0) :: number, len(attr(n, "y1"), vh, st, 0) :: number
|
||||
local x2, y2 = len(attr(n, "x2"), vw, st, 0) :: number, len(attr(n, "y2"), vh, st, 0) :: number
|
||||
return { { op = "M", x1, y1 }, { op = "L", x2, y2 } }
|
||||
return { { op = "M", x1, y1 }, { op = "L", x2, y2 } } :: { PathData.Cmd }
|
||||
elseif kind == "polyline" or kind == "polygon" then
|
||||
local v = Style.numbers(attr(n, "points"))
|
||||
if #v < 4 then
|
||||
@@ -354,7 +354,7 @@ local function shape(n: Node, st: { [string]: string }, ctx: Ctx): { PathData.Cm
|
||||
table.insert(out, { op = "L", v[i], v[i + 1] })
|
||||
end
|
||||
if kind == "polygon" then
|
||||
table.insert(out, { op = "Z" })
|
||||
table.insert(out, { op = "Z" } :: PathData.Cmd)
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user