|  | load("@aspect_rules_js//js:defs.bzl", "js_library") | 
|  | load("//infra-sk:index.bzl", "bool_flag", "extract_files_from_skia_wasm_container") | 
|  |  | 
|  | bool_flag( | 
|  | default = True, | 
|  | flag_name = "use_debugger_from_container", | 
|  | ) | 
|  |  | 
|  | # This target makes the wasm binaries and js files available for tests. This is not the same | 
|  | # as ../build because we want to be able to control which binaries get used when we deploy a | 
|  | # container, but we are less stringent when running tests on the infra CI. | 
|  | extract_files_from_skia_wasm_container( | 
|  | name = "fetch_debugger_wasm", | 
|  | testonly = True, | 
|  | container = "@pinned_debugger", | 
|  | container_files = { | 
|  | "/usr/local/share/debugger-app/index.d.ts": "from_container/canvaskit.d.ts", | 
|  | "/usr/local/share/debugger-app/canvaskit.js": "from_container/canvaskit.js", | 
|  | "/usr/local/share/debugger-app/canvaskit.wasm": "from_container/canvaskit.wasm", | 
|  | }, | 
|  | enabled_flag = ":use_debugger_from_container", | 
|  | ) | 
|  |  | 
|  | filegroup( | 
|  | name = "canvaskit.js", | 
|  | srcs = select({ | 
|  | ":use_debugger_from_container_true": ["from_container/canvaskit.js"], | 
|  | ":use_debugger_from_container_false": ["local_build/canvaskit.js"], | 
|  | }), | 
|  | visibility = ["//debugger-app:__subpackages__"], | 
|  | ) | 
|  |  | 
|  | filegroup( | 
|  | name = "canvaskit.wasm", | 
|  | srcs = select({ | 
|  | ":use_debugger_from_container_true": ["from_container/canvaskit.wasm"], | 
|  | ":use_debugger_from_container_false": ["local_build/canvaskit.wasm"], | 
|  | }), | 
|  | visibility = ["//debugger-app:__subpackages__"], | 
|  | ) | 
|  |  | 
|  | filegroup( | 
|  | name = "canvaskit.d.ts", | 
|  | srcs = select({ | 
|  | ":use_debugger_from_container_true": ["from_container/canvaskit.d.ts"], | 
|  | ":use_debugger_from_container_false": ["local_build/canvaskit.d.ts"], | 
|  | }), | 
|  | visibility = ["//debugger-app:__subpackages__"], | 
|  | ) | 
|  |  | 
|  | genrule( | 
|  | name = "make version file", | 
|  | outs = ["version.js"], | 
|  | # We use LATEST here to make Puppeteer tests more deterministic. | 
|  | cmd = """echo "const SKIA_VERSION = 'LATEST';" > $@""", | 
|  | visibility = ["//debugger-app:__subpackages__"], | 
|  | ) | 
|  |  | 
|  | # This js_library rule makes the source a viable dependency of ts_library rules (and thus visible | 
|  | # during compilation). | 
|  | js_library( | 
|  | name = "canvaskit_types", | 
|  | srcs = [ | 
|  | "types/canvaskit.d.ts", | 
|  | ], | 
|  | visibility = ["//debugger-app:__subpackages__"], | 
|  | deps = [ | 
|  | # Because we copy the index.d.ts out of canvaskit, we lose the transitive dependency on the | 
|  | # webgpu types that canvaskit itself has. | 
|  | "//:node_modules/@webgpu/types", | 
|  | ], | 
|  | ) | 
|  |  | 
|  | # This copy rule makes it so we can import from '../../wasm_libs/types/canvaskit' and not | 
|  | # '../../wasm_libs/from_container/canvaskit', which does not make the source easily toggleable. | 
|  | genrule( | 
|  | name = "copy_canvaskit_types", | 
|  | srcs = ["canvaskit.d.ts"], | 
|  | outs = ["types/canvaskit.d.ts"], | 
|  | # Copy the one input file to the one output location | 
|  | cmd = "cp $< $@", | 
|  | ) |