Initial commit with user management
This commit is contained in:
commit
a1a928e7cb
98 changed files with 13042 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
notes2
|
192
authentication/pkg.go
Normal file
192
authentication/pkg.go
Normal file
|
@ -0,0 +1,192 @@
|
|||
package authentication
|
||||
|
||||
import (
|
||||
// External
|
||||
_ "git.gibonuddevalla.se/go/wrappederror"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/lib/pq"
|
||||
|
||||
// Standard
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Manager struct {
|
||||
db *sqlx.DB
|
||||
log *slog.Logger
|
||||
secret []byte
|
||||
ExpireDays int
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID int
|
||||
Username string
|
||||
Name string
|
||||
}
|
||||
|
||||
func httpError(w http.ResponseWriter, err error) { // {{{
|
||||
j, _ := json.Marshal(struct {
|
||||
OK bool
|
||||
Error string
|
||||
}{
|
||||
false,
|
||||
err.Error(),
|
||||
})
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
|
||||
func NewManager(db *sqlx.DB, log *slog.Logger, secret string, expireDays int) (mngr Manager, err error) { // {{{
|
||||
mngr.db = db
|
||||
mngr.log = log
|
||||
|
||||
mngr.secret, err = hex.DecodeString(secret)
|
||||
mngr.ExpireDays = expireDays
|
||||
return
|
||||
} // }}}
|
||||
func (mngr *Manager) GenerateToken(data map[string]any) (string, error) { // {{{
|
||||
// Create a new token object, specifying signing method and the claims
|
||||
// you would like it to contain.
|
||||
now := time.Now()
|
||||
data["iat"] = now.Unix()
|
||||
data["exp"] = now.Add(time.Hour * 24 * time.Duration(mngr.ExpireDays)).Unix()
|
||||
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims(data))
|
||||
|
||||
// Sign and get the complete encoded token as a string using the secret.
|
||||
return token.SignedString(mngr.secret)
|
||||
} // }}}
|
||||
func (mngr *Manager) AuthenticationHandler(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
var request struct {
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
body, _ := io.ReadAll(r.Body)
|
||||
err := json.Unmarshal(body, &request)
|
||||
if err != nil {
|
||||
httpError(w, err)
|
||||
}
|
||||
|
||||
// Verify username and password against the db user table.
|
||||
authenticated, user, err := mngr.Authenticate(request.Username, request.Password)
|
||||
if err != nil {
|
||||
httpError(w, err)
|
||||
}
|
||||
|
||||
if !authenticated {
|
||||
httpError(w, errors.New("Authentication failed"))
|
||||
}
|
||||
|
||||
j, _ := json.Marshal(struct {
|
||||
OK bool
|
||||
User User
|
||||
}{true, user})
|
||||
w.Write(j)
|
||||
} // }}}
|
||||
|
||||
func (mngr *Manager) Authenticate(username, password string) (authenticated bool, user User, err error) { // {{{
|
||||
var row *sql.Row
|
||||
row = mngr.db.QueryRow(`
|
||||
SELECT id, username, name
|
||||
FROM public.user
|
||||
WHERE
|
||||
LOWER(username) = LOWER($1) AND
|
||||
password = password_hash(SUBSTRING(password FROM 1 FOR 32), $2::bytea)
|
||||
`,
|
||||
username,
|
||||
password,
|
||||
)
|
||||
err = row.Scan(&user.ID, &user.Username, &user.Name)
|
||||
authenticated = user.ID > 0
|
||||
return
|
||||
} // }}}
|
||||
func (mngr *Manager) CreateUser(username, password, name string) (alreadyExists bool, err error) { // {{{
|
||||
_, err = mngr.db.Exec(`
|
||||
INSERT INTO public.user(username, password, name, totp)
|
||||
VALUES(
|
||||
$1,
|
||||
public.password_hash(
|
||||
/* salt in hex */
|
||||
ENCODE(public.gen_random_bytes(16), 'hex'),
|
||||
|
||||
/* password */
|
||||
$2::bytea
|
||||
),
|
||||
$3,
|
||||
''
|
||||
)
|
||||
`,
|
||||
username,
|
||||
password,
|
||||
name,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
if pqErr, ok := err.(*pq.Error); ok && pqErr.Code == "23505" {
|
||||
err = errors.New("User already exists")
|
||||
alreadyExists = true
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
} // }}}
|
||||
func (mngr *Manager) ChangePassword(username, currentPassword, newPassword string, forceChange bool) (changed bool, err error) { // {{{
|
||||
var res sql.Result
|
||||
|
||||
if forceChange {
|
||||
res, err = mngr.db.Exec(`
|
||||
UPDATE public.user
|
||||
SET
|
||||
"password" = public.password_hash(
|
||||
/* salt in hex */
|
||||
ENCODE(public.gen_random_bytes(16), 'hex'),
|
||||
|
||||
/* password */
|
||||
$2::bytea
|
||||
)
|
||||
WHERE
|
||||
username = $1
|
||||
|
||||
`,
|
||||
username,
|
||||
newPassword,
|
||||
)
|
||||
} else {
|
||||
res, err = mngr.db.Exec(`
|
||||
UPDATE public.user
|
||||
SET
|
||||
"password" = public.password_hash(
|
||||
/* salt in hex */
|
||||
ENCODE(public.gen_random_bytes(16), 'hex'),
|
||||
|
||||
/* password */
|
||||
$3::bytea
|
||||
)
|
||||
WHERE
|
||||
username = $1 AND
|
||||
"password" = public.password_hash(SUBSTRING(password FROM 1 FOR 32), $2::bytea)
|
||||
|
||||
`,
|
||||
username,
|
||||
currentPassword,
|
||||
newPassword,
|
||||
)
|
||||
}
|
||||
|
||||
var rowsAffected int64
|
||||
rowsAffected, err = res.RowsAffected()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
changed = (rowsAffected == 1)
|
||||
return
|
||||
} // }}}
|
40
config.go
Normal file
40
config.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// Standard
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Network struct {
|
||||
Address string
|
||||
Port int
|
||||
}
|
||||
|
||||
Database struct {
|
||||
Host string
|
||||
Port int
|
||||
Db string
|
||||
Username string
|
||||
Password string
|
||||
}
|
||||
|
||||
JWT struct {
|
||||
Secret string
|
||||
ExpireDays int
|
||||
}
|
||||
}
|
||||
|
||||
func readConfig() (err error) {
|
||||
var configData []byte
|
||||
fname := fmt.Sprintf("%s/.config/notes2.json", os.Getenv("HOME"))
|
||||
configData, err = os.ReadFile(fname)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(configData, &config)
|
||||
return
|
||||
}
|
63
db.go
Normal file
63
db.go
Normal file
|
@ -0,0 +1,63 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// External
|
||||
"git.gibonuddevalla.se/go/dbschema"
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/lib/pq"
|
||||
|
||||
// Standard
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
db *sqlx.DB
|
||||
)
|
||||
|
||||
func sqlCallback(db string, version int) (sql []byte, found bool) { // {{{
|
||||
var err error
|
||||
fname := fmt.Sprintf("sql/%05d.sql", version)
|
||||
sql, err = SqlFS.ReadFile(fname)
|
||||
found = (err == nil)
|
||||
return
|
||||
} // }}}
|
||||
func logCallback(section, message string) { // {{{
|
||||
Log.Info("database", section, message)
|
||||
} // }}}
|
||||
func initDB() (err error) { // {{{
|
||||
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.Db,
|
||||
)
|
||||
|
||||
Log.Info(
|
||||
"database",
|
||||
"host", config.Database.Host,
|
||||
"port", config.Database.Port,
|
||||
)
|
||||
|
||||
if db, err = sqlx.Connect("postgres", dbConn); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
upgrader := dbschema.NewUpgrader()
|
||||
upgrader.SetSqlCallback(sqlCallback)
|
||||
upgrader.SetLogCallback(logCallback)
|
||||
_, err = upgrader.AddDatabase(
|
||||
config.Database.Host,
|
||||
config.Database.Port,
|
||||
config.Database.Db,
|
||||
config.Database.Username,
|
||||
config.Database.Password,
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = upgrader.Run()
|
||||
|
||||
return
|
||||
} // }}}
|
12
go.mod
Normal file
12
go.mod
Normal file
|
@ -0,0 +1,12 @@
|
|||
module notes2
|
||||
|
||||
go 1.23.0
|
||||
|
||||
require (
|
||||
git.gibonuddevalla.se/go/dbschema v1.3.1
|
||||
git.gibonuddevalla.se/go/wrappederror v0.3.5
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/jmoiron/sqlx v1.4.0
|
||||
github.com/lib/pq v1.10.9
|
||||
)
|
18
go.sum
Normal file
18
go.sum
Normal file
|
@ -0,0 +1,18 @@
|
|||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
git.gibonuddevalla.se/go/dbschema v1.3.1 h1:TGPvbNO/u7IK5TU0HT92mVzqdF179lLCfdTxM1ftcAE=
|
||||
git.gibonuddevalla.se/go/dbschema v1.3.1/go.mod h1:BNw3q/574nXbGoeWyK+tLhRfggVkw2j2aXZzrBKC3ig=
|
||||
git.gibonuddevalla.se/go/wrappederror v0.3.5 h1:/EzrdXETlZfNpS6TcK1Ix6BaV+Fl7qcGoxUM0GkrIN8=
|
||||
git.gibonuddevalla.se/go/wrappederror v0.3.5/go.mod h1:j4w320Hk1wvhOPjUaK4GgLvmtnjUUM5yVu6JFO1OCSc=
|
||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
|
||||
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
|
||||
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.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
31
html_template/page.go
Normal file
31
html_template/page.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package HTMLTemplate
|
||||
|
||||
type Page interface {
|
||||
GetVersion() string
|
||||
GetLayout() string
|
||||
GetPage() string
|
||||
GetData() any
|
||||
}
|
||||
|
||||
type SimplePage struct {
|
||||
Version string
|
||||
Layout string
|
||||
Page string
|
||||
Data any
|
||||
}
|
||||
|
||||
func (s SimplePage) GetVersion() string {
|
||||
return s.Version
|
||||
}
|
||||
|
||||
func (s SimplePage) GetLayout() string {
|
||||
return s.Layout
|
||||
}
|
||||
|
||||
func (s SimplePage) GetPage() string {
|
||||
return s.Page
|
||||
}
|
||||
|
||||
func (s SimplePage) GetData() any {
|
||||
return s.Data
|
||||
}
|
158
html_template/pkg.go
Normal file
158
html_template/pkg.go
Normal file
|
@ -0,0 +1,158 @@
|
|||
package HTMLTemplate
|
||||
|
||||
import (
|
||||
// External
|
||||
werr "git.gibonuddevalla.se/go/wrappederror"
|
||||
|
||||
// Standard
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type Engine struct {
|
||||
parsedTemplates map[string]*template.Template
|
||||
viewFS fs.FS
|
||||
staticEmbeddedFS http.Handler
|
||||
staticLocalFS http.Handler
|
||||
componentFilenames []string
|
||||
DevMode bool
|
||||
}
|
||||
|
||||
func NewEngine(viewFS, staticFS fs.FS, devmode bool) (e Engine, err error) { // {{{
|
||||
e.parsedTemplates = make(map[string]*template.Template)
|
||||
e.viewFS = viewFS
|
||||
e.DevMode = devmode
|
||||
|
||||
e.componentFilenames, err = e.getComponentFilenames()
|
||||
|
||||
// Set up fileservers for static resources.
|
||||
// The embedded FS is using the embedded files intented for production use.
|
||||
// The local FS is for development of Javascript to avoid server rebuild (devmode).
|
||||
var staticSubFS fs.FS
|
||||
staticSubFS, err = fs.Sub(staticFS, "static")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
e.staticEmbeddedFS = http.FileServer(http.FS(staticSubFS))
|
||||
e.staticLocalFS = http.FileServer(http.Dir("static"))
|
||||
|
||||
return
|
||||
} // }}}
|
||||
|
||||
func (e *Engine) getComponentFilenames() (files []string, err error) { // {{{
|
||||
files = []string{}
|
||||
if err := fs.WalkDir(e.viewFS, "views/components", func(path string, d fs.DirEntry, err error) error {
|
||||
if d == nil {
|
||||
return nil
|
||||
}
|
||||
if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
files = append(files, path)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return files, nil
|
||||
} // }}}
|
||||
|
||||
func (e *Engine) ReloadTemplates() { // {{{
|
||||
e.parsedTemplates = make(map[string]*template.Template)
|
||||
} // }}}
|
||||
|
||||
func (e *Engine) StaticResource(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
var err error
|
||||
|
||||
// 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.
|
||||
if r.URL.Path == "/favicon.ico" {
|
||||
e.staticEmbeddedFS.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
rxp := regexp.MustCompile("^/(css|images|js|fonts)/v[0-9]+/(.*)$")
|
||||
if comp := rxp.FindStringSubmatch(r.URL.Path); comp != nil {
|
||||
w.Header().Add("Pragma", "public")
|
||||
w.Header().Add("Cache-Control", "max-age=604800")
|
||||
|
||||
r.URL.Path = fmt.Sprintf("/%s/%s", comp[1], comp[2])
|
||||
if e.DevMode {
|
||||
p := fmt.Sprintf("static/%s/%s", comp[1], comp[2])
|
||||
_, err = os.Stat(p)
|
||||
if err == nil {
|
||||
e.staticLocalFS.ServeHTTP(w, r)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
e.staticEmbeddedFS.ServeHTTP(w, r)
|
||||
} // }}}
|
||||
func (e *Engine) getPage(layout, page string) (tmpl *template.Template, err error) { // {{{
|
||||
layoutFilename := fmt.Sprintf("views/layouts/%s.gotmpl", layout)
|
||||
pageFilename := fmt.Sprintf("views/pages/%s.gotmpl", page)
|
||||
|
||||
if tmpl, found := e.parsedTemplates[page]; found {
|
||||
return tmpl, nil
|
||||
}
|
||||
|
||||
funcMap := template.FuncMap{
|
||||
/*
|
||||
"format_time": func(t time.Time) template.HTML {
|
||||
return template.HTML(
|
||||
t.In(smonConfig.Timezone()).Format(`<span class="date">2006-01-02</span> <span class="time">15:04:05<span class="seconds">:05</span></span>`),
|
||||
)
|
||||
},
|
||||
*/
|
||||
}
|
||||
|
||||
filenames := []string{layoutFilename, pageFilename}
|
||||
filenames = append(filenames, e.componentFilenames...)
|
||||
|
||||
if e.DevMode {
|
||||
tmpl, err = template.New(layout+".gotmpl").Funcs(funcMap).ParseFS(os.DirFS("."), filenames...)
|
||||
} else {
|
||||
tmpl, err = template.New(layout+".gotmpl").Funcs(funcMap).ParseFS(e.viewFS, filenames...)
|
||||
}
|
||||
if err != nil {
|
||||
err = werr.Wrap(err).Log()
|
||||
return
|
||||
}
|
||||
|
||||
e.parsedTemplates[page] = tmpl
|
||||
return
|
||||
} // }}}
|
||||
func (e *Engine) Render(p Page, w http.ResponseWriter, r *http.Request) (err error) { // {{{
|
||||
if e.DevMode {
|
||||
e.ReloadTemplates()
|
||||
}
|
||||
|
||||
var tmpl *template.Template
|
||||
tmpl, err = e.getPage(p.GetLayout(), p.GetPage())
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
return
|
||||
}
|
||||
|
||||
data := map[string]any{
|
||||
"VERSION": p.GetVersion(),
|
||||
"LAYOUT": p.GetLayout(),
|
||||
"PAGE": p.GetPage(),
|
||||
"ERROR": r.URL.Query().Get("_err"),
|
||||
"Data": p.GetData(),
|
||||
}
|
||||
|
||||
err = tmpl.Execute(w, data)
|
||||
if err != nil {
|
||||
err = werr.Wrap(err)
|
||||
}
|
||||
return
|
||||
} // }}}
|
||||
|
||||
// vim: foldmethod=marker
|
202
main.go
Normal file
202
main.go
Normal file
|
@ -0,0 +1,202 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
// External
|
||||
|
||||
// Internal
|
||||
"notes2/authentication"
|
||||
"notes2/html_template"
|
||||
"os"
|
||||
|
||||
// Standard
|
||||
"bufio"
|
||||
"embed"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
const VERSION = "v1"
|
||||
|
||||
var (
|
||||
FlagDev bool
|
||||
FlagConfig string
|
||||
FlagCreateUser string
|
||||
FlagChangePassword string
|
||||
Webengine HTMLTemplate.Engine
|
||||
config Config
|
||||
Log *slog.Logger
|
||||
AuthManager authentication.Manager
|
||||
|
||||
//go:embed views
|
||||
ViewFS embed.FS
|
||||
|
||||
//go:embed static
|
||||
StaticFS embed.FS
|
||||
|
||||
//go:embed sql
|
||||
SqlFS embed.FS
|
||||
)
|
||||
|
||||
func init() { // {{{
|
||||
// Configuration filename to use with a somewhat sane default.
|
||||
cfgDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cfgFilename := path.Join(cfgDir, "notes2.json")
|
||||
|
||||
flag.StringVar(&FlagConfig, "config", cfgFilename, "Configuration file")
|
||||
flag.BoolVar(&FlagDev, "dev", false, "Use local files instead of embedded files")
|
||||
flag.StringVar(&FlagCreateUser, "create-user", "", "Username for creating a new user")
|
||||
flag.StringVar(&FlagChangePassword, "change-password", "", "Change the password for the given username")
|
||||
flag.Parse()
|
||||
} // }}}
|
||||
func initLog() { // {{{
|
||||
opts := slog.HandlerOptions{}
|
||||
opts.Level = slog.LevelDebug
|
||||
Log = slog.New(slog.NewJSONHandler(os.Stdout, &opts))
|
||||
} // }}}
|
||||
func main() { // {{{
|
||||
initLog()
|
||||
err := readConfig()
|
||||
if err != nil {
|
||||
Log.Error("config", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// dbschema uses the embedded SQL files to keep the database schema up to date.
|
||||
err = initDB()
|
||||
if err != nil {
|
||||
Log.Error("database", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// The session manager contains authentication, authorization and session settings.
|
||||
AuthManager, err = authentication.NewManager(db, Log, config.JWT.Secret, config.JWT.ExpireDays)
|
||||
|
||||
// A new user?
|
||||
if FlagCreateUser != "" {
|
||||
createNewUser(FlagCreateUser)
|
||||
return
|
||||
}
|
||||
|
||||
// Forgotten the password?
|
||||
if FlagChangePassword != "" {
|
||||
changePassword(FlagChangePassword)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// The webengine takes layouts, pages and components and renders them into HTML.
|
||||
Webengine, err = HTMLTemplate.NewEngine(ViewFS, StaticFS, FlagDev)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
http.HandleFunc("/", rootHandler)
|
||||
http.HandleFunc("/authenticate", AuthManager.AuthenticationHandler)
|
||||
http.HandleFunc("/service_worker.js", pageServiceWorker)
|
||||
listen := fmt.Sprintf("%s:%d", config.Network.Address, config.Network.Port)
|
||||
http.ListenAndServe(listen, nil)
|
||||
} // }}}
|
||||
|
||||
func rootHandler(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
// All URLs not specifically handled are routed to this function.
|
||||
// Everything going here should be a static resource.
|
||||
if r.URL.Path != "/" {
|
||||
Webengine.StaticResource(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
pageIndex(w, r)
|
||||
} // }}}
|
||||
func pageServiceWorker(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
w.Header().Add("Content-Type", "text/javascript; charset=utf-8")
|
||||
|
||||
var tmpl *template.Template
|
||||
var err error
|
||||
if FlagDev {
|
||||
tmpl, err = template.ParseFiles("static/service_worker.js")
|
||||
} else {
|
||||
tmpl, err = template.ParseFS(StaticFS, "static/service_worker.js")
|
||||
}
|
||||
if err != nil {
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
err = tmpl.Execute(w, struct{ VERSION string }{VERSION})
|
||||
if err != nil {
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
} // }}}
|
||||
func pageIndex(w http.ResponseWriter, r *http.Request) { // {{{
|
||||
// Index page is rendered since everything
|
||||
// else are specifically handled.
|
||||
page := HTMLTemplate.SimplePage{
|
||||
Layout: "main",
|
||||
Page: "index",
|
||||
Version: VERSION,
|
||||
}
|
||||
|
||||
err := Webengine.Render(page, w, r)
|
||||
if err != nil {
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
} // }}}
|
||||
func sessionFilter(fn func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) { // {{{
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Printf("Filtered ")
|
||||
fn(w, r)
|
||||
}
|
||||
} // }}}
|
||||
|
||||
func createNewUser(username string) { // {{{
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
|
||||
fmt.Print("\nPassword: ")
|
||||
pwd, _ := reader.ReadString('\n')
|
||||
pwd = strings.Trim(pwd, "\r\n")
|
||||
|
||||
fmt.Print("Name: ")
|
||||
name, _ := reader.ReadString('\n')
|
||||
name = strings.Trim(name, "\r\n")
|
||||
|
||||
alreadyExists, err := AuthManager.CreateUser(username, pwd, name)
|
||||
if alreadyExists {
|
||||
fmt.Printf("\nUser '%s' already exists\n", username)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
Log.Error("create_user", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("\nUser '%s' with username '%s' is created.\n", name, username)
|
||||
} // }}}
|
||||
func changePassword(username string) { // {{{
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
|
||||
fmt.Print("\nPassword: ")
|
||||
newPwd, _ := reader.ReadString('\n')
|
||||
newPwd = strings.Trim(newPwd, "\r\n")
|
||||
|
||||
hasChanged, err := AuthManager.ChangePassword(username, "", newPwd, true)
|
||||
if !hasChanged {
|
||||
fmt.Printf("Invalid user\n")
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
Log.Error("change_password", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("\nPassword changed\n")
|
||||
} // }}}
|
43
sql/00001.sql
Normal file
43
sql/00001.sql
Normal file
|
@ -0,0 +1,43 @@
|
|||
CREATE TABLE public.user (
|
||||
id serial NOT NULL,
|
||||
"name" varchar NOT NULL,
|
||||
"username" varchar NOT NULL,
|
||||
"password" char(96) NOT NULL,
|
||||
totp varchar NOT NULL,
|
||||
last_login timestamp with time zone NOT NULL DEFAULT '1970-01-01 00:00:00',
|
||||
CONSTRAINT user_pk PRIMARY KEY (id),
|
||||
CONSTRAINT user_un UNIQUE (username)
|
||||
);
|
||||
|
||||
CREATE TABLE public.session (
|
||||
id serial NOT NULL,
|
||||
user_id int4 NULL,
|
||||
"uuid" char(36) NOT NULL,
|
||||
created timestamp with time zone NOT NULL DEFAULT NOW(),
|
||||
last_used timestamp with time zone NOT NULL DEFAULT NOW(),
|
||||
CONSTRAINT session_pk PRIMARY KEY (id),
|
||||
CONSTRAINT session_un UNIQUE ("uuid"),
|
||||
CONSTRAINT session_user_fk FOREIGN KEY (user_id) REFERENCES "user"(id) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS pgcrypto SCHEMA public;
|
||||
|
||||
CREATE FUNCTION password_hash(salt_hex char(32), pass bytea)
|
||||
RETURNS char(96)
|
||||
LANGUAGE plpgsql
|
||||
AS
|
||||
$$
|
||||
BEGIN
|
||||
RETURN (
|
||||
SELECT
|
||||
salt_hex ||
|
||||
encode(
|
||||
sha256(
|
||||
decode(salt_hex, 'hex') || /* salt in binary */
|
||||
pass /* password */
|
||||
),
|
||||
'hex'
|
||||
)
|
||||
);
|
||||
END;
|
||||
$$;
|
14
static/css/main.css
Normal file
14
static/css/main.css
Normal file
|
@ -0,0 +1,14 @@
|
|||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
*:focus {
|
||||
outline: none;
|
||||
}
|
||||
[onClick] {
|
||||
cursor: pointer;
|
||||
}
|
1
static/foo
Normal file
1
static/foo
Normal file
|
@ -0,0 +1 @@
|
|||
foo
|
1
static/js/app.mjs
Normal file
1
static/js/app.mjs
Normal file
|
@ -0,0 +1 @@
|
|||
console.log('app.mjs')
|
6
static/js/lib/fullcalendar.min.js
vendored
Normal file
6
static/js/lib/fullcalendar.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
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]}});
|
1
static/js/lib/node_modules/.bin/marked
generated
vendored
Symbolic link
1
static/js/lib/node_modules/.bin/marked
generated
vendored
Symbolic link
|
@ -0,0 +1 @@
|
|||
../marked/bin/marked.js
|
18
static/js/lib/node_modules/.package-lock.json
generated
vendored
Normal file
18
static/js/lib/node_modules/.package-lock.json
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "lib",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/marked": {
|
||||
"version": "11.1.1",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-11.1.1.tgz",
|
||||
"integrity": "sha512-EgxRjgK9axsQuUa/oKMx5DEY8oXpKJfk61rT5iY3aRlgU6QJtUcxU5OAymdhCvWvhYcd9FKmO5eQoX8m9VGJXg==",
|
||||
"bin": {
|
||||
"marked": "bin/marked.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
static/js/lib/node_modules/marked/LICENSE.md
generated
vendored
Normal file
44
static/js/lib/node_modules/marked/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
# License information
|
||||
|
||||
## Contribution License Agreement
|
||||
|
||||
If you contribute code to this project, you are implicitly allowing your code
|
||||
to be distributed under the MIT license. You are also implicitly verifying that
|
||||
all code is your original work. `</legalese>`
|
||||
|
||||
## Marked
|
||||
|
||||
Copyright (c) 2018+, MarkedJS (https://github.com/markedjs/)
|
||||
Copyright (c) 2011-2018, Christopher Jeffrey (https://github.com/chjj/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
## Markdown
|
||||
|
||||
Copyright © 2004, John Gruber
|
||||
http://daringfireball.net/
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
107
static/js/lib/node_modules/marked/README.md
generated
vendored
Normal file
107
static/js/lib/node_modules/marked/README.md
generated
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
<a href="https://marked.js.org">
|
||||
<img width="60px" height="60px" src="https://marked.js.org/img/logo-black.svg" align="right" />
|
||||
</a>
|
||||
|
||||
# Marked
|
||||
|
||||
[![npm](https://badgen.net/npm/v/marked)](https://www.npmjs.com/package/marked)
|
||||
[![gzip size](https://badgen.net/badgesize/gzip/https://cdn.jsdelivr.net/npm/marked/marked.min.js)](https://cdn.jsdelivr.net/npm/marked/marked.min.js)
|
||||
[![install size](https://badgen.net/packagephobia/install/marked)](https://packagephobia.now.sh/result?p=marked)
|
||||
[![downloads](https://badgen.net/npm/dt/marked)](https://www.npmjs.com/package/marked)
|
||||
[![github actions](https://github.com/markedjs/marked/workflows/Tests/badge.svg)](https://github.com/markedjs/marked/actions)
|
||||
[![snyk](https://snyk.io/test/npm/marked/badge.svg)](https://snyk.io/test/npm/marked)
|
||||
|
||||
- ⚡ built for speed
|
||||
- ⬇️ low-level compiler for parsing markdown without caching or blocking for long periods of time
|
||||
- ⚖️ light-weight while implementing all markdown features from the supported flavors & specifications
|
||||
- 🌐 works in a browser, on a server, or from a command line interface (CLI)
|
||||
|
||||
## Demo
|
||||
|
||||
Checkout the [demo page](https://marked.js.org/demo/) to see marked in action ⛹️
|
||||
|
||||
## Docs
|
||||
|
||||
Our [documentation pages](https://marked.js.org) are also rendered using marked 💯
|
||||
|
||||
Also read about:
|
||||
|
||||
* [Options](https://marked.js.org/using_advanced)
|
||||
* [Extensibility](https://marked.js.org/using_pro)
|
||||
|
||||
## Compatibility
|
||||
|
||||
**Node.js:** Only [current and LTS](https://nodejs.org/en/about/releases/) Node.js versions are supported. End of life Node.js versions may become incompatible with Marked at any point in time.
|
||||
|
||||
**Browser:** Not IE11 :)
|
||||
|
||||
## Installation
|
||||
|
||||
**CLI:**
|
||||
|
||||
```sh
|
||||
npm install -g marked
|
||||
```
|
||||
|
||||
**In-browser:**
|
||||
|
||||
```sh
|
||||
npm install marked
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Warning: 🚨 Marked does not [sanitize](https://marked.js.org/using_advanced#options) the output HTML. Please use a sanitize library, like [DOMPurify](https://github.com/cure53/DOMPurify) (recommended), [sanitize-html](https://github.com/apostrophecms/sanitize-html) or [insane](https://github.com/bevacqua/insane) on the *output* HTML! 🚨
|
||||
|
||||
```
|
||||
DOMPurify.sanitize(marked.parse(`<img src="x" onerror="alert('not happening')">`));
|
||||
```
|
||||
|
||||
**CLI**
|
||||
|
||||
``` bash
|
||||
# Example with stdin input
|
||||
$ marked -o hello.html
|
||||
hello world
|
||||
^D
|
||||
$ cat hello.html
|
||||
<p>hello world</p>
|
||||
```
|
||||
|
||||
```bash
|
||||
# Print all options
|
||||
$ marked --help
|
||||
```
|
||||
|
||||
**Browser**
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Marked in the browser</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content"></div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<script>
|
||||
document.getElementById('content').innerHTML =
|
||||
marked.parse('# Marked in the browser\n\nRendered by **marked**.');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
or import esm module
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { marked } from "https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js";
|
||||
document.getElementById('content').innerHTML =
|
||||
marked.parse('# Marked in the browser\n\nRendered by **marked**.');
|
||||
</script>
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2011-2022, Christopher Jeffrey. (MIT License)
|
279
static/js/lib/node_modules/marked/bin/main.js
generated
vendored
Normal file
279
static/js/lib/node_modules/marked/bin/main.js
generated
vendored
Normal file
|
@ -0,0 +1,279 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Marked CLI
|
||||
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
|
||||
*/
|
||||
|
||||
import { promises } from 'node:fs';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { homedir } from 'node:os';
|
||||
import { createRequire } from 'node:module';
|
||||
import { marked } from '../lib/marked.esm.js';
|
||||
|
||||
const { access, readFile, writeFile } = promises;
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
/**
|
||||
* @param {Process} nodeProcess inject process so it can be mocked in tests.
|
||||
*/
|
||||
export async function main(nodeProcess) {
|
||||
/**
|
||||
* Man Page
|
||||
*/
|
||||
async function help() {
|
||||
const { spawn } = await import('child_process');
|
||||
const { fileURLToPath } = await import('url');
|
||||
|
||||
const options = {
|
||||
cwd: nodeProcess.cwd(),
|
||||
env: nodeProcess.env,
|
||||
stdio: 'inherit'
|
||||
};
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const helpText = await readFile(resolve(__dirname, '../man/marked.1.md'), 'utf8');
|
||||
|
||||
// eslint-disable-next-line promise/param-names
|
||||
await new Promise(res => {
|
||||
spawn('man', [resolve(__dirname, '../man/marked.1')], options)
|
||||
.on('error', () => {
|
||||
console.log(helpText);
|
||||
})
|
||||
.on('close', res);
|
||||
});
|
||||
}
|
||||
|
||||
async function version() {
|
||||
const pkg = require('../package.json');
|
||||
console.log(pkg.version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Main
|
||||
*/
|
||||
async function start(argv) {
|
||||
const files = [];
|
||||
const options = {};
|
||||
let input;
|
||||
let output;
|
||||
let string;
|
||||
let arg;
|
||||
let tokens;
|
||||
let config;
|
||||
let opt;
|
||||
let noclobber;
|
||||
|
||||
function getArg() {
|
||||
let arg = argv.shift();
|
||||
|
||||
if (arg.indexOf('--') === 0) {
|
||||
// e.g. --opt
|
||||
arg = arg.split('=');
|
||||
if (arg.length > 1) {
|
||||
// e.g. --opt=val
|
||||
argv.unshift(arg.slice(1).join('='));
|
||||
}
|
||||
arg = arg[0];
|
||||
} else if (arg[0] === '-') {
|
||||
if (arg.length > 2) {
|
||||
// e.g. -abc
|
||||
argv = arg.substring(1).split('').map(function(ch) {
|
||||
return '-' + ch;
|
||||
}).concat(argv);
|
||||
arg = argv.shift();
|
||||
} else {
|
||||
// e.g. -a
|
||||
}
|
||||
} else {
|
||||
// e.g. foo
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
while (argv.length) {
|
||||
arg = getArg();
|
||||
switch (arg) {
|
||||
case '-o':
|
||||
case '--output':
|
||||
output = argv.shift();
|
||||
break;
|
||||
case '-i':
|
||||
case '--input':
|
||||
input = argv.shift();
|
||||
break;
|
||||
case '-s':
|
||||
case '--string':
|
||||
string = argv.shift();
|
||||
break;
|
||||
case '-t':
|
||||
case '--tokens':
|
||||
tokens = true;
|
||||
break;
|
||||
case '-c':
|
||||
case '--config':
|
||||
config = argv.shift();
|
||||
break;
|
||||
case '-n':
|
||||
case '--no-clobber':
|
||||
noclobber = true;
|
||||
break;
|
||||
case '-h':
|
||||
case '--help':
|
||||
return await help();
|
||||
case '-v':
|
||||
case '--version':
|
||||
return await version();
|
||||
default:
|
||||
if (arg.indexOf('--') === 0) {
|
||||
opt = camelize(arg.replace(/^--(no-)?/, ''));
|
||||
if (!marked.defaults.hasOwnProperty(opt)) {
|
||||
continue;
|
||||
}
|
||||
if (arg.indexOf('--no-') === 0) {
|
||||
options[opt] = typeof marked.defaults[opt] !== 'boolean'
|
||||
? null
|
||||
: false;
|
||||
} else {
|
||||
options[opt] = typeof marked.defaults[opt] !== 'boolean'
|
||||
? argv.shift()
|
||||
: true;
|
||||
}
|
||||
} else {
|
||||
files.push(arg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
async function getData() {
|
||||
if (!input) {
|
||||
if (files.length <= 2) {
|
||||
if (string) {
|
||||
return string;
|
||||
}
|
||||
return await getStdin();
|
||||
}
|
||||
input = files.pop();
|
||||
}
|
||||
return await readFile(input, 'utf8');
|
||||
}
|
||||
|
||||
function resolveFile(file) {
|
||||
return resolve(file.replace(/^~/, homedir));
|
||||
}
|
||||
|
||||
function fileExists(file) {
|
||||
return access(resolveFile(file)).then(() => true, () => false);
|
||||
}
|
||||
|
||||
async function runConfig(file) {
|
||||
const configFile = resolveFile(file);
|
||||
let markedConfig;
|
||||
try {
|
||||
// try require for json
|
||||
markedConfig = require(configFile);
|
||||
} catch (err) {
|
||||
if (err.code !== 'ERR_REQUIRE_ESM') {
|
||||
throw err;
|
||||
}
|
||||
// must import esm
|
||||
markedConfig = await import('file:///' + configFile);
|
||||
}
|
||||
|
||||
if (markedConfig.default) {
|
||||
markedConfig = markedConfig.default;
|
||||
}
|
||||
|
||||
if (typeof markedConfig === 'function') {
|
||||
markedConfig(marked);
|
||||
} else {
|
||||
marked.use(markedConfig);
|
||||
}
|
||||
}
|
||||
|
||||
const data = await getData();
|
||||
|
||||
if (config) {
|
||||
if (!await fileExists(config)) {
|
||||
throw Error(`Cannot load config file '${config}'`);
|
||||
}
|
||||
|
||||
await runConfig(config);
|
||||
} else {
|
||||
const defaultConfig = [
|
||||
'~/.marked.json',
|
||||
'~/.marked.js',
|
||||
'~/.marked/index.js'
|
||||
];
|
||||
|
||||
for (const configFile of defaultConfig) {
|
||||
if (await fileExists(configFile)) {
|
||||
await runConfig(configFile);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const html = tokens
|
||||
? JSON.stringify(marked.lexer(data, options), null, 2)
|
||||
: await marked.parse(data, options);
|
||||
|
||||
if (output) {
|
||||
if (noclobber && await fileExists(output)) {
|
||||
nodeProcess.stderr.write('marked: output file \'' + output + '\' already exists, disable the \'-n\' / \'--no-clobber\' flag to overwrite\n');
|
||||
nodeProcess.exit(1);
|
||||
}
|
||||
return await writeFile(output, html);
|
||||
}
|
||||
|
||||
nodeProcess.stdout.write(html + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helpers
|
||||
*/
|
||||
function getStdin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const stdin = nodeProcess.stdin;
|
||||
let buff = '';
|
||||
|
||||
stdin.setEncoding('utf8');
|
||||
|
||||
stdin.on('data', function(data) {
|
||||
buff += data;
|
||||
});
|
||||
|
||||
stdin.on('error', function(err) {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
stdin.on('end', function() {
|
||||
resolve(buff);
|
||||
});
|
||||
|
||||
stdin.resume();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text
|
||||
*/
|
||||
function camelize(text) {
|
||||
return text.replace(/(\w)-(\w)/g, function(_, a, b) {
|
||||
return a + b.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
await start(nodeProcess.argv.slice());
|
||||
nodeProcess.exit(0);
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
nodeProcess.stderr.write('marked: output to ' + err.path + ': No such directory');
|
||||
}
|
||||
nodeProcess.stderr.write(err);
|
||||
return nodeProcess.exit(1);
|
||||
}
|
||||
}
|
15
static/js/lib/node_modules/marked/bin/marked.js
generated
vendored
Executable file
15
static/js/lib/node_modules/marked/bin/marked.js
generated
vendored
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Marked CLI
|
||||
* Copyright (c) 2011-2013, Christopher Jeffrey (MIT License)
|
||||
*/
|
||||
|
||||
import { main } from './main.js';
|
||||
|
||||
/**
|
||||
* Expose / Entry Point
|
||||
*/
|
||||
|
||||
process.title = 'marked';
|
||||
main(process);
|
2442
static/js/lib/node_modules/marked/lib/marked.cjs
generated
vendored
Normal file
2442
static/js/lib/node_modules/marked/lib/marked.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
static/js/lib/node_modules/marked/lib/marked.cjs.map
generated
vendored
Normal file
1
static/js/lib/node_modules/marked/lib/marked.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
638
static/js/lib/node_modules/marked/lib/marked.d.cts
generated
vendored
Normal file
638
static/js/lib/node_modules/marked/lib/marked.d.cts
generated
vendored
Normal file
|
@ -0,0 +1,638 @@
|
|||
// Generated by dts-bundle-generator v9.0.0
|
||||
|
||||
export type Token = (Tokens.Space | Tokens.Code | Tokens.Heading | Tokens.Table | Tokens.Hr | Tokens.Blockquote | Tokens.List | Tokens.ListItem | Tokens.Paragraph | Tokens.HTML | Tokens.Text | Tokens.Def | Tokens.Escape | Tokens.Tag | Tokens.Image | Tokens.Link | Tokens.Strong | Tokens.Em | Tokens.Codespan | Tokens.Br | Tokens.Del | Tokens.Generic);
|
||||
export declare namespace Tokens {
|
||||
interface Space {
|
||||
type: "space";
|
||||
raw: string;
|
||||
}
|
||||
interface Code {
|
||||
type: "code";
|
||||
raw: string;
|
||||
codeBlockStyle?: "indented" | undefined;
|
||||
lang?: string | undefined;
|
||||
text: string;
|
||||
escaped?: boolean;
|
||||
}
|
||||
interface Heading {
|
||||
type: "heading";
|
||||
raw: string;
|
||||
depth: number;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Table {
|
||||
type: "table";
|
||||
raw: string;
|
||||
align: Array<"center" | "left" | "right" | null>;
|
||||
header: TableCell[];
|
||||
rows: TableCell[][];
|
||||
}
|
||||
interface TableCell {
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Hr {
|
||||
type: "hr";
|
||||
raw: string;
|
||||
}
|
||||
interface Blockquote {
|
||||
type: "blockquote";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface List {
|
||||
type: "list";
|
||||
raw: string;
|
||||
ordered: boolean;
|
||||
start: number | "";
|
||||
loose: boolean;
|
||||
items: ListItem[];
|
||||
}
|
||||
interface ListItem {
|
||||
type: "list_item";
|
||||
raw: string;
|
||||
task: boolean;
|
||||
checked?: boolean | undefined;
|
||||
loose: boolean;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Paragraph {
|
||||
type: "paragraph";
|
||||
raw: string;
|
||||
pre?: boolean | undefined;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface HTML {
|
||||
type: "html";
|
||||
raw: string;
|
||||
pre: boolean;
|
||||
text: string;
|
||||
block: boolean;
|
||||
}
|
||||
interface Text {
|
||||
type: "text";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens?: Token[];
|
||||
}
|
||||
interface Def {
|
||||
type: "def";
|
||||
raw: string;
|
||||
tag: string;
|
||||
href: string;
|
||||
title: string;
|
||||
}
|
||||
interface Escape {
|
||||
type: "escape";
|
||||
raw: string;
|
||||
text: string;
|
||||
}
|
||||
interface Tag {
|
||||
type: "text" | "html";
|
||||
raw: string;
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
text: string;
|
||||
block: boolean;
|
||||
}
|
||||
interface Link {
|
||||
type: "link";
|
||||
raw: string;
|
||||
href: string;
|
||||
title?: string | null;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Image {
|
||||
type: "image";
|
||||
raw: string;
|
||||
href: string;
|
||||
title: string | null;
|
||||
text: string;
|
||||
}
|
||||
interface Strong {
|
||||
type: "strong";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Em {
|
||||
type: "em";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Codespan {
|
||||
type: "codespan";
|
||||
raw: string;
|
||||
text: string;
|
||||
}
|
||||
interface Br {
|
||||
type: "br";
|
||||
raw: string;
|
||||
}
|
||||
interface Del {
|
||||
type: "del";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Generic {
|
||||
[index: string]: any;
|
||||
type: string;
|
||||
raw: string;
|
||||
tokens?: Token[] | undefined;
|
||||
}
|
||||
}
|
||||
export type Links = Record<string, Pick<Tokens.Link | Tokens.Image, "href" | "title">>;
|
||||
export type TokensList = Token[] & {
|
||||
links: Links;
|
||||
};
|
||||
declare class _Renderer {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
code(code: string, infostring: string | undefined, escaped: boolean): string;
|
||||
blockquote(quote: string): string;
|
||||
html(html: string, block?: boolean): string;
|
||||
heading(text: string, level: number, raw: string): string;
|
||||
hr(): string;
|
||||
list(body: string, ordered: boolean, start: number | ""): string;
|
||||
listitem(text: string, task: boolean, checked: boolean): string;
|
||||
checkbox(checked: boolean): string;
|
||||
paragraph(text: string): string;
|
||||
table(header: string, body: string): string;
|
||||
tablerow(content: string): string;
|
||||
tablecell(content: string, flags: {
|
||||
header: boolean;
|
||||
align: "center" | "left" | "right" | null;
|
||||
}): string;
|
||||
/**
|
||||
* span level renderer
|
||||
*/
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
br(): string;
|
||||
del(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
text(text: string): string;
|
||||
}
|
||||
declare class _TextRenderer {
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
del(text: string): string;
|
||||
html(text: string): string;
|
||||
text(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
br(): string;
|
||||
}
|
||||
declare class _Parser {
|
||||
options: MarkedOptions;
|
||||
renderer: _Renderer;
|
||||
textRenderer: _TextRenderer;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Static Parse Method
|
||||
*/
|
||||
static parse(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Static Parse Inline Method
|
||||
*/
|
||||
static parseInline(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Parse Loop
|
||||
*/
|
||||
parse(tokens: Token[], top?: boolean): string;
|
||||
/**
|
||||
* Parse Inline Tokens
|
||||
*/
|
||||
parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
|
||||
}
|
||||
declare const blockNormal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
export type BlockKeys = keyof typeof blockNormal;
|
||||
declare const inlineNormal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
export type InlineKeys = keyof typeof inlineNormal;
|
||||
/**
|
||||
* exports
|
||||
*/
|
||||
export declare const block: {
|
||||
normal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
};
|
||||
export declare const inline: {
|
||||
normal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
};
|
||||
export interface Rules {
|
||||
block: Record<BlockKeys, RegExp>;
|
||||
inline: Record<InlineKeys, RegExp>;
|
||||
}
|
||||
declare class _Tokenizer {
|
||||
options: MarkedOptions;
|
||||
rules: Rules;
|
||||
lexer: _Lexer;
|
||||
constructor(options?: MarkedOptions);
|
||||
space(src: string): Tokens.Space | undefined;
|
||||
code(src: string): Tokens.Code | undefined;
|
||||
fences(src: string): Tokens.Code | undefined;
|
||||
heading(src: string): Tokens.Heading | undefined;
|
||||
hr(src: string): Tokens.Hr | undefined;
|
||||
blockquote(src: string): Tokens.Blockquote | undefined;
|
||||
list(src: string): Tokens.List | undefined;
|
||||
html(src: string): Tokens.HTML | undefined;
|
||||
def(src: string): Tokens.Def | undefined;
|
||||
table(src: string): Tokens.Table | undefined;
|
||||
lheading(src: string): Tokens.Heading | undefined;
|
||||
paragraph(src: string): Tokens.Paragraph | undefined;
|
||||
text(src: string): Tokens.Text | undefined;
|
||||
escape(src: string): Tokens.Escape | undefined;
|
||||
tag(src: string): Tokens.Tag | undefined;
|
||||
link(src: string): Tokens.Link | Tokens.Image | undefined;
|
||||
reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Tokens.Text | undefined;
|
||||
emStrong(src: string, maskedSrc: string, prevChar?: string): Tokens.Em | Tokens.Strong | undefined;
|
||||
codespan(src: string): Tokens.Codespan | undefined;
|
||||
br(src: string): Tokens.Br | undefined;
|
||||
del(src: string): Tokens.Del | undefined;
|
||||
autolink(src: string): Tokens.Link | undefined;
|
||||
url(src: string): Tokens.Link | undefined;
|
||||
inlineText(src: string): Tokens.Text | undefined;
|
||||
}
|
||||
declare class _Hooks {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
static passThroughHooks: Set<string>;
|
||||
/**
|
||||
* Process markdown before marked
|
||||
*/
|
||||
preprocess(markdown: string): string;
|
||||
/**
|
||||
* Process HTML after marked is finished
|
||||
*/
|
||||
postprocess(html: string): string;
|
||||
/**
|
||||
* Process all tokens before walk tokens
|
||||
*/
|
||||
processAllTokens(tokens: Token[] | TokensList): Token[] | TokensList;
|
||||
}
|
||||
export interface TokenizerThis {
|
||||
lexer: _Lexer;
|
||||
}
|
||||
export type TokenizerExtensionFunction = (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | undefined;
|
||||
export type TokenizerStartFunction = (this: TokenizerThis, src: string) => number | void;
|
||||
export interface TokenizerExtension {
|
||||
name: string;
|
||||
level: "block" | "inline";
|
||||
start?: TokenizerStartFunction | undefined;
|
||||
tokenizer: TokenizerExtensionFunction;
|
||||
childTokens?: string[] | undefined;
|
||||
}
|
||||
export interface RendererThis {
|
||||
parser: _Parser;
|
||||
}
|
||||
export type RendererExtensionFunction = (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
|
||||
export interface RendererExtension {
|
||||
name: string;
|
||||
renderer: RendererExtensionFunction;
|
||||
}
|
||||
export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
|
||||
export type HooksApi = Omit<_Hooks, "constructor" | "options">;
|
||||
export type HooksObject = {
|
||||
[K in keyof HooksApi]?: (...args: Parameters<HooksApi[K]>) => ReturnType<HooksApi[K]> | Promise<ReturnType<HooksApi[K]>>;
|
||||
};
|
||||
export type RendererApi = Omit<_Renderer, "constructor" | "options">;
|
||||
export type RendererObject = {
|
||||
[K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false;
|
||||
};
|
||||
export type TokenizerApi = Omit<_Tokenizer, "constructor" | "options" | "rules" | "lexer">;
|
||||
export type TokenizerObject = {
|
||||
[K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false;
|
||||
};
|
||||
export interface MarkedExtension {
|
||||
/**
|
||||
* True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
|
||||
*/
|
||||
async?: boolean;
|
||||
/**
|
||||
* Enable GFM line breaks. This option requires the gfm option to be true.
|
||||
*/
|
||||
breaks?: boolean | undefined;
|
||||
/**
|
||||
* Add tokenizers and renderers to marked
|
||||
*/
|
||||
extensions?: TokenizerAndRendererExtension[] | undefined | null;
|
||||
/**
|
||||
* Enable GitHub flavored markdown.
|
||||
*/
|
||||
gfm?: boolean | undefined;
|
||||
/**
|
||||
* Hooks are methods that hook into some part of marked.
|
||||
* preprocess is called to process markdown before sending it to marked.
|
||||
* processAllTokens is called with the TokensList before walkTokens.
|
||||
* postprocess is called to process html after marked has finished parsing.
|
||||
*/
|
||||
hooks?: HooksObject | undefined | null;
|
||||
/**
|
||||
* Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
|
||||
*/
|
||||
pedantic?: boolean | undefined;
|
||||
/**
|
||||
* Type: object Default: new Renderer()
|
||||
*
|
||||
* An object containing functions to render tokens to HTML.
|
||||
*/
|
||||
renderer?: RendererObject | undefined | null;
|
||||
/**
|
||||
* Shows an HTML error message when rendering fails.
|
||||
*/
|
||||
silent?: boolean | undefined;
|
||||
/**
|
||||
* The tokenizer defines how to turn markdown text into tokens.
|
||||
*/
|
||||
tokenizer?: TokenizerObject | undefined | null;
|
||||
/**
|
||||
* The walkTokens function gets called with every token.
|
||||
* Child tokens are called before moving on to sibling tokens.
|
||||
* Each token is passed by reference so updates are persisted when passed to the parser.
|
||||
* The return value of the function is ignored.
|
||||
*/
|
||||
walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
|
||||
}
|
||||
export interface MarkedOptions extends Omit<MarkedExtension, "hooks" | "renderer" | "tokenizer" | "extensions" | "walkTokens"> {
|
||||
/**
|
||||
* Hooks are methods that hook into some part of marked.
|
||||
*/
|
||||
hooks?: _Hooks | undefined | null;
|
||||
/**
|
||||
* Type: object Default: new Renderer()
|
||||
*
|
||||
* An object containing functions to render tokens to HTML.
|
||||
*/
|
||||
renderer?: _Renderer | undefined | null;
|
||||
/**
|
||||
* The tokenizer defines how to turn markdown text into tokens.
|
||||
*/
|
||||
tokenizer?: _Tokenizer | undefined | null;
|
||||
/**
|
||||
* Custom extensions
|
||||
*/
|
||||
extensions?: null | {
|
||||
renderers: {
|
||||
[name: string]: RendererExtensionFunction;
|
||||
};
|
||||
childTokens: {
|
||||
[name: string]: string[];
|
||||
};
|
||||
inline?: TokenizerExtensionFunction[];
|
||||
block?: TokenizerExtensionFunction[];
|
||||
startInline?: TokenizerStartFunction[];
|
||||
startBlock?: TokenizerStartFunction[];
|
||||
};
|
||||
/**
|
||||
* walkTokens function returns array of values for Promise.all
|
||||
*/
|
||||
walkTokens?: null | ((token: Token) => void | Promise<void> | (void | Promise<void>)[]);
|
||||
}
|
||||
declare class _Lexer {
|
||||
tokens: TokensList;
|
||||
options: MarkedOptions;
|
||||
state: {
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
top: boolean;
|
||||
};
|
||||
private tokenizer;
|
||||
private inlineQueue;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Expose Rules
|
||||
*/
|
||||
static get rules(): {
|
||||
block: {
|
||||
normal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
};
|
||||
inline: {
|
||||
normal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Static Lex Method
|
||||
*/
|
||||
static lex(src: string, options?: MarkedOptions): TokensList;
|
||||
/**
|
||||
* Static Lex Inline Method
|
||||
*/
|
||||
static lexInline(src: string, options?: MarkedOptions): Token[];
|
||||
/**
|
||||
* Preprocessing
|
||||
*/
|
||||
lex(src: string): TokensList;
|
||||
/**
|
||||
* Lexing
|
||||
*/
|
||||
blockTokens(src: string, tokens?: Token[]): Token[];
|
||||
blockTokens(src: string, tokens?: TokensList): TokensList;
|
||||
inline(src: string, tokens?: Token[]): Token[];
|
||||
/**
|
||||
* Lexing/Compiling
|
||||
*/
|
||||
inlineTokens(src: string, tokens?: Token[]): Token[];
|
||||
}
|
||||
declare function _getDefaults(): MarkedOptions;
|
||||
declare let _defaults: MarkedOptions;
|
||||
export type MaybePromise = void | Promise<void>;
|
||||
export declare class Marked {
|
||||
#private;
|
||||
defaults: MarkedOptions;
|
||||
options: (opt: MarkedOptions) => this;
|
||||
parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
||||
parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
||||
Parser: typeof _Parser;
|
||||
Renderer: typeof _Renderer;
|
||||
TextRenderer: typeof _TextRenderer;
|
||||
Lexer: typeof _Lexer;
|
||||
Tokenizer: typeof _Tokenizer;
|
||||
Hooks: typeof _Hooks;
|
||||
constructor(...args: MarkedExtension[]);
|
||||
/**
|
||||
* Run callback for every token
|
||||
*/
|
||||
walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
|
||||
use(...args: MarkedExtension[]): this;
|
||||
setOptions(opt: MarkedOptions): this;
|
||||
lexer(src: string, options?: MarkedOptions): TokensList;
|
||||
parser(tokens: Token[], options?: MarkedOptions): string;
|
||||
}
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options, having async: true
|
||||
* @return Promise of string of compiled HTML
|
||||
*/
|
||||
export declare function marked(src: string, options: MarkedOptions & {
|
||||
async: true;
|
||||
}): Promise<string>;
|
||||
/**
|
||||
* Compiles markdown to HTML.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Optional hash of options
|
||||
* @return String of compiled HTML. Wil be a Promise of string if async is set to true by any extensions.
|
||||
*/
|
||||
export declare function marked(src: string, options?: MarkedOptions): string | Promise<string>;
|
||||
export declare namespace marked {
|
||||
var options: (options: MarkedOptions) => typeof marked;
|
||||
var setOptions: (options: MarkedOptions) => typeof marked;
|
||||
var getDefaults: typeof _getDefaults;
|
||||
var defaults: MarkedOptions;
|
||||
var use: (...args: MarkedExtension[]) => typeof marked;
|
||||
var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
||||
var parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
||||
var Parser: typeof _Parser;
|
||||
var parser: typeof _Parser.parse;
|
||||
var Renderer: typeof _Renderer;
|
||||
var TextRenderer: typeof _TextRenderer;
|
||||
var Lexer: typeof _Lexer;
|
||||
var lexer: typeof _Lexer.lex;
|
||||
var Tokenizer: typeof _Tokenizer;
|
||||
var Hooks: typeof _Hooks;
|
||||
var parse: typeof marked;
|
||||
}
|
||||
export declare const options: (options: MarkedOptions) => typeof marked;
|
||||
export declare const setOptions: (options: MarkedOptions) => typeof marked;
|
||||
export declare const use: (...args: MarkedExtension[]) => typeof marked;
|
||||
export declare const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
||||
export declare const parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
||||
export declare const parse: typeof marked;
|
||||
export declare const parser: typeof _Parser.parse;
|
||||
export declare const lexer: typeof _Lexer.lex;
|
||||
|
||||
export {
|
||||
_Hooks as Hooks,
|
||||
_Lexer as Lexer,
|
||||
_Parser as Parser,
|
||||
_Renderer as Renderer,
|
||||
_TextRenderer as TextRenderer,
|
||||
_Tokenizer as Tokenizer,
|
||||
_defaults as defaults,
|
||||
_getDefaults as getDefaults,
|
||||
};
|
||||
|
||||
export {};
|
638
static/js/lib/node_modules/marked/lib/marked.d.ts
generated
vendored
Normal file
638
static/js/lib/node_modules/marked/lib/marked.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,638 @@
|
|||
// Generated by dts-bundle-generator v9.0.0
|
||||
|
||||
export type Token = (Tokens.Space | Tokens.Code | Tokens.Heading | Tokens.Table | Tokens.Hr | Tokens.Blockquote | Tokens.List | Tokens.ListItem | Tokens.Paragraph | Tokens.HTML | Tokens.Text | Tokens.Def | Tokens.Escape | Tokens.Tag | Tokens.Image | Tokens.Link | Tokens.Strong | Tokens.Em | Tokens.Codespan | Tokens.Br | Tokens.Del | Tokens.Generic);
|
||||
export declare namespace Tokens {
|
||||
interface Space {
|
||||
type: "space";
|
||||
raw: string;
|
||||
}
|
||||
interface Code {
|
||||
type: "code";
|
||||
raw: string;
|
||||
codeBlockStyle?: "indented" | undefined;
|
||||
lang?: string | undefined;
|
||||
text: string;
|
||||
escaped?: boolean;
|
||||
}
|
||||
interface Heading {
|
||||
type: "heading";
|
||||
raw: string;
|
||||
depth: number;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Table {
|
||||
type: "table";
|
||||
raw: string;
|
||||
align: Array<"center" | "left" | "right" | null>;
|
||||
header: TableCell[];
|
||||
rows: TableCell[][];
|
||||
}
|
||||
interface TableCell {
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Hr {
|
||||
type: "hr";
|
||||
raw: string;
|
||||
}
|
||||
interface Blockquote {
|
||||
type: "blockquote";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface List {
|
||||
type: "list";
|
||||
raw: string;
|
||||
ordered: boolean;
|
||||
start: number | "";
|
||||
loose: boolean;
|
||||
items: ListItem[];
|
||||
}
|
||||
interface ListItem {
|
||||
type: "list_item";
|
||||
raw: string;
|
||||
task: boolean;
|
||||
checked?: boolean | undefined;
|
||||
loose: boolean;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Paragraph {
|
||||
type: "paragraph";
|
||||
raw: string;
|
||||
pre?: boolean | undefined;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface HTML {
|
||||
type: "html";
|
||||
raw: string;
|
||||
pre: boolean;
|
||||
text: string;
|
||||
block: boolean;
|
||||
}
|
||||
interface Text {
|
||||
type: "text";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens?: Token[];
|
||||
}
|
||||
interface Def {
|
||||
type: "def";
|
||||
raw: string;
|
||||
tag: string;
|
||||
href: string;
|
||||
title: string;
|
||||
}
|
||||
interface Escape {
|
||||
type: "escape";
|
||||
raw: string;
|
||||
text: string;
|
||||
}
|
||||
interface Tag {
|
||||
type: "text" | "html";
|
||||
raw: string;
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
text: string;
|
||||
block: boolean;
|
||||
}
|
||||
interface Link {
|
||||
type: "link";
|
||||
raw: string;
|
||||
href: string;
|
||||
title?: string | null;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Image {
|
||||
type: "image";
|
||||
raw: string;
|
||||
href: string;
|
||||
title: string | null;
|
||||
text: string;
|
||||
}
|
||||
interface Strong {
|
||||
type: "strong";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Em {
|
||||
type: "em";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Codespan {
|
||||
type: "codespan";
|
||||
raw: string;
|
||||
text: string;
|
||||
}
|
||||
interface Br {
|
||||
type: "br";
|
||||
raw: string;
|
||||
}
|
||||
interface Del {
|
||||
type: "del";
|
||||
raw: string;
|
||||
text: string;
|
||||
tokens: Token[];
|
||||
}
|
||||
interface Generic {
|
||||
[index: string]: any;
|
||||
type: string;
|
||||
raw: string;
|
||||
tokens?: Token[] | undefined;
|
||||
}
|
||||
}
|
||||
export type Links = Record<string, Pick<Tokens.Link | Tokens.Image, "href" | "title">>;
|
||||
export type TokensList = Token[] & {
|
||||
links: Links;
|
||||
};
|
||||
declare class _Renderer {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
code(code: string, infostring: string | undefined, escaped: boolean): string;
|
||||
blockquote(quote: string): string;
|
||||
html(html: string, block?: boolean): string;
|
||||
heading(text: string, level: number, raw: string): string;
|
||||
hr(): string;
|
||||
list(body: string, ordered: boolean, start: number | ""): string;
|
||||
listitem(text: string, task: boolean, checked: boolean): string;
|
||||
checkbox(checked: boolean): string;
|
||||
paragraph(text: string): string;
|
||||
table(header: string, body: string): string;
|
||||
tablerow(content: string): string;
|
||||
tablecell(content: string, flags: {
|
||||
header: boolean;
|
||||
align: "center" | "left" | "right" | null;
|
||||
}): string;
|
||||
/**
|
||||
* span level renderer
|
||||
*/
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
br(): string;
|
||||
del(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
text(text: string): string;
|
||||
}
|
||||
declare class _TextRenderer {
|
||||
strong(text: string): string;
|
||||
em(text: string): string;
|
||||
codespan(text: string): string;
|
||||
del(text: string): string;
|
||||
html(text: string): string;
|
||||
text(text: string): string;
|
||||
link(href: string, title: string | null | undefined, text: string): string;
|
||||
image(href: string, title: string | null, text: string): string;
|
||||
br(): string;
|
||||
}
|
||||
declare class _Parser {
|
||||
options: MarkedOptions;
|
||||
renderer: _Renderer;
|
||||
textRenderer: _TextRenderer;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Static Parse Method
|
||||
*/
|
||||
static parse(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Static Parse Inline Method
|
||||
*/
|
||||
static parseInline(tokens: Token[], options?: MarkedOptions): string;
|
||||
/**
|
||||
* Parse Loop
|
||||
*/
|
||||
parse(tokens: Token[], top?: boolean): string;
|
||||
/**
|
||||
* Parse Inline Tokens
|
||||
*/
|
||||
parseInline(tokens: Token[], renderer?: _Renderer | _TextRenderer): string;
|
||||
}
|
||||
declare const blockNormal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
export type BlockKeys = keyof typeof blockNormal;
|
||||
declare const inlineNormal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
export type InlineKeys = keyof typeof inlineNormal;
|
||||
/**
|
||||
* exports
|
||||
*/
|
||||
export declare const block: {
|
||||
normal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
};
|
||||
export declare const inline: {
|
||||
normal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
};
|
||||
export interface Rules {
|
||||
block: Record<BlockKeys, RegExp>;
|
||||
inline: Record<InlineKeys, RegExp>;
|
||||
}
|
||||
declare class _Tokenizer {
|
||||
options: MarkedOptions;
|
||||
rules: Rules;
|
||||
lexer: _Lexer;
|
||||
constructor(options?: MarkedOptions);
|
||||
space(src: string): Tokens.Space | undefined;
|
||||
code(src: string): Tokens.Code | undefined;
|
||||
fences(src: string): Tokens.Code | undefined;
|
||||
heading(src: string): Tokens.Heading | undefined;
|
||||
hr(src: string): Tokens.Hr | undefined;
|
||||
blockquote(src: string): Tokens.Blockquote | undefined;
|
||||
list(src: string): Tokens.List | undefined;
|
||||
html(src: string): Tokens.HTML | undefined;
|
||||
def(src: string): Tokens.Def | undefined;
|
||||
table(src: string): Tokens.Table | undefined;
|
||||
lheading(src: string): Tokens.Heading | undefined;
|
||||
paragraph(src: string): Tokens.Paragraph | undefined;
|
||||
text(src: string): Tokens.Text | undefined;
|
||||
escape(src: string): Tokens.Escape | undefined;
|
||||
tag(src: string): Tokens.Tag | undefined;
|
||||
link(src: string): Tokens.Link | Tokens.Image | undefined;
|
||||
reflink(src: string, links: Links): Tokens.Link | Tokens.Image | Tokens.Text | undefined;
|
||||
emStrong(src: string, maskedSrc: string, prevChar?: string): Tokens.Em | Tokens.Strong | undefined;
|
||||
codespan(src: string): Tokens.Codespan | undefined;
|
||||
br(src: string): Tokens.Br | undefined;
|
||||
del(src: string): Tokens.Del | undefined;
|
||||
autolink(src: string): Tokens.Link | undefined;
|
||||
url(src: string): Tokens.Link | undefined;
|
||||
inlineText(src: string): Tokens.Text | undefined;
|
||||
}
|
||||
declare class _Hooks {
|
||||
options: MarkedOptions;
|
||||
constructor(options?: MarkedOptions);
|
||||
static passThroughHooks: Set<string>;
|
||||
/**
|
||||
* Process markdown before marked
|
||||
*/
|
||||
preprocess(markdown: string): string;
|
||||
/**
|
||||
* Process HTML after marked is finished
|
||||
*/
|
||||
postprocess(html: string): string;
|
||||
/**
|
||||
* Process all tokens before walk tokens
|
||||
*/
|
||||
processAllTokens(tokens: Token[] | TokensList): Token[] | TokensList;
|
||||
}
|
||||
export interface TokenizerThis {
|
||||
lexer: _Lexer;
|
||||
}
|
||||
export type TokenizerExtensionFunction = (this: TokenizerThis, src: string, tokens: Token[] | TokensList) => Tokens.Generic | undefined;
|
||||
export type TokenizerStartFunction = (this: TokenizerThis, src: string) => number | void;
|
||||
export interface TokenizerExtension {
|
||||
name: string;
|
||||
level: "block" | "inline";
|
||||
start?: TokenizerStartFunction | undefined;
|
||||
tokenizer: TokenizerExtensionFunction;
|
||||
childTokens?: string[] | undefined;
|
||||
}
|
||||
export interface RendererThis {
|
||||
parser: _Parser;
|
||||
}
|
||||
export type RendererExtensionFunction = (this: RendererThis, token: Tokens.Generic) => string | false | undefined;
|
||||
export interface RendererExtension {
|
||||
name: string;
|
||||
renderer: RendererExtensionFunction;
|
||||
}
|
||||
export type TokenizerAndRendererExtension = TokenizerExtension | RendererExtension | (TokenizerExtension & RendererExtension);
|
||||
export type HooksApi = Omit<_Hooks, "constructor" | "options">;
|
||||
export type HooksObject = {
|
||||
[K in keyof HooksApi]?: (...args: Parameters<HooksApi[K]>) => ReturnType<HooksApi[K]> | Promise<ReturnType<HooksApi[K]>>;
|
||||
};
|
||||
export type RendererApi = Omit<_Renderer, "constructor" | "options">;
|
||||
export type RendererObject = {
|
||||
[K in keyof RendererApi]?: (...args: Parameters<RendererApi[K]>) => ReturnType<RendererApi[K]> | false;
|
||||
};
|
||||
export type TokenizerApi = Omit<_Tokenizer, "constructor" | "options" | "rules" | "lexer">;
|
||||
export type TokenizerObject = {
|
||||
[K in keyof TokenizerApi]?: (...args: Parameters<TokenizerApi[K]>) => ReturnType<TokenizerApi[K]> | false;
|
||||
};
|
||||
export interface MarkedExtension {
|
||||
/**
|
||||
* True will tell marked to await any walkTokens functions before parsing the tokens and returning an HTML string.
|
||||
*/
|
||||
async?: boolean;
|
||||
/**
|
||||
* Enable GFM line breaks. This option requires the gfm option to be true.
|
||||
*/
|
||||
breaks?: boolean | undefined;
|
||||
/**
|
||||
* Add tokenizers and renderers to marked
|
||||
*/
|
||||
extensions?: TokenizerAndRendererExtension[] | undefined | null;
|
||||
/**
|
||||
* Enable GitHub flavored markdown.
|
||||
*/
|
||||
gfm?: boolean | undefined;
|
||||
/**
|
||||
* Hooks are methods that hook into some part of marked.
|
||||
* preprocess is called to process markdown before sending it to marked.
|
||||
* processAllTokens is called with the TokensList before walkTokens.
|
||||
* postprocess is called to process html after marked has finished parsing.
|
||||
*/
|
||||
hooks?: HooksObject | undefined | null;
|
||||
/**
|
||||
* Conform to obscure parts of markdown.pl as much as possible. Don't fix any of the original markdown bugs or poor behavior.
|
||||
*/
|
||||
pedantic?: boolean | undefined;
|
||||
/**
|
||||
* Type: object Default: new Renderer()
|
||||
*
|
||||
* An object containing functions to render tokens to HTML.
|
||||
*/
|
||||
renderer?: RendererObject | undefined | null;
|
||||
/**
|
||||
* Shows an HTML error message when rendering fails.
|
||||
*/
|
||||
silent?: boolean | undefined;
|
||||
/**
|
||||
* The tokenizer defines how to turn markdown text into tokens.
|
||||
*/
|
||||
tokenizer?: TokenizerObject | undefined | null;
|
||||
/**
|
||||
* The walkTokens function gets called with every token.
|
||||
* Child tokens are called before moving on to sibling tokens.
|
||||
* Each token is passed by reference so updates are persisted when passed to the parser.
|
||||
* The return value of the function is ignored.
|
||||
*/
|
||||
walkTokens?: ((token: Token) => void | Promise<void>) | undefined | null;
|
||||
}
|
||||
export interface MarkedOptions extends Omit<MarkedExtension, "hooks" | "renderer" | "tokenizer" | "extensions" | "walkTokens"> {
|
||||
/**
|
||||
* Hooks are methods that hook into some part of marked.
|
||||
*/
|
||||
hooks?: _Hooks | undefined | null;
|
||||
/**
|
||||
* Type: object Default: new Renderer()
|
||||
*
|
||||
* An object containing functions to render tokens to HTML.
|
||||
*/
|
||||
renderer?: _Renderer | undefined | null;
|
||||
/**
|
||||
* The tokenizer defines how to turn markdown text into tokens.
|
||||
*/
|
||||
tokenizer?: _Tokenizer | undefined | null;
|
||||
/**
|
||||
* Custom extensions
|
||||
*/
|
||||
extensions?: null | {
|
||||
renderers: {
|
||||
[name: string]: RendererExtensionFunction;
|
||||
};
|
||||
childTokens: {
|
||||
[name: string]: string[];
|
||||
};
|
||||
inline?: TokenizerExtensionFunction[];
|
||||
block?: TokenizerExtensionFunction[];
|
||||
startInline?: TokenizerStartFunction[];
|
||||
startBlock?: TokenizerStartFunction[];
|
||||
};
|
||||
/**
|
||||
* walkTokens function returns array of values for Promise.all
|
||||
*/
|
||||
walkTokens?: null | ((token: Token) => void | Promise<void> | (void | Promise<void>)[]);
|
||||
}
|
||||
declare class _Lexer {
|
||||
tokens: TokensList;
|
||||
options: MarkedOptions;
|
||||
state: {
|
||||
inLink: boolean;
|
||||
inRawBlock: boolean;
|
||||
top: boolean;
|
||||
};
|
||||
private tokenizer;
|
||||
private inlineQueue;
|
||||
constructor(options?: MarkedOptions);
|
||||
/**
|
||||
* Expose Rules
|
||||
*/
|
||||
static get rules(): {
|
||||
block: {
|
||||
normal: {
|
||||
blockquote: RegExp;
|
||||
code: RegExp;
|
||||
def: RegExp;
|
||||
fences: RegExp;
|
||||
heading: RegExp;
|
||||
hr: RegExp;
|
||||
html: RegExp;
|
||||
lheading: RegExp;
|
||||
list: RegExp;
|
||||
newline: RegExp;
|
||||
paragraph: RegExp;
|
||||
table: RegExp;
|
||||
text: RegExp;
|
||||
};
|
||||
gfm: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
pedantic: Record<"code" | "blockquote" | "hr" | "html" | "table" | "text" | "heading" | "list" | "paragraph" | "def" | "fences" | "lheading" | "newline", RegExp>;
|
||||
};
|
||||
inline: {
|
||||
normal: {
|
||||
_backpedal: RegExp;
|
||||
anyPunctuation: RegExp;
|
||||
autolink: RegExp;
|
||||
blockSkip: RegExp;
|
||||
br: RegExp;
|
||||
code: RegExp;
|
||||
del: RegExp;
|
||||
emStrongLDelim: RegExp;
|
||||
emStrongRDelimAst: RegExp;
|
||||
emStrongRDelimUnd: RegExp;
|
||||
escape: RegExp;
|
||||
link: RegExp;
|
||||
nolink: RegExp;
|
||||
punctuation: RegExp;
|
||||
reflink: RegExp;
|
||||
reflinkSearch: RegExp;
|
||||
tag: RegExp;
|
||||
text: RegExp;
|
||||
url: RegExp;
|
||||
};
|
||||
gfm: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
breaks: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
pedantic: Record<"link" | "code" | "url" | "br" | "del" | "text" | "escape" | "tag" | "reflink" | "autolink" | "nolink" | "_backpedal" | "anyPunctuation" | "blockSkip" | "emStrongLDelim" | "emStrongRDelimAst" | "emStrongRDelimUnd" | "punctuation" | "reflinkSearch", RegExp>;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Static Lex Method
|
||||
*/
|
||||
static lex(src: string, options?: MarkedOptions): TokensList;
|
||||
/**
|
||||
* Static Lex Inline Method
|
||||
*/
|
||||
static lexInline(src: string, options?: MarkedOptions): Token[];
|
||||
/**
|
||||
* Preprocessing
|
||||
*/
|
||||
lex(src: string): TokensList;
|
||||
/**
|
||||
* Lexing
|
||||
*/
|
||||
blockTokens(src: string, tokens?: Token[]): Token[];
|
||||
blockTokens(src: string, tokens?: TokensList): TokensList;
|
||||
inline(src: string, tokens?: Token[]): Token[];
|
||||
/**
|
||||
* Lexing/Compiling
|
||||
*/
|
||||
inlineTokens(src: string, tokens?: Token[]): Token[];
|
||||
}
|
||||
declare function _getDefaults(): MarkedOptions;
|
||||
declare let _defaults: MarkedOptions;
|
||||
export type MaybePromise = void | Promise<void>;
|
||||
export declare class Marked {
|
||||
#private;
|
||||
defaults: MarkedOptions;
|
||||
options: (opt: MarkedOptions) => this;
|
||||
parse: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
||||
parseInline: (src: string, options?: MarkedOptions | undefined | null) => string | Promise<string>;
|
||||
Parser: typeof _Parser;
|
||||
Renderer: typeof _Renderer;
|
||||
TextRenderer: typeof _TextRenderer;
|
||||
Lexer: typeof _Lexer;
|
||||
Tokenizer: typeof _Tokenizer;
|
||||
Hooks: typeof _Hooks;
|
||||
constructor(...args: MarkedExtension[]);
|
||||
/**
|
||||
* Run callback for every token
|
||||
*/
|
||||
walkTokens(tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]): MaybePromise[];
|
||||
use(...args: MarkedExtension[]): this;
|
||||
setOptions(opt: MarkedOptions): this;
|
||||
lexer(src: string, options?: MarkedOptions): TokensList;
|
||||
parser(tokens: Token[], options?: MarkedOptions): string;
|
||||
}
|
||||
/**
|
||||
* Compiles markdown to HTML asynchronously.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Hash of options, having async: true
|
||||
* @return Promise of string of compiled HTML
|
||||
*/
|
||||
export declare function marked(src: string, options: MarkedOptions & {
|
||||
async: true;
|
||||
}): Promise<string>;
|
||||
/**
|
||||
* Compiles markdown to HTML.
|
||||
*
|
||||
* @param src String of markdown source to be compiled
|
||||
* @param options Optional hash of options
|
||||
* @return String of compiled HTML. Wil be a Promise of string if async is set to true by any extensions.
|
||||
*/
|
||||
export declare function marked(src: string, options?: MarkedOptions): string | Promise<string>;
|
||||
export declare namespace marked {
|
||||
var options: (options: MarkedOptions) => typeof marked;
|
||||
var setOptions: (options: MarkedOptions) => typeof marked;
|
||||
var getDefaults: typeof _getDefaults;
|
||||
var defaults: MarkedOptions;
|
||||
var use: (...args: MarkedExtension[]) => typeof marked;
|
||||
var walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
||||
var parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
||||
var Parser: typeof _Parser;
|
||||
var parser: typeof _Parser.parse;
|
||||
var Renderer: typeof _Renderer;
|
||||
var TextRenderer: typeof _TextRenderer;
|
||||
var Lexer: typeof _Lexer;
|
||||
var lexer: typeof _Lexer.lex;
|
||||
var Tokenizer: typeof _Tokenizer;
|
||||
var Hooks: typeof _Hooks;
|
||||
var parse: typeof marked;
|
||||
}
|
||||
export declare const options: (options: MarkedOptions) => typeof marked;
|
||||
export declare const setOptions: (options: MarkedOptions) => typeof marked;
|
||||
export declare const use: (...args: MarkedExtension[]) => typeof marked;
|
||||
export declare const walkTokens: (tokens: Token[] | TokensList, callback: (token: Token) => MaybePromise | MaybePromise[]) => MaybePromise[];
|
||||
export declare const parseInline: (src: string, options?: MarkedOptions | null | undefined) => string | Promise<string>;
|
||||
export declare const parse: typeof marked;
|
||||
export declare const parser: typeof _Parser.parse;
|
||||
export declare const lexer: typeof _Lexer.lex;
|
||||
|
||||
export {
|
||||
_Hooks as Hooks,
|
||||
_Lexer as Lexer,
|
||||
_Parser as Parser,
|
||||
_Renderer as Renderer,
|
||||
_TextRenderer as TextRenderer,
|
||||
_Tokenizer as Tokenizer,
|
||||
_defaults as defaults,
|
||||
_getDefaults as getDefaults,
|
||||
};
|
||||
|
||||
export {};
|
2424
static/js/lib/node_modules/marked/lib/marked.esm.js
generated
vendored
Normal file
2424
static/js/lib/node_modules/marked/lib/marked.esm.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
static/js/lib/node_modules/marked/lib/marked.esm.js.map
generated
vendored
Normal file
1
static/js/lib/node_modules/marked/lib/marked.esm.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2448
static/js/lib/node_modules/marked/lib/marked.umd.js
generated
vendored
Normal file
2448
static/js/lib/node_modules/marked/lib/marked.umd.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
1
static/js/lib/node_modules/marked/lib/marked.umd.js.map
generated
vendored
Normal file
1
static/js/lib/node_modules/marked/lib/marked.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
111
static/js/lib/node_modules/marked/man/marked.1
generated
vendored
Normal file
111
static/js/lib/node_modules/marked/man/marked.1
generated
vendored
Normal file
|
@ -0,0 +1,111 @@
|
|||
.TH "MARKED" "1" "December 2023" "11.1.0"
|
||||
.SH "NAME"
|
||||
\fBmarked\fR \- a javascript markdown parser
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
\fBmarked\fP [\fB\-o\fP <output file>] [\fB\-i\fP <input file>] [\fB\-s\fP <markdown string>] [\fB\-c\fP <config file>] [\fB\-\-help\fP] [\fB\-\-version\fP] [\fB\-\-tokens\fP] [\fB\-\-no\-clobber\fP] [\fB\-\-pedantic\fP] [\fB\-\-gfm\fP] [\fB\-\-breaks\fP] [\fB\-\-no\-etc\.\.\.\fP] [\fB\-\-silent\fP] [filename]
|
||||
.SH DESCRIPTION
|
||||
.P
|
||||
marked is a full\-featured javascript markdown parser, built for speed\.
|
||||
.br
|
||||
It also includes multiple GFM features\.
|
||||
.SH EXAMPLES
|
||||
.RS 2
|
||||
.nf
|
||||
cat in\.md | marked > out\.html
|
||||
.fi
|
||||
.RE
|
||||
.RS 2
|
||||
.nf
|
||||
echo "hello *world*" | marked
|
||||
.fi
|
||||
.RE
|
||||
.RS 2
|
||||
.nf
|
||||
marked \-o out\.html \-i in\.md \-\-gfm
|
||||
.fi
|
||||
.RE
|
||||
.RS 2
|
||||
.nf
|
||||
marked \-\-output="hello world\.html" \-i in\.md \-\-no\-breaks
|
||||
.fi
|
||||
.RE
|
||||
.SH OPTIONS
|
||||
|
||||
.RS 1
|
||||
.IP \(bu 2
|
||||
\-o, \-\-output [output file]
|
||||
.br
|
||||
Specify file output\. If none is specified, write to stdout\.
|
||||
.IP \(bu 2
|
||||
\-i, \-\-input [input file]
|
||||
.br
|
||||
Specify file input, otherwise use last argument as input file\.
|
||||
.br
|
||||
If no input file is specified, read from stdin\.
|
||||
.IP \(bu 2
|
||||
\-s, \-\-string [markdown string]
|
||||
.br
|
||||
Specify string input instead of a file\.
|
||||
.IP \(bu 2
|
||||
\-c, \-\-config [config file]
|
||||
.br
|
||||
Specify config file to use instead of the default \fB~/\.marked\.json\fP or \fB~/\.marked\.js\fP or \fB~/\.marked/index\.js\fP\|\.
|
||||
.IP \(bu 2
|
||||
\-t, \-\-tokens
|
||||
.br
|
||||
Output a token list instead of html\.
|
||||
.IP \(bu 2
|
||||
\-n, \-\-no\-clobber
|
||||
.br
|
||||
Do not overwrite \fBoutput\fP if it exists\.
|
||||
.IP \(bu 2
|
||||
\-\-pedantic
|
||||
.br
|
||||
Conform to obscure parts of markdown\.pl as much as possible\.
|
||||
.br
|
||||
Don't fix original markdown bugs\.
|
||||
.IP \(bu 2
|
||||
\-\-gfm
|
||||
.br
|
||||
Enable github flavored markdown\.
|
||||
.IP \(bu 2
|
||||
\-\-breaks
|
||||
.br
|
||||
Enable GFM line breaks\. Only works with the gfm option\.
|
||||
.IP \(bu 2
|
||||
\-\-no\-breaks, \-no\-etc\.\.\.
|
||||
.br
|
||||
The inverse of any of the marked options above\.
|
||||
.IP \(bu 2
|
||||
\-\-silent
|
||||
.br
|
||||
Silence error output\.
|
||||
.IP \(bu 2
|
||||
\-h, \-\-help
|
||||
.br
|
||||
Display help information\.
|
||||
|
||||
.RE
|
||||
.SH CONFIGURATION
|
||||
.P
|
||||
For configuring and running programmatically\.
|
||||
.P
|
||||
Example
|
||||
.RS 2
|
||||
.nf
|
||||
import { Marked } from 'marked';
|
||||
const marked = new Marked({ gfm: true });
|
||||
marked\.parse('*foo*');
|
||||
.fi
|
||||
.RE
|
||||
.SH BUGS
|
||||
.P
|
||||
Please report any bugs to https://github.com/markedjs/marked
|
||||
.SH LICENSE
|
||||
.P
|
||||
Copyright (c) 2011\-2014, Christopher Jeffrey (MIT License)\.
|
||||
.SH SEE ALSO
|
||||
.P
|
||||
markdown(1), nodejs(1)
|
||||
|
92
static/js/lib/node_modules/marked/man/marked.1.md
generated
vendored
Normal file
92
static/js/lib/node_modules/marked/man/marked.1.md
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
# marked(1) -- a javascript markdown parser
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
`marked` [`-o` <output file>] [`-i` <input file>] [`-s` <markdown string>] [`-c` <config file>] [`--help`] [`--version`] [`--tokens`] [`--no-clobber`] [`--pedantic`] [`--gfm`] [`--breaks`] [`--no-etc...`] [`--silent`] [filename]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
marked is a full-featured javascript markdown parser, built for speed.
|
||||
It also includes multiple GFM features.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
```sh
|
||||
cat in.md | marked > out.html
|
||||
```
|
||||
|
||||
```sh
|
||||
echo "hello *world*" | marked
|
||||
```
|
||||
|
||||
```sh
|
||||
marked -o out.html -i in.md --gfm
|
||||
```
|
||||
|
||||
```sh
|
||||
marked --output="hello world.html" -i in.md --no-breaks
|
||||
```
|
||||
|
||||
## OPTIONS
|
||||
|
||||
* -o, --output [output file]
|
||||
Specify file output. If none is specified, write to stdout.
|
||||
|
||||
* -i, --input [input file]
|
||||
Specify file input, otherwise use last argument as input file.
|
||||
If no input file is specified, read from stdin.
|
||||
|
||||
* -s, --string [markdown string]
|
||||
Specify string input instead of a file.
|
||||
|
||||
* -c, --config [config file]
|
||||
Specify config file to use instead of the default `~/.marked.json` or `~/.marked.js` or `~/.marked/index.js`.
|
||||
|
||||
* -t, --tokens
|
||||
Output a token list instead of html.
|
||||
|
||||
* -n, --no-clobber
|
||||
Do not overwrite `output` if it exists.
|
||||
|
||||
* --pedantic
|
||||
Conform to obscure parts of markdown.pl as much as possible.
|
||||
Don't fix original markdown bugs.
|
||||
|
||||
* --gfm
|
||||
Enable github flavored markdown.
|
||||
|
||||
* --breaks
|
||||
Enable GFM line breaks. Only works with the gfm option.
|
||||
|
||||
* --no-breaks, -no-etc...
|
||||
The inverse of any of the marked options above.
|
||||
|
||||
* --silent
|
||||
Silence error output.
|
||||
|
||||
* -h, --help
|
||||
Display help information.
|
||||
|
||||
## CONFIGURATION
|
||||
|
||||
For configuring and running programmatically.
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
import { Marked } from 'marked';
|
||||
const marked = new Marked({ gfm: true });
|
||||
marked.parse('*foo*');
|
||||
```
|
||||
|
||||
## BUGS
|
||||
|
||||
Please report any bugs to <https://github.com/markedjs/marked>.
|
||||
|
||||
## LICENSE
|
||||
|
||||
Copyright (c) 2011-2014, Christopher Jeffrey (MIT License).
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
markdown(1), nodejs(1)
|
6
static/js/lib/node_modules/marked/marked.min.js
generated
vendored
Normal file
6
static/js/lib/node_modules/marked/marked.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
108
static/js/lib/node_modules/marked/package.json
generated
vendored
Normal file
108
static/js/lib/node_modules/marked/package.json
generated
vendored
Normal file
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"name": "marked",
|
||||
"description": "A markdown parser built for speed",
|
||||
"author": "Christopher Jeffrey",
|
||||
"version": "11.1.1",
|
||||
"type": "module",
|
||||
"main": "./lib/marked.cjs",
|
||||
"module": "./lib/marked.esm.js",
|
||||
"browser": "./lib/marked.umd.js",
|
||||
"types": "./lib/marked.d.ts",
|
||||
"bin": {
|
||||
"marked": "bin/marked.js"
|
||||
},
|
||||
"man": "./man/marked.1",
|
||||
"files": [
|
||||
"bin/",
|
||||
"lib/",
|
||||
"man/",
|
||||
"marked.min.js"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./lib/marked.d.ts",
|
||||
"default": "./lib/marked.esm.js"
|
||||
},
|
||||
"default": {
|
||||
"types": "./lib/marked.d.cts",
|
||||
"default": "./lib/marked.cjs"
|
||||
}
|
||||
},
|
||||
"./bin/marked": "./bin/marked.js",
|
||||
"./marked.min.js": "./marked.min.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"repository": "git://github.com/markedjs/marked.git",
|
||||
"homepage": "https://marked.js.org",
|
||||
"bugs": {
|
||||
"url": "http://github.com/markedjs/marked/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"markdown",
|
||||
"markup",
|
||||
"html"
|
||||
],
|
||||
"tags": [
|
||||
"markdown",
|
||||
"markup",
|
||||
"html"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@markedjs/testutils": "9.1.5-0",
|
||||
"@arethetypeswrong/cli": "^0.13.5",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"@rollup/plugin-typescript": "^11.1.5",
|
||||
"@semantic-release/commit-analyzer": "^11.1.0",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@semantic-release/github": "^9.2.6",
|
||||
"@semantic-release/npm": "^11.0.2",
|
||||
"@semantic-release/release-notes-generator": "^12.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
||||
"@typescript-eslint/parser": "^6.13.2",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"commonmark": "0.30.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"dts-bundle-generator": "^9.0.0",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-standard": "^17.1.0",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
"eslint-plugin-n": "^16.5.0",
|
||||
"eslint-plugin-promise": "^6.1.1",
|
||||
"highlight.js": "^11.9.0",
|
||||
"markdown-it": "13.0.2",
|
||||
"marked-highlight": "^2.1.0",
|
||||
"marked-man": "^2.0.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"recheck": "^4.4.5",
|
||||
"rollup": "^4.9.1",
|
||||
"semantic-release": "^22.0.12",
|
||||
"titleize": "^4.0.0",
|
||||
"ts-expect": "^1.3.0",
|
||||
"typescript": "5.3.3"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "npm run build && npm run test:specs && npm run test:unit",
|
||||
"test:all": "npm test && npm run test:umd && npm run test:types && npm run test:lint",
|
||||
"test:unit": "node --test --test-reporter=spec test/unit",
|
||||
"test:specs": "node --test --test-reporter=spec test/run-spec-tests.js",
|
||||
"test:lint": "eslint .",
|
||||
"test:redos": "node test/recheck.js > vuln.js",
|
||||
"test:types": "tsc --project tsconfig-type-test.json && attw -P --exclude-entrypoints ./bin/marked ./marked.min.js",
|
||||
"test:umd": "node test/umd-test.js",
|
||||
"test:update": "node test/update-specs.js",
|
||||
"rules": "node test/rules.js",
|
||||
"bench": "npm run build && node test/bench.js",
|
||||
"lint": "eslint --fix .",
|
||||
"build:reset": "git checkout upstream/master lib/marked.cjs lib/marked.umd.js lib/marked.esm.js marked.min.js",
|
||||
"build": "npm run rollup && npm run build:types && npm run build:man",
|
||||
"build:docs": "npm run build && node docs/build.js",
|
||||
"build:types": "tsc && dts-bundle-generator --project tsconfig.json -o lib/marked.d.ts src/marked.ts && dts-bundle-generator --project tsconfig.json -o lib/marked.d.cts src/marked.ts",
|
||||
"build:man": "marked-man man/marked.1.md > man/marked.1",
|
||||
"rollup": "rollup -c rollup.config.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
}
|
23
static/js/lib/package-lock.json
generated
Normal file
23
static/js/lib/package-lock.json
generated
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "lib",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"marked": "^11.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/marked": {
|
||||
"version": "11.1.1",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-11.1.1.tgz",
|
||||
"integrity": "sha512-EgxRjgK9axsQuUa/oKMx5DEY8oXpKJfk61rT5iY3aRlgU6QJtUcxU5OAymdhCvWvhYcd9FKmO5eQoX8m9VGJXg==",
|
||||
"bin": {
|
||||
"marked": "bin/marked.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
5
static/js/lib/package.json
Normal file
5
static/js/lib/package.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"marked": "^11.1.1"
|
||||
}
|
||||
}
|
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
2574
static/js/lib/sjcl.js
Normal file
2574
static/js/lib/sjcl.js
Normal file
File diff suppressed because it is too large
Load diff
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
|
||||
lessc $< $@
|
||||
|
||||
all: $(css)
|
||||
|
||||
clean:
|
||||
rm -vf $(css)
|
19
static/less/loop_make.sh
Executable file
19
static/less/loop_make.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
|
||||
while true
|
||||
do
|
||||
# inotifywait -q -e MOVE_SELF *less
|
||||
inotifywait -q -e MODIFY *less
|
||||
#sleep 0.5
|
||||
clear
|
||||
|
||||
for THEME in $(ls theme-*.less | sed -e 's/^theme-\(.*\)\.less$/\1/'); do
|
||||
export THEME=$THEME
|
||||
make -j12
|
||||
#curl -s http://notes.lan:1371/_ws/css_update
|
||||
done
|
||||
echo -e "\n\e[32;1mOK!\e[0m"
|
||||
sleep 1
|
||||
clear
|
||||
|
||||
done
|
17
static/less/main.less
Normal file
17
static/less/main.less
Normal file
|
@ -0,0 +1,17 @@
|
|||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
*:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
[onClick] {
|
||||
cursor: pointer;
|
||||
}
|
45
static/service_worker.js
Normal file
45
static/service_worker.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
const CACHE_NAME = 'notes2-{{ .VERSION }}'
|
||||
const CACHED_ASSETS = [
|
||||
'/',
|
||||
'/js/{{ .VERSION }}/app.mjs',
|
||||
]
|
||||
|
||||
async function precache() {
|
||||
const cache = await caches.open(CACHE_NAME)
|
||||
return cache.addAll(CACHED_ASSETS)
|
||||
}
|
||||
|
||||
async function fetchAsset(event) {
|
||||
try {
|
||||
return await fetch(event.request)
|
||||
} catch (e) {
|
||||
const cache = await caches.open(CACHE_NAME)
|
||||
return cache.match(event.request)
|
||||
}
|
||||
}
|
||||
|
||||
async function cleanupCache() {
|
||||
const keys = await caches.keys()
|
||||
const keysToDelete = keys.map(key => {
|
||||
if (key !== CACHE_NAME)
|
||||
return caches.delete(key)
|
||||
})
|
||||
return Promise.all(keysToDelete)
|
||||
}
|
||||
|
||||
self.addEventListener('install', event => {
|
||||
console.log('SERVICE WORKER: install')
|
||||
self.skipWaiting()
|
||||
event.waitUntil(precache())
|
||||
})
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
console.log('SERVICE WORKER: activate')
|
||||
self.clients.claim()
|
||||
event.waitUntil(cleanupCache())
|
||||
})
|
||||
|
||||
self.addEventListener('fetch', event => {
|
||||
//console.log('SERVICE WORKER: fetch')
|
||||
event.respondWith(fetchAsset(event))
|
||||
})
|
45
views/layouts/main.gotmpl
Normal file
45
views/layouts/main.gotmpl
Normal file
|
@ -0,0 +1,45 @@
|
|||
<!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">
|
||||
<script>
|
||||
window._VERSION = "{{ .VERSION }}"
|
||||
|
||||
if (navigator.serviceWorker)
|
||||
navigator.serviceWorker.register('/service_worker.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",
|
||||
"session": "/js/{{ .VERSION }}/session.mjs",
|
||||
"node": "/js/{{ .VERSION }}/node.mjs",
|
||||
"node_store": "/js/{{ .VERSION }}/node_store.mjs",
|
||||
"key": "/js/{{ .VERSION }}/key.mjs",
|
||||
"crypto": "/js/{{ .VERSION }}/crypto.mjs",
|
||||
"checklist": "/js/{{ .VERSION }}/checklist.mjs",
|
||||
"ws": "/_js/{{ .VERSION }}/websocket.mjs"
|
||||
*/
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/sjcl.js"></script>
|
||||
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/node_modules/marked/marked.min.js"></script>
|
||||
<script type="text/javascript" src="/js/{{ .VERSION }}/lib/fullcalendar.min.js"></script>
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="app">{{ block "page" . }}{{ end }}</div>
|
||||
</body>
|
||||
</html>
|
3
views/pages/index.gotmpl
Normal file
3
views/pages/index.gotmpl
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{ define "page" }}
|
||||
<script type="module" src="/js/{{ .VERSION }}/app.mjs"></script>
|
||||
{{ end }}
|
Loading…
Add table
Reference in a new issue