@playcanvas/attribute-parser
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -8,3 +8,3 @@ { | ||
}, | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"dependencies": { | ||
@@ -11,0 +11,0 @@ "@microsoft/tsdoc": "^0.15.0", |
@@ -35,10 +35,16 @@ import * as ts from 'typescript'; | ||
async init(basePath = '') { | ||
/** | ||
* Initializes the JSDocParser with the standard library files | ||
* | ||
* @param {string} libPath - The path to standard library files | ||
* @returns {Promise<JSDocParser>} - The initialized JSDocParser | ||
*/ | ||
async init(libPath = '') { | ||
if (this._env) { | ||
return; | ||
return this; | ||
} | ||
let fsMap; | ||
if (basePath) { | ||
fsMap = await createDefaultMapFromCDN({ target: ts.ScriptTarget.ES2022 }, basePath, ts); | ||
if (libPath) { | ||
fsMap = await createDefaultMapFromCDN({ target: ts.ScriptTarget.ES2022 }, libPath, ts); | ||
} else { | ||
@@ -51,2 +57,4 @@ fsMap = await createDefaultMapFromNodeModules(COMPILER_OPTIONS, ts); | ||
this._env = createVirtualTypeScriptEnvironment(system, Array.from(fsMap.keys()), ts, COMPILER_OPTIONS); | ||
return this; | ||
} | ||
@@ -53,0 +61,0 @@ |
@@ -193,2 +193,7 @@ import * as ts from 'typescript'; | ||
// Curve Attributes specifically should not expose a default value if it's an empty array | ||
if (attribute.type === 'curve' && Array.isArray(attribute.value) && attribute.value.length === 0) { | ||
delete attribute.default; | ||
} | ||
// remove typeName from the output | ||
@@ -195,0 +200,0 @@ delete attribute.typeName; |
@@ -30,3 +30,3 @@ /* eslint-disable no-unused-expressions */ | ||
expect(data[0].example.attributes.a.array).to.equal(false); | ||
expect(data[0].example.attributes.a.default).to.eql([]); | ||
expect(data[0].example.attributes.a.default).to.not.exist; | ||
}); | ||
@@ -47,3 +47,3 @@ | ||
expect(data[0].example.attributes.c.array).to.equal(false); | ||
expect(data[0].example.attributes.c.default).to.eql([]); | ||
expect(data[0].example.attributes.a.default).to.not.exist; | ||
expect(data[0].example.attributes.c.color).to.equal('r'); | ||
@@ -57,3 +57,3 @@ }); | ||
expect(data[0].example.attributes.d.array).to.equal(false); | ||
expect(data[0].example.attributes.d.default).to.eql([]); | ||
expect(data[0].example.attributes.a.default).to.not.exist; | ||
expect(data[0].example.attributes.d.color).to.equal('rgb'); | ||
@@ -69,3 +69,3 @@ expect(data[0].example.attributes.d.curves).to.deep.equal(['x', 'y', 'z']); | ||
expect(data[0].example.attributes.e.size).to.equal(2); | ||
expect(data[0].example.attributes.e.default).equal(null); | ||
expect(data[0].example.attributes.e.default).to.not.exist; | ||
}); | ||
@@ -72,0 +72,0 @@ |
1759295
50409