@kehto/paja 0.24.3 → 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 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 includes a share control that copies a `/web/paja/?naddr=...`
198
- or `/web/paja/?nevent=...` link for that pointer, and the browser remembers open
199
- runtime tabs in local storage so returning to `/web/paja/` restores the previous
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
 
@@ -23757,22 +23757,22 @@ function renderShareButton(state, tab) {
23757
23757
  share.textContent = "\u2197";
23758
23758
  share.addEventListener("click", (event) => {
23759
23759
  event.stopPropagation();
23760
- if (canCreatePajaIntentLink(state, tab)) openShareDialog(state, tab, share);
23761
- else void shareRuntimeTab(tab, share).catch((error) => console.error(error));
23760
+ openShareDialog(state, tab, share);
23762
23761
  });
23763
23762
  share.addEventListener("keydown", (event) => {
23764
23763
  if (event.key !== "Enter" && event.key !== " ") return;
23765
23764
  event.preventDefault();
23766
23765
  event.stopPropagation();
23767
- if (canCreatePajaIntentLink(state, tab)) openShareDialog(state, tab, share);
23768
- else void shareRuntimeTab(tab, share).catch((error) => console.error(error));
23766
+ openShareDialog(state, tab, share);
23769
23767
  });
23770
23768
  return share;
23771
23769
  }
23772
23770
  function openShareDialog(state, tab, opener) {
23773
- const dialog = document.createElement("dialog");
23774
- dialog.className = "config-dialog";
23771
+ const dialog = document.createElement("div");
23772
+ dialog.className = "dialog-backdrop";
23775
23773
  dialog.id = "paja-share-dialog";
23774
+ dialog.setAttribute("role", "dialog");
23775
+ dialog.setAttribute("aria-modal", "true");
23776
23776
  const panel = document.createElement("div");
23777
23777
  panel.className = "dialog";
23778
23778
  const title = document.createElement("div");
@@ -23782,7 +23782,18 @@ function openShareDialog(state, tab, opener) {
23782
23782
  dialog.setAttribute("aria-labelledby", title.id);
23783
23783
  const description = document.createElement("div");
23784
23784
  description.className = "dialog-copy";
23785
- description.textContent = `Share ${tab.title} as an app link or create an intent link.`;
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");
23786
23797
  const actions = document.createElement("div");
23787
23798
  actions.className = "dialog-actions";
23788
23799
  const copy = document.createElement("button");
@@ -23794,39 +23805,50 @@ function openShareDialog(state, tab, opener) {
23794
23805
  const cancel = document.createElement("button");
23795
23806
  cancel.type = "button";
23796
23807
  cancel.textContent = "Cancel";
23797
- actions.append(copy, create, cancel);
23798
- panel.append(title, description, actions);
23808
+ actions.append(copy, ...offersIntents ? [create] : [], cancel);
23809
+ panel.append(title, description, linkLabel, status, actions);
23799
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;
23800
23813
  document.body.append(dialog);
23801
23814
  const retainModalFocus = (event) => {
23802
- if (!dialog.open) return;
23815
+ if (!dialog.isConnected) return;
23803
23816
  const next = event.relatedTarget;
23804
23817
  if (next instanceof Node && dialog.contains(next)) return;
23805
23818
  queueMicrotask(() => {
23806
- if (dialog.open && !dialog.matches(":focus-within")) copy.focus();
23819
+ if (dialog.isConnected && !dialog.matches(":focus-within")) copy.focus();
23807
23820
  });
23808
23821
  };
23809
23822
  const close = (restoreFocus = true) => {
23810
- if (dialog.open) dialog.close();
23811
23823
  dialog.removeEventListener("focusout", retainModalFocus);
23812
23824
  dialog.remove();
23825
+ for (const { node, inert } of siblings) node.inert = inert;
23813
23826
  if (restoreFocus) opener.focus();
23814
23827
  };
23815
- const onCancel = (event) => {
23816
- event.preventDefault();
23817
- close();
23818
- };
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
+ });
23819
23843
  cancel.addEventListener("click", () => close());
23820
23844
  copy.addEventListener("click", () => {
23821
- void shareRuntimeTab(tab, copy).catch((error) => console.error(error));
23845
+ void copyShareLink(link, status);
23822
23846
  });
23823
23847
  create.addEventListener("click", () => {
23824
23848
  close();
23825
23849
  state.createIntentLink?.(tab);
23826
23850
  });
23827
- dialog.addEventListener("cancel", onCancel);
23828
23851
  dialog.addEventListener("focusout", retainModalFocus);
23829
- dialog.showModal();
23830
23852
  copy.focus();
23831
23853
  }
23832
23854
  function renderCloseButton(state, tab) {
@@ -23847,24 +23869,15 @@ function renderCloseButton(state, tab) {
23847
23869
  });
23848
23870
  return close;
23849
23871
  }
23850
- async function shareRuntimeTab(tab, button2) {
23851
- const shareUrl = createPajaShareUrl(tab.pointerValue);
23852
- const clipboard = navigator.clipboard;
23853
- if (!clipboard) {
23854
- window.prompt("Copy Paja share link", shareUrl);
23855
- return;
23856
- }
23872
+ async function copyShareLink(link, status) {
23857
23873
  try {
23858
- await clipboard.writeText(shareUrl);
23874
+ await navigator.clipboard.writeText(link.value);
23875
+ status.textContent = "App link copied.";
23859
23876
  } catch {
23860
- window.prompt("Copy Paja share link", shareUrl);
23861
- return;
23877
+ link.focus();
23878
+ link.select();
23879
+ status.textContent = "Select and copy the app link.";
23862
23880
  }
23863
- const originalTitle = button2.title;
23864
- button2.title = "Share link copied";
23865
- window.setTimeout(() => {
23866
- button2.title = originalTitle || "Copy app link";
23867
- }, 1200);
23868
23881
  }
23869
23882
  function getPointerParamName(pointer) {
23870
23883
  if (pointer.startsWith("naddr")) return "naddr";