UNPKG

@communities-webruntime/services

Version:

If you would like to run Lightning Web Runtime without the CLI, we expose some of our programmatic APIs available in Node.js. If you're looking for the CLI documentation [you can find that here](https://www.npmjs.com/package/@communities-webruntime/cli).

48 lines 2.17 kB
/** * Copyright (c) 2019, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: MIT * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT */ import { API_PATH_PREFIX, PUBLIC_API_PATH_PREFIX } from '@communities-webruntime/common'; import { ContextService } from '../context/context-service.js'; import { MetadataService } from '../metadata/metadata-service.js'; const { getBrandingTokenMap, getRoutes, getViewToThemeLayoutMap, getLocales } = MetadataService; const { getContext } = ContextService; export function getModuleValues(locale) { const { appOverrides, basePath, isDesignMode, isMobileAppMode } = getContext(); const { inlineModuleOverrides } = appOverrides; const values = { '@app/authenticationCookieName': null, '@app/basePath': `"${basePath}"`, '@app/apiBasePath': `"${basePath}${API_PATH_PREFIX}/${locale}"`, '@app/publicApiBasePath': `"${basePath}${PUBLIC_API_PATH_PREFIX}/${locale}"`, '@app/routes': getRoutes(), '@app/brandingProperties': getBrandingTokenMap(), '@app/guestUuidCookieName': '"guest_uuid_essential"', '@app/isDesignMode': isDesignMode, '@app/isPreviewMode': isDesignMode, '@app/isMobileAppMode': isMobileAppMode, '@app/viewToThemeLayoutMap': getViewToThemeLayoutMap(), '@salesforce/commerce/webstoreId': '"webstoreId"', '@salesforce/community/basePath': `"${basePath}"`, '@salesforce/site/Id': '"siteId"', '@salesforce/user/isGuest': true, '@salesforce/user/Id': null, '@salesforce/site/activeLanguages': getLocales(), ...inlineModuleOverrides, }; Object.keys(values).forEach((name) => { const value = values[name]; values[name] = typeof value === 'string' ? value : JSON.stringify(value); }); return values; } export function generateModules(locale = 'en-US') { const modules = getModuleValues(locale); for (const [key, code] of Object.entries(modules)) { modules[key] = `export default ${code};`; } return modules; } //# sourceMappingURL=app-modules.js.map