@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
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { ComponentFn, Fragment, Props, VNodeChild, h as pyreonH } from "@pyreon/core";
|
|
2
|
+
import { batch } from "@pyreon/reactivity";
|
|
3
|
+
|
|
4
|
+
//#region src/index.d.ts
|
|
5
|
+
declare const V_IS_REF: unique symbol;
|
|
6
|
+
interface Ref<T = unknown> {
|
|
7
|
+
value: T;
|
|
8
|
+
readonly [V_IS_REF]: true;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Creates a reactive ref wrapping the given value.
|
|
12
|
+
* Access via `.value` — reads track, writes trigger.
|
|
13
|
+
*
|
|
14
|
+
* Difference from Vue: backed by a Pyreon signal. No `__v_isShallow` distinction
|
|
15
|
+
* at runtime since Pyreon signals are always shallow (deep reactivity is via stores).
|
|
16
|
+
*/
|
|
17
|
+
declare function ref<T>(value: T): Ref<T>;
|
|
18
|
+
/**
|
|
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
|
+
*/
|
|
23
|
+
declare function shallowRef<T>(value: T): Ref<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Force trigger a ref's subscribers, even if the value hasn't changed.
|
|
26
|
+
*/
|
|
27
|
+
declare function triggerRef<T>(r: Ref<T>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Returns `true` if the value is a ref (created by `ref()` or `computed()`).
|
|
30
|
+
*/
|
|
31
|
+
declare function isRef(val: unknown): val is Ref;
|
|
32
|
+
/**
|
|
33
|
+
* Unwraps a ref: if it has `.value`, return `.value`; otherwise return as-is.
|
|
34
|
+
*/
|
|
35
|
+
declare function unref<T>(r: T | Ref<T>): T;
|
|
36
|
+
interface ComputedRef<T = unknown> extends Ref<T> {
|
|
37
|
+
readonly value: T;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Creates a computed ref. Supports both readonly and writable forms:
|
|
41
|
+
* - `computed(() => value)` — readonly
|
|
42
|
+
* - `computed({ get: () => value, set: (v) => ... })` — writable
|
|
43
|
+
*
|
|
44
|
+
* Backed by Pyreon's `computed()`, wrapped in a `.value` accessor.
|
|
45
|
+
*/
|
|
46
|
+
declare function computed<T>(fnOrOptions: (() => T) | {
|
|
47
|
+
get: () => T;
|
|
48
|
+
set: (value: T) => void;
|
|
49
|
+
}): ComputedRef<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a deeply reactive proxy from a plain object.
|
|
52
|
+
* Backed by Pyreon's `createStore()`.
|
|
53
|
+
*
|
|
54
|
+
* Difference from Vue: uses Pyreon's fine-grained per-property signals.
|
|
55
|
+
* Direct mutation triggers only affected signals.
|
|
56
|
+
*/
|
|
57
|
+
declare function reactive<T extends object>(obj: T): T;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a shallow reactive proxy.
|
|
60
|
+
* In Pyreon, `createStore` is already per-property (not deeply recursive for primitives),
|
|
61
|
+
* but nested objects will be wrapped. For truly shallow behavior, use individual refs.
|
|
62
|
+
*
|
|
63
|
+
* Difference from Vue: backed by `createStore()` — same as `reactive()` in practice.
|
|
64
|
+
*/
|
|
65
|
+
declare function shallowReactive<T extends object>(obj: T): T;
|
|
66
|
+
/**
|
|
67
|
+
* Returns a readonly proxy that throws on mutation attempts.
|
|
68
|
+
*
|
|
69
|
+
* Difference from Vue: uses a simple Proxy with a set trap that throws,
|
|
70
|
+
* rather than Vue's full readonly reactive system.
|
|
71
|
+
*/
|
|
72
|
+
declare function readonly<T extends object>(obj: T): Readonly<T>;
|
|
73
|
+
/**
|
|
74
|
+
* Returns the raw (unwrapped) object behind a reactive or readonly proxy.
|
|
75
|
+
*
|
|
76
|
+
* Difference from Vue: only works for objects created via `reactive()` or `readonly()`.
|
|
77
|
+
*/
|
|
78
|
+
declare function toRaw<T extends object>(proxy: T): T;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a ref linked to a property of a reactive object.
|
|
81
|
+
* Reading/writing the ref's `.value` reads/writes the original property.
|
|
82
|
+
*/
|
|
83
|
+
declare function toRef<T extends object, K extends keyof T>(obj: T, key: K): Ref<T[K]>;
|
|
84
|
+
/**
|
|
85
|
+
* Converts all properties of a reactive object into individual refs.
|
|
86
|
+
* Each ref is linked to the original property (not a copy).
|
|
87
|
+
*/
|
|
88
|
+
declare function toRefs<T extends object>(obj: T): { [K in keyof T]: Ref<T[K]> };
|
|
89
|
+
interface WatchOptions {
|
|
90
|
+
/** Call the callback immediately with current value. Default: false */
|
|
91
|
+
immediate?: boolean;
|
|
92
|
+
/** Ignored in Pyreon — dependencies are tracked automatically. */
|
|
93
|
+
deep?: boolean;
|
|
94
|
+
}
|
|
95
|
+
type WatchSource<T> = Ref<T> | (() => T);
|
|
96
|
+
/**
|
|
97
|
+
* Watches a reactive source and calls `cb` when it changes.
|
|
98
|
+
* Tracks old and new values.
|
|
99
|
+
*
|
|
100
|
+
* Difference from Vue: `deep` option is ignored — Pyreon tracks dependencies automatically.
|
|
101
|
+
* Returns a stop function to dispose the watcher.
|
|
102
|
+
*/
|
|
103
|
+
declare function watch<T>(source: WatchSource<T>, cb: (newValue: T, oldValue: T | undefined) => void, options?: WatchOptions): () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Runs the given function reactively — re-executes whenever its tracked
|
|
106
|
+
* dependencies change.
|
|
107
|
+
*
|
|
108
|
+
* Difference from Vue: identical to Pyreon's `effect()`.
|
|
109
|
+
* Returns a stop function.
|
|
110
|
+
*/
|
|
111
|
+
declare function watchEffect(fn: () => void): () => void;
|
|
112
|
+
/**
|
|
113
|
+
* Registers a callback to run after the component is mounted.
|
|
114
|
+
*
|
|
115
|
+
* Difference from Vue: maps directly to Pyreon's `onMount()`.
|
|
116
|
+
* In Pyreon there is no distinction between beforeMount and mounted.
|
|
117
|
+
*/
|
|
118
|
+
declare function onMounted(fn: () => void): void;
|
|
119
|
+
/**
|
|
120
|
+
* Registers a callback to run before the component is unmounted.
|
|
121
|
+
*
|
|
122
|
+
* Difference from Vue: maps to Pyreon's `onUnmount()`.
|
|
123
|
+
* In Pyreon there is no distinction between beforeUnmount and unmounted.
|
|
124
|
+
*/
|
|
125
|
+
declare function onUnmounted(fn: () => void): void;
|
|
126
|
+
/**
|
|
127
|
+
* Registers a callback to run after a reactive update.
|
|
128
|
+
*
|
|
129
|
+
* Difference from Vue: maps to Pyreon's `onUpdate()`.
|
|
130
|
+
*/
|
|
131
|
+
declare function onUpdated(fn: () => void): void;
|
|
132
|
+
/**
|
|
133
|
+
* Registers a callback to run before mount.
|
|
134
|
+
* In Pyreon there is no pre-mount phase — maps to `onMount()`.
|
|
135
|
+
*/
|
|
136
|
+
declare function onBeforeMount(fn: () => void): void;
|
|
137
|
+
/**
|
|
138
|
+
* Registers a callback to run before unmount.
|
|
139
|
+
* In Pyreon there is no pre-unmount phase — maps to `onUnmount()`.
|
|
140
|
+
*/
|
|
141
|
+
declare function onBeforeUnmount(fn: () => void): void;
|
|
142
|
+
/**
|
|
143
|
+
* Returns a Promise that resolves after all pending reactive updates have flushed.
|
|
144
|
+
*
|
|
145
|
+
* Difference from Vue: identical to Pyreon's `nextTick()`.
|
|
146
|
+
*/
|
|
147
|
+
declare function nextTick(): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Provides a value to all descendant components.
|
|
150
|
+
*
|
|
151
|
+
* Difference from Vue: backed by Pyreon's context stack (pushContext/popContext).
|
|
152
|
+
* Must be called during component setup. The value is scoped to the component
|
|
153
|
+
* tree — not globally shared.
|
|
154
|
+
*/
|
|
155
|
+
declare function provide<T>(key: string | symbol, value: T): void;
|
|
156
|
+
/**
|
|
157
|
+
* Injects a value provided by an ancestor component.
|
|
158
|
+
*
|
|
159
|
+
* Difference from Vue: backed by Pyreon's context system (useContext).
|
|
160
|
+
*/
|
|
161
|
+
declare function inject<T>(key: string | symbol, defaultValue?: T): T | undefined;
|
|
162
|
+
interface ComponentOptions<P extends Props = Props> {
|
|
163
|
+
/** The setup function — called once during component initialization. */
|
|
164
|
+
setup: (props: P) => (() => VNodeChild) | VNodeChild;
|
|
165
|
+
/** Optional name for debugging. */
|
|
166
|
+
name?: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Defines a component using Vue 3 Composition API style.
|
|
170
|
+
* Only supports the `setup()` function — Options API is not supported.
|
|
171
|
+
*
|
|
172
|
+
* Difference from Vue: returns a Pyreon `ComponentFn`. No template/render option —
|
|
173
|
+
* the setup function should return a render function or VNode directly.
|
|
174
|
+
*/
|
|
175
|
+
declare function defineComponent<P extends Props = Props>(options: ComponentOptions<P> | ((props: P) => VNodeChild)): ComponentFn<P>;
|
|
176
|
+
interface App {
|
|
177
|
+
/** Mount the application into a DOM element. Returns an unmount function. */
|
|
178
|
+
mount(el: string | Element): () => void;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Creates a Pyreon application instance — Vue 3 `createApp()` compatible.
|
|
182
|
+
*
|
|
183
|
+
* Difference from Vue: does not support plugins, directives, or global config.
|
|
184
|
+
* The component receives `props` if provided.
|
|
185
|
+
*/
|
|
186
|
+
declare function createApp(component: ComponentFn, props?: Props): App;
|
|
187
|
+
//#endregion
|
|
188
|
+
export { ComputedRef, Fragment, Ref, WatchOptions, batch, computed, createApp, defineComponent, pyreonH as h, inject, isRef, nextTick, onBeforeMount, onBeforeUnmount, onMounted, onUnmounted, onUpdated, provide, reactive, readonly, ref, shallowReactive, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, watch, watchEffect };
|
|
189
|
+
//# sourceMappingURL=index2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index2.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;cA4CM,QAAA;AAAA,UAMW,GAAA;EACf,KAAA,EAAO,CAAA;EAAA,UACG,QAAA;AAAA;;;;;;;;iBAUI,GAAA,GAAA,CAAO,KAAA,EAAO,CAAA,GAAI,GAAA,CAAI,CAAA;AAqBtC;;;;;AAAA,iBAAgB,UAAA,GAAA,CAAc,KAAA,EAAO,CAAA,GAAI,GAAA,CAAI,CAAA;;;;iBAO7B,UAAA,GAAA,CAAc,CAAA,EAAG,GAAA,CAAI,CAAA;;;;iBAarB,KAAA,CAAM,GAAA,YAAe,GAAA,IAAO,GAAA;;AAb5C;;iBAsBgB,KAAA,GAAA,CAAS,CAAA,EAAG,CAAA,GAAI,GAAA,CAAI,CAAA,IAAK,CAAA;AAAA,UAMxB,WAAA,sBAAiC,GAAA,CAAI,CAAA;EAAA,SAC3C,KAAA,EAAO,CAAA;AAAA;;;;;AAhBlB;;;iBA0BgB,QAAA,GAAA,CACd,WAAA,SAAoB,CAAA;EAAO,GAAA,QAAW,CAAA;EAAG,GAAA,GAAM,KAAA,EAAO,CAAA;AAAA,IACrD,WAAA,CAAY,CAAA;;;AAnBf;;;;;iBA+CgB,QAAA,kBAAA,CAA2B,GAAA,EAAK,CAAA,GAAI,CAAA;;;;;;;;iBAcpC,eAAA,kBAAA,CAAkC,GAAA,EAAK,CAAA,GAAI,CAAA;;;;AAvD3D;;;iBAoEgB,QAAA,kBAAA,CAA2B,GAAA,EAAK,CAAA,GAAI,QAAA,CAAS,CAAA;;;;;;iBAwB7C,KAAA,kBAAA,CAAwB,KAAA,EAAO,CAAA,GAAI,CAAA;;;;;iBAenC,KAAA,mCAAwC,CAAA,CAAA,CAAG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D;EAsNrE,KAAA,CAAM,EAAA,WAAa,OAAA;AAAA;;;;;;;iBASL,SAAA,CAAU,SAAA,EAAW,WAAA,EAAa,KAAA,GAAQ,KAAA,GAAQ,GAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pyreon/vue-compat",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vue 3-compatible Composition API shim for Pyreon — write Vue-style code that runs on Pyreon's reactive engine",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/pyreon/pyreon.git",
|
|
9
|
+
"directory": "packages/vue-compat"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/pyreon/pyreon/tree/main/packages/vue-compat#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/pyreon/pyreon/issues"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"lib",
|
|
17
|
+
"src",
|
|
18
|
+
"README.md",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./lib/index.js",
|
|
24
|
+
"module": "./lib/index.js",
|
|
25
|
+
"types": "./lib/types/index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"bun": "./src/index.ts",
|
|
29
|
+
"import": "./lib/index.js",
|
|
30
|
+
"types": "./lib/types/index.d.ts"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "vl_rolldown_build",
|
|
35
|
+
"dev": "vl_rolldown_build-watch",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"prepublishOnly": "bun run build"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@pyreon/core": "workspace:*",
|
|
42
|
+
"@pyreon/reactivity": "workspace:*",
|
|
43
|
+
"@pyreon/runtime-dom": "workspace:*"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@happy-dom/global-registrator": "^20.8.3",
|
|
47
|
+
"happy-dom": "^20.8.3"
|
|
48
|
+
}
|
|
49
|
+
}
|