Skip to content

Commit f42e6e2

Browse files
committed
Add new package
1 parent 8d95c88 commit f42e6e2

File tree

10 files changed

+1774
-77
lines changed

10 files changed

+1774
-77
lines changed

typescript/package-lock.json

Lines changed: 1587 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"./packages/usuba-ui:build",
3535
"./packages/runtime-demo:build",
3636
"./packages/example-module:build",
37+
"./packages/lookslike-prototype:build",
3738
"./common/data:build",
3839
"./common/io:build",
3940
"./common/module:build",
@@ -48,11 +49,12 @@
4849
"./packages/usuba-ui:clean",
4950
"./packages/runtime-demo:clean",
5051
"./packages/example-module:clean",
52+
"./packages/lookslike-prototype:clean",
5153
"./common/data:clean",
5254
"./common/io:clean",
5355
"./common/module:clean",
5456
"./common/runtime:clean"
5557
]
5658
}
5759
}
58-
}
60+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6+
<title></title>
7+
<link rel="stylesheet" href="src/main.css">
8+
<script type="module" src="src/main.ts"></script>
9+
</head>
10+
<body class="theme">
11+
<com-app></com-app>
12+
</body>
13+
</html>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "@commontools/lookslike-prototype",
3+
"author": "The Common Authors",
4+
"version": "0.0.1",
5+
"description": "Testbed for wasm modules.",
6+
"license": "UNLICENSED",
7+
"private": true,
8+
"type": "module",
9+
"scripts": {
10+
"build": "wireit",
11+
"clean": "wireit"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "git+https://github.com/commontoolsinc/labs.git"
16+
},
17+
"bugs": {
18+
"url": "https://github.com/commontoolsinc/labs/issues"
19+
},
20+
"homepage": "https://github.com/commontoolsinc/labs#readme",
21+
"devDependencies": {
22+
"@commontools/module": "^0.0.1",
23+
"@commontools/data": "^0.0.1",
24+
"@commontools/io": "^0.0.1",
25+
"@commontools/usuba-rt": "^0.0.1",
26+
"@commontools/runtime": "^0.0.1",
27+
"@shoelace-style/shoelace": "^2.15.1",
28+
"typescript": "^5.2.2",
29+
"vite": "^5.2.0",
30+
"wireit": "^0.14.4",
31+
"@instructor-ai/instructor": "^1.3.0",
32+
"@types/pretty": "^2.0.3",
33+
"lit": "^3.1.3",
34+
"openai": "^4.47.2",
35+
"pretty": "^2.0.0",
36+
"rxjs": "^7.8.1"
37+
},
38+
"wireit": {
39+
"build": {
40+
"dependencies": [
41+
"../../common/module:build",
42+
"../../common/data:build",
43+
"../../common/io:build",
44+
"../../common/runtime:build",
45+
"../usuba-rt:build"
46+
],
47+
"command": "vite build"
48+
},
49+
"clean": {
50+
"command": "rm -rf ./lib ./dist ./.wireit ./node_modules"
51+
}
52+
}
53+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../node_modules/@shoelace-style/shoelace
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
body {
2+
font-family: var(--sl-font-sans, sans-serif);
3+
padding: 1em;
4+
}
5+
6+
* {
7+
box-sizing: border-box;
8+
}
9+
10+
sl-textarea {
11+
min-height: 360px;
12+
flex: 1;
13+
}
14+
sl-textarea::part(textarea) {
15+
font-family: var(--sl-font-mono, mono);
16+
font-size: 0.85rem;
17+
}
18+
19+
sl-input {
20+
flex: 1;
21+
}
22+
23+
#specifier {
24+
display: flex;
25+
flex-direction: row;
26+
align-items: center;
27+
margin-bottom: 1em;
28+
gap: 1em;
29+
margin-right: 1em;
30+
}
31+
32+
#code {
33+
display: flex;
34+
flex-direction: row;
35+
gap: 1em;
36+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { IO, Runtime, Value, infer } from '@commontools/runtime';
2+
console.log('wow')
3+
4+
const EXAMPLE_MODULE_JS = `
5+
import { read, write } from 'common:io/state@0.0.1';
6+
7+
export class Body {
8+
run() {
9+
console.log('Running!');
10+
const foo = read('foo');
11+
console.log('Reference:', foo);
12+
const value = foo?.deref();
13+
console.log('Value:', value);
14+
}
15+
}
16+
17+
export const module = {
18+
Body,
19+
20+
create() {
21+
console.log('Creating!');
22+
return new Body();
23+
}
24+
};`;
25+
26+
class LocalStorageIO implements IO {
27+
reset() {
28+
localStorage.clear();
29+
}
30+
31+
read(key: string): Value | undefined {
32+
console.log(`Reading '${key}' from local storage`);
33+
let rawValue = localStorage.getItem(key);
34+
return infer(rawValue);
35+
}
36+
37+
write(key: string, value: Value): void {
38+
console.log(`Writing '${key} => ${value.val}' to local storage`);
39+
// YOLO (don't do it this way actually)
40+
localStorage.setItem(key, value.val);
41+
}
42+
}
43+
44+
export const demo = async () => {
45+
const rt = new Runtime();
46+
const io = new LocalStorageIO();
47+
48+
io.reset();
49+
50+
const module = await rt.eval('text/javascript', EXAMPLE_MODULE_JS, io);
51+
52+
console.log(`Setting 'foo => bar' at the host level`);
53+
io.write('foo', infer('bar'));
54+
55+
console.log('Running the module:');
56+
module.run();
57+
};
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"],
5+
"outDir": "./lib",
6+
"rootDir": "./src",
7+
},
8+
"include": [
9+
"src/**/*"
10+
]
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// vite.config.js
2+
import { resolve } from 'path'
3+
import { defineConfig } from 'vite'
4+
5+
export default defineConfig({
6+
build: {
7+
target: 'esnext'
8+
},
9+
resolve: {
10+
preserveSymlinks: true
11+
}
12+
})

0 commit comments

Comments
 (0)