{"action":"created","comment":{"url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/comments/54747774","id":54747774,"diff_hunk":"@@ -0,0 +1,109 @@\n+# Static Asset Loader\n+\n+This can be used by client-side web applications to request and receive the\n+static resources they require from a suitable static asset server. The\n+primary objective is to allow multiple discrete web applications on the same\n+page to converge on shared dependencies. Each dependency is only loaded\n+once and this reduces the overall page footprint.\n+\n+## Basic Usage\n+\n+### Configuration\n+\n+The static asset loader must be configured with the following:\n+\n+  * A function to generate asset URLs from asset name and version strings.\n+  * The name of the application namespace.\n+\n+Applications sharing static assets must use the same namespace.\n+\n+```javascript\n+var namespacer = require('bv-ui-core/lib/namespacer');\n+var staticAssetLoaderFactory = require('bv-ui-core/lib/staticAssetLoader');\n+\n+var staticAssetLoader = staticAssetLoaderFactory.create({\n+  /**\n+   * Convert one or more asset strings into a static asset service URL.\n+   *\n+   * The details depend on the static asset server capabilities. This is an\n+   * example implementation for a server capable of delivering asset bundles.\n+   *\n+   * @param {String[]} An array of asset names and version: ['jQuery@2.0.0'].\n+   * @return {String} The URL for the asset.\n+   */\n+  generateUrl: function (assetNames, namespaceName) {\n+    var filename = encodeURIComponent(assetNames.slice(0).sort().join('+')) + '.js';\n+\n+    namespaceName = encodeURIComponent(namespaceName);\n+    return 'https://static.example.com/1/asset/' + namespaceName + '/' + filename;\n+  },\n+\n+  /**\n+   * Provide the name of a namespace to hold the _staticAssetRegistry properties\n+   * and methods. Applications sharing static assets must use the same\n+   * namespace.\n+   */\n+  namespaceName: 'EXAMPLE'\n+});\n+```\n+\n+### Require Assets\n+\n+When the application requires a resource of a supported type, use the client to\n+request that resource via the `require` method.\n+\n+```javascript\n+// Request the desired assets. For example:\n+staticAssetLoader.require([\n+  'underscore@1.0.0',\n+  'jquery-custom@1.11.1',\n+  'backbone@1.2.0'\n+], function (_, $, Backbone) {\n+  // This callback will be invoked when all of the required assets have been\n+  // resolved.\n+});\n+```\n+\n+Note that when requesting an asset that has dependency assets - for example,\n+Backbone depends on jQuery and either Underscore or Lodash - it is necessary to\n+request those dependencies in the same `require` call.\n+\n+### Provide Assets\n+\n+Applications that ship with resources that might be useful to other applications\n+on the page can provide those resources via the static asset loader. This again\n+allows for a convergence of dependencies and reduced page weight.","path":"lib/staticAssetLoader/README.md","position":75,"original_position":75,"commit_id":"ff619bd960fb99eef9b5a4e19a042dcb76123d67","original_commit_id":"ff619bd960fb99eef9b5a4e19a042dcb76123d67","user":{"login":"reason-bv","id":6154515,"avatar_url":"https://avatars.githubusercontent.com/u/6154515?v=3","gravatar_id":"","url":"https://api.github.com/users/reason-bv","html_url":"https://github.com/reason-bv","followers_url":"https://api.github.com/users/reason-bv/followers","following_url":"https://api.github.com/users/reason-bv/following{/other_user}","gists_url":"https://api.github.com/users/reason-bv/gists{/gist_id}","starred_url":"https://api.github.com/users/reason-bv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reason-bv/subscriptions","organizations_url":"https://api.github.com/users/reason-bv/orgs","repos_url":"https://api.github.com/users/reason-bv/repos","events_url":"https://api.github.com/users/reason-bv/events{/privacy}","received_events_url":"https://api.github.com/users/reason-bv/received_events","type":"User","site_admin":false},"body":"Yes, `require` and `define` can be called in any order. Though behavior becomes undefined if there is double definition of a given resource, as different people will have a different reference if the library itself doesn't prevent that. I should probably prevent that from happening in the loader code.","created_at":"2016-03-02T16:23:30Z","updated_at":"2016-03-02T16:23:30Z","html_url":"https://github.com/bazaarvoice/bv-ui-core/pull/53#discussion_r54747774","pull_request_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/53","_links":{"self":{"href":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/comments/54747774"},"html":{"href":"https://github.com/bazaarvoice/bv-ui-core/pull/53#discussion_r54747774"},"pull_request":{"href":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/53"}}},"pull_request":{"url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/53","id":61129852,"html_url":"https://github.com/bazaarvoice/bv-ui-core/pull/53","diff_url":"https://github.com/bazaarvoice/bv-ui-core/pull/53.diff","patch_url":"https://github.com/bazaarvoice/bv-ui-core/pull/53.patch","issue_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/issues/53","number":53,"state":"open","locked":false,"title":"Add a static asset loader client.","user":{"login":"reason-bv","id":6154515,"avatar_url":"https://avatars.githubusercontent.com/u/6154515?v=3","gravatar_id":"","url":"https://api.github.com/users/reason-bv","html_url":"https://github.com/reason-bv","followers_url":"https://api.github.com/users/reason-bv/followers","following_url":"https://api.github.com/users/reason-bv/following{/other_user}","gists_url":"https://api.github.com/users/reason-bv/gists{/gist_id}","starred_url":"https://api.github.com/users/reason-bv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reason-bv/subscriptions","organizations_url":"https://api.github.com/users/reason-bv/orgs","repos_url":"https://api.github.com/users/reason-bv/repos","events_url":"https://api.github.com/users/reason-bv/events{/privacy}","received_events_url":"https://api.github.com/users/reason-bv/received_events","type":"User","site_admin":false},"body":"This adds an implementation of the static asset loader client to bv-ui-core, as a first step to opening the static asset service.\r\n\r\nNote that this is a much simplified version of the first pass internal static asset service, as that had some issues with conflicting dependency declarations. Here dependencies are implicit in the request for resources: you request all of the dependencies you need with the asset.\r\n\r\nAlso included in this:\r\n\r\n- catch up the changelog.\r\n- minor logger changes.\r\n- update old Node.js dependencies.","created_at":"2016-02-29T19:25:04Z","updated_at":"2016-03-02T16:23:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5f12386956e69b3cfc89c04bfcd96463fadf8167","assignee":{"login":"sirugh","id":1278869,"avatar_url":"https://avatars.githubusercontent.com/u/1278869?v=3","gravatar_id":"","url":"https://api.github.com/users/sirugh","html_url":"https://github.com/sirugh","followers_url":"https://api.github.com/users/sirugh/followers","following_url":"https://api.github.com/users/sirugh/following{/other_user}","gists_url":"https://api.github.com/users/sirugh/gists{/gist_id}","starred_url":"https://api.github.com/users/sirugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirugh/subscriptions","organizations_url":"https://api.github.com/users/sirugh/orgs","repos_url":"https://api.github.com/users/sirugh/repos","events_url":"https://api.github.com/users/sirugh/events{/privacy}","received_events_url":"https://api.github.com/users/sirugh/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/53/commits","review_comments_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/53/comments","review_comment_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/issues/53/comments","statuses_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/statuses/ff619bd960fb99eef9b5a4e19a042dcb76123d67","head":{"label":"reason-bv:static-asset","ref":"static-asset","sha":"ff619bd960fb99eef9b5a4e19a042dcb76123d67","user":{"login":"reason-bv","id":6154515,"avatar_url":"https://avatars.githubusercontent.com/u/6154515?v=3","gravatar_id":"","url":"https://api.github.com/users/reason-bv","html_url":"https://github.com/reason-bv","followers_url":"https://api.github.com/users/reason-bv/followers","following_url":"https://api.github.com/users/reason-bv/following{/other_user}","gists_url":"https://api.github.com/users/reason-bv/gists{/gist_id}","starred_url":"https://api.github.com/users/reason-bv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reason-bv/subscriptions","organizations_url":"https://api.github.com/users/reason-bv/orgs","repos_url":"https://api.github.com/users/reason-bv/repos","events_url":"https://api.github.com/users/reason-bv/events{/privacy}","received_events_url":"https://api.github.com/users/reason-bv/received_events","type":"User","site_admin":false},"repo":{"id":41712835,"name":"bv-ui-core","full_name":"reason-bv/bv-ui-core","owner":{"login":"reason-bv","id":6154515,"avatar_url":"https://avatars.githubusercontent.com/u/6154515?v=3","gravatar_id":"","url":"https://api.github.com/users/reason-bv","html_url":"https://github.com/reason-bv","followers_url":"https://api.github.com/users/reason-bv/followers","following_url":"https://api.github.com/users/reason-bv/following{/other_user}","gists_url":"https://api.github.com/users/reason-bv/gists{/gist_id}","starred_url":"https://api.github.com/users/reason-bv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reason-bv/subscriptions","organizations_url":"https://api.github.com/users/reason-bv/orgs","repos_url":"https://api.github.com/users/reason-bv/repos","events_url":"https://api.github.com/users/reason-bv/events{/privacy}","received_events_url":"https://api.github.com/users/reason-bv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/reason-bv/bv-ui-core","description":"A Node module for common Bazaarvoice UI code.","fork":true,"url":"https://api.github.com/repos/reason-bv/bv-ui-core","forks_url":"https://api.github.com/repos/reason-bv/bv-ui-core/forks","keys_url":"https://api.github.com/repos/reason-bv/bv-ui-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reason-bv/bv-ui-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reason-bv/bv-ui-core/teams","hooks_url":"https://api.github.com/repos/reason-bv/bv-ui-core/hooks","issue_events_url":"https://api.github.com/repos/reason-bv/bv-ui-core/issues/events{/number}","events_url":"https://api.github.com/repos/reason-bv/bv-ui-core/events","assignees_url":"https://api.github.com/repos/reason-bv/bv-ui-core/assignees{/user}","branches_url":"https://api.github.com/repos/reason-bv/bv-ui-core/branches{/branch}","tags_url":"https://api.github.com/repos/reason-bv/bv-ui-core/tags","blobs_url":"https://api.github.com/repos/reason-bv/bv-ui-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reason-bv/bv-ui-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reason-bv/bv-ui-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/reason-bv/bv-ui-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reason-bv/bv-ui-core/statuses/{sha}","languages_url":"https://api.github.com/repos/reason-bv/bv-ui-core/languages","stargazers_url":"https://api.github.com/repos/reason-bv/bv-ui-core/stargazers","contributors_url":"https://api.github.com/repos/reason-bv/bv-ui-core/contributors","subscribers_url":"https://api.github.com/repos/reason-bv/bv-ui-core/subscribers","subscription_url":"https://api.github.com/repos/reason-bv/bv-ui-core/subscription","commits_url":"https://api.github.com/repos/reason-bv/bv-ui-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/reason-bv/bv-ui-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/reason-bv/bv-ui-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/reason-bv/bv-ui-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/reason-bv/bv-ui-core/contents/{+path}","compare_url":"https://api.github.com/repos/reason-bv/bv-ui-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reason-bv/bv-ui-core/merges","archive_url":"https://api.github.com/repos/reason-bv/bv-ui-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reason-bv/bv-ui-core/downloads","issues_url":"https://api.github.com/repos/reason-bv/bv-ui-core/issues{/number}","pulls_url":"https://api.github.com/repos/reason-bv/bv-ui-core/pulls{/number}","milestones_url":"https://api.github.com/repos/reason-bv/bv-ui-core/milestones{/number}","notifications_url":"https://api.github.com/repos/reason-bv/bv-ui-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reason-bv/bv-ui-core/labels{/name}","releases_url":"https://api.github.com/repos/reason-bv/bv-ui-core/releases{/id}","deployments_url":"https://api.github.com/repos/reason-bv/bv-ui-core/deployments","created_at":"2015-09-01T02:41:15Z","updated_at":"2015-09-01T02:42:45Z","pushed_at":"2016-02-29T19:18:18Z","git_url":"git://github.com/reason-bv/bv-ui-core.git","ssh_url":"git@github.com:reason-bv/bv-ui-core.git","clone_url":"https://github.com/reason-bv/bv-ui-core.git","svn_url":"https://github.com/reason-bv/bv-ui-core","homepage":"","size":88,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bazaarvoice:master","ref":"master","sha":"9c60457d6c037b22262fd128618aa4fb343072cf","user":{"login":"bazaarvoice","id":152469,"avatar_url":"https://avatars.githubusercontent.com/u/152469?v=3","gravatar_id":"","url":"https://api.github.com/users/bazaarvoice","html_url":"https://github.com/bazaarvoice","followers_url":"https://api.github.com/users/bazaarvoice/followers","following_url":"https://api.github.com/users/bazaarvoice/following{/other_user}","gists_url":"https://api.github.com/users/bazaarvoice/gists{/gist_id}","starred_url":"https://api.github.com/users/bazaarvoice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bazaarvoice/subscriptions","organizations_url":"https://api.github.com/users/bazaarvoice/orgs","repos_url":"https://api.github.com/users/bazaarvoice/repos","events_url":"https://api.github.com/users/bazaarvoice/events{/privacy}","received_events_url":"https://api.github.com/users/bazaarvoice/received_events","type":"Organization","site_admin":false},"repo":{"id":39015617,"name":"bv-ui-core","full_name":"bazaarvoice/bv-ui-core","owner":{"login":"bazaarvoice","id":152469,"avatar_url":"https://avatars.githubusercontent.com/u/152469?v=3","gravatar_id":"","url":"https://api.github.com/users/bazaarvoice","html_url":"https://github.com/bazaarvoice","followers_url":"https://api.github.com/users/bazaarvoice/followers","following_url":"https://api.github.com/users/bazaarvoice/following{/other_user}","gists_url":"https://api.github.com/users/bazaarvoice/gists{/gist_id}","starred_url":"https://api.github.com/users/bazaarvoice/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bazaarvoice/subscriptions","organizations_url":"https://api.github.com/users/bazaarvoice/orgs","repos_url":"https://api.github.com/users/bazaarvoice/repos","events_url":"https://api.github.com/users/bazaarvoice/events{/privacy}","received_events_url":"https://api.github.com/users/bazaarvoice/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bazaarvoice/bv-ui-core","description":"A Node module for common Bazaarvoice UI code.","fork":false,"url":"https://api.github.com/repos/bazaarvoice/bv-ui-core","forks_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/forks","keys_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/teams","hooks_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/hooks","issue_events_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/issues/events{/number}","events_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/events","assignees_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/assignees{/user}","branches_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/branches{/branch}","tags_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/tags","blobs_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/statuses/{sha}","languages_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/languages","stargazers_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/stargazers","contributors_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/contributors","subscribers_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/subscribers","subscription_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/subscription","commits_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/contents/{+path}","compare_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/merges","archive_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/downloads","issues_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/issues{/number}","pulls_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls{/number}","milestones_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/milestones{/number}","notifications_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/labels{/name}","releases_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/releases{/id}","deployments_url":"https://api.github.com/repos/bazaarvoice/bv-ui-core/deployments","created_at":"2015-07-13T14:03:45Z","updated_at":"2016-02-01T19:05:40Z","pushed_at":"2016-02-29T19:25:04Z","git_url":"git://github.com/bazaarvoice/bv-ui-core.git","ssh_url":"git@github.com:bazaarvoice/bv-ui-core.git","clone_url":"https://github.com/bazaarvoice/bv-ui-core.git","svn_url":"https://github.com/bazaarvoice/bv-ui-core","homepage":"","size":117,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":4,"forks":9,"open_issues":4,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/53"},"html":{"href":"https://github.com/bazaarvoice/bv-ui-core/pull/53"},"issue":{"href":"https://api.github.com/repos/bazaarvoice/bv-ui-core/issues/53"},"comments":{"href":"https://api.github.com/repos/bazaarvoice/bv-ui-core/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bazaarvoice/bv-ui-core/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/bazaarvoice/bv-ui-core/statuses/ff619bd960fb99eef9b5a4e19a042dcb76123d67"}}}}