Compare commits
5 Commits
50a77995bc
...
a052fbb0cb
Author | SHA1 | Date |
---|---|---|
|
a052fbb0cb | |
|
704dd66415 | |
|
1c023a6ef8 | |
|
b6b02bf71a | |
|
4ed90b0e02 |
10
lock.json
10
lock.json
|
@ -52,12 +52,12 @@
|
||||||
"packages": [
|
"packages": [
|
||||||
"preserves"
|
"preserves"
|
||||||
],
|
],
|
||||||
"path": "/nix/store/6nnn5di5vip1vladlb7z56rbw18d1y7j-source",
|
"path": "/nix/store/fpkhfxnfbdcri6k7mac21r3byg738bs4-source",
|
||||||
"ref": "20240208",
|
"ref": "20240108",
|
||||||
"rev": "2825bceecf33a15b9b7942db5331a32cbc39b281",
|
"rev": "a01ba8c96d65f670862ba074bf82b50cbda6ed99",
|
||||||
"sha256": "145vf46fy3wc52j6vs509fm9bi5lx7c53gskbkpcfbkv82l86dgk",
|
"sha256": "0n8pghy2qfywx0psr54yzjvhdhi5av204150jyyzfxhigczd8sr4",
|
||||||
"srcDir": "src",
|
"srcDir": "src",
|
||||||
"url": "https://git.syndicate-lang.org/ehmry/preserves-nim/archive/2825bceecf33a15b9b7942db5331a32cbc39b281.tar.gz"
|
"url": "https://git.syndicate-lang.org/ehmry/preserves-nim/archive/a01ba8c96d65f670862ba074bf82b50cbda6ed99.tar.gz"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{ pkgs ? import <nixpkgs> { } }:
|
let pkgs = import <nixpkgs> { };
|
||||||
pkgs.buildNimPackage {
|
in pkgs.buildNimPackage {
|
||||||
name = "dummy";
|
name = "noiseprotocol";
|
||||||
|
buildInputs = [ pkgs.noise-c ];
|
||||||
lockFile = ./lock.json;
|
lockFile = ./lock.json;
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,7 @@ proc match(bindings: var Bindings; p: Pattern; v: Value): bool =
|
||||||
of PatternKind.Patom:
|
of PatternKind.Patom:
|
||||||
result = case p.patom
|
result = case p.patom
|
||||||
of PAtom.Boolean: v.isBoolean
|
of PAtom.Boolean: v.isBoolean
|
||||||
|
of PAtom.Float: v.isFloat
|
||||||
of PAtom.Double: v.isDouble
|
of PAtom.Double: v.isDouble
|
||||||
of PAtom.Signedinteger: v.isInteger
|
of PAtom.Signedinteger: v.isInteger
|
||||||
of PAtom.String: v.isString
|
of PAtom.String: v.isString
|
||||||
|
|
|
@ -70,7 +70,9 @@ proc grab*(pr: Value): Pattern =
|
||||||
of pkBoolean:
|
of pkBoolean:
|
||||||
AnyAtom(orKind: AnyAtomKind.`bool`, bool: pr.bool).toPattern
|
AnyAtom(orKind: AnyAtomKind.`bool`, bool: pr.bool).toPattern
|
||||||
of pkFloat:
|
of pkFloat:
|
||||||
AnyAtom(orKind: AnyAtomKind.`double`, double: pr.float).toPattern
|
AnyAtom(orKind: AnyAtomKind.`float`, float: pr.float).toPattern
|
||||||
|
of pkDouble:
|
||||||
|
AnyAtom(orKind: AnyAtomKind.`double`, double: pr.double).toPattern
|
||||||
of pkRegister:
|
of pkRegister:
|
||||||
AnyAtom(orKind: AnyAtomKind.`int`, int: pr.register).toPattern
|
AnyAtom(orKind: AnyAtomKind.`int`, int: pr.register).toPattern
|
||||||
of pkString:
|
of pkString:
|
||||||
|
|
|
@ -6,7 +6,6 @@ modules += http.nim
|
||||||
modules += noise.nim
|
modules += noise.nim
|
||||||
modules += protocol.nim
|
modules += protocol.nim
|
||||||
modules += service.nim
|
modules += service.nim
|
||||||
modules += stdenv.nim
|
|
||||||
modules += stream.nim
|
modules += stream.nim
|
||||||
modules += sturdy.nim
|
modules += sturdy.nim
|
||||||
modules += tcp.nim
|
modules += tcp.nim
|
||||||
|
|
|
@ -4,14 +4,17 @@ import
|
||||||
|
|
||||||
type
|
type
|
||||||
AnyAtomKind* {.pure.} = enum
|
AnyAtomKind* {.pure.} = enum
|
||||||
`bool`, `double`, `int`, `string`, `bytes`, `symbol`, `embedded`
|
`bool`, `float`, `double`, `int`, `string`, `bytes`, `symbol`, `embedded`
|
||||||
`AnyAtom`* {.preservesOr.} = object
|
`AnyAtom`* {.preservesOr.} = object
|
||||||
case orKind*: AnyAtomKind
|
case orKind*: AnyAtomKind
|
||||||
of AnyAtomKind.`bool`:
|
of AnyAtomKind.`bool`:
|
||||||
`bool`*: bool
|
`bool`*: bool
|
||||||
|
|
||||||
|
of AnyAtomKind.`float`:
|
||||||
|
`float`*: float32
|
||||||
|
|
||||||
of AnyAtomKind.`double`:
|
of AnyAtomKind.`double`:
|
||||||
`double`*: float
|
`double`*: float64
|
||||||
|
|
||||||
of AnyAtomKind.`int`:
|
of AnyAtomKind.`int`:
|
||||||
`int`*: BiggestInt
|
`int`*: BiggestInt
|
||||||
|
|
|
@ -8,18 +8,18 @@ type
|
||||||
`detail`*: Value
|
`detail`*: Value
|
||||||
|
|
||||||
Turn* = seq[TurnEvent]
|
Turn* = seq[TurnEvent]
|
||||||
Message* {.preservesRecord: "M".} = object
|
Message* {.preservesRecord: "message".} = object
|
||||||
`body`*: Assertion
|
`body`*: Assertion
|
||||||
|
|
||||||
Retract* {.preservesRecord: "R".} = object
|
Retract* {.preservesRecord: "retract".} = object
|
||||||
`handle`*: Handle
|
`handle`*: Handle
|
||||||
|
|
||||||
Assert* {.preservesRecord: "A".} = object
|
Assert* {.preservesRecord: "assert".} = object
|
||||||
`assertion`*: Assertion
|
`assertion`*: Assertion
|
||||||
`handle`*: Handle
|
`handle`*: Handle
|
||||||
|
|
||||||
Extension* = Value
|
Extension* = Value
|
||||||
Sync* {.preservesRecord: "S".} = object
|
Sync* {.preservesRecord: "sync".} = object
|
||||||
`peer`* {.preservesEmbedded.}: Value
|
`peer`* {.preservesEmbedded.}: Value
|
||||||
|
|
||||||
TurnEvent* {.preservesTuple.} = object
|
TurnEvent* {.preservesTuple.} = object
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
|
|
||||||
import
|
|
||||||
preserves, sturdy, gatekeeper
|
|
||||||
|
|
||||||
type
|
|
||||||
StandardTransportKind* {.pure.} = enum
|
|
||||||
`wsUrl`, `other`
|
|
||||||
`StandardTransport`* {.preservesOr.} = object
|
|
||||||
case orKind*: StandardTransportKind
|
|
||||||
of StandardTransportKind.`wsUrl`:
|
|
||||||
`wsurl`*: string
|
|
||||||
|
|
||||||
of StandardTransportKind.`other`:
|
|
||||||
`other`*: Value
|
|
||||||
|
|
||||||
|
|
||||||
StandardRouteKind* {.pure.} = enum
|
|
||||||
`standard`, `general`
|
|
||||||
StandardRouteStandard* {.preservesTuple.} = object
|
|
||||||
`transports`*: seq[StandardTransport]
|
|
||||||
`key`*: seq[byte]
|
|
||||||
`service`*: Value
|
|
||||||
`sig`*: seq[byte]
|
|
||||||
`oid`*: Value
|
|
||||||
`caveats`* {.preservesTupleTail.}: seq[sturdy.Caveat]
|
|
||||||
|
|
||||||
`StandardRoute`* {.preservesOr.} = object
|
|
||||||
case orKind*: StandardRouteKind
|
|
||||||
of StandardRouteKind.`standard`:
|
|
||||||
`standard`*: StandardRouteStandard
|
|
||||||
|
|
||||||
of StandardRouteKind.`general`:
|
|
||||||
`general`*: gatekeeper.Route
|
|
||||||
|
|
||||||
|
|
||||||
proc `$`*(x: StandardTransport | StandardRoute): string =
|
|
||||||
`$`(toPreserves(x))
|
|
||||||
|
|
||||||
proc encode*(x: StandardTransport | StandardRoute): seq[byte] =
|
|
||||||
encode(toPreserves(x))
|
|
|
@ -107,7 +107,8 @@ type
|
||||||
|
|
||||||
SturdyPathStepDetail* = Parameters
|
SturdyPathStepDetail* = Parameters
|
||||||
`PAtom`* {.preservesOr, pure.} = enum
|
`PAtom`* {.preservesOr, pure.} = enum
|
||||||
`Boolean`, `Double`, `SignedInteger`, `String`, `ByteString`, `Symbol`
|
`Boolean`, `Float`, `Double`, `SignedInteger`, `String`, `ByteString`,
|
||||||
|
`Symbol`
|
||||||
PDiscard* {.preservesRecord: "_".} = object
|
PDiscard* {.preservesRecord: "_".} = object
|
||||||
|
|
||||||
TemplateKind* {.pure.} = enum
|
TemplateKind* {.pure.} = enum
|
||||||
|
|
|
@ -5,17 +5,17 @@ import
|
||||||
type
|
type
|
||||||
TimerExpired* {.preservesRecord: "timer-expired".} = object
|
TimerExpired* {.preservesRecord: "timer-expired".} = object
|
||||||
`label`*: Value
|
`label`*: Value
|
||||||
`seconds`*: float
|
`seconds`*: float64
|
||||||
|
|
||||||
SetTimer* {.preservesRecord: "set-timer".} = object
|
SetTimer* {.preservesRecord: "set-timer".} = object
|
||||||
`label`*: Value
|
`label`*: Value
|
||||||
`seconds`*: float
|
`seconds`*: float64
|
||||||
`kind`*: TimerKind
|
`kind`*: TimerKind
|
||||||
|
|
||||||
`TimerKind`* {.preservesOr, pure.} = enum
|
`TimerKind`* {.preservesOr, pure.} = enum
|
||||||
`relative`, `absolute`, `clear`
|
`relative`, `absolute`, `clear`
|
||||||
LaterThan* {.preservesRecord: "later-than".} = object
|
LaterThan* {.preservesRecord: "later-than".} = object
|
||||||
`seconds`*: float
|
`seconds`*: float64
|
||||||
|
|
||||||
proc `$`*(x: TimerExpired | SetTimer | LaterThan): string =
|
proc `$`*(x: TimerExpired | SetTimer | LaterThan): string =
|
||||||
`$`(toPreserves(x))
|
`$`(toPreserves(x))
|
||||||
|
|
|
@ -86,11 +86,11 @@ type
|
||||||
`reason`*: LinkedTaskReleaseReason
|
`reason`*: LinkedTaskReleaseReason
|
||||||
|
|
||||||
TurnCausePeriodicActivation* {.preservesRecord: "periodic-activation".} = object
|
TurnCausePeriodicActivation* {.preservesRecord: "periodic-activation".} = object
|
||||||
`period`*: float
|
`period`*: float64
|
||||||
|
|
||||||
TurnCauseDelay* {.preservesRecord: "delay".} = object
|
TurnCauseDelay* {.preservesRecord: "delay".} = object
|
||||||
`causingTurn`*: TurnId
|
`causingTurn`*: TurnId
|
||||||
`amount`*: float
|
`amount`*: float64
|
||||||
|
|
||||||
TurnCauseExternal* {.preservesRecord: "external".} = object
|
TurnCauseExternal* {.preservesRecord: "external".} = object
|
||||||
`description`*: Value
|
`description`*: Value
|
||||||
|
@ -170,7 +170,7 @@ type
|
||||||
|
|
||||||
|
|
||||||
TraceEntry* {.preservesRecord: "trace".} = object
|
TraceEntry* {.preservesRecord: "trace".} = object
|
||||||
`timestamp`*: float
|
`timestamp`*: float64
|
||||||
`actor`*: ActorId
|
`actor`*: ActorId
|
||||||
`item`*: ActorActivation
|
`item`*: ActorActivation
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "20240208"
|
version = "20240120"
|
||||||
author = "Emery Hemingway"
|
author = "Emery Hemingway"
|
||||||
description = "Syndicated actors for conversational concurrency"
|
description = "Syndicated actors for conversational concurrency"
|
||||||
license = "Unlicense"
|
license = "Unlicense"
|
||||||
|
@ -9,4 +9,4 @@ srcDir = "src"
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
requires "https://github.com/ehmry/hashlib.git#f9455d4be988e14e3dc7933eb7cc7d7c4820b7ac", "nim >= 2.0.0", "https://git.syndicate-lang.org/ehmry/preserves-nim.git >= 20240208"
|
requires "https://github.com/ehmry/hashlib.git#f9455d4be988e14e3dc7933eb7cc7d7c4820b7ac", "nim >= 2.0.0", "https://git.syndicate-lang.org/ehmry/preserves-nim.git >= 20240116"
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
#!/usr/bin/env spry
|
||||||
|
|
||||||
|
title = "Simple Chat Demo"
|
||||||
|
|
||||||
|
# Initialize libui
|
||||||
|
uiInit
|
||||||
|
|
||||||
|
username = "user"
|
||||||
|
|
||||||
|
menu = newMenu "Menu"
|
||||||
|
|
||||||
|
# menu addItem: "Username" onClicked: [
|
||||||
|
# dialog = newWindow: "Username" width: 200 height: 40 hasBar: false
|
||||||
|
# entry = newEntryText: username onChanged: []
|
||||||
|
# quitit = newButton: "Quit" onClicked: [
|
||||||
|
# destroy dialog
|
||||||
|
# true
|
||||||
|
# ]
|
||||||
|
# layout = newHorizontalBox
|
||||||
|
# #layout add: entry stretch: true
|
||||||
|
# layout.add: quitit stretch: false
|
||||||
|
# group = newGroup "Username"
|
||||||
|
# group setChild: layout
|
||||||
|
# dialog setChild: quitit
|
||||||
|
# dialog show
|
||||||
|
# ]
|
||||||
|
|
||||||
|
menu menuAppendAboutItem
|
||||||
|
|
||||||
|
menu addQuitItemShouldClose: [
|
||||||
|
win destroy
|
||||||
|
uiQuit
|
||||||
|
true
|
||||||
|
]
|
||||||
|
|
||||||
|
# Create a new Window
|
||||||
|
win = newWindow: title width: 640 height: 400 hasBar: true
|
||||||
|
win margined: true
|
||||||
|
|
||||||
|
# create text boxes
|
||||||
|
scrollback = newMultilineEntryText
|
||||||
|
scrollback readonly: true
|
||||||
|
|
||||||
|
sendEntry = newMultilineEntryText
|
||||||
|
|
||||||
|
# create layouts
|
||||||
|
layout = newVerticalBox
|
||||||
|
sendBox = newHorizontalBox
|
||||||
|
|
||||||
|
# Some buttons and their handlers
|
||||||
|
sendButton = newButton: "Send" onClicked: [
|
||||||
|
msg = (sendEntry text)
|
||||||
|
msg != "" then: [
|
||||||
|
scrollback addText: (msg, "\x0a")
|
||||||
|
sendEntry text: ""
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
# Group
|
||||||
|
group = newGroup "Workspace"
|
||||||
|
group margined: false
|
||||||
|
group setChild: layout
|
||||||
|
|
||||||
|
sendBox add: sendEntry stretch: true
|
||||||
|
sendBox add: sendButton stretch: false
|
||||||
|
|
||||||
|
# Put things in the boxes
|
||||||
|
layout padded: true
|
||||||
|
layout add: scrollback stretch: true
|
||||||
|
layout add: sendBox stretch: false
|
||||||
|
|
||||||
|
# Add box to window
|
||||||
|
win setChild: group
|
||||||
|
|
||||||
|
# Set initial text
|
||||||
|
sendEntry text: "compose a message here"
|
||||||
|
|
||||||
|
# Close handler
|
||||||
|
closeHandler = [
|
||||||
|
win destroy
|
||||||
|
uiQuit
|
||||||
|
true
|
||||||
|
]
|
||||||
|
|
||||||
|
# Set a handler on closing window
|
||||||
|
win onClosingShouldClose: [ true ]
|
||||||
|
|
||||||
|
# Show the window
|
||||||
|
win show
|
||||||
|
|
||||||
|
# Enter libui's event loop
|
||||||
|
uiMain
|
Loading…
Reference in New Issue