@onlyworlds/sdk 4.117.1 → 4.118.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/CHANGELOG.md +17 -0
- package/README.md +2 -2
- package/dist/{chunk-CH3ITUSR.js → chunk-2FAAOQVM.js} +11 -6
- package/dist/index.d.ts +13 -8
- package/dist/index.js +1 -1
- package/dist/waymark.css +56 -2
- package/dist/waymark.d.ts +11 -3
- package/dist/waymark.js +61 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ earlier history lives in git log only.
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [4.118.0] - 2026-10-30
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **`openersFor` takes `online` on the surface.** With `online: false`, every row whose href is a web address (its scheme `http:` or `https:`, read from the row's own filled href) says "Needs a connection", the site's own `onlyworlds` row included, which had no word before. The words in order, the first that holds: "You are here" for the surface's own tool, then "Needs a connection", then the account, browser and phone words, then "Opens the world"; so offline, a row that needed a sign-in says the connection. A row whose link opens an app on the device (any other scheme) keeps its own word, and every row keeps its href. `online` defaults to true, which gives the rows as before; anything but `true` or `false` is a TypeError naming it. `OwOpenerState` gains the word. The shared fixture gains nine cases (54; the same bytes as the Python package's).
|
|
13
|
+
- **The Waymark draws the offline row.** At each open it reads `navigator.onLine` (no navigator reads as online) and draws the rows `openersFor` gives for it. Offline, a row that says "Needs a connection" is grey (`ow-waymark__row--cannot`, no new style) and is a link with no href and `aria-disabled="true"`, still a menu item in the arrow and Tab order; a click, Enter or Space on it does nothing, and the fan-out stays open. While the fan-out is open it listens to the window's `online` and `offline` events and redraws the rows in place: focus on a row stays on that row, and nothing else moves. The listeners go when it closes. Copy link is unchanged. No new option.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **The Waymark's sheet and its toast clear a phone's safe area.** On a page with `viewport-fit=cover`, an iPhone's home indicator covered the lower part of the sheet's last row (Copy link) and the "Link copied" toast. The sheet's bottom padding is now `calc(18px + env(safe-area-inset-bottom, 0px))` and the toast sits at `calc(24px + env(safe-area-inset-bottom, 0px))`, at 480 px and below and in the sheet a narrow box takes alike. On a page without `viewport-fit=cover` the inset is 0 and nothing moves.
|
|
18
|
+
|
|
19
|
+
## [4.117.2] - 2026-10-30
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- **The Waymark opens as the sheet when neither side fits.** Wider than 480 px, a fan-out whose start would cross the right edge of the box that clips it and whose end would cross its left edge (a mark in the middle of a narrow window, or of a narrow pane) took the side that crossed less and still left the box: in a 481 px window, a mark at 196 to 235 px opened its 300 px pop from 187 to 487, 6 px past the edge. The same holds for below and above. Now the open puts `ow-waymark--sheet` on the wrapper and the stylesheet draws the sheet from the bottom, the layout it already draws at 480 px and below (rows at least 44 px, the page behind dimmed), and no side class is set. A side is taken only where it fits, so `--end` and `--up` mean the pop lies inside the box. "Link copied", shown after the fan-out closes, keeps the sheet's place until it hides. The sheet's rules under the class are the media block's, declaration for declaration, held by a test. No node carries a style attribute.
|
|
24
|
+
|
|
8
25
|
## [4.117.1] - 2026-10-30
|
|
9
26
|
|
|
10
27
|
### Changed
|
package/README.md
CHANGED
|
@@ -471,7 +471,7 @@ const rows = openersFor(TOOLS, 'element', parseOwLink(link), { audience: 'member
|
|
|
471
471
|
// [{ id: 'onlyworlds', name: 'onlyworlds.com', href, state: null }, { id: 'atlas', name: 'Atlas', href, state: 'Sign in to Atlas first' }, ...]
|
|
472
472
|
```
|
|
473
473
|
|
|
474
|
-
`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.
|
|
474
|
+
`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`, `online` (false with no connection: every row whose link is a web address then says "Needs a connection"), 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.
|
|
475
475
|
|
|
476
476
|
### The Waymark: Open with, beside a name
|
|
477
477
|
|
|
@@ -491,7 +491,7 @@ const dispose = mountWaymark(document.querySelector('h1.name'), {
|
|
|
491
491
|
// later: dispose() removes every node, listener and timer it added
|
|
492
492
|
```
|
|
493
493
|
|
|
494
|
-
What it draws is decided in the core, never in the component: the rows and their words are `openersFor`'s, a member's "Last shaped in Atlas, 12 Oct" line is `doorsOf`'s newest entry in `doorWhere`'s words with its date, and Copy link copies `elementAddress`'s site address with the world's id (never a slug) and says "Link copied". When the page has no clipboard or the copy is refused, the fan-out stays open and the toast says "Could not copy the link." over the same address in a read-only line, selected for a copy by hand; it stays until the fan-out closes or Escape. The public face (`reader: 'public'`) shows the name and type, only the rows that need nothing first, and Copy link: no last door, no lenses. A row that cannot open now says why ("Sign in to Atlas first", "Needs the world on this phone") and is grey; grey means nothing else. The page's own tool says "You are here", and its row leads nowhere: a button with `aria-current="page"`, not a link, which closes the fan-out and returns focus to what opened it.
|
|
494
|
+
What it draws is decided in the core, never in the component: the rows and their words are `openersFor`'s, a member's "Last shaped in Atlas, 12 Oct" line is `doorsOf`'s newest entry in `doorWhere`'s words with its date, and Copy link copies `elementAddress`'s site address with the world's id (never a slug) and says "Link copied". When the page has no clipboard or the copy is refused, the fan-out stays open and the toast says "Could not copy the link." over the same address in a read-only line, selected for a copy by hand; it stays until the fan-out closes or Escape. The public face (`reader: 'public'`) shows the name and type, only the rows that need nothing first, and Copy link: no last door, no lenses. A row that cannot open now says why ("Sign in to Atlas first", "Needs the world on this phone", "Needs a connection") and is grey; grey means nothing else. The connection is read from `navigator.onLine` at each open, and while the fan-out is open its rows follow the window's `online` and `offline` events; offline, a web row is a link with no href, `aria-disabled="true"`, that does nothing when pressed. The page's own tool says "You are here", and its row leads nowhere: a button with `aria-current="page"`, not a link, which closes the fan-out and returns focus to what opened it.
|
|
495
495
|
|
|
496
496
|
Options, each refused by name when unknown, before anything is drawn: `world` (its `x_names`, when present, words the type), `element`, `reader`, `tool`, `signedIn`, `browser`, `phone`, `tools` (default `TOOLS`), `lenses` (`[{ id, name }]`, the Through row; absent, no row; a lens chosen rides on the copied link as `?lens=`), `ground`, `entry` and `returnFocus`.
|
|
497
497
|
|
|
@@ -1234,9 +1234,11 @@ function parseOwLink(text) {
|
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
1236
1236
|
// src/openers.ts
|
|
1237
|
-
var SURFACE_KEYS = ["tool", "audience", "signedIn", "browser", "phone"];
|
|
1237
|
+
var SURFACE_KEYS = ["tool", "audience", "signedIn", "browser", "phone", "online"];
|
|
1238
1238
|
var NEEDS = ["account", "device", null];
|
|
1239
1239
|
var PLACEHOLDER = /\{(world|type|id)\}/g;
|
|
1240
|
+
var WEB = /^https?:/i;
|
|
1241
|
+
var OFFLINE = "Needs a connection";
|
|
1240
1242
|
var fail = (what) => {
|
|
1241
1243
|
throw new TypeError(`openersFor: ${what}`);
|
|
1242
1244
|
};
|
|
@@ -1261,17 +1263,18 @@ function openersFor(tools, kind, address, surface) {
|
|
|
1261
1263
|
const id = hasElement ? a.id.toLowerCase() : "";
|
|
1262
1264
|
if (surface === null || typeof surface !== "object" || Array.isArray(surface)) fail("the surface is an object ({ audience, ... })");
|
|
1263
1265
|
refuseUnknownOptions("openersFor", surface, SURFACE_KEYS);
|
|
1264
|
-
const { tool = null, audience, signedIn = null, browser = true, phone = false } = surface;
|
|
1266
|
+
const { tool = null, audience, signedIn = null, browser = true, phone = false, online = true } = surface;
|
|
1265
1267
|
if (audience !== "member" && audience !== "public") fail(`surface.audience is 'member' or 'public'; got ${JSON.stringify(audience)}`);
|
|
1266
1268
|
if (tool !== null && typeof tool !== "string") fail("surface.tool is a client name or null");
|
|
1267
1269
|
if (signedIn !== null && typeof signedIn !== "boolean") fail("surface.signedIn is true, false or null");
|
|
1268
1270
|
if (typeof browser !== "boolean") fail("surface.browser is a boolean");
|
|
1269
1271
|
if (typeof phone !== "boolean") fail("surface.phone is a boolean");
|
|
1272
|
+
if (typeof online !== "boolean") fail("surface.online is a boolean");
|
|
1270
1273
|
const values = { world, type, id };
|
|
1271
1274
|
const fill = (template) => template.replace(PLACEHOLDER, (_, n) => values[n]);
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1274
|
-
];
|
|
1275
|
+
const offline = (href) => !online && WEB.test(href);
|
|
1276
|
+
const site = kind === "element" ? page : elementAddress({ form: "human", world });
|
|
1277
|
+
const rows = [{ id: "onlyworlds", name: "onlyworlds.com", href: site, state: offline(site) ? OFFLINE : null }];
|
|
1275
1278
|
for (const r of tools) {
|
|
1276
1279
|
if (r === null || typeof r !== "object" || typeof r.id !== "string" || typeof r.name !== "string") {
|
|
1277
1280
|
fail("each tools row is an object with an id and a name");
|
|
@@ -1288,13 +1291,15 @@ function openersFor(tools, kind, address, surface) {
|
|
|
1288
1291
|
if (audience === "public" && needs !== null) continue;
|
|
1289
1292
|
const template = kind === "element" ? elementDoor ?? worldDoor : worldDoor;
|
|
1290
1293
|
if (template === null) continue;
|
|
1294
|
+
const href = fill(template);
|
|
1291
1295
|
let state = null;
|
|
1292
1296
|
if (tool !== null && r.client === tool) state = "You are here";
|
|
1297
|
+
else if (offline(href)) state = OFFLINE;
|
|
1293
1298
|
else if (needs === "account" && !browser) state = "Opens in your browser";
|
|
1294
1299
|
else if (needs === "account" && signedIn === false) state = `Sign in to ${r.name} first`;
|
|
1295
1300
|
else if (needs === "device" && phone) state = "Needs the world on this phone";
|
|
1296
1301
|
else if (kind === "element" && elementDoor === null) state = "Opens the world";
|
|
1297
|
-
rows.push({ id: r.id, name: r.name, href
|
|
1302
|
+
rows.push({ id: r.id, name: r.name, href, state });
|
|
1298
1303
|
}
|
|
1299
1304
|
return rows;
|
|
1300
1305
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5624,9 +5624,11 @@ interface OwOpenerSurface {
|
|
|
5624
5624
|
browser?: boolean;
|
|
5625
5625
|
/** True on a phone. Default false. */
|
|
5626
5626
|
phone?: boolean;
|
|
5627
|
+
/** False when the device has no connection; then every row whose link is a web address says "Needs a connection". Default true. */
|
|
5628
|
+
online?: boolean;
|
|
5627
5629
|
}
|
|
5628
5630
|
/** The word a row says when it cannot open now, or says where it lands. Sentence case, exactly. */
|
|
5629
|
-
type OwOpenerState = 'You are here' | `Sign in to ${string} first` | 'Opens in your browser' | 'Needs the world on this phone' | 'Opens the world';
|
|
5631
|
+
type OwOpenerState = 'You are here' | 'Needs a connection' | `Sign in to ${string} first` | 'Opens in your browser' | 'Needs the world on this phone' | 'Opens the world';
|
|
5630
5632
|
/** One row of the menu. */
|
|
5631
5633
|
interface OwOpener {
|
|
5632
5634
|
/** `onlyworlds` for the site's own row, else the tool's id in the list. */
|
|
@@ -5640,19 +5642,22 @@ interface OwOpener {
|
|
|
5640
5642
|
/**
|
|
5641
5643
|
* The rows of the Open with menu for a world (`kind: 'world'`) or one element of it (`'element'`), in
|
|
5642
5644
|
* order: first the site's own row (id `onlyworlds`, name `onlyworlds.com`, the world's or the element's
|
|
5643
|
-
* page on www.onlyworlds.com,
|
|
5644
|
-
* list's order, that is `listed` and has a door for this kind. `tools`
|
|
5645
|
-
* or the list as served; `address` is a reading from `parseOwLink` or
|
|
5646
|
-
* the world's id. A lens and a moment on it ride on no href.
|
|
5645
|
+
* page on www.onlyworlds.com, for every audience, its one word "Needs a connection" when offline), then
|
|
5646
|
+
* one row per `tools` row, in the list's order, that is `listed` and has a door for this kind. `tools`
|
|
5647
|
+
* is the tools list's rows, `TOOLS` or the list as served; `address` is a reading from `parseOwLink` or
|
|
5648
|
+
* what `elementAddress` takes, with the world's id. A lens and a moment on it ride on no href.
|
|
5647
5649
|
*
|
|
5648
5650
|
* A row with `open: null`, or with no door for this kind, is not there. On an element, a tool with only
|
|
5649
5651
|
* a world door is a row to its world door that says "Opens the world". For the `public` audience only
|
|
5650
5652
|
* rows whose `open.needs` is null are there: a row that needs anything does not exist for the public.
|
|
5651
5653
|
*
|
|
5652
5654
|
* Each row's `state`, the first that holds: "You are here" for the surface's own tool (its `client` is
|
|
5653
|
-
* `surface.tool`); then
|
|
5654
|
-
*
|
|
5655
|
-
*
|
|
5655
|
+
* `surface.tool`); then, when `surface.online` is false, "Needs a connection" for a row whose href is a
|
|
5656
|
+
* web address (scheme `http:` or `https:`; a row whose link opens an app on the device is unaffected,
|
|
5657
|
+
* and the href stays in the row either way); then what `needs` asks of this surface: `account` outside
|
|
5658
|
+
* a browser "Opens in your browser", in a browser signed out "Sign in to <name> first" (none when
|
|
5659
|
+
* `signedIn` is null: a word shows only when the surface knows it is true), `device` on a phone "Needs
|
|
5660
|
+
* the world on this phone"; then
|
|
5656
5661
|
* "Opens the world" (a world door on an element: a sign-in the row needs is the more urgent word); else null.
|
|
5657
5662
|
*
|
|
5658
5663
|
* Refuses with `OwAddressError` whatever `elementAddress` refuses of the whole address, in its own form
|
package/dist/index.js
CHANGED
package/dist/waymark.css
CHANGED
|
@@ -328,6 +328,60 @@
|
|
|
328
328
|
outline-offset: 1px;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
+
/* Wider than 480 px, when neither side of an axis fits the box that clips the fan-out (a mark
|
|
332
|
+
mid-window in a narrow window, or in a narrow pane): the same sheet as below, by the class the open
|
|
333
|
+
puts on the wrapper. Each rule here is the media block's, declaration for declaration. */
|
|
334
|
+
.ow-waymark--sheet .ow-waymark__scrim {
|
|
335
|
+
display: block;
|
|
336
|
+
position: fixed;
|
|
337
|
+
inset: 0;
|
|
338
|
+
z-index: 999;
|
|
339
|
+
background: var(--ow-waymark-page);
|
|
340
|
+
opacity: 0.6;
|
|
341
|
+
}
|
|
342
|
+
.ow-waymark--sheet .ow-waymark__pop {
|
|
343
|
+
position: fixed;
|
|
344
|
+
top: auto;
|
|
345
|
+
right: 0;
|
|
346
|
+
bottom: 0;
|
|
347
|
+
left: 0;
|
|
348
|
+
width: auto;
|
|
349
|
+
max-width: none;
|
|
350
|
+
max-height: 85vh;
|
|
351
|
+
overflow-y: auto;
|
|
352
|
+
padding: 8px 14px calc(18px + env(safe-area-inset-bottom, 0px));
|
|
353
|
+
border-width: 1px 0 0;
|
|
354
|
+
border-radius: 18px 18px 0 0;
|
|
355
|
+
box-shadow: none;
|
|
356
|
+
}
|
|
357
|
+
.ow-waymark--sheet .ow-waymark__grab {
|
|
358
|
+
display: block;
|
|
359
|
+
width: 40px;
|
|
360
|
+
height: 4px;
|
|
361
|
+
margin: 0 auto 8px;
|
|
362
|
+
border-radius: 2px;
|
|
363
|
+
background: var(--ow-waymark-line);
|
|
364
|
+
}
|
|
365
|
+
.ow-waymark--sheet .ow-waymark__row {
|
|
366
|
+
min-height: 44px;
|
|
367
|
+
padding: 12px 6px;
|
|
368
|
+
font-size: 15px;
|
|
369
|
+
}
|
|
370
|
+
.ow-waymark--sheet .ow-waymark__row--lens {
|
|
371
|
+
padding-left: 30px;
|
|
372
|
+
}
|
|
373
|
+
.ow-waymark--sheet .ow-waymark__toast {
|
|
374
|
+
position: fixed;
|
|
375
|
+
top: auto;
|
|
376
|
+
bottom: calc(24px + env(safe-area-inset-bottom, 0px));
|
|
377
|
+
left: 50%;
|
|
378
|
+
transform: translateX(-50%);
|
|
379
|
+
}
|
|
380
|
+
.ow-waymark--sheet .ow-waymark__pop:not([hidden]) ~ .ow-waymark__toast {
|
|
381
|
+
top: 16px;
|
|
382
|
+
bottom: auto;
|
|
383
|
+
}
|
|
384
|
+
|
|
331
385
|
/* 480 px wide and below: a sheet from the bottom, the page behind dimmed, rows tall enough to touch.
|
|
332
386
|
Portrait phones run to about 430 px, so every one gets the sheet with room to spare, and so does a
|
|
333
387
|
desktop window as narrow: by width alone, whatever the pointer. */
|
|
@@ -350,7 +404,7 @@
|
|
|
350
404
|
max-width: none;
|
|
351
405
|
max-height: 85vh;
|
|
352
406
|
overflow-y: auto;
|
|
353
|
-
padding: 8px 14px 18px;
|
|
407
|
+
padding: 8px 14px calc(18px + env(safe-area-inset-bottom, 0px));
|
|
354
408
|
border-width: 1px 0 0;
|
|
355
409
|
border-radius: 18px 18px 0 0;
|
|
356
410
|
box-shadow: none;
|
|
@@ -375,7 +429,7 @@
|
|
|
375
429
|
.ow-waymark__toast {
|
|
376
430
|
position: fixed;
|
|
377
431
|
top: auto;
|
|
378
|
-
bottom: 24px;
|
|
432
|
+
bottom: calc(24px + env(safe-area-inset-bottom, 0px));
|
|
379
433
|
left: 50%;
|
|
380
434
|
transform: translateX(-50%);
|
|
381
435
|
}
|
package/dist/waymark.d.ts
CHANGED
|
@@ -88,6 +88,13 @@ interface OwWaymark {
|
|
|
88
88
|
* The surface's own row (the `tool` option's, "You are here") leads nowhere: a button with
|
|
89
89
|
* `aria-current="page"` and no link, which closes the fan-out and returns focus to what opened it.
|
|
90
90
|
*
|
|
91
|
+
* The connection is read at each open (`navigator.onLine`; no navigator reads as online), and the rows
|
|
92
|
+
* drawn for it: offline, every row whose link is a web address says "Needs a connection" (`openersFor`
|
|
93
|
+
* with `online: false`) and is drawn grey (`ow-waymark__row--cannot`) as a link with no href,
|
|
94
|
+
* `aria-disabled="true"`, still in the arrow and Tab order; pressing it (a click, Enter or Space) does
|
|
95
|
+
* nothing and the fan-out stays open. While the fan-out is open, the window's `online` and `offline`
|
|
96
|
+
* events redraw the rows in place, and focus on a row stays on that row. Copy link is unaffected.
|
|
97
|
+
*
|
|
91
98
|
* Keyboard: the mark is a button and the fan-out a menu; Tab goes from the mark through the rows in
|
|
92
99
|
* order, the arrow keys, Home and End move within it, Escape closes it and returns focus to what opened
|
|
93
100
|
* it: the mark, or for the entry `returnFocus` when given (the surface's "..." button, which stays
|
|
@@ -98,9 +105,10 @@ interface OwWaymark {
|
|
|
98
105
|
* Placement: below the name at its start, unless it would cross the box that clips it (the nearest
|
|
99
106
|
* ancestor of `target` whose overflow on that axis is not visible, within the window, else the window):
|
|
100
107
|
* measured at each open, it then opens at the name's end (class `ow-waymark__pop--end`) or above the
|
|
101
|
-
* name (`ow-waymark__pop--up`), where that side
|
|
102
|
-
*
|
|
103
|
-
*
|
|
108
|
+
* name (`ow-waymark__pop--up`), where that side fits; the toast takes the same side. When neither side
|
|
109
|
+
* of an axis fits (a mark mid-window in a narrow window, or in a narrow pane), it opens as the sheet
|
|
110
|
+
* from the bottom (class `ow-waymark--sheet` on the wrapper). At 480 px wide and below (every portrait
|
|
111
|
+
* phone, and a desktop window as narrow) the stylesheet draws it as that sheet, and no side is chosen. The page must load `@onlyworlds/sdk/waymark.css`; no
|
|
104
112
|
* node carries a style attribute.
|
|
105
113
|
*
|
|
106
114
|
* Refuses, before anything is drawn, an unknown option key by name and a value of the wrong kind (a
|
package/dist/waymark.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
openersFor,
|
|
7
7
|
refuseUnknownOptions,
|
|
8
8
|
typeWord
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2FAAOQVM.js";
|
|
10
10
|
|
|
11
11
|
// src/waymark/glyphs.ts
|
|
12
12
|
var MARK_PATH = "M48.8 0.0 43.8 0.4 39.0 1.2 36.0 2.0 33.2 2.9 29.3 4.5 24.8 6.8 20.6 9.5 17.0 12.4 13.6 15.7 10.4 19.4 7.8 23.1 5.8 26.6 4.5 29.3 3.3 32.1 1.8 36.8 0.8 41.2 0.1 46.3 0.0 51.1 0.4 56.2 1.2 61.0 2.0 63.9 2.9 66.8 4.5 70.7 6.8 75.2 9.5 79.4 12.4 82.9 15.7 86.3 19.4 89.5 23.1 92.1 26.6 94.2 29.3 95.5 32.1 96.7 36.8 98.2 41.2 99.2 46.3 99.8 51.1 100.0 56.2 99.6 61.0 98.8 63.9 98.0 66.8 97.1 70.7 95.5 75.2 93.2 79.4 90.4 82.9 87.6 86.3 84.3 89.5 80.5 92.1 76.9 94.2 73.4 95.5 70.7 96.7 67.9 98.2 63.2 99.2 58.7 99.8 53.7 100.0 48.8 99.6 43.8 98.6 38.4 97.1 33.2 95.5 29.3 93.2 24.8 90.4 20.6 87.6 17.0 84.3 13.6 80.5 10.4 76.9 7.8 73.4 5.8 70.7 4.5 67.9 3.3 63.2 1.8 58.7 0.8 53.7 0.1ZM77.5 80.7 74.1 83.4 70.7 85.7 67.0 87.5 64.5 88.6 64.1 88.7 65.7 86.3 67.1 83.9 68.7 80.7 69.9 77.6 72.7 78.5 73.0 78.4ZM22.5 80.7 25.6 79.0 27.3 78.3 30.0 77.6 31.3 80.7 32.8 83.9 34.2 86.3 35.9 88.7 32.9 87.5 29.3 85.7 25.8 83.4ZM51.2 74.5 55.1 74.7 59.9 75.2 64.2 76.0 67.5 76.9 66.0 80.5 64.2 84.0 62.0 87.4 59.6 90.1 55.1 90.9 52.2 91.2 51.2 91.1ZM48.7 74.5 48.8 91.1 47.7 91.2 44.9 90.9 40.3 90.1 38.2 87.8 36.3 85.0 34.2 81.2 32.5 77.0 35.8 76.0 40.5 75.2 44.5 74.7ZM91.1 51.2 91.1 52.9 90.8 56.3 90.1 59.7 89.3 62.5 88.5 64.8 87.2 67.7 85.7 70.7 83.9 73.4 82.0 75.9 79.4 78.9 76.3 77.2 73.8 76.1 76.2 68.8 77.8 62.7 78.7 56.8 79.0 51.2ZM55.8 51.2 67.7 51.2 67.6 55.1 67.2 59.0 66.7 61.5 65.7 65.0 61.0 64.2 55.7 63.6ZM32.5 51.2 44.5 51.2 44.4 63.6 39.7 64.1 34.5 65.0 33.5 61.3 32.9 58.1 32.5 54.2ZM8.8 51.2 21.0 51.2 21.0 53.3 21.4 56.6 22.7 64.0 23.8 68.4 25.0 72.1 26.6 75.9 23.7 77.2 20.6 78.9 18.5 76.7 16.5 74.1 14.8 71.5 13.4 69.1 12.1 66.3 11.0 63.6 10.1 60.5 9.4 57.3 8.9 53.5 8.8 51.3ZM36.2 27.0 39.5 27.5 44.5 28.2 44.4 48.8 32.4 48.7 32.8 44.5 33.6 39.1 35.0 32.0ZM63.9 26.9 65.2 32.1 66.6 39.2 67.4 44.8 67.7 48.7 55.8 48.8 55.7 28.1 60.5 27.5ZM74.8 23.4 76.9 22.5 79.4 21.1 82.0 24.0 84.8 27.8 86.2 30.3 87.5 32.9 88.6 35.4 89.5 38.1 90.3 41.2 90.8 44.0 91.1 47.0 91.1 48.8 79.0 48.7 78.7 44.6 78.0 39.3 76.5 31.2 74.7 23.5ZM25.5 23.5 25.5 23.7 24.5 26.8 23.7 30.2 22.4 36.6 21.5 42.5 21.1 48.7 8.8 48.8 8.8 47.0 9.2 43.7 9.8 40.8 10.5 38.1 11.5 35.2 12.4 32.9 13.8 30.2 15.2 27.8 17.9 24.0 20.6 21.1 23.1 22.5ZM64.1 11.3 67.0 12.4 70.7 14.3 74.1 16.5 77.5 19.3 75.6 20.3 73.2 21.5 70.0 22.6 68.7 19.2 67.1 16.1 65.7 13.6ZM35.9 11.3 34.2 13.6 32.8 16.1 31.3 19.2 30.0 22.5 27.9 21.9 26.4 21.3 22.5 19.3 25.8 16.5 29.3 14.3 32.9 12.4 35.4 11.4ZM51.2 8.8 52.2 8.8 55.1 9.0 59.6 9.9 61.7 12.2 64.2 16.0 66.0 19.5 67.6 23.3 64.3 24.3 59.4 25.2 56.2 25.6 51.2 25.5ZM48.8 8.8 48.7 25.5 44.2 25.6 40.6 25.2 36.4 24.5 32.4 23.2 33.9 19.5 35.7 16.0 38.2 12.2 40.3 9.9 44.9 9.0 47.7 8.8Z";
|
|
@@ -50,15 +50,17 @@ var POP_END = "ow-waymark__pop--end";
|
|
|
50
50
|
var POP_UP = "ow-waymark__pop--up";
|
|
51
51
|
var TOAST_END = "ow-waymark__toast--end";
|
|
52
52
|
var TOAST_UP = "ow-waymark__toast--up";
|
|
53
|
+
var SHEET = "ow-waymark--sheet";
|
|
53
54
|
var COPIED = "Link copied";
|
|
54
55
|
var NOT_COPIED = "Could not copy the link.";
|
|
55
56
|
var HERE = "You are here";
|
|
57
|
+
var OFFLINE = "Needs a connection";
|
|
56
58
|
var mounted = 0;
|
|
57
59
|
var fail = (what) => {
|
|
58
60
|
throw new TypeError(`mountWaymark: ${what}`);
|
|
59
61
|
};
|
|
60
62
|
function cannotOpen(state) {
|
|
61
|
-
return state !== null && (state.startsWith("Sign in to ") || state === "Needs the world on this phone");
|
|
63
|
+
return state !== null && (state.startsWith("Sign in to ") || state === "Needs the world on this phone" || state === OFFLINE);
|
|
62
64
|
}
|
|
63
65
|
function shapedOn(at, now) {
|
|
64
66
|
const d = new Date(at);
|
|
@@ -107,13 +109,16 @@ function mountWaymark(target, options) {
|
|
|
107
109
|
const isPublic = reader === "public";
|
|
108
110
|
const kind = element === null ? "world" : "element";
|
|
109
111
|
const address = element === null ? { form: "human", world: world.id } : { form: "human", world: world.id, type: element.type, id: element.id };
|
|
110
|
-
const
|
|
112
|
+
const rowsFor = (online) => openersFor(tools, kind, address, { tool, audience: isPublic ? "public" : "member", signedIn, browser, phone, online });
|
|
113
|
+
const rowsOnline = rowsFor(true);
|
|
114
|
+
const rowsOffline = rowsFor(false);
|
|
111
115
|
const throughLenses = isPublic ? [] : [...lenses ?? []];
|
|
112
116
|
const linkFor = (lens) => elementAddress({ ...address, lens });
|
|
113
117
|
for (const l of throughLenses) linkFor(l.id);
|
|
114
118
|
const doc = target.ownerDocument;
|
|
115
119
|
const win = doc.defaultView;
|
|
116
120
|
const timers = win ?? globalThis;
|
|
121
|
+
const isOnline = () => timers.navigator?.onLine !== false;
|
|
117
122
|
const last = !isPublic && element !== null ? doorsOf(element, tools)[0] : void 0;
|
|
118
123
|
const doorLine = last === void 0 ? null : `Last shaped ${doorWhere(last)}, ${shapedOn(last.at, /* @__PURE__ */ new Date())}`;
|
|
119
124
|
const typeLine = element === null ? null : typeWord(world, element.type) ?? element.type.charAt(0).toUpperCase() + element.type.slice(1);
|
|
@@ -228,7 +233,7 @@ function mountWaymark(target, options) {
|
|
|
228
233
|
return group;
|
|
229
234
|
};
|
|
230
235
|
const openWith = section("Open with");
|
|
231
|
-
|
|
236
|
+
const rowNode = (r) => {
|
|
232
237
|
const cls = `ow-waymark__row${cannotOpen(r.state) ? " ow-waymark__row--cannot" : ""}`;
|
|
233
238
|
let a;
|
|
234
239
|
if (r.state === HERE) {
|
|
@@ -236,6 +241,10 @@ function mountWaymark(target, options) {
|
|
|
236
241
|
a.type = "button";
|
|
237
242
|
a.setAttribute("aria-current", "page");
|
|
238
243
|
a.dataset.here = "";
|
|
244
|
+
} else if (r.state === OFFLINE) {
|
|
245
|
+
a = el("a", cls);
|
|
246
|
+
a.tabIndex = 0;
|
|
247
|
+
a.setAttribute("aria-disabled", "true");
|
|
239
248
|
} else {
|
|
240
249
|
a = el("a", cls);
|
|
241
250
|
a.href = r.href;
|
|
@@ -245,8 +254,23 @@ function mountWaymark(target, options) {
|
|
|
245
254
|
a.appendChild(r.id === "onlyworlds" ? markSvg("ow-waymark__icon") : glyph(TOOL_GLYPH, "ow-waymark__icon"));
|
|
246
255
|
a.appendChild(el("span", "ow-waymark__label", r.name));
|
|
247
256
|
if (r.state !== null) a.appendChild(el("span", "ow-waymark__state", r.state));
|
|
248
|
-
|
|
249
|
-
}
|
|
257
|
+
return a;
|
|
258
|
+
};
|
|
259
|
+
let drawn = [];
|
|
260
|
+
let drawnOnline = null;
|
|
261
|
+
const drawRows = () => {
|
|
262
|
+
const online = isOnline();
|
|
263
|
+
if (online === drawnOnline) return;
|
|
264
|
+
drawnOnline = online;
|
|
265
|
+
const active = doc.activeElement;
|
|
266
|
+
const kept = active !== null && drawn.includes(active) ? active.dataset.opener : void 0;
|
|
267
|
+
const fresh = (online ? rowsOnline : rowsOffline).map(rowNode);
|
|
268
|
+
for (const a of fresh) openWith.appendChild(a);
|
|
269
|
+
if (kept !== void 0) fresh.find((a) => a.dataset.opener === kept)?.focus();
|
|
270
|
+
for (const a of drawn) a.remove();
|
|
271
|
+
drawn = fresh;
|
|
272
|
+
};
|
|
273
|
+
drawRows();
|
|
250
274
|
let chosenLens = null;
|
|
251
275
|
let lensToggle = null;
|
|
252
276
|
let lensList = null;
|
|
@@ -320,20 +344,28 @@ function mountWaymark(target, options) {
|
|
|
320
344
|
}
|
|
321
345
|
return [0, edge];
|
|
322
346
|
};
|
|
347
|
+
let sheetAtOpen = false;
|
|
323
348
|
const placePop = () => {
|
|
324
349
|
pop.classList.remove(POP_END, POP_UP);
|
|
350
|
+
root.classList.remove(SHEET);
|
|
325
351
|
let end = false;
|
|
326
352
|
let up = false;
|
|
353
|
+
let sheet = false;
|
|
327
354
|
if (win !== null && win.getComputedStyle(pop).position !== "fixed") {
|
|
328
355
|
const at = pop.getBoundingClientRect();
|
|
329
356
|
const anchor = root.getBoundingClientRect();
|
|
330
357
|
const [left, right] = clipBox(win, "x");
|
|
331
358
|
const [top, bottom] = clipBox(win, "y");
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
|
|
359
|
+
const startCrosses = at.right > right;
|
|
360
|
+
const endCrosses = anchor.right - at.width < left;
|
|
361
|
+
const belowCrosses = at.bottom > bottom;
|
|
362
|
+
const aboveCrosses = anchor.top - GAP - at.height < top;
|
|
363
|
+
sheet = startCrosses && endCrosses || belowCrosses && aboveCrosses;
|
|
364
|
+
end = !sheet && startCrosses;
|
|
365
|
+
up = !sheet && belowCrosses;
|
|
336
366
|
}
|
|
367
|
+
sheetAtOpen = sheet;
|
|
368
|
+
root.classList.toggle(SHEET, sheet);
|
|
337
369
|
pop.classList.toggle(POP_END, end);
|
|
338
370
|
pop.classList.toggle(POP_UP, up);
|
|
339
371
|
toast.classList.toggle(TOAST_END, end);
|
|
@@ -343,11 +375,16 @@ function mountWaymark(target, options) {
|
|
|
343
375
|
if (isOpen()) return;
|
|
344
376
|
openedBy = from;
|
|
345
377
|
pressedInside = false;
|
|
378
|
+
drawRows();
|
|
346
379
|
pop.hidden = false;
|
|
347
380
|
scrim.hidden = false;
|
|
348
381
|
placePop();
|
|
349
382
|
from.setAttribute("aria-expanded", "true");
|
|
350
383
|
on(openListeners, doc, "pointerdown", onOutside, true);
|
|
384
|
+
if (win !== null) {
|
|
385
|
+
on(openListeners, win, "online", onConnection);
|
|
386
|
+
on(openListeners, win, "offline", onConnection);
|
|
387
|
+
}
|
|
351
388
|
const list = items();
|
|
352
389
|
(focus === "first" ? list[0] : list[list.length - 1])?.focus();
|
|
353
390
|
};
|
|
@@ -355,6 +392,7 @@ function mountWaymark(target, options) {
|
|
|
355
392
|
const hideToast = () => {
|
|
356
393
|
toast.hidden = true;
|
|
357
394
|
toast.classList.remove(TOAST_END, TOAST_UP);
|
|
395
|
+
if (pop.hidden) root.classList.remove(SHEET);
|
|
358
396
|
};
|
|
359
397
|
const close = (refocus) => {
|
|
360
398
|
if (!isOpen()) return;
|
|
@@ -368,10 +406,12 @@ function mountWaymark(target, options) {
|
|
|
368
406
|
addressLine.hidden = true;
|
|
369
407
|
toast.classList.remove("ow-waymark__toast--failed");
|
|
370
408
|
}
|
|
409
|
+
if (toast.hidden) root.classList.remove(SHEET);
|
|
371
410
|
if (refocus) focusBack().focus();
|
|
372
411
|
};
|
|
373
412
|
const copied = () => {
|
|
374
413
|
toastWords.textContent = COPIED;
|
|
414
|
+
root.classList.toggle(SHEET, sheetAtOpen);
|
|
375
415
|
toast.hidden = false;
|
|
376
416
|
if (toastTimer !== null) timers.clearTimeout(toastTimer);
|
|
377
417
|
toastTimer = timers.setTimeout(() => {
|
|
@@ -420,6 +460,7 @@ function mountWaymark(target, options) {
|
|
|
420
460
|
close(true);
|
|
421
461
|
}
|
|
422
462
|
};
|
|
463
|
+
const disabled = (n2) => n2.getAttribute("aria-disabled") === "true";
|
|
423
464
|
const onMenuKey = (e) => {
|
|
424
465
|
pressedInside = false;
|
|
425
466
|
const list = items();
|
|
@@ -433,6 +474,9 @@ function mountWaymark(target, options) {
|
|
|
433
474
|
owned(e);
|
|
434
475
|
close(true);
|
|
435
476
|
return;
|
|
477
|
+
} else if ((e.key === "Enter" || e.key === " ") && disabled(e.target)) {
|
|
478
|
+
e.preventDefault();
|
|
479
|
+
return;
|
|
436
480
|
} else if (e.key === " " && e.target.tagName === "A") {
|
|
437
481
|
e.preventDefault();
|
|
438
482
|
e.target.click();
|
|
@@ -445,6 +489,10 @@ function mountWaymark(target, options) {
|
|
|
445
489
|
const t = e.target;
|
|
446
490
|
const row = t.closest(".ow-waymark__row");
|
|
447
491
|
if (row === null) return;
|
|
492
|
+
if (disabled(row)) {
|
|
493
|
+
e.preventDefault();
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
448
496
|
if (row === lensToggle) {
|
|
449
497
|
const show = lensList.hidden;
|
|
450
498
|
lensList.hidden = !show;
|
|
@@ -492,6 +540,9 @@ function mountWaymark(target, options) {
|
|
|
492
540
|
if (!inside(doc.activeElement)) close(false);
|
|
493
541
|
}, 0);
|
|
494
542
|
};
|
|
543
|
+
const onConnection = () => {
|
|
544
|
+
if (isOpen()) drawRows();
|
|
545
|
+
};
|
|
495
546
|
for (const b of openers) {
|
|
496
547
|
on(listeners, b, "pointerdown", onOpenerPress);
|
|
497
548
|
on(listeners, b, "click", onOpenerClick);
|