@bravostudioai/react 0.1.17 → 0.1.21

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 (99) hide show
  1. package/dist/_virtual/index.js +6 -0
  2. package/dist/_virtual/index.js.map +1 -0
  3. package/dist/_virtual/index2.js +5 -0
  4. package/dist/_virtual/index2.js.map +1 -0
  5. package/dist/_virtual/use-sync-external-store-shim.development.js +5 -0
  6. package/dist/_virtual/use-sync-external-store-shim.development.js.map +1 -0
  7. package/dist/_virtual/use-sync-external-store-shim.production.js +5 -0
  8. package/dist/_virtual/use-sync-external-store-shim.production.js.map +1 -0
  9. package/dist/cli/commands/generate.js +144 -129
  10. package/dist/cli/commands/generate.js.map +1 -1
  11. package/dist/components/DynamicComponent.js.map +1 -1
  12. package/dist/components/EncoreApp.js +42 -39
  13. package/dist/components/EncoreApp.js.map +1 -1
  14. package/dist/components/EncoreErrorBoundary.js.map +1 -1
  15. package/dist/components/EncoreLoadingFallback.js.map +1 -1
  16. package/dist/components.js +343 -336
  17. package/dist/components.js.map +1 -1
  18. package/dist/contexts/EncoreActionContext.js +3 -3
  19. package/dist/contexts/EncoreActionContext.js.map +1 -1
  20. package/dist/contexts/EncoreAppContext.js +2 -2
  21. package/dist/contexts/EncoreAppContext.js.map +1 -1
  22. package/dist/contexts/EncoreBindingContext.js +2 -2
  23. package/dist/contexts/EncoreBindingContext.js.map +1 -1
  24. package/dist/contexts/EncoreComponentIdContext.js +3 -5
  25. package/dist/contexts/EncoreComponentIdContext.js.map +1 -1
  26. package/dist/contexts/EncoreRepeatingContainerContext.js +2 -2
  27. package/dist/contexts/EncoreRepeatingContainerContext.js.map +1 -1
  28. package/dist/contexts/EncoreRouterContext.js +2 -2
  29. package/dist/contexts/EncoreRouterContext.js.map +1 -1
  30. package/dist/hooks/usePusherUpdates.js +1 -1
  31. package/dist/hooks/usePusherUpdates.js.map +1 -1
  32. package/dist/index.js +21 -19
  33. package/dist/index.js.map +1 -1
  34. package/dist/lib/fetcher.js +22 -17
  35. package/dist/lib/fetcher.js.map +1 -1
  36. package/dist/node_modules/dequal/lite/index.js +25 -0
  37. package/dist/node_modules/dequal/lite/index.js.map +1 -0
  38. package/dist/node_modules/swr/dist/_internal/config-context-12s-Dh3trQsc.js +289 -0
  39. package/dist/node_modules/swr/dist/_internal/config-context-12s-Dh3trQsc.js.map +1 -0
  40. package/dist/node_modules/swr/dist/_internal/constants.js +5 -0
  41. package/dist/node_modules/swr/dist/_internal/constants.js.map +1 -0
  42. package/dist/node_modules/swr/dist/_internal/events.js +8 -0
  43. package/dist/node_modules/swr/dist/_internal/events.js.map +1 -0
  44. package/dist/node_modules/swr/dist/_internal/index.js +78 -0
  45. package/dist/node_modules/swr/dist/_internal/index.js.map +1 -0
  46. package/dist/node_modules/swr/dist/index/index.js +216 -0
  47. package/dist/node_modules/swr/dist/index/index.js.map +1 -0
  48. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +59 -0
  49. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
  50. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +47 -0
  51. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +1 -0
  52. package/dist/node_modules/use-sync-external-store/shim/index.js +11 -0
  53. package/dist/node_modules/use-sync-external-store/shim/index.js.map +1 -0
  54. package/dist/src/cli/commands/generate.d.ts.map +1 -1
  55. package/dist/src/components/DynamicComponent.d.ts.map +1 -1
  56. package/dist/src/components/EncoreApp.d.ts.map +1 -1
  57. package/dist/src/components/EncoreErrorBoundary.d.ts.map +1 -1
  58. package/dist/src/components/EncoreLoadingFallback.d.ts.map +1 -1
  59. package/dist/src/components.d.ts.map +1 -1
  60. package/dist/src/contexts/EncoreActionContext.d.ts +1 -2
  61. package/dist/src/contexts/EncoreActionContext.d.ts.map +1 -1
  62. package/dist/src/contexts/EncoreAppContext.d.ts +1 -2
  63. package/dist/src/contexts/EncoreAppContext.d.ts.map +1 -1
  64. package/dist/src/contexts/EncoreBindingContext.d.ts +1 -2
  65. package/dist/src/contexts/EncoreBindingContext.d.ts.map +1 -1
  66. package/dist/src/contexts/EncoreComponentIdContext.d.ts +1 -2
  67. package/dist/src/contexts/EncoreComponentIdContext.d.ts.map +1 -1
  68. package/dist/src/contexts/EncoreRepeatingContainerContext.d.ts +1 -2
  69. package/dist/src/contexts/EncoreRepeatingContainerContext.d.ts.map +1 -1
  70. package/dist/src/contexts/EncoreRouterContext.d.ts +1 -2
  71. package/dist/src/contexts/EncoreRouterContext.d.ts.map +1 -1
  72. package/dist/src/hooks/useAuthRedirect.d.ts.map +1 -1
  73. package/dist/src/hooks/usePusherUpdates.d.ts.map +1 -1
  74. package/dist/src/index.d.ts +2 -1
  75. package/dist/src/index.d.ts.map +1 -1
  76. package/dist/src/lib/fetcher.d.ts.map +1 -1
  77. package/dist/src/stores/useEncoreState.d.ts.map +1 -1
  78. package/dist/src/version.d.ts +2 -0
  79. package/dist/src/version.d.ts.map +1 -0
  80. package/dist/stores/useEncoreState.js.map +1 -1
  81. package/dist/version.js +5 -0
  82. package/dist/version.js.map +1 -0
  83. package/package.json +3 -2
  84. package/src/components/DynamicComponent.tsx +1 -0
  85. package/src/components/EncoreApp.tsx +3 -1
  86. package/src/components/EncoreErrorBoundary.tsx +36 -35
  87. package/src/components/EncoreLoadingFallback.tsx +19 -18
  88. package/src/components.tsx +35 -34
  89. package/src/contexts/EncoreActionContext.ts +4 -2
  90. package/src/contexts/EncoreAppContext.ts +4 -2
  91. package/src/contexts/EncoreBindingContext.ts +4 -2
  92. package/src/contexts/EncoreComponentIdContext.ts +4 -4
  93. package/src/contexts/EncoreRepeatingContainerContext.ts +4 -3
  94. package/src/contexts/EncoreRouterContext.ts +4 -2
  95. package/src/hooks/useAuthRedirect.ts +2 -0
  96. package/src/hooks/usePusherUpdates.ts +2 -0
  97. package/src/index.ts +2 -0
  98. package/src/stores/useEncoreState.ts +2 -0
  99. package/src/version.ts +1 -0
@@ -1,6 +1,6 @@
1
- import t from "react";
2
- const o = t.createContext({});
1
+ import { createContext as t } from "react";
2
+ const e = t({});
3
3
  export {
4
- o as default
4
+ e as default
5
5
  };
6
6
  //# sourceMappingURL=EncoreActionContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EncoreActionContext.js","sources":["../../src/contexts/EncoreActionContext.ts"],"sourcesContent":["import React from \"react\";\n\nexport type EncoreActionPayload = {\n bravo: {\n cancel: () => void;\n action: any;\n componentId?: string; // ID of the component that triggered the action\n };\n};\n\ntype EncoreActionContextType = {\n onAction?: (payload: EncoreActionPayload) => void | Promise<void>;\n};\n\nconst EncoreActionContext = React.createContext<EncoreActionContextType>({});\n\nexport default EncoreActionContext;\n"],"names":["EncoreActionContext","React"],"mappings":";AAcA,MAAMA,IAAsBC,EAAM,cAAuC,CAAA,CAAE;"}
1
+ {"version":3,"file":"EncoreActionContext.js","sources":["../../src/contexts/EncoreActionContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\nexport type EncoreActionPayload = {\n bravo: {\n cancel: () => void;\n action: any;\n componentId?: string; // ID of the component that triggered the action\n };\n};\n\ntype EncoreActionContextType = {\n onAction?: (payload: EncoreActionPayload) => void | Promise<void>;\n};\n\nconst EncoreActionContext = createContext<EncoreActionContextType>({});\n\nexport default EncoreActionContext;\n"],"names":["EncoreActionContext","createContext"],"mappings":";AAgBA,MAAMA,IAAsBC,EAAuC,CAAA,CAAE;"}
@@ -1,5 +1,5 @@
1
- import t from "react";
2
- const o = t.createContext({
1
+ import { createContext as t } from "react";
2
+ const o = t({
3
3
  app: null,
4
4
  baseURL: ""
5
5
  });
@@ -1 +1 @@
1
- {"version":3,"file":"EncoreAppContext.js","sources":["../../src/contexts/EncoreAppContext.ts"],"sourcesContent":["import React from \"react\";\n\ntype EncoreAppContext = {\n app: any;\n baseURL: string;\n};\n\nconst EncoreAppContext = React.createContext<EncoreAppContext>({\n app: null,\n baseURL: \"\",\n});\n\nexport default EncoreAppContext;\n"],"names":["EncoreAppContext","React"],"mappings":";AAOA,MAAMA,IAAmBC,EAAM,cAAgC;AAAA,EAC7D,KAAK;AAAA,EACL,SAAS;AACX,CAAC;"}
1
+ {"version":3,"file":"EncoreAppContext.js","sources":["../../src/contexts/EncoreAppContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\ntype EncoreAppContext = {\n app: any;\n baseURL: string;\n};\n\nconst EncoreAppContext = createContext<EncoreAppContext>({\n app: null,\n baseURL: \"\",\n});\n\nexport default EncoreAppContext;\n"],"names":["EncoreAppContext","createContext"],"mappings":";AASA,MAAMA,IAAmBC,EAAgC;AAAA,EACvD,KAAK;AAAA,EACL,SAAS;AACX,CAAC;"}
@@ -1,5 +1,5 @@
1
- import t from "react";
2
- const o = t.createContext({});
1
+ import { createContext as t } from "react";
2
+ const o = t({});
3
3
  export {
4
4
  o as default
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"EncoreBindingContext.js","sources":["../../src/contexts/EncoreBindingContext.ts"],"sourcesContent":["import React from \"react\";\n\ntype EncoreBindingContext = {};\nconst EncoreBindingContext = React.createContext({});\n\nexport default EncoreBindingContext;\n"],"names":["EncoreBindingContext","React"],"mappings":";AAGA,MAAMA,IAAuBC,EAAM,cAAc,CAAA,CAAE;"}
1
+ {"version":3,"file":"EncoreBindingContext.js","sources":["../../src/contexts/EncoreBindingContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\ntype EncoreBindingContext = {};\nconst EncoreBindingContext = createContext({});\n\nexport default EncoreBindingContext;\n"],"names":["EncoreBindingContext","createContext"],"mappings":";AAKA,MAAMA,IAAuBC,EAAc,CAAA,CAAE;"}
@@ -1,8 +1,6 @@
1
- import t from "react";
2
- const o = t.createContext(
3
- {}
4
- );
1
+ import { createContext as t } from "react";
2
+ const e = t({});
5
3
  export {
6
- o as default
4
+ e as default
7
5
  };
8
6
  //# sourceMappingURL=EncoreComponentIdContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EncoreComponentIdContext.js","sources":["../../src/contexts/EncoreComponentIdContext.ts"],"sourcesContent":["import React from \"react\";\n\ntype EncoreComponentIdContext = {\n componentId?: string;\n statefulSetId?: string; // ID of the parent StatefulSetComponent\n};\n\nconst EncoreComponentIdContext = React.createContext<EncoreComponentIdContext>(\n {}\n);\n\nexport default EncoreComponentIdContext;\n"],"names":["EncoreComponentIdContext","React"],"mappings":";AAOA,MAAMA,IAA2BC,EAAM;AAAA,EACrC,CAAA;AACF;"}
1
+ {"version":3,"file":"EncoreComponentIdContext.js","sources":["../../src/contexts/EncoreComponentIdContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\ntype EncoreComponentIdContext = {\n componentId?: string;\n statefulSetId?: string; // ID of the parent StatefulSetComponent\n};\n\nconst EncoreComponentIdContext = createContext<EncoreComponentIdContext>({});\n\nexport default EncoreComponentIdContext;\n"],"names":["EncoreComponentIdContext","createContext"],"mappings":";AASA,MAAMA,IAA2BC,EAAwC,CAAA,CAAE;"}
@@ -1,5 +1,5 @@
1
- import t from "react";
2
- const n = t.createContext(null);
1
+ import { createContext as t } from "react";
2
+ const n = t(null);
3
3
  export {
4
4
  n as default
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"EncoreRepeatingContainerContext.js","sources":["../../src/contexts/EncoreRepeatingContainerContext.ts"],"sourcesContent":["import React from \"react\";\n\nexport type RepeatingContainerControl = {\n currentIndex?: number;\n onIndexChange?: (index: number, containerId: string) => void;\n goToIndex: (index: number) => void;\n getCurrentIndex: () => number;\n};\n\ntype ControlProps = {\n currentIndex?: number;\n onIndexChange?: (index: number) => void;\n};\n\ntype EncoreRepeatingContainerContextValue = {\n registerContainer: (id: string, control: RepeatingContainerControl) => void;\n unregisterContainer: (id: string) => void;\n getControl: (id: string) => RepeatingContainerControl | undefined;\n setControlProps: (\n id: string,\n props: ControlProps | ((prev: ControlProps) => ControlProps)\n ) => void;\n getControlProps: (id: string) => ControlProps | undefined;\n};\n\nconst EncoreRepeatingContainerContext =\n React.createContext<EncoreRepeatingContainerContextValue | null>(null);\n\nexport default EncoreRepeatingContainerContext;\n\n"],"names":["EncoreRepeatingContainerContext","React"],"mappings":";AAyBA,MAAMA,IACJC,EAAM,cAA2D,IAAI;"}
1
+ {"version":3,"file":"EncoreRepeatingContainerContext.js","sources":["../../src/contexts/EncoreRepeatingContainerContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\nexport type RepeatingContainerControl = {\n currentIndex?: number;\n onIndexChange?: (index: number, containerId: string) => void;\n goToIndex: (index: number) => void;\n getCurrentIndex: () => number;\n};\n\ntype ControlProps = {\n currentIndex?: number;\n onIndexChange?: (index: number) => void;\n};\n\ntype EncoreRepeatingContainerContextValue = {\n registerContainer: (id: string, control: RepeatingContainerControl) => void;\n unregisterContainer: (id: string) => void;\n getControl: (id: string) => RepeatingContainerControl | undefined;\n setControlProps: (\n id: string,\n props: ControlProps | ((prev: ControlProps) => ControlProps)\n ) => void;\n getControlProps: (id: string) => ControlProps | undefined;\n};\n\nconst EncoreRepeatingContainerContext =\n createContext<EncoreRepeatingContainerContextValue | null>(null);\n\nexport default EncoreRepeatingContainerContext;\n"],"names":["EncoreRepeatingContainerContext","createContext"],"mappings":";AA2BA,MAAMA,IACJC,EAA2D,IAAI;"}
@@ -1,11 +1,11 @@
1
- import o, { useContext as n } from "react";
1
+ import { createContext as o, useContext as n } from "react";
2
2
  const t = {
3
3
  navigate: (e) => {
4
4
  typeof window < "u" && (window.location.href = e);
5
5
  },
6
6
  pathname: typeof window < "u" ? window.location.pathname : "",
7
7
  searchParams: typeof window < "u" ? new URLSearchParams(window.location.search) : new URLSearchParams()
8
- }, a = o.createContext(t), i = () => n(a);
8
+ }, a = o(t), i = () => n(a);
9
9
  export {
10
10
  a as default,
11
11
  i as useEncoreRouter
@@ -1 +1 @@
1
- {"version":3,"file":"EncoreRouterContext.js","sources":["../../src/contexts/EncoreRouterContext.ts"],"sourcesContent":["import React, { useContext } from \"react\";\n\nexport type EncoreRouterContextType = {\n navigate: (path: string) => void;\n pathname: string;\n searchParams: URLSearchParams;\n};\n\n// Default implementation using window for basic fallback\nconst defaultRouter: EncoreRouterContextType = {\n navigate: (path: string) => {\n if (typeof window !== \"undefined\") {\n window.location.href = path;\n }\n },\n pathname: typeof window !== \"undefined\" ? window.location.pathname : \"\",\n searchParams:\n typeof window !== \"undefined\"\n ? new URLSearchParams(window.location.search)\n : new URLSearchParams(),\n};\n\nconst EncoreRouterContext =\n React.createContext<EncoreRouterContextType>(defaultRouter);\n\nexport const useEncoreRouter = () => useContext(EncoreRouterContext);\n\nexport default EncoreRouterContext;\n"],"names":["defaultRouter","path","EncoreRouterContext","React","useEncoreRouter","useContext"],"mappings":";AASA,MAAMA,IAAyC;AAAA,EAC7C,UAAU,CAACC,MAAiB;AAC1B,IAAI,OAAO,SAAW,QACpB,OAAO,SAAS,OAAOA;AAAA,EAE3B;AAAA,EACA,UAAU,OAAO,SAAW,MAAc,OAAO,SAAS,WAAW;AAAA,EACrE,cACE,OAAO,SAAW,MACd,IAAI,gBAAgB,OAAO,SAAS,MAAM,IAC1C,IAAI,gBAAA;AACZ,GAEMC,IACJC,EAAM,cAAuCH,CAAa,GAE/CI,IAAkB,MAAMC,EAAWH,CAAmB;"}
1
+ {"version":3,"file":"EncoreRouterContext.js","sources":["../../src/contexts/EncoreRouterContext.ts"],"sourcesContent":["\"use client\";\n\nimport { useContext, createContext } from \"react\";\n\nexport type EncoreRouterContextType = {\n navigate: (path: string) => void;\n pathname: string;\n searchParams: URLSearchParams;\n};\n\n// Default implementation using window for basic fallback\nconst defaultRouter: EncoreRouterContextType = {\n navigate: (path: string) => {\n if (typeof window !== \"undefined\") {\n window.location.href = path;\n }\n },\n pathname: typeof window !== \"undefined\" ? window.location.pathname : \"\",\n searchParams:\n typeof window !== \"undefined\"\n ? new URLSearchParams(window.location.search)\n : new URLSearchParams(),\n};\n\nconst EncoreRouterContext =\n createContext<EncoreRouterContextType>(defaultRouter);\n\nexport const useEncoreRouter = () => useContext(EncoreRouterContext);\n\nexport default EncoreRouterContext;\n"],"names":["defaultRouter","path","EncoreRouterContext","createContext","useEncoreRouter","useContext"],"mappings":";AAWA,MAAMA,IAAyC;AAAA,EAC7C,UAAU,CAACC,MAAiB;AAC1B,IAAI,OAAO,SAAW,QACpB,OAAO,SAAS,OAAOA;AAAA,EAE3B;AAAA,EACA,UAAU,OAAO,SAAW,MAAc,OAAO,SAAS,WAAW;AAAA,EACrE,cACE,OAAO,SAAW,MACd,IAAI,gBAAgB,OAAO,SAAS,MAAM,IAC1C,IAAI,gBAAA;AACZ,GAEMC,IACJC,EAAuCH,CAAa,GAEzCI,IAAkB,MAAMC,EAAWH,CAAmB;"}
@@ -1,7 +1,7 @@
1
1
  import { useRef as m, useEffect as g } from "react";
2
2
  import P from "pusher-js";
3
- import { mutate as t } from "swr";
4
3
  import { clearModuleCache as v } from "../lib/moduleRegistry.js";
4
+ import { j as t } from "../node_modules/swr/dist/_internal/config-context-12s-Dh3trQsc.js";
5
5
  const y = () => ({
6
6
  key: "7b0611d0051677eed996",
7
7
  cluster: "us2",
@@ -1 +1 @@
1
- {"version":3,"file":"usePusherUpdates.js","sources":["../../src/hooks/usePusherUpdates.ts"],"sourcesContent":["import { useEffect, useRef } from \"react\";\nimport Pusher from \"pusher-js\";\nimport { mutate } from \"swr\";\nimport { clearModuleCache } from \"../lib/moduleRegistry\";\n\ntype PusherConfig = {\n key?: string;\n cluster?: string;\n encrypted?: boolean;\n};\n\ntype UsePusherUpdatesOptions = {\n appId: string;\n pageId?: string;\n enabled?: boolean;\n onUpdate?: () => void;\n};\n\n// Get Pusher config from environment variables\nconst getPusherConfig = (): PusherConfig => {\n return {\n key: \"7b0611d0051677eed996\",\n cluster: \"us2\",\n encrypted: true,\n };\n};\n\n/**\n * Hook to listen for EncoreApp component updates via Pusher\n * Channel name format: `${appId}-${pageId}`\n * When an update event is received, it invalidates SWR cache and triggers a reload\n */\nexport function usePusherUpdates({\n appId,\n pageId,\n enabled = true,\n onUpdate,\n}: UsePusherUpdatesOptions) {\n const pusherRef = useRef<Pusher | null>(null);\n const channelRef = useRef<ReturnType<Pusher[\"subscribe\"]> | null>(null);\n\n useEffect(() => {\n // Only connect if enabled and we have both appId and pageId\n if (!enabled || !appId || !pageId) {\n return;\n }\n\n const config = getPusherConfig();\n\n // Skip if Pusher key is not configured\n if (!config.key) {\n console.warn(\"[Pusher] not configured. Pusher updates disabled.\");\n return;\n }\n\n // Initialize Pusher\n const pusher = new Pusher(config.key, {\n cluster: config.cluster || \"us2\",\n forceTLS: config.encrypted,\n });\n\n pusherRef.current = pusher;\n\n // Channel name format: appId-pageId (e.g., \"01KA23JMNBQ2V9NR7K0VXKT5TF-01KA23JMPBZSG2YRJ6M5X87SKJ\")\n const channelName = `${appId}`;\n console.log(`[Pusher] Subscribing to channel: ${channelName}`);\n\n // Subscribe to the channel\n const channel = pusher.subscribe(channelName);\n channelRef.current = channel;\n\n // Handle subscription success\n channel.bind(\"pusher:subscription_succeeded\", () => {\n console.log(\n `[Pusher] Successfully subscribed to channel: ${channelName}`\n );\n });\n\n // Handle subscription error\n channel.bind(\"pusher:subscription_error\", (status: number) => {\n console.error(\n `[Pusher] Subscription error for channel ${channelName}:`,\n status\n );\n });\n\n // Listen for update events\n // You can customize the event name based on your backend's Pusher event names\n // Common event names: 'update', 'component-updated', 'app-updated', etc.\n const handleUpdate = (data: unknown) => {\n console.log(`[Pusher] Update received for ${channelName}:`, data);\n\n // Clear the module cache for the component to force reload\n const componentName = `${appId}/draft/components/${pageId}`;\n clearModuleCache(componentName);\n\n // Invalidate SWR cache for both app and page data\n const appUrl = `/devices/apps/${appId}`;\n const pageUrl = `/devices/apps/${appId}/node/${pageId}`;\n\n // Mutate both URLs to trigger refetch\n mutate(appUrl).catch((err) => {\n console.error(\"[Pusher] Error invalidating app cache:\", err);\n });\n mutate(pageUrl).catch((err) => {\n console.error(\"[Pusher] Error invalidating page cache:\", err);\n });\n\n // Also invalidate URLs with useLocal query param if they exist\n mutate(`${appUrl}?useLocal=1`).catch(() => {\n // Ignore errors for optional URLs\n });\n mutate(`${pageUrl}?useLocal=1`).catch(() => {\n // Ignore errors for optional URLs\n });\n\n // Call the onUpdate callback if provided\n onUpdate?.();\n };\n\n // Bind to update events\n // Adjust the event name(s) based on what your backend sends\n channel.bind(\"update\", handleUpdate);\n channel.bind(\"component-updated\", handleUpdate);\n channel.bind(\"app-updated\", handleUpdate);\n\n // Cleanup function\n return () => {\n console.log(`[Pusher] Unsubscribing from channel: ${channelName}`);\n\n // Unbind all event handlers\n if (channelRef.current) {\n channelRef.current.unbind_all();\n }\n\n // Unsubscribe from channel\n if (channelRef.current && pusherRef.current) {\n pusherRef.current.unsubscribe(channelName);\n }\n\n // Disconnect Pusher if no other channels are subscribed\n if (pusherRef.current) {\n pusherRef.current.disconnect();\n pusherRef.current = null;\n }\n\n channelRef.current = null;\n };\n }, [appId, pageId, enabled, onUpdate]);\n\n // Return channel ref for advanced usage\n return {\n channel: channelRef.current,\n pusher: pusherRef.current,\n };\n}\n"],"names":["getPusherConfig","usePusherUpdates","appId","pageId","enabled","onUpdate","pusherRef","useRef","channelRef","useEffect","config","pusher","Pusher","channelName","channel","status","handleUpdate","data","componentName","clearModuleCache","appUrl","pageUrl","mutate","err"],"mappings":";;;;AAmBA,MAAMA,IAAkB,OACf;AAAA,EACL,KAAK;AAAA,EACL,SAAS;AAAA,EACT,WAAW;AAAA;AASR,SAASC,EAAiB;AAAA,EAC/B,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,UAAAC;AACF,GAA4B;AAC1B,QAAMC,IAAYC,EAAsB,IAAI,GACtCC,IAAaD,EAA+C,IAAI;AAEtE,SAAAE,EAAU,MAAM;AAEd,QAAI,CAACL,KAAW,CAACF,KAAS,CAACC;AACzB;AAGF,UAAMO,IAASV,EAAA,GASTW,IA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AGjC,MAAM;AACX,cAAQ,IAAI,wCAAwCH,CAAW,EAAE,GAG7DL,EAAW,WACbA,EAAW,QAAQ,WAAA,GAIjBA,EAAW,WAAWF,EAAU,WAClCA,EAAU,QAAQ,YAAYO,CAAW,GAIvCP,EAAU,YACZA,EAAU,QAAQ,WAAA,GAClBA,EAAU,UAAU,OAGtBE,EAAW,UAAU;AAAA,IACvB;AAAA,EACF,GAAG,CAACN,GAAOC,GAAQC,GAASC,CAAQ,CAAC,GAG9B;AAAA,IACL,SAASG,EAAW;AAAA,IACpB,QAAQF,EAAU;AAAA,EAAA;AAEtB;"}
1
+ {"version":3,"file":"usePusherUpdates.js","sources":["../../src/hooks/usePusherUpdates.ts"],"sourcesContent":["\"use client\";\nimport { useEffect, useRef } from \"react\";\n\nimport Pusher from \"pusher-js\";\nimport { mutate } from \"swr\";\nimport { clearModuleCache } from \"../lib/moduleRegistry\";\n\ntype PusherConfig = {\n key?: string;\n cluster?: string;\n encrypted?: boolean;\n};\n\ntype UsePusherUpdatesOptions = {\n appId: string;\n pageId?: string;\n enabled?: boolean;\n onUpdate?: () => void;\n};\n\n// Get Pusher config from environment variables\nconst getPusherConfig = (): PusherConfig => {\n return {\n key: \"7b0611d0051677eed996\",\n cluster: \"us2\",\n encrypted: true,\n };\n};\n\n/**\n * Hook to listen for EncoreApp component updates via Pusher\n * Channel name format: `${appId}-${pageId}`\n * When an update event is received, it invalidates SWR cache and triggers a reload\n */\nexport function usePusherUpdates({\n appId,\n pageId,\n enabled = true,\n onUpdate,\n}: UsePusherUpdatesOptions) {\n const pusherRef = useRef<Pusher | null>(null);\n const channelRef = useRef<ReturnType<Pusher[\"subscribe\"]> | null>(null);\n\n useEffect(() => {\n // Only connect if enabled and we have both appId and pageId\n if (!enabled || !appId || !pageId) {\n return;\n }\n\n const config = getPusherConfig();\n\n // Skip if Pusher key is not configured\n if (!config.key) {\n console.warn(\"[Pusher] not configured. Pusher updates disabled.\");\n return;\n }\n\n // Initialize Pusher\n const pusher = new Pusher(config.key, {\n cluster: config.cluster || \"us2\",\n forceTLS: config.encrypted,\n });\n\n pusherRef.current = pusher;\n\n // Channel name format: appId-pageId (e.g., \"01KA23JMNBQ2V9NR7K0VXKT5TF-01KA23JMPBZSG2YRJ6M5X87SKJ\")\n const channelName = `${appId}`;\n console.log(`[Pusher] Subscribing to channel: ${channelName}`);\n\n // Subscribe to the channel\n const channel = pusher.subscribe(channelName);\n channelRef.current = channel;\n\n // Handle subscription success\n channel.bind(\"pusher:subscription_succeeded\", () => {\n console.log(\n `[Pusher] Successfully subscribed to channel: ${channelName}`\n );\n });\n\n // Handle subscription error\n channel.bind(\"pusher:subscription_error\", (status: number) => {\n console.error(\n `[Pusher] Subscription error for channel ${channelName}:`,\n status\n );\n });\n\n // Listen for update events\n // You can customize the event name based on your backend's Pusher event names\n // Common event names: 'update', 'component-updated', 'app-updated', etc.\n const handleUpdate = (data: unknown) => {\n console.log(`[Pusher] Update received for ${channelName}:`, data);\n\n // Clear the module cache for the component to force reload\n const componentName = `${appId}/draft/components/${pageId}`;\n clearModuleCache(componentName);\n\n // Invalidate SWR cache for both app and page data\n const appUrl = `/devices/apps/${appId}`;\n const pageUrl = `/devices/apps/${appId}/node/${pageId}`;\n\n // Mutate both URLs to trigger refetch\n mutate(appUrl).catch((err) => {\n console.error(\"[Pusher] Error invalidating app cache:\", err);\n });\n mutate(pageUrl).catch((err) => {\n console.error(\"[Pusher] Error invalidating page cache:\", err);\n });\n\n // Also invalidate URLs with useLocal query param if they exist\n mutate(`${appUrl}?useLocal=1`).catch(() => {\n // Ignore errors for optional URLs\n });\n mutate(`${pageUrl}?useLocal=1`).catch(() => {\n // Ignore errors for optional URLs\n });\n\n // Call the onUpdate callback if provided\n onUpdate?.();\n };\n\n // Bind to update events\n // Adjust the event name(s) based on what your backend sends\n channel.bind(\"update\", handleUpdate);\n channel.bind(\"component-updated\", handleUpdate);\n channel.bind(\"app-updated\", handleUpdate);\n\n // Cleanup function\n return () => {\n console.log(`[Pusher] Unsubscribing from channel: ${channelName}`);\n\n // Unbind all event handlers\n if (channelRef.current) {\n channelRef.current.unbind_all();\n }\n\n // Unsubscribe from channel\n if (channelRef.current && pusherRef.current) {\n pusherRef.current.unsubscribe(channelName);\n }\n\n // Disconnect Pusher if no other channels are subscribed\n if (pusherRef.current) {\n pusherRef.current.disconnect();\n pusherRef.current = null;\n }\n\n channelRef.current = null;\n };\n }, [appId, pageId, enabled, onUpdate]);\n\n // Return channel ref for advanced usage\n return {\n channel: channelRef.current,\n pusher: pusherRef.current,\n };\n}\n"],"names":["getPusherConfig","usePusherUpdates","appId","pageId","enabled","onUpdate","pusherRef","useRef","channelRef","useEffect","config","pusher","Pusher","channelName","channel","status","handleUpdate","data","componentName","clearModuleCache","appUrl","pageUrl","mutate","err"],"mappings":";;;;AAqBA,MAAMA,IAAkB,OACf;AAAA,EACL,KAAK;AAAA,EACL,SAAS;AAAA,EACT,WAAW;AAAA;AASR,SAASC,EAAiB;AAAA,EAC/B,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,UAAAC;AACF,GAA4B;AAC1B,QAAMC,IAAYC,EAAsB,IAAI,GACtCC,IAAaD,EAA+C,IAAI;AAEtE,SAAAE,EAAU,MAAM;AAEd,QAAI,CAACL,KAAW,CAACF,KAAS,CAACC;AACzB;AAGF,UAAMO,IAASV,EAAA,GASTW,IAAS,IAAIC,EAAOF,EAAO,KAAK;AAAA,MACpC,SAASA,EAAO;AAAA,MAChB,UAAUA,EAAO;AAAA,IAAA,CAClB;AAED,IAAAJ,EAAU,UAAUK;AAGpB,UAAME,IAAc,GAAGX,CAAK;AAC5B,YAAQ,IAAI,oCAAoCW,CAAW,EAAE;AAG7D,UAAMC,IAAUH,EAAO,UAAUE,CAAW;AAC5C,IAAAL,EAAW,UAAUM,GAGrBA,EAAQ,KAAK,iCAAiC,MAAM;AAClD,cAAQ;AAAA,QACN,gDAAgDD,CAAW;AAAA,MAAA;AAAA,IAE/D,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AAEtB;"}
package/dist/index.js CHANGED
@@ -1,34 +1,36 @@
1
1
  import { default as n } from "./components/EncoreApp.js";
2
2
  import { default as a } from "./components/EncoreErrorBoundary.js";
3
3
  import { default as d } from "./components/EncoreLoadingFallback.js";
4
- import { default as p } from "./contexts/EncoreAppContext.js";
4
+ import { default as i } from "./contexts/EncoreAppContext.js";
5
5
  import { default as m } from "./contexts/EncoreBindingContext.js";
6
6
  import { default as l } from "./stores/useEncoreState.js";
7
- import { arraysEqual as g, findActionButtons as c, findForms as x, findInputGroups as E, findMinimalDistinguishingPath as C, findSlidersAndDataBindings as P, findStandaloneComponents as S, findStandaloneSelectInputs as y, generateQualifiedPropName as A, getComponentPropName as B, getComponentPropType as F, qualifyFormInputs as I, sanitizePropName as L } from "./codegen/parser.js";
8
- import { generateComponentCode as b, generateComponentMetadata as h, generateReadme as q } from "./codegen/generator.js";
7
+ import { PACKAGE_VERSION as g } from "./version.js";
8
+ import { arraysEqual as x, findActionButtons as E, findForms as C, findInputGroups as A, findMinimalDistinguishingPath as P, findSlidersAndDataBindings as S, findStandaloneComponents as y, findStandaloneSelectInputs as B, generateQualifiedPropName as I, getComponentPropName as N, getComponentPropType as F, qualifyFormInputs as L, sanitizePropName as b } from "./codegen/parser.js";
9
+ import { generateComponentCode as q, generateComponentMetadata as D, generateReadme as G } from "./codegen/generator.js";
9
10
  console.log("Encore Lib Loaded");
10
11
  export {
11
12
  n as EncoreApp,
12
- p as EncoreAppContext,
13
+ i as EncoreAppContext,
13
14
  m as EncoreBindingContext,
14
15
  a as EncoreErrorBoundary,
15
16
  d as EncoreLoadingFallback,
16
- g as arraysEqual,
17
- c as findActionButtons,
18
- x as findForms,
19
- E as findInputGroups,
20
- C as findMinimalDistinguishingPath,
21
- P as findSlidersAndDataBindings,
22
- S as findStandaloneComponents,
23
- y as findStandaloneSelectInputs,
24
- b as generateComponentCode,
25
- h as generateComponentMetadata,
26
- A as generateQualifiedPropName,
27
- q as generateReadme,
28
- B as getComponentPropName,
17
+ g as PACKAGE_VERSION,
18
+ x as arraysEqual,
19
+ E as findActionButtons,
20
+ C as findForms,
21
+ A as findInputGroups,
22
+ P as findMinimalDistinguishingPath,
23
+ S as findSlidersAndDataBindings,
24
+ y as findStandaloneComponents,
25
+ B as findStandaloneSelectInputs,
26
+ q as generateComponentCode,
27
+ D as generateComponentMetadata,
28
+ I as generateQualifiedPropName,
29
+ G as generateReadme,
30
+ N as getComponentPropName,
29
31
  F as getComponentPropType,
30
- I as qualifyFormInputs,
31
- L as sanitizePropName,
32
+ L as qualifyFormInputs,
33
+ b as sanitizePropName,
32
34
  l as useEncoreState
33
35
  };
34
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["console.log(\"Encore Lib Loaded\");\nimport EncoreApp from \"./components/EncoreApp\";\nimport EncoreErrorBoundary from \"./components/EncoreErrorBoundary\";\nimport EncoreLoadingFallback from \"./components/EncoreLoadingFallback\";\nimport EncoreAppContext from \"./contexts/EncoreAppContext\";\nimport EncoreBindingContext from \"./contexts/EncoreBindingContext\";\nimport useEncoreState from \"./stores/useEncoreState\";\n\nexport {\n EncoreApp,\n EncoreErrorBoundary,\n EncoreLoadingFallback,\n EncoreAppContext,\n EncoreBindingContext,\n useEncoreState,\n};\n\nexport * from \"./codegen\";\n"],"names":[],"mappings":";;;;;;;;AAAA,QAAQ,IAAI,mBAAmB;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["console.log(\"Encore Lib Loaded\");\nimport EncoreApp from \"./components/EncoreApp\";\nimport EncoreErrorBoundary from \"./components/EncoreErrorBoundary\";\nimport EncoreLoadingFallback from \"./components/EncoreLoadingFallback\";\nimport EncoreAppContext from \"./contexts/EncoreAppContext\";\nimport EncoreBindingContext from \"./contexts/EncoreBindingContext\";\nimport useEncoreState from \"./stores/useEncoreState\";\nimport { PACKAGE_VERSION } from \"./version\";\n\nexport {\n EncoreApp,\n EncoreErrorBoundary,\n EncoreLoadingFallback,\n EncoreAppContext,\n EncoreBindingContext,\n useEncoreState,\n PACKAGE_VERSION,\n};\n\nexport * from \"./codegen\";\n"],"names":[],"mappings":";;;;;;;;;AAAA,QAAQ,IAAI,mBAAmB;"}
@@ -1,11 +1,11 @@
1
1
  import d from "axios";
2
2
  import { isLocalMode as u } from "./localMode.js";
3
3
  import h from "../stores/useEncoreState.js";
4
- const g = () => h.getState().baseURL, l = {}, U = (o) => {
4
+ const g = () => h.getState().baseURL, f = {}, v = (o) => {
5
5
  if (/\buseLocal=1\b/.test(o) || u()) {
6
- const c = o.split("?")[0], p = c.match(/^\/devices\/apps\/([^/]+)$/);
7
- if (p) {
8
- const e = p[1], a = [
6
+ const c = o.split("?")[0], i = c.match(/^\/devices\/apps\/([^/]+)$/);
7
+ if (i) {
8
+ const e = i[1], a = [
9
9
  `/flex-layout/${e}/${e}.json`,
10
10
  void 0
11
11
  ].filter(Boolean);
@@ -17,9 +17,7 @@ const g = () => h.getState().baseURL, l = {}, U = (o) => {
17
17
  } catch {
18
18
  }
19
19
  throw new Error(
20
- `Local app.json not found for ${e} (tried ${a.join(
21
- ", "
22
- )})`
20
+ `Local app.json not found for ${e} (tried ${a.join(", ")})`
23
21
  );
24
22
  })();
25
23
  }
@@ -37,22 +35,29 @@ const g = () => h.getState().baseURL, l = {}, U = (o) => {
37
35
  const t = await fetch(n[1]).catch(() => null);
38
36
  if (t && t.ok) return t.json();
39
37
  }
40
- const i = await fetch(`/flex-layout/${e}/${e}.json`).then((t) => t.ok ? t.json() : null).catch(() => null) || null;
41
- return { clientData: (i?.app?.data?.pages || i?.data?.pages || []).find((t) => t?.id === a) || {} };
38
+ const l = await fetch(`/flex-layout/${e}/${e}.json`).then((t) => t.ok ? t.json() : null).catch(() => null) || null;
39
+ return { clientData: (l?.app?.data?.pages || l?.data?.pages || []).find((t) => t?.id === a) || {} };
42
40
  }).catch(async () => ({ clientData: null }));
43
41
  }
44
42
  }
45
- if (l?.[o])
46
- return JSON.parse(l?.[o]);
47
- const f = g();
48
- return d({
49
- baseURL: f,
50
- url: o,
51
- headers: { "x-app-clientrendered": "true" }
43
+ if (f?.[o])
44
+ return JSON.parse(f?.[o]);
45
+ const p = g();
46
+ return console.log(
47
+ "[Fetcher] Requesting:",
48
+ o,
49
+ "BaseURL:",
50
+ p,
51
+ "Headers:",
52
+ { "x-app-clientrendered": "disabled" }
53
+ ), d({
54
+ baseURL: p,
55
+ url: o
56
+ // headers: { "x-app-clientrendered": "true" },
52
57
  }).then((c) => c.data);
53
58
  };
54
59
  export {
55
60
  g as appsServiceUrl,
56
- U as default
61
+ v as default
57
62
  };
58
63
  //# sourceMappingURL=fetcher.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.js","sources":["../../src/lib/fetcher.ts"],"sourcesContent":["import axios from \"axios\";\nimport { isLocalMode } from \"./localMode\";\nimport useEncoreState from \"../stores/useEncoreState\";\n\n// Get baseURL from store at runtime instead of build time\nconst getAppsServiceUrl = () => {\n return useEncoreState.getState().baseURL;\n};\n\nconst bundledResponses: Record<string, string> = {};\n\nconst fetcher = (url: string) => {\n // Local mode: map Encore service URLs to files in /flex-layout\n const forceLocal = /\\buseLocal=1\\b/.test(url);\n if (forceLocal || isLocalMode()) {\n const pathOnly = url.split(\"?\")[0];\n const absBase = null;\n // /devices/apps/:appId\n const appMatch = pathOnly.match(/^\\/devices\\/apps\\/([^/]+)$/);\n if (appMatch) {\n const appId = appMatch[1];\n const tryUrls = [\n `/flex-layout/${appId}/${appId}.json`,\n absBase\n ? `/@fs/${absBase}/${appId}/${appId}.json`\n : undefined,\n ].filter(Boolean) as string[];\n return (async () => {\n for (const u of tryUrls) {\n try {\n const r = await fetch(u);\n if (r.ok) return r.json();\n } catch {\n // try next\n }\n }\n throw new Error(\n `Local app.json not found for ${appId} (tried ${tryUrls.join(\n \", \",\n )})`,\n );\n })();\n }\n // /devices/apps/:appId/node/:pageId\n const pageMatch = pathOnly.match(\n /^\\/devices\\/apps\\/([^/]+)\\/node\\/([^/?#]+)$/,\n );\n if (pageMatch) {\n const appId = pageMatch[1];\n const pageId = pageMatch[2];\n // Try a dedicated page JSON first (if present)\n const tryUrls = [\n `/flex-layout/${appId}/${pageId}.json`,\n absBase\n ? `/@fs/${absBase}/${appId}/${pageId}.json`\n : undefined,\n ].filter(Boolean) as string[];\n return fetch(tryUrls[0])\n .then(async (r) => {\n if (r.ok) return r.json();\n // try secondary url if defined\n if (tryUrls[1]) {\n const r2 = await fetch(tryUrls[1]).catch(() => null);\n if (r2 && r2.ok) return r2.json();\n }\n // Fallback: derive minimal shape from app.json\n const appJson =\n (await fetch(`/flex-layout/${appId}/${appId}.json`)\n .then((a) => (a.ok ? a.json() : null))\n .catch(() => null)) ||\n (absBase\n ? await fetch(\n `/@fs/${absBase}/${appId}/${appId}.json`,\n )\n .then((a) => (a.ok ? a.json() : null))\n .catch(() => null)\n : null);\n // Keep shape compatible with current consumers\n const pages =\n appJson?.app?.data?.pages ||\n appJson?.data?.pages ||\n [];\n const page = pages.find((p: any) => p?.id === pageId) || {};\n return { clientData: page };\n })\n .catch(async () => {\n // Final fallback: minimal object\n return { clientData: null };\n });\n }\n }\n\n if (bundledResponses?.[url]) {\n return JSON.parse(bundledResponses?.[url]);\n }\n\n // Get baseURL at runtime from store\n const appsServiceUrl = getAppsServiceUrl();\n\n return axios({\n baseURL: appsServiceUrl,\n url,\n headers: { \"x-app-clientrendered\": \"true\" },\n }).then((res) => res.data);\n};\n\nexport default fetcher;\nexport { getAppsServiceUrl as appsServiceUrl };\n"],"names":["getAppsServiceUrl","useEncoreState","bundledResponses","fetcher","url","isLocalMode","pathOnly","appMatch","appId","tryUrls","u","r","pageMatch","pageId","r2","appJson","a","p","appsServiceUrl","axios","res"],"mappings":";;;AAKA,MAAMA,IAAoB,MACfC,EAAe,WAAW,SAG/BC,IAA2C,CAAA,GAE3CC,IAAU,CAACC,MAAgB;AAG7B,MADmB,iBAAiB,KA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eAAO,EAAE,aAJLD,GAAS,KAAK,MAAM,SACpBA,GAAS,MAAM,SACf,CAAA,GACe,KAAK,CAACE,MAAWA,GAAG,OAAOJ,CAAM,KAAK,CAAA,EACpC;AAAA,MACzB,CAAC,EACA,MAAM,aAEI,EAAE,YAAY,KAAA,EACxB;AAAA,IACT;AAAA,EACJ;AAEA,MAAIX,IAAmBE,CAAG;AACtB,WAAO,KAAK,MAAMF,IAAmBE,CAAG,CAAC;AAI7C,QAAMc,IAAiBlB,EAAA;AAEvB,SAAOmB,EAAM;AAAA,IACT,SAASD;AAAA,IACT,KAAAd;AAAA,IACA,SAAS,EAAE,wBAAwB,OAAA;AAAA,EAAO,CAC7C,EAAE,KAAK,CAACgB,MAAQA,EAAI,IAAI;AAC7B;"}
1
+ {"version":3,"file":"fetcher.js","sources":["../../src/lib/fetcher.ts"],"sourcesContent":["import axios from \"axios\";\nimport { isLocalMode } from \"./localMode\";\nimport useEncoreState from \"../stores/useEncoreState\";\n\n// Get baseURL from store at runtime instead of build time\nconst getAppsServiceUrl = () => {\n return useEncoreState.getState().baseURL;\n};\n\nconst bundledResponses: Record<string, string> = {};\n\nconst fetcher = (url: string) => {\n // Local mode: map Encore service URLs to files in /flex-layout\n const forceLocal = /\\buseLocal=1\\b/.test(url);\n if (forceLocal || isLocalMode()) {\n const pathOnly = url.split(\"?\")[0];\n const absBase = null;\n // /devices/apps/:appId\n const appMatch = pathOnly.match(/^\\/devices\\/apps\\/([^/]+)$/);\n if (appMatch) {\n const appId = appMatch[1];\n const tryUrls = [\n `/flex-layout/${appId}/${appId}.json`,\n absBase ? `/@fs/${absBase}/${appId}/${appId}.json` : undefined,\n ].filter(Boolean) as string[];\n return (async () => {\n for (const u of tryUrls) {\n try {\n const r = await fetch(u);\n if (r.ok) return r.json();\n } catch {\n // try next\n }\n }\n throw new Error(\n `Local app.json not found for ${appId} (tried ${tryUrls.join(\", \")})`\n );\n })();\n }\n // /devices/apps/:appId/node/:pageId\n const pageMatch = pathOnly.match(\n /^\\/devices\\/apps\\/([^/]+)\\/node\\/([^/?#]+)$/\n );\n if (pageMatch) {\n const appId = pageMatch[1];\n const pageId = pageMatch[2];\n // Try a dedicated page JSON first (if present)\n const tryUrls = [\n `/flex-layout/${appId}/${pageId}.json`,\n absBase ? `/@fs/${absBase}/${appId}/${pageId}.json` : undefined,\n ].filter(Boolean) as string[];\n return fetch(tryUrls[0])\n .then(async (r) => {\n if (r.ok) return r.json();\n // try secondary url if defined\n if (tryUrls[1]) {\n const r2 = await fetch(tryUrls[1]).catch(() => null);\n if (r2 && r2.ok) return r2.json();\n }\n // Fallback: derive minimal shape from app.json\n const appJson =\n (await fetch(`/flex-layout/${appId}/${appId}.json`)\n .then((a) => (a.ok ? a.json() : null))\n .catch(() => null)) ||\n (absBase\n ? await fetch(`/@fs/${absBase}/${appId}/${appId}.json`)\n .then((a) => (a.ok ? a.json() : null))\n .catch(() => null)\n : null);\n // Keep shape compatible with current consumers\n const pages = appJson?.app?.data?.pages || appJson?.data?.pages || [];\n const page = pages.find((p: any) => p?.id === pageId) || {};\n return { clientData: page };\n })\n .catch(async () => {\n // Final fallback: minimal object\n return { clientData: null };\n });\n }\n }\n\n if (bundledResponses?.[url]) {\n return JSON.parse(bundledResponses?.[url]);\n }\n\n // Get baseURL at runtime from store\n const appsServiceUrl = getAppsServiceUrl();\n\n console.log(\n \"[Fetcher] Requesting:\",\n url,\n \"BaseURL:\",\n appsServiceUrl,\n \"Headers:\",\n { \"x-app-clientrendered\": \"disabled\" }\n );\n\n return axios({\n baseURL: appsServiceUrl,\n url,\n // headers: { \"x-app-clientrendered\": \"true\" },\n }).then((res) => res.data);\n};\n\nexport default fetcher;\nexport { getAppsServiceUrl as appsServiceUrl };\n"],"names":["getAppsServiceUrl","useEncoreState","bundledResponses","fetcher","url","isLocalMode","pathOnly","appMatch","appId","tryUrls","u","r","pageMatch","pageId","r2","appJson","a","p","appsServiceUrl","axios","res"],"mappings":";;;AAKA,MAAMA,IAAoB,MACjBC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AAE,KAAKA,EAAE,KAAA,IAAS,IAAK,EACpC,MAAM,MAAM,IAAI,KAKf;AAIN,eAAO,EAAE,aAFKD,GAAS,KAAK,MAAM,SAASA,GAAS,MAAM,SAAS,CAAA,GAChD,KAAK,CAACE,MAAWA,GAAG,OAAOJ,CAAM,KAAK,CAAA,EACpC;AAAA,MACvB,CAAC,EACA,MAAM,aAEE,EAAE,YAAY,KAAA,EACtB;AAAA,IACL;AAAA,EACF;AAEA,MAAIX,IAAmBE,CAAG;AACxB,WAAO,KAAK,MAAMF,IAAmBE,CAAG,CAAC;AAI3C,QAAMc,IAAiBlB,EAAA;AAEvB,iBAAQ;AAAA,IACN;AAAA,IACAI;AAAA,IACA;AAAA,IACAc;AAAA,IACA;AAAA,IACA,EAAE,wBAAwB,WAAA;AAAA,EAAW,GAGhCC,EAAM;AAAA,IACX,SAASD;AAAA,IACT,KAAAd;AAAA;AAAA,EAAA,CAED,EAAE,KAAK,CAACgB,MAAQA,EAAI,IAAI;AAC3B;"}
@@ -0,0 +1,25 @@
1
+ var i = Object.prototype.hasOwnProperty;
2
+ function u(t, e) {
3
+ var n, r;
4
+ if (t === e) return !0;
5
+ if (t && e && (n = t.constructor) === e.constructor) {
6
+ if (n === Date) return t.getTime() === e.getTime();
7
+ if (n === RegExp) return t.toString() === e.toString();
8
+ if (n === Array) {
9
+ if ((r = t.length) === e.length)
10
+ for (; r-- && u(t[r], e[r]); ) ;
11
+ return r === -1;
12
+ }
13
+ if (!n || typeof t == "object") {
14
+ r = 0;
15
+ for (n in t)
16
+ if (i.call(t, n) && ++r && !i.call(e, n) || !(n in e) || !u(t[n], e[n])) return !1;
17
+ return Object.keys(e).length === r;
18
+ }
19
+ }
20
+ return t !== t && e !== e;
21
+ }
22
+ export {
23
+ u as dequal
24
+ };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../../node_modules/dequal/lite/index.mjs"],"sourcesContent":["var has = Object.prototype.hasOwnProperty;\n\nexport function dequal(foo, bar) {\n\tvar ctor, len;\n\tif (foo === bar) return true;\n\n\tif (foo && bar && (ctor=foo.constructor) === bar.constructor) {\n\t\tif (ctor === Date) return foo.getTime() === bar.getTime();\n\t\tif (ctor === RegExp) return foo.toString() === bar.toString();\n\n\t\tif (ctor === Array) {\n\t\t\tif ((len=foo.length) === bar.length) {\n\t\t\t\twhile (len-- && dequal(foo[len], bar[len]));\n\t\t\t}\n\t\t\treturn len === -1;\n\t\t}\n\n\t\tif (!ctor || typeof foo === 'object') {\n\t\t\tlen = 0;\n\t\t\tfor (ctor in foo) {\n\t\t\t\tif (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;\n\t\t\t\tif (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;\n\t\t\t}\n\t\t\treturn Object.keys(bar).length === len;\n\t\t}\n\t}\n\n\treturn foo !== foo && bar !== bar;\n}\n"],"names":["has","dequal","foo","bar","ctor","len"],"mappings":"AAAA,IAAIA,IAAM,OAAO,UAAU;AAEpB,SAASC,EAAOC,GAAKC,GAAK;AAChC,MAAIC,GAAMC;AACV,MAAIH,MAAQC,EAAK,QAAO;AAExB,MAAID,KAAOC,MAAQC,IAAKF,EAAI,iBAAiBC,EAAI,aAAa;AAC7D,QAAIC,MAAS,KAAM,QAAOF,EAAI,QAAO,MAAOC,EAAI,QAAO;AACvD,QAAIC,MAAS,OAAQ,QAAOF,EAAI,SAAQ,MAAOC,EAAI,SAAQ;AAE3D,QAAIC,MAAS,OAAO;AACnB,WAAKC,IAAIH,EAAI,YAAYC,EAAI;AAC5B,eAAOE,OAASJ,EAAOC,EAAIG,CAAG,GAAGF,EAAIE,CAAG,CAAC,IAAE;AAE5C,aAAOA,MAAQ;AAAA,IAChB;AAEA,QAAI,CAACD,KAAQ,OAAOF,KAAQ,UAAU;AACrC,MAAAG,IAAM;AACN,WAAKD,KAAQF;AAEZ,YADIF,EAAI,KAAKE,GAAKE,CAAI,KAAK,EAAEC,KAAO,CAACL,EAAI,KAAKG,GAAKC,CAAI,KACnD,EAAEA,KAAQD,MAAQ,CAACF,EAAOC,EAAIE,CAAI,GAAGD,EAAIC,CAAI,CAAC,EAAG,QAAO;AAE7D,aAAO,OAAO,KAAKD,CAAG,EAAE,WAAWE;AAAA,IACpC;AAAA,EACD;AAEA,SAAOH,MAAQA,KAAOC,MAAQA;AAC/B;","x_google_ignoreList":[0]}