@onlyworlds/sdk 4.180.0 → 4.182.0
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/AGENTS.md +3 -3
- package/README.md +4 -3
- package/SCHEMA.md +1 -1
- package/dist/{chunk-XHCCTVG7.js → chunk-EFH2PAJN.js} +25 -0
- package/dist/index.d.ts +227 -61
- package/dist/index.js +417 -96
- package/dist/waymark.d.ts +2 -1
- package/dist/waymark.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
isKnownOf,
|
|
38
38
|
isRoomElement,
|
|
39
39
|
isWhiteSpaceAt,
|
|
40
|
+
namedTalks,
|
|
40
41
|
openersFor,
|
|
41
42
|
parseOwLink,
|
|
42
43
|
proposedMarkOf,
|
|
@@ -45,11 +46,12 @@ import {
|
|
|
45
46
|
readingAidOf,
|
|
46
47
|
refuseUnknownOptions,
|
|
47
48
|
simpleCaseFold,
|
|
49
|
+
talksOf,
|
|
48
50
|
trimAndFold,
|
|
49
51
|
trimWhiteSpace,
|
|
50
52
|
typeWord,
|
|
51
53
|
unknownKey
|
|
52
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-EFH2PAJN.js";
|
|
53
55
|
|
|
54
56
|
// src/v2/keyed-id.ts
|
|
55
57
|
var KEYED_IDS = "0199b6a0-6f0e-7c2a-9d1e-3b5c7a8e4f21";
|
|
@@ -445,7 +447,7 @@ var OwApiError = class extends Error {
|
|
|
445
447
|
return this.status === 502 && this.code === "ask_failed";
|
|
446
448
|
}
|
|
447
449
|
/**
|
|
448
|
-
* patch, upsert or editLinks became a proposal (202): the world takes an
|
|
450
|
+
* patch, upsert or editLinks became a proposal (202): the world takes an AI seat's
|
|
449
451
|
* writes as proposals (`agent_writes_proposed`), so the element did not change. The error is an
|
|
450
452
|
* OwProposedError; its `proposal` is the row a keeper accepts or declines. Not a failure to retry:
|
|
451
453
|
* the write is waiting for a person.
|
|
@@ -480,7 +482,7 @@ var OwApiError = class extends Error {
|
|
|
480
482
|
return this.status === 409 && this.code === "stale_proposal";
|
|
481
483
|
}
|
|
482
484
|
/**
|
|
483
|
-
* While the world takes
|
|
485
|
+
* While the world takes AI seats' writes as proposals, an AI seat's key tried
|
|
484
486
|
* what it may not: delete an element it did not create, or accept or decline a proposal (403
|
|
485
487
|
* `proposed_only`). On any world, reviewNewElement by the member the mark names is the same 403.
|
|
486
488
|
* Retrying will not help; a person decides.
|
|
@@ -943,7 +945,7 @@ var OwV2Client = class {
|
|
|
943
945
|
* A person member's write key with its PIN; answers GET /me's body. 422 for a hidden
|
|
944
946
|
* Character (`character_hidden`, `err.isCharacterHidden`), a guest's pick it did not make, or a
|
|
945
947
|
* taken Character (`invalid_request`, `param` character); 404 for one this key cannot see; 403 for
|
|
946
|
-
* an
|
|
948
|
+
* an AI seat, a player, the owner (whose own is the world's `owner_character`, set with
|
|
947
949
|
* patchWorld) or a read key. A guest's view resets once.
|
|
948
950
|
*/
|
|
949
951
|
async setMyCharacter(character) {
|
|
@@ -958,7 +960,7 @@ var OwV2Client = class {
|
|
|
958
960
|
* a seat off its Titles' lenses. `null` goes back to never chosen: a seat playing a Character then
|
|
959
961
|
* starts with its Titles' lenses (`lenses_from` says where a list comes from); on the owner's own
|
|
960
962
|
* keys `null` is the empty list. Any write
|
|
961
|
-
* key of the world, with its PIN, sets its own holder's list: a person member's, an
|
|
963
|
+
* key of the world, with its PIN, sets its own holder's list: a person member's, an AI seat's, or
|
|
962
964
|
* on the owner's keys the owner's own; answers GET /me's body. The draught reads the list whenever it
|
|
963
965
|
* is given no lens and no policy. 404 for a lens this key cannot see; 422 `not_a_lens`,
|
|
964
966
|
* `lens_is_template` or `lens_hidden` (`param` lenses); 403 for a read key. A lens only narrows what
|
|
@@ -1139,7 +1141,7 @@ var OwV2Client = class {
|
|
|
1139
1141
|
* PUT /{type}/{id}/ -- upsert-by-client-id. The local-first write primitive. A known-of
|
|
1140
1142
|
* stub (`known_of: true`, see isKnownOf) is a TypeError before sending, here and on every
|
|
1141
1143
|
* element write: a PUT of one would blank every field it does not keep.
|
|
1142
|
-
* An
|
|
1144
|
+
* An AI seat's PUT on an existing element, in a world that takes its writes as proposals,
|
|
1143
1145
|
* answers 202 and is thrown as an OwProposedError: the element did not change.
|
|
1144
1146
|
*/
|
|
1145
1147
|
async upsert(type, id, element) {
|
|
@@ -1156,7 +1158,7 @@ var OwV2Client = class {
|
|
|
1156
1158
|
* an OwPreconditionFailedError (412) whose `current` is the element as it is now. Omit
|
|
1157
1159
|
* it for today's unconditional write.
|
|
1158
1160
|
*
|
|
1159
|
-
* In a world that takes an
|
|
1161
|
+
* In a world that takes an AI seat's writes as proposals (the world's
|
|
1160
1162
|
* `agent_writes_proposed`), a seat's patch answers 202 with `{proposal}`, never an element:
|
|
1161
1163
|
* this throws an OwProposedError (`err.isProposed`, the row under `err.proposal`) and the
|
|
1162
1164
|
* element did not change. If-Match is checked first: a stale one is still a 412.
|
|
@@ -1185,7 +1187,7 @@ var OwV2Client = class {
|
|
|
1185
1187
|
* Dedupes, tolerates already-present/already-absent ids. Returns the FULL
|
|
1186
1188
|
* updated element (fixture P5). Use this for all relationship editing; it
|
|
1187
1189
|
* retires the read-merge-PATCH dance. `ifMatch` works as on patch(): a link write
|
|
1188
|
-
* moves the element too. A 202 (an
|
|
1190
|
+
* moves the element too. A 202 (an AI seat's link edit that became a proposal)
|
|
1189
1191
|
* is thrown as an OwProposedError, as on patch().
|
|
1190
1192
|
*/
|
|
1191
1193
|
async editLinks(type, id, field, edit, opts = {}) {
|
|
@@ -1221,7 +1223,7 @@ var OwV2Client = class {
|
|
|
1221
1223
|
* After an atomic:true request with errors:true NOTHING was written, yet the slots of
|
|
1222
1224
|
* the items that would have succeeded still say 201 with the ids and timestamps they
|
|
1223
1225
|
* would have had (keel's "counterfactual 201s"): do not record those ids as created.
|
|
1224
|
-
* An
|
|
1226
|
+
* An AI seat's item on an existing element, in a world that takes its writes as
|
|
1225
1227
|
* proposals, answers a slot `{status: 202, id, proposal}`: never thrown, the
|
|
1226
1228
|
* element unchanged, the slot's `proposal` the row a keeper decides.
|
|
1227
1229
|
* An element without an id gets one, as `create` mints it, by its position in `items`: with an
|
|
@@ -1401,7 +1403,7 @@ var OwV2Client = class {
|
|
|
1401
1403
|
/**
|
|
1402
1404
|
* POST /media/remove-ticket -- permission to remove ONE image (a write key and its
|
|
1403
1405
|
* PIN). The image's uploader may remove it, and so may the world's owner key; an
|
|
1404
|
-
*
|
|
1406
|
+
* AI seat answers as its sponsor. Only images uploaded with a ticket qualify.
|
|
1405
1407
|
* `key` is the object key, or the whole image_url (the part after the host is taken).
|
|
1406
1408
|
* The reply's `referenced` counts the world's elements still showing the image.
|
|
1407
1409
|
* Refusals: 403 `permission_error` (neither uploader nor owner), 404 `not_found`
|
|
@@ -1571,7 +1573,7 @@ var OwV2Client = class {
|
|
|
1571
1573
|
/**
|
|
1572
1574
|
* DELETE /{type}/{id}/files/{fileId} -- remove a file for real: it leaves the lists and
|
|
1573
1575
|
* the world's total at once, and its bytes are deleted from the store. The world's owner
|
|
1574
|
-
* key may, and so may the key of whoever added it (an
|
|
1576
|
+
* key may, and so may the key of whoever added it (an AI seat answers as its sponsor);
|
|
1575
1577
|
* any other key is 403 `permission_error`. A file that is not there is 404 `not_found`.
|
|
1576
1578
|
* Deleting an element removes its files too.
|
|
1577
1579
|
*/
|
|
@@ -1850,7 +1852,7 @@ var OwV2Client = class {
|
|
|
1850
1852
|
return this.request("POST", `/account/worlds/${seg("worldId", worldId)}/seats`, { body });
|
|
1851
1853
|
}
|
|
1852
1854
|
/**
|
|
1853
|
-
* GET /account/worlds/{worldId}/seats -- the live
|
|
1855
|
+
* GET /account/worlds/{worldId}/seats -- the live AI seats you can see: your own AI's, or,
|
|
1854
1856
|
* as the world's owner, every seat. No keys or secrets. Needs the client's `ow_a_` token.
|
|
1855
1857
|
*/
|
|
1856
1858
|
async listSeats(worldId) {
|
|
@@ -1874,7 +1876,7 @@ var OwV2Client = class {
|
|
|
1874
1876
|
return this.request("POST", `/account/worlds/${seg("worldId", worldId)}/seats/${seg("seatId", seatId)}/key`);
|
|
1875
1877
|
}
|
|
1876
1878
|
/**
|
|
1877
|
-
* DELETE /account/worlds/{worldId}/seats/{seatId} -- remove an
|
|
1879
|
+
* DELETE /account/worlds/{worldId}/seats/{seatId} -- remove an AI seat: its sponsor or the
|
|
1878
1880
|
* world's owner may. Its key and secret stop at once; the Character it plays goes with it only
|
|
1879
1881
|
* while it is as the join left one (made by the join, named as the seat, supertype `Agent` alone,
|
|
1880
1882
|
* last written by the join, linked from nothing, played by no one else); any other stays, one
|
|
@@ -1950,7 +1952,7 @@ var OwV2Client = class {
|
|
|
1950
1952
|
/**
|
|
1951
1953
|
* POST /{type}/{id}/proposals -- propose a change to an element without making it. Any member
|
|
1952
1954
|
* who reads the element proposes (the owner with its write key and PIN; a co-builder, a
|
|
1953
|
-
* contributor, a guest, an
|
|
1955
|
+
* contributor, a guest, an AI seat or a player seat, whose read key is enough). `fields` is
|
|
1954
1956
|
* cleaned as patch() cleans a body (a read body's server keys stripped; a known-of stub is a
|
|
1955
1957
|
* TypeError before sending) and names only fields this key's view of the element holds;
|
|
1956
1958
|
* `evidence` is 1 to 2,000 characters; `expires` 1 to 365 days out (keel's default 30). keel
|
|
@@ -2016,7 +2018,7 @@ var OwV2Client = class {
|
|
|
2016
2018
|
* POST /{type}/{id}/proposals/{pid}/accept -- write the proposal's fields to the element as one
|
|
2017
2019
|
* ordinary write by this key (`changed_by` is the keeper, a new change_seq, a /changes row), and
|
|
2018
2020
|
* the row turns accepted. The world's owner key or a co-builder's, with its PIN; never the
|
|
2019
|
-
* proposer's own (403 `own_proposal`, `err.isOwnProposal`), never an
|
|
2021
|
+
* proposer's own (403 `own_proposal`, `err.isOwnProposal`), never an AI seat's while the
|
|
2020
2022
|
* world holds them (403 `proposed_only`, `err.isProposedOnly`). Refused with nothing written when
|
|
2021
2023
|
* a proposed field moved since (409 `stale_proposal`: an OwStaleProposalError carrying
|
|
2022
2024
|
* `conflicts` and `current`; the row stays open) or a proposed link names an element deleted
|
|
@@ -2053,7 +2055,7 @@ var OwV2Client = class {
|
|
|
2053
2055
|
* deletes the element (a tombstone, the links to it scrubbed, its open proposals dropped) and
|
|
2054
2056
|
* answers `{ deleted }`, its id; the reason is answered back and kept nowhere. Refusals: 422
|
|
2055
2057
|
* `not_proposed` (`err.isNotProposed`: the element carries no mark), 403 `proposed_only`
|
|
2056
|
-
* (`err.isProposedOnly`: the seat the mark names, or an
|
|
2058
|
+
* (`err.isProposedOnly`: the seat the mark names, or an AI seat under the world's switch), 403
|
|
2057
2059
|
* for any key but a keeper's. A proposed change to an existing element is decided with
|
|
2058
2060
|
* acceptProposal or declineProposal instead.
|
|
2059
2061
|
*/
|
|
@@ -2530,7 +2532,7 @@ async function proposedFromResponse(res, method, path) {
|
|
|
2530
2532
|
return new OwProposedError(
|
|
2531
2533
|
202,
|
|
2532
2534
|
null,
|
|
2533
|
-
`${method} ${path} became a proposal (202): this world takes an
|
|
2535
|
+
`${method} ${path} became a proposal (202): this world takes an AI seat's writes as proposals, so the element did not change. err.proposal is the row; the owner or a co-builder accepts or declines it.`,
|
|
2534
2536
|
null,
|
|
2535
2537
|
body
|
|
2536
2538
|
);
|
|
@@ -3271,7 +3273,7 @@ var Reading = class {
|
|
|
3271
3273
|
this.owner = reader.rung === "owner";
|
|
3272
3274
|
const seen = this.owner && reader.as != null ? reader.as : reader;
|
|
3273
3275
|
this.seenRung = seen.rung;
|
|
3274
|
-
this.stored = seen.rung === "owner";
|
|
3276
|
+
this.stored = seen.rung === "owner" || seen.rung === "co-builder";
|
|
3275
3277
|
this.character = typeof seen.character === "string" && seen.character !== "" ? seen.character : null;
|
|
3276
3278
|
const listed = (v) => new Set(Array.isArray(v) ? v.filter((i) => typeof i === "string") : []);
|
|
3277
3279
|
const wholeIds = listed(seen.whole);
|
|
@@ -3283,10 +3285,13 @@ var Reading = class {
|
|
|
3283
3285
|
let sees;
|
|
3284
3286
|
switch (seen.rung) {
|
|
3285
3287
|
case "owner":
|
|
3288
|
+
case "co-builder":
|
|
3286
3289
|
sees = true;
|
|
3287
3290
|
break;
|
|
3291
|
+
// The hidden mark keeps an element from every reader but a keeper and the one who made it: a contributor's
|
|
3292
|
+
// view is the world less the hidden, plus the hidden elements it made, listed in `whole` (serial 138).
|
|
3288
3293
|
case "contributor":
|
|
3289
|
-
sees = !hidden.has(id);
|
|
3294
|
+
sees = !hidden.has(id) || wholeIds.has(id);
|
|
3290
3295
|
break;
|
|
3291
3296
|
case "public":
|
|
3292
3297
|
sees = !hidden.has(id) && !this.room.has(id) && !proposed2;
|
|
@@ -3353,7 +3358,8 @@ var Reading = class {
|
|
|
3353
3358
|
* and the type's public fields kept, every other field of the type it holds at its unset value (`UNSET`; the
|
|
3354
3359
|
* server's who and door null), no extension key, and `known_of: true`. A body of an element under the hidden
|
|
3355
3360
|
* mark (the world's `hidden` list or its own `hidden`) carries `hidden: true`, and no other body a `hidden` key:
|
|
3356
|
-
* only the owner's view holds a hidden element, and a guest's its own hidden creations, listed
|
|
3361
|
+
* only the owner's view holds a hidden element, and a contributor's or a guest's its own hidden creations, listed
|
|
3362
|
+
* in `whole`.
|
|
3357
3363
|
*/
|
|
3358
3364
|
body(id) {
|
|
3359
3365
|
let b = this.served.get(id);
|
|
@@ -3667,8 +3673,8 @@ function mailPart(r, mode, budget, clock) {
|
|
|
3667
3673
|
}
|
|
3668
3674
|
var NOTHING = () => ({ kept: [], rows: [], cut: {}, notesIgnored: 0, mail: null, unreadable: null });
|
|
3669
3675
|
function checkReader(reader, where) {
|
|
3670
|
-
if (!isBody2(reader) || !["owner", "contributor", "guest", "public"].includes(reader.rung)) {
|
|
3671
|
-
throw new TypeError(`${where}: a reader is an object whose rung is owner, contributor, guest or public; got ${JSON.stringify(reader) ?? String(reader)}.`);
|
|
3676
|
+
if (!isBody2(reader) || !["owner", "co-builder", "contributor", "guest", "public"].includes(reader.rung)) {
|
|
3677
|
+
throw new TypeError(`${where}: a reader is an object whose rung is owner, co-builder, contributor, guest or public; got ${JSON.stringify(reader) ?? String(reader)}.`);
|
|
3672
3678
|
}
|
|
3673
3679
|
if (reader.as !== void 0 && reader.as !== null) checkReader(reader.as, `${where}.as`);
|
|
3674
3680
|
}
|
|
@@ -3771,16 +3777,21 @@ function hubsOf(id, r) {
|
|
|
3771
3777
|
return out;
|
|
3772
3778
|
}
|
|
3773
3779
|
var NONE = () => ({ charter: null, guide: null, domains: [] });
|
|
3774
|
-
function
|
|
3780
|
+
function readAids(world, reader, fn) {
|
|
3775
3781
|
if (!isBody2(world) || !Array.isArray(world.elements)) {
|
|
3776
|
-
throw new TypeError(
|
|
3782
|
+
throw new TypeError(`${fn}: world is an object with an elements list.`);
|
|
3777
3783
|
}
|
|
3778
|
-
checkReader(reader,
|
|
3784
|
+
checkReader(reader, `${fn}: reader`);
|
|
3779
3785
|
const r = new Reading(world, reader, null);
|
|
3780
|
-
if (r.seenRung === "public" && world.open !== true) return
|
|
3786
|
+
if (r.seenRung === "public" && world.open !== true) return null;
|
|
3781
3787
|
const seen = (pair) => r.order.filter((id) => r.view.has(id) && r.aid.get(id) === pair);
|
|
3788
|
+
return { r, law: newest(seen("law/charter"), r), seen };
|
|
3789
|
+
}
|
|
3790
|
+
function charterOf(world, reader) {
|
|
3791
|
+
const read = readAids(world, reader, "charterOf");
|
|
3792
|
+
if (read === null) return NONE();
|
|
3793
|
+
const { r, law, seen } = read;
|
|
3782
3794
|
const out = NONE();
|
|
3783
|
-
const law = newest(seen("law/charter"), r);
|
|
3784
3795
|
if (law !== null) {
|
|
3785
3796
|
const el = r.byId.get(law);
|
|
3786
3797
|
const rules = el.x_checks_rules;
|
|
@@ -3821,6 +3832,23 @@ function charterOf(world, reader) {
|
|
|
3821
3832
|
function domainsOf(world, reader) {
|
|
3822
3833
|
return charterOf(world, reader).domains;
|
|
3823
3834
|
}
|
|
3835
|
+
var DESIGN_STATES = /* @__PURE__ */ new Set(["in design", "locked"]);
|
|
3836
|
+
function designPartsOf(world, reader) {
|
|
3837
|
+
const read = readAids(world, reader, "designPartsOf");
|
|
3838
|
+
if (read === null || read.law === null) return [];
|
|
3839
|
+
const { r } = read;
|
|
3840
|
+
const out = [];
|
|
3841
|
+
for (const id of r.order) {
|
|
3842
|
+
if (!r.view.has(id) || r.stubs.has(id)) continue;
|
|
3843
|
+
const type = r.typeOf.get(id);
|
|
3844
|
+
if (type !== "object" && type !== "construct") continue;
|
|
3845
|
+
const subtype = r.body(id).subtype;
|
|
3846
|
+
if (typeof subtype !== "string") continue;
|
|
3847
|
+
const state = fold(subtype);
|
|
3848
|
+
if (DESIGN_STATES.has(state)) out.push({ type, id, state });
|
|
3849
|
+
}
|
|
3850
|
+
return out;
|
|
3851
|
+
}
|
|
3824
3852
|
|
|
3825
3853
|
// src/strand.ts
|
|
3826
3854
|
var STRAND_FIELD = "x_strand";
|
|
@@ -4006,6 +4034,10 @@ function reportThreadsOf(narratives) {
|
|
|
4006
4034
|
}
|
|
4007
4035
|
return { parents, groups, lints };
|
|
4008
4036
|
}
|
|
4037
|
+
function reportTalksOf(narrative) {
|
|
4038
|
+
if (!isBody3(narrative) || roomKindOf(narrative) !== "report") return [];
|
|
4039
|
+
return namedTalks(narrative);
|
|
4040
|
+
}
|
|
4009
4041
|
var REPORT_LINE_KEYS = ["world"];
|
|
4010
4042
|
var CLOSING = /* @__PURE__ */ new Set([".", ",", ";", ":", "!", ")", "]", "}", "'", '"', "\u2019", "\u201D", "\xBB"]);
|
|
4011
4043
|
var PAIRS = /* @__PURE__ */ new Map([["(", ")"], ["[", "]"], ['"', '"'], ["'", "'"], ["\u201C", "\u201D"], ["\u2018", "\u2019"], ["\xAB", "\xBB"]]);
|
|
@@ -4060,6 +4092,98 @@ function readReportLines(text2, options) {
|
|
|
4060
4092
|
return text2.split(/[\r\n]/).map(trimWhiteSpace).filter((l) => l !== "").map((l) => readLine(l, world));
|
|
4061
4093
|
}
|
|
4062
4094
|
|
|
4095
|
+
// src/packet.ts
|
|
4096
|
+
var WORK_ITEM_PAIR = { type: "relation", supertype: "Work item" };
|
|
4097
|
+
var STATES = /* @__PURE__ */ new Set(["open", "taken", "done", "standing"]);
|
|
4098
|
+
var isBody4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4099
|
+
function isWorkItem(item) {
|
|
4100
|
+
if (!isBody4(item) || typeof item.type !== "string" || typeof item.supertype !== "string") return false;
|
|
4101
|
+
return fold(item.type) === WORK_ITEM_PAIR.type && fold(item.supertype) === fold(WORK_ITEM_PAIR.supertype);
|
|
4102
|
+
}
|
|
4103
|
+
function put(map, key3, value) {
|
|
4104
|
+
Object.defineProperty(map, key3, { value, enumerable: true, writable: true, configurable: true });
|
|
4105
|
+
}
|
|
4106
|
+
var has = (map, key3) => Object.prototype.hasOwnProperty.call(map, key3);
|
|
4107
|
+
function workStateOf(item) {
|
|
4108
|
+
if (!isWorkItem(item) || typeof item.subtype !== "string") return null;
|
|
4109
|
+
const state = fold(item.subtype);
|
|
4110
|
+
return STATES.has(state) ? state : null;
|
|
4111
|
+
}
|
|
4112
|
+
function isOpenWork(item) {
|
|
4113
|
+
const state = workStateOf(item);
|
|
4114
|
+
return state === "open" || state === "taken";
|
|
4115
|
+
}
|
|
4116
|
+
function askerKey(item) {
|
|
4117
|
+
const v = has(item, "x_packet_from") ? item.x_packet_from : void 0;
|
|
4118
|
+
if (v === void 0 || v === null) return "absent";
|
|
4119
|
+
if (typeof v !== "string" || trimWhiteSpace(v) === "") return "bad";
|
|
4120
|
+
return v;
|
|
4121
|
+
}
|
|
4122
|
+
function idsOf(v) {
|
|
4123
|
+
return new Set(Array.isArray(v) ? v.filter((x) => typeof x === "string") : []);
|
|
4124
|
+
}
|
|
4125
|
+
function askerOf(item, world) {
|
|
4126
|
+
if (!isWorkItem(item)) return null;
|
|
4127
|
+
const key3 = askerKey(item);
|
|
4128
|
+
if (key3 === "absent" || key3 === "bad") return null;
|
|
4129
|
+
if (world === void 0) return key3;
|
|
4130
|
+
if (!isBody4(world)) throw new TypeError("askerOf: world is an object with its characters and others.");
|
|
4131
|
+
return idsOf(world.characters).has(key3) ? key3 : null;
|
|
4132
|
+
}
|
|
4133
|
+
function elementsOf(item) {
|
|
4134
|
+
const list2 = item.x_packet_elements;
|
|
4135
|
+
const out = [];
|
|
4136
|
+
for (const e of Array.isArray(list2) ? list2 : []) {
|
|
4137
|
+
if (!isBody4(e) || typeof e.type !== "string" || typeof e.id !== "string" || typeof e.reason !== "string") continue;
|
|
4138
|
+
if (trimWhiteSpace(e.id) === "") continue;
|
|
4139
|
+
out.push({ type: e.type, id: e.id, reason: e.reason });
|
|
4140
|
+
}
|
|
4141
|
+
return out;
|
|
4142
|
+
}
|
|
4143
|
+
function workOf(items, world, sourceWorld) {
|
|
4144
|
+
if (!Array.isArray(items)) throw new TypeError("workOf: items is a list of work items.");
|
|
4145
|
+
if (!isBody4(world)) throw new TypeError("workOf: world is an object with its characters and others.");
|
|
4146
|
+
if (sourceWorld !== void 0 && sourceWorld !== null && !isBody4(sourceWorld)) {
|
|
4147
|
+
throw new TypeError("workOf: sourceWorld is an object with its characters and others, or left out.");
|
|
4148
|
+
}
|
|
4149
|
+
const characters = idsOf(world.characters);
|
|
4150
|
+
const held = /* @__PURE__ */ new Set([...idsOf(world.others)]);
|
|
4151
|
+
if (isBody4(sourceWorld)) for (const id of [...idsOf(sourceWorld.characters), ...idsOf(sourceWorld.others)]) held.add(id);
|
|
4152
|
+
const read = [];
|
|
4153
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4154
|
+
for (const item of items) {
|
|
4155
|
+
if (!isWorkItem(item) || typeof item.id !== "string" || item.id === "" || seen.has(item.id)) continue;
|
|
4156
|
+
seen.add(item.id);
|
|
4157
|
+
read.push(item);
|
|
4158
|
+
}
|
|
4159
|
+
for (const id of seen) held.add(id);
|
|
4160
|
+
const out = { states: {}, shown: [], openWork: {}, elements: {}, askers: {}, lints: [], waitingOn: {} };
|
|
4161
|
+
for (const id of characters) put(out.waitingOn, id, []);
|
|
4162
|
+
for (const item of read) {
|
|
4163
|
+
const id = item.id;
|
|
4164
|
+
const open = isOpenWork(item);
|
|
4165
|
+
put(out.states, id, workStateOf(item));
|
|
4166
|
+
out.shown.push(id);
|
|
4167
|
+
const elements = elementsOf(item);
|
|
4168
|
+
put(out.elements, id, elements);
|
|
4169
|
+
for (const e of elements) {
|
|
4170
|
+
if (!has(out.openWork, e.id)) put(out.openWork, e.id, []);
|
|
4171
|
+
const list2 = out.openWork[e.id];
|
|
4172
|
+
if (open && !list2.includes(id)) list2.push(id);
|
|
4173
|
+
}
|
|
4174
|
+
const key3 = askerKey(item);
|
|
4175
|
+
let asker = null;
|
|
4176
|
+
if (key3 === "bad") out.lints.push({ kind: "asker", item: id });
|
|
4177
|
+
else if (key3 !== "absent") {
|
|
4178
|
+
if (characters.has(key3)) asker = key3;
|
|
4179
|
+
else if (held.has(key3)) out.lints.push({ kind: "asker", item: id });
|
|
4180
|
+
}
|
|
4181
|
+
put(out.askers, id, asker);
|
|
4182
|
+
if (asker !== null && open) out.waitingOn[asker].push(id);
|
|
4183
|
+
}
|
|
4184
|
+
return out;
|
|
4185
|
+
}
|
|
4186
|
+
|
|
4063
4187
|
// src/graph.ts
|
|
4064
4188
|
var GRAPH_OPTION_KEYS = ["lens", "asOf", "clock", "rooms", "hidden", "proposed", "mapSpace", "readingAids"];
|
|
4065
4189
|
var DECLARED_LINKS = Object.freeze(["x_lens_leads_to", "x_spine_depends_on"]);
|
|
@@ -6483,12 +6607,12 @@ function relax(feed, opts = {}) {
|
|
|
6483
6607
|
// src/layout3d/hang.ts
|
|
6484
6608
|
var REST3 = 60;
|
|
6485
6609
|
var GOLD = 2.399963229728653;
|
|
6486
|
-
var HOW = ["centre", "with", "arm", "link", "
|
|
6610
|
+
var HOW = ["centre", "with", "arm", "link", "off", "map"];
|
|
6487
6611
|
var CENTRE = 0;
|
|
6488
6612
|
var WITH = 1;
|
|
6489
6613
|
var ARM = 2;
|
|
6490
6614
|
var LINK = 3;
|
|
6491
|
-
var
|
|
6615
|
+
var OFF = 4;
|
|
6492
6616
|
var MAP = 5;
|
|
6493
6617
|
var LINE = REST3 / 8;
|
|
6494
6618
|
var len3 = (x, y, z) => Math.sqrt(x * x + y * y + z * z);
|
|
@@ -6508,7 +6632,7 @@ function quantile90(a, m) {
|
|
|
6508
6632
|
const d = s[hi] - s[lo];
|
|
6509
6633
|
return t >= 0.5 ? s[hi] - d * (1 - t) : s[lo] + d * t;
|
|
6510
6634
|
}
|
|
6511
|
-
function hang(ids, body, hangCut, hangDepth, off, taken, group, cpt, plate2,
|
|
6635
|
+
function hang(ids, body, hangCut, hangDepth, off, taken, group, cpt, plate2, degree, relaxed, opts = {}) {
|
|
6512
6636
|
const n = ids.length, k = taken.length;
|
|
6513
6637
|
const pinned = plate2 ? plate2.pinned : new Uint8Array(n);
|
|
6514
6638
|
const at = plate2 ? plate2.at : null;
|
|
@@ -6686,51 +6810,7 @@ function hang(ids, body, hangCut, hangDepth, off, taken, group, cpt, plate2, kin
|
|
|
6686
6810
|
pos[3 * v + 2] = fp[2];
|
|
6687
6811
|
}
|
|
6688
6812
|
}
|
|
6689
|
-
let
|
|
6690
|
-
for (let v = 0; v < n; v++) if (off[v]) anyOff++;
|
|
6691
|
-
if (anyOff) {
|
|
6692
|
-
let zmin = Infinity, sx = 0, sy = 0, cnt = 0;
|
|
6693
|
-
for (let v = 0; v < n; v++) {
|
|
6694
|
-
if (off[v]) continue;
|
|
6695
|
-
const end = pinned[v];
|
|
6696
|
-
const src = end ? at : inH[v] ? hat : pos;
|
|
6697
|
-
const fx = src[3 * v], fy = src[3 * v + 1], fz = src[3 * v + 2];
|
|
6698
|
-
if (fz < zmin) zmin = fz;
|
|
6699
|
-
sx += fx;
|
|
6700
|
-
sy += fy;
|
|
6701
|
-
cnt++;
|
|
6702
|
-
}
|
|
6703
|
-
zmin = zmin - REST3 * 3;
|
|
6704
|
-
const cx = sx / cnt, cy = sy / cnt;
|
|
6705
|
-
const shelf = [];
|
|
6706
|
-
for (let v = 0; v < n; v++) if (off[v] && !pinned[v]) shelf.push(v);
|
|
6707
|
-
shelf.sort((x, y) => byCodePoint2(kind[x], kind[y]) || x - y);
|
|
6708
|
-
const shelfPoint = (j) => {
|
|
6709
|
-
const r = REST3 * 0.9 * Math.sqrt(j + 1);
|
|
6710
|
-
fp[0] = cx + r * Math.cos(GOLD * j);
|
|
6711
|
-
fp[1] = cy + r * Math.sin(GOLD * j);
|
|
6712
|
-
fp[2] = zmin;
|
|
6713
|
-
};
|
|
6714
|
-
const used = H ? /* @__PURE__ */ new Set() : null;
|
|
6715
|
-
for (let q = 0; q < shelf.length; q++) {
|
|
6716
|
-
const v = shelf[q];
|
|
6717
|
-
how[v] = SHELF;
|
|
6718
|
-
let j = q;
|
|
6719
|
-
if (H) {
|
|
6720
|
-
if (inH[v]) continue;
|
|
6721
|
-
for (j = 0; ; j++) {
|
|
6722
|
-
if (used.has(j)) continue;
|
|
6723
|
-
shelfPoint(j);
|
|
6724
|
-
if (!near(fp[0], fp[1], fp[2])) break;
|
|
6725
|
-
}
|
|
6726
|
-
used.add(j);
|
|
6727
|
-
}
|
|
6728
|
-
shelfPoint(j);
|
|
6729
|
-
pos[3 * v] = fp[0];
|
|
6730
|
-
pos[3 * v + 1] = fp[1];
|
|
6731
|
-
pos[3 * v + 2] = fp[2];
|
|
6732
|
-
}
|
|
6733
|
-
}
|
|
6813
|
+
for (let v = 0; v < n; v++) if (off[v] && !pinned[v]) how[v] = OFF;
|
|
6734
6814
|
if (H) {
|
|
6735
6815
|
for (let i = 0; i < hl.length; i++) {
|
|
6736
6816
|
const v = hl[i];
|
|
@@ -6775,7 +6855,7 @@ function isPoint(p) {
|
|
|
6775
6855
|
for (let i = 0; i < 3; i++) if (typeof q[i] !== "number" || !Number.isFinite(q[i])) return false;
|
|
6776
6856
|
return true;
|
|
6777
6857
|
}
|
|
6778
|
-
function readHeld(held) {
|
|
6858
|
+
function readHeld(held, box = true) {
|
|
6779
6859
|
if (held === void 0 || held === null) return null;
|
|
6780
6860
|
let entries = [];
|
|
6781
6861
|
if (held instanceof Map) entries = [...held.entries()];
|
|
@@ -6785,7 +6865,7 @@ function readHeld(held) {
|
|
|
6785
6865
|
if (!isPoint(p)) refuse(TypeError, REFUSED.notPoint, `layoutByLinks3d: held[${id}] is not three finite numbers`);
|
|
6786
6866
|
}
|
|
6787
6867
|
const points2 = entries;
|
|
6788
|
-
if (points2.length) {
|
|
6868
|
+
if (box && points2.length) {
|
|
6789
6869
|
const lo = [Infinity, Infinity, Infinity], hi = [-Infinity, -Infinity, -Infinity];
|
|
6790
6870
|
for (const [, p] of points2) for (let a = 0; a < 3; a++) {
|
|
6791
6871
|
if (p[a] < lo[a]) lo[a] = p[a];
|
|
@@ -7067,7 +7147,6 @@ function layout3d(nodes, edges, rows2, table, opts = {}) {
|
|
|
7067
7147
|
relaxed[3 * v + 2] = r.pos[3 * j + 2];
|
|
7068
7148
|
j++;
|
|
7069
7149
|
}
|
|
7070
|
-
const kind = sortedNodes.map((x) => x.type);
|
|
7071
7150
|
const degree = new Int32Array(n);
|
|
7072
7151
|
for (const [a, b] of ip) {
|
|
7073
7152
|
degree[a]++;
|
|
@@ -7075,7 +7154,7 @@ function layout3d(nodes, edges, rows2, table, opts = {}) {
|
|
|
7075
7154
|
}
|
|
7076
7155
|
const hopts = {};
|
|
7077
7156
|
if (heldOpt) hopts.held = { ...heldOpt };
|
|
7078
|
-
const h = hang(s.ids, s.body, s.hangCut, s.hangDepth, s.off, c.taken, c.group, p.cpt, p.plate,
|
|
7157
|
+
const h = hang(s.ids, s.body, s.hangCut, s.hangDepth, s.off, c.taken, c.group, p.cpt, p.plate, degree, relaxed, hopts);
|
|
7079
7158
|
const out = new Float64Array(3 * n), how = new Array(n), group = new Array(n), part = new Array(n);
|
|
7080
7159
|
const held = new Array(n);
|
|
7081
7160
|
for (let i = 0; i < n; i++) {
|
|
@@ -7098,12 +7177,247 @@ function layout3d(nodes, edges, rows2, table, opts = {}) {
|
|
|
7098
7177
|
part[i] = "one-link";
|
|
7099
7178
|
} else {
|
|
7100
7179
|
group[i] = null;
|
|
7101
|
-
part[i] =
|
|
7180
|
+
part[i] = null;
|
|
7102
7181
|
}
|
|
7103
7182
|
}
|
|
7104
7183
|
return { method: METHOD, ids: handed, points: out, how, group, part, centres: Array.from(c.taken, (t) => ids[t]), held };
|
|
7105
7184
|
}
|
|
7106
7185
|
|
|
7186
|
+
// src/layout3d/pieces.ts
|
|
7187
|
+
var RING_GAP = CLEAR * REST4;
|
|
7188
|
+
var FIT = 1e-6;
|
|
7189
|
+
var TWO_PI = 2 * Math.PI;
|
|
7190
|
+
var FIT_EDGE = TWO_PI - FIT;
|
|
7191
|
+
function heldMapOf(held) {
|
|
7192
|
+
if (held === void 0 || held === null) return /* @__PURE__ */ new Map();
|
|
7193
|
+
if (held instanceof Map) return held;
|
|
7194
|
+
return new Map(Object.entries(held));
|
|
7195
|
+
}
|
|
7196
|
+
function layoutPieces(nodes, edges, rows2, table, opts = {}) {
|
|
7197
|
+
readHeld(opts.held, false);
|
|
7198
|
+
readUnit(opts.heldUnit);
|
|
7199
|
+
const n = nodes.length;
|
|
7200
|
+
const runOpts = (held2) => {
|
|
7201
|
+
const o = {};
|
|
7202
|
+
if (held2 !== void 0) o.held = held2;
|
|
7203
|
+
if (opts.heldUnit !== void 0) o.heldUnit = opts.heldUnit;
|
|
7204
|
+
return o;
|
|
7205
|
+
};
|
|
7206
|
+
if (!n) {
|
|
7207
|
+
const none = opts.held === void 0 || opts.held === null ? opts.held : /* @__PURE__ */ new Map();
|
|
7208
|
+
return { ...layout3d(nodes, edges, rows2, table, runOpts(none)), unplaced: [] };
|
|
7209
|
+
}
|
|
7210
|
+
const handed = nodes.map((x) => x.id);
|
|
7211
|
+
const mainRow = new Map(handed.map((id, i) => [id, i]));
|
|
7212
|
+
const sortedNodes = [...nodes].sort((a, b) => byCodePoint2(a.id, b.id));
|
|
7213
|
+
const ids = sortedNodes.map((x) => x.id);
|
|
7214
|
+
const at = new Map(ids.map((id, i) => [id, i]));
|
|
7215
|
+
const parent = new Int32Array(n);
|
|
7216
|
+
for (let i = 0; i < n; i++) parent[i] = i;
|
|
7217
|
+
const find = (a) => {
|
|
7218
|
+
while (parent[a] !== a) {
|
|
7219
|
+
parent[a] = parent[parent[a]];
|
|
7220
|
+
a = parent[a];
|
|
7221
|
+
}
|
|
7222
|
+
return a;
|
|
7223
|
+
};
|
|
7224
|
+
for (const e of edges) {
|
|
7225
|
+
const a = at.get(e.source), b = at.get(e.target);
|
|
7226
|
+
if (a === void 0 || b === void 0 || a === b) continue;
|
|
7227
|
+
const ra = find(a), rb = find(b);
|
|
7228
|
+
if (ra !== rb) {
|
|
7229
|
+
if (ra < rb) parent[rb] = ra;
|
|
7230
|
+
else parent[ra] = rb;
|
|
7231
|
+
}
|
|
7232
|
+
}
|
|
7233
|
+
const pieceOf = new Int32Array(n).fill(-1);
|
|
7234
|
+
const pieces = [];
|
|
7235
|
+
for (let v = 0; v < n; v++) {
|
|
7236
|
+
const r = find(v);
|
|
7237
|
+
if (pieceOf[r] === -1) {
|
|
7238
|
+
pieceOf[r] = pieces.length;
|
|
7239
|
+
pieces.push({ members: [], least: ids[v] });
|
|
7240
|
+
}
|
|
7241
|
+
pieceOf[v] = pieceOf[r];
|
|
7242
|
+
pieces[pieceOf[v]].members.push(v);
|
|
7243
|
+
}
|
|
7244
|
+
let mainP = -1, mainSize = 0;
|
|
7245
|
+
for (let p = 0; p < pieces.length; p++) if (pieces[p].members.length > mainSize) {
|
|
7246
|
+
mainSize = pieces[p].members.length;
|
|
7247
|
+
mainP = p;
|
|
7248
|
+
}
|
|
7249
|
+
const heldAll = heldMapOf(opts.held);
|
|
7250
|
+
const onMap = /* @__PURE__ */ new Set();
|
|
7251
|
+
if (rows2) {
|
|
7252
|
+
const pa = plate(rows2, new Set(ids));
|
|
7253
|
+
if (pa) for (const id of pa.at.keys()) onMap.add(id);
|
|
7254
|
+
}
|
|
7255
|
+
const mainSet = new Set(mainSize >= 2 ? pieces[mainP].members.map((v) => ids[v]) : []);
|
|
7256
|
+
let mainHeld = opts.held === void 0 || opts.held === null ? opts.held : /* @__PURE__ */ new Map();
|
|
7257
|
+
if (mainHeld) {
|
|
7258
|
+
for (const [id, q] of heldAll) if (mainSet.has(id) || onMap.has(id)) mainHeld.set(id, q);
|
|
7259
|
+
}
|
|
7260
|
+
const main = layout3d(nodes, edges, rows2, table, runOpts(mainHeld));
|
|
7261
|
+
const pinned = new Uint8Array(n), keep = new Uint8Array(n);
|
|
7262
|
+
for (let v = 0; v < n; v++) {
|
|
7263
|
+
if (main.how[mainRow.get(ids[v])] === "map") pinned[v] = 1;
|
|
7264
|
+
if (mainSize >= 2 && pieceOf[v] === mainP || pinned[v]) keep[v] = 1;
|
|
7265
|
+
}
|
|
7266
|
+
const others = [];
|
|
7267
|
+
for (let p = 0; p < pieces.length; p++) if (p !== mainP && pieces[p].members.length >= 2) others.push(p);
|
|
7268
|
+
others.sort((p, q) => pieces[q].members.length - pieces[p].members.length || byCodePoint2(pieces[p].least, pieces[q].least));
|
|
7269
|
+
const runs = /* @__PURE__ */ new Map();
|
|
7270
|
+
for (const p of others) {
|
|
7271
|
+
const inP = new Set(pieces[p].members.map((v) => ids[v]));
|
|
7272
|
+
const pnodes = nodes.filter((x) => inP.has(x.id));
|
|
7273
|
+
const pedges = edges.filter((e) => inP.has(e.source) && inP.has(e.target));
|
|
7274
|
+
const sub = /* @__PURE__ */ new Map();
|
|
7275
|
+
for (const v of pieces[p].members) {
|
|
7276
|
+
if (pinned[v]) {
|
|
7277
|
+
const m = mainRow.get(ids[v]);
|
|
7278
|
+
sub.set(ids[v], [main.points[3 * m], main.points[3 * m + 1], main.points[3 * m + 2]]);
|
|
7279
|
+
} else if (heldAll.has(ids[v])) sub.set(ids[v], heldAll.get(ids[v]));
|
|
7280
|
+
}
|
|
7281
|
+
const ans = layout3d(pnodes, pedges, null, table, runOpts(sub.size ? sub : void 0));
|
|
7282
|
+
runs.set(p, { ans, row: new Map(ans.ids.map((id, i) => [id, i])), moved: sub.size === 0, c: [0, 0, 0], r: 0, T: null });
|
|
7283
|
+
}
|
|
7284
|
+
let cnt = 0, sx = 0, sy = 0, sz = 0;
|
|
7285
|
+
for (let v = 0; v < n; v++) {
|
|
7286
|
+
if (!keep[v]) continue;
|
|
7287
|
+
const m = mainRow.get(ids[v]);
|
|
7288
|
+
sx += main.points[3 * m];
|
|
7289
|
+
sy += main.points[3 * m + 1];
|
|
7290
|
+
sz += main.points[3 * m + 2];
|
|
7291
|
+
cnt++;
|
|
7292
|
+
}
|
|
7293
|
+
const M = cnt ? [sx / cnt, sy / cnt, sz / cnt] : [0, 0, 0];
|
|
7294
|
+
let Rmain = 0;
|
|
7295
|
+
const reach2 = (x, y, z) => {
|
|
7296
|
+
const dx = x - M[0], dy = y - M[1], dz = z - M[2];
|
|
7297
|
+
const d = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
7298
|
+
if (d > Rmain) Rmain = d;
|
|
7299
|
+
};
|
|
7300
|
+
for (let v = 0; v < n; v++) {
|
|
7301
|
+
if (!keep[v]) continue;
|
|
7302
|
+
const m = mainRow.get(ids[v]);
|
|
7303
|
+
reach2(main.points[3 * m], main.points[3 * m + 1], main.points[3 * m + 2]);
|
|
7304
|
+
}
|
|
7305
|
+
for (const p of others) {
|
|
7306
|
+
const u = runs.get(p);
|
|
7307
|
+
if (u.moved) continue;
|
|
7308
|
+
for (const v of pieces[p].members) {
|
|
7309
|
+
if (pinned[v]) continue;
|
|
7310
|
+
const j = u.row.get(ids[v]);
|
|
7311
|
+
reach2(u.ans.points[3 * j], u.ans.points[3 * j + 1], u.ans.points[3 * j + 2]);
|
|
7312
|
+
}
|
|
7313
|
+
}
|
|
7314
|
+
const ringList = others.filter((p) => runs.get(p).moved);
|
|
7315
|
+
for (const p of ringList) {
|
|
7316
|
+
const u = runs.get(p);
|
|
7317
|
+
let qx = 0, qy = 0, qz = 0;
|
|
7318
|
+
for (const v of pieces[p].members) {
|
|
7319
|
+
const i = u.row.get(ids[v]);
|
|
7320
|
+
qx += u.ans.points[3 * i];
|
|
7321
|
+
qy += u.ans.points[3 * i + 1];
|
|
7322
|
+
qz += u.ans.points[3 * i + 2];
|
|
7323
|
+
}
|
|
7324
|
+
const k = pieces[p].members.length;
|
|
7325
|
+
const c = [qx / k, qy / k, qz / k];
|
|
7326
|
+
let r = 0;
|
|
7327
|
+
for (const v of pieces[p].members) {
|
|
7328
|
+
const i = u.row.get(ids[v]);
|
|
7329
|
+
const dx = u.ans.points[3 * i] - c[0], dy = u.ans.points[3 * i + 1] - c[1], dz = u.ans.points[3 * i + 2] - c[2];
|
|
7330
|
+
const d = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
7331
|
+
if (d > r) r = d;
|
|
7332
|
+
}
|
|
7333
|
+
u.c = c;
|
|
7334
|
+
u.r = r;
|
|
7335
|
+
}
|
|
7336
|
+
let rmax = 0;
|
|
7337
|
+
for (const p of ringList) if (runs.get(p).r > rmax) rmax = runs.get(p).r;
|
|
7338
|
+
const rings = [];
|
|
7339
|
+
let R = Rmain + RING_GAP + rmax, on = [], sumT = 0;
|
|
7340
|
+
for (const p of ringList) {
|
|
7341
|
+
const u = runs.get(p);
|
|
7342
|
+
let th = 2 * Math.asin((u.r + RING_GAP / 2) / R);
|
|
7343
|
+
if (on.length && !(sumT + th <= FIT_EDGE)) {
|
|
7344
|
+
rings.push({ R, on, sum: sumT });
|
|
7345
|
+
R = R + 2 * rmax + RING_GAP;
|
|
7346
|
+
on = [];
|
|
7347
|
+
sumT = 0;
|
|
7348
|
+
th = 2 * Math.asin((u.r + RING_GAP / 2) / R);
|
|
7349
|
+
}
|
|
7350
|
+
on.push({ p, th });
|
|
7351
|
+
sumT += th;
|
|
7352
|
+
}
|
|
7353
|
+
if (on.length) rings.push({ R, on, sum: sumT });
|
|
7354
|
+
for (const ring of rings) {
|
|
7355
|
+
const share = (TWO_PI - ring.sum) / ring.on.length;
|
|
7356
|
+
let a = 0;
|
|
7357
|
+
for (const q of ring.on) {
|
|
7358
|
+
const phi = a + q.th / 2;
|
|
7359
|
+
a = a + (q.th + share);
|
|
7360
|
+
const u = runs.get(q.p);
|
|
7361
|
+
u.T = [M[0] + ring.R * Math.cos(phi) - u.c[0], M[1] + ring.R * Math.sin(phi) - u.c[1], M[2] - u.c[2]];
|
|
7362
|
+
}
|
|
7363
|
+
}
|
|
7364
|
+
const outIds = [], pts = [];
|
|
7365
|
+
const how = [], group = [], part = [], held = [];
|
|
7366
|
+
const unplaced = [];
|
|
7367
|
+
for (let i = 0; i < n; i++) {
|
|
7368
|
+
const id = handed[i], v = at.get(id);
|
|
7369
|
+
if (keep[v]) {
|
|
7370
|
+
const m = mainRow.get(id);
|
|
7371
|
+
outIds.push(id);
|
|
7372
|
+
pts.push(main.points[3 * m], main.points[3 * m + 1], main.points[3 * m + 2]);
|
|
7373
|
+
how.push(main.how[m]);
|
|
7374
|
+
group.push(main.group[m]);
|
|
7375
|
+
part.push(main.part[m]);
|
|
7376
|
+
held.push(main.held[m]);
|
|
7377
|
+
const pr = pinned[v] && pieceOf[v] !== mainP ? runs.get(pieceOf[v]) : void 0;
|
|
7378
|
+
if (pr && pr.ans.centres.includes(id)) {
|
|
7379
|
+
group[group.length - 1] = id;
|
|
7380
|
+
part[part.length - 1] = null;
|
|
7381
|
+
}
|
|
7382
|
+
continue;
|
|
7383
|
+
}
|
|
7384
|
+
const p = pieceOf[v];
|
|
7385
|
+
if (pieces[p].members.length < 2) {
|
|
7386
|
+
unplaced.push(v);
|
|
7387
|
+
continue;
|
|
7388
|
+
}
|
|
7389
|
+
const u = runs.get(p);
|
|
7390
|
+
const j = u.row.get(id);
|
|
7391
|
+
let x = u.ans.points[3 * j], y = u.ans.points[3 * j + 1], z = u.ans.points[3 * j + 2];
|
|
7392
|
+
if (u.T) {
|
|
7393
|
+
x = x + u.T[0];
|
|
7394
|
+
y = y + u.T[1];
|
|
7395
|
+
z = z + u.T[2];
|
|
7396
|
+
}
|
|
7397
|
+
outIds.push(id);
|
|
7398
|
+
pts.push(x, y, z);
|
|
7399
|
+
how.push(u.ans.how[j]);
|
|
7400
|
+
group.push(u.ans.group[j]);
|
|
7401
|
+
part.push(u.ans.part[j]);
|
|
7402
|
+
held.push(u.ans.held[j]);
|
|
7403
|
+
}
|
|
7404
|
+
unplaced.sort((a, b) => a - b);
|
|
7405
|
+
const placed = new Set(outIds);
|
|
7406
|
+
const centres2 = main.centres.filter((id) => placed.has(id));
|
|
7407
|
+
for (const p of others) for (const id of runs.get(p).ans.centres) centres2.push(id);
|
|
7408
|
+
return {
|
|
7409
|
+
method: METHOD,
|
|
7410
|
+
ids: outIds,
|
|
7411
|
+
points: Float64Array.from(pts),
|
|
7412
|
+
how,
|
|
7413
|
+
group,
|
|
7414
|
+
part,
|
|
7415
|
+
centres: centres2,
|
|
7416
|
+
held,
|
|
7417
|
+
unplaced: unplaced.map((v) => ids[v])
|
|
7418
|
+
};
|
|
7419
|
+
}
|
|
7420
|
+
|
|
7107
7421
|
// src/layout3d/space.ts
|
|
7108
7422
|
var isRow3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
7109
7423
|
var idOf4 = (v) => typeof v === "string" && v !== "" ? v : null;
|
|
@@ -7133,7 +7447,7 @@ function spaceRows(elements) {
|
|
|
7133
7447
|
|
|
7134
7448
|
// src/layout-by-links-3d.ts
|
|
7135
7449
|
var BY_LINKS_3D_REST = 60;
|
|
7136
|
-
var BY_LINKS_3D_VERSION =
|
|
7450
|
+
var BY_LINKS_3D_VERSION = 2;
|
|
7137
7451
|
var KEYS = ["held", "heldUnit"];
|
|
7138
7452
|
function layoutByLinks3d(graph, elements, options) {
|
|
7139
7453
|
refuseUnknownOptions("layoutByLinks3d", options, KEYS);
|
|
@@ -7141,7 +7455,7 @@ function layoutByLinks3d(graph, elements, options) {
|
|
|
7141
7455
|
throw new TypeError("layoutByLinks3d: the graph is { nodes, edges }, as worldGraph answers it");
|
|
7142
7456
|
}
|
|
7143
7457
|
const rows2 = spaceRows(elements);
|
|
7144
|
-
return
|
|
7458
|
+
return layoutPieces(graph.nodes, graph.edges, rows2, LAYOUT_DIRECTIONS, options ?? {});
|
|
7145
7459
|
}
|
|
7146
7460
|
function unplacedByLinks3d(graph, placed) {
|
|
7147
7461
|
if (!graph || typeof graph !== "object" || !Array.isArray(graph.nodes) || !Array.isArray(graph.edges)) {
|
|
@@ -8552,29 +8866,29 @@ function draughtText(draught) {
|
|
|
8552
8866
|
const moment = (n) => unit === null ? BigInt(n).toString() : `${unit} ${BigInt(n).toString()}`;
|
|
8553
8867
|
const herName = her === null ? "the Character" : text(own3(her, "name")) ?? "(unnamed)";
|
|
8554
8868
|
const out = [];
|
|
8555
|
-
const
|
|
8869
|
+
const put2 = (line, cont = " ") => {
|
|
8556
8870
|
const [first, ...rest] = line.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
|
|
8557
8871
|
out.push(first, ...rest.map((l) => cont + l));
|
|
8558
8872
|
};
|
|
8559
|
-
|
|
8873
|
+
put2(`# ${herName}, in ${text(own3(world, "name")) ?? "(unnamed)"}`);
|
|
8560
8874
|
const asOf = own3(d, "as_of");
|
|
8561
8875
|
const now = own3(d, "now");
|
|
8562
8876
|
const mode = own3(d, "mode");
|
|
8563
8877
|
const public_ = own3(d, "reader") === "public";
|
|
8564
|
-
|
|
8878
|
+
put2(
|
|
8565
8879
|
`What the record holds around ${herName}` + (isInt(asOf) ? `, dated up to ${moment(asOf)}` : "") + (isInt(now) ? ` (the world's now: ${moment(now)})` : "") + "." + (public_ ? " Read as the public reader." : mode === "voice" ? " Read as the Character's own view." : mode === "act" ? " Read as the caller's view." : "")
|
|
8566
8880
|
);
|
|
8567
8881
|
if (asked) {
|
|
8568
8882
|
out.push("");
|
|
8569
|
-
|
|
8883
|
+
put2(`## ${herName}`);
|
|
8570
8884
|
}
|
|
8571
8885
|
if (asked && her === null) {
|
|
8572
8886
|
out.push("Hidden from this reader.");
|
|
8573
8887
|
} else if (her !== null) {
|
|
8574
8888
|
const type = own3(her, "type");
|
|
8575
8889
|
const kind = kindOf(her);
|
|
8576
|
-
|
|
8577
|
-
for (const l of descriptionLines(her))
|
|
8890
|
+
put2(typeWordOf(type) + (kind === null ? "" : ` \xB7 ${kind}`) + marks(her));
|
|
8891
|
+
for (const l of descriptionLines(her)) put2(l);
|
|
8578
8892
|
for (const key3 of Object.keys(her)) {
|
|
8579
8893
|
if (UNPRINTED.has(key3) || UNPRINTED_PREFIXES.some((p) => key3.startsWith(p))) continue;
|
|
8580
8894
|
const v = her[key3];
|
|
@@ -8597,7 +8911,7 @@ function draughtText(draught) {
|
|
|
8597
8911
|
} else {
|
|
8598
8912
|
value = text(v);
|
|
8599
8913
|
}
|
|
8600
|
-
if (value !== null)
|
|
8914
|
+
if (value !== null) put2(` ${key3.replace(/_/g, " ")}: ${value}`, " ");
|
|
8601
8915
|
}
|
|
8602
8916
|
}
|
|
8603
8917
|
const roster = own3(d, "roster");
|
|
@@ -8652,9 +8966,9 @@ function draughtText(draught) {
|
|
|
8652
8966
|
out.push("", `## ${heading}`);
|
|
8653
8967
|
for (const row of rowsOf(key3, v)) {
|
|
8654
8968
|
if (!isObj(row)) continue;
|
|
8655
|
-
if (key3 === "recent")
|
|
8656
|
-
else if (key3 === "roster")
|
|
8657
|
-
else for (const l of elementRow(row))
|
|
8969
|
+
if (key3 === "recent") put2(recentRow(row));
|
|
8970
|
+
else if (key3 === "roster") put2(memberRow(row));
|
|
8971
|
+
else for (const l of elementRow(row)) put2(l);
|
|
8658
8972
|
}
|
|
8659
8973
|
if (key3 === "recent" && recentMore) out.push("More changes than these; read on from recent_cursor.");
|
|
8660
8974
|
}
|
|
@@ -8664,15 +8978,15 @@ function draughtText(draught) {
|
|
|
8664
8978
|
const empty = components.filter((c) => typeof c === "string" && c !== "self" && !sectionSet(c));
|
|
8665
8979
|
if (empty.length) {
|
|
8666
8980
|
out.push("");
|
|
8667
|
-
|
|
8981
|
+
put2(`Nothing in: ${empty.join(", ")}.`);
|
|
8668
8982
|
}
|
|
8669
8983
|
}
|
|
8670
8984
|
const cut2 = own3(d, "cut");
|
|
8671
8985
|
const left = isObj(cut2) ? Object.keys(cut2).filter((k) => isInt(cut2[k])).map((k) => `${BigInt(cut2[k]).toString()} ${k}`) : [];
|
|
8672
8986
|
out.push("");
|
|
8673
|
-
if (isInt(asOf) && mode === "voice")
|
|
8674
|
-
else if (isInt(asOf) && mode === "act")
|
|
8675
|
-
|
|
8987
|
+
if (isInt(asOf) && mode === "voice") put2(`Not listed: rows dated after ${moment(asOf)}.`);
|
|
8988
|
+
else if (isInt(asOf) && mode === "act") put2(`Not listed: Events, Knowledge and proposed Events or Narratives dated after ${moment(asOf)}.`);
|
|
8989
|
+
put2(`Left out by the budget: ${left.length ? left.join(", ") : "nothing"}.`);
|
|
8676
8990
|
return out.join("\n") + "\n";
|
|
8677
8991
|
}
|
|
8678
8992
|
|
|
@@ -9511,6 +9825,7 @@ export {
|
|
|
9511
9825
|
absYearForEraYear,
|
|
9512
9826
|
absoluteYear,
|
|
9513
9827
|
approxYearLength,
|
|
9828
|
+
askerOf,
|
|
9514
9829
|
base64url,
|
|
9515
9830
|
breakdownStep,
|
|
9516
9831
|
buildAskContext,
|
|
@@ -9520,6 +9835,7 @@ export {
|
|
|
9520
9835
|
compareInstants,
|
|
9521
9836
|
dateOf,
|
|
9522
9837
|
degreeOf,
|
|
9838
|
+
designPartsOf,
|
|
9523
9839
|
detectKeyKind,
|
|
9524
9840
|
displayYear,
|
|
9525
9841
|
domainsOf,
|
|
@@ -9558,6 +9874,7 @@ export {
|
|
|
9558
9874
|
isLens,
|
|
9559
9875
|
isMessage,
|
|
9560
9876
|
isNote,
|
|
9877
|
+
isOpenWork,
|
|
9561
9878
|
isParseError,
|
|
9562
9879
|
isRoomElement,
|
|
9563
9880
|
isSentBy,
|
|
@@ -9597,6 +9914,7 @@ export {
|
|
|
9597
9914
|
recordMarkOf,
|
|
9598
9915
|
recordsOf,
|
|
9599
9916
|
renderElement,
|
|
9917
|
+
reportTalksOf,
|
|
9600
9918
|
reportThreadsOf,
|
|
9601
9919
|
resolveCalendar,
|
|
9602
9920
|
resolveCalendarLens,
|
|
@@ -9606,6 +9924,7 @@ export {
|
|
|
9606
9924
|
senderStatus,
|
|
9607
9925
|
simpleCaseFold,
|
|
9608
9926
|
strandOf,
|
|
9927
|
+
talksOf,
|
|
9609
9928
|
threadOf,
|
|
9610
9929
|
trailByPlace,
|
|
9611
9930
|
trimAndFold,
|
|
@@ -9617,6 +9936,8 @@ export {
|
|
|
9617
9936
|
validateCalendarConfig,
|
|
9618
9937
|
viewOf,
|
|
9619
9938
|
weekdayForStep,
|
|
9939
|
+
workOf,
|
|
9940
|
+
workStateOf,
|
|
9620
9941
|
worldCalendars,
|
|
9621
9942
|
worldGraph,
|
|
9622
9943
|
writeWorldFile,
|