@onlyworlds/sdk 4.128.1 → 4.129.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/AGENTS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # For AI agents using @onlyworlds/sdk
2
2
 
3
- **Current as of**: SDK **4.x** · schema-dist **v0.34.0-dist.104** (canonical 00.34.00).
3
+ **Current as of**: SDK **4.x** · schema-dist **v0.34.0-dist.106** (canonical 00.34.00).
4
4
  This line is asserted by `codegen:check` in CI — if the pin moves and this file is not
5
5
  re-read against it, the check fails rather than letting this document rot quietly.
6
6
 
package/CHANGELOG.md CHANGED
@@ -5,6 +5,26 @@ earlier history lives in git log only.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.129.1] - 2026-11-02
9
+
10
+ ### Fixed
11
+
12
+ - **`mapSpace` reads two rows of one type with one id as the last one served** (schema-dist `profiles/map-space.md`, serial 106, reading I: an element is its id). Markers and Pins now follow the rule Maps and Zones already did: until now each row of a repeated Marker or Pin id was read as a Marker or Pin of its own. The last row wins even when it reads less (no point, or a map that is not served), and is then counted under its reason.
13
+
14
+ ### Changed
15
+
16
+ - **Schema repinned to schema-dist `v0.34.0-dist.106`** (from dist.105); the standard stays canonical **00.34.00** and no schema field moved. Serial 106 words the map-space page's readings I to K and four sharpened rules (a measured frame from placed points only, a `z` that is not a whole number read as 0, `no_markers` for a Zone with no placed Marker, a Pin with neither a served map nor a point counted once as `no_map`), and its fixture holds 34 cases. Apart from reading I, `mapSpace` already answered every new case as ruled.
17
+
18
+ ## [4.129.0] - 2026-11-02
19
+
20
+ ### Added
21
+
22
+ - **`mapSpace(elements)`: the map-space profile** (schema-dist `profiles/map-space.md`, serial 105). It reads a world's map space from its elements as the reader is served them: `{ maps, zones, pins, out }`, all four keys always present. Each Map reports its frame (`width`, `height`, `depth`, `z_max`, `scale`, `location`, `parent_map`; `z_max` is the largest z among its own points, and a missing `width` or `height` is measured from the Map's own points and marked `extent: "points"`). Each Zone has one outline per Map it has Markers on, its Markers in `order` ascending (a Marker without a whole `order` after the ordered ones, then by id in code point order). Each Pin reports its point and its element (both keys or both null). What the reading left aside is counted by reason in `out` (`no_point`, `no_markers`, `dangling`, `no_map`). A number is whole by value (`2.0` is 2), and a row without a non-empty string `id` is no element. The fixture `profiles/map-space.fixture.json` (24 cases) is the test. Types: `OwMapSpace`, `OwMapSpaceMap`, `OwMapSpaceOutline`, `OwMapSpacePin`, `OwMapSpacePoint`, `OwMapSpaceOutReason`.
23
+
24
+ ### Changed
25
+
26
+ - **Schema repinned to schema-dist `v0.34.0-dist.105`** (from dist.104); the standard stays canonical **00.34.00** and no schema field moved. Serial 105 adds the map-space profile page and its fixture.
27
+
8
28
  ## [4.128.1] - 2026-11-02
9
29
 
10
30
  ### Fixed
package/SCHEMA.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # OnlyWorlds Schema Reference
2
2
 
3
- **Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.34.0-dist.104** — canonical schema **00.34.00**, published 2026-11-02.
3
+ **Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.34.0-dist.106** — canonical schema **00.34.00**, published 2026-11-02.
4
4
 
5
5
  GENERATED from the canonical schema YAML — do not hand-edit (regenerate: `python codegen/generate_types.py`).
6
6
  Written for both humans and AI agents reading this package locally.
