@pyreon/vue-compat 0.2.1 → 0.3.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/lib/analysis/index.js.html +1 -1
- package/lib/index.js +261 -65
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +265 -64
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index2.d.ts +22 -49
- package/lib/types/index2.d.ts.map +1 -1
- package/package.json +14 -4
- package/src/index.ts +307 -81
- package/src/jsx-runtime.ts +178 -0
- package/src/tests/vue-compat.test.ts +348 -119
package/lib/types/index2.d.ts
CHANGED
|
@@ -11,14 +11,12 @@ interface Ref<T = unknown> {
|
|
|
11
11
|
* Creates a reactive ref wrapping the given value.
|
|
12
12
|
* Access via `.value` — reads track, writes trigger.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* Inside a component: hook-indexed. The setter also calls `scheduleRerender()`.
|
|
15
|
+
* Outside a component: creates a standalone reactive ref.
|
|
16
16
|
*/
|
|
17
17
|
declare function ref<T>(value: T): Ref<T>;
|
|
18
18
|
/**
|
|
19
19
|
* Creates a shallow ref — same as `ref()` in Pyreon since signals are inherently shallow.
|
|
20
|
-
*
|
|
21
|
-
* Difference from Vue: identical to `ref()` — Pyreon signals don't perform deep conversion.
|
|
22
20
|
*/
|
|
23
21
|
declare function shallowRef<T>(value: T): Ref<T>;
|
|
24
22
|
/**
|
|
@@ -40,11 +38,9 @@ interface WritableComputedRef<T = unknown> extends Ref<T> {
|
|
|
40
38
|
value: T;
|
|
41
39
|
}
|
|
42
40
|
/**
|
|
43
|
-
* Creates a computed ref. Supports both readonly and writable forms
|
|
44
|
-
* - `computed(() => value)` — readonly ComputedRef
|
|
45
|
-
* - `computed({ get, set })` — writable WritableComputedRef
|
|
41
|
+
* Creates a computed ref. Supports both readonly and writable forms.
|
|
46
42
|
*
|
|
47
|
-
*
|
|
43
|
+
* Inside a component: hook-indexed.
|
|
48
44
|
*/
|
|
49
45
|
declare function computed<T>(getter: () => T): ComputedRef<T>;
|
|
50
46
|
declare function computed<T>(options: {
|
|
@@ -55,39 +51,36 @@ declare function computed<T>(options: {
|
|
|
55
51
|
* Creates a deeply reactive proxy from a plain object.
|
|
56
52
|
* Backed by Pyreon's `createStore()`.
|
|
57
53
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
54
|
+
* Inside a component: hook-indexed. Proxy wrapper intercepts sets to
|
|
55
|
+
* call `scheduleRerender()`.
|
|
60
56
|
*/
|
|
61
57
|
declare function reactive<T extends object>(obj: T): T;
|
|
62
58
|
/**
|
|
63
|
-
* Creates a shallow reactive proxy.
|
|
64
|
-
* In Pyreon, `createStore` is already per-property (not deeply recursive for primitives),
|
|
65
|
-
* but nested objects will be wrapped. For truly shallow behavior, use individual refs.
|
|
66
|
-
*
|
|
67
|
-
* Difference from Vue: backed by `createStore()` — same as `reactive()` in practice.
|
|
59
|
+
* Creates a shallow reactive proxy — same as `reactive()` in Pyreon.
|
|
68
60
|
*/
|
|
69
61
|
declare function shallowReactive<T extends object>(obj: T): T;
|
|
70
62
|
/**
|
|
71
63
|
* Returns a readonly proxy that throws on mutation attempts.
|
|
72
64
|
*
|
|
73
|
-
*
|
|
74
|
-
* rather than Vue's full readonly reactive system.
|
|
65
|
+
* Inside a component: hook-indexed.
|
|
75
66
|
*/
|
|
76
67
|
declare function readonly<T extends object>(obj: T): Readonly<T>;
|
|
77
68
|
/**
|
|
78
69
|
* Returns the raw (unwrapped) object behind a reactive or readonly proxy.
|
|
79
|
-
*
|
|
80
|
-
* Difference from Vue: only works for objects created via `reactive()` or `readonly()`.
|
|
81
70
|
*/
|
|
82
71
|
declare function toRaw<T extends object>(proxy: T): T;
|
|
83
72
|
/**
|
|
84
73
|
* Creates a ref linked to a property of a reactive object.
|
|
85
74
|
* Reading/writing the ref's `.value` reads/writes the original property.
|
|
75
|
+
*
|
|
76
|
+
* Inside a component: hook-indexed.
|
|
86
77
|
*/
|
|
87
78
|
declare function toRef<T extends object, K extends keyof T>(obj: T, key: K): Ref<T[K]>;
|
|
88
79
|
/**
|
|
89
80
|
* Converts all properties of a reactive object into individual refs.
|
|
90
81
|
* Each ref is linked to the original property (not a copy).
|
|
82
|
+
*
|
|
83
|
+
* Inside a component: hook-indexed (the entire result, not individual refs).
|
|
91
84
|
*/
|
|
92
85
|
declare function toRefs<T extends object>(obj: T): { [K in keyof T]: Ref<T[K]> };
|
|
93
86
|
interface WatchOptions {
|
|
@@ -99,68 +92,54 @@ interface WatchOptions {
|
|
|
99
92
|
type WatchSource<T> = Ref<T> | (() => T);
|
|
100
93
|
/**
|
|
101
94
|
* Watches a reactive source and calls `cb` when it changes.
|
|
102
|
-
* Tracks old and new values.
|
|
103
95
|
*
|
|
104
|
-
*
|
|
105
|
-
* Returns a stop function to dispose the watcher.
|
|
96
|
+
* Inside a component: hook-indexed, created once. Disposed on unmount.
|
|
106
97
|
*/
|
|
107
98
|
declare function watch<T>(source: WatchSource<T>, cb: (newValue: T, oldValue: T | undefined) => void, options?: WatchOptions): () => void;
|
|
108
99
|
/**
|
|
109
100
|
* Runs the given function reactively — re-executes whenever its tracked
|
|
110
101
|
* dependencies change.
|
|
111
102
|
*
|
|
112
|
-
*
|
|
113
|
-
* Returns a stop function.
|
|
103
|
+
* Inside a component: hook-indexed, created once. Disposed on unmount.
|
|
114
104
|
*/
|
|
115
105
|
declare function watchEffect(fn: () => void): () => void;
|
|
116
106
|
/**
|
|
117
107
|
* Registers a callback to run after the component is mounted.
|
|
118
|
-
*
|
|
119
|
-
* Difference from Vue: maps directly to Pyreon's `onMount()`.
|
|
120
|
-
* In Pyreon there is no distinction between beforeMount and mounted.
|
|
108
|
+
* Hook-indexed: only registered on first render.
|
|
121
109
|
*/
|
|
122
110
|
declare function onMounted(fn: () => void): void;
|
|
123
111
|
/**
|
|
124
|
-
* Registers a callback to run
|
|
125
|
-
*
|
|
126
|
-
* Difference from Vue: maps to Pyreon's `onUnmount()`.
|
|
127
|
-
* In Pyreon there is no distinction between beforeUnmount and unmounted.
|
|
112
|
+
* Registers a callback to run when the component is unmounted.
|
|
113
|
+
* Hook-indexed: only registered on first render.
|
|
128
114
|
*/
|
|
129
115
|
declare function onUnmounted(fn: () => void): void;
|
|
130
116
|
/**
|
|
131
|
-
* Registers a callback to run after a reactive update.
|
|
132
|
-
*
|
|
133
|
-
* Difference from Vue: maps to Pyreon's `onUpdate()`.
|
|
117
|
+
* Registers a callback to run after a reactive update (not on initial mount).
|
|
118
|
+
* Hook-indexed: registered once, fires on each re-render.
|
|
134
119
|
*/
|
|
135
120
|
declare function onUpdated(fn: () => void): void;
|
|
136
121
|
/**
|
|
137
122
|
* Registers a callback to run before mount.
|
|
138
|
-
* In Pyreon there is no pre-mount phase — maps to `
|
|
123
|
+
* In Pyreon there is no pre-mount phase — maps to `onMounted()`.
|
|
139
124
|
*/
|
|
140
125
|
declare function onBeforeMount(fn: () => void): void;
|
|
141
126
|
/**
|
|
142
127
|
* Registers a callback to run before unmount.
|
|
143
|
-
* In Pyreon there is no pre-unmount phase — maps to `
|
|
128
|
+
* In Pyreon there is no pre-unmount phase — maps to `onUnmounted()`.
|
|
144
129
|
*/
|
|
145
130
|
declare function onBeforeUnmount(fn: () => void): void;
|
|
146
131
|
/**
|
|
147
132
|
* Returns a Promise that resolves after all pending reactive updates have flushed.
|
|
148
|
-
*
|
|
149
|
-
* Difference from Vue: identical to Pyreon's `nextTick()`.
|
|
150
133
|
*/
|
|
151
134
|
declare function nextTick(): Promise<void>;
|
|
152
135
|
/**
|
|
153
136
|
* Provides a value to all descendant components.
|
|
154
137
|
*
|
|
155
|
-
*
|
|
156
|
-
* Must be called during component setup. The value is scoped to the component
|
|
157
|
-
* tree — not globally shared.
|
|
138
|
+
* Inside a component: hook-indexed, pushed once. Popped on unmount.
|
|
158
139
|
*/
|
|
159
140
|
declare function provide<T>(key: string | symbol, value: T): void;
|
|
160
141
|
/**
|
|
161
142
|
* Injects a value provided by an ancestor component.
|
|
162
|
-
*
|
|
163
|
-
* Difference from Vue: backed by Pyreon's context system (useContext).
|
|
164
143
|
*/
|
|
165
144
|
declare function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
|
|
166
145
|
interface ComponentOptions<P extends Props = Props> {
|
|
@@ -172,9 +151,6 @@ interface ComponentOptions<P extends Props = Props> {
|
|
|
172
151
|
/**
|
|
173
152
|
* Defines a component using Vue 3 Composition API style.
|
|
174
153
|
* Only supports the `setup()` function — Options API is not supported.
|
|
175
|
-
*
|
|
176
|
-
* Difference from Vue: returns a Pyreon `ComponentFn`. No template/render option —
|
|
177
|
-
* the setup function should return a render function or VNode directly.
|
|
178
154
|
*/
|
|
179
155
|
declare function defineComponent<P extends Props = Props>(options: ComponentOptions<P> | ((props: P) => VNodeChild)): ComponentFn<P>;
|
|
180
156
|
interface App {
|
|
@@ -183,9 +159,6 @@ interface App {
|
|
|
183
159
|
}
|
|
184
160
|
/**
|
|
185
161
|
* Creates a Pyreon application instance — Vue 3 `createApp()` compatible.
|
|
186
|
-
*
|
|
187
|
-
* Difference from Vue: does not support plugins, directives, or global config.
|
|
188
|
-
* The component receives `props` if provided.
|
|
189
162
|
*/
|
|
190
163
|
declare function createApp(component: ComponentFn, props?: Props): App;
|
|
191
164
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;cAgDM,QAAA;AAAA,UAMW,GAAA;EACf,KAAA,EAAO,CAAA;EAAA,UACG,QAAA;AAAA;;;;;;AAsDZ;;iBA5CgB,GAAA,GAAA,CAAO,KAAA,EAAO,CAAA,GAAI,GAAA,CAAI,CAAA;;;;iBA4CtB,UAAA,GAAA,CAAc,KAAA,EAAO,CAAA,GAAI,GAAA,CAAI,CAAA;;;;iBAO7B,UAAA,GAAA,CAAc,CAAA,EAAG,GAAA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AAA,EAAQ,WAAA,CAAY,CAAA,GACpB,EAAA,GAAK,QAAA,EAAU,CAAA,EAAG,QAAA,EAAU,CAAA,uBAC5B,OAAA,GAAU,YAAA;;;;;;;iBA+EI,WAAA,CAAY,EAAA;;;;AA1T5B;iBAmWgB,SAAA,CAAU,EAAA;;;;;iBA4BV,WAAA,CAAY,EAAA;;;;;iBAgBZ,SAAA,CAAU,EAAA;;;;;iBA2BV,aAAA,CAAc,EAAA;;;;AA1W9B;iBAkXgB,eAAA,CAAgB,EAAA;;;;iBAShB,QAAA,CAAA,GAAY,OAAA;;;;;AAxV5B;iBA6WgB,OAAA,GAAA,CAAW,GAAA,mBAAsB,KAAA,EAAO,CAAA;;;;iBAmBxC,MAAA,GAAA,CAAU,GAAA,mBAAsB,YAAA,GAAe,CAAA,GAAI,CAAA;AAAA,UAQzD,gBAAA,WAA2B,KAAA,GAAQ,KAAA;EAxYc;EA0YzD,KAAA,GAAQ,KAAA,EAAO,CAAA,YAAa,UAAA,IAAc,UAAA;EA1YgB;EA4Y1D,IAAA;AAAA;;;;;iBAOc,eAAA,WAA0B,KAAA,GAAQ,KAAA,CAAA,CAChD,OAAA,EAAS,gBAAA,CAAiB,CAAA,MAAO,KAAA,EAAO,CAAA,KAAM,UAAA,IAC7C,WAAA,CAAY,CAAA;AAAA,UA0BL,GAAA;EAtamD;EAwa3D,KAAA,CAAM,EAAA,WAAa,OAAA;AAAA;AApYrB;;;AAAA,iBA0YgB,SAAA,CAAU,SAAA,EAAW,WAAA,EAAa,KAAA,GAAQ,KAAA,GAAQ,GAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/vue-compat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Vue 3-compatible Composition API shim for Pyreon — write Vue-style code that runs on Pyreon's reactive engine",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,6 +28,16 @@
|
|
|
28
28
|
"bun": "./src/index.ts",
|
|
29
29
|
"import": "./lib/index.js",
|
|
30
30
|
"types": "./lib/types/index.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./jsx-runtime": {
|
|
33
|
+
"bun": "./src/jsx-runtime.ts",
|
|
34
|
+
"import": "./lib/jsx-runtime.js",
|
|
35
|
+
"types": "./lib/types/jsx-runtime.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./jsx-dev-runtime": {
|
|
38
|
+
"bun": "./src/jsx-runtime.ts",
|
|
39
|
+
"import": "./lib/jsx-runtime.js",
|
|
40
|
+
"types": "./lib/types/jsx-runtime.d.ts"
|
|
31
41
|
}
|
|
32
42
|
},
|
|
33
43
|
"scripts": {
|
|
@@ -39,9 +49,9 @@
|
|
|
39
49
|
"prepublishOnly": "bun run build"
|
|
40
50
|
},
|
|
41
51
|
"dependencies": {
|
|
42
|
-
"@pyreon/core": "^0.
|
|
43
|
-
"@pyreon/reactivity": "^0.
|
|
44
|
-
"@pyreon/runtime-dom": "^0.
|
|
52
|
+
"@pyreon/core": "^0.3.0",
|
|
53
|
+
"@pyreon/reactivity": "^0.3.0",
|
|
54
|
+
"@pyreon/runtime-dom": "^0.3.0"
|
|
45
55
|
},
|
|
46
56
|
"devDependencies": {
|
|
47
57
|
"@happy-dom/global-registrator": "^20.8.3",
|