chromium/ios/web/text_fragments/BUILD.gn

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

import("//build/buildflag_header.gni")
import("//ios/build/config.gni")
import("//ios/web/public/js_messaging/compile_ts.gni")
import("//ios/web/public/js_messaging/optimize_js.gni")

source_set("text_fragments") {
  deps = [
    ":text_fragments_js",
    "//base",
    "//components/shared_highlighting/core/common",
    "//components/shared_highlighting/ios",
    "//ios/web/common:features",
    "//ios/web/public",
    "//ios/web/public:web_state_observer",
    "//ios/web/public/js_messaging",
    "//ios/web/public/navigation",
    "//ios/web/public/navigation:referrer",
    "//ios/web/public/text_fragments",
    "//services/metrics/public/cpp:metrics_cpp",
  ]

  sources = [
    "text_fragments_java_script_feature.h",
    "text_fragments_java_script_feature.mm",
    "text_fragments_manager_impl.h",
    "text_fragments_manager_impl.mm",
  ]
}

compile_ts("compile_text_fragments_js") {
  allow_js = true

  sources = [
    "//third_party/text-fragments-polyfill/src/src/text-fragment-utils.js",
    "resources/text_fragments.ts",
  ]

  deps = [
    "//ios/web/public/js_messaging:gcrweb",
    "//ios/web/public/js_messaging:util_scripts",
  ]
}

optimize_js("text_fragments_js") {
  visibility = [ ":text_fragments" ]
  _script = filter_include(get_target_outputs(":compile_text_fragments_js"),
                           [ "*text_fragments.js" ])
  primary_script = _script[0]

  sources = _script

  deps = [
    ":compile_text_fragments_js",
    "//ios/web/public/js_messaging:gcrweb",
    "//ios/web/public/js_messaging:util_scripts",
  ]
}