@nativue/core 0.19.0 → 0.21.0
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/AGENTS.md +13 -2
- package/android/nativue.settings.gradle.kts +2 -1
- package/cli/link.mjs +20 -16
- package/cli/nativue.mjs +32 -1
- package/package.json +1 -1
package/AGENTS.md
CHANGED
|
@@ -99,7 +99,8 @@ Import the runtime from `vue`: `ref`, `computed`, `StyleSheet`, `Animated`, `Lay
|
|
|
99
99
|
`clear`; promise-based, string values. Store objects as JSON. For large data or queries, use
|
|
100
100
|
`@nativue/sqlite`.
|
|
101
101
|
- `fetch`, `XMLHttpRequest`, `Blob`, `FileReader`, `URL`, `URLSearchParams`, timers and `console`
|
|
102
|
-
work as on the web, with no import.
|
|
102
|
+
work as on the web, with no import. Release builds leave out `console.log`, `info`, `debug`,
|
|
103
|
+
`trace`, `table`, `dir` and `group` calls; `warn`, `error` and `assert` stay.
|
|
103
104
|
- Accessibility: `role` and `aria-*` attributes (`aria-label`, `aria-hidden`...) on any component.
|
|
104
105
|
|
|
105
106
|
## Project
|
|
@@ -119,7 +120,17 @@ Import the runtime from `vue`: `ref`, `computed`, `StyleSheet`, `Animated`, `Lay
|
|
|
119
120
|
`@nativue/network` (`useNetworkState()`: `{ isConnected, isInternetReachable, type, isExpensive }`, live),
|
|
120
121
|
`@nativue/share` (`Share.share({ text, url, files })` opens the system's share sheet),
|
|
121
122
|
`@nativue/auth-session` (OAuth: `AuthSession.open(url, 'myapp://oauth')` with `createPKCE()`; keep tokens in secure-store),
|
|
122
|
-
`@nativue/biometrics` (`Biometrics.authenticate({ reason })` resolves `{ success }` or `{ success: false, error }`)
|
|
123
|
+
`@nativue/biometrics` (`Biometrics.authenticate({ reason })` resolves `{ success }` or `{ success: false, error }`),
|
|
124
|
+
`@nativue/location` (`usePermission(Location.getPermission, Location.requestPermission)`, then
|
|
125
|
+
`Location.getCurrentPosition({ accuracy })` or `Location.watchPosition(options, onPosition)`; iOS texts and
|
|
126
|
+
`background` in `location({...})` from `@nativue/location/plugin`),
|
|
127
|
+
`@nativue/maps` (`<MapView :initial-camera="{ center, zoom }">` with `<Marker :coordinate>` (or Vue content
|
|
128
|
+
inside it), `<Polyline>`, `<Polygon>`, `<Circle>`; `:clustering="true"` and a `#cluster="{ count }"` slot; a ref has
|
|
129
|
+
`animateCamera`, `fitToCoordinates`, `getCamera`; coordinates are `{ latitude, longitude }`; Apple Maps on iOS,
|
|
130
|
+
Android draws with the provider package named in `maps({ provider: { android } })` from `@nativue/maps/plugin`:
|
|
131
|
+
`@nativue/maps-maplibre`, whose `mapLibre({ style })` sets the style, OpenFreeMap's by default),
|
|
132
|
+
`@nativue/webview` (`<WebView :source="{ uri }" @message>`, sized by its style; a ref has `goBack`, `reload`,
|
|
133
|
+
`evaluateJavaScript(expression)`, `postMessage(data)`; the page posts with `window.nativueWebView.postMessage`).
|
|
123
134
|
A package with native code needs the app
|
|
124
135
|
rebuilt with `npm run ios` or `npm run android`, not just a reload.
|
|
125
136
|
- Notifications: `Notifications.schedule({ title, body, data }, { seconds } | { date } | { hour, minute } | null)`
|
|
@@ -54,7 +54,8 @@ fun androidPlugin(name: String, directory: File, nativue: Map<*, *>?): AndroidPl
|
|
|
54
54
|
val projectPath = ":" + name.removePrefix("@").replace('/', '-')
|
|
55
55
|
|
|
56
56
|
include(projectPath)
|
|
57
|
-
|
|
57
|
+
// The real path: through node_modules links (workspaces), Kotlin's incremental builds lose track of files.
|
|
58
|
+
project(projectPath).projectDir = File(directory, android["sources"] as String).canonicalFile
|
|
58
59
|
|
|
59
60
|
return AndroidPlugin(projectPath, android["plugin"] as String)
|
|
60
61
|
}
|
package/cli/link.mjs
CHANGED
|
@@ -62,7 +62,11 @@ export function nativuePackages(appDirectory) {
|
|
|
62
62
|
const manifest = directory && readJson(join(directory, 'package.json'))
|
|
63
63
|
const isForNativue = manifest?.nativue || manifest?.peerDependencies?.['@nativue/core']
|
|
64
64
|
|
|
65
|
-
if (manifest?.nativue)
|
|
65
|
+
if (manifest?.nativue) {
|
|
66
|
+
const requires = Object.keys({ ...manifest.dependencies, ...manifest.peerDependencies })
|
|
67
|
+
|
|
68
|
+
found.push({ name, directory, nativue: manifest.nativue, requires })
|
|
69
|
+
}
|
|
66
70
|
if (isForNativue) {
|
|
67
71
|
Object.keys(manifest.dependencies ?? {}).forEach((dependency) =>
|
|
68
72
|
pending.push([dependency, directory]),
|
|
@@ -76,19 +80,17 @@ export function nativuePackages(appDirectory) {
|
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
function iosPlugins(appDirectory) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
]
|
|
91
|
-
})
|
|
83
|
+
const packages = nativuePackages(appDirectory).filter(({ nativue }) => nativue.ios)
|
|
84
|
+
const linkedNames = new Set(packages.map(({ name }) => name))
|
|
85
|
+
|
|
86
|
+
return packages.map(({ name, directory, nativue, requires }) => ({
|
|
87
|
+
module: moduleName(name),
|
|
88
|
+
sources: join(directory, nativue.ios.sources),
|
|
89
|
+
plugin: nativue.ios.plugin,
|
|
90
|
+
dependencies: nativue.ios.dependencies ?? [],
|
|
91
|
+
// Linked packages it depends on (a map provider on @nativue/maps): their modules, to import.
|
|
92
|
+
modules: requires.filter((required) => linkedNames.has(required)).map(moduleName),
|
|
93
|
+
}))
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
/** native/<name>/ios: module App<Name> (not <Name>, which could hide a system module like Photos). */
|
|
@@ -140,11 +142,13 @@ function swiftPackages(plugins) {
|
|
|
140
142
|
|
|
141
143
|
function packageManifest(plugins, corePath) {
|
|
142
144
|
const nativue = '.product(name: "Nativue", package: "core")'
|
|
143
|
-
const pluginTargets = plugins.map(({ module, dependencies }) => {
|
|
145
|
+
const pluginTargets = plugins.map(({ module, dependencies, modules = [] }) => {
|
|
144
146
|
const products = dependencies.flatMap(({ url, products }) =>
|
|
145
147
|
products.map((product) => `.product(name: "${product}", package: "${packageIdentity(url)}")`),
|
|
146
148
|
)
|
|
147
|
-
const targetDependencies = [nativue, ...products].join(
|
|
149
|
+
const targetDependencies = [nativue, ...modules.map((name) => `"${name}"`), ...products].join(
|
|
150
|
+
', ',
|
|
151
|
+
)
|
|
148
152
|
|
|
149
153
|
return ` .target(name: "${module}", dependencies: [${targetDependencies}], path: "Sources/${module}"),\n`
|
|
150
154
|
})
|
package/cli/nativue.mjs
CHANGED
|
@@ -36,6 +36,19 @@ const BUNDLE_PATH = `${BUNDLE_DIRECTORY}/main.bundle.js`
|
|
|
36
36
|
const ANDROID_ASSETS_DIRECTORY = 'android/app/src/main/assets'
|
|
37
37
|
const KEEPALIVE_INTERVAL_MS = 15000
|
|
38
38
|
const UNANSWERED_UPDATE_TIMEOUT_MS = 10000
|
|
39
|
+
// What a release build leaves out: logs slow the JavaScript thread and land in the device's log, which
|
|
40
|
+
// Android keeps readable. warn, error and assert stay, for problems in the field.
|
|
41
|
+
const DEVELOPMENT_CONSOLE_METHODS = [
|
|
42
|
+
'log',
|
|
43
|
+
'info',
|
|
44
|
+
'debug',
|
|
45
|
+
'trace',
|
|
46
|
+
'table',
|
|
47
|
+
'dir',
|
|
48
|
+
'group',
|
|
49
|
+
'groupCollapsed',
|
|
50
|
+
'groupEnd',
|
|
51
|
+
]
|
|
39
52
|
|
|
40
53
|
const NATIVE_COMPONENT_TAGS = [
|
|
41
54
|
'View',
|
|
@@ -165,6 +178,19 @@ const APP_VITE_PLUGINS = [
|
|
|
165
178
|
...appPlugins.flatMap((plugin) => plugin.vite ?? []),
|
|
166
179
|
]
|
|
167
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Each method an empty function the minifier then drops with its call, even where the call's value is
|
|
183
|
+
* used (`onPress: () => console.log(item)`). Arguments that do something still run.
|
|
184
|
+
*/
|
|
185
|
+
function withoutDevelopmentLogs() {
|
|
186
|
+
return Object.fromEntries(
|
|
187
|
+
DEVELOPMENT_CONSOLE_METHODS.flatMap((method) => [
|
|
188
|
+
[`console.${method}`, '(() => {})'],
|
|
189
|
+
[`globalThis.console.${method}`, '(() => {})'],
|
|
190
|
+
]),
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
168
194
|
function viteConfig({ mode, plugins = [] }) {
|
|
169
195
|
// Vite reads the mode from NODE_ENV: development builds keep each component's file (for errors).
|
|
170
196
|
process.env.NODE_ENV = mode
|
|
@@ -199,7 +225,10 @@ function viteConfig({ mode, plugins = [] }) {
|
|
|
199
225
|
{ find: /^@\//, replacement: `${process.cwd()}/src/` },
|
|
200
226
|
],
|
|
201
227
|
},
|
|
202
|
-
define: {
|
|
228
|
+
define: {
|
|
229
|
+
'process.env.NODE_ENV': JSON.stringify(mode),
|
|
230
|
+
...(mode === 'production' ? withoutDevelopmentLogs() : {}),
|
|
231
|
+
},
|
|
203
232
|
build: {
|
|
204
233
|
lib: {
|
|
205
234
|
entry: frameworkPath('src/entry.ts'),
|
|
@@ -262,6 +291,8 @@ async function dev() {
|
|
|
262
291
|
build: {
|
|
263
292
|
...config.build,
|
|
264
293
|
lib: false,
|
|
294
|
+
// As the lib build does: an imported image is a data: URL, which the app loads with no server.
|
|
295
|
+
assetsInlineLimit: () => true,
|
|
265
296
|
rolldownOptions: {
|
|
266
297
|
input: frameworkPath('src/entry.ts'),
|
|
267
298
|
experimental: { devMode: { lazy: false } },
|