@nativue/core 0.9.0 → 0.10.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.
Files changed (3) hide show
  1. package/AGENTS.md +94 -0
  2. package/package.json +3 -2
  3. package/src/xhr.ts +2 -1
package/AGENTS.md ADDED
@@ -0,0 +1,94 @@
1
+ # nativue: guide for coding agents
2
+
3
+ This app is built with nativue: Vue 3 single-file components rendered as real native views on iOS and
4
+ Android. It is not a web app. There is no DOM, no browser and no CSS, so web habits produce code that
5
+ doesn't work. Full docs: https://github.com/nativue/nativue/tree/main/docs
6
+
7
+ ## What doesn't exist
8
+
9
+ - HTML elements (`<div>`, `<span>`, `<p>`, `<img>`, `<button>`, `<input>`, `<ul>`...): use the
10
+ components below.
11
+ - CSS: `<style>` blocks, class names from a stylesheet, `px`/`rem`/`em` units, `:hover`, media queries.
12
+ A `.vue` file's `<style>` block is left out of the build.
13
+ - Browser globals: `window`, `document`, `localStorage`, `sessionStorage`, `navigator`, `alert`.
14
+ Use `AsyncStorage` for storage.
15
+ - Vue Router and `main.ts`: routing is file-based (below), and nativue creates the app.
16
+
17
+ ## Components
18
+
19
+ Global, with no import: `View`, `Text`, `Image`, `ImageBackground`, `Pressable`, `Button`, `TextInput`,
20
+ `Switch`, `ScrollView`, `FlatList`, `Swipeable`, `Modal`, `ActivityIndicator`, `SafeAreaView`,
21
+ `KeyboardAvoidingView`, `Svg`.
22
+
23
+ - Text must be inside a `<Text>`, never directly in a `<View>`.
24
+ - Taps: `<Pressable @press="save">` (also `@long-press`, and `v-slot="{ pressed }"`), or
25
+ `<Button title="Save" @press="save" />`. There is no `@click`.
26
+ - Inputs: `<TextInput v-model="name" placeholder="Name" @submit-editing="save" />`.
27
+ - Images: `import logo from '@/assets/logo.png'` then `<Image :source="logo" />`; remote ones as
28
+ `:source="{ uri: url }"`. A remote image has no size until it loads: give it a width and height
29
+ where the layout shouldn't jump, like a list's rows.
30
+ - Long lists: `<FlatList :data="items" :key-extractor="(item) => item.id">` with a
31
+ `<template #item="{ item }">` slot, not `v-for` in a `ScrollView`.
32
+
33
+ ## Styling
34
+
35
+ - `style` takes an object with CSS properties in camelCase and numbers in points, no units:
36
+ `:style="{ padding: 16, borderRadius: 12, backgroundColor: '#ffffff' }"`. Arrays merge, later wins:
37
+ `:style="[styles.card, selected && styles.selected]"`.
38
+ - `StyleSheet.create({...})` (from `vue`) groups and types a screen's styles.
39
+ - Every view is a flexbox container stacking its children in a **column** by default; `flex: 1` takes
40
+ the space left. Percentages (`'50%'`) work for sizes.
41
+ - Text styles (`color`, `fontSize`, `fontWeight`, `textAlign`, `textDecorationLine`) go on the
42
+ `<Text>` itself: native views don't inherit them from their parents.
43
+ - Pressed and focused states: `pressed-style` on `Pressable`, `focused-style` on `TextInput`.
44
+ - Dark mode: `useColorScheme()` (from `vue`) gives `'light'` or `'dark'`, live.
45
+ - Platform: `Platform.OS` is `'ios'` or `'android'`; `Platform.select({ ios, android })`.
46
+ - If the app uses `@nativue/tailwind` (see `nativue.config.ts`), Tailwind classes work in `class`,
47
+ with the `active:`, `focus:`, `disabled:`, `dark:`, `ios:` and `android:` variants.
48
+
49
+ ## Navigation
50
+
51
+ Every `.vue` file in `src/app` is a screen, and its path is its URL:
52
+
53
+ | File | URL |
54
+ | --------------------- | ------------------------------------------------------ |
55
+ | `app/index.vue` | `/` |
56
+ | `app/items/[id].vue` | `/items/42`, param `id` |
57
+ | `app/(tabs)/home.vue` | `/home`: a folder in parentheses groups without a path |
58
+ | `app/_layout.vue` | the layout of its folder: a `<Stack>` or a `<Tabs>` |
59
+ | `app/+not-found.vue` | shown when no route matches |
60
+
61
+ Import navigation from `@nativue/core/router`:
62
+
63
+ - `<Link href="/items/42">` (a Pressable); `router.push(path)`, `router.navigate(path)`,
64
+ `router.replace(path)`, `router.back()`.
65
+ - `useLocalSearchParams<{ id: string }>()` reads params and the query string.
66
+ - `<Stack.Screen :options="{ title: 'Item' }" />` inside a screen sets its header; in a layout,
67
+ `<Stack.Screen name="modal" :options="{ presentation: 'modal' }" />` sets a route's options.
68
+
69
+ ## APIs
70
+
71
+ Import the runtime from `vue`: `ref`, `computed`, `StyleSheet`, `Animated`, `LayoutAnimation`,
72
+ `Platform`, `AsyncStorage`, `Keyboard`, `Dimensions`, `useWindowDimensions`, `useColorScheme`,
73
+ `AccessibilityInfo`, `requireNativeFunction`.
74
+
75
+ - `AsyncStorage`: `getItem`, `setItem`, `removeItem`, `getAllKeys`, `multiGet`, `multiSet`,
76
+ `clear`; promise-based, string values. Store objects as JSON. For large data or queries, use
77
+ `@nativue/sqlite`.
78
+ - `fetch`, `XMLHttpRequest`, `Blob`, `FileReader`, `URL`, `URLSearchParams`, timers and `console`
79
+ work as on the web, with no import.
80
+ - Accessibility: `role` and `aria-*` attributes (`aria-label`, `aria-hidden`...) on any component.
81
+
82
+ ## Project
83
+
84
+ - `@/` points at `src/`. Shared components go in `src/components`, everything else in `src/lib`.
85
+ - Vue plugins (Pinia...) are installed in `src/app.ts`: `export default function setup(app: App)`.
86
+ - Official packages: `@nativue/icons` (icon components), `@nativue/tailwind`, `@nativue/haptics`,
87
+ `@nativue/sqlite`. A package with native code needs the app rebuilt with `npm run ios` or
88
+ `npm run android`, not just a reload.
89
+ - Commands: `npm run ios` / `npm run android` build and open the app, then reload on save;
90
+ `npm run typecheck` checks scripts and templates; `npm run build` makes the release bundle;
91
+ `npm run format` formats with Prettier.
92
+ - Check changes with `npm run typecheck`. `ios/` and `android/` are the native host apps: change them
93
+ only for native settings (permissions in `Info.plist` or `AndroidManifest.xml`, the app's name and
94
+ icon).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativue/core",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Vue rendering real native views on iOS and Android",
5
5
  "keywords": [
6
6
  "vue",
@@ -56,7 +56,8 @@
56
56
  "android/build.gradle.kts",
57
57
  "android/consumer-rules.pro",
58
58
  "android/nativue.settings.gradle.kts",
59
- "android/src"
59
+ "android/src",
60
+ "AGENTS.md"
60
61
  ],
61
62
  "publishConfig": {
62
63
  "access": "public"
package/src/xhr.ts CHANGED
@@ -381,7 +381,8 @@ export class XMLHttpRequest extends EventTarget {
381
381
 
382
382
  private parseResponse(): unknown {
383
383
  if (this.chosenResponseType === 'blob') return this.blobResponse
384
- if (this.chosenResponseType === 'arraybuffer') return (this.bytesResponse ?? new Uint8Array()).buffer
384
+ if (this.chosenResponseType === 'arraybuffer')
385
+ return (this.bytesResponse ?? new Uint8Array()).buffer
385
386
 
386
387
  try {
387
388
  return JSON.parse(this.rawResponse)