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).

61 lines 2.27 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 * as path from 'path'; import { hashContent } from '@lwrjs/shared-utils'; import { ContextService } from '../context/context-service.js'; import { generateModules } from './app-modules.js'; const { getContext } = ContextService; /** * This service provides generated modules for Communities apps */ export default class CommunitiesAppService { constructor() { this.name = 'communities-app-provider'; this.version = '1'; this.modules = generateModules(); } async getModuleEntry({ specifier }) { const { appOverrides } = getContext(); const { inlineModuleOverrides } = appOverrides; if (specifier.startsWith('@app/') || specifier.startsWith('@salesforce/user/') || specifier === '@salesforce/commerce/webstoreId' || specifier === '@salesforce/community/basePath' || specifier === '@salesforce/site/Id' || specifier === '@salesforce/site/activeLanguages' || (inlineModuleOverrides && inlineModuleOverrides[specifier])) { return { id: `${specifier}|${this.version}`, virtual: true, entry: `<virtual>/${specifier}${path.extname(specifier.replace(/\./g, '-')) ? '' : '.js'}`, specifier, version: this.version, }; } } async getModule({ specifier, namespace, name = specifier, }) { // Retrieve the Module Entry const moduleEntry = await this.getModuleEntry({ specifier }); if (!moduleEntry) { return; } // Generate code for the requested module const originalSource = this.modules[specifier]; return { id: moduleEntry.id, specifier, namespace, name, version: this.version, originalSource, moduleEntry, ownHash: hashContent(originalSource), compiledSource: originalSource, }; } } //# sourceMappingURL=app-provider.js.map