incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Mueller <pmue...@gmail.com>
Subject Re: CB-280 - Improve layout of cordova-js scripts
Date Mon, 19 Mar 2012 19:09:16 GMT
On Mon, Mar 19, 2012 at 14:31, Filip Maj <fil@adobe.com> wrote:

> These are two use cases I see so far in the various cordova JS platform
> implementations for module overriding:
>
> 1. I want to completely override a common module. This seems solved with
> the proposed convention of /platform/<platform>/foo.js overriding
> /cordova/foo.js at build time, instead of the current "objects" property
> on the platform definition JSON file.
>

+1


> 2. I want to override or add a few methods on the common foo module (or
> its prototype) with some platform specific stuff. BlackBerry and iOS do a
> fair bit of this. Current suggested method is using the "merges" property
> on the platform definition JSON file. No proposed solution to this in the
> new re-architect? Interestingly most platforms can settle for overriding
> the prototype methods if the parent object to override has a prototype.
> Some platforms, like iOS, however, do NOT allow native code prototype
> overriding so we clobber a specific instance's methods instead. I.e:
>
> navigator.geolocation.getCurrentPosition = require('ios-specific geo
> plugin').getCurrentPosition;
>

The CB-280 issue is really just about moving existing files around.  Very
disruptive, and a huge change (kind of), but not touching any API.
 Hopefully.  Makes for a "as clean as possible" commit.  I'd prefer to not
make code changes to the modules, unless we absolutely have to.


> I guess this new approach would also eliminate the need to have an
> explicit common platform definition, as that should just be all of the
> scripts located under the /cordova directory. That being said, the current
> implementation has a few of what Pat calls "scripts" that are defined/used
> as modules: the channel, utils, builder and base cordova scripts are all
> wrapped as modules and used as such throughout the plugin JS files. The
> current path -> module id mapping for these scripts (where applicable) is:
>
> /lib/cordova.js is "cordova"
> /lib/channel.js is "cordova/channel"
> /lib/require.js is in-lined as a script that scopes to the entire built
> cordova.js file
> /lib/bootstrap.js is in-lined
> /lib/builder.js is "cordova/builder"
> /lib/utils.js is "cordova/utils"
>

I was thinking of moving bootstrap and require somewhere by themselves,
since they aren't modules.


> What about the location of the exec module for each platform? Assume the
> existence of an exec.js in each platform/<platform>/ directory?
>

yes

-- 
Patrick Mueller
http://muellerware.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message