Dust off the @syndicate-lang/create template

This commit is contained in:
Tony Garnock-Jones 2024-03-10 14:50:28 +01:00
parent 502c0fd286
commit 61997473a3
6 changed files with 26 additions and 46 deletions

View File

@ -1,22 +0,0 @@
((typescript-mode
. ((eval
. (progn
;; For TIDE:
(setq tide-tsserver-executable
(concat
(let ((d (dir-locals-find-file ".")))
(if (stringp d) d (car d)))
"node_modules/typescript/lib/tsserver.js"))
;; For LSP:
(require 'lsp-javascript)
(let ((node-modules (concat
(let ((d (dir-locals-find-file ".")))
(if (stringp d) d (car d)))
"node_modules/")))
(lsp-dependency 'typescript-language-server
`(:system ,(concat node-modules
"typescript-language-server/lib/cli.mjs")))
(lsp-dependency 'typescript
`(:system ,(concat node-modules
"typescript/lib/tsserver.js")))))
))))

View File

@ -6,7 +6,7 @@
<link href="style.css" rel="stylesheet">
<script src="node_modules/@preserves/core/dist/preserves.js"></script>
<script src="node_modules/@syndicate-lang/core/dist/syndicate.js"></script>
<script src="node_modules/@syndicate-lang/html/dist/syndicate-html.js"></script>
<script src="node_modules/@syndicate-lang/html2/dist/syndicate-html2.js"></script>
<script src="node_modules/@syndicate-lang/ws-relay/dist/syndicate-ws-relay.js"></script>
<script src="index.js"></script>
</head>

View File

@ -14,7 +14,7 @@
"dependencies": {
"@preserves/core": "0.995.0",
"@syndicate-lang/core": "*",
"@syndicate-lang/html": "*",
"@syndicate-lang/html2": "*",
"@syndicate-lang/ws-relay": "*"
},
"scripts": {
@ -26,6 +26,6 @@
"rollup": "rollup -c",
"rollup:watch": "rollup -c -w",
"clean": "rm -rf lib/ src.ts/ src/gen/ index.js index.js.map",
"serve": "python -m http.server"
"serve": "syndicate-server -c syndicate-server.config.pr"
}
}

View File

@ -9,7 +9,7 @@ export default {
external: [
'@preserves/core',
'@syndicate-lang/core',
'@syndicate-lang/html',
'@syndicate-lang/html2',
'@syndicate-lang/ws-relay',
],
output: {
@ -20,7 +20,7 @@ export default {
globals: {
'@preserves/core': 'Preserves',
'@syndicate-lang/core': 'Syndicate',
'@syndicate-lang/html': 'SyndicateHtml',
'@syndicate-lang/html2': 'SyndicateHtml2',
'@syndicate-lang/ws-relay': 'SyndicateWsRelay',
},
},

View File

@ -2,14 +2,14 @@
/// SPDX-FileCopyrightText: Copyright © 2023-2024 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
import { Dataspace, Ref, Sturdy, Reader, Schemas, Embedded, randomId, fromJS } from "@syndicate-lang/core";
import html from "@syndicate-lang/html";
import { boot as bootHtml, Widget } from "@syndicate-lang/html2";
import wsRelay from "@syndicate-lang/ws-relay";
import { ExampleDefinition } from './gen/example';
import G = Schemas.gatekeeper;
export function main() {
Dataspace.boot(ds => {
html.boot(ds);
bootHtml(ds);
wsRelay.boot(ds, true /* remove this `true` to turn off client/server debug logging */);
bootApp(ds);
});
@ -19,7 +19,7 @@ function bootApp(ds: Ref) {
spawn named 'app' {
at ds {
/*
* This example expects a syndicate-server instance running on port 9001 on the
* This example expects a syndicate-server instance running on port 8000 on the
* server hosting index.html, exposing a dataspace entity via a capability called
* `"syndicate"` with empty "secret". See syndicate-server.config.pr.
*/
@ -28,7 +28,7 @@ function bootApp(ds: Ref) {
const route = G.Route<Ref>({
"transports": [fromJS(Schemas.transportAddress.WebSocket(
`ws://${document.location.hostname}:9001/`))],
`ws://${document.location.hostname}:8000/`))],
"pathSteps": [G.asPathStep(fromJS(Sturdy.asSturdyRef(
new Reader<Ref>(
'<ref {oid: "syndicate" sig: #[acowDB2/oI+6aSEC3YIxGg==]}>').next())))],
@ -42,13 +42,9 @@ function bootApp(ds: Ref) {
at remoteDs {
assert ExampleDefinition(this_instance);
during ExampleDefinition($who: string) => {
const ui = new html.Anchor();
at ds {
assert ui.html(
'#main',
html.template`<p>We see <span class="example-definition">${who}</span></p>`,
who);
}
new Widget(t =>
t`<p>We see <span class="example-definition">${who}</span></p>`)
.setParent('#main');
}
}
}

View File

@ -1,12 +1,18 @@
; Start the server with
;
; syndicate-server -c ./syndicate-server.config.pr
;---------------------------------------------------------------------------
# Start the server with
#
# syndicate-server -c ./syndicate-server.config.pr
# ---------------------------------------------------------------------------
; Expose the gatekeeper on port 9001:
<require-service <relay-listener <tcp "0.0.0.0" 9001> $gatekeeper>>
# Expose the gatekeeper and HTTP on port 8000:
<require-service <relay-listener <tcp "0.0.0.0" 8000> $gatekeeper $config>>
<require-service <http-router $config>>
; Create a dataspace entity, and register it with the gatekeeper with name `"syndicate"` and an
; empty secret key:
<require-service <http-static-files "." 0>>
? <service-object <http-static-files "." 0> ?handler> [
$config += <http-bind #f 8000 get [...] $handler>
]
# Create a dataspace entity, and register it with the gatekeeper with name `"syndicate"` and an
# empty secret key:
let ?ds = dataspace
<bind <ref {oid: "syndicate" key: #x""}> $ds #f>