@nativue/core 0.14.0 → 0.15.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 CHANGED
@@ -95,8 +95,16 @@ Import the runtime from `vue`: `ref`, `computed`, `StyleSheet`, `Animated`, `Lay
95
95
  - `@/` points at `src/`. Shared components go in `src/components`, everything else in `src/lib`.
96
96
  - Vue plugins (Pinia...) are installed in `src/app.ts`: `export default function setup(app: App)`.
97
97
  - Official packages: `@nativue/icons` (icon components), `@nativue/tailwind`, `@nativue/haptics`,
98
- `@nativue/clipboard` (copy text), `@nativue/sqlite`. A package with native code needs the app
98
+ `@nativue/clipboard` (copy text), `@nativue/notifications` (local notifications), `@nativue/sqlite`.
99
+ A package with native code needs the app
99
100
  rebuilt with `npm run ios` or `npm run android`, not just a reload.
101
+ - Notifications: `Notifications.schedule({ title, body, data }, { seconds } | { date } | { hour, minute } | null)`
102
+ after `usePermission(Notifications.getPermission, Notifications.requestPermission)` says granted.
103
+ Handle taps with `Notifications.onResponse` and, on start, `Notifications.getLastResponse()` (the tap
104
+ that opened the app); each tap reaches only one of them.
105
+ A custom sound is a `.wav` listed in `notifications({ sounds: [...] })`, played with
106
+ `schedule({ sound: 'chime.wav' })`; on Android 8+ it's the channel's: `setChannel({ id: 'orders', name, sound })`, then
107
+ `schedule({ ..., sound: 'chime.wav', channelId: 'orders' })`.
100
108
  - Copying: `const { copied, systemConfirmed } = await Clipboard.copy(text)`; show a "copied" toast
101
109
  only when `copied && !systemConfirmed` (Android 13+ shows its own).
102
110
  - Commands: `npm run ios` / `npm run android` build and open the app, then update it on save
@@ -16,6 +16,17 @@ const SECRET_NAME = /^[A-Za-z_][A-Za-z0-9_.]*$/
16
16
  const GRADLE_PROPERTY = /^[A-Za-z_][A-Za-z0-9_.-]*$/
17
17
  // aapt2's rule for the files of res/: lowercase letters, digits and underscores.
18
18
  const ANDROID_RESOURCE_NAME = /^[a-z][a-z0-9_]*$/
19
+ // aapt2 turns resource names into Java fields (R.raw.chime): it refuses Java's keywords.
20
+ const JAVA_KEYWORDS = new Set(
21
+ `abstract assert boolean break byte case catch char class const continue default do double else enum
22
+ extends false final finally float for goto if implements import instanceof int interface long native
23
+ new null package private protected public return short static strictfp super switch synchronized this
24
+ throw throws transient true try void volatile while`.split(/\s+/),
25
+ )
26
+
27
+ function isAndroidResourceName(name) {
28
+ return ANDROID_RESOURCE_NAME.test(name) && !JAVA_KEYWORDS.has(name)
29
+ }
19
30
  const ANDROID_RESOURCE_TYPES = ['raw', 'font', 'drawable', 'xml', 'assets']
20
31
  const APP_GROUP = /^group\.[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/
21
32
  const EXTENSION_NAME = /^[A-Za-z][A-Za-z0-9_]*$/
@@ -363,8 +374,8 @@ function resourceProblems(resource, field, appDirectory) {
363
374
  !android ||
364
375
  (android.type === 'assets'
365
376
  ? android.name.split('/').every((part) => part !== '' && part !== '.' && part !== '..')
366
- : ANDROID_RESOURCE_NAME.test(android.name)),
367
- `${field}.android.name: lowercase letters, digits and underscores, e.g. '${basename(
377
+ : isAndroidResourceName(android.name)),
378
+ `${field}.android.name: lowercase letters, digits and underscores, not a Java keyword, e.g. '${basename(
368
379
  source,
369
380
  extname(source),
370
381
  )
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativue/core",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Vue rendering real native views on iOS and Android",
5
5
  "keywords": [
6
6
  "vue",