@onlyworlds/sdk 4.166.0 → 4.167.1

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 CHANGED
@@ -5,6 +5,19 @@ earlier history lives in git log only.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.167.1] - 2026-11-14
9
+
10
+ ### Fixed
11
+
12
+ - `findOwLinks` and `readOwLinkAt` pass over a moment the parser refuses (more than 11 characters, a leading zero, past the 32-bit range) without the parse it would fail, so a line of addresses each carrying a 60-digit moment reads in about 5 ms where it took about 31 (200 KB), and one of moments with a leading zero in about 14 where it took about 103. `parseOwLink` reads a moment through the same function. No answer changes: 200,000 random texts aimed at moments answer the same as 4.167.0.
13
+
14
+ ## [4.167.0] - 2026-11-14
15
+
16
+ ### Added
17
+
18
+ - `layoutByKind(graph)`: a world nobody laid out, laid out from its graph as `worldGraph` answers it. Each kind gets a point on a circle, links pull, neighbours push apart, for 320 seeded steps (160 past 2,000 elements), and the points are fitted into a frame of -1 to 1 on the longer axis. Answers `{ method: 'by-kind', version: 1, points }`, one `{ id, x, y }` per node in node order (`OwLayoutByKind`). The kinds' points on the circle are a table of numbers baked into the package, never computed, so the same graph gives the same points to the last bit in every browser and in the Python package; the shared fixture `test/fixtures/layout/by-kind.json` (12 cases, 3,013 points) is compared exactly. The graph is first put in one order (nodes by id; links by source, field, index, then target, in code point order), so the order a caller hands the nodes and links in moves no point; the points come back in the caller's node order.
19
+ - `layoutAround(graph, focus, { steps })`: one element at the centre, its neighbours on rings round it in kind order and then by name in code point order (never by locale), up to 60 on the first ring, and with `steps: 2` their own neighbours further out, near the neighbour that reached them. Answers `{ method: 'around', version: 1, points }`, one `{ id, depth, x, y }` per element within the steps, in the caller's node order, after the same one order as `layoutByKind` (`OwLayoutAround`). A focus that is not a node, a `steps` that is not 1 or 2, or an unknown option is refused with a TypeError.
20
+
8
21
  ## [4.166.0] - 2026-11-14
9
22
 
10
23
  schema-dist v0.34.1-dist.128 (canonical 00.34.01 unchanged; `ONLYWORLDS_VERSION` unchanged, no schema file moved). The fixtures' new cases pass: the lens fixture's 235, the message fixture's 102 (its two `recipients` cases), the address fixture's two `prose-all` cases, the landing fixture's 33.
@@ -1255,6 +1255,11 @@ var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
1255
1255
  var STEP = /^(?:0|-?[1-9][0-9]*)$/;
1256
1256
  var STEP_MIN = -2147483648;
1257
1257
  var STEP_MAX = 2147483647;
1258
+ function readStep(step) {
1259
+ if (step.length > 11 || !STEP.test(step)) return null;
1260
+ const m = Number(step);
1261
+ return m < STEP_MIN || m > STEP_MAX ? null : m;
1262
+ }
1258
1263
  var ADDRESS_KEYS = ["form", "world", "type", "id", "lens", "moment", "worldIsSlug", "canonical"];
1259
1264
  var asciiLower = (s) => s.replace(/[A-Z]/g, (c) => String.fromCharCode(c.charCodeAt(0) + 32));
1260
1265
  var isUuid = (s) => UUID.test(s);
@@ -1379,10 +1384,8 @@ function parseOwLink(text) {
1379
1384
  }
1380
1385
  let moment = null;
1381
1386
  if (step !== null) {
1382
- if (!STEP.test(step) || step.length > 11) return refuse("bad_moment");
1383
- const m = Number(step);
1384
- if (m < STEP_MIN || m > STEP_MAX) return refuse("bad_moment");
1385
- moment = m;
1387
+ moment = readStep(step);
1388
+ if (moment === null) return refuse("bad_moment");
1386
1389
  }
1387
1390
  const lens = query === null ? null : readLens(query);
1388
1391
  const canonical = !worldIsSlug && text === write(form, world, type, id, moment, lens);
@@ -1401,7 +1404,7 @@ function codePointStart(text, i) {
1401
1404
  }
1402
1405
  return i;
1403
1406
  }
1404
- var STEP_RUN = /^-?[0-9]+/;
1407
+ var STEP_RUN = /-?[0-9]+/y;
1405
1408
  var ID_LENGTH = 36;
