forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate Sample System Web App to TypeScript
This CL migrates the Sample System Web App to use the ts_library() toolchain. This includes: - splitting the trusted/untrusted resources into their own directories - adding some type annotations where required - reorganizing the BUILD infrastructure to be more streamlined and readable This CL has not fully migrated all resources to TS as there are still some settings that need to be tweaked for SharedWorker APIs. Bug: 1002798 Change-Id: Ie0209fb15839a29077422736c949e561a8b3303c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3301133 Reviewed-by: Giovanni Ortuno Urquidi <ortuno@chromium.org> Reviewed-by: Ken Rockot <rockot@google.com> Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org> Commit-Queue: Christopher Lam <calamity@chromium.org> Cr-Commit-Position: refs/heads/main@{#953018}
- Loading branch information
Showing
24 changed files
with
272 additions
and
190 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
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
ash/webui/sample_system_web_app_ui/resources/trusted/BUILD.gn
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,84 @@ | ||
# Copyright 2021 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("//build/config/chromeos/ui_mode.gni") | ||
import("//third_party/material_web_components/build_mwc_app.gni") | ||
import("//tools/typescript/ts_library.gni") | ||
import("//ui/webui/resources/tools/generate_grd.gni") | ||
|
||
assert(is_chromeos_ash, "Sample System Web App is ash-chrome only") | ||
assert(!is_official_build, | ||
"Sample System Web App is only built for unofficial builds") | ||
|
||
generate_grd("trusted_grd") { | ||
grd_prefix = "ash_sample_system_web_app" | ||
out_grd = "$target_gen_dir/${grd_prefix}_resources.grd" | ||
|
||
input_files = [ | ||
"app_icon_192.png", | ||
"component_playground.html", | ||
"index.html", | ||
"inter_frame_communication.html", | ||
"timer.html", | ||
] | ||
input_files_base_dir = rebase_path(".", "//") | ||
|
||
# tsconfig.manifest is generated by :trusted_ts and adds all of the | ||
# in_files to the grd. | ||
manifest_files = [ | ||
"$target_gen_dir/tsconfig.manifest", | ||
"$target_gen_dir/component_playground.manifest", | ||
] | ||
|
||
# Flatten out the dependency tree of your mojom and add generated bindings | ||
# grdp files here. | ||
# TODO(crbug.com/1002798): We could add a mojo_grdp_deps variable to | ||
# generate_grd that automatically adds these grdp files when you add a | ||
# X_webui_grdp target to it. | ||
grdp_files = [ | ||
"$target_gen_dir/../../mojom/shared_webui_resources.grdp", | ||
"$target_gen_dir/../../mojom/trusted_webui_resources.grdp", | ||
] | ||
|
||
deps = [ | ||
":component_playground", | ||
":trusted_ts", | ||
"../../mojom:shared_webui_grdp", | ||
"../../mojom:trusted_webui_grdp", | ||
] | ||
} | ||
|
||
ts_library("trusted_ts") { | ||
root_dir = "." | ||
out_dir = "$target_gen_dir/tsc" | ||
|
||
in_files = [ | ||
"inter_frame_communication.ts", | ||
"main.ts", | ||
"page_handler.ts", | ||
|
||
# TODO(crbug.com/1002798): Migrate these Shared Worker files to TS. | ||
"timer.js", | ||
"worker.js", | ||
] | ||
|
||
tsconfig_base = "../../tsconfig_base.json" | ||
composite = true | ||
|
||
# Allows TSC to check the generated mojom-webui/ directory when it encounters | ||
# imports. | ||
path_mappings = | ||
[ "/*|" + rebase_path("$root_gen_dir/mojom-webui/*", target_gen_dir) ] | ||
|
||
deps = [ "../../mojom:mojom_ts" ] | ||
} | ||
|
||
build_mwc_app("component_playground") { | ||
host = "sample-system-web-app" | ||
input = rebase_path(".", root_build_dir) | ||
js_module_in_files = [ "component_playground.js" ] | ||
js_out_files = [ "component_playground.rollup.js" ] | ||
out_manifest = "$target_gen_dir/component_playground.manifest" | ||
deps = [] | ||
} |
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.