-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
566 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
load("//:index.bzl", "ts_proto_library") | ||
load("@npm//@swc/cli:index.bzl", "spack") | ||
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test") | ||
load("@npm//http-server:index.bzl", "http_server") | ||
|
||
proto_library( | ||
name = "protos", | ||
srcs = glob(["**/*.proto"]) | ||
) | ||
|
||
ts_proto_library( | ||
name = "codegen", | ||
deps = [ | ||
":protos", | ||
], | ||
target = "web" | ||
) | ||
|
||
generated_file_test( | ||
name = "weather_checked_in", | ||
generated = "src/weather.ts", | ||
src = ":codegen", | ||
) | ||
|
||
spack( | ||
name = "bundle", | ||
outs = ["index.js"], | ||
args = [ | ||
"--entry", "$(execpath src/index.ts)", | ||
"--target", "browser", | ||
"--config", "../../../$(rootpath spack.config.js)", | ||
"-o", "$(RULEDIR)", | ||
], | ||
data = [ | ||
"src/index.ts", | ||
"src/weather.ts", | ||
"spack.config.js", | ||
"@npm//google-protobuf", | ||
"@npm//grpc-web" | ||
], | ||
) | ||
|
||
|
||
http_server( | ||
name = "server", | ||
data = [ | ||
"index.js", | ||
"index.html", | ||
], | ||
templated_args = ["test/web/client/"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Weather</title> | ||
<script> | ||
function __swcpack_require__(mod) { | ||
function interop(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj; | ||
} else { | ||
var newObj = { | ||
}; | ||
if (obj != null) { | ||
for(var key in obj){ | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : { | ||
}; | ||
if (desc.get || desc.set) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
return newObj; | ||
} | ||
} | ||
var cache; | ||
if (cache) { | ||
return cache; | ||
} | ||
var module = { | ||
exports: { | ||
} | ||
}; | ||
mod(module, module.exports); | ||
cache = interop(module.exports); | ||
return cache; | ||
} | ||
</script> | ||
<script type="module" src="/index.js"></script> | ||
</head> | ||
<body> | ||
It is kinda working! | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const { config } = require('@swc/core/spack') | ||
|
||
module.exports = config({ | ||
output: { | ||
path: process.argv[process.argv.length - 1], | ||
name: "app", | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
syntax = "proto3"; | ||
|
||
package weather; | ||
|
||
message City { | ||
// See: https://en.wikipedia.org/wiki/ISO_3166-2 | ||
string code = 1; | ||
string name = 2; | ||
} | ||
|
||
message Temperature { | ||
// See: https://en.wikipedia.org/wiki/ISO_3166-2 | ||
string code = 1; | ||
int32 current = 2; | ||
} | ||
|
||
message CityQuery { | ||
message Result { repeated City cities = 2; } | ||
} | ||
|
||
message GetTemperature { string code = 1; } | ||
|
||
message Ping { | ||
message Ack {} | ||
} | ||
|
||
message Forecast { | ||
string code = 1; | ||
string date = 2; | ||
message Result { | ||
Temperature temperature = 1; | ||
} | ||
} | ||
|
||
service Weather { | ||
rpc cities(CityQuery) returns (CityQuery.Result); | ||
rpc get(GetTemperature) returns (stream Temperature); | ||
// Unsupported at the moment | ||
// rpc ping(stream Ping) returns (Ping.Ack); | ||
// rpc forecast(stream Forecast) returns (stream Forecast.Result); | ||
} |
Oops, something went wrong.