mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 16:19:07 -05:00
using nostr-tools with a facade.
This commit is contained in:
parent
892b2122b8
commit
3a97f7928b
20
build.js
20
build.js
|
@ -1,7 +1,23 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
require('esbuild').buildSync({
|
const esbuild = require('esbuild')
|
||||||
|
const alias = require('esbuild-plugin-alias')
|
||||||
|
const nodeGlobals = require('@esbuild-plugins/node-globals-polyfill').default
|
||||||
|
|
||||||
|
esbuild
|
||||||
|
.build({
|
||||||
entryPoints: ['globals.js'],
|
entryPoints: ['globals.js'],
|
||||||
outfile: 'globals.bundle.js',
|
outfile: 'globals.bundle.js',
|
||||||
bundle: true
|
bundle: true,
|
||||||
|
plugins: [
|
||||||
|
alias({
|
||||||
|
stream: require.resolve('readable-stream')
|
||||||
|
}),
|
||||||
|
nodeGlobals({buffer: true})
|
||||||
|
],
|
||||||
|
define: {
|
||||||
|
window: 'self',
|
||||||
|
global: 'self'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
.then(() => console.log('build success.'))
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
window.React = require('react')
|
window.React = require('react')
|
||||||
window.ReactDOM = require('react-dom')
|
window.ReactDOM = require('react-dom')
|
||||||
|
window.Nostr = require('nostr-tools')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<meta charset=utf-8>
|
<meta charset=utf-8>
|
||||||
<title>title</title>
|
<title>nostr army knife - nak</title>
|
||||||
<body></body>
|
<body></body>
|
||||||
<script src=globals.bundle.js></script>
|
<script src=globals.bundle.js></script>
|
||||||
<script src=target/scala-2.13/app-fastopt/main.js></script>
|
<script src=target/scala-2.13/app-fastopt/main.js></script>
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
"start": "./build.js && sbt ~fastLinkJS"
|
"start": "./build.js && sbt ~fastLinkJS"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
||||||
"esbuild": "^0.14.23",
|
"esbuild": "^0.14.23",
|
||||||
|
"esbuild-plugin-alias": "^0.2.1",
|
||||||
|
"events": "^3.3.0",
|
||||||
|
"nostr-tools": "^0.22.2",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2"
|
"react-dom": "^17.0.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import slinky.web.html._
|
||||||
import slinky.core.facade.Hooks._
|
import slinky.core.facade.Hooks._
|
||||||
import slinky.core.facade.Fragment
|
import slinky.core.facade.Fragment
|
||||||
|
|
||||||
|
import app.modules.Nostr
|
||||||
import app.handlers.{Handler}
|
import app.handlers.{Handler}
|
||||||
import app.components.{Item}
|
import app.components.{Item}
|
||||||
|
|
||||||
|
@ -19,7 +20,9 @@ object KeyHandling extends Handler {
|
||||||
override val component = FunctionalComponent[String] { props =>
|
override val component = FunctionalComponent[String] { props =>
|
||||||
Fragment(
|
Fragment(
|
||||||
Item.component(Item.props("private key", "", props)),
|
Item.component(Item.props("private key", "", props)),
|
||||||
Item.component(Item.props("public key", "", "soon to be shown here"))
|
Item.component(
|
||||||
|
Item.props("public key", "", Nostr.getPublicKey(props))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
src/main/scala/app/modules/Nostr.scala
Normal file
10
src/main/scala/app/modules/Nostr.scala
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package app.modules
|
||||||
|
|
||||||
|
import scala.scalajs.js.annotation._
|
||||||
|
import scala.scalajs.js
|
||||||
|
|
||||||
|
@js.native
|
||||||
|
@JSGlobal
|
||||||
|
object Nostr extends js.Object {
|
||||||
|
def getPublicKey(text: String): String = js.native
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user