@webhandle/external-resource-manager 1.0.3 → 1.0.4
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.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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.
|
|
107
|
+
this.includedResources.add(resource)
|
|
84
108
|
}
|
|
85
|
-
this.includedResources.add(resource)
|
|
86
109
|
}
|
|
87
110
|
|
|
88
111
|
provideResource(resource) {
|
|
@@ -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)
|