alloy-compiler
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -6,2 +6,15 @@ # Change Log | ||
## [0.2.7](https://github.com/appcelerator/alloy-devkit/compare/v0.2.6...v0.2.7) (2021-06-02) | ||
### Bug Fixes | ||
* strip platfrom prefix from component dirname ([4d065e7](https://github.com/appcelerator/alloy-devkit/commit/4d065e7a60815119aeff572f70ad063b2bf5d413)) | ||
* **compiler:** allow tabgroup as a child of navigationwindow ([#222](https://github.com/appcelerator/alloy-devkit/issues/222)) ([fbe453c](https://github.com/appcelerator/alloy-devkit/commit/fbe453ce48849ab2ec2a32bf06221dcce0f01c41)) | ||
* improve check around whether widget is only node in the view ([#194](https://github.com/appcelerator/alloy-devkit/issues/194)) ([d32c819](https://github.com/appcelerator/alloy-devkit/commit/d32c81913c155d0fd6953bdf717d4cd28581e57b)) | ||
## [0.2.6](https://github.com/appcelerator/alloy-devkit/compare/v0.2.5...v0.2.6) (2020-11-05) | ||
@@ -8,0 +21,0 @@ |
@@ -15,2 +15,4 @@ const { | ||
const componentRegex = /(?:[/\\]widgets[/\\][^/\\]+)?[/\\](controllers|views|styles)[/\\](.*)/; | ||
// eslint-disable-next-line security/detect-non-literal-regexp | ||
const dirRegex = new RegExp('^(?:' + platforms.constants.PLATFORM_FOLDERS_ALLOY.join('|') + ')[\\\\\\/]*'); | ||
@@ -70,3 +72,3 @@ const metaCache = new Map(); | ||
basePath: widget ? widget.dir : this.appDir, | ||
subPath: path.dirname(componentIdentifier), | ||
subPath: path.dirname(componentIdentifier).replace(dirRegex, ''), | ||
componentName: path.basename(componentIdentifier), | ||
@@ -73,0 +75,0 @@ widget, |
@@ -143,3 +143,3 @@ var path = require('path'), | ||
code += ';\n' + args.symbol + '.setParent(' + args.parent.symbol + ');\n'; | ||
} else if (type === 'widget' && (node.parentNode && node.parentNode.nodeName === 'Alloy')) { | ||
} else if (type === 'widget' && isOnlyNodeInView(node)) { | ||
code += '.getViewEx({recurse:true});\n'; | ||
@@ -158,1 +158,34 @@ parent = { symbol: args.symbol }; | ||
} | ||
/** | ||
* Determines whether a node is the only child node of the Alloy in the view structure. This is | ||
* used to determine whether a Widget should become the root element of the view when only a view | ||
* only contains a single Widget tag like below | ||
* | ||
* <Alloy> | ||
* <Widget src="com.ti.mywidget" id="widget" /> | ||
* </Alloy> | ||
* | ||
* @param {Node} node - XMLDom node to be inspected | ||
* @return Boolean | ||
*/ | ||
function isOnlyNodeInView (node) { | ||
// Shouldn't happen as the Alloy tag should always exist, but lets handle it | ||
if (!node.parentNode) { | ||
return false; | ||
} | ||
// If the parent isn't the Alloy tag, then it isn't the only node in the view | ||
if (node.parentNode.nodeName !== 'Alloy') { | ||
return false; | ||
} | ||
// If there are sibling nodes, then it isn't the only node in the view | ||
const siblingNodes = U.XML.getElementsFromNodes(node.parentNode.childNodes).filter(n => n !== node); | ||
if (siblingNodes.length !== 0) { | ||
return false; | ||
} | ||
return true; | ||
} |
@@ -8,2 +8,3 @@ var styler = require('../styler'), | ||
const MIN_VERSION = '8.0.0'; | ||
const MIN_ANDROID_TABGROUP_CHILD = '8.3.0'; | ||
@@ -16,2 +17,3 @@ exports.parse = function (node, state) { | ||
const tiappSdkVersion = tiapp.getSdkVersion(); | ||
const platform = CU.getCompilerConfig().alloyConfig.platform; | ||
if (tiapp.version.lt(tiappSdkVersion, MIN_VERSION_FOR_IOS)) { | ||
@@ -26,6 +28,6 @@ U.die(`Ti.UI.iOS.NavigationWindow (line ${node.lineNumber}) requires Titanium ${MIN_VERSION_FOR_IOS}+`); | ||
var children = U.XML.getElementsFromNodes(node.childNodes), | ||
err = [ 'NavigationWindow must have only one child element, which must be a Window' ], | ||
err = [ 'NavigationWindow must have only one child element, which must be a Window or TabGroup' ], | ||
code = ''; | ||
// NavigationWindow must have 1 window as a child | ||
// NavigationWindow must have 1 window or tabgroup as a child | ||
if (children.length !== 1) { | ||
@@ -37,5 +39,9 @@ U.die(err); | ||
childArgs = CU.getParserArgs(child), | ||
theNode = CU.validateNodeName(child, 'Ti.UI.Window'), | ||
theNode = CU.validateNodeName(child, [ 'Ti.UI.Window', 'Ti.UI.TabGroup' ]), | ||
windowSymbol; | ||
if (platform === 'android' && theNode === 'Ti.UI.TabGroup' && tiapp.version.lt(tiappSdkVersion, MIN_ANDROID_TABGROUP_CHILD)) { | ||
U.die(`TabGroup can only be a child of a NavigationWindow on Android from SDK ${MIN_ANDROID_TABGROUP_CHILD} onwards. Current SDK is ${tiappSdkVersion}`); | ||
} | ||
// generate the code for the Window first | ||
@@ -42,0 +48,0 @@ if (theNode) { |
{ | ||
"name": "alloy-compiler", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "Compiler for Alloy components", | ||
@@ -23,3 +23,3 @@ "main": "lib/index.js", | ||
"@babel/types": "^7.9.6", | ||
"alloy-utils": "^0.2.5", | ||
"alloy-utils": "^0.2.7", | ||
"chmodr": "^1.2.0", | ||
@@ -32,3 +32,3 @@ "fs-extra": "^9.0.0", | ||
"walk-sync": "^2.0.2", | ||
"xmldom": "^0.3.0" | ||
"xmldom": "^0.6.0" | ||
}, | ||
@@ -38,3 +38,3 @@ "engines": { | ||
}, | ||
"gitHead": "133c0ac4d1d1982397a492c37627c6fd2a806c08" | ||
"gitHead": "7797da97ca3bdae05acd785b6073f07cf3d4fb45" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
923929
23768
- Removedxmldom@0.3.0(transitive)
Updatedalloy-utils@^0.2.7
Updatedxmldom@^0.6.0