Grabs a compiled Svelte component (ES Module) from the interwebs and mounts it so it to the DOM, so you can check it out, use it, and run your data (props) through it.
Save a Svelte component to the internet (maybe using something like Web3 Repl Deploy) then paste the URL for the resulting es module / Svelte Component into this gateway.
This gateway will render the component and add the props so you can check it out.
Use the Gateway in your mini-apps:
<script>
import { NetworkIsolated as Gateway } from '@douganderson444/svelte-component-gateway';
// or, if you want the mounted Javascript code to have access to the network:
// import { NetworkAllowed as Gateway } from '@douganderson444/svelte-component-gateway';
// props
export let count = 0;
function handleChange(event) {
console.log(`The count is now: `, event.detail.count);
}
</script>
// YourApp.svelte
<Gateway
esModule={ContactCard}
props={{ firstName: 'Doug', lastname: 'Anderson' }}
on:change={handleChange}
/>
// yourscript.js
import { NetworkIsolated as Gateway } from 'svelte-component-gateway'
// fetch your esModule from the interwebs, [IPFS](https://docs.ipfs.io/concepts/ipfs-gateway/), or perhaps [Arweave](https://docs.arweave.org/developers/server/http-api)
const fetched = await fetch(url);
const ExampleComponent = await fetched.text();
const gateway = new Gateway({
target: document.getElementById('gateway-element'),
props: {
esModule: ExampleComponent,
// optional props
// assuming ExampleComponent.svelte contains something like
// `export let answer`:
props: { answer: 42 } // we want the answer to be 42 instead of the default
})
gateway.$on('change',
event => {
// save them somewhere
// defaults props will be emited on load
console.log("The following properties changed: ", event.detail)
}
)
...
<!-- in your html: -->
<div id='gateway-element'></div>