@onlyworlds/sdk 4.128.1 → 4.129.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 +1 -1
- package/CHANGELOG.md +10 -0
- package/SCHEMA.md +1 -1
- package/dist/index.d.ts +61 -1
- package/dist/index.js +136 -12
- package/package.json +1 -1
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.
|
|
3
|
+
**Current as of**: SDK **4.x** · schema-dist **v0.34.0-dist.105** (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,16 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.129.0] - 2026-11-02
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`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`.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **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.
|
|
17
|
+
|
|
8
18
|
## [4.128.1] - 2026-11-02
|
|
9
19
|
|
|
10
20
|
### 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.
|
|
3
|
+
**Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.34.0-dist.105** — 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,66 @@ 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.
|
|
5774
|
+
*/
|
|
5775
|
+
declare function mapSpace(elements: readonly unknown[]): OwMapSpace;
|
|
5776
|
+
|
|
5717
5777
|
/** One word pair of a names map: `one` for a single thing, `many` for a plural (absent: `one`). */
|
|
5718
5778
|
interface OwWordPair {
|
|
5719
5779
|
one: string;
|
|
@@ -7063,4 +7123,4 @@ declare class TokenResource {
|
|
|
7063
7123
|
getEncryptionInfo(): Promise<EncryptionInfo>;
|
|
7064
7124
|
}
|
|
7065
7125
|
|
|
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 };
|
|
7126
|
+
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
|
|
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" && !
|
|
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" ?
|
|
2665
|
+
at = typeof parent === "string" ? byId2.get(parent) : void 0;
|
|
2666
2666
|
}
|
|
2667
2667
|
return false;
|
|
2668
2668
|
};
|
|
@@ -3844,6 +3844,129 @@ 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" || idOf2(e.id) === null) continue;
|
|
3865
|
+
const list2 = byType.get(e.type);
|
|
3866
|
+
if (list2) list2.push(e);
|
|
3867
|
+
else byType.set(e.type, [e]);
|
|
3868
|
+
}
|
|
3869
|
+
const rowsOf2 = (type) => byType.get(type) ?? [];
|
|
3870
|
+
const indexed = (type) => {
|
|
3871
|
+
const m = /* @__PURE__ */ new Map();
|
|
3872
|
+
for (const r of rowsOf2(type)) {
|
|
3873
|
+
const id = idOf2(r.id);
|
|
3874
|
+
if (id !== null) m.set(id, r);
|
|
3875
|
+
}
|
|
3876
|
+
return m;
|
|
3877
|
+
};
|
|
3878
|
+
const maps = indexed("map");
|
|
3879
|
+
const zones = indexed("zone");
|
|
3880
|
+
const out = { no_point: 0, no_markers: 0, dangling: 0, no_map: 0 };
|
|
3881
|
+
const placed = /* @__PURE__ */ new Map();
|
|
3882
|
+
for (const mk of rowsOf2("marker")) {
|
|
3883
|
+
const z = idOf2(mk.zone);
|
|
3884
|
+
const m = idOf2(mk.map);
|
|
3885
|
+
if (z === null || m === null || !zones.has(z) || !maps.has(m)) {
|
|
3886
|
+
out.dangling++;
|
|
3887
|
+
continue;
|
|
3888
|
+
}
|
|
3889
|
+
if (!(whole3(mk.x) && whole3(mk.y))) {
|
|
3890
|
+
out.no_point++;
|
|
3891
|
+
continue;
|
|
3892
|
+
}
|
|
3893
|
+
const key = JSON.stringify([z, m]);
|
|
3894
|
+
const group = placed.get(key);
|
|
3895
|
+
if (group) group.markers.push(mk);
|
|
3896
|
+
else placed.set(key, { zone: z, map: m, markers: [mk] });
|
|
3897
|
+
}
|
|
3898
|
+
const rowId = (r) => r.id;
|
|
3899
|
+
const markerOrder = (a, b) => {
|
|
3900
|
+
const oa = whole3(a.order);
|
|
3901
|
+
const ob = whole3(b.order);
|
|
3902
|
+
if (oa && ob && a.order !== b.order) return a.order - b.order;
|
|
3903
|
+
if (oa !== ob) return oa ? -1 : 1;
|
|
3904
|
+
return byId(rowId(a), rowId(b));
|
|
3905
|
+
};
|
|
3906
|
+
const outlines = [];
|
|
3907
|
+
for (const zid of [...zones.keys()].sort(byId)) {
|
|
3908
|
+
const groups = [...placed.values()].filter((g) => g.zone === zid).sort((a, b) => byId(a.map, b.map));
|
|
3909
|
+
if (groups.length === 0) {
|
|
3910
|
+
out.no_markers++;
|
|
3911
|
+
continue;
|
|
3912
|
+
}
|
|
3913
|
+
const s = zones.get(zid).shape;
|
|
3914
|
+
const shape = s === "line" ? "line" : "polygon";
|
|
3915
|
+
for (const g of groups) {
|
|
3916
|
+
outlines.push({ zone: zid, map: g.map, shape, points: [...g.markers].sort(markerOrder).map(point) });
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
const pins = [];
|
|
3920
|
+
for (const p of [...rowsOf2("pin")].sort((a, b) => byId(rowId(a), rowId(b)))) {
|
|
3921
|
+
const m = idOf2(p.map);
|
|
3922
|
+
if (m === null || !maps.has(m)) {
|
|
3923
|
+
out.no_map++;
|
|
3924
|
+
continue;
|
|
3925
|
+
}
|
|
3926
|
+
if (!(whole3(p.x) && whole3(p.y))) {
|
|
3927
|
+
out.no_point++;
|
|
3928
|
+
continue;
|
|
3929
|
+
}
|
|
3930
|
+
let et = idOf2(p.element_type);
|
|
3931
|
+
let ei = idOf2(p.element_id);
|
|
3932
|
+
if (et === null || ei === null) et = ei = null;
|
|
3933
|
+
const [x, y, z] = point(p);
|
|
3934
|
+
pins.push({ pin: rowId(p), map: m, element_type: et, element_id: ei, x, y, z });
|
|
3935
|
+
}
|
|
3936
|
+
const mapRows = [];
|
|
3937
|
+
for (const mid of [...maps.keys()].sort(byId)) {
|
|
3938
|
+
const mp = maps.get(mid);
|
|
3939
|
+
const own3 = [];
|
|
3940
|
+
for (const o of outlines) if (o.map === mid) own3.push(...o.points);
|
|
3941
|
+
for (const q of pins) if (q.map === mid) own3.push([q.x, q.y, q.z]);
|
|
3942
|
+
let measured = false;
|
|
3943
|
+
const slot = (key, i) => {
|
|
3944
|
+
const v = mp[key];
|
|
3945
|
+
if (whole3(v)) return v;
|
|
3946
|
+
measured = true;
|
|
3947
|
+
return largest(own3, i);
|
|
3948
|
+
};
|
|
3949
|
+
const width = slot("width", 0);
|
|
3950
|
+
const height = slot("height", 1);
|
|
3951
|
+
const sc = mp.x_metres_per_pixel;
|
|
3952
|
+
const row = {
|
|
3953
|
+
id: mid,
|
|
3954
|
+
width,
|
|
3955
|
+
height,
|
|
3956
|
+
depth: whole3(mp.depth) ? mp.depth : null,
|
|
3957
|
+
z_max: largest(own3, 2),
|
|
3958
|
+
scale: typeof sc === "number" && sc > 0 ? sc : null,
|
|
3959
|
+
location: idOf2(mp.location),
|
|
3960
|
+
parent_map: idOf2(mp.parent_map)
|
|
3961
|
+
};
|
|
3962
|
+
if (measured) row.extent = "points";
|
|
3963
|
+
mapRows.push(row);
|
|
3964
|
+
}
|
|
3965
|
+
const counted = {};
|
|
3966
|
+
for (const k of ["no_point", "no_markers", "dangling", "no_map"]) if (out[k] > 0) counted[k] = out[k];
|
|
3967
|
+
return { maps: mapRows, zones: outlines, pins, out: counted };
|
|
3968
|
+
}
|
|
3969
|
+
|
|
3847
3970
|
// src/drag.ts
|
|
3848
3971
|
var TYPES = new Set(ELEMENT_TYPES);
|
|
3849
3972
|
function dragField(a, b) {
|
|
@@ -4707,8 +4830,8 @@ function aliasesOf(el) {
|
|
|
4707
4830
|
return [...out];
|
|
4708
4831
|
}
|
|
4709
4832
|
function buildWorldIndex(elements) {
|
|
4710
|
-
const
|
|
4711
|
-
for (const el of elements) if (el && el.id)
|
|
4833
|
+
const byId2 = /* @__PURE__ */ new Map();
|
|
4834
|
+
for (const el of elements) if (el && el.id) byId2.set(el.id, el);
|
|
4712
4835
|
const out = /* @__PURE__ */ new Map(), inn = /* @__PURE__ */ new Map();
|
|
4713
4836
|
const unresolved = /* @__PURE__ */ new Map();
|
|
4714
4837
|
const phrase = /* @__PURE__ */ new Map();
|
|
@@ -4719,7 +4842,7 @@ function buildWorldIndex(elements) {
|
|
|
4719
4842
|
if (!m.has(k)) m.set(k, []);
|
|
4720
4843
|
m.get(k).push(v);
|
|
4721
4844
|
};
|
|
4722
|
-
for (const el of
|
|
4845
|
+
for (const el of byId2.values()) {
|
|
4723
4846
|
const schema = linkFieldsOf(el.type);
|
|
4724
4847
|
const linkFields = /* @__PURE__ */ new Set();
|
|
4725
4848
|
for (const [field, v] of Object.entries(el)) {
|
|
@@ -4731,7 +4854,7 @@ function buildWorldIndex(elements) {
|
|
|
4731
4854
|
if (!ids.length) continue;
|
|
4732
4855
|
linkFields.add(field);
|
|
4733
4856
|
for (const id of ids) {
|
|
4734
|
-
if (
|
|
4857
|
+
if (byId2.has(id)) {
|
|
4735
4858
|
pushTo(out, el.id, { field, id });
|
|
4736
4859
|
pushTo(inn, id, { field, id: el.id });
|
|
4737
4860
|
} else pushTo(unresolved, el.id, { field, id });
|
|
@@ -4740,7 +4863,7 @@ function buildWorldIndex(elements) {
|
|
|
4740
4863
|
}
|
|
4741
4864
|
if (!vals.every((x) => typeof x === "string" && ID_SHAPE.test(x))) continue;
|
|
4742
4865
|
for (const id of vals) {
|
|
4743
|
-
if (
|
|
4866
|
+
if (byId2.has(id)) {
|
|
4744
4867
|
pushTo(out, el.id, { field, id });
|
|
4745
4868
|
pushTo(inn, id, { field, id: el.id });
|
|
4746
4869
|
} else pushTo(unresolved, el.id, { field, id });
|
|
@@ -4774,12 +4897,12 @@ function buildWorldIndex(elements) {
|
|
|
4774
4897
|
tokenIds.get(w).add(el.id);
|
|
4775
4898
|
}
|
|
4776
4899
|
}
|
|
4777
|
-
const N =
|
|
4900
|
+
const N = byId2.size || 1;
|
|
4778
4901
|
const idf = /* @__PURE__ */ new Map();
|
|
4779
4902
|
for (const [w, ids] of tokenIds) idf.set(w, Math.log(1 + N / ids.size));
|
|
4780
4903
|
const textIdf = /* @__PURE__ */ new Map();
|
|
4781
4904
|
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 };
|
|
4905
|
+
return { byId: byId2, out, inn, unresolved, phrase, tokenIds, nameWords, idf, textIds, textIdf };
|
|
4783
4906
|
}
|
|
4784
4907
|
function similarWords(w, vocab) {
|
|
4785
4908
|
const res = [];
|
|
@@ -5632,8 +5755,8 @@ var DEFAULT_FORMAT_PLAIN = "{year} {era}";
|
|
|
5632
5755
|
var DEFAULT_FORMAT_INTERCALARY = "{intercalary}, {year} {era}";
|
|
5633
5756
|
var EMPTY_KNOWN = "\uE000";
|
|
5634
5757
|
function renderTemplate(template, values) {
|
|
5635
|
-
let out = template.replace(/\{([a-z_]+)\}/g, (
|
|
5636
|
-
if (!KNOWN_TOKENS.includes(token)) return
|
|
5758
|
+
let out = template.replace(/\{([a-z_]+)\}/g, (whole4, token) => {
|
|
5759
|
+
if (!KNOWN_TOKENS.includes(token)) return whole4;
|
|
5637
5760
|
const v = values[token];
|
|
5638
5761
|
return v == null || v === "" ? EMPTY_KNOWN : v;
|
|
5639
5762
|
});
|
|
@@ -6149,6 +6272,7 @@ export {
|
|
|
6149
6272
|
landingOf,
|
|
6150
6273
|
lensesInUse,
|
|
6151
6274
|
lookupWorld,
|
|
6275
|
+
mapSpace,
|
|
6152
6276
|
monthStartSteps,
|
|
6153
6277
|
nfc,
|
|
6154
6278
|
noteOf,
|