| 1 |
type TablebergConfig = { |
| 2 |
plugin_url?: string; |
| 3 |
IS_PRO?: boolean; |
| 4 |
}; |
| 5 |
|
| 6 |
export function getTablebergConfig(): TablebergConfig { |
| 7 |
if (typeof globalThis !== "undefined") { |
| 8 |
const globalConfig = ( |
| 9 |
globalThis as typeof globalThis & { |
| 10 |
TABLEBERG_CFG?: TablebergConfig; |
| 11 |
} |
| 12 |
).TABLEBERG_CFG; |
| 13 |
|
| 14 |
if (globalConfig) { |
| 15 |
return globalConfig; |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
if (typeof window !== "undefined") { |
| 20 |
try { |
| 21 |
const parentConfig = ( |
| 22 |
window.parent as Window & { |
| 23 |
TABLEBERG_CFG?: TablebergConfig; |
| 24 |
} |
| 25 |
)?.TABLEBERG_CFG; |
| 26 |
|
| 27 |
if (parentConfig) { |
| 28 |
return parentConfig; |
| 29 |
} |
| 30 |
} catch { |
| 31 |
// Cross-frame access can fail; fall back to defaults. |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
return {}; |
| 36 |
} |
| 37 |
|
| 38 |
export function isProAvailable() { |
| 39 |
return Boolean(getTablebergConfig().IS_PRO); |
| 40 |
} |
| 41 |
|