Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1133EE345 for ; Thu, 14 Feb 2013 18:32:15 +0000 (UTC) Received: (qmail 86017 invoked by uid 500); 14 Feb 2013 18:32:14 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 85996 invoked by uid 500); 14 Feb 2013 18:32:14 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 85988 invoked by uid 99); 14 Feb 2013 18:32:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Feb 2013 18:32:14 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FRT_ADOBE2,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of braden@google.com designates 209.85.214.49 as permitted sender) Received: from [209.85.214.49] (HELO mail-bk0-f49.google.com) (209.85.214.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Feb 2013 18:32:10 +0000 Received: by mail-bk0-f49.google.com with SMTP id w11so1215774bku.22 for ; Thu, 14 Feb 2013 10:31:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=IWsG7Gfl+zSYyLYrxSVAky+LADDKTo65rkvb1ZoPTQs=; b=CrZiby1wPEB67JeUJ5aCtC/WQbMYPSianTXwJLkX1zcFQO56Vph2MUp/xUGzMdF2Qf TEiVGl0xGWUAy1z9agLWrZiR6x/FQsvPbUfytfjW5ANt7V/+v7nnWyJ7Gswq2nluFk1B Z30SvDbVItt43uPt2VNZy31SHeGSvOmb+a8XFASPudn6KlOxErx1haoDbsNve0ZdDQYi ez8AMe8dmqpHzu426glFKPhwS8fUX4JCaX7KqsuEBQ6EB5SgdNSQ7rlqxw9ZslSUODjy V4+iUS04+xvjddWJm0XhqVNeO1dfUv3id1KHjEXnLbcBsmBVhfmbYn8mpU2EfUfSVgrV uygA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=IWsG7Gfl+zSYyLYrxSVAky+LADDKTo65rkvb1ZoPTQs=; b=FnSWks08IQYLdJsP4ttClR0tdERkRDb9lwXD699mbdCR7r3k70bZMxbyT3YRYQ2UR5 Q/oXHyN6l1x/pL2NGR7BgqwaLcQ84fk8mXExIYlqASkHz/p7y/PSVb62mjZ24OJtefs0 2qvNIvQNF/piIFKMFgMXDHodDVXW+61B27PIs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :x-gm-message-state; bh=IWsG7Gfl+zSYyLYrxSVAky+LADDKTo65rkvb1ZoPTQs=; b=ldqKFdA3MpD5UZ4xQ5Hm2viABnQMzRx7fcOeghBQkA7SPJVK1Rt4vGEqa9FH5P/dwo QlaKI57uJUyKgKRJheNusQ2+UAay/A7mDDm99FMLovv1t3v1GnxkqrwZBunZm3qitUAV LcbeXkrTSILT09+uq1eo0dbp4y+3FgvSjfjKhlX7vi8EzmzpY7rWIkT3XaCsD0WGzzN1 /aBrq4SBkuja/qjBAt7n3EnYm1LnNZkUGBnTTN8NTVvtjP4QsuMvxOck+hmfWqnGfOyn lGNthEkCtsGX7tgGXuzFByy3B7RtWg/WIVu4T570RjbSxqeCmohJp5Dbu62VEAFBgWTp Hsrg== MIME-Version: 1.0 X-Received: by 10.204.152.28 with SMTP id e28mr8531149bkw.85.1360866708555; Thu, 14 Feb 2013 10:31:48 -0800 (PST) Sender: braden@google.com Received: by 10.204.12.206 with HTTP; Thu, 14 Feb 2013 10:31:48 -0800 (PST) In-Reply-To: References: Date: Thu, 14 Feb 2013 13:31:48 -0500 X-Google-Sender-Auth: 7vf6YqTppy57n7ZQGWpzYCwPmc8 Message-ID: Subject: Re: Proposal for JS in Plugins From: Braden Shepherdson To: dev@cordova.apache.org Content-Type: multipart/alternative; boundary=0015175defeec0084c04d5b378e9 X-Gm-Message-State: ALoCoQm+9JtMWJJmTBAZ0ePfK1itPsQG8Geux1NCwjpQAaBAA3E8ocxrCF/lEIJ6ydkZ3naDdxH5YE1o9+As08Q/xq/qf0IqgaHdNDtsKPNK58Ls3XjkmBqOhsaopuwav/vo+TfJhbPfrXZN62+wKlQPlFz1ZGgwepWcZjjDioMKrBoiAPwsynUckJAjClIvBwHnDooAINVJ X-Virus-Checked: Checked by ClamAV on apache.org --0015175defeec0084c04d5b378e9 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable So I've written up my plan for attacking this problem into a Google Doc I've shared for public comments: https://docs.google.com/document/d/1fhwnIZ5TqwklGx71pLmfSghysls1S4_5ktEsjA9= ac5Y/edit?usp=3Dsharing tl;dr version is that on cordova prepare (the new fast first part of cordova build, copies www) we read all installed plugins for new XML tags that define the JS modules and where they should be exposed on window, and inject code into cordova.js to load the modules, and do the clobbering/merging/executing as necessary. This is a relatively modest new feature for the CLI that doesn't require any refactoring, and should be fast enough to run on every prepare/build without significant slowdown. I'm working on a prototype of this approach in a fork of the CLI. If you spot any problems with the approach, please comment on the doc or in this thread. Braden On Fri, Feb 8, 2013 at 4:45 AM, Brian LeRoux wrote: > You know what. I'm super wrong. I was thinking in the context of a > native project and not a *cordova* project. > > The flaw in the thinking was that we were shipping only one file we > build leaving devs to include as they see fit. But whats really > happening is that we are generating a new file for every plugin > add/remove which will be different for each platform. If they move > that file around and include from a directory of their choosing we're > fucked. > > The difference here is the audience. A developer content to NOT use > our tools, and compose their own app for a single platform, say > Android, is going to have to figure out inclusion themselves. For us, > its a build time concern. Not magic. > > Consider: we are required to re-build every time a user adds/removes a > plugin. And if they move that generated file, again, we're fucked. > This is increasingly looking like a script inject....which we could > make configurable with config.xml so that it isn't too magical > feeling. > > We should talk about how the www install part works though. I wonder > if it would appropriate to propose a special folder in www for this > purpose. Like node_modules but without fugly underscores. > > > On Wed, Feb 6, 2013 at 4:01 PM, Andrew Grieve > wrote: > > For a project who's main language is JS, I'm a bit surprised that > injecting > > a script tag through DOM manipulation would put us into the "magic" > > category... > > > > Brian - Your sentiments about the development stack don't make sense to > me. > > The development stack is *the* job of CLI. We are prescribing a way to > set > > up your project so that it's easy to have an x-platform www directory, > and > > writing tools to make it easy to add/remove plugins. Is not "the > > development stack" *the* goal of CLI? > > > > This isn't a problem that we can "not solve". It's a problem that exist= s, > > and doing nothing *is a solution*. Here's the "do nothing" solution: > > - Let plugins put their .js file anywhere within the www/ directory (an= d > > hope that it doesn't clobber anything) > > - Have them write documentation to instruct users that they must insert > > their script tags into each of their .html files > > - Hope that users notice the instructions, and that they are correct, a= nd > > that they don't mess them up > > - Hope that users can remember which JS files belong to what if they ev= er > > want to remove plugins > > > > Note that for our core plugins, we have 78 .js files just within > > lib/common/plugin. > > > > A variation on "do nothing": > > - Tell each plugin developer to come up with their own packaging system > > - Tell them to check in a pre-packaged version with every commit (or ju= st > > on releases) > > - Tell them to write instructions for the manual steps involved in > adding / > > removing their plugins. > > > > I don't accept that this isn't a problem. If there are actually better > > alternatives, I'd like to hear what they are, and what the development > > workflow looks like for both the plugin users as well as the plugin > > developers. > > > > > > Anis - What sort of needs / requirements are you thinking of that won't > > work with the injecting script tags approach? Let's try and work throug= h > > them. The same argument could be used to shoot down the entire CLI > effort... > > > > > > Andrew > > > > > > On Wed, Feb 6, 2013 at 6:27 PM, Joe Bowser wrote: > > > >> I also disagree with automagically injecting the script tags. If > >> we're adding the script tags, we have the ability of adding the script > >> tags wrong, and breaking people's apps with magic. We have enough > >> trouble directing our users to use Cordova/PhoneGap without us trying > >> to make things more clever. > >> > >> On Wed, Feb 6, 2013 at 2:39 PM, Anis KADRI > wrote: > >> > I don't think we should be automatically injecting javascript tags. > >> > Instruct users to do so when they add a plugin by displaying the tag= . > >> > Everyone has different needs/requirements. > >> > > >> > Also > >> > > >> > *"cordova plugin add file" > >> > - Download plugin files to project/plugins > >> > - Runs plugman to install native parts of the plugin. > >> > - Plugman will copy JS files listed into > >> > project/platforms/cordova-js/lib/...* > >> > * * > >> > *plugman supports installation by local-dir/git-repo/name. Names are > >> > listed/stored on an outside source. So I believe this step should ju= st > >> call > >> > plugman with the name/git/local-dir. We've already agreed that all > >> plugins > >> > will have separate repositories, yes ?* > >> > > > > Which step are you referring to? Could you maybe write out the version = of > > how things work that you're suggesting? > > > > > > > >> > * > >> > * > >> > *I also agree that plugin.xml should support dependencies and that w= e > >> > should update the plugin spec. **I like the requires-plugin tag but = I > am > >> > not sure I like that js-symbols tag in plugin.xml though. **I am > confused > >> > about that "Exporting Module Symbols" section. An example would be > >> > appreciated.* > >> > > > > There's this example in the doc already: > > * > > > > > > > > > target=3D=94requestFileSystem=94> > > > > > target=3D=94navigator.connection=94> > > > > > > * > > * > > * > > And what symbol.js files look like is described in > > https://issues.apache.org/jira/browse/CB-2227 > > > > *Does this help? Is there something else you want an example of?* > > > >> * > >> > * > >> > *Anis* > >> > > >> > > >> > On Wed, Feb 6, 2013 at 12:45 PM, Braden Shepherdson < > braden@chromium.org > >> >wrote: > >> > > >> >> I think it's fine to have the default behavior be to inject script > tags. > >> >> That will suffice for 90% of our users, probably more. If you fall > into > >> the > >> >> 10% that have some more complicated setup, we should provide a flag > like > >> >> > cordova plugin add --no-inject-js myplugin > >> >> that prevents us from doing it automatically, and you can do whatev= er > >> more > >> >> complex step you need to do. > >> >> > >> >> > >> >> Braden > >> >> > >> >> > >> >> On Wed, Feb 6, 2013 at 3:37 PM, Andrew Grieve > >> >> wrote: > >> >> > >> >> > On Wed, Feb 6, 2013 at 3:00 PM, Filip Maj wrote: > >> >> > > >> >> > > > >> >> > > > >> >> > > On 2/6/13 11:51 AM, "Andrew Grieve" > wrote: > >> >> > > > >> >> > > >On Wed, Feb 6, 2013 at 2:33 PM, Filip Maj > wrote: > >> >> > > > > >> >> > > >> I've added a few detail explanations to the document, but > moved > >> the > >> >> > > >> discussion to the ML. > >> >> > > >> > >> >> > > >> ---- > >> >> > > >> > >> >> > > >> > Should be easy to install / remove plugins (no need to > manually > >> >> > > >> >add/remove script tags) > >> >> > > >> > >> >> > > >> > >> >> > > >> I think adding/removing script tags is the way to go. > >> Concatenating > >> >> > all > >> >> > > >> javascript relevant to your project (cordova.js + any plugin= s > you > >> >> add) > >> >> > > >> makes it difficult to debug later on. WE'd have to get users > to > >> post > >> >> > > >> entire contents of their cordova.js file to determine what w= as > >> added > >> >> > and > >> >> > > >> what exists in there. With that in mind, I favor the package= r > >> >> > approach, > >> >> > > >> which would require: > >> >> > > >> > >> >> > > > > >> >> > > >Very good point about concat making it hard to track bugs! I > >> wonder if > >> >> > > >there's a better way than requiring users to manually add the > tags > >> (we > >> >> > > >don't require them to manually add native files to their proje= ct > >> >> files). > >> >> > > > > >> >> > > >One thought is to have cordova-packer output source-maps. I > don't > >> >> think > >> >> > > >there's very good support for them in mobile browsers yet, but > we > >> >> could > >> >> > > >use > >> >> > > >them to manually map exception line numbers to file+line > numbers. > >> >> > > > > >> >> > > >Another idea is to use exec + special comment that is used in > our > >> >> > existing > >> >> > > >pkg/debug/*.js files. I don't think support for this is all th= at > >> great > >> >> > > >either though. > >> >> > > > > >> >> > > >Another idea is to have cordova.js inject a script tag for eac= h > >> >> module. > >> >> > > >This may have an adverse effect on start-up time, but probably > no > >> >> worse > >> >> > > >than if the user manually adds all of the script tags > separately. > >> >> > Winner? > >> >> > > > >> >> > > I don't think the script tag is a giant issue, but I do think i= t > is > >> a > >> >> > > slipper slope problem to try and solve. What if the user has a > >> >> multipage > >> >> > > application? Do we then add script tags automatically to all > pages? > >> >> What > >> >> > > if the user only uses the plugin on specific pages? Etc etc > >> >> > > > >> >> > > >> >> > I'm suggesting that any page that include (manually) cordova.js > will > >> have > >> >> > it dynamically inject installed plugin JS files. Should work fine > in a > >> >> > multi-page app. We don't currently disable plugins on a per-page > >> basis. > >> >> Is > >> >> > this really an important use-case? If so, I'm sure we could figur= e > out > >> >> how > >> >> > to not inject script tags for plugins you don't want. > >> >> > > >> >> > >> > --0015175defeec0084c04d5b378e9--