Skip to content

Commit

Permalink
CCA: Migrate comlink related files to TypeScript
Browse files Browse the repository at this point in the history
Also update comlink library from comlink.js to comlink.ts (version
4.3.1) for better typing support, since we're using TypeScript now.

Bug: b:172340451
Test: tsc compiles
Test: tast run <ip> camera.CCAUISmoke* camera.CCAUIStress*
Change-Id: I8f19bcb06da3a644c17b2197f51d02fba53381bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3292652
Reviewed-by: Shik Chen <shik@chromium.org>
Commit-Queue: Pi-Hsun Shih <pihsun@chromium.org>
Cr-Commit-Position: refs/heads/main@{#951373}
  • Loading branch information
peter50216 authored and Chromium LUCI CQ committed Dec 14, 2021
1 parent 3b0c762 commit d11eed6
Show file tree
Hide file tree
Showing 13 changed files with 757 additions and 430 deletions.
6 changes: 3 additions & 3 deletions ash/webui/camera_app_ui/resources/js/externs/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ type CreateScriptURLCallback = (input: string, arguments: any) => string;

interface TrustedTypePolicy {
readonly name: string;
createHTML(input: string, arguments: any): TrustedHTML;
createScript(input: string, arguments: any): TrustedScript;
createScriptURL(input: string, arguments: any): TrustedScriptURL;
createHTML(input: string, arguments?: any): TrustedHTML;
createScript(input: string, arguments?: any): TrustedScript;
createScriptURL(input: string, arguments?: any): TrustedScriptURL;
}

interface TrustedTypePolicyFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
import '/strings.m.js';

import * as Comlink from './lib/comlink.js';
import {TestBridge} from './test_bridge.js';

document.addEventListener('DOMContentLoaded', async () => {
const workerPath = '/js/test_bridge.js';
const sharedWorker = new SharedWorker(workerPath, {type: 'module'});
const testBridge = Comlink.wrap(sharedWorker.port);
const testBridge = Comlink.wrap<TestBridge>(sharedWorker.port);
const appWindow = await testBridge.bindWindow(window.location.href);
// TODO(crbug.com/980846): Refactor to use a better way rather than window
// properties to pass data to other modules.
Expand Down
11 changes: 6 additions & 5 deletions ash/webui/camera_app_ui/resources/js/js.gni
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ compile_js_files = [
"geometry.js",
"h264.js",
"i18n_string.js",
"init.js",
"init.ts",
"intent.js",
"lib/comlink.js",
"lib/comlink.ts",
"lib/comlink_protocol.ts",
"lib/ffmpeg.js",
"main.js",
"metrics.ts",
Expand All @@ -46,7 +47,7 @@ compile_js_files = [
"models/local_storage.js",
"models/result_saver.js",
"models/video_processor_interface.js",
"models/video_saver.js",
"models/video_saver.ts",
"mojo/chrome_helper.ts",
"mojo/device_operator.js",
"mojo/image_capture.js",
Expand All @@ -58,7 +59,7 @@ compile_js_files = [
"snackbar.js",
"sound.js",
"state.js",
"test_bridge.js",
"test_bridge.ts",
"thumbnailer.js",
"timer.ts",
"toast.js",
Expand All @@ -68,7 +69,7 @@ compile_js_files = [
"untrusted_ga_helper.js",
"untrusted_helper_interfaces.js",
"untrusted_script_loader.js",
"untrusted_video_processor_helper.js",
"untrusted_video_processor_helper.ts",
"util.ts",
"views/camera_intent.js",
"views/camera.js",
Expand Down
297 changes: 0 additions & 297 deletions ash/webui/camera_app_ui/resources/js/lib/comlink.js

This file was deleted.

Loading

0 comments on commit d11eed6

Please sign in to comment.