Skip to content

OnlyWorlds Unity SDK 0.50.0

Choose a tag to compare

@tmoosting tmoosting released this 23 Nov 20:23
· 135 commits to main since this release

A world's element names found in prose, and four refusals that keep a reader and a writer honest: a number the reader
cannot hold is refused by name, a file is one JSON value and nothing after it, a share carries only what the folder
reader serves as one element with no mark, and a save never writes over a file it could not read or a byte that is
not UTF-8. The package is now on OpenUPM (openupm add com.onlyworlds.sdk). A minor release because it adds public
API (below).

Added

  • OWNameFinder.For(elements, nameCase): a world's element names found in prose. It reads the names once and
    answers an OWNameFinder<T>, whose Find(text) lists every OWNameFound<T> (Start, End, and Element, the
    object that was passed in) in order, none overlapping, so a game or a tool can mark the words that are elements (a
    hover, a suggestion, a link a person chooses to make). It finds and never writes. Elements are JSON rows
    (IEnumerable<JToken>, by their string id and name), typed models (OWElement, by Id and Name), or any
    kind of the caller's own with an idOf. nameCase must be given, OWNameCase.Exact or OWNameCase.Folded
    (simple case folding, Unicode 15.1): the enum has no zero value, so default(OWNameCase) is refused. The optional
    names gives the names an element is found by, by default its name alone; a name is a string or a JSON string,
    anything else is passed over. The rule: a whole name only, where the character on each side is not a letter, a
    combining mark, a decimal digit or an underscore in any script (so Kira's holds the name and Kiran does not);
    trimmed of White_Space, three code points at least; the longest whole name where several start at one place; a
    name two elements share is never answered, nor anything inside it; nothing inside an address (what
    OWAddress.FindLinks finds) or a Markdown link [label](target). Start and End are C# string indexes, UTF-16
    code units, as the TypeScript SDK counts them (the Python package counts code points). Limits: text is compared as
    written, with no Unicode normalisation; a space in a name matches that one space; what counts as a letter is the
    runtime's own table, as in the other two packages, and Unity 6's Mono reads Unicode 11.0's, so beside a letter
    assigned since then (one of CJK Extension G, say) a name is whole here and not for the TypeScript SDK on a current
    Node. The work for one text is at most its length times the longest name's length, with no pattern that
    backtracks. The TypeScript SDK's cases file (name-finder.cases.json, 47 cases, each answer written by hand) is
    vendored byte for byte and its sha256 held; every case is replayed, its seven hostile or large texts timed, and ten
    inputs the cases are silent on are held to the TypeScript SDK's own answers. Parity with the TypeScript SDK
    4.194.0.

  • OWNumberOutOfRangeException, a number the reader cannot hold refused by name. An integer of more than 380
    characters (its sign counted) or a number past the largest double (1e400, -1e400) is valid JSON that Newtonsoft
    cannot read, and every reader of the SDK threw its bare JsonReaderException for it. Each now throws this one
    refusal instead: Reason is number_out_of_range (OWJson.NumberOutOfRange, the word the TypeScript SDK's and the
    Python package's folder readers skip such a file by), Path is the number's place in the text, Newtonsoft's
    exception is the inner one. It is a JsonReaderException, so a caller that catches JsonException still catches it.
    Where the line falls is unchanged: 380 characters still read, exactly, and write back with the same bytes. The
    three packages do not draw it in one place (the TypeScript SDK refuses any number a double cannot hold, an integer
    from 309 digits; the Python package an integer of more than 4,300 digits), and no profile says yet.

  • OWWorldArchivePackOptions.UnreadLeftOut, and unreadLeftOut as the last parameter of
    OWWorldArchive.Pack(worldFolder, archivePath, keepApiBlock, includePrivateRecords, includeHidden, hiddenLeftOut, unreadLeftOut)
    : on a share, the paths inside the world (code point order) of the files under elements/ and
    spatial/ left out because the folder reader would not serve them as one element (below), counted apart from
    HiddenLeftOut. Nothing is added on a copy. The new parameter is optional, so every existing call compiles as
    before.

Changed

  • A share carries under elements/ and spatial/ only an element the folder reader serves with no mark (folder
    spec §4.8, a file whose mark cannot be read, and its rulings of 2026-11-23). With includeHidden: false, "read as
    an element" is the folder reader's own verdict, by its own code over the bytes decoded strictly as UTF-8: a file is
    carried only when OWFolderReader would serve it as an element and it carries no mark; a served element with the
    mark or a doubt is left out whole and named in HiddenLeftOut; every other file under the two folders is left out
    whole and named in UnreadLeftOut. That is a file the writer could not read, whatever the reason (not UTF-8, not
    JSON, not one JSON value, cut short, nested past the parser's depth of 64, a number the parser refuses such as
    1e400 or 4,301 digits, an array or a string, an object with no id or an empty one); a file no reader serves as an
    element (a notes.txt in a type folder, a .json in a folder deeper than a type folder, such as a hidden element's
    file moved into old/ by hand, a file directly in elements/ or spatial/, a folder under elements/ that is not
    one of the 22 types or under spatial/ not one of map, pin, zone, marker, a name spelled .JSON, which the
    archive reader never serves); and both files of an id two files hold, in one folder or across elements/ and
    spatial/, since the share cannot say which file's mark is the element's (a hidden first file with a visible twin
    would hand the twin on). Before, such files were carried byte for byte: {"id": "c-2", "hidden": true, cut short
    travelled; a hidden element in a file holding one byte that is not UTF-8 reached the receiver, whose reader decodes
    leniently, as a hidden element; a hidden element's visible twin, or its old spatial/ copy, reached it as that
    element, visible; and {"hidden": true} with no id was counted hidden. media/ and records/ are not read for it
    and travel as before. A copy (includeHidden on, the default) is unchanged: it carries every such file byte for
    byte.
  • A JSON text is one value and nothing after it but whitespace, at every reader (folder spec §4.8).
    {"id": "c-9"} {"hidden": true} was read by the folder and .owworld readers, a world.json, an export file, the
    cache's IsKnownOf and OWFolderWriter.Parse as the visible element c-9, the content after the first object
    ignored, while the serializer refused it; and every reader passed over a comment, U+00A0 or a NUL after the value.
    Now every reader refuses anything after the value but JSON's four whitespace characters (space, tab, LF, CR),
    saying where it starts: a folder or an .owworld skips the file, its Reason starting content after the JSON value with the line and position, and serves the rest; a world.json or an export file is refused with those
    words; a response throws the refusal naming the request (GET /character/<id>: Not one JSON value: …); the cache's
    IsKnownOf throws it rather than answer false, and All<T> passes over that element and logs it; a records
    manifest with content after it refuses a share, as an unreadable one does. The refusal is a JsonReaderException,
    so a caller that catches JsonException still catches it. A text that ends in newlines or other whitespace reads as
    before.

Fixed

  • A folder or an .owworld skips such a file by its name. The other elements were always served, but the skip's
    Reason said unparseable JSON for a file that is JSON; it now starts number_out_of_range and says where the
    number sits. A world.json or a portal export file holding one is refused by that name, no longer as "not valid
    JSON".
  • A response holding such a number throws the refusal, naming the request (GET /character/: A number too large …), where it threw Newtonsoft's exception with no word of which call. A page is one JSON text, so the whole page
    fails, as before. An error response holding one still becomes an OWApiError of its status, its Code unread.
  • OWSync.BaselineAsync leaves the cache as it was when its walk throws. It emptied the cache before walking, and
    a walk that failed part way (a dropped connection, a cancel, a page holding such a number) left it empty at cursor 0;
    only the resets put it back. Now the baseline puts back its elements, cursor, cursor token, epoch and sync time
    itself, and an IncrementalAsync with no cursor (which runs one) does too.
  • OWWorldCache.IsKnownOf throws the refusal for a raw body holding such a number, where it answered false
    and so read a stub it could not read as a whole element.
  • A save never writes U+FFFD over bytes that are not UTF-8. The folder reader decodes an element file leniently,
    so a file holding one Latin-1 byte reads with U+FFFD in its place, and OWFolderWriter.Write or WriteElement of
    that body wrote EF BF BD over the person's byte, even when nothing was edited. Now a body read from such a file and
    not edited is left as it is on disk (its path returned, nothing written), and an edited one is refused with an
    OWFolderFormatException naming the file; a refused Write writes none of its batch. Files that are UTF-8 are
    written as before.
  • A save never writes over a file it could not read (folder spec §4.8). A new element whose short filename was
    already a file the writer could not read as an element (cut short, not JSON, not one JSON value, a number it cannot
    hold, an array, {"hidden": true} with no id) was written over it, since such a file was taken as holding no id and
    so as free. Now the element takes the next name, the full-id form the writer collision rule gives, and the file
    keeps its bytes; the next write of that element finds it there. When the full-id form is such a file too, nothing is
    written and WriteElement or Write throws an OWFolderFormatException naming the file (a refused Write writes
    none of its batch). A neighbour's id is read as the folder reader reads it, so an id shaped like a date is compared
    as written.