From 199e0efb45807324d5467a950e74b9d0f9c23252 Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Thu, 28 Oct 2021 15:26:08 -0400 Subject: [PATCH] Add transpile fix for instantresume components (#465) * Add transpile fix for instantresume components * Fix bug --- src/astUtils/xml.ts | 3 +++ src/files/XmlFile.spec.ts | 37 +++++++++++++++++++++++++++++++++++++ src/parser/SGParser.ts | 2 +- src/parser/SGTypes.ts | 13 ++++++++----- 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/astUtils/xml.ts b/src/astUtils/xml.ts index bb501eec7..11c2df7fa 100644 --- a/src/astUtils/xml.ts +++ b/src/astUtils/xml.ts @@ -21,3 +21,6 @@ export function isSGFunction(tag: SGTag): tag is SGFunction { export function isSGNode(tag: SGTag): tag is SGNode { return tag?.constructor.name === 'SGNode'; } +export function isSGCustomization(tag: SGTag): tag is SGNode { + return isSGNode(tag) && tag.tag?.text?.toLowerCase() === 'customization'; +} diff --git a/src/files/XmlFile.spec.ts b/src/files/XmlFile.spec.ts index 261dc84c7..fee1427ed 100644 --- a/src/files/XmlFile.spec.ts +++ b/src/files/XmlFile.spec.ts @@ -11,6 +11,8 @@ import { BrsFile } from './BrsFile'; import { XmlFile } from './XmlFile'; import { standardizePath as s } from '../util'; import { expectZeroDiagnostics, getTestTranspile, trim, trimMap } from '../testHelpers.spec'; +import { ProgramBuilder } from '../ProgramBuilder'; +import { LogLevel } from '../Logger'; describe('XmlFile', () => { const tempDir = s`${process.cwd()}/.tmp`; @@ -624,6 +626,41 @@ describe('XmlFile', () => { }); describe('transpile', () => { + it('supports instantresume elements', async () => { + fsExtra.outputFileSync(`${rootDir}/manifest`, ''); + fsExtra.outputFileSync(`${rootDir}/source/main.brs`, `sub main()\nend sub`); + fsExtra.outputFileSync(`${rootDir}/components/MainScene.xml`, trim` + + + + + + + + + `); + const builder = new ProgramBuilder(); + await builder.run({ + cwd: rootDir, + retainStagingFolder: true, + stagingFolderPath: stagingDir, + logLevel: LogLevel.off + }); + expect( + fsExtra.readFileSync(`${stagingDir}/components/MainScene.xml`).toString() + ).to.eql(trim` + + +