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

65 lines 2.41 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MessageChannelService = void 0; /** * Copyright (c) 2020, 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 */ const api_1 = require("@webruntime/api"); const compiler_1 = require("@webruntime/compiler"); const rollup_plugin_salesforce_message_channel_1 = __importDefault(require("./rollup-plugin-salesforce-message-channel")); const URI = `/:uid/:mode/:locale/@salesforce/messageChannel/:messageChannel`; /** * MessageChannelService * * This is an AddressableService because we cannot inline message channel modules into a view. * They need to be shared across views and registered by the framework. */ class MessageChannelService extends api_1.AddressableService { constructor() { super(URI); } initialize() { // noop } toSpecifier(url) { const { messageChannel } = this.parseUrl(url); return `@salesforce/messageChannel/${messageChannel}`; } get mappings() { return { '@salesforce/messageChannel/': `/:uid/:mode/:locale/@salesforce/messageChannel/`, }; } async request(specifier, params, context) { const { compilerConfig } = context; // Compile the module by calling the plugin to generate the code const files = {}; files[`${specifier}.js`] = rollup_plugin_salesforce_message_channel_1.default().load(specifier); const { result, success, diagnostics, metadata } = await compiler_1.compile({ ...compilerConfig, name: specifier, namespace: '', files, }); return { type: 'component', specifier, resource: result, success, metadata, diagnostics, }; } // Just in the case in the future there are more apps, and they want to inline messageChannels getPlugin() { return rollup_plugin_salesforce_message_channel_1.default; } } exports.MessageChannelService = MessageChannelService; //# sourceMappingURL=salesforce-message-channel-service.js.map