aboutsummaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/features')
-rw-r--r--src/features/hats.js2
-rw-r--r--src/features/index.js35
-rw-r--r--src/features/names.js2
3 files changed, 24 insertions, 15 deletions
diff --git a/src/features/hats.js b/src/features/hats.js
index bb9b8b0..43151ad 100644
--- a/src/features/hats.js
+++ b/src/features/hats.js
@@ -13,7 +13,7 @@
import { t } from '../i18n.js';
import { fmtSats } from '../format.js';
-import { nip98Header } from '../nostr-login.js';
+import { nip98Header } from '../nip98.js';
import { getNetwork } from '../api.js';
const REGISTRAR = 'https://names.coinos.io';
diff --git a/src/features/index.js b/src/features/index.js
index 5ecb7c0..a32bced 100644
--- a/src/features/index.js
+++ b/src/features/index.js
@@ -3,24 +3,33 @@
// build.js replaces this module's contents based on HAL_FEATURES, so a
// disabled feature's code — and its network endpoints — never enters the
// bundle. See featureIndexSource() in build.js.
-
-import { giftsFeature } from './gifts.js';
-import { nostrLoginFeature } from './nostrlogin.js';
+//
+// This checked-in copy must stay byte-equivalent (comments aside) to
+// featureIndexSource(all features) — tools/feature-registry-check.js enforces
+// it. Deferred features (gifts, nwc, hats) hold their array position with an
+// empty placeholder — hook precedence is position — and are filled in place
+// by loadDeferredFeatures right after boot, as separate chunks in the split
+// build. NB order is meaningful where hooks stack: gifts' receive takeover
+// and balance line come before ark's; zaps sits after ark so an npub prefers
+// an instant Ark zap; nwc sits after ark because it drives ark's headless
+// pay/balance seam; names sits between ark and zaps so a pasted user@domain
+// resolves over DNS (BIP-353) before zaps treats it as a Lightning address.
import { arkFeature } from './ark.js';
+import { nostrLoginFeature } from './nostrlogin.js';
import { namesFeature } from './names.js';
import { zapsFeature } from './zaps.js';
import { syncFeature } from './sync.js';
-import { nwcFeature } from './nwc.js';
-import { hatsFeature } from './hats.js';
import { messagesFeature } from './messages.js';
-// NB order is meaningful where hooks stack: gifts' receive takeover and
-// balance line come before ark's, matching the pre-plugin layout. zaps sits
-// after ark so an npub prefers an instant Ark zap and only falls through to a
-// Lightning zap when Ark can't serve it. nwc sits after ark because it
-// drives ark's headless pay/balance seam.
-// names sits between ark and zaps: a pasted user@domain resolves over DNS
-// (BIP-353) before the zaps feature treats it as a plain Lightning address.
export function buildFeatures(ctx) {
- return [giftsFeature(ctx), arkFeature(ctx), nostrLoginFeature(ctx), namesFeature(ctx), zapsFeature(ctx), nwcFeature(ctx), hatsFeature(ctx), syncFeature(ctx), messagesFeature(ctx)];
+ return [{}, arkFeature(ctx), nostrLoginFeature(ctx), namesFeature(ctx), zapsFeature(ctx), {}, {}, syncFeature(ctx), messagesFeature(ctx)];
+}
+export async function loadDeferredFeatures(ctx, features) {
+ const late = [];
+ await Promise.all([
+ import('./gifts.js').then((m) => { late.push(features[0] = m.giftsFeature(ctx)); }),
+ import('./nwc.js').then((m) => { late.push(features[5] = m.nwcFeature(ctx)); }),
+ import('./hats.js').then((m) => { late.push(features[6] = m.hatsFeature(ctx)); })
+ ]);
+ return late;
}
diff --git a/src/features/names.js b/src/features/names.js
index cf2aa3c..56fc77d 100644
--- a/src/features/names.js
+++ b/src/features/names.js
@@ -12,7 +12,7 @@
// record falls back to the Lightning-address flow (zaps feature).
import { resolveBip353, parsePaymentName, parseBip21 } from '../bip353.js';
-import { nip98Header } from '../nostr-login.js';
+import { nip98Header } from '../nip98.js';
import { qrSvg } from '../qr.js';
import { isArkAddress } from './ark.js';
import { getNetwork } from '../api.js';