Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-27352
Browse files Browse the repository at this point in the history
  • Loading branch information
lokeshchdhry committed Aug 28, 2019
2 parents 76c3618 + e3f5586 commit d1c4d6e
Show file tree
Hide file tree
Showing 33 changed files with 715 additions and 3,239 deletions.
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"rules": {
"node/no-unsupported-features/es-syntax": "off"
}
},
{
Expand Down
44 changes: 26 additions & 18 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,28 @@ module.exports = function (grunt) {

// Project configuration.
grunt.initConfig({
appcJs: {
src: [
'dangerfile.js',
'Gruntfile.js',
'apidoc/**/*.js',
'build/**/*.js',
'cli/!(locales)/**/*.js',
'common/**/*.js',
'android/cli/!(locales)/**/*.js',
'android/modules/**/src/js/**/*.js',
'android/runtime/common/src/js/**/*.js',
'iphone/cli/!(locales)/**/*.js',
'tests/Resources/**/*test.js'
]
eslint: {
lintOnly: {
src: [
'dangerfile.js',
'Gruntfile.js',
'apidoc/**/*.js',
'build/**/*.js',
'cli/!(locales)/**/*.js',
'common/**/*.js',
'android/cli/!(locales)/**/*.js',
'android/modules/**/src/js/**/*.js',
'android/runtime/common/src/js/**/*.js',
'iphone/cli/!(locales)/**/*.js',
'tests/Resources/**/*test.js'
],
},
fix: {
src: '<%= eslint.lintOnly.src %>',
options: {
fix: true
}
}
},
clangFormat: {
android: { src: androidSrc },
Expand Down Expand Up @@ -126,15 +134,15 @@ module.exports = function (grunt) {
grunt.registerMultiTask('checkFormat', 'Validates the source code formatting.', validateFormatting);

// Load grunt plugins for modules
grunt.loadNpmTasks('grunt-appc-js');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-clang-format');
grunt.loadNpmTasks('grunt-contrib-clean');

// linting: run eslint against js, standard appc checks, check ios/android format via clang, run doc validation script
grunt.registerTask('lint', [ 'appcJs:src:lintOnly', 'checkFormat:ios', 'checkFormat:android', 'validate:docs' ]);
// linting: run eslint against js, check ios/android format via clang, run doc validation script
grunt.registerTask('lint', [ 'eslint:lintOnly', 'checkFormat:ios', 'checkFormat:android', 'validate:docs' ]);

// Tasks for formatting the source code according to our clang/eslint rules
grunt.registerTask('format:js', [ 'appcJs:src:lint:fix' ]);
grunt.registerTask('format:js', [ 'eslint:fix' ]);
grunt.registerTask('format:android', [ 'clangFormat:android' ]);
grunt.registerTask('format:ios', [ 'clangFormat:ios' ]);
grunt.registerTask('format', [ 'format:android', 'format:ios', 'format:js' ]);
Expand Down
2 changes: 1 addition & 1 deletion android/cli/hooks/aar-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class SimpleFileCache {
* @return {boolean}
*/
has(key) {
return this.data.hasOwnProperty(key);
return Object.prototype.hasOwnProperty.call(this.data, key);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion android/cli/tests/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ optimist
desc: 'disables colors'
});

if (optimist.argv.hasOwnProperty('colors') && !optimist.argv.colors) {
if (Object.prototype.hasOwnProperty.call(optimist.argv, 'colors') && !optimist.argv.colors) {
Base.useColors = false;
colors.mode = 'none';
}
Expand Down
2 changes: 1 addition & 1 deletion android/modules/app/src/js/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.bootstrap = function (Titanium) {
var Properties = Titanium.App.Properties;

function nullOrDefaultValue(defaultValue) {
if (typeof(defaultValue) === 'undefined') {
if (typeof defaultValue === 'undefined') {
return null;
}
return defaultValue;
Expand Down
1 change: 0 additions & 1 deletion android/modules/network/src/js/httpclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* global kroll */
'use strict';

var PersistentHandle = require('network').PersistentHandle;
Expand Down
2 changes: 1 addition & 1 deletion android/modules/ui/src/js/listview.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports.bootstrap = function (Titanium) {
// Recursive function that process childTemplates and append corresponding proxies to
// property 'tiProxy'. I.e: type: "Titanium.UI.Label" -> tiProxy: LabelProxy object
function processChildTemplates(properties) {
if (!properties.hasOwnProperty('childTemplates')) {
if (!Object.prototype.hasOwnProperty.call(properties, 'childTemplates')) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion android/runtime/common/src/js/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function join(args) {
return (arg === null)
? 'null'
: ((typeof arg === 'object')
? (arg.hasOwnProperty('toString') ? arg.toString() : JSON.stringify(arg))
? (Object.prototype.hasOwnProperty.call(arg, 'toString') ? arg.toString() : JSON.stringify(arg))
: arg);
}).join(' ');
}
Expand Down
2 changes: 1 addition & 1 deletion android/runtime/common/src/js/invoker.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function genInvoker(wrapperAPI, realAPI, apiName, invocationAPI, scopeVars) {
var api;

// Create a module wrapper only if it hasn't been wrapped already.
if (apiNamespace.hasOwnProperty(name)) {
if (Object.prototype.hasOwnProperty.call(apiNamespace, name)) {
api = apiNamespace[name];

} else {
Expand Down
1 change: 0 additions & 1 deletion android/runtime/common/src/js/titanium.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
/* global kroll */
'use strict';

var tiBinding = kroll.binding('Titanium'),
Expand Down
1 change: 0 additions & 1 deletion android/runtime/common/src/js/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
/* global kroll */
'use strict';

var binding = kroll.binding('evals');
Expand Down
12 changes: 4 additions & 8 deletions apidoc/Titanium/UI/WebView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ description: |
**Plugin Support**
The Android web view supports native plugins such as Flash Player. Note that the Chromium-based
web view introduced in Android 4.4 does not support the Flash Player plugin.
The Android web view supports native plugins.
To use plugin content, you must set the [pluginState](Titanium.UI.WebView.pluginState) property
to either [WEBVIEW_PLUGINS_ON](Titanium.UI.Android.WEBVIEW_PLUGINS_ON) or
Expand Down Expand Up @@ -283,8 +282,7 @@ methods:
summary: Pauses native webview plugins.
description: |
Add a `pause` handler to your <Titanium.Android.Activity> and invoke
this method to pause native plugins. This is important with Flash content
as it will continue in the background unless this method is invoked.
this method to pause native plugins.
Call [resume](Titanium.UI.WebView.resume) to unpause native plugins.
since: "1.8.0"
Expand Down Expand Up @@ -826,11 +824,9 @@ properties:
- name: pluginState
summary: Determines how to treat content that requires plugins in this web view.
description: |
This setting affects the loading of content that requires web plugins, such as
Flash Player.
This setting affects the loading of content that requires web plugins.
To use the Flash Player plugin, hardware acceleration must be enabled for your
application. To enable hardware acceleration, add the `tool-api-level` and
To enable hardware acceleration, add the `tool-api-level` and
`manifest` elements shown below inside the `android` element in your `tiapp.xml` file.
<android xmlns:android="http://schemas.android.com/apk/res/android">
Expand Down
2 changes: 1 addition & 1 deletion apidoc/lib/parity_generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function sort(object) {
const sorted = {};
const array = [];
for (const key in object) {
if (object.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(object, key)) {
array.push(key);
}
}
Expand Down
2 changes: 1 addition & 1 deletion build/lib/android/ant.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function build(script, targets, properties) {

// add properties
for (const k in properties) {
if (properties.hasOwnProperty(k)) {
if (Object.prototype.hasOwnProperty.call(properties, k)) {
args.push('-D' + k + '=' + properties[k]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion build/lib/ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class IOS {
// TODO: Use copyAndModifyFile?
const contents = await fs.readFile(path.join(ROOT_DIR, 'support/iphone/main.m'), 'utf8');
const newContents = contents.replace(/(__.+?__)/g, function (match, key) {
const s = subs.hasOwnProperty(key) ? subs[key] : key;
const s = Object.prototype.hasOwnProperty.call(subs, key) ? subs[key] : key;
return typeof s === 'string' ? s.replace(/"/g, '\\"').replace(/\n/g, '\\n') : s;
});
return fs.writeFile(dest, newContents);
Expand Down
2 changes: 1 addition & 1 deletion build/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Utils.copyAndModifyFile = async function (srcFolder, destFolder, filename, subst

// Go through each substitution and replace!
for (const key in substitutions) {
if (substitutions.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(substitutions, key)) {
str = str.split(key).join(substitutions[key]);
}
}
Expand Down
1 change: 1 addition & 0 deletions build/scons-modules-integrity.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const modulesPath = path.join(__dirname, '../support/module/packaged/modules.jso
*/
async function handleModule(moduleObject, moduleName) {
const hash = await utils.generateSSRIHashFromURL(moduleObject.url);
// eslint-disable-next-line require-atomic-updates
moduleObject.integrity = hash.toString();
return {
[moduleName]: moduleObject
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ CreateCommand.prototype.config = function config(logger, config, cli) {
return next();
}

const creator = new(require(path.join(creatorDir, filename)))(logger, config, cli); // eslint-disable-line security/detect-non-literal-require
const creator = new (require(path.join(creatorDir, filename)))(logger, config, cli); // eslint-disable-line security/detect-non-literal-require
this.creators[creator.type] = creator;

try {
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ exports.run = function (logger, config, cli, finished) {
// Validate the platforms and override the tiapp.xml setting to true
value = args[1].split(',');
value.forEach(function (p) {
if (!result.hasOwnProperty(p)) {
if (!Object.prototype.hasOwnProperty.call(result, p)) {
logger.error(__('Unsupported deployment target "%s"', p) + '\n');
logger.log(__('Available deployment targets are:'));
Object.keys(result).sort().forEach(function (p) {
Expand Down
2 changes: 1 addition & 1 deletion common/Resources/ti.internal/extensions/node/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ function checkError(actual, expected, message) {
}

// If `expected` is a subclass of Error but `actual` wasn't an instance of it (above), fail
if (Error.isPrototypeOf(expected)) {
if (Object.prototype.isPrototypeOf.call(Error, expected)) {
return false;
}

Expand Down
27 changes: 22 additions & 5 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/APIModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ - (bool)isNSBoolean:(id)object
- (void)logMessage:(id)args severity:(NSString *)severity
{
if (args == nil) {
args = @[ @"null" ];
args = @[ [NSNull null] ];
} else if (!([args isKindOfClass:[NSArray class]])) {
args = @[ args ];
}
// If the arg is an NSNumber wrapping a BOOL we should print the string equivalent for the boolean!
NSMutableArray *newArray = [NSMutableArray array];
[args enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[JSValue class]]) {
obj = ((JSValue *)obj).toObject;
}
if ([self isNSBoolean:obj]) {
[newArray addObject:[NSString stringWithFormat:[obj boolValue] ? @"true" : @"false"]];
} else {
[newArray addObject:obj];
obj = [obj boolValue] ? @"true" : @"false";
} else if (obj == nil) {
obj = [NSNull null];
}
[newArray addObject:obj];
}];
NSLog(@"[%@] %@", [severity uppercaseString], [newArray componentsJoinedByString:@" "]);
}
Expand All @@ -49,26 +53,32 @@ - (id)transform:(id)arg

- (void)debug:(id)args
{
args = [JSContext currentArguments] ?: args;

[self logMessage:args severity:@"debug"];
}

- (void)info:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"info"];
}

- (void)warn:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"warn"];
}

- (void)error:(NSArray *)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"error"];
}

- (void)trace:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"trace"];
}

Expand All @@ -84,17 +94,24 @@ - (void)timestamp:(id)args

- (void)notice:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"info"];
}

- (void)critical:(id)args
{
args = [JSContext currentArguments] ?: args;
[self logMessage:args severity:@"error"];
}

- (void)log:(id)level withMessage:(id)args
{
if (args == nil) {
if ([JSContext currentArguments].count > 0) {
NSMutableArray *array = [NSMutableArray arrayWithArray:[JSContext currentArguments]];
[array removeObjectAtIndex:0];
args = array;
}
if (args == nil || ([args isKindOfClass:[NSArray class]] && [args count] == 0)) {
[self logMessage:level severity:@"info"];
} else {
[self logMessage:args severity:level];
Expand Down
1 change: 1 addition & 0 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ - (void)didStartNewContext:(KrollContext *)kroll
@"Network",
@"Stream",
@"UI",
@"WatchSession",
@"XML" ];
for (NSString *name in legacyModuleNames) {
// We must generate the block and copy it to put it into heap or else every instance of the block shares
Expand Down
16 changes: 9 additions & 7 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -2897,19 +2897,21 @@ + (TiViewProxy *)unarchiveFromTemplate:(id)viewTemplate_ inContext:(id<TiEvaluat
// TODO eval once and pass in the controller name and props as args?
DebugLog(@"[DEBUG] Failed to load native class %@, trying Alloy widget / CommonJS module", viewTemplate.type);
NSString *code = [NSString stringWithFormat:@"var result;"
"var jsModule;"
"try {"
" var jsModule = require('/alloy/widgets/%@/controllers/widget');"
" if (!jsModule) {"
" jsModule = require('/alloy/widgets/%@/controllers/widget');"
"} catch (error) {"
" try {"
" jsModule = require('%@');"
" } catch (e) {"
" Ti.API.error('Failed to load Alloy widget / CommonJS module \"%@\" to be used as template');"
" }"
" if (jsModule) {"
" result = function (parameters) {"
"}"
"if (jsModule) {"
" result = function (parameters) {"
" const obj = new jsModule(parameters);"
" return obj.getView();"
" };"
" }"
"} catch (e) {"
" Ti.API.error('Failed to load Alloy widget / CommonJS module \"%@\" to be used as template');"
"}"
"result;",
viewTemplate.type, viewTemplate.type, viewTemplate.type];
Expand Down
2 changes: 1 addition & 1 deletion iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6370,7 +6370,7 @@ iOSBuilder.prototype.removeFiles = function removeFiles(next) {
}, this);

// remove invalid architectures from TitaniumKit.framework for App Store distributions
if (this.target === 'dist-appstore') {
if (this.target === 'dist-appstore' || this.target === 'dist-adhoc') {
this.logger.info(__('Removing invalid architectures from TitaniumKit.framework'));

const titaniumKitPath = path.join(this.buildDir, 'Frameworks', 'TitaniumKit.framework', 'TitaniumKit');
Expand Down

0 comments on commit d1c4d6e

Please sign in to comment.