@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.mjs CHANGED
@@ -184,6 +184,39 @@ function Text({
184
184
  // src/studio/bootstrap/useStudioBootstrap.ts
185
185
  import * as React from "react";
186
186
 
187
+ // src/core/services/http/public.ts
188
+ import axios from "axios";
189
+
190
+ // src/core/services/http/baseUrl.ts
191
+ var BASE_URL = "http://192.168.8.175:8080";
192
+
193
+ // src/core/services/http/public.ts
194
+ var CLIENT_KEY_HEADER = "x-comerge-api-key";
195
+ var clientApiKey = null;
196
+ var publicApi = axios.create({
197
+ baseURL: BASE_URL,
198
+ timeout: 3e4,
199
+ headers: {
200
+ Accept: "application/json",
201
+ "Content-Type": "application/json"
202
+ }
203
+ });
204
+ function setClientApiKey(apiKey) {
205
+ var _a;
206
+ const trimmed = ((_a = apiKey == null ? void 0 : apiKey.trim) == null ? void 0 : _a.call(apiKey)) ?? "";
207
+ if (!trimmed) {
208
+ throw new Error("comerge-studio: apiKey is required");
209
+ }
210
+ clientApiKey = trimmed;
211
+ publicApi.defaults.headers.common[CLIENT_KEY_HEADER] = trimmed;
212
+ }
213
+ publicApi.interceptors.request.use((config) => {
214
+ if (!clientApiKey) return config;
215
+ config.headers = config.headers ?? {};
216
+ config.headers[CLIENT_KEY_HEADER] = clientApiKey;
217
+ return config;
218
+ });
219
+
187
220
  // src/core/services/supabase/client.ts
188
221
  import { createClient } from "@supabase/supabase-js";
189
222
  var clientSingleton = null;
@@ -254,22 +287,6 @@ var BaseRepository = class {
254
287
  }
255
288
  };
256
289
 
257
- // src/core/services/http/public.ts
258
- import axios from "axios";
259
-
260
- // src/core/services/http/baseUrl.ts
261
- var BASE_URL = "http://192.168.8.175:8080";
262
-
263
- // src/core/services/http/public.ts
264
- var publicApi = axios.create({
265
- baseURL: BASE_URL,
266
- timeout: 3e4,
267
- headers: {
268
- Accept: "application/json",
269
- "Content-Type": "application/json"
270
- }
271
- });
272
-
273
290
  // src/data/base-remote.ts
274
291
  var BaseRemote = class {
275
292
  };
@@ -307,6 +324,7 @@ function useStudioBootstrap(options) {
307
324
  let cancelled = false;
308
325
  (async () => {
309
326
  try {
327
+ setClientApiKey(options.apiKey);
310
328
  const requireAuth = isSupabaseClientInjected();
311
329
  if (!requireAuth) {
312
330
  const cfg = await studioConfigRepository.get();
@@ -324,14 +342,14 @@ function useStudioBootstrap(options) {
324
342
  return () => {
325
343
  cancelled = true;
326
344
  };
327
- }, []);
345
+ }, [options.apiKey]);
328
346
  return state;
329
347
  }
330
348
 
331
349
  // src/studio/bootstrap/StudioBootstrap.tsx
332
350
  import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
333
- function StudioBootstrap({ children, fallback, renderError }) {
334
- const { ready, error, userId } = useStudioBootstrap({});
351
+ function StudioBootstrap({ children, fallback, renderError, apiKey }) {
352
+ const { ready, error, userId } = useStudioBootstrap({ apiKey });
335
353
  if (error) {
336
354
  return /* @__PURE__ */ jsx2(View, { style: { flex: 1, justifyContent: "center", alignItems: "center", padding: 24 }, children: renderError ? renderError(error) : /* @__PURE__ */ jsx2(Text, { variant: "bodyMuted", children: error.message }) });
337
355
  }
@@ -6285,6 +6303,7 @@ function StudioOverlay({
6285
6303
  import { jsx as jsx56, jsxs as jsxs34 } from "react/jsx-runtime";
6286
6304
  function ComergeStudio({
6287
6305
  appId,
6306
+ apiKey,
6288
6307
  appKey = "MicroMain",
6289
6308
  onNavigateHome,
6290
6309
  style
@@ -6299,7 +6318,7 @@ function ComergeStudio({
6299
6318
  setPendingRuntimeTargetAppId(null);
6300
6319
  }, [appId]);
6301
6320
  const captureTargetRef = React38.useRef(null);
6302
- return /* @__PURE__ */ jsx56(StudioBootstrap, { children: ({ userId }) => /* @__PURE__ */ jsx56(BottomSheetModalProvider, { children: /* @__PURE__ */ jsx56(
6321
+ return /* @__PURE__ */ jsx56(StudioBootstrap, { apiKey, children: ({ userId }) => /* @__PURE__ */ jsx56(BottomSheetModalProvider, { children: /* @__PURE__ */ jsx56(
6303
6322
  ComergeStudioInner,
6304
6323
  {
6305
6324
  userId,