@totalpave/cordova-plugin-insets 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totalpave/cordova-plugin-insets",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Cordova Android Plugin to receive native information regarding the unsafe area insets.",
5
5
  "main": "www/insets.js",
6
6
  "types": "www/api.d.ts",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="@totalpave/cordova-plugin-insets" version="0.1.6">
2
+ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="@totalpave/cordova-plugin-insets" version="0.1.8">
3
3
  <name>cordova-plugin-insets</name>
4
4
  <description>Cordova Android Plugin to receive native information regarding the unsafe area insets</description>
5
5
  <author>Total Pave Inc.</author>
package/src/www/Insets.ts CHANGED
@@ -46,6 +46,12 @@ export class Insets {
46
46
  return this.initPromise;
47
47
  }
48
48
  this.initPromise = new Promise<void>((resolve, reject) => {
49
+ // no-op on iOS, still installs to iOS so apps don't need to do platform checks.
50
+ if (cordova.platformId === 'ios') {
51
+ resolve();
52
+ return;
53
+ }
54
+
49
55
  // Setup promise resolving mechanism.
50
56
  // We don't use the cordova callback functions as they will be called multiple times over the lifespan of an app.
51
57
  let func = () => {
package/www/insets.js CHANGED
@@ -28,6 +28,11 @@ class Insets {
28
28
  return this.initPromise;
29
29
  }
30
30
  this.initPromise = new Promise((resolve, reject) => {
31
+ // no-op on iOS, still installs to iOS so apps don't need to do platform checks.
32
+ if (cordova.platformId === 'ios') {
33
+ resolve();
34
+ return;
35
+ }
31
36
  // Setup promise resolving mechanism.
32
37
  // We don't use the cordova callback functions as they will be called multiple times over the lifespan of an app.
33
38
  let func = () => {
package/www/insets.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"insets.js","sources":["../src/www/Insets.ts"],"sourcesContent":["/*\n Copyright 2022 Total Pave Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n\nexport const SERVICE_NAME: string = \"Insets\";\n\nexport interface IInsets {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport type IInsetCallbackFunc = (inset: IInsets) => void;\n\nexport class Insets {\n private static initPromise: Promise<void>;\n private static listeners: Array<Function> = [];\n private static insets: IInsets = {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n };\n\n /**\n * Initializes javascript side of the plugin.\n * \n * This function is called automatically on deviceready.\n * @internal\n */\n public static __init(): Promise<void> {\n if (this.initPromise) {\n return this.initPromise;\n }\n this.initPromise = new Promise<void>((resolve, reject) => {\n // Setup promise resolving mechanism.\n // We don't use the cordova callback functions as they will be called multiple times over the lifespan of an app.\n let func = () => {\n resolve();\n Insets.removeListener(func);\n }\n Insets.addListener(func);\n\n // Setup cordova callback.\n cordova.exec(\n (insets: IInsets) => {\n Insets.insets = insets;\n for (let i = 0, listeners = Insets.listeners.slice(), length = listeners.length; i < length; ++i) {\n listeners[i](insets);\n }\n },\n reject,\n SERVICE_NAME,\n \"setListener\",\n []\n );\n });\n }\n\n public static addListener(callback: IInsetCallbackFunc) {\n this.listeners.push(callback);\n }\n\n public static removeListener(callback: IInsetCallbackFunc) {\n let index = this.listeners.indexOf(callback);\n if (index === -1) {\n return;\n }\n this.listeners.splice(index, 1);\n }\n\n /**\n * @returns Last emitted insets.\n */ \n public static getInsets(): IInsets {\n return Insets.insets;\n }\n};\n\ndocument.addEventListener('deviceready', function() {\n Insets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YACd,OAAO;AACV,SAAA;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;KACnC;AAED;;AAEG;AACI,IAAA,OAAO,SAAS,GAAA;QACnB,OAAO,MAAM,CAAC,MAAM,CAAC;KACxB;;AA5Dc,MAAS,CAAA,SAAA,GAAoB,EAAE,CAAC;AAChC,MAAA,CAAA,MAAM,GAAY;AAC7B,IAAA,GAAG,EAAE,CAAC;AACN,IAAA,KAAK,EAAE,CAAC;AACR,IAAA,MAAM,EAAE,CAAC;AACT,IAAA,IAAI,EAAE,CAAC;CACV,CAAC;AAyDN,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,YAAA;IACrC,MAAM,CAAC,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"insets.js","sources":["../src/www/Insets.ts"],"sourcesContent":["/*\n Copyright 2022 Total Pave Inc.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n*/\n\nexport const SERVICE_NAME: string = \"Insets\";\n\nexport interface IInsets {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport type IInsetCallbackFunc = (inset: IInsets) => void;\n\nexport class Insets {\n private static initPromise: Promise<void>;\n private static listeners: Array<Function> = [];\n private static insets: IInsets = {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n };\n\n /**\n * Initializes javascript side of the plugin.\n * \n * This function is called automatically on deviceready.\n * @internal\n */\n public static __init(): Promise<void> {\n if (this.initPromise) {\n return this.initPromise;\n }\n this.initPromise = new Promise<void>((resolve, reject) => {\n // no-op on iOS, still installs to iOS so apps don't need to do platform checks.\n if (cordova.platformId === 'ios') {\n resolve();\n return;\n }\n\n // Setup promise resolving mechanism.\n // We don't use the cordova callback functions as they will be called multiple times over the lifespan of an app.\n let func = () => {\n resolve();\n Insets.removeListener(func);\n }\n Insets.addListener(func);\n\n // Setup cordova callback.\n cordova.exec(\n (insets: IInsets) => {\n Insets.insets = insets;\n for (let i = 0, listeners = Insets.listeners.slice(), length = listeners.length; i < length; ++i) {\n listeners[i](insets);\n }\n },\n reject,\n SERVICE_NAME,\n \"setListener\",\n []\n );\n });\n }\n\n public static addListener(callback: IInsetCallbackFunc) {\n this.listeners.push(callback);\n }\n\n public static removeListener(callback: IInsetCallbackFunc) {\n let index = this.listeners.indexOf(callback);\n if (index === -1) {\n return;\n }\n this.listeners.splice(index, 1);\n }\n\n /**\n * @returns Last emitted insets.\n */ \n public static getInsets(): IInsets {\n return Insets.insets;\n }\n};\n\ndocument.addEventListener('deviceready', function() {\n Insets.__init();\n});\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;AAcE;AAEK,MAAM,YAAY,GAAW,QAAQ,CAAC;MAWhC,MAAM,CAAA;AAUf;;;;;AAKG;AACI,IAAA,OAAO,MAAM,GAAA;QAChB,IAAI,IAAI,CAAC,WAAW,EAAE;YAClB,OAAO,IAAI,CAAC,WAAW,CAAC;AAC3B,SAAA;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,KAAI;;AAErD,YAAA,IAAI,OAAO,CAAC,UAAU,KAAK,KAAK,EAAE;AAC9B,gBAAA,OAAO,EAAE,CAAC;gBACV,OAAO;AACV,aAAA;;;YAID,IAAI,IAAI,GAAG,MAAK;AACZ,gBAAA,OAAO,EAAE,CAAC;AACV,gBAAA,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;AAChC,aAAC,CAAA;AACD,YAAA,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;;AAGzB,YAAA,OAAO,CAAC,IAAI,CACR,CAA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