@hiloenergie/capacitor-plugin-safe-area 0.0.10 → 0.0.12-beta.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/HiloenergieCapacitorPluginSafeArea.podspec +17 -17
- package/README.md +225 -225
- package/android/build.gradle +58 -58
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/getcapacitor/community/plugins/safearea/SafeAreaPlugin.java +158 -158
- package/android/src/main/java/com/getcapacitor/community/plugins/safearea/SafeAreaView.java +48 -48
- package/dist/docs.json +3 -3
- package/dist/esm/controller.js +1 -1
- package/dist/esm/controller.js.map +1 -1
- package/dist/esm/definitions.d.ts +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/SafeAreaPlugin.swift +25 -71
- package/package.json +7 -7
package/android/src/main/java/com/getcapacitor/community/plugins/safearea/SafeAreaPlugin.java
CHANGED
|
@@ -1,158 +1,158 @@
|
|
|
1
|
-
package com.getcapacitor.community.plugins.safearea;
|
|
2
|
-
|
|
3
|
-
import android.annotation.SuppressLint;
|
|
4
|
-
import android.graphics.Insets;
|
|
5
|
-
import android.os.Build;
|
|
6
|
-
import android.view.DisplayCutout;
|
|
7
|
-
import android.view.View;
|
|
8
|
-
import android.view.ViewGroup;
|
|
9
|
-
import android.view.WindowInsets;
|
|
10
|
-
import android.widget.FrameLayout;
|
|
11
|
-
|
|
12
|
-
import com.getcapacitor.JSObject;
|
|
13
|
-
import com.getcapacitor.Plugin;
|
|
14
|
-
import com.getcapacitor.PluginCall;
|
|
15
|
-
import com.getcapacitor.PluginMethod;
|
|
16
|
-
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
17
|
-
|
|
18
|
-
@CapacitorPlugin(name = "SafeArea")
|
|
19
|
-
public class SafeAreaPlugin extends Plugin {
|
|
20
|
-
private static final String KEY_INSET = "insets";
|
|
21
|
-
private static final String EVENT_ON_INSETS_CHANGED = "safeAreaPluginsInsetChange";
|
|
22
|
-
private SafeAreaInsets safeAreaInsets = new com.getcapacitor.community.plugins.safearea.SafeAreaInsets();
|
|
23
|
-
private SafeAreaView safeAreaView;
|
|
24
|
-
|
|
25
|
-
@Override
|
|
26
|
-
public void load() {
|
|
27
|
-
this.getBridge().getActivity().runOnUiThread(() -> {
|
|
28
|
-
safeAreaView = new SafeAreaView(this.getBridge().getActivity(), (WindowInsets insets) -> {
|
|
29
|
-
this.getSafeArea(insets);
|
|
30
|
-
this.doNotify();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
FrameLayout.LayoutParams safeAreaPreviewParams = new FrameLayout.LayoutParams(
|
|
34
|
-
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
35
|
-
FrameLayout.LayoutParams.MATCH_PARENT
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
// Set SafeAreaView as sibling View of WebView
|
|
39
|
-
((ViewGroup) this.getBridge().getWebView().getParent()).addView(safeAreaView, safeAreaPreviewParams);
|
|
40
|
-
|
|
41
|
-
// Bring the WebView in front of the SafeAreaView
|
|
42
|
-
this.getBridge().getWebView().bringToFront();
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@PluginMethod
|
|
47
|
-
public void refresh(PluginCall call) {
|
|
48
|
-
this.doNotify();
|
|
49
|
-
call.success();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@PluginMethod
|
|
53
|
-
public void getSafeAreaInsets(PluginCall call) {
|
|
54
|
-
JSObject ret = new JSObject();
|
|
55
|
-
|
|
56
|
-
ret.put(SafeAreaPlugin.KEY_INSET, this.safeAreaInsets.toJSON());
|
|
57
|
-
|
|
58
|
-
call.success(ret);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
protected void getSafeArea(WindowInsets windowInsets) {
|
|
62
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
63
|
-
this.getSafeAreaR(windowInsets);
|
|
64
|
-
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
65
|
-
this.getSafeAreaQ(windowInsets);
|
|
66
|
-
} else {
|
|
67
|
-
this.getSafeAreaLollipop(windowInsets);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Cutout
|
|
71
|
-
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
|
|
72
|
-
this.getSafeAreaCutout(windowInsets);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
float density = this.getBridge().getActivity().getResources().getDisplayMetrics().density;
|
|
76
|
-
|
|
77
|
-
this.applySafeAreaInsets(
|
|
78
|
-
Math.round(this.safeAreaInsets.top() / density),
|
|
79
|
-
Math.round(this.safeAreaInsets.bottom() / density),
|
|
80
|
-
Math.round(this.safeAreaInsets.left() / density),
|
|
81
|
-
Math.round(this.safeAreaInsets.right() / density)
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// api level 30
|
|
86
|
-
// Get insets (Mandatory System Gestures: https://developer.android.com/reference/android/view/WindowInsets#getMandatorySystemGestureInsets())
|
|
87
|
-
@SuppressLint("NewApi")
|
|
88
|
-
protected void getSafeAreaR(WindowInsets windowInsets) {
|
|
89
|
-
Insets finalInsets = windowInsets.getInsets(WindowInsets.Type.mandatorySystemGestures());
|
|
90
|
-
|
|
91
|
-
this.applySafeAreaInsets(
|
|
92
|
-
finalInsets.top,
|
|
93
|
-
finalInsets.bottom,
|
|
94
|
-
finalInsets.left,
|
|
95
|
-
finalInsets.right
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// api level 29
|
|
100
|
-
@SuppressLint("NewApi")
|
|
101
|
-
protected void getSafeAreaQ(WindowInsets windowInsets) {
|
|
102
|
-
Insets finalInsets = windowInsets.getMandatorySystemGestureInsets();
|
|
103
|
-
|
|
104
|
-
this.applySafeAreaInsets(
|
|
105
|
-
finalInsets.top,
|
|
106
|
-
finalInsets.bottom,
|
|
107
|
-
finalInsets.left,
|
|
108
|
-
finalInsets.right
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// api level 21
|
|
113
|
-
protected void getSafeAreaLollipop(WindowInsets windowInsets) {
|
|
114
|
-
this.applySafeAreaInsets(
|
|
115
|
-
windowInsets.getSystemWindowInsetTop(),
|
|
116
|
-
windowInsets.getStableInsetBottom(),
|
|
117
|
-
windowInsets.getStableInsetLeft(),
|
|
118
|
-
windowInsets.getStableInsetRight()
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// cutout (api level >= 28)
|
|
123
|
-
@SuppressLint("NewApi")
|
|
124
|
-
protected void getSafeAreaCutout(WindowInsets windowInsets) {
|
|
125
|
-
DisplayCutout cutout = windowInsets.getDisplayCutout();
|
|
126
|
-
if (cutout != null) {
|
|
127
|
-
this.applySafeAreaInsets(
|
|
128
|
-
Math.max(this.safeAreaInsets.top(), cutout.getSafeInsetTop()),
|
|
129
|
-
Math.max(this.safeAreaInsets.bottom(), cutout.getSafeInsetBottom()),
|
|
130
|
-
Math.max(this.safeAreaInsets.left(), cutout.getSafeInsetLeft()),
|
|
131
|
-
Math.max(this.safeAreaInsets.right(), cutout.getSafeInsetRight())
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
protected void doNotify() {
|
|
137
|
-
JSObject ret = new JSObject();
|
|
138
|
-
|
|
139
|
-
ret.put(SafeAreaPlugin.KEY_INSET, this.safeAreaInsets.toJSON());
|
|
140
|
-
|
|
141
|
-
this.notifyListeners(SafeAreaPlugin.EVENT_ON_INSETS_CHANGED, ret);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
private void applySafeAreaInsets(int top, int bottom, int left, int right) {
|
|
145
|
-
View decorView = this.getBridge().getActivity().getWindow().getDecorView();
|
|
146
|
-
int uiVisibility = decorView.getSystemUiVisibility();
|
|
147
|
-
|
|
148
|
-
if ((uiVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) {
|
|
149
|
-
this.safeAreaInsets.bottom(bottom);
|
|
150
|
-
} else {
|
|
151
|
-
this.safeAreaInsets.bottom(0);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
this.safeAreaInsets.top(top);
|
|
155
|
-
this.safeAreaInsets.right(left);
|
|
156
|
-
this.safeAreaInsets.left(right);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
1
|
+
package com.getcapacitor.community.plugins.safearea;
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint;
|
|
4
|
+
import android.graphics.Insets;
|
|
5
|
+
import android.os.Build;
|
|
6
|
+
import android.view.DisplayCutout;
|
|
7
|
+
import android.view.View;
|
|
8
|
+
import android.view.ViewGroup;
|
|
9
|
+
import android.view.WindowInsets;
|
|
10
|
+
import android.widget.FrameLayout;
|
|
11
|
+
|
|
12
|
+
import com.getcapacitor.JSObject;
|
|
13
|
+
import com.getcapacitor.Plugin;
|
|
14
|
+
import com.getcapacitor.PluginCall;
|
|
15
|
+
import com.getcapacitor.PluginMethod;
|
|
16
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
17
|
+
|
|
18
|
+
@CapacitorPlugin(name = "SafeArea")
|
|
19
|
+
public class SafeAreaPlugin extends Plugin {
|
|
20
|
+
private static final String KEY_INSET = "insets";
|
|
21
|
+
private static final String EVENT_ON_INSETS_CHANGED = "safeAreaPluginsInsetChange";
|
|
22
|
+
private SafeAreaInsets safeAreaInsets = new com.getcapacitor.community.plugins.safearea.SafeAreaInsets();
|
|
23
|
+
private SafeAreaView safeAreaView;
|
|
24
|
+
|
|
25
|
+
@Override
|
|
26
|
+
public void load() {
|
|
27
|
+
this.getBridge().getActivity().runOnUiThread(() -> {
|
|
28
|
+
safeAreaView = new SafeAreaView(this.getBridge().getActivity(), (WindowInsets insets) -> {
|
|
29
|
+
this.getSafeArea(insets);
|
|
30
|
+
this.doNotify();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
FrameLayout.LayoutParams safeAreaPreviewParams = new FrameLayout.LayoutParams(
|
|
34
|
+
FrameLayout.LayoutParams.MATCH_PARENT,
|
|
35
|
+
FrameLayout.LayoutParams.MATCH_PARENT
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Set SafeAreaView as sibling View of WebView
|
|
39
|
+
((ViewGroup) this.getBridge().getWebView().getParent()).addView(safeAreaView, safeAreaPreviewParams);
|
|
40
|
+
|
|
41
|
+
// Bring the WebView in front of the SafeAreaView
|
|
42
|
+
this.getBridge().getWebView().bringToFront();
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@PluginMethod
|
|
47
|
+
public void refresh(PluginCall call) {
|
|
48
|
+
this.doNotify();
|
|
49
|
+
call.success();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@PluginMethod
|
|
53
|
+
public void getSafeAreaInsets(PluginCall call) {
|
|
54
|
+
JSObject ret = new JSObject();
|
|
55
|
+
|
|
56
|
+
ret.put(SafeAreaPlugin.KEY_INSET, this.safeAreaInsets.toJSON());
|
|
57
|
+
|
|
58
|
+
call.success(ret);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected void getSafeArea(WindowInsets windowInsets) {
|
|
62
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
63
|
+
this.getSafeAreaR(windowInsets);
|
|
64
|
+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
65
|
+
this.getSafeAreaQ(windowInsets);
|
|
66
|
+
} else {
|
|
67
|
+
this.getSafeAreaLollipop(windowInsets);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Cutout
|
|
71
|
+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
|
|
72
|
+
this.getSafeAreaCutout(windowInsets);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
float density = this.getBridge().getActivity().getResources().getDisplayMetrics().density;
|
|
76
|
+
|
|
77
|
+
this.applySafeAreaInsets(
|
|
78
|
+
Math.round(this.safeAreaInsets.top() / density),
|
|
79
|
+
Math.round(this.safeAreaInsets.bottom() / density),
|
|
80
|
+
Math.round(this.safeAreaInsets.left() / density),
|
|
81
|
+
Math.round(this.safeAreaInsets.right() / density)
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// api level 30
|
|
86
|
+
// Get insets (Mandatory System Gestures: https://developer.android.com/reference/android/view/WindowInsets#getMandatorySystemGestureInsets())
|
|
87
|
+
@SuppressLint("NewApi")
|
|
88
|
+
protected void getSafeAreaR(WindowInsets windowInsets) {
|
|
89
|
+
Insets finalInsets = windowInsets.getInsets(WindowInsets.Type.mandatorySystemGestures());
|
|
90
|
+
|
|
91
|
+
this.applySafeAreaInsets(
|
|
92
|
+
finalInsets.top,
|
|
93
|
+
finalInsets.bottom,
|
|
94
|
+
finalInsets.left,
|
|
95
|
+
finalInsets.right
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// api level 29
|
|
100
|
+
@SuppressLint("NewApi")
|
|
101
|
+
protected void getSafeAreaQ(WindowInsets windowInsets) {
|
|
102
|
+
Insets finalInsets = windowInsets.getMandatorySystemGestureInsets();
|
|
103
|
+
|
|
104
|
+
this.applySafeAreaInsets(
|
|
105
|
+
finalInsets.top,
|
|
106
|
+
finalInsets.bottom,
|
|
107
|
+
finalInsets.left,
|
|
108
|
+
finalInsets.right
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// api level 21
|
|
113
|
+
protected void getSafeAreaLollipop(WindowInsets windowInsets) {
|
|
114
|
+
this.applySafeAreaInsets(
|
|
115
|
+
windowInsets.getSystemWindowInsetTop(),
|
|
116
|
+
windowInsets.getStableInsetBottom(),
|
|
117
|
+
windowInsets.getStableInsetLeft(),
|
|
118
|
+
windowInsets.getStableInsetRight()
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// cutout (api level >= 28)
|
|
123
|
+
@SuppressLint("NewApi")
|
|
124
|
+
protected void getSafeAreaCutout(WindowInsets windowInsets) {
|
|
125
|
+
DisplayCutout cutout = windowInsets.getDisplayCutout();
|
|
126
|
+
if (cutout != null) {
|
|
127
|
+
this.applySafeAreaInsets(
|
|
128
|
+
Math.max(this.safeAreaInsets.top(), cutout.getSafeInsetTop()),
|
|
129
|
+
Math.max(this.safeAreaInsets.bottom(), cutout.getSafeInsetBottom()),
|
|
130
|
+
Math.max(this.safeAreaInsets.left(), cutout.getSafeInsetLeft()),
|
|
131
|
+
Math.max(this.safeAreaInsets.right(), cutout.getSafeInsetRight())
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
protected void doNotify() {
|
|
137
|
+
JSObject ret = new JSObject();
|
|
138
|
+
|
|
139
|
+
ret.put(SafeAreaPlugin.KEY_INSET, this.safeAreaInsets.toJSON());
|
|
140
|
+
|
|
141
|
+
this.notifyListeners(SafeAreaPlugin.EVENT_ON_INSETS_CHANGED, ret);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private void applySafeAreaInsets(int top, int bottom, int left, int right) {
|
|
145
|
+
View decorView = this.getBridge().getActivity().getWindow().getDecorView();
|
|
146
|
+
int uiVisibility = decorView.getSystemUiVisibility();
|
|
147
|
+
|
|
148
|
+
if ((uiVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) {
|
|
149
|
+
this.safeAreaInsets.bottom(bottom);
|
|
150
|
+
} else {
|
|
151
|
+
this.safeAreaInsets.bottom(0);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.safeAreaInsets.top(top);
|
|
155
|
+
this.safeAreaInsets.right(left);
|
|
156
|
+
this.safeAreaInsets.left(right);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
package com.getcapacitor.community.plugins.safearea;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.util.AttributeSet;
|
|
5
|
-
import android.view.View;
|
|
6
|
-
import android.view.WindowInsets;
|
|
7
|
-
import java.util.function.Consumer;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* SafeArea View
|
|
11
|
-
* WindowInsets monitor
|
|
12
|
-
*/
|
|
13
|
-
public class SafeAreaView extends View {
|
|
14
|
-
private Consumer<WindowInsets> callbackInsets;
|
|
15
|
-
|
|
16
|
-
public SafeAreaView(Context context) {
|
|
17
|
-
super(context);
|
|
18
|
-
init(null, 0, null);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public SafeAreaView(Context context, Consumer<WindowInsets> onApplyInsets) {
|
|
22
|
-
super(context);
|
|
23
|
-
init(null, 0, onApplyInsets);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public SafeAreaView(Context context, AttributeSet attrs) {
|
|
27
|
-
super(context, attrs);
|
|
28
|
-
init(attrs, 0, null);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public SafeAreaView(Context context, AttributeSet attrs, int defStyle) {
|
|
32
|
-
super(context, attrs, defStyle);
|
|
33
|
-
init(attrs, defStyle, null);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private void init(AttributeSet attrs, int defStyle, Consumer<WindowInsets> onApplyInsets) {
|
|
37
|
-
if (onApplyInsets == null) {
|
|
38
|
-
this.callbackInsets = (WindowInsets wInsts) -> {};
|
|
39
|
-
} else {
|
|
40
|
-
this.callbackInsets = onApplyInsets;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@Override
|
|
45
|
-
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
|
|
46
|
-
this.callbackInsets.accept(insets);
|
|
47
|
-
return super.onApplyWindowInsets(insets);
|
|
48
|
-
}
|
|
1
|
+
package com.getcapacitor.community.plugins.safearea;
|
|
2
|
+
|
|
3
|
+
import android.content.Context;
|
|
4
|
+
import android.util.AttributeSet;
|
|
5
|
+
import android.view.View;
|
|
6
|
+
import android.view.WindowInsets;
|
|
7
|
+
import java.util.function.Consumer;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* SafeArea View
|
|
11
|
+
* WindowInsets monitor
|
|
12
|
+
*/
|
|
13
|
+
public class SafeAreaView extends View {
|
|
14
|
+
private Consumer<WindowInsets> callbackInsets;
|
|
15
|
+
|
|
16
|
+
public SafeAreaView(Context context) {
|
|
17
|
+
super(context);
|
|
18
|
+
init(null, 0, null);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public SafeAreaView(Context context, Consumer<WindowInsets> onApplyInsets) {
|
|
22
|
+
super(context);
|
|
23
|
+
init(null, 0, onApplyInsets);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public SafeAreaView(Context context, AttributeSet attrs) {
|
|
27
|
+
super(context, attrs);
|
|
28
|
+
init(attrs, 0, null);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public SafeAreaView(Context context, AttributeSet attrs, int defStyle) {
|
|
32
|
+
super(context, attrs, defStyle);
|
|
33
|
+
init(attrs, defStyle, null);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private void init(AttributeSet attrs, int defStyle, Consumer<WindowInsets> onApplyInsets) {
|
|
37
|
+
if (onApplyInsets == null) {
|
|
38
|
+
this.callbackInsets = (WindowInsets wInsts) -> {};
|
|
39
|
+
} else {
|
|
40
|
+
this.callbackInsets = onApplyInsets;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
|
|
46
|
+
this.callbackInsets.accept(insets);
|
|
47
|
+
return super.onApplyWindowInsets(insets);
|
|
48
|
+
}
|
|
49
49
|
}
|
package/dist/docs.json
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
"name": "addListener",
|
|
32
|
-
"signature": "(eventName: 'safeAreaPluginsInsetChange', listener: SafeAreaInsetsChangedCallback) => PluginListenerHandle",
|
|
32
|
+
"signature": "(eventName: 'safeAreaPluginsInsetChange', listener: SafeAreaInsetsChangedCallback) => Promise<PluginListenerHandle>",
|
|
33
33
|
"parameters": [
|
|
34
34
|
{
|
|
35
35
|
"name": "eventName",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"type": "SafeAreaInsetsChangedCallback"
|
|
43
43
|
}
|
|
44
44
|
],
|
|
45
|
-
"returns": "PluginListenerHandle",
|
|
45
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
46
46
|
"tags": [],
|
|
47
47
|
"docs": "",
|
|
48
48
|
"complexTypes": [
|
|
49
49
|
"PluginListenerHandle",
|
|
50
50
|
"SafeAreaInsetsChangedCallback"
|
|
51
51
|
],
|
|
52
|
-
"slug": "addlistenersafeareapluginsinsetchange"
|
|
52
|
+
"slug": "addlistenersafeareapluginsinsetchange-"
|
|
53
53
|
}
|
|
54
54
|
],
|
|
55
55
|
"properties": []
|
package/dist/esm/controller.js
CHANGED
|
@@ -14,7 +14,7 @@ export class SafeAreaController {
|
|
|
14
14
|
async load() {
|
|
15
15
|
var _a;
|
|
16
16
|
await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove());
|
|
17
|
-
this.callback = this.safeAreaPlugin.addListener("safeAreaPluginsInsetChange", (result) => {
|
|
17
|
+
this.callback = await this.safeAreaPlugin.addListener("safeAreaPluginsInsetChange", (result) => {
|
|
18
18
|
this.updateInsets(result.insets);
|
|
19
19
|
this.injectCSSVariables();
|
|
20
20
|
this.notifyListeners();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../src/controller.ts"],"names":[],"mappings":"AAAA,OAAO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ED,KAAK,CAAC,OAAO;QACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;QAE7D,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,MAAM;;QACJ,MAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,EAAE,CAAC;IAC1B,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEO,YAAY,CAAC,MAAsB;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAAA,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { PluginListenerHandle } from '@capacitor/core';
|
|
|
2
2
|
export interface SafeAreaPlugin {
|
|
3
3
|
refresh(): Promise<void>;
|
|
4
4
|
getSafeAreaInsets(): Promise<SafeAreaInsetsResult>;
|
|
5
|
-
addListener(eventName: 'safeAreaPluginsInsetChange', listener: SafeAreaInsetsChangedCallback): PluginListenerHandle
|
|
5
|
+
addListener(eventName: 'safeAreaPluginsInsetChange', listener: SafeAreaInsetsChangedCallback): Promise<PluginListenerHandle>;
|
|
6
6
|
}
|
|
7
7
|
export interface SafeAreaInsets {
|
|
8
8
|
top: number;
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -19,7 +19,7 @@ class SafeAreaController {
|
|
|
19
19
|
async load() {
|
|
20
20
|
var _a;
|
|
21
21
|
await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove());
|
|
22
|
-
this.callback = this.safeAreaPlugin.addListener("safeAreaPluginsInsetChange", (result) => {
|
|
22
|
+
this.callback = await this.safeAreaPlugin.addListener("safeAreaPluginsInsetChange", (result) => {
|
|
23
23
|
this.updateInsets(result.insets);
|
|
24
24
|
this.injectCSSVariables();
|
|
25
25
|
this.notifyListeners();
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/controller.js","esm/definitions.js","esm/web.js","esm/index.js"],"sourcesContent":["import { Capacitor } from '@capacitor/core';\nexport class SafeAreaController {\n constructor(safeAreaPlugin) {\n this.safeAreaPlugin = safeAreaPlugin;\n this.insets = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n this.callback = undefined;\n this.listeners = [];\n }\n async load() {\n var _a;\n await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove());\n this.callback = this.safeAreaPlugin.addListener(\"safeAreaPluginsInsetChange\", (result) => {\n this.updateInsets(result.insets);\n this.injectCSSVariables();\n this.notifyListeners();\n });\n await this.refresh();\n }\n addListener(listener) {\n this.listeners.push(listener);\n }\n removeListener(listener) {\n const index = this.listeners.indexOf(listener);\n if (index >= 0)\n delete this.listeners[index];\n }\n removeAllListeners() {\n this.listeners.length = 0;\n }\n injectCSSVariables() {\n for (const inset in this.insets) {\n switch (Capacitor.getPlatform()) {\n case \"android\":\n case \"ios\":\n {\n document.documentElement.style.setProperty(`--${Capacitor.getPlatform()}-safe-area-inset-${inset}`, `${this.insets[inset]}px`);\n document.documentElement.style.setProperty(`--safe-area-inset-${inset}`, `var(--${Capacitor.getPlatform()}-safe-area-inset-${inset}, env(safe-area-inset-${inset}))`);\n }\n break;\n default:\n {\n document.documentElement.style.setProperty(`--safe-area-inset-${inset}`, \"0px\");\n }\n break;\n }\n }\n }\n async refresh() {\n const result = await this.safeAreaPlugin.getSafeAreaInsets();\n this.updateInsets(result.insets);\n this.injectCSSVariables();\n this.notifyListeners();\n }\n getInsets() {\n return this.insets;\n }\n unload() {\n var _a;\n (_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove();\n }\n notifyListeners() {\n this.listeners.forEach((listener) => listener({ insets: this.insets }));\n }\n updateInsets(insets) {\n this.insets = insets;\n }\n}\n;\n//# sourceMappingURL=controller.js.map",";\nexport const SafeAreaInsetsChangeEventName = \"safeAreaPluginsInsetChange\";\n//# sourceMappingURL=definitions.js.map","import { WebPlugin } from '@capacitor/core';\nimport { SafeAreaInsetsChangeEventName } from './definitions';\nexport class SafeAreaWeb extends WebPlugin {\n /**\n * Call this whenever you want the EventOnInsetsChanged to be fired manually.\n */\n async refresh() {\n const dummy = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n this.notifyListeners(SafeAreaInsetsChangeEventName, {\n insets: dummy\n });\n }\n /**\n * Gets the current SafeAreaInsets.\n */\n getSafeAreaInsets() {\n const dummy = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0,\n };\n return new Promise((resolve) => {\n resolve({ insets: dummy });\n });\n }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nimport { SafeAreaController } from './controller';\nconst SafeArea = registerPlugin('SafeArea', {\n web: () => import('./web').then(m => new m.SafeAreaWeb()),\n});\nexport * from './definitions';\nexport * from './web';\nconst controller = new SafeAreaController(SafeArea);\nexport { controller as SafeAreaController };\n//# sourceMappingURL=index.js.map"],"names":["Capacitor","WebPlugin","registerPlugin"],"mappings":";;;;;;AACO,MAAM,kBAAkB,CAAC;AAChC,IAAI,WAAW,CAAC,cAAc,EAAE;AAChC,QAAQ,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;AAC7C,QAAQ,IAAI,CAAC,MAAM,GAAG;AACtB,YAAY,GAAG,EAAE,CAAC;AAClB,YAAY,MAAM,EAAE,CAAC;AACrB,YAAY,KAAK,EAAE,CAAC;AACpB,YAAY,IAAI,EAAE,CAAC;AACnB,SAAS,CAAC;AACV,QAAQ,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;AAClC,QAAQ,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;AAC5B,KAAK;AACL,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,IAAI,EAAE,CAAC;AACf,QAAQ,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;AACtF,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,4BAA4B,EAAE,CAAC,MAAM,KAAK;
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/controller.js","esm/definitions.js","esm/web.js","esm/index.js"],"sourcesContent":["import { Capacitor } from '@capacitor/core';\nexport class SafeAreaController {\n constructor(safeAreaPlugin) {\n this.safeAreaPlugin = safeAreaPlugin;\n this.insets = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n this.callback = undefined;\n this.listeners = [];\n }\n async load() {\n var _a;\n await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove());\n this.callback = await this.safeAreaPlugin.addListener(\"safeAreaPluginsInsetChange\", (result) => {\n this.updateInsets(result.insets);\n this.injectCSSVariables();\n this.notifyListeners();\n });\n await this.refresh();\n }\n addListener(listener) {\n this.listeners.push(listener);\n }\n removeListener(listener) {\n const index = this.listeners.indexOf(listener);\n if (index >= 0)\n delete this.listeners[index];\n }\n removeAllListeners() {\n this.listeners.length = 0;\n }\n injectCSSVariables() {\n for (const inset in this.insets) {\n switch (Capacitor.getPlatform()) {\n case \"android\":\n case \"ios\":\n {\n document.documentElement.style.setProperty(`--${Capacitor.getPlatform()}-safe-area-inset-${inset}`, `${this.insets[inset]}px`);\n document.documentElement.style.setProperty(`--safe-area-inset-${inset}`, `var(--${Capacitor.getPlatform()}-safe-area-inset-${inset}, env(safe-area-inset-${inset}))`);\n }\n break;\n default:\n {\n document.documentElement.style.setProperty(`--safe-area-inset-${inset}`, \"0px\");\n }\n break;\n }\n }\n }\n async refresh() {\n const result = await this.safeAreaPlugin.getSafeAreaInsets();\n this.updateInsets(result.insets);\n this.injectCSSVariables();\n this.notifyListeners();\n }\n getInsets() {\n return this.insets;\n }\n unload() {\n var _a;\n (_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove();\n }\n notifyListeners() {\n this.listeners.forEach((listener) => listener({ insets: this.insets }));\n }\n updateInsets(insets) {\n this.insets = insets;\n }\n}\n;\n//# sourceMappingURL=controller.js.map",";\nexport const SafeAreaInsetsChangeEventName = \"safeAreaPluginsInsetChange\";\n//# sourceMappingURL=definitions.js.map","import { WebPlugin } from '@capacitor/core';\nimport { SafeAreaInsetsChangeEventName } from './definitions';\nexport class SafeAreaWeb extends WebPlugin {\n /**\n * Call this whenever you want the EventOnInsetsChanged to be fired manually.\n */\n async refresh() {\n const dummy = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n this.notifyListeners(SafeAreaInsetsChangeEventName, {\n insets: dummy\n });\n }\n /**\n * Gets the current SafeAreaInsets.\n */\n getSafeAreaInsets() {\n const dummy = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0,\n };\n return new Promise((resolve) => {\n resolve({ insets: dummy });\n });\n }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nimport { SafeAreaController } from './controller';\nconst SafeArea = registerPlugin('SafeArea', {\n web: () => import('./web').then(m => new m.SafeAreaWeb()),\n});\nexport * from './definitions';\nexport * from './web';\nconst controller = new SafeAreaController(SafeArea);\nexport { controller as SafeAreaController };\n//# sourceMappingURL=index.js.map"],"names":["Capacitor","WebPlugin","registerPlugin"],"mappings":";;;;;;AACO,MAAM,kBAAkB,CAAC;AAChC,IAAI,WAAW,CAAC,cAAc,EAAE;AAChC,QAAQ,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;AAC7C,QAAQ,IAAI,CAAC,MAAM,GAAG;AACtB,YAAY,GAAG,EAA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;AACxC,YAAY,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AACvC,SAAS,CAAC,CAAC;AACX,KAAK;AACL;;;;;;;AC7BA,MAAM,QAAQ,GAAGC,mBAAc,CAAC,UAAU,EAAE;AAC5C,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;AAC7D,CAAC,CAAC,CAAC;AAGE,MAAC,UAAU,GAAG,IAAI,kBAAkB,CAAC,QAAQ;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -16,7 +16,7 @@ var capacitorSafeArea = (function (exports, core) {
|
|
|
16
16
|
async load() {
|
|
17
17
|
var _a;
|
|
18
18
|
await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove());
|
|
19
|
-
this.callback = this.safeAreaPlugin.addListener("safeAreaPluginsInsetChange", (result) => {
|
|
19
|
+
this.callback = await this.safeAreaPlugin.addListener("safeAreaPluginsInsetChange", (result) => {
|
|
20
20
|
this.updateInsets(result.insets);
|
|
21
21
|
this.injectCSSVariables();
|
|
22
22
|
this.notifyListeners();
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/controller.js","esm/definitions.js","esm/web.js","esm/index.js"],"sourcesContent":["import { Capacitor } from '@capacitor/core';\nexport class SafeAreaController {\n constructor(safeAreaPlugin) {\n this.safeAreaPlugin = safeAreaPlugin;\n this.insets = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n this.callback = undefined;\n this.listeners = [];\n }\n async load() {\n var _a;\n await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove());\n this.callback = this.safeAreaPlugin.addListener(\"safeAreaPluginsInsetChange\", (result) => {\n this.updateInsets(result.insets);\n this.injectCSSVariables();\n this.notifyListeners();\n });\n await this.refresh();\n }\n addListener(listener) {\n this.listeners.push(listener);\n }\n removeListener(listener) {\n const index = this.listeners.indexOf(listener);\n if (index >= 0)\n delete this.listeners[index];\n }\n removeAllListeners() {\n this.listeners.length = 0;\n }\n injectCSSVariables() {\n for (const inset in this.insets) {\n switch (Capacitor.getPlatform()) {\n case \"android\":\n case \"ios\":\n {\n document.documentElement.style.setProperty(`--${Capacitor.getPlatform()}-safe-area-inset-${inset}`, `${this.insets[inset]}px`);\n document.documentElement.style.setProperty(`--safe-area-inset-${inset}`, `var(--${Capacitor.getPlatform()}-safe-area-inset-${inset}, env(safe-area-inset-${inset}))`);\n }\n break;\n default:\n {\n document.documentElement.style.setProperty(`--safe-area-inset-${inset}`, \"0px\");\n }\n break;\n }\n }\n }\n async refresh() {\n const result = await this.safeAreaPlugin.getSafeAreaInsets();\n this.updateInsets(result.insets);\n this.injectCSSVariables();\n this.notifyListeners();\n }\n getInsets() {\n return this.insets;\n }\n unload() {\n var _a;\n (_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove();\n }\n notifyListeners() {\n this.listeners.forEach((listener) => listener({ insets: this.insets }));\n }\n updateInsets(insets) {\n this.insets = insets;\n }\n}\n;\n//# sourceMappingURL=controller.js.map",";\nexport const SafeAreaInsetsChangeEventName = \"safeAreaPluginsInsetChange\";\n//# sourceMappingURL=definitions.js.map","import { WebPlugin } from '@capacitor/core';\nimport { SafeAreaInsetsChangeEventName } from './definitions';\nexport class SafeAreaWeb extends WebPlugin {\n /**\n * Call this whenever you want the EventOnInsetsChanged to be fired manually.\n */\n async refresh() {\n const dummy = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n this.notifyListeners(SafeAreaInsetsChangeEventName, {\n insets: dummy\n });\n }\n /**\n * Gets the current SafeAreaInsets.\n */\n getSafeAreaInsets() {\n const dummy = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0,\n };\n return new Promise((resolve) => {\n resolve({ insets: dummy });\n });\n }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nimport { SafeAreaController } from './controller';\nconst SafeArea = registerPlugin('SafeArea', {\n web: () => import('./web').then(m => new m.SafeAreaWeb()),\n});\nexport * from './definitions';\nexport * from './web';\nconst controller = new SafeAreaController(SafeArea);\nexport { controller as SafeAreaController };\n//# sourceMappingURL=index.js.map"],"names":["Capacitor","WebPlugin","registerPlugin"],"mappings":";;;IACO,MAAM,kBAAkB,CAAC;IAChC,IAAI,WAAW,CAAC,cAAc,EAAE;IAChC,QAAQ,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IAC7C,QAAQ,IAAI,CAAC,MAAM,GAAG;IACtB,YAAY,GAAG,EAAE,CAAC;IAClB,YAAY,MAAM,EAAE,CAAC;IACrB,YAAY,KAAK,EAAE,CAAC;IACpB,YAAY,IAAI,EAAE,CAAC;IACnB,SAAS,CAAC;IACV,QAAQ,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAClC,QAAQ,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IAC5B,KAAK;IACL,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,IAAI,EAAE,CAAC;IACf,QAAQ,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;IACtF,QAAQ,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,4BAA4B,EAAE,CAAC,MAAM,KAAK;
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/controller.js","esm/definitions.js","esm/web.js","esm/index.js"],"sourcesContent":["import { Capacitor } from '@capacitor/core';\nexport class SafeAreaController {\n constructor(safeAreaPlugin) {\n this.safeAreaPlugin = safeAreaPlugin;\n this.insets = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n this.callback = undefined;\n this.listeners = [];\n }\n async load() {\n var _a;\n await ((_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove());\n this.callback = await this.safeAreaPlugin.addListener(\"safeAreaPluginsInsetChange\", (result) => {\n this.updateInsets(result.insets);\n this.injectCSSVariables();\n this.notifyListeners();\n });\n await this.refresh();\n }\n addListener(listener) {\n this.listeners.push(listener);\n }\n removeListener(listener) {\n const index = this.listeners.indexOf(listener);\n if (index >= 0)\n delete this.listeners[index];\n }\n removeAllListeners() {\n this.listeners.length = 0;\n }\n injectCSSVariables() {\n for (const inset in this.insets) {\n switch (Capacitor.getPlatform()) {\n case \"android\":\n case \"ios\":\n {\n document.documentElement.style.setProperty(`--${Capacitor.getPlatform()}-safe-area-inset-${inset}`, `${this.insets[inset]}px`);\n document.documentElement.style.setProperty(`--safe-area-inset-${inset}`, `var(--${Capacitor.getPlatform()}-safe-area-inset-${inset}, env(safe-area-inset-${inset}))`);\n }\n break;\n default:\n {\n document.documentElement.style.setProperty(`--safe-area-inset-${inset}`, \"0px\");\n }\n break;\n }\n }\n }\n async refresh() {\n const result = await this.safeAreaPlugin.getSafeAreaInsets();\n this.updateInsets(result.insets);\n this.injectCSSVariables();\n this.notifyListeners();\n }\n getInsets() {\n return this.insets;\n }\n unload() {\n var _a;\n (_a = this.callback) === null || _a === void 0 ? void 0 : _a.remove();\n }\n notifyListeners() {\n this.listeners.forEach((listener) => listener({ insets: this.insets }));\n }\n updateInsets(insets) {\n this.insets = insets;\n }\n}\n;\n//# sourceMappingURL=controller.js.map",";\nexport const SafeAreaInsetsChangeEventName = \"safeAreaPluginsInsetChange\";\n//# sourceMappingURL=definitions.js.map","import { WebPlugin } from '@capacitor/core';\nimport { SafeAreaInsetsChangeEventName } from './definitions';\nexport class SafeAreaWeb extends WebPlugin {\n /**\n * Call this whenever you want the EventOnInsetsChanged to be fired manually.\n */\n async refresh() {\n const dummy = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0\n };\n this.notifyListeners(SafeAreaInsetsChangeEventName, {\n insets: dummy\n });\n }\n /**\n * Gets the current SafeAreaInsets.\n */\n getSafeAreaInsets() {\n const dummy = {\n top: 0,\n bottom: 0,\n right: 0,\n left: 0,\n };\n return new Promise((resolve) => {\n resolve({ insets: dummy });\n });\n }\n}\n//# sourceMappingURL=web.js.map","import { registerPlugin } from '@capacitor/core';\nimport { SafeAreaController } from './controller';\nconst SafeArea = registerPlugin('SafeArea', {\n web: () => import('./web').then(m => new m.SafeAreaWeb()),\n});\nexport * from './definitions';\nexport * from './web';\nconst controller = new SafeAreaController(SafeArea);\nexport { controller as SafeAreaController };\n//# sourceMappingURL=index.js.map"],"names":["Capacitor","WebPlugin","registerPlugin"],"mappings":";;;IACO,MAAM,kBAAkB,CAAC;IAChC,IAAI,WAAW,CAAC,cAAc,EAAE;IAChC,QAAQ,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IAC7C,QAAQ,IAAI,CAAC,MAAM,GAAG;IACtB,YAAY,GAAG,EAAE,CAAC;IAClB,YAAY,MAAM,EAAE,CAAC;IACrB,YAAY,KAAK,EAAE,CAAC;IACpB,YAAY,IAAI,EAAE,CAAC;IACnB,SAAS,CAAC;IACV,QAAQ,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAClC,QAAQ,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IAC5B,KAAK;IACL,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,IAAI,EAAE,CAAC;IACf,QAAQ,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,QAAQ,MAAM,IAAI,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;IACtF,QAAQ,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,4BAA4B,EAAE,CAAC,MAAM,KAAK;IACxG,YAAY,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7C,YAAY,IAAI,CAAC,kBAAkB,EAAE,CAAC;IACtC,YAAY,IAAI,CAAC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