1406
1409
  function parses(s) {
1407
1410
  try {
@@ -1443,8 +1446,9 @@ function readOwLinkAt(text, index = 0) {
1443
1446
  }
1444
1447
  if (end === -1) return null;
1445
1448
  if (text[end] === "@") {
1446
- const step = STEP_RUN.exec(text.slice(end + 1));
1447
- if (step !== null && parses(text.slice(index, end + 1 + step[0].length))) end += 1 + step[0].length;
1449
+ STEP_RUN.lastIndex = end + 1;
1450
+ const step = STEP_RUN.exec(text);
1451
+ if (step !== null && readStep(step[0]) !== null && parses(text.slice(index, end + 1 + step[0].length))) end += 1 + step[0].length;
1448
1452
  }
1449
1453
  if (text.startsWith("?lens=", end)) {
1450
1454
  const lensEnd = end + 6 + ID_LENGTH;
package/dist/index.d.ts CHANGED
@@ -6513,6 +6513,88 @@ declare function roundHalfEven(v: number): number;
6513
6513
  */
6514
6514
  declare function trailByPlace(input: OwTrailInput): OwTrailLayout;
6515
6515
 
6516
+ /** A graph to lay out: `worldGraph`'s answer, or any graph of the same shape. */
6517
+ interface OwLayoutGraph {
6518
+ /** The elements, each with its id, its type as a slug (`character`) and, for `layoutAround`, its name. */
6519
+ nodes: ReadonlyArray<{
6520
+ id: string;
6521
+ type: string;
6522
+ name?: string | null;
6523
+ }>;
6524
+ /**
6525
+ * The links, each from `source` to `target` by id, with the link field's name and the place in it as `worldGraph`
6526
+ * gives them. A link to an id that is not a node is passed over.
6527
+ */
6528
+ edges: ReadonlyArray<{
6529
+ source: string;
6530
+ target: string;
6531
+ field?: string;
6532
+ index?: number;
6533
+ }>;
6534
+ }
6535
+ /** One element's point, in a frame of -1 to 1 on the picture's longer axis, centred. */
6536
+ interface OwLayoutPoint {
6537
+ id: string;
6538
+ x: number;
6539
+ y: number;
6540
+ }
6541
+ /** What `layoutByKind` answers: one point per node, in the graph's node order, and the method that made them. */
6542
+ interface OwLayoutByKind {
6543
+ method: 'by-kind';
6544
+ version: 1;
6545
+ points: OwLayoutPoint[];
6546
+ }
6547
+ /** One element's point round the focus: the focus at 0, 0, and how many links away from it the element is. */
6548
+ interface OwLayoutAroundPoint {
6549
+ id: string;
6550
+ /** 0 for the focus, 1 for its neighbours, 2 for theirs. */
6551
+ depth: number;
6552
+ x: number;
6553
+ y: number;
6554
+ }
6555
+ /** What `layoutAround` answers: the focus and every element within the steps, in the graph's node order. */
6556
+ interface OwLayoutAround {
6557
+ method: 'around';
6558
+ version: 1;
6559
+ points: OwLayoutAroundPoint[];
6560
+ }
6561
+ /** `layoutAround`'s options. */
6562
+ interface OwLayoutAroundOptions {
6563
+ /** How many links out from the focus: 1 (the default) or 2. */
6564
+ steps?: 1 | 2;
6565
+ }
6566
+ /**
6567
+ * Lay out a whole graph by kind. Each kind present gets an anchor on a circle, in colour group order (`GROUP_ORDER`)
6568
+ * and then by type word; every element starts near its kind's anchor, at a seeded jitter. Then, for 320 steps (160
6569
+ * past 2,000 elements): elements closer than a few rest lengths push each other apart (a cell holding more than 12
6570
+ * pushes with a rotating sample of 12, scaled up), every link pulls its two ends towards a rest length, every element
6571
+ * is drawn back towards its kind's anchor, and no element moves further in one step than a cap that shrinks as the
6572
+ * steps run out. Last, the points are fitted into a frame of -1 to 1 on the longer axis, centred, proportions kept.
6573
+ *
6574
+ * The graph is first put in one order (nodes by id; links by source, field, index, then target), so the order the
6575
+ * nodes and links are handed in moves nothing. Answers one point per node in the order the nodes were handed in, with
6576
+ * the method's name and version (`by-kind`, 1), so a saved layout can say what made it. An empty graph answers no points; a graph of one element answers 0, 0.
6577
+ * The same graph gives the same points to the last bit in every browser and language: the anchors are a baked
6578
+ * table of numbers, never computed, and the rest is arithmetic every runtime rounds alike. Self-links pull nothing;
6579
+ * a link to an id that is not a node is passed over. Throws a TypeError, naming what, on a graph it cannot read:
6580
+ * no nodes or edges list, a node with no id, a type that is not one of the 22, an id twice.
6581
+ */
6582
+ declare function layoutByKind(graph: OwLayoutGraph): OwLayoutByKind;
6583
+ /**
6584
+ * Lay out one element and what is linked to it. The focus stands at 0, 0. Its neighbours (one link away, either
6585
+ * direction) stand on a ring round it, in colour group order, then by type word, then by name (code point order, the
6586
+ * same in every language and locale), up to 60 on the first ring and further rings beyond it. With `steps: 2`, each
6587
+ * neighbour's own neighbours stand on an outer ring, fanned out near the neighbour that reached them.
6588
+ *
6589
+ * The graph is first put in one order, as `layoutByKind` puts it, so the order the nodes and links are handed in
6590
+ * moves nothing. Answers the focus and every element within the steps, in the order the nodes were handed in, each
6591
+ * with its depth (0, 1 or 2), and the method's name and version (`around`, 1). Nothing iterates, so each point is one cosine and one sine of an
6592
+ * angle the method computes exactly; runtimes agree to within about 1e-12. Throws a TypeError on an unknown option
6593
+ * (before anything else), a `steps` that is not 1 or 2, a graph it cannot read (as `layoutByKind`), or a focus that
6594
+ * is not one of the graph's nodes.
6595
+ */
6596
+ declare function layoutAround(graph: OwLayoutGraph, focus: string, options?: OwLayoutAroundOptions): OwLayoutAround;
6597
+
6516
6598
  /** One word pair of a names map: `one` for a single thing, `many` for a plural (absent: `one`). */
6517
6599
  interface OwWordPair {
6518
6600
  one: string;
@@ -7978,4 +8060,4 @@ declare class TokenResource {
7978
8060
  getEncryptionInfo(): Promise<EncryptionInfo>;
7979
8061
  }
7980
8062
 
7981
- export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, CHARTER_PAIRS, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, DATE_FIELD, ELEMENT_FAMILIES, ELEMENT_GROUPS, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementGroup, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GROUP_COLORS, GROUP_ORDER, GameTier, type ListParams, MESSAGE_PAIR, NOTE_PAIR, ONLYWORLDS_VERSION, type OwAccountToken, type OwAccountWorld, type OwAddress, type OwAddressAt, OwAddressError, type OwAddressForm, type OwAddressFound, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAiAskAnswer, type OwAiAskBody, type OwAiMeter, type OwAiRefusal, type OwAiSortAnswer, type OwAiSortBody, type OwAiToken, type OwAiUse, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwCharterWorld, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDoor, type OwDragField, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwElementMark, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwGraphCutReason, type OwGraphEdge, type OwGraphMark, type OwGraphNode, type OwGraphOptions, type OwHiddenRow, type OwInstant, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLanding, type OwLandingCluster, type OwLandingGap, type OwLandingGapKind, type OwLandingMember, type OwLandingMode, type OwLandingOptions, type OwLayoutOf, type OwLensCutReason, type OwLensMail, type OwLensOptions, type OwLensReader, type OwLensReading, type OwLensWorld, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMapSpace, type OwMapSpaceMap, type OwMapSpaceOutReason, type OwMapSpaceOutline, type OwMapSpacePin, type OwMapSpacePoint, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedAiToken, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwOpenersOptions, type OwPage, type OwPaidBy, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwReadingAids, type OwReadingAidsCharter, type OwReadingAidsDomain, type OwReadingAidsGuide, type OwReadingAidsHub, type OwRecord, type OwRecordMark, type OwRecordStory, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwReportGroup, type OwReportLint, type OwReportParentKind, type OwReportThreads, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSearchResult, type OwSearchResults, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwServedReadingAids, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwStrand, type OwStrandSlot, type OwStrandWorld, type OwTool, type OwToolNeeds, type OwToolOpen, type OwTrailGround, type OwTrailHanger, type OwTrailInput, type OwTrailLayout, type OwTrailPin, type OwTrailPlace, type OwTrailSettings, type OwTrailSpiral, type OwTrailTier, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwView, type OwViewRow, type OwViewsTable, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldKeyMember, type OwWorldKeyRow, type OwWorldLens, type OwWorldLensReading, type OwWorldLenses, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, RECORD_FIELD, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, STRAND_FIELD, type SectionInfo, type StepBreakdown, TOOLS, TRAIL_TIERS, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, VIEWS, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, charterOf, compareInstants, dateOf, degreeOf, detectKeyKind, displayYear, domainsOf, doorWhere, doorsOf, dragField, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, findOwLinks, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, groupOf, handsOnAsProposed, hasUnseenRecipients, instantOf, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, landingOf, layoutOf, lensesInUse, lookupWorld, mapSpace, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readOwLinkAt, readWorldFile, readingAidOf, recipientsOf, recordMarkOf, recordsOf, renderElement, reportThreadsOf, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, roundHalfEven, senderStatus, simpleCaseFold, strandOf, threadOf, trailByPlace, typeWord, unreadFor, validateCalendarConfig, viewOf, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
8063
+ export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, CHARTER_PAIRS, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, DATE_FIELD, ELEMENT_FAMILIES, ELEMENT_GROUPS, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementGroup, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GROUP_COLORS, GROUP_ORDER, GameTier, type ListParams, MESSAGE_PAIR, NOTE_PAIR, ONLYWORLDS_VERSION, type OwAccountToken, type OwAccountWorld, type OwAddress, type OwAddressAt, OwAddressError, type OwAddressForm, type OwAddressFound, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAiAskAnswer, type OwAiAskBody, type OwAiMeter, type OwAiRefusal, type OwAiSortAnswer, type OwAiSortBody, type OwAiToken, type OwAiUse, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwCharterWorld, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDoor, type OwDragField, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwElementMark, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwGraphCutReason, type OwGraphEdge, type OwGraphMark, type OwGraphNode, type OwGraphOptions, type OwHiddenRow, type OwInstant, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLanding, type OwLandingCluster, type OwLandingGap, type OwLandingGapKind, type OwLandingMember, type OwLandingMode, type OwLandingOptions, type OwLayoutAround, type OwLayoutAroundOptions, type OwLayoutAroundPoint, type OwLayoutByKind, type OwLayoutGraph, type OwLayoutOf, type OwLayoutPoint, type OwLensCutReason, type OwLensMail, type OwLensOptions, type OwLensReader, type OwLensReading, type OwLensWorld, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMapSpace, type OwMapSpaceMap, type OwMapSpaceOutReason, type OwMapSpaceOutline, type OwMapSpacePin, type OwMapSpacePoint, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedAiToken, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwOpenersOptions, type OwPage, type OwPaidBy, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwReadingAids, type OwReadingAidsCharter, type OwReadingAidsDomain, type OwReadingAidsGuide, type OwReadingAidsHub, type OwRecord, type OwRecordMark, type OwRecordStory, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwReportGroup, type OwReportLint, type OwReportParentKind, type OwReportThreads, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSearchResult, type OwSearchResults, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwServedReadingAids, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwStrand, type OwStrandSlot, type OwStrandWorld, type OwTool, type OwToolNeeds, type OwToolOpen, type OwTrailGround, type OwTrailHanger, type OwTrailInput, type OwTrailLayout, type OwTrailPin, type OwTrailPlace, type OwTrailSettings, type OwTrailSpiral, type OwTrailTier, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwView, type OwViewRow, type OwViewsTable, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldKeyMember, type OwWorldKeyRow, type OwWorldLens, type OwWorldLensReading, type OwWorldLenses, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, RECORD_FIELD, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, STRAND_FIELD, type SectionInfo, type StepBreakdown, TOOLS, TRAIL_TIERS, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, VIEWS, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, charterOf, compareInstants, dateOf, degreeOf, detectKeyKind, displayYear, domainsOf, doorWhere, doorsOf, dragField, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, findOwLinks, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, groupOf, handsOnAsProposed, hasUnseenRecipients, instantOf, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, landingOf, layoutAround, layoutByKind, layoutOf, lensesInUse, lookupWorld, mapSpace, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readOwLinkAt, readWorldFile, readingAidOf, recipientsOf, recordMarkOf, recordsOf, renderElement, reportThreadsOf, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, roundHalfEven, senderStatus, simpleCaseFold, strandOf, threadOf, trailByPlace, typeWord, unreadFor, validateCalendarConfig, viewOf, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ import {
47
47
  trimWhiteSpace,
48
48
  typeWord,
49
49
  unknownKey
50
- } from "./chunk-EWHZMOUF.js";
50
+ } from "./chunk-LHFKNEC4.js";
51
51
 
52
52
  // src/v2/keyed-id.ts
53
53
  var KEYED_IDS = "0199b6a0-6f0e-7c2a-9d1e-3b5c7a8e4f21";
@@ -4570,6 +4570,767 @@ function trailByPlace(input) {
4570
4570
  };
4571
4571
  }
4572
4572
 
4573
+ // src/layout-anchors.generated.ts
4574
+ var LAYOUT_ANCHORS = [
4575
+ 6123233995736766e-32,
4576
+ -1,
4577
+ 6123233995736766e-32,
4578
+ -1,
4579
+ 6123233995736766e-32,
4580
+ 1,
4581
+ 6123233995736766e-32,
4582
+ -1,
4583
+ 0.8660254037844387,
4584
+ 0.49999999999999983,
4585
+ -0.8660254037844385,
4586
+ 0.5000000000000003,
4587
+ 6123233995736766e-32,
4588
+ -1,
4589
+ 1,
4590
+ 0,
4591
+ 6123233995736766e-32,
4592
+ 1,
4593
+ -1,
4594
+ 12246467991473532e-32,
4595
+ 6123233995736766e-32,
4596
+ -1,
4597
+ 0.9510565162951535,
4598
+ -0.3090169943749474,
4599
+ 0.5877852522924731,
4600
+ 0.8090169943749475,
4601
+ -0.587785252292473,
4602
+ 0.8090169943749475,
4603
+ -0.9510565162951536,
4604
+ -0.3090169943749473,
4605
+ 6123233995736766e-32,
4606
+ -1,
4607
+ 0.8660254037844386,
4608
+ -0.5,
4609
+ 0.8660254037844387,
4610
+ 0.49999999999999983,
4611
+ 6123233995736766e-32,
4612
+ 1,
4613
+ -0.8660254037844385,
4614
+ 0.5000000000000003,
4615
+ -0.8660254037844386,
4616
+ -0.5000000000000001,
4617
+ 6123233995736766e-32,
4618
+ -1,
4619
+ 0.7818314824680298,
4620
+ -0.6234898018587335,
4621
+ 0.9749279121818236,
4622
+ 0.2225209339563144,
4623
+ 0.4338837391175582,
4624
+ 0.9009688679024191,
4625
+ -0.43388373911755806,
4626
+ 0.9009688679024191,
4627
+ -0.9749279121818236,
4628
+ 0.2225209339563145,
4629
+ -0.7818314824680299,
4630
+ -0.6234898018587334,
4631
+ 6123233995736766e-32,
4632
+ -1,
4633
+ 0.7071067811865476,
4634
+ -0.7071067811865475,
4635
+ 1,
4636
+ 0,
4637
+ 0.7071067811865476,
4638
+ 0.7071067811865475,
4639
+ 6123233995736766e-32,
4640
+ 1,
4641
+ -0.7071067811865475,
4642
+ 0.7071067811865476,
4643
+ -1,
4644
+ 12246467991473532e-32,
4645
+ -0.7071067811865477,
4646
+ -0.7071067811865475,
4647
+ 6123233995736766e-32,
4648
+ -1,
4649
+ 0.6427876096865394,
4650
+ -0.766044443118978,
4651
+ 0.984807753012208,
4652
+ -0.17364817766693036,
4653
+ 0.8660254037844387,
4654
+ 0.49999999999999983,
4655
+ 0.3420201433256688,
4656
+ 0.9396926207859083,
4657
+ -0.3420201433256687,
4658
+ 0.9396926207859084,
4659
+ -0.8660254037844385,
4660
+ 0.5000000000000003,
4661
+ -0.9848077530122081,
4662
+ -0.17364817766693003,
4663
+ -0.6427876096865395,
4664
+ -0.7660444431189779,
4665
+ 6123233995736766e-32,
4666
+ -1,
4667
+ 0.5877852522924731,
4668
+ -0.8090169943749475,
4669
+ 0.9510565162951535,
4670
+ -0.3090169943749474,
4671
+ 0.9510565162951535,
4672
+ 0.3090169943749474,
4673
+ 0.5877852522924731,
4674
+ 0.8090169943749475,
4675
+ 6123233995736766e-32,
4676
+ 1,
4677
+ -0.587785252292473,
4678
+ 0.8090169943749475,
4679
+ -0.9510565162951535,
4680
+ 0.3090169943749475,
4681
+ -0.9510565162951536,
4682
+ -0.3090169943749473,
4683
+ -0.5877852522924732,
4684
+ -0.8090169943749473,
4685
+ 6123233995736766e-32,
4686
+ -1,
4687
+ 0.5406408174555977,
4688
+ -0.8412535328311811,
4689
+ 0.9096319953545184,
4690
+ -0.4154150130018864,
4691
+ 0.9898214418809328,
4692
+ 0.14231483827328506,
4693
+ 0.7557495743542583,
4694
+ 0.6548607339452851,
4695
+ 0.2817325568414296,
4696
+ 0.9594929736144975,
4697
+ -0.28173255684142945,
4698
+ 0.9594929736144975,
4699
+ -0.7557495743542582,
4700
+ 0.6548607339452852,
4701
+ -0.9898214418809327,
4702
+ 0.14231483827328517,
4703
+ -0.9096319953545186,
4704
+ -0.4154150130018861,
4705
+ -0.5406408174555974,
4706
+ -0.8412535328311813,
4707
+ 6123233995736766e-32,
4708
+ -1,
4709
+ 0.4999999999999999,
4710
+ -0.8660254037844387,
4711
+ 0.8660254037844386,
4712
+ -0.5,
4713
+ 1,
4714
+ 0,
4715
+ 0.8660254037844387,
4716
+ 0.49999999999999983,
4717
+ 0.4999999999999999,
4718
+ 0.8660254037844387,
4719
+ 6123233995736766e-32,
4720
+ 1,
4721
+ -0.4999999999999998,
4722
+ 0.8660254037844387,
4723
+ -0.8660254037844385,
4724
+ 0.5000000000000003,
4725
+ -1,
4726
+ 12246467991473532e-32,
4727
+ -0.8660254037844386,
4728
+ -0.5000000000000001,
4729
+ -0.5000000000000004,
4730
+ -0.8660254037844385,
4731
+ 6123233995736766e-32,
4732
+ -1,
4733
+ 0.4647231720437686,
4734
+ -0.8854560256532099,
4735
+ 0.8229838658936564,
4736
+ -0.5680647467311558,
4737
+ 0.992708874098054,
4738
+ -0.12053668025532295,
4739
+ 0.9350162426854148,
4740
+ 0.3546048870425355,
4741
+ 0.6631226582407951,
4742
+ 0.7485107481711012,
4743
+ 0.23931566428755763,
4744
+ 0.970941817426052,
4745
+ -0.2393156642875575,
4746
+ 0.9709418174260521,
4747
+ -0.663122658240795,
4748
+ 0.7485107481711013,
4749
+ -0.9350162426854147,
4750
+ 0.35460488704253584,
4751
+ -0.992708874098054,
4752
+ -0.12053668025532327,
4753
+ -0.822983865893657,
4754
+ -0.5680647467311549,
4755
+ -0.46472317204376834,
4756
+ -0.88545602565321,
4757
+ 6123233995736766e-32,
4758
+ -1,
4759
+ 0.4338837391175582,
4760
+ -0.9009688679024191,
4761
+ 0.7818314824680298,
4762
+ -0.6234898018587335,
4763
+ 0.9749279121818236,
4764
+ -0.2225209339563144,
4765
+ 0.9749279121818236,
4766
+ 0.2225209339563144,
4767
+ 0.7818314824680298,
4768
+ 0.6234898018587335,
4769
+ 0.4338837391175582,
4770
+ 0.9009688679024191,
4771
+ 6123233995736766e-32,
4772
+ 1,
4773
+ -0.43388373911755806,
4774
+ 0.9009688679024191,
4775
+ -0.7818314824680297,
4776
+ 0.6234898018587336,
4777
+ -0.9749279121818236,
4778
+ 0.2225209339563145,
4779
+ -0.9749279121818238,
4780
+ -0.22252093395631342,
4781
+ -0.7818314824680299,
4782
+ -0.6234898018587334,
4783
+ -0.43388373911755745,
4784
+ -0.9009688679024195,
4785
+ 6123233995736766e-32,
4786
+ -1,
4787
+ 0.4067366430758002,
4788
+ -0.9135454576426009,
4789
+ 0.7431448254773942,
4790
+ -0.6691306063588582,
4791
+ 0.9510565162951535,
4792
+ -0.3090169943749474,
4793
+ 0.9945218953682733,
4794
+ 0.10452846326765339,
4795
+ 0.8660254037844387,
4796
+ 0.49999999999999983,
4797
+ 0.5877852522924731,
4798
+ 0.8090169943749475,
4799
+ 0.20791169081775923,
4800
+ 0.9781476007338057,
4801
+ -0.20791169081775912,
4802
+ 0.9781476007338057,
4803
+ -0.587785252292473,
4804
+ 0.8090169943749475,
4805
+ -0.8660254037844385,
4806
+ 0.5000000000000003,
4807
+ -0.9945218953682733,
4808
+ 0.10452846326765418,
4809
+ -0.9510565162951536,
4810
+ -0.3090169943749473,
4811
+ -0.7431448254773939,
4812
+ -0.6691306063588586,
4813
+ -0.4067366430758001,
4814
+ -0.913545457642601,
4815
+ 6123233995736766e-32,
4816
+ -1,
4817
+ 0.38268343236508984,
4818
+ -0.9238795325112867,
4819
+ 0.7071067811865476,
4820
+ -0.7071067811865475,
4821
+ 0.9238795325112867,
4822
+ -0.3826834323650898,
4823
+ 1,
4824
+ 0,
4825
+ 0.9238795325112867,
4826
+ 0.3826834323650898,
4827
+ 0.7071067811865476,
4828
+ 0.7071067811865475,
4829
+ 0.38268343236508984,
4830
+ 0.9238795325112867,
4831
+ 6123233995736766e-32,
4832
+ 1,
4833
+ -0.3826834323650897,
4834
+ 0.9238795325112867,
4835
+ -0.7071067811865475,
4836
+ 0.7071067811865476,
4837
+ -0.9238795325112865,
4838
+ 0.3826834323650903,
4839
+ -1,
4840
+ 12246467991473532e-32,
4841
+ -0.9238795325112866,
4842
+ -0.38268343236509006,
4843
+ -0.7071067811865477,
4844
+ -0.7071067811865475,
4845
+ -0.38268343236509034,
4846
+ -0.9238795325112865,
4847
+ 6123233995736766e-32,
4848
+ -1,
4849
+ 0.36124166618715303,
4850
+ -0.9324722294043558,
4851
+ 0.6736956436465572,
4852
+ -0.7390089172206591,
4853
+ 0.8951632913550623,
4854
+ -0.44573835577653825,
4855
+ 0.9957341762950346,
4856
+ -0.09226835946330195,
4857
+ 0.961825643172819,
4858
+ 0.27366299007208295,
4859
+ 0.7980172272802395,
4860
+ 0.6026346363792563,
4861
+ 0.5264321628773561,
4862
+ 0.850217135729614,
4863
+ 0.1837495178165703,
4864
+ 0.9829730996839018,
4865
+ -0.1837495178165702,
4866
+ 0.9829730996839018,
4867
+ -0.526432162877356,
4868
+ 0.8502171357296141,
4869
+ -0.7980172272802389,
4870
+ 0.6026346363792572,
4871
+ -0.961825643172819,
4872
+ 0.27366299007208306,
4873
+ -0.9957341762950345,
4874
+ -0.09226835946330249,
4875
+ -0.8951632913550626,
4876
+ -0.44573835577653775,
4877
+ -0.6736956436465578,
4878
+ -0.7390089172206586,
4879
+ -0.361241666187153,
4880
+ -0.9324722294043558,
4881
+ 6123233995736766e-32,
4882
+ -1,
4883
+ 0.3420201433256688,
4884
+ -0.9396926207859083,
4885
+ 0.6427876096865394,
4886
+ -0.766044443118978,
4887
+ 0.8660254037844386,
4888
+ -0.5,
4889
+ 0.984807753012208,
4890
+ -0.17364817766693036,
4891
+ 0.984807753012208,
4892
+ 0.17364817766693036,
4893
+ 0.8660254037844387,
4894
+ 0.49999999999999983,
4895
+ 0.6427876096865395,
4896
+ 0.7660444431189779,
4897
+ 0.3420201433256688,
4898
+ 0.9396926207859083,
4899
+ 6123233995736766e-32,
4900
+ 1,
4901
+ -0.3420201433256687,
4902
+ 0.9396926207859084,
4903
+ -0.642787609686539,
4904
+ 0.7660444431189783,
4905
+ -0.8660254037844385,
4906
+ 0.5000000000000003,
4907
+ -0.984807753012208,
4908
+ 0.17364817766693028,
4909
+ -0.9848077530122081,
4910
+ -0.17364817766693003,
4911
+ -0.866025403784439,
4912
+ -0.4999999999999994,
4913
+ -0.6427876096865395,
4914
+ -0.7660444431189779,
4915
+ -0.34202014332566855,
4916
+ -0.9396926207859084,
4917
+ 6123233995736766e-32,
4918
+ -1,
4919
+ 0.32469946920468357,
4920
+ -0.9458172417006346,
4921
+ 0.6142127126896678,
4922
+ -0.7891405093963936,
4923
+ 0.8371664782625285,
4924
+ -0.5469481581224268,
4925
+ 0.9694002659393304,
4926
+ -0.24548548714079918,
4927
+ 0.9965844930066698,
4928
+ 0.08257934547233234,
4929
+ 0.9157733266550574,
4930
+ 0.4016954246529695,
4931
+ 0.7357239106731317,
4932
+ 0.677281571625741,
4933
+ 0.4759473930370736,
4934
+ 0.879473751206489,
4935
+ 0.16459459028073398,
4936
+ 0.9863613034027223,
4937
+ -0.16459459028073384,
4938
+ 0.9863613034027224,
4939
+ -0.4759473930370731,
4940
+ 0.8794737512064893,
4941
+ -0.7357239106731316,
4942
+ 0.677281571625741,
4943
+ -0.9157733266550576,
4944
+ 0.401695424652969,
4945
+ -0.9965844930066698,
4946
+ 0.08257934547233267,
4947
+ -0.9694002659393305,
4948
+ -0.24548548714079885,
4949
+ -0.8371664782625288,
4950
+ -0.5469481581224266,
4951
+ -0.6142127126896673,
4952
+ -0.789140509396394,
4953
+ -0.3246994692046837,
4954
+ -0.9458172417006346,
4955
+ 6123233995736766e-32,
4956
+ -1,
4957
+ 0.30901699437494745,
4958
+ -0.9510565162951535,
4959
+ 0.5877852522924731,
4960
+ -0.8090169943749475,
4961
+ 0.8090169943749475,
4962
+ -0.5877852522924731,
4963
+ 0.9510565162951535,
4964
+ -0.3090169943749474,
4965
+ 1,
4966
+ 0,
4967
+ 0.9510565162951535,
4968
+ 0.3090169943749474,
4969
+ 0.8090169943749475,
4970
+ 0.5877852522924731,
4971
+ 0.5877852522924731,
4972
+ 0.8090169943749475,
4973
+ 0.30901699437494745,
4974
+ 0.9510565162951535,
4975
+ 6123233995736766e-32,
4976
+ 1,
4977
+ -0.30901699437494695,
4978
+ 0.9510565162951538,
4979
+ -0.587785252292473,
4980
+ 0.8090169943749475,
4981
+ -0.8090169943749473,
4982
+ 0.5877852522924732,
4983
+ -0.9510565162951535,
4984
+ 0.3090169943749475,
4985
+ -1,
4986
+ 12246467991473532e-32,
4987
+ -0.9510565162951536,
4988
+ -0.3090169943749473,
4989
+ -0.8090169943749475,
4990
+ -0.587785252292473,
4991
+ -0.5877852522924732,
4992
+ -0.8090169943749473,
4993
+ -0.30901699437494756,
4994
+ -0.9510565162951535,
4995
+ 6123233995736766e-32,
4996
+ -1,
4997
+ 0.2947551744109043,
4998
+ -0.9555728057861407,
4999
+ 0.5633200580636221,
5000
+ -0.8262387743159948,
5001
+ 0.7818314824680298,
5002
+ -0.6234898018587335,
5003
+ 0.9308737486442042,
5004
+ -0.36534102436639493,
5005
+ 0.9972037971811801,
5006
+ -0.07473009358642432,
5007
+ 0.9749279121818236,
5008
+ 0.2225209339563144,
5009
+ 0.8660254037844387,
5010
+ 0.49999999999999983,
5011
+ 0.6801727377709192,
5012
+ 0.7330518718298265,
5013
+ 0.4338837391175582,
5014
+ 0.9009688679024191,
5015
+ 0.14904226617617464,
5016
+ 0.9888308262251285,
5017
+ -0.14904226617617408,
5018
+ 0.9888308262251286,
5019
+ -0.43388373911755806,
5020
+ 0.9009688679024191,
5021
+ -0.6801727377709196,
5022
+ 0.7330518718298262,
5023
+ -0.8660254037844385,
5024
+ 0.5000000000000003,
5025
+ -0.9749279121818236,
5026
+ 0.2225209339563145,
5027
+ -0.9972037971811801,
5028
+ -0.07473009358642442,
5029
+ -0.9308737486442041,
5030
+ -0.36534102436639543,
5031
+ -0.7818314824680299,
5032
+ -0.6234898018587334,
5033
+ -0.5633200580636226,
5034
+ -0.8262387743159945,
5035
+ -0.29475517441090465,
5036
+ -0.9555728057861406,
5037
+ 6123233995736766e-32,
5038
+ -1,
5039
+ 0.2817325568414298,
5040
+ -0.9594929736144974,
5041
+ 0.5406408174555977,
5042
+ -0.8412535328311811,
5043
+ 0.7557495743542583,
5044
+ -0.6548607339452851,
5045
+ 0.9096319953545184,
5046
+ -0.4154150130018864,
5047
+ 0.9898214418809328,
5048
+ -0.14231483827328506,
5049
+ 0.9898214418809328,
5050
+ 0.14231483827328506,
5051
+ 0.9096319953545184,
5052
+ 0.4154150130018864,
5053
+ 0.7557495743542583,
5054
+ 0.6548607339452851,
5055
+ 0.5406408174555977,
5056
+ 0.8412535328311811,
5057
+ 0.2817325568414296,
5058
+ 0.9594929736144975,
5059
+ 5053215498074303e-31,
5060
+ 1,
5061
+ -0.28173255684142945,
5062
+ 0.9594929736144975,
5063
+ -0.5406408174555977,
5064
+ 0.8412535328311811,
5065
+ -0.7557495743542582,
5066
+ 0.6548607339452852,
5067
+ -0.9096319953545181,
5068
+ 0.4154150130018871,
5069
+ -0.9898214418809327,
5070
+ 0.14231483827328517,
5071
+ -0.9898214418809328,
5072
+ -0.14231483827328492,
5073
+ -0.9096319953545186,
5074
+ -0.4154150130018861,
5075
+ -0.7557495743542587,
5076
+ -0.6548607339452847,
5077
+ -0.5406408174555974,
5078
+ -0.8412535328311813,
5079
+ -0.2817325568414297,
5080
+ -0.9594929736144974
5081
+ ];
5082
+
5083
+ // src/layout-by-kind.ts
5084
+ var STEPS = 320;
5085
+ var CELL_MAX = 12;
5086
+ var RING_ONE = 60;
5087
+ var cellKey = (x, y) => (x + 1048576) * 2097152 + (y + 1048576);
5088
+ function rng(seed) {
5089
+ let s = seed >>> 0;
5090
+ return () => (s = s * 1664525 + 1013904223 >>> 0) / 4294967296;
5091
+ }
5092
+ var groupRank = (type) => GROUP_ORDER.indexOf(ELEMENT_GROUPS[type]);
5093
+ function readGraph(fn, graph) {
5094
+ const fail2 = (msg) => {
5095
+ throw new TypeError(`${fn}: ${msg}`);
5096
+ };
5097
+ if (!graph || typeof graph !== "object" || !Array.isArray(graph.nodes) || !Array.isArray(graph.edges)) {
5098
+ fail2("the graph is { nodes, edges }, as worldGraph answers it");
5099
+ }
5100
+ const seen = /* @__PURE__ */ new Set();
5101
+ graph.nodes.forEach((node, i) => {
5102
+ if (!node || typeof node !== "object") fail2(`node ${i} is not an object`);
5103
+ if (typeof node.id !== "string" || !node.id) fail2(`node ${i} has no id`);
5104
+ if (typeof node.type !== "string" || !Object.prototype.hasOwnProperty.call(ELEMENT_GROUPS, node.type)) {
5105
+ fail2(`node ${node.id}: '${String(node.type)}' is not one of the 22 element types`);
5106
+ }
5107
+ if (node.name !== void 0 && node.name !== null && typeof node.name !== "string") fail2(`node ${node.id}: name is a string or null`);
5108
+ if (seen.has(node.id)) fail2(`the id ${node.id} is a node twice`);
5109
+ seen.add(node.id);
5110
+ });
5111
+ graph.edges.forEach((e, k) => {
5112
+ if (!e || typeof e !== "object" || typeof e.source !== "string" || typeof e.target !== "string") fail2(`edge ${k} is not { source, target }`);
5113
+ if (e.field !== void 0 && typeof e.field !== "string") fail2(`edge ${k}: field is a string`);
5114
+ if (e.index !== void 0 && !Number.isFinite(e.index)) fail2(`edge ${k}: index is a number`);
5115
+ });
5116
+ const nodes = [...graph.nodes].sort((a, b) => byCodePoint(a.id, b.id));
5117
+ const edges = [...graph.edges].sort((a, b) => byCodePoint(a.source, b.source) || byCodePoint(a.field ?? "", b.field ?? "") || (a.index ?? 0) - (b.index ?? 0) || byCodePoint(a.target, b.target));
5118
+ return { nodes, edges, index: new Map(nodes.map((x, i) => [x.id, i])) };
5119
+ }
5120
+ function layoutByKind(graph) {
5121
+ const { nodes, edges: links, index } = readGraph("layoutByKind", graph);
5122
+ const n = nodes.length;
5123
+ if (n <= 1) return { method: "by-kind", version: 1, points: graph.nodes.map((x) => ({ id: x.id, x: 0, y: 0 })) };
5124
+ const edges = [];
5125
+ for (const e of links) {
5126
+ const a = index.get(e.source);
5127
+ const b = index.get(e.target);
5128
+ if (a !== void 0 && b !== void 0 && a !== b) edges.push([a, b]);
5129
+ }
5130
+ const types = [...new Set(nodes.map((x) => x.type))].sort((a, b) => groupRank(a) - groupRank(b) || byCodePoint(a, b));
5131
+ const k = types.length;
5132
+ const anchorX = /* @__PURE__ */ new Map();
5133
+ const anchorY = /* @__PURE__ */ new Map();
5134
+ types.forEach((t, i) => {
5135
+ anchorX.set(t, LAYOUT_ANCHORS[k * (k - 1) + 2 * i]);
5136
+ anchorY.set(t, LAYOUT_ANCHORS[k * (k - 1) + 2 * i + 1]);
5137
+ });
5138
+ const R = rng(7);
5139
+ const px = new Array(n);
5140
+ const py = new Array(n);
5141
+ const tx = new Array(n);
5142
+ const ty = new Array(n);
5143
+ for (let i = 0; i < n; i++) {
5144
+ const ax = anchorX.get(nodes[i].type);
5145
+ const ay = anchorY.get(nodes[i].type);
5146
+ px[i] = ax * 0.8 + (R() - 0.5) * 0.5;
5147
+ py[i] = ay * 0.8 + (R() - 0.5) * 0.5;
5148
+ tx[i] = ax * 0.85;
5149
+ ty[i] = ay * 0.85;
5150
+ }
5151
+ const rest = Math.max(2e-3, 0.9 / Math.sqrt(n));
5152
+ const push = rest * rest * 1.4;
5153
+ const cell = rest * 2.2;
5154
+ const cell2 = cell * cell;
5155
+ const fx = new Array(n);
5156
+ const fy = new Array(n);
5157
+ const steps = n > 2e3 ? STEPS / 2 : STEPS;
5158
+ for (let it = 0; it < steps; it++) {
5159
+ const t = 1 - it / steps;
5160
+ fx.fill(0);
5161
+ fy.fill(0);
5162
+ const grid = /* @__PURE__ */ new Map();
5163
+ for (let i = 0; i < n; i++) {
5164
+ const key = cellKey(Math.floor(px[i] / cell), Math.floor(py[i] / cell));
5165
+ const c = grid.get(key);
5166
+ if (c) c.push(i);
5167
+ else grid.set(key, [i]);
5168
+ }
5169
+ for (let i = 0; i < n; i++) {
5170
+ const cx = Math.floor(px[i] / cell);
5171
+ const cy = Math.floor(py[i] / cell);
5172
+ for (let dx = -1; dx <= 1; dx++) {
5173
+ for (let dy = -1; dy <= 1; dy++) {
5174
+ const cellOf = grid.get(cellKey(cx + dx, cy + dy));
5175
+ if (!cellOf) continue;
5176
+ if (cellOf.length > CELL_MAX) {
5177
+ const len = cellOf.length;
5178
+ const off = (i * 7 + it * 13) % len;
5179
+ const scale = len / CELL_MAX;
5180
+ for (let s2 = 0; s2 < CELL_MAX; s2++) {
5181
+ const j = cellOf[(off + s2) % len];
5182
+ if (j === i) continue;
5183
+ const ux = px[i] - px[j];
5184
+ const uy = py[i] - py[j];
5185
+ const d2 = ux * ux + uy * uy + 1e-6;
5186
+ if (d2 > cell2) continue;
5187
+ const d = Math.sqrt(d2);
5188
+ const f = push * scale / d2;
5189
+ fx[i] += ux / d * f;
5190
+ fy[i] += uy / d * f;
5191
+ }
5192
+ continue;
5193
+ }
5194
+ for (const j of cellOf) {
5195
+ if (j <= i) continue;
5196
+ const ux = px[i] - px[j];
5197
+ const uy = py[i] - py[j];
5198
+ const d2 = ux * ux + uy * uy + 1e-6;
5199
+ if (d2 > cell2) continue;
5200
+ const d = Math.sqrt(d2);
5201
+ const f = push / d2;
5202
+ fx[i] += ux / d * f;
5203
+ fy[i] += uy / d * f;
5204
+ fx[j] -= ux / d * f;
5205
+ fy[j] -= uy / d * f;
5206
+ }
5207
+ }
5208
+ }
5209
+ }
5210
+ for (const [a, b] of edges) {
5211
+ const ux = px[b] - px[a];
5212
+ const uy = py[b] - py[a];
5213
+ const d = Math.sqrt(ux * ux + uy * uy) + 1e-6;
5214
+ const f = (d - rest) * 0.06;
5215
+ fx[a] += ux / d * f;
5216
+ fy[a] += uy / d * f;
5217
+ fx[b] -= ux / d * f;
5218
+ fy[b] -= uy / d * f;
5219
+ }
5220
+ for (let i = 0; i < n; i++) {
5221
+ fx[i] += (tx[i] - px[i]) * 0.06;
5222
+ fy[i] += (ty[i] - py[i]) * 0.06;
5223
+ const m = Math.sqrt(fx[i] * fx[i] + fy[i] * fy[i]);
5224
+ const cap = 0.03 * t + 2e-3;
5225
+ const s2 = m > cap ? cap / m : 1;
5226
+ px[i] += fx[i] * s2;
5227
+ py[i] += fy[i] * s2;
5228
+ }
5229
+ }
5230
+ let x0 = Infinity;
5231
+ let x1 = -Infinity;
5232
+ let y0 = Infinity;
5233
+ let y1 = -Infinity;
5234
+ for (let i = 0; i < n; i++) {
5235
+ x0 = Math.min(x0, px[i]);
5236
+ x1 = Math.max(x1, px[i]);
5237
+ y0 = Math.min(y0, py[i]);
5238
+ y1 = Math.max(y1, py[i]);
5239
+ }
5240
+ const span = Math.max(x1 - x0, y1 - y0);
5241
+ const s = span > 1e-9 ? 2 / span : 1;
5242
+ const mx = (x0 + x1) / 2;
5243
+ const my = (y0 + y1) / 2;
5244
+ return {
5245
+ method: "by-kind",
5246
+ version: 1,
5247
+ points: graph.nodes.map((x) => {
5248
+ const i = index.get(x.id);
5249
+ return { id: x.id, x: (px[i] - mx) * s, y: (py[i] - my) * s };
5250
+ })
5251
+ };
5252
+ }
5253
+ function layoutAround(graph, focus, options) {
5254
+ if (options !== void 0 && options !== null && (typeof options !== "object" || Array.isArray(options))) {
5255
+ throw new TypeError("layoutAround: options is an object, { steps }");
5256
+ }
5257
+ refuseUnknownOptions("layoutAround", options, ["steps"]);
5258
+ const steps = options?.steps ?? 1;
5259
+ if (steps !== 1 && steps !== 2) throw new TypeError(`layoutAround: steps is 1 or 2, not ${String(steps)}`);
5260
+ const { nodes: N, edges: links, index } = readGraph("layoutAround", graph);
5261
+ const centre = typeof focus === "string" ? index.get(focus) : void 0;
5262
+ if (centre === void 0) throw new TypeError(`layoutAround: the focus ${String(focus)} is not a node of the graph`);
5263
+ const adj = N.map(() => []);
5264
+ for (const e of links) {
5265
+ const a = index.get(e.source);
5266
+ const b = index.get(e.target);
5267
+ if (a === void 0 || b === void 0) continue;
5268
+ adj[a].push(b);
5269
+ if (a !== b) adj[b].push(a);
5270
+ }
5271
+ const depth = /* @__PURE__ */ new Map([[centre, 0]]);
5272
+ const via = /* @__PURE__ */ new Map();
5273
+ let frontier = [centre];
5274
+ for (let s = 1; s <= steps; s++) {
5275
+ const next = [];
5276
+ for (const a of frontier) {
5277
+ for (const to of adj[a]) {
5278
+ if (depth.has(to)) continue;
5279
+ depth.set(to, s);
5280
+ via.set(to, a);
5281
+ next.push(to);
5282
+ }
5283
+ }
5284
+ frontier = next;
5285
+ }
5286
+ const name = (j) => N[j].name ?? "";
5287
+ const ring1 = [...depth].filter(([, s]) => s === 1).map(([j]) => j).sort((a, b) => groupRank(N[a].type) - groupRank(N[b].type) || byCodePoint(N[a].type, N[b].type) || byCodePoint(name(a), name(b)) || a - b);
5288
+ const at = /* @__PURE__ */ new Map([[centre, [0, 0]]]);
5289
+ const angle = /* @__PURE__ */ new Map();
5290
+ if (ring1.length) {
5291
+ const first = Math.min(ring1.length, RING_ONE);
5292
+ const r1 = Math.max(0.34, first * 0.017);
5293
+ const gap = 2 * Math.PI * r1 / first;
5294
+ let placed = 0;
5295
+ let r = r1;
5296
+ while (placed < ring1.length) {
5297
+ const room = Math.max(1, Math.floor(2 * Math.PI * r / gap));
5298
+ const these = ring1.slice(placed, placed + room);
5299
+ these.forEach((j, k) => {
5300
+ const a = -Math.PI / 2 + 2 * Math.PI * (k + 0.5) / these.length;
5301
+ angle.set(j, a);
5302
+ at.set(j, [Math.cos(a) * r, Math.sin(a) * r]);
5303
+ });
5304
+ placed += these.length;
5305
+ r += gap * 1.2;
5306
+ }
5307
+ const outer = r - gap * 1.2;
5308
+ const kids = /* @__PURE__ */ new Map();
5309
+ for (const [j, s] of depth) {
5310
+ if (s !== 2) continue;
5311
+ const p = via.get(j);
5312
+ const l = kids.get(p);
5313
+ if (l) l.push(j);
5314
+ else kids.set(p, [j]);
5315
+ }
5316
+ for (const [p, ks] of kids) {
5317
+ const a0 = angle.get(p) ?? 0;
5318
+ const spread = Math.min(0.5, 2 * Math.PI / Math.max(1, ring1.length) * 0.9);
5319
+ ks.forEach((j, k) => {
5320
+ const a = a0 + (ks.length === 1 ? 0 : (k / (ks.length - 1) - 0.5) * spread);
5321
+ at.set(j, [Math.cos(a) * outer * 1.8, Math.sin(a) * outer * 1.8]);
5322
+ });
5323
+ }
5324
+ }
5325
+ const points = [];
5326
+ for (const x of graph.nodes) {
5327
+ const j = index.get(x.id);
5328
+ const p = at.get(j);
5329
+ if (p) points.push({ id: x.id, depth: depth.get(j), x: p[0], y: p[1] });
5330
+ }
5331
+ return { method: "around", version: 1, points };
5332
+ }
5333
+
4573
5334
  // src/drag.ts
4574
5335
  var TYPES = new Set(ELEMENT_TYPES);
4575
5336
  function dragField(a, b) {
@@ -6978,6 +7739,8 @@ export {
6978
7739
  isToEveryone,
6979
7740
  kindCanWrite,
6980
7741
  landingOf,
7742
+ layoutAround,
7743
+ layoutByKind,
6981
7744
  layoutOf,
6982
7745
  lensesInUse,
6983
7746
  lookupWorld,
package/dist/waymark.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  openersFor,
7
7
  refuseUnknownOptions,
8
8
  typeWord
9
- } from "./chunk-EWHZMOUF.js";
9
+ } from "./chunk-LHFKNEC4.js";
10
10
 
11
11
  // src/waymark/glyphs.ts
12
12
  var MARK_PATH = "M100 50C100 63.261 94.732 75.979 85.355 85.355C75.979 94.732 63.261 100 50 100C36.739 100 24.021 94.732 14.645 85.355C5.268 75.979 0 63.261 0 50C0 36.739 5.268 24.021 14.645 14.645C24.021 5.268 36.739 0 50 0C63.261 0 75.979 5.268 85.355 14.645C94.732 24.021 100 36.739 100 50ZM20.479 78.74C22.377 77.765 24.322 76.884 26.306 76.102Q25.845 75.042 25.421 73.934Q24.026 70.291 23.069 66.268Q22.121 62.281 21.637 58.063Q21.252 54.707 21.171 51.3L8.82 51.3C9.144 61.572 13.298 71.363 20.479 78.74ZM91.18 51.3L78.829 51.3Q78.748 54.707 78.363 58.063Q77.879 62.281 76.931 66.268Q75.974 70.291 74.579 73.934Q74.155 75.041 73.694 76.102C75.678 76.884 77.623 77.765 79.521 78.74C86.702 71.363 90.856 61.572 91.18 51.3ZM8.82 48.7L21.154 48.7Q21.195 44.785 21.637 40.937Q22.121 36.719 23.069 32.732Q24.026 28.709 25.421 25.066Q25.676 24.401 25.943 23.754C24.085 23.008 22.262 22.176 20.479 21.26C13.298 28.637 9.144 38.428 8.82 48.7ZM79.521 21.26C77.738 22.176 75.915 23.008 74.057 23.754Q74.324 24.401 74.579 25.066Q75.974 28.709 76.931 32.732Q77.879 36.719 78.363 40.937Q78.805 44.785 78.846 48.7L91.18 48.7C90.856 38.428 86.702 28.637 79.521 21.26ZM32.455 48.7L44.2 48.7L44.2 28.139C41.714 27.915 39.253 27.548 36.827 27.043Q36.381 28.044 35.974 29.107Q34.846 32.052 34.063 35.347Q33.27 38.678 32.863 42.226Q32.495 45.432 32.455 48.7ZM63.173 27.043C60.747 27.548 58.286 27.915 55.8 28.139L55.8 48.7L67.545 48.7Q67.505 45.432 67.137 42.226Q66.73 38.678 65.937 35.347Q65.153 32.052 64.026 29.107Q63.619 28.044 63.173 27.043ZM48.7 25.786L48.7 8.82C45.82 8.911 42.977 9.303 40.215 9.979Q39.193 11.05 38.224 12.342Q36.393 14.784 34.829 17.913Q33.574 20.422 32.533 23.289C34.326 23.815 36.144 24.261 37.982 24.624C37.99 24.626 37.998 24.627 38.006 24.629C40.048 25.032 42.115 25.332 44.2 25.528C45.692 25.668 47.193 25.755 48.7 25.786ZM51.3 8.82L51.3 25.786C52.68 25.757 54.054 25.683 55.421 25.563C55.548 25.552 55.674 25.54 55.8 25.528C57.885 25.332 59.952 25.032 61.994 24.629C63.841 24.265 65.667 23.817 67.467 23.289Q66.426 20.422 65.171 17.913Q63.607 14.784 61.776 12.342Q60.807 11.05 59.785 9.979C57.023 9.303 54.18 8.911 51.3 8.82ZM48.7 91.18L48.7 74.214C47.193 74.245 45.692 74.332 44.2 74.472C42.331 74.647 40.476 74.907 38.641 75.249C38.628 75.252 38.616 75.254 38.604 75.256C38.571 75.262 38.539 75.268 38.507 75.274C36.606 75.633 34.726 76.08 32.874 76.612C32.76 76.645 32.646 76.678 32.533 76.711Q33.574 79.578 34.829 82.087Q36.393 85.216 38.224 87.658Q39.193 88.95 40.215 90.021C42.977 90.697 45.82 91.089 48.7 91.18ZM59.785 90.021Q60.807 88.95 61.776 87.658Q63.607 85.216 65.171 82.087Q66.426 79.578 67.467 76.711C65.504 76.135 63.511 75.655 61.493 75.274C59.664 74.929 57.815 74.666 55.951 74.486C55.901 74.481 55.85 74.476 55.8 74.472C54.36 74.336 52.911 74.251 51.457 74.217C51.404 74.216 51.352 74.215 51.3 74.214L51.3 91.18C54.18 91.089 57.023 90.697 59.785 90.021ZM65.602 64.989Q65.777 64.328 65.937 63.653Q66.73 60.322 67.137 56.774Q67.449 54.059 67.525 51.3L55.8 51.3L55.8 63.531C59.11 63.795 62.384 64.284 65.602 64.989ZM44.2 51.3L32.475 51.3Q32.551 54.059 32.863 56.774Q33.27 60.322 34.063 63.653Q34.223 64.328 34.398 64.989C37.615 64.284 40.89 63.795 44.2 63.531L44.2 51.3ZM35.727 88.649Q33.994 86.232 32.503 83.25Q31.159 80.562 30.052 77.497C29.162 77.799 28.279 78.122 27.403 78.464C25.727 79.12 24.08 79.849 22.467 80.649C26.368 84.154 30.875 86.857 35.727 88.649ZM77.533 80.649C75.92 79.849 74.273 79.12 72.597 78.464C71.756 78.136 70.909 77.825 70.055 77.533C70.019 77.521 69.983 77.509 69.948 77.497Q68.841 80.562 67.497 83.25Q66.006 86.232 64.273 88.649C69.125 86.857 73.632 84.154 77.533 80.649ZM64.273 11.351Q66.006 13.768 67.497 16.75Q68.841 19.438 69.948 22.503C70.921 22.173 71.886 21.818 72.841 21.439C72.895 21.418 72.95 21.396 73.004 21.375C74.54 20.761 76.051 20.086 77.533 19.351C73.632 15.846 69.125 13.143 64.273 11.351ZM22.467 19.351C23.949 20.086 25.46 20.761 26.996 21.374C28.005 21.777 29.024 22.154 30.052 22.503Q31.159 19.438 32.503 16.75Q33.994 13.768 35.727 11.351C30.875 13.143 26.368 15.846 22.467 19.351Z";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlyworlds/sdk",
3
- "version": "4.166.0",
3
+ "version": "4.167.1",
4
4
  "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
5
5
  "type": "module",
6
6
  "exports": {
@@ -31,8 +31,8 @@
31
31
  "dev": "tsup --entry.index src/index.ts --entry.waymark src/waymark/index.ts --format esm --dts --watch",
32
32
  "pretest": "npm run build",
33
33
  "test": "node --test",
34
- "codegen": "python codegen/generate_types.py && node codegen/tools.mjs",
35
- "codegen:check": "python codegen/generate_types.py --check && node codegen/tools.mjs --check",
34
+ "codegen": "python codegen/generate_types.py && node codegen/tools.mjs && node codegen/layout_anchors.mjs",
35
+ "codegen:check": "python codegen/generate_types.py --check && node codegen/tools.mjs --check && node codegen/layout_anchors.mjs --check",
36
36
  "schema:verify": "python codegen/verify_dist.py",
37
37
  "schema:check": "npm run schema:verify && npm run codegen:check",
38
38
  "prepublishOnly": "npm run build",