@totalpave/cordova-plugin-insets 0.3.2 → 0.4.0
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/CHANGELOG.md +17 -1
- package/README.md +5 -11
- package/docs.md +2 -0
- package/package.json +7 -6
- package/plugin.xml +16 -3
- package/plugin.xml.ejs +15 -2
- package/src/ios/TPIInset.h +31 -0
- package/src/ios/TPIInset.m +132 -0
- package/src/ios/TPIInsetObserver.h +35 -0
- package/src/ios/TPIInsetObserver.m +38 -0
- package/src/www/Inset.ts +3 -20
- package/www/Inset.d.ts +3 -1
- package/www/Insets.d.ts +0 -1
- package/www/insets.js +3 -16
- package/www/insets.js.map +1 -1
- package/www/InsetType.d.ts +0 -22
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
-
## 0.
|
|
7
|
+
## 0.4.0 (September 9, 2025)
|
|
8
|
+
|
|
9
|
+
Introduced iOS implementation. While iOS's WKWebView has full support for CSS safe area insets, it does not consistently
|
|
10
|
+
work properly. Particularly on app launch while the iOS device is under load / throttled CPU. In our testing, we found that when this issue occurs
|
|
11
|
+
the native safe area inset reporting on `UIView` will continue to report accurately.
|
|
12
|
+
|
|
13
|
+
The WKWebView bug is very likely related to [#191872](https://bugs.webkit.org/show_bug.cgi?id=191872), though slight difference of behaviour where the safe area insets gets "stuck" until something triggers a native relayout (e.g. displaying a native dialog).
|
|
14
|
+
|
|
15
|
+
## 0.3.2 (September 27, 2024)
|
|
16
|
+
|
|
17
|
+
Rolled dependencies. No API change.
|
|
18
|
+
|
|
19
|
+
## 0.3.1 (Janurary 17, 2024)
|
|
20
|
+
|
|
21
|
+
A fix for android to apply rounded corners to the appropriate sides only, which more closely matches iOS behaviour.
|
|
22
|
+
|
|
23
|
+
## 0.3.0 (January 3, 2024)
|
|
8
24
|
|
|
9
25
|
### Breaking Changes:
|
|
10
26
|
|
package/README.md
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
cordova-plugin-insets
|
|
2
2
|
=====================
|
|
3
3
|
|
|
4
|
-
This plugin provides access to
|
|
4
|
+
This plugin provides access to native unsafe area insets. Normally these insets are accessed through the CSS env variables, unsafe-area-inset-* (where * is top, right, bottom, or left).
|
|
5
5
|
|
|
6
|
-
These env variables are recognized by Android's webviews but are not properly implemented. They always resolve to 0.
|
|
6
|
+
On Android These env variables are recognized by Android's webviews but are not properly implemented. They always resolve to 0.t
|
|
7
|
+
On iOS, in rare circumstances the CSS safe area inset variables may resolve to incorrectly 0.
|
|
7
8
|
|
|
8
9
|
This plugin provides a work around to obtain these values in javascript. You will have to implement your own javascript code to actually start using these values in your CSS.
|
|
9
10
|
|
|
10
11
|
## Supported Platforms
|
|
11
12
|
|
|
12
|
-
Android
|
|
13
|
-
|
|
14
|
-
If your app suppots multiple platforms, the API calls to this plugin should be platform guarded.
|
|
15
|
-
|
|
16
|
-
```javascript
|
|
17
|
-
if (cordova.platform === 'android') {
|
|
18
|
-
let insets = await window.totalpave.Inset.create();
|
|
19
|
-
}
|
|
20
|
-
```
|
|
13
|
+
- Android
|
|
14
|
+
- iOS
|
|
21
15
|
|
|
22
16
|
## Documentation
|
|
23
17
|
|
package/docs.md
CHANGED
|
@@ -107,6 +107,8 @@ update notifications. When the provider is no longer needed, it should be freed
|
|
|
107
107
|
Creating `Inset` objects will trigger a layout request, triggering an update on
|
|
108
108
|
all inset providers.
|
|
109
109
|
|
|
110
|
+
NOTE: Configurations are only supported on Android as iOS does not have an underlying API to provide inset information by mask type. Therefore configuration details are silently ignored on iOS.
|
|
111
|
+
|
|
110
112
|
##### Signature
|
|
111
113
|
|
|
112
114
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@totalpave/cordova-plugin-insets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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",
|
|
@@ -26,15 +26,16 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/totalpaveinc/cordova-plugin-insets#readme",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@rollup/plugin-commonjs": "28.0.
|
|
30
|
-
"@rollup/plugin-node-resolve": "
|
|
29
|
+
"@rollup/plugin-commonjs": "28.0.6",
|
|
30
|
+
"@rollup/plugin-node-resolve": "16.0.1",
|
|
31
31
|
"@types/cordova": "11.0.3",
|
|
32
|
+
"@types/node": "24.3.1",
|
|
32
33
|
"ejs": "3.1.10",
|
|
33
|
-
"rollup": "4.
|
|
34
|
+
"rollup": "4.50.1",
|
|
34
35
|
"rollup-plugin-progress": "1.1.2",
|
|
35
36
|
"rollup-plugin-typescript2": "0.36.0",
|
|
36
37
|
"ts-node": "10.9.2",
|
|
37
|
-
"typescript": "5.
|
|
38
|
+
"typescript": "5.9.2"
|
|
38
39
|
},
|
|
39
40
|
"engines": {
|
|
40
41
|
"cordovaDependencies": {
|
|
@@ -44,6 +45,6 @@
|
|
|
44
45
|
}
|
|
45
46
|
},
|
|
46
47
|
"dependencies": {
|
|
47
|
-
"tslib": "2.
|
|
48
|
+
"tslib": "2.8.1"
|
|
48
49
|
}
|
|
49
50
|
}
|
package/plugin.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<plugin
|
|
3
3
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
4
4
|
id="@totalpave/cordova-plugin-insets"
|
|
5
|
-
version="0.
|
|
5
|
+
version="0.4.0"
|
|
6
6
|
>
|
|
7
7
|
<name>cordova-plugin-insets</name>
|
|
8
8
|
<description>Cordova Android Plugin to receive native information regarding the unsafe area insets</description>
|
|
@@ -17,11 +17,24 @@
|
|
|
17
17
|
|
|
18
18
|
<platform name="android">
|
|
19
19
|
<config-file target="res/xml/config.xml" parent="/*">
|
|
20
|
+
<feature name="Inset">
|
|
21
|
+
<param name="android-package" value="com.totalpave.cordova.inset.Inset" />
|
|
22
|
+
</feature>
|
|
23
|
+
</config-file>
|
|
24
|
+
<source-file src="src/android/com/totalpave/cordova/inset/Inset.java" target-dir="src/com/totalpave/cordova/inset" />
|
|
25
|
+
</platform>
|
|
26
|
+
|
|
27
|
+
<platform name="ios">
|
|
28
|
+
<config-file target="config.xml" parent="/*">
|
|
20
29
|
<feature name="Inset">
|
|
21
|
-
<param name="
|
|
30
|
+
<param name="ios-package" value="TPIInset" />
|
|
22
31
|
</feature>
|
|
23
32
|
</config-file>
|
|
33
|
+
|
|
34
|
+
<header-file src="src/ios/TPIInset.h" target-dir="totalpave/insets" />
|
|
35
|
+
<source-file src="src/ios/TPIInset.m" target-dir="totalpave/insets" />
|
|
24
36
|
|
|
25
|
-
<
|
|
37
|
+
<header-file src="src/ios/TPIInsetObserver.h" target-dir="totalpave/insets" />
|
|
38
|
+
<source-file src="src/ios/TPIInsetObserver.m" target-dir="totalpave/insets" />
|
|
26
39
|
</platform>
|
|
27
40
|
</plugin>
|
package/plugin.xml.ejs
CHANGED
|
@@ -17,11 +17,24 @@
|
|
|
17
17
|
|
|
18
18
|
<platform name="android">
|
|
19
19
|
<config-file target="res/xml/config.xml" parent="/*">
|
|
20
|
+
<feature name="Inset">
|
|
21
|
+
<param name="android-package" value="com.totalpave.cordova.inset.Inset" />
|
|
22
|
+
</feature>
|
|
23
|
+
</config-file>
|
|
24
|
+
<source-file src="src/android/com/totalpave/cordova/inset/Inset.java" target-dir="src/com/totalpave/cordova/inset" />
|
|
25
|
+
</platform>
|
|
26
|
+
|
|
27
|
+
<platform name="ios">
|
|
28
|
+
<config-file target="config.xml" parent="/*">
|
|
20
29
|
<feature name="Inset">
|
|
21
|
-
<param name="
|
|
30
|
+
<param name="ios-package" value="TPIInset" />
|
|
22
31
|
</feature>
|
|
23
32
|
</config-file>
|
|
33
|
+
|
|
34
|
+
<header-file src="src/ios/TPIInset.h" target-dir="totalpave/insets" />
|
|
35
|
+
<source-file src="src/ios/TPIInset.m" target-dir="totalpave/insets" />
|
|
24
36
|
|
|
25
|
-
<
|
|
37
|
+
<header-file src="src/ios/TPIInsetObserver.h" target-dir="totalpave/insets" />
|
|
38
|
+
<source-file src="src/ios/TPIInsetObserver.m" target-dir="totalpave/insets" />
|
|
26
39
|
</platform>
|
|
27
40
|
</plugin>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2025 Total Pave Inc.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#ifndef TPIInset_h
|
|
19
|
+
#define TPIInset_h
|
|
20
|
+
|
|
21
|
+
#import <Foundation/Foundation.h>
|
|
22
|
+
#import <Cordova/CDVPlugin.h>
|
|
23
|
+
|
|
24
|
+
@interface TPIInset: CDVPlugin {}
|
|
25
|
+
|
|
26
|
+
- (void) create:(CDVInvokedUrlCommand*) command;
|
|
27
|
+
- (void) delete:(CDVInvokedUrlCommand*) command;
|
|
28
|
+
|
|
29
|
+
@end
|
|
30
|
+
|
|
31
|
+
#endif
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Total Pave Inc.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#import <Foundation/Foundation.h>
|
|
18
|
+
#import "TPIInset.h"
|
|
19
|
+
#import "TPIInsetObserver.h"
|
|
20
|
+
#import <UIKit/UIKit.h>
|
|
21
|
+
|
|
22
|
+
@implementation TPIInset {
|
|
23
|
+
NSMutableDictionary* $listeners;
|
|
24
|
+
TPIInsetObserver* $observer;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
- (void) pluginInitialize {
|
|
28
|
+
self->$listeners = [[NSMutableDictionary alloc] init];
|
|
29
|
+
self->$observer = [[TPIInsetObserver alloc] init];
|
|
30
|
+
self->$observer.frame = self.viewController.view.frame;
|
|
31
|
+
self->$observer.userInteractionEnabled = false;
|
|
32
|
+
self->$observer.translatesAutoresizingMaskIntoConstraints = false;
|
|
33
|
+
|
|
34
|
+
__weak TPIInset* weakSelf = self;
|
|
35
|
+
|
|
36
|
+
self->$observer.safeAreaChanged = ^(UIEdgeInsets insets) {
|
|
37
|
+
TPIInset* strongSelf = weakSelf;
|
|
38
|
+
|
|
39
|
+
if (strongSelf == nil) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@synchronized (strongSelf->$listeners) {
|
|
44
|
+
for (id key in strongSelf->$listeners) {
|
|
45
|
+
NSDictionary* value = strongSelf->$listeners[key];
|
|
46
|
+
[strongSelf emitInsetChange: value inset: insets];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
[self.viewController.view addSubview: self->$observer];
|
|
52
|
+
|
|
53
|
+
[NSLayoutConstraint activateConstraints:@[
|
|
54
|
+
[self->$observer.topAnchor constraintEqualToAnchor:self.viewController.view.topAnchor],
|
|
55
|
+
[self->$observer.bottomAnchor constraintEqualToAnchor:self.viewController.view.bottomAnchor],
|
|
56
|
+
[self->$observer.leadingAnchor constraintEqualToAnchor:self.viewController.view.leadingAnchor],
|
|
57
|
+
[self->$observer.trailingAnchor constraintEqualToAnchor:self.viewController.view.trailingAnchor],
|
|
58
|
+
]];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
- (void) emitInsetChange:(NSDictionary*) listener inset:(UIEdgeInsets) inset {
|
|
62
|
+
NSString* callbackID = [listener objectForKey: @"callbackID"];
|
|
63
|
+
|
|
64
|
+
if (callbackID == nil) return;
|
|
65
|
+
|
|
66
|
+
NSString* ident = [listener objectForKey:@"id"];
|
|
67
|
+
if (ident == nil) return;
|
|
68
|
+
|
|
69
|
+
NSDictionary* payload = @{
|
|
70
|
+
@"type": @"update",
|
|
71
|
+
@"id": ident,
|
|
72
|
+
@"data": @{
|
|
73
|
+
@"top": @(inset.top),
|
|
74
|
+
@"bottom": @(inset.bottom),
|
|
75
|
+
@"left": @(inset.left),
|
|
76
|
+
@"right": @(inset.right)
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: payload];
|
|
81
|
+
[result setKeepCallbackAsBool: true];
|
|
82
|
+
[self.commandDelegate sendPluginResult: result callbackId: callbackID];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
- (UIEdgeInsets) $getViewInsets {
|
|
86
|
+
if (self.viewController.viewIfLoaded == nil) {
|
|
87
|
+
return UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 0.0f);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return self.viewController.view.safeAreaInsets;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
- (void) create:(CDVInvokedUrlCommand*) command {
|
|
94
|
+
NSString* ident = [[NSUUID UUID] UUIDString];
|
|
95
|
+
|
|
96
|
+
NSDictionary* listener = @{
|
|
97
|
+
@"id": ident,
|
|
98
|
+
@"callbackID": command.callbackId
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{
|
|
102
|
+
@"type": @"init",
|
|
103
|
+
@"data": ident
|
|
104
|
+
}];
|
|
105
|
+
[result setKeepCallbackAsBool: true];
|
|
106
|
+
|
|
107
|
+
@synchronized (self->$listeners) {
|
|
108
|
+
[self->$listeners setObject: listener forKey: ident];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
[self.commandDelegate sendPluginResult: result callbackId: command.callbackId];
|
|
112
|
+
|
|
113
|
+
[self emitInsetChange: listener inset: self->$observer.safeAreaInsets];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void) delete:(CDVInvokedUrlCommand*) command {
|
|
117
|
+
NSString* ident = [command argumentAtIndex: 0];
|
|
118
|
+
|
|
119
|
+
@synchronized (self->$listeners) {
|
|
120
|
+
[self->$listeners removeObjectForKey: ident];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK];
|
|
124
|
+
[self.commandDelegate sendPluginResult: result callbackId: command.callbackId];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
- (void) dealloc {
|
|
128
|
+
[self->$observer removeFromSuperview];
|
|
129
|
+
self->$observer.safeAreaChanged = nil;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Total Pave Inc.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#ifndef TPIInsetObserver_h
|
|
19
|
+
#define TPIInsetObserver_h
|
|
20
|
+
|
|
21
|
+
#import <Foundation/Foundation.h>
|
|
22
|
+
#import <UIKit/UIKit.h>
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
iOS SDK does not provide an ability to listen for safe area inset changes outside of views, so
|
|
26
|
+
this is a dummy view that can be attached to the window and it accepts a function pointer which will dispatch safe area changes to.
|
|
27
|
+
When the view is attached to the window, it will fire at least one event. So setup the function hook before attaching it to the window hierachy.
|
|
28
|
+
*/
|
|
29
|
+
@interface TPIInsetObserver: UIView
|
|
30
|
+
|
|
31
|
+
@property (nonatomic, copy) void (^safeAreaChanged)(UIEdgeInsets insets);
|
|
32
|
+
|
|
33
|
+
@end
|
|
34
|
+
|
|
35
|
+
#endif
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Total Pave Inc.
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
#import <Foundation/Foundation.h>
|
|
18
|
+
#import "TPIInsetObserver.h"
|
|
19
|
+
|
|
20
|
+
@implementation TPIInsetObserver
|
|
21
|
+
|
|
22
|
+
- (void) emit {
|
|
23
|
+
self.safeAreaChanged(self.safeAreaInsets);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
- (void) didMoveToWindow {
|
|
27
|
+
[super didMoveToWindow];
|
|
28
|
+
if (self.window) {
|
|
29
|
+
[self emit];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (void) safeAreaInsetsDidChange {
|
|
34
|
+
[super safeAreaInsetsDidChange];
|
|
35
|
+
[self emit];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@end
|
package/src/www/Inset.ts
CHANGED
|
@@ -116,14 +116,6 @@ export class Inset {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
private static $generateID(): string {
|
|
120
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
121
|
-
const r = Math.random() * 16 | 0,
|
|
122
|
-
v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
123
|
-
return v.toString(16);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
119
|
/**
|
|
128
120
|
* Configures a new Inset instance to listen for inset changes
|
|
129
121
|
* It's valid to have multiple instances, with different configurations
|
|
@@ -137,6 +129,9 @@ export class Inset {
|
|
|
137
129
|
* single instance and share it rather than every object having it's own
|
|
138
130
|
* inset listener instance.
|
|
139
131
|
*
|
|
132
|
+
* NOTE: Configurations are only supported by Android. It is silently
|
|
133
|
+
* ignored on iOS
|
|
134
|
+
*
|
|
140
135
|
* @param config
|
|
141
136
|
* @returns
|
|
142
137
|
*/
|
|
@@ -146,13 +141,6 @@ export class Inset {
|
|
|
146
141
|
config = {};
|
|
147
142
|
}
|
|
148
143
|
|
|
149
|
-
if (cordova.platformId === 'ios') {
|
|
150
|
-
let instance: Inset = new Inset();
|
|
151
|
-
instance.$id = Inset.$generateID();
|
|
152
|
-
resolve(instance);
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
144
|
let inset: Inset = new Inset();
|
|
157
145
|
|
|
158
146
|
cordova.exec(
|
|
@@ -198,11 +186,6 @@ export class Inset {
|
|
|
198
186
|
}
|
|
199
187
|
|
|
200
188
|
return new Promise<void>((resolve, reject) => {
|
|
201
|
-
if (cordova.platformId === 'ios') {
|
|
202
|
-
resolve();
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
189
|
cordova.exec(
|
|
207
190
|
() => {
|
|
208
191
|
resolve();
|
package/www/Inset.d.ts
CHANGED
|
@@ -47,7 +47,6 @@ export declare class Inset {
|
|
|
47
47
|
*/
|
|
48
48
|
removeListener(listener: IInsetCallbackFunc): void;
|
|
49
49
|
private $onUpdate;
|
|
50
|
-
private static $generateID;
|
|
51
50
|
/**
|
|
52
51
|
* Configures a new Inset instance to listen for inset changes
|
|
53
52
|
* It's valid to have multiple instances, with different configurations
|
|
@@ -61,6 +60,9 @@ export declare class Inset {
|
|
|
61
60
|
* single instance and share it rather than every object having it's own
|
|
62
61
|
* inset listener instance.
|
|
63
62
|
*
|
|
63
|
+
* NOTE: Configurations are only supported by Android. It is silently
|
|
64
|
+
* ignored on iOS
|
|
65
|
+
*
|
|
64
66
|
* @param config
|
|
65
67
|
* @returns
|
|
66
68
|
*/
|
package/www/Insets.d.ts
CHANGED
package/www/insets.js
CHANGED
|
@@ -89,12 +89,6 @@ class Inset {
|
|
|
89
89
|
this.$listeners[i](insets);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
static $generateID() {
|
|
93
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
94
|
-
const r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
95
|
-
return v.toString(16);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
92
|
/**
|
|
99
93
|
* Configures a new Inset instance to listen for inset changes
|
|
100
94
|
* It's valid to have multiple instances, with different configurations
|
|
@@ -108,6 +102,9 @@ class Inset {
|
|
|
108
102
|
* single instance and share it rather than every object having it's own
|
|
109
103
|
* inset listener instance.
|
|
110
104
|
*
|
|
105
|
+
* NOTE: Configurations are only supported by Android. It is silently
|
|
106
|
+
* ignored on iOS
|
|
107
|
+
*
|
|
111
108
|
* @param config
|
|
112
109
|
* @returns
|
|
113
110
|
*/
|
|
@@ -116,12 +113,6 @@ class Inset {
|
|
|
116
113
|
if (!config) {
|
|
117
114
|
config = {};
|
|
118
115
|
}
|
|
119
|
-
if (cordova.platformId === 'ios') {
|
|
120
|
-
let instance = new Inset();
|
|
121
|
-
instance.$id = Inset.$generateID();
|
|
122
|
-
resolve(instance);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
116
|
let inset = new Inset();
|
|
126
117
|
cordova.exec((e) => {
|
|
127
118
|
if (Inset.$isInitEvent(e)) {
|
|
@@ -157,10 +148,6 @@ class Inset {
|
|
|
157
148
|
id = inset.getID();
|
|
158
149
|
}
|
|
159
150
|
return new Promise((resolve, reject) => {
|
|
160
|
-
if (cordova.platformId === 'ios') {
|
|
161
|
-
resolve();
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
151
|
cordova.exec(() => {
|
|
165
152
|
resolve();
|
|
166
153
|
}, reject, SERVICE_NAME, "delete", [id]);
|
package/www/insets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insets.js","sources":["../src/www/Inset.ts","../src/www/InsetMask.ts"],"sourcesContent":["/*\n Copyright 2022-2024 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\nimport {IInsetConfiguration} from './IInsetConfiguration';\nimport {IInsetCallbackFunc} from './IInsetCallbackFunc';\nimport {IInset} from './IInset';\n\nexport const SERVICE_NAME: string = \"Inset\";\n\ninterface IInsetEvent<T = unknown> {\n type: 'init' | 'update';\n data: T;\n}\n\ntype IInsetInitEvent = IInsetEvent<string>;\ninterface IInsetUpdateEvent extends IInsetEvent<IInset> {\n id: string;\n}\n\nexport class Inset {\n private $currentInset: IInset;\n private $listeners: IInsetCallbackFunc[];\n private $id: string;\n\n private constructor() {\n this.$id = null;\n this.$listeners = [];\n this.$currentInset = {\n top: 0,\n left: 0,\n right: 0,\n bottom: 0\n };\n }\n\n /**\n * Gets the native identifier\n * \n * @returns \n */\n public getID(): string {\n return this.$id;\n }\n\n /**\n * Gets the last emitted inset information\n * \n * @returns\n */\n public getInsets(): IInset {\n console.warn('getInsets() is deprecated, use getInset instead()', new Error().stack);\n return this.getInset();\n }\n\n public getInset(): IInset {\n return this.$currentInset;\n }\n\n /**\n * See the static Inset.free method for details\n * \n * This is the equivilant of calling Inset.free(insetInstance)\n * \n * @returns \n */\n public async free(): Promise<void> {\n return await Inset.free(this);\n }\n\n /**\n * Adds a listener to this inset configuration.\n * \n * Note that this may fire even if nothing has actually\n * changed.\n * \n * Retain the listener reference to remove it later if\n * necessary.\n * \n * @param listener \n */\n public addListener(listener: IInsetCallbackFunc): void {\n this.$listeners.push(listener);\n listener(this.$currentInset);\n }\n\n /**\n * Frees the listener reference\n * \n * @param listener \n */\n public removeListener(listener: IInsetCallbackFunc): void {\n let idx: number = this.$listeners.indexOf(listener);\n if (idx > -1) {\n this.$listeners.splice(idx, 1);\n }\n }\n\n private $onUpdate(insets: IInset): void {\n this.$currentInset = insets;\n\n for (let i = 0; i < this.$listeners.length; i++) {\n this.$listeners[i](insets);\n }\n }\n\n private static $generateID(): string {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n const r = Math.random() * 16 | 0,\n v = c === 'x' ? r : (r & 0x3 | 0x8);\n return v.toString(16);\n });\n }\n\n /**\n * Configures a new Inset instance to listen for inset changes\n * It's valid to have multiple instances, with different configurations\n * Each instance may have 0-to-many listeners attached via addListener\n * \n * If this instance is no longer needed/used, call `free` to free\n * resources.\n * \n * It will be more performant to keep the instance count low. If only one\n * configuration set is needed, then it would be recommended to create a\n * single instance and share it rather than every object having it's own\n * inset listener instance.\n * \n * @param config \n * @returns \n */\n public static create(config: IInsetConfiguration): Promise<Inset> {\n return new Promise<Inset>((resolve, reject) => {\n if (!config) {\n config = {};\n }\n\n if (cordova.platformId === 'ios') {\n let instance: Inset = new Inset();\n instance.$id = Inset.$generateID();\n resolve(instance);\n return;\n }\n\n let inset: Inset = new Inset();\n\n cordova.exec(\n (e: IInsetEvent) => {\n if (Inset.$isInitEvent(e)) {\n inset.$id = e.data;\n resolve(inset);\n }\n else if (Inset.$isUpdateEvent(e)) {\n inset.$onUpdate(e.data);\n }\n },\n reject,\n SERVICE_NAME,\n \"create\",\n [config]\n );\n });\n }\n\n /**\n * Frees the native resources associated with the given\n * inset.\n * \n * After freeing, the inset is no longer usable and it will\n * not receive anymore inset updates. If you retain any\n * references to inset listeners, they should also be dereferenced\n * to allow for garbage collection.\n * \n * This is the equivilant of calling `await inset.free()`\n * \n * @param inset \n * @returns \n */\n public static free(inset: Inset | string): Promise<void> {\n let id: string = null;\n\n if (typeof inset === 'string') {\n id = inset;\n }\n else {\n id = inset.getID();\n }\n\n return new Promise<void>((resolve, reject) => {\n if (cordova.platformId === 'ios') {\n resolve();\n return;\n }\n\n cordova.exec(\n () => {\n resolve();\n },\n reject,\n SERVICE_NAME,\n \"delete\",\n [id]\n );\n });\n }\n\n private static $isInitEvent(e: IInsetEvent): e is IInsetInitEvent {\n return e.type === 'init';\n }\n\n private static $isUpdateEvent(e: IInsetEvent): e is IInsetUpdateEvent {\n return e.type === 'update';\n }\n}\n\ndeclare global {\n interface ITotalpave {\n Inset: Inset;\n }\n interface Window {\n totalpave: ITotalpave;\n }\n}\n","/*\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\n/**\n * An enumeration of Inset Types.\n * These are mapped to android's native WindowInsetsCompat.TYPE\n * \n * See https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type\n * for more information.\n * \n * Note that the native constant values is an implementation detail,\n * therefore the values here isn't a direct mapping, but will be resolved\n * appropriately.\n */\nexport enum InsetMask {\n CAPTION_BAR = 1,\n DISPLAY_CUTOUT = 1 << 1,\n IME = 1 << 2,\n MANDATORY_SYSTEM_GESTURES = 1 << 3,\n NAVIGATION_BARS = 1 << 4,\n STATUS_BARS = 1 << 5,\n SYSTEM_BARS = 1 << 6,\n SYSTEM_GESTURES = 1 << 7,\n TAPPABLE_ELEMENT = 1 << 8\n};\n"],"names":["InsetMask"],"mappings":";;AAAA;;;;;;;;;;;;;;AAcE;AAMK,MAAM,YAAY,GAAW,OAAO,CAAC;MAY/B,KAAK,CAAA;AAKd,IAAA,WAAA,GAAA;AACI,QAAA,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;AAChB,QAAA,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG;AACjB,YAAA,GAAG,EAAE,CAAC;AACN,YAAA,IAAI,EAAE,CAAC;AACP,YA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AA,SAAA,CAAA,2BAAA,CAAA,GAAA,CAAA,CAAA,GAAA,2BAAoC,CAAA;AACpC,IAAA,SAAA,CAAA,SAAA,CAAA,iBAAA,CAAA,GAAA,EAAA,CAAA,GAAA,iBAAoC,CAAA;AACpC,IAAA,SAAA,CAAA,SAAA,CAAA,aAAA,CAAA,GAAA,EAAA,CAAA,GAAA,aAAoC,CAAA;AACpC,IAAA,SAAA,CAAA,SAAA,CAAA,aAAA,CAAA,GAAA,EAAA,CAAA,GAAA,aAAoC,CAAA;AACpC,IAAA,SAAA,CAAA,SAAA,CAAA,iBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,iBAAoC,CAAA;AACpC,IAAA,SAAA,CAAA,SAAA,CAAA,kBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,kBAAoC,CAAA;AACxC,CAAC,EAVWA,iBAAS,KAATA,iBAAS,GAUpB,EAAA,CAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"insets.js","sources":["../src/www/Inset.ts","../src/www/InsetMask.ts"],"sourcesContent":["/*\n Copyright 2022-2024 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\nimport {IInsetConfiguration} from './IInsetConfiguration';\nimport {IInsetCallbackFunc} from './IInsetCallbackFunc';\nimport {IInset} from './IInset';\n\nexport const SERVICE_NAME: string = \"Inset\";\n\ninterface IInsetEvent<T = unknown> {\n type: 'init' | 'update';\n data: T;\n}\n\ntype IInsetInitEvent = IInsetEvent<string>;\ninterface IInsetUpdateEvent extends IInsetEvent<IInset> {\n id: string;\n}\n\nexport class Inset {\n private $currentInset: IInset;\n private $listeners: IInsetCallbackFunc[];\n private $id: string;\n\n private constructor() {\n this.$id = null;\n this.$listeners = [];\n this.$currentInset = {\n top: 0,\n left: 0,\n right: 0,\n bottom: 0\n };\n }\n\n /**\n * Gets the native identifier\n * \n * @returns \n */\n public getID(): string {\n return this.$id;\n }\n\n /**\n * Gets the last emitted inset information\n * \n * @returns\n */\n public getInsets(): IInset {\n console.warn('getInsets() is deprecated, use getInset instead()', new Error().stack);\n return this.getInset();\n }\n\n public getInset(): IInset {\n return this.$currentInset;\n }\n\n /**\n * See the static Inset.free method for details\n * \n * This is the equivilant of calling Inset.free(insetInstance)\n * \n * @returns \n */\n public async free(): Promise<void> {\n return await Inset.free(this);\n }\n\n /**\n * Adds a listener to this inset configuration.\n * \n * Note that this may fire even if nothing has actually\n * changed.\n * \n * Retain the listener reference to remove it later if\n * necessary.\n * \n * @param listener \n */\n public addListener(listener: IInsetCallbackFunc): void {\n this.$listeners.push(listener);\n listener(this.$currentInset);\n }\n\n /**\n * Frees the listener reference\n * \n * @param listener \n */\n public removeListener(listener: IInsetCallbackFunc): void {\n let idx: number = this.$listeners.indexOf(listener);\n if (idx > -1) {\n this.$listeners.splice(idx, 1);\n }\n }\n\n private $onUpdate(insets: IInset): void {\n this.$currentInset = insets;\n\n for (let i = 0; i < this.$listeners.length; i++) {\n this.$listeners[i](insets);\n }\n }\n\n /**\n * Configures a new Inset instance to listen for inset changes\n * It's valid to have multiple instances, with different configurations\n * Each instance may have 0-to-many listeners attached via addListener\n * \n * If this instance is no longer needed/used, call `free` to free\n * resources.\n * \n * It will be more performant to keep the instance count low. If only one\n * configuration set is needed, then it would be recommended to create a\n * single instance and share it rather than every object having it's own\n * inset listener instance.\n * \n * NOTE: Configurations are only supported by Android. It is silently\n * ignored on iOS\n * \n * @param config \n * @returns \n */\n public static create(config: IInsetConfiguration): Promise<Inset> {\n return new Promise<Inset>((resolve, reject) => {\n if (!config) {\n config = {};\n }\n\n let inset: Inset = new Inset();\n\n cordova.exec(\n (e: IInsetEvent) => {\n if (Inset.$isInitEvent(e)) {\n inset.$id = e.data;\n resolve(inset);\n }\n else if (Inset.$isUpdateEvent(e)) {\n inset.$onUpdate(e.data);\n }\n },\n reject,\n SERVICE_NAME,\n \"create\",\n [config]\n );\n });\n }\n\n /**\n * Frees the native resources associated with the given\n * inset.\n * \n * After freeing, the inset is no longer usable and it will\n * not receive anymore inset updates. If you retain any\n * references to inset listeners, they should also be dereferenced\n * to allow for garbage collection.\n * \n * This is the equivilant of calling `await inset.free()`\n * \n * @param inset \n * @returns \n */\n public static free(inset: Inset | string): Promise<void> {\n let id: string = null;\n\n if (typeof inset === 'string') {\n id = inset;\n }\n else {\n id = inset.getID();\n }\n\n return new Promise<void>((resolve, reject) => {\n cordova.exec(\n () => {\n resolve();\n },\n reject,\n SERVICE_NAME,\n \"delete\",\n [id]\n );\n });\n }\n\n private static $isInitEvent(e: IInsetEvent): e is IInsetInitEvent {\n return e.type === 'init';\n }\n\n private static $isUpdateEvent(e: IInsetEvent): e is IInsetUpdateEvent {\n return e.type === 'update';\n }\n}\n\ndeclare global {\n interface ITotalpave {\n Inset: Inset;\n }\n interface Window {\n totalpave: ITotalpave;\n }\n}\n","/*\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\n/**\n * An enumeration of Inset Types.\n * These are mapped to android's native WindowInsetsCompat.TYPE\n * \n * See https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type\n * for more information.\n * \n * Note that the native constant values is an implementation detail,\n * therefore the values here isn't a direct mapping, but will be resolved\n * appropriately.\n */\nexport enum InsetMask {\n CAPTION_BAR = 1,\n DISPLAY_CUTOUT = 1 << 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C;AACpC,IAAA,SAAA,CAAA,SAAA,CAAA,kBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,kBAAoC;AACxC,CAAC,EAVWA,iBAAS,KAATA,iBAAS,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/www/InsetType.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An enumeration of Inset Types.
|
|
3
|
-
* These are mapped to android's native WindowInsetsCompat.TYPE
|
|
4
|
-
*
|
|
5
|
-
* See https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Type
|
|
6
|
-
* for more information.
|
|
7
|
-
*
|
|
8
|
-
* Note that the native constant values is an implementation detail,
|
|
9
|
-
* therefore the values here isn't a direct mapping, but will be resolved
|
|
10
|
-
* appropriately.
|
|
11
|
-
*/
|
|
12
|
-
export declare enum InsetType {
|
|
13
|
-
CAPTION_BAR = 1,
|
|
14
|
-
DISPLAY_CUTOUT = 2,
|
|
15
|
-
IME = 4,
|
|
16
|
-
MANDATORY_SYSTEM_GESTURES = 8,
|
|
17
|
-
NAVIGATION_BARS = 16,
|
|
18
|
-
STATUS_BARS = 32,
|
|
19
|
-
SYSTEM_BARS = 64,
|
|
20
|
-
SYSTEM_GESTURES = 128,
|
|
21
|
-
TAPPABLE_ELEMENT = 256
|
|
22
|
-
}
|