1.6 KiB
1.6 KiB
Local Power — fs, sqlite, net
What this example does
Exercises the host-side capability packs that give the page allowlisted local power:
- fs — read / write / list / delete under
BRIDGE_SWARM_STORAGE/files/ - sqlite — open a database under
BRIDGE_SWARM_STORAGE/sqlite/, exec and query - net — CORS-free public http(s) fetch (private / loopback / metadata hosts blocked)
No P2P topic is required.
Prerequisites
Install the BridgeSwarm extension and native host before opening this example.
How to run
Recommended: Extension Settings → enable Examples server, then open the demo URL below.
Dev alternative from the repo root:
npm run examples
Open http://127.0.0.1:4173/local-power/. Do not use file://.
Usage
- Confirm the banner lists
fs,sqlite, andnet. - Files: write
hello.txt, read it back, list the tree, delete. - SQLite: open
demo, execCREATE TABLE …, change the SQL toSELECT * FROM notes, query. - Fetch: request
https://example.com(text) or a public JSON URL.http://127.0.0.1/must fail.
Files in this directory
- index.html — Tabs for Files / SQLite / Fetch.
- style.css — Small layout extras on shared chrome.
- app.js —
BridgeSwarm.fs/.sqlite/.netcalls.
APIs and concepts
BridgeSwarm.capabilities.list()— installed pack ids.BridgeSwarm.fs.write/read/list/unlinkBridgeSwarm.sqlite.open/exec/query/closeBridgeSwarm.net.fetch({ url, as })
See Capabilities.