Initial commit
This commit is contained in:
commit
79288b0483
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
notes
|
33
config.go
Normal file
33
config.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
// External
|
||||||
|
"gopkg.in/yaml.v3"
|
||||||
|
|
||||||
|
// Standard
|
||||||
|
"io/ioutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Websocket struct {
|
||||||
|
Domains []string
|
||||||
|
}
|
||||||
|
|
||||||
|
Database struct {
|
||||||
|
Host string
|
||||||
|
Port int
|
||||||
|
Name string
|
||||||
|
Username string
|
||||||
|
Password string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ConfigRead(filename string) (config Config, err error) {
|
||||||
|
var rawConfigData []byte
|
||||||
|
rawConfigData, err = ioutil.ReadFile(filename)
|
||||||
|
if err != nil { return }
|
||||||
|
|
||||||
|
err = yaml.Unmarshal(rawConfigData, &config)
|
||||||
|
return
|
||||||
|
}
|
132
connection_manager.go
Normal file
132
connection_manager.go
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
// External
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/gorilla/websocket"
|
||||||
|
|
||||||
|
// Standard
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type WsConnection struct {
|
||||||
|
ConnectionManager *ConnectionManager
|
||||||
|
UUID string
|
||||||
|
Conn *websocket.Conn
|
||||||
|
Pruned bool
|
||||||
|
}
|
||||||
|
type ConnectionManager struct {
|
||||||
|
connections map[string]*WsConnection
|
||||||
|
broadcastQueue chan interface{}
|
||||||
|
sendQueue chan SendRequest
|
||||||
|
}
|
||||||
|
type SendRequest struct {
|
||||||
|
WsConn *WsConnection
|
||||||
|
Msg interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateOrigin(r *http.Request) bool {// {{{
|
||||||
|
/*
|
||||||
|
host := r.Header.Get("X-Forwarded-Host")
|
||||||
|
if host == "" {
|
||||||
|
components := strings.Split(r.Host, ":")
|
||||||
|
host = components[0]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return true
|
||||||
|
}// }}}
|
||||||
|
|
||||||
|
var (
|
||||||
|
upgrader = websocket.Upgrader{
|
||||||
|
ReadBufferSize: 1024,
|
||||||
|
WriteBufferSize: 1024,
|
||||||
|
|
||||||
|
// CheckOrigin is to match DOMAIN constant.
|
||||||
|
// Use X-Forwarded-Server if behind proxy.
|
||||||
|
CheckOrigin: validateOrigin,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewConnectionManager() (cm ConnectionManager) {// {{{
|
||||||
|
cm.connections = make(map[string]*WsConnection)
|
||||||
|
cm.sendQueue = make(chan SendRequest, 65536)
|
||||||
|
cm.broadcastQueue = make(chan interface{}, 65536)
|
||||||
|
return
|
||||||
|
}// }}}
|
||||||
|
|
||||||
|
// NewConnection creates a new connection, which is assigned a UUIDv4 for
|
||||||
|
// identification. This is then put into the connection collection.
|
||||||
|
func (cm *ConnectionManager) NewConnection(w http.ResponseWriter, r *http.Request) (*WsConnection, error) {// {{{
|
||||||
|
var err error
|
||||||
|
wsConn := WsConnection{
|
||||||
|
UUID: uuid.NewString(),
|
||||||
|
ConnectionManager: cm,
|
||||||
|
}
|
||||||
|
wsConn.Conn, err = upgrader.Upgrade(w, r, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep track of all connections.
|
||||||
|
cm.connections[wsConn.UUID] = &wsConn
|
||||||
|
|
||||||
|
// Successfully upgraded to a websocket connection.
|
||||||
|
log.Printf("[%s] Connection from %s", wsConn.UUID, r.RemoteAddr)
|
||||||
|
|
||||||
|
go cm.ReadLoop(&wsConn)
|
||||||
|
|
||||||
|
return &wsConn, nil
|
||||||
|
}// }}}
|
||||||
|
|
||||||
|
// Prune closes an deletes connections. If this happened to be non-fatal, the
|
||||||
|
// user will just have to reconnect.
|
||||||
|
func (cm *ConnectionManager) Prune(wsConn *WsConnection, err error) {// {{{
|
||||||
|
if false {
|
||||||
|
log.Printf("[%s] pruning connection [%s]\n", wsConn.UUID, err)
|
||||||
|
}
|
||||||
|
wsConn.Conn.Close()
|
||||||
|
wsConn.Pruned = true
|
||||||
|
delete(cm.connections, wsConn.UUID)
|
||||||
|
}// }}}
|
||||||
|
func (cm *ConnectionManager) ReadLoop(wsConn *WsConnection) {// {{{
|
||||||
|
var data []byte
|
||||||
|
var ok bool
|
||||||
|
|
||||||
|
for {
|
||||||
|
if data, ok = cm.Read(wsConn); !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("%s\n", data)
|
||||||
|
|
||||||
|
//cm.Send(wsConn, response)
|
||||||
|
}
|
||||||
|
}// }}}
|
||||||
|
func (cm *ConnectionManager) Read(wsConn *WsConnection) ([]byte, bool) {// {{{
|
||||||
|
var err error
|
||||||
|
var requestData []byte
|
||||||
|
_, requestData, err = wsConn.Conn.ReadMessage()
|
||||||
|
if err != nil {
|
||||||
|
cm.Prune(wsConn, err)
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
return requestData, true
|
||||||
|
}// }}}
|
||||||
|
func (cm *ConnectionManager) Send(wsConn *WsConnection, msg interface{}) {// {{{
|
||||||
|
wsConn.Conn.WriteJSON(msg)
|
||||||
|
}// }}}
|
||||||
|
func (cm *ConnectionManager) Broadcast(msg interface{}) {// {{{
|
||||||
|
cm.broadcastQueue <- msg
|
||||||
|
}// }}}
|
||||||
|
|
||||||
|
func (cm *ConnectionManager) BroadcastLoop() {// {{{
|
||||||
|
for {
|
||||||
|
msg := <-cm.broadcastQueue
|
||||||
|
for _, wsConn := range cm.connections {
|
||||||
|
cm.Send(wsConn, msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}// }}}
|
||||||
|
|
||||||
|
// vim: foldmethod=marker
|
42
db.go
Normal file
42
db.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
// External
|
||||||
|
"github.com/jmoiron/sqlx"
|
||||||
|
_ "github.com/lib/pq"
|
||||||
|
|
||||||
|
// Standard
|
||||||
|
_ "database/sql"
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
dbConn string
|
||||||
|
db *sqlx.DB
|
||||||
|
)
|
||||||
|
|
||||||
|
func dbInit() {
|
||||||
|
dbConn = fmt.Sprintf(
|
||||||
|
"host=%s port=%d user=%s password=%s dbname=%s sslmode=disable",
|
||||||
|
config.Database.Host,
|
||||||
|
config.Database.Port,
|
||||||
|
config.Database.Username,
|
||||||
|
config.Database.Password,
|
||||||
|
config.Database.Name,
|
||||||
|
)
|
||||||
|
|
||||||
|
log.Printf(
|
||||||
|
"\x1b[32mNotes\x1b[0m Connecting to database %s:%d\n",
|
||||||
|
config.Database.Host,
|
||||||
|
config.Database.Port,
|
||||||
|
)
|
||||||
|
|
||||||
|
var err error
|
||||||
|
db, err = sqlx.Connect("postgres", dbConn)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// vim: foldmethod=marker
|
11
go.mod
Normal file
11
go.mod
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
module notes
|
||||||
|
|
||||||
|
go 1.20
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/google/uuid v1.3.0
|
||||||
|
github.com/gorilla/websocket v1.5.0
|
||||||
|
github.com/jmoiron/sqlx v1.3.5
|
||||||
|
github.com/lib/pq v1.10.9
|
||||||
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
|
)
|
17
go.sum
Normal file
17
go.sum
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||||
|
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||||
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||||
|
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=
|
||||||
|
github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ=
|
||||||
|
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||||
|
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
128
main.go
Normal file
128
main.go
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
// Standard
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"html/template"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const VERSION = "v0.0.1";
|
||||||
|
const LISTEN_HOST = "0.0.0.0";
|
||||||
|
|
||||||
|
var (
|
||||||
|
flagPort int
|
||||||
|
connectionManager ConnectionManager
|
||||||
|
static http.Handler
|
||||||
|
config Config
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
func init() {// {{{
|
||||||
|
flag.IntVar(
|
||||||
|
&flagPort,
|
||||||
|
"port",
|
||||||
|
1371,
|
||||||
|
"TCP port to listen on",
|
||||||
|
)
|
||||||
|
|
||||||
|
flag.Parse()
|
||||||
|
}// }}}
|
||||||
|
func main() {// {{{
|
||||||
|
var err error
|
||||||
|
log.Printf("\x1b[32mNotes\x1b[0m %s\n", VERSION)
|
||||||
|
|
||||||
|
config, err = ConfigRead(os.Getenv("HOME")+"/.config/notes.yaml")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
dbInit()
|
||||||
|
connectionManager = NewConnectionManager()
|
||||||
|
go connectionManager.BroadcastLoop()
|
||||||
|
|
||||||
|
static = http.FileServer(http.Dir("./static"))
|
||||||
|
http.HandleFunc("/css_updated", cssUpdateHandler)
|
||||||
|
http.HandleFunc("/session/create", sessionCreate)
|
||||||
|
http.HandleFunc("/ws", websocketHandler)
|
||||||
|
http.HandleFunc("/", staticHandler)
|
||||||
|
|
||||||
|
listen := fmt.Sprintf("%s:%d", LISTEN_HOST, flagPort)
|
||||||
|
log.Printf("\x1b[32mNotes\x1b[0m Listening on %s\n", listen)
|
||||||
|
log.Printf("\x1b[32mNotes\x1b[0m Answer for domains %s\n", strings.Join(config.Websocket.Domains, ", "))
|
||||||
|
http.ListenAndServe(listen, nil)
|
||||||
|
}// }}}
|
||||||
|
|
||||||
|
func cssUpdateHandler(w http.ResponseWriter, r *http.Request) {// {{{
|
||||||
|
log.Println("[BROADCAST] CSS updated")
|
||||||
|
connectionManager.Broadcast(struct{ Ok bool; ID string; Op string }{ Ok: true, Op: "css_reload" })
|
||||||
|
}// }}}
|
||||||
|
func sessionCreate(w http.ResponseWriter, r *http.Request) {// {{{
|
||||||
|
session, err := NewSession()
|
||||||
|
if err != nil {
|
||||||
|
w.Write()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}// }}}
|
||||||
|
func websocketHandler(w http.ResponseWriter, r *http.Request) {// {{{
|
||||||
|
var err error
|
||||||
|
|
||||||
|
_, err = connectionManager.NewConnection(w, r)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[Connection] %s\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}// }}}
|
||||||
|
func staticHandler(w http.ResponseWriter, r *http.Request) {// {{{
|
||||||
|
data := struct{
|
||||||
|
VERSION string
|
||||||
|
}{
|
||||||
|
VERSION: VERSION,
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLs with pattern /(css|images)/v1.0.0/foobar are stripped of the version.
|
||||||
|
// To get rid of problems with cached content in browser on a new version release,
|
||||||
|
// while also not disabling cache altogether.
|
||||||
|
rxp := regexp.MustCompile("^/(css|images|js|fonts)/v[0-9]+\\.[0-9]+\\.[0-9]+/(.*)$")
|
||||||
|
if comp := rxp.FindStringSubmatch(r.URL.Path); comp != nil {
|
||||||
|
r.URL.Path = fmt.Sprintf("/%s/%s", comp[1], comp[2])
|
||||||
|
static.ServeHTTP(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Everything else is run through the template system.
|
||||||
|
// For now to get VERSION into files to fix caching.
|
||||||
|
tmpl, err := newTemplate(r.URL.Path)
|
||||||
|
if err != nil {
|
||||||
|
w.Write([]byte(err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = tmpl.Execute(w, data); err != nil {
|
||||||
|
w.Write([]byte(err.Error()))
|
||||||
|
}
|
||||||
|
}// }}}
|
||||||
|
|
||||||
|
func newTemplate(requestPath string) (tmpl *template.Template, err error) {// {{{
|
||||||
|
// Append index.html if needed for further reading of the file
|
||||||
|
p := requestPath
|
||||||
|
if p[len(p)-1] == '/' {
|
||||||
|
p += "index.html"
|
||||||
|
}
|
||||||
|
p = "static" + p
|
||||||
|
|
||||||
|
base := path.Base(p)
|
||||||
|
if tmpl, err = template.New(base).ParseFiles(p); err != nil { return }
|
||||||
|
|
||||||
|
return
|
||||||
|
}// }}}
|
||||||
|
|
||||||
|
// vim: foldmethod=marker
|
12
request_response.go
Normal file
12
request_response.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
// Standard
|
||||||
|
"encoding/json"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Request struct {
|
||||||
|
ID string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (req *Request)
|
31
session.go
Normal file
31
session.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
// Standard
|
||||||
|
"database/sql"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Session struct {
|
||||||
|
UUID string
|
||||||
|
UserID int
|
||||||
|
Created time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSession() (session Session, err error) {
|
||||||
|
var rows *sql.Rows
|
||||||
|
if rows, err = db.Query(`
|
||||||
|
INSERT INTO public.session(uuid)
|
||||||
|
VALUES(gen_random_uuid())
|
||||||
|
RETURNING uuid, created`,
|
||||||
|
); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
|
||||||
|
if rows.Next() {
|
||||||
|
rows.Scan(&session.UUID, &session.Created)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
20
static/css/login.css
Normal file
20
static/css/login.css
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#login {
|
||||||
|
display: grid;
|
||||||
|
justify-items: center;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
#login div {
|
||||||
|
max-width: 300px;
|
||||||
|
}
|
||||||
|
#login div input {
|
||||||
|
margin-bottom: 32px;
|
||||||
|
width: 100%;
|
||||||
|
border: 0px;
|
||||||
|
border-bottom: 1px solid #fff;
|
||||||
|
font-size: 18pt;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #494949;
|
||||||
|
}
|
||||||
|
#login div input:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
15
static/css/main.css
Normal file
15
static/css/main.css
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
html,
|
||||||
|
body {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
font-family: 'Liberation Mono', monospace;
|
||||||
|
font-size: 16pt;
|
||||||
|
background-color: #494949;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #ecbf00;
|
||||||
|
}
|
||||||
|
#app {
|
||||||
|
padding: 32px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
0
static/css/theme.css
Normal file
0
static/css/theme.css
Normal file
1013
static/images/test.svg
Normal file
1013
static/images/test.svg
Normal file
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 57 KiB |
32
static/index.html
Normal file
32
static/index.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/main.css">
|
||||||
|
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/login.css">
|
||||||
|
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/css_reload.js"></script>
|
||||||
|
|
||||||
|
<script type="importmap">
|
||||||
|
{
|
||||||
|
"imports": {
|
||||||
|
"preact": "/js/{{ .VERSION }}/lib/preact/preact.mjs",
|
||||||
|
"preact/hooks": "/js/{{ .VERSION }}/lib/preact/hooks.mjs",
|
||||||
|
"preact/debug": "/js/{{ .VERSION }}/lib/preact/debug.mjs",
|
||||||
|
"preact/devtools": "/js/{{ .VERSION }}/lib/preact/devtools.mjs",
|
||||||
|
"@preact/signals-core": "/js/{{ .VERSION }}/lib/signals/signals-core.mjs",
|
||||||
|
"preact/signals": "/js/{{ .VERSION }}/lib/signals/signals.mjs",
|
||||||
|
"htm": "/js/{{ .VERSION }}/lib/htm/htm.mjs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="app"></div>
|
||||||
|
</body>
|
||||||
|
<script>
|
||||||
|
window._VERSION = "{{ .VERSION }}"
|
||||||
|
</script>
|
||||||
|
<script type="module" src="/js/{{ .VERSION }}/app.mjs" defer></script>
|
||||||
|
</html>
|
96
static/js/app.mjs
Normal file
96
static/js/app.mjs
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import 'preact/debug'
|
||||||
|
import 'preact/devtools'
|
||||||
|
//import { signal } from 'preact/signals'
|
||||||
|
import { h, Component, render, createRef } from 'preact'
|
||||||
|
import htm from 'htm'
|
||||||
|
const html = htm.bind(h)
|
||||||
|
|
||||||
|
class App extends Component {
|
||||||
|
constructor() {//{{{
|
||||||
|
super()
|
||||||
|
this.websocket = null
|
||||||
|
this.websocket_int_ping = null
|
||||||
|
this.websocket_int_reconnect = null
|
||||||
|
this.wsConnect()
|
||||||
|
this.wsLoop()
|
||||||
|
|
||||||
|
this.sessionID = window.localStorage.getItem("sessionID")
|
||||||
|
}//}}}
|
||||||
|
render() {//{{{
|
||||||
|
if(this.sessionID === null) {
|
||||||
|
return html`<${Login} />`
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`Welcome`;
|
||||||
|
}//}}}
|
||||||
|
|
||||||
|
wsLoop() {//{{{
|
||||||
|
setInterval(()=>{
|
||||||
|
if(this.websocket === null) {
|
||||||
|
console.log("wsLoop connect")
|
||||||
|
this.wsConnect()
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}//}}}
|
||||||
|
wsConnect() {//{{{
|
||||||
|
this.websocket = new WebSocket(`wss://notes.ahall.se/ws`)
|
||||||
|
this.websocket.onopen = evt=>this.wsOpen(evt)
|
||||||
|
this.websocket.onmessage = evt=>this.wsMessage(evt)
|
||||||
|
this.websocket.onerror = evt=>this.wsError(evt)
|
||||||
|
this.websocket.onclose = evt=>this.wsClose(evt)
|
||||||
|
}//}}}
|
||||||
|
wsOpen() {//{{{
|
||||||
|
this.setState({ wsConnected: true })
|
||||||
|
|
||||||
|
// A ping interval to implement a rudimentary keep-alive.
|
||||||
|
}//}}}
|
||||||
|
wsClose() {//{{{
|
||||||
|
console.log("Lost connection to Notes server")
|
||||||
|
this.websocket = null
|
||||||
|
}//}}}
|
||||||
|
wsError(evt) {//{{{
|
||||||
|
console.log("websocket error", evt)
|
||||||
|
this.websocket = null;
|
||||||
|
}//}}}
|
||||||
|
wsMessage(evt) {//{{{
|
||||||
|
let msg = JSON.parse(evt.data)
|
||||||
|
|
||||||
|
// Broadcast message
|
||||||
|
if(msg.ID == '') {
|
||||||
|
this.broadcastHandler(msg)
|
||||||
|
} else {
|
||||||
|
this.msgHandler(msg)
|
||||||
|
}
|
||||||
|
}//}}}
|
||||||
|
|
||||||
|
broadcastHandler(msg) {//{{{
|
||||||
|
switch(msg.Op) {
|
||||||
|
case 'css_reload':
|
||||||
|
refreshCSS()
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}//}}}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Login extends Component {
|
||||||
|
render() {
|
||||||
|
return html`
|
||||||
|
<div id="login">
|
||||||
|
<h1>Notes</h1>
|
||||||
|
<div>
|
||||||
|
<input id="username" type="text" placeholder="Username" />
|
||||||
|
<input id="password" type="password" placeholder="Password" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init{{{
|
||||||
|
//let urlParams = new URLSearchParams(window.location.search)
|
||||||
|
window._app = createRef()
|
||||||
|
window._resourceModels = []
|
||||||
|
render(html`<${App} ref=${window._app} />`, document.getElementById('app'))
|
||||||
|
//}}}
|
||||||
|
|
||||||
|
// vim: foldmethod=marker
|
10
static/js/lib/css_reload.js
Normal file
10
static/js/lib/css_reload.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
function refreshCSS() {
|
||||||
|
let links = document.getElementsByTagName('link')
|
||||||
|
Array.from(links).forEach(l=>{
|
||||||
|
if (l.rel == 'stylesheet' && !l.hasAttribute('x-no-reload')) {
|
||||||
|
let cache = Math.floor(Math.random()*100000)
|
||||||
|
l.href = l.href.replace(/\?.*/, '') + `?cache=${cache}`
|
||||||
|
console.log(l.href)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
6
static/js/lib/htm/htm.d.ts
vendored
Normal file
6
static/js/lib/htm/htm.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
declare const htm: {
|
||||||
|
bind<HResult>(
|
||||||
|
h: (type: any, props: Record<string, any>, ...children: any[]) => HResult
|
||||||
|
): (strings: TemplateStringsArray, ...values: any[]) => HResult | HResult[];
|
||||||
|
};
|
||||||
|
export default htm;
|
1
static/js/lib/htm/htm.js
Normal file
1
static/js/lib/htm/htm.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(){const t=(e,n,s,u)=>{let h;n[0]=0;for(let l=1;l<n.length;l++){const p=n[l++],o=n[l]?(n[0]|=p?1:2,s[n[l++]]):n[++l];3===p?u[0]=o:4===p?u[1]=Object.assign(u[1]||{},o):5===p?(u[1]=u[1]||{})[n[++l]]=o:6===p?u[1][n[++l]]+=o+"":p?(h=e.apply(o,t(e,o,s,["",null])),u.push(h),o[0]?n[0]|=2:(n[l-2]=0,n[l]=h)):u.push(o)}return u},e=function(t){let e,n,s=1,u="",h="",l=[0];const p=t=>{1===s&&(t||(u=u.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?l.push(0,t,u):3===s&&(t||u)?(l.push(3,t,u),s=2):2===s&&"..."===u&&t?l.push(4,t,0):2===s&&u&&!t?l.push(5,0,!0,u):s>=5&&((u||!t&&5===s)&&(l.push(s,0,u,n),s=6),t&&(l.push(s,t,0,n),s=6)),u=""};for(let o=0;o<t.length;o++){o&&(1===s&&p(),p(o));for(let r=0;r<t[o].length;r++)e=t[o][r],1===s?"<"===e?(p(),l=[l],s=3):u+=e:4===s?"--"===u&&">"===e?(s=1,u=""):u=e+u[0]:h?e===h?h="":u+=e:'"'===e||"'"===e?h=e:">"===e?(p(),s=1):s&&("="===e?(s=5,n=u,u=""):"/"===e&&(s<5||">"===t[o][r+1])?(p(),3===s&&(l=l[0]),s=l,(l=l[0]).push(2,0,s),s=0):" "===e||"\t"===e||"\n"===e||"\r"===e?(p(),s=2):u+=e),3===s&&"!--"===u&&(s=4,l=l[0])}return p(),l},n=new Map;var s=function(s){let u=n.get(this);return u||(u=new Map,n.set(this,u)),u=t(this,u.get(s)||(u.set(s,u=e(s)),u),arguments,[]),u.length>1?u:u[0]};"undefined"!=typeof module?module.exports=s:self.htm=s}();
|
1
static/js/lib/htm/htm.mjs
Normal file
1
static/js/lib/htm/htm.mjs
Normal file
@ -0,0 +1 @@
|
|||||||
|
const t=(e,s,n,h)=>{let u;s[0]=0;for(let l=1;l<s.length;l++){const p=s[l++],r=s[l]?(s[0]|=p?1:2,n[s[l++]]):s[++l];3===p?h[0]=r:4===p?h[1]=Object.assign(h[1]||{},r):5===p?(h[1]=h[1]||{})[s[++l]]=r:6===p?h[1][s[++l]]+=r+"":p?(u=e.apply(r,t(e,r,n,["",null])),h.push(u),r[0]?s[0]|=2:(s[l-2]=0,s[l]=u)):h.push(r)}return h},e=function(t){let e,s,n=1,h="",u="",l=[0];const p=t=>{1===n&&(t||(h=h.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?l.push(0,t,h):3===n&&(t||h)?(l.push(3,t,h),n=2):2===n&&"..."===h&&t?l.push(4,t,0):2===n&&h&&!t?l.push(5,0,!0,h):n>=5&&((h||!t&&5===n)&&(l.push(n,0,h,s),n=6),t&&(l.push(n,t,0,s),n=6)),h=""};for(let r=0;r<t.length;r++){r&&(1===n&&p(),p(r));for(let o=0;o<t[r].length;o++)e=t[r][o],1===n?"<"===e?(p(),l=[l],n=3):h+=e:4===n?"--"===h&&">"===e?(n=1,h=""):h=e+h[0]:u?e===u?u="":h+=e:'"'===e||"'"===e?u=e:">"===e?(p(),n=1):n&&("="===e?(n=5,s=h,h=""):"/"===e&&(n<5||">"===t[r][o+1])?(p(),3===n&&(l=l[0]),n=l,(l=l[0]).push(2,0,n),n=0):" "===e||"\t"===e||"\n"===e||"\r"===e?(p(),n=2):h+=e),3===n&&"!--"===h&&(n=4,l=l[0])}return p(),l},s=new Map;var n=function(n){let h=s.get(this);return h||(h=new Map,s.set(this,h)),h=t(this,h.get(n)||(h.set(n,h=e(n)),h),arguments,[]),h.length>1?h:h[0]};export{n as default};
|
1
static/js/lib/htm/htm.module.js
Normal file
1
static/js/lib/htm/htm.module.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
const t=(e,s,n,h)=>{let u;s[0]=0;for(let l=1;l<s.length;l++){const p=s[l++],r=s[l]?(s[0]|=p?1:2,n[s[l++]]):s[++l];3===p?h[0]=r:4===p?h[1]=Object.assign(h[1]||{},r):5===p?(h[1]=h[1]||{})[s[++l]]=r:6===p?h[1][s[++l]]+=r+"":p?(u=e.apply(r,t(e,r,n,["",null])),h.push(u),r[0]?s[0]|=2:(s[l-2]=0,s[l]=u)):h.push(r)}return h},e=function(t){let e,s,n=1,h="",u="",l=[0];const p=t=>{1===n&&(t||(h=h.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?l.push(0,t,h):3===n&&(t||h)?(l.push(3,t,h),n=2):2===n&&"..."===h&&t?l.push(4,t,0):2===n&&h&&!t?l.push(5,0,!0,h):n>=5&&((h||!t&&5===n)&&(l.push(n,0,h,s),n=6),t&&(l.push(n,t,0,s),n=6)),h=""};for(let r=0;r<t.length;r++){r&&(1===n&&p(),p(r));for(let o=0;o<t[r].length;o++)e=t[r][o],1===n?"<"===e?(p(),l=[l],n=3):h+=e:4===n?"--"===h&&">"===e?(n=1,h=""):h=e+h[0]:u?e===u?u="":h+=e:'"'===e||"'"===e?u=e:">"===e?(p(),n=1):n&&("="===e?(n=5,s=h,h=""):"/"===e&&(n<5||">"===t[r][o+1])?(p(),3===n&&(l=l[0]),n=l,(l=l[0]).push(2,0,n),n=0):" "===e||"\t"===e||"\n"===e||"\r"===e?(p(),n=2):h+=e),3===n&&"!--"===h&&(n=4,l=l[0])}return p(),l},s=new Map;var n=function(n){let h=s.get(this);return h||(h=new Map,s.set(this,h)),h=t(this,h.get(n)||(h.set(n,h=e(n)),h),arguments,[]),h.length>1?h:h[0]};export{n as default};
|
1
static/js/lib/htm/htm.umd.js
Normal file
1
static/js/lib/htm/htm.umd.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).htm=t()}(this,function(){const e=(t,n,s,u)=>{let o;n[0]=0;for(let l=1;l<n.length;l++){const h=n[l++],p=n[l]?(n[0]|=h?1:2,s[n[l++]]):n[++l];3===h?u[0]=p:4===h?u[1]=Object.assign(u[1]||{},p):5===h?(u[1]=u[1]||{})[n[++l]]=p:6===h?u[1][n[++l]]+=p+"":h?(o=t.apply(p,e(t,p,s,["",null])),u.push(o),p[0]?n[0]|=2:(n[l-2]=0,n[l]=o)):u.push(p)}return u},t=function(e){let t,n,s=1,u="",o="",l=[0];const h=e=>{1===s&&(e||(u=u.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?l.push(0,e,u):3===s&&(e||u)?(l.push(3,e,u),s=2):2===s&&"..."===u&&e?l.push(4,e,0):2===s&&u&&!e?l.push(5,0,!0,u):s>=5&&((u||!e&&5===s)&&(l.push(s,0,u,n),s=6),e&&(l.push(s,e,0,n),s=6)),u=""};for(let p=0;p<e.length;p++){p&&(1===s&&h(),h(p));for(let f=0;f<e[p].length;f++)t=e[p][f],1===s?"<"===t?(h(),l=[l],s=3):u+=t:4===s?"--"===u&&">"===t?(s=1,u=""):u=t+u[0]:o?t===o?o="":u+=t:'"'===t||"'"===t?o=t:">"===t?(h(),s=1):s&&("="===t?(s=5,n=u,u=""):"/"===t&&(s<5||">"===e[p][f+1])?(h(),3===s&&(l=l[0]),s=l,(l=l[0]).push(2,0,s),s=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(h(),s=2):u+=t),3===s&&"!--"===u&&(s=4,l=l[0])}return h(),l},n=new Map;return function(s){let u=n.get(this);return u||(u=new Map,n.set(this,u)),u=e(this,u.get(s)||(u.set(s,u=t(s)),u),arguments,[]),u.length>1?u:u[0]}});
|
2
static/js/lib/preact/debug.js
Normal file
2
static/js/lib/preact/debug.js
Normal file
File diff suppressed because one or more lines are too long
1
static/js/lib/preact/debug.js.map
Normal file
1
static/js/lib/preact/debug.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/debug.mjs
Normal file
2
static/js/lib/preact/debug.mjs
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/debug.module.js
Normal file
2
static/js/lib/preact/debug.module.js
Normal file
File diff suppressed because one or more lines are too long
1
static/js/lib/preact/debug.module.js.map
Normal file
1
static/js/lib/preact/debug.module.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/debug.umd.js
Normal file
2
static/js/lib/preact/debug.umd.js
Normal file
File diff suppressed because one or more lines are too long
1
static/js/lib/preact/debug.umd.js.map
Normal file
1
static/js/lib/preact/debug.umd.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/devtools.js
Normal file
2
static/js/lib/preact/devtools.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var n=require("preact");"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.12.0",n.options,{Fragment:n.Fragment,Component:n.Component}),exports.addHookName=function(e,o){return n.options.__a&&n.options.__a(o),e};
|
||||||
|
//# sourceMappingURL=devtools.js.map
|
1
static/js/lib/preact/devtools.js.map
Normal file
1
static/js/lib/preact/devtools.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"devtools.js","sources":["../src/devtools.js","../src/index.js"],"sourcesContent":["import { options, Fragment, Component } from 'preact';\n\nexport function initDevTools() {\n\tif (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {\n\t\twindow.__PREACT_DEVTOOLS__.attachPreact('10.12.0', options, {\n\t\t\tFragment,\n\t\t\tComponent\n\t\t});\n\t}\n}\n","import { options } from 'preact';\nimport { initDevTools } from './devtools';\n\ninitDevTools();\n\n/**\n * Display a custom label for a custom hook for the devtools panel\n * @type {<T>(value: T, name: string) => T}\n */\nexport function addHookName(value, name) {\n\tif (options._addHookName) {\n\t\toptions._addHookName(name);\n\t}\n\treturn value;\n}\n"],"names":["window","__PREACT_DEVTOOLS__","attachPreact","options","Fragment","Component","value","name","__a"],"mappings":"wBAGsB,oBAAVA,QAAyBA,OAAOC,qBAC1CD,OAAOC,oBAAoBC,aAAa,UAAWC,EAAAA,QAAS,CAC3DC,SAAAA,EAAAA,SACAC,UAAAA,EAF2DA,gCCKvD,SAAqBC,EAAOC,GAIlC,OAHIJ,EAAAA,QAAsBK,KACzBL,EAAAA,QAAOK,IAAcD,GAEfD,CACP"}
|
2
static/js/lib/preact/devtools.mjs
Normal file
2
static/js/lib/preact/devtools.mjs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import{options as n,Fragment as o,Component as e}from"preact";function t(o,e){return n.__a&&n.__a(e),o}"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.12.0",n,{Fragment:o,Component:e});export{t as addHookName};
|
||||||
|
//# sourceMappingURL=devtools.module.js.map
|
2
static/js/lib/preact/devtools.module.js
Normal file
2
static/js/lib/preact/devtools.module.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import{options as n,Fragment as o,Component as e}from"preact";function t(o,e){return n.__a&&n.__a(e),o}"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.12.0",n,{Fragment:o,Component:e});export{t as addHookName};
|
||||||
|
//# sourceMappingURL=devtools.module.js.map
|
1
static/js/lib/preact/devtools.module.js.map
Normal file
1
static/js/lib/preact/devtools.module.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"devtools.module.js","sources":["../src/index.js","../src/devtools.js"],"sourcesContent":["import { options } from 'preact';\nimport { initDevTools } from './devtools';\n\ninitDevTools();\n\n/**\n * Display a custom label for a custom hook for the devtools panel\n * @type {<T>(value: T, name: string) => T}\n */\nexport function addHookName(value, name) {\n\tif (options._addHookName) {\n\t\toptions._addHookName(name);\n\t}\n\treturn value;\n}\n","import { options, Fragment, Component } from 'preact';\n\nexport function initDevTools() {\n\tif (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {\n\t\twindow.__PREACT_DEVTOOLS__.attachPreact('10.12.0', options, {\n\t\t\tFragment,\n\t\t\tComponent\n\t\t});\n\t}\n}\n"],"names":["addHookName","value","name","options","__a","window","__PREACT_DEVTOOLS__","attachPreact","Fragment","Component"],"mappings":"8DASO,SAASA,EAAYC,EAAOC,GAIlC,OAHIC,EAAsBC,KACzBD,EAAOC,IAAcF,GAEfD,CACP,CCXqB,oBAAVI,QAAyBA,OAAOC,qBAC1CD,OAAOC,oBAAoBC,aAAa,UAAWJ,EAAS,CAC3DK,SAAAA,EACAC,UAAAA"}
|
2
static/js/lib/preact/devtools.umd.js
Normal file
2
static/js/lib/preact/devtools.umd.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],n):n((e||self).preactDevtools={},e.preact)}(this,function(e,n){"undefined"!=typeof window&&window.__PREACT_DEVTOOLS__&&window.__PREACT_DEVTOOLS__.attachPreact("10.12.0",n.options,{Fragment:n.Fragment,Component:n.Component}),e.addHookName=function(e,o){return n.options.__a&&n.options.__a(o),e}});
|
||||||
|
//# sourceMappingURL=devtools.umd.js.map
|
1
static/js/lib/preact/devtools.umd.js.map
Normal file
1
static/js/lib/preact/devtools.umd.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"devtools.umd.js","sources":["../src/devtools.js","../src/index.js"],"sourcesContent":["import { options, Fragment, Component } from 'preact';\n\nexport function initDevTools() {\n\tif (typeof window != 'undefined' && window.__PREACT_DEVTOOLS__) {\n\t\twindow.__PREACT_DEVTOOLS__.attachPreact('10.12.0', options, {\n\t\t\tFragment,\n\t\t\tComponent\n\t\t});\n\t}\n}\n","import { options } from 'preact';\nimport { initDevTools } from './devtools';\n\ninitDevTools();\n\n/**\n * Display a custom label for a custom hook for the devtools panel\n * @type {<T>(value: T, name: string) => T}\n */\nexport function addHookName(value, name) {\n\tif (options._addHookName) {\n\t\toptions._addHookName(name);\n\t}\n\treturn value;\n}\n"],"names":["window","__PREACT_DEVTOOLS__","attachPreact","options","Fragment","Component","value","name","__a"],"mappings":"8QAGsB,oBAAVA,QAAyBA,OAAOC,qBAC1CD,OAAOC,oBAAoBC,aAAa,UAAWC,EAAAA,QAAS,CAC3DC,SAAAA,EAAAA,SACAC,UAAAA,EAF2DA,0BCKvD,SAAqBC,EAAOC,GAIlC,OAHIJ,EAAAA,QAAsBK,KACzBL,EAAAA,QAAOK,IAAcD,GAEfD,CACP"}
|
2
static/js/lib/preact/hooks.js
Normal file
2
static/js/lib/preact/hooks.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var n,t,r,u,o=require("preact"),i=0,c=[],f=[],e=o.options.__b,a=o.options.__r,v=o.options.diffed,s=o.options.__c,p=o.options.unmount;function l(n,r){o.options.__h&&o.options.__h(t,n,i||r),i=0;var u=t.__H||(t.__H={__:[],__h:[]});return n>=u.__.length&&u.__.push({__V:f}),u.__[n]}function x(n){return i=1,m(T,n)}function m(r,u,o){var i=l(n++,2);if(i.t=r,!i.__c&&(i.__=[o?o(u):T(void 0,u),function(n){var t=i.__N?i.__N[0]:i.__[0],r=i.t(t,n);t!==r&&(i.__N=[r,i.__[1]],i.__c.setState({}))}],i.__c=t,!t.u)){t.u=!0;var c=t.shouldComponentUpdate;t.shouldComponentUpdate=function(n,t,r){if(!i.__c.__H)return!0;var u=i.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return!n.__N}))return!c||c.call(this,n,t,r);var o=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(o=!0)}}),!!o&&(!c||c.call(this,n,t,r))}}return i.__N||i.__}function d(r,u){var i=l(n++,4);!o.options.__s&&F(i.__H,u)&&(i.__=r,i.o=u,t.__h.push(i))}function y(t,r){var u=l(n++,7);return F(u.__H,r)?(u.__V=t(),u.o=r,u.__h=t,u.__V):u.__}function h(){for(var n;n=c.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(q),n.__H.__h.forEach(A),n.__H.__h=[]}catch(t){n.__H.__h=[],o.options.__e(t,n.__v)}}o.options.__b=function(n){t=null,e&&e(n)},o.options.__r=function(u){a&&a(u),n=0;var o=(t=u.__c).__H;o&&(r===t?(o.__h=[],t.__h=[],o.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=f,n.__N=n.o=void 0})):(o.__h.forEach(q),o.__h.forEach(A),o.__h=[])),r=t},o.options.diffed=function(n){v&&v(n);var i=n.__c;i&&i.__H&&(i.__H.__h.length&&(1!==c.push(i)&&u===o.options.requestAnimationFrame||((u=o.options.requestAnimationFrame)||function(n){var t,r=function(){clearTimeout(u),_&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,100);_&&(t=requestAnimationFrame(r))})(h)),i.__H.__.forEach(function(n){n.o&&(n.__H=n.o),n.__V!==f&&(n.__=n.__V),n.o=void 0,n.__V=f})),r=t=null},o.options.__c=function(n,t){t.some(function(n){try{n.__h.forEach(q),n.__h=n.__h.filter(function(n){return!n.__||A(n)})}catch(r){t.some(function(n){n.__h&&(n.__h=[])}),t=[],o.options.__e(r,n.__v)}}),s&&s(n,t)},o.options.unmount=function(n){p&&p(n);var t,r=n.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{q(n)}catch(n){t=n}}),t&&o.options.__e(t,r.__v))};var _="function"==typeof requestAnimationFrame;function q(n){var r=t,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),t=r}function A(n){var r=t;n.__c=n.__(),t=r}function F(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function T(n,t){return"function"==typeof t?t(n):t}exports.useState=x,exports.useReducer=m,exports.useEffect=function(r,u){var i=l(n++,3);!o.options.__s&&F(i.__H,u)&&(i.__=r,i.o=u,t.__H.__h.push(i))},exports.useLayoutEffect=d,exports.useRef=function(n){return i=5,y(function(){return{current:n}},[])},exports.useImperativeHandle=function(n,t,r){i=6,d(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==r?r:r.concat(n))},exports.useMemo=y,exports.useCallback=function(n,t){return i=8,y(function(){return n},t)},exports.useContext=function(r){var u=t.context[r.__c],o=l(n++,9);return o.c=r,u?(null==o.__&&(o.__=!0,u.sub(t)),u.props.value):r.__},exports.useDebugValue=function(n,t){o.options.useDebugValue&&o.options.useDebugValue(t?t(n):n)},exports.useErrorBoundary=function(r){var u=l(n++,10),o=x();return u.__=r,t.componentDidCatch||(t.componentDidCatch=function(n){u.__&&u.__(n),o[1](n)}),[o[0],function(){o[1](void 0)}]};
|
||||||
|
//# sourceMappingURL=hooks.js.map
|
1
static/js/lib/preact/hooks.js.map
Normal file
1
static/js/lib/preact/hooks.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/hooks.mjs
Normal file
2
static/js/lib/preact/hooks.mjs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import{options as n}from"preact";var t,r,u,i,o=0,c=[],f=[],e=n.__b,a=n.__r,v=n.diffed,l=n.__c,m=n.unmount;function d(t,u){n.__h&&n.__h(r,t,o||u),o=0;var i=r.__H||(r.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:f}),i.__[t]}function p(n){return o=1,y(z,n)}function y(n,u,i){var o=d(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):z(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.u)){r.u=!0;var c=r.shouldComponentUpdate;r.shouldComponentUpdate=function(n,t,r){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return!n.__N}))return!c||c.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),!!i&&(!c||c.call(this,n,t,r))}}return o.__N||o.__}function h(u,i){var o=d(t++,3);!n.__s&&w(o.__H,i)&&(o.__=u,o.i=i,r.__H.__h.push(o))}function s(u,i){var o=d(t++,4);!n.__s&&w(o.__H,i)&&(o.__=u,o.i=i,r.__h.push(o))}function _(n){return o=5,F(function(){return{current:n}},[])}function A(n,t,r){o=6,s(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==r?r:r.concat(n))}function F(n,r){var u=d(t++,7);return w(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function T(n,t){return o=8,F(function(){return n},t)}function q(n){var u=r.context[n.__c],i=d(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function x(t,r){n.useDebugValue&&n.useDebugValue(r?r(t):t)}function V(n){var u=d(t++,10),i=p();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n){u.__&&u.__(n),i[1](n)}),[i[0],function(){i[1](void 0)}]}function b(){for(var t;t=c.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(j),t.__H.__h.forEach(k),t.__H.__h=[]}catch(r){t.__H.__h=[],n.__e(r,t.__v)}}n.__b=function(n){r=null,e&&e(n)},n.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=f,n.__N=n.i=void 0})):(i.__h.forEach(j),i.__h.forEach(k),i.__h=[])),u=r},n.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==c.push(o)&&i===n.requestAnimationFrame||((i=n.requestAnimationFrame)||function(n){var t,r=function(){clearTimeout(u),g&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,100);g&&(t=requestAnimationFrame(r))})(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==f&&(n.__=n.__V),n.i=void 0,n.__V=f})),u=r=null},n.__c=function(t,r){r.some(function(t){try{t.__h.forEach(j),t.__h=t.__h.filter(function(n){return!n.__||k(n)})}catch(u){r.some(function(n){n.__h&&(n.__h=[])}),r=[],n.__e(u,t.__v)}}),l&&l(t,r)},n.unmount=function(t){m&&m(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{j(n)}catch(n){r=n}}),r&&n.__e(r,u.__v))};var g="function"==typeof requestAnimationFrame;function j(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t}function k(n){var t=r;n.__c=n.__(),r=t}function w(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function z(n,t){return"function"==typeof t?t(n):t}export{p as useState,y as useReducer,h as useEffect,s as useLayoutEffect,_ as useRef,A as useImperativeHandle,F as useMemo,T as useCallback,q as useContext,x as useDebugValue,V as useErrorBoundary};
|
||||||
|
//# sourceMappingURL=hooks.module.js.map
|
2
static/js/lib/preact/hooks.module.js
Normal file
2
static/js/lib/preact/hooks.module.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import{options as n}from"preact";var t,r,u,i,o=0,c=[],f=[],e=n.__b,a=n.__r,v=n.diffed,l=n.__c,m=n.unmount;function d(t,u){n.__h&&n.__h(r,t,o||u),o=0;var i=r.__H||(r.__H={__:[],__h:[]});return t>=i.__.length&&i.__.push({__V:f}),i.__[t]}function p(n){return o=1,y(z,n)}function y(n,u,i){var o=d(t++,2);if(o.t=n,!o.__c&&(o.__=[i?i(u):z(void 0,u),function(n){var t=o.__N?o.__N[0]:o.__[0],r=o.t(t,n);t!==r&&(o.__N=[r,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.u)){r.u=!0;var c=r.shouldComponentUpdate;r.shouldComponentUpdate=function(n,t,r){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(n){return n.__c});if(u.every(function(n){return!n.__N}))return!c||c.call(this,n,t,r);var i=!1;return u.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),!!i&&(!c||c.call(this,n,t,r))}}return o.__N||o.__}function h(u,i){var o=d(t++,3);!n.__s&&w(o.__H,i)&&(o.__=u,o.i=i,r.__H.__h.push(o))}function s(u,i){var o=d(t++,4);!n.__s&&w(o.__H,i)&&(o.__=u,o.i=i,r.__h.push(o))}function _(n){return o=5,F(function(){return{current:n}},[])}function A(n,t,r){o=6,s(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==r?r:r.concat(n))}function F(n,r){var u=d(t++,7);return w(u.__H,r)?(u.__V=n(),u.i=r,u.__h=n,u.__V):u.__}function T(n,t){return o=8,F(function(){return n},t)}function q(n){var u=r.context[n.__c],i=d(t++,9);return i.c=n,u?(null==i.__&&(i.__=!0,u.sub(r)),u.props.value):n.__}function x(t,r){n.useDebugValue&&n.useDebugValue(r?r(t):t)}function V(n){var u=d(t++,10),i=p();return u.__=n,r.componentDidCatch||(r.componentDidCatch=function(n){u.__&&u.__(n),i[1](n)}),[i[0],function(){i[1](void 0)}]}function b(){for(var t;t=c.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(j),t.__H.__h.forEach(k),t.__H.__h=[]}catch(r){t.__H.__h=[],n.__e(r,t.__v)}}n.__b=function(n){r=null,e&&e(n)},n.__r=function(n){a&&a(n),t=0;var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=f,n.__N=n.i=void 0})):(i.__h.forEach(j),i.__h.forEach(k),i.__h=[])),u=r},n.diffed=function(t){v&&v(t);var o=t.__c;o&&o.__H&&(o.__H.__h.length&&(1!==c.push(o)&&i===n.requestAnimationFrame||((i=n.requestAnimationFrame)||function(n){var t,r=function(){clearTimeout(u),g&&cancelAnimationFrame(t),setTimeout(n)},u=setTimeout(r,100);g&&(t=requestAnimationFrame(r))})(b)),o.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==f&&(n.__=n.__V),n.i=void 0,n.__V=f})),u=r=null},n.__c=function(t,r){r.some(function(t){try{t.__h.forEach(j),t.__h=t.__h.filter(function(n){return!n.__||k(n)})}catch(u){r.some(function(n){n.__h&&(n.__h=[])}),r=[],n.__e(u,t.__v)}}),l&&l(t,r)},n.unmount=function(t){m&&m(t);var r,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{j(n)}catch(n){r=n}}),r&&n.__e(r,u.__v))};var g="function"==typeof requestAnimationFrame;function j(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t}function k(n){var t=r;n.__c=n.__(),r=t}function w(n,t){return!n||n.length!==t.length||t.some(function(t,r){return t!==n[r]})}function z(n,t){return"function"==typeof t?t(n):t}export{p as useState,y as useReducer,h as useEffect,s as useLayoutEffect,_ as useRef,A as useImperativeHandle,F as useMemo,T as useCallback,q as useContext,x as useDebugValue,V as useErrorBoundary};
|
||||||
|
//# sourceMappingURL=hooks.module.js.map
|
1
static/js/lib/preact/hooks.module.js.map
Normal file
1
static/js/lib/preact/hooks.module.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/hooks.umd.js
Normal file
2
static/js/lib/preact/hooks.umd.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("preact")):"function"==typeof define&&define.amd?define(["exports","preact"],t):t(n.preactHooks={},n.preact)}(this,function(n,t){var u,r,i,o,f=0,c=[],e=[],a=t.options.__b,v=t.options.__r,l=t.options.diffed,d=t.options.__c,p=t.options.unmount;function m(n,u){t.options.__h&&t.options.__h(r,n,f||u),f=0;var i=r.__H||(r.__H={__:[],__h:[]});return n>=i.__.length&&i.__.push({__V:e}),i.__[n]}function s(n){return f=1,y(b,n)}function y(n,t,i){var o=m(u++,2);if(o.t=n,!o.__c&&(o.__=[i?i(t):b(void 0,t),function(n){var t=o.__N?o.__N[0]:o.__[0],u=o.t(t,n);t!==u&&(o.__N=[u,o.__[1]],o.__c.setState({}))}],o.__c=r,!r.u)){r.u=!0;var f=r.shouldComponentUpdate;r.shouldComponentUpdate=function(n,t,u){if(!o.__c.__H)return!0;var r=o.__c.__H.__.filter(function(n){return n.__c});if(r.every(function(n){return!n.__N}))return!f||f.call(this,n,t,u);var i=!1;return r.forEach(function(n){if(n.__N){var t=n.__[0];n.__=n.__N,n.__N=void 0,t!==n.__[0]&&(i=!0)}}),!!i&&(!f||f.call(this,n,t,u))}}return o.__N||o.__}function h(n,i){var o=m(u++,4);!t.options.__s&&T(o.__H,i)&&(o.__=n,o.i=i,r.__h.push(o))}function _(n,t){var r=m(u++,7);return T(r.__H,t)?(r.__V=n(),r.i=t,r.__h=n,r.__V):r.__}function q(){for(var n;n=c.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(A),n.__H.__h.forEach(F),n.__H.__h=[]}catch(u){n.__H.__h=[],t.options.__e(u,n.__v)}}t.options.__b=function(n){r=null,a&&a(n)},t.options.__r=function(n){v&&v(n),u=0;var t=(r=n.__c).__H;t&&(i===r?(t.__h=[],r.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=e,n.__N=n.i=void 0})):(t.__h.forEach(A),t.__h.forEach(F),t.__h=[])),i=r},t.options.diffed=function(n){l&&l(n);var u=n.__c;u&&u.__H&&(u.__H.__h.length&&(1!==c.push(u)&&o===t.options.requestAnimationFrame||((o=t.options.requestAnimationFrame)||function(n){var t,u=function(){clearTimeout(r),x&&cancelAnimationFrame(t),setTimeout(n)},r=setTimeout(u,100);x&&(t=requestAnimationFrame(u))})(q)),u.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==e&&(n.__=n.__V),n.i=void 0,n.__V=e})),i=r=null},t.options.__c=function(n,u){u.some(function(n){try{n.__h.forEach(A),n.__h=n.__h.filter(function(n){return!n.__||F(n)})}catch(r){u.some(function(n){n.__h&&(n.__h=[])}),u=[],t.options.__e(r,n.__v)}}),d&&d(n,u)},t.options.unmount=function(n){p&&p(n);var u,r=n.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{A(n)}catch(n){u=n}}),u&&t.options.__e(u,r.__v))};var x="function"==typeof requestAnimationFrame;function A(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t}function F(n){var t=r;n.__c=n.__(),r=t}function T(n,t){return!n||n.length!==t.length||t.some(function(t,u){return t!==n[u]})}function b(n,t){return"function"==typeof t?t(n):t}n.useState=s,n.useReducer=y,n.useEffect=function(n,i){var o=m(u++,3);!t.options.__s&&T(o.__H,i)&&(o.__=n,o.i=i,r.__H.__h.push(o))},n.useLayoutEffect=h,n.useRef=function(n){return f=5,_(function(){return{current:n}},[])},n.useImperativeHandle=function(n,t,u){f=6,h(function(){return"function"==typeof n?(n(t()),function(){return n(null)}):n?(n.current=t(),function(){return n.current=null}):void 0},null==u?u:u.concat(n))},n.useMemo=_,n.useCallback=function(n,t){return f=8,_(function(){return n},t)},n.useContext=function(n){var t=r.context[n.__c],i=m(u++,9);return i.c=n,t?(null==i.__&&(i.__=!0,t.sub(r)),t.props.value):n.__},n.useDebugValue=function(n,u){t.options.useDebugValue&&t.options.useDebugValue(u?u(n):n)},n.useErrorBoundary=function(n){var t=m(u++,10),i=s();return t.__=n,r.componentDidCatch||(r.componentDidCatch=function(n){t.__&&t.__(n),i[1](n)}),[i[0],function(){i[1](void 0)}]}});
|
||||||
|
//# sourceMappingURL=hooks.umd.js.map
|
1
static/js/lib/preact/hooks.umd.js.map
Normal file
1
static/js/lib/preact/hooks.umd.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/preact.js
Normal file
2
static/js/lib/preact/preact.js
Normal file
File diff suppressed because one or more lines are too long
1
static/js/lib/preact/preact.js.map
Normal file
1
static/js/lib/preact/preact.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/preact.min.js
vendored
Normal file
2
static/js/lib/preact/preact.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
static/js/lib/preact/preact.min.js.map
Normal file
1
static/js/lib/preact/preact.min.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/preact.min.module.js
Normal file
2
static/js/lib/preact/preact.min.module.js
Normal file
File diff suppressed because one or more lines are too long
1
static/js/lib/preact/preact.min.module.js.map
Normal file
1
static/js/lib/preact/preact.min.module.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/preact.min.umd.js
Normal file
2
static/js/lib/preact/preact.min.umd.js
Normal file
File diff suppressed because one or more lines are too long
1
static/js/lib/preact/preact.min.umd.js.map
Normal file
1
static/js/lib/preact/preact.min.umd.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/preact.mjs
Normal file
2
static/js/lib/preact/preact.mjs
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/preact.module.js
Normal file
2
static/js/lib/preact/preact.module.js
Normal file
File diff suppressed because one or more lines are too long
1
static/js/lib/preact/preact.module.js.map
Normal file
1
static/js/lib/preact/preact.module.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/preact/preact.umd.js
Normal file
2
static/js/lib/preact/preact.umd.js
Normal file
File diff suppressed because one or more lines are too long
1
static/js/lib/preact/preact.umd.js.map
Normal file
1
static/js/lib/preact/preact.umd.js.map
Normal file
File diff suppressed because one or more lines are too long
17
static/js/lib/signals/signals-core.d.ts
vendored
Normal file
17
static/js/lib/signals/signals-core.d.ts
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
declare function batch<T>(callback: () => T): T;
|
||||||
|
declare class Signal<T = any> {
|
||||||
|
constructor(value?: T);
|
||||||
|
subscribe(fn: (value: T) => void): () => void;
|
||||||
|
valueOf(): T;
|
||||||
|
toString(): string;
|
||||||
|
peek(): T;
|
||||||
|
get value(): T;
|
||||||
|
set value(value: T);
|
||||||
|
}
|
||||||
|
declare function signal<T>(value: T): Signal<T>;
|
||||||
|
interface ReadonlySignal<T = any> extends Signal<T> {
|
||||||
|
readonly value: T;
|
||||||
|
}
|
||||||
|
declare function computed<T>(compute: () => T): ReadonlySignal<T>;
|
||||||
|
declare function effect(compute: () => unknown): () => void;
|
||||||
|
export { signal, computed, effect, batch, Signal, ReadonlySignal };
|
2
static/js/lib/signals/signals-core.js
Normal file
2
static/js/lib/signals/signals-core.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
function i(){throw new Error("Cycle detected")}var t=1,h=2,o=4,r=8,s=32;function n(){if(!(e>1)){var i,t=!1;while(void 0!==v){var o=v;v=void 0;u++;while(void 0!==o){var s=o.o;o.o=void 0;o.f&=~h;if(!(o.f&r)&&l(o))try{o.c()}catch(h){if(!t){i=h;t=!0}}o=s}}u=0;e--;if(t)throw i}else e--}var f=void 0,v=void 0,e=0,u=0,d=0;function c(i){if(void 0!==f){var t=i.n;if(void 0===t||t.t!==f){f.s=t={i:0,S:i,p:void 0,n:f.s,t:f,e:void 0,x:void 0,r:t};i.n=t;if(f.f&s)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.p){t.p.n=t.n;if(void 0!==t.n)t.n.p=t.p;t.p=void 0;t.n=f.s;f.s.p=t;f.s=t}return t}}}function a(i){this.v=i;this.i=0;this.n=void 0;this.t=void 0}a.prototype.h=function(){return!0};a.prototype.S=function(i){if(this.t!==i&&void 0===i.e){i.x=this.t;if(void 0!==this.t)this.t.e=i;this.t=i}};a.prototype.U=function(i){var t=i.e,h=i.x;if(void 0!==t){t.x=h;i.e=void 0}if(void 0!==h){h.e=t;i.x=void 0}if(i===this.t)this.t=h};a.prototype.subscribe=function(i){var t=this;return O(function(){var h=t.value,o=this.f&s;this.f&=~s;try{i(h)}finally{this.f|=o}})};a.prototype.valueOf=function(){return this.value};a.prototype.toString=function(){return this.value+""};a.prototype.peek=function(){return this.v};Object.defineProperty(a.prototype,"value",{get:function(){var i=c(this);if(void 0!==i)i.i=this.i;return this.v},set:function(t){if(t!==this.v){if(u>100)i();this.v=t;this.i++;d++;e++;try{for(var h=this.t;void 0!==h;h=h.x)h.t.N()}finally{n()}}}});function l(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function w(i){for(var t=i.s;void 0!==t;t=t.n){var h=t.S.n;if(void 0!==h)t.r=h;t.S.n=t;t.i=-1}}function y(i){var t=i.s,h=void 0;while(void 0!==t){var o=t.n;if(-1===t.i){t.S.U(t);t.n=void 0}else{if(void 0!==h)h.p=t;t.p=void 0;t.n=h;h=t}t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o}i.s=h}function p(i){a.call(this,void 0);this.x=i;this.s=void 0;this.g=d-1;this.f=o}(p.prototype=new a).h=function(){this.f&=~h;if(this.f&t)return!1;if((this.f&(o|s))===s)return!0;this.f&=~o;if(this.g===d)return!0;this.g=d;this.f|=t;if(this.i>0&&!l(this)){this.f&=~t;return!0}var i=f;try{w(this);f=this;var r=this.x();if(16&this.f||this.v!==r||0===this.i){this.v=r;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}f=i;y(this);this.f&=~t;return!0};p.prototype.S=function(i){if(void 0===this.t){this.f|=o|s;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}a.prototype.S.call(this,i)};p.prototype.U=function(i){a.prototype.U.call(this,i);if(void 0===this.t){this.f&=~s;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}};p.prototype.N=function(){if(!(this.f&h)){this.f|=o|h;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};p.prototype.peek=function(){if(!this.h())i();if(16&this.f)throw this.v;return this.v};Object.defineProperty(p.prototype,"value",{get:function(){if(this.f&t)i();var h=c(this);this.h();if(void 0!==h)h.i=this.i;if(16&this.f)throw this.v;return this.v}});function _(i){var h=i.u;i.u=void 0;if("function"==typeof h){e++;var o=f;f=void 0;try{h()}catch(h){i.f&=~t;i.f|=r;x(i);throw h}finally{f=o;n()}}}function x(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;_(i)}function g(i){if(f!==this)throw new Error("Out-of-order effect");y(this);f=i;this.f&=~t;if(this.f&r)x(this);n()}function b(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=s}b.prototype.c=function(){var i=this.S();try{if(!(this.f&r)&&void 0!==this.x)this.u=this.x()}finally{i()}};b.prototype.S=function(){if(this.f&t)i();this.f|=t;this.f&=~r;_(this);w(this);e++;var h=f;f=this;return g.bind(this,h)};b.prototype.N=function(){if(!(this.f&h)){this.f|=h;this.o=v;v=this}};b.prototype.d=function(){this.f|=r;if(!(this.f&t))x(this)};function O(i){var t=new b(i);t.c();return t.d.bind(t)}exports.Signal=a;exports.batch=function(i){if(e>0)return i();e++;try{return i()}finally{n()}};exports.computed=function(i){return new p(i)};exports.effect=O;exports.signal=function(i){return new a(i)};
|
||||||
|
//# sourceMappingURL=signals-core.js.map
|
1
static/js/lib/signals/signals-core.js.map
Normal file
1
static/js/lib/signals/signals-core.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/signals/signals-core.min.js
vendored
Normal file
2
static/js/lib/signals/signals-core.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
!function(i,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((i||self).preactSignalsCore={})}(this,function(i){function t(){throw new Error("Cycle detected")}var o=1,n=2,h=4,s=8,r=32;function f(){if(!(u>1)){var i,t=!1;while(void 0!==v){var o=v;v=void 0;d++;while(void 0!==o){var h=o.o;o.o=void 0;o.f&=~n;if(!(o.f&s)&&y(o))try{o.c()}catch(o){if(!t){i=o;t=!0}}o=h}}d=0;u--;if(t)throw i}else u--}var e=void 0,v=void 0,u=0,d=0,c=0;function a(i){if(void 0!==e){var t=i.n;if(void 0===t||t.t!==e){e.s=t={i:0,S:i,p:void 0,n:e.s,t:e,e:void 0,x:void 0,r:t};i.n=t;if(e.f&r)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.p){t.p.n=t.n;if(void 0!==t.n)t.n.p=t.p;t.p=void 0;t.n=e.s;e.s.p=t;e.s=t}return t}}}function l(i){this.v=i;this.i=0;this.n=void 0;this.t=void 0}l.prototype.h=function(){return!0};l.prototype.S=function(i){if(this.t!==i&&void 0===i.e){i.x=this.t;if(void 0!==this.t)this.t.e=i;this.t=i}};l.prototype.U=function(i){var t=i.e,o=i.x;if(void 0!==t){t.x=o;i.e=void 0}if(void 0!==o){o.e=t;i.x=void 0}if(i===this.t)this.t=o};l.prototype.subscribe=function(i){var t=this;return j(function(){var o=t.value,n=this.f&r;this.f&=~r;try{i(o)}finally{this.f|=n}})};l.prototype.valueOf=function(){return this.value};l.prototype.toString=function(){return this.value+""};l.prototype.peek=function(){return this.v};Object.defineProperty(l.prototype,"value",{get:function(){var i=a(this);if(void 0!==i)i.i=this.i;return this.v},set:function(i){if(i!==this.v){if(d>100)t();this.v=i;this.i++;c++;u++;try{for(var o=this.t;void 0!==o;o=o.x)o.t.N()}finally{f()}}}});function y(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function w(i){for(var t=i.s;void 0!==t;t=t.n){var o=t.S.n;if(void 0!==o)t.r=o;t.S.n=t;t.i=-1}}function p(i){var t=i.s,o=void 0;while(void 0!==t){var n=t.n;if(-1===t.i){t.S.U(t);t.n=void 0}else{if(void 0!==o)o.p=t;t.p=void 0;t.n=o;o=t}t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=n}i.s=o}function _(i){l.call(this,void 0);this.x=i;this.s=void 0;this.g=c-1;this.f=h}(_.prototype=new l).h=function(){this.f&=~n;if(this.f&o)return!1;if((this.f&(h|r))===r)return!0;this.f&=~h;if(this.g===c)return!0;this.g=c;this.f|=o;if(this.i>0&&!y(this)){this.f&=~o;return!0}var i=e;try{w(this);e=this;var t=this.x();if(16&this.f||this.v!==t||0===this.i){this.v=t;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}e=i;p(this);this.f&=~o;return!0};_.prototype.S=function(i){if(void 0===this.t){this.f|=h|r;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}l.prototype.S.call(this,i)};_.prototype.U=function(i){l.prototype.U.call(this,i);if(void 0===this.t){this.f&=~r;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}};_.prototype.N=function(){if(!(this.f&n)){this.f|=h|n;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};_.prototype.peek=function(){if(!this.h())t();if(16&this.f)throw this.v;return this.v};Object.defineProperty(_.prototype,"value",{get:function(){if(this.f&o)t();var i=a(this);this.h();if(void 0!==i)i.i=this.i;if(16&this.f)throw this.v;return this.v}});function g(i){var t=i.u;i.u=void 0;if("function"==typeof t){u++;var n=e;e=void 0;try{t()}catch(t){i.f&=~o;i.f|=s;b(i);throw t}finally{e=n;f()}}}function b(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;g(i)}function x(i){if(e!==this)throw new Error("Out-of-order effect");p(this);e=i;this.f&=~o;if(this.f&s)b(this);f()}function T(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=r}T.prototype.c=function(){var i=this.S();try{if(!(this.f&s)&&void 0!==this.x)this.u=this.x()}finally{i()}};T.prototype.S=function(){if(this.f&o)t();this.f|=o;this.f&=~s;g(this);w(this);u++;var i=e;e=this;return x.bind(this,i)};T.prototype.N=function(){if(!(this.f&n)){this.f|=n;this.o=v;v=this}};T.prototype.d=function(){this.f|=s;if(!(this.f&o))b(this)};function j(i){var t=new T(i);t.c();return t.d.bind(t)}i.Signal=l;i.batch=function(i){if(u>0)return i();u++;try{return i()}finally{f()}};i.computed=function(i){return new _(i)};i.effect=j;i.signal=function(i){return new l(i)}});
|
||||||
|
//# sourceMappingURL=signals-core.min.js.map
|
1
static/js/lib/signals/signals-core.min.js.map
Normal file
1
static/js/lib/signals/signals-core.min.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/signals/signals-core.mjs
Normal file
2
static/js/lib/signals/signals-core.mjs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
function i(){throw new Error("Cycle detected")}const t=1,s=2,n=4,o=8,h=32;function f(){if(u>1){u--;return}let i,t=!1;while(void 0!==c){let n=c;c=void 0;v++;while(void 0!==n){const h=n.o;n.o=void 0;n.f&=~s;if(!(n.f&o)&&y(n))try{n.c()}catch(s){if(!t){i=s;t=!0}}n=h}}v=0;u--;if(t)throw i}function r(i){if(u>0)return i();u++;try{return i()}finally{f()}}let e,c,u=0,v=0,d=0;function l(i){if(void 0===e)return;let t=i.n;if(void 0===t||t.t!==e){t={i:0,S:i,p:void 0,n:e.s,t:e,e:void 0,x:void 0,r:t};e.s=t;i.n=t;if(e.f&h)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.p){t.p.n=t.n;if(void 0!==t.n)t.n.p=t.p;t.p=void 0;t.n=e.s;e.s.p=t;e.s=t}return t}}function w(i){this.v=i;this.i=0;this.n=void 0;this.t=void 0}w.prototype.h=function(){return!0};w.prototype.S=function(i){if(this.t!==i&&void 0===i.e){i.x=this.t;if(void 0!==this.t)this.t.e=i;this.t=i}};w.prototype.U=function(i){const t=i.e,s=i.x;if(void 0!==t){t.x=s;i.e=void 0}if(void 0!==s){s.e=t;i.x=void 0}if(i===this.t)this.t=s};w.prototype.subscribe=function(i){const t=this;return S(function(){const s=t.value,n=this.f&h;this.f&=~h;try{i(s)}finally{this.f|=n}})};w.prototype.valueOf=function(){return this.value};w.prototype.toString=function(){return this.value+""};w.prototype.peek=function(){return this.v};Object.defineProperty(w.prototype,"value",{get(){const i=l(this);if(void 0!==i)i.i=this.i;return this.v},set(t){if(t!==this.v){if(v>100)i();this.v=t;this.i++;d++;u++;try{for(let i=this.t;void 0!==i;i=i.x)i.t.N()}finally{f()}}}});function a(i){return new w(i)}function y(i){for(let t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function _(i){for(let t=i.s;void 0!==t;t=t.n){const i=t.S.n;if(void 0!==i)t.r=i;t.S.n=t;t.i=-1}}function g(i){let t,s=i.s;while(void 0!==s){const i=s.n;if(-1===s.i){s.S.U(s);s.n=void 0}else{if(void 0!==t)t.p=s;s.p=void 0;s.n=t;t=s}s.S.n=s.r;if(void 0!==s.r)s.r=void 0;s=i}i.s=t}function p(i){w.call(this,void 0);this.x=i;this.s=void 0;this.g=d-1;this.f=n}(p.prototype=new w).h=function(){this.f&=~s;if(this.f&t)return!1;if((this.f&(n|h))===h)return!0;this.f&=~n;if(this.g===d)return!0;this.g=d;this.f|=t;if(this.i>0&&!y(this)){this.f&=~t;return!0}const i=e;try{_(this);e=this;const i=this.x();if(16&this.f||this.v!==i||0===this.i){this.v=i;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}e=i;g(this);this.f&=~t;return!0};p.prototype.S=function(i){if(void 0===this.t){this.f|=n|h;for(let i=this.s;void 0!==i;i=i.n)i.S.S(i)}w.prototype.S.call(this,i)};p.prototype.U=function(i){w.prototype.U.call(this,i);if(void 0===this.t){this.f&=~h;for(let i=this.s;void 0!==i;i=i.n)i.S.U(i)}};p.prototype.N=function(){if(!(this.f&s)){this.f|=n|s;for(let i=this.t;void 0!==i;i=i.x)i.t.N()}};p.prototype.peek=function(){if(!this.h())i();if(16&this.f)throw this.v;return this.v};Object.defineProperty(p.prototype,"value",{get(){if(this.f&t)i();const s=l(this);this.h();if(void 0!==s)s.i=this.i;if(16&this.f)throw this.v;return this.v}});function b(i){return new p(i)}function x(i){const s=i.u;i.u=void 0;if("function"==typeof s){u++;const n=e;e=void 0;try{s()}catch(s){i.f&=~t;i.f|=o;O(i);throw s}finally{e=n;f()}}}function O(i){for(let t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;x(i)}function j(i){if(e!==this)throw new Error("Out-of-order effect");g(this);e=i;this.f&=~t;if(this.f&o)O(this);f()}function E(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=h}E.prototype.c=function(){const i=this.S();try{if(!(this.f&o)&&void 0!==this.x)this.u=this.x()}finally{i()}};E.prototype.S=function(){if(this.f&t)i();this.f|=t;this.f&=~o;x(this);_(this);u++;const s=e;e=this;return j.bind(this,s)};E.prototype.N=function(){if(!(this.f&s)){this.f|=s;this.o=c;c=this}};E.prototype.d=function(){this.f|=o;if(!(this.f&t))O(this)};function S(i){const t=new E(i);t.c();return t.d.bind(t)}export{w as Signal,r as batch,b as computed,S as effect,a as signal};
|
||||||
|
//# sourceMappingURL=signals-core.mjs.map
|
1
static/js/lib/signals/signals-core.mjs.map
Normal file
1
static/js/lib/signals/signals-core.mjs.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/signals/signals-core.module.js
Normal file
2
static/js/lib/signals/signals-core.module.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
function i(){throw new Error("Cycle detected")}var t=1,h=2,o=4,r=8,n=32;function s(){if(!(u>1)){var i,t=!1;while(void 0!==e){var o=e;e=void 0;d++;while(void 0!==o){var n=o.o;o.o=void 0;o.f&=~h;if(!(o.f&r)&&y(o))try{o.c()}catch(h){if(!t){i=h;t=!0}}o=n}}d=0;u--;if(t)throw i}else u--}function f(i){if(u>0)return i();u++;try{return i()}finally{s()}}var v=void 0,e=void 0,u=0,d=0,c=0;function a(i){if(void 0!==v){var t=i.n;if(void 0===t||t.t!==v){v.s=t={i:0,S:i,p:void 0,n:v.s,t:v,e:void 0,x:void 0,r:t};i.n=t;if(v.f&n)i.S(t);return t}else if(-1===t.i){t.i=0;if(void 0!==t.p){t.p.n=t.n;if(void 0!==t.n)t.n.p=t.p;t.p=void 0;t.n=v.s;v.s.p=t;v.s=t}return t}}}function l(i){this.v=i;this.i=0;this.n=void 0;this.t=void 0}l.prototype.h=function(){return!0};l.prototype.S=function(i){if(this.t!==i&&void 0===i.e){i.x=this.t;if(void 0!==this.t)this.t.e=i;this.t=i}};l.prototype.U=function(i){var t=i.e,h=i.x;if(void 0!==t){t.x=h;i.e=void 0}if(void 0!==h){h.e=t;i.x=void 0}if(i===this.t)this.t=h};l.prototype.subscribe=function(i){var t=this;return S(function(){var h=t.value,o=this.f&n;this.f&=~n;try{i(h)}finally{this.f|=o}})};l.prototype.valueOf=function(){return this.value};l.prototype.toString=function(){return this.value+""};l.prototype.peek=function(){return this.v};Object.defineProperty(l.prototype,"value",{get:function(){var i=a(this);if(void 0!==i)i.i=this.i;return this.v},set:function(t){if(t!==this.v){if(d>100)i();this.v=t;this.i++;c++;u++;try{for(var h=this.t;void 0!==h;h=h.x)h.t.N()}finally{s()}}}});function w(i){return new l(i)}function y(i){for(var t=i.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function _(i){for(var t=i.s;void 0!==t;t=t.n){var h=t.S.n;if(void 0!==h)t.r=h;t.S.n=t;t.i=-1}}function g(i){var t=i.s,h=void 0;while(void 0!==t){var o=t.n;if(-1===t.i){t.S.U(t);t.n=void 0}else{if(void 0!==h)h.p=t;t.p=void 0;t.n=h;h=t}t.S.n=t.r;if(void 0!==t.r)t.r=void 0;t=o}i.s=h}function p(i){l.call(this,void 0);this.x=i;this.s=void 0;this.g=c-1;this.f=o}(p.prototype=new l).h=function(){this.f&=~h;if(this.f&t)return!1;if((this.f&(o|n))===n)return!0;this.f&=~o;if(this.g===c)return!0;this.g=c;this.f|=t;if(this.i>0&&!y(this)){this.f&=~t;return!0}var i=v;try{_(this);v=this;var r=this.x();if(16&this.f||this.v!==r||0===this.i){this.v=r;this.f&=-17;this.i++}}catch(i){this.v=i;this.f|=16;this.i++}v=i;g(this);this.f&=~t;return!0};p.prototype.S=function(i){if(void 0===this.t){this.f|=o|n;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}l.prototype.S.call(this,i)};p.prototype.U=function(i){l.prototype.U.call(this,i);if(void 0===this.t){this.f&=~n;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}};p.prototype.N=function(){if(!(this.f&h)){this.f|=o|h;for(var i=this.t;void 0!==i;i=i.x)i.t.N()}};p.prototype.peek=function(){if(!this.h())i();if(16&this.f)throw this.v;return this.v};Object.defineProperty(p.prototype,"value",{get:function(){if(this.f&t)i();var h=a(this);this.h();if(void 0!==h)h.i=this.i;if(16&this.f)throw this.v;return this.v}});function b(i){return new p(i)}function x(i){var h=i.u;i.u=void 0;if("function"==typeof h){u++;var o=v;v=void 0;try{h()}catch(h){i.f&=~t;i.f|=r;O(i);throw h}finally{v=o;s()}}}function O(i){for(var t=i.s;void 0!==t;t=t.n)t.S.U(t);i.x=void 0;i.s=void 0;x(i)}function j(i){if(v!==this)throw new Error("Out-of-order effect");g(this);v=i;this.f&=~t;if(this.f&r)O(this);s()}function E(i){this.x=i;this.u=void 0;this.s=void 0;this.o=void 0;this.f=n}E.prototype.c=function(){var i=this.S();try{if(!(this.f&r)&&void 0!==this.x)this.u=this.x()}finally{i()}};E.prototype.S=function(){if(this.f&t)i();this.f|=t;this.f&=~r;x(this);_(this);u++;var h=v;v=this;return j.bind(this,h)};E.prototype.N=function(){if(!(this.f&h)){this.f|=h;this.o=e;e=this}};E.prototype.d=function(){this.f|=r;if(!(this.f&t))O(this)};function S(i){var t=new E(i);t.c();return t.d.bind(t)}export{l as Signal,f as batch,b as computed,S as effect,w as signal};
|
||||||
|
//# sourceMappingURL=signals-core.module.js.map
|
1
static/js/lib/signals/signals-core.module.js.map
Normal file
1
static/js/lib/signals/signals-core.module.js.map
Normal file
File diff suppressed because one or more lines are too long
40
static/js/lib/signals/signals.d.ts
vendored
Normal file
40
static/js/lib/signals/signals.d.ts
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import { signal, computed, batch, effect, Signal, type ReadonlySignal } from "@preact/signals-core";
|
||||||
|
export { signal, computed, batch, effect, Signal, type ReadonlySignal };
|
||||||
|
export declare function useSignal<T>(value: T): Signal<T>;
|
||||||
|
export declare function useComputed<T>(compute: () => T): ReadonlySignal<T>;
|
||||||
|
export declare function useSignalEffect(cb: () => void | (() => void)): void;
|
||||||
|
/**
|
||||||
|
* @todo Determine which Reactive implementation we'll be using.
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* Update a Reactive's using the properties of an object or other Reactive.
|
||||||
|
* Also works for Signals.
|
||||||
|
* @example
|
||||||
|
* // Update a Reactive with Object.assign()-like syntax:
|
||||||
|
* const r = reactive({ name: "Alice" });
|
||||||
|
* update(r, { name: "Bob" });
|
||||||
|
* update(r, { age: 42 }); // property 'age' does not exist in type '{ name?: string }'
|
||||||
|
* update(r, 2); // '2' has no properties in common with '{ name?: string }'
|
||||||
|
* console.log(r.name.value); // "Bob"
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Update a Reactive with the properties of another Reactive:
|
||||||
|
* const A = reactive({ name: "Alice" });
|
||||||
|
* const B = reactive({ name: "Bob", age: 42 });
|
||||||
|
* update(A, B);
|
||||||
|
* console.log(`${A.name} is ${A.age}`); // "Bob is 42"
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* // Update a signal with assign()-like syntax:
|
||||||
|
* const s = signal(42);
|
||||||
|
* update(s, "hi"); // Argument type 'string' not assignable to type 'number'
|
||||||
|
* update(s, {}); // Argument type '{}' not assignable to type 'number'
|
||||||
|
* update(s, 43);
|
||||||
|
* console.log(s.value); // 43
|
||||||
|
*
|
||||||
|
* @param obj The Reactive or Signal to be updated
|
||||||
|
* @param update The value, Signal, object or Reactive to update `obj` to match
|
||||||
|
* @param overwrite If `true`, any properties `obj` missing from `update` are set to `undefined`
|
||||||
|
*/
|
2
static/js/lib/signals/signals.js
Normal file
2
static/js/lib/signals/signals.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var n,r,i=require("preact"),t=require("preact/hooks"),e=require("@preact/signals-core"),f=4;function u(n,r){i.options[n]=r.bind(null,i.options[n]||function(){})}function o(n){if(r)r();r=n&&n.S()}function c(n){var r=this,i=n.data,u=useSignal(i);u.value=i;var o=t.useMemo(function(){var n=r.__v;while(n=n.__)if(n.__c){n.__c.__$f|=f;break}r.__$u.c=function(){r.base.data=o.peek()};return e.computed(function(){var n=u.value.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}c.displayName="_st";Object.defineProperties(e.Signal.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:c},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});u("__b",function(n,r){if("string"==typeof r.type){var i,t=r.props;for(var f in t)if("children"!==f){var u=t[f];if(u instanceof e.Signal){if(!i)r.__np=i={};i[f]=u;t[f]=u.peek()}}}n(r)});u("__r",function(r,i){o();var t,f=i.__c;if(f){f.__$f&=-2;if(void 0===(t=f.__$u))f.__$u=t=function(n){var r;e.effect(function(){r=this});r.c=function(){f.__$f|=1;f.setState({})};return r}()}n=f;o(t);r(i)});u("__e",function(r,i,t,e){o();n=void 0;r(i,t,e)});u("diffed",function(r,i){o();n=void 0;var t;if("string"==typeof i.type&&(t=i.__e)){var e=i.__np,f=i.props;if(e){var u=t.U;if(u)for(var c in u){var v=u[c];if(void 0!==v&&!(c in e)){v.d();u[c]=void 0}}else t.U=u={};for(var s in e){var l=u[s],p=e[s];if(void 0===l){l=a(t,s,p,f);u[s]=l}else l.u(p,f)}}}r(i)});function a(n,r,i,t){var f=r in n&&void 0===n.ownerSVGElement,u=e.signal(i);return{u:function(n,r){u.value=n;t=r},d:e.effect(function(){var i=u.value.value;if(t[r]!==i){t[r]=i;if(f)n[r]=i;else if(i)n.setAttribute(r,i);else n.removeAttribute(r)}})}}u("unmount",function(n,r){if("string"==typeof r.type){var i=r.__e;if(i){var t=i.U;if(t){i.U=void 0;for(var e in t){var f=t[e];if(f)f.d()}}}}else{var u=r.__c;if(u){var o=u.__$u;if(o){u.__$u=void 0;o.d()}}}n(r)});u("__h",function(n,r,i,t){if(t<3)r.__$f|=2;n(r,i,t)});i.Component.prototype.shouldComponentUpdate=function(n,r){var i=this.__$u;if(!(i&&void 0!==i.s||this.__$f&f))return!0;if(3&this.__$f)return!0;for(var t in r)return!0;for(var e in n)if("__source"!==e&&n[e]!==this.props[e])return!0;for(var u in this.props)if(!(u in n))return!0;return!1};function useSignal(n){return t.useMemo(function(){return e.signal(n)},[])}Object.defineProperty(exports,"Signal",{enumerable:!0,get:function(){return e.Signal}});Object.defineProperty(exports,"batch",{enumerable:!0,get:function(){return e.batch}});Object.defineProperty(exports,"computed",{enumerable:!0,get:function(){return e.computed}});Object.defineProperty(exports,"effect",{enumerable:!0,get:function(){return e.effect}});Object.defineProperty(exports,"signal",{enumerable:!0,get:function(){return e.signal}});exports.useComputed=function(r){var i=t.useRef(r);i.current=r;n.__$f|=f;return t.useMemo(function(){return e.computed(function(){return i.current()})},[])};exports.useSignal=useSignal;exports.useSignalEffect=function(n){var r=t.useRef(n);r.current=n;t.useEffect(function(){return e.effect(function(){r.current()})},[])};
|
||||||
|
//# sourceMappingURL=signals.js.map
|
1
static/js/lib/signals/signals.js.map
Normal file
1
static/js/lib/signals/signals.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/signals/signals.min.js
vendored
Normal file
2
static/js/lib/signals/signals.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("preact"),require("preact/hooks"),require("@preact/signals-core")):"function"==typeof define&&define.amd?define(["exports","preact","preact/hooks","@preact/signals-core"],r):r((n||self).preactSignals={},n.preact,n.hooks,n.signalsCore)}(this,function(n,r,i,e){var t,f,o=4;function u(n,i){r.options[n]=i.bind(null,r.options[n]||function(){})}function c(n){if(f)f();f=n&&n.S()}function a(n){var r=this,t=n.data,f=useSignal(t);f.value=t;var u=i.useMemo(function(){var n=r.__v;while(n=n.__)if(n.__c){n.__c.__$f|=o;break}r.__$u.c=function(){r.base.data=u.peek()};return e.computed(function(){var n=f.value.value;return 0===n?0:!0===n?"":n||""})},[]);return u.value}a.displayName="_st";Object.defineProperties(e.Signal.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:a},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});u("__b",function(n,r){if("string"==typeof r.type){var i,t=r.props;for(var f in t)if("children"!==f){var o=t[f];if(o instanceof e.Signal){if(!i)r.__np=i={};i[f]=o;t[f]=o.peek()}}}n(r)});u("__r",function(n,r){c();var i,f=r.__c;if(f){f.__$f&=-2;if(void 0===(i=f.__$u))f.__$u=i=function(n){var r;e.effect(function(){r=this});r.c=function(){f.__$f|=1;f.setState({})};return r}()}t=f;c(i);n(r)});u("__e",function(n,r,i,e){c();t=void 0;n(r,i,e)});u("diffed",function(n,r){c();t=void 0;var i;if("string"==typeof r.type&&(i=r.__e)){var e=r.__np,f=r.props;if(e){var o=i.U;if(o)for(var u in o){var a=o[u];if(void 0!==a&&!(u in e)){a.d();o[u]=void 0}}else i.U=o={};for(var s in e){var l=o[s],d=e[s];if(void 0===l){l=v(i,s,d,f);o[s]=l}else l.o(d,f)}}}n(r)});function v(n,r,i,t){var f=r in n&&void 0===n.ownerSVGElement,o=e.signal(i);return{o:function(n,r){o.value=n;t=r},d:e.effect(function(){var i=o.value.value;if(t[r]!==i){t[r]=i;if(f)n[r]=i;else if(i)n.setAttribute(r,i);else n.removeAttribute(r)}})}}u("unmount",function(n,r){if("string"==typeof r.type){var i=r.__e;if(i){var e=i.U;if(e){i.U=void 0;for(var t in e){var f=e[t];if(f)f.d()}}}}else{var o=r.__c;if(o){var u=o.__$u;if(u){o.__$u=void 0;u.d()}}}n(r)});u("__h",function(n,r,i,e){if(e<3)r.__$f|=2;n(r,i,e)});r.Component.prototype.shouldComponentUpdate=function(n,r){var i=this.__$u;if(!(i&&void 0!==i.s||this.__$f&o))return!0;if(3&this.__$f)return!0;for(var e in r)return!0;for(var t in n)if("__source"!==t&&n[t]!==this.props[t])return!0;for(var f in this.props)if(!(f in n))return!0;return!1};function useSignal(n){return i.useMemo(function(){return e.signal(n)},[])}Object.defineProperty(n,"Signal",{enumerable:!0,get:function(){return e.Signal}});Object.defineProperty(n,"batch",{enumerable:!0,get:function(){return e.batch}});Object.defineProperty(n,"computed",{enumerable:!0,get:function(){return e.computed}});Object.defineProperty(n,"effect",{enumerable:!0,get:function(){return e.effect}});Object.defineProperty(n,"signal",{enumerable:!0,get:function(){return e.signal}});n.useComputed=function(n){var r=i.useRef(n);r.current=n;t.__$f|=o;return i.useMemo(function(){return e.computed(function(){return r.current()})},[])};n.useSignal=useSignal;n.useSignalEffect=function(n){var r=i.useRef(n);r.current=n;i.useEffect(function(){return e.effect(function(){r.current()})},[])}});
|
||||||
|
//# sourceMappingURL=signals.min.js.map
|
1
static/js/lib/signals/signals.min.js.map
Normal file
1
static/js/lib/signals/signals.min.js.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/signals/signals.mjs
Normal file
2
static/js/lib/signals/signals.mjs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import{Component as t,options as i}from"preact";import{useMemo as e,useRef as n,useEffect as o}from"preact/hooks";import{Signal as r,computed as f,signal as l,effect as s}from"@preact/signals-core";export{Signal,batch,computed,effect,signal}from"@preact/signals-core";const c=4;function u(t,e){i[t]=e.bind(null,i[t]||(()=>{}))}let a,d;function p(t){if(d)d();d=t&&t.S()}function h({data:t}){const i=useSignal(t);i.value=t;const n=e(()=>{let t=this.__v;while(t=t.__)if(t.__c){t.__c.__$f|=c;break}this.__$u.c=()=>{this.base.data=n.peek()};return f(()=>{let t=i.value.value;return 0===t?0:!0===t?"":t||""})},[]);return n.value}h.displayName="_st";Object.defineProperties(r.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:h},props:{configurable:!0,get(){return{data:this}}},__b:{configurable:!0,value:1}});u("__b",(t,i)=>{if("string"==typeof i.type){let t,e=i.props;for(let n in e){if("children"===n)continue;let o=e[n];if(o instanceof r){if(!t)i.__np=t={};t[n]=o;e[n]=o.peek()}}}t(i)});u("__r",(t,i)=>{p();let e,n=i.__c;if(n){n.__$f&=-2;e=n.__$u;if(void 0===e)n.__$u=e=function(t){let i;s(function(){i=this});i.c=()=>{n.__$f|=1;n.setState({})};return i}()}a=n;p(e);t(i)});u("__e",(t,i,e,n)=>{p();a=void 0;t(i,e,n)});u("diffed",(t,i)=>{p();a=void 0;let e;if("string"==typeof i.type&&(e=i.__e)){let t=i.__np,n=i.props;if(t){let i=e.U;if(i)for(let e in i){let n=i[e];if(void 0!==n&&!(e in t)){n.d();i[e]=void 0}}else{i={};e.U=i}for(let o in t){let r=i[o],f=t[o];if(void 0===r){r=_(e,o,f,n);i[o]=r}else r.o(f,n)}}}t(i)});function _(t,i,e,n){const o=i in t&&void 0===t.ownerSVGElement,r=l(e);return{o:(t,i)=>{r.value=t;n=i},d:s(()=>{const e=r.value.value;if(n[i]!==e){n[i]=e;if(o)t[i]=e;else if(e)t.setAttribute(i,e);else t.removeAttribute(i)}})}}u("unmount",(t,i)=>{if("string"==typeof i.type){let t=i.__e;if(t){const i=t.U;if(i){t.U=void 0;for(let t in i){let e=i[t];if(e)e.d()}}}}else{let t=i.__c;if(t){const i=t.__$u;if(i){t.__$u=void 0;i.d()}}}t(i)});u("__h",(t,i,e,n)=>{if(n<3)i.__$f|=2;t(i,e,n)});t.prototype.shouldComponentUpdate=function(t,i){const e=this.__$u;if(!(e&&void 0!==e.s||this.__$f&c))return!0;if(3&this.__$f)return!0;for(let t in i)return!0;for(let i in t)if("__source"!==i&&t[i]!==this.props[i])return!0;for(let i in this.props)if(!(i in t))return!0;return!1};function useSignal(t){return e(()=>l(t),[])}function useComputed(t){const i=n(t);i.current=t;a.__$f|=c;return e(()=>f(()=>i.current()),[])}function useSignalEffect(t){const i=n(t);i.current=t;o(()=>s(()=>{i.current()}),[])}export{useComputed,useSignal,useSignalEffect};
|
||||||
|
//# sourceMappingURL=signals.mjs.map
|
1
static/js/lib/signals/signals.mjs.map
Normal file
1
static/js/lib/signals/signals.mjs.map
Normal file
File diff suppressed because one or more lines are too long
2
static/js/lib/signals/signals.module.js
Normal file
2
static/js/lib/signals/signals.module.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
import{Component as n,options as i}from"preact";import{useMemo as r,useRef as t,useEffect as f}from"preact/hooks";import{Signal as o,computed as e,signal as u,effect as a}from"@preact/signals-core";export{Signal,batch,computed,effect,signal}from"@preact/signals-core";var c,v,s=4;function l(n,r){i[n]=r.bind(null,i[n]||function(){})}function p(n){if(v)v();v=n&&n.S()}function d(n){var i=this,t=n.data,f=useSignal(t);f.value=t;var o=r(function(){var n=i.__v;while(n=n.__)if(n.__c){n.__c.__$f|=s;break}i.__$u.c=function(){i.base.data=o.peek()};return e(function(){var n=f.value.value;return 0===n?0:!0===n?"":n||""})},[]);return o.value}d.displayName="_st";Object.defineProperties(o.prototype,{constructor:{configurable:!0},type:{configurable:!0,value:d},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}});l("__b",function(n,i){if("string"==typeof i.type){var r,t=i.props;for(var f in t)if("children"!==f){var e=t[f];if(e instanceof o){if(!r)i.__np=r={};r[f]=e;t[f]=e.peek()}}}n(i)});l("__r",function(n,i){p();var r,t=i.__c;if(t){t.__$f&=-2;if(void 0===(r=t.__$u))t.__$u=r=function(n){var i;a(function(){i=this});i.c=function(){t.__$f|=1;t.setState({})};return i}()}c=t;p(r);n(i)});l("__e",function(n,i,r,t){p();c=void 0;n(i,r,t)});l("diffed",function(n,i){p();c=void 0;var r;if("string"==typeof i.type&&(r=i.__e)){var t=i.__np,f=i.props;if(t){var o=r.U;if(o)for(var e in o){var u=o[e];if(void 0!==u&&!(e in t)){u.d();o[e]=void 0}}else r.U=o={};for(var a in t){var v=o[a],s=t[a];if(void 0===v){v=_(r,a,s,f);o[a]=v}else v.o(s,f)}}}n(i)});function _(n,i,r,t){var f=i in n&&void 0===n.ownerSVGElement,o=u(r);return{o:function(n,i){o.value=n;t=i},d:a(function(){var r=o.value.value;if(t[i]!==r){t[i]=r;if(f)n[i]=r;else if(r)n.setAttribute(i,r);else n.removeAttribute(i)}})}}l("unmount",function(n,i){if("string"==typeof i.type){var r=i.__e;if(r){var t=r.U;if(t){r.U=void 0;for(var f in t){var o=t[f];if(o)o.d()}}}}else{var e=i.__c;if(e){var u=e.__$u;if(u){e.__$u=void 0;u.d()}}}n(i)});l("__h",function(n,i,r,t){if(t<3)i.__$f|=2;n(i,r,t)});n.prototype.shouldComponentUpdate=function(n,i){var r=this.__$u;if(!(r&&void 0!==r.s||this.__$f&s))return!0;if(3&this.__$f)return!0;for(var t in i)return!0;for(var f in n)if("__source"!==f&&n[f]!==this.props[f])return!0;for(var o in this.props)if(!(o in n))return!0;return!1};function useSignal(n){return r(function(){return u(n)},[])}function useComputed(n){var i=t(n);i.current=n;c.__$f|=s;return r(function(){return e(function(){return i.current()})},[])}function useSignalEffect(n){var i=t(n);i.current=n;f(function(){return a(function(){i.current()})},[])}export{useComputed,useSignal,useSignalEffect};
|
||||||
|
//# sourceMappingURL=signals.module.js.map
|
1
static/js/lib/signals/signals.module.js.map
Normal file
1
static/js/lib/signals/signals.module.js.map
Normal file
File diff suppressed because one or more lines are too long
11
static/less/Makefile
Normal file
11
static/less/Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
less = $(wildcard *.less)
|
||||||
|
_css = $(less:.less=.css)
|
||||||
|
css = $(addprefix ../css/, $(_css) )
|
||||||
|
|
||||||
|
../css/%.css: %.less theme.less
|
||||||
|
lessc $< ../css/$@
|
||||||
|
|
||||||
|
all: $(css)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -vf $(css)
|
26
static/less/login.less
Normal file
26
static/less/login.less
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
@import "theme.less";
|
||||||
|
|
||||||
|
#login {
|
||||||
|
display: grid;
|
||||||
|
justify-items: center;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
div {
|
||||||
|
max-width: 300px;
|
||||||
|
|
||||||
|
input {
|
||||||
|
margin-bottom: 32px;
|
||||||
|
width: 100%;
|
||||||
|
border: 0px;
|
||||||
|
border-bottom: 1px solid #fff;
|
||||||
|
|
||||||
|
font-size: 18pt;
|
||||||
|
color: #fff;
|
||||||
|
background-color: @background;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
static/less/loop_make.sh
Executable file
15
static/less/loop_make.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
# inotifywait -q -e MOVE_SELF *less
|
||||||
|
inotifywait -q -e MODIFY *less
|
||||||
|
#sleep 0.5
|
||||||
|
clear
|
||||||
|
if make -j12; then
|
||||||
|
echo -e "\n\e[32;1mOK!\e[0m"
|
||||||
|
curl -s http://notes.lan:1371/css_updated
|
||||||
|
sleep 1
|
||||||
|
clear
|
||||||
|
fi
|
||||||
|
done
|
19
static/less/main.less
Normal file
19
static/less/main.less
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
@import "theme.less";
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0px;
|
||||||
|
font-family: 'Liberation Mono', monospace;
|
||||||
|
font-size: 16pt;
|
||||||
|
|
||||||
|
background-color: @background;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: @accent_1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
padding: 32px;
|
||||||
|
color: #fff;
|
||||||
|
}
|
2
static/less/theme.less
Normal file
2
static/less/theme.less
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@background: #494949;
|
||||||
|
@accent_1: #ecbf00;
|
Loading…
Reference in New Issue
Block a user