ソースを参照

[js] Add externs for the Web Share API (#11423)

Cédric Belin 1 年間 前
コミット
e391fda1a2
1 ファイル変更38 行追加1 行削除
  1. 38 1
      std/js/html/Navigator.hx

+ 38 - 1
std/js/html/Navigator.hx

@@ -127,4 +127,41 @@ extern class Navigator {
 	function sendBeacon( url : String, ?data : Blob ) : Bool;
 	function requestMediaKeySystemAccess( keySystem : String, supportedConfigurations : Array<js.html.eme.MediaKeySystemConfiguration> ) : Promise<js.html.eme.MediaKeySystemAccess>;
 	function taintEnabled() : Bool;
-}
+
+	/**
+		Returns `true` if the equivalent call to `share()` would succeed.
+		Returns `false` if the data cannot be validated.
+	**/
+	function canShare(?data: NavigatorShareData): Bool;
+
+	/**
+		Invokes the native sharing mechanism of the device to share data such as text, URLs, or files.
+	**/
+	function share(data: NavigatorShareData): Promise<Void>;
+}
+
+/**
+	An object containing data to share.
+**/
+typedef NavigatorShareData = {
+
+	/**
+		An array of `File` objects representing files to be shared.
+	**/
+	var ?files: Array<File>;
+
+	/**
+		A string representing text to be shared.
+	**/
+	var ?text: String;
+
+	/**
+		A string representing the title to be shared.
+	**/
+	var ?title: String;
+
+	/**
+		A string representing a URL to be shared
+	**/
+	var ?url: String;
+}