Created
April 2, 2020 12:44
-
-
Save zo0m/0f3eb18f811e56dab277a5a7d69e8f8d to your computer and use it in GitHub Desktop.
Alloy bind_ attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sourceMapper = require('./sourceMapper'); | |
var paths = require('global-paths'); | |
var projectDirectory; | |
var logger; | |
function resolver(moduleName) { | |
return require(require('resolve').sync(moduleName, { | |
basedir: projectDirectory, | |
paths: paths(), | |
})); | |
} | |
task('pre:load', (event, alloyLogger) => { | |
logger = alloyLogger; | |
projectDirectory = event.dir.project; | |
sourceMapper.OPTIONS_OUTPUT.presets = sourceMapper.OPTIONS_OUTPUT.presets || []; | |
sourceMapper.OPTIONS_OUTPUT.presets.push(resolver('babel-preset-env')); | |
sourceMapper.OPTIONS_OUTPUT.presets.push({ | |
plugins: [ | |
[resolver('babel-plugin-titanium-controller-args')], | |
[bind_AttributeTransformer], | |
[resolver('babel-plugin-transform-async-generator-functions')] | |
], | |
}); | |
}); | |
function bind_AttributeTransformer(_ref) { | |
var types = _ref.types; | |
return { | |
pre: function (state) { | |
}, | |
visitor: { | |
Property: function (path, state) { | |
if (types.isStringLiteral(path.node.value)) { | |
// if (path.node.value.value.startsWith('@:')) { | |
var namePrefix = 'bind_'; | |
if (path.node.key.name && path.node.key.name.startsWith(namePrefix)) { | |
path.replaceWith(types.ObjectProperty(types.identifier(path.node.key.name), types.Identifier(path.node.value.value))); | |
path.node.key.name = path.node.key.name.slice(namePrefix.length); | |
} | |
} | |
}, | |
} | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alloy | |
Require(src='components/common/base-window/BaseWindow') | |
Require#loader(src="components/common/horizontal-scroller/LoadingContainer") | |
Require#eventMap(src="components/event/map/EventMap", bind_onLoad="(()=> $.loader.onload())") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alloy | |
Require(src='components/common/base-window/BaseWindow') | |
Require#scroller( | |
src="components/common/horizontal-scroller/HorizontalScroller", | |
module="app/ui/components", | |
bind_startIndex="getCurrentListIndex($.args.event)", | |
bind_createNextView="createNextView", | |
bind_createPrevView="createPrevView", | |
bind_handleScrollend="handleScrollend" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment