@pyreon/vue-compat 0.1.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/LICENSE +21 -0
- package/README.md +86 -0
- package/lib/analysis/index.js.html +5406 -0
- package/lib/index.js +309 -0
- package/lib/index.js.map +1 -0
- package/lib/types/index.d.ts +309 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index2.d.ts +189 -0
- package/lib/types/index2.d.ts.map +1 -0
- package/package.json +49 -0
- package/src/index.ts +481 -0
- package/src/tests/setup.ts +3 -0
- package/src/tests/vue-compat.test.ts +698 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Vit Bokisch
|
|
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
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @pyreon/vue-compat
|
|
2
|
+
|
|
3
|
+
Vue 3 Composition API shim that runs on Pyreon's signal-based reactive engine. Migrate Vue code by swapping the import path.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @pyreon/vue-compat
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// Replace:
|
|
15
|
+
// import { ref, computed, watch } from "vue"
|
|
16
|
+
// With:
|
|
17
|
+
import { ref, computed, watch } from "@pyreon/vue-compat"
|
|
18
|
+
|
|
19
|
+
function useCounter() {
|
|
20
|
+
const count = ref(0)
|
|
21
|
+
const doubled = computed(() => count.value * 2)
|
|
22
|
+
watch(count, (newVal, oldVal) => {
|
|
23
|
+
console.log(`count: ${oldVal} -> ${newVal}`)
|
|
24
|
+
})
|
|
25
|
+
return { count, doubled }
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Key Differences from Vue
|
|
30
|
+
|
|
31
|
+
- **No virtual DOM.** Pyreon uses fine-grained reactivity -- no diffing, no re-renders.
|
|
32
|
+
- **Components run once** (setup phase only).
|
|
33
|
+
- **`reactive()` uses Pyreon's store proxy** with deep signal wrapping.
|
|
34
|
+
- **`readonly()` is strict** -- setting any property (including symbols) throws an error.
|
|
35
|
+
- **`provide` / `inject` uses Pyreon's context system** -- fully isolated per component tree.
|
|
36
|
+
|
|
37
|
+
## API
|
|
38
|
+
|
|
39
|
+
### Reactivity: Refs
|
|
40
|
+
|
|
41
|
+
- **`ref(value)`** -- returns `{ value }` with reactive `.value`.
|
|
42
|
+
- **`shallowRef(value)`** -- shallow reactive ref (no deep tracking).
|
|
43
|
+
- **`triggerRef(ref)`** -- force subscribers to re-run.
|
|
44
|
+
- **`isRef(val)`** -- type guard.
|
|
45
|
+
- **`unref(val)`** -- unwrap a ref or return value as-is.
|
|
46
|
+
- **`toRef(obj, key)`** -- create a ref bound to an object property.
|
|
47
|
+
- **`toRefs(obj)`** -- convert all properties to refs.
|
|
48
|
+
|
|
49
|
+
### Reactivity: Computed
|
|
50
|
+
|
|
51
|
+
- **`computed(fn)`** -- read-only computed ref.
|
|
52
|
+
- **`computed({ get, set })`** -- writable computed ref.
|
|
53
|
+
|
|
54
|
+
### Reactivity: Objects
|
|
55
|
+
|
|
56
|
+
- **`reactive(obj)`** -- deep reactive proxy (Pyreon store).
|
|
57
|
+
- **`shallowReactive(obj)`** -- shallow reactive proxy.
|
|
58
|
+
- **`readonly(obj)`** -- read-only proxy that throws on writes.
|
|
59
|
+
- **`toRaw(proxy)`** -- unwrap to the original object.
|
|
60
|
+
|
|
61
|
+
### Watchers
|
|
62
|
+
|
|
63
|
+
- **`watch(source, callback, options?)`** -- watch a ref, getter, or reactive object. Supports `immediate` and `deep`.
|
|
64
|
+
- **`watchEffect(fn)`** -- auto-tracking effect, returns stop handle.
|
|
65
|
+
|
|
66
|
+
### Lifecycle Hooks
|
|
67
|
+
|
|
68
|
+
- **`onMounted(fn)`** / **`onBeforeMount(fn)`**
|
|
69
|
+
- **`onUnmounted(fn)`** / **`onBeforeUnmount(fn)`**
|
|
70
|
+
- **`onUpdated(fn)`**
|
|
71
|
+
|
|
72
|
+
### Dependency Injection
|
|
73
|
+
|
|
74
|
+
- **`provide(key, value)`** -- provide a value to descendants.
|
|
75
|
+
- **`inject(key, defaultValue?)`** -- inject a value from an ancestor.
|
|
76
|
+
|
|
77
|
+
### Application
|
|
78
|
+
|
|
79
|
+
- **`createApp(component, props?)`** -- create an app instance with `.mount(el)` and `.unmount()`.
|
|
80
|
+
- **`defineComponent(setup)`** -- wrapper for type inference (returns setup as-is).
|
|
81
|
+
- **`nextTick()`** -- wait for the next microtask.
|
|
82
|
+
|
|
83
|
+
### Utilities
|
|
84
|
+
|
|
85
|
+
- **`h` / `Fragment`** -- JSX runtime.
|
|
86
|
+
- **`batch(fn)`** -- coalesce multiple signal writes.
|