@fullstackunicorn/webapp 2.0.3 → 2.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.
package/load/engine.js CHANGED
@@ -40,7 +40,8 @@ class Engine {
40
40
 
41
41
  changed = async lang => {
42
42
  const [current, previous] = await Promise.all([this.pulse(lang), get(this.key(lang))])
43
- return !previous?.complete || this.signature(previous.state) !== this.signature(current)
43
+ const resourcesReady = previous?.resources === true || previous?.complete === true
44
+ return !resourcesReady || this.signature(previous.state) !== this.signature(current)
44
45
  }
45
46
 
46
47
  run = async (lang, width, signal, onResources) => {
@@ -84,12 +85,15 @@ class Engine {
84
85
  const item = typeof value === 'string' ? before.items?.[value] : value
85
86
  return item?.kind === 'resource'
86
87
  })
87
- nextItems = await resources.apply(preload, width, nextItems, signal, () => onResources?.(refresh))
88
- await set(key, { state: response.current, complete: true, items: nextItems, geometry })
88
+ nextItems = await resources.apply(preload, width, nextItems, signal, async resourceItems => {
89
+ await set(key, { state: response.current, complete: false, resources: true, items: resourceItems, geometry })
90
+ await onResources?.(refresh)
91
+ })
92
+ await set(key, { state: response.current, complete: true, resources: true, items: nextItems, geometry })
89
93
  } else if (geometryChanged) {
90
94
  await onResources?.(false)
91
95
  nextItems = await resources.resize(nextItems, width, signal)
92
- await set(key, { ...before, state: current, complete: true, items: nextItems, geometry })
96
+ await set(key, { ...before, state: current, complete: true, resources: true, items: nextItems, geometry })
93
97
  } else {
94
98
  await onResources?.(false)
95
99
  await set(key, { ...before, state: current })
package/load/resources.js CHANGED
@@ -77,7 +77,7 @@ class Resources {
77
77
  await client.cacheDataSet({ endpoint: resource.url(item.path), value: item.value, version: item.sha256 })
78
78
  next[item.key] = item
79
79
  })
80
- await onResources?.()
80
+ await onResources?.(next)
81
81
 
82
82
  const pictures = changed.filter(item => item.kind === 'image')
83
83
  await this.queue(pictures, images.concurrency, async item => {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.3",
2
+ "version": "2.0.4",
3
3
  "name": "@fullstackunicorn/webapp",
4
4
  "author": "lucanigido (https://fullstackunicorn.dev/author/lucanigido)",
5
5
  "description": "Shared Web and Native runtime engines and core components for Fullstack Unicorn applications",
package/package.md CHANGED
@@ -16,6 +16,8 @@ binary is actually present at the declared version in browser cache. Hosts may u
16
16
  the `Load` component's `onReady` callback to initialize page content only after
17
17
  the required JSON resources have been reconciled. Image warming continues in
18
18
  parallel and shares the same requests and cache with mounted `Img` components.
19
+ The resource-ready state is committed before content initialization, while the
20
+ complete state is committed only after image warming finishes.
19
21
  The shared
20
22
  `Img` component measures its mounted container, treats `src + hash` as binary
21
23
  identity and keeps the decoded displayed image visible until a changed pending