package/dist/index.d.ts CHANGED
@@ -5714,6 +5714,67 @@ interface OwLanding {
5714
5714
  */
5715
5715
  declare function landingOf(graph: OwWorldGraph, options?: OwLandingOptions | null): OwLanding;
5716
5716
 
5717
+ /** A point `[x, y, z]`, whole numbers in the Map's pixels; z counts upward and reads 0 when the row has none. */
5718
+ type OwMapSpacePoint = [number, number, number];
5719
+ interface OwMapSpaceMap {
5720
+ id: string;
5721
+ /** The Map's own `width` when it is a whole number, else the largest x among its own points; null with no point. */
5722
+ width: number | null;
5723
+ height: number | null;
5724
+ /** The Map's `depth` when it is a whole number, else null. */
5725
+ depth: number | null;
5726
+ /** The largest z among the Map's own outline and Pin points (kept as written, so it can pass `depth`); null with no point. */
5727
+ z_max: number | null;
5728
+ /** Metres per pixel: `x_metres_per_pixel` when it is a positive number, else null. */
5729
+ scale: number | null;
5730
+ location: string | null;
5731
+ parent_map: string | null;
5732
+ /** `points` when `width` or `height` was measured from the Map's own points; absent when both were written. */
5733
+ extent?: 'points';
5734
+ }
5735
+ interface OwMapSpaceOutline {
5736
+ zone: string;
5737
+ map: string;
5738
+ /** The Zone's own `shape` when it is `polygon` or `line`, else `polygon`. */
5739
+ shape: 'polygon' | 'line';
5740
+ points: OwMapSpacePoint[];
5741
+ }
5742
+ interface OwMapSpacePin {
5743
+ pin: string;
5744
+ map: string;
5745
+ /** Both keys or neither: a Pin with one of the two reads both null. */
5746
+ element_type: string | null;
5747
+ element_id: string | null;
5748
+ x: number;
5749
+ y: number;
5750
+ z: number;
5751
+ }
5752
+ type OwMapSpaceOutReason = 'no_point' | 'no_markers' | 'dangling' | 'no_map';
5753
+ interface OwMapSpace {
5754
+ /** By id in code point order. */
5755
+ maps: OwMapSpaceMap[];
5756
+ /** By Zone id, then Map id. */
5757
+ zones: OwMapSpaceOutline[];
5758
+ /** By id in code point order. */
5759
+ pins: OwMapSpacePin[];
5760
+ /** What the reading left aside, by reason, in the order `no_point`, `no_markers`, `dangling`, `no_map`; a reason with nothing counted is absent. */
5761
+ out: Partial<Record<OwMapSpaceOutReason, number>>;
5762
+ }
5763
+ /**
5764
+ * A world's map space (the map-space profile): `{maps, zones, pins, out}`, all four keys always present, from
5765
+ * the elements as the reader is served them (so a Zone the reader may not see is not in the input, and not brought
5766
+ * back). Everything is keyed by id and holds whole numbers in the Map's pixels; ids sort by code point, so the same
5767
+ * input gives the same bytes.
5768
+ *
5769
+ * A Zone's outline is the Markers that name the Zone and one Map, by `order` ascending; a Marker without a whole
5770
+ * `order` sorts after every ordered one, then by id. A Marker whose Zone or Map is not served is counted `dangling`
5771
+ * (checked first), one without a whole `x` and `y` `no_point`; a Zone without a placed Marker `no_markers`; a Pin whose
5772
+ * Map is not served `no_map`, one without a whole `x` and `y` `no_point`. A `z` past a Map's `depth` is kept as written
5773
+ * and reported in the Map's `z_max`. A row without a non-empty string `id` is no element and is not counted; two rows
5774
+ * of one type with one id read as the last one served.
5775
+ */
5776
+ declare function mapSpace(elements: readonly unknown[]): OwMapSpace;
5777
+
5717
5778
  /** One word pair of a names map: `one` for a single thing, `many` for a plural (absent: `one`). */
5718
5779
  interface OwWordPair {
5719
5780
  one: string;
@@ -7063,4 +7124,4 @@ declare class TokenResource {
7063
7124
  getEncryptionInfo(): Promise<EncryptionInfo>;
7064
7125
  }
7065
7126
 
7066
- 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, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, 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 OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLanding, type OwLandingCluster, type OwLandingGap, type OwLandingGapKind, type OwLandingMember, type OwLandingMode, type OwLandingOptions, 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 OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwOpenersOptions, type OwPage, 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 OwResyncReason, type OwReviewInput, type OwReviewed, 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 OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, 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, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, charterOf, dateOf, degreeOf, detectKeyKind, displayYear, domainsOf, doorWhere, doorsOf, dragField, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, groupOf, handsOnAsProposed, hasUnseenRecipients, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, landingOf, lensesInUse, lookupWorld, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, recordMarkOf, recordsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, strandOf, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
7127
+ 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, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, 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 OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLanding, type OwLandingCluster, type OwLandingGap, type OwLandingGapKind, type OwLandingMember, type OwLandingMode, type OwLandingOptions, 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 OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwOpener, type OwOpenerKind, type OwOpenerState, type OwOpenerSurface, type OwOpenersOptions, type OwPage, 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 OwResyncReason, type OwReviewInput, type OwReviewed, 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 OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, 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, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, charterOf, dateOf, degreeOf, detectKeyKind, displayYear, domainsOf, doorWhere, doorsOf, dragField, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, groupOf, handsOnAsProposed, hasUnseenRecipients, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, landingOf, lensesInUse, lookupWorld, mapSpace, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, recordMarkOf, recordsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, strandOf, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
package/dist/index.js CHANGED
@@ -2647,10 +2647,10 @@ function unreadFor(messages, characterId, readMark, members) {
2647
2647
  }
2648
2648
  function threadOf(messages, rootId) {
2649
2649
  if (!Array.isArray(messages) || typeof rootId !== "string" || rootId === "") return [];
2650
- const byId = /* @__PURE__ */ new Map();
2650
+ const byId2 = /* @__PURE__ */ new Map();
2651
2651
  for (const m of messages) {
2652
2652
  const id = isBody(m) ? idOf(m) : void 0;
2653
- if (typeof id === "string" && !byId.has(id)) byId.set(id, m);
2653
+ if (typeof id === "string" && !byId2.has(id)) byId2.set(id, m);
2654
2654
  }
2655
2655
  const reaches = (start) => {
2656
2656
  const seen = /* @__PURE__ */ new Set();
@@ -2662,7 +2662,7 @@ function threadOf(messages, rootId) {
2662
2662
  seen.add(id);
2663
2663
  const parent = at.parent_narrative;
2664
2664
  if (parent === rootId) return true;
2665
- at = typeof parent === "string" ? byId.get(parent) : void 0;
2665
+ at = typeof parent === "string" ? byId2.get(parent) : void 0;
2666
2666
  }
2667
2667
  return false;
2668
2668
  };
@@ -3844,6 +3844,124 @@ function landingOf(graph, options) {
3844
3844
  return { mode: graph.nodes.length < size ? "gaps" : "graph", size, clusters, unclustered, gaps };
3845
3845
  }
3846
3846
 
3847
+ // src/mapspace.ts
3848
+ var isRow = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
3849
+ var whole3 = (v) => typeof v === "number" && Number.isInteger(v);
3850
+ var idOf2 = (v) => typeof v === "string" && v !== "" ? v : null;
3851
+ var byId = (a, b) => byCodePoint(a, b);
3852
+ function point(e) {
3853
+ return [e.x, e.y, whole3(e.z) ? e.z : 0];
3854
+ }
3855
+ function largest(points, index) {
3856
+ let best = null;
3857
+ for (const p of points) if (best === null || p[index] > best) best = p[index];
3858
+ return best;
3859
+ }
3860
+ function mapSpace(elements) {
3861
+ if (!Array.isArray(elements)) throw new TypeError("mapSpace: elements is a list of elements.");
3862
+ const byType = /* @__PURE__ */ new Map();
3863
+ for (const e of elements) {
3864
+ if (!isRow(e) || typeof e.type !== "string") continue;
3865
+ const id = idOf2(e.id);
3866
+ if (id === null) continue;
3867
+ const rows = byType.get(e.type);
3868
+ if (rows) rows.set(id, e);
3869
+ else byType.set(e.type, /* @__PURE__ */ new Map([[id, e]]));
3870
+ }
3871
+ const indexed = (type) => byType.get(type) ?? /* @__PURE__ */ new Map();
3872
+ const rowsOf2 = (type) => [...indexed(type).values()];
3873
+ const maps = indexed("map");
3874
+ const zones = indexed("zone");
3875
+ const out = { no_point: 0, no_markers: 0, dangling: 0, no_map: 0 };
3876
+ const placed = /* @__PURE__ */ new Map();
3877
+ for (const mk of rowsOf2("marker")) {
3878
+ const z = idOf2(mk.zone);
3879
+ const m = idOf2(mk.map);
3880
+ if (z === null || m === null || !zones.has(z) || !maps.has(m)) {
3881
+ out.dangling++;
3882
+ continue;
3883
+ }
3884
+ if (!(whole3(mk.x) && whole3(mk.y))) {
3885
+ out.no_point++;
3886
+ continue;
3887
+ }
3888
+ const key = JSON.stringify([z, m]);
3889
+ const group = placed.get(key);
3890
+ if (group) group.markers.push(mk);
3891
+ else placed.set(key, { zone: z, map: m, markers: [mk] });
3892
+ }
3893
+ const rowId = (r) => r.id;
3894
+ const markerOrder = (a, b) => {
3895
+ const oa = whole3(a.order);
3896
+ const ob = whole3(b.order);
3897
+ if (oa && ob && a.order !== b.order) return a.order - b.order;
3898
+ if (oa !== ob) return oa ? -1 : 1;
3899
+ return byId(rowId(a), rowId(b));
3900
+ };
3901
+ const outlines = [];
3902
+ for (const zid of [...zones.keys()].sort(byId)) {
3903
+ const groups = [...placed.values()].filter((g) => g.zone === zid).sort((a, b) => byId(a.map, b.map));
3904
+ if (groups.length === 0) {
3905
+ out.no_markers++;
3906
+ continue;
3907
+ }
3908
+ const s = zones.get(zid).shape;
3909
+ const shape = s === "line" ? "line" : "polygon";
3910
+ for (const g of groups) {
3911
+ outlines.push({ zone: zid, map: g.map, shape, points: [...g.markers].sort(markerOrder).map(point) });
3912
+ }
3913
+ }
3914
+ const pins = [];
3915
+ for (const p of [...rowsOf2("pin")].sort((a, b) => byId(rowId(a), rowId(b)))) {
3916
+ const m = idOf2(p.map);
3917
+ if (m === null || !maps.has(m)) {
3918
+ out.no_map++;
3919
+ continue;
3920
+ }
3921
+ if (!(whole3(p.x) && whole3(p.y))) {
3922
+ out.no_point++;
3923
+ continue;
3924
+ }
3925
+ let et = idOf2(p.element_type);
3926
+ let ei = idOf2(p.element_id);
3927
+ if (et === null || ei === null) et = ei = null;
3928
+ const [x, y, z] = point(p);
3929
+ pins.push({ pin: rowId(p), map: m, element_type: et, element_id: ei, x, y, z });
3930
+ }
3931
+ const mapRows = [];
3932
+ for (const mid of [...maps.keys()].sort(byId)) {
3933
+ const mp = maps.get(mid);
3934
+ const own3 = [];
3935
+ for (const o of outlines) if (o.map === mid) own3.push(...o.points);
3936
+ for (const q of pins) if (q.map === mid) own3.push([q.x, q.y, q.z]);
3937
+ let measured = false;
3938
+ const slot = (key, i) => {
3939
+ const v = mp[key];
3940
+ if (whole3(v)) return v;
3941
+ measured = true;
3942
+ return largest(own3, i);
3943
+ };
3944
+ const width = slot("width", 0);
3945
+ const height = slot("height", 1);
3946
+ const sc = mp.x_metres_per_pixel;
3947
+ const row = {
3948
+ id: mid,
3949
+ width,
3950
+ height,
3951
+ depth: whole3(mp.depth) ? mp.depth : null,
3952
+ z_max: largest(own3, 2),
3953
+ scale: typeof sc === "number" && sc > 0 ? sc : null,
3954
+ location: idOf2(mp.location),
3955
+ parent_map: idOf2(mp.parent_map)
3956
+ };
3957
+ if (measured) row.extent = "points";
3958
+ mapRows.push(row);
3959
+ }
3960
+ const counted = {};
3961
+ for (const k of ["no_point", "no_markers", "dangling", "no_map"]) if (out[k] > 0) counted[k] = out[k];
3962
+ return { maps: mapRows, zones: outlines, pins, out: counted };
3963
+ }
3964
+
3847
3965
  // src/drag.ts
3848
3966
  var TYPES = new Set(ELEMENT_TYPES);
3849
3967
  function dragField(a, b) {
@@ -4707,8 +4825,8 @@ function aliasesOf(el) {
4707
4825
  return [...out];
4708
4826
  }
4709
4827
  function buildWorldIndex(elements) {
4710
- const byId = /* @__PURE__ */ new Map();
4711
- for (const el of elements) if (el && el.id) byId.set(el.id, el);
4828
+ const byId2 = /* @__PURE__ */ new Map();
4829
+ for (const el of elements) if (el && el.id) byId2.set(el.id, el);
4712
4830
  const out = /* @__PURE__ */ new Map(), inn = /* @__PURE__ */ new Map();
4713
4831
  const unresolved = /* @__PURE__ */ new Map();
4714
4832
  const phrase = /* @__PURE__ */ new Map();
@@ -4719,7 +4837,7 @@ function buildWorldIndex(elements) {
4719
4837
  if (!m.has(k)) m.set(k, []);
4720
4838
  m.get(k).push(v);
4721
4839
  };
4722
- for (const el of byId.values()) {
4840
+ for (const el of byId2.values()) {
4723
4841
  const schema = linkFieldsOf(el.type);
4724
4842
  const linkFields = /* @__PURE__ */ new Set();
4725
4843
  for (const [field, v] of Object.entries(el)) {
@@ -4731,7 +4849,7 @@ function buildWorldIndex(elements) {
4731
4849
  if (!ids.length) continue;
4732
4850
  linkFields.add(field);
4733
4851
  for (const id of ids) {
4734
- if (byId.has(id)) {
4852
+ if (byId2.has(id)) {
4735
4853
  pushTo(out, el.id, { field, id });
4736
4854
  pushTo(inn, id, { field, id: el.id });
4737
4855
  } else pushTo(unresolved, el.id, { field, id });
@@ -4740,7 +4858,7 @@ function buildWorldIndex(elements) {
4740
4858
  }
4741
4859
  if (!vals.every((x) => typeof x === "string" && ID_SHAPE.test(x))) continue;
4742
4860
  for (const id of vals) {
4743
- if (byId.has(id)) {
4861
+ if (byId2.has(id)) {
4744
4862
  pushTo(out, el.id, { field, id });
4745
4863
  pushTo(inn, id, { field, id: el.id });
4746
4864
  } else pushTo(unresolved, el.id, { field, id });
@@ -4774,12 +4892,12 @@ function buildWorldIndex(elements) {
4774
4892
  tokenIds.get(w).add(el.id);
4775
4893
  }
4776
4894
  }
4777
- const N = byId.size || 1;
4895
+ const N = byId2.size || 1;
4778
4896
  const idf = /* @__PURE__ */ new Map();
4779
4897
  for (const [w, ids] of tokenIds) idf.set(w, Math.log(1 + N / ids.size));
4780
4898
  const textIdf = /* @__PURE__ */ new Map();
4781
4899
  for (const [w, ids] of textIds) textIdf.set(w, Math.log(1 + N / ids.size));
4782
- return { byId, out, inn, unresolved, phrase, tokenIds, nameWords, idf, textIds, textIdf };
4900
+ return { byId: byId2, out, inn, unresolved, phrase, tokenIds, nameWords, idf, textIds, textIdf };
4783
4901
  }
4784
4902
  function similarWords(w, vocab) {
4785
4903
  const res = [];
@@ -5632,8 +5750,8 @@ var DEFAULT_FORMAT_PLAIN = "{year} {era}";
5632
5750
  var DEFAULT_FORMAT_INTERCALARY = "{intercalary}, {year} {era}";
5633
5751
  var EMPTY_KNOWN = "\uE000";
5634
5752
  function renderTemplate(template, values) {
5635
- let out = template.replace(/\{([a-z_]+)\}/g, (whole3, token) => {
5636
- if (!KNOWN_TOKENS.includes(token)) return whole3;
5753
+ let out = template.replace(/\{([a-z_]+)\}/g, (whole4, token) => {
5754
+ if (!KNOWN_TOKENS.includes(token)) return whole4;
5637
5755
  const v = values[token];
5638
5756
  return v == null || v === "" ? EMPTY_KNOWN : v;
5639
5757
  });
@@ -6149,6 +6267,7 @@ export {
6149
6267
  landingOf,
6150
6268
  lensesInUse,
6151
6269
  lookupWorld,
6270
+ mapSpace,
6152
6271
  monthStartSteps,
6153
6272
  nfc,
6154
6273
  noteOf,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlyworlds/sdk",
3
- "version": "4.128.1",
3
+ "version": "4.129.1",
4
4
  "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
5
5
  "type": "module",
6
6
  "exports": {