Skip to content

Commit 51911af

Browse files
authored
Merge pull request #24 from commontoolsinc/feat/2024-06-04-lookslike-integration
Lookslike + Code Sandbox
2 parents 81f7c8e + f0d9719 commit 51911af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5497
-134
lines changed

docs/usuba.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Local Usuba Setup
2+
3+
Install some environment dependencies:
4+
5+
```sh
6+
cargo install wit-deps-cli wasm-tools
7+
rustup target add wasm32-wasi wasm32-unknown-unknown
8+
9+
npm install -g @bytecodealliance/jco
10+
npm install -g @bytecodealliance/componentize-js
11+
12+
pip install componentize-py
13+
```
14+
15+
On a Mac, also do this also:
16+
17+
```sh
18+
brew install wget gsed
19+
```
20+
21+
Set up an NPM project (using whatever stack) in `/typescript/packages` and add `@commontools/runtime` to your dependencies:
22+
23+
```sh
24+
mkdir -p ./typescript/packages/my-project
25+
cd ./typescript/packages/my-project
26+
27+
# Actually, better to copy a package.json from another package
28+
echo '{"type": "module"}' > ./package.json
29+
npm install --save @commontools/runtime
30+
```
31+
32+
Get a web server going and note the `PORT` it is running on.
33+
34+
In another terminal, get `usuba` running:
35+
36+
```sh
37+
cd ./rust/usuba
38+
UPSTREAM=localhost:$PORT cargo run --bin usuba
39+
```
40+
41+
Open your browser to http://localhost:8080. You should see whatever you would expect to see from the first web server you started.

rust/usuba/src/bake/javascript.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ impl Bake for JavaScriptBaker {
6161

6262
debug!(?workspace, "Populated temporary input files");
6363

64+
Command::new("cp")
65+
.arg("-r")
66+
.arg(format!("{}", workspace.path().display()))
67+
.arg("/tmp/failed")
68+
.spawn()?
69+
.wait()
70+
.await?;
71+
6472
let mut command = Command::new("jco");
6573

6674
command

typescript/common/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deps

typescript/common/data/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"name": "@commontools/data",
3+
"author": "The Common Authors",
4+
"version": "0.0.1",
5+
"description": "",
6+
"license": "UNLICENSED",
7+
"private": true,
8+
"type": "module",
9+
"files": [
10+
"./lib/**/*"
11+
],
12+
"exports": {
13+
".": {
14+
"types": "./lib/index.d.ts",
15+
"default": "./lib/index.js"
16+
},
17+
"./interfaces/common-data-types.js": {
18+
"types": "./lib/interfaces/common-data-types.js"
19+
}
20+
},
21+
"scripts": {
22+
"build": "wireit",
23+
"clean": "wireit",
24+
"update:wit": "wireit",
25+
"lint:wit": "wireit",
26+
"build:wit": "wireit"
27+
},
28+
"repository": {
29+
"type": "git",
30+
"url": "git+https://github.com/commontoolsinc/labs.git"
31+
},
32+
"bugs": {
33+
"url": "https://github.com/commontoolsinc/labs/issues"
34+
},
35+
"homepage": "https://github.com/commontoolsinc/labs#readme",
36+
"dependencies": {},
37+
"devDependencies": {
38+
"@bytecodealliance/jco": "^1.2.4",
39+
"typescript": "^5.2.2",
40+
"wireit": "^0.14.4"
41+
},
42+
"wireit": {
43+
"install:wit": {
44+
"command": "wit-deps",
45+
"files": [
46+
"./wit/deps.*"
47+
],
48+
"output": [
49+
"./wit/deps/**/*"
50+
]
51+
},
52+
"lint:wit": {
53+
"dependencies": [
54+
"install:wit"
55+
],
56+
"command": "wasm-tools component wit ./wit",
57+
"files": [
58+
"./wit/**/*"
59+
]
60+
},
61+
"update:wit": {
62+
"command": "wit-deps update",
63+
"files": [
64+
"./wit/deps.toml"
65+
],
66+
"output": [
67+
"./wit/deps.lock",
68+
"./wit/deps/**/*"
69+
]
70+
},
71+
"build:jco": {
72+
"dependencies": [
73+
"install:wit",
74+
"lint:wit"
75+
],
76+
"command": "jco types -o ./lib --name index ./wit",
77+
"files": [
78+
"./wit/**/*"
79+
],
80+
"output": [
81+
"./lib/**/*"
82+
]
83+
},
84+
"build:wit:index": {
85+
"dependencies": [
86+
"build:jco"
87+
],
88+
"command": "cat ./wit/*.wit | ./scripts/generate-wit-module.sh > ./lib/index.js",
89+
"files": [
90+
"./scripts/generate-wit-module.sh",
91+
"./wit/*.wit"
92+
]
93+
},
94+
"build:wit:types": {
95+
"dependencies": [
96+
"build:jco"
97+
],
98+
"command": "echo 'export const wit: string;' >> ./lib/index.d.ts",
99+
"files": [
100+
"./lib/index.d.ts"
101+
]
102+
},
103+
"build:wit": {
104+
"dependencies": [
105+
"build:wit:index",
106+
"build:wit:types"
107+
]
108+
},
109+
"build": {
110+
"dependencies": [
111+
"build:jco",
112+
"build:wit"
113+
]
114+
},
115+
"clean": {
116+
"command": "rm -rf ./src ./lib ./.wireit"
117+
}
118+
}
119+
}

typescript/common/data/scripts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../module/scripts
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"lib": ["es2022", "DOM", "DOM.Iterable"],
5+
"outDir": "./lib",
6+
"rootDir": "./src",
7+
},
8+
"include": [
9+
"src/**/*",
10+
]
11+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package common:data@0.0.1;
2+
3+
interface types {
4+
resource reference {
5+
// Dereference a reference to a value
6+
// This call is fallible (for example, if the dereference is not allowed)
7+
// The value may be none (for example, if it is strictly opaque)
8+
deref: func() -> result<option<value>, %string>;
9+
}
10+
11+
resource dictionary {
12+
get: func(key: %string) -> option<reference>;
13+
}
14+
15+
type array = list<reference>;
16+
type %string = string;
17+
type boolean = bool;
18+
type number = f64;
19+
type buffer = list<u8>;
20+
21+
variant value {
22+
%string(%string),
23+
number(number),
24+
boolean(boolean),
25+
buffer(buffer),
26+
array(array),
27+
dictionary(dictionary)
28+
}
29+
}
30+
31+
world common {
32+
export types;
33+
}

typescript/common/data/wit/deps.lock

Whitespace-only changes.

typescript/common/data/wit/deps.toml

Whitespace-only changes.

0 commit comments

Comments
 (0)