@webhandle/external-resource-manager 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,6 +58,26 @@ export default class ExternalResourceManager {
58
58
  }
59
59
  }
60
60
 
61
+ expandURLList(resource) {
62
+ let urls
63
+ if(typeof resource.url === 'string') {
64
+ urls = resource.url.split('\n').map(line => line.trim()).filter(line => !!line)
65
+ }
66
+ else if(Array.isArray(resource.url)) {
67
+ urls = resource.url
68
+ }
69
+
70
+ if(!urls) {
71
+ return [resource]
72
+ }
73
+ if(urls.length === 1) {
74
+ return [resource]
75
+ }
76
+
77
+
78
+
79
+ }
80
+
61
81
  includeResource(resource) {
62
82
  if(!resource) {
63
83
  return
@@ -65,24 +85,27 @@ export default class ExternalResourceManager {
65
85
  if(typeof resource === 'object' && resource instanceof Resource === false) {
66
86
  resource = new Resource(resource)
67
87
  }
68
- this._noteSatisfies(resource)
69
- if(this.alreadySatisfied.has(resource.url)) {
70
- // We've already got a resource which satisfies this url
71
- this.differentlySatisfiedResource.push(resource)
72
- return
73
- }
74
- if(resource.satisfies && Array.isArray(resource.satisfies)) {
75
- // We're going to remove any previously included resource which is satisfied
76
- // by this resource
77
- for(let included of this.includedResources) {
78
- if(resource.satisfies.includes(included.url)) {
79
- this.includedResources.delete(included)
80
- this.differentlySatisfiedResource.push(resource)
88
+ let resources = this.expandURLList(resource)
89
+ for(let resource of resources) {
90
+ this._noteSatisfies(resource)
91
+ if(this.alreadySatisfied.has(resource.url)) {
92
+ // We've already got a resource which satisfies this url
93
+ this.differentlySatisfiedResource.push(resource)
94
+ return
95
+ }
96
+ if(resource.satisfies && Array.isArray(resource.satisfies)) {
97
+ // We're going to remove any previously included resource which is satisfied
98
+ // by this resource
99
+ for(let included of this.includedResources) {
100
+ if(resource.satisfies.includes(included.url)) {
101
+ this.includedResources.delete(included)
102
+ this.differentlySatisfiedResource.push(resource)
103
+ }
81
104
  }
105
+ this._noteSatisfies(resource)
82
106
  }
83
- this._noteSatisfies(resource)
107
+ this.includedResources.add(resource)
84
108
  }
85
- this.includedResources.add(resource)
86
109
  }
87
110
 
88
111
  provideResource(resource) {
@@ -17,7 +17,14 @@ export default function createImportmapGenerator(webhandle) {
17
17
 
18
18
  found = true
19
19
  if(resource.data && !resource.url) {
20
- let content = `export default ${JSON.stringify(resource.data)}`
20
+ let d = JSON.stringify(resource.data)
21
+ // # in the value trigger a problem in the browser where it doesn't think #
22
+ // are valid for the types of URLs it's looking for. That's a little weird
23
+ // given that this is a data url. It's possible these values should be
24
+ // fully URI encoded, but other values which would normally need that
25
+ // don't seem to cause problems.
26
+ d = d.split('#').join('%23')
27
+ let content = `export default ${d}`
21
28
  let url = `data:text/javascript,${content}`
22
29
  resource.url = url
23
30
  }
@@ -16,6 +16,7 @@ initializeWebhandleComponent.templatePaths = ['views']
16
16
 
17
17
  initializeWebhandleComponent.setup = async function (webhandle, config) {
18
18
  let compmanager = new ComponentManager()
19
+ compmanager.config = config
19
20
 
20
21
  let generator = createImportmapGenerator(webhandle)
21
22
  let cssRender = createTextCssRenderer(webhandle)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webhandle/external-resource-manager",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "external-resource-manager.js",
6
6
  "scripts": {