@apps-in-toss/framework 0.0.5 → 0.0.7
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/bin.js +4 -0
- package/dist/config/index.cjs +33172 -0
- package/dist/config/index.d.cts +37 -0
- package/dist/config/index.d.ts +37 -0
- package/dist/config/index.js +33177 -0
- package/dist/index.cjs +135 -94
- package/dist/index.d.cts +27 -20
- package/dist/index.d.ts +27 -20
- package/dist/index.js +129 -93
- package/dist/jest/index.cjs +24 -0
- package/dist/jest/index.d.cts +1 -0
- package/dist/jest/index.d.ts +1 -0
- package/dist/jest/index.js +4 -0
- package/dist/plugins/index.cjs +33154 -0
- package/dist/plugins/index.d.cts +36 -0
- package/dist/plugins/index.d.ts +36 -0
- package/dist/plugins/index.js +33159 -0
- package/package.json +27 -12
- package/plugins.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/native-event-emitter/index.ts
|
|
8
|
+
var native_event_emitter_exports = {};
|
|
9
|
+
__export(native_event_emitter_exports, {
|
|
10
|
+
startUpdateLocation: () => startUpdateLocation
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// src/native-event-emitter/bedrock-event.ts
|
|
14
|
+
import { BedrockEvent } from "react-native-bedrock";
|
|
15
|
+
|
|
16
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
17
|
+
import { BedrockEventDefinition } from "react-native-bedrock";
|
|
3
18
|
|
|
4
19
|
// src/native-modules/AppsInTossModule.ts
|
|
5
20
|
import { NativeModules } from "react-native";
|
|
6
21
|
var AppsInTossModuleInstance = NativeModules.AppsInTossModule;
|
|
7
22
|
var AppsInTossModule = AppsInTossModuleInstance;
|
|
8
23
|
|
|
9
|
-
// src/native-event-emitter/nativeEventEmitter.ts
|
|
10
|
-
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
11
|
-
|
|
12
24
|
// src/native-modules/getPermission.ts
|
|
13
25
|
function getPermission(permission) {
|
|
14
26
|
return AppsInTossModule.getPermission(permission);
|
|
@@ -31,32 +43,56 @@ async function requestPermission(permission) {
|
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
|
|
34
|
-
// src/native-event-emitter/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
// src/native-event-emitter/nativeEventEmitter.ts
|
|
47
|
+
import { NativeEventEmitter } from "react-native";
|
|
48
|
+
var nativeEventEmitter = new NativeEventEmitter(AppsInTossModuleInstance);
|
|
49
|
+
|
|
50
|
+
// src/native-event-emitter/event-plugins/UpdateLocationEvent.ts
|
|
51
|
+
var UpdateLocationEvent = class extends BedrockEventDefinition {
|
|
52
|
+
name = "updateLocationEvent";
|
|
53
|
+
subscriptionCount = 0;
|
|
54
|
+
ref = {
|
|
55
|
+
remove: () => {
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
remove() {
|
|
59
|
+
--this.subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({});
|
|
60
|
+
this.ref.remove();
|
|
40
61
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const result = Reflect.get(target, key, receiver);
|
|
47
|
-
if (key === "remove") {
|
|
48
|
-
return async () => {
|
|
49
|
-
await (--subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({}));
|
|
50
|
-
const remove = result;
|
|
51
|
-
remove();
|
|
52
|
-
};
|
|
62
|
+
listener(options, onEvent, onError) {
|
|
63
|
+
requestPermission({ name: "geolocation", access: "access" }).then((permissionStatus) => {
|
|
64
|
+
if (permissionStatus === "denied") {
|
|
65
|
+
onError(new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694."));
|
|
66
|
+
return;
|
|
53
67
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
void AppsInTossModuleInstance.startUpdateLocation(options).catch(onError);
|
|
69
|
+
const subscription = nativeEventEmitter.addListener("updateLocation", onEvent);
|
|
70
|
+
this.ref = {
|
|
71
|
+
remove: () => subscription?.remove()
|
|
72
|
+
};
|
|
73
|
+
this.subscriptionCount++;
|
|
74
|
+
}).catch(onError);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/native-event-emitter/bedrock-event.ts
|
|
79
|
+
var appsInTossEvent = new BedrockEvent([new UpdateLocationEvent()]);
|
|
80
|
+
|
|
81
|
+
// src/native-event-emitter/startUpdateLocation.ts
|
|
82
|
+
function startUpdateLocation(eventParams) {
|
|
83
|
+
return appsInTossEvent.addEventListener("updateLocationEvent", eventParams);
|
|
58
84
|
}
|
|
59
|
-
|
|
85
|
+
|
|
86
|
+
// src/native-modules/index.ts
|
|
87
|
+
var native_modules_exports = {};
|
|
88
|
+
__export(native_modules_exports, {
|
|
89
|
+
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
90
|
+
fetchContacts: () => fetchContacts,
|
|
91
|
+
getClipboardText: () => getClipboardText,
|
|
92
|
+
getCurrentLocation: () => getCurrentLocation,
|
|
93
|
+
openCamera: () => openCamera,
|
|
94
|
+
setClipboardText: () => setClipboardText
|
|
95
|
+
});
|
|
60
96
|
|
|
61
97
|
// src/native-modules/setClipboardText.ts
|
|
62
98
|
async function setClipboardText(text) {
|
|
@@ -139,88 +175,88 @@ import {
|
|
|
139
175
|
WebView as OriginalWebView
|
|
140
176
|
} from "@react-native-bedrock/native/react-native-webview";
|
|
141
177
|
import { useMemo } from "react";
|
|
142
|
-
import {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
function getAppsInTossWebViewUrl({
|
|
146
|
-
appName,
|
|
147
|
-
groupId,
|
|
148
|
-
localhostPort,
|
|
149
|
-
env
|
|
150
|
-
}) {
|
|
151
|
-
if (env === "local") {
|
|
152
|
-
return `http://localhost:${localhostPort}`;
|
|
153
|
-
}
|
|
154
|
-
const subdomain = env === "alpha" ? "alpha-apps" : "apps";
|
|
155
|
-
return `https://${appName}--${groupId}.${subdomain}.tossmini.com`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// src/components/WebView.tsx
|
|
178
|
+
import { useBridgeHandler } from "react-native-bedrock";
|
|
179
|
+
import * as bridges from "react-native-bedrock/bridges";
|
|
180
|
+
import * as constantBridges from "react-native-bedrock/constants";
|
|
159
181
|
import { jsx } from "react/jsx-runtime";
|
|
160
|
-
function WebView({
|
|
182
|
+
function WebView({ localhostPort = 5173, onMessage, ...props }) {
|
|
161
183
|
const uri = useMemo(() => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
184
|
+
if (__DEV__) {
|
|
185
|
+
return `http://localhost:${localhostPort}`;
|
|
186
|
+
}
|
|
187
|
+
return AppsInTossModule.getWebBundleURL({}).url;
|
|
188
|
+
}, [localhostPort]);
|
|
189
|
+
const handler = useBridgeHandler({
|
|
190
|
+
onMessage,
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
192
|
+
eventListenerMap: native_event_emitter_exports,
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
194
|
+
// @ts-expect-error
|
|
195
|
+
constantHandlerMap: constantBridges,
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
197
|
+
// @ts-expect-error
|
|
198
|
+
handlerMap: {
|
|
199
|
+
...bridges,
|
|
200
|
+
...native_modules_exports
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return /* @__PURE__ */ jsx(
|
|
204
|
+
OriginalWebView,
|
|
205
|
+
{
|
|
206
|
+
ref: handler.ref,
|
|
207
|
+
...props,
|
|
208
|
+
source: { uri },
|
|
209
|
+
sharedCookiesEnabled: true,
|
|
210
|
+
thirdPartyCookiesEnabled: true,
|
|
211
|
+
onMessage: handler.onMessage,
|
|
212
|
+
injectedJavaScript: handler.injectedJavaScript,
|
|
213
|
+
injectedJavaScriptBeforeContentLoaded: handler.injectedJavaScript
|
|
214
|
+
}
|
|
215
|
+
);
|
|
171
216
|
}
|
|
172
217
|
|
|
173
218
|
// src/hooks/useGeolocation.ts
|
|
174
|
-
import { useState,
|
|
219
|
+
import { useState, useEffect } from "react";
|
|
175
220
|
import { useVisibility } from "react-native-bedrock";
|
|
176
221
|
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
177
222
|
const isVisible = useVisibility();
|
|
178
|
-
const subscriptionRef = useRef();
|
|
179
223
|
const [location, setLocation] = useState(null);
|
|
180
|
-
const subscribe = useCallback(async () => {
|
|
181
|
-
try {
|
|
182
|
-
const subscription = await startUpdateLocation({
|
|
183
|
-
accuracy,
|
|
184
|
-
distanceInterval,
|
|
185
|
-
timeInterval,
|
|
186
|
-
callback: setLocation
|
|
187
|
-
});
|
|
188
|
-
subscriptionRef.current = subscription;
|
|
189
|
-
} catch (error) {
|
|
190
|
-
console.error("failed to subscribe location", error);
|
|
191
|
-
}
|
|
192
|
-
}, [accuracy, distanceInterval, timeInterval]);
|
|
193
|
-
const cleanup = useCallback(async () => {
|
|
194
|
-
try {
|
|
195
|
-
const prevSubscription = subscriptionRef.current;
|
|
196
|
-
subscriptionRef.current = void 0;
|
|
197
|
-
await prevSubscription?.remove();
|
|
198
|
-
} catch (error) {
|
|
199
|
-
console.error("failed to cleanup location subscription", error);
|
|
200
|
-
}
|
|
201
|
-
}, []);
|
|
202
224
|
useEffect(() => {
|
|
203
|
-
if (
|
|
204
|
-
|
|
225
|
+
if (!isVisible) {
|
|
226
|
+
return;
|
|
205
227
|
}
|
|
206
|
-
return (
|
|
207
|
-
|
|
228
|
+
return startUpdateLocation({
|
|
229
|
+
options: {
|
|
230
|
+
accuracy,
|
|
231
|
+
distanceInterval,
|
|
232
|
+
timeInterval
|
|
233
|
+
},
|
|
234
|
+
onEvent: setLocation,
|
|
235
|
+
onError: console.error
|
|
236
|
+
});
|
|
237
|
+
}, [accuracy, distanceInterval, timeInterval, isVisible]);
|
|
208
238
|
return location;
|
|
209
239
|
}
|
|
210
240
|
|
|
241
|
+
// src/env.ts
|
|
242
|
+
var env = {
|
|
243
|
+
getDeploymentId: () => __DEV__ ? "local" : global.__appsInToss?.deploymentId
|
|
244
|
+
};
|
|
245
|
+
|
|
211
246
|
// src/types.ts
|
|
212
|
-
var
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return
|
|
220
|
-
})(
|
|
247
|
+
var Accuracy2 = /* @__PURE__ */ ((Accuracy3) => {
|
|
248
|
+
Accuracy3[Accuracy3["Lowest"] = 1] = "Lowest";
|
|
249
|
+
Accuracy3[Accuracy3["Low"] = 2] = "Low";
|
|
250
|
+
Accuracy3[Accuracy3["Balanced"] = 3] = "Balanced";
|
|
251
|
+
Accuracy3[Accuracy3["High"] = 4] = "High";
|
|
252
|
+
Accuracy3[Accuracy3["Highest"] = 5] = "Highest";
|
|
253
|
+
Accuracy3[Accuracy3["BestForNavigation"] = 6] = "BestForNavigation";
|
|
254
|
+
return Accuracy3;
|
|
255
|
+
})(Accuracy2 || {});
|
|
221
256
|
export {
|
|
222
|
-
Accuracy,
|
|
257
|
+
Accuracy2 as Accuracy,
|
|
223
258
|
WebView,
|
|
259
|
+
env,
|
|
224
260
|
fetchAlbumPhotos,
|
|
225
261
|
fetchContacts,
|
|
226
262
|
getClipboardText,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
|
|
17
|
+
// src/jest/index.ts
|
|
18
|
+
var jest_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(jest_exports);
|
|
20
|
+
__reExport(jest_exports, require("react-native-bedrock/jest"), module.exports);
|
|
21
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
+
0 && (module.exports = {
|
|
23
|
+
...require("react-native-bedrock/jest")
|
|
24
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'react-native-bedrock/jest';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'react-native-bedrock/jest';
|