@fluid-app/portal-sdk 0.1.450 → 0.1.452

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.
Files changed (49) hide show
  1. package/dist/{FluidProvider-BjSf_FiB.cjs → FluidProvider-BULkBuyn.cjs} +121 -28
  2. package/dist/FluidProvider-BULkBuyn.cjs.map +1 -0
  3. package/dist/{FluidProvider-CXqSq1iX.mjs → FluidProvider-CA_HAl9a.mjs} +116 -29
  4. package/dist/FluidProvider-CA_HAl9a.mjs.map +1 -0
  5. package/dist/{MessagingScreen-Ck5kiA-O.mjs → MessagingScreen-BdsSr7l4.mjs} +2 -2
  6. package/dist/{MessagingScreen-NdUsPc_N.cjs → MessagingScreen-CApfcPd5.cjs} +2 -2
  7. package/dist/{MessagingScreen-NdUsPc_N.cjs.map → MessagingScreen-CApfcPd5.cjs.map} +1 -1
  8. package/dist/{MessagingScreen-CtMw_Wp3.mjs → MessagingScreen-Cf0OOWZ5.mjs} +2 -2
  9. package/dist/{MessagingScreen-CtMw_Wp3.mjs.map → MessagingScreen-Cf0OOWZ5.mjs.map} +1 -1
  10. package/dist/{MessagingScreen-BAl4Hg2w.cjs → MessagingScreen-N3CiZ807.cjs} +2 -2
  11. package/dist/{OrdersScreen-B3sEroyv.mjs → OrdersScreen-BPihQMaX.mjs} +2 -2
  12. package/dist/{OrdersScreen-B3sEroyv.mjs.map → OrdersScreen-BPihQMaX.mjs.map} +1 -1
  13. package/dist/{OrdersScreen-iCm9w3Kz.cjs → OrdersScreen-CgU8hdeD.cjs} +2 -2
  14. package/dist/{OrdersScreen-Dz_rz68P.mjs → OrdersScreen-Cv-qovZG.mjs} +2 -2
  15. package/dist/{OrdersScreen-CNCGv-jL.cjs → OrdersScreen-DEv_TOuP.cjs} +2 -2
  16. package/dist/{OrdersScreen-CNCGv-jL.cjs.map → OrdersScreen-DEv_TOuP.cjs.map} +1 -1
  17. package/dist/{ProfileScreen--xpXB--h.mjs → ProfileScreen-3gbdDTy0.mjs} +3 -3
  18. package/dist/{ProfileScreen-DD8HaCNH.mjs → ProfileScreen-BdzjBeMm.mjs} +4 -4
  19. package/dist/ProfileScreen-BdzjBeMm.mjs.map +1 -0
  20. package/dist/{ProfileScreen-CCVbDYek.cjs → ProfileScreen-Cs3B8vfS.cjs} +4 -4
  21. package/dist/ProfileScreen-Cs3B8vfS.cjs.map +1 -0
  22. package/dist/{ProfileScreen-Ce8jwoAg.cjs → ProfileScreen-cCOWdo-G.cjs} +3 -3
  23. package/dist/{ShopScreen-DsKCSRzS.mjs → ShopScreen-BQu3Hv89.mjs} +2 -2
  24. package/dist/{ShopScreen-DsKCSRzS.mjs.map → ShopScreen-BQu3Hv89.mjs.map} +1 -1
  25. package/dist/{ShopScreen-Cm-B46dF.cjs → ShopScreen-DqdBdkjS.cjs} +2 -2
  26. package/dist/{ShopScreen-Cm-B46dF.cjs.map → ShopScreen-DqdBdkjS.cjs.map} +1 -1
  27. package/dist/{ShopScreen-B9xABYoy.mjs → ShopScreen-eC3clAjp.mjs} +2 -2
  28. package/dist/{ShopScreen-CRVZOMY5.cjs → ShopScreen-lyjY8yxm.cjs} +2 -2
  29. package/dist/{SubscriptionsScreen-D1qYFGmN.cjs → SubscriptionsScreen-CYCQcYMB.cjs} +3 -3
  30. package/dist/{SubscriptionsScreen-C17iAZ_N.mjs → SubscriptionsScreen-Db9gI6D6.mjs} +3 -3
  31. package/dist/{SubscriptionsScreen-DhxSxQ43.cjs → SubscriptionsScreen-aaF2B1qD.cjs} +3 -3
  32. package/dist/{SubscriptionsScreen-DhxSxQ43.cjs.map → SubscriptionsScreen-aaF2B1qD.cjs.map} +1 -1
  33. package/dist/{SubscriptionsScreen-IWNnfQ36.mjs → SubscriptionsScreen-bCXc9Bqn.mjs} +3 -3
  34. package/dist/{SubscriptionsScreen-IWNnfQ36.mjs.map → SubscriptionsScreen-bCXc9Bqn.mjs.map} +1 -1
  35. package/dist/index.cjs +34 -22
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts.map +1 -1
  38. package/dist/index.d.mts.map +1 -1
  39. package/dist/index.mjs +34 -22
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/{use-portal-card-add-3ds-flow-Ch7FwzUp.cjs → use-portal-card-add-3ds-flow-1JkstOR0.cjs} +2 -2
  42. package/dist/{use-portal-card-add-3ds-flow-Ch7FwzUp.cjs.map → use-portal-card-add-3ds-flow-1JkstOR0.cjs.map} +1 -1
  43. package/dist/{use-portal-card-add-3ds-flow-hgln6QRL.mjs → use-portal-card-add-3ds-flow-DueNr2yx.mjs} +2 -2
  44. package/dist/{use-portal-card-add-3ds-flow-hgln6QRL.mjs.map → use-portal-card-add-3ds-flow-DueNr2yx.mjs.map} +1 -1
  45. package/package.json +16 -16
  46. package/dist/FluidProvider-BjSf_FiB.cjs.map +0 -1
  47. package/dist/FluidProvider-CXqSq1iX.mjs.map +0 -1
  48. package/dist/ProfileScreen-CCVbDYek.cjs.map +0 -1
  49. package/dist/ProfileScreen-DD8HaCNH.mjs.map +0 -1
