Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-19392

Load JS files and image assets relative to a different codebase than resourcesDirectory

    Details

    • Type: New Feature
    • Status: Open
    • Priority: None
    • Resolution: Unresolved
    • Affects Version/s: Release 4.1.0
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Environment:

      SDK 4.1.0 / master

      Description

      There's a growing number of use cases where you would want to require() JavaScript files and image assets from a different codebase than the default Ti.Filesystem.resourcesDirectory.

      • LiveViewer, TiShadow and potentially LiveView.
      • Apps or frameworks for apps built on Titanium that let you update an app by pushing new scripts and images to it, much like ChariTi, GoodBarber.com and AppMachine.com

      These currently require to modify loaded JavaScript files to reroute calls to require() and paths to image assets to custom methods that look up the actual full path and use that with the original methods. This is hacky and often not that stable.

      Desired behaviour

      app.js

       
      // only once use full path
      var b = require(Ti.Filesystem.applicationDataDirectory + 'foo/b');
      

      b.js

       
      // this will load relative to dirname(b.js)
      var c = require('./c');
       
      var i = Ti.UI.createImageView({
        // this will load relative to dirname(b.js)
        image: './i.png'
      });
      

      Possible solutions

      Requiring from a full path already works. What needs to be done is that calls to require() and image assets that start with ./ - like NodeJS - will be resolved relative to the directory of the JavaScript file. So somehow, our API needs to be aware of this context.

      This is probably related to if not included by TIMOB-16078.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                fokkezb Fokke Zandbergen
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration