@kehto/paja 0.24.2 → 0.24.4
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/README.md +11 -3
- package/dist/browser-host.js +65 -40
- package/dist/browser-host.js.map +1 -1
- package/dist/{chunk-YXFOVFON.js → chunk-PLZYKUBM.js} +18 -7
- package/dist/chunk-PLZYKUBM.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-YXFOVFON.js.map +0 -1
package/README.md
CHANGED
|
@@ -194,9 +194,13 @@ artifact. It uses the same browser host and service adapters, but loads verified
|
|
|
194
194
|
napplet HTML from pasted `naddr` or `nevent` pointers with `hmr: none`. Each
|
|
195
195
|
loaded pointer becomes a closeable header tab; loading an already-running
|
|
196
196
|
napplet opens a choice to load another instance, switch to the existing tab, or
|
|
197
|
-
cancel. Each tab
|
|
198
|
-
or `/web/paja/?nevent=...` link
|
|
199
|
-
|
|
197
|
+
cancel. Each verified tab's Share control opens a dialog with its selectable
|
|
198
|
+
`/web/paja/?naddr=...` or `/web/paja/?nevent=...` app link. **Copy app link**
|
|
199
|
+
shows a confirmation on success; blocked or unavailable clipboard access selects
|
|
200
|
+
the link for manual copying. Apps with advertised intents also offer
|
|
201
|
+
**Create intent link**. Share keeps focus and pointer input in the host overlay
|
|
202
|
+
while the apps remain loaded. The browser remembers open runtime tabs in local storage
|
|
203
|
+
so returning to `/web/paja/` restores the previous
|
|
200
204
|
pointer set. An explicit pointer in the URL still takes precedence over restored
|
|
201
205
|
tabs.
|
|
202
206
|
|
|
@@ -561,6 +565,10 @@ remain a documented upstream spec gap; no host sender identity is invented.
|
|
|
561
565
|
|
|
562
566
|
This non-normative guidance defers to the living [NAP-GAMEPAD](https://github.com/napplet/naps/pull/108). Services export `createGamepadService` and `browserGamepadOptions`; shell exports `denyNappletControllerAccess`. Paja and the playground register one host reader and deny native gamepad/HID/USB paths before frame execution. Source-bound subscriptions receive immediate full snapshots; only the visible host's input owner gets live controls. Focus loss supplies neutral controls and timestamp zero; unsubscribe, window destruction, and service removal release polling. Non-browser or denied native readers report the proposal's unavailable reasons. See [Controller input](https://github.com/kehto/web/blob/main/docs/gamepad.md).
|
|
563
567
|
|
|
568
|
+
## NIP-5D runtime pointers
|
|
569
|
+
|
|
570
|
+
Paja MUST load all three NIP-5D manifest kinds: root `15129`, named `35129`, and snapshot `5129`. Use an `naddr` with an empty identifier for the latest root, an `naddr` with the literal `d` identifier for the latest named napplet, or a `nevent` to pin a signed event of any of the three kinds. Snapshots require `nevent` because they are immutable events without replaceable coordinates. All paths verify the signed manifest and artifact hash before injecting `srcdoc`. Distinct snapshots retain separate tabs and catalog identities even when their artifact bytes match.
|
|
571
|
+
|
|
564
572
|
## Controller diagnostics
|
|
565
573
|
|
|
566
574
|
Paja shows a numbered controller icon directly beside the console arrow for each controller the browser detects. Each slot has its own color and input animation; hover for the controller model and activity state. Buttons and stick movement light up only that controller (stick movement below 0.12 is ignored). Quick taps retain the highlight briefly so they are easy to spot. Reduced-motion settings keep the activity highlight without animation. Disconnecting removes the icon. Browsers may require a button press before exposing a newly connected controller. These host diagnostics work without a napplet gamepad subscription and do not change focus-scoped input delivery.
|
package/dist/browser-host.js
CHANGED
|
@@ -23542,6 +23542,9 @@ function unregisterSingleFrameWindow(bridge, runtime, windowId) {
|
|
|
23542
23542
|
var PAJA_RUNTIME_TABS_STORAGE_KEY = "kehto:paja:runtime-tabs:v1";
|
|
23543
23543
|
function resolvedTargetKey(target) {
|
|
23544
23544
|
if (isPajaLocalTarget(target)) return ["local", target.dTag, target.aggregateHash].join(":");
|
|
23545
|
+
if (target.event.kind === NAPPLET_KIND_SNAPSHOT) {
|
|
23546
|
+
return [target.event.kind, target.event.id, target.aggregateHash].join(":");
|
|
23547
|
+
}
|
|
23545
23548
|
return [
|
|
23546
23549
|
target.event.kind,
|
|
23547
23550
|
target.event.pubkey,
|
|
@@ -23754,22 +23757,22 @@ function renderShareButton(state, tab) {
|
|
|
23754
23757
|
share.textContent = "\u2197";
|
|
23755
23758
|
share.addEventListener("click", (event) => {
|
|
23756
23759
|
event.stopPropagation();
|
|
23757
|
-
|
|
23758
|
-
else void shareRuntimeTab(tab, share).catch((error) => console.error(error));
|
|
23760
|
+
openShareDialog(state, tab, share);
|
|
23759
23761
|
});
|
|
23760
23762
|
share.addEventListener("keydown", (event) => {
|
|
23761
23763
|
if (event.key !== "Enter" && event.key !== " ") return;
|
|
23762
23764
|
event.preventDefault();
|
|
23763
23765
|
event.stopPropagation();
|
|
23764
|
-
|
|
23765
|
-
else void shareRuntimeTab(tab, share).catch((error) => console.error(error));
|
|
23766
|
+
openShareDialog(state, tab, share);
|
|
23766
23767
|
});
|
|
23767
23768
|
return share;
|
|
23768
23769
|
}
|
|
23769
23770
|
function openShareDialog(state, tab, opener) {
|
|
23770
|
-
const dialog = document.createElement("
|
|
23771
|
-
dialog.className = "
|
|
23771
|
+
const dialog = document.createElement("div");
|
|
23772
|
+
dialog.className = "dialog-backdrop";
|
|
23772
23773
|
dialog.id = "paja-share-dialog";
|
|
23774
|
+
dialog.setAttribute("role", "dialog");
|
|
23775
|
+
dialog.setAttribute("aria-modal", "true");
|
|
23773
23776
|
const panel = document.createElement("div");
|
|
23774
23777
|
panel.className = "dialog";
|
|
23775
23778
|
const title = document.createElement("div");
|
|
@@ -23779,7 +23782,18 @@ function openShareDialog(state, tab, opener) {
|
|
|
23779
23782
|
dialog.setAttribute("aria-labelledby", title.id);
|
|
23780
23783
|
const description = document.createElement("div");
|
|
23781
23784
|
description.className = "dialog-copy";
|
|
23782
|
-
|
|
23785
|
+
const offersIntents = canCreatePajaIntentLink(state, tab);
|
|
23786
|
+
description.textContent = offersIntents ? `Share ${tab.title} as an app link or create an intent link.` : `Share ${tab.title} as an app link.`;
|
|
23787
|
+
const linkLabel = document.createElement("label");
|
|
23788
|
+
linkLabel.className = "config-field";
|
|
23789
|
+
linkLabel.textContent = "App link";
|
|
23790
|
+
const link = document.createElement("input");
|
|
23791
|
+
link.type = "text";
|
|
23792
|
+
link.readOnly = true;
|
|
23793
|
+
link.value = createPajaShareUrl(tab.pointerValue);
|
|
23794
|
+
linkLabel.append(link);
|
|
23795
|
+
const status = document.createElement("div");
|
|
23796
|
+
status.setAttribute("role", "status");
|
|
23783
23797
|
const actions = document.createElement("div");
|
|
23784
23798
|
actions.className = "dialog-actions";
|
|
23785
23799
|
const copy = document.createElement("button");
|
|
@@ -23791,39 +23805,50 @@ function openShareDialog(state, tab, opener) {
|
|
|
23791
23805
|
const cancel = document.createElement("button");
|
|
23792
23806
|
cancel.type = "button";
|
|
23793
23807
|
cancel.textContent = "Cancel";
|
|
23794
|
-
actions.append(copy, create, cancel);
|
|
23795
|
-
panel.append(title, description, actions);
|
|
23808
|
+
actions.append(copy, ...offersIntents ? [create] : [], cancel);
|
|
23809
|
+
panel.append(title, description, linkLabel, status, actions);
|
|
23796
23810
|
dialog.append(panel);
|
|
23811
|
+
const siblings = Array.from(document.body.children).filter((node) => node instanceof HTMLElement).map((node) => ({ node, inert: node.inert }));
|
|
23812
|
+
for (const { node } of siblings) node.inert = true;
|
|
23797
23813
|
document.body.append(dialog);
|
|
23798
23814
|
const retainModalFocus = (event) => {
|
|
23799
|
-
if (!dialog.
|
|
23815
|
+
if (!dialog.isConnected) return;
|
|
23800
23816
|
const next = event.relatedTarget;
|
|
23801
23817
|
if (next instanceof Node && dialog.contains(next)) return;
|
|
23802
23818
|
queueMicrotask(() => {
|
|
23803
|
-
if (dialog.
|
|
23819
|
+
if (dialog.isConnected && !dialog.matches(":focus-within")) copy.focus();
|
|
23804
23820
|
});
|
|
23805
23821
|
};
|
|
23806
23822
|
const close = (restoreFocus = true) => {
|
|
23807
|
-
if (dialog.open) dialog.close();
|
|
23808
23823
|
dialog.removeEventListener("focusout", retainModalFocus);
|
|
23809
23824
|
dialog.remove();
|
|
23825
|
+
for (const { node, inert } of siblings) node.inert = inert;
|
|
23810
23826
|
if (restoreFocus) opener.focus();
|
|
23811
23827
|
};
|
|
23812
|
-
|
|
23813
|
-
event.
|
|
23814
|
-
|
|
23815
|
-
|
|
23828
|
+
dialog.addEventListener("keydown", (event) => {
|
|
23829
|
+
if (event.key === "Escape") {
|
|
23830
|
+
event.preventDefault();
|
|
23831
|
+
close();
|
|
23832
|
+
return;
|
|
23833
|
+
}
|
|
23834
|
+
if (event.key !== "Tab") return;
|
|
23835
|
+
const controls = [link, copy, ...offersIntents ? [create] : [], cancel];
|
|
23836
|
+
const next = event.shiftKey ? controls.at(-1) : controls[0];
|
|
23837
|
+
const edge = event.shiftKey ? controls[0] : controls.at(-1);
|
|
23838
|
+
if (document.activeElement === edge) {
|
|
23839
|
+
event.preventDefault();
|
|
23840
|
+
next.focus();
|
|
23841
|
+
}
|
|
23842
|
+
});
|
|
23816
23843
|
cancel.addEventListener("click", () => close());
|
|
23817
23844
|
copy.addEventListener("click", () => {
|
|
23818
|
-
void
|
|
23845
|
+
void copyShareLink(link, status);
|
|
23819
23846
|
});
|
|
23820
23847
|
create.addEventListener("click", () => {
|
|
23821
23848
|
close();
|
|
23822
23849
|
state.createIntentLink?.(tab);
|
|
23823
23850
|
});
|
|
23824
|
-
dialog.addEventListener("cancel", onCancel);
|
|
23825
23851
|
dialog.addEventListener("focusout", retainModalFocus);
|
|
23826
|
-
dialog.showModal();
|
|
23827
23852
|
copy.focus();
|
|
23828
23853
|
}
|
|
23829
23854
|
function renderCloseButton(state, tab) {
|
|
@@ -23844,24 +23869,15 @@ function renderCloseButton(state, tab) {
|
|
|
23844
23869
|
});
|
|
23845
23870
|
return close;
|
|
23846
23871
|
}
|
|
23847
|
-
async function
|
|
23848
|
-
const shareUrl = createPajaShareUrl(tab.pointerValue);
|
|
23849
|
-
const clipboard = navigator.clipboard;
|
|
23850
|
-
if (!clipboard) {
|
|
23851
|
-
window.prompt("Copy Paja share link", shareUrl);
|
|
23852
|
-
return;
|
|
23853
|
-
}
|
|
23872
|
+
async function copyShareLink(link, status) {
|
|
23854
23873
|
try {
|
|
23855
|
-
await clipboard.writeText(
|
|
23874
|
+
await navigator.clipboard.writeText(link.value);
|
|
23875
|
+
status.textContent = "App link copied.";
|
|
23856
23876
|
} catch {
|
|
23857
|
-
|
|
23858
|
-
|
|
23877
|
+
link.focus();
|
|
23878
|
+
link.select();
|
|
23879
|
+
status.textContent = "Select and copy the app link.";
|
|
23859
23880
|
}
|
|
23860
|
-
const originalTitle = button2.title;
|
|
23861
|
-
button2.title = "Share link copied";
|
|
23862
|
-
window.setTimeout(() => {
|
|
23863
|
-
button2.title = originalTitle || "Copy app link";
|
|
23864
|
-
}, 1200);
|
|
23865
23881
|
}
|
|
23866
23882
|
function getPointerParamName(pointer) {
|
|
23867
23883
|
if (pointer.startsWith("naddr")) return "naddr";
|
|
@@ -24342,7 +24358,7 @@ function resolvePointerBlossomServers(event, configured) {
|
|
|
24342
24358
|
async function resolvePointerEvent(pointer, pool, relays, maxWaitMs) {
|
|
24343
24359
|
const filter = pointer.type === "naddr" ? addressableFilter(pointer) : eventFilter(pointer);
|
|
24344
24360
|
const result2 = await queryPointerRelays(pool, relays, filter, maxWaitMs);
|
|
24345
|
-
const event = result2.events.filter((candidate) => matchesPointer(pointer, candidate)).sort((a, b) => b.created_at - a.created_at)[0];
|
|
24361
|
+
const event = result2.events.filter((candidate) => matchesPointer(pointer, candidate)).sort((a, b) => b.created_at - a.created_at || a.id.localeCompare(b.id))[0];
|
|
24346
24362
|
if (!event) {
|
|
24347
24363
|
if (result2.timedOut) {
|
|
24348
24364
|
throw new Error(
|
|
@@ -24432,13 +24448,22 @@ function normalizeMaxWaitMs(value) {
|
|
|
24432
24448
|
return Math.floor(value);
|
|
24433
24449
|
}
|
|
24434
24450
|
function addressableFilter(pointer) {
|
|
24435
|
-
if (pointer.kind
|
|
24436
|
-
throw new Error(
|
|
24451
|
+
if (pointer.kind === NAPPLET_KIND_SNAPSHOT) {
|
|
24452
|
+
throw new Error("NIP-5D snapshot kind 5129 requires a nevent pointer with its signed event ID.");
|
|
24453
|
+
}
|
|
24454
|
+
if (pointer.kind !== NAPPLET_KIND_NAMED && pointer.kind !== NAPPLET_KIND_ROOT) {
|
|
24455
|
+
throw new Error(`naddr kind ${pointer.kind} is not a root or named NIP-5D napplet manifest kind.`);
|
|
24456
|
+
}
|
|
24457
|
+
if (pointer.kind === NAPPLET_KIND_ROOT && pointer.identifier !== "") {
|
|
24458
|
+
throw new Error("NIP-5D root naddr requires an empty identifier.");
|
|
24459
|
+
}
|
|
24460
|
+
if (pointer.kind === NAPPLET_KIND_NAMED && pointer.identifier === "") {
|
|
24461
|
+
throw new Error("NIP-5D named naddr requires a non-empty identifier.");
|
|
24437
24462
|
}
|
|
24438
24463
|
return {
|
|
24439
|
-
kinds: [
|
|
24464
|
+
kinds: [pointer.kind],
|
|
24440
24465
|
authors: [pointer.pubkey],
|
|
24441
|
-
"#d": [pointer.identifier],
|
|
24466
|
+
...pointer.kind === NAPPLET_KIND_NAMED ? { "#d": [pointer.identifier] } : {},
|
|
24442
24467
|
limit: 1
|
|
24443
24468
|
};
|
|
24444
24469
|
}
|
|
@@ -24457,7 +24482,7 @@ function matchesPointer(pointer, event) {
|
|
|
24457
24482
|
if (pointer.kind && event.kind !== pointer.kind) return false;
|
|
24458
24483
|
return true;
|
|
24459
24484
|
}
|
|
24460
|
-
return event.kind === pointer.kind && event.pubkey === pointer.pubkey && event.tags.some((tag) => tag[0] === "d" && tag[1] === pointer.identifier);
|
|
24485
|
+
return event.kind === pointer.kind && event.pubkey === pointer.pubkey && (pointer.kind === NAPPLET_KIND_ROOT || event.tags.some((tag) => tag[0] === "d" && tag[1] === pointer.identifier));
|
|
24461
24486
|
}
|
|
24462
24487
|
function uniqueRelayUrls(values) {
|
|
24463
24488
|
const out = [];
|