@qontinui/ui-bridge-native 0.6.15 → 0.6.16
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/README.md +17 -0
- package/dist/control/index.js.map +1 -1
- package/dist/control/index.mjs.map +1 -1
- package/dist/core/index.js +42 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +42 -0
- package/dist/core/index.mjs.map +1 -1
- package/dist/core/registry.d.ts +23 -1
- package/dist/core/registry.d.ts.map +1 -1
- package/dist/core/types.d.ts +66 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +112 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +116 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +112 -2
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/routePattern.d.ts +145 -0
- package/dist/react/routePattern.d.ts.map +1 -0
- package/dist/react/useRouteAwareness.d.ts +106 -0
- package/dist/react/useRouteAwareness.d.ts.map +1 -0
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -311,6 +311,13 @@ function computeVisibility(state, clip) {
|
|
|
311
311
|
const onScreen = spansOverlap(rect.left, rect.right, clip.left, clip.right) && spansOverlap(rect.top, rect.bottom, clip.top, clip.bottom);
|
|
312
312
|
return onScreen ? { visibility: "visible" } : { visibility: "hidden", visibilityReason: "off-screen" };
|
|
313
313
|
}
|
|
314
|
+
function copyRouteInfo(info) {
|
|
315
|
+
const copy = { ...info };
|
|
316
|
+
if (info.params) copy.params = { ...info.params };
|
|
317
|
+
if (info.queryParams) copy.queryParams = { ...info.queryParams };
|
|
318
|
+
if (info.routeStack) copy.routeStack = [...info.routeStack];
|
|
319
|
+
return copy;
|
|
320
|
+
}
|
|
314
321
|
function inferActions(type, scrollAncestorId) {
|
|
315
322
|
const baseActions = scrollAncestorId ? ["focus", "blur", "scrollIntoView"] : ["focus", "blur"];
|
|
316
323
|
switch (type) {
|
|
@@ -375,6 +382,16 @@ var NativeUIBridgeRegistry = class {
|
|
|
375
382
|
* already installs.
|
|
376
383
|
*/
|
|
377
384
|
this.routeProvider = null;
|
|
385
|
+
/**
|
|
386
|
+
* The route TEMPLATE the app last reported through `useRouteAwareness`
|
|
387
|
+
* (via {@link setRouteInfo}), emitted on every snapshot as `page.route`.
|
|
388
|
+
*
|
|
389
|
+
* Deliberately NOT named `routeInfo`: `createSnapshot`'s parameter of that
|
|
390
|
+
* name is the CONCRETE `{currentRoute, segments, activeTab}` read from the
|
|
391
|
+
* route provider. The two must never be confused — the concrete path is
|
|
392
|
+
* user input, and this slot is the router-asserted template.
|
|
393
|
+
*/
|
|
394
|
+
this.reportedRoute = void 0;
|
|
378
395
|
/**
|
|
379
396
|
* Device pixel ratio used to project `state.layout` (logical dp) into the
|
|
380
397
|
* physical-pixel `bbox` emitted on each snapshot element. Defaults to `1`
|
|
@@ -433,6 +450,22 @@ var NativeUIBridgeRegistry = class {
|
|
|
433
450
|
getRouteProvider() {
|
|
434
451
|
return this.routeProvider;
|
|
435
452
|
}
|
|
453
|
+
/**
|
|
454
|
+
* Set the route info emitted as `page.route` on every snapshot — the
|
|
455
|
+
* router-asserted TEMPLATE, normally reported by `useRouteAwareness`.
|
|
456
|
+
* Pass `undefined` to clear it (the hook does so on unmount), after which
|
|
457
|
+
* snapshots omit `page` again.
|
|
458
|
+
*
|
|
459
|
+
* The value is copied, so a later mutation by the caller cannot alter what
|
|
460
|
+
* is stored or what an already-emitted snapshot holds.
|
|
461
|
+
*/
|
|
462
|
+
setRouteInfo(info) {
|
|
463
|
+
this.reportedRoute = info ? copyRouteInfo(info) : void 0;
|
|
464
|
+
}
|
|
465
|
+
/** Read-only accessor for the reported route info, if any (a copy). */
|
|
466
|
+
getRouteInfo() {
|
|
467
|
+
return this.reportedRoute ? copyRouteInfo(this.reportedRoute) : void 0;
|
|
468
|
+
}
|
|
436
469
|
/**
|
|
437
470
|
* Resolve the snapshot's `activeTab`: an explicit `getActiveTab()` on the
|
|
438
471
|
* route provider wins, otherwise derive it from the Expo Router segments the
|
|
@@ -1273,6 +1306,12 @@ var NativeUIBridgeRegistry = class {
|
|
|
1273
1306
|
// hosts that wire no route provider.
|
|
1274
1307
|
...resolvedRoute.currentRoute ? { route: resolvedRoute.currentRoute } : {},
|
|
1275
1308
|
...resolvedRoute.activeTab ? { activeTab: resolvedRoute.activeTab } : {},
|
|
1309
|
+
// The router-asserted route TEMPLATE, spelled as the web SDK's
|
|
1310
|
+
// `snapshot.page.route`. Emitted on the ONE assembly point both route
|
|
1311
|
+
// branches above share (the explicit-`routeInfo` branch the server's
|
|
1312
|
+
// `getSnapshot` override uses, and the provider fallback). Omitted, not
|
|
1313
|
+
// nulled, when unset — the same convention as the aliases above.
|
|
1314
|
+
...this.reportedRoute ? { page: { route: copyRouteInfo(this.reportedRoute) } } : {},
|
|
1276
1315
|
registration: this.getRegistrationCoverage()
|
|
1277
1316
|
};
|
|
1278
1317
|
if (this.appInfo) {
|
|
@@ -1319,6 +1358,9 @@ var NativeUIBridgeRegistry = class {
|
|
|
1319
1358
|
}
|
|
1320
1359
|
}
|
|
1321
1360
|
}
|
|
1361
|
+
if (this.reportedRoute) {
|
|
1362
|
+
snapshot.page = { route: copyRouteInfo(this.reportedRoute) };
|
|
1363
|
+
}
|
|
1322
1364
|
}
|
|
1323
1365
|
return snapshot;
|
|
1324
1366
|
}
|
|
@@ -4311,7 +4353,7 @@ function createServerHandlers(registry, executor, config) {
|
|
|
4311
4353
|
};
|
|
4312
4354
|
if (config?.appInfo) {
|
|
4313
4355
|
response.uiBridge = {
|
|
4314
|
-
version: "0.6.
|
|
4356
|
+
version: "0.6.16",
|
|
4315
4357
|
...config.appInfo,
|
|
4316
4358
|
capabilities: ["elements", "components", "actions", "design"],
|
|
4317
4359
|
elementCount: stats.elements,
|
|
@@ -7873,7 +7915,75 @@ function State(props) {
|
|
|
7873
7915
|
function TransitionTo(props) {
|
|
7874
7916
|
return /* @__PURE__ */ jsx(Fragment, { children: props.children });
|
|
7875
7917
|
}
|
|
7918
|
+
function effectiveInfo(info, unmatched) {
|
|
7919
|
+
return unmatched ? { ...info, pattern: null, params: void 0 } : info;
|
|
7920
|
+
}
|
|
7921
|
+
function useRouteAwareness(info, options = {}) {
|
|
7922
|
+
const bridge = useUIBridgeNativeOptional();
|
|
7923
|
+
const unmatched = options.unmatched === true;
|
|
7924
|
+
const infoRef = useRef(info);
|
|
7925
|
+
infoRef.current = info;
|
|
7926
|
+
const pattern = info.pattern;
|
|
7927
|
+
const patternSource = info.patternSource;
|
|
7928
|
+
const paramsKey = info.params ? JSON.stringify(info.params) : "";
|
|
7929
|
+
const queryParamsKey = info.queryParams ? JSON.stringify(info.queryParams) : "";
|
|
7930
|
+
const routeStackKey = info.routeStack?.join(",");
|
|
7931
|
+
useEffect(() => {
|
|
7932
|
+
if (!bridge) return;
|
|
7933
|
+
const registry = bridge.registry;
|
|
7934
|
+
registry.setRouteInfo(effectiveInfo(infoRef.current, unmatched));
|
|
7935
|
+
return () => {
|
|
7936
|
+
registry.setRouteInfo(void 0);
|
|
7937
|
+
};
|
|
7938
|
+
}, [bridge, unmatched, pattern, patternSource, paramsKey, queryParamsKey, routeStackKey]);
|
|
7939
|
+
}
|
|
7940
|
+
|
|
7941
|
+
// src/react/routePattern.ts
|
|
7942
|
+
function focusedIndex(state, routeCount) {
|
|
7943
|
+
if (state.index !== void 0) return state.index;
|
|
7944
|
+
return typeof state.type === "string" && state.type !== "stack" ? 0 : routeCount - 1;
|
|
7945
|
+
}
|
|
7946
|
+
function isRouteIdentifier(value) {
|
|
7947
|
+
return typeof value === "string" && value.length > 0 && !value.includes("/") && !value.includes("?") && !value.includes("#");
|
|
7948
|
+
}
|
|
7949
|
+
function isExpoRouterUnmatched(segments) {
|
|
7950
|
+
return segments.some((s) => typeof s === "string" && s.startsWith("+"));
|
|
7951
|
+
}
|
|
7952
|
+
function expoRouterPattern(segments) {
|
|
7953
|
+
if (!Array.isArray(segments)) return null;
|
|
7954
|
+
for (const segment of segments) {
|
|
7955
|
+
if (!isRouteIdentifier(segment)) return null;
|
|
7956
|
+
if (segment.startsWith("+")) return null;
|
|
7957
|
+
}
|
|
7958
|
+
return "/" + segments.join("/");
|
|
7959
|
+
}
|
|
7960
|
+
function expoRouterRouteStack(segments) {
|
|
7961
|
+
if (expoRouterPattern(segments) === null) return void 0;
|
|
7962
|
+
const stack = ["/"];
|
|
7963
|
+
for (let depth = 1; depth <= segments.length; depth++) {
|
|
7964
|
+
stack.push("/" + segments.slice(0, depth).join("/"));
|
|
7965
|
+
}
|
|
7966
|
+
return stack;
|
|
7967
|
+
}
|
|
7968
|
+
function reactNavigationPattern(state, options = {}) {
|
|
7969
|
+
const names = [];
|
|
7970
|
+
let level = state ?? void 0;
|
|
7971
|
+
while (level) {
|
|
7972
|
+
const routes = level.routes;
|
|
7973
|
+
if (!Array.isArray(routes) || routes.length === 0) return null;
|
|
7974
|
+
const index = focusedIndex(level, routes.length);
|
|
7975
|
+
if (!Number.isInteger(index) || index < 0 || index >= routes.length) return null;
|
|
7976
|
+
const route = routes[index];
|
|
7977
|
+
if (!route || !isRouteIdentifier(route.name)) return null;
|
|
7978
|
+
names.push(route.name);
|
|
7979
|
+
level = route.state;
|
|
7980
|
+
}
|
|
7981
|
+
if (names.length === 0) return null;
|
|
7982
|
+
const leaf = names[names.length - 1];
|
|
7983
|
+
if (options.notFoundRouteNames?.includes(leaf)) return null;
|
|
7984
|
+
return "/" + names.join("/");
|
|
7985
|
+
}
|
|
7876
7986
|
|
|
7877
|
-
export { State, TransitionTo, UIBridgeNativeProvider, useAutoRegister, useToastRecorder, useUIBridge, useUIBridgeModal, useUIBridgeNative, useUIBridgeNativeOptional, useUIBridgeNativeRequired, useUIBridgeRequired, useUIBridgeToast, useUIComponent, useUIComponentAction, useUIElement, useUIElementWithProps };
|
|
7987
|
+
export { State, TransitionTo, UIBridgeNativeProvider, expoRouterPattern, expoRouterRouteStack, isExpoRouterUnmatched, reactNavigationPattern, useAutoRegister, useRouteAwareness, useToastRecorder, useUIBridge, useUIBridgeModal, useUIBridgeNative, useUIBridgeNativeOptional, useUIBridgeNativeRequired, useUIBridgeRequired, useUIBridgeToast, useUIComponent, useUIComponentAction, useUIElement, useUIElementWithProps };
|
|
7878
7988
|
//# sourceMappingURL=index.mjs.map
|
|
7879
7989
|
//# sourceMappingURL=index.mjs.map
|