121 lines
3.0 KiB
Python
121 lines
3.0 KiB
Python
# Copyright 2020 The Pigweed Authors
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
# use this file except in compliance with the License. You may obtain a copy of
|
|
# the License at
|
|
#
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations under
|
|
# the License.
|
|
|
|
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
|
|
load("@npm//@bazel/concatjs:index.bzl", "karma_web_test")
|
|
load("@npm//@bazel/esbuild:index.bzl", "esbuild")
|
|
load("@npm//@bazel/typescript:index.bzl", "ts_library", "ts_project")
|
|
load("@npm//http-server:index.bzl", "http_server")
|
|
load("//pw_protobuf_compiler/ts:ts_proto_collection.bzl", "ts_proto_collection")
|
|
load("@rules_proto_grpc//js:defs.bzl", "js_proto_library")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
js_proto_library(
|
|
name = "rpc_protos_tspb",
|
|
protos = [
|
|
"//pw_rpc:echo_proto",
|
|
],
|
|
)
|
|
|
|
ts_proto_collection(
|
|
name = "web_proto_collection",
|
|
js_proto_library = "@//pw_web_ui:rpc_protos_tspb",
|
|
proto_library = "@//pw_rpc:echo_proto",
|
|
)
|
|
|
|
ts_project(
|
|
name = "lib",
|
|
srcs = [
|
|
"index.ts",
|
|
"src/frontend/app.tsx",
|
|
"src/frontend/index.tsx",
|
|
"src/frontend/log.tsx",
|
|
"src/frontend/serial_log.tsx",
|
|
"src/transport/device_transport.ts",
|
|
"src/transport/serial_mock.ts",
|
|
"src/transport/web_serial_transport.ts",
|
|
"types/serial.d.ts",
|
|
],
|
|
declaration = True,
|
|
source_map = True,
|
|
deps = [
|
|
":web_proto_collection",
|
|
"//pw_hdlc/ts:pw_hdlc",
|
|
"//pw_rpc/ts:pw_rpc",
|
|
"//pw_status/ts:pw_status",
|
|
"@npm//:node_modules",
|
|
], # can't use fine-grained deps
|
|
)
|
|
|
|
js_library(
|
|
name = "pw_web_ui",
|
|
package_name = "@pigweed/pw_web_ui",
|
|
srcs = ["package.json"],
|
|
deps = [":lib"],
|
|
)
|
|
|
|
ts_library(
|
|
name = "web_ui_test_lib",
|
|
srcs = [
|
|
"src/transport/web_serial_transport_test.ts",
|
|
],
|
|
deps = [
|
|
":lib",
|
|
"@npm//rxjs",
|
|
],
|
|
)
|
|
|
|
esbuild(
|
|
name = "web_ui_test_bundle",
|
|
entry_point = "src/transport/web_serial_transport_test.ts",
|
|
deps = [":web_ui_test_lib"],
|
|
)
|
|
|
|
esbuild(
|
|
name = "app_bundle",
|
|
args = {
|
|
"resolveExtensions": [
|
|
".mjs",
|
|
".js",
|
|
],
|
|
},
|
|
entry_point = "src/frontend/index.tsx",
|
|
target = "es2021",
|
|
deps = [":lib"],
|
|
)
|
|
|
|
karma_web_test(
|
|
name = "web_ui_test",
|
|
srcs = [
|
|
":web_ui_test_bundle",
|
|
],
|
|
)
|
|
|
|
http_server(
|
|
name = "devserver",
|
|
args = ["pw_web_ui/"],
|
|
data = [
|
|
"index.html",
|
|
":app_bundle",
|
|
],
|
|
)
|
|
|
|
# needed for embedding into downstream projects
|
|
filegroup(name = "pw_web_ui__contents")
|
|
|
|
filegroup(name = "pw_web_ui__files")
|
|
|
|
filegroup(name = "pw_web_ui__nested_node_modules")
|