Merge branch 'master' into kosmos
# Conflicts: # release/assets/main-BD5lfqyM.js # release/assets/modules-4-12-DPYeIi5w.js # release/assets/modules-4-12-DRDkPElI.js # release/assets/modules-4-12-Dqxw6E4Q.js # release/index.html
This commit is contained in:
18 files changed
+1074
-49
No files matched your search
@@ -2,13 +2,24 @@ import Component from '@glimmer/component';
|
||||
import { action } from '@ember/object';
|
||||
import { service } from '@ember/service';
|
||||
import { on } from '@ember/modifier';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { eq } from 'ember-truth-helpers';
|
||||
import qrCode from '../modifiers/qr-code';
|
||||
|
||||
// How long to wait for the signer app to take over the page (via the OS
|
||||
// `nostrconnect:` protocol handler) before assuming it did not open.
|
||||
const SIGNER_LAUNCH_TIMEOUT = 2000;
|
||||
|
||||
export default class NostrConnectComponent extends Component {
|
||||
@service nostrAuth;
|
||||
@service toast;
|
||||
|
||||
@tracked showSignerHint = false;
|
||||
@tracked showQrCode = false;
|
||||
|
||||
_launchAttempt = 0;
|
||||
_launchTeardown = null;
|
||||
|
||||
get hasExtension() {
|
||||
return typeof window !== 'undefined' && typeof window.nostr !== 'undefined';
|
||||
}
|
||||
@@ -75,6 +86,80 @@ export default class NostrConnectComponent extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
toggleQrCode() {
|
||||
this.showQrCode = !this.showQrCode;
|
||||
}
|
||||
|
||||
// The anchor's default navigation is what hands the `nostrconnect:` URI to
|
||||
// the OS, so we must not preventDefault. We only watch for signs that a
|
||||
// signer app actually took over — the page being hidden or blurred, or a
|
||||
// navigation error for the `nostrconnect:` scheme (no protocol handler) —
|
||||
// and otherwise reveal a hint pointing at the QR code / copy link fallback.
|
||||
@action
|
||||
openSigner() {
|
||||
this.showSignerHint = false;
|
||||
this._teardownLaunch();
|
||||
|
||||
const attempt = (this._launchAttempt += 1);
|
||||
let launched = false;
|
||||
const teardown = [];
|
||||
|
||||
const revealHint = () => {
|
||||
if (attempt === this._launchAttempt) this.showSignerHint = true;
|
||||
};
|
||||
|
||||
const markLaunched = () => {
|
||||
launched = true;
|
||||
this._teardownLaunch();
|
||||
};
|
||||
|
||||
const onVisibility = () => {
|
||||
if (document.visibilityState === 'hidden') markLaunched();
|
||||
};
|
||||
const onBlur = () => markLaunched();
|
||||
const onNavigateError = (event) => {
|
||||
if (!event.destination?.url?.startsWith('nostrconnect:')) return;
|
||||
this._teardownLaunch();
|
||||
revealHint();
|
||||
};
|
||||
|
||||
document.addEventListener('visibilitychange', onVisibility);
|
||||
teardown.push(() =>
|
||||
document.removeEventListener('visibilitychange', onVisibility)
|
||||
);
|
||||
|
||||
window.addEventListener('blur', onBlur, { once: true });
|
||||
teardown.push(() => window.removeEventListener('blur', onBlur));
|
||||
|
||||
if ('navigation' in window) {
|
||||
window.navigation.addEventListener('navigateerror', onNavigateError);
|
||||
teardown.push(() =>
|
||||
window.navigation.removeEventListener('navigateerror', onNavigateError)
|
||||
);
|
||||
}
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
if (launched || attempt !== this._launchAttempt) return;
|
||||
this._teardownLaunch();
|
||||
revealHint();
|
||||
}, SIGNER_LAUNCH_TIMEOUT);
|
||||
teardown.push(() => clearTimeout(timer));
|
||||
|
||||
this._launchTeardown = teardown;
|
||||
}
|
||||
|
||||
_teardownLaunch() {
|
||||
if (!this._launchTeardown) return;
|
||||
for (const fn of this._launchTeardown) fn();
|
||||
this._launchTeardown = null;
|
||||
}
|
||||
|
||||
willDestroy() {
|
||||
this._teardownLaunch();
|
||||
super.willDestroy(...arguments);
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="nostr-connect-modal">
|
||||
<h2>Connect with Nostr</h2>
|
||||
@@ -104,29 +189,46 @@ export default class NostrConnectComponent extends Component {
|
||||
type="button"
|
||||
{{on "click" this.connectApp}}
|
||||
>
|
||||
Mobile Signer App (Amber, etc.)
|
||||
Signer app (Amber, Regent, etc.)
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{{#if (eq this.nostrAuth.connectStatus "waiting")}}
|
||||
<div class="nostr-connect-status">
|
||||
{{#if this.nostrAuth.isMobile}}
|
||||
<p>Waiting for you to approve the connection in your mobile signer
|
||||
app...</p>
|
||||
<div class="mobile-connect-actions">
|
||||
<a href={{this.nostrAuth.connectUri}} class="btn btn-primary">
|
||||
Open Signer App
|
||||
</a>
|
||||
<p>Approve the connection in your signer app on this device, or scan
|
||||
the QR code with a signer app on another device.</p>
|
||||
<div class="signer-connect-actions">
|
||||
<a
|
||||
href={{this.nostrAuth.connectUri}}
|
||||
class="btn btn-primary"
|
||||
{{on "click" this.openSigner}}
|
||||
>
|
||||
Open signer app
|
||||
</a>
|
||||
<div class="signer-connect-secondary">
|
||||
<button
|
||||
class="btn btn-outline"
|
||||
type="button"
|
||||
{{on "click" this.copyConnectUri}}
|
||||
>
|
||||
Copy Connection Link
|
||||
Copy connection link
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-outline"
|
||||
type="button"
|
||||
{{on "click" this.toggleQrCode}}
|
||||
>
|
||||
{{if this.showQrCode "Hide QR code" "Show QR code"}}
|
||||
</button>
|
||||
</div>
|
||||
{{else}}
|
||||
<p>Scan this QR code with a Nostr signer app (like Amber):</p>
|
||||
</div>
|
||||
{{#if this.showSignerHint}}
|
||||
<p class="signer-connect-hint">
|
||||
Didn't open your signer app? Scan the QR code or copy the
|
||||
connection link.
|
||||
</p>
|
||||
{{/if}}
|
||||
{{#if this.showQrCode}}
|
||||
<div class="qr-code-container">
|
||||
<canvas {{qrCode this.nostrAuth.connectUri}}></canvas>
|
||||
</div>
|
||||
|
||||
@@ -8,8 +8,18 @@ import { task, timeout } from 'ember-concurrency';
|
||||
import Icon from '#components/icon';
|
||||
import humanizeOsmTag from '../helpers/humanize-osm-tag';
|
||||
import { POI_CATEGORIES } from '../utils/poi-categories';
|
||||
import {
|
||||
parseNostrEventReference,
|
||||
nostrEventRouteParam,
|
||||
nostrEventLabel,
|
||||
} from '../utils/nostr';
|
||||
import { eq, or } from 'ember-truth-helpers';
|
||||
|
||||
// Interactive, as-you-type Nostr lookup. Kept short so a pasted reference
|
||||
// either resolves quickly or the field stops spinning; a later "Enter" that
|
||||
// opens /e/ benefits from the store cache populated by this attempt.
|
||||
const NOSTR_LOOKUP_TIMEOUT_MS = 5000;
|
||||
|
||||
export default class SearchBoxComponent extends Component {
|
||||
@service photon;
|
||||
@service osm;
|
||||
@@ -17,11 +27,20 @@ export default class SearchBoxComponent extends Component {
|
||||
@service router;
|
||||
@service mapUi;
|
||||
@service map; // Assuming we might need map context, but mostly we use router
|
||||
@service nostrData;
|
||||
@service toast;
|
||||
|
||||
@tracked _internalQuery = '';
|
||||
@tracked results = [];
|
||||
@tracked isFocused = false;
|
||||
@tracked isLoading = false;
|
||||
// Separate from `isLoading` so the spinner only appears while resolving a
|
||||
// Nostr reference, leaving ordinary Photon/category/saved popover UX alone.
|
||||
@tracked isNostrLookup = false;
|
||||
|
||||
// Last completed reference lookup, used to re-apply its outcome on refocus
|
||||
// without a second network round-trip (or duplicate toast). Reset in clear().
|
||||
_lastNostrRef = null;
|
||||
|
||||
get query() {
|
||||
return this.args.query ?? this._internalQuery;
|
||||
@@ -44,6 +63,9 @@ export default class SearchBoxComponent extends Component {
|
||||
}
|
||||
|
||||
if (value.length < 2) {
|
||||
// Cancel any in-flight (e.g. Nostr) lookup so it can't pop a stale row
|
||||
// or toast over an input the user has since shortened.
|
||||
this.searchTask.cancelAll();
|
||||
this.results = [];
|
||||
return;
|
||||
}
|
||||
@@ -81,6 +103,14 @@ export default class SearchBoxComponent extends Component {
|
||||
|
||||
if (query.length < 2) return;
|
||||
|
||||
// A Nostr event reference opens the /e/ handler instead of running a
|
||||
// Photon/bookmark search.
|
||||
const routeParam = nostrEventRouteParam(query);
|
||||
if (routeParam) {
|
||||
await this.resolveNostrReference(query, routeParam);
|
||||
return;
|
||||
}
|
||||
|
||||
this.isLoading = true;
|
||||
try {
|
||||
// Use map center if available for location bias
|
||||
@@ -131,6 +161,56 @@ export default class SearchBoxComponent extends Component {
|
||||
}
|
||||
});
|
||||
|
||||
nostrResult(routeParam, event) {
|
||||
const { title, description } = nostrEventLabel(event);
|
||||
return {
|
||||
source: 'nostr',
|
||||
id: routeParam,
|
||||
icon: 'nostrich',
|
||||
title,
|
||||
description,
|
||||
};
|
||||
}
|
||||
|
||||
async resolveNostrReference(query, routeParam) {
|
||||
// Re-apply the cached outcome on refocus rather than re-running a relay
|
||||
// lookup (and re-toasting) for a reference we have already resolved.
|
||||
if (this._lastNostrRef?.param === routeParam) {
|
||||
this.results = this._lastNostrRef.result
|
||||
? [this._lastNostrRef.result]
|
||||
: [];
|
||||
return;
|
||||
}
|
||||
|
||||
this.isNostrLookup = true;
|
||||
try {
|
||||
const event = await this.nostrData.loadEventByPointer(
|
||||
parseNostrEventReference(query),
|
||||
NOSTR_LOOKUP_TIMEOUT_MS
|
||||
);
|
||||
|
||||
// The query may have changed (or been cleared) while we waited. Drop a
|
||||
// stale outcome instead of toasting or showing a row for the wrong
|
||||
// input; this also covers builds where cancellation does not interrupt
|
||||
// the awaited lookup.
|
||||
if (nostrEventRouteParam(this.query) !== routeParam) {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = event ? this.nostrResult(routeParam, event) : null;
|
||||
this._lastNostrRef = { param: routeParam, result };
|
||||
|
||||
if (result) {
|
||||
this.results = [result];
|
||||
} else {
|
||||
this.results = [];
|
||||
this.toast.show('Could not find this event on any relay.');
|
||||
}
|
||||
} finally {
|
||||
this.isNostrLookup = false;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
handleFocus() {
|
||||
this.isFocused = true;
|
||||
@@ -154,6 +234,16 @@ export default class SearchBoxComponent extends Component {
|
||||
event.preventDefault();
|
||||
if (!this.query) return;
|
||||
|
||||
// A Nostr event reference is opened by the /e/ route; the route reports
|
||||
// its own errors ("not found" / "not linked to a place").
|
||||
const nostrRef = nostrEventRouteParam(this.query);
|
||||
if (nostrRef) {
|
||||
this.results = [];
|
||||
this.isFocused = false;
|
||||
this.router.transitionTo('event', nostrRef);
|
||||
return;
|
||||
}
|
||||
|
||||
let queryParams = { q: this.query, selected: null, category: null };
|
||||
|
||||
if (this.mapUi.currentCenter) {
|
||||
@@ -195,6 +285,14 @@ export default class SearchBoxComponent extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (place.source === 'nostr') {
|
||||
// Open the /e/ handler. Intentionally skip the shared lines below so we
|
||||
// don't overwrite the input with the result label.
|
||||
this.results = [];
|
||||
this.router.transitionTo('event', place.id);
|
||||
return;
|
||||
}
|
||||
|
||||
this.query = place.title;
|
||||
if (this.args.onQueryChange) {
|
||||
this.args.onQueryChange(place.title);
|
||||
@@ -233,6 +331,7 @@ export default class SearchBoxComponent extends Component {
|
||||
this.osm.cancelAll();
|
||||
this.photon.cancelAll();
|
||||
|
||||
this._lastNostrRef = null;
|
||||
this.query = '';
|
||||
this.results = [];
|
||||
if (this.args.onQueryChange) {
|
||||
@@ -271,9 +370,10 @@ export default class SearchBoxComponent extends Component {
|
||||
(eq this.mapUi.loadingState.type "text")
|
||||
(eq this.mapUi.loadingState.type "category")
|
||||
(eq this.mapUi.loadingState.type "nearby")
|
||||
this.isNostrLookup
|
||||
)
|
||||
}}
|
||||
<Icon @name="loading-ring" @size={{20}} />
|
||||
<Icon @name="loading-ring" @size={{20}} class="search-spinner" />
|
||||
{{else}}
|
||||
<Icon @name="search" @size={{20}} @color="#5f6368" />
|
||||
{{/if}}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { service } from '@ember/service';
|
||||
import { task } from 'ember-concurrency';
|
||||
import { getDistance } from '../utils/geo';
|
||||
import { NEARBY_CATEGORY } from '../utils/poi-categories';
|
||||
import { nostrEventRouteParam } from '../utils/nostr';
|
||||
|
||||
export default class SearchController extends Controller {
|
||||
@service osm;
|
||||
@@ -55,6 +56,16 @@ export default class SearchController extends Controller {
|
||||
}
|
||||
|
||||
fetchResultsTask = task({ restartable: true }, async (params) => {
|
||||
// A Nostr event reference (typed into the search field or reached via a
|
||||
// direct /search?q=<ref> link) is handled by the /e/ route, never by a
|
||||
// Photon/bookmark search. Do this before any sidebar or loading state is
|
||||
// touched so references never flash search UI.
|
||||
const nostrRef = params.q ? nostrEventRouteParam(params.q) : null;
|
||||
if (nostrRef) {
|
||||
this.router.replaceWith('event', nostrRef);
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. Check if the incoming parameters match our currently loaded search
|
||||
const isSameSearch =
|
||||
this.mapUi.currentSearch &&
|
||||
|
||||
+22
-18
@@ -19,7 +19,8 @@ const STORAGE_KEY_CONNECT_RELAY = 'marco:nostr_connect_relay';
|
||||
|
||||
const DEFAULT_CONNECT_RELAY = 'wss://nostr.kosmos.org';
|
||||
|
||||
import { isMobile } from '../utils/device';
|
||||
/** How long to wait for a remote signer to acknowledge a NIP-46 logout. */
|
||||
export const REMOTE_SIGNER_LOGOUT_TIMEOUT = 10000;
|
||||
|
||||
export default class NostrAuthService extends Service {
|
||||
@service nostrRelay;
|
||||
@@ -79,10 +80,6 @@ export default class NostrAuthService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
get isMobile() {
|
||||
return isMobile();
|
||||
}
|
||||
|
||||
/**
|
||||
* NIP-46 client metadata: name/url/image are display hints for the signer
|
||||
* app, and the requested permissions let it pre-approve what Marco signs.
|
||||
@@ -193,15 +190,9 @@ export default class NostrAuthService extends Service {
|
||||
},
|
||||
});
|
||||
|
||||
// Set the uri for display (e.g., to redirect via intent)
|
||||
// Set the uri so the UI can offer to open a signer app or show a QR code
|
||||
this.connectUri = this._signerInstance.getNostrConnectURI(metadata);
|
||||
|
||||
// Trigger the deep link intent immediately for the user if on mobile
|
||||
if (this.isMobile) {
|
||||
console.debug('Mobile detected, triggering deep link intent.');
|
||||
window.location.href = this.connectUri;
|
||||
}
|
||||
|
||||
// Start listening to the relay
|
||||
console.debug('Opening signer connection to relay...');
|
||||
await this._signerInstance.open();
|
||||
@@ -291,17 +282,15 @@ export default class NostrAuthService extends Service {
|
||||
}
|
||||
|
||||
async disconnect() {
|
||||
const instance = this._signerInstance;
|
||||
const wasConnect = this.signerType === 'connect';
|
||||
|
||||
// Clear local state immediately, regardless of what the remote signer does.
|
||||
this.pubkey = null;
|
||||
this.nostrData?.loadProfile(null);
|
||||
this.signerType = null;
|
||||
this.connectStatus = null;
|
||||
this.connectUri = null;
|
||||
if (
|
||||
this._signerInstance &&
|
||||
typeof this._signerInstance.close === 'function'
|
||||
) {
|
||||
await this._signerInstance.close();
|
||||
}
|
||||
this._signerInstance = null;
|
||||
|
||||
localStorage.removeItem(STORAGE_KEY);
|
||||
@@ -309,5 +298,20 @@ export default class NostrAuthService extends Service {
|
||||
localStorage.removeItem(STORAGE_KEY_CONNECT_LOCAL_KEY);
|
||||
localStorage.removeItem(STORAGE_KEY_CONNECT_REMOTE_PUBKEY);
|
||||
localStorage.removeItem(STORAGE_KEY_CONNECT_RELAY);
|
||||
|
||||
if (!instance) return;
|
||||
|
||||
if (wasConnect && typeof instance.logout === 'function') {
|
||||
// NIP-46: tell the remote signer to drop the session. logout() also
|
||||
// closes the local connection and is a no-op when not connected. It is
|
||||
// a courtesy hint, so a failure must not stop the local disconnect.
|
||||
try {
|
||||
await instance.logout({ timeout: REMOTE_SIGNER_LOGOUT_TIMEOUT });
|
||||
} catch (error) {
|
||||
console.warn('Failed to send NIP-46 logout to remote signer', error);
|
||||
}
|
||||
} else if (typeof instance.close === 'function') {
|
||||
await instance.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-1
@@ -2027,13 +2027,28 @@ button.create-place {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.mobile-connect-actions {
|
||||
.signer-connect-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.signer-connect-secondary {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.signer-connect-secondary > * {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.signer-connect-hint {
|
||||
margin-top: 1rem;
|
||||
color: #b45309;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.nostr-connect-status {
|
||||
margin-top: 1.5rem;
|
||||
text-align: center;
|
||||
|
||||
+64
-6
@@ -193,6 +193,17 @@ function toReference(value) {
|
||||
}
|
||||
}
|
||||
|
||||
// Normalizes a user-supplied reference to its bare, single-segment form: drops
|
||||
// an optional `nostr:` scheme and reduces a permalink to its last path segment.
|
||||
// Returns an empty string for anything that isn't a usable string. Shared by
|
||||
// `parseNostrEventReference` and `nostrEventRouteParam` so both agree on what
|
||||
// counts as a reference.
|
||||
function normalizeNostrReference(input) {
|
||||
if (typeof input !== 'string') return '';
|
||||
const candidate = toReference(stripNostrScheme(input.trim()));
|
||||
return candidate ? stripNostrScheme(candidate) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a user-supplied event reference into an Applesauce pointer that
|
||||
* `EventStore.event()` / the event loader can resolve.
|
||||
@@ -208,12 +219,8 @@ function toReference(value) {
|
||||
* | null} An EventPointer or AddressPointer, or `null` if unrecognized
|
||||
*/
|
||||
export function parseNostrEventReference(input) {
|
||||
if (typeof input !== 'string') return null;
|
||||
|
||||
const candidate = toReference(stripNostrScheme(input.trim()));
|
||||
if (!candidate) return null;
|
||||
|
||||
const reference = stripNostrScheme(candidate);
|
||||
const reference = normalizeNostrReference(input);
|
||||
if (!reference) return null;
|
||||
|
||||
if (HEX_EVENT_ID.test(reference)) {
|
||||
return { id: reference.toLowerCase() };
|
||||
@@ -242,6 +249,21 @@ export function parseNostrEventReference(input) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the single, URL-safe reference suitable for the `/e/:event_id`
|
||||
* route when `input` is a Nostr event reference Marco can open, or `null`
|
||||
* otherwise. Unlike `parseNostrEventReference`, a pasted `nostr:` prefix or
|
||||
* full permalink is reduced to its bare path segment so it can be used
|
||||
* directly as a router dynamic segment.
|
||||
*
|
||||
* @param {string} input
|
||||
* @returns {string | null}
|
||||
*/
|
||||
export function nostrEventRouteParam(input) {
|
||||
const reference = normalizeNostrReference(input);
|
||||
return reference && parseNostrEventReference(reference) ? reference : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the place identifier (e.g. `osm:node:123`) from a place photo or
|
||||
* review event's `i` tag, or `null` when the event is not linked to an OSM
|
||||
@@ -255,3 +277,39 @@ export function placeIdentifierFromEvent(event) {
|
||||
const value = event.tags.find((tag) => tag[0] === 'i')?.[1];
|
||||
return value && PLACE_IDENTIFIER.test(value) ? value : null;
|
||||
}
|
||||
|
||||
// Event-kind labels for the search field's "Open …" row. Kept here so the
|
||||
// (kind + place-link) rules are testable independently of the component.
|
||||
export const NOSTR_PLACE_PHOTO_KIND = 360;
|
||||
export const NOSTR_PLACE_REVIEW_KIND = 30360;
|
||||
|
||||
/**
|
||||
* Builds the title/description for the search field's result row of a resolved
|
||||
* Nostr event, reflecting what kind of event it is and whether it is linked to
|
||||
* a place.
|
||||
*
|
||||
* @param {object} event A resolved Nostr event
|
||||
* @returns {{title: string, description: string}}
|
||||
*/
|
||||
export function nostrEventLabel(event) {
|
||||
const kind = event?.kind;
|
||||
let title = 'Nostr event';
|
||||
if (kind === NOSTR_PLACE_PHOTO_KIND) {
|
||||
title = 'Place photo';
|
||||
} else if (kind === NOSTR_PLACE_REVIEW_KIND) {
|
||||
title = 'Place review';
|
||||
}
|
||||
|
||||
let description;
|
||||
if (!placeIdentifierFromEvent(event)) {
|
||||
description = 'Not linked to a place';
|
||||
} else if (kind === NOSTR_PLACE_PHOTO_KIND) {
|
||||
description = 'Opens the linked place and photo';
|
||||
} else if (kind === NOSTR_PLACE_REVIEW_KIND) {
|
||||
description = 'Opens the linked place and review';
|
||||
} else {
|
||||
description = 'Opens the linked place';
|
||||
}
|
||||
|
||||
return { title, description };
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "marco",
|
||||
"version": "1.37.0",
|
||||
"version": "1.38.0",
|
||||
"private": true,
|
||||
"description": "Unhosted maps app",
|
||||
"repository": {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
var t=Object.create,e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),a=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:"Module"}),r},l=(t,i,o,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),u=0,h=c.length;u<h;u++)l=c[u],s.call(t,l)||l===o||e(t,l,{get:(t=>i[t]).bind(null,l),enumerable:!(a=n(i,l))||a.enumerable});return t},c=(n,r,o)=>(o=null!=n?t(i(n)):{},l(!r&&n&&n.__esModule&&s.call(n,"default")?o:e(o,"default",{value:n,enumerable:!0}),n)),u=(t=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(t,{get:(t,e)=>("undefined"!=typeof require?require:t)[e]}):t)(function(t){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Calling `require` for "'+t+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});!function(){const t=document.createElement("link").relList;if(!(t&&t.supports&&t.supports("modulepreload"))){for(const t of document.querySelectorAll('link[rel="modulepreload"]'))e(t);new MutationObserver(t=>{for(const n of t)if("childList"===n.type)for(const t of n.addedNodes)"LINK"===t.tagName&&"modulepreload"===t.rel&&e(t)}).observe(document,{childList:!0,subtree:!0})}function e(t){if(t.ep)return;t.ep=!0;const e=function(t){const e={};return t.integrity&&(e.integrity=t.integrity),t.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),"use-credentials"===t.crossOrigin?e.credentials="include":"anonymous"===t.crossOrigin?e.credentials="omit":e.credentials="same-origin",e}(t);fetch(t.href,e)}}();var h,d=Object.prototype,p=Symbol("undefined"),f=function(t){return t[t.ADD=0]="ADD",t[t.ONCE=1]="ONCE",t[t.REMOVE=2]="REMOVE",t}(f||{}),g=1,m=class{_descriptors;_mixins;_isInit;_lazyChains;_values;_revisions;source;proto;_parent;_listeners;_listenersVersion=1;_inheritedEnd=-1;_flattenedVersion=0;constructor(t){this._parent=void 0,this._descriptors=void 0,this._mixins=void 0,this._lazyChains=void 0,this._values=void 0,this._revisions=void 0,this._isInit=!1,this.source=t,this.proto=void 0===t.constructor?void 0:t.constructor.prototype,this._listeners=void 0}get parent(){let t=this._parent;if(void 0===t){let e=y(this.source);this._parent=t=null===e||e===d?null:_(e)}return t}setInitializing(){this._isInit=!0}unsetInitializing(){this._isInit=!1}isInitializing(){return this._isInit}isPrototypeMeta(t){return this.proto===this.source&&this.source===t}_getOrCreateOwnMap(t){return this[t]||(this[t]=Object.create(null))}_getOrCreateOwnSet(t){return this[t]||(this[t]=new Set)}_findInheritedMap(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r){let t=r.get(e);if(void 0!==t)return t}n=n.parent}}_hasInInheritedSet(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r&&r.has(e))return!0;n=n.parent}return!1}valueFor(t){let e=this._values;return void 0!==e?e[t]:void 0}setValueFor(t,e){this._getOrCreateOwnMap("_values")[t]=e}revisionFor(t){let e=this._revisions;return void 0!==e?e[t]:void 0}setRevisionFor(t,e){this._getOrCreateOwnMap("_revisions")[t]=e}writableLazyChainsFor(t){let e=this._getOrCreateOwnMap("_lazyChains"),n=e[t];return void 0===n&&(n=e[t]=[]),n}readableLazyChainsFor(t){let e=this._lazyChains;if(void 0!==e)return e[t]}addMixin(t){this._getOrCreateOwnSet("_mixins").add(t)}hasMixin(t){return this._hasInInheritedSet("_mixins",t)}forEachMixins(t){let e,n=this;for(;null!==n;){let r=n._mixins;void 0!==r&&(e=void 0===e?new Set:e,r.forEach(n=>{e.has(n)||(e.add(n),t(n))})),n=n.parent}}writeDescriptors(t,e){(this._descriptors||(this._descriptors=new Map)).set(t,e)}peekDescriptors(t){let e=this._findInheritedMap("_descriptors",t);return e===p?void 0:e}removeDescriptors(t){this.writeDescriptors(t,p)}forEachDescriptors(t){let e,n=this;for(;null!==n;){let r=n._descriptors;void 0!==r&&(e=void 0===e?new Set:e,r.forEach((n,r)=>{e.has(r)||(e.add(r),n!==p&&t(r,n))})),n=n.parent}}addToListeners(t,e,n,r,i){this.pushListener(t,e,n,r?f.ONCE:f.ADD,i)}removeFromListeners(t,e,n){this.pushListener(t,e,n,f.REMOVE)}pushListener(t,e,n,r,i=!1){let s=this.writableListeners(),o=x(s,t,e,n);if(-1!==o&&o<this._inheritedEnd&&(s.splice(o,1),this._inheritedEnd--,o=-1),-1===o)s.push({event:t,target:e,method:n,kind:r,sync:i});else{let t=s[o];r===f.REMOVE&&t.kind!==f.REMOVE?s.splice(o,1):(t.kind=r,t.sync=i)}}writableListeners(){return this._flattenedVersion!==g||this.source!==this.proto&&-1!==this._inheritedEnd||g++,-1===this._inheritedEnd&&(this._inheritedEnd=0,this._listeners=[]),this._listeners}flattenedListeners(){if(this._flattenedVersion<g){let t=this.parent;if(null!==t){let e=t.flattenedListeners();if(void 0!==e)if(void 0===this._listeners)this._listeners=e;else{let t=this._listeners;this._inheritedEnd>0&&(t.splice(0,this._inheritedEnd),this._inheritedEnd=0);for(Line truncated
|
||||
@@ -0,0 +1 @@
|
||||
var t=Object.create,e=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),a=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:"Module"}),r},l=(t,i,o,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(var l,c=r(i),u=0,h=c.length;u<h;u++)l=c[u],s.call(t,l)||l===o||e(t,l,{get:(t=>i[t]).bind(null,l),enumerable:!(a=n(i,l))||a.enumerable});return t},c=(n,r,o)=>(o=null!=n?t(i(n)):{},l(!r&&n&&n.__esModule&&s.call(n,"default")?o:e(o,"default",{value:n,enumerable:!0}),n)),u=(t=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(t,{get:(t,e)=>("undefined"!=typeof require?require:t)[e]}):t)(function(t){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Calling `require` for "'+t+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")});!function(){const t=document.createElement("link").relList;if(!(t&&t.supports&&t.supports("modulepreload"))){for(const t of document.querySelectorAll('link[rel="modulepreload"]'))e(t);new MutationObserver(t=>{for(const n of t)if("childList"===n.type)for(const t of n.addedNodes)"LINK"===t.tagName&&"modulepreload"===t.rel&&e(t)}).observe(document,{childList:!0,subtree:!0})}function e(t){if(t.ep)return;t.ep=!0;const e=function(t){const e={};return t.integrity&&(e.integrity=t.integrity),t.referrerPolicy&&(e.referrerPolicy=t.referrerPolicy),"use-credentials"===t.crossOrigin?e.credentials="include":"anonymous"===t.crossOrigin?e.credentials="omit":e.credentials="same-origin",e}(t);fetch(t.href,e)}}();var h,d=Object.prototype,p=Symbol("undefined"),f=function(t){return t[t.ADD=0]="ADD",t[t.ONCE=1]="ONCE",t[t.REMOVE=2]="REMOVE",t}(f||{}),g=1,m=class{_descriptors;_mixins;_isInit;_lazyChains;_values;_revisions;source;proto;_parent;_listeners;_listenersVersion=1;_inheritedEnd=-1;_flattenedVersion=0;constructor(t){this._parent=void 0,this._descriptors=void 0,this._mixins=void 0,this._lazyChains=void 0,this._values=void 0,this._revisions=void 0,this._isInit=!1,this.source=t,this.proto=void 0===t.constructor?void 0:t.constructor.prototype,this._listeners=void 0}get parent(){let t=this._parent;if(void 0===t){let e=y(this.source);this._parent=t=null===e||e===d?null:_(e)}return t}setInitializing(){this._isInit=!0}unsetInitializing(){this._isInit=!1}isInitializing(){return this._isInit}isPrototypeMeta(t){return this.proto===this.source&&this.source===t}_getOrCreateOwnMap(t){return this[t]||(this[t]=Object.create(null))}_getOrCreateOwnSet(t){return this[t]||(this[t]=new Set)}_findInheritedMap(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r){let t=r.get(e);if(void 0!==t)return t}n=n.parent}}_hasInInheritedSet(t,e){let n=this;for(;null!==n;){let r=n[t];if(void 0!==r&&r.has(e))return!0;n=n.parent}return!1}valueFor(t){let e=this._values;return void 0!==e?e[t]:void 0}setValueFor(t,e){this._getOrCreateOwnMap("_values")[t]=e}revisionFor(t){let e=this._revisions;return void 0!==e?e[t]:void 0}setRevisionFor(t,e){this._getOrCreateOwnMap("_revisions")[t]=e}writableLazyChainsFor(t){let e=this._getOrCreateOwnMap("_lazyChains"),n=e[t];return void 0===n&&(n=e[t]=[]),n}readableLazyChainsFor(t){let e=this._lazyChains;if(void 0!==e)return e[t]}addMixin(t){this._getOrCreateOwnSet("_mixins").add(t)}hasMixin(t){return this._hasInInheritedSet("_mixins",t)}forEachMixins(t){let e,n=this;for(;null!==n;){let r=n._mixins;void 0!==r&&(e=void 0===e?new Set:e,r.forEach(n=>{e.has(n)||(e.add(n),t(n))})),n=n.parent}}writeDescriptors(t,e){(this._descriptors||(this._descriptors=new Map)).set(t,e)}peekDescriptors(t){let e=this._findInheritedMap("_descriptors",t);return e===p?void 0:e}removeDescriptors(t){this.writeDescriptors(t,p)}forEachDescriptors(t){let e,n=this;for(;null!==n;){let r=n._descriptors;void 0!==r&&(e=void 0===e?new Set:e,r.forEach((n,r)=>{e.has(r)||(e.add(r),n!==p&&t(r,n))})),n=n.parent}}addToListeners(t,e,n,r,i){this.pushListener(t,e,n,r?f.ONCE:f.ADD,i)}removeFromListeners(t,e,n){this.pushListener(t,e,n,f.REMOVE)}pushListener(t,e,n,r,i=!1){let s=this.writableListeners(),o=x(s,t,e,n);if(-1!==o&&o<this._inheritedEnd&&(s.splice(o,1),this._inheritedEnd--,o=-1),-1===o)s.push({event:t,target:e,method:n,kind:r,sync:i});else{let t=s[o];r===f.REMOVE&&t.kind!==f.REMOVE?s.splice(o,1):(t.kind=r,t.sync=i)}}writableListeners(){return this._flattenedVersion!==g||this.source!==this.proto&&-1!==this._inheritedEnd||g++,-1===this._inheritedEnd&&(this._inheritedEnd=0,this._listeners=[]),this._listeners}flattenedListeners(){if(this._flattenedVersion<g){let t=this.parent;if(null!==t){let e=t.flattenedListeners();if(void 0!==e)if(void 0===this._listeners)this._listeners=e;else{let t=this._listeners;this._inheritedEnd>0&&(t.splice(0,this._inheritedEnd),this._inheritedEnd=0);for(Line truncated
|
||||
@@ -1 +1 @@
|
||||
:root{--body-text-color:#333;--primary-background-color:#fff;--hover-bg:#f8f9fa;--divider-color:#eee;--sidebar-width:350px;--link-color:#2a7fff;--link-color-visited:#6a4fbf;--marker-color-primary:#ea4335;--marker-color-dark:#b31412;--danger-color:var(--marker-color-primary);--danger-color-dark:var(--marker-color-dark);--default-list-color:#fc3;--secondary-text-color:#898989;--border-color:#d8d8d8;--success-color:#2e7d32;--secondary-background-color:#f0f0f0}html,body{overscroll-behavior:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;height:100%}button{-webkit-tap-highlight-color:transparent}body{color:var(--body-text-color);margin:0;font-family:Noto Sans,sans-serif;font-size:16px;font-weight:400}#root,#ember-testing{height:100%}.map-container{-webkit-tap-highlight-color:transparent;background:#f8f9fa;outline:none;position:absolute;inset:0}#rs-widget-container{z-index:4000;display:none;position:absolute;top:60px;right:10px}#rs-widget-container.visible{display:block}.rs-backdrop{z-index:3999;position:fixed;inset:0}.app-header{z-index:3000;pointer-events:none;grid-template-columns:1fr auto 1fr;grid-template-areas:"search chips user";align-items:center;gap:1rem;height:60px;padding:.5rem 1rem;display:grid;position:absolute;top:0;left:0;right:0}@media (width<=768px){.app-header{grid-template-columns:1fr auto;grid-template-areas:"search user""chips chips";row-gap:8px;height:auto;padding:.5rem .5rem 0}}.header-left,.header-right,.header-center{pointer-events:auto}.header-left{grid-area:search;justify-self:start;align-items:center;width:100%;display:flex}@media (width>768px){.header-left{min-width:300px;max-width:350px}}.header-right{grid-area:user;justify-self:end}.header-center{grid-area:chips;justify-content:center;min-width:0;display:flex}@media (width>768px){.header-center .category-chips-scroll{width:auto;max-width:100%}}@media (width<=768px){.header-center{justify-content:start;width:100%;overflow:hidden}.header-center.searching{display:none}}.btn-press{transition:transform .1s}.btn-press:active{transform:scale(.95)}.user-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:flex}.user-avatar-placeholder{background:#2a3743;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:40px;height:40px;display:flex}.user-avatar{object-fit:cover;border-radius:50%;flex-shrink:0;width:40px;height:40px;display:block}.photo-preview-img{max-width:100%;height:auto}.dropzone{text-align:center;cursor:pointer;aspect-ratio:4/3;background-color:#ffffff05;border:2px dashed #ccc;border-radius:8px;margin:1.5rem 0 1rem;transition:all .2s}.dropzone.is-dragging{background-color:#61afef0d;border-color:#61afef}.dropzone-label{cursor:pointer;color:#898989;flex-direction:column;justify-content:center;align-items:center;gap:1rem;width:100%;height:100%;display:flex}.dropzone-label p{margin:0}.file-input-hidden{display:none}.photo-upload-item{aspect-ratio:4/3;background:#1e262e;border-radius:6px;width:100%;margin-bottom:1.25rem;position:relative;overflow:hidden}.photo-upload-item img{object-fit:contain;z-index:1;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.photo-upload-item .overlay,.photo-upload-item .btn-remove-photo{z-index:2}.photo-upload-item .overlay{background:#0009;flex-direction:column;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.upload-status-text{color:#fff;text-shadow:0 1px 3px #000c;text-align:center;margin-top:1rem;padding:0 1rem;font-size:.9rem}.photo-upload-item .error-overlay{cursor:pointer;background:#e06c75cc;border:none;width:100%;margin:0;padding:0}.photo-upload-item .btn-remove-photo{cursor:pointer;color:#fff;background:#000000b3;border:none;border-radius:50%;justify-content:center;align-items:center;width:24px;height:24px;padding:0;display:flex;position:absolute;top:4px;right:4px}.photo-upload-item .btn-remove-photo:hover{background:var(--danger-color)}.spin-animation{animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.btn-publish{width:100%}.user-menu-container{position:relative}.user-menu-popover{z-index:3001;background:#fff;border-radius:8px;width:280px;margin-top:10px;padding:1rem;position:absolute;top:100%;right:0;box-shadow:0 4px 12px #00000026}.menu-backdrop{z-index:3000;position:fixed;inset:0}.account-list{margin:0;padding:0;list-style:none}.account-item{border-bottom:1px solid var(--divider-color);flex-direction:column;padding:1rem 0;display:flex}.account-item:last-child{border-bottom:none;padding-bottom:0}.account-item:first-child{padding-top:0}.account-header{justify-content:space-between;align-items:center;display:flex}.account-status{color:#898989;white-space:nowrap;text-overflow:ellipsis;margin-top:.35rem;margin-left:calc(18px + .75rem);font-size:.85rem;overflow:hidden}.account-status strong{font-weight:600}.account-item.disaLine truncated
|
||||
:root{--body-text-color:#333;--primary-background-color:#fff;--hover-bg:#f8f9fa;--divider-color:#eee;--sidebar-width:350px;--link-color:#2a7fff;--link-color-visited:#6a4fbf;--marker-color-primary:#ea4335;--marker-color-dark:#b31412;--danger-color:var(--marker-color-primary);--danger-color-dark:var(--marker-color-dark);--default-list-color:#fc3;--secondary-text-color:#898989;--border-color:#d8d8d8;--success-color:#2e7d32;--secondary-background-color:#f0f0f0}html,body{overscroll-behavior:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;height:100%}button{-webkit-tap-highlight-color:transparent}body{color:var(--body-text-color);margin:0;font-family:Noto Sans,sans-serif;font-size:16px;font-weight:400}#root,#ember-testing{height:100%}.map-container{-webkit-tap-highlight-color:transparent;background:#f8f9fa;outline:none;position:absolute;inset:0}#rs-widget-container{z-index:4000;display:none;position:absolute;top:60px;right:10px}#rs-widget-container.visible{display:block}.rs-backdrop{z-index:3999;position:fixed;inset:0}.app-header{z-index:3000;pointer-events:none;grid-template-columns:1fr auto 1fr;grid-template-areas:"search chips user";align-items:center;gap:1rem;height:60px;padding:.5rem 1rem;display:grid;position:absolute;top:0;left:0;right:0}@media (width<=768px){.app-header{grid-template-columns:1fr auto;grid-template-areas:"search user""chips chips";row-gap:8px;height:auto;padding:.5rem .5rem 0}}.header-left,.header-right,.header-center{pointer-events:auto}.header-left{grid-area:search;justify-self:start;align-items:center;width:100%;display:flex}@media (width>768px){.header-left{min-width:300px;max-width:350px}}.header-right{grid-area:user;justify-self:end}.header-center{grid-area:chips;justify-content:center;min-width:0;display:flex}@media (width>768px){.header-center .category-chips-scroll{width:auto;max-width:100%}}@media (width<=768px){.header-center{justify-content:start;width:100%;overflow:hidden}.header-center.searching{display:none}}.btn-press{transition:transform .1s}.btn-press:active{transform:scale(.95)}.user-btn{cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;display:flex}.user-avatar-placeholder{background:#2a3743;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:40px;height:40px;display:flex}.user-avatar{object-fit:cover;border-radius:50%;flex-shrink:0;width:40px;height:40px;display:block}.photo-preview-img{max-width:100%;height:auto}.dropzone{text-align:center;cursor:pointer;aspect-ratio:4/3;background-color:#ffffff05;border:2px dashed #ccc;border-radius:8px;margin:1.5rem 0 1rem;transition:all .2s}.dropzone.is-dragging{background-color:#61afef0d;border-color:#61afef}.dropzone-label{cursor:pointer;color:#898989;flex-direction:column;justify-content:center;align-items:center;gap:1rem;width:100%;height:100%;display:flex}.dropzone-label p{margin:0}.file-input-hidden{display:none}.photo-upload-item{aspect-ratio:4/3;background:#1e262e;border-radius:6px;width:100%;margin-bottom:1.25rem;position:relative;overflow:hidden}.photo-upload-item img{object-fit:contain;z-index:1;width:100%;height:100%;display:block;position:absolute;top:0;left:0}.photo-upload-item .overlay,.photo-upload-item .btn-remove-photo{z-index:2}.photo-upload-item .overlay{background:#0009;flex-direction:column;justify-content:center;align-items:center;display:flex;position:absolute;inset:0}.upload-status-text{color:#fff;text-shadow:0 1px 3px #000c;text-align:center;margin-top:1rem;padding:0 1rem;font-size:.9rem}.photo-upload-item .error-overlay{cursor:pointer;background:#e06c75cc;border:none;width:100%;margin:0;padding:0}.photo-upload-item .btn-remove-photo{cursor:pointer;color:#fff;background:#000000b3;border:none;border-radius:50%;justify-content:center;align-items:center;width:24px;height:24px;padding:0;display:flex;position:absolute;top:4px;right:4px}.photo-upload-item .btn-remove-photo:hover{background:var(--danger-color)}.spin-animation{animation:1s linear infinite spin}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.btn-publish{width:100%}.user-menu-container{position:relative}.user-menu-popover{z-index:3001;background:#fff;border-radius:8px;width:280px;margin-top:10px;padding:1rem;position:absolute;top:100%;right:0;box-shadow:0 4px 12px #00000026}.menu-backdrop{z-index:3000;position:fixed;inset:0}.account-list{margin:0;padding:0;list-style:none}.account-item{border-bottom:1px solid var(--divider-color);flex-direction:column;padding:1rem 0;display:flex}.account-item:last-child{border-bottom:none;padding-bottom:0}.account-item:first-child{padding-top:0}.account-header{justify-content:space-between;align-items:center;display:flex}.account-status{color:#898989;white-space:nowrap;text-overflow:ellipsis;margin-top:.35rem;margin-left:calc(18px + .75rem);font-size:.85rem;overflow:hidden}.account-status strong{font-weight:600}.account-item.disaLine truncated
|
||||
@@ -1 +1 @@
|
||||
import{$ as e,$n as t,$t as a,A as n,An as s,Ar as r,At as i,B as o,Bn as l,Br as g,Bt as d,C as h,Cn as c,Cr as u,Ct as p,D as _,Dn as m,Dr as y,Dt as C,E as b,En as f,Er as A,Et as M,F as I,Fn as D,Fr as T,Ft as v,G as O,Gn as E,Gr as S,Gt as R,H as j,Hn as x,Hr as w,Ht as P,I as N,In as V,Ir as F,It as G,J as L,Jn as k,Jr as U,Jt as Y,K as B,Kn as H,Kr as $,Kt as z,L as W,Ln as q,Lr as Z,Lt as J,M as K,Mn as X,Mr as Q,Mt as ee,N as te,Nn as ae,Nr as ne,Nt as se,O as re,On as ie,Or as oe,Ot as le,P as ge,Pn as de,Pr as he,Pt as ce,Q as ue,Qn as pe,Qt as _e,R as me,Rn as ye,Rr as Ce,Rt as be,S as fe,Sn as Ae,Sr as Me,St as Ie,T as De,Tn as Te,Tr as ve,Tt as Oe,U as Ee,Un as Se,Ur as Re,Ut as je,V as xe,Vn as we,Vr as Pe,Vt as Ne,W as Ve,Wn as Fe,Wr as Ge,Wt as Le,X as ke,Xn as Ue,Xr as Ye,Xt as Be,Y as He,Yn as $e,Yr as ze,Yt as We,Z as qe,Zn as Ze,Zr as Je,Zt as Ke,_ as Xe,_n as Qe,_r as et,_t as tt,a as at,an as nt,ar as st,at as rt,b as it,bn as ot,br as lt,bt as gt,c as dt,cn as ht,cr as ct,ct as ut,d as pt,dn as _t,dr as mt,dt as yt,en as Ct,er as bt,et as ft,f as At,fn as Mt,fr as It,ft as Dt,g as Tt,gn as vt,gr as Ot,gt as Et,h as St,hn as Rt,hr as jt,ht as xt,i as wt,in as Pt,ir as Nt,it as Vt,j as Ft,jn as Gt,jr as Lt,jt as kt,k as Ut,kn as Yt,kr as Bt,kt as Ht,l as $t,ln as zt,lr as Wt,lt as qt,m as Zt,mn as Jt,mr as Kt,mt as Xt,n as Qt,nn as ea,nr as ta,nt as aa,o as na,on as sa,or as ra,ot as ia,p as oa,pn as la,pr as ga,pt as da,q as ha,qn as ca,qr as ua,qt as pa,r as _a,rn as ma,rr as ya,rt as Ca,s as ba,sn as fa,sr as Aa,st as Ma,t as Ia,tn as Da,tr as Ta,tt as va,u as Oa,un as Ea,ur as Sa,ut as Ra,v as ja,vn as xa,vr as wa,vt as Pa,w as Na,wn as Va,wr as Fa,wt as Ga,x as La,xn as ka,xr as Ua,xt as Ya,y as Ba,yn as Ha,yr as $a,yt as za,z as Wa,zn as qa,zr as Za,zt as Ja}from"./main-BD5lfqyM.js";var Ka=Je({default:()=>Jt}),Xa=Je({default:()=>tn}),Qa={willChange:"_arrangedContentArrayWillChange",didChange:"_arrangedContentArrayDidChange"};function en(e,t){return"[]"===t?(e._revalidate(),e._arrTag):"length"===t?(e._revalidate(),e._lengthTag):F(e,t)}var tn=class extends V{_objectsDirtyIndex=0;_objects=null;_lengthDirty=!0;_length=0;_arrangedContent=null;_arrangedContentIsUpdating=!1;_arrangedContentTag=null;_arrangedContentRevision=null;_lengthTag=null;_arrTag=null;init(e){super.init(e),y(this,en)}[Ot](){this._revalidate()}willDestroy(){this._removeArrangedContentArrayObserver()}objectAtContent(e){let t=It(this,"arrangedContent");return Fa(t,e)}replace(e,t,a){this.replaceContent(e,t,a)}replaceContent(e,t,a){let n=It(this,"content");Wt(n,e,t,a)}objectAt(e){if(this._revalidate(),null===this._objects&&(this._objects=[]),-1!==this._objectsDirtyIndex&&e>=this._objectsDirtyIndex){let e=It(this,"arrangedContent");if(e){let t=this._objects.length=It(e,"length");for(let e=this._objectsDirtyIndex;e<t;e++)this._objects[e]=this.objectAtContent(e)}else this._objects.length=0;this._objectsDirtyIndex=-1}return this._objects[e]}get length(){if(this._revalidate(),this._lengthDirty){let e=It(this,"arrangedContent");this._length=e?It(e,"length"):0,this._lengthDirty=!1}return Ce(this._lengthTag),this._length}set length(e){let t,a=this.length-e;if(0===a)return;a<0&&(t=new Array(-a),a=0);let n=It(this,"content");n&&(Wt(n,e,a,t),this._invalidate())}_updateArrangedContentArray(e){let t=null===this._objects?0:this._objects.length,a=e?It(e,"length"):0;this._removeArrangedContentArrayObserver(),Aa(this,0,t,a),this._invalidate(),ra(this,0,t,a,!1),this._addArrangedContentArrayObserver(e)}_addArrangedContentArrayObserver(e){e&&!e.isDestroyed&&(st(e,this,Qa),this._arrangedContent=e)}_removeArrangedContentArrayObserver(){this._arrangedContent&&ct(this._arrangedContent,this,Qa)}_arrangedContentArrayWillChange(){}_arrangedContentArrayDidChange(e,t,a,n){Aa(this,t,a,n);let s=t;s<0&&(s+=It(this._arrangedContent,"length")+a-n),(-1===this._objectsDirtyIndex||this._objectsDirtyIndex>s)&&(this._objectsDirtyIndex=s),this._lengthDirty=!0,ra(this,t,a,n,!1)}_invalidate(){this._objectsDirtyIndex=0,this._lengthDirty=!0}_revalidate(){if(!0!==this._arrangedContentIsUpdating&&(null===this._arrangedContentTag||!Za(this._arrangedContentTag,this._arrangedContentRevision))){let e=this.get("arrangedContent");null===this._arrangedContentTag?this._addArrangedContentArrayObserver(e):(this._arrangedContentIsUpdating=!0,this._updateArrangedContentArray(e),this._arrangedContentIsUpdating=!1);let t=this._arrangedContentTag=F(this,"arrangedContent");this._arrangedContentRevision=g(this._arrangedContentTag),T(e)?(this._lengthTag=Z([t,ve(e,"length")]),this._arrTag=Z([t,ve(e,"[]")])):this._lengthTag=this._arrTag=t}}};tn.reopen(Jt,{arrangedContent:Sa("content")});var an=Je({Meta:()=>S,UNDEFINED:()=>$,counters:()=>ua,meta:()=>U,peekMeta:()=>ze,setMeta:()=>Ye}),nn=Je({ActionHandler:()=>l,Comparable:()=>vt,ContainerProxyMixin:()=>_t,MutableEnumerable:()=>Qe,RSVP:()=>k,RegistryProxyMixin:()=>Ea,TargetActionSupport:()=>ja,_ProxyMixin:()=>O,_contentFor:()=>B,onerrorLine truncated
|
||||
import{$ as e,$n as t,$t as a,A as n,An as s,Ar as r,At as i,B as o,Bn as l,Br as g,Bt as d,C as h,Cn as c,Cr as u,Ct as p,D as _,Dn as m,Dr as y,Dt as C,E as b,En as f,Er as A,Et as M,F as I,Fn as D,Fr as T,Ft as v,G as O,Gn as E,Gr as S,Gt as R,H as j,Hn as x,Hr as w,Ht as P,I as N,In as V,Ir as F,It as G,J as L,Jn as k,Jr as U,Jt as Y,K as B,Kn as H,Kr as $,Kt as z,L as W,Ln as q,Lr as Z,Lt as J,M as K,Mn as X,Mr as Q,Mt as ee,N as te,Nn as ae,Nr as ne,Nt as se,O as re,On as ie,Or as oe,Ot as le,P as ge,Pn as de,Pr as he,Pt as ce,Q as ue,Qn as pe,Qt as _e,R as me,Rn as ye,Rr as Ce,Rt as be,S as fe,Sn as Ae,Sr as Me,St as Ie,T as De,Tn as Te,Tr as ve,Tt as Oe,U as Ee,Un as Se,Ur as Re,Ut as je,V as xe,Vn as we,Vr as Pe,Vt as Ne,W as Ve,Wn as Fe,Wr as Ge,Wt as Le,X as ke,Xn as Ue,Xr as Ye,Xt as Be,Y as He,Yn as $e,Yr as ze,Yt as We,Z as qe,Zn as Ze,Zr as Je,Zt as Ke,_ as Xe,_n as Qe,_r as et,_t as tt,a as at,an as nt,ar as st,at as rt,b as it,bn as ot,br as lt,bt as gt,c as dt,cn as ht,cr as ct,ct as ut,d as pt,dn as _t,dr as mt,dt as yt,en as Ct,er as bt,et as ft,f as At,fn as Mt,fr as It,ft as Dt,g as Tt,gn as vt,gr as Ot,gt as Et,h as St,hn as Rt,hr as jt,ht as xt,i as wt,in as Pt,ir as Nt,it as Vt,j as Ft,jn as Gt,jr as Lt,jt as kt,k as Ut,kn as Yt,kr as Bt,kt as Ht,l as $t,ln as zt,lr as Wt,lt as qt,m as Zt,mn as Jt,mr as Kt,mt as Xt,n as Qt,nn as ea,nr as ta,nt as aa,o as na,on as sa,or as ra,ot as ia,p as oa,pn as la,pr as ga,pt as da,q as ha,qn as ca,qr as ua,qt as pa,r as _a,rn as ma,rr as ya,rt as Ca,s as ba,sn as fa,sr as Aa,st as Ma,t as Ia,tn as Da,tr as Ta,tt as va,u as Oa,un as Ea,ur as Sa,ut as Ra,v as ja,vn as xa,vr as wa,vt as Pa,w as Na,wn as Va,wr as Fa,wt as Ga,x as La,xn as ka,xr as Ua,xt as Ya,y as Ba,yn as Ha,yr as $a,yt as za,z as Wa,zn as qa,zr as Za,zt as Ja}from"./main-BHr2t0K0.js";var Ka=Je({default:()=>Jt}),Xa=Je({default:()=>tn}),Qa={willChange:"_arrangedContentArrayWillChange",didChange:"_arrangedContentArrayDidChange"};function en(e,t){return"[]"===t?(e._revalidate(),e._arrTag):"length"===t?(e._revalidate(),e._lengthTag):F(e,t)}var tn=class extends V{_objectsDirtyIndex=0;_objects=null;_lengthDirty=!0;_length=0;_arrangedContent=null;_arrangedContentIsUpdating=!1;_arrangedContentTag=null;_arrangedContentRevision=null;_lengthTag=null;_arrTag=null;init(e){super.init(e),y(this,en)}[Ot](){this._revalidate()}willDestroy(){this._removeArrangedContentArrayObserver()}objectAtContent(e){let t=It(this,"arrangedContent");return Fa(t,e)}replace(e,t,a){this.replaceContent(e,t,a)}replaceContent(e,t,a){let n=It(this,"content");Wt(n,e,t,a)}objectAt(e){if(this._revalidate(),null===this._objects&&(this._objects=[]),-1!==this._objectsDirtyIndex&&e>=this._objectsDirtyIndex){let e=It(this,"arrangedContent");if(e){let t=this._objects.length=It(e,"length");for(let e=this._objectsDirtyIndex;e<t;e++)this._objects[e]=this.objectAtContent(e)}else this._objects.length=0;this._objectsDirtyIndex=-1}return this._objects[e]}get length(){if(this._revalidate(),this._lengthDirty){let e=It(this,"arrangedContent");this._length=e?It(e,"length"):0,this._lengthDirty=!1}return Ce(this._lengthTag),this._length}set length(e){let t,a=this.length-e;if(0===a)return;a<0&&(t=new Array(-a),a=0);let n=It(this,"content");n&&(Wt(n,e,a,t),this._invalidate())}_updateArrangedContentArray(e){let t=null===this._objects?0:this._objects.length,a=e?It(e,"length"):0;this._removeArrangedContentArrayObserver(),Aa(this,0,t,a),this._invalidate(),ra(this,0,t,a,!1),this._addArrangedContentArrayObserver(e)}_addArrangedContentArrayObserver(e){e&&!e.isDestroyed&&(st(e,this,Qa),this._arrangedContent=e)}_removeArrangedContentArrayObserver(){this._arrangedContent&&ct(this._arrangedContent,this,Qa)}_arrangedContentArrayWillChange(){}_arrangedContentArrayDidChange(e,t,a,n){Aa(this,t,a,n);let s=t;s<0&&(s+=It(this._arrangedContent,"length")+a-n),(-1===this._objectsDirtyIndex||this._objectsDirtyIndex>s)&&(this._objectsDirtyIndex=s),this._lengthDirty=!0,ra(this,t,a,n,!1)}_invalidate(){this._objectsDirtyIndex=0,this._lengthDirty=!0}_revalidate(){if(!0!==this._arrangedContentIsUpdating&&(null===this._arrangedContentTag||!Za(this._arrangedContentTag,this._arrangedContentRevision))){let e=this.get("arrangedContent");null===this._arrangedContentTag?this._addArrangedContentArrayObserver(e):(this._arrangedContentIsUpdating=!0,this._updateArrangedContentArray(e),this._arrangedContentIsUpdating=!1);let t=this._arrangedContentTag=F(this,"arrangedContent");this._arrangedContentRevision=g(this._arrangedContentTag),T(e)?(this._lengthTag=Z([t,ve(e,"length")]),this._arrTag=Z([t,ve(e,"[]")])):this._lengthTag=this._arrTag=t}}};tn.reopen(Jt,{arrangedContent:Sa("content")});var an=Je({Meta:()=>S,UNDEFINED:()=>$,counters:()=>ua,meta:()=>U,peekMeta:()=>ze,setMeta:()=>Ye}),nn=Je({ActionHandler:()=>l,Comparable:()=>vt,ContainerProxyMixin:()=>_t,MutableEnumerable:()=>Qe,RSVP:()=>k,RegistryProxyMixin:()=>Ea,TargetActionSupport:()=>ja,_ProxyMixin:()=>O,_contentFor:()=>B,onerrorLine truncated
|
||||
+2
-2
@@ -42,8 +42,8 @@
|
||||
<meta name="msapplication-TileColor" content="#F6E9A6">
|
||||
<meta name="msapplication-TileImage" content="/icons/icon-144.png">
|
||||
|
||||
<script type="module" crossorigin src="/assets/main-BD5lfqyM.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-D1ODG1Dj.css">
|
||||
<script type="module" crossorigin src="/assets/main-BHr2t0K0.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-D1hwoGyg.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="modal-portal"></div>
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { visit, currentURL, click } from '@ember/test-helpers';
|
||||
import {
|
||||
visit,
|
||||
currentURL,
|
||||
click,
|
||||
waitFor,
|
||||
waitUntil,
|
||||
} from '@ember/test-helpers';
|
||||
import { setupApplicationTest } from 'marco/tests/helpers';
|
||||
import Service from '@ember/service';
|
||||
import { MockNostrDataService } from 'marco/tests/helpers/mock-nostr';
|
||||
|
||||
const NOSTR_EVENT_ID =
|
||||
'1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb';
|
||||
|
||||
module('Acceptance | search', function (hooks) {
|
||||
setupApplicationTest(hooks);
|
||||
@@ -452,4 +462,122 @@ module('Acceptance | search', function (hooks) {
|
||||
assert.strictEqual(currentURL(), '/', 'Dismissing nearby clears the route');
|
||||
assert.strictEqual(mapUi.searchResults.length, 0, 'Results are cleared');
|
||||
});
|
||||
|
||||
test('a /search?q=<hex> link opens the linked place via the /e/ handler', async function (assert) {
|
||||
class StubNostrDataService extends MockNostrDataService {
|
||||
async loadEventByPointer() {
|
||||
return { id: NOSTR_EVENT_ID, kind: 360, tags: [['i', 'osm:node:123']] };
|
||||
}
|
||||
}
|
||||
this.owner.register('service:nostr-data', StubNostrDataService);
|
||||
|
||||
class MockOsmService extends Service {
|
||||
async fetchOsmObject(id, type) {
|
||||
return {
|
||||
osmId: id,
|
||||
osmType: type,
|
||||
lat: 1,
|
||||
lon: 1,
|
||||
osmTags: { name: 'Test Place' },
|
||||
title: 'Test Place',
|
||||
};
|
||||
}
|
||||
}
|
||||
this.owner.register('service:osm', MockOsmService);
|
||||
|
||||
class MockStorageService extends Service {
|
||||
initialSyncDone = true;
|
||||
savedPlaces = [];
|
||||
findPlaceById() {
|
||||
return null;
|
||||
}
|
||||
isPlaceSaved() {
|
||||
return false;
|
||||
}
|
||||
loadPlacesInBounds() {
|
||||
return [];
|
||||
}
|
||||
get placesInView() {
|
||||
return [];
|
||||
}
|
||||
rs = { on: () => {} };
|
||||
}
|
||||
this.owner.register('service:storage', MockStorageService);
|
||||
|
||||
let photonCalled = false;
|
||||
class MockPhotonService extends Service {
|
||||
async search() {
|
||||
photonCalled = true;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
this.owner.register('service:photon', MockPhotonService);
|
||||
|
||||
try {
|
||||
await visit(`/search?q=${NOSTR_EVENT_ID}`);
|
||||
} catch {
|
||||
// The /search transition is aborted by the redirect to /e/; expected.
|
||||
}
|
||||
|
||||
await waitUntil(
|
||||
() => currentURL() === `/place/osm:node:123?photo=${NOSTR_EVENT_ID}`,
|
||||
{ timeout: 5000 }
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
`/place/osm:node:123?photo=${NOSTR_EVENT_ID}`,
|
||||
'ends on the place with the focused photo'
|
||||
);
|
||||
assert.false(photonCalled, 'Photon was never called for a reference');
|
||||
});
|
||||
|
||||
test('a /search?q=<hex> link to an unknown event returns to the map with a toast', async function (assert) {
|
||||
class StubNostrDataService extends MockNostrDataService {
|
||||
async loadEventByPointer() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
this.owner.register('service:nostr-data', StubNostrDataService);
|
||||
|
||||
class MockStorageService extends Service {
|
||||
initialSyncDone = true;
|
||||
savedPlaces = [];
|
||||
findPlaceById() {
|
||||
return null;
|
||||
}
|
||||
isPlaceSaved() {
|
||||
return false;
|
||||
}
|
||||
loadPlacesInBounds() {
|
||||
return [];
|
||||
}
|
||||
get placesInView() {
|
||||
return [];
|
||||
}
|
||||
rs = { on: () => {} };
|
||||
}
|
||||
this.owner.register('service:storage', MockStorageService);
|
||||
|
||||
let photonCalled = false;
|
||||
class MockPhotonService extends Service {
|
||||
async search() {
|
||||
photonCalled = true;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
this.owner.register('service:photon', MockPhotonService);
|
||||
|
||||
try {
|
||||
await visit(`/search?q=${NOSTR_EVENT_ID}`);
|
||||
} catch {
|
||||
// The /search transition is aborted by the redirect to /e/; expected.
|
||||
}
|
||||
|
||||
await waitUntil(() => currentURL() === '/', { timeout: 5000 });
|
||||
assert.strictEqual(currentURL(), '/', 'returns to the map');
|
||||
await waitFor('.toast-notification', { timeout: 5000 });
|
||||
assert.dom('.toast-notification').exists('a toast reports the failure');
|
||||
assert.false(photonCalled, 'Photon was never called for a reference');
|
||||
});
|
||||
});
|
||||
@@ -17,10 +17,6 @@ export class MockNostrAuthService extends Service {
|
||||
);
|
||||
}
|
||||
|
||||
get isMobile() {
|
||||
return false;
|
||||
}
|
||||
|
||||
get signer() {
|
||||
return null;
|
||||
}
|
||||
@@ -62,6 +58,8 @@ export class MockNostrDataService extends Service {
|
||||
return this.profiles[pubkey];
|
||||
}
|
||||
|
||||
loadProfile() {}
|
||||
|
||||
getEventRelays() {
|
||||
return [];
|
||||
}
|
||||
@@ -108,6 +106,10 @@ export class MockNostrDataService extends Service {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
loadEventByPointer() {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
loadPlacePhotos() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'marco/tests/helpers';
|
||||
import {
|
||||
render,
|
||||
click,
|
||||
waitUntil,
|
||||
settled,
|
||||
findAll,
|
||||
} from '@ember/test-helpers';
|
||||
import Service from '@ember/service';
|
||||
import NostrConnect from 'marco/components/nostr-connect';
|
||||
import { setupNostrMocks } from 'marco/tests/helpers/mock-nostr';
|
||||
|
||||
class MockToastService extends Service {
|
||||
show() {}
|
||||
}
|
||||
|
||||
const CONNECT_URI = 'nostrconnect://abc123@wss://relay.test';
|
||||
|
||||
module('Integration | Component | nostr-connect', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
setupNostrMocks(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
this.owner.register('service:toast', MockToastService);
|
||||
|
||||
this.nostrAuth = this.owner.lookup('service:nostrAuth');
|
||||
this.nostrAuth.connectStatus = 'waiting';
|
||||
this.nostrAuth.connectUri = CONNECT_URI;
|
||||
|
||||
// Clicking the `nostrconnect://` anchor would attempt a real navigation in
|
||||
// the test browser. Prevent only the default action; the component's click
|
||||
// listener still runs.
|
||||
this.preventNav = (event) => {
|
||||
if (event.target.closest?.('a[href^="nostrconnect:"]')) {
|
||||
event.preventDefault();
|
||||
}
|
||||
};
|
||||
document.addEventListener('click', this.preventNav, true);
|
||||
});
|
||||
|
||||
hooks.afterEach(function () {
|
||||
document.removeEventListener('click', this.preventNav, true);
|
||||
});
|
||||
|
||||
test('offers a signer app option without calling it mobile-only', async function (assert) {
|
||||
await render(<template><NostrConnect /></template>);
|
||||
|
||||
assert
|
||||
.dom('.nostr-connect-options')
|
||||
.includesText('Signer app (Amber, Regent, etc.)');
|
||||
assert
|
||||
.dom('.nostr-connect-modal')
|
||||
.doesNotIncludeText('Mobile Signer', 'not described as mobile-only');
|
||||
});
|
||||
|
||||
test('offers opening the signer app on any device while waiting', async function (assert) {
|
||||
await render(<template><NostrConnect /></template>);
|
||||
|
||||
assert.dom('a.btn').hasText('Open signer app');
|
||||
assert.dom('a.btn').hasAttribute('href', CONNECT_URI);
|
||||
assert
|
||||
.dom('.signer-connect-secondary')
|
||||
.includesText('Copy connection link');
|
||||
assert.dom('.signer-connect-secondary').includesText('Show QR code');
|
||||
assert.dom('.qr-code-container').doesNotExist('QR code hidden by default');
|
||||
});
|
||||
|
||||
test('toggles the QR code on and off', async function (assert) {
|
||||
await render(<template><NostrConnect /></template>);
|
||||
|
||||
const [, toggle] = findAll('.signer-connect-secondary .btn');
|
||||
|
||||
await click(toggle);
|
||||
assert.dom('.qr-code-container canvas').exists('QR code shown on demand');
|
||||
assert.dom(toggle).hasText('Hide QR code');
|
||||
|
||||
await click(toggle);
|
||||
assert.dom('.qr-code-container').doesNotExist('QR code hidden again');
|
||||
assert.dom(toggle).hasText('Show QR code');
|
||||
});
|
||||
|
||||
test('reveals a fallback hint when the signer app does not open', async function (assert) {
|
||||
await render(<template><NostrConnect /></template>);
|
||||
|
||||
assert.dom('.signer-connect-hint').doesNotExist('hint hidden initially');
|
||||
|
||||
await click('a.btn');
|
||||
|
||||
await waitUntil(() => document.querySelector('.signer-connect-hint'), {
|
||||
timeout: 4000,
|
||||
message: 'fallback hint appears after the launch timeout',
|
||||
});
|
||||
|
||||
assert.dom('.signer-connect-hint').includesText('Scan the QR code');
|
||||
});
|
||||
|
||||
test('stays quiet when the page is hidden (signer app took over)', async function (assert) {
|
||||
const originalVisibility = Object.getOwnPropertyDescriptor(
|
||||
document,
|
||||
'visibilityState'
|
||||
);
|
||||
|
||||
try {
|
||||
await render(<template><NostrConnect /></template>);
|
||||
|
||||
Object.defineProperty(document, 'visibilityState', {
|
||||
configurable: true,
|
||||
get: () => 'hidden',
|
||||
});
|
||||
|
||||
await click('a.btn');
|
||||
document.dispatchEvent(new Event('visibilitychange'));
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 2300));
|
||||
await settled();
|
||||
|
||||
assert
|
||||
.dom('.signer-connect-hint')
|
||||
.doesNotExist('no hint when the signer app opened');
|
||||
} finally {
|
||||
if (originalVisibility) {
|
||||
Object.defineProperty(document, 'visibilityState', originalVisibility);
|
||||
} else {
|
||||
delete document.visibilityState;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,20 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'marco/tests/helpers';
|
||||
import { render, fillIn, click, waitFor, focus } from '@ember/test-helpers';
|
||||
import {
|
||||
render,
|
||||
fillIn,
|
||||
click,
|
||||
waitFor,
|
||||
focus,
|
||||
blur,
|
||||
waitUntil,
|
||||
} from '@ember/test-helpers';
|
||||
import SearchBox from 'marco/components/search-box';
|
||||
import Service from '@ember/service';
|
||||
|
||||
const NOSTR_EVENT_ID =
|
||||
'1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb';
|
||||
|
||||
module('Integration | Component | search-box', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
@@ -506,4 +517,274 @@ module('Integration | Component | search-box', function (hooks) {
|
||||
// Verify it navigated using the internal ID, NOT a search query
|
||||
assert.verifySteps(['transitionTo: place ["custom-1234"]']);
|
||||
});
|
||||
|
||||
test('it resolves a Nostr reference inline and opens it on click', async function (assert) {
|
||||
let resolveLookup;
|
||||
let loadedPointer;
|
||||
|
||||
class MockNostrDataService extends Service {
|
||||
loadEventByPointer(pointer) {
|
||||
loadedPointer = pointer;
|
||||
return new Promise((resolve) => {
|
||||
resolveLookup = resolve;
|
||||
});
|
||||
}
|
||||
}
|
||||
this.owner.register('service:nostr-data', MockNostrDataService);
|
||||
|
||||
let photonCalled = false;
|
||||
class MockPhotonService extends Service {
|
||||
async search() {
|
||||
photonCalled = true;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
this.owner.register('service:photon', MockPhotonService);
|
||||
|
||||
class MockRouterService extends Service {
|
||||
transitionTo(routeName, ...args) {
|
||||
assert.step(`transitionTo: ${routeName} ${JSON.stringify(args)}`);
|
||||
}
|
||||
}
|
||||
this.owner.register('service:router', MockRouterService);
|
||||
|
||||
this.noop = () => {};
|
||||
await render(
|
||||
<template><SearchBox @onToggleMenu={{this.noop}} /></template>
|
||||
);
|
||||
|
||||
await fillIn('.search-input', NOSTR_EVENT_ID);
|
||||
|
||||
// The spinner appears while the event is being resolved.
|
||||
await waitFor('.search-spinner', { timeout: 2000 });
|
||||
assert.dom('.search-spinner').exists('shows a spinner while resolving');
|
||||
|
||||
resolveLookup({
|
||||
id: NOSTR_EVENT_ID,
|
||||
kind: 360,
|
||||
tags: [['i', 'osm:node:123']],
|
||||
});
|
||||
await waitFor('.search-result-item', { timeout: 2000 });
|
||||
|
||||
assert.deepEqual(
|
||||
loadedPointer,
|
||||
{ id: NOSTR_EVENT_ID },
|
||||
'resolves the parsed event pointer'
|
||||
);
|
||||
assert.dom('.search-result-item').exists({ count: 1 });
|
||||
assert.dom('.result-title').hasText('Place photo');
|
||||
assert.dom('.result-desc').hasText('Opens the linked place and photo');
|
||||
assert.false(photonCalled, 'Photon is not called for a reference');
|
||||
|
||||
await click('.search-result-item');
|
||||
|
||||
assert.verifySteps([`transitionTo: event ["${NOSTR_EVENT_ID}"]`]);
|
||||
});
|
||||
|
||||
test('it labels a place review and an unlinked event by kind', async function (assert) {
|
||||
const eventsByQuery = {};
|
||||
const reviewId = `${'a'.repeat(63)}b`;
|
||||
const noteId = `${'c'.repeat(63)}d`;
|
||||
|
||||
class MockNostrDataService extends Service {
|
||||
async loadEventByPointer(pointer) {
|
||||
return eventsByQuery[pointer.id];
|
||||
}
|
||||
}
|
||||
this.owner.register('service:nostr-data', MockNostrDataService);
|
||||
|
||||
class MockPhotonService extends Service {
|
||||
async search() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
this.owner.register('service:photon', MockPhotonService);
|
||||
|
||||
this.noop = () => {};
|
||||
await render(
|
||||
<template><SearchBox @onToggleMenu={{this.noop}} /></template>
|
||||
);
|
||||
|
||||
// Kind 30360 (place review) linked to a place.
|
||||
eventsByQuery[reviewId] = {
|
||||
id: reviewId,
|
||||
kind: 30360,
|
||||
tags: [['i', 'osm:way:9']],
|
||||
};
|
||||
await fillIn('.search-input', reviewId);
|
||||
await waitFor('.search-result-item', { timeout: 2000 });
|
||||
assert.dom('.result-title').hasText('Place review');
|
||||
assert.dom('.result-desc').hasText('Opens the linked place and review');
|
||||
|
||||
// Kind 1 (a plain note) with no place link. Clear first so the previous
|
||||
// row is gone before we wait for the new one.
|
||||
eventsByQuery[noteId] = { id: noteId, kind: 1, tags: [] };
|
||||
await fillIn('.search-input', '');
|
||||
await fillIn('.search-input', noteId);
|
||||
await waitFor('.search-result-item', { timeout: 2000 });
|
||||
assert.dom('.result-title').hasText('Nostr event');
|
||||
assert.dom('.result-desc').hasText('Not linked to a place');
|
||||
});
|
||||
|
||||
test('it toasts and shows no results when a Nostr reference is not found', async function (assert) {
|
||||
class MockNostrDataService extends Service {
|
||||
async loadEventByPointer() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
this.owner.register('service:nostr-data', MockNostrDataService);
|
||||
|
||||
let toastMessage;
|
||||
class MockToastService extends Service {
|
||||
show(message) {
|
||||
toastMessage = message;
|
||||
}
|
||||
}
|
||||
this.owner.register('service:toast', MockToastService);
|
||||
|
||||
let photonCalled = false;
|
||||
class MockPhotonService extends Service {
|
||||
async search() {
|
||||
photonCalled = true;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
this.owner.register('service:photon', MockPhotonService);
|
||||
|
||||
this.noop = () => {};
|
||||
await render(
|
||||
<template><SearchBox @onToggleMenu={{this.noop}} /></template>
|
||||
);
|
||||
|
||||
await fillIn('.search-input', NOSTR_EVENT_ID);
|
||||
await waitUntil(() => toastMessage !== undefined, { timeout: 3000 });
|
||||
|
||||
assert.strictEqual(toastMessage, 'Could not find this event on any relay.');
|
||||
assert.dom('.search-result-item').doesNotExist('no results are shown');
|
||||
assert.false(photonCalled, 'Photon is not called for a reference');
|
||||
});
|
||||
|
||||
test('it opens a Nostr reference on submit without a search', async function (assert) {
|
||||
class MockNostrDataService extends Service {
|
||||
async loadEventByPointer() {
|
||||
return { id: NOSTR_EVENT_ID, tags: [['i', 'osm:node:123']] };
|
||||
}
|
||||
}
|
||||
this.owner.register('service:nostr-data', MockNostrDataService);
|
||||
|
||||
let photonCalled = false;
|
||||
class MockPhotonService extends Service {
|
||||
async search() {
|
||||
photonCalled = true;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
this.owner.register('service:photon', MockPhotonService);
|
||||
|
||||
class MockRouterService extends Service {
|
||||
transitionTo(routeName, ...args) {
|
||||
assert.step(`transitionTo: ${routeName} ${JSON.stringify(args)}`);
|
||||
}
|
||||
}
|
||||
this.owner.register('service:router', MockRouterService);
|
||||
|
||||
this.noop = () => {};
|
||||
await render(
|
||||
<template><SearchBox @onToggleMenu={{this.noop}} /></template>
|
||||
);
|
||||
|
||||
await fillIn('.search-input', NOSTR_EVENT_ID);
|
||||
await this.element
|
||||
.querySelector('form')
|
||||
.dispatchEvent(new Event('submit', { bubbles: true, cancelable: true }));
|
||||
|
||||
assert.verifySteps([`transitionTo: event ["${NOSTR_EVENT_ID}"]`]);
|
||||
assert.false(photonCalled, 'Photon is not called for a reference');
|
||||
});
|
||||
|
||||
test('it does not re-query an unresolved reference on refocus', async function (assert) {
|
||||
let loadCalls = 0;
|
||||
class MockNostrDataService extends Service {
|
||||
async loadEventByPointer() {
|
||||
loadCalls++;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
this.owner.register('service:nostr-data', MockNostrDataService);
|
||||
|
||||
class MockPhotonService extends Service {
|
||||
async search() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
this.owner.register('service:photon', MockPhotonService);
|
||||
|
||||
class MockRouterService extends Service {
|
||||
transitionTo() {}
|
||||
}
|
||||
this.owner.register('service:router', MockRouterService);
|
||||
|
||||
this.noop = () => {};
|
||||
await render(
|
||||
<template><SearchBox @onToggleMenu={{this.noop}} /></template>
|
||||
);
|
||||
|
||||
await fillIn('.search-input', NOSTR_EVENT_ID);
|
||||
await waitUntil(() => loadCalls === 1, { timeout: 3000 });
|
||||
assert.strictEqual(loadCalls, 1, 'resolved once');
|
||||
|
||||
// Refocus the empty field: handleFocus retries, but the cached outcome is
|
||||
// re-applied instead of hitting the relays again.
|
||||
await blur('.search-input');
|
||||
await focus('.search-input');
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
|
||||
assert.strictEqual(loadCalls, 1, 'no second lookup on refocus');
|
||||
});
|
||||
|
||||
test('it cancels an in-flight reference lookup when the query is shortened', async function (assert) {
|
||||
let toastMessage;
|
||||
let releaseLookup;
|
||||
class MockNostrDataService extends Service {
|
||||
loadEventByPointer() {
|
||||
// Hold the lookup open until the test releases it, so it is always
|
||||
// still pending when the query is shortened (no timing race).
|
||||
return new Promise((resolve) => {
|
||||
releaseLookup = () => resolve(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
this.owner.register('service:nostr-data', MockNostrDataService);
|
||||
|
||||
class MockToastService extends Service {
|
||||
show(message) {
|
||||
toastMessage = message;
|
||||
}
|
||||
}
|
||||
this.owner.register('service:toast', MockToastService);
|
||||
|
||||
class MockPhotonService extends Service {
|
||||
async search() {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
this.owner.register('service:photon', MockPhotonService);
|
||||
|
||||
this.noop = () => {};
|
||||
await render(
|
||||
<template><SearchBox @onToggleMenu={{this.noop}} /></template>
|
||||
);
|
||||
|
||||
await fillIn('.search-input', NOSTR_EVENT_ID);
|
||||
await waitFor('.search-spinner', { timeout: 2000 });
|
||||
|
||||
// Shorten below the 2-character threshold while the lookup is pending,
|
||||
// then let the (now stale) lookup resolve.
|
||||
await fillIn('.search-input', 'n');
|
||||
releaseLookup();
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
|
||||
assert.notOk(toastMessage, 'the cancelled lookup never toasts');
|
||||
assert.dom('.search-result-item').doesNotExist();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,83 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'marco/tests/helpers';
|
||||
import sinon from 'sinon';
|
||||
import NostrAuthService, {
|
||||
REMOTE_SIGNER_LOGOUT_TIMEOUT,
|
||||
} from 'marco/services/nostr-auth';
|
||||
|
||||
const STORAGE_KEY_CONNECT_REMOTE_PUBKEY = 'marco:nostr_connect_remote_pubkey';
|
||||
|
||||
module('Unit | Service | nostr-auth', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
localStorage.clear();
|
||||
|
||||
this.owner.register('service:nostrAuth', NostrAuthService);
|
||||
this.service = this.owner.lookup('service:nostrAuth');
|
||||
});
|
||||
|
||||
hooks.afterEach(function () {
|
||||
sinon.restore();
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
test('disconnect sends a NIP-46 logout for a remote signer', async function (assert) {
|
||||
const logout = sinon.spy(async () => {});
|
||||
const close = sinon.spy(async () => {});
|
||||
|
||||
this.service.signerType = 'connect';
|
||||
this.service.pubkey = 'a'.repeat(64);
|
||||
localStorage.setItem(STORAGE_KEY_CONNECT_REMOTE_PUBKEY, 'b'.repeat(64));
|
||||
this.service._signerInstance = { logout, close };
|
||||
|
||||
await this.service.disconnect();
|
||||
|
||||
assert.true(logout.calledOnce, 'sends the logout request');
|
||||
assert.deepEqual(
|
||||
logout.firstCall.args[0],
|
||||
{ timeout: REMOTE_SIGNER_LOGOUT_TIMEOUT },
|
||||
'waits for the acknowledgement with the configured timeout'
|
||||
);
|
||||
assert.false(close.called, 'does not close separately (logout does it)');
|
||||
assert.strictEqual(this.service.pubkey, null, 'clears the pubkey');
|
||||
assert.strictEqual(this.service.signerType, null, 'clears the signer type');
|
||||
assert.strictEqual(
|
||||
localStorage.getItem(STORAGE_KEY_CONNECT_REMOTE_PUBKEY),
|
||||
null,
|
||||
'clears the persisted connection state'
|
||||
);
|
||||
});
|
||||
|
||||
test('disconnect closes the connection for an extension signer', async function (assert) {
|
||||
const close = sinon.spy(async () => {});
|
||||
|
||||
this.service.signerType = 'extension';
|
||||
this.service.pubkey = 'a'.repeat(64);
|
||||
this.service._signerInstance = { close };
|
||||
|
||||
await this.service.disconnect();
|
||||
|
||||
assert.true(close.calledOnce, 'closes the extension connection');
|
||||
assert.strictEqual(this.service.pubkey, null, 'clears the pubkey');
|
||||
});
|
||||
|
||||
test('disconnect still resolves when the remote signer logout fails', async function (assert) {
|
||||
const logout = sinon.spy(async () => {
|
||||
throw new Error('signer offline');
|
||||
});
|
||||
|
||||
this.service.signerType = 'connect';
|
||||
this.service.pubkey = 'a'.repeat(64);
|
||||
this.service._signerInstance = { logout };
|
||||
|
||||
await this.service.disconnect();
|
||||
|
||||
assert.true(logout.calledOnce, 'attempts the logout');
|
||||
assert.strictEqual(
|
||||
this.service.pubkey,
|
||||
null,
|
||||
'local state is cleared even if the signer is unreachable'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -3,6 +3,8 @@ import {
|
||||
excludeRequiredRelays,
|
||||
mergeRequiredRelays,
|
||||
normalizeRelayUrl,
|
||||
nostrEventLabel,
|
||||
nostrEventRouteParam,
|
||||
parseNostrEventReference,
|
||||
parsePlacePhotos,
|
||||
placeIdentifierFromEvent,
|
||||
@@ -513,6 +515,76 @@ module('Unit | Utility | nostr', function () {
|
||||
null
|
||||
);
|
||||
});
|
||||
|
||||
test('rejects profile identifiers (npub/nprofile)', function (assert) {
|
||||
// Only event references are openable by the /e/ handler; profiles are
|
||||
// intentionally out of scope and must fall through to a normal search.
|
||||
assert.strictEqual(
|
||||
parseNostrEventReference(
|
||||
'npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees'
|
||||
),
|
||||
null
|
||||
);
|
||||
assert.strictEqual(
|
||||
parseNostrEventReference(
|
||||
'nprofile1qqsp77g933m6yf89hc3xerczfjkd44xhgxz46a0dnug5wwagawrwrjc267jp9'
|
||||
),
|
||||
null
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
module('nostrEventRouteParam', function () {
|
||||
const EVENT_ID =
|
||||
'1f79058c77a224e5be226c8f024cacdad4d741855d75ed9f11473ba8eb86e1cb';
|
||||
const NOTE =
|
||||
'note1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89sazwyqc';
|
||||
const NEVENT =
|
||||
'nevent1qvzqqqqpdqpzq8meqkx80g3yuklzymy0qfx2ekk56aqc2ht4ak03z3em4r4cdcwtqyfhwumn8ghj7un9d3shjtn90psk6urvv5qzq8meqkx80g3yuklzymy0qfx2ekk56aqc2ht4ak03z3em4r4cdcwtzltwfa';
|
||||
|
||||
test('returns a bare reference unchanged', function (assert) {
|
||||
assert.strictEqual(nostrEventRouteParam(EVENT_ID), EVENT_ID);
|
||||
assert.strictEqual(nostrEventRouteParam(NOTE), NOTE);
|
||||
assert.strictEqual(nostrEventRouteParam(NEVENT), NEVENT);
|
||||
});
|
||||
|
||||
test('strips a nostr: scheme prefix', function (assert) {
|
||||
assert.strictEqual(nostrEventRouteParam(`nostr:${NOTE}`), NOTE);
|
||||
assert.strictEqual(nostrEventRouteParam(`NOSTR:${NOTE}`), NOTE);
|
||||
});
|
||||
|
||||
test('reduces a permalink to its last path segment', function (assert) {
|
||||
assert.strictEqual(
|
||||
nostrEventRouteParam(`https://njump.me/${NEVENT}`),
|
||||
NEVENT
|
||||
);
|
||||
assert.strictEqual(
|
||||
nostrEventRouteParam(`https://primal.net/e/${EVENT_ID}`),
|
||||
EVENT_ID
|
||||
);
|
||||
});
|
||||
|
||||
test('passes a raw address coordinate through as one segment', function (assert) {
|
||||
const coordinate = `30360:${EVENT_ID}:osm:node:123`;
|
||||
assert.strictEqual(nostrEventRouteParam(coordinate), coordinate);
|
||||
|
||||
// Identifiers may themselves contain colons, slashes and spaces and must
|
||||
// survive as a single dynamic segment.
|
||||
const messy = `30360:${EVENT_ID}:some/id with:colons`;
|
||||
assert.strictEqual(nostrEventRouteParam(messy), messy);
|
||||
});
|
||||
|
||||
test('returns null for anything not openable by /e/', function (assert) {
|
||||
assert.strictEqual(nostrEventRouteParam('Berlin'), null);
|
||||
assert.strictEqual(nostrEventRouteParam(''), null);
|
||||
assert.strictEqual(nostrEventRouteParam(null), null);
|
||||
assert.strictEqual(
|
||||
nostrEventRouteParam(
|
||||
'npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees'
|
||||
),
|
||||
null
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
module('placeIdentifierFromEvent', function () {
|
||||
@@ -546,4 +618,44 @@ module('Unit | Utility | nostr', function () {
|
||||
assert.strictEqual(placeIdentifierFromEvent({}), null);
|
||||
});
|
||||
});
|
||||
|
||||
module('nostrEventLabel', function () {
|
||||
test('labels a linked place photo', function (assert) {
|
||||
assert.deepEqual(
|
||||
nostrEventLabel({ kind: 360, tags: [['i', 'osm:node:123']] }),
|
||||
{
|
||||
title: 'Place photo',
|
||||
description: 'Opens the linked place and photo',
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('labels a linked place review', function (assert) {
|
||||
assert.deepEqual(
|
||||
nostrEventLabel({ kind: 30360, tags: [['i', 'osm:way:9']] }),
|
||||
{
|
||||
title: 'Place review',
|
||||
description: 'Opens the linked place and review',
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps the kind title but flags an unlinked event', function (assert) {
|
||||
assert.deepEqual(nostrEventLabel({ kind: 360, tags: [] }), {
|
||||
title: 'Place photo',
|
||||
description: 'Not linked to a place',
|
||||
});
|
||||
});
|
||||
|
||||
test('falls back to a generic label for other kinds', function (assert) {
|
||||
assert.deepEqual(
|
||||
nostrEventLabel({ kind: 1, tags: [['i', 'osm:node:123']] }),
|
||||
{ title: 'Nostr event', description: 'Opens the linked place' }
|
||||
);
|
||||
assert.deepEqual(nostrEventLabel(null), {
|
||||
title: 'Nostr event',
|
||||
description: 'Not linked to a place',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user