Skip to content

refactor: decouple deployer widget into @nsite/deployer package#42

Open
dskvr wants to merge 2 commits into
mainfrom
enhance/decouple-deployer-v2
Open

refactor: decouple deployer widget into @nsite/deployer package#42
dskvr wants to merge 2 commits into
mainfrom
enhance/decouple-deployer-v2

Conversation

@dskvr
Copy link
Copy Markdown
Contributor

@dskvr dskvr commented Apr 10, 2026

Summary

  • Extracts the deploy/manage/auth component tree from apps/spa into a standalone @nsite/deployer package consumable as an embeddable widget (12 Svelte components + 8 lib modules + Svelte/ESM/IIFE build targets + <nsite-deployer> custom element).
  • Sets up npm workspaces (apps/spa + packages/deployer) with .npmrc for JSR, deno.json nodeModulesDir: "none" for deno+npm coexistence, and CI deno install step.
  • Rewrites apps/spa/src/App.svelte into a thin shell that mounts DeployerWidget and refactors Navbar.svelte to receive session state via props/events instead of reading the store directly.

Context

This replaces the original enhance/decouple-deployer branch, which forked from d36ac10 and accumulated ~40 commits that conflicted badly with main's PR #18 (Enhance/action guards) squash-merge. Rather than rebase through the squash, the decoupled package was ported onto a fresh branch from main and main's divergent fixes were manually applied to the new file locations.

Ported fixes (applied into decoupled files)

  • DeployerWidget.svelte
    • kind-10063 blossoms are merged into serverConfig.extraBlossoms (both fetch paths) so AdvancedConfig shows them and users can remove them
    • dTagValid regex allows interior hyphens (^[a-z0-9](?:[a-z0-9-]{0,11}[a-z0-9])?$) with matching error message
    • Deploy blossomUrls union no longer re-adds userBlossoms (now comes through cfg.extraBlossoms)
    • dTag input sanitizer allows -
  • packages/deployer/src/lib/upload.jsuploadBlobs and deleteBlobs both batch auth signing (350 hashes per event) per BUD-11
  • packages/deployer/src/lib/files.jsinferMimeType uses contentType() from @std/media-types instead of an inline MIME_TYPES map (+ runtime dep added to packages/deployer/package.json)

Intentionally kept at main's version (not overwritten from old branch)

  • apps/blossom/src/auth/nostr.ts — main's BUD-11 multi-x-tag validation
  • apps/gateway/src/hostname.{ts,test.ts} — main's hyphenated-dTag support + tests
  • apps/gateway/src/security-headers.ts — main's tighter CSP
  • apps/spa/src/lib/tools-resources.yaml — main's updated URLs/versions
  • packages/stealthis/* — main-only package, untouched

Test plan

  • packages/deployer vitest — 114/114 pass
  • apps/spa vitest — 6/6 pass
  • vite build (SPA) — ok
  • npm run build:widget (packages/deployer) — ok (dist/deployer.js + dist/deployer.mjs)
  • deno task build — ok (relay/blossom/gateway bundles)
  • deno task check — ok
  • Manual widget test via packages/deployer/test/test-widget.html after build
  • Manual SPA smoke test: login → deploy → manage → delete flow

Extract the deploy/manage/auth component tree from apps/spa into a standalone
@nsite/deployer package so it can be consumed as an embeddable widget. The SPA
becomes a thin shell that mounts DeployerWidget and renders Navbar with
session props received via events.

Package layout:
- packages/deployer/src/components: 12 Svelte components (DeployerWidget,
  ManageSite, SuccessPanel, LoginModal, NIP46Dialog, AdvancedConfig,
  DeployZone, FileTree, ActivityRings, ProgressIndicator, LogoutConfirmModal,
  OperationBanner)
- packages/deployer/src/lib: upload, publish, nostr, scanner, crypto, files,
  base36, store (converted to createDeployerStores factory)
- packages/deployer/src/widget: NsiteDeployerElement HTMLElement wrapper and
  CSS string constant for the custom element
- packages/deployer/{vite.widget.config.js,vitest.config.js,svelte.config.js}

Workspace:
- Root package.json with npm workspaces (apps/spa, packages/deployer)
- .npmrc for @jsr registry
- deno.json nodeModulesDir: "none" for deno+npm workspace compat
- apps/spa/package.json depends on @nsite/deployer via workspace protocol
- CI installs deno workspace before build

Main fixes preserved by manual port into decoupled files (bypassing rebase
conflicts from PR #18 squash-merge divergence):
- DeployerWidget.svelte: merge kind-10063 blossoms into serverConfig.extraBlossoms
  so AdvancedConfig shows them; dTag regex allows interior hyphens; deploy
  blossom URL union no longer re-adds userBlossoms (already in extraBlossoms)
- packages/deployer/src/lib/upload.js: uploadBlobs and deleteBlobs batch auth
  signing (50 hashes per event) per BUD-11
- packages/deployer/src/lib/files.js: inferMimeType uses @std/media-types
  contentType() instead of inline MIME_TYPES map

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 10, 2026

Bundle Size Report

Bundle Base PR Delta Status
relay 126.5 KB 126.5 KB +0.0 KB ✅ OK
blossom 64.3 KB 64.3 KB +0.0 KB ✅ OK
gateway 235.1 KB 235.1 KB +0.0 KB ✅ OK

Generated by CI — hard limit 1MB, warning at 750KB.

Bump AUTH_BATCH_SIZE in uploadBlobs and deleteBlobs from 50 to 350 so a
single BUD-11 auth event can cover up to 350 hashes instead of requiring
a sign() round-trip every 50 files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dskvr dskvr mentioned this pull request Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant