@apps-in-toss/framework 0.0.0-dev.1736241821988 → 0.0.0-dev.1739241377950

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/LICENSE CHANGED
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright 2024 Viva Republica, Inc
190
+ Copyright 2025 Viva Republica, Inc
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
@@ -199,4 +199,4 @@
199
199
  distributed under the License is distributed on an "AS IS" BASIS,
200
200
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
201
  See the License for the specific language governing permissions and
202
- limitations under the License.
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # @apps-in-toss/cli-commands
1
+ # @apps-in-toss/framework
2
2
 
3
- CLI presets package for Apps In Toss.
3
+ Hub package for Apps In Toss
4
4
 
5
5
  ## License
6
6
 
7
7
  This software is licensed under the [Apache 2 license](LICENSE), quoted below.
8
8
 
9
9
  ```
10
- Copyright 2024 Viva Republica, Inc
10
+ Copyright 2025 Viva Republica, Inc
11
11
 
12
12
  Licensed under the Apache License, Version 2.0 (the "License");
13
13
  you may not use this file except in compliance with the License.
@@ -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/cli-presets.ts
18
+ var cli_presets_exports = {};
19
+ module.exports = __toCommonJS(cli_presets_exports);
20
+ __reExport(cli_presets_exports, require("@apps-in-toss/cli-presets"), module.exports);
21
+ // Annotate the CommonJS export names for ESM import in node:
22
+ 0 && (module.exports = {
23
+ ...require("@apps-in-toss/cli-presets")
24
+ });
@@ -0,0 +1 @@
1
+ export * from '@apps-in-toss/cli-presets';
@@ -1,24 +1,2 @@
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
1
  // src/cli-presets.ts
18
- var cli_presets_exports = {};
19
- module.exports = __toCommonJS(cli_presets_exports);
20
- __reExport(cli_presets_exports, require("@apps-in-toss/cli-presets"), module.exports);
21
- // Annotate the CommonJS export names for ESM import in node:
22
- 0 && (module.exports = {
23
- ...require("@apps-in-toss/cli-presets")
24
- });
2
+ export * from "@apps-in-toss/cli-presets";
package/dist/index.cjs ADDED
@@ -0,0 +1,266 @@
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 __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Accuracy: () => Accuracy,
24
+ WebView: () => WebView,
25
+ fetchAlbumPhotos: () => fetchAlbumPhotos,
26
+ fetchContacts: () => fetchContacts,
27
+ getClipboardText: () => getClipboardText,
28
+ getCurrentLocation: () => getCurrentLocation,
29
+ openCamera: () => openCamera,
30
+ setClipboardText: () => setClipboardText,
31
+ startUpdateLocation: () => startUpdateLocation,
32
+ useGeolocation: () => useGeolocation
33
+ });
34
+ module.exports = __toCommonJS(src_exports);
35
+
36
+ // src/native-event-emitter/nativeEventEmitter.ts
37
+ var import_react_native2 = require("react-native");
38
+
39
+ // src/native-modules/AppsInTossModule.ts
40
+ var import_react_native = require("react-native");
41
+ var AppsInTossModuleInstance = import_react_native.NativeModules.AppsInTossModule;
42
+ var AppsInTossModule = AppsInTossModuleInstance;
43
+
44
+ // src/native-event-emitter/nativeEventEmitter.ts
45
+ var nativeEventEmitter = new import_react_native2.NativeEventEmitter(AppsInTossModuleInstance);
46
+
47
+ // src/native-modules/getPermission.ts
48
+ function getPermission(permission) {
49
+ return AppsInTossModule.getPermission(permission);
50
+ }
51
+
52
+ // src/native-modules/openPermissionDialog.ts
53
+ function openPermissionDialog(permission) {
54
+ return AppsInTossModule.openPermissionDialog(permission);
55
+ }
56
+
57
+ // src/native-modules/requestPermission.ts
58
+ async function requestPermission(permission) {
59
+ const permissionStatus = await getPermission(permission);
60
+ switch (permissionStatus) {
61
+ case "allowed":
62
+ case "denied":
63
+ return permissionStatus;
64
+ default:
65
+ return openPermissionDialog(permission);
66
+ }
67
+ }
68
+
69
+ // src/native-event-emitter/startUpdateLocation.ts
70
+ async function startUpdateLocation(options) {
71
+ const { callback, ...nativeOptions } = options;
72
+ const permissionStatus = await requestPermission({ name: "geolocation", access: "access" });
73
+ if (permissionStatus === "denied") {
74
+ throw new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
75
+ }
76
+ await AppsInTossModuleInstance.startUpdateLocation(nativeOptions);
77
+ const subscription = nativeEventEmitter.addListener("updateLocation", callback);
78
+ subscriptionCount++;
79
+ const subscriptionProxy = new Proxy(subscription, {
80
+ get: (target, key, receiver) => {
81
+ const result = Reflect.get(target, key, receiver);
82
+ if (key === "remove") {
83
+ return async () => {
84
+ await (--subscriptionCount === 0 && AppsInTossModuleInstance.stopUpdateLocation({}));
85
+ const remove = result;
86
+ remove();
87
+ };
88
+ }
89
+ return result;
90
+ }
91
+ });
92
+ return subscriptionProxy;
93
+ }
94
+ var subscriptionCount = 0;
95
+
96
+ // src/native-modules/setClipboardText.ts
97
+ async function setClipboardText(text) {
98
+ const permissionStatus = await requestPermission({ name: "clipboard", access: "write" });
99
+ if (permissionStatus === "denied") {
100
+ throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC4F0\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
101
+ }
102
+ return AppsInTossModule.setClipboardText({ text });
103
+ }
104
+
105
+ // src/native-modules/getClipboardText.ts
106
+ async function getClipboardText() {
107
+ const permissionStatus = await requestPermission({ name: "clipboard", access: "read" });
108
+ if (permissionStatus === "denied") {
109
+ throw new Error("\uD074\uB9BD\uBCF4\uB4DC \uC77D\uAE30 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
110
+ }
111
+ return AppsInTossModule.getClipboardText({});
112
+ }
113
+
114
+ // src/native-modules/fetchContacts.ts
115
+ async function fetchContacts({
116
+ size,
117
+ offset,
118
+ query
119
+ }) {
120
+ const permissionStatus = await requestPermission({ name: "contacts", access: "read" });
121
+ if (permissionStatus === "denied") {
122
+ throw new Error("\uC5F0\uB77D\uCC98 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
123
+ }
124
+ const contacts = await AppsInTossModule.fetchContacts({
125
+ size,
126
+ offset,
127
+ query
128
+ });
129
+ return {
130
+ result: contacts.result,
131
+ nextOffset: contacts.nextOffset ?? null,
132
+ done: contacts.done
133
+ };
134
+ }
135
+
136
+ // src/native-modules/fetchAlbumPhotos.ts
137
+ var DEFAULT_MAX_COUNT = 10;
138
+ var DEFAULT_MAX_WIDTH = 1024;
139
+ async function fetchAlbumPhotos(options) {
140
+ const permissionStatus = await requestPermission({ name: "photos", access: "read" });
141
+ if (permissionStatus === "denied") {
142
+ throw new Error("\uC0AC\uC9C4\uCCA9 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
143
+ }
144
+ const albumPhotos = await AppsInTossModule.fetchAlbumPhotos({
145
+ ...options,
146
+ maxCount: options.maxCount ?? DEFAULT_MAX_COUNT,
147
+ maxWidth: options.maxWidth ?? DEFAULT_MAX_WIDTH
148
+ });
149
+ return albumPhotos;
150
+ }
151
+
152
+ // src/native-modules/getCurrentLocation.ts
153
+ async function getCurrentLocation(options) {
154
+ const permissionStatus = await requestPermission({ name: "geolocation", access: "access" });
155
+ if (permissionStatus === "denied") {
156
+ throw new Error("\uC704\uCE58 \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
157
+ }
158
+ const position = await AppsInTossModule.getCurrentLocation(options);
159
+ return position;
160
+ }
161
+
162
+ // src/native-modules/openCamera.ts
163
+ async function openCamera(options) {
164
+ const permissionStatus = await requestPermission({ name: "camera", access: "access" });
165
+ if (permissionStatus === "denied") {
166
+ throw new Error("\uCE74\uBA54\uB77C \uAD8C\uD55C\uC774 \uAC70\uBD80\uB418\uC5C8\uC5B4\uC694.");
167
+ }
168
+ const photo = await AppsInTossModule.openCamera({ base64: false, maxWidth: 1024, ...options });
169
+ return photo;
170
+ }
171
+
172
+ // src/components/WebView.tsx
173
+ var import_react_native_webview = require("@react-native-bedrock/native/react-native-webview");
174
+ var import_react = require("react");
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");
209
+ function useGeolocation({ accuracy, distanceInterval, timeInterval }) {
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 () => {
214
+ try {
215
+ const subscription = await startUpdateLocation({
216
+ accuracy,
217
+ distanceInterval,
218
+ timeInterval,
219
+ callback: setLocation
220
+ });
221
+ subscriptionRef.current = subscription;
222
+ } catch (error) {
223
+ console.error("failed to subscribe location", error);
224
+ }
225
+ }, [accuracy, distanceInterval, timeInterval]);
226
+ const cleanup = (0, import_react2.useCallback)(async () => {
227
+ try {
228
+ const prevSubscription = subscriptionRef.current;
229
+ subscriptionRef.current = void 0;
230
+ await prevSubscription?.remove();
231
+ } catch (error) {
232
+ console.error("failed to cleanup location subscription", error);
233
+ }
234
+ }, []);
235
+ (0, import_react2.useEffect)(() => {
236
+ if (subscriptionRef.current == null && isVisible) {
237
+ subscribe();
238
+ }
239
+ return () => void cleanup();
240
+ }, [subscribe, cleanup, isVisible]);
241
+ return location;
242
+ }
243
+
244
+ // src/types.ts
245
+ var Accuracy = /* @__PURE__ */ ((Accuracy2) => {
246
+ Accuracy2[Accuracy2["Lowest"] = 1] = "Lowest";
247
+ Accuracy2[Accuracy2["Low"] = 2] = "Low";
248
+ Accuracy2[Accuracy2["Balanced"] = 3] = "Balanced";
249
+ Accuracy2[Accuracy2["High"] = 4] = "High";
250
+ Accuracy2[Accuracy2["Highest"] = 5] = "Highest";
251
+ Accuracy2[Accuracy2["BestForNavigation"] = 6] = "BestForNavigation";
252
+ return Accuracy2;
253
+ })(Accuracy || {});
254
+ // Annotate the CommonJS export names for ESM import in node:
255
+ 0 && (module.exports = {
256
+ Accuracy,
257
+ WebView,
258
+ fetchAlbumPhotos,
259
+ fetchContacts,
260
+ getClipboardText,
261
+ getCurrentLocation,
262
+ openCamera,
263
+ setClipboardText,
264
+ startUpdateLocation,
265
+ useGeolocation
266
+ });