@bravostudioai/react 0.1.31 → 0.1.32
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/cli/commands/generate.js +69 -65
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/codegen/generator.js.map +1 -1
- package/dist/codegen/parser.js +256 -593
- package/dist/codegen/parser.js.map +1 -1
- package/dist/codegen/propQualification.js +117 -0
- package/dist/codegen/propQualification.js.map +1 -0
- package/dist/components/DynamicComponent.js.map +1 -1
- package/dist/components/EncoreApp.js +142 -275
- package/dist/components/EncoreApp.js.map +1 -1
- package/dist/components/EncoreContextProviders.js +24 -0
- package/dist/components/EncoreContextProviders.js.map +1 -0
- package/dist/components.js +179 -174
- package/dist/components.js.map +1 -1
- package/dist/hooks/useFontLoader.js +41 -0
- package/dist/hooks/useFontLoader.js.map +1 -0
- package/dist/hooks/usePusherUpdates.js +41 -45
- package/dist/hooks/usePusherUpdates.js.map +1 -1
- package/dist/hooks/useRepeatingContainers.js +79 -0
- package/dist/hooks/useRepeatingContainers.js.map +1 -0
- package/dist/index.js +13 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/dataPatching.js +24 -0
- package/dist/lib/dataPatching.js.map +1 -0
- package/dist/lib/dynamicModules.js +44 -45
- package/dist/lib/dynamicModules.js.map +1 -1
- package/dist/lib/fetcher.js +6 -13
- package/dist/lib/fetcher.js.map +1 -1
- package/dist/lib/logger.js +35 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/moduleRegistry.js +9 -8
- package/dist/lib/moduleRegistry.js.map +1 -1
- package/dist/src/cli/commands/generate.d.ts.map +1 -1
- package/dist/src/codegen/generator.d.ts +74 -0
- package/dist/src/codegen/generator.d.ts.map +1 -1
- package/dist/src/codegen/parser.d.ts +39 -0
- package/dist/src/codegen/parser.d.ts.map +1 -1
- package/dist/src/codegen/propQualification.d.ts +42 -0
- package/dist/src/codegen/propQualification.d.ts.map +1 -0
- package/dist/src/components/DynamicComponent.d.ts +1 -1
- package/dist/src/components/DynamicComponent.d.ts.map +1 -1
- package/dist/src/components/EncoreApp.d.ts +55 -2
- package/dist/src/components/EncoreApp.d.ts.map +1 -1
- package/dist/src/components/EncoreContextProviders.d.ts +34 -0
- package/dist/src/components/EncoreContextProviders.d.ts.map +1 -0
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/hooks/useFontLoader.d.ts +17 -0
- package/dist/src/hooks/useFontLoader.d.ts.map +1 -0
- package/dist/src/hooks/usePusherUpdates.d.ts.map +1 -1
- package/dist/src/hooks/useRepeatingContainers.d.ts +31 -0
- package/dist/src/hooks/useRepeatingContainers.d.ts.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/lib/dataPatching.d.ts +18 -0
- package/dist/src/lib/dataPatching.d.ts.map +1 -0
- package/dist/src/lib/dynamicModules.d.ts.map +1 -1
- package/dist/src/lib/fetcher.d.ts.map +1 -1
- package/dist/src/lib/logger.d.ts +33 -0
- package/dist/src/lib/logger.d.ts.map +1 -0
- package/dist/src/lib/moduleRegistry.d.ts.map +1 -1
- package/dist/src/stores/useEncoreState.d.ts +43 -1
- package/dist/src/stores/useEncoreState.d.ts.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/stores/useEncoreState.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DynamicComponent.tsx +1 -1
- package/src/hooks/useRepeatingContainers.ts +1 -1
- package/src/version.ts +1 -1
package/dist/lib/fetcher.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import d from "axios";
|
|
2
2
|
import { isLocalMode as u } from "./localMode.js";
|
|
3
3
|
import h from "../stores/useEncoreState.js";
|
|
4
|
-
|
|
4
|
+
import { logger as g } from "./logger.js";
|
|
5
|
+
const m = () => h.getState().baseURL, f = {}, S = (o) => {
|
|
5
6
|
if (/\buseLocal=1\b/.test(o) || u()) {
|
|
6
7
|
const c = o.split("?")[0], i = c.match(/^\/devices\/apps\/([^/]+)$/);
|
|
7
8
|
if (i) {
|
|
@@ -42,22 +43,14 @@ const g = () => h.getState().baseURL, f = {}, v = (o) => {
|
|
|
42
43
|
}
|
|
43
44
|
if (f?.[o])
|
|
44
45
|
return JSON.parse(f?.[o]);
|
|
45
|
-
const p =
|
|
46
|
-
return
|
|
47
|
-
"[Fetcher] Requesting:",
|
|
48
|
-
o,
|
|
49
|
-
"BaseURL:",
|
|
50
|
-
p,
|
|
51
|
-
"Headers:",
|
|
52
|
-
{ "x-app-clientrendered": "disabled" }
|
|
53
|
-
), d({
|
|
46
|
+
const p = m();
|
|
47
|
+
return g.debug("Fetching from Encore service", { url: o, baseURL: p }), d({
|
|
54
48
|
baseURL: p,
|
|
55
49
|
url: o
|
|
56
|
-
// headers: { "x-app-clientrendered": "true" },
|
|
57
50
|
}).then((c) => c.data);
|
|
58
51
|
};
|
|
59
52
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
m as appsServiceUrl,
|
|
54
|
+
S as default
|
|
62
55
|
};
|
|
63
56
|
//# 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 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
|
|
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\";\nimport logger from \"./logger\";\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 logger.debug('Fetching from Encore service', { url, baseURL: appsServiceUrl });\n\n return axios({\n baseURL: appsServiceUrl,\n url,\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","logger","axios","res"],"mappings":";;;;AAMA,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,SAAAmB,EAAO,MAAM,gCAAgC,EAAE,KAAAf,GAAK,SAASc,GAAgB,GAEtEE,EAAM;AAAA,IACX,SAASF;AAAA,IACT,KAAAd;AAAA,EAAA,CACD,EAAE,KAAK,CAACiB,MAAQA,EAAI,IAAI;AAC3B;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const o = typeof import.meta < "u" ? !1 : process.env.NODE_ENV === "development", n = {
|
|
2
|
+
/**
|
|
3
|
+
* Debug-level logging (only in development)
|
|
4
|
+
* Use for detailed diagnostic information
|
|
5
|
+
*/
|
|
6
|
+
debug: (...e) => {
|
|
7
|
+
o && console.debug("[encore-lib]", ...e);
|
|
8
|
+
},
|
|
9
|
+
/**
|
|
10
|
+
* Info-level logging (only in development)
|
|
11
|
+
* Use for general informational messages
|
|
12
|
+
*/
|
|
13
|
+
info: (...e) => {
|
|
14
|
+
o && console.info("[encore-lib]", ...e);
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Warning-level logging (always shown)
|
|
18
|
+
* Use for recoverable issues that need attention
|
|
19
|
+
*/
|
|
20
|
+
warn: (...e) => {
|
|
21
|
+
console.warn("[encore-lib]", ...e);
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Error-level logging (always shown)
|
|
25
|
+
* Use for errors and exceptions
|
|
26
|
+
*/
|
|
27
|
+
error: (...e) => {
|
|
28
|
+
console.error("[encore-lib]", ...e);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
n as default,
|
|
33
|
+
n as logger
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sources":["../../src/lib/logger.ts"],"sourcesContent":["/**\n * Centralized logging utility for encore-lib\n *\n * Provides conditional logging based on environment.\n * Debug logs only appear in development mode.\n */\n\nconst isDev = typeof import.meta !== 'undefined'\n ? import.meta.env?.DEV || import.meta.env?.MODE === 'development'\n : process.env.NODE_ENV === 'development';\n\n/**\n * Logger instance with environment-aware methods\n */\nexport const logger = {\n /**\n * Debug-level logging (only in development)\n * Use for detailed diagnostic information\n */\n debug: (...args: any[]) => {\n if (isDev) {\n console.debug('[encore-lib]', ...args);\n }\n },\n\n /**\n * Info-level logging (only in development)\n * Use for general informational messages\n */\n info: (...args: any[]) => {\n if (isDev) {\n console.info('[encore-lib]', ...args);\n }\n },\n\n /**\n * Warning-level logging (always shown)\n * Use for recoverable issues that need attention\n */\n warn: (...args: any[]) => {\n console.warn('[encore-lib]', ...args);\n },\n\n /**\n * Error-level logging (always shown)\n * Use for errors and exceptions\n */\n error: (...args: any[]) => {\n console.error('[encore-lib]', ...args);\n },\n};\n\nexport default logger;\n"],"names":["isDev","logger","args"],"mappings":"AAOA,MAAMA,IAAQ,OAAO,cAAgB,MACT,KACxB,QAAQ,IAAI,aAAa,eAKhBC,IAAS;AAAA;AAAA;AAAA;AAAA;AAAA,EAKpB,OAAO,IAAIC,MAAgB;AACzB,IAAIF,KACF,QAAQ,MAAM,gBAAgB,GAAGE,CAAI;AAAA,EAEzC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,IAAIA,MAAgB;AACxB,IAAIF,KACF,QAAQ,KAAK,gBAAgB,GAAGE,CAAI;AAAA,EAExC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,IAAIA,MAAgB;AACxB,YAAQ,KAAK,gBAAgB,GAAGA,CAAI;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,IAAIA,MAAgB;AACzB,YAAQ,MAAM,gBAAgB,GAAGA,CAAI;AAAA,EACvC;AACF;"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
import { logger as t } from "./logger.js";
|
|
1
2
|
const o = {};
|
|
2
|
-
function
|
|
3
|
-
o[e] =
|
|
3
|
+
function n(e, r) {
|
|
4
|
+
o[e] = r;
|
|
4
5
|
}
|
|
5
|
-
function
|
|
6
|
+
function c(e) {
|
|
6
7
|
return o[e]().exports;
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
+
function i(e) {
|
|
9
10
|
return e in o;
|
|
10
11
|
}
|
|
11
12
|
function l(e) {
|
|
12
|
-
e in o && (delete o[e],
|
|
13
|
+
e in o && (delete o[e], t.debug("Module cache cleared", { name: e }));
|
|
13
14
|
}
|
|
14
15
|
export {
|
|
15
16
|
l as clearModuleCache,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
c as getModuleExports,
|
|
18
|
+
i as haveModule,
|
|
19
|
+
n as registerModule
|
|
19
20
|
};
|
|
20
21
|
//# sourceMappingURL=moduleRegistry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moduleRegistry.js","sources":["../../src/lib/moduleRegistry.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"moduleRegistry.js","sources":["../../src/lib/moduleRegistry.ts"],"sourcesContent":["import logger from \"./logger\";\n\nconst registry: Record<string, any> = {};\n\nexport function registerModule(name: string, module: any) {\n registry[name] = module;\n}\n\nexport function getModuleExports(name: string) {\n return registry[name]().exports;\n}\n\nexport function haveModule(name: string): boolean {\n return name in registry;\n}\n\n/**\n * Clear a module from the cache to force reload on next fetch\n * @param name Module name (e.g., `${appId}/draft/components/${pageId}`)\n */\nexport function clearModuleCache(name: string): void {\n if (name in registry) {\n delete registry[name];\n logger.debug('Module cache cleared', { name });\n }\n}\n"],"names":["registry","registerModule","name","module","getModuleExports","haveModule","clearModuleCache","logger"],"mappings":";AAEA,MAAMA,IAAgC,CAAA;AAE/B,SAASC,EAAeC,GAAcC,GAAa;AACxD,EAAAH,EAASE,CAAI,IAAIC;AACnB;AAEO,SAASC,EAAiBF,GAAc;AAC7C,SAAOF,EAASE,CAAI,EAAA,EAAI;AAC1B;AAEO,SAASG,EAAWH,GAAuB;AAChD,SAAOA,KAAQF;AACjB;AAMO,SAASM,EAAiBJ,GAAoB;AACnD,EAAIA,KAAQF,MACV,OAAOA,EAASE,CAAI,GACpBK,EAAO,MAAM,wBAAwB,EAAE,MAAAL,EAAA,CAAM;AAEjD;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/generate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/generate.ts"],"names":[],"mappings":"AA8XA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,iBA8D/C"}
|
|
@@ -1,14 +1,88 @@
|
|
|
1
1
|
import { ComponentInfo, SliderInfo, InputGroupInfo, FormInfo, SelectInputInfo, ActionButtonInfo } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Metadata extracted from generated component
|
|
4
|
+
*/
|
|
2
5
|
export interface ComponentMetadata {
|
|
6
|
+
/** List of prop names */
|
|
3
7
|
props: string[];
|
|
8
|
+
/** List of event handler names */
|
|
4
9
|
events: string[];
|
|
10
|
+
/** Example JSX usage string */
|
|
5
11
|
jsx: string;
|
|
6
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Generates React component wrapper code for an Encore page
|
|
15
|
+
*
|
|
16
|
+
* Creates a TypeScript React component that wraps EncoreApp with typed props
|
|
17
|
+
* for all data-bound components, sliders, forms, and interactive elements.
|
|
18
|
+
*
|
|
19
|
+
* @param appId - Encore app ID
|
|
20
|
+
* @param pageId - Encore page ID
|
|
21
|
+
* @param componentName - Name for the generated component
|
|
22
|
+
* @param sliders - Slider/list metadata from parser
|
|
23
|
+
* @param standaloneComponents - Standalone component metadata
|
|
24
|
+
* @param inputGroups - Input group metadata
|
|
25
|
+
* @param forms - Form metadata
|
|
26
|
+
* @param selectInputs - Select input metadata
|
|
27
|
+
* @param actionButtons - Action button metadata
|
|
28
|
+
* @param isProduction - Whether to include bundled data for production
|
|
29
|
+
* @param pageMeta - Optional page dimensions and aspect ratio
|
|
30
|
+
* @returns TypeScript component source code
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const code = generateComponentCode(
|
|
34
|
+
* "01ABC123",
|
|
35
|
+
* "01DEF456",
|
|
36
|
+
* "MyPage",
|
|
37
|
+
* sliders,
|
|
38
|
+
* components,
|
|
39
|
+
* inputGroups,
|
|
40
|
+
* forms,
|
|
41
|
+
* selectInputs,
|
|
42
|
+
* actionButtons
|
|
43
|
+
* );
|
|
44
|
+
* fs.writeFileSync("MyPage.tsx", code);
|
|
45
|
+
*/
|
|
7
46
|
export declare function generateComponentCode(appId: string, pageId: string, componentName: string, sliders: SliderInfo[], standaloneComponents: ComponentInfo[], inputGroups: InputGroupInfo[], forms: FormInfo[], selectInputs: SelectInputInfo[], actionButtons: ActionButtonInfo[], isProduction?: boolean, pageMeta?: {
|
|
8
47
|
width?: number;
|
|
9
48
|
height?: number;
|
|
10
49
|
aspectRatio?: number;
|
|
11
50
|
}): string;
|
|
51
|
+
/**
|
|
52
|
+
* Generates README documentation for a generated component
|
|
53
|
+
*
|
|
54
|
+
* Creates comprehensive Markdown documentation explaining all props,
|
|
55
|
+
* events, and usage examples for the generated wrapper component.
|
|
56
|
+
*
|
|
57
|
+
* @param appId - Encore app ID
|
|
58
|
+
* @param pageId - Encore page ID
|
|
59
|
+
* @param appName - Human-readable app name
|
|
60
|
+
* @param pageName - Human-readable page name
|
|
61
|
+
* @param componentName - Generated component name
|
|
62
|
+
* @param sliders - Slider/list metadata
|
|
63
|
+
* @param standaloneComponents - Component metadata
|
|
64
|
+
* @param inputGroups - Input group metadata
|
|
65
|
+
* @param forms - Form metadata
|
|
66
|
+
* @param selectInputs - Select input metadata
|
|
67
|
+
* @param actionButtons - Action button metadata
|
|
68
|
+
* @returns Markdown documentation string
|
|
69
|
+
*/
|
|
12
70
|
export declare function generateReadme(appId: string, pageId: string, appName: string, pageName: string, componentName: string, sliders: SliderInfo[], standaloneComponents: ComponentInfo[], inputGroups: InputGroupInfo[], forms: FormInfo[], selectInputs: SelectInputInfo[], actionButtons: ActionButtonInfo[]): string;
|
|
71
|
+
/**
|
|
72
|
+
* Extracts component metadata for programmatic use
|
|
73
|
+
*
|
|
74
|
+
* Generates a simplified metadata object listing all props and events
|
|
75
|
+
* without the full code generation.
|
|
76
|
+
*
|
|
77
|
+
* @param _appName - App name (currently unused)
|
|
78
|
+
* @param pageName - Page name for component naming
|
|
79
|
+
* @param sliders - Slider metadata
|
|
80
|
+
* @param standaloneComponents - Component metadata
|
|
81
|
+
* @param inputGroups - Input group metadata
|
|
82
|
+
* @param forms - Form metadata
|
|
83
|
+
* @param selectInputs - Select input metadata
|
|
84
|
+
* @param actionButtons - Action button metadata
|
|
85
|
+
* @returns Component metadata object
|
|
86
|
+
*/
|
|
13
87
|
export declare function generateComponentMetadata(_appName: string, pageName: string, sliders: SliderInfo[], standaloneComponents: ComponentInfo[], inputGroups: InputGroupInfo[], forms: FormInfo[], selectInputs: SelectInputInfo[], actionButtons: ActionButtonInfo[]): ComponentMetadata;
|
|
14
88
|
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/codegen/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAOjB,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,UAAU,EAAE,EACrB,oBAAoB,EAAE,aAAa,EAAE,EACrC,WAAW,EAAE,cAAc,EAAE,EAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,aAAa,EAAE,gBAAgB,EAAE,EACjC,YAAY,GAAE,OAAe,EAC7B,QAAQ,CAAC,EAAE;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,MAAM,CAiaR;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,UAAU,EAAE,EACrB,oBAAoB,EAAE,aAAa,EAAE,EACrC,WAAW,EAAE,cAAc,EAAE,EAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,aAAa,EAAE,gBAAgB,EAAE,GAChC,MAAM,CAwVR;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,UAAU,EAAE,EACrB,oBAAoB,EAAE,aAAa,EAAE,EACrC,WAAW,EAAE,cAAc,EAAE,EAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,aAAa,EAAE,gBAAgB,EAAE,GAChC,iBAAiB,CAiEnB"}
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/codegen/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAOjB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,kCAAkC;IAClC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,UAAU,EAAE,EACrB,oBAAoB,EAAE,aAAa,EAAE,EACrC,WAAW,EAAE,cAAc,EAAE,EAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,aAAa,EAAE,gBAAgB,EAAE,EACjC,YAAY,GAAE,OAAe,EAC7B,QAAQ,CAAC,EAAE;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,MAAM,CAiaR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,UAAU,EAAE,EACrB,oBAAoB,EAAE,aAAa,EAAE,EACrC,WAAW,EAAE,cAAc,EAAE,EAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,aAAa,EAAE,gBAAgB,EAAE,GAChC,MAAM,CAwVR;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,UAAU,EAAE,EACrB,oBAAoB,EAAE,aAAa,EAAE,EACrC,WAAW,EAAE,cAAc,EAAE,EAC7B,KAAK,EAAE,QAAQ,EAAE,EACjB,YAAY,EAAE,eAAe,EAAE,EAC/B,aAAa,EAAE,gBAAgB,EAAE,GAChC,iBAAiB,CAiEnB"}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { ComponentInfo, SliderInfo, InputGroupInfo, FormInfo, SelectInputInfo, ActionButtonInfo } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Sanitizes a component name into a valid camelCase prop name
|
|
4
|
+
*
|
|
5
|
+
* Removes special characters, handles spaces, and converts to camelCase.
|
|
6
|
+
*
|
|
7
|
+
* @param name - Raw component name from Figma/design tool
|
|
8
|
+
* @returns Valid JavaScript property name
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* sanitizePropName("My Component!") // "myComponent"
|
|
12
|
+
* sanitizePropName("user-name") // "userName"
|
|
13
|
+
*/
|
|
2
14
|
export declare function sanitizePropName(name: string): string;
|
|
3
15
|
export declare function generateQualifiedPropName(componentName: string, parentPath: string[]): string;
|
|
4
16
|
/**
|
|
@@ -16,8 +28,35 @@ export declare function arraysEqual(a: string[], b: string[]): boolean;
|
|
|
16
28
|
export declare function getComponentPropType(componentType: string, _componentName: string): string;
|
|
17
29
|
export declare function getComponentPropName(componentType: string): string;
|
|
18
30
|
export declare function findSlidersAndDataBindings(pageData: any): SliderInfo[];
|
|
31
|
+
/**
|
|
32
|
+
* Finds standalone data-bound components (not in sliders)
|
|
33
|
+
*
|
|
34
|
+
* Locates components tagged with encore:data (but not encore:data:array)
|
|
35
|
+
* for standalone data binding at the page level.
|
|
36
|
+
*
|
|
37
|
+
* @param pageData - Page definition from Encore service
|
|
38
|
+
* @returns Array of component metadata
|
|
39
|
+
*/
|
|
19
40
|
export declare function findStandaloneComponents(pageData: any): ComponentInfo[];
|
|
41
|
+
/**
|
|
42
|
+
* Finds input groups (radio button-like components) in the page
|
|
43
|
+
*
|
|
44
|
+
* Locates stateful sets tagged with encore:input-group for coordinated
|
|
45
|
+
* selection behavior.
|
|
46
|
+
*
|
|
47
|
+
* @param pageData - Page definition from Encore service
|
|
48
|
+
* @returns Array of input group metadata
|
|
49
|
+
*/
|
|
20
50
|
export declare function findInputGroups(pageData: any): InputGroupInfo[];
|
|
51
|
+
/**
|
|
52
|
+
* Finds forms and their input fields in the page
|
|
53
|
+
*
|
|
54
|
+
* Locates containers tagged with encore:form and extracts all input
|
|
55
|
+
* components within them for form submission handling.
|
|
56
|
+
*
|
|
57
|
+
* @param pageData - Page definition from Encore service
|
|
58
|
+
* @returns Array of form metadata with input fields
|
|
59
|
+
*/
|
|
21
60
|
export declare function findForms(pageData: any): FormInfo[];
|
|
22
61
|
/**
|
|
23
62
|
* Finds standalone select input components (input-select) that are NOT inside forms.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/codegen/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/codegen/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,QAAQ,EACR,eAAe,EACf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0BrD;AAED,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAAE,GACnB,MAAM,CA8BR;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAAE,EAClB,UAAU,EAAE,MAAM,EAAE,EAAE,GACrB,MAAM,EAAE,CA6DV;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAG7D;AAED,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACrB,MAAM,CAgBR;AAED,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAQlE;AAED,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,GAAG,GAAG,UAAU,EAAE,CAoOtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,GAAG,GAAG,aAAa,EAAE,CAuGvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,GAAG,GAAG,cAAc,EAAE,CA0D/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,EAAE,CAkJnD;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,GAAG,EACb,KAAK,EAAE,QAAQ,EAAE,GAChB,eAAe,EAAE,CAqEnB;AASD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,GAAG,GAAG,gBAAgB,EAAE,CAgFnE;AASD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAIzD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable prop name qualification utilities
|
|
3
|
+
*
|
|
4
|
+
* When multiple components/inputs have the same base prop name,
|
|
5
|
+
* this module provides utilities to make each name unique by using
|
|
6
|
+
* minimal distinguishing parent paths.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Base interface for items that can have their prop names qualified
|
|
10
|
+
*/
|
|
11
|
+
export interface QualifiableItem {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
propName: string;
|
|
15
|
+
_parentPath?: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Qualifies duplicate prop names using minimal distinguishing paths.
|
|
19
|
+
*
|
|
20
|
+
* When multiple components have the same prop name, this function
|
|
21
|
+
* finds the shortest parent path segment that makes each name unique.
|
|
22
|
+
*
|
|
23
|
+
* Algorithm:
|
|
24
|
+
* 1. Group items by base prop name
|
|
25
|
+
* 2. For each group with duplicates:
|
|
26
|
+
* a. Find minimal distinguishing paths
|
|
27
|
+
* b. Iteratively expand paths if duplicates remain
|
|
28
|
+
* c. Apply numeric suffixes if paths are identical
|
|
29
|
+
*
|
|
30
|
+
* @param items - Components/inputs to qualify (will be modified in place)
|
|
31
|
+
* @returns The same items array with qualified propName values
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const items = [
|
|
35
|
+
* { id: '1', name: 'Title', propName: 'title', _parentPath: ['Header'] },
|
|
36
|
+
* { id: '2', name: 'Title', propName: 'title', _parentPath: ['Footer'] }
|
|
37
|
+
* ];
|
|
38
|
+
* qualifyPropNames(items);
|
|
39
|
+
* // Result: items[0].propName = 'headerTitle', items[1].propName = 'footerTitle'
|
|
40
|
+
*/
|
|
41
|
+
export declare function qualifyPropNames<T extends QualifiableItem>(items: T[]): T[];
|
|
42
|
+
//# sourceMappingURL=propQualification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propQualification.d.ts","sourceRoot":"","sources":["../../../src/codegen/propQualification.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAqOD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,eAAe,EACxD,KAAK,EAAE,CAAC,EAAE,GACT,CAAC,EAAE,CAUL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicComponent.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"DynamicComponent.d.ts","sourceRoot":"","sources":["../../../src/components/DynamicComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;;AA8BF,wBAA4C"}
|
|
@@ -1,31 +1,84 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import type { EncoreActionPayload } from "../contexts/EncoreActionContext";
|
|
3
|
+
/**
|
|
4
|
+
* Props for the EncoreApp component
|
|
5
|
+
*/
|
|
6
|
+
export type EncoreAppProps = {
|
|
7
|
+
/** Unique identifier for the Encore app */
|
|
4
8
|
appId: string;
|
|
9
|
+
/** Unique identifier for the page to render. If not provided, shows page selector UI */
|
|
5
10
|
pageId?: string;
|
|
11
|
+
/** Optional component identifier for context tracking */
|
|
6
12
|
componentId?: string;
|
|
13
|
+
/** Fallback UI to show during component loading */
|
|
7
14
|
fallback?: React.ReactNode;
|
|
15
|
+
/** Callback fired when the container size changes */
|
|
8
16
|
onSizeChange?: (size: {
|
|
9
17
|
width: number;
|
|
10
18
|
height: number;
|
|
11
19
|
}) => void;
|
|
20
|
+
/** Callback fired when the content size changes (including overflow) */
|
|
12
21
|
onContentSizeChange?: (size: {
|
|
13
22
|
width: number;
|
|
14
23
|
height: number;
|
|
15
24
|
}) => void;
|
|
25
|
+
/** Callback fired when user interactions trigger actions (button clicks, form submissions, etc.) */
|
|
16
26
|
onAction?: (payload: EncoreActionPayload) => void | Promise<void>;
|
|
27
|
+
/** Data bindings for components with encore:data tags. Maps component IDs to display values */
|
|
17
28
|
data?: Record<string, string | number | any[]>;
|
|
29
|
+
/** Force component loading from "remote" CDN or "local" filesystem */
|
|
18
30
|
source?: "remote" | "local";
|
|
31
|
+
/** Control repeating containers (sliders, lists) programmatically by container ID */
|
|
19
32
|
repeatingContainerControls?: Record<string, {
|
|
20
33
|
currentIndex?: number;
|
|
21
34
|
onIndexChange?: (index: number) => void;
|
|
22
35
|
}>;
|
|
36
|
+
/** Control input groups (radio button-like behavior). Maps group name to active element */
|
|
23
37
|
inputGroups?: Record<string, string>;
|
|
38
|
+
/** Base URL for the Encore service API */
|
|
24
39
|
baseURL?: string;
|
|
40
|
+
/** Provide app definition directly instead of fetching (for offline/bundled deployments) */
|
|
25
41
|
appDefinition?: any;
|
|
42
|
+
/** Provide page definition directly instead of fetching (for offline/bundled deployments) */
|
|
26
43
|
pageDefinition?: any;
|
|
44
|
+
/** Provide component code directly instead of fetching (for offline/bundled deployments) */
|
|
27
45
|
componentCode?: string;
|
|
28
46
|
};
|
|
47
|
+
type Props = EncoreAppProps;
|
|
48
|
+
/**
|
|
49
|
+
* Main Encore runtime component
|
|
50
|
+
*
|
|
51
|
+
* Loads and renders Encore Studio apps dynamically from the Encore service.
|
|
52
|
+
* Handles data fetching, font loading, real-time updates, and component rendering.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Basic usage
|
|
56
|
+
* <EncoreApp appId="01ABC123" pageId="01DEF456" />
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // With data binding
|
|
60
|
+
* <EncoreApp
|
|
61
|
+
* appId="01ABC123"
|
|
62
|
+
* pageId="01DEF456"
|
|
63
|
+
* data={{
|
|
64
|
+
* "title-component": { text: "Hello World" }
|
|
65
|
+
* }}
|
|
66
|
+
* />
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Controlling a slider
|
|
70
|
+
* const [slideIndex, setSlideIndex] = useState(0);
|
|
71
|
+
* <EncoreApp
|
|
72
|
+
* appId="01ABC123"
|
|
73
|
+
* pageId="01DEF456"
|
|
74
|
+
* repeatingContainerControls={{
|
|
75
|
+
* "slider-123": {
|
|
76
|
+
* currentIndex: slideIndex,
|
|
77
|
+
* onIndexChange: setSlideIndex
|
|
78
|
+
* }
|
|
79
|
+
* }}
|
|
80
|
+
* />
|
|
81
|
+
*/
|
|
29
82
|
declare const EncoreApp: ({ appId, pageId, componentId, fallback, onSizeChange, onContentSizeChange, onAction, data, source, repeatingContainerControls, inputGroups, baseURL, appDefinition, pageDefinition, componentCode, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
30
83
|
export default EncoreApp;
|
|
31
84
|
//# sourceMappingURL=EncoreApp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EncoreApp.d.ts","sourceRoot":"","sources":["../../../src/components/EncoreApp.tsx"],"names":[],"mappings":"AAIA,OAAO,KAON,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"EncoreApp.d.ts","sourceRoot":"","sources":["../../../src/components/EncoreApp.tsx"],"names":[],"mappings":"AAIA,OAAO,KAON,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AA4B3E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,qDAAqD;IACrD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjE,wEAAwE;IACxE,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACxE,oGAAoG;IACpG,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,+FAA+F;IAC/F,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC;IAC/C,sEAAsE;IACtE,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC5B,qFAAqF;IACrF,0BAA0B,CAAC,EAAE,MAAM,CACjC,MAAM,EACN;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,CACnE,CAAC;IACF,2FAA2F;IAC3F,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4FAA4F;IAC5F,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,6FAA6F;IAC7F,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,KAAK,KAAK,GAAG,cAAc,CAAC;AAe5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,QAAA,MAAM,SAAS,GAAI,sMAgBhB,KAAK,4CA+QP,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context provider composition component
|
|
3
|
+
*
|
|
4
|
+
* Wraps children with all necessary Encore contexts in the correct order.
|
|
5
|
+
* This reduces nesting in the main EncoreApp component.
|
|
6
|
+
*/
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { type EncoreActionPayload } from "../contexts/EncoreActionContext";
|
|
9
|
+
interface EncoreContextProvidersProps {
|
|
10
|
+
componentId?: string;
|
|
11
|
+
onAction?: (payload: EncoreActionPayload) => void | Promise<void>;
|
|
12
|
+
repeatingContainerContextValue: any;
|
|
13
|
+
bindingContextValue: any;
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Composes all Encore context providers
|
|
18
|
+
*
|
|
19
|
+
* Provides a cleaner way to wrap content with multiple contexts
|
|
20
|
+
* instead of deeply nested Provider components.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <EncoreContextProviders
|
|
24
|
+
* componentId={componentId}
|
|
25
|
+
* onAction={onAction}
|
|
26
|
+
* repeatingContainerContextValue={containerContextValue}
|
|
27
|
+
* bindingContextValue={bindingContext}
|
|
28
|
+
* >
|
|
29
|
+
* <DynamicComponent />
|
|
30
|
+
* </EncoreContextProviders>
|
|
31
|
+
*/
|
|
32
|
+
export declare function EncoreContextProviders({ componentId, onAction, repeatingContainerContextValue, bindingContextValue, children, }: EncoreContextProvidersProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=EncoreContextProviders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EncoreContextProviders.d.ts","sourceRoot":"","sources":["../../../src/components/EncoreContextProviders.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAA4B,EAC1B,KAAK,mBAAmB,EACzB,MAAM,iCAAiC,CAAC;AAIzC,UAAU,2BAA2B;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,8BAA8B,EAAE,GAAG,CAAC;IACpC,mBAAmB,EAAE,GAAG,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,WAAW,EACX,QAAQ,EACR,8BAA8B,EAC9B,mBAAmB,EACnB,QAAQ,GACT,EAAE,2BAA2B,2CAc7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AACA,OAAO,KAMN,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/components.tsx"],"names":[],"mappings":"AACA,OAAO,KAMN,MAAM,OAAO,CAAC;AAmkGf,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAoDxD,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook for loading fonts from app definition
|
|
3
|
+
*
|
|
4
|
+
* Handles FontFace API loading of custom fonts declared in the app JSON.
|
|
5
|
+
* Skips fonts marked as broken and provides debug logging in development.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Loads fonts declared in app definition using the FontFace API
|
|
9
|
+
*
|
|
10
|
+
* @param appData - App definition containing fonts array
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const { data: appData } = useSWR(appUrl, fetcher);
|
|
14
|
+
* useFontLoader(appData);
|
|
15
|
+
*/
|
|
16
|
+
export declare function useFontLoader(appData: unknown): void;
|
|
17
|
+
//# sourceMappingURL=useFontLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFontLoader.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFontLoader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,QAqD7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePusherUpdates.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePusherUpdates.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"usePusherUpdates.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePusherUpdates.ts"],"names":[],"mappings":"AAGA,OAAO,MAAM,MAAM,WAAW,CAAC;AAW/B,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CAAC;AAWF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,MAAM,EACN,OAAc,EACd,QAAQ,GACT,EAAE,uBAAuB;;;EA4GzB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook for managing repeating container controls
|
|
3
|
+
*
|
|
4
|
+
* Handles slider/list index management and synchronization between
|
|
5
|
+
* parent-provided controls and internal component state.
|
|
6
|
+
*/
|
|
7
|
+
import type { RepeatingContainerControl } from "../contexts/EncoreRepeatingContainerContext";
|
|
8
|
+
interface ContainerControlProps {
|
|
9
|
+
currentIndex?: number;
|
|
10
|
+
onIndexChange?: (index: number) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Manages repeating container (slider/list) controls
|
|
14
|
+
*
|
|
15
|
+
* @param externalControls - Optional controls passed from parent component
|
|
16
|
+
* @returns Context value for EncoreRepeatingContainerContext
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const containerContextValue = useRepeatingContainers(repeatingContainerControls);
|
|
20
|
+
* <EncoreRepeatingContainerContext.Provider value={containerContextValue}>
|
|
21
|
+
*/
|
|
22
|
+
export declare function useRepeatingContainers(externalControls?: Record<string, ContainerControlProps>): {
|
|
23
|
+
registerContainer: (id: string, control: RepeatingContainerControl) => void;
|
|
24
|
+
unregisterContainer: (id: string) => void;
|
|
25
|
+
getControl: (id: string) => RepeatingContainerControl | undefined;
|
|
26
|
+
setControlProps: (id: string, props: ContainerControlProps | ((prev: ContainerControlProps) => ContainerControlProps)) => void;
|
|
27
|
+
getControlProps: (id: string) => ContainerControlProps | undefined;
|
|
28
|
+
_propsVersion: number;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=useRepeatingContainers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRepeatingContainers.d.ts","sourceRoot":"","sources":["../../../src/hooks/useRepeatingContainers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAE7F,UAAU,qBAAqB;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC;4BA+CjD,MAAM,WAAW,yBAAyB;8BAUJ,MAAM;qBAS5C,MAAM;0BAQL,MAAM,SAEN,qBAAqB,GACrB,CAAC,CAAC,IAAI,EAAE,qBAAqB,KAAK,qBAAqB,CAAC;0BAczD,MAAM;;EA4Bd"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -6,5 +6,7 @@ import EncoreBindingContext from "./contexts/EncoreBindingContext";
|
|
|
6
6
|
import useEncoreState from "./stores/useEncoreState";
|
|
7
7
|
import { PACKAGE_VERSION } from "./version";
|
|
8
8
|
export { EncoreApp, EncoreErrorBoundary, EncoreLoadingFallback, EncoreAppContext, EncoreBindingContext, useEncoreState, PACKAGE_VERSION, };
|
|
9
|
+
export type { EncoreAppProps } from "./components/EncoreApp";
|
|
10
|
+
export type { EncoreActionPayload } from "./contexts/EncoreActionContext";
|
|
9
11
|
export * from "./codegen";
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,mBAAmB,MAAM,kCAAkC,CAAC;AACnE,OAAO,qBAAqB,MAAM,oCAAoC,CAAC;AACvE,OAAO,gBAAgB,MAAM,6BAA6B,CAAC;AAC3D,OAAO,oBAAoB,MAAM,iCAAiC,CAAC;AACnE,OAAO,cAAc,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,eAAe,GAChB,CAAC;AAGF,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,YAAY,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Data patching utilities for fixing layout and component issues
|
|
3
|
+
*
|
|
4
|
+
* Applies heuristic-based fixes to page data to correct common layout problems
|
|
5
|
+
* that occur during the Figma-to-Encore conversion process.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Recursively patches page data to fix layout issues
|
|
9
|
+
*
|
|
10
|
+
* Current heuristics:
|
|
11
|
+
* 1. Horizontal layout detection - If children widths sum to ~100% or ~375px,
|
|
12
|
+
* force HORIZONTAL layout mode to prevent vertical stacking
|
|
13
|
+
*
|
|
14
|
+
* @param clientData - The client data object from page definition
|
|
15
|
+
* @returns Patched client data (mutates in place)
|
|
16
|
+
*/
|
|
17
|
+
export declare function patchPageData(clientData: any): any;
|
|
18
|
+
//# sourceMappingURL=dataPatching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataPatching.d.ts","sourceRoot":"","sources":["../../../src/lib/dataPatching.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,CA0DlD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamicModules.d.ts","sourceRoot":"","sources":["../../../src/lib/dynamicModules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamicModules.d.ts","sourceRoot":"","sources":["../../../src/lib/dynamicModules.ts"],"names":[],"mappings":"AAWA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAuGvD;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,gBAoE1C;AAOD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|