@onlyworlds/sdk 4.104.3 → 4.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -0
- package/CHANGELOG.md +7 -0
- package/README.md +13 -0
- package/dist/index.d.ts +81 -1
- package/dist/index.js +100 -5
- package/package.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -216,6 +216,9 @@ against live data). The v1 surface (`OnlyWorldsClient`, the `ElementType` enum)
|
|
|
216
216
|
`ow://<world id>/<type>/<id>` for another world's, the site's address for a person. Read one
|
|
217
217
|
with `parseOwLink(text)`; a refusal throws `OwAddressError` with the profile's `reason`. An
|
|
218
218
|
address in a field is text: never fetch it to show what it names.
|
|
219
|
+
- To offer a world or an element in other tools, `openersFor(TOOLS, kind, address, surface)` gives
|
|
220
|
+
the "Open with" rows in order, each `{ id, name, href, state }` with its word ("Sign in to Atlas
|
|
221
|
+
first") or null. Draw them as given; never word a row yourself.
|
|
219
222
|
- A string holding an unpaired surrogate (text cut mid-emoji) is a 422 naming the field.
|
|
220
223
|
Slice strings by code point, not by UTF-16 unit.
|
|
221
224
|
- Colour carries the element's colour group (`elementColor(type, mode)`, `groupOf(type)`: `blue`,
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,13 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.105.0] - 2026-10-29
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`openersFor(tools, kind, address, surface)`**: the rows of an "Open with" menu for a world (`kind: 'world'`) or one element of it (`'element'`), in order, each `{ id, name, href, state }`. First the site's own row (`onlyworlds.com`, the world's or the element's page on www.onlyworlds.com, never a word), then one row per tools list row, in the list's order, that is `listed` and has an `open` link for this kind; a tool with only a world link is offered on an element as opening its world. `surface` is what the page knows, and nothing is guessed: `audience` (`member` or `public`, required; the public sees only rows whose `open.needs` is null), `signedIn` (true, false, or null when the page cannot know), `browser` (default true), `phone` (default false) and `tool`, the page's own client name. `state` is the first that holds: "You are here" (the row whose `client` is `tool`), "Opens in your browser" (needs an account, outside a browser), "Sign in to <name> first" (needs an account, signed out), "Needs the world on this phone" (needs the world on the device, on a phone), "Opens the world" (a world link on an element), else null. An address with no world, or with a slug for it, refuses with `OwAddressError` (`no_world`, `bad_world`); an element's rows from an address with no element, an unknown `kind`, a missing `audience`, and an unknown key on the address or the surface are a TypeError. Pure and DOM-free; the Python package's `openers_for` answers the same shared fixture (41 cases) row for row.
|
|
13
|
+
- **`TOOLS`**: the OnlyWorlds tools list (github.com/OnlyWorlds/tools, `tools.json` format 1) as of this release, the keys `openersFor` reads (`id`, `name`, `url`, `client`, `rung`, `open`), with the types `OwTool`, `OwToolOpen`, `OwToolNeeds`, `OwOpener`, `OwOpenerKind`, `OwOpenerState` and `OwOpenerSurface`. It is generated by `codegen/tools.mjs` from a copy vendored byte for byte at a pinned commit (`codegen/tools-pin.json`, the commit and the file's sha256), and `npm run codegen:check` now also fails when the copy or the generated module is stale. A tool listed after a release is offered from the next one.
|
|
14
|
+
|
|
8
15
|
## [4.104.3] - 2026-10-29
|
|
9
16
|
|
|
10
17
|
### Changed
|
package/README.md
CHANGED
|
@@ -452,6 +452,19 @@ const r = parseOwLink(text); // { form, world, worldIsSlug, type, id, lens, mome
|
|
|
452
452
|
|
|
453
453
|
A field that holds an address is text: never fetch or resolve it on the server, and show one wording ("private or missing") for a world you cannot read and an element that is not there. `parseOwLink` reads one string whole; finding a link inside other text is yours. The profile: [`profiles/address.md`](https://github.com/OnlyWorlds/schema-dist/blob/main/profiles/address.md), with its 133-case fixture, which is these functions' test.
|
|
454
454
|
|
|
455
|
+
### Open with
|
|
456
|
+
|
|
457
|
+
The rows of an "Open with" menu for a world or one of its elements: the site's page first, then each listed tool that has a link for it, in the tools list's order, each with the word it says when it cannot open now. `TOOLS` is the [OnlyWorlds tools list](https://github.com/OnlyWorlds/tools) as of this release.
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
import { openersFor, parseOwLink, TOOLS } from '@onlyworlds/sdk';
|
|
461
|
+
|
|
462
|
+
const rows = openersFor(TOOLS, 'element', parseOwLink(link), { audience: 'member', signedIn: false, tool: 'mytool' });
|
|
463
|
+
// [{ id: 'onlyworlds', name: 'onlyworlds.com', href, state: null }, { id: 'atlas', name: 'Atlas', href, state: 'Sign in to Atlas first' }, ...]
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
`surface` says what the page knows and nothing is guessed: `audience` (`member` or `public`; the public sees only rows that need nothing first), `signedIn` (`null` when the page cannot know, and then no row says so), `browser` (false in a desktop app), `phone`, and `tool`, the page's own client name, whose row says "You are here". Draw the rows as given; the words are decided here, so every surface says the same.
|
|
467
|
+
|
|
455
468
|
## Tokens
|
|
456
469
|
|
|
457
470
|
The account's token rating, which some OnlyWorlds tools use. `getStatus()` and `getEncryptionInfo()` are what keel still serves under `/tokens/`; `consume()`, `getAccessKey()` and the two session revokes are deprecated (keel answers 404) and leave in 5.0. To read the token rating, prefer `account.allowance()` above.
|
package/dist/index.d.ts
CHANGED
|
@@ -5556,6 +5556,86 @@ declare function elementAddress(address: OwAddress | OwAddressReading): string;
|
|
|
5556
5556
|
*/
|
|
5557
5557
|
declare function parseOwLink(text: string): OwAddressReading;
|
|
5558
5558
|
|
|
5559
|
+
/** What a person must have before a tool's link works: signed in to the tool (`account`), or the world already in the tool on this device (`device`). */
|
|
5560
|
+
type OwToolNeeds = 'account' | 'device';
|
|
5561
|
+
/** A tool's `open` in the tools list: its link templates and what they need first. */
|
|
5562
|
+
interface OwToolOpen {
|
|
5563
|
+
/** The link that opens a world, holding `{world}` (the world's id); null without one. */
|
|
5564
|
+
world: string | null;
|
|
5565
|
+
/** The link that opens one element, holding `{id}` and, if it needs them, `{world}` and `{type}` (the type word); null without one. */
|
|
5566
|
+
element: string | null;
|
|
5567
|
+
/** What the person needs first; null for nothing, which is the one kind of row a public page offers. */
|
|
5568
|
+
needs: OwToolNeeds | null;
|
|
5569
|
+
}
|
|
5570
|
+
/** The keys of one tools list row that `openersFor` reads; a row straight from `tools.json` carries more, and they are ignored. */
|
|
5571
|
+
interface OwTool {
|
|
5572
|
+
/** The list's id for the tool, the row's `id` in the menu. */
|
|
5573
|
+
id: string;
|
|
5574
|
+
name: string;
|
|
5575
|
+
url: string;
|
|
5576
|
+
/** The tool's client name (`X-OW-Client`), which a surface names itself by; null without one. */
|
|
5577
|
+
client: string | null;
|
|
5578
|
+
/** `listed` rows are offered; `built` and `delisted` rows never are. */
|
|
5579
|
+
rung: 'built' | 'listed' | 'delisted';
|
|
5580
|
+
/** How a link opens a world or an element in the tool; null: never offered. */
|
|
5581
|
+
open: OwToolOpen | null;
|
|
5582
|
+
}
|
|
5583
|
+
/** What the menu opens: a world, or one element of it. */
|
|
5584
|
+
type OwOpenerKind = 'world' | 'element';
|
|
5585
|
+
/** What the surface drawing the menu knows of itself and its reader. The function guesses none of it. */
|
|
5586
|
+
interface OwOpenerSurface {
|
|
5587
|
+
/** The client name of the surface's own tool, when it is a listed tool; its row says "You are here". */
|
|
5588
|
+
tool?: string | null;
|
|
5589
|
+
/** `member` (a seat in the world, a guest included) or `public` (the signed-out reader). Required. */
|
|
5590
|
+
audience: 'member' | 'public';
|
|
5591
|
+
/** Whether the reader is signed in; null or absent when the surface cannot know, and then no row says so. */
|
|
5592
|
+
signedIn?: boolean | null;
|
|
5593
|
+
/** False in a desktop app, which cannot see the browser's sign-in. Default true. */
|
|
5594
|
+
browser?: boolean;
|
|
5595
|
+
/** True on a phone. Default false. */
|
|
5596
|
+
phone?: boolean;
|
|
5597
|
+
}
|
|
5598
|
+
/** The word a row says when it cannot open now, or says where it lands. Sentence case, exactly. */
|
|
5599
|
+
type OwOpenerState = 'You are here' | `Sign in to ${string} first` | 'Opens in your browser' | 'Needs the world on this phone' | 'Opens the world';
|
|
5600
|
+
/** One row of the menu. */
|
|
5601
|
+
interface OwOpener {
|
|
5602
|
+
/** `onlyworlds` for the site's own row, else the tool's id in the list. */
|
|
5603
|
+
id: string;
|
|
5604
|
+
/** `onlyworlds.com`, or the tool's name. */
|
|
5605
|
+
name: string;
|
|
5606
|
+
href: string;
|
|
5607
|
+
/** Null when the row opens now and says nothing. */
|
|
5608
|
+
state: OwOpenerState | null;
|
|
5609
|
+
}
|
|
5610
|
+
/**
|
|
5611
|
+
* The rows of the Open with menu for a world (`kind: 'world'`) or one element of it (`'element'`), in
|
|
5612
|
+
* order: first the site's own row (id `onlyworlds`, name `onlyworlds.com`, the world's or the element's
|
|
5613
|
+
* page on www.onlyworlds.com, never a word, for every audience), then one row per `tools` row, in the
|
|
5614
|
+
* list's order, that is `listed` and has a door for this kind. `tools` is the tools list's rows, `TOOLS`
|
|
5615
|
+
* or the list as served; `address` is a reading from `parseOwLink` or what `elementAddress` takes, with
|
|
5616
|
+
* the world's id. A lens and a moment on it ride on no href.
|
|
5617
|
+
*
|
|
5618
|
+
* A row with `open: null`, or with no door for this kind, is not there. On an element, a tool with only
|
|
5619
|
+
* a world door is a row to its world door that says "Opens the world". For the `public` audience only
|
|
5620
|
+
* rows whose `open.needs` is null are there: a row that needs anything does not exist for the public.
|
|
5621
|
+
*
|
|
5622
|
+
* Each row's `state`, the first that holds: "You are here" for the surface's own tool (its `client` is
|
|
5623
|
+
* `surface.tool`); then what `needs` asks of this surface: `account` outside a browser "Opens in your
|
|
5624
|
+
* browser", in a browser signed out "Sign in to <name> first" (none when `signedIn` is null: a word shows
|
|
5625
|
+
* only when the surface knows it is true), `device` on a phone "Needs the world on this phone"; then
|
|
5626
|
+
* "Opens the world" (a world door on an element: a sign-in the row needs is the more urgent word); else null.
|
|
5627
|
+
*
|
|
5628
|
+
* Refuses with `OwAddressError` an address without a world (`no_world`) or with a slug or anything else
|
|
5629
|
+
* for its id (`bad_world`), and a type, id or pairing `elementAddress` refuses. A TypeError names the
|
|
5630
|
+
* rest: a `kind` that is neither, an element's openers asked of an address with no element, an unknown
|
|
5631
|
+
* key on the address or the surface, a missing or unknown `audience`, a surface value of the wrong type,
|
|
5632
|
+
* a tools row that is not one (a `needs` outside the list's format included).
|
|
5633
|
+
*/
|
|
5634
|
+
declare function openersFor(tools: readonly OwTool[], kind: OwOpenerKind, address: OwAddress | OwAddressReading, surface: OwOpenerSurface): OwOpener[];
|
|
5635
|
+
|
|
5636
|
+
/** The OnlyWorlds tools list's rows (format 1), in the list's order, as of this release: the keys openersFor reads. */
|
|
5637
|
+
declare const TOOLS: readonly OwTool[];
|
|
5638
|
+
|
|
5559
5639
|
/**
|
|
5560
5640
|
* The world file, `.owworld` (Folder Format spec §4.7; a `.zip` by another
|
|
5561
5641
|
* name): one archive holding one whole world as a portable copy (§4.1), and
|
|
@@ -6598,4 +6678,4 @@ declare class TokenResource {
|
|
|
6598
6678
|
getEncryptionInfo(): Promise<EncryptionInfo>;
|
|
6599
6679
|
}
|
|
6600
6680
|
|
|
6601
|
-
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 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 OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, 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 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 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 OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, 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 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, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, 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, 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, lensesInUse, lookupWorld, monthStartSteps, nfc, noteOf, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
|
|
6681
|
+
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 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 OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, 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 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 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 OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, 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 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, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, 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, 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, lensesInUse, lookupWorld, monthStartSteps, nfc, noteOf, openersFor, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, readingAidOf, recipientsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
|
package/dist/index.js
CHANGED
|
@@ -2219,17 +2219,17 @@ function xhrUpload(XHR, url, headers, body, total, onProgress) {
|
|
|
2219
2219
|
last = loaded;
|
|
2220
2220
|
onProgress(loaded, total);
|
|
2221
2221
|
};
|
|
2222
|
-
const
|
|
2222
|
+
const fail2 = (why) => () => reject(new OwNetworkError(`OnlyWorlds file upload failed: POST ${url}`, new Error(why)));
|
|
2223
2223
|
xhr.open("POST", url);
|
|
2224
2224
|
for (const [k, v] of Object.entries(headers)) xhr.setRequestHeader(k, v);
|
|
2225
2225
|
if (xhr.upload) xhr.upload.onprogress = (e) => report(Math.min(e.loaded, total));
|
|
2226
|
-
xhr.onerror =
|
|
2227
|
-
xhr.onabort =
|
|
2228
|
-
xhr.ontimeout =
|
|
2226
|
+
xhr.onerror = fail2("network error");
|
|
2227
|
+
xhr.onabort = fail2("aborted");
|
|
2228
|
+
xhr.ontimeout = fail2("timed out");
|
|
2229
2229
|
xhr.onload = () => {
|
|
2230
2230
|
const status = xhr.status;
|
|
2231
2231
|
if (!status) {
|
|
2232
|
-
|
|
2232
|
+
fail2("no answer")();
|
|
2233
2233
|
return;
|
|
2234
2234
|
}
|
|
2235
2235
|
const ok = status >= 200 && status < 300;
|
|
@@ -5241,6 +5241,99 @@ function parseOwLink(text2) {
|
|
|
5241
5241
|
return { form, world, worldIsSlug, type, id, lens, moment, canonical };
|
|
5242
5242
|
}
|
|
5243
5243
|
|
|
5244
|
+
// src/openers.ts
|
|
5245
|
+
var SURFACE_KEYS = ["tool", "audience", "signedIn", "browser", "phone"];
|
|
5246
|
+
var NEEDS = ["account", "device", null];
|
|
5247
|
+
var PLACEHOLDER = /\{(world|type|id)\}/g;
|
|
5248
|
+
var fail = (what) => {
|
|
5249
|
+
throw new TypeError(`openersFor: ${what}`);
|
|
5250
|
+
};
|
|
5251
|
+
function templateOf(row, key, v) {
|
|
5252
|
+
if (v === void 0 || v === null) return null;
|
|
5253
|
+
return typeof v === "string" ? v : fail(`tool ${row}: open.${key} is a link template or null`);
|
|
5254
|
+
}
|
|
5255
|
+
function openersFor(tools, kind, address, surface) {
|
|
5256
|
+
if (!Array.isArray(tools)) fail("tools is the tools list's rows, an array");
|
|
5257
|
+
if (kind !== "world" && kind !== "element") fail(`kind is 'world' or 'element'; got ${JSON.stringify(kind)}`);
|
|
5258
|
+
if (address === null || typeof address !== "object" || Array.isArray(address)) {
|
|
5259
|
+
fail("the address is an object ({ form, world, type, id }), as parseOwLink reads it");
|
|
5260
|
+
}
|
|
5261
|
+
refuseUnknownOptions("openersFor", address, ADDRESS_KEYS);
|
|
5262
|
+
const a = address;
|
|
5263
|
+
const page = elementAddress({ form: "human", world: a.world, type: a.type, id: a.id });
|
|
5264
|
+
const world = a.world.toLowerCase();
|
|
5265
|
+
const hasElement = a.type !== void 0 && a.type !== null;
|
|
5266
|
+
if (kind === "element" && !hasElement) fail("an element's openers need an address with its type and id");
|
|
5267
|
+
const type = hasElement ? a.type : "";
|
|
5268
|
+
const id = hasElement ? a.id.toLowerCase() : "";
|
|
5269
|
+
if (surface === null || typeof surface !== "object" || Array.isArray(surface)) fail("the surface is an object ({ audience, ... })");
|
|
5270
|
+
refuseUnknownOptions("openersFor", surface, SURFACE_KEYS);
|
|
5271
|
+
const { tool = null, audience, signedIn = null, browser = true, phone = false } = surface;
|
|
5272
|
+
if (audience !== "member" && audience !== "public") fail(`surface.audience is 'member' or 'public'; got ${JSON.stringify(audience)}`);
|
|
5273
|
+
if (tool !== null && typeof tool !== "string") fail("surface.tool is a client name or null");
|
|
5274
|
+
if (signedIn !== null && typeof signedIn !== "boolean") fail("surface.signedIn is true, false or null");
|
|
5275
|
+
if (typeof browser !== "boolean") fail("surface.browser is a boolean");
|
|
5276
|
+
if (typeof phone !== "boolean") fail("surface.phone is a boolean");
|
|
5277
|
+
const values = { world, type, id };
|
|
5278
|
+
const fill = (template) => template.replace(PLACEHOLDER, (_, n) => values[n]);
|
|
5279
|
+
const rows = [
|
|
5280
|
+
{ id: "onlyworlds", name: "onlyworlds.com", href: kind === "element" ? page : elementAddress({ form: "human", world }), state: null }
|
|
5281
|
+
];
|
|
5282
|
+
for (const r of tools) {
|
|
5283
|
+
if (r === null || typeof r !== "object" || typeof r.id !== "string" || typeof r.name !== "string") {
|
|
5284
|
+
fail("each tools row is an object with an id and a name");
|
|
5285
|
+
}
|
|
5286
|
+
const open = r.open;
|
|
5287
|
+
if (open === null || open === void 0) continue;
|
|
5288
|
+
if (typeof open !== "object" || Array.isArray(open)) fail(`tool ${r.id}: open is an object or null`);
|
|
5289
|
+
const o = open;
|
|
5290
|
+
const worldDoor = templateOf(r.id, "world", o.world);
|
|
5291
|
+
const elementDoor = templateOf(r.id, "element", o.element);
|
|
5292
|
+
const needs = o.needs === void 0 ? null : o.needs;
|
|
5293
|
+
if (!NEEDS.includes(needs)) fail(`tool ${r.id}: open.needs is 'account', 'device' or null; got ${JSON.stringify(needs)}`);
|
|
5294
|
+
if (r.rung !== "listed") continue;
|
|
5295
|
+
if (audience === "public" && needs !== null) continue;
|
|
5296
|
+
const template = kind === "element" ? elementDoor ?? worldDoor : worldDoor;
|
|
5297
|
+
if (template === null) continue;
|
|
5298
|
+
let state = null;
|
|
5299
|
+
if (tool !== null && r.client === tool) state = "You are here";
|
|
5300
|
+
else if (needs === "account" && !browser) state = "Opens in your browser";
|
|
5301
|
+
else if (needs === "account" && signedIn === false) state = `Sign in to ${r.name} first`;
|
|
5302
|
+
else if (needs === "device" && phone) state = "Needs the world on this phone";
|
|
5303
|
+
else if (kind === "element" && elementDoor === null) state = "Opens the world";
|
|
5304
|
+
rows.push({ id: r.id, name: r.name, href: fill(template), state });
|
|
5305
|
+
}
|
|
5306
|
+
return rows;
|
|
5307
|
+
}
|
|
5308
|
+
|
|
5309
|
+
// src/tools.generated.ts
|
|
5310
|
+
var TOOLS = [
|
|
5311
|
+
{
|
|
5312
|
+
"id": "atlas",
|
|
5313
|
+
"name": "Atlas",
|
|
5314
|
+
"url": "https://atlas.onlyworlds.com",
|
|
5315
|
+
"client": "atlas",
|
|
5316
|
+
"rung": "listed",
|
|
5317
|
+
"open": {
|
|
5318
|
+
"world": "https://atlas.onlyworlds.com/#/open/{world}",
|
|
5319
|
+
"element": "https://atlas.onlyworlds.com/#/open/{world}/element/{id}",
|
|
5320
|
+
"needs": "account"
|
|
5321
|
+
}
|
|
5322
|
+
},
|
|
5323
|
+
{
|
|
5324
|
+
"id": "lantern",
|
|
5325
|
+
"name": "Lantern",
|
|
5326
|
+
"url": "https://lantern.onlyworlds.com",
|
|
5327
|
+
"client": "lantern",
|
|
5328
|
+
"rung": "listed",
|
|
5329
|
+
"open": {
|
|
5330
|
+
"world": "https://lantern.onlyworlds.com/#/open/{world}",
|
|
5331
|
+
"element": "https://lantern.onlyworlds.com/#/open/{world}/element/{id}",
|
|
5332
|
+
"needs": "account"
|
|
5333
|
+
}
|
|
5334
|
+
}
|
|
5335
|
+
];
|
|
5336
|
+
|
|
5244
5337
|
// src/lookup.ts
|
|
5245
5338
|
var LOOKUP_OPTION_KEYS = ["limit"];
|
|
5246
5339
|
var RENDER_OPTION_KEYS = ["descMax", "linkMax", "incomingMax"];
|
|
@@ -6840,6 +6933,7 @@ export {
|
|
|
6840
6933
|
REVIEW_PROPOSED_LABEL,
|
|
6841
6934
|
ROOM_PAIRS,
|
|
6842
6935
|
SPATIAL_TYPES,
|
|
6936
|
+
TOOLS,
|
|
6843
6937
|
TokenResource,
|
|
6844
6938
|
WORLD_FILE_MAX_BYTES,
|
|
6845
6939
|
WORLD_FILE_MAX_ENTRIES,
|
|
@@ -6898,6 +6992,7 @@ export {
|
|
|
6898
6992
|
monthStartSteps,
|
|
6899
6993
|
nfc,
|
|
6900
6994
|
noteOf,
|
|
6995
|
+
openersFor,
|
|
6901
6996
|
outDegreeOf,
|
|
6902
6997
|
parseDate,
|
|
6903
6998
|
parseErrorEnvelope,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlyworlds/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.105.0",
|
|
4
4
|
"description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
25
25
|
"pretest": "npm run build",
|
|
26
26
|
"test": "node --test",
|
|
27
|
-
"codegen": "python codegen/generate_types.py",
|
|
28
|
-
"codegen:check": "python codegen/generate_types.py --check",
|
|
27
|
+
"codegen": "python codegen/generate_types.py && node codegen/tools.mjs",
|
|
28
|
+
"codegen:check": "python codegen/generate_types.py --check && node codegen/tools.mjs --check",
|
|
29
29
|
"schema:verify": "python codegen/verify_dist.py",
|
|
30
30
|
"schema:check": "npm run schema:verify && npm run codegen:check",
|
|
31
31
|
"prepublishOnly": "npm run build",
|