@nativue/core 0.14.1 → 0.15.1
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.
|
@@ -88,16 +88,18 @@ class Bridge(private val activity: ComponentActivity, private val rootView: Root
|
|
|
88
88
|
/** Set by LayoutAnimation.configureNext in JS; animates the batch it's sent with. */
|
|
89
89
|
private var nextLayoutAnimation: Map<*, *>? = null
|
|
90
90
|
|
|
91
|
+
/** Thread-safe: used from the JS thread (requests, and clearing them in run) and the requests' own. */
|
|
92
|
+
private val blobStore = BlobStore.shared
|
|
93
|
+
private val networking = Networking(activity, blobStore) { owner, requestId, eventName, payload ->
|
|
94
|
+
callIfStillRunning(owner, "__networkEvent", requestId, eventName, payload)
|
|
95
|
+
}
|
|
96
|
+
|
|
91
97
|
// Only touched on the main thread.
|
|
92
98
|
private val nodesById = HashMap<Int, NativeNode>()
|
|
93
99
|
private val animatedGraph = AnimatedGraph()
|
|
94
100
|
private val modalHostsByNodeId = HashMap<Int, ModalHost>()
|
|
95
101
|
private val gestureReportersByNodeId = HashMap<Int, GestureReporter>()
|
|
96
102
|
/** Views with @layout, and the box they last reported. */
|
|
97
|
-
private val blobStore = BlobStore.shared
|
|
98
|
-
private val networking = Networking(activity, blobStore) { owner, requestId, eventName, payload ->
|
|
99
|
-
callIfStillRunning(owner, "__networkEvent", requestId, eventName, payload)
|
|
100
|
-
}
|
|
101
103
|
private val reportedLayoutsByNodeId = mutableMapOf<Int, Map<String, Float>?>()
|
|
102
104
|
|
|
103
105
|
/** The latest window insets, mid-animation while the keyboard moves. */
|
|
@@ -262,6 +264,10 @@ class Bridge(private val activity: ComponentActivity, private val rootView: Root
|
|
|
262
264
|
errorOverlay.hide()
|
|
263
265
|
|
|
264
266
|
evaluate {
|
|
267
|
+
// Here, not in resetNodeTree: that runs on the main thread after the new bundle has started
|
|
268
|
+
// its own requests, which it would abort, and their responses' blobs.
|
|
269
|
+
networking.abortAll()
|
|
270
|
+
blobStore.removeAll()
|
|
265
271
|
enqueue(::resetNodeTree)
|
|
266
272
|
|
|
267
273
|
runtime?.destroy()
|
|
@@ -670,8 +676,6 @@ class Bridge(private val activity: ComponentActivity, private val rootView: Root
|
|
|
670
676
|
}
|
|
671
677
|
modalHostsByNodeId.clear()
|
|
672
678
|
gestureReportersByNodeId.clear() // node ids start over
|
|
673
|
-
networking.abortAll() // and so do request ids
|
|
674
|
-
blobStore.removeAll() // and the Blobs that held them are gone
|
|
675
679
|
reportedLayoutsByNodeId.clear()
|
|
676
680
|
animatedGraph.reset()
|
|
677
681
|
animatedGraph.onAnimationEnd = { animationId, finished ->
|
|
@@ -242,7 +242,12 @@ class Networking(
|
|
|
242
242
|
"bytes" -> bytes
|
|
243
243
|
"blob" -> {
|
|
244
244
|
val type = contentType?.substringBefore(";")?.trim().orEmpty()
|
|
245
|
-
|
|
245
|
+
val blobId = blobStore.store(bytes)
|
|
246
|
+
|
|
247
|
+
// A reload aborts the request before clearing the store: stored after that, nothing would release it.
|
|
248
|
+
if (request.aborted) blobStore.remove(blobId)
|
|
249
|
+
|
|
250
|
+
mapOf("blobId" to blobId, "offset" to 0, "size" to bytes.size, "type" to type)
|
|
246
251
|
}
|
|
247
252
|
else -> String(bytes, Charsets.UTF_8)
|
|
248
253
|
}
|
package/cli/nativue.mjs
CHANGED
|
@@ -220,10 +220,12 @@ function viteConfig({ mode, plugins = [] }) {
|
|
|
220
220
|
finishBundle(mode),
|
|
221
221
|
...plugins,
|
|
222
222
|
],
|
|
223
|
-
// Compiled templates and app code import from 'vue': point them to the native renderer.
|
|
223
|
+
// Compiled templates and app code import from 'vue': point them to the native renderer. A package
|
|
224
|
+
// installed from a folder with its own node_modules gets the app's @nativue/core too, not a second one.
|
|
224
225
|
resolve: {
|
|
225
226
|
alias: [
|
|
226
227
|
{ find: /^vue$/, replacement: frameworkPath('src/renderer.ts') },
|
|
228
|
+
{ find: /^@nativue\/core$/, replacement: frameworkPath('src/renderer.ts') },
|
|
227
229
|
{ find: /^@nativue\/core\/router$/, replacement: frameworkPath('src/router.ts') },
|
|
228
230
|
{ find: /^@\//, replacement: `${process.cwd()}/src/` },
|
|
229
231
|
],
|
package/ios/Bridge.swift
CHANGED
|
@@ -42,6 +42,10 @@ final class Bridge {
|
|
|
42
42
|
/// Kept on the JS queue: the router's screens, reopened after a reload in development.
|
|
43
43
|
private var savedNavigation: String?
|
|
44
44
|
|
|
45
|
+
/// Thread-safe: used from the JS queue (requests, and clearing them in run) and Networking's own.
|
|
46
|
+
private let blobStore = BlobStore.shared
|
|
47
|
+
private lazy var networking = Networking(blobStore: blobStore)
|
|
48
|
+
|
|
45
49
|
// Only touched on the main thread.
|
|
46
50
|
var rootView: RootView!
|
|
47
51
|
private var gestureReportersByNodeId: [Int: GestureReporter] = [:]
|
|
@@ -49,8 +53,6 @@ final class Bridge {
|
|
|
49
53
|
var nodesById: [Int: NativeNode] = [:]
|
|
50
54
|
/// Views with @layout, and the box they last reported.
|
|
51
55
|
private var reportedLayoutsByNodeId: [Int: CGRect] = [:]
|
|
52
|
-
private let blobStore = BlobStore.shared
|
|
53
|
-
private lazy var networking = Networking(blobStore: blobStore)
|
|
54
56
|
/// Modals and screens: their content is laid out as a separate Yoga root.
|
|
55
57
|
private var contentRootsByNodeId: [Int: ContentRoot] = [:]
|
|
56
58
|
/// For Dimensions.get('window'): the screen's at start, then the root view's, kept on the JS queue.
|
|
@@ -144,6 +146,10 @@ final class Bridge {
|
|
|
144
146
|
errorOverlay.hide()
|
|
145
147
|
|
|
146
148
|
evaluate { [unowned self] in
|
|
149
|
+
// Here, not in resetNodeTree: that runs on the main thread after the new bundle has started
|
|
150
|
+
// its own requests, which it would abort, and their responses' blobs.
|
|
151
|
+
networking.abortAll()
|
|
152
|
+
blobStore.removeAll()
|
|
147
153
|
enqueue { [unowned self] in resetNodeTree() }
|
|
148
154
|
|
|
149
155
|
runtime = makeRuntime()
|
|
@@ -491,8 +497,6 @@ final class Bridge {
|
|
|
491
497
|
contentRootsByNodeId.values.forEach { ($0 as? ModalController)?.setVisible(false) }
|
|
492
498
|
contentRootsByNodeId = [:]
|
|
493
499
|
gestureReportersByNodeId = [:] // node ids start over
|
|
494
|
-
networking.abortAll() // and so do request ids
|
|
495
|
-
blobStore.removeAll() // and the Blobs that held them are gone
|
|
496
500
|
reportedLayoutsByNodeId = [:]
|
|
497
501
|
animatedGraph.reset()
|
|
498
502
|
animatedGraph.onAnimationEnd = { [unowned self] animationId, finished in
|
package/ios/Networking.swift
CHANGED
|
@@ -95,14 +95,17 @@ final class Networking: NSObject, URLSessionDataDelegate {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
/// On reload: the requests' JS is gone.
|
|
98
|
+
/// On reload: the requests' JS is gone. Waits, so no response finishing meanwhile stores a blob after
|
|
99
|
+
/// the bridge clears them. This queue never waits on the JS one.
|
|
99
100
|
func abortAll() {
|
|
100
|
-
|
|
101
|
+
let abort = BlockOperation { [self] in
|
|
101
102
|
tasksByRequestId.values.forEach { $0.cancel() }
|
|
102
103
|
statesByTaskId.values.forEach { $0.deleteTemporaryFile() }
|
|
103
104
|
tasksByRequestId = [:]
|
|
104
105
|
statesByTaskId = [:]
|
|
105
106
|
}
|
|
107
|
+
|
|
108
|
+
queue.addOperations([abort], waitUntilFinished: true)
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
// MARK: URLSessionDataDelegate
|