Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Implement the Runtime library
  • Loading branch information
cdata committed May 26, 2024
commit af60bbd5575ba19031a6ae83dda09cdea9ba0728
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target
.wireit
node_modules
dist
dist
*.tsbuildinfo
12 changes: 10 additions & 2 deletions typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"./packages/*"
],
"scripts": {
"build": "wireit"
"build": "wireit",
"clean": "wireit"
},
"repository": {
"type": "git",
Expand All @@ -26,11 +27,19 @@
"wireit": {
"build": {
"dependencies": [
"./packages/example-package:build",
"./packages/usuba-rt:build",
"./packages/usuba-api:build",
"./packages/usuba-sw:build",
"./packages/usuba-ui:build"
]
},
"clean": {
"dependencies": [
"./packages/usuba-rt:clean",
"./packages/usuba-api:clean",
"./packages/usuba-sw:clean",
"./packages/usuba-ui:clean"
]
}
}
}
12 changes: 9 additions & 3 deletions typescript/packages/usuba-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"type": "module",
"scripts": {
"build": "wireit",
"clean": "wireit",
"update-openapi-spec": "wireit"
},
"repository": {
Expand All @@ -22,23 +23,25 @@
"./lib/**/*"
],
"exports": "./lib/index.js",
"dependencies": {},
"devDependencies": {
"@hey-api/openapi-ts": "^0.46.0",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"wireit": "^0.14.4"
},
"wireit": {
"update-openapi-spec": {
"command": "./scripts/update-openapi-spec.sh",
"files": [
"./scripts/update-openapi-spec.sh"
],
"output": [
"./openapi.json"
]
},
"build:openapi-client": {
"command": "npx @hey-api/openapi-ts -i ./openapi.json -o ./src/openapi-client",
"command": "npx @hey-api/openapi-ts -i ./openapi.json -o ./src/openapi-client && ./scripts/fix-paths.sh",
"files": [
"./scripts/fix-paths.sh",
"./openapi.json"
],
"output": [
Expand All @@ -56,6 +59,9 @@
"./lib/**/*"
],
"command": "tsc --build -f"
},
"clean": {
"command": "rm -rf ./lib ./.wireit"
}
}
}
19 changes: 19 additions & 0 deletions typescript/packages/usuba-api/scripts/fix-paths.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# The autogenerated REST client has module specifiers that omit their `.js`
# extensions, which means they are incompatible with TypeScript's NodeNext
# module resolution. Since the code is autogenerated anyway, we post-process the
# specifiers here to "fix" them.

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

set -euo pipefail

pushd $SCRIPT_DIR/../src/openapi-client

find ./ -type f -exec sed -i "/import\|export/ s/\(.* '\.\/[^']*\)/\0.js/g" {} +

popd



28 changes: 3 additions & 25 deletions typescript/packages/usuba-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"target": "es2021",
"module": "es6",
"lib": ["es2021"],
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"inlineSources": true,
"lib": ["ES2022", "WebWorker"],
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitThis": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"importHelpers": true,
"stripInternal": true,
"noImplicitOverride": true,
"types": []
},
"include": [
"src/**/*",
"../../node_modules/@bytecodealliance/preview2-shim",
"../../node_modules/@types/serviceworker/*.d.ts"
"src/**/*"
]
}
1 change: 0 additions & 1 deletion typescript/packages/usuba-api/tsconfig.tsbuildinfo

This file was deleted.

19 changes: 0 additions & 19 deletions typescript/packages/usuba-api/vite.config.js

This file was deleted.

32 changes: 32 additions & 0 deletions typescript/packages/usuba-rt/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export type SourceCode = string | Uint8Array;
export type PendingSourceCode = SourceCode | Promise<SourceCode>;
export type ContentType = 'text/javascript';
export type ContentTypeFileExtensions = {
[C in ContentType]: string;
};
export interface ModuleDefinition {
contentType: ContentType;
wit: PendingSourceCode;
sourceCode: PendingSourceCode;
}
export type Import = {
[index: string]: any;
};
export type ImportMap = {
[index: string]: Import;
};
export type Importable = string | Import | Promise<Import>;
export type ImportableMap = {
[index: string]: Importable;
};
export declare class Runtime {
#private;
constructor(library: PendingSourceCode[]);
defineModule<T>(definition: ModuleDefinition): Promise<PreparedModule<T>>;
}
export declare class PreparedModule<T> {
#private;
constructor(instantiate: any);
instantiate(importables: ImportableMap): Promise<T>;
}
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions typescript/packages/usuba-rt/lib/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions typescript/packages/usuba-rt/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions typescript/packages/usuba-rt/lib/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions typescript/packages/usuba-rt/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@commontools/usuba-rt",
"author": "The Common Authors",
"version": "0.0.1",
"description": "A Runtime for managing the invocation of Usuba-produced Modules",
"license": "UNLICENSED",
"private": true,
"type": "module",
"scripts": {
"build": "wireit",
"clean": "wireit"
},
"repository": {
"type": "git",
"url": "git+https://github.com/commontoolsinc/labs.git"
},
"bugs": {
"url": "https://github.com/commontoolsinc/labs/issues"
},
"homepage": "https://github.com/commontoolsinc/labs#readme",
"files": [
"./lib/*.js"
],
"dependencies": {
"@commontools/usuba-api": "^0.0.1"
},
"devDependencies": {
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"wireit": "^0.14.4"
},
"wireit": {
"build": {
"dependencies": [
"../usuba-api:build"
],
"files": [
"./src/**/*"
],
"output": [
"./lib/**/*"
],
"command": "tsc --build -f"
},
"clean": {
"command": "rm -rf ./lib ./.wireit"
}
}
}
Loading