@@ -4523,6 +4523,87 @@ function mapManifestToDefinition(manifest) {
4523
4523
  };
4524
4524
  }
4525
4525
  //#endregion
4526
+ //#region ../core/src/native-capabilities-api.ts
4527
+ /** Safe no-op implementation used when no native shell is present. */
4528
+ const webNativeCapabilitiesApi = {
4529
+ isNativeApp: false,
4530
+ capabilities: [],
4531
+ supports: () => false,
4532
+ haptic: () => {},
4533
+ showActionSheet: () => Promise.resolve(null),
4534
+ showToast: () => {}
4535
+ };
4536
+ //#endregion
4537
+ //#region ../core/src/native-capabilities-api-context.ts
4538
+ const NativeCapabilitiesApiContext = createContext(null);
4539
+ const NativeCapabilitiesApiProvider = NativeCapabilitiesApiContext.Provider;
4540
+ /**
4541
+ * Resolve the effective capabilities api. Unlike most ports, a missing
4542
+ * provider is not an error: the web fallback is returned so portal code runs
4543
+ * unchanged outside the native shell.
4544
+ */
4545
+ function resolveNativeCapabilitiesApi(api) {
4546
+ return api ?? webNativeCapabilitiesApi;
4547
+ }
4548
+ function useNativeCapabilities() {
4549
+ return resolveNativeCapabilitiesApi(use(NativeCapabilitiesApiContext));
4550
+ }
4551
+ //#endregion
4552
+ //#region src/adapters/native-capabilities-api-adapter.ts
4553
+ /** Event emitted by portal-mobile after installing the native bridge runtime. */
4554
+ const PORTAL_NATIVE_BRIDGE_READY_EVENT = "fluid.portal.native:ready";
4555
+ /** Read the native bridge runtime from the current window, if installed. */
4556
+ function getFluidNativeBridge() {
4557
+ if (typeof window === "undefined") return null;
4558
+ return window.__fluidNativeBridge ?? null;
4559
+ }
4560
+ /**
4561
+ * Keep a consumer synchronized with the bridge runtime. The immediate read
4562
+ * covers bridges installed before React mounts; the event covers WebViews
4563
+ * that install injected JavaScript after the portal has started hydrating.
4564
+ */
4565
+ function subscribeToFluidNativeBridge(listener) {
4566
+ if (typeof window === "undefined") return () => {};
4567
+ const syncBridge = () => listener(getFluidNativeBridge());
4568
+ syncBridge();
4569
+ window.addEventListener(PORTAL_NATIVE_BRIDGE_READY_EVENT, syncBridge);
4570
+ return () => {
4571
+ window.removeEventListener(PORTAL_NATIVE_BRIDGE_READY_EVENT, syncBridge);
4572
+ };
4573
+ }
4574
+ /**
4575
+ * Build a {@link NativeCapabilitiesApi} over the injected bridge runtime.
4576
+ * Returns the shared web fallback when no native shell is present, so callers
4577
+ * always receive a working implementation.
4578
+ */
4579
+ function createNativeCapabilitiesAdapter(bridge) {
4580
+ if (!bridge || !bridge.isNativeApp) return webNativeCapabilitiesApi;
4581
+ const capabilities = bridge.capabilities ?? [];
4582
+ const supports = (capability) => capabilities.includes(capability);
4583
+ return {
4584
+ isNativeApp: true,
4585
+ capabilities,
4586
+ supports,
4587
+ haptic: (style = "light") => {
4588
+ if (!supports("haptic")) return;
4589
+ bridge.postRequest("haptic", { style }).catch(() => {});
4590
+ },
4591
+ showToast: (request) => {
4592
+ if (!supports("toast")) return;
4593
+ bridge.postRequest("toast", request).catch(() => {});
4594
+ },
4595
+ showActionSheet: async (request) => {
4596
+ if (!supports("actionSheet")) return null;
4597
+ const result = await bridge.postRequest("actionSheet", request).catch(() => null);
4598
+ if (result && typeof result === "object" && "actionId" in result) {
4599
+ const { actionId } = result;
4600
+ return typeof actionId === "string" ? actionId : null;
4601
+ }
4602
+ return null;
4603
+ }
4604
+ };
4605
+ }
4606
+ //#endregion
4526
4607
  //#region src/adapters/account-api-adapter.ts
