@comergehq/studio 0.1.3 → 0.1.4
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.d.mts +2 -10
- package/dist/index.d.ts +2 -10
- package/dist/index.js +39 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/services/http/public.ts +19 -0
- package/src/studio/ComergeStudio.tsx +3 -10
- package/src/studio/bootstrap/StudioBootstrap.tsx +2 -2
- package/src/studio/bootstrap/useStudioBootstrap.ts +7 -3
package/dist/index.d.mts
CHANGED
|
@@ -3,21 +3,13 @@ import { ViewStyle } from 'react-native';
|
|
|
3
3
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
4
4
|
|
|
5
5
|
type ComergeStudioProps = {
|
|
6
|
-
/**
|
|
7
|
-
* App to open in the runtime and studio.
|
|
8
|
-
*/
|
|
9
6
|
appId: string;
|
|
10
|
-
|
|
11
|
-
* App root key exposed by the bundle (defaults to MicroMain).
|
|
12
|
-
*/
|
|
7
|
+
apiKey: string;
|
|
13
8
|
appKey?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Optional callback for a “home” button.
|
|
16
|
-
*/
|
|
17
9
|
onNavigateHome?: () => void;
|
|
18
10
|
style?: ViewStyle;
|
|
19
11
|
};
|
|
20
|
-
declare function ComergeStudio({ appId, appKey, onNavigateHome, style, }: ComergeStudioProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
declare function ComergeStudio({ appId, apiKey, appKey, onNavigateHome, style, }: ComergeStudioProps): react_jsx_runtime.JSX.Element;
|
|
21
13
|
|
|
22
14
|
declare function setSupabaseClient(client: SupabaseClient): void;
|
|
23
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,21 +3,13 @@ import { ViewStyle } from 'react-native';
|
|
|
3
3
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
4
4
|
|
|
5
5
|
type ComergeStudioProps = {
|
|
6
|
-
/**
|
|
7
|
-
* App to open in the runtime and studio.
|
|
8
|
-
*/
|
|
9
6
|
appId: string;
|
|
10
|
-
|
|
11
|
-
* App root key exposed by the bundle (defaults to MicroMain).
|
|
12
|
-
*/
|
|
7
|
+
apiKey: string;
|
|
13
8
|
appKey?: string;
|
|
14
|
-
/**
|
|
15
|
-
* Optional callback for a “home” button.
|
|
16
|
-
*/
|
|
17
9
|
onNavigateHome?: () => void;
|
|
18
10
|
style?: ViewStyle;
|
|
19
11
|
};
|
|
20
|
-
declare function ComergeStudio({ appId, appKey, onNavigateHome, style, }: ComergeStudioProps): react_jsx_runtime.JSX.Element;
|
|
12
|
+
declare function ComergeStudio({ appId, apiKey, appKey, onNavigateHome, style, }: ComergeStudioProps): react_jsx_runtime.JSX.Element;
|
|
21
13
|
|
|
22
14
|
declare function setSupabaseClient(client: SupabaseClient): void;
|
|
23
15
|
|
package/dist/index.js
CHANGED
|
@@ -214,6 +214,39 @@ function Text({
|
|
|
214
214
|
// src/studio/bootstrap/useStudioBootstrap.ts
|
|
215
215
|
var React = __toESM(require("react"));
|
|
216
216
|
|
|
217
|
+
// src/core/services/http/public.ts
|
|
218
|
+
var import_axios = __toESM(require("axios"));
|
|
219
|
+
|
|
220
|
+
// src/core/services/http/baseUrl.ts
|
|
221
|
+
var BASE_URL = "http://192.168.8.175:8080";
|
|
222
|
+
|
|
223
|
+
// src/core/services/http/public.ts
|
|
224
|
+
var CLIENT_KEY_HEADER = "x-comerge-api-key";
|
|
225
|
+
var clientApiKey = null;
|
|
226
|
+
var publicApi = import_axios.default.create({
|
|
227
|
+
baseURL: BASE_URL,
|
|
228
|
+
timeout: 3e4,
|
|
229
|
+
headers: {
|
|
230
|
+
Accept: "application/json",
|
|
231
|
+
"Content-Type": "application/json"
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
function setClientApiKey(apiKey) {
|
|
235
|
+
var _a;
|
|
236
|
+
const trimmed = ((_a = apiKey == null ? void 0 : apiKey.trim) == null ? void 0 : _a.call(apiKey)) ?? "";
|
|
237
|
+
if (!trimmed) {
|
|
238
|
+
throw new Error("comerge-studio: apiKey is required");
|
|
239
|
+
}
|
|
240
|
+
clientApiKey = trimmed;
|
|
241
|
+
publicApi.defaults.headers.common[CLIENT_KEY_HEADER] = trimmed;
|
|
242
|
+
}
|
|
243
|
+
publicApi.interceptors.request.use((config) => {
|
|
244
|
+
if (!clientApiKey) return config;
|
|
245
|
+
config.headers = config.headers ?? {};
|
|
246
|
+
config.headers[CLIENT_KEY_HEADER] = clientApiKey;
|
|
247
|
+
return config;
|
|
248
|
+
});
|
|
249
|
+
|
|
217
250
|
// src/core/services/supabase/client.ts
|
|
218
251
|
var import_supabase_js = require("@supabase/supabase-js");
|
|
219
252
|
var clientSingleton = null;
|
|
@@ -284,22 +317,6 @@ var BaseRepository = class {
|
|
|
284
317
|
}
|
|
285
318
|
};
|
|
286
319
|
|
|
287
|
-
// src/core/services/http/public.ts
|
|
288
|
-
var import_axios = __toESM(require("axios"));
|
|
289
|
-
|
|
290
|
-
// src/core/services/http/baseUrl.ts
|
|
291
|
-
var BASE_URL = "http://192.168.8.175:8080";
|
|
292
|
-
|
|
293
|
-
// src/core/services/http/public.ts
|
|
294
|
-
var publicApi = import_axios.default.create({
|
|
295
|
-
baseURL: BASE_URL,
|
|
296
|
-
timeout: 3e4,
|
|
297
|
-
headers: {
|
|
298
|
-
Accept: "application/json",
|
|
299
|
-
"Content-Type": "application/json"
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
|
|
303
320
|
// src/data/base-remote.ts
|
|
304
321
|
var BaseRemote = class {
|
|
305
322
|
};
|
|
@@ -337,6 +354,7 @@ function useStudioBootstrap(options) {
|
|
|
337
354
|
let cancelled = false;
|
|
338
355
|
(async () => {
|
|
339
356
|
try {
|
|
357
|
+
setClientApiKey(options.apiKey);
|
|
340
358
|
const requireAuth = isSupabaseClientInjected();
|
|
341
359
|
if (!requireAuth) {
|
|
342
360
|
const cfg = await studioConfigRepository.get();
|
|
@@ -354,14 +372,14 @@ function useStudioBootstrap(options) {
|
|
|
354
372
|
return () => {
|
|
355
373
|
cancelled = true;
|
|
356
374
|
};
|
|
357
|
-
}, []);
|
|
375
|
+
}, [options.apiKey]);
|
|
358
376
|
return state;
|
|
359
377
|
}
|
|
360
378
|
|
|
361
379
|
// src/studio/bootstrap/StudioBootstrap.tsx
|
|
362
380
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
363
|
-
function StudioBootstrap({ children, fallback, renderError }) {
|
|
364
|
-
const { ready, error, userId } = useStudioBootstrap({});
|
|
381
|
+
function StudioBootstrap({ children, fallback, renderError, apiKey }) {
|
|
382
|
+
const { ready, error, userId } = useStudioBootstrap({ apiKey });
|
|
365
383
|
if (error) {
|
|
366
384
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native3.View, { style: { flex: 1, justifyContent: "center", alignItems: "center", padding: 24 }, children: renderError ? renderError(error) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Text, { variant: "bodyMuted", children: error.message }) });
|
|
367
385
|
}
|
|
@@ -6255,6 +6273,7 @@ function StudioOverlay({
|
|
|
6255
6273
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
6256
6274
|
function ComergeStudio({
|
|
6257
6275
|
appId,
|
|
6276
|
+
apiKey,
|
|
6258
6277
|
appKey = "MicroMain",
|
|
6259
6278
|
onNavigateHome,
|
|
6260
6279
|
style
|
|
@@ -6269,7 +6288,7 @@ function ComergeStudio({
|
|
|
6269
6288
|
setPendingRuntimeTargetAppId(null);
|
|
6270
6289
|
}, [appId]);
|
|
6271
6290
|
const captureTargetRef = React38.useRef(null);
|
|
6272
|
-
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(StudioBootstrap, { children: ({ userId }) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_bottom_sheet6.BottomSheetModalProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
6291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(StudioBootstrap, { apiKey, children: ({ userId }) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_bottom_sheet6.BottomSheetModalProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
|
|
6273
6292
|
ComergeStudioInner,
|
|
6274
6293
|
{
|
|
6275
6294
|
userId,
|