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"> <link href="style.css" rel="stylesheet">
<script src="node_modules/@preserves/core/dist/preserves.js"></script> <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/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="node_modules/@syndicate-lang/ws-relay/dist/syndicate-ws-relay.js"></script>
<script src="index.js"></script> <script src="index.js"></script>
</head> </head>

View File

@ -14,7 +14,7 @@
"dependencies": { "dependencies": {
"@preserves/core": "0.995.0", "@preserves/core": "0.995.0",
"@syndicate-lang/core": "*", "@syndicate-lang/core": "*",
"@syndicate-lang/html": "*", "@syndicate-lang/html2": "*",
"@syndicate-lang/ws-relay": "*" "@syndicate-lang/ws-relay": "*"
}, },
"scripts": { "scripts": {
@ -26,6 +26,6 @@
"rollup": "rollup -c", "rollup": "rollup -c",
"rollup:watch": "rollup -c -w", "rollup:watch": "rollup -c -w",
"clean": "rm -rf lib/ src.ts/ src/gen/ index.js index.js.map", "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: [ external: [
'@preserves/core', '@preserves/core',
'@syndicate-lang/core', '@syndicate-lang/core',
'@syndicate-lang/html', '@syndicate-lang/html2',
'@syndicate-lang/ws-relay', '@syndicate-lang/ws-relay',
], ],
output: { output: {
@ -20,7 +20,7 @@ export default {
globals: { globals: {
'@preserves/core': 'Preserves', '@preserves/core': 'Preserves',
'@syndicate-lang/core': 'Syndicate', '@syndicate-lang/core': 'Syndicate',
'@syndicate-lang/html': 'SyndicateHtml', '@syndicate-lang/html2': 'SyndicateHtml2',
'@syndicate-lang/ws-relay': 'SyndicateWsRelay', '@syndicate-lang/ws-relay': 'SyndicateWsRelay',
}, },
}, },

View File

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

View File

@ -1,12 +1,18 @@
; Start the server with # Start the server with
; #
; syndicate-server -c ./syndicate-server.config.pr # syndicate-server -c ./syndicate-server.config.pr
;--------------------------------------------------------------------------- # ---------------------------------------------------------------------------
; Expose the gatekeeper on port 9001: # Expose the gatekeeper and HTTP on port 8000:
<require-service <relay-listener <tcp "0.0.0.0" 9001> $gatekeeper>> <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 <require-service <http-static-files "." 0>>
; empty secret key: ? <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 let ?ds = dataspace
<bind <ref {oid: "syndicate" key: #x""}> $ds #f> <bind <ref {oid: "syndicate" key: #x""}> $ds #f>