4527
4608
  function mapAccount(raw) {
4528
4609
  return {
@@ -7542,6 +7623,9 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
7542
7623
  }), [config.baseUrl, csrfToken]);
7543
7624
  const dataSourceApi = useMemo(() => createDataSourceApiAdapter(portalTenantClient, portalTenantContentClient), [portalTenantClient, portalTenantContentClient]);
7544
7625
  const appDefinitionApi = useMemo(() => createAppDefinitionApiAdapter(portalTenantClient), [portalTenantClient]);
7626
+ const [nativeBridge, setNativeBridge] = useState(getFluidNativeBridge);
7627
+ useEffect(() => subscribeToFluidNativeBridge(setNativeBridge), []);
7628
+ const nativeCapabilitiesApi = useMemo(() => createNativeCapabilitiesAdapter(nativeBridge), [nativeBridge]);
7545
7629
  const accountApi = useMemo(() => createAccountApiAdapter(portalTenantClient), [portalTenantClient]);
7546
7630
  const storeApi = useMemo(() => createStoreApiAdapter(portalTenantClient), [portalTenantClient]);
7547
7631
  const payApi = useMemo(() => createPortalTenantPayAdapter(portalTenantClient), [portalTenantClient]);
@@ -7578,35 +7662,38 @@ function FluidProvider({ config, children, queryClient, initialTheme, themeConta
7578
7662
  ...remoteWidgets?.packages === void 0 ? {} : { packages: remoteWidgets.packages },
7579
7663
  ...remoteWidgets?.functions === void 0 ? {} : { functions: remoteWidgets.functions },
7580
7664
  ...remoteWidgets?.onFullscreen === void 0 ? {} : { onFullscreen: remoteWidgets.onFullscreen },
7581
- children: (remoteWidgetRegistry) => /* @__PURE__ */ jsx(AppDefinitionApiProvider, {
7582
- value: appDefinitionApi,
7583
- children: /* @__PURE__ */ jsx(AccountApiProvider, {
7584
- value: accountApi,
7585
- children: /* @__PURE__ */ jsx(PayApiProvider, {
7586
- value: payApi,
7587
- children: /* @__PURE__ */ jsx(CountriesApiProvider, {
7588
- value: countriesApi,
7589
- children: /* @__PURE__ */ jsx(LanguagesApiProvider, {
7590
- value: languagesApi,
7591
- children: /* @__PURE__ */ jsx(PortalLocaleProvider, { children: /* @__PURE__ */ jsx(MySiteApiProvider, {
7592
- value: mysiteApi,
7593
- children: /* @__PURE__ */ jsx(AddressFieldsApiProvider, {
7594
- value: addressFieldsApi,
7595
- children: /* @__PURE__ */ jsx(AddressAutocompleteApiProvider, {
7596
- value: addressAutocompleteApi,
7597
- children: /* @__PURE__ */ jsx(PortalRuntimeProviderStack, {
7598
- baseUrl: dataSourceBaseUrl,
7599
- getApiHeaders,
7600
- dataSourceApi,
7601
- variables: effectiveVariables,
7602
- registry: remoteWidgetRegistry,
7603
- storeApi,
7604
- themeProviderProps,
7605
- children
7665
+ children: (remoteWidgetRegistry) => /* @__PURE__ */ jsx(NativeCapabilitiesApiProvider, {
7666
+ value: nativeCapabilitiesApi,
7667
+ children: /* @__PURE__ */ jsx(AppDefinitionApiProvider, {
7668
+ value: appDefinitionApi,
7669
+ children: /* @__PURE__ */ jsx(AccountApiProvider, {
7670
+ value: accountApi,
7671
+ children: /* @__PURE__ */ jsx(PayApiProvider, {
7672
+ value: payApi,
7673
+ children: /* @__PURE__ */ jsx(CountriesApiProvider, {
7674
+ value: countriesApi,
7675
+ children: /* @__PURE__ */ jsx(LanguagesApiProvider, {
7676
+ value: languagesApi,
7677
+ children: /* @__PURE__ */ jsx(PortalLocaleProvider, { children: /* @__PURE__ */ jsx(MySiteApiProvider, {
7678
+ value: mysiteApi,
7679
+ children: /* @__PURE__ */ jsx(AddressFieldsApiProvider, {
7680
+ value: addressFieldsApi,
7681
+ children: /* @__PURE__ */ jsx(AddressAutocompleteApiProvider, {
7682
+ value: addressAutocompleteApi,
7683
+ children: /* @__PURE__ */ jsx(PortalRuntimeProviderStack, {
7684
+ baseUrl: dataSourceBaseUrl,
7685
+ getApiHeaders,
7686
+ dataSourceApi,
7687
+ variables: effectiveVariables,
7688
+ registry: remoteWidgetRegistry,
7689
+ storeApi,
7690
+ themeProviderProps,
7691
+ children
7692
+ })
7606
7693
  })
7607
7694
  })
7608
- })
7609
- }) })
7695
+ }) })
7696
+ })
7610
7697
  })
7611
7698
  })
7612
7699
  })
@@ -7698,6 +7785,6 @@ function useFluidContext() {
7698
7785
  return context;
7699
7786
  }
7700
7787
  //#endregion
7701
- export { isApiError as _, messagingDomain as a, useLanguagesApi as b, createSubscriptionsTranslationAdapter as c, ordersDomain as d, useShopTranslation as f, ApiError as g, useThemeContext as h, createMessagingTranslationAdapter as i, subscriptionsDomain as l, FluidThemeProvider as m, useFluidContext as n, createProfileTranslationAdapter as o, shellEn as p, SUPPORTED_LANGUAGES as r, profileDomain as s, FluidProvider as t, createOrdersTranslationAdapter as u, useAddressFieldsApiOptional as v, usePayApi as x, useAddressAutocompleteApi as y };
7788
+ export { usePayApi as S, ApiError as _, messagingDomain as a, useAddressAutocompleteApi as b, createSubscriptionsTranslationAdapter as c, ordersDomain as d, useShopTranslation as f, useNativeCapabilities as g, useThemeContext as h, createMessagingTranslationAdapter as i, subscriptionsDomain as l, FluidThemeProvider as m, useFluidContext as n, createProfileTranslationAdapter as o, shellEn as p, SUPPORTED_LANGUAGES as r, profileDomain as s, FluidProvider as t, createOrdersTranslationAdapter as u, isApiError as v, useLanguagesApi as x, useAddressFieldsApiOptional as y };
7702
7789
 
7703
- //# sourceMappingURL=FluidProvider-CXqSq1iX.mjs.map
7790
+ //# sourceMappingURL=FluidProvider-CA_HAl9a.mjs.map