@apps-in-toss/framework 0.0.4 → 0.0.5
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/dist/index.cjs +43 -7
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +37 -0
- package/package.json +7 -11
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
Accuracy: () => Accuracy,
|
|
24
|
+
WebView: () => WebView,
|
|
24
25
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
25
26
|
fetchContacts: () => fetchContacts,
|
|
26
27
|
getClipboardText: () => getClipboardText,
|
|
@@ -168,14 +169,48 @@ async function openCamera(options) {
|
|
|
168
169
|
return photo;
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
// src/
|
|
172
|
+
// src/components/WebView.tsx
|
|
173
|
+
var import_react_native_webview = require("@react-native-bedrock/native/react-native-webview");
|
|
172
174
|
var import_react = require("react");
|
|
173
175
|
var import_react_native_bedrock = require("react-native-bedrock");
|
|
176
|
+
|
|
177
|
+
// src/components/getAppsInTossWebViewUrl.tsx
|
|
178
|
+
function getAppsInTossWebViewUrl({
|
|
179
|
+
appName,
|
|
180
|
+
groupId,
|
|
181
|
+
localhostPort,
|
|
182
|
+
env
|
|
183
|
+
}) {
|
|
184
|
+
if (env === "local") {
|
|
185
|
+
return `http://localhost:${localhostPort}`;
|
|
186
|
+
}
|
|
187
|
+
const subdomain = env === "alpha" ? "alpha-apps" : "apps";
|
|
188
|
+
return `https://${appName}--${groupId}.${subdomain}.tossmini.com`;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/components/WebView.tsx
|
|
192
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
193
|
+
function WebView({ env, localhostPort = 5173, ...props }) {
|
|
194
|
+
const uri = (0, import_react.useMemo)(() => {
|
|
195
|
+
const $env = env ?? (__DEV__ ? "local" : AppsInTossModule.operationalEnvironment === "sandbox" ? "alpha" : "production");
|
|
196
|
+
return getAppsInTossWebViewUrl({
|
|
197
|
+
appName: import_react_native_bedrock.Bedrock.appName,
|
|
198
|
+
groupId: AppsInTossModule.groupId,
|
|
199
|
+
localhostPort,
|
|
200
|
+
env: $env
|
|
201
|
+
});
|
|
202
|
+
}, [env, localhostPort]);
|
|
203
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_webview.WebView, { source: { uri }, ...props });
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/hooks/useGeolocation.ts
|
|
207
|
+
var import_react2 = require("react");
|
|
208
|
+
var import_react_native_bedrock2 = require("react-native-bedrock");
|
|
174
209
|
function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
175
|
-
const isVisible = (0,
|
|
176
|
-
const subscriptionRef = (0,
|
|
177
|
-
const [location, setLocation] = (0,
|
|
178
|
-
const subscribe = (0,
|
|
210
|
+
const isVisible = (0, import_react_native_bedrock2.useVisibility)();
|
|
211
|
+
const subscriptionRef = (0, import_react2.useRef)();
|
|
212
|
+
const [location, setLocation] = (0, import_react2.useState)(null);
|
|
213
|
+
const subscribe = (0, import_react2.useCallback)(async () => {
|
|
179
214
|
try {
|
|
180
215
|
const subscription = await startUpdateLocation({
|
|
181
216
|
accuracy,
|
|
@@ -188,7 +223,7 @@ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
|
188
223
|
console.error("failed to subscribe location", error);
|
|
189
224
|
}
|
|
190
225
|
}, [accuracy, distanceInterval, timeInterval]);
|
|
191
|
-
const cleanup = (0,
|
|
226
|
+
const cleanup = (0, import_react2.useCallback)(async () => {
|
|
192
227
|
try {
|
|
193
228
|
const prevSubscription = subscriptionRef.current;
|
|
194
229
|
subscriptionRef.current = void 0;
|
|
@@ -197,7 +232,7 @@ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
|
|
|
197
232
|
console.error("failed to cleanup location subscription", error);
|
|
198
233
|
}
|
|
199
234
|
}, []);
|
|
200
|
-
(0,
|
|
235
|
+
(0, import_react2.useEffect)(() => {
|
|
201
236
|
if (subscriptionRef.current == null && isVisible) {
|
|
202
237
|
subscribe();
|
|
203
238
|
}
|
|
@@ -219,6 +254,7 @@ var Accuracy = /* @__PURE__ */ ((Accuracy2) => {
|
|
|
219
254
|
// Annotate the CommonJS export names for ESM import in node:
|
|
220
255
|
0 && (module.exports = {
|
|
221
256
|
Accuracy,
|
|
257
|
+
WebView,
|
|
222
258
|
fetchAlbumPhotos,
|
|
223
259
|
fetchContacts,
|
|
224
260
|
getClipboardText,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { WebViewProps as WebViewProps$1 } from '@react-native-bedrock/native/react-native-webview';
|
|
2
4
|
|
|
3
5
|
interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
4
6
|
name: K;
|
|
@@ -507,6 +509,12 @@ interface OpenCameraOptions {
|
|
|
507
509
|
*/
|
|
508
510
|
declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>;
|
|
509
511
|
|
|
512
|
+
interface WebViewProps extends Omit<WebViewProps$1, 'source'> {
|
|
513
|
+
env?: 'production' | 'alpha' | 'local';
|
|
514
|
+
localhostPort?: number;
|
|
515
|
+
}
|
|
516
|
+
declare function WebView({ env, localhostPort, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
|
|
517
|
+
|
|
510
518
|
type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
511
519
|
/**
|
|
512
520
|
* @public
|
|
@@ -554,4 +562,4 @@ type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
|
554
562
|
*/
|
|
555
563
|
declare function useGeolocation({ accuracy, distanceInterval, timeInterval }: UseGeolocationOptions): Location | null;
|
|
556
564
|
|
|
557
|
-
export { Accuracy, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
|
565
|
+
export { Accuracy, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { WebViewProps as WebViewProps$1 } from '@react-native-bedrock/native/react-native-webview';
|
|
2
4
|
|
|
3
5
|
interface EventEmitterSchema<K extends string, P extends unknown[]> {
|
|
4
6
|
name: K;
|
|
@@ -507,6 +509,12 @@ interface OpenCameraOptions {
|
|
|
507
509
|
*/
|
|
508
510
|
declare function openCamera(options?: OpenCameraOptions): Promise<ImageResponse>;
|
|
509
511
|
|
|
512
|
+
interface WebViewProps extends Omit<WebViewProps$1, 'source'> {
|
|
513
|
+
env?: 'production' | 'alpha' | 'local';
|
|
514
|
+
localhostPort?: number;
|
|
515
|
+
}
|
|
516
|
+
declare function WebView({ env, localhostPort, ...props }: WebViewProps): react_jsx_runtime.JSX.Element;
|
|
517
|
+
|
|
510
518
|
type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
511
519
|
/**
|
|
512
520
|
* @public
|
|
@@ -554,4 +562,4 @@ type UseGeolocationOptions = Omit<StartUpdateLocationOptions, 'callback'>;
|
|
|
554
562
|
*/
|
|
555
563
|
declare function useGeolocation({ accuracy, distanceInterval, timeInterval }: UseGeolocationOptions): Location | null;
|
|
556
564
|
|
|
557
|
-
export { Accuracy, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
|
565
|
+
export { Accuracy, type ContactEntity, type FetchAlbumPhotosOptions, type GetCurrentLocationOptions, type ImageResponse, type Location, type OpenCameraOptions, type StartUpdateLocationOptions, type StartUpdateLocationSubscription, type UpdateLocationEventEmitter, type UseGeolocationOptions, WebView, type WebViewProps, fetchAlbumPhotos, fetchContacts, getClipboardText, getCurrentLocation, openCamera, setClipboardText, startUpdateLocation, useGeolocation };
|
package/dist/index.js
CHANGED
|
@@ -134,6 +134,42 @@ async function openCamera(options) {
|
|
|
134
134
|
return photo;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
// src/components/WebView.tsx
|
|
138
|
+
import {
|
|
139
|
+
WebView as OriginalWebView
|
|
140
|
+
} from "@react-native-bedrock/native/react-native-webview";
|
|
141
|
+
import { useMemo } from "react";
|
|
142
|
+
import { Bedrock } from "react-native-bedrock";
|
|
143
|
+
|
|
144
|
+
// src/components/getAppsInTossWebViewUrl.tsx
|
|
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
|
|
159
|
+
import { jsx } from "react/jsx-runtime";
|
|
160
|
+
function WebView({ env, localhostPort = 5173, ...props }) {
|
|
161
|
+
const uri = useMemo(() => {
|
|
162
|
+
const $env = env ?? (__DEV__ ? "local" : AppsInTossModule.operationalEnvironment === "sandbox" ? "alpha" : "production");
|
|
163
|
+
return getAppsInTossWebViewUrl({
|
|
164
|
+
appName: Bedrock.appName,
|
|
165
|
+
groupId: AppsInTossModule.groupId,
|
|
166
|
+
localhostPort,
|
|
167
|
+
env: $env
|
|
168
|
+
});
|
|
169
|
+
}, [env, localhostPort]);
|
|
170
|
+
return /* @__PURE__ */ jsx(OriginalWebView, { source: { uri }, ...props });
|
|
171
|
+
}
|
|
172
|
+
|
|
137
173
|
// src/hooks/useGeolocation.ts
|
|
138
174
|
import { useState, useCallback, useEffect, useRef } from "react";
|
|
139
175
|
import { useVisibility } from "react-native-bedrock";
|
|
@@ -184,6 +220,7 @@ var Accuracy = /* @__PURE__ */ ((Accuracy2) => {
|
|
|
184
220
|
})(Accuracy || {});
|
|
185
221
|
export {
|
|
186
222
|
Accuracy,
|
|
223
|
+
WebView,
|
|
187
224
|
fetchAlbumPhotos,
|
|
188
225
|
fetchContacts,
|
|
189
226
|
getClipboardText,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/framework",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"description": "Hub package for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"prepack": "yarn build",
|
|
@@ -30,31 +30,27 @@
|
|
|
30
30
|
"dist/**/*"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@apps-in-toss/cli-presets": "0.0.
|
|
33
|
+
"@apps-in-toss/cli-presets": "0.0.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"@react-native-bedrock/native": "0.0.10",
|
|
36
37
|
"@types/react": "18.3.3",
|
|
37
38
|
"eslint": "^9.7.0",
|
|
38
39
|
"react": "18.2.0",
|
|
39
40
|
"react-native": "0.72.6",
|
|
40
|
-
"react-native-bedrock": "0.0.
|
|
41
|
+
"react-native-bedrock": "0.0.10",
|
|
41
42
|
"tsup": "^8.3.5",
|
|
42
43
|
"typescript": "4.9.5",
|
|
43
44
|
"vitest": "^3.0.3"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
47
|
+
"@react-native-bedrock/native": "*",
|
|
46
48
|
"react": "*",
|
|
47
49
|
"react-native": "*",
|
|
48
|
-
"react-native-bedrock": "*"
|
|
49
|
-
"vite": "*"
|
|
50
|
-
},
|
|
51
|
-
"peerDependenciesMeta": {
|
|
52
|
-
"vite": {
|
|
53
|
-
"optional": true
|
|
54
|
-
}
|
|
50
|
+
"react-native-bedrock": "*"
|
|
55
51
|
},
|
|
56
52
|
"publishConfig": {
|
|
57
53
|
"access": "public"
|
|
58
54
|
},
|
|
59
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "1f2a93c6e928096e0626a0f99167fe617d85c722"
|
|
60
56
|
}
|