@intlayer/config
Version:
Retrieve Intlayer configurations and manage environment variables for both server-side and client-side environments.
1 lines • 2.77 kB
Source Map (JSON)
{"version":3,"file":"built.browser.cjs","names":[],"sources":["../../src/built.browser.ts"],"sourcesContent":["/**\n * @intlayer/config/built — browser build\n *\n * In browser bundles this module is selected automatically via the `browser`\n * export condition in package.json (supported by Vite, webpack, Rollup, etc.).\n *\n * Configuration is resolved at *access time* (lazy) from `window.INTLAYER_CONFIG`\n * so that it works both when:\n *\n * - A build plugin (vite-intlayer / withIntlayer) injects the value via\n * bundler `define` (static replacement at build time), OR\n * - The application calls `installIntlayer(config)` at runtime before any\n * config field is first accessed.\n */\nimport type { IntlayerConfig } from '@intlayer/types/config';\n// This import brings in the `declare global { interface Window { INTLAYER_CONFIG } }` augmentation\nimport type {} from './configFile/buildBrowserConfiguration';\n\n/**\n * Proxy that reads each top-level key from `window.INTLAYER_CONFIG` lazily.\n * This avoids the module-evaluation timing issue: the proxy is safe to import\n * at the top of any file because the actual `window.INTLAYER_CONFIG` value is\n * only read when a property is first accessed.\n */\nconst configuration = new Proxy({} as IntlayerConfig, {\n get(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return (config as Record<string, unknown> | undefined)?.[prop];\n },\n has(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return config != null && prop in config;\n },\n});\n\nexport const internationalization = configuration.internationalization;\nexport const dictionary = configuration.dictionary;\nexport const routing = configuration.routing;\nexport const content = configuration.content;\nexport const system = configuration.system;\nexport const editor = configuration.editor;\nexport const log = configuration.log;\nexport const ai = configuration.ai;\nexport const build = configuration.build;\nexport const compiler = configuration.compiler;\nexport const schemas = configuration.schemas;\nexport const plugins = configuration.plugins;\n\nexport default configuration;\n"],"mappings":";;;;;;;;;AAwBA,MAAM,gBAAgB,IAAI,MAAM,EAAE,EAAoB;CACpD,IAAI,SAAS,MAAc;AAGzB,UADE,OAAO,WAAW,cAAc,OAAO,kBAAkB,UACF;;CAE3D,IAAI,SAAS,MAAc;EACzB,MAAM,SACJ,OAAO,WAAW,cAAc,OAAO,kBAAkB;AAC3D,SAAO,UAAU,QAAQ,QAAQ;;CAEpC,CAAC;AAEF,MAAa,uBAAuB,cAAc;AAClD,MAAa,aAAa,cAAc;AACxC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc;AACrC,MAAa,SAAS,cAAc;AACpC,MAAa,SAAS,cAAc;AACpC,MAAa,MAAM,cAAc;AACjC,MAAa,KAAK,cAAc;AAChC,MAAa,QAAQ,cAAc;AACnC,MAAa,WAAW,cAAc;AACtC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc"}