{ "id": "91371", "key": "TIMOB-8997", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2012-06-14T17:19:14.000+0000", "created": "2012-05-04T12:31:01.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [], "issuelinks": [ { "id": "17812", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "92563", "key": "TIMOB-9315", "fields": { "summary": "Android: External modules should support executing both a companion CommonJS file (if any) and the native code.", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "5", "description": "The sub-task of the issue", "name": "Sub-task", "subtask": true } } } } ], "assignee": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2017-03-21T22:40:59.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Titanium needs a way to expose a JavaScript wrapper around a native module by providing a way to distribute CommonJS / JavaScript modules along side their native counter parts.\r\n\r\nIn theory, this might work something like:\r\n{code}\r\n@Kroll.module\r\npublic class MyModule extends KrollModule\r\n{\r\n @Kroll.method\r\n public void nativeMethod() {}\r\n}\r\n{code}\r\n\r\n{code}\r\n// in assets/myModule.js\r\n\r\nvar nativeModule = require(\"my.native.module.id\");\r\nexports.wrappedMethod = function() {\r\n return nativeModule.nativeMethod();\r\n}\r\n{code}\r\n\r\n{code}\r\n// now in the app.js\r\n\r\nvar myModule = require(\"myModule\");\r\nmyModule.wrappedMethod();\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: Add the ability to distribute CommonJS modules along with a native module", "creator": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "194436", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "Dependency on TIMOB-4521 because a) it's in the same sprint; b) it will determine how we handle commonjs, period, in android module projects.", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-05-10T14:16:30.000+0000", "updated": "2012-05-10T14:16:30.000+0000" }, { "id": "196603", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "Please follow the linked items (dependencies) as well for status.\r\n\r\nThis is a complex issue because:\r\n\r\na) We need to maintain parity, and _none_ of the platforms (Android, iOS, MobileWeb) support this. Therefore parity discussions and test cases will need to occur/be developed.\r\n\r\nb) This would require that both Javascript-based and native-based module code be executed at runtime, and the way modules are currently architected this won't work.\r\n\r\nTherefore we need to book substantially more time for this, and I've broken it down to the linked tasks.", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-05-30T15:37:56.000+0000", "updated": "2012-05-30T15:37:56.000+0000" }, { "id": "198621", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "At this point, this item basically duplicates TIMOB-9315, so I'm going to close it. Follow the progress of TIMOB-9315, which is already at the pull request stage and therefore should be merged into our master branch in time for 2.1.0.\r\n\r\nTIMOB-9315 implements the ability to run both javascript (CommonJS) and native code in the same module. The CommonJS file should be assets/[moduleid].js (substituting the actual module id of course.) If we find such a file, we merge its exported members with the native module at runtime.\r\n\r\nSo there's just a few alterations to marshall's suggested code above. It would now look like this:\r\n\r\n{code}\r\n@Kroll.module\r\npublic class MyModule extends KrollModule\r\n{\r\n @Kroll.method\r\n public void nativeMethod() {}\r\n}\r\n{code}\r\n\r\n{code}\r\n// in assets/my.native.module.id.js\r\n\r\nexports.wrappedMethod = function() {\r\n return this.nativeMethod();\r\n}\r\n{code}\r\n\r\n{code}\r\n// now in the app.js\r\n\r\nvar myModule = require(\"my.native.module.id\");\r\nmyModule.wrappedMethod();\r\n{code}\r\n\r\nNote the use of \"this\" in the my.native.module.id.js file. It provides access to the native methods.", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-06-14T17:17:14.000+0000", "updated": "2012-06-14T17:17:52.000+0000" }, { "id": "414604", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as duplicate.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-21T22:40:59.000+0000", "updated": "2017-03-21T22:40:59.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }