<?xml version="1.0" encoding="UTF-8"?>

<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
           id="nodejs-mobile-cordova"
      version="0.4.3">

  <name>Node.js Mobile</name>
  <description>Node.js for Mobile Apps Cordova Plugin</description>
  <license>MIT</license>
  <keywords>cordova,mobile,nodejs,node.js</keywords>

  <engines>
    <engine name="cordova-android" version=">=6.2.1"/>
    <engine name="cordova-ios" version=">=4.4.0"/>
   </engines>

  <js-module src="www/nodejs_apis.js" name="nodejs">
    <clobbers target="nodejs" />
  </js-module>

  <js-module src="www/nodejs_events.js" name="nodejs_events">
    <clobbers target="nodejs_events" />
  </js-module>

  <!-- ios -->
  <platform name="ios">

    <hook type="before_plugin_install" src="install/hooks/ios/before-plugin-install.js" />
    <hook type="after_plugin_install" src="install/hooks/ios/after-plugin-install.js" />
    <hook type="before_plugin_uninstall" src="install/hooks/ios/before-plugin-uninstall.js" />
    <hook type="after_platform_add" src="install/hooks/ios/fix-xcframework-path.js" />
    <hook type="after_plugin_add" src="install/hooks/ios/fix-xcframework-path.js" />
    <hook type="after_plugin_install" src="install/hooks/ios/fix-xcframework-path.js" />
    <hook type="after_prepare" src="install/hooks/ios/fix-xcframework-path.js" />
    <hook type="after_prepare" src="install/hooks/both/after-prepare-patch-npm-packages.js" />
    <hook type="after_prepare" src="install/hooks/both/after-prepare-native-modules-preference.js" />

    <config-file target="config.xml" parent="/*">
      <feature name="NodeJS">
        <param name="ios-package" value="CDVNodeJS" />
        <param name="onload" value= "true" />
      </feature>
    </config-file>

    <header-file src="src/ios/CDVNodeJS.hh" />
    <source-file src="src/ios/CDVNodeJS.mm" />
    <header-file src="src/common/cordova-bridge/cordova-bridge.h" />
    <source-file src="src/common/cordova-bridge/cordova-bridge.cpp" compiler-flags="-I$(SRCROOT)/$(PRODUCT_NAME)/Plugins/nodejs-mobile-cordova/include/node/"/>
    <header-file src="src/ios/NodeJSRunner.hh" />
    <source-file src="src/ios/NodeJSRunner.mm" />
    <header-file src="libs/ios/nodemobile/include"/>

    <asset src="install/nodejs-mobile-cordova-assets" target="nodejs-mobile-cordova-assets" />

    <framework src="libs/ios/nodemobile/NodeMobile.xcframework" custom="true" embed="true" />
    <framework src="libs/ios/nodemobile/NodeMobile.xcframework" />

  </platform>

  <!-- android -->
  <platform name="android">

    <hook type="before_plugin_install" src="install/hooks/android/before-plugin-install.js" />
    <hook type="after_prepare" src="install/hooks/android/after-prepare-build-node-assets-lists.js" />
    <hook type="after_prepare" src="install/hooks/both/after-prepare-patch-npm-packages.js" />
    <hook type="after_prepare" src="install/hooks/android/after-prepare-create-macOS-builder-helper.js" />
    <hook type="after_prepare" src="install/hooks/both/after-prepare-native-modules-preference.js" />

    <config-file target="res/xml/config.xml" parent="/*">
      <feature name="NodeJS">
        <param name="android-package" value="com.janeasystems.cdvnodejsmobile.NodeJS" />
      </feature>
    </config-file>

    <config-file target="AndroidManifest.xml" parent="/manifest">
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    </config-file>

    <source-file src="src/android/java/com/janeasystems/cdvnodejsmobile/NodeJS.java" target-dir="src/com/janeasystems/cdvnodejsmobile/" />

    <source-file src="src/common/cordova-bridge/cordova-bridge.h" target-dir="libs/cdvnodejsmobile/" />
    <source-file src="src/common/cordova-bridge/cordova-bridge.cpp" target-dir="libs/cdvnodejsmobile/" />
    <source-file src="src/android/jni/native-lib.cpp" target-dir="libs/cdvnodejsmobile/" />

    <source-file src="libs/android/libnode/" target-dir="libs/cdvnodejsmobile/" />

    <source-file src="install/nodejs-mobile-cordova-assets/" target-dir="assets/" />

    <framework src="src/android/build.gradle" custom="true" type="gradleReference" />
    <source-file src="src/android/CMakeLists.txt" target-dir="libs/cdvnodejsmobile/"/>

  </platform>

</plugin>
