ws-cleanup-types: Types, api, host: honest annotations; return the full annotated value count
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e35de41c9f
commit
2c15b97cd8
22 files changed
+147
-147
No files matched your search
+15
-15
@@ -95,7 +95,7 @@ local function detect(buf: buffer, name: string?, category: string?, format: str
|
||||
if not e then
|
||||
return nil, Err.new(Err.UNKNOWN_FORMAT, "no format named " .. format .. (if category then " in " .. category else ""))
|
||||
end
|
||||
return e
|
||||
return e, nil
|
||||
end
|
||||
local ext = Input.extension(name)
|
||||
local best: Registry.Entry? = nil
|
||||
@@ -117,12 +117,12 @@ local function detect(buf: buffer, name: string?, category: string?, format: str
|
||||
end
|
||||
end
|
||||
if best then
|
||||
return best
|
||||
return best, nil
|
||||
end
|
||||
if ext then
|
||||
local e = find(ext, category)
|
||||
if e then
|
||||
return e
|
||||
return e, nil
|
||||
end
|
||||
end
|
||||
return nil, Err.new(Err.UNKNOWN_FORMAT, "unrecognised data" .. (if name then " (" .. name .. ")" else "") .. (if category then " for " .. category else ""))
|
||||
@@ -196,7 +196,7 @@ local function pageLoader(value: any, name: string?, o: Options)
|
||||
if type(value) ~= "table" or value.kind ~= "font" or type(value.meta) ~= "table" or type(value.meta.pageFiles) ~= "table" then
|
||||
return
|
||||
end
|
||||
local user = o.loadPage
|
||||
local user: any = o.loadPage
|
||||
if value.pages or (value.meta.pageLoader and type(user) ~= "function") then
|
||||
return
|
||||
end
|
||||
@@ -207,7 +207,7 @@ local function pageLoader(value: any, name: string?, o: Options)
|
||||
value.meta.pageLoader = function(file: string, page: number): (any, Err.Err?)
|
||||
local src: any
|
||||
if type(user) == "function" then
|
||||
src = user(file, page)
|
||||
src = (user :: any)(file, page)
|
||||
else
|
||||
src = (dir :: string) .. file
|
||||
end
|
||||
@@ -304,7 +304,7 @@ end
|
||||
|
||||
-- load(src, opts?) -> value | nil, Err
|
||||
function F.load(src: any, opts: Options?): (any, Err.Err?)
|
||||
local o = opts or {}
|
||||
local o: Options = opts or {}
|
||||
local buf, ierr, name = Input.resolve(src, o, host)
|
||||
if not buf then
|
||||
return nil, ierr
|
||||
@@ -356,7 +356,7 @@ load = F.load
|
||||
|
||||
-- open(src, opts?) -> a streaming decoder (audio Decoder / VideoDecoder / Demuxer) | nil, Err
|
||||
function F.open(src: any, opts: Options?): (any, Err.Err?)
|
||||
local o = opts or {}
|
||||
local o: Options = opts or {}
|
||||
local buf, ierr, name = Input.resolve(src, o, host)
|
||||
if not buf then
|
||||
return nil, ierr
|
||||
@@ -453,7 +453,7 @@ end
|
||||
|
||||
-- save(value, dest?, opts?) -> buffer (no dest) | true (written to dest) | nil, Err
|
||||
function F.save(value: any, dest: string?, opts: Options?): (any, Err.Err?)
|
||||
local o = opts or {}
|
||||
local o: Options = opts or {}
|
||||
local entry, m, err, key = encoderFor(value, dest, o)
|
||||
if not entry then
|
||||
return nil, err
|
||||
@@ -513,12 +513,12 @@ function F.saveString(value: any, opts: Options?): (string?, Err.Err?)
|
||||
if not buf then
|
||||
return nil, err
|
||||
end
|
||||
return buffer.tostring(buf)
|
||||
return buffer.tostring(buf), nil
|
||||
end
|
||||
|
||||
-- convert(src, format, opts?) -> buffer (or true with opts.out = a path) | nil, Err. opts go to both load and save.
|
||||
function F.convert(src: any, format: string, opts: Options?): (any, Err.Err?)
|
||||
local o = opts or {}
|
||||
local o: Options = opts or {}
|
||||
local value, err = F.load(src, o)
|
||||
if value == nil then
|
||||
return nil, err
|
||||
@@ -531,7 +531,7 @@ end
|
||||
|
||||
-- detect(src, opts?) -> format name | nil, Err
|
||||
function F.detect(src: any, opts: Options?): (string?, Err.Err?)
|
||||
local o = opts or {}
|
||||
local o: Options = opts or {}
|
||||
local buf, ierr, name = Input.resolve(src, o, host)
|
||||
if not buf then
|
||||
return nil, ierr
|
||||
@@ -540,7 +540,7 @@ function F.detect(src: any, opts: Options?): (string?, Err.Err?)
|
||||
if not entry then
|
||||
return nil, err
|
||||
end
|
||||
return entry.name
|
||||
return entry.name, nil
|
||||
end
|
||||
|
||||
export type FormatInfo = { name: string, category: string, extensions: { string }, mime: { string }, caps: { [string]: any } }
|
||||
@@ -568,7 +568,7 @@ end
|
||||
-- ------------------------------------------------------------------------------------------------ category facades
|
||||
-- F.image.load / save / open / formats, F.audio..., F.model... : the same calls restricted to one category
|
||||
local function with(opts: Options?, category: string): Options
|
||||
local o = if opts then table.clone(opts) else {}
|
||||
local o: Options = if opts then table.clone(opts) else {}
|
||||
o.category = category
|
||||
return o
|
||||
end
|
||||
@@ -597,7 +597,7 @@ F.data.null = Types.null
|
||||
for _, fn in { "toBodies", "fromBodies", "tessellate" } do
|
||||
local name: string = fn
|
||||
F.cad[name] = function(value: any, opts: Options?): (any, any)
|
||||
local o = if opts then table.clone(opts) else {}
|
||||
local o: Options = if opts then table.clone(opts) else {}
|
||||
if o.plugins == nil then
|
||||
o.plugins = F.plugins
|
||||
end
|
||||
@@ -659,7 +659,7 @@ F.model.loadTextures = function(scene: any, opts: Options?): (any, { [number]: E
|
||||
if type(scene) ~= "table" or type(scene.textures) ~= "table" then
|
||||
return scene, errs
|
||||
end
|
||||
local resolve = opts and opts.resolve
|
||||
local resolve: ((any) -> any)? = opts and opts.resolve
|
||||
for i, tex in scene.textures do
|
||||
if type(tex) == "table" and tex.image == nil then
|
||||
local data = tex.data
|
||||
|
||||
Reference in new issue
Block a user