@nativue/core 0.15.2 → 0.15.3
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/cli/hot-prelude.mjs +29 -0
- package/cli/nativue.mjs +1 -10
- package/ios/Bridge.swift +3 -3
- package/ios/NativueView.swift +10 -5
- package/ios/ScreenStackView.swift +7 -1
- package/package.json +5 -5
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// What the dev server puts before the bundle: Vite's module runtime and nativue's hot client.
|
|
2
|
+
import { readFileSync } from 'node:fs'
|
|
3
|
+
import { createRequire } from 'node:module'
|
|
4
|
+
|
|
5
|
+
const HOT_CLIENT_PATH = new URL('./hot-client.js', import.meta.url)
|
|
6
|
+
// The ESM syntax Hermes doesn't compile: the runtime's export list, and import() but not a method
|
|
7
|
+
// named import (`hooks.import(`).
|
|
8
|
+
export const EXPORT_LIST = /^export \{[^}]*\};?$/m
|
|
9
|
+
export const DYNAMIC_IMPORT = /(?<![.\w$])import\s*\(/g
|
|
10
|
+
|
|
11
|
+
export function hotPrelude(clientId, serverURL) {
|
|
12
|
+
const viteRequire = createRequire(createRequire(import.meta.url).resolve('vite'))
|
|
13
|
+
const runtime = readFileSync(viteRequire.resolve('rolldown/experimental/runtime'), 'utf8')
|
|
14
|
+
const client = readFileSync(HOT_CLIENT_PATH, 'utf8')
|
|
15
|
+
const options = JSON.stringify({ clientId, serverURL })
|
|
16
|
+
|
|
17
|
+
return `${hermesCompatible(runtime)}\nvar __NATIVUE_HOT__ = ${options};\n${client}\n`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Hermes compiles neither `export` nor `import()`. The runtime's import() loads lazy chunks, which
|
|
22
|
+
* nativue builds without, so it's never called.
|
|
23
|
+
*/
|
|
24
|
+
function hermesCompatible(runtime) {
|
|
25
|
+
return `function __nativueDynamicImport(specifier) {
|
|
26
|
+
return Promise.reject(new Error('nativue builds without lazy chunks: ' + specifier))
|
|
27
|
+
}
|
|
28
|
+
${runtime.replace(EXPORT_LIST, '').replace(DYNAMIC_IMPORT, '__nativueDynamicImport(')}`
|
|
29
|
+
}
|
package/cli/nativue.mjs
CHANGED
|
@@ -17,10 +17,10 @@ import http from 'node:http'
|
|
|
17
17
|
import net from 'node:net'
|
|
18
18
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, watch } from 'node:fs'
|
|
19
19
|
import { randomUUID } from 'node:crypto'
|
|
20
|
-
import { createRequire } from 'node:module'
|
|
21
20
|
import { relative } from 'node:path'
|
|
22
21
|
import { fileURLToPath } from 'node:url'
|
|
23
22
|
import { compileToBytecode } from './hermes.mjs'
|
|
23
|
+
import { hotPrelude } from './hot-prelude.mjs'
|
|
24
24
|
import { resolvePlugins } from './plugins.mjs'
|
|
25
25
|
import { linkNativePackages, PLATFORMS, prebuild } from './prebuild.mjs'
|
|
26
26
|
import { runOnAndroid, runOnIOS } from './run.mjs'
|
|
@@ -238,15 +238,6 @@ function vueHotUpdates(sendToApps) {
|
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
function hotPrelude(clientId, serverURL) {
|
|
242
|
-
const viteRequire = createRequire(createRequire(import.meta.url).resolve('vite'))
|
|
243
|
-
const runtime = readFileSync(viteRequire.resolve('rolldown/experimental/runtime'), 'utf8')
|
|
244
|
-
const client = readFileSync(frameworkPath('cli/hot-client.js'), 'utf8')
|
|
245
|
-
const options = JSON.stringify({ clientId, serverURL })
|
|
246
|
-
|
|
247
|
-
return `${runtime.replace(/^export \{[^}]*\};?$/m, '')}\nvar __NATIVUE_HOT__ = ${options};\n${client}\n`
|
|
248
|
-
}
|
|
249
|
-
|
|
250
241
|
// Vite's full bundle mode builds the app and, on save, a patch with the changed modules. Each app
|
|
251
242
|
// runtime is a Vite client: the dev server speaks Vite's protocol for it and relays updates over SSE.
|
|
252
243
|
async function dev() {
|
package/ios/Bridge.swift
CHANGED
|
@@ -158,7 +158,7 @@ final class Bridge {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
private func modalTransitionInProgress() -> UIViewControllerTransitionCoordinator? {
|
|
161
|
-
guard let presentedViewController = rootView.
|
|
161
|
+
guard let presentedViewController = rootView.hostWindow?.rootViewController?.presentedViewController else {
|
|
162
162
|
return nil
|
|
163
163
|
}
|
|
164
164
|
|
|
@@ -440,7 +440,7 @@ final class Bridge {
|
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
define("dismissKeyboard") { [unowned self] _ in
|
|
443
|
-
enqueue { [unowned self] in rootView.
|
|
443
|
+
enqueue { [unowned self] in rootView.hostWindow?.endEditing(true) }
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
return JavaScriptRuntime(functions: functions) { [unowned self] message, stack in
|
|
@@ -492,7 +492,7 @@ final class Bridge {
|
|
|
492
492
|
|
|
493
493
|
private func resetNodeTree() {
|
|
494
494
|
// Sheets of the old tree's screen stacks too, which only their stack knows about.
|
|
495
|
-
rootView.
|
|
495
|
+
rootView.hostWindow?.rootViewController?.dismiss(animated: false)
|
|
496
496
|
rootView.subviews.forEach { $0.removeFromSuperview() }
|
|
497
497
|
contentRootsByNodeId.values.forEach { ($0 as? ModalController)?.setVisible(false) }
|
|
498
498
|
contentRootsByNodeId = [:]
|
package/ios/NativueView.swift
CHANGED
|
@@ -42,6 +42,8 @@ struct VueRoot: UIViewRepresentable {
|
|
|
42
42
|
final class RootView: UIView {
|
|
43
43
|
var onLayoutSubviews: (() -> Void)?
|
|
44
44
|
var onTraitCollectionChange: ((_ previous: UITraitCollection?) -> Void)?
|
|
45
|
+
/// `window` is nil under a full-screen modal: the bridge finds that modal through this one.
|
|
46
|
+
private(set) weak var hostWindow: UIWindow?
|
|
45
47
|
|
|
46
48
|
override func layoutSubviews() {
|
|
47
49
|
super.layoutSubviews()
|
|
@@ -53,6 +55,14 @@ final class RootView: UIView {
|
|
|
53
55
|
onTraitCollectionChange?(previous)
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
override func didMoveToWindow() {
|
|
59
|
+
super.didMoveToWindow()
|
|
60
|
+
if let window { hostWindow = window }
|
|
61
|
+
#if DEBUG
|
|
62
|
+
becomeFirstResponder()
|
|
63
|
+
#endif
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
#if DEBUG
|
|
57
67
|
var onReloadShortcut: (() -> Void)?
|
|
58
68
|
|
|
@@ -62,11 +72,6 @@ final class RootView: UIView {
|
|
|
62
72
|
[UIKeyCommand(input: "r", modifierFlags: .command, action: #selector(reloadShortcutPressed))]
|
|
63
73
|
}
|
|
64
74
|
|
|
65
|
-
override func didMoveToWindow() {
|
|
66
|
-
super.didMoveToWindow()
|
|
67
|
-
becomeFirstResponder()
|
|
68
|
-
}
|
|
69
|
-
|
|
70
75
|
@objc private func reloadShortcutPressed() {
|
|
71
76
|
onReloadShortcut?()
|
|
72
77
|
}
|
|
@@ -73,6 +73,7 @@ final class ScreenStackView: UIView, ScreenContainer, UINavigationControllerDele
|
|
|
73
73
|
super.didMoveToWindow()
|
|
74
74
|
|
|
75
75
|
embedInNearestViewController(navigationController)
|
|
76
|
+
if window != nil { scheduleSync() }
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
private func configure(_ navigationController: UINavigationController) {
|
|
@@ -185,9 +186,14 @@ final class ScreenStackView: UIView, ScreenContainer, UINavigationControllerDele
|
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
private func presentModal(_ group: [ScreenController]) {
|
|
188
|
-
let modalNavigationController = UINavigationController()
|
|
189
189
|
let presenter = modalNavigationControllers.last ?? navigationController
|
|
190
190
|
|
|
191
|
+
// Out of the window under a full-screen modal: UIKit would refuse without calling back. didMoveToWindow
|
|
192
|
+
// syncs again once it's back.
|
|
193
|
+
guard presenter.view.window != nil else { return }
|
|
194
|
+
|
|
195
|
+
let modalNavigationController = UINavigationController()
|
|
196
|
+
|
|
191
197
|
configure(modalNavigationController)
|
|
192
198
|
modalNavigationController.setViewControllers(group, animated: false)
|
|
193
199
|
modalNavigationController.modalPresentationStyle =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nativue/core",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"description": "Vue rendering real native views on iOS and Android",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@vitejs/plugin-vue": "^6.0.11",
|
|
40
|
-
"@vue/runtime-core": "^3.5.
|
|
40
|
+
"@vue/runtime-core": "^3.5.46",
|
|
41
41
|
"hermes-compiler": "260318099.0.8",
|
|
42
|
-
"vite": "^8.
|
|
43
|
-
"vue": "^3.5.
|
|
42
|
+
"vite": "^8.4.0",
|
|
43
|
+
"vue": "^3.5.46",
|
|
44
44
|
"whatwg-fetch": "^3.6.20"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"typescript": "^
|
|
47
|
+
"typescript": "^6.0.3",
|
|
48
48
|
"vue-tsc": "^3.3.14"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|