diff --git a/src/generators/lightningEmbeddingGenerator.ts b/src/generators/uiEmbeddingGenerator.ts similarity index 78% rename from src/generators/lightningEmbeddingGenerator.ts rename to src/generators/uiEmbeddingGenerator.ts index 1450dfe8..a945d0f8 100644 --- a/src/generators/lightningEmbeddingGenerator.ts +++ b/src/generators/uiEmbeddingGenerator.ts @@ -10,17 +10,17 @@ import * as path from 'path'; import { nls } from '../i18n'; import { CreateUtil } from '../utils'; import { - isAllowedLightningEmbeddingSrcUrl, - LIGHTNING_EMBEDDING_SANDBOX_TOKENS, -} from '../utils/lightningEmbedding'; -import { LightningEmbeddingOptions } from '../utils/types'; + isAllowedUIEmbeddingSrcUrl, + UI_EMBEDDING_SANDBOX_TOKENS, +} from '../utils/uiEmbedding'; +import { UIEmbeddingOptions } from '../utils/types'; import { BaseGenerator } from './baseGenerator'; const VALID_SANDBOX_TOKENS: ReadonlySet = new Set( - LIGHTNING_EMBEDDING_SANDBOX_TOKENS + UI_EMBEDDING_SANDBOX_TOKENS ); -export default class LightningEmbeddingGenerator extends BaseGenerator { +export default class UIEmbeddingGenerator extends BaseGenerator { public validateOptions(): void { CreateUtil.checkInputs(this.options.componentname); @@ -29,27 +29,27 @@ export default class LightningEmbeddingGenerator extends BaseGenerator !VALID_SANDBOX_TOKENS.has(t)); if (invalid.length) { throw new Error( - nls.localize('InvalidLightningEmbeddingSandboxToken', [ + nls.localize('InvalidUIEmbeddingSandboxToken', [ invalid.join(', '), [...VALID_SANDBOX_TOKENS].join(', '), ]) @@ -67,7 +67,7 @@ export default class LightningEmbeddingGenerator extends BaseGenerator base component.', }; diff --git a/src/index.ts b/src/index.ts index 31821d07..92353403 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,4 +9,4 @@ import { TemplateService } from './service/templateService'; export { TemplateService }; export * from './utils/types'; export * from './utils/createUtil'; -export * from './utils/lightningEmbedding'; +export * from './utils/uiEmbedding'; diff --git a/src/templates/lightningembedding/default/default.css b/src/templates/uiembedding/default/default.css similarity index 100% rename from src/templates/lightningembedding/default/default.css rename to src/templates/uiembedding/default/default.css diff --git a/src/templates/lightningembedding/default/default.html b/src/templates/uiembedding/default/default.html similarity index 53% rename from src/templates/lightningembedding/default/default.html rename to src/templates/uiembedding/default/default.html index 00e45621..a3340ccf 100644 --- a/src/templates/lightningembedding/default/default.html +++ b/src/templates/uiembedding/default/default.html @@ -1,7 +1,7 @@ diff --git a/src/templates/lightningembedding/default/default.js b/src/templates/uiembedding/default/default.js similarity index 78% rename from src/templates/lightningembedding/default/default.js rename to src/templates/uiembedding/default/default.js index 74fc4387..f55f7d35 100644 --- a/src/templates/lightningembedding/default/default.js +++ b/src/templates/uiembedding/default/default.js @@ -1,5 +1,5 @@ import { LightningElement } from 'lwc'; export default class <%= pascalCaseComponentName %> extends LightningElement { - widgetUrl = '<%= src %>'; + embeddingUrl = '<%= src %>'; } diff --git a/src/templates/lightningembedding/default/default.js-meta.xml b/src/templates/uiembedding/default/default.js-meta.xml similarity index 100% rename from src/templates/lightningembedding/default/default.js-meta.xml rename to src/templates/uiembedding/default/default.js-meta.xml diff --git a/src/utils/types.ts b/src/utils/types.ts index 9b1474b8..76a51484 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -11,7 +11,7 @@ import ApexTriggerGenerator from '../generators/apexTriggerGenerator'; import FlexipageGenerator from '../generators/flexipageGenerator'; import LightningAppGenerator from '../generators/lightningAppGenerator'; import LightningComponentGenerator from '../generators/lightningComponentGenerator'; -import LightningEmbeddingGenerator from '../generators/lightningEmbeddingGenerator'; +import UIEmbeddingGenerator from '../generators/uiEmbeddingGenerator'; import LightningEventGenerator from '../generators/lightningEventGenerator'; import LightningInterfaceGenerator from '../generators/lightningInterfaceGenerator'; import LightningTestGenerator from '../generators/lightningTestGenerator'; @@ -52,7 +52,7 @@ export type Generators = | typeof LightningTestGenerator | typeof LightningInterfaceGenerator | typeof DigitalExperienceSiteGenerator - | typeof LightningEmbeddingGenerator + | typeof UIEmbeddingGenerator | typeof ProjectGenerator | typeof StaticResourceGenerator | typeof VisualforceComponentGenerator @@ -77,7 +77,7 @@ export enum TemplateType { LightningInterface, LightningTest, DigitalExperienceSite, - LightningEmbedding, + UIEmbedding, Project, VisualforceComponent, VisualforcePage, @@ -96,7 +96,7 @@ export const generators = new Map>([ [TemplateType.LightningInterface, LightningInterfaceGenerator], [TemplateType.LightningTest, LightningTestGenerator], [TemplateType.DigitalExperienceSite, DigitalExperienceSiteGenerator], - [TemplateType.LightningEmbedding, LightningEmbeddingGenerator], + [TemplateType.UIEmbedding, UIEmbeddingGenerator], [TemplateType.Project, ProjectGenerator], [TemplateType.StaticResource, StaticResourceGenerator], [TemplateType.VisualforceComponent, VisualforceComponentGenerator], @@ -196,7 +196,7 @@ export interface LightningTestOptions extends TemplateOptions { internal: boolean; } -export interface LightningEmbeddingOptions extends TemplateOptions { +export interface UIEmbeddingOptions extends TemplateOptions { componentname: string; src: string; sandbox: string; diff --git a/src/utils/lightningEmbedding.ts b/src/utils/uiEmbedding.ts similarity index 73% rename from src/utils/lightningEmbedding.ts rename to src/utils/uiEmbedding.ts index 142bde02..2946d115 100644 --- a/src/utils/lightningEmbedding.ts +++ b/src/utils/uiEmbedding.ts @@ -6,10 +6,10 @@ */ /** - * W3C-defined iframe sandbox tokens accepted by the lightning-embedding wrapper template. + * W3C-defined iframe sandbox tokens accepted by the UI embedding wrapper template. * Exposed so CLI plugins can derive their flag `options` list from a single source of truth. */ -export const LIGHTNING_EMBEDDING_SANDBOX_TOKENS = [ +export const UI_EMBEDDING_SANDBOX_TOKENS = [ 'allow-forms', 'allow-modals', 'allow-orientation-lock', @@ -24,15 +24,15 @@ export const LIGHTNING_EMBEDDING_SANDBOX_TOKENS = [ 'allow-top-navigation-by-user-activation', ] as const; -export type LightningEmbeddingSandboxToken = - (typeof LIGHTNING_EMBEDDING_SANDBOX_TOKENS)[number]; +export type UIEmbeddingSandboxToken = + (typeof UI_EMBEDDING_SANDBOX_TOKENS)[number]; /** * Returns true if `src` is an absolute URL acceptable as the iframe source on the - * lightning-embedding wrapper. https is accepted everywhere; plain http is permitted + * UI embedding wrapper. https is accepted everywhere; plain http is permitted * only for localhost / 127.0.0.1 to support local development servers. */ -export function isAllowedLightningEmbeddingSrcUrl(src: string): boolean { +export function isAllowedUIEmbeddingSrcUrl(src: string): boolean { let parsed: URL; try { parsed = new URL(src); diff --git a/test/generators/lightningEmbeddingGenerator.test.ts b/test/generators/uiEmbeddingGenerator.test.ts similarity index 86% rename from test/generators/lightningEmbeddingGenerator.test.ts rename to test/generators/uiEmbeddingGenerator.test.ts index b00ea47f..de118151 100644 --- a/test/generators/lightningEmbeddingGenerator.test.ts +++ b/test/generators/uiEmbeddingGenerator.test.ts @@ -9,7 +9,7 @@ import * as chai from 'chai'; import * as fs from 'fs'; import * as path from 'path'; import { TemplateService, TemplateType } from '../../src'; -import LightningEmbeddingGenerator from '../../src/generators/lightningEmbeddingGenerator'; +import UIEmbeddingGenerator from '../../src/generators/uiEmbeddingGenerator'; import { getDefaultApiVersion } from '../../src/generators/baseGenerator'; chai.config.truncateThreshold = 100000; @@ -32,7 +32,7 @@ function assertFileContent(file: string, needle: string | RegExp) { .be.true; } -describe('LightningEmbeddingGenerator', () => { +describe('UIEmbeddingGenerator', () => { const apiVersion = getDefaultApiVersion(); const lwcOutputDir = path.join('testsoutput', 'lwc'); const nonLwcOutputDir = path.join('testsoutput', 'embedding'); @@ -46,7 +46,7 @@ describe('LightningEmbeddingGenerator', () => { it('should throw when componentname is empty', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: '', src: 'https://app.example.com', sandbox: 'allow-scripts', @@ -60,7 +60,7 @@ describe('LightningEmbeddingGenerator', () => { it('should throw when not internal and outputdir is missing lwc parent', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'https://app.example.com', sandbox: 'allow-scripts', @@ -74,7 +74,7 @@ describe('LightningEmbeddingGenerator', () => { it('should accept http src on localhost', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'http://localhost:3000', sandbox: 'allow-scripts', @@ -88,7 +88,7 @@ describe('LightningEmbeddingGenerator', () => { it('should accept http src on 127.0.0.1', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'http://127.0.0.1:8080', sandbox: 'allow-scripts', @@ -102,7 +102,7 @@ describe('LightningEmbeddingGenerator', () => { it('should reject http src on non-localhost host', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'http://app.example.com', sandbox: 'allow-scripts', @@ -116,7 +116,7 @@ describe('LightningEmbeddingGenerator', () => { it('should reject non-URL src', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'not a url', sandbox: 'allow-scripts', @@ -130,7 +130,7 @@ describe('LightningEmbeddingGenerator', () => { it('should reject non-http(s) protocols', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'ftp://example.com', sandbox: 'allow-scripts', @@ -144,7 +144,7 @@ describe('LightningEmbeddingGenerator', () => { it('should reject empty shellTitle', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'https://app.example.com', sandbox: 'allow-scripts', @@ -158,7 +158,7 @@ describe('LightningEmbeddingGenerator', () => { it('should reject invalid sandbox tokens', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'https://app.example.com', sandbox: 'allow-scripts allow-everything', @@ -172,7 +172,7 @@ describe('LightningEmbeddingGenerator', () => { it('should accept multiple valid sandbox tokens', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'https://app.example.com', sandbox: 'allow-scripts allow-forms allow-same-origin', @@ -186,7 +186,7 @@ describe('LightningEmbeddingGenerator', () => { it('should reject a single-quote character in src (would break the generated JS string)', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: "https://app.example.com/path?q='foo", sandbox: 'allow-scripts', @@ -200,7 +200,7 @@ describe('LightningEmbeddingGenerator', () => { it('should reject a double-quote character in shellTitle (would break the generated HTML attribute)', () => { expect( () => - new LightningEmbeddingGenerator({ + new UIEmbeddingGenerator({ componentname: 'embeddingDemo', src: 'https://app.example.com', sandbox: 'allow-scripts', @@ -215,18 +215,15 @@ describe('LightningEmbeddingGenerator', () => { describe('generate', () => { it('should create the LWC bundle (internal — no meta xml)', async () => { const templateService = TemplateService.getInstance(process.cwd()); - const result = await templateService.create( - TemplateType.LightningEmbedding, - { - componentname: 'embeddingDemo', - src: 'https://app.example.com', - sandbox: 'allow-scripts allow-forms', - shellTitle: 'Demo Shell', - outputdir: lwcOutputDir, - apiversion: apiVersion, - internal: true, - } - ); + const result = await templateService.create(TemplateType.UIEmbedding, { + componentname: 'embeddingDemo', + src: 'https://app.example.com', + sandbox: 'allow-scripts allow-forms', + shellTitle: 'Demo Shell', + outputdir: lwcOutputDir, + apiversion: apiVersion, + internal: true, + }); const base = path.join(lwcOutputDir, 'embeddingDemo'); assertFileExists(path.join(base, 'embeddingDemo.html')); @@ -250,7 +247,7 @@ describe('LightningEmbeddingGenerator', () => { it('should generate meta xml when not internal', async () => { const templateService = TemplateService.getInstance(process.cwd()); - await templateService.create(TemplateType.LightningEmbedding, { + await templateService.create(TemplateType.UIEmbedding, { componentname: 'embeddingDemo', src: 'https://app.example.com', sandbox: 'allow-scripts',