Merge branch 'master' into kosmos
# Conflicts: # release/assets/main-BHr2t0K0.js # release/assets/modules-4-12-C5tGRFkG.js # release/assets/modules-4-12-CRUhRJ4U.js # release/assets/modules-4-12-DRDkPElI.js # release/index.html
This commit is contained in:
15 files changed
+402
-132
No files matched your search
@@ -11,94 +11,40 @@ Marco (as in [Marco Polo][1]) is an unhosted maps application that respects
|
||||
your privacy and choices.
|
||||
|
||||
It allows users to connect their own remote storage to sync place bookmarks
|
||||
across apps and devices. It also supports the decentralized sharing of place
|
||||
photos (and soon reviews) via [Nostr][2].
|
||||
across apps and devices. It also supports the decentralized sharing and
|
||||
discovery of place photos (and soon reviews) via [Nostr][2].
|
||||
|
||||
This README outlines the details of collaborating on this Ember application, or
|
||||
just building and deploying it for yourself.
|
||||
## Try it
|
||||
|
||||
## Prerequisites
|
||||
- https://marco.earth
|
||||
|
||||
You will need the following things properly installed on your computer.
|
||||
Marco runs in any modern browser, and can be installed as a
|
||||
[progressive web app][3] on phones and desktops. On mobile, open the URL above
|
||||
and choose "Add to Home Screen" (iOS Safari) or "Install app" (Android Chrome);
|
||||
Marco then launches full screen from its own icon.
|
||||
|
||||
- [Git](https://git-scm.com/)
|
||||
- [Node.js](https://nodejs.org/)
|
||||
- [pnpm](https://pnpm.io/)
|
||||
- [Google Chrome](https://google.com/chrome/)
|
||||
## Repositories & Contributions
|
||||
|
||||
## Installation
|
||||
The upstream repository is available on both Gitea and ngit (git over Nostr),
|
||||
and issues and pull requests are accepted on either:
|
||||
|
||||
- `git clone <repository-url>` this repository
|
||||
- `cd marco`
|
||||
- `pnpm install`
|
||||
- Gitea: https://gitea.kosmos.org/raucao/marco
|
||||
- ngit: https://gitworkshop.dev/raucao@kosmos.org/relay.ngit.dev/marco
|
||||
|
||||
## Running / Development
|
||||
## Documentation
|
||||
|
||||
- `pnpm start`
|
||||
- Visit your app at [http://localhost:4200](http://localhost:4200).
|
||||
- Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests).
|
||||
- [Development](doc/dev/development.md) — prerequisites, running locally,
|
||||
tests, linting, building and deployment
|
||||
- [Nostr notes](doc/nostr/) — protocol and feature design documents
|
||||
|
||||
### Code Generators
|
||||
## License
|
||||
|
||||
Make use of the many generators for code, try `pnpm ember help generate` for more details
|
||||
[GNU Affero General Public License v3.0](LICENSE)
|
||||
|
||||
### Running Tests
|
||||
## Contact
|
||||
|
||||
- `pnpm test`
|
||||
|
||||
### Linting
|
||||
|
||||
- `pnpm lint`
|
||||
- `pnpm lint:fix`
|
||||
|
||||
### Building
|
||||
|
||||
- `pnpm vite build --mode development` (development)
|
||||
- `pnpm build` (production)
|
||||
|
||||
### App Icon
|
||||
|
||||
- `pnpm build:icons` generates PNGs of all sizes from `public/icons/icon.svg`
|
||||
|
||||
To run the script, you need `imagemagick` and `librsvg` installed:
|
||||
|
||||
- **Arch Linux:** `pacman -S imagemagick librsvg`
|
||||
- **Ubuntu/Debian:** `apt install imagemagick librsvg2-bin`
|
||||
|
||||
### Deploying
|
||||
|
||||
Marco is deployed to two domains from two branches, both serving the committed
|
||||
`release/` directory:
|
||||
|
||||
- `master` → https://marco.earth (`git push 5apps master`)
|
||||
- `kosmos` → https://marco.kosmos.org (`git push 5apps-old kosmos:master`)
|
||||
|
||||
The branches differ only in `.env.production` (app origin + OSM OAuth client
|
||||
ID); everything else is identical. Prepare a release on `master`, then sync the
|
||||
`kosmos` branch and push both:
|
||||
|
||||
```sh
|
||||
pnpm version patch # bumps version, runs lint/tests, rebuilds release/
|
||||
git push origin master && git push 5apps master
|
||||
|
||||
./scripts/sync-kosmos.sh # merges master into kosmos and rebuilds release/
|
||||
git push origin kosmos && git push 5apps-old kosmos:master
|
||||
```
|
||||
|
||||
Both 5apps Deploy apps use `release/` as their build directory.
|
||||
|
||||
- Or deploy `release/` to any static file host (ideally routing all 404s to
|
||||
`index.html` for launching with client-side routes to work)
|
||||
|
||||
## Further Reading / Useful Links
|
||||
|
||||
- [ember.js](https://emberjs.com/)
|
||||
- [remoteStorage.js](https://remotestorage.io/rs.js/docs/)
|
||||
- [@remotestorage/module-places](https://gitea.kosmos.org/raucao/remotestorage-module-places)
|
||||
- [Vite](https://vite.dev)
|
||||
- Development Browser Extensions
|
||||
- [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi)
|
||||
- [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/)
|
||||
E-Mail, Chat, Social, Lightning: [raucao@kosmos.org](mailto:raucao@kosmos.org)
|
||||
|
||||
[1]: https://en.wikipedia.org/wiki/Marco_Polo
|
||||
[2]: https://nostr.org
|
||||
[3]: https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps
|
||||
@@ -5,6 +5,7 @@ import { on } from '@ember/modifier';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { eq } from 'ember-truth-helpers';
|
||||
import qrCode from '../modifiers/qr-code';
|
||||
import { copyText } from '../utils/share';
|
||||
|
||||
// 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.
|
||||
@@ -57,28 +58,7 @@ export default class NostrConnectComponent extends Component {
|
||||
const text = this.nostrAuth.connectUri;
|
||||
|
||||
try {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
await navigator.clipboard.writeText(text);
|
||||
} else {
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
|
||||
textArea.style.position = 'fixed';
|
||||
textArea.style.top = '0';
|
||||
textArea.style.left = '0';
|
||||
textArea.style.opacity = '0';
|
||||
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
|
||||
const successful = document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
|
||||
if (!successful) {
|
||||
throw new Error('Fallback copy failed');
|
||||
}
|
||||
}
|
||||
await copyText(text);
|
||||
this.toast.show('Connection link copied to clipboard');
|
||||
} catch (err) {
|
||||
console.error('Failed to copy text: ', err);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { task } from 'ember-concurrency';
|
||||
import { EventFactory } from 'applesauce-core';
|
||||
import { encodePointer } from 'applesauce-core/helpers/pointers';
|
||||
import { withMarcoClientTag } from '../utils/client-tag';
|
||||
import { copyText, toAbsoluteUrl } from '../utils/share';
|
||||
import or from 'ember-truth-helpers/helpers/or';
|
||||
import config from 'marco/config/environment';
|
||||
import DropdownMenu from './dropdown-menu';
|
||||
@@ -44,7 +45,12 @@ const GalleryContent = <template>
|
||||
class="dropdown-item"
|
||||
type="button"
|
||||
{{on "click" (fn @copyEventId closeMenu)}}
|
||||
>Copy Photo Event ID</button>
|
||||
>Copy photo event ID</button>
|
||||
<button
|
||||
class="dropdown-item"
|
||||
type="button"
|
||||
{{on "click" (fn @copyShareLink closeMenu)}}
|
||||
>Copy share link</button>
|
||||
{{#if @canZapPhoto}}
|
||||
<button
|
||||
class="dropdown-item"
|
||||
@@ -237,26 +243,37 @@ export default class PhotoGallery extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
async copyEventId(closeMenu) {
|
||||
if (this.currentPhoto?.eventId) {
|
||||
let value = this.currentPhoto.eventId;
|
||||
try {
|
||||
const nevent = encodePointer({
|
||||
id: this.currentPhoto.eventId,
|
||||
relays: this.nostrData
|
||||
.getEventRelays(this.currentPhoto.eventId)
|
||||
.slice(0, MAX_NEVENT_RELAY_HINTS),
|
||||
author: this.currentPhoto.pubkey,
|
||||
kind: 360,
|
||||
});
|
||||
if (nevent) value = nevent;
|
||||
} catch (err) {
|
||||
console.warn('Failed to encode nevent, copying raw event ID:', err);
|
||||
}
|
||||
// Builds the most portable reference for the current photo: an `nevent1…`
|
||||
// with relay hints so other clients can resolve it, falling back to the raw
|
||||
// event id if encoding fails.
|
||||
buildEventReference() {
|
||||
const eventId = this.currentPhoto?.eventId;
|
||||
if (!eventId) return null;
|
||||
|
||||
try {
|
||||
const nevent = encodePointer({
|
||||
id: eventId,
|
||||
relays: this.nostrData
|
||||
.getEventRelays(eventId)
|
||||
.slice(0, MAX_NEVENT_RELAY_HINTS),
|
||||
author: this.currentPhoto.pubkey,
|
||||
kind: 360,
|
||||
});
|
||||
if (nevent) return nevent;
|
||||
} catch (err) {
|
||||
console.warn('Failed to encode nevent, using raw event ID:', err);
|
||||
}
|
||||
|
||||
return eventId;
|
||||
}
|
||||
|
||||
@action
|
||||
async copyEventId(closeMenu, e) {
|
||||
e?.stopPropagation();
|
||||
const reference = this.buildEventReference();
|
||||
if (reference) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
await copyText(reference);
|
||||
this.toast.show('Event ID copied to clipboard');
|
||||
} catch (err) {
|
||||
console.error('Failed to copy event ID:', err);
|
||||
@@ -266,6 +283,22 @@ export default class PhotoGallery extends Component {
|
||||
closeMenu();
|
||||
}
|
||||
|
||||
@action
|
||||
async copyShareLink(closeMenu, e) {
|
||||
e?.stopPropagation();
|
||||
const reference = this.buildEventReference();
|
||||
if (reference) {
|
||||
try {
|
||||
await copyText(toAbsoluteUrl(`/e/${reference}`));
|
||||
this.toast.show('Share link copied to clipboard');
|
||||
} catch (err) {
|
||||
console.error('Failed to copy share link:', err);
|
||||
this.toast.show('Failed to copy share link');
|
||||
}
|
||||
}
|
||||
closeMenu();
|
||||
}
|
||||
|
||||
@action
|
||||
openZap(closeMenu, e) {
|
||||
e?.stopPropagation();
|
||||
@@ -368,6 +401,7 @@ export default class PhotoGallery extends Component {
|
||||
@bindKeyboard={{this.bindKeyboard}}
|
||||
@handleKeydown={{this.handleKeydown}}
|
||||
@copyEventId={{this.copyEventId}}
|
||||
@copyShareLink={{this.copyShareLink}}
|
||||
@canDeletePhoto={{this.canDeletePhoto}}
|
||||
@deletePhoto={{this.deletePhoto}}
|
||||
@handleClose={{this.handleClose}}
|
||||
@@ -391,6 +425,7 @@ export default class PhotoGallery extends Component {
|
||||
@bindKeyboard={{this.bindKeyboard}}
|
||||
@handleKeydown={{this.handleKeydown}}
|
||||
@copyEventId={{this.copyEventId}}
|
||||
@copyShareLink={{this.copyShareLink}}
|
||||
@canDeletePhoto={{this.canDeletePhoto}}
|
||||
@deletePhoto={{this.deletePhoto}}
|
||||
@handleClose={{this.handleClose}}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { service } from '@ember/service';
|
||||
import { task } from 'ember-concurrency';
|
||||
import { eq } from 'ember-truth-helpers';
|
||||
import qrCode from '../modifiers/qr-code';
|
||||
import { copyText } from '../utils/share';
|
||||
import Icon from './icon';
|
||||
import Modal from './modal';
|
||||
|
||||
@@ -201,13 +202,13 @@ export default class ZapPhotoModal extends Component {
|
||||
}
|
||||
|
||||
@action
|
||||
copyInvoice() {
|
||||
async copyInvoice() {
|
||||
if (!this.invoice) return;
|
||||
try {
|
||||
navigator.clipboard.writeText(this.invoice);
|
||||
await copyText(this.invoice);
|
||||
this.toast.show('Invoice copied to clipboard');
|
||||
} catch {
|
||||
// no-op
|
||||
this.toast.show('Could not copy invoice');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,11 @@ import { tracked } from '@glimmer/tracking';
|
||||
|
||||
import { DEFAULT_BLOSSOM_SERVER } from './blossom';
|
||||
|
||||
const LEGACY_OVERPASS_API = 'https://overpass-api.de/api/interpreter';
|
||||
const OVERPASS_BTCMAP_MIGRATION_KEY = 'marco:migration:overpass-btcmap';
|
||||
|
||||
const DEFAULT_SETTINGS = {
|
||||
overpassApi: 'https://overpass-api.de/api/interpreter',
|
||||
overpassApi: 'https://overpass.btcmap.org/api/interpreter',
|
||||
mapKinetic: true,
|
||||
photonApi: 'https://photon.komoot.io/api/',
|
||||
showQuickSearchButtons: true,
|
||||
@@ -110,6 +113,16 @@ export default class SettingsService extends Service {
|
||||
if (savedPhotonApi) settings.photonApi = savedPhotonApi;
|
||||
}
|
||||
|
||||
// One-time migration: switch users still on the previous default Overpass
|
||||
// provider to the BTC Map provider. Runs once per device, so users can
|
||||
// change it again afterwards without it being re-applied.
|
||||
if (!localStorage.getItem(OVERPASS_BTCMAP_MIGRATION_KEY)) {
|
||||
if (settings.overpassApi === LEGACY_OVERPASS_API) {
|
||||
settings.overpassApi = DEFAULT_SETTINGS.overpassApi;
|
||||
}
|
||||
localStorage.setItem(OVERPASS_BTCMAP_MIGRATION_KEY, 'true');
|
||||
}
|
||||
|
||||
// Merge with defaults
|
||||
const finalSettings = { ...DEFAULT_SETTINGS, ...settings };
|
||||
|
||||
|
||||
@@ -19,10 +19,6 @@ function hasAsyncClipboard() {
|
||||
);
|
||||
}
|
||||
|
||||
export function canUseClipboard() {
|
||||
return hasAsyncClipboard();
|
||||
}
|
||||
|
||||
// True when text can be copied one way or another. Falls back to the legacy
|
||||
// `document.execCommand('copy')` path, which also works on non-secure origins
|
||||
// (e.g. a LAN dev server over plain http) where the async Clipboard API is
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
# Development
|
||||
|
||||
How to collaborate on Marco, or just build and deploy it for yourself.
|
||||
|
||||
> Scope: local setup, running, tests, linting, builds and deployment. For
|
||||
> subsystem deep dives see the other documents in this directory, and for
|
||||
> Nostr-related design notes see [`doc/nostr/`](../nostr/).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
You will need the following things properly installed on your computer.
|
||||
|
||||
- [Git](https://git-scm.com/)
|
||||
- [Node.js](https://nodejs.org/)
|
||||
- [pnpm](https://pnpm.io/)
|
||||
- [Google Chrome](https://google.com/chrome/)
|
||||
|
||||
## Installation
|
||||
|
||||
- `git clone https://gitea.kosmos.org/raucao/marco.git`
|
||||
- `cd marco`
|
||||
- `pnpm install`
|
||||
|
||||
## Running / Development
|
||||
|
||||
- `pnpm start`
|
||||
- Visit your app at [http://localhost:4200](http://localhost:4200).
|
||||
- Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests).
|
||||
|
||||
### Code Generators
|
||||
|
||||
Make use of the many generators for code, try `pnpm ember help generate` for more details
|
||||
|
||||
### Running Tests
|
||||
|
||||
- `pnpm test`
|
||||
|
||||
### Linting
|
||||
|
||||
- `pnpm lint`
|
||||
- `pnpm lint:fix`
|
||||
|
||||
### Building
|
||||
|
||||
- `pnpm vite build --mode development` (development)
|
||||
- `pnpm build` (production)
|
||||
|
||||
### App Icon
|
||||
|
||||
- `pnpm build:icons` generates PNGs of all sizes from `public/icons/icon.svg`
|
||||
|
||||
To run the script, you need `imagemagick` and `librsvg` installed:
|
||||
|
||||
- **Arch Linux:** `pacman -S imagemagick librsvg`
|
||||
- **Ubuntu/Debian:** `apt install imagemagick librsvg2-bin`
|
||||
|
||||
### Deploying
|
||||
|
||||
Marco is deployed to two domains from two branches, both serving the committed
|
||||
`release/` directory:
|
||||
|
||||
- `master` → https://marco.earth (`git push 5apps master`)
|
||||
- `kosmos` → https://marco.kosmos.org (`git push 5apps-old kosmos:master`),
|
||||
legacy and kept only for the existing deployment
|
||||
|
||||
The branches differ only in `.env.production` (app origin + OSM OAuth client
|
||||
ID); everything else is identical. Prepare a release on `master`, then sync the
|
||||
`kosmos` branch and push both:
|
||||
|
||||
```sh
|
||||
pnpm version patch # bumps version, runs lint/tests, rebuilds release/
|
||||
git push origin master && git push 5apps master
|
||||
|
||||
./scripts/sync-kosmos.sh # merges master into kosmos and rebuilds release/
|
||||
git push origin kosmos && git push 5apps-old kosmos:master
|
||||
```
|
||||
|
||||
Both 5apps Deploy apps use `release/` as their build directory.
|
||||
|
||||
- Or deploy `release/` to any static file host (ideally routing all 404s to
|
||||
`index.html` for launching with client-side routes to work)
|
||||
|
||||
## Further Reading / Useful Links
|
||||
|
||||
- [ember.js](https://emberjs.com/)
|
||||
- [remoteStorage.js](https://remotestorage.io/rs.js/docs/)
|
||||
- [@remotestorage/module-places](https://gitea.kosmos.org/raucao/remotestorage-module-places)
|
||||
- [Vite](https://vite.dev)
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "marco",
|
||||
"version": "1.38.0",
|
||||
"version": "1.39.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 @@
|
||||
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
|
||||
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-bPhej5rb.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
|
||||
+1
-1
@@ -42,7 +42,7 @@
|
||||
<meta name="msapplication-TileColor" content="#F6E9A6">
|
||||
<meta name="msapplication-TileImage" content="/icons/icon-144.png">
|
||||
|
||||
<script type="module" crossorigin src="/assets/main-BHr2t0K0.js"></script>
|
||||
<script type="module" crossorigin src="/assets/main-bPhej5rb.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/main-D1hwoGyg.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -20,11 +20,30 @@ class MockToastService extends Service {
|
||||
show() {}
|
||||
}
|
||||
|
||||
function restoreProperty(target, key, descriptor) {
|
||||
if (descriptor) {
|
||||
Object.defineProperty(target, key, descriptor);
|
||||
} else {
|
||||
delete target[key];
|
||||
}
|
||||
}
|
||||
|
||||
module('Integration | Component | photo-gallery', function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
setupNostrMocks(hooks);
|
||||
|
||||
let originalClipboard;
|
||||
let originalIsSecureContext;
|
||||
let originalExecCommand;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
originalClipboard = Object.getOwnPropertyDescriptor(navigator, 'clipboard');
|
||||
originalIsSecureContext = Object.getOwnPropertyDescriptor(
|
||||
window,
|
||||
'isSecureContext'
|
||||
);
|
||||
originalExecCommand = document.execCommand;
|
||||
|
||||
this.owner.register('service:blossom', MockBlossomService);
|
||||
this.owner.register('service:toast', MockToastService);
|
||||
|
||||
@@ -55,6 +74,9 @@ module('Integration | Component | photo-gallery', function (hooks) {
|
||||
|
||||
hooks.afterEach(function () {
|
||||
sinon.restore();
|
||||
restoreProperty(navigator, 'clipboard', originalClipboard);
|
||||
restoreProperty(window, 'isSecureContext', originalIsSecureContext);
|
||||
document.execCommand = originalExecCommand;
|
||||
localStorage.removeItem('marco:settings');
|
||||
});
|
||||
|
||||
@@ -402,7 +424,7 @@ module('Integration | Component | photo-gallery', function (hooks) {
|
||||
const items = document.querySelectorAll('.dropdown-item');
|
||||
let copyBtn;
|
||||
items.forEach((item) => {
|
||||
if (item.textContent.includes('Copy Photo Event ID')) {
|
||||
if (item.textContent.includes('Copy photo event ID')) {
|
||||
copyBtn = item;
|
||||
}
|
||||
});
|
||||
@@ -432,6 +454,132 @@ module('Integration | Component | photo-gallery', function (hooks) {
|
||||
);
|
||||
});
|
||||
|
||||
test('it copies a share link that resolves the photo via the /e/ route', async function (assert) {
|
||||
const eventId = '3'.repeat(64);
|
||||
this.nostrAuth.pubkey = USER_A;
|
||||
this.photos = [
|
||||
{
|
||||
eventId,
|
||||
pubkey: USER_A,
|
||||
placeIdentifier: 'osm:node:12345',
|
||||
url: 'photo.jpg',
|
||||
},
|
||||
];
|
||||
this.selectedPhoto = this.photos[0];
|
||||
|
||||
sinon
|
||||
.stub(this.nostrData, 'getEventRelays')
|
||||
.returns(['wss://a.test', 'wss://b.test']);
|
||||
const clipboardStub = sinon
|
||||
.stub(navigator.clipboard, 'writeText')
|
||||
.resolves();
|
||||
const toastSpy = sinon.spy(this.toast, 'show');
|
||||
|
||||
await render(
|
||||
<template>
|
||||
<div id="test-container">
|
||||
<div id="modal-portal"></div>
|
||||
<PhotoGallery
|
||||
@photos={{this.photos}}
|
||||
@selectedPhoto={{this.selectedPhoto}}
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
);
|
||||
|
||||
await click('.dropdown-trigger-btn');
|
||||
|
||||
const items = document.querySelectorAll('.dropdown-item');
|
||||
let shareBtn;
|
||||
items.forEach((item) => {
|
||||
if (item.textContent.includes('Copy share link')) {
|
||||
shareBtn = item;
|
||||
}
|
||||
});
|
||||
|
||||
await click(shareBtn);
|
||||
|
||||
const copied = clipboardStub.firstCall.args[0];
|
||||
const prefix = `${window.location.origin}/e/`;
|
||||
assert.true(
|
||||
copied.startsWith(`${prefix}nevent1`),
|
||||
'copied value is an absolute /e/ share link'
|
||||
);
|
||||
const decoded = decodePointer(copied.slice(prefix.length));
|
||||
assert.strictEqual(
|
||||
decoded.data.id,
|
||||
eventId,
|
||||
'share link references the correct event id'
|
||||
);
|
||||
assert.ok(
|
||||
toastSpy.calledWith('Share link copied to clipboard'),
|
||||
'success toast was shown'
|
||||
);
|
||||
});
|
||||
|
||||
test('it copies the event id on a non-secure origin without the async Clipboard API', async function (assert) {
|
||||
const eventId = '2'.repeat(64);
|
||||
this.nostrAuth.pubkey = USER_A;
|
||||
this.photos = [
|
||||
{
|
||||
eventId,
|
||||
pubkey: USER_A,
|
||||
placeIdentifier: 'osm:node:12345',
|
||||
url: 'photo.jpg',
|
||||
},
|
||||
];
|
||||
this.selectedPhoto = this.photos[0];
|
||||
|
||||
sinon.stub(this.nostrData, 'getEventRelays').returns([]);
|
||||
|
||||
// Simulate a LAN dev server over plain http: no async Clipboard API and a
|
||||
// non-secure context, so the copy must fall back to execCommand.
|
||||
Object.defineProperty(navigator, 'clipboard', {
|
||||
configurable: true,
|
||||
value: undefined,
|
||||
});
|
||||
Object.defineProperty(window, 'isSecureContext', {
|
||||
configurable: true,
|
||||
value: false,
|
||||
});
|
||||
let usedExecCommand = false;
|
||||
document.execCommand = (command) => {
|
||||
usedExecCommand = command === 'copy';
|
||||
return true;
|
||||
};
|
||||
const toastSpy = sinon.spy(this.toast, 'show');
|
||||
|
||||
await render(
|
||||
<template>
|
||||
<div id="test-container">
|
||||
<div id="modal-portal"></div>
|
||||
<PhotoGallery
|
||||
@photos={{this.photos}}
|
||||
@selectedPhoto={{this.selectedPhoto}}
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
);
|
||||
|
||||
await click('.dropdown-trigger-btn');
|
||||
|
||||
const items = document.querySelectorAll('.dropdown-item');
|
||||
let copyBtn;
|
||||
items.forEach((item) => {
|
||||
if (item.textContent.includes('Copy photo event ID')) {
|
||||
copyBtn = item;
|
||||
}
|
||||
});
|
||||
|
||||
await click(copyBtn);
|
||||
|
||||
assert.true(usedExecCommand, 'execCommand("copy") was invoked');
|
||||
assert.ok(
|
||||
toastSpy.calledWith('Event ID copied to clipboard'),
|
||||
'success toast was shown'
|
||||
);
|
||||
});
|
||||
|
||||
test('keyboard navigation changes photos', async function (assert) {
|
||||
this.photos = [
|
||||
{ eventId: 'event1', url: 'photo1.jpg' },
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'marco/tests/helpers';
|
||||
|
||||
const BTCMAP_OVERPASS_API = 'https://overpass.btcmap.org/api/interpreter';
|
||||
const LEGACY_OVERPASS_API = 'https://overpass-api.de/api/interpreter';
|
||||
const PRIVATE_COFFEE_OVERPASS_API =
|
||||
'https://overpass.private.coffee/api/interpreter';
|
||||
const MIGRATION_KEY = 'marco:migration:overpass-btcmap';
|
||||
|
||||
function storeSettings(settings) {
|
||||
localStorage.setItem('marco:settings', JSON.stringify(settings));
|
||||
}
|
||||
|
||||
module('Unit | Service | settings', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
hooks.afterEach(function () {
|
||||
localStorage.clear();
|
||||
});
|
||||
|
||||
test('it exists', function (assert) {
|
||||
let service = this.owner.lookup('service:settings');
|
||||
assert.ok(service);
|
||||
});
|
||||
|
||||
test('new users get the BTC Map Overpass provider by default', function (assert) {
|
||||
let service = this.owner.lookup('service:settings');
|
||||
|
||||
assert.strictEqual(service.overpassApi, BTCMAP_OVERPASS_API);
|
||||
assert.strictEqual(localStorage.getItem(MIGRATION_KEY), 'true');
|
||||
});
|
||||
|
||||
test('users still on the legacy default are migrated to BTC Map once', function (assert) {
|
||||
storeSettings({ overpassApi: LEGACY_OVERPASS_API });
|
||||
|
||||
let service = this.owner.lookup('service:settings');
|
||||
|
||||
assert.strictEqual(service.overpassApi, BTCMAP_OVERPASS_API);
|
||||
assert.strictEqual(localStorage.getItem(MIGRATION_KEY), 'true');
|
||||
});
|
||||
|
||||
test('users on a non-legacy provider are left untouched', function (assert) {
|
||||
storeSettings({ overpassApi: PRIVATE_COFFEE_OVERPASS_API });
|
||||
|
||||
let service = this.owner.lookup('service:settings');
|
||||
|
||||
assert.strictEqual(service.overpassApi, PRIVATE_COFFEE_OVERPASS_API);
|
||||
assert.strictEqual(localStorage.getItem(MIGRATION_KEY), 'true');
|
||||
});
|
||||
|
||||
test('migration does not run again once it has been applied', function (assert) {
|
||||
// Simulate a user who already went through the migration and then
|
||||
// deliberately switched back to the legacy provider.
|
||||
localStorage.setItem(MIGRATION_KEY, 'true');
|
||||
storeSettings({ overpassApi: LEGACY_OVERPASS_API });
|
||||
|
||||
let service = this.owner.lookup('service:settings');
|
||||
|
||||
assert.strictEqual(service.overpassApi, LEGACY_OVERPASS_API);
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,5 @@
|
||||
import { module, test } from 'qunit';
|
||||
import {
|
||||
canUseClipboard,
|
||||
canCopyText,
|
||||
canWebShare,
|
||||
copyText,
|
||||
@@ -55,7 +54,6 @@ module('Unit | Utility | share', function () {
|
||||
|
||||
test('capability guards return booleans without throwing', function (assert) {
|
||||
assert.strictEqual(typeof canWebShare(), 'boolean');
|
||||
assert.strictEqual(typeof canUseClipboard(), 'boolean');
|
||||
assert.strictEqual(typeof canCopyText(), 'boolean');
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user