@onlyworlds/sdk 4.124.0 → 4.124.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.js +15 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,18 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.124.2] - 2026-11-01
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **`recordsOf` orders tied records and stories by code point**, as the record profile says. It compared ids with JavaScript's `<`, which is UTF-16 order and differs from code point order for characters above U+FFFF (an id holding U+1F600 sorted before one holding U+FF00). Ids in ASCII, which every fixture case uses, order as before.
|
|
13
|
+
|
|
14
|
+
## [4.124.1] - 2026-11-01
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **`recordsOf` reads a world in one pass.** It finds the Character's stories by each Event they name once, then looks each record's stories up, where it scanned every element again for each record: on a world of 5,000 elements with 200 records, about 7 ms a call down to about 1 ms. Every answer is the same as 4.124.0's (compared on 20,000 random worlds, including Narratives that name an Event twice and `events` lists holding other values), and each record's stories are its own objects.
|
|
19
|
+
|
|
8
20
|
## [4.124.0] - 2026-11-01
|
|
9
21
|
|
|
10
22
|
### Added
|
package/dist/index.js
CHANGED
|
@@ -3540,7 +3540,7 @@ var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
|
3540
3540
|
var unsetOr = (v, test) => v === void 0 || v === null || test(v);
|
|
3541
3541
|
var isString = (v) => typeof v === "string";
|
|
3542
3542
|
var list = (v) => Array.isArray(v) ? v : [];
|
|
3543
|
-
var cp =
|
|
3543
|
+
var cp = byCodePoint;
|
|
3544
3544
|
function isInstant(s) {
|
|
3545
3545
|
const m = PLAYED_AT.exec(s);
|
|
3546
3546
|
if (!m) return false;
|
|
@@ -3572,19 +3572,25 @@ function recordMarkOf(element) {
|
|
|
3572
3572
|
function recordsOf(characterId, elements) {
|
|
3573
3573
|
if (typeof characterId !== "string") throw new TypeError("recordsOf: characterId must be a string");
|
|
3574
3574
|
if (!Array.isArray(elements)) throw new TypeError("recordsOf: elements must be an array");
|
|
3575
|
+
const storiesOf = /* @__PURE__ */ new Map();
|
|
3576
|
+
for (const n of elements) {
|
|
3577
|
+
if (!isObject(n) || n.type !== "narrative" || proposed(n)) continue;
|
|
3578
|
+
const p = n.protagonist === characterId;
|
|
3579
|
+
const r = n.narrator === characterId;
|
|
3580
|
+
if (!p && !r) continue;
|
|
3581
|
+
const story = { id: n.id, name: isString(n.name) ? n.name : "", as: p && r ? "both" : p ? "protagonist" : "narrator" };
|
|
3582
|
+
for (const e of new Set(list(n.events))) {
|
|
3583
|
+
const at = storiesOf.get(e);
|
|
3584
|
+
if (at) at.push(story);
|
|
3585
|
+
else storiesOf.set(e, [story]);
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3575
3588
|
const out = [];
|
|
3576
3589
|
for (const ev of elements) {
|
|
3577
3590
|
const mark = recordMarkOf(ev);
|
|
3578
3591
|
if (!mark || proposed(ev) || !list(ev.characters).includes(characterId)) continue;
|
|
3579
3592
|
const id = ev.id;
|
|
3580
|
-
const stories = [];
|
|
3581
|
-
for (const n of elements) {
|
|
3582
|
-
if (!isObject(n) || n.type !== "narrative" || proposed(n) || !list(n.events).includes(id)) continue;
|
|
3583
|
-
const p = n.protagonist === characterId;
|
|
3584
|
-
const r = n.narrator === characterId;
|
|
3585
|
-
if (!p && !r) continue;
|
|
3586
|
-
stories.push({ id: n.id, name: isString(n.name) ? n.name : "", as: p && r ? "both" : p ? "protagonist" : "narrator" });
|
|
3587
|
-
}
|
|
3593
|
+
const stories = (storiesOf.get(id) ?? []).map((s) => ({ ...s }));
|
|
3588
3594
|
stories.sort((a, b) => cp(a.id, b.id));
|
|
3589
3595
|
const name = ev.name;
|
|
3590
3596
|
out.push({
|