@bawantharajapaksha/purenative 0.0.0-stage → 0.2.0-rc.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PureNative contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,108 @@
1
- # Temporary Holding Version
1
+ # PureNative (working name)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Native UI. Pure TypeScript. Zero JSX.**
4
+
5
+ A typed, immutable fluent interface for React Native. React owns components, hooks and lifecycle; React Native owns layout and native interaction. Consumers write ordinary `.ts` files with no custom compiler or additional native bridge from core.
6
+
7
+ **Current version: 0.2.0-rc.2, a release candidate.** Source is public on [GitHub](https://github.com/bawantha/purenative). Published candidates use npm's `next` tag. Stable-release requirements, including physical-device and assistive-technology checks, remain in the repository release-readiness record. This repository does not claim that green browser tests alone establish native production readiness.
8
+
9
+ The npm package name is `@bawantharajapaksha/purenative`. npm rejected the unscoped name `purenative` as too similar to the existing `pure-native` package. “PureNative” remains a working project name; a registry scope does not establish trademark clearance. The workspace and core remain `private: true`; release tooling changes only a staged package manifest after the appropriate checks.
10
+
11
+ ```ts
12
+ import { useState } from 'react';
13
+ import { Column, Text, Button } from '@bawantharajapaksha/purenative';
14
+
15
+ export default function Counter() {
16
+ const [count, setCount] = useState(0);
17
+ return Column([
18
+ Text(`Count: ${count}`).fontSize(32).bold(),
19
+ Button('Increase', () => setCount(value => value + 1))
20
+ .padding(16).background('#176A4C').color('white').cornerRadius(12),
21
+ ]).fillMaxSize().padding(24).spacing(16).center().render();
22
+ }
23
+ ```
24
+
25
+ ## Install a published candidate
26
+
27
+ In an existing React Native 0.88 / React 19.3 application (or Expo SDK 58):
28
+
29
+ ```sh
30
+ npm install @bawantharajapaksha/purenative@next
31
+ ```
32
+
33
+ Use the explicit `next` tag for a candidate; these versions have outstanding stable-release checks. React and React Native are peer dependencies supplied by the application. Consult the repository's compatibility record before adopting a different combination.
34
+
35
+ ## Source and development
36
+
37
+ Clone [bawantha/purenative](https://github.com/bawantha/purenative) and run `npm ci`, `npm run check` and `npm run demo` from its root. The example includes persisted tasks, forms, lists, native navigation and theme switching.
38
+
39
+ ## API
40
+
41
+ | Factory | Native foundation | Main additions |
42
+ | --- | --- | --- |
43
+ | `Column(children?)`, `Row(children?)`, `Box(children?)` | View | spacing, alignment, centering; Box retains ordinary native View flow |
44
+ | `Text(value)` | Text | typography, plain string/number content |
45
+ | `Button(label, onPress)` | Pressable + Text | label typography, disabled state and native pressed-state styling |
46
+ | `Pressable(children, onPress)` | Pressable | custom content, disabled state and state styling |
47
+ | `TextField(value, onChangeText)` | TextInput | controlled value, placeholder, typography and typed native props/refs |
48
+ | `Image(source)` | Image | typed source, native image styles and load/error props |
49
+ | `Switch(value, onValueChange)` | Switch | controlled value and native props |
50
+ | `Loading(props?)` | ActivityIndicator | native size/color/accessibility props |
51
+ | `Scroll(children?)` | ScrollView | separate viewport/content styles and native scrolling props/refs |
52
+ | `List(data, renderItem, keyExtractor)` | FlatList | typed items, required stable keys, empty/header/footer content and native virtualization |
53
+ | `Modal(visible, onRequestClose, children)` | Modal | explicit back/dismiss handling and native presentation props |
54
+ | `Native(Component, props, children?)` | Existing React component | typed interoperability, refs, animated styles and React lifecycle |
55
+
56
+ Styled builders share padding/margin, logical start/end spacing, background, border, size constraints, flex, opacity, `.style()`, `.props()`, `.key()` and `.render()`. Plain styles remain native, component-specific types. Button `.color()` and `.textStyle()` target the label; its `.style()` targets the Pressable. `.stateStyle(({ pressed }) => ...)` merges a native state-specific style over the base style. Use existing native props for platform ripple, focus, hover and loading behavior.
57
+
58
+ ```ts
59
+ const title = Text('Reusable').fontSize(24);
60
+ const green = title.color('#176A4C'); // title stays unchanged
61
+
62
+ TextField(name, setName).placeholder('Your name').padding(12);
63
+ Scroll([Text('Content')]).contentStyle({ padding: 24, gap: 12 });
64
+ List(items, ({ item }) => Text(item.title), item => item.id)
65
+ .empty(Text('No items yet'));
66
+ ```
67
+
68
+ ## Themes and React interoperability
69
+
70
+ Create a theme once at module scope. `Provider` and `useTheme` use ordinary React context and hooks. Provider mode can be `light`, `dark` or `system`; the resolved tokens are copied snapshots. See the application for persistent preferences and responsive native layouts.
71
+
72
+ ```ts
73
+ import { createElement } from 'react';
74
+ import { createTheme, Native, Text } from '@bawantharajapaksha/purenative';
75
+
76
+ const Theme = createTheme({ light: { ink: '#18382E' }, dark: { ink: '#F0F5EE' } });
77
+ function Greeting({ name }: { name: string }) {
78
+ const { theme } = Theme.useTheme();
79
+ return Text(`Hello, ${name}`).color(theme.ink).render();
80
+ }
81
+ function App() {
82
+ return createElement(Theme.Provider, { mode: 'system' }, Native(Greeting, { name: 'Ada' }).render());
83
+ }
84
+ ```
85
+
86
+ A builder is a description. Return `.render()` at React component boundaries; nested builders are converted automatically. Existing React elements retain their identity. Mount custom components using `Native(Component, props)` or React `createElement`; React invokes them and owns their state/effects. For stateful list rows, return `Native(RowComponent, { item })` from `renderItem` instead of calling a component function or hooks inside that callback.
87
+
88
+ `.props()` preserves native events, accessibility and ref types. `Native` also accepts the target component's full style API, including animated values and render props. Required component props remain required; for components with a required `children` prop, pass a normal React node in that prop. Explicit third-argument children override a children prop, following React creation behavior.
89
+
90
+ Use stable `.key(id)` values for changing ordinary child arrays. `List` requires a key extractor. View containers accept arrays, nested arrays, conditions, builders and React elements; wrap raw text in `Text`. Key warnings are not guaranteed for the outer child array.
91
+
92
+ ## Modifier semantics
93
+
94
+ Modifiers merge properties into one native style object. Later writes to the **same property** win. Different native properties coexist, and React Native resolves shorthand/axis/edge precedence. Ordered Compose modifier semantics are outside the accepted architecture.
95
+
96
+ ```ts
97
+ Box().padding(8).padding(24); // final padding is 24
98
+ Box().background('red').padding(8); // same appearance as padding then background
99
+ Box().paddingHorizontal(8).padding(24); // retains both native properties
100
+ ```
101
+
102
+ Use explicit Box layers for distinct background/padding regions. `.fillMaxSize()` means `{ flex: 1, width: '100%' }` within available flex space. Box does not create automatic overlays. Scroll/List `.padding()` affects the viewport; `.contentStyle()` affects the content container. Nested style patches such as `transform` replace that full property.
103
+
104
+ Styles and child arrays are copied/frozen, and trusted immutable snapshots are shared across branches. Native props are shallow snapshots; callbacks, refs, item objects and opaque native values retain React's usual caller-ownership rules. Circular plain style objects are rejected. See the runtime semantics documentation in the repository.
105
+
106
+ ## License
107
+
108
+ [MIT](LICENSE) © 2026 PureNative contributors.