-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-views.js
41 lines (37 loc) · 1.04 KB
/
get-views.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import load from './import.js'
export default ({ mounted, schema, uri }) => (
Promise.all(
mounted.map(({ app, path }, mountedAt) => (
load(app)
.then(bundle => (
bundle.get({ path })
.then(views => ({
app,
path,
mountedAt,
Runtime: bundle.Runtime,
views,
}))
)
)
))
).then(viewsPerApp => {
// get the focus app's runtime
const focusApp = viewsPerApp[viewsPerApp.length - 1]
let context = schema
const views = viewsPerApp.map(data => {
const base = `${context}${data.app}`
context = `${base}${data.path}`
return data.views.map(view => ({
...view, // TODO run through edge cases to see if it's alright to mutate v instead
context: `${base}${view.path}`,
key: `${data.app}-${data.mountedAt}-${view.path}`,
uri,
}))
}).reduce((a, b) => a.concat(b), [])
return {
Runtime: focusApp && focusApp.Runtime,
views,
}
})
)