chromium/chrome/browser/resources/chromeos/emoji_picker/BUILD.gn

# Copyright 2020 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//ui/webui/resources/tools/build_webui.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

preprocess_folder = "$target_gen_dir/preprocessed"

build_webui("build") {
  grd_prefix = "emoji_picker"

  static_files = [
    "index.html",
    "nudge_icon.svg",
  ]

  web_component_files = [
    "app.ts",
    "emoji_button.ts",
    "emoji_category_button.ts",
    "emoji_error.ts",
    "emoji_gif_nudge_overlay.ts",
    "emoji_group.ts",
    "emoji_group_button.ts",
    "emoji_image.ts",
    "emoji_search.ts",
    "emoji_variants.ts",
    "text_group_button.ts",
  ]

  non_web_component_files = [
    "constants.ts",
    "emoji_picker.ts",
    "emoji_picker_api_proxy.ts",
    "events.ts",
    "metadata_extension.ts",
    "prefix_search.ts",
    "store.ts",
    "structs/trie.ts",
    "types.ts",
  ]

  icons_html_files = [ "icons.html" ]

  mojo_files_deps = [
    "//chrome/browser/ui/webui/ash/emoji:mojo_bindings_ts__generator",
    "//chromeos/ash/components/emoji:mojo_bindings_ts__generator",
  ]
  mojo_files = [
    "$root_gen_dir/chrome/browser/ui/webui/ash/emoji/emoji_picker.mojom-webui.ts",
    "$root_gen_dir/chrome/browser/ui/webui/ash/emoji/new_window_proxy.mojom-webui.ts",
    "$root_gen_dir/chromeos/ash/components/emoji/emoji_search.mojom-webui.ts",
  ]

  ts_composite = true
  ts_definitions = [ "$preprocess_folder/fuse.d.ts" ]
  ts_deps = [
    "//ash/webui/common/resources/cr_elements:build_ts",
    "//third_party/polymer/v3_0:library",
    "//ui/webui/resources/cr_components/color_change_listener:build_ts",
    "//ui/webui/resources/js:build_ts",
    "//ui/webui/resources/mojo:build_ts",
  ]
  ts_extra_deps = [
    ":copy_fuse",
    ":copy_fuse_dts",
    "//ash/webui/common/resources:generate_definitions",
    "//chromeos/ash/components/emoji:resources",
  ]

  extra_grdp_deps = [ ":build_fuse_grdp" ]
  extra_grdp_files = [ "$target_gen_dir/fuse_resources.grdp" ]
  webui_context_type = "trusted"
  optimize = optimize_webui
  if (optimize) {
    optimize_webui_host = "emoji-picker"
    optimize_webui_in_files = [ "emoji_picker.js" ]
    optimize_webui_excludes = [ "fuse.js" ]
  }
}

generate_grd("build_fuse_grdp") {
  grd_prefix = "emoji_picker"
  out_grd = "$target_gen_dir/fuse_resources.grdp"
  input_files = [ "fuse.js" ]
  input_files_base_dir = rebase_path(preprocess_folder, root_build_dir)
  deps = [ ":copy_fuse" ]
}

copy("copy_fuse") {
  sources = [ "//third_party/fusejs/dist/fuse.basic.esm.min.js" ]
  outputs = [ "$preprocess_folder/fuse.js" ]
}

copy("copy_fuse_dts") {
  sources = [ "//third_party/fusejs/dist/fuse.d.ts" ]
  outputs = [ "$preprocess_folder/fuse.d.ts" ]
}