From 07f39b817679457a8882cbd594bf003dbeada58f Mon Sep 17 00:00:00 2001 From: sandeep-vedam Date: Mon, 4 Nov 2024 19:14:05 +0530 Subject: [PATCH 01/10] Fixed element test failures --- src/engines/L3/element.test.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/engines/L3/element.test.js b/src/engines/L3/element.test.js index d3fabb69..f1a5e73e 100644 --- a/src/engines/L3/element.test.js +++ b/src/engines/L3/element.test.js @@ -101,7 +101,7 @@ test('Element - Set `w` property', (assert) => { assert.equal(el.node['width'], 100, 'Node width parameter should be set') assert.equal(el.props.props['width'], 100, 'Props width parameter should be set') - assert.equal(el.props.raw.get('w'), 100, "Props' raw map entry should be added") + assert.equal(el.props.raw['w'], 100, "Props' raw map entry should be added") assert.end() }) @@ -116,7 +116,7 @@ test('Element - Set `mount` property', (assert) => { assert.equal(el.node['mountY'], 20, 'Node mountY parameter should be set') assert.equal(el.props.props['mountX'], 10, 'Props mountX parameter should be set') assert.equal(el.props.props['mountY'], 20, 'Props mountY parameter should be set') - assert.equal(el.props.raw.get('mount'), value, "Props' raw map entry should be added") + assert.equal(el.props.raw['mount'], value, "Props' raw map entry should be added") assert.end() }) @@ -128,7 +128,7 @@ test('Element - Set `color` property', (assert) => { assert.equal(el.node['color'], '0xf0ffffff', 'Node color parameter should be set') assert.equal(el.props.props['color'], '0xf0ffffff', 'Props color parameter should be set') - assert.equal(el.props.raw.get('color'), 'azure', "Props' raw map entry should be added") + assert.equal(el.props.raw['color'], 'azure', "Props' raw map entry should be added") assert.end() }) @@ -141,7 +141,7 @@ test('Element - Set `src` property', (assert) => { assert.equal(el.node['src'], value, 'Node src parameter should be set') assert.equal(el.props.props['src'], value, 'Props src parameter should be set') - assert.equal(el.props.raw.get('src'), value, "Props' raw map entry should be added") + assert.equal(el.props.raw['src'], value, "Props' raw map entry should be added") assert.equal(el.props.props['color'], 0xffffffff, 'Props default color parameter should be set') assert.end() }) @@ -154,7 +154,7 @@ test('Element - Set `texture` property', (assert) => { assert.equal(el.node['texture'], 'foo', 'Node texture parameter should be set') assert.equal(el.props.props['texture'], 'foo', 'Props texture parameter should be set') - assert.equal(el.props.raw.get('texture'), 'foo', "Props' raw map entry should be added") + assert.equal(el.props.raw['texture'], 'foo', "Props' raw map entry should be added") assert.equal(el.props.props['color'], 0xffffffff, 'Props default color parameter should be set') assert.end() }) @@ -181,7 +181,7 @@ test('Element - Set `fit` property with a string type value', (assert) => { fitVal, 'Props textureOptions parameter should be set' ) - assert.equal(el.props.raw.get('fit'), fitVal, "Props' raw map entry should be added") + assert.equal(el.props.raw['fit'], fitVal, "Props' raw map entry should be added") assert.end() }) @@ -212,7 +212,7 @@ test('Element - Set `fit` property with an object type value', (assert) => { 1, 'Node resizeMode "clipY" parameter should be set to correct value' ) - assert.equal(el.props.raw.get('fit'), fitVal, "Props' raw map entry should be added") + assert.equal(el.props.raw['fit'], fitVal, "Props' raw map entry should be added") assert.end() }) @@ -243,7 +243,7 @@ test('Element - Set `fit` property with position key as a string type value', (a 1, 'Node resizeMode "clipY" parameter should be set to correct value' ) - assert.equal(el.props.raw.get('fit'), fitVal, "Props' raw map entry should be added") + assert.equal(el.props.raw['fit'], fitVal, "Props' raw map entry should be added") assert.end() }) From 0944e6adec5e1d878bc9dec3860a36f271907f80 Mon Sep 17 00:00:00 2001 From: Ugur Aslan Date: Tue, 27 Aug 2024 11:02:54 +0200 Subject: [PATCH 02/10] implemented .blits file support --- .../boilerplate/js/default/blits.d.ts | 5 ++ vite/blitsFileType.js | 50 +++++++++++++++++++ vite/index.js | 4 +- vite/preCompiler.js | 7 +++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 packages/create-blits/boilerplate/js/default/blits.d.ts create mode 100644 vite/blitsFileType.js diff --git a/packages/create-blits/boilerplate/js/default/blits.d.ts b/packages/create-blits/boilerplate/js/default/blits.d.ts new file mode 100644 index 00000000..c19c1261 --- /dev/null +++ b/packages/create-blits/boilerplate/js/default/blits.d.ts @@ -0,0 +1,5 @@ +// required for suppressing vscode typescript errors when importing .blits files in JS/TS files +declare module '*.blits' { + const value: any; + export default value; +} diff --git a/vite/blitsFileType.js b/vite/blitsFileType.js new file mode 100644 index 00000000..e856f6e4 --- /dev/null +++ b/vite/blitsFileType.js @@ -0,0 +1,50 @@ +export default function blitsFileType() { + return { + name: 'vite-plugin-blits-file-type', + enforce: 'pre', + transform(src, id) { + if (id.endsWith('.blits')) { + try { + const { template, script } = parseBlitsFile(src) + const transformedCode = injectTemplate(script, template) + return { + code: transformedCode, + map: null, // no source map + } + } catch (error) { + this.error(error) + } + } + }, + } +} + +function parseBlitsFile(source) { + const templateMatch = source.match(/