You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
worldFolderFiles(world, elements) in @onlyworlds/sdk/convert: a world held as plain objects, as a world folder's files. It takes what the Python package's write_folder takes, the world's record (id and name required) and an object from an element type to a list of element bodies, and answers OwFolderFile[] ({ path, data }) in memory, in a browser or in Node: world.json and one file per element, named and written byte for byte as write_folder names and writes them (the collision rule included), through the writer convertKanka uses. writeWorldFile(files, topDir) packs them into a .owworld file and folderFetch serves them. Within a type a repeated id keeps its last body; the same id under two types is refused. A stub (known_of: true) is written without its unset fields. A world or body that is not a plain object, a missing id or name, an unknown type, and a value a JSON file cannot hold (undefined, a Date, a NaN, a value that holds itself) are refused with a TypeError that names where. An element id that cannot be a file name is refused the same way, whatever the name, before any file is made: one that is empty, holds /, \, : or a control character, or is . or .. (an element whose name gives no slug is written as <id>.json); the cases are in test/fixtures/unsafe-ids.cases.json, the same bytes the Python package's writer is held to. Known limits: a whole number past 2^53 is written as a float, where Python writes every digit, and a JavaScript object lists integer-like keys first.