-- stickyflow 0.2.2 for LuaLaTeX, licensed under the Apache License 2.0.
-- Built from the sources of stickyflow.js 0.23.2; do not edit, see https://github.com/Stickyflow/stickyflow-latex.
package.preload['stickyflow-core'] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____modules = {}
local ____moduleCache = {}
local ____originalRequire = require
local function require(file, ...)
if ____moduleCache[file] then
return ____moduleCache[file].value
end
if ____modules[file] then
local module = ____modules[file]
local value = nil
if (select("#", ...) > 0) then value = module(...) else value = module(file) end
____moduleCache[file] = { value = value }
return value
else
if ____originalRequire then
return ____originalRequire(file)
else
error("module '" .. file .. "' not found")
end
end
end
____modules = {
["lualib_bundle"] = function(...)
local function __TS__ArrayAt(self, relativeIndex)
local absoluteIndex = relativeIndex < 0 and #self + relativeIndex or relativeIndex
if absoluteIndex >= 0 and absoluteIndex < #self then
return self[absoluteIndex + 1]
end
return nil
end
local function __TS__ArrayIsArray(value)
return type(value) == "table" and (value[1] ~= nil or next(value) == nil)
end
local function __TS__ArrayConcat(self, ...)
local items = {...}
local result = {}
local len = 0
for i = 1, #self do
len = len + 1
result[len] = self[i]
end
for i = 1, #items do
local item = items[i]
if __TS__ArrayIsArray(item) then
for j = 1, #item do
len = len + 1
result[len] = item[j]
end
else
len = len + 1
result[len] = item
end
end
return result
end
local __TS__Symbol, Symbol
do
local symbolMetatable = {__tostring = function(self)
return ("Symbol(" .. (self.description or "")) .. ")"
end}
function __TS__Symbol(description)
return setmetatable({description = description}, symbolMetatable)
end
Symbol = {
asyncDispose = __TS__Symbol("Symbol.asyncDispose"),
dispose = __TS__Symbol("Symbol.dispose"),
iterator = __TS__Symbol("Symbol.iterator"),
hasInstance = __TS__Symbol("Symbol.hasInstance"),
species = __TS__Symbol("Symbol.species"),
toStringTag = __TS__Symbol("Symbol.toStringTag")
}
end
local function __TS__ArrayEntries(array)
local key = 0
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
local result = {done = array[key + 1] == nil, value = {key, array[key + 1]}}
key = key + 1
return result
end
}
end
local function __TS__ArrayEvery(self, callbackfn, thisArg)
for i = 1, #self do
if not callbackfn(thisArg, self[i], i - 1, self) then
return false
end
end
return true
end
local function __TS__ArrayFill(self, value, start, ____end)
local relativeStart = start or 0
local relativeEnd = ____end or #self
if relativeStart < 0 then
relativeStart = relativeStart + #self
end
if relativeEnd < 0 then
relativeEnd = relativeEnd + #self
end
do
local i = relativeStart
while i < relativeEnd do
self[i + 1] = value
i = i + 1
end
end
return self
end
local function __TS__ArrayFilter(self, callbackfn, thisArg)
local result = {}
local len = 0
for i = 1, #self do
if callbackfn(thisArg, self[i], i - 1, self) then
len = len + 1
result[len] = self[i]
end
end
return result
end
local function __TS__ArrayForEach(self, callbackFn, thisArg)
for i = 1, #self do
callbackFn(thisArg, self[i], i - 1, self)
end
end
local function __TS__ArrayFind(self, predicate, thisArg)
for i = 1, #self do
local elem = self[i]
if predicate(thisArg, elem, i - 1, self) then
return elem
end
end
return nil
end
local function __TS__ArrayFindIndex(self, callbackFn, thisArg)
for i = 1, #self do
if callbackFn(thisArg, self[i], i - 1, self) then
return i - 1
end
end
return -1
end
local __TS__Iterator
do
local function iteratorGeneratorStep(self)
local co = self.____coroutine
local status, value = coroutine.resume(co)
if not status then
error(value, 0)
end
if coroutine.status(co) == "dead" then
return
end
return true, value
end
local function iteratorIteratorStep(self)
local result = self:next()
if result.done then
return
end
return true, result.value
end
local function iteratorStringStep(self, index)
index = index + 1
if index > #self then
return
end
return index, string.sub(self, index, index)
end
function __TS__Iterator(iterable)
if type(iterable) == "string" then
return iteratorStringStep, iterable, 0
elseif iterable.____coroutine ~= nil then
return iteratorGeneratorStep, iterable
elseif iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
return iteratorIteratorStep, iterator
else
return ipairs(iterable)
end
end
end
local __TS__ArrayFrom
do
local function arrayLikeStep(self, index)
index = index + 1
if index > self.length then
return
end
return index, self[index]
end
local function arrayLikeIterator(arr)
if type(arr.length) == "number" then
return arrayLikeStep, arr, 0
end
return __TS__Iterator(arr)
end
function __TS__ArrayFrom(arrayLike, mapFn, thisArg)
local result = {}
if mapFn == nil then
for ____, v in arrayLikeIterator(arrayLike) do
result[#result + 1] = v
end
else
local i = 0
for ____, v in arrayLikeIterator(arrayLike) do
local ____mapFn_3 = mapFn
local ____thisArg_1 = thisArg
local ____v_2 = v
local ____i_0 = i
i = ____i_0 + 1
result[#result + 1] = ____mapFn_3(____thisArg_1, ____v_2, ____i_0)
end
end
return result
end
end
local function __TS__ArrayIncludes(self, searchElement, fromIndex)
if fromIndex == nil then
fromIndex = 0
end
local len = #self
local k = fromIndex
if fromIndex < 0 then
k = len + fromIndex
end
if k < 0 then
k = 0
end
for i = k + 1, len do
if self[i] == searchElement then
return true
end
end
return false
end
local function __TS__ArrayIndexOf(self, searchElement, fromIndex)
if fromIndex == nil then
fromIndex = 0
end
local len = #self
if len == 0 then
return -1
end
if fromIndex >= len then
return -1
end
if fromIndex < 0 then
fromIndex = len + fromIndex
if fromIndex < 0 then
fromIndex = 0
end
end
for i = fromIndex + 1, len do
if self[i] == searchElement then
return i - 1
end
end
return -1
end
local function __TS__ArrayJoin(self, separator)
if separator == nil then
separator = ","
end
local parts = {}
for i = 1, #self do
parts[i] = tostring(self[i])
end
return table.concat(parts, separator)
end
local function __TS__ArrayMap(self, callbackfn, thisArg)
local result = {}
for i = 1, #self do
result[i] = callbackfn(thisArg, self[i], i - 1, self)
end
return result
end
local function __TS__ArrayPush(self, ...)
local items = {...}
local len = #self
for i = 1, #items do
len = len + 1
self[len] = items[i]
end
return len
end
local function __TS__ArrayPushArray(self, items)
local len = #self
for i = 1, #items do
len = len + 1
self[len] = items[i]
end
return len
end
local function __TS__CountVarargs(...)
return select("#", ...)
end
local function __TS__ArrayReduce(self, callbackFn, ...)
local len = #self
local k = 0
local accumulator = nil
if __TS__CountVarargs(...) ~= 0 then
accumulator = ...
elseif len > 0 then
accumulator = self[1]
k = 1
else
error("Reduce of empty array with no initial value", 0)
end
for i = k + 1, len do
accumulator = callbackFn(
nil,
accumulator,
self[i],
i - 1,
self
)
end
return accumulator
end
local function __TS__ArrayReduceRight(self, callbackFn, ...)
local len = #self
local k = len - 1
local accumulator = nil
if __TS__CountVarargs(...) ~= 0 then
accumulator = ...
elseif len > 0 then
accumulator = self[k + 1]
k = k - 1
else
error("Reduce of empty array with no initial value", 0)
end
for i = k + 1, 1, -1 do
accumulator = callbackFn(
nil,
accumulator,
self[i],
i - 1,
self
)
end
return accumulator
end
local function __TS__ArrayReverse(self)
local i = 1
local j = #self
while i < j do
local temp = self[j]
self[j] = self[i]
self[i] = temp
i = i + 1
j = j - 1
end
return self
end
local function __TS__ArrayUnshift(self, ...)
local items = {...}
local numItemsToInsert = #items
if numItemsToInsert == 0 then
return #self
end
for i = #self, 1, -1 do
self[i + numItemsToInsert] = self[i]
end
for i = 1, numItemsToInsert do
self[i] = items[i]
end
return #self
end
local function __TS__ArraySort(self, compareFn)
if compareFn ~= nil then
table.sort(
self,
function(a, b) return compareFn(nil, a, b) < 0 end
)
else
table.sort(self)
end
return self
end
local function __TS__ArraySlice(self, first, last)
local len = #self
first = first or 0
if first < 0 then
first = len + first
if first < 0 then
first = 0
end
else
if first > len then
first = len
end
end
last = last or len
if last < 0 then
last = len + last
if last < 0 then
last = 0
end
else
if last > len then
last = len
end
end
local out = {}
first = first + 1
last = last + 1
local n = 1
while first < last do
out[n] = self[first]
first = first + 1
n = n + 1
end
return out
end
local function __TS__ArraySome(self, callbackfn, thisArg)
for i = 1, #self do
if callbackfn(thisArg, self[i], i - 1, self) then
return true
end
end
return false
end
local function __TS__ArraySplice(self, ...)
local args = {...}
local len = #self
local actualArgumentCount = __TS__CountVarargs(...)
local start = args[1]
local deleteCount = args[2]
if start < 0 then
start = len + start
if start < 0 then
start = 0
end
elseif start > len then
start = len
end
local itemCount = actualArgumentCount - 2
if itemCount < 0 then
itemCount = 0
end
local actualDeleteCount
if actualArgumentCount == 0 then
actualDeleteCount = 0
elseif actualArgumentCount == 1 then
actualDeleteCount = len - start
else
actualDeleteCount = deleteCount or 0
if actualDeleteCount < 0 then
actualDeleteCount = 0
end
if actualDeleteCount > len - start then
actualDeleteCount = len - start
end
end
local out = {}
for k = 1, actualDeleteCount do
local from = start + k
if self[from] ~= nil then
out[k] = self[from]
end
end
if itemCount < actualDeleteCount then
for k = start + 1, len - actualDeleteCount do
local from = k + actualDeleteCount
local to = k + itemCount
if self[from] then
self[to] = self[from]
else
self[to] = nil
end
end
for k = len - actualDeleteCount + itemCount + 1, len do
self[k] = nil
end
elseif itemCount > actualDeleteCount then
for k = len - actualDeleteCount, start + 1, -1 do
local from = k + actualDeleteCount
local to = k + itemCount
if self[from] then
self[to] = self[from]
else
self[to] = nil
end
end
end
local j = start + 1
for i = 3, actualArgumentCount do
self[j] = args[i]
j = j + 1
end
for k = #self, len - actualDeleteCount + itemCount + 1, -1 do
self[k] = nil
end
return out
end
local function __TS__ArrayToObject(self)
local object = {}
for i = 1, #self do
object[i - 1] = self[i]
end
return object
end
local function __TS__ArrayFlat(self, depth)
if depth == nil then
depth = 1
end
local result = {}
local len = 0
for i = 1, #self do
local value = self[i]
if depth > 0 and __TS__ArrayIsArray(value) then
local toAdd
if depth == 1 then
toAdd = value
else
toAdd = __TS__ArrayFlat(value, depth - 1)
end
for j = 1, #toAdd do
local val = toAdd[j]
len = len + 1
result[len] = val
end
else
len = len + 1
result[len] = value
end
end
return result
end
local function __TS__ArrayFlatMap(self, callback, thisArg)
local result = {}
local len = 0
for i = 1, #self do
local value = callback(thisArg, self[i], i - 1, self)
if __TS__ArrayIsArray(value) then
for j = 1, #value do
len = len + 1
result[len] = value[j]
end
else
len = len + 1
result[len] = value
end
end
return result
end
local function __TS__ArraySetLength(self, length)
if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then
error(
"invalid array length: " .. tostring(length),
0
)
end
for i = length + 1, #self do
self[i] = nil
end
return length
end
local __TS__Unpack = table.unpack or unpack
local function __TS__ArrayToReversed(self)
local copy = {__TS__Unpack(self)}
__TS__ArrayReverse(copy)
return copy
end
local function __TS__ArrayToSorted(self, compareFn)
local copy = {__TS__Unpack(self)}
__TS__ArraySort(copy, compareFn)
return copy
end
local function __TS__ArrayToSpliced(self, start, deleteCount, ...)
local copy = {__TS__Unpack(self)}
__TS__ArraySplice(copy, start, deleteCount, ...)
return copy
end
local function __TS__ArrayWith(self, index, value)
local copy = {__TS__Unpack(self)}
copy[index + 1] = value
return copy
end
local function __TS__New(target, ...)
local instance = setmetatable({}, target.prototype)
instance:____constructor(...)
return instance
end
local function __TS__InstanceOf(obj, classTbl)
if type(classTbl) ~= "table" then
error("Right-hand side of 'instanceof' is not an object", 0)
end
if classTbl[Symbol.hasInstance] ~= nil then
return not not classTbl[Symbol.hasInstance](classTbl, obj)
end
if type(obj) == "table" then
local luaClass = obj.constructor
while luaClass ~= nil do
if luaClass == classTbl then
return true
end
luaClass = luaClass.____super
end
end
return false
end
local function __TS__Class(self)
local c = {prototype = {}}
c.prototype.__index = c.prototype
c.prototype.constructor = c
return c
end
local __TS__Promise
do
local function makeDeferredPromiseFactory()
local resolve
local reject
local function executor(____, res, rej)
resolve = res
reject = rej
end
return function()
local promise = __TS__New(__TS__Promise, executor)
return promise, resolve, reject
end
end
local makeDeferredPromise = makeDeferredPromiseFactory()
local function isPromiseLike(value)
return __TS__InstanceOf(value, __TS__Promise)
end
local function doNothing(self)
end
local ____pcall = _G.pcall
__TS__Promise = __TS__Class()
__TS__Promise.name = "__TS__Promise"
function __TS__Promise.prototype.____constructor(self, executor)
self.state = 0
self.fulfilledCallbacks = {}
self.rejectedCallbacks = {}
local success, ____error = ____pcall(
executor,
nil,
function(____, v) return self:resolve(v) end,
function(____, err) return self:reject(err) end
)
if not success then
self:reject(____error)
end
end
function __TS__Promise.resolve(value)
if __TS__InstanceOf(value, __TS__Promise) then
return value
end
local promise = __TS__New(__TS__Promise, doNothing)
promise.state = 1
promise.value = value
return promise
end
function __TS__Promise.reject(reason)
local promise = __TS__New(__TS__Promise, doNothing)
promise.state = 2
promise.rejectionReason = reason
return promise
end
__TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
local promise, resolve, reject = makeDeferredPromise()
self:addCallbacks(
onFulfilled and self:createPromiseResolvingCallback(onFulfilled, resolve, reject) or resolve,
onRejected and self:createPromiseResolvingCallback(onRejected, resolve, reject) or reject
)
return promise
end
function __TS__Promise.prototype.addCallbacks(self, fulfilledCallback, rejectedCallback)
if self.state == 1 then
return fulfilledCallback(nil, self.value)
end
if self.state == 2 then
return rejectedCallback(nil, self.rejectionReason)
end
local ____self_fulfilledCallbacks_0 = self.fulfilledCallbacks
____self_fulfilledCallbacks_0[#____self_fulfilledCallbacks_0 + 1] = fulfilledCallback
local ____self_rejectedCallbacks_1 = self.rejectedCallbacks
____self_rejectedCallbacks_1[#____self_rejectedCallbacks_1 + 1] = rejectedCallback
end
function __TS__Promise.prototype.catch(self, onRejected)
return self["then"](self, nil, onRejected)
end
function __TS__Promise.prototype.finally(self, onFinally)
if type(onFinally) ~= "function" then
return self["then"](self, onFinally, onFinally)
end
return self["then"](
self,
function(____, x)
local ____self_2 = __TS__New(
__TS__Promise,
function(____, resolve) return resolve(
nil,
onFinally(nil)
) end
)
return ____self_2["then"](
____self_2,
function() return x end
)
end,
function(____, e)
local ____self_3 = __TS__New(
__TS__Promise,
function(____, resolve) return resolve(
nil,
onFinally(nil)
) end
)
return ____self_3["then"](
____self_3,
function()
error(e, 0)
end
)
end
)
end
function __TS__Promise.prototype.resolve(self, value)
if isPromiseLike(value) then
return value:addCallbacks(
function(____, v) return self:resolve(v) end,
function(____, err) return self:reject(err) end
)
end
if self.state == 0 then
self.state = 1
self.value = value
return self:invokeCallbacks(self.fulfilledCallbacks, value)
end
end
function __TS__Promise.prototype.reject(self, reason)
if self.state == 0 then
self.state = 2
self.rejectionReason = reason
return self:invokeCallbacks(self.rejectedCallbacks, reason)
end
end
function __TS__Promise.prototype.invokeCallbacks(self, callbacks, value)
local callbacksLength = #callbacks
if callbacksLength ~= 0 then
for i = 1, callbacksLength - 1 do
callbacks[i](callbacks, value)
end
return callbacks[callbacksLength](callbacks, value)
end
end
function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
return function(____, value)
local success, resultOrError = ____pcall(f, nil, value)
if not success then
return reject(nil, resultOrError)
end
return self:handleCallbackValue(resultOrError, resolve, reject)
end
end
function __TS__Promise.prototype.handleCallbackValue(self, value, resolve, reject)
if isPromiseLike(value) then
local nextpromise = value
if nextpromise.state == 1 then
return resolve(nil, nextpromise.value)
elseif nextpromise.state == 2 then
return reject(nil, nextpromise.rejectionReason)
else
return nextpromise:addCallbacks(resolve, reject)
end
else
return resolve(nil, value)
end
end
end
local __TS__AsyncAwaiter, __TS__Await
do
local ____coroutine = _G.coroutine or ({})
local cocreate = ____coroutine.create
local coresume = ____coroutine.resume
local costatus = ____coroutine.status
local coyield = ____coroutine.yield
function __TS__AsyncAwaiter(generator)
return __TS__New(
__TS__Promise,
function(____, resolve, reject)
local fulfilled, step, resolved, asyncCoroutine
function fulfilled(self, value)
local success, resultOrError = coresume(asyncCoroutine, value)
if success then
return step(resultOrError)
end
return reject(nil, resultOrError)
end
function step(result)
if resolved then
return
end
if costatus(asyncCoroutine) == "dead" then
return resolve(nil, result)
end
return __TS__Promise.resolve(result):addCallbacks(fulfilled, reject)
end
resolved = false
asyncCoroutine = cocreate(generator)
local success, resultOrError = coresume(
asyncCoroutine,
function(____, v)
resolved = true
return __TS__Promise.resolve(v):addCallbacks(resolve, reject)
end
)
if success then
return step(resultOrError)
else
return reject(nil, resultOrError)
end
end
)
end
function __TS__Await(thing)
return coyield(thing)
end
end
local function __TS__ClassExtends(target, base)
target.____super = base
local staticMetatable = setmetatable({__index = base}, base)
setmetatable(target, staticMetatable)
local baseMetatable = getmetatable(base)
if baseMetatable then
if type(baseMetatable.__index) == "function" then
staticMetatable.__index = baseMetatable.__index
end
if type(baseMetatable.__newindex) == "function" then
staticMetatable.__newindex = baseMetatable.__newindex
end
end
setmetatable(target.prototype, base.prototype)
if type(base.prototype.__index) == "function" then
target.prototype.__index = base.prototype.__index
end
if type(base.prototype.__newindex) == "function" then
target.prototype.__newindex = base.prototype.__newindex
end
if type(base.prototype.__tostring) == "function" then
target.prototype.__tostring = base.prototype.__tostring
end
end
local function __TS__CloneDescriptor(____bindingPattern0)
local value
local writable
local set
local get
local configurable
local enumerable
enumerable = ____bindingPattern0.enumerable
configurable = ____bindingPattern0.configurable
get = ____bindingPattern0.get
set = ____bindingPattern0.set
writable = ____bindingPattern0.writable
value = ____bindingPattern0.value
local descriptor = {enumerable = enumerable == true, configurable = configurable == true}
local hasGetterOrSetter = get ~= nil or set ~= nil
local hasValueOrWritableAttribute = writable ~= nil or value ~= nil
if hasGetterOrSetter and hasValueOrWritableAttribute then
error("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute.", 0)
end
if get or set then
descriptor.get = get
descriptor.set = set
else
descriptor.value = value
descriptor.writable = writable == true
end
return descriptor
end
local function __TS__Decorate(self, originalValue, decorators, context)
local result = originalValue
do
local i = #decorators
while i >= 0 do
local decorator = decorators[i + 1]
if decorator ~= nil then
local ____decorator_result_0 = decorator(self, result, context)
if ____decorator_result_0 == nil then
____decorator_result_0 = result
end
result = ____decorator_result_0
end
i = i - 1
end
end
return result
end
local function __TS__ObjectAssign(target, ...)
local sources = {...}
for i = 1, #sources do
local source = sources[i]
if type(source) == "table" then
for key in pairs(source) do
target[key] = source[key]
end
end
end
return target
end
local function __TS__ObjectGetOwnPropertyDescriptor(object, key)
local metatable = getmetatable(object)
if not metatable then
return
end
if not rawget(metatable, "_descriptors") then
return
end
return rawget(metatable, "_descriptors")[key]
end
local __TS__DescriptorGet
do
local getmetatable = _G.getmetatable
local ____rawget = _G.rawget
function __TS__DescriptorGet(self, metatable, key)
while metatable do
local rawResult = ____rawget(metatable, key)
if rawResult ~= nil then
return rawResult
end
local descriptors = ____rawget(metatable, "_descriptors")
if descriptors then
local descriptor = descriptors[key]
if descriptor ~= nil then
if descriptor.get then
return descriptor.get(self)
end
return descriptor.value
end
end
metatable = getmetatable(metatable)
end
end
end
local __TS__DescriptorSet
do
local getmetatable = _G.getmetatable
local ____rawget = _G.rawget
local rawset = _G.rawset
function __TS__DescriptorSet(self, metatable, key, value)
while metatable do
local descriptors = ____rawget(metatable, "_descriptors")
if descriptors then
local descriptor = descriptors[key]
if descriptor ~= nil then
if descriptor.set then
descriptor.set(self, value)
else
if descriptor.writable == false then
error(
((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
0
)
end
descriptor.value = value
end
return
end
end
metatable = getmetatable(metatable)
end
rawset(self, key, value)
end
end
local __TS__SetDescriptor
do
local getmetatable = _G.getmetatable
local function descriptorIndex(self, key)
return __TS__DescriptorGet(
self,
getmetatable(self),
key
)
end
local function descriptorNewIndex(self, key, value)
return __TS__DescriptorSet(
self,
getmetatable(self),
key,
value
)
end
function __TS__SetDescriptor(target, key, desc, isPrototype)
if isPrototype == nil then
isPrototype = false
end
local ____isPrototype_0
if isPrototype then
____isPrototype_0 = target
else
____isPrototype_0 = getmetatable(target)
end
local metatable = ____isPrototype_0
if not metatable then
metatable = {}
setmetatable(target, metatable)
end
if not isPrototype and not rawget(metatable, "_isOwnDescriptorMetatable") then
local instanceMetatable = {}
instanceMetatable._isOwnDescriptorMetatable = true
setmetatable(instanceMetatable, metatable)
setmetatable(target, instanceMetatable)
metatable = instanceMetatable
end
local value = rawget(target, key)
if value ~= nil then
rawset(target, key, nil)
end
if not rawget(metatable, "_descriptors") then
metatable._descriptors = {}
end
metatable._descriptors[key] = __TS__CloneDescriptor(desc)
metatable.__index = descriptorIndex
metatable.__newindex = descriptorNewIndex
end
end
local function __TS__DecorateLegacy(decorators, target, key, desc)
local result = target
do
local i = #decorators
while i >= 0 do
local decorator = decorators[i + 1]
if decorator ~= nil then
local oldResult = result
if key == nil then
result = decorator(nil, result)
elseif desc == true then
local value = rawget(target, key)
local descriptor = __TS__ObjectGetOwnPropertyDescriptor(target, key) or ({configurable = true, writable = true, value = value})
local desc = decorator(nil, target, key, descriptor) or descriptor
local isSimpleValue = desc.configurable == true and desc.writable == true and not desc.get and not desc.set
if isSimpleValue then
rawset(target, key, desc.value)
else
__TS__SetDescriptor(
target,
key,
__TS__ObjectAssign({}, descriptor, desc)
)
end
elseif desc == false then
result = decorator(nil, target, key, desc)
else
result = decorator(nil, target, key)
end
result = result or oldResult
end
i = i - 1
end
end
return result
end
local function __TS__DecorateParam(paramIndex, decorator)
return function(____, target, key) return decorator(nil, target, key, paramIndex) end
end
local function __TS__StringIncludes(self, searchString, position)
if not position then
position = 1
else
position = position + 1
end
local index = string.find(self, searchString, position, true)
return index ~= nil
end
local Error, RangeError, ReferenceError, SyntaxError, TypeError, URIError
do
local function getErrorStack(self, constructor)
if debug == nil then
return nil
end
local level = 1
while true do
local info = debug.getinfo(level, "f")
level = level + 1
if not info then
level = 1
break
elseif info.func == constructor then
break
end
end
if __TS__StringIncludes(_VERSION, "Lua 5.0") then
return debug.traceback(("[Level " .. tostring(level)) .. "]")
elseif _VERSION == "Lua 5.1" then
return string.sub(
debug.traceback("", level),
2
)
else
return debug.traceback(nil, level)
end
end
local function wrapErrorToString(self, getDescription)
return function(self)
local description = getDescription(self)
local caller = debug.getinfo(3, "f")
local isClassicLua = __TS__StringIncludes(_VERSION, "Lua 5.0")
if isClassicLua or caller and caller.func ~= error then
return description
else
return (description .. "\n") .. tostring(self.stack)
end
end
end
local function initErrorClass(self, Type, name)
Type.name = name
return setmetatable(
Type,
{__call = function(____, _self, message) return __TS__New(Type, message) end}
)
end
local ____initErrorClass_1 = initErrorClass
local ____class_0 = __TS__Class()
____class_0.name = ""
function ____class_0.prototype.____constructor(self, message)
if message == nil then
message = ""
end
self.message = message
self.name = "Error"
self.stack = getErrorStack(nil, __TS__New)
local metatable = getmetatable(self)
if metatable and not metatable.__errorToStringPatched then
metatable.__errorToStringPatched = true
metatable.__tostring = wrapErrorToString(nil, metatable.__tostring)
end
end
function ____class_0.prototype.__tostring(self)
return self.message ~= "" and (self.name .. ": ") .. self.message or self.name
end
Error = ____initErrorClass_1(nil, ____class_0, "Error")
local function createErrorClass(self, name)
local ____initErrorClass_3 = initErrorClass
local ____class_2 = __TS__Class()
____class_2.name = ____class_2.name
__TS__ClassExtends(____class_2, Error)
function ____class_2.prototype.____constructor(self, ...)
____class_2.____super.prototype.____constructor(self, ...)
self.name = name
end
return ____initErrorClass_3(nil, ____class_2, name)
end
RangeError = createErrorClass(nil, "RangeError")
ReferenceError = createErrorClass(nil, "ReferenceError")
SyntaxError = createErrorClass(nil, "SyntaxError")
TypeError = createErrorClass(nil, "TypeError")
URIError = createErrorClass(nil, "URIError")
end
local function __TS__ObjectGetOwnPropertyDescriptors(object)
local metatable = getmetatable(object)
if not metatable then
return {}
end
return rawget(metatable, "_descriptors") or ({})
end
local function __TS__Delete(target, key)
local descriptors = __TS__ObjectGetOwnPropertyDescriptors(target)
local descriptor = descriptors[key]
if descriptor then
if not descriptor.configurable then
error(
__TS__New(
TypeError,
((("Cannot delete property " .. tostring(key)) .. " of ") .. tostring(target)) .. "."
),
0
)
end
descriptors[key] = nil
return true
end
target[key] = nil
return true
end
local function __TS__StringAccess(self, index)
if index >= 0 and index < #self then
return string.sub(self, index + 1, index + 1)
end
end
local function __TS__DelegatedYield(iterable)
if type(iterable) == "string" then
for index = 0, #iterable - 1 do
coroutine.yield(__TS__StringAccess(iterable, index))
end
elseif iterable.____coroutine ~= nil then
local co = iterable.____coroutine
while true do
local status, value = coroutine.resume(co)
if not status then
error(value, 0)
end
if coroutine.status(co) == "dead" then
return value
else
coroutine.yield(value)
end
end
elseif iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
while true do
local result = iterator:next()
if result.done then
return result.value
else
coroutine.yield(result.value)
end
end
else
for ____, value in ipairs(iterable) do
coroutine.yield(value)
end
end
end
local function __TS__FunctionBind(fn, ...)
local boundArgs = {...}
return function(____, ...)
local args = {...}
__TS__ArrayUnshift(
args,
__TS__Unpack(boundArgs)
)
return fn(__TS__Unpack(args))
end
end
local __TS__Generator
do
local function generatorIterator(self)
return self
end
local function generatorNext(self, ...)
local co = self.____coroutine
if coroutine.status(co) == "dead" then
return {done = true}
end
local status, value = coroutine.resume(co, ...)
if not status then
error(value, 0)
end
return {
value = value,
done = coroutine.status(co) == "dead"
}
end
function __TS__Generator(fn)
return function(...)
local args = {...}
local argsLength = __TS__CountVarargs(...)
return {
____coroutine = coroutine.create(function() return fn(__TS__Unpack(args, 1, argsLength)) end),
[Symbol.iterator] = generatorIterator,
next = generatorNext
}
end
end
end
local function __TS__InstanceOfObject(value)
local valueType = type(value)
return valueType == "table" or valueType == "function"
end
local function __TS__LuaIteratorSpread(self, state, firstKey)
local results = {}
local key, value = self(state, firstKey)
while key do
results[#results + 1] = {key, value}
key, value = self(state, key)
end
return __TS__Unpack(results)
end
local Map
do
Map = __TS__Class()
Map.name = "Map"
function Map.prototype.____constructor(self, entries)
self[Symbol.toStringTag] = "Map"
self.items = {}
self.size = 0
self.nextKey = {}
self.previousKey = {}
if entries == nil then
return
end
local iterable = entries
if iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
while true do
local result = iterator:next()
if result.done then
break
end
local value = result.value
self:set(value[1], value[2])
end
else
local array = entries
for ____, kvp in ipairs(array) do
self:set(kvp[1], kvp[2])
end
end
end
function Map.prototype.clear(self)
self.items = {}
self.nextKey = {}
self.previousKey = {}
self.firstKey = nil
self.lastKey = nil
self.size = 0
end
function Map.prototype.delete(self, key)
local contains = self:has(key)
if contains then
self.size = self.size - 1
local next = self.nextKey[key]
local previous = self.previousKey[key]
if next ~= nil and previous ~= nil then
self.nextKey[previous] = next
self.previousKey[next] = previous
elseif next ~= nil then
self.firstKey = next
self.previousKey[next] = nil
elseif previous ~= nil then
self.lastKey = previous
self.nextKey[previous] = nil
else
self.firstKey = nil
self.lastKey = nil
end
self.nextKey[key] = nil
self.previousKey[key] = nil
end
self.items[key] = nil
return contains
end
function Map.prototype.forEach(self, callback)
for ____, key in __TS__Iterator(self:keys()) do
callback(nil, self.items[key], key, self)
end
end
function Map.prototype.get(self, key)
return self.items[key]
end
function Map.prototype.has(self, key)
return self.nextKey[key] ~= nil or self.lastKey == key
end
function Map.prototype.set(self, key, value)
local isNewValue = not self:has(key)
if isNewValue then
self.size = self.size + 1
end
self.items[key] = value
if self.firstKey == nil then
self.firstKey = key
self.lastKey = key
elseif isNewValue then
self.nextKey[self.lastKey] = key
self.previousKey[key] = self.lastKey
self.lastKey = key
end
return self
end
Map.prototype[Symbol.iterator] = function(self)
return self:entries()
end
function Map.prototype.entries(self)
local function getFirstKey()
return self.firstKey
end
local items = self.items
local nextKey = self.nextKey
local key
local started = false
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
if not started then
started = true
key = getFirstKey(nil)
else
key = nextKey[key]
end
return {done = not key, value = {key, items[key]}}
end
}
end
function Map.prototype.keys(self)
local function getFirstKey()
return self.firstKey
end
local nextKey = self.nextKey
local key
local started = false
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
if not started then
started = true
key = getFirstKey(nil)
else
key = nextKey[key]
end
return {done = not key, value = key}
end
}
end
function Map.prototype.values(self)
local function getFirstKey()
return self.firstKey
end
local items = self.items
local nextKey = self.nextKey
local key
local started = false
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
if not started then
started = true
key = getFirstKey(nil)
else
key = nextKey[key]
end
return {done = not key, value = items[key]}
end
}
end
Map[Symbol.species] = Map
end
local function __TS__MapGroupBy(items, keySelector)
local result = __TS__New(Map)
local i = 0
for ____, item in __TS__Iterator(items) do
local key = keySelector(nil, item, i)
if result:has(key) then
local ____temp_0 = result:get(key)
____temp_0[#____temp_0 + 1] = item
else
result:set(key, {item})
end
i = i + 1
end
return result
end
local __TS__Match = string.match
local __TS__MathAtan2 = math.atan2 or math.atan
local __TS__MathModf = math.modf
local function __TS__NumberIsNaN(value)
return value ~= value
end
local function __TS__MathSign(val)
if __TS__NumberIsNaN(val) or val == 0 then
return val
end
if val < 0 then
return -1
end
return 1
end
local function __TS__NumberIsFinite(value)
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
end
local function __TS__MathTrunc(val)
if not __TS__NumberIsFinite(val) or val == 0 then
return val
end
return val > 0 and math.floor(val) or math.ceil(val)
end
local function __TS__Number(value)
local valueType = type(value)
if valueType == "number" then
return value
elseif valueType == "string" then
local numberValue = tonumber(value)
if numberValue then
return numberValue
end
if value == "Infinity" then
return math.huge
end
if value == "-Infinity" then
return -math.huge
end
local stringWithoutSpaces = string.gsub(value, "%s", "")
if stringWithoutSpaces == "" then
return 0
end
return 0 / 0
elseif valueType == "boolean" then
return value and 1 or 0
else
return 0 / 0
end
end
local function __TS__NumberIsInteger(value)
return __TS__NumberIsFinite(value) and math.floor(value) == value
end
local function __TS__StringSubstring(self, start, ____end)
if ____end ~= ____end then
____end = 0
end
if ____end ~= nil and start > ____end then
start, ____end = ____end, start
end
if start >= 0 then
start = start + 1
else
start = 1
end
if ____end ~= nil and ____end < 0 then
____end = 0
end
return string.sub(self, start, ____end)
end
local __TS__ParseInt
do
local parseIntBasePattern = "0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTvVwWxXyYzZ"
function __TS__ParseInt(numberString, base)
if base == nil then
base = 10
local hexMatch = __TS__Match(numberString, "^%s*-?0[xX]")
if hexMatch ~= nil then
base = 16
numberString = (__TS__Match(hexMatch, "-")) and "-" .. __TS__StringSubstring(numberString, #hexMatch) or __TS__StringSubstring(numberString, #hexMatch)
end
end
if base < 2 or base > 36 then
return 0 / 0
end
local allowedDigits = base <= 10 and __TS__StringSubstring(parseIntBasePattern, 0, base) or __TS__StringSubstring(parseIntBasePattern, 0, 10 + 2 * (base - 10))
local pattern = ("^%s*(-?[" .. allowedDigits) .. "]*)"
local number = tonumber((__TS__Match(numberString, pattern)), base)
if number == nil then
return 0 / 0
end
if number >= 0 then
return math.floor(number)
else
return math.ceil(number)
end
end
end
local function __TS__ParseFloat(numberString)
local infinityMatch = __TS__Match(numberString, "^%s*(-?Infinity)")
if infinityMatch ~= nil then
return __TS__StringAccess(infinityMatch, 0) == "-" and -math.huge or math.huge
end
local number = tonumber((__TS__Match(numberString, "^%s*(-?%d+%.?%d*)")))
return number or 0 / 0
end
local __TS__NumberToString
do
local radixChars = "0123456789abcdefghijklmnopqrstuvwxyz"
function __TS__NumberToString(self, radix)
if radix == nil or radix == 10 or self == math.huge or self == -math.huge or self ~= self then
return tostring(self)
end
radix = math.floor(radix)
if radix < 2 or radix > 36 then
error("toString() radix argument must be between 2 and 36", 0)
end
local integer, fraction = __TS__MathModf(math.abs(self))
local result = ""
if radix == 8 then
result = string.format("%o", integer)
elseif radix == 16 then
result = string.format("%x", integer)
else
repeat
do
result = __TS__StringAccess(radixChars, integer % radix) .. result
integer = math.floor(integer / radix)
end
until not (integer ~= 0)
end
if fraction ~= 0 then
result = result .. "."
local delta = 1e-16
repeat
do
fraction = fraction * radix
delta = delta * radix
local digit = math.floor(fraction)
result = result .. __TS__StringAccess(radixChars, digit)
fraction = fraction - digit
end
until not (fraction >= delta)
end
if self < 0 then
result = "-" .. result
end
return result
end
end
local function __TS__NumberToFixed(self, fractionDigits)
if math.abs(self) >= 1e+21 or self ~= self then
return tostring(self)
end
local f = math.floor(fractionDigits or 0)
if f < 0 or f > 99 then
error("toFixed() digits argument must be between 0 and 99", 0)
end
return string.format(
("%." .. tostring(f)) .. "f",
self
)
end
local function __TS__ObjectDefineProperty(target, key, desc)
local luaKey = type(key) == "number" and key + 1 or key
local value = rawget(target, luaKey)
local hasGetterOrSetter = desc.get ~= nil or desc.set ~= nil
local descriptor
if hasGetterOrSetter then
if value ~= nil then
error(
"Cannot redefine property: " .. tostring(key),
0
)
end
descriptor = desc
else
local valueExists = value ~= nil
local ____desc_set_4 = desc.set
local ____desc_get_5 = desc.get
local ____desc_configurable_0 = desc.configurable
if ____desc_configurable_0 == nil then
____desc_configurable_0 = valueExists
end
local ____desc_enumerable_1 = desc.enumerable
if ____desc_enumerable_1 == nil then
____desc_enumerable_1 = valueExists
end
local ____desc_writable_2 = desc.writable
if ____desc_writable_2 == nil then
____desc_writable_2 = valueExists
end
local ____temp_3
if desc.value ~= nil then
____temp_3 = desc.value
else
____temp_3 = value
end
descriptor = {
set = ____desc_set_4,
get = ____desc_get_5,
configurable = ____desc_configurable_0,
enumerable = ____desc_enumerable_1,
writable = ____desc_writable_2,
value = ____temp_3
}
end
__TS__SetDescriptor(target, luaKey, descriptor)
return target
end
local function __TS__ObjectEntries(obj)
local result = {}
local len = 0
for key in pairs(obj) do
len = len + 1
result[len] = {key, obj[key]}
end
return result
end
local function __TS__ObjectFromEntries(entries)
local obj = {}
local iterable = entries
if iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
while true do
local result = iterator:next()
if result.done then
break
end
local value = result.value
obj[value[1]] = value[2]
end
else
for ____, entry in ipairs(entries) do
obj[entry[1]] = entry[2]
end
end
return obj
end
local function __TS__ObjectGroupBy(items, keySelector)
local result = {}
local i = 0
for ____, item in __TS__Iterator(items) do
local key = keySelector(nil, item, i)
if result[key] ~= nil then
local ____result_key_0 = result[key]
____result_key_0[#____result_key_0 + 1] = item
else
result[key] = {item}
end
i = i + 1
end
return result
end
local function __TS__ObjectKeys(obj)
local result = {}
local len = 0
for key in pairs(obj) do
len = len + 1
result[len] = key
end
return result
end
local function __TS__ObjectRest(target, usedProperties)
local result = {}
for property in pairs(target) do
if not usedProperties[property] then
result[property] = target[property]
end
end
return result
end
local function __TS__ObjectValues(obj)
local result = {}
local len = 0
for key in pairs(obj) do
len = len + 1
result[len] = obj[key]
end
return result
end
local function __TS__PromiseAll(iterable)
local results = {}
local toResolve = {}
local numToResolve = 0
local i = 0
for ____, item in __TS__Iterator(iterable) do
if __TS__InstanceOf(item, __TS__Promise) then
if item.state == 1 then
results[i + 1] = item.value
elseif item.state == 2 then
return __TS__Promise.reject(item.rejectionReason)
else
numToResolve = numToResolve + 1
toResolve[i] = item
end
else
results[i + 1] = item
end
i = i + 1
end
if numToResolve == 0 then
return __TS__Promise.resolve(results)
end
return __TS__New(
__TS__Promise,
function(____, resolve, reject)
for index, promise in pairs(toResolve) do
promise["then"](
promise,
function(____, data)
results[index + 1] = data
numToResolve = numToResolve - 1
if numToResolve == 0 then
resolve(nil, results)
end
end,
function(____, reason)
reject(nil, reason)
end
)
end
end
)
end
local function __TS__PromiseAllSettled(iterable)
local results = {}
local toResolve = {}
local numToResolve = 0
local i = 0
for ____, item in __TS__Iterator(iterable) do
if __TS__InstanceOf(item, __TS__Promise) then
if item.state == 1 then
results[i + 1] = {status = "fulfilled", value = item.value}
elseif item.state == 2 then
results[i + 1] = {status = "rejected", reason = item.rejectionReason}
else
numToResolve = numToResolve + 1
toResolve[i] = item
end
else
results[i + 1] = {status = "fulfilled", value = item}
end
i = i + 1
end
if numToResolve == 0 then
return __TS__Promise.resolve(results)
end
return __TS__New(
__TS__Promise,
function(____, resolve)
for index, promise in pairs(toResolve) do
promise["then"](
promise,
function(____, data)
results[index + 1] = {status = "fulfilled", value = data}
numToResolve = numToResolve - 1
if numToResolve == 0 then
resolve(nil, results)
end
end,
function(____, reason)
results[index + 1] = {status = "rejected", reason = reason}
numToResolve = numToResolve - 1
if numToResolve == 0 then
resolve(nil, results)
end
end
)
end
end
)
end
local function __TS__PromiseAny(iterable)
local rejections = {}
local pending = {}
for ____, item in __TS__Iterator(iterable) do
if __TS__InstanceOf(item, __TS__Promise) then
if item.state == 1 then
return __TS__Promise.resolve(item.value)
elseif item.state == 2 then
rejections[#rejections + 1] = item.rejectionReason
else
pending[#pending + 1] = item
end
else
return __TS__Promise.resolve(item)
end
end
if #pending == 0 then
return __TS__Promise.reject("No promises to resolve with .any()")
end
local numResolved = 0
return __TS__New(
__TS__Promise,
function(____, resolve, reject)
for ____, promise in ipairs(pending) do
promise["then"](
promise,
function(____, data)
resolve(nil, data)
end,
function(____, reason)
rejections[#rejections + 1] = reason
numResolved = numResolved + 1
if numResolved == #pending then
reject(nil, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
end
end
)
end
end
)
end
local function __TS__PromiseRace(iterable)
local pending = {}
for ____, item in __TS__Iterator(iterable) do
if __TS__InstanceOf(item, __TS__Promise) then
if item.state == 1 then
return __TS__Promise.resolve(item.value)
elseif item.state == 2 then
return __TS__Promise.reject(item.rejectionReason)
else
pending[#pending + 1] = item
end
else
return __TS__Promise.resolve(item)
end
end
return __TS__New(
__TS__Promise,
function(____, resolve, reject)
for ____, promise in ipairs(pending) do
promise["then"](
promise,
function(____, value) return resolve(nil, value) end,
function(____, reason) return reject(nil, reason) end
)
end
end
)
end
local Set
do
Set = __TS__Class()
Set.name = "Set"
function Set.prototype.____constructor(self, values)
self[Symbol.toStringTag] = "Set"
self.size = 0
self.nextKey = {}
self.previousKey = {}
if values == nil then
return
end
local iterable = values
if iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
while true do
local result = iterator:next()
if result.done then
break
end
self:add(result.value)
end
else
local array = values
for ____, value in ipairs(array) do
self:add(value)
end
end
end
function Set.prototype.add(self, value)
local isNewValue = not self:has(value)
if isNewValue then
self.size = self.size + 1
end
if self.firstKey == nil then
self.firstKey = value
self.lastKey = value
elseif isNewValue then
self.nextKey[self.lastKey] = value
self.previousKey[value] = self.lastKey
self.lastKey = value
end
return self
end
function Set.prototype.clear(self)
self.nextKey = {}
self.previousKey = {}
self.firstKey = nil
self.lastKey = nil
self.size = 0
end
function Set.prototype.delete(self, value)
local contains = self:has(value)
if contains then
self.size = self.size - 1
local next = self.nextKey[value]
local previous = self.previousKey[value]
if next ~= nil and previous ~= nil then
self.nextKey[previous] = next
self.previousKey[next] = previous
elseif next ~= nil then
self.firstKey = next
self.previousKey[next] = nil
elseif previous ~= nil then
self.lastKey = previous
self.nextKey[previous] = nil
else
self.firstKey = nil
self.lastKey = nil
end
self.nextKey[value] = nil
self.previousKey[value] = nil
end
return contains
end
function Set.prototype.forEach(self, callback)
for ____, key in __TS__Iterator(self:keys()) do
callback(nil, key, key, self)
end
end
function Set.prototype.has(self, value)
return self.nextKey[value] ~= nil or self.lastKey == value
end
Set.prototype[Symbol.iterator] = function(self)
return self:values()
end
function Set.prototype.entries(self)
local function getFirstKey()
return self.firstKey
end
local nextKey = self.nextKey
local key
local started = false
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
if not started then
started = true
key = getFirstKey(nil)
else
key = nextKey[key]
end
return {done = not key, value = {key, key}}
end
}
end
function Set.prototype.keys(self)
local function getFirstKey()
return self.firstKey
end
local nextKey = self.nextKey
local key
local started = false
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
if not started then
started = true
key = getFirstKey(nil)
else
key = nextKey[key]
end
return {done = not key, value = key}
end
}
end
function Set.prototype.values(self)
local function getFirstKey()
return self.firstKey
end
local nextKey = self.nextKey
local key
local started = false
return {
[Symbol.iterator] = function(self)
return self
end,
next = function(self)
if not started then
started = true
key = getFirstKey(nil)
else
key = nextKey[key]
end
return {done = not key, value = key}
end
}
end
function Set.prototype.union(self, other)
local result = __TS__New(Set, self)
for ____, item in __TS__Iterator(other) do
result:add(item)
end
return result
end
function Set.prototype.intersection(self, other)
local result = __TS__New(Set)
for ____, item in __TS__Iterator(self) do
if other:has(item) then
result:add(item)
end
end
return result
end
function Set.prototype.difference(self, other)
local result = __TS__New(Set, self)
for ____, item in __TS__Iterator(other) do
result:delete(item)
end
return result
end
function Set.prototype.symmetricDifference(self, other)
local result = __TS__New(Set, self)
for ____, item in __TS__Iterator(other) do
if self:has(item) then
result:delete(item)
else
result:add(item)
end
end
return result
end
function Set.prototype.isSubsetOf(self, other)
for ____, item in __TS__Iterator(self) do
if not other:has(item) then
return false
end
end
return true
end
function Set.prototype.isSupersetOf(self, other)
for ____, item in __TS__Iterator(other) do
if not self:has(item) then
return false
end
end
return true
end
function Set.prototype.isDisjointFrom(self, other)
for ____, item in __TS__Iterator(self) do
if other:has(item) then
return false
end
end
return true
end
Set[Symbol.species] = Set
end
local function __TS__SparseArrayNew(...)
local sparseArray = {...}
sparseArray.sparseLength = __TS__CountVarargs(...)
return sparseArray
end
local function __TS__SparseArrayPush(sparseArray, ...)
local args = {...}
local argsLen = __TS__CountVarargs(...)
local listLen = sparseArray.sparseLength
for i = 1, argsLen do
sparseArray[listLen + i] = args[i]
end
sparseArray.sparseLength = listLen + argsLen
end
local function __TS__SparseArraySpread(sparseArray)
local _unpack = unpack or table.unpack
return _unpack(sparseArray, 1, sparseArray.sparseLength)
end
local WeakMap
do
WeakMap = __TS__Class()
WeakMap.name = "WeakMap"
function WeakMap.prototype.____constructor(self, entries)
self[Symbol.toStringTag] = "WeakMap"
self.items = {}
setmetatable(self.items, {__mode = "k"})
if entries == nil then
return
end
local iterable = entries
if iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
while true do
local result = iterator:next()
if result.done then
break
end
local value = result.value
self.items[value[1]] = value[2]
end
else
for ____, kvp in ipairs(entries) do
self.items[kvp[1]] = kvp[2]
end
end
end
function WeakMap.prototype.delete(self, key)
local contains = self:has(key)
self.items[key] = nil
return contains
end
function WeakMap.prototype.get(self, key)
return self.items[key]
end
function WeakMap.prototype.has(self, key)
return self.items[key] ~= nil
end
function WeakMap.prototype.set(self, key, value)
self.items[key] = value
return self
end
WeakMap[Symbol.species] = WeakMap
end
local WeakSet
do
WeakSet = __TS__Class()
WeakSet.name = "WeakSet"
function WeakSet.prototype.____constructor(self, values)
self[Symbol.toStringTag] = "WeakSet"
self.items = {}
setmetatable(self.items, {__mode = "k"})
if values == nil then
return
end
local iterable = values
if iterable[Symbol.iterator] then
local iterator = iterable[Symbol.iterator](iterable)
while true do
local result = iterator:next()
if result.done then
break
end
self.items[result.value] = true
end
else
for ____, value in ipairs(values) do
self.items[value] = true
end
end
end
function WeakSet.prototype.add(self, value)
self.items[value] = true
return self
end
function WeakSet.prototype.delete(self, value)
local contains = self:has(value)
self.items[value] = nil
return contains
end
function WeakSet.prototype.has(self, value)
return self.items[value] == true
end
WeakSet[Symbol.species] = WeakSet
end
local function __TS__SourceMapTraceBack(fileName, sourceMap)
_G.__TS__sourcemap = _G.__TS__sourcemap or ({})
_G.__TS__sourcemap[fileName] = sourceMap
if _G.__TS__originalTraceback == nil then
local originalTraceback = debug.traceback
_G.__TS__originalTraceback = originalTraceback
debug.traceback = function(thread, message, level)
local trace
if thread == nil and message == nil and level == nil then
trace = originalTraceback()
elseif __TS__StringIncludes(_VERSION, "Lua 5.0") then
trace = originalTraceback((("[Level " .. tostring(level)) .. "] ") .. tostring(message))
else
trace = originalTraceback(thread, message, level)
end
if type(trace) ~= "string" then
return trace
end
local function replacer(____, file, srcFile, line)
local fileSourceMap = _G.__TS__sourcemap[file]
if fileSourceMap ~= nil and fileSourceMap[line] ~= nil then
local data = fileSourceMap[line]
if type(data) == "number" then
return (srcFile .. ":") .. tostring(data)
end
return (data.file .. ":") .. tostring(data.line)
end
return (file .. ":") .. line
end
local result = string.gsub(
trace,
"([^%s<]+)%.lua:(%d+)",
function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
)
local function stringReplacer(____, file, line)
local fileSourceMap = _G.__TS__sourcemap[file]
if fileSourceMap ~= nil and fileSourceMap[line] ~= nil then
local chunkName = (__TS__Match(file, "%[string \"([^\"]+)\"%]"))
local sourceName = string.gsub(chunkName, ".lua$", ".ts")
local data = fileSourceMap[line]
if type(data) == "number" then
return (sourceName .. ":") .. tostring(data)
end
return (data.file .. ":") .. tostring(data.line)
end
return (file .. ":") .. line
end
result = string.gsub(
result,
"(%[string \"[^\"]+\"%]):(%d+)",
function(file, line) return stringReplacer(nil, file, line) end
)
return result
end
end
end
local function __TS__Spread(iterable)
local arr = {}
if type(iterable) == "string" then
for i = 0, #iterable - 1 do
arr[i + 1] = __TS__StringAccess(iterable, i)
end
else
local len = 0
for ____, item in __TS__Iterator(iterable) do
len = len + 1
arr[len] = item
end
end
return __TS__Unpack(arr)
end
local function __TS__StringCharAt(self, pos)
if pos ~= pos then
pos = 0
end
if pos < 0 then
return ""
end
return string.sub(self, pos + 1, pos + 1)
end
local function __TS__StringCharCodeAt(self, index)
if index ~= index then
index = 0
end
if index < 0 then
return 0 / 0
end
return string.byte(self, index + 1) or 0 / 0
end
local function __TS__StringEndsWith(self, searchString, endPosition)
if endPosition == nil or endPosition > #self then
endPosition = #self
end
return string.sub(self, endPosition - #searchString + 1, endPosition) == searchString
end
local function __TS__StringPadEnd(self, maxLength, fillString)
if fillString == nil then
fillString = " "
end
if maxLength ~= maxLength then
maxLength = 0
end
if maxLength == -math.huge or maxLength == math.huge then
error("Invalid string length", 0)
end
if #self >= maxLength or #fillString == 0 then
return self
end
maxLength = maxLength - #self
if maxLength > #fillString then
fillString = fillString .. string.rep(
fillString,
math.floor(maxLength / #fillString)
)
end
return self .. string.sub(
fillString,
1,
math.floor(maxLength)
)
end
local function __TS__StringPadStart(self, maxLength, fillString)
if fillString == nil then
fillString = " "
end
if maxLength ~= maxLength then
maxLength = 0
end
if maxLength == -math.huge or maxLength == math.huge then
error("Invalid string length", 0)
end
if #self >= maxLength or #fillString == 0 then
return self
end
maxLength = maxLength - #self
if maxLength > #fillString then
fillString = fillString .. string.rep(
fillString,
math.floor(maxLength / #fillString)
)
end
return string.sub(
fillString,
1,
math.floor(maxLength)
) .. self
end
local __TS__StringReplace
do
local sub = string.sub
function __TS__StringReplace(source, searchValue, replaceValue)
local startPos, endPos = string.find(source, searchValue, nil, true)
if not startPos then
return source
end
local before = sub(source, 1, startPos - 1)
local replacement = type(replaceValue) == "string" and replaceValue or replaceValue(nil, searchValue, startPos - 1, source)
local after = sub(source, endPos + 1)
return (before .. replacement) .. after
end
end
local __TS__StringSplit
do
local sub = string.sub
local find = string.find
function __TS__StringSplit(source, separator, limit)
if limit == nil then
limit = 4294967295
end
if limit == 0 then
return {}
end
local result = {}
local resultIndex = 1
if separator == nil or separator == "" then
for i = 1, #source do
result[resultIndex] = sub(source, i, i)
resultIndex = resultIndex + 1
end
else
local currentPos = 1
while resultIndex <= limit do
local startPos, endPos = find(source, separator, currentPos, true)
if not startPos then
break
end
result[resultIndex] = sub(source, currentPos, startPos - 1)
resultIndex = resultIndex + 1
currentPos = endPos + 1
end
if resultIndex <= limit then
result[resultIndex] = sub(source, currentPos)
end
end
return result
end
end
local __TS__StringReplaceAll
do
local sub = string.sub
local find = string.find
function __TS__StringReplaceAll(source, searchValue, replaceValue)
if type(replaceValue) == "string" then
local concat = table.concat(
__TS__StringSplit(source, searchValue),
replaceValue
)
if #searchValue == 0 then
return (replaceValue .. concat) .. replaceValue
end
return concat
end
local parts = {}
local partsIndex = 1
if #searchValue == 0 then
parts[1] = replaceValue(nil, "", 0, source)
partsIndex = 2
for i = 1, #source do
parts[partsIndex] = sub(source, i, i)
parts[partsIndex + 1] = replaceValue(nil, "", i, source)
partsIndex = partsIndex + 2
end
else
local currentPos = 1
while true do
local startPos, endPos = find(source, searchValue, currentPos, true)
if not startPos then
break
end
parts[partsIndex] = sub(source, currentPos, startPos - 1)
parts[partsIndex + 1] = replaceValue(nil, searchValue, startPos - 1, source)
partsIndex = partsIndex + 2
currentPos = endPos + 1
end
parts[partsIndex] = sub(source, currentPos)
end
return table.concat(parts)
end
end
local function __TS__StringSlice(self, start, ____end)
if start == nil or start ~= start then
start = 0
end
if ____end ~= ____end then
____end = 0
end
if start >= 0 then
start = start + 1
end
if ____end ~= nil and ____end < 0 then
____end = ____end - 1
end
return string.sub(self, start, ____end)
end
local function __TS__StringStartsWith(self, searchString, position)
if position == nil or position < 0 then
position = 0
end
return string.sub(self, position + 1, #searchString + position) == searchString
end
local function __TS__StringSubstr(self, from, length)
if from ~= from then
from = 0
end
if length ~= nil then
if length ~= length or length <= 0 then
return ""
end
length = length + from
end
if from >= 0 then
from = from + 1
end
return string.sub(self, from, length)
end
local function __TS__StringTrim(self)
local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1")
return result
end
local function __TS__StringTrimEnd(self)
local result = string.gsub(self, "[%s ]*$", "")
return result
end
local function __TS__StringTrimStart(self)
local result = string.gsub(self, "^[%s ]*", "")
return result
end
local __TS__SymbolRegistryFor, __TS__SymbolRegistryKeyFor
do
local symbolRegistry = {}
function __TS__SymbolRegistryFor(key)
if not symbolRegistry[key] then
symbolRegistry[key] = __TS__Symbol(key)
end
return symbolRegistry[key]
end
function __TS__SymbolRegistryKeyFor(sym)
for key in pairs(symbolRegistry) do
if symbolRegistry[key] == sym then
return key
end
end
return nil
end
end
local function __TS__TypeOf(value)
local luaType = type(value)
if luaType == "table" then
return "object"
elseif luaType == "nil" then
return "undefined"
else
return luaType
end
end
local function __TS__Using(self, cb, ...)
local args = {...}
local thrownError
local ok, result = xpcall(
function() return cb(__TS__Unpack(args)) end,
function(err)
thrownError = err
return thrownError
end
)
local argArray = {__TS__Unpack(args)}
do
local i = #argArray - 1
while i >= 0 do
local ____self_0 = argArray[i + 1]
____self_0[Symbol.dispose](____self_0)
i = i - 1
end
end
if not ok then
error(thrownError, 0)
end
return result
end
local function __TS__UsingAsync(self, cb, ...)
local args = {...}
return __TS__AsyncAwaiter(function(____awaiter_resolve)
local thrownError
local ok, result = xpcall(
function() return cb(
nil,
__TS__Unpack(args)
) end,
function(err)
thrownError = err
return thrownError
end
)
local argArray = {__TS__Unpack(args)}
do
local i = #argArray - 1
while i >= 0 do
if argArray[i + 1][Symbol.dispose] ~= nil then
local ____self_0 = argArray[i + 1]
____self_0[Symbol.dispose](____self_0)
end
if argArray[i + 1][Symbol.asyncDispose] ~= nil then
local ____self_1 = argArray[i + 1]
__TS__Await(____self_1[Symbol.asyncDispose](____self_1))
end
i = i - 1
end
end
if not ok then
error(thrownError, 0)
end
return ____awaiter_resolve(nil, result)
end)
end
return {
__TS__ArrayAt = __TS__ArrayAt,
__TS__ArrayConcat = __TS__ArrayConcat,
__TS__ArrayEntries = __TS__ArrayEntries,
__TS__ArrayEvery = __TS__ArrayEvery,
__TS__ArrayFill = __TS__ArrayFill,
__TS__ArrayFilter = __TS__ArrayFilter,
__TS__ArrayForEach = __TS__ArrayForEach,
__TS__ArrayFind = __TS__ArrayFind,
__TS__ArrayFindIndex = __TS__ArrayFindIndex,
__TS__ArrayFrom = __TS__ArrayFrom,
__TS__ArrayIncludes = __TS__ArrayIncludes,
__TS__ArrayIndexOf = __TS__ArrayIndexOf,
__TS__ArrayIsArray = __TS__ArrayIsArray,
__TS__ArrayJoin = __TS__ArrayJoin,
__TS__ArrayMap = __TS__ArrayMap,
__TS__ArrayPush = __TS__ArrayPush,
__TS__ArrayPushArray = __TS__ArrayPushArray,
__TS__ArrayReduce = __TS__ArrayReduce,
__TS__ArrayReduceRight = __TS__ArrayReduceRight,
__TS__ArrayReverse = __TS__ArrayReverse,
__TS__ArrayUnshift = __TS__ArrayUnshift,
__TS__ArraySort = __TS__ArraySort,
__TS__ArraySlice = __TS__ArraySlice,
__TS__ArraySome = __TS__ArraySome,
__TS__ArraySplice = __TS__ArraySplice,
__TS__ArrayToObject = __TS__ArrayToObject,
__TS__ArrayFlat = __TS__ArrayFlat,
__TS__ArrayFlatMap = __TS__ArrayFlatMap,
__TS__ArraySetLength = __TS__ArraySetLength,
__TS__ArrayToReversed = __TS__ArrayToReversed,
__TS__ArrayToSorted = __TS__ArrayToSorted,
__TS__ArrayToSpliced = __TS__ArrayToSpliced,
__TS__ArrayWith = __TS__ArrayWith,
__TS__AsyncAwaiter = __TS__AsyncAwaiter,
__TS__Await = __TS__Await,
__TS__Class = __TS__Class,
__TS__ClassExtends = __TS__ClassExtends,
__TS__CloneDescriptor = __TS__CloneDescriptor,
__TS__CountVarargs = __TS__CountVarargs,
__TS__Decorate = __TS__Decorate,
__TS__DecorateLegacy = __TS__DecorateLegacy,
__TS__DecorateParam = __TS__DecorateParam,
__TS__Delete = __TS__Delete,
__TS__DelegatedYield = __TS__DelegatedYield,
__TS__DescriptorGet = __TS__DescriptorGet,
__TS__DescriptorSet = __TS__DescriptorSet,
Error = Error,
RangeError = RangeError,
ReferenceError = ReferenceError,
SyntaxError = SyntaxError,
TypeError = TypeError,
URIError = URIError,
__TS__FunctionBind = __TS__FunctionBind,
__TS__Generator = __TS__Generator,
__TS__InstanceOf = __TS__InstanceOf,
__TS__InstanceOfObject = __TS__InstanceOfObject,
__TS__Iterator = __TS__Iterator,
__TS__LuaIteratorSpread = __TS__LuaIteratorSpread,
Map = Map,
__TS__MapGroupBy = __TS__MapGroupBy,
__TS__Match = __TS__Match,
__TS__MathAtan2 = __TS__MathAtan2,
__TS__MathModf = __TS__MathModf,
__TS__MathSign = __TS__MathSign,
__TS__MathTrunc = __TS__MathTrunc,
__TS__New = __TS__New,
__TS__Number = __TS__Number,
__TS__NumberIsFinite = __TS__NumberIsFinite,
__TS__NumberIsInteger = __TS__NumberIsInteger,
__TS__NumberIsNaN = __TS__NumberIsNaN,
__TS__ParseInt = __TS__ParseInt,
__TS__ParseFloat = __TS__ParseFloat,
__TS__NumberToString = __TS__NumberToString,
__TS__NumberToFixed = __TS__NumberToFixed,
__TS__ObjectAssign = __TS__ObjectAssign,
__TS__ObjectDefineProperty = __TS__ObjectDefineProperty,
__TS__ObjectEntries = __TS__ObjectEntries,
__TS__ObjectFromEntries = __TS__ObjectFromEntries,
__TS__ObjectGetOwnPropertyDescriptor = __TS__ObjectGetOwnPropertyDescriptor,
__TS__ObjectGetOwnPropertyDescriptors = __TS__ObjectGetOwnPropertyDescriptors,
__TS__ObjectGroupBy = __TS__ObjectGroupBy,
__TS__ObjectKeys = __TS__ObjectKeys,
__TS__ObjectRest = __TS__ObjectRest,
__TS__ObjectValues = __TS__ObjectValues,
__TS__ParseFloat = __TS__ParseFloat,
__TS__ParseInt = __TS__ParseInt,
__TS__Promise = __TS__Promise,
__TS__PromiseAll = __TS__PromiseAll,
__TS__PromiseAllSettled = __TS__PromiseAllSettled,
__TS__PromiseAny = __TS__PromiseAny,
__TS__PromiseRace = __TS__PromiseRace,
Set = Set,
__TS__SetDescriptor = __TS__SetDescriptor,
__TS__SparseArrayNew = __TS__SparseArrayNew,
__TS__SparseArrayPush = __TS__SparseArrayPush,
__TS__SparseArraySpread = __TS__SparseArraySpread,
WeakMap = WeakMap,
WeakSet = WeakSet,
__TS__SourceMapTraceBack = __TS__SourceMapTraceBack,
__TS__Spread = __TS__Spread,
__TS__StringAccess = __TS__StringAccess,
__TS__StringCharAt = __TS__StringCharAt,
__TS__StringCharCodeAt = __TS__StringCharCodeAt,
__TS__StringEndsWith = __TS__StringEndsWith,
__TS__StringIncludes = __TS__StringIncludes,
__TS__StringPadEnd = __TS__StringPadEnd,
__TS__StringPadStart = __TS__StringPadStart,
__TS__StringReplace = __TS__StringReplace,
__TS__StringReplaceAll = __TS__StringReplaceAll,
__TS__StringSlice = __TS__StringSlice,
__TS__StringSplit = __TS__StringSplit,
__TS__StringStartsWith = __TS__StringStartsWith,
__TS__StringSubstr = __TS__StringSubstr,
__TS__StringSubstring = __TS__StringSubstring,
__TS__StringTrim = __TS__StringTrim,
__TS__StringTrimEnd = __TS__StringTrimEnd,
__TS__StringTrimStart = __TS__StringTrimStart,
__TS__Symbol = __TS__Symbol,
Symbol = Symbol,
__TS__SymbolRegistryFor = __TS__SymbolRegistryFor,
__TS__SymbolRegistryKeyFor = __TS__SymbolRegistryKeyFor,
__TS__TypeOf = __TS__TypeOf,
__TS__Unpack = __TS__Unpack,
__TS__Using = __TS__Using,
__TS__UsingAsync = __TS__UsingAsync
}
end,
["core.__shims"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__StringSubstring = ____lualib.__TS__StringSubstring
local __TS__Number = ____lualib.__TS__Number
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__StringIncludes = ____lualib.__TS__StringIncludes
local __TS__New = ____lualib.__TS__New
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local Map = ____lualib.Map
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local __TS__ArraySort = ____lualib.__TS__ArraySort
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local ____exports = {}
local ____repeat
function ____repeat(self, atom, min, max, lazy)
local step
step = function(____, count, s, i, caps, k)
local function more()
return count < max and atom(
nil,
s,
i,
caps,
function(____, j) return j ~= i and step(
nil,
count + 1,
s,
j,
caps,
k
) end
)
end
if count < min then
return atom(
nil,
s,
i,
caps,
function(____, j) return step(
nil,
count + 1,
s,
j,
caps,
k
) end
)
end
local ____lazy_6
if lazy then
____lazy_6 = k(nil, i) or more(nil)
else
____lazy_6 = more(nil) or k(nil, i)
end
return ____lazy_6
end
return function(____, s, i, caps, k) return step(
nil,
0,
s,
i,
caps,
k
) end
end
local function DIGIT(____, c)
return c >= "0" and c <= "9"
end
local function WORD(____, c)
return DIGIT(nil, c) or c >= "a" and c <= "z" or c >= "A" and c <= "Z" or c == "_"
end
local function SPACE(____, c)
return c == " " or c == "\t" or c == "\n" or c == "\r" or c == "\f" or c == "\v"
end
local Parser = __TS__Class()
Parser.name = "Parser"
function Parser.prototype.____constructor(self, src, fold)
self.src = src
self.fold = fold
self.pos = 0
self.groups = 0
end
function Parser.prototype.peek(self)
return __TS__StringSubstring(self.src, self.pos, self.pos + 1)
end
function Parser.prototype.eat(self, c)
if self:peek() == c then
self.pos = self.pos + 1
return true
end
return false
end
function Parser.prototype.parseAlt(self)
local alts = {self:parseSeq()}
while self:eat("|") do
alts[#alts + 1] = self:parseSeq()
end
if #alts == 1 then
return alts[1]
end
return function(____, s, i, caps, k)
for ____, alt in ipairs(alts) do
if alt(
nil,
s,
i,
caps,
k
) then
return true
end
end
return false
end
end
function Parser.prototype.parseSeq(self)
local items = {}
while self.pos < #self.src and self:peek() ~= "|" and self:peek() ~= ")" do
items[#items + 1] = self:parseQuantified()
end
local run
run = function(____, index, s, i, caps, k)
local ____temp_0
if index == #items then
____temp_0 = k(nil, i)
else
____temp_0 = items[index + 1](
items,
s,
i,
caps,
function(____, j) return run(
nil,
index + 1,
s,
j,
caps,
k
) end
)
end
return ____temp_0
end
return function(____, s, i, caps, k) return run(
nil,
0,
s,
i,
caps,
k
) end
end
function Parser.prototype.parseQuantified(self)
local atom = self:parseAtom()
local min = 1
local max = 1
local c = self:peek()
if c == "*" then
min = 0
max = math.huge
self.pos = self.pos + 1
elseif c == "+" then
min = 1
max = math.huge
self.pos = self.pos + 1
elseif c == "?" then
min = 0
max = 1
self.pos = self.pos + 1
elseif c == "{" then
local close = (string.find(
self.src,
"}",
math.max(self.pos + 1, 1),
true
) or 0) - 1
local body = __TS__StringSubstring(self.src, self.pos + 1, close)
local comma = (string.find(body, ",", nil, true) or 0) - 1
if comma < 0 then
min = __TS__Number(body)
max = min
else
min = __TS__Number(__TS__StringSubstring(body, 0, comma))
local upper = __TS__StringSubstring(body, comma + 1)
max = upper == "" and math.huge or __TS__Number(upper)
end
self.pos = close + 1
else
return atom
end
local lazy = self:eat("?")
return ____repeat(
nil,
atom,
min,
max,
lazy
)
end
function Parser.prototype.parseClassEscape(self)
local e = __TS__StringSubstring(self.src, self.pos, self.pos + 1)
self.pos = self.pos + 1
repeat
local ____switch30 = e
local ____cond30 = ____switch30 == "d"
if ____cond30 then
return DIGIT
end
____cond30 = ____cond30 or ____switch30 == "D"
if ____cond30 then
return function(____, c) return not DIGIT(nil, c) end
end
____cond30 = ____cond30 or ____switch30 == "w"
if ____cond30 then
return WORD
end
____cond30 = ____cond30 or ____switch30 == "W"
if ____cond30 then
return function(____, c) return not WORD(nil, c) end
end
____cond30 = ____cond30 or ____switch30 == "s"
if ____cond30 then
return SPACE
end
____cond30 = ____cond30 or ____switch30 == "S"
if ____cond30 then
return function(____, c) return not SPACE(nil, c) end
end
____cond30 = ____cond30 or ____switch30 == "n"
if ____cond30 then
return function(____, c) return c == "\n" end
end
____cond30 = ____cond30 or ____switch30 == "r"
if ____cond30 then
return function(____, c) return c == "\r" end
end
____cond30 = ____cond30 or ____switch30 == "t"
if ____cond30 then
return function(____, c) return c == "\t" end
end
do
return function(____, c) return c == e end
end
until true
end
function Parser.prototype.literal(self, ch)
return self.fold and (function(____, c) return string.lower(c) == string.lower(ch) end) or (function(____, c) return c == ch end)
end
function Parser.prototype.parseClass(self)
local negate = self:eat("^")
local tests = {}
local first = true
while self.pos < #self.src and (first or self:peek() ~= "]") do
first = false
local test
local low
if self:eat("\\") then
local e = self:peek()
test = self:parseClassEscape()
if not __TS__ArrayIncludes({
"d",
"D",
"w",
"W",
"s",
"S"
}, e) then
low = e == "n" and "\n" or (e == "r" and "\r" or (e == "t" and "\t" or e))
end
else
low = self:peek()
self.pos = self.pos + 1
test = self:literal(low)
end
if low ~= nil and self:peek() == "-" and __TS__StringSubstring(self.src, self.pos + 1, self.pos + 2) ~= "]" then
self.pos = self.pos + 1
local high = self:peek()
self.pos = self.pos + 1
if high == "\\" then
high = self:peek()
self.pos = self.pos + 1
end
local from = low
local to = high
test = self.fold and (function(____, c) return string.lower(c) >= string.lower(from) and string.lower(c) <= string.lower(to) or string.upper(c) >= string.upper(from) and string.upper(c) <= string.upper(to) end) or (function(____, c) return c >= from and c <= to end)
end
tests[#tests + 1] = test
end
self.pos = self.pos + 1
return function(____, c)
local hit = false
for ____, t in ipairs(tests) do
if t(nil, c) then
hit = true
break
end
end
local ____negate_1
if negate then
____negate_1 = not hit
else
____negate_1 = hit
end
return ____negate_1
end
end
function Parser.prototype.parseAtom(self)
local c = self:peek()
self.pos = self.pos + 1
if c == "(" then
local capture = true
if __TS__StringSubstring(self.src, self.pos, self.pos + 2) == "?:" then
capture = false
self.pos = self.pos + 2
end
local ____capture_5
if capture then
local ____self_2, ____groups_3 = self, "groups"
local ____self_groups_4 = ____self_2[____groups_3] + 1
____self_2[____groups_3] = ____self_groups_4
____capture_5 = ____self_groups_4
else
____capture_5 = 0
end
local index = ____capture_5
local inner = self:parseAlt()
self.pos = self.pos + 1
if not capture then
return inner
end
return function(____, s, i, caps, k)
local before = caps[index + 1]
local done = inner(
nil,
s,
i,
caps,
function(____, j)
local saved = caps[index + 1]
caps[index + 1] = __TS__StringSubstring(s, i, j)
if k(nil, j) then
return true
end
caps[index + 1] = saved
return false
end
)
if not done then
caps[index + 1] = before
end
return done
end
end
if c == "^" then
return function(____, _s, i, _caps, k) return i == 0 and k(nil, i) end
end
if c == "$" then
return function(____, s, i, _caps, k) return i == #s and k(nil, i) end
end
local test
if c == "." then
test = function(____, ch) return ch ~= "\n" and ch ~= "\r" end
elseif c == "[" then
test = self:parseClass()
elseif c == "\\" then
test = self:parseClassEscape()
else
test = self:literal(c)
end
return function(____, s, i, _caps, k) return i < #s and test(
nil,
__TS__StringSubstring(s, i, i + 1)
) and k(nil, i + 1) end
end
____exports.JsRegExp = __TS__Class()
local JsRegExp = ____exports.JsRegExp
JsRegExp.name = "JsRegExp"
function JsRegExp.prototype.____constructor(self, source, flags)
self.source = source
self.flags = flags
self.lastIndex = 0
self.global = __TS__StringIncludes(flags, "g")
self.ignoreCase = __TS__StringIncludes(flags, "i")
local parser = __TS__New(Parser, source, self.ignoreCase)
local match = parser:parseAlt()
self.pattern = {match = match, groups = parser.groups}
end
function JsRegExp.prototype.matchFrom(self, s, from)
do
local start = from
while start <= #s do
local caps = {}
local ____end = -1
if self.pattern:match(
s,
start,
caps,
function(____, j)
____end = j
return true
end
) then
return {index = start, ["end"] = ____end, caps = caps}
end
start = start + 1
end
end
return nil
end
local function resultOf(self, re, s, found)
local result = {__TS__StringSubstring(s, found.index, found["end"])}
do
local g = 1
while g <= re.pattern.groups do
result[g + 1] = found.caps[g + 1]
g = g + 1
end
end
result.index = found.index
result.input = s
return result
end
function ____exports.__re(self, source, flags)
if flags == nil then
flags = ""
end
return __TS__New(____exports.JsRegExp, source, flags)
end
function ____exports.__exec(self, re, s)
local from = re.global and re.lastIndex or 0
local ____temp_7
if from > #s then
____temp_7 = nil
else
____temp_7 = re:matchFrom(s, from)
end
local found = ____temp_7
if not found then
re.lastIndex = 0
return nil
end
if re.global then
re.lastIndex = found["end"] > found.index and found["end"] or found["end"] + 1
end
return resultOf(nil, re, s, found)
end
function ____exports.__test(self, re, s)
return ____exports.__exec(nil, re, s) ~= nil
end
local function allMatches(self, re, s)
local out = {}
local from = 0
while from <= #s do
local found = re:matchFrom(s, from)
if not found then
break
end
out[#out + 1] = resultOf(nil, re, s, found)
from = found["end"] > found.index and found["end"] or found["end"] + 1
end
return out
end
function ____exports.__match(self, s, re)
if not re.global then
local found = re:matchFrom(s, 0)
return found and resultOf(nil, re, s, found) or nil
end
local all = __TS__ArrayMap(
allMatches(nil, re, s),
function(____, m) return m[1] end
)
return #all > 0 and all or nil
end
function ____exports.__matchAll(self, s, re)
return allMatches(nil, re, s)
end
function ____exports.__search(self, s, re)
local found = re:matchFrom(s, 0)
return found and found.index or -1
end
local function expand(self, template, m)
local out = ""
do
local i = 0
while i < #template do
local c = __TS__StringSubstring(template, i, i + 1)
local next = __TS__StringSubstring(template, i + 1, i + 2)
if c == "$" and next == "&" then
out = out .. m[1]
i = i + 1
elseif c == "$" and DIGIT(nil, next) then
out = out .. (m[__TS__Number(next) + 1] or "")
i = i + 1
elseif c == "$" and next == "$" then
out = out .. "$"
i = i + 1
else
out = out .. c
end
i = i + 1
end
end
return out
end
local function replaceWith(self, s, matches, replacement)
local out = ""
local last = 0
for ____, m in ipairs(matches) do
out = out .. __TS__StringSubstring(s, last, m.index)
if type(replacement) == "string" then
out = out .. expand(nil, replacement, m)
else
local args = {}
do
local g = 0
while g < #m do
args[#args + 1] = m[g + 1]
g = g + 1
end
end
__TS__ArrayPush(args, m.index, s)
out = out .. replacement(
nil,
table.unpack(args)
)
end
last = m.index + #m[1]
end
return out .. __TS__StringSubstring(s, last)
end
function ____exports.__replace(self, s, pattern, replacement)
if type(pattern) == "string" then
local at = (string.find(s, pattern, nil, true) or 0) - 1
if at < 0 then
return s
end
local m = {pattern}
m.index = at
m.input = s
return replaceWith(nil, s, {m}, replacement)
end
if pattern.global then
return replaceWith(
nil,
s,
allMatches(nil, pattern, s),
replacement
)
end
local found = pattern:matchFrom(s, 0)
return found and replaceWith(
nil,
s,
{resultOf(nil, pattern, s, found)},
replacement
) or s
end
function ____exports.__replaceAll(self, s, pattern, replacement)
if type(pattern) == "string" then
return table.concat(
__TS__StringSplit(s, pattern),
type(replacement) == "string" and replacement or "" or ","
)
end
return replaceWith(
nil,
s,
allMatches(nil, pattern, s),
replacement
)
end
function ____exports.__split(self, s, separator, limit)
local out = {}
local last = 0
for ____, m in ipairs(allMatches(nil, separator, s)) do
do
if #m[1] == 0 and (m.index == 0 or m.index == #s) then
goto __continue122
end
out[#out + 1] = __TS__StringSubstring(s, last, m.index)
do
local g = 1
while g < #m do
out[#out + 1] = m[g + 1]
g = g + 1
end
end
last = m.index + #m[1]
end
::__continue122::
end
out[#out + 1] = __TS__StringSubstring(s, last)
return limit == nil and out or __TS__ArraySlice(out, 0, limit)
end
function ____exports.__hypot(self, ...)
local values = {...}
local sum = 0
for ____, v in ipairs(values) do
sum = sum + v * v
end
return math.sqrt(sum)
end
local TWO32 = 4294967296
local TWO31 = 2147483648
local function toUint32(self, x)
if x ~= x or x == math.huge or x == -math.huge then
return 0
end
local n = (x < 0 and math.ceil(x) or math.floor(x)) % TWO32
return n < 0 and n + TWO32 or n
end
local function toInt32(self, x)
local u = toUint32(nil, x)
return u >= TWO31 and u - TWO32 or u
end
function ____exports.__and(self, a, b)
return toInt32(
nil,
toUint32(nil, a) & toUint32(nil, b)
)
end
function ____exports.__or(self, a, b)
return toInt32(
nil,
toUint32(nil, a) | toUint32(nil, b)
)
end
function ____exports.__xor(self, a, b)
return toInt32(
nil,
toUint32(nil, a) ~ toUint32(nil, b)
)
end
function ____exports.__not(self, a)
return toInt32(
nil,
TWO32 - 1 - toUint32(nil, a)
)
end
function ____exports.__shl(self, a, b)
return toInt32(
nil,
toUint32(nil, a) * 2 ^ (toUint32(nil, b) % 32)
)
end
function ____exports.__shr(self, a, b)
return math.floor(toUint32(nil, a) / 2 ^ (toUint32(nil, b) % 32))
end
function ____exports.__sar(self, a, b)
return math.floor(toInt32(nil, a) / 2 ^ (toUint32(nil, b) % 32))
end
function ____exports.__imul(self, a, b)
local ua = toUint32(nil, a)
local ub = toUint32(nil, b)
local high = math.floor(ua / 65536)
local low = ua % 65536
return toInt32(nil, (high * ub % 65536 * 65536 + low * ub) % TWO32)
end
function ____exports.__is(self, a, b)
if type(a) == "number" and type(b) == "number" and a == 0 and b == 0 then
return 1 / a == 1 / b
end
return a == b or a ~= a and b ~= b
end
function ____exports.__isArray(self, value)
return __TS__ArrayIsArray(value)
end
function ____exports.__isFinite(self, value)
return type(value) == "number" and value == value and value ~= math.huge and value ~= -math.huge
end
function ____exports.__newArray(self, length)
local out = {}
do
local i = 0
while i < length do
out[#out + 1] = nil
i = i + 1
end
end
return out
end
local functionCount = 0
local functionNames = __TS__New(Map)
function ____exports.__fnName(self, f)
local name = functionNames:get(f)
if name == nil then
functionCount = functionCount + 1
name = "f" .. tostring(functionCount)
functionNames:set(f, name)
end
return name
end
local function quote(self, s)
local out = "\""
do
local i = 0
while i < #s do
local c = __TS__StringSubstring(s, i, i + 1)
out = out .. (c == "\"" and "\\\"" or (c == "\\" and "\\\\" or (c == "\n" and "\\n" or (c == "\r" and "\\r" or (c == "\t" and "\\t" or c)))))
i = i + 1
end
end
return out .. "\""
end
function ____exports.__json(self, value)
if value == nil or value == nil then
return "null"
end
if type(value) == "string" then
return quote(nil, value)
end
if type(value) == "number" then
return value == value and value ~= math.huge and value ~= -math.huge and tostring(value) or "null"
end
if type(value) == "boolean" then
return value and "true" or "false"
end
if __TS__ArrayIsArray(value) then
return ("[" .. table.concat(
__TS__ArrayMap(
value,
function(____, item) return item == nil and "null" or ____exports.__json(nil, item) end
),
","
)) .. "]"
end
local keys = __TS__ArraySort(__TS__ObjectKeys(value))
local parts = {}
for ____, key in ipairs(keys) do
local item = value[key]
if item ~= nil and type(item) ~= "function" then
parts[#parts + 1] = (quote(nil, key) .. ":") .. ____exports.__json(nil, item)
end
end
return ("{" .. table.concat(parts, ",")) .. "}"
end
function ____exports.__jsonParse(self, text)
local pos = 0
local function ws()
while pos < #text and SPACE(
nil,
__TS__StringSubstring(text, pos, pos + 1)
) do
pos = pos + 1
end
end
local value
value = function()
ws(nil)
local c = __TS__StringSubstring(text, pos, pos + 1)
if c == "\"" then
pos = pos + 1
local out = ""
while pos < #text and __TS__StringSubstring(text, pos, pos + 1) ~= "\"" do
local ch = __TS__StringSubstring(text, pos, pos + 1)
if ch == "\\" then
pos = pos + 1
local e = __TS__StringSubstring(text, pos, pos + 1)
ch = e == "n" and "\n" or (e == "t" and "\t" or (e == "r" and "\r" or e))
end
out = out .. ch
pos = pos + 1
end
pos = pos + 1
return out
end
if c == "[" then
pos = pos + 1
local items = {}
ws(nil)
if __TS__StringSubstring(text, pos, pos + 1) == "]" then
pos = pos + 1
return items
end
while true do
items[#items + 1] = value(nil)
ws(nil)
local sep = __TS__StringSubstring(text, pos, pos + 1)
pos = pos + 1
if sep == "]" then
return items
end
if sep ~= "," then
error(
__TS__New(Error, "bad json"),
0
)
end
end
end
if c == "{" then
pos = pos + 1
local obj = {}
ws(nil)
if __TS__StringSubstring(text, pos, pos + 1) == "}" then
pos = pos + 1
return obj
end
while true do
local key = value(nil)
ws(nil)
pos = pos + 1
obj[key] = value(nil)
ws(nil)
local sep = __TS__StringSubstring(text, pos, pos + 1)
pos = pos + 1
if sep == "}" then
return obj
end
if sep ~= "," then
error(
__TS__New(Error, "bad json"),
0
)
end
end
end
for ____, ____value in ipairs({{"true", true}, {"false", false}, {"null", nil}}) do
local word = ____value[1]
local result = ____value[2]
if __TS__StringSubstring(text, pos, pos + #word) == word then
pos = pos + #word
return result
end
end
local ____end = pos
while ____end < #text and __TS__StringIncludes(
"+-0123456789.eE",
__TS__StringSubstring(text, ____end, ____end + 1)
) do
____end = ____end + 1
end
if ____end == pos then
error(
__TS__New(Error, "bad json"),
0
)
end
local n = __TS__Number(__TS__StringSubstring(text, pos, ____end))
pos = ____end
return n
end
local result = value(nil)
ws(nil)
if pos < #text then
error(
__TS__New(Error, "bad json"),
0
)
end
return result
end
function ____exports.__sort(self, items, compare)
local cmp = compare or (function(____, a, b)
local x = tostring(a)
local y = tostring(b)
return x < y and -1 or (x > y and 1 or 0)
end)
local n = #items
if n < 2 then
return items
end
local src = __TS__ArraySlice(items)
local dst = {}
do
local width = 1
while width < n do
dst = {}
do
local lo = 0
while lo < n do
local mid = math.min(lo + width, n)
local hi = math.min(lo + 2 * width, n)
local i = lo
local j = mid
while i < mid and j < hi do
if cmp(nil, src[j + 1], src[i + 1]) < 0 then
dst[#dst + 1] = src[j + 1]
j = j + 1
else
dst[#dst + 1] = src[i + 1]
i = i + 1
end
end
while i < mid do
dst[#dst + 1] = src[i + 1]
i = i + 1
end
while j < hi do
dst[#dst + 1] = src[j + 1]
j = j + 1
end
lo = lo + 2 * width
end
end
src = dst
width = width * 2
end
end
do
local k = 0
while k < n do
items[k + 1] = src[k + 1]
k = k + 1
end
end
return items
end
function ____exports.__toSorted(self, items, compare)
return ____exports.__sort(
nil,
__TS__ArraySlice(items),
compare
)
end
function ____exports.__t(self, value)
return not (value == nil or value == nil or value == false or value == 0 or value == "" or value ~= value)
end
function ____exports.__lor(self, left, right)
return ____exports.__t(nil, left) and left or right(nil)
end
function ____exports.__land(self, left, right)
local ____t_result_8
if ____exports.__t(nil, left) then
____t_result_8 = right(nil)
else
____t_result_8 = left
end
return ____t_result_8
end
function ____exports.__arr(self, value)
return value
end
function ____exports.__clone(self, value)
return __deepClone(value)
end
function ____exports.__microtask(self, callback)
callback(nil)
end
return ____exports
end,
["core.model.component.categories"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.COMPONENT_CATEGORIES = {
{id = "action", label = "Actions"},
{id = "selection", label = "Selection"},
{id = "value", label = "Value input"},
{id = "text", label = "Text input"},
{id = "indicator", label = "Indicators"},
{id = "instrument", label = "Instruments"},
{id = "navigation", label = "Navigation"},
{id = "container", label = "Containers"}
}
return ____exports
end,
["core.model.component.descriptor"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.component.format"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__NumberIsInteger = ____lualib.__TS__NumberIsInteger
local __TS__StringPadStart = ____lualib.__TS__StringPadStart
local ____exports = {}
function ____exports.formatRollingNumber(self, value, digits)
local text = tostring(value)
if digits == nil then
return text
end
if not __TS__NumberIsInteger(digits) or digits < 1 then
return text
end
return __TS__StringPadStart(text, digits, "0")
end
return ____exports
end,
["core.model.component.supportedTypes"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local ____exports = {}
____exports.BUILT_IN_COMPONENT_TYPES = {"rollingNumber", "tickScale", "ruler"}
function ____exports.isBuiltInComponentType(self, value)
return value ~= nil and __TS__ArrayIncludes(____exports.BUILT_IN_COMPONENT_TYPES, value)
end
return ____exports
end,
["core.model.component.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.component.guards"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____supportedTypes = require("core.model.component.supportedTypes")
local isBuiltInComponentType = ____supportedTypes.isBuiltInComponentType
function ____exports.isGenericComponent(self, component)
return not isBuiltInComponentType(nil, component.type)
end
return ____exports
end,
["core.model.component.builtIns"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.BUILT_IN_DESCRIPTORS = {
{
type = "rollingNumber",
group = "readout",
category = "indicator",
value = {type = "number", writable = false, default = 0},
properties = {},
interaction = "none",
pointerScale = false,
size = {width = 160, height = 90}
},
{
type = "tickScale",
group = "readout",
category = "instrument",
value = {type = "number", writable = false, default = 0},
properties = {},
interaction = "none",
pointerScale = true,
size = {width = 200, height = 200}
},
{
type = "hand",
group = "readout",
category = "instrument",
value = {type = "number", writable = false, default = 0},
properties = {
max = {type = "number", default = 60, min = 1, max = 7200},
start = {type = "number", default = 0, min = -360, max = 360},
length = {
type = "number",
default = 0.8,
min = 0.05,
max = 1,
step = 0.01
},
tail = {
type = "number",
default = 0,
min = 0,
max = 1,
step = 0.01
},
gap = {
type = "number",
default = 0,
min = 0,
max = 1,
step = 0.01
},
width = {type = "number", default = 6, min = 0.5, max = 80},
taper = {
type = "number",
default = 0.4,
min = 0,
max = 1,
step = 0.05
},
color = {type = "color", default = "#ffffff"},
root = {type = "color", default = "", optional = true},
fade = {
type = "number",
default = 0,
min = 0,
max = 1,
step = 0.05
},
tipFade = {
type = "number",
default = 0,
min = 0,
max = 1,
step = 0.05
},
soft = {type = "number", default = 0, min = 0, max = 40},
bloom = {type = "number", default = 0, min = 0, max = 60},
glow = {type = "number", default = 0, min = 0, max = 80},
glowColor = {type = "color", default = "", optional = true},
hub = {type = "number", default = 0, min = 0, max = 80},
hubFill = {type = "color", default = "#000000", optional = true},
hubRing = {type = "number", default = 2, min = 0, max = 40},
animate = {
type = "number",
default = 0,
min = 0,
max = 2000,
step = 10
}
},
interaction = "none",
pointerScale = false,
size = {
width = 200,
height = 200,
minWidth = 20,
minHeight = 20,
aspect = 1
}
},
{
type = "ruler",
group = "input",
category = "instrument",
value = {type = "number", writable = false, default = 0},
properties = {},
interaction = "scale",
pointerScale = true,
size = {width = 120, height = 360}
},
{
type = "switch",
group = "input",
category = "selection",
value = {type = "boolean", writable = true, default = false},
properties = {accent = {type = "color", default = "#5a6bff"}, track = {type = "color", default = "#cbd5e1"}, thumb = {type = "color", default = "#ffffff"}, animate = {
type = "number",
default = 160,
min = 0,
max = 2000,
step = 10
}},
interaction = "toggle",
pointerScale = false,
size = {
width = 52,
height = 30,
minWidth = 36,
minHeight = 20,
aspect = 52 / 30
},
role = "switch"
},
{
type = "checkbox",
group = "input",
category = "selection",
value = {type = "boolean", writable = true, default = false},
properties = {
accent = {type = "color", default = "#5a6bff"},
stroke = {type = "color", default = "#94a3b8"},
check = {type = "color", default = "#ffffff"},
textColor = {type = "color", default = "#0f172a"},
fontSize = {type = "number", default = 14, min = 6, max = 200},
animate = {
type = "number",
default = 160,
min = 0,
max = 2000,
step = 10
}
},
interaction = "toggle",
pointerScale = false,
size = {width = 160, height = 24, minWidth = 18, minHeight = 18},
role = "checkbox"
},
{
type = "toggleButton",
group = "input",
category = "action",
value = {type = "boolean", writable = true, default = false},
properties = {
accent = {type = "color", default = "#5a6bff"},
stroke = {type = "color", default = "#94a3b8"},
textColor = {type = "color", default = "#0f172a"},
onTextColor = {type = "color", default = "#ffffff"},
fontSize = {type = "number", default = 14, min = 6, max = 200},
animate = {
type = "number",
default = 160,
min = 0,
max = 2000,
step = 10
}
},
interaction = "toggle",
pointerScale = false,
size = {width = 120, height = 40, minWidth = 40, minHeight = 24},
role = "button"
},
{
type = "button",
group = "action",
category = "action",
properties = {
accent = {type = "color", default = "#5a6bff"},
textColor = {type = "color", default = "#ffffff"},
radius = {type = "number", default = 8, min = 0, max = 200},
fontSize = {type = "number", default = 14, min = 6, max = 200},
animate = {
type = "number",
default = 160,
min = 0,
max = 2000,
step = 10
}
},
interaction = "press",
pointerScale = false,
size = {width = 120, height = 40, minWidth = 40, minHeight = 24},
role = "button"
},
{
type = "textField",
group = "input",
category = "text",
value = {type = "string", writable = true, default = ""},
properties = {
placeholder = {type = "string", default = ""},
format = {type = "enum", default = "text", options = {"text", "email", "password"}},
variant = {type = "enum", default = "box", options = {"box", "line"}},
textColor = {type = "color", default = "#0f172a"},
placeholderColor = {type = "color", default = "#94a3b8"},
fill = {type = "color", default = "none", optional = true},
stroke = {type = "color", default = "#94a3b8"},
accent = {type = "color", default = "#5a6bff"},
radius = {type = "number", default = 8, min = 0, max = 200},
padding = {type = "number", default = 12, min = 0, max = 80},
fontSize = {type = "number", default = 15, min = 6, max = 200},
animate = {
type = "number",
default = 160,
min = 0,
max = 2000,
step = 10
},
focused = {type = "boolean", default = false}
},
interaction = "type",
pointerScale = false,
size = {width = 240, height = 44, minWidth = 60, minHeight = 24},
role = "textbox"
},
{
type = "slider",
group = "input",
category = "value",
value = {type = "number", writable = true, default = 40},
properties = {
variant = {type = "enum", default = "line", options = {"line", "field"}},
direction = {type = "enum", default = "horizontal", options = {"horizontal", "vertical"}},
ticks = {type = "number", default = 0, min = 0, max = 200},
tickColor = {type = "color", default = "#94a3b8"},
min = {type = "number", default = 0},
max = {type = "number", default = 100},
step = {type = "number", default = 0, min = 0},
surface = {type = "color", default = "#eef1f6"},
fill = {type = "color", default = "#cbd5e1"},
textColor = {type = "color", default = "#0f172a"},
fontSize = {type = "number", default = 14, min = 6, max = 200},
display = {type = "enum", default = "value", options = {"none", "value", "percent"}},
radius = {type = "number", default = 10, min = 0, max = 200},
accent = {type = "color", default = "#5a6bff"},
track = {type = "color", default = "#cbd5e1"},
thumb = {type = "color", default = "#ffffff"},
trackHeight = {type = "number", default = 6, min = 1, max = 80},
thumbSize = {
type = "number",
default = 56,
min = 20,
max = 100,
step = 5
},
animate = {
type = "number",
default = 0,
min = 0,
max = 2000,
step = 10
}
},
interaction = "slide",
pointerScale = false,
size = {width = 220, height = 28, minWidth = 60, minHeight = 12},
role = "slider"
},
{
type = "range",
group = "input",
category = "value",
value = {type = "number", writable = true, default = 25},
properties = {
variant = {type = "enum", default = "line", options = {"line", "field"}},
direction = {type = "enum", default = "horizontal", options = {"horizontal", "vertical"}},
ticks = {type = "number", default = 0, min = 0, max = 200},
tickColor = {type = "color", default = "#94a3b8"},
valueEnd = {type = "number", default = 75},
min = {type = "number", default = 0},
max = {type = "number", default = 100},
step = {type = "number", default = 0, min = 0},
surface = {type = "color", default = "#eef1f6"},
fill = {type = "color", default = "#cbd5e1"},
textColor = {type = "color", default = "#0f172a"},
fontSize = {type = "number", default = 14, min = 6, max = 200},
display = {type = "enum", default = "value", options = {"none", "value", "percent"}},
radius = {type = "number", default = 10, min = 0, max = 200},
accent = {type = "color", default = "#5a6bff"},
track = {type = "color", default = "#cbd5e1"},
thumb = {type = "color", default = "#ffffff"},
trackHeight = {type = "number", default = 6, min = 1, max = 80},
thumbSize = {
type = "number",
default = 56,
min = 20,
max = 100,
step = 5
},
animate = {
type = "number",
default = 0,
min = 0,
max = 2000,
step = 10
}
},
interaction = "range",
pointerScale = false,
size = {width = 220, height = 28, minWidth = 60, minHeight = 12},
role = "slider"
},
{
type = "progress",
group = "readout",
category = "indicator",
value = {type = "number", writable = false, default = 60},
properties = {
min = {type = "number", default = 0},
max = {type = "number", default = 100},
variant = {type = "enum", default = "bar", options = {"bar", "ring"}},
direction = {type = "enum", default = "horizontal", options = {"horizontal", "vertical"}},
accent = {type = "color", default = "#5a6bff"},
track = {type = "color", default = "#e2e8f0"},
thickness = {type = "number", default = 10, min = 1, max = 80},
rounded = {type = "boolean", default = true},
display = {type = "enum", default = "none", options = {"none", "percent", "value"}},
textColor = {type = "color", default = "#0f172a"},
fontSize = {type = "number", default = 14, min = 6, max = 200},
animate = {
type = "number",
default = 300,
min = 0,
max = 2000,
step = 10
}
},
interaction = "none",
pointerScale = false,
size = {width = 220, height = 12, minWidth = 20, minHeight = 4},
role = "progressbar"
},
{
type = "segmented",
group = "input",
category = "selection",
value = {type = "number", writable = true, default = 0},
properties = {
options = {type = "string", default = "Day,Week,Month"},
accent = {type = "color", default = "#5a6bff"},
track = {type = "color", default = "#e2e8f0"},
textColor = {type = "color", default = "#475569"},
activeTextColor = {type = "color", default = "#ffffff"},
radius = {type = "number", default = 200, min = 0, max = 200},
inset = {type = "number", default = 3, min = 0, max = 20},
fontSize = {type = "number", default = 14, min = 6, max = 200},
animate = {
type = "number",
default = 200,
min = 0,
max = 2000,
step = 10
}
},
interaction = "pick",
pointerScale = false,
size = {width = 300, height = 40, minWidth = 80, minHeight = 20},
role = "radiogroup"
},
{
type = "knob",
group = "input",
category = "value",
value = {type = "number", writable = true, default = 40},
properties = {
min = {type = "number", default = 0},
max = {type = "number", default = 100},
step = {type = "number", default = 0, min = 0},
start = {type = "number", default = 225, min = 0, max = 360},
sweep = {type = "number", default = 270, min = 30, max = 360},
accent = {type = "color", default = "#5a6bff"},
track = {type = "color", default = "#cbd5e1"},
face = {type = "color", default = "#f1f5f9"},
dot = {type = "color", default = "#0f172a"},
thickness = {type = "number", default = 8, min = 1, max = 80},
rounded = {type = "boolean", default = true},
display = {type = "enum", default = "value", options = {"none", "value", "percent"}},
textColor = {type = "color", default = "#0f172a"},
fontSize = {type = "number", default = 16, min = 6, max = 200},
animate = {
type = "number",
default = 0,
min = 0,
max = 2000,
step = 10
}
},
interaction = "turn",
pointerScale = false,
size = {
width = 96,
height = 96,
minWidth = 40,
minHeight = 40,
aspect = 1
},
role = "slider"
}
}
return ____exports
end,
["core.model.component.registry"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__New = ____lualib.__TS__New
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local __TS__Spread = ____lualib.__TS__Spread
local ____exports = {}
local ______shims = require("core.__shims")
local __re = ______shims.__re
local __test = ______shims.__test
local ____builtIns = require("core.model.component.builtIns")
local BUILT_IN_DESCRIPTORS = ____builtIns.BUILT_IN_DESCRIPTORS
local version = 0
local descriptors = __TS__New(
Map,
__TS__ArrayMap(
BUILT_IN_DESCRIPTORS,
function(____, descriptor) return {descriptor.type, descriptor} end
)
)
local TYPE_NAME = __re(nil, "^[A-Za-z][A-Za-z0-9]*$", "")
function ____exports.registerComponentDescriptor(self, descriptor)
if not __test(nil, TYPE_NAME, descriptor.type) then
error(
__TS__New(Error, ("'" .. descriptor.type) .. "' is not a valid component type name."),
0
)
end
if descriptors:has(descriptor.type) then
error(
__TS__New(Error, ("A component of type '" .. descriptor.type) .. "' is already defined."),
0
)
end
descriptors:set(descriptor.type, descriptor)
version = version + 1
return function()
if descriptors:get(descriptor.type) == descriptor then
descriptors:delete(descriptor.type)
version = version + 1
end
end
end
function ____exports.componentRegistryVersion(self)
return version
end
function ____exports.getComponentDescriptor(self, ____type)
local ____temp_0
if ____type == nil then
____temp_0 = nil
else
____temp_0 = descriptors:get(____type)
end
return ____temp_0
end
function ____exports.componentTypes(self)
return {__TS__Spread(descriptors:keys())}
end
function ____exports.isComponentType(self, value)
return ____exports.getComponentDescriptor(nil, value) ~= nil
end
return ____exports
end,
["core.model.component.theme"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.DEFAULT_ROLLING_NUMBER_STYLE = {
color = "#000000",
surface = "rgba(255, 255, 255, 0.28)",
divider = "rgba(0, 0, 0, 0.2)",
labelColor = "rgba(0, 0, 0, 0.62)",
fontFamily = "'Roboto Mono', 'SFMono-Regular', Consolas, monospace",
variant = "flip",
motion = "roll",
fontWeight = "300",
fontSize = 0
}
function ____exports.resolveRollingNumberStyle(self, style)
return {
color = style.color or ____exports.DEFAULT_ROLLING_NUMBER_STYLE.color,
surface = style.surface or ____exports.DEFAULT_ROLLING_NUMBER_STYLE.surface,
divider = style.divider or ____exports.DEFAULT_ROLLING_NUMBER_STYLE.divider,
labelColor = style.labelColor or ____exports.DEFAULT_ROLLING_NUMBER_STYLE.labelColor,
fontFamily = style.fontFamily or ____exports.DEFAULT_ROLLING_NUMBER_STYLE.fontFamily,
variant = style.variant or ____exports.DEFAULT_ROLLING_NUMBER_STYLE.variant,
motion = style.motion or ____exports.DEFAULT_ROLLING_NUMBER_STYLE.motion,
fontWeight = style.fontWeight or ____exports.DEFAULT_ROLLING_NUMBER_STYLE.fontWeight,
fontSize = style.fontSize or ____exports.DEFAULT_ROLLING_NUMBER_STYLE.fontSize
}
end
return ____exports
end,
["core.model.component.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____categories = require("core.model.component.categories")
____exports.COMPONENT_CATEGORIES = ____categories.COMPONENT_CATEGORIES
end
do
local ____format = require("core.model.component.format")
____exports.formatRollingNumber = ____format.formatRollingNumber
end
do
local ____guards = require("core.model.component.guards")
____exports.isGenericComponent = ____guards.isGenericComponent
end
do
local ____registry = require("core.model.component.registry")
____exports.componentRegistryVersion = ____registry.componentRegistryVersion
____exports.componentTypes = ____registry.componentTypes
____exports.getComponentDescriptor = ____registry.getComponentDescriptor
____exports.isComponentType = ____registry.isComponentType
____exports.registerComponentDescriptor = ____registry.registerComponentDescriptor
end
do
local ____supportedTypes = require("core.model.component.supportedTypes")
____exports.BUILT_IN_COMPONENT_TYPES = ____supportedTypes.BUILT_IN_COMPONENT_TYPES
____exports.isBuiltInComponentType = ____supportedTypes.isBuiltInComponentType
end
do
local ____theme = require("core.model.component.theme")
____exports.DEFAULT_ROLLING_NUMBER_STYLE = ____theme.DEFAULT_ROLLING_NUMBER_STYLE
____exports.resolveRollingNumberStyle = ____theme.resolveRollingNumberStyle
end
return ____exports
end,
["core.sflLanguage.ast"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local ____exports = {}
____exports.NAMED_BLOCK_KINDS = {
"Project",
"Model",
"Group",
"Entity",
"Container",
"Screen",
"Path",
"Chart",
"Widget",
"Component",
"Shape",
"Text",
"Image",
"Isometric",
"Mesh",
"Solid",
"Facets",
"Terrain",
"Canvas",
"Scene",
"Light",
"Ground",
"Dimension",
"Link",
"Connection",
"Layout",
"Style",
"Shader",
"Axis",
"Series",
"Rule",
"Net",
"Symbol",
"Port",
"Cut",
"Add",
"Keep",
"Sketch",
"Rect",
"Circle",
"Outline",
"DataSource",
"Repeat",
"Template",
"Use",
"Parameters"
}
local ____array_0 = __TS__SparseArrayNew(table.unpack(____exports.NAMED_BLOCK_KINDS))
__TS__SparseArrayPush(____array_0, "data")
____exports.BLOCK_KINDS = {__TS__SparseArraySpread(____array_0)}
____exports.SIDES = {"top", "bottom", "left", "right"}
____exports.isSide = function(____, s) return __TS__ArrayIncludes(____exports.SIDES, s) end
____exports.isComponentBlockKind = function(____, kind) return kind == "Component" or kind == "Widget" end
____exports.isBlockKind = function(____, s) return __TS__ArrayIncludes(____exports.BLOCK_KINDS, s) end
____exports.isNamedBlockKind = function(____, s) return __TS__ArrayIncludes(____exports.NAMED_BLOCK_KINDS, s) end
return ____exports
end,
["core.sflLanguage.emitting.blockEntries"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.collectBlockEntries(self, block)
local entries = {
properties = {},
blocks = {},
layouts = {},
styles = {},
dataBlocks = {},
fields = {},
bindings = {},
handlers = {}
}
for ____, entry in ipairs(block.entries) do
if entry.type == "property" then
local ____entries_properties_0 = entries.properties
____entries_properties_0[#____entries_properties_0 + 1] = entry.property
elseif entry.type == "block" then
local ____entries_blocks_1 = entries.blocks
____entries_blocks_1[#____entries_blocks_1 + 1] = entry.block
elseif entry.type == "layout" then
local ____entries_layouts_2 = entries.layouts
____entries_layouts_2[#____entries_layouts_2 + 1] = entry.layout
elseif entry.type == "style" then
local ____entries_styles_3 = entries.styles
____entries_styles_3[#____entries_styles_3 + 1] = entry.style
elseif entry.type == "fields" then
local ____entries_fields_4 = entries.fields
____entries_fields_4[#____entries_fields_4 + 1] = entry.fields
elseif entry.type == "binding" then
local ____entries_bindings_5 = entries.bindings
____entries_bindings_5[#____entries_bindings_5 + 1] = entry.binding
elseif entry.type == "handler" then
local ____entries_handlers_6 = entries.handlers
____entries_handlers_6[#____entries_handlers_6 + 1] = entry.handler
else
local ____entries_dataBlocks_7 = entries.dataBlocks
____entries_dataBlocks_7[#____entries_dataBlocks_7 + 1] = entry.data
end
end
return entries
end
return ____exports
end,
["core.sflLanguage.emitting.composition"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
function ____exports.emitComposition(self, composition)
if not __t(nil, #composition) then
return ""
end
return " : " .. table.concat(composition, " & ")
end
return ____exports
end,
["core.sflLanguage.emitting.literals"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __is = ______shims.__is
local __re = ______shims.__re
local __replace = ______shims.__replace
function ____exports.formatNumber(self, value)
if __is(nil, value, -0) then
return "0"
end
return tostring(value)
end
function ____exports.emitString(self, value)
local escaped = __replace(
nil,
__replace(
nil,
__replace(
nil,
__replace(
nil,
__replace(
nil,
value,
__re(nil, "\\r\\n?", "g"),
"\n"
),
__re(nil, "\\\\", "g"),
"\\\\"
),
__re(nil, "\"", "g"),
"\\\""
),
__re(nil, "\\n", "g"),
"\\n"
),
__re(nil, "\\t", "g"),
"\\t"
)
return ("\"" .. escaped) .. "\""
end
return ____exports
end,
["core.sflLanguage.emitting.expressions"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ____literals = require("core.sflLanguage.emitting.literals")
local emitString = ____literals.emitString
local PRECEDENCE = {
["||"] = 1,
["&&"] = 2,
["=="] = 3,
["!="] = 3,
[">"] = 3,
["<"] = 3,
[">="] = 3,
["<="] = 3,
["+"] = 4,
["-"] = 4,
["*"] = 5,
["/"] = 5
}
function ____exports.emitExpression(self, expr, parentPrecedence)
if parentPrecedence == nil then
parentPrecedence = 0
end
repeat
local ____switch3 = expr.kind
local ____cond3 = ____switch3 == "number"
if ____cond3 then
return tostring(expr.value)
end
____cond3 = ____cond3 or ____switch3 == "string"
if ____cond3 then
return emitString(nil, expr.value)
end
____cond3 = ____cond3 or ____switch3 == "boolean"
if ____cond3 then
return tostring(expr.value)
end
____cond3 = ____cond3 or ____switch3 == "ref"
if ____cond3 then
return table.concat(expr.path, ".")
end
____cond3 = ____cond3 or ____switch3 == "unary"
if ____cond3 then
return expr.operator .. ____exports.emitExpression(nil, expr.operand, 6)
end
____cond3 = ____cond3 or ____switch3 == "call"
if ____cond3 then
return ((table.concat(expr.callee, ".") .. "(") .. table.concat(
__TS__ArrayMap(
expr.args,
function(____, arg) return ____exports.emitExpression(nil, arg) end
),
", "
)) .. ")"
end
____cond3 = ____cond3 or ____switch3 == "binary"
if ____cond3 then
do
local precedence = PRECEDENCE[expr.operator]
local text = (((____exports.emitExpression(nil, expr.left, precedence) .. " ") .. expr.operator) .. " ") .. ____exports.emitExpression(nil, expr.right, precedence + 1)
return precedence < parentPrecedence and ("(" .. text) .. ")" or text
end
end
until true
end
local function emitAssignment(____, assignment)
return (table.concat(assignment.target, ".") .. " <- ") .. ____exports.emitExpression(nil, assignment.expr)
end
function ____exports.emitHandler(self, handler, pad)
if #handler.assignments == 1 then
return ((pad .. handler.event) .. ": ") .. emitAssignment(nil, handler.assignments[1])
end
local lines = __TS__ArrayMap(
handler.assignments,
function(____, assignment) return (pad .. " ") .. emitAssignment(nil, assignment) end
)
local ____array_0 = __TS__SparseArrayNew(
(pad .. handler.event) .. " {",
table.unpack(lines)
)
__TS__SparseArrayPush(____array_0, pad .. "}")
return table.concat(
{__TS__SparseArraySpread(____array_0)},
"\n"
)
end
____exports.emitBinding = function(____, binding) return (((binding.key .. ": ") .. binding.operator) .. " ") .. ____exports.emitExpression(nil, binding.expr) end
return ____exports
end,
["core.sflLanguage.emitting.propertyOrder"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayIndexOf = ____lualib.__TS__ArrayIndexOf
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local LAYOUT_ORDER = {"position", "size", "rotation", "order"}
local STYLE_ORDER = {
"shape",
"fill",
"stroke",
"strokeWidth",
"strokeStyle",
"textColor",
"color",
"fontSize",
"fontWeight",
"fontFamily",
"textAlign",
"verticalAlign",
"cornerRadius",
"cornerRadii",
"dash",
"shadow",
"opacity",
"blur",
"blend",
"icon",
"route",
"marker",
"markerStart",
"markerEnd",
"asset"
}
local function alphabetical(____, a, b)
return a < b and -1 or (a > b and 1 or 0)
end
function ____exports.compareProps(self, a, b)
local function rank(____, key)
return key == "id" and 0 or (key == "kind" and 1 or (key == "text" and 2 or 3))
end
return __lor(
nil,
rank(nil, a) - rank(nil, b),
function() return alphabetical(nil, a, b) end
)
end
local function compareByOrder(self, order, a, b)
local aIndex = __TS__ArrayIndexOf(order, a)
local bIndex = __TS__ArrayIndexOf(order, b)
local aRank = aIndex == -1 and #order or aIndex
local bRank = bIndex == -1 and #order or bIndex
return __lor(
nil,
aRank - bRank,
function() return alphabetical(nil, a, b) end
)
end
____exports.compareLayoutProps = function(____, a, b) return compareByOrder(nil, LAYOUT_ORDER, a, b) end
____exports.compareStyleProps = function(____, a, b) return compareByOrder(nil, STYLE_ORDER, a, b) end
return ____exports
end,
["core.sflLanguage.emitting.values"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____expressions = require("core.sflLanguage.emitting.expressions")
local emitExpression = ____expressions.emitExpression
local ____literals = require("core.sflLanguage.emitting.literals")
local emitString = ____literals.emitString
local formatNumber = ____literals.formatNumber
function ____exports.emitValue(self, value)
repeat
local ____switch3 = value.type
local ____cond3 = ____switch3 == "string"
if ____cond3 then
return emitString(nil, value.value)
end
____cond3 = ____cond3 or ____switch3 == "number"
if ____cond3 then
return formatNumber(nil, value.value)
end
____cond3 = ____cond3 or ____switch3 == "tuple"
if ____cond3 then
return table.concat(
__TS__ArrayMap(value.values, formatNumber),
", "
)
end
____cond3 = ____cond3 or ____switch3 == "list"
if ____cond3 then
return ("[" .. table.concat(
__TS__ArrayMap(value.values, ____exports.emitValue),
", "
)) .. "]"
end
____cond3 = ____cond3 or ____switch3 == "ident"
if ____cond3 then
return table.concat(value.segments, ".")
end
____cond3 = ____cond3 or ____switch3 == "each"
if ____cond3 then
return (value.row .. " in ") .. value.source
end
____cond3 = ____cond3 or ____switch3 == "expr"
if ____cond3 then
return table.concat(
__TS__ArrayMap(
value.items,
function(____, item) return emitExpression(nil, item) end
),
", "
)
end
____cond3 = ____cond3 or ____switch3 == "endpoint"
if ____cond3 then
do
local output = table.concat(value.segments, ".")
if __t(nil, value.side) then
output = output .. ", " .. value.side
if value.fraction ~= nil then
output = output .. (" (" .. formatNumber(nil, value.fraction)) .. ")"
end
end
return output
end
end
until true
end
____exports.emitProperty = function(____, property) return (property.key .. ": ") .. ____exports.emitValue(nil, property.value) end
return ____exports
end,
["core.sflLanguage.emitting.propertyBlock"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ______shims = require("core.__shims")
local __sort = ______shims.__sort
local __t = ______shims.__t
local ____expressions = require("core.sflLanguage.emitting.expressions")
local emitBinding = ____expressions.emitBinding
local ____propertyOrder = require("core.sflLanguage.emitting.propertyOrder")
local compareLayoutProps = ____propertyOrder.compareLayoutProps
local compareStyleProps = ____propertyOrder.compareStyleProps
local ____values = require("core.sflLanguage.emitting.values")
local emitProperty = ____values.emitProperty
local INDENT = " "
function ____exports.emitPropertyBlock(self, name, properties, depth, bindings)
if bindings == nil then
bindings = {}
end
local pad = string.rep(
INDENT,
math.floor(depth)
)
local innerPad = string.rep(
INDENT,
math.floor(depth + 1)
)
local compare = name == "layout" and compareLayoutProps or compareStyleProps
local lines = __TS__ArrayMap(
__sort(
nil,
{table.unpack(properties)},
function(____, left, right) return compare(nil, left.key, right.key) end
),
function(____, property) return innerPad .. emitProperty(nil, property) end
)
__TS__ArrayPushArray(
lines,
__TS__ArrayMap(
bindings,
function(____, binding) return innerPad .. emitBinding(nil, binding) end
)
)
if not __t(nil, #lines) then
return (((pad .. name) .. " {\n") .. pad) .. "}"
end
return (((((pad .. name) .. " {\n") .. table.concat(lines, "\n")) .. "\n") .. pad) .. "}"
end
return ____exports
end,
["core.sflLanguage.emitting.blocks"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local propertyComparator, orderedProperties, usesCompactBlockForm, emitCompactBlock, emitExpandedBlockBody, emitPrimaryBlockEntries, emitAttachedPropertyBlocks, emitFieldsBlock, emitDataBlock, emitExpandedBlock, INDENT, COMPACT_MAX_PROPS, WRITTEN_ORDER
local ______shims = require("core.__shims")
local __sort = ______shims.__sort
local __t = ______shims.__t
local ____blockEntries = require("core.sflLanguage.emitting.blockEntries")
local collectBlockEntries = ____blockEntries.collectBlockEntries
local ____composition = require("core.sflLanguage.emitting.composition")
local emitComposition = ____composition.emitComposition
local ____expressions = require("core.sflLanguage.emitting.expressions")
local emitBinding = ____expressions.emitBinding
local emitHandler = ____expressions.emitHandler
local ____propertyBlock = require("core.sflLanguage.emitting.propertyBlock")
local emitPropertyBlock = ____propertyBlock.emitPropertyBlock
local ____propertyOrder = require("core.sflLanguage.emitting.propertyOrder")
local compareLayoutProps = ____propertyOrder.compareLayoutProps
local compareProps = ____propertyOrder.compareProps
local compareStyleProps = ____propertyOrder.compareStyleProps
local ____values = require("core.sflLanguage.emitting.values")
local emitProperty = ____values.emitProperty
function propertyComparator(self, kind)
if kind == "Layout" then
return compareLayoutProps
end
if kind == "Style" then
return compareStyleProps
end
return compareProps
end
function ____exports.joinSiblingBlocks(self, blocks, depth)
local pad = string.rep(
INDENT,
math.floor(depth)
)
local layouts = __TS__ArrayFilter(
blocks,
function(____, block) return block.kind == "Layout" end
)
local styles = __TS__ArrayFilter(
blocks,
function(____, block) return block.kind == "Style" end
)
local others = __TS__ArrayFilter(
blocks,
function(____, block) return block.kind ~= "Layout" and block.kind ~= "Style" end
)
local groups = {}
if __t(nil, #layouts) then
groups[#groups + 1] = (pad .. "// Layout Definition\n") .. table.concat(
__TS__ArrayMap(
layouts,
function(____, block) return ____exports.emitBlock(nil, block, depth) end
),
"\n"
)
end
if __t(nil, #styles) then
groups[#groups + 1] = (pad .. "// Style Definition\n") .. table.concat(
__TS__ArrayMap(
styles,
function(____, block) return ____exports.emitBlock(nil, block, depth) end
),
"\n"
)
end
__TS__ArrayForEach(
others,
function(____, block)
groups[#groups + 1] = ____exports.emitBlock(nil, block, depth)
end
)
return table.concat(groups, "\n\n")
end
function ____exports.emitBlock(self, block, depth)
local pad = string.rep(
INDENT,
math.floor(depth)
)
local header = (((block.kind .. " ") .. block.name) .. emitComposition(nil, block.composition)) .. " {"
local entries = collectBlockEntries(nil, block)
local properties = orderedProperties(nil, block.kind, entries.properties)
if usesCompactBlockForm(nil, block.kind, entries, #properties) then
return emitCompactBlock(nil, pad, header, properties)
end
local body = emitExpandedBlockBody(nil, entries, properties, depth)
return emitExpandedBlock(nil, pad, header, body)
end
function orderedProperties(self, kind, properties)
if WRITTEN_ORDER:has(kind) then
return properties
end
return __sort(
nil,
{table.unpack(properties)},
function(____, left, right) return propertyComparator(nil, kind)(nil, left.key, right.key) end
)
end
function usesCompactBlockForm(self, kind, entries, propertyCount)
local supportsCompactForm = kind == "Layout" or kind == "Style"
local hasNestedContent = #entries.blocks > 0 or #entries.layouts > 0 or #entries.styles > 0 or #entries.dataBlocks > 0 or #entries.fields > 0 or #entries.bindings > 0 or #entries.handlers > 0
return supportsCompactForm and not hasNestedContent and propertyCount <= COMPACT_MAX_PROPS
end
function emitCompactBlock(self, pad, header, properties)
local body = table.concat(
__TS__ArrayMap(properties, emitProperty),
"; "
)
return __t(nil, body) and (((pad .. header) .. " ") .. body) .. " }" or (pad .. header) .. " }"
end
function emitExpandedBlockBody(self, entries, properties, depth)
local primaryEntries = emitPrimaryBlockEntries(nil, entries, properties, depth)
local propertyBlocks = emitAttachedPropertyBlocks(nil, entries, depth)
return table.concat(
__TS__ArrayFilter({primaryEntries, propertyBlocks}, Boolean),
"\n"
)
end
function emitPrimaryBlockEntries(self, entries, properties, depth)
local innerPad = string.rep(
INDENT,
math.floor(depth + 1)
)
local ____array_0 = __TS__SparseArrayNew(table.unpack(__TS__ArrayMap(
properties,
function(____, property) return innerPad .. emitProperty(nil, property) end
)))
__TS__SparseArrayPush(
____array_0,
table.unpack(__TS__ArrayMap(
entries.bindings,
function(____, binding) return innerPad .. emitBinding(nil, binding) end
))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(__TS__ArrayMap(
entries.handlers,
function(____, handler) return emitHandler(nil, handler, innerPad) end
))
)
local propertyLines = table.concat(
{__TS__SparseArraySpread(____array_0)},
"\n"
)
local nestedBlocks = ____exports.joinSiblingBlocks(nil, entries.blocks, depth + 1)
return table.concat(
__TS__ArrayFilter({propertyLines, nestedBlocks}, Boolean),
"\n\n"
)
end
function emitAttachedPropertyBlocks(self, entries, depth)
local fields = __TS__ArrayMap(
entries.fields,
function(____, properties) return emitFieldsBlock(nil, properties, depth + 1) end
)
local dataBlocks = __TS__ArrayMap(
entries.dataBlocks,
function(____, data) return emitDataBlock(nil, data, depth + 1) end
)
local layouts = __TS__ArrayMap(
entries.layouts,
function(____, layout) return emitPropertyBlock(
nil,
"layout",
layout.properties,
depth + 1,
layout.bindings
) end
)
local styles = __TS__ArrayMap(
entries.styles,
function(____, style) return emitPropertyBlock(
nil,
"style",
style.properties,
depth + 1,
style.bindings
) end
)
local ____array_1 = __TS__SparseArrayNew(table.unpack(fields))
__TS__SparseArrayPush(
____array_1,
table.unpack(dataBlocks)
)
__TS__SparseArrayPush(
____array_1,
table.unpack(layouts)
)
__TS__SparseArrayPush(
____array_1,
table.unpack(styles)
)
return table.concat(
{__TS__SparseArraySpread(____array_1)},
"\n"
)
end
function emitFieldsBlock(self, properties, depth)
local pad = string.rep(
INDENT,
math.floor(depth)
)
local lines = __TS__ArrayMap(
properties,
function(____, property) return (pad .. INDENT) .. emitProperty(nil, property) end
)
return __t(nil, #lines) and ((((pad .. "fields {\n") .. table.concat(lines, "\n")) .. "\n") .. pad) .. "}" or ((pad .. "fields {\n") .. pad) .. "}"
end
function emitDataBlock(self, data, depth)
local pad = string.rep(
INDENT,
math.floor(depth)
)
local entries = collectBlockEntries(nil, data)
local properties = orderedProperties(nil, data.kind, entries.properties)
local body = emitExpandedBlockBody(nil, entries, properties, depth)
return emitExpandedBlock(nil, pad, "data {", body)
end
function emitExpandedBlock(self, pad, header, body)
return __t(nil, body) and (((((pad .. header) .. "\n") .. body) .. "\n") .. pad) .. "}" or (((pad .. header) .. "\n") .. pad) .. "}"
end
INDENT = " "
COMPACT_MAX_PROPS = 3
WRITTEN_ORDER = __TS__New(Set, {"Parameters", "Repeat", "Template"})
return ____exports
end,
["core.sflLanguage.emitting.document"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __re = ______shims.__re
local __replace = ______shims.__replace
local __t = ______shims.__t
local ____blocks = require("core.sflLanguage.emitting.blocks")
local joinSiblingBlocks = ____blocks.joinSiblingBlocks
function ____exports.emitDocument(self, doc)
local body = joinSiblingBlocks(nil, doc.blocks, 0)
local output = __t(nil, body) and (("sfl " .. doc.version) .. "\n\n") .. body or "sfl " .. doc.version
local trimmed = table.concat(
__TS__ArrayMap(
__TS__StringSplit(output, "\n"),
function(____, line) return __replace(
nil,
line,
__re(nil, "[ \\t]+$", ""),
""
) end
),
"\n"
)
return trimmed .. "\n"
end
return ____exports
end,
["core.sflLanguage.lexing.cursor"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__StringAccess = ____lualib.__TS__StringAccess
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local __TS__New = ____lualib.__TS__New
local __TS__SetDescriptor = ____lualib.__TS__SetDescriptor
local ____exports = {}
____exports.SourceCursor = __TS__Class()
local SourceCursor = ____exports.SourceCursor
SourceCursor.name = "SourceCursor"
function SourceCursor.prototype.____constructor(self, input)
self.input = input
self.offset = 0
self.line = 1
self.col = 1
end
function SourceCursor.prototype.peek(self, ahead)
if ahead == nil then
ahead = 0
end
return __TS__StringAccess(self.input, self.offset + ahead)
end
function SourceCursor.prototype.startsWith(self, value)
return __TS__StringStartsWith(self.input, value, self.offset)
end
function SourceCursor.prototype.position(self)
return {line = self.line, col = self.col}
end
function SourceCursor.prototype.advance(self)
local character = __TS__StringAccess(self.input, self.offset)
if character == nil then
error(
__TS__New(Error, "Cannot advance beyond the end of the SFL source."),
0
)
end
self.offset = self.offset + 1
if character == "\n" or character == "\r" and self:peek() ~= "\n" then
self.line = self.line + 1
self.col = 1
else
self.col = self.col + 1
end
return character
end
__TS__SetDescriptor(
SourceCursor.prototype,
"done",
{get = function(self)
return self.offset >= #self.input
end},
true
)
return ____exports
end,
["core.sflLanguage.lexing.error"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = {}
____exports.SflLexError = __TS__Class()
local SflLexError = ____exports.SflLexError
SflLexError.name = "SflLexError"
__TS__ClassExtends(SflLexError, Error)
function SflLexError.prototype.____constructor(self, message, line, col)
Error.prototype.____constructor(
self,
(((("SFL lex error (" .. tostring(line)) .. ":") .. tostring(col)) .. "): ") .. message
)
self.line = line
self.col = col
self.name = "SflLexError"
end
return ____exports
end,
["core.sflLanguage.lexing.characters"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __re = ______shims.__re
local __test = ______shims.__test
____exports.isLetter = function(____, character) return character ~= nil and __test(
nil,
__re(nil, "^[A-Za-z_]$", ""),
character
) end
____exports.isDigit = function(____, character) return character ~= nil and character >= "0" and character <= "9" end
____exports.isIdentPart = function(____, character) return character ~= nil and __test(
nil,
__re(nil, "^[A-Za-z0-9_]$", ""),
character
) end
return ____exports
end,
["core.sflLanguage.lexing.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflLanguage.lexing.tokenCreation"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
function ____exports.createToken(self, ____type, value, start, detail)
if detail == nil then
detail = {}
end
return __TS__ObjectAssign({
type = ____type,
value = value,
line = start.line,
col = start.col,
endLine = start.line,
endCol = start.col
}, detail)
end
function ____exports.withTokenEnd(self, token, cursor)
return __TS__ObjectAssign({}, token, {endLine = cursor.line, endCol = cursor.col})
end
return ____exports
end,
["core.sflLanguage.lexing.identifiers"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____characters = require("core.sflLanguage.lexing.characters")
local isIdentPart = ____characters.isIdentPart
local isLetter = ____characters.isLetter
local ____tokenCreation = require("core.sflLanguage.lexing.tokenCreation")
local createToken = ____tokenCreation.createToken
function ____exports.startsIdentifier(self, cursor)
return isLetter(
nil,
cursor:peek()
)
end
function ____exports.readIdentifier(self, cursor, start)
local value = ""
while isIdentPart(
nil,
cursor:peek()
) do
value = value .. cursor:advance()
end
return createToken(nil, "ident", value, start)
end
return ____exports
end,
["core.sflLanguage.lexing.lineBreak"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____tokenCreation = require("core.sflLanguage.lexing.tokenCreation")
local createToken = ____tokenCreation.createToken
function ____exports.isLineBreak(self, character)
return character == "\r" or character == "\n"
end
function ____exports.readLineBreak(self, cursor, start)
local firstCharacter = cursor:advance()
if firstCharacter == "\r" and cursor:peek() == "\n" then
cursor:advance()
end
return createToken(nil, "newline", "\n", start)
end
return ____exports
end,
["core.sflLanguage.lexing.lineComment"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.startsLineComment(self, cursor)
return cursor:peek() == "/" and cursor:peek(1) == "/"
end
function ____exports.consumeLineComment(self, cursor)
while not cursor.done and cursor:peek() ~= "\n" and cursor:peek() ~= "\r" do
cursor:advance()
end
end
return ____exports
end,
["core.sflLanguage.lexing.numbers"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local ____exports = {}
local ____characters = require("core.sflLanguage.lexing.characters")
local isDigit = ____characters.isDigit
local ____tokenCreation = require("core.sflLanguage.lexing.tokenCreation")
local createToken = ____tokenCreation.createToken
function ____exports.startsNumber(self, cursor)
local character = cursor:peek()
return isDigit(nil, character) or character == "-" and isDigit(
nil,
cursor:peek(1)
)
end
function ____exports.readNumber(self, cursor, start)
local value = ""
if cursor:peek() == "-" then
value = value .. cursor:advance()
end
while isDigit(
nil,
cursor:peek()
) do
value = value .. cursor:advance()
end
if cursor:peek() == "." and isDigit(
nil,
cursor:peek(1)
) then
value = value .. cursor:advance()
while isDigit(
nil,
cursor:peek()
) do
value = value .. cursor:advance()
end
end
return createToken(
nil,
"number",
value,
start,
{numberValue = __TS__Number(value)}
)
end
return ____exports
end,
["core.sflLanguage.lexing.operators"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local ____exports = {}
local ______shims = require("core.__shims")
local __re = ______shims.__re
local __test = ______shims.__test
local ____tokenCreation = require("core.sflLanguage.lexing.tokenCreation")
local createToken = ____tokenCreation.createToken
local OPERATORS = {
{"<->", "bind2"},
{"<-", "bind"},
{"->", "action"},
{"&&", "op"},
{"||", "op"},
{">=", "op"},
{"<=", "op"},
{"==", "op"},
{"!=", "op"},
{"+", "op"},
{"-", "op"},
{"*", "op"},
{"/", "op"},
{">", "op"},
{"<", "op"},
{"!", "op"}
}
local function startsNumber(____, character)
return character ~= nil and __test(
nil,
__re(nil, "[\\d.]", ""),
character
)
end
function ____exports.readOperator(self, cursor, start)
local match = __TS__ArrayFind(
OPERATORS,
function(____, ____bindingPattern0)
local text
text = ____bindingPattern0[1]
return cursor:startsWith(text)
end
)
if not match then
return nil
end
local text, ____type = table.unpack(match, 1, 2)
if text == "-" and startsNumber(
nil,
cursor:peek(1)
) then
return nil
end
do
local index = 0
while index < #text do
cursor:advance()
index = index + 1
end
end
return createToken(nil, ____type, text, start)
end
return ____exports
end,
["core.sflLanguage.lexing.punctuation"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____tokenCreation = require("core.sflLanguage.lexing.tokenCreation")
local createToken = ____tokenCreation.createToken
local PUNCTUATION = {
["{"] = "lbrace",
["}"] = "rbrace",
["["] = "lbracket",
["]"] = "rbracket",
["("] = "lparen",
[")"] = "rparen",
[":"] = "colon",
[","] = "comma",
[";"] = "semi",
["."] = "dot",
["&"] = "amp"
}
function ____exports.readPunctuation(self, cursor, start)
local character = cursor:peek()
local ____t_result_0
if __t(nil, character) then
____t_result_0 = PUNCTUATION[character]
else
____t_result_0 = nil
end
local ____type = ____t_result_0
if not __t(nil, character) or not __t(nil, ____type) or character == "&" and cursor:peek(1) == "&" then
return nil
end
cursor:advance()
return createToken(nil, ____type, character, start)
end
return ____exports
end,
["core.sflLanguage.lexing.spacing"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.isSpacing(self, character)
return character == " " or character == "\t"
end
function ____exports.consumeSpacing(self, cursor)
cursor:advance()
end
return ____exports
end,
["core.sflLanguage.lexing.strings"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringAccess = ____lualib.__TS__StringAccess
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__StringTrim = ____lualib.__TS__StringTrim
local __TS__StringSlice = ____lualib.__TS__StringSlice
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local consumeLongStringDelimiter, readEscapedCharacter
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
local __re = ______shims.__re
local __replace = ______shims.__replace
local __t = ______shims.__t
local ____error = require("core.sflLanguage.lexing.error")
local SflLexError = ____error.SflLexError
local ____tokenCreation = require("core.sflLanguage.lexing.tokenCreation")
local createToken = ____tokenCreation.createToken
function consumeLongStringDelimiter(self, cursor)
cursor:advance()
cursor:advance()
cursor:advance()
end
function readEscapedCharacter(self, cursor, start)
if cursor.done then
error(
__TS__New(SflLexError, "unterminated escape sequence", start.line, start.col),
0
)
end
local escaped = cursor:advance()
repeat
local ____switch20 = escaped
local ____cond20 = ____switch20 == "\""
if ____cond20 then
return "\""
end
____cond20 = ____cond20 or ____switch20 == "\\"
if ____cond20 then
return "\\"
end
____cond20 = ____cond20 or ____switch20 == "n"
if ____cond20 then
return "\n"
end
____cond20 = ____cond20 or ____switch20 == "t"
if ____cond20 then
return "\t"
end
do
error(
__TS__New(SflLexError, ("invalid escape '\\" .. escaped) .. "'", start.line, start.col),
0
)
end
until true
end
local function indentationWidth(self, line)
local width = 0
while __TS__StringAccess(line, width) == " " or __TS__StringAccess(line, width) == "\t" do
width = width + 1
end
return width
end
local function dedent(self, text)
local lines = __TS__StringSplit(text, "\n")
local margin = math.huge
for ____, line in ipairs(lines) do
do
if not __t(
nil,
__TS__StringTrim(line)
) then
goto __continue5
end
margin = math.min(
margin,
indentationWidth(nil, line)
)
end
::__continue5::
end
if not __isFinite(nil, margin) or margin == 0 then
return text
end
return table.concat(
__TS__ArrayMap(
lines,
function(____, line) return __t(
nil,
__TS__StringTrim(line)
) and __TS__StringSlice(line, margin) or line end
),
"\n"
)
end
local function readLongString(self, cursor, start)
consumeLongStringDelimiter(nil, cursor)
local body = ""
while not cursor.done do
if cursor:startsWith("\"\"\"") then
consumeLongStringDelimiter(nil, cursor)
return dedent(
nil,
__replace(
nil,
__replace(
nil,
body,
__re(nil, "^\\r?\\n", ""),
""
),
__re(nil, "\\r?\\n[ \\t]*$", ""),
""
)
)
end
body = body .. cursor:advance()
end
error(
__TS__New(SflLexError, "unterminated long string", start.line, start.col),
0
)
end
local function readShortString(self, cursor, start)
cursor:advance()
local value = ""
while not cursor.done do
local character = cursor:advance()
if character == "\"" then
return value
end
if character == "\n" or character == "\r" then
error(
__TS__New(SflLexError, "newline in short string (use \"\"\" for multiline)", start.line, start.col),
0
)
end
value = value .. (character == "\\" and readEscapedCharacter(nil, cursor, start) or character)
end
error(
__TS__New(SflLexError, "unterminated string", start.line, start.col),
0
)
end
local function readString(self, cursor, start)
return cursor:startsWith("\"\"\"") and readLongString(nil, cursor, start) or readShortString(nil, cursor, start)
end
function ____exports.readStringToken(self, cursor, start)
return createToken(
nil,
"string",
readString(nil, cursor, start),
start
)
end
return ____exports
end,
["core.sflLanguage.lexing.nextToken"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local consumeLexerTrivia, readSymbolToken, readWordToken
local ____error = require("core.sflLanguage.lexing.error")
local SflLexError = ____error.SflLexError
local ____identifiers = require("core.sflLanguage.lexing.identifiers")
local readIdentifier = ____identifiers.readIdentifier
local startsIdentifier = ____identifiers.startsIdentifier
local ____lineBreak = require("core.sflLanguage.lexing.lineBreak")
local isLineBreak = ____lineBreak.isLineBreak
local readLineBreak = ____lineBreak.readLineBreak
local ____lineComment = require("core.sflLanguage.lexing.lineComment")
local consumeLineComment = ____lineComment.consumeLineComment
local startsLineComment = ____lineComment.startsLineComment
local ____numbers = require("core.sflLanguage.lexing.numbers")
local readNumber = ____numbers.readNumber
local startsNumber = ____numbers.startsNumber
local ____operators = require("core.sflLanguage.lexing.operators")
local readOperator = ____operators.readOperator
local ____punctuation = require("core.sflLanguage.lexing.punctuation")
local readPunctuation = ____punctuation.readPunctuation
local ____spacing = require("core.sflLanguage.lexing.spacing")
local consumeSpacing = ____spacing.consumeSpacing
local isSpacing = ____spacing.isSpacing
local ____strings = require("core.sflLanguage.lexing.strings")
local readStringToken = ____strings.readStringToken
function consumeLexerTrivia(self, cursor, character)
if isSpacing(nil, character) then
consumeSpacing(nil, cursor)
return true
end
if startsLineComment(nil, cursor) then
consumeLineComment(nil, cursor)
return true
end
return false
end
function readSymbolToken(self, cursor, character, start)
local punctuation = readPunctuation(nil, cursor, start)
if punctuation then
return punctuation
end
if character == "\"" then
return readStringToken(nil, cursor, start)
end
return readOperator(nil, cursor, start)
end
function readWordToken(self, cursor, start)
if startsNumber(nil, cursor) then
return readNumber(nil, cursor, start)
end
if startsIdentifier(nil, cursor) then
return readIdentifier(nil, cursor, start)
end
return nil
end
function ____exports.readNextToken(self, cursor)
local character = cursor:peek()
if character == nil then
return nil
end
local start = cursor:position()
if isLineBreak(nil, character) then
return readLineBreak(nil, cursor, start)
end
if consumeLexerTrivia(nil, cursor, character) then
return nil
end
local token = readSymbolToken(nil, cursor, character, start) or readWordToken(nil, cursor, start)
if token then
return token
end
error(
__TS__New(SflLexError, ("unexpected character '" .. character) .. "'", start.line, start.col),
0
)
end
return ____exports
end,
["core.sflLanguage.lexing.tokenizer"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____cursor = require("core.sflLanguage.lexing.cursor")
local SourceCursor = ____cursor.SourceCursor
local ____nextToken = require("core.sflLanguage.lexing.nextToken")
local readNextToken = ____nextToken.readNextToken
local ____tokenCreation = require("core.sflLanguage.lexing.tokenCreation")
local createToken = ____tokenCreation.createToken
local withTokenEnd = ____tokenCreation.withTokenEnd
function ____exports.tokenizeSource(self, input)
local cursor = __TS__New(SourceCursor, input)
local tokens = {}
while not cursor.done do
local token = readNextToken(nil, cursor)
if token then
tokens[#tokens + 1] = withTokenEnd(nil, token, cursor)
end
end
tokens[#tokens + 1] = withTokenEnd(
nil,
createToken(
nil,
"eof",
"",
cursor:position()
),
cursor
)
return tokens
end
return ____exports
end,
["core.sflLanguage.parsing.error"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local ____exports = {}
____exports.SflParseError = __TS__Class()
local SflParseError = ____exports.SflParseError
SflParseError.name = "SflParseError"
__TS__ClassExtends(SflParseError, Error)
function SflParseError.prototype.____constructor(self, message, line, col)
Error.prototype.____constructor(
self,
(((("SFL parse error (" .. tostring(line)) .. ":") .. tostring(col)) .. "): ") .. message
)
self.line = line
self.col = col
self.name = "SflParseError"
end
return ____exports
end,
["core.sflLanguage.parsing.cursor"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____error = require("core.sflLanguage.parsing.error")
local SflParseError = ____error.SflParseError
____exports.TokenCursor = __TS__Class()
local TokenCursor = ____exports.TokenCursor
TokenCursor.name = "TokenCursor"
function TokenCursor.prototype.____constructor(self, tokens)
self.tokens = tokens
self.position = 0
end
function TokenCursor.prototype.peek(self, offset)
if offset == nil then
offset = 0
end
return self.tokens[math.min(self.position + offset, #self.tokens - 1) + 1]
end
function TokenCursor.prototype.at(self, ____type)
return self:peek().type == ____type
end
function TokenCursor.prototype.next(self)
local ____self_tokens_3 = self.tokens
local ____self_0, ____position_1 = self, "position"
local ____self_position_2 = ____self_0[____position_1]
____self_0[____position_1] = ____self_position_2 + 1
return ____self_tokens_3[____self_position_2 + 1]
end
function TokenCursor.prototype.expect(self, ____type, description)
local token = self:peek()
if token.type ~= ____type then
error(
__TS__New(
SflParseError,
((("expected " .. description) .. ", got '") .. __lor(
nil,
token.value,
function() return token.type end
)) .. "'",
token.line,
token.col
),
0
)
end
return self:next()
end
function TokenCursor.prototype.expectNumber(self, description)
local token = self:expect("number", description)
if token.numberValue == nil then
error(
__TS__New(SflParseError, ("expected " .. description) .. " to contain a numeric value", token.line, token.col),
0
)
end
return token.numberValue
end
function TokenCursor.prototype.skipNewlines(self)
while self:at("newline") do
self:next()
end
end
return ____exports
end,
["core.sflLanguage.parsing.pathSegments"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.parsePathSegments(self, cursor)
local segments = {cursor:expect("ident", "path identifier").value}
while cursor:at("dot") do
cursor:next()
segments[#segments + 1] = cursor:expect("ident", "identifier after \".\"").value
end
return segments
end
return ____exports
end,
["core.sflLanguage.parsing.expressions"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local ____exports = {}
local atOperator, parseBinaryLevel, parseAnd, parseComparison, parseAdditive, parseMultiplicative, parseUnary, parseCallArguments, parsePrimary, expectEnd, COMPARISONS, OR, AND, ADDITIVE, MULTIPLICATIVE
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __re = ______shims.__re
local __test = ______shims.__test
local ____error = require("core.sflLanguage.parsing.error")
local SflParseError = ____error.SflParseError
local ____pathSegments = require("core.sflLanguage.parsing.pathSegments")
local parsePathSegments = ____pathSegments.parsePathSegments
function atOperator(self, cursor, operators)
local token = cursor:peek()
return token.type == "op" and operators:has(token.value)
end
function parseBinaryLevel(self, cursor, operators, parseOperand)
local left = parseOperand(nil, cursor)
while atOperator(nil, cursor, operators) do
local operator = cursor:next().value
left = {
kind = "binary",
operator = operator,
left = left,
right = parseOperand(nil, cursor)
}
end
return left
end
function ____exports.parseExpression(self, cursor)
return parseBinaryLevel(nil, cursor, OR, parseAnd)
end
function parseAnd(self, cursor)
return parseBinaryLevel(nil, cursor, AND, parseComparison)
end
function parseComparison(self, cursor)
return parseBinaryLevel(nil, cursor, COMPARISONS, parseAdditive)
end
function parseAdditive(self, cursor)
return parseBinaryLevel(nil, cursor, ADDITIVE, parseMultiplicative)
end
function parseMultiplicative(self, cursor)
return parseBinaryLevel(nil, cursor, MULTIPLICATIVE, parseUnary)
end
function parseUnary(self, cursor)
local token = cursor:peek()
if token.type == "op" and (token.value == "!" or token.value == "-") then
cursor:next()
return {
kind = "unary",
operator = token.value,
operand = parseUnary(nil, cursor)
}
end
return parsePrimary(nil, cursor)
end
function parseCallArguments(self, cursor)
cursor:expect("lparen", "'('")
local args = {}
cursor:skipNewlines()
while not cursor:at("rparen") do
args[#args + 1] = ____exports.parseExpression(nil, cursor)
cursor:skipNewlines()
if cursor:at("comma") then
cursor:next()
cursor:skipNewlines()
elseif not cursor:at("rparen") then
local token = cursor:peek()
error(
__TS__New(
SflParseError,
("expected ',' or ')', got '" .. __lor(
nil,
token.value,
function() return token.type end
)) .. "'",
token.line,
token.col
),
0
)
end
end
cursor:expect("rparen", "')'")
return args
end
function parsePrimary(self, cursor)
local token = cursor:peek()
repeat
local ____switch18 = token.type
local ____cond18 = ____switch18 == "number"
if ____cond18 then
return {
kind = "number",
value = cursor:expectNumber("number")
}
end
____cond18 = ____cond18 or ____switch18 == "string"
if ____cond18 then
cursor:next()
return {kind = "string", value = token.value}
end
____cond18 = ____cond18 or ____switch18 == "lparen"
if ____cond18 then
do
cursor:next()
local inner = ____exports.parseExpression(nil, cursor)
cursor:expect("rparen", "')'")
return inner
end
end
____cond18 = ____cond18 or ____switch18 == "ident"
if ____cond18 then
do
local path = parsePathSegments(nil, cursor)
if #path == 1 and (path[1] == "true" or path[1] == "false") then
return {kind = "boolean", value = path[1] == "true"}
end
return cursor:at("lparen") and ({
kind = "call",
callee = path,
args = parseCallArguments(nil, cursor)
}) or ({kind = "ref", path = path})
end
end
do
error(
__TS__New(
SflParseError,
("expected an expression, got '" .. __lor(
nil,
token.value,
function() return token.type end
)) .. "'",
token.line,
token.col
),
0
)
end
until true
end
function expectEnd(self, cursor, what)
local next = cursor:peek()
if not __TS__ArrayIncludes({"newline", "semi", "rbrace", "eof"}, next.type) then
error(
__TS__New(
SflParseError,
(("unexpected '" .. __lor(
nil,
next.value,
function() return next.type end
)) .. "' after ") .. what,
next.line,
next.col
),
0
)
end
if next.type == "semi" then
cursor:next()
end
end
COMPARISONS = __TS__New(Set, {
">",
"<",
">=",
"<=",
"==",
"!="
})
OR = __TS__New(Set, {"||"})
AND = __TS__New(Set, {"&&"})
ADDITIVE = __TS__New(Set, {"+", "-"})
MULTIPLICATIVE = __TS__New(Set, {"*", "/"})
____exports.BINDING_OPERATORS = {"bind", "bind2", "action"}
function ____exports.atBinding(self, cursor)
return cursor:peek().type == "ident" and cursor:peek(1).type == "colon" and __TS__ArrayIncludes(
____exports.BINDING_OPERATORS,
cursor:peek(2).type
)
end
function ____exports.parseBinding(self, cursor)
local key = cursor:expect("ident", "bound property")
cursor:expect("colon", "':'")
local operator = cursor:next().value
local expr = ____exports.parseExpression(nil, cursor)
local next = cursor:peek()
if not __TS__ArrayIncludes({"newline", "semi", "rbrace", "eof"}, next.type) then
error(
__TS__New(
SflParseError,
("unexpected '" .. __lor(
nil,
next.value,
function() return next.type end
)) .. "' after binding",
next.line,
next.col
),
0
)
end
return {
key = key.value,
operator = operator,
expr = expr,
line = key.line,
col = key.col
}
end
function ____exports.parseAssignment(self, cursor)
local start = cursor:peek()
local target = parsePathSegments(nil, cursor)
cursor:expect("bind", "'<-'")
local expr = ____exports.parseExpression(nil, cursor)
return {target = target, expr = expr, line = start.line, col = start.col}
end
function ____exports.atHandler(self, cursor)
local token = cursor:peek()
return token.type == "ident" and __test(
nil,
__re(nil, "^on[A-Z]", ""),
token.value
) and __TS__ArrayIncludes(
{"colon", "lbrace"},
cursor:peek(1).type
)
end
function ____exports.parseHandler(self, cursor)
local event = cursor:expect("ident", "event name")
local assignments = {}
if cursor:at("colon") then
cursor:next()
assignments[#assignments + 1] = ____exports.parseAssignment(nil, cursor)
expectEnd(nil, cursor, "handler")
else
cursor:expect("lbrace", "'{'")
cursor:skipNewlines()
while not cursor:at("rbrace") do
if cursor:at("eof") then
error(
__TS__New(SflParseError, ("unterminated handler '" .. event.value) .. "'", event.line, event.col),
0
)
end
assignments[#assignments + 1] = ____exports.parseAssignment(nil, cursor)
expectEnd(nil, cursor, "assignment")
cursor:skipNewlines()
end
cursor:expect("rbrace", "'}'")
end
return {event = event.value, assignments = assignments, line = event.line, col = event.col}
end
return ____exports
end,
["core.sflLanguage.parsing.values"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local Set = ____lualib.Set
local ____exports = {}
local listItemIsComputed, parseListItem, parseList, startsComputed, parseComputed, ARITHMETIC
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____ast = require("core.sflLanguage.ast")
local isSide = ____ast.isSide
local ____error = require("core.sflLanguage.parsing.error")
local SflParseError = ____error.SflParseError
local ____expressions = require("core.sflLanguage.parsing.expressions")
local parseExpression = ____expressions.parseExpression
local ____pathSegments = require("core.sflLanguage.parsing.pathSegments")
local parsePathSegments = ____pathSegments.parsePathSegments
function listItemIsComputed(self, cursor)
local start = cursor:peek().type == "op" and cursor:peek().value == "-" and 1 or 0
local first = cursor:peek(start)
if first.type ~= "number" and first.type ~= "ident" and first.type ~= "lparen" then
return false
end
do
local offset = start
while true do
local token = cursor:peek(offset)
if token.type == "comma" or token.type == "rbracket" or token.type == "newline" or token.type == "eof" then
return false
end
if token.type == "lparen" or token.type == "op" and ARITHMETIC:has(token.value) then
return true
end
offset = offset + 1
end
end
end
function parseListItem(self, cursor)
return listItemIsComputed(nil, cursor) and ({
type = "expr",
items = {parseExpression(nil, cursor)}
}) or ____exports.parseValue(nil, cursor, false)
end
function parseList(self, cursor)
cursor:expect("lbracket", "'['")
local values = {}
cursor:skipNewlines()
if not cursor:at("rbracket") then
values[#values + 1] = parseListItem(nil, cursor)
cursor:skipNewlines()
while cursor:at("comma") do
cursor:next()
cursor:skipNewlines()
if cursor:at("rbracket") then
break
end
values[#values + 1] = parseListItem(nil, cursor)
cursor:skipNewlines()
end
end
cursor:expect("rbracket", "']'")
return {type = "list", values = values}
end
function startsComputed(self, cursor)
local first = cursor:peek()
if first.type == "op" and first.value == "-" then
return true
end
if first.type == "string" and cursor:peek(1).type == "op" then
return true
end
if first.type ~= "number" and first.type ~= "ident" and first.type ~= "lparen" then
return false
end
do
local offset = 0
while true do
local token = cursor:peek(offset)
if token.type == "newline" or token.type == "semi" or token.type == "rbrace" or token.type == "eof" then
return false
end
if token.type == "lparen" or token.type == "op" and ARITHMETIC:has(token.value) then
return true
end
if token.type == "ident" and cursor:peek(offset - 1).type == "comma" then
return true
end
if offset == 0 and token.type == "ident" and cursor:peek(1).type == "comma" then
return true
end
offset = offset + 1
end
end
end
function parseComputed(self, cursor)
local items = {parseExpression(nil, cursor)}
while cursor:at("comma") do
cursor:next()
items[#items + 1] = parseExpression(nil, cursor)
end
return {type = "expr", items = items}
end
function ____exports.parseValue(self, cursor, allowTuple)
if allowTuple == nil then
allowTuple = true
end
if allowTuple and startsComputed(nil, cursor) then
return parseComputed(nil, cursor)
end
local token = cursor:peek()
repeat
local ____switch31 = token.type
local ____cond31 = ____switch31 == "string"
if ____cond31 then
cursor:next()
return {type = "string", value = token.value}
end
____cond31 = ____cond31 or ____switch31 == "lbracket"
if ____cond31 then
return parseList(nil, cursor)
end
____cond31 = ____cond31 or ____switch31 == "number"
if ____cond31 then
do
local firstValue = cursor:expectNumber("number")
if not allowTuple or not cursor:at("comma") then
return {type = "number", value = firstValue}
end
local values = {firstValue}
while cursor:at("comma") do
cursor:next()
values[#values + 1] = cursor:expectNumber("number in tuple")
end
return {type = "tuple", values = values}
end
end
____cond31 = ____cond31 or ____switch31 == "ident"
if ____cond31 then
return {
type = "ident",
segments = parsePathSegments(nil, cursor)
}
end
do
error(
__TS__New(
SflParseError,
("expected a value, got '" .. __lor(
nil,
token.value,
function() return token.type end
)) .. "'",
token.line,
token.col
),
0
)
end
until true
end
function ____exports.parseEndpoint(self, cursor)
local segments = parsePathSegments(nil, cursor)
local side
local fraction
if cursor:at("comma") then
cursor:next()
local sideToken = cursor:expect("ident", "side after \",\"")
if not isSide(nil, sideToken.value) then
error(
__TS__New(SflParseError, ("expected a side (top/right/bottom/left), got '" .. sideToken.value) .. "'", sideToken.line, sideToken.col),
0
)
end
side = sideToken.value
if cursor:at("lparen") then
cursor:next()
fraction = cursor:expectNumber("fraction inside \"(\"")
cursor:expect("rparen", "')'")
end
end
return {type = "endpoint", segments = segments, side = side, fraction = fraction}
end
ARITHMETIC = __TS__New(Set, {
"+",
"-",
"*",
"/",
">",
"<",
">=",
"<=",
"==",
"!=",
"&&",
"||"
})
return ____exports
end,
["core.sflLanguage.parsing.properties"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____error = require("core.sflLanguage.parsing.error")
local SflParseError = ____error.SflParseError
local ____expressions = require("core.sflLanguage.parsing.expressions")
local atBinding = ____expressions.atBinding
local parseBinding = ____expressions.parseBinding
local ____values = require("core.sflLanguage.parsing.values")
local parseEndpoint = ____values.parseEndpoint
local parseValue = ____values.parseValue
____exports.PropertyParser = __TS__Class()
local PropertyParser = ____exports.PropertyParser
PropertyParser.name = "PropertyParser"
function PropertyParser.prototype.____constructor(self, cursor)
self.cursor = cursor
end
function PropertyParser.prototype.parseLayout(self)
return self:parseBoundBlock("layout")
end
function PropertyParser.prototype.parseStyle(self)
return self:parseBoundBlock("style")
end
function PropertyParser.prototype.parseBoundBlock(self, kind)
self.cursor:next()
self.cursor:skipNewlines()
self.cursor:expect("lbrace", "'{'")
local properties = {}
local bindings = {}
self.cursor:skipNewlines()
while not self.cursor:at("rbrace") do
if self.cursor:at("eof") then
local token = self.cursor:peek()
error(
__TS__New(SflParseError, ("unterminated " .. kind) .. " block", token.line, token.col),
0
)
end
if atBinding(nil, self.cursor) then
bindings[#bindings + 1] = parseBinding(nil, self.cursor)
if self.cursor:at("newline") or self.cursor:at("semi") then
self.cursor:next()
end
else
properties[#properties + 1] = self:parseProperty()
end
self.cursor:skipNewlines()
end
self.cursor:expect("rbrace", "'}'")
return __t(nil, #bindings) and ({properties = properties, bindings = bindings}) or ({properties = properties})
end
function PropertyParser.prototype.parseFields(self)
self.cursor:next()
return self:parsePropertyBlock("fields")
end
function PropertyParser.prototype.parseProperty(self)
local key = self.cursor:expect("ident", "property key").value
self.cursor:expect("colon", "':'")
local value = (key == "from" or key == "to") and parseEndpoint(nil, self.cursor) or (key == "each" and self:parseEach() or parseValue(nil, self.cursor))
self:consumeTerminator()
return {key = key, value = value}
end
function PropertyParser.prototype.parseEach(self)
local row = self.cursor:expect("ident", "a name for one row").value
local word = self.cursor:expect("ident", "'in'")
if word.value ~= "in" then
error(
__TS__New(SflParseError, "each is written as 'each: row in table'", word.line, word.col),
0
)
end
local source = self.cursor:expect("ident", "the name of a DataSource").value
return {type = "each", row = row, source = source}
end
function PropertyParser.prototype.parsePropertyBlock(self, kind)
self.cursor:skipNewlines()
self.cursor:expect("lbrace", "'{'")
local properties = {}
self.cursor:skipNewlines()
while not self.cursor:at("rbrace") do
if self.cursor:at("eof") then
local token = self.cursor:peek()
error(
__TS__New(SflParseError, ("unterminated " .. kind) .. " block", token.line, token.col),
0
)
end
properties[#properties + 1] = self:parseProperty()
self.cursor:skipNewlines()
end
self.cursor:expect("rbrace", "'}'")
return properties
end
function PropertyParser.prototype.consumeTerminator(self)
if self.cursor:at("newline") or self.cursor:at("semi") then
self.cursor:next()
return
end
if self.cursor:at("rbrace") or self.cursor:at("eof") then
return
end
local token = self.cursor:peek()
error(
__TS__New(
SflParseError,
("unexpected '" .. __lor(
nil,
token.value,
function() return token.type end
)) .. "' after property value",
token.line,
token.col
),
0
)
end
return ____exports
end,
["core.sflLanguage.parsing.blocks"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____ast = require("core.sflLanguage.ast")
local isNamedBlockKind = ____ast.isNamedBlockKind
local ____error = require("core.sflLanguage.parsing.error")
local SflParseError = ____error.SflParseError
local ____expressions = require("core.sflLanguage.parsing.expressions")
local atBinding = ____expressions.atBinding
local atHandler = ____expressions.atHandler
local parseBinding = ____expressions.parseBinding
local parseHandler = ____expressions.parseHandler
local ____properties = require("core.sflLanguage.parsing.properties")
local PropertyParser = ____properties.PropertyParser
____exports.BlockParser = __TS__Class()
local BlockParser = ____exports.BlockParser
BlockParser.name = "BlockParser"
function BlockParser.prototype.____constructor(self, cursor)
self.cursor = cursor
self.properties = __TS__New(PropertyParser, cursor)
end
function BlockParser.prototype.parseBlock(self)
local kind = self.cursor:expect("ident", "block kind")
if not isNamedBlockKind(nil, kind.value) then
error(
__TS__New(SflParseError, ("unknown block kind '" .. kind.value) .. "'", kind.line, kind.col),
0
)
end
local name = self.cursor:expect("ident", "block name")
local composition = self:parseComposition()
local entries = self:parseBlockEntries()
return {kind = kind.value, name = name.value, composition = composition, entries = entries}
end
function BlockParser.prototype.parseComposition(self)
if not self.cursor:at("colon") then
return {}
end
self.cursor:next()
local composition = {self.cursor:expect("ident", "reference name after \":\"").value}
while self.cursor:at("amp") do
self.cursor:next()
composition[#composition + 1] = self.cursor:expect("ident", "reference name after \"&\"").value
end
return composition
end
function BlockParser.prototype.parseBlockEntries(self)
return self:parseEntries(function() return self:parseBlockEntry() end)
end
function BlockParser.prototype.parseDataEntries(self)
return self:parseEntries(function() return self:parseDataEntry() end)
end
function BlockParser.prototype.parseEntries(self, parseEntry)
self.cursor:skipNewlines()
self.cursor:expect("lbrace", "'{'")
local entries = {}
self.cursor:skipNewlines()
while not self.cursor:at("rbrace") do
if self.cursor:at("eof") then
local token = self.cursor:peek()
error(
__TS__New(SflParseError, "unterminated block (missing \"}\")", token.line, token.col),
0
)
end
entries[#entries + 1] = parseEntry(nil)
if self.cursor:at("semi") then
self.cursor:next()
end
self.cursor:skipNewlines()
end
self.cursor:expect("rbrace", "'}'")
return entries
end
function BlockParser.prototype.parseBlockEntry(self)
local token = self.cursor:peek()
if token.type ~= "ident" then
error(
__TS__New(
SflParseError,
("expected property, block, layout, or style — got '" .. __lor(
nil,
token.value,
function() return token.type end
)) .. "'",
token.line,
token.col
),
0
)
end
if isNamedBlockKind(nil, token.value) and self.cursor:peek(1).type == "ident" then
return {
type = "block",
block = self:parseBlock()
}
end
if token.value == "layout" and self.cursor:peek(1).type == "lbrace" then
return {
type = "layout",
layout = self.properties:parseLayout()
}
end
if token.value == "style" and self.cursor:peek(1).type == "lbrace" then
return {
type = "style",
style = self.properties:parseStyle()
}
end
if token.value == "fields" and self.cursor:peek(1).type == "lbrace" then
return {
type = "fields",
fields = self.properties:parseFields()
}
end
if atBinding(nil, self.cursor) then
return {
type = "binding",
binding = parseBinding(nil, self.cursor)
}
end
if atHandler(nil, self.cursor) then
return {
type = "handler",
handler = parseHandler(nil, self.cursor)
}
end
if token.value == "data" and self.cursor:peek(1).type == "lbrace" then
return {
type = "data",
data = self:parseDataBlock()
}
end
return {
type = "property",
property = self.properties:parseProperty()
}
end
function BlockParser.prototype.parseDataEntry(self)
local token = self.cursor:peek()
if token.type == "ident" and not isNamedBlockKind(nil, token.value) and self:looksLikeSeriesEntry() then
return {
type = "block",
block = self:parseSeriesEntry()
}
end
return self:parseBlockEntry()
end
function BlockParser.prototype.parseDataBlock(self)
self.cursor:next()
return {
kind = "data",
name = "",
composition = {},
entries = self:parseDataEntries()
}
end
function BlockParser.prototype.looksLikeSeriesEntry(self)
if self.cursor:peek(1).type == "lbrace" then
return true
end
if self.cursor:peek(1).type ~= "colon" then
return false
end
local offset = 2
if self.cursor:peek(offset).type ~= "ident" then
return false
end
offset = offset + 1
while self.cursor:peek(offset).type == "amp" do
offset = offset + 1
if self.cursor:peek(offset).type ~= "ident" then
return false
end
offset = offset + 1
end
return self.cursor:peek(offset).type == "lbrace"
end
function BlockParser.prototype.parseSeriesEntry(self)
local name = self.cursor:expect("ident", "series name")
local composition = self:parseComposition()
local entries = self:parseBlockEntries()
return {kind = "Series", name = name.value, composition = composition, entries = entries}
end
return ____exports
end,
["core.sflLanguage.parsing.document"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____blocks = require("core.sflLanguage.parsing.blocks")
local BlockParser = ____blocks.BlockParser
local ____error = require("core.sflLanguage.parsing.error")
local SflParseError = ____error.SflParseError
____exports.DocumentParser = __TS__Class()
local DocumentParser = ____exports.DocumentParser
DocumentParser.name = "DocumentParser"
function DocumentParser.prototype.____constructor(self, cursor)
self.cursor = cursor
self.blocks = __TS__New(BlockParser, cursor)
end
function DocumentParser.prototype.parseDocument(self)
self.cursor:skipNewlines()
local header = self.cursor:expect("ident", "'sfl' header")
if header.value ~= "sfl" then
error(
__TS__New(SflParseError, ("document must start with 'sfl', got '" .. header.value) .. "'", header.line, header.col),
0
)
end
local version = self.cursor:expect("number", "version number")
self.cursor:skipNewlines()
local blocks = {}
while not self.cursor:at("eof") do
blocks[#blocks + 1] = self.blocks:parseBlock()
self.cursor:skipNewlines()
end
return {version = version.value, blocks = blocks}
end
return ____exports
end,
["core.sflLanguage.parsing.parser"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____tokenizer = require("core.sflLanguage.lexing.tokenizer")
local tokenizeSource = ____tokenizer.tokenizeSource
local ____cursor = require("core.sflLanguage.parsing.cursor")
local TokenCursor = ____cursor.TokenCursor
local ____document = require("core.sflLanguage.parsing.document")
local DocumentParser = ____document.DocumentParser
function ____exports.parseSource(self, input)
return __TS__New(
DocumentParser,
__TS__New(
TokenCursor,
tokenizeSource(nil, input)
)
):parseDocument()
end
return ____exports
end,
["core.sflLanguage.canonicalize"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____document = require("core.sflLanguage.emitting.document")
local emitDocument = ____document.emitDocument
local ____parser = require("core.sflLanguage.parsing.parser")
local parseSource = ____parser.parseSource
function ____exports.canonicalizeSource(self, sflText)
return emitDocument(
nil,
parseSource(nil, sflText)
)
end
return ____exports
end,
["core.sflLanguage.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____export = require("core.sflLanguage.ast")
for ____exportKey, ____exportValue in pairs(____export) do
if ____exportKey ~= "default" then
____exports[____exportKey] = ____exportValue
end
end
end
do
local ____canonicalize = require("core.sflLanguage.canonicalize")
____exports.canonicalize = ____canonicalize.canonicalizeSource
end
do
local ____document = require("core.sflLanguage.emitting.document")
____exports.emit = ____document.emitDocument
end
do
local ____error = require("core.sflLanguage.lexing.error")
____exports.SflLexError = ____error.SflLexError
end
do
local ____tokenizer = require("core.sflLanguage.lexing.tokenizer")
____exports.tokenize = ____tokenizer.tokenizeSource
end
do
local ____error = require("core.sflLanguage.parsing.error")
____exports.SflParseError = ____error.SflParseError
end
do
local ____parser = require("core.sflLanguage.parsing.parser")
____exports.parse = ____parser.parseSource
end
return ____exports
end,
["core.sflLanguage.expansion.random"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
local ______shims = require("core.__shims")
local __imul = ______shims.__imul
local __or = ______shims.__or
local __shr = ______shims.__shr
local __xor = ______shims.__xor
____exports.Random = __TS__Class()
local Random = ____exports.Random
Random.name = "Random"
function Random.prototype.____constructor(self, seed)
self.state = __shr(nil, seed, 0)
end
function Random.prototype.next(self)
self.state = __shr(nil, self.state + 1831565813, 0)
local t = self.state
t = __imul(
nil,
__xor(
nil,
t,
__shr(nil, t, 15)
),
__or(nil, t, 1)
)
t = __xor(
nil,
t,
t + __imul(
nil,
__xor(
nil,
t,
__shr(nil, t, 7)
),
__or(nil, t, 61)
)
)
return __shr(
nil,
__xor(
nil,
t,
__shr(nil, t, 14)
),
0
) / 4294967296
end
return ____exports
end,
["core.sflLanguage.expansion.scope"] = function(...)
local ____lualib = require("lualib_bundle")
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
function ____exports.fail(self, scope, message)
error(
__TS__New(Error, (scope.label .. ": ") .. message),
0
)
end
function ____exports.numberOf(self, scope, value, what)
if type(value) ~= "number" or not __isFinite(nil, value) then
____exports.fail(nil, scope, what .. " needs a number")
end
return value
end
return ____exports
end,
["core.sflLanguage.expansion.functions"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ParseInt = ____lualib.__TS__ParseInt
local __TS__NumberToString = ____lualib.__TS__NumberToString
local __TS__StringPadStart = ____lualib.__TS__StringPadStart
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __and = ______shims.__and
local __exec = ______shims.__exec
local __hypot = ______shims.__hypot
local __re = ______shims.__re
local __sar = ______shims.__sar
local __t = ______shims.__t
local ____scope = require("core.sflLanguage.expansion.scope")
local fail = ____scope.fail
local numberOf = ____scope.numberOf
local function rgbOf(self, scope, value)
local ____temp_0
if type(value) == "string" then
____temp_0 = __exec(
nil,
__re(nil, "^#([0-9a-f]{6})$", "i"),
value
)
else
____temp_0 = nil
end
local match = ____temp_0
if not match then
fail(nil, scope, "a color has to be written as \"#rrggbb\"")
end
local n = __TS__ParseInt(match[2], 16)
return {
__and(
nil,
__sar(nil, n, 16),
255
),
__and(
nil,
__sar(nil, n, 8),
255
),
__and(nil, n, 255)
}
end
local function hexOf(____, rgb)
return "#" .. table.concat(
__TS__ArrayMap(
rgb,
function(____, channel) return __TS__StringPadStart(
__TS__NumberToString(
math.floor(math.max(
0,
math.min(255, channel)
) + 0.5),
16
),
2,
"0"
) end
),
""
)
end
function ____exports.callFunction(self, scope, name, args)
local function number(____, index)
return numberOf(nil, scope, args[index + 1], name .. "()")
end
repeat
local ____switch8 = name
local ____cond8 = ____switch8 == "random"
if ____cond8 then
do
if #args == 0 then
return scope.random:next()
end
local low = #args == 1 and 0 or number(nil, 0)
local high = #args == 1 and number(nil, 0) or number(nil, 1)
return low + scope.random:next() * (high - low)
end
end
____cond8 = ____cond8 or ____switch8 == "pick"
if ____cond8 then
do
if #args == 0 then
fail(nil, scope, "pick() needs at least one value")
end
return args[math.floor(scope.random:next() * #args) + 1]
end
end
____cond8 = ____cond8 or ____switch8 == "exp"
if ____cond8 then
return math.exp(number(nil, 0))
end
____cond8 = ____cond8 or ____switch8 == "pow"
if ____cond8 then
return number(nil, 0) ^ number(nil, 1)
end
____cond8 = ____cond8 or ____switch8 == "dist"
if ____cond8 then
return __hypot(
nil,
number(nil, 0) - number(nil, 2),
number(nil, 1) - number(nil, 3)
)
end
____cond8 = ____cond8 or ____switch8 == "mix"
if ____cond8 then
do
local from = rgbOf(nil, scope, args[1])
local to = rgbOf(nil, scope, args[2])
local amount = math.max(
0,
math.min(
1,
number(nil, 2)
)
)
return hexOf(
nil,
__TS__ArrayMap(
from,
function(____, channel, index) return channel + (to[index + 1] - channel) * amount end
)
)
end
end
____cond8 = ____cond8 or ____switch8 == "shade"
if ____cond8 then
do
local factor = number(nil, 1)
return hexOf(
nil,
__TS__ArrayMap(
rgbOf(nil, scope, args[1]),
function(____, channel) return channel * factor end
)
)
end
end
____cond8 = ____cond8 or ____switch8 == "floor"
if ____cond8 then
return math.floor(number(nil, 0))
end
____cond8 = ____cond8 or ____switch8 == "ceil"
if ____cond8 then
return math.ceil(number(nil, 0))
end
____cond8 = ____cond8 or ____switch8 == "round"
if ____cond8 then
return math.floor(number(nil, 0) + 0.5)
end
____cond8 = ____cond8 or ____switch8 == "abs"
if ____cond8 then
return math.abs(number(nil, 0))
end
____cond8 = ____cond8 or ____switch8 == "sqrt"
if ____cond8 then
return math.sqrt(number(nil, 0))
end
____cond8 = ____cond8 or ____switch8 == "sin"
if ____cond8 then
return math.sin(number(nil, 0))
end
____cond8 = ____cond8 or ____switch8 == "cos"
if ____cond8 then
return math.cos(number(nil, 0))
end
____cond8 = ____cond8 or ____switch8 == "min"
if ____cond8 then
return math.min(table.unpack(__TS__ArrayMap(
args,
function(____, _, index) return number(nil, index) end
)))
end
____cond8 = ____cond8 or ____switch8 == "max"
if ____cond8 then
return math.max(table.unpack(__TS__ArrayMap(
args,
function(____, _, index) return number(nil, index) end
)))
end
____cond8 = ____cond8 or ____switch8 == "when"
if ____cond8 then
local ____t_result_1
if __t(nil, args[1]) then
____t_result_1 = args[2]
else
____t_result_1 = args[3]
end
return ____t_result_1
end
do
return fail(nil, scope, ("unknown function " .. name) .. "()")
end
until true
end
return ____exports
end,
["core.sflLanguage.expansion.evaluation"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____functions = require("core.sflLanguage.expansion.functions")
local callFunction = ____functions.callFunction
local ____scope = require("core.sflLanguage.expansion.scope")
local fail = ____scope.fail
local numberOf = ____scope.numberOf
function ____exports.evaluate(self, scope, expr)
repeat
local ____switch3 = expr.kind
local ____cond3 = ____switch3 == "number" or ____switch3 == "string" or ____switch3 == "boolean"
if ____cond3 then
return expr.value
end
____cond3 = ____cond3 or ____switch3 == "ref"
if ____cond3 then
do
local name = table.concat(expr.path, ".")
local ____temp_0 = scope.vars:get(name)
if ____temp_0 == nil then
____temp_0 = scope.params:get(name)
end
local value = ____temp_0
if value == nil then
fail(nil, scope, "unknown name " .. name)
end
return value
end
end
____cond3 = ____cond3 or ____switch3 == "unary"
if ____cond3 then
do
local operand = ____exports.evaluate(nil, scope, expr.operand)
return expr.operator == "-" and -numberOf(nil, scope, operand, "a minus") or not __t(nil, operand)
end
end
____cond3 = ____cond3 or ____switch3 == "call"
if ____cond3 then
return callFunction(
nil,
scope,
table.concat(expr.callee, "."),
__TS__ArrayMap(
expr.args,
function(____, arg) return ____exports.evaluate(nil, scope, arg) end
)
)
end
____cond3 = ____cond3 or ____switch3 == "binary"
if ____cond3 then
do
local left = ____exports.evaluate(nil, scope, expr.left)
local right = ____exports.evaluate(nil, scope, expr.right)
repeat
local ____switch9 = expr.operator
local ____cond9 = ____switch9 == "+"
if ____cond9 then
return (type(left) == "string" or type(right) == "string") and tostring(left) .. tostring(right) or numberOf(nil, scope, left, "+") + numberOf(nil, scope, right, "+")
end
____cond9 = ____cond9 or ____switch9 == "-"
if ____cond9 then
return numberOf(nil, scope, left, "-") - numberOf(nil, scope, right, "-")
end
____cond9 = ____cond9 or ____switch9 == "*"
if ____cond9 then
return numberOf(nil, scope, left, "*") * numberOf(nil, scope, right, "*")
end
____cond9 = ____cond9 or ____switch9 == "/"
if ____cond9 then
return numberOf(nil, scope, left, "/") / numberOf(nil, scope, right, "/")
end
____cond9 = ____cond9 or ____switch9 == ">"
if ____cond9 then
return numberOf(nil, scope, left, ">") > numberOf(nil, scope, right, ">")
end
____cond9 = ____cond9 or ____switch9 == "<"
if ____cond9 then
return numberOf(nil, scope, left, "<") < numberOf(nil, scope, right, "<")
end
____cond9 = ____cond9 or ____switch9 == ">="
if ____cond9 then
return numberOf(nil, scope, left, ">=") >= numberOf(nil, scope, right, ">=")
end
____cond9 = ____cond9 or ____switch9 == "<="
if ____cond9 then
return numberOf(nil, scope, left, "<=") <= numberOf(nil, scope, right, "<=")
end
____cond9 = ____cond9 or ____switch9 == "=="
if ____cond9 then
return left == right
end
____cond9 = ____cond9 or ____switch9 == "!="
if ____cond9 then
return left ~= right
end
____cond9 = ____cond9 or ____switch9 == "&&"
if ____cond9 then
return Boolean(nil, left) and Boolean(nil, right)
end
____cond9 = ____cond9 or ____switch9 == "||"
if ____cond9 then
return Boolean(nil, left) or Boolean(nil, right)
end
until true
end
break
end
until true
end
____exports.round = function(____, value) return math.floor(value * 1000 + 0.5) / 1000 end
local function scalarValue(self, scope, only)
if type(only) == "number" then
return {
type = "number",
value = ____exports.round(
nil,
numberOf(nil, scope, only, "a value")
)
}
end
if type(only) == "string" then
return {type = "string", value = only}
end
return {
type = "ident",
segments = {tostring(only)}
}
end
function ____exports.resolveValue(self, scope, value)
if value.type == "ident" and #value.segments > 1 then
local field = scope.vars:get(table.concat(value.segments, "."))
if field ~= nil then
return scalarValue(nil, scope, field)
end
end
if value.type == "ident" and #value.segments == 1 then
local ____temp_1 = scope.vars:get(value.segments[1])
if ____temp_1 == nil then
____temp_1 = scope.params:get(value.segments[1])
end
local known = ____temp_1
if known ~= nil then
return scalarValue(nil, scope, known)
end
end
if value.type == "list" then
return {
type = "list",
values = __TS__ArrayMap(
value.values,
function(____, item) return ____exports.resolveValue(nil, scope, item) end
)
}
end
if value.type ~= "expr" then
return value
end
local results = __TS__ArrayMap(
value.items,
function(____, item) return ____exports.evaluate(nil, scope, item) end
)
if #results == 1 then
return scalarValue(nil, scope, results[1])
end
return {
type = "tuple",
values = __TS__ArrayMap(
results,
function(____, result) return ____exports.round(
nil,
numberOf(nil, scope, result, "a tuple")
) end
)
}
end
return ____exports
end,
["core.sflLanguage.expansion.instance"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local knownNames, bindingOf, handlerOf, propertiesOf, referenceOf, entryOf, REFERENCES
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____evaluation = require("core.sflLanguage.expansion.evaluation")
local resolveValue = ____evaluation.resolveValue
function knownNames(self, scope, expr)
repeat
local ____switch3 = expr.kind
local ____cond3 = ____switch3 == "ref"
if ____cond3 then
do
local ____temp_1
if #expr.path == 1 then
local ____temp_0 = scope.vars:get(expr.path[1])
if ____temp_0 == nil then
____temp_0 = scope.params:get(expr.path[1])
end
____temp_1 = ____temp_0
else
____temp_1 = scope.vars:get(table.concat(expr.path, "."))
end
local value = ____temp_1
if type(value) == "number" then
return {kind = "number", value = value}
end
if type(value) == "string" then
return {kind = "string", value = value}
end
return type(value) == "boolean" and ({kind = "boolean", value = value}) or expr
end
end
____cond3 = ____cond3 or ____switch3 == "unary"
if ____cond3 then
return __TS__ObjectAssign(
{},
expr,
{operand = knownNames(nil, scope, expr.operand)}
)
end
____cond3 = ____cond3 or ____switch3 == "binary"
if ____cond3 then
return __TS__ObjectAssign(
{},
expr,
{
left = knownNames(nil, scope, expr.left),
right = knownNames(nil, scope, expr.right)
}
)
end
____cond3 = ____cond3 or ____switch3 == "call"
if ____cond3 then
return __TS__ObjectAssign(
{},
expr,
{args = __TS__ArrayMap(
expr.args,
function(____, arg) return knownNames(nil, scope, arg) end
)}
)
end
do
return expr
end
until true
end
function bindingOf(self, scope, binding)
return __TS__ObjectAssign(
{},
binding,
{expr = knownNames(nil, scope, binding.expr)}
)
end
function handlerOf(self, scope, handler)
return __TS__ObjectAssign(
{},
handler,
{assignments = __TS__ArrayMap(
handler.assignments,
function(____, assignment) return __TS__ObjectAssign(
{},
assignment,
{expr = knownNames(nil, scope, assignment.expr)}
) end
)}
)
end
function propertiesOf(self, scope, properties)
return __TS__ArrayMap(
properties,
function(____, property) return {
key = property.key,
value = resolveValue(nil, scope, property.value)
} end
)
end
function referenceOf(self, key, value, rename, ____local)
local ____temp_2 = (value.type == "ident" or value.type == "endpoint") and value.segments or ({})
local first = ____temp_2[1]
local rest = __TS__ArraySlice(____temp_2, 1)
if first == nil or not ____local:has(first) then
return value
end
if value.type == "endpoint" then
return __TS__ObjectAssign(
{},
value,
{segments = {
rename(nil, first),
table.unpack(rest)
}}
)
end
return value.type == "ident" and REFERENCES:has(key) and #rest == 0 and __TS__ObjectAssign(
{},
value,
{segments = {rename(nil, first)}}
) or value
end
function entryOf(self, scope, entry, rename, ____local)
repeat
local ____switch17 = entry.type
local ____cond17 = ____switch17 == "property"
if ____cond17 then
return {
type = "property",
property = {
key = entry.property.key,
value = referenceOf(
nil,
entry.property.key,
resolveValue(nil, scope, entry.property.value),
rename,
____local
)
}
}
end
____cond17 = ____cond17 or ____switch17 == "layout"
if ____cond17 then
return {
type = "layout",
layout = __TS__ObjectAssign(
{properties = propertiesOf(nil, scope, entry.layout.properties)},
entry.layout.bindings and ({bindings = __TS__ArrayMap(
entry.layout.bindings,
function(____, binding) return bindingOf(nil, scope, binding) end
)}) or ({})
)
}
end
____cond17 = ____cond17 or ____switch17 == "style"
if ____cond17 then
return {
type = "style",
style = __TS__ObjectAssign(
{},
entry.style,
{properties = propertiesOf(nil, scope, entry.style.properties)},
entry.style.bindings and ({bindings = __TS__ArrayMap(
entry.style.bindings,
function(____, binding) return bindingOf(nil, scope, binding) end
)}) or ({})
)
}
end
____cond17 = ____cond17 or ____switch17 == "binding"
if ____cond17 then
return {
type = "binding",
binding = bindingOf(nil, scope, entry.binding)
}
end
____cond17 = ____cond17 or ____switch17 == "handler"
if ____cond17 then
return {
type = "handler",
handler = handlerOf(nil, scope, entry.handler)
}
end
____cond17 = ____cond17 or ____switch17 == "block"
if ____cond17 then
return {
type = "block",
block = ____exports.instance(
nil,
scope,
entry.block,
rename,
____local
)
}
end
do
return entry
end
until true
end
function ____exports.instance(self, scope, block, rename, ____local)
if ____local == nil then
____local = __TS__New(Set)
end
return __TS__ObjectAssign(
{},
block,
{
name = rename(nil, block.name),
entries = __TS__ArrayMap(
block.entries,
function(____, entry) return entryOf(
nil,
scope,
entry,
rename,
____local
) end
)
}
)
end
REFERENCES = __TS__New(Set, {"sketch", "anchor", "picture"})
function ____exports.namesIn(self, blocks)
local names = __TS__New(Set)
local visit
visit = function(____, block)
if __t(nil, block.name) then
names:add(block.name)
end
for ____, entry in ipairs(block.entries) do
if entry.type == "block" then
visit(nil, entry.block)
end
end
end
__TS__ArrayForEach(blocks, visit)
return names
end
return ____exports
end,
["core.sflLanguage.expansion.placement"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArraySome = ____lualib.__TS__ArraySome
local Map = ____lualib.Map
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____evaluation = require("core.sflLanguage.expansion.evaluation")
local resolveValue = ____evaluation.resolveValue
local ____random = require("core.sflLanguage.expansion.random")
local Random = ____random.Random
local ____scope = require("core.sflLanguage.expansion.scope")
local fail = ____scope.fail
function ____exports.turnMatrix(self, ____bindingPattern0)
local z
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
z = ____bindingPattern0[3]
local a, b, c = table.unpack(
__TS__ArrayMap(
{x, y, z},
function(____, angle) return angle * math.pi / 180 end
),
1,
3
)
local sa, ca, sb, cb, sc, cc = math.sin(a), math.cos(a), math.sin(b), math.cos(b), math.sin(c), math.cos(c)
return {
cc * cb,
cc * sb * sa - sc * ca,
cc * sb * ca + sc * sa,
sc * cb,
sc * sb * sa + cc * ca,
sc * sb * ca - cc * sa,
-sb,
cb * sa,
cb * ca
}
end
function ____exports.turnDegrees(self, m)
local function degrees(____, radians)
return __lor(
nil,
math.floor(radians * 180 / math.pi * 1000000 + 0.5) / 1000000,
function() return 0 end
)
end
local sb = math.max(
-1,
math.min(1, -m[7])
)
if math.abs(sb) > 0.999999 then
return {
0,
degrees(
nil,
math.asin(sb)
),
degrees(
nil,
math.atan(-m[2], m[5])
)
}
end
return {
degrees(
nil,
math.atan(m[8], m[9])
),
degrees(
nil,
math.asin(sb)
),
degrees(
nil,
math.atan(m[4], m[1])
)
}
end
local function times(____, m, v)
return {m[1] * v[1] + m[2] * v[2] + m[3] * v[3], m[4] * v[1] + m[5] * v[2] + m[6] * v[3], m[7] * v[1] + m[8] * v[2] + m[9] * v[3]}
end
____exports.product = function(____, a, b) return __TS__ArrayFlatMap(
{0, 1, 2},
function(____, row) return __TS__ArrayMap(
{0, 1, 2},
function(____, column) return a[row * 3 + 1] * b[column + 1] + a[row * 3 + 1 + 1] * b[3 + column + 1] + a[row * 3 + 2 + 1] * b[6 + column + 1] end
) end
) end
function ____exports.within(self, outer, inner)
local moved = times(nil, outer.turn, inner.at)
return {
at = {outer.at[1] + outer.scale * moved[1], outer.at[2] + outer.scale * moved[2], outer.at[3] + outer.scale * moved[3]},
turn = ____exports.product(nil, outer.turn, inner.turn),
scale = outer.scale * inner.scale
}
end
function ____exports.placeIn(self, placement, position, rotation, scale)
local placed = ____exports.within(
nil,
placement,
{
at = {position[1], position[2], position[3]},
turn = ____exports.turnMatrix(nil, rotation),
scale = 1
}
)
return {
position = placed.at,
rotation = ____exports.turnDegrees(nil, placed.turn),
scale = {scale[1] * placement.scale, scale[2] * placement.scale, scale[3] * placement.scale}
}
end
function ____exports.placementOf(self, scope, block)
local properties = __TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "layout" and entry.layout.properties or ({}) end
)
if #properties == 0 then
return nil
end
local kind = "a " .. block.kind
local function numbers(____, key)
local ____opt_0 = __TS__ArrayFind(
properties,
function(____, property) return property.key == key end
)
local written = ____opt_0 and ____opt_0.value
if not written then
return nil
end
local value = resolveValue(nil, scope, written)
if value.type == "number" then
return {value.value}
end
if value.type == "tuple" then
return value.values
end
fail(nil, scope, key .. " needs numbers")
end
for ____, ____value in ipairs(properties) do
local key = ____value.key
if key ~= "position" and key ~= "rotation" and key ~= "scale" then
fail(nil, scope, (("the layout of " .. kind) .. " in a Scene says its position, rotation and scale, not ") .. key)
end
end
local function three(____, key)
local found = numbers(nil, key) or ({0, 0, 0})
if #found ~= 3 then
fail(nil, scope, ((key .. " of ") .. kind) .. " in a Scene needs three numbers: x, y, z")
end
return {found[1], found[2], found[3]}
end
local scale = numbers(nil, "scale") or ({1})
if #scale ~= 1 or not (scale[1] > 0) then
fail(nil, scope, ("scale of " .. kind) .. " is one number above 0, as what it holds is made larger evenly; a Template can take a parameter for a length")
end
return {
at = three(nil, "position"),
turn = ____exports.turnMatrix(
nil,
three(nil, "rotation")
),
scale = scale[1]
}
end
function ____exports.placedWithin(self, blocks, placement)
return placement and __TS__ArrayMap(
blocks,
function(____, block) return __TS__ObjectAssign(
{},
block,
{["local"] = block["local"] and ____exports.within(nil, placement, block["local"]) or placement}
) end
) or blocks
end
local WHOLE = __TS__New(Set, {
"Solid",
"Mesh",
"Facets",
"Terrain",
"Canvas"
})
local function hasLayout(____, block)
return __TS__ArraySome(
block.entries,
function(____, entry) return entry.type == "layout" end
)
end
function ____exports.hasPlacements(self, blocks, inScene)
if inScene == nil then
inScene = false
end
return __TS__ArraySome(
blocks,
function(____, block) return block["local"] ~= nil or inScene and block.kind == "Group" and hasLayout(nil, block) or ____exports.hasPlacements(
nil,
__TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and ({entry.block}) or ({}) end
),
inScene or block.kind == "Scene"
) end
)
end
function ____exports.withPlacements(self, blocks, outer, inScene)
if inScene == nil then
inScene = false
end
return __TS__ArrayMap(
blocks,
function(____, block)
local scope = {
vars = __TS__New(Map),
params = __TS__New(Map),
random = __TS__New(Random, 0),
label = (block.kind .. " ") .. block.name
}
local ____temp_2
if inScene and block.kind == "Group" then
____temp_2 = ____exports.placementOf(nil, scope, block)
else
____temp_2 = nil
end
local own = ____temp_2
local steps = __TS__ArrayFilter(
__compact(outer, block["local"], own),
function(____, step) return step ~= nil end
)
local placement = __t(nil, #steps) and __TS__ArrayReduce(
steps,
function(____, sum, step) return ____exports.within(nil, sum, step) end
) or nil
return __TS__ObjectAssign(
{},
block,
placement and ({placement = placement}) or ({}),
{entries = WHOLE:has(block.kind) and block.entries or __TS__ArrayMap(
block.entries,
function(____, entry) return entry.type == "block" and ({
type = "block",
block = ____exports.withPlacements(nil, {entry.block}, placement, inScene or block.kind == "Scene")[1]
}) or entry end
)}
)
end
)
end
return ____exports
end,
["core.sflLanguage.expansion.properties"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____evaluation = require("core.sflLanguage.expansion.evaluation")
local resolveValue = ____evaluation.resolveValue
local ____scope = require("core.sflLanguage.expansion.scope")
local fail = ____scope.fail
function ____exports.propertyOf(self, block, key)
for ____, entry in ipairs(block.entries) do
if entry.type == "property" and entry.property.key == key then
return entry.property.value
end
end
return nil
end
function ____exports.numbersOf(self, scope, block, key)
local written = ____exports.propertyOf(nil, block, key)
if not written then
return nil
end
local value = resolveValue(nil, scope, written)
if value.type == "number" then
return {value.value}
end
if value.type == "tuple" then
return value.values
end
fail(nil, scope, key .. " needs a number")
end
return ____exports
end,
["core.sflLanguage.expansion.repeat"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local Map = ____lualib.Map
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local __TS__StringAccess = ____lualib.__TS__StringAccess
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__StringIncludes = ____lualib.__TS__StringIncludes
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local distance, helpersOf, RESERVED
local ______shims = require("core.__shims")
local __imul = ______shims.__imul
local __json = ______shims.__json
local __lor = ______shims.__lor
local __sort = ______shims.__sort
local __t = ______shims.__t
local __xor = ______shims.__xor
local ____evaluation = require("core.sflLanguage.expansion.evaluation")
local evaluate = ____evaluation.evaluate
local resolveValue = ____evaluation.resolveValue
local round = ____evaluation.round
local ____instance = require("core.sflLanguage.expansion.instance")
local instance = ____instance.instance
local namesIn = ____instance.namesIn
local ____placement = require("core.sflLanguage.expansion.placement")
local placedWithin = ____placement.placedWithin
local placementOf = ____placement.placementOf
local ____properties = require("core.sflLanguage.expansion.properties")
local numbersOf = ____properties.numbersOf
local propertyOf = ____properties.propertyOf
local ____random = require("core.sflLanguage.expansion.random")
local Random = ____random.Random
local ____scope = require("core.sflLanguage.expansion.scope")
local fail = ____scope.fail
function distance(self, a, b)
local row = __TS__ArrayFrom(
{length = #b + 1},
function(____, _, index) return index end
)
do
local i = 1
while i <= #a do
local corner = row[1]
row[1] = i
do
local j = 1
while j <= #b do
local above = row[j + 1]
row[j + 1] = math.min(
row[j + 1] + 1,
row[j] + 1,
corner + (__TS__StringAccess(a, i - 1) == __TS__StringAccess(b, j - 1) and 0 or 1)
)
corner = above
j = j + 1
end
end
i = i + 1
end
end
return row[#b + 1]
end
function helpersOf(self, block, scope, templates)
local used = __json(nil, templates)
return __TS__ArrayFlatMap(
block.entries,
function(____, entry)
if entry.type ~= "property" or RESERVED:has(entry.property.key) then
return {}
end
local ____entry_property_24 = entry.property
local key = ____entry_property_24.key
local meant = __TS__ArrayFind(
{__TS__Spread(RESERVED)},
function(____, word) return distance(nil, word, key) <= (#word > 4 and 2 or 1) end
)
if __t(nil, meant) and not __TS__StringIncludes(used, ("\"" .. key) .. "\"") then
fail(nil, scope, ((key .. " is not read by a Repeat, and no cell uses it: is it ") .. meant) .. "?")
end
return {entry.property}
end
)
end
RESERVED = __TS__New(Set, {
"columns",
"rows",
"count",
"each",
"step",
"origin",
"seed",
"jitter",
"chance",
"order",
"sequence",
"where"
})
local CELL_NAMES = __TS__New(Set, {
"col",
"row",
"index",
"count",
"columns",
"rows",
"x",
"y",
"z"
})
local NO_DATA = {
tables = __TS__New(Map),
sources = __TS__New(Map)
}
local MAX_CELLS = 20000
local MAX_VALUES = 1000000
local function readEach(self, block, scope, data)
local each = propertyOf(nil, block, "each")
if not each then
return nil
end
if each.type ~= "each" then
fail(nil, scope, "each is written as 'each: row in table'")
end
if __TS__ArraySome(
{"columns", "rows", "count"},
function(____, key) return propertyOf(nil, block, key) end
) then
fail(nil, scope, "each makes one cell for every row, so columns, rows and count cannot stand beside it")
end
local kind = data.sources:get(each.source)
if not __t(nil, kind) then
fail(nil, scope, ("each names " .. each.source) .. ", which is not a DataSource of this document")
end
if kind == "record" then
fail(nil, scope, each.source .. " is a record and has no rows to run over")
end
if CELL_NAMES:has(each.row) or scope.params:has(each.row) or data.sources:has(each.row) then
fail(nil, scope, ("a row cannot be called " .. each.row) .. ", as that name is taken")
end
return {
row = each.row,
rows = data.tables:get(each.source) or ({})
}
end
local function readGrid(self, block, scope, data)
local each = readEach(nil, block, scope, data)
local ____each_2
if each then
____each_2 = #each.rows
else
local ____opt_0 = numbersOf(nil, scope, block, "count")
____each_2 = ____opt_0 and ____opt_0[1]
end
local count = ____each_2
local ____each_6
if each then
____each_6 = #each.rows
else
local ____count_5 = count
if ____count_5 == nil then
local ____opt_3 = numbersOf(nil, scope, block, "columns")
____count_5 = ____opt_3 and ____opt_3[1]
end
____each_6 = math.max(
1,
math.floor(____count_5 or 1)
)
end
local columns = ____each_6
local ____temp_9
if count == nil then
local ____opt_7 = numbersOf(nil, scope, block, "rows")
____temp_9 = math.max(
1,
math.floor(____opt_7 and ____opt_7[1] or 1)
)
else
____temp_9 = 1
end
local rows = ____temp_9
if columns * rows > MAX_CELLS then
fail(
nil,
scope,
(tostring(columns * rows) .. " cells are too many, the limit is ") .. tostring(MAX_CELLS)
)
end
local stepX, stepY = table.unpack(
numbersOf(nil, scope, block, "step") or ({}),
1,
2
)
if stepX == nil then
stepX = 0
end
if stepY == nil then
stepY = stepX
end
local originX, originY = table.unpack(
numbersOf(nil, scope, block, "origin") or ({}),
1,
2
)
if originX == nil then
originX = 0
end
if originY == nil then
originY = 0
end
local order = propertyOf(nil, block, "sequence") or propertyOf(nil, block, "order")
local templates = __TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and ({entry.block}) or ({}) end
)
if __TS__ArraySome(
templates,
function(____, template) return template.kind == "Repeat" end
) then
fail(nil, scope, "a Repeat cannot hold another Repeat")
end
if columns * rows * math.max(1, #templates) > MAX_VALUES then
fail(nil, scope, "too many blocks")
end
local ____columns_18 = columns
local ____rows_19 = rows
local ____temp_20 = {stepX, stepY}
local ____temp_21 = {originX, originY}
local ____opt_10 = numbersOf(nil, scope, block, "seed")
local ____temp_22 = ____opt_10 and ____opt_10[1] or 0
local ____opt_12 = numbersOf(nil, scope, block, "jitter")
local ____temp_23 = ____opt_12 and ____opt_12[1] or 0
local ____opt_14 = numbersOf(nil, scope, block, "chance")
return {
columns = ____columns_18,
rows = ____rows_19,
step = ____temp_20,
origin = ____temp_21,
seed = ____temp_22,
jitter = ____temp_23,
chance = ____opt_14 and ____opt_14[1] or 1,
diagonal = (order and order.type) == "ident" and order.segments[1] == "diagonal",
condition = propertyOf(nil, block, "where"),
helpers = helpersOf(nil, block, scope, templates),
templates = templates,
each = each
}
end
local function cellsOf(self, grid)
local cells = {}
do
local row = 0
while row < grid.rows do
do
local col = 0
while col < grid.columns do
cells[#cells + 1] = {col, row}
col = col + 1
end
end
row = row + 1
end
end
return grid.diagonal and __sort(
nil,
cells,
function(____, a, b) return __lor(
nil,
a[1] + a[2] - (b[1] + b[2]),
function() return a[1] - b[1] end
) end
) or cells
end
local function enterCell(self, scope, grid, col, row)
local index = row * grid.columns + col
scope.random = __TS__New(
Random,
__xor(
nil,
__imul(nil, grid.seed + 1, 2654435761),
__imul(nil, index + 1, 2246822507)
)
)
if grid.chance < 1 and scope.random:next() >= grid.chance then
return false
end
local function spread()
return grid.jitter > 0 and (scope.random:next() * 2 - 1) * grid.jitter or 0
end
scope.vars = __TS__New(
Map,
{
{"col", col},
{"row", row},
{"index", index},
{"count", grid.columns * grid.rows},
{"columns", grid.columns},
{"rows", grid.rows},
{
"x",
round(
nil,
grid.origin[1] + col * grid.step[1] + spread(nil)
)
},
{
"y",
round(
nil,
grid.origin[2] + row * grid.step[2] + spread(nil)
)
}
}
)
scope.vars:set(
"z",
scope.vars:get("y")
)
local ____opt_29 = grid.each
for ____, ____value in ipairs(__TS__ObjectEntries(____opt_29 and ____opt_29.rows[index + 1] or ({}))) do
local field = ____value[1]
local value = ____value[2]
if type(value) == "number" or type(value) == "string" or type(value) == "boolean" then
local ____self_27 = scope.vars
local ____self_27_set_28 = ____self_27.set
local ____opt_25 = grid.each
____self_27_set_28(
____self_27,
(tostring(____opt_25 and ____opt_25.row) .. ".") .. field,
value
)
end
end
return true
end
local function nameHelpers(self, scope, helpers)
for ____, helper in ipairs(helpers) do
local value = resolveValue(nil, scope, helper.value)
if value.type == "number" or value.type == "string" then
scope.vars:set(helper.key, value.value)
elseif value.type == "ident" then
local word = table.unpack(value.segments, 1, 1)
scope.vars:set(
helper.key,
word == "true" and 1 or (word == "false" and 0 or table.concat(value.segments, "."))
)
else
fail(nil, scope, helper.key .. " needs a number")
end
end
end
local function keepsCell(self, scope, condition)
if condition == nil then
return true
end
if condition.type == "expr" then
return Boolean(
nil,
__TS__ArrayMap(
condition.items,
function(____, item) return evaluate(nil, scope, item) end
)[1]
)
end
local value = resolveValue(nil, scope, condition)
if value.type == "number" then
return value.value ~= 0
end
if value.type == "ident" and #value.segments == 1 and (value.segments[1] == "true" or value.segments[1] == "false") then
return value.segments[1] == "true"
end
fail(nil, scope, "where needs true or false")
end
local function expandRepeat(self, block, params, data, inScene)
local scope = {
vars = __TS__New(Map),
params = params,
random = __TS__New(Random, 0),
label = "Repeat " .. block.name
}
local ____inScene_31
if inScene then
____inScene_31 = placementOf(nil, scope, block)
else
____inScene_31 = nil
end
local placement = ____inScene_31
local grid = readGrid(nil, block, scope, data)
local made = {}
local ____local = namesIn(nil, grid.templates)
for ____, ____value in ipairs(cellsOf(nil, grid)) do
local col = ____value[1]
local row = ____value[2]
do
if not enterCell(
nil,
scope,
grid,
col,
row
) then
goto __continue53
end
nameHelpers(nil, scope, grid.helpers)
if not keepsCell(nil, scope, grid.condition) then
goto __continue53
end
local suffix = grid.rows == 1 and "_" .. tostring(col) or (("_" .. tostring(col)) .. "_") .. tostring(row)
for ____, template in ipairs(grid.templates) do
made[#made + 1] = instance(
nil,
scope,
template,
function(____, name) return name .. suffix end,
____local
)
end
end
::__continue53::
end
return placedWithin(nil, made, placement)
end
function ____exports.expandRepeatBlocks(self, blocks, params, data, inScene)
if params == nil then
params = __TS__New(Map)
end
if data == nil then
data = NO_DATA
end
if inScene == nil then
inScene = false
end
return __TS__ArrayFlatMap(
blocks,
function(____, block)
if block.kind == "Repeat" then
return expandRepeat(
nil,
block,
params,
data,
inScene
)
end
if block.kind == "Template" or not __TS__ArraySome(
block.entries,
function(____, entry) return entry.type == "block" end
) then
return {block}
end
return {__TS__ObjectAssign(
{},
block,
{entries = __TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and __TS__ArrayMap(
____exports.expandRepeatBlocks(
nil,
{entry.block},
params,
data,
inScene or block.kind == "Scene"
),
function(____, child) return {type = "block", block = child} end
) or ({entry}) end
)}
)}
end
)
end
function ____exports.hasRepeats(self, blocks)
return __TS__ArraySome(
blocks,
function(____, block) return block.kind == "Repeat" or __TS__ArraySome(
block.entries,
function(____, entry) return entry.type == "block" and ____exports.hasRepeats(nil, {entry.block}) end
) end
)
end
function ____exports.eachSources(self, blocks)
local names = __TS__New(Set)
local visit
visit = function(____, block)
for ____, entry in ipairs(block.entries) do
if entry.type == "block" then
visit(nil, entry.block)
elseif block.kind == "Repeat" and entry.type == "property" and entry.property.value.type == "each" then
names:add(entry.property.value.source)
end
end
end
__TS__ArrayForEach(blocks, visit)
return names
end
function ____exports.repeatNotes(self, blocks, inScene)
if inScene == nil then
inScene = false
end
return __TS__ArrayFlatMap(
blocks,
function(____, block)
local own = {}
if block.kind == "Repeat" then
if propertyOf(nil, block, "order") then
own[#own + 1] = {code = "repeat-order", owner = block.name, message = ("Repeat '" .. block.name) .. "': order is written sequence now, as order is the stacking of a layout. It is still read."}
end
local cells = __json(
nil,
__TS__ArrayFilter(
block.entries,
function(____, entry) return entry.type == "block" end
)
)
if inScene and __TS__StringIncludes(cells, "\"path\":[\"y\"]") then
own[#own + 1] = {code = "repeat-y-in-scene", owner = block.name, message = ("Repeat '" .. block.name) .. "' lies in a Scene, where y is up: its rows are named z there. y is still read."}
end
end
local children = __TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and ({entry.block}) or ({}) end
)
local ____array_32 = __TS__SparseArrayNew(table.unpack(own))
__TS__SparseArrayPush(
____array_32,
table.unpack(____exports.repeatNotes(nil, children, inScene or block.kind == "Scene"))
)
return {__TS__SparseArraySpread(____array_32)}
end
)
end
return ____exports
end,
["core.sflLanguage.expansion.template"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__StringCharCodeAt = ____lualib.__TS__StringCharCodeAt
local Map = ____lualib.Map
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__Class = ____lualib.__TS__Class
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local hashOf, expandUse, expandIn, MAX_DEPTH, OWN, PLACE
local ______shims = require("core.__shims")
local __imul = ______shims.__imul
local __shr = ______shims.__shr
local __xor = ______shims.__xor
local ____evaluation = require("core.sflLanguage.expansion.evaluation")
local resolveValue = ____evaluation.resolveValue
local ____instance = require("core.sflLanguage.expansion.instance")
local instance = ____instance.instance
local namesIn = ____instance.namesIn
local ____placement = require("core.sflLanguage.expansion.placement")
local placedWithin = ____placement.placedWithin
local placementOf = ____placement.placementOf
local within = ____placement.within
local ____properties = require("core.sflLanguage.expansion.properties")
local numbersOf = ____properties.numbersOf
local ____random = require("core.sflLanguage.expansion.random")
local Random = ____random.Random
local ____scope = require("core.sflLanguage.expansion.scope")
local fail = ____scope.fail
function hashOf(self, text)
local hash = 2166136261
do
local index = 0
while index < #text do
hash = __imul(
nil,
__xor(
nil,
hash,
__TS__StringCharCodeAt(text, index)
),
16777619
)
index = index + 1
end
end
return __shr(nil, hash, 0)
end
function expandUse(self, use, templates, depth, budget, params)
local scope = {
vars = __TS__New(Map),
params = params,
random = __TS__New(Random, 0),
label = "Use " .. use.name
}
if depth > MAX_DEPTH then
fail(
nil,
scope,
("Templates are nested more than " .. tostring(MAX_DEPTH)) .. " deep, which may be a Template that uses itself"
)
end
if #use.composition ~= 1 then
fail(nil, scope, "a Use names one Template, as in Use oak : tree")
end
local template = templates:get(use.composition[1])
if not template then
fail(nil, scope, "there is no Template " .. use.composition[1])
end
local ____opt_0 = numbersOf(nil, scope, use, "seed")
local seed = ____opt_0 and ____opt_0[1] or 0
scope.random = __TS__New(
Random,
__xor(
nil,
__imul(nil, seed + 1, 2654435761),
hashOf(nil, use.name)
)
)
local x, y = table.unpack(
numbersOf(nil, scope, use, "at") or ({}),
1,
2
)
if x == nil then
x = 0
end
if y == nil then
y = 0
end
scope.vars:set("x", x)
scope.vars:set("y", y)
local own = placementOf(nil, scope, use)
local placement = use["local"] and own and within(nil, use["local"], own) or (use["local"] or own)
local given = __TS__New(
Map,
__TS__ArrayFlatMap(
use.entries,
function(____, entry) return entry.type == "property" and not OWN:has(entry.property.key) and ({{entry.property.key, entry.property.value}}) or ({}) end
)
)
for ____, entry in ipairs(template.entries) do
do
if entry.type ~= "property" then
goto __continue21
end
local ____entry_property_2 = entry.property
local key = ____entry_property_2.key
local value = ____entry_property_2.value
if PLACE:has(key) or OWN:has(key) then
fail(nil, scope, key .. " is the name of something a Use sets, so it cannot be a parameter")
end
local chosen = resolveValue(
nil,
scope,
given:get(key) or value
)
given:delete(key)
if chosen.type == "number" or chosen.type == "string" then
scope.vars:set(key, chosen.value)
elseif chosen.type == "ident" then
scope.vars:set(
key,
chosen.segments[1] == "true" and 1 or (chosen.segments[1] == "false" and 0 or table.concat(chosen.segments, "."))
)
else
fail(nil, scope, key .. " needs a number, a text or a name")
end
end
::__continue21::
end
local unknown = ({__TS__Spread(given:keys())})[1]
if unknown ~= nil then
fail(nil, scope, (("Template " .. template.name) .. " has no parameter ") .. unknown)
end
local parts = __TS__ArrayFlatMap(
template.entries,
function(____, entry) return entry.type == "block" and ({entry.block}) or ({}) end
)
local ____local = namesIn(nil, parts)
local made = __TS__ArrayMap(
parts,
function(____, part) return instance(
nil,
scope,
part,
function(____, name) return (use.name .. "_") .. name end,
____local
) end
)
budget:take(#made, scope)
local expanded = expandIn(
nil,
made,
templates,
depth + 1,
budget,
params
)
return placedWithin(nil, expanded, placement)
end
function expandIn(self, blocks, templates, depth, budget, params)
return __TS__ArrayFlatMap(
blocks,
function(____, block)
if block.kind == "Template" then
return {}
end
if block.kind == "Use" then
return expandUse(
nil,
block,
templates,
depth,
budget,
params
)
end
if not __TS__ArraySome(
block.entries,
function(____, entry) return entry.type == "block" end
) then
return {block}
end
return {__TS__ObjectAssign(
{},
block,
{entries = __TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and __TS__ArrayMap(
expandIn(
nil,
{entry.block},
templates,
depth,
budget,
params
),
function(____, child) return {type = "block", block = child} end
) or ({entry}) end
)}
)}
end
)
end
MAX_DEPTH = 4
local MAX_BLOCKS = 100000
OWN = __TS__New(Set, {"at", "seed"})
PLACE = __TS__New(Set, {"x", "y"})
local function collect(self, blocks, into)
for ____, block in ipairs(blocks) do
if block.kind == "Template" then
if into:has(block.name) then
error(
__TS__New(Error, ("Template " .. block.name) .. ": there is another Template of this name"),
0
)
end
if __TS__ArraySome(
block.entries,
function(____, entry) return entry.type == "block" and entry.block.kind == "Repeat" end
) then
error(
__TS__New(Error, ("Template " .. block.name) .. ": a Template cannot hold a Repeat, a Repeat can hold a Use"),
0
)
end
into:set(block.name, block)
end
collect(
nil,
__TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and ({entry.block}) or ({}) end
),
into
)
end
end
local BlockBudget = __TS__Class()
BlockBudget.name = "BlockBudget"
function BlockBudget.prototype.____constructor(self)
self.made = 0
end
function BlockBudget.prototype.take(self, count, scope)
self.made = self.made + count
if self.made > MAX_BLOCKS then
fail(nil, scope, "too many blocks")
end
end
function ____exports.hasTemplates(self, blocks)
return __TS__ArraySome(
blocks,
function(____, block) return block.kind == "Template" or block.kind == "Use" or __TS__ArraySome(
block.entries,
function(____, entry) return entry.type == "block" and ____exports.hasTemplates(nil, {entry.block}) end
) end
)
end
function ____exports.expandUses(self, blocks, params)
if params == nil then
params = __TS__New(Map)
end
local templates = __TS__New(Map)
collect(nil, blocks, templates)
return expandIn(
nil,
blocks,
templates,
0,
__TS__New(BlockBudget),
params
)
end
return ____exports
end,
["core.sflLanguage.expansion.expandDocument"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySome = ____lualib.__TS__ArraySome
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local __TS__New = ____lualib.__TS__New
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local Map = ____lualib.Map
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local checkNoComputed, parameterBlocks, withoutParameters, readParameters, resolveWithParameters, dataSources, expandCopies, isComputed
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____evaluation = require("core.sflLanguage.expansion.evaluation")
local resolveValue = ____evaluation.resolveValue
local ____instance = require("core.sflLanguage.expansion.instance")
local instance = ____instance.instance
local ____placement = require("core.sflLanguage.expansion.placement")
local hasPlacements = ____placement.hasPlacements
local withPlacements = ____placement.withPlacements
local ____random = require("core.sflLanguage.expansion.random")
local Random = ____random.Random
local ____repeat = require("core.sflLanguage.expansion.repeat")
local expandRepeatBlocks = ____repeat.expandRepeatBlocks
local hasRepeats = ____repeat.hasRepeats
local repeatNotes = ____repeat.repeatNotes
local ____scope = require("core.sflLanguage.expansion.scope")
local fail = ____scope.fail
local ____template = require("core.sflLanguage.expansion.template")
local expandUses = ____template.expandUses
local hasTemplates = ____template.hasTemplates
function checkNoComputed(self, blocks)
for ____, block in ipairs(blocks) do
for ____, entry in ipairs(block.entries) do
local properties = entry.type == "property" and ({entry.property}) or (entry.type == "layout" and entry.layout.properties or (entry.type == "style" and entry.style.properties or ({})))
for ____, property in ipairs(properties) do
if isComputed(nil, property.value) then
error(
__TS__New(Error, ((((block.kind .. " ") .. block.name) .. ": ") .. property.key) .. " is computed, and only a Repeat can work out a computed value"),
0
)
end
end
if entry.type == "block" then
checkNoComputed(nil, {entry.block})
end
end
end
end
function parameterBlocks(self, blocks)
return __TS__ArrayFlatMap(
blocks,
function(____, block)
local ____array_0 = __TS__SparseArrayNew(table.unpack(block.kind == "Parameters" and ({block}) or ({})))
__TS__SparseArrayPush(
____array_0,
table.unpack(parameterBlocks(
nil,
__TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and ({entry.block}) or ({}) end
)
))
)
return {__TS__SparseArraySpread(____array_0)}
end
)
end
function withoutParameters(self, blocks)
return __TS__ArrayFlatMap(
blocks,
function(____, block) return block.kind == "Parameters" and ({}) or ({__TS__ObjectAssign(
{},
block,
{entries = __TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type ~= "block" and ({entry}) or (entry.block.kind == "Parameters" and ({}) or ({{
type = "block",
block = withoutParameters(nil, {entry.block})[1]
}})) end
)}
)}) end
)
end
function readParameters(self, blocks)
local params = __TS__New(Map)
for ____, block in ipairs(parameterBlocks(nil, blocks)) do
local scope = {
vars = __TS__New(Map),
params = params,
random = __TS__New(Random, 0),
label = "Parameters " .. block.name
}
for ____, entry in ipairs(block.entries) do
if entry.type ~= "property" then
fail(nil, scope, "Parameters hold only properties")
end
local value = resolveValue(nil, scope, entry.property.value)
if value.type == "number" or value.type == "string" then
params:set(entry.property.key, value.value)
elseif value.type == "ident" then
params:set(
entry.property.key,
table.concat(value.segments, ".")
)
else
fail(nil, scope, entry.property.key .. " needs a number, a text or a name")
end
end
end
return params
end
function resolveWithParameters(self, blocks, params)
return __TS__ArrayMap(
blocks,
function(____, block) return instance(
nil,
{
vars = __TS__New(Map),
params = params,
random = __TS__New(Random, 0),
label = (block.kind .. " ") .. block.name
},
block,
function(____, name) return name end
) end
)
end
function dataSources(self, blocks)
local found = __TS__New(Map)
local visit
visit = function(____, block)
if block.kind == "DataSource" then
local mode = __TS__ArrayFind(
block.entries,
function(____, entry) return entry.type == "property" and entry.property.key == "mode" end
)
local record = (mode and mode.type) == "property" and mode.property.value.type == "ident" and mode.property.value.segments[1] == "record"
found:set(block.name, record and "record" or "table")
end
for ____, entry in ipairs(block.entries) do
if entry.type == "block" then
visit(nil, entry.block)
end
end
end
__TS__ArrayForEach(blocks, visit)
return found
end
function expandCopies(self, doc, tables)
local params = readParameters(nil, doc.blocks)
local repeats = hasRepeats(nil, doc.blocks)
if not repeats and not hasTemplates(nil, doc.blocks) and params.size == 0 and #parameterBlocks(nil, doc.blocks) == 0 then
checkNoComputed(nil, doc.blocks)
return doc
end
local source = withoutParameters(nil, doc.blocks)
local data = {
tables = tables,
sources = dataSources(nil, doc.blocks)
}
local expanded = expandUses(
nil,
repeats and expandRepeatBlocks(nil, source, params, data) or source,
params
)
local blocks = params.size > 0 and resolveWithParameters(nil, expanded, params) or expanded
checkNoComputed(nil, blocks)
return __TS__ObjectAssign({}, doc, {blocks = blocks})
end
isComputed = function(____, value) return value.type == "expr" or value.type == "list" and __TS__ArraySome(value.values, isComputed) end
local function withMirrors(self, blocks)
return __TS__ArrayFlatMap(
blocks,
function(____, block)
local inner = __TS__ObjectAssign(
{},
block,
{entries = __TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and __TS__ArrayMap(
withMirrors(nil, {entry.block}),
function(____, child) return {type = "block", block = child} end
) or ({entry}) end
)}
)
local mirror = block.kind == "Solid" and __TS__ArrayFind(
block.entries,
function(____, entry) return entry.type == "property" and entry.property.key == "mirror" end
)
if not mirror or mirror.type ~= "property" then
return {inner}
end
local plane = mirror.property.value
local twin = __TS__ObjectAssign(
{},
inner,
{
name = block.name .. "_mirror",
entries = __TS__ArrayFilter(
inner.entries,
function(____, entry) return entry ~= mirror end
)
},
plane.type == "ident" and ({mirrored = table.concat(plane.segments, ".")}) or (plane.type == "string" and ({mirrored = plane.value}) or ({}))
)
return {inner, twin}
end
)
end
local hasMirrors
hasMirrors = function(____, blocks) return __TS__ArraySome(
blocks,
function(____, block) return block.kind == "Solid" and __TS__ArraySome(
block.entries,
function(____, entry) return entry.type == "property" and entry.property.key == "mirror" end
) or hasMirrors(
nil,
__TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and ({entry.block}) or ({}) end
)
) end
) end
function ____exports.expandDocument(self, doc, tables)
if tables == nil then
tables = __TS__New(Map)
end
local notes = repeatNotes(nil, doc.blocks)
local expanded = __TS__ObjectAssign(
{},
expandCopies(nil, doc, tables),
__t(nil, #notes) and ({notes = notes}) or ({})
)
local mirrored = hasMirrors(nil, expanded.blocks) and __TS__ObjectAssign(
{},
expanded,
{blocks = withMirrors(nil, expanded.blocks)}
) or expanded
return hasPlacements(nil, mirrored.blocks) and __TS__ObjectAssign(
{},
mirrored,
{blocks = withPlacements(nil, mirrored.blocks)}
) or mirrored
end
return ____exports
end,
["core.sflLanguage.expansion.parameterValues"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
function ____exports.withParameterValues(self, doc, values)
local change
change = function(____, blocks) return __TS__ArrayMap(
blocks,
function(____, block) return __TS__ObjectAssign(
{},
block,
{entries = __TS__ArrayMap(
block.entries,
function(____, entry)
if entry.type == "block" then
return __TS__ObjectAssign(
{},
entry,
{block = change(nil, {entry.block})[1]}
)
end
if block.kind ~= "Parameters" or entry.type ~= "property" or entry.property.value.type ~= "number" then
return entry
end
local value = values:get((block.name .. ".") .. entry.property.key)
return (value == nil or not __isFinite(nil, value)) and entry or __TS__ObjectAssign(
{},
entry,
{property = __TS__ObjectAssign({}, entry.property, {value = {type = "number", value = value}})}
)
end
)}
) end
) end
return __TS__ObjectAssign(
{},
doc,
{blocks = change(nil, doc.blocks)}
)
end
return ____exports
end,
["core.sflLanguage.expansion.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____expandDocument = require("core.sflLanguage.expansion.expandDocument")
____exports.expandDocument = ____expandDocument.expandDocument
end
do
local ____parameterValues = require("core.sflLanguage.expansion.parameterValues")
____exports.withParameterValues = ____parameterValues.withParameterValues
end
do
local ____repeat = require("core.sflLanguage.expansion.repeat")
____exports.eachSources = ____repeat.eachSources
end
return ____exports
end,
["core.model.geometry.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.shadow.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.shadow.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.isometricObject.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.isometricObject.geometry"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local ____exports = {}
function ____exports.isometricFaces(self, object)
local ____object_0 = object
local x = ____object_0.x
local y = ____object_0.y
local width = math.max(0, object.width)
local height = math.max(0, object.height)
local depth = math.max(0, object.depth)
local apex = {x = x + depth * ____exports.AXIS_COS, y = y}
local toRight = {x = width * ____exports.AXIS_COS, y = width * ____exports.AXIS_SIN}
local toLeft = {x = -depth * ____exports.AXIS_COS, y = depth * ____exports.AXIS_SIN}
local down = {x = 0, y = height}
local right = {x = apex.x + toRight.x, y = apex.y + toRight.y}
local left = {x = apex.x + toLeft.x, y = apex.y + toLeft.y}
local center = {x = apex.x + toRight.x + toLeft.x, y = apex.y + toRight.y + toLeft.y}
local apexDown = {x = apex.x + down.x, y = apex.y + down.y}
local bottom = {x = center.x + down.x, y = center.y + down.y}
local bottomLeft = {x = left.x + down.x, y = left.y + down.y}
local bottomRight = {x = right.x + down.x, y = right.y + down.y}
return {
top = {apex, right, center, left},
bottom = {apexDown, bottomRight, bottom, bottomLeft},
front = {left, center, bottom, bottomLeft},
back = {apex, right, bottomRight, apexDown},
right = {center, right, bottomRight, bottom},
left = {apex, left, bottomLeft, apexDown}
}
end
____exports.VISIBLE_ISOMETRIC_FACES = __TS__New(Set, {"top", "front", "right"})
local AXIS_ANGLE = math.pi / 6
____exports.AXIS_COS = math.cos(AXIS_ANGLE)
____exports.AXIS_SIN = math.sin(AXIS_ANGLE)
function ____exports.isometricBounds(self, object)
local width = math.max(0, object.width)
local height = math.max(0, object.height)
local depth = math.max(0, object.depth)
return {x = object.x, y = object.y, width = (width + depth) * ____exports.AXIS_COS, height = height + (width + depth) * ____exports.AXIS_SIN}
end
function ____exports.isometricTopFaceCenter(self, object)
local width = math.max(0, object.width)
local depth = math.max(0, object.depth)
return {x = object.x + (width + depth) * ____exports.AXIS_COS / 2, y = object.y + (width + depth) * ____exports.AXIS_SIN / 2}
end
local function faceCenter(self, corners)
return {x = (corners[1].x + corners[2].x + corners[3].x + corners[4].x) / 4, y = (corners[1].y + corners[2].y + corners[3].y + corners[4].y) / 4}
end
function ____exports.isometricFaceCenter(self, object, face)
return faceCenter(
nil,
____exports.isometricFaces(nil, object)[face]
)
end
return ____exports
end,
["core.model.isometricObject.footprint"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __isFinite = ______shims.__isFinite
local __sort = ______shims.__sort
local ____geometry = require("core.model.isometricObject.geometry")
local AXIS_COS = ____geometry.AXIS_COS
local AXIS_SIN = ____geometry.AXIS_SIN
local function signedArea(self, points)
local sum = 0
do
local i = 0
while i < #points do
local x1, y1 = table.unpack(points[i + 1], 1, 2)
local x2, y2 = table.unpack(points[(i + 1) % #points + 1], 1, 2)
sum = sum + (x1 * y2 - x2 * y1)
i = i + 1
end
end
return sum / 2
end
function ____exports.cleanFootprint(self, points)
local clean = __TS__ArrayFilter(
points or ({}),
function(____, point) return __TS__ArrayIsArray(point) and __isFinite(nil, point[1]) and __isFinite(nil, point[2]) end
)
local unique = __TS__ArrayFilter(
clean,
function(____, point, index)
local next = clean[(index + 1) % #clean + 1]
return point[1] ~= next[1] or point[2] ~= next[2]
end
)
return #unique >= 3 and unique or ({})
end
local ARC_STEP = math.pi / 12
function ____exports.roundFootprint(self, points, radius, width, depth)
if not (radius > 0) or width <= 0 or depth <= 0 then
return {table.unpack(points)}
end
local world = __TS__ArrayMap(
points,
function(____, ____bindingPattern0)
local v
local u
u = ____bindingPattern0[1]
v = ____bindingPattern0[2]
return {x = u * width, y = v * depth}
end
)
local rounded = {}
do
local i = 0
while i < #world do
do
local here = world[i + 1]
local before = world[(i - 1 + #world) % #world + 1]
local after = world[(i + 1) % #world + 1]
local a = {x = before.x - here.x, y = before.y - here.y}
local b = {x = after.x - here.x, y = after.y - here.y}
local lengthA = __hypot(nil, a.x, a.y)
local lengthB = __hypot(nil, b.x, b.y)
local cos = (a.x * b.x + a.y * b.y) / (lengthA * lengthB)
local angle = math.acos(math.max(
-1,
math.min(1, cos)
))
if not __isFinite(nil, angle) or angle < 0.001 or math.pi - angle < 0.001 then
rounded[#rounded + 1] = points[i + 1]
goto __continue12
end
local reach = math.min(
radius / math.tan(angle / 2),
math.min(lengthA, lengthB) / 2
)
local effective = reach * math.tan(angle / 2)
local unitA = {x = a.x / lengthA, y = a.y / lengthA}
local unitB = {x = b.x / lengthB, y = b.y / lengthB}
local from = {x = here.x + unitA.x * reach, y = here.y + unitA.y * reach}
local to = {x = here.x + unitB.x * reach, y = here.y + unitB.y * reach}
local bisector = {x = unitA.x + unitB.x, y = unitA.y + unitB.y}
local bisectorLength = __hypot(nil, bisector.x, bisector.y)
local centerDistance = effective / math.sin(angle / 2)
local center = {x = here.x + bisector.x / bisectorLength * centerDistance, y = here.y + bisector.y / bisectorLength * centerDistance}
local start = math.atan(from.y - center.y, from.x - center.x)
local sweep = math.atan(to.y - center.y, to.x - center.x) - start
sweep = sweep - 2 * math.pi * math.floor(sweep / (2 * math.pi) + 0.5)
local steps = math.max(
2,
math.ceil(math.abs(sweep) / ARC_STEP)
)
do
local step = 0
while step <= steps do
local t = start + sweep * step / steps
rounded[#rounded + 1] = {
(center.x + effective * math.cos(t)) / width,
(center.y + effective * math.sin(t)) / depth
}
step = step + 1
end
end
end
::__continue12::
i = i + 1
end
end
return rounded
end
function ____exports.extrudeFootprint(self, frame, footprint, cornerRadius)
if cornerRadius == nil then
cornerRadius = 0
end
local width = math.max(0, frame.width)
local depth = math.max(0, frame.depth)
local height = math.max(0, frame.height)
local points = ____exports.roundFootprint(
nil,
____exports.cleanFootprint(nil, footprint),
cornerRadius,
width,
depth
)
local apexX = frame.x + depth * AXIS_COS
local function project(____, ____bindingPattern0, z)
local v
local u
u = ____bindingPattern0[1]
v = ____bindingPattern0[2]
return {x = apexX + (u * width - v * depth) * AXIS_COS, y = frame.y + (u * width + v * depth) * AXIS_SIN + z}
end
local top = __TS__ArrayMap(
points,
function(____, point) return project(nil, point, 0) end
)
local turn = signedArea(nil, points) >= 0 and 1 or -1
local edges = __TS__ArrayMap(
points,
function(____, from, i)
local to = points[(i + 1) % #points + 1]
local edgeU = (to[1] - from[1]) * width
local edgeV = (to[2] - from[2]) * depth
local length = __hypot(nil, edgeU, edgeV)
local normalU = length == 0 and 0 or edgeV / length * turn
local normalV = length == 0 and 0 or -edgeU / length * turn
return {
from = from,
to = to,
length = length,
normalU = normalU,
normalV = normalV,
visible = length > 0 and normalU + normalV > 1e-9
}
end
)
local function sameWay(____, a, b)
return a.visible and b.visible and a.normalU * b.normalU + a.normalV * b.normalV > math.cos(0.5)
end
local sides = {}
__TS__ArrayForEach(
edges,
function(____, edge, i)
if not edge.visible then
return
end
local before = edges[(i - 1 + #edges) % #edges + 1]
local after = edges[(i + 1) % #edges + 1]
local ____edge_0 = edge
local from = ____edge_0.from
local to = ____edge_0.to
sides[#sides + 1] = {
points = {
project(nil, from, 0),
project(nil, to, 0),
project(nil, to, height),
project(nil, from, height)
},
light = 0.72 + 0.28 * math.max(
0,
math.min(
1,
edge.normalV / (math.abs(edge.normalU) + math.abs(edge.normalV))
)
),
depth = (from[1] + to[1]) / 2 + (from[2] + to[2]) / 2,
smoothStart = sameWay(nil, before, edge),
smoothEnd = sameWay(nil, edge, after)
}
end
)
__sort(
nil,
sides,
function(____, a, b) return a.depth - b.depth end
)
return {top = top, sides = sides}
end
return ____exports
end,
["core.model.color.conversion"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ParseInt = ____lualib.__TS__ParseInt
local __TS__StringTrim = ____lualib.__TS__StringTrim
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__NumberToString = ____lualib.__TS__NumberToString
local ____exports = {}
local ______shims = require("core.__shims")
local __and = ______shims.__and
local __exec = ______shims.__exec
local __re = ______shims.__re
local __sar = ______shims.__sar
____exports.hexToRgb = function(____, hex)
local result = __exec(
nil,
__re(nil, "^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})?$", "i"),
hex
)
if not result then
return {r = 255, g = 255, b = 255, a = 1}
end
return {
r = __TS__ParseInt(result[2], 16),
g = __TS__ParseInt(result[3], 16),
b = __TS__ParseInt(result[4], 16),
a = result[5] == nil and 1 or __TS__ParseInt(result[5], 16) / 255
}
end
____exports.parseHexRgb = function(____, value)
local match = __exec(
nil,
__re(nil, "^#?([0-9a-f]{3}|[0-9a-f]{6})$", "i"),
__TS__StringTrim(value)
)
if not match then
return nil
end
local digits = #match[2] == 3 and table.concat(
__TS__ArrayMap(
{__TS__Spread(match[2])},
function(____, digit) return digit .. digit end
),
""
) or match[2]
local n = __TS__ParseInt(digits, 16)
return {
__and(
nil,
__sar(nil, n, 16),
255
),
__and(
nil,
__sar(nil, n, 8),
255
),
__and(nil, n, 255)
}
end
____exports.rgbToHex = function(____, r, g, b, a)
local function channel(____, x)
local hex = __TS__NumberToString(
math.max(
0,
math.min(
255,
math.floor(x + 0.5)
)
),
16
)
return #hex == 1 and "0" .. hex or hex
end
local alphaChannel = (a == nil or a >= 1) and "" or channel(nil, a * 255)
return ((("#" .. channel(nil, r)) .. channel(nil, g)) .. channel(nil, b)) .. alphaChannel
end
____exports.hsvToRgb = function(____, h, s, v)
local c = v * s
local x = c * (1 - math.abs(h / 60 % 2 - 1))
local m = v - c
local r = 0
local g = 0
local b = 0
if h >= 0 and h < 60 then
r = c
g = x
b = 0
elseif h >= 60 and h < 120 then
r = x
g = c
b = 0
elseif h >= 120 and h < 180 then
r = 0
g = c
b = x
elseif h >= 180 and h < 240 then
r = 0
g = x
b = c
elseif h >= 240 and h < 300 then
r = x
g = 0
b = c
elseif h >= 300 and h < 360 then
r = c
g = 0
b = x
end
return {
r = math.floor((r + m) * 255 + 0.5),
g = math.floor((g + m) * 255 + 0.5),
b = math.floor((b + m) * 255 + 0.5)
}
end
____exports.rgbToHsv = function(____, r, g, b)
r = r / 255
g = g / 255
b = b / 255
local max = math.max(r, g, b)
local min = math.min(r, g, b)
local delta = max - min
local h = 0
if delta ~= 0 then
if max == r then
h = 60 * ((g - b) / delta % 6)
elseif max == g then
h = 60 * ((b - r) / delta + 2)
elseif max == b then
h = 60 * ((r - g) / delta + 4)
end
end
if h < 0 then
h = h + 360
end
local s = max == 0 and 0 or delta / max
local v = max
return {h = h, s = s, v = v}
end
return ____exports
end,
["core.model.color.interpolation"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __sort = ______shims.__sort
local ____conversion = require("core.model.color.conversion")
local hexToRgb = ____conversion.hexToRgb
local rgbToHex = ____conversion.rgbToHex
local function mixHexColors(self, start, ____end, ratio)
local startRgb = hexToRgb(nil, start)
local endRgb = hexToRgb(nil, ____end)
local startAlpha = startRgb.a or 1
local endAlpha = endRgb.a or 1
return rgbToHex(
nil,
math.floor(startRgb.r + (endRgb.r - startRgb.r) * ratio + 0.5),
math.floor(startRgb.g + (endRgb.g - startRgb.g) * ratio + 0.5),
math.floor(startRgb.b + (endRgb.b - startRgb.b) * ratio + 0.5),
startAlpha + (endAlpha - startAlpha) * ratio
)
end
function ____exports.interpolateHexColorStops(self, stops, position)
local sortedStops = __sort(
nil,
{table.unpack(stops)},
function(____, first, second) return first.position - second.position end
)
local first = sortedStops[1]
local last = sortedStops[#sortedStops]
if position <= first.position then
return first.color
end
if position >= last.position then
return last.color
end
do
local index = 0
while index < #sortedStops - 1 do
local start = sortedStops[index + 1]
local ____end = sortedStops[index + 1 + 1]
if position >= start.position and position <= ____end.position then
local range = ____end.position - start.position
local ratio = range == 0 and 0 or (position - start.position) / range
return mixHexColors(nil, start.color, ____end.color, ratio)
end
index = index + 1
end
end
return last.color
end
return ____exports
end,
["core.model.color.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.color.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____conversion = require("core.model.color.conversion")
____exports.hexToRgb = ____conversion.hexToRgb
____exports.hsvToRgb = ____conversion.hsvToRgb
____exports.parseHexRgb = ____conversion.parseHexRgb
____exports.rgbToHex = ____conversion.rgbToHex
____exports.rgbToHsv = ____conversion.rgbToHsv
end
do
local ____interpolation = require("core.model.color.interpolation")
____exports.interpolateHexColorStops = ____interpolation.interpolateHexColorStops
end
return ____exports
end,
["core.model.isometricObject.shading"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____color = require("core.model.color.index")
local parseHexRgb = ____color.parseHexRgb
local rgbToHex = ____color.rgbToHex
local function multiply(self, hex, factor)
local rgb = parseHexRgb(nil, hex)
if not rgb then
return hex
end
local r, g, b = table.unpack(rgb, 1, 3)
return rgbToHex(nil, r * factor, g * factor, b * factor)
end
function ____exports.shadeFill(self, fill, factor)
return multiply(nil, fill, factor)
end
function ____exports.deriveFaceFills(self, fill)
return {
topFill = fill,
frontFill = multiply(nil, fill, 0.95),
sideFill = multiply(nil, fill, 0.88)
}
end
return ____exports
end,
["core.model.isometricObject.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____footprint = require("core.model.isometricObject.footprint")
____exports.cleanFootprint = ____footprint.cleanFootprint
____exports.extrudeFootprint = ____footprint.extrudeFootprint
____exports.roundFootprint = ____footprint.roundFootprint
end
do
local ____geometry = require("core.model.isometricObject.geometry")
____exports.AXIS_COS = ____geometry.AXIS_COS
____exports.AXIS_SIN = ____geometry.AXIS_SIN
____exports.isometricBounds = ____geometry.isometricBounds
____exports.isometricFaceCenter = ____geometry.isometricFaceCenter
____exports.isometricFaces = ____geometry.isometricFaces
____exports.isometricTopFaceCenter = ____geometry.isometricTopFaceCenter
____exports.VISIBLE_ISOMETRIC_FACES = ____geometry.VISIBLE_ISOMETRIC_FACES
end
do
local ____shading = require("core.model.isometricObject.shading")
____exports.deriveFaceFills = ____shading.deriveFaceFills
____exports.shadeFill = ____shading.shadeFill
end
return ____exports
end,
["core.sflSemantic.ast.valueAccess"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
function ____exports.asString(self, value)
if not value then
return nil
end
if value.type == "string" then
return value.value
end
if value.type == "ident" then
return table.concat(value.segments, ".")
end
if value.type == "number" then
return tostring(value.value)
end
return nil
end
function ____exports.asNumber(self, value)
return (value and value.type) == "number" and value.value or nil
end
function ____exports.tupleValues(self, value)
return (value and value.type) == "tuple" and value.values or nil
end
function ____exports.listNumbers(self, value)
return (value and value.type) == "list" and __TS__ArrayFlatMap(
value.values,
function(____, item) return item.type == "number" and ({item.value}) or ({}) end
) or nil
end
return ____exports
end,
["core.model.shader.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.shader.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.dimension.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.isometric.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.mesh.index"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local NUMBERS = {
"opacity",
"roughness",
"metallic",
"transmission",
"ior",
"turn",
"height",
"intensity",
"ambient",
"softness"
}
local AXES = {
positionX = {"position", 0},
positionY = {"position", 1},
positionZ = {"position", 2},
rotationX = {"rotation", 0},
rotationY = {"rotation", 1},
rotationZ = {"rotation", 2},
scaleX = {"scale", 0},
scaleY = {"scale", 1},
scaleZ = {"scale", 2}
}
function ____exports.setMeshValue(self, mesh, written, value)
local property = written == "elevation" and "height" or written
local axis = AXES[property]
local number = __TS__ArrayFind(
NUMBERS,
function(____, name) return name == property end
)
local vector = axis and mesh[axis[1]]
if vector then
vector[axis[2] + 1] = value
elseif property == "scale" then
mesh.scale = {value, value, value}
elseif property == "color" then
mesh.color = value
elseif __t(nil, number) then
mesh[number] = value
end
end
____exports.DEFAULT_LIGHT = {
id = "light-default",
turn = 57.5,
height = 49,
intensity = 1,
ambient = 1
}
____exports.DEFAULT_ORBIT = {45, 27}
____exports.DEFAULT_MESH_SCENE = {
id = "mesh-world-default",
x = 0,
y = 0,
width = 800,
height = 600,
orbit = ____exports.DEFAULT_ORBIT,
shadow = false
}
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.mesh.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.path.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.swimlane.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.object"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.isChartObject(self, canvasObject)
return canvasObject.objectType == "chart" and canvasObject.chart ~= nil
end
return ____exports
end,
["core.model.chart.annotations"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.axis"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.category"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.bar"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.boxplot"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.custom"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.colorScale"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.field"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.heatmap"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.hexbin"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.line"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.mekko"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.pie"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.radar"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.radialBar"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.sankey"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.scatter"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.treemap"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.capabilities"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.polarArea"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.radial"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.configs.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.series"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.supportedTypes"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local ____exports = {}
____exports.CHART_TYPES = {
"bar",
"line",
"scatter",
"radar",
"radial",
"field",
"heatmap",
"boxplot",
"sankey",
"treemap",
"mekko",
"hexbin",
"pie",
"radialBar",
"polarArea",
"custom"
}
function ____exports.isChartType(self, value)
return value ~= nil and __TS__ArrayIncludes(____exports.CHART_TYPES, value)
end
return ____exports
end,
["core.model.chart.chart"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.chart.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____supportedTypes = require("core.model.chart.supportedTypes")
____exports.CHART_TYPES = ____supportedTypes.CHART_TYPES
____exports.isChartType = ____supportedTypes.isChartType
end
return ____exports
end,
["core.sflSemantic.ast.blockEntries"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
function ____exports.layoutProperties(self, block)
local properties = __TS__New(Map)
for ____, entry in ipairs(block.entries) do
if entry.type == "layout" then
for ____, property in ipairs(entry.layout.properties) do
properties:set(property.key, property.value)
end
end
end
return properties
end
function ____exports.directProperties(self, block)
local properties = __TS__New(Map)
for ____, entry in ipairs(block.entries) do
if entry.type == "property" then
properties:set(entry.property.key, entry.property.value)
end
end
return properties
end
function ____exports.styleProperties(self, block)
local properties = __TS__New(Map)
for ____, entry in ipairs(block.entries) do
if entry.type == "style" then
for ____, property in ipairs(entry.style.properties) do
properties:set(property.key, property.value)
end
end
end
return properties
end
function ____exports.placementValue(self, block, key, before)
if before == nil then
before = key
end
return ____exports.layoutProperties(nil, block):get(key) or ____exports.directProperties(nil, block):get(before)
end
function ____exports.childBlocks(self, block)
return __TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and ({entry.block}) or ({}) end
)
end
local function dataEntryBlock(self, block)
for ____, entry in ipairs(block.entries) do
if entry.type == "data" then
return entry.data
end
end
return nil
end
function ____exports.contentChildren(self, block)
local data = dataEntryBlock(nil, block)
local ____data_1
if data then
local ____array_0 = __TS__SparseArrayNew(table.unpack(____exports.childBlocks(nil, block)))
__TS__SparseArrayPush(
____array_0,
table.unpack(____exports.childBlocks(nil, data))
)
____data_1 = {__TS__SparseArraySpread(____array_0)}
else
____data_1 = ____exports.childBlocks(nil, block)
end
return ____data_1
end
function ____exports.contentProperty(self, block, key)
local direct = ____exports.directProperties(nil, block):get(key)
if direct ~= nil then
return direct
end
local data = dataEntryBlock(nil, block)
local ____data_2
if data then
____data_2 = ____exports.directProperties(nil, data):get(key)
else
____data_2 = nil
end
return ____data_2
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.values"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
function ____exports.numberList(self, value)
if (value and value.type) ~= "list" then
return nil
end
local numbers = __TS__ArrayFlatMap(
value.values,
function(____, item)
local number = asNumber(nil, item)
return number == nil and ({}) or ({number})
end
)
return #numbers > 0 and numbers or nil
end
function ____exports.stringList(self, value)
if (value and value.type) ~= "list" then
return nil
end
return __TS__ArrayFlatMap(
value.values,
function(____, item)
local text = asString(nil, item)
return text == nil and ({}) or ({text})
end
)
end
function ____exports.readBoolean(self, value)
local text = asString(nil, value)
if text == nil then
return nil
end
return text == "true"
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.axis"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local directProperties = ____blockEntries.directProperties
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local ____values = require("core.sflSemantic.canvasObjects.artifacts.chart.values")
local numberList = ____values.numberList
function ____exports.readAxis(self, block)
local properties = block and directProperties(nil, block) or __TS__New(Map)
return {
min = asNumber(
nil,
properties:get("min")
) or 0,
max = asNumber(
nil,
properties:get("max")
) or 10,
step = asNumber(
nil,
properties:get("step")
) or 1,
label = asString(
nil,
properties:get("label")
),
unit = asString(
nil,
properties:get("unit")
),
thresholds = numberList(
nil,
properties:get("thresholds")
)
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.rules"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local contentChildren = ____blockEntries.contentChildren
local directProperties = ____blockEntries.directProperties
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local ____values = require("core.sflSemantic.canvasObjects.artifacts.chart.values")
local numberList = ____values.numberList
function ____exports.readChartRules(self, block)
return __TS__ArrayMap(
__TS__ArrayFilter(
contentChildren(nil, block),
function(____, child) return child.kind == "Rule" end
),
function(____, rule)
local properties = directProperties(nil, rule)
return {
id = rule.name,
at = asNumber(
nil,
properties:get("at")
) or 0,
text = asString(
nil,
properties:get("text")
),
color = asString(
nil,
properties:get("color")
),
strokeWidth = asNumber(
nil,
properties:get("strokeWidth")
),
dash = numberList(
nil,
properties:get("dash")
)
}
end
)
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.seriesValues"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local Map = ____lualib.Map
local ____exports = {}
local asComponents, firstSeriesValueShape, readScalarSeriesValues, readTupleSeriesValues, readSeriesError, readSeriesErrorRange, readSeriesColor, readSeriesSymbolPoint
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
function asComponents(self, value)
if value.type ~= "list" or #value.values < 2 then
return nil
end
local components = __TS__ArrayMap(value.values, asNumber)
return __TS__ArrayEvery(
components,
function(____, part) return part ~= nil end
) and components or nil
end
function firstSeriesValueShape(self, values)
for ____, value in ipairs(values) do
if value.type == "number" then
return "scalar"
end
if asComponents(nil, value) then
return "tuple"
end
end
return nil
end
function readScalarSeriesValues(self, values)
return __TS__ArrayFlatMap(
values,
function(____, value) return value.type == "number" and ({value.value}) or ({}) end
)
end
function readTupleSeriesValues(self, values)
return __TS__ArrayFlatMap(
values,
function(____, value)
local components = asComponents(nil, value)
return components and ({components}) or ({})
end
)
end
function readSeriesError(self, value)
if value.type == "ident" and table.concat(value.segments, ".") == "none" then
return nil
end
if value.type == "number" then
return value.value
end
return readSeriesErrorRange(nil, value)
end
function readSeriesErrorRange(self, value)
if value.type ~= "list" or #value.values < 2 then
return nil
end
local low = asNumber(nil, value.values[1])
local high = asNumber(nil, value.values[2])
return low ~= nil and high ~= nil and ({low, high}) or nil
end
function readSeriesColor(self, value)
if value.type == "ident" and table.concat(value.segments, ".") == "none" then
return nil
end
return asString(nil, value) or nil
end
function readSeriesSymbolPoint(self, value)
if value.type ~= "list" or #value.values < 2 then
return {}
end
local x = asNumber(nil, value.values[1])
local y = asNumber(nil, value.values[2])
return (x == nil or y == nil) and ({}) or ({{x, y}})
end
function ____exports.readSeriesValues(self, value)
if (value and value.type) ~= "list" then
return {}
end
local shape = firstSeriesValueShape(nil, value.values)
return shape == "tuple" and readTupleSeriesValues(nil, value.values) or readScalarSeriesValues(nil, value.values)
end
function ____exports.readSeriesErrors(self, value)
if (value and value.type) ~= "list" then
return nil
end
return __TS__ArrayMap(value.values, readSeriesError)
end
function ____exports.readSeriesColors(self, value)
if (value and value.type) ~= "list" then
return nil
end
return __TS__ArrayMap(value.values, readSeriesColor)
end
function ____exports.readSeriesSymbol(self, value, symbolDefs)
if (value and value.type) == "list" then
local points = __TS__ArrayFlatMap(value.values, readSeriesSymbolPoint)
return #points > 0 and ({points = points}) or nil
end
local name = asString(nil, value)
local ____t_result_8
if __t(nil, name) then
____t_result_8 = symbolDefs:get(name)
else
____t_result_8 = nil
end
local definition = ____t_result_8
if not definition then
return nil
end
return {points = definition.points, normalized = true, tension = definition.tension}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.series"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local ____seriesValues = require("core.sflSemantic.canvasObjects.artifacts.chart.seriesValues")
local readSeriesColors = ____seriesValues.readSeriesColors
local readSeriesErrors = ____seriesValues.readSeriesErrors
local readSeriesSymbol = ____seriesValues.readSeriesSymbol
local readSeriesValues = ____seriesValues.readSeriesValues
local ____values = require("core.sflSemantic.canvasObjects.artifacts.chart.values")
local numberList = ____values.numberList
function ____exports.readSeries(self, block, symbolDefs, mergedProps)
local properties = mergedProps(nil, block)
return {
id = block.name,
label = asString(
nil,
properties:get("label")
) or block.name,
color = asString(
nil,
properties:get("color")
),
colors = readSeriesColors(
nil,
properties:get("colors")
),
opacity = asNumber(
nil,
properties:get("opacity")
),
group = asString(
nil,
properties:get("group")
),
values = readSeriesValues(
nil,
properties:get("values")
),
error = readSeriesErrors(
nil,
properties:get("error")
),
source = asString(
nil,
properties:get("source")
),
target = asString(
nil,
properties:get("target")
),
size = asNumber(
nil,
properties:get("size")
),
symbol = readSeriesSymbol(
nil,
properties:get("symbol"),
symbolDefs
),
stroke = asString(
nil,
properties:get("stroke")
),
strokeWidth = asNumber(
nil,
properties:get("strokeWidth")
),
dash = numberList(
nil,
properties:get("dash")
),
offset = asNumber(
nil,
properties:get("offset")
),
labelOffsetX = asNumber(
nil,
properties:get("labelOffsetX")
),
labelOffsetY = asNumber(
nil,
properties:get("labelOffsetY")
)
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.zones"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
function ____exports.readChartZones(self, value)
if (value and value.type) ~= "list" then
return nil
end
local zones = __TS__ArrayFlatMap(
value.values,
function(____, item)
if item.type ~= "list" then
return {}
end
local label = asString(nil, item.values[1])
if label == nil then
return {}
end
return {{
label = label,
color = asString(nil, item.values[2]),
offsetX = asNumber(nil, item.values[3]),
offsetY = asNumber(nil, item.values[4])
}}
end
)
return #zones > 0 and zones or nil
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.reader"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local Map = ____lualib.Map
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____chart = require("core.model.chart.index")
local isChartType = ____chart.isChartType
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local contentChildren = ____blockEntries.contentChildren
local contentProperty = ____blockEntries.contentProperty
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local ____axis = require("core.sflSemantic.canvasObjects.artifacts.chart.axis")
local readAxis = ____axis.readAxis
local ____rules = require("core.sflSemantic.canvasObjects.artifacts.chart.rules")
local readChartRules = ____rules.readChartRules
local ____series = require("core.sflSemantic.canvasObjects.artifacts.chart.series")
local readSeries = ____series.readSeries
local ____values = require("core.sflSemantic.canvasObjects.artifacts.chart.values")
local numberList = ____values.numberList
local readBoolean = ____values.readBoolean
local stringList = ____values.stringList
local ____zones = require("core.sflSemantic.canvasObjects.artifacts.chart.zones")
local readChartZones = ____zones.readChartZones
local STACKED_MODES = {"none", "true", "percent", "waterfall"}
local function asChartType(self, value)
return isChartType(nil, value) and value or "bar"
end
local function asStackedMode(self, value)
return __TS__ArrayFind(
STACKED_MODES,
function(____, mode) return mode == value end
)
end
function ____exports.readChart(self, block, properties, symbolDefs, mergedProps)
local children = contentChildren(nil, block)
local axes = __TS__ArrayFilter(
children,
function(____, child) return child.kind == "Axis" end
)
local stacked = asString(
nil,
properties:get("stacked")
)
return {
chartType = asChartType(
nil,
asString(
nil,
properties:get("type")
)
),
categories = stringList(
nil,
contentProperty(nil, block, "categories")
),
areaOpacity = asNumber(
nil,
properties:get("areaOpacity")
),
stacked = asStackedMode(nil, stacked),
scale = asString(
nil,
properties:get("scale")
),
interpolate = asString(
nil,
properties:get("interpolate")
) == "idw" and "idw" or nil,
idwPower = asNumber(
nil,
properties:get("idwPower")
),
isolines = numberList(
nil,
properties:get("isolines")
),
zones = readChartZones(
nil,
properties:get("zones")
),
boxWidth = asNumber(
nil,
properties:get("boxWidth")
),
orientation = asString(
nil,
properties:get("orientation")
) == "horizontal" and "horizontal" or nil,
lineTension = asNumber(
nil,
properties:get("lineTension")
),
highlightPoints = numberList(
nil,
properties:get("highlightPoints")
),
barCornerRadius = asNumber(
nil,
properties:get("barCornerRadius")
),
showBoxplotPoints = readBoolean(
nil,
properties:get("showBoxplotPoints")
),
barBorderColor = asString(
nil,
properties:get("barBorderColor")
),
barBorderWidth = asNumber(
nil,
properties:get("barBorderWidth")
),
barGroupGap = asNumber(
nil,
properties:get("barGroupGap")
),
barGlow = asNumber(
nil,
properties:get("barGlow")
),
barGap = asNumber(
nil,
properties:get("barGap")
),
mekkoVaryHeight = readBoolean(
nil,
properties:get("mekkoVaryHeight")
),
hexRadius = asNumber(
nil,
properties:get("hexRadius")
),
innerRadius = asNumber(
nil,
properties:get("innerRadius")
),
pieCornerRadius = asNumber(
nil,
properties:get("pieCornerRadius")
),
pieSliceGap = asNumber(
nil,
properties:get("pieSliceGap")
),
ringThickness = asNumber(
nil,
properties:get("ringThickness")
),
ringGap = asNumber(
nil,
properties:get("ringGap")
),
cellGap = asNumber(
nil,
properties:get("cellGap")
),
showValues = readBoolean(
nil,
properties:get("showValues")
),
squareCells = readBoolean(
nil,
properties:get("squareCells")
),
headerColor = asString(
nil,
properties:get("headerColor")
),
tileGradient = readBoolean(
nil,
properties:get("tileGradient")
),
showColumnBackdrop = readBoolean(
nil,
properties:get("showColumnBackdrop")
),
labelPosition = asString(
nil,
properties:get("labelPosition")
) == "inside" and "inside" or nil,
labelOrientation = asString(
nil,
properties:get("labelOrientation")
) == "vertical" and "vertical" or nil,
labelColor = asString(
nil,
properties:get("labelColor")
),
linkGradient = readBoolean(
nil,
properties:get("linkGradient")
),
connectPoints = readBoolean(
nil,
properties:get("connectPoints")
),
reverseComparison = readBoolean(
nil,
properties:get("reverseComparison")
),
axisX = readAxis(
nil,
__TS__ArrayFind(
axes,
function(____, axis) return axis.name == "x" end
)
),
axisY = readAxis(
nil,
__TS__ArrayFind(
axes,
function(____, axis) return axis.name == "y" or axis.name == "value" end
)
),
series = __TS__ArrayMap(
__TS__ArrayFilter(
children,
function(____, child) return child.kind == "Series" end
),
function(____, child) return readSeries(nil, child, symbolDefs, mergedProps) end
),
rules = readChartRules(nil, block)
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.chart.resolver"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____reader = require("core.sflSemantic.canvasObjects.artifacts.chart.reader")
local readChart = ____reader.readChart
function ____exports.resolveChartObject(self, base, block, properties, symbolDefinitions, mergedProperties)
return __TS__ObjectAssign(
{},
base,
{
objectType = "chart",
chart = readChart(
nil,
block,
properties,
symbolDefinitions,
mergedProperties
)
}
)
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.dimension.object"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.isDimensionObject(self, canvasObject)
return canvasObject.objectType == "dimension" and canvasObject.dimension ~= nil
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.dimension.reader"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local tupleValues = ____valueAccess.tupleValues
local function readPoint(self, value, origin)
local x, y = table.unpack(
tupleValues(nil, value) or ({}),
1,
2
)
return {x = origin.x + (x or 0), y = origin.y + (y or 0)}
end
function ____exports.readDimension(self, properties, origin)
return {
start = readPoint(
nil,
properties:get("start"),
origin
),
["end"] = readPoint(
nil,
properties:get("end"),
origin
),
offset = asNumber(
nil,
properties:get("offset")
) or 0,
unit = asString(
nil,
properties:get("unit")
)
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.dimension.resolver"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____reader = require("core.sflSemantic.canvasObjects.artifacts.dimension.reader")
local readDimension = ____reader.readDimension
function ____exports.resolveDimensionObject(self, base, properties, origin)
return __TS__ObjectAssign(
{},
base,
{
objectType = "dimension",
dimension = readDimension(nil, properties, origin)
}
)
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.isometric.object"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.isIsometricObject(self, canvasObject)
return canvasObject.objectType == "isometric" and canvasObject.isometric ~= nil
end
return ____exports
end,
["core.model.link.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.link.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.path.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.path.curve"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local SAMPLES_PER_SEGMENT = 8
function ____exports.pointTension(self, curve, point)
return math.max(0, point.tension or curve.tension)
end
function ____exports.isStraight(self, curve)
return #curve.points < 3 or __TS__ArrayEvery(
curve.points,
function(____, point) return ____exports.pointTension(nil, curve, point) <= 0 end
)
end
local function pointAt(self, curve, index)
local ____curve_0 = curve
local points = ____curve_0.points
if curve.closed then
return points[(index + #points) % #points + 1]
end
return points[math.max(
0,
math.min(#points - 1, index)
) + 1]
end
function ____exports.pathSegments(self, curve)
local count = curve.closed and #curve.points or #curve.points - 1
return __TS__ArrayFrom(
{length = math.max(0, count)},
function(____, _, index)
local previous = pointAt(nil, curve, index - 1)
local from = pointAt(nil, curve, index)
local to = pointAt(nil, curve, index + 1)
local next = pointAt(nil, curve, index + 2)
local fromFactor = ____exports.pointTension(nil, curve, from) / 6
local toFactor = ____exports.pointTension(nil, curve, to) / 6
if fromFactor == 0 and toFactor == 0 then
return {from = from, to = to, controls = nil}
end
local first = {x = from.x + (to.x - previous.x) * fromFactor, y = from.y + (to.y - previous.y) * fromFactor}
local second = {x = to.x - (next.x - from.x) * toFactor, y = to.y - (next.y - from.y) * toFactor}
return {from = from, to = to, controls = {first, second}}
end
)
end
local function bezierAt(self, segment, t)
local ____segment_1 = segment
local from = ____segment_1.from
local to = ____segment_1.to
local controls = ____segment_1.controls
local u = 1 - t
local weights = {u * u * u, 3 * u * u * t, 3 * u * t * t, t * t * t}
local anchors = {from, controls[1], controls[2], to}
return {
x = __TS__ArrayReduce(
anchors,
function(____, sum, anchor, i) return sum + anchor.x * weights[i + 1] end,
0
),
y = __TS__ArrayReduce(
anchors,
function(____, sum, anchor, i) return sum + anchor.y * weights[i + 1] end,
0
)
}
end
function ____exports.flattenPath(self, curve, samples)
if samples == nil then
samples = SAMPLES_PER_SEGMENT
end
if ____exports.isStraight(nil, curve) then
return __TS__ArrayMap(
curve.points,
function(____, point) return {x = point.x, y = point.y} end
)
end
local flat = {}
local segments = ____exports.pathSegments(nil, curve)
__TS__ArrayForEach(
segments,
function(____, segment)
flat[#flat + 1] = {x = segment.from.x, y = segment.from.y}
if segment.controls then
local curved = __TS__ObjectAssign({}, segment, {controls = segment.controls})
do
local step = 1
while step < samples do
flat[#flat + 1] = bezierAt(nil, curved, step / samples)
step = step + 1
end
end
end
end
)
local last = segments[#segments]
if not curve.closed and last then
flat[#flat + 1] = {x = last.to.x, y = last.to.y}
end
return flat
end
return ____exports
end,
["core.model.path.symbol"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
function ____exports.pathBounds(self, points)
local xs = __TS__ArrayMap(
points,
function(____, point) return point.x end
)
local ys = __TS__ArrayMap(
points,
function(____, point) return point.y end
)
local x = math.min(table.unpack(xs))
local y = math.min(table.unpack(ys))
return {
x = x,
y = y,
width = math.max(table.unpack(xs)) - x,
height = math.max(table.unpack(ys)) - y
}
end
local function round(____, value)
return math.floor(value * 10000 + 0.5) / 10000
end
function ____exports.pathToSymbol(self, points)
if #points == 0 then
return {points = {}, width = 0, height = 0}
end
local frame = ____exports.pathBounds(nil, points)
local function unit(____, value, size)
return size == 0 and 0 or round(nil, value / size)
end
return {
width = frame.width,
height = frame.height,
points = __TS__ArrayMap(
points,
function(____, point)
local x = unit(nil, point.x - frame.x, frame.width)
local y = unit(nil, point.y - frame.y, frame.height)
return point.tension == nil and ({x, y}) or ({x, y, point.tension})
end
)
}
end
function ____exports.symbolToPath(self, points, frame)
return __TS__ArrayMap(
points,
function(____, point)
local placed = {x = frame.x + point[1] * frame.width, y = frame.y + point[2] * frame.height}
return point[3] == nil and placed or __TS__ObjectAssign({}, placed, {tension = point[3]})
end
)
end
return ____exports
end,
["core.model.path.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____curve = require("core.model.path.curve")
____exports.flattenPath = ____curve.flattenPath
____exports.isStraight = ____curve.isStraight
____exports.pathSegments = ____curve.pathSegments
____exports.pointTension = ____curve.pointTension
end
do
local ____symbol = require("core.model.path.symbol")
____exports.pathBounds = ____symbol.pathBounds
____exports.pathToSymbol = ____symbol.pathToSymbol
____exports.symbolToPath = ____symbol.symbolToPath
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.isometric.reader"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Map = ____lualib.Map
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____path = require("core.model.path.index")
local flattenPath = ____path.flattenPath
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local function readFootprintPoint(self, value)
if value.type ~= "list" or #value.values < 2 then
return {}
end
local x = asNumber(nil, value.values[1])
local y = asNumber(nil, value.values[2])
local ____temp_0
if value.values[3] == nil then
____temp_0 = nil
else
____temp_0 = asNumber(nil, value.values[3])
end
local tension = ____temp_0
if x == nil or y == nil then
return {}
end
return {tension == nil and ({x = x, y = y}) or ({x = x, y = y, tension = tension})}
end
local function asPolygon(self, points, tension)
local flat = flattenPath(nil, {points = points, tension = tension, closed = true})
return #flat >= 3 and __TS__ArrayMap(
flat,
function(____, point) return {point.x, point.y} end
) or nil
end
local function readFootprint(self, value, symbolDefs)
if (value and value.type) == "list" then
return asPolygon(
nil,
__TS__ArrayFlatMap(value.values, readFootprintPoint),
0
)
end
local name = asString(nil, value)
local ____t_result_3
if __t(nil, name) then
____t_result_3 = symbolDefs:get(name)
else
____t_result_3 = nil
end
local definition = ____t_result_3
if not definition then
return nil
end
local points = __TS__ArrayMap(
definition.points,
function(____, ____bindingPattern0, index)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
local ____opt_4 = definition.pointTensions
local tension = ____opt_4 and ____opt_4[index + 1]
return tension == nil and ({x = x, y = y}) or ({x = x, y = y, tension = tension})
end
)
return asPolygon(nil, points, definition.tension or 0)
end
function ____exports.readIsometric(self, properties, depth, symbolDefs)
return {
depth = depth,
icon = asString(
nil,
properties:get("icon")
),
footprint = readFootprint(
nil,
properties:get("symbol"),
symbolDefs
),
form = asString(
nil,
properties:get("shape")
) == "sphere" and "sphere" or "box"
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.isometric.resolver"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local tupleValues = ____valueAccess.tupleValues
local ____reader = require("core.sflSemantic.canvasObjects.artifacts.isometric.reader")
local readIsometric = ____reader.readIsometric
function ____exports.resolveIsometricObject(self, base, block, properties, layoutProperty, symbolDefinitions)
local size = tupleValues(
nil,
layoutProperty(nil, block, "size")
)
return __TS__ObjectAssign(
{},
base,
{
objectType = "isometric",
isometric = readIsometric(nil, properties, size and size[3] or 24, symbolDefinitions)
}
)
end
return ____exports
end,
["core.model.facets.index"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__NumberIsInteger = ____lualib.__TS__NumberIsInteger
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayReverse = ____lualib.__TS__ArrayReverse
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArraySplice = ____lualib.__TS__ArraySplice
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local Map = ____lualib.Map
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
local __TS__StringSlice = ____lualib.__TS__StringSlice
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __json = ______shims.__json
local __jsonParse = ______shims.__jsonParse
local __t = ______shims.__t
local function sub(____, a, b)
return {a[1] - b[1], a[2] - b[2], a[3] - b[3]}
end
local function add(____, a, b)
return {a[1] + b[1], a[2] + b[2], a[3] + b[3]}
end
local function times(____, a, k)
return {a[1] * k, a[2] * k, a[3] * k}
end
local function dot(____, a, b)
return a[1] * b[1] + a[2] * b[2] + a[3] * b[3]
end
local function cross(____, a, b)
return {a[2] * b[3] - a[3] * b[2], a[3] * b[1] - a[1] * b[3], a[1] * b[2] - a[2] * b[1]}
end
local function unit(____, a)
local length = __hypot(nil, a[1], a[2], a[3])
return length > 1e-12 and ({a[1] / length, a[2] / length, a[3] / length}) or ({0, 0, 0})
end
local function normalOf(self, points, face)
local n = {0, 0, 0}
do
local i = 0
while i < #face do
local p, q = points[face[i + 1] + 1], points[face[(i + 1) % #face + 1] + 1]
n[1] = n[1] + (p[2] - q[2]) * (p[3] + q[3])
n[2] = n[2] + (p[3] - q[3]) * (p[1] + q[1])
n[3] = n[3] + (p[1] - q[1]) * (p[2] + q[2])
i = i + 1
end
end
return unit(nil, n)
end
local function whole(self, sheet)
local count = #sheet.points
local faces = __TS__ArrayFilter(
__TS__ArrayMap(
sheet.faces,
function(____, face) return __TS__ArrayFilter(
face,
function(____, at, i) return __TS__NumberIsInteger(at) and at >= 0 and at < count and at ~= face[(i + 1) % #face + 1] end
) end
),
function(____, face) return #face >= 3 end
)
return {points = sheet.points, faces = faces}
end
local function withOtherHalf(self, sheet, axis)
local points = {table.unpack(sheet.points)}
local twin = __TS__ArrayMap(
sheet.points,
function(____, point, i)
if math.abs(point[axis + 1]) < 0.000001 then
return i
end
local mirrored = {point[1], point[2], point[3]}
mirrored[axis + 1] = -mirrored[axis + 1]
points[#points + 1] = mirrored
return #points - 1
end
)
local ____array_0 = __TS__SparseArrayNew(table.unpack(sheet.faces))
__TS__SparseArrayPush(
____array_0,
table.unpack(__TS__ArrayMap(
sheet.faces,
function(____, face) return __TS__ArrayReverse(__TS__ArrayMap(
face,
function(____, at) return twin[at + 1] end
)) end
))
)
local faces = {__TS__SparseArraySpread(____array_0)}
return {points = points, faces = faces}
end
local function key(____, a, b)
return a * 1048576 + b
end
local function thick(self, sheet, thickness)
local count = #sheet.points
local normals = __TS__ArrayMap(
sheet.faces,
function(____, face) return normalOf(nil, sheet.points, face) end
)
local around = __TS__ArrayMap(
sheet.points,
function() return {} end
)
__TS__ArrayForEach(
sheet.faces,
function(____, face, f)
for ____, at in ipairs(face) do
local ____around_index_1 = around[at + 1]
____around_index_1[#____around_index_1 + 1] = normals[f + 1]
end
end
)
local inner = __TS__ArrayMap(
sheet.points,
function(____, point, i)
local way = unit(
nil,
__TS__ArrayReduce(
around[i + 1],
function(____, sum, n) return add(nil, sum, n) end,
{0, 0, 0}
)
)
local least = math.min(
1,
table.unpack(__TS__ArrayMap(
around[i + 1],
function(____, n) return dot(nil, way, n) end
))
)
return sub(
nil,
point,
times(
nil,
way,
thickness / math.max(0.35, least)
)
)
end
)
local taken = __TS__New(Set)
for ____, face in ipairs(sheet.faces) do
__TS__ArrayForEach(
face,
function(____, a, i)
taken:add(key(nil, a, face[(i + 1) % #face + 1]))
end
)
end
local ____array_2 = __TS__SparseArrayNew(table.unpack(sheet.faces))
__TS__SparseArrayPush(
____array_2,
table.unpack(__TS__ArrayMap(
sheet.faces,
function(____, face) return __TS__ArrayReverse(__TS__ArrayMap(
face,
function(____, at) return at + count end
)) end
))
)
local faces = {__TS__SparseArraySpread(____array_2)}
for ____, face in ipairs(sheet.faces) do
__TS__ArrayForEach(
face,
function(____, a, i)
local b = face[(i + 1) % #face + 1]
if not taken:has(key(nil, b, a)) then
faces[#faces + 1] = {b, a, a + count, b + count}
end
end
)
end
local ____array_3 = __TS__SparseArrayNew(table.unpack(sheet.points))
__TS__SparseArrayPush(
____array_3,
table.unpack(inner)
)
return {
points = {__TS__SparseArraySpread(____array_3)},
faces = faces
}
end
local function ears(self, corners, normal)
local rest = __TS__ArrayMap(
corners,
function(____, _, i) return i end
)
local triangles = {}
local function turns(____, a, b, c)
return dot(
nil,
cross(
nil,
sub(nil, corners[b + 1], corners[a + 1]),
sub(nil, corners[c + 1], corners[b + 1])
),
normal
)
end
local guard = #corners * #corners + 8
while #rest > 3 and guard > 0 do
guard = guard - 1
local cut = false
do
local i = 0
while i < #rest do
do
local a, b, c = rest[(i + #rest - 1) % #rest + 1], rest[i + 1], rest[(i + 1) % #rest + 1]
if turns(nil, a, b, c) <= 1e-14 then
goto __continue44
end
local blocked = __TS__ArraySome(
rest,
function(____, p) return p ~= a and p ~= b and p ~= c and turns(nil, a, b, p) > 0 and turns(nil, b, c, p) > 0 and turns(nil, c, a, p) > 0 end
)
if blocked then
goto __continue44
end
triangles[#triangles + 1] = {a, b, c}
__TS__ArraySplice(rest, i, 1)
cut = true
break
end
::__continue44::
i = i + 1
end
end
if not cut then
__TS__ArraySplice(rest, 0, 1)
end
end
if #rest == 3 then
triangles[#triangles + 1] = {rest[1], rest[2], rest[3]}
end
return triangles
end
function ____exports.buildFacets(self, shape)
local sheet = whole(nil, {points = shape.points, faces = shape.faces})
if __t(nil, shape.symmetry) then
sheet = withOtherHalf(nil, sheet, shape.symmetry == "x" and 0 or (shape.symmetry == "y" and 1 or 2))
end
if __t(nil, shape.thickness) and shape.thickness > 0 then
sheet = thick(nil, sheet, shape.thickness)
end
local ____sheet_4 = sheet
local points = ____sheet_4.points
local faces = ____sheet_4.faces
local normals = __TS__ArrayMap(
faces,
function(____, face) return normalOf(nil, points, face) end
)
local wanted = math.max(0, shape.bevel or 0)
local drawn = __TS__ArrayMap(
faces,
function(____, face, f)
local corners = __TS__ArrayMap(
face,
function(____, at) return points[at + 1] end
)
local n = normals[f + 1]
local shortest = math.min(table.unpack(__TS__ArrayMap(
corners,
function(____, p, i) return __hypot(
nil,
table.unpack(sub(nil, corners[(i + 1) % #corners + 1], p))
) end
)))
local round = __TS__ArrayReduce(
corners,
function(____, sum, p, i) return sum + __hypot(
nil,
table.unpack(sub(nil, corners[(i + 1) % #corners + 1], p))
) end,
0
)
local area = __hypot(
nil,
table.unpack(__TS__ArrayReduce(
corners,
function(____, sum, p, i) return add(
nil,
sum,
cross(nil, p, corners[(i + 1) % #corners + 1])
) end,
{0, 0, 0}
))
) / 2
local band = math.min(wanted, shortest * 0.3, round > 0 and 2 * area / round * 0.35 or 0)
do
local step = 0
while step < 6 and band > 0.000001 do
local width = band
local inside = __TS__ArrayMap(
corners,
function(____, point, i)
local before = corners[(i + #corners - 1) % #corners + 1]
local after = corners[(i + 1) % #corners + 1]
local in1, in2 = cross(
nil,
n,
unit(
nil,
sub(nil, point, before)
)
), cross(
nil,
n,
unit(
nil,
sub(nil, after, point)
)
)
local reach = 1 / math.max(
0.25,
1 + dot(nil, in1, in2)
)
return add(
nil,
point,
times(
nil,
add(nil, in1, in2),
width * reach
)
)
end
)
local kept = __TS__ArrayEvery(
corners,
function(____, point, i)
local j = (i + 1) % #corners
local was, now = sub(nil, corners[j + 1], point), sub(nil, inside[j + 1], inside[i + 1])
return dot(nil, was, now) > dot(nil, was, was) * 0.05
end
)
if kept then
return inside
end
band = band / 2
step = step + 1
end
end
return corners
end
)
local positions = {}
local facing = {}
local function triangle(____, a, b, c, na, nb, nc)
local size = cross(
nil,
sub(nil, b, a),
sub(nil, c, a)
)
if __hypot(nil, size[1], size[2], size[3]) < 1e-12 then
return
end
local ____array_5 = __TS__SparseArrayNew(table.unpack(a))
__TS__SparseArrayPush(
____array_5,
table.unpack(b)
)
__TS__SparseArrayPush(
____array_5,
table.unpack(c)
)
__TS__ArrayPush(
positions,
__TS__SparseArraySpread(____array_5)
)
local ____array_6 = __TS__SparseArrayNew(table.unpack(na))
__TS__SparseArrayPush(
____array_6,
table.unpack(nb)
)
__TS__SparseArrayPush(
____array_6,
table.unpack(nc)
)
__TS__ArrayPush(
facing,
__TS__SparseArraySpread(____array_6)
)
end
__TS__ArrayForEach(
faces,
function(____, _, f)
for ____, ____value in ipairs(ears(nil, drawn[f + 1], normals[f + 1])) do
local a = ____value[1]
local b = ____value[2]
local c = ____value[3]
triangle(
nil,
drawn[f + 1][a + 1],
drawn[f + 1][b + 1],
drawn[f + 1][c + 1],
normals[f + 1],
normals[f + 1],
normals[f + 1]
)
end
end
)
if wanted <= 0 then
return {
positions = __TS__New(Float32Array, positions),
normals = __TS__New(Float32Array, facing)
}
end
local edges = __TS__New(Map)
__TS__ArrayForEach(
faces,
function(____, face, f)
__TS__ArrayForEach(
face,
function(____, a, i)
edges:set(
key(nil, a, face[(i + 1) % #face + 1]),
{f, i}
)
end
)
end
)
__TS__ArrayForEach(
faces,
function(____, face, f)
__TS__ArrayForEach(
face,
function(____, a, i)
local j = (i + 1) % #face
local b = face[j + 1]
local other = edges:get(key(nil, b, a))
if not other or a > b then
return
end
local g, k = table.unpack(other, 1, 2)
local l = (k + 1) % #faces[g + 1]
local fb, fa, ga, gb = drawn[f + 1][j + 1], drawn[f + 1][i + 1], drawn[g + 1][l + 1], drawn[g + 1][k + 1]
triangle(
nil,
fb,
fa,
ga,
normals[f + 1],
normals[f + 1],
normals[g + 1]
)
triangle(
nil,
fb,
ga,
gb,
normals[f + 1],
normals[g + 1],
normals[g + 1]
)
end
)
end
)
local done = __TS__New(Set)
__TS__ArrayForEach(
faces,
function(____, face, f)
__TS__ArrayForEach(
face,
function(____, at, i)
if done:has(at) then
return
end
done:add(at)
local ring = {}
local g, k = f, i
do
local guard = 0
while guard < 64 do
ring[#ring + 1] = {g, k}
local next = edges:get(key(nil, faces[g + 1][(k + 1) % #faces[g + 1] + 1], at))
if not next then
return
end
g, k = next[1], (next[2] + 1) % #faces[next[1] + 1]
if g == f and k == i then
break
end
guard = guard + 1
end
end
if #ring < 3 then
return
end
local corners = __TS__ArrayMap(
ring,
function(____, ____bindingPattern0)
local corner
local face
face = ____bindingPattern0[1]
corner = ____bindingPattern0[2]
return drawn[face + 1][corner + 1]
end
)
local ways = __TS__ArrayMap(
ring,
function(____, ____bindingPattern0)
local face
face = ____bindingPattern0[1]
return normals[face + 1]
end
)
local mean = unit(
nil,
__TS__ArrayReduce(
ways,
function(____, sum, n) return add(nil, sum, n) end,
{0, 0, 0}
)
)
local middle = times(
nil,
__TS__ArrayReduce(
corners,
function(____, sum, p) return add(nil, sum, p) end,
{0, 0, 0}
),
1 / #corners
)
do
local c = 0
while c < #corners do
local d = (c + 1) % #corners
local out = dot(
nil,
cross(
nil,
sub(nil, corners[c + 1], middle),
sub(nil, corners[d + 1], middle)
),
mean
) >= 0
if out then
triangle(
nil,
middle,
corners[c + 1],
corners[d + 1],
mean,
ways[c + 1],
ways[d + 1]
)
else
triangle(
nil,
middle,
corners[d + 1],
corners[c + 1],
mean,
ways[d + 1],
ways[c + 1]
)
end
c = c + 1
end
end
end
)
end
)
return {
positions = __TS__New(Float32Array, positions),
normals = __TS__New(Float32Array, facing)
}
end
____exports.FACETS_ASSET = "facets:"
____exports.facetsAssetName = function(____, shape) return ____exports.FACETS_ASSET .. __json(nil, shape) end
function ____exports.facetsOfAsset(self, asset)
if not __TS__StringStartsWith(asset, ____exports.FACETS_ASSET) then
return nil
end
do
local function ____catch()
return true, nil
end
local ____try, ____hasReturned, ____returnValue = pcall(function()
return true, __jsonParse(
nil,
__TS__StringSlice(asset, #____exports.FACETS_ASSET)
)
end)
if not ____try then
____hasReturned, ____returnValue = ____catch()
end
if ____hasReturned then
return ____returnValue
end
end
end
return ____exports
end,
["core.model.outline.index"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__Spread = ____lualib.__TS__Spread
local ____exports = {}
local withoutStraightPoints
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __sort = ______shims.__sort
function withoutStraightPoints(self, ring)
return __TS__ArrayFilter(
ring,
function(____, point, i)
local before = ring[(i + #ring - 1) % #ring + 1]
local after = ring[(i + 1) % #ring + 1]
return math.abs((point[1] - before[1]) * (after[2] - before[2]) - (point[2] - before[2]) * (after[1] - before[1])) > 1e-9
end
)
end
local TINY = 1e-9
local function key(____, x, y)
return (tostring(math.floor(x * 10000000 + 0.5)) .. ",") .. tostring(math.floor(y * 10000000 + 0.5))
end
function ____exports.ringArea(self, ring)
local sum = 0
do
local i = 0
while i < #ring do
local x1, y1 = table.unpack(ring[i + 1], 1, 2)
local x2, y2 = table.unpack(ring[(i + 1) % #ring + 1], 1, 2)
sum = sum + (x1 * y2 - x2 * y1)
i = i + 1
end
end
return sum / 2
end
function ____exports.insideOutline(self, outline, x, y)
local inside = false
for ____, ring in ipairs(outline) do
do
local i = 0
local j = #ring - 1
while i < #ring do
local ax, ay = table.unpack(ring[i + 1], 1, 2)
local bx, by = table.unpack(ring[j + 1], 1, 2)
if ay > y ~= (by > y) and x < (bx - ax) * (y - ay) / (by - ay) + ax then
inside = not inside
end
do
j = i
i = i + 1
end
end
end
end
return inside
end
local function edgesOf(____, outline)
return __TS__ArrayFlatMap(
outline,
function(____, ring) return __TS__ArrayMap(
ring,
function(____, ____bindingPattern0, i)
local ay
local ax
ax = ____bindingPattern0[1]
ay = ____bindingPattern0[2]
local bx, by = table.unpack(ring[(i + 1) % #ring + 1], 1, 2)
return {ax = ax, ay = ay, bx = bx, by = by}
end
) end
)
end
local function cutsAlong(self, edge, others)
local cuts = {}
local dx, dy = edge.bx - edge.ax, edge.by - edge.ay
local length = dx * dx + dy * dy
for ____, other in ipairs(others) do
do
local ex, ey = other.bx - other.ax, other.by - other.ay
local cross = dx * ey - dy * ex
if math.abs(cross) < TINY then
if math.abs((other.ax - edge.ax) * dy - (other.ay - edge.ay) * dx) > TINY then
goto __continue16
end
for ____, ____value in ipairs({{other.ax, other.ay}, {other.bx, other.by}}) do
local px = ____value[1]
local py = ____value[2]
cuts[#cuts + 1] = ((px - edge.ax) * dx + (py - edge.ay) * dy) / length
end
goto __continue16
end
local t = ((other.ax - edge.ax) * ey - (other.ay - edge.ay) * ex) / cross
local u = ((other.ax - edge.ax) * dy - (other.ay - edge.ay) * dx) / cross
if u > -1e-7 and u < 1 + 1e-7 then
cuts[#cuts + 1] = t
end
end
::__continue16::
end
return __sort(
nil,
__TS__ArrayFilter(
cuts,
function(____, t) return t > 1e-7 and t < 1 - 1e-7 end
),
function(____, a, b) return a - b end
)
end
local function pieces(self, edges, others)
return __TS__ArrayFlatMap(
edges,
function(____, edge)
local ____array_0 = __TS__SparseArrayNew(
0,
table.unpack(cutsAlong(nil, edge, others))
)
__TS__SparseArrayPush(____array_0, 1)
local stops = {__TS__SparseArraySpread(____array_0)}
local function at(____, t)
return {edge.ax + (edge.bx - edge.ax) * t, edge.ay + (edge.by - edge.ay) * t}
end
local parts = {}
do
local i = 0
while i + 1 < #stops do
do
if stops[i + 1 + 1] - stops[i + 1] < 1e-7 then
goto __continue29
end
local ax, ay = table.unpack(
at(nil, stops[i + 1]),
1,
2
)
local bx, by = table.unpack(
at(nil, stops[i + 1 + 1]),
1,
2
)
parts[#parts + 1] = {ax = ax, ay = ay, bx = bx, by = by}
end
::__continue29::
i = i + 1
end
end
return parts
end
)
end
function ____exports.combineOutlines(self, first, second, operation)
local function within(____, x, y)
local a = ____exports.insideOutline(nil, first, x, y)
local b = ____exports.insideOutline(nil, second, x, y)
local ____temp_2
if operation == "add" then
____temp_2 = a or b
else
local ____temp_1
if operation == "cut" then
____temp_1 = a and not b
else
____temp_1 = a and b
end
____temp_2 = ____temp_1
end
return ____temp_2
end
local edgesA, edgesB = edgesOf(nil, first), edgesOf(nil, second)
local kept = __TS__New(Map)
local ____array_3 = __TS__SparseArrayNew(table.unpack(pieces(nil, edgesA, edgesB)))
__TS__SparseArrayPush(
____array_3,
table.unpack(pieces(nil, edgesB, edgesA))
)
for ____, edge in ipairs({__TS__SparseArraySpread(____array_3)}) do
do
local dx, dy = edge.bx - edge.ax, edge.by - edge.ay
local length = __hypot(nil, dx, dy)
if length < 1e-7 then
goto __continue33
end
local mx, my = (edge.ax + edge.bx) / 2, (edge.ay + edge.by) / 2
local step = math.min(0.00001, length / 4)
local nx, ny = -dy / length * step, dx / length * step
local left = within(nil, mx + nx, my + ny)
local right = within(nil, mx - nx, my - ny)
if left == right then
goto __continue33
end
local directed = left and edge or ({ax = edge.bx, ay = edge.by, bx = edge.ax, by = edge.ay})
kept:set(
(key(nil, directed.ax, directed.ay) .. ">") .. key(nil, directed.bx, directed.by),
directed
)
end
::__continue33::
end
local from = __TS__New(Map)
for ____, edge in __TS__Iterator(kept:values()) do
local start = key(nil, edge.ax, edge.ay)
local ____from_set_5 = from.set
local ____array_4 = __TS__SparseArrayNew(table.unpack(from:get(start) or ({})))
__TS__SparseArrayPush(____array_4, edge)
____from_set_5(
from,
start,
{__TS__SparseArraySpread(____array_4)}
)
end
local rings = {}
for ____, start in ipairs({__TS__Spread(from:keys())}) do
do
while true do
local ring = {}
local at = start
do
local guard = 0
while guard < 100000 do
local ____opt_6 = from:get(at)
local edge = ____opt_6 and table.remove(from:get(at))
if not edge then
break
end
ring[#ring + 1] = {edge.ax, edge.ay}
at = key(nil, edge.bx, edge.by)
if at == start then
break
end
guard = guard + 1
end
end
if #ring == 0 then
break
end
if #ring >= 3 and at == start and math.abs(____exports.ringArea(nil, ring)) > 1e-10 then
rings[#rings + 1] = withoutStraightPoints(nil, ring)
end
end
end
end
return __TS__ArrayFilter(
rings,
function(____, ring) return #ring >= 3 end
)
end
return ____exports
end,
["core.model.sketch.index"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local Map = ____lualib.Map
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __lor = ______shims.__lor
local __or = ______shims.__or
local __shl = ______shims.__shl
local __sort = ______shims.__sort
local __t = ______shims.__t
local ____outline = require("core.model.outline.index")
local ringArea = ____outline.ringArea
local ROUND_STEPS = 8
local CIRCLE_STEPS = 32
local function unit(self, x, y)
local length = __lor(
nil,
__hypot(nil, x, y),
function() return 1 end
)
return {x / length, y / length, length}
end
function ____exports.circleRing(self, at, radius)
return __TS__ArrayFrom(
{length = CIRCLE_STEPS},
function(____, _, i)
local angle = i / CIRCLE_STEPS * math.pi * 2
return {
at[1] + math.cos(angle) * radius,
at[2] + math.sin(angle) * radius
}
end
)
end
function ____exports.roundedRing(self, points, radii, straight)
local out = {}
__TS__ArrayForEach(
points,
function(____, corner, i)
local radius = radii[i + 1] or 0
local before = points[(i + #points - 1) % #points + 1]
local after = points[(i + 1) % #points + 1]
local ux, uy, lu = table.unpack(
unit(nil, before[1] - corner[1], before[2] - corner[2]),
1,
3
)
local wx, wy, lw = table.unpack(
unit(nil, after[1] - corner[1], after[2] - corner[2]),
1,
3
)
local half = math.acos(math.max(
-1,
math.min(1, ux * wx + uy * wy)
)) / 2
if radius <= 0 or half < 0.02 or half > math.pi / 2 - 0.02 then
out[#out + 1] = corner
return
end
local reach = math.min(
radius / math.tan(half),
lu / 2,
lw / 2
)
local r = reach * math.tan(half)
local bx, by = table.unpack(
unit(nil, ux + wx, uy + wy),
1,
2
)
local centre = {
corner[1] + bx * r / math.sin(half),
corner[2] + by * r / math.sin(half)
}
local from = {corner[1] + ux * reach, corner[2] + uy * reach}
local to = {corner[1] + wx * reach, corner[2] + wy * reach}
local start = math.atan(from[2] - centre[2], from[1] - centre[1])
local sweep = math.atan(to[2] - centre[2], to[1] - centre[1]) - start
if sweep > math.pi then
sweep = sweep - math.pi * 2
end
if sweep < -math.pi then
sweep = sweep + math.pi * 2
end
if straight and straight[i + 1] then
__TS__ArrayPush(out, from, to)
return
end
do
local step = 0
while step <= ROUND_STEPS do
local angle = start + sweep * step / ROUND_STEPS
out[#out + 1] = {
centre[1] + math.cos(angle) * r,
centre[2] + math.sin(angle) * r
}
step = step + 1
end
end
end
)
return out
end
local function inside(self, ring, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
local hit = false
do
local i = 0
local j = #ring - 1
while i < #ring do
local a, b = ring[i + 1], ring[j + 1]
if a[2] > y ~= (b[2] > y) and x < (b[1] - a[1]) * (y - a[2]) / (b[2] - a[2]) + a[1] then
hit = not hit
end
local ____i_2 = i
i = ____i_2 + 1
j = ____i_2
end
end
return hit
end
local function pieceAt(____, shapes, at)
return __TS__ArrayReduce(
shapes,
function(____, piece, shape, i) return inside(nil, shape, at) and __or(
nil,
piece,
__shl(nil, 1, i)
) or piece end,
0
)
end
local function keyOf(____, p)
return (tostring(math.floor(p[1] * 100000 + 0.5)) .. ",") .. tostring(math.floor(p[2] * 100000 + 0.5))
end
function ____exports.pickedOutline(self, shapes, picks)
local picked = __TS__New(Set)
if picks and #picks > 0 then
for ____, pick in ipairs(picks) do
local piece = pieceAt(nil, shapes, pick)
if __t(nil, piece) then
picked:add(piece)
end
end
else
do
local piece = 1
while piece < __shl(nil, 1, #shapes) do
picked:add(piece)
piece = piece + 1
end
end
end
local edges = __TS__ArrayFilter(
__TS__ArrayFlatMap(
shapes,
function(____, shape) return __TS__ArrayMap(
shape,
function(____, a, i) return {a, shape[(i + 1) % #shape + 1]} end
) end
),
function(____, ____bindingPattern0)
local b
local a
a = ____bindingPattern0[1]
b = ____bindingPattern0[2]
return __hypot(nil, b[1] - a[1], b[2] - a[2]) > 1e-9
end
)
local pieces = {}
local seen = __TS__New(Set)
for ____, edge in ipairs(edges) do
local a, b = table.unpack(edge, 1, 2)
local d = {b[1] - a[1], b[2] - a[2]}
local length = __hypot(nil, d[1], d[2])
local cuts = {0, 1}
for ____, other in ipairs(edges) do
do
if other == edge then
goto __continue33
end
local c, e = table.unpack(other, 1, 2)
local f = {e[1] - c[1], e[2] - c[2]}
local cross = d[1] * f[2] - d[2] * f[1]
if math.abs(cross) > 1e-12 then
local t = ((c[1] - a[1]) * f[2] - (c[2] - a[2]) * f[1]) / cross
local u = ((c[1] - a[1]) * d[2] - (c[2] - a[2]) * d[1]) / cross
if t > 1e-9 and t < 1 - 1e-9 and u >= -1e-9 and u <= 1 + 1e-9 then
cuts[#cuts + 1] = t
end
goto __continue33
end
for ____, p in ipairs({c, e}) do
local t = ((p[1] - a[1]) * d[1] + (p[2] - a[2]) * d[2]) / (length * length)
local off = math.abs((p[1] - a[1]) * d[2] - (p[2] - a[2]) * d[1]) / length
if off < 1e-7 and t > 1e-9 and t < 1 - 1e-9 then
cuts[#cuts + 1] = t
end
end
end
::__continue33::
end
__sort(
nil,
cuts,
function(____, x, y) return x - y end
)
local left = {-d[2] / length * 0.0001, d[1] / length * 0.0001}
do
local i = 0
while i + 1 < #cuts do
do
local t0, t1 = cuts[i + 1], cuts[i + 1 + 1]
if t1 - t0 < 1e-9 then
goto __continue43
end
local p = {a[1] + d[1] * t0, a[2] + d[2] * t0}
local q = {a[1] + d[1] * t1, a[2] + d[2] * t1}
local middle = {(p[1] + q[1]) / 2, (p[2] + q[2]) / 2}
local onLeft = picked:has(pieceAt(nil, shapes, {middle[1] + left[1], middle[2] + left[2]}))
local onRight = picked:has(pieceAt(nil, shapes, {middle[1] - left[1], middle[2] - left[2]}))
if onLeft == onRight then
goto __continue43
end
local piece = onLeft and ({p, q}) or ({q, p})
local key = (keyOf(nil, piece[1]) .. ">") .. keyOf(nil, piece[2])
if not seen:has(key) then
seen:add(key)
pieces[#pieces + 1] = piece
end
end
::__continue43::
i = i + 1
end
end
end
local from = __TS__New(Map)
for ____, piece in ipairs(pieces) do
local ____from_set_5 = from.set
local ____keyOf_result_4 = keyOf(nil, piece[1])
local ____array_3 = __TS__SparseArrayNew(table.unpack(from:get(keyOf(nil, piece[1])) or ({})))
__TS__SparseArrayPush(____array_3, piece)
____from_set_5(
from,
____keyOf_result_4,
{__TS__SparseArraySpread(____array_3)}
)
end
local used = __TS__New(Set)
local outline = {}
for ____, first in ipairs(pieces) do
do
if used:has(first) then
goto __continue50
end
local ring = {}
local now = first
do
local guard = 0
while guard <= #pieces do
used:add(now)
ring[#ring + 1] = now[1]
if keyOf(nil, now[2]) == keyOf(nil, first[1]) then
break
end
local way = {now[2][1] - now[1][1], now[2][2] - now[1][2]}
local next
local most = -math.huge
for ____, candidate in ipairs(from:get(keyOf(nil, now[2])) or ({})) do
do
if used:has(candidate) then
goto __continue55
end
local to = {candidate[2][1] - candidate[1][1], candidate[2][2] - candidate[1][2]}
local turn = math.atan(way[1] * to[2] - way[2] * to[1], way[1] * to[1] + way[2] * to[2])
if turn > most then
most = turn
next = candidate
end
end
::__continue55::
end
if not next then
break
end
now = next
guard = guard + 1
end
end
local plain = __TS__ArrayFilter(
ring,
function(____, p, i)
local before, after = ring[(i + #ring - 1) % #ring + 1], ring[(i + 1) % #ring + 1]
return math.abs((p[1] - before[1]) * (after[2] - p[2]) - (p[2] - before[2]) * (after[1] - p[1])) > 1e-9
end
)
if #plain >= 3 and math.abs(ringArea(nil, plain)) > 1e-8 then
outline[#outline + 1] = plain
end
end
::__continue50::
end
return __sort(
nil,
outline,
function(____, x, y) return math.abs(ringArea(nil, y)) - math.abs(ringArea(nil, x)) end
)
end
return ____exports
end,
["core.model.solid.combine"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayReverse = ____lualib.__TS__ArrayReverse
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__Class = ____lualib.__TS__Class
local __TS__New = ____lualib.__TS__New
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __or = ______shims.__or
local EPSILON = 0.000001
local function dot(____, a, b)
return a[1] * b[1] + a[2] * b[2] + a[3] * b[3]
end
local function mix(____, a, b, t)
return {a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t, a[3] + (b[3] - a[3]) * t}
end
function ____exports.faceOf(self, corners)
local a, b, c = corners[1].at, corners[2].at, corners[3].at
local u, v = {b[1] - a[1], b[2] - a[2], b[3] - a[3]}, {c[1] - a[1], c[2] - a[2], c[3] - a[3]}
local n = {u[2] * v[3] - u[3] * v[2], u[3] * v[1] - u[1] * v[3], u[1] * v[2] - u[2] * v[1]}
local length = __hypot(nil, n[1], n[2], n[3])
if length < 1e-12 then
return nil
end
local normal = {n[1] / length, n[2] / length, n[3] / length}
return {
corners = corners,
plane = {
normal = normal,
w = dot(nil, normal, a)
}
}
end
local function turnedOver(____, face)
return {
corners = __TS__ArrayMap(
__TS__ArrayReverse({table.unpack(face.corners)}),
function(____, corner) return {at = corner.at, normal = {-corner.normal[1], -corner.normal[2], -corner.normal[3]}} end
),
plane = {normal = {-face.plane.normal[1], -face.plane.normal[2], -face.plane.normal[3]}, w = -face.plane.w}
}
end
local ON, FRONT, BACK, ACROSS = 0, 1, 2, 3
local function divide(self, plane, face, onFront, onBack, front, back)
local kind = 0
local sides = __TS__ArrayMap(
face.corners,
function(____, corner)
local distance = dot(nil, plane.normal, corner.at) - plane.w
local side = distance < -EPSILON and BACK or (distance > EPSILON and FRONT or ON)
kind = __or(nil, kind, side)
return side
end
)
if kind == ON then
local ____temp_0 = dot(nil, plane.normal, face.plane.normal) > 0 and onFront or onBack
____temp_0[#____temp_0 + 1] = face
elseif kind == FRONT then
front[#front + 1] = face
elseif kind == BACK then
back[#back + 1] = face
elseif kind == ACROSS then
local before, behind = {}, {}
__TS__ArrayForEach(
face.corners,
function(____, corner, i)
local j = (i + 1) % #face.corners
local next = face.corners[j + 1]
if sides[i + 1] ~= BACK then
before[#before + 1] = corner
end
if sides[i + 1] ~= FRONT then
behind[#behind + 1] = corner
end
if __or(nil, sides[i + 1], sides[j + 1]) == ACROSS then
local step = {next.at[1] - corner.at[1], next.at[2] - corner.at[2], next.at[3] - corner.at[3]}
local t = (plane.w - dot(nil, plane.normal, corner.at)) / dot(nil, plane.normal, step)
local cut = {
at = mix(nil, corner.at, next.at, t),
normal = mix(nil, corner.normal, next.normal, t)
}
before[#before + 1] = cut
behind[#behind + 1] = cut
end
end
)
if #before >= 3 then
front[#front + 1] = {corners = before, plane = face.plane}
end
if #behind >= 3 then
back[#back + 1] = {corners = behind, plane = face.plane}
end
end
end
local Tree = __TS__Class()
Tree.name = "Tree"
function Tree.prototype.____constructor(self, faces)
if faces == nil then
faces = {}
end
self.faces = {}
self:take(faces)
end
function Tree.prototype.take(self, all)
local node = self
local faces = all
while #faces > 0 do
if node.plane == nil then
node.plane = faces[1].plane
end
local front, back = {}, {}
for ____, face in ipairs(faces) do
divide(
nil,
node.plane,
face,
node.faces,
node.faces,
front,
back
)
end
if #front > 0 then
if node.front == nil then
node.front = __TS__New(Tree)
end
node.front:take(front)
end
if #back == 0 then
return
end
if node.back == nil then
node.back = __TS__New(Tree)
end
node = node.back
faces = back
end
end
function Tree.prototype.turnOver(self)
do
local node = self
while node do
local stack = {node}
while #stack > 0 do
local at = table.remove(stack)
at.faces = __TS__ArrayMap(at.faces, turnedOver)
if at.plane then
at.plane = {normal = {-at.plane.normal[1], -at.plane.normal[2], -at.plane.normal[3]}, w = -at.plane.w}
end
local ____temp_1 = {at.back, at.front}
at.front = ____temp_1[1]
at.back = ____temp_1[2]
if at.front then
stack[#stack + 1] = at.front
end
if at.back then
stack[#stack + 1] = at.back
end
end
node = nil
end
end
end
function Tree.prototype.outside(self, faces)
if not self.plane then
return faces
end
local front, back = {}, {}
for ____, face in ipairs(faces) do
divide(
nil,
self.plane,
face,
front,
back,
front,
back
)
end
local kept = self.front and self.front:outside(front) or front
local ____table_back_3
if self.back then
local ____array_2 = __TS__SparseArrayNew(table.unpack(kept))
__TS__SparseArrayPush(
____array_2,
table.unpack(self.back:outside(back))
)
____table_back_3 = {__TS__SparseArraySpread(____array_2)}
else
____table_back_3 = kept
end
return ____table_back_3
end
function Tree.prototype.clipTo(self, other)
local stack = {self}
while #stack > 0 do
local at = table.remove(stack)
at.faces = other:outside(at.faces)
if at.front then
stack[#stack + 1] = at.front
end
if at.back then
stack[#stack + 1] = at.back
end
end
end
function Tree.prototype.all(self)
local found = {}
local stack = {self}
while #stack > 0 do
local at = table.remove(stack)
__TS__ArrayPushArray(found, at.faces)
if at.front then
stack[#stack + 1] = at.front
end
if at.back then
stack[#stack + 1] = at.back
end
end
return found
end
function ____exports.joinBodies(self, first, second, joining)
local a = __TS__New(Tree, first)
local b = __TS__New(Tree, second)
if joining == "add" then
a:clipTo(b)
b:clipTo(a)
b:turnOver()
b:clipTo(a)
b:turnOver()
a:take(b:all())
return a:all()
end
a:turnOver()
if joining == "cut" then
a:clipTo(b)
b:clipTo(a)
b:turnOver()
b:clipTo(a)
b:turnOver()
else
b:clipTo(a)
b:turnOver()
a:clipTo(b)
b:clipTo(a)
end
a:take(b:all())
a:turnOver()
return a:all()
end
return ____exports
end,
["core.model.solid.index"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArraySplice = ____lualib.__TS__ArraySplice
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local __TS__ArrayReverse = ____lualib.__TS__ArrayReverse
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local __TS__New = ____lualib.__TS__New
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__MathSign = ____lualib.__TS__MathSign
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
local __TS__StringSlice = ____lualib.__TS__StringSlice
local ____exports = {}
local segmentsCross, inRing, withStraightPoints, inset, holds, safeChamfer, fractions, sampleRing, partners, wallRings, ringKept, meet, outlines, edgeCutter, cross, ROUND_STEPS
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __json = ______shims.__json
local __jsonParse = ______shims.__jsonParse
local __lor = ______shims.__lor
local __sort = ______shims.__sort
local __t = ______shims.__t
local ____outline = require("core.model.outline.index")
local ringArea = ____outline.ringArea
local ____sketch = require("core.model.sketch.index")
local roundedRing = ____sketch.roundedRing
local ____combine = require("core.model.solid.combine")
local faceOf = ____combine.faceOf
local joinBodies = ____combine.joinBodies
function segmentsCross(self, a, b, c, d)
local d1, d2, d3, d4 = cross(nil, c, d, a), cross(nil, c, d, b), cross(nil, a, b, c), cross(nil, a, b, d)
return d1 * d2 < -1e-14 and d3 * d4 < -1e-14
end
function inRing(self, ring, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
local inside = false
do
local i = 0
local j = #ring - 1
while i < #ring do
local ax, ay = table.unpack(ring[i + 1], 1, 2)
local bx, by = table.unpack(ring[j + 1], 1, 2)
if ay > y ~= (by > y) and x < (bx - ax) * (y - ay) / (by - ay) + ax then
inside = not inside
end
do
j = i
i = i + 1
end
end
end
return inside
end
function withStraightPoints(self, triangles, rings)
local list = {table.unpack(triangles)}
for ____, ring in ipairs(rings) do
__TS__ArrayForEach(
ring,
function(____, point)
do
local t = 0
while t < #list do
local tri = list[t + 1]
do
local e = 0
while e < 3 do
do
local u, v, w = tri[e + 1], tri[(e + 1) % 3 + 1], tri[(e + 2) % 3 + 1]
local length = __hypot(nil, v[1] - u[1], v[2] - u[2])
if point == u or point == v or length < 1e-12 then
goto __continue44
end
local along = ((point[1] - u[1]) * (v[1] - u[1]) + (point[2] - u[2]) * (v[2] - u[2])) / (length * length)
if along <= 1e-9 or along >= 1 - 1e-9 or math.abs(cross(nil, u, v, point)) / length > 1e-9 then
goto __continue44
end
__TS__ArraySplice(
list,
t,
1,
{u, point, w},
{point, v, w}
)
return
end
::__continue44::
e = e + 1
end
end
t = t + 1
end
end
end
)
end
return list
end
function inset(self, ring, distance)
if distance == 0 then
return ring
end
return __TS__ArrayMap(
ring,
function(____, point, i)
local before = ring[(i + #ring - 1) % #ring + 1]
local after = ring[(i + 1) % #ring + 1]
local function inward(____, from, to)
local length = __lor(
nil,
__hypot(nil, to[1] - from[1], to[2] - from[2]),
function() return 1 end
)
return {-(to[2] - from[2]) / length, (to[1] - from[1]) / length}
end
local n1, n2 = inward(nil, before, point), inward(nil, point, after)
local sum = __lor(
nil,
__hypot(nil, n1[1] + n2[1], n1[2] + n2[2]),
function() return 1 end
)
local reach = math.min(
1.5 / sum,
1 / math.max(0.05, 1 + n1[1] * n2[1] + n1[2] * n2[2])
)
return {point[1] + (n1[1] + n2[1]) * reach * distance, point[2] + (n1[2] + n2[2]) * reach * distance}
end
)
end
function holds(self, rings, distance)
local drawn = __TS__ArrayMap(
rings,
function(____, ring) return inset(nil, ring, distance) end
)
local edges = {}
do
local r = 0
while r < #rings do
local before, after = rings[r + 1], drawn[r + 1]
do
local i = 0
while i < #before do
local j = (i + 1) % #before
local kept = (before[j + 1][1] - before[i + 1][1]) * (after[j + 1][1] - after[i + 1][1]) + (before[j + 1][2] - before[i + 1][2]) * (after[j + 1][2] - after[i + 1][2])
if kept <= 0 then
return false
end
edges[#edges + 1] = {after[i + 1], after[j + 1]}
i = i + 1
end
end
r = r + 1
end
end
do
local a = 0
while a < #edges do
do
local b = a + 1
while b < #edges do
if segmentsCross(
nil,
edges[a + 1][1],
edges[a + 1][2],
edges[b + 1][1],
edges[b + 1][2]
) then
return false
end
b = b + 1
end
end
a = a + 1
end
end
local bodies = __TS__ArrayFilter(
drawn,
function(____, _, r) return ringArea(nil, rings[r + 1]) > 0 end
)
return __TS__ArrayEvery(
drawn,
function(____, ring, r) return ringArea(nil, rings[r + 1]) >= 0 or __TS__ArrayEvery(
ring,
function(____, point) return __TS__ArraySome(
bodies,
function(____, body) return inRing(nil, body, point) end
) end
) end
)
end
function safeChamfer(self, rings, wanted)
if wanted <= 0 or holds(nil, rings, wanted) then
return math.max(0, wanted)
end
local low, high = 0, wanted
do
local step = 0
while step < 7 do
local middle = (low + high) / 2
if holds(nil, rings, middle) then
low = middle
else
high = middle
end
step = step + 1
end
end
return low * 0.9
end
function fractions(self, ring)
local lengths = __TS__ArrayMap(
ring,
function(____, p, i)
local q = ring[(i + 1) % #ring + 1]
return __hypot(nil, q[1] - p[1], q[2] - p[2])
end
)
local total = __lor(
nil,
__TS__ArrayReduce(
lengths,
function(____, sum, length) return sum + length end,
0
),
function() return 1 end
)
local run = 0
return __TS__ArrayMap(
lengths,
function(____, length)
local at = run / total
run = run + length
return at
end
)
end
function sampleRing(self, ring, at, where)
return __TS__ArrayMap(
where,
function(____, t)
local i = #at - 1
while i > 0 and at[i + 1] > t do
i = i - 1
end
local next = i + 1 < #at and at[i + 1 + 1] or 1
local k = next - at[i + 1] > 1e-12 and (t - at[i + 1]) / (next - at[i + 1]) or 0
local p, q = ring[i + 1], ring[(i + 1) % #ring + 1]
return {p[1] + (q[1] - p[1]) * k, p[2] + (q[2] - p[2]) * k}
end
)
end
function partners(self, bottom, top)
local function middle(____, ring)
return {
__TS__ArrayReduce(
ring,
function(____, sum, p) return sum + p[1] end,
0
) / #ring,
__TS__ArrayReduce(
ring,
function(____, sum, p) return sum + p[2] end,
0
) / #ring
}
end
local upper = ringArea(nil, top) * ringArea(nil, bottom) < 0 and __TS__ArrayReverse({table.unpack(top)}) or top
local mb, mt = middle(nil, bottom), middle(nil, upper)
local way = math.atan(bottom[1][2] - mb[2], bottom[1][1] - mb[1])
local start = 0
local nearest = math.huge
__TS__ArrayForEach(
upper,
function(____, p, i)
local off = math.abs(math.atan(
math.sin(math.atan(p[2] - mt[2], p[1] - mt[1]) - way),
math.cos(math.atan(p[2] - mt[2], p[1] - mt[1]) - way)
))
if off < nearest then
nearest = off
start = i
end
end
)
local ____array_3 = __TS__SparseArrayNew(table.unpack(__TS__ArraySlice(upper, start)))
__TS__SparseArrayPush(
____array_3,
table.unpack(__TS__ArraySlice(upper, 0, start))
)
upper = {__TS__SparseArraySpread(____array_3)}
local fb, ft = fractions(nil, bottom), fractions(nil, upper)
local ____sort_5 = __sort
local ____array_4 = __TS__SparseArrayNew(table.unpack(fb))
__TS__SparseArrayPush(
____array_4,
table.unpack(ft)
)
local all = __TS__ArrayFilter(
____sort_5(
nil,
{__TS__SparseArraySpread(____array_4)},
function(____, a, b) return a - b end
),
function(____, t, i, list) return i == 0 or t - list[i] > 0.0001 end
)
return {
sampleRing(nil, bottom, fb, all),
sampleRing(nil, upper, ft, all)
}
end
function wallRings(self, ring, height, walls)
if #walls == 0 then
return {ring, ring}
end
local count = #ring
local function planes(____, part)
return __TS__ArrayMap(
ring,
function(____, p, i)
local q = ring[(i + 1) % count + 1]
local length = __lor(
nil,
__hypot(nil, q[1] - p[1], q[2] - p[2]),
function() return 1 end
)
local n = {(q[2] - p[2]) / length, -(q[1] - p[1]) / length}
local own = __TS__ArrayFind(
walls,
function(____, ____bindingPattern0)
local at
at = ____bindingPattern0[2]
return at == i
end
)
local push = (own and own[3] or 0) * part
local lean = math.tan((own and own[4] or 0) * part * math.pi / 180)
return {n = n, c = n[1] * p[1] + n[2] * p[2] + push, lean = lean}
end
)
end
local function rings(____, part)
local own = planes(nil, part)
return {
meet(nil, ring, own, 0),
meet(nil, ring, own, height)
}
end
local function keeps(____, ____bindingPattern0)
local high
local low
low = ____bindingPattern0[1]
high = ____bindingPattern0[2]
return __TS__ArrayEvery(
{low, high},
function(____, moved) return ringKept(nil, ring, moved) end
)
end
if keeps(
nil,
rings(nil, 1)
) then
return rings(nil, 1)
end
local fine, over = 0, 1
do
local step = 0
while step < 8 do
local middle = (fine + over) / 2
if keeps(
nil,
rings(nil, middle)
) then
fine = middle
else
over = middle
end
step = step + 1
end
end
return rings(nil, fine * 0.98)
end
function ringKept(self, before, after)
local count = #before
do
local i = 0
while i < count do
local j = (i + 1) % count
local kept = (before[j + 1][1] - before[i + 1][1]) * (after[j + 1][1] - after[i + 1][1]) + (before[j + 1][2] - before[i + 1][2]) * (after[j + 1][2] - after[i + 1][2])
if kept <= 1e-12 then
return false
end
i = i + 1
end
end
do
local a = 0
while a < count do
do
local b = a + 2
while b < count do
do
if (b + 1) % count == a then
goto __continue113
end
if segmentsCross(
nil,
after[a + 1],
after[(a + 1) % count + 1],
after[b + 1],
after[(b + 1) % count + 1]
) then
return false
end
end
::__continue113::
b = b + 1
end
end
a = a + 1
end
end
return true
end
function meet(self, ring, planes, y)
local count = #ring
return __TS__ArrayMap(
ring,
function(____, p, i)
local a, b = planes[(i + count - 1) % count + 1], planes[i + 1]
local ca, cb = a.c - a.lean * y, b.c - b.lean * y
local det = a.n[1] * b.n[2] - a.n[2] * b.n[1]
if math.abs(det) < 0.000001 then
local da, db = ca - (a.n[1] * p[1] + a.n[2] * p[2]), cb - (b.n[1] * p[1] + b.n[2] * p[2])
return {p[1] + (a.n[1] * da + b.n[1] * db) / 2, p[2] + (a.n[2] * da + b.n[2] * db) / 2}
end
return {(ca * b.n[2] - cb * a.n[2]) / det, (a.n[1] * cb - b.n[1] * ca) / det}
end
)
end
function outlines(self, shape)
local width, ____, depth = table.unpack(shape.size, 1, 3)
local function place(____, ring)
return __TS__ArrayMap(
ring,
function(____, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
return {(x - 0.5) * width, (y - 0.5) * depth}
end
)
end
local function rounded(____, placed, r)
local own = __TS__ArrayFilter(
shape.corners or ({}),
function(____, ____bindingPattern0)
local at
at = ____bindingPattern0[1]
return at == r
end
)
if #own == 0 then
return placed
end
local sizes = __TS__ArrayMap(
placed,
function(____, _, i)
local ____opt_10 = __TS__ArrayFind(
own,
function(____, ____bindingPattern0)
local at
at = ____bindingPattern0[2]
return at == i
end
)
return ____opt_10 and ____opt_10[3] or 0
end
)
local straight = __TS__ArrayMap(
placed,
function(____, _, i)
local ____opt_12 = __TS__ArrayFind(
own,
function(____, ____bindingPattern0)
local at
at = ____bindingPattern0[2]
return at == i
end
)
return (____opt_12 and ____opt_12[4]) == 0
end
)
return roundedRing(nil, placed, sizes, straight)
end
local walled = __TS__ArrayMap(
shape.rings,
function(____, ring, r) return wallRings(
nil,
place(nil, ring),
shape.size[2],
__TS__ArrayFilter(
shape.walls or ({}),
function(____, ____bindingPattern0)
local at
at = ____bindingPattern0[1]
return at == r
end
)
) end
)
local bottom = __TS__ArrayMap(
walled,
function(____, ____bindingPattern0, r)
local low
low = ____bindingPattern0[1]
return rounded(nil, low, r)
end
)
local upper = __TS__ArrayMap(
walled,
function(____, ____bindingPattern0, r)
local high
high = ____bindingPattern0[2]
return rounded(nil, high, r)
end
)
local dx, dz = table.unpack(shape.shift or ({0, 0}), 1, 2)
local wanted = shape.taper or 0
local taper = wanted > 0 and safeChamfer(
nil,
shape.top and __TS__ArrayMap(shape.top, place) or upper,
wanted
) or wanted
local function moved(____, ring)
return __TS__ArrayMap(
inset(nil, ring, taper),
function(____, ____bindingPattern0)
local z
local x
x = ____bindingPattern0[1]
z = ____bindingPattern0[2]
return {x + dx, z + dz}
end
)
end
local ____opt_14 = shape.top
local own = ____opt_14 and __TS__ArrayMap(shape.top, place)
if not own or #own ~= #bottom then
return {
bottom = bottom,
top = __TS__ArrayMap(
upper,
function(____, ring, r) return #ring == #bottom[r + 1] and moved(nil, ring) or moved(
nil,
partners(nil, bottom[r + 1], ring)[2]
) end
)
}
end
local ____pairs = __TS__ArrayMap(
bottom,
function(____, ring, r) return partners(nil, ring, own[r + 1]) end
)
return {
bottom = __TS__ArrayMap(
____pairs,
function(____, ____bindingPattern0)
local b
b = ____bindingPattern0[1]
return b
end
),
top = __TS__ArrayMap(
____pairs,
function(____, ____bindingPattern0)
local t
t = ____bindingPattern0[2]
return moved(nil, t)
end
)
}
end
function edgeCutter(self, shape, ____bindingPattern0)
local round
local top
local size
local i
local r
r = ____bindingPattern0[1]
i = ____bindingPattern0[2]
size = ____bindingPattern0[3]
top = ____bindingPattern0[4]
round = ____bindingPattern0[5]
local width, height, depth = table.unpack(shape.size, 1, 3)
local ring = shape.rings[r + 1]
if not ring or size <= 0 or not ring[i + 1] then
return nil
end
local function place(____, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
return {(x - 0.5) * width, (y - 0.5) * depth}
end
local ____temp_38 = __t(nil, top) and not shape.top
if ____temp_38 then
local ____opt_36 = shape.corners
____temp_38 = not (____opt_36 and __TS__ArraySome(
shape.corners,
function(____, ____bindingPattern0)
local at
at = ____bindingPattern0[1]
return at == r
end
))
end
local moved = ____temp_38 and outlines(nil, shape).top[r + 1] or nil
local a, b = table.unpack(
moved and ({moved[i + 1], moved[(i + 1) % #moved + 1]}) or ({
place(nil, ring[i + 1]),
place(nil, ring[(i + 1) % #ring + 1])
}),
1,
2
)
local length = __hypot(nil, b[1] - a[1], b[2] - a[2])
if length < 1e-9 then
return nil
end
local along = {(b[1] - a[1]) / length, 0, (b[2] - a[2]) / length}
local out = {along[3], 0, -along[1]}
local away = {
0,
__t(nil, top) and 1 or -1,
0
}
local y = __t(nil, top) and height or 0
local s = math.min(size, height / 2, length / 2)
local e = s * 0.05 + 0.0001
local section = {{e, e}, {e, -s}}
if __t(nil, round) then
do
local k = 0
while k <= ROUND_STEPS * 2 do
local angle = k / (ROUND_STEPS * 2) * (math.pi / 2)
section[#section + 1] = {
-s + s * math.cos(angle),
-s + s * math.sin(angle)
}
k = k + 1
end
end
else
__TS__ArrayPush(section, {0, -s}, {-s, 0})
end
section[#section + 1] = {-s, e}
local ends = {-e, length + e}
local function point(____, o, w, t)
return {a[1] + along[1] * t + out[1] * o, y + away[2] * w, a[2] + along[3] * t + out[3] * o}
end
local positions = {}
local normals = {}
local function triangle(____, p, q, t, facing)
local u = {q[1] - p[1], q[2] - p[2], q[3] - p[3]}
local v = {t[1] - p[1], t[2] - p[2], t[3] - p[3]}
local n = {u[2] * v[3] - u[3] * v[2], u[3] * v[1] - u[1] * v[3], u[1] * v[2] - u[2] * v[1]}
local length = __hypot(nil, n[1], n[2], n[3])
if length < 1e-14 then
return
end
local flip = n[1] * facing[1] + n[2] * facing[2] + n[3] * facing[3] < 0
n = {n[1] / length, n[2] / length, n[3] / length}
local corners = flip and ({p, t, q}) or ({p, q, t})
for ____, c in ipairs(corners) do
__TS__ArrayPushArray(positions, c)
__TS__ArrayPushArray(normals, flip and ({-n[1], -n[2], -n[3]}) or n)
end
end
local count = #section
local turning = __lor(
nil,
__TS__MathSign(__TS__ArrayReduce(
section,
function(____, sum, ____bindingPattern0, k)
local w1
local o1
o1 = ____bindingPattern0[1]
w1 = ____bindingPattern0[2]
return sum + o1 * section[(k + 1) % count + 1][2] - section[(k + 1) % count + 1][1] * w1
end,
0
)),
function() return 1 end
)
do
local k = 0
while k < count do
local o1, w1 = table.unpack(section[k + 1], 1, 2)
local o2, w2 = table.unpack(section[(k + 1) % count + 1], 1, 2)
local no, nw = (w2 - w1) * turning, -(o2 - o1) * turning
local facing = {out[1] * no, away[2] * nw, out[3] * no}
local p, q, t, u = point(nil, o1, w1, ends[1]), point(nil, o2, w2, ends[1]), point(nil, o2, w2, ends[2]), point(nil, o1, w1, ends[2])
triangle(
nil,
p,
q,
t,
facing
)
triangle(
nil,
p,
t,
u,
facing
)
k = k + 1
end
end
for ____, ____value in ipairs({{ends[1], -1}, {ends[2], 1}}) do
local t = ____value[1]
local way = ____value[2]
do
local k = 1
while k + 1 < count do
triangle(
nil,
point(nil, section[1][1], section[1][2], t),
point(nil, section[k + 1][1], section[k + 1][2], t),
point(nil, section[k + 1 + 1][1], section[k + 1 + 1][2], t),
{along[1] * way, 0, along[3] * way}
)
k = k + 1
end
end
end
return {
positions = __TS__New(Float32Array, positions),
normals = __TS__New(Float32Array, normals)
}
end
cross = function(____, o, a, b) return (a[1] - o[1]) * (b[2] - o[2]) - (a[2] - o[2]) * (b[1] - o[1]) end
local function withBridges(self, body, holes)
local line = {table.unpack(body)}
local left = __sort(
nil,
{table.unpack(holes)},
function(____, a, b) return math.max(table.unpack(__TS__ArrayMap(
b,
function(____, p) return p[1] end
))) - math.max(table.unpack(__TS__ArrayMap(
a,
function(____, p) return p[1] end
))) end
)
for ____, hole in ipairs(left) do
do
local best
local nearest = math.huge
local ____array_0 = __TS__SparseArrayNew(table.unpack(__TS__ArrayMap(
line,
function(____, p, i) return {p, line[(i + 1) % #line + 1]} end
)))
__TS__SparseArrayPush(
____array_0,
table.unpack(__TS__ArrayFlatMap(
left,
function(____, other) return __TS__ArrayMap(
other,
function(____, p, i) return {p, other[(i + 1) % #other + 1]} end
) end
))
)
local edges = {__TS__SparseArraySpread(____array_0)}
do
local h = 0
while h < #hole do
do
local l = 0
while l < #line do
do
local distance = __hypot(nil, hole[h + 1][1] - line[l + 1][1], hole[h + 1][2] - line[l + 1][2])
if distance >= nearest or __TS__ArraySome(
edges,
function(____, ____bindingPattern0)
local d
local c
c = ____bindingPattern0[1]
d = ____bindingPattern0[2]
return segmentsCross(
nil,
hole[h + 1],
line[l + 1],
c,
d
)
end
) then
goto __continue19
end
nearest = distance
best = {h, l}
end
::__continue19::
l = l + 1
end
end
h = h + 1
end
end
if not best then
goto __continue12
end
local h, l = table.unpack(best, 1, 2)
local ____array_1 = __TS__SparseArrayNew(table.unpack(__TS__ArraySlice(hole, h)))
__TS__SparseArrayPush(
____array_1,
table.unpack(__TS__ArraySlice(hole, 0, h))
)
__TS__SparseArrayPush(____array_1, hole[h + 1])
local round = {__TS__SparseArraySpread(____array_1)}
local ____array_2 = __TS__SparseArrayNew(table.unpack(__TS__ArraySlice(line, 0, l + 1)))
__TS__SparseArrayPush(
____array_2,
table.unpack(round)
)
__TS__SparseArrayPush(
____array_2,
table.unpack(__TS__ArraySlice(line, l))
)
line = {__TS__SparseArraySpread(____array_2)}
end
::__continue12::
end
return line
end
local function ears(self, line)
local triangles = {}
local rest = {table.unpack(line)}
local guard = #rest * #rest + 8
while #rest > 3 and guard > 0 do
guard = guard - 1
local cut = false
do
local i = 0
while i < #rest do
do
local a, b, c = rest[(i + #rest - 1) % #rest + 1], rest[i + 1], rest[(i + 1) % #rest + 1]
if cross(nil, a, b, c) <= 1e-14 then
goto __continue27
end
local blocked = __TS__ArraySome(
rest,
function(____, p) return p ~= a and p ~= b and p ~= c and cross(nil, a, b, p) > 1e-12 and cross(nil, b, c, p) > 1e-12 and cross(nil, c, a, p) > 1e-12 end
)
if blocked then
goto __continue27
end
triangles[#triangles + 1] = {a, b, c}
__TS__ArraySplice(rest, i, 1)
cut = true
break
end
::__continue27::
i = i + 1
end
end
if not cut then
__TS__ArraySplice(rest, 0, 1)
end
end
if #rest == 3 and math.abs(cross(nil, rest[1], rest[2], rest[3])) > 1e-14 then
triangles[#triangles + 1] = {rest[1], rest[2], rest[3]}
end
return triangles
end
local function triangulate(self, rings, keepStraight)
if keepStraight == nil then
keepStraight = false
end
local bodies = __TS__ArrayFilter(
rings,
function(____, ring) return ringArea(nil, ring) > 0 end
)
local holes = __TS__ArrayFilter(
rings,
function(____, ring) return ringArea(nil, ring) < 0 end
)
local triangles = __TS__ArrayFlatMap(
bodies,
function(____, body) return ears(
nil,
withBridges(
nil,
body,
__TS__ArrayFilter(
holes,
function(____, hole) return inRing(nil, body, hole[1]) end
)
)
) end
)
return keepStraight and withStraightPoints(nil, triangles, rings) or triangles
end
local SMOOTH = math.cos(32 * math.pi / 180)
ROUND_STEPS = 6
function ____exports.solidOutlines(self, shape)
return outlines(nil, shape)
end
local function plainSolid(self, shape)
local width, height, depth = table.unpack(shape.size, 1, 3)
local ____outlines_result_16 = outlines(nil, shape)
local rings = ____outlines_result_16.bottom
local tops = ____outlines_result_16.top
local ____temp_23 = shape.top ~= nil or Boolean(nil, shape.taper)
if not ____temp_23 then
local ____Boolean_22 = Boolean
local ____lor_21 = __lor
local ____opt_17 = shape.shift
____temp_23 = ____Boolean_22(
nil,
____lor_21(
nil,
____opt_17 and ____opt_17[1],
function()
local ____opt_19 = shape.shift
return ____opt_19 and ____opt_19[2]
end
)
)
end
local ____temp_23_27 = ____temp_23
if not ____temp_23_27 then
local ____Boolean_26 = Boolean
local ____opt_24 = shape.walls
____temp_23_27 = ____Boolean_26(nil, ____opt_24 and #____opt_24)
end
local lofted = ____temp_23_27
local function ringAt(____, r, y)
if not lofted then
return rings[r + 1]
end
local t = height > 0 and y / height or 0
return __TS__ArrayMap(
rings[r + 1],
function(____, p, i) return {p[1] + (tops[r + 1][i + 1][1] - p[1]) * t, p[2] + (tops[r + 1][i + 1][2] - p[2]) * t} end
)
end
local function most(____, wanted)
return math.max(
0,
math.min(
wanted,
height / 2 - 0.000001,
math.min(width, depth) / 4
)
)
end
local top = safeChamfer(
nil,
tops,
most(nil, shape.chamfer)
)
local bottom = safeChamfer(
nil,
rings,
most(nil, shape.chamferBottom or shape.chamfer)
)
local steps = shape.round and ROUND_STEPS or 1
local function profile(____, size)
return __TS__ArrayFrom(
{length = steps + 1},
function(____, _, k)
local angle = k / steps * (math.pi / 2)
return shape.round and ({
inward = size * (1 - math.cos(angle)),
along = size * math.sin(angle),
out = math.cos(angle),
up = math.sin(angle)
}) or ({inward = size * (k / steps), along = size * (k / steps), out = 0.7071067811865476, up = 0.7071067811865476})
end
)
end
local rims = {
{
size = top,
profile = profile(nil, top),
from = height - top,
way = 1
},
{
size = bottom,
profile = profile(nil, bottom),
from = bottom,
way = -1
}
}
local positions = {}
local normals = {}
local function corner(____, p, y, n)
__TS__ArrayPush(positions, p[1], y, p[2])
__TS__ArrayPush(normals, n[1], n[2], n[3])
end
local function triangle(____, a, b, c, n)
local u = {b[1][1] - a[1][1], b[2] - a[2], b[1][2] - a[1][2]}
local v = {c[1][1] - a[1][1], c[2] - a[2], c[1][2] - a[1][2]}
local face = {u[2] * v[3] - u[3] * v[2], u[3] * v[1] - u[1] * v[3], u[1] * v[2] - u[2] * v[1]}
local mean = {n[1][1] + n[2][1] + n[3][1], n[1][2] + n[2][2] + n[3][2], n[1][3] + n[2][3] + n[3][3]}
if face[1] * mean[1] + face[2] * mean[2] + face[3] * mean[3] >= 0 then
corner(nil, a[1], a[2], n[1])
corner(nil, b[1], b[2], n[2])
corner(nil, c[1], c[2], n[3])
else
corner(nil, a[1], a[2], n[1])
corner(nil, c[1], c[2], n[3])
corner(nil, b[1], b[2], n[2])
end
end
local function quad(____, a, b, c, d, n)
triangle(
nil,
a,
b,
c,
{n[1], n[2], n[3]}
)
triangle(
nil,
a,
c,
d,
{n[1], n[3], n[4]}
)
end
for ____, ____value in ipairs({{rims[1], height, 1}, {rims[2], 0, -1}}) do
local rim = ____value[1]
local y = ____value[2]
local up = ____value[3]
local caps = __TS__ArrayMap(
y > 0 and tops or rings,
function(____, ring) return inset(nil, ring, rim.size) end
)
for ____, ____value in ipairs(triangulate(nil, caps, shape.top ~= nil)) do
local a = ____value[1]
local b = ____value[2]
local c = ____value[3]
triangle(
nil,
{a, y},
{b, y},
{c, y},
{{0, up, 0}, {0, up, 0}, {0, up, 0}}
)
end
end
__TS__ArrayForEach(
rings,
function(____, ground, r)
local count = #ground
local ring = ringAt(nil, r, height / 2)
local out = __TS__ArrayMap(
ring,
function(____, point, i)
local next = ring[(i + 1) % count + 1]
local length = __lor(
nil,
__hypot(nil, next[1] - point[1], next[2] - point[2]),
function() return 1 end
)
return {(next[2] - point[2]) / length, -(next[1] - point[1]) / length}
end
)
local function at(____, i, wall)
local other = out[(i == wall and wall + count - 1 or wall + 1) % count + 1]
local own = out[wall + 1]
if own[1] * other[1] + own[2] * other[2] < SMOOTH then
return own
end
local length = __lor(
nil,
__hypot(nil, own[1] + other[1], own[2] + other[2]),
function() return 1 end
)
return {(own[1] + other[1]) / length, (own[2] + other[2]) / length}
end
local drawn = __TS__ArrayMap(
rims,
function(____, rim) return __TS__ArrayMap(
rim.profile,
function(____, step)
local level = ringAt(nil, r, rim.from + rim.way * step.along)
return step.inward > 0 and inset(nil, level, step.inward) or level
end
) end
)
local low, high = ringAt(nil, r, bottom), ringAt(nil, r, height - top)
local function lean(____, n, i)
return height > 0 and ((tops[r + 1][i + 1][1] - ground[i + 1][1]) * n[1] + (tops[r + 1][i + 1][2] - ground[i + 1][2]) * n[2]) / height or 0
end
do
local i = 0
while i < count do
local j = (i + 1) % count
local ni, nj = at(nil, i, i), at(nil, j, i)
local function side(____, n, k)
local up = lofted and -lean(nil, n, k) or 0
local length = __lor(
nil,
__hypot(nil, n[1], up, n[2]),
function() return 1 end
)
return {n[1] / length, up / length, n[2] / length}
end
quad(
nil,
{low[i + 1], bottom},
{low[j + 1], bottom},
{high[j + 1], height - top},
{high[i + 1], height - top},
{
side(nil, ni, i),
side(nil, nj, j),
side(nil, nj, j),
side(nil, ni, i)
}
)
__TS__ArrayForEach(
rims,
function(____, rim, r)
if rim.size <= 0 then
return
end
local function facing(____, n, k)
local step = rim.profile[k + 1]
local length = __lor(
nil,
__hypot(nil, step.out, step.up),
function() return 1 end
)
return {n[1] * step.out / length, rim.way * step.up / length, n[2] * step.out / length}
end
do
local k = 0
while k < steps do
local a, b = rim.profile[k + 1], rim.profile[k + 1 + 1]
local ya, yb = rim.from + rim.way * a.along, rim.from + rim.way * b.along
local ka, kb = table.unpack(shape.round and ({k, k + 1}) or ({0, 0}), 1, 2)
quad(
nil,
{drawn[r + 1][k + 1][i + 1], ya},
{drawn[r + 1][k + 1][j + 1], ya},
{drawn[r + 1][k + 1 + 1][j + 1], yb},
{drawn[r + 1][k + 1 + 1][i + 1], yb},
{
facing(nil, ni, ka),
facing(nil, nj, ka),
facing(nil, nj, kb),
facing(nil, ni, kb)
}
)
k = k + 1
end
end
end
)
i = i + 1
end
end
end
)
return {
positions = __TS__New(Float32Array, positions),
normals = __TS__New(Float32Array, normals)
}
end
function ____exports.turn(self, ____bindingPattern0)
local z
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
z = ____bindingPattern0[3]
local a, b, c = table.unpack(
__TS__ArrayMap(
{x, y, z},
function(____, angle) return angle * math.pi / 180 end
),
1,
3
)
local sa, ca, sb, cb, sc, cc = math.sin(a), math.cos(a), math.sin(b), math.cos(b), math.sin(c), math.cos(c)
return {
cc * cb,
cc * sb * sa - sc * ca,
cc * sb * ca + sc * sa,
sc * cb,
sc * sb * sa + cc * ca,
sc * sb * ca - cc * sa,
-sb,
cb * sa,
cb * ca
}
end
local function facesOf(self, geometry, position, rotation)
if position == nil then
position = {0, 0, 0}
end
if rotation == nil then
rotation = {0, 0, 0}
end
local m = ____exports.turn(nil, rotation)
local function turned(____, x, y, z)
return {m[1] * x + m[2] * y + m[3] * z, m[4] * x + m[5] * y + m[6] * z, m[7] * x + m[8] * y + m[9] * z}
end
local faces = {}
local ____geometry_28 = geometry
local positions = ____geometry_28.positions
local normals = ____geometry_28.normals
do
local i = 0
while i < positions.length do
local corners = __TS__ArrayMap(
{0, 3, 6},
function(____, k)
local at = turned(nil, positions[i + k], positions[i + k + 1], positions[i + k + 2])
return {
at = {at[1] + position[1], at[2] + position[2], at[3] + position[3]},
normal = turned(nil, normals[i + k], normals[i + k + 1], normals[i + k + 2])
}
end
)
local face = faceOf(nil, corners)
if face then
faces[#faces + 1] = face
end
i = i + 9
end
end
return faces
end
function ____exports.buildSolid(self, shape)
local plain = plainSolid(nil, shape)
local ____t_31 = __t
local ____opt_29 = shape.joins
local ____temp_35 = not ____t_31(nil, ____opt_29 and #____opt_29)
if ____temp_35 then
local ____t_34 = __t
local ____opt_32 = shape.edges
____temp_35 = not ____t_34(nil, ____opt_32 and #____opt_32)
end
if ____temp_35 then
return plain
end
local faces = facesOf(nil, plain)
for ____, join in ipairs(shape.joins or ({})) do
faces = joinBodies(
nil,
faces,
facesOf(
nil,
plainSolid(nil, join),
join.position,
join.rotation
),
join.joining
)
end
for ____, edge in ipairs(shape.edges or ({})) do
local cutter = edgeCutter(nil, shape, edge)
if cutter then
faces = joinBodies(
nil,
faces,
facesOf(nil, cutter),
"cut"
)
end
end
local positions = {}
local normals = {}
for ____, face in ipairs(faces) do
do
local i = 1
while i + 1 < #face.corners do
for ____, corner in ipairs({face.corners[1], face.corners[i + 1], face.corners[i + 1 + 1]}) do
__TS__ArrayPushArray(positions, corner.at)
local length = __lor(
nil,
__hypot(
nil,
table.unpack(corner.normal)
),
function() return 1 end
)
__TS__ArrayPush(normals, corner.normal[1] / length, corner.normal[2] / length, corner.normal[3] / length)
end
i = i + 1
end
end
end
return {
positions = __TS__New(Float32Array, positions),
normals = __TS__New(Float32Array, normals)
}
end
____exports.SOLID_ASSET = "solid:"
____exports.solidAssetName = function(____, shape) return ____exports.SOLID_ASSET .. __json(nil, shape) end
function ____exports.solidOfAsset(self, asset)
if not __TS__StringStartsWith(asset, ____exports.SOLID_ASSET) then
return nil
end
do
local function ____catch()
return true, nil
end
local ____try, ____hasReturned, ____returnValue = pcall(function()
return true, __jsonParse(
nil,
__TS__StringSlice(asset, #____exports.SOLID_ASSET)
)
end)
if not ____try then
____hasReturned, ____returnValue = ____catch()
end
if ____hasReturned then
return ____returnValue
end
end
end
return ____exports
end,
["core.model.terrain.index"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
local __TS__StringSlice = ____lualib.__TS__StringSlice
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __json = ______shims.__json
local __jsonParse = ______shims.__jsonParse
local __lor = ______shims.__lor
local DEFAULT_DETAIL = 256
local MOST_DETAIL = 1024
function ____exports.terrainGrid(self, shape, columns, rows)
local most = math.min(
math.max(
math.floor((shape.detail or DEFAULT_DETAIL) + 0.5),
2
),
MOST_DETAIL
)
local scale = math.min(
1,
most / math.max(columns, rows)
)
return {
math.max(
2,
math.floor(columns * scale + 0.5)
),
math.max(
2,
math.floor(rows * scale + 0.5)
)
}
end
function ____exports.buildTerrain(self, shape, field)
local ____field_0 = field
local columns = ____field_0.columns
local rows = ____field_0.rows
local values = ____field_0.values
local width, rise, depth = table.unpack(shape.size, 1, 3)
local base = math.max(shape.base or rise * 0.25, 0)
local function x(____, column)
return (column / (columns - 1) - 0.5) * width
end
local function z(____, row)
return (row / (rows - 1) - 0.5) * depth
end
local function y(____, column, row)
return base + values[row * columns + column] * rise
end
local positions = __TS__New(Float32Array, columns * rows * 3)
local normals = __TS__New(Float32Array, columns * rows * 3)
local uvs = __TS__New(Float32Array, columns * rows * 2)
local stepX = width / (columns - 1)
local stepZ = depth / (rows - 1)
do
local row = 0
while row < rows do
do
local column = 0
while column < columns do
local at = row * columns + column
positions:set(
{
x(nil, column),
y(nil, column, row),
z(nil, row)
},
at * 3
)
uvs:set({column / (columns - 1), row / (rows - 1)}, at * 2)
local left = math.max(column - 1, 0)
local right = math.min(column + 1, columns - 1)
local far = math.max(row - 1, 0)
local near = math.min(row + 1, rows - 1)
local slopeX = (y(nil, right, row) - y(nil, left, row)) / ((right - left) * stepX)
local slopeZ = (y(nil, column, near) - y(nil, column, far)) / ((near - far) * stepZ)
local length = __hypot(nil, slopeX, 1, slopeZ)
normals:set({-slopeX / length, 1 / length, -slopeZ / length}, at * 3)
column = column + 1
end
end
row = row + 1
end
end
local indices = __TS__New(Uint32Array, (columns - 1) * (rows - 1) * 6)
local next = 0
do
local row = 0
while row < rows - 1 do
do
local column = 0
while column < columns - 1 do
local a = row * columns + column
local b = a + columns
indices:set({
a,
b,
a + 1,
a + 1,
b,
b + 1
}, next)
next = next + 6
column = column + 1
end
end
row = row + 1
end
end
local sidePositions = {}
local sideNormals = {}
local function wall(____, from, to, facing)
local ax, ay, az = x(nil, from[1]), y(nil, from[1], from[2]), z(nil, from[2])
local bx, by, bz = x(nil, to[1]), y(nil, to[1], to[2]), z(nil, to[2])
__TS__ArrayPush(
sidePositions,
ax,
ay,
az,
ax,
0,
az,
bx,
0,
bz,
ax,
ay,
az,
bx,
0,
bz,
bx,
by,
bz
)
do
local corner = 0
while corner < 6 do
__TS__ArrayPushArray(sideNormals, facing)
corner = corner + 1
end
end
end
do
local column = 0
while column < columns - 1 do
wall(nil, {column + 1, 0}, {column, 0}, {0, 0, -1})
wall(nil, {column, rows - 1}, {column + 1, rows - 1}, {0, 0, 1})
column = column + 1
end
end
do
local row = 0
while row < rows - 1 do
wall(nil, {0, row}, {0, row + 1}, {-1, 0, 0})
wall(nil, {columns - 1, row + 1}, {columns - 1, row}, {1, 0, 0})
row = row + 1
end
end
local w, d = width / 2, depth / 2
__TS__ArrayPush(
sidePositions,
-w,
0,
-d,
w,
0,
-d,
w,
0,
d,
-w,
0,
-d,
w,
0,
d,
-w,
0,
d
)
do
local corner = 0
while corner < 6 do
__TS__ArrayPush(sideNormals, 0, -1, 0)
corner = corner + 1
end
end
return {
top = {positions = positions, normals = normals, uvs = uvs, indices = indices},
sides = {
positions = __TS__New(Float32Array, sidePositions),
normals = __TS__New(Float32Array, sideNormals)
}
}
end
function ____exports.resampleHeights(self, field, columns, rows)
if columns == field.columns and rows == field.rows then
return field
end
local values = __TS__New(Float32Array, columns * rows)
do
local row = 0
while row < rows do
local top = math.floor(row * field.rows / rows)
local bottom = math.max(
top + 1,
math.floor((row + 1) * field.rows / rows)
)
do
local column = 0
while column < columns do
local left = math.floor(column * field.columns / columns)
local right = math.max(
left + 1,
math.floor((column + 1) * field.columns / columns)
)
local sum = 0
do
local j = top
while j < bottom do
do
local i = left
while i < right do
sum = sum + field.values[j * field.columns + i]
i = i + 1
end
end
j = j + 1
end
end
values[row * columns + column] = sum / ((bottom - top) * (right - left))
column = column + 1
end
end
row = row + 1
end
end
return {columns = columns, rows = rows, values = values}
end
function ____exports.heightsOfPixels(self, pixels, columns, rows)
local grey = true
do
local at = 0
while at < columns * rows * 4 and grey do
grey = math.abs(pixels[at] - pixels[at + 1]) <= 2 and math.abs(pixels[at] - pixels[at + 2]) <= 2
at = at + 4
end
end
local values = __TS__New(Float32Array, columns * rows)
local low = math.huge
local high = -math.huge
do
local at = 0
while at < columns * rows do
local red, green, blue = pixels[at * 4], pixels[at * 4 + 1], pixels[at * 4 + 2]
local value = grey and red or red * 256 + green + blue / 256 - 32768
values[at] = value
low = math.min(low, value)
high = math.max(high, value)
at = at + 1
end
end
local range = __lor(
nil,
high - low,
function() return 1 end
)
do
local at = 0
while at < values.length do
values[at] = (values[at] - low) / range
at = at + 1
end
end
return {columns = columns, rows = rows, values = values}
end
____exports.TERRAIN_ASSET = "terrain:"
____exports.terrainAssetName = function(____, shape) return ____exports.TERRAIN_ASSET .. __json(nil, shape) end
function ____exports.terrainOfAsset(self, asset)
if not __TS__StringStartsWith(asset, ____exports.TERRAIN_ASSET) then
return nil
end
do
local function ____catch()
return true, nil
end
local ____try, ____hasReturned, ____returnValue = pcall(function()
return true, __jsonParse(
nil,
__TS__StringSlice(asset, #____exports.TERRAIN_ASSET)
)
end)
if not ____try then
____hasReturned, ____returnValue = ____catch()
end
if ____hasReturned then
return ____returnValue
end
end
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.mesh.object"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.isMeshSurfaceObject(self, canvasObject)
return canvasObject.objectType == "meshSurface" and canvasObject.meshSurface ~= nil
end
function ____exports.isMeshLightObject(self, canvasObject)
return canvasObject.objectType == "meshLight" and canvasObject.meshLight ~= nil
end
function ____exports.isMeshGroundObject(self, canvasObject)
return canvasObject.objectType == "meshGround" and canvasObject.meshGround ~= nil
end
function ____exports.isMeshObject(self, canvasObject)
return canvasObject.objectType == "mesh" and canvasObject.mesh ~= nil
end
function ____exports.isMeshSceneObject(self, canvasObject)
return canvasObject.objectType == "meshScene" and canvasObject.meshScene ~= nil
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.mesh.resolver"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayReverse = ____lualib.__TS__ArrayReverse
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayFlat = ____lualib.__TS__ArrayFlat
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local placedByUse, mirrorOf, mirrored, place
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____facets = require("core.model.facets.index")
local facetsAssetName = ____facets.facetsAssetName
local ____mesh = require("core.model.mesh.index")
local DEFAULT_LIGHT = ____mesh.DEFAULT_LIGHT
local DEFAULT_ORBIT = ____mesh.DEFAULT_ORBIT
local ____outline = require("core.model.outline.index")
local ringArea = ____outline.ringArea
local ____path = require("core.model.path.index")
local flattenPath = ____path.flattenPath
local ____sketch = require("core.model.sketch.index")
local circleRing = ____sketch.circleRing
local pickedOutline = ____sketch.pickedOutline
local roundedRing = ____sketch.roundedRing
local ____solid = require("core.model.solid.index")
local solidAssetName = ____solid.solidAssetName
local turn = ____solid.turn
local ____terrain = require("core.model.terrain.index")
local terrainAssetName = ____terrain.terrainAssetName
local ____placement = require("core.sflLanguage.expansion.placement")
local placeIn = ____placement.placeIn
local product = ____placement.product
local turnDegrees = ____placement.turnDegrees
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local directProperties = ____blockEntries.directProperties
local placementValue = ____blockEntries.placementValue
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local listNumbers = ____valueAccess.listNumbers
local tupleValues = ____valueAccess.tupleValues
function placedByUse(self, block, position, rotation, scale)
return block.placement and placeIn(
nil,
block.placement,
position,
rotation,
scale
) or ({position = position, rotation = rotation, scale = scale})
end
function mirrorOf(self, block, properties)
return block.mirrored or asString(
nil,
properties:get("flip")
)
end
function mirrored(self, value, flip, acrossX, acrossZ)
local signs = flip == "x" and acrossX or (flip == "z" and acrossZ or nil)
return signs and ({value[1] * signs[1], value[2] * signs[2], value[3] * signs[3]}) or value
end
function place(self, value)
local x, y, z = table.unpack(
tupleValues(nil, value) or ({}),
1,
3
)
return x ~= nil and y ~= nil and z ~= nil and ({x, y, z}) or nil
end
local function vector(self, block, layoutProp, key, fallback)
local value = layoutProp(nil, block, key)
local single = asNumber(nil, value)
local x, y, z = table.unpack(
tupleValues(nil, value) or ({}),
1,
3
)
if x == nil then
x = single or fallback
end
if y == nil then
y = single or fallback
end
if z == nil then
z = single or fallback
end
local function axis(____, name, plain)
return asNumber(
nil,
layoutProp(nil, block, key .. name)
) or plain
end
return {
axis(nil, "X", x),
axis(nil, "Y", y),
axis(nil, "Z", z)
}
end
local SQUARE = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}
local function outlineOf(self, properties, symbolDefs, flip)
local symbol = symbolDefs:get(asString(
nil,
properties:get("symbol")
) or "")
local flat = symbol and (symbol.rings or ({__TS__ArrayMap(
flattenPath(
nil,
{
points = __TS__ArrayMap(
symbol.points,
function(____, ____bindingPattern0, index)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
local ____opt_0 = symbol.pointTensions
local tension = ____opt_0 and ____opt_0[index + 1]
return tension == nil and ({x = x, y = y}) or ({x = x, y = y, tension = tension})
end
),
tension = symbol.tension or 0,
closed = true
}
),
function(____, point) return {point.x, point.y} end
)})) or ({SQUARE})
local rings = symbol and symbol.rings or __TS__ArrayMap(
flat,
function(____, ring) return ringArea(nil, ring) > 0 and ring or __TS__ArrayReverse({table.unpack(ring)}) end
)
return (flip == "x" or flip == "z") and __TS__ArrayMap(
rings,
function(____, ring) return __TS__ArrayReverse(__TS__ArrayMap(
ring,
function(____, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
return flip == "x" and ({1 - x, y}) or ({x, 1 - y})
end
)) end
) or rings
end
local function pair(____, value)
local x, y = table.unpack(
tupleValues(nil, value) or ({}),
1,
2
)
if x == nil then
x = 0
end
if y == nil then
y = 0
end
return {x, y}
end
local function sketchShapes(self, sketch)
return __TS__ArrayFlatMap(
childBlocks(nil, sketch),
function(____, shape)
local own = directProperties(nil, shape)
if shape.kind == "Circle" then
local radius = asNumber(
nil,
own:get("radius")
) or 0
return radius > 0 and ({circleRing(
nil,
pair(
nil,
placementValue(nil, shape, "position", "at")
),
radius
)}) or ({})
end
if shape.kind == "Rect" then
local x, y = table.unpack(
pair(
nil,
placementValue(nil, shape, "position", "at")
),
1,
2
)
local width, height = table.unpack(
pair(
nil,
placementValue(nil, shape, "size")
),
1,
2
)
local one = asNumber(
nil,
own:get("radius")
)
local radii = tupleValues(
nil,
own:get("radius")
) or ({one or 0, one or 0, one or 0, one or 0})
return width > 0 and height > 0 and ({roundedRing(nil, {{x, y}, {x + width, y}, {x + width, y + height}, {x, y + height}}, radii)}) or ({})
end
local points = own:get("points")
if shape.kind ~= "Outline" or (points and points.type) ~= "list" then
return {}
end
local rows = __TS__ArrayFilter(
__TS__ArrayMap(
points.values,
function(____, item) return listNumbers(nil, item) or ({}) end
),
function(____, row) return #row >= 2 end
)
return #rows >= 3 and ({roundedRing(
nil,
__TS__ArrayMap(
rows,
function(____, row) return {row[1], row[2]} end
),
__TS__ArrayMap(
rows,
function(____, row) return row[3] or 0 end
)
)}) or ({})
end
)
end
local function fromSketch(self, properties, layoutProp, sketchDefs)
local sketch = sketchDefs and sketchDefs:get(asString(
nil,
properties:get("sketch")
) or "")
if not sketch then
return nil
end
local pick = properties:get("pick")
local picks = (pick and pick.type) == "list" and __TS__ArrayFlatMap(
pick.values,
function(____, item)
local at = listNumbers(nil, item)
return at and #at >= 2 and ({{at[1], at[2]}}) or ({})
end
) or ({})
local outline = pickedOutline(
nil,
sketchShapes(nil, sketch),
picks
)
local points = __TS__ArrayFlat(__TS__ArrayFilter(
outline,
function(____, ring) return ringArea(nil, ring) > 0 end
))
if #points == 0 then
return nil
end
local xs = __TS__ArrayMap(
points,
function(____, point) return point[1] end
)
local ys = __TS__ArrayMap(
points,
function(____, point) return point[2] end
)
local left, top = math.min(table.unpack(xs)), math.min(table.unpack(ys))
local width, depth = math.max(table.unpack(xs)) - left, math.max(table.unpack(ys)) - top
if width < 1e-9 or depth < 1e-9 then
return nil
end
local rotation = vector(
nil,
sketch,
layoutProp,
"rotation",
0
)
local origin = vector(
nil,
sketch,
layoutProp,
"position",
0
)
local m = turn(nil, rotation)
local u, v = left + width / 2, top + depth / 2
return {
rings = __TS__ArrayMap(
outline,
function(____, ring) return __TS__ArrayMap(
ring,
function(____, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
return {(x - left) / width, (y - top) / depth}
end
) end
),
width = width,
depth = depth,
position = {origin[1] + m[1] * u + m[3] * v, origin[2] + m[4] * u + m[6] * v, origin[3] + m[7] * u + m[9] * v},
rotation = rotation
}
end
____exports.EDGE_WORDS_BEFORE = {
cut = "chamferEdges",
round = "filletEdges",
cutTop = "chamferTop",
cutBottom = "chamferBottom",
roundTop = "filletTop",
roundBottom = "filletBottom"
}
local function rimOf(self, properties)
local fillet = properties:get("fillet")
local value = fillet or properties:get("chamfer")
local top, bottom = table.unpack(
tupleValues(nil, value) or ({}),
1,
2
)
if top == nil then
top = asNumber(nil, value) or 0
end
if bottom == nil then
bottom = top
end
local function listOf(____, now)
local before = __TS__ArrayFind(
__TS__ObjectKeys(____exports.EDGE_WORDS_BEFORE),
function(____, word) return ____exports.EDGE_WORDS_BEFORE[word] == now end
)
local ____temp_11 = properties:get(now)
if ____temp_11 == nil then
local ____t_result_10
if __t(nil, before) then
____t_result_10 = properties:get(before)
else
____t_result_10 = nil
end
____temp_11 = ____t_result_10
end
local list = ____temp_11
return (list and list.type) == "list" and __TS__ArrayFlatMap(
list.values,
function(____, item) return {listNumbers(nil, item) or ({})} end
) or ({})
end
local corners = __TS__ArrayFlatMap(
{"chamferEdges", "filletEdges"},
function(____, name, kind) return __TS__ArrayFlatMap(
listOf(nil, name),
function(____, ____bindingPattern0)
local size
local at
local ring
ring = ____bindingPattern0[1]
at = ____bindingPattern0[2]
size = ____bindingPattern0[3]
return size ~= nil and size > 0 and ({{ring, at, size, kind}}) or ({})
end
) end
)
local edges = __TS__ArrayFlatMap(
{{"chamferBottom", 0, 0}, {"chamferTop", 1, 0}, {"filletBottom", 0, 1}, {"filletTop", 1, 1}},
function(____, ____bindingPattern0)
local round
local atTop
local name
name = ____bindingPattern0[1]
atTop = ____bindingPattern0[2]
round = ____bindingPattern0[3]
return __TS__ArrayFlatMap(
listOf(nil, name),
function(____, ____bindingPattern0)
local size
local at
local ring
ring = ____bindingPattern0[1]
at = ____bindingPattern0[2]
size = ____bindingPattern0[3]
return size ~= nil and size > 0 and ({{
ring,
at,
size,
atTop,
round
}}) or ({})
end
)
end
)
return __TS__ObjectAssign(
{},
#corners > 0 and ({corners = corners}) or ({}),
#edges > 0 and ({edges = edges}) or ({}),
{chamfer = top},
bottom ~= top and ({chamferBottom = bottom}) or ({}),
(fillet ~= nil or asString(
nil,
properties:get("edge")
) == "round") and ({round = true}) or ({})
)
end
local function topOf(self, properties, symbolDefs, flip)
local list = properties:get("walls")
local walls = (list and list.type) == "list" and __TS__ArrayFlatMap(
list.values,
function(____, item)
local ring, at, push, lean = table.unpack(
listNumbers(nil, item) or ({}),
1,
4
)
if push == nil then
push = 0
end
if lean == nil then
lean = 0
end
return ring ~= nil and at ~= nil and (__t(nil, push) or __t(nil, lean)) and ({{ring, at, push, lean}}) or ({})
end
) or ({})
local taper = asNumber(
nil,
properties:get("taper")
)
local x, z = table.unpack(
tupleValues(
nil,
properties:get("shift")
) or ({}),
1,
2
)
if x == nil then
x = asNumber(
nil,
properties:get("shift")
) or 0
end
if z == nil then
z = 0
end
local named = asString(
nil,
properties:get("loft")
)
local top = __t(nil, named) and symbolDefs:has(named) and outlineOf(
nil,
__TS__New(
Map,
{{
"symbol",
properties:get("loft")
}}
),
symbolDefs,
flip
) or nil
local shift = {flip == "x" and -x or x, flip == "z" and -z or z}
return __TS__ObjectAssign(
{},
__t(nil, taper) and ({taper = taper}) or ({}),
(__t(nil, shift[1]) or __t(nil, shift[2])) and ({shift = shift}) or ({}),
top and ({top = top}) or ({}),
#walls > 0 and ({walls = walls}) or ({})
)
end
local JOININGS = {Cut = "cut", Add = "add", Keep = "keep"}
local function solidAsset(self, block, properties, layoutProp, symbolDefs, sketched)
local flip = mirrorOf(nil, block, properties)
local joins = __TS__ArrayMap(
__TS__ArrayFilter(
childBlocks(nil, block),
function(____, child) return JOININGS[child.kind] ~= nil end
),
function(____, child)
local own = directProperties(nil, child)
return __TS__ObjectAssign(
{
joining = JOININGS[child.kind],
rings = outlineOf(nil, own, symbolDefs, flip),
size = vector(
nil,
child,
layoutProp,
"size",
1
)
},
rimOf(nil, own),
topOf(nil, own, symbolDefs, flip),
{
position = mirrored(
nil,
vector(
nil,
child,
layoutProp,
"position",
0
),
flip,
{-1, 1, 1},
{1, 1, -1}
),
rotation = mirrored(
nil,
vector(
nil,
child,
layoutProp,
"rotation",
0
),
flip,
{1, -1, -1},
{-1, -1, 1}
)
}
)
end
)
return solidAssetName(
nil,
__TS__ObjectAssign(
{
rings = sketched and sketched.rings or outlineOf(nil, properties, symbolDefs, flip),
size = sketched and ({
sketched.width,
asNumber(
nil,
properties:get("height")
) or vector(
nil,
block,
layoutProp,
"size",
1
)[2],
sketched.depth
}) or vector(
nil,
block,
layoutProp,
"size",
1
)
},
rimOf(nil, properties),
topOf(nil, properties, symbolDefs, flip),
#joins > 0 and ({joins = joins}) or ({})
)
)
end
local function facetsAsset(self, properties)
local function rows(____, key)
local list = properties:get(key)
return (list and list.type) == "list" and __TS__ArrayMap(
list.values,
function(____, item) return listNumbers(nil, item) or ({}) end
) or ({})
end
local symmetry = asString(
nil,
properties:get("symmetry")
)
local thickness = asNumber(
nil,
properties:get("thickness")
)
local bevel = asNumber(
nil,
properties:get("bevel")
)
local shape = __TS__ObjectAssign(
{
points = __TS__ArrayMap(
__TS__ArrayFilter(
rows(nil, "points"),
function(____, row) return #row >= 3 end
),
function(____, row) return {row[1], row[2], row[3]} end
),
faces = __TS__ArrayFilter(
rows(nil, "faces"),
function(____, row) return #row >= 3 end
)
},
(symmetry == "x" or symmetry == "y" or symmetry == "z") and ({symmetry = symmetry}) or ({}),
__t(nil, thickness) and ({thickness = thickness}) or ({}),
__t(nil, bevel) and ({bevel = bevel}) or ({})
)
return facetsAssetName(nil, shape)
end
local function terrainAsset(self, block, properties, layoutProp)
local pictured = properties:get("picture")
local picture = asString(nil, pictured)
local surface = (pictured and pictured.type) == "ident" and table.concat(pictured.segments, ".") or nil
local base = asNumber(
nil,
properties:get("base")
)
local detail = asNumber(
nil,
properties:get("detail")
)
return terrainAssetName(
nil,
__TS__ObjectAssign(
{heights = asString(
nil,
properties:get("heights")
) or ""},
__t(nil, surface) and ({surface = surface}) or (__t(nil, picture) and ({picture = picture}) or ({})),
{size = vector(
nil,
block,
layoutProp,
"size",
1
)},
base ~= nil and ({base = base}) or ({}),
__t(nil, detail) and ({detail = detail}) or ({})
)
)
end
function ____exports.resolveMeshObject(self, base, block, properties, layoutProp, symbolDefs, sketchDefs)
if symbolDefs == nil then
symbolDefs = __TS__New(Map)
end
local ____temp_22
if block.kind == "Solid" then
____temp_22 = mirrorOf(nil, block, properties)
else
____temp_22 = nil
end
local flip = ____temp_22
local ____temp_23
if block.kind == "Solid" then
____temp_23 = fromSketch(nil, properties, layoutProp, sketchDefs)
else
____temp_23 = nil
end
local sketched = ____temp_23
local own = vector(
nil,
block,
layoutProp,
"position",
0
)
local turned = sketched and turn(nil, sketched.rotation)
local placed = sketched and turned and ({sketched.position[1] + turned[1] * own[1] + turned[2] * own[2] + turned[3] * own[3], sketched.position[2] + turned[4] * own[1] + turned[5] * own[2] + turned[6] * own[3], sketched.position[3] + turned[7] * own[1] + turned[8] * own[2] + turned[9] * own[3]}) or nil
local where = placedByUse(
nil,
block,
placed or mirrored(
nil,
own,
flip,
{-1, 1, 1},
{1, 1, -1}
),
sketched and turnDegrees(
nil,
product(
nil,
turn(nil, sketched.rotation),
turn(
nil,
vector(
nil,
block,
layoutProp,
"rotation",
0
)
)
)
) or mirrored(
nil,
vector(
nil,
block,
layoutProp,
"rotation",
0
),
flip,
{1, -1, -1},
{-1, -1, 1}
),
vector(
nil,
block,
layoutProp,
"scale",
1
)
)
return __TS__ObjectAssign(
{},
base,
{
objectType = "mesh",
mesh = __TS__ObjectAssign(
{
asset = block.kind == "Solid" and solidAsset(
nil,
block,
properties,
layoutProp,
symbolDefs,
sketched
) or (block.kind == "Facets" and facetsAsset(nil, properties) or (block.kind == "Terrain" and terrainAsset(nil, block, properties, layoutProp) or (asString(
nil,
properties:get("asset")
) or ""))),
role = asString(
nil,
properties:get("role")
),
color = asString(
nil,
properties:get("color")
),
opacity = asNumber(
nil,
properties:get("opacity")
),
roughness = asNumber(
nil,
properties:get("roughness")
),
metallic = asNumber(
nil,
properties:get("metallic")
),
transmission = asNumber(
nil,
properties:get("transmission")
),
ior = asNumber(
nil,
properties:get("ior")
)
},
where
)
}
)
end
function ____exports.resolveMeshSceneObject(self, base, properties)
local yaw, pitch = table.unpack(
tupleValues(
nil,
properties:get("orbit")
) or ({}),
1,
2
)
if yaw == nil then
yaw = DEFAULT_ORBIT[1]
end
if pitch == nil then
pitch = DEFAULT_ORBIT[2]
end
return __TS__ObjectAssign(
{},
base,
{
objectType = "meshScene",
meshScene = {
orbit = {yaw, pitch},
zoom = asNumber(
nil,
properties:get("zoom")
),
shadow = asString(
nil,
properties:get("shadow")
) == "true",
environment = asString(
nil,
properties:get("environment")
),
environmentTurn = asNumber(
nil,
properties:get("environmentTurn")
),
exposure = asNumber(
nil,
properties:get("exposure")
),
haze = asNumber(
nil,
properties:get("haze")
),
hazeColor = asString(
nil,
properties:get("hazeColor")
)
}
}
)
end
function ____exports.resolveMeshSurfaceObject(self, base, block, layoutProp)
return __TS__ObjectAssign(
{},
base,
{
x = 0,
y = 0,
objectType = "meshSurface",
meshSurface = placedByUse(
nil,
block,
vector(
nil,
block,
layoutProp,
"position",
0
),
vector(
nil,
block,
layoutProp,
"rotation",
0
),
vector(
nil,
block,
layoutProp,
"scale",
1
)
)
}
)
end
function ____exports.resolveMeshLightObject(self, base, block, properties)
return __TS__ObjectAssign(
{},
base,
{
objectType = "meshLight",
meshLight = {
turn = asNumber(
nil,
properties:get("turn")
) or DEFAULT_LIGHT.turn,
height = asNumber(
nil,
properties:get("elevation")
) or asNumber(
nil,
properties:get("height")
) or DEFAULT_LIGHT.height,
color = asString(
nil,
properties:get("color")
),
intensity = asNumber(
nil,
properties:get("intensity")
) or DEFAULT_LIGHT.intensity,
ambient = asNumber(
nil,
properties:get("ambient")
) or DEFAULT_LIGHT.ambient,
ambientColor = asString(
nil,
properties:get("ambientColor")
),
softness = asNumber(
nil,
properties:get("softness")
),
position = place(
nil,
placementValue(nil, block, "position") or properties:get("position")
),
glow = asNumber(
nil,
properties:get("glow")
)
}
}
)
end
function ____exports.resolveMeshGroundObject(self, base, block, properties)
local color = asString(
nil,
properties:get("color")
)
local placed = tupleValues(
nil,
placementValue(nil, block, "position")
)
local ____base_28 = base
local ____temp_27 = placed and placed[2] or asNumber(
nil,
properties:get("height")
)
local ____temp_26
if color == "none" then
____temp_26 = nil
else
____temp_26 = color
end
return __TS__ObjectAssign(
{},
____base_28,
{
objectType = "meshGround",
meshGround = {
height = ____temp_27,
color = ____temp_26,
reflection = math.min(
1,
math.max(
0,
asNumber(
nil,
properties:get("reflection")
) or 0
)
),
roughness = math.min(
1,
math.max(
0,
asNumber(
nil,
properties:get("roughness")
) or 0
)
)
}
}
)
end
function ____exports.readAnchor(self, properties)
local mesh = asString(
nil,
properties:get("anchor")
)
if not __t(nil, mesh) then
return nil
end
local x, y, z = table.unpack(
tupleValues(
nil,
properties:get("anchorAt")
) or ({}),
1,
3
)
if x == nil then
x = 0
end
if y == nil then
y = 0
end
if z == nil then
z = 0
end
return {mesh = mesh, point = {x, y, z}}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.path.object"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.isPathObject(self, canvasObject)
return canvasObject.objectType == "path" and canvasObject.path ~= nil
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.path.reader"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
function ____exports.readPath(self, p, origin)
local pointsValue = p:get("points")
local points = (pointsValue and pointsValue.type) == "list" and __TS__ArrayFlatMap(
pointsValue.values,
function(____, value)
if value.type ~= "list" or #value.values < 2 then
return {}
end
local x = asNumber(nil, value.values[1])
local y = asNumber(nil, value.values[2])
local ____temp_2
if value.values[3] == nil then
____temp_2 = nil
else
____temp_2 = asNumber(nil, value.values[3])
end
local tension = ____temp_2
if x == nil or y == nil then
return {}
end
local point = {x = origin.x + x, y = origin.y + y}
return {tension == nil and point or __TS__ObjectAssign({}, point, {tension = tension})}
end
) or ({})
return {
points = points,
tension = asNumber(
nil,
p:get("tension")
),
startMarker = asString(
nil,
p:get("startMarker")
),
endMarker = asString(
nil,
p:get("endMarker")
),
closed = asString(
nil,
p:get("closed")
) == "true",
value = asNumber(
nil,
p:get("value")
)
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.path.resolver"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____reader = require("core.sflSemantic.canvasObjects.artifacts.path.reader")
local readPath = ____reader.readPath
function ____exports.resolvePathObject(self, base, properties, origin)
return __TS__ObjectAssign(
{},
base,
{
objectType = "path",
path = readPath(nil, properties, origin)
}
)
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.swimlane.object"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.isSwimlaneObject(self, canvasObject)
return canvasObject.objectType == "swimlane" and canvasObject.swimlane ~= nil
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.swimlane.reader"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
function ____exports.readSwimlane(self, p)
local orientation = asString(
nil,
p:get("orientation")
) == "vertical" and "vertical" or "horizontal"
local lanesValue = p:get("lanes")
local lanes = (lanesValue and lanesValue.type) == "list" and __TS__ArrayFlatMap(
lanesValue.values,
function(____, value, index)
if value.type ~= "list" then
return {}
end
local label = asString(nil, value.values[1])
local size = asNumber(nil, value.values[2])
if label == nil or size == nil then
return {}
end
local color = asString(nil, value.values[3])
return {__TS__ObjectAssign(
{
id = "lane-" .. tostring(index + 1),
label = label,
size = size
},
__t(nil, color) and ({color = color}) or ({})
)}
end
) or ({})
local swimlaneData = {orientation = orientation, lanes = lanes}
return swimlaneData
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.swimlane.resolver"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____reader = require("core.sflSemantic.canvasObjects.artifacts.swimlane.reader")
local readSwimlane = ____reader.readSwimlane
function ____exports.resolveSwimlaneObject(self, base, properties)
return __TS__ObjectAssign(
{},
base,
{
objectType = "swimlane",
swimlane = readSwimlane(nil, properties)
}
)
end
return ____exports
end,
["core.sflSemantic.canvasObjects.processing.classification"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____component = require("core.model.component.index")
local isBuiltInComponentType = ____component.isBuiltInComponentType
local ____ast = require("core.sflLanguage.ast")
local isComponentBlockKind = ____ast.isComponentBlockKind
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asString = ____valueAccess.asString
local function declaredCanvasObjectKind(self, block, properties)
if block.kind == "Screen" then
return "screen"
end
if block.kind == "Path" then
return "path"
end
if block.kind == "Chart" then
return "chart"
end
if isComponentBlockKind(nil, block.kind) then
return asString(
nil,
properties:get("type")
) or "widget"
end
if block.kind == "Text" then
return "text"
end
if block.kind == "Image" then
return "image"
end
if block.kind == "Isometric" then
return "isometric"
end
if block.kind == "Dimension" then
return "dimension"
end
if block.kind == "Mesh" or block.kind == "Solid" or block.kind == "Facets" or block.kind == "Terrain" then
return "mesh"
end
if block.kind == "Scene" then
return "meshScene"
end
if block.kind == "Canvas" then
return "meshSurface"
end
if block.kind == "Light" then
return "meshLight"
end
if block.kind == "Ground" then
return "meshGround"
end
return asString(
nil,
properties:get("kind")
) or ""
end
local function canvasObjectTypeForKind(self, kind)
if kind == "frame" or kind == "screen" then
return "frame"
end
if kind == "swimlane" then
return "swimlane"
end
if kind == "path" then
return "path"
end
if kind == "chart" then
return "chart"
end
if isBuiltInComponentType(nil, kind) then
return "component"
end
if kind == "isometric" then
return "isometric"
end
if kind == "dimension" then
return "dimension"
end
if kind == "mesh" then
return "mesh"
end
if kind == "meshScene" then
return "meshScene"
end
if kind == "meshSurface" then
return "meshSurface"
end
if kind == "meshLight" then
return "meshLight"
end
if kind == "meshGround" then
return "meshGround"
end
return "shape"
end
function ____exports.classifyCanvasObject(self, block, properties, symbolDefinitions)
local kind = declaredCanvasObjectKind(nil, block, properties)
local shapeReference = asString(
nil,
properties:get("shape")
)
local ____temp_0
if block.kind == "Shape" or block.kind == "Entity" then
____temp_0 = asString(
nil,
properties:get("symbol")
)
else
____temp_0 = nil
end
local named = ____temp_0
local ____t_result_1
if __t(nil, named) then
____t_result_1 = symbolDefinitions:get(named)
else
____t_result_1 = nil
end
local ____t_result_1_3 = ____t_result_1
if ____t_result_1_3 == nil then
local ____t_result_2
if __t(nil, shapeReference) then
____t_result_2 = symbolDefinitions:get(shapeReference)
else
____t_result_2 = nil
end
____t_result_1_3 = ____t_result_2
end
local symbol = ____t_result_1_3
return {
objectType = isComponentBlockKind(nil, block.kind) and "component" or canvasObjectTypeForKind(nil, kind),
kind = kind,
shapeType = symbol and "symbol" or shapeReference,
symbol = symbol
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.processing.layout.geometry"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local tupleValues = ____valueAccess.tupleValues
function ____exports.readCanvasObjectGeometry(self, block, origin, layoutProperty, positionOverride)
local position = positionOverride or tupleValues(
nil,
layoutProperty(nil, block, "position")
) or ({0, 0})
local size = tupleValues(
nil,
layoutProperty(nil, block, "size")
) or ({0, 0})
return {
x = origin.x + (position[1] or 0),
y = origin.y + (position[2] or 0),
width = size[1] or 0,
height = size[2] or 0,
rotation = asNumber(
nil,
layoutProperty(nil, block, "rotation")
),
order = asNumber(
nil,
layoutProperty(nil, block, "order")
)
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.processing.presentation"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local Map = ____lualib.Map
local __TS__ArrayJoin = ____lualib.__TS__ArrayJoin
local __TS__Iterator = ____lualib.__TS__Iterator
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asString = ____valueAccess.asString
local listNumbers = ____valueAccess.listNumbers
local tupleValues = ____valueAccess.tupleValues
local STRUCTURAL_PROPERTIES = __TS__New(Set, {
"id",
"kind",
"text",
"shape",
"parent",
"order",
"orientation",
"lanes"
})
local TUPLE_PROPERTIES = __TS__New(Set, {"crop", "imageSize"})
local LIST_PROPERTIES = __TS__New(Set, {"cornerRadii"})
function ____exports.readCanvasObjectPresentation(self, properties)
local presentation = {}
for ____, ____value in __TS__Iterator(properties) do
local key = ____value[1]
local value = ____value[2]
do
if STRUCTURAL_PROPERTIES:has(key) then
goto __continue3
end
local ____TUPLE_PROPERTIES_has_result_5
if TUPLE_PROPERTIES:has(key) then
local ____opt_0 = tupleValues(nil, value)
____TUPLE_PROPERTIES_has_result_5 = ____opt_0 and __TS__ArrayJoin(
tupleValues(nil, value),
","
)
else
local ____LIST_PROPERTIES_has_result_4
if LIST_PROPERTIES:has(key) then
local ____opt_2 = listNumbers(nil, value)
____LIST_PROPERTIES_has_result_4 = ____opt_2 and __TS__ArrayJoin(
listNumbers(nil, value),
","
)
else
____LIST_PROPERTIES_has_result_4 = asString(nil, value)
end
____TUPLE_PROPERTIES_has_result_5 = ____LIST_PROPERTIES_has_result_4
end
local text = ____TUPLE_PROPERTIES_has_result_5
if text ~= nil then
presentation[key] = text
end
end
::__continue3::
end
return presentation
end
return ____exports
end,
["core.sflSemantic.canvasObjects.processing.resolver"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local ____resolver = require("core.sflSemantic.canvasObjects.artifacts.chart.resolver")
local resolveChartObject = ____resolver.resolveChartObject
local ____resolver = require("core.sflSemantic.canvasObjects.artifacts.dimension.resolver")
local resolveDimensionObject = ____resolver.resolveDimensionObject
local ____resolver = require("core.sflSemantic.canvasObjects.artifacts.isometric.resolver")
local resolveIsometricObject = ____resolver.resolveIsometricObject
local ____resolver = require("core.sflSemantic.canvasObjects.artifacts.mesh.resolver")
local readAnchor = ____resolver.readAnchor
local resolveMeshGroundObject = ____resolver.resolveMeshGroundObject
local resolveMeshLightObject = ____resolver.resolveMeshLightObject
local resolveMeshObject = ____resolver.resolveMeshObject
local resolveMeshSceneObject = ____resolver.resolveMeshSceneObject
local resolveMeshSurfaceObject = ____resolver.resolveMeshSurfaceObject
local ____resolver = require("core.sflSemantic.canvasObjects.artifacts.path.resolver")
local resolvePathObject = ____resolver.resolvePathObject
local ____resolver = require("core.sflSemantic.canvasObjects.artifacts.swimlane.resolver")
local resolveSwimlaneObject = ____resolver.resolveSwimlaneObject
local ____classification = require("core.sflSemantic.canvasObjects.processing.classification")
local classifyCanvasObject = ____classification.classifyCanvasObject
local ____geometry = require("core.sflSemantic.canvasObjects.processing.layout.geometry")
local readCanvasObjectGeometry = ____geometry.readCanvasObjectGeometry
local ____presentation = require("core.sflSemantic.canvasObjects.processing.presentation")
local readCanvasObjectPresentation = ____presentation.readCanvasObjectPresentation
function ____exports.resolveCanvasObject(self, block, origin, context, frameId, positionOverride)
local ____context_0 = context
local mergedProps = ____context_0.mergedProps
local layoutProp = ____context_0.layoutProp
local symbolDefs = ____context_0.symbolDefs
local properties = mergedProps(nil, block)
local classification = classifyCanvasObject(nil, block, properties, symbolDefs)
local geometry = readCanvasObjectGeometry(
nil,
block,
origin,
layoutProp,
positionOverride
)
local base = __TS__ObjectAssign(
{
id = asString(
nil,
properties:get("id")
) or block.name,
kind = classification.kind,
text = asString(
nil,
properties:get("text")
)
},
geometry,
{
parentFrameId = frameId or asString(
nil,
properties:get("parent")
),
anchor = readAnchor(nil, properties),
props = readCanvasObjectPresentation(nil, properties)
}
)
repeat
local ____switch3 = classification.objectType
local ____cond3 = ____switch3 == "chart"
if ____cond3 then
return resolveChartObject(
nil,
base,
block,
properties,
symbolDefs,
mergedProps
)
end
____cond3 = ____cond3 or ____switch3 == "isometric"
if ____cond3 then
return resolveIsometricObject(
nil,
base,
block,
properties,
layoutProp,
symbolDefs
)
end
____cond3 = ____cond3 or ____switch3 == "path"
if ____cond3 then
return resolvePathObject(nil, base, properties, origin)
end
____cond3 = ____cond3 or ____switch3 == "dimension"
if ____cond3 then
return resolveDimensionObject(nil, base, properties, origin)
end
____cond3 = ____cond3 or ____switch3 == "mesh"
if ____cond3 then
return resolveMeshObject(
nil,
base,
block,
properties,
layoutProp,
symbolDefs,
context.sketchDefs
)
end
____cond3 = ____cond3 or ____switch3 == "meshScene"
if ____cond3 then
return resolveMeshSceneObject(nil, base, properties)
end
____cond3 = ____cond3 or ____switch3 == "meshLight"
if ____cond3 then
return resolveMeshLightObject(nil, base, block, properties)
end
____cond3 = ____cond3 or ____switch3 == "meshGround"
if ____cond3 then
return resolveMeshGroundObject(nil, base, block, properties)
end
____cond3 = ____cond3 or ____switch3 == "meshSurface"
if ____cond3 then
return resolveMeshSurfaceObject(nil, base, block, layoutProp)
end
____cond3 = ____cond3 or ____switch3 == "swimlane"
if ____cond3 then
return resolveSwimlaneObject(nil, base, properties)
end
____cond3 = ____cond3 or ____switch3 == "frame"
if ____cond3 then
return __TS__ObjectAssign({}, base, {objectType = "frame"})
end
____cond3 = ____cond3 or ____switch3 == "component"
if ____cond3 then
return __TS__ObjectAssign(
{},
base,
{
objectType = "component",
component = {
type = asString(
nil,
properties:get("type")
) or "rollingNumber",
value = asString(
nil,
properties:get("value")
) or "0",
digits = asNumber(
nil,
properties:get("digits")
),
duration = asNumber(
nil,
properties:get("duration")
),
min = asNumber(
nil,
properties:get("min")
),
max = asNumber(
nil,
properties:get("max")
),
label = asString(
nil,
properties:get("label")
)
}
}
)
end
____cond3 = ____cond3 or ____switch3 == "shape"
if ____cond3 then
return __TS__ObjectAssign({}, base, {objectType = "shape", shapeType = classification.shapeType, symbol = classification.symbol})
end
until true
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.links.endpointReader"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySome = ____lualib.__TS__ArraySome
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local function namedPortReference(self, segments, context)
if #segments < 2 then
return nil
end
local portName = segments[#segments]
local canvasObjectName = segments[#segments - 2 + 1]
local canvasObjectId = context.idByName:get(canvasObjectName)
local ____t_result_0
if __t(nil, canvasObjectId) then
____t_result_0 = context.canvasObjectById:get(canvasObjectId)
else
____t_result_0 = nil
end
local canvasObject = ____t_result_0
local ____opt_7 = canvasObject and canvasObject.symbol
local ____opt_1 = ____opt_7 and ____opt_7.ports
if ____opt_1 ~= nil then
local ____opt_2 = canvasObject and canvasObject.symbol
____opt_1 = __TS__ArraySome(
____opt_2 and ____opt_2.ports,
function(____, port) return port.name == portName end
)
end
if not ____opt_1 then
return nil
end
return {id = canvasObjectId, port = portName}
end
function ____exports.readLinkEndpoint(self, value, context)
if (value and value.type) ~= "endpoint" then
return {}
end
local namedPort = namedPortReference(nil, value.segments, context)
if namedPort then
return namedPort
end
local endpointName = value.segments[#value.segments]
return {
id = context.idByName:get(endpointName) or endpointName,
side = value.side,
fraction = value.fraction
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.processing.blockKinds"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local ____exports = {}
____exports.CANVAS_OBJECT_BLOCK_KINDS = {
"Entity",
"Shape",
"Text",
"Image",
"Container",
"Screen",
"Path",
"Chart",
"Widget",
"Component",
"Isometric",
"Dimension",
"Mesh",
"Solid",
"Facets",
"Terrain",
"Canvas",
"Scene",
"Light",
"Ground"
}
local canvasObjectBlockKinds = __TS__New(Set, ____exports.CANVAS_OBJECT_BLOCK_KINDS)
function ____exports.isCanvasObjectBlockKind(self, kind)
return canvasObjectBlockKinds:has(kind)
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.links.nameIndex"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local directProperties = ____blockEntries.directProperties
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asString = ____valueAccess.asString
local ____blockKinds = require("core.sflSemantic.canvasObjects.processing.blockKinds")
local isCanvasObjectBlockKind = ____blockKinds.isCanvasObjectBlockKind
local function indexLinkableNames(self, blocks, idByName)
for ____, block in ipairs(blocks) do
if isCanvasObjectBlockKind(nil, block.kind) then
idByName:set(
block.name,
asString(
nil,
directProperties(nil, block):get("id")
) or block.name
)
end
indexLinkableNames(
nil,
childBlocks(nil, block),
idByName
)
end
end
function ____exports.buildLinkNameIndex(self, model)
local idByName = __TS__New(Map)
if model then
indexLinkableNames(
nil,
childBlocks(nil, model),
idByName
)
end
return idByName
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.links.presentation"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local Map = ____lualib.Map
local __TS__Iterator = ____lualib.__TS__Iterator
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asString = ____valueAccess.asString
local STRUCTURAL_LINK_PROPERTIES = __TS__New(Set, {
"id",
"from",
"to",
"text",
"order",
"segments"
})
function ____exports.readLinkPresentation(self, properties)
local presentation = {}
for ____, ____value in __TS__Iterator(properties) do
local key = ____value[1]
local value = ____value[2]
do
if STRUCTURAL_LINK_PROPERTIES:has(key) then
goto __continue3
end
local text = asString(nil, value)
if text ~= nil then
presentation[key] = text
end
end
::__continue3::
end
return presentation
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.connections.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.connections.reader"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Map = ____lualib.Map
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local ____endpointReader = require("core.sflSemantic.canvasObjects.artifacts.links.endpointReader")
local readLinkEndpoint = ____endpointReader.readLinkEndpoint
local ____nameIndex = require("core.sflSemantic.canvasObjects.artifacts.links.nameIndex")
local buildLinkNameIndex = ____nameIndex.buildLinkNameIndex
local ____presentation = require("core.sflSemantic.canvasObjects.artifacts.links.presentation")
local readLinkPresentation = ____presentation.readLinkPresentation
local FACES = __TS__New(Set, {
"top",
"bottom",
"front",
"back",
"left",
"right"
})
local function readFace(self, value)
return value ~= nil and FACES:has(value) and value or "front"
end
function ____exports.readConnections(self, model, connectionBlocks, canvasObjects, context, sourceIndexes)
if sourceIndexes == nil then
sourceIndexes = {}
end
local endpointContext = {
idByName = buildLinkNameIndex(nil, model),
canvasObjectById = __TS__New(
Map,
__TS__ArrayMap(
canvasObjects,
function(____, canvasObject) return {canvasObject.id, canvasObject} end
)
)
}
return __TS__ArrayMap(
connectionBlocks,
function(____, block, index)
local properties = context:mergedProps(block)
return {
id = asString(
nil,
properties:get("id")
) or block.name,
fromId = readLinkEndpoint(
nil,
properties:get("from"),
endpointContext
).id,
toId = readLinkEndpoint(
nil,
properties:get("to"),
endpointContext
).id,
fromFace = readFace(
nil,
asString(
nil,
properties:get("fromFace")
)
),
toFace = readFace(
nil,
asString(
nil,
properties:get("toFace")
)
),
order = asNumber(
nil,
properties:get("order")
),
sourceIndex = sourceIndexes[index + 1],
props = readLinkPresentation(nil, properties)
}
end
)
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.links.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.links.blockReader"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local listNumbers = ____valueAccess.listNumbers
local ____endpointReader = require("core.sflSemantic.canvasObjects.artifacts.links.endpointReader")
local readLinkEndpoint = ____endpointReader.readLinkEndpoint
local ____presentation = require("core.sflSemantic.canvasObjects.artifacts.links.presentation")
local readLinkPresentation = ____presentation.readLinkPresentation
function ____exports.readLinkBlock(self, block, canvasObjectContext, endpointContext)
local properties = canvasObjectContext:mergedProps(block)
local from = readLinkEndpoint(
nil,
properties:get("from"),
endpointContext
)
local to = readLinkEndpoint(
nil,
properties:get("to"),
endpointContext
)
return {
id = asString(
nil,
properties:get("id")
) or block.name,
fromId = from.id,
toId = to.id,
text = asString(
nil,
properties:get("text")
),
fromSide = from.side,
fromFraction = from.fraction,
toSide = to.side,
toFraction = to.fraction,
fromPort = from.port,
toPort = to.port,
order = asNumber(
nil,
properties:get("order")
),
segments = listNumbers(
nil,
properties:get("segments")
),
props = readLinkPresentation(nil, properties)
}
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.links.reader"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____blockReader = require("core.sflSemantic.canvasObjects.artifacts.links.blockReader")
local readLinkBlock = ____blockReader.readLinkBlock
local ____nameIndex = require("core.sflSemantic.canvasObjects.artifacts.links.nameIndex")
local buildLinkNameIndex = ____nameIndex.buildLinkNameIndex
function ____exports.readLinks(self, model, linkBlocks, canvasObjects, context, sourceIndexes)
if sourceIndexes == nil then
sourceIndexes = {}
end
local endpointContext = {
idByName = buildLinkNameIndex(nil, model),
canvasObjectById = __TS__New(
Map,
__TS__ArrayMap(
canvasObjects,
function(____, canvasObject) return {canvasObject.id, canvasObject} end
)
)
}
return __TS__ArrayMap(
linkBlocks,
function(____, block, index) return __TS__ObjectAssign(
{},
readLinkBlock(nil, block, context, endpointContext),
{sourceIndex = sourceIndexes[index + 1]}
) end
)
end
return ____exports
end,
["core.sflSemantic.canvasObjects.artifacts.links.netExpansion"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asString = ____valueAccess.asString
local function netMembers(self, block, context)
local membersValue = context:mergedProps(block):get("members")
return (membersValue and membersValue.type) == "list" and __TS__ArrayFlatMap(
membersValue.values,
function(____, value) return value.type == "ident" and ({value.segments}) or ({}) end
) or ({})
end
local function netLink(self, block, from, to, index, text)
local entries = {{type = "property", property = {key = "from", value = {type = "endpoint", segments = from}}}, {type = "property", property = {key = "to", value = {type = "endpoint", segments = to}}}}
if __t(nil, text) then
entries[#entries + 1] = {type = "property", property = {key = "text", value = {type = "string", value = text}}}
end
return {
kind = "Link",
name = (block.name .. "_") .. tostring(index + 1),
composition = {},
entries = entries
}
end
function ____exports.expandNetLinks(self, block, context)
local members = netMembers(nil, block, context)
if #members < 2 then
return {}
end
local text = asString(
nil,
context:mergedProps(block):get("text")
)
return __TS__ArrayMap(
__TS__ArraySlice(members, 1),
function(____, member, index) return netLink(
nil,
block,
members[1],
member,
index,
text
) end
)
end
return ____exports
end,
["core.sflSemantic.canvasObjects.processing.layout.flow"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
function ____exports.createFlowPositioner(self, block, context)
local axis = asString(
nil,
context:layoutProp(block, "flow")
)
local gap = asNumber(
nil,
context:layoutProp(block, "gap")
) or 0
local cursor = 0
return function(____, size)
if axis ~= "horizontal" and axis ~= "vertical" then
return nil
end
local position = axis == "horizontal" and ({cursor, 0}) or ({0, cursor})
cursor = cursor + ((axis == "horizontal" and size[1] or size[2]) + gap)
return position
end
end
return ____exports
end,
["core.sflSemantic.definitions.shaders"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local directProperties = ____blockEntries.directProperties
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
function ____exports.readShaderDefinition(self, block)
local properties = directProperties(nil, block)
local program = asString(
nil,
properties:get("program")
)
local surfacePadding = asNumber(
nil,
properties:get("surfacePadding")
)
if not __t(nil, program) then
return nil
end
local parameters = {}
for ____, ____value in __TS__Iterator(properties) do
local key = ____value[1]
local value = ____value[2]
do
if key == "program" or key == "surfacePadding" then
goto __continue4
end
local number = asNumber(nil, value)
local text = asString(nil, value)
if number ~= nil then
parameters[key] = number
elseif text ~= nil then
local ____key_2 = key
local ____temp_1
if text == "true" then
____temp_1 = true
else
local ____temp_0
if text == "false" then
____temp_0 = false
else
____temp_0 = text
end
____temp_1 = ____temp_0
end
parameters[____key_2] = ____temp_1
end
end
::__continue4::
end
return __TS__ObjectAssign(
{name = block.name, program = program},
surfacePadding == nil and ({}) or ({surfacePadding = math.max(0, surfacePadding)}),
{parameters = parameters}
)
end
return ____exports
end,
["core.sflSemantic.definitions.symbols"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Map = ____lualib.Map
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____outline = require("core.model.outline.index")
local combineOutlines = ____outline.combineOutlines
local ringArea = ____outline.ringArea
local ____path = require("core.model.path.index")
local flattenPath = ____path.flattenPath
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local directProperties = ____blockEntries.directProperties
local placementValue = ____blockEntries.placementValue
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asNumber = ____valueAccess.asNumber
local asString = ____valueAccess.asString
local tupleValues = ____valueAccess.tupleValues
local function readSymbolPoints(self, block)
local value = directProperties(nil, block):get("points")
local points = {}
local tensions = {}
if (value and value.type) ~= "list" then
return {points = points, tensions = tensions}
end
for ____, item in ipairs(value.values) do
do
if item.type ~= "list" or #item.values < 2 then
goto __continue4
end
local x = asNumber(nil, item.values[1])
local y = asNumber(nil, item.values[2])
if x == nil or y == nil then
goto __continue4
end
points[#points + 1] = {x, y}
local ____temp_2
if item.values[3] == nil then
____temp_2 = nil
else
____temp_2 = asNumber(nil, item.values[3])
end
tensions[#tensions + 1] = ____temp_2
end
::__continue4::
end
return {points = points, tensions = tensions}
end
local function readSymbolPorts(self, block)
local ports = __TS__ArrayFlatMap(
__TS__ArrayFilter(
childBlocks(nil, block),
function(____, child) return child.kind == "Port" end
),
function(____, port)
local position = tupleValues(
nil,
placementValue(nil, port, "position", "at")
)
if type(position and position[1]) ~= "number" or type(position[2]) ~= "number" then
return {}
end
return {{name = port.name, at = {position[1], position[2]}}}
end
)
return #ports > 0 and ports or nil
end
local function flatRing(self, points, tensions, tension)
local curve = __TS__ArrayMap(
points,
function(____, ____bindingPattern0, index)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
return tensions[index + 1] == nil and ({x = x, y = y}) or ({x = x, y = y, tension = tensions[index + 1]})
end
)
return __TS__ArrayMap(
flattenPath(nil, {points = curve, tension = tension, closed = true}),
function(____, point) return {point.x, point.y} end
)
end
local function ringsOf(____, symbol)
return symbol.rings or ({flatRing(nil, symbol.points, symbol.pointTensions or ({}), symbol.tension or 0)})
end
local function childOutline(self, child, lookup)
local properties = directProperties(nil, child)
local name = asString(
nil,
properties:get("symbol")
)
if not __t(nil, name) then
local ____readSymbolPoints_result_5 = readSymbolPoints(nil, child)
local points = ____readSymbolPoints_result_5.points
local tensions = ____readSymbolPoints_result_5.tensions
return #points >= 3 and ({flatRing(
nil,
points,
tensions,
asNumber(
nil,
properties:get("tension")
) or 0
)}) or ({})
end
local other = lookup(nil, name)
if not other then
return {}
end
local x, y = table.unpack(
tupleValues(
nil,
placementValue(nil, child, "position", "at")
) or ({}),
1,
2
)
if x == nil then
x = 0
end
if y == nil then
y = 0
end
local width, height = table.unpack(
tupleValues(
nil,
placementValue(nil, child, "size")
) or ({}),
1,
2
)
if width == nil then
width = 1
end
if height == nil then
height = 1
end
if type(x) ~= "number" or type(y) ~= "number" or type(width) ~= "number" or type(height) ~= "number" then
return {}
end
return __TS__ArrayMap(
ringsOf(nil, other),
function(____, ring) return __TS__ArrayMap(
ring,
function(____, ____bindingPattern0)
local py
local px
px = ____bindingPattern0[1]
py = ____bindingPattern0[2]
return {x + px * width, y + py * height}
end
) end
)
end
function ____exports.readSymbolDefinition(self, block, lookup)
if lookup == nil then
lookup = function() return nil end
end
local ____readSymbolPoints_result_6 = readSymbolPoints(nil, block)
local points = ____readSymbolPoints_result_6.points
local tensions = ____readSymbolPoints_result_6.tensions
if #points < 2 then
return nil
end
local plain = {
name = block.name,
points = points,
pointTensions = __TS__ArraySome(
tensions,
function(____, tension) return tension ~= nil end
) and tensions or nil,
tension = asNumber(
nil,
directProperties(nil, block):get("tension")
),
ports = readSymbolPorts(nil, block)
}
local changes = __TS__ArrayFilter(
childBlocks(nil, block),
function(____, child) return child.kind == "Cut" or child.kind == "Add" end
)
if #changes == 0 or #points < 3 then
return plain
end
local outline = ringsOf(nil, plain)
for ____, child in ipairs(changes) do
local other = childOutline(nil, child, lookup)
if #other > 0 then
outline = combineOutlines(nil, outline, other, child.kind == "Cut" and "cut" or "add")
end
end
if #outline == 0 then
return nil
end
local largest = __TS__ArrayReduce(
outline,
function(____, best, ring) return math.abs(ringArea(nil, ring)) > math.abs(ringArea(nil, best)) and ring or best end
)
return {name = block.name, points = largest, ports = plain.ports, rings = outline}
end
return ____exports
end,
["core.sflSemantic.definitions.collection"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Set = ____lualib.Set
local __TS__Iterator = ____lualib.__TS__Iterator
local ____exports = {}
local projectModel, collectSketches, collectShaderDefinitions, collectStyleDefinitions, collectLayoutDefinitions, collectSymbolDefinitions, findCanvasModel
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local ____shaders = require("core.sflSemantic.definitions.shaders")
local readShaderDefinition = ____shaders.readShaderDefinition
local ____symbols = require("core.sflSemantic.definitions.symbols")
local readSymbolDefinition = ____symbols.readSymbolDefinition
function projectModel(self, block)
return __TS__ArrayFind(
childBlocks(nil, block),
function(____, child) return child.kind == "Model" end
)
end
function collectSketches(self, blocks, found)
if found == nil then
found = __TS__New(Map)
end
for ____, block in ipairs(blocks) do
if block.kind == "Sketch" then
found:set(block.name, block)
else
collectSketches(
nil,
childBlocks(nil, block),
found
)
end
end
return found
end
function collectShaderDefinitions(self, sflDocument)
local shaders = __TS__New(Map)
for ____, block in ipairs(sflDocument.blocks) do
do
if block.kind ~= "Shader" then
goto __continue11
end
local shader = readShaderDefinition(nil, block)
if shader then
shaders:set(block.name, shader)
end
end
::__continue11::
end
return shaders
end
function collectStyleDefinitions(self, sflDocument)
local styles = __TS__New(Map)
for ____, block in ipairs(sflDocument.blocks) do
if block.kind == "Style" then
styles:set(block.name, block)
end
end
return styles
end
function collectLayoutDefinitions(self, sflDocument)
local layouts = __TS__New(Map)
for ____, block in ipairs(sflDocument.blocks) do
if block.kind == "Layout" then
layouts:set(block.name, block)
end
end
return layouts
end
function collectSymbolDefinitions(self, sflDocument)
local symbols = __TS__New(Map)
local blocks = __TS__New(
Map,
__TS__ArrayMap(
__TS__ArrayFilter(
sflDocument.blocks,
function(____, block) return block.kind == "Symbol" end
),
function(____, block) return {block.name, block} end
)
)
local reading = __TS__New(Set)
local read
read = function(____, name)
local known = symbols:get(name)
local block = blocks:get(name)
if known or not block or reading:has(name) then
return known
end
reading:add(name)
local symbol = readSymbolDefinition(nil, block, read)
reading:delete(name)
if symbol then
symbols:set(name, symbol)
end
return symbol
end
for ____, name in __TS__Iterator(blocks:keys()) do
read(nil, name)
end
return symbols
end
function findCanvasModel(self, sflDocument)
for ____, block in ipairs(sflDocument.blocks) do
if block.kind == "Model" then
return block
end
if block.kind == "Project" then
local model = projectModel(nil, block)
if model then
return model
end
end
end
return nil
end
function ____exports.collectCanvasDefinitions(self, sflDocument)
return {
styles = collectStyleDefinitions(nil, sflDocument),
layouts = collectLayoutDefinitions(nil, sflDocument),
symbols = collectSymbolDefinitions(nil, sflDocument),
sketches = collectSketches(nil, sflDocument.blocks),
shaders = collectShaderDefinitions(nil, sflDocument),
model = findCanvasModel(nil, sflDocument)
}
end
return ____exports
end,
["core.model.diagnostic.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.diagnostic.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.groups.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.canvasObjects.typedObjects"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____object = require("core.sflSemantic.canvasObjects.artifacts.chart.object")
____exports.isChartObject = ____object.isChartObject
end
do
local ____object = require("core.sflSemantic.canvasObjects.artifacts.dimension.object")
____exports.isDimensionObject = ____object.isDimensionObject
end
do
local ____object = require("core.sflSemantic.canvasObjects.artifacts.isometric.object")
____exports.isIsometricObject = ____object.isIsometricObject
end
do
local ____object = require("core.sflSemantic.canvasObjects.artifacts.mesh.object")
____exports.isMeshGroundObject = ____object.isMeshGroundObject
____exports.isMeshLightObject = ____object.isMeshLightObject
____exports.isMeshObject = ____object.isMeshObject
____exports.isMeshSceneObject = ____object.isMeshSceneObject
____exports.isMeshSurfaceObject = ____object.isMeshSurfaceObject
end
do
local ____object = require("core.sflSemantic.canvasObjects.artifacts.path.object")
____exports.isPathObject = ____object.isPathObject
end
do
local ____object = require("core.sflSemantic.canvasObjects.artifacts.swimlane.object")
____exports.isSwimlaneObject = ____object.isSwimlaneObject
end
return ____exports
end,
["core.sflSemantic.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____typedObjects = require("core.sflSemantic.canvasObjects.typedObjects")
____exports.isChartObject = ____typedObjects.isChartObject
____exports.isDimensionObject = ____typedObjects.isDimensionObject
____exports.isIsometricObject = ____typedObjects.isIsometricObject
____exports.isMeshGroundObject = ____typedObjects.isMeshGroundObject
____exports.isMeshLightObject = ____typedObjects.isMeshLightObject
____exports.isMeshObject = ____typedObjects.isMeshObject
____exports.isMeshSceneObject = ____typedObjects.isMeshSceneObject
____exports.isMeshSurfaceObject = ____typedObjects.isMeshSurfaceObject
____exports.isPathObject = ____typedObjects.isPathObject
____exports.isSwimlaneObject = ____typedObjects.isSwimlaneObject
end
return ____exports
end,
["core.sflSemantic.definitions.compositionReferences"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
function ____exports.classifyCompositionReferences(self, composition, styleBlocks, layoutBlocks)
local styleRef
local layoutRef
for ____, reference in ipairs(composition) do
if styleBlocks:has(reference) then
styleRef = reference
elseif layoutBlocks:has(reference) then
layoutRef = reference
end
end
return {styleRef = styleRef, layoutRef = layoutRef}
end
local function collectBlockDiagnostics(self, block, styleBlocks, layoutBlocks, diagnostics)
for ____, reference in ipairs(block.composition) do
if not styleBlocks:has(reference) and not layoutBlocks:has(reference) then
diagnostics[#diagnostics + 1] = {severity = "warning", code = "unresolved-style-or-layout", ownerId = block.name, message = ((("\"" .. reference) .. "\" is not a Style or Layout defined at the top level of the document — \"") .. block.name) .. "\" gets no shape, fill, or stroke from it."}
end
end
for ____, child in ipairs(childBlocks(nil, block)) do
collectBlockDiagnostics(
nil,
child,
styleBlocks,
layoutBlocks,
diagnostics
)
end
end
function ____exports.collectUnresolvedCompositionReferences(self, sflDocument, styleBlocks, layoutBlocks)
local diagnostics = {}
for ____, block in ipairs(sflDocument.blocks) do
collectBlockDiagnostics(
nil,
block,
styleBlocks,
layoutBlocks,
diagnostics
)
end
return diagnostics
end
return ____exports
end,
["core.sflSemantic.definitions.inheritance"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Class = ____lualib.__TS__Class
local Set = ____lualib.Set
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__Spread = ____lualib.__TS__Spread
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local DefinitionInheritanceResolver
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local directProperties = ____blockEntries.directProperties
function ____exports.resolveDefinitionInheritance(self, definitions, parentName)
return __TS__New(DefinitionInheritanceResolver, definitions, parentName):resolveAll()
end
DefinitionInheritanceResolver = __TS__Class()
DefinitionInheritanceResolver.name = "DefinitionInheritanceResolver"
function DefinitionInheritanceResolver.prototype.____constructor(self, definitions, parentName)
self._p_resolved = __TS__New(Map)
self._p_definitions = definitions
self._p_parentName = parentName
end
function DefinitionInheritanceResolver.prototype.resolveAll(self)
for ____, name in __TS__Iterator(self._p_definitions:keys()) do
self:_p_resolveDefinition(
name,
__TS__New(Set)
)
end
return self._p_resolved
end
function DefinitionInheritanceResolver.prototype._p_resolveDefinition(self, name, ancestry)
local cached = self._p_resolved:get(name)
if cached then
return cached
end
local block = self._p_definitions:get(name)
if not block or ancestry:has(name) then
return __TS__New(Map)
end
local ____self__p_inheritedProperties_2 = self._p_inheritedProperties
local ____Set_1 = Set
local ____array_0 = __TS__SparseArrayNew(__TS__Spread(ancestry))
__TS__SparseArrayPush(____array_0, name)
local values = ____self__p_inheritedProperties_2(
self,
block,
__TS__New(
____Set_1,
{__TS__SparseArraySpread(____array_0)}
)
)
for ____, ____value in __TS__Iterator(directProperties(nil, block)) do
local key = ____value[1]
local value = ____value[2]
values:set(key, value)
end
self._p_resolved:set(name, values)
return values
end
function DefinitionInheritanceResolver.prototype._p_inheritedProperties(self, block, ancestry)
local parent = self:_p_parentName(block)
return __t(nil, parent) and __TS__New(
Map,
self:_p_resolveDefinition(parent, ancestry)
) or __TS__New(Map)
end
return ____exports
end,
["core.sflSemantic.definitions.propertyReaders"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Iterator = ____lualib.__TS__Iterator
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local directProperties = ____blockEntries.directProperties
local layoutProperties = ____blockEntries.layoutProperties
local styleProperties = ____blockEntries.styleProperties
local ____compositionReferences = require("core.sflSemantic.definitions.compositionReferences")
local classifyCompositionReferences = ____compositionReferences.classifyCompositionReferences
local ____inheritance = require("core.sflSemantic.definitions.inheritance")
local resolveDefinitionInheritance = ____inheritance.resolveDefinitionInheritance
function ____exports.createCanvasObjectPropertyReaders(self, definitions)
local ____definitions_0 = definitions
local styles = ____definitions_0.styles
local layouts = ____definitions_0.layouts
local symbols = ____definitions_0.symbols
local sketches = ____definitions_0.sketches
local shaders = ____definitions_0.shaders
local function references(____, block)
return classifyCompositionReferences(nil, block.composition, styles, layouts)
end
local resolvedStyles = resolveDefinitionInheritance(
nil,
styles,
function(____, block) return references(nil, block).styleRef end
)
local resolvedLayouts = resolveDefinitionInheritance(
nil,
layouts,
function(____, block) return references(nil, block).layoutRef end
)
local function mergedProps(____, block)
local merged = __TS__New(
Map,
resolvedStyles:get(references(nil, block).styleRef or "") or ({})
)
for ____, ____value in __TS__Iterator(directProperties(nil, block)) do
local key = ____value[1]
local value = ____value[2]
merged:set(key, value)
end
for ____, ____value in __TS__Iterator(styleProperties(nil, block)) do
local key = ____value[1]
local value = ____value[2]
merged:set(key, value)
end
return merged
end
local function layoutProp(____, block, key)
local localProperties = layoutProperties(nil, block)
if localProperties:has(key) then
return localProperties:get(key)
end
local reference = references(nil, block).layoutRef
local ____t_result_3
if __t(nil, reference) then
local ____opt_1 = resolvedLayouts:get(reference)
____t_result_3 = ____opt_1 and ____opt_1:get(key)
else
____t_result_3 = nil
end
return ____t_result_3
end
return {
mergedProps = mergedProps,
layoutProp = layoutProp,
symbolDefs = symbols,
sketchDefs = sketches,
shaderDefs = shaders
}
end
return ____exports
end,
["core.sflSemantic.diagnostics.charts"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayJoin = ____lualib.__TS__ArrayJoin
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__Spread = ____lualib.__TS__Spread
local ____exports = {}
local ____chart = require("core.model.chart.index")
local CHART_TYPES = ____chart.CHART_TYPES
local isChartType = ____chart.isChartType
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local contentChildren = ____blockEntries.contentChildren
local directProperties = ____blockEntries.directProperties
local styleProperties = ____blockEntries.styleProperties
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asString = ____valueAccess.asString
local NATIVE_CIRCULAR_CHART_TYPES = __TS__New(Set, {"radar", "radial"})
local OPTIONAL_CIRCULAR_GRID_CHART_TYPES = __TS__New(Set, {"scatter", "custom", "hexbin"})
function ____exports.collectUnsupportedChartTypes(self, doc)
local diagnostics = {}
local visit
visit = function(____, block)
if block.kind == "Chart" then
local declared = asString(
nil,
directProperties(nil, block):get("type")
)
if declared ~= nil and not isChartType(nil, declared) then
diagnostics[#diagnostics + 1] = {
severity = "warning",
code = "unsupported-chart-type",
ownerId = block.name,
message = ((("Unsupported chart type '" .. declared) .. "' — drawn as a plain series plot. Supported: ") .. __TS__ArrayJoin(CHART_TYPES, ", ")) .. "."
}
end
end
for ____, child in ipairs(childBlocks(nil, block)) do
visit(nil, child)
end
end
for ____, block in ipairs(doc.blocks) do
visit(nil, block)
end
return diagnostics
end
function ____exports.collectEmptySeries(self, doc)
local diagnostics = {}
local visit
visit = function(____, block)
if block.kind == "Chart" then
for ____, series in ipairs(__TS__ArrayFilter(
contentChildren(nil, block),
function(____, child) return child.kind == "Series" end
)) do
if not directProperties(nil, series):has("values") then
diagnostics[#diagnostics + 1] = {severity = "warning", code = "series-without-values", ownerId = series.name, message = ("Series '" .. series.name) .. "' has no values. If this was meant to be an Axis or Rule, it needs that keyword in front of the name — inside data{}, a bare name is read as a Series."}
end
end
end
for ____, child in ipairs(childBlocks(nil, block)) do
visit(nil, child)
end
end
for ____, block in ipairs(doc.blocks) do
visit(nil, block)
end
return diagnostics
end
function ____exports.collectUnsupportedGridShapes(self, doc)
local diagnostics = {}
local visit
visit = function(____, block)
if block.kind == "Chart" then
local declared = asString(
nil,
directProperties(nil, block):get("type")
)
local chartType = isChartType(nil, declared) and declared or "bar"
local gridShape = asString(
nil,
styleProperties(nil, block):get("gridShape")
)
if gridShape == "circle" and not OPTIONAL_CIRCULAR_GRID_CHART_TYPES:has(chartType) and not NATIVE_CIRCULAR_CHART_TYPES:has(chartType) then
diagnostics[#diagnostics + 1] = {
severity = "warning",
code = "unsupported-grid-shape",
ownerId = block.name,
message = ((("gridShape: circle isn't supported on '" .. chartType) .. "' — drawn with the standard rectangular grid instead. Supported: ") .. table.concat(
{__TS__Spread(OPTIONAL_CIRCULAR_GRID_CHART_TYPES)},
", "
)) .. "."
}
end
end
for ____, child in ipairs(childBlocks(nil, block)) do
visit(nil, child)
end
end
for ____, block in ipairs(doc.blocks) do
visit(nil, block)
end
return diagnostics
end
return ____exports
end,
["core.sflSemantic.diagnostics.components"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____component = require("core.model.component.index")
local componentTypes = ____component.componentTypes
local isComponentType = ____component.isComponentType
local ____ast = require("core.sflLanguage.ast")
local isComponentBlockKind = ____ast.isComponentBlockKind
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local directProperties = ____blockEntries.directProperties
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asString = ____valueAccess.asString
function ____exports.collectUnsupportedComponentTypes(self, sflDocument)
local diagnostics = {}
local visit
visit = function(____, block)
if isComponentBlockKind(nil, block.kind) then
local ____type = asString(
nil,
directProperties(nil, block):get("type")
) or "rollingNumber"
if not isComponentType(nil, ____type) then
diagnostics[#diagnostics + 1] = {
severity = "warning",
code = "unsupported-component-type",
ownerId = block.name,
message = ((("Unsupported component type '" .. ____type) .. "'. Supported: ") .. table.concat(
componentTypes(nil),
", "
)) .. "."
}
end
end
for ____, child in ipairs(childBlocks(nil, block)) do
visit(nil, child)
end
end
for ____, block in ipairs(sflDocument.blocks) do
visit(nil, block)
end
return diagnostics
end
return ____exports
end,
["core.sflSemantic.diagnostics.meshes"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local Map = ____lualib.Map
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local directProperties = ____blockEntries.directProperties
local layoutProperties = ____blockEntries.layoutProperties
local styleProperties = ____blockEntries.styleProperties
local ____resolver = require("core.sflSemantic.canvasObjects.artifacts.mesh.resolver")
local EDGE_WORDS_BEFORE = ____resolver.EDGE_WORDS_BEFORE
local function warning(____, code, ownerId, message)
return {severity = "warning", code = code, ownerId = ownerId, message = message}
end
local function meshesIn(self, block)
return __TS__ArrayFlatMap(
childBlocks(nil, block),
function(____, child) return child.kind == "Mesh" and ({
child,
table.unpack(meshesIn(nil, child))
}) or meshesIn(nil, child) end
)
end
local function blocksIn(self, block)
return {
block,
table.unpack(__TS__ArrayFlatMap(
childBlocks(nil, block),
blocksIn
))
}
end
function ____exports.collectMeshProblems(self, sflDocument)
local outside = __TS__ArrayFlatMap(
sflDocument.blocks,
function(____, block)
if __TS__ArrayIncludes({
"Mesh",
"Solid",
"Facets",
"Terrain",
"Sketch",
"Scene",
"Canvas",
"Light",
"Ground"
}, block.kind) then
return {warning(nil, "mesh-outside-model", block.name, ((block.kind .. " '") .. block.name) .. "' is not drawn: it has to be inside a Model.")}
end
if block.kind == "Model" and directProperties(nil, block):has("asset") then
return {warning(nil, "model-with-asset", block.name, "'asset' on a Model does nothing. Put the asset into a Mesh inside the Model.")}
end
return {}
end
)
local missing = __TS__ArrayMap(
__TS__ArrayFilter(
__TS__ArrayFlatMap(
__TS__ArrayFilter(
sflDocument.blocks,
function(____, block) return block.kind == "Model" end
),
meshesIn
),
function(____, mesh) return not directProperties(nil, mesh):has("asset") and not styleProperties(nil, mesh):has("asset") end
),
function(____, mesh) return warning(nil, "mesh-without-asset", mesh.name, ("Mesh '" .. mesh.name) .. "' has no asset, so there is nothing to draw.") end
)
local onSurface = __TS__ArrayMap(
__TS__ArrayFlatMap(
__TS__ArrayFilter(
__TS__ArrayFlatMap(sflDocument.blocks, blocksIn),
function(____, block) return block.kind == "Canvas" end
),
meshesIn
),
function(____, mesh) return warning(nil, "mesh-on-canvas", mesh.name, ("Mesh '" .. mesh.name) .. "' lies on a Canvas, which is a flat surface. Put it into the Scene next to the Canvas.") end
)
local extraLights = __TS__ArrayMap(
__TS__ArrayFlatMap(
__TS__ArrayFilter(
__TS__ArrayFlatMap(sflDocument.blocks, blocksIn),
function(____, block) return block.kind == "Scene" end
),
function(____, scene) return __TS__ArraySlice(
__TS__ArrayFilter(
childBlocks(nil, scene),
function(____, child) return child.kind == "Light" end
),
3
) end
),
function(____, light) return warning(nil, "extra-light", light.name, ("Light '" .. light.name) .. "' does nothing: a Scene has one sun and up to two lights from the side.") end
)
local sketchSizes = __TS__ArrayMap(
__TS__ArrayFilter(
__TS__ArrayFlatMap(sflDocument.blocks, blocksIn),
function(____, block) return block.kind == "Solid" and directProperties(nil, block):has("sketch") and layoutProperties(nil, block):has("size") end
),
function(____, solid) return warning(
nil,
"sketch-solid-size",
solid.name,
directProperties(nil, solid):has("height") and ("Solid '" .. solid.name) .. "' is made from a Sketch, which gives its width and depth, and height gives its height: size in its layout does nothing." or ("Solid '" .. solid.name) .. "' is made from a Sketch, which gives its width and depth. Its height is read from size in its layout, but is written as height: … now."
) end
)
local mirrors = __TS__ArrayFlatMap(
__TS__ArrayFlatMap(sflDocument.blocks, blocksIn),
function(____, block)
local own = directProperties(nil, block)
if own:has("mirror") and block.kind ~= "Solid" then
return {warning(nil, "mirror-not-solid", block.name, ((block.kind .. " '") .. block.name) .. "' has mirror, which makes a twin of a Solid alone: it does nothing here.")}
end
if own:has("flip") and __TS__ArrayIncludes({"Solid", "Cut", "Add", "Keep"}, block.kind) then
return {warning(nil, "flip-written", block.name, ((block.kind .. " '") .. block.name) .. "' writes flip, which is no word of SFL. It still mirrors this block alone and may go; mirror makes a mirrored twin beside it.")}
end
return {}
end
)
local edgeWords = __TS__ArrayFlatMap(
__TS__ArrayFilter(
__TS__ArrayFlatMap(sflDocument.blocks, blocksIn),
function(____, block) return __TS__ArrayIncludes({"Solid", "Cut", "Add", "Keep"}, block.kind) end
),
function(____, block)
local own = directProperties(nil, block)
local words = __TS__ArrayMap(
__TS__ArrayFilter(
__TS__ObjectKeys(EDGE_WORDS_BEFORE),
function(____, word)
local ____opt_0 = own:get(word)
return (____opt_0 and ____opt_0.type) == "list"
end
),
function(____, word) return (word .. " is written ") .. EDGE_WORDS_BEFORE[word] end
)
local edge = own:get("edge")
if (edge and edge.type) == "ident" and edge.segments[1] == "round" then
words[#words + 1] = "edge: round with chamfer is written fillet"
end
return __t(nil, #words) and ({warning(
nil,
"edge-word-before",
block.name,
((((block.kind .. " '") .. block.name) .. "': ") .. table.concat(words, ", ")) .. " now. It is still read."
)}) or ({})
end
)
local wordsBefore = __TS__ArrayFlatMap(
__TS__ArrayFlatMap(sflDocument.blocks, blocksIn),
function(____, block)
local own = directProperties(nil, block)
if block.kind == "Light" and own:has("height") then
return {warning(nil, "light-height", block.name, ("Light '" .. block.name) .. "': height is written elevation now, the degrees above the horizon, as height is a length elsewhere. It is still read.")}
end
if block.kind == "Ground" and own:has("height") then
return {warning(nil, "ground-height", block.name, ("Ground '" .. block.name) .. "': height is written as its place now, layout { position: 0, height, 0 }. It is still read.")}
end
return {}
end
)
local ____array_4 = __TS__SparseArrayNew(table.unpack(outside))
__TS__SparseArrayPush(
____array_4,
table.unpack(missing)
)
__TS__SparseArrayPush(
____array_4,
table.unpack(onSurface)
)
__TS__SparseArrayPush(
____array_4,
table.unpack(extraLights)
)
__TS__SparseArrayPush(
____array_4,
table.unpack(sketchSizes)
)
__TS__SparseArrayPush(
____array_4,
table.unpack(mirrors)
)
__TS__SparseArrayPush(
____array_4,
table.unpack(edgeWords)
)
__TS__SparseArrayPush(
____array_4,
table.unpack(wordsBefore)
)
return {__TS__SparseArraySpread(____array_4)}
end
return ____exports
end,
["core.sflSemantic.diagnostics.names"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local Map = ____lualib.Map
local __TS__StringSlice = ____lualib.__TS__StringSlice
local __TS__Iterator = ____lualib.__TS__Iterator
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local OBJECTS = __TS__New(Set, {
"Shape",
"Text",
"Image",
"Container",
"Screen",
"Chart",
"Path",
"Widget",
"Component",
"Entity",
"Isometric",
"Group"
})
local LINKS = __TS__New(Set, {"Link", "Connection"})
function ____exports.collectDuplicateNames(self, sflDocument)
local counts = __TS__New(Map)
local visit
visit = function(____, block)
local space = OBJECTS:has(block.kind) and "object" or (LINKS:has(block.kind) and "link" or nil)
if __t(nil, space) then
local key = (space .. ":") .. block.name
counts:set(
key,
(counts:get(key) or 0) + 1
)
end
for ____, child in ipairs(childBlocks(nil, block)) do
visit(nil, child)
end
end
for ____, block in ipairs(sflDocument.blocks) do
visit(nil, block)
end
local diagnostics = {}
for ____, ____value in __TS__Iterator(counts) do
local key = ____value[1]
local count = ____value[2]
if count > 1 then
local name = __TS__StringSlice(
key,
(string.find(key, ":", nil, true) or 0) - 1 + 1
)
diagnostics[#diagnostics + 1] = {
severity = "warning",
code = "duplicate-name",
ownerId = name,
message = ((("The name '" .. name) .. "' is used ") .. tostring(count)) .. " times. A name must be unique in a document, so give each block its own."
}
end
end
return diagnostics
end
return ____exports
end,
["core.sflSemantic.diagnostics.placement"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local Map = ____lualib.Map
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local directProperties = ____blockEntries.directProperties
local ____blockKinds = require("core.sflSemantic.canvasObjects.processing.blockKinds")
local isCanvasObjectBlockKind = ____blockKinds.isCanvasObjectBlockKind
local CHART = __TS__New(Set, {
"Chart",
"Series",
"Axis",
"Rule",
"Band",
"Legend",
"Mark"
})
local PLACED = __TS__New(Set, {
"Solid",
"Mesh",
"Facets",
"Terrain",
"Canvas",
"Group",
"Use",
"Repeat"
})
local KEYS = {
"at",
"position",
"rotation",
"scale",
"size"
}
local function inShape(____, block, parent)
return block.kind == "Rect" or block.kind == "Circle" or block.kind == "Port" or (parent and parent.kind) == "Symbol"
end
local function readBefore(self, key, block, parent)
if key == "position" then
return block.kind == "Light"
end
if key == "at" then
return inShape(nil, block, parent)
end
return key == "size" and inShape(nil, block, parent) and block.kind ~= "Circle" and block.kind ~= "Port"
end
local function meansPlace(self, key, block, parent)
if (key == "position" or key == "rotation") and (isCanvasObjectBlockKind(nil, block.kind) or PLACED:has(block.kind)) then
return true
end
return readBefore(nil, key, block, parent) or key ~= "at" and PLACED:has(block.kind)
end
function ____exports.collectPlacementsOutsideLayout(self, doc)
local found = {}
local visit
visit = function(____, block, parent)
local own = directProperties(nil, block)
for ____, key in ipairs(CHART:has(block.kind) and ({}) or __TS__ArrayFilter(
KEYS,
function(____, written) return own:has(written) end
)) do
do
if not meansPlace(nil, key, block, parent) then
goto __continue10
end
local now = key == "at" and "position" or key
found[#found + 1] = {
severity = "warning",
code = "placement-outside-layout",
ownerId = block.name,
message = readBefore(nil, key, block, parent) and ((((((block.kind .. " '") .. block.name) .. "' writes ") .. key) .. " on itself. It is read, but is written in its layout now: layout { ") .. now) .. ": … }." or ((((((block.kind .. " '") .. block.name) .. "' writes ") .. key) .. " on itself, where it does nothing. Write it in its layout: layout { ") .. now) .. ": … }."
}
end
::__continue10::
end
for ____, child in ipairs(childBlocks(nil, block)) do
visit(nil, child, block)
end
end
for ____, block in ipairs(doc.blocks) do
visit(nil, block, nil)
end
return found
end
return ____exports
end,
["core.sflSemantic.diagnostics.properties"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local Map = ____lualib.Map
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local directProperties = ____blockEntries.directProperties
local styleProperties = ____blockEntries.styleProperties
local function blocksIn(self, block)
return {
block,
table.unpack(__TS__ArrayFlatMap(
childBlocks(nil, block),
blocksIn
))
}
end
function ____exports.collectPropertiesWrittenTwice(self, sflDocument)
return __TS__ArrayFlatMap(
__TS__ArrayFlatMap(sflDocument.blocks, blocksIn),
function(____, block)
local own = directProperties(nil, block)
return __TS__ArrayMap(
__TS__ArrayFilter(
{__TS__Spread(styleProperties(nil, block):keys())},
function(____, key) return own:has(key) end
),
function(____, key) return {severity = "warning", code = "property-twice", ownerId = block.name, message = ((((("'" .. key) .. "' of ") .. block.kind) .. " '") .. block.name) .. "' stands on the block and in its style. The one in the style counts."} end
)
end
)
end
local FORM = __TS__New(Set, {
"asset",
"symbol",
"sketch",
"loft",
"height",
"chamfer",
"fillet",
"chamferEdges",
"filletEdges",
"chamferTop",
"chamferBottom",
"filletTop",
"filletBottom",
"mirror",
"taper",
"shift",
"points",
"faces",
"thickness",
"bevel",
"symmetry",
"heights",
"picture",
"anchor",
"position",
"rotation",
"scale",
"size",
"at"
})
local BODIES = __TS__New(Set, {
"Solid",
"Mesh",
"Facets",
"Terrain",
"Cut",
"Add",
"Keep",
"Light",
"Ground",
"Canvas",
"Group",
"Use"
})
function ____exports.collectFormInStyle(self, sflDocument)
return __TS__ArrayFlatMap(
__TS__ArrayFlatMap(sflDocument.blocks, blocksIn),
function(____, block) return __TS__ArrayMap(
__TS__ArrayFilter(
{__TS__Spread(BODIES:has(block.kind) and styleProperties(nil, block):keys() or ({}))},
function(____, key) return FORM:has(key) end
),
function(____, key) return {
severity = "warning",
code = "form-in-style",
ownerId = block.name,
message = ((((((("'" .. key) .. "' of ") .. block.kind) .. " '") .. block.name) .. "' stands in its style, which says how it looks. It says what it is: write it on the block") .. (__TS__ArrayIncludes({
"position",
"rotation",
"scale",
"size",
"at"
}, key) and ", in its layout" or "")) .. ". It is still read."
} end
) end
)
end
return ____exports
end,
["core.sflSemantic.diagnostics.references"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Map = ____lualib.Map
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local __TS__ArrayConcat = ____lualib.__TS__ArrayConcat
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local directProperties = ____blockEntries.directProperties
local blocksIn
blocksIn = function(____, block) return {
block,
table.unpack(__TS__ArrayFlatMap(
childBlocks(nil, block),
blocksIn
))
} end
local function nameOf(____, value)
return (value and value.type) == "ident" and #value.segments == 1 and value.segments[1] or nil
end
local OUTLINED = __TS__New(Set, {
"Solid",
"Cut",
"Add",
"Keep",
"Isometric",
"Shape",
"Entity"
})
local BODIES = __TS__New(Set, {"Mesh", "Solid", "Facets", "Terrain"})
function ____exports.collectUnknownReferences(self, doc)
local all = __TS__ArrayFlatMap(doc.blocks, blocksIn)
local function named(____, kinds)
return __TS__New(
Set,
__TS__ArrayMap(
__TS__ArrayFilter(
all,
function(____, block)
local ____temp_2
if type(kinds) == "string" then
____temp_2 = block.kind == kinds
else
____temp_2 = kinds:has(block.kind)
end
return ____temp_2
end
),
function(____, block) return block.name end
)
)
end
local known = {
sketch = named(nil, "Sketch"),
symbol = named(nil, "Symbol"),
loft = named(nil, "Symbol"),
anchor = named(nil, BODIES),
picture = named(nil, "Canvas")
}
local what = {
sketch = "Sketch",
symbol = "Symbol",
loft = "Symbol",
anchor = "body",
picture = "Canvas"
}
local shapeAsSymbol = __TS__ArrayFlatMap(
all,
function(____, block)
local name = nameOf(
nil,
directProperties(nil, block):get("shape")
)
return (block.kind == "Shape" or block.kind == "Entity") and name ~= nil and known.symbol:has(name) and ({{severity = "warning", code = "shape-names-symbol", ownerId = block.name, message = ((((((block.kind .. " '") .. block.name) .. "' names the Symbol '") .. name) .. "' in shape. It is drawn, but is written symbol: ") .. name) .. " now; shape names a form that is built in."}}) or ({})
end
)
return __TS__ArrayConcat(
shapeAsSymbol,
__TS__ArrayFlatMap(
all,
function(____, block)
local properties = directProperties(nil, block)
return __TS__ArrayFlatMap(
__TS__ObjectKeys(known),
function(____, key)
if (key == "symbol" or key == "loft") and not OUTLINED:has(block.kind) then
return {}
end
local name = nameOf(
nil,
properties:get(key)
)
if name == nil or known[key]:has(name) then
return {}
end
return {{severity = "warning", code = "unknown-reference", ownerId = block.name, message = ((((((((block.kind .. " '") .. block.name) .. "' names the ") .. what[key]) .. " '") .. name) .. "' in ") .. key) .. ", and there is none of that name."}}
end
)
end
)
)
end
return ____exports
end,
["core.sflSemantic.diagnostics.screens"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Map = ____lualib.Map
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local directProperties = ____blockEntries.directProperties
local MODEL_SCREEN_LINES = {"device", "screen", "screenColor", "at"}
function ____exports.collectModelScreenLines(self, sflDocument)
local major, minor = table.unpack(
__TS__ArrayMap(
__TS__StringSplit(
tostring(sflDocument.version),
"."
),
Number
),
1,
2
)
if major == nil then
major = 0
end
if minor == nil then
minor = 0
end
if major < 1 or major == 1 and minor < 7 then
return {}
end
return __TS__ArrayFlatMap(
__TS__ArrayFilter(
sflDocument.blocks,
function(____, block) return block.kind == "Model" end
),
function(____, model)
local properties = directProperties(nil, model)
return __TS__ArrayMap(
__TS__ArrayFilter(
MODEL_SCREEN_LINES,
function(____, key) return properties:has(key) end
),
function(____, key) return {severity = "warning", code = "model-screen-line", ownerId = model.name, message = ("'" .. key) .. "' on a Model is no longer used from sfl 1.7. Put the design into a Screen block."} end
)
end
)
end
return ____exports
end,
["core.sflSemantic.canvasState.resolution"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ____collection = require("core.sflSemantic.definitions.collection")
local collectCanvasDefinitions = ____collection.collectCanvasDefinitions
local ____compositionReferences = require("core.sflSemantic.definitions.compositionReferences")
local collectUnresolvedCompositionReferences = ____compositionReferences.collectUnresolvedCompositionReferences
local ____propertyReaders = require("core.sflSemantic.definitions.propertyReaders")
local createCanvasObjectPropertyReaders = ____propertyReaders.createCanvasObjectPropertyReaders
local ____charts = require("core.sflSemantic.diagnostics.charts")
local collectEmptySeries = ____charts.collectEmptySeries
local collectUnsupportedChartTypes = ____charts.collectUnsupportedChartTypes
local collectUnsupportedGridShapes = ____charts.collectUnsupportedGridShapes
local ____components = require("core.sflSemantic.diagnostics.components")
local collectUnsupportedComponentTypes = ____components.collectUnsupportedComponentTypes
local ____meshes = require("core.sflSemantic.diagnostics.meshes")
local collectMeshProblems = ____meshes.collectMeshProblems
local ____names = require("core.sflSemantic.diagnostics.names")
local collectDuplicateNames = ____names.collectDuplicateNames
local ____placement = require("core.sflSemantic.diagnostics.placement")
local collectPlacementsOutsideLayout = ____placement.collectPlacementsOutsideLayout
local ____properties = require("core.sflSemantic.diagnostics.properties")
local collectFormInStyle = ____properties.collectFormInStyle
local collectPropertiesWrittenTwice = ____properties.collectPropertiesWrittenTwice
local ____references = require("core.sflSemantic.diagnostics.references")
local collectUnknownReferences = ____references.collectUnknownReferences
local ____screens = require("core.sflSemantic.diagnostics.screens")
local collectModelScreenLines = ____screens.collectModelScreenLines
function ____exports.createCanvasResolution(self, doc)
local definitions = collectCanvasDefinitions(nil, doc)
local ____definitions_model_1 = definitions.model
local ____array_0 = __TS__SparseArrayNew(table.unpack(collectUnresolvedCompositionReferences(nil, doc, definitions.styles, definitions.layouts)))
__TS__SparseArrayPush(
____array_0,
table.unpack(collectUnsupportedChartTypes(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectUnsupportedGridShapes(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectEmptySeries(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectUnsupportedComponentTypes(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectDuplicateNames(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectModelScreenLines(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectMeshProblems(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectPropertiesWrittenTwice(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectFormInStyle(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectUnknownReferences(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(collectPlacementsOutsideLayout(nil, doc))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(__TS__ArrayMap(
doc.notes or ({}),
function(____, note) return {severity = "warning", code = note.code, ownerId = note.owner, message = note.message} end
))
)
return {
model = ____definitions_model_1,
diagnostics = {__TS__SparseArraySpread(____array_0)},
canvasObjectResolutionContext = createCanvasObjectPropertyReaders(nil, definitions)
}
end
return ____exports
end,
["core.sflSemantic.groups.members"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local directProperties = ____blockEntries.directProperties
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asString = ____valueAccess.asString
local ____blockKinds = require("core.sflSemantic.canvasObjects.processing.blockKinds")
local isCanvasObjectBlockKind = ____blockKinds.isCanvasObjectBlockKind
function ____exports.directGroupMemberIds(self, block)
return __TS__ArrayMap(
__TS__ArrayFilter(
childBlocks(nil, block),
function(____, child) return isCanvasObjectBlockKind(nil, child.kind) end
),
function(____, child) return asString(
nil,
directProperties(nil, child):get("id")
) or child.name end
)
end
return ____exports
end,
["core.sflSemantic.canvasTree.resolver"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____blockEntries = require("core.sflSemantic.ast.blockEntries")
local childBlocks = ____blockEntries.childBlocks
local ____valueAccess = require("core.sflSemantic.ast.valueAccess")
local asString = ____valueAccess.asString
local tupleValues = ____valueAccess.tupleValues
local ____netExpansion = require("core.sflSemantic.canvasObjects.artifacts.links.netExpansion")
local expandNetLinks = ____netExpansion.expandNetLinks
local ____blockKinds = require("core.sflSemantic.canvasObjects.processing.blockKinds")
local isCanvasObjectBlockKind = ____blockKinds.isCanvasObjectBlockKind
local ____flow = require("core.sflSemantic.canvasObjects.processing.layout.flow")
local createFlowPositioner = ____flow.createFlowPositioner
local ____resolver = require("core.sflSemantic.canvasObjects.processing.resolver")
local resolveCanvasObject = ____resolver.resolveCanvasObject
local ____members = require("core.sflSemantic.groups.members")
local directGroupMemberIds = ____members.directGroupMemberIds
local CanvasTreeResolver = __TS__Class()
CanvasTreeResolver.name = "CanvasTreeResolver"
function CanvasTreeResolver.prototype.____constructor(self, resolution)
self._p_canvasObjects = {}
self._p_linkBlocks = {}
self._p_connectionBlocks = {}
self._p_linkSourceIndexes = {}
self._p_connectionSourceIndexes = {}
self._p_sequence = 0
self._p_context = resolution.canvasObjectResolutionContext
end
function CanvasTreeResolver.prototype.resolve(self, model)
local groups = model and self:_p_resolveChildren(model, {origin = {x = 0, y = 0}}) or ({})
return {
canvasObjects = self._p_canvasObjects,
groups = groups,
linkBlocks = self._p_linkBlocks,
connectionBlocks = self._p_connectionBlocks,
linkSourceIndexes = self._p_linkSourceIndexes,
connectionSourceIndexes = self._p_connectionSourceIndexes
}
end
function CanvasTreeResolver.prototype._p_resolveChildren(self, block, location)
local groups = {}
local nextFlowPosition = createFlowPositioner(nil, block, self._p_context)
for ____, child in ipairs(childBlocks(nil, block)) do
__TS__ArrayPushArray(
groups,
self:_p_resolveChild(child, location, nextFlowPosition)
)
end
return groups
end
function CanvasTreeResolver.prototype._p_resolveChild(self, child, location, nextFlowPosition)
local ____self_0, ____p_sequence_1 = self, "_p_sequence"
local ____self__p_sequence_2 = ____self_0[____p_sequence_1]
____self_0[____p_sequence_1] = ____self__p_sequence_2 + 1
local sourceIndex = ____self__p_sequence_2
if child.kind == "Container" or child.kind == "Screen" or child.kind == "Scene" or child.kind == "Canvas" then
return self:_p_resolveContainer(child, location, nextFlowPosition, sourceIndex)
end
if isCanvasObjectBlockKind(nil, child.kind) then
self:_p_resolveCanvasObject(child, location, nextFlowPosition, sourceIndex)
return {}
end
repeat
local ____switch10 = child.kind
local ____cond10 = ____switch10 == "Group"
if ____cond10 then
return {self:_p_resolveGroup(child, location)}
end
____cond10 = ____cond10 or ____switch10 == "Link"
if ____cond10 then
local ____self__p_linkBlocks_3 = self._p_linkBlocks
____self__p_linkBlocks_3[#____self__p_linkBlocks_3 + 1] = child
local ____self__p_linkSourceIndexes_4 = self._p_linkSourceIndexes
____self__p_linkSourceIndexes_4[#____self__p_linkSourceIndexes_4 + 1] = sourceIndex
return {}
end
____cond10 = ____cond10 or ____switch10 == "Connection"
if ____cond10 then
local ____self__p_connectionBlocks_5 = self._p_connectionBlocks
____self__p_connectionBlocks_5[#____self__p_connectionBlocks_5 + 1] = child
local ____self__p_connectionSourceIndexes_6 = self._p_connectionSourceIndexes
____self__p_connectionSourceIndexes_6[#____self__p_connectionSourceIndexes_6 + 1] = sourceIndex
return {}
end
____cond10 = ____cond10 or ____switch10 == "Net"
if ____cond10 then
do
local expanded = expandNetLinks(nil, child, self._p_context)
__TS__ArrayPushArray(self._p_linkBlocks, expanded)
__TS__ArrayPushArray(
self._p_linkSourceIndexes,
__TS__ArrayMap(
expanded,
function() return sourceIndex end
)
)
return {}
end
end
do
return {}
end
until true
end
function CanvasTreeResolver.prototype._p_resolveContainer(self, block, location, nextFlowPosition, sourceIndex)
local canvasObject = self:_p_resolvePositionedCanvasObject(block, location, nextFlowPosition, sourceIndex)
local ____self__p_canvasObjects_7 = self._p_canvasObjects
____self__p_canvasObjects_7[#____self__p_canvasObjects_7 + 1] = canvasObject
return self:_p_resolveChildren(block, {origin = {x = canvasObject.x, y = canvasObject.y}, frameId = canvasObject.id})
end
function CanvasTreeResolver.prototype._p_resolveCanvasObject(self, block, location, nextFlowPosition, sourceIndex)
local ____self__p_canvasObjects_8 = self._p_canvasObjects
____self__p_canvasObjects_8[#____self__p_canvasObjects_8 + 1] = self:_p_resolvePositionedCanvasObject(block, location, nextFlowPosition, sourceIndex)
end
function CanvasTreeResolver.prototype._p_resolvePositionedCanvasObject(self, block, location, nextFlowPosition, sourceIndex)
local size = tupleValues(
nil,
self._p_context:layoutProp(block, "size")
) or ({0, 0})
return __TS__ObjectAssign(
{},
resolveCanvasObject(
nil,
block,
location.origin,
self._p_context,
location.frameId,
nextFlowPosition(nil, size)
),
{sourceIndex = sourceIndex}
)
end
function CanvasTreeResolver.prototype._p_resolveGroup(self, block, location)
local properties = self._p_context:mergedProps(block)
return {
id = asString(
nil,
properties:get("id")
) or block.name,
name = asString(
nil,
properties:get("text")
) or block.name,
color = asString(
nil,
properties:get("color")
),
icon = asString(
nil,
properties:get("icon")
),
canvasObjectIds = directGroupMemberIds(nil, block),
subGroups = self:_p_resolveChildren(block, location),
parentFrameId = location.frameId or asString(
nil,
properties:get("parent")
)
}
end
function ____exports.resolveCanvasTree(self, model, resolution)
return __TS__New(CanvasTreeResolver, resolution):resolve(model)
end
return ____exports
end,
["core.sflSemantic.canvasState.resolver"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Spread = ____lualib.__TS__Spread
local ____exports = {}
local ____reader = require("core.sflSemantic.canvasObjects.artifacts.connections.reader")
local readConnections = ____reader.readConnections
local ____reader = require("core.sflSemantic.canvasObjects.artifacts.links.reader")
local readLinks = ____reader.readLinks
local ____resolver = require("core.sflSemantic.canvasTree.resolver")
local resolveCanvasTree = ____resolver.resolveCanvasTree
local ____resolution = require("core.sflSemantic.canvasState.resolution")
local createCanvasResolution = ____resolution.createCanvasResolution
function ____exports.resolveCanvasState(self, document)
local resolution = createCanvasResolution(nil, document)
local ____resolveCanvasTree_result_0 = resolveCanvasTree(nil, resolution.model, resolution)
local canvasObjects = ____resolveCanvasTree_result_0.canvasObjects
local groups = ____resolveCanvasTree_result_0.groups
local linkBlocks = ____resolveCanvasTree_result_0.linkBlocks
local connectionBlocks = ____resolveCanvasTree_result_0.connectionBlocks
local linkSourceIndexes = ____resolveCanvasTree_result_0.linkSourceIndexes
local connectionSourceIndexes = ____resolveCanvasTree_result_0.connectionSourceIndexes
local links = readLinks(
nil,
resolution.model,
linkBlocks,
canvasObjects,
resolution.canvasObjectResolutionContext,
linkSourceIndexes
)
local connections = readConnections(
nil,
resolution.model,
connectionBlocks,
canvasObjects,
resolution.canvasObjectResolutionContext,
connectionSourceIndexes
)
return {
canvasObjects = canvasObjects,
groups = groups,
links = links,
connections = connections,
diagnostics = resolution.diagnostics,
shaders = {__TS__Spread(resolution.canvasObjectResolutionContext.shaderDefs:values())}
}
end
return ____exports
end,
["core.model.dimension.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.dimension.geometry"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __t = ______shims.__t
local GAP = 4
local OVERSHOOT = 6
local function along(____, origin, direction, distance)
return {x = origin.x + direction.x * distance, y = origin.y + direction.y * distance}
end
function ____exports.dimensionLength(self, dimension)
return __hypot(nil, dimension["end"].x - dimension.start.x, dimension["end"].y - dimension.start.y)
end
function ____exports.dimensionText(self, dimension)
if dimension.text ~= nil then
return dimension.text
end
local length = math.floor(____exports.dimensionLength(nil, dimension) * 10 + 0.5) / 10
return tostring(length) .. (__t(nil, dimension.unit) and " " .. dimension.unit or "")
end
function ____exports.dimensionGeometry(self, dimension)
local length = ____exports.dimensionLength(nil, dimension)
local direction = length == 0 and ({x = 1, y = 0}) or ({x = (dimension["end"].x - dimension.start.x) / length, y = (dimension["end"].y - dimension.start.y) / length})
local normal = {x = direction.y, y = -direction.x}
local side = dimension.offset < 0 and -1 or 1
local line = {
along(nil, dimension.start, normal, dimension.offset),
along(nil, dimension["end"], normal, dimension.offset)
}
local extensions = math.abs(dimension.offset) <= GAP and ({}) or __TS__ArrayMap(
{dimension.start, dimension["end"]},
function(____, point) return {
along(nil, point, normal, GAP * side),
along(nil, point, normal, dimension.offset + OVERSHOOT * side)
} end
)
local lift = ((dimension.fontSize or 11) * 0.75 + 2) * side
local middle = {x = (line[1].x + line[2].x) / 2, y = (line[1].y + line[2].y) / 2}
local angle = math.atan(direction.y, direction.x) * 180 / math.pi
if angle > 90 then
angle = angle - 180
elseif angle <= -90 then
angle = angle + 180
end
return {
length = length,
line = line,
extensions = extensions,
label = {
center = along(nil, middle, normal, lift),
angle = angle
}
}
end
return ____exports
end,
["core.model.dimension.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____geometry = require("core.model.dimension.geometry")
____exports.dimensionGeometry = ____geometry.dimensionGeometry
____exports.dimensionLength = ____geometry.dimensionLength
____exports.dimensionText = ____geometry.dimensionText
end
return ____exports
end,
["core.model.frame.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.frame.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.shape.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.shape.supportedTypes"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.SHAPE_TYPES = {
"rectangle",
"rounded_rectangle",
"triangle",
"diamond",
"hexagon",
"oval",
"circle",
"document",
"parallelogram",
"trapezoid",
"cylinder",
"note",
"cloud",
"predefined_process",
"pill",
"person",
"symbol"
}
return ____exports
end,
["core.model.shape.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____supportedTypes = require("core.model.shape.supportedTypes")
____exports.SHAPE_TYPES = ____supportedTypes.SHAPE_TYPES
end
return ____exports
end,
["core.model.swimlane.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.swimlane.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderInput.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.connection.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.connection.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.sflSemantic.sflToCanvasState"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____sflLanguage = require("core.sflLanguage.index")
local parse = ____sflLanguage.parse
local ____expansion = require("core.sflLanguage.expansion.index")
local expandDocument = ____expansion.expandDocument
local ____resolver = require("core.sflSemantic.canvasState.resolver")
local resolveCanvasState = ____resolver.resolveCanvasState
do
local ____types = require("core.sflSemantic.types")
____exports.isChartObject = ____types.isChartObject
____exports.isDimensionObject = ____types.isDimensionObject
____exports.isIsometricObject = ____types.isIsometricObject
____exports.isMeshGroundObject = ____types.isMeshGroundObject
____exports.isMeshLightObject = ____types.isMeshLightObject
____exports.isMeshObject = ____types.isMeshObject
____exports.isMeshSceneObject = ____types.isMeshSceneObject
____exports.isMeshSurfaceObject = ____types.isMeshSurfaceObject
____exports.isPathObject = ____types.isPathObject
____exports.isSwimlaneObject = ____types.isSwimlaneObject
end
function ____exports.sflToCanvasState(self, source)
return resolveCanvasState(
nil,
expandDocument(
nil,
parse(nil, source)
)
)
end
return ____exports
end,
["core.renderInput.styleDecoding.colorToken"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.COLOR_TOKEN_PATTERN = "rgba?\\([^)]*\\)|#[0-9a-fA-F]+|[a-zA-Z][\\w-]*"
return ____exports
end,
["core.renderInput.styleDecoding.color"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local ____exports = {}
local ______shims = require("core.__shims")
local __match = ______shims.__match
local __matchAll = ______shims.__matchAll
local __re = ______shims.__re
local ____colorToken = require("core.renderInput.styleDecoding.colorToken")
local COLOR_TOKEN_PATTERN = ____colorToken.COLOR_TOKEN_PATTERN
local function decodeGradient(self, source)
local match = __match(
nil,
source,
__re(nil, "^gradient\\(\\s*([-\\d.]+)\\s*,\\s*(.*)\\)\\s*$", "")
)
if not match then
return nil
end
local stops = {}
local stopPattern = __re(nil, ("(" .. COLOR_TOKEN_PATTERN) .. ")\\s+([-\\d.]+)%", "g")
for ____, stop in ipairs(__matchAll(nil, match[3], stopPattern)) do
stops[#stops + 1] = {
color = stop[2],
position = __TS__Number(stop[3])
}
end
return {
type = "gradient",
angle = __TS__Number(match[2]),
stops = stops
}
end
local function decodeMesh(self, source)
local match = __match(
nil,
source,
__re(nil, "^mesh\\(\\s*(.*)\\)\\s*$", "")
)
if not match then
return nil
end
local points = {}
local pointPattern = __re(nil, ("(" .. COLOR_TOKEN_PATTERN) .. ")\\s+([-\\d.]+)\\s*,\\s*([-\\d.]+)", "g")
local index = 0
for ____, point in ipairs(__matchAll(nil, match[2], pointPattern)) do
local ____temp_1 = Date:now()
local ____index_0 = index
index = ____index_0 + 1
points[#points + 1] = {
id = (("mp-" .. tostring(____temp_1)) .. "-") .. tostring(____index_0),
color = point[2],
x = __TS__Number(point[3]),
y = __TS__Number(point[4])
}
end
return {type = "mesh", points = points}
end
function ____exports.decodeColor(self, source)
if source == nil or source == nil or source == "" then
return nil
end
return decodeGradient(nil, source) or decodeMesh(nil, source) or source
end
return ____exports
end,
["core.renderInput.styleDecoding.ramp"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local ____exports = {}
local ______shims = require("core.__shims")
local __match = ______shims.__match
local __matchAll = ______shims.__matchAll
local __re = ______shims.__re
local __t = ______shims.__t
local ____colorToken = require("core.renderInput.styleDecoding.colorToken")
local COLOR_TOKEN_PATTERN = ____colorToken.COLOR_TOKEN_PATTERN
function ____exports.decodeRamp(self, source)
if not __t(nil, source) then
return nil
end
local match = __match(
nil,
source,
__re(nil, "^ramp\\(\\s*(.*)\\)\\s*$", "")
)
if not match then
return nil
end
local stops = {}
local stopPattern = __re(nil, ("(" .. COLOR_TOKEN_PATTERN) .. ")\\s+([-\\d.]+)", "g")
for ____, stop in ipairs(__matchAll(nil, match[2], stopPattern)) do
stops[#stops + 1] = {
color = stop[2],
position = __TS__Number(stop[3])
}
end
return {type = "ramp", stops = stops}
end
return ____exports
end,
["core.renderInput.styleDecoding.shadow"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__StringTrim = ____lualib.__TS__StringTrim
local ____exports = {}
local ______shims = require("core.__shims")
local __match = ______shims.__match
local __re = ______shims.__re
local __t = ______shims.__t
local function applyShadowProperty(self, shadow, key, value)
repeat
local ____switch3 = key
local ____cond3 = ____switch3 == "color"
if ____cond3 then
shadow.color = value
break
end
____cond3 = ____cond3 or ____switch3 == "opacity"
if ____cond3 then
shadow.opacity = __TS__Number(value)
break
end
____cond3 = ____cond3 or ____switch3 == "blur"
if ____cond3 then
shadow.blur = __TS__Number(value)
break
end
____cond3 = ____cond3 or ____switch3 == "angle"
if ____cond3 then
shadow.angle = __TS__Number(value)
break
end
____cond3 = ____cond3 or ____switch3 == "distance"
if ____cond3 then
shadow.distance = __TS__Number(value)
break
end
until true
end
function ____exports.decodeShadow(self, source)
if not __t(nil, source) then
return nil
end
if source == "on" then
return {enabled = true}
end
local match = __match(
nil,
source,
__re(nil, "^shadow\\((.*)\\)\\s*$", "")
)
if not match then
return nil
end
local shadow = {enabled = true}
for ____, part in ipairs(__TS__StringSplit(match[2], ",")) do
do
local keyValue = __TS__StringSplit(part, ":")
if #keyValue ~= 2 then
goto __continue8
end
applyShadowProperty(
nil,
shadow,
__TS__StringTrim(keyValue[1]),
__TS__StringTrim(keyValue[2])
)
end
::__continue8::
end
return shadow
end
return ____exports
end,
["core.renderInput.styleDecoding.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____color = require("core.renderInput.styleDecoding.color")
____exports.decodeColor = ____color.decodeColor
end
do
local ____ramp = require("core.renderInput.styleDecoding.ramp")
____exports.decodeRamp = ____ramp.decodeRamp
end
do
local ____shadow = require("core.renderInput.styleDecoding.shadow")
____exports.decodeShadow = ____shadow.decodeShadow
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.values"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local ____exports = {}
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
local __jsonParse = ______shims.__jsonParse
local __re = ______shims.__re
local __t = ______shims.__t
local __test = ______shims.__test
local ____styleDecoding = require("core.renderInput.styleDecoding.index")
local decodeColor = ____styleDecoding.decodeColor
____exports.numOf = function(____, value)
local ____temp_0
if value == nil then
____temp_0 = nil
else
____temp_0 = __TS__Number(value)
end
return ____temp_0
end
function ____exports.safeJson(self, value)
do
local function ____catch()
return true, nil
end
local ____try, ____hasReturned, ____returnValue = pcall(function()
return true, __jsonParse(nil, value)
end)
if not ____try then
____hasReturned, ____returnValue = ____catch()
end
if ____hasReturned then
return ____returnValue
end
end
end
function ____exports.dashArray(self, value)
if value == nil then
return nil
end
local parsed = ____exports.safeJson(nil, value)
if not __TS__ArrayIsArray(parsed) then
return nil
end
local numbers = __TS__ArrayFilter(
parsed,
function(____, entry) return type(entry) == "number" and __isFinite(nil, entry) end
)
return #numbers == #parsed and numbers or nil
end
function ____exports.solidColor(self, value)
local decoded = decodeColor(nil, value)
return type(decoded) == "string" and decoded or nil
end
local CSS_COLOR = __re(nil, "^(?:#[0-9a-f]{3,8}|rgba?\\([\\d.,%\\s]+\\)|[a-z][\\w-]*)$", "i")
function ____exports.cssColor(self, value)
return __t(nil, value) and __test(nil, CSS_COLOR, value) and value or nil
end
function ____exports.oneOf(self, value, allowed, fallback)
return __TS__ArrayIncludes(allowed, value) and value or fallback
end
____exports.FONT_WEIGHTS = {"normal", "bold"}
____exports.SHAPE_FONT_WEIGHTS = {
"normal",
"bold",
"100",
"200",
"300",
"400",
"500",
"600",
"700",
"800",
"900"
}
____exports.LABEL_POSITIONS = {"top", "bottom", "left", "right"}
____exports.PATH_MARKERS = {"none", "arrow", "filled_arrow"}
____exports.BORDER_STYLES = {"none", "single", "double"}
function ____exports.strokePaint(self, value)
local decoded = decodeColor(nil, value)
if decoded == nil or type(decoded) == "string" then
return decoded
end
return decoded.type == "gradient" and decoded or nil
end
____exports.TEXT_ALIGNS = {"left", "center", "right"}
____exports.VERTICAL_ALIGNS = {"top", "middle", "bottom"}
____exports.STROKE_STYLES = {"solid", "dashed", "dotted"}
____exports.PATH_TYPES = {"straight", "curved", "orthogonal"}
function ____exports.optionalOneOf(self, value, allowed)
return value ~= nil and __TS__ArrayIncludes(allowed, value) and value or nil
end
____exports.BLEND_MODES = {
"multiply",
"screen",
"overlay",
"darken",
"lighten",
"color-dodge",
"color-burn",
"hard-light",
"soft-light",
"difference",
"exclusion",
"hue",
"saturation",
"color",
"luminosity"
}
____exports.SHAPE_STROKE_STYLES = {"solid", "dashed", "dotted", "double"}
____exports.MARKER_TYPES = {
"none",
"arrow",
"filled_arrow",
"circle",
"filled_circle",
"diamond",
"filled_diamond",
"bar",
"triangle",
"one",
"zero_one",
"many",
"one_many",
"zero_many"
}
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.chartBase"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __match = ______shims.__match
local __re = ______shims.__re
local ____styleDecoding = require("core.renderInput.styleDecoding.index")
local decodeColor = ____styleDecoding.decodeColor
local decodeShadow = ____styleDecoding.decodeShadow
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local numOf = ____values.numOf
local solidColor = ____values.solidColor
local function decodeImageFill(self, source)
local ____temp_0
if source == nil then
____temp_0 = nil
else
____temp_0 = __match(
nil,
source,
__re(nil, "^image\\(\\s*([^,)]+?)\\s*(?:,\\s*(.+?))?\\s*\\)$", "")
)
end
local match = ____temp_0
return match and ({url = match[2], overlay = match[3]}) or nil
end
local function legendPositionOf(self, value)
return (value == "bottom" or value == "bottomLeft" or value == "bottomRight" or value == "left" or value == "right") and value or "top"
end
local function lineStyleOf(self, value)
return (value == "dashed" or value == "dotted") and value or "solid"
end
local function dataOf(self, e)
local ____opt_1 = e.chart
local ____temp_14 = ____opt_1 and ____opt_1.axisX or ({min = 0, max = 4, step = 1})
local ____opt_3 = e.chart
local ____temp_15 = ____opt_3 and ____opt_3.axisY or ({min = 0, max = 500, step = 100})
local ____opt_10 = e.chart
local ____TS__ArrayMap_result_16 = __TS__ArrayMap(
____opt_10 and ____opt_10.series or ({}),
function(____, s)
local ____s_8 = s
local ____decodeColor_result_9 = decodeColor(nil, s.color)
local ____opt_5 = s.colors
return __TS__ObjectAssign(
{},
____s_8,
{
color = ____decodeColor_result_9,
colors = ____opt_5 and __TS__ArrayMap(
s.colors,
function(____, c)
local ____temp_6
if c == nil then
____temp_6 = nil
else
____temp_6 = decodeColor(nil, c) or nil
end
return ____temp_6
end
),
strokeWidth = s.strokeWidth
}
)
end
)
local ____opt_12 = e.chart
return {
axisX = ____temp_14,
axisY = ____temp_15,
series = ____TS__ArrayMap_result_16,
rules = __TS__ArrayMap(
____opt_12 and ____opt_12.rules or ({}),
function(____, r) return {
id = r.id,
at = r.at,
text = r.text,
color = r.color,
strokeWidth = r.strokeWidth,
dash = r.dash
} end
)
}
end
local function frameOf(self, p)
local image = decodeImageFill(nil, p.fill)
return {
fillColor = image and "#111418" or (decodeColor(nil, p.fill) or "#ffffff"),
fillImage = image,
strokeColor = solidColor(nil, p.stroke) or "#475569",
strokeWidth = numOf(nil, p.strokeWidth) or 1,
cornerRadius = numOf(nil, p.cornerRadius) or 12,
shadowStyle = decodeShadow(nil, p.shadow)
}
end
local function gridOf(self, p)
return {
gridColor = p.gridColor or "#e2e8f0",
gridWidth = numOf(nil, p.gridWidth) or 1,
gridShape = p.gridShape == "circle" and "circle" or "rect",
gridLineStyle = lineStyleOf(nil, p.gridLineStyle),
gridRoundedCorners = p.gridRoundedCorners == "true",
gridAxes = (p.gridAxes == "x" or p.gridAxes == "y") and p.gridAxes or nil,
showGrid = p.showGrid ~= "false"
}
end
local function axesOf(self, p)
return {
axisLabelColor = p.axisLabelColor,
axisLineWidth = numOf(nil, p.axisLineWidth),
axisLineColor = p.axisLineColor,
axisLineStyle = (p.axisLineStyle == "dashed" or p.axisLineStyle == "dotted") and p.axisLineStyle or nil,
tickLength = numOf(nil, p.tickLength),
axisFontSize = numOf(nil, p.axisFontSize),
axisLabelAngle = numOf(nil, p.axisLabelAngle),
axisLabelSpace = numOf(nil, p.axisLabelSpace),
rowLabelSide = (p.rowLabelSide == "left" or p.rowLabelSide == "right") and p.rowLabelSide or nil,
columnLabelSide = (p.columnLabelSide == "top" or p.columnLabelSide == "bottom") and p.columnLabelSide or nil,
legendSide = (p.legendSide == "top" or p.legendSide == "bottom" or p.legendSide == "left" or p.legendSide == "right") and p.legendSide or nil,
xLabelGap = numOf(nil, p.xLabelGap),
yLabelGap = numOf(nil, p.yLabelGap),
axisLabelAlign = (p.axisLabelAlign == "left" or p.axisLabelAlign == "center" or p.axisLabelAlign == "right") and p.axisLabelAlign or nil,
axisFontFamily = p.axisFontFamily,
showValueAxis = p.showValueAxis ~= "false",
categoryAlign = (p.categoryAlign == "left" or p.categoryAlign == "inside") and p.categoryAlign or nil,
showAxisLabels = p.showAxisLabels ~= "false"
}
end
local function textOf(self, p)
return {
textColor = p.textColor or "#0f172a",
titleSize = numOf(nil, p.titleSize),
titleAlign = (p.titleAlign == "left" or p.titleAlign == "center" or p.titleAlign == "right") and p.titleAlign or nil,
titleWeight = p.titleWeight == "normal" and "normal" or nil,
titleColor = p.titleColor,
fontSize = numOf(nil, p.fontSize) or 12,
fontFamily = p.fontFamily or "Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
}
end
local function legendOf(self, p)
return {
legendColor = p.legendColor,
legendGap = numOf(nil, p.legendGap),
showLegend = p.showLegend == "true",
legendPosition = legendPositionOf(nil, p.legendPosition)
}
end
function ____exports.chartBase(self, e)
local p = e.props
return __TS__ObjectAssign(
{
id = e.id,
title = e.text or nil,
x = e.x,
y = e.y,
width = e.width,
height = e.height
},
dataOf(nil, e),
frameOf(nil, p),
gridOf(nil, p),
axesOf(nil, p),
textOf(nil, p),
legendOf(nil, p),
{order = e.order, sourceIndex = e.sourceIndex}
)
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.chartConfigs"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____styleDecoding = require("core.renderInput.styleDecoding.index")
local decodeColor = ____styleDecoding.decodeColor
local decodeRamp = ____styleDecoding.decodeRamp
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local numOf = ____values.numOf
function ____exports.barConfig(self, source, p)
local ____temp_19 = source and source.categories
local ____temp_20 = source and source.barCornerRadius
local ____decodeColor_result_21 = decodeColor(nil, source and source.barBorderColor)
local ____temp_22 = source and source.barBorderWidth
local ____temp_23 = source and source.barGroupGap
local ____temp_24 = source and source.barGap
local ____temp_25 = source and source.barGlow
local ____numOf_result_26 = numOf(nil, p.barSegments)
local ____numOf_result_27 = numOf(nil, p.barSegmentGap)
local ____temp_14
if p.barSegmentSnap == "false" then
____temp_14 = false
else
____temp_14 = nil
end
return {
categories = ____temp_19,
barCornerRadius = ____temp_20,
barBorderColor = ____decodeColor_result_21,
barBorderWidth = ____temp_22,
barGroupGap = ____temp_23,
barGap = ____temp_24,
barGlow = ____temp_25,
barSegments = ____numOf_result_26,
barSegmentGap = ____numOf_result_27,
barSegmentSnap = ____temp_14,
barGlassBlur = numOf(nil, p.barGlassBlur),
barGlassSaturation = numOf(nil, p.barGlassSaturation),
barGlassTint = p.barGlassTint,
barThickness = numOf(nil, p.barThickness),
orientation = source and source.orientation,
barTrack = p.barTrack == "true",
barRoundedBottom = p.barRoundedBottom == "true",
barLabelMaxOnly = p.barLabelMaxOnly == "true",
barTrackColor = p.barTrackColor,
barTrackHatch = p.barTrackHatch == "true",
barTrackHatchColor = p.barTrackHatchColor,
barTrackHatchAngle = numOf(nil, p.barTrackHatchAngle),
barTrackHatchSpacing = numOf(nil, p.barTrackHatchSpacing),
barTrackHatchWidth = numOf(nil, p.barTrackHatchWidth),
stacked = source and source.stacked or "true",
showBarLabels = p.showBarLabels == "true",
barLabelPosition = (p.barLabelPosition == "inside" or p.barLabelPosition == "center" or p.barLabelPosition == "axis") and p.barLabelPosition or nil,
barLabelFontSize = numOf(nil, p.barLabelFontSize),
barLabelFontFamily = p.barLabelFontFamily,
barLabelFontWeight = p.barLabelFontWeight == "bold" and "bold" or nil,
barLabelColor = p.barLabelColor,
barLabelPill = p.barLabelPill == "true",
barLabelPillColor = p.barLabelPillColor,
barLabelBorderColor = p.barLabelBorderColor,
barLabelBorderWidth = numOf(nil, p.barLabelBorderWidth),
barLabelFormat = p.barLabelFormat
}
end
function ____exports.lineConfig(self, source, p)
return {
categories = source and source.categories,
areaOpacity = source and source.areaOpacity,
lineTension = source and source.lineTension,
lineWidth = numOf(nil, p.lineWidth),
lineGlow = numOf(nil, p.lineGlow),
pointSize = numOf(nil, p.pointSize),
pointFill = p.pointFill,
pointStrokeWidth = numOf(nil, p.pointStrokeWidth),
highlightPoints = source and source.highlightPoints,
highlightSize = numOf(nil, p.highlightSize),
highlightColor = p.highlightColor,
highlightGuide = p.highlightGuide == "true",
highlightLabels = p.highlightLabels == "true",
highlightLabelColor = p.highlightLabelColor,
highlightLabelFormat = p.highlightLabelFormat
}
end
function ____exports.scatterConfig(self, source, p)
return {
categories = source and source.categories,
pointSize = numOf(nil, p.pointSize),
pointOpacity = numOf(nil, p.pointOpacity),
pointStrokeWidth = numOf(nil, p.pointStrokeWidth),
pointStrokeColor = p.pointStrokeColor
}
end
function ____exports.boxplotConfig(self, source, p)
return {
boxWidth = source and source.boxWidth,
orientation = source and source.orientation,
barCornerRadius = source and source.barCornerRadius,
showBoxplotPoints = source and source.showBoxplotPoints,
barBorderColor = source and source.barBorderColor,
barBorderWidth = source and source.barBorderWidth,
boxWhiskerWidth = numOf(nil, p.boxWhiskerWidth),
boxMedianWidth = numOf(nil, p.boxMedianWidth),
boxMedianColor = p.boxMedianColor,
boxWhiskerColor = p.boxWhiskerColor,
boxCapSize = numOf(nil, p.boxCapSize),
boxPointSize = numOf(nil, p.boxPointSize),
boxPointOpacity = numOf(nil, p.boxPointOpacity),
boxJitter = numOf(nil, p.boxJitter)
}
end
function ____exports.fieldConfig(self, source)
return {
scale = decodeRamp(nil, source and source.scale),
interpolate = source and source.interpolate,
idwPower = source and source.idwPower,
isolines = source and source.isolines
}
end
function ____exports.heatmapConfig(self, source, p)
return {
categories = source and source.categories,
zones = source and source.zones,
cellGap = source and source.cellGap,
showValues = source and source.showValues,
squareCells = source and source.squareCells,
barCornerRadius = source and source.barCornerRadius,
cellShape = p.cellShape == "circle" and "circle" or (p.cellShape == "square" and "square" or nil),
cellStrokeColor = p.cellStrokeColor,
cellStrokeWidth = numOf(nil, p.cellStrokeWidth),
cellValueSize = numOf(nil, p.cellValueSize),
cellValueColor = p.cellValueColor
}
end
function ____exports.hexbinConfig(self, source, p)
return {
hexRadius = source and source.hexRadius,
scale = decodeRamp(nil, source and source.scale),
hexGap = numOf(nil, p.hexGap),
hexStrokeWidth = numOf(nil, p.hexStrokeWidth),
hexStrokeColor = p.hexStrokeColor,
hexMinOpacity = numOf(nil, p.hexMinOpacity)
}
end
function ____exports.mekkoConfig(self, source, p)
local ____temp_86 = source and source.categories
local ____temp_87 = source and source.barCornerRadius
local ____temp_88 = source and source.mekkoVaryHeight
local ____temp_89 = source and source.tileGradient
local ____temp_90 = source and source.showColumnBackdrop
local ____numOf_result_91 = numOf(nil, p.mekkoColumnGap)
local ____numOf_result_92 = numOf(nil, p.mekkoSegmentGap)
local ____temp_84
if p.mekkoRoundAll == nil then
____temp_84 = nil
else
____temp_84 = tostring(p.mekkoRoundAll) ~= "false"
end
local ____p_mekkoSegmentStrokeColor_93 = p.mekkoSegmentStrokeColor
local ____numOf_result_94 = numOf(nil, p.mekkoSegmentStrokeWidth)
local ____numOf_result_95 = numOf(nil, p.mekkoLabelSize)
local ____numOf_result_96 = numOf(nil, p.mekkoValueSize)
local ____p_mekkoTextColor_97 = p.mekkoTextColor
local ____temp_85
if p.showMekkoTotals == nil then
____temp_85 = nil
else
____temp_85 = tostring(p.showMekkoTotals) ~= "false"
end
return {
categories = ____temp_86,
barCornerRadius = ____temp_87,
mekkoVaryHeight = ____temp_88,
tileGradient = ____temp_89,
showColumnBackdrop = ____temp_90,
mekkoColumnGap = ____numOf_result_91,
mekkoSegmentGap = ____numOf_result_92,
mekkoRoundAll = ____temp_84,
mekkoSegmentStrokeColor = ____p_mekkoSegmentStrokeColor_93,
mekkoSegmentStrokeWidth = ____numOf_result_94,
mekkoLabelSize = ____numOf_result_95,
mekkoValueSize = ____numOf_result_96,
mekkoTextColor = ____p_mekkoTextColor_97,
showMekkoTotals = ____temp_85,
mekkoValueFormat = p.mekkoValueFormat == "percent" and "percent" or (p.mekkoValueFormat == "value" and "value" or nil)
}
end
function ____exports.pieConfig(self, source, p)
return {
innerRadius = source and source.innerRadius,
pieCornerRadius = source and source.pieCornerRadius,
pieSliceGap = source and source.pieSliceGap,
pieStartAngle = numOf(nil, p.pieStartAngle),
pieSweep = numOf(nil, p.pieSweep),
pieExplode = numOf(nil, p.pieExplode),
pieGlow = numOf(nil, p.pieGlow),
pieStroke = p.pieStroke,
pieStrokeWidth = numOf(nil, p.pieStrokeWidth),
pieLabelPosition = (p.pieLabelPosition == "inside" or p.pieLabelPosition == "outside") and p.pieLabelPosition or nil,
pieLabelContent = (p.pieLabelContent == "percent" or p.pieLabelContent == "name" or p.pieLabelContent == "inline") and p.pieLabelContent or nil,
pieLabelColor = p.pieLabelColor,
pieCenterText = p.pieCenterText,
pieCenterSize = numOf(nil, p.pieCenterSize),
pieCenterColor = p.pieCenterColor
}
end
function ____exports.polarAreaConfig(self, source, p)
local ____temp_113 = source and source.innerRadius
local ____temp_114 = source and source.pieCornerRadius
local ____temp_115 = source and source.pieSliceGap
local ____numOf_result_116 = numOf(nil, p.pieStartAngle)
local ____p_pieStroke_117 = p.pieStroke
local ____numOf_result_118 = numOf(nil, p.pieStrokeWidth)
local ____numOf_result_119 = numOf(nil, p.polarTrackOpacity)
local ____temp_110
if p.polarRings == nil then
____temp_110 = nil
else
____temp_110 = tostring(p.polarRings) ~= "false"
end
local ____p_polarTrackStroke_120 = p.polarTrackStroke
local ____numOf_result_121 = numOf(nil, p.polarTrackStrokeWidth)
local ____p_polarTrackDash_122 = p.polarTrackDash
local ____numOf_result_123 = numOf(nil, p.polarValueSize)
local ____numOf_result_124 = numOf(nil, p.polarNameSize)
local ____temp_111
if p.polarValueFirst == nil then
____temp_111 = nil
else
____temp_111 = tostring(p.polarValueFirst) ~= "false"
end
local ____temp_112
if p.polarOutsideLabels == nil then
____temp_112 = nil
else
____temp_112 = tostring(p.polarOutsideLabels) ~= "false"
end
return {
innerRadius = ____temp_113,
pieCornerRadius = ____temp_114,
pieSliceGap = ____temp_115,
pieStartAngle = ____numOf_result_116,
pieStroke = ____p_pieStroke_117,
pieStrokeWidth = ____numOf_result_118,
polarTrackOpacity = ____numOf_result_119,
polarRings = ____temp_110,
polarTrackStroke = ____p_polarTrackStroke_120,
polarTrackStrokeWidth = ____numOf_result_121,
polarTrackDash = ____p_polarTrackDash_122,
polarValueSize = ____numOf_result_123,
polarNameSize = ____numOf_result_124,
polarValueFirst = ____temp_111,
polarOutsideLabels = ____temp_112
}
end
local function radarStyle(self, p)
local ____numOf_result_126 = numOf(nil, p.radarStrokeWidth)
local ____numOf_result_127 = numOf(nil, p.radarPointSize)
local ____numOf_result_128 = numOf(nil, p.radarTension)
local ____temp_125
if p.radarSpokes == nil then
____temp_125 = nil
else
____temp_125 = tostring(p.radarSpokes) ~= "false"
end
return {radarStrokeWidth = ____numOf_result_126, radarPointSize = ____numOf_result_127, radarTension = ____numOf_result_128, radarSpokes = ____temp_125}
end
function ____exports.radarConfig(self, source, p)
return __TS__ObjectAssign(
{categories = source and source.categories, areaOpacity = source and source.areaOpacity},
radarStyle(nil, p)
)
end
function ____exports.radialConfig(self, source, p)
return __TS__ObjectAssign(
{categories = source and source.categories, areaOpacity = source and source.areaOpacity},
radarStyle(nil, p)
)
end
function ____exports.radialBarConfig(self, source, p)
return {
ringThickness = source and source.ringThickness,
ringGap = source and source.ringGap,
ringTrackOpacity = numOf(nil, p.ringTrackOpacity),
ringCap = p.ringCap == "butt" and "butt" or (p.ringCap == "round" and "round" or nil),
ringStartAngle = numOf(nil, p.ringStartAngle),
ringSweep = numOf(nil, p.ringSweep)
}
end
function ____exports.sankeyConfig(self, source, p)
return {
zones = source and source.zones,
barCornerRadius = source and source.barCornerRadius,
labelPosition = source and source.labelPosition,
labelOrientation = source and source.labelOrientation,
labelColor = source and source.labelColor,
linkGradient = source and source.linkGradient,
sankeyNodeWidth = numOf(nil, p.sankeyNodeWidth),
sankeyNodeGap = numOf(nil, p.sankeyNodeGap),
sankeyLinkOpacity = numOf(nil, p.sankeyLinkOpacity),
sankeyLinkCurve = numOf(nil, p.sankeyLinkCurve),
sankeyLabelSize = numOf(nil, p.sankeyLabelSize)
}
end
function ____exports.treemapConfig(self, source, p)
local ____temp_164 = source and source.zones
local ____temp_165 = source and source.cellGap
local ____temp_166 = source and source.barCornerRadius
local ____temp_167 = source and source.headerColor
local ____temp_168 = source and source.tileGradient
local ____p_tileStrokeColor_169 = p.tileStrokeColor
local ____numOf_result_170 = numOf(nil, p.tileStrokeWidth)
local ____numOf_result_171 = numOf(nil, p.tileLabelSize)
local ____numOf_result_172 = numOf(nil, p.tileValueSize)
local ____p_tileTextColor_173 = p.tileTextColor
local ____numOf_result_174 = numOf(nil, p.tileLabelPadding)
local ____temp_163
if p.showTileValues == nil then
____temp_163 = nil
else
____temp_163 = tostring(p.showTileValues) ~= "false"
end
return {
zones = ____temp_164,
cellGap = ____temp_165,
barCornerRadius = ____temp_166,
headerColor = ____temp_167,
tileGradient = ____temp_168,
tileStrokeColor = ____p_tileStrokeColor_169,
tileStrokeWidth = ____numOf_result_170,
tileLabelSize = ____numOf_result_171,
tileValueSize = ____numOf_result_172,
tileTextColor = ____p_tileTextColor_173,
tileLabelPadding = ____numOf_result_174,
showTileValues = ____temp_163,
headerHeight = numOf(nil, p.headerHeight)
}
end
function ____exports.customConfig(self, source, p)
return {
categories = source and source.categories,
zones = source and source.zones,
orientation = source and source.orientation,
connectPoints = source and source.connectPoints,
reverseComparison = source and source.reverseComparison,
customConnectorWidth = numOf(nil, p.customConnectorWidth),
customConnectorOpacity = numOf(nil, p.customConnectorOpacity),
customConnectorDash = p.customConnectorDash,
customBeforeFill = p.customBeforeFill,
customBeforeStroke = p.customBeforeStroke,
customBeforeStrokeWidth = numOf(nil, p.customBeforeStrokeWidth),
customLabelSize = numOf(nil, p.customLabelSize),
customLabelColor = p.customLabelColor
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.chart"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local typedChart
local ____chartBase = require("core.renderInput.fromSfl.canvasObjects.chartBase")
local chartBase = ____chartBase.chartBase
local ____chartConfigs = require("core.renderInput.fromSfl.canvasObjects.chartConfigs")
local barConfig = ____chartConfigs.barConfig
local boxplotConfig = ____chartConfigs.boxplotConfig
local customConfig = ____chartConfigs.customConfig
local fieldConfig = ____chartConfigs.fieldConfig
local heatmapConfig = ____chartConfigs.heatmapConfig
local hexbinConfig = ____chartConfigs.hexbinConfig
local lineConfig = ____chartConfigs.lineConfig
local mekkoConfig = ____chartConfigs.mekkoConfig
local pieConfig = ____chartConfigs.pieConfig
local polarAreaConfig = ____chartConfigs.polarAreaConfig
local radarConfig = ____chartConfigs.radarConfig
local radialBarConfig = ____chartConfigs.radialBarConfig
local radialConfig = ____chartConfigs.radialConfig
local sankeyConfig = ____chartConfigs.sankeyConfig
local scatterConfig = ____chartConfigs.scatterConfig
local treemapConfig = ____chartConfigs.treemapConfig
function typedChart(self, base, chartType, config)
return __TS__ObjectAssign({}, base, {chartType = chartType, config = config})
end
function ____exports.chartObject(self, e)
local base = chartBase(nil, e)
local source = e.chart
local p = e.props
local chartType = source and source.chartType or "bar"
repeat
local ____switch3 = chartType
local ____cond3 = ____switch3 == "bar"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
barConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "line"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
lineConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "scatter"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
scatterConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "boxplot"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
boxplotConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "field"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
fieldConfig(nil, source)
)
end
____cond3 = ____cond3 or ____switch3 == "heatmap"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
heatmapConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "hexbin"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
hexbinConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "mekko"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
mekkoConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "pie"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
pieConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "polarArea"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
polarAreaConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "radar"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
radarConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "radial"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
radialConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "radialBar"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
radialBarConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "sankey"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
sankeyConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "treemap"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
treemapConfig(nil, source, p)
)
end
____cond3 = ____cond3 or ____switch3 == "custom"
if ____cond3 then
return typedChart(
nil,
base,
chartType,
customConfig(nil, source, p)
)
end
until true
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.genericComponent"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
local ____exports = {}
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
local ____component = require("core.model.component.index")
local getComponentDescriptor = ____component.getComponentDescriptor
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local cssColor = ____values.cssColor
local function numberProperty(self, descriptor, raw)
local value = __TS__Number(raw)
if raw == nil or raw == "" or not __isFinite(nil, value) then
return descriptor.default
end
local atLeast = descriptor.min == nil and value or math.max(descriptor.min, value)
return descriptor.max == nil and atLeast or math.min(descriptor.max, atLeast)
end
local function readProperty(self, descriptor, raw)
repeat
local ____switch5 = descriptor.type
local ____cond5 = ____switch5 == "number"
if ____cond5 then
return numberProperty(nil, descriptor, raw)
end
____cond5 = ____cond5 or ____switch5 == "boolean"
if ____cond5 then
local ____temp_0
if raw == nil then
____temp_0 = descriptor.default
else
____temp_0 = raw == "true"
end
return ____temp_0
end
____cond5 = ____cond5 or ____switch5 == "color"
if ____cond5 then
return descriptor.optional and raw == "none" and "none" or (cssColor(nil, raw) or descriptor.default)
end
____cond5 = ____cond5 or ____switch5 == "enum"
if ____cond5 then
return raw ~= nil and __TS__ArrayIncludes(descriptor.options, raw) and raw or descriptor.default
end
____cond5 = ____cond5 or ____switch5 == "string"
if ____cond5 then
return raw or descriptor.default
end
until true
end
function ____exports.readComponentProperties(self, descriptor, props)
local properties = {}
for ____, ____value in ipairs(__TS__ObjectEntries(descriptor and descriptor.properties or ({}))) do
local key = ____value[1]
local property = ____value[2]
properties[key] = readProperty(nil, property, props[key])
end
return properties
end
function ____exports.readComponentValue(self, descriptor, raw)
if not descriptor then
return ""
end
if descriptor.type == "boolean" then
return raw == "true"
end
if descriptor.type == "number" then
local value = __TS__Number(raw)
return __isFinite(nil, value) and value or descriptor.default
end
return raw
end
function ____exports.genericComponentObject(self, canvasObject)
local descriptor = getComponentDescriptor(nil, canvasObject.component.type)
local ____canvasObject_id_4 = canvasObject.id
local ____canvasObject_component_type_5 = canvasObject.component.type
local ____descriptor_3
if descriptor then
____descriptor_3 = ____exports.readComponentValue(nil, descriptor.value, canvasObject.component.value)
else
____descriptor_3 = canvasObject.component.value
end
return {
id = ____canvasObject_id_4,
type = ____canvasObject_component_type_5,
value = ____descriptor_3,
disabled = canvasObject.props.disabled == "true",
label = canvasObject.component.label,
x = canvasObject.x,
y = canvasObject.y,
width = canvasObject.width,
height = canvasObject.height,
rotation = canvasObject.rotation,
order = canvasObject.order,
sourceIndex = canvasObject.sourceIndex,
parentFrameId = canvasObject.parentFrameId,
properties = ____exports.readComponentProperties(nil, descriptor, canvasObject.props)
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.component"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local ____exports = {}
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
local __re = ______shims.__re
local __t = ______shims.__t
local __test = ______shims.__test
local ____component = require("core.model.component.index")
local isBuiltInComponentType = ____component.isBuiltInComponentType
local ____genericComponent = require("core.renderInput.fromSfl.canvasObjects.genericComponent")
local genericComponentObject = ____genericComponent.genericComponentObject
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local cssColor = ____values.cssColor
local CSS_FONT_FAMILY = __re(nil, "^[\\w\\s,'\"-]+$", "")
local function fontFamily(self, value)
return __t(nil, value) and __test(nil, CSS_FONT_FAMILY, value) and value or nil
end
local FONT_WEIGHT = __re(nil, "^(?:[1-9]00|normal|bold)$", "")
local function variant(self, value)
return (value == "plain" or value == "flip") and value or nil
end
local function motion(self, value)
return (value == "roll" or value == "fade") and value or nil
end
local function positiveNumber(self, value)
local number = __TS__Number(value)
return value ~= nil and __isFinite(nil, number) and number > 0 and number or nil
end
local function fontWeight(self, value)
return __t(nil, value) and __test(nil, FONT_WEIGHT, value) and value or nil
end
local TICK_SCALE_NUMBERS = {
"ticks",
"major",
"radius",
"length",
"thickness",
"round",
"start",
"sweep",
"intensity"
}
local TICK_SCALE_COLORS = {"color", "accent", "lowColor", "highColor"}
local function tickScaleObject(self, canvasObject)
local properties = canvasObject.props
local parameters = {}
for ____, key in ipairs(TICK_SCALE_NUMBERS) do
local value = __TS__Number(properties[key])
if properties[key] ~= nil and __isFinite(nil, value) then
parameters[key] = value
end
end
for ____, key in ipairs(TICK_SCALE_COLORS) do
local value = cssColor(nil, properties[key])
if __t(nil, value) then
parameters[key] = value
end
end
return {
id = canvasObject.id,
type = "tickScale",
value = canvasObject.component.value,
max = canvasObject.component.max,
label = canvasObject.component.label,
x = canvasObject.x,
y = canvasObject.y,
width = canvasObject.width,
height = canvasObject.height,
rotation = canvasObject.rotation,
order = canvasObject.order,
sourceIndex = canvasObject.sourceIndex,
parentFrameId = canvasObject.parentFrameId,
parameters = parameters,
labels = properties.labels == "true" and ({
size = __isFinite(
nil,
__TS__Number(properties.labelSize)
) and properties.labelSize ~= nil and __TS__Number(properties.labelSize) or nil,
color = cssColor(nil, properties.labelColor),
offset = __isFinite(
nil,
__TS__Number(properties.labelOffset)
) and properties.labelOffset ~= nil and __TS__Number(properties.labelOffset) or nil,
weight = fontWeight(nil, properties.labelWeight),
fontFamily = fontFamily(nil, properties.labelFont)
}) or nil
}
end
local RULER_NUMBERS = {
"ticks",
"major",
"length",
"thickness",
"round",
"dent",
"spread",
"inset",
"line",
"gap",
"intensity"
}
local RULER_COLORS = {"color", "accent", "glow"}
local RULER_DEFAULTS = {color = "#8f95c4", accent = "#d9f270", glow = "#3ddc84"}
local RULER_OPTIONAL_COLORS = {"core", "peak"}
local function rulerObject(self, canvasObject)
local properties = canvasObject.props
local parameters = {}
for ____, key in ipairs(RULER_NUMBERS) do
local value = __TS__Number(properties[key])
if properties[key] ~= nil and __isFinite(nil, value) then
parameters[key] = value
end
end
for ____, key in ipairs(RULER_COLORS) do
parameters[key] = cssColor(nil, properties[key]) or RULER_DEFAULTS[key]
end
for ____, key in ipairs(RULER_OPTIONAL_COLORS) do
local value = cssColor(nil, properties[key])
if __t(nil, value) then
parameters[key] = value
end
end
parameters.axis = properties.axis == "horizontal" and "horizontal" or "vertical"
if __t(nil, properties.knob) then
parameters.knob = properties.knob
end
return {
id = canvasObject.id,
type = "ruler",
value = canvasObject.component.value,
min = canvasObject.component.min,
max = canvasObject.component.max,
label = canvasObject.component.label,
x = canvasObject.x,
y = canvasObject.y,
width = canvasObject.width,
height = canvasObject.height,
rotation = canvasObject.rotation,
order = canvasObject.order,
sourceIndex = canvasObject.sourceIndex,
parentFrameId = canvasObject.parentFrameId,
parameters = parameters,
labels = properties.labels == "true" and ({
size = __isFinite(
nil,
__TS__Number(properties.labelSize)
) and properties.labelSize ~= nil and __TS__Number(properties.labelSize) or nil,
color = cssColor(nil, properties.labelColor),
offset = __isFinite(
nil,
__TS__Number(properties.labelOffset)
) and properties.labelOffset ~= nil and __TS__Number(properties.labelOffset) or nil,
weight = fontWeight(nil, properties.labelWeight),
fontFamily = fontFamily(nil, properties.labelFont)
}) or nil
}
end
local function rollingNumberObject(self, canvasObject)
local properties = canvasObject.props
return {
id = canvasObject.id,
type = "rollingNumber",
value = canvasObject.component.value,
digits = canvasObject.component.digits,
duration = canvasObject.component.duration,
label = canvasObject.component.label,
x = canvasObject.x,
y = canvasObject.y,
width = canvasObject.width,
height = canvasObject.height,
rotation = canvasObject.rotation,
order = canvasObject.order,
sourceIndex = canvasObject.sourceIndex,
parentFrameId = canvasObject.parentFrameId,
style = {
color = cssColor(nil, properties.color),
surface = cssColor(nil, properties.surface),
divider = cssColor(nil, properties.divider),
labelColor = cssColor(nil, properties.labelColor),
fontFamily = fontFamily(nil, properties.fontFamily),
variant = variant(nil, properties.variant),
motion = motion(nil, properties.motion),
fontWeight = fontWeight(nil, properties.fontWeight),
fontSize = positiveNumber(nil, properties.fontSize)
}
}
end
local BUILT_IN_OBJECTS = {rollingNumber = rollingNumberObject, tickScale = tickScaleObject, ruler = rulerObject}
function ____exports.componentObject(self, canvasObject)
local ____type = canvasObject.component.type
return isBuiltInComponentType(nil, ____type) and BUILT_IN_OBJECTS[____type](BUILT_IN_OBJECTS, canvasObject) or genericComponentObject(nil, canvasObject)
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.connection"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local numOf = ____values.numOf
local optionalOneOf = ____values.optionalOneOf
local PATH_TYPES = ____values.PATH_TYPES
local STROKE_STYLES = ____values.STROKE_STYLES
local strokePaint = ____values.strokePaint
function ____exports.connectionObject(self, c)
local p = c.props
local ____c_id_5 = c.id
local ____c_fromId_6 = c.fromId
local ____c_toId_7 = c.toId
local ____c_fromFace_8 = c.fromFace
local ____c_toFace_9 = c.toFace
local ____c_order_10 = c.order
local ____c_sourceIndex_11 = c.sourceIndex
local ____temp_1 = optionalOneOf(nil, p.route, PATH_TYPES) or "straight"
local ____strokePaint_result_2 = strokePaint(nil, p.stroke)
local ____numOf_result_3 = numOf(nil, p.strokeWidth)
local ____optionalOneOf_result_4 = optionalOneOf(nil, p.strokeStyle, STROKE_STYLES)
local ____temp_0
if p.opacity ~= nil then
____temp_0 = numOf(nil, p.opacity)
else
____temp_0 = nil
end
return {
id = ____c_id_5,
fromId = ____c_fromId_6,
toId = ____c_toId_7,
fromFace = ____c_fromFace_8,
toFace = ____c_toFace_9,
order = ____c_order_10,
sourceIndex = ____c_sourceIndex_11,
style = {
pathType = ____temp_1,
color = ____strokePaint_result_2,
strokeWidth = ____numOf_result_3,
strokeStyle = ____optionalOneOf_result_4,
opacity = ____temp_0
}
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.dimension"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local numOf = ____values.numOf
local solidColor = ____values.solidColor
function ____exports.dimensionObject(self, canvasObject)
local presentation = canvasObject.props
return {
id = canvasObject.id,
start = canvasObject.dimension.start,
["end"] = canvasObject.dimension["end"],
offset = canvasObject.dimension.offset,
text = canvasObject.text,
unit = canvasObject.dimension.unit,
strokeColor = solidColor(nil, presentation.stroke),
strokeWidth = numOf(nil, presentation.strokeWidth),
textColor = solidColor(nil, presentation.textColor),
fontSize = numOf(nil, presentation.fontSize),
order = canvasObject.order,
sourceIndex = canvasObject.sourceIndex,
parentFrameId = canvasObject.parentFrameId
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.frame"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local dashArray = ____values.dashArray
local FONT_WEIGHTS = ____values.FONT_WEIGHTS
local LABEL_POSITIONS = ____values.LABEL_POSITIONS
local numOf = ____values.numOf
local oneOf = ____values.oneOf
function ____exports.frameObject(self, e)
local p = e.props
local screen = e.kind == "screen"
local ____e_id_2 = e.id
local ____temp_3 = e.text or nil
local ____e_x_4 = e.x
local ____e_y_5 = e.y
local ____e_width_6 = e.width
local ____e_height_7 = e.height
local ____temp_8 = p.fill or (screen and "rgba(0, 0, 0, 0)" or "rgba(155, 66, 223, 0.05)")
local ____temp_9 = p.stroke or (screen and "rgba(0, 0, 0, 0)" or "#9b42df")
local ____temp_10 = numOf(nil, p.strokeWidth) or (screen and 0 or 2)
local ____temp_11 = numOf(nil, p.cornerRadius) or (screen and 0 or 12)
local ____temp_12 = p.textColor or "#ffffff"
local ____temp_13 = numOf(nil, p.fontSize) or 14
local ____oneOf_result_14 = oneOf(nil, p.fontWeight, FONT_WEIGHTS, "bold")
local ____p_fontFamily_15 = p.fontFamily
local ____dashArray_result_16 = dashArray(nil, p.dash)
local ____screen_0
if screen then
____screen_0 = p.showLabel == "true"
else
____screen_0 = p.showLabel ~= "false"
end
local ____oneOf_result_17 = oneOf(nil, p.labelPosition, LABEL_POSITIONS, "top")
local ____screen_1
if screen then
____screen_1 = p.shadow == "true"
else
____screen_1 = p.shadow ~= "false"
end
return {
id = ____e_id_2,
title = ____temp_3,
x = ____e_x_4,
y = ____e_y_5,
width = ____e_width_6,
height = ____e_height_7,
fillColor = ____temp_8,
strokeColor = ____temp_9,
strokeWidth = ____temp_10,
cornerRadius = ____temp_11,
textColor = ____temp_12,
fontSize = ____temp_13,
fontWeight = ____oneOf_result_14,
fontFamily = ____p_fontFamily_15,
dash = ____dashArray_result_16,
showLabel = ____screen_0,
labelPosition = ____oneOf_result_17,
shadow = ____screen_1,
clip = p.clip == "true" or nil,
screen = screen or nil,
order = e.order,
sourceIndex = e.sourceIndex
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.isometric"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____styleDecoding = require("core.renderInput.styleDecoding.index")
local decodeShadow = ____styleDecoding.decodeShadow
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local numOf = ____values.numOf
local solidColor = ____values.solidColor
function ____exports.isometricObject(self, canvasObject)
local presentation = canvasObject.props
local shadowStyle = decodeShadow(nil, presentation.shadow)
local ____canvasObject_id_4 = canvasObject.id
local ____canvasObject_x_5 = canvasObject.x
local ____canvasObject_y_6 = canvasObject.y
local ____canvasObject_width_7 = canvasObject.width
local ____canvasObject_height_8 = canvasObject.height
local ____canvasObject_isometric_depth_9 = canvasObject.isometric.depth
local ____canvasObject_isometric_footprint_10 = canvasObject.isometric.footprint
local ____canvasObject_isometric_form_11 = canvasObject.isometric.form
local ____canvasObject_rotation_12 = canvasObject.rotation
local ____canvasObject_order_13 = canvasObject.order
local ____canvasObject_sourceIndex_14 = canvasObject.sourceIndex
local ____canvasObject_text_15 = canvasObject.text
local ____canvasObject_isometric_icon_16 = canvasObject.isometric.icon
local ____temp_17 = solidColor(nil, presentation.fill) or "#f8fafc"
local ____temp_18 = solidColor(nil, presentation.stroke) or "#111827"
local ____temp_19 = numOf(nil, presentation.strokeWidth) or 1
local ____temp_20 = numOf(nil, presentation.cornerRadius) or (canvasObject.isometric.footprint and 0 or 8)
local ____temp_0
if presentation.seams == "false" then
____temp_0 = false
else
____temp_0 = nil
end
local ____temp_3 = shadowStyle and shadowStyle.enabled
if ____temp_3 == nil then
____temp_3 = false
end
return {
id = ____canvasObject_id_4,
x = ____canvasObject_x_5,
y = ____canvasObject_y_6,
width = ____canvasObject_width_7,
height = ____canvasObject_height_8,
depth = ____canvasObject_isometric_depth_9,
footprint = ____canvasObject_isometric_footprint_10,
form = ____canvasObject_isometric_form_11,
rotation = ____canvasObject_rotation_12,
order = ____canvasObject_order_13,
sourceIndex = ____canvasObject_sourceIndex_14,
text = ____canvasObject_text_15,
icon = ____canvasObject_isometric_icon_16,
fill = ____temp_17,
strokeColor = ____temp_18,
strokeWidth = ____temp_19,
cornerRadius = ____temp_20,
seams = ____temp_0,
hasShadow = ____temp_3,
shadowStyle = shadowStyle,
labelOffsetX = numOf(nil, presentation.labelOffsetX) or 0,
labelOffsetY = numOf(nil, presentation.labelOffsetY) or 0,
labelBackground = solidColor(nil, presentation.labelBackground),
parentFrameId = canvasObject.parentFrameId
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.link"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____styleDecoding = require("core.renderInput.styleDecoding.index")
local decodeShadow = ____styleDecoding.decodeShadow
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local MARKER_TYPES = ____values.MARKER_TYPES
local numOf = ____values.numOf
local optionalOneOf = ____values.optionalOneOf
local PATH_TYPES = ____values.PATH_TYPES
local STROKE_STYLES = ____values.STROKE_STYLES
local strokePaint = ____values.strokePaint
function ____exports.linkObject(self, l)
local p = l.props
local ____l_id_5 = l.id
local ____l_fromId_6 = l.fromId
local ____l_toId_7 = l.toId
local ____temp_8 = l.text or ""
local ____temp_9 = p.showText ~= "false"
local ____numOf_result_10 = numOf(nil, p.weight)
local ____temp_11 = p.showWeight ~= "false"
local ____optionalOneOf_result_1 = optionalOneOf(nil, p.route, PATH_TYPES)
local ____strokePaint_result_2 = strokePaint(nil, p.stroke)
local ____numOf_result_3 = numOf(nil, p.strokeWidth)
local ____optionalOneOf_result_4 = optionalOneOf(nil, p.strokeStyle, STROKE_STYLES)
local ____temp_0
if p.opacity ~= nil then
____temp_0 = numOf(nil, p.opacity)
else
____temp_0 = nil
end
return {
id = ____l_id_5,
fromId = ____l_fromId_6,
toId = ____l_toId_7,
text = ____temp_8,
showText = ____temp_9,
weight = ____numOf_result_10,
showWeight = ____temp_11,
style = {
pathType = ____optionalOneOf_result_1,
color = ____strokePaint_result_2,
strokeWidth = ____numOf_result_3,
strokeStyle = ____optionalOneOf_result_4,
opacity = ____temp_0,
fontSize = numOf(nil, p.fontSize),
fontFamily = p.fontFamily,
startLabel = p.startLabel,
endLabel = p.endLabel,
shadow = decodeShadow(nil, p.shadow)
},
startMarker = optionalOneOf(nil, p.markerStart, MARKER_TYPES),
endMarker = optionalOneOf(nil, p.markerEnd, MARKER_TYPES),
segmentOffsets = l.segments,
fromPoint = __t(nil, l.fromPort) and ({kind = "port", port = l.fromPort}) or (__t(nil, l.fromSide) and ({kind = "side", side = l.fromSide, offset = l.fromFraction}) or nil),
toPoint = __t(nil, l.toPort) and ({kind = "port", port = l.toPort}) or (__t(nil, l.toSide) and ({kind = "side", side = l.toSide, offset = l.toFraction}) or nil),
order = l.order,
sourceIndex = l.sourceIndex
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.mesh"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local Map = ____lualib.Map
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__New = ____lualib.__TS__New
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____sflToCanvasState = require("core.sflSemantic.sflToCanvasState")
local isMeshSurfaceObject = ____sflToCanvasState.isMeshSurfaceObject
function ____exports.meshObject(self, canvasObject, scenes)
local ____canvasObject_mesh_0 = canvasObject.mesh
local asset = ____canvasObject_mesh_0.asset
local role = ____canvasObject_mesh_0.role
local color = ____canvasObject_mesh_0.color
local opacity = ____canvasObject_mesh_0.opacity
local roughness = ____canvasObject_mesh_0.roughness
local metallic = ____canvasObject_mesh_0.metallic
local transmission = ____canvasObject_mesh_0.transmission
local ior = ____canvasObject_mesh_0.ior
local position = ____canvasObject_mesh_0.position
local rotation = ____canvasObject_mesh_0.rotation
local scale = ____canvasObject_mesh_0.scale
local parent = canvasObject.parentFrameId
return {
id = canvasObject.id,
asset = asset,
role = role,
color = color,
opacity = opacity or 1,
roughness = roughness,
metallic = metallic,
transmission = transmission,
ior = ior,
position = position,
rotation = rotation,
scale = scale,
sceneId = __t(nil, parent) and scenes:has(parent) and parent or nil,
sourceIndex = canvasObject.sourceIndex
}
end
function ____exports.meshLightObject(self, canvasObject, scenes)
local parent = canvasObject.parentFrameId
return __TS__ObjectAssign(
{
id = canvasObject.id,
sceneId = __t(nil, parent) and scenes:has(parent) and parent or nil
},
canvasObject.meshLight
)
end
function ____exports.meshSurfaces(self, canvasObjects, scenes)
local parents = __TS__New(
Map,
__TS__ArrayMap(
canvasObjects,
function(____, object) return {object.id, object.parentFrameId} end
)
)
local function liesOn(____, object, surface)
local parent = object.parentFrameId
while __t(nil, parent) do
if parent == surface then
return true
end
parent = parents:get(parent)
end
return false
end
return __TS__ArrayMap(
__TS__ArrayFilter(canvasObjects, isMeshSurfaceObject),
function(____, ____bindingPattern0)
local meshSurface
local parentFrameId
local height
local width
local id
id = ____bindingPattern0.id
width = ____bindingPattern0.width
height = ____bindingPattern0.height
parentFrameId = ____bindingPattern0.parentFrameId
meshSurface = ____bindingPattern0.meshSurface
return __TS__ObjectAssign(
{
id = id,
sceneId = __t(nil, parentFrameId) and scenes:has(parentFrameId) and parentFrameId or nil,
width = width,
height = height
},
meshSurface,
{members = __TS__ArrayMap(
__TS__ArrayFilter(
canvasObjects,
function(____, object) return liesOn(nil, object, id) end
),
function(____, ____bindingPattern0)
local h
local w
local y
local x
local member
member = ____bindingPattern0.id
x = ____bindingPattern0.x
y = ____bindingPattern0.y
w = ____bindingPattern0.width
h = ____bindingPattern0.height
return {
id = member,
x = x,
y = y,
width = w,
height = h
}
end
)}
)
end
)
end
function ____exports.meshSceneObject(self, canvasObject)
local ____canvasObject_1 = canvasObject
local id = ____canvasObject_1.id
local x = ____canvasObject_1.x
local y = ____canvasObject_1.y
local width = ____canvasObject_1.width
local height = ____canvasObject_1.height
local order = ____canvasObject_1.order
local meshScene = ____canvasObject_1.meshScene
local ____meshScene_2 = meshScene
local orbit = ____meshScene_2.orbit
local zoom = ____meshScene_2.zoom
local shadow = ____meshScene_2.shadow
local environment = ____meshScene_2.environment
local environmentTurn = ____meshScene_2.environmentTurn
local exposure = ____meshScene_2.exposure
local haze = ____meshScene_2.haze
local hazeColor = ____meshScene_2.hazeColor
return {
id = id,
x = x,
y = y,
width = width,
height = height,
order = order,
orbit = orbit,
zoom = zoom,
shadow = shadow,
environment = environment,
environmentTurn = environmentTurn,
exposure = exposure,
haze = haze,
hazeColor = hazeColor
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.path"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __match = ______shims.__match
local __re = ______shims.__re
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local dashArray = ____values.dashArray
local numOf = ____values.numOf
local oneOf = ____values.oneOf
local PATH_MARKERS = ____values.PATH_MARKERS
local solidColor = ____values.solidColor
local function numberList(self, value)
local ____temp_0
if value == nil then
____temp_0 = nil
else
____temp_0 = __match(
nil,
tostring(value),
__re(nil, "-?\\d+(?:\\.\\d+)?", "g")
)
end
local numbers = ____temp_0
local ____opt_1 = numbers
return ____opt_1 and __TS__ArrayMap(numbers, Number)
end
function ____exports.pathObject(self, e)
local p = e.props
local ____e_id_18 = e.id
local ____e_x_19 = e.x
local ____e_y_20 = e.y
local ____e_width_21 = e.width
local ____e_height_22 = e.height
local ____opt_3 = e.path
local ____temp_23 = ____opt_3 and ____opt_3.points or ({})
local ____opt_5 = e.path
local ____temp_24 = ____opt_5 and ____opt_5.value
local ____opt_7 = e.path
local ____temp_25 = ____opt_7 and ____opt_7.tension or 0
local ____temp_26 = numOf(nil, p.cornerRadius) or 0
local ____numberList_result_27 = numberList(nil, p.cornerRadii)
local ____oneOf_11 = oneOf
local ____opt_9 = e.path
local ____oneOf_11_result_28 = ____oneOf_11(nil, ____opt_9 and ____opt_9.startMarker, PATH_MARKERS, "none")
local ____oneOf_14 = oneOf
local ____opt_12 = e.path
local ____oneOf_14_result_29 = ____oneOf_14(nil, ____opt_12 and ____opt_12.endMarker, PATH_MARKERS, "none")
local ____opt_15 = e.path
local ____temp_17 = ____opt_15 and ____opt_15.closed
if ____temp_17 == nil then
____temp_17 = false
end
return {
id = ____e_id_18,
x = ____e_x_19,
y = ____e_y_20,
width = ____e_width_21,
height = ____e_height_22,
points = ____temp_23,
value = ____temp_24,
tension = ____temp_25,
cornerRadius = ____temp_26,
cornerRadii = ____numberList_result_27,
startMarker = ____oneOf_11_result_28,
endMarker = ____oneOf_14_result_29,
closed = ____temp_17,
strokeColor = solidColor(nil, p.stroke) or "#7c3aed",
strokeWidth = numOf(nil, p.strokeWidth) or 2,
dash = dashArray(nil, p.dash) or ({}),
opacity = numOf(nil, p.opacity) or 1,
transition = numOf(nil, p.transition),
glow = numOf(nil, p.glow),
glowColor = solidColor(nil, p.glowColor),
fillColor = solidColor(nil, p.fill) or "transparent",
order = e.order,
sourceIndex = e.sourceIndex
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.shape"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local ____exports = {}
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____styleDecoding = require("core.renderInput.styleDecoding.index")
local decodeColor = ____styleDecoding.decodeColor
local decodeShadow = ____styleDecoding.decodeShadow
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local BLEND_MODES = ____values.BLEND_MODES
local dashArray = ____values.dashArray
local numOf = ____values.numOf
local oneOf = ____values.oneOf
local optionalOneOf = ____values.optionalOneOf
local SHAPE_FONT_WEIGHTS = ____values.SHAPE_FONT_WEIGHTS
local SHAPE_STROKE_STYLES = ____values.SHAPE_STROKE_STYLES
local strokePaint = ____values.strokePaint
local TEXT_ALIGNS = ____values.TEXT_ALIGNS
local VERTICAL_ALIGNS = ____values.VERTICAL_ALIGNS
local IMAGE_FITS = {"cover", "contain", "fill"}
local function shapeTypeOf(self, value)
return __lor(
nil,
value,
function() return "rectangle" end
)
end
local function numbers(self, value, count)
local ____opt_0 = value
if ____opt_0 ~= nil then
local ____opt_1 = value
____opt_0 = __TS__ArrayMap(
____opt_1 and __TS__StringSplit(value, ","),
Number
)
end
local parts = ____opt_0
return (parts and #parts) == count and __TS__ArrayEvery(parts, __isFinite) and parts or nil
end
local function imageOf(self, p)
local size = numbers(nil, p.imageSize, 2)
local crop = numbers(nil, p.crop, 4)
return {
src = p.src,
fit = oneOf(nil, p.fit, IMAGE_FITS, "cover"),
pixels = size and size[1] > 0 and size[2] > 0 and ({size[1], size[2]}) or nil,
crop = crop and crop[3] > 0 and crop[4] > 0 and ({x = crop[1], y = crop[2], width = crop[3], height = crop[4]}) or nil
}
end
function ____exports.shapeObject(self, e, shaders)
local p = e.props
local isText = e.kind == "text"
local isImage = e.kind == "image"
local unpainted = isText or isImage
local ____e_id_8 = e.id
local ____temp_9 = e.text or nil
local ____shapeTypeOf_result_10 = shapeTypeOf(
nil,
e.shapeType or (isImage and __t(nil, p.cornerRadius) and "rounded_rectangle" or nil)
)
local ____e_symbol_11 = e.symbol
local ____e_x_12 = e.x
local ____e_y_13 = e.y
local ____e_width_14 = e.width
local ____e_height_15 = e.height
local ____e_width_16 = e.width
local ____e_height_17 = e.height
local ____temp_18 = e.rotation or 0
local ____decodeColor_result_19 = decodeColor(nil, p.fill or (unpainted and "none" or nil))
local ____strokePaint_result_20 = strokePaint(nil, p.stroke or (unpainted and "none" or nil))
local ____temp_21 = isText or nil
local ____numOf_result_22 = numOf(nil, p.strokeWidth)
local ____p_textColor_23 = p.textColor
local ____numOf_result_24 = numOf(nil, p.fontSize)
local ____temp_6
if p.fontWeight == nil then
____temp_6 = nil
else
____temp_6 = oneOf(nil, p.fontWeight, SHAPE_FONT_WEIGHTS, "normal")
end
local ____numOf_result_25 = numOf(nil, p.letterSpacing)
local ____numOf_result_26 = numOf(nil, p.lineHeight)
local ____p_fontFamily_27 = p.fontFamily
local ____optionalOneOf_result_28 = optionalOneOf(nil, p.textAlign, TEXT_ALIGNS)
local ____optionalOneOf_result_29 = optionalOneOf(nil, p.verticalAlign, VERTICAL_ALIGNS)
local ____numOf_result_30 = numOf(nil, p.cornerRadius)
local ____decodeShadow_result_31 = decodeShadow(nil, p.shadow)
local ____dashArray_result_32 = dashArray(nil, p.dash)
local ____optionalOneOf_result_33 = optionalOneOf(nil, p.strokeStyle, SHAPE_STROKE_STYLES)
local ____numOf_result_34 = numOf(nil, p.opacity)
local ____numOf_result_35 = numOf(nil, p.transition)
local ____numOf_result_36 = numOf(nil, p.blur)
local ____optionalOneOf_result_37 = optionalOneOf(nil, p.blend, BLEND_MODES)
local ____e_parentFrameId_38 = e.parentFrameId
local ____e_order_39 = e.order
local ____e_sourceIndex_40 = e.sourceIndex
local ____t_result_7
if __t(nil, p.shader) then
____t_result_7 = shaders:get(p.shader)
else
____t_result_7 = nil
end
return {
id = ____e_id_8,
type = "shape",
text = ____temp_9,
shapeType = ____shapeTypeOf_result_10,
symbol = ____e_symbol_11,
x = ____e_x_12,
y = ____e_y_13,
width = ____e_width_14,
height = ____e_height_15,
w = ____e_width_16,
h = ____e_height_17,
rotation = ____temp_18,
fillColor = ____decodeColor_result_19,
strokeColor = ____strokePaint_result_20,
isText = ____temp_21,
strokeWidth = ____numOf_result_22,
textColor = ____p_textColor_23,
fontSize = ____numOf_result_24,
fontWeight = ____temp_6,
letterSpacing = ____numOf_result_25,
lineHeight = ____numOf_result_26,
fontFamily = ____p_fontFamily_27,
textAlign = ____optionalOneOf_result_28,
textVerticalAlign = ____optionalOneOf_result_29,
cornerRadius = ____numOf_result_30,
shadowStyle = ____decodeShadow_result_31,
dash = ____dashArray_result_32,
strokeStyle = ____optionalOneOf_result_33,
opacity = ____numOf_result_34,
transition = ____numOf_result_35,
blur = ____numOf_result_36,
blend = ____optionalOneOf_result_37,
parentFrameId = ____e_parentFrameId_38,
order = ____e_order_39,
sourceIndex = ____e_sourceIndex_40,
shader = ____t_result_7,
image = isImage and __t(nil, p.src) and imageOf(nil, p) or nil
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.swimlane"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____styleDecoding = require("core.renderInput.styleDecoding.index")
local decodeShadow = ____styleDecoding.decodeShadow
local ____values = require("core.renderInput.fromSfl.canvasObjects.values")
local dashArray = ____values.dashArray
local FONT_WEIGHTS = ____values.FONT_WEIGHTS
local numOf = ____values.numOf
local oneOf = ____values.oneOf
function ____exports.swimlaneObject(self, e)
local p = e.props
local ____e_id_4 = e.id
local ____temp_5 = e.text or nil
local ____e_x_6 = e.x
local ____e_y_7 = e.y
local ____e_width_8 = e.width
local ____e_height_9 = e.height
local ____opt_0 = e.swimlane
local ____temp_10 = ____opt_0 and ____opt_0.orientation or "horizontal"
local ____opt_2 = e.swimlane
return {
id = ____e_id_4,
title = ____temp_5,
x = ____e_x_6,
y = ____e_y_7,
width = ____e_width_8,
height = ____e_height_9,
orientation = ____temp_10,
lanes = ____opt_2 and ____opt_2.lanes or ({}),
fillColor = p.fill or "rgba(107, 114, 128, 0.05)",
strokeColor = p.stroke or "#6b7280",
strokeWidth = numOf(nil, p.strokeWidth) or 2,
cornerRadius = numOf(nil, p.cornerRadius) or 12,
dash = dashArray(nil, p.dash),
shadowStyle = decodeShadow(nil, p.shadow),
textColor = p.textColor or "#6b7280",
fontSize = numOf(nil, p.fontSize) or 22,
fontWeight = oneOf(nil, p.fontWeight, FONT_WEIGHTS, "bold"),
fontFamily = p.fontFamily,
showLaneLabels = p.showLaneLabels ~= "false",
order = e.order,
sourceIndex = e.sourceIndex
}
end
return ____exports
end,
["core.renderInput.fromSfl.canvasObjects.collect"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__New = ____lualib.__TS__New
local Set = ____lualib.Set
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __sort = ______shims.__sort
local ____sflToCanvasState = require("core.sflSemantic.sflToCanvasState")
local isDimensionObject = ____sflToCanvasState.isDimensionObject
local isIsometricObject = ____sflToCanvasState.isIsometricObject
local isMeshGroundObject = ____sflToCanvasState.isMeshGroundObject
local isMeshLightObject = ____sflToCanvasState.isMeshLightObject
local isMeshObject = ____sflToCanvasState.isMeshObject
local isMeshSceneObject = ____sflToCanvasState.isMeshSceneObject
local ____chart = require("core.renderInput.fromSfl.canvasObjects.chart")
local chartObject = ____chart.chartObject
local ____component = require("core.renderInput.fromSfl.canvasObjects.component")
local componentObject = ____component.componentObject
local ____connection = require("core.renderInput.fromSfl.canvasObjects.connection")
local connectionObject = ____connection.connectionObject
local ____dimension = require("core.renderInput.fromSfl.canvasObjects.dimension")
local dimensionObject = ____dimension.dimensionObject
local ____frame = require("core.renderInput.fromSfl.canvasObjects.frame")
local frameObject = ____frame.frameObject
local ____isometric = require("core.renderInput.fromSfl.canvasObjects.isometric")
local isometricObject = ____isometric.isometricObject
local ____link = require("core.renderInput.fromSfl.canvasObjects.link")
local linkObject = ____link.linkObject
local ____mesh = require("core.renderInput.fromSfl.canvasObjects.mesh")
local meshLightObject = ____mesh.meshLightObject
local meshObject = ____mesh.meshObject
local meshSceneObject = ____mesh.meshSceneObject
local meshSurfaces = ____mesh.meshSurfaces
local ____path = require("core.renderInput.fromSfl.canvasObjects.path")
local pathObject = ____path.pathObject
local ____shape = require("core.renderInput.fromSfl.canvasObjects.shape")
local shapeObject = ____shape.shapeObject
local ____swimlane = require("core.renderInput.fromSfl.canvasObjects.swimlane")
local swimlaneObject = ____swimlane.swimlaneObject
local function byOrder(____, items)
return __sort(
nil,
{table.unpack(items)},
function(____, a, b) return (a.order or 0) - (b.order or 0) end
)
end
function ____exports.collectCanvasObjects(self, state)
local canvasObjects = byOrder(nil, state.canvasObjects)
local shaders = __TS__New(
Map,
__TS__ArrayMap(
state.shaders or ({}),
function(____, shader) return {shader.name, shader} end
)
)
local sceneIds = __TS__New(
Set,
__TS__ArrayMap(
__TS__ArrayFilter(canvasObjects, isMeshSceneObject),
function(____, object) return object.id end
)
)
return {
shapes = __TS__ArrayMap(
__TS__ArrayFilter(
canvasObjects,
function(____, canvasObject) return canvasObject.objectType == "shape" end
),
function(____, shape) return shapeObject(nil, shape, shaders) end
),
frames = __TS__ArrayMap(
__TS__ArrayFilter(
canvasObjects,
function(____, canvasObject) return canvasObject.objectType == "frame" end
),
frameObject
),
swimlanes = __TS__ArrayMap(
__TS__ArrayFilter(
canvasObjects,
function(____, canvasObject) return canvasObject.objectType == "swimlane" end
),
swimlaneObject
),
isometricObjects = __TS__ArrayMap(
__TS__ArrayFilter(canvasObjects, isIsometricObject),
isometricObject
),
paths = __TS__ArrayMap(
__TS__ArrayFilter(
canvasObjects,
function(____, canvasObject) return canvasObject.objectType == "path" end
),
pathObject
),
dimensions = __TS__ArrayMap(
__TS__ArrayFilter(canvasObjects, isDimensionObject),
dimensionObject
),
meshes = __TS__ArrayMap(
__TS__ArrayFilter(canvasObjects, isMeshObject),
function(____, object) return meshObject(nil, object, sceneIds) end
),
meshScenes = __TS__ArrayMap(
__TS__ArrayFilter(canvasObjects, isMeshSceneObject),
function(____, scene)
local ground = __TS__ArrayFind(
__TS__ArrayFilter(canvasObjects, isMeshGroundObject),
function(____, object) return object.parentFrameId == scene.id end
)
return __TS__ObjectAssign(
{},
meshSceneObject(nil, scene),
{ground = ground and __TS__ObjectAssign({id = ground.id}, ground.meshGround)}
)
end
),
meshSurfaces = meshSurfaces(nil, canvasObjects, sceneIds),
meshLights = __TS__ArrayMap(
__TS__ArrayFilter(canvasObjects, isMeshLightObject),
function(____, object) return meshLightObject(nil, object, sceneIds) end
),
meshAnchors = __TS__ArrayFlatMap(
canvasObjects,
function(____, object) return object.anchor and ({__TS__ObjectAssign({objectId = object.id}, object.anchor)}) or ({}) end
),
charts = __TS__ArrayMap(
__TS__ArrayFilter(
canvasObjects,
function(____, canvasObject) return canvasObject.objectType == "chart" end
),
chartObject
),
components = __TS__ArrayMap(
__TS__ArrayFilter(
canvasObjects,
function(____, canvasObject) return canvasObject.objectType == "component" and canvasObject.component ~= nil end
),
componentObject
),
links = __TS__ArrayMap(
byOrder(nil, state.links),
linkObject
),
connections = __TS__ArrayMap(
byOrder(nil, state.connections),
connectionObject
)
}
end
return ____exports
end,
["core.model.geometry.ports.rectangleCoordinates"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local DEGREES_TO_RADIANS = math.pi / 180
local function rotatePoint(self, point, degrees)
local radians = degrees * DEGREES_TO_RADIANS
local cosine = math.cos(radians)
local sine = math.sin(radians)
return {x = point.x * cosine - point.y * sine, y = point.x * sine + point.y * cosine}
end
local function rectangleCenter(self, rectangle)
return {x = rectangle.x + rectangle.width / 2, y = rectangle.y + rectangle.height / 2}
end
function ____exports.worldPointToRectangle(self, rectangle, worldPoint)
local center = rectangleCenter(nil, rectangle)
local pointRelativeToCenter = {x = worldPoint.x - center.x, y = worldPoint.y - center.y}
return __t(nil, rectangle.rotation) and rotatePoint(nil, pointRelativeToCenter, -rectangle.rotation) or pointRelativeToCenter
end
function ____exports.rectanglePointToWorld(self, rectangle, rectanglePoint)
local center = rectangleCenter(nil, rectangle)
local rotatedPoint = __t(nil, rectangle.rotation) and rotatePoint(nil, rectanglePoint, rectangle.rotation) or rectanglePoint
return {x = center.x + rotatedPoint.x, y = center.y + rotatedPoint.y}
end
return ____exports
end,
["core.model.geometry.ports.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.model.geometry.ports.coordinates"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____rectangleCoordinates = require("core.model.geometry.ports.rectangleCoordinates")
local rectanglePointToWorld = ____rectangleCoordinates.rectanglePointToWorld
local worldPointToRectangle = ____rectangleCoordinates.worldPointToRectangle
local function portPointInRectangle(self, rectangle, port)
local offset = math.max(
0,
math.min(1, port.offset)
)
local halfWidth = rectangle.width / 2
local halfHeight = rectangle.height / 2
repeat
local ____switch3 = port.side
local ____cond3 = ____switch3 == "top"
if ____cond3 then
return {x = (offset - 0.5) * rectangle.width, y = -halfHeight}
end
____cond3 = ____cond3 or ____switch3 == "right"
if ____cond3 then
return {x = halfWidth, y = (offset - 0.5) * rectangle.height}
end
____cond3 = ____cond3 or ____switch3 == "bottom"
if ____cond3 then
return {x = (offset - 0.5) * rectangle.width, y = halfHeight}
end
____cond3 = ____cond3 or ____switch3 == "left"
if ____cond3 then
return {x = -halfWidth, y = (offset - 0.5) * rectangle.height}
end
until true
end
function ____exports.pointAtPort(self, rectangle, port)
return rectanglePointToWorld(
nil,
rectangle,
portPointInRectangle(nil, rectangle, port)
)
end
function ____exports.pointAtNormalizedPort(self, rectangle, normalizedPosition)
return rectanglePointToWorld(nil, rectangle, {x = (normalizedPosition[1] - 0.5) * rectangle.width, y = (normalizedPosition[2] - 0.5) * rectangle.height})
end
function ____exports.relativeOffsetOnRectangleSide(self, rectangle, side, worldPoint)
local rectanglePoint = worldPointToRectangle(nil, rectangle, worldPoint)
repeat
local ____switch7 = side
local ____cond7 = ____switch7 == "top" or ____switch7 == "bottom"
if ____cond7 then
return (rectanglePoint.x + rectangle.width / 2) / rectangle.width
end
____cond7 = ____cond7 or (____switch7 == "left" or ____switch7 == "right")
if ____cond7 then
return (rectanglePoint.y + rectangle.height / 2) / rectangle.height
end
until true
end
return ____exports
end,
["core.model.geometry.ports.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____coordinates = require("core.model.geometry.ports.coordinates")
____exports.pointAtNormalizedPort = ____coordinates.pointAtNormalizedPort
____exports.pointAtPort = ____coordinates.pointAtPort
____exports.relativeOffsetOnRectangleSide = ____coordinates.relativeOffsetOnRectangleSide
end
return ____exports
end,
["core.model.geometry.rectangle.edgePoint"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.elementCenter(self, rect)
return {x = rect.x + rect.width / 2, y = rect.y + rect.height / 2}
end
function ____exports.edgePointToward(self, rect, other)
local center = ____exports.elementCenter(nil, rect)
local otherCenter = ____exports.elementCenter(nil, other)
local angle = math.atan(otherCenter.y - center.y, otherCenter.x - center.x)
if angle >= -math.pi / 4 and angle < math.pi / 4 then
return {x = rect.x + rect.width, y = center.y}
end
if angle >= math.pi / 4 and angle < 3 * math.pi / 4 then
return {x = center.x, y = rect.y + rect.height}
end
if angle >= -3 * math.pi / 4 and angle < -math.pi / 4 then
return {x = center.x, y = rect.y}
end
return {x = rect.x, y = center.y}
end
return ____exports
end,
["core.model.geometry.rectangle.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____edgePoint = require("core.model.geometry.rectangle.edgePoint")
____exports.edgePointToward = ____edgePoint.edgePointToward
____exports.elementCenter = ____edgePoint.elementCenter
end
return ____exports
end,
["core.renderInput.fromSfl.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderInput.fromSfl.endpoint"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local ____exports = {}
local sidePoint, namedPortPoint, selectLinkEndpoint, explicitAbsolutePoint, explicitAnchorPoint, automaticEndpointPoint, findPositionedCanvasObject
local ____ports = require("core.model.geometry.ports.index")
local pointAtNormalizedPort = ____ports.pointAtNormalizedPort
local ____rectangle = require("core.model.geometry.rectangle.index")
local edgePointToward = ____rectangle.edgePointToward
local elementCenter = ____rectangle.elementCenter
function sidePoint(self, canvasObject, endpoint)
local offset = endpoint.offset or 0.5
repeat
local ____switch3 = endpoint.side
local ____cond3 = ____switch3 == "top"
if ____cond3 then
return {x = canvasObject.x + canvasObject.width * offset, y = canvasObject.y}
end
____cond3 = ____cond3 or ____switch3 == "right"
if ____cond3 then
return {x = canvasObject.x + canvasObject.width, y = canvasObject.y + canvasObject.height * offset}
end
____cond3 = ____cond3 or ____switch3 == "bottom"
if ____cond3 then
return {x = canvasObject.x + canvasObject.width * offset, y = canvasObject.y + canvasObject.height}
end
____cond3 = ____cond3 or ____switch3 == "left"
if ____cond3 then
return {x = canvasObject.x, y = canvasObject.y + canvasObject.height * offset}
end
until true
end
function namedPortPoint(self, canvasObject, endpoint)
local ____opt_4 = canvasObject.symbol
local ____opt_0 = ____opt_4 and ____opt_4.ports
if ____opt_0 ~= nil then
local ____opt_1 = canvasObject.symbol
____opt_0 = __TS__ArrayFind(
____opt_1 and ____opt_1.ports,
function(____, candidate) return candidate.name == endpoint.port end
)
end
local port = ____opt_0
if not port then
return elementCenter(nil, canvasObject)
end
return pointAtNormalizedPort(nil, {
x = canvasObject.x,
y = canvasObject.y,
width = canvasObject.width,
height = canvasObject.height,
rotation = canvasObject.rotation or nil
}, port.at)
end
function selectLinkEndpoint(self, link, ____end)
return ____end == "from" and ({canvasObjectId = link.fromId, oppositeCanvasObjectId = link.toId, explicit = link.fromPoint}) or ({canvasObjectId = link.toId, oppositeCanvasObjectId = link.fromId, explicit = link.toPoint})
end
function explicitAbsolutePoint(self, endpoint)
return (endpoint and endpoint.kind) == "absolute" and ({x = endpoint.x, y = endpoint.y}) or nil
end
function explicitAnchorPoint(self, canvasObject, endpoint)
if (endpoint and endpoint.kind) == "port" then
return namedPortPoint(nil, canvasObject, endpoint)
end
if (endpoint and endpoint.kind) == "side" then
return sidePoint(nil, canvasObject, endpoint)
end
return nil
end
function automaticEndpointPoint(self, canvasObject, opposite)
return opposite and edgePointToward(nil, canvasObject, opposite) or elementCenter(nil, canvasObject)
end
function findPositionedCanvasObject(self, canvasObjects, id)
return __TS__ArrayFind(
canvasObjects,
function(____, candidate) return candidate.id == id end
)
end
function ____exports.resolveLinkEndpoint(self, link, ____end, canvasObjects)
local selected = selectLinkEndpoint(nil, link, ____end)
local absolutePoint = explicitAbsolutePoint(nil, selected.explicit)
if absolutePoint then
return absolutePoint
end
local canvasObject = findPositionedCanvasObject(nil, canvasObjects, selected.canvasObjectId)
if not canvasObject then
return {x = 0, y = 0}
end
local anchoredPoint = explicitAnchorPoint(nil, canvasObject, selected.explicit)
if anchoredPoint then
return anchoredPoint
end
return automaticEndpointPoint(
nil,
canvasObject,
findPositionedCanvasObject(nil, canvasObjects, selected.oppositeCanvasObjectId)
)
end
return ____exports
end,
["core.renderInput.fromSfl.links"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFindIndex = ____lualib.__TS__ArrayFindIndex
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local Map = ____lualib.Map
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__New = ____lualib.__TS__New
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____isometricObject = require("core.model.isometricObject.index")
local isometricFaceCenter = ____isometricObject.isometricFaceCenter
local VISIBLE_ISOMETRIC_FACES = ____isometricObject.VISIBLE_ISOMETRIC_FACES
local ____endpoint = require("core.renderInput.fromSfl.endpoint")
local resolveLinkEndpoint = ____endpoint.resolveLinkEndpoint
local ISOMETRIC_SEQUENCE_BASE = 15000
local function positionedCanvasObjects(self, canvasObjects)
local ____array_0 = __TS__SparseArrayNew(table.unpack(canvasObjects.shapes))
__TS__SparseArrayPush(
____array_0,
table.unpack(canvasObjects.frames)
)
__TS__SparseArrayPush(
____array_0,
table.unpack(canvasObjects.swimlanes)
)
__TS__SparseArrayPush(
____array_0,
table.unpack(canvasObjects.paths)
)
__TS__SparseArrayPush(
____array_0,
table.unpack(canvasObjects.charts)
)
return {__TS__SparseArraySpread(____array_0)}
end
local function connectionEndpointPoint(self, object, face)
return object and isometricFaceCenter(nil, object, face) or ({x = 0, y = 0})
end
local function isometricStackPosition(self, isometricObjects, id)
local index = __TS__ArrayFindIndex(
isometricObjects,
function(____, object) return object.id == id end
)
if index < 0 then
return nil
end
local object = isometricObjects[index + 1]
return {rank = object.order or 0, sequence = object.sourceIndex or ISOMETRIC_SEQUENCE_BASE + index}
end
local function connectionStack(self, isometricObjects, connection)
if type(connection.order) == "number" then
return {order = connection.order, sourceIndex = connection.sourceIndex}
end
local ____compact_3 = __compact
local ____VISIBLE_ISOMETRIC_FACES_has_result_1
if VISIBLE_ISOMETRIC_FACES:has(connection.fromFace) then
____VISIBLE_ISOMETRIC_FACES_has_result_1 = nil
else
____VISIBLE_ISOMETRIC_FACES_has_result_1 = isometricStackPosition(nil, isometricObjects, connection.fromId)
end
local ____VISIBLE_ISOMETRIC_FACES_has_result_2
if VISIBLE_ISOMETRIC_FACES:has(connection.toFace) then
____VISIBLE_ISOMETRIC_FACES_has_result_2 = nil
else
____VISIBLE_ISOMETRIC_FACES_has_result_2 = isometricStackPosition(nil, isometricObjects, connection.toId)
end
local behind = __TS__ArrayFilter(
____compact_3(____VISIBLE_ISOMETRIC_FACES_has_result_1, ____VISIBLE_ISOMETRIC_FACES_has_result_2),
function(____, position) return position ~= nil end
)
if not __t(nil, #behind) then
return {sourceIndex = connection.sourceIndex}
end
local lowest = __TS__ArrayReduce(
behind,
function(____, best, position) return (position.rank < best.rank or position.rank == best.rank and position.sequence < best.sequence) and position or best end
)
return {order = lowest.rank, sourceIndex = lowest.sequence - 0.5}
end
local function createRenderInputConnections(self, canvasObjects)
local isometricById = __TS__New(
Map,
__TS__ArrayMap(
canvasObjects.isometricObjects,
function(____, object) return {object.id, object} end
)
)
return __TS__ArrayMap(
canvasObjects.connections,
function(____, connection)
local link = __TS__ObjectAssign(
{
id = connection.id,
fromId = connection.fromId,
toId = connection.toId,
fromPoint = {kind = "face", face = connection.fromFace},
toPoint = {kind = "face", face = connection.toFace},
style = connection.style
},
connectionStack(nil, canvasObjects.isometricObjects, connection)
)
return {
link = link,
from = connectionEndpointPoint(
nil,
isometricById:get(connection.fromId or ""),
connection.fromFace
),
to = connectionEndpointPoint(
nil,
isometricById:get(connection.toId or ""),
connection.toFace
),
kind = "connection"
}
end
)
end
function ____exports.createRenderInputLinks(self, canvasObjects)
local positionedObjects = positionedCanvasObjects(nil, canvasObjects)
local links = __TS__ArrayMap(
canvasObjects.links,
function(____, link) return {
link = link,
from = resolveLinkEndpoint(nil, link, "from", positionedObjects),
to = resolveLinkEndpoint(nil, link, "to", positionedObjects)
} end
)
local ____array_4 = __TS__SparseArrayNew(table.unpack(links))
__TS__SparseArrayPush(
____array_4,
table.unpack(createRenderInputConnections(nil, canvasObjects))
)
return {__TS__SparseArraySpread(____array_4)}
end
return ____exports
end,
["core.renderInput.fromSfl.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____sflLanguage = require("core.sflLanguage.index")
local parse = ____sflLanguage.parse
local ____expansion = require("core.sflLanguage.expansion.index")
local expandDocument = ____expansion.expandDocument
local ____resolver = require("core.sflSemantic.canvasState.resolver")
local resolveCanvasState = ____resolver.resolveCanvasState
local ____collect = require("core.renderInput.fromSfl.canvasObjects.collect")
local collectCanvasObjects = ____collect.collectCanvasObjects
local ____links = require("core.renderInput.fromSfl.links")
local createRenderInputLinks = ____links.createRenderInputLinks
function ____exports.documentToRenderInput(self, doc, tables)
local state = resolveCanvasState(
nil,
expandDocument(nil, doc, tables)
)
local canvasObjects = collectCanvasObjects(nil, state)
return {
shapes = canvasObjects.shapes,
frames = canvasObjects.frames,
swimlanes = canvasObjects.swimlanes,
isometricObjects = canvasObjects.isometricObjects,
paths = canvasObjects.paths,
dimensions = canvasObjects.dimensions,
meshes = canvasObjects.meshes,
meshScenes = canvasObjects.meshScenes,
meshSurfaces = canvasObjects.meshSurfaces,
meshLights = canvasObjects.meshLights,
meshAnchors = canvasObjects.meshAnchors,
charts = canvasObjects.charts,
components = canvasObjects.components,
links = createRenderInputLinks(nil, canvasObjects),
diagnostics = state.diagnostics
}
end
function ____exports.sflToRenderInput(self, sfl)
return ____exports.documentToRenderInput(
nil,
parse(nil, sfl)
)
end
return ____exports
end,
["core.renderScene.scene.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.scene.bounds"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local rotateFrameCorners, frameCorners, boundsAroundPoints
local ______shims = require("core.__shims")
local __t = ______shims.__t
function rotateFrameCorners(self, frame, degrees)
local centerX = frame.x + frame.width / 2
local centerY = frame.y + frame.height / 2
local angle = degrees * math.pi / 180
local cos = math.cos(angle)
local sin = math.sin(angle)
return __TS__ArrayMap(
frameCorners(nil, frame),
function(____, point) return {x = centerX + (point.x - centerX) * cos - (point.y - centerY) * sin, y = centerY + (point.x - centerX) * sin + (point.y - centerY) * cos} end
)
end
function frameCorners(self, frame)
return {{x = frame.x, y = frame.y}, {x = frame.x + frame.width, y = frame.y}, {x = frame.x + frame.width, y = frame.y + frame.height}, {x = frame.x, y = frame.y + frame.height}}
end
function boundsAroundPoints(self, points, extra)
return {
minX = math.min(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.x end
))) - extra,
minY = math.min(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.y end
))) - extra,
maxX = math.max(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.x end
))) + extra,
maxY = math.max(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.y end
))) + extra
}
end
____exports.EMPTY_BOUNDS = {minX = 0, minY = 0, maxX = 100, maxY = 100}
function ____exports.boxBounds(self, frame, extra)
if extra == nil then
extra = 0
end
return {minX = frame.x - extra, minY = frame.y - extra, maxX = frame.x + frame.width + extra, maxY = frame.y + frame.height + extra}
end
function ____exports.rotatedBounds(self, frame, degrees, extra)
if extra == nil then
extra = 0
end
if not __t(nil, degrees) then
return ____exports.boxBounds(nil, frame, extra)
end
return boundsAroundPoints(
nil,
rotateFrameCorners(nil, frame, degrees),
extra
)
end
return ____exports
end,
["core.model.path.fillet"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local FLAT = 0.001
local function sides(self, previous, corner, next)
local toPrevious = {x = previous.x - corner.x, y = previous.y - corner.y}
local toNext = {x = next.x - corner.x, y = next.y - corner.y}
local previousLength = __hypot(nil, toPrevious.x, toPrevious.y)
local nextLength = __hypot(nil, toNext.x, toNext.y)
if previousLength == 0 or nextLength == 0 then
return nil
end
local a = {x = toPrevious.x / previousLength, y = toPrevious.y / previousLength}
local b = {x = toNext.x / nextLength, y = toNext.y / nextLength}
local angle = math.acos(math.min(
1,
math.max(-1, a.x * b.x + a.y * b.y)
))
if angle < FLAT or math.pi - angle < FLAT then
return nil
end
return {
a = a,
b = b,
angle = angle,
reach = math.min(previousLength, nextLength) / 2
}
end
function ____exports.cornerFrame(self, previous, corner, next)
local found = sides(nil, previous, corner, next)
if not found then
return nil
end
local a = found.a
local b = found.b
local angle = found.angle
local reach = found.reach
local length = __hypot(nil, a.x + b.x, a.y + b.y)
return {
inward = {x = (a.x + b.x) / length, y = (a.y + b.y) / length},
halfSine = math.sin(angle / 2),
maxRadius = reach * math.tan(angle / 2)
}
end
function ____exports.cornerFillet(self, previous, corner, next, radius)
local found = sides(nil, previous, corner, next)
if not found or radius <= 0 then
return nil
end
local a = found.a
local b = found.b
local angle = found.angle
local reach = found.reach
local tangent = math.tan(angle / 2)
local setback = math.min(radius / tangent, reach)
return {start = {x = corner.x + a.x * setback, y = corner.y + a.y * setback}, ["end"] = {x = corner.x + b.x * setback, y = corner.y + b.y * setback}, radius = setback * tangent, sweep = a.x * b.y - a.y * b.x < 0 and 1 or 0}
end
return ____exports
end,
["core.renderScene.scene.freeformPath"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local roundedPathData, linearPathData
local ____path = require("core.model.path.index")
local isStraight = ____path.isStraight
local pathSegments = ____path.pathSegments
local ____fillet = require("core.model.path.fillet")
local cornerFillet = ____fillet.cornerFillet
function ____exports.radiusAt(self, geometry, index)
local ____opt_0 = geometry.cornerRadii
return ____opt_0 and ____opt_0[index + 1] or geometry.cornerRadius or 0
end
function roundedPathData(self, geometry)
local ____geometry_2 = geometry
local points = ____geometry_2.points
local closed = ____geometry_2.closed
local count = #points
local corners = closed and __TS__ArrayMap(
points,
function(____, _, index) return index end
) or __TS__ArrayMap(
__TS__ArraySlice(points, 1, -1),
function(____, _, index) return index + 1 end
)
local commands = {}
if not closed then
commands[#commands + 1] = (("M " .. tostring(points[1].x)) .. " ") .. tostring(points[1].y)
end
__TS__ArrayForEach(
corners,
function(____, index, order)
local point = points[index + 1]
local fillet = cornerFillet(
nil,
points[(index + count - 1) % count + 1],
point,
points[(index + 1) % count + 1],
____exports.radiusAt(nil, geometry, index)
)
local move = order == 0 and closed and "M" or "L"
if fillet then
__TS__ArrayPush(
commands,
(((move .. " ") .. tostring(fillet.start.x)) .. " ") .. tostring(fillet.start.y),
(((((((("A " .. tostring(fillet.radius)) .. " ") .. tostring(fillet.radius)) .. " 0 0 ") .. tostring(fillet.sweep)) .. " ") .. tostring(fillet["end"].x)) .. " ") .. tostring(fillet["end"].y)
)
else
commands[#commands + 1] = (((move .. " ") .. tostring(point.x)) .. " ") .. tostring(point.y)
end
end
)
local last = points[count]
commands[#commands + 1] = closed and "Z" or (("L " .. tostring(last.x)) .. " ") .. tostring(last.y)
return table.concat(commands, " ")
end
function linearPathData(self, geometry)
local ____geometry_points_3 = geometry.points
local first = ____geometry_points_3[1]
local remaining = __TS__ArraySlice(____geometry_points_3, 1)
local segments = table.concat(
__TS__ArrayMap(
remaining,
function(____, point) return (("L " .. tostring(point.x)) .. " ") .. tostring(point.y) end
),
" "
)
return ((((("M " .. tostring(first.x)) .. " ") .. tostring(first.y)) .. " ") .. segments) .. (geometry.closed and " Z" or "")
end
function ____exports.freeformPathData(self, geometry)
if #geometry.points == 0 then
return ""
end
if isStraight(nil, geometry) then
return #geometry.points > 2 and __TS__ArraySome(
geometry.points,
function(____, _, index) return ____exports.radiusAt(nil, geometry, index) > 0 end
) and roundedPathData(nil, geometry) or linearPathData(nil, geometry)
end
local first = geometry.points[1]
local commands = {(("M " .. tostring(first.x)) .. " ") .. tostring(first.y)}
for ____, ____value in ipairs(pathSegments(nil, geometry)) do
local to = ____value.to
local controls = ____value.controls
commands[#commands + 1] = controls and (((((((((("C " .. tostring(controls[1].x)) .. " ") .. tostring(controls[1].y)) .. " ") .. tostring(controls[2].x)) .. " ") .. tostring(controls[2].y)) .. " ") .. tostring(to.x)) .. " ") .. tostring(to.y) or (("L " .. tostring(to.x)) .. " ") .. tostring(to.y)
end
if geometry.closed then
commands[#commands + 1] = "Z"
end
return table.concat(commands, " ")
end
return ____exports
end,
["core.renderScene.scene.numbers"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
function ____exports.finite(self, value, fallback)
return type(value) == "number" and __isFinite(nil, value) and value or fallback
end
return ____exports
end,
["core.renderScene.scene.order"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringCharCodeAt = ____lualib.__TS__StringCharCodeAt
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
function ____exports.stackRank(self, object)
local key = object.order_key or object.orderKey
if not __t(nil, key) then
return object.order or 0
end
local rank = 0
do
local index = 0
while index < math.min(#key, 8) do
rank = rank * 128 + __TS__StringCharCodeAt(key, index)
index = index + 1
end
end
return rank
end
function ____exports.stackSequence(self, object, fallback)
return object.sourceIndex or fallback
end
return ____exports
end,
["core.renderScene.scene.paint"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
function ____exports.paint(self, value, diagnostics, ownerId)
if not __t(nil, value) then
return {kind = "none"}
end
if type(value) == "string" then
return {kind = "solid", color = value}
end
if value.type == "gradient" then
return {
kind = "linear-gradient",
angle = value.angle,
stops = __TS__ArrayMap(
value.stops,
function(____, stop) return {offset = stop.position, color = stop.color} end
)
}
end
if #value.points == 0 then
diagnostics[#diagnostics + 1] = {severity = "warning", code = "empty-mesh-gradient", ownerId = ownerId, message = "Mesh gradient has no color points."}
return {kind = "none"}
end
return {
kind = "mesh-gradient",
points = __TS__ArrayMap(
value.points,
function(____, point) return {x = point.x, y = point.y, color = point.color} end
)
}
end
return ____exports
end,
["core.renderScene.scene.tagging"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
function ____exports.tag(self, nodes, role, id, kind, label, parentFrameId)
__TS__ArrayForEach(
nodes,
function(____, node, index)
node.identity = __TS__ObjectAssign(
{role = role, id = id},
__t(nil, kind) and ({kind = kind}) or ({}),
index == 0 and ({primary = true}) or ({}),
index == 0 and __t(nil, label) and ({label = label}) or ({}),
index == 0 and __t(nil, parentFrameId) and ({parentFrameId = parentFrameId}) or ({})
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.scene.textMetrics"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.scene.textStyle"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.DEFAULT_FONT = "Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"
return ____exports
end,
["core.renderScene.scene.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____bounds = require("core.renderScene.scene.bounds")
____exports.boxBounds = ____bounds.boxBounds
____exports.EMPTY_BOUNDS = ____bounds.EMPTY_BOUNDS
____exports.rotatedBounds = ____bounds.rotatedBounds
end
do
local ____freeformPath = require("core.renderScene.scene.freeformPath")
____exports.freeformPathData = ____freeformPath.freeformPathData
end
do
local ____numbers = require("core.renderScene.scene.numbers")
____exports.finite = ____numbers.finite
end
do
local ____order = require("core.renderScene.scene.order")
____exports.stackRank = ____order.stackRank
____exports.stackSequence = ____order.stackSequence
end
do
local ____paint = require("core.renderScene.scene.paint")
____exports.paint = ____paint.paint
end
do
local ____tagging = require("core.renderScene.scene.tagging")
____exports.tag = ____tagging.tag
end
do
local ____textStyle = require("core.renderScene.scene.textStyle")
____exports.DEFAULT_FONT = ____textStyle.DEFAULT_FONT
end
return ____exports
end,
["core.renderScene.artifacts.component.placeholder"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local rotatedBounds = ____scene.rotatedBounds
local STROKE = "#94a3b8"
function ____exports.buildPlaceholder(self, component, index)
local x = finite(nil, component.x, 0)
local y = finite(nil, component.y, 0)
local width = math.max(
0,
finite(nil, component.width, 120)
)
local height = math.max(
0,
finite(nil, component.height, 60)
)
local rotation = finite(nil, component.rotation, 0)
local order = 10000 + index
local bounds = rotatedBounds(nil, {x = x, y = y, width = width, height = height}, rotation, 2)
return {{
id = "widget-" .. component.id,
type = "rect",
order = order,
bounds = bounds,
x = x,
y = y,
width = width,
height = height,
rx = 6,
rotation = rotation,
style = {fill = {kind = "none"}, stroke = {kind = "solid", color = STROKE}, strokeWidth = 1, dash = {4, 3}}
}, {
id = ("widget-" .. component.id) .. "-label",
type = "text",
order = order + 0.1,
bounds = bounds,
x = x,
y = y,
width = width,
height = height,
lines = {component.type},
fontFamily = DEFAULT_FONT,
fontSize = 12,
fontWeight = "normal",
color = STROKE,
align = "center",
verticalAlign = "middle",
lineHeight = 1.3,
rotation = rotation
}}
end
return ____exports
end,
["core.renderScene.artifacts.component.builtIn"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local buildTickLabels, buildRulerLabels
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____component = require("core.model.component.index")
local formatRollingNumber = ____component.formatRollingNumber
local resolveRollingNumberStyle = ____component.resolveRollingNumberStyle
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local rotatedBounds = ____scene.rotatedBounds
function buildTickLabels(self, component, box)
local labels = component.labels or ({})
local ticks = math.max(
1,
finite(
nil,
__TS__Number(component.parameters.ticks),
48
)
)
local major = math.max(
1,
finite(
nil,
__TS__Number(component.parameters.major),
5
)
)
local start = finite(
nil,
__TS__Number(component.parameters.start),
225
) * math.pi / 180
local sweep = finite(
nil,
__TS__Number(component.parameters.sweep),
270
) * math.pi / 180
local radius = finite(
nil,
__TS__Number(component.parameters.radius),
0.9
) + finite(nil, labels.offset, 0.08)
local fontSize = finite(nil, labels.size, 12)
local centerX = box.x + box.width / 2
local centerY = box.y + box.height / 2
local count = math.floor(ticks / major)
local nodes = {}
do
local step = 0
while step <= count do
local fraction = step * major / ticks
local angle = start - fraction * sweep
local labelX = centerX + math.cos(angle) * radius * (box.width / 2)
local labelY = centerY - math.sin(angle) * radius * (box.height / 2)
local labelBox = {x = labelX - 24, y = labelY - fontSize, width = 48, height = fontSize * 2}
nodes[#nodes + 1] = __TS__ObjectAssign(
{
id = (("widget-" .. component.id) .. "-label-") .. tostring(step),
type = "text",
order = box.order + 0.1,
bounds = rotatedBounds(nil, labelBox, 0, 2)
},
labelBox,
{
lines = {tostring(math.floor(box.max * fraction * 10 + 0.5) / 10)},
fontFamily = __lor(
nil,
labels.fontFamily,
function() return DEFAULT_FONT end
),
fontSize = fontSize,
fontWeight = labels.weight or "normal",
color = __lor(
nil,
labels.color,
function() return "#8f95c4" end
),
align = "center",
verticalAlign = "middle",
lineHeight = 1.3
}
)
step = step + 1
end
end
return nodes
end
function buildRulerLabels(self, component, box)
local labels = component.labels or ({})
local horizontal = component.parameters.axis == "horizontal"
local ticks = math.max(
1,
finite(
nil,
__TS__Number(component.parameters.ticks),
50
)
)
local major = math.max(
1,
finite(
nil,
__TS__Number(component.parameters.major),
5
)
)
local inset = finite(
nil,
__TS__Number(component.parameters.inset),
0.05
) > 0 and finite(
nil,
__TS__Number(component.parameters.inset),
0.05
) or 0.05
local line = finite(
nil,
__TS__Number(component.parameters.line),
0.7
) > 0 and finite(
nil,
__TS__Number(component.parameters.line),
0.7
) or 0.7
local across = horizontal and box.height or box.width
local tickLength = (finite(
nil,
__TS__Number(component.parameters.length),
0.1
) > 0 and finite(
nil,
__TS__Number(component.parameters.length),
0.1
) or 0.1) * across * 1.9
local edge = line * across - 0.12 * across - tickLength - finite(nil, labels.offset, 0.04) * across
local fontSize = finite(nil, labels.size, 12)
local count = math.floor(ticks / major)
local nodes = {}
do
local step = 0
while step <= count do
local fraction = step * major / ticks
local along = inset + (1 - 2 * inset) * fraction
local labelBox = horizontal and ({x = box.x + box.width * along - 24, y = box.y + edge - fontSize * 2, width = 48, height = fontSize * 2}) or ({x = box.x + edge - 48, y = box.y + box.height * (1 - along) - fontSize, width = 48, height = fontSize * 2})
nodes[#nodes + 1] = __TS__ObjectAssign(
{
id = (("widget-" .. component.id) .. "-label-") .. tostring(step),
type = "text",
order = box.order + 0.1,
bounds = rotatedBounds(nil, labelBox, 0, 2)
},
labelBox,
{
lines = {tostring(math.floor((box.min + (box.max - box.min) * fraction) * 10 + 0.5) / 10)},
fontFamily = __lor(
nil,
labels.fontFamily,
function() return DEFAULT_FONT end
),
fontSize = fontSize,
fontWeight = labels.weight or "normal",
color = __lor(
nil,
labels.color,
function() return "#8f95c4" end
),
align = horizontal and "center" or "right",
verticalAlign = "middle",
lineHeight = 1.3
}
)
step = step + 1
end
end
return nodes
end
function ____exports.buildRollingNumber(self, component, index)
local x = finite(nil, component.x, 0)
local y = finite(nil, component.y, 0)
local width = math.max(
0,
finite(nil, component.width, 160)
)
local height = math.max(
0,
finite(nil, component.height, 90)
)
local rotation = finite(nil, component.rotation, 0)
return {{
id = "widget-" .. component.id,
type = "rolling-number",
order = 10000 + index,
bounds = rotatedBounds(nil, {x = x, y = y, width = width, height = height}, rotation, 2),
x = x,
y = y,
width = width,
height = height,
rotation = rotation,
value = formatRollingNumber(nil, component.value, component.digits),
digits = component.digits,
duration = math.max(
0,
finite(nil, component.duration, 420)
),
label = component.label,
componentStyle = resolveRollingNumberStyle(nil, component.style)
}}
end
function ____exports.buildTickScale(self, component, index)
local x = finite(nil, component.x, 0)
local y = finite(nil, component.y, 0)
local width = math.max(
0,
finite(nil, component.width, 200)
)
local height = math.max(
0,
finite(nil, component.height, 200)
)
local rotation = finite(nil, component.rotation, 0)
local max = __lor(
nil,
finite(nil, component.max, 100),
function() return 100 end
)
local progress = math.min(
1,
math.max(
0,
finite(
nil,
__TS__Number(component.value),
0
) / max
)
)
local nodes = {{
id = "widget-" .. component.id,
type = "shader-surface",
order = 10000 + index,
bounds = rotatedBounds(nil, {x = x, y = y, width = width, height = height}, rotation, 2),
x = x,
y = y,
width = width,
height = height,
rotation = rotation,
shader = {
name = component.id,
program = "tickScale",
parameters = __TS__ObjectAssign({}, component.parameters, {progress = progress, max = max})
},
mask = "ellipse"
}}
if component.labels then
__TS__ArrayPushArray(
nodes,
buildTickLabels(nil, component, {
x = x,
y = y,
width = width,
height = height,
rotation = rotation,
max = max,
order = 10000 + index
})
)
end
return nodes
end
function ____exports.buildRuler(self, component, index)
local x = finite(nil, component.x, 0)
local y = finite(nil, component.y, 0)
local width = math.max(
0,
finite(nil, component.width, 120)
)
local height = math.max(
0,
finite(nil, component.height, 360)
)
local rotation = finite(nil, component.rotation, 0)
local min = finite(nil, component.min, 0)
local max = finite(nil, component.max, 100)
local progress = max == min and 0 or math.min(
1,
math.max(
0,
(finite(
nil,
__TS__Number(component.value),
min
) - min) / (max - min)
)
)
local nodes = {{
id = "widget-" .. component.id,
type = "shader-surface",
order = 10000 + index,
bounds = rotatedBounds(nil, {x = x, y = y, width = width, height = height}, rotation, 2),
x = x,
y = y,
width = width,
height = height,
rotation = rotation,
shader = {
name = component.id,
program = "ruler",
parameters = __TS__ObjectAssign({}, component.parameters, {progress = progress, min = min, max = max})
},
mask = "rect"
}}
if component.labels then
__TS__ArrayPushArray(
nodes,
buildRulerLabels(nil, component, {
x = x,
y = y,
width = width,
height = height,
min = min,
max = max,
order = 10000 + index
})
)
end
return nodes
end
return ____exports
end,
["core.renderScene.artifacts.component.controlParts"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local rotatedBounds = ____scene.rotatedBounds
local DISABLED_INK = "#94a3b8"
function ____exports.controlBox(self, component, index, fallback)
return {
x = finite(nil, component.x, 0),
y = finite(nil, component.y, 0),
width = math.max(
1,
finite(nil, component.width, fallback.width)
),
height = math.max(
1,
finite(nil, component.height, fallback.height)
),
order = 10000 + index
}
end
____exports.textProperty = function(____, component, key)
local ____component_properties_key_0 = component.properties[key]
if ____component_properties_key_0 == nil then
____component_properties_key_0 = ""
end
return tostring(____component_properties_key_0)
end
____exports.numberProperty = function(____, component, key)
local ____component_properties_key_1 = component.properties[key]
if ____component_properties_key_1 == nil then
____component_properties_key_1 = 0
end
return __TS__Number(____component_properties_key_1)
end
____exports.solid = function(____, color) return {kind = "solid", color = color} end
____exports.ink = function(____, component, color) return component.disabled and DISABLED_INK or color end
function ____exports.fade(self, component, style)
local ____component_properties_animate_2 = component.properties.animate
if ____component_properties_animate_2 == nil then
____component_properties_animate_2 = 0
end
local animate = __TS__Number(____component_properties_animate_2)
local shown = component.disabled and __TS__ObjectAssign({}, style, {opacity = 0.4}) or style
return animate > 0 and __TS__ObjectAssign({}, shown, {transition = animate}) or shown
end
function ____exports.hitArea(self, component, box, takesClicks)
if takesClicks == nil then
takesClicks = true
end
return {
id = "widget-" .. component.id,
type = "rect",
order = box.order,
bounds = rotatedBounds(nil, box, 0, 0),
x = box.x,
y = box.y,
width = box.width,
height = box.height,
style = {fill = {kind = "none"}, stroke = {kind = "none"}, pointerEvents = takesClicks and "all" or "none"}
}
end
function ____exports.labelText(self, component, part, area, label, order)
return {
id = (("widget-" .. component.id) .. "-") .. part,
type = "text",
order = order,
bounds = rotatedBounds(nil, area, 0, 0),
x = area.x,
y = area.y,
width = area.width,
height = area.height,
lines = {label.text},
fontFamily = DEFAULT_FONT,
fontSize = label.fontSize,
fontWeight = "600",
color = label.color,
align = label.align,
verticalAlign = "middle",
lineHeight = 1.3
}
end
return ____exports
end,
["core.renderScene.artifacts.component.button"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local ink = ____controlParts.ink
local labelText = ____controlParts.labelText
local numberProperty = ____controlParts.numberProperty
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
function ____exports.buildButton(self, component, index)
local box = controlBox(nil, component, index, {width = 120, height = 40})
local nodes = {
hitArea(nil, component, box),
{
id = ("widget-" .. component.id) .. "-face",
type = "rect",
order = box.order + 0.1,
bounds = rotatedBounds(nil, box, 0, 0),
x = box.x,
y = box.y,
width = box.width,
height = box.height,
rx = math.min(
numberProperty(nil, component, "radius"),
box.height / 2
),
style = fade(
nil,
component,
{
fill = solid(
nil,
textProperty(nil, component, "accent")
),
stroke = {kind = "none"}
}
)
}
}
if __t(nil, component.label) then
local label = {
text = component.label,
color = ink(
nil,
component,
textProperty(nil, component, "textColor")
),
fontSize = numberProperty(nil, component, "fontSize"),
align = "center"
}
nodes[#nodes + 1] = labelText(
nil,
component,
"label",
box,
label,
box.order + 0.2
)
end
return nodes
end
return ____exports
end,
["core.renderScene.artifacts.component.checkbox"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local ink = ____controlParts.ink
local labelText = ____controlParts.labelText
local numberProperty = ____controlParts.numberProperty
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
local CORNER_RATIO = 0.22
local LABEL_GAP_RATIO = 0.5
local CHECK_MARK = {{0.24, 0.52}, {0.43, 0.72}, {0.78, 0.3}}
local function checkPath(self, square)
local ____TS__ArrayMap_result_0 = __TS__ArrayMap(
CHECK_MARK,
function(____, ____bindingPattern0)
local v
local u
u = ____bindingPattern0[1]
v = ____bindingPattern0[2]
return (tostring(square.x + u * square.width) .. " ") .. tostring(square.y + v * square.width)
end
)
local first = ____TS__ArrayMap_result_0[1]
local rest = __TS__ArraySlice(____TS__ArrayMap_result_0, 1)
return (("M " .. first) .. " ") .. table.concat(
__TS__ArrayMap(
rest,
function(____, point) return "L " .. point end
),
" "
)
end
local function boxNode(self, component, box, square)
local on = component.value == true
return __TS__ObjectAssign(
{
id = ("widget-" .. component.id) .. "-box",
type = "rect",
order = box.order + 0.1,
bounds = rotatedBounds(nil, square, 0, 2)
},
square,
{
rx = square.width * CORNER_RATIO,
style = fade(
nil,
component,
{
fill = on and solid(
nil,
textProperty(nil, component, "accent")
) or ({kind = "none"}),
stroke = solid(
nil,
on and textProperty(nil, component, "accent") or textProperty(nil, component, "stroke")
),
strokeWidth = 1.5
}
)
}
)
end
local function checkNode(self, component, box, square)
return {
id = ("widget-" .. component.id) .. "-check",
type = "path",
order = box.order + 0.2,
bounds = rotatedBounds(nil, square, 0, 0),
d = checkPath(nil, square),
style = fade(
nil,
component,
{
fill = {kind = "none"},
stroke = solid(
nil,
textProperty(nil, component, "check")
),
strokeWidth = math.max(1.5, square.width * 0.12),
lineCap = "round",
lineJoin = "round"
}
)
}
end
local function labelNode(self, component, box, side, text)
local gap = side * LABEL_GAP_RATIO
local area = {
x = box.x + side + gap,
y = box.y,
width = math.max(0, box.width - side - gap),
height = box.height
}
local label = {
text = text,
color = ink(
nil,
component,
textProperty(nil, component, "textColor")
),
fontSize = numberProperty(nil, component, "fontSize"),
align = "left"
}
return labelText(
nil,
component,
"label",
area,
label,
box.order + 0.3
)
end
function ____exports.buildCheckbox(self, component, index)
local box = controlBox(nil, component, index, {width = 160, height = 24})
local side = math.min(box.height, box.width)
local square = {x = box.x, y = box.y + (box.height - side) / 2, width = side, height = side}
local ____array_1 = __TS__SparseArrayNew(
hitArea(nil, component, box),
boxNode(nil, component, box, square),
table.unpack(component.value == true and ({checkNode(nil, component, box, square)}) or ({}))
)
__TS__SparseArrayPush(
____array_1,
table.unpack(__t(nil, component.label) and ({labelNode(
nil,
component,
box,
side,
component.label
)}) or ({}))
)
return {__TS__SparseArraySpread(____array_1)}
end
return ____exports
end,
["core.renderScene.artifacts.component.hand"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__NumberToFixed = ____lualib.__TS__NumberToFixed
local __TS__Number = ____lualib.__TS__Number
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____color = require("core.model.color.index")
local parseHexRgb = ____color.parseHexRgb
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local numberProperty = ____controlParts.numberProperty
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
local MIN_TIP = 0.25
local function withAlpha(self, color, alpha)
local rgb = parseHexRgb(nil, color)
return rgb and alpha < 1 and ((((((("rgba(" .. tostring(rgb[1])) .. ", ") .. tostring(rgb[2])) .. ", ") .. tostring(rgb[3])) .. ", ") .. tostring(__TS__Number(__TS__NumberToFixed(alpha, 3)))) .. ")" or color
end
local function num(____, value)
return tostring(__TS__Number(__TS__NumberToFixed(value, 3)))
end
local function isOff(____, component, key)
return textProperty(nil, component, key) == "none"
end
local function colorOr(____, component, key, fallback)
return isOff(nil, component, key) and fallback or __lor(
nil,
textProperty(nil, component, key),
function() return fallback end
)
end
local function handOf(self, component, box)
local radius = math.min(box.width, box.height) / 2
local root = math.max(
0.5,
numberProperty(nil, component, "width")
)
local taper = math.min(
1,
math.max(
0,
numberProperty(nil, component, "taper")
)
)
return {
cx = box.x + box.width / 2,
cy = box.y + box.height / 2,
radius = radius,
length = math.max(
1,
numberProperty(nil, component, "length") * radius
),
tail = math.max(
0,
numberProperty(nil, component, "tail") * radius
),
gap = math.max(
0,
numberProperty(nil, component, "gap") * radius
),
rootHalf = root / 2,
tipHalf = math.max(MIN_TIP, root * taper / 2)
}
end
local function outline(self, ____bindingPattern0)
local tipHalf
local rootHalf
local gap
local tail
local length
local cy
local cx
cx = ____bindingPattern0.cx
cy = ____bindingPattern0.cy
length = ____bindingPattern0.length
tail = ____bindingPattern0.tail
gap = ____bindingPattern0.gap
rootHalf = ____bindingPattern0.rootHalf
tipHalf = ____bindingPattern0.tipHalf
local root = gap > 0 and cy - gap or cy
local back = gap > 0 and 0 or tail
local tipLeft = (("L" .. num(nil, cx - tipHalf)) .. " ") .. num(nil, cy - length)
local tip = (((((("A" .. num(nil, tipHalf)) .. " ") .. num(nil, tipHalf)) .. " 0 0 1 ") .. num(nil, cx + tipHalf)) .. " ") .. num(nil, cy - length)
local round = (((((("A" .. num(nil, rootHalf)) .. " ") .. num(nil, rootHalf)) .. " 0 0 1 ") .. num(nil, cx - rootHalf)) .. " ") .. num(nil, root + back)
if gap > 0 then
return (((((((((("M" .. num(nil, cx - rootHalf)) .. " ") .. num(nil, root)) .. tipLeft) .. tip) .. "L") .. num(nil, cx + rootHalf)) .. " ") .. num(nil, root)) .. round) .. "Z"
end
return table.concat(
{
(("M" .. num(nil, cx - rootHalf)) .. " ") .. num(nil, root + back),
(("L" .. num(nil, cx - rootHalf)) .. " ") .. num(nil, root),
tipLeft,
tip,
(("L" .. num(nil, cx + rootHalf)) .. " ") .. num(nil, root),
(("L" .. num(nil, cx + rootHalf)) .. " ") .. num(nil, root + back),
back > 0 and round or (("L" .. num(nil, cx - rootHalf)) .. " ") .. num(nil, root),
"Z"
},
""
)
end
local function shaped(self, hand, layer)
local rootHalf = hand.rootHalf * layer.scale
local tipHalf = layer.taper == nil and hand.tipHalf * layer.scale or rootHalf * layer.taper
return __TS__ObjectAssign(
{},
hand,
{
length = hand.length * (layer.length or 1),
rootHalf = rootHalf,
tipHalf = math.max(MIN_TIP, tipHalf)
}
)
end
local function stopsPaint(self, hand, stops, fadeOut, clear)
local tail = hand.gap > 0 and 0 or hand.tail
local function offset(____, along)
return (tail + along * hand.length) / (hand.length + tail) * 100
end
local ____, firstColor, firstAlpha = table.unpack(stops[1], 1, 3)
local ____temp_1 = -90
local ____array_0 = __TS__SparseArrayNew(table.unpack(tail > 0 and ({{
offset = 0,
color = withAlpha(nil, firstColor, firstAlpha * (clear and 0 or 1 - fadeOut))
}}) or ({})))
__TS__SparseArrayPush(
____array_0,
table.unpack(__TS__ArrayMap(
stops,
function(____, ____bindingPattern0, position)
local alpha
local color
local along
along = ____bindingPattern0[1]
color = ____bindingPattern0[2]
alpha = ____bindingPattern0[3]
return {
offset = offset(nil, along),
color = withAlpha(nil, color, clear and position == 0 and 0 or alpha)
}
end
))
)
return {
kind = "linear-gradient",
angle = ____temp_1,
stops = {__TS__SparseArraySpread(____array_0)}
}
end
local function plainPaint(self, hand, layer, fadeOut, tipFade)
if fadeOut <= 0 and tipFade <= 0 and not layer.clear then
return solid(nil, layer.color)
end
local ____temp_3 = -90
local ____array_2 = __TS__SparseArrayNew(
{
offset = 0,
color = withAlpha(nil, layer.root, layer.clear and 0 or 1 - fadeOut)
},
table.unpack(hand.gap == 0 and hand.tail > 0 and ({{offset = hand.tail / (hand.length + hand.tail) * 100, color = layer.root}}) or ({}))
)
__TS__SparseArrayPush(
____array_2,
{
offset = 100,
color = withAlpha(nil, layer.color, 1 - tipFade)
}
)
return {
kind = "linear-gradient",
angle = ____temp_3,
stops = {__TS__SparseArraySpread(____array_2)}
}
end
local function handLayer(self, component, box, base, angle, layer, order)
local hand = shaped(nil, base, layer)
local fadeOut = math.min(
1,
math.max(
0,
numberProperty(nil, component, "fade")
)
)
local tipFade = math.min(
1,
math.max(
0,
layer.tipFade or numberProperty(nil, component, "tipFade")
)
)
local glow = numberProperty(nil, component, "glow")
local soft = layer.blur > 0
local reach = math.max(hand.rootHalf, hand.tipHalf)
local near = hand.gap > 0 and -hand.gap or hand.tail
local extent = {x = hand.cx - reach, y = hand.cy - hand.length, width = reach * 2, height = hand.length + near}
return {
id = (("widget-" .. component.id) .. "-") .. layer.part,
type = "path",
order = box.order + order,
bounds = rotatedBounds(nil, extent, 0, 0),
d = outline(nil, hand),
rotation = angle,
rotationCenter = {x = hand.cx, y = hand.cy},
style = fade(
nil,
component,
__TS__ObjectAssign(
{
fill = layer.stops and stopsPaint(
nil,
hand,
layer.stops,
fadeOut,
Boolean(nil, layer.clear)
) or plainPaint(
nil,
hand,
layer,
fadeOut,
tipFade
),
stroke = {kind = "none"}
},
soft and ({blur = layer.blur, opacity = layer.opacity}) or ({}),
not soft and glow > 0 and not isOff(nil, component, "glowColor") and ({shadow = {
color = colorOr(nil, component, "glowColor", layer.color),
opacity = 1,
blur = glow,
dx = 0,
dy = 0
}}) or ({})
)
)
}
end
local function trailLayers(self, color, root, light, soft, clear, lit)
local trail = {{
part = "hand-light",
scale = 4.5,
length = 0.55,
taper = 0.15,
blur = soft * 3,
opacity = 1,
color = light,
root = light,
stops = {{0, light, 0.95}, {0.35, light, 0.45}, {1, light, 0}}
}, {
part = "hand-body",
scale = 1.6,
taper = 0.25,
blur = soft,
opacity = 1,
color = color,
root = root,
clear = clear,
stops = {{0, root, 1}, {0.18, color, 1}, {0.6, color, 0.55}, {1, color, 0}}
}, {
part = "hand",
scale = 0.55,
length = 0.8,
taper = 0.3,
blur = soft * 0.3,
opacity = 1,
color = root,
root = root,
clear = clear,
stops = {{0, root, 1}, {0.45, root, 0.6}, {1, root, 0}}
}}
return lit and trail or __TS__ArraySlice(trail, 1)
end
local function handLayers(self, component, box, hand, angle)
local color = textProperty(nil, component, "color")
local root = colorOr(nil, component, "root", color)
local light = colorOr(nil, component, "glowColor", color)
local lit = not isOff(nil, component, "glowColor")
local clear = isOff(nil, component, "root")
local soft = numberProperty(nil, component, "soft")
local bloom = numberProperty(nil, component, "bloom")
if soft > 0 then
return __TS__ArrayMap(
trailLayers(
nil,
color,
root,
light,
soft,
clear,
lit
),
function(____, layer, position) return handLayer(
nil,
component,
box,
hand,
angle,
layer,
0.26 + position * 0.02
) end
)
end
local ____array_4 = __TS__SparseArrayNew(table.unpack(bloom > 0 and lit and ({handLayer(
nil,
component,
box,
hand,
angle,
{
part = "hand-bloom",
scale = 4,
blur = bloom,
opacity = 0.9,
color = light,
root = light,
tipFade = 1
},
0.26
)}) or ({})))
__TS__SparseArrayPush(
____array_4,
handLayer(
nil,
component,
box,
hand,
angle,
{
part = "hand",
scale = 1,
blur = 0,
opacity = 1,
color = color,
root = root,
clear = clear
},
0.3
)
)
return {__TS__SparseArraySpread(____array_4)}
end
local function hubNode(self, component, box, hand, radius)
local ringWidth = numberProperty(nil, component, "hubRing")
return {
id = ("widget-" .. component.id) .. "-hub",
type = "ellipse",
order = box.order + 0.4,
bounds = rotatedBounds(nil, {x = hand.cx - radius, y = hand.cy - radius, width = radius * 2, height = radius * 2}, 0, ringWidth),
cx = hand.cx,
cy = hand.cy,
rx = math.max(0.5, radius - ringWidth / 2),
ry = math.max(0.5, radius - ringWidth / 2),
style = fade(
nil,
component,
__TS__ObjectAssign(
{
fill = isOff(nil, component, "hubFill") and ({kind = "none"}) or solid(
nil,
textProperty(nil, component, "hubFill")
),
stroke = ringWidth > 0 and solid(
nil,
textProperty(nil, component, "color")
) or ({kind = "none"}),
strokeWidth = ringWidth
},
numberProperty(nil, component, "glow") > 0 and not isOff(nil, component, "glowColor") and ({shadow = {
color = colorOr(
nil,
component,
"glowColor",
textProperty(nil, component, "color")
),
opacity = 1,
blur = numberProperty(nil, component, "glow"),
dx = 0,
dy = 0
}}) or ({})
)
)
}
end
local HIT_HALF = 8
local function pickNodes(self, component, box, hand, angle)
local reach = __TS__ObjectAssign(
{},
hand,
{
rootHalf = math.max(hand.rootHalf, HIT_HALF),
tipHalf = math.max(hand.tipHalf, HIT_HALF)
}
)
local near = reach.gap > 0 and -reach.gap or reach.tail
local extent = {x = reach.cx - HIT_HALF, y = reach.cy - reach.length, width = HIT_HALF * 2, height = reach.length + near}
return {
hitArea(nil, component, box, false),
{
id = ("widget-" .. component.id) .. "-pick",
type = "path",
order = box.order + 0.5,
bounds = rotatedBounds(nil, extent, 0, 0),
d = outline(nil, reach),
rotation = angle,
rotationCenter = {x = reach.cx, y = reach.cy},
style = {fill = {kind = "none"}, stroke = {kind = "none"}, pointerEvents = "all"}
}
}
end
function ____exports.buildHand(self, component, index)
local box = controlBox(nil, component, index, {width = 200, height = 200})
local hand = handOf(nil, component, box)
local max = __lor(
nil,
numberProperty(nil, component, "max"),
function() return 1 end
)
local angle = numberProperty(nil, component, "start") + __TS__Number(component.value) / max * 360
local hub = numberProperty(nil, component, "hub")
local ____array_5 = __TS__SparseArrayNew(table.unpack(pickNodes(
nil,
component,
box,
hand,
angle
)))
__TS__SparseArrayPush(
____array_5,
table.unpack(handLayers(
nil,
component,
box,
hand,
angle
))
)
__TS__SparseArrayPush(
____array_5,
table.unpack(hub > 0 and ({hubNode(
nil,
component,
box,
hand,
hub
)}) or ({}))
)
return {__TS__SparseArraySpread(____array_5)}
end
return ____exports
end,
["core.renderScene.artifacts.component.knob"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__Number = ____lualib.__TS__Number
local __TS__NumberToFixed = ____lualib.__TS__NumberToFixed
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local ink = ____controlParts.ink
local labelText = ____controlParts.labelText
local numberProperty = ____controlParts.numberProperty
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
local DOT_RATIO = 0.62
local function decimals(self, step)
local ____temp_2
if step > 0 then
local ____opt_0 = __TS__StringSplit(
tostring(step),
"."
)[2]
____temp_2 = ____opt_0 and #____opt_0 or 0
else
____temp_2 = 0
end
return ____temp_2
end
local function readout(self, component, fraction)
local display = textProperty(nil, component, "display")
if display == "percent" then
return tostring(math.floor(fraction * 100 + 0.5)) .. "%"
end
return display == "value" and __TS__NumberToFixed(
__TS__Number(component.value),
decimals(
nil,
numberProperty(nil, component, "step")
)
) or ""
end
local function dialOf(self, component, box)
local min = numberProperty(nil, component, "min")
local max = numberProperty(nil, component, "max")
local thickness = math.min(
numberProperty(nil, component, "thickness"),
math.min(box.width, box.height) / 3
)
local radius = math.max(
1,
math.min(box.width, box.height) / 2 - thickness / 2
)
return {
cx = box.x + box.width / 2,
cy = box.y + box.height / 2,
radius = radius,
thickness = thickness,
fraction = math.min(
1,
math.max(
0,
(__TS__Number(component.value) - min) / __lor(
nil,
max - min,
function() return 1 end
)
)
),
start = numberProperty(nil, component, "start"),
sweep = math.min(
360,
math.max(
1,
numberProperty(nil, component, "sweep")
)
),
circumference = 2 * math.pi * radius,
rounded = textProperty(nil, component, "rounded") ~= "false"
}
end
local function arcNode(self, component, box, dial, part, order, color, length, extra)
if extra == nil then
extra = {}
end
local ____dial_3 = dial
local cx = ____dial_3.cx
local cy = ____dial_3.cy
local radius = ____dial_3.radius
local thickness = ____dial_3.thickness
return {
id = (("widget-" .. component.id) .. "-") .. part,
type = "ellipse",
order = box.order + order,
bounds = rotatedBounds(nil, {x = cx - radius, y = cy - radius, width = radius * 2, height = radius * 2}, 0, thickness),
cx = cx,
cy = cy,
rx = radius,
ry = radius,
rotation = -dial.start,
style = fade(
nil,
component,
__TS__ObjectAssign(
{
fill = {kind = "none"},
stroke = solid(nil, color),
strokeWidth = thickness,
dash = {
math.max(0.001, length),
dial.circumference
},
lineCap = dial.rounded and "round" or "butt"
},
extra
)
)
}
end
local function discNode(self, component, box, part, order, center, radius, fill)
return {
id = (("widget-" .. component.id) .. "-") .. part,
type = "ellipse",
order = box.order + order,
bounds = rotatedBounds(nil, {x = center.x - radius, y = center.y - radius, width = radius * 2, height = radius * 2}, 0, 0),
cx = center.x,
cy = center.y,
rx = radius,
ry = radius,
style = fade(
nil,
component,
{
fill = solid(nil, fill),
stroke = {kind = "none"}
}
)
}
end
function ____exports.buildKnob(self, component, index)
local box = controlBox(nil, component, index, {width = 96, height = 96})
local dial = dialOf(nil, component, box)
local cx = dial.cx
local cy = dial.cy
local radius = dial.radius
local thickness = dial.thickness
local fraction = dial.fraction
local sweep = dial.sweep
local circumference = dial.circumference
local angle = (dial.start - fraction * sweep) * math.pi / 180
local faceRadius = math.max(
1,
radius - thickness / 2 - math.max(2, thickness * 0.4)
)
local dotRadius = thickness / 2 * DOT_RATIO + 1
local nodes = {
hitArea(nil, component, box),
arcNode(
nil,
component,
box,
dial,
"track",
0.1,
textProperty(nil, component, "track"),
sweep / 360 * circumference
),
arcNode(
nil,
component,
box,
dial,
"fill",
0.2,
textProperty(nil, component, "accent"),
fraction * sweep / 360 * circumference,
{opacity = fraction > 0 and 1 or 0}
),
discNode(
nil,
component,
box,
"face",
0.3,
{x = cx, y = cy},
faceRadius,
textProperty(nil, component, "face")
),
discNode(
nil,
component,
box,
"dot",
0.4,
{
x = cx + radius * math.cos(angle),
y = cy - radius * math.sin(angle)
},
dotRadius,
textProperty(nil, component, "dot")
)
}
local text = readout(nil, component, fraction)
if __t(nil, text) then
local label = {
text = text,
color = ink(
nil,
component,
textProperty(nil, component, "textColor")
),
fontSize = numberProperty(nil, component, "fontSize"),
align = "center"
}
nodes[#nodes + 1] = labelText(
nil,
component,
"value",
{x = cx - faceRadius, y = cy - faceRadius, width = faceRadius * 2, height = faceRadius * 2},
label,
box.order + 0.5
)
end
return nodes
end
return ____exports
end,
["core.renderScene.artifacts.component.progress"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local ink = ____controlParts.ink
local labelText = ____controlParts.labelText
local numberProperty = ____controlParts.numberProperty
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
local function readout(self, component, fraction)
local display = textProperty(nil, component, "display")
if display == "percent" then
return tostring(math.floor(fraction * 100 + 0.5)) .. "%"
end
return display == "value" and tostring(__TS__Number(component.value)) or ""
end
local function buildRing(self, component, box, fraction, round)
local thickness = math.min(
numberProperty(nil, component, "thickness"),
math.min(box.width, box.height) / 2
)
local radius = math.max(
1,
math.min(box.width, box.height) / 2 - thickness / 2
)
local circumference = 2 * math.pi * radius
local cx = box.x + box.width / 2
local cy = box.y + box.height / 2
local function ring(____, part, order, color, extra)
return {
id = (("widget-" .. component.id) .. "-") .. part,
type = "ellipse",
order = box.order + order,
bounds = rotatedBounds(nil, {x = cx - radius, y = cy - radius, width = radius * 2, height = radius * 2}, 0, thickness),
cx = cx,
cy = cy,
rx = radius,
ry = radius,
rotation = -90,
style = fade(
nil,
component,
__TS__ObjectAssign(
{
fill = {kind = "none"},
stroke = solid(nil, color),
strokeWidth = thickness
},
extra
)
)
}
end
return {
ring(
nil,
"track",
0.1,
textProperty(nil, component, "track"),
{}
),
ring(
nil,
"fill",
0.2,
textProperty(nil, component, "accent"),
{
dash = {
math.max(0.001, fraction * circumference),
circumference
},
lineCap = round and "round" or "butt",
opacity = fraction > 0 and 1 or 0
}
)
}
end
local function buildBar(self, component, box, fraction, round)
local vertical = textProperty(nil, component, "direction") == "vertical"
local radius = round and (vertical and box.width or box.height) / 2 or 0
local function bar(____, part, order, length, color, opacity)
local shape = vertical and ({x = box.x, y = box.y + box.height - length, width = box.width, height = length}) or ({x = box.x, y = box.y, width = length, height = box.height})
return __TS__ObjectAssign(
{
id = (("widget-" .. component.id) .. "-") .. part,
type = "rect",
order = box.order + order,
bounds = rotatedBounds(nil, shape, 0, 0)
},
shape,
{
rx = radius,
style = fade(
nil,
component,
__TS__ObjectAssign(
{
fill = solid(nil, color),
stroke = {kind = "none"}
},
opacity == nil and ({}) or ({opacity = opacity})
)
)
}
)
end
local full = vertical and box.height or box.width
return {
bar(
nil,
"track",
0.1,
full,
textProperty(nil, component, "track")
),
bar(
nil,
"fill",
0.2,
math.max(0, fraction * full),
textProperty(nil, component, "accent"),
fraction > 0 and 1 or 0
)
}
end
function ____exports.buildProgress(self, component, index)
local box = controlBox(nil, component, index, {width = 220, height = 12})
local min = numberProperty(nil, component, "min")
local max = numberProperty(nil, component, "max")
local fraction = math.min(
1,
math.max(
0,
(__TS__Number(component.value) - min) / __lor(
nil,
max - min,
function() return 1 end
)
)
)
local round = textProperty(nil, component, "rounded") ~= "false"
local nodes = {
hitArea(nil, component, box),
table.unpack(textProperty(nil, component, "variant") == "ring" and buildRing(
nil,
component,
box,
fraction,
round
) or buildBar(
nil,
component,
box,
fraction,
round
))
}
local text = readout(nil, component, fraction)
if __t(nil, text) then
local label = {
text = text,
color = ink(
nil,
component,
textProperty(nil, component, "textColor")
),
fontSize = numberProperty(nil, component, "fontSize"),
align = "center"
}
nodes[#nodes + 1] = labelText(
nil,
component,
"value",
box,
label,
box.order + 0.3
)
end
return nodes
end
return ____exports
end,
["core.renderScene.artifacts.component.segmented"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringTrim = ____lualib.__TS__StringTrim
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__Number = ____lualib.__TS__Number
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local ink = ____controlParts.ink
local labelText = ____controlParts.labelText
local numberProperty = ____controlParts.numberProperty
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
function ____exports.buildSegmented(self, component, index)
local box = controlBox(nil, component, index, {width = 300, height = 40})
local options = __TS__ArrayFilter(
__TS__ArrayMap(
__TS__StringSplit(
textProperty(nil, component, "options"),
","
),
function(____, option) return __TS__StringTrim(option) end
),
Boolean
)
local count = math.max(1, #options)
local active = math.min(
count - 1,
math.max(
0,
__lor(
nil,
math.floor(__TS__Number(component.value) + 0.5),
function() return 0 end
)
)
)
local inset = math.min(
numberProperty(nil, component, "inset"),
box.height / 2
)
local radius = math.min(
numberProperty(nil, component, "radius"),
box.height / 2
)
local cellWidth = (box.width - inset * 2) / count
local cell = {y = box.y + inset, height = box.height - inset * 2}
local nodes = {
hitArea(nil, component, box),
{
id = ("widget-" .. component.id) .. "-track",
type = "rect",
order = box.order + 0.1,
bounds = rotatedBounds(nil, box, 0, 0),
x = box.x,
y = box.y,
width = box.width,
height = box.height,
rx = radius,
style = fade(
nil,
component,
{
fill = solid(
nil,
textProperty(nil, component, "track")
),
stroke = {kind = "none"}
}
)
},
{
id = ("widget-" .. component.id) .. "-active",
type = "rect",
order = box.order + 0.2,
bounds = rotatedBounds(
nil,
__TS__ObjectAssign({x = box.x + inset + active * cellWidth, width = cellWidth}, cell),
0,
0
),
x = box.x + inset + active * cellWidth,
y = cell.y,
width = cellWidth,
height = cell.height,
rx = math.max(0, radius - inset),
style = fade(
nil,
component,
{
fill = solid(
nil,
textProperty(nil, component, "accent")
),
stroke = {kind = "none"},
shadow = {
color = "#000000",
opacity = 0.18,
blur = 3,
dx = 0,
dy = 1
}
}
)
}
}
__TS__ArrayForEach(
options,
function(____, option, position)
local area = __TS__ObjectAssign({x = box.x + inset + position * cellWidth, width = cellWidth}, cell)
local color = ink(
nil,
component,
textProperty(nil, component, position == active and "activeTextColor" or "textColor")
)
nodes[#nodes + 1] = labelText(
nil,
component,
"option-" .. tostring(position),
area,
{
text = option,
color = color,
fontSize = numberProperty(nil, component, "fontSize"),
align = "center"
},
box.order + 0.3
)
end
)
return nodes
end
return ____exports
end,
["core.model.component.sliderReach"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.sliderReach(self, variant, height)
return variant == "field" and math.min(8, height / 2) or height / 2
end
return ____exports
end,
["core.renderScene.artifacts.component.slider"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__NumberToFixed = ____lualib.__TS__NumberToFixed
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__Number = ____lualib.__TS__Number
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____sliderReach = require("core.model.component.sliderReach")
local sliderReach = ____sliderReach.sliderReach
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local ink = ____controlParts.ink
local labelText = ____controlParts.labelText
local numberProperty = ____controlParts.numberProperty
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
local HANDLE_WIDTH = 4
local TEXT_PADDING = 12
local TICK_LENGTH = 5
local TICK_THICKNESS = 1.5
local function decimals(self, step)
local ____temp_2
if step > 0 then
local ____opt_0 = __TS__StringSplit(
tostring(step),
"."
)[2]
____temp_2 = ____opt_0 and #____opt_0 or 0
else
____temp_2 = 0
end
return ____temp_2
end
local function readout(self, component, thumbs)
local display = textProperty(nil, component, "display")
local places = decimals(
nil,
numberProperty(nil, component, "step")
)
local parts = display == "percent" and (thumbs.two and __TS__ArrayMap(
{thumbs.from, thumbs.to},
function(____, fraction) return tostring(math.floor(fraction * 100 + 0.5)) .. "%" end
) or ({tostring(math.floor(thumbs.to * 100 + 0.5)) .. "%"})) or (display == "value" and __TS__ArrayMap(
thumbs.values,
function(____, value) return __TS__NumberToFixed(value, places) end
) or ({}))
return table.concat(parts, " – ")
end
local function rect(____, component, box, part, order, shape, color, extra)
if extra == nil then
extra = {}
end
return __TS__ObjectAssign(
{
id = (("widget-" .. component.id) .. "-") .. part,
type = "rect",
order = box.order + order,
bounds = rotatedBounds(nil, shape, 0, 0)
},
shape,
{style = fade(
nil,
component,
__TS__ObjectAssign(
{
fill = solid(nil, color),
stroke = {kind = "none"}
},
extra
)
)}
)
end
local function ticks(self, component, box, vertical, reach, offset)
local count = math.floor(numberProperty(nil, component, "ticks") + 0.5)
local color = textProperty(nil, component, "tickColor")
return __TS__ArrayFrom(
{length = count >= 2 and count or 0},
function(____, _, index)
local t = index / (count - 1)
local shape = vertical and ({
x = box.x + offset,
y = box.y + box.height - reach - t * (box.height - reach * 2) - TICK_THICKNESS / 2,
width = TICK_LENGTH,
height = TICK_THICKNESS,
rx = TICK_THICKNESS / 2
}) or ({
x = box.x + reach + t * (box.width - reach * 2) - TICK_THICKNESS / 2,
y = box.y + offset,
width = TICK_THICKNESS,
height = TICK_LENGTH,
rx = TICK_THICKNESS / 2
})
return rect(
nil,
component,
box,
"tick-" .. tostring(index),
0.15,
shape,
color
)
end
)
end
local function alongOf(self, box, reach, vertical)
return function(____, fraction) return vertical and box.y + box.height - reach - fraction * (box.height - reach * 2) or box.x + reach + fraction * (box.width - reach * 2) end
end
local function buildLine(self, component, box, thumbs, vertical)
local reach = sliderReach(nil, "line", vertical and box.width or box.height)
local radius = reach * numberProperty(nil, component, "thumbSize") / 100
local thickness = math.min(
numberProperty(nil, component, "trackHeight"),
vertical and box.width or box.height
)
local mid = vertical and box.x + box.width / 2 or box.y + box.height / 2
local along = alongOf(nil, box, reach, vertical)
local function line(____, start, ____end)
return vertical and ({
x = mid - thickness / 2,
y = math.min(start, ____end),
width = thickness,
height = math.abs(____end - start),
rx = thickness / 2
}) or ({
x = math.min(start, ____end),
y = mid - thickness / 2,
width = math.abs(____end - start),
height = thickness,
rx = thickness / 2
})
end
local whole = vertical and line(nil, box.y, box.y + box.height) or line(nil, box.x, box.x + box.width)
local filled = line(
nil,
thumbs.two and along(nil, thumbs.from) or (vertical and box.y + box.height or box.x),
along(nil, thumbs.to)
)
local function thumb(____, part, fraction, order)
local cx = vertical and mid or along(nil, fraction)
local cy = vertical and along(nil, fraction) or mid
return {
id = (("widget-" .. component.id) .. "-") .. part,
type = "ellipse",
order = box.order + order,
bounds = rotatedBounds(nil, {x = cx - radius, y = cy - radius, width = radius * 2, height = radius * 2}, 0, 0),
cx = cx,
cy = cy,
rx = radius,
ry = radius,
style = fade(
nil,
component,
{
fill = solid(
nil,
textProperty(nil, component, "thumb")
),
stroke = {kind = "none"},
shadow = {
color = "#000000",
opacity = 0.25,
blur = 3,
dx = 0,
dy = 1
}
}
)
}
end
local ____array_3 = __TS__SparseArrayNew(
rect(
nil,
component,
box,
"track",
0.1,
whole,
textProperty(nil, component, "track")
),
table.unpack(ticks(
nil,
component,
box,
vertical,
reach,
vertical and box.width / 2 + thickness / 2 + 5 or box.height / 2 + thickness / 2 + 5
))
)
__TS__SparseArrayPush(
____array_3,
rect(
nil,
component,
box,
"fill",
0.2,
filled,
textProperty(nil, component, "accent")
),
table.unpack(thumbs.two and ({thumb(nil, "thumb-start", thumbs.from, 0.3)}) or ({}))
)
__TS__SparseArrayPush(
____array_3,
thumb(nil, thumbs.two and "thumb-end" or "thumb", thumbs.to, 0.31)
)
return {__TS__SparseArraySpread(____array_3)}
end
local function fieldFill(self, whole, box, thumbs, vertical, start, ____end)
local first = math.min(start, ____end) - (thumbs.two and HANDLE_WIDTH / 2 or 0)
local last = math.max(start, ____end) + HANDLE_WIDTH / 2
return vertical and __TS__ObjectAssign(
{},
whole,
{
y = thumbs.two and first or ____end - HANDLE_WIDTH / 2,
height = thumbs.two and last - first or math.max(0, box.y + box.height - ____end + HANDLE_WIDTH / 2),
rx = thumbs.two and 0 or whole.rx
}
) or __TS__ObjectAssign(
{},
whole,
{
x = thumbs.two and first or box.x,
width = thumbs.two and last - first or math.max(0, ____end + HANDLE_WIDTH / 2 - box.x),
rx = thumbs.two and 0 or whole.rx
}
)
end
local function fieldHandle(self, component, box, vertical, part, at)
local handleLength = (vertical and box.width or box.height) * 0.5
local shape = vertical and ({
x = box.x + (box.width - handleLength) / 2,
y = at - HANDLE_WIDTH / 2,
width = handleLength,
height = HANDLE_WIDTH,
rx = HANDLE_WIDTH / 2
}) or ({
x = at - HANDLE_WIDTH / 2,
y = box.y + (box.height - handleLength) / 2,
width = HANDLE_WIDTH,
height = handleLength,
rx = HANDLE_WIDTH / 2
})
return rect(
nil,
component,
box,
part,
0.3,
shape,
textProperty(nil, component, "accent")
)
end
local function fieldTexts(self, component, box, thumbs, vertical)
local text = {
color = ink(
nil,
component,
textProperty(nil, component, "textColor")
),
fontSize = numberProperty(nil, component, "fontSize")
}
local value = readout(nil, component, thumbs)
if vertical then
return __t(nil, value) and ({labelText(
nil,
component,
"value",
{x = box.x, y = box.y + 6, width = box.width, height = 20},
__TS__ObjectAssign({}, text, {text = value, align = "center"}),
box.order + 0.4
)}) or ({})
end
local inner = {
y = box.y,
height = box.height,
width = math.max(0, box.width / 2 - TEXT_PADDING)
}
local nodes = {}
if __t(nil, component.label) then
nodes[#nodes + 1] = labelText(
nil,
component,
"label",
__TS__ObjectAssign({x = box.x + TEXT_PADDING}, inner),
__TS__ObjectAssign({}, text, {text = component.label, align = "left"}),
box.order + 0.4
)
end
if __t(nil, value) then
nodes[#nodes + 1] = labelText(
nil,
component,
"value",
__TS__ObjectAssign({x = box.x + box.width / 2}, inner),
__TS__ObjectAssign({}, text, {text = value, align = "right"}),
box.order + 0.4
)
end
return nodes
end
local function buildField(self, component, box, thumbs, vertical)
local reach = sliderReach(nil, "field", vertical and box.width or box.height)
local radius = math.min(
numberProperty(nil, component, "radius"),
math.min(box.width, box.height) / 2
)
local whole = {
x = box.x,
y = box.y,
width = box.width,
height = box.height,
rx = radius
}
local along = alongOf(nil, box, reach, vertical)
local start = thumbs.two and along(nil, thumbs.from) or (vertical and box.y + box.height or box.x)
local ____end = along(nil, thumbs.to)
local ____array_4 = __TS__SparseArrayNew(
rect(
nil,
component,
box,
"track",
0.1,
whole,
textProperty(nil, component, "surface")
),
rect(
nil,
component,
box,
"fill",
0.2,
fieldFill(
nil,
whole,
box,
thumbs,
vertical,
start,
____end
),
textProperty(nil, component, "fill")
),
table.unpack(thumbs.two and ({fieldHandle(
nil,
component,
box,
vertical,
"handle-start",
start
)}) or ({}))
)
__TS__SparseArrayPush(
____array_4,
fieldHandle(
nil,
component,
box,
vertical,
thumbs.two and "handle-end" or "handle",
____end
),
table.unpack(fieldTexts(
nil,
component,
box,
thumbs,
vertical
))
)
__TS__SparseArrayPush(
____array_4,
table.unpack(vertical and ({}) or ticks(
nil,
component,
box,
false,
reach,
box.height - TICK_LENGTH - 5
))
)
return {__TS__SparseArraySpread(____array_4)}
end
function ____exports.buildSlider(self, component, index)
local field = textProperty(nil, component, "variant") == "field"
local vertical = textProperty(nil, component, "direction") == "vertical"
local fallback = vertical and ({width = field and 56 or 28, height = 180}) or ({width = 220, height = field and 36 or 28})
local box = controlBox(nil, component, index, fallback)
local min = numberProperty(nil, component, "min")
local max = numberProperty(nil, component, "max")
local function fractionOf(____, value)
return math.min(
1,
math.max(
0,
(value - min) / __lor(
nil,
max - min,
function() return 1 end
)
)
)
end
local two = component.type == "range"
local low = __TS__Number(component.value)
local ____two_6
if two then
local ____component_properties_valueEnd_5 = component.properties.valueEnd
if ____component_properties_valueEnd_5 == nil then
____component_properties_valueEnd_5 = max
end
____two_6 = __TS__Number(____component_properties_valueEnd_5)
else
____two_6 = low
end
local high = ____two_6
local thumbs = {
from = fractionOf(
nil,
two and math.min(low, high) or min
),
to = fractionOf(
nil,
two and math.max(low, high) or low
),
values = two and ({
math.min(low, high),
math.max(low, high)
}) or ({low}),
two = two
}
return {
hitArea(nil, component, box),
table.unpack(field and buildField(
nil,
component,
box,
thumbs,
vertical
) or buildLine(
nil,
component,
box,
thumbs,
vertical
))
}
end
return ____exports
end,
["core.renderScene.artifacts.component.switch"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
local PADDING_RATIO = 0.12
function ____exports.buildSwitch(self, component, index)
local box = controlBox(nil, component, index, {width = 52, height = 30})
local on = component.value == true
local padding = box.height * PADDING_RATIO
local radius = box.height / 2 - padding
local centerX = on and box.x + box.width - box.height / 2 or box.x + box.height / 2
local thumb = {x = centerX - radius, y = box.y + padding, width = radius * 2, height = radius * 2}
return {
hitArea(nil, component, box),
{
id = ("widget-" .. component.id) .. "-track",
type = "rect",
order = box.order + 0.1,
bounds = rotatedBounds(nil, box, 0, 0),
x = box.x,
y = box.y,
width = box.width,
height = box.height,
rx = box.height / 2,
style = fade(
nil,
component,
{
fill = solid(
nil,
textProperty(nil, component, on and "accent" or "track")
),
stroke = {kind = "none"}
}
)
},
{
id = ("widget-" .. component.id) .. "-thumb",
type = "ellipse",
order = box.order + 0.2,
bounds = rotatedBounds(nil, thumb, 0, 0),
cx = centerX,
cy = box.y + box.height / 2,
rx = radius,
ry = radius,
style = fade(
nil,
component,
{
fill = solid(
nil,
textProperty(nil, component, "thumb")
),
stroke = {kind = "none"},
shadow = {
color = "#000000",
opacity = 0.25,
blur = 2,
dx = 0,
dy = 1
}
}
)
}
}
end
return ____exports
end,
["core.renderScene.artifacts.component.textField"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local ink = ____controlParts.ink
local labelText = ____controlParts.labelText
local numberProperty = ____controlParts.numberProperty
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
local LINE_WIDTH = 1.5
local AVERAGE_LETTER = 0.56
local function shownValue(self, component, room)
local ____component_value_0 = component.value
if ____component_value_0 == nil then
____component_value_0 = ""
end
local value = tostring(____component_value_0)
local text = component.properties.format == "password" and string.rep(
"•",
math.floor(#({__TS__Spread(value)}))
) or value
local fits = math.max(
1,
math.floor(room / (numberProperty(nil, component, "fontSize") * AVERAGE_LETTER))
)
local letters = {__TS__Spread(text)}
return #letters > fits and "…" .. table.concat(
__TS__ArraySlice(letters, 1 - fits),
""
) or text
end
function ____exports.buildTextField(self, component, index)
local box = controlBox(nil, component, index, {width = 240, height = 44})
local focused = component.properties.focused == true
local stroke = textProperty(nil, component, focused and "accent" or "stroke")
local line = component.properties.variant == "line"
local fill = textProperty(nil, component, "fill")
local face = line and __TS__ObjectAssign({}, box, {y = box.y + box.height - LINE_WIDTH, height = LINE_WIDTH}) or box
local nodes = {
hitArea(nil, component, box),
{
id = ("widget-" .. component.id) .. "-face",
type = "rect",
order = box.order + 0.1,
bounds = rotatedBounds(nil, face, 0, 0),
x = face.x,
y = face.y,
width = face.width,
height = face.height,
rx = line and 0 or math.min(
numberProperty(nil, component, "radius"),
box.height / 2
),
style = fade(
nil,
component,
line and ({
fill = solid(nil, stroke),
stroke = {kind = "none"}
}) or ({
fill = fill == "none" and ({kind = "none"}) or solid(nil, fill),
stroke = solid(nil, stroke),
strokeWidth = focused and 2 or 1
})
)
}
}
local padding = numberProperty(nil, component, "padding")
local area = {
x = box.x + padding,
y = box.y,
width = math.max(1, box.width - padding * 2),
height = box.height
}
local value = shownValue(nil, component, area.width)
if not focused and __t(nil, value) then
local color = ink(
nil,
component,
textProperty(nil, component, "textColor")
)
local fontSize = numberProperty(nil, component, "fontSize")
local label = {text = value, color = color, fontSize = fontSize, align = "left"}
nodes[#nodes + 1] = __TS__ObjectAssign(
{},
labelText(
nil,
component,
"value",
area,
label,
box.order + 0.2
),
{fontWeight = "400"}
)
elseif not __t(nil, value) and not focused then
local color = textProperty(nil, component, "placeholderColor")
local fontSize = numberProperty(nil, component, "fontSize")
local label = {
text = textProperty(nil, component, "placeholder"),
color = color,
fontSize = fontSize,
align = "left"
}
if __t(nil, label.text) then
nodes[#nodes + 1] = __TS__ObjectAssign(
{},
labelText(
nil,
component,
"value",
area,
label,
box.order + 0.2
),
{fontWeight = "400"}
)
end
end
return nodes
end
return ____exports
end,
["core.renderScene.artifacts.component.toggleButton"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local rotatedBounds = ____scene.rotatedBounds
local ____controlParts = require("core.renderScene.artifacts.component.controlParts")
local controlBox = ____controlParts.controlBox
local fade = ____controlParts.fade
local hitArea = ____controlParts.hitArea
local ink = ____controlParts.ink
local labelText = ____controlParts.labelText
local numberProperty = ____controlParts.numberProperty
local solid = ____controlParts.solid
local textProperty = ____controlParts.textProperty
function ____exports.buildToggleButton(self, component, index)
local box = controlBox(nil, component, index, {width = 120, height = 40})
local on = component.value == true
local nodes = {
hitArea(nil, component, box),
{
id = ("widget-" .. component.id) .. "-face",
type = "rect",
order = box.order + 0.1,
bounds = rotatedBounds(nil, box, 0, 2),
x = box.x,
y = box.y,
width = box.width,
height = box.height,
rx = box.height / 2,
style = fade(
nil,
component,
{
fill = on and solid(
nil,
textProperty(nil, component, "accent")
) or ({kind = "none"}),
stroke = solid(
nil,
on and textProperty(nil, component, "accent") or textProperty(nil, component, "stroke")
),
strokeWidth = 1.5
}
)
}
}
if __t(nil, component.label) then
local label = {
text = component.label,
color = ink(
nil,
component,
textProperty(nil, component, on and "onTextColor" or "textColor")
),
fontSize = numberProperty(nil, component, "fontSize"),
align = "center"
}
nodes[#nodes + 1] = labelText(
nil,
component,
"label",
box,
label,
box.order + 0.2
)
end
return nodes
end
return ____exports
end,
["core.renderScene.artifacts.component.registry"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____builtIn = require("core.renderScene.artifacts.component.builtIn")
local buildRollingNumber = ____builtIn.buildRollingNumber
local buildRuler = ____builtIn.buildRuler
local buildTickScale = ____builtIn.buildTickScale
local ____button = require("core.renderScene.artifacts.component.button")
local buildButton = ____button.buildButton
local ____checkbox = require("core.renderScene.artifacts.component.checkbox")
local buildCheckbox = ____checkbox.buildCheckbox
local ____hand = require("core.renderScene.artifacts.component.hand")
local buildHand = ____hand.buildHand
local ____knob = require("core.renderScene.artifacts.component.knob")
local buildKnob = ____knob.buildKnob
local ____progress = require("core.renderScene.artifacts.component.progress")
local buildProgress = ____progress.buildProgress
local ____segmented = require("core.renderScene.artifacts.component.segmented")
local buildSegmented = ____segmented.buildSegmented
local ____slider = require("core.renderScene.artifacts.component.slider")
local buildSlider = ____slider.buildSlider
local ____switch = require("core.renderScene.artifacts.component.switch")
local buildSwitch = ____switch.buildSwitch
local ____textField = require("core.renderScene.artifacts.component.textField")
local buildTextField = ____textField.buildTextField
local ____toggleButton = require("core.renderScene.artifacts.component.toggleButton")
local buildToggleButton = ____toggleButton.buildToggleButton
local function asComponentBuilder(____, build)
return function(____, component, index) return build(nil, component, index) end
end
local builders = __TS__New(
Map,
{
{
"rollingNumber",
asComponentBuilder(nil, buildRollingNumber)
},
{
"tickScale",
asComponentBuilder(nil, buildTickScale)
},
{
"ruler",
asComponentBuilder(nil, buildRuler)
},
{
"switch",
asComponentBuilder(nil, buildSwitch)
},
{
"checkbox",
asComponentBuilder(nil, buildCheckbox)
},
{
"toggleButton",
asComponentBuilder(nil, buildToggleButton)
},
{
"button",
asComponentBuilder(nil, buildButton)
},
{
"slider",
asComponentBuilder(nil, buildSlider)
},
{
"textField",
asComponentBuilder(nil, buildTextField)
},
{
"progress",
asComponentBuilder(nil, buildProgress)
},
{
"segmented",
asComponentBuilder(nil, buildSegmented)
},
{
"knob",
asComponentBuilder(nil, buildKnob)
},
{
"hand",
asComponentBuilder(nil, buildHand)
},
{
"range",
asComponentBuilder(nil, buildSlider)
}
}
)
function ____exports.registerComponentBuilder(self, ____type, builder)
builders:set(____type, builder)
return function()
if builders:get(____type) == builder then
builders:delete(____type)
end
end
end
function ____exports.getComponentBuilder(self, ____type)
return builders:get(____type)
end
return ____exports
end,
["core.renderScene.artifacts.component.build"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____component = require("core.model.component.index")
local getComponentDescriptor = ____component.getComponentDescriptor
local isGenericComponent = ____component.isGenericComponent
local ____tagging = require("core.renderScene.scene.tagging")
local tag = ____tagging.tag
local ____placeholder = require("core.renderScene.artifacts.component.placeholder")
local buildPlaceholder = ____placeholder.buildPlaceholder
local ____registry = require("core.renderScene.artifacts.component.registry")
local getComponentBuilder = ____registry.getComponentBuilder
local function ariaOf(self, component)
local ____opt_0 = getComponentDescriptor(nil, component.type)
local role = ____opt_0 and ____opt_0.role
if not __t(nil, role) or not isGenericComponent(nil, component) then
return nil
end
local ____temp_2
if type(component.value) == "boolean" then
____temp_2 = component.value
else
____temp_2 = nil
end
local flag = ____temp_2
return __TS__ObjectAssign({role = role}, flag == nil and ({}) or (role == "button" and ({pressed = flag}) or ({checked = flag})), component.disabled and ({disabled = true}) or ({}))
end
local function labelOf(self, component)
return component.label or (isGenericComponent(nil, component) and component.id or tostring(component.value))
end
function ____exports.buildComponents(self, components)
return __TS__ArrayFlatMap(
components,
function(____, component, index)
if isGenericComponent(nil, component) and component.isVisible == false then
return {}
end
local build = getComponentBuilder(nil, component.type) or buildPlaceholder
local nodes = tag(
nil,
build(nil, component, index),
"widget",
component.id,
component.type,
labelOf(nil, component),
component.parentFrameId
)
local aria = ariaOf(nil, component)
local primary = __TS__ArrayFind(
nodes,
function(____, node)
local ____opt_3 = node.identity
return ____opt_3 and ____opt_3.primary
end
)
if aria and (primary and primary.identity) then
primary.identity.aria = aria
end
return nodes
end
)
end
return ____exports
end,
["core.renderScene.artifacts.component.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____build = require("core.renderScene.artifacts.component.build")
____exports.buildComponents = ____build.buildComponents
end
do
local ____registry = require("core.renderScene.artifacts.component.registry")
____exports.getComponentBuilder = ____registry.getComponentBuilder
____exports.registerComponentBuilder = ____registry.registerComponentBuilder
end
return ____exports
end,
["core.renderScene.scene.roundedRectPath"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.topRoundedRectPath(self, x, y, width, height, radius)
local clampedRadius = math.max(
0,
math.min(radius, width / 2, height)
)
if clampedRadius == 0 then
return ((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width)) .. " V ") .. tostring(y + height)) .. " H ") .. tostring(x)) .. " Z"
end
return ((((((((((((((((((((((((("M " .. tostring(x)) .. " ") .. tostring(y + clampedRadius)) .. " A ") .. tostring(clampedRadius)) .. " ") .. tostring(clampedRadius)) .. " 0 0 1 ") .. tostring(x + clampedRadius)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width - clampedRadius)) .. " A ") .. tostring(clampedRadius)) .. " ") .. tostring(clampedRadius)) .. " 0 0 1 ") .. tostring(x + width)) .. " ") .. tostring(y + clampedRadius)) .. " V ") .. tostring(y + height)) .. " H ") .. tostring(x)) .. " Z"
end
function ____exports.bottomRoundedRectPath(self, x, y, width, height, radius)
local clampedRadius = math.max(
0,
math.min(radius, width / 2, height)
)
if clampedRadius == 0 then
return ((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width)) .. " V ") .. tostring(y + height)) .. " H ") .. tostring(x)) .. " Z"
end
return ((((((((((((((((((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width)) .. " V ") .. tostring(y + height - clampedRadius)) .. " A ") .. tostring(clampedRadius)) .. " ") .. tostring(clampedRadius)) .. " 0 0 1 ") .. tostring(x + width - clampedRadius)) .. " ") .. tostring(y + height)) .. " H ") .. tostring(x + clampedRadius)) .. " A ") .. tostring(clampedRadius)) .. " ") .. tostring(clampedRadius)) .. " 0 0 1 ") .. tostring(x)) .. " ") .. tostring(y + height - clampedRadius)) .. " Z"
end
function ____exports.leftRoundedRectPath(self, x, y, width, height, radius)
local clampedRadius = math.max(
0,
math.min(radius, width / 2, height / 2)
)
if clampedRadius == 0 then
return ((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width)) .. " V ") .. tostring(y + height)) .. " H ") .. tostring(x)) .. " Z"
end
return ((((((((((((((((((((((((("M " .. tostring(x)) .. " ") .. tostring(y + clampedRadius)) .. " A ") .. tostring(clampedRadius)) .. " ") .. tostring(clampedRadius)) .. " 0 0 1 ") .. tostring(x + clampedRadius)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width)) .. " V ") .. tostring(y + height)) .. " H ") .. tostring(x + clampedRadius)) .. " A ") .. tostring(clampedRadius)) .. " ") .. tostring(clampedRadius)) .. " 0 0 1 ") .. tostring(x)) .. " ") .. tostring(y + height - clampedRadius)) .. " Z"
end
function ____exports.rightRoundedRectPath(self, x, y, width, height, radius)
local clampedRadius = math.max(
0,
math.min(radius, width / 2, height / 2)
)
if clampedRadius == 0 then
return ((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width)) .. " V ") .. tostring(y + height)) .. " H ") .. tostring(x)) .. " Z"
end
return ((((((((((((((((((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width - clampedRadius)) .. " A ") .. tostring(clampedRadius)) .. " ") .. tostring(clampedRadius)) .. " 0 0 1 ") .. tostring(x + width)) .. " ") .. tostring(y + clampedRadius)) .. " V ") .. tostring(y + height - clampedRadius)) .. " A ") .. tostring(clampedRadius)) .. " ") .. tostring(clampedRadius)) .. " 0 0 1 ") .. tostring(x + width - clampedRadius)) .. " ") .. tostring(y + height)) .. " H ") .. tostring(x)) .. " Z"
end
function ____exports.cornersRoundedRectPath(self, x, y, width, height, radii)
local max = math.max(
0,
math.min(width, height) / 2
)
local tl = math.max(
0,
math.min(radii.topLeft, max)
)
local tr = math.max(
0,
math.min(radii.topRight, max)
)
local br = math.max(
0,
math.min(radii.bottomRight, max)
)
local bl = math.max(
0,
math.min(radii.bottomLeft, max)
)
local function arcTo(____, r, toX, toY)
return r > 0 and ((((((("A " .. tostring(r)) .. " ") .. tostring(r)) .. " 0 0 1 ") .. tostring(toX)) .. " ") .. tostring(toY)) .. " " or ""
end
return ((((((((((((("M " .. tostring(x + tl)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width - tr)) .. " ") .. arcTo(nil, tr, x + width, y + tr)) .. ("V " .. tostring(y + height - br)) .. " ") .. arcTo(nil, br, x + width - br, y + height)) .. ("H " .. tostring(x + bl)) .. " ") .. arcTo(nil, bl, x, y + height - bl)) .. ("V " .. tostring(y + tl)) .. " ") .. arcTo(nil, tl, x + tl, y)) .. "Z"
end
return ____exports
end,
["core.renderScene.artifacts.container.style"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
function ____exports.simpleContainerStyle(self, fill, stroke, strokeWidth, dash)
return {
fill = {
kind = "solid",
color = __lor(
nil,
fill,
function() return "transparent" end
)
},
stroke = {kind = "solid", color = stroke},
strokeWidth = strokeWidth,
dash = __t(nil, dash and #dash) and dash or nil
}
end
return ____exports
end,
["core.renderScene.artifacts.container.titleTab"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local horizontalTitleText, verticalTitleText
local ____scene = require("core.renderScene.scene.index")
local boxBounds = ____scene.boxBounds
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local ____roundedRectPath = require("core.renderScene.scene.roundedRectPath")
local bottomRoundedRectPath = ____roundedRectPath.bottomRoundedRectPath
local leftRoundedRectPath = ____roundedRectPath.leftRoundedRectPath
local rightRoundedRectPath = ____roundedRectPath.rightRoundedRectPath
local topRoundedRectPath = ____roundedRectPath.topRoundedRectPath
function horizontalTitleText(self, input, box, padding, bounds)
return {
type = "text",
id = input.titleId,
order = input.order + 0.2,
bounds = bounds,
x = box.x + padding,
y = box.y,
width = math.max(0, box.width - padding * 2),
height = box.height,
lines = {input.title},
fontFamily = input.fontFamily or DEFAULT_FONT,
fontSize = input.fontSize,
fontWeight = input.fontWeight,
color = input.textColor,
align = "left",
verticalAlign = "middle",
lineHeight = 1.2
}
end
function verticalTitleText(self, input, box, padding, bounds)
local centerX = box.x + box.width / 2
local centerY = box.y + box.height / 2
local textThickness = input.fontSize * 1.4
local textLength = math.max(1, box.height - padding * 2)
return {
type = "text",
id = input.titleId,
order = input.order + 0.2,
bounds = bounds,
x = centerX - textLength / 2,
y = centerY - textThickness / 2,
width = textLength,
height = textThickness,
lines = {input.title},
fontFamily = input.fontFamily or DEFAULT_FONT,
fontSize = input.fontSize,
fontWeight = input.fontWeight,
color = input.textColor,
align = "center",
verticalAlign = "middle",
lineHeight = 1.2,
rotation = -90,
rotationCenter = {x = centerX, y = centerY}
}
end
local TAB_RADIUS = 8
local function tabBox(self, input, thickness, length)
local inset = input.strokeWidth / 2
repeat
local ____switch3 = input.labelPosition
local ____cond3 = ____switch3 == "bottom"
if ____cond3 then
do
local x = input.x - inset
local y = input.y + input.height
return {
x = x,
y = y,
width = length,
height = thickness,
path = bottomRoundedRectPath(
nil,
x,
y,
length,
thickness,
TAB_RADIUS
)
}
end
end
____cond3 = ____cond3 or ____switch3 == "left"
if ____cond3 then
do
local x = input.x - thickness
local y = input.y - inset
return {
x = x,
y = y,
width = thickness,
height = length,
path = leftRoundedRectPath(
nil,
x,
y,
thickness,
length,
TAB_RADIUS
)
}
end
end
____cond3 = ____cond3 or ____switch3 == "right"
if ____cond3 then
do
local x = input.x + input.width
local y = input.y - inset
return {
x = x,
y = y,
width = thickness,
height = length,
path = rightRoundedRectPath(
nil,
x,
y,
thickness,
length,
TAB_RADIUS
)
}
end
end
do
do
local x = input.x - inset
local y = input.y - thickness
return {
x = x,
y = y,
width = length,
height = thickness,
path = topRoundedRectPath(
nil,
x,
y,
length,
thickness,
TAB_RADIUS
)
}
end
end
until true
end
function ____exports.renderTitleTab(self, input)
local thickness = math.max(32, input.fontSize + 18)
local padding = 16
local length = math.max(120, #input.title * input.fontSize * 0.62 + padding * 2)
local box = tabBox(nil, input, thickness, length)
local bounds = boxBounds(nil, box, 6)
local vertical = input.labelPosition == "left" or input.labelPosition == "right"
return {
{
type = "path",
id = input.tabId,
order = input.order + 0.1,
bounds = bounds,
d = box.path,
style = {fill = {kind = "solid", color = input.color}, stroke = {kind = "none"}}
},
vertical and verticalTitleText(
nil,
input,
box,
padding,
bounds
) or horizontalTitleText(
nil,
input,
box,
padding,
bounds
)
}
end
return ____exports
end,
["core.renderScene.artifacts.container.frame"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local boxBounds = ____scene.boxBounds
local ____roundedRectPath = require("core.renderScene.scene.roundedRectPath")
local cornersRoundedRectPath = ____roundedRectPath.cornersRoundedRectPath
local ____style = require("core.renderScene.artifacts.container.style")
local simpleContainerStyle = ____style.simpleContainerStyle
local ____titleTab = require("core.renderScene.artifacts.container.titleTab")
local renderTitleTab = ____titleTab.renderTitleTab
local SQUARED_CORNER_BY_LABEL_POSITION = {top = "topLeft", bottom = "bottomLeft", left = "topLeft", right = "topRight"}
local function frameBoundaryNode(self, frame, order, hasTab)
local ____frame_shadow_0 = frame.shadow
if ____frame_shadow_0 == nil then
____frame_shadow_0 = true
end
local shadow = ____frame_shadow_0
local bounds = boxBounds(nil, {x = frame.x, y = frame.y, width = frame.width, height = frame.height}, frame.strokeWidth + (shadow and 20 or 4))
local style = __TS__ObjectAssign(
{},
simpleContainerStyle(
nil,
frame.fillColor,
frame.strokeColor,
frame.strokeWidth,
frame.dash
),
{shadow = shadow and ({
color = "#000000",
opacity = 0.2,
blur = 12,
dx = 0,
dy = 4
}) or nil}
)
if not hasTab then
return {
type = "rect",
id = "frame-" .. frame.id,
order = order,
bounds = bounds,
x = frame.x,
y = frame.y,
width = frame.width,
height = frame.height,
rx = frame.cornerRadius,
style = style
}
end
local squared = SQUARED_CORNER_BY_LABEL_POSITION[frame.labelPosition or "top"]
local radii = {
topLeft = frame.cornerRadius,
topRight = frame.cornerRadius,
bottomRight = frame.cornerRadius,
bottomLeft = frame.cornerRadius,
[squared] = 0
}
return {
type = "path",
id = "frame-" .. frame.id,
order = order,
bounds = bounds,
d = cornersRoundedRectPath(
nil,
frame.x,
frame.y,
frame.width,
frame.height,
radii
),
detail = {of = "frameBoundary", cornerRadius = frame.cornerRadius, squareCorner = squared},
style = style
}
end
function ____exports.buildFrame(self, frame, index)
if frame.isVisible == false then
return {}
end
local order = index
local ____frame_showLabel_1 = frame.showLabel
if ____frame_showLabel_1 == nil then
____frame_showLabel_1 = true
end
local hasTab = ____frame_showLabel_1 and Boolean(nil, frame.title)
local nodes = {frameBoundaryNode(nil, frame, order, hasTab)}
if hasTab and __t(nil, frame.title) then
__TS__ArrayPushArray(
nodes,
renderTitleTab(nil, {
tabId = "frame-tab-" .. frame.id,
titleId = "frame-title-" .. frame.id,
x = frame.x,
y = frame.y,
width = frame.width,
height = frame.height,
cornerRadius = frame.cornerRadius,
strokeWidth = frame.strokeWidth,
title = frame.title,
color = frame.strokeColor,
textColor = frame.textColor,
fontFamily = frame.fontFamily,
fontSize = frame.fontSize,
fontWeight = frame.fontWeight,
labelPosition = frame.labelPosition or "top",
order = order
})
)
end
return nodes
end
return ____exports
end,
["core.renderScene.scene.shadow"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.DEFAULT_SHADOW_STYLE = {
enabled = false,
color = "#000000",
opacity = 0.3,
blur = 10,
angle = 45,
distance = 4
}
function ____exports.getShadowOffset(self, angle, distance)
local rad = angle * math.pi / 180
return {
x = math.cos(rad) * distance,
y = math.sin(rad) * distance
}
end
function ____exports.resolveShadow(self, shadow)
if not (shadow and shadow.enabled) then
return nil
end
local offset = ____exports.getShadowOffset(nil, shadow.angle or 45, shadow.distance or 5)
return {
color = shadow.color or "#000000",
opacity = shadow.opacity or 0.25,
blur = shadow.blur or 10,
dx = offset.x,
dy = offset.y
}
end
return ____exports
end,
["core.renderScene.artifacts.container.swimlane.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.artifacts.container.swimlane.dividers"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local function dividerPath(self, context, offset)
local ____context_0 = context
local swimlane = ____context_0.swimlane
if swimlane.orientation == "horizontal" then
return (((("M " .. tostring(swimlane.x)) .. " ") .. tostring(swimlane.y + offset)) .. " H ") .. tostring(swimlane.x + swimlane.width)
end
return (((("M " .. tostring(swimlane.x + offset)) .. " ") .. tostring(swimlane.y)) .. " V ") .. tostring(swimlane.y + swimlane.height)
end
function ____exports.renderLaneDividers(self, context)
return __TS__ArrayMap(
__TS__ArraySlice(context.lanes, 1),
function(____, lane, index) return {
type = "path",
id = (("swimlane-divider-" .. context.swimlane.id) .. "-") .. tostring(index),
order = context.order + 0.1 + index / 100,
bounds = context.bounds,
d = dividerPath(nil, context, lane.offset),
style = {fill = {kind = "none"}, stroke = {kind = "solid", color = context.swimlane.strokeColor}, strokeWidth = context.swimlane.strokeWidth}
} end
)
end
return ____exports
end,
["core.renderScene.artifacts.container.swimlane.labels"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local rotatedBounds = ____scene.rotatedBounds
local function labelBase(self, context, lane, index)
return {
type = "text",
id = (("swimlane-label-" .. context.swimlane.id) .. "-") .. lane.id,
order = context.order + 0.5 + index / 100,
lines = {lane.label},
fontFamily = context.swimlane.fontFamily or DEFAULT_FONT,
fontSize = context.swimlane.fontSize,
fontWeight = context.swimlane.fontWeight,
color = context.swimlane.textColor,
lineHeight = 1.2
}
end
local function horizontalLabel(self, context, lane, index)
local thickness = context.swimlane.fontSize * 1.4
local centerX = context.swimlane.x + 10 + thickness / 2
local centerY = context.swimlane.y + lane.offset + lane.size / 2
local width = math.max(20, lane.size - 16)
local x = centerX - width / 2
local y = centerY - thickness / 2
return __TS__ObjectAssign(
{},
labelBase(nil, context, lane, index),
{
bounds = rotatedBounds(nil, {x = x, y = y, width = width, height = thickness}, -90, 12),
x = x,
y = y,
width = width,
height = thickness,
align = "center",
verticalAlign = "middle",
rotation = -90,
rotationCenter = {x = centerX, y = centerY}
}
)
end
local function verticalLabel(self, context, lane, index)
return __TS__ObjectAssign(
{},
labelBase(nil, context, lane, index),
{
bounds = context.bounds,
x = context.swimlane.x + lane.offset + 8,
y = context.swimlane.y + 8,
width = math.max(0, lane.size - 16),
height = math.max(0, context.swimlane.height - 16),
align = "left",
verticalAlign = "top"
}
)
end
function ____exports.renderLaneLabels(self, context)
if not context.swimlane.showLaneLabels then
return {}
end
local render = context.swimlane.orientation == "horizontal" and horizontalLabel or verticalLabel
return __TS__ArrayMap(
context.lanes,
function(____, lane, index) return render(nil, context, lane, index) end
)
end
return ____exports
end,
["core.renderScene.artifacts.container.swimlane.layout"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local boxBounds = ____scene.boxBounds
local function normalizeLanes(self, swimlane)
local targetSize = swimlane.orientation == "horizontal" and swimlane.height or swimlane.width
local total = __TS__ArrayReduce(
swimlane.lanes,
function(____, sum, lane) return sum + lane.size end,
0
)
if total <= 0 or targetSize <= 0 then
return swimlane.lanes
end
return __TS__ArrayMap(
swimlane.lanes,
function(____, lane) return __TS__ObjectAssign({}, lane, {size = lane.size * (targetSize / total)}) end
)
end
local function positionLanes(self, swimlane)
local offset = 0
return __TS__ArrayMap(
normalizeLanes(nil, swimlane),
function(____, lane)
local positioned = __TS__ObjectAssign({}, lane, {offset = offset})
offset = offset + lane.size
return positioned
end
)
end
function ____exports.createSwimlaneRenderContext(self, swimlane, index)
return {
swimlane = swimlane,
order = 5000 + index,
bounds = boxBounds(nil, {x = swimlane.x, y = swimlane.y, width = swimlane.width, height = swimlane.height}, swimlane.strokeWidth + 4),
lanes = positionLanes(nil, swimlane)
}
end
return ____exports
end,
["core.renderScene.artifacts.container.swimlane.index"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ____shadow = require("core.renderScene.scene.shadow")
local resolveShadow = ____shadow.resolveShadow
local ____style = require("core.renderScene.artifacts.container.style")
local simpleContainerStyle = ____style.simpleContainerStyle
local ____dividers = require("core.renderScene.artifacts.container.swimlane.dividers")
local renderLaneDividers = ____dividers.renderLaneDividers
local ____labels = require("core.renderScene.artifacts.container.swimlane.labels")
local renderLaneLabels = ____labels.renderLaneLabels
local ____layout = require("core.renderScene.artifacts.container.swimlane.layout")
local createSwimlaneRenderContext = ____layout.createSwimlaneRenderContext
function ____exports.buildSwimlane(self, swimlane, index)
if swimlane.isVisible == false then
return {}
end
local context = createSwimlaneRenderContext(nil, swimlane, index)
local ____array_0 = __TS__SparseArrayNew(
{
type = "rect",
id = "swimlane-" .. swimlane.id,
order = context.order,
bounds = context.bounds,
x = swimlane.x,
y = swimlane.y,
width = swimlane.width,
height = swimlane.height,
rx = swimlane.cornerRadius,
style = __TS__ObjectAssign(
{},
simpleContainerStyle(
nil,
swimlane.fillColor,
swimlane.strokeColor,
swimlane.strokeWidth,
swimlane.dash
),
{shadow = resolveShadow(nil, swimlane.shadowStyle)}
)
},
table.unpack(renderLaneDividers(nil, context))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(renderLaneLabels(nil, context))
)
return {__TS__SparseArraySpread(____array_0)}
end
return ____exports
end,
["core.renderScene.artifacts.containers"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ____tagging = require("core.renderScene.scene.tagging")
local tag = ____tagging.tag
local ____frame = require("core.renderScene.artifacts.container.frame")
local buildFrame = ____frame.buildFrame
local ____swimlane = require("core.renderScene.artifacts.container.swimlane.index")
local buildSwimlane = ____swimlane.buildSwimlane
do
local ____roundedRectPath = require("core.renderScene.scene.roundedRectPath")
____exports.bottomRoundedRectPath = ____roundedRectPath.bottomRoundedRectPath
____exports.leftRoundedRectPath = ____roundedRectPath.leftRoundedRectPath
____exports.rightRoundedRectPath = ____roundedRectPath.rightRoundedRectPath
____exports.topRoundedRectPath = ____roundedRectPath.topRoundedRectPath
end
do
local ____frame = require("core.renderScene.artifacts.container.frame")
____exports.buildFrame = ____frame.buildFrame
end
do
local ____style = require("core.renderScene.artifacts.container.style")
____exports.simpleContainerStyle = ____style.simpleContainerStyle
end
do
local ____swimlane = require("core.renderScene.artifacts.container.swimlane.index")
____exports.buildSwimlane = ____swimlane.buildSwimlane
end
function ____exports.buildContainers(self, input)
local ____array_0 = __TS__SparseArrayNew(table.unpack(__TS__ArrayFlatMap(
input.frames,
function(____, frame, index) return tag(
nil,
buildFrame(nil, frame, index),
"frame",
frame.id,
frame.screen and "screen" or nil,
frame.title or nil
) end
)))
__TS__SparseArrayPush(
____array_0,
table.unpack(__TS__ArrayFlatMap(
input.swimlanes,
function(____, swimlane, index) return tag(
nil,
buildSwimlane(nil, swimlane, index),
"swimlane",
swimlane.id
) end
))
)
return {__TS__SparseArraySpread(____array_0)}
end
return ____exports
end,
["core.renderScene.artifacts.dimension"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlat = ____lualib.__TS__ArrayFlat
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ____dimension = require("core.model.dimension.index")
local dimensionGeometry = ____dimension.dimensionGeometry
local dimensionText = ____dimension.dimensionText
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local ____tagging = require("core.renderScene.scene.tagging")
local tag = ____tagging.tag
local DEFAULT_COLOR = "#475569"
local CHAR_WIDTH = 0.6
local function pathData(____, segments)
return table.concat(
__TS__ArrayMap(
segments,
function(____, ____bindingPattern0)
local to
local from
from = ____bindingPattern0[1]
to = ____bindingPattern0[2]
return (((((("M " .. tostring(from.x)) .. " ") .. tostring(from.y)) .. " L ") .. tostring(to.x)) .. " ") .. tostring(to.y)
end
),
" "
)
end
local function pathNode(self, dimension, name, order, segments)
local strokeWidth = math.max(
0,
finite(nil, dimension.strokeWidth, 1)
)
local points = __TS__ArrayFlat(segments)
return {
type = "path",
id = (("dimension-" .. dimension.id) .. "-") .. name,
order = order,
bounds = {
minX = math.min(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.x end
))) - strokeWidth,
minY = math.min(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.y end
))) - strokeWidth,
maxX = math.max(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.x end
))) + strokeWidth,
maxY = math.max(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.y end
))) + strokeWidth
},
d = pathData(nil, segments),
style = {fill = {kind = "none"}, stroke = {kind = "solid", color = dimension.strokeColor or DEFAULT_COLOR}, strokeWidth = strokeWidth, lineCap = "round"}
}
end
local function labelNode(self, dimension, order, text, center, angle)
local fontSize = finite(nil, dimension.fontSize, 11)
local width = math.max(24, #text * fontSize * CHAR_WIDTH + 8)
local height = fontSize * 1.3
return {
type = "text",
id = ("dimension-" .. dimension.id) .. "-label",
order = order,
bounds = {minX = center.x - width / 2, minY = center.y - height / 2, maxX = center.x + width / 2, maxY = center.y + height / 2},
x = center.x - width / 2,
y = center.y - height / 2,
width = width,
height = height,
lines = {text},
fontFamily = DEFAULT_FONT,
fontSize = fontSize,
fontWeight = "normal",
color = dimension.textColor or dimension.strokeColor or DEFAULT_COLOR,
align = "center",
verticalAlign = "middle",
lineHeight = 1.2,
rotation = angle,
rotationCenter = center
}
end
function ____exports.buildDimension(self, dimension, index)
local geometry = dimensionGeometry(nil, dimension)
local order = 31000 + index
local line = __TS__ObjectAssign(
{},
pathNode(
nil,
dimension,
"line",
order + 0.1,
{geometry.line}
),
{markerStart = "filled_arrow", markerEnd = "filled_arrow", detail = {of = "dimensionGeometry", start = {dimension.start.x, dimension.start.y}, ["end"] = {dimension["end"].x, dimension["end"].y}, offset = dimension.offset}}
)
local extensions = #geometry.extensions > 0 and ({pathNode(
nil,
dimension,
"extensions",
order,
geometry.extensions
)}) or ({})
local text = dimensionText(nil, dimension)
local ____array_0 = __TS__SparseArrayNew(
line,
table.unpack(extensions)
)
__TS__SparseArrayPush(
____array_0,
labelNode(
nil,
dimension,
order + 0.2,
text,
geometry.label.center,
geometry.label.angle
)
)
return {__TS__SparseArraySpread(____array_0)}
end
function ____exports.buildDimensions(self, dimensions)
return __TS__ArrayFlatMap(
dimensions,
function(____, dimension, index) return tag(
nil,
____exports.buildDimension(nil, dimension, index),
"dimension",
dimension.id,
"dimension",
dimensionText(nil, dimension),
dimension.parentFrameId
) end
)
end
return ____exports
end,
["core.renderScene.scene.roundedPolygonPath"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local function distance(self, a, b)
return __hypot(nil, b.x - a.x, b.y - a.y)
end
local function toward(self, from, to, distanceFromStart)
local length = distance(nil, from, to)
if length == 0 then
return from
end
local ratio = distanceFromStart / length
return {x = from.x + (to.x - from.x) * ratio, y = from.y + (to.y - from.y) * ratio}
end
local function roundedCorner(self, previous, vertex, next, requestedRadius)
local radius = math.max(
0,
math.min(
requestedRadius,
distance(nil, vertex, previous) / 2,
distance(nil, vertex, next) / 2
)
)
return {
vertex = vertex,
start = toward(nil, vertex, previous, radius),
["end"] = toward(nil, vertex, next, radius)
}
end
function ____exports.roundedPolygonPath(self, points, radius)
if #points < 3 then
return ""
end
local function radiusAt(____, index)
return type(radius) == "number" and radius or (radius[index + 1] or 0)
end
if __TS__ArrayEvery(
points,
function(____, _, index) return radiusAt(nil, index) <= 0 end
) then
local ____points_0 = points
local first = ____points_0[1]
local rest = __TS__ArraySlice(____points_0, 1)
return ((((("M " .. tostring(first.x)) .. " ") .. tostring(first.y)) .. " ") .. table.concat(
__TS__ArrayMap(
rest,
function(____, point) return (("L " .. tostring(point.x)) .. " ") .. tostring(point.y) end
),
" "
)) .. " Z"
end
local corners = __TS__ArrayMap(
points,
function(____, vertex, index) return roundedCorner(
nil,
points[(index - 1 + #points) % #points + 1],
vertex,
points[(index + 1) % #points + 1],
radiusAt(nil, index)
) end
)
local commands = {(("M " .. tostring(corners[1]["end"].x)) .. " ") .. tostring(corners[1]["end"].y)}
do
local index = 1
while index < #corners do
local corner = corners[index + 1]
__TS__ArrayPush(
commands,
(("L " .. tostring(corner.start.x)) .. " ") .. tostring(corner.start.y),
(((((("Q " .. tostring(corner.vertex.x)) .. " ") .. tostring(corner.vertex.y)) .. " ") .. tostring(corner["end"].x)) .. " ") .. tostring(corner["end"].y)
)
index = index + 1
end
end
local first = corners[1]
__TS__ArrayPush(
commands,
(("L " .. tostring(first.start.x)) .. " ") .. tostring(first.start.y),
(((((("Q " .. tostring(first.vertex.x)) .. " ") .. tostring(first.vertex.y)) .. " ") .. tostring(first["end"].x)) .. " ") .. tostring(first["end"].y),
"Z"
)
return table.concat(commands, " ")
end
return ____exports
end,
["core.renderScene.artifacts.isometric.context"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____isometricObject = require("core.model.isometricObject.index")
local isometricBounds = ____isometricObject.isometricBounds
local isometricFaces = ____isometricObject.isometricFaces
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local rotatedBounds = ____scene.rotatedBounds
local ____roundedPolygonPath = require("core.renderScene.scene.roundedPolygonPath")
local roundedPolygonPath = ____roundedPolygonPath.roundedPolygonPath
local FILL_PROP = {prop = "style.fill", propKind = "color", propSolidOnly = true}
function ____exports.isometricContext(self, object, index)
local strokeWidth = math.max(
0,
finite(nil, object.strokeWidth, 1)
)
local rotation = finite(nil, object.rotation, 0)
local box = isometricBounds(nil, object)
local rotationCenter = {x = box.x + box.width / 2, y = box.y + box.height / 2}
return {
object = object,
index = index,
order = 15000 + index,
rotation = rotation,
rotationCenter = rotationCenter,
box = box,
strokeWidth = strokeWidth,
common = {
type = "path",
bounds = rotatedBounds(nil, box, rotation, strokeWidth + 2),
rotation = rotation,
rotationCenter = rotationCenter,
style = {stroke = {kind = "solid", color = object.strokeColor or "#111827"}, strokeWidth = strokeWidth, lineJoin = "round"}
}
}
end
function ____exports.faceNode(self, context, name, offset, points, style)
return __TS__ObjectAssign(
{},
context.common,
{
id = (("isometric-" .. context.object.id) .. "-") .. name,
order = context.order + offset,
d = roundedPolygonPath(
nil,
{table.unpack(points)},
0
),
style = style
},
FILL_PROP
)
end
function ____exports.silhouette(self, object)
local faces = isometricFaces(nil, object)
return {
faces.top[1],
faces.top[2],
faces.right[3],
faces.front[3],
faces.front[4],
faces.top[4]
}
end
function ____exports.hullNode(self, context, hullPath, cornerRadius)
local ____context_0 = context
local object = ____context_0.object
local order = ____context_0.order
local common = ____context_0.common
local box = ____context_0.box
return __TS__ObjectAssign(
{},
common,
{
id = ("isometric-" .. object.id) .. "-hull",
order = order + 0.24,
d = hullPath,
detail = {
of = "isometricGeometry",
width = math.max(0, object.width),
height = math.max(0, object.height),
depth = math.max(0, object.depth),
cornerRadius = cornerRadius,
bounds = box,
labelOffsetX = finite(nil, object.labelOffsetX, 0),
labelOffsetY = finite(nil, object.labelOffsetY, 0)
},
style = __TS__ObjectAssign({}, common.style, {fill = {kind = "none"}})
}
)
end
function ____exports.unseenHullNode(self, context)
return __TS__ObjectAssign(
{},
____exports.hullNode(
nil,
context,
roundedPolygonPath(
nil,
____exports.silhouette(nil, context.object),
0
),
0
),
{style = __TS__ObjectAssign({}, context.common.style, {fill = {kind = "none"}, stroke = {kind = "none"}})}
)
end
return ____exports
end,
["core.renderScene.artifacts.isometric.label"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____isometricObject = require("core.model.isometricObject.index")
local isometricTopFaceCenter = ____isometricObject.isometricTopFaceCenter
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local LABEL_HEIGHT = 20
local LABEL_GAP = 12
local LABEL_PADDING_X = 6
local LABEL_PADDING_Y = 3
local LABEL_CHAR_WIDTH = 6.5
local function labelPlacement(self, context)
local ____context_0 = context
local object = ____context_0.object
local anchor = isometricTopFaceCenter(nil, object)
local bottomY = anchor.y - LABEL_GAP + finite(nil, object.labelOffsetY, 0)
return {
anchor = anchor,
centerX = anchor.x + finite(nil, object.labelOffsetX, 0),
topY = bottomY - LABEL_HEIGHT,
bottomY = bottomY
}
end
local function labelTextNode(self, context, placement, text)
local ____context_1 = context
local object = ____context_1.object
local order = ____context_1.order
local rotation = ____context_1.rotation
local rotationCenter = ____context_1.rotationCenter
local box = ____context_1.box
local ____placement_2 = placement
local centerX = ____placement_2.centerX
local topY = ____placement_2.topY
local bottomY = ____placement_2.bottomY
return {
type = "text",
id = ("isometric-" .. object.id) .. "-label",
order = order + 0.3,
bounds = {minX = centerX - box.width / 2, minY = topY, maxX = centerX + box.width / 2, maxY = bottomY},
x = centerX - box.width / 2,
y = topY,
width = box.width,
height = LABEL_HEIGHT,
lines = {text},
fontFamily = DEFAULT_FONT,
fontSize = 12,
fontWeight = "normal",
color = "#111827",
align = "center",
verticalAlign = "middle",
lineHeight = 1.2,
rotation = rotation,
rotationCenter = rotationCenter,
mark = "isometric-label"
}
end
local function labelGuideNode(self, context, placement)
local ____context_3 = context
local object = ____context_3.object
local order = ____context_3.order
local rotation = ____context_3.rotation
local rotationCenter = ____context_3.rotationCenter
local ____placement_4 = placement
local anchor = ____placement_4.anchor
local centerX = ____placement_4.centerX
local bottomY = ____placement_4.bottomY
return {
type = "path",
id = ("isometric-" .. object.id) .. "-label-guide",
order = order + 0.25,
bounds = {
minX = math.min(anchor.x, centerX),
minY = math.min(anchor.y, bottomY),
maxX = math.max(anchor.x, centerX),
maxY = math.max(anchor.y, bottomY)
},
d = (((((("M " .. tostring(anchor.x)) .. " ") .. tostring(anchor.y)) .. " L ") .. tostring(centerX)) .. " ") .. tostring(bottomY),
rotation = rotation,
rotationCenter = rotationCenter,
style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = "#cbd5e1"},
strokeWidth = 1,
lineCap = "round",
pointerEvents = "none"
}
}
end
local function labelBackgroundNode(self, context, placement, text, background)
local ____context_5 = context
local object = ____context_5.object
local order = ____context_5.order
local rotation = ____context_5.rotation
local ____placement_6 = placement
local centerX = ____placement_6.centerX
local topY = ____placement_6.topY
local bottomY = ____placement_6.bottomY
local width = math.max(24, #text * LABEL_CHAR_WIDTH + LABEL_PADDING_X * 2)
return {
type = "rect",
id = ("isometric-" .. object.id) .. "-label-background",
order = order + 0.28,
x = centerX - width / 2,
y = topY - LABEL_PADDING_Y,
width = width,
height = LABEL_HEIGHT + LABEL_PADDING_Y * 2,
rx = 4,
bounds = {minX = centerX - width / 2, minY = topY - LABEL_PADDING_Y, maxX = centerX + width / 2, maxY = bottomY + LABEL_PADDING_Y},
rotation = rotation,
mark = "isometric-label",
style = {fill = {kind = "solid", color = background}, stroke = {kind = "none"}}
}
end
function ____exports.labelNodes(self, context, text)
local placement = labelPlacement(nil, context)
local label = labelTextNode(nil, context, placement, text)
local guide = labelGuideNode(nil, context, placement)
local background = context.object.labelBackground
if not __t(nil, background) then
return {guide, label}
end
return {
guide,
labelBackgroundNode(
nil,
context,
placement,
text,
background
),
label
}
end
return ____exports
end,
["core.renderScene.artifacts.isometric.shadow"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local ____isometricObject = require("core.model.isometricObject.index")
local AXIS_SIN = ____isometricObject.AXIS_SIN
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____roundedPolygonPath = require("core.renderScene.scene.roundedPolygonPath")
local roundedPolygonPath = ____roundedPolygonPath.roundedPolygonPath
function ____exports.groundShadowNode(self, context, topOutline)
local ____context_0 = context
local object = ____context_0.object
local index = ____context_0.index
local rotation = ____context_0.rotation
local rotationCenter = ____context_0.rotationCenter
if not object.hasShadow then
return nil
end
local height = math.max(0, object.height)
local heightFactor = 0.6 + math.min(1, height / 150) * 0.7
local ____finite_3 = finite
local ____opt_1 = object.shadowStyle
local shadowDrop = height + ____finite_3(nil, ____opt_1 and ____opt_1.distance, 0)
local contactFootprint = __TS__ArrayMap(
topOutline,
function(____, point) return {x = point.x, y = point.y + shadowDrop} end
)
local footprintCenter = {
x = __TS__ArrayReduce(
contactFootprint,
function(____, sum, point) return sum + point.x end,
0
) / #contactFootprint,
y = __TS__ArrayReduce(
contactFootprint,
function(____, sum, point) return sum + point.y end,
0
) / #contactFootprint
}
local shadowSpread = 1.3
local footprint = __TS__ArrayMap(
contactFootprint,
function(____, point) return {x = footprintCenter.x + (point.x - footprintCenter.x) * shadowSpread, y = footprintCenter.y + (point.y - footprintCenter.y) * shadowSpread} end
)
local footprintXs = __TS__ArrayMap(
footprint,
function(____, point) return point.x end
)
local footprintYs = __TS__ArrayMap(
footprint,
function(____, point) return point.y end
)
local ____temp_14 = ("isometric-" .. object.id) .. "-ground-shadow"
local ____temp_15 = 14000 + index
local ____temp_16 = {
minX = math.min(table.unpack(footprintXs)),
minY = math.min(table.unpack(footprintYs)),
maxX = math.max(table.unpack(footprintXs)),
maxY = math.max(table.unpack(footprintYs))
}
local ____roundedPolygonPath_result_17 = roundedPolygonPath(nil, footprint, 0)
local ____rotation_18 = rotation
local ____rotationCenter_19 = rotationCenter
local ____opt_4 = object.shadowStyle
local ____temp_11 = {kind = "solid", color = ____opt_4 and ____opt_4.color or "#000000"}
local ____temp_12 = {kind = "none"}
local ____opt_6 = object.shadowStyle
local ____math_min_result_13 = math.min(1, (____opt_6 and ____opt_6.opacity or 0.18) * heightFactor)
local ____finite_10 = finite
local ____opt_8 = object.shadowStyle
return {
type = "path",
id = ____temp_14,
order = ____temp_15,
bounds = ____temp_16,
d = ____roundedPolygonPath_result_17,
rotation = ____rotation_18,
rotationCenter = ____rotationCenter_19,
style = {
fill = ____temp_11,
stroke = ____temp_12,
opacity = ____math_min_result_13,
blur = ____finite_10(nil, ____opt_8 and ____opt_8.blur, 8),
pointerEvents = "none"
}
}
end
function ____exports.sphereShadowNode(self, context, radius)
local ____context_20 = context
local object = ____context_20.object
local index = ____context_20.index
local box = ____context_20.box
if not object.hasShadow then
return nil
end
local width = math.max(0, object.width)
local depth = math.max(0, object.depth)
local center = {
x = box.x + box.width / 2,
y = object.y + math.max(0, object.height) + (width + depth) * AXIS_SIN / 2
}
local ____temp_31 = ("isometric-" .. object.id) .. "-ground-shadow"
local ____temp_32 = 14000 + index
local ____temp_33 = {minX = center.x - radius * 1.1, minY = center.y - radius * 0.6, maxX = center.x + radius * 1.1, maxY = center.y + radius * 0.6}
local ____center_x_34 = center.x
local ____center_y_35 = center.y
local ____temp_36 = radius * 1.05
local ____temp_37 = radius * 0.52
local ____opt_21 = object.shadowStyle
local ____temp_28 = {kind = "solid", color = ____opt_21 and ____opt_21.color or "#000000"}
local ____temp_29 = {kind = "none"}
local ____opt_23 = object.shadowStyle
local ____temp_30 = ____opt_23 and ____opt_23.opacity or 0.2
local ____finite_27 = finite
local ____opt_25 = object.shadowStyle
return {
type = "ellipse",
id = ____temp_31,
order = ____temp_32,
bounds = ____temp_33,
cx = ____center_x_34,
cy = ____center_y_35,
rx = ____temp_36,
ry = ____temp_37,
style = {
fill = ____temp_28,
stroke = ____temp_29,
opacity = ____temp_30,
blur = ____finite_27(nil, ____opt_25 and ____opt_25.blur, 8),
pointerEvents = "none"
}
}
end
return ____exports
end,
["core.renderScene.artifacts.isometric.box"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____isometricObject = require("core.model.isometricObject.index")
local deriveFaceFills = ____isometricObject.deriveFaceFills
local isometricFaces = ____isometricObject.isometricFaces
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____roundedPolygonPath = require("core.renderScene.scene.roundedPolygonPath")
local roundedPolygonPath = ____roundedPolygonPath.roundedPolygonPath
local ____context = require("core.renderScene.artifacts.isometric.context")
local faceNode = ____context.faceNode
local hullNode = ____context.hullNode
local isometricContext = ____context.isometricContext
local silhouette = ____context.silhouette
local ____label = require("core.renderScene.artifacts.isometric.label")
local labelNodes = ____label.labelNodes
local ____shadow = require("core.renderScene.artifacts.isometric.shadow")
local groundShadowNode = ____shadow.groundShadowNode
local function faceNodes(self, context, faces, hullClip)
local ____context_0 = context
local object = ____context_0.object
local common = ____context_0.common
local noStroke = __TS__ObjectAssign({}, common.style, {stroke = {kind = "none"}})
local fills = deriveFaceFills(nil, object.fill or "#f8fafc")
local function face(____, name, offset, points, color)
return faceNode(
nil,
context,
name,
offset,
points,
__TS__ObjectAssign({}, noStroke, {fill = {kind = "solid", color = color}, clip = hullClip})
)
end
return {
face(
nil,
"top",
0,
faces.top,
fills.topFill
),
face(
nil,
"front",
0.1,
faces.front,
fills.frontFill
),
face(
nil,
"side",
0.2,
faces.right,
fills.sideFill
)
}
end
local function seamsNode(self, context, faces, hullClip)
local ____context_1 = context
local object = ____context_1.object
local order = ____context_1.order
local common = ____context_1.common
local strokeWidth = ____context_1.strokeWidth
return __TS__ObjectAssign(
{},
common,
{
id = ("isometric-" .. object.id) .. "-seams",
order = order + 0.22,
d = (((((((((((((((((("M " .. tostring(faces.top[4].x)) .. " ") .. tostring(faces.top[4].y)) .. " L ") .. tostring(faces.top[3].x)) .. " ") .. tostring(faces.top[3].y)) .. " L ") .. tostring(faces.top[2].x)) .. " ") .. tostring(faces.top[2].y)) .. " M ") .. tostring(faces.top[3].x)) .. " ") .. tostring(faces.top[3].y)) .. " L ") .. tostring(faces.front[3].x)) .. " ") .. tostring(faces.front[3].y),
style = __TS__ObjectAssign(
{},
common.style,
{
fill = {kind = "none"},
stroke = {kind = "solid", color = "#cbd5e1"},
strokeWidth = math.min(strokeWidth, 1),
clip = hullClip
}
)
}
)
end
function ____exports.buildBox(self, object, index)
local context = isometricContext(nil, object, index)
local faces = isometricFaces(nil, object)
local cornerRadius = math.max(
0,
finite(nil, object.cornerRadius, 8)
)
local hullPath = roundedPolygonPath(
nil,
silhouette(nil, object),
cornerRadius
)
local hullClip = {type = "path", d = hullPath}
local groundShadow = groundShadowNode(nil, context, faces.top)
local ____temp_2
if object.seams == false then
____temp_2 = nil
else
____temp_2 = seamsNode(nil, context, faces, hullClip)
end
local seams = ____temp_2
local hull = hullNode(nil, context, hullPath, cornerRadius)
local facesNodes = faceNodes(nil, context, faces, hullClip)
local ____groundShadow_5
if groundShadow then
local ____array_3 = __TS__SparseArrayNew(
hull,
table.unpack(facesNodes)
)
__TS__SparseArrayPush(
____array_3,
groundShadow,
table.unpack(seams and ({seams}) or ({}))
)
____groundShadow_5 = {__TS__SparseArraySpread(____array_3)}
else
local ____array_4 = __TS__SparseArrayNew(
hull,
table.unpack(facesNodes)
)
__TS__SparseArrayPush(
____array_4,
table.unpack(seams and ({seams}) or ({}))
)
____groundShadow_5 = {__TS__SparseArraySpread(____array_4)}
end
local objectNodes = ____groundShadow_5
local ____t_result_7
if __t(nil, object.text) then
local ____array_6 = __TS__SparseArrayNew(table.unpack(objectNodes))
__TS__SparseArrayPush(
____array_6,
table.unpack(labelNodes(nil, context, object.text))
)
____t_result_7 = {__TS__SparseArraySpread(____array_6)}
else
____t_result_7 = objectNodes
end
return ____t_result_7
end
return ____exports
end,
["core.renderScene.artifacts.isometric.extruded"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____isometricObject = require("core.model.isometricObject.index")
local extrudeFootprint = ____isometricObject.extrudeFootprint
local shadeFill = ____isometricObject.shadeFill
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____context = require("core.renderScene.artifacts.isometric.context")
local faceNode = ____context.faceNode
local isometricContext = ____context.isometricContext
local unseenHullNode = ____context.unseenHullNode
local ____label = require("core.renderScene.artifacts.isometric.label")
local labelNodes = ____label.labelNodes
local ____shadow = require("core.renderScene.artifacts.isometric.shadow")
local groundShadowNode = ____shadow.groundShadowNode
local function wallNode(self, context, side, index, fill)
local color = shadeFill(nil, fill, side.light)
return faceNode(
nil,
context,
"side-" .. tostring(index),
0.05 + index * 0.001,
side.points,
__TS__ObjectAssign({}, context.common.style, {stroke = {kind = "solid", color = color}, strokeWidth = 0.6, fill = {kind = "solid", color = color}})
)
end
local function wallEdgesNode(self, context, side, index)
local topFrom, topTo, bottomTo, bottomFrom = table.unpack(side.points, 1, 4)
local ____array_0 = __TS__SparseArrayNew(
(((((("M " .. tostring(bottomFrom.x)) .. " ") .. tostring(bottomFrom.y)) .. " L ") .. tostring(bottomTo.x)) .. " ") .. tostring(bottomTo.y),
table.unpack(side.smoothStart and ({}) or ({(((((("M " .. tostring(topFrom.x)) .. " ") .. tostring(topFrom.y)) .. " L ") .. tostring(bottomFrom.x)) .. " ") .. tostring(bottomFrom.y)}))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(side.smoothEnd and ({}) or ({(((((("M " .. tostring(topTo.x)) .. " ") .. tostring(topTo.y)) .. " L ") .. tostring(bottomTo.x)) .. " ") .. tostring(bottomTo.y)}))
)
local lines = {__TS__SparseArraySpread(____array_0)}
return __TS__ObjectAssign(
{},
context.common,
{
id = ((("isometric-" .. context.object.id) .. "-side-") .. tostring(index)) .. "-edges",
order = context.order + 0.0505 + index * 0.001,
d = table.concat(lines, " "),
style = __TS__ObjectAssign({}, context.common.style, {fill = {kind = "none"}})
}
)
end
function ____exports.buildExtruded(self, object, index, footprint)
local context = isometricContext(nil, object, index)
local ____extrudeFootprint_result_1 = extrudeFootprint(
nil,
object,
footprint,
math.max(
0,
finite(nil, object.cornerRadius, 0)
)
)
local top = ____extrudeFootprint_result_1.top
local sides = ____extrudeFootprint_result_1.sides
local fill = object.fill or "#f8fafc"
local groundShadow = groundShadowNode(nil, context, top)
local topFace = faceNode(
nil,
context,
"top",
0.2,
top,
__TS__ObjectAssign({}, context.common.style, {fill = {kind = "solid", color = fill}})
)
local ____array_2 = __TS__SparseArrayNew(
unseenHullNode(nil, context),
table.unpack(groundShadow and ({groundShadow}) or ({}))
)
__TS__SparseArrayPush(
____array_2,
table.unpack(__TS__ArrayFlatMap(
sides,
function(____, side, i) return {
wallNode(
nil,
context,
side,
i,
fill
),
wallEdgesNode(nil, context, side, i)
} end
))
)
__TS__SparseArrayPush(____array_2, topFace)
local nodes = {__TS__SparseArraySpread(____array_2)}
local ____t_result_4
if __t(nil, object.text) then
local ____array_3 = __TS__SparseArrayNew(table.unpack(nodes))
__TS__SparseArrayPush(
____array_3,
table.unpack(labelNodes(nil, context, object.text))
)
____t_result_4 = {__TS__SparseArraySpread(____array_3)}
else
____t_result_4 = nodes
end
return ____t_result_4
end
return ____exports
end,
["core.renderScene.artifacts.isometric.sphere"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____isometricObject = require("core.model.isometricObject.index")
local shadeFill = ____isometricObject.shadeFill
local ____context = require("core.renderScene.artifacts.isometric.context")
local isometricContext = ____context.isometricContext
local unseenHullNode = ____context.unseenHullNode
local ____label = require("core.renderScene.artifacts.isometric.label")
local labelNodes = ____label.labelNodes
local ____shadow = require("core.renderScene.artifacts.isometric.shadow")
local sphereShadowNode = ____shadow.sphereShadowNode
function ____exports.buildSphere(self, object, index)
local context = isometricContext(nil, object, index)
local order = context.order
local common = context.common
local box = context.box
local radius = math.max(
0,
math.min(object.width, object.height, object.depth)
) / 2
local cx = box.x + box.width / 2
local cy = box.y + box.height / 2
local fill = object.fill or "#f8fafc"
local bounds = {minX = cx - radius, minY = cy - radius, maxX = cx + radius, maxY = cy + radius}
local body = {
type = "ellipse",
id = ("isometric-" .. object.id) .. "-sphere",
order = order + 0.1,
bounds = bounds,
cx = cx,
cy = cy,
rx = radius,
ry = radius,
style = __TS__ObjectAssign(
{},
common.style,
{fill = {
kind = "linear-gradient",
angle = 135,
stops = {
{
offset = 0,
color = shadeFill(nil, fill, 1.22)
},
{offset = 0.5, color = fill},
{
offset = 1,
color = shadeFill(nil, fill, 0.82)
}
}
}}
),
prop = "style.fill",
propKind = "color",
propSolidOnly = true
}
local highlight = {
type = "ellipse",
id = ("isometric-" .. object.id) .. "-highlight",
order = order + 0.2,
bounds = bounds,
cx = cx - radius * 0.32,
cy = cy - radius * 0.38,
rx = radius * 0.26,
ry = radius * 0.18,
rotation = -35,
style = {
fill = {kind = "solid", color = "#ffffff"},
stroke = {kind = "none"},
opacity = 0.45,
blur = radius * 0.1,
pointerEvents = "none"
}
}
local shadow = sphereShadowNode(nil, context, radius)
local ____array_0 = __TS__SparseArrayNew(
unseenHullNode(nil, context),
table.unpack(shadow and ({shadow}) or ({}))
)
__TS__SparseArrayPush(____array_0, body, highlight)
local nodes = {__TS__SparseArraySpread(____array_0)}
local ____t_result_2
if __t(nil, object.text) then
local ____array_1 = __TS__SparseArrayNew(table.unpack(nodes))
__TS__SparseArrayPush(
____array_1,
table.unpack(labelNodes(nil, context, object.text))
)
____t_result_2 = {__TS__SparseArraySpread(____array_1)}
else
____t_result_2 = nodes
end
return ____t_result_2
end
return ____exports
end,
["core.renderScene.artifacts.isometric.index"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ____isometricObject = require("core.model.isometricObject.index")
local cleanFootprint = ____isometricObject.cleanFootprint
local ____tagging = require("core.renderScene.scene.tagging")
local tag = ____tagging.tag
local ____box = require("core.renderScene.artifacts.isometric.box")
local buildBox = ____box.buildBox
local ____extruded = require("core.renderScene.artifacts.isometric.extruded")
local buildExtruded = ____extruded.buildExtruded
local ____sphere = require("core.renderScene.artifacts.isometric.sphere")
local buildSphere = ____sphere.buildSphere
function ____exports.buildIsometricObject(self, object, index)
if not (object.width > 0) and not (object.height > 0) and not (object.depth > 0) then
return {}
end
if object.form == "sphere" then
return buildSphere(nil, object, index)
end
local footprint = cleanFootprint(nil, object.footprint)
return #footprint > 0 and buildExtruded(nil, object, index, footprint) or buildBox(nil, object, index)
end
function ____exports.buildIsometricObjects(self, objects)
return __TS__ArrayFlatMap(
objects,
function(____, object, index) return tag(
nil,
____exports.buildIsometricObject(nil, object, index),
"isometric",
object.id,
"isometric",
object.text or "Isometric object",
object.parentFrameId
) end
)
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.artifacts.link.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.artifacts.link.endpointLabels"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringTrim = ____lualib.__TS__StringTrim
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local function endpointLabelPosition(self, points, ____end)
local index = ____end == "start" and 0 or #points - 2
local neighbor = ____end == "start" and 2 or #points - 4
local x = points[index + 1]
local y = points[index + 1 + 1]
local dx = points[neighbor + 1] - x
local dy = points[neighbor + 1 + 1] - y
local length = __lor(
nil,
__hypot(nil, dx, dy),
function() return 1 end
)
local ux = dx / length
local uy = dy / length
return {x = x + ux * 20 - uy * 13, y = y + uy * 20 + ux * 13}
end
local function renderEndpointLabel(self, context, ____end, labelIndex)
local ____temp_11
if ____end == "start" then
local ____opt_7 = context.link.style
____temp_11 = ____opt_7 and ____opt_7.startLabel
else
local ____opt_9 = context.link.style
____temp_11 = ____opt_9 and ____opt_9.endLabel
end
local ____opt_0 = ____temp_11
if ____opt_0 ~= nil then
local ____temp_5
if ____end == "start" then
local ____opt_1 = context.link.style
____temp_5 = ____opt_1 and ____opt_1.startLabel
else
local ____opt_3 = context.link.style
____temp_5 = ____opt_3 and ____opt_3.endLabel
end
____opt_0 = __TS__StringTrim(____temp_5)
end
local label = ____opt_0
if not __t(nil, label) then
return {}
end
local ____finite_14 = finite
local ____opt_12 = context.link.style
local fontSize = ____finite_14(nil, ____opt_12 and ____opt_12.fontSize, 10)
local position = endpointLabelPosition(nil, context.points, ____end)
local width = 90
local ____temp_17 = (("link-" .. ____end) .. "-label-") .. context.link.id
local ____temp_18 = context.order + 0.55 + labelIndex * 0.01
local ____context_bounds_19 = context.bounds
local ____temp_20 = position.x - width / 2
local ____temp_21 = position.y - fontSize
local ____width_22 = width
local ____temp_23 = fontSize * 2
local ____temp_24 = {label}
local ____opt_15 = context.link.style
return {{
type = "text",
id = ____temp_17,
order = ____temp_18,
bounds = ____context_bounds_19,
x = ____temp_20,
y = ____temp_21,
width = ____width_22,
height = ____temp_23,
lines = ____temp_24,
fontFamily = ____opt_15 and ____opt_15.fontFamily or DEFAULT_FONT,
fontSize = fontSize,
fontWeight = "normal",
color = context.color,
align = "center",
verticalAlign = "middle",
lineHeight = 1.4
}}
end
function ____exports.renderEndpointLabels(self, context)
local ____array_25 = __TS__SparseArrayNew(table.unpack(renderEndpointLabel(nil, context, "start", 0)))
__TS__SparseArrayPush(
____array_25,
table.unpack(renderEndpointLabel(nil, context, "end", 1))
)
return {__TS__SparseArraySpread(____array_25)}
end
return ____exports
end,
["core.renderScene.artifacts.link.label"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
function ____exports.renderMainLabel(self, context)
if not context.label.visible then
return {}
end
local ____temp_2 = "link-text-" .. context.link.id
local ____temp_3 = context.order + 0.5
local ____context_bounds_4 = context.bounds
local ____temp_5 = context.midpoint.x - context.label.width / 2
local ____temp_6 = context.midpoint.y - context.label.fontSize
local ____context_label_width_7 = context.label.width
local ____temp_8 = context.label.fontSize * 2
local ____context_label_lines_9 = context.label.lines
local ____opt_0 = context.link.style
return {{
type = "text",
id = ____temp_2,
order = ____temp_3,
bounds = ____context_bounds_4,
x = ____temp_5,
y = ____temp_6,
width = ____context_label_width_7,
height = ____temp_8,
lines = ____context_label_lines_9,
fontFamily = ____opt_0 and ____opt_0.fontFamily or DEFAULT_FONT,
fontSize = context.label.fontSize,
fontWeight = "normal",
color = context.color,
align = "center",
verticalAlign = "middle",
lineHeight = 1.4
}}
end
return ____exports
end,
["core.model.geometry.axisPosition"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.relativePositionOnAxis(self, axisStart, axisEnd, point)
local deltaX = axisEnd.x - axisStart.x
local deltaY = axisEnd.y - axisStart.y
local lengthSquared = deltaX * deltaX + deltaY * deltaY
if lengthSquared == 0 then
return 0
end
local relativePosition = ((point.x - axisStart.x) * deltaX + (point.y - axisStart.y) * deltaY) / lengthSquared
return math.max(
0,
math.min(1, relativePosition)
)
end
return ____exports
end,
["core.renderScene.scene.linkPaint"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local isGradientWithStops
local ______shims = require("core.__shims")
local __land = ______shims.__land
local __t = ______shims.__t
local ____color = require("core.model.color.index")
local interpolateHexColorStops = ____color.interpolateHexColorStops
local ____axisPosition = require("core.model.geometry.axisPosition")
local relativePositionOnAxis = ____axisPosition.relativePositionOnAxis
function isGradientWithStops(self, colorValue)
return Boolean(
nil,
__land(
nil,
__land(
nil,
__land(
nil,
colorValue,
function() return type(colorValue) == "table" end
),
function() return colorValue.type == "gradient" end
),
function()
local ____opt_6 = colorValue.stops
if ____opt_6 ~= nil then
____opt_6 = ____opt_6.length
end
return ____opt_6
end
)
)
end
function ____exports.getLinkStrokeColor(self, colorValue)
if not __t(nil, colorValue) then
return nil
end
if type(colorValue) == "string" then
return colorValue
end
if colorValue.type == "gradient" then
local ____opt_2 = colorValue.stops
local ____opt_0 = ____opt_2 and ____opt_2[1]
return ____opt_0 and ____opt_0.color
end
if colorValue.type == "solid" then
return colorValue.color
end
return nil
end
function ____exports.getLinkEndpointColor(self, colorValue, ____end)
if isGradientWithStops(nil, colorValue) then
return ____end == "start" and colorValue.stops[1].color or colorValue.stops[#colorValue.stops].color
end
return ____exports.getLinkStrokeColor(nil, colorValue)
end
function ____exports.getLinkColorAtPoint(self, colorValue, points, point)
if not isGradientWithStops(nil, colorValue) then
return ____exports.getLinkStrokeColor(nil, colorValue)
end
if #points < 4 then
local ____opt_4 = colorValue.stops[1]
return ____opt_4 and ____opt_4.color
end
local axisStart = {x = points[1], y = points[2]}
local axisEnd = {x = points[#points - 2 + 1], y = points[#points]}
local relativePosition = relativePositionOnAxis(nil, axisStart, axisEnd, point)
return interpolateHexColorStops(nil, colorValue.stops, relativePosition * 100)
end
return ____exports
end,
["core.renderScene.scene.linkStroke"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
____exports.getLinkGradientStrokeProps = function(____, colorValue, points)
if not __t(nil, colorValue) or type(colorValue) == "string" or colorValue.type ~= "gradient" then
return {}
end
if #points < 4 then
return {}
end
local colorStops = {}
__TS__ArrayForEach(
colorValue.stops,
function(____, stop)
colorStops[#colorStops + 1] = stop.position / 100
colorStops[#colorStops + 1] = stop.color
end
)
return {strokeLinearGradientStartPoint = {x = points[1], y = points[2]}, strokeLinearGradientEndPoint = {x = points[#points - 2 + 1], y = points[#points]}, strokeLinearGradientColorStops = colorStops}
end
____exports.getDashArray = function(____, strokeWidth, strokeStyle)
repeat
local ____switch7 = strokeStyle
local ____cond7 = ____switch7 == "dashed"
if ____cond7 then
return {strokeWidth * 8, strokeWidth * 4}
end
____cond7 = ____cond7 or ____switch7 == "dotted"
if ____cond7 then
return {strokeWidth * 2, strokeWidth * 3}
end
____cond7 = ____cond7 or ____switch7 == "solid"
do
return nil
end
until true
end
return ____exports
end,
["core.renderScene.scene.textLayout"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__StringSlice = ____lualib.__TS__StringSlice
local ____exports = {}
local PLAIN_CHAR_FACTOR, BOLD_CHAR_FACTOR
local ______shims = require("core.__shims")
local __re = ______shims.__re
local __split = ______shims.__split
local __t = ______shims.__t
function ____exports.estimateTextWidth(self, text, fontSize, bold)
return #text * fontSize * (bold and BOLD_CHAR_FACTOR or PLAIN_CHAR_FACTOR)
end
PLAIN_CHAR_FACTOR = 0.58
BOLD_CHAR_FACTOR = 0.64
function ____exports.wrapText(self, text, width, fontSize, metrics)
local maxChars = math.max(
1,
math.floor(width / math.max(1, fontSize * PLAIN_CHAR_FACTOR))
)
local fits = metrics and (function(____, line, word) return metrics:measure(line, false) + metrics.spaceWidth + metrics:measure(word, false) <= width end) or (function(____, line, word) return #((line .. " ") .. word) <= maxChars end)
local result = {}
for ____, rawLine in ipairs(__TS__StringSplit(text, "\n")) do
do
local words = __TS__ArrayFilter(
__split(
nil,
rawLine,
__re(nil, "\\s+", "")
),
Boolean
)
if not __t(nil, #words) then
result[#result + 1] = ""
goto __continue5
end
local line = ""
for ____, word in ipairs(words) do
if not __t(nil, line) then
line = word
elseif fits(nil, line, word) then
line = line .. " " .. word
else
result[#result + 1] = line
line = word
end
end
result[#result + 1] = line
end
::__continue5::
end
return result
end
function ____exports.ellipsizeToWidth(self, text, width, fontSize, bold)
if ____exports.estimateTextWidth(nil, text, fontSize, bold) <= width then
return text
end
local ____end = #text
while ____end > 1 and ____exports.estimateTextWidth(
nil,
__TS__StringSlice(text, 0, ____end) .. "…",
fontSize,
bold
) > width do
____end = ____end - 1
end
return __TS__StringSlice(text, 0, ____end) .. "…"
end
function ____exports.heuristicRichMeasure(self, fontSize)
return {
measure = function(____, text, bold) return ____exports.estimateTextWidth(nil, text, fontSize, bold) end,
spaceWidth = fontSize * PLAIN_CHAR_FACTOR
}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.label.pathMetrics"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
____exports.lerpPoint = function(____, a, b, t) return {x = a.x + (b.x - a.x) * t, y = a.y + (b.y - a.y) * t} end
function ____exports.cubicBezierPoint(self, p0, p1, p2, p3, t)
local mt = 1 - t
return {x = mt * mt * mt * p0.x + 3 * mt * mt * t * p1.x + 3 * mt * t * t * p2.x + t * t * t * p3.x, y = mt * mt * mt * p0.y + 3 * mt * mt * t * p1.y + 3 * mt * t * t * p2.y + t * t * t * p3.y}
end
function ____exports.splitCubicBezier(self, p0, p1, p2, p3, t)
local a = ____exports.lerpPoint(nil, p0, p1, t)
local b = ____exports.lerpPoint(nil, p1, p2, t)
local c = ____exports.lerpPoint(nil, p2, p3, t)
local d = ____exports.lerpPoint(nil, a, b, t)
local e = ____exports.lerpPoint(nil, b, c, t)
local f = ____exports.lerpPoint(nil, d, e, t)
return {left = {p0, a, d, f}, right = {f, e, c, p3}}
end
function ____exports.pointAtArcLength(self, points, targetLength)
local lastIndex = #points - 2
if targetLength <= 0 then
return {point = {x = points[1], y = points[2]}, segmentIndex = 0}
end
local accumulated = 0
do
local index = 0
while index < lastIndex do
local start = {x = points[index + 1], y = points[index + 1 + 1]}
local ____end = {x = points[index + 2 + 1], y = points[index + 3 + 1]}
local length = __hypot(nil, ____end.x - start.x, ____end.y - start.y)
if accumulated + length >= targetLength then
local ratio = length == 0 and 0 or (targetLength - accumulated) / length
return {
point = ____exports.lerpPoint(nil, start, ____end, ratio),
segmentIndex = index
}
end
accumulated = accumulated + length
index = index + 2
end
end
return {point = {x = points[lastIndex + 1], y = points[lastIndex + 1 + 1]}, segmentIndex = lastIndex}
end
function ____exports.polylineLength(self, points)
local total = 0
do
local index = 0
while index < #points - 2 do
total = total + __hypot(nil, points[index + 2 + 1] - points[index + 1], points[index + 3 + 1] - points[index + 1 + 1])
index = index + 2
end
end
return total
end
function ____exports.bezierArcLength(self, p0, p1, p2, p3, samples)
if samples == nil then
samples = 40
end
local total = 0
local previous = p0
do
local index = 1
while index <= samples do
local point = ____exports.cubicBezierPoint(
nil,
p0,
p1,
p2,
p3,
index / samples
)
total = total + __hypot(nil, point.x - previous.x, point.y - previous.y)
previous = point
index = index + 1
end
end
return total
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.label.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.artifacts.link.geometry.label.curvedGap"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local curvedControlPoints, curvedPathBeforeGap, curvedPathAfterGap
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __lor = ______shims.__lor
local ____pathMetrics = require("core.renderScene.artifacts.link.geometry.label.pathMetrics")
local cubicBezierPoint = ____pathMetrics.cubicBezierPoint
local splitCubicBezier = ____pathMetrics.splitCubicBezier
function curvedControlPoints(self, flatPoints)
return {{x = flatPoints[1], y = flatPoints[2]}, {x = flatPoints[3], y = flatPoints[4]}, {x = flatPoints[5], y = flatPoints[6]}, {x = flatPoints[7], y = flatPoints[8]}}
end
function curvedPathBeforeGap(self, points, parameter)
if parameter <= 0.01 then
return nil
end
local ____splitCubicBezier_3 = splitCubicBezier
local ____array_2 = __TS__SparseArrayNew(
nil,
table.unpack(points)
)
__TS__SparseArrayPush(____array_2, parameter)
return __TS__ArrayFlatMap(
____splitCubicBezier_3(__TS__SparseArraySpread(____array_2)).left,
function(____, point) return {point.x, point.y} end
)
end
function curvedPathAfterGap(self, points, parameter)
if parameter >= 0.99 then
return nil
end
local ____splitCubicBezier_5 = splitCubicBezier
local ____array_4 = __TS__SparseArrayNew(
nil,
table.unpack(points)
)
__TS__SparseArrayPush(____array_4, parameter)
return __TS__ArrayFlatMap(
____splitCubicBezier_5(__TS__SparseArraySpread(____array_4)).right,
function(____, point) return {point.x, point.y} end
)
end
local SAMPLES = 40
local function sampledArcLengths(self, points)
local lengths = {0}
local previous = points[1]
do
local index = 1
while index <= SAMPLES do
local ____cubicBezierPoint_1 = cubicBezierPoint
local ____array_0 = __TS__SparseArrayNew(
nil,
table.unpack(points)
)
__TS__SparseArrayPush(____array_0, index / SAMPLES)
local point = ____cubicBezierPoint_1(__TS__SparseArraySpread(____array_0))
lengths[#lengths + 1] = lengths[index] + __hypot(nil, point.x - previous.x, point.y - previous.y)
previous = point
index = index + 1
end
end
return lengths
end
local function parameterAtLength(self, lengths, target)
local total = lengths[SAMPLES + 1]
if target <= 0 then
return 0
end
if target >= total then
return 1
end
do
local index = 1
while index <= SAMPLES do
if lengths[index + 1] >= target then
local fraction = (target - lengths[index]) / __lor(
nil,
lengths[index + 1] - lengths[index],
function() return 1 end
)
return (index - 1 + fraction) / SAMPLES
end
index = index + 1
end
end
return 1
end
local function projectedGapHalfLength(self, points, clearance, maximum)
local p0, p1, p2, p3 = table.unpack(points, 1, 4)
local dx = 0.75 * (p1.x - p0.x) + 1.5 * (p2.x - p1.x) + 0.75 * (p3.x - p2.x)
local dy = 0.75 * (p1.y - p0.y) + 1.5 * (p2.y - p1.y) + 0.75 * (p3.y - p2.y)
local length = __hypot(nil, dx, dy)
local ux = length == 0 and 1 or math.abs(dx) / length
local uy = length == 0 and 0 or math.abs(dy) / length
return math.min(clearance.halfWidth * ux + clearance.halfHeight * uy, maximum)
end
function ____exports.splitCurvedPath(self, flatPoints, clearance)
if #flatPoints < 8 then
return nil
end
local points = curvedControlPoints(nil, flatPoints)
local lengths = sampledArcLengths(nil, points)
local total = lengths[SAMPLES + 1]
if total == 0 then
return nil
end
local half = total / 2
local maximumGap = math.max(0, half - clearance.minimumVisibleStub)
local gapHalfLength = projectedGapHalfLength(nil, points, clearance, maximumGap)
local beforeParameter = parameterAtLength(nil, lengths, half - gapHalfLength)
local afterParameter = parameterAtLength(nil, lengths, half + gapHalfLength)
return {
before = curvedPathBeforeGap(nil, points, beforeParameter),
after = curvedPathAfterGap(nil, points, afterParameter),
bezier = true
}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.label.polylineGap"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local polylineGapPlacement, projectedPolylineGap, polylineBeforeGap, polylineAfterGap
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local ____pathMetrics = require("core.renderScene.artifacts.link.geometry.label.pathMetrics")
local pointAtArcLength = ____pathMetrics.pointAtArcLength
local polylineLength = ____pathMetrics.polylineLength
function polylineGapPlacement(self, points, totalLength, clearance)
local half = totalLength / 2
local midpoint = pointAtArcLength(nil, points, half)
local start = {x = points[midpoint.segmentIndex + 1], y = points[midpoint.segmentIndex + 1 + 1]}
local ____end = {x = points[midpoint.segmentIndex + 2 + 1], y = points[midpoint.segmentIndex + 3 + 1]}
local gapHalfLength = projectedPolylineGap(
nil,
start,
____end,
clearance,
half
)
return {beforeLength = half - gapHalfLength, afterLength = half + gapHalfLength}
end
function projectedPolylineGap(self, start, ____end, clearance, halfLength)
local segmentLength = __hypot(nil, ____end.x - start.x, ____end.y - start.y)
local horizontalShare = segmentLength == 0 and 1 or math.abs(____end.x - start.x) / segmentLength
local verticalShare = segmentLength == 0 and 0 or math.abs(____end.y - start.y) / segmentLength
local projectedClearance = clearance.halfWidth * horizontalShare + clearance.halfHeight * verticalShare
return math.min(
projectedClearance,
math.max(0, halfLength - clearance.minimumVisibleStub)
)
end
function polylineBeforeGap(self, points, splitLength)
if splitLength <= 0.5 then
return nil
end
local split = pointAtArcLength(nil, points, splitLength)
local ____array_0 = __TS__SparseArrayNew(table.unpack(__TS__ArraySlice(points, 0, split.segmentIndex + 2)))
__TS__SparseArrayPush(____array_0, split.point.x, split.point.y)
return {__TS__SparseArraySpread(____array_0)}
end
function polylineAfterGap(self, points, splitLength, totalLength)
if splitLength >= totalLength - 0.5 then
return nil
end
local split = pointAtArcLength(nil, points, splitLength)
return {
split.point.x,
split.point.y,
table.unpack(__TS__ArraySlice(points, split.segmentIndex + 2))
}
end
function ____exports.splitPolylinePath(self, points, clearance)
if #points < 4 then
return nil
end
local total = polylineLength(nil, points)
if total == 0 then
return nil
end
local placement = polylineGapPlacement(nil, points, total, clearance)
return {
before = polylineBeforeGap(nil, points, placement.beforeLength),
after = polylineAfterGap(nil, points, placement.afterLength, total),
bezier = false
}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.label.gap"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____curvedGap = require("core.renderScene.artifacts.link.geometry.label.curvedGap")
local splitCurvedPath = ____curvedGap.splitCurvedPath
local ____pathMetrics = require("core.renderScene.artifacts.link.geometry.label.pathMetrics")
local bezierArcLength = ____pathMetrics.bezierArcLength
local polylineLength = ____pathMetrics.polylineLength
local ____polylineGap = require("core.renderScene.artifacts.link.geometry.label.polylineGap")
local splitPolylinePath = ____polylineGap.splitPolylinePath
local LABEL_GAP_PADDING = 3
local MIN_VISIBLE_STUB = 10
local function bezierPoints(self, points)
return {{x = points[1], y = points[2]}, {x = points[3], y = points[4]}, {x = points[5], y = points[6]}, {x = points[7], y = points[8]}}
end
local function pathLength(self, points, bezier)
if bezier then
return bezierArcLength(
nil,
table.unpack(bezierPoints(nil, points))
)
end
return polylineLength(nil, points)
end
function ____exports.splitPathAroundLabel(self, points, pathType, gapWidth, gapHeight)
local clearance = {halfWidth = (gapWidth + LABEL_GAP_PADDING) / 2, halfHeight = (gapHeight + LABEL_GAP_PADDING) / 2, minimumVisibleStub = MIN_VISIBLE_STUB}
if pathType == "curved" then
return splitCurvedPath(nil, points, clearance)
end
return splitPolylinePath(nil, points, clearance)
end
function ____exports.labelGapDash(self, points, pathType, gapWidth, gapHeight)
local split = ____exports.splitPathAroundLabel(
nil,
points,
pathType,
gapWidth,
gapHeight
)
if not split or not split.before and not split.after then
return nil
end
local totalLength = pathLength(nil, points, split.bezier)
local dashBefore = split.before and pathLength(nil, split.before, split.bezier) or 0
local afterLength = split.after and pathLength(nil, split.after, split.bezier) or 0
local gapLength = math.max(0, totalLength - dashBefore - afterLength)
if gapLength <= 0 then
return nil
end
return {dashBefore = dashBefore, gapLength = gapLength}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.label.measurement"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local LABEL_MAX_WIDTH = 250
local LABEL_CHAR_WIDTH_RATIO = 0.65
local LABEL_LINE_HEIGHT_RATIO = 1.4
function ____exports.measureLinkLabel(self, text, fontSize)
local charWidth = fontSize * LABEL_CHAR_WIDTH_RATIO
local lineHeight = fontSize * LABEL_LINE_HEIGHT_RATIO
local lines = __TS__StringSplit(text, "\n")
local maxLineLength = math.max(table.unpack(__TS__ArrayMap(
lines,
function(____, line) return #line end
)))
local width = math.max(
fontSize * 1.8,
math.min(LABEL_MAX_WIDTH, maxLineLength * charWidth + 10)
)
local lineCount = __TS__ArrayReduce(
lines,
function(____, total, line) return total + math.max(
1,
math.ceil(#line * charWidth / LABEL_MAX_WIDTH)
) end,
0
)
return {
width = width,
height = math.max(lineHeight + 2, lineCount * lineHeight + 4)
}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.labels"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____gap = require("core.renderScene.artifacts.link.geometry.label.gap")
____exports.labelGapDash = ____gap.labelGapDash
____exports.splitPathAroundLabel = ____gap.splitPathAroundLabel
end
do
local ____measurement = require("core.renderScene.artifacts.link.geometry.label.measurement")
____exports.measureLinkLabel = ____measurement.measureLinkLabel
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.markers.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.artifacts.link.geometry.markers.arrowPoints"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local function shortenedArrowSegment(self, endpoint, neighbor)
local dx = endpoint.x - neighbor.x
local dy = endpoint.y - neighbor.y
local length = math.sqrt(dx * dx + dy * dy)
if length <= 0 then
return {neighbor.x, neighbor.y, endpoint.x, endpoint.y}
end
return {endpoint.x - dx / length * 8, endpoint.y - dy / length * 8, endpoint.x, endpoint.y}
end
local function curvedArrowPoints(self, points, direction)
if direction == "forward" then
local last = #points - 2
return shortenedArrowSegment(nil, {x = points[last + 1], y = points[last + 1 + 1]}, {x = points[last - 2 + 1], y = points[last]})
end
return shortenedArrowSegment(nil, {x = points[1], y = points[2]}, {x = points[3], y = points[4]})
end
local function linearArrowPoints(self, points, direction, from, to)
if direction == "forward" then
if #points >= 4 then
return {points[#points - 4 + 1], points[#points - 3 + 1], points[#points - 2 + 1], points[#points]}
end
return {
__lor(
nil,
points[1],
function() return from.x end
),
__lor(
nil,
points[2],
function() return from.y end
),
__lor(
nil,
points[3],
function() return to.x end
),
__lor(
nil,
points[4],
function() return to.y end
)
}
end
return {
__lor(
nil,
points[3],
function() return to.x end
),
__lor(
nil,
points[4],
function() return to.y end
),
__lor(
nil,
points[1],
function() return from.x end
),
__lor(
nil,
points[2],
function() return from.y end
)
}
end
function ____exports.getArrowPoints(self, points, pathType, direction, from, to)
if pathType == "curved" then
return curvedArrowPoints(nil, points, direction)
end
return linearArrowPoints(
nil,
points,
direction,
from,
to
)
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.markers.endpoints"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____arrowPoints = require("core.renderScene.artifacts.link.geometry.markers.arrowPoints")
local getArrowPoints = ____arrowPoints.getArrowPoints
function ____exports.getActualArrowEndpoints(self, points, pathType, from, to)
local forwardArrow = getArrowPoints(
nil,
points,
pathType,
"forward",
from,
to
)
local backwardArrow = getArrowPoints(
nil,
points,
pathType,
"backward",
from,
to
)
return {actualFrom = {x = backwardArrow[3], y = backwardArrow[4]}, actualTo = {x = forwardArrow[3], y = forwardArrow[4]}}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.markers.midpoint"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local function curvedMidpoint(self, points)
local x0, y0, x1, y1, x2, y2, x3, y3 = table.unpack(points, 1, 8)
local t = 0.5
local mt = 1 - t
return {x = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3, y = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3}
end
local function orthogonalMidpoint(self, points, fallback)
local totalLength = 0
local segments = {}
do
local index = 0
while index < #points - 2 do
local start = {x = points[index + 1], y = points[index + 1 + 1]}
local ____end = {x = points[index + 2 + 1], y = points[index + 3 + 1]}
local length = math.sqrt((____end.x - start.x) ^ 2 + (____end.y - start.y) ^ 2)
totalLength = totalLength + length
segments[#segments + 1] = {start = start, ["end"] = ____end, length = length}
index = index + 2
end
end
local halfLength = totalLength / 2
local accumulatedLength = 0
for ____, segment in ipairs(segments) do
if accumulatedLength + segment.length >= halfLength then
local ratio = (halfLength - accumulatedLength) / segment.length
return {x = segment.start.x + ratio * (segment["end"].x - segment.start.x), y = segment.start.y + ratio * (segment["end"].y - segment.start.y)}
end
accumulatedLength = accumulatedLength + segment.length
end
return fallback
end
function ____exports.getLineMidpoint(self, points, pathType, effectiveFrom, effectiveTo)
if pathType == "curved" then
return curvedMidpoint(nil, points)
end
local fallback = {x = (effectiveFrom.x + effectiveTo.x) / 2, y = (effectiveFrom.y + effectiveTo.y) / 2}
if pathType == "orthogonal" then
return orthogonalMidpoint(nil, points, fallback)
end
return fallback
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.markers.transform"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local function endMarkerTransform(self, points)
local last = #points - 2
local x = points[last + 1]
local y = points[last + 1 + 1]
if #points < 4 then
return {x = x, y = y, rotation = 0}
end
local dx = x - points[last - 2 + 1]
local dy = y - points[last]
return {
x = x,
y = y,
rotation = math.atan(dy, dx) * (180 / math.pi)
}
end
local function startMarkerTransform(self, points)
local x = points[1]
local y = points[2]
if #points < 4 then
return {x = x, y = y, rotation = 180}
end
local dx = points[3] - x
local dy = points[4] - y
return {
x = x,
y = y,
rotation = math.atan(dy, dx) * (180 / math.pi) + 180
}
end
function ____exports.getMarkerTransform(self, points, direction)
if direction == "end" then
return endMarkerTransform(nil, points)
end
return startMarkerTransform(nil, points)
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.markers"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____arrowPoints = require("core.renderScene.artifacts.link.geometry.markers.arrowPoints")
____exports.getArrowPoints = ____arrowPoints.getArrowPoints
end
do
local ____endpoints = require("core.renderScene.artifacts.link.geometry.markers.endpoints")
____exports.getActualArrowEndpoints = ____endpoints.getActualArrowEndpoints
end
do
local ____midpoint = require("core.renderScene.artifacts.link.geometry.markers.midpoint")
____exports.getLineMidpoint = ____midpoint.getLineMidpoint
end
do
local ____transform = require("core.renderScene.artifacts.link.geometry.markers.transform")
____exports.getMarkerTransform = ____transform.getMarkerTransform
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.sideNormal"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.sideNormal(self, side)
repeat
local ____switch3 = side
local ____cond3 = ____switch3 == "top"
if ____cond3 then
return {0, -1}
end
____cond3 = ____cond3 or ____switch3 == "right"
if ____cond3 then
return {1, 0}
end
____cond3 = ____cond3 or ____switch3 == "bottom"
if ____cond3 then
return {0, 1}
end
____cond3 = ____cond3 or ____switch3 == "left"
if ____cond3 then
return {-1, 0}
end
until true
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.cubic"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____sideNormal = require("core.renderScene.artifacts.link.geometry.routing.sideNormal")
local sideNormal = ____sideNormal.sideNormal
local function controlDistances(self, from, to, fromNormal, toNormal, options)
local minimum = options and options.min or 50
local maximum = options and options.max or 240
local perpendicularScale = options and options.perpendicularScale or 0.9
local deltaX = to.x - from.x
local deltaY = to.y - from.y
local alongFrom = math.abs(deltaX * fromNormal[1] + deltaY * fromNormal[2])
local alongTo = math.abs(deltaX * toNormal[1] + deltaY * toNormal[2])
local perpendicularFrom = math.abs(deltaX * fromNormal[2] - deltaY * fromNormal[1])
local perpendicularTo = math.abs(deltaX * toNormal[2] - deltaY * toNormal[1])
local parallel = fromNormal[1] == toNormal[1] and fromNormal[2] == toNormal[2] or fromNormal[1] == -toNormal[1] and fromNormal[2] == -toNormal[2]
local fromDistance = math.max(
minimum,
math.min(
maximum,
math.max(alongFrom, perpendicularFrom * perpendicularScale)
)
)
local toDistance = math.max(
minimum,
math.min(
maximum,
math.max(alongTo, perpendicularTo * perpendicularScale)
)
)
if parallel then
fromDistance = math.min(maximum, fromDistance + perpendicularFrom * 0.75)
toDistance = math.min(maximum, toDistance + perpendicularTo * 0.75)
end
return {fromDistance = fromDistance, toDistance = toDistance}
end
function ____exports.routeCubic(self, from, to, fromSide, toSide, options)
local fromNormal = sideNormal(nil, fromSide)
local toNormal = sideNormal(nil, toSide)
local ____controlDistances_result_6 = controlDistances(
nil,
from,
to,
fromNormal,
toNormal,
options
)
local fromDistance = ____controlDistances_result_6.fromDistance
local toDistance = ____controlDistances_result_6.toDistance
return {p0 = {from.x, from.y}, p1 = {from.x + fromNormal[1] * fromDistance, from.y + fromNormal[2] * fromDistance}, p2 = {to.x + toNormal[1] * toDistance, to.y + toNormal[2] * toDistance}, p3 = {to.x, to.y}}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.curvedRoute"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ____cubic = require("core.renderScene.artifacts.link.geometry.routing.cubic")
local routeCubic = ____cubic.routeCubic
function ____exports.calculateCurvedLinkRoute(self, from, to, fromSide, toSide)
local ____routeCubic_result_0 = routeCubic(
nil,
from,
to,
fromSide,
toSide,
{min = 35, max = 90, perpendicularScale = 0.5}
)
local p0 = ____routeCubic_result_0.p0
local p1 = ____routeCubic_result_0.p1
local p2 = ____routeCubic_result_0.p2
local p3 = ____routeCubic_result_0.p3
local ____array_1 = __TS__SparseArrayNew(table.unpack(p0))
__TS__SparseArrayPush(
____array_1,
table.unpack(p1)
)
__TS__SparseArrayPush(
____array_1,
table.unpack(p2)
)
__TS__SparseArrayPush(
____array_1,
table.unpack(p3)
)
return {
points = {__TS__SparseArraySpread(____array_1)},
segments = {}
}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.orthogonalPlan"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local isHorizontalSide
local ______shims = require("core.__shims")
local __t = ______shims.__t
function isHorizontalSide(self, side)
return side == "left" or side == "right"
end
function ____exports.snapAlignedEndpoints(self, from, to, fromSide, toSide)
local threshold = 6
local verticalPair = __TS__ArrayIncludes({"top", "bottom"}, fromSide) and __TS__ArrayIncludes({"top", "bottom"}, toSide)
local horizontalPair = __TS__ArrayIncludes({"left", "right"}, fromSide) and __TS__ArrayIncludes({"left", "right"}, toSide)
if verticalPair and math.abs(to.x - from.x) < threshold then
return {
from,
__TS__ObjectAssign({}, to, {x = from.x})
}
end
if horizontalPair and math.abs(to.y - from.y) < threshold then
return {
from,
__TS__ObjectAssign({}, to, {y = from.y})
}
end
return {from, to}
end
function ____exports.chooseInitialOrientation(self, from, to, endpointEdges)
if __t(nil, endpointEdges and endpointEdges.toEdge) then
return endpointEdges.toEdge == "left" or endpointEdges.toEdge == "right"
end
if __t(nil, endpointEdges and endpointEdges.fromEdge) then
return endpointEdges.fromEdge == "left" or endpointEdges.fromEdge == "right"
end
return math.abs(to.x - from.x) > math.abs(to.y - from.y)
end
function ____exports.stepOutDistances(self, from, to, fromNormal, toNormal, horizontalFirst)
local fromDistance = 40
local toDistance = 40
local axis = horizontalFirst and 0 or 1
local delta = horizontalFirst and to.x - from.x or to.y - from.y
if fromNormal[axis + 1] ~= 0 and fromNormal[axis + 1] == -toNormal[axis + 1] then
local gap = delta * fromNormal[axis + 1]
if gap > 0 and gap < fromDistance + toDistance then
fromDistance = gap / 2
toDistance = gap / 2
end
elseif fromNormal[axis + 1] == 0 then
local gap = delta * -toNormal[axis + 1]
if gap > 0 and gap < toDistance then
toDistance = gap
end
end
return {fromDistance, toDistance}
end
function ____exports.chooseBend(self, route)
local ____route_4 = route
local fromConnection = ____route_4.fromConnection
local toConnection = ____route_4.toConnection
local to = ____route_4.to
local horizontalFirst = ____route_4.horizontalFirst
local fromStub = fromConnection.stub
local toStub = toConnection.stub
local x = (fromStub[1] + toStub[1]) / 2
local y = (fromStub[2] + toStub[2]) / 2
local fromHorizontal = isHorizontalSide(nil, fromConnection.side)
local toHorizontal = isHorizontalSide(nil, toConnection.side)
if fromHorizontal ~= toHorizontal then
if horizontalFirst then
x = (fromStub[1] - to.x) * toConnection.normal[1] >= 0 and fromStub[1] or toStub[1]
else
y = (fromStub[2] - to.y) * toConnection.normal[2] >= 0 and fromStub[2] or toStub[2]
end
elseif fromConnection.side == toConnection.side then
if horizontalFirst then
x = fromConnection.normal[1] < 0 and math.min(fromStub[1], toStub[1]) or math.max(fromStub[1], toStub[1])
else
y = fromConnection.normal[2] < 0 and math.min(fromStub[2], toStub[2]) or math.max(fromStub[2], toStub[2])
end
end
return {x, y}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.orthogonalPoints"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
function ____exports.segmentMidpoints(self, points)
local midpoints = {}
do
local index = 0
while index < #points - 2 do
midpoints[#midpoints + 1] = {x = (points[index + 1] + points[index + 2 + 1]) / 2, y = (points[index + 1 + 1] + points[index + 3 + 1]) / 2}
index = index + 2
end
end
return midpoints
end
function ____exports.baseOrthogonalPoints(self, route, bend)
local ____route_0 = route
local from = ____route_0.from
local to = ____route_0.to
local fromConnection = ____route_0.fromConnection
local toConnection = ____route_0.toConnection
local horizontalFirst = ____route_0.horizontalFirst
local fromStub = fromConnection.stub
local toStub = toConnection.stub
local points = {from.x, from.y, fromStub[1], fromStub[2]}
if horizontalFirst then
__TS__ArrayPush(
points,
bend[1],
fromStub[2],
bend[1],
toStub[2]
)
else
__TS__ArrayPush(
points,
fromStub[1],
bend[2],
toStub[1],
bend[2]
)
end
__TS__ArrayPush(
points,
toStub[1],
toStub[2],
to.x,
to.y
)
return points
end
function ____exports.movableInnerSegments(self, horizontalFirst, fromSide, toSide)
local fixedSides = horizontalFirst and ({"left", "right"}) or ({"top", "bottom"})
return {
not __TS__ArrayIncludes(fixedSides, fromSide),
not __TS__ArrayIncludes(fixedSides, toSide)
}
end
function ____exports.offsetOrthogonalPoints(self, route, bend, segmentOffsets, movable)
local ____route_1 = route
local from = ____route_1.from
local to = ____route_1.to
local fromConnection = ____route_1.fromConnection
local toConnection = ____route_1.toConnection
local horizontalFirst = ____route_1.horizontalFirst
local fromStub = fromConnection.stub
local toStub = toConnection.stub
local first = movable[1] and __lor(
nil,
segmentOffsets and segmentOffsets[2],
function() return 0 end
) or 0
local middle = __lor(
nil,
segmentOffsets and segmentOffsets[3],
function() return 0 end
)
local last = movable[2] and __lor(
nil,
segmentOffsets and segmentOffsets[4],
function() return 0 end
) or 0
if horizontalFirst then
local fromY = fromStub[2] + first
local bendX = bend[1] + middle
local toY = toStub[2] + last
return {
from.x,
from.y,
fromStub[1],
fromY,
bendX,
fromY,
bendX,
toY,
toStub[1],
toY,
to.x,
to.y
}
end
local fromX = fromStub[1] + first
local bendY = bend[2] + middle
local toX = toStub[1] + last
return {
from.x,
from.y,
fromX,
fromStub[2],
fromX,
bendY,
toX,
bendY,
toX,
toStub[2],
to.x,
to.y
}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.orthogonalSegments"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
function ____exports.describeSegments(self, points, originalMidpoints, canMoveFirstInner, canMoveLastInner)
local totalSegments = (#points - 2) / 2
return __TS__ArrayMap(
originalMidpoints,
function(____, originalMidpoint, segmentIndex)
local offset = segmentIndex * 2
local start = {x = points[offset + 1], y = points[offset + 1 + 1]}
local ____end = {x = points[offset + 2 + 1], y = points[offset + 3 + 1]}
local midpoint = {x = (start.x + ____end.x) / 2, y = (start.y + ____end.y) / 2}
local isInner = segmentIndex > 0 and segmentIndex < totalSegments - 1
local ____temp_1
if segmentIndex == 1 then
____temp_1 = canMoveFirstInner
else
local ____temp_0
if segmentIndex == totalSegments - 2 then
____temp_0 = canMoveLastInner
else
____temp_0 = true
end
____temp_1 = ____temp_0
end
local isMovableEdge = ____temp_1
local hasLength = __hypot(nil, ____end.x - start.x, ____end.y - start.y) >= 1
return {
start = start,
["end"] = ____end,
midpoint = midpoint,
originalMidpoint = originalMidpoint,
isHorizontal = math.abs(____end.x - start.x) > math.abs(____end.y - start.y),
canMove = isInner and isMovableEdge and hasLength
}
end
)
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.rounding"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__MathSign = ____lualib.__TS__MathSign
local ____exports = {}
local createRoundedCorner, offsetPoint, axisLength, axisDirection, normalizedAngleSweep, sampleRoundedCorner, coordinatePoints, CORNER_SAMPLE_COUNT
function createRoundedCorner(self, previous, corner, next, maximumRadius)
local incoming = {x = corner.x - previous.x, y = corner.y - previous.y}
local outgoing = {x = next.x - corner.x, y = next.y - corner.y}
local incomingIsAxisAligned = incoming.x == 0 or incoming.y == 0
local outgoingIsAxisAligned = outgoing.x == 0 or outgoing.y == 0
local isStraight = incoming.x == 0 and outgoing.x == 0 or incoming.y == 0 and outgoing.y == 0
if not incomingIsAxisAligned or not outgoingIsAxisAligned or isStraight then
return nil
end
local radius = math.min(
maximumRadius,
axisLength(nil, incoming) * 0.4,
axisLength(nil, outgoing) * 0.4
)
if radius <= 0 then
return nil
end
local incomingDirection = axisDirection(nil, incoming)
local outgoingDirection = axisDirection(nil, outgoing)
local entry = offsetPoint(nil, corner, incomingDirection, -radius)
local exit = offsetPoint(nil, corner, outgoingDirection, radius)
local center = offsetPoint(nil, entry, outgoingDirection, radius)
local startAngle = math.atan(entry.y - center.y, entry.x - center.x)
local endAngle = math.atan(exit.y - center.y, exit.x - center.x)
return {
entry = entry,
exit = exit,
center = center,
radius = radius,
startAngle = startAngle,
angleSweep = normalizedAngleSweep(nil, endAngle - startAngle)
}
end
function offsetPoint(self, point, direction, distance)
return {x = point.x + direction.x * distance, y = point.y + direction.y * distance}
end
function axisLength(self, vector)
return math.abs(vector.x) + math.abs(vector.y)
end
function axisDirection(self, vector)
return {
x = vector.x ~= 0 and __TS__MathSign(vector.x) or 0,
y = vector.y ~= 0 and __TS__MathSign(vector.y) or 0
}
end
function normalizedAngleSweep(self, angle)
if angle > math.pi then
return angle - 2 * math.pi
end
if angle < -math.pi then
return angle + 2 * math.pi
end
return angle
end
function sampleRoundedCorner(self, corner)
local points = {corner.entry}
do
local sampleIndex = 1
while sampleIndex < CORNER_SAMPLE_COUNT - 1 do
local progress = sampleIndex / (CORNER_SAMPLE_COUNT - 1)
local angle = corner.startAngle + corner.angleSweep * progress
points[#points + 1] = {
x = corner.center.x + math.cos(angle) * corner.radius,
y = corner.center.y + math.sin(angle) * corner.radius
}
sampleIndex = sampleIndex + 1
end
end
points[#points + 1] = corner.exit
return points
end
function coordinatePoints(self, coordinates)
local points = {}
do
local index = 0
while index < #coordinates do
points[#points + 1] = {x = coordinates[index + 1], y = coordinates[index + 1 + 1]}
index = index + 2
end
end
return points
end
CORNER_SAMPLE_COUNT = 8
function ____exports.roundOrthogonalPoints(self, coordinates, maximumRadius)
if #coordinates < 6 then
return coordinates
end
local points = coordinatePoints(nil, coordinates)
local roundedPoints = {points[1]}
do
local index = 1
while index < #points - 1 do
local corner = createRoundedCorner(
nil,
points[index],
points[index + 1],
points[index + 1 + 1],
maximumRadius
)
__TS__ArrayPushArray(
roundedPoints,
corner and sampleRoundedCorner(nil, corner) or ({points[index + 1]})
)
index = index + 1
end
end
roundedPoints[#roundedPoints + 1] = points[#points]
return __TS__ArrayFlatMap(
roundedPoints,
function(____, point) return {point.x, point.y} end
)
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.orthogonal"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local createOrthogonalRouteDraft, createRouteConnection
local ____orthogonalPlan = require("core.renderScene.artifacts.link.geometry.routing.orthogonalPlan")
local chooseBend = ____orthogonalPlan.chooseBend
local chooseInitialOrientation = ____orthogonalPlan.chooseInitialOrientation
local snapAlignedEndpoints = ____orthogonalPlan.snapAlignedEndpoints
local stepOutDistances = ____orthogonalPlan.stepOutDistances
local ____orthogonalPoints = require("core.renderScene.artifacts.link.geometry.routing.orthogonalPoints")
local baseOrthogonalPoints = ____orthogonalPoints.baseOrthogonalPoints
local movableInnerSegments = ____orthogonalPoints.movableInnerSegments
local offsetOrthogonalPoints = ____orthogonalPoints.offsetOrthogonalPoints
local segmentMidpoints = ____orthogonalPoints.segmentMidpoints
local ____orthogonalSegments = require("core.renderScene.artifacts.link.geometry.routing.orthogonalSegments")
local describeSegments = ____orthogonalSegments.describeSegments
local ____rounding = require("core.renderScene.artifacts.link.geometry.routing.rounding")
local roundOrthogonalPoints = ____rounding.roundOrthogonalPoints
local ____sideNormal = require("core.renderScene.artifacts.link.geometry.routing.sideNormal")
local sideNormal = ____sideNormal.sideNormal
function createOrthogonalRouteDraft(self, request)
local alignedFrom, alignedTo = table.unpack(
snapAlignedEndpoints(
nil,
request.from,
request.to,
request.fromSide,
request.toSide
),
1,
2
)
local fromNormal = sideNormal(nil, request.fromSide)
local toNormal = sideNormal(nil, request.toSide)
local horizontalFirst = chooseInitialOrientation(nil, alignedFrom, alignedTo, request.endpointEdges)
local fromDistance, toDistance = table.unpack(
stepOutDistances(
nil,
alignedFrom,
alignedTo,
fromNormal,
toNormal,
horizontalFirst
),
1,
2
)
return {
from = alignedFrom,
to = alignedTo,
fromConnection = createRouteConnection(
nil,
alignedFrom,
request.fromSide,
fromNormal,
fromDistance
),
toConnection = createRouteConnection(
nil,
alignedTo,
request.toSide,
toNormal,
toDistance
),
horizontalFirst = horizontalFirst
}
end
function createRouteConnection(self, point, side, normal, distance)
return {side = side, normal = normal, stub = {point.x + normal[1] * distance, point.y + normal[2] * distance}}
end
function ____exports.routeOrthogonal(self, request)
local routeDraft = createOrthogonalRouteDraft(nil, request)
local bend = chooseBend(nil, routeDraft)
local originalPoints = baseOrthogonalPoints(nil, routeDraft, bend)
local originalSegmentMidpoints = segmentMidpoints(nil, originalPoints)
local movableSegments = movableInnerSegments(nil, routeDraft.horizontalFirst, request.fromSide, request.toSide)
local points = offsetOrthogonalPoints(
nil,
routeDraft,
bend,
request.segmentOffsets,
movableSegments
)
local segments = describeSegments(
nil,
points,
originalSegmentMidpoints,
movableSegments[1],
movableSegments[2]
)
return {
points = roundOrthogonalPoints(nil, points, 10),
segments = segments
}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.waypoints"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local ____exports = {}
local ____rounding = require("core.renderScene.artifacts.link.geometry.routing.rounding")
local roundOrthogonalPoints = ____rounding.roundOrthogonalPoints
local ORTHOGONAL_EPSILON = 0.5
function ____exports.pathFromWaypoints(self, from, waypoints, to)
local ____array_0 = __TS__SparseArrayNew(
from,
table.unpack(waypoints)
)
__TS__SparseArrayPush(____array_0, to)
local corners = {__TS__SparseArraySpread(____array_0)}
local points = {}
for ____, point in ipairs(corners) do
__TS__ArrayPush(points, point.x, point.y)
end
local segments = {}
do
local index = 0
while index < #points - 2 do
local start = {x = points[index + 1], y = points[index + 1 + 1]}
local ____end = {x = points[index + 2 + 1], y = points[index + 3 + 1]}
local midpoint = {x = (start.x + ____end.x) / 2, y = (start.y + ____end.y) / 2}
segments[#segments + 1] = {
start = start,
["end"] = ____end,
midpoint = midpoint,
originalMidpoint = midpoint,
isHorizontal = math.abs(____end.x - start.x) > math.abs(____end.y - start.y),
canMove = false
}
index = index + 2
end
end
return {
points = roundOrthogonalPoints(nil, points, 10),
segments = segments
}
end
function ____exports.isAxisAligned(self, segments)
return __TS__ArrayEvery(
segments,
function(____, segment)
local dx = math.abs(segment["end"].x - segment.start.x)
local dy = math.abs(segment["end"].y - segment.start.y)
return dx <= ORTHOGONAL_EPSILON or dy <= ORTHOGONAL_EPSILON
end
)
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.orthogonalRoute"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____orthogonal = require("core.renderScene.artifacts.link.geometry.routing.orthogonal")
local routeOrthogonal = ____orthogonal.routeOrthogonal
local ____waypoints = require("core.renderScene.artifacts.link.geometry.routing.waypoints")
local isAxisAligned = ____waypoints.isAxisAligned
local pathFromWaypoints = ____waypoints.pathFromWaypoints
function ____exports.calculateOrthogonalLinkRoute(self, link, from, to, fromSide, toSide)
if link.waypoints and #link.waypoints > 0 then
local waypointResult = pathFromWaypoints(nil, from, link.waypoints, to)
if isAxisAligned(nil, waypointResult.segments) then
return waypointResult
end
end
local endpointEdges = {fromEdge = fromSide, toEdge = toSide}
local request = {
from = from,
to = to,
fromSide = fromSide,
toSide = toSide,
segmentOffsets = link.segmentOffsets,
endpointEdges = endpointEdges
}
local route = routeOrthogonal(nil, request)
if isAxisAligned(nil, route.segments) then
return route
end
return routeOrthogonal(
nil,
__TS__ObjectAssign({}, request, {segmentOffsets = nil})
)
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.sides"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local function facingSide(self, from, to)
local angle = math.atan(to.y - from.y, to.x - from.x)
if angle >= -math.pi / 4 and angle < math.pi / 4 then
return "right"
end
if angle >= math.pi / 4 and angle < 3 * math.pi / 4 then
return "bottom"
end
if angle >= -3 * math.pi / 4 and angle < -math.pi / 4 then
return "top"
end
return "left"
end
function ____exports.connectionSides(self, link, from, to)
local ____opt_0 = link.fromPoint
local fromSide = (____opt_0 and ____opt_0.kind) == "side" and link.fromPoint.side or facingSide(nil, from, to)
local ____opt_2 = link.toPoint
local toSide = (____opt_2 and ____opt_2.kind) == "side" and link.toPoint.side or facingSide(nil, to, from)
return {fromSide = fromSide, toSide = toSide}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing.straightRoute"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.calculateStraightLinkRoute(self, from, to)
return {points = {from.x, from.y, to.x, to.y}, segments = {}}
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.routing"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____curvedRoute = require("core.renderScene.artifacts.link.geometry.routing.curvedRoute")
local calculateCurvedLinkRoute = ____curvedRoute.calculateCurvedLinkRoute
local ____orthogonalRoute = require("core.renderScene.artifacts.link.geometry.routing.orthogonalRoute")
local calculateOrthogonalLinkRoute = ____orthogonalRoute.calculateOrthogonalLinkRoute
local ____sides = require("core.renderScene.artifacts.link.geometry.routing.sides")
local connectionSides = ____sides.connectionSides
local ____straightRoute = require("core.renderScene.artifacts.link.geometry.routing.straightRoute")
local calculateStraightLinkRoute = ____straightRoute.calculateStraightLinkRoute
function ____exports.calculateLinkRoute(self, link, effectiveFrom, effectiveTo, pathType)
local ____connectionSides_result_0 = connectionSides(nil, link, effectiveFrom, effectiveTo)
local fromSide = ____connectionSides_result_0.fromSide
local toSide = ____connectionSides_result_0.toSide
if pathType == "curved" then
return calculateCurvedLinkRoute(
nil,
effectiveFrom,
effectiveTo,
fromSide,
toSide
)
end
if pathType == "orthogonal" then
return calculateOrthogonalLinkRoute(
nil,
link,
effectiveFrom,
effectiveTo,
fromSide,
toSide
)
end
return calculateStraightLinkRoute(nil, effectiveFrom, effectiveTo)
end
return ____exports
end,
["core.renderScene.artifacts.link.geometry.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____export = require("core.renderScene.artifacts.link.geometry.labels")
for ____exportKey, ____exportValue in pairs(____export) do
if ____exportKey ~= "default" then
____exports[____exportKey] = ____exportValue
end
end
end
do
local ____export = require("core.renderScene.artifacts.link.geometry.markers")
for ____exportKey, ____exportValue in pairs(____export) do
if ____exportKey ~= "default" then
____exports[____exportKey] = ____exportValue
end
end
end
do
local ____export = require("core.renderScene.artifacts.link.geometry.routing")
for ____exportKey, ____exportValue in pairs(____export) do
if ____exportKey ~= "default" then
____exports[____exportKey] = ____exportValue
end
end
end
return ____exports
end,
["core.renderScene.artifacts.link.layout"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local ____linkPaint = require("core.renderScene.scene.linkPaint")
local getLinkStrokeColor = ____linkPaint.getLinkStrokeColor
local ____linkStroke = require("core.renderScene.scene.linkStroke")
local getDashArray = ____linkStroke.getDashArray
local ____shadow = require("core.renderScene.scene.shadow")
local resolveShadow = ____shadow.resolveShadow
local ____textLayout = require("core.renderScene.scene.textLayout")
local wrapText = ____textLayout.wrapText
local ____geometry = require("core.renderScene.artifacts.link.geometry.index")
local calculateLinkRoute = ____geometry.calculateLinkRoute
local getLineMidpoint = ____geometry.getLineMidpoint
local labelGapDash = ____geometry.labelGapDash
local function linkBounds(self, points, padding)
local xs = __TS__ArrayFilter(
points,
function(____, _, index) return index % 2 == 0 end
)
local ys = __TS__ArrayFilter(
points,
function(____, _, index) return index % 2 == 1 end
)
return {
minX = math.min(table.unpack(xs)) - padding,
minY = math.min(table.unpack(ys)) - padding,
maxX = math.max(table.unpack(xs)) + padding,
maxY = math.max(table.unpack(ys)) + padding
}
end
local function labelLayout(self, link, measureText)
local visible = Boolean(nil, link.showText and link.text)
local ____finite_2 = finite
local ____opt_0 = link.style
local fontSize = ____finite_2(nil, ____opt_0 and ____opt_0.fontSize, 10)
local ____temp_5 = fontSize * 2
local ____opt_3 = link.text
local width = math.min(
250,
math.max(____temp_5, (____opt_3 and ____opt_3.length or 0) * fontSize * 0.65 + 10)
)
local ____opt_6 = measureText
if ____opt_6 ~= nil then
local ____opt_7 = link.style
____opt_6 = ____opt_6(nil, ____opt_7 and ____opt_7.fontFamily or DEFAULT_FONT, fontSize)
end
local metrics = ____opt_6
local lines = visible and wrapText(
nil,
link.text or "",
width,
fontSize,
metrics
) or ({})
return {
visible = visible,
fontSize = fontSize,
width = width,
height = #lines * fontSize * 1.4,
lines = lines
}
end
local function linkStyle(self, item, strokeWidth, color, dash)
local link = item.link
local ____opt_10 = link.style
local stroke = type(____opt_10 and ____opt_10.color) == "table" and link.style.color.type == "gradient" and ({
kind = "linear-gradient",
angle = 0,
stops = __TS__ArrayMap(
link.style.color.stops,
function(____, stop) return {offset = stop.position, color = stop.color} end
)
}) or ({kind = "solid", color = color})
local ____temp_18 = {kind = "none"}
local ____stroke_19 = stroke
local ____strokeWidth_20 = strokeWidth
local ____dash_21 = dash
local ____finite_14 = finite
local ____opt_12 = link.style
local ____finite_14_result_22 = ____finite_14(nil, ____opt_12 and ____opt_12.opacity, 1)
local ____resolveShadow_17 = resolveShadow
local ____opt_15 = link.style
return {
fill = ____temp_18,
stroke = ____stroke_19,
strokeWidth = ____strokeWidth_20,
dash = ____dash_21,
lineCap = "round",
lineJoin = "round",
opacity = ____finite_14_result_22,
shadow = ____resolveShadow_17(nil, ____opt_15 and ____opt_15.shadow)
}
end
function ____exports.createLinkRenderContext(self, item, index, measureText)
local ____item_23 = item
local link = ____item_23.link
local from = ____item_23.from
local to = ____item_23.to
local ____opt_24 = link.style
local pathType = ____opt_24 and ____opt_24.pathType or "orthogonal"
local ____calculateLinkRoute_result_26 = calculateLinkRoute(
nil,
link,
from,
to,
pathType
)
local points = ____calculateLinkRoute_result_26.points
local segments = ____calculateLinkRoute_result_26.segments
local ____finite_29 = finite
local ____opt_27 = link.style
local strokeWidth = ____finite_29(nil, ____opt_27 and ____opt_27.strokeWidth, 2)
local ____lor_33 = __lor
local ____getLinkStrokeColor_32 = getLinkStrokeColor
local ____opt_30 = link.style
local color = ____lor_33(
nil,
____getLinkStrokeColor_32(nil, ____opt_30 and ____opt_30.color),
function() return "#64748b" end
)
local label = labelLayout(nil, link, measureText)
local ____getDashArray_36 = getDashArray
local ____opt_34 = link.style
local contentDash = ____getDashArray_36(nil, strokeWidth, ____opt_34 and ____opt_34.strokeStyle or "solid")
local ____temp_37
if label.visible and not contentDash then
____temp_37 = labelGapDash(
nil,
points,
pathType,
label.width,
label.height
)
else
____temp_37 = nil
end
local gap = ____temp_37
local dash = gap and ({gap.dashBefore, gap.gapLength, 1000000}) or contentDash
return {
link = link,
pathType = pathType,
points = points,
segments = segments,
midpoint = getLineMidpoint(
nil,
points,
pathType,
from,
to
),
strokeWidth = strokeWidth,
bounds = linkBounds(nil, points, strokeWidth + 14),
color = color,
order = 20000 + index,
style = linkStyle(
nil,
item,
strokeWidth,
color,
dash
),
label = label,
hasLabelGap = Boolean(nil, gap)
}
end
return ____exports
end,
["core.renderScene.artifacts.link.markers"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
function ____exports.markerForEnd(self, link, ____end)
local ____temp_0
if ____end == "start" then
____temp_0 = link.startMarker
else
____temp_0 = link.endMarker
end
local explicit = ____temp_0
if __t(nil, explicit) then
return explicit
end
local ____opt_1 = link.style
local direction = ____opt_1 and ____opt_1.arrowDirection or "forward"
if direction == "bidirectional" then
return "arrow"
end
if ____end == "start" and direction == "backward" then
return "arrow"
end
if ____end == "end" and direction == "forward" then
return "arrow"
end
return "none"
end
return ____exports
end,
["core.renderScene.artifacts.link.roundedOrthogonalPathData"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
function ____exports.roundedOrthogonalPathData(self, segments, radius)
if #segments == 0 then
return ""
end
local raw = {
segments[1].start,
table.unpack(__TS__ArrayMap(
segments,
function(____, segment) return segment["end"] end
))
}
local points = __TS__ArrayFilter(
raw,
function(____, point, index) return index == 0 or point.x ~= raw[index].x or point.y ~= raw[index].y end
)
local corners = __TS__ArrayFilter(
points,
function(____, point, index)
if index == 0 or index == #points - 1 then
return true
end
local previous = points[index]
local next = points[index + 1 + 1]
return not (previous.x == point.x and point.x == next.x or previous.y == point.y and point.y == next.y)
end
)
if #corners < 2 then
return ""
end
local pathData = (("M " .. tostring(corners[1].x)) .. " ") .. tostring(corners[1].y)
do
local index = 1
while index < #corners - 1 do
do
local previous = corners[index]
local corner = corners[index + 1]
local next = corners[index + 1 + 1]
local incoming = __hypot(nil, corner.x - previous.x, corner.y - previous.y)
local outgoing = __hypot(nil, next.x - corner.x, next.y - corner.y)
if incoming == 0 or outgoing == 0 then
pathData = pathData .. ((" L " .. tostring(corner.x)) .. " ") .. tostring(corner.y)
goto __continue10
end
local cornerRadius = math.min(radius, incoming * 0.4, outgoing * 0.4)
local before = {x = corner.x + (previous.x - corner.x) / incoming * cornerRadius, y = corner.y + (previous.y - corner.y) / incoming * cornerRadius}
local after = {x = corner.x + (next.x - corner.x) / outgoing * cornerRadius, y = corner.y + (next.y - corner.y) / outgoing * cornerRadius}
pathData = pathData .. ((((((((((" L " .. tostring(before.x)) .. " ") .. tostring(before.y)) .. " Q ") .. tostring(corner.x)) .. " ") .. tostring(corner.y)) .. " ") .. tostring(after.x)) .. " ") .. tostring(after.y)
end
::__continue10::
index = index + 1
end
end
local last = corners[#corners]
return (((pathData .. " L ") .. tostring(last.x)) .. " ") .. tostring(last.y)
end
return ____exports
end,
["core.renderScene.artifacts.link.path"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____markers = require("core.renderScene.artifacts.link.markers")
local markerForEnd = ____markers.markerForEnd
local ____roundedOrthogonalPathData = require("core.renderScene.artifacts.link.roundedOrthogonalPathData")
local roundedOrthogonalPathData = ____roundedOrthogonalPathData.roundedOrthogonalPathData
local function polylinePathData(self, points)
local path = (("M " .. tostring(points[1])) .. " ") .. tostring(points[2])
do
local index = 2
while index < #points do
path = path .. ((" L " .. tostring(points[index + 1])) .. " ") .. tostring(points[index + 1 + 1])
index = index + 2
end
end
return path
end
local function pathData(self, points, pathType, segments, strokeWidth)
if #points < 4 then
return ""
end
if pathType == "curved" and #points >= 8 then
return (((((((((((((("M " .. tostring(points[1])) .. " ") .. tostring(points[2])) .. " C ") .. tostring(points[3])) .. " ") .. tostring(points[4])) .. " ") .. tostring(points[5])) .. " ") .. tostring(points[6])) .. " ") .. tostring(points[7])) .. " ") .. tostring(points[8])
end
if pathType == "orthogonal" and #segments > 0 then
return roundedOrthogonalPathData(
nil,
segments,
math.max(16, strokeWidth * 4)
)
end
return polylinePathData(nil, points)
end
local function round(____, value)
return math.floor(value * 100 + 0.5) / 100
end
local function movableSegments(self, pathType, segments)
if pathType ~= "orthogonal" or not __TS__ArraySome(
segments,
function(____, segment) return segment.canMove end
) then
return nil
end
return __TS__ArrayMap(
segments,
function(____, segment) return {
ax = round(nil, segment.start.x),
ay = round(nil, segment.start.y),
bx = round(nil, segment["end"].x),
by = round(nil, segment["end"].y),
ox = round(nil, segment.originalMidpoint.x),
oy = round(nil, segment.originalMidpoint.y),
movable = segment.canMove
} end
)
end
function ____exports.renderLinkPath(self, context)
local ____context_0 = context
local link = ____context_0.link
local ____temp_15 = "link-" .. link.id
local ____context_order_16 = context.order
local ____context_bounds_17 = context.bounds
local ____pathData_result_18 = pathData(
nil,
context.points,
context.pathType,
context.segments,
context.strokeWidth
)
local ____context_style_19 = context.style
local ____markerForEnd_result_20 = markerForEnd(nil, link, "start")
local ____markerForEnd_result_21 = markerForEnd(nil, link, "end")
local ____link_fromId_9 = link.fromId
local ____link_toId_10 = link.toId
local ____context_pathType_11 = context.pathType
local ____opt_1 = link.fromPoint
local ____temp_12 = (____opt_1 and ____opt_1.kind) == "side" and link.fromPoint.side or nil
local ____opt_3 = link.toPoint
local ____temp_13 = (____opt_3 and ____opt_3.kind) == "side" and link.toPoint.side or nil
local ____opt_5 = link.fromPoint
local ____temp_14 = (____opt_5 and ____opt_5.kind) == "face" and link.fromPoint.face or nil
local ____opt_7 = link.toPoint
return {
type = "path",
id = ____temp_15,
order = ____context_order_16,
bounds = ____context_bounds_17,
d = ____pathData_result_18,
style = ____context_style_19,
markerStart = ____markerForEnd_result_20,
markerEnd = ____markerForEnd_result_21,
detail = {
of = "link",
fromId = ____link_fromId_9,
toId = ____link_toId_10,
route = ____context_pathType_11,
fromSide = ____temp_12,
toSide = ____temp_13,
fromFace = ____temp_14,
toFace = (____opt_7 and ____opt_7.kind) == "face" and link.toPoint.face or nil,
labelGap = context.hasLabelGap,
segments = movableSegments(nil, context.pathType, context.segments)
}
}
end
return ____exports
end,
["core.renderScene.artifacts.link.weight"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__NumberToFixed = ____lualib.__TS__NumberToFixed
local ____exports = {}
function ____exports.renderWeightBadge(self, context)
local ____context_0 = context
local link = ____context_0.link
if link.weight == nil or link.weight == nil or link.showWeight == false then
return {}
end
local text = __TS__NumberToFixed(link.weight, 1)
local width = math.max(30, #text * 8 + 12)
local height = 16
local y = context.midpoint.y + (context.label.visible and context.label.height / 2 + 10 or 0)
return {{
type = "rect",
id = "link-weight-badge-" .. link.id,
order = context.order + 0.6,
bounds = context.bounds,
x = context.midpoint.x - width / 2,
y = y - height / 2,
width = width,
height = height,
rx = height / 2,
style = {fill = {kind = "solid", color = context.color}, stroke = {kind = "none"}, opacity = 0.92}
}, {
type = "text",
id = "link-weight-" .. link.id,
order = context.order + 0.61,
bounds = context.bounds,
x = context.midpoint.x - width / 2,
y = y - height / 2,
width = width,
height = height,
lines = {text},
fontFamily = "Arial, sans-serif",
fontSize = 10,
fontWeight = "bold",
color = "#ffffff",
align = "center",
verticalAlign = "middle",
lineHeight = 1
}}
end
return ____exports
end,
["core.renderScene.artifacts.link"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____tagging = require("core.renderScene.scene.tagging")
local tag = ____tagging.tag
local ____endpointLabels = require("core.renderScene.artifacts.link.endpointLabels")
local renderEndpointLabels = ____endpointLabels.renderEndpointLabels
local ____label = require("core.renderScene.artifacts.link.label")
local renderMainLabel = ____label.renderMainLabel
local ____layout = require("core.renderScene.artifacts.link.layout")
local createLinkRenderContext = ____layout.createLinkRenderContext
local ____path = require("core.renderScene.artifacts.link.path")
local renderLinkPath = ____path.renderLinkPath
local ____weight = require("core.renderScene.artifacts.link.weight")
local renderWeightBadge = ____weight.renderWeightBadge
function ____exports.buildLink(self, item, index, measureText)
if item.link.isVisible == false then
return {}
end
local context = createLinkRenderContext(nil, item, index, measureText)
local ____array_0 = __TS__SparseArrayNew(
renderLinkPath(nil, context),
table.unpack(renderMainLabel(nil, context))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(renderWeightBadge(nil, context))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(renderEndpointLabels(nil, context))
)
return {__TS__SparseArraySpread(____array_0)}
end
function ____exports.buildLinks(self, links, measureText)
return __TS__ArrayFlatMap(
links,
function(____, item, index) return tag(
nil,
____exports.buildLink(nil, item, index, measureText),
"link",
item.link.id,
item.kind,
__lor(
nil,
item.link.text,
function() return (tostring(item.link.fromId) .. " → ") .. tostring(item.link.toId) end
)
) end
)
end
return ____exports
end,
["core.renderScene.artifacts.meshStage"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____mesh = require("core.model.mesh.index")
local DEFAULT_MESH_SCENE = ____mesh.DEFAULT_MESH_SCENE
function ____exports.buildMeshStages(self, meshes, canvases, anchors, surfaces, lights)
local loose = __TS__ArraySome(
meshes,
function(____, mesh) return not __t(nil, mesh.sceneId) end
) or __TS__ArraySome(
surfaces,
function(____, surface) return not __t(nil, surface.sceneId) end
)
local ____array_1 = __TS__SparseArrayNew(table.unpack(canvases))
__TS__SparseArrayPush(
____array_1,
table.unpack(loose and ({DEFAULT_MESH_SCENE}) or ({}))
)
return __TS__ArrayMap(
{__TS__SparseArraySpread(____array_1)},
function(____, canvas, index)
local own = __TS__ArrayFilter(
meshes,
function(____, mesh) return (mesh.sceneId or DEFAULT_MESH_SCENE.id) == canvas.id end
)
local inScene = __TS__ArrayFilter(
lights,
function(____, light) return (light.sceneId or DEFAULT_MESH_SCENE.id) == canvas.id end
)
local ____canvas_0 = canvas
local id = ____canvas_0.id
local x = ____canvas_0.x
local y = ____canvas_0.y
local width = ____canvas_0.width
local height = ____canvas_0.height
local orbit = ____canvas_0.orbit
local zoom = ____canvas_0.zoom
local shadow = ____canvas_0.shadow
local environment = ____canvas_0.environment
local environmentTurn = ____canvas_0.environmentTurn
local exposure = ____canvas_0.exposure
local haze = ____canvas_0.haze
local hazeColor = ____canvas_0.hazeColor
local ground = ____canvas_0.ground
return {
type = "mesh-stage",
id = "mesh-stage-" .. id,
order = -1000 + index,
bounds = {minX = x, minY = y, maxX = x + width, maxY = y + height},
x = x,
y = y,
width = width,
height = height,
stageId = id,
orbit = orbit,
zoom = zoom,
shadow = shadow,
environment = environment,
environmentTurn = environmentTurn,
exposure = exposure,
haze = haze,
hazeColor = hazeColor,
ground = ground,
meshes = own,
light = inScene[1],
sideLights = #inScene > 1 and __TS__ArraySlice(inScene, 1) or nil,
surfaces = __TS__ArrayFilter(
surfaces,
function(____, surface) return (surface.sceneId or DEFAULT_MESH_SCENE.id) == canvas.id end
),
anchors = __TS__ArrayFilter(
anchors,
function(____, anchor) return __TS__ArraySome(
own,
function(____, mesh) return mesh.id == anchor.mesh end
) end
)
}
end
)
end
return ____exports
end,
["core.renderScene.artifacts.meshSurfaces"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectFromEntries = ____lualib.__TS__ObjectFromEntries
local Set = ____lualib.Set
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__New = ____lualib.__TS__New
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local function filtered(self, input, keep)
local entries = __TS__ArrayMap(
__TS__ObjectEntries(input),
function(____, ____bindingPattern0)
local value
local key
key = ____bindingPattern0[1]
value = ____bindingPattern0[2]
if key == "links" then
return {
key,
__TS__ArrayFilter(
input.links,
function(____, item) return keep(nil, item.link.fromId or "") and keep(nil, item.link.toId or "") end
)
}
end
local objects = __TS__ArrayIsArray(value) and __TS__ArrayEvery(
value,
function(____, item)
local ____opt_result_2
if item ~= nil then
____opt_result_2 = item.id
end
return type(____opt_result_2) == "string"
end
)
return {
key,
objects and __TS__ArrayFilter(
value,
function(____, item) return keep(nil, item.id) end
) or value
}
end
)
return __TS__ObjectFromEntries(entries)
end
function ____exports.splitMeshSurfaces(self, input, build)
local declared = input.meshSurfaces or ({})
if not __t(nil, #declared) then
return {input = input, surfaces = {}}
end
local onSurface = __TS__New(
Set,
__TS__ArrayFlatMap(
declared,
function(____, surface) return __TS__ArrayMap(
surface.members,
function(____, member) return member.id end
) end
)
)
local surfaces = __TS__ArrayMap(
declared,
function(____, surface)
local own = __TS__New(
Set,
__TS__ArrayMap(
surface.members,
function(____, member) return member.id end
)
)
return __TS__ObjectAssign(
{},
surface,
{scene = build(
nil,
__TS__ObjectAssign(
{},
filtered(
nil,
input,
function(____, id) return own:has(id) end
),
{meshSurfaces = {}, diagnostics = {}}
)
)}
)
end
)
return {
input = filtered(
nil,
input,
function(____, id) return not onSurface:has(id) end
),
surfaces = surfaces
}
end
return ____exports
end,
["core.renderScene.artifacts.path"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local freeformPathData = ____scene.freeformPathData
local ____freeformPath = require("core.renderScene.scene.freeformPath")
local radiusAt = ____freeformPath.radiusAt
local ____tagging = require("core.renderScene.scene.tagging")
local tag = ____tagging.tag
local GLOW_LAYERS = {{0, 1, 0.5, 0.55}, {1, 0.3, 0.15, 0.8}}
function ____exports.buildFreeformPath(self, path, index)
if path.isVisible == false or #path.points < 2 then
return {}
end
local strokeWidth = finite(nil, path.strokeWidth, 2)
local extra = strokeWidth + 12
local bounds = {
minX = math.min(table.unpack(__TS__ArrayMap(
path.points,
function(____, point) return point.x end
))) - extra,
minY = math.min(table.unpack(__TS__ArrayMap(
path.points,
function(____, point) return point.y end
))) - extra,
maxX = math.max(table.unpack(__TS__ArrayMap(
path.points,
function(____, point) return point.x end
))) + extra,
maxY = math.max(table.unpack(__TS__ArrayMap(
path.points,
function(____, point) return point.y end
))) + extra
}
local tension = finite(nil, path.tension, 0)
local closed = path.closed == true
local corners = {
cornerRadius = finite(nil, path.cornerRadius, 0),
cornerRadii = path.cornerRadii
}
local radii = __TS__ArrayMap(
path.points,
function(____, _, position) return radiusAt(nil, corners, position) end
)
local ____temp_6 = "path-" .. path.id
local ____temp_7 = 30000 + index
local ____bounds_8 = bounds
local ____freeformPathData_result_9 = freeformPathData(
nil,
__TS__ObjectAssign({points = path.points, tension = tension, closed = closed}, corners)
)
local ____path_startMarker_10 = path.startMarker
local ____path_endMarker_11 = path.endMarker
local ____TS__ObjectAssign_result_12 = __TS__ObjectAssign(
{
of = "pathGeometry",
points = __TS__ArrayMap(
path.points,
function(____, point) return {point.x, point.y} end
),
tension = tension,
closed = closed
},
__TS__ArraySome(
radii,
function(____, radius) return radius > 0 end
) and ({cornerRadii = radii}) or ({})
)
local ____temp_3 = path.closed and ({kind = "solid", color = path.fillColor or "transparent"}) or ({kind = "none"})
local ____temp_4 = {kind = "solid", color = path.strokeColor or "#7c3aed"}
local ____strokeWidth_5 = strokeWidth
local ____t_2 = __t
local ____opt_0 = path.dash
local nodes = {{
type = "path",
id = ____temp_6,
order = ____temp_7,
bounds = ____bounds_8,
d = ____freeformPathData_result_9,
markerStart = ____path_startMarker_10,
markerEnd = ____path_endMarker_11,
detail = ____TS__ObjectAssign_result_12,
style = {
fill = ____temp_3,
stroke = ____temp_4,
strokeWidth = ____strokeWidth_5,
dash = ____t_2(nil, ____opt_0 and #____opt_0) and path.dash or nil,
lineCap = "round",
lineJoin = "round",
opacity = finite(nil, path.opacity, 1),
transition = path.transition
}
}}
local glow = finite(nil, path.glow, 0)
if glow > 0 then
local d = freeformPathData(
nil,
__TS__ObjectAssign({points = path.points, tension = tension, closed = closed}, corners)
)
local color = path.glowColor or path.strokeColor or "#7c3aed"
local reach = glow * 4 + strokeWidth
local blurArea = {x = bounds.minX + extra - reach, y = bounds.minY + extra - reach, width = bounds.maxX - bounds.minX - extra * 2 + reach * 2, height = bounds.maxY - bounds.minY - extra * 2 + reach * 2}
for ____, ____value in ipairs(GLOW_LAYERS) do
local part = ____value[1]
local blur = ____value[2]
local width = ____value[3]
local strength = ____value[4]
nodes[#nodes + 1] = {
type = "path",
id = (("path-" .. path.id) .. "-glow-") .. tostring(part),
order = 30000 + index - 0.3 + part * 0.1,
bounds = bounds,
d = d,
style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = color},
strokeWidth = strokeWidth + glow * width,
lineCap = "round",
lineJoin = "round",
opacity = finite(nil, path.opacity, 1) * strength,
blur = glow * blur,
blurArea = blurArea,
pointerEvents = "none",
transition = path.transition
}
}
end
end
return nodes
end
function ____exports.buildFreeformPaths(self, paths)
return __TS__ArrayFlatMap(
paths,
function(____, path, index) return tag(
nil,
____exports.buildFreeformPath(nil, path, index),
"path",
path.id,
"path",
"Path"
) end
)
end
return ____exports
end,
["core.renderScene.artifacts.shape.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.artifacts.shape.geometry.base"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.shapeNodeBase(self, context)
return {
id = context.id,
order = context.order,
bounds = context.bounds,
rotation = context.rotation,
style = context.style
}
end
return ____exports
end,
["core.renderScene.artifacts.shape.geometry.cloud"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local CLOUD_LOBES = {
{30, 64, 24},
{52, 40, 22},
{86, 32, 28},
{118, 42, 24},
{132, 64, 24}
}
local QUARTER_TURN = math.pi / 2
local FULL_TURN = 4 * QUARTER_TURN
local BOTTOM_ANGLE = math.pi / 2
local EPSILON = 1e-9
local function pointOnLobe(self, ____bindingPattern0, angle)
local radius
local centerY
local centerX
centerX = ____bindingPattern0[1]
centerY = ____bindingPattern0[2]
radius = ____bindingPattern0[3]
return {
centerX + radius * math.cos(angle),
centerY + radius * math.sin(angle)
}
end
local function angleOnLobe(self, ____bindingPattern0, point)
local centerY
local centerX
centerX = ____bindingPattern0[1]
centerY = ____bindingPattern0[2]
return math.atan(point[2] - centerY, point[1] - centerX)
end
local function outerCusp(self, first, second, centroid)
local dx = second[1] - first[1]
local dy = second[2] - first[2]
local distance = __hypot(nil, dx, dy)
local along = (first[3] ^ 2 - second[3] ^ 2 + distance ^ 2) / (2 * distance)
local across = math.sqrt(math.max(0, first[3] ^ 2 - along ^ 2))
local footX = first[1] + along * dx / distance
local footY = first[2] + along * dy / distance
local candidates = {{footX - across * dy / distance, footY + across * dx / distance}, {footX + across * dy / distance, footY - across * dx / distance}}
local function fromCentroid(____, point)
return __hypot(nil, point[1] - centroid[1], point[2] - centroid[2])
end
return fromCentroid(nil, candidates[1]) > fromCentroid(nil, candidates[2]) and candidates[1] or candidates[2]
end
local function lobeArcs(self, lobes)
local centroid = {
__TS__ArrayReduce(
lobes,
function(____, sum, lobe) return sum + lobe[1] end,
0
) / #lobes,
__TS__ArrayReduce(
lobes,
function(____, sum, lobe) return sum + lobe[2] end,
0
) / #lobes
}
return __TS__ArrayMap(
lobes,
function(____, lobe, index)
local from = index == 0 and BOTTOM_ANGLE or angleOnLobe(
nil,
lobe,
outerCusp(nil, lobes[index], lobe, centroid)
)
local isLast = index == #lobes - 1
local to = isLast and BOTTOM_ANGLE or angleOnLobe(
nil,
lobe,
outerCusp(nil, lobe, lobes[index + 1 + 1], centroid)
)
while to <= from do
to = to + FULL_TURN
end
return {lobe = lobe, from = from, to = to}
end
)
end
local function quarterStops(self, from, to)
local stops = {}
do
local turn = math.floor(from / QUARTER_TURN) + 1
while turn * QUARTER_TURN < to - EPSILON do
stops[#stops + 1] = turn * QUARTER_TURN
turn = turn + 1
end
end
local ____array_0 = __TS__SparseArrayNew(table.unpack(stops))
__TS__SparseArrayPush(____array_0, to)
return {__TS__SparseArraySpread(____array_0)}
end
local function arcCurves(self, ____bindingPattern0)
local to
local from
local lobe
lobe = ____bindingPattern0.lobe
from = ____bindingPattern0.from
to = ____bindingPattern0.to
local start = pointOnLobe(nil, lobe, from)
local curves = {}
local angle = from
for ____, stop in ipairs(quarterStops(nil, from, to)) do
local reach = 4 / 3 * math.tan((stop - angle) / 4) * lobe[3]
local begin = pointOnLobe(nil, lobe, angle)
local ____end = pointOnLobe(nil, lobe, stop)
curves[#curves + 1] = {
{
begin[1] - reach * math.sin(angle),
begin[2] + reach * math.cos(angle)
},
{
____end[1] + reach * math.sin(stop),
____end[2] - reach * math.cos(stop)
},
____end
}
angle = stop
end
return {start = start, curves = curves}
end
local function normalizedCloudOutline(self)
local arcs = __TS__ArrayMap(
lobeArcs(nil, CLOUD_LOBES),
arcCurves
)
local start = arcs[1].start
local curves = __TS__ArrayFlatMap(
arcs,
function(____, arc) return arc.curves end
)
local anchors = {
start,
table.unpack(__TS__ArrayMap(
curves,
function(____, curve) return curve[3] end
))
}
local minX = math.min(table.unpack(__TS__ArrayMap(
anchors,
function(____, point) return point[1] end
)))
local maxX = math.max(table.unpack(__TS__ArrayMap(
anchors,
function(____, point) return point[1] end
)))
local minY = math.min(table.unpack(__TS__ArrayMap(
anchors,
function(____, point) return point[2] end
)))
local maxY = math.max(table.unpack(__TS__ArrayMap(
anchors,
function(____, point) return point[2] end
)))
local function unit(____, point)
return {(point[1] - minX) / (maxX - minX), (point[2] - minY) / (maxY - minY)}
end
return {
start = unit(nil, start),
curves = __TS__ArrayMap(
curves,
function(____, ____bindingPattern0)
local ____end
local second
local first
first = ____bindingPattern0[1]
second = ____bindingPattern0[2]
____end = ____bindingPattern0[3]
return {
unit(nil, first),
unit(nil, second),
unit(nil, ____end)
}
end
)
}
end
local CLOUD_OUTLINE = normalizedCloudOutline(nil)
function ____exports.cloudPath(self, x, y, width, height)
local function at(____, ____bindingPattern0)
local v
local u
u = ____bindingPattern0[1]
v = ____bindingPattern0[2]
return (tostring(x + u * width) .. " ") .. tostring(y + v * height)
end
local curves = __TS__ArrayMap(
CLOUD_OUTLINE.curves,
function(____, ____bindingPattern0)
local ____end
local second
local first
first = ____bindingPattern0[1]
second = ____bindingPattern0[2]
____end = ____bindingPattern0[3]
return (((("C " .. at(nil, first)) .. " ") .. at(nil, second)) .. " ") .. at(nil, ____end)
end
)
return ((("M " .. at(nil, CLOUD_OUTLINE.start)) .. " ") .. table.concat(curves, " ")) .. " Z"
end
return ____exports
end,
["core.renderScene.artifacts.shape.geometry.roundedForms"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local KAPPA = 0.5523
local CYLINDER_CAP_OF_HEIGHT = 0.22
local CYLINDER_CAP_OF_WIDTH = 0.2
local PERSON_BODY_IN_HEADS = 2
local PERSON_NECK_IN_HEADS = 0.35
local PERSON_WIDTH_IN_HEADS = 2 * PERSON_BODY_IN_HEADS
local PERSON_HEIGHT_IN_HEADS = 2 + PERSON_NECK_IN_HEADS + PERSON_BODY_IN_HEADS
function ____exports.cylinderPath(self, x, y, width, height)
local cap = math.min(height * CYLINDER_CAP_OF_HEIGHT, width * CYLINDER_CAP_OF_WIDTH)
local rx = width / 2
local cx = x + rx
local left = x
local right = x + width
local lidY = y + cap
local floorY = y + height - cap
local lid = (((((((((((((((((("M " .. tostring(left)) .. " ") .. tostring(lidY)) .. " C ") .. tostring(left)) .. " ") .. tostring(lidY + KAPPA * cap)) .. " ") .. tostring(cx - KAPPA * rx)) .. " ") .. tostring(lidY + cap)) .. " ") .. tostring(cx)) .. " ") .. tostring(lidY + cap)) .. " ") .. ((((((((((("C " .. tostring(cx + KAPPA * rx)) .. " ") .. tostring(lidY + cap)) .. " ") .. tostring(right)) .. " ") .. tostring(lidY + KAPPA * cap)) .. " ") .. tostring(right)) .. " ") .. tostring(lidY)) .. " ") .. ((((((((((("C " .. tostring(right)) .. " ") .. tostring(lidY - KAPPA * cap)) .. " ") .. tostring(cx + KAPPA * rx)) .. " ") .. tostring(y)) .. " ") .. tostring(cx)) .. " ") .. tostring(y)) .. " ") .. ((((((((((("C " .. tostring(cx - KAPPA * rx)) .. " ") .. tostring(y)) .. " ") .. tostring(left)) .. " ") .. tostring(lidY - KAPPA * cap)) .. " ") .. tostring(left)) .. " ") .. tostring(lidY)) .. " Z"
local wall = (((((((((("M " .. tostring(left)) .. " ") .. tostring(lidY)) .. " L ") .. tostring(left)) .. " ") .. tostring(floorY)) .. " ") .. ((((((((((("C " .. tostring(left)) .. " ") .. tostring(floorY + KAPPA * cap)) .. " ") .. tostring(cx - KAPPA * rx)) .. " ") .. tostring(y + height)) .. " ") .. tostring(cx)) .. " ") .. tostring(y + height)) .. " ") .. ((((((((((("C " .. tostring(cx + KAPPA * rx)) .. " ") .. tostring(y + height)) .. " ") .. tostring(right)) .. " ") .. tostring(floorY + KAPPA * cap)) .. " ") .. tostring(right)) .. " ") .. tostring(floorY)) .. " ") .. (("L " .. tostring(right)) .. " ") .. tostring(lidY)
return (lid .. " ") .. wall
end
local function personFigure(self, x, y, width, height)
local scale = math.min(width / PERSON_WIDTH_IN_HEADS, height / PERSON_HEIGHT_IN_HEADS)
local head = scale
local body = scale * PERSON_BODY_IN_HEADS
local figureHeight = scale * PERSON_HEIGHT_IN_HEADS
local top = y + (height - figureHeight) / 2
return {
head = head,
body = body,
centerX = x + width / 2,
headCenterY = top + head,
bottom = top + figureHeight
}
end
function ____exports.personLabelArea(self, x, y, width, height)
local ____personFigure_result_0 = personFigure(
nil,
x,
y,
width,
height
)
local body = ____personFigure_result_0.body
local centerX = ____personFigure_result_0.centerX
local bottom = ____personFigure_result_0.bottom
return {x = centerX - body, y = bottom - body, width = body * 2, height = body}
end
function ____exports.personPath(self, x, y, width, height)
local ____personFigure_result_1 = personFigure(
nil,
x,
y,
width,
height
)
local head = ____personFigure_result_1.head
local body = ____personFigure_result_1.body
local centerX = ____personFigure_result_1.centerX
local headCenterY = ____personFigure_result_1.headCenterY
local bottom = ____personFigure_result_1.bottom
local skull = ((((((("M " .. tostring(centerX)) .. " ") .. tostring(headCenterY - head)) .. " ") .. ((((((((((("C " .. tostring(centerX + KAPPA * head)) .. " ") .. tostring(headCenterY - head)) .. " ") .. tostring(centerX + head)) .. " ") .. tostring(headCenterY - KAPPA * head)) .. " ") .. tostring(centerX + head)) .. " ") .. tostring(headCenterY)) .. " ") .. ((((((((((("C " .. tostring(centerX + head)) .. " ") .. tostring(headCenterY + KAPPA * head)) .. " ") .. tostring(centerX + KAPPA * head)) .. " ") .. tostring(headCenterY + head)) .. " ") .. tostring(centerX)) .. " ") .. tostring(headCenterY + head)) .. " ") .. ((((((((((("C " .. tostring(centerX - KAPPA * head)) .. " ") .. tostring(headCenterY + head)) .. " ") .. tostring(centerX - head)) .. " ") .. tostring(headCenterY + KAPPA * head)) .. " ") .. tostring(centerX - head)) .. " ") .. tostring(headCenterY)) .. " ") .. ((((((((((("C " .. tostring(centerX - head)) .. " ") .. tostring(headCenterY - KAPPA * head)) .. " ") .. tostring(centerX - KAPPA * head)) .. " ") .. tostring(headCenterY - head)) .. " ") .. tostring(centerX)) .. " ") .. tostring(headCenterY - head)) .. " Z"
local dome = ((((("M " .. tostring(centerX - body)) .. " ") .. tostring(bottom)) .. " ") .. ((((((((((("C " .. tostring(centerX - body)) .. " ") .. tostring(bottom - KAPPA * body)) .. " ") .. tostring(centerX - KAPPA * body)) .. " ") .. tostring(bottom - body)) .. " ") .. tostring(centerX)) .. " ") .. tostring(bottom - body)) .. " ") .. ((((((((((("C " .. tostring(centerX + KAPPA * body)) .. " ") .. tostring(bottom - body)) .. " ") .. tostring(centerX + body)) .. " ") .. tostring(bottom - KAPPA * body)) .. " ") .. tostring(centerX + body)) .. " ") .. tostring(bottom)) .. " Z"
return (skull .. " ") .. dome
end
return ____exports
end,
["core.renderScene.artifacts.shape.geometry.pathCalculation"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____cloud = require("core.renderScene.artifacts.shape.geometry.cloud")
local cloudPath = ____cloud.cloudPath
local ____roundedForms = require("core.renderScene.artifacts.shape.geometry.roundedForms")
local cylinderPath = ____roundedForms.cylinderPath
local personPath = ____roundedForms.personPath
local function polygonPath(____, points)
return #points < 4 and "" or ((((("M " .. tostring(points[1])) .. " ") .. tostring(points[2])) .. " ") .. __TS__ArrayReduce(
__TS__ArraySlice(points, 2),
function(____, s, n, i) return s .. (__t(nil, i % 2) and " " .. tostring(n) or " L " .. tostring(n)) end,
""
)) .. " Z"
end
local DOCUMENT_WAVE_AMPLITUDE = 0.1
local QUARTER_SINE_SLOPE = math.pi / 6
local NOTE_FOLD_RATIO = 0.25
local PREDEFINED_PROCESS_BAR_RATIO = 0.15
function ____exports.pillCornerRadius(self, width, height)
return math.min(width, height) / 2
end
function ____exports.localShapePath(self, ____type, x, y, width, height)
local function p(____, ...)
local coords = {...}
return polygonPath(nil, coords)
end
repeat
local ____switch7 = ____type
local ____cond7 = ____switch7 == "diamond"
if ____cond7 then
return p(
nil,
x + width / 2,
y,
x + width,
y + height / 2,
x + width / 2,
y + height,
x,
y + height / 2
)
end
____cond7 = ____cond7 or ____switch7 == "triangle"
if ____cond7 then
return p(
nil,
x + width / 2,
y,
x,
y + height,
x + width,
y + height
)
end
____cond7 = ____cond7 or ____switch7 == "parallelogram"
if ____cond7 then
return p(
nil,
x + width * 0.15,
y,
x + width,
y,
x + width * 0.85,
y + height,
x,
y + height
)
end
____cond7 = ____cond7 or ____switch7 == "trapezoid"
if ____cond7 then
return p(
nil,
x + width * 0.2,
y,
x + width * 0.8,
y,
x + width,
y + height,
x,
y + height
)
end
____cond7 = ____cond7 or ____switch7 == "hexagon"
if ____cond7 then
do
local cut = math.min(width, height) / 4
return p(
nil,
x + cut,
y,
x + width - cut,
y,
x + width,
y + height / 2,
x + width - cut,
y + height,
x + cut,
y + height,
x,
y + height / 2
)
end
end
____cond7 = ____cond7 or ____switch7 == "document"
if ____cond7 then
do
local amplitude = height * DOCUMENT_WAVE_AMPLITUDE
local mid = y + height - amplitude
local quarter = width / 4
local slope = amplitude * QUARTER_SINE_SLOPE
return ((((((((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " L ") .. tostring(x + width)) .. " ") .. tostring(y)) .. " L ") .. tostring(x + width)) .. " ") .. tostring(mid)) .. " ") .. ((((((((((("C " .. tostring(x + width - quarter / 3)) .. " ") .. tostring(mid - slope)) .. " ") .. tostring(x + width - quarter * 2 / 3)) .. " ") .. tostring(mid - amplitude)) .. " ") .. tostring(x + width - quarter)) .. " ") .. tostring(mid - amplitude)) .. " ") .. ((((((((((("C " .. tostring(x + width - quarter - quarter / 3)) .. " ") .. tostring(mid - amplitude)) .. " ") .. tostring(x + width / 2 + quarter / 3)) .. " ") .. tostring(mid - slope)) .. " ") .. tostring(x + width / 2)) .. " ") .. tostring(mid)) .. " ") .. ((((((((((("C " .. tostring(x + width / 2 - quarter / 3)) .. " ") .. tostring(mid + slope)) .. " ") .. tostring(x + width / 2 - quarter * 2 / 3)) .. " ") .. tostring(mid + amplitude)) .. " ") .. tostring(x + quarter)) .. " ") .. tostring(mid + amplitude)) .. " ") .. ((((((((((("C " .. tostring(x + quarter - quarter / 3)) .. " ") .. tostring(mid + amplitude)) .. " ") .. tostring(x + quarter / 3)) .. " ") .. tostring(mid + slope)) .. " ") .. tostring(x)) .. " ") .. tostring(mid)) .. " Z"
end
end
____cond7 = ____cond7 or ____switch7 == "note"
if ____cond7 then
do
local fold = math.min(width, height) * NOTE_FOLD_RATIO
return (((((((((((((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " L ") .. tostring(x + width - fold)) .. " ") .. tostring(y)) .. " L ") .. tostring(x + width)) .. " ") .. tostring(y + fold)) .. " L ") .. tostring(x + width)) .. " ") .. tostring(y + height)) .. " L ") .. tostring(x)) .. " ") .. tostring(y + height)) .. " Z ") .. (((((((((("M " .. tostring(x + width)) .. " ") .. tostring(y + fold)) .. " L ") .. tostring(x + width - fold)) .. " ") .. tostring(y + fold)) .. " L ") .. tostring(x + width - fold)) .. " ") .. tostring(y)
end
end
____cond7 = ____cond7 or ____switch7 == "cloud"
if ____cond7 then
return cloudPath(
nil,
x,
y,
width,
height
)
end
____cond7 = ____cond7 or ____switch7 == "cylinder"
if ____cond7 then
return cylinderPath(
nil,
x,
y,
width,
height
)
end
____cond7 = ____cond7 or ____switch7 == "person"
if ____cond7 then
return personPath(
nil,
x,
y,
width,
height
)
end
____cond7 = ____cond7 or ____switch7 == "predefined_process"
if ____cond7 then
do
local bar = math.min(width, height) * PREDEFINED_PROCESS_BAR_RATIO
return (((((((((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " L ") .. tostring(x + width)) .. " ") .. tostring(y)) .. " L ") .. tostring(x + width)) .. " ") .. tostring(y + height)) .. " L ") .. tostring(x)) .. " ") .. tostring(y + height)) .. " Z ") .. (((((((((((((("M " .. tostring(x + bar)) .. " ") .. tostring(y)) .. " L ") .. tostring(x + bar)) .. " ") .. tostring(y + height)) .. " M ") .. tostring(x + width - bar)) .. " ") .. tostring(y)) .. " L ") .. tostring(x + width - bar)) .. " ") .. tostring(y + height)
end
end
do
return nil
end
until true
end
return ____exports
end,
["core.renderScene.artifacts.shape.geometry.simple"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local freeformPathData = ____scene.freeformPathData
local ____base = require("core.renderScene.artifacts.shape.geometry.base")
local shapeNodeBase = ____base.shapeNodeBase
local ____pathCalculation = require("core.renderScene.artifacts.shape.geometry.pathCalculation")
local localShapePath = ____pathCalculation.localShapePath
local pillCornerRadius = ____pathCalculation.pillCornerRadius
function ____exports.renderPath(self, context)
local path = localShapePath(
nil,
context.shape.shapeType,
context.x,
context.y,
context.width,
context.height
)
if not __t(nil, path) then
return {}
end
return {__TS__ObjectAssign(
{},
shapeNodeBase(nil, context),
{type = "path", d = path, rotationCenter = context.rotationCenter}
)}
end
function ____exports.renderBoundedPath(self, context)
return __TS__ArrayMap(
____exports.renderPath(nil, context),
function(____, node) return __TS__ObjectAssign({}, node, {detail = {of = "declaredBounds", bounds = {x = context.x, y = context.y, width = context.width, height = context.height}}}) end
)
end
function ____exports.renderRectangle(self, context)
local rx = context.shape.shapeType == "pill" and pillCornerRadius(nil, context.width, context.height) or (context.shape.shapeType == "rounded_rectangle" and finite(nil, context.shape.cornerRadius, 8) or 0)
return {__TS__ObjectAssign(
{},
shapeNodeBase(nil, context),
{
type = "rect",
x = context.x,
y = context.y,
width = context.width,
height = context.height,
rx = rx
}
)}
end
function ____exports.renderEllipse(self, context)
return {__TS__ObjectAssign(
{},
shapeNodeBase(nil, context),
{
type = "ellipse",
cx = context.x + context.width / 2,
cy = context.y + context.height / 2,
rx = context.width / 2,
ry = context.height / 2
}
)}
end
function ____exports.renderSymbol(self, context)
if not context.shape.symbol or #context.shape.symbol.points < 2 then
return ____exports.renderRectangle(nil, context)
end
local tension = finite(nil, context.shape.symbol.tension, 0)
local function place(____, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
return {x = context.x + x * context.width, y = context.y + y * context.height}
end
local points = __TS__ArrayMap(context.shape.symbol.points, place)
local rings = context.shape.symbol.rings
return {__TS__ObjectAssign(
{},
shapeNodeBase(nil, context),
{
type = "path",
d = rings and table.concat(
__TS__ArrayMap(
rings,
function(____, ring) return freeformPathData(
nil,
{
points = __TS__ArrayMap(ring, place),
tension = 0,
closed = true
}
) end
),
" "
) or freeformPathData(nil, {points = points, tension = tension, closed = true}),
rotationCenter = context.rotationCenter,
detail = {of = "symbolGeometry", points = context.shape.symbol.points, tension = tension, declaredBounds = {x = context.x, y = context.y, width = context.width, height = context.height}}
}
)}
end
return ____exports
end,
["core.renderScene.artifacts.shape.geometry.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____simple = require("core.renderScene.artifacts.shape.geometry.simple")
local renderBoundedPath = ____simple.renderBoundedPath
local renderEllipse = ____simple.renderEllipse
local renderPath = ____simple.renderPath
local renderRectangle = ____simple.renderRectangle
local renderSymbol = ____simple.renderSymbol
local GEOMETRY_RENDERERS = {
cloud = renderPath,
cylinder = renderPath,
diamond = renderPath,
document = renderPath,
hexagon = renderPath,
note = renderPath,
oval = renderEllipse,
circle = renderEllipse,
parallelogram = renderPath,
person = renderBoundedPath,
pill = renderRectangle,
predefined_process = renderPath,
rectangle = renderRectangle,
rounded_rectangle = renderRectangle,
symbol = renderSymbol,
trapezoid = renderPath,
triangle = renderPath
}
function ____exports.renderShapeGeometry(self, context)
local renderer = GEOMETRY_RENDERERS[context.shape.shapeType] or renderRectangle
return renderer(nil, context)
end
return ____exports
end,
["core.renderScene.artifacts.shape.image"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local function clipOf(self, outline, box)
if (outline and outline.type) == "path" then
return {type = "path", d = outline.d}
end
if (outline and outline.type) == "ellipse" then
local ____outline_4 = outline
local cx = ____outline_4.cx
local cy = ____outline_4.cy
local rx = ____outline_4.rx
local ry = ____outline_4.ry
return {
type = "path",
d = ((((((((((((((((((("M" .. tostring(cx - rx)) .. " ") .. tostring(cy)) .. "A") .. tostring(rx)) .. " ") .. tostring(ry)) .. " 0 1 0 ") .. tostring(cx + rx)) .. " ") .. tostring(cy)) .. "A") .. tostring(rx)) .. " ") .. tostring(ry)) .. " 0 1 0 ") .. tostring(cx - rx)) .. " ") .. tostring(cy)) .. "Z"
}
end
return __TS__ObjectAssign({type = "rect"}, box, {rx = (outline and outline.type) == "rect" and (outline.rx or 0) or 0})
end
local function croppedBox(self, image, crop, pixels, box)
local scaleX = box.width / crop.width
local scaleY = box.height / crop.height
local scale = image.fit == "contain" and math.min(scaleX, scaleY) or math.max(scaleX, scaleY)
local sx, sy = table.unpack(image.fit == "fill" and ({scaleX, scaleY}) or ({scale, scale}), 1, 2)
return {x = box.x + (box.width - crop.width * sx) / 2 - crop.x * sx, y = box.y + (box.height - crop.height * sy) / 2 - crop.y * sy, width = pixels[1] * sx, height = pixels[2] * sy}
end
local ASPECTS = {cover = "slice", contain = "meet", fill = "none"}
function ____exports.renderShapeImage(self, context, outline, diagnostics)
local image = context.shape.image
if not image then
return nil
end
if image.crop and not image.pixels then
diagnostics[#diagnostics + 1] = {severity = "warning", code = "image-crop-without-size", ownerId = context.shape.id, message = ("The image '" .. context.shape.id) .. "' has a crop but no imageSize, so it is shown uncropped. Give it the size of the file, as imageSize: width, height."}
end
local box = {x = context.x, y = context.y, width = context.width, height = context.height}
local cropped = image.crop and image.pixels
return __TS__ObjectAssign(
{type = "image", id = context.id .. "-image", order = context.order, bounds = context.bounds},
cropped and croppedBox(
nil,
image,
image.crop,
image.pixels,
box
) or box,
{
href = image.src,
aspect = cropped and "none" or ASPECTS[image.fit],
rotation = context.rotation,
rotationCenter = context.rotationCenter,
style = {
opacity = context.style.opacity,
blur = context.style.blur,
blend = context.style.blend,
clip = clipOf(nil, outline, box),
pointerEvents = "none"
}
}
)
end
return ____exports
end,
["core.renderScene.artifacts.shape.shaderSurface"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local shapeOutline
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local freeformPathData = ____scene.freeformPathData
local rotatedBounds = ____scene.rotatedBounds
local ____pathCalculation = require("core.renderScene.artifacts.shape.geometry.pathCalculation")
local localShapePath = ____pathCalculation.localShapePath
function shapeOutline(self, context)
local ____context_0 = context
local x = ____context_0.x
local y = ____context_0.y
local width = ____context_0.width
local height = ____context_0.height
local ____type = context.shape.shapeType
if ____type == "circle" or ____type == "oval" then
local rx = width / 2
local ry = height / 2
local cy = y + ry
return {
type = "path",
d = ((((((((((((((((((("M " .. tostring(x)) .. " ") .. tostring(cy)) .. " A ") .. tostring(rx)) .. " ") .. tostring(ry)) .. " 0 1 0 ") .. tostring(x + width)) .. " ") .. tostring(cy)) .. " A ") .. tostring(rx)) .. " ") .. tostring(ry)) .. " 0 1 0 ") .. tostring(x)) .. " ") .. tostring(cy)) .. " Z"
}
end
if ____type == "symbol" then
local symbol = context.shape.symbol
if not symbol or #symbol.points < 3 then
return nil
end
local function place(____, ____bindingPattern0)
local py
local px
px = ____bindingPattern0[1]
py = ____bindingPattern0[2]
return {x = x + px * width, y = y + py * height}
end
local d = symbol.rings and table.concat(
__TS__ArrayMap(
symbol.rings,
function(____, ring) return freeformPathData(
nil,
{
points = __TS__ArrayMap(ring, place),
tension = 0,
closed = true
}
) end
),
" "
) or freeformPathData(
nil,
{
points = __TS__ArrayMap(symbol.points, place),
tension = symbol.tension or 0,
closed = true
}
)
return {type = "path", d = d}
end
local d = localShapePath(
nil,
____type,
x,
y,
width,
height
)
return __t(nil, d) and ({type = "path", d = d}) or nil
end
local RECT_PROGRAMS = __TS__New(Set, {
"reactivePanel",
"ledMatrix",
"lightBand",
"silkFolds",
"glowCard",
"glassDots",
"horizonGlow",
"lightStreaks",
"pulseLine",
"glassRefraction",
"grain",
"worn",
"cityMap"
})
local FILLING_PROGRAMS = __TS__New(Set, {
"horizonGlow",
"lightStreaks",
"grain",
"worn",
"cityMap"
})
local function fillsRectangle(____, context)
return Boolean(
nil,
context.shape.shader and RECT_PROGRAMS:has(context.shape.shader.program)
)
end
local function shaderMask(self, context)
local ____type = context.shape.shapeType
if (____type == "circle" or ____type == "oval") and not fillsRectangle(nil, context) then
return "ellipse"
end
local rectangular = ____type == "rectangle" or ____type == "rounded_rectangle"
if (rectangular or shapeOutline(nil, context)) and fillsRectangle(nil, context) then
return "rect"
end
return nil
end
function ____exports.renderShapeShaderSurface(self, context)
if not context.shape.shader then
return nil
end
local mask = shaderMask(nil, context)
if not __t(nil, mask) then
return nil
end
local padding = mask == "rect" and math.max(0, context.shape.shader.surfacePadding or 0) or 0
local surfaceBounds = {x = context.x - padding, y = context.y - padding, width = context.width + padding * 2, height = context.height + padding * 2}
local ____temp_4 = context.id .. "-shader"
local ____context_order_5 = context.order
local ____rotatedBounds_result_6 = rotatedBounds(nil, surfaceBounds, context.rotation, 0)
local ____context_rotation_7 = context.rotation
local ____temp_8 = mask == "rect" and context.shape.shader.program == "glassRefraction" and __TS__ObjectAssign(
{},
context.shape.shader,
{parameters = __TS__ObjectAssign({panel = 1, cornerRadius = context.shape.shapeType == "rounded_rectangle" and (context.shape.cornerRadius or 8) or 0}, context.shape.shader.parameters)}
) or context.shape.shader
local ____mask_9 = mask
local ____opt_1 = context.style.fill
local ____temp_10 = (____opt_1 and ____opt_1.kind) == "solid" and context.style.fill.color or nil
local ____temp_11 = context.shape.shapeType == "rounded_rectangle" and FILLING_PROGRAMS:has(context.shape.shader.program) and (context.shape.cornerRadius or 8) or nil
local ____fillsRectangle_result_3
if fillsRectangle(nil, context) then
____fillsRectangle_result_3 = shapeOutline(nil, context)
else
____fillsRectangle_result_3 = nil
end
return __TS__ObjectAssign({id = ____temp_4, type = "shader-surface", order = ____context_order_5, bounds = ____rotatedBounds_result_6}, surfaceBounds, {
rotation = ____context_rotation_7,
shader = ____temp_8,
mask = ____mask_9,
fillColor = ____temp_10,
cornerRadius = ____temp_11,
clip = ____fillsRectangle_result_3
})
end
return ____exports
end,
["core.renderScene.artifacts.shape.style"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local REMOVED_SHAPE_HINTS = {container_rectangle = " (use 'rectangle' with strokeStyle: dashed)"}
local COMMON_SHAPE_DEFAULTS = {
strokeColor = "#cbd5e1",
strokeWidth = 2,
fillColor = "#ffffff",
dash = {},
strokeStyle = "solid",
fontSize = 14,
fontWeight = "normal",
textAlign = "center",
textVerticalAlign = "middle",
lineHeight = 1.3,
hasShadow = false,
opacity = 1
}
local SHAPE_RENDER_DEFAULTS = {
rectangle = COMMON_SHAPE_DEFAULTS,
rounded_rectangle = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {cornerRadius = 8}),
triangle = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
diamond = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
hexagon = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
oval = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
circle = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
document = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
parallelogram = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
trapezoid = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
cylinder = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
note = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
cloud = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
predefined_process = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
pill = COMMON_SHAPE_DEFAULTS,
person = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0}),
symbol = __TS__ObjectAssign({}, COMMON_SHAPE_DEFAULTS, {rotation = 0})
}
function ____exports.shapeDefaults(self, shape, diagnostics)
local defaults = SHAPE_RENDER_DEFAULTS[shape.shapeType]
if defaults then
return defaults
end
diagnostics[#diagnostics + 1] = {severity = "warning", code = "unknown-shape-type", ownerId = shape.id, message = ((("Unknown shapeType '" .. shape.shapeType) .. "'") .. (REMOVED_SHAPE_HINTS[shape.shapeType] or "")) .. ", falling back to rectangle defaults."}
return SHAPE_RENDER_DEFAULTS.rectangle
end
local function shapeDash(self, shape, strokeWidth)
if shape.strokeStyle == "dotted" then
return {0.001, strokeWidth * 2}
end
if shape.strokeStyle == "dashed" then
return {strokeWidth * 4, strokeWidth * 2}
end
local ____t_2 = __t
local ____opt_0 = shape.dash
return ____t_2(nil, ____opt_0 and #____opt_0) and shape.dash or nil
end
function ____exports.shapeStyle(self, shape, diagnostics)
local defaults = ____exports.shapeDefaults(nil, shape, diagnostics)
local strokeWidth = finite(nil, shape.strokeWidth, defaults.strokeWidth)
local shadow = shape.shadowStyle or (shape.hasShadow and ({
enabled = true,
color = "#000000",
opacity = 0.25,
blur = 10,
angle = 45,
distance = 5
}) or nil)
local angle = finite(nil, shadow and shadow.angle, 45) * math.pi / 180
return {
fill = paint(nil, shape.fillColor, diagnostics, shape.id),
stroke = paint(nil, shape.strokeColor, diagnostics, shape.id),
strokeWidth = strokeWidth,
dash = shapeDash(nil, shape, strokeWidth),
lineCap = shape.strokeStyle == "dotted" and "round" or "butt",
opacity = finite(nil, shape.opacity, defaults.opacity),
transition = shape.transition,
blur = shape.blur ~= nil and shape.blur > 0 and shape.blur or nil,
blend = shape.blend,
shadow = shadow and shadow.enabled and ({
color = shadow.color or "#000000",
opacity = finite(nil, shadow.opacity, 0.25),
blur = finite(nil, shadow.blur, 10),
dx = math.cos(angle) * finite(nil, shadow.distance, 5),
dy = math.sin(angle) * finite(nil, shadow.distance, 5)
}) or nil
}
end
return ____exports
end,
["core.renderScene.scene.richTextLayout"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringSlice = ____lualib.__TS__StringSlice
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __exec = ______shims.__exec
local __re = ______shims.__re
local __split = ______shims.__split
local __t = ______shims.__t
local __test = ______shims.__test
local BOLD_PATTERN = __re(nil, "\\*\\*([^*]+)\\*\\*", "g")
function ____exports.hasBoldMarkup(self, text)
return __test(
nil,
__re(nil, "\\*\\*[^*]+\\*\\*", ""),
text
)
end
function ____exports.parseRichLine(self, line)
local runs = {}
local lastIndex = 0
BOLD_PATTERN.lastIndex = 0
local match
while true do
match = __exec(nil, BOLD_PATTERN, line)
if not match then
break
end
if match.index > lastIndex then
runs[#runs + 1] = {
text = __TS__StringSlice(line, lastIndex, match.index),
bold = false
}
end
if __t(nil, match[2]) then
runs[#runs + 1] = {text = match[2], bold = true}
end
lastIndex = BOLD_PATTERN.lastIndex
end
if lastIndex < #line then
runs[#runs + 1] = {
text = __TS__StringSlice(line, lastIndex),
bold = false
}
end
return __t(nil, #runs) and runs or ({{text = line, bold = false}})
end
function ____exports.parseRichText(self, text)
return __TS__ArrayMap(
__TS__StringSplit(text, "\n"),
____exports.parseRichLine
)
end
local function runsToWords(self, runs)
local words = {}
for ____, run in ipairs(runs) do
for ____, word in ipairs(__split(
nil,
run.text,
__re(nil, "\\s+", "")
)) do
if __t(nil, word) then
words[#words + 1] = {text = word, bold = run.bold}
end
end
end
return words
end
function ____exports.wrapRichLine(self, runs, maxWidth, measure, spaceWidth)
local words = runsToWords(nil, runs)
if not __t(nil, #words) then
return {{}}
end
local lines = {}
local current = {}
local currentWidth = 0
for ____, word in ipairs(words) do
local wordWidth = measure(nil, word.text, word.bold)
local addedWidth = __t(nil, #current) and spaceWidth + wordWidth or wordWidth
if __t(nil, #current) and currentWidth + addedWidth > maxWidth then
lines[#lines + 1] = current
current = {word}
currentWidth = wordWidth
else
current[#current + 1] = word
currentWidth = currentWidth + addedWidth
end
end
lines[#lines + 1] = current
return lines
end
function ____exports.wrapRichText(self, text, maxWidth, measure, spaceWidth)
return __TS__ArrayFlatMap(
____exports.parseRichText(nil, text),
function(____, runs) return ____exports.wrapRichLine(
nil,
runs,
math.max(1, maxWidth),
measure,
spaceWidth
) end
)
end
return ____exports
end,
["core.renderScene.artifacts.shape.text"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local ____richTextLayout = require("core.renderScene.scene.richTextLayout")
local hasBoldMarkup = ____richTextLayout.hasBoldMarkup
local wrapRichText = ____richTextLayout.wrapRichText
local ____textLayout = require("core.renderScene.scene.textLayout")
local heuristicRichMeasure = ____textLayout.heuristicRichMeasure
local wrapText = ____textLayout.wrapText
local ____roundedForms = require("core.renderScene.artifacts.shape.geometry.roundedForms")
local personLabelArea = ____roundedForms.personLabelArea
local ____style = require("core.renderScene.artifacts.shape.style")
local shapeDefaults = ____style.shapeDefaults
function ____exports.renderShapeText(self, context, strokeWidth, measureText)
local ____context_0 = context
local shape = ____context_0.shape
local bounds = ____context_0.bounds
local order = ____context_0.order
local rotation = ____context_0.rotation
local rotationCenter = ____context_0.rotationCenter
local x = ____context_0.x
local y = ____context_0.y
local width = ____context_0.width
local height = ____context_0.height
if not __t(nil, shape.text) then
return nil
end
local fontSize = finite(
nil,
shape.fontSize,
shapeDefaults(nil, shape, {}).fontSize
)
local padding = shape.isText and 0 or math.max(8, strokeWidth * 2)
local area = shape.shapeType == "person" and personLabelArea(
nil,
x,
y,
width,
height
) or ({x = x, y = y, width = width, height = height})
local textWidth = math.max(0, area.width - padding * 2)
local fontFamily = __lor(
nil,
shape.fontFamily,
function() return DEFAULT_FONT end
)
local metrics = measureText and measureText(nil, fontFamily, fontSize)
local textNode = {
type = "text",
id = "shape-text-" .. shape.id,
order = order + 0.5,
bounds = bounds,
x = area.x + padding,
y = area.y + padding,
width = textWidth,
height = math.max(0, area.height - padding * 2),
lines = wrapText(
nil,
shape.text,
textWidth,
fontSize,
metrics
),
fontFamily = fontFamily,
fontSize = fontSize,
fontWeight = shape.fontWeight or "normal",
letterSpacing = shape.letterSpacing,
color = __lor(
nil,
shape.textColor,
function() return "#111827" end
),
align = shape.textAlign or "center",
verticalAlign = shape.textVerticalAlign or "middle",
lineHeight = finite(nil, shape.lineHeight, 1.3),
rotation = rotation,
rotationCenter = rotationCenter
}
if hasBoldMarkup(nil, shape.text) then
local ____temp_3 = metrics or heuristicRichMeasure(nil, fontSize)
local measure = ____temp_3.measure
local spaceWidth = ____temp_3.spaceWidth
textNode.richLines = wrapRichText(
nil,
shape.text,
textWidth,
measure,
spaceWidth
)
end
return textNode
end
return ____exports
end,
["core.renderScene.artifacts.shape"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayPush = ____lualib.__TS__ArrayPush
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local rotatedBounds = ____scene.rotatedBounds
local ____tagging = require("core.renderScene.scene.tagging")
local tag = ____tagging.tag
local ____geometry = require("core.renderScene.artifacts.shape.geometry.index")
local renderShapeGeometry = ____geometry.renderShapeGeometry
local ____image = require("core.renderScene.artifacts.shape.image")
local renderShapeImage = ____image.renderShapeImage
local ____shaderSurface = require("core.renderScene.artifacts.shape.shaderSurface")
local renderShapeShaderSurface = ____shaderSurface.renderShapeShaderSurface
local ____style = require("core.renderScene.artifacts.shape.style")
local shapeStyle = ____style.shapeStyle
local ____text = require("core.renderScene.artifacts.shape.text")
local renderShapeText = ____text.renderShapeText
local function renderDoubleStroke(self, context, strokeWidth)
local insetWidth = math.max(0, context.width - 2 * strokeWidth)
local insetHeight = math.max(0, context.height - 2 * strokeWidth)
local ring = __TS__ObjectAssign(
{},
context.style,
{
fill = {kind = "none"},
strokeWidth = math.max(1, strokeWidth / 3),
dash = nil,
shadow = nil
}
)
local nodes = renderShapeGeometry(
nil,
__TS__ObjectAssign({}, context, {style = ring})
)
if insetWidth <= 0 or insetHeight <= 0 then
return nodes
end
local inset = __TS__ObjectAssign({}, context, {x = context.x + strokeWidth, y = context.y + strokeWidth, width = insetWidth, height = insetHeight})
local ____array_0 = __TS__SparseArrayNew(table.unpack(renderShapeGeometry(
nil,
__TS__ObjectAssign(
{},
inset,
{
id = context.id .. "-fill",
style = __TS__ObjectAssign({}, context.style, {stroke = {kind = "none"}, strokeWidth = 0, dash = nil})
}
)
)))
__TS__SparseArrayPush(
____array_0,
table.unpack(renderShapeGeometry(
nil,
__TS__ObjectAssign({}, inset, {id = context.id .. "-inner", style = ring})
))
)
__TS__ArrayPush(
nodes,
__TS__SparseArraySpread(____array_0)
)
return nodes
end
local function createRenderContext(self, shape, index, diagnostics)
local x = finite(nil, shape.x, 0)
local y = finite(nil, shape.y, 0)
local width = math.max(
0,
finite(nil, shape.width, 100)
)
local height = math.max(
0,
finite(nil, shape.height, 100)
)
local rotation = finite(nil, shape.rotation, 0)
local strokeWidth = finite(nil, shape.strokeWidth, 2)
return {
strokeWidth = strokeWidth,
context = {
shape = shape,
id = "shape-" .. shape.id,
order = 10000 + index,
bounds = rotatedBounds(nil, {x = x, y = y, width = width, height = height}, rotation, strokeWidth + (shape.hasShadow and 20 or 2)),
rotation = rotation,
rotationCenter = {x = x + width / 2, y = y + height / 2},
style = shapeStyle(nil, shape, diagnostics),
x = x,
y = y,
width = width,
height = height
}
}
end
function ____exports.buildShape(self, shape, index, diagnostics, measureText)
if shape.isVisible == false then
return {}
end
local ____createRenderContext_result_1 = createRenderContext(nil, shape, index, diagnostics)
local context = ____createRenderContext_result_1.context
local strokeWidth = ____createRenderContext_result_1.strokeWidth
local nodes = shape.strokeStyle == "double" and renderDoubleStroke(
nil,
context,
__lor(
nil,
strokeWidth,
function() return 1 end
)
) or renderShapeGeometry(nil, context)
local shader = renderShapeShaderSurface(nil, context)
if shader then
for ____, node in ipairs(nodes) do
if node.type == "ellipse" or node.type == "path" or node.type == "rect" then
node.style = __TS__ObjectAssign({}, node.style, {pointerEvents = "all"})
end
end
nodes[#nodes + 1] = shader
end
local image = renderShapeImage(nil, context, nodes[1], diagnostics)
if image then
for ____, node in ipairs(nodes) do
if node.type == "ellipse" or node.type == "path" or node.type == "rect" then
node.style = __TS__ObjectAssign({}, node.style, {pointerEvents = "all"})
end
end
nodes[#nodes + 1] = image
end
if shape.isText then
for ____, node in ipairs(nodes) do
if node.type == "ellipse" or node.type == "path" or node.type == "rect" then
node.style = __TS__ObjectAssign({}, node.style, {pointerEvents = "all"})
end
end
end
local text = renderShapeText(nil, context, strokeWidth, measureText)
if text then
local ____temp_4
if text.type == "text" then
local ____shape_transition_3 = shape.transition
local ____shape_isText_2
if shape.isText then
____shape_isText_2 = context.style.opacity
else
____shape_isText_2 = nil
end
____temp_4 = __TS__ObjectAssign({}, text, {transition = ____shape_transition_3, opacity = ____shape_isText_2})
else
____temp_4 = text
end
nodes[#nodes + 1] = ____temp_4
end
return nodes
end
function ____exports.buildShapes(self, shapes, diagnostics, measureText)
return __TS__ArrayFlatMap(
shapes,
function(____, shape, index) return tag(
nil,
____exports.buildShape(
nil,
shape,
index,
diagnostics,
measureText
),
"shape",
shape.id,
shape.shapeType,
__lor(
nil,
shape.text,
function() return shape.shapeType end
),
shape.parentFrameId or nil
) end
)
end
return ____exports
end,
["core.renderScene.charts.chartRenderOrder"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
____exports.ChartRenderOrder = __TS__Class()
local ChartRenderOrder = ____exports.ChartRenderOrder
ChartRenderOrder.name = "ChartRenderOrder"
function ChartRenderOrder.prototype.____constructor(self, baseOrder)
self._p_offset = 0.01
self.next = function()
local ____self__p_baseOrder_3 = self._p_baseOrder
local ____self_0, ____p_offset_1 = self, "_p_offset"
local ____self__p_offset_2 = ____self_0[____p_offset_1]
____self_0[____p_offset_1] = ____self__p_offset_2 + 1
return ____self__p_baseOrder_3 + ____self__p_offset_2
end
self._p_baseOrder = baseOrder
end
function ChartRenderOrder.prototype.current(self)
return self._p_baseOrder + self._p_offset
end
function ChartRenderOrder.prototype.advance(self, nodeCount)
self._p_offset = self._p_offset + nodeCount
end
return ____exports
end,
["core.renderScene.charts.chartBackdrop"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
function ____exports.chartImageRect(self, chart)
local inset = finite(nil, chart.strokeWidth, 1) / 2
return {
x = chart.x + inset,
y = chart.y + inset,
width = math.max(1, chart.width - inset * 2),
height = math.max(1, chart.height - inset * 2),
rx = math.max(
0,
finite(nil, chart.cornerRadius, 12) - inset
)
}
end
function ____exports.buildChartBackdrop(self, chart, bounds, order)
if not chart.fillImage then
return {}
end
local rect = ____exports.chartImageRect(nil, chart)
local nodes = {{
type = "image",
id = "chart-image-" .. chart.id,
order = order:next(),
bounds = bounds,
x = rect.x,
y = rect.y,
width = rect.width,
height = rect.height,
href = chart.fillImage.url,
style = {
clip = __TS__ObjectAssign({type = "rect"}, rect),
pointerEvents = "none"
}
}}
if __t(nil, chart.fillImage.overlay) then
nodes[#nodes + 1] = {
type = "rect",
id = "chart-image-overlay-" .. chart.id,
order = order:next(),
bounds = bounds,
x = rect.x,
y = rect.y,
width = rect.width,
height = rect.height,
rx = rect.rx,
style = {fill = {kind = "solid", color = chart.fillImage.overlay}, pointerEvents = "none"}
}
end
return nodes
end
return ____exports
end,
["core.renderScene.charts.primitives.defaults"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.CHART_COLORS = {
"#7c3aed",
"#0ea5e9",
"#f97316",
"#10b981",
"#ec4899",
"#eab308"
}
____exports.DEFAULT_ZONE_FILL = "#94a3b8"
____exports.DEFAULT_HEATMAP_ZONES = {{label = "Low", color = "#ddd6fe"}, {label = "Medium", color = "#a78bfa"}, {label = "High", color = "#6d28d9"}}
____exports.DEFAULT_HEX_RADIUS = 14
return ____exports
end,
["core.renderScene.charts.primitives.axis"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __sort = ______shims.__sort
local __t = ______shims.__t
local ____color = require("core.model.color.index")
local interpolateHexColorStops = ____color.interpolateHexColorStops
local ____defaults = require("core.renderScene.charts.primitives.defaults")
local DEFAULT_ZONE_FILL = ____defaults.DEFAULT_ZONE_FILL
function ____exports.mapChartValue(self, value, axis, extent)
if axis.max == axis.min then
return 0
end
return (value - axis.min) / (axis.max - axis.min) * extent
end
function ____exports.chartTicks(self, axis)
if not (axis.step > 0) then
return axis.min == axis.max and ({axis.min}) or ({axis.min, axis.max})
end
local ascending = axis.min <= axis.max
local step = ascending and axis.step or -axis.step
local ticks = {}
do
local value = axis.min
while true do
local ____ascending_0
if ascending then
____ascending_0 = value <= axis.max + 1e-9
else
____ascending_0 = value >= axis.max - 1e-9
end
if not (____ascending_0 and #ticks < 1000) then
break
end
ticks[#ticks + 1] = math.floor(value * 1000 + 0.5) / 1000
value = value + step
end
end
return ticks
end
function ____exports.axisBands(self, axis)
local thresholds = __sort(
nil,
__TS__ArrayFilter(
{table.unpack(axis.thresholds or ({}))},
function(____, threshold) return threshold > axis.min and threshold < axis.max end
),
function(____, a, b) return a - b end
)
local ____array_1 = __TS__SparseArrayNew(
axis.min,
table.unpack(thresholds)
)
__TS__SparseArrayPush(____array_1, axis.max)
return {__TS__SparseArraySpread(____array_1)}
end
function ____exports.zoneColorAtValue(self, value, bands, zones)
local bandCount = math.max(0, #bands - 1)
local stops = __TS__ArrayMap(
__TS__ArraySlice(zones, 0, bandCount),
function(____, zone, index) return {position = bands[index + 1 + 1] or bands[#bands], color = zone.color or DEFAULT_ZONE_FILL} end
)
if not __t(nil, #stops) then
return DEFAULT_ZONE_FILL
end
return interpolateHexColorStops(nil, stops, value)
end
return ____exports
end,
["core.renderScene.charts.primitives.barCategories"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
function ____exports.barCategoryCount(self, chart)
local ____opt_2 = chart.config
local ____opt_0 = ____opt_2 and ____opt_2.categories
return math.max(
1,
____opt_0 and #____opt_0 or 0,
table.unpack(__TS__ArrayMap(
chart.series,
function(____, series) return #series.values end
))
)
end
return ____exports
end,
["core.renderScene.charts.primitives.barLabel"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringReplace = ____lualib.__TS__StringReplace
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
____exports.BAR_LABEL = {
padX = 8,
padY = 3,
charWidth = 0.58,
lineHeight = 1.2,
gap = 4
}
function ____exports.formatBarLabel(self, value, template)
return __TS__StringReplace(
__lor(
nil,
template,
function() return "{value}" end
),
"{value}",
tostring(math.floor(value * 100 + 0.5) / 100)
)
end
function ____exports.barLabelSize(self, text, fontSize, pill)
local padX = pill and ____exports.BAR_LABEL.padX or 0
local padY = pill and ____exports.BAR_LABEL.padY or 0
local lineHeight = fontSize * ____exports.BAR_LABEL.lineHeight
return {
width = #text * fontSize * ____exports.BAR_LABEL.charWidth + padX * 2,
height = lineHeight + padY * 2,
lineHeight = lineHeight,
padX = padX,
padY = padY
}
end
function ____exports.pillPath(self, x, y, width, height)
local r = height / 2
return (((((((((((((("M " .. tostring(x + r)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width - r)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 0 1 ") .. tostring(x + width - r)) .. " ") .. tostring(y + height)) .. " ") .. ((((((((("H " .. tostring(x + r)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 0 1 ") .. tostring(x + r)) .. " ") .. tostring(y)) .. " Z"
end
return ____exports
end,
["core.renderScene.charts.primitives.barShape"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.barShapePath(self, x, y, width, height, radius)
local r = math.max(
0,
math.min(radius, width / 2, height)
)
if r == 0 then
return ((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width)) .. " V ") .. tostring(y + height)) .. " H ") .. tostring(x)) .. " Z"
end
return (((((((("M " .. tostring(x)) .. " ") .. tostring(y + r)) .. " ") .. ((((((("Q " .. tostring(x)) .. " ") .. tostring(y)) .. " ") .. tostring(x + r)) .. " ") .. tostring(y)) .. " ") .. ("H " .. tostring(x + width - r)) .. " ") .. ((((((("Q " .. tostring(x + width)) .. " ") .. tostring(y)) .. " ") .. tostring(x + width)) .. " ") .. tostring(y + r)) .. " ") .. ("V " .. tostring(y + height)) .. " ") .. ("H " .. tostring(x)) .. " Z"
end
function ____exports.roundedBarPath(self, x, y, width, height, radius)
local r = math.max(
0,
math.min(radius, width / 2, height / 2)
)
if r == 0 then
return ((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width)) .. " V ") .. tostring(y + height)) .. " H ") .. tostring(x)) .. " Z"
end
return ((((((((((((((("M " .. tostring(x + r)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width - r)) .. " Q ") .. tostring(x + width)) .. " ") .. tostring(y)) .. " ") .. tostring(x + width)) .. " ") .. tostring(y + r)) .. " ") .. ((((((((("V " .. tostring(y + height - r)) .. " Q ") .. tostring(x + width)) .. " ") .. tostring(y + height)) .. " ") .. tostring(x + width - r)) .. " ") .. tostring(y + height)) .. " ") .. ((((((((((((((((((("H " .. tostring(x + r)) .. " Q ") .. tostring(x)) .. " ") .. tostring(y + height)) .. " ") .. tostring(x)) .. " ") .. tostring(y + height - r)) .. " V ") .. tostring(y + r)) .. " Q ") .. tostring(x)) .. " ") .. tostring(y)) .. " ") .. tostring(x + r)) .. " ") .. tostring(y)) .. " Z"
end
function ____exports.barPath(self, x, y, width, height, radius, roundedBottom)
return roundedBottom and ____exports.roundedBarPath(
nil,
x,
y,
width,
height,
radius
) or ____exports.barShapePath(
nil,
x,
y,
width,
height,
radius
)
end
return ____exports
end,
["core.renderScene.charts.primitives.boxplot"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __sort = ______shims.__sort
local __t = ______shims.__t
local function quantile(self, sorted, probability)
if #sorted == 1 then
return sorted[1]
end
local position = (#sorted - 1) * probability
local lowerIndex = math.floor(position)
local upperIndex = math.ceil(position)
if lowerIndex == upperIndex then
return sorted[lowerIndex + 1]
end
return sorted[lowerIndex + 1] + (position - lowerIndex) * (sorted[upperIndex + 1] - sorted[lowerIndex + 1])
end
function ____exports.computeBoxplotStats(self, values)
if not __t(nil, values and #values) then
return nil
end
local sorted = __sort(
nil,
{table.unpack(values)},
function(____, a, b) return a - b end
)
return {
min = sorted[1],
q1 = quantile(nil, sorted, 0.25),
median = quantile(nil, sorted, 0.5),
q3 = quantile(nil, sorted, 0.75),
max = sorted[#sorted]
}
end
return ____exports
end,
["core.renderScene.color"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
local ____exports = {}
local ____color = require("core.model.color.index")
local parseHexRgb = ____color.parseHexRgb
local rgbToHex = ____color.rgbToHex
local function hexToRgb(self, hex)
local ____hex_startsWith_result_2
local ____opt_0 = hex
if ____opt_0 and __TS__StringStartsWith(hex, "#") then
____hex_startsWith_result_2 = parseHexRgb(nil, hex) or nil
else
____hex_startsWith_result_2 = nil
end
return ____hex_startsWith_result_2
end
function ____exports.colorWithAlpha(self, hex, alpha)
local rgb = hexToRgb(nil, hex)
local clamped = math.max(
0,
math.min(1, alpha)
)
if not rgb then
return clamped <= 0 and "transparent" or (hex or "transparent")
end
local red, green, blue = table.unpack(rgb, 1, 3)
return ((((((("rgba(" .. tostring(red)) .. ", ") .. tostring(green)) .. ", ") .. tostring(blue)) .. ", ") .. tostring(clamped)) .. ")"
end
local function rgbToHsl(self, red, green, blue)
local r = red / 255
local g = green / 255
local b = blue / 255
local max = math.max(r, g, b)
local min = math.min(r, g, b)
local lightness = (max + min) / 2
local delta = max - min
if delta == 0 then
return {0, 0, lightness}
end
local saturation = delta / (1 - math.abs(2 * lightness - 1))
local hue
if max == r then
hue = (g - b) / delta % 6
elseif max == g then
hue = (b - r) / delta + 2
else
hue = (r - g) / delta + 4
end
hue = hue * 60
if hue < 0 then
hue = hue + 360
end
return {hue, saturation, lightness}
end
local function hslToRgb(self, hue, saturation, lightness)
local chroma = (1 - math.abs(2 * lightness - 1)) * saturation
local x = chroma * (1 - math.abs(hue / 60 % 2 - 1))
local m = lightness - chroma / 2
local r, g, b = 0, 0, 0
if hue < 60 then
r, g, b = chroma, x, 0
elseif hue < 120 then
r, g, b = x, chroma, 0
elseif hue < 180 then
r, g, b = 0, chroma, x
elseif hue < 240 then
r, g, b = 0, x, chroma
elseif hue < 300 then
r, g, b = x, 0, chroma
else
r, g, b = chroma, 0, x
end
return {(r + m) * 255, (g + m) * 255, (b + m) * 255}
end
local function relativeLuminance(self, red, green, blue)
local function linear(____, channel)
local normalized = channel / 255
return normalized <= 0.03928 and normalized / 12.92 or ((normalized + 0.055) / 1.055) ^ 2.4
end
return 0.2126 * linear(nil, red) + 0.7152 * linear(nil, green) + 0.0722 * linear(nil, blue)
end
local function contrastRatio(self, luminanceA, luminanceB)
local lighter = math.max(luminanceA, luminanceB)
local darker = math.min(luminanceA, luminanceB)
return (lighter + 0.05) / (darker + 0.05)
end
local SAME_HUE_LIGHTNESS_GAP = 0.35
local SAME_HUE_MIN_LIGHTNESS = 0.08
local SAME_HUE_MAX_LIGHTNESS = 0.22
local SAME_HUE_LIGHT_MIN_LIGHTNESS = 0.78
local SAME_HUE_LIGHT_MAX_LIGHTNESS = 0.92
local SAME_HUE_MIN_CONTRAST = 3
function ____exports.contrastTextColor(self, hex)
local rgb = hexToRgb(nil, hex)
if not rgb then
return "#0f172a"
end
local red, green, blue = table.unpack(rgb, 1, 3)
local fallback = (0.299 * red + 0.587 * green + 0.114 * blue) / 255 > 0.6 and "#0f172a" or "#ffffff"
local hue, saturation, lightness = table.unpack(
rgbToHsl(nil, red, green, blue),
1,
3
)
if saturation == 0 then
return fallback
end
local targetLightness = lightness > 0.5 and math.max(
SAME_HUE_MIN_LIGHTNESS,
math.min(lightness - SAME_HUE_LIGHTNESS_GAP, SAME_HUE_MAX_LIGHTNESS)
) or math.min(
SAME_HUE_LIGHT_MAX_LIGHTNESS,
math.max(lightness + SAME_HUE_LIGHTNESS_GAP, SAME_HUE_LIGHT_MIN_LIGHTNESS)
)
local variant = hslToRgb(nil, hue, saturation, targetLightness)
local ratio = contrastRatio(
nil,
relativeLuminance(nil, red, green, blue),
relativeLuminance(
nil,
table.unpack(variant)
)
)
return ratio >= SAME_HUE_MIN_CONTRAST and rgbToHex(
nil,
table.unpack(variant)
) or fallback
end
function ____exports.sameHueContrastColor(self, hex, fallback)
local rgb = hexToRgb(nil, hex)
if not rgb then
return fallback
end
local red, green, blue = table.unpack(rgb, 1, 3)
local hue, saturation, lightness = table.unpack(
rgbToHsl(nil, red, green, blue),
1,
3
)
if saturation == 0 then
return fallback
end
local targetLightness = lightness > 0.5 and math.max(
SAME_HUE_MIN_LIGHTNESS,
math.min(lightness - SAME_HUE_LIGHTNESS_GAP, SAME_HUE_MAX_LIGHTNESS)
) or math.min(
SAME_HUE_LIGHT_MAX_LIGHTNESS,
math.max(lightness + SAME_HUE_LIGHTNESS_GAP, SAME_HUE_LIGHT_MIN_LIGHTNESS)
)
return rgbToHex(
nil,
table.unpack(hslToRgb(nil, hue, saturation, targetLightness))
)
end
function ____exports.isLightColor(self, hex)
local rgb = hexToRgb(nil, hex)
local ____rgb_3
if rgb then
____rgb_3 = rgbToHsl(
nil,
table.unpack(rgb)
)[3] > 0.5
else
____rgb_3 = false
end
return ____rgb_3
end
function ____exports.sameHueTint(self, hex, targetLightness)
local rgb = hexToRgb(nil, hex)
if not rgb then
return nil
end
local hue, saturation = table.unpack(
rgbToHsl(
nil,
table.unpack(rgb)
),
1,
2
)
if saturation == 0 then
return nil
end
return rgbToHex(
nil,
table.unpack(hslToRgb(nil, hue, saturation, targetLightness))
)
end
return ____exports
end,
["core.renderScene.charts.primitives.colors"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
do
local ____color = require("core.renderScene.color")
____exports.contrastTextColor = ____color.contrastTextColor
____exports.isLightColor = ____color.isLightColor
____exports.sameHueContrastColor = ____color.sameHueContrastColor
____exports.sameHueTint = ____color.sameHueTint
end
function ____exports.representativeColor(self, value, fallback)
if not __t(nil, value) then
return fallback
end
if type(value) == "string" then
return value
end
if value.type == "gradient" then
local ____opt_0 = value.stops[1]
return ____opt_0 and ____opt_0.color or fallback
end
local ____opt_2 = value.points[1]
return ____opt_2 and ____opt_2.color or fallback
end
return ____exports
end,
["core.renderScene.charts.primitives.errors"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local ____exports = {}
local verticalErrorWhiskerPath, ERROR_CAP_HALF
function verticalErrorWhiskerPath(self, geometry)
local ____geometry_0 = geometry
local centerX = ____geometry_0.centerX
local startY = ____geometry_0.startY
local endY = ____geometry_0.endY
local capStartX = centerX - ERROR_CAP_HALF
local capEndX = centerX + ERROR_CAP_HALF
return (((((((((((((((((((((("M " .. tostring(centerX)) .. " ") .. tostring(startY)) .. " L ") .. tostring(centerX)) .. " ") .. tostring(endY)) .. " M ") .. tostring(capStartX)) .. " ") .. tostring(startY)) .. " L ") .. tostring(capEndX)) .. " ") .. tostring(startY)) .. " M ") .. tostring(capStartX)) .. " ") .. tostring(endY)) .. " L ") .. tostring(capEndX)) .. " ") .. tostring(endY)
end
ERROR_CAP_HALF = 5
function ____exports.errorBarRange(self, value, ____error)
return __TS__ArrayIsArray(____error) and ({value - ____error[1], value + ____error[2]}) or ({value - ____error, value + ____error})
end
function ____exports.createVerticalErrorWhiskerNode(self, whisker)
return {
type = "path",
id = whisker.id,
order = whisker.order,
bounds = whisker.bounds,
d = verticalErrorWhiskerPath(nil, whisker.geometry),
detail = {of = "chartValue", series = whisker.valueReference.seriesId, valueIndex = whisker.valueReference.valueIndex},
style = {fill = {kind = "none"}, stroke = {kind = "solid", color = whisker.color}, strokeWidth = 1}
}
end
return ____exports
end,
["core.renderScene.charts.primitives.format"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__NumberIsInteger = ____lualib.__TS__NumberIsInteger
local __TS__NumberToFixed = ____lualib.__TS__NumberToFixed
local ____exports = {}
local ______shims = require("core.__shims")
local __re = ______shims.__re
local __replace = ______shims.__replace
function ____exports.formatFieldValue(self, value)
return __TS__NumberIsInteger(value) and tostring(value) or __replace(
nil,
__TS__NumberToFixed(value, 2),
__re(nil, "\\.?0+$", ""),
""
)
end
return ____exports
end,
["core.renderScene.charts.primitives.horizontalBars"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____barCategories = require("core.renderScene.charts.primitives.barCategories")
local barCategoryCount = ____barCategories.barCategoryCount
____exports.CATEGORY_LABEL_ROW = 18
local function settings(____, chart)
return chart.config
end
function ____exports.isHorizontalBar(self, chart)
local ____temp_2 = chart.chartType == "bar"
if ____temp_2 then
local ____opt_0 = settings(nil, chart)
____temp_2 = (____opt_0 and ____opt_0.orientation) == "horizontal"
end
return ____temp_2
end
function ____exports.horizontalRows(self, chart, plot)
local count = barCategoryCount(
nil,
{
series = chart.series,
config = settings(nil, chart)
}
)
local slotHeight = plot.height / count
local ____finite_5 = finite
local ____opt_3 = settings(nil, chart)
local groupGap = math.min(
math.max(
0,
____finite_5(nil, ____opt_3 and ____opt_3.barGroupGap, 8)
),
math.max(0, slotHeight - 1)
)
local labelRow = chart.categoryAlign == "left" and ____exports.CATEGORY_LABEL_ROW or 0
local available = math.max(1, slotHeight - groupGap - labelRow)
local ____finite_8 = finite
local ____opt_6 = settings(nil, chart)
local thickness = ____finite_8(nil, ____opt_6 and ____opt_6.barThickness, 0)
local barsHeight = thickness > 0 and math.min(available, thickness) or available
return {
count = count,
slotHeight = slotHeight,
groupGap = groupGap,
labelRow = labelRow,
barsHeight = barsHeight,
offset = (available - barsHeight) / 2
}
end
function ____exports.rowTop(self, rows, plot, index)
return plot.y + index * rows.slotHeight + rows.groupGap / 2 + rows.offset
end
return ____exports
end,
["core.renderScene.charts.primitives.labelTilt"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____textLayout = require("core.renderScene.scene.textLayout")
local estimateTextWidth = ____textLayout.estimateTextWidth
function ____exports.labelTilt(self, chart)
return math.min(
90,
math.max(
0,
finite(nil, chart.axisLabelAngle, 0)
)
)
end
local function radians(____, degrees)
return degrees * math.pi / 180
end
local function labelFontSize(self, chart)
return math.max(
9,
finite(nil, chart.axisFontSize or chart.fontSize, 12)
)
end
function ____exports.tiltedLabelRoom(self, chart, labels, tilt)
local fontSize = labelFontSize(nil, chart)
local widest = math.max(
0,
table.unpack(__TS__ArrayMap(
labels,
function(____, label) return estimateTextWidth(nil, label, fontSize, false) end
))
)
return math.ceil(widest * math.sin(radians(nil, tilt)) + (fontSize + 2) * math.cos(radians(nil, tilt)))
end
function ____exports.labelAboveFrame(self, chart, label, tilt, anchor)
local fontSize = labelFontSize(nil, chart)
local height = fontSize + 2
local width = math.ceil(estimateTextWidth(nil, label, fontSize, false)) + 4
local angle = radians(nil, tilt)
return {
frame = {
x = anchor.x - height / 2 * math.sin(angle),
y = anchor.y - height / 2 * math.cos(angle),
width = width,
height = height
},
rotation = -tilt
}
end
function ____exports.labelBelowFrame(self, chart, label, tilt, anchor)
local fontSize = labelFontSize(nil, chart)
local height = fontSize + 2
local width = math.ceil(estimateTextWidth(nil, label, fontSize, false)) + 4
local angle = radians(nil, tilt)
return {
frame = {
x = anchor.x - (width * math.cos(angle) + height / 2 * math.sin(angle)),
y = anchor.y + width * math.sin(angle) - height / 2 * math.cos(angle),
width = width,
height = height
},
rotation = -tilt
}
end
return ____exports
end,
["core.renderScene.charts.primitives.linePath"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____freeformPath = require("core.renderScene.scene.freeformPath")
local freeformPathData = ____freeformPath.freeformPathData
function ____exports.linePathData(self, points, tension)
if tension > 0 then
return freeformPathData(nil, {points = points, tension = tension, closed = false})
end
local commands = __TS__ArrayMap(
points,
function(____, point, index) return ((((__t(nil, index) and "L" or "") .. " ") .. tostring(point.x)) .. " ") .. tostring(point.y) end
)
return "M " .. table.concat(commands, " ")
end
return ____exports
end,
["core.renderScene.charts.primitives.pieShape"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.resolvePieRadii(self, plotWidth, plotHeight, configInnerRadius, configCornerRadius)
local rawOuterRadius = math.max(
1,
math.min(plotWidth, plotHeight) / 2 - 4
)
local rawInnerRadius = math.max(
0,
math.min(configInnerRadius or 0, rawOuterRadius - 1)
)
local cornerRadius = math.max(
0,
math.min(configCornerRadius or 0, rawOuterRadius / 2)
)
local outerRadius = math.max(1, rawOuterRadius - cornerRadius)
local innerRadius = rawInnerRadius > 0 and math.min(rawInnerRadius + cornerRadius, outerRadius - 1) or 0
return {outerRadius = outerRadius, innerRadius = innerRadius, cornerRadius = cornerRadius}
end
function ____exports.pieArcPoint(self, geometry, angle, radius)
return {
x = geometry.centerX + radius * math.cos(angle),
y = geometry.centerY + radius * math.sin(angle)
}
end
function ____exports.clipSegmentToRect(self, from, to, halfWidth, halfHeight)
local dx = to.x - from.x
local dy = to.y - from.y
local tMin = 0
local tMax = 1
if math.abs(dx) > 0.000001 then
local tx1 = (to.x - halfWidth - from.x) / dx
local tx2 = (to.x + halfWidth - from.x) / dx
tMin = math.max(
tMin,
math.min(tx1, tx2)
)
tMax = math.min(
tMax,
math.max(tx1, tx2)
)
end
if math.abs(dy) > 0.000001 then
local ty1 = (to.y - halfHeight - from.y) / dy
local ty2 = (to.y + halfHeight - from.y) / dy
tMin = math.max(
tMin,
math.min(ty1, ty2)
)
tMax = math.min(
tMax,
math.max(ty1, ty2)
)
end
local t = tMin <= tMax and tMin or 1
return {x = from.x + t * dx, y = from.y + t * dy}
end
local function largeArcFlag(self, a, b)
return math.abs(b - a) > math.pi and 1 or 0
end
function ____exports.gapInsetAngle(self, halfGap, radius)
if halfGap <= 0 or radius <= 0 then
return 0
end
return math.asin(math.min(1, halfGap / radius))
end
local function insetAngles(self, angles, inset)
return {start = angles.start + inset, ["end"] = angles["end"] - inset}
end
function ____exports.pieApexRadius(self, halfGap, sweep, outerRadius)
if halfGap <= 0 then
return 0
end
local halfSweep = math.min(
math.abs(sweep) / 2,
math.pi / 2
)
local denominator = math.sin(halfSweep)
return denominator <= 0.000001 and outerRadius or math.min(halfGap / denominator, outerRadius)
end
local function apexSlicePath(self, geometry, outerAngles, apex)
local start = ____exports.pieArcPoint(nil, geometry, outerAngles.start, geometry.outerRadius)
local ____end = ____exports.pieArcPoint(nil, geometry, outerAngles["end"], geometry.outerRadius)
return table.concat(
{
(("M " .. tostring(apex.x)) .. " ") .. tostring(apex.y),
(("L " .. tostring(start.x)) .. " ") .. tostring(start.y),
(((((((("A " .. tostring(geometry.outerRadius)) .. " ") .. tostring(geometry.outerRadius)) .. " 0 ") .. tostring(largeArcFlag(nil, outerAngles.start, outerAngles["end"]))) .. " 1 ") .. tostring(____end.x)) .. " ") .. tostring(____end.y),
"Z"
},
" "
)
end
local function donutSlicePath(self, geometry, innerRadius, outerAngles, innerAngles)
local outerStart = ____exports.pieArcPoint(nil, geometry, outerAngles.start, geometry.outerRadius)
local outerEnd = ____exports.pieArcPoint(nil, geometry, outerAngles["end"], geometry.outerRadius)
local innerEnd = ____exports.pieArcPoint(nil, geometry, innerAngles["end"], innerRadius)
local innerStart = ____exports.pieArcPoint(nil, geometry, innerAngles.start, innerRadius)
return table.concat(
{
(("M " .. tostring(outerStart.x)) .. " ") .. tostring(outerStart.y),
(((((((("A " .. tostring(geometry.outerRadius)) .. " ") .. tostring(geometry.outerRadius)) .. " 0 ") .. tostring(largeArcFlag(nil, outerAngles.start, outerAngles["end"]))) .. " 1 ") .. tostring(outerEnd.x)) .. " ") .. tostring(outerEnd.y),
(("L " .. tostring(innerEnd.x)) .. " ") .. tostring(innerEnd.y),
(((((((("A " .. tostring(innerRadius)) .. " ") .. tostring(innerRadius)) .. " 0 ") .. tostring(largeArcFlag(nil, innerAngles.start, innerAngles["end"]))) .. " 0 ") .. tostring(innerStart.x)) .. " ") .. tostring(innerStart.y),
"Z"
},
" "
)
end
local CORNER_ANGLE_HEADROOM = 0.82
local function pieFillet(self, geometry, circleRadius, filletCenterRadius, edgeAngle, cornerRadius, sign)
local ratio = math.min(1, cornerRadius / filletCenterRadius)
local angle = edgeAngle + sign * math.asin(ratio)
local d = math.sqrt(math.max(0, filletCenterRadius * filletCenterRadius - cornerRadius * cornerRadius))
return {
lineTangent = {
x = geometry.centerX + d * math.cos(edgeAngle),
y = geometry.centerY + d * math.sin(edgeAngle)
},
arcTangent = ____exports.pieArcPoint(nil, geometry, angle, circleRadius),
angle = angle
}
end
function ____exports.maxPieCornerRadius(self, outerRadius, innerRadius, sweep)
local halfSweep = math.min(
math.abs(sweep) / 2,
math.pi / 2
)
local angleFactor = math.sin(halfSweep * CORNER_ANGLE_HEADROOM)
local outerLimit = outerRadius * angleFactor / (1 + angleFactor)
local innerLimit = innerRadius > 0 and innerRadius * angleFactor or math.huge
local ringLimit = innerRadius > 0 and (outerRadius - innerRadius) / 2 or outerRadius / 2
return math.max(
0,
math.min(outerLimit, innerLimit, ringLimit)
)
end
function ____exports.maxApexCornerRadius(self, outerRadius, apexRadius, sweep)
local halfSweep = math.min(
math.abs(sweep) / 2,
math.pi / 2
)
local angleFactor = math.sin(halfSweep * CORNER_ANGLE_HEADROOM)
local outerLimit = outerRadius * angleFactor / (1 + angleFactor)
local depthLimit = (outerRadius * outerRadius - apexRadius * apexRadius) / (2 * outerRadius)
return math.max(
0,
math.min(outerLimit, depthLimit)
)
end
local function roundedApexSlicePath(self, geometry, outerAngles, cornerRadius, apex)
local ____geometry_0 = geometry
local outerRadius = ____geometry_0.outerRadius
local outerFilletCenterRadius = outerRadius - cornerRadius
local start = pieFillet(
nil,
geometry,
outerRadius,
outerFilletCenterRadius,
outerAngles.start,
cornerRadius,
1
)
local ____end = pieFillet(
nil,
geometry,
outerRadius,
outerFilletCenterRadius,
outerAngles["end"],
cornerRadius,
-1
)
return table.concat(
{
(("M " .. tostring(apex.x)) .. " ") .. tostring(apex.y),
(("L " .. tostring(start.lineTangent.x)) .. " ") .. tostring(start.lineTangent.y),
(((((("A " .. tostring(cornerRadius)) .. " ") .. tostring(cornerRadius)) .. " 0 0 1 ") .. tostring(start.arcTangent.x)) .. " ") .. tostring(start.arcTangent.y),
(((((((("A " .. tostring(outerRadius)) .. " ") .. tostring(outerRadius)) .. " 0 ") .. tostring(largeArcFlag(nil, start.angle, ____end.angle))) .. " 1 ") .. tostring(____end.arcTangent.x)) .. " ") .. tostring(____end.arcTangent.y),
(((((("A " .. tostring(cornerRadius)) .. " ") .. tostring(cornerRadius)) .. " 0 0 1 ") .. tostring(____end.lineTangent.x)) .. " ") .. tostring(____end.lineTangent.y),
"Z"
},
" "
)
end
local function roundedDonutSlicePath(self, geometry, innerRadius, outerAngles, innerAngles, cornerRadius)
local ____geometry_1 = geometry
local outerRadius = ____geometry_1.outerRadius
local outerFilletCenterRadius = outerRadius - cornerRadius
local outerStart = pieFillet(
nil,
geometry,
outerRadius,
outerFilletCenterRadius,
outerAngles.start,
cornerRadius,
1
)
local outerEnd = pieFillet(
nil,
geometry,
outerRadius,
outerFilletCenterRadius,
outerAngles["end"],
cornerRadius,
-1
)
local innerFilletCenterRadius = innerRadius + cornerRadius
local innerStart = pieFillet(
nil,
geometry,
innerRadius,
innerFilletCenterRadius,
innerAngles.start,
cornerRadius,
1
)
local innerEnd = pieFillet(
nil,
geometry,
innerRadius,
innerFilletCenterRadius,
innerAngles["end"],
cornerRadius,
-1
)
return table.concat(
{
(("M " .. tostring(outerStart.lineTangent.x)) .. " ") .. tostring(outerStart.lineTangent.y),
(((((("A " .. tostring(cornerRadius)) .. " ") .. tostring(cornerRadius)) .. " 0 0 1 ") .. tostring(outerStart.arcTangent.x)) .. " ") .. tostring(outerStart.arcTangent.y),
(((((((("A " .. tostring(outerRadius)) .. " ") .. tostring(outerRadius)) .. " 0 ") .. tostring(largeArcFlag(nil, outerStart.angle, outerEnd.angle))) .. " 1 ") .. tostring(outerEnd.arcTangent.x)) .. " ") .. tostring(outerEnd.arcTangent.y),
(((((("A " .. tostring(cornerRadius)) .. " ") .. tostring(cornerRadius)) .. " 0 0 1 ") .. tostring(outerEnd.lineTangent.x)) .. " ") .. tostring(outerEnd.lineTangent.y),
(("L " .. tostring(innerEnd.lineTangent.x)) .. " ") .. tostring(innerEnd.lineTangent.y),
(((((("A " .. tostring(cornerRadius)) .. " ") .. tostring(cornerRadius)) .. " 0 0 1 ") .. tostring(innerEnd.arcTangent.x)) .. " ") .. tostring(innerEnd.arcTangent.y),
(((((((("A " .. tostring(innerRadius)) .. " ") .. tostring(innerRadius)) .. " 0 ") .. tostring(largeArcFlag(nil, innerEnd.angle, innerStart.angle))) .. " 0 ") .. tostring(innerStart.arcTangent.x)) .. " ") .. tostring(innerStart.arcTangent.y),
(((((("A " .. tostring(cornerRadius)) .. " ") .. tostring(cornerRadius)) .. " 0 0 1 ") .. tostring(innerStart.lineTangent.x)) .. " ") .. tostring(innerStart.lineTangent.y),
"Z"
},
" "
)
end
function ____exports.pieUsesInnerArc(self, geometry, angles, gapPx)
local halfGap = math.max(0, gapPx) / 2
local apexRadius = ____exports.pieApexRadius(nil, halfGap, angles["end"] - angles.start, geometry.outerRadius)
return geometry.innerRadius > 0 and geometry.innerRadius >= apexRadius
end
function ____exports.createPieSlicePath(self, geometry, angles, cornerRadius, gapPx)
if cornerRadius == nil then
cornerRadius = 0
end
if gapPx == nil then
gapPx = 0
end
local halfGap = math.max(0, gapPx) / 2
local outerAngles = insetAngles(
nil,
angles,
____exports.gapInsetAngle(nil, halfGap, geometry.outerRadius)
)
if not ____exports.pieUsesInnerArc(nil, geometry, angles, gapPx) then
local apexRadius = ____exports.pieApexRadius(nil, halfGap, angles["end"] - angles.start, geometry.outerRadius)
local apex = ____exports.pieArcPoint(nil, geometry, (angles.start + angles["end"]) / 2, apexRadius)
return cornerRadius > 0 and roundedApexSlicePath(
nil,
geometry,
outerAngles,
cornerRadius,
apex
) or apexSlicePath(nil, geometry, outerAngles, apex)
end
local innerAngles = insetAngles(
nil,
angles,
____exports.gapInsetAngle(nil, halfGap, geometry.innerRadius)
)
return cornerRadius > 0 and roundedDonutSlicePath(
nil,
geometry,
geometry.innerRadius,
outerAngles,
innerAngles,
cornerRadius
) or donutSlicePath(
nil,
geometry,
geometry.innerRadius,
outerAngles,
innerAngles
)
end
return ____exports
end,
["core.renderScene.charts.primitives.segments"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____barShape = require("core.renderScene.charts.primitives.barShape")
local roundedBarPath = ____barShape.roundedBarPath
function ____exports.segmentedBarPath(self, frame, orientation, count, gap, radius, fraction, snap)
local horizontal = orientation == "horizontal"
local length = horizontal and frame.width or frame.height
local segment = math.max(1, (length - gap * (count - 1)) / count)
local filled = math.min(
count,
math.max(0, fraction * count)
)
local units = snap and math.floor(filled + 0.5) or filled
local parts = {}
do
local index = 0
while index < count do
do
local visible = math.min(
1,
math.max(0, units - index)
) * segment
if visible < 0.5 then
goto __continue4
end
local offset = index * (segment + gap)
parts[#parts + 1] = horizontal and roundedBarPath(
nil,
frame.x + offset,
frame.y,
visible,
frame.height,
radius
) or roundedBarPath(
nil,
frame.x,
frame.y + frame.height - offset - visible,
frame.width,
visible,
radius
)
end
::__continue4::
index = index + 1
end
end
return table.concat(parts, " ")
end
return ____exports
end,
["core.renderScene.charts.primitives.shadow"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
function ____exports.resolveChartShadow(self, shadow)
if not (shadow and shadow.enabled) then
return nil
end
local angle = finite(nil, shadow.angle, 45) * math.pi / 180
local distance = finite(nil, shadow.distance, 5)
return {
color = shadow.color or "#000000",
opacity = finite(nil, shadow.opacity, 0.25),
blur = finite(nil, shadow.blur, 10),
dx = math.cos(angle) * distance,
dy = math.sin(angle) * distance
}
end
return ____exports
end,
["core.renderScene.charts.primitives.stacking"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local waterfallSegment, percentSegment, cumulativeSegment, mappedSegment
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____axis = require("core.renderScene.charts.primitives.axis")
local mapChartValue = ____axis.mapChartValue
function waterfallSegment(self, chart, categoryIndex, seriesIndex, plotHeight, value)
local running = 0
do
local index = 0
while index < categoryIndex do
running = running + (chart.series[seriesIndex + 1].values[index + 1] or 0)
index = index + 1
end
end
return mappedSegment(
nil,
value,
running,
running + value,
chart,
plotHeight
)
end
function percentSegment(self, chart, categoryIndex, seriesIndex, plotHeight, value)
local total = __lor(
nil,
__TS__ArrayReduce(
chart.series,
function(____, sum, series) return sum + math.abs(series.values[categoryIndex + 1] or 0) end,
0
),
function() return 1 end
)
local cumulative = 0
do
local index = 0
while index < seriesIndex do
cumulative = cumulative + math.abs(chart.series[index + 1].values[categoryIndex + 1] or 0)
index = index + 1
end
end
local magnitude = math.abs(value)
return {value = value, pixelStart = cumulative / total * plotHeight, pixelEnd = (cumulative + magnitude) / total * plotHeight}
end
function cumulativeSegment(self, chart, categoryIndex, seriesIndex, plotHeight, value)
local cumulative = 0
do
local index = 0
while index < seriesIndex do
cumulative = cumulative + (chart.series[index + 1].values[categoryIndex + 1] or 0)
index = index + 1
end
end
return mappedSegment(
nil,
value,
cumulative,
cumulative + value,
chart,
plotHeight
)
end
function mappedSegment(self, value, start, ____end, chart, plotHeight)
return {
value = value,
pixelStart = mapChartValue(nil, start, chart.axisY, plotHeight),
pixelEnd = mapChartValue(nil, ____end, chart.axisY, plotHeight)
}
end
function ____exports.stackedSegment(self, chart, mode, categoryIndex, seriesIndex, plotHeight)
local value = chart.series[seriesIndex + 1].values[categoryIndex + 1] or 0
if mode == "waterfall" then
return waterfallSegment(
nil,
chart,
categoryIndex,
seriesIndex,
plotHeight,
value
)
end
if mode == "percent" then
return percentSegment(
nil,
chart,
categoryIndex,
seriesIndex,
plotHeight,
value
)
end
return cumulativeSegment(
nil,
chart,
categoryIndex,
seriesIndex,
plotHeight,
value
)
end
return ____exports
end,
["core.renderScene.charts.primitives.text"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
function ____exports.chartText(self, options)
local ____options_0 = options
local chart = ____options_0.chart
local frame = ____options_0.frame
local ____options_id_6 = options.id
local ____options_order_7 = options.order
local ____options_bounds_8 = options.bounds
local ____frame_9 = frame
local ____temp_10 = {options.text}
local ____temp_1
if options.role == "axis" then
____temp_1 = chart.axisFontFamily
else
____temp_1 = nil
end
local ____temp_11 = ____temp_1 or chart.fontFamily or DEFAULT_FONT
local ____finite_3 = finite
local ____temp_2
if options.role == "axis" then
____temp_2 = chart.axisFontSize or chart.fontSize
else
____temp_2 = chart.fontSize
end
local ____math_max_result_12 = math.max(
9,
____finite_3(nil, ____temp_2, 12)
)
local ____temp_5
if options.role == "axis" then
____temp_5 = chart.axisLabelColor
else
local ____temp_4
if options.role == "legend" then
____temp_4 = chart.legendColor
else
____temp_4 = nil
end
____temp_5 = ____temp_4
end
return __TS__ObjectAssign(
{type = "text", id = ____options_id_6, order = ____options_order_7, bounds = ____options_bounds_8},
____frame_9,
{
lines = ____temp_10,
fontFamily = ____temp_11,
fontSize = ____math_max_result_12,
fontWeight = "normal",
color = ____temp_5 or chart.textColor or "#0f172a",
align = options.align or "left",
verticalAlign = "top",
lineHeight = 1.2,
rotation = options.rotation,
rotationCenter = __t(nil, options.rotation) and ({x = frame.x, y = frame.y}) or nil
}
)
end
return ____exports
end,
["core.renderScene.charts.primitives.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____axis = require("core.renderScene.charts.primitives.axis")
____exports.axisBands = ____axis.axisBands
____exports.chartTicks = ____axis.chartTicks
____exports.mapChartValue = ____axis.mapChartValue
____exports.zoneColorAtValue = ____axis.zoneColorAtValue
end
do
local ____barCategories = require("core.renderScene.charts.primitives.barCategories")
____exports.barCategoryCount = ____barCategories.barCategoryCount
end
do
local ____barLabel = require("core.renderScene.charts.primitives.barLabel")
____exports.BAR_LABEL = ____barLabel.BAR_LABEL
____exports.barLabelSize = ____barLabel.barLabelSize
____exports.formatBarLabel = ____barLabel.formatBarLabel
____exports.pillPath = ____barLabel.pillPath
end
do
local ____barShape = require("core.renderScene.charts.primitives.barShape")
____exports.barPath = ____barShape.barPath
____exports.barShapePath = ____barShape.barShapePath
____exports.roundedBarPath = ____barShape.roundedBarPath
end
do
local ____boxplot = require("core.renderScene.charts.primitives.boxplot")
____exports.computeBoxplotStats = ____boxplot.computeBoxplotStats
end
do
local ____colors = require("core.renderScene.charts.primitives.colors")
____exports.contrastTextColor = ____colors.contrastTextColor
____exports.isLightColor = ____colors.isLightColor
____exports.representativeColor = ____colors.representativeColor
____exports.sameHueContrastColor = ____colors.sameHueContrastColor
____exports.sameHueTint = ____colors.sameHueTint
end
do
local ____defaults = require("core.renderScene.charts.primitives.defaults")
____exports.CHART_COLORS = ____defaults.CHART_COLORS
____exports.DEFAULT_HEATMAP_ZONES = ____defaults.DEFAULT_HEATMAP_ZONES
____exports.DEFAULT_HEX_RADIUS = ____defaults.DEFAULT_HEX_RADIUS
____exports.DEFAULT_ZONE_FILL = ____defaults.DEFAULT_ZONE_FILL
end
do
local ____errors = require("core.renderScene.charts.primitives.errors")
____exports.createVerticalErrorWhiskerNode = ____errors.createVerticalErrorWhiskerNode
____exports.errorBarRange = ____errors.errorBarRange
end
do
local ____format = require("core.renderScene.charts.primitives.format")
____exports.formatFieldValue = ____format.formatFieldValue
end
do
local ____horizontalBars = require("core.renderScene.charts.primitives.horizontalBars")
____exports.CATEGORY_LABEL_ROW = ____horizontalBars.CATEGORY_LABEL_ROW
____exports.horizontalRows = ____horizontalBars.horizontalRows
____exports.isHorizontalBar = ____horizontalBars.isHorizontalBar
____exports.rowTop = ____horizontalBars.rowTop
end
do
local ____labelTilt = require("core.renderScene.charts.primitives.labelTilt")
____exports.labelAboveFrame = ____labelTilt.labelAboveFrame
____exports.labelBelowFrame = ____labelTilt.labelBelowFrame
____exports.labelTilt = ____labelTilt.labelTilt
____exports.tiltedLabelRoom = ____labelTilt.tiltedLabelRoom
end
do
local ____linePath = require("core.renderScene.charts.primitives.linePath")
____exports.linePathData = ____linePath.linePathData
end
do
local ____pieShape = require("core.renderScene.charts.primitives.pieShape")
____exports.clipSegmentToRect = ____pieShape.clipSegmentToRect
____exports.createPieSlicePath = ____pieShape.createPieSlicePath
____exports.gapInsetAngle = ____pieShape.gapInsetAngle
____exports.maxApexCornerRadius = ____pieShape.maxApexCornerRadius
____exports.maxPieCornerRadius = ____pieShape.maxPieCornerRadius
____exports.pieApexRadius = ____pieShape.pieApexRadius
____exports.pieArcPoint = ____pieShape.pieArcPoint
____exports.pieUsesInnerArc = ____pieShape.pieUsesInnerArc
end
do
local ____segments = require("core.renderScene.charts.primitives.segments")
____exports.segmentedBarPath = ____segments.segmentedBarPath
end
do
local ____shadow = require("core.renderScene.charts.primitives.shadow")
____exports.resolveChartShadow = ____shadow.resolveChartShadow
end
do
local ____stacking = require("core.renderScene.charts.primitives.stacking")
____exports.stackedSegment = ____stacking.stackedSegment
end
do
local ____text = require("core.renderScene.charts.primitives.text")
____exports.chartText = ____text.chartText
end
return ____exports
end,
["core.renderScene.charts.propPath"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__NumberIsInteger = ____lualib.__TS__NumberIsInteger
local ____exports = {}
local ______shims = require("core.__shims")
local __re = ______shims.__re
local __test = ______shims.__test
local IDENT = __re(nil, "^[A-Za-z_][A-Za-z0-9_]*$", "")
local function block(self, kind, id, property)
return __test(nil, IDENT, id) and (((kind .. "[") .. id) .. "].") .. property or nil
end
____exports.CHART_TITLE_PROP = "text"
function ____exports.axisLabelProp(self, axis)
return ("Axis[" .. axis) .. "].label"
end
function ____exports.categoryProp(self, index)
return __TS__NumberIsInteger(index) and index >= 0 and ("categories[" .. tostring(index)) .. "]" or nil
end
function ____exports.seriesLabelProp(self, id)
return block(nil, "Series", id, "label")
end
function ____exports.seriesColorProp(self, id)
return block(nil, "Series", id, "color")
end
function ____exports.seriesLabelOffsetXProp(self, id)
return block(nil, "Series", id, "labelOffsetX")
end
function ____exports.seriesLabelOffsetYProp(self, id)
return block(nil, "Series", id, "labelOffsetY")
end
function ____exports.seriesValueProp(self, id, index)
local ____temp_0
if __TS__NumberIsInteger(index) and index >= 0 then
____temp_0 = block(
nil,
"Series",
id,
("values[" .. tostring(index)) .. "]"
)
else
____temp_0 = nil
end
return ____temp_0
end
function ____exports.seriesValueColorProp(self, id, index)
local ____temp_1
if __TS__NumberIsInteger(index) and index >= 0 then
____temp_1 = block(
nil,
"Series",
id,
("colors[" .. tostring(index)) .. "]"
)
else
____temp_1 = nil
end
return ____temp_1
end
function ____exports.ruleTextProp(self, id)
return block(nil, "Rule", id, "text")
end
function ____exports.ruleAtProp(self, id)
return block(nil, "Rule", id, "at")
end
return ____exports
end,
["core.renderScene.charts.decorations.chartLayout"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.decorations.legend"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local usesStandardLegend, legendSeries, legendItemWidths, legendStartX, legendY, createStackedLegendItems, createRowLegendItems, createLegendItems, renderLegendItem, createLegendSwatch, createLegendLabel, CHARTS_WITH_OWN_LEGEND
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local chartText = ____primitives.chartText
local representativeColor = ____primitives.representativeColor
local ____propPath = require("core.renderScene.charts.propPath")
local seriesColorProp = ____propPath.seriesColorProp
local seriesLabelProp = ____propPath.seriesLabelProp
function usesStandardLegend(self, chart)
local ____temp_3 = chart.chartType == "custom"
if ____temp_3 then
local ____Boolean_2 = Boolean
local ____opt_0 = chart.config
____temp_3 = ____Boolean_2(nil, ____opt_0 and ____opt_0.connectPoints)
end
local isConnectedCustom = ____temp_3
return chart.showLegend ~= false and not CHARTS_WITH_OWN_LEGEND:has(chart.chartType) and not isConnectedCustom
end
function legendSeries(self, chart)
return chart.chartType == "field" and __TS__ArrayFilter(
chart.series,
function(____, item)
local ____opt_4 = item.values[1]
return (____opt_4 and #____opt_4) == 4
end
) or chart.series
end
function ____exports.isStackedLegendPosition(self, position)
return position == "bottomLeft" or position == "bottomRight"
end
function legendItemWidths(self, chart)
return __TS__ArrayMap(
legendSeries(nil, chart),
function(____, item) return math.max(
42,
#item.label * finite(nil, chart.fontSize, 12) * 0.58 + 22
) end
)
end
function legendStartX(self, chart, plot, totalWidth)
if chart.legendPosition == "bottom" then
return plot.x + (plot.width - totalWidth) / 2
end
return plot.x + plot.width - totalWidth
end
function legendY(self, chart, plot)
return (chart.legendPosition or "top") == "top" and chart.y + 16 or plot.y + plot.height + 16
end
function createStackedLegendItems(self, render)
local ____render_6 = render
local chart = ____render_6.chart
local plot = ____render_6.plot
local order = ____render_6.order
local series = legendSeries(nil, chart)
local widths = legendItemWidths(nil, chart)
local maxWidth = math.max(table.unpack(widths))
local x = chart.legendPosition == "bottomLeft" and plot.x - ____exports.LEGEND_COLUMN_GAP - maxWidth or plot.x + plot.width + ____exports.LEGEND_COLUMN_GAP
local lastY = plot.y + plot.height - 15
return __TS__ArrayMap(
series,
function(____, item, seriesIndex) return {
series = item,
seriesIndex = seriesIndex,
x = x,
y = lastY - (#series - 1 - seriesIndex) * ____exports.LEGEND_ROW_HEIGHT,
width = widths[seriesIndex + 1],
order = order + (#series - 1 - seriesIndex) * 2
} end
)
end
function createRowLegendItems(self, render)
local ____render_7 = render
local chart = ____render_7.chart
local plot = ____render_7.plot
local order = ____render_7.order
local series = legendSeries(nil, chart)
local widths = legendItemWidths(nil, chart)
local totalWidth = __TS__ArrayReduce(
widths,
function(____, sum, width) return sum + width end,
0
)
local y = legendY(nil, chart, plot)
local x = legendStartX(nil, chart, plot, totalWidth)
return __TS__ArrayMap(
series,
function(____, item, seriesIndex)
local width = widths[seriesIndex + 1]
local itemX = x
x = x + width
return {
series = item,
seriesIndex = seriesIndex,
x = itemX,
y = y,
width = width,
order = order + (#series - 1 - seriesIndex) * 2
}
end
)
end
function createLegendItems(self, render)
return ____exports.isStackedLegendPosition(nil, render.chart.legendPosition) and createStackedLegendItems(nil, render) or createRowLegendItems(nil, render)
end
function renderLegendItem(self, render, item)
return {
createLegendSwatch(nil, render, item),
createLegendLabel(nil, render, item)
}
end
function createLegendSwatch(self, render, item)
local ____render_8 = render
local chart = ____render_8.chart
local bounds = ____render_8.bounds
local diagnostics = ____render_8.diagnostics
local fallback = CHART_COLORS[item.seriesIndex % #CHART_COLORS + 1]
local solidOnly = chart.chartType == "line"
local color = solidOnly and representativeColor(nil, item.series.color, fallback) or (item.series.color or fallback)
return {
type = "rect",
id = (("chart-legend-swatch-" .. chart.id) .. "-") .. item.series.id,
order = item.order,
bounds = bounds,
x = item.x,
y = item.y,
width = 10,
height = 10,
rx = 3,
prop = seriesColorProp(nil, item.series.id),
propKind = "color",
propSolidOnly = solidOnly,
style = {fill = paint(nil, color, diagnostics, chart.id)}
}
end
function createLegendLabel(self, render, item)
local ____render_9 = render
local chart = ____render_9.chart
local bounds = ____render_9.bounds
return __TS__ObjectAssign(
{},
chartText(nil, {
role = "legend",
id = (("chart-legend-" .. chart.id) .. "-") .. item.series.id,
order = item.order + 1,
bounds = bounds,
frame = {x = item.x + 15, y = item.y - 3, width = item.width - 15, height = 18},
text = item.series.label,
chart = chart
}),
{prop = seriesLabelProp(nil, item.series.id)}
)
end
CHARTS_WITH_OWN_LEGEND = __TS__New(Set, {
"heatmap",
"boxplot",
"sankey",
"treemap",
"mekko"
})
function ____exports.buildLegend(self, render)
if not usesStandardLegend(nil, render.chart) then
return {}
end
return __TS__ArrayFlatMap(
createLegendItems(nil, render),
function(____, item) return renderLegendItem(nil, render, item) end
)
end
____exports.LEGEND_ROW_HEIGHT = 22
____exports.LEGEND_COLUMN_GAP = 16
function ____exports.stackedLegendColumnWidth(self, chart)
local widths = legendItemWidths(nil, chart)
return __t(nil, #widths) and math.max(table.unpack(widths)) or 0
end
return ____exports
end,
["core.renderScene.charts.decorations.layout"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local boxBounds = ____scene.boxBounds
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local isHorizontalBar = ____primitives.isHorizontalBar
local labelTilt = ____primitives.labelTilt
local tiltedLabelRoom = ____primitives.tiltedLabelRoom
local ____legend = require("core.renderScene.charts.decorations.legend")
local isStackedLegendPosition = ____legend.isStackedLegendPosition
local LEGEND_COLUMN_GAP = ____legend.LEGEND_COLUMN_GAP
local LEGEND_ROW_HEIGHT = ____legend.LEGEND_ROW_HEIGHT
local stackedLegendColumnWidth = ____legend.stackedLegendColumnWidth
____exports.CARTESIAN_VALUE_TYPES = __TS__New(Set, {
"bar",
"line",
"scatter",
"boxplot",
"hexbin",
"custom",
"field"
})
local CHARTS_WITHOUT_CARTESIAN_DECORATIONS = __TS__New(Set, {
"heatmap",
"sankey",
"treemap",
"mekko",
"pie",
"radialBar",
"polarArea"
})
function ____exports.hasCartesianDecorations(self, chart)
return not CHARTS_WITHOUT_CARTESIAN_DECORATIONS:has(chart.chartType)
end
function ____exports.tickOffset(self, chart)
return ____exports.hasCartesianDecorations(nil, chart) and math.max(
0,
finite(nil, chart.tickLength, 0)
) or 0
end
function ____exports.xLabelOffset(self, chart)
return ____exports.tickOffset(nil, chart) + (____exports.hasCartesianDecorations(nil, chart) and math.max(
0,
finite(nil, chart.xLabelGap, 0)
) or 0)
end
function ____exports.yLabelOffset(self, chart)
return ____exports.tickOffset(nil, chart) + (____exports.hasCartesianDecorations(nil, chart) and math.max(
0,
finite(nil, chart.yLabelGap, 0)
) or 0)
end
local function isHorizontalBoxplot(self, chart)
local ____temp_2 = chart.chartType == "boxplot"
if ____temp_2 then
local ____opt_0 = chart.config
____temp_2 = (____opt_0 and ____opt_0.orientation) == "horizontal"
end
return ____temp_2
end
local function boxplotCategoryLabelWidth(self, chart)
local fontSize = finite(nil, chart.fontSize, 12)
local longest = math.max(
0,
table.unpack(__TS__ArrayMap(
chart.series,
function(____, series) return #__lor(
nil,
series.label,
function() return series.id end
) end
))
)
return longest * fontSize * 0.58 + 16
end
local TREEMAP_SIDE_LEGEND_WIDTH = 66
local function treemapSideLegendSide(self, chart, showLegend)
if chart.chartType ~= "treemap" or not showLegend then
return nil
end
return chart.legendPosition == "left" and "left" or (chart.legendPosition == "right" and "right" or nil)
end
local function barCategoryLabelWidth(self, chart)
local fontSize = finite(nil, chart.axisFontSize or chart.fontSize, 12)
local ____opt_3 = chart.config
local categories = ____opt_3 and ____opt_3.categories or ({})
return math.max(
0,
table.unpack(__TS__ArrayMap(
categories,
function(____, category) return #category end
))
) * fontSize * 0.58 + 16
end
local function leftLabelWidth(self, chart)
if __t(nil, chart.axisLabelSpace) and chart.axisLabelSpace > 0 and (isHorizontalBoxplot(nil, chart) or isHorizontalBar(nil, chart)) then
return chart.axisLabelSpace
end
if isHorizontalBoxplot(nil, chart) then
return boxplotCategoryLabelWidth(nil, chart)
end
if isHorizontalBar(nil, chart) then
return (chart.categoryAlign == "left" or chart.categoryAlign == "inside") and 20 or barCategoryLabelWidth(nil, chart)
end
if chart.showValueAxis == false then
return 20
end
return __t(nil, chart.axisY.label) and 60 or 46
end
local function tiltedBottomRoom(self, chart)
local tilt = labelTilt(nil, chart)
if tilt <= 0 then
return 0
end
local ____temp_7
if chart.chartType == "bar" and not isHorizontalBar(nil, chart) then
local ____opt_5 = chart.config
____temp_7 = ____opt_5 and ____opt_5.categories or ({})
else
____temp_7 = chart.chartType == "boxplot" and not isHorizontalBoxplot(nil, chart) and __TS__ArrayMap(
chart.series,
function(____, series) return __lor(
nil,
series.label,
function() return series.id end
) end
) or ({})
end
local labels = ____temp_7
return #labels > 0 and math.max(
0,
tiltedLabelRoom(nil, chart, labels, tilt) - 18
) or 0
end
local function legendPlaceOf(self, chart)
local showLegend = chart.showLegend ~= false
local position = chart.legendPosition or "top"
local hasItems = showLegend and #chart.series > 0
local stacked = hasItems and isStackedLegendPosition(nil, position)
return {
showLegend = showLegend,
position = position,
atTop = position == "top",
hasItems = hasItems,
stacked = stacked,
sideColumnWidth = stacked and stackedLegendColumnWidth(nil, chart) + LEGEND_COLUMN_GAP or 0,
treemapSide = treemapSideLegendSide(nil, chart, showLegend)
}
end
local function padLeftOf(self, chart, showLabels, legend)
return ____exports.yLabelOffset(nil, chart) + (showLabels and leftLabelWidth(nil, chart) or 12) + (legend.position == "bottomLeft" and legend.sideColumnWidth or 0) + (legend.treemapSide == "left" and TREEMAP_SIDE_LEGEND_WIDTH or 0)
end
local function padRightOf(self, legend)
return 24 + (legend.position == "bottomRight" and legend.sideColumnWidth or 0) + (legend.treemapSide == "right" and TREEMAP_SIDE_LEGEND_WIDTH or 0)
end
local function padBottomOf(self, chart, showLabels, legend)
local ____temp_10 = chart.chartType == "bar"
if ____temp_10 then
local ____opt_8 = chart.config
____temp_10 = (____opt_8 and ____opt_8.showBarLabels) == true
end
local valueRow = ____temp_10 and chart.config.barLabelPosition == "axis"
local horizontalValueAxis = isHorizontalBar(nil, chart) and chart.showValueAxis ~= false
local base = showLabels and (isHorizontalBar(nil, chart) and (horizontalValueAxis and 34 or 12) or (__t(nil, chart.axisX.label) and 52 or 34) + (valueRow and 18 or 0)) or 12
local ____temp_16 = chart.chartType == "field" and legend.showLegend
if ____temp_16 then
local ____Boolean_15 = Boolean
local ____opt_13 = chart.config
local ____opt_11 = ____opt_13 and ____opt_13.scale
____temp_16 = ____Boolean_15(nil, ____opt_11 and #____opt_11.stops)
end
local hasColorBar = ____temp_16
local legendInRow = legend.hasItems and not legend.atTop and not legend.stacked
return ____exports.xLabelOffset(nil, chart) + base + (showLabels and tiltedBottomRoom(nil, chart) or 0) + (hasColorBar and 44 or 0) + (legendInRow and 16 + LEGEND_ROW_HEIGHT or 0)
end
local function padTopOf(self, chart, legend)
local titleHeight = __t(nil, chart.title) and math.max(
44,
20 + finite(nil, chart.titleSize, 14) * 1.6
) or 0
return __lor(
nil,
titleHeight,
function() return legend.atTop and legend.hasItems and 44 or 24 end
)
end
function ____exports.decorations(self, chart)
local showLabels = chart.showAxisLabels ~= false
local legend = legendPlaceOf(nil, chart)
local padLeft = padLeftOf(nil, chart, showLabels, legend)
local padRight = padRightOf(nil, legend)
local padBottom = padBottomOf(nil, chart, showLabels, legend)
local padTop = padTopOf(nil, chart, legend)
return {
bounds = boxBounds(
nil,
{x = chart.x, y = chart.y, width = chart.width, height = chart.height},
finite(nil, chart.strokeWidth, 1) + 2
),
plot = {
x = chart.x + padLeft,
y = chart.y + padTop,
width = math.max(1, chart.width - padLeft - padRight),
height = math.max(1, chart.height - padTop - padBottom)
},
showLabels = showLabels,
showLegend = legend.showLegend,
padLeft = padLeft
}
end
return ____exports
end,
["core.renderScene.charts.decorations.axisLabels"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local ____propPath = require("core.renderScene.charts.propPath")
local axisLabelProp = ____propPath.axisLabelProp
local function buildXAxisLabel(self, chart, layout, order)
if not __t(nil, chart.axisX.label) then
return nil
end
return __TS__ObjectAssign(
{},
chartText(nil, {
role = "axis",
id = "chart-x-label-" .. chart.id,
order = order,
bounds = layout.bounds,
frame = {x = layout.plot.x, y = chart.y + chart.height - 18, width = layout.plot.width, height = 18},
text = chart.axisX.label,
chart = chart,
align = "center"
}),
{prop = axisLabelProp(nil, "x")}
)
end
local function buildYAxisLabel(self, chart, layout, order)
if not __t(nil, chart.axisY.label) or chart.showValueAxis == false then
return nil
end
return __TS__ObjectAssign(
{},
chartText(nil, {
role = "axis",
id = "chart-y-label-" .. chart.id,
order = order,
bounds = layout.bounds,
frame = {x = chart.x + 12, y = layout.plot.y + layout.plot.height, width = layout.plot.height, height = 18},
text = chart.axisY.label,
chart = chart,
align = "center",
rotation = -90
}),
{prop = axisLabelProp(nil, "y")}
)
end
function ____exports.buildAxisLabels(self, chart, layout, order)
local labels = {}
local xLabel = buildXAxisLabel(nil, chart, layout, order)
if xLabel then
labels[#labels + 1] = xLabel
end
local yLabel = buildYAxisLabel(nil, chart, layout, order + #labels)
if yLabel then
labels[#labels + 1] = yLabel
end
return labels
end
return ____exports
end,
["core.renderScene.charts.decorations.boxplotYAxis"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local ____propPath = require("core.renderScene.charts.propPath")
local seriesLabelProp = ____propPath.seriesLabelProp
function ____exports.buildBoxplotSeriesYAxisTicks(self, chart, layout, order)
local count = math.max(1, #chart.series)
local slotWidth = layout.plot.height / count
return __TS__ArrayMap(
chart.series,
function(____, series, index)
local centerY = layout.plot.y + (index + 0.5) * slotWidth
return __TS__ObjectAssign(
{},
chartText(
nil,
{
role = "axis",
id = (("chart-y-tick-" .. chart.id) .. "-") .. tostring(index),
order = order + index,
bounds = layout.bounds,
frame = {x = chart.x, y = centerY - 9, width = layout.padLeft - 8, height = 18},
text = __lor(
nil,
series.label,
function() return series.id end
),
chart = chart,
align = "right"
}
),
{prop = seriesLabelProp(nil, series.id)}
)
end
)
end
return ____exports
end,
["core.renderScene.charts.decorations.categoricalXAxis"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local barCategoryCount = ____primitives.barCategoryCount
local chartText = ____primitives.chartText
local labelBelowFrame = ____primitives.labelBelowFrame
local labelTilt = ____primitives.labelTilt
local ____propPath = require("core.renderScene.charts.propPath")
local categoryProp = ____propPath.categoryProp
local seriesLabelProp = ____propPath.seriesLabelProp
local ____layout = require("core.renderScene.charts.decorations.layout")
local xLabelOffset = ____layout.xLabelOffset
local function categoryLabels(self, chart, count)
local ____t_4 = __t
local ____opt_2 = chart.config
local ____opt_0 = ____opt_2 and ____opt_2.categories
if ____t_4(nil, ____opt_0 and #____opt_0) then
return chart.config.categories
end
return __TS__ArrayFrom(
{length = count},
function(____, _value, index) return tostring(index + 1) end
)
end
function ____exports.buildCategoricalXAxisTicks(self, chart, layout, order)
local count = barCategoryCount(nil, chart)
local slotWidth = layout.plot.width / count
local labels = categoryLabels(nil, chart, count)
local ____Boolean_9 = Boolean
local ____opt_7 = chart.config
local ____opt_5 = ____opt_7 and ____opt_7.categories
local editable = ____Boolean_9(nil, ____opt_5 and #____opt_5)
local tilt = labelTilt(nil, chart)
local left = chart.categoryAlign == "left"
local ____left_13
if left then
local ____finite_12 = finite
local ____opt_10 = chart.config
____left_13 = math.min(
math.max(
0,
____finite_12(nil, ____opt_10 and ____opt_10.barGroupGap, 8)
),
math.max(0, slotWidth - 1)
)
else
____left_13 = 0
end
local groupGap = ____left_13
return __TS__ArrayFrom(
{length = count},
function(____, _value, index)
local centerX = layout.plot.x + (index + 0.5) * slotWidth
if tilt > 0 then
local text = labels[index + 1] or tostring(index + 1)
local ____labelBelowFrame_result_14 = labelBelowFrame(
nil,
chart,
text,
tilt,
{
x = centerX,
y = layout.plot.y + layout.plot.height + 4 + xLabelOffset(nil, chart)
}
)
local frame = ____labelBelowFrame_result_14.frame
local rotation = ____labelBelowFrame_result_14.rotation
local ____chartText_result_16 = chartText(
nil,
{
role = "axis",
id = (("chart-x-tick-" .. chart.id) .. "-") .. tostring(index),
order = order + index,
bounds = layout.bounds,
frame = frame,
text = text,
chart = chart,
align = "right",
rotation = rotation
}
)
local ____editable_15
if editable then
____editable_15 = categoryProp(nil, index)
else
____editable_15 = nil
end
return __TS__ObjectAssign({}, ____chartText_result_16, {prop = ____editable_15})
end
local ____chartText_result_18 = chartText(
nil,
{
role = "axis",
id = (("chart-x-tick-" .. chart.id) .. "-") .. tostring(index),
order = order + index,
bounds = layout.bounds,
frame = {
x = left and layout.plot.x + index * slotWidth + groupGap / 2 or centerX - slotWidth / 2,
y = layout.plot.y + layout.plot.height + 4 + xLabelOffset(nil, chart),
width = left and slotWidth - groupGap or slotWidth,
height = 18
},
text = labels[index + 1] or tostring(index + 1),
chart = chart,
align = left and "left" or "center"
}
)
local ____editable_17
if editable then
____editable_17 = categoryProp(nil, index)
else
____editable_17 = nil
end
return __TS__ObjectAssign({}, ____chartText_result_18, {prop = ____editable_17})
end
)
end
function ____exports.buildSeriesXAxisTicks(self, chart, layout, order)
local count = math.max(1, #chart.series)
local slotWidth = layout.plot.width / count
local tilt = labelTilt(nil, chart)
return __TS__ArrayMap(
chart.series,
function(____, series, index)
local centerX = layout.plot.x + (index + 0.5) * slotWidth
if tilt > 0 then
local text = __lor(
nil,
series.label,
function() return series.id end
)
local ____labelBelowFrame_result_19 = labelBelowFrame(
nil,
chart,
text,
tilt,
{
x = centerX,
y = layout.plot.y + layout.plot.height + 4 + xLabelOffset(nil, chart)
}
)
local frame = ____labelBelowFrame_result_19.frame
local rotation = ____labelBelowFrame_result_19.rotation
return __TS__ObjectAssign(
{},
chartText(
nil,
{
role = "axis",
id = (("chart-x-tick-" .. chart.id) .. "-") .. tostring(index),
order = order + index,
bounds = layout.bounds,
frame = frame,
text = text,
chart = chart,
align = "right",
rotation = rotation
}
),
{prop = seriesLabelProp(nil, series.id)}
)
end
return __TS__ObjectAssign(
{},
chartText(
nil,
{
role = "axis",
id = (("chart-x-tick-" .. chart.id) .. "-") .. tostring(index),
order = order + index,
bounds = layout.bounds,
frame = {
x = centerX - slotWidth / 2,
y = layout.plot.y + layout.plot.height + 4 + xLabelOffset(nil, chart),
width = slotWidth,
height = 18
},
text = __lor(
nil,
series.label,
function() return series.id end
),
chart = chart,
align = "center"
}
),
{prop = seriesLabelProp(nil, series.id)}
)
end
)
end
return ____exports
end,
["core.renderScene.charts.decorations.numericXAxis"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local chartTicks = ____primitives.chartTicks
local mapChartValue = ____primitives.mapChartValue
local ____layout = require("core.renderScene.charts.decorations.layout")
local xLabelOffset = ____layout.xLabelOffset
function ____exports.buildNumericXAxisTicks(self, chart, layout, order)
return __TS__ArrayMap(
chartTicks(nil, chart.axisX),
function(____, tick, index)
local x = layout.plot.x + mapChartValue(nil, tick, chart.axisX, layout.plot.width)
return chartText(
nil,
{
role = "axis",
id = (("chart-x-tick-" .. chart.id) .. "-") .. tostring(tick),
order = order + index,
bounds = layout.bounds,
frame = {
x = x - 20,
y = layout.plot.y + layout.plot.height + 10 + xLabelOffset(nil, chart),
width = 40,
height = 18
},
text = tostring(tick),
chart = chart,
align = "center"
}
)
end
)
end
return ____exports
end,
["core.renderScene.charts.decorations.numericYAxis"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local chartTicks = ____primitives.chartTicks
local mapChartValue = ____primitives.mapChartValue
local ____layout = require("core.renderScene.charts.decorations.layout")
local yLabelOffset = ____layout.yLabelOffset
function ____exports.buildNumericYAxisTicks(self, chart, layout, order)
return __TS__ArrayMap(
chartTicks(nil, chart.axisY),
function(____, tick, index)
local y = layout.plot.y + layout.plot.height - mapChartValue(nil, tick, chart.axisY, layout.plot.height)
return chartText(
nil,
{
role = "axis",
id = (("chart-y-tick-" .. chart.id) .. "-") .. tostring(tick),
order = order + index,
bounds = layout.bounds,
frame = {
x = chart.x,
y = y - 6,
width = layout.padLeft - 14 - yLabelOffset(nil, chart),
height = 18
},
text = tostring(tick),
chart = chart,
align = "right"
}
)
end
)
end
return ____exports
end,
["core.renderScene.charts.decorations.axes"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local barCategoryCount = ____primitives.barCategoryCount
local chartText = ____primitives.chartText
local chartTicks = ____primitives.chartTicks
local horizontalRows = ____primitives.horizontalRows
local isHorizontalBar = ____primitives.isHorizontalBar
local mapChartValue = ____primitives.mapChartValue
local rowTop = ____primitives.rowTop
local ____propPath = require("core.renderScene.charts.propPath")
local categoryProp = ____propPath.categoryProp
local ____axisLabels = require("core.renderScene.charts.decorations.axisLabels")
local buildAxisLabels = ____axisLabels.buildAxisLabels
local ____boxplotYAxis = require("core.renderScene.charts.decorations.boxplotYAxis")
local buildBoxplotSeriesYAxisTicks = ____boxplotYAxis.buildBoxplotSeriesYAxisTicks
local ____categoricalXAxis = require("core.renderScene.charts.decorations.categoricalXAxis")
local buildCategoricalXAxisTicks = ____categoricalXAxis.buildCategoricalXAxisTicks
local buildSeriesXAxisTicks = ____categoricalXAxis.buildSeriesXAxisTicks
local ____layout = require("core.renderScene.charts.decorations.layout")
local hasCartesianDecorations = ____layout.hasCartesianDecorations
local ____numericXAxis = require("core.renderScene.charts.decorations.numericXAxis")
local buildNumericXAxisTicks = ____numericXAxis.buildNumericXAxisTicks
local ____numericYAxis = require("core.renderScene.charts.decorations.numericYAxis")
local buildNumericYAxisTicks = ____numericYAxis.buildNumericYAxisTicks
local function isHorizontalBoxplot(self, chart)
local ____temp_2 = chart.chartType == "boxplot"
if ____temp_2 then
local ____opt_0 = chart.config
____temp_2 = (____opt_0 and ____opt_0.orientation) == "horizontal"
end
return ____temp_2
end
local function buildXAxisTicks(self, chart, layout, order)
if chart.chartType == "bar" then
return buildCategoricalXAxisTicks(nil, chart, layout, order)
end
if chart.chartType == "boxplot" and not isHorizontalBoxplot(nil, chart) then
return buildSeriesXAxisTicks(nil, chart, layout, order)
end
return buildNumericXAxisTicks(nil, chart, layout, order)
end
local function buildYAxisTicks(self, chart, layout, order)
if isHorizontalBoxplot(nil, chart) then
return buildBoxplotSeriesYAxisTicks(nil, chart, layout, order)
end
return chart.showValueAxis == false and ({}) or buildNumericYAxisTicks(nil, chart, layout, order)
end
local function xTickPositions(self, chart, layout)
local ____layout_3 = layout
local plot = ____layout_3.plot
if chart.chartType == "bar" then
local count = barCategoryCount(nil, chart)
return __TS__ArrayFrom(
{length = count},
function(____, _value, index) return plot.x + (index + 0.5) * plot.width / count end
)
end
return __TS__ArrayMap(
chartTicks(nil, chart.axisX),
function(____, tick) return plot.x + mapChartValue(nil, tick, chart.axisX, plot.width) end
)
end
local function axisLineDash(self, chart, width)
if chart.axisLineStyle == "dashed" then
return {dash = {width * 3, width * 2}}
end
return chart.axisLineStyle == "dotted" and ({dash = {0.1, width * 3}, lineCap = "round"}) or ({})
end
local function buildAxisLines(self, chart, layout, order)
local lineWidth = finite(nil, chart.axisLineWidth, 0)
local tickLength = finite(nil, chart.tickLength, 0)
if lineWidth <= 0 and tickLength <= 0 then
return {}
end
local ____layout_4 = layout
local plot = ____layout_4.plot
local bounds = ____layout_4.bounds
local bottom = plot.y + plot.height
local style = __TS__ObjectAssign(
{fill = {kind = "none"}, stroke = {kind = "solid", color = chart.axisLineColor or chart.gridColor or "#94a3b8"}, strokeWidth = lineWidth > 0 and lineWidth or 1, pointerEvents = "none"},
axisLineDash(nil, chart, lineWidth > 0 and lineWidth or 1)
)
local nodes = {}
local function add(____, id, d)
local ____temp_5 = #nodes + 1
nodes[____temp_5] = {
type = "path",
id = (("chart-axis-" .. id) .. "-") .. chart.id,
order = order + #nodes,
bounds = bounds,
d = d,
style = style
}
return ____temp_5
end
if lineWidth > 0 then
if chart.showValueAxis ~= false then
add(
nil,
"line-y",
(((((("M " .. tostring(plot.x)) .. " ") .. tostring(plot.y)) .. " L ") .. tostring(plot.x)) .. " ") .. tostring(bottom)
)
end
add(
nil,
"line-x",
(((((("M " .. tostring(plot.x)) .. " ") .. tostring(bottom)) .. " L ") .. tostring(plot.x + plot.width)) .. " ") .. tostring(bottom)
)
end
if tickLength > 0 and isHorizontalBar(nil, chart) then
__TS__ArrayForEach(
chartTicks(nil, chart.axisY),
function(____, tick)
local x = plot.x + mapChartValue(nil, tick, chart.axisY, plot.width)
add(
nil,
"tick-v-" .. tostring(tick),
(((((("M " .. tostring(x)) .. " ") .. tostring(bottom)) .. " L ") .. tostring(x)) .. " ") .. tostring(bottom + tickLength)
)
end
)
local rows = horizontalRows(nil, chart, plot)
do
local index = 0
while index < rows.count do
local y = rowTop(nil, rows, plot, index) + rows.labelRow + rows.barsHeight / 2
add(
nil,
"tick-c-" .. tostring(index),
(((((("M " .. tostring(plot.x - tickLength)) .. " ") .. tostring(y)) .. " L ") .. tostring(plot.x)) .. " ") .. tostring(y)
)
index = index + 1
end
end
end
if tickLength > 0 and not isHorizontalBoxplot(nil, chart) and not isHorizontalBar(nil, chart) then
__TS__ArrayForEach(
chartTicks(nil, chart.axisY),
function(____, tick)
local y = bottom - mapChartValue(nil, tick, chart.axisY, plot.height)
add(
nil,
"tick-y-" .. tostring(tick),
(((((("M " .. tostring(plot.x - tickLength)) .. " ") .. tostring(y)) .. " L ") .. tostring(plot.x)) .. " ") .. tostring(y)
)
end
)
__TS__ArrayForEach(
xTickPositions(nil, chart, layout),
function(____, x, index)
add(
nil,
"tick-x-" .. tostring(index),
(((((("M " .. tostring(x)) .. " ") .. tostring(bottom)) .. " L ") .. tostring(x)) .. " ") .. tostring(bottom + tickLength)
)
end
)
end
return nodes
end
local function categoryNames(self, chart, count)
local ____opt_6 = chart.config
local names = ____opt_6 and ____opt_6.categories
return __TS__ArrayFrom(
{length = count},
function(____, _value, index) return names and names[index + 1] or tostring(index + 1) end
)
end
local function buildHorizontalBarAxes(self, chart, layout, order)
local ____layout_10 = layout
local plot = ____layout_10.plot
local bounds = ____layout_10.bounds
local rows = horizontalRows(nil, chart, plot)
local above = chart.categoryAlign == "left"
local inside = chart.categoryAlign == "inside"
local ____Boolean_15 = Boolean
local ____opt_13 = chart.config
local ____opt_11 = ____opt_13 and ____opt_13.categories
local editable = ____Boolean_15(nil, ____opt_11 and #____opt_11)
local nodes = __TS__ArrayMap(
categoryNames(nil, chart, rows.count),
function(____, name, index)
local top = rowTop(nil, rows, plot, index)
local ____chartText_result_17 = chartText(
nil,
{
role = "axis",
id = (("chart-y-category-" .. chart.id) .. "-") .. tostring(index),
order = order + index,
bounds = bounds,
frame = above and ({x = plot.x, y = top, width = plot.width, height = rows.labelRow}) or (inside and ({x = plot.x + 14, y = top + rows.barsHeight / 2 - 9, width = plot.width - 28, height = 18}) or ({x = chart.x + 8, y = top + rows.barsHeight / 2 - 9, width = plot.x - chart.x - 16, height = 18})),
text = name,
chart = chart,
align = (above or inside) and "left" or "right"
}
)
local ____editable_16
if editable then
____editable_16 = categoryProp(nil, index)
else
____editable_16 = nil
end
return __TS__ObjectAssign({}, ____chartText_result_17, {prop = ____editable_16})
end
)
if chart.showValueAxis ~= false then
__TS__ArrayForEach(
chartTicks(nil, chart.axisY),
function(____, tick, index)
local x = plot.x + mapChartValue(nil, tick, chart.axisY, plot.width)
nodes[#nodes + 1] = chartText(
nil,
{
role = "axis",
id = (("chart-x-tick-" .. chart.id) .. "-") .. tostring(tick),
order = order + rows.count + index,
bounds = bounds,
frame = {
x = x - 20,
y = plot.y + plot.height + 4 + finite(nil, chart.tickLength, 0),
width = 40,
height = 18
},
text = tostring(tick),
chart = chart,
align = "center"
}
)
end
)
end
return nodes
end
function ____exports.buildChartAxes(self, chart, layout, order)
if not hasCartesianDecorations(nil, chart) then
return {}
end
local lines = buildAxisLines(nil, chart, layout, order)
if not layout.showLabels then
return lines
end
order = order + #lines
if isHorizontalBar(nil, chart) then
local ____array_18 = __TS__SparseArrayNew(table.unpack(lines))
__TS__SparseArrayPush(
____array_18,
table.unpack(buildHorizontalBarAxes(nil, chart, layout, order))
)
return {__TS__SparseArraySpread(____array_18)}
end
local xTicks = buildXAxisTicks(nil, chart, layout, order)
local yTicks = buildYAxisTicks(nil, chart, layout, order + #xTicks)
local labels = buildAxisLabels(nil, chart, layout, order + #xTicks + #yTicks)
local ____array_19 = __TS__SparseArrayNew(table.unpack(lines))
__TS__SparseArrayPush(
____array_19,
table.unpack(xTicks)
)
__TS__SparseArrayPush(
____array_19,
table.unpack(yTicks)
)
__TS__SparseArrayPush(
____array_19,
table.unpack(labels)
)
return {__TS__SparseArraySpread(____array_19)}
end
return ____exports
end,
["core.renderScene.charts.field.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.field.idw"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.idwInterpolate(self, samples, pointX, pointY, power)
local weightedSum = 0
local weightSum = 0
for ____, sample in ipairs(samples) do
local deltaX = sample.x - pointX
local deltaY = sample.y - pointY
local distanceSquared = deltaX * deltaX + deltaY * deltaY
if distanceSquared == 0 then
return sample.value
end
local weight = 1 / distanceSquared ^ (power / 2)
weightedSum = weightedSum + weight * sample.value
weightSum = weightSum + weight
end
return weightSum == 0 and 0 or weightedSum / weightSum
end
return ____exports
end,
["core.renderScene.charts.field.grid"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____idw = require("core.renderScene.charts.field.idw")
local idwInterpolate = ____idw.idwInterpolate
____exports.FIELD_GRID_MAX_CELLS = 32
function ____exports.fieldSurfaceClip(self, chart, plot)
return {
type = "rect",
x = plot.x,
y = plot.y,
width = plot.width,
height = plot.height,
rx = chart.cornerRadius or 12
}
end
function ____exports.computeFieldGrid(self, samples, width, height, power)
local aspect = width > 0 and height > 0 and width / height or 1
local cols = math.max(
2,
math.min(
____exports.FIELD_GRID_MAX_CELLS,
math.floor(math.sqrt(____exports.FIELD_GRID_MAX_CELLS * ____exports.FIELD_GRID_MAX_CELLS * aspect) + 0.5)
)
)
local rows = math.max(
2,
math.floor(cols / aspect + 0.5)
)
local grid = __TS__New(Float32Array, cols * rows)
do
local row = 0
while row < rows do
local pointY = height * (row / (rows - 1))
do
local column = 0
while column < cols do
local pointX = width * (column / (cols - 1))
grid[row * cols + column] = __t(nil, #samples) and idwInterpolate(
nil,
samples,
pointX,
pointY,
power
) or 0
column = column + 1
end
end
row = row + 1
end
end
return {grid = grid, cols = cols, rows = rows}
end
return ____exports
end,
["core.renderScene.charts.gridSupport"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local ____exports = {}
____exports.CIRCULAR_GRID_CHART_TYPES = __TS__New(Set, {"scatter", "custom", "hexbin"})
return ____exports
end,
["core.renderScene.charts.primitives.radarShape"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____freeformPath = require("core.renderScene.scene.freeformPath")
local freeformPathData = ____freeformPath.freeformPathData
local START_ANGLE = -math.pi / 2
local CURVED_TENSION = 0.5
local LABEL_FREE_MARGIN = 6
function ____exports.radarLabelSpace(self, fontSize)
return math.max(38, fontSize * 3.2)
end
function ____exports.radarRadius(self, plotWidth, plotHeight, fontSize, hasLabels)
if hasLabels == nil then
hasLabels = true
end
local margin = hasLabels and ____exports.radarLabelSpace(nil, fontSize) or LABEL_FREE_MARGIN
return math.max(
8,
math.min(plotWidth, plotHeight) / 2 - margin
)
end
function ____exports.radarCategoryCount(self, configuredCount, dataCount)
return math.max(
3,
__lor(
nil,
configuredCount,
function() return dataCount end
)
)
end
function ____exports.radarAngleAt(self, count, index)
return START_ANGLE + index * math.pi * 2 / count
end
function ____exports.angleForAxisValue(self, min, max, value)
local ratio = max == min and 0 or (value - min) / (max - min)
return START_ANGLE + ratio * math.pi * 2
end
function ____exports.radarPointAt(self, frame, index, pointRadius)
local angle = ____exports.radarAngleAt(nil, frame.count, index)
return {
x = frame.centerX + math.cos(angle) * pointRadius,
y = frame.centerY + math.sin(angle) * pointRadius
}
end
function ____exports.radarRadiusForValue(self, frame, value)
local range = frame.max - frame.min
local ratio = range == 0 and 0 or math.max(
0,
math.min(1, (value - frame.min) / range)
)
return ratio * frame.radius
end
function ____exports.radarVertexPoint(self, frame, index, value)
return ____exports.radarPointAt(
nil,
frame,
index,
____exports.radarRadiusForValue(nil, frame, value)
)
end
function ____exports.radarValueAtPoint(self, frame, index, px, py)
local angle = ____exports.radarAngleAt(nil, frame.count, index)
local projected = (px - frame.centerX) * math.cos(angle) + (py - frame.centerY) * math.sin(angle)
local ratio = frame.radius == 0 and 0 or math.max(
0,
math.min(1, projected / frame.radius)
)
return frame.min + ratio * (frame.max - frame.min)
end
function ____exports.radarSeriesPath(self, points, curved, tension)
if tension == nil then
tension = CURVED_TENSION
end
if #points == 0 then
return ""
end
if curved then
return freeformPathData(nil, {points = points, tension = tension, closed = true})
end
local commands = __TS__ArrayMap(
points,
function(____, point, index) return (((__t(nil, index) and "L " or "") .. tostring(point.x)) .. " ") .. tostring(point.y) end
)
return ("M " .. table.concat(commands, " ")) .. " Z"
end
return ____exports
end,
["core.renderScene.charts.decorations.gridDots"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.createGridDot(self, chart, id, order, bounds, x, y, width, clip)
local radius = math.max(1, width * 1.5)
local style = {fill = {kind = "solid", color = chart.gridColor or "#e2e8f0"}, clip = clip}
if chart.gridRoundedCorners == true then
return {
type = "ellipse",
id = id,
order = order,
bounds = bounds,
cx = x,
cy = y,
rx = radius,
ry = radius,
style = style
}
end
local size = radius * 2
return {
type = "rect",
id = id,
order = order,
bounds = bounds,
x = x - radius,
y = y - radius,
width = size,
height = size,
style = style
}
end
return ____exports
end,
["core.renderScene.charts.decorations.gridLineStyle"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
function ____exports.gridLineDashStyle(self, chart, width)
if chart.gridLineStyle ~= "dashed" then
return {}
end
local rounded = chart.gridRoundedCorners == true
return {dash = {width * 3, width * 2}, lineCap = rounded and "round" or "butt"}
end
return ____exports
end,
["core.renderScene.charts.decorations.gridCircle"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local buildDottedCircularGrid, ringRatio
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartTicks = ____primitives.chartTicks
local ____radarShape = require("core.renderScene.charts.primitives.radarShape")
local angleForAxisValue = ____radarShape.angleForAxisValue
local ____gridDots = require("core.renderScene.charts.decorations.gridDots")
local createGridDot = ____gridDots.createGridDot
local ____gridLineStyle = require("core.renderScene.charts.decorations.gridLineStyle")
local gridLineDashStyle = ____gridLineStyle.gridLineDashStyle
function buildDottedCircularGrid(self, chart, bounds, order, centerX, centerY, radius, width)
local yTicks = __TS__ArrayFilter(
chartTicks(nil, chart.axisY),
function(____, tick) return tick > chart.axisY.min end
)
local xTicks = chartTicks(nil, chart.axisX)
local nodes = {}
__TS__ArrayForEach(
yTicks,
function(____, yTick)
local ringRadius = radius * ringRatio(nil, chart, yTick)
__TS__ArrayForEach(
xTicks,
function(____, xTick)
local angle = angleForAxisValue(nil, chart.axisX.min, chart.axisX.max, xTick)
local x = centerX + math.cos(angle) * ringRadius
local y = centerY + math.sin(angle) * ringRadius
local id = (((("chart-grid-dot-" .. chart.id) .. "-") .. tostring(xTick)) .. "-") .. tostring(yTick)
nodes[#nodes + 1] = createGridDot(
nil,
chart,
id,
order + #nodes,
bounds,
x,
y,
width,
nil
)
end
)
end
)
return nodes
end
function ringRatio(self, chart, tick)
local range = chart.axisY.max - chart.axisY.min
return range == 0 and 0 or math.max(
0,
math.min(1, (tick - chart.axisY.min) / range)
)
end
function ____exports.buildCircularChartGrid(self, chart, plot, bounds, order)
local centerX = plot.x + plot.width / 2
local centerY = plot.y + plot.height / 2
local radius = math.max(
0,
math.min(plot.width, plot.height) / 2
)
local width = finite(nil, chart.gridWidth, 1)
if chart.gridLineStyle == "dotted" then
return buildDottedCircularGrid(
nil,
chart,
bounds,
order,
centerX,
centerY,
radius,
width
)
end
local style = __TS__ObjectAssign(
{fill = {kind = "none"}, stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"}, strokeWidth = width},
gridLineDashStyle(nil, chart, width)
)
local nodes = {}
__TS__ArrayForEach(
__TS__ArrayFilter(
chartTicks(nil, chart.axisY),
function(____, tick) return tick > chart.axisY.min end
),
function(____, tick)
local ringRadius = radius * ringRatio(nil, chart, tick)
nodes[#nodes + 1] = {
type = "ellipse",
id = (("chart-grid-ring-" .. chart.id) .. "-") .. tostring(tick),
order = order + #nodes,
bounds = bounds,
cx = centerX,
cy = centerY,
rx = ringRadius,
ry = ringRadius,
style = style
}
end
)
__TS__ArrayForEach(
chartTicks(nil, chart.axisX),
function(____, tick)
local angle = angleForAxisValue(nil, chart.axisX.min, chart.axisX.max, tick)
local edgeX = centerX + math.cos(angle) * radius
local edgeY = centerY + math.sin(angle) * radius
nodes[#nodes + 1] = {
type = "path",
id = (("chart-grid-spoke-" .. chart.id) .. "-") .. tostring(tick),
order = order + #nodes,
bounds = bounds,
d = (((((("M " .. tostring(centerX)) .. " ") .. tostring(centerY)) .. " L ") .. tostring(edgeX)) .. " ") .. tostring(edgeY),
style = style
}
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.decorations.grid"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local buildHorizontalBarGrid, buildDottedRectGrid
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____grid = require("core.renderScene.charts.field.grid")
local fieldSurfaceClip = ____grid.fieldSurfaceClip
local ____gridSupport = require("core.renderScene.charts.gridSupport")
local CIRCULAR_GRID_CHART_TYPES = ____gridSupport.CIRCULAR_GRID_CHART_TYPES
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartTicks = ____primitives.chartTicks
local isHorizontalBar = ____primitives.isHorizontalBar
local mapChartValue = ____primitives.mapChartValue
local ____gridCircle = require("core.renderScene.charts.decorations.gridCircle")
local buildCircularChartGrid = ____gridCircle.buildCircularChartGrid
local ____gridDots = require("core.renderScene.charts.decorations.gridDots")
local createGridDot = ____gridDots.createGridDot
local ____gridLineStyle = require("core.renderScene.charts.decorations.gridLineStyle")
local gridLineDashStyle = ____gridLineStyle.gridLineDashStyle
local ____layout = require("core.renderScene.charts.decorations.layout")
local hasCartesianDecorations = ____layout.hasCartesianDecorations
function buildHorizontalBarGrid(self, chart, plot, bounds, order, width)
if chart.gridAxes == "y" then
return {}
end
local style = __TS__ObjectAssign(
{fill = {kind = "none"}, stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"}, strokeWidth = width},
chart.gridLineStyle == "dotted" and ({dash = {0.1, width * 3}, lineCap = "round"}) or gridLineDashStyle(nil, chart, width)
)
return __TS__ArrayMap(
chartTicks(nil, chart.axisY),
function(____, tick, index)
local x = plot.x + mapChartValue(nil, tick, chart.axisY, plot.width)
return {
type = "path",
id = (("chart-grid-x-" .. chart.id) .. "-") .. tostring(tick),
order = order + index,
bounds = bounds,
d = (((((("M " .. tostring(x)) .. " ") .. tostring(plot.y)) .. " L ") .. tostring(x)) .. " ") .. tostring(plot.y + plot.height),
style = style
}
end
)
end
function buildDottedRectGrid(self, chart, plot, bounds, order, width, clip)
local xTicks = chartTicks(nil, chart.axisX)
local yTicks = chartTicks(nil, chart.axisY)
local nodes = {}
__TS__ArrayForEach(
xTicks,
function(____, xTick)
local x = plot.x + mapChartValue(nil, xTick, chart.axisX, plot.width)
__TS__ArrayForEach(
yTicks,
function(____, yTick)
local y = plot.y + plot.height - mapChartValue(nil, yTick, chart.axisY, plot.height)
local id = (((("chart-grid-dot-" .. chart.id) .. "-") .. tostring(xTick)) .. "-") .. tostring(yTick)
nodes[#nodes + 1] = createGridDot(
nil,
chart,
id,
order + #nodes,
bounds,
x,
y,
width,
clip
)
end
)
end
)
return nodes
end
function ____exports.buildChartGrid(self, chart, plot, bounds, order)
if chart.showGrid == false or not hasCartesianDecorations(nil, chart) then
return {}
end
if chart.gridShape == "circle" and CIRCULAR_GRID_CHART_TYPES:has(chart.chartType) then
return buildCircularChartGrid(
nil,
chart,
plot,
bounds,
order
)
end
local width = finite(nil, chart.gridWidth, 1)
if isHorizontalBar(nil, chart) then
return buildHorizontalBarGrid(
nil,
chart,
plot,
bounds,
order,
width
)
end
local ____temp_0
if chart.chartType == "field" then
____temp_0 = fieldSurfaceClip(nil, chart, plot)
else
____temp_0 = nil
end
local clip = ____temp_0
if chart.gridLineStyle == "dotted" then
return buildDottedRectGrid(
nil,
chart,
plot,
bounds,
order,
width,
clip
)
end
local style = __TS__ObjectAssign(
{fill = {kind = "none"}, stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"}, strokeWidth = width},
gridLineDashStyle(nil, chart, width),
{clip = clip}
)
local nodes = {}
__TS__ArrayForEach(
chart.gridAxes == "y" and ({}) or chartTicks(nil, chart.axisX),
function(____, tick)
local x = plot.x + mapChartValue(nil, tick, chart.axisX, plot.width)
nodes[#nodes + 1] = {
type = "path",
id = (("chart-grid-x-" .. chart.id) .. "-") .. tostring(tick),
order = order + #nodes,
bounds = bounds,
d = (((((("M " .. tostring(x)) .. " ") .. tostring(plot.y)) .. " L ") .. tostring(x)) .. " ") .. tostring(plot.y + plot.height),
style = style
}
end
)
__TS__ArrayForEach(
chart.gridAxes == "x" and ({}) or chartTicks(nil, chart.axisY),
function(____, tick)
local y = plot.y + plot.height - mapChartValue(nil, tick, chart.axisY, plot.height)
nodes[#nodes + 1] = {
type = "path",
id = (("chart-grid-y-" .. chart.id) .. "-") .. tostring(tick),
order = order + #nodes,
bounds = bounds,
d = (((((("M " .. tostring(plot.x)) .. " ") .. tostring(y)) .. " L ") .. tostring(plot.x + plot.width)) .. " ") .. tostring(y),
style = style
}
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.decorations.rules"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local createChartRuleMarks, renderChartRule, createChartRuleLine, createChartRuleLabel
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local mapChartValue = ____primitives.mapChartValue
local ____propPath = require("core.renderScene.charts.propPath")
local ruleAtProp = ____propPath.ruleAtProp
local ruleTextProp = ____propPath.ruleTextProp
function createChartRuleMarks(self, render)
local nextOrder = render.order
return __TS__ArrayMap(
render.chart.rules or ({}),
function(____, rule)
local ____nextOrder_3 = nextOrder
nextOrder = ____nextOrder_3 + 1
local lineOrder = ____nextOrder_3
local ____t_result_5
if __t(nil, rule.text) then
local ____nextOrder_4 = nextOrder
nextOrder = ____nextOrder_4 + 1
____t_result_5 = ____nextOrder_4
else
____t_result_5 = nil
end
local labelOrder = ____t_result_5
return {
rule = rule,
color = __lor(
nil,
__lor(
nil,
rule.color,
function() return render.chart.strokeColor end
),
function() return "#475569" end
),
y = render.plot.y + render.plot.height - mapChartValue(nil, rule.at, render.chart.axisY, render.plot.height),
lineOrder = lineOrder,
labelOrder = labelOrder
}
end
)
end
function renderChartRule(self, render, mark)
local nodes = {createChartRuleLine(nil, render, mark)}
if __t(nil, mark.rule.text) and mark.labelOrder ~= nil then
nodes[#nodes + 1] = createChartRuleLabel(nil, render, mark)
end
return nodes
end
function createChartRuleLine(self, render, mark)
return {
type = "path",
id = (("chart-rule-" .. render.chart.id) .. "-") .. mark.rule.id,
order = mark.lineOrder,
bounds = render.bounds,
d = (((((("M " .. tostring(render.plot.x)) .. " ") .. tostring(mark.y)) .. " L ") .. tostring(render.plot.x + render.plot.width)) .. " ") .. tostring(mark.y),
prop = ruleAtProp(nil, mark.rule.id),
propKind = "value",
style = {fill = {kind = "none"}, stroke = {kind = "solid", color = mark.color}, strokeWidth = mark.rule.strokeWidth or 1, dash = mark.rule.dash}
}
end
function createChartRuleLabel(self, render, mark)
local fontSize = math.max(
9,
finite(nil, render.chart.fontSize, 12) - 2
)
return __TS__ObjectAssign(
{},
chartText(nil, {
id = (("chart-rule-label-" .. render.chart.id) .. "-") .. mark.rule.id,
order = mark.labelOrder or mark.lineOrder + 1,
bounds = render.bounds,
frame = {x = render.plot.x + 4, y = mark.y - fontSize - 2, width = 160, height = fontSize + 2},
text = mark.rule.text or "",
chart = render.chart
}),
{
color = mark.color,
prop = ruleTextProp(nil, mark.rule.id)
}
)
end
function ____exports.buildChartRules(self, render)
local ____t_2 = __t
local ____opt_0 = render.chart.rules
if not ____t_2(nil, ____opt_0 and #____opt_0) then
return {}
end
return __TS__ArrayFlatMap(
createChartRuleMarks(nil, render),
function(____, mark) return renderChartRule(nil, render, mark) end
)
end
return ____exports
end,
["core.renderScene.charts.decorations.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____export = require("core.renderScene.charts.decorations.axes")
for ____exportKey, ____exportValue in pairs(____export) do
if ____exportKey ~= "default" then
____exports[____exportKey] = ____exportValue
end
end
end
do
local ____export = require("core.renderScene.charts.decorations.grid")
for ____exportKey, ____exportValue in pairs(____export) do
if ____exportKey ~= "default" then
____exports[____exportKey] = ____exportValue
end
end
end
do
local ____export = require("core.renderScene.charts.decorations.layout")
for ____exportKey, ____exportValue in pairs(____export) do
if ____exportKey ~= "default" then
____exports[____exportKey] = ____exportValue
end
end
end
do
local ____export = require("core.renderScene.charts.decorations.legend")
for ____exportKey, ____exportValue in pairs(____export) do
if ____exportKey ~= "default" then
____exports[____exportKey] = ____exportValue
end
end
end
do
local ____export = require("core.renderScene.charts.decorations.rules")
for ____exportKey, ____exportValue in pairs(____export) do
if ____exportKey ~= "default" then
____exports[____exportKey] = ____exportValue
end
end
end
return ____exports
end,
["core.renderScene.charts.chartFrame"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____decorations = require("core.renderScene.charts.decorations.index")
local CARTESIAN_VALUE_TYPES = ____decorations.CARTESIAN_VALUE_TYPES
local ____primitives = require("core.renderScene.charts.primitives.index")
local isHorizontalBar = ____primitives.isHorizontalBar
local ____pieShape = require("core.renderScene.charts.primitives.pieShape")
local resolvePieRadii = ____pieShape.resolvePieRadii
local ____radarShape = require("core.renderScene.charts.primitives.radarShape")
local radarCategoryCount = ____radarShape.radarCategoryCount
local radarRadius = ____radarShape.radarRadius
local function scaleDetail(self, chart, plot)
local horizontal = isHorizontalBar(nil, chart)
local range = horizontal and (tostring(plot.x) .. ",") .. tostring(plot.width) or (tostring(plot.y) .. ",") .. tostring(plot.height)
return {
of = "chartScale",
valueScale = ((((range .. ",") .. tostring(chart.axisY.min)) .. ",") .. tostring(chart.axisY.max)) .. (horizontal and ",horizontal" or "")
}
end
local function pieDetail(self, chart, plot)
local ____resolvePieRadii_5 = resolvePieRadii
local ____array_4 = __TS__SparseArrayNew(nil, plot.width, plot.height)
local ____opt_0 = chart.config
__TS__SparseArrayPush(____array_4, ____opt_0 and ____opt_0.innerRadius)
local ____opt_2 = chart.config
__TS__SparseArrayPush(____array_4, ____opt_2 and ____opt_2.pieCornerRadius)
local ____resolvePieRadii_5_result_6 = ____resolvePieRadii_5(__TS__SparseArraySpread(____array_4))
local outerRadius = ____resolvePieRadii_5_result_6.outerRadius
local innerRadius = ____resolvePieRadii_5_result_6.innerRadius
local cornerRadius = ____resolvePieRadii_5_result_6.cornerRadius
return {
of = "pieGeometry",
pieGeometry = (((((((tostring(plot.x + plot.width / 2) .. ",") .. tostring(plot.y + plot.height / 2)) .. ",") .. tostring(outerRadius)) .. ",") .. tostring(innerRadius)) .. ",") .. tostring(cornerRadius)
}
end
local function polarAreaDetail(self, chart, plot)
local maxRadius = math.max(
1,
math.min(plot.width, plot.height) / 2 - 4
)
local ____finite_9 = finite
local ____opt_7 = chart.config
local innerRadius = math.max(
0,
math.min(
____finite_9(nil, ____opt_7 and ____opt_7.innerRadius, 0),
maxRadius - 1
)
)
local ____finite_12 = finite
local ____opt_10 = chart.config
local cornerRadius = math.max(
0,
____finite_12(nil, ____opt_10 and ____opt_10.pieCornerRadius, 0)
)
return {
of = "pieGeometry",
pieGeometry = (((((((tostring(plot.x + plot.width / 2) .. ",") .. tostring(plot.y + plot.height / 2)) .. ",") .. tostring(maxRadius)) .. ",") .. tostring(innerRadius)) .. ",") .. tostring(cornerRadius)
}
end
local function radarDetail(self, chart, plot)
local ____opt_17 = chart.config
local ____opt_13 = ____opt_17 and ____opt_17.categories
if ____opt_13 ~= nil then
local ____opt_14 = chart.config
____opt_13 = __TS__ArrayFilter(____opt_14 and ____opt_14.categories, Boolean)
end
local configuredCount = #(____opt_13 or ({}))
local dataCount = math.max(
0,
table.unpack(__TS__ArrayMap(
chart.series,
function(____, series) return #series.values end
))
)
local count = radarCategoryCount(nil, configuredCount, dataCount)
local radius = radarRadius(
nil,
plot.width,
plot.height,
finite(nil, chart.fontSize, 12),
chart.showAxisLabels ~= false
)
local centerX = plot.x + plot.width / 2
local centerY = plot.y + plot.height / 2
local curved = chart.chartType == "radial" and 1 or 0
local ____opt_19 = chart.config
local tension = ____opt_19 and ____opt_19.radarTension
return {
of = "radarGeometry",
radarGeometry = ((((((((((((tostring(centerX) .. ",") .. tostring(centerY)) .. ",") .. tostring(radius)) .. ",") .. tostring(chart.axisY.min)) .. ",") .. tostring(chart.axisY.max)) .. ",") .. tostring(count)) .. ",") .. tostring(curved)) .. (tension == nil and "" or "," .. tostring(tension))
}
end
local function frameDetail(self, chart, plot)
if chart.chartType == "pie" then
return pieDetail(nil, chart, plot)
end
if chart.chartType == "polarArea" then
return polarAreaDetail(nil, chart, plot)
end
if chart.chartType == "radar" or chart.chartType == "radial" then
return radarDetail(nil, chart, plot)
end
return CARTESIAN_VALUE_TYPES:has(chart.chartType) and scaleDetail(nil, chart, plot) or nil
end
function ____exports.buildChartFrame(self, chart, bounds, plot, order)
local frame = {
type = "rect",
id = "chart-" .. chart.id,
order = order,
bounds = bounds,
x = chart.x,
y = chart.y,
width = chart.width,
height = chart.height,
rx = chart.cornerRadius or 12,
style = {
fill = paint(nil, chart.fillColor or "#ffffff", {}, chart.id),
stroke = {kind = "solid", color = chart.strokeColor or "#475569"},
strokeWidth = finite(nil, chart.strokeWidth, 1)
}
}
local detail = frameDetail(nil, chart, plot)
if detail then
frame.detail = detail
end
return frame
end
return ____exports
end,
["core.renderScene.charts.chartLegend"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____decorations = require("core.renderScene.charts.decorations.index")
local buildLegend = ____decorations.buildLegend
function ____exports.buildOrderedChartLegend(self, chart, layout, renderOrder, diagnostics)
local nodes = buildLegend(
nil,
{
chart = chart,
plot = layout.plot,
bounds = layout.bounds,
order = renderOrder:current(),
diagnostics = diagnostics
}
)
renderOrder:advance(#nodes)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.renderers.bar.glass"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____chartBackdrop = require("core.renderScene.charts.chartBackdrop")
local chartImageRect = ____chartBackdrop.chartImageRect
local ____grid = require("core.renderScene.charts.decorations.grid")
local buildChartGrid = ____grid.buildChartGrid
function ____exports.createGlassBackdropNodes(self, context, id, d)
local ____context_0 = context
local chart = ____context_0.chart
local bounds = ____context_0.bounds
local nextOrder = ____context_0.nextOrder
local ____finite_3 = finite
local ____opt_1 = chart.config
local blur = ____finite_3(nil, ____opt_1 and ____opt_1.barGlassBlur, 0)
if blur <= 0 or not chart.fillImage then
return {}
end
local rect = chartImageRect(nil, chart)
local ____temp_8 = (("chart-bar-glass-" .. chart.id) .. "-") .. id
local ____nextOrder_result_9 = nextOrder(nil)
local ____bounds_10 = bounds
local ____rect_x_11 = rect.x
local ____rect_y_12 = rect.y
local ____rect_width_13 = rect.width
local ____rect_height_14 = rect.height
local ____chart_fillImage_url_15 = chart.fillImage.url
local ____blur_7 = blur
local ____finite_6 = finite
local ____opt_4 = chart.config
local nodes = {{
type = "image",
id = ____temp_8,
order = ____nextOrder_result_9,
bounds = ____bounds_10,
x = ____rect_x_11,
y = ____rect_y_12,
width = ____rect_width_13,
height = ____rect_height_14,
href = ____chart_fillImage_url_15,
style = {
blur = ____blur_7,
saturate = ____finite_6(nil, ____opt_4 and ____opt_4.barGlassSaturation, 1),
clip = {type = "path", d = d},
pointerEvents = "none"
}
}}
if __t(nil, chart.fillImage.overlay) then
nodes[#nodes + 1] = {
type = "path",
id = (("chart-bar-glass-overlay-" .. chart.id) .. "-") .. id,
order = nextOrder(nil),
bounds = bounds,
d = d,
style = {fill = {kind = "solid", color = chart.fillImage.overlay}, pointerEvents = "none"}
}
end
local ____t_18 = __t
local ____opt_16 = chart.config
if ____t_18(nil, ____opt_16 and ____opt_16.barGlassTint) then
nodes[#nodes + 1] = {
type = "path",
id = (("chart-bar-glass-tint-" .. chart.id) .. "-") .. id,
order = nextOrder(nil),
bounds = bounds,
d = d,
style = {fill = {kind = "solid", color = chart.config.barGlassTint}, pointerEvents = "none"}
}
end
__TS__ArrayPushArray(
nodes,
__TS__ArrayMap(
buildChartGrid(
nil,
chart,
context.plot,
bounds,
0
),
function(____, node) return __TS__ObjectAssign(
{},
node,
{
id = (node.id .. "-glass-") .. id,
order = nextOrder(nil),
style = __TS__ObjectAssign({}, node.style ~= nil and node.style or ({}), {clip = {type = "path", d = d}, pointerEvents = "none"})
}
) end
)
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.bar.glow"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local representativeColor = ____primitives.representativeColor
function ____exports.createBarGlowNode(self, context, id, d, color, glow, bounds)
if bounds == nil then
bounds = context.bounds
end
local ____context_0 = context
local chart = ____context_0.chart
local diagnostics = ____context_0.diagnostics
local nextOrder = ____context_0.nextOrder
return {
type = "path",
id = id,
order = nextOrder(nil),
bounds = bounds,
d = d,
style = {
fill = paint(nil, color, diagnostics, chart.id),
shadow = {
color = representativeColor(nil, color, "#ffffff"),
opacity = 0.9,
blur = glow,
dx = 0,
dy = 0
},
pointerEvents = "none"
}
}
end
return ____exports
end,
["core.renderScene.charts.renderers.bar.labels"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local BAR_LABEL = ____primitives.BAR_LABEL
local barLabelSize = ____primitives.barLabelSize
local CATEGORY_LABEL_ROW = ____primitives.CATEGORY_LABEL_ROW
local chartText = ____primitives.chartText
local formatBarLabel = ____primitives.formatBarLabel
local pillPath = ____primitives.pillPath
function ____exports.barLabelsEnabled(self, context)
local ____opt_0 = context.chart.config
return (____opt_0 and ____opt_0.showBarLabels) == true
end
local function resolvePlacement(self, target, size)
local fits = target.frame.height >= size.height + BAR_LABEL.gap * 2
return target.placement ~= "outside" and not fits and "outside" or target.placement
end
local function labelTop(self, placement, frame, height)
if placement == "outside" then
return frame.y - height - BAR_LABEL.gap
end
return placement == "inside" and frame.y + BAR_LABEL.gap or frame.y + frame.height / 2 - height / 2
end
local function createPillNode(self, context, id, box, color)
local ____context_2 = context
local chart = ____context_2.chart
local bounds = ____context_2.bounds
local diagnostics = ____context_2.diagnostics
local nextOrder = ____context_2.nextOrder
local config = chart.config
return {
type = "path",
id = id .. "-pill",
order = nextOrder(nil),
bounds = bounds,
d = pillPath(
nil,
box.left,
box.top,
box.width,
box.height
),
style = {
fill = __t(nil, config and config.barLabelPillColor) and paint(nil, config.barLabelPillColor, diagnostics, chart.id) or ({kind = "none"}),
stroke = paint(nil, config and config.barLabelBorderColor or color, diagnostics, chart.id),
strokeWidth = finite(nil, config and config.barLabelBorderWidth, 1),
pointerEvents = "none"
}
}
end
local function createTextNode(self, context, id, box, text, placement, fontSize, color)
local ____context_9 = context
local chart = ____context_9.chart
local bounds = ____context_9.bounds
local nextOrder = ____context_9.nextOrder
local config = chart.config
return __TS__ObjectAssign(
{},
chartText(
nil,
{
id = id,
order = nextOrder(nil),
bounds = bounds,
frame = {x = box.left, y = box.top + box.padY, width = box.width, height = box.lineHeight},
text = text,
chart = chart,
align = "center"
}
),
{
mark = (("bar-label|" .. placement) .. "|") .. (config and config.barLabelFormat or ""),
color = color,
fontSize = fontSize,
fontFamily = config and config.barLabelFontFamily or chart.fontFamily or "Inter, sans-serif",
fontWeight = config and config.barLabelFontWeight or "normal"
}
)
end
local function createAxisValueNode(self, context, target, text, fontSize)
local ____context_16 = context
local chart = ____context_16.chart
local plot = ____context_16.plot
local bounds = ____context_16.bounds
local nextOrder = ____context_16.nextOrder
local config = chart.config
local top = plot.y + plot.height + 4 + 16 + math.max(0, chart.tickLength or 0)
return __TS__ObjectAssign(
{},
chartText(
nil,
{
id = target.id,
order = nextOrder(nil),
bounds = bounds,
frame = target.horizontal and (chart.categoryAlign == "inside" and ({x = plot.x, y = target.frame.y + target.frame.height / 2 - fontSize * 0.6, width = plot.width - 14, height = fontSize * 1.2}) or ({x = plot.x, y = target.frame.y - CATEGORY_LABEL_ROW, width = plot.width, height = fontSize * 1.2})) or ({x = target.frame.x, y = top, width = target.frame.width, height = fontSize * 1.2}),
text = text,
chart = chart,
align = target.horizontal and "right" or (chart.categoryAlign == "left" and "left" or "center")
}
),
{
mark = "bar-label|axis|" .. (config and config.barLabelFormat or ""),
color = config and config.barLabelColor or chart.textColor or "#0f172a",
fontSize = fontSize,
fontFamily = config and config.barLabelFontFamily or chart.fontFamily or "Inter, sans-serif",
fontWeight = config and config.barLabelFontWeight or "normal"
}
)
end
local function horizontalPlacement(self, target, size)
local requested = target.placement == "axis" and "outside" or target.placement
local fits = target.frame.width >= size.width + BAR_LABEL.gap * 2
return requested ~= "outside" and not fits and "outside" or requested
end
local function horizontalBox(self, target, size, placement)
local ____target_25 = target
local frame = ____target_25.frame
local left = placement == "outside" and frame.x + frame.width + BAR_LABEL.gap or (placement == "inside" and frame.x + frame.width - size.width - BAR_LABEL.gap or frame.x + frame.width / 2 - size.width / 2)
return __TS__ObjectAssign({}, size, {left = left, top = frame.y + frame.height / 2 - size.height / 2})
end
function ____exports.createBarLabelNodes(self, context, target)
local ____context_26 = context
local chart = ____context_26.chart
local config = chart.config
local fontSize = math.max(
8,
finite(
nil,
config and config.barLabelFontSize,
finite(nil, chart.fontSize, 12)
)
)
local text = formatBarLabel(nil, target.value, config and config.barLabelFormat)
if target.placement == "axis" then
return {createAxisValueNode(
nil,
context,
target,
text,
fontSize
)}
end
local pill = (config and config.barLabelPill) == true
local size = barLabelSize(nil, text, fontSize, pill)
local placement = target.horizontal and horizontalPlacement(nil, target, size) or resolvePlacement(nil, target, size)
local box = target.horizontal and horizontalBox(nil, target, size, placement) or __TS__ObjectAssign(
{},
size,
{
left = target.frame.x + target.frame.width / 2 - size.width / 2,
top = labelTop(nil, placement, target.frame, size.height)
}
)
local color = config and config.barLabelColor or chart.textColor or "#0f172a"
local nodes = {}
if pill then
nodes[#nodes + 1] = createPillNode(
nil,
context,
target.id,
box,
color
)
end
nodes[#nodes + 1] = createTextNode(
nil,
context,
target.id,
box,
text,
placement,
fontSize,
color
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.bar.track"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____barShape = require("core.renderScene.charts.primitives.barShape")
local roundedBarPath = ____barShape.roundedBarPath
local ____segments = require("core.renderScene.charts.primitives.segments")
local segmentedBarPath = ____segments.segmentedBarPath
function ____exports.barTrackEnabled(self, context)
local ____opt_4 = context.chart.config
return (____opt_4 and ____opt_4.barTrack) == true
end
local DEFAULT_HATCH = {angle = 45, spacing = 7, width = 1.5}
local MIN_HATCH_SPACING = 2
local function hatchPath(self, x, y, width, height, angle, spacing)
local radians = angle * math.pi / 180
local direction = {
x = math.cos(radians),
y = math.sin(radians)
}
local normal = {x = -direction.y, y = direction.x}
local center = {x = x + width / 2, y = y + height / 2}
local reach = __hypot(nil, width, height) / 2
local segments = {}
do
local offset = -reach
while offset <= reach do
local cx = center.x + normal.x * offset
local cy = center.y + normal.y * offset
segments[#segments + 1] = (((((("M " .. tostring(cx - direction.x * reach)) .. " ") .. tostring(cy - direction.y * reach)) .. " L ") .. tostring(cx + direction.x * reach)) .. " ") .. tostring(cy + direction.y * reach)
offset = offset + spacing
end
end
return table.concat(segments, " ")
end
function ____exports.barTrackClip(self, context, frame)
if not ____exports.barTrackEnabled(nil, context) then
return nil
end
local ____roundedBarPath_3 = roundedBarPath
local ____array_2 = __TS__SparseArrayNew(
nil,
frame.x,
frame.y,
frame.width,
frame.height
)
local ____opt_0 = context.chart.config
__TS__SparseArrayPush(____array_2, ____opt_0 and ____opt_0.barCornerRadius or 2)
return {
type = "path",
d = ____roundedBarPath_3(__TS__SparseArraySpread(____array_2))
}
end
function ____exports.createBarTrackNodes(self, context, id, frame, orientation)
if orientation == nil then
orientation = "vertical"
end
local ____context_6 = context
local chart = ____context_6.chart
local bounds = ____context_6.bounds
local diagnostics = ____context_6.diagnostics
local nextOrder = ____context_6.nextOrder
local config = chart.config
local radius = config and config.barCornerRadius or 2
local segments = finite(nil, config and config.barSegments, 0)
local d = segments > 0 and segmentedBarPath(
nil,
frame,
orientation,
segments,
finite(nil, config and config.barSegmentGap, 4),
radius,
1,
true
) or roundedBarPath(
nil,
frame.x,
frame.y,
frame.width,
frame.height,
radius
)
local nodes = {{
type = "path",
id = (("chart-bar-track-" .. chart.id) .. "-") .. id,
order = nextOrder(nil),
bounds = bounds,
d = d,
style = {
fill = paint(nil, config and config.barTrackColor or chart.gridColor or "#e2e8f0", diagnostics, chart.id),
pointerEvents = "none"
}
}}
if config and config.barTrackHatch then
nodes[#nodes + 1] = {
type = "path",
id = (("chart-bar-track-hatch-" .. chart.id) .. "-") .. id,
order = nextOrder(nil),
bounds = bounds,
d = hatchPath(
nil,
frame.x,
frame.y,
frame.width,
frame.height,
finite(nil, config.barTrackHatchAngle, DEFAULT_HATCH.angle),
math.max(
MIN_HATCH_SPACING,
finite(nil, config.barTrackHatchSpacing, DEFAULT_HATCH.spacing)
)
),
style = {
fill = {kind = "none"},
stroke = paint(nil, config.barTrackHatchColor or chart.gridColor or "#cbd5e1", diagnostics, chart.id),
strokeWidth = finite(nil, config.barTrackHatchWidth, DEFAULT_HATCH.width),
pointerEvents = "none",
clip = {type = "path", d = d}
}
}
end
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.bar.grouped"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local ____exports = {}
local isSeriesMax, createGroupedLabel, groupedShape, createGroupedGlow, createGroupedBarLayout, createSeriesBarMarks, renderGroupedBarMark, plotClipPath, createGroupedBarNodes, createGroupedBarError
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local barCategoryCount = ____primitives.barCategoryCount
local barPath = ____primitives.barPath
local CHART_COLORS = ____primitives.CHART_COLORS
local createVerticalErrorWhiskerNode = ____primitives.createVerticalErrorWhiskerNode
local errorBarRange = ____primitives.errorBarRange
local mapChartValue = ____primitives.mapChartValue
local resolveChartShadow = ____primitives.resolveChartShadow
local segmentedBarPath = ____primitives.segmentedBarPath
local ____propPath = require("core.renderScene.charts.propPath")
local seriesValueColorProp = ____propPath.seriesValueColorProp
local seriesValueProp = ____propPath.seriesValueProp
local ____glass = require("core.renderScene.charts.renderers.bar.glass")
local createGlassBackdropNodes = ____glass.createGlassBackdropNodes
local ____glow = require("core.renderScene.charts.renderers.bar.glow")
local createBarGlowNode = ____glow.createBarGlowNode
local ____labels = require("core.renderScene.charts.renderers.bar.labels")
local barLabelsEnabled = ____labels.barLabelsEnabled
local createBarLabelNodes = ____labels.createBarLabelNodes
local ____track = require("core.renderScene.charts.renderers.bar.track")
local barTrackClip = ____track.barTrackClip
local barTrackEnabled = ____track.barTrackEnabled
local createBarTrackNodes = ____track.createBarTrackNodes
function isSeriesMax(self, mark, marks)
local values = __TS__ArrayMap(
__TS__ArrayFilter(
marks,
function(____, entry) return entry.seriesId == mark.seriesId end
),
function(____, entry) return entry.value end
)
return mark.value >= math.max(table.unpack(values))
end
function createGroupedLabel(self, context, mark, marks)
local ____context_1 = context
local chart = ____context_1.chart
local ____opt_2 = chart.config
if ____opt_2 and ____opt_2.barLabelMaxOnly and not isSeriesMax(nil, mark, marks) then
return {}
end
local ____createBarLabelNodes_10 = createBarLabelNodes
local ____context_9 = context
local ____temp_6 = (((("chart-bar-label-" .. chart.id) .. "-") .. mark.seriesId) .. "-") .. tostring(mark.valueIndex)
local ____mark_value_7 = mark.value
local ____mark_frame_8 = mark.frame
local ____opt_4 = chart.config
return ____createBarLabelNodes_10(nil, ____context_9, {id = ____temp_6, value = ____mark_value_7, frame = ____mark_frame_8, placement = ____opt_4 and ____opt_4.barLabelPosition or "outside"})
end
function groupedShape(self, context, frame)
local ____context_11 = context
local chart = ____context_11.chart
local plot = ____context_11.plot
local config = chart.config
local radius = config and config.barCornerRadius or 2
local segments = finite(nil, config and config.barSegments, 0)
if segments > 0 then
return segmentedBarPath(
nil,
{x = frame.x, y = plot.y, width = frame.width, height = plot.height},
"vertical",
segments,
finite(nil, config and config.barSegmentGap, 4),
radius,
frame.height / plot.height,
(config and config.barSegmentSnap) ~= false
)
end
return barPath(
nil,
frame.x,
frame.y,
frame.width,
frame.height,
radius,
(config and config.barRoundedBottom) == true
)
end
function createGroupedGlow(self, context, mark)
local ____context_22 = context
local chart = ____context_22.chart
local ____finite_25 = finite
local ____opt_23 = chart.config
local glow = ____finite_25(nil, ____opt_23 and ____opt_23.barGlow, 0)
if glow <= 0 or mark.frame.height <= 0 then
return {}
end
local d = groupedShape(nil, context, mark.frame)
return {createBarGlowNode(
nil,
context,
(((("chart-bar-glow-" .. chart.id) .. "-") .. mark.seriesId) .. "-") .. tostring(mark.valueIndex),
d,
mark.color,
glow
)}
end
function createGroupedBarLayout(self, context)
local ____context_26 = context
local chart = ____context_26.chart
local plot = ____context_26.plot
local valueCount = barCategoryCount(nil, chart)
local slotWidth = plot.width / valueCount
local ____finite_29 = finite
local ____opt_27 = chart.config
local groupGap = math.min(
math.max(
0,
____finite_29(nil, ____opt_27 and ____opt_27.barGroupGap, 8)
),
math.max(0, slotWidth - 1)
)
local ____finite_32 = finite
local ____opt_30 = chart.config
local barGap = math.max(
0,
____finite_32(nil, ____opt_30 and ____opt_30.barGap, 2)
)
return {
slotWidth = slotWidth,
seriesWidth = math.max(
1,
(slotWidth - groupGap) / math.max(1, #chart.series)
),
groupGap = groupGap,
barGap = barGap
}
end
function createSeriesBarMarks(self, context, layout, series, seriesIndex)
local ____context_33 = context
local chart = ____context_33.chart
local plot = ____context_33.plot
local seriesColor = series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1]
return __TS__ArrayMap(
series.values,
function(____, value, valueIndex)
local numericValue = __TS__ArrayIsArray(value) and value[2] or value
local height = math.max(
0,
mapChartValue(nil, numericValue, chart.axisY, plot.height)
)
local ____series_id_40 = series.id
local ____valueIndex_41 = valueIndex
local ____opt_34 = series.error
local ____temp_42 = ____opt_34 and ____opt_34[valueIndex + 1]
local ____opt_36 = series.colors
local ____temp_43 = ____opt_36 and ____opt_36[valueIndex + 1] or seriesColor
local ____opt_38 = series.colors
return {
seriesId = ____series_id_40,
valueIndex = ____valueIndex_41,
value = numericValue,
error = ____temp_42,
color = ____temp_43,
hasColorOverride = (____opt_38 and ____opt_38[valueIndex + 1]) ~= nil,
frame = {
x = plot.x + valueIndex * layout.slotWidth + layout.groupGap / 2 + seriesIndex * layout.seriesWidth,
y = plot.y + plot.height - height,
width = math.max(1, layout.seriesWidth - layout.barGap),
height = height
}
}
end
)
end
function renderGroupedBarMark(self, context, mark)
local nodes = createGroupedBarNodes(nil, context, mark)
local errorNode = createGroupedBarError(nil, context, mark)
if errorNode then
nodes[#nodes + 1] = errorNode
end
return nodes
end
function plotClipPath(self, plot)
local ____plot_44 = plot
local x = ____plot_44.x
local y = ____plot_44.y
local width = ____plot_44.width
local height = ____plot_44.height
return ((((((((("M " .. tostring(x)) .. " ") .. tostring(y)) .. " H ") .. tostring(x + width)) .. " V ") .. tostring(y + height)) .. " H ") .. tostring(x)) .. " Z"
end
function createGroupedBarNodes(self, context, mark)
local ____context_45 = context
local chart = ____context_45.chart
local plot = ____context_45.plot
local bounds = ____context_45.bounds
local diagnostics = ____context_45.diagnostics
local nextOrder = ____context_45.nextOrder
local ____opt_46 = chart.config
local radius = ____opt_46 and ____opt_46.barCornerRadius or 2
local ____mark_frame_48 = mark.frame
local x = ____mark_frame_48.x
local width = ____mark_frame_48.width
local path = groupedShape(nil, context, mark.frame)
local fill = paint(nil, mark.color, diagnostics, chart.id)
local ____paint_52 = paint
local ____lor_51 = __lor
local ____opt_49 = chart.config
local stroke = ____paint_52(
nil,
____lor_51(
nil,
____opt_49 and ____opt_49.barBorderColor,
function() return "#000000" end
),
diagnostics,
chart.id
)
local ____finite_55 = finite
local ____opt_53 = chart.config
local strokeWidth = ____finite_55(nil, ____opt_53 and ____opt_53.barBorderWidth, 0)
local shadow = resolveChartShadow(nil, chart.shadowStyle)
local shadowCaster = shadow and ({
type = "path",
id = (((("chart-bar-shadow-" .. chart.id) .. "-") .. mark.seriesId) .. "-") .. tostring(mark.valueIndex),
order = nextOrder(nil),
bounds = bounds,
d = path,
style = {
fill = fill,
stroke = stroke,
strokeWidth = strokeWidth,
shadow = shadow,
clip = barTrackClip(nil, context, {x = x, y = plot.y, width = width, height = plot.height}) or ({
type = "path",
d = plotClipPath(nil, plot)
})
}
}) or nil
local bar = {
type = "path",
id = (((("chart-bar-" .. chart.id) .. "-") .. mark.seriesId) .. "-") .. tostring(mark.valueIndex),
order = nextOrder(nil),
bounds = bounds,
d = path,
detail = {
of = "chartValue",
series = mark.seriesId,
valueIndex = mark.valueIndex,
mark = "bar",
radius = radius,
colorProp = seriesValueColorProp(nil, mark.seriesId, mark.valueIndex),
hasColorOverride = mark.hasColorOverride
},
prop = seriesValueProp(nil, mark.seriesId, mark.valueIndex),
style = {fill = fill, stroke = stroke, strokeWidth = strokeWidth, innerShadow = shadow}
}
local glass = createGlassBackdropNodes(
nil,
context,
(mark.seriesId .. "-") .. tostring(mark.valueIndex),
path
)
local ____shadowCaster_58
if shadowCaster then
local ____array_56 = __TS__SparseArrayNew(
shadowCaster,
table.unpack(glass)
)
__TS__SparseArrayPush(____array_56, bar)
____shadowCaster_58 = {__TS__SparseArraySpread(____array_56)}
else
local ____array_57 = __TS__SparseArrayNew(table.unpack(glass))
__TS__SparseArrayPush(____array_57, bar)
____shadowCaster_58 = {__TS__SparseArraySpread(____array_57)}
end
return ____shadowCaster_58
end
function createGroupedBarError(self, context, mark)
if mark.error == nil then
return nil
end
local ____context_59 = context
local chart = ____context_59.chart
local plot = ____context_59.plot
local bounds = ____context_59.bounds
local nextOrder = ____context_59.nextOrder
local lower, upper = table.unpack(
errorBarRange(nil, mark.value, mark.error),
1,
2
)
return createVerticalErrorWhiskerNode(
nil,
{
id = (((("chart-bar-error-" .. chart.id) .. "-") .. mark.seriesId) .. "-") .. tostring(mark.valueIndex),
order = nextOrder(nil),
bounds = bounds,
geometry = {
centerX = mark.frame.x + mark.frame.width / 2,
startY = plot.y + plot.height - mapChartValue(nil, lower, chart.axisY, plot.height),
endY = plot.y + plot.height - mapChartValue(nil, upper, chart.axisY, plot.height)
},
color = chart.textColor or "#0f172a",
valueReference = {seriesId = mark.seriesId, valueIndex = mark.valueIndex}
}
)
end
function ____exports.renderGroupedBars(self, context)
local layout = createGroupedBarLayout(nil, context)
local marks = __TS__ArrayFlatMap(
context.chart.series,
function(____, series, seriesIndex) return createSeriesBarMarks(
nil,
context,
layout,
series,
seriesIndex
) end
)
local tracks = barTrackEnabled(nil, context) and __TS__ArrayFlatMap(
marks,
function(____, mark) return createBarTrackNodes(
nil,
context,
(mark.seriesId .. "-") .. tostring(mark.valueIndex),
{x = mark.frame.x, y = context.plot.y, width = mark.frame.width, height = context.plot.height}
) end
) or ({})
local bars = __TS__ArrayFlatMap(
marks,
function(____, mark) return renderGroupedBarMark(nil, context, mark) end
)
local labels = barLabelsEnabled(nil, context) and __TS__ArrayFlatMap(
marks,
function(____, mark) return createGroupedLabel(nil, context, mark, marks) end
) or ({})
local ____array_0 = __TS__SparseArrayNew(table.unpack(tracks))
__TS__SparseArrayPush(
____array_0,
table.unpack(bars)
)
__TS__SparseArrayPush(
____array_0,
table.unpack(__TS__ArrayFlatMap(
marks,
function(____, mark) return createGroupedGlow(nil, context, mark) end
))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(labels)
)
return {__TS__SparseArraySpread(____array_0)}
end
return ____exports
end,
["core.renderScene.charts.renderers.bar.horizontal"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local horizontalRows = ____primitives.horizontalRows
local mapChartValue = ____primitives.mapChartValue
local resolveChartShadow = ____primitives.resolveChartShadow
local roundedBarPath = ____primitives.roundedBarPath
local rowTop = ____primitives.rowTop
local segmentedBarPath = ____primitives.segmentedBarPath
local stackedSegment = ____primitives.stackedSegment
local ____propPath = require("core.renderScene.charts.propPath")
local seriesValueColorProp = ____propPath.seriesValueColorProp
local ____glass = require("core.renderScene.charts.renderers.bar.glass")
local createGlassBackdropNodes = ____glass.createGlassBackdropNodes
local ____glow = require("core.renderScene.charts.renderers.bar.glow")
local createBarGlowNode = ____glow.createBarGlowNode
local ____labels = require("core.renderScene.charts.renderers.bar.labels")
local barLabelsEnabled = ____labels.barLabelsEnabled
local createBarLabelNodes = ____labels.createBarLabelNodes
local ____track = require("core.renderScene.charts.renderers.bar.track")
local barTrackClip = ____track.barTrackClip
local barTrackEnabled = ____track.barTrackEnabled
local createBarTrackNodes = ____track.createBarTrackNodes
local function barFrame(self, context, rows, seriesIndex, valueIndex, value)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local top = rowTop(nil, rows, plot, valueIndex) + rows.labelRow
if __t(nil, context.stackedMode) then
local segment = stackedSegment(
nil,
chart,
context.stackedMode,
valueIndex,
seriesIndex,
plot.width
)
local start = math.min(segment.pixelStart, segment.pixelEnd)
return {
x = plot.x + start,
y = top,
width = math.max(
1,
math.abs(segment.pixelEnd - segment.pixelStart)
),
height = rows.barsHeight
}
end
local ____finite_3 = finite
local ____opt_1 = chart.config
local barGap = math.max(
0,
____finite_3(nil, ____opt_1 and ____opt_1.barGap, 2)
)
local seriesHeight = rows.barsHeight / math.max(1, #chart.series)
local width = math.max(
0,
mapChartValue(nil, value, chart.axisY, plot.width)
)
return {
x = plot.x,
y = top + seriesIndex * seriesHeight,
width = width,
height = math.max(1, seriesHeight - barGap)
}
end
local function barPath(self, context, frame)
local ____context_4 = context
local chart = ____context_4.chart
local plot = ____context_4.plot
local config = chart.config
local segments = __t(nil, context.stackedMode) and #chart.series > 1 and 0 or finite(nil, config and config.barSegments, 0)
if segments > 0 then
return segmentedBarPath(
nil,
{x = plot.x, y = frame.y, width = plot.width, height = frame.height},
"horizontal",
segments,
finite(nil, config and config.barSegmentGap, 4),
config and config.barCornerRadius or 2,
frame.width / plot.width,
(config and config.barSegmentSnap) ~= false
)
end
return roundedBarPath(
nil,
frame.x,
frame.y,
frame.width,
frame.height,
config and config.barCornerRadius or 2
)
end
local function markOf(self, context, rows, series, seriesIndex, valueIndex, value)
local ____context_15 = context
local plot = ____context_15.plot
local frame = barFrame(
nil,
context,
rows,
seriesIndex,
valueIndex,
value
)
local ____temp_18 = (series.id .. "-") .. tostring(valueIndex)
local ____series_19 = series
local ____seriesIndex_20 = seriesIndex
local ____valueIndex_21 = valueIndex
local ____value_22 = value
local ____frame_23 = frame
local ____temp_24 = {x = plot.x, y = frame.y, width = plot.width, height = frame.height}
local ____temp_25 = {
minX = frame.x,
maxX = frame.x + math.max(frame.width, 1),
minY = frame.y,
maxY = frame.y + frame.height
}
local ____barPath_result_26 = barPath(nil, context, frame)
local ____opt_16 = series.colors
return {
id = ____temp_18,
series = ____series_19,
seriesIndex = ____seriesIndex_20,
valueIndex = ____valueIndex_21,
value = ____value_22,
frame = ____frame_23,
trackFrame = ____temp_24,
bounds = ____temp_25,
path = ____barPath_result_26,
color = ____opt_16 and ____opt_16[valueIndex + 1] or series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1]
}
end
local function barNodes(self, context, mark)
local ____context_27 = context
local chart = ____context_27.chart
local diagnostics = ____context_27.diagnostics
local nextOrder = ____context_27.nextOrder
local config = chart.config
local stroke = paint(
nil,
__lor(
nil,
config and config.barBorderColor,
function() return "#000000" end
),
diagnostics,
chart.id
)
local strokeWidth = finite(nil, config and config.barBorderWidth, 0)
local shadow = resolveChartShadow(nil, chart.shadowStyle)
local fill = paint(nil, mark.color, diagnostics, chart.id)
local nodes = {table.unpack(createGlassBackdropNodes(nil, context, mark.id, mark.path))}
if shadow then
nodes[#nodes + 1] = {
type = "path",
id = (("chart-bar-shadow-" .. chart.id) .. "-") .. mark.id,
order = nextOrder(nil),
bounds = mark.bounds,
d = mark.path,
style = {
fill = fill,
stroke = stroke,
strokeWidth = strokeWidth,
shadow = shadow,
clip = barTrackClip(nil, context, mark.trackFrame)
}
}
end
local ____temp_40 = (("chart-bar-" .. chart.id) .. "-") .. mark.id
local ____nextOrder_result_41 = nextOrder(nil)
local ____mark_bounds_42 = mark.bounds
local ____mark_path_43 = mark.path
local ____mark_series_id_36 = mark.series.id
local ____mark_valueIndex_37 = mark.valueIndex
local ____temp_38 = config and config.barCornerRadius or 2
local ____seriesValueColorProp_result_39 = seriesValueColorProp(nil, mark.series.id, mark.valueIndex)
local ____opt_34 = mark.series.colors
nodes[#nodes + 1] = {
type = "path",
id = ____temp_40,
order = ____nextOrder_result_41,
bounds = ____mark_bounds_42,
d = ____mark_path_43,
detail = {
of = "chartValue",
series = ____mark_series_id_36,
valueIndex = ____mark_valueIndex_37,
mark = "bar",
radius = ____temp_38,
colorProp = ____seriesValueColorProp_result_39,
hasColorOverride = (____opt_34 and ____opt_34[mark.valueIndex + 1]) ~= nil
},
style = {fill = fill, stroke = stroke, strokeWidth = strokeWidth, innerShadow = shadow}
}
return nodes
end
local function labelNodes(self, context, mark, highest)
local ____context_44 = context
local chart = ____context_44.chart
local config = chart.config
local showLabel = barLabelsEnabled(nil, context) and (not (config and config.barLabelMaxOnly) or mark.value >= highest)
local lastSeries = mark.seriesIndex == #chart.series - 1
if not showLabel or __t(nil, context.stackedMode) and not lastSeries and (config and config.barLabelPosition) == "outside" then
return {}
end
return createBarLabelNodes(nil, context, {
id = (("chart-bar-label-" .. chart.id) .. "-") .. mark.id,
value = mark.value,
frame = mark.frame,
placement = config and config.barLabelPosition or "outside",
horizontal = true
})
end
local function pushBar(self, context, rows, layers, series, seriesIndex, valueIndex, value, highest)
local ____context_51 = context
local chart = ____context_51.chart
local mark = markOf(
nil,
context,
rows,
series,
seriesIndex,
valueIndex,
value
)
if barTrackEnabled(nil, context) and (not __t(nil, context.stackedMode) or seriesIndex == 0) then
__TS__ArrayPushArray(
layers.tracks,
createBarTrackNodes(
nil,
context,
mark.id,
mark.trackFrame,
"horizontal"
)
)
end
__TS__ArrayPushArray(
layers.bars,
barNodes(nil, context, mark)
)
local ____finite_54 = finite
local ____opt_52 = chart.config
local glow = ____finite_54(nil, ____opt_52 and ____opt_52.barGlow, 0)
if glow > 0 and mark.frame.width > 0 then
local ____layers_glows_55 = layers.glows
____layers_glows_55[#____layers_glows_55 + 1] = createBarGlowNode(
nil,
context,
(("chart-bar-glow-" .. chart.id) .. "-") .. mark.id,
mark.path,
mark.color,
glow,
mark.bounds
)
end
__TS__ArrayPushArray(
layers.labels,
labelNodes(nil, context, mark, highest)
)
end
function ____exports.renderHorizontalBars(self, context)
local rows = horizontalRows(nil, context.chart, context.plot)
local layers = {tracks = {}, bars = {}, glows = {}, labels = {}}
__TS__ArrayForEach(
context.chart.series,
function(____, series, seriesIndex)
local numeric = __TS__ArrayMap(
series.values,
function(____, value) return type(value) == "number" and value or value[2] end
)
local highest = math.max(table.unpack(numeric))
__TS__ArrayForEach(
numeric,
function(____, value, valueIndex)
pushBar(
nil,
context,
rows,
layers,
series,
seriesIndex,
valueIndex,
value,
highest
)
end
)
end
)
local ____array_56 = __TS__SparseArrayNew(table.unpack(layers.tracks))
__TS__SparseArrayPush(
____array_56,
table.unpack(layers.bars)
)
__TS__SparseArrayPush(
____array_56,
table.unpack(layers.glows)
)
__TS__SparseArrayPush(
____array_56,
table.unpack(layers.labels)
)
return {__TS__SparseArraySpread(____array_56)}
end
return ____exports
end,
["core.renderScene.charts.renderers.bar.stacked"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local isSeriesMax
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local barCategoryCount = ____primitives.barCategoryCount
local barPath = ____primitives.barPath
local CHART_COLORS = ____primitives.CHART_COLORS
local resolveChartShadow = ____primitives.resolveChartShadow
local segmentedBarPath = ____primitives.segmentedBarPath
local stackedSegment = ____primitives.stackedSegment
local ____propPath = require("core.renderScene.charts.propPath")
local seriesValueColorProp = ____propPath.seriesValueColorProp
local seriesValueProp = ____propPath.seriesValueProp
local ____glass = require("core.renderScene.charts.renderers.bar.glass")
local createGlassBackdropNodes = ____glass.createGlassBackdropNodes
local ____glow = require("core.renderScene.charts.renderers.bar.glow")
local createBarGlowNode = ____glow.createBarGlowNode
local ____labels = require("core.renderScene.charts.renderers.bar.labels")
local barLabelsEnabled = ____labels.barLabelsEnabled
local createBarLabelNodes = ____labels.createBarLabelNodes
local ____track = require("core.renderScene.charts.renderers.bar.track")
local barTrackClip = ____track.barTrackClip
local barTrackEnabled = ____track.barTrackEnabled
local createBarTrackNodes = ____track.createBarTrackNodes
function isSeriesMax(self, values, index)
local numeric = __TS__ArrayMap(
values,
function(____, value) return type(value) == "number" and value or value[2] end
)
return numeric[index + 1] >= math.max(table.unpack(numeric))
end
local function slotOf(self, context, mode)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local slotWidth = plot.width / barCategoryCount(nil, chart)
local ____finite_3 = finite
local ____opt_1 = chart.config
local groupGap = math.min(
math.max(
0,
____finite_3(nil, ____opt_1 and ____opt_1.barGroupGap, 8)
),
math.max(0, slotWidth - 1)
)
local ____slotWidth_7 = slotWidth
local ____groupGap_8 = groupGap
local ____math_max_result_9 = math.max(1, slotWidth - groupGap)
local ____opt_4 = chart.config
local ____temp_10 = ____opt_4 and ____opt_4.barCornerRadius or 2
local ____temp_6
if mode == "waterfall" then
____temp_6 = nil
else
____temp_6 = #chart.series - 1
end
return {
slotWidth = ____slotWidth_7,
groupGap = ____groupGap_8,
barWidth = ____math_max_result_9,
cornerRadius = ____temp_10,
outerSeriesIndex = ____temp_6
}
end
local function pathOf(self, context, x, y, height, slot, radius)
local ____context_11 = context
local chart = ____context_11.chart
local plot = ____context_11.plot
local ____temp_15
if #chart.series == 1 then
local ____finite_14 = finite
local ____opt_12 = chart.config
____temp_15 = ____finite_14(nil, ____opt_12 and ____opt_12.barSegments, 0)
else
____temp_15 = 0
end
local segments = ____temp_15
if segments > 0 then
local ____segmentedBarPath_22 = segmentedBarPath
local ____array_21 = __TS__SparseArrayNew(nil, {x = x, y = plot.y, width = slot.barWidth, height = plot.height}, "vertical", segments)
local ____finite_18 = finite
local ____opt_16 = chart.config
__TS__SparseArrayPush(
____array_21,
____finite_18(nil, ____opt_16 and ____opt_16.barSegmentGap, 4),
radius,
height / plot.height
)
local ____opt_19 = chart.config
__TS__SparseArrayPush(____array_21, (____opt_19 and ____opt_19.barSegmentSnap) ~= false)
return ____segmentedBarPath_22(__TS__SparseArraySpread(____array_21))
end
local ____barPath_26 = barPath
local ____array_25 = __TS__SparseArrayNew(
nil,
x,
y,
slot.barWidth,
height,
radius
)
local ____opt_23 = chart.config
__TS__SparseArrayPush(____array_25, (____opt_23 and ____opt_23.barRoundedBottom) == true)
return ____barPath_26(__TS__SparseArraySpread(____array_25))
end
local function pushLabel(self, context, layers, series, seriesIndex, valueIndex, slot, frame)
local ____context_27 = context
local chart = ____context_27.chart
local config = chart.config
local visible = barLabelsEnabled(nil, context) and not (config and config.barLabelMaxOnly and not isSeriesMax(nil, series.values, valueIndex)) and ((config and config.barLabelPosition) ~= "axis" or seriesIndex == slot.outerSeriesIndex)
if not visible then
return
end
local requested = config and config.barLabelPosition or "outside"
local value = series.values[valueIndex + 1]
__TS__ArrayPushArray(
layers.labels,
createBarLabelNodes(
nil,
context,
{
id = (((("chart-bar-label-" .. chart.id) .. "-") .. series.id) .. "-") .. tostring(valueIndex),
value = __TS__ArrayIsArray(value) and value[2] or (value or 0),
frame = frame,
placement = requested == "outside" and seriesIndex ~= slot.outerSeriesIndex and "center" or requested
}
)
)
end
local function markOf(self, context, mode, slot, series, seriesIndex, valueIndex)
local ____context_34 = context
local chart = ____context_34.chart
local plot = ____context_34.plot
local segment = stackedSegment(
nil,
chart,
mode,
valueIndex,
seriesIndex,
plot.height
)
local radius = (slot.outerSeriesIndex == nil or seriesIndex == slot.outerSeriesIndex) and slot.cornerRadius or 0
local x = plot.x + valueIndex * slot.slotWidth + slot.groupGap / 2
local y = plot.y + plot.height - math.max(segment.pixelStart, segment.pixelEnd)
local height = math.max(
1,
math.abs(segment.pixelEnd - segment.pixelStart)
)
local ____series_37 = series
local ____valueIndex_38 = valueIndex
local ____radius_39 = radius
local ____opt_35 = series.colors
return {
series = ____series_37,
valueIndex = ____valueIndex_38,
radius = ____radius_39,
color = ____opt_35 and ____opt_35[valueIndex + 1] or series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1],
x = x,
y = y,
height = height,
path = pathOf(
nil,
context,
x,
y,
height,
slot,
radius
),
column = {x = x, y = plot.y, width = slot.barWidth, height = plot.height}
}
end
local function segmentNodes(self, context, mark)
local ____context_40 = context
local chart = ____context_40.chart
local plot = ____context_40.plot
local bounds = ____context_40.bounds
local diagnostics = ____context_40.diagnostics
local nextOrder = ____context_40.nextOrder
local ____mark_41 = mark
local series = ____mark_41.series
local valueIndex = ____mark_41.valueIndex
local path = ____mark_41.path
local fill = paint(nil, mark.color, diagnostics, chart.id)
local ____paint_45 = paint
local ____lor_44 = __lor
local ____opt_42 = chart.config
local stroke = ____paint_45(
nil,
____lor_44(
nil,
____opt_42 and ____opt_42.barBorderColor,
function() return "#000000" end
),
diagnostics,
chart.id
)
local ____finite_48 = finite
local ____opt_46 = chart.config
local strokeWidth = ____finite_48(nil, ____opt_46 and ____opt_46.barBorderWidth, 0)
local shadow = resolveChartShadow(nil, chart.shadowStyle)
local nodes = {}
if shadow then
local plotClip = ((((((((("M " .. tostring(plot.x)) .. " ") .. tostring(plot.y)) .. " H ") .. tostring(plot.x + plot.width)) .. " V ") .. tostring(plot.y + plot.height)) .. " H ") .. tostring(plot.x)) .. " Z"
nodes[#nodes + 1] = {
type = "path",
id = (((("chart-bar-shadow-" .. chart.id) .. "-") .. series.id) .. "-") .. tostring(valueIndex),
order = nextOrder(nil),
bounds = bounds,
d = path,
style = {
fill = fill,
stroke = stroke,
strokeWidth = strokeWidth,
shadow = shadow,
clip = barTrackClip(nil, context, mark.column) or ({type = "path", d = plotClip})
}
}
end
__TS__ArrayPushArray(
nodes,
createGlassBackdropNodes(
nil,
context,
(series.id .. "-") .. tostring(valueIndex),
path
)
)
local ____temp_55 = (((("chart-bar-" .. chart.id) .. "-") .. series.id) .. "-") .. tostring(valueIndex)
local ____nextOrder_result_56 = nextOrder(nil)
local ____bounds_57 = bounds
local ____path_58 = path
local ____series_id_51 = series.id
local ____valueIndex_52 = valueIndex
local ____mark_radius_53 = mark.radius
local ____seriesValueColorProp_result_54 = seriesValueColorProp(nil, series.id, valueIndex)
local ____opt_49 = series.colors
nodes[#nodes + 1] = {
type = "path",
id = ____temp_55,
order = ____nextOrder_result_56,
bounds = ____bounds_57,
d = ____path_58,
detail = {
of = "chartValue",
series = ____series_id_51,
valueIndex = ____valueIndex_52,
mark = "bar",
radius = ____mark_radius_53,
colorProp = ____seriesValueColorProp_result_54,
hasColorOverride = (____opt_49 and ____opt_49[valueIndex + 1]) ~= nil
},
prop = seriesValueProp(nil, series.id, valueIndex),
style = {fill = fill, stroke = stroke, strokeWidth = strokeWidth, innerShadow = shadow}
}
return nodes
end
local function pushSegment(self, context, mode, layers, slot, series, seriesIndex, valueIndex)
local ____context_59 = context
local chart = ____context_59.chart
local mark = markOf(
nil,
context,
mode,
slot,
series,
seriesIndex,
valueIndex
)
if seriesIndex == 0 and barTrackEnabled(nil, context) then
__TS__ArrayPushArray(
layers.tracks,
createBarTrackNodes(
nil,
context,
tostring(valueIndex),
mark.column
)
)
end
__TS__ArrayPushArray(
layers.bars,
segmentNodes(nil, context, mark)
)
local frame = {x = mark.x, y = mark.y, width = slot.barWidth, height = mark.height}
pushLabel(
nil,
context,
layers,
series,
seriesIndex,
valueIndex,
slot,
frame
)
local ____finite_62 = finite
local ____opt_60 = chart.config
local glow = ____finite_62(nil, ____opt_60 and ____opt_60.barGlow, 0)
if glow > 0 then
local ____layers_glows_63 = layers.glows
____layers_glows_63[#____layers_glows_63 + 1] = createBarGlowNode(
nil,
context,
(((("chart-bar-glow-" .. chart.id) .. "-") .. series.id) .. "-") .. tostring(valueIndex),
mark.path,
mark.color,
glow
)
end
end
function ____exports.renderStackedBars(self, context, mode)
local ____context_64 = context
local chart = ____context_64.chart
local layers = {tracks = {}, bars = {}, glows = {}, labels = {}}
local slot = slotOf(nil, context, mode)
local valueCount = barCategoryCount(nil, chart)
do
local valueIndex = 0
while valueIndex < valueCount do
__TS__ArrayForEach(
chart.series,
function(____, series, seriesIndex)
pushSegment(
nil,
context,
mode,
layers,
slot,
series,
seriesIndex,
valueIndex
)
end
)
valueIndex = valueIndex + 1
end
end
local ____array_65 = __TS__SparseArrayNew(table.unpack(layers.tracks))
__TS__SparseArrayPush(
____array_65,
table.unpack(layers.bars)
)
__TS__SparseArrayPush(
____array_65,
table.unpack(layers.glows)
)
__TS__SparseArrayPush(
____array_65,
table.unpack(layers.labels)
)
return {__TS__SparseArraySpread(____array_65)}
end
return ____exports
end,
["core.renderScene.charts.renderers.bar"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____primitives = require("core.renderScene.charts.primitives.index")
local isHorizontalBar = ____primitives.isHorizontalBar
local ____grouped = require("core.renderScene.charts.renderers.bar.grouped")
local renderGroupedBars = ____grouped.renderGroupedBars
local ____horizontal = require("core.renderScene.charts.renderers.bar.horizontal")
local renderHorizontalBars = ____horizontal.renderHorizontalBars
local ____stacked = require("core.renderScene.charts.renderers.bar.stacked")
local renderStackedBars = ____stacked.renderStackedBars
function ____exports.renderBar(self, context)
if isHorizontalBar(nil, context.chart) then
return renderHorizontalBars(nil, context)
end
if __t(nil, context.stackedMode) then
return renderStackedBars(nil, context, context.stackedMode)
end
return renderGroupedBars(nil, context)
end
return ____exports
end,
["core.renderScene.charts.renderers.boxplot.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.renderers.boxplot.layout"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local representativeColor = ____primitives.representativeColor
function ____exports.createBoxplotLayout(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local ____opt_1 = chart.config
local orientation = ____opt_1 and ____opt_1.orientation or "vertical"
local boxCount = math.max(1, #chart.series)
local slotWidth = (orientation == "horizontal" and plot.height or plot.width) / boxCount
local ____representativeColor_5 = representativeColor
local ____opt_3 = chart.config
local borderColor = ____representativeColor_5(nil, ____opt_3 and ____opt_3.barBorderColor, "#000000")
local ____opt_6 = chart.config
local widthFraction = math.min(
1,
math.max(0.05, ____opt_6 and ____opt_6.boxWidth or 0.6)
)
local ____orientation_38 = orientation
local ____slotWidth_39 = slotWidth
local ____math_max_result_40 = math.max(4, slotWidth * widthFraction)
local ____opt_8 = chart.config
local ____temp_41 = ____opt_8 and ____opt_8.barCornerRadius or 2
local ____opt_10 = chart.config
local ____temp_12 = ____opt_10 and ____opt_10.showBoxplotPoints
if ____temp_12 == nil then
____temp_12 = true
end
local ____borderColor_42 = borderColor
local ____finite_15 = finite
local ____opt_13 = chart.config
local ____finite_15_result_43 = ____finite_15(nil, ____opt_13 and ____opt_13.barBorderWidth, 1)
local ____finite_18 = finite
local ____opt_16 = chart.config
local ____math_max_result_44 = math.max(
0,
____finite_18(nil, ____opt_16 and ____opt_16.boxWhiskerWidth, 1)
)
local ____finite_21 = finite
local ____opt_19 = chart.config
local ____math_max_result_45 = math.max(
0,
____finite_21(nil, ____opt_19 and ____opt_19.boxMedianWidth, 2)
)
local ____opt_22 = chart.config
local ____temp_46 = ____opt_22 and ____opt_22.boxMedianColor or borderColor
local ____opt_24 = chart.config
local ____temp_47 = ____opt_24 and ____opt_24.boxWhiskerColor
local ____finite_28 = finite
local ____opt_26 = chart.config
local ____math_max_result_48 = math.max(
0,
____finite_28(nil, ____opt_26 and ____opt_26.boxCapSize, 0.4)
)
local ____finite_31 = finite
local ____opt_29 = chart.config
local ____math_max_result_49 = math.max(
0,
____finite_31(nil, ____opt_29 and ____opt_29.boxPointSize, 3)
)
local ____finite_34 = finite
local ____opt_32 = chart.config
local ____math_min_result_50 = math.min(
1,
math.max(
0,
____finite_34(nil, ____opt_32 and ____opt_32.boxPointOpacity, 0.7)
)
)
local ____finite_37 = finite
local ____opt_35 = chart.config
return {
orientation = ____orientation_38,
slotWidth = ____slotWidth_39,
boxWidth = ____math_max_result_40,
cornerRadius = ____temp_41,
showPoints = ____temp_12,
borderColor = ____borderColor_42,
borderWidth = ____finite_15_result_43,
whiskerWidth = ____math_max_result_44,
medianWidth = ____math_max_result_45,
medianColor = ____temp_46,
whiskerColor = ____temp_47,
capSize = ____math_max_result_48,
pointSize = ____math_max_result_49,
pointOpacity = ____math_min_result_50,
jitter = math.max(
0,
____finite_37(nil, ____opt_35 and ____opt_35.boxJitter, 1)
)
}
end
return ____exports
end,
["core.renderScene.charts.renderers.boxplot.geometry"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____primitives = require("core.renderScene.charts.primitives.index")
local mapChartValue = ____primitives.mapChartValue
function ____exports.boxplotPoint(self, orientation, center, value)
return orientation == "horizontal" and ({x = value, y = center}) or ({x = center, y = value})
end
function ____exports.createBoxplotGeometry(self, context, layout, seriesIndex, stats)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local ____layout_1 = layout
local orientation = ____layout_1.orientation
local function valueAt(____, value)
return orientation == "horizontal" and plot.x + mapChartValue(nil, value, chart.axisX, plot.width) or plot.y + plot.height - mapChartValue(nil, value, chart.axisY, plot.height)
end
local center = plot[orientation == "horizontal" and "y" or "x"] + seriesIndex * layout.slotWidth + layout.slotWidth / 2
return {
center = center,
min = valueAt(nil, stats.min),
q1 = valueAt(nil, stats.q1),
median = valueAt(nil, stats.median),
q3 = valueAt(nil, stats.q3),
max = valueAt(nil, stats.max)
}
end
return ____exports
end,
["core.renderScene.charts.renderers.boxplot.points"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local jitter
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local mapChartValue = ____primitives.mapChartValue
local ____geometry = require("core.renderScene.charts.renderers.boxplot.geometry")
local boxplotPoint = ____geometry.boxplotPoint
function jitter(self, seed)
local hash = math.sin(seed * 12.9898) * 43758.5453
return hash - math.floor(hash) - 0.5
end
function ____exports.renderSamplePoints(self, context, layout, mark)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local bounds = ____context_0.bounds
local diagnostics = ____context_0.diagnostics
local nextOrder = ____context_0.nextOrder
local function valueAt(____, value)
return layout.orientation == "horizontal" and plot.x + mapChartValue(nil, value, chart.axisX, plot.width) or plot.y + plot.height - mapChartValue(nil, value, chart.axisY, plot.height)
end
if layout.pointSize <= 0 then
return {}
end
return __TS__ArrayMap(
mark.series.values,
function(____, value, pointIndex)
local center = mark.geometry.center + jitter(nil, mark.seriesIndex * 10000 + pointIndex) * layout.jitter * layout.boxWidth
local ____boxplotPoint_result_1 = boxplotPoint(
nil,
layout.orientation,
center,
valueAt(nil, value)
)
local x = ____boxplotPoint_result_1.x
local y = ____boxplotPoint_result_1.y
return {
type = "ellipse",
id = (("chart-box-point-" .. mark.id) .. "-") .. tostring(pointIndex),
order = nextOrder(nil),
bounds = bounds,
cx = x,
cy = y,
rx = layout.pointSize,
ry = layout.pointSize,
style = {
fill = paint(nil, mark.color, diagnostics, chart.id),
opacity = layout.pointOpacity
}
}
end
)
end
return ____exports
end,
["core.renderScene.charts.renderers.boxplot.shapes"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local whiskerColor, lowerWhisker, upperWhisker, lowerWhiskerCap, upperWhiskerCap, whiskerCap, medianLine, createBoxBorderLine, createBoxNode
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local representativeColor = ____primitives.representativeColor
local ____geometry = require("core.renderScene.charts.renderers.boxplot.geometry")
local boxplotPoint = ____geometry.boxplotPoint
function whiskerColor(self, layout, mark)
if layout.whiskerColor == "series" then
return representativeColor(nil, mark.color, layout.borderColor)
end
return layout.whiskerColor
end
function lowerWhisker(self, layout, mark)
local ____mark_geometry_2 = mark.geometry
local center = ____mark_geometry_2.center
local min = ____mark_geometry_2.min
local q1 = ____mark_geometry_2.q1
return {
id = "chart-box-whisker-lo-" .. mark.id,
from = boxplotPoint(nil, layout.orientation, center, min),
to = boxplotPoint(nil, layout.orientation, center, q1),
strokeWidth = layout.whiskerWidth
}
end
function upperWhisker(self, layout, mark)
local ____mark_geometry_3 = mark.geometry
local center = ____mark_geometry_3.center
local q3 = ____mark_geometry_3.q3
local max = ____mark_geometry_3.max
return {
id = "chart-box-whisker-hi-" .. mark.id,
from = boxplotPoint(nil, layout.orientation, center, q3),
to = boxplotPoint(nil, layout.orientation, center, max),
strokeWidth = layout.whiskerWidth
}
end
function lowerWhiskerCap(self, layout, mark)
return whiskerCap(
nil,
"chart-box-cap-lo-" .. mark.id,
layout,
mark.geometry.center,
mark.geometry.min
)
end
function upperWhiskerCap(self, layout, mark)
return whiskerCap(
nil,
"chart-box-cap-hi-" .. mark.id,
layout,
mark.geometry.center,
mark.geometry.max
)
end
function whiskerCap(self, id, layout, center, value)
local capHalf = layout.boxWidth * layout.capSize / 2
return {
id = id,
from = boxplotPoint(nil, layout.orientation, center - capHalf, value),
to = boxplotPoint(nil, layout.orientation, center + capHalf, value),
strokeWidth = layout.whiskerWidth
}
end
function medianLine(self, layout, mark)
local half = layout.boxWidth / 2
return {
id = "chart-box-median-" .. mark.id,
from = boxplotPoint(nil, layout.orientation, mark.geometry.center - half, mark.geometry.median),
to = boxplotPoint(nil, layout.orientation, mark.geometry.center + half, mark.geometry.median),
strokeWidth = layout.medianWidth,
color = layout.medianColor
}
end
function createBoxBorderLine(self, context, layout, line)
return {
type = "path",
id = line.id,
order = context:nextOrder(),
bounds = context.bounds,
d = (((((("M " .. tostring(line.from.x)) .. " ") .. tostring(line.from.y)) .. " L ") .. tostring(line.to.x)) .. " ") .. tostring(line.to.y),
style = {fill = {kind = "none"}, stroke = {kind = "solid", color = line.color or layout.borderColor}, strokeWidth = line.strokeWidth}
}
end
function createBoxNode(self, context, layout, mark)
local ____context_4 = context
local chart = ____context_4.chart
local bounds = ____context_4.bounds
local diagnostics = ____context_4.diagnostics
local nextOrder = ____context_4.nextOrder
local ____mark_5 = mark
local geometry = ____mark_5.geometry
local half = layout.boxWidth / 2
local a = boxplotPoint(nil, layout.orientation, geometry.center - half, geometry.q1)
local b = boxplotPoint(nil, layout.orientation, geometry.center + half, geometry.q3)
local x = math.min(a.x, b.x)
local y = math.min(a.y, b.y)
local width = math.max(
1,
math.abs(b.x - a.x)
)
local height = math.max(
1,
math.abs(b.y - a.y)
)
return {
type = "rect",
id = "chart-box-" .. mark.id,
order = nextOrder(nil),
bounds = bounds,
x = x,
y = y,
width = width,
height = height,
rx = layout.cornerRadius,
style = {
fill = paint(nil, mark.color, diagnostics, chart.id),
stroke = {kind = "solid", color = layout.borderColor},
strokeWidth = layout.borderWidth
}
}
end
function ____exports.renderBoxAndWhiskers(self, context, layout, mark)
local whiskers = layout.whiskerWidth > 0 and ({
lowerWhisker(nil, layout, mark),
upperWhisker(nil, layout, mark)
}) or ({})
local caps = layout.whiskerWidth > 0 and layout.capSize > 0 and ({
lowerWhiskerCap(nil, layout, mark),
upperWhiskerCap(nil, layout, mark)
}) or ({})
local median = layout.medianWidth > 0 and ({medianLine(nil, layout, mark)}) or ({})
local ____array_0 = __TS__SparseArrayNew(table.unpack(whiskers))
__TS__SparseArrayPush(
____array_0,
table.unpack(caps)
)
local ____array_1 = __TS__SparseArrayNew(table.unpack(__TS__ArrayMap(
{__TS__SparseArraySpread(____array_0)},
function(____, line) return createBoxBorderLine(
nil,
context,
layout,
__TS__ObjectAssign(
{},
line,
{color = whiskerColor(nil, layout, mark)}
)
) end
)))
__TS__SparseArrayPush(
____array_1,
createBoxNode(nil, context, layout, mark),
table.unpack(__TS__ArrayMap(
median,
function(____, line) return createBoxBorderLine(nil, context, layout, line) end
))
)
return {__TS__SparseArraySpread(____array_1)}
end
return ____exports
end,
["core.renderScene.charts.renderers.boxplot.series"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local computeBoxplotStats = ____primitives.computeBoxplotStats
local ____geometry = require("core.renderScene.charts.renderers.boxplot.geometry")
local createBoxplotGeometry = ____geometry.createBoxplotGeometry
local ____points = require("core.renderScene.charts.renderers.boxplot.points")
local renderSamplePoints = ____points.renderSamplePoints
local ____shapes = require("core.renderScene.charts.renderers.boxplot.shapes")
local renderBoxAndWhiskers = ____shapes.renderBoxAndWhiskers
function ____exports.renderBoxplotSeries(self, context, layout, series, seriesIndex)
local stats = computeBoxplotStats(nil, series.values)
if not stats then
return {}
end
local geometry = createBoxplotGeometry(
nil,
context,
layout,
seriesIndex,
stats
)
local color = series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1]
local mark = {
id = (context.chart.id .. "-") .. series.id,
series = series,
seriesIndex = seriesIndex,
color = color,
geometry = geometry
}
local nodes = renderBoxAndWhiskers(nil, context, layout, mark)
if layout.showPoints then
__TS__ArrayPushArray(
nodes,
renderSamplePoints(nil, context, layout, mark)
)
end
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.boxplot"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local ____layout = require("core.renderScene.charts.renderers.boxplot.layout")
local createBoxplotLayout = ____layout.createBoxplotLayout
local ____series = require("core.renderScene.charts.renderers.boxplot.series")
local renderBoxplotSeries = ____series.renderBoxplotSeries
function ____exports.renderBoxplot(self, context)
local layout = createBoxplotLayout(nil, context)
local nodes = {}
__TS__ArrayForEach(
context.chart.series,
function(____, series, seriesIndex)
__TS__ArrayPushArray(
nodes,
renderBoxplotSeries(
nil,
context,
layout,
series,
seriesIndex
)
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.custom"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local renderCustomSeries, isHorizontal, customSeriesValues, metricComponent, customPointPosition, customSeriesStyle, createCustomSymbolMark, createCustomPointMark, customMarkId, renderConnectedPairs, connectorDash, createConnectorLine, createConnectorLabel, HOLLOW_POINT_STROKE, CONNECTOR_LABEL_GAP, CONNECTOR_LABEL_WIDTH
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
local __re = ______shims.__re
local __split = ______shims.__split
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local freeformPathData = ____scene.freeformPathData
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local chartText = ____primitives.chartText
local DEFAULT_ZONE_FILL = ____primitives.DEFAULT_ZONE_FILL
local mapChartValue = ____primitives.mapChartValue
function renderCustomSeries(self, context, series, seriesIndex)
local style = customSeriesStyle(nil, context, series, seriesIndex)
return __TS__ArrayMap(
customSeriesValues(nil, context, series),
function(____, value, valueIndex)
local point = customPointPosition(nil, context, value)
local mark = {series = series, valueIndex = valueIndex, point = point, style = style}
local ____t_4 = __t
local ____opt_2 = series.symbol
return ____t_4(nil, ____opt_2 and #____opt_2.points) and createCustomSymbolMark(nil, context, mark) or createCustomPointMark(nil, context, mark)
end
)
end
function isHorizontal(self, chart)
local ____opt_5 = chart.config
return (____opt_5 and ____opt_5.orientation) == "horizontal"
end
function customSeriesValues(self, context, series)
local ____context_7 = context
local chart = ____context_7.chart
local hasExplicitXValues = #series.values > 0 and __TS__ArrayIsArray(series.values[1])
if hasExplicitXValues then
return __TS__ArrayMap(
series.values,
function(____, value) return {value[1], value[2]} end
)
end
if isHorizontal(nil, chart) then
return __TS__ArrayMap(
series.values,
function(____, value, index) return {value, chart.axisY.min + index * chart.axisY.step} end
)
end
return __TS__ArrayMap(
series.values,
function(____, value, index) return {chart.axisX.min + index * chart.axisX.step, value} end
)
end
function metricComponent(self, chart, point)
return isHorizontal(nil, chart) and point[1] or point[2]
end
function customPointPosition(self, context, value)
return {
x = context.plot.x + mapChartValue(nil, value[1], context.chart.axisX, context.plot.width),
y = context.plot.y + context.plot.height - mapChartValue(nil, value[2], context.chart.axisY, context.plot.height)
}
end
function customSeriesStyle(self, context, series, seriesIndex)
local color = series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1]
return {
fill = paint(nil, color, context.diagnostics, context.chart.id),
stroke = __t(nil, series.stroke) and ({kind = "solid", color = series.stroke}) or nil,
strokeWidth = __t(nil, series.stroke) and finite(nil, series.strokeWidth, 1) or nil
}
end
function createCustomSymbolMark(self, context, mark)
local symbol = mark.series.symbol
local size = finite(nil, mark.series.size, 3)
local scale = symbol and symbol.normalized and size * 2 or 1
local offset = symbol and symbol.normalized and 0.5 or 0
local points = __TS__ArrayMap(
symbol and symbol.points or ({}),
function(____, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
return {x = mark.point.x + (x - offset) * scale, y = mark.point.y + (y - offset) * scale}
end
)
return {
type = "path",
id = customMarkId(nil, context.chart, mark.series, mark.valueIndex),
order = context:nextOrder(),
bounds = context.bounds,
d = freeformPathData(
nil,
{
points = points,
tension = finite(nil, symbol and symbol.tension, 0),
closed = true
}
),
style = mark.style
}
end
function createCustomPointMark(self, context, mark)
local radius = finite(nil, mark.series.size, 3)
return {
type = "ellipse",
id = customMarkId(nil, context.chart, mark.series, mark.valueIndex),
order = context:nextOrder(),
bounds = context.bounds,
cx = mark.point.x,
cy = mark.point.y,
rx = radius,
ry = radius,
style = mark.style
}
end
function customMarkId(self, chart, series, valueIndex)
return (((("chart-custom-mark-" .. chart.id) .. "-") .. series.id) .. "-") .. tostring(valueIndex)
end
function renderConnectedPairs(self, context)
local ____context_16 = context
local chart = ____context_16.chart
local beforeSeries, afterSeries = table.unpack(chart.series, 1, 2)
local beforeValues = customSeriesValues(nil, context, beforeSeries)
local afterValues = customSeriesValues(nil, context, afterSeries)
local ____opt_17 = chart.config
local zones = ____opt_17 and ____opt_17.zones or ({})
local ____opt_19 = zones[1]
local betterColor = ____opt_19 and ____opt_19.color or "#10b981"
local ____opt_21 = zones[2]
local worseColor = ____opt_21 and ____opt_21.color or "#ec4899"
local ____opt_23 = zones[3]
local tieColor = ____opt_23 and ____opt_23.color or DEFAULT_ZONE_FILL
local ____Boolean_27 = Boolean
local ____opt_25 = chart.config
local reverse = ____Boolean_27(nil, ____opt_25 and ____opt_25.reverseComparison)
local count = math.min(#beforeValues, #afterValues)
local ____opt_28 = chart.config
local categories = ____opt_28 and ____opt_28.categories or ({})
local nodes = {}
do
local index = 0
while index < count do
local beforeValue = beforeValues[index + 1]
local afterValue = afterValues[index + 1]
local beforePoint = customPointPosition(nil, context, beforeValue)
local afterPoint = customPointPosition(nil, context, afterValue)
local beforeMetric = metricComponent(nil, chart, beforeValue)
local afterMetric = metricComponent(nil, chart, afterValue)
local ____reverse_30
if reverse then
____reverse_30 = afterMetric < beforeMetric
else
____reverse_30 = afterMetric > beforeMetric
end
local better = ____reverse_30
local ____reverse_31
if reverse then
____reverse_31 = afterMetric > beforeMetric
else
____reverse_31 = afterMetric < beforeMetric
end
local worse = ____reverse_31
local comparisonColor = better and betterColor or (worse and worseColor or tieColor)
local radius = finite(nil, afterSeries.size, 3)
nodes[#nodes + 1] = createConnectorLine(
nil,
context,
index,
beforePoint,
afterPoint,
comparisonColor
)
local ____createCustomPointMark_45 = createCustomPointMark
local ____context_44 = context
local ____beforeSeries_42 = beforeSeries
local ____index_43 = index
local ____paint_34 = paint
local ____opt_32 = chart.config
local ____paint_34_result_40 = ____paint_34(nil, ____opt_32 and ____opt_32.customBeforeFill or chart.gridColor or "#e2e8f0", context.diagnostics, chart.id)
local ____opt_35 = chart.config
local ____temp_41 = {kind = "solid", color = ____opt_35 and ____opt_35.customBeforeStroke or HOLLOW_POINT_STROKE}
local ____finite_39 = finite
local ____opt_37 = chart.config
nodes[#nodes + 1] = ____createCustomPointMark_45(
nil,
____context_44,
{
series = ____beforeSeries_42,
valueIndex = ____index_43,
point = beforePoint,
style = {
fill = ____paint_34_result_40,
stroke = ____temp_41,
strokeWidth = ____finite_39(nil, ____opt_37 and ____opt_37.customBeforeStrokeWidth, 1.5)
}
}
)
nodes[#nodes + 1] = createCustomPointMark(
nil,
context,
{
series = afterSeries,
valueIndex = index,
point = afterPoint,
style = {
fill = paint(nil, comparisonColor, context.diagnostics, chart.id),
stroke = nil,
strokeWidth = nil
}
}
)
if context.showLabels and __t(nil, categories[index + 1]) then
nodes[#nodes + 1] = createConnectorLabel(
nil,
context,
index,
beforePoint,
afterPoint,
radius,
categories[index + 1]
)
end
index = index + 1
end
end
return nodes
end
function connectorDash(self, text)
local parts = __TS__ArrayFilter(
__TS__ArrayMap(
__split(
nil,
text or "",
__re(nil, "[ ,]+", "")
),
Number
),
function(____, part) return __isFinite(nil, part) and part > 0 end
)
return #parts > 0 and parts or nil
end
function createConnectorLine(self, context, index, from, to, color)
local ____context_46 = context
local chart = ____context_46.chart
local ____temp_59 = (("chart-custom-connector-" .. chart.id) .. "-") .. tostring(index)
local ____temp_60 = context:nextOrder()
local ____context_bounds_61 = context.bounds
local ____temp_62 = (((((("M " .. tostring(from.x)) .. " ") .. tostring(from.y)) .. " L ") .. tostring(to.x)) .. " ") .. tostring(to.y)
local ____temp_55 = {kind = "none"}
local ____temp_56 = {kind = "solid", color = color}
local ____finite_49 = finite
local ____opt_47 = chart.config
local ____finite_49_result_57 = ____finite_49(nil, ____opt_47 and ____opt_47.customConnectorWidth, 2)
local ____opt_50 = chart.config
local ____temp_58 = ____opt_50 and ____opt_50.customConnectorOpacity
local ____connectorDash_54 = connectorDash
local ____opt_52 = chart.config
return {
type = "path",
id = ____temp_59,
order = ____temp_60,
bounds = ____context_bounds_61,
d = ____temp_62,
style = {
fill = ____temp_55,
stroke = ____temp_56,
strokeWidth = ____finite_49_result_57,
opacity = ____temp_58,
dash = ____connectorDash_54(nil, ____opt_52 and ____opt_52.customConnectorDash)
}
}
end
function createConnectorLabel(self, context, index, beforePoint, afterPoint, radius, text)
local ____context_63 = context
local chart = ____context_63.chart
local bounds = ____context_63.bounds
local nextOrder = ____context_63.nextOrder
local horizontal = isHorizontal(nil, chart)
local frame = horizontal and ({
x = math.max(beforePoint.x, afterPoint.x) + radius + CONNECTOR_LABEL_GAP,
y = math.min(beforePoint.y, afterPoint.y) - 8,
width = CONNECTOR_LABEL_WIDTH,
height = 16
}) or ({
x = math.min(beforePoint.x, afterPoint.x) - CONNECTOR_LABEL_WIDTH / 2,
y = math.min(beforePoint.y, afterPoint.y) - radius - CONNECTOR_LABEL_GAP - 14,
width = CONNECTOR_LABEL_WIDTH,
height = 16
})
local ____chartText_result_70 = chartText(
nil,
{
id = (("chart-custom-label-" .. chart.id) .. "-") .. tostring(index),
order = nextOrder(nil),
bounds = bounds,
frame = frame,
text = text,
chart = chart,
align = horizontal and "left" or "center"
}
)
local ____finite_66 = finite
local ____opt_64 = chart.config
local ____math_max_result_71 = math.max(
6,
____finite_66(
nil,
____opt_64 and ____opt_64.customLabelSize,
math.max(
9,
finite(nil, chart.fontSize, 12)
) - 2
)
)
local ____t_69 = __t
local ____opt_67 = chart.config
return __TS__ObjectAssign(
{},
____chartText_result_70,
{fontSize = ____math_max_result_71},
____t_69(nil, ____opt_67 and ____opt_67.customLabelColor) and ({color = chart.config.customLabelColor}) or ({})
)
end
HOLLOW_POINT_STROKE = "#94a3b8"
CONNECTOR_LABEL_GAP = 8
CONNECTOR_LABEL_WIDTH = 140
function ____exports.renderCustom(self, context)
local ____opt_0 = context.chart.config
if ____opt_0 and ____opt_0.connectPoints and #context.chart.series >= 2 then
return renderConnectedPairs(nil, context)
end
return __TS__ArrayFlatMap(
context.chart.series,
function(____, series, seriesIndex) return renderCustomSeries(nil, context, series, seriesIndex) end
)
end
return ____exports
end,
["core.renderScene.charts.renderers.field.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.renderers.field.data"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local ____exports = {}
local tupleSize
local ____primitives = require("core.renderScene.charts.primitives.index")
local mapChartValue = ____primitives.mapChartValue
function tupleSize(self, value)
return __TS__ArrayIsArray(value) and #value or nil
end
function ____exports.classifyFieldData(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local scalarSeries = __TS__ArrayFilter(
chart.series,
function(____, series) return tupleSize(nil, series.values[1]) == 3 end
)
local vectorSeries = __TS__ArrayFilter(
chart.series,
function(____, series) return tupleSize(nil, series.values[1]) == 4 end
)
local scalarSamples = __TS__ArrayFlatMap(
scalarSeries,
function(____, series) return __TS__ArrayMap(
series.values,
function(____, ____bindingPattern0)
local value
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
value = ____bindingPattern0[3]
return {
x = mapChartValue(nil, x, chart.axisX, plot.width),
y = plot.height - mapChartValue(nil, y, chart.axisY, plot.height),
value = value
}
end
) end
)
return {scalarSamples = scalarSamples, vectorSeries = vectorSeries}
end
return ____exports
end,
["core.renderScene.charts.renderers.field.legend"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local legendGeometry, createColorBar, createLegendLabels
local ______shims = require("core.__shims")
local __sort = ______shims.__sort
local __t = ______shims.__t
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local formatFieldValue = ____primitives.formatFieldValue
function legendGeometry(self, context)
local ____context_6 = context
local plot = ____context_6.plot
local width = math.min(220, plot.width)
return {x = plot.x + (plot.width - width) / 2, y = plot.y + plot.height + 46, width = width, height = 8}
end
function createColorBar(self, context, stops, minimum, maximum, geometry)
local ____context_7 = context
local chart = ____context_7.chart
local bounds = ____context_7.bounds
local nextOrder = ____context_7.nextOrder
local span = maximum - minimum
return {
type = "rect",
id = "chart-field-colorbar-" .. chart.id,
order = nextOrder(nil),
bounds = bounds,
x = geometry.x,
y = geometry.y,
width = geometry.width,
height = geometry.height,
rx = 2,
style = {fill = {
kind = "linear-gradient",
angle = 0,
stops = __TS__ArrayMap(
stops,
function(____, stop) return {offset = span == 0 and 0 or (stop.position - minimum) / span * 100, color = stop.color} end
)
}}
}
end
function createLegendLabels(self, context, minimum, maximum, geometry)
local ____context_8 = context
local chart = ____context_8.chart
local bounds = ____context_8.bounds
local nextOrder = ____context_8.nextOrder
local y = geometry.y + geometry.height + 3
return {
chartText(
nil,
{
id = "chart-field-colorbar-min-" .. chart.id,
order = nextOrder(nil),
bounds = bounds,
frame = {x = geometry.x, y = y, width = 80, height = 16},
text = formatFieldValue(nil, minimum),
chart = chart
}
),
chartText(
nil,
{
id = "chart-field-colorbar-max-" .. chart.id,
order = nextOrder(nil),
bounds = bounds,
frame = {x = geometry.x + geometry.width - 80, y = y, width = 80, height = 16},
text = formatFieldValue(nil, maximum),
chart = chart,
align = "right"
}
)
}
end
function ____exports.renderFieldLegend(self, context)
local ____opt_2 = context.chart.config
local ____opt_0 = ____opt_2 and ____opt_2.scale
local stops = ____opt_0 and ____opt_0.stops
if not context.showLegend or not __t(nil, stops and #stops) then
return {}
end
local sortedStops = __sort(
nil,
{table.unpack(stops)},
function(____, a, b) return a.position - b.position end
)
local minimum = sortedStops[1].position
local maximum = sortedStops[#sortedStops].position
local geometry = legendGeometry(nil, context)
return {
createColorBar(
nil,
context,
sortedStops,
minimum,
maximum,
geometry
),
table.unpack(createLegendLabels(
nil,
context,
minimum,
maximum,
geometry
))
}
end
return ____exports
end,
["core.renderScene.charts.field.colorRamp"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____color = require("core.model.color.index")
local interpolateHexColorStops = ____color.interpolateHexColorStops
local RAMP_FALLBACK_COLOR = "#94a3b8"
function ____exports.colorAtRamp(self, ramp, value)
if not __t(nil, ramp and #ramp.stops) then
return RAMP_FALLBACK_COLOR
end
return interpolateHexColorStops(nil, ramp.stops, value)
end
return ____exports
end,
["core.renderScene.charts.field.isolines"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayFill = ____lualib.__TS__ArrayFill
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ArrayReverse = ____lualib.__TS__ArrayReverse
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local createIsolineCell, fieldSample, isolineCaseIndex, isAboveThreshold, segmentsForIsolineCase, cellEdgeIntersections, interpolateEdge, isolineSegment
local ______shims = require("core.__shims")
local __newArray = ______shims.__newArray
local __or = ______shims.__or
local __t = ______shims.__t
function createIsolineCell(self, field, row, column)
return {
topLeft = fieldSample(nil, field, row, column),
topRight = fieldSample(nil, field, row, column + 1),
bottomRight = fieldSample(nil, field, row + 1, column + 1),
bottomLeft = fieldSample(nil, field, row + 1, column)
}
end
function fieldSample(self, field, row, column)
return {x = field.width * (column / (field.columns - 1)), y = field.height * (row / (field.rows - 1)), value = field.values[row * field.columns + column]}
end
function isolineCaseIndex(self, cell, threshold)
return __or(
nil,
__or(
nil,
__or(
nil,
isAboveThreshold(nil, cell.topLeft, threshold) and 8 or 0,
isAboveThreshold(nil, cell.topRight, threshold) and 4 or 0
),
isAboveThreshold(nil, cell.bottomRight, threshold) and 2 or 0
),
isAboveThreshold(nil, cell.bottomLeft, threshold) and 1 or 0
)
end
function isAboveThreshold(self, sample, threshold)
return sample.value >= threshold
end
function segmentsForIsolineCase(self, cell, caseIndex, threshold)
local edges = cellEdgeIntersections(nil, cell, threshold)
repeat
local ____switch27 = caseIndex
local ____cond27 = ____switch27 == 1 or ____switch27 == 14
if ____cond27 then
return {isolineSegment(nil, edges.left, edges.bottom)}
end
____cond27 = ____cond27 or (____switch27 == 2 or ____switch27 == 13)
if ____cond27 then
return {isolineSegment(nil, edges.bottom, edges.right)}
end
____cond27 = ____cond27 or (____switch27 == 3 or ____switch27 == 12)
if ____cond27 then
return {isolineSegment(nil, edges.left, edges.right)}
end
____cond27 = ____cond27 or (____switch27 == 4 or ____switch27 == 11)
if ____cond27 then
return {isolineSegment(nil, edges.top, edges.right)}
end
____cond27 = ____cond27 or ____switch27 == 5
if ____cond27 then
return {
isolineSegment(nil, edges.left, edges.top),
isolineSegment(nil, edges.bottom, edges.right)
}
end
____cond27 = ____cond27 or (____switch27 == 6 or ____switch27 == 9)
if ____cond27 then
return {isolineSegment(nil, edges.top, edges.bottom)}
end
____cond27 = ____cond27 or (____switch27 == 7 or ____switch27 == 8)
if ____cond27 then
return {isolineSegment(nil, edges.left, edges.top)}
end
____cond27 = ____cond27 or ____switch27 == 10
if ____cond27 then
return {
isolineSegment(nil, edges.top, edges.right),
isolineSegment(nil, edges.left, edges.bottom)
}
end
do
return {}
end
until true
end
function cellEdgeIntersections(self, cell, threshold)
return {
top = interpolateEdge(nil, cell.topLeft, cell.topRight, threshold),
right = interpolateEdge(nil, cell.topRight, cell.bottomRight, threshold),
bottom = interpolateEdge(nil, cell.bottomLeft, cell.bottomRight, threshold),
left = interpolateEdge(nil, cell.topLeft, cell.bottomLeft, threshold)
}
end
function interpolateEdge(self, start, ____end, threshold)
local progress = ____end.value == start.value and 0.5 or (threshold - start.value) / (____end.value - start.value)
return {start.x + (____end.x - start.x) * progress, start.y + (____end.y - start.y) * progress}
end
function isolineSegment(self, from, to)
return {x1 = from[1], y1 = from[2], x2 = to[1], y2 = to[2]}
end
function ____exports.stitchIsolineSegments(self, segments)
if #segments == 0 then
return {}
end
local function pointKey(____, point)
return (tostring(math.floor(point[1] * 1000 + 0.5)) .. ":") .. tostring(math.floor(point[2] * 1000 + 0.5))
end
local adjacency = __TS__New(Map)
local function addEdge(____, from, to, segment)
local key = pointKey(nil, from)
local list = adjacency:get(key)
local entry = {point = to, segment = segment}
if list then
list[#list + 1] = entry
else
adjacency:set(key, {entry})
end
end
__TS__ArrayForEach(
segments,
function(____, segment, index)
local a = {segment.x1, segment.y1}
local b = {segment.x2, segment.y2}
addEdge(nil, a, b, index)
addEdge(nil, b, a, index)
end
)
local usedSegments = __TS__ArrayFill(
__newArray(nil, #segments),
false
)
local function extend(____, chain, from)
local current = from
do
while true do
local candidates = adjacency:get(pointKey(nil, current))
local ____opt_0 = candidates
local next = ____opt_0 and __TS__ArrayFind(
candidates,
function(____, candidate) return not __t(nil, usedSegments[candidate.segment + 1]) end
)
if not next then
return
end
usedSegments[next.segment + 1] = true
chain[#chain + 1] = next.point
current = next.point
end
end
end
local chains = {}
__TS__ArrayForEach(
segments,
function(____, segment, index)
if __t(nil, usedSegments[index + 1]) then
return
end
usedSegments[index + 1] = true
local forward = {{segment.x1, segment.y1}, {segment.x2, segment.y2}}
extend(nil, forward, forward[#forward])
local backward = {}
extend(nil, backward, forward[1])
__TS__ArrayReverse(backward)
local ____array_2 = __TS__SparseArrayNew(table.unpack(backward))
__TS__SparseArrayPush(
____array_2,
table.unpack(forward)
)
chains[#chains + 1] = {__TS__SparseArraySpread(____array_2)}
end
)
return chains
end
function ____exports.computeIsolineSegments(self, field, threshold)
local segments = {}
do
local row = 0
while row < field.rows - 1 do
do
local column = 0
while column < field.columns - 1 do
local cell = createIsolineCell(nil, field, row, column)
local caseIndex = isolineCaseIndex(nil, cell, threshold)
if caseIndex ~= 0 and caseIndex ~= 15 then
__TS__ArrayPushArray(
segments,
segmentsForIsolineCase(nil, cell, caseIndex, threshold)
)
end
column = column + 1
end
end
row = row + 1
end
end
return segments
end
return ____exports
end,
["core.renderScene.charts.renderers.field.scalar"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local createScalarGrid, renderFieldCells, createFieldCell, renderIsolines, createIsoline, ISOLINE_TENSION
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____colorRamp = require("core.renderScene.charts.field.colorRamp")
local colorAtRamp = ____colorRamp.colorAtRamp
local ____grid = require("core.renderScene.charts.field.grid")
local computeFieldGrid = ____grid.computeFieldGrid
local fieldSurfaceClip = ____grid.fieldSurfaceClip
local ____isolines = require("core.renderScene.charts.field.isolines")
local computeIsolineSegments = ____isolines.computeIsolineSegments
local stitchIsolineSegments = ____isolines.stitchIsolineSegments
local ____linePath = require("core.renderScene.charts.primitives.linePath")
local linePathData = ____linePath.linePathData
function createScalarGrid(self, context, samples)
local ____context_1 = context
local plot = ____context_1.plot
local chart = ____context_1.chart
local ____computeFieldGrid_5 = computeFieldGrid
local ____array_4 = __TS__SparseArrayNew(nil, samples, plot.width, plot.height)
local ____opt_2 = chart.config
__TS__SparseArrayPush(____array_4, ____opt_2 and ____opt_2.idwPower or 2)
local result = ____computeFieldGrid_5(__TS__SparseArraySpread(____array_4))
return {
values = result.grid,
columns = result.cols,
rows = result.rows,
cellWidth = plot.width / math.max(1, result.cols - 1),
cellHeight = plot.height / math.max(1, result.rows - 1)
}
end
function renderFieldCells(self, context, grid)
local nodes = {}
do
local row = 0
while row < grid.rows do
do
local column = 0
while column < grid.columns do
nodes[#nodes + 1] = createFieldCell(
nil,
context,
grid,
row,
column
)
column = column + 1
end
end
row = row + 1
end
end
return nodes
end
function createFieldCell(self, context, grid, row, column)
local ____context_6 = context
local chart = ____context_6.chart
local plot = ____context_6.plot
local bounds = ____context_6.bounds
local nextOrder = ____context_6.nextOrder
local centerX = plot.x + plot.width * (column / (grid.columns - 1))
local centerY = plot.y + plot.height * (row / (grid.rows - 1))
local ____colorAtRamp_9 = colorAtRamp
local ____opt_7 = chart.config
local color = ____colorAtRamp_9(nil, ____opt_7 and ____opt_7.scale, grid.values[row * grid.columns + column])
return {
type = "rect",
id = (((("chart-field-cell-" .. chart.id) .. "-") .. tostring(row)) .. "-") .. tostring(column),
order = nextOrder(nil),
bounds = bounds,
x = centerX - grid.cellWidth / 2,
y = centerY - grid.cellHeight / 2,
width = grid.cellWidth,
height = grid.cellHeight,
style = {
fill = {kind = "solid", color = color},
clip = fieldSurfaceClip(nil, chart, plot)
}
}
end
function renderIsolines(self, context, grid)
local nodes = {}
local ____opt_10 = context.chart.config
__TS__ArrayForEach(
____opt_10 and ____opt_10.isolines or ({}),
function(____, threshold, thresholdIndex)
local node = createIsoline(
nil,
context,
grid,
threshold,
thresholdIndex
)
if node then
nodes[#nodes + 1] = node
end
end
)
return nodes
end
function createIsoline(self, context, grid, threshold, thresholdIndex)
local ____context_12 = context
local chart = ____context_12.chart
local plot = ____context_12.plot
local bounds = ____context_12.bounds
local nextOrder = ____context_12.nextOrder
local segments = computeIsolineSegments(nil, {
values = grid.values,
columns = grid.columns,
rows = grid.rows,
width = plot.width,
height = plot.height
}, threshold)
if not __t(nil, #segments) then
return nil
end
local chains = stitchIsolineSegments(nil, segments)
local path = table.concat(
__TS__ArrayMap(
chains,
function(____, chain) return linePathData(
nil,
__TS__ArrayMap(
chain,
function(____, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
return {x = plot.x + x, y = plot.y + y}
end
),
ISOLINE_TENSION
) end
),
" "
)
return {
type = "path",
id = (("chart-field-isoline-" .. chart.id) .. "-") .. tostring(thresholdIndex),
order = nextOrder(nil),
bounds = bounds,
d = path,
style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = "rgba(15, 23, 42, 0.55)"},
strokeWidth = 1,
clip = fieldSurfaceClip(nil, chart, plot)
}
}
end
ISOLINE_TENSION = 0.5
function ____exports.renderScalarField(self, context, samples)
if not __t(nil, #samples) or context.plot.width <= 0 or context.plot.height <= 0 then
return {}
end
local grid = createScalarGrid(nil, context, samples)
local ____array_0 = __TS__SparseArrayNew(table.unpack(renderFieldCells(nil, context, grid)))
__TS__SparseArrayPush(
____array_0,
table.unpack(renderIsolines(nil, context, grid))
)
return {__TS__SparseArraySpread(____array_0)}
end
return ____exports
end,
["core.renderScene.charts.renderers.field.vectors"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local createVectorNode
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local mapChartValue = ____primitives.mapChartValue
function createVectorNode(self, context, seriesId, vector, vectorIndex, color)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local bounds = ____context_0.bounds
local diagnostics = ____context_0.diagnostics
local nextOrder = ____context_0.nextOrder
local x, y, angle, magnitude = table.unpack(vector, 1, 4)
local startX = plot.x + mapChartValue(nil, x, chart.axisX, plot.width)
local startY = plot.y + plot.height - mapChartValue(nil, y, chart.axisY, plot.height)
local endX = plot.x + mapChartValue(
nil,
x + math.cos(angle) * magnitude,
chart.axisX,
plot.width
)
local endY = plot.y + plot.height - mapChartValue(
nil,
y + math.sin(angle) * magnitude,
chart.axisY,
plot.height
)
return {
type = "path",
id = (((("chart-field-vector-" .. chart.id) .. "-") .. seriesId) .. "-") .. tostring(vectorIndex),
order = nextOrder(nil),
bounds = bounds,
d = (((((("M " .. tostring(startX)) .. " ") .. tostring(startY)) .. " L ") .. tostring(endX)) .. " ") .. tostring(endY),
markerEnd = "filled_arrow",
style = {
fill = {kind = "none"},
stroke = paint(nil, color, diagnostics, chart.id),
strokeWidth = 2
}
}
end
function ____exports.renderVectorField(self, context, seriesList)
local nodes = {}
__TS__ArrayForEach(
seriesList,
function(____, series, seriesIndex)
local color = series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1]
__TS__ArrayForEach(
series.values,
function(____, vector, vectorIndex)
nodes[#nodes + 1] = createVectorNode(
nil,
context,
series.id,
vector,
vectorIndex,
color
)
end
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.field"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____data = require("core.renderScene.charts.renderers.field.data")
local classifyFieldData = ____data.classifyFieldData
local ____legend = require("core.renderScene.charts.renderers.field.legend")
local renderFieldLegend = ____legend.renderFieldLegend
local ____scalar = require("core.renderScene.charts.renderers.field.scalar")
local renderScalarField = ____scalar.renderScalarField
local ____vectors = require("core.renderScene.charts.renderers.field.vectors")
local renderVectorField = ____vectors.renderVectorField
function ____exports.renderField(self, context)
local data = classifyFieldData(nil, context)
local nodes = {}
__TS__ArrayPushArray(
nodes,
renderScalarField(nil, context, data.scalarSamples)
)
__TS__ArrayPushArray(
nodes,
renderVectorField(nil, context, data.vectorSeries)
)
__TS__ArrayPushArray(
nodes,
renderFieldLegend(nil, context)
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.heatmap.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.renderers.heatmap.cells"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local renderRowCells, createHeatmapCell, colorForValue, renderHeatmapCell, createCellBackground, createCellValueLabel
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local contrastTextColor = ____primitives.contrastTextColor
local zoneColorAtValue = ____primitives.zoneColorAtValue
function renderRowCells(self, context, layout, series, rowIndex)
return __TS__ArrayFlatMap(
layout.columns,
function(____, _, columnIndex)
local cell = createHeatmapCell(
nil,
layout,
series,
rowIndex,
columnIndex
)
return renderHeatmapCell(nil, context, layout, cell)
end
)
end
function createHeatmapCell(self, layout, series, rowIndex, columnIndex)
local value = series.values[columnIndex + 1] or 0
local ____layout_grid_0 = layout.grid
local cellGap = ____layout_grid_0.cellGap
return {
seriesId = series.id,
columnIndex = columnIndex,
value = value,
color = colorForValue(nil, value, layout),
frame = {
x = layout.grid.x + columnIndex * layout.grid.cellWidth + cellGap / 2,
y = layout.grid.y + rowIndex * layout.grid.cellHeight + cellGap / 2,
width = math.max(0, layout.grid.cellWidth - cellGap),
height = math.max(0, layout.grid.cellHeight - cellGap)
}
}
end
function colorForValue(self, value, layout)
return zoneColorAtValue(nil, value, layout.bands, layout.zones)
end
function renderHeatmapCell(self, context, layout, cell)
local background = createCellBackground(nil, context, layout, cell)
local ____opt_1 = context.chart.config
if (____opt_1 and ____opt_1.showValues) == false then
return {background}
end
return {
background,
createCellValueLabel(nil, context, layout, cell)
}
end
function createCellBackground(self, context, layout, cell)
local ____context_3 = context
local chart = ____context_3.chart
local bounds = ____context_3.bounds
local nextOrder = ____context_3.nextOrder
local id = (((("chart-heatmap-cell-" .. chart.id) .. "-") .. cell.seriesId) .. "-") .. tostring(cell.columnIndex)
local ____temp_9 = {kind = "solid", color = cell.color}
local ____opt_4 = chart.config
local ____temp_10 = {kind = "solid", color = ____opt_4 and ____opt_4.cellStrokeColor or chart.gridColor or "#e2e8f0"}
local ____finite_8 = finite
local ____opt_6 = chart.config
local style = {
fill = ____temp_9,
stroke = ____temp_10,
strokeWidth = ____finite_8(
nil,
____opt_6 and ____opt_6.cellStrokeWidth,
finite(nil, chart.gridWidth, 1)
)
}
local ____opt_11 = chart.config
if (____opt_11 and ____opt_11.cellShape) == "circle" then
return {
type = "ellipse",
id = id,
order = nextOrder(nil),
bounds = bounds,
cx = cell.frame.x + cell.frame.width / 2,
cy = cell.frame.y + cell.frame.height / 2,
rx = cell.frame.width / 2,
ry = cell.frame.height / 2,
style = style
}
end
return __TS__ObjectAssign(
{
type = "rect",
id = id,
order = nextOrder(nil),
bounds = bounds
},
cell.frame,
{rx = layout.grid.cellRadius, style = style}
)
end
function createCellValueLabel(self, context, layout, cell)
local ____context_13 = context
local chart = ____context_13.chart
local bounds = ____context_13.bounds
local nextOrder = ____context_13.nextOrder
local ____finite_16 = finite
local ____opt_14 = chart.config
local size = math.max(
6,
____finite_16(nil, ____opt_14 and ____opt_14.cellValueSize, layout.fontSize)
)
local ____chartText_result_21 = chartText(
nil,
{
id = (((("chart-heatmap-value-" .. chart.id) .. "-") .. cell.seriesId) .. "-") .. tostring(cell.columnIndex),
order = nextOrder(nil),
bounds = bounds,
frame = {x = cell.frame.x, y = cell.frame.y + cell.frame.height / 2 - size / 2, width = cell.frame.width, height = size + 2},
text = tostring(cell.value),
chart = chart,
align = "center"
}
)
local ____opt_17 = chart.config
local ____temp_22 = (____opt_17 and ____opt_17.cellValueSize) == nil and ({}) or ({fontSize = size})
local ____opt_19 = chart.config
return __TS__ObjectAssign(
{},
____chartText_result_21,
____temp_22,
{color = ____opt_19 and ____opt_19.cellValueColor or contrastTextColor(nil, cell.color)}
)
end
function ____exports.renderHeatmapCells(self, context, layout)
local nodes = {}
__TS__ArrayForEach(
layout.rows,
function(____, series, rowIndex)
__TS__ArrayPushArray(
nodes,
renderRowCells(
nil,
context,
layout,
series,
rowIndex
)
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.heatmap.layout"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local heatmapSides, heatmapColumns, heatmapReservedSpace, columnHeaderRoom, createHeatmapGrid, LEGEND_ACROSS, LEGEND_BESIDE
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____textLayout = require("core.renderScene.scene.textLayout")
local estimateTextWidth = ____textLayout.estimateTextWidth
local ____primitives = require("core.renderScene.charts.primitives.index")
local axisBands = ____primitives.axisBands
local DEFAULT_HEATMAP_ZONES = ____primitives.DEFAULT_HEATMAP_ZONES
local labelTilt = ____primitives.labelTilt
local tiltedLabelRoom = ____primitives.tiltedLabelRoom
function heatmapSides(self, context)
local ____context_9 = context
local chart = ____context_9.chart
return {rows = chart.rowLabelSide == "right" and "right" or "left", columns = chart.columnLabelSide == "bottom" and "bottom" or "top", legend = chart.legendSide or "bottom"}
end
function heatmapColumns(self, context)
local ____context_10 = context
local chart = ____context_10.chart
local ____t_result_22
local ____t_15 = __t
local ____opt_13 = chart.config
local ____opt_11 = ____opt_13 and ____opt_13.categories
if ____t_15(nil, ____opt_11 and #____opt_11) then
____t_result_22 = chart.config.categories
else
local ____opt_20 = chart.series[1]
local ____opt_16 = ____opt_20 and ____opt_20.values
if ____opt_16 ~= nil then
local ____opt_17 = chart.series[1]
____opt_16 = __TS__ArrayMap(
____opt_17 and ____opt_17.values,
function(____, _, index) return tostring(index + 1) end
)
end
____t_result_22 = ____opt_16 or ({})
end
return ____t_result_22
end
function heatmapReservedSpace(self, context, sides)
local ____context_23 = context
local chart = ____context_23.chart
local fontSize = ____exports.headerFontSize(nil, chart)
local longestLabel = __TS__ArrayReduce(
chart.series,
function(____, max, series) return math.max(
max,
estimateTextWidth(nil, series.label or "", fontSize, false)
) end,
0
)
local vertical = sides.legend == "left" or sides.legend == "right"
return {
rowHeaders = context.showLabels and math.min(
context.plot.width * 0.7,
__t(nil, chart.axisLabelSpace) and chart.axisLabelSpace > 0 and chart.axisLabelSpace or longestLabel + 6 + ____exports.rowGap(nil, chart)
) or 0,
columnHeaders = context.showLabels and columnHeaderRoom(nil, context) or 0,
legend = context.showLegend and (vertical and LEGEND_BESIDE or LEGEND_ACROSS) + ____exports.legendGap(nil, chart) or 0
}
end
function columnHeaderRoom(self, context)
local ____context_24 = context
local chart = ____context_24.chart
local tilt = labelTilt(nil, chart)
return tilt > 0 and math.min(
context.plot.height * 0.4,
tiltedLabelRoom(
nil,
chart,
heatmapColumns(nil, context),
tilt
) + ____exports.columnGap(nil, chart) + 4
) or ____exports.headerFontSize(nil, chart) + 2 + ____exports.columnGap(nil, chart) + 6
end
function createHeatmapGrid(self, context, reservedSpace, sides, columnCount)
local ____context_25 = context
local chart = ____context_25.chart
local left = (sides.rows == "left" and reservedSpace.rowHeaders or 0) + (sides.legend == "left" and reservedSpace.legend or 0)
local right = (sides.rows == "right" and reservedSpace.rowHeaders or 0) + (sides.legend == "right" and reservedSpace.legend or 0)
local top = (sides.columns == "top" and reservedSpace.columnHeaders or 0) + (sides.legend == "top" and reservedSpace.legend or 0)
local bottom = (sides.columns == "bottom" and reservedSpace.columnHeaders or 0) + (sides.legend == "bottom" and reservedSpace.legend or 0)
local width = math.max(1, context.plot.width - left - right)
local height = math.max(1, context.plot.height - top - bottom)
local rowCount = #chart.series
local ____finite_28 = finite
local ____opt_26 = chart.config
local cellGap = math.max(
0,
____finite_28(nil, ____opt_26 and ____opt_26.cellGap, 0)
)
local cellWidth = __t(nil, columnCount) and width / columnCount or width
local cellHeight = __t(nil, rowCount) and height / rowCount or height
local gridWidth = width
local gridHeight = height
local ____opt_29 = chart.config
if ____opt_29 and ____opt_29.squareCells and __t(nil, columnCount) and __t(nil, rowCount) then
local cellSize = math.min(cellWidth, cellHeight)
cellWidth = cellSize
cellHeight = cellSize
gridWidth = cellSize * columnCount
gridHeight = cellSize * rowCount
end
local ____temp_34 = context.plot.x + left
local ____temp_35 = context.plot.y + top
local ____gridWidth_36 = gridWidth
local ____gridHeight_37 = gridHeight
local ____cellWidth_38 = cellWidth
local ____cellHeight_39 = cellHeight
local ____cellGap_40 = cellGap
local ____finite_33 = finite
local ____opt_31 = chart.config
return {
x = ____temp_34,
y = ____temp_35,
width = ____gridWidth_36,
height = ____gridHeight_37,
cellWidth = ____cellWidth_38,
cellHeight = ____cellHeight_39,
cellGap = ____cellGap_40,
cellRadius = math.max(
0,
____finite_33(nil, ____opt_31 and ____opt_31.barCornerRadius, cellGap)
)
}
end
function ____exports.createHeatmapLayout(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local columns = heatmapColumns(nil, context)
local sides = heatmapSides(nil, context)
local reservedSpace = heatmapReservedSpace(nil, context, sides)
local ____chart_series_6 = chart.series
local ____columns_7 = columns
local ____axisBands_result_8 = axisBands(nil, chart.axisY)
local ____t_5 = __t
local ____opt_3 = chart.config
local ____opt_1 = ____opt_3 and ____opt_3.zones
return {
rows = ____chart_series_6,
columns = ____columns_7,
bands = ____axisBands_result_8,
zones = ____t_5(nil, ____opt_1 and #____opt_1) and chart.config.zones or DEFAULT_HEATMAP_ZONES,
fontSize = math.max(
9,
finite(nil, chart.fontSize, 12)
),
headerFontSize = ____exports.headerFontSize(nil, chart),
legendGap = ____exports.legendGap(nil, chart),
sides = sides,
reservedSpace = reservedSpace,
grid = createHeatmapGrid(
nil,
context,
reservedSpace,
sides,
#columns
)
}
end
____exports.headerFontSize = function(____, chart) return math.max(
9,
finite(nil, chart.axisFontSize or chart.fontSize, 12)
) end
____exports.rowGap = function(____, chart) return math.min(
120,
math.max(
0,
finite(nil, chart.yLabelGap, 6)
)
) end
____exports.columnGap = function(____, chart) return math.min(
120,
math.max(
0,
finite(nil, chart.xLabelGap, 4)
)
) end
____exports.legendGap = function(____, chart) return math.min(
80,
math.max(
0,
finite(nil, chart.legendGap, 6)
)
) end
LEGEND_ACROSS = 32
LEGEND_BESIDE = 56
return ____exports
end,
["core.renderScene.charts.renderers.heatmap.headers"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local renderRowHeaders, createRowHeader, renderColumnHeaders, createColumnHeader
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local labelAboveFrame = ____primitives.labelAboveFrame
local labelBelowFrame = ____primitives.labelBelowFrame
local labelTilt = ____primitives.labelTilt
local ____layout = require("core.renderScene.charts.renderers.heatmap.layout")
local columnGap = ____layout.columnGap
local rowGap = ____layout.rowGap
function renderRowHeaders(self, context, layout)
if layout.reservedSpace.rowHeaders <= 0 then
return {}
end
return __TS__ArrayMap(
layout.rows,
function(____, series, rowIndex) return createRowHeader(
nil,
context,
layout,
series,
rowIndex
) end
)
end
function createRowHeader(self, context, layout, series, rowIndex)
local ____context_1 = context
local chart = ____context_1.chart
local bounds = ____context_1.bounds
local nextOrder = ____context_1.nextOrder
local room = layout.reservedSpace.rowHeaders
local gap = rowGap(nil, chart)
local x = layout.sides.rows == "left" and layout.grid.x - room or layout.grid.x + layout.grid.width + gap
return chartText(
nil,
{
id = (("chart-heatmap-row-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil),
bounds = bounds,
frame = {
x = x,
y = layout.grid.y + rowIndex * layout.grid.cellHeight + layout.grid.cellHeight / 2 - layout.headerFontSize / 2,
width = math.max(1, room - gap),
height = layout.headerFontSize + 2
},
text = series.label,
chart = chart,
align = chart.axisLabelAlign or "left",
role = "axis"
}
)
end
function renderColumnHeaders(self, context, layout)
if layout.reservedSpace.columnHeaders <= 0 then
return {}
end
return __TS__ArrayMap(
layout.columns,
function(____, label, columnIndex) return createColumnHeader(
nil,
context,
layout,
label,
columnIndex
) end
)
end
function createColumnHeader(self, context, layout, label, columnIndex)
local ____context_2 = context
local chart = ____context_2.chart
local bounds = ____context_2.bounds
local nextOrder = ____context_2.nextOrder
local above = layout.sides.columns == "top"
local centerX = layout.grid.x + (columnIndex + 0.5) * layout.grid.cellWidth
local tilt = labelTilt(nil, chart)
local gap = columnGap(nil, chart)
local id = (("chart-heatmap-col-" .. chart.id) .. "-") .. tostring(columnIndex)
if tilt > 0 then
local ____temp_3 = above and labelAboveFrame(
nil,
chart,
label,
tilt,
{x = centerX, y = layout.grid.y - gap}
) or labelBelowFrame(
nil,
chart,
label,
tilt,
{x = centerX, y = layout.grid.y + layout.grid.height + gap}
)
local frame = ____temp_3.frame
local rotation = ____temp_3.rotation
return chartText(
nil,
{
id = id,
order = nextOrder(nil),
bounds = bounds,
frame = frame,
text = label,
chart = chart,
align = above and "left" or "right",
rotation = rotation,
role = "axis"
}
)
end
return chartText(
nil,
{
id = id,
order = nextOrder(nil),
bounds = bounds,
frame = {x = layout.grid.x + columnIndex * layout.grid.cellWidth, y = above and layout.grid.y - gap - (layout.headerFontSize + 2) or layout.grid.y + layout.grid.height + gap, width = layout.grid.cellWidth, height = layout.headerFontSize + 2},
text = label,
chart = chart,
align = "center",
role = "axis"
}
)
end
function ____exports.renderHeatmapHeaders(self, context, layout)
local ____array_0 = __TS__SparseArrayNew(table.unpack(renderRowHeaders(nil, context, layout)))
__TS__SparseArrayPush(
____array_0,
table.unpack(renderColumnHeaders(nil, context, layout))
)
return {__TS__SparseArraySpread(____array_0)}
end
return ____exports
end,
["core.renderScene.charts.renderers.heatmap.legend"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local bandRatio, createGradientBar, createBoundaryTicks, tickPathAt, labelAt, TICK_LENGTH, ROW_GAP, LABEL_WIDTH
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local boxBounds = ____scene.boxBounds
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local DEFAULT_ZONE_FILL = ____primitives.DEFAULT_ZONE_FILL
local formatFieldValue = ____primitives.formatFieldValue
function bandRatio(self, layout, value)
local first = layout.bands[1]
local last = layout.bands[#layout.bands]
return last == first and 0 or (value - first) / (last - first)
end
function createGradientBar(self, context, layout, place, barBounds)
local ____context_1 = context
local chart = ____context_1.chart
local nextOrder = ____context_1.nextOrder
local bandCount = math.max(0, #layout.bands - 1)
local zones = __TS__ArraySlice(layout.zones, 0, bandCount)
local stops = __TS__ArrayMap(
zones,
function(____, zone, index) return {
offset = bandRatio(nil, layout, layout.bands[index + 1 + 1] or layout.bands[#layout.bands]) * 100,
color = zone.color or DEFAULT_ZONE_FILL
} end
)
return {
type = "rect",
id = "chart-heatmap-legend-bar-" .. chart.id,
order = nextOrder(nil),
bounds = barBounds,
x = place.x,
y = place.y,
width = place.width,
height = place.height,
rx = 3,
zoneGradient = {axis = "y", min = chart.axisY.min, max = chart.axisY.max},
style = {
fill = __t(nil, #stops) and ({kind = "linear-gradient", angle = place.vertical and 270 or 0, stops = stops}) or ({kind = "solid", color = DEFAULT_ZONE_FILL}),
stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"},
strokeWidth = 1
}
}
end
function createBoundaryTicks(self, context, layout, place)
local ____context_2 = context
local chart = ____context_2.chart
local bounds = ____context_2.bounds
local nextOrder = ____context_2.nextOrder
local labelHeight = layout.fontSize + 2
local lastIndex = #layout.bands - 1
return __TS__ArrayFlatMap(
layout.bands,
function(____, value, index)
local ratio = bandRatio(nil, layout, value)
local at = place.vertical and place.y + place.height - ratio * place.height or place.x + ratio * place.width
local tickPath = tickPathAt(nil, place, at)
local tick = {
type = "path",
id = (("chart-heatmap-legend-tick-" .. chart.id) .. "-") .. tostring(index),
order = nextOrder(nil),
bounds = bounds,
d = tickPath,
style = {fill = {kind = "none"}, stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"}, strokeWidth = 1}
}
local label = chartText(
nil,
__TS__ObjectAssign(
{
id = (("chart-heatmap-legend-tick-label-" .. chart.id) .. "-") .. tostring(index),
order = nextOrder(nil),
bounds = bounds
},
labelAt(
nil,
place,
at,
index == 0,
index == lastIndex,
labelHeight
),
{
text = formatFieldValue(nil, value),
chart = chart
}
)
)
return {tick, label}
end
)
end
function tickPathAt(self, place, at)
if place.vertical then
local from = place.numbers == "right" and place.x + place.width or place.x
local to = place.numbers == "right" and from + TICK_LENGTH or from - TICK_LENGTH
return (((((("M " .. tostring(from)) .. " ") .. tostring(at)) .. " L ") .. tostring(to)) .. " ") .. tostring(at)
end
local from = place.numbers == "bottom" and place.y + place.height or place.y
local to = place.numbers == "bottom" and from + TICK_LENGTH or from - TICK_LENGTH
return (((((("M " .. tostring(at)) .. " ") .. tostring(from)) .. " L ") .. tostring(at)) .. " ") .. tostring(to)
end
function labelAt(self, place, at, first, last, labelHeight)
if place.vertical then
local onRight = place.numbers == "right"
local x = onRight and place.x + place.width + TICK_LENGTH + ROW_GAP or place.x - TICK_LENGTH - ROW_GAP - LABEL_WIDTH
return {frame = {x = x, y = at - labelHeight / 2, width = LABEL_WIDTH, height = labelHeight}, align = onRight and "left" or "right"}
end
local y = place.numbers == "bottom" and place.y + place.height + TICK_LENGTH + ROW_GAP or place.y - TICK_LENGTH - ROW_GAP - labelHeight
local x = first and at or (last and at - LABEL_WIDTH or at - LABEL_WIDTH / 2)
return {frame = {x = x, y = y, width = LABEL_WIDTH, height = labelHeight}, align = first and "left" or (last and "right" or "center")}
end
local BAR_THICKNESS = 10
TICK_LENGTH = 4
ROW_GAP = 2
LABEL_WIDTH = 48
local function barPlace(self, layout)
local ____layout_0 = layout
local grid = ____layout_0.grid
local sides = ____layout_0.sides
local reservedSpace = ____layout_0.reservedSpace
local legendGap = ____layout_0.legendGap
local rowRoom = reservedSpace.rowHeaders
local columnRoom = reservedSpace.columnHeaders
repeat
local ____switch3 = sides.legend
local ____cond3 = ____switch3 == "top"
if ____cond3 then
do
local edge = grid.y - (sides.columns == "top" and columnRoom or 0)
return {
x = grid.x,
y = edge - legendGap - BAR_THICKNESS,
width = grid.width,
height = BAR_THICKNESS,
vertical = false,
numbers = "top"
}
end
end
____cond3 = ____cond3 or ____switch3 == "left"
if ____cond3 then
do
local edge = grid.x - (sides.rows == "left" and rowRoom or 0)
return {
x = edge - legendGap - BAR_THICKNESS,
y = grid.y,
width = BAR_THICKNESS,
height = grid.height,
vertical = true,
numbers = "left"
}
end
end
____cond3 = ____cond3 or ____switch3 == "right"
if ____cond3 then
do
local edge = grid.x + grid.width + (sides.rows == "right" and rowRoom or 0)
return {
x = edge + legendGap,
y = grid.y,
width = BAR_THICKNESS,
height = grid.height,
vertical = true,
numbers = "right"
}
end
end
do
do
local edge = grid.y + grid.height + (sides.columns == "bottom" and columnRoom or 0)
return {
x = grid.x,
y = edge + legendGap,
width = grid.width,
height = BAR_THICKNESS,
vertical = false,
numbers = "bottom"
}
end
end
until true
end
function ____exports.renderHeatmapLegend(self, context, layout)
if layout.reservedSpace.legend <= 0 or #layout.zones == 0 then
return {}
end
local place = barPlace(nil, layout)
local barBounds = boxBounds(nil, {x = place.x, y = place.y, width = place.width, height = place.height})
return {
createGradientBar(
nil,
context,
layout,
place,
barBounds
),
table.unpack(createBoundaryTicks(nil, context, layout, place))
}
end
return ____exports
end,
["core.renderScene.charts.renderers.heatmap"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____cells = require("core.renderScene.charts.renderers.heatmap.cells")
local renderHeatmapCells = ____cells.renderHeatmapCells
local ____headers = require("core.renderScene.charts.renderers.heatmap.headers")
local renderHeatmapHeaders = ____headers.renderHeatmapHeaders
local ____layout = require("core.renderScene.charts.renderers.heatmap.layout")
local createHeatmapLayout = ____layout.createHeatmapLayout
local ____legend = require("core.renderScene.charts.renderers.heatmap.legend")
local renderHeatmapLegend = ____legend.renderHeatmapLegend
function ____exports.renderHeatmap(self, context)
local layout = createHeatmapLayout(nil, context)
local nodes = {}
__TS__ArrayPushArray(
nodes,
renderHeatmapCells(nil, context, layout)
)
__TS__ArrayPushArray(
nodes,
renderHeatmapHeaders(nil, context, layout)
)
__TS__ArrayPushArray(
nodes,
renderHeatmapLegend(nil, context, layout)
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.geometry.hexbin"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Spread = ____lualib.__TS__Spread
local ____exports = {}
function ____exports.computeHexBins(self, points, radius)
if radius <= 0 or #points == 0 then
return {}
end
local dx = radius * 1.5
local dy = radius * math.sqrt(3)
local bins = __TS__New(Map)
for ____, ____value in ipairs(points) do
local x = ____value.x
local y = ____value.y
local col = math.floor(x / dx + 0.5)
local rowOffset = col % 2 ~= 0 and dy / 2 or 0
local row = math.floor((y - rowOffset) / dy + 0.5)
local key = (tostring(col) .. ":") .. tostring(row)
local existing = bins:get(key)
if existing then
existing.count = existing.count + 1
else
bins:set(key, {cx = col * dx, cy = row * dy + rowOffset, count = 1})
end
end
return {__TS__Spread(bins:values())}
end
return ____exports
end,
["core.renderScene.charts.geometry.sankey.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.geometry.sankey.columns"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Iterator = ____lualib.__TS__Iterator
local Set = ____lualib.Set
local ____exports = {}
function ____exports.assignSankeyColumns(self, graph)
local columns = __TS__New(Map)
for ____, id in __TS__Iterator(graph.ids) do
columns:set(id, 0)
end
do
local pass = 0
while pass < graph.ids.size do
local changed = false
for ____, link in ipairs(graph.links) do
local candidate = (columns:get(link.source) or 0) + 1
if candidate > (columns:get(link.target) or 0) then
columns:set(link.target, candidate)
changed = true
end
end
if not changed then
break
end
pass = pass + 1
end
end
return columns
end
function ____exports.groupSankeyColumns(self, ids, columns)
local groups = __TS__New(Map)
for ____, id in __TS__Iterator(ids) do
local column = columns:get(id) or 0
local group = groups:get(column) or ({})
group[#group + 1] = id
groups:set(column, group)
end
return groups
end
return ____exports
end,
["core.renderScene.charts.geometry.sankey.constants"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.SANKEY_NODE_WIDTH = 18
____exports.SANKEY_NODE_GAP = 8
return ____exports
end,
["core.renderScene.charts.geometry.sankey.graph"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__New = ____lualib.__TS__New
local Map = ____lualib.Map
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local ____exports = {}
function ____exports.createSankeyGraph(self, nodes, links)
local ids = __TS__New(
Set,
__TS__ArrayMap(
nodes,
function(____, node) return node.id end
)
)
for ____, link in ipairs(links) do
ids:add(link.source)
ids:add(link.target)
end
local incoming = __TS__New(Map)
local outgoing = __TS__New(Map)
for ____, id in __TS__Iterator(ids) do
incoming:set(id, {})
outgoing:set(id, {})
end
local validLinks = __TS__ArrayFilter(
links,
function(____, link) return ids:has(link.source) and ids:has(link.target) and link.value > 0 and link.source ~= link.target end
)
for ____, link in ipairs(validLinks) do
local ____opt_0 = outgoing:get(link.source)
if ____opt_0 ~= nil then
local ____temp_1 = outgoing:get(link.source)
____temp_1[#____temp_1 + 1] = link
end
local ____opt_3 = incoming:get(link.target)
if ____opt_3 ~= nil then
local ____temp_4 = incoming:get(link.target)
____temp_4[#____temp_4 + 1] = link
end
end
return {ids = ids, links = validLinks, incoming = incoming, outgoing = outgoing}
end
return ____exports
end,
["core.renderScene.charts.geometry.sankey.nodeGeometry"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
local ____columns = require("core.renderScene.charts.geometry.sankey.columns")
local groupSankeyColumns = ____columns.groupSankeyColumns
local ____constants = require("core.renderScene.charts.geometry.sankey.constants")
local SANKEY_NODE_GAP = ____constants.SANKEY_NODE_GAP
local SANKEY_NODE_WIDTH = ____constants.SANKEY_NODE_WIDTH
local function nodeValues(self, graph)
local values = __TS__New(Map)
for ____, id in __TS__Iterator(graph.ids) do
local inflow = __TS__ArrayReduce(
graph.incoming:get(id) or ({}),
function(____, sum, link) return sum + link.value end,
0
)
local outflow = __TS__ArrayReduce(
graph.outgoing:get(id) or ({}),
function(____, sum, link) return sum + link.value end,
0
)
values:set(
id,
math.max(inflow, outflow, 0.0001)
)
end
return values
end
local function calculateValueScale(self, groups, values, height, nodeGap)
local scale = math.huge
for ____, ids in __TS__Iterator(groups:values()) do
local total = __TS__ArrayReduce(
ids,
function(____, sum, id) return sum + (values:get(id) or 0) end,
0
)
local gaps = math.max(0, #ids - 1) * nodeGap
local usable = math.max(1, height - gaps)
if total > 0 then
scale = math.min(scale, usable / total)
end
end
if not __isFinite(nil, scale) or scale <= 0 then
return 1
end
return scale
end
function ____exports.sankeyNodeX(self, column, columnCount, width, nodeWidth)
if nodeWidth == nil then
nodeWidth = SANKEY_NODE_WIDTH
end
if columnCount <= 1 then
return 0
end
return column * (width - nodeWidth) / (columnCount - 1)
end
function ____exports.calculateNodeGeometry(self, graph, columns, height, nodeGap)
if nodeGap == nil then
nodeGap = SANKEY_NODE_GAP
end
local groups = groupSankeyColumns(nil, graph.ids, columns)
local values = nodeValues(nil, graph)
local valueScale = calculateValueScale(
nil,
groups,
values,
height,
nodeGap
)
local y = __TS__New(Map)
local heights = __TS__New(Map)
for ____, ids in __TS__Iterator(groups:values()) do
local cursor = 0
for ____, id in ipairs(ids) do
local nodeHeight = math.max(
2,
(values:get(id) or 0) * valueScale
)
y:set(id, cursor)
heights:set(id, nodeHeight)
cursor = cursor + (nodeHeight + nodeGap)
end
end
return {
columns = columns,
y = y,
heights = heights,
valueScale = valueScale,
columnCount = math.max(
1,
table.unpack(__TS__ArrayMap(
{__TS__Spread(columns:values())},
function(____, column) return column + 1 end
))
)
}
end
return ____exports
end,
["core.renderScene.charts.geometry.sankey.links"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____constants = require("core.renderScene.charts.geometry.sankey.constants")
local SANKEY_NODE_WIDTH = ____constants.SANKEY_NODE_WIDTH
local ____nodeGeometry = require("core.renderScene.charts.geometry.sankey.nodeGeometry")
local sankeyNodeX = ____nodeGeometry.sankeyNodeX
function ____exports.layoutSankeyLinks(self, graph, geometry, width, offsets, nodeWidth)
if nodeWidth == nil then
nodeWidth = SANKEY_NODE_WIDTH
end
local outgoingOffsets = __TS__New(Map)
local incomingOffsets = __TS__New(Map)
for ____, id in __TS__Iterator(graph.ids) do
outgoingOffsets:set(id, 0)
incomingOffsets:set(id, 0)
end
return __TS__ArrayMap(
graph.links,
function(____, link)
local sliceHeight = math.max(0.5, link.value * geometry.valueScale)
local sourceOffset = offsets:get(link.source)
local targetOffset = offsets:get(link.target)
local sourceTop = (geometry.y:get(link.source) or 0) + (sourceOffset and sourceOffset.y or 0)
local targetTop = (geometry.y:get(link.target) or 0) + (targetOffset and targetOffset.y or 0)
local sourceSlice = outgoingOffsets:get(link.source) or 0
local targetSlice = incomingOffsets:get(link.target) or 0
outgoingOffsets:set(link.source, sourceSlice + sliceHeight)
incomingOffsets:set(link.target, targetSlice + sliceHeight)
return {
source = link.source,
target = link.target,
value = link.value,
color = link.color,
x0 = sankeyNodeX(
nil,
geometry.columns:get(link.source) or 0,
geometry.columnCount,
width,
nodeWidth
) + nodeWidth + (sourceOffset and sourceOffset.x or 0),
x1 = sankeyNodeX(
nil,
geometry.columns:get(link.target) or 0,
geometry.columnCount,
width,
nodeWidth
) + (targetOffset and targetOffset.x or 0),
sourceY0 = sourceTop + sourceSlice,
sourceY1 = sourceTop + sourceSlice + sliceHeight,
targetY0 = targetTop + targetSlice,
targetY1 = targetTop + targetSlice + sliceHeight
}
end
)
end
return ____exports
end,
["core.renderScene.charts.geometry.sankey.nodes"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____constants = require("core.renderScene.charts.geometry.sankey.constants")
local SANKEY_NODE_WIDTH = ____constants.SANKEY_NODE_WIDTH
local ____nodeGeometry = require("core.renderScene.charts.geometry.sankey.nodeGeometry")
local sankeyNodeX = ____nodeGeometry.sankeyNodeX
function ____exports.layoutSankeyNodes(self, inputs, graph, geometry, width, offsets, nodeWidth)
if nodeWidth == nil then
nodeWidth = SANKEY_NODE_WIDTH
end
return __TS__ArrayMap(
{__TS__Spread(graph.ids)},
function(____, id)
local input = __TS__ArrayFind(
inputs,
function(____, node) return node.id == id end
)
local column = geometry.columns:get(id) or 0
local offset = offsets:get(id)
return {
id = id,
label = input and input.label or id,
color = input and input.color,
x = sankeyNodeX(
nil,
column,
geometry.columnCount,
width,
nodeWidth
) + (offset and offset.x or 0),
y = (geometry.y:get(id) or 0) + (offset and offset.y or 0),
width = nodeWidth,
height = geometry.heights:get(id) or 2,
column = column
}
end
)
end
return ____exports
end,
["core.renderScene.charts.geometry.sankey.layout"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____columns = require("core.renderScene.charts.geometry.sankey.columns")
local assignSankeyColumns = ____columns.assignSankeyColumns
local ____constants = require("core.renderScene.charts.geometry.sankey.constants")
local SANKEY_NODE_GAP = ____constants.SANKEY_NODE_GAP
local SANKEY_NODE_WIDTH = ____constants.SANKEY_NODE_WIDTH
local ____graph = require("core.renderScene.charts.geometry.sankey.graph")
local createSankeyGraph = ____graph.createSankeyGraph
local ____links = require("core.renderScene.charts.geometry.sankey.links")
local layoutSankeyLinks = ____links.layoutSankeyLinks
local ____nodeGeometry = require("core.renderScene.charts.geometry.sankey.nodeGeometry")
local calculateNodeGeometry = ____nodeGeometry.calculateNodeGeometry
local ____nodes = require("core.renderScene.charts.geometry.sankey.nodes")
local layoutSankeyNodes = ____nodes.layoutSankeyNodes
local function collectOffsets(self, inputs)
local offsets = __TS__New(Map)
for ____, input in ipairs(inputs) do
if __t(nil, input.offsetX) or __t(nil, input.offsetY) then
offsets:set(input.id, {x = input.offsetX or 0, y = input.offsetY or 0})
end
end
return offsets
end
function ____exports.layoutSankey(self, nodeInputs, linkInputs, width, height, options)
if options == nil then
options = {nodeWidth = SANKEY_NODE_WIDTH, nodeGap = SANKEY_NODE_GAP}
end
local graph = createSankeyGraph(nil, nodeInputs, linkInputs)
if graph.ids.size == 0 then
return {nodes = {}, links = {}}
end
local columns = assignSankeyColumns(nil, graph)
local geometry = calculateNodeGeometry(
nil,
graph,
columns,
height,
options.nodeGap
)
local offsets = collectOffsets(nil, nodeInputs)
return {
nodes = layoutSankeyNodes(
nil,
nodeInputs,
graph,
geometry,
width,
offsets,
options.nodeWidth
),
links = layoutSankeyLinks(
nil,
graph,
geometry,
width,
offsets,
options.nodeWidth
)
}
end
return ____exports
end,
["core.renderScene.charts.geometry.sankey.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____layout = require("core.renderScene.charts.geometry.sankey.layout")
____exports.layoutSankey = ____layout.layoutSankey
end
return ____exports
end,
["core.renderScene.charts.geometry.treemap"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local sizeTreemapItems, selectTreemapRow, worstAspectRatio, placeTreemapRow, placeVerticalTreemapRow, placeHorizontalTreemapRow
local ______shims = require("core.__shims")
local __sort = ______shims.__sort
local __t = ______shims.__t
function sizeTreemapItems(self, items, bounds)
local positiveItems = __TS__ArrayFilter(
items,
function(____, item) return item.value > 0 end
)
if not __t(nil, #positiveItems) or bounds.width <= 0 or bounds.height <= 0 then
return {}
end
local total = __TS__ArrayReduce(
positiveItems,
function(____, sum, item) return sum + item.value end,
0
)
if total <= 0 then
return {}
end
local areaScale = bounds.width * bounds.height / total
return __TS__ArrayMap(
__sort(
nil,
{table.unpack(positiveItems)},
function(____, left, right) return right.value - left.value end
),
function(____, item) return {item = item, area = item.value * areaScale} end
)
end
function selectTreemapRow(self, items, availableLength)
local rowItems = {items[1]}
do
local index = 1
while index < #items do
local ____array_0 = __TS__SparseArrayNew(table.unpack(rowItems))
__TS__SparseArrayPush(____array_0, items[index + 1])
local candidateItems = {__TS__SparseArraySpread(____array_0)}
if worstAspectRatio(nil, candidateItems, availableLength) > worstAspectRatio(nil, rowItems, availableLength) then
break
end
rowItems[#rowItems + 1] = items[index + 1]
index = index + 1
end
end
return {
items = rowItems,
area = __TS__ArrayReduce(
rowItems,
function(____, sum, item) return sum + item.area end,
0
)
}
end
function worstAspectRatio(self, items, availableLength)
local area = __TS__ArrayReduce(
items,
function(____, sum, item) return sum + item.area end,
0
)
if area <= 0 or availableLength <= 0 then
return math.huge
end
local areas = __TS__ArrayMap(
items,
function(____, item) return item.area end
)
local largestArea = math.max(table.unpack(areas))
local smallestArea = math.min(table.unpack(areas))
local squaredLength = availableLength * availableLength
return math.max(squaredLength * largestArea / (area * area), area * area / (squaredLength * smallestArea))
end
function placeTreemapRow(self, row, bounds)
return bounds.width >= bounds.height and placeVerticalTreemapRow(nil, row, bounds) or placeHorizontalTreemapRow(nil, row, bounds)
end
function placeVerticalTreemapRow(self, row, bounds)
local columnWidth = bounds.height > 0 and row.area / bounds.height or 0
local y = bounds.y
local rectangles = __TS__ArrayMap(
row.items,
function(____, ____bindingPattern0)
local area
local item
item = ____bindingPattern0.item
area = ____bindingPattern0.area
local height = columnWidth > 0 and area / columnWidth or 0
local rectangle = {
item = item,
x = bounds.x,
y = y,
width = columnWidth,
height = height
}
y = y + height
return rectangle
end
)
return {rectangles = rectangles, remainingBounds = {x = bounds.x + columnWidth, y = bounds.y, width = bounds.width - columnWidth, height = bounds.height}}
end
function placeHorizontalTreemapRow(self, row, bounds)
local rowHeight = bounds.width > 0 and row.area / bounds.width or 0
local x = bounds.x
local rectangles = __TS__ArrayMap(
row.items,
function(____, ____bindingPattern0)
local area
local item
item = ____bindingPattern0.item
area = ____bindingPattern0.area
local width = rowHeight > 0 and area / rowHeight or 0
local rectangle = {
item = item,
x = x,
y = bounds.y,
width = width,
height = rowHeight
}
x = x + width
return rectangle
end
)
return {rectangles = rectangles, remainingBounds = {x = bounds.x, y = bounds.y + rowHeight, width = bounds.width, height = bounds.height - rowHeight}}
end
function ____exports.squarifyTreemap(self, items, bounds)
local remainingItems = sizeTreemapItems(nil, items, bounds)
if not __t(nil, #remainingItems) then
return {}
end
local rectangles = {}
local remaining = remainingItems
local remainingBounds = bounds
while __t(nil, #remaining) do
local row = selectTreemapRow(
nil,
remaining,
math.min(remainingBounds.width, remainingBounds.height)
)
local placement = placeTreemapRow(nil, row, remainingBounds)
__TS__ArrayPushArray(rectangles, placement.rectangles)
remaining = __TS__ArraySlice(remaining, #row.items)
remainingBounds = placement.remainingBounds
end
return rectangles
end
return ____exports
end,
["core.renderScene.charts.geometry.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____hexbin = require("core.renderScene.charts.geometry.hexbin")
____exports.computeHexBins = ____hexbin.computeHexBins
end
do
local ____sankey = require("core.renderScene.charts.geometry.sankey.index")
____exports.layoutSankey = ____sankey.layoutSankey
end
do
local ____treemap = require("core.renderScene.charts.geometry.treemap")
____exports.squarifyTreemap = ____treemap.squarifyTreemap
end
return ____exports
end,
["core.renderScene.charts.renderers.hexbin"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____colorRamp = require("core.renderScene.charts.field.colorRamp")
local colorAtRamp = ____colorRamp.colorAtRamp
local ____geometry = require("core.renderScene.charts.geometry.index")
local computeHexBins = ____geometry.computeHexBins
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local DEFAULT_HEX_RADIUS = ____primitives.DEFAULT_HEX_RADIUS
local mapChartValue = ____primitives.mapChartValue
local resolveChartShadow = ____primitives.resolveChartShadow
local DEFAULT_MIN_OPACITY = 0.15
local GAP_TO_RADIUS = 1 / math.sqrt(3)
local function hexPath(self, cx, cy, radius)
local points = {}
do
local corner = 0
while corner < 6 do
local angle = (-60 + 60 * corner) * math.pi / 180
points[#points + 1] = ((((corner == 0 and "M" or "L") .. " ") .. tostring(cx + radius * math.cos(angle))) .. " ") .. tostring(cy + radius * math.sin(angle))
corner = corner + 1
end
end
return table.concat(points, " ") .. " Z"
end
function ____exports.renderHexbin(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local bounds = ____context_0.bounds
local diagnostics = ____context_0.diagnostics
local nextOrder = ____context_0.nextOrder
local nodes = {}
local config = chart.config
local hexRadius = math.max(1, config and config.hexRadius or DEFAULT_HEX_RADIUS)
local drawRadius = math.max(
0.5,
hexRadius - math.max(0, config and config.hexGap or 0) * GAP_TO_RADIUS
)
local strokeWidth = config and config.hexStrokeWidth or 0
local minOpacity = math.min(
1,
math.max(0, config and config.hexMinOpacity or DEFAULT_MIN_OPACITY)
)
local shadow = resolveChartShadow(nil, chart.shadowStyle)
local clipPath = shadow and ((((((((("M " .. tostring(plot.x)) .. " ") .. tostring(plot.y)) .. " H ") .. tostring(plot.x + plot.width)) .. " V ") .. tostring(plot.y + plot.height)) .. " H ") .. tostring(plot.x)) .. " Z" or nil
__TS__ArrayForEach(
chart.series,
function(____, series, seriesIndex)
local explicit = #series.values > 0 and __TS__ArrayIsArray(series.values[1])
local ____pairs = explicit and series.values or __TS__ArrayMap(
series.values,
function(____, y, i) return {chart.axisX.min + i * chart.axisX.step, y} end
)
local pixelPoints = __TS__ArrayMap(
____pairs,
function(____, ____bindingPattern0)
local vy
local vx
vx = ____bindingPattern0[1]
vy = ____bindingPattern0[2]
return {
x = mapChartValue(nil, vx, chart.axisX, plot.width),
y = plot.height - mapChartValue(nil, vy, chart.axisY, plot.height)
}
end
)
local bins = computeHexBins(nil, pixelPoints, hexRadius)
local maxCount = math.max(
1,
table.unpack(__TS__ArrayMap(
bins,
function(____, bin) return bin.count end
))
)
local color = series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1]
local ramp = config and config.scale
__TS__ArrayForEach(
bins,
function(____, bin, i)
local share = bin.count / maxCount
local fill = ramp and colorAtRamp(nil, ramp, share) or color
local ____temp_17 = (((("chart-hexbin-" .. chart.id) .. "-") .. series.id) .. "-") .. tostring(i)
local ____nextOrder_result_18 = nextOrder(nil)
local ____bounds_19 = bounds
local ____hexPath_result_20 = hexPath(nil, plot.x + bin.cx, plot.y + bin.cy, drawRadius)
local ____paint_result_14 = paint(nil, fill, diagnostics, chart.id)
local ____temp_15 = strokeWidth > 0 and paint(nil, config and config.hexStrokeColor or fill, diagnostics, chart.id) or nil
local ____temp_16 = strokeWidth > 0 and strokeWidth or nil
local ____ramp_13
if ramp then
____ramp_13 = nil
else
____ramp_13 = math.max(minOpacity, share)
end
nodes[#nodes + 1] = {
type = "path",
id = ____temp_17,
order = ____nextOrder_result_18,
bounds = ____bounds_19,
d = ____hexPath_result_20,
style = {
fill = ____paint_result_14,
stroke = ____temp_15,
strokeWidth = ____temp_16,
opacity = ____ramp_13,
shadow = shadow,
clip = __t(nil, clipPath) and ({type = "path", d = clipPath}) or nil
}
}
end
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.cartesianPoints"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____primitives = require("core.renderScene.charts.primitives.index")
local mapChartValue = ____primitives.mapChartValue
function ____exports.seriesValuePairs(self, chart, series)
if #series.values > 0 and __TS__ArrayIsArray(series.values[1]) then
return series.values
end
return __TS__ArrayMap(
series.values,
function(____, value, index) return {chart.axisX.min + index * chart.axisX.step, value} end
)
end
function ____exports.pixelPoints(self, context, ____pairs)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
return __TS__ArrayMap(
____pairs,
function(____, ____bindingPattern0)
local y
local x
x = ____bindingPattern0[1]
y = ____bindingPattern0[2]
return {
x = plot.x + mapChartValue(nil, x, chart.axisX, plot.width),
y = plot.y + plot.height - mapChartValue(nil, y, chart.axisY, plot.height)
}
end
)
end
return ____exports
end,
["core.renderScene.charts.renderers.line.area"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ____color = require("core.renderScene.color")
local colorWithAlpha = ____color.colorWithAlpha
local ____linePath = require("core.renderScene.charts.primitives.linePath")
local linePathData = ____linePath.linePathData
function ____exports.createLineAreaFill(self, context, series, points, color, tension, areaOpacity)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local nextOrder = ____context_0.nextOrder
local baselineY = plot.y + plot.height
local first = points[1]
local last = points[#points]
local d = ((((((((linePathData(nil, points, tension) .. " L ") .. tostring(last.x)) .. " ") .. tostring(baselineY)) .. " L ") .. tostring(first.x)) .. " ") .. tostring(baselineY)) .. " Z"
local top = math.min(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.y end
)))
local centerX = (math.min(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.x end
))) + math.max(table.unpack(__TS__ArrayMap(
points,
function(____, point) return point.x end
)))) / 2
local halfHeight = (baselineY - top) / 2
local fillBounds = {minX = centerX - halfHeight, maxX = centerX + halfHeight, minY = top, maxY = baselineY}
return {
type = "path",
id = (("chart-line-area-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil),
bounds = fillBounds,
d = d,
detail = {of = "chartSeries", series = series.id},
style = {
fill = {
kind = "linear-gradient",
angle = 90,
stops = {
{
offset = 0,
color = colorWithAlpha(nil, color, areaOpacity)
},
{
offset = 100,
color = colorWithAlpha(nil, color, 0)
}
}
},
stroke = {kind = "none"},
pointerEvents = "none"
}
}
end
return ____exports
end,
["core.renderScene.charts.renderers.line.highlights"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__StringReplace = ____lualib.__TS__StringReplace
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local ____cartesianPoints = require("core.renderScene.charts.renderers.cartesianPoints")
local pixelPoints = ____cartesianPoints.pixelPoints
local seriesValuePairs = ____cartesianPoints.seriesValuePairs
local function formatHighlight(self, template, category, value)
return __TS__StringReplace(
__TS__StringReplace(
__lor(
nil,
template,
function() return "{value}" end
),
"{category}",
category
),
"{value}",
tostring(math.floor(value * 100 + 0.5) / 100)
)
end
local function guideNode(self, context, mark)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local bounds = ____context_0.bounds
local diagnostics = ____context_0.diagnostics
local nextOrder = ____context_0.nextOrder
return {
type = "path",
id = "chart-highlight-guide-" .. mark.key,
order = nextOrder(nil),
bounds = bounds,
d = (((("M " .. tostring(mark.point.x)) .. " ") .. tostring(mark.point.y)) .. " V ") .. tostring(plot.y + plot.height),
style = {
fill = {kind = "none"},
stroke = paint(nil, mark.color, diagnostics, chart.id),
strokeWidth = 1,
dash = {3, 4},
opacity = 0.55,
pointerEvents = "none"
}
}
end
local function dotNode(self, context, mark)
local ____context_1 = context
local chart = ____context_1.chart
local bounds = ____context_1.bounds
local diagnostics = ____context_1.diagnostics
local nextOrder = ____context_1.nextOrder
local ____opt_2 = chart.config
local glow = ____opt_2 and ____opt_2.lineGlow
return {
type = "ellipse",
id = "chart-highlight-" .. mark.key,
order = nextOrder(nil),
bounds = bounds,
cx = mark.point.x,
cy = mark.point.y,
rx = mark.radius,
ry = mark.radius,
style = {
fill = paint(nil, mark.color, diagnostics, chart.id),
shadow = __t(nil, glow) and ({
color = mark.color,
opacity = 0.9,
blur = glow,
dx = 0,
dy = 0
}) or nil,
pointerEvents = "none"
}
}
end
local function labelNode(self, context, mark, value)
local ____context_4 = context
local chart = ____context_4.chart
local bounds = ____context_4.bounds
local nextOrder = ____context_4.nextOrder
local config = chart.config
local fontSize = math.max(9, chart.fontSize or 12)
local ____formatHighlight_12 = formatHighlight
local ____temp_11 = config and config.highlightLabelFormat
local ____opt_7 = config and config.categories
local text = ____formatHighlight_12(nil, ____temp_11, ____opt_7 and ____opt_7[mark.index + 1] or "", value)
local width = math.max(48, #text * fontSize * 0.62)
return __TS__ObjectAssign(
{},
chartText(
nil,
{
id = "chart-highlight-label-" .. mark.key,
order = nextOrder(nil),
bounds = bounds,
frame = {x = mark.point.x - width / 2, y = mark.point.y - mark.radius - 6 - fontSize * 1.2, width = width, height = fontSize * 1.2},
text = text,
chart = chart,
align = "center"
}
),
{color = config and config.highlightLabelColor or chart.textColor or "#0f172a", fontWeight = "bold"}
)
end
function ____exports.renderLineHighlights(self, context, series, color)
local ____context_15 = context
local chart = ____context_15.chart
local config = chart.config
local wanted = config and config.highlightPoints
if not __t(nil, wanted and #wanted) then
return {}
end
local ____pairs = seriesValuePairs(nil, chart, series)
local points = pixelPoints(nil, context, ____pairs)
local nodes = {}
for ____, wantedIndex in ipairs(wanted) do
do
local index = wantedIndex < 0 and #points + wantedIndex or wantedIndex
local point = points[index + 1]
if not point then
goto __continue9
end
local mark = {
key = (((chart.id .. "-") .. series.id) .. "-") .. tostring(index),
point = point,
index = index,
radius = config and config.highlightSize or 6,
color = config and config.highlightColor or color
}
if config and config.highlightGuide then
nodes[#nodes + 1] = guideNode(nil, context, mark)
end
nodes[#nodes + 1] = dotNode(nil, context, mark)
if config and config.highlightLabels then
nodes[#nodes + 1] = labelNode(nil, context, mark, ____pairs[index + 1][2])
end
end
::__continue9::
end
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.line.marks"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local renderLinePointMark, createLineError, createLinePoint
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local createVerticalErrorWhiskerNode = ____primitives.createVerticalErrorWhiskerNode
local errorBarRange = ____primitives.errorBarRange
local mapChartValue = ____primitives.mapChartValue
function renderLinePointMark(self, context, mark)
local nodes = {}
local errorNode = createLineError(nil, context, mark)
if errorNode then
nodes[#nodes + 1] = errorNode
end
nodes[#nodes + 1] = createLinePoint(nil, context, mark)
return nodes
end
function createLineError(self, context, mark)
if mark.error == nil then
return nil
end
local ____context_5 = context
local chart = ____context_5.chart
local plot = ____context_5.plot
local bounds = ____context_5.bounds
local nextOrder = ____context_5.nextOrder
local lower, upper = table.unpack(
errorBarRange(nil, mark.value, mark.error),
1,
2
)
return createVerticalErrorWhiskerNode(
nil,
{
id = (((("chart-line-error-" .. chart.id) .. "-") .. mark.seriesId) .. "-") .. tostring(mark.valueIndex),
order = nextOrder(nil),
bounds = bounds,
geometry = {
centerX = mark.position.x,
startY = plot.y + plot.height - mapChartValue(nil, lower, chart.axisY, plot.height),
endY = plot.y + plot.height - mapChartValue(nil, upper, chart.axisY, plot.height)
},
color = mark.color,
valueReference = {seriesId = mark.seriesId, valueIndex = mark.valueIndex}
}
)
end
function createLinePoint(self, context, mark)
local ____context_6 = context
local chart = ____context_6.chart
local bounds = ____context_6.bounds
local diagnostics = ____context_6.diagnostics
local nextOrder = ____context_6.nextOrder
local config = chart.config
local radius = config and config.pointSize or 3
local strokeWidth = config and config.pointStrokeWidth or 0
local visible = radius > 0
local fill = __t(nil, config and config.pointFill) and config.pointFill ~= "series" and config.pointFill or mark.color
local ____temp_17 = (((("chart-point-" .. chart.id) .. "-") .. mark.seriesId) .. "-") .. tostring(mark.valueIndex)
local ____nextOrder_result_18 = nextOrder(nil)
local ____bounds_19 = bounds
local ____mark_position_x_20 = mark.position.x
local ____mark_position_y_21 = mark.position.y
local ____temp_22 = visible and radius or 6
local ____temp_23 = visible and radius or 6
local ____temp_24 = {of = "chartValue", series = mark.seriesId, valueIndex = mark.valueIndex}
local ____temp_14 = visible and paint(nil, fill, diagnostics, chart.id) or ({kind = "none"})
local ____temp_15 = visible and strokeWidth > 0 and paint(nil, mark.color, diagnostics, chart.id) or nil
local ____temp_16 = visible and strokeWidth > 0 and strokeWidth or nil
local ____visible_13
if visible then
____visible_13 = nil
else
____visible_13 = "all"
end
return {
type = "ellipse",
id = ____temp_17,
order = ____nextOrder_result_18,
bounds = ____bounds_19,
cx = ____mark_position_x_20,
cy = ____mark_position_y_21,
rx = ____temp_22,
ry = ____temp_23,
detail = ____temp_24,
style = {fill = ____temp_14, stroke = ____temp_15, strokeWidth = ____temp_16, pointerEvents = ____visible_13}
}
end
function ____exports.createLinePointMarks(self, series, ____pairs, points, color)
return __TS__ArrayMap(
points,
function(____, position, valueIndex)
local ____series_id_2 = series.id
local ____valueIndex_3 = valueIndex
local ____pairs_index__2_4 = ____pairs[valueIndex + 1][2]
local ____opt_0 = series.error
return {
seriesId = ____series_id_2,
valueIndex = ____valueIndex_3,
value = ____pairs_index__2_4,
error = ____opt_0 and ____opt_0[valueIndex + 1],
position = position,
color = color
}
end
)
end
function ____exports.renderLineMarks(self, context, marks)
return __TS__ArrayFlatMap(
marks,
function(____, mark) return renderLinePointMark(nil, context, mark) end
)
end
return ____exports
end,
["core.renderScene.charts.renderers.line.path"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local resolveChartShadow = ____primitives.resolveChartShadow
local ____linePath = require("core.renderScene.charts.primitives.linePath")
local linePathData = ____linePath.linePathData
function ____exports.createLinePath(self, context, series, points, color, tension)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local bounds = ____context_0.bounds
local diagnostics = ____context_0.diagnostics
local nextOrder = ____context_0.nextOrder
local config = chart.config
local source = series.color
local gradient = __t(nil, source) and type(source) ~= "string" and source.type == "gradient" and source or nil
local glow = config and config.lineGlow
local ____temp_12 = (("chart-line-" .. chart.id) .. "-") .. series.id
local ____nextOrder_result_13 = nextOrder(nil)
local ____temp_14 = gradient and ({minX = plot.x, maxX = plot.x + plot.width, minY = plot.y, maxY = plot.y + plot.height}) or bounds
local ____temp_15 = {
of = "chartSeries",
series = series.id,
lineTension = __lor(
nil,
tension,
function() return nil end
)
}
local ____linePathData_result_16 = linePathData(nil, points, tension)
local ____temp_8 = {kind = "none"}
local ____paint_result_9 = paint(nil, gradient or color, diagnostics, chart.id)
local ____temp_10 = series.strokeWidth or config and config.lineWidth or 2
local ____series_dash_11 = series.dash
local ____temp_7
if (config and config.lineWidth) == nil then
____temp_7 = nil
else
____temp_7 = "round"
end
return {
type = "path",
id = ____temp_12,
order = ____nextOrder_result_13,
bounds = ____temp_14,
detail = ____temp_15,
d = ____linePathData_result_16,
style = {
fill = ____temp_8,
stroke = ____paint_result_9,
strokeWidth = ____temp_10,
dash = ____series_dash_11,
lineCap = ____temp_7,
lineJoin = "round",
shadow = __t(nil, glow) and ({
color = color,
opacity = 0.9,
blur = glow,
dx = 0,
dy = 0
}) or resolveChartShadow(nil, chart.shadowStyle)
}
}
end
return ____exports
end,
["core.renderScene.charts.renderers.line.series"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local representativeColor = ____primitives.representativeColor
local ____cartesianPoints = require("core.renderScene.charts.renderers.cartesianPoints")
local pixelPoints = ____cartesianPoints.pixelPoints
local seriesValuePairs = ____cartesianPoints.seriesValuePairs
local ____area = require("core.renderScene.charts.renderers.line.area")
local createLineAreaFill = ____area.createLineAreaFill
local ____highlights = require("core.renderScene.charts.renderers.line.highlights")
local renderLineHighlights = ____highlights.renderLineHighlights
local ____marks = require("core.renderScene.charts.renderers.line.marks")
local createLinePointMarks = ____marks.createLinePointMarks
local renderLineMarks = ____marks.renderLineMarks
local ____path = require("core.renderScene.charts.renderers.line.path")
local createLinePath = ____path.createLinePath
local function seriesColor(self, series, seriesIndex)
return representativeColor(nil, series.color, CHART_COLORS[seriesIndex % #CHART_COLORS + 1])
end
function ____exports.renderLineSeriesArea(self, context, series, seriesIndex)
local ____opt_0 = context.chart.config
local areaOpacity = ____opt_0 and ____opt_0.areaOpacity
if areaOpacity == nil or areaOpacity <= 0 then
return {}
end
local color = seriesColor(nil, series, seriesIndex)
local ____opt_2 = context.chart.config
local tension = ____opt_2 and ____opt_2.lineTension or 0
local points = pixelPoints(
nil,
context,
seriesValuePairs(nil, context.chart, series)
)
return #points > 1 and ({createLineAreaFill(
nil,
context,
series,
points,
color,
tension,
areaOpacity
)}) or ({})
end
function ____exports.renderLineSeries(self, context, series, seriesIndex)
local color = seriesColor(nil, series, seriesIndex)
local ____opt_4 = context.chart.config
local tension = ____opt_4 and ____opt_4.lineTension or 0
local ____pairs = seriesValuePairs(nil, context.chart, series)
local points = pixelPoints(nil, context, ____pairs)
local nodes = {}
if __t(nil, #points) then
nodes[#nodes + 1] = createLinePath(
nil,
context,
series,
points,
color,
tension
)
end
local marks = createLinePointMarks(
nil,
series,
____pairs,
points,
color
)
__TS__ArrayPushArray(
nodes,
renderLineMarks(nil, context, marks)
)
__TS__ArrayPushArray(
nodes,
renderLineHighlights(nil, context, series, color)
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.line"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local ____series = require("core.renderScene.charts.renderers.line.series")
local renderLineSeries = ____series.renderLineSeries
local renderLineSeriesArea = ____series.renderLineSeriesArea
function ____exports.renderLine(self, context)
local nodes = {}
__TS__ArrayForEach(
context.chart.series,
function(____, series, seriesIndex)
__TS__ArrayPushArray(
nodes,
renderLineSeriesArea(nil, context, series, seriesIndex)
)
end
)
__TS__ArrayForEach(
context.chart.series,
function(____, series, seriesIndex)
__TS__ArrayPushArray(
nodes,
renderLineSeries(nil, context, series, seriesIndex)
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.mekko.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.renderers.mekko.grid"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local renderGridLines, renderPercentageLabels, percentageY, PERCENT_TICKS
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
function renderGridLines(self, context, layout)
local ____context_0 = context
local chart = ____context_0.chart
local bounds = ____context_0.bounds
local nextOrder = ____context_0.nextOrder
return __TS__ArrayMap(
PERCENT_TICKS,
function(____, percent)
local y = percentageY(nil, layout, percent)
return {
type = "path",
id = (("chart-mekko-grid-" .. chart.id) .. "-") .. tostring(percent),
order = nextOrder(nil),
bounds = bounds,
d = (((((("M " .. tostring(layout.grid.x)) .. " ") .. tostring(y)) .. " L ") .. tostring(layout.grid.x + layout.grid.width)) .. " ") .. tostring(y),
style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"},
strokeWidth = finite(nil, chart.gridWidth, 1)
}
}
end
)
end
function renderPercentageLabels(self, context, layout)
local ____context_1 = context
local chart = ____context_1.chart
local plot = ____context_1.plot
local bounds = ____context_1.bounds
local nextOrder = ____context_1.nextOrder
return __TS__ArrayMap(
PERCENT_TICKS,
function(____, percent) return __TS__ObjectAssign(
{},
chartText(
nil,
{
id = (("chart-mekko-pct-" .. chart.id) .. "-") .. tostring(percent),
order = nextOrder(nil),
bounds = bounds,
frame = {
x = plot.x,
y = percentageY(nil, layout, percent) - layout.smallFontSize / 2,
width = layout.labelGutterWidth - 6,
height = layout.smallFontSize + 2
},
text = tostring(percent) .. "%",
chart = chart,
align = "right"
}
),
{fontSize = layout.smallFontSize}
) end
)
end
function percentageY(self, layout, percent)
return layout.grid.y + layout.grid.height * (1 - percent / 100)
end
PERCENT_TICKS = {
0,
25,
50,
75,
100
}
function ____exports.renderMekkoGrid(self, context, layout)
local nodes = {}
if context.chart.showGrid ~= false then
__TS__ArrayPushArray(
nodes,
renderGridLines(nil, context, layout)
)
end
if context.showLabels then
__TS__ArrayPushArray(
nodes,
renderPercentageLabels(nil, context, layout)
)
end
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.mekko.labels"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local createTotalLabel, createColumnLabel
local ____textLayout = require("core.renderScene.scene.textLayout")
local wrapText = ____textLayout.wrapText
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
function createTotalLabel(self, context, layout, columnIndex, column)
local ____context_2 = context
local chart = ____context_2.chart
local plot = ____context_2.plot
local bounds = ____context_2.bounds
local nextOrder = ____context_2.nextOrder
return __TS__ObjectAssign(
{},
chartText(
nil,
{
id = (("chart-mekko-total-" .. chart.id) .. "-") .. tostring(columnIndex),
order = nextOrder(nil),
bounds = bounds,
frame = {x = column.x, y = plot.y, width = column.width, height = layout.smallFontSize + 2},
text = tostring(column.total),
chart = chart,
align = "center"
}
),
{fontSize = layout.smallFontSize}
)
end
function createColumnLabel(self, context, layout, columnIndex, column)
local ____context_3 = context
local chart = ____context_3.chart
local bounds = ____context_3.bounds
local nextOrder = ____context_3.nextOrder
local ____column_4 = column
local label = ____column_4.label
local width = ____column_4.width
return __TS__ObjectAssign(
{},
chartText(
nil,
{
id = (("chart-mekko-col-label-" .. chart.id) .. "-") .. tostring(columnIndex),
order = nextOrder(nil),
bounds = bounds,
frame = {x = column.x, y = layout.grid.y + layout.grid.height + 4, width = width, height = layout.smallFontSize * 2 + 4},
text = label,
chart = chart,
align = "center"
}
),
{
lines = wrapText(nil, label, width, layout.smallFontSize),
fontSize = layout.smallFontSize
}
)
end
function ____exports.renderMekkoColumnLabels(self, context, layout, columnIndex, column)
if not context.showLabels then
return {}
end
local columnLabel = createColumnLabel(
nil,
context,
layout,
columnIndex,
column
)
local ____opt_0 = context.chart.config
return (____opt_0 and ____opt_0.showMekkoTotals) == false and ({columnLabel}) or ({
createTotalLabel(
nil,
context,
layout,
columnIndex,
column
),
columnLabel
})
end
return ____exports
end,
["core.renderScene.charts.renderers.mekko.layout"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local mekkoColumnLabels, createMekkoGrid, createMekkoColumns
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
function mekkoColumnLabels(self, context)
local ____context_15 = context
local chart = ____context_15.chart
local ____t_result_27
local ____t_20 = __t
local ____opt_18 = chart.config
local ____opt_16 = ____opt_18 and ____opt_18.categories
if ____t_20(nil, ____opt_16 and #____opt_16) then
____t_result_27 = chart.config.categories
else
local ____opt_25 = chart.series[1]
local ____opt_21 = ____opt_25 and ____opt_25.values
if ____opt_21 ~= nil then
local ____opt_22 = chart.series[1]
____opt_21 = __TS__ArrayMap(
____opt_22 and ____opt_22.values,
function(____, _, index) return tostring(index + 1) end
)
end
____t_result_27 = ____opt_21 or ({})
end
return ____t_result_27
end
function createMekkoGrid(self, context, labelGutterWidth)
local topGutter = context.showLabels and 18 or 0
local bottomGutter = context.showLabels and 32 or 0
return {
x = context.plot.x + labelGutterWidth,
y = context.plot.y + topGutter,
width = math.max(1, context.plot.width - labelGutterWidth),
height = math.max(1, context.plot.height - topGutter - bottomGutter)
}
end
function createMekkoColumns(self, context, grid, labels, columnGap)
local totals = __TS__ArrayMap(
labels,
function(____, _, columnIndex) return __TS__ArrayReduce(
context.chart.series,
function(____, sum, series) return sum + (series.values[columnIndex + 1] or 0) end,
0
) end
)
local grandTotal = __TS__ArrayReduce(
totals,
function(____, sum, total) return sum + total end,
0
)
local maximumTotal = math.max(
1,
table.unpack(totals)
)
local availableWidth = math.max(
1,
grid.width - columnGap * math.max(0, #labels - 1)
)
local nextX = grid.x
return __TS__ArrayMap(
labels,
function(____, label, index)
local total = totals[index + 1]
local width = grandTotal > 0 and total / grandTotal * availableWidth or availableWidth / #labels
local ____opt_28 = context.chart.config
local height = ____opt_28 and ____opt_28.mekkoVaryHeight and grid.height * (total / maximumTotal) or grid.height
local column = {
label = label,
total = total,
x = nextX,
y = grid.y + grid.height - height,
width = width,
height = height
}
nextX = nextX + (width + columnGap)
return column
end
)
end
function ____exports.createMekkoLayout(self, context)
local labels = mekkoColumnLabels(nil, context)
local labelGutterWidth = context.showLabels and 30 or 0
local grid = createMekkoGrid(nil, context, labelGutterWidth)
local fontSize = math.max(
9,
finite(nil, context.chart.fontSize, 12)
)
local ____finite_2 = finite
local ____opt_0 = context.chart.config
local columnGap = math.max(
0,
____finite_2(nil, ____opt_0 and ____opt_0.mekkoColumnGap, 4)
)
local smallFontSize = math.max(8, fontSize - 1)
local ____createMekkoColumns_result_9 = createMekkoColumns(
nil,
context,
grid,
labels,
columnGap
)
local ____fontSize_10 = fontSize
local ____smallFontSize_11 = smallFontSize
local ____labelGutterWidth_12 = labelGutterWidth
local ____columnGap_13 = columnGap
local ____finite_5 = finite
local ____opt_3 = context.chart.config
local ____math_max_result_14 = math.max(
6,
____finite_5(nil, ____opt_3 and ____opt_3.mekkoLabelSize, smallFontSize)
)
local ____finite_8 = finite
local ____opt_6 = context.chart.config
return {
columns = ____createMekkoColumns_result_9,
fontSize = ____fontSize_10,
smallFontSize = ____smallFontSize_11,
labelGutterWidth = ____labelGutterWidth_12,
columnGap = ____columnGap_13,
labelSize = ____math_max_result_14,
valueSize = math.max(
6,
____finite_8(nil, ____opt_6 and ____opt_6.mekkoValueSize, smallFontSize)
),
grid = grid
}
end
return ____exports
end,
["core.renderScene.charts.renderers.mekko.segments"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local createColumnBackdrop, mekkoCornerRadius, calculateColumnSegments, renderSegment, createSegmentNode, createSegmentLabel, BACKDROP_OPACITY
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____textLayout = require("core.renderScene.scene.textLayout")
local ellipsizeToWidth = ____textLayout.ellipsizeToWidth
local wrapText = ____textLayout.wrapText
local ____primitives = require("core.renderScene.charts.primitives.index")
local barPath = ____primitives.barPath
local barShapePath = ____primitives.barShapePath
local CHART_COLORS = ____primitives.CHART_COLORS
local chartText = ____primitives.chartText
local contrastTextColor = ____primitives.contrastTextColor
local representativeColor = ____primitives.representativeColor
local resolveChartShadow = ____primitives.resolveChartShadow
function createColumnBackdrop(self, context, layout, columnIndex)
local ____context_11 = context
local chart = ____context_11.chart
local bounds = ____context_11.bounds
local diagnostics = ____context_11.diagnostics
local nextOrder = ____context_11.nextOrder
local column = layout.columns[columnIndex + 1]
local cornerRadius = mekkoCornerRadius(nil, context)
return {
type = "path",
id = (("chart-mekko-column-backdrop-" .. chart.id) .. "-") .. tostring(columnIndex),
order = nextOrder(nil),
bounds = bounds,
d = barShapePath(
nil,
column.x,
layout.grid.y,
column.width,
layout.grid.height,
cornerRadius
),
style = {
fill = paint(nil, chart.gridColor or "#e2e8f0", diagnostics, chart.id),
opacity = BACKDROP_OPACITY
}
}
end
function mekkoCornerRadius(self, context)
local ____finite_14 = finite
local ____opt_12 = context.chart.config
return math.max(
0,
____finite_14(nil, ____opt_12 and ____opt_12.barCornerRadius, 2)
)
end
function calculateColumnSegments(self, seriesList, layout, columnIndex)
local segments = {}
local column = layout.columns[columnIndex + 1]
local cumulativeHeight = 0
__TS__ArrayForEach(
seriesList,
function(____, series, seriesIndex)
local value = series.values[columnIndex + 1] or 0
local height = (column.total > 0 and value / column.total or 0) * column.height
local y = column.y + cumulativeHeight
cumulativeHeight = cumulativeHeight + height
local color = series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1]
segments[#segments + 1] = {
columnIndex = columnIndex,
seriesId = series.id,
seriesLabel = series.label,
value = value,
color = color,
isTop = seriesIndex == 0,
frame = {x = column.x, y = y, width = column.width, height = height}
}
end
)
return segments
end
function renderSegment(self, context, layout, segment, nextColor)
return {
createSegmentNode(nil, context, segment, nextColor),
table.unpack(createSegmentLabel(nil, context, layout, segment))
}
end
function createSegmentNode(self, context, segment, nextColor)
local ____context_15 = context
local chart = ____context_15.chart
local plot = ____context_15.plot
local bounds = ____context_15.bounds
local diagnostics = ____context_15.diagnostics
local nextOrder = ____context_15.nextOrder
local shadow = resolveChartShadow(nil, chart.shadowStyle)
local clipPath = shadow and ((((((((("M " .. tostring(plot.x)) .. " ") .. tostring(plot.y)) .. " H ") .. tostring(plot.x + plot.width)) .. " V ") .. tostring(plot.y + plot.height)) .. " H ") .. tostring(plot.x)) .. " Z" or nil
local config = chart.config
local radius = (segment.isTop or config and config.mekkoRoundAll) and mekkoCornerRadius(nil, context) or 0
local ____segment_frame_18 = segment.frame
local x = ____segment_frame_18.x
local y = ____segment_frame_18.y
local width = ____segment_frame_18.width
local height = ____segment_frame_18.height
local segmentGap = math.max(
0,
finite(nil, config and config.mekkoSegmentGap, 0)
)
local fallback = "#94a3b8"
local gradientBounds = {minX = x + width / 2 - height / 2, maxX = x + width / 2 + height / 2, minY = y, maxY = y + height}
local fill = __t(nil, nextColor) and ({
kind = "linear-gradient",
angle = 90,
stops = {
{
offset = 0,
color = representativeColor(nil, segment.color, fallback)
},
{
offset = 100,
color = representativeColor(nil, nextColor, fallback)
}
}
}) or paint(nil, segment.color, diagnostics, chart.id)
return {
type = "path",
id = (((("chart-mekko-seg-" .. chart.id) .. "-") .. tostring(segment.columnIndex)) .. "-") .. segment.seriesId,
order = nextOrder(nil),
bounds = __t(nil, nextColor) and gradientBounds or bounds,
d = barPath(
nil,
x,
y + segmentGap / 2,
width,
math.max(0, height - segmentGap),
radius,
Boolean(nil, config and config.mekkoRoundAll)
),
style = {
fill = fill,
stroke = {kind = "solid", color = config and config.mekkoSegmentStrokeColor or chart.gridColor or "#e2e8f0"},
strokeWidth = finite(
nil,
config and config.mekkoSegmentStrokeWidth,
finite(nil, chart.gridWidth, 1)
),
shadow = shadow,
clip = __t(nil, clipPath) and ({type = "path", d = clipPath}) or nil
}
}
end
function createSegmentLabel(self, context, layout, segment)
local ____context_27 = context
local chart = ____context_27.chart
local bounds = ____context_27.bounds
local nextOrder = ____context_27.nextOrder
local ____segment_frame_28 = segment.frame
local x = ____segment_frame_28.x
local y = ____segment_frame_28.y
local width = ____segment_frame_28.width
local height = ____segment_frame_28.height
if not context.showLegend or width < 34 then
return {}
end
local innerWidth = math.max(1, width - 8)
local innerHeight = math.max(1, height - 6)
local lineHeight = layout.labelSize * 1.2
local valueHeight = layout.valueSize * 1.2
local labelLines = __TS__ArrayMap(
wrapText(nil, segment.seriesLabel, innerWidth, layout.labelSize),
function(____, line) return ellipsizeToWidth(
nil,
line,
innerWidth,
layout.labelSize,
true
) end
)
if #labelLines * lineHeight + valueHeight > innerHeight then
return {}
end
local ____opt_29 = chart.config
local textColor = ____opt_29 and ____opt_29.mekkoTextColor or contrastTextColor(
nil,
representativeColor(nil, segment.color, "#ffffff")
)
local ____opt_31 = layout.columns[segment.columnIndex + 1]
local columnTotal = ____opt_31 and ____opt_31.total or 0
local ____opt_33 = chart.config
local valueText = (____opt_33 and ____opt_33.mekkoValueFormat) == "percent" and tostring(columnTotal > 0 and math.floor(segment.value / columnTotal * 100 + 0.5) or 0) .. "%" or tostring(segment.value)
local label = __TS__ObjectAssign(
{},
chartText(
nil,
{
id = (((("chart-mekko-seg-label-" .. chart.id) .. "-") .. tostring(segment.columnIndex)) .. "-") .. segment.seriesId,
order = nextOrder(nil),
bounds = bounds,
frame = {x = x + 4, y = y + 3, width = innerWidth, height = innerHeight},
text = segment.seriesLabel,
chart = chart
}
),
{lines = labelLines, fontSize = layout.labelSize, fontWeight = "bold", color = textColor}
)
local valueNode = __TS__ObjectAssign(
{},
chartText(
nil,
{
id = (((("chart-mekko-seg-value-" .. chart.id) .. "-") .. tostring(segment.columnIndex)) .. "-") .. segment.seriesId,
order = nextOrder(nil),
bounds = bounds,
frame = {
x = x + 4,
y = y + 3 + #labelLines * lineHeight,
width = innerWidth,
height = math.max(1, innerHeight - #labelLines * lineHeight)
},
text = valueText,
chart = chart
}
),
{lines = {valueText}, fontSize = layout.valueSize, color = textColor}
)
return {label, valueNode}
end
BACKDROP_OPACITY = 0.15
function ____exports.renderMekkoColumnSegments(self, context, layout, columnIndex)
local ____opt_0 = context.chart.config
local showBackdrop = (____opt_0 and ____opt_0.showColumnBackdrop) ~= false
local backdrop = showBackdrop and ({createColumnBackdrop(nil, context, layout, columnIndex)}) or ({})
local ____Boolean_4 = Boolean
local ____opt_2 = context.chart.config
local gradientFlow = ____Boolean_4(nil, ____opt_2 and ____opt_2.tileGradient)
local columnSegments = calculateColumnSegments(nil, context.chart.series, layout, columnIndex)
local segments = __TS__ArrayFlatMap(
columnSegments,
function(____, segment, index)
local ____renderSegment_9 = renderSegment
local ____array_8 = __TS__SparseArrayNew(nil, context, layout, segment)
local ____gradientFlow_7
if gradientFlow then
local ____opt_5 = columnSegments[index + 1 + 1]
____gradientFlow_7 = ____opt_5 and ____opt_5.color
else
____gradientFlow_7 = nil
end
__TS__SparseArrayPush(____array_8, ____gradientFlow_7)
return ____renderSegment_9(__TS__SparseArraySpread(____array_8))
end
)
local ____array_10 = __TS__SparseArrayNew(table.unpack(backdrop))
__TS__SparseArrayPush(
____array_10,
table.unpack(segments)
)
return {__TS__SparseArraySpread(____array_10)}
end
return ____exports
end,
["core.renderScene.charts.renderers.mekko"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local ____grid = require("core.renderScene.charts.renderers.mekko.grid")
local renderMekkoGrid = ____grid.renderMekkoGrid
local ____labels = require("core.renderScene.charts.renderers.mekko.labels")
local renderMekkoColumnLabels = ____labels.renderMekkoColumnLabels
local ____layout = require("core.renderScene.charts.renderers.mekko.layout")
local createMekkoLayout = ____layout.createMekkoLayout
local ____segments = require("core.renderScene.charts.renderers.mekko.segments")
local renderMekkoColumnSegments = ____segments.renderMekkoColumnSegments
function ____exports.renderMekko(self, context)
local layout = createMekkoLayout(nil, context)
local nodes = renderMekkoGrid(nil, context, layout)
__TS__ArrayForEach(
layout.columns,
function(____, column, columnIndex)
__TS__ArrayPushArray(
nodes,
renderMekkoColumnSegments(nil, context, layout, columnIndex)
)
__TS__ArrayPushArray(
nodes,
renderMekkoColumnLabels(
nil,
context,
layout,
columnIndex,
column
)
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.pie.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.renderers.pie.center"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local ______shims = require("core.__shims")
local __re = ______shims.__re
local __replace = ______shims.__replace
local __split = ______shims.__split
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local function fill(self, template, chart)
local values = __TS__ArrayMap(
chart.series,
function(____, series) return math.max(
0,
finite(nil, series.values[1], 0)
) end
)
local total = __TS__ArrayReduce(
values,
function(____, sum, value) return sum + value end,
0
)
local first = values[1] or 0
local ____replace_4 = __replace
local ____replace_result_2 = __replace(
nil,
__replace(
nil,
template,
__re(nil, "\\{total\\}", "g"),
tostring(math.floor(total * 100 + 0.5) / 100)
),
__re(nil, "\\{percent\\}", "g"),
tostring(total > 0 and math.floor(first / total * 100 + 0.5) or 0)
)
local ____re_result_3 = __re(nil, "\\{label\\}", "g")
local ____opt_0 = chart.series[1]
return ____replace_4(nil, ____replace_result_2, ____re_result_3, ____opt_0 and ____opt_0.label or "")
end
function ____exports.renderPieCenter(self, context, geometry)
local ____context_5 = context
local chart = ____context_5.chart
local bounds = ____context_5.bounds
local nextOrder = ____context_5.nextOrder
local ____opt_6 = chart.config
local template = ____opt_6 and ____opt_6.pieCenterText
if not __t(nil, template) then
return {}
end
local lines = __split(
nil,
fill(nil, template, chart),
__re(nil, "\\\\n|\\n", "")
)
local ____finite_10 = finite
local ____opt_8 = chart.config
local fontSize = ____finite_10(
nil,
____opt_8 and ____opt_8.pieCenterSize,
math.max(
14,
math.min(40, geometry.outerRadius * 0.3)
)
)
local lineHeight = fontSize * 1.2
local width = math.max(40, (geometry.innerRadius > 0 and geometry.innerRadius or geometry.outerRadius * 0.6) * 2)
local ____temp_15 = "chart-pie-center-" .. chart.id
local ____nextOrder_result_16 = nextOrder(nil)
local ____bounds_17 = bounds
local ____temp_18 = geometry.centerX - width / 2
local ____temp_19 = geometry.centerY - lineHeight * #lines / 2
local ____width_20 = width
local ____temp_21 = lineHeight * #lines
local ____lines_22 = lines
local ____temp_23 = chart.fontFamily or DEFAULT_FONT
local ____fontSize_24 = fontSize
local ____opt_11 = chart.config
local ____temp_25 = ____opt_11 and ____opt_11.pieCenterColor or chart.textColor or "#0f172a"
local ____opt_13 = chart.series[1]
local text = {
type = "text",
id = ____temp_15,
order = ____nextOrder_result_16,
bounds = ____bounds_17,
x = ____temp_18,
y = ____temp_19,
width = ____width_20,
height = ____temp_21,
lines = ____lines_22,
fontFamily = ____temp_23,
fontSize = ____fontSize_24,
fontWeight = "bold",
align = "center",
verticalAlign = "middle",
lineHeight = 1.2,
color = ____temp_25,
detail = {of = "chartSeries", series = ____opt_13 and ____opt_13.id or "", mark = "pie-center"}
}
return {text}
end
return ____exports
end,
["core.renderScene.charts.renderers.pie.geometry"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____pieShape = require("core.renderScene.charts.primitives.pieShape")
local pieArcPoint = ____pieShape.pieArcPoint
local resolvePieRadii = ____pieShape.resolvePieRadii
____exports.pieArcPoint = pieArcPoint
function ____exports.createPieGeometry(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local ____resolvePieRadii_6 = resolvePieRadii
local ____array_5 = __TS__SparseArrayNew(nil, plot.width, plot.height)
local ____opt_1 = chart.config
__TS__SparseArrayPush(____array_5, ____opt_1 and ____opt_1.innerRadius)
local ____opt_3 = chart.config
__TS__SparseArrayPush(____array_5, ____opt_3 and ____opt_3.pieCornerRadius)
local resolved = ____resolvePieRadii_6(__TS__SparseArraySpread(____array_5))
local ____opt_7 = chart.config
local outside = (____opt_7 and ____opt_7.pieLabelPosition) == "outside" and chart.showAxisLabels ~= false
local ____outside_11
if outside then
local ____opt_9 = chart.config
____outside_11 = (____opt_9 and ____opt_9.pieLabelContent) == "inline" and 0.6 or 0.7
else
____outside_11 = 1
end
local room = ____outside_11
local outerRadius = resolved.outerRadius * room
local innerRadius = resolved.innerRadius * room
local cornerRadius = resolved.cornerRadius
return {
centerX = plot.x + plot.width / 2,
centerY = plot.y + plot.height / 2,
outerRadius = outerRadius,
innerRadius = innerRadius,
cornerRadius = cornerRadius,
total = __lor(
nil,
__TS__ArrayReduce(
chart.series,
function(____, sum, series) return sum + math.max(
0,
finite(nil, series.values[1], 0)
) end,
0
),
function() return 1 end
)
}
end
return ____exports
end,
["core.renderScene.charts.renderers.pie.labels"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local labelTextPair, createTick, createPieLabel, addOffset, LABEL_RADIUS_FRACTION, OUTSIDE_GAP, OUTSIDE_TINT_LIGHTNESS, OUTSIDE_FALLBACK_COLOR
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local clipSegmentToRect = ____primitives.clipSegmentToRect
local contrastTextColor = ____primitives.contrastTextColor
local representativeColor = ____primitives.representativeColor
local sameHueContrastColor = ____primitives.sameHueContrastColor
local sameHueTint = ____primitives.sameHueTint
local ____propPath = require("core.renderScene.charts.propPath")
local seriesLabelProp = ____propPath.seriesLabelProp
local seriesValueProp = ____propPath.seriesValueProp
local ____geometry = require("core.renderScene.charts.renderers.pie.geometry")
local pieArcPoint = ____geometry.pieArcPoint
function labelTextPair(self, context, mark, point, color, fontSize, percent, outside, midAngle)
local ____context_0 = context
local chart = ____context_0.chart
local bounds = ____context_0.bounds
local nextOrder = ____context_0.nextOrder
local lineHeight = fontSize * 1.2
local ____opt_1 = chart.config
local content = ____opt_1 and ____opt_1.pieLabelContent or "both"
local width = content == "inline" and ____exports.LABEL_WIDTH * 1.9 or ____exports.LABEL_WIDTH
local base = {
bounds = bounds,
x = point.x - width / 2,
width = width,
height = lineHeight,
fontFamily = chart.fontFamily or DEFAULT_FONT,
fontSize = fontSize,
align = "center",
verticalAlign = "middle",
lineHeight = 1.2,
color = color
}
local function detail(____, extra)
return __TS__ObjectAssign({
of = "chartSeries",
series = mark.seriesId,
mark = "pie-label",
pulled = outside or nil,
midAngle = midAngle
}, extra)
end
local nameText = __TS__ObjectAssign(
{
type = "text",
id = (("chart-pie-label-name-" .. chart.id) .. "-") .. mark.seriesId,
order = nextOrder(nil)
},
base,
{
y = content == "name" and point.y - lineHeight / 2 or point.y - lineHeight,
lines = {content == "inline" and ((mark.label .. ", ") .. tostring(percent)) .. "%" or mark.label},
fontWeight = "bold",
detail = detail(nil, {}),
prop = seriesLabelProp(nil, mark.seriesId)
}
)
local valueText = __TS__ObjectAssign(
{
type = "text",
id = (("chart-pie-label-value-" .. chart.id) .. "-") .. mark.seriesId,
order = nextOrder(nil)
},
base,
{
y = content == "percent" and point.y - lineHeight / 2 or point.y,
lines = {tostring(percent) .. "%"},
fontWeight = "normal",
detail = detail(nil, {}),
prop = seriesValueProp(nil, mark.seriesId, 0),
propKind = "value"
}
)
if content == "inline" or content == "name" then
return {nameText}
end
return content == "percent" and ({valueText}) or ({nameText, valueText})
end
function createTick(self, context, mark, tickStart, tickEnd, color, outside)
local ____context_3 = context
local chart = ____context_3.chart
local bounds = ____context_3.bounds
local nextOrder = ____context_3.nextOrder
return {
type = "path",
id = (("chart-pie-label-tick-" .. chart.id) .. "-") .. mark.seriesId,
order = nextOrder(nil),
bounds = bounds,
d = (((((("M " .. tostring(tickStart.x)) .. " ") .. tostring(tickStart.y)) .. " L ") .. tostring(tickEnd.x)) .. " ") .. tostring(tickEnd.y),
detail = {of = "chartSeries", series = mark.seriesId, mark = "pie-label-tick"},
style = outside and ({stroke = {kind = "solid", color = color}, strokeWidth = 1.5}) or ({stroke = {kind = "none"}})
}
end
function createPieLabel(self, context, base, mark)
local config = context.chart.config
local geometry = __TS__ObjectAssign({}, base, {centerX = base.centerX + mark.shift.dx, centerY = base.centerY + mark.shift.dy})
local mid = (mark.start + mark["end"]) / 2
local fontSize = math.max(
9,
finite(nil, context.chart.fontSize, 12)
)
local percent = math.floor(mark.share * 100 + 0.5)
local lineHeight = fontSize * 1.2
local tickStart = pieArcPoint(nil, geometry, mid, geometry.outerRadius + ____exports.LEADER_INSET)
local ringThickness = geometry.outerRadius - geometry.innerRadius
local tooThin = ringThickness < lineHeight * 2 + 6
local hasManualOffset = mark.labelOffsetX ~= 0 or mark.labelOffsetY ~= 0
local position = config and config.pieLabelPosition or "auto"
local outside = hasManualOffset or position == "outside" or position == "auto" and tooThin
if outside then
local point = hasManualOffset and addOffset(
nil,
pieArcPoint(nil, geometry, mid, geometry.outerRadius),
mark.labelOffsetX,
mark.labelOffsetY
) or pieArcPoint(
nil,
geometry,
mid,
geometry.outerRadius + OUTSIDE_GAP + (position == "outside" and math.abs(math.cos(mid)) * ((config and config.pieLabelContent) == "inline" and ____exports.LABEL_WIDTH * 0.95 or ____exports.LABEL_WIDTH / 2) or 0)
)
local tickEnd = clipSegmentToRect(
nil,
tickStart,
point,
____exports.LABEL_WIDTH / 2,
lineHeight
)
local color = config and config.pieLabelColor or sameHueTint(
nil,
representativeColor(nil, mark.color, OUTSIDE_FALLBACK_COLOR),
OUTSIDE_TINT_LIGHTNESS
) or OUTSIDE_FALLBACK_COLOR
local tick = createTick(
nil,
context,
mark,
tickStart,
tickEnd,
color,
true
)
return {
tick,
table.unpack(labelTextPair(
nil,
context,
mark,
point,
color,
fontSize,
percent,
true,
mid
))
}
end
local labelRadius = geometry.innerRadius + ringThickness * LABEL_RADIUS_FRACTION
local point = pieArcPoint(nil, geometry, mid, labelRadius)
local sliceColor = representativeColor(nil, mark.color, "#0f172a")
local color = config and config.pieLabelColor or sameHueContrastColor(
nil,
sliceColor,
contrastTextColor(nil, sliceColor)
)
local tick = createTick(
nil,
context,
mark,
tickStart,
tickStart,
color,
false
)
return {
tick,
table.unpack(labelTextPair(
nil,
context,
mark,
point,
color,
fontSize,
percent,
false,
mid
))
}
end
function addOffset(self, point, dx, dy)
return {x = point.x + dx, y = point.y + dy}
end
local MIN_LABEL_SWEEP = 14 * math.pi / 180
____exports.LABEL_WIDTH = 80
LABEL_RADIUS_FRACTION = 0.62
OUTSIDE_GAP = 14
____exports.LEADER_INSET = 3
OUTSIDE_TINT_LIGHTNESS = 0.32
OUTSIDE_FALLBACK_COLOR = "#334155"
function ____exports.renderPieLabels(self, context, geometry, marks)
if context.chart.showAxisLabels == false then
return {}
end
return __TS__ArrayFlatMap(
__TS__ArrayFilter(
marks,
function(____, mark) return mark["end"] - mark.start >= MIN_LABEL_SWEEP end
),
function(____, mark) return createPieLabel(nil, context, geometry, mark) end
)
end
return ____exports
end,
["core.renderScene.charts.renderers.pie.path"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____pieShape = require("core.renderScene.charts.primitives.pieShape")
____exports.createPieSlicePath = ____pieShape.createPieSlicePath
end
return ____exports
end,
["core.renderScene.charts.renderers.pie.slices"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local shiftOf, shiftGeometry, createPieSliceMarks, fullCirclePath, pieOuterShadow, sliceCornerRadius, sliceStroke, createSliceNodes, FULL, MAXIMUM_SWEEP
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local gapInsetAngle = ____primitives.gapInsetAngle
local maxApexCornerRadius = ____primitives.maxApexCornerRadius
local maxPieCornerRadius = ____primitives.maxPieCornerRadius
local pieApexRadius = ____primitives.pieApexRadius
local pieUsesInnerArc = ____primitives.pieUsesInnerArc
local representativeColor = ____primitives.representativeColor
local resolveChartShadow = ____primitives.resolveChartShadow
local ____propPath = require("core.renderScene.charts.propPath")
local seriesValueProp = ____propPath.seriesValueProp
local ____labels = require("core.renderScene.charts.renderers.pie.labels")
local renderPieLabels = ____labels.renderPieLabels
local ____path = require("core.renderScene.charts.renderers.pie.path")
local createPieSlicePath = ____path.createPieSlicePath
function shiftOf(self, mark)
local mid = (mark.angles.start + mark.angles["end"]) / 2
return {
dx = math.cos(mid) * mark.explode,
dy = math.sin(mid) * mark.explode
}
end
function shiftGeometry(self, geometry, mark)
if mark.explode == 0 then
return geometry
end
local ____shiftOf_result_9 = shiftOf(nil, mark)
local dx = ____shiftOf_result_9.dx
local dy = ____shiftOf_result_9.dy
return __TS__ObjectAssign({}, geometry, {centerX = geometry.centerX + dx, centerY = geometry.centerY + dy})
end
function createPieSliceMarks(self, seriesList, total, layout)
local marks = {}
local angle = layout.start
__TS__ArrayForEach(
seriesList,
function(____, series, seriesIndex)
local value = math.max(
0,
finite(nil, series.values[1], 0)
)
local sweep = value / total * layout.sweep
marks[#marks + 1] = {
seriesId = series.id,
label = series.label,
color = series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1],
stroke = series.stroke,
strokeWidth = series.strokeWidth,
value = value,
share = value / total,
angles = {
start = angle,
["end"] = angle + math.min(sweep, layout.sweep >= FULL and MAXIMUM_SWEEP or layout.sweep)
},
explode = math.max(
0,
finite(nil, series.offset, layout.explode)
),
labelOffsetX = finite(nil, series.labelOffsetX, 0),
labelOffsetY = finite(nil, series.labelOffsetY, 0)
}
angle = angle + sweep
end
)
return marks
end
function fullCirclePath(self, cx, cy, r)
return ((((((((((((((((((("M " .. tostring(cx - r)) .. " ") .. tostring(cy)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 1 0 ") .. tostring(cx + r)) .. " ") .. tostring(cy)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 1 0 ") .. tostring(cx - r)) .. " ") .. tostring(cy)) .. " Z"
end
function pieOuterShadow(self, shadow, gapPx)
if gapPx <= 0 then
return shadow
end
local halfGap = gapPx / 2
local blur = math.min(shadow.blur, halfGap * 2)
local maxDistance = halfGap
local distance = __hypot(nil, shadow.dx, shadow.dy)
local scale = distance > maxDistance and maxDistance / distance or 1
return __TS__ObjectAssign({}, shadow, {blur = blur, dx = shadow.dx * scale, dy = shadow.dy * scale})
end
function sliceCornerRadius(self, geometry, mark, gapPx)
local halfGap = math.max(0, gapPx) / 2
local rawSweep = mark.angles["end"] - mark.angles.start
local usesInnerArc = pieUsesInnerArc(nil, geometry, mark.angles, gapPx)
local gapSweep = 2 * gapInsetAngle(nil, halfGap, geometry.outerRadius)
local availableSweep = math.max(0, rawSweep - gapSweep)
return math.min(
geometry.cornerRadius,
usesInnerArc and maxPieCornerRadius(nil, geometry.outerRadius, geometry.innerRadius, availableSweep) or maxApexCornerRadius(
nil,
geometry.outerRadius,
pieApexRadius(nil, halfGap, rawSweep, geometry.outerRadius),
availableSweep
)
)
end
function sliceStroke(self, context, mark)
local config = context.chart.config
local strokeColor = mark.stroke or config and config.pieStroke
if not __t(nil, strokeColor) then
return {}
end
return {
stroke = {kind = "solid", color = strokeColor},
strokeWidth = finite(
nil,
mark.strokeWidth,
finite(nil, config and config.pieStrokeWidth, 1)
)
}
end
function createSliceNodes(self, context, geometry, mark, gapPx)
local ____context_14 = context
local chart = ____context_14.chart
local bounds = ____context_14.bounds
local diagnostics = ____context_14.diagnostics
local nextOrder = ____context_14.nextOrder
local fill = paint(nil, mark.color, diagnostics, chart.id)
local slicePath = createPieSlicePath(
nil,
geometry,
mark.angles,
sliceCornerRadius(nil, geometry, mark, gapPx),
gapPx
)
local shadow = resolveChartShadow(nil, chart.shadowStyle)
local strokeStyle = sliceStroke(nil, context, mark)
local ____opt_15 = chart.config
local glow = ____opt_15 and ____opt_15.pieGlow
local shadowCaster = shadow and ({
type = "path",
id = (("chart-pie-slice-shadow-" .. chart.id) .. "-") .. mark.seriesId,
order = nextOrder(nil),
bounds = bounds,
d = slicePath,
style = __TS__ObjectAssign(
{fill = fill},
strokeStyle,
{
shadow = pieOuterShadow(nil, shadow, gapPx),
clip = {
type = "path",
d = fullCirclePath(nil, geometry.centerX, geometry.centerY, geometry.outerRadius)
}
}
)
}) or nil
local slice = {
type = "path",
id = (("chart-pie-slice-" .. chart.id) .. "-") .. mark.seriesId,
order = nextOrder(nil),
bounds = bounds,
d = slicePath,
detail = {
of = "chartValue",
series = mark.seriesId,
valueIndex = 0,
mark = "pie-slice",
pieStart = mark.angles.start,
pieEnd = mark.angles["end"],
pieValue = mark.value
},
prop = seriesValueProp(nil, mark.seriesId, 0),
style = __TS__ObjectAssign(
{fill = fill},
strokeStyle,
{
innerShadow = shadow,
shadow = __t(nil, glow) and ({
color = representativeColor(nil, mark.color, "#ffffff"),
opacity = 0.85,
blur = glow,
dx = 0,
dy = 0
}) or nil
}
)
}
return shadowCaster and ({shadowCaster, slice}) or ({slice})
end
local TOP = -math.pi / 2
FULL = math.pi * 2
MAXIMUM_SWEEP = FULL * (359.999 / 360)
local function radians(____, degrees)
return degrees * math.pi / 180
end
function ____exports.renderPieSlices(self, context, geometry)
local config = context.chart.config
local marks = createPieSliceMarks(
nil,
context.chart.series,
geometry.total,
{
start = TOP + radians(
nil,
finite(nil, config and config.pieStartAngle, 0)
),
sweep = math.min(
FULL,
math.max(
radians(nil, 1),
radians(
nil,
finite(nil, config and config.pieSweep, 360)
)
)
),
explode = math.max(
0,
finite(nil, config and config.pieExplode, 0)
)
}
)
local gapPx = config and config.pieSliceGap or 0
local ____array_8 = __TS__SparseArrayNew(table.unpack(__TS__ArrayFlatMap(
marks,
function(____, mark) return createSliceNodes(
nil,
context,
shiftGeometry(nil, geometry, mark),
mark,
gapPx
) end
)))
__TS__SparseArrayPush(
____array_8,
table.unpack(renderPieLabels(
nil,
context,
geometry,
__TS__ArrayMap(
marks,
function(____, mark) return {
seriesId = mark.seriesId,
label = mark.label,
color = mark.color,
share = mark.share,
start = mark.angles.start,
["end"] = mark.angles["end"],
labelOffsetX = mark.labelOffsetX,
labelOffsetY = mark.labelOffsetY,
shift = shiftOf(nil, mark)
} end
)
))
)
return {__TS__SparseArraySpread(____array_8)}
end
return ____exports
end,
["core.renderScene.charts.renderers.pie"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ____center = require("core.renderScene.charts.renderers.pie.center")
local renderPieCenter = ____center.renderPieCenter
local ____geometry = require("core.renderScene.charts.renderers.pie.geometry")
local createPieGeometry = ____geometry.createPieGeometry
local ____slices = require("core.renderScene.charts.renderers.pie.slices")
local renderPieSlices = ____slices.renderPieSlices
function ____exports.renderPie(self, context)
local geometry = createPieGeometry(nil, context)
local ____array_0 = __TS__SparseArrayNew(table.unpack(renderPieSlices(nil, context, geometry)))
__TS__SparseArrayPush(
____array_0,
table.unpack(renderPieCenter(nil, context, geometry))
)
return {__TS__SparseArraySpread(____array_0)}
end
return ____exports
end,
["core.renderScene.charts.renderers.polarArea"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local trackStroke, wedgeStroke, labelSizes, labelPlacement, labelTick, labelTexts, createWedgeLabel, addOffset, LABEL_WIDTH, LABEL_RADIUS_FRACTION, OUTSIDE_GAP, LEADER_INSET, OUTSIDE_TINT_LIGHTNESS, OUTSIDE_FALLBACK_COLOR
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
local __re = ______shims.__re
local __split = ______shims.__split
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local DEFAULT_FONT = ____scene.DEFAULT_FONT
local finite = ____scene.finite
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local chartTicks = ____primitives.chartTicks
local clipSegmentToRect = ____primitives.clipSegmentToRect
local contrastTextColor = ____primitives.contrastTextColor
local createPieSlicePath = ____primitives.createPieSlicePath
local formatFieldValue = ____primitives.formatFieldValue
local gapInsetAngle = ____primitives.gapInsetAngle
local maxApexCornerRadius = ____primitives.maxApexCornerRadius
local maxPieCornerRadius = ____primitives.maxPieCornerRadius
local pieApexRadius = ____primitives.pieApexRadius
local pieArcPoint = ____primitives.pieArcPoint
local pieUsesInnerArc = ____primitives.pieUsesInnerArc
local representativeColor = ____primitives.representativeColor
local resolveChartShadow = ____primitives.resolveChartShadow
local sameHueContrastColor = ____primitives.sameHueContrastColor
local sameHueTint = ____primitives.sameHueTint
local ____propPath = require("core.renderScene.charts.propPath")
local seriesLabelProp = ____propPath.seriesLabelProp
local seriesValueProp = ____propPath.seriesValueProp
function trackStroke(self, context)
local config = context.chart.config
if not __t(nil, config and config.polarTrackStroke) then
return {}
end
local dash = __TS__ArrayFilter(
__TS__ArrayMap(
__split(
nil,
config.polarTrackDash or "",
__re(nil, "[ ,]+", "")
),
Number
),
function(____, part) return __isFinite(nil, part) and part > 0 end
)
return {
stroke = {kind = "solid", color = config.polarTrackStroke},
strokeWidth = finite(nil, config.polarTrackStrokeWidth, 1),
dash = #dash > 0 and dash or nil
}
end
function wedgeStroke(self, context)
local config = context.chart.config
if not __t(nil, config and config.pieStroke) then
return {}
end
return {
stroke = {kind = "solid", color = config.pieStroke},
strokeWidth = finite(nil, config.pieStrokeWidth, 1)
}
end
function labelSizes(self, chart)
local base = math.max(
9,
finite(nil, chart.fontSize, 12)
)
local ____finite_42 = finite
local ____opt_40 = chart.config
local ____math_max_result_46 = math.max(
6,
____finite_42(nil, ____opt_40 and ____opt_40.polarNameSize, base)
)
local ____finite_45 = finite
local ____opt_43 = chart.config
return {
nameSize = ____math_max_result_46,
valueSize = math.max(
6,
____finite_45(nil, ____opt_43 and ____opt_43.polarValueSize, base)
)
}
end
function labelPlacement(self, context, geometry, angles, series, fillColor)
local mid = (angles.start + angles["end"]) / 2
local ____labelSizes_result_47 = labelSizes(nil, context.chart)
local nameSize = ____labelSizes_result_47.nameSize
local valueSize = ____labelSizes_result_47.valueSize
local lineHeight = (nameSize + valueSize) * 1.2 / 2
local ringThickness = geometry.outerRadius - geometry.innerRadius
local labelOffsetX = finite(nil, series.labelOffsetX, 0)
local labelOffsetY = finite(nil, series.labelOffsetY, 0)
local hasManualOffset = labelOffsetX ~= 0 or labelOffsetY ~= 0
local tooThin = ringThickness < lineHeight * 2 + 6
local chordWidth = 2 * geometry.outerRadius * math.sin(math.abs(angles["end"] - angles.start) / 2)
local fitsInline = not tooThin and chordWidth >= LABEL_WIDTH
local ____opt_48 = context.chart.config
local ____temp_50 = ____opt_48 and ____opt_48.polarOutsideLabels
if ____temp_50 == nil then
____temp_50 = false
end
local outsideLabels = ____temp_50
if not fitsInline and not hasManualOffset and not outsideLabels then
return nil
end
local outside = hasManualOffset or not fitsInline
local tickStart = pieArcPoint(nil, geometry, mid, geometry.outerRadius + LEADER_INSET)
local point = outside and (hasManualOffset and addOffset(
nil,
pieArcPoint(nil, geometry, mid, geometry.outerRadius),
labelOffsetX,
labelOffsetY
) or pieArcPoint(nil, geometry, mid, geometry.outerRadius + OUTSIDE_GAP)) or pieArcPoint(nil, geometry, mid, geometry.innerRadius + ringThickness * LABEL_RADIUS_FRACTION)
local color = outside and (outsideLabels and __t(nil, context.chart.textColor) and context.chart.textColor or (sameHueTint(
nil,
representativeColor(nil, fillColor, OUTSIDE_FALLBACK_COLOR),
OUTSIDE_TINT_LIGHTNESS
) or OUTSIDE_FALLBACK_COLOR)) or sameHueContrastColor(
nil,
representativeColor(nil, fillColor, "#0f172a"),
contrastTextColor(
nil,
representativeColor(nil, fillColor, "#0f172a")
)
)
return {
point = point,
color = color,
outside = outside,
mid = mid,
tickStart = tickStart
}
end
function labelTick(self, context, series, placement, lineHeight)
local ____placement_51 = placement
local point = ____placement_51.point
local color = ____placement_51.color
local outside = ____placement_51.outside
local tickStart = ____placement_51.tickStart
local tickEnd = outside and clipSegmentToRect(
nil,
tickStart,
point,
LABEL_WIDTH / 2,
lineHeight
) or tickStart
return {
type = "path",
id = (("chart-polar-area-label-tick-" .. context.chart.id) .. "-") .. series.id,
order = context:nextOrder(),
bounds = context.bounds,
d = (((((("M " .. tostring(tickStart.x)) .. " ") .. tostring(tickStart.y)) .. " L ") .. tostring(tickEnd.x)) .. " ") .. tostring(tickEnd.y),
detail = {of = "chartSeries", series = series.id, mark = "polar-area-label-tick"},
style = outside and ({stroke = {kind = "solid", color = color}, strokeWidth = 1.5}) or ({stroke = {kind = "none"}})
}
end
function labelTexts(self, context, geometry, series, value, placement)
local ____context_52 = context
local chart = ____context_52.chart
local bounds = ____context_52.bounds
local nextOrder = ____context_52.nextOrder
local ____placement_53 = placement
local point = ____placement_53.point
local color = ____placement_53.color
local outside = ____placement_53.outside
local mid = ____placement_53.mid
local ____labelSizes_result_54 = labelSizes(nil, chart)
local nameSize = ____labelSizes_result_54.nameSize
local valueSize = ____labelSizes_result_54.valueSize
local detail = {
of = "chartSeries",
series = series.id,
mark = "polar-area-label",
pulled = outside or nil,
midAngle = mid,
wedgeRadius = geometry.outerRadius
}
local base = {
bounds = bounds,
x = point.x - LABEL_WIDTH / 2,
width = LABEL_WIDTH,
fontFamily = chart.fontFamily or DEFAULT_FONT,
align = "center",
verticalAlign = "middle",
lineHeight = 1.2,
color = color
}
local ____opt_55 = chart.config
local ____temp_57 = ____opt_55 and ____opt_55.polarValueFirst
if ____temp_57 == nil then
____temp_57 = false
end
local valueFirst = ____temp_57
local nameHeight = nameSize * 1.2
local valueHeight = valueSize * 1.2
local top = point.y - (nameHeight + valueHeight) / 2
local nameY = valueFirst and top + valueHeight or top
local valueY = valueFirst and top or top + nameHeight
local nameText = __TS__ObjectAssign(
{
type = "text",
id = (("chart-polar-area-label-name-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil)
},
base,
{
y = nameY,
height = nameSize * 1.2,
fontSize = nameSize,
lines = {series.label},
fontWeight = valueFirst and "normal" or "bold",
detail = detail,
prop = seriesLabelProp(nil, series.id)
}
)
local valueText = __TS__ObjectAssign(
{
type = "text",
id = (("chart-polar-area-label-value-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil)
},
base,
{
y = valueY,
height = valueSize * 1.2,
fontSize = valueSize,
lines = {formatFieldValue(nil, value)},
fontWeight = valueFirst and "bold" or "normal",
detail = detail,
prop = seriesValueProp(nil, series.id, 0),
propKind = "value"
}
)
return {nameText, valueText}
end
function createWedgeLabel(self, context, geometry, angles, series, value, fillColor)
local placement = labelPlacement(
nil,
context,
geometry,
angles,
series,
fillColor
)
if not placement then
return {}
end
local ____labelSizes_result_58 = labelSizes(nil, context.chart)
local nameSize = ____labelSizes_result_58.nameSize
local valueSize = ____labelSizes_result_58.valueSize
local tick = labelTick(
nil,
context,
series,
placement,
math.max(nameSize, valueSize) * 1.2
)
return {
tick,
table.unpack(labelTexts(
nil,
context,
geometry,
series,
value,
placement
))
}
end
function addOffset(self, point, dx, dy)
return {x = point.x + dx, y = point.y + dy}
end
local TOP = -math.pi / 2
local TRACK_COLOR_FALLBACK = "#e2e8f0"
local MIN_LABEL_SWEEP = 14 * math.pi / 180
LABEL_WIDTH = 80
LABEL_RADIUS_FRACTION = 0.62
OUTSIDE_GAP = 14
LEADER_INSET = 3
OUTSIDE_TINT_LIGHTNESS = 0.32
OUTSIDE_FALLBACK_COLOR = "#334155"
local function layoutOf(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local maxRadius = math.max(
1,
math.min(plot.width, plot.height) / 2 - 4
)
local axisMin = finite(nil, chart.axisY.min, 0)
local ____temp_13 = plot.x + plot.width / 2
local ____temp_14 = plot.y + plot.height / 2
local ____maxRadius_15 = maxRadius
local ____finite_3 = finite
local ____opt_1 = chart.config
local ____math_max_result_16 = math.max(
0,
math.min(
____finite_3(nil, ____opt_1 and ____opt_1.innerRadius, 0),
maxRadius - 1
)
)
local ____finite_6 = finite
local ____opt_4 = chart.config
local ____math_max_result_17 = math.max(
0,
____finite_6(nil, ____opt_4 and ____opt_4.pieCornerRadius, 0)
)
local ____finite_9 = finite
local ____opt_7 = chart.config
local ____math_max_result_18 = math.max(
0,
____finite_9(nil, ____opt_7 and ____opt_7.pieSliceGap, 0)
)
local ____axisMin_19 = axisMin
local ____temp_20 = finite(nil, chart.axisY.max, 100) - axisMin
local ____temp_21 = #chart.series > 0 and math.pi * 2 / #chart.series or 0
local ____finite_12 = finite
local ____opt_10 = chart.config
return {
centerX = ____temp_13,
centerY = ____temp_14,
maxRadius = ____maxRadius_15,
innerRadius = ____math_max_result_16,
cornerRadius = ____math_max_result_17,
gapPx = ____math_max_result_18,
axisMin = ____axisMin_19,
range = ____temp_20,
sweep = ____temp_21,
start = TOP + ____finite_12(nil, ____opt_10 and ____opt_10.pieStartAngle, 0) * math.pi / 180
}
end
local function clampedCorner(self, layout, outerRadius, angles)
local ____layout_22 = layout
local centerX = ____layout_22.centerX
local centerY = ____layout_22.centerY
local innerRadius = ____layout_22.innerRadius
local cornerRadius = ____layout_22.cornerRadius
local gapPx = ____layout_22.gapPx
local geometry = {centerX = centerX, centerY = centerY, outerRadius = outerRadius, innerRadius = innerRadius}
local halfGap = math.max(0, gapPx) / 2
local rawSweep = angles["end"] - angles.start
local availableSweep = math.max(
0,
rawSweep - 2 * gapInsetAngle(nil, halfGap, outerRadius)
)
if pieUsesInnerArc(nil, geometry, angles, gapPx) then
return math.min(
cornerRadius,
maxPieCornerRadius(nil, outerRadius, innerRadius, availableSweep)
)
end
local apexRadius = pieApexRadius(nil, halfGap, rawSweep, outerRadius)
return math.min(
cornerRadius,
maxApexCornerRadius(nil, outerRadius, apexRadius, availableSweep)
)
end
local function wedgeNodes(self, context, layout, series, angles, outerRadius, value, rawColor)
local ____context_23 = context
local chart = ____context_23.chart
local bounds = ____context_23.bounds
local diagnostics = ____context_23.diagnostics
local nextOrder = ____context_23.nextOrder
local ____layout_24 = layout
local centerX = ____layout_24.centerX
local centerY = ____layout_24.centerY
local innerRadius = ____layout_24.innerRadius
local maxRadius = ____layout_24.maxRadius
local gapPx = ____layout_24.gapPx
local color = paint(nil, rawColor, diagnostics, chart.id)
local shadow = resolveChartShadow(nil, chart.shadowStyle)
local trackPath = createPieSlicePath(
nil,
{centerX = centerX, centerY = centerY, outerRadius = maxRadius, innerRadius = innerRadius},
angles,
clampedCorner(nil, layout, maxRadius, angles),
gapPx
)
local ____temp_28 = (("chart-polar-area-track-" .. chart.id) .. "-") .. series.id
local ____nextOrder_result_29 = nextOrder(nil)
local ____bounds_30 = bounds
local ____paint_result_27 = paint(nil, chart.gridColor or TRACK_COLOR_FALLBACK, diagnostics, chart.id)
local ____opt_25 = chart.config
local track = {
type = "path",
id = ____temp_28,
order = ____nextOrder_result_29,
bounds = ____bounds_30,
d = trackPath,
style = __TS__ObjectAssign(
{fill = ____paint_result_27, opacity = ____opt_25 and ____opt_25.polarTrackOpacity},
trackStroke(nil, context)
)
}
local wedgePath = createPieSlicePath(
nil,
{centerX = centerX, centerY = centerY, outerRadius = outerRadius, innerRadius = innerRadius},
angles,
clampedCorner(nil, layout, outerRadius, angles),
gapPx
)
local shadowCaster = shadow and ({
type = "path",
id = (("chart-polar-area-wedge-shadow-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil),
bounds = bounds,
d = wedgePath,
style = {fill = color, shadow = shadow, clip = {type = "path", d = trackPath}}
}) or nil
local wedge = {
type = "path",
id = (("chart-polar-area-wedge-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil),
bounds = bounds,
d = wedgePath,
detail = {
of = "chartValue",
series = series.id,
valueIndex = 0,
mark = "polar-area-wedge",
pieStart = angles.start,
pieEnd = angles["end"],
pieValue = value
},
prop = seriesValueProp(nil, series.id, 0),
style = __TS__ObjectAssign(
{fill = color, innerShadow = shadow},
wedgeStroke(nil, context)
)
}
return shadowCaster and ({track, shadowCaster, wedge}) or ({track, wedge})
end
local function ringNodes(self, context, layout)
local ____context_35 = context
local chart = ____context_35.chart
local bounds = ____context_35.bounds
local nextOrder = ____context_35.nextOrder
local ____opt_36 = chart.config
if not (____opt_36 and ____opt_36.polarRings) or layout.range <= 0 then
return {}
end
return __TS__ArrayMap(
__TS__ArrayFilter(
chartTicks(nil, chart.axisY),
function(____, tick) return tick > layout.axisMin and tick < layout.axisMin + layout.range end
),
function(____, tick)
local radius = layout.innerRadius + (layout.maxRadius - layout.innerRadius) * (tick - layout.axisMin) / layout.range
return {
type = "ellipse",
id = (("chart-polar-area-ring-" .. chart.id) .. "-") .. tostring(tick),
order = nextOrder(nil),
bounds = bounds,
cx = layout.centerX,
cy = layout.centerY,
rx = radius,
ry = radius,
style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = chart.textColor or "#334155"},
strokeWidth = finite(nil, chart.gridWidth, 1),
opacity = 0.25
}
}
end
)
end
function ____exports.renderPolarArea(self, context)
local layout = layoutOf(nil, context)
local centerX = layout.centerX
local centerY = layout.centerY
local innerRadius = layout.innerRadius
local maxRadius = layout.maxRadius
local axisMin = layout.axisMin
local range = layout.range
local sweep = layout.sweep
local start = layout.start
local showLabels = context.showLabels and sweep >= MIN_LABEL_SWEEP
local wedges = __TS__ArrayFlatMap(
context.chart.series,
function(____, series, index)
local angles = {start = start + index * sweep, ["end"] = start + (index + 1) * sweep}
local value = math.max(
0,
finite(nil, series.values[1], 0)
)
local fraction = range > 0 and math.min(
1,
math.max(0, (value - axisMin) / range)
) or 0
local outerRadius = math.max(innerRadius + 1, innerRadius + (maxRadius - innerRadius) * fraction)
local rawColor = series.color or CHART_COLORS[index % #CHART_COLORS + 1]
local nodes = wedgeNodes(
nil,
context,
layout,
series,
angles,
outerRadius,
value,
rawColor
)
if not showLabels then
return nodes
end
local geometry = {centerX = centerX, centerY = centerY, outerRadius = outerRadius, innerRadius = innerRadius}
local ____array_38 = __TS__SparseArrayNew(table.unpack(nodes))
__TS__SparseArrayPush(
____array_38,
table.unpack(createWedgeLabel(
nil,
context,
geometry,
angles,
series,
value,
rawColor
))
)
return {__TS__SparseArraySpread(____array_38)}
end
)
local ____array_39 = __TS__SparseArrayNew(table.unpack(wedges))
__TS__SparseArrayPush(
____array_39,
table.unpack(ringNodes(nil, context, layout))
)
return {__TS__SparseArraySpread(____array_39)}
end
return ____exports
end,
["core.renderScene.charts.renderers.radar.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.renderers.radar.geometry"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local ____exports = {}
local createCategories, DEFAULT_CATEGORIES
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____radarShape = require("core.renderScene.charts.primitives.radarShape")
local radarCategoryCount = ____radarShape.radarCategoryCount
local radarPointAt = ____radarShape.radarPointAt
local radarRadius = ____radarShape.radarRadius
local radarRadiusForValue = ____radarShape.radarRadiusForValue
local radarSeriesPath = ____radarShape.radarSeriesPath
function createCategories(self, configured, categoryCount)
return __TS__ArrayFrom(
{length = categoryCount},
function(____, _, index) return configured[index + 1] or DEFAULT_CATEGORIES[index + 1] or "Category " .. tostring(index + 1) end
)
end
DEFAULT_CATEGORIES = {
"Speed",
"Quality",
"Cost",
"Reliability",
"Usability"
}
function ____exports.radarFrameFor(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local ____opt_5 = chart.config
local ____opt_1 = ____opt_5 and ____opt_5.categories
if ____opt_1 ~= nil then
local ____opt_2 = chart.config
____opt_1 = __TS__ArrayFilter(____opt_2 and ____opt_2.categories, Boolean)
end
local configuredCount = #(____opt_1 or ({}))
local dataCount = math.max(
0,
table.unpack(__TS__ArrayMap(
chart.series,
function(____, series) return #series.values end
))
)
local ____temp_9 = plot.x + plot.width / 2
local ____temp_10 = plot.y + plot.height / 2
local ____radarRadius_result_11 = radarRadius(
nil,
plot.width,
plot.height,
finite(nil, chart.fontSize, 12),
context.showLabels
)
local ____chart_axisY_min_12 = chart.axisY.min
local ____chart_axisY_max_13 = chart.axisY.max
local ____radarCategoryCount_result_14 = radarCategoryCount(nil, configuredCount, dataCount)
local ____temp_15 = chart.chartType == "radial"
local ____opt_7 = chart.config
return {
centerX = ____temp_9,
centerY = ____temp_10,
radius = ____radarRadius_result_11,
min = ____chart_axisY_min_12,
max = ____chart_axisY_max_13,
count = ____radarCategoryCount_result_14,
curved = ____temp_15,
tension = ____opt_7 and ____opt_7.radarTension
}
end
function ____exports.createRadarGeometry(self, context)
local ____context_16 = context
local chart = ____context_16.chart
local ____opt_21 = chart.config
local ____opt_17 = ____opt_21 and ____opt_21.categories
if ____opt_17 ~= nil then
local ____opt_18 = chart.config
____opt_17 = __TS__ArrayFilter(____opt_18 and ____opt_18.categories, Boolean)
end
local configuredCategories = ____opt_17 or ({})
local frame = ____exports.radarFrameFor(nil, context)
local categories = createCategories(nil, configuredCategories, frame.count)
local function pointAt(____, pointRadius, pointIndex)
return radarPointAt(nil, frame, pointIndex, pointRadius)
end
local ____frame_curved_32 = frame.curved
local ____opt_23 = chart.config
local ____math_max_result_33 = math.max(
0,
math.min(1, ____opt_23 and ____opt_23.areaOpacity or 0.16)
)
local ____opt_25 = chart.config
local ____math_max_result_34 = math.max(0, ____opt_25 and ____opt_25.radarStrokeWidth or 2)
local ____frame_tension_35 = frame.tension
local ____opt_27 = chart.config
local ____math_max_result_36 = math.max(0, ____opt_27 and ____opt_27.radarPointSize or 3)
local ____opt_29 = chart.config
local ____temp_31 = ____opt_29 and ____opt_29.radarSpokes
if ____temp_31 == nil then
____temp_31 = true
end
return {
circular = ____frame_curved_32,
areaOpacity = ____math_max_result_33,
strokeWidth = ____math_max_result_34,
tension = ____frame_tension_35,
pointSize = ____math_max_result_36,
showSpokes = ____temp_31,
categories = categories,
centerX = frame.centerX,
centerY = frame.centerY,
radius = frame.radius,
radiusForValue = function(____, value) return radarRadiusForValue(nil, frame, value) end,
pointAt = pointAt,
polygonPath = function(____, pointRadius) return radarSeriesPath(
nil,
__TS__ArrayMap(
categories,
function(____, _, index) return pointAt(nil, pointRadius, index) end
),
false
) end
}
end
return ____exports
end,
["core.renderScene.charts.renderers.radar.grid"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local renderRings, createRingNode, renderSpokes
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartTicks = ____primitives.chartTicks
function renderRings(self, context, geometry)
return __TS__ArrayMap(
__TS__ArrayFilter(
chartTicks(nil, context.chart.axisY),
function(____, tick) return tick > context.chart.axisY.min end
),
function(____, tick) return createRingNode(nil, context, geometry, tick) end
)
end
function createRingNode(self, context, geometry, tick)
local ____context_1 = context
local chart = ____context_1.chart
local bounds = ____context_1.bounds
local nextOrder = ____context_1.nextOrder
local ringRadius = geometry:radiusForValue(tick)
local style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"},
strokeWidth = finite(nil, chart.gridWidth, 1)
}
if geometry.circular then
return {
type = "ellipse",
id = (("chart-radial-ring-" .. chart.id) .. "-") .. tostring(tick),
order = nextOrder(nil),
bounds = bounds,
cx = geometry.centerX,
cy = geometry.centerY,
rx = ringRadius,
ry = ringRadius,
style = style
}
end
return {
type = "path",
id = (("chart-radar-ring-" .. chart.id) .. "-") .. tostring(tick),
order = nextOrder(nil),
bounds = bounds,
d = geometry:polygonPath(ringRadius),
style = style
}
end
function renderSpokes(self, context, geometry)
local ____context_2 = context
local chart = ____context_2.chart
local bounds = ____context_2.bounds
local nextOrder = ____context_2.nextOrder
return __TS__ArrayMap(
geometry.categories,
function(____, _, categoryIndex)
local edge = geometry:pointAt(geometry.radius, categoryIndex)
return {
type = "path",
id = (("chart-radar-spoke-" .. chart.id) .. "-") .. tostring(categoryIndex),
order = nextOrder(nil),
bounds = bounds,
d = (((((("M " .. tostring(geometry.centerX)) .. " ") .. tostring(geometry.centerY)) .. " L ") .. tostring(edge.x)) .. " ") .. tostring(edge.y),
style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"},
strokeWidth = finite(nil, chart.gridWidth, 1)
}
}
end
)
end
function ____exports.renderRadarGrid(self, context, geometry)
if context.chart.showGrid == false then
return {}
end
local ____array_0 = __TS__SparseArrayNew(table.unpack(renderRings(nil, context, geometry)))
__TS__SparseArrayPush(
____array_0,
table.unpack(geometry.showSpokes and renderSpokes(nil, context, geometry) or ({}))
)
return {__TS__SparseArraySpread(____array_0)}
end
return ____exports
end,
["core.renderScene.charts.renderers.radar.labels"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local createCategoryLabel, labelX, labelAlignment
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
function createCategoryLabel(self, context, geometry, category, categoryIndex)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local bounds = ____context_0.bounds
local nextOrder = ____context_0.nextOrder
local labelPoint = geometry:pointAt(geometry.radius + 10, categoryIndex)
local horizontalOffset = labelPoint.x - geometry.centerX
local width = math.max(
64,
math.min(120, plot.width / 3)
)
return chartText(
nil,
{
id = (("chart-radar-label-" .. chart.id) .. "-") .. tostring(categoryIndex),
order = nextOrder(nil),
bounds = bounds,
frame = {
x = labelX(nil, labelPoint.x, horizontalOffset, width),
y = labelPoint.y - 6,
width = width,
height = 30
},
text = category,
chart = chart,
align = labelAlignment(nil, horizontalOffset)
}
)
end
function labelX(self, pointX, horizontalOffset, width)
if horizontalOffset > 8 then
return pointX
end
if horizontalOffset < -8 then
return pointX - width
end
return pointX - width / 2
end
function labelAlignment(self, horizontalOffset)
if horizontalOffset > 8 then
return "left"
end
if horizontalOffset < -8 then
return "right"
end
return "center"
end
function ____exports.renderRadarLabels(self, context, geometry)
if not context.showLabels then
return {}
end
return __TS__ArrayMap(
geometry.categories,
function(____, category, categoryIndex) return createCategoryLabel(
nil,
context,
geometry,
category,
categoryIndex
) end
)
end
return ____exports
end,
["core.renderScene.charts.renderers.radar.series"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local renderSeries, seriesPoints, createSeriesFill, createSeriesStroke, createSeriesPoints
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local resolveChartShadow = ____primitives.resolveChartShadow
local ____radarShape = require("core.renderScene.charts.primitives.radarShape")
local radarSeriesPath = ____radarShape.radarSeriesPath
local ____propPath = require("core.renderScene.charts.propPath")
local seriesValueProp = ____propPath.seriesValueProp
function renderSeries(self, context, geometry, series, seriesIndex)
local color = series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1]
local points = seriesPoints(nil, series, context, geometry)
local path = radarSeriesPath(nil, points, geometry.circular, geometry.tension)
local ____array_0 = __TS__SparseArrayNew(
createSeriesFill(
nil,
context,
geometry,
series,
path,
color
),
table.unpack(geometry.strokeWidth > 0 and ({createSeriesStroke(
nil,
context,
geometry,
series,
path,
color
)}) or ({}))
)
__TS__SparseArrayPush(
____array_0,
table.unpack(geometry.pointSize > 0 and createSeriesPoints(
nil,
context,
geometry,
series,
points,
color
) or ({}))
)
return {__TS__SparseArraySpread(____array_0)}
end
function seriesPoints(self, series, context, geometry)
local values = series.values
return __TS__ArrayMap(
geometry.categories,
function(____, _, categoryIndex) return geometry:pointAt(
geometry:radiusForValue(values[categoryIndex + 1] or context.chart.axisY.min),
categoryIndex
) end
)
end
function createSeriesFill(self, context, geometry, series, path, color)
local ____context_1 = context
local chart = ____context_1.chart
local bounds = ____context_1.bounds
local diagnostics = ____context_1.diagnostics
local nextOrder = ____context_1.nextOrder
return {
type = "path",
id = (("chart-radar-fill-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil),
bounds = bounds,
d = path,
detail = {of = "chartSeries", series = series.id},
style = {
fill = paint(nil, color, diagnostics, chart.id),
stroke = {kind = "none"},
opacity = math.max(
0,
math.min(1, series.opacity or geometry.areaOpacity)
)
}
}
end
function createSeriesStroke(self, context, geometry, series, path, color)
local ____context_2 = context
local chart = ____context_2.chart
local bounds = ____context_2.bounds
local diagnostics = ____context_2.diagnostics
local nextOrder = ____context_2.nextOrder
return {
type = "path",
id = (("chart-radar-series-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil),
bounds = bounds,
d = path,
detail = {of = "chartSeries", series = series.id},
style = {
fill = {kind = "none"},
stroke = paint(nil, color, diagnostics, chart.id),
strokeWidth = geometry.strokeWidth,
lineJoin = "round",
shadow = resolveChartShadow(nil, chart.shadowStyle)
}
}
end
function createSeriesPoints(self, context, geometry, series, points, color)
local ____context_3 = context
local chart = ____context_3.chart
local bounds = ____context_3.bounds
local diagnostics = ____context_3.diagnostics
local nextOrder = ____context_3.nextOrder
return __TS__ArrayMap(
points,
function(____, point, pointIndex) return {
type = "ellipse",
id = (((("chart-radar-point-" .. chart.id) .. "-") .. series.id) .. "-") .. tostring(pointIndex),
order = nextOrder(nil),
bounds = bounds,
cx = point.x,
cy = point.y,
rx = geometry.pointSize,
ry = geometry.pointSize,
detail = {of = "chartValue", series = series.id, valueIndex = pointIndex, mark = "radar-vertex"},
prop = seriesValueProp(nil, series.id, pointIndex),
style = {fill = paint(nil, color, diagnostics, chart.id)}
} end
)
end
function ____exports.renderRadarSeries(self, context, geometry)
local nodes = {}
__TS__ArrayForEach(
context.chart.series,
function(____, series, seriesIndex)
__TS__ArrayPushArray(
nodes,
renderSeries(
nil,
context,
geometry,
series,
seriesIndex
)
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.radar"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____geometry = require("core.renderScene.charts.renderers.radar.geometry")
local createRadarGeometry = ____geometry.createRadarGeometry
local ____grid = require("core.renderScene.charts.renderers.radar.grid")
local renderRadarGrid = ____grid.renderRadarGrid
local ____labels = require("core.renderScene.charts.renderers.radar.labels")
local renderRadarLabels = ____labels.renderRadarLabels
local ____series = require("core.renderScene.charts.renderers.radar.series")
local renderRadarSeries = ____series.renderRadarSeries
function ____exports.renderRadar(self, context)
local geometry = createRadarGeometry(nil, context)
local nodes = {}
__TS__ArrayPushArray(
nodes,
renderRadarGrid(nil, context, geometry)
)
__TS__ArrayPushArray(
nodes,
renderRadarLabels(nil, context, geometry)
)
__TS__ArrayPushArray(
nodes,
renderRadarSeries(nil, context, geometry)
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.radialBar"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __hypot = ______shims.__hypot
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local resolveChartShadow = ____primitives.resolveChartShadow
local ____propPath = require("core.renderScene.charts.propPath")
local seriesValueProp = ____propPath.seriesValueProp
local TOP = -math.pi / 2
local DEFAULT_RING_THICKNESS = 14
local DEFAULT_RING_GAP = 4
local TRACK_OPACITY = 0.18
local FULL_SWEEP_EPSILON = 0.0001
local function arcPoint(self, cx, cy, r, angle)
return {
x = cx + r * math.cos(angle),
y = cy + r * math.sin(angle)
}
end
local function fullCirclePath(self, cx, cy, r)
return ((((((((((((((((((("M " .. tostring(cx - r)) .. " ") .. tostring(cy)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 1 0 ") .. tostring(cx + r)) .. " ") .. tostring(cy)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 1 0 ") .. tostring(cx - r)) .. " ") .. tostring(cy)) .. " Z"
end
local function annulusPath(self, cx, cy, outerRadius, innerRadius)
return (fullCirclePath(nil, cx, cy, outerRadius) .. " ") .. fullCirclePath(
nil,
cx,
cy,
math.max(0, innerRadius)
)
end
local function arcSegmentPath(self, cx, cy, r, from, to)
local start = arcPoint(
nil,
cx,
cy,
r,
from
)
local ____end = arcPoint(
nil,
cx,
cy,
r,
to
)
return (((((((((((("M " .. tostring(start.x)) .. " ") .. tostring(start.y)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 ") .. tostring(to - from > math.pi and 1 or 0)) .. " 1 ") .. tostring(____end.x)) .. " ") .. tostring(____end.y)
end
local function ringShadow(self, shadow, ringThickness)
local blur = math.min(shadow.blur, ringThickness * 0.6)
local maxDistance = ringThickness * 0.4
local distance = __hypot(nil, shadow.dx, shadow.dy)
local scale = distance > maxDistance and maxDistance / distance or 1
return __TS__ObjectAssign({}, shadow, {blur = blur, dx = shadow.dx * scale, dy = shadow.dy * scale})
end
local function ringProgressPath(self, cx, cy, r, sweep, from)
if sweep >= math.pi * 2 - FULL_SWEEP_EPSILON then
local start = arcPoint(
nil,
cx,
cy,
r,
from
)
local mid = arcPoint(
nil,
cx,
cy,
r,
from + math.pi
)
return (((((((((((((((((("M " .. tostring(start.x)) .. " ") .. tostring(start.y)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 1 1 ") .. tostring(mid.x)) .. " ") .. tostring(mid.y)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 1 1 ") .. tostring(start.x)) .. " ") .. tostring(start.y)
end
local start = arcPoint(
nil,
cx,
cy,
r,
from
)
local ____end = arcPoint(
nil,
cx,
cy,
r,
from + sweep
)
local largeArc = sweep > math.pi and 1 or 0
return (((((((((((("M " .. tostring(start.x)) .. " ") .. tostring(start.y)) .. " A ") .. tostring(r)) .. " ") .. tostring(r)) .. " 0 ") .. tostring(largeArc)) .. " 1 ") .. tostring(____end.x)) .. " ") .. tostring(____end.y)
end
local function layoutOf(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local axisMin = finite(nil, chart.axisY.min, 0)
local ____temp_18 = plot.x + plot.width / 2
local ____temp_19 = plot.y + plot.height / 2
local ____math_max_result_20 = math.max(
1,
math.min(plot.width, plot.height) / 2 - 4
)
local ____finite_3 = finite
local ____opt_1 = chart.config
local ____math_max_result_21 = math.max(
1,
____finite_3(nil, ____opt_1 and ____opt_1.ringThickness, DEFAULT_RING_THICKNESS)
)
local ____finite_6 = finite
local ____opt_4 = chart.config
local ____math_max_result_22 = math.max(
0,
____finite_6(nil, ____opt_4 and ____opt_4.ringGap, DEFAULT_RING_GAP)
)
local ____axisMin_23 = axisMin
local ____temp_24 = finite(nil, chart.axisY.max, 100) - axisMin
local ____finite_9 = finite
local ____opt_7 = chart.config
local ____temp_25 = TOP + ____finite_9(nil, ____opt_7 and ____opt_7.ringStartAngle, 0) * math.pi / 180
local ____finite_12 = finite
local ____opt_10 = chart.config
local ____temp_26 = math.min(
360,
math.max(
1,
____finite_12(nil, ____opt_10 and ____opt_10.ringSweep, 360)
)
) * math.pi / 180
local ____finite_15 = finite
local ____opt_13 = chart.config
local ____math_min_result_27 = math.min(
1,
math.max(
0,
____finite_15(nil, ____opt_13 and ____opt_13.ringTrackOpacity, TRACK_OPACITY)
)
)
local ____opt_16 = chart.config
return {
centerX = ____temp_18,
centerY = ____temp_19,
outerRadius = ____math_max_result_20,
ringThickness = ____math_max_result_21,
ringGap = ____math_max_result_22,
axisMin = ____axisMin_23,
range = ____temp_24,
start = ____temp_25,
total = ____temp_26,
trackOpacity = ____math_min_result_27,
cap = ____opt_16 and ____opt_16.ringCap or "round"
}
end
local function ringEndShadows(self, context, layout, series, radius, sweep, color)
local ____context_28 = context
local chart = ____context_28.chart
local bounds = ____context_28.bounds
local nextOrder = ____context_28.nextOrder
local ____layout_29 = layout
local centerX = ____layout_29.centerX
local centerY = ____layout_29.centerY
local ringThickness = ____layout_29.ringThickness
local start = ____layout_29.start
local shadow = resolveChartShadow(nil, chart.shadowStyle)
local isFullCircle = sweep >= math.pi * 2 - FULL_SWEEP_EPSILON
if not shadow or isFullCircle then
return {}
end
local clampedShadow = ringShadow(nil, shadow, ringThickness)
local stubSweep = math.min(sweep, ringThickness / radius)
return __TS__ArrayMap(
{{start, start + stubSweep}, {start + sweep - stubSweep, start + sweep}},
function(____, ____bindingPattern0, endIndex)
local to
local from
from = ____bindingPattern0[1]
to = ____bindingPattern0[2]
return {
type = "path",
id = (((("chart-radial-bar-ring-end-shadow-" .. chart.id) .. "-") .. series.id) .. "-") .. tostring(endIndex),
order = nextOrder(nil),
bounds = bounds,
d = arcSegmentPath(
nil,
centerX,
centerY,
radius,
from,
to
),
style = {
fill = {kind = "none"},
stroke = color,
strokeWidth = ringThickness,
lineCap = layout.cap,
shadow = clampedShadow,
clip = {
type = "path",
d = annulusPath(
nil,
centerX,
centerY,
radius + ringThickness / 2,
radius - ringThickness / 2
)
}
}
}
end
)
end
local function ringNodes(self, context, layout, series, index)
local ____context_30 = context
local chart = ____context_30.chart
local bounds = ____context_30.bounds
local diagnostics = ____context_30.diagnostics
local nextOrder = ____context_30.nextOrder
local ____layout_31 = layout
local centerX = ____layout_31.centerX
local centerY = ____layout_31.centerY
local outerRadius = ____layout_31.outerRadius
local ringThickness = ____layout_31.ringThickness
local ringGap = ____layout_31.ringGap
local axisMin = ____layout_31.axisMin
local range = ____layout_31.range
local start = ____layout_31.start
local total = ____layout_31.total
local trackOpacity = ____layout_31.trackOpacity
local cap = ____layout_31.cap
local radius = outerRadius - index * (ringThickness + ringGap) - ringThickness / 2
if radius <= ringThickness / 2 then
return {}
end
local color = paint(nil, series.color or CHART_COLORS[index % #CHART_COLORS + 1], diagnostics, chart.id)
local value = math.max(
0,
finite(nil, series.values[1], 0)
)
local fraction = range > 0 and math.min(
1,
math.max(0, (value - axisMin) / range)
) or 0
local trackStyle = {fill = {kind = "none"}, stroke = color, strokeWidth = ringThickness, opacity = trackOpacity}
local track = total >= math.pi * 2 - FULL_SWEEP_EPSILON and ({
type = "ellipse",
id = (("chart-radial-bar-track-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil),
bounds = bounds,
cx = centerX,
cy = centerY,
rx = radius,
ry = radius,
style = trackStyle
}) or ({
type = "path",
id = (("chart-radial-bar-track-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil),
bounds = bounds,
d = arcSegmentPath(
nil,
centerX,
centerY,
radius,
start,
start + total
),
style = __TS__ObjectAssign({}, trackStyle, {lineCap = cap})
})
if fraction <= 0 then
return {track}
end
local sweep = fraction * total
local casters = ringEndShadows(
nil,
context,
layout,
series,
radius,
sweep,
color
)
local progress = {
type = "path",
id = (("chart-radial-bar-ring-" .. chart.id) .. "-") .. series.id,
order = nextOrder(nil),
bounds = bounds,
d = ringProgressPath(
nil,
centerX,
centerY,
radius,
sweep,
start
),
detail = {of = "chartValue", series = series.id, valueIndex = 0, mark = "radial-bar-ring"},
prop = seriesValueProp(nil, series.id, 0),
style = {fill = {kind = "none"}, stroke = color, strokeWidth = ringThickness, lineCap = cap}
}
local ____array_32 = __TS__SparseArrayNew(
track,
table.unpack(casters)
)
__TS__SparseArrayPush(____array_32, progress)
return {__TS__SparseArraySpread(____array_32)}
end
function ____exports.renderRadialBar(self, context)
local layout = layoutOf(nil, context)
return __TS__ArrayFlatMap(
context.chart.series,
function(____, series, index) return ringNodes(
nil,
context,
layout,
series,
index
) end
)
end
return ____exports
end,
["core.renderScene.charts.renderers.sankey.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.renderers.sankey.links"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local createSankeyLinkRibbon, createSankeyRibbonNode, sankeyRibbonPath
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local DEFAULT_ZONE_FILL = ____primitives.DEFAULT_ZONE_FILL
local resolveChartShadow = ____primitives.resolveChartShadow
function createSankeyLinkRibbon(self, context, data, link, linkIndex, gradient)
local source = {x = data.baseX + link.x0, top = data.baseY + link.sourceY0, bottom = data.baseY + link.sourceY1}
local target = {x = data.baseX + link.x1, top = data.baseY + link.targetY0, bottom = data.baseY + link.targetY1}
local config = context.chart.config
local fromColor = __lor(
nil,
__lor(
nil,
link.color,
function() return data.nodeColors:get(link.source) end
),
function() return DEFAULT_ZONE_FILL end
)
local toColor = __lor(
nil,
data.nodeColors:get(link.target),
function() return DEFAULT_ZONE_FILL end
)
local fill = gradient and ({kind = "linear-gradient", angle = 0, stops = {{offset = 0, color = fromColor}, {offset = 100, color = toColor}}}) or ({
kind = "solid",
color = __lor(
nil,
link.color,
function() return toColor end
)
})
return {
linkIndex = linkIndex,
fromId = link.source,
toId = link.target,
source = source,
target = target,
controlX = source.x + (target.x - source.x) * math.min(
1,
math.max(
0,
finite(nil, config and config.sankeyLinkCurve, 0.5)
)
),
fill = fill,
opacity = math.min(
1,
math.max(
0,
finite(
nil,
config and config.sankeyLinkOpacity,
__t(nil, link.color) and 0.85 or 0.45
)
)
)
}
end
function createSankeyRibbonNode(self, context, ribbon, shadow, clipPath, gradient)
local ____context_8 = context
local chart = ____context_8.chart
local bounds = ____context_8.bounds
local nextOrder = ____context_8.nextOrder
local gradientBounds = {
minX = math.min(ribbon.source.x, ribbon.target.x),
maxX = math.max(ribbon.source.x, ribbon.target.x),
minY = math.min(ribbon.source.top, ribbon.target.top),
maxY = math.max(ribbon.source.bottom, ribbon.target.bottom)
}
return {
type = "path",
id = (("chart-sankey-link-" .. chart.id) .. "-") .. tostring(ribbon.linkIndex),
order = nextOrder(nil),
bounds = gradient and gradientBounds or bounds,
d = sankeyRibbonPath(nil, ribbon),
detail = {of = "link", fromId = ribbon.fromId, toId = ribbon.toId},
style = {
fill = ribbon.fill,
opacity = ribbon.opacity,
shadow = shadow,
clip = __t(nil, clipPath) and ({type = "path", d = clipPath}) or nil
}
}
end
function sankeyRibbonPath(self, ribbon)
local ____ribbon_9 = ribbon
local source = ____ribbon_9.source
local target = ____ribbon_9.target
local controlX = ____ribbon_9.controlX
return table.concat(
{
(("M " .. tostring(source.x)) .. " ") .. tostring(source.top),
(((((((((("C " .. tostring(controlX)) .. " ") .. tostring(source.top)) .. " ") .. tostring(controlX)) .. " ") .. tostring(target.top)) .. " ") .. tostring(target.x)) .. " ") .. tostring(target.top),
(("L " .. tostring(target.x)) .. " ") .. tostring(target.bottom),
(((((((((("C " .. tostring(controlX)) .. " ") .. tostring(target.bottom)) .. " ") .. tostring(controlX)) .. " ") .. tostring(source.bottom)) .. " ") .. tostring(source.x)) .. " ") .. tostring(source.bottom),
"Z"
},
" "
)
end
function ____exports.renderSankeyLinks(self, context, data)
local shadow = resolveChartShadow(nil, context.chart.shadowStyle)
local ____Boolean_2 = Boolean
local ____opt_0 = context.chart.config
local gradient = ____Boolean_2(nil, ____opt_0 and ____opt_0.linkGradient)
local ____context_3 = context
local plot = ____context_3.plot
local clipPath = shadow and ((((((((("M " .. tostring(plot.x)) .. " ") .. tostring(plot.y)) .. " H ") .. tostring(plot.x + plot.width)) .. " V ") .. tostring(plot.y + plot.height)) .. " H ") .. tostring(plot.x)) .. " Z" or nil
return __TS__ArrayMap(
data.links,
function(____, link, linkIndex)
local ribbon = createSankeyLinkRibbon(
nil,
context,
data,
link,
linkIndex,
gradient
)
return createSankeyRibbonNode(
nil,
context,
ribbon,
shadow,
clipPath,
gradient
)
end
)
end
return ____exports
end,
["core.renderScene.charts.renderers.sankey.nodes"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local createNodeRect, createNodeLabel, createOutsideLabel, createInsideLabel, OUTSIDE_LABEL_LIGHTNESS_ON_LIGHT_BG, OUTSIDE_LABEL_LIGHTNESS_ON_DARK_BG
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local ____containers = require("core.renderScene.artifacts.containers")
local leftRoundedRectPath = ____containers.leftRoundedRectPath
local rightRoundedRectPath = ____containers.rightRoundedRectPath
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____textLayout = require("core.renderScene.scene.textLayout")
local estimateTextWidth = ____textLayout.estimateTextWidth
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local contrastTextColor = ____primitives.contrastTextColor
local DEFAULT_ZONE_FILL = ____primitives.DEFAULT_ZONE_FILL
local isLightColor = ____primitives.isLightColor
local resolveChartShadow = ____primitives.resolveChartShadow
local sameHueTint = ____primitives.sameHueTint
function createNodeRect(self, context, data, node, cornerRadius)
local ____context_4 = context
local chart = ____context_4.chart
local bounds = ____context_4.bounds
local nextOrder = ____context_4.nextOrder
local x = data.baseX + node.x
local y = data.baseY + node.y
local style = {
fill = {
kind = "solid",
color = __lor(
nil,
node.color,
function() return DEFAULT_ZONE_FILL end
)
},
shadow = resolveChartShadow(nil, chart.shadowStyle)
}
local isFirstColumn = node.column == 0
local isLastColumn = node.column == data.columnCount - 1
local detail = {of = "chartSeries", series = node.id, mark = "sankey-node"}
if cornerRadius > 0 and isFirstColumn and isLastColumn then
return {
type = "rect",
id = (("chart-sankey-node-" .. chart.id) .. "-") .. node.id,
order = nextOrder(nil),
bounds = bounds,
x = x,
y = y,
width = node.width,
height = node.height,
rx = cornerRadius,
style = style,
detail = detail
}
end
if cornerRadius > 0 and isFirstColumn then
return {
type = "path",
id = (("chart-sankey-node-" .. chart.id) .. "-") .. node.id,
order = nextOrder(nil),
bounds = bounds,
d = leftRoundedRectPath(
nil,
x,
y,
node.width,
node.height,
cornerRadius
),
style = style,
detail = detail
}
end
if cornerRadius > 0 and isLastColumn then
return {
type = "path",
id = (("chart-sankey-node-" .. chart.id) .. "-") .. node.id,
order = nextOrder(nil),
bounds = bounds,
d = rightRoundedRectPath(
nil,
x,
y,
node.width,
node.height,
cornerRadius
),
style = style,
detail = detail
}
end
return {
type = "rect",
id = (("chart-sankey-node-" .. chart.id) .. "-") .. node.id,
order = nextOrder(nil),
bounds = bounds,
x = x,
y = y,
width = node.width,
height = node.height,
style = style,
detail = detail
}
end
function createNodeLabel(self, context, data, node)
local ____context_5 = context
local chart = ____context_5.chart
local ____opt_6 = chart.config
local position = ____opt_6 and ____opt_6.labelPosition or "outside"
local ____temp_12
if position == "inside" then
local ____createInsideLabel_11 = createInsideLabel
local ____array_10 = __TS__SparseArrayNew(nil, context, data, node)
local ____opt_8 = chart.config
__TS__SparseArrayPush(____array_10, ____opt_8 and ____opt_8.labelOrientation or "horizontal")
____temp_12 = ____createInsideLabel_11(__TS__SparseArraySpread(____array_10))
else
____temp_12 = createOutsideLabel(nil, context, data, node)
end
local label = ____temp_12
if not label then
return nil
end
local fallback = chart.textColor or "#0f172a"
local defaultColor = position == "inside" and contrastTextColor(nil, node.color) or (sameHueTint(
nil,
node.color,
isLightColor(nil, fallback) and OUTSIDE_LABEL_LIGHTNESS_ON_DARK_BG or OUTSIDE_LABEL_LIGHTNESS_ON_LIGHT_BG
) or fallback)
local ____opt_13 = chart.config
local color = ____opt_13 and ____opt_13.labelColor or defaultColor
return __TS__ObjectAssign({}, label, {color = color, detail = {of = "chartSeries", series = node.id, mark = "sankey-node-label"}})
end
function createOutsideLabel(self, context, data, node)
local ____context_15 = context
local chart = ____context_15.chart
local bounds = ____context_15.bounds
local nextOrder = ____context_15.nextOrder
local isLastColumn = node.column == data.columnCount - 1
local x = data.baseX + node.x
local y = data.baseY + node.y
local labelX = isLastColumn and x - data.labelGutter + 8 or x + node.width + 6
return __TS__ObjectAssign(
{},
chartText(
nil,
{
id = (("chart-sankey-label-" .. chart.id) .. "-") .. node.id,
order = nextOrder(nil),
bounds = bounds,
frame = {
x = labelX,
y = y,
width = data.labelGutter - 12,
height = math.max(1, node.height)
},
text = node.label,
chart = chart,
align = isLastColumn and "right" or "left"
}
),
{fontSize = data.labelSize, fontWeight = "bold", verticalAlign = "middle"}
)
end
function createInsideLabel(self, context, data, node, orientation)
local ____context_16 = context
local chart = ____context_16.chart
local bounds = ____context_16.bounds
local nextOrder = ____context_16.nextOrder
local x = data.baseX + node.x
local y = data.baseY + node.y
local centerX = x + node.width / 2
local centerY = y + node.height / 2
local fontSize = data.labelSize
local id = (("chart-sankey-label-" .. chart.id) .. "-") .. node.id
if orientation == "vertical" then
local thickness = fontSize * 1.4
local width = math.max(1, node.height - 8)
if estimateTextWidth(nil, node.label, fontSize, false) > width then
return nil
end
return __TS__ObjectAssign(
{},
chartText(
nil,
{
id = id,
order = nextOrder(nil),
bounds = bounds,
frame = {x = centerX - width / 2, y = centerY - thickness / 2, width = width, height = thickness},
text = node.label,
chart = chart,
align = "center",
rotation = -90
}
),
{fontSize = fontSize, fontWeight = "bold", verticalAlign = "middle", rotationCenter = {x = centerX, y = centerY}}
)
end
return __TS__ObjectAssign(
{},
chartText(
nil,
{
id = id,
order = nextOrder(nil),
bounds = bounds,
frame = {
x = x + 4,
y = centerY - fontSize / 2 - 2,
width = math.max(1, node.width - 8),
height = fontSize + 4
},
text = node.label,
chart = chart,
align = "center"
}
),
{fontSize = fontSize, fontWeight = "bold", verticalAlign = "middle"}
)
end
OUTSIDE_LABEL_LIGHTNESS_ON_LIGHT_BG = 0.3
OUTSIDE_LABEL_LIGHTNESS_ON_DARK_BG = 0.78
function ____exports.renderSankeyNodes(self, context, data)
local ____finite_2 = finite
local ____opt_0 = context.chart.config
local cornerRadius = math.max(
0,
____finite_2(nil, ____opt_0 and ____opt_0.barCornerRadius, 0)
)
local nodes = {}
__TS__ArrayForEach(
data.nodes,
function(____, node)
nodes[#nodes + 1] = createNodeRect(
nil,
context,
data,
node,
cornerRadius
)
local ____context_showLabels_3
if context.showLabels then
____context_showLabels_3 = createNodeLabel(nil, context, data, node)
else
____context_showLabels_3 = nil
end
local label = ____context_showLabels_3
if label then
nodes[#nodes + 1] = label
end
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.sankey.prepare"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local createNodeInputs, createLinkInputs
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____sankey = require("core.renderScene.charts.geometry.sankey.index")
local layoutSankey = ____sankey.layoutSankey
local ____primitives = require("core.renderScene.charts.primitives.index")
local DEFAULT_ZONE_FILL = ____primitives.DEFAULT_ZONE_FILL
local representativeColor = ____primitives.representativeColor
function createNodeInputs(self, context)
local ____opt_17 = context.chart.config
return __TS__ArrayMap(
____opt_17 and ____opt_17.zones or ({}),
function(____, zone) return {
id = zone.label,
label = zone.label,
color = zone.color,
offsetX = zone.offsetX,
offsetY = zone.offsetY
} end
)
end
function createLinkInputs(self, context)
local inputs = {}
__TS__ArrayForEach(
context.chart.series,
function(____, series)
if not __t(nil, series.source) or not __t(nil, series.target) then
return
end
inputs[#inputs + 1] = {
source = series.source,
target = series.target,
value = series.values[1] or 0,
color = __t(nil, series.color) and representativeColor(nil, series.color, DEFAULT_ZONE_FILL) or nil
}
end
)
return inputs
end
function ____exports.createSankeyRenderData(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local showLabels = ____context_0.showLabels
local labelGutter = showLabels and 92 or 0
local availableWidth = math.max(1, plot.width - labelGutter * 2)
local ____layoutSankey_9 = layoutSankey
local ____array_8 = __TS__SparseArrayNew(
nil,
createNodeInputs(nil, context),
createLinkInputs(nil, context),
availableWidth,
plot.height
)
local ____finite_3 = finite
local ____opt_1 = chart.config
local ____math_max_result_7 = math.max(
1,
____finite_3(nil, ____opt_1 and ____opt_1.sankeyNodeWidth, 18)
)
local ____finite_6 = finite
local ____opt_4 = chart.config
__TS__SparseArrayPush(
____array_8,
{
nodeWidth = ____math_max_result_7,
nodeGap = math.max(
0,
____finite_6(nil, ____opt_4 and ____opt_4.sankeyNodeGap, 8)
)
}
)
local layout = ____layoutSankey_9(__TS__SparseArraySpread(____array_8))
local ____temp_13 = plot.x + labelGutter
local ____plot_y_14 = plot.y
local ____labelGutter_15 = labelGutter
local ____math_max_result_16 = math.max(
9,
finite(nil, chart.fontSize, 12)
)
local ____finite_12 = finite
local ____opt_10 = chart.config
return __TS__ObjectAssign(
{},
layout,
{
baseX = ____temp_13,
baseY = ____plot_y_14,
labelGutter = ____labelGutter_15,
fontSize = ____math_max_result_16,
labelSize = math.max(
6,
____finite_12(
nil,
____opt_10 and ____opt_10.sankeyLabelSize,
math.max(
9,
finite(nil, chart.fontSize, 12)
) - 2
)
),
columnCount = math.max(
1,
table.unpack(__TS__ArrayMap(
layout.nodes,
function(____, node) return node.column + 1 end
))
),
nodeColors = __TS__New(
Map,
__TS__ArrayMap(
layout.nodes,
function(____, node) return {
node.id,
__lor(
nil,
node.color,
function() return DEFAULT_ZONE_FILL end
)
} end
)
)
}
)
end
return ____exports
end,
["core.renderScene.charts.renderers.sankey"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____links = require("core.renderScene.charts.renderers.sankey.links")
local renderSankeyLinks = ____links.renderSankeyLinks
local ____nodes = require("core.renderScene.charts.renderers.sankey.nodes")
local renderSankeyNodes = ____nodes.renderSankeyNodes
local ____prepare = require("core.renderScene.charts.renderers.sankey.prepare")
local createSankeyRenderData = ____prepare.createSankeyRenderData
function ____exports.renderSankey(self, context)
local data = createSankeyRenderData(nil, context)
local nodes = {}
__TS__ArrayPushArray(
nodes,
renderSankeyLinks(nil, context, data)
)
__TS__ArrayPushArray(
nodes,
renderSankeyNodes(nil, context, data)
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.scatter"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local ____exports = {}
local createScatterPoint, DEFAULT_POINT_SIZE
local ____scene = require("core.renderScene.scene.index")
local paint = ____scene.paint
local ____primitives = require("core.renderScene.charts.primitives.index")
local CHART_COLORS = ____primitives.CHART_COLORS
local resolveChartShadow = ____primitives.resolveChartShadow
local ____cartesianPoints = require("core.renderScene.charts.renderers.cartesianPoints")
local pixelPoints = ____cartesianPoints.pixelPoints
local seriesValuePairs = ____cartesianPoints.seriesValuePairs
function createScatterPoint(self, context, series, point, pointIndex, color, shadow)
local ____context_0 = context
local chart = ____context_0.chart
local bounds = ____context_0.bounds
local diagnostics = ____context_0.diagnostics
local nextOrder = ____context_0.nextOrder
local config = chart.config
local radius = config and config.pointSize or DEFAULT_POINT_SIZE
local strokeWidth = config and config.pointStrokeWidth or 0
return {
type = "ellipse",
id = (((("chart-point-" .. chart.id) .. "-") .. series.id) .. "-") .. tostring(pointIndex),
order = nextOrder(nil),
bounds = bounds,
cx = point.x,
cy = point.y,
rx = radius,
ry = radius,
detail = {of = "chartValue", series = series.id, valueIndex = pointIndex},
style = {
fill = paint(nil, color, diagnostics, chart.id),
stroke = strokeWidth > 0 and paint(nil, config and config.pointStrokeColor or color, diagnostics, chart.id) or nil,
strokeWidth = strokeWidth > 0 and strokeWidth or nil,
opacity = config and config.pointOpacity,
shadow = shadow
}
}
end
DEFAULT_POINT_SIZE = 4
function ____exports.renderScatter(self, context)
local nodes = {}
local shadow = resolveChartShadow(nil, context.chart.shadowStyle)
__TS__ArrayForEach(
context.chart.series,
function(____, series, seriesIndex)
local color = series.color or CHART_COLORS[seriesIndex % #CHART_COLORS + 1]
local points = pixelPoints(
nil,
context,
seriesValuePairs(nil, context.chart, series)
)
__TS__ArrayForEach(
points,
function(____, point, pointIndex)
nodes[#nodes + 1] = createScatterPoint(
nil,
context,
series,
point,
pointIndex,
color,
shadow
)
end
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.treemap.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.renderScene.charts.renderers.treemap.layout"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local axisBands = ____primitives.axisBands
local DEFAULT_HEATMAP_ZONES = ____primitives.DEFAULT_HEATMAP_ZONES
local zoneColorAtValue = ____primitives.zoneColorAtValue
function ____exports.createTreemapLayout(self, context)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local showLegend = ____context_0.showLegend
local fontSize = math.max(
9,
finite(nil, chart.fontSize, 12)
)
local legendPosition = chart.legendPosition == "left" and "left" or (chart.legendPosition == "right" and "right" or "bottom")
local legendHeight = showLegend and legendPosition == "bottom" and 48 or 0
local ____finite_3 = finite
local ____opt_1 = chart.config
local cellGap = math.max(
0,
____finite_3(nil, ____opt_1 and ____opt_1.cellGap, 0)
)
local ____chart_series_24 = chart.series
local ____axisBands_result_25 = axisBands(nil, chart.axisY)
local ____t_8 = __t
local ____opt_6 = chart.config
local ____opt_4 = ____opt_6 and ____opt_6.zones
local ____temp_26 = ____t_8(nil, ____opt_4 and #____opt_4) and chart.config.zones or DEFAULT_HEATMAP_ZONES
local ____fontSize_27 = fontSize
local ____math_max_result_28 = math.max(8, fontSize - 1)
local ____legendPosition_29 = legendPosition
local ____legendHeight_30 = legendHeight
local ____math_max_result_31 = math.max(1, plot.width)
local ____math_max_result_32 = math.max(1, plot.height - legendHeight)
local ____cellGap_33 = cellGap
local ____finite_11 = finite
local ____opt_9 = chart.config
local ____math_max_result_34 = math.max(
0,
____finite_11(nil, ____opt_9 and ____opt_9.barCornerRadius, cellGap)
)
local ____finite_14 = finite
local ____opt_12 = chart.config
local ____math_max_result_35 = math.max(
0,
____finite_14(nil, ____opt_12 and ____opt_12.headerHeight, 20)
)
local ____finite_17 = finite
local ____opt_15 = chart.config
local ____math_max_result_36 = math.max(
6,
____finite_17(
nil,
____opt_15 and ____opt_15.tileLabelSize,
math.max(8, fontSize - 1)
)
)
local ____finite_20 = finite
local ____opt_18 = chart.config
local ____math_max_result_37 = math.max(
6,
____finite_20(
nil,
____opt_18 and ____opt_18.tileValueSize,
math.max(8, fontSize - 1)
)
)
local ____finite_23 = finite
local ____opt_21 = chart.config
return {
leaves = ____chart_series_24,
bands = ____axisBands_result_25,
zones = ____temp_26,
fontSize = ____fontSize_27,
smallFontSize = ____math_max_result_28,
legendPosition = ____legendPosition_29,
legendHeight = ____legendHeight_30,
gridWidth = ____math_max_result_31,
gridHeight = ____math_max_result_32,
cellGap = ____cellGap_33,
cellRadius = ____math_max_result_34,
headerHeight = ____math_max_result_35,
labelSize = ____math_max_result_36,
valueSize = ____math_max_result_37,
labelPadding = math.max(
0,
____finite_23(nil, ____opt_21 and ____opt_21.tileLabelPadding, 4)
)
}
end
function ____exports.treemapLeafValue(self, leaf)
return leaf.values[1] or 0
end
function ____exports.treemapLeafColor(self, leaf, layout)
return leaf.color or zoneColorAtValue(
nil,
____exports.treemapLeafValue(nil, leaf),
layout.bands,
layout.zones
)
end
return ____exports
end,
["core.renderScene.charts.renderers.treemap.legend"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local bandRatio, bandStops, renderBottomLegend, renderSideLegend, BAR_THICKNESS, TICK_LENGTH, ROW_GAP, CHART_GAP, LABEL_SIZE
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local boxBounds = ____scene.boxBounds
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local DEFAULT_ZONE_FILL = ____primitives.DEFAULT_ZONE_FILL
local formatFieldValue = ____primitives.formatFieldValue
function bandRatio(self, layout, value)
local first = layout.bands[1]
local last = layout.bands[#layout.bands]
return last == first and 0 or (value - first) / (last - first)
end
function bandStops(self, layout)
local bandCount = math.max(0, #layout.bands - 1)
local zones = __TS__ArraySlice(layout.zones, 0, bandCount)
return __TS__ArrayMap(
zones,
function(____, zone, index) return {
offset = bandRatio(nil, layout, layout.bands[index + 1 + 1] or layout.bands[#layout.bands]) * 100,
color = zone.color or DEFAULT_ZONE_FILL
} end
)
end
function renderBottomLegend(self, context, layout)
local ____context_0 = context
local chart = ____context_0.chart
local plot = ____context_0.plot
local bounds = ____context_0.bounds
local nextOrder = ____context_0.nextOrder
local barX = plot.x
local barWidth = layout.gridWidth
local labelHeight = layout.fontSize + 2
local barY = plot.y + layout.gridHeight + CHART_GAP
local barBounds = boxBounds(nil, {x = barX, y = barY, width = barWidth, height = BAR_THICKNESS})
local stops = bandStops(nil, layout)
local bar = {
type = "rect",
id = "chart-treemap-legend-bar-" .. chart.id,
order = nextOrder(nil),
bounds = barBounds,
x = barX,
y = barY,
width = barWidth,
height = BAR_THICKNESS,
rx = 3,
zoneGradient = {axis = "y", min = chart.axisY.min, max = chart.axisY.max},
style = {
fill = __t(nil, #stops) and ({kind = "linear-gradient", angle = 0, stops = stops}) or ({kind = "solid", color = DEFAULT_ZONE_FILL}),
stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"},
strokeWidth = 1
}
}
local ticks = __TS__ArrayFlatMap(
layout.bands,
function(____, value, index)
local x = barX + bandRatio(nil, layout, value) * barWidth
local tick = {
type = "path",
id = (("chart-treemap-legend-tick-" .. chart.id) .. "-") .. tostring(index),
order = nextOrder(nil),
bounds = bounds,
d = (((((("M " .. tostring(x)) .. " ") .. tostring(barY + BAR_THICKNESS)) .. " L ") .. tostring(x)) .. " ") .. tostring(barY + BAR_THICKNESS + TICK_LENGTH),
style = {fill = {kind = "none"}, stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"}, strokeWidth = 1}
}
local isFirst = index == 0
local isLast = index == #layout.bands - 1
local align = isFirst and "left" or (isLast and "right" or "center")
local frameX = isFirst and x or (isLast and x - LABEL_SIZE or x - LABEL_SIZE / 2)
local label = chartText(
nil,
{
id = (("chart-treemap-legend-tick-label-" .. chart.id) .. "-") .. tostring(index),
order = nextOrder(nil),
bounds = bounds,
frame = {x = frameX, y = barY + BAR_THICKNESS + TICK_LENGTH + ROW_GAP, width = LABEL_SIZE, height = labelHeight},
text = formatFieldValue(nil, value),
chart = chart,
align = align
}
)
return {tick, label}
end
)
return {
bar,
table.unpack(ticks)
}
end
function renderSideLegend(self, context, layout)
local ____context_1 = context
local chart = ____context_1.chart
local plot = ____context_1.plot
local bounds = ____context_1.bounds
local nextOrder = ____context_1.nextOrder
local side = layout.legendPosition
local barTop = plot.y
local barHeight = layout.gridHeight
local barX = side == "left" and plot.x - CHART_GAP - BAR_THICKNESS or plot.x + layout.gridWidth + CHART_GAP
local barBounds = boxBounds(nil, {x = barX, y = barTop, width = BAR_THICKNESS, height = barHeight})
local stops = bandStops(nil, layout)
local bar = {
type = "rect",
id = "chart-treemap-legend-bar-" .. chart.id,
order = nextOrder(nil),
bounds = barBounds,
x = barX,
y = barTop,
width = BAR_THICKNESS,
height = barHeight,
rx = 3,
zoneGradient = {axis = "y", min = chart.axisY.min, max = chart.axisY.max},
style = {
fill = __t(nil, #stops) and ({kind = "linear-gradient", angle = 270, stops = stops}) or ({kind = "solid", color = DEFAULT_ZONE_FILL}),
stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"},
strokeWidth = 1
}
}
local tickX = side == "left" and barX or barX + BAR_THICKNESS
local tickEndX = side == "left" and tickX - TICK_LENGTH or tickX + TICK_LENGTH
local labelX = side == "left" and tickEndX - ROW_GAP - LABEL_SIZE or tickEndX + ROW_GAP
local ticks = __TS__ArrayFlatMap(
layout.bands,
function(____, value, index)
local y = barTop + (1 - bandRatio(nil, layout, value)) * barHeight
local tick = {
type = "path",
id = (("chart-treemap-legend-tick-" .. chart.id) .. "-") .. tostring(index),
order = nextOrder(nil),
bounds = bounds,
d = (((((("M " .. tostring(tickX)) .. " ") .. tostring(y)) .. " L ") .. tostring(tickEndX)) .. " ") .. tostring(y),
style = {fill = {kind = "none"}, stroke = {kind = "solid", color = chart.gridColor or "#e2e8f0"}, strokeWidth = 1}
}
local label = chartText(
nil,
{
id = (("chart-treemap-legend-tick-label-" .. chart.id) .. "-") .. tostring(index),
order = nextOrder(nil),
bounds = bounds,
frame = {x = labelX, y = y - layout.fontSize / 2, width = LABEL_SIZE, height = layout.fontSize + 2},
text = formatFieldValue(nil, value),
chart = chart,
align = side == "left" and "right" or "left"
}
)
return {tick, label}
end
)
return {
bar,
table.unpack(ticks)
}
end
BAR_THICKNESS = 10
TICK_LENGTH = 4
ROW_GAP = 2
CHART_GAP = 16
LABEL_SIZE = 34
function ____exports.renderTreemapLegend(self, context, layout)
if #layout.zones == 0 or layout.legendPosition == "bottom" and layout.legendHeight <= 0 then
return {}
end
return layout.legendPosition == "bottom" and renderBottomLegend(nil, context, layout) or renderSideLegend(nil, context, layout)
end
return ____exports
end,
["core.renderScene.charts.renderers.treemap.tiles"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local ____exports = {}
local layoutTreemapTiles, renderTreemapHeader, renderTile, createTileNode, createTileLabel
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local paint = ____scene.paint
local ____textLayout = require("core.renderScene.scene.textLayout")
local ellipsizeToWidth = ____textLayout.ellipsizeToWidth
local estimateTextWidth = ____textLayout.estimateTextWidth
local wrapText = ____textLayout.wrapText
local ____geometry = require("core.renderScene.charts.geometry.index")
local squarifyTreemap = ____geometry.squarifyTreemap
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local contrastTextColor = ____primitives.contrastTextColor
local representativeColor = ____primitives.representativeColor
local resolveChartShadow = ____primitives.resolveChartShadow
local ____layout = require("core.renderScene.charts.renderers.treemap.layout")
local treemapLeafColor = ____layout.treemapLeafColor
local treemapLeafValue = ____layout.treemapLeafValue
function layoutTreemapTiles(self, context, layout)
if not __TS__ArraySome(
layout.leaves,
function(____, ...) return __t(
nil,
(function(____, leaf) return leaf.group end)(nil, ...)
) end
) then
local items = __TS__ArrayMap(
layout.leaves,
function(____, leaf) return {
leaf = leaf,
value = treemapLeafValue(nil, leaf)
} end
)
local tiles = squarifyTreemap(nil, items, {x = 0, y = 0, width = layout.gridWidth, height = layout.gridHeight})
return {tiles = tiles, headers = {}}
end
local groupOrder = {}
for ____, leaf in ipairs(layout.leaves) do
local key = leaf.group or ""
if not __TS__ArrayIncludes(groupOrder, key) then
groupOrder[#groupOrder + 1] = key
end
end
local groupItems = __TS__ArrayMap(
groupOrder,
function(____, key) return {
key = key,
label = __lor(
nil,
key,
function() return "Other" end
),
value = __TS__ArrayReduce(
__TS__ArrayFilter(
layout.leaves,
function(____, leaf) return (leaf.group or "") == key end
),
function(____, sum, leaf) return sum + treemapLeafValue(nil, leaf) end,
0
)
} end
)
local groupRects = squarifyTreemap(nil, groupItems, {x = 0, y = 0, width = layout.gridWidth, height = layout.gridHeight})
local groupGap = layout.cellGap
local tiles = {}
local headers = {}
__TS__ArrayForEach(
groupRects,
function(____, groupRect)
local headerHeight = context.showLabels and math.min(layout.headerHeight, groupRect.height) or 0
if context.showLabels then
headers[#headers + 1] = {
key = groupRect.item.key,
label = groupRect.item.label,
x = groupRect.x + groupGap / 2,
y = groupRect.y,
width = math.max(0, groupRect.width - groupGap)
}
end
local innerLeaves = __TS__ArrayFilter(
layout.leaves,
function(____, leaf) return (leaf.group or "") == groupRect.item.key end
)
local leafItems = __TS__ArrayMap(
innerLeaves,
function(____, leaf) return {
leaf = leaf,
value = treemapLeafValue(nil, leaf)
} end
)
__TS__ArrayPushArray(
tiles,
squarifyTreemap(
nil,
leafItems,
{
x = groupRect.x,
y = groupRect.y + headerHeight,
width = groupRect.width,
height = math.max(0, groupRect.height - headerHeight)
}
)
)
end
)
return {tiles = tiles, headers = headers}
end
function renderTreemapHeader(self, context, layout, header, index)
local ____context_4 = context
local chart = ____context_4.chart
local plot = ____context_4.plot
local bounds = ____context_4.bounds
local nextOrder = ____context_4.nextOrder
local ____opt_5 = chart.config
local fill = ____opt_5 and ____opt_5.headerColor or chart.gridColor or "#e2e8f0"
local background = {
type = "rect",
id = (("chart-treemap-header-" .. chart.id) .. "-") .. tostring(index),
order = nextOrder(nil),
bounds = bounds,
x = plot.x + header.x,
y = plot.y + header.y,
width = header.width,
height = layout.headerHeight,
rx = layout.cellRadius,
style = {fill = {kind = "solid", color = fill}}
}
local smallFontSize = math.max(
8,
math.max(9, chart.fontSize or 12) - 1
)
local label = __TS__ObjectAssign(
{},
chartText(
nil,
{
id = (("chart-treemap-header-label-" .. chart.id) .. "-") .. tostring(index),
order = nextOrder(nil),
bounds = bounds,
frame = {x = plot.x + header.x, y = plot.y + header.y + (layout.headerHeight - smallFontSize) / 2, width = header.width, height = smallFontSize + 2},
text = header.label,
chart = chart,
align = "center"
}
),
{
fontSize = smallFontSize,
color = contrastTextColor(nil, fill)
}
)
return {background, label}
end
function renderTile(self, context, layout, tile, nextTile)
local color = treemapLeafColor(nil, tile.item.leaf, layout)
local nextColor = nextTile and treemapLeafColor(nil, nextTile.item.leaf, layout) or nil
local nodes = {createTileNode(
nil,
context,
layout,
tile,
color,
nextColor
)}
if context.showLabels and tile.width >= 34 and tile.height >= 18 then
__TS__ArrayPushArray(
nodes,
createTileLabel(
nil,
context,
layout,
tile,
color
)
)
end
return nodes
end
function createTileNode(self, context, layout, tile, color, nextColor)
local ____context_7 = context
local chart = ____context_7.chart
local plot = ____context_7.plot
local bounds = ____context_7.bounds
local diagnostics = ____context_7.diagnostics
local nextOrder = ____context_7.nextOrder
local gap = layout.cellGap
local shadow = resolveChartShadow(nil, chart.shadowStyle)
local clipPath = shadow and ((((((((("M " .. tostring(plot.x)) .. " ") .. tostring(plot.y)) .. " H ") .. tostring(plot.x + plot.width)) .. " V ") .. tostring(plot.y + plot.height)) .. " H ") .. tostring(plot.x)) .. " Z" or nil
local tileX = plot.x + tile.x + gap / 2
local tileY = plot.y + tile.y + gap / 2
local tileWidth = math.max(0, tile.width - gap)
local tileHeight = math.max(0, tile.height - gap)
local fallback = "#94a3b8"
local gradientBounds = {minX = tileX, maxX = tileX + tileWidth, minY = tileY + tileHeight / 2 - tileWidth / 2, maxY = tileY + tileHeight / 2 + tileWidth / 2}
local fill = __t(nil, nextColor) and ({
kind = "linear-gradient",
angle = 0,
stops = {
{
offset = 0,
color = representativeColor(nil, color, fallback)
},
{
offset = 100,
color = representativeColor(nil, nextColor, fallback)
}
}
}) or paint(nil, color, diagnostics, chart.id)
local ____temp_15 = (("chart-treemap-tile-" .. chart.id) .. "-") .. tile.item.leaf.id
local ____nextOrder_result_16 = nextOrder(nil)
local ____temp_17 = __t(nil, nextColor) and gradientBounds or bounds
local ____layout_cellRadius_18 = layout.cellRadius
local ____fill_13 = fill
local ____opt_8 = chart.config
local ____temp_14 = {kind = "solid", color = ____opt_8 and ____opt_8.tileStrokeColor or chart.gridColor or "#e2e8f0"}
local ____finite_12 = finite
local ____opt_10 = chart.config
return {
type = "rect",
id = ____temp_15,
order = ____nextOrder_result_16,
bounds = ____temp_17,
x = tileX,
y = tileY,
width = tileWidth,
height = tileHeight,
rx = ____layout_cellRadius_18,
style = {
fill = ____fill_13,
stroke = ____temp_14,
strokeWidth = ____finite_12(
nil,
____opt_10 and ____opt_10.tileStrokeWidth,
finite(nil, chart.gridWidth, 1)
),
shadow = shadow,
clip = __t(nil, clipPath) and ({type = "path", d = clipPath}) or nil
}
}
end
function createTileLabel(self, context, layout, tile, color)
local ____context_19 = context
local chart = ____context_19.chart
local plot = ____context_19.plot
local bounds = ____context_19.bounds
local nextOrder = ____context_19.nextOrder
local ____tile_item_20 = tile.item
local leaf = ____tile_item_20.leaf
local value = ____tile_item_20.value
local gap = layout.cellGap
local pad = layout.labelPadding
local width = math.max(1, tile.width - gap - pad * 2)
local height = math.max(1, tile.height - gap - pad * 1.5)
local x = plot.x + tile.x + gap / 2 + pad
local y = plot.y + tile.y + gap / 2 + pad * 0.75
local ____opt_21 = chart.config
local textColor = ____opt_21 and ____opt_21.tileTextColor or contrastTextColor(
nil,
representativeColor(nil, color, "#ffffff")
)
local lineHeight = layout.labelSize * 1.2
local maxLines = math.max(
1,
math.floor(height / lineHeight)
)
local labelLines = __TS__ArrayMap(
__TS__ArraySlice(
wrapText(nil, leaf.label, width, layout.labelSize),
0,
maxLines
),
function(____, line) return ellipsizeToWidth(
nil,
line,
width,
layout.labelSize,
true
) end
)
local label = __TS__ObjectAssign(
{},
chartText(
nil,
{
id = (("chart-treemap-label-" .. chart.id) .. "-") .. leaf.id,
order = nextOrder(nil),
bounds = bounds,
frame = {x = x, y = y, width = width, height = height},
text = leaf.label,
chart = chart
}
),
{lines = labelLines, fontSize = layout.labelSize, fontWeight = "bold", color = textColor}
)
local valueText = tostring(value)
local valueFits = #labelLines * lineHeight + layout.valueSize * 1.2 <= height + 2 and estimateTextWidth(nil, valueText, layout.valueSize, false) <= width
local ____opt_23 = chart.config
if (____opt_23 and ____opt_23.showTileValues) == false or not valueFits then
return {label}
end
local valueNode = __TS__ObjectAssign(
{},
chartText(
nil,
{
id = (("chart-treemap-value-" .. chart.id) .. "-") .. leaf.id,
order = nextOrder(nil),
bounds = bounds,
frame = {
x = x,
y = y + #labelLines * lineHeight,
width = width,
height = math.max(1, height - #labelLines * lineHeight)
},
text = tostring(value),
chart = chart
}
),
{
lines = {tostring(value)},
fontSize = layout.valueSize,
color = textColor
}
)
return {label, valueNode}
end
function ____exports.renderTreemapTiles(self, context, layout)
local ____layoutTreemapTiles_result_0 = layoutTreemapTiles(nil, context, layout)
local tiles = ____layoutTreemapTiles_result_0.tiles
local headers = ____layoutTreemapTiles_result_0.headers
local nodes = {}
local ____Boolean_3 = Boolean
local ____opt_1 = context.chart.config
local gradientFlow = ____Boolean_3(nil, ____opt_1 and ____opt_1.tileGradient)
__TS__ArrayForEach(
tiles,
function(____, tile, index)
local next = tiles[index + 1 + 1]
local sameGroup = next and (tile.item.leaf.group or "") == (next.item.leaf.group or "")
local nextTile = gradientFlow and sameGroup and next or nil
__TS__ArrayPushArray(
nodes,
renderTile(
nil,
context,
layout,
tile,
nextTile
)
)
end
)
__TS__ArrayForEach(
headers,
function(____, header, index)
__TS__ArrayPushArray(
nodes,
renderTreemapHeader(
nil,
context,
layout,
header,
index
)
)
end
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.treemap"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____layout = require("core.renderScene.charts.renderers.treemap.layout")
local createTreemapLayout = ____layout.createTreemapLayout
local ____legend = require("core.renderScene.charts.renderers.treemap.legend")
local renderTreemapLegend = ____legend.renderTreemapLegend
local ____tiles = require("core.renderScene.charts.renderers.treemap.tiles")
local renderTreemapTiles = ____tiles.renderTreemapTiles
function ____exports.renderTreemap(self, context)
local layout = createTreemapLayout(nil, context)
local nodes = {}
__TS__ArrayPushArray(
nodes,
renderTreemapTiles(nil, context, layout)
)
__TS__ArrayPushArray(
nodes,
renderTreemapLegend(nil, context, layout)
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.renderers.dispatch"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____bar = require("core.renderScene.charts.renderers.bar")
local renderBar = ____bar.renderBar
local ____boxplot = require("core.renderScene.charts.renderers.boxplot")
local renderBoxplot = ____boxplot.renderBoxplot
local ____custom = require("core.renderScene.charts.renderers.custom")
local renderCustom = ____custom.renderCustom
local ____field = require("core.renderScene.charts.renderers.field")
local renderField = ____field.renderField
local ____heatmap = require("core.renderScene.charts.renderers.heatmap")
local renderHeatmap = ____heatmap.renderHeatmap
local ____hexbin = require("core.renderScene.charts.renderers.hexbin")
local renderHexbin = ____hexbin.renderHexbin
local ____line = require("core.renderScene.charts.renderers.line")
local renderLine = ____line.renderLine
local ____mekko = require("core.renderScene.charts.renderers.mekko")
local renderMekko = ____mekko.renderMekko
local ____pie = require("core.renderScene.charts.renderers.pie")
local renderPie = ____pie.renderPie
local ____polarArea = require("core.renderScene.charts.renderers.polarArea")
local renderPolarArea = ____polarArea.renderPolarArea
local ____radar = require("core.renderScene.charts.renderers.radar")
local renderRadar = ____radar.renderRadar
local ____radialBar = require("core.renderScene.charts.renderers.radialBar")
local renderRadialBar = ____radialBar.renderRadialBar
local ____sankey = require("core.renderScene.charts.renderers.sankey")
local renderSankey = ____sankey.renderSankey
local ____scatter = require("core.renderScene.charts.renderers.scatter")
local renderScatter = ____scatter.renderScatter
local ____treemap = require("core.renderScene.charts.renderers.treemap")
local renderTreemap = ____treemap.renderTreemap
local RENDERERS = {
bar = renderBar,
boxplot = renderBoxplot,
custom = renderCustom,
field = renderField,
heatmap = renderHeatmap,
hexbin = function(____, context) return renderHexbin(nil, context) end,
line = renderLine,
mekko = renderMekko,
pie = function(____, context) return renderPie(nil, context) end,
polarArea = function(____, context) return renderPolarArea(nil, context) end,
radar = function(____, context) return renderRadar(nil, context) end,
radial = function(____, context) return renderRadar(nil, context) end,
radialBar = function(____, context) return renderRadialBar(nil, context) end,
sankey = renderSankey,
scatter = renderScatter,
treemap = renderTreemap
}
local POLAR_TYPES = __TS__New(Set, {"radar", "radial"})
function ____exports.isPolarChart(self, chartType)
return POLAR_TYPES:has(chartType)
end
function ____exports.renderChartMarks(self, context)
return RENDERERS[context.chart.chartType](RENDERERS, context)
end
return ____exports
end,
["core.renderScene.charts.renderers.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____dispatch = require("core.renderScene.charts.renderers.dispatch")
____exports.isPolarChart = ____dispatch.isPolarChart
____exports.renderChartMarks = ____dispatch.renderChartMarks
end
return ____exports
end,
["core.renderScene.charts.chartRenderContext"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
function ____exports.createChartRenderContext(self, chart, layout, renderOrder, diagnostics)
local ____chart_3 = chart
local ____layout_plot_4 = layout.plot
local ____layout_bounds_5 = layout.bounds
local ____diagnostics_6 = diagnostics
local ____layout_showLabels_7 = layout.showLabels
local ____layout_showLegend_8 = layout.showLegend
local ____t_2 = __t
local ____opt_0 = chart.config
return {
chart = ____chart_3,
plot = ____layout_plot_4,
bounds = ____layout_bounds_5,
diagnostics = ____diagnostics_6,
showLabels = ____layout_showLabels_7,
showLegend = ____layout_showLegend_8,
stackedMode = ____t_2(nil, ____opt_0 and ____opt_0.stacked) and chart.config.stacked ~= "none" and chart.config.stacked or nil,
nextOrder = renderOrder.next
}
end
return ____exports
end,
["core.renderScene.charts.chartTitle"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____scene = require("core.renderScene.scene.index")
local finite = ____scene.finite
local ____primitives = require("core.renderScene.charts.primitives.index")
local chartText = ____primitives.chartText
local ____propPath = require("core.renderScene.charts.propPath")
local CHART_TITLE_PROP = ____propPath.CHART_TITLE_PROP
function ____exports.buildChartTitle(self, chart, bounds, plot, renderOrder)
if not __t(nil, chart.title) then
return {}
end
return {__TS__ObjectAssign(
{},
chartText(
nil,
{
id = "chart-title-" .. chart.id,
order = renderOrder:next(),
bounds = bounds,
frame = {x = plot.x, y = chart.y + 12, width = plot.width, height = 20},
text = chart.title,
chart = chart,
align = chart.titleAlign or "left"
}
),
__t(nil, chart.titleColor) and ({color = chart.titleColor}) or ({}),
{
fontWeight = chart.titleWeight or "bold",
fontSize = finite(
nil,
chart.titleSize,
math.max(
10,
finite(nil, chart.fontSize, 12)
) + 2
),
prop = CHART_TITLE_PROP
}
)}
end
return ____exports
end,
["core.renderScene.charts.chartFoundation"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____chartBackdrop = require("core.renderScene.charts.chartBackdrop")
local buildChartBackdrop = ____chartBackdrop.buildChartBackdrop
local ____chartFrame = require("core.renderScene.charts.chartFrame")
local buildChartFrame = ____chartFrame.buildChartFrame
local ____chartLegend = require("core.renderScene.charts.chartLegend")
local buildOrderedChartLegend = ____chartLegend.buildOrderedChartLegend
local ____chartRenderContext = require("core.renderScene.charts.chartRenderContext")
local createChartRenderContext = ____chartRenderContext.createChartRenderContext
local ____chartRenderOrder = require("core.renderScene.charts.chartRenderOrder")
local ChartRenderOrder = ____chartRenderOrder.ChartRenderOrder
local ____chartTitle = require("core.renderScene.charts.chartTitle")
local buildChartTitle = ____chartTitle.buildChartTitle
local ____decorations = require("core.renderScene.charts.decorations.index")
local decorations = ____decorations.decorations
function ____exports.createChartFoundation(self, chart, index, diagnostics)
local baseOrder = 20000 + index
local layout = decorations(nil, chart)
local renderOrder = __TS__New(ChartRenderOrder, baseOrder)
local nodes = {buildChartFrame(
nil,
chart,
layout.bounds,
layout.plot,
baseOrder
)}
__TS__ArrayPushArray(
nodes,
buildChartBackdrop(nil, chart, layout.bounds, renderOrder)
)
__TS__ArrayPushArray(
nodes,
buildChartTitle(
nil,
chart,
layout.bounds,
layout.plot,
renderOrder
)
)
__TS__ArrayPushArray(
nodes,
buildOrderedChartLegend(
nil,
chart,
layout,
renderOrder,
diagnostics
)
)
return {
chart = chart,
layout = layout,
nodes = nodes,
renderOrder = renderOrder,
context = createChartRenderContext(
nil,
chart,
layout,
renderOrder,
diagnostics
)
}
end
return ____exports
end,
["core.renderScene.charts.cartesianChart"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____decorations = require("core.renderScene.charts.decorations.index")
local buildChartAxes = ____decorations.buildChartAxes
local buildChartGrid = ____decorations.buildChartGrid
local buildChartRules = ____decorations.buildChartRules
local ____renderers = require("core.renderScene.charts.renderers.index")
local renderChartMarks = ____renderers.renderChartMarks
function ____exports.buildCartesianChart(self, foundation)
local ____foundation_0 = foundation
local chart = ____foundation_0.chart
local context = ____foundation_0.context
local layout = ____foundation_0.layout
local nodes = ____foundation_0.nodes
local renderOrder = ____foundation_0.renderOrder
local gridNodes = buildChartGrid(
nil,
chart,
layout.plot,
layout.bounds,
renderOrder:current()
)
__TS__ArrayPushArray(nodes, gridNodes)
renderOrder:advance(#gridNodes)
__TS__ArrayPushArray(
nodes,
renderChartMarks(nil, context)
)
local ruleNodes = buildChartRules(
nil,
{
chart = chart,
plot = layout.plot,
bounds = layout.bounds,
order = renderOrder:current()
}
)
__TS__ArrayPushArray(nodes, ruleNodes)
renderOrder:advance(#ruleNodes)
__TS__ArrayPushArray(
nodes,
buildChartAxes(
nil,
chart,
layout,
renderOrder:current()
)
)
return nodes
end
return ____exports
end,
["core.renderScene.charts.polarChart"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____renderers = require("core.renderScene.charts.renderers.index")
local renderChartMarks = ____renderers.renderChartMarks
function ____exports.buildPolarChart(self, foundation)
__TS__ArrayPushArray(
foundation.nodes,
renderChartMarks(nil, foundation.context)
)
return foundation.nodes
end
return ____exports
end,
["core.renderScene.charts.undecoratedChart"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local ____exports = {}
local ____renderers = require("core.renderScene.charts.renderers.index")
local renderChartMarks = ____renderers.renderChartMarks
function ____exports.buildUndecoratedChart(self, foundation)
__TS__ArrayPushArray(
foundation.nodes,
renderChartMarks(nil, foundation.context)
)
return foundation.nodes
end
return ____exports
end,
["core.renderScene.charts.buildChart"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____cartesianChart = require("core.renderScene.charts.cartesianChart")
local buildCartesianChart = ____cartesianChart.buildCartesianChart
local ____chartFoundation = require("core.renderScene.charts.chartFoundation")
local createChartFoundation = ____chartFoundation.createChartFoundation
local ____decorations = require("core.renderScene.charts.decorations.index")
local hasCartesianDecorations = ____decorations.hasCartesianDecorations
local ____polarChart = require("core.renderScene.charts.polarChart")
local buildPolarChart = ____polarChart.buildPolarChart
local ____renderers = require("core.renderScene.charts.renderers.index")
local isPolarChart = ____renderers.isPolarChart
local ____undecoratedChart = require("core.renderScene.charts.undecoratedChart")
local buildUndecoratedChart = ____undecoratedChart.buildUndecoratedChart
function ____exports.buildChart(self, chart, index, diagnostics)
if chart.isVisible == false then
return {}
end
local foundation = createChartFoundation(nil, chart, index, diagnostics)
if isPolarChart(nil, chart.chartType) then
return buildPolarChart(nil, foundation)
end
if hasCartesianDecorations(nil, chart) then
return buildCartesianChart(nil, foundation)
end
return buildUndecoratedChart(nil, foundation)
end
return ____exports
end,
["core.renderScene.charts.artifacts"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ____tagging = require("core.renderScene.scene.tagging")
local tag = ____tagging.tag
local ____buildChart = require("core.renderScene.charts.buildChart")
local buildChart = ____buildChart.buildChart
function ____exports.buildCharts(self, charts, diagnostics)
return __TS__ArrayFlatMap(
charts,
function(____, chart, index) return tag(
nil,
buildChart(nil, chart, index, diagnostics),
"chart",
chart.id,
chart.chartType,
chart.title or "Chart"
) end
)
end
return ____exports
end,
["core.renderScene.charts.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____artifacts = require("core.renderScene.charts.artifacts")
____exports.buildCharts = ____artifacts.buildCharts
end
do
local ____buildChart = require("core.renderScene.charts.buildChart")
____exports.buildChart = ____buildChart.buildChart
end
return ____exports
end,
["core.renderScene.scene.frameClip"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Map = ____lualib.Map
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__New = ____lualib.__TS__New
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ARC_STEPS = 8
local function turnOf(self, node)
local turned = node
if not __t(nil, turned.rotation) then
return nil
end
if turned.rotationCenter then
return {angle = turned.rotation, x = turned.rotationCenter.x, y = turned.rotationCenter.y}
end
if turned.cx ~= nil and turned.cy ~= nil then
return {angle = turned.rotation, x = turned.cx, y = turned.cy}
end
if turned.x ~= nil and turned.y ~= nil and turned.width ~= nil and turned.height ~= nil then
return {angle = turned.rotation, x = turned.x + turned.width / 2, y = turned.y + turned.height / 2}
end
return nil
end
local function roundedRectPoints(self, frame)
local ____frame_0 = frame
local x = ____frame_0.x
local y = ____frame_0.y
local width = ____frame_0.width
local height = ____frame_0.height
local r = math.max(
0,
math.min(frame.cornerRadius, width / 2, height / 2)
)
if r == 0 then
return {{x, y}, {x + width, y}, {x + width, y + height}, {x, y + height}}
end
local corners = {{x + width - r, y + r, -90}, {x + width - r, y + height - r, 0}, {x + r, y + height - r, 90}, {x + r, y + r, 180}}
return __TS__ArrayFlatMap(
corners,
function(____, ____bindingPattern0)
local start
local cy
local cx
cx = ____bindingPattern0[1]
cy = ____bindingPattern0[2]
start = ____bindingPattern0[3]
return __TS__ArrayFrom(
{length = ARC_STEPS + 1},
function(____, _, step)
local angle = (start + 90 * step / ARC_STEPS) * math.pi / 180
return {
cx + r * math.cos(angle),
cy + r * math.sin(angle)
}
end
)
end
)
end
local function clipFor(self, frame, turn)
if not turn then
return {
type = "rect",
x = frame.x,
y = frame.y,
width = frame.width,
height = frame.height,
rx = frame.cornerRadius
}
end
local back = -turn.angle * math.pi / 180
local cos = math.cos(back)
local sin = math.sin(back)
local points = __TS__ArrayMap(
roundedRectPoints(nil, frame),
function(____, ____bindingPattern0)
local py
local px
px = ____bindingPattern0[1]
py = ____bindingPattern0[2]
local dx = px - turn.x
local dy = py - turn.y
return {turn.x + dx * cos - dy * sin, turn.y + dx * sin + dy * cos}
end
)
local function round(____, value)
return math.floor(value * 100 + 0.5) / 100
end
return {
type = "path",
d = ("M" .. table.concat(
__TS__ArrayMap(
points,
function(____, ____bindingPattern0)
local py
local px
px = ____bindingPattern0[1]
py = ____bindingPattern0[2]
return (tostring(round(nil, px)) .. " ") .. tostring(round(nil, py))
end
),
"L"
)) .. "Z"
}
end
function ____exports.applyFrameClips(self, nodes, frames)
local clipping = __TS__New(
Map,
__TS__ArrayMap(
__TS__ArrayFilter(
frames,
function(____, frame) return frame.clip end
),
function(____, frame) return {frame.id, frame} end
)
)
if clipping.size == 0 then
return
end
local inside = __TS__New(Map)
for ____, node in ipairs(nodes) do
local ____opt_1 = node.identity
local parent = ____opt_1 and ____opt_1.parentFrameId
local ____t_result_3
if __t(nil, parent) then
____t_result_3 = clipping:get(parent)
else
____t_result_3 = nil
end
local frame = ____t_result_3
if node.identity and frame then
inside:set((node.identity.role .. ":") .. node.identity.id, frame)
end
end
for ____, node in ipairs(nodes) do
local ____node_identity_4
if node.identity then
____node_identity_4 = inside:get((node.identity.role .. ":") .. node.identity.id)
else
____node_identity_4 = nil
end
local frame = ____node_identity_4
local styled = node
if frame and styled.style then
local edge = clipFor(
nil,
frame,
turnOf(nil, node)
)
styled.style = __TS__ObjectAssign(
{},
styled.style,
{clip = styled.style.clip and __TS__ObjectAssign({}, styled.style.clip, {within = edge}) or edge}
)
end
end
end
return ____exports
end,
["core.renderScene.scene.build"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local ____exports = {}
local ______shims = require("core.__shims")
local __lor = ______shims.__lor
local __sort = ______shims.__sort
local __t = ______shims.__t
local ____component = require("core.renderScene.artifacts.component.index")
local buildComponents = ____component.buildComponents
local ____containers = require("core.renderScene.artifacts.containers")
local buildContainers = ____containers.buildContainers
local ____dimension = require("core.renderScene.artifacts.dimension")
local buildDimensions = ____dimension.buildDimensions
local ____isometric = require("core.renderScene.artifacts.isometric.index")
local buildIsometricObjects = ____isometric.buildIsometricObjects
local ____link = require("core.renderScene.artifacts.link")
local buildLinks = ____link.buildLinks
local ____meshStage = require("core.renderScene.artifacts.meshStage")
local buildMeshStages = ____meshStage.buildMeshStages
local ____meshSurfaces = require("core.renderScene.artifacts.meshSurfaces")
local splitMeshSurfaces = ____meshSurfaces.splitMeshSurfaces
local ____path = require("core.renderScene.artifacts.path")
local buildFreeformPaths = ____path.buildFreeformPaths
local ____shape = require("core.renderScene.artifacts.shape")
local buildShapes = ____shape.buildShapes
local ____charts = require("core.renderScene.charts.index")
local buildCharts = ____charts.buildCharts
local ____bounds = require("core.renderScene.scene.bounds")
local EMPTY_BOUNDS = ____bounds.EMPTY_BOUNDS
local ____frameClip = require("core.renderScene.scene.frameClip")
local applyFrameClips = ____frameClip.applyFrameClips
local ____order = require("core.renderScene.scene.order")
local stackRank = ____order.stackRank
local stackSequence = ____order.stackSequence
local function visibleBounds(self, node)
local ____node_bounds_0 = node.bounds
local minX = ____node_bounds_0.minX
local minY = ____node_bounds_0.minY
local maxX = ____node_bounds_0.maxX
local maxY = ____node_bounds_0.maxY
local ____temp_3
if node.style ~= nil then
local ____opt_1 = node.style
____temp_3 = ____opt_1 and ____opt_1.clip
else
____temp_3 = nil
end
local clip = ____temp_3
while clip do
if clip.type == "rect" then
minX = math.max(minX, clip.x)
minY = math.max(minY, clip.y)
maxX = math.min(maxX, clip.x + clip.width)
maxY = math.min(maxY, clip.y + clip.height)
end
clip = clip.within
end
return minX <= maxX and minY <= maxY and ({minX = minX, minY = minY, maxX = maxX, maxY = maxY}) or node.bounds
end
local function sceneBounds(self, nodes)
if not __t(nil, #nodes) then
return EMPTY_BOUNDS
end
local all = __TS__ArrayMap(nodes, visibleBounds)
return {
minX = math.min(table.unpack(__TS__ArrayMap(
all,
function(____, b) return b.minX end
))),
minY = math.min(table.unpack(__TS__ArrayMap(
all,
function(____, b) return b.minY end
))),
maxX = math.max(table.unpack(__TS__ArrayMap(
all,
function(____, b) return b.maxX end
))),
maxY = math.max(table.unpack(__TS__ArrayMap(
all,
function(____, b) return b.maxY end
)))
}
end
local function stackingOf(self, input)
local stacking = __TS__New(Map)
local function add(____, role, objects, legacyBase)
__TS__ArrayForEach(
objects,
function(____, object, index)
stacking:set(
(role .. ":") .. object.id,
{
rank = stackRank(nil, object),
sequence = stackSequence(nil, object, legacyBase + index)
}
)
end
)
end
add(nil, "frame", input.frames, 0)
add(nil, "swimlane", input.swimlanes, 5000)
add(nil, "shape", input.shapes, 10000)
add(nil, "widget", input.components or input.widgets or ({}), 10000)
add(nil, "isometric", input.isometricObjects or ({}), 15000)
add(
nil,
"link",
__TS__ArrayMap(
input.links,
function(____, item) return item.link end
),
20000
)
add(nil, "chart", input.charts or ({}), 20000)
add(nil, "path", input.paths or ({}), 30000)
add(nil, "dimension", input.dimensions or ({}), 31000)
add(nil, "mesh-stage", input.meshScenes or ({}), -1000)
return stacking
end
local function stampStacking(self, nodes, input)
local stacking = stackingOf(nil, input)
for ____, node in ipairs(nodes) do
local ____temp_5
if node.type == "mesh-stage" then
____temp_5 = stacking:get("mesh-stage:" .. node.stageId)
else
local ____node_identity_4
if node.identity then
____node_identity_4 = stacking:get((node.identity.role .. ":") .. node.identity.id)
else
____node_identity_4 = nil
end
____temp_5 = ____node_identity_4
end
local stack = ____temp_5
node.rank = stack and stack.rank or 0
node.sequence = stack and stack.sequence or 0
end
end
function ____exports.buildRenderScene(self, whole, options)
if options == nil then
options = {}
end
local ____options_10 = options
local measureText = ____options_10.measureText
local ____splitMeshSurfaces_result_11 = splitMeshSurfaces(
nil,
whole,
function(____, part) return ____exports.buildRenderScene(nil, part, options) end
)
local input = ____splitMeshSurfaces_result_11.input
local surfaces = ____splitMeshSurfaces_result_11.surfaces
local diagnostics = {table.unpack(input.diagnostics or ({}))}
local ____array_12 = __TS__SparseArrayNew(table.unpack(buildMeshStages(
nil,
input.meshes or ({}),
input.meshScenes or ({}),
input.meshAnchors or ({}),
surfaces,
input.meshLights or ({})
)))
__TS__SparseArrayPush(
____array_12,
table.unpack(buildContainers(nil, input))
)
__TS__SparseArrayPush(
____array_12,
table.unpack(buildFreeformPaths(nil, input.paths or ({})))
)
__TS__SparseArrayPush(
____array_12,
table.unpack(buildCharts(nil, input.charts or ({}), diagnostics))
)
__TS__SparseArrayPush(
____array_12,
table.unpack(buildLinks(nil, input.links, measureText))
)
__TS__SparseArrayPush(
____array_12,
table.unpack(buildShapes(nil, input.shapes, diagnostics, measureText))
)
__TS__SparseArrayPush(
____array_12,
table.unpack(buildComponents(nil, input.components or input.widgets or ({})))
)
__TS__SparseArrayPush(
____array_12,
table.unpack(buildIsometricObjects(nil, input.isometricObjects or ({})))
)
__TS__SparseArrayPush(
____array_12,
table.unpack(buildDimensions(nil, input.dimensions or ({})))
)
local nodes = {__TS__SparseArraySpread(____array_12)}
applyFrameClips(nil, nodes, input.frames)
stampStacking(nil, nodes, input)
__sort(
nil,
nodes,
function(____, a, b) return __lor(
nil,
__lor(
nil,
__lor(
nil,
(a.rank or 0) - (b.rank or 0),
function() return (a.sequence or 0) - (b.sequence or 0) end
),
function() return a.order - b.order end
),
function() return a.id < b.id and -1 or (a.id > b.id and 1 or 0) end
) end
)
return {
nodes = nodes,
bounds = sceneBounds(nil, nodes),
diagnostics = diagnostics
}
end
return ____exports
end,
["core.svg.format"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__NumberToFixed = ____lualib.__TS__NumberToFixed
local __TS__Number = ____lualib.__TS__Number
local ____exports = {}
local ______shims = require("core.__shims")
local __re = ______shims.__re
local __replace = ______shims.__replace
____exports.xml = function(____, value) return __replace(
nil,
__replace(
nil,
__replace(
nil,
__replace(
nil,
__replace(
nil,
tostring(value),
__re(nil, "&", "g"),
"&"
),
__re(nil, "<", "g"),
"<"
),
__re(nil, ">", "g"),
">"
),
__re(nil, "\"", "g"),
"""
),
__re(nil, "'", "g"),
"'"
) end
____exports.num = function(____, value) return tostring(__TS__Number(__TS__NumberToFixed(value, 3))) end
____exports.safeId = function(____, value) return "sf-" .. __replace(
nil,
value,
__re(nil, "[^A-Za-z0-9_.:-]", "g"),
"-"
) end
return ____exports
end,
["core.svg.clipDefinitions"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __json = ______shims.__json
local __t = ______shims.__t
local ____format = require("core.svg.format")
local num = ____format.num
local safeId = ____format.safeId
local xml = ____format.xml
____exports.SvgClipDefinitions = __TS__Class()
local SvgClipDefinitions = ____exports.SvgClipDefinitions
SvgClipDefinitions.name = "SvgClipDefinitions"
function SvgClipDefinitions.prototype.____constructor(self, addDefinition, prefix)
self.addDefinition = addDefinition
self.prefix = prefix
self.ids = __TS__New(Map)
end
function SvgClipDefinitions.prototype.clip(self, style)
return style.clip and self:define(style.clip) or nil
end
function SvgClipDefinitions.prototype.define(self, clip)
local key = __json(nil, clip)
local id = self.ids:get(key)
if not __t(nil, id) then
local outer = clip.within and self:define(clip.within) or nil
id = safeId(
nil,
(self.prefix .. "clip-") .. tostring(self.ids.size)
)
self.ids:set(key, id)
local shape = clip.type == "path" and ("" or (((((((((""
self:addDefinition(((((("") .. shape) .. "")
end
return id
end
return ____exports
end,
["core.svg.filterDefinitions"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local outerShadowPrimitives, blurPrimitives, innerShadowPrimitives
local ______shims = require("core.__shims")
local __fnName = ______shims.__fnName
local __json = ______shims.__json
local __t = ______shims.__t
local ____format = require("core.svg.format")
local num = ____format.num
local safeId = ____format.safeId
local xml = ____format.xml
function outerShadowPrimitives(self, shadow)
return (((((((((""
end
function blurPrimitives(self, effect)
local blur = effect.blur > 0 and ("" or ""
local saturate = effect.saturate == 1 and "" or (""
return blur .. saturate
end
function innerShadowPrimitives(self, shadow)
return table.concat(
{
"",
"",
"",
("",
((("",
((("",
"",
"",
""
},
""
)
end
____exports.SvgFilterDefinitions = __TS__Class()
local SvgFilterDefinitions = ____exports.SvgFilterDefinitions
SvgFilterDefinitions.name = "SvgFilterDefinitions"
function SvgFilterDefinitions.prototype.____constructor(self, addDefinition, prefix)
self.addDefinition = addDefinition
self.prefix = prefix
self.ids = __TS__New(Map)
end
function SvgFilterDefinitions.prototype.filter(self, style, nodeId, size)
if style.innerShadow then
return self:define(nodeId, style.innerShadow, innerShadowPrimitives)
end
if style.shadow then
local reach = style.shadow.blur * 1.5 + math.max(
math.abs(style.shadow.dx),
math.abs(style.shadow.dy)
)
return self:define(
nodeId,
style.shadow,
outerShadowPrimitives,
__t(nil, size) and size > 0 and math.max(0.5, reach / size) or 0.5
)
end
if __t(nil, style.blur) and style.blurArea then
return self:defineInArea(nodeId, style.blur, style.blurArea)
end
if __t(nil, style.blur) or style.saturate ~= nil then
local margin = __t(nil, size) and size > 0 and __t(nil, style.blur) and math.max(0.5, style.blur * 1.5 / size) or 0.5
return self:define(nodeId, {blur = style.blur or 0, saturate = style.saturate or 1}, blurPrimitives, margin)
end
return nil
end
function SvgFilterDefinitions.prototype.defineInArea(self, nodeId, blur, area)
local id = safeId(nil, (self.prefix .. "glow-") .. nodeId)
self:addDefinition(((((((((((("") .. blurPrimitives(nil, {blur = blur, saturate = 1})) .. "")
return id
end
function SvgFilterDefinitions.prototype.define(self, nodeId, value, primitives, margin)
if margin == nil then
margin = 0.5
end
local key = (__json(nil, value) .. __fnName(nil, primitives)) .. tostring(margin)
local id = self.ids:get(key)
if not __t(nil, id) then
id = safeId(
nil,
(((self.prefix .. "shadow-") .. nodeId) .. "-") .. tostring(self.ids.size)
)
self.ids:set(key, id)
self:addDefinition(((((((((((("") .. primitives(nil, value)) .. "")
end
return id
end
return ____exports
end,
["core.svg.markerBodies"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____format = require("core.svg.format")
local num = ____format.num
function ____exports.markerBody(self, ____type, size, color, strokeWidth)
local bodies = {
arrow = ((((((((((("",
filled_arrow = ((((((((((((("",
circle = ((((("",
filled_circle = ((("",
diamond = ((((((((((("",
filled_diamond = ((((((((((((("",
bar = ((((((("",
triangle = ((((((((((("",
one = ((((((((((((("",
zero_one = ((((((((((((((("",
many = ((((((((((((("",
one_many = ((((((((((((((((((("",
zero_many = (((((((((((((((((((((""
}
return bodies[____type]
end
return ____exports
end,
["core.svg.markerDefinitions"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____format = require("core.svg.format")
local num = ____format.num
local safeId = ____format.safeId
local xml = ____format.xml
local ____markerBodies = require("core.svg.markerBodies")
local markerBody = ____markerBodies.markerBody
local function markerExtent(self, ____type, size, strokeWidth)
local isCompoundErMarker = ____type == "one_many" or ____type == "zero_many"
return math.max(size * (isCompoundErMarker and 2 or 1.4), strokeWidth * 2)
end
local function markerAttributes(self, id, extent)
return ((((((((((((("id=\"" .. id) .. "\" markerWidth=\"") .. num(nil, extent * 2)) .. "\" markerHeight=\"") .. num(nil, extent * 2)) .. "\" viewBox=\"") .. num(nil, -extent)) .. " ") .. num(nil, -extent)) .. " ") .. num(nil, extent * 2)) .. " ") .. num(nil, extent * 2)) .. "\" refX=\"0\" refY=\"0\" orient=\"auto-start-reverse\" markerUnits=\"userSpaceOnUse\" overflow=\"visible\""
end
____exports.SvgMarkerDefinitions = __TS__Class()
local SvgMarkerDefinitions = ____exports.SvgMarkerDefinitions
SvgMarkerDefinitions.name = "SvgMarkerDefinitions"
function SvgMarkerDefinitions.prototype.____constructor(self, addDefinition, prefix)
self.addDefinition = addDefinition
self.prefix = prefix
self.ids = __TS__New(Map)
end
function SvgMarkerDefinitions.prototype.marker(self, ____type, color, strokeWidth)
if not __t(nil, ____type) or ____type == "none" then
return nil
end
local key = (((____type .. ":") .. color) .. ":") .. tostring(strokeWidth)
local id = self.ids:get(key)
if __t(nil, id) then
return id
end
id = safeId(
nil,
(((self.prefix .. "marker-") .. ____type) .. "-") .. tostring(self.ids.size)
)
self.ids:set(key, id)
local size = 12 + (strokeWidth - 2) * 3
local extent = markerExtent(nil, ____type, size, strokeWidth)
local attributes = markerAttributes(nil, id, extent)
self:addDefinition(((("") .. markerBody(
nil,
____type,
size,
xml(nil, color),
strokeWidth
)) .. "")
return id
end
return ____exports
end,
["core.svg.paintDefinitions"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__Class = ____lualib.__TS__Class
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __json = ______shims.__json
local __t = ______shims.__t
local ____format = require("core.svg.format")
local num = ____format.num
local safeId = ____format.safeId
local xml = ____format.xml
local function meshGradientDefinition(self, id, paint)
local radialIds = __TS__ArrayMap(
paint.points,
function(____, _point, index) return safeId(
nil,
(id .. "-point-") .. tostring(index)
) end
)
local radialDefinitions = table.concat(
__TS__ArrayMap(
paint.points,
function(____, point, index)
local centerX = math.max(
0,
math.min(100, point.x)
)
local centerY = math.max(
0,
math.min(100, point.y)
)
return (((((((((""
end
),
""
)
local layers = table.concat(
__TS__ArrayMap(
paint.points,
function(____, _point, index) return ("" end
),
""
)
local ____id_3 = id
local ____xml_2 = xml
local ____opt_0 = paint.points[1]
return ((((((radialDefinitions .. "") .. layers) .. ""
end
local function linearGradientDefinition(self, id, paint, bounds)
local angle = paint.angle * math.pi / 180
local centerX = (bounds.minX + bounds.maxX) / 2
local centerY = (bounds.minY + bounds.maxY) / 2
local radius = math.max(bounds.maxX - bounds.minX, bounds.maxY - bounds.minY) / 2
local deltaX = math.cos(angle) * radius
local deltaY = math.sin(angle) * radius
local stops = table.concat(
__TS__ArrayMap(
paint.stops,
function(____, stop) return ((("" end
),
""
)
return ((((((((((("") .. stops) .. ""
end
____exports.SvgPaintDefinitions = __TS__Class()
local SvgPaintDefinitions = ____exports.SvgPaintDefinitions
SvgPaintDefinitions.name = "SvgPaintDefinitions"
function SvgPaintDefinitions.prototype.____constructor(self, addDefinition, prefix)
self.addDefinition = addDefinition
self.prefix = prefix
self.ids = __TS__New(Map)
end
function SvgPaintDefinitions.prototype.paint(self, value, nodeId, bounds)
if not value or value.kind == "none" then
return "none"
end
if value.kind == "solid" then
return value.color
end
local key = __json(nil, value) .. __json(nil, bounds)
local id = self.ids:get(key)
if not __t(nil, id) then
id = safeId(
nil,
(((self.prefix .. "gradient-") .. nodeId) .. "-") .. tostring(self.ids.size)
)
self.ids:set(key, id)
local definition = value.kind == "mesh-gradient" and meshGradientDefinition(nil, id, value) or linearGradientDefinition(nil, id, value, bounds)
self:addDefinition(definition)
end
return ("url(#" .. id) .. ")"
end
return ____exports
end,
["core.svg.definitions"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ____clipDefinitions = require("core.svg.clipDefinitions")
local SvgClipDefinitions = ____clipDefinitions.SvgClipDefinitions
local ____filterDefinitions = require("core.svg.filterDefinitions")
local SvgFilterDefinitions = ____filterDefinitions.SvgFilterDefinitions
local ____format = require("core.svg.format")
local safeId = ____format.safeId
local ____markerDefinitions = require("core.svg.markerDefinitions")
local SvgMarkerDefinitions = ____markerDefinitions.SvgMarkerDefinitions
local ____paintDefinitions = require("core.svg.paintDefinitions")
local SvgPaintDefinitions = ____paintDefinitions.SvgPaintDefinitions
____exports.SvgDefinitionRegistry = __TS__Class()
local SvgDefinitionRegistry = ____exports.SvgDefinitionRegistry
SvgDefinitionRegistry.name = "SvgDefinitionRegistry"
function SvgDefinitionRegistry.prototype.____constructor(self, prefix)
self.prefix = prefix
self.entries = {}
local function addDefinition(____, definition)
local ____self_entries_0 = self.entries
____self_entries_0[#____self_entries_0 + 1] = definition
end
self.paints = __TS__New(SvgPaintDefinitions, addDefinition, prefix)
self.filters = __TS__New(SvgFilterDefinitions, addDefinition, prefix)
self.markers = __TS__New(SvgMarkerDefinitions, addDefinition, prefix)
self.clips = __TS__New(SvgClipDefinitions, addDefinition, prefix)
end
function SvgDefinitionRegistry.prototype.elementId(self, id)
return safeId(nil, self.prefix .. id)
end
function SvgDefinitionRegistry.prototype.paint(self, value, nodeId, bounds)
return self.paints:paint(value, nodeId, bounds)
end
function SvgDefinitionRegistry.prototype.filter(self, style, nodeId, size)
return self.filters:filter(style, nodeId, size)
end
function SvgDefinitionRegistry.prototype.marker(self, ____type, color, strokeWidth)
return self.markers:marker(____type, color, strokeWidth)
end
function SvgDefinitionRegistry.prototype.clip(self, style)
return self.clips:clip(style)
end
function SvgDefinitionRegistry.prototype.clipArea(self, clip)
return self.clips:define(clip)
end
return ____exports
end,
["core.svg.domContract.version"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.DOM_CONTRACT_VERSION = 1
return ____exports
end,
["core.svg.linkHitAreas"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local HIT_WIDTH = 16
local LINE_HIT_WIDTH_PX = 14
local function hitAreaFor(self, path, linkId)
return {
type = "path",
id = "link-hit-" .. linkId,
order = path.order,
rank = path.rank,
sequence = path.sequence,
bounds = path.bounds,
d = path.d,
identity = {role = "link", id = linkId},
style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = "#000000"},
strokeWidth = HIT_WIDTH,
opacity = 0,
pointerEvents = "stroke"
}
}
end
local function isEmpty(____, paint)
return not paint or paint.kind == "none" or paint.kind == "solid" and (paint.color == "none" or paint.color == "transparent")
end
local function lineHitArea(self, node)
if node.type ~= "path" and node.type ~= "rect" and node.type ~= "ellipse" then
return nil
end
local ____node_0 = node
local identity = ____node_0.identity
local style = ____node_0.style
if not (identity and identity.primary) or identity.role == "link" or __t(nil, style.pointerEvents) or isEmpty(nil, style.stroke) or not isEmpty(nil, style.fill) then
return nil
end
return __TS__ObjectAssign({}, node, {id = "line-hit-" .. node.id, identity = {role = identity.role, id = identity.id}, detail = nil, style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = "#000000"},
strokeWidth = LINE_HIT_WIDTH_PX,
nonScalingStroke = true,
opacity = 0,
pointerEvents = "stroke"
}})
end
local DIMENSION_LINE_HIT_WIDTH_PX = 20
local LABEL_MARGIN = 4
local function dimensionHitArea(self, node)
local ____opt_3 = node.identity
if (____opt_3 and ____opt_3.role) ~= "dimension" then
return nil
end
local identity = {role = "dimension", id = node.identity.id}
if node.type == "path" then
return __TS__ObjectAssign({}, node, {
id = "line-hit-" .. node.id,
identity = identity,
detail = nil,
markerStart = nil,
markerEnd = nil,
style = {
fill = {kind = "none"},
stroke = {kind = "solid", color = "#000000"},
strokeWidth = DIMENSION_LINE_HIT_WIDTH_PX,
nonScalingStroke = true,
opacity = 0,
pointerEvents = "stroke"
}
})
end
if node.type ~= "text" then
return nil
end
local ____node_5 = node
local x = ____node_5.x
local y = ____node_5.y
local width = ____node_5.width
local height = ____node_5.height
local rotation = ____node_5.rotation
if rotation == nil then
rotation = 0
end
local rotationCenter = ____node_5.rotationCenter
local center = rotationCenter or ({x = x + width / 2, y = y + height / 2})
local angle = rotation * math.pi / 180
local function corner(____, px, py)
local dx = px - center.x
local dy = py - center.y
return (tostring(center.x + dx * math.cos(angle) - dy * math.sin(angle)) .. " ") .. tostring(center.y + dx * math.sin(angle) + dy * math.cos(angle))
end
local left, top, right, bottom = x - LABEL_MARGIN, y - LABEL_MARGIN, x + width + LABEL_MARGIN, y + height + LABEL_MARGIN
return {
type = "path",
id = "line-hit-" .. node.id,
order = node.order,
rank = node.rank,
sequence = node.sequence,
bounds = node.bounds,
d = ((((((("M " .. corner(nil, left, top)) .. " L ") .. corner(nil, right, top)) .. " L ") .. corner(nil, right, bottom)) .. " L ") .. corner(nil, left, bottom)) .. " Z",
identity = identity,
style = {fill = {kind = "solid", color = "#000000"}, opacity = 0, pointerEvents = "all"}
}
end
function ____exports.withLinkHitAreas(self, nodes)
return __TS__ArrayFlatMap(
nodes,
function(____, node)
local ____temp_8 = node.type == "path"
if ____temp_8 then
local ____opt_6 = node.identity
____temp_8 = (____opt_6 and ____opt_6.role) == "link"
end
if ____temp_8 and node.identity.primary then
return {
node,
hitAreaFor(nil, node, node.identity.id)
}
end
local dimension = dimensionHitArea(nil, node)
if dimension then
return {node, dimension}
end
local line = lineHitArea(nil, node)
return line and ({node, line}) or ({node})
end
)
end
return ____exports
end,
["core.svg.attributes"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local strokeColorAt, addStrokeAttrs, elementSize, addVisualEffectAttrs, addPathMarkerAttrs
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____format = require("core.svg.format")
local num = ____format.num
local xml = ____format.xml
function strokeColorAt(self, style, edge)
local paint = style.stroke
if (paint and paint.kind) == "solid" then
return paint.color
end
if (paint and paint.kind) == "linear-gradient" and __t(nil, #paint.stops) then
local pick = edge == "start" and __TS__ArrayReduce(
paint.stops,
function(____, a, b) return a.offset <= b.offset and a or b end
) or __TS__ArrayReduce(
paint.stops,
function(____, a, b) return a.offset >= b.offset and a or b end
)
return pick.color
end
if (paint and paint.kind) == "mesh-gradient" and __t(nil, #paint.points) then
return paint.points[1].color
end
return "#64748b"
end
function addStrokeAttrs(self, attrs, style)
if style.strokeWidth ~= nil then
attrs[#attrs + 1] = ("stroke-width=\"" .. num(nil, style.strokeWidth)) .. "\""
end
local ____t_8 = __t
local ____opt_6 = style.dash
if ____t_8(nil, ____opt_6 and #____opt_6) then
attrs[#attrs + 1] = ("stroke-dasharray=\"" .. table.concat(
__TS__ArrayMap(style.dash, num),
" "
)) .. "\""
end
if __t(nil, style.lineCap) then
attrs[#attrs + 1] = ("stroke-linecap=\"" .. style.lineCap) .. "\""
end
if __t(nil, style.lineJoin) then
attrs[#attrs + 1] = ("stroke-linejoin=\"" .. style.lineJoin) .. "\""
end
if style.opacity ~= nil then
attrs[#attrs + 1] = ("opacity=\"" .. num(nil, style.opacity)) .. "\""
end
if style.nonScalingStroke then
attrs[#attrs + 1] = "vector-effect=\"non-scaling-stroke\""
end
if __t(nil, style.pointerEvents) then
attrs[#attrs + 1] = ("pointer-events=\"" .. style.pointerEvents) .. "\""
end
local css = {}
if __t(nil, style.transition) and style.transition > 0 then
local time = num(nil, style.transition) .. "ms ease"
css[#css + 1] = (((((((((((((((((((((((("transition: x " .. time) .. ", y ") .. time) .. ", width ") .. time) .. ", height ") .. time) .. ", cx ") .. time) .. ", cy ") .. time) .. ", rx ") .. time) .. ", ry ") .. time) .. ", fill ") .. time) .. ", stroke ") .. time) .. ", stroke-width ") .. time) .. ", stroke-dasharray ") .. time) .. ", opacity ") .. time
end
if __t(nil, style.blend) then
css[#css + 1] = "mix-blend-mode: " .. xml(nil, style.blend)
end
if #css > 0 then
attrs[#attrs + 1] = ("style=\"" .. table.concat(css, "; ")) .. "\""
end
end
function elementSize(self, node)
local shape = node
if shape.type == "ellipse" and shape.rx ~= nil and shape.ry ~= nil then
return math.min(shape.rx, shape.ry) * 2
end
if shape.type == "rect" and shape.width ~= nil and shape.height ~= nil then
return math.min(shape.width, shape.height)
end
if shape.type == "path" and shape.bounds then
local side = math.min(shape.bounds.maxX - shape.bounds.minX, shape.bounds.maxY - shape.bounds.minY)
return side > 0 and side or nil
end
return nil
end
function addVisualEffectAttrs(self, attrs, node, defs)
local filter = defs:filter(
node.style,
node.id,
elementSize(nil, node)
)
if __t(nil, filter) then
attrs[#attrs + 1] = ("filter=\"url(#" .. filter) .. ")\""
end
local clip = defs:clip(node.style)
if __t(nil, clip) then
attrs[#attrs + 1] = ("clip-path=\"url(#" .. clip) .. ")\""
end
end
function addPathMarkerAttrs(self, attrs, node, defs)
if node.type ~= "path" then
return
end
local start = defs:marker(
node.markerStart,
strokeColorAt(nil, node.style, "start"),
node.style.strokeWidth or 1
)
local ____end = defs:marker(
node.markerEnd,
strokeColorAt(nil, node.style, "end"),
node.style.strokeWidth or 1
)
if __t(nil, start) then
attrs[#attrs + 1] = ("marker-start=\"url(#" .. start) .. ")\""
end
if __t(nil, ____end) then
attrs[#attrs + 1] = ("marker-end=\"url(#" .. ____end) .. ")\""
end
end
function ____exports.styleAttrs(self, node, defs)
local stroke = defs:paint(node.style.stroke, node.id .. "-stroke", node.bounds)
local fill = defs:paint(node.style.fill, node.id .. "-fill", node.bounds)
local attrs = {
("fill=\"" .. xml(nil, fill)) .. "\"",
("stroke=\"" .. xml(nil, stroke)) .. "\""
}
addStrokeAttrs(nil, attrs, node.style)
addVisualEffectAttrs(nil, attrs, node, defs)
addPathMarkerAttrs(nil, attrs, node, defs)
return table.concat(attrs, " ")
end
function ____exports.transform(self, rotation, center)
return __t(nil, rotation) and center and (((((" transform=\"rotate(" .. num(nil, rotation)) .. " ") .. num(nil, center.x)) .. " ") .. num(nil, center.y)) .. ")\"" or ""
end
function ____exports.imageAttrs(self, node, defs)
local attrs = {}
if node.style.opacity ~= nil then
attrs[#attrs + 1] = ("opacity=\"" .. num(nil, node.style.opacity)) .. "\""
end
if __t(nil, node.style.pointerEvents) then
attrs[#attrs + 1] = ("pointer-events=\"" .. node.style.pointerEvents) .. "\""
end
addVisualEffectAttrs(nil, attrs, node, defs)
return table.concat(attrs, " ")
end
return ____exports
end,
["core.svg.domContract.attributes"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
____exports.SYMBOL_POINTS_ATTR = "data-sf-symbol-points"
____exports.SYMBOL_TENSION_ATTR = "data-sf-symbol-tension"
____exports.SYMBOL_BOUNDS_ATTR = "data-sf-symbol-bounds"
____exports.CORNER_RADIUS_ATTR = "data-sf-corner-radius"
____exports.SQUARE_CORNER_ATTR = "data-sf-square-corner"
____exports.PATH_POINTS_ATTR = "data-sf-path-points"
____exports.PATH_TENSION_ATTR = "data-sf-path-tension"
____exports.PATH_CLOSED_ATTR = "data-sf-path-closed"
____exports.PATH_POINT_INDEX_ATTR = "data-sf-path-point"
____exports.PATH_POINT_SELECTED_ATTR = "data-sf-path-point-selected"
____exports.PATH_INSERT_INDEX_ATTR = "data-sf-path-insert"
____exports.DIMENSION_ATTR = "data-sf-dimension"
____exports.DIMENSION_HANDLE_ATTR = "data-sf-dimension-handle"
____exports.PATH_CORNERS_ATTR = "data-sf-path-corners"
____exports.PATH_CORNER_INDEX_ATTR = "data-sf-path-corner"
____exports.ISOMETRIC_SIZE_ATTR = "data-sf-isometric-size"
____exports.ISOMETRIC_LABEL_OFFSET_ATTR = "data-sf-isometric-label-offset"
return ____exports
end,
["core.svg.contract"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__StringTrim = ____lualib.__TS__StringTrim
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local ____exports = {}
local chartValueAttrs, pieGeometryAttrs, radarGeometryAttrs, chartScaleAttrs, chartSeriesAttrs, frameBoundaryAttrs, declaredBoundsAttr, symbolGeometryAttrs, pathGeometryAttrs, isometricGeometryAttrs, linkDetailAttrs
local ______shims = require("core.__shims")
local __json = ______shims.__json
local __re = ______shims.__re
local __replace = ______shims.__replace
local __t = ______shims.__t
local ____attributes = require("core.svg.domContract.attributes")
local CORNER_RADIUS_ATTR = ____attributes.CORNER_RADIUS_ATTR
local DIMENSION_ATTR = ____attributes.DIMENSION_ATTR
local ISOMETRIC_LABEL_OFFSET_ATTR = ____attributes.ISOMETRIC_LABEL_OFFSET_ATTR
local ISOMETRIC_SIZE_ATTR = ____attributes.ISOMETRIC_SIZE_ATTR
local PATH_CLOSED_ATTR = ____attributes.PATH_CLOSED_ATTR
local PATH_CORNERS_ATTR = ____attributes.PATH_CORNERS_ATTR
local PATH_POINTS_ATTR = ____attributes.PATH_POINTS_ATTR
local PATH_TENSION_ATTR = ____attributes.PATH_TENSION_ATTR
local SQUARE_CORNER_ATTR = ____attributes.SQUARE_CORNER_ATTR
local SYMBOL_BOUNDS_ATTR = ____attributes.SYMBOL_BOUNDS_ATTR
local SYMBOL_POINTS_ATTR = ____attributes.SYMBOL_POINTS_ATTR
local SYMBOL_TENSION_ATTR = ____attributes.SYMBOL_TENSION_ATTR
local ____format = require("core.svg.format")
local num = ____format.num
local xml = ____format.xml
function chartValueAttrs(self, detail)
return {
("data-sf-series=\"" .. xml(nil, detail.series)) .. "\"",
("data-sf-value-index=\"" .. tostring(detail.valueIndex)) .. "\"",
__t(nil, detail.mark) and ("data-sf-mark=\"" .. detail.mark) .. "\"" or nil,
detail.radius ~= nil and ("data-sf-bar-radius=\"" .. num(nil, detail.radius)) .. "\"" or nil,
__t(nil, detail.colorProp) and ("data-sf-color-prop=\"" .. xml(nil, detail.colorProp)) .. "\"" or nil,
detail.hasColorOverride and "data-sf-color-override=\"true\"" or nil,
detail.pieStart ~= nil and ("data-sf-pie-start=\"" .. num(nil, detail.pieStart)) .. "\"" or nil,
detail.pieEnd ~= nil and ("data-sf-pie-end=\"" .. num(nil, detail.pieEnd)) .. "\"" or nil,
detail.pieValue ~= nil and ("data-sf-pie-value=\"" .. num(nil, detail.pieValue)) .. "\"" or nil
}
end
function pieGeometryAttrs(self, detail)
return {("data-sf-pie-geometry=\"" .. detail.pieGeometry) .. "\""}
end
function radarGeometryAttrs(self, detail)
return {("data-sf-radar-geometry=\"" .. detail.radarGeometry) .. "\""}
end
function chartScaleAttrs(self, detail)
return {("data-sf-value-scale=\"" .. detail.valueScale) .. "\""}
end
function chartSeriesAttrs(self, detail)
return {
("data-sf-series=\"" .. xml(nil, detail.series)) .. "\"",
detail.lineTension ~= nil and ("data-sf-line-tension=\"" .. num(nil, detail.lineTension)) .. "\"" or nil,
__t(nil, detail.mark) and ("data-sf-mark=\"" .. xml(nil, detail.mark)) .. "\"" or nil,
detail.pulled and "data-sf-label-pulled=\"true\"" or nil,
detail.midAngle ~= nil and ("data-sf-pie-mid-angle=\"" .. num(nil, detail.midAngle)) .. "\"" or nil,
detail.wedgeRadius ~= nil and ("data-sf-pie-wedge-radius=\"" .. num(nil, detail.wedgeRadius)) .. "\"" or nil
}
end
function frameBoundaryAttrs(self, detail)
return {
((CORNER_RADIUS_ATTR .. "=\"") .. num(nil, detail.cornerRadius)) .. "\"",
((SQUARE_CORNER_ATTR .. "=\"") .. detail.squareCorner) .. "\""
}
end
function declaredBoundsAttr(self, bounds)
return ((((((((SYMBOL_BOUNDS_ATTR .. "=\"") .. num(nil, bounds.x)) .. ",") .. num(nil, bounds.y)) .. ",") .. num(nil, bounds.width)) .. ",") .. num(nil, bounds.height)) .. "\""
end
function symbolGeometryAttrs(self, detail)
return {
((SYMBOL_POINTS_ATTR .. "=\"") .. xml(
nil,
__json(nil, detail.points)
)) .. "\"",
((SYMBOL_TENSION_ATTR .. "=\"") .. num(nil, detail.tension)) .. "\"",
declaredBoundsAttr(nil, detail.declaredBounds)
}
end
function pathGeometryAttrs(self, detail)
return {
((PATH_POINTS_ATTR .. "=\"") .. xml(
nil,
__json(nil, detail.points)
)) .. "\"",
((PATH_TENSION_ATTR .. "=\"") .. num(nil, detail.tension)) .. "\"",
((PATH_CLOSED_ATTR .. "=\"") .. tostring(detail.closed)) .. "\"",
table.unpack(detail.cornerRadii and ({((PATH_CORNERS_ATTR .. "=\"") .. xml(
nil,
__json(nil, detail.cornerRadii)
)) .. "\""}) or ({}))
}
end
function isometricGeometryAttrs(self, detail)
return {
((((((ISOMETRIC_SIZE_ATTR .. "=\"") .. num(nil, detail.width)) .. ",") .. num(nil, detail.height)) .. ",") .. num(nil, detail.depth)) .. "\"",
((CORNER_RADIUS_ATTR .. "=\"") .. num(nil, detail.cornerRadius)) .. "\"",
declaredBoundsAttr(nil, detail.bounds),
((((ISOMETRIC_LABEL_OFFSET_ATTR .. "=\"") .. num(nil, detail.labelOffsetX)) .. ",") .. num(nil, detail.labelOffsetY)) .. "\""
}
end
function linkDetailAttrs(self, detail)
return {
__t(nil, detail.fromId) and ("data-sf-from=\"" .. xml(nil, detail.fromId)) .. "\"" or nil,
__t(nil, detail.toId) and ("data-sf-to=\"" .. xml(nil, detail.toId)) .. "\"" or nil,
__t(nil, detail.route) and ("data-sf-route=\"" .. detail.route) .. "\"" or nil,
__t(nil, detail.fromSide) and ("data-sf-from-side=\"" .. detail.fromSide) .. "\"" or nil,
__t(nil, detail.toSide) and ("data-sf-to-side=\"" .. detail.toSide) .. "\"" or nil,
detail.segments and ("data-sf-link-segments=\"" .. xml(
nil,
__json(nil, detail.segments)
)) .. "\"" or nil,
__t(nil, detail.fromFace) and ("data-sf-from-face=\"" .. detail.fromFace) .. "\"" or nil,
__t(nil, detail.toFace) and ("data-sf-to-face=\"" .. detail.toFace) .. "\"" or nil,
detail.labelGap and "data-sf-label-gap=\"true\"" or nil
}
end
local function domRole(self, identity)
return identity.role == "shape" and "entity" or identity.role
end
local function ariaAttrs(self, aria)
local ____temp_2 = ("role=\"" .. xml(nil, aria.role)) .. "\""
local ____temp_0
if aria.checked == nil then
____temp_0 = nil
else
____temp_0 = ("aria-checked=\"" .. tostring(aria.checked)) .. "\""
end
local ____temp_1
if aria.pressed == nil then
____temp_1 = nil
else
____temp_1 = ("aria-pressed=\"" .. tostring(aria.pressed)) .. "\""
end
return {____temp_2, ____temp_0, ____temp_1, aria.disabled and "aria-disabled=\"true\"" or nil}
end
local function identityAttrs(self, identity)
return {
("data-sf-role=\"" .. domRole(nil, identity)) .. "\"",
("data-sf-id=\"" .. xml(nil, identity.id)) .. "\"",
__t(nil, identity.kind) and ("data-sf-kind=\"" .. xml(nil, identity.kind)) .. "\"" or nil,
identity.primary and "data-sf-primary=\"true\"" or nil,
__t(nil, identity.parentFrameId) and ("data-sf-parent-frame=\"" .. xml(nil, identity.parentFrameId)) .. "\"" or nil,
table.unpack(identity.aria and ariaAttrs(nil, identity.aria) or ({}))
}
end
local function detailAttrs(self, detail)
repeat
local ____switch6 = detail.of
local ____cond6 = ____switch6 == "chartValue"
if ____cond6 then
return chartValueAttrs(nil, detail)
end
____cond6 = ____cond6 or ____switch6 == "chartScale"
if ____cond6 then
return chartScaleAttrs(nil, detail)
end
____cond6 = ____cond6 or ____switch6 == "chartSeries"
if ____cond6 then
return chartSeriesAttrs(nil, detail)
end
____cond6 = ____cond6 or ____switch6 == "pieGeometry"
if ____cond6 then
return pieGeometryAttrs(nil, detail)
end
____cond6 = ____cond6 or ____switch6 == "radarGeometry"
if ____cond6 then
return radarGeometryAttrs(nil, detail)
end
____cond6 = ____cond6 or ____switch6 == "link"
if ____cond6 then
return linkDetailAttrs(nil, detail)
end
____cond6 = ____cond6 or ____switch6 == "frameBoundary"
if ____cond6 then
return frameBoundaryAttrs(nil, detail)
end
____cond6 = ____cond6 or ____switch6 == "symbolGeometry"
if ____cond6 then
return symbolGeometryAttrs(nil, detail)
end
____cond6 = ____cond6 or ____switch6 == "declaredBounds"
if ____cond6 then
return {declaredBoundsAttr(nil, detail.bounds)}
end
____cond6 = ____cond6 or ____switch6 == "dimensionGeometry"
if ____cond6 then
local ____DIMENSION_ATTR_4 = DIMENSION_ATTR
local ____array_3 = __TS__SparseArrayNew(table.unpack(detail.start))
__TS__SparseArrayPush(
____array_3,
table.unpack(detail["end"])
)
__TS__SparseArrayPush(____array_3, detail.offset)
return {((____DIMENSION_ATTR_4 .. "=\"") .. table.concat(
__TS__ArrayMap(
{__TS__SparseArraySpread(____array_3)},
num
),
","
)) .. "\""}
end
____cond6 = ____cond6 or ____switch6 == "pathGeometry"
if ____cond6 then
return pathGeometryAttrs(nil, detail)
end
____cond6 = ____cond6 or ____switch6 == "isometricGeometry"
if ____cond6 then
return isometricGeometryAttrs(nil, detail)
end
until true
end
function ____exports.contractAttrs(self, node)
local ____opt_5 = node.identity
local label = ____opt_5 and ____opt_5.label
local ____compact_8 = __compact
local ____array_7 = __TS__SparseArrayNew(table.unpack(node.identity and identityAttrs(nil, node.identity) or ({})))
__TS__SparseArrayPush(
____array_7,
table.unpack(node.detail and detailAttrs(nil, node.detail) or ({}))
)
__TS__SparseArrayPush(
____array_7,
__t(nil, node.prop) and ("data-sf-prop=\"" .. xml(nil, node.prop)) .. "\"" or nil,
__t(nil, node.propKind) and ("data-sf-prop-kind=\"" .. node.propKind) .. "\"" or nil,
node.propSolidOnly and "data-sf-prop-solid-only=\"true\"" or nil,
__t(nil, node.mark) and ("data-sf-mark=\"" .. xml(nil, node.mark)) .. "\"" or nil,
node.zoneGradient and "data-sf-zone-gradient=\"true\"" or nil,
node.zoneGradient and ("data-sf-zone-axis-min=\"" .. num(nil, node.zoneGradient.min)) .. "\"" or nil,
node.zoneGradient and ("data-sf-zone-axis-max=\"" .. num(nil, node.zoneGradient.max)) .. "\"" or nil,
__t(nil, label) and ("tabindex=\"0\" aria-label=\"" .. xml(
nil,
__TS__StringTrim(__replace(
nil,
label,
__re(nil, "\\s+", "g"),
" "
))
)) .. "\"" or nil
)
local attributes = __TS__ArrayFilter(
____compact_8(__TS__SparseArraySpread(____array_7)),
function(____, attribute) return attribute ~= nil end
)
return __t(nil, #attributes) and " " .. table.concat(attributes, " ") or ""
end
return ____exports
end,
["core.svg.text"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local richLineTspans, textPosition, firstTextBaseline, textContent, lineTspan, lineOffset
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____attributes = require("core.svg.attributes")
local transform = ____attributes.transform
local ____contract = require("core.svg.contract")
local contractAttrs = ____contract.contractAttrs
local ____format = require("core.svg.format")
local num = ____format.num
local xml = ____format.xml
function richLineTspans(self, words, x, dy, fontSize)
if not __t(nil, #words) then
return (((((""
end
local groups = {}
for ____, word in ipairs(words) do
local prev = groups[#groups]
if prev and prev.bold == word.bold then
prev.text = prev.text .. " " .. word.text
else
if prev then
prev.text = prev.text .. " "
end
groups[#groups + 1] = {text = word.text, bold = word.bold}
end
end
return table.concat(
__TS__ArrayMap(
groups,
function(____, group, i) return ((((((("") .. xml(nil, group.text)) .. "" end
),
""
)
end
function textPosition(self, node)
local linePx = node.fontSize * node.lineHeight
local lineCount = node.richLines and #node.richLines or #node.lines
local contentHeight = lineCount * linePx
local x = node.align == "left" and node.x or (node.align == "right" and node.x + node.width or node.x + node.width / 2)
local anchor = node.align == "left" and "start" or (node.align == "right" and "end" or "middle")
return {
x = x,
firstY = firstTextBaseline(nil, node, contentHeight),
linePx = linePx,
anchor = anchor
}
end
function firstTextBaseline(self, node, contentHeight)
if node.verticalAlign == "top" then
return node.y + node.fontSize
end
if node.verticalAlign == "bottom" then
return node.y + node.height - contentHeight + node.fontSize
end
return node.y + (node.height - contentHeight) / 2 + node.fontSize
end
function textContent(self, node, position, fontSize)
if node.richLines then
return table.concat(
__TS__ArrayMap(
node.richLines,
function(____, words, index) return richLineTspans(
nil,
words,
position.x,
lineOffset(nil, index, position.linePx),
fontSize
) end
),
""
)
end
return table.concat(
__TS__ArrayMap(
node.lines,
function(____, line, index) return lineTspan(
nil,
line,
index,
position,
fontSize
) end
),
""
)
end
function lineTspan(self, line, index, position, fontSize)
return ((((((("") .. xml(nil, line)) .. ""
end
function lineOffset(self, index, linePx)
return __t(nil, index) and (" dy=\"" .. num(nil, linePx)) .. "px\"" or ""
end
local function textFade(self, node)
local opacity = node.opacity ~= nil and node.opacity < 1 and (" opacity=\"" .. num(nil, node.opacity)) .. "\"" or ""
local time = __t(nil, node.transition) and node.transition > 0 and num(nil, node.transition) .. "ms ease" or ""
return opacity .. (__t(nil, time) and (((" style=\"transition: fill " .. time) .. ", opacity ") .. time) .. "\"" or "")
end
function ____exports.textSvg(self, node, defs)
local position = textPosition(nil, node)
local fontSize = num(nil, node.fontSize) .. "px"
local content = textContent(nil, node, position, fontSize)
local preserve = node.richLines and " xml:space=\"preserve\"" or ""
return (((((((((((((((((((((((((((((("") .. content) .. ""
end
return ____exports
end,
["core.svg.nodes"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ObjectRest = ____lualib.__TS__ObjectRest
local ____exports = {}
local ______shims = require("core.__shims")
local __json = ______shims.__json
local __t = ______shims.__t
local ____attributes = require("core.svg.attributes")
local imageAttrs = ____attributes.imageAttrs
local styleAttrs = ____attributes.styleAttrs
local transform = ____attributes.transform
local ____contract = require("core.svg.contract")
local contractAttrs = ____contract.contractAttrs
local ____format = require("core.svg.format")
local num = ____format.num
local xml = ____format.xml
local ____text = require("core.svg.text")
local textSvg = ____text.textSvg
local function shaderSurfaceSvg(self, node, defs)
local rotation = transform(nil, node.rotation, {x = node.x + node.width / 2, y = node.y + node.height / 2})
local parameters = xml(
nil,
__json(nil, node.shader.parameters)
)
local surfacePadding = node.shader.surfacePadding or 0
local fillColor = __t(nil, node.fillColor) and (" data-sf-shader-fill=\"" .. xml(nil, node.fillColor)) .. "\"" or ""
local corners = __t(nil, node.cornerRadius) and (";border-radius:" .. num(nil, node.cornerRadius)) .. "px" or ""
local clip = node.clip and (" clip-path=\"url(#" .. defs:clipArea(node.clip)) .. ")\"" or ""
local ____temp_3 = defs:elementId(node.id)
local ____contractAttrs_result_4 = contractAttrs(nil, node)
local ____xml_result_5 = xml(nil, node.shader.program)
local ____xml_result_6 = xml(nil, node.shader.name)
local ____node_mask_7 = node.mask
local ____num_result_8 = num(nil, surfacePadding)
local ____num_result_9 = num(nil, node.x)
local ____num_result_10 = num(nil, node.y)
local ____num_result_11 = num(nil, node.width)
local ____num_result_12 = num(nil, node.height)
local ____temp_2 = node.shader.program == "ruler"
if not ____temp_2 then
local ____opt_0 = node.identity
____temp_2 = (____opt_0 and ____opt_0.role) == "widget"
end
return ((((((((((((((((((((((((((((((""
end
local function rollingDigitSvg(self, character, node)
local style = node.componentStyle
if style.variant == "plain" then
return ((((("") .. xml(nil, character)) .. ""
end
return ((((((((("") .. xml(nil, character)) .. ""
end
local function rollingNumberSvg(self, node, defs)
local rotation = transform(nil, node.rotation, {x = node.x + node.width / 2, y = node.y + node.height / 2})
local fontSize = node.componentStyle.fontSize > 0 and node.componentStyle.fontSize or math.max(
1,
math.min(node.width, node.height) * 0.28
)
local label = __t(nil, node.label) and ((("") .. xml(nil, node.label)) .. "" or ""
local digits = table.concat(
__TS__ArrayMap(
{__TS__Spread(node.value)},
function(____, character) return rollingDigitSvg(nil, character, node) end
),
""
)
local componentStyle = xml(
nil,
__json(nil, node.componentStyle)
)
return ((((((((((((((((((((((((((((((((("
") .. label) .. "
") .. digits) .. "
"
end
local function meshStageSvg(self, node, defs)
local data = xml(
nil,
__json(
nil,
{
id = node.stageId,
orbit = node.orbit,
zoom = node.zoom,
shadow = node.shadow,
environment = node.environment,
environmentTurn = node.environmentTurn,
exposure = node.exposure,
haze = node.haze,
hazeColor = node.hazeColor,
ground = node.ground,
light = node.light,
sideLights = node.sideLights,
meshes = node.meshes,
surfaces = __TS__ArrayMap(
node.surfaces,
function(____, ____bindingPattern0)
local surface
local _scene = ____bindingPattern0.scene
surface = __TS__ObjectRest(____bindingPattern0, {scene = true})
return surface
end
),
anchors = node.anchors
}
)
)
return (((((((((((((""
end
function ____exports.nodeSvg(self, node, defs)
if node.type == "mesh-stage" then
return meshStageSvg(nil, node, defs)
end
if node.type == "text" then
return textSvg(nil, node, defs)
end
if node.type == "shader-surface" then
return shaderSurfaceSvg(nil, node, defs)
end
if node.type == "rolling-number" then
return rollingNumberSvg(nil, node, defs)
end
if node.type == "image" then
return (((((((((((((((((((""
end
local attrs = (((("id=\"" .. defs:elementId(node.id)) .. "\"") .. contractAttrs(nil, node)) .. " ") .. styleAttrs(nil, node, defs)
if node.type == "rect" then
return ((((((((((((""
end
if node.type == "ellipse" then
return (((((((((((""
end
return (((((""
end
return ____exports
end,
["core.svg.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.svg.document"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____definitions = require("core.svg.definitions")
local SvgDefinitionRegistry = ____definitions.SvgDefinitionRegistry
local ____version = require("core.svg.domContract.version")
local DOM_CONTRACT_VERSION = ____version.DOM_CONTRACT_VERSION
local ____format = require("core.svg.format")
local num = ____format.num
local ____linkHitAreas = require("core.svg.linkHitAreas")
local withLinkHitAreas = ____linkHitAreas.withLinkHitAreas
local ____nodes = require("core.svg.nodes")
local nodeSvg = ____nodes.nodeSvg
function ____exports.renderSvgDocument(self, scene, options)
if options == nil then
options = {}
end
local padding = options.padding or 16
local width = math.max(1, scene.bounds.maxX - scene.bounds.minX + padding * 2)
local height = math.max(1, scene.bounds.maxY - scene.bounds.minY + padding * 2)
local viewBox = (((((num(nil, scene.bounds.minX - padding) .. " ") .. num(nil, scene.bounds.minY - padding)) .. " ") .. num(nil, width)) .. " ") .. num(nil, height)
local defs = __TS__New(
SvgDefinitionRegistry,
__t(nil, options.idPrefix) and options.idPrefix .. "-" or ""
)
local nodes = __TS__ArrayMap(
options.linkHitAreas and withLinkHitAreas(nil, scene.nodes) or scene.nodes,
function(____, node) return node.type == "mesh-stage" and __t(nil, #node.surfaces) and __TS__ObjectAssign(
{},
node,
{surfaces = __TS__ArrayMap(
node.surfaces,
function(____, surface) return __TS__ObjectAssign(
{},
surface,
{svg = ____exports.renderSvgDocument(nil, surface.scene, {padding = 0, includeXmlDeclaration = false}).svg}
) end
)}
) or node end
)
local body = table.concat(
__TS__ArrayMap(
nodes,
function(____, node) return nodeSvg(nil, node, defs) end
),
"\n "
)
local declaration = options.includeXmlDeclaration == false and "" or "\n"
local svg = ((((((((((((declaration .. ""
return {svg = svg, width = width, height = height, diagnostics = scene.diagnostics}
end
return ____exports
end,
["core.svg.renderScene"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____document = require("core.svg.document")
local renderSvgDocument = ____document.renderSvgDocument
function ____exports.renderSceneToSvg(self, scene, options)
if options == nil then
options = {}
end
return renderSvgDocument(nil, scene, options)
end
return ____exports
end,
["core.svg.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
do
local ____renderScene = require("core.svg.renderScene")
____exports.renderSceneToSvg = ____renderScene.renderSceneToSvg
end
return ____exports
end,
["core.render"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ObjectRest = ____lualib.__TS__ObjectRest
local ____exports = {}
local ____component = require("core.model.component.index")
local componentRegistryVersion = ____component.componentRegistryVersion
local registerComponentDescriptor = ____component.registerComponentDescriptor
local ____fromSfl = require("core.renderInput.fromSfl.index")
local sflToRenderInput = ____fromSfl.sflToRenderInput
local ____component = require("core.renderScene.artifacts.component.index")
local registerComponentBuilder = ____component.registerComponentBuilder
local ____build = require("core.renderScene.scene.build")
local buildRenderScene = ____build.buildRenderScene
local ____svg = require("core.svg.index")
local renderSceneToSvg = ____svg.renderSceneToSvg
function ____exports.renderCanvas(self, input, options)
if options == nil then
options = {}
end
local scene = buildRenderScene(nil, input, {measureText = options.measureText})
local ____renderSceneToSvg_result_0 = renderSceneToSvg(nil, scene, options)
local svg = ____renderSceneToSvg_result_0.svg
local width = ____renderSceneToSvg_result_0.width
local height = ____renderSceneToSvg_result_0.height
local diagnostics = ____renderSceneToSvg_result_0.diagnostics
return {
svg = svg,
width = width,
height = height,
diagnostics = diagnostics,
scene = scene
}
end
local SCENE_CACHE_LIMIT = 50
local sceneCache = __TS__New(Map)
local cachedForRegistry = componentRegistryVersion(nil)
local function cachedRenderScene(self, source)
local registry = componentRegistryVersion(nil)
if registry ~= cachedForRegistry then
sceneCache:clear()
cachedForRegistry = registry
end
local cached = sceneCache:get(source)
if cached then
sceneCache:delete(source)
sceneCache:set(source, cached)
return cached
end
local scene = buildRenderScene(
nil,
sflToRenderInput(nil, source)
)
sceneCache:set(source, scene)
if sceneCache.size > SCENE_CACHE_LIMIT then
local oldest = sceneCache:keys():next().value
if oldest ~= nil then
sceneCache:delete(oldest)
end
end
return scene
end
function ____exports.render(self, source, options)
if options == nil then
options = {}
end
if options.measureText then
return ____exports.renderCanvas(
nil,
sflToRenderInput(nil, source),
options
)
end
local scene = cachedRenderScene(nil, source)
local ____renderSceneToSvg_result_1 = renderSceneToSvg(nil, scene, options)
local svg = ____renderSceneToSvg_result_1.svg
local width = ____renderSceneToSvg_result_1.width
local height = ____renderSceneToSvg_result_1.height
local diagnostics = ____renderSceneToSvg_result_1.diagnostics
return {
svg = svg,
width = width,
height = height,
diagnostics = diagnostics,
scene = scene
}
end
local SCENE_ORDER_BASE = 10000
function ____exports.defineComponent(self, definition)
local ____definition_2 = definition
local scene = ____definition_2.scene
local descriptor = __TS__ObjectRest(____definition_2, {scene = true})
local unregisterDescriptor = registerComponentDescriptor(nil, descriptor)
local unregisterBuilder = registerComponentBuilder(
nil,
descriptor.type,
function(____, component, index) return scene(nil, component, {order = SCENE_ORDER_BASE + index}) end
)
return function()
unregisterBuilder(nil)
unregisterDescriptor(nil)
end
end
return ____exports
end,
["core.binding.types"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local DECLARED = {
number = "number",
int = "number",
float = "number",
string = "string",
boolean = "boolean",
bool = "boolean"
}
____exports.scalarOf = function(____, declared) return DECLARED[declared] end
____exports.typeName = function(____, ____type) return type(____type) == "string" and ____type or ("list<" .. ____type.list) .. ">" end
____exports.sameType = function(____, left, right) return ____exports.typeName(nil, left) == ____exports.typeName(nil, right) end
____exports.POINTER_EVENTS = {"onPress", "onRelease", "onTap", "onDrag"}
____exports.CHANGE_EVENT = "onChange"
____exports.TEXT_EVENTS = {"onFocus", "onBlur", "onSubmit"}
____exports.TICK_EVENT = "onTick"
return ____exports
end,
["core.binding.dataSource"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__Spread = ____lualib.__TS__Spread
local ____exports = {}
function ____exports.createDataSource(self, initial)
local current = initial
local listeners = __TS__New(Set)
return {
get = function() return current end,
set = function(self, next)
current = next
for ____, listener in ipairs({__TS__Spread(listeners)}) do
listener(nil)
end
end,
subscribe = function(self, listener)
listeners:add(listener)
return function() return listeners:delete(listener) end
end
}
end
return ____exports
end,
["core.binding.applyValue"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____component = require("core.model.component.index")
local isGenericComponent = ____component.isGenericComponent
local ____mesh = require("core.model.mesh.index")
local setMeshValue = ____mesh.setMeshValue
local function findChart(____, input, id)
local ____opt_0 = input.charts
return ____opt_0 and __TS__ArrayFind(
input.charts,
function(____, candidate) return candidate.id == id end
)
end
local function applyToSeries(self, input, path, change)
local chart = findChart(nil, input, path[1])
if not chart then
return
end
local series = __TS__ArrayFind(
chart.series,
function(____, candidate) return candidate.id == path[2] end
)
if not series then
series = {id = path[2], label = path[2], values = {}}
local ____chart_series_2 = chart.series
____chart_series_2[#____chart_series_2 + 1] = series
end
change(nil, series)
end
function ____exports.findComponent(self, input, id)
local ____opt_3 = input.components or input.widgets
return ____opt_3 and __TS__ArrayFind(
input.components or input.widgets,
function(____, candidate) return candidate.id == id end
)
end
function ____exports.writeComponentValue(self, input, id, value)
local component = ____exports.findComponent(nil, input, id)
if not component then
return
end
local ____isGenericComponent_result_5
if isGenericComponent(nil, component) then
____isGenericComponent_result_5 = value
else
____isGenericComponent_result_5 = tostring(value)
end
component.value = ____isGenericComponent_result_5
end
function ____exports.writeComponentValueEnd(self, input, id, value)
local component = ____exports.findComponent(nil, input, id)
if component and isGenericComponent(nil, component) then
component.properties.valueEnd = value
end
end
function ____exports.writeComponentDisabled(self, input, id, disabled)
local component = ____exports.findComponent(nil, input, id)
if component and isGenericComponent(nil, component) then
component.disabled = disabled
end
end
function ____exports.isComponentDisabled(self, input, id)
local component = ____exports.findComponent(nil, input, id)
return component ~= nil and isGenericComponent(nil, component) and component.disabled
end
local function setPath(self, input, path, change)
local ____opt_6 = input.paths
local item = ____opt_6 and __TS__ArrayFind(
input.paths,
function(____, candidate) return candidate.id == path[1] end
)
if item then
change(nil, item)
end
end
local function setComponent(self, input, id, change)
local component = ____exports.findComponent(nil, input, id)
if component and isGenericComponent(nil, component) then
change(nil, component)
end
end
local function setShape(self, input, path, change)
local shape = __TS__ArrayFind(
input.shapes,
function(____, candidate) return candidate.id == path[1] end
)
if shape then
change(nil, shape)
end
end
____exports.APPLY = {
["Chart.categories"] = function(____, input, path, value)
local chart = findChart(nil, input, path[1])
if chart then
chart.config = __TS__ObjectAssign({}, chart.config or ({}), {categories = value})
end
end,
["Chart.text"] = function(____, input, path, value)
local chart = findChart(nil, input, path[1])
if chart then
chart.title = value
end
end,
["Series.values"] = function(____, input, path, value) return applyToSeries(
nil,
input,
path,
function(____, series)
local ____value_8 = value
series.values = ____value_8
return ____value_8
end
) end,
["Series.label"] = function(____, input, path, value) return applyToSeries(
nil,
input,
path,
function(____, series)
local ____value_9 = value
series.label = ____value_9
return ____value_9
end
) end,
["Shape.text"] = function(____, input, path, value)
local shape = __TS__ArrayFind(
input.shapes,
function(____, candidate) return candidate.id == path[1] end
)
if shape then
shape.text = value
end
end,
["Shape.fill"] = function(____, input, path, value) return setShape(
nil,
input,
path,
function(____, shape)
local ____value_10 = value
shape.fillColor = ____value_10
return ____value_10
end
) end,
["Shape.stroke"] = function(____, input, path, value) return setShape(
nil,
input,
path,
function(____, shape)
local ____value_11 = value
shape.strokeColor = ____value_11
return ____value_11
end
) end,
["Shape.textColor"] = function(____, input, path, value) return setShape(
nil,
input,
path,
function(____, shape)
local ____value_12 = value
shape.textColor = ____value_12
return ____value_12
end
) end,
["Shape.opacity"] = function(____, input, path, value) return setShape(
nil,
input,
path,
function(____, shape)
local ____value_13 = value
shape.opacity = ____value_13
return ____value_13
end
) end,
["Shape.x"] = function(____, input, path, value) return setShape(
nil,
input,
path,
function(____, shape)
local ____value_14 = value
shape.x = ____value_14
return ____value_14
end
) end,
["Shape.y"] = function(____, input, path, value) return setShape(
nil,
input,
path,
function(____, shape)
local ____value_15 = value
shape.y = ____value_15
return ____value_15
end
) end,
["Shape.width"] = function(____, input, path, value) return setShape(
nil,
input,
path,
function(____, shape)
local ____value_16 = value
shape.width = ____value_16
return ____value_16
end
) end,
["Shape.height"] = function(____, input, path, value) return setShape(
nil,
input,
path,
function(____, shape)
local ____value_17 = value
shape.height = ____value_17
return ____value_17
end
) end,
["Shape.visible"] = function(____, input, path, value) return setShape(
nil,
input,
path,
function(____, shape)
local ____temp_18 = value == true
shape.isVisible = ____temp_18
return ____temp_18
end
) end,
["Path.stroke"] = function(____, input, path, value) return setPath(
nil,
input,
path,
function(____, item)
local ____value_19 = value
item.strokeColor = ____value_19
return ____value_19
end
) end,
["Path.opacity"] = function(____, input, path, value) return setPath(
nil,
input,
path,
function(____, item)
local ____value_20 = value
item.opacity = ____value_20
return ____value_20
end
) end,
["Path.visible"] = function(____, input, path, value) return setPath(
nil,
input,
path,
function(____, item)
local ____temp_21 = value == true
item.isVisible = ____temp_21
return ____temp_21
end
) end,
["Component.visible"] = function(____, input, path, value) return setComponent(
nil,
input,
path[1],
function(____, component)
local ____temp_22 = value == true
component.isVisible = ____temp_22
return ____temp_22
end
) end,
["Component.x"] = function(____, input, path, value) return setComponent(
nil,
input,
path[1],
function(____, component)
local ____value_23 = value
component.x = ____value_23
return ____value_23
end
) end,
["Component.y"] = function(____, input, path, value) return setComponent(
nil,
input,
path[1],
function(____, component)
local ____value_24 = value
component.y = ____value_24
return ____value_24
end
) end,
["Component.format"] = function(____, input, path, value) return setComponent(
nil,
input,
path[1],
function(____, component)
local ____value_25 = value
component.properties.format = ____value_25
return ____value_25
end
) end,
["Component.value"] = function(____, input, path, value) return ____exports.writeComponentValue(nil, input, path[1], value) end,
["Component.valueEnd"] = function(____, input, path, value) return ____exports.writeComponentValueEnd(nil, input, path[1], value) end,
["Component.disabled"] = function(____, input, path, value) return ____exports.writeComponentDisabled(nil, input, path[1], value == true) end
}
function ____exports.applyMesh(self, input, id, property, value)
local ____opt_26 = input.meshes
local ____temp_30 = ____opt_26 and __TS__ArrayFind(
input.meshes,
function(____, candidate) return candidate.id == id end
)
if ____temp_30 == nil then
local ____opt_28 = input.meshSurfaces
____temp_30 = ____opt_28 and __TS__ArrayFind(
input.meshSurfaces,
function(____, item) return item.id == id end
)
end
local ____temp_30_33 = ____temp_30
if ____temp_30_33 == nil then
local ____opt_31 = input.meshLights
____temp_30_33 = ____opt_31 and __TS__ArrayFind(
input.meshLights,
function(____, item) return item.id == id end
)
end
local mesh = ____temp_30_33
if mesh then
setMeshValue(nil, mesh, property, value)
end
end
function ____exports.applyShader(self, input, binding, value, ownerId)
local owners = {}
for ____, shape in ipairs(input.shapes) do
local ____opt_34 = shape.shader
if (____opt_34 and ____opt_34.name) == binding.ownerPath[1] and (ownerId == nil or shape.id == ownerId) then
shape.shader = __TS__ObjectAssign(
{},
shape.shader,
{parameters = __TS__ObjectAssign({}, shape.shader.parameters, {[binding.property] = value})}
)
owners[#owners + 1] = shape.id
end
end
return owners
end
return ____exports
end,
["core.binding.expression"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__MathSign = ____lualib.__TS__MathSign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArraySome = ____lualib.__TS__ArraySome
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayFrom = ____lualib.__TS__ArrayFrom
local __TS__Spread = ____lualib.__TS__Spread
local __TS__StringIncludes = ____lualib.__TS__StringIncludes
local __TS__ArraySlice = ____lualib.__TS__ArraySlice
local ____exports = {}
local inferBinary, inferMath, inferLeft, inferTextQuestion, inferCall, arithmetic, evaluateBinary, isNumeric, isList, MATH, text
local ______shims = require("core.__shims")
local __isArray = ______shims.__isArray
local __t = ______shims.__t
local ____types = require("core.binding.types")
local sameType = ____types.sameType
local typeName = ____types.typeName
function inferBinary(self, expr, scope, report)
local left = ____exports.inferType(nil, expr.left, scope, report)
local right = ____exports.inferType(nil, expr.right, scope, report)
if not __t(nil, left) or not __t(nil, right) then
return nil
end
local ____expr_1 = expr
local operator = ____expr_1.operator
if operator == "&&" or operator == "||" then
if left ~= "boolean" or right ~= "boolean" then
report(
nil,
"type-mismatch",
((((("'" .. operator) .. "' needs two booleans, got ") .. typeName(nil, left)) .. " and ") .. typeName(nil, right)) .. "."
)
return nil
end
return "boolean"
end
if __TS__ArrayIncludes({">", "<", ">=", "<="}, operator) then
if left ~= "number" or right ~= "number" then
report(
nil,
"type-mismatch",
((((("'" .. operator) .. "' compares two numbers, got ") .. typeName(nil, left)) .. " and ") .. typeName(nil, right)) .. "."
)
return nil
end
return "boolean"
end
if operator == "==" or operator == "!=" then
if isList(nil, left) or not sameType(nil, left, right) then
report(
nil,
"type-mismatch",
((((("'" .. operator) .. "' compares two values of the same simple type, got ") .. typeName(nil, left)) .. " and ") .. typeName(nil, right)) .. "."
)
return nil
end
return "boolean"
end
if operator == "+" and not isList(nil, left) and not isList(nil, right) and (left == "string" or right == "string") then
return "string"
end
if not isNumeric(nil, left) or not isNumeric(nil, right) then
report(
nil,
"type-mismatch",
((((("'" .. operator) .. "' needs numbers, got ") .. typeName(nil, left)) .. " and ") .. typeName(nil, right)) .. "."
)
return nil
end
return (isList(nil, left) or isList(nil, right)) and ({list = "number"}) or "number"
end
function inferMath(self, name, expr, scope, report)
local spec = MATH[name]
if #expr.args ~= spec.arguments then
report(
nil,
"wrong-arguments",
((((name .. "() takes exactly ") .. tostring(spec.arguments)) .. " argument") .. (spec.arguments == 1 and "" or "s")) .. "."
)
return nil
end
local types = __TS__ArrayMap(
expr.args,
function(____, arg) return ____exports.inferType(nil, arg, scope, report) end
)
if __TS__ArraySome(
types,
function(____, ____type) return not __t(nil, ____type) end
) then
return nil
end
if __TS__ArraySome(
types,
function(____, ____type) return not isNumeric(nil, ____type) end
) then
report(
nil,
"type-mismatch",
((name .. "() needs numbers, got ") .. table.concat(
__TS__ArrayMap(
types,
function(____, ____type) return typeName(nil, ____type) end
),
", "
)) .. "."
)
return nil
end
return __TS__ArraySome(
types,
function(____, ____type) return isList(nil, ____type) end
) and ({list = "number"}) or "number"
end
function inferLeft(self, expr, scope, report)
if #expr.args ~= 2 then
report(nil, "wrong-arguments", "left(text, count) takes exactly two arguments.")
return nil
end
local text, count = table.unpack(
__TS__ArrayMap(
expr.args,
function(____, arg) return ____exports.inferType(nil, arg, scope, report) end
),
1,
2
)
if not __t(nil, text) or not __t(nil, count) then
return nil
end
if text ~= "string" or not isNumeric(nil, count) or isList(nil, count) then
report(
nil,
"type-mismatch",
((("left() needs a string and a number, got " .. typeName(nil, text)) .. " and ") .. typeName(nil, count)) .. "."
)
return nil
end
return "string"
end
function inferTextQuestion(self, name, expr, scope, report)
local wanted = name == "length" and 1 or 2
if #expr.args ~= wanted then
report(nil, "wrong-arguments", name == "length" and "length(text) takes one argument." or "contains(text, part) takes two arguments.")
return nil
end
local types = __TS__ArrayMap(
expr.args,
function(____, arg) return ____exports.inferType(nil, arg, scope, report) end
)
if __TS__ArraySome(
types,
function(____, ____type) return not __t(nil, ____type) end
) then
return nil
end
if __TS__ArraySome(
types,
function(____, ____type) return ____type ~= "string" end
) then
report(
nil,
"type-mismatch",
((name .. "() needs text, got ") .. table.concat(
__TS__ArrayMap(
types,
function(____, ____type) return typeName(nil, ____type) end
),
", "
)) .. "."
)
return nil
end
return name == "length" and "number" or "boolean"
end
function inferCall(self, expr, scope, report)
local name = table.concat(expr.callee, ".")
if MATH[name] ~= nil then
return inferMath(
nil,
name,
expr,
scope,
report
)
end
if name == "left" then
return inferLeft(nil, expr, scope, report)
end
if name == "length" or name == "contains" then
return inferTextQuestion(
nil,
name,
expr,
scope,
report
)
end
if name ~= "when" then
report(
nil,
"unknown-function",
((("Unknown function '" .. name) .. "'. Available: when, left, length, contains, ") .. table.concat(
__TS__ObjectKeys(MATH),
", "
)) .. "."
)
return nil
end
if #expr.args ~= 3 then
report(nil, "wrong-arguments", "when(condition, then, else) takes exactly three arguments.")
return nil
end
local condition, whenTrue, whenFalse = table.unpack(
__TS__ArrayMap(
expr.args,
function(____, arg) return ____exports.inferType(nil, arg, scope, report) end
),
1,
3
)
if not __t(nil, condition) or not __t(nil, whenTrue) or not __t(nil, whenFalse) then
return nil
end
if condition ~= "boolean" then
report(
nil,
"type-mismatch",
("The condition of when() must be boolean, got " .. typeName(nil, condition)) .. "."
)
return nil
end
if not sameType(nil, whenTrue, whenFalse) then
report(
nil,
"type-mismatch",
((("when() branches must have the same type, got " .. typeName(nil, whenTrue)) .. " and ") .. typeName(nil, whenFalse)) .. "."
)
return nil
end
return whenTrue
end
function ____exports.inferType(self, expr, scope, report)
repeat
local ____switch57 = expr.kind
local ____cond57 = ____switch57 == "number"
if ____cond57 then
return "number"
end
____cond57 = ____cond57 or ____switch57 == "string"
if ____cond57 then
return "string"
end
____cond57 = ____cond57 or ____switch57 == "boolean"
if ____cond57 then
return "boolean"
end
____cond57 = ____cond57 or ____switch57 == "ref"
if ____cond57 then
do
local ____type = scope:resolve(expr.path)
if not __t(nil, ____type) then
local name = table.concat(expr.path, ".")
report(nil, "unknown-reference", name == "time.delta" and "'time.delta' is only available in an onTick handler." or ("Unknown reference '" .. name) .. "'. Use ., self.id, or .pressed / hovered / pointer.")
end
return ____type
end
end
____cond57 = ____cond57 or ____switch57 == "unary"
if ____cond57 then
do
local operand = ____exports.inferType(nil, expr.operand, scope, report)
local wanted = expr.operator == "!" and "boolean" or "number"
if __t(nil, operand) and operand ~= wanted then
report(
nil,
"type-mismatch",
((((("'" .. expr.operator) .. "' needs a ") .. wanted) .. ", got ") .. typeName(nil, operand)) .. "."
)
return nil
end
return __t(nil, operand) and wanted or nil
end
end
____cond57 = ____cond57 or ____switch57 == "binary"
if ____cond57 then
return inferBinary(nil, expr, scope, report)
end
____cond57 = ____cond57 or ____switch57 == "call"
if ____cond57 then
return inferCall(nil, expr, scope, report)
end
until true
end
function arithmetic(self, operator, left, right)
repeat
local ____switch63 = operator
local ____cond63 = ____switch63 == "+"
if ____cond63 then
return left + right
end
____cond63 = ____cond63 or ____switch63 == "-"
if ____cond63 then
return left - right
end
____cond63 = ____cond63 or ____switch63 == "*"
if ____cond63 then
return left * right
end
do
return right == 0 and 0 or left / right
end
until true
end
function evaluateBinary(self, expr, env)
local left = ____exports.evaluate(nil, expr.left, env)
if expr.operator == "&&" then
return Boolean(nil, left) and Boolean(
nil,
____exports.evaluate(nil, expr.right, env)
)
end
if expr.operator == "||" then
return Boolean(nil, left) or Boolean(
nil,
____exports.evaluate(nil, expr.right, env)
)
end
local right = ____exports.evaluate(nil, expr.right, env)
repeat
local ____switch68 = expr.operator
local ____cond68 = ____switch68 == ">"
if ____cond68 then
return left > right
end
____cond68 = ____cond68 or ____switch68 == "<"
if ____cond68 then
return left < right
end
____cond68 = ____cond68 or ____switch68 == ">="
if ____cond68 then
return left >= right
end
____cond68 = ____cond68 or ____switch68 == "<="
if ____cond68 then
return left <= right
end
____cond68 = ____cond68 or ____switch68 == "=="
if ____cond68 then
return left == right
end
____cond68 = ____cond68 or ____switch68 == "!="
if ____cond68 then
return left ~= right
end
until true
if type(left) == "string" or type(right) == "string" then
return text(nil, left) .. text(nil, right)
end
local function apply(____, a, b)
return arithmetic(nil, expr.operator, a, b)
end
if __TS__ArrayIsArray(left) and __TS__ArrayIsArray(right) then
local length = math.min(#left, #right)
return __TS__ArrayFrom(
{length = length},
function(____, _value, index) return apply(nil, left[index + 1], right[index + 1]) end
)
end
if __TS__ArrayIsArray(left) then
return __TS__ArrayMap(
left,
function(____, value) return apply(nil, value, right) end
)
end
if __TS__ArrayIsArray(right) then
return __TS__ArrayMap(
right,
function(____, value) return apply(nil, left, value) end
)
end
return apply(nil, left, right)
end
function ____exports.evaluate(self, expr, env)
repeat
local ____switch78 = expr.kind
local ____cond78 = ____switch78 == "number" or ____switch78 == "string" or ____switch78 == "boolean"
if ____cond78 then
return expr.value
end
____cond78 = ____cond78 or ____switch78 == "ref"
if ____cond78 then
return env:read(expr.path)
end
____cond78 = ____cond78 or ____switch78 == "unary"
if ____cond78 then
do
local operand = ____exports.evaluate(nil, expr.operand, env)
local ____temp_2
if expr.operator == "!" then
____temp_2 = not __t(nil, operand)
else
____temp_2 = -operand
end
return ____temp_2
end
end
____cond78 = ____cond78 or ____switch78 == "binary"
if ____cond78 then
return evaluateBinary(nil, expr, env)
end
____cond78 = ____cond78 or ____switch78 == "call"
if ____cond78 then
do
local name = table.concat(expr.callee, ".")
if MATH[name] ~= nil then
local values = __TS__ArrayMap(
expr.args,
function(____, arg) return ____exports.evaluate(nil, arg, env) end
)
local length = math.max(
0,
table.unpack(__TS__ArrayMap(
values,
function(____, value) return __TS__ArrayIsArray(value) and #value or 0 end
))
)
if length == 0 and not __TS__ArraySome(values, __isArray) then
return MATH[name]:apply(values)
end
return __TS__ArrayFrom(
{length = length},
function(____, _value, index) return MATH[name]:apply(__TS__ArrayMap(
values,
function(____, value) return __TS__ArrayIsArray(value) and value[index + 1] or value end
)) end
)
end
if name == "length" then
return #({__TS__Spread(tostring(____exports.evaluate(nil, expr.args[1], env)))})
end
if name == "contains" then
return __TS__StringIncludes(
tostring(____exports.evaluate(nil, expr.args[1], env)),
tostring(____exports.evaluate(nil, expr.args[2], env))
)
end
if name == "left" then
local count = math.max(
0,
math.floor(____exports.evaluate(nil, expr.args[2], env))
)
return table.concat(
__TS__ArraySlice(
{__TS__Spread(tostring(____exports.evaluate(nil, expr.args[1], env)))},
0,
count
),
""
)
end
local condition, whenTrue, whenFalse = table.unpack(expr.args, 1, 3)
local ____t_result_3
if __t(
nil,
____exports.evaluate(nil, condition, env)
) then
____t_result_3 = ____exports.evaluate(nil, whenTrue, env)
else
____t_result_3 = ____exports.evaluate(nil, whenFalse, env)
end
return ____t_result_3
end
end
until true
end
isNumeric = function(____, ____type) return ____type == "number" or type(____type) == "table" and ____type.list == "number" end
isList = function(____, ____type) return type(____type) == "table" end
function ____exports.collectRefs(self, expr)
repeat
local ____switch5 = expr.kind
local ____cond5 = ____switch5 == "ref"
if ____cond5 then
return {expr.path}
end
____cond5 = ____cond5 or ____switch5 == "unary"
if ____cond5 then
return ____exports.collectRefs(nil, expr.operand)
end
____cond5 = ____cond5 or ____switch5 == "binary"
if ____cond5 then
local ____array_0 = __TS__SparseArrayNew(table.unpack(____exports.collectRefs(nil, expr.left)))
__TS__SparseArrayPush(
____array_0,
table.unpack(____exports.collectRefs(nil, expr.right))
)
return {__TS__SparseArraySpread(____array_0)}
end
____cond5 = ____cond5 or ____switch5 == "call"
if ____cond5 then
return __TS__ArrayFlatMap(expr.args, ____exports.collectRefs)
end
do
return {}
end
until true
end
MATH = {
round = {
arguments = 1,
apply = function(____, ____bindingPattern0)
local value
value = ____bindingPattern0[1]
return math.floor(value + 0.5)
end
},
floor = {
arguments = 1,
apply = function(____, ____bindingPattern0)
local value
value = ____bindingPattern0[1]
return math.floor(value)
end
},
ceil = {
arguments = 1,
apply = function(____, ____bindingPattern0)
local value
value = ____bindingPattern0[1]
return math.ceil(value)
end
},
abs = {
arguments = 1,
apply = function(____, ____bindingPattern0)
local value
value = ____bindingPattern0[1]
return math.abs(value)
end
},
min = {
arguments = 2,
apply = function(____, ____bindingPattern0)
local b
local a
a = ____bindingPattern0[1]
b = ____bindingPattern0[2]
return math.min(a, b)
end
},
max = {
arguments = 2,
apply = function(____, ____bindingPattern0)
local b
local a
a = ____bindingPattern0[1]
b = ____bindingPattern0[2]
return math.max(a, b)
end
},
clamp = {
arguments = 3,
apply = function(____, ____bindingPattern0)
local high
local low
local value
value = ____bindingPattern0[1]
low = ____bindingPattern0[2]
high = ____bindingPattern0[3]
return math.min(
high,
math.max(low, value)
)
end
},
moveToward = {
arguments = 3,
apply = function(____, ____bindingPattern0)
local maxStep
local target
local current
current = ____bindingPattern0[1]
target = ____bindingPattern0[2]
maxStep = ____bindingPattern0[3]
return math.abs(target - current) <= maxStep and target or current + __TS__MathSign(target - current) * maxStep
end
}
}
text = function(____, value) return type(value) == "number" and tostring(math.floor(value * 10 + 0.5) / 10) or tostring(value) end
return ____exports
end,
["core.binding.componentBinding"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____component = require("core.model.component.index")
local getComponentDescriptor = ____component.getComponentDescriptor
____exports.BINDABLE_COMPONENT_PROPERTIES = {
"value",
"valueEnd",
"disabled",
"visible",
"x",
"y",
"format"
}
function ____exports.acceptsUserChange(self, componentType)
local ____opt_2 = getComponentDescriptor(nil, componentType)
local ____opt_0 = ____opt_2 and ____opt_2.value
return (____opt_0 and ____opt_0.writable) == true
end
function ____exports.componentStateType(self, componentType, state)
local descriptor = getComponentDescriptor(nil, componentType)
if state == "focused" then
return "boolean"
end
if state == "pointer" then
return descriptor and descriptor.pointerScale and "number" or nil
end
local ____temp_10
if state == "value" then
local ____opt_6 = descriptor and descriptor.value
____temp_10 = ____opt_6 and ____opt_6.type
else
____temp_10 = nil
end
return ____temp_10
end
function ____exports.componentPropertyType(self, componentType, property)
if property == "disabled" or property == "visible" then
return "boolean"
end
if property == "x" or property == "y" then
return "number"
end
if property == "format" then
local ____opt_11 = getComponentDescriptor(nil, componentType)
return ____opt_11 and ____opt_11.properties.format and "string" or nil
end
if property == "valueEnd" then
local ____opt_15 = getComponentDescriptor(nil, componentType)
local ____opt_13 = ____opt_15 and ____opt_15.properties.valueEnd
return (____opt_13 and ____opt_13.type) == "number" and "number" or nil
end
local ____temp_21
if property == "value" then
local ____opt_19 = getComponentDescriptor(nil, componentType)
local ____opt_17 = ____opt_19 and ____opt_19.value
____temp_21 = ____opt_17 and ____opt_17.type
else
____temp_21 = nil
end
return ____temp_21
end
function ____exports.twoWayTargetProblem(self, key, expr, contracts)
local target = expr.kind == "ref" and expr.path or nil
local ____temp_24
if (target and #target) == 2 then
____temp_24 = contracts:get(target[1])
else
____temp_24 = nil
end
local contract = ____temp_24
if not target or (contract and contract.mode) ~= "record" or not __t(nil, contract.fields[target[2]]) then
return ("'<->' on '" .. key) .. "' has to name one field of a record DataSource, as in .."
end
if contract.writable and not __TS__ArrayIncludes(contract.writable, target[2]) then
return ((((("'<->' on '" .. key) .. "' writes '") .. table.concat(target, ".")) .. "', which DataSource '") .. target[1]) .. "' does not list as writable."
end
return nil
end
return ____exports
end,
["core.binding.contract"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayEntries = ____lualib.__TS__ArrayEntries
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local identOf, writableFields
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____types = require("core.binding.types")
local scalarOf = ____types.scalarOf
function identOf(self, value)
return (value and value.type) == "ident" and table.concat(value.segments, ".") or nil
end
function writableFields(self, contract, value, diagnostics)
local function report(____, message)
local ____temp_7 = #diagnostics + 1
diagnostics[____temp_7] = {
severity = "error",
code = "writable-list",
message = message,
line = 0,
col = 0
}
return ____temp_7
end
if value.type ~= "list" then
report(nil, ("'writable' of DataSource '" .. contract.name) .. "' is a list of its fields, as in writable: [offset, gain].")
return {}
end
local names = __TS__ArrayMap(value.values, identOf)
for ____, ____value in __TS__Iterator(__TS__ArrayEntries(names)) do
local index = ____value[1]
local name = ____value[2]
if name == nil then
report(
nil,
((("'writable' of DataSource '" .. contract.name) .. "' holds something that is not the name of a field, at place ") .. tostring(index + 1)) .. "."
)
elseif not __t(nil, contract.fields[name]) then
report(nil, ((("'writable' of DataSource '" .. contract.name) .. "' names '") .. name) .. "', which is not one of its fields.")
end
end
return __TS__ArrayFilter(
names,
function(____, name) return name ~= nil end
)
end
local function readContract(self, block, diagnostics)
local properties = __TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "property" and ({entry.property}) or ({}) end
)
local ____identOf_4 = identOf
local ____opt_2 = __TS__ArrayFind(
properties,
function(____, property) return property.key == "mode" end
)
local mode = ____identOf_4(nil, ____opt_2 and ____opt_2.value) == "record" and "record" or "table"
local contract = {name = block.name, mode = mode, fields = {}, declared = {}}
local ____opt_5 = __TS__ArrayFind(
properties,
function(____, property) return property.key == "writable" end
)
local writable = ____opt_5 and ____opt_5.value
for ____, entry in ipairs(block.entries) do
if entry.type == "fields" then
for ____, field in ipairs(entry.fields) do
local declared = identOf(nil, field.value) or ""
local scalar = scalarOf(nil, declared)
if __t(nil, scalar) then
contract.fields[field.key] = scalar
contract.declared[field.key] = declared
else
diagnostics[#diagnostics + 1] = {
severity = "error",
code = "unknown-field-type",
message = ((((("Field '" .. block.name) .. ".") .. field.key) .. "' has unknown type '") .. declared) .. "' (use int, float, number, string or bool).",
line = 0,
col = 0
}
end
end
end
end
if writable then
contract.writable = writableFields(nil, contract, writable, diagnostics)
end
return contract
end
function ____exports.visitBlocks(self, blocks, visit)
for ____, block in ipairs(blocks) do
visit(nil, block)
____exports.visitBlocks(
nil,
__TS__ArrayFlatMap(
block.entries,
function(____, entry) return entry.type == "block" and ({entry.block}) or ({}) end
),
visit
)
end
end
function ____exports.collectParameterContracts(self, sflDocument)
local contracts = {}
____exports.visitBlocks(
nil,
sflDocument.blocks,
function(____, block)
if block.kind ~= "Parameters" then
return
end
local contract = {
name = block.name,
mode = "record",
fields = {},
declared = {},
parameters = {}
}
for ____, entry in ipairs(block.entries) do
if entry.type == "property" and entry.property.value.type == "number" then
contract.fields[entry.property.key] = "number"
contract.declared[entry.property.key] = "number"
contract.parameters[entry.property.key] = entry.property.value.value
end
end
contracts[#contracts + 1] = contract
end
)
return contracts
end
function ____exports.collectContracts(self, sflDocument)
local contracts = __TS__New(Map)
local diagnostics = {}
____exports.visitBlocks(
nil,
sflDocument.blocks,
function(____, block)
if block.kind ~= "DataSource" then
return
end
if contracts:has(block.name) then
diagnostics[#diagnostics + 1] = {
severity = "error",
code = "duplicate-data-source",
message = ("DataSource '" .. block.name) .. "' is declared more than once.",
line = 0,
col = 0
}
return
end
contracts:set(
block.name,
readContract(nil, block, diagnostics)
)
end
)
return {contracts = contracts, diagnostics = diagnostics}
end
return ____exports
end,
["core.binding.targets"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local PLACE = {
x = "number",
y = "number",
width = "number",
height = "number",
visible = "boolean"
}
local MESH = {
color = "string",
opacity = "number",
roughness = "number",
metallic = "number",
positionX = "number",
positionY = "number",
positionZ = "number",
rotationX = "number",
rotationY = "number",
rotationZ = "number",
scale = "number",
scaleX = "number",
scaleY = "number",
scaleZ = "number"
}
____exports.BINDABLE_PROPERTIES = {
Chart = {categories = {list = "string"}, text = "string"},
Series = {values = {list = "number"}, label = "string"},
Shape = __TS__ObjectAssign({
text = "string",
fill = "string",
stroke = "string",
textColor = "string",
opacity = "number"
}, PLACE),
Image = __TS__ObjectAssign({opacity = "number"}, PLACE),
Path = {stroke = "string", opacity = "number", visible = "boolean"},
Light = {
turn = "number",
elevation = "number",
height = "number",
color = "string",
intensity = "number",
ambient = "number"
},
Canvas = {
positionX = "number",
positionY = "number",
positionZ = "number",
rotationX = "number",
rotationY = "number",
rotationZ = "number",
scale = "number",
scaleX = "number",
scaleY = "number",
scaleZ = "number"
},
Mesh = MESH,
Solid = MESH,
Facets = MESH,
Terrain = MESH,
Text = __TS__ObjectAssign({text = "string", textColor = "string", opacity = "number"}, PLACE)
}
return ____exports
end,
["core.binding.graph"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local Set = ____lualib.Set
local __TS__Spread = ____lualib.__TS__Spread
local ____exports = {}
local blockKind
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____component = require("core.model.component.index")
local getComponentDescriptor = ____component.getComponentDescriptor
local ____expansion = require("core.sflLanguage.expansion.index")
local expandDocument = ____expansion.expandDocument
local ____componentBinding = require("core.binding.componentBinding")
local acceptsUserChange = ____componentBinding.acceptsUserChange
local BINDABLE_COMPONENT_PROPERTIES = ____componentBinding.BINDABLE_COMPONENT_PROPERTIES
local componentPropertyType = ____componentBinding.componentPropertyType
local componentStateType = ____componentBinding.componentStateType
local twoWayTargetProblem = ____componentBinding.twoWayTargetProblem
local ____contract = require("core.binding.contract")
local collectContracts = ____contract.collectContracts
local collectParameterContracts = ____contract.collectParameterContracts
local visitBlocks = ____contract.visitBlocks
local ____expression = require("core.binding.expression")
local collectRefs = ____expression.collectRefs
local inferType = ____expression.inferType
local ____targets = require("core.binding.targets")
local BINDABLE_PROPERTIES = ____targets.BINDABLE_PROPERTIES
local ____types = require("core.binding.types")
local CHANGE_EVENT = ____types.CHANGE_EVENT
local POINTER_EVENTS = ____types.POINTER_EVENTS
local sameType = ____types.sameType
local TEXT_EVENTS = ____types.TEXT_EVENTS
local TICK_EVENT = ____types.TICK_EVENT
local typeName = ____types.typeName
function ____exports.listed(self, fields)
return #fields == 0 and "no field" or table.concat(
__TS__ArrayMap(
fields,
function(____, field) return ("'" .. field) .. "'" end
),
", "
)
end
local function collectSites(self, blocks, chartPath, sites)
for ____, block in ipairs(blocks) do
local ____temp_1
if block.kind == "Series" then
local ____array_0 = __TS__SparseArrayNew(table.unpack(chartPath))
__TS__SparseArrayPush(____array_0, block.name)
____temp_1 = {__TS__SparseArraySpread(____array_0)}
else
____temp_1 = {block.name}
end
local path = ____temp_1
local ownChart = block.kind == "Chart" and ({block.name}) or chartPath
for ____, entry in ipairs(block.entries) do
if entry.type == "binding" then
sites[#sites + 1] = {
kind = blockKind(nil, block),
path = path,
binding = entry.binding
}
elseif entry.type == "style" or entry.type == "layout" then
for ____, binding in ipairs((entry.type == "style" and entry.style or entry.layout).bindings or ({})) do
sites[#sites + 1] = {
kind = blockKind(nil, block),
path = path,
binding = binding
}
end
elseif entry.type == "block" then
collectSites(nil, {entry.block}, ownChart, sites)
elseif entry.type == "data" then
for ____, inner in ipairs(entry.data.entries) do
if inner.type == "binding" then
sites[#sites + 1] = {kind = "Chart", path = ownChart, binding = inner.binding}
elseif inner.type == "block" then
collectSites(nil, {inner.block}, ownChart, sites)
end
end
end
end
end
end
local function fieldType(self, contract, field)
local ____type = contract.fields[field]
if not __t(nil, ____type) then
return nil
end
return contract.mode == "table" and ({list = ____type}) or ____type
end
local INTERACTIVE_KINDS = {
"Shape",
"Text",
"Component",
"Mesh",
"Solid",
"Facets",
"Terrain"
}
blockKind = function(____, block) return block.kind == "Widget" and "Component" or block.kind end
local function collectElements(self, sflDocument)
local elements = __TS__New(Map)
visitBlocks(
nil,
sflDocument.blocks,
function(____, block)
if not __TS__ArrayIncludes(
INTERACTIVE_KINDS,
blockKind(nil, block)
) or elements:has(block.name) then
return
end
local ____type = __TS__ArrayFind(
block.entries,
function(____, entry) return entry.type == "property" and entry.property.key == "type" end
)
local value = (____type and ____type.type) == "property" and ____type.property.value or nil
elements:set(
block.name,
{
kind = blockKind(nil, block),
componentType = (value and value.type) == "ident" and table.concat(value.segments, ".") or nil
}
)
end
)
return elements
end
local function elementStateType(self, element, state)
if state == "pressed" or state == "hovered" then
return "boolean"
end
local ____temp_6
if element.kind == "Component" then
____temp_6 = componentStateType(nil, element.componentType, state)
else
____temp_6 = nil
end
return ____temp_6
end
local function createScope(self, contracts, elements, ticking, selfAvailable)
if ticking == nil then
ticking = false
end
if selfAvailable == nil then
selfAvailable = false
end
return {resolve = function(self, path)
if #path ~= 2 then
return nil
end
if selfAvailable and path[1] == "self" and path[2] == "id" then
return "string"
end
local contract = contracts:get(path[1])
if contract then
return fieldType(nil, contract, path[2])
end
if ticking and path[1] == "time" and path[2] == "delta" then
return "number"
end
local element = elements:get(path[1])
local ____element_7
if element then
____element_7 = elementStateType(nil, element, path[2])
else
____element_7 = nil
end
return ____element_7
end}
end
local function qualify(self, expr, source)
repeat
local ____switch33 = expr.kind
local ____cond33 = ____switch33 == "ref"
if ____cond33 then
return #expr.path == 1 and source.fields[expr.path[1]] ~= nil and ({kind = "ref", path = {source.name, expr.path[1]}}) or expr
end
____cond33 = ____cond33 or ____switch33 == "unary"
if ____cond33 then
return __TS__ObjectAssign(
{},
expr,
{operand = qualify(nil, expr.operand, source)}
)
end
____cond33 = ____cond33 or ____switch33 == "binary"
if ____cond33 then
return __TS__ObjectAssign(
{},
expr,
{
left = qualify(nil, expr.left, source),
right = qualify(nil, expr.right, source)
}
)
end
____cond33 = ____cond33 or ____switch33 == "call"
if ____cond33 then
return __TS__ObjectAssign(
{},
expr,
{args = __TS__ArrayMap(
expr.args,
function(____, arg) return qualify(nil, arg, source) end
)}
)
end
do
return expr
end
until true
end
local function collectHandlerSites(self, sflDocument)
local sites = {}
visitBlocks(
nil,
sflDocument.blocks,
function(____, block)
for ____, entry in ipairs(block.entries) do
if entry.type == "handler" then
sites[#sites + 1] = {
kind = blockKind(nil, block),
name = block.name,
handler = entry.handler
}
end
end
end
)
return sites
end
local function allowedEvents(self, kind, componentType)
if kind == "DataSource" then
return {TICK_EVENT}
end
if not __TS__ArrayIncludes(INTERACTIVE_KINDS, kind) then
return {}
end
local changes = kind == "Component" and acceptsUserChange(nil, componentType)
local ____temp_10 = kind == "Component"
if ____temp_10 then
local ____opt_8 = getComponentDescriptor(nil, componentType)
____temp_10 = (____opt_8 and ____opt_8.interaction) == "type"
end
local typed = ____temp_10
local ____array_11 = __TS__SparseArrayNew(table.unpack(POINTER_EVENTS))
__TS__SparseArrayPush(
____array_11,
table.unpack(changes and ({CHANGE_EVENT}) or ({}))
)
__TS__SparseArrayPush(
____array_11,
table.unpack(typed and TEXT_EVENTS or ({}))
)
return {__TS__SparseArraySpread(____array_11)}
end
local function eventIsKnown(self, site, componentType, report)
local ____site_12 = site
local kind = ____site_12.kind
local name = ____site_12.name
local handler = ____site_12.handler
local allowed = allowedEvents(nil, kind, componentType)
if __TS__ArrayIncludes(allowed, handler.event) then
return true
end
report(
nil,
"unknown-event",
__t(nil, #allowed) and ((((((kind .. " '") .. name) .. "' has no event '") .. handler.event) .. "' (events: ") .. table.concat(allowed, ", ")) .. ")." or ((kind .. " '") .. name) .. "' has no events; handlers belong on a Shape, Text, Component, a body in a Scene or DataSource."
)
return false
end
local function bindAssignment(self, assignment, name, own, contracts, scope, report)
local function at(____, code, message)
return report(
nil,
code,
message,
assignment.line,
assignment.col
)
end
local target = table.concat(assignment.target, ".")
local source, field = table.unpack(own and #assignment.target == 1 and ({own.name, assignment.target[1]}) or assignment.target, 1, 2)
local ____temp_13
if #assignment.target <= 2 then
____temp_13 = contracts:get(source)
else
____temp_13 = nil
end
local contract = ____temp_13
if not contract or field == nil then
at(nil, "unknown-target", ("'" .. target) .. "' is not a field of a DataSource (write .).")
return nil
end
if own and contract ~= own then
at(nil, "tick-foreign-target", ((((("onTick of '" .. name) .. "' can only change fields of '") .. name) .. "', not '") .. target) .. "'.")
return nil
end
if contract.mode ~= "record" then
at(nil, "target-not-record", ("DataSource '" .. source) .. "' is a table source; only record sources can be changed by a handler.")
return nil
end
local wanted = contract.fields[field]
if not __t(nil, wanted) then
at(nil, "unknown-target", ((("DataSource '" .. source) .. "' has no field '") .. field) .. "'.")
return nil
end
if contract.writable and not __TS__ArrayIncludes(contract.writable, field) then
at(
nil,
"field-not-writable",
((((("'" .. target) .. "' cannot be written: DataSource '") .. source) .. "' lists ") .. ____exports.listed(nil, contract.writable)) .. " as writable."
)
return nil
end
local expr = own and qualify(nil, assignment.expr, own) or assignment.expr
local actual = inferType(
nil,
expr,
scope,
function(____, code, message) return at(nil, code, message) end
)
if not __t(nil, actual) then
return nil
end
if not sameType(nil, actual, wanted) then
at(
nil,
"type-mismatch",
((((("'" .. target) .. "' is ") .. wanted) .. ", the expression is ") .. typeName(nil, actual)) .. "."
)
return nil
end
return {
source = source,
field = field,
expr = expr,
type = wanted,
line = assignment.line,
col = assignment.col
}
end
local function bindHandler(self, site, contracts, elements, diagnostics)
local ____site_14 = site
local kind = ____site_14.kind
local name = ____site_14.name
local handler = ____site_14.handler
local function report(____, code, message, line, col)
if line == nil then
line = handler.line
end
if col == nil then
col = handler.col
end
local ____temp_15 = #diagnostics + 1
diagnostics[____temp_15] = {
severity = "error",
code = code,
message = message,
line = line,
col = col
}
return ____temp_15
end
local ____eventIsKnown_19 = eventIsKnown
local ____site_18 = site
local ____opt_16 = elements:get(name)
if not ____eventIsKnown_19(nil, ____site_18, ____opt_16 and ____opt_16.componentType, report) then
return nil
end
local ticking = kind == "DataSource"
local ____ticking_20
if ticking then
____ticking_20 = contracts:get(name)
else
____ticking_20 = nil
end
local own = ____ticking_20
if ticking and (own and own.mode) ~= "record" then
report(nil, "tick-needs-record", ("DataSource '" .. name) .. "' has to be a record source to change its fields on every tick.")
return nil
end
local scope = createScope(
nil,
contracts,
elements,
ticking,
not ticking
)
local assignments = __TS__ArrayFlatMap(
handler.assignments,
function(____, assignment) return bindAssignment(
nil,
assignment,
name,
own,
contracts,
scope,
report
) or ({}) end
)
return {
id = (((kind .. ".") .. name) .. ".") .. handler.event,
ownerKind = kind,
ownerPath = {name},
event = handler.event,
assignments = assignments,
line = handler.line,
col = handler.col
}
end
local function warnNameCollisions(self, contracts, elements, diagnostics)
for ____, name in __TS__Iterator(elements:keys()) do
if contracts:has(name) then
diagnostics[#diagnostics + 1] = {
severity = "warning",
code = "name-collision",
message = ("'" .. name) .. "' is a DataSource and an element; in expressions it means the DataSource.",
line = 0,
col = 0
}
end
end
end
local function expectedType(self, site, elements)
local ____site_23 = site
local kind = ____site_23.kind
local path = ____site_23.path
local binding = ____site_23.binding
if kind == "Shader" then
return "number"
end
if kind == "Component" then
local ____componentPropertyType_26 = componentPropertyType
local ____opt_24 = elements:get(path[1])
return ____componentPropertyType_26(nil, ____opt_24 and ____opt_24.componentType, binding.key)
end
local ____opt_27 = BINDABLE_PROPERTIES[kind]
return ____opt_27 and ____opt_27[binding.key]
end
local function canBindTwoWay(self, site, elements)
local ____site_29 = site
local kind = ____site_29.kind
local path = ____site_29.path
local binding = ____site_29.binding
local ____temp_33 = kind == "Component" and (binding.key == "value" or binding.key == "valueEnd")
if ____temp_33 then
local ____acceptsUserChange_32 = acceptsUserChange
local ____opt_30 = elements:get(path[1])
____temp_33 = ____acceptsUserChange_32(nil, ____opt_30 and ____opt_30.componentType)
end
return ____temp_33
end
local function rejectedOperator(self, site, elements, contracts)
local ____site_34 = site
local binding = ____site_34.binding
local twoWay = binding.operator == "<->"
if binding.operator == "->" or twoWay and not canBindTwoWay(nil, site, elements) then
return {code = "binding-operator-unsupported", message = ((("'" .. binding.operator) .. "' on '") .. binding.key) .. "' is parsed but not executed; '<->' works on the value of a component that the user can change, and '->' is not supported.", severity = "warning"}
end
local ____twoWay_35
if twoWay then
____twoWay_35 = twoWayTargetProblem(nil, binding.key, binding.expr, contracts)
else
____twoWay_35 = nil
end
local problem = ____twoWay_35
return __t(nil, problem) and ({code = "two-way-target", message = problem, severity = "error"}) or nil
end
local function bindProperty(self, site, scope, elements, contracts, diagnostics)
local ____site_36 = site
local kind = ____site_36.kind
local path = ____site_36.path
local binding = ____site_36.binding
local owner = table.concat(path, ".")
local function report(____, code, message, severity)
if severity == nil then
severity = "error"
end
local ____temp_37 = #diagnostics + 1
diagnostics[____temp_37] = {
severity = severity,
code = code,
message = message,
line = binding.line,
col = binding.col
}
return ____temp_37
end
local rejected = rejectedOperator(nil, site, elements, contracts)
if rejected then
report(nil, rejected.code, rejected.message, rejected.severity)
return nil
end
local expected = expectedType(nil, site, elements)
if not __t(nil, expected) then
local allowed = kind == "Component" and BINDABLE_COMPONENT_PROPERTIES or __TS__ObjectKeys(BINDABLE_PROPERTIES[kind] or ({}))
report(
nil,
"unknown-bound-property",
((((((kind .. " '") .. owner) .. "' has no bindable property '") .. binding.key) .. "'") .. (__t(nil, #allowed) and (" (bindable: " .. table.concat(allowed, ", ")) .. ")" or "")) .. "."
)
return nil
end
local actual = inferType(nil, binding.expr, scope, report)
if not __t(nil, actual) then
return nil
end
if not sameType(nil, actual, expected) then
report(
nil,
"type-mismatch",
((((("'" .. binding.key) .. "' expects ") .. typeName(nil, expected)) .. ", the expression is ") .. typeName(nil, actual)) .. "."
)
return nil
end
return {
id = (((kind .. ".") .. owner) .. ".") .. binding.key,
ownerKind = kind,
ownerPath = path,
property = binding.key,
operator = binding.operator,
expr = binding.expr,
type = expected,
dependencies = {__TS__Spread(__TS__New(
Set,
__TS__ArrayMap(
collectRefs(nil, binding.expr),
function(____, ref) return table.concat(ref, ".") end
)
))},
line = binding.line,
col = binding.col
}
end
local function indexByField(self, bindings)
local byField = __TS__New(Map)
for ____, binding in ipairs(bindings) do
for ____, dependency in ipairs(binding.dependencies) do
local ____byField_set_39 = byField.set
local ____array_38 = __TS__SparseArrayNew(table.unpack(byField:get(dependency) or ({})))
__TS__SparseArrayPush(____array_38, binding)
____byField_set_39(
byField,
dependency,
{__TS__SparseArraySpread(____array_38)}
)
end
end
return byField
end
function ____exports.buildBindingGraph(self, source, tables)
local sflDocument = expandDocument(nil, source, tables)
local ____collectContracts_result_40 = collectContracts(nil, sflDocument)
local contracts = ____collectContracts_result_40.contracts
local diagnostics = ____collectContracts_result_40.diagnostics
for ____, contract in ipairs(collectParameterContracts(nil, source)) do
if contracts:has(contract.name) then
diagnostics[#diagnostics + 1] = {
severity = "error",
code = "duplicate-data-source",
message = ("'" .. contract.name) .. "' is a DataSource and a Parameters block; give one of them another name.",
line = 0,
col = 0
}
else
contracts:set(contract.name, contract)
end
end
local elements = collectElements(nil, sflDocument)
warnNameCollisions(nil, contracts, elements, diagnostics)
local scope = createScope(
nil,
contracts,
elements,
false,
true
)
local sites = {}
collectSites(nil, sflDocument.blocks, {}, sites)
local bindings = __TS__ArrayFlatMap(
sites,
function(____, site) return bindProperty(
nil,
site,
scope,
elements,
contracts,
diagnostics
) or ({}) end
)
local handlers = __TS__ArrayFlatMap(
collectHandlerSites(nil, sflDocument),
function(____, site) return bindHandler(
nil,
site,
contracts,
elements,
diagnostics
) or ({}) end
)
return {
contracts = contracts,
bindings = bindings,
handlers = handlers,
elements = elements,
byField = indexByField(nil, bindings),
diagnostics = diagnostics
}
end
return ____exports
end,
["core.binding.interactive"] = function(...)
local ____lualib = require("lualib_bundle")
local Set = ____lualib.Set
local __TS__New = ____lualib.__TS__New
local __TS__ArrayForEach = ____lualib.__TS__ArrayForEach
local __TS__Iterator = ____lualib.__TS__Iterator
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____component = require("core.model.component.index")
local getComponentDescriptor = ____component.getComponentDescriptor
local ____expression = require("core.binding.expression")
local collectRefs = ____expression.collectRefs
local OPERATED = __TS__New(Set, {
"toggle",
"press",
"slide",
"pick",
"turn",
"range"
})
function ____exports.interactiveElements(self, graph)
local pressable = __TS__New(Set)
local scales = __TS__New(Set)
local function note(____, ____bindingPattern0)
local state
local name
name = ____bindingPattern0[1]
state = ____bindingPattern0[2]
if graph.contracts:has(name) or not graph.elements:has(name) then
return
end
(state == "pointer" and scales or pressable):add(name)
end
for ____, handler in ipairs(graph.handlers) do
if handler.ownerKind ~= "DataSource" then
pressable:add(handler.ownerPath[1])
end
for ____, assignment in ipairs(handler.assignments) do
__TS__ArrayForEach(
collectRefs(nil, assignment.expr),
note
)
end
end
for ____, binding in ipairs(graph.bindings) do
__TS__ArrayForEach(
collectRefs(nil, binding.expr),
note
)
end
for ____, ____value in __TS__Iterator(graph.elements) do
local name = ____value[1]
local info = ____value[2]
local ____opt_0 = getComponentDescriptor(nil, info.componentType)
local interaction = ____opt_0 and ____opt_0.interaction
if info.kind == "Component" and __t(nil, interaction) and OPERATED:has(interaction) and not graph.contracts:has(name) then
pressable:add(name)
end
end
return {pressable = pressable, scales = scales}
end
return ____exports
end,
["core.binding.runtimeTypes"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
return ____exports
end,
["core.binding.checkData"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__TypeOf = ____lualib.__TS__TypeOf
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__NumberIsInteger = ____lualib.__TS__NumberIsInteger
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
local ____exports = {}
local function typeOfValue(____, value)
return (type(value) == "number" or type(value) == "string" or type(value) == "boolean") and __TS__TypeOf(value) or "other"
end
function ____exports.checkData(self, contract, data)
local rows = __TS__ArrayIsArray(data) and data or ({data})
if contract.mode == "table" ~= __TS__ArrayIsArray(data) then
return ((((("DataSource '" .. contract.name) .. "' is a ") .. contract.mode) .. " source but delivered ") .. (__TS__ArrayIsArray(data) and "rows" or "a record")) .. "."
end
for ____, row in ipairs(rows) do
for ____, ____value in ipairs(__TS__ObjectEntries(contract.fields)) do
local field = ____value[1]
local ____type = ____value[2]
if typeOfValue(nil, row[field]) ~= ____type then
return ((((((("'" .. contract.name) .. ".") .. field) .. "' should be ") .. contract.declared[field]) .. ", got ") .. typeOfValue(nil, row[field])) .. "."
end
if contract.declared[field] == "int" and not __TS__NumberIsInteger(row[field]) then
return ((((("'" .. contract.name) .. ".") .. field) .. "' should be a whole number (int), got ") .. tostring(row[field])) .. "."
end
end
end
return nil
end
return ____exports
end,
["core.binding.remake"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__Number = ____lualib.__TS__Number
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local ____exports = {}
local ______shims = require("core.__shims")
local __clone = ______shims.__clone
local __isFinite = ______shims.__isFinite
local __microtask = ______shims.__microtask
local ____fromSfl = require("core.renderInput.fromSfl.index")
local documentToRenderInput = ____fromSfl.documentToRenderInput
local ____expansion = require("core.sflLanguage.expansion.index")
local eachSources = ____expansion.eachSources
local withParameterValues = ____expansion.withParameterValues
local ____evaluation = require("core.binding.evaluation")
local flush = ____evaluation.flush
local ____graph = require("core.binding.graph")
local buildBindingGraph = ____graph.buildBindingGraph
local ____runtimeState = require("core.binding.runtimeState")
local addElementStates = ____runtimeState.addElementStates
local function parameterValues(self, state)
local values = __TS__New(Map)
for ____, contract in __TS__Iterator(state.graph.contracts:values()) do
do
if not contract.parameters then
goto __continue3
end
local ____opt_0 = state.sources:get(contract.name)
local row = ____opt_0 and ____opt_0:get()
for ____, key in ipairs(__TS__ObjectKeys(contract.fields)) do
local value = __TS__Number(row and row[key])
if __isFinite(nil, value) then
values:set((contract.name .. ".") .. key, value)
end
end
end
::__continue3::
end
return values
end
function ____exports.tableRows(self, state)
local tables = __TS__New(Map)
local ____state_document_4 = state.document
local blocks = ____state_document_4.blocks
for ____, name in __TS__Iterator(eachSources(nil, blocks)) do
local ____opt_5 = state.sources:get(name)
local rows = ____opt_5 and ____opt_5:get()
if __TS__ArrayIsArray(rows) then
tables:set(name, rows)
end
end
return tables
end
function ____exports.remake(self, state)
local document = withParameterValues(
nil,
state.document,
parameterValues(nil, state)
)
local tables = ____exports.tableRows(nil, state)
state.graph = buildBindingGraph(nil, document, tables)
state.input = __clone(
nil,
documentToRenderInput(nil, document, tables)
)
addElementStates(nil, state.graph, state.input, state.elementState)
state.applied:clear()
for ____, binding in ipairs(state.graph.bindings) do
state.dirty:add(binding)
end
state.renderNeeded = true
flush(nil, state)
end
function ____exports.remakeNow(self, state)
if state.remakePending then
state.remakePending = false
____exports.remake(nil, state)
end
end
function ____exports.requestRemake(self, state)
if state.remakePending then
return
end
state.remakePending = true
local function run()
return ____exports.remakeNow(nil, state)
end
local frame = _G.requestAnimationFrame
if frame then
frame(nil, run)
else
__microtask(nil, run)
end
end
return ____exports
end,
["core.binding.writes"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__ArrayFlatMap = ____lualib.__TS__ArrayFlatMap
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
local __TS__ObjectFromEntries = ____lualib.__TS__ObjectFromEntries
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ____graph = require("core.binding.graph")
local listed = ____graph.listed
local function warnOnce(self, state, name, code, message, line, col)
local key = "write:" .. name
if state.warned:has(key) then
return
end
state.warned:add(key)
local ____state_diagnostics_0 = state.diagnostics
____state_diagnostics_0[#____state_diagnostics_0 + 1] = {
severity = "warning",
code = code,
message = message,
line = line,
col = col
}
end
function ____exports.sourceWrites(self, graph)
local writes = __TS__ArrayFlatMap(
graph.handlers,
function(____, handler) return __TS__ArrayMap(
handler.assignments,
function(____, ____bindingPattern0)
local col
local line
local field
local source
source = ____bindingPattern0.source
field = ____bindingPattern0.field
line = ____bindingPattern0.line
col = ____bindingPattern0.col
return {source = source, field = field, line = line, col = col}
end
) end
)
for ____, binding in ipairs(graph.bindings) do
local target = binding.operator == "<->" and binding.expr.kind == "ref" and binding.expr.path or nil
if (target and target[2]) ~= nil then
writes[#writes + 1] = {source = target[1], field = target[2], line = binding.line, col = binding.col}
end
end
return writes
end
function ____exports.hostWriteProblems(self, graph, name, allowed)
return __TS__ArrayMap(
__TS__ArrayFilter(
____exports.sourceWrites(nil, graph),
function(____, write) return write.source == name and not __TS__ArrayIncludes(allowed, write.field) end
),
function(____, ____bindingPattern0)
local col
local line
local field
field = ____bindingPattern0.field
line = ____bindingPattern0.line
col = ____bindingPattern0.col
return {
severity = "error",
code = "write-not-allowed",
message = ((((("'" .. name) .. ".") .. field) .. "' is written by the document, but the host does not let it be written (it allows ") .. listed(nil, allowed)) .. ").",
line = line,
col = col
}
end
)
end
function ____exports.checkHostWritable(self, state, name, allowed)
__TS__ArrayPushArray(
state.diagnostics,
____exports.hostWriteProblems(nil, state.graph, name, allowed)
)
end
function ____exports.writeFields(self, state, name, fields, line, col)
local source = state.sources:get(name)
if not source then
warnOnce(
nil,
state,
name,
"source-not-registered",
("DataSource '" .. name) .. "' has no registered source, so writing to it does nothing.",
line,
col
)
return
end
local row = source:get()
if __TS__ArrayIsArray(row) then
return
end
local allowed = source.writable
local changed = __TS__ObjectFromEntries(__TS__ArrayFilter(
__TS__ObjectEntries(fields),
function(____, ____bindingPattern0)
local value
local field
field = ____bindingPattern0[1]
value = ____bindingPattern0[2]
return row[field] ~= value and (not allowed or __TS__ArrayIncludes(allowed, field))
end
))
if #__TS__ObjectKeys(changed) == 0 then
return
end
if source.write ~= nil and type(source.write) == "function" then
source:write(changed)
elseif source.set ~= nil and type(source.set) == "function" then
source:set(__TS__ObjectAssign({}, row, changed))
else
warnOnce(
nil,
state,
name,
"source-not-writable",
("DataSource '" .. name) .. "' was registered without write or set, so writing to it does nothing.",
line,
col
)
end
end
return ____exports
end,
["core.binding.sources"] = function(...)
local ____lualib = require("lualib_bundle")
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local ______shims = require("core.__shims")
local __t = ______shims.__t
local ____expansion = require("core.sflLanguage.expansion.index")
local eachSources = ____expansion.eachSources
local ____checkData = require("core.binding.checkData")
local checkData = ____checkData.checkData
local ____evaluation = require("core.binding.evaluation")
local markDirty = ____evaluation.markDirty
local schedule = ____evaluation.schedule
local ____remake = require("core.binding.remake")
local requestRemake = ____remake.requestRemake
local ____writes = require("core.binding.writes")
local checkHostWritable = ____writes.checkHostWritable
local function remade(self, state, name)
local ____state_document_0 = state.document
local blocks = ____state_document_0.blocks
local ____Boolean_3 = Boolean
local ____opt_1 = state.graph.contracts:get(name)
return ____Boolean_3(nil, ____opt_1 and ____opt_1.parameters) or eachSources(nil, blocks):has(name)
end
local function adopt(self, state, name, registration)
local contract = state.graph.contracts:get(name)
if not contract or Boolean(nil, contract.parameters) ~= registration.own then
return
end
local problem = checkData(
nil,
contract,
registration.source:get()
)
if __t(nil, problem) then
local ____state_diagnostics_4 = state.diagnostics
____state_diagnostics_4[#____state_diagnostics_4 + 1] = {
severity = "error",
code = "data-type-mismatch",
message = problem,
line = 0,
col = 0
}
return
end
state.sources:set(name, registration.source)
state.warned:delete(name)
state.warned:delete("write:" .. name)
markDirty(nil, state, name)
schedule(nil, state)
end
function ____exports.registerSource(self, state, name, source, own)
if own == nil then
own = false
end
if not state.graph.contracts:has(name) then
error(
__TS__New(Error, ("No DataSource '" .. name) .. "' is declared in the SFL."),
0
)
end
if source.writable then
checkHostWritable(nil, state, name, source.writable)
end
local registration = {
source = source,
own = own,
unsubscribe = function() return nil end
}
state.registered:set(name, registration)
adopt(nil, state, name, registration)
if not own and remade(nil, state, name) then
requestRemake(nil, state)
end
registration.unsubscribe = source:subscribe(function()
if state.registered:get(name) ~= registration then
return
end
adopt(nil, state, name, registration)
if state.sources:get(name) == source and remade(nil, state, name) then
requestRemake(nil, state)
end
end)
return function()
registration:unsubscribe()
if state.registered:get(name) == registration then
state.registered:delete(name)
state.sources:delete(name)
end
end
end
return ____exports
end,
["core.binding.runtimeState"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Number = ____lualib.__TS__Number
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local Set = ____lualib.Set
local __TS__Iterator = ____lualib.__TS__Iterator
local Error = ____lualib.Error
local RangeError = ____lualib.RangeError
local ReferenceError = ____lualib.ReferenceError
local SyntaxError = ____lualib.SyntaxError
local TypeError = ____lualib.TypeError
local URIError = ____lualib.URIError
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayMap = ____lualib.__TS__ArrayMap
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local ____exports = {}
local initialValue
local ______shims = require("core.__shims")
local __clone = ______shims.__clone
local __isFinite = ______shims.__isFinite
local ____component = require("core.model.component.index")
local getComponentDescriptor = ____component.getComponentDescriptor
local ____fromSfl = require("core.renderInput.fromSfl.index")
local documentToRenderInput = ____fromSfl.documentToRenderInput
local ____sflLanguage = require("core.sflLanguage.index")
local parse = ____sflLanguage.parse
local ____applyValue = require("core.binding.applyValue")
local findComponent = ____applyValue.findComponent
local ____graph = require("core.binding.graph")
local buildBindingGraph = ____graph.buildBindingGraph
function initialValue(self, input, id, componentType)
local descriptor = getComponentDescriptor(nil, componentType)
local ____opt_0 = findComponent(nil, input, id)
local current = ____opt_0 and ____opt_0.value
if current == nil then
local ____opt_2 = descriptor and descriptor.value
local ____temp_6 = ____opt_2 and ____opt_2.default
if ____temp_6 == nil then
____temp_6 = 0
end
return ____temp_6
end
local ____opt_7 = descriptor and descriptor.value
if (____opt_7 and ____opt_7.type) == "number" then
local value = __TS__Number(current)
return __isFinite(nil, value) and value or descriptor.value.default
end
return current
end
function ____exports.addElementStates(self, graph, input, elementState)
for ____, ____value in __TS__Iterator(graph.elements) do
local name = ____value[1]
local info = ____value[2]
if not graph.contracts:has(name) and not elementState:has(name) then
elementState:set(
name,
{
pressed = false,
hovered = false,
focused = false,
pointer = 0,
value = initialValue(nil, input, name, info.componentType)
}
)
end
end
end
function ____exports.createRuntimeState(self, sfl, options)
local document = parse(nil, sfl)
local graph = buildBindingGraph(nil, document)
local input = __clone(
nil,
documentToRenderInput(nil, document)
)
local elementState = __TS__New(Map)
____exports.addElementStates(nil, graph, input, elementState)
return {
options = options,
graph = graph,
diagnostics = {table.unpack(graph.diagnostics)},
input = input,
sources = __TS__New(Map),
registered = __TS__New(Map),
applied = __TS__New(Map),
dirty = __TS__New(Set),
listeners = __TS__New(Set),
warned = __TS__New(Set),
liveListeners = __TS__New(Set),
liveState = __TS__New(Map),
resetListeners = __TS__New(Set),
elementState = elementState,
scheduled = false,
renderNeeded = false,
document = document,
remakePending = false
}
end
function ____exports.readValue(self, state, path)
local name, field = table.unpack(path, 1, 2)
local ____state_sources_has_result_11
if state.sources:has(name) then
____state_sources_has_result_11 = nil
else
____state_sources_has_result_11 = state.elementState:get(name)
end
local element = ____state_sources_has_result_11
if element then
return element[field]
end
local ____opt_12 = state.sources:get(name)
local data = ____opt_12 and ____opt_12:get()
if data == nil then
error(
__TS__New(Error, ("DataSource '" .. name) .. "' has no data yet."),
0
)
end
local ____Array_isArray_result_14
if __TS__ArrayIsArray(data) then
____Array_isArray_result_14 = __TS__ArrayMap(
data,
function(____, row) return row[field] end
)
else
____Array_isArray_result_14 = data[field]
end
return ____Array_isArray_result_14
end
function ____exports.missingSource(self, state, binding)
return __TS__ArrayFind(
__TS__ArrayMap(
binding.dependencies,
function(____, dependency) return __TS__StringSplit(dependency, ".")[1] end
),
function(____, name) return name ~= "self" and not state.sources:has(name) and not state.elementState:has(name) end
)
end
return ____exports
end,
["core.binding.evaluation"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__StringStartsWith = ____lualib.__TS__StringStartsWith
local ____exports = {}
local ______shims = require("core.__shims")
local __json = ______shims.__json
local __microtask = ______shims.__microtask
local __t = ______shims.__t
local ____component = require("core.model.component.index")
local isBuiltInComponentType = ____component.isBuiltInComponentType
local ____render = require("core.render")
local renderCanvas = ____render.renderCanvas
local ____applyValue = require("core.binding.applyValue")
local APPLY = ____applyValue.APPLY
local applyMesh = ____applyValue.applyMesh
local applyShader = ____applyValue.applyShader
local ____expression = require("core.binding.expression")
local evaluate = ____expression.evaluate
local ____runtimeState = require("core.binding.runtimeState")
local missingSource = ____runtimeState.missingSource
local readValue = ____runtimeState.readValue
function ____exports.markDirty(self, state, name)
for ____, ____value in __TS__Iterator(state.graph.byField) do
local field = ____value[1]
local bindings = ____value[2]
if __TS__StringStartsWith(field, name .. ".") then
for ____, binding in ipairs(bindings) do
state.dirty:add(binding)
end
end
end
end
local function announce(self, state, id, change)
state.liveState:set(id, change)
for ____, listener in ipairs({__TS__Spread(state.liveListeners)}) do
listener(nil, change)
end
end
local function applyComponentValue(self, state, binding, value)
local id = binding.ownerPath[1]
local element = state.elementState:get(id)
if element then
element.value = value
____exports.markDirty(nil, state, id)
end
local ____isBuiltInComponentType_2 = isBuiltInComponentType
local ____opt_0 = state.graph.elements:get(id)
if not ____isBuiltInComponentType_2(nil, ____opt_0 and ____opt_0.componentType) then
return true
end
announce(nil, state, binding.id, {kind = "component", id = id, value = value})
return false
end
local function warnMissingSource(self, state, binding, missing)
if state.warned:has(missing) then
return
end
state.warned:add(missing)
local ____state_diagnostics_3 = state.diagnostics
____state_diagnostics_3[#____state_diagnostics_3 + 1] = {
severity = "warning",
code = "source-not-registered",
message = ((("DataSource '" .. missing) .. "' has no registered source, so '") .. binding.property) .. "' stays empty.",
line = binding.line,
col = binding.col
}
end
local function evaluateBinding(self, state, binding)
local missing = missingSource(nil, state, binding)
if __t(nil, missing) then
warnMissingSource(nil, state, binding, missing)
return false
end
local readsSelf = __TS__ArrayIncludes(binding.dependencies, "self.id")
if binding.ownerKind == "Shader" and readsSelf then
local owners = __TS__ArrayFilter(
state.input.shapes,
function(____, shape)
local ____opt_4 = shape.shader
return (____opt_4 and ____opt_4.name) == binding.ownerPath[1]
end
)
for ____, owner in ipairs(owners) do
do
local value = evaluate(
nil,
binding.expr,
{read = function(____, path) return path[1] == "self" and path[2] == "id" and owner.id or readValue(nil, state, path) end}
)
local appliedId = (binding.id .. ".") .. owner.id
local key = __json(nil, value)
if state.applied:get(appliedId) == key then
goto __continue14
end
state.applied:set(appliedId, key)
applyShader(
nil,
state.input,
binding,
value,
owner.id
)
announce(nil, state, appliedId, {kind = "shader", owners = {owner.id}, parameters = {[binding.property] = value}})
end
::__continue14::
end
return false
end
local ____temp_6
if binding.ownerKind == "Shader" then
____temp_6 = nil
else
____temp_6 = binding.ownerPath[1]
end
local selfId = ____temp_6
local value = evaluate(
nil,
binding.expr,
{read = function(____, path) return path[1] == "self" and path[2] == "id" and __t(nil, selfId) and selfId or readValue(nil, state, path) end}
)
local key = __json(nil, value)
if state.applied:get(binding.id) == key then
return false
end
state.applied:set(binding.id, key)
if binding.ownerKind == "Shader" then
announce(
nil,
state,
binding.id,
{
kind = "shader",
owners = applyShader(nil, state.input, binding, value),
parameters = {[binding.property] = value}
}
)
return false
end
if __TS__ArrayIncludes({
"Mesh",
"Solid",
"Facets",
"Terrain",
"Canvas",
"Light"
}, binding.ownerKind) then
applyMesh(
nil,
state.input,
binding.ownerPath[1],
binding.property,
value
)
announce(nil, state, binding.id, {kind = "mesh", id = binding.ownerPath[1], property = binding.property, value = value})
return false
end
local applyAs = (binding.ownerKind == "Text" or binding.ownerKind == "Image") and "Shape" or binding.ownerKind
local ____this_8
____this_8 = APPLY
local ____opt_7 = ____this_8[(applyAs .. ".") .. binding.property]
if ____opt_7 ~= nil then
____opt_7(____this_8, state.input, binding.ownerPath, value)
end
if binding.ownerKind == "Component" and binding.property == "value" then
return applyComponentValue(nil, state, binding, value)
end
return true
end
function ____exports.flush(self, state)
state.scheduled = false
local changed = state.renderNeeded
state.renderNeeded = false
for ____, binding in __TS__Iterator(state.dirty) do
changed = evaluateBinding(nil, state, binding) or changed
end
state.dirty:clear()
if not changed then
return nil
end
local result = renderCanvas(
nil,
state.input,
__TS__ObjectAssign({}, state.options.renderOptions, {linkHitAreas = true})
)
for ____, listener in ipairs({__TS__Spread(state.listeners)}) do
listener(nil, result)
end
return result
end
function ____exports.schedule(self, state)
if not state.scheduled then
state.scheduled = true
__microtask(
nil,
function() return ____exports.flush(nil, state) end
)
end
end
return ____exports
end,
["core.binding.handlers"] = function(...)
local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local ____exports = {}
local ______shims = require("core.__shims")
local __isFinite = ______shims.__isFinite
local __t = ______shims.__t
local ____evaluation = require("core.binding.evaluation")
local markDirty = ____evaluation.markDirty
local schedule = ____evaluation.schedule
local ____expression = require("core.binding.expression")
local collectRefs = ____expression.collectRefs
local evaluate = ____expression.evaluate
local ____runtimeState = require("core.binding.runtimeState")
local readValue = ____runtimeState.readValue
local ____types = require("core.binding.types")
local TICK_EVENT = ____types.TICK_EVENT
local ____writes = require("core.binding.writes")
local writeFields = ____writes.writeFields
function ____exports.runHandler(self, state, handler, delta, selfId)
local env = {read = function(____, path)
if path[1] == "time" and path[2] == "delta" then
return delta or 0
end
if path[1] == "self" and path[2] == "id" and __t(nil, selfId) then
return selfId
end
return readValue(nil, state, path)
end}
local writes = __TS__New(Map)
for ____, assignment in ipairs(handler.assignments) do
do
local readable = __TS__ArrayEvery(
collectRefs(nil, assignment.expr),
function(____, ____bindingPattern0)
local name
name = ____bindingPattern0[1]
return name == "time" or name == "self" and Boolean(nil, selfId) or state.sources:has(name) or state.elementState:has(name)
end
)
if not readable then
goto __continue6
end
local value = evaluate(nil, assignment.expr, env)
if type(value) == "number" then
local ____opt_0 = state.graph.contracts:get(assignment.source)
value = (____opt_0 and ____opt_0.declared[assignment.field]) == "int" and math.floor(value + 0.5) or value
if not __isFinite(nil, value) then
goto __continue6
end
end
local write = writes:get(assignment.source) or ({fields = {}, line = assignment.line, col = assignment.col})
write.fields[assignment.field] = value
writes:set(assignment.source, write)
end
::__continue6::
end
for ____, ____value in __TS__Iterator(writes) do
local source = ____value[1]
local fields = ____value[2].fields
local line = ____value[2].line
local col = ____value[2].col
writeFields(
nil,
state,
source,
fields,
line,
col
)
end
end
function ____exports.dispatch(self, state, id, event)
for ____, handler in ipairs(state.graph.handlers) do
if handler.event == event and handler.ownerKind ~= "DataSource" and handler.ownerPath[1] == id then
____exports.runHandler(
nil,
state,
handler,
nil,
id
)
end
end
end
function ____exports.runTick(self, state, seconds)
for ____, handler in ipairs(state.graph.handlers) do
if handler.event == TICK_EVENT then
____exports.runHandler(nil, state, handler, seconds)
end
end
end
function ____exports.setElementState(self, state, id, patch)
local current = state.elementState:get(id)
if not current or __TS__ArrayEvery(
__TS__ObjectKeys(patch),
function(____, key) return current[key] == patch[key] end
) then
return
end
__TS__ObjectAssign(current, patch)
markDirty(nil, state, id)
schedule(nil, state)
end
return ____exports
end,
["core.binding.replace"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArraySome = ____lualib.__TS__ArraySome
local Map = ____lualib.Map
local __TS__New = ____lualib.__TS__New
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
local __TS__ArrayIsArray = ____lualib.__TS__ArrayIsArray
local __TS__ArrayPushArray = ____lualib.__TS__ArrayPushArray
local Set = ____lualib.Set
local __TS__Spread = ____lualib.__TS__Spread
local __TS__ArraySplice = ____lualib.__TS__ArraySplice
local ____exports = {}
local ______shims = require("core.__shims")
local __clone = ______shims.__clone
local __isFinite = ______shims.__isFinite
local __t = ______shims.__t
local ____fromSfl = require("core.renderInput.fromSfl.index")
local documentToRenderInput = ____fromSfl.documentToRenderInput
local ____sflLanguage = require("core.sflLanguage.index")
local parse = ____sflLanguage.parse
local ____expansion = require("core.sflLanguage.expansion.index")
local eachSources = ____expansion.eachSources
local withParameterValues = ____expansion.withParameterValues
local ____checkData = require("core.binding.checkData")
local checkData = ____checkData.checkData
local ____dataSource = require("core.binding.dataSource")
local createDataSource = ____dataSource.createDataSource
local ____evaluation = require("core.binding.evaluation")
local flush = ____evaluation.flush
local ____graph = require("core.binding.graph")
local buildBindingGraph = ____graph.buildBindingGraph
local ____runtimeState = require("core.binding.runtimeState")
local addElementStates = ____runtimeState.addElementStates
local ____sources = require("core.binding.sources")
local registerSource = ____sources.registerSource
local ____writes = require("core.binding.writes")
local hostWriteProblems = ____writes.hostWriteProblems
local sourceWrites = ____writes.sourceWrites
local function failed(self, diagnostics)
return __TS__ArraySome(
diagnostics,
function(____, diagnostic) return diagnostic.severity == "error" end
)
end
local function readError(self, ____error)
local at = ____error
return {
severity = "error",
code = "document-not-read",
message = at.message or tostring(____error),
line = at.line or 0,
col = at.col or 0
}
end
local function keptParameters(self, state, graph)
local parameters = __TS__New(Map)
for ____, contract in __TS__Iterator(graph.contracts:values()) do
do
if not contract.parameters then
goto __continue6
end
local before = state.registered:get(contract.name)
local row = before and before.own and before.source:get() or nil
local values = __TS__ObjectAssign({}, contract.parameters)
for ____, key in ipairs(__TS__ObjectKeys(values)) do
local value = row and row[key]
if type(value) == "number" and __isFinite(nil, value) then
values[key] = value
end
end
parameters:set(contract.name, values)
end
::__continue6::
end
return parameters
end
local function hostWrites(self, graph)
local writes = {}
for ____, ____value in ipairs(sourceWrites(nil, graph)) do
local source = ____value.source
local field = ____value.field
do
local ____opt_4 = graph.contracts:get(source)
if ____opt_4 and ____opt_4.parameters then
goto __continue13
end
if writes[source] == nil then
writes[source] = {}
end
if not __TS__ArrayIncludes(writes[source], field) then
local ____writes_source_6 = writes[source]
____writes_source_6[#____writes_source_6 + 1] = field
end
end
::__continue13::
end
return writes
end
local function prepare(self, state, sfl)
do
local function ____catch(____error)
return true, {readError(nil, ____error)}
end
local ____try, ____hasReturned, ____returnValue = pcall(function()
local written = parse(nil, sfl)
local parameters = keptParameters(
nil,
state,
buildBindingGraph(nil, written)
)
local values = __TS__New(Map)
for ____, ____value in __TS__Iterator(parameters) do
local name = ____value[1]
local row = ____value[2]
for ____, ____value in ipairs(__TS__ObjectEntries(row)) do
local key = ____value[1]
local value = ____value[2]
values:set((name .. ".") .. key, value)
end
end
local made = withParameterValues(nil, written, values)
local tables = __TS__New(Map)
for ____, name in __TS__Iterator(eachSources(nil, written.blocks)) do
local ____opt_7 = state.registered:get(name)
local rows = ____opt_7 and ____opt_7.source:get()
if __TS__ArrayIsArray(rows) then
tables:set(name, rows)
end
end
local graph = buildBindingGraph(nil, made, tables)
local diagnostics = {table.unpack(graph.diagnostics)}
for ____, ____value in __TS__Iterator(state.registered) do
local name = ____value[1]
local source = ____value[2].source
local own = ____value[2].own
do
local contract = graph.contracts:get(name)
if own or not contract or contract.parameters then
goto __continue26
end
local problem = checkData(
nil,
contract,
source:get()
)
if __t(nil, problem) then
diagnostics[#diagnostics + 1] = {
severity = "error",
code = "data-type-mismatch",
message = problem,
line = 0,
col = 0
}
end
if source.writable then
__TS__ArrayPushArray(
diagnostics,
hostWriteProblems(nil, graph, name, source.writable)
)
end
end
::__continue26::
end
local input = __clone(
nil,
documentToRenderInput(nil, made, tables)
)
return true, {
written = written,
graph = graph,
input = input,
parameters = parameters,
diagnostics = diagnostics,
writes = hostWrites(nil, graph)
}
end)
if not ____try then
____hasReturned, ____returnValue = ____catch(____hasReturned)
end
if ____hasReturned then
return ____returnValue
end
end
end
function ____exports.checkDocument(self, state, sfl)
local candidate = prepare(nil, state, sfl)
if __TS__ArrayIsArray(candidate) then
return {ok = false, diagnostics = candidate, writes = {}}
end
return {
ok = not failed(nil, candidate.diagnostics),
diagnostics = candidate.diagnostics,
writes = candidate.writes
}
end
local function put(self, target, from)
target:clear()
for ____, ____value in __TS__Iterator(from) do
local key = ____value[1]
local value = ____value[2]
target:set(key, value)
end
end
function ____exports.replaceDocument(self, state, sfl)
local candidate = prepare(nil, state, sfl)
if __TS__ArrayIsArray(candidate) then
return {ok = false, diagnostics = candidate, writes = {}}
end
local diagnostics = candidate.diagnostics
local writes = candidate.writes
local graph = candidate.graph
local input = candidate.input
if failed(nil, diagnostics) then
return {ok = false, diagnostics = diagnostics, writes = writes}
end
local before = {
document = state.document,
graph = state.graph,
input = state.input,
sources = __TS__New(Map, state.sources),
registered = __TS__New(Map, state.registered),
applied = __TS__New(Map, state.applied),
liveState = __TS__New(Map, state.liveState),
elementState = __TS__New(Map, state.elementState),
diagnostics = {table.unpack(state.diagnostics)},
warned = __TS__New(Set, state.warned)
}
local added = {}
do
local function ____catch(____error)
for ____, release in ipairs(added) do
release(nil)
end
state.document = before.document
state.graph = before.graph
state.input = before.input
put(nil, state.sources, before.sources)
put(nil, state.registered, before.registered)
put(nil, state.applied, before.applied)
put(nil, state.liveState, before.liveState)
put(nil, state.elementState, before.elementState)
__TS__ArraySplice(
state.diagnostics,
0,
#state.diagnostics,
table.unpack(before.diagnostics)
)
state.warned:clear()
for ____, key in __TS__Iterator(before.warned) do
state.warned:add(key)
end
state.dirty:clear()
for ____, change in __TS__Iterator(state.liveState:values()) do
for ____, listener in ipairs({__TS__Spread(state.liveListeners)}) do
listener(nil, change)
end
end
state.renderNeeded = true
flush(nil, state)
return true, {
ok = false,
diagnostics = {readError(nil, ____error)},
writes = writes
}
end
local ____try, ____hasReturned, ____returnValue = pcall(function()
state.document = candidate.written
state.graph = graph
state.input = input
for ____, ____value in __TS__Iterator(before.registered) do
local name = ____value[1]
local registration = ____value[2]
local contract = graph.contracts:get(name)
if registration.own then
state.registered:delete(name)
state.sources:delete(name)
elseif contract and not contract.parameters then
state.sources:set(name, registration.source)
else
state.sources:delete(name)
end
end
for ____, ____value in __TS__Iterator(candidate.parameters) do
local name = ____value[1]
local row = ____value[2]
added[#added + 1] = registerSource(
nil,
state,
name,
createDataSource(nil, row),
true
)
end
for ____, name in ipairs({__TS__Spread(state.elementState:keys())}) do
if not graph.elements:has(name) then
state.elementState:delete(name)
end
end
addElementStates(nil, graph, input, state.elementState)
state.applied:clear()
state.liveState:clear()
state.warned:clear()
__TS__ArraySplice(
state.diagnostics,
0,
#state.diagnostics,
table.unpack(diagnostics)
)
state.dirty:clear()
for ____, binding in ipairs(graph.bindings) do
state.dirty:add(binding)
end
state.renderNeeded = true
state.remakePending = false
for ____, reset in ipairs({__TS__Spread(state.resetListeners)}) do
reset(nil)
end
flush(nil, state)
end)
if not ____try then
____hasReturned, ____returnValue = ____catch(____hasReturned)
end
if ____hasReturned then
return ____returnValue
end
end
for ____, registration in __TS__Iterator(before.registered:values()) do
if registration.own then
registration:unsubscribe()
end
end
return {ok = true, diagnostics = diagnostics, writes = writes}
end
return ____exports
end,
["core.binding.userInput"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__ArrayFind = ____lualib.__TS__ArrayFind
local __TS__TypeOf = ____lualib.__TS__TypeOf
local WeakMap = ____lualib.WeakMap
local __TS__New = ____lualib.__TS__New
local __TS__Number = ____lualib.__TS__Number
local __TS__StringSplit = ____lualib.__TS__StringSplit
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
local __TS__NumberToFixed = ____lualib.__TS__NumberToFixed
local Map = ____lualib.Map
local ____exports = {}
local ______shims = require("core.__shims")
local __json = ______shims.__json
local __t = ______shims.__t
local ____component = require("core.model.component.index")
local getComponentDescriptor = ____component.getComponentDescriptor
local isGenericComponent = ____component.isGenericComponent
local ____sliderReach = require("core.model.component.sliderReach")
local sliderReach = ____sliderReach.sliderReach
local ____applyValue = require("core.binding.applyValue")
local findComponent = ____applyValue.findComponent
local isComponentDisabled = ____applyValue.isComponentDisabled
local writeComponentValue = ____applyValue.writeComponentValue
local writeComponentValueEnd = ____applyValue.writeComponentValueEnd
local ____evaluation = require("core.binding.evaluation")
local markDirty = ____evaluation.markDirty
local schedule = ____evaluation.schedule
local ____handlers = require("core.binding.handlers")
local dispatch = ____handlers.dispatch
local setElementState = ____handlers.setElementState
local ____types = require("core.binding.types")
local CHANGE_EVENT = ____types.CHANGE_EVENT
local ____writes = require("core.binding.writes")
local writeFields = ____writes.writeFields
local function descriptorOf(self, state, id)
local info = state.graph.elements:get(id)
local ____temp_2
if (info and info.kind) == "Component" then
____temp_2 = getComponentDescriptor(nil, info.componentType)
else
____temp_2 = nil
end
return ____temp_2
end
local function valueBinding(self, state, id, property)
if property == nil then
property = "value"
end
return __TS__ArrayFind(
state.graph.bindings,
function(____, binding) return binding.ownerKind == "Component" and binding.ownerPath[1] == id and binding.property == property end
)
end
local function writeBack(self, state, binding, value)
local target = binding.expr.kind == "ref" and binding.expr.path or nil
if target then
writeFields(
nil,
state,
target[1],
{[target[2]] = value},
binding.line,
binding.col
)
end
end
local function changeValueEnd(self, state, id, next)
local component = findComponent(nil, state.input, id)
if not component or not isGenericComponent(nil, component) or component.properties.valueEnd == next or isComponentDisabled(nil, state.input, id) then
return false
end
local binding = valueBinding(nil, state, id, "valueEnd")
if binding and binding.operator ~= "<->" then
return false
end
writeComponentValueEnd(nil, state.input, id, next)
state.renderNeeded = true
if binding then
state.applied:set(
binding.id,
__json(nil, next)
)
writeBack(nil, state, binding, next)
end
markDirty(nil, state, id)
dispatch(nil, state, id, CHANGE_EVENT)
schedule(nil, state)
return true
end
function ____exports.changeComponentValue(self, state, id, next, property)
if property == nil then
property = "value"
end
if property == "valueEnd" then
return type(next) == "number" and changeValueEnd(nil, state, id, next)
end
local ____opt_3 = descriptorOf(nil, state, id)
local spec = ____opt_3 and ____opt_3.value
local element = state.elementState:get(id)
if not (spec and spec.writable) or not element or __TS__TypeOf(next) ~= spec.type or element.value == next then
return false
end
if isComponentDisabled(nil, state.input, id) then
return false
end
local binding = valueBinding(nil, state, id)
if binding and binding.operator ~= "<->" then
return false
end
element.value = next
writeComponentValue(nil, state.input, id, next)
state.renderNeeded = true
if binding then
state.applied:set(
binding.id,
__json(nil, next)
)
writeBack(nil, state, binding, next)
end
markDirty(nil, state, id)
dispatch(nil, state, id, CHANGE_EVENT)
schedule(nil, state)
return true
end
local TAU = math.pi * 2
local grabbed = __TS__New(WeakMap)
local function within(____, value)
return math.min(
1,
math.max(0, value)
)
end
local function slideAlong(self, properties, width, height, x, y)
local vertical = properties.direction == "vertical"
local length = vertical and height or width
local reach = sliderReach(nil, properties.variant, vertical and width or height)
local position = vertical and 1 - y or x
return length > reach * 2 and within(nil, (position * length - reach) / (length - reach * 2)) or position
end
local function turnAlong(self, properties, width, height, x, y)
local ____properties_start_7 = properties.start
if ____properties_start_7 == nil then
____properties_start_7 = 225
end
local start = __TS__Number(____properties_start_7) * math.pi / 180
local ____properties_sweep_8 = properties.sweep
if ____properties_sweep_8 == nil then
____properties_sweep_8 = 270
end
local sweep = __TS__Number(____properties_sweep_8) * math.pi / 180
local gap = TAU - sweep
local angle = math.atan(-(y - 0.5) * height, (x - 0.5) * width)
local shifted = start - angle + gap / 2
return within(nil, ((shifted % TAU + TAU) % TAU - gap / 2) / sweep)
end
function ____exports.slideElement(self, state, id, x, y)
if y == nil then
y = 0
end
local component = findComponent(nil, state.input, id)
if not component or not isGenericComponent(nil, component) then
return
end
local ____opt_9 = descriptorOf(nil, state, id)
local kind = ____opt_9 and ____opt_9.interaction
local properties = component.properties
if kind == "pick" then
local ____properties_options_11 = properties.options
if ____properties_options_11 == nil then
____properties_options_11 = ""
end
local count = #__TS__ArrayFilter(
__TS__StringSplit(
tostring(____properties_options_11),
","
),
function(____, ...) return __t(
nil,
(function(____, option) return option:trim() end)(nil, ...)
) end
)
if count > 0 then
____exports.changeComponentValue(
nil,
state,
id,
math.min(
count - 1,
math.floor(x * count)
)
)
end
return
end
local along = kind == "turn" and turnAlong(
nil,
properties,
component.width,
component.height,
x,
y
) or slideAlong(
nil,
properties,
component.width,
component.height,
x,
y
)
local ____properties_min_12 = properties.min
if ____properties_min_12 == nil then
____properties_min_12 = 0
end
local min = __TS__Number(____properties_min_12)
local ____properties_max_13 = properties.max
if ____properties_max_13 == nil then
____properties_max_13 = 100
end
local max = __TS__Number(____properties_max_13)
local ____properties_step_14 = properties.step
if ____properties_step_14 == nil then
____properties_step_14 = 0
end
local step = __TS__Number(____properties_step_14)
local value = min + along * (max - min)
if step > 0 then
value = min + math.floor((value - min) / step + 0.5) * step
end
local taken = __TS__Number(__TS__NumberToFixed(
math.min(
max,
math.max(min, value)
),
6
))
if kind ~= "range" then
____exports.changeComponentValue(nil, state, id, taken)
return
end
local low = __TS__Number(component.value)
local ____properties_valueEnd_15 = properties.valueEnd
if ____properties_valueEnd_15 == nil then
____properties_valueEnd_15 = max
end
local high = __TS__Number(____properties_valueEnd_15)
local holds = grabbed:get(state) or __TS__New(Map)
grabbed:set(state, holds)
if not holds:has(id) then
holds:set(id, (taken >= high or taken > low and taken - low > high - taken) and "end" or "start")
end
if holds:get(id) == "start" then
____exports.changeComponentValue(
nil,
state,
id,
math.min(taken, high)
)
else
____exports.changeComponentValue(
nil,
state,
id,
math.max(taken, low),
"valueEnd"
)
end
end
local function reactToActivation(self, state, id)
local element = state.elementState:get(id)
local descriptor = descriptorOf(nil, state, id)
local ____temp_20 = element and (descriptor and descriptor.interaction) == "toggle"
if ____temp_20 then
local ____opt_18 = descriptor.value
____temp_20 = (____opt_18 and ____opt_18.type) == "boolean"
end
if ____temp_20 then
____exports.changeComponentValue(nil, state, id, element.value ~= true)
end
end
function ____exports.focusElement(self, state, id, focused)
local component = findComponent(nil, state.input, id)
if component and isGenericComponent(nil, component) then
component.properties.focused = focused
state.renderNeeded = true
end
setElementState(nil, state, id, {focused = focused})
dispatch(nil, state, id, focused and "onFocus" or "onBlur")
schedule(nil, state)
end
function ____exports.pressElement(self, state, id)
local ____opt_21 = grabbed:get(state)
if ____opt_21 ~= nil then
____opt_21:delete(id)
end
if isComponentDisabled(nil, state.input, id) then
return
end
setElementState(nil, state, id, {pressed = true})
dispatch(nil, state, id, "onPress")
end
function ____exports.releaseElement(self, state, id, tapped)
local ____opt_23 = grabbed:get(state)
if ____opt_23 ~= nil then
____opt_23:delete(id)
end
setElementState(nil, state, id, {pressed = false})
if isComponentDisabled(nil, state.input, id) then
return
end
if tapped then
reactToActivation(nil, state, id)
end
dispatch(nil, state, id, "onRelease")
if tapped then
dispatch(nil, state, id, "onTap")
end
end
function ____exports.activateElement(self, state, id)
if isComponentDisabled(nil, state.input, id) then
return
end
reactToActivation(nil, state, id)
dispatch(nil, state, id, "onTap")
end
return ____exports
end,
["core.binding.runtime"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Iterator = ____lualib.__TS__Iterator
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
local __TS__ObjectRest = ____lualib.__TS__ObjectRest
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
local ____exports = {}
local ____render = require("core.render")
local renderCanvas = ____render.renderCanvas
local ____dataSource = require("core.binding.dataSource")
local createDataSource = ____dataSource.createDataSource
local ____evaluation = require("core.binding.evaluation")
local flush = ____evaluation.flush
local schedule = ____evaluation.schedule
local ____handlers = require("core.binding.handlers")
local dispatch = ____handlers.dispatch
local runTick = ____handlers.runTick
local setElementState = ____handlers.setElementState
local ____interactive = require("core.binding.interactive")
local interactiveElements = ____interactive.interactiveElements
local ____remake = require("core.binding.remake")
local remakeNow = ____remake.remakeNow
local ____replace = require("core.binding.replace")
local checkDocument = ____replace.checkDocument
local replaceDocument = ____replace.replaceDocument
local ____runtimeState = require("core.binding.runtimeState")
local createRuntimeState = ____runtimeState.createRuntimeState
local ____sources = require("core.binding.sources")
local registerSource = ____sources.registerSource
local ____userInput = require("core.binding.userInput")
local activateElement = ____userInput.activateElement
local changeComponentValue = ____userInput.changeComponentValue
local focusElement = ____userInput.focusElement
local pressElement = ____userInput.pressElement
local releaseElement = ____userInput.releaseElement
local slideElement = ____userInput.slideElement
local function pushLiveChange(self, target, change)
if change.kind == "component" then
local ____opt_0 = target.setComponentValue or target.setWidgetValue
if ____opt_0 ~= nil then
(target.setComponentValue or target.setWidgetValue)(target, change.id, change.value)
end
return
end
if change.kind == "mesh" then
local ____this_3
____this_3 = target
local ____opt_2 = ____this_3.setMeshValue
if ____opt_2 ~= nil then
____opt_2(____this_3, change.id, change.property, change.value)
end
return
end
for ____, owner in ipairs(change.owners) do
local ____this_5
____this_5 = target
local ____opt_4 = ____this_5.setShaderParameters
if ____opt_4 ~= nil then
____opt_4(____this_5, owner, change.parameters)
end
end
end
local function attach(self, state, target)
local function send(____, change)
return pushLiveChange(nil, target, change)
end
state.liveListeners:add(send)
for ____, change in __TS__Iterator(state.liveState:values()) do
send(nil, change)
end
local function listener(____, result)
return target:update({svg = result.svg})
end
state.listeners:add(listener)
local function reset()
local ____this_7
____this_7 = target
local ____opt_6 = ____this_7.clearOverrides
return ____opt_6 and ____opt_6(____this_7)
end
state.resetListeners:add(reset)
for ____, binding in ipairs(state.graph.bindings) do
state.dirty:add(binding)
end
flush(nil, state)
return function()
state.listeners:delete(listener)
state.liveListeners:delete(send)
state.resetListeners:delete(reset)
end
end
function ____exports.createBindingRuntime(self, sfl, options)
if options == nil then
options = {}
end
local state = createRuntimeState(nil, sfl, options)
for ____, contract in __TS__Iterator(state.graph.contracts:values()) do
if contract.parameters then
registerSource(
nil,
state,
contract.name,
createDataSource(
nil,
__TS__ObjectAssign({}, contract.parameters)
),
true
)
end
end
for ____, binding in ipairs(state.graph.bindings) do
if #binding.dependencies == 0 then
state.dirty:add(binding)
end
end
if state.dirty.size > 0 then
schedule(nil, state)
end
local interactiveOf = {
graph = state.graph,
value = interactiveElements(nil, state.graph)
}
return __getters(
{
diagnostics = state.diagnostics,
registerSource = function(____, name, source) return registerSource(nil, state, name, source) end,
sourceOf = function(____, name) return state.sources:get(name) end,
check = function(____, sfl) return checkDocument(nil, state, sfl) end,
replace = function(____, sfl) return replaceDocument(nil, state, sfl) end,
setElementState = function(____, id, patch) return setElementState(nil, state, id, patch) end,
press = function(____, id) return pressElement(nil, state, id) end,
release = function(____, id, tapped) return releaseElement(nil, state, id, tapped) end,
activate = function(____, id) return activateElement(nil, state, id) end,
focus = function(____, id, focused) return focusElement(nil, state, id, focused) end,
submit = function(____, id) return dispatch(nil, state, id, "onSubmit") end,
change = function(____, id, value) return changeComponentValue(nil, state, id, value) end,
slide = function(____, id, x, y) return slideElement(
nil,
state,
id,
x,
y
) end,
drag = function(self, id, pointer)
if pointer ~= nil then
setElementState(nil, state, id, {pointer = pointer})
end
dispatch(nil, state, id, "onDrag")
end,
tick = function(____, seconds) return runTick(nil, state, seconds) end,
flush = function()
remakeNow(nil, state)
return flush(nil, state)
end,
onRender = function(self, listener)
state.listeners:add(listener)
return function() return state.listeners:delete(listener) end
end,
attach = function(____, target) return attach(nil, state, target) end
},
{
graph = function()
return state.graph
end,
interactive = function()
if interactiveOf.graph ~= state.graph then
interactiveOf.graph = state.graph
interactiveOf.value = interactiveElements(nil, state.graph)
end
return interactiveOf.value
end,
input = function()
return state.input
end
}
)
end
function ____exports.renderBound(self, sfl, options)
if options == nil then
options = {}
end
local ____options_8 = options
local data = ____options_8.data
if data == nil then
data = {}
end
local renderOptions = __TS__ObjectRest(____options_8, {data = true})
local runtime = ____exports.createBindingRuntime(nil, sfl, {renderOptions = renderOptions})
for ____, ____value in ipairs(__TS__ObjectEntries(data)) do
local name = ____value[1]
local rows = ____value[2]
runtime:registerSource(
name,
{
get = function() return rows end,
subscribe = function() return function() return nil end end
}
)
end
runtime:flush()
return renderCanvas(nil, runtime.input, renderOptions)
end
return ____exports
end,
["entry"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____runtime = require("core.binding.runtime")
local renderBound = ____runtime.renderBound
local ______shims = require("core.__shims")
local __jsonParse = ______shims.__jsonParse
function ____exports.renderSfl(self, source, data)
local rows = data and __jsonParse(nil, data) or ({})
return renderBound(nil, source, {data = rows, padding = 0}).svg
end
return ____exports
end,
}
local ____entry = require("entry", ...)
return ____entry
end
-- stickyflow for LuaLaTeX: renders SFL with the core of stickyflow.js, translated to Lua, and draws the SVG it gives as PDF, with the texts set
-- by TeX in the fonts of the document.
local stickyflow = {}
---------------------------------------------------------------------------------------------------------------------------------------------
-- What the core needs of JavaScript, beyond what the translator brings.
local plain = tostring
-- Numbers as JavaScript writes them: whole numbers without a point, others in the shortest form that reads back as the same number.
local function jsNumber(v)
if v ~= v then return 'NaN' end
if v == math.huge then return 'Infinity' end
if v == -math.huge then return '-Infinity' end
if v == math.floor(v) and v > -1e21 and v < 1e21 then return string.format('%d', v) end
local s
for p = 1, 17 do
s = string.format('%.' .. p .. 'g', v)
if tonumber(s) == v then break end
end
local mantissa, exponent = s:match('^(.-)e([-+]%d+)$')
if exponent then
local e = tonumber(exponent)
if e >= -7 and e < 21 then
s = string.format('%.' .. math.max(0, -e + #mantissa:gsub('[^%d]', '') - 1) .. 'f', v)
s = s:gsub('(%..-)0+$', '%1'):gsub('%.$', '')
else
s = mantissa .. 'e' .. (e > 0 and '+' or '-') .. math.abs(e)
end
end
return s
end
tostring = function(v)
if math.type(v) == 'float' then return jsNumber(v) end
return plain(v)
end
-- The globals of JavaScript that the core passes around as functions, as in list.filter(Boolean).
Boolean = function(_, v) return not (v == nil or v == false or v == 0 or v == '' or v ~= v) end
Number = function(_, v)
if type(v) == 'number' then return v end
if v == nil then return 0 / 0 end
if v == true then return 1 end
if v == false then return 0 end
local s = plain(v):match('^%s*(.-)%s*$')
if s == '' then return 0 end
return tonumber(s) or 0 / 0
end
String = function(_, v) return tostring(v) end
-- The arguments as a list, without the ones that are undefined: Lua cannot keep a list with holes.
function __compact(...)
local out = {}
for i = 1, select('#', ...) do
local v = select(i, ...)
if v ~= nil then out[#out + 1] = v end
end
return out
end
-- An object with getters, as JavaScript has them in an object literal.
function __getters(object, getters)
return setmetatable(object, { __index = function(_, key)
local getter = getters[key]
if getter then return getter(nil) end
end })
end
-- A deep copy of plain data; tables keep their metatable, so the maps and sets of the core stay what they are.
function __deepClone(value, seen)
if type(value) ~= 'table' then return value end
seen = seen or {}
if seen[value] then return seen[value] end
local copy = {}
seen[value] = copy
for k, v in pairs(value) do copy[__deepClone(k, seen)] = __deepClone(v, seen) end
return setmetatable(copy, getmetatable(value))
end
local core = require('stickyflow-core')
function stickyflow.render(source, data)
return core.renderSfl(nil, source, data)
end
---------------------------------------------------------------------------------------------------------------------------------------------
-- The SVG, read into a tree. The renderer writes well-formed SVG of a known shape, so a small reader is enough.
local entities = { amp = '&', lt = '<', gt = '>', quot = '"', apos = "'" }
local function unescape(s)
return (s:gsub('&(#?x?)(%w+);', function(kind, body)
if kind == '#' then return utf8.char(tonumber(body)) end
if kind == '#x' then return utf8.char(tonumber(body, 16)) end
return entities[body] or ('&' .. body .. ';')
end))
end
local function parseSvg(svg)
local root = { name = '#root', attrs = {}, children = {} }
local stack = { root }
local pos = 1
while true do
local start, finish, close, name, rest, selfClose = svg:find('<(/?)([%w:_-]+)(.-)(/?)>', pos)
if not start then break end
local text = svg:sub(pos, start - 1)
if text:find('%S') then
local parent = stack[#stack]
parent.children[#parent.children + 1] = { name = '#text', text = unescape(text) }
end
if name:sub(1, 1) ~= '?' and name:sub(1, 1) ~= '!' then
if close == '/' then
stack[#stack] = nil
else
local node = { name = name, attrs = {}, children = {} }
for key, value in rest:gmatch('([%w:_-]+)="([^"]*)"') do
node.attrs[key] = unescape(value)
end
local parent = stack[#stack]
parent.children[#parent.children + 1] = node
if selfClose ~= '/' then stack[#stack + 1] = node end
end
end
pos = finish + 1
end
for _, node in ipairs(root.children) do
if node.name == 'svg' then return node end
end
error('stickyflow: the renderer gave no