@bravostudioai/react 0.1.18 → 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.
- package/dist/_virtual/index.js +6 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/index2.js +5 -0
- package/dist/_virtual/index2.js.map +1 -0
- package/dist/_virtual/use-sync-external-store-shim.development.js +5 -0
- package/dist/_virtual/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/_virtual/use-sync-external-store-shim.production.js +5 -0
- package/dist/_virtual/use-sync-external-store-shim.production.js.map +1 -0
- package/dist/cli/commands/generate.js +144 -129
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/components/DynamicComponent.js.map +1 -1
- package/dist/components/EncoreApp.js +42 -39
- package/dist/components/EncoreApp.js.map +1 -1
- package/dist/components/EncoreErrorBoundary.js.map +1 -1
- package/dist/components/EncoreLoadingFallback.js.map +1 -1
- package/dist/components.js +343 -336
- package/dist/components.js.map +1 -1
- package/dist/contexts/EncoreActionContext.js +3 -3
- package/dist/contexts/EncoreActionContext.js.map +1 -1
- package/dist/contexts/EncoreAppContext.js +2 -2
- package/dist/contexts/EncoreAppContext.js.map +1 -1
- package/dist/contexts/EncoreBindingContext.js +2 -2
- package/dist/contexts/EncoreBindingContext.js.map +1 -1
- package/dist/contexts/EncoreComponentIdContext.js +3 -5
- package/dist/contexts/EncoreComponentIdContext.js.map +1 -1
- package/dist/contexts/EncoreRepeatingContainerContext.js +2 -2
- package/dist/contexts/EncoreRepeatingContainerContext.js.map +1 -1
- package/dist/contexts/EncoreRouterContext.js +2 -2
- package/dist/contexts/EncoreRouterContext.js.map +1 -1
- package/dist/hooks/usePusherUpdates.js +1 -1
- package/dist/hooks/usePusherUpdates.js.map +1 -1
- package/dist/index.js +21 -19
- package/dist/index.js.map +1 -1
- package/dist/lib/fetcher.js +22 -17
- package/dist/lib/fetcher.js.map +1 -1
- package/dist/node_modules/dequal/lite/index.js +25 -0
- package/dist/node_modules/dequal/lite/index.js.map +1 -0
- package/dist/node_modules/swr/dist/_internal/config-context-12s-Dh3trQsc.js +289 -0
- package/dist/node_modules/swr/dist/_internal/config-context-12s-Dh3trQsc.js.map +1 -0
- package/dist/node_modules/swr/dist/_internal/constants.js +5 -0
- package/dist/node_modules/swr/dist/_internal/constants.js.map +1 -0
- package/dist/node_modules/swr/dist/_internal/events.js +8 -0
- package/dist/node_modules/swr/dist/_internal/events.js.map +1 -0
- package/dist/node_modules/swr/dist/_internal/index.js +78 -0
- package/dist/node_modules/swr/dist/_internal/index.js.map +1 -0
- package/dist/node_modules/swr/dist/index/index.js +216 -0
- package/dist/node_modules/swr/dist/index/index.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +59 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +47 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js.map +1 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js +11 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js.map +1 -0
- package/dist/src/cli/commands/generate.d.ts.map +1 -1
- package/dist/src/components/DynamicComponent.d.ts.map +1 -1
- package/dist/src/components/EncoreApp.d.ts.map +1 -1
- package/dist/src/components/EncoreErrorBoundary.d.ts.map +1 -1
- package/dist/src/components/EncoreLoadingFallback.d.ts.map +1 -1
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/contexts/EncoreActionContext.d.ts +1 -2
- package/dist/src/contexts/EncoreActionContext.d.ts.map +1 -1
- package/dist/src/contexts/EncoreAppContext.d.ts +1 -2
- package/dist/src/contexts/EncoreAppContext.d.ts.map +1 -1
- package/dist/src/contexts/EncoreBindingContext.d.ts +1 -2
- package/dist/src/contexts/EncoreBindingContext.d.ts.map +1 -1
- package/dist/src/contexts/EncoreComponentIdContext.d.ts +1 -2
- package/dist/src/contexts/EncoreComponentIdContext.d.ts.map +1 -1
- package/dist/src/contexts/EncoreRepeatingContainerContext.d.ts +1 -2
- package/dist/src/contexts/EncoreRepeatingContainerContext.d.ts.map +1 -1
- package/dist/src/contexts/EncoreRouterContext.d.ts +1 -2
- package/dist/src/contexts/EncoreRouterContext.d.ts.map +1 -1
- package/dist/src/hooks/useAuthRedirect.d.ts.map +1 -1
- package/dist/src/hooks/usePusherUpdates.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/lib/fetcher.d.ts.map +1 -1
- package/dist/src/stores/useEncoreState.d.ts.map +1 -1
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.d.ts.map +1 -0
- package/dist/stores/useEncoreState.js.map +1 -1
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +3 -2
- package/src/components/DynamicComponent.tsx +1 -0
- package/src/components/EncoreApp.tsx +3 -1
- package/src/components/EncoreErrorBoundary.tsx +36 -35
- package/src/components/EncoreLoadingFallback.tsx +19 -18
- package/src/components.tsx +5 -34
- package/src/contexts/EncoreActionContext.ts +4 -2
- package/src/contexts/EncoreAppContext.ts +4 -2
- package/src/contexts/EncoreBindingContext.ts +4 -2
- package/src/contexts/EncoreComponentIdContext.ts +4 -4
- package/src/contexts/EncoreRepeatingContainerContext.ts +4 -3
- package/src/contexts/EncoreRouterContext.ts +4 -2
- package/src/hooks/useAuthRedirect.ts +2 -0
- package/src/hooks/usePusherUpdates.ts +2 -0
- package/src/index.ts +2 -0
- package/src/stores/useEncoreState.ts +2 -0
- package/src/version.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncoreActionContext.js","sources":["../../src/contexts/EncoreActionContext.ts"],"sourcesContent":["
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncoreAppContext.js","sources":["../../src/contexts/EncoreAppContext.ts"],"sourcesContent":["
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncoreBindingContext.js","sources":["../../src/contexts/EncoreBindingContext.ts"],"sourcesContent":["
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncoreComponentIdContext.js","sources":["../../src/contexts/EncoreComponentIdContext.ts"],"sourcesContent":["
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncoreRepeatingContainerContext.js","sources":["../../src/contexts/EncoreRepeatingContainerContext.ts"],"sourcesContent":["
|
|
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,
|
|
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
|
|
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":["
|
|
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":["
|
|
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,CAAC,GAGDC,EAAQ,KAAK,6BAA6B,CAACC,MAAmB;AAC5D,cAAQ;AAAA,QACN,2CAA2CF,CAAW;AAAA,QACtDE;AAAA,MAAA;AAAA,IAEJ,CAAC;AAKD,UAAMC,IAAe,CAACC,MAAkB;AACtC,cAAQ,IAAI,gCAAgCJ,CAAW,KAAKI,CAAI;AAGhE,YAAMC,IAAgB,GAAGhB,CAAK,qBAAqBC,CAAM;AACzD,MAAAgB,EAAiBD,CAAa;AAG9B,YAAME,IAAS,iBAAiBlB,CAAK,IAC/BmB,IAAU,iBAAiBnB,CAAK,SAASC,CAAM;AAGrD,MAAAmB,EAAOF,CAAM,EAAE,MAAM,CAACG,MAAQ;AAC5B,gBAAQ,MAAM,0CAA0CA,CAAG;AAAA,MAC7D,CAAC,GACDD,EAAOD,CAAO,EAAE,MAAM,CAACE,MAAQ;AAC7B,gBAAQ,MAAM,2CAA2CA,CAAG;AAAA,MAC9D,CAAC,GAGDD,EAAO,GAAGF,CAAM,aAAa,EAAE,MAAM,MAAM;AAAA,MAE3C,CAAC,GACDE,EAAO,GAAGD,CAAO,aAAa,EAAE,MAAM,MAAM;AAAA,MAE5C,CAAC,GAGDhB,IAAA;AAAA,IACF;AAIA,WAAAS,EAAQ,KAAK,UAAUE,CAAY,GACnCF,EAAQ,KAAK,qBAAqBE,CAAY,GAC9CF,EAAQ,KAAK,eAAeE,CAAY,GAGjC,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;"}
|
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
|
|
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 {
|
|
8
|
-
import {
|
|
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
|
-
|
|
13
|
+
i as EncoreAppContext,
|
|
13
14
|
m as EncoreBindingContext,
|
|
14
15
|
a as EncoreErrorBoundary,
|
|
15
16
|
d as EncoreLoadingFallback,
|
|
16
|
-
g as
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
P as
|
|
22
|
-
S as
|
|
23
|
-
y as
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
31
|
-
|
|
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":"
|
|
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;"}
|
package/dist/lib/fetcher.js
CHANGED
|
@@ -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,
|
|
4
|
+
const g = () => h.getState().baseURL, f = {}, v = (o) => {
|
|
5
5
|
if (/\buseLocal=1\b/.test(o) || u()) {
|
|
6
|
-
const c = o.split("?")[0],
|
|
7
|
-
if (
|
|
8
|
-
const e =
|
|
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
|
|
41
|
-
return { clientData: (
|
|
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 (
|
|
46
|
-
return JSON.parse(
|
|
47
|
-
const
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
61
|
+
v as default
|
|
57
62
|
};
|
|
58
63
|
//# sourceMappingURL=fetcher.js.map
|
package/dist/lib/fetcher.js.map
CHANGED
|
@@ -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
|
|
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,EAAe,WAAW,SAG7BC,IAA2C,CAAA,GAE3CC,IAAU,CAACC,MAAgB;AAG/B,MADmB,iBAAiB,KAAKA,CAAG,KAC1BC,KAAe;AAC/B,UAAMC,IAAWF,EAAI,MAAM,GAAG,EAAE,CAAC,GAG3BG,IAAWD,EAAS,MAAM,4BAA4B;AAC5D,QAAIC,GAAU;AACZ,YAAMC,IAAQD,EAAS,CAAC,GAClBE,IAAU;AAAA,QACd,gBAAgBD,CAAK,IAAIA,CAAK;AAAA,QACuB;AAAA,MAAA,EACrD,OAAO,OAAO;AAChB,cAAQ,YAAY;AAClB,mBAAWE,KAAKD;AACd,cAAI;AACF,kBAAME,IAAI,MAAM,MAAMD,CAAC;AACvB,gBAAIC,EAAE,GAAI,QAAOA,EAAE,KAAA;AAAA,UACrB,QAAQ;AAAA,UAER;AAEF,cAAM,IAAI;AAAA,UACR,gCAAgCH,CAAK,WAAWC,EAAQ,KAAK,IAAI,CAAC;AAAA,QAAA;AAAA,MAEtE,GAAA;AAAA,IACF;AAEA,UAAMG,IAAYN,EAAS;AAAA,MACzB;AAAA,IAAA;AAEF,QAAIM,GAAW;AACb,YAAMJ,IAAQI,EAAU,CAAC,GACnBC,IAASD,EAAU,CAAC,GAEpBH,IAAU;AAAA,QACd,gBAAgBD,CAAK,IAAIK,CAAM;AAAA,QACuB;AAAA,MAAA,EACtD,OAAO,OAAO;AAChB,aAAO,MAAMJ,EAAQ,CAAC,CAAC,EACpB,KAAK,OAAOE,MAAM;AACjB,YAAIA,EAAE,GAAI,QAAOA,EAAE,KAAA;AAEnB,YAAIF,EAAQ,CAAC,GAAG;AACd,gBAAMK,IAAK,MAAM,MAAML,EAAQ,CAAC,CAAC,EAAE,MAAM,MAAM,IAAI;AACnD,cAAIK,KAAMA,EAAG,GAAI,QAAOA,EAAG,KAAA;AAAA,QAC7B;AAEA,cAAMC,IACH,MAAM,MAAM,gBAAgBP,CAAK,IAAIA,CAAK,OAAO,EAC/C,KAAK,CAACQ,MAAOA,EAAE,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]}
|