teraprox-core-sdk 0.3.2 → 0.3.3

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.
@@ -65,13 +65,21 @@ async function probeEmulator(host, port) {
65
65
  return false;
66
66
  }
67
67
  }
68
- async function resolveRtdbStrategy(firebaseConfig) {
69
- var _a;
68
+ async function resolveRtdbStrategy(firebaseConfig, emulator) {
69
+ var _a, _b;
70
+ if (emulator) {
71
+ return {
72
+ type: "emulator",
73
+ host: emulator.host,
74
+ port: emulator.port,
75
+ namespace: (_a = emulator.namespace) != null ? _a : "teraprox-default-rtdb"
76
+ };
77
+ }
70
78
  const emulatorHostEnv = typeof process !== "undefined" && process.env.REACT_APP_RTDB_EMULATOR_HOST || void 0;
71
79
  if (emulatorHostEnv) {
72
80
  const [host, portStr] = emulatorHostEnv.split(":");
73
81
  const port = parseInt(portStr != null ? portStr : "9000", 10);
74
- const namespace = (_a = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _a : "demo-local";
82
+ const namespace = (_b = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _b : "demo-local";
75
83
  return { type: "emulator", host, port, namespace };
76
84
  }
77
85
  if (firebaseConfig && Object.keys(firebaseConfig).length > 0) {
@@ -147,7 +155,7 @@ function RtdbConfigWarning({ onDismiss }) {
147
155
  }
148
156
  );
149
157
  }
150
- function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }) {
158
+ function StandaloneProvider({ createController, addToast, firebaseConfig, emulator, tenant, children }) {
151
159
  const [subscriptions] = useState([]);
152
160
  const subscriptionsRef = useRef(subscriptions);
153
161
  subscriptionsRef.current = subscriptions;
@@ -182,7 +190,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
182
190
  let cancelled = false;
183
191
  (async () => {
184
192
  var _a;
185
- const strategy = await resolveRtdbStrategy(firebaseConfig);
193
+ const strategy = await resolveRtdbStrategy(firebaseConfig, emulator);
186
194
  if (cancelled) return;
187
195
  if (strategy.type === "none") {
188
196
  if (process.env.NODE_ENV !== "production") setRtdbWarning(true);
@@ -250,7 +258,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
250
258
  cancelled = true;
251
259
  cleanup == null ? void 0 : cleanup();
252
260
  };
253
- }, [firebaseConfig, tenant]);
261
+ }, [firebaseConfig, emulator, tenant]);
254
262
  const value = useMemo(
255
263
  () => ({
256
264
  createController,
@@ -119,6 +119,11 @@ interface ReducersBundle {
119
119
  }
120
120
  declare function createReducersBundle(config: ReducersBundleConfig): ReducersBundle;
121
121
 
122
+ interface EmulatorConfig {
123
+ host: string;
124
+ port: number;
125
+ namespace?: string;
126
+ }
122
127
  interface StandaloneConfig {
123
128
  /**
124
129
  * Factory for creating an HttpController. The remote provides its
@@ -133,11 +138,20 @@ interface StandaloneConfig {
133
138
  * object listening via Firebase RTDB — same path the Core uses.
134
139
  *
135
140
  * If omitted, the provider auto-detects the RTDB emulator:
136
- * 1. Reads `REACT_APP_RTDB_EMULATOR_HOST` (e.g. `localhost:9000`)
137
- * 2. Falls back to probing `localhost:9000`
138
- * 3. If neither works, shows a configuration popup (dev only)
141
+ * 1. Uses `emulator` prop if provided
142
+ * 2. Reads `REACT_APP_RTDB_EMULATOR_HOST` env var
143
+ * 3. Falls back to probing `localhost:9000`
144
+ * 4. If neither works, shows a configuration popup (dev only)
139
145
  */
140
146
  firebaseConfig?: Record<string, unknown>;
147
+ /**
148
+ * Explicit emulator configuration. Preferred over env vars because
149
+ * DefinePlugin may not replace process.env.REACT_APP_* inside node_modules.
150
+ * The app should read its own env vars and pass them here.
151
+ *
152
+ * Example: `{ host: 'localhost', port: 9000, namespace: 'teraprox-default-rtdb' }`
153
+ */
154
+ emulator?: EmulatorConfig;
141
155
  /**
142
156
  * Tenant / company ID used to build the RTDB path:
143
157
  * `{tenant}/matchingObjects`
@@ -178,7 +192,7 @@ interface StandaloneConfig {
178
192
  * }
179
193
  * ```
180
194
  */
181
- declare function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }: StandaloneConfig): react_jsx_runtime.JSX.Element;
195
+ declare function StandaloneProvider({ createController, addToast, firebaseConfig, emulator, tenant, children }: StandaloneConfig): react_jsx_runtime.JSX.Element;
182
196
 
183
197
  interface DevUser {
184
198
  firstName: string;
@@ -119,6 +119,11 @@ interface ReducersBundle {
119
119
  }
120
120
  declare function createReducersBundle(config: ReducersBundleConfig): ReducersBundle;
121
121
 
122
+ interface EmulatorConfig {
123
+ host: string;
124
+ port: number;
125
+ namespace?: string;
126
+ }
122
127
  interface StandaloneConfig {
123
128
  /**
124
129
  * Factory for creating an HttpController. The remote provides its
@@ -133,11 +138,20 @@ interface StandaloneConfig {
133
138
  * object listening via Firebase RTDB — same path the Core uses.
134
139
  *
135
140
  * If omitted, the provider auto-detects the RTDB emulator:
136
- * 1. Reads `REACT_APP_RTDB_EMULATOR_HOST` (e.g. `localhost:9000`)
137
- * 2. Falls back to probing `localhost:9000`
138
- * 3. If neither works, shows a configuration popup (dev only)
141
+ * 1. Uses `emulator` prop if provided
142
+ * 2. Reads `REACT_APP_RTDB_EMULATOR_HOST` env var
143
+ * 3. Falls back to probing `localhost:9000`
144
+ * 4. If neither works, shows a configuration popup (dev only)
139
145
  */
140
146
  firebaseConfig?: Record<string, unknown>;
147
+ /**
148
+ * Explicit emulator configuration. Preferred over env vars because
149
+ * DefinePlugin may not replace process.env.REACT_APP_* inside node_modules.
150
+ * The app should read its own env vars and pass them here.
151
+ *
152
+ * Example: `{ host: 'localhost', port: 9000, namespace: 'teraprox-default-rtdb' }`
153
+ */
154
+ emulator?: EmulatorConfig;
141
155
  /**
142
156
  * Tenant / company ID used to build the RTDB path:
143
157
  * `{tenant}/matchingObjects`
@@ -178,7 +192,7 @@ interface StandaloneConfig {
178
192
  * }
179
193
  * ```
180
194
  */
181
- declare function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }: StandaloneConfig): react_jsx_runtime.JSX.Element;
195
+ declare function StandaloneProvider({ createController, addToast, firebaseConfig, emulator, tenant, children }: StandaloneConfig): react_jsx_runtime.JSX.Element;
182
196
 
183
197
  interface DevUser {
184
198
  firstName: string;
@@ -1,3 +1,3 @@
1
- export { D as DevAutoLogin, F as FederatedBridge, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, f as createReducersBundle } from './federation-B4ShfmDd.mjs';
1
+ export { D as DevAutoLogin, F as FederatedBridge, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, f as createReducersBundle } from './federation-UNcGnNB-.mjs';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
@@ -1,3 +1,3 @@
1
- export { D as DevAutoLogin, F as FederatedBridge, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, f as createReducersBundle } from './federation-B4ShfmDd.js';
1
+ export { D as DevAutoLogin, F as FederatedBridge, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, f as createReducersBundle } from './federation-UNcGnNB-.js';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
@@ -106,13 +106,21 @@ async function probeEmulator(host, port) {
106
106
  return false;
107
107
  }
108
108
  }
109
- async function resolveRtdbStrategy(firebaseConfig) {
110
- var _a;
109
+ async function resolveRtdbStrategy(firebaseConfig, emulator) {
110
+ var _a, _b;
111
+ if (emulator) {
112
+ return {
113
+ type: "emulator",
114
+ host: emulator.host,
115
+ port: emulator.port,
116
+ namespace: (_a = emulator.namespace) != null ? _a : "teraprox-default-rtdb"
117
+ };
118
+ }
111
119
  const emulatorHostEnv = typeof process !== "undefined" && process.env.REACT_APP_RTDB_EMULATOR_HOST || void 0;
112
120
  if (emulatorHostEnv) {
113
121
  const [host, portStr] = emulatorHostEnv.split(":");
114
122
  const port = parseInt(portStr != null ? portStr : "9000", 10);
115
- const namespace = (_a = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _a : "demo-local";
123
+ const namespace = (_b = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _b : "demo-local";
116
124
  return { type: "emulator", host, port, namespace };
117
125
  }
118
126
  if (firebaseConfig && Object.keys(firebaseConfig).length > 0) {
@@ -188,7 +196,7 @@ function RtdbConfigWarning({ onDismiss }) {
188
196
  }
189
197
  );
190
198
  }
191
- function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }) {
199
+ function StandaloneProvider({ createController, addToast, firebaseConfig, emulator, tenant, children }) {
192
200
  const [subscriptions] = (0, import_react3.useState)([]);
193
201
  const subscriptionsRef = (0, import_react3.useRef)(subscriptions);
194
202
  subscriptionsRef.current = subscriptions;
@@ -223,7 +231,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
223
231
  let cancelled = false;
224
232
  (async () => {
225
233
  var _a;
226
- const strategy = await resolveRtdbStrategy(firebaseConfig);
234
+ const strategy = await resolveRtdbStrategy(firebaseConfig, emulator);
227
235
  if (cancelled) return;
228
236
  if (strategy.type === "none") {
229
237
  if (process.env.NODE_ENV !== "production") setRtdbWarning(true);
@@ -291,7 +299,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
291
299
  cancelled = true;
292
300
  cleanup == null ? void 0 : cleanup();
293
301
  };
294
- }, [firebaseConfig, tenant]);
302
+ }, [firebaseConfig, emulator, tenant]);
295
303
  const value = (0, import_react3.useMemo)(
296
304
  () => ({
297
305
  createController,
@@ -3,7 +3,7 @@ import {
3
3
  FederatedBridge,
4
4
  StandaloneProvider,
5
5
  createReducersBundle
6
- } from "./chunk-PATJPPYP.mjs";
6
+ } from "./chunk-CLNYFYWU.mjs";
7
7
  export {
8
8
  DevAutoLogin,
9
9
  FederatedBridge,
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CoreService, H as HttpController, T as ToastService } from './federation-B4ShfmDd.mjs';
2
- export { D as DevAutoLogin, F as FederatedBridge, M as MatchingObjectSubscription, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, e as ToastOptions, f as createReducersBundle } from './federation-B4ShfmDd.mjs';
1
+ import { C as CoreService, H as HttpController, T as ToastService } from './federation-UNcGnNB-.mjs';
2
+ export { D as DevAutoLogin, F as FederatedBridge, M as MatchingObjectSubscription, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, e as ToastOptions, f as createReducersBundle } from './federation-UNcGnNB-.mjs';
3
3
  import * as React from 'react';
4
4
  import { Dispatch } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CoreService, H as HttpController, T as ToastService } from './federation-B4ShfmDd.js';
2
- export { D as DevAutoLogin, F as FederatedBridge, M as MatchingObjectSubscription, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, e as ToastOptions, f as createReducersBundle } from './federation-B4ShfmDd.js';
1
+ import { C as CoreService, H as HttpController, T as ToastService } from './federation-UNcGnNB-.js';
2
+ export { D as DevAutoLogin, F as FederatedBridge, M as MatchingObjectSubscription, R as ReducersBundle, a as ReducersBundleConfig, b as RemoteManifest, c as RemoteMenuItem, d as RemoteMenuSection, S as StandaloneProvider, e as ToastOptions, f as createReducersBundle } from './federation-UNcGnNB-.js';
3
3
  import * as React from 'react';
4
4
  import { Dispatch } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
package/dist/index.js CHANGED
@@ -1353,13 +1353,21 @@ async function probeEmulator(host, port) {
1353
1353
  return false;
1354
1354
  }
1355
1355
  }
1356
- async function resolveRtdbStrategy(firebaseConfig) {
1357
- var _a;
1356
+ async function resolveRtdbStrategy(firebaseConfig, emulator) {
1357
+ var _a, _b;
1358
+ if (emulator) {
1359
+ return {
1360
+ type: "emulator",
1361
+ host: emulator.host,
1362
+ port: emulator.port,
1363
+ namespace: (_a = emulator.namespace) != null ? _a : "teraprox-default-rtdb"
1364
+ };
1365
+ }
1358
1366
  const emulatorHostEnv = typeof process !== "undefined" && process.env.REACT_APP_RTDB_EMULATOR_HOST || void 0;
1359
1367
  if (emulatorHostEnv) {
1360
1368
  const [host, portStr] = emulatorHostEnv.split(":");
1361
1369
  const port = parseInt(portStr != null ? portStr : "9000", 10);
1362
- const namespace = (_a = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _a : "demo-local";
1370
+ const namespace = (_b = process.env.REACT_APP_RTDB_EMULATOR_NS) != null ? _b : "demo-local";
1363
1371
  return { type: "emulator", host, port, namespace };
1364
1372
  }
1365
1373
  if (firebaseConfig && Object.keys(firebaseConfig).length > 0) {
@@ -1435,7 +1443,7 @@ function RtdbConfigWarning({ onDismiss }) {
1435
1443
  }
1436
1444
  );
1437
1445
  }
1438
- function StandaloneProvider({ createController, addToast, firebaseConfig, tenant, children }) {
1446
+ function StandaloneProvider({ createController, addToast, firebaseConfig, emulator, tenant, children }) {
1439
1447
  const [subscriptions] = (0, import_react19.useState)([]);
1440
1448
  const subscriptionsRef = (0, import_react19.useRef)(subscriptions);
1441
1449
  subscriptionsRef.current = subscriptions;
@@ -1470,7 +1478,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
1470
1478
  let cancelled = false;
1471
1479
  (async () => {
1472
1480
  var _a;
1473
- const strategy = await resolveRtdbStrategy(firebaseConfig);
1481
+ const strategy = await resolveRtdbStrategy(firebaseConfig, emulator);
1474
1482
  if (cancelled) return;
1475
1483
  if (strategy.type === "none") {
1476
1484
  if (process.env.NODE_ENV !== "production") setRtdbWarning(true);
@@ -1538,7 +1546,7 @@ function StandaloneProvider({ createController, addToast, firebaseConfig, tenant
1538
1546
  cancelled = true;
1539
1547
  cleanup == null ? void 0 : cleanup();
1540
1548
  };
1541
- }, [firebaseConfig, tenant]);
1549
+ }, [firebaseConfig, emulator, tenant]);
1542
1550
  const value = (0, import_react19.useMemo)(
1543
1551
  () => ({
1544
1552
  createController,
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  FederatedBridge,
5
5
  StandaloneProvider,
6
6
  createReducersBundle
7
- } from "./chunk-PATJPPYP.mjs";
7
+ } from "./chunk-CLNYFYWU.mjs";
8
8
 
9
9
  // src/hooks/useCoreService.ts
10
10
  import { useContext } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teraprox-core-sdk",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Contrato tipado Core ↔ Federados — interfaces, context, hooks e componentes compartilhados",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -46,7 +46,9 @@
46
46
  "react-router-dom": ">=6.0.0"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
- "firebase": { "optional": true }
49
+ "firebase": {
50
+ "optional": true
51
+ }
50
52
  },
51
53
  "devDependencies": {
52
54
  "@reduxjs/toolkit": "^2.0.0",