@apps-in-toss/web-bridge 1.0.3 → 1.1.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/built/bridge.d.ts +4 -1
- package/built/bridge.js +1 -1
- package/built/fetchAlbumPhotos.d.ts +55 -14
- package/built/fetchContacts.d.ts +46 -10
- package/built/getClipboardText.d.ts +54 -10
- package/built/getCurrentLocation.d.ts +47 -11
- package/built/getPermission.d.ts +58 -0
- package/built/index.cjs +153 -1
- package/built/index.d.cts +22 -1
- package/built/index.d.ts +22 -1
- package/built/index.js +148 -0
- package/built/openCamera.d.ts +47 -10
- package/built/openPermissionDialog.d.ts +55 -0
- package/built/requestPermission.d.ts +55 -0
- package/built/setClipboardText.d.ts +44 -4
- package/built/startUpdateLocation.d.ts +72 -29
- package/built/types.d.ts +0 -107
- package/package.json +7 -4
package/built/index.cjs
CHANGED
|
@@ -27,11 +27,18 @@ __export(index_exports, {
|
|
|
27
27
|
Storage: () => Storage,
|
|
28
28
|
appsInTossEvent: () => appsInTossEvent,
|
|
29
29
|
env: () => env,
|
|
30
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
31
|
+
fetchContacts: () => fetchContacts,
|
|
30
32
|
getAppsInTossGlobals: () => getAppsInTossGlobals,
|
|
33
|
+
getClipboardText: () => getClipboardText,
|
|
34
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
31
35
|
getSafeAreaInsets: () => getSafeAreaInsets,
|
|
32
36
|
graniteEvent: () => graniteEvent,
|
|
33
37
|
isMinVersionSupported: () => isMinVersionSupported,
|
|
38
|
+
openCamera: () => openCamera,
|
|
34
39
|
partner: () => partner,
|
|
40
|
+
setClipboardText: () => setClipboardText,
|
|
41
|
+
startUpdateLocation: () => startUpdateLocation,
|
|
35
42
|
tdsEvent: () => tdsEvent
|
|
36
43
|
});
|
|
37
44
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -774,6 +781,143 @@ var partner = {
|
|
|
774
781
|
*/
|
|
775
782
|
removeAccessoryButton: (0, import_bridge_core11.createAsyncBridge)("removeAccessoryButton")
|
|
776
783
|
};
|
|
784
|
+
|
|
785
|
+
// src/permissions/fetchAlbumPhotos.ts
|
|
786
|
+
var import_bridge_core13 = require("@apps-in-toss/bridge-core");
|
|
787
|
+
var import_types = require("@apps-in-toss/types");
|
|
788
|
+
|
|
789
|
+
// src/permissions/createPermissionFunction.ts
|
|
790
|
+
var import_bridge_core12 = require("@apps-in-toss/bridge-core");
|
|
791
|
+
var requestPermission = (0, import_bridge_core12.createAsyncBridge)("requestPermission");
|
|
792
|
+
var getPermission = (0, import_bridge_core12.createAsyncBridge)("getPermission");
|
|
793
|
+
var openPermissionDialog = (0, import_bridge_core12.createAsyncBridge)("openPermissionDialog");
|
|
794
|
+
function createPermissionFunction({
|
|
795
|
+
permission,
|
|
796
|
+
handler,
|
|
797
|
+
error
|
|
798
|
+
}) {
|
|
799
|
+
const permissionFunction = async (...args) => {
|
|
800
|
+
const permissionStatus = await requestPermission(permission);
|
|
801
|
+
if (permissionStatus === "denied") {
|
|
802
|
+
throw new error();
|
|
803
|
+
}
|
|
804
|
+
return handler(...args);
|
|
805
|
+
};
|
|
806
|
+
permissionFunction.getPermission = () => getPermission(permission);
|
|
807
|
+
permissionFunction.openPermissionDialog = () => openPermissionDialog(permission);
|
|
808
|
+
return permissionFunction;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// src/permissions/fetchAlbumPhotos.ts
|
|
812
|
+
var fetchAlbumPhotos = createPermissionFunction({
|
|
813
|
+
handler: (options) => {
|
|
814
|
+
return (0, import_bridge_core13.createAsyncBridge)("fetchAlbumPhotos")(
|
|
815
|
+
options
|
|
816
|
+
);
|
|
817
|
+
},
|
|
818
|
+
permission: {
|
|
819
|
+
name: "photos",
|
|
820
|
+
access: "read"
|
|
821
|
+
},
|
|
822
|
+
error: import_types.FetchAlbumPhotosPermissionError
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
// src/permissions/fetchContacts.ts
|
|
826
|
+
var import_bridge_core14 = require("@apps-in-toss/bridge-core");
|
|
827
|
+
var import_types2 = require("@apps-in-toss/types");
|
|
828
|
+
var fetchContacts = createPermissionFunction({
|
|
829
|
+
handler: (options) => {
|
|
830
|
+
return (0, import_bridge_core14.createAsyncBridge)("fetchContacts")(options);
|
|
831
|
+
},
|
|
832
|
+
permission: {
|
|
833
|
+
name: "contacts",
|
|
834
|
+
access: "read"
|
|
835
|
+
},
|
|
836
|
+
error: import_types2.FetchContactsPermissionError
|
|
837
|
+
});
|
|
838
|
+
|
|
839
|
+
// src/permissions/getCurrentLocation.ts
|
|
840
|
+
var import_bridge_core15 = require("@apps-in-toss/bridge-core");
|
|
841
|
+
var import_types3 = require("@apps-in-toss/types");
|
|
842
|
+
var getCurrentLocation = createPermissionFunction({
|
|
843
|
+
handler: (options) => {
|
|
844
|
+
return (0, import_bridge_core15.createAsyncBridge)(
|
|
845
|
+
"getCurrentLocation"
|
|
846
|
+
)(options);
|
|
847
|
+
},
|
|
848
|
+
permission: {
|
|
849
|
+
name: "geolocation",
|
|
850
|
+
access: "access"
|
|
851
|
+
},
|
|
852
|
+
error: import_types3.GetCurrentLocationPermissionError
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
// src/permissions/openCamera.ts
|
|
856
|
+
var import_bridge_core16 = require("@apps-in-toss/bridge-core");
|
|
857
|
+
var import_types4 = require("@apps-in-toss/types");
|
|
858
|
+
var openCamera = createPermissionFunction({
|
|
859
|
+
handler: (options) => {
|
|
860
|
+
return (0, import_bridge_core16.createAsyncBridge)("openCamera")(options);
|
|
861
|
+
},
|
|
862
|
+
permission: {
|
|
863
|
+
name: "camera",
|
|
864
|
+
access: "access"
|
|
865
|
+
},
|
|
866
|
+
error: import_types4.OpenCameraPermissionError
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
// src/permissions/setClipboardText.ts
|
|
870
|
+
var import_bridge_core17 = require("@apps-in-toss/bridge-core");
|
|
871
|
+
var import_types5 = require("@apps-in-toss/types");
|
|
872
|
+
var setClipboardText = createPermissionFunction({
|
|
873
|
+
handler: (options) => {
|
|
874
|
+
return (0, import_bridge_core17.createAsyncBridge)("setClipboardText")(
|
|
875
|
+
options
|
|
876
|
+
);
|
|
877
|
+
},
|
|
878
|
+
permission: {
|
|
879
|
+
name: "clipboard",
|
|
880
|
+
access: "write"
|
|
881
|
+
},
|
|
882
|
+
error: import_types5.SetClipboardTextPermissionError
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
// src/permissions/getClipboardText.ts
|
|
886
|
+
var import_bridge_core18 = require("@apps-in-toss/bridge-core");
|
|
887
|
+
var import_types6 = require("@apps-in-toss/types");
|
|
888
|
+
var getClipboardText = createPermissionFunction({
|
|
889
|
+
handler: () => {
|
|
890
|
+
return (0, import_bridge_core18.createAsyncBridge)("getClipboardText")();
|
|
891
|
+
},
|
|
892
|
+
permission: {
|
|
893
|
+
name: "clipboard",
|
|
894
|
+
access: "read"
|
|
895
|
+
},
|
|
896
|
+
error: import_types6.GetClipboardTextPermissionError
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
// src/permissions/startUpdateLocation.ts
|
|
900
|
+
var import_bridge_core19 = require("@apps-in-toss/bridge-core");
|
|
901
|
+
var import_types7 = require("@apps-in-toss/types");
|
|
902
|
+
var getPermission2 = (0, import_bridge_core19.createAsyncBridge)("getPermission");
|
|
903
|
+
var openPermissionDialog2 = (0, import_bridge_core19.createAsyncBridge)("openPermissionDialog");
|
|
904
|
+
var startUpdateLocation = (params) => {
|
|
905
|
+
return (0, import_bridge_core19.createEventBridge)("updateLocationEvent")({
|
|
906
|
+
...params,
|
|
907
|
+
onError: (error) => {
|
|
908
|
+
const locationError = new import_types7.StartUpdateLocationPermissionError();
|
|
909
|
+
if (error instanceof Error && error.name === locationError.name) {
|
|
910
|
+
return params.onError(locationError);
|
|
911
|
+
}
|
|
912
|
+
return params.onError(error);
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
};
|
|
916
|
+
startUpdateLocation.getPermission = () => getPermission2({ name: "geolocation", access: "access" });
|
|
917
|
+
startUpdateLocation.openPermissionDialog = () => openPermissionDialog2({ name: "geolocation", access: "access" });
|
|
918
|
+
|
|
919
|
+
// src/index.ts
|
|
920
|
+
__reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
777
921
|
// Annotate the CommonJS export names for ESM import in node:
|
|
778
922
|
0 && (module.exports = {
|
|
779
923
|
GoogleAdMob,
|
|
@@ -781,11 +925,19 @@ var partner = {
|
|
|
781
925
|
Storage,
|
|
782
926
|
appsInTossEvent,
|
|
783
927
|
env,
|
|
928
|
+
fetchAlbumPhotos,
|
|
929
|
+
fetchContacts,
|
|
784
930
|
getAppsInTossGlobals,
|
|
931
|
+
getClipboardText,
|
|
932
|
+
getCurrentLocation,
|
|
785
933
|
getSafeAreaInsets,
|
|
786
934
|
graniteEvent,
|
|
787
935
|
isMinVersionSupported,
|
|
936
|
+
openCamera,
|
|
788
937
|
partner,
|
|
938
|
+
setClipboardText,
|
|
939
|
+
startUpdateLocation,
|
|
789
940
|
tdsEvent,
|
|
790
|
-
...require("@apps-in-toss/bridge-core")
|
|
941
|
+
...require("@apps-in-toss/bridge-core"),
|
|
942
|
+
...require("@apps-in-toss/types")
|
|
791
943
|
});
|
package/built/index.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from './bridge';
|
|
2
2
|
export * from '@apps-in-toss/bridge-core';
|
|
3
3
|
import { LoadAdMobInterstitialAdEvent, LoadAdMobInterstitialAdOptions, ShowAdMobInterstitialAdEvent, ShowAdMobInterstitialAdOptions, LoadAdMobRewardedAdEvent, LoadAdMobRewardedAdOptions, ShowAdMobRewardedAdEvent, ShowAdMobRewardedAdOptions, LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions } from '@apps-in-toss/framework';
|
|
4
|
+
import * as _apps_in_toss_types from '@apps-in-toss/types';
|
|
5
|
+
import { FetchAlbumPhotos, FetchContacts, GetCurrentLocation, OpenCamera, SetClipboardText, GetClipboardText, StartUpdateLocationEventParams } from '@apps-in-toss/types';
|
|
6
|
+
export * from '@apps-in-toss/types';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* @public
|
|
@@ -766,4 +769,22 @@ declare const partner: {
|
|
|
766
769
|
removeAccessoryButton: () => Promise<void>;
|
|
767
770
|
};
|
|
768
771
|
|
|
769
|
-
|
|
772
|
+
declare const fetchAlbumPhotos: _apps_in_toss_types.PermissionFunctionWithDialog<FetchAlbumPhotos>;
|
|
773
|
+
|
|
774
|
+
declare const fetchContacts: _apps_in_toss_types.PermissionFunctionWithDialog<FetchContacts>;
|
|
775
|
+
|
|
776
|
+
declare const getCurrentLocation: _apps_in_toss_types.PermissionFunctionWithDialog<GetCurrentLocation>;
|
|
777
|
+
|
|
778
|
+
declare const openCamera: _apps_in_toss_types.PermissionFunctionWithDialog<OpenCamera>;
|
|
779
|
+
|
|
780
|
+
declare const setClipboardText: _apps_in_toss_types.PermissionFunctionWithDialog<SetClipboardText>;
|
|
781
|
+
|
|
782
|
+
declare const getClipboardText: _apps_in_toss_types.PermissionFunctionWithDialog<GetClipboardText>;
|
|
783
|
+
|
|
784
|
+
declare const startUpdateLocation: {
|
|
785
|
+
(params: StartUpdateLocationEventParams): () => void;
|
|
786
|
+
getPermission(): Promise<_apps_in_toss_types.PermissionStatus>;
|
|
787
|
+
openPermissionDialog(): Promise<"denied" | "allowed">;
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
export { type AddAccessoryButtonOptions, type AppsInTossEvent, type AppsInTossGlobals, GoogleAdMob, type GraniteEvent, IAP, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, Storage, type TdsEvent, appsInTossEvent, env, fetchAlbumPhotos, fetchContacts, getAppsInTossGlobals, getClipboardText, getCurrentLocation, getSafeAreaInsets, graniteEvent, isMinVersionSupported, openCamera, partner, setClipboardText, startUpdateLocation, tdsEvent };
|
package/built/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from './bridge';
|
|
2
2
|
export * from '@apps-in-toss/bridge-core';
|
|
3
3
|
import { LoadAdMobInterstitialAdEvent, LoadAdMobInterstitialAdOptions, ShowAdMobInterstitialAdEvent, ShowAdMobInterstitialAdOptions, LoadAdMobRewardedAdEvent, LoadAdMobRewardedAdOptions, ShowAdMobRewardedAdEvent, ShowAdMobRewardedAdOptions, LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions } from '@apps-in-toss/framework';
|
|
4
|
+
import * as _apps_in_toss_types from '@apps-in-toss/types';
|
|
5
|
+
import { FetchAlbumPhotos, FetchContacts, GetCurrentLocation, OpenCamera, SetClipboardText, GetClipboardText, StartUpdateLocationEventParams } from '@apps-in-toss/types';
|
|
6
|
+
export * from '@apps-in-toss/types';
|
|
4
7
|
|
|
5
8
|
/**
|
|
6
9
|
* @public
|
|
@@ -766,4 +769,22 @@ declare const partner: {
|
|
|
766
769
|
removeAccessoryButton: () => Promise<void>;
|
|
767
770
|
};
|
|
768
771
|
|
|
769
|
-
|
|
772
|
+
declare const fetchAlbumPhotos: _apps_in_toss_types.PermissionFunctionWithDialog<FetchAlbumPhotos>;
|
|
773
|
+
|
|
774
|
+
declare const fetchContacts: _apps_in_toss_types.PermissionFunctionWithDialog<FetchContacts>;
|
|
775
|
+
|
|
776
|
+
declare const getCurrentLocation: _apps_in_toss_types.PermissionFunctionWithDialog<GetCurrentLocation>;
|
|
777
|
+
|
|
778
|
+
declare const openCamera: _apps_in_toss_types.PermissionFunctionWithDialog<OpenCamera>;
|
|
779
|
+
|
|
780
|
+
declare const setClipboardText: _apps_in_toss_types.PermissionFunctionWithDialog<SetClipboardText>;
|
|
781
|
+
|
|
782
|
+
declare const getClipboardText: _apps_in_toss_types.PermissionFunctionWithDialog<GetClipboardText>;
|
|
783
|
+
|
|
784
|
+
declare const startUpdateLocation: {
|
|
785
|
+
(params: StartUpdateLocationEventParams): () => void;
|
|
786
|
+
getPermission(): Promise<_apps_in_toss_types.PermissionStatus>;
|
|
787
|
+
openPermissionDialog(): Promise<"denied" | "allowed">;
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
export { type AddAccessoryButtonOptions, type AppsInTossEvent, type AppsInTossGlobals, GoogleAdMob, type GraniteEvent, IAP, type IapCreateOneTimePurchaseOrderResult, type IapProductListItem, Storage, type TdsEvent, appsInTossEvent, env, fetchAlbumPhotos, fetchContacts, getAppsInTossGlobals, getClipboardText, getCurrentLocation, getSafeAreaInsets, graniteEvent, isMinVersionSupported, openCamera, partner, setClipboardText, startUpdateLocation, tdsEvent };
|
package/built/index.js
CHANGED
|
@@ -740,16 +740,164 @@ var partner = {
|
|
|
740
740
|
*/
|
|
741
741
|
removeAccessoryButton: createAsyncBridge3("removeAccessoryButton")
|
|
742
742
|
};
|
|
743
|
+
|
|
744
|
+
// src/permissions/fetchAlbumPhotos.ts
|
|
745
|
+
import { createAsyncBridge as createAsyncBridge5 } from "@apps-in-toss/bridge-core";
|
|
746
|
+
import { FetchAlbumPhotosPermissionError } from "@apps-in-toss/types";
|
|
747
|
+
|
|
748
|
+
// src/permissions/createPermissionFunction.ts
|
|
749
|
+
import { createAsyncBridge as createAsyncBridge4 } from "@apps-in-toss/bridge-core";
|
|
750
|
+
var requestPermission = createAsyncBridge4("requestPermission");
|
|
751
|
+
var getPermission = createAsyncBridge4("getPermission");
|
|
752
|
+
var openPermissionDialog = createAsyncBridge4("openPermissionDialog");
|
|
753
|
+
function createPermissionFunction({
|
|
754
|
+
permission,
|
|
755
|
+
handler,
|
|
756
|
+
error
|
|
757
|
+
}) {
|
|
758
|
+
const permissionFunction = async (...args) => {
|
|
759
|
+
const permissionStatus = await requestPermission(permission);
|
|
760
|
+
if (permissionStatus === "denied") {
|
|
761
|
+
throw new error();
|
|
762
|
+
}
|
|
763
|
+
return handler(...args);
|
|
764
|
+
};
|
|
765
|
+
permissionFunction.getPermission = () => getPermission(permission);
|
|
766
|
+
permissionFunction.openPermissionDialog = () => openPermissionDialog(permission);
|
|
767
|
+
return permissionFunction;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// src/permissions/fetchAlbumPhotos.ts
|
|
771
|
+
var fetchAlbumPhotos = createPermissionFunction({
|
|
772
|
+
handler: (options) => {
|
|
773
|
+
return createAsyncBridge5("fetchAlbumPhotos")(
|
|
774
|
+
options
|
|
775
|
+
);
|
|
776
|
+
},
|
|
777
|
+
permission: {
|
|
778
|
+
name: "photos",
|
|
779
|
+
access: "read"
|
|
780
|
+
},
|
|
781
|
+
error: FetchAlbumPhotosPermissionError
|
|
782
|
+
});
|
|
783
|
+
|
|
784
|
+
// src/permissions/fetchContacts.ts
|
|
785
|
+
import { createAsyncBridge as createAsyncBridge6 } from "@apps-in-toss/bridge-core";
|
|
786
|
+
import { FetchContactsPermissionError } from "@apps-in-toss/types";
|
|
787
|
+
var fetchContacts = createPermissionFunction({
|
|
788
|
+
handler: (options) => {
|
|
789
|
+
return createAsyncBridge6("fetchContacts")(options);
|
|
790
|
+
},
|
|
791
|
+
permission: {
|
|
792
|
+
name: "contacts",
|
|
793
|
+
access: "read"
|
|
794
|
+
},
|
|
795
|
+
error: FetchContactsPermissionError
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
// src/permissions/getCurrentLocation.ts
|
|
799
|
+
import { createAsyncBridge as createAsyncBridge7 } from "@apps-in-toss/bridge-core";
|
|
800
|
+
import {
|
|
801
|
+
GetCurrentLocationPermissionError
|
|
802
|
+
} from "@apps-in-toss/types";
|
|
803
|
+
var getCurrentLocation = createPermissionFunction({
|
|
804
|
+
handler: (options) => {
|
|
805
|
+
return createAsyncBridge7(
|
|
806
|
+
"getCurrentLocation"
|
|
807
|
+
)(options);
|
|
808
|
+
},
|
|
809
|
+
permission: {
|
|
810
|
+
name: "geolocation",
|
|
811
|
+
access: "access"
|
|
812
|
+
},
|
|
813
|
+
error: GetCurrentLocationPermissionError
|
|
814
|
+
});
|
|
815
|
+
|
|
816
|
+
// src/permissions/openCamera.ts
|
|
817
|
+
import { createAsyncBridge as createAsyncBridge8 } from "@apps-in-toss/bridge-core";
|
|
818
|
+
import { OpenCameraPermissionError } from "@apps-in-toss/types";
|
|
819
|
+
var openCamera = createPermissionFunction({
|
|
820
|
+
handler: (options) => {
|
|
821
|
+
return createAsyncBridge8("openCamera")(options);
|
|
822
|
+
},
|
|
823
|
+
permission: {
|
|
824
|
+
name: "camera",
|
|
825
|
+
access: "access"
|
|
826
|
+
},
|
|
827
|
+
error: OpenCameraPermissionError
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
// src/permissions/setClipboardText.ts
|
|
831
|
+
import { createAsyncBridge as createAsyncBridge9 } from "@apps-in-toss/bridge-core";
|
|
832
|
+
import { SetClipboardTextPermissionError } from "@apps-in-toss/types";
|
|
833
|
+
var setClipboardText = createPermissionFunction({
|
|
834
|
+
handler: (options) => {
|
|
835
|
+
return createAsyncBridge9("setClipboardText")(
|
|
836
|
+
options
|
|
837
|
+
);
|
|
838
|
+
},
|
|
839
|
+
permission: {
|
|
840
|
+
name: "clipboard",
|
|
841
|
+
access: "write"
|
|
842
|
+
},
|
|
843
|
+
error: SetClipboardTextPermissionError
|
|
844
|
+
});
|
|
845
|
+
|
|
846
|
+
// src/permissions/getClipboardText.ts
|
|
847
|
+
import { createAsyncBridge as createAsyncBridge10 } from "@apps-in-toss/bridge-core";
|
|
848
|
+
import { GetClipboardTextPermissionError } from "@apps-in-toss/types";
|
|
849
|
+
var getClipboardText = createPermissionFunction({
|
|
850
|
+
handler: () => {
|
|
851
|
+
return createAsyncBridge10("getClipboardText")();
|
|
852
|
+
},
|
|
853
|
+
permission: {
|
|
854
|
+
name: "clipboard",
|
|
855
|
+
access: "read"
|
|
856
|
+
},
|
|
857
|
+
error: GetClipboardTextPermissionError
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
// src/permissions/startUpdateLocation.ts
|
|
861
|
+
import { createAsyncBridge as createAsyncBridge11, createEventBridge as createEventBridge5 } from "@apps-in-toss/bridge-core";
|
|
862
|
+
import {
|
|
863
|
+
StartUpdateLocationPermissionError
|
|
864
|
+
} from "@apps-in-toss/types";
|
|
865
|
+
var getPermission2 = createAsyncBridge11("getPermission");
|
|
866
|
+
var openPermissionDialog2 = createAsyncBridge11("openPermissionDialog");
|
|
867
|
+
var startUpdateLocation = (params) => {
|
|
868
|
+
return createEventBridge5("updateLocationEvent")({
|
|
869
|
+
...params,
|
|
870
|
+
onError: (error) => {
|
|
871
|
+
const locationError = new StartUpdateLocationPermissionError();
|
|
872
|
+
if (error instanceof Error && error.name === locationError.name) {
|
|
873
|
+
return params.onError(locationError);
|
|
874
|
+
}
|
|
875
|
+
return params.onError(error);
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
};
|
|
879
|
+
startUpdateLocation.getPermission = () => getPermission2({ name: "geolocation", access: "access" });
|
|
880
|
+
startUpdateLocation.openPermissionDialog = () => openPermissionDialog2({ name: "geolocation", access: "access" });
|
|
881
|
+
|
|
882
|
+
// src/index.ts
|
|
883
|
+
export * from "@apps-in-toss/types";
|
|
743
884
|
export {
|
|
744
885
|
GoogleAdMob,
|
|
745
886
|
IAP,
|
|
746
887
|
Storage,
|
|
747
888
|
appsInTossEvent,
|
|
748
889
|
env,
|
|
890
|
+
fetchAlbumPhotos,
|
|
891
|
+
fetchContacts,
|
|
749
892
|
getAppsInTossGlobals,
|
|
893
|
+
getClipboardText,
|
|
894
|
+
getCurrentLocation,
|
|
750
895
|
getSafeAreaInsets,
|
|
751
896
|
graniteEvent,
|
|
752
897
|
isMinVersionSupported,
|
|
898
|
+
openCamera,
|
|
753
899
|
partner,
|
|
900
|
+
setClipboardText,
|
|
901
|
+
startUpdateLocation,
|
|
754
902
|
tdsEvent
|
|
755
903
|
};
|
package/built/openCamera.d.ts
CHANGED
|
@@ -21,6 +21,14 @@ export interface OpenCameraOptions {
|
|
|
21
21
|
*/
|
|
22
22
|
maxWidth?: number;
|
|
23
23
|
}
|
|
24
|
+
export type OpenCamera = (options?: OpenCameraOptions) => Promise<ImageResponse>;
|
|
25
|
+
type PermissionStatus$1 = "notDetermined" | "denied" | "allowed";
|
|
26
|
+
export type PermissionDialogFunction = () => Promise<Exclude<PermissionStatus$1, "notDetermined">>;
|
|
27
|
+
export type GetPermissionFunction = () => Promise<PermissionStatus$1>;
|
|
28
|
+
export type PermissionFunctionWithDialog<T extends (...args: any[]) => any> = T & {
|
|
29
|
+
getPermission: GetPermissionFunction;
|
|
30
|
+
openPermissionDialog: PermissionDialogFunction;
|
|
31
|
+
};
|
|
24
32
|
/**
|
|
25
33
|
* @public
|
|
26
34
|
* @category 카메라
|
|
@@ -29,50 +37,79 @@ export interface OpenCameraOptions {
|
|
|
29
37
|
* @param {OpenCameraOptions} options - 카메라 실행 시 사용되는 옵션 객체예요.
|
|
30
38
|
* @param {boolean} [options.base64=false] - 이미지를 Base64 형식으로 반환할지 여부를 나타내는 불리언 값이에요. 기본값은 `false`예요. `true`로 설정하면 `dataUri` 대신 Base64 인코딩된 문자열을 반환해요.
|
|
31
39
|
* @param {number} [options.maxWidth=1024] - 이미지의 최대 너비를 나타내는 숫자 값이에요. 기본값은 `1024`예요.
|
|
40
|
+
* @property [openPermissionDialog] - 카메라 접근 권한을 다시 요청하는 다이얼로그를 표시해요. 사용자는 "허용", "한 번만 허용", "안하기" 중 하나를 선택할 수 있어요. "허용"이나 "한 번만 허용"을 선택하면 `allowed`를 반환하고, "안하기"를 선택하면 `denied`를 반환해요.
|
|
41
|
+
* @property [getPermission] - 카메라 접근 권한의 현재 상태를 반환해요. `allowed`는 사용자가 카메라 접근 권한을 허용한 상태예요. `denied`는 사용자가 카메라 접근 권한을 거부한 상태예요. `notDetermined`는 카메라 접근 권한 요청을 한 번도 하지 않은 상태예요.
|
|
32
42
|
* @returns {Promise<ImageResponse>}
|
|
33
43
|
* 촬영된 이미지 정보를 포함한 객체를 반환해요. 반환 객체의 구성은 다음과 같아요:
|
|
34
44
|
* - `id`: 이미지의 고유 식별자예요.
|
|
35
45
|
* - `dataUri`: 이미지 데이터를 표현하는 데이터 URI예요.
|
|
36
46
|
*
|
|
47
|
+
* @signature
|
|
48
|
+
* ```typescript
|
|
49
|
+
* function openCamera(options: {
|
|
50
|
+
* base64: boolean;
|
|
51
|
+
* maxWidth: number;
|
|
52
|
+
* }): Promise<ImageResponse>;
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
37
55
|
* @example
|
|
38
56
|
* ### 카메라 실행 후 촬영된 사진 가져오기
|
|
39
57
|
*
|
|
58
|
+
* 카메라로 사진을 찍고 결과를 가져오는 예제예요.
|
|
59
|
+
* 이 과정에서 현재 카메라 권한 상태를 확인할 수 있고, 권한이 없으면 권한을 요청해요.
|
|
60
|
+
* 사용자가 권한을 거부했거나 시스템에서 권한이 제한된 경우에는 [`OpenCameraPermissionError`](/react-native/reference/types/권한/OpenCameraPermissionError)를 반환해요.
|
|
61
|
+
*
|
|
40
62
|
* ```tsx
|
|
41
|
-
* import
|
|
63
|
+
* import { ImageResponse, openCamera, OpenCameraPermissionError } from '@apps-in-toss/web-framework';
|
|
64
|
+
* import { useState } from 'react';
|
|
42
65
|
*
|
|
43
|
-
* import { openCamera } from '@apps-in-toss/web-framework';
|
|
44
66
|
*
|
|
45
67
|
* const base64 = true;
|
|
46
68
|
*
|
|
47
69
|
* // 카메라를 실행하고 촬영된 이미지를 화면에 표시하는 컴포넌트
|
|
48
70
|
* function Camera() {
|
|
49
|
-
* const [image, setImage] = useState(null);
|
|
71
|
+
* const [image, setImage] = useState<ImageResponse | null>(null);
|
|
50
72
|
*
|
|
51
73
|
* const handlePress = async () => {
|
|
52
74
|
* try {
|
|
53
75
|
* const response = await openCamera({ base64 });
|
|
54
76
|
* setImage(response);
|
|
55
77
|
* } catch (error) {
|
|
78
|
+
* if (error instanceof OpenCameraPermissionError) {
|
|
79
|
+
* console.log('권한 에러');
|
|
80
|
+
* }
|
|
81
|
+
*
|
|
56
82
|
* console.error('사진을 가져오는 데 실패했어요:', error);
|
|
57
83
|
* }
|
|
58
84
|
* };
|
|
59
85
|
*
|
|
60
86
|
* // base64 형식으로 반환된 이미지를 표시하려면 데이터 URL 스키마 Prefix를 붙여야해요.
|
|
61
|
-
* const imageUri = base64 ? 'data:image/jpeg;base64,' + image
|
|
87
|
+
* const imageUri = base64 ? 'data:image/jpeg;base64,' + image?.dataUri : image?.dataUri;
|
|
62
88
|
*
|
|
63
89
|
* return (
|
|
64
90
|
* <div>
|
|
65
|
-
* {image ?
|
|
66
|
-
* <Image source={{ uri: imageUri }} style={{ width: 200, height: 200 }} />
|
|
67
|
-
* ) : (
|
|
68
|
-
* <span>사진이 없어요</span>
|
|
69
|
-
* )}
|
|
91
|
+
* {image ? <Image source={{ uri: imageUri }} style={{ width: 200, height: 200 }} /> : <span>사진이 없어요</span>}
|
|
70
92
|
* <input type="button" value="사진 촬영하기" onClick={handlePress} />
|
|
93
|
+
* <input type="button"
|
|
94
|
+
* value="권한 확인하기"
|
|
95
|
+
* onClick={async () => {
|
|
96
|
+
* const permission = await openCamera.getPermission();
|
|
97
|
+
* Alert.alert(permission);
|
|
98
|
+
* }}
|
|
99
|
+
* />
|
|
100
|
+
*
|
|
101
|
+
* <input type="button"
|
|
102
|
+
* value="권한 요청하기"
|
|
103
|
+
* onClick={async () => {
|
|
104
|
+
* const currentPermission = await openCamera.openPermissionDialog();
|
|
105
|
+
* Alert.alert(currentPermission);
|
|
106
|
+
* }}
|
|
107
|
+
* />
|
|
71
108
|
* </div>
|
|
72
109
|
* );
|
|
73
110
|
* }
|
|
74
111
|
* ```
|
|
75
112
|
*/
|
|
76
|
-
export declare
|
|
113
|
+
export declare const openCamera: PermissionFunctionWithDialog<OpenCamera>;
|
|
77
114
|
|
|
78
115
|
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
type PermissionStatus$1 = "notDetermined" | "denied" | "allowed";
|
|
2
|
+
export type PermissionAccess = "read" | "write" | "access";
|
|
3
|
+
type PermissionName$1 = "clipboard" | "contacts" | "photos" | "geolocation" | "camera";
|
|
4
|
+
export type PermissionDialogFunction = () => Promise<Exclude<PermissionStatus$1, "notDetermined">>;
|
|
5
|
+
/**
|
|
6
|
+
* @category AppsInTossModules
|
|
7
|
+
* @name openPermissionDialog
|
|
8
|
+
* @description 권한 요청 다이얼로그를 표시하는 함수예요. 사용자는 이 다이얼로그에서 특정 권한을 허용하거나 거부할 수 있어요.
|
|
9
|
+
* @param permission.name {PermissionName} 요청할 권한의 이름이에요. 예를 들어 `clipboard`는 클립보드 접근 권한을, `camera`는 카메라 접근 권한을 나타내요.
|
|
10
|
+
* @param permission.access {PermissionAccess} 요청할 권한의 접근 유형이에요. 예를 들어 `read`는 읽기 권한, `write`는 쓰기 권한을 의미해요.
|
|
11
|
+
* @returns {Promise<'allowed' | 'denied'>} 권한의 현재 상태를 반환해요. 반환값은 다음 중 하나예요:
|
|
12
|
+
* - `allowed`: 권한이 허용된 상태예요.
|
|
13
|
+
* - `denied`: 권한이 거부된 상태예요.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ### 클립보드 읽기 권한 다이얼로그 열기
|
|
17
|
+
*
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import React, { useState } from 'react';
|
|
20
|
+
*
|
|
21
|
+
* import { openPermissionDialog, type PermissionStatus } from '@apps-in-toss/web-framework';
|
|
22
|
+
*
|
|
23
|
+
* function PermissionRequest() {
|
|
24
|
+
* const [permission, setPermission] = useState<PermissionStatus | null>(null);
|
|
25
|
+
*
|
|
26
|
+
* const handleRequestPermission = async () => {
|
|
27
|
+
* try {
|
|
28
|
+
* // 클립보드 읽기 권한을 요청하는 다이얼로그를 표시해요.
|
|
29
|
+
* const status = await openPermissionDialog({
|
|
30
|
+
* name: 'clipboard',
|
|
31
|
+
* access: 'read',
|
|
32
|
+
* });
|
|
33
|
+
* setPermission(status); // 권한 상태를 업데이트해요.
|
|
34
|
+
* } catch (error) {
|
|
35
|
+
* console.error('권한 요청 중 오류가 발생했어요:', error);
|
|
36
|
+
* }
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* return (
|
|
40
|
+
* <div>
|
|
41
|
+
* <span>
|
|
42
|
+
* 클립보드 읽기 권한 상태: {permission ? permission : '아직 요청하지 않음'}
|
|
43
|
+
* </span>
|
|
44
|
+
* <input type="button" value="권한 요청하기" onClick={handleRequestPermission} />
|
|
45
|
+
* </div>
|
|
46
|
+
* );
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function openPermissionDialog(permission: {
|
|
51
|
+
name: PermissionName$1;
|
|
52
|
+
access: PermissionAccess;
|
|
53
|
+
}): ReturnType<PermissionDialogFunction>;
|
|
54
|
+
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
type PermissionStatus$1 = "notDetermined" | "denied" | "allowed";
|
|
2
|
+
export type PermissionAccess = "read" | "write" | "access";
|
|
3
|
+
type PermissionName$1 = "clipboard" | "contacts" | "photos" | "geolocation" | "camera";
|
|
4
|
+
/**
|
|
5
|
+
* @category PermissionManagement
|
|
6
|
+
* @name requestPermission
|
|
7
|
+
* @description 특정 권한을 요청하는 함수예요. 이미 허용되었거나 거부된 권한 상태를 확인한 뒤, 필요할 때 권한 요청 다이얼로그를 표시해요.
|
|
8
|
+
* @param permission.name {PermissionName} 요청할 권한의 이름이에요. 예를 들어 `clipboard`는 클립보드 접근 권한을, `camera`는 카메라 접근 권한을 나타내요.
|
|
9
|
+
* @param permission.access {PermissionAccess} 요청할 권한의 접근 유형이에요. 예를 들어 `read`는 읽기 권한, `write`는 쓰기 권한을 의미해요.
|
|
10
|
+
* @returns {Promise<'allowed' | 'denied'>} 사용자가 선택한 최종 권한 상태를 반환해요.
|
|
11
|
+
* 반환값은 다음 중 하나예요:
|
|
12
|
+
* - `allowed`: 권한이 허용된 경우
|
|
13
|
+
* - `denied`: 권한이 거부된 경우
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ### 클립보드 읽기 권한 요청하기
|
|
17
|
+
*
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import React, { useState } from 'react';
|
|
20
|
+
*
|
|
21
|
+
* import { requestPermission, type PermissionStatus } from '@apps-in-toss/web-framework';
|
|
22
|
+
*
|
|
23
|
+
* function PermissionRequest() {
|
|
24
|
+
* const [permissionStatus, setPermissionStatus] = useState<PermissionStatus | null>(null);
|
|
25
|
+
*
|
|
26
|
+
* const handleRequestPermission = async () => {
|
|
27
|
+
* try {
|
|
28
|
+
* // 클립보드 읽기 권한을 요청해요.
|
|
29
|
+
* const permissionStatus = await requestPermission({
|
|
30
|
+
* name: 'clipboard', // 권한 이름: 클립보드
|
|
31
|
+
* access: 'read', // 접근 유형: 읽기
|
|
32
|
+
* });
|
|
33
|
+
* setPermissionStatus(permissionStatus); // 최종 권한 상태를 저장해요.
|
|
34
|
+
* } catch (error) {
|
|
35
|
+
* console.error('권한 요청 중 오류가 발생했어요:', error);
|
|
36
|
+
* }
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* return (
|
|
40
|
+
* <div>
|
|
41
|
+
* <span>
|
|
42
|
+
* 클립보드 읽기 권한 상태: {permissionStatus ? permissionStatus : '아직 요청하지 않음'}
|
|
43
|
+
* </span>
|
|
44
|
+
* <input type="button" value="권한 요청하기" onClick={handleRequestPermission} />
|
|
45
|
+
* </div>
|
|
46
|
+
* );
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function requestPermission(permission: {
|
|
51
|
+
name: PermissionName$1;
|
|
52
|
+
access: PermissionAccess;
|
|
53
|
+
}): Promise<Exclude<PermissionStatus$1, "notDetermined">>;
|
|
54
|
+
|
|
55
|
+
export {};
|