@pyreon/vue-compat 0.1.1 → 0.1.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/README.md +80 -3
- package/lib/analysis/index.js.html +1 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +1 -1
- package/lib/types/index.d.ts +0 -7
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index2.d.ts +9 -5
- package/lib/types/index2.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/index.ts +13 -4
package/README.md
CHANGED
|
@@ -10,22 +10,99 @@ bun add @pyreon/vue-compat
|
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
|
-
```
|
|
13
|
+
```tsx
|
|
14
14
|
// Replace:
|
|
15
15
|
// import { ref, computed, watch } from "vue"
|
|
16
16
|
// With:
|
|
17
17
|
import { ref, computed, watch } from "@pyreon/vue-compat"
|
|
18
18
|
|
|
19
|
-
function
|
|
19
|
+
function Counter() {
|
|
20
20
|
const count = ref(0)
|
|
21
21
|
const doubled = computed(() => count.value * 2)
|
|
22
|
+
|
|
22
23
|
watch(count, (newVal, oldVal) => {
|
|
23
24
|
console.log(`count: ${oldVal} -> ${newVal}`)
|
|
24
25
|
})
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div>
|
|
29
|
+
<span>{doubled.value}</span>
|
|
30
|
+
<button onClick={() => count.value++}>Count: {count.value}</button>
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Reactive Objects
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { reactive, watchEffect } from "@pyreon/vue-compat"
|
|
40
|
+
|
|
41
|
+
function UserForm() {
|
|
42
|
+
const form = reactive({ name: "", email: "" })
|
|
43
|
+
|
|
44
|
+
watchEffect(() => {
|
|
45
|
+
console.log("form changed:", form.name, form.email)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div>
|
|
50
|
+
<input
|
|
51
|
+
value={form.name}
|
|
52
|
+
onInput={(e) => (form.name = e.currentTarget.value)}
|
|
53
|
+
placeholder="Name"
|
|
54
|
+
/>
|
|
55
|
+
<input
|
|
56
|
+
value={form.email}
|
|
57
|
+
onInput={(e) => (form.email = e.currentTarget.value)}
|
|
58
|
+
placeholder="Email"
|
|
59
|
+
/>
|
|
60
|
+
<p>Hello, {form.name} ({form.email})</p>
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Provide / Inject
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { ref, provide, inject, defineComponent } from "@pyreon/vue-compat"
|
|
70
|
+
|
|
71
|
+
const ThemeKey = Symbol("theme")
|
|
72
|
+
|
|
73
|
+
function ThemeProvider(props: { children: any }) {
|
|
74
|
+
const theme = ref("light")
|
|
75
|
+
provide(ThemeKey, theme)
|
|
76
|
+
return (
|
|
77
|
+
<div>
|
|
78
|
+
<button onClick={() => (theme.value = theme.value === "light" ? "dark" : "light")}>
|
|
79
|
+
Toggle theme
|
|
80
|
+
</button>
|
|
81
|
+
{props.children}
|
|
82
|
+
</div>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function ThemedBox() {
|
|
87
|
+
const theme = inject(ThemeKey, ref("light"))
|
|
88
|
+
return <div class={`box-${theme.value}`}>Theme: {theme.value}</div>
|
|
26
89
|
}
|
|
27
90
|
```
|
|
28
91
|
|
|
92
|
+
### createApp
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import { createApp, ref } from "@pyreon/vue-compat"
|
|
96
|
+
|
|
97
|
+
function App() {
|
|
98
|
+
const message = ref("Hello from Pyreon")
|
|
99
|
+
return <h1>{message.value}</h1>
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const app = createApp(App)
|
|
103
|
+
app.mount("#app")
|
|
104
|
+
```
|
|
105
|
+
|
|
29
106
|
## Key Differences from Vue
|
|
30
107
|
|
|
31
108
|
- **No virtual DOM.** Pyreon uses fine-grained reactivity -- no diffing, no re-renders.
|
|
@@ -5386,7 +5386,7 @@ var drawChart = (function (exports) {
|
|
|
5386
5386
|
</script>
|
|
5387
5387
|
<script>
|
|
5388
5388
|
/*<!--*/
|
|
5389
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src/index.ts","uid":"
|
|
5389
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.js","children":[{"name":"src/index.ts","uid":"7bb4adb7-1"}]}],"isRoot":true},"nodeParts":{"7bb4adb7-1":{"renderedLength":8358,"gzipLength":2795,"brotliLength":0,"metaUid":"7bb4adb7-0"}},"nodeMetas":{"7bb4adb7-0":{"id":"/src/index.ts","moduleParts":{"index.js":"7bb4adb7-1"},"imported":[{"uid":"7bb4adb7-2"},{"uid":"7bb4adb7-3"},{"uid":"7bb4adb7-4"}],"importedBy":[],"isEntry":true},"7bb4adb7-2":{"id":"@pyreon/core","moduleParts":{},"imported":[],"importedBy":[{"uid":"7bb4adb7-0"}]},"7bb4adb7-3":{"id":"@pyreon/reactivity","moduleParts":{},"imported":[],"importedBy":[{"uid":"7bb4adb7-0"}]},"7bb4adb7-4":{"id":"@pyreon/runtime-dom","moduleParts":{},"imported":[],"importedBy":[{"uid":"7bb4adb7-0"}]}},"env":{"rollup":"4.23.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
5390
5390
|
|
|
5391
5391
|
const run = () => {
|
|
5392
5392
|
const width = window.innerWidth;
|
package/lib/index.js
CHANGED
|
@@ -57,13 +57,6 @@ function isRef(val) {
|
|
|
57
57
|
function unref(r) {
|
|
58
58
|
return isRef(r) ? r.value : r;
|
|
59
59
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Creates a computed ref. Supports both readonly and writable forms:
|
|
62
|
-
* - `computed(() => value)` — readonly
|
|
63
|
-
* - `computed({ get: () => value, set: (v) => ... })` — writable
|
|
64
|
-
*
|
|
65
|
-
* Backed by Pyreon's `computed()`, wrapped in a `.value` accessor.
|
|
66
|
-
*/
|
|
67
60
|
function computed(fnOrOptions) {
|
|
68
61
|
const getter = typeof fnOrOptions === "function" ? fnOrOptions : fnOrOptions.get;
|
|
69
62
|
const setter = typeof fnOrOptions === "object" ? fnOrOptions.set : void 0;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["pyreonComputed","pyreonNextTick","pyreonMount"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @pyreon/vue-compat\n *\n * Vue 3-compatible Composition API that runs on Pyreon's reactive engine.\n *\n * Allows you to write familiar Vue 3 Composition API code while getting Pyreon's\n * fine-grained reactivity and superior performance.\n *\n * DIFFERENCES FROM VUE 3:\n * - `deep` option in watch() is ignored — Pyreon tracks dependencies automatically.\n * - `shallowReactive` uses per-property signals (still shallow, but Pyreon-flavored).\n * - `readonly` returns a Proxy that throws on set (not Vue's readonly proxy).\n * - `defineComponent` only supports Composition API (setup function), not Options API.\n * - Components run ONCE (setup phase), not on every render.\n *\n * USAGE:\n * Replace `import { ref, computed, watch } from \"vue\"` with\n * `import { ref, computed, watch } from \"@pyreon/vue-compat\"`\n */\n\nimport type { ComponentFn, Props, VNodeChild } from \"@pyreon/core\"\nimport {\n createContext,\n Fragment,\n onMount,\n onUnmount,\n onUpdate,\n popContext,\n pushContext,\n h as pyreonH,\n useContext,\n} from \"@pyreon/core\"\nimport {\n createStore,\n effect,\n computed as pyreonComputed,\n nextTick as pyreonNextTick,\n type Signal,\n signal,\n} from \"@pyreon/reactivity\"\nimport { mount as pyreonMount } from \"@pyreon/runtime-dom\"\n\n// ─── Internal symbols ─────────────────────────────────────────────────────────\n\nconst V_IS_REF = Symbol(\"__v_isRef\")\nconst V_IS_READONLY = Symbol(\"__v_isReadonly\")\nconst V_RAW = Symbol(\"__v_raw\")\n\n// ─── Ref ──────────────────────────────────────────────────────────────────────\n\nexport interface Ref<T = unknown> {\n value: T\n readonly [V_IS_REF]: true\n}\n\n/**\n * Creates a reactive ref wrapping the given value.\n * Access via `.value` — reads track, writes trigger.\n *\n * Difference from Vue: backed by a Pyreon signal. No `__v_isShallow` distinction\n * at runtime since Pyreon signals are always shallow (deep reactivity is via stores).\n */\nexport function ref<T>(value: T): Ref<T> {\n const s = signal(value)\n const r = {\n [V_IS_REF]: true as const,\n get value(): T {\n return s()\n },\n set value(newValue: T) {\n s.set(newValue)\n },\n /** @internal — access underlying signal for triggerRef */\n _signal: s,\n }\n return r as Ref<T>\n}\n\n/**\n * Creates a shallow ref — same as `ref()` in Pyreon since signals are inherently shallow.\n *\n * Difference from Vue: identical to `ref()` — Pyreon signals don't perform deep conversion.\n */\nexport function shallowRef<T>(value: T): Ref<T> {\n return ref(value)\n}\n\n/**\n * Force trigger a ref's subscribers, even if the value hasn't changed.\n */\nexport function triggerRef<T>(r: Ref<T>): void {\n const internal = r as Ref<T> & { _signal: Signal<T> }\n if (internal._signal) {\n // Force notify by setting the same value with Object.is bypass\n const current = internal._signal.peek()\n internal._signal.set(undefined as T)\n internal._signal.set(current)\n }\n}\n\n/**\n * Returns `true` if the value is a ref (created by `ref()` or `computed()`).\n */\nexport function isRef(val: unknown): val is Ref {\n return (\n val !== null && typeof val === \"object\" && (val as Record<symbol, unknown>)[V_IS_REF] === true\n )\n}\n\n/**\n * Unwraps a ref: if it has `.value`, return `.value`; otherwise return as-is.\n */\nexport function unref<T>(r: T | Ref<T>): T {\n return isRef(r) ? r.value : r\n}\n\n// ─── Computed ─────────────────────────────────────────────────────────────────\n\nexport interface ComputedRef<T = unknown> extends Ref<T> {\n readonly value: T\n}\n\n/**\n * Creates a computed ref. Supports both readonly and writable forms:\n * - `computed(() => value)` — readonly\n * - `computed({ get: () => value, set: (v) => ... })` — writable\n *\n * Backed by Pyreon's `computed()`, wrapped in a `.value` accessor.\n */\nexport function computed<T>(\n fnOrOptions: (() => T) | { get: () => T; set: (value: T) => void },\n): ComputedRef<T> {\n const getter = typeof fnOrOptions === \"function\" ? fnOrOptions : fnOrOptions.get\n const setter = typeof fnOrOptions === \"object\" ? fnOrOptions.set : undefined\n const c = pyreonComputed(getter)\n const r = {\n [V_IS_REF]: true as const,\n get value(): T {\n return c()\n },\n set value(v: T) {\n if (!setter) {\n throw new Error(\"Cannot set value of a computed ref — computed refs are readonly\")\n }\n setter(v)\n },\n }\n return r as ComputedRef<T>\n}\n\n// ─── Reactive / Readonly ──────────────────────────────────────────────────────\n\n/**\n * Creates a deeply reactive proxy from a plain object.\n * Backed by Pyreon's `createStore()`.\n *\n * Difference from Vue: uses Pyreon's fine-grained per-property signals.\n * Direct mutation triggers only affected signals.\n */\nexport function reactive<T extends object>(obj: T): T {\n const proxy = createStore(obj)\n // Store raw reference for toRaw()\n rawMap.set(proxy as object, obj)\n return proxy\n}\n\n/**\n * Creates a shallow reactive proxy.\n * In Pyreon, `createStore` is already per-property (not deeply recursive for primitives),\n * but nested objects will be wrapped. For truly shallow behavior, use individual refs.\n *\n * Difference from Vue: backed by `createStore()` — same as `reactive()` in practice.\n */\nexport function shallowReactive<T extends object>(obj: T): T {\n return reactive(obj)\n}\n\n// WeakMap to track raw objects behind reactive proxies\nconst rawMap = new WeakMap<object, object>()\n\n/**\n * Returns a readonly proxy that throws on mutation attempts.\n *\n * Difference from Vue: uses a simple Proxy with a set trap that throws,\n * rather than Vue's full readonly reactive system.\n */\nexport function readonly<T extends object>(obj: T): Readonly<T> {\n const proxy = new Proxy(obj, {\n get(target, key) {\n if (key === V_IS_READONLY) return true\n if (key === V_RAW) return target\n return Reflect.get(target, key)\n },\n set(_target, key) {\n // Internal symbols used for identification are allowed\n if (key === V_IS_READONLY || key === V_RAW) return true\n throw new Error(`Cannot set property \"${String(key)}\" on a readonly object`)\n },\n deleteProperty(_target, key) {\n throw new Error(`Cannot delete property \"${String(key)}\" from a readonly object`)\n },\n })\n return proxy as Readonly<T>\n}\n\n/**\n * Returns the raw (unwrapped) object behind a reactive or readonly proxy.\n *\n * Difference from Vue: only works for objects created via `reactive()` or `readonly()`.\n */\nexport function toRaw<T extends object>(proxy: T): T {\n // Check readonly first\n const readonlyRaw = (proxy as Record<symbol, unknown>)[V_RAW]\n if (readonlyRaw) return readonlyRaw as T\n // Check reactive\n const raw = rawMap.get(proxy as object)\n return (raw as T) ?? proxy\n}\n\n// ─── toRef / toRefs ───────────────────────────────────────────────────────────\n\n/**\n * Creates a ref linked to a property of a reactive object.\n * Reading/writing the ref's `.value` reads/writes the original property.\n */\nexport function toRef<T extends object, K extends keyof T>(obj: T, key: K): Ref<T[K]> {\n const r = {\n [V_IS_REF]: true as const,\n get value(): T[K] {\n return obj[key]\n },\n set value(newValue: T[K]) {\n obj[key] = newValue\n },\n }\n return r as Ref<T[K]>\n}\n\n/**\n * Converts all properties of a reactive object into individual refs.\n * Each ref is linked to the original property (not a copy).\n */\nexport function toRefs<T extends object>(obj: T): { [K in keyof T]: Ref<T[K]> } {\n const result = {} as { [K in keyof T]: Ref<T[K]> }\n for (const key of Object.keys(obj) as (keyof T)[]) {\n result[key] = toRef(obj, key)\n }\n return result\n}\n\n// ─── Watch ────────────────────────────────────────────────────────────────────\n\nexport interface WatchOptions {\n /** Call the callback immediately with current value. Default: false */\n immediate?: boolean\n /** Ignored in Pyreon — dependencies are tracked automatically. */\n deep?: boolean\n}\n\ntype WatchSource<T> = Ref<T> | (() => T)\n\n/**\n * Watches a reactive source and calls `cb` when it changes.\n * Tracks old and new values.\n *\n * Difference from Vue: `deep` option is ignored — Pyreon tracks dependencies automatically.\n * Returns a stop function to dispose the watcher.\n */\nexport function watch<T>(\n source: WatchSource<T>,\n cb: (newValue: T, oldValue: T | undefined) => void,\n options?: WatchOptions,\n): () => void {\n const getter = isRef(source) ? () => source.value : (source as () => T)\n let oldValue: T | undefined\n let initialized = false\n\n if (options?.immediate) {\n oldValue = undefined\n const current = getter()\n cb(current, oldValue)\n oldValue = current\n initialized = true\n }\n\n const e = effect(() => {\n const newValue = getter()\n if (initialized) {\n // Only call cb if value actually changed (or on first tracked run)\n cb(newValue, oldValue)\n }\n oldValue = newValue\n initialized = true\n })\n\n return () => e.dispose()\n}\n\n/**\n * Runs the given function reactively — re-executes whenever its tracked\n * dependencies change.\n *\n * Difference from Vue: identical to Pyreon's `effect()`.\n * Returns a stop function.\n */\nexport function watchEffect(fn: () => void): () => void {\n const e = effect(fn)\n return () => e.dispose()\n}\n\n// ─── Lifecycle ────────────────────────────────────────────────────────────────\n\n/**\n * Registers a callback to run after the component is mounted.\n *\n * Difference from Vue: maps directly to Pyreon's `onMount()`.\n * In Pyreon there is no distinction between beforeMount and mounted.\n */\nexport function onMounted(fn: () => void): void {\n onMount(() => {\n fn()\n return undefined\n })\n}\n\n/**\n * Registers a callback to run before the component is unmounted.\n *\n * Difference from Vue: maps to Pyreon's `onUnmount()`.\n * In Pyreon there is no distinction between beforeUnmount and unmounted.\n */\nexport function onUnmounted(fn: () => void): void {\n onUnmount(fn)\n}\n\n/**\n * Registers a callback to run after a reactive update.\n *\n * Difference from Vue: maps to Pyreon's `onUpdate()`.\n */\nexport function onUpdated(fn: () => void): void {\n onUpdate(fn)\n}\n\n/**\n * Registers a callback to run before mount.\n * In Pyreon there is no pre-mount phase — maps to `onMount()`.\n */\nexport function onBeforeMount(fn: () => void): void {\n onMount(() => {\n fn()\n return undefined\n })\n}\n\n/**\n * Registers a callback to run before unmount.\n * In Pyreon there is no pre-unmount phase — maps to `onUnmount()`.\n */\nexport function onBeforeUnmount(fn: () => void): void {\n onUnmount(fn)\n}\n\n// ─── nextTick ─────────────────────────────────────────────────────────────────\n\n/**\n * Returns a Promise that resolves after all pending reactive updates have flushed.\n *\n * Difference from Vue: identical to Pyreon's `nextTick()`.\n */\nexport function nextTick(): Promise<void> {\n return pyreonNextTick()\n}\n\n// ─── Provide / Inject ─────────────────────────────────────────────────────────\n\n// Registry of string/symbol keys to Pyreon context objects (created lazily)\nconst _contextRegistry = new Map<string | symbol, ReturnType<typeof createContext>>()\n\nfunction getOrCreateContext<T>(key: string | symbol, defaultValue?: T) {\n if (!_contextRegistry.has(key)) {\n _contextRegistry.set(key, createContext<T>(defaultValue as T))\n }\n return _contextRegistry.get(key) as ReturnType<typeof createContext<T>>\n}\n\n/**\n * Provides a value to all descendant components.\n *\n * Difference from Vue: backed by Pyreon's context stack (pushContext/popContext).\n * Must be called during component setup. The value is scoped to the component\n * tree — not globally shared.\n */\nexport function provide<T>(key: string | symbol, value: T): void {\n const ctx = getOrCreateContext<T>(key)\n pushContext(new Map([[ctx.id, value]]))\n onUnmount(() => popContext())\n}\n\n/**\n * Injects a value provided by an ancestor component.\n *\n * Difference from Vue: backed by Pyreon's context system (useContext).\n */\nexport function inject<T>(key: string | symbol, defaultValue?: T): T | undefined {\n const ctx = getOrCreateContext<T>(key)\n const value = useContext(ctx)\n return value !== undefined ? value : defaultValue\n}\n\n// ─── defineComponent ──────────────────────────────────────────────────────────\n\ninterface ComponentOptions<P extends Props = Props> {\n /** The setup function — called once during component initialization. */\n setup: (props: P) => (() => VNodeChild) | VNodeChild\n /** Optional name for debugging. */\n name?: string\n}\n\n/**\n * Defines a component using Vue 3 Composition API style.\n * Only supports the `setup()` function — Options API is not supported.\n *\n * Difference from Vue: returns a Pyreon `ComponentFn`. No template/render option —\n * the setup function should return a render function or VNode directly.\n */\nexport function defineComponent<P extends Props = Props>(\n options: ComponentOptions<P> | ((props: P) => VNodeChild),\n): ComponentFn<P> {\n if (typeof options === \"function\") {\n return options as ComponentFn<P>\n }\n const comp = (props: P) => {\n const result = options.setup(props)\n if (typeof result === \"function\") {\n return (result as () => VNodeChild)()\n }\n return result\n }\n if (options.name) {\n Object.defineProperty(comp, \"name\", { value: options.name })\n }\n return comp as ComponentFn<P>\n}\n\n// ─── h ────────────────────────────────────────────────────────────────────────\n\n/**\n * Re-export of Pyreon's `h()` function for creating VNodes.\n */\nexport { pyreonH as h, Fragment }\n\n// ─── createApp ────────────────────────────────────────────────────────────────\n\ninterface App {\n /** Mount the application into a DOM element. Returns an unmount function. */\n mount(el: string | Element): () => void\n}\n\n/**\n * Creates a Pyreon application instance — Vue 3 `createApp()` compatible.\n *\n * Difference from Vue: does not support plugins, directives, or global config.\n * The component receives `props` if provided.\n */\nexport function createApp(component: ComponentFn, props?: Props): App {\n return {\n mount(el: string | Element): () => void {\n const container = typeof el === \"string\" ? document.querySelector(el) : el\n if (!container) {\n throw new Error(`Cannot find mount target: ${el}`)\n }\n const vnode = pyreonH(component, props ?? null)\n return pyreonMount(vnode, container)\n },\n }\n}\n\n// ─── Additional re-exports ────────────────────────────────────────────────────\n\nexport { batch } from \"@pyreon/reactivity\"\n"],"mappings":";;;;;AA4CA,MAAM,WAAW,OAAO,YAAY;AACpC,MAAM,gBAAgB,OAAO,iBAAiB;AAC9C,MAAM,QAAQ,OAAO,UAAU;;;;;;;;AAgB/B,SAAgB,IAAO,OAAkB;CACvC,MAAM,IAAI,OAAO,MAAM;AAYvB,QAXU;GACP,WAAW;EACZ,IAAI,QAAW;AACb,UAAO,GAAG;;EAEZ,IAAI,MAAM,UAAa;AACrB,KAAE,IAAI,SAAS;;EAGjB,SAAS;EACV;;;;;;;AASH,SAAgB,WAAc,OAAkB;AAC9C,QAAO,IAAI,MAAM;;;;;AAMnB,SAAgB,WAAc,GAAiB;CAC7C,MAAM,WAAW;AACjB,KAAI,SAAS,SAAS;EAEpB,MAAM,UAAU,SAAS,QAAQ,MAAM;AACvC,WAAS,QAAQ,IAAI,OAAe;AACpC,WAAS,QAAQ,IAAI,QAAQ;;;;;;AAOjC,SAAgB,MAAM,KAA0B;AAC9C,QACE,QAAQ,QAAQ,OAAO,QAAQ,YAAa,IAAgC,cAAc;;;;;AAO9F,SAAgB,MAAS,GAAkB;AACzC,QAAO,MAAM,EAAE,GAAG,EAAE,QAAQ;;;;;;;;;AAgB9B,SAAgB,SACd,aACgB;CAChB,MAAM,SAAS,OAAO,gBAAgB,aAAa,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ACvC,iBAAgB,YAAY,CAAC;;;;;;;AAQ/B,SAAgB,OAAU,KAAsB,cAAiC;CAE/E,MAAM,QAAQ,WADF,mBAAsB,IAAI,CACT;AAC7B,QAAO,UAAU,SAAY,QAAQ;;;;;;;;;AAmBvC,SAAgB,gBACd,SACgB;AAChB,KAAI,OAAO,YAAY,WACrB,QAAO;CAET,MAAM,QAAQ,UAAa;EACzB,MAAM,SAAS,QAAQ,MAAM,MAAM;AACnC,MAAI,OAAO,WAAW,WACpB,QAAQ,QAA6B;AAEvC,SAAO;;AAET,KAAI,QAAQ,KACV,QAAO,eAAe,MAAM,QAAQ,EAAE,OAAO,QAAQ,MAAM,CAAC;AAE9D,QAAO;;;;;;;;AAuBT,SAAgB,UAAU,WAAwB,OAAoB;AACpE,QAAO,EACL,MAAM,IAAkC;EACtC,MAAM,YAAY,OAAO,OAAO,WAAW,SAAS,cAAc,GAAG,GAAG;AACxE,MAAI,CAAC,UACH,OAAM,IAAI,MAAM,6BAA6B,KAAK;AAGpD,SAAOC,MADO,QAAQ,WAAW,SAAS,KAAK,EACrB,UAAU;IAEvC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["pyreonComputed","pyreonNextTick","pyreonMount"],"sources":["../src/index.ts"],"sourcesContent":["/**\n * @pyreon/vue-compat\n *\n * Vue 3-compatible Composition API that runs on Pyreon's reactive engine.\n *\n * Allows you to write familiar Vue 3 Composition API code while getting Pyreon's\n * fine-grained reactivity and superior performance.\n *\n * DIFFERENCES FROM VUE 3:\n * - `deep` option in watch() is ignored — Pyreon tracks dependencies automatically.\n * - `shallowReactive` uses per-property signals (still shallow, but Pyreon-flavored).\n * - `readonly` returns a Proxy that throws on set (not Vue's readonly proxy).\n * - `defineComponent` only supports Composition API (setup function), not Options API.\n * - Components run ONCE (setup phase), not on every render.\n *\n * USAGE:\n * Replace `import { ref, computed, watch } from \"vue\"` with\n * `import { ref, computed, watch } from \"@pyreon/vue-compat\"`\n */\n\nimport type { ComponentFn, Props, VNodeChild } from \"@pyreon/core\"\nimport {\n createContext,\n Fragment,\n onMount,\n onUnmount,\n onUpdate,\n popContext,\n pushContext,\n h as pyreonH,\n useContext,\n} from \"@pyreon/core\"\nimport {\n createStore,\n effect,\n computed as pyreonComputed,\n nextTick as pyreonNextTick,\n type Signal,\n signal,\n} from \"@pyreon/reactivity\"\nimport { mount as pyreonMount } from \"@pyreon/runtime-dom\"\n\n// ─── Internal symbols ─────────────────────────────────────────────────────────\n\nconst V_IS_REF = Symbol(\"__v_isRef\")\nconst V_IS_READONLY = Symbol(\"__v_isReadonly\")\nconst V_RAW = Symbol(\"__v_raw\")\n\n// ─── Ref ──────────────────────────────────────────────────────────────────────\n\nexport interface Ref<T = unknown> {\n value: T\n readonly [V_IS_REF]: true\n}\n\n/**\n * Creates a reactive ref wrapping the given value.\n * Access via `.value` — reads track, writes trigger.\n *\n * Difference from Vue: backed by a Pyreon signal. No `__v_isShallow` distinction\n * at runtime since Pyreon signals are always shallow (deep reactivity is via stores).\n */\nexport function ref<T>(value: T): Ref<T> {\n const s = signal(value)\n const r = {\n [V_IS_REF]: true as const,\n get value(): T {\n return s()\n },\n set value(newValue: T) {\n s.set(newValue)\n },\n /** @internal — access underlying signal for triggerRef */\n _signal: s,\n }\n return r as Ref<T>\n}\n\n/**\n * Creates a shallow ref — same as `ref()` in Pyreon since signals are inherently shallow.\n *\n * Difference from Vue: identical to `ref()` — Pyreon signals don't perform deep conversion.\n */\nexport function shallowRef<T>(value: T): Ref<T> {\n return ref(value)\n}\n\n/**\n * Force trigger a ref's subscribers, even if the value hasn't changed.\n */\nexport function triggerRef<T>(r: Ref<T>): void {\n const internal = r as Ref<T> & { _signal: Signal<T> }\n if (internal._signal) {\n // Force notify by setting the same value with Object.is bypass\n const current = internal._signal.peek()\n internal._signal.set(undefined as T)\n internal._signal.set(current)\n }\n}\n\n/**\n * Returns `true` if the value is a ref (created by `ref()` or `computed()`).\n */\nexport function isRef(val: unknown): val is Ref {\n return (\n val !== null && typeof val === \"object\" && (val as Record<symbol, unknown>)[V_IS_REF] === true\n )\n}\n\n/**\n * Unwraps a ref: if it has `.value`, return `.value`; otherwise return as-is.\n */\nexport function unref<T>(r: T | Ref<T>): T {\n return isRef(r) ? r.value : r\n}\n\n// ─── Computed ─────────────────────────────────────────────────────────────────\n\nexport interface ComputedRef<T = unknown> extends Ref<T> {\n readonly value: T\n}\n\nexport interface WritableComputedRef<T = unknown> extends Ref<T> {\n value: T\n}\n\n/**\n * Creates a computed ref. Supports both readonly and writable forms:\n * - `computed(() => value)` — readonly ComputedRef\n * - `computed({ get, set })` — writable WritableComputedRef\n *\n * Backed by Pyreon's `computed()`, wrapped in a `.value` accessor.\n */\nexport function computed<T>(getter: () => T): ComputedRef<T>\nexport function computed<T>(options: {\n get: () => T\n set: (value: T) => void\n}): WritableComputedRef<T>\nexport function computed<T>(\n fnOrOptions: (() => T) | { get: () => T; set: (value: T) => void },\n): ComputedRef<T> | WritableComputedRef<T> {\n const getter = typeof fnOrOptions === \"function\" ? fnOrOptions : fnOrOptions.get\n const setter = typeof fnOrOptions === \"object\" ? fnOrOptions.set : undefined\n const c = pyreonComputed(getter)\n const r = {\n [V_IS_REF]: true as const,\n get value(): T {\n return c()\n },\n set value(v: T) {\n if (!setter) {\n throw new Error(\"Cannot set value of a computed ref — computed refs are readonly\")\n }\n setter(v)\n },\n }\n return r as ComputedRef<T>\n}\n\n// ─── Reactive / Readonly ──────────────────────────────────────────────────────\n\n/**\n * Creates a deeply reactive proxy from a plain object.\n * Backed by Pyreon's `createStore()`.\n *\n * Difference from Vue: uses Pyreon's fine-grained per-property signals.\n * Direct mutation triggers only affected signals.\n */\nexport function reactive<T extends object>(obj: T): T {\n const proxy = createStore(obj)\n // Store raw reference for toRaw()\n rawMap.set(proxy as object, obj)\n return proxy\n}\n\n/**\n * Creates a shallow reactive proxy.\n * In Pyreon, `createStore` is already per-property (not deeply recursive for primitives),\n * but nested objects will be wrapped. For truly shallow behavior, use individual refs.\n *\n * Difference from Vue: backed by `createStore()` — same as `reactive()` in practice.\n */\nexport function shallowReactive<T extends object>(obj: T): T {\n return reactive(obj)\n}\n\n// WeakMap to track raw objects behind reactive proxies\nconst rawMap = new WeakMap<object, object>()\n\n/**\n * Returns a readonly proxy that throws on mutation attempts.\n *\n * Difference from Vue: uses a simple Proxy with a set trap that throws,\n * rather than Vue's full readonly reactive system.\n */\nexport function readonly<T extends object>(obj: T): Readonly<T> {\n const proxy = new Proxy(obj, {\n get(target, key) {\n if (key === V_IS_READONLY) return true\n if (key === V_RAW) return target\n return Reflect.get(target, key)\n },\n set(_target, key) {\n // Internal symbols used for identification are allowed\n if (key === V_IS_READONLY || key === V_RAW) return true\n throw new Error(`Cannot set property \"${String(key)}\" on a readonly object`)\n },\n deleteProperty(_target, key) {\n throw new Error(`Cannot delete property \"${String(key)}\" from a readonly object`)\n },\n })\n return proxy as Readonly<T>\n}\n\n/**\n * Returns the raw (unwrapped) object behind a reactive or readonly proxy.\n *\n * Difference from Vue: only works for objects created via `reactive()` or `readonly()`.\n */\nexport function toRaw<T extends object>(proxy: T): T {\n // Check readonly first\n const readonlyRaw = (proxy as Record<symbol, unknown>)[V_RAW]\n if (readonlyRaw) return readonlyRaw as T\n // Check reactive\n const raw = rawMap.get(proxy as object)\n return (raw as T) ?? proxy\n}\n\n// ─── toRef / toRefs ───────────────────────────────────────────────────────────\n\n/**\n * Creates a ref linked to a property of a reactive object.\n * Reading/writing the ref's `.value` reads/writes the original property.\n */\nexport function toRef<T extends object, K extends keyof T>(obj: T, key: K): Ref<T[K]> {\n const r = {\n [V_IS_REF]: true as const,\n get value(): T[K] {\n return obj[key]\n },\n set value(newValue: T[K]) {\n obj[key] = newValue\n },\n }\n return r as Ref<T[K]>\n}\n\n/**\n * Converts all properties of a reactive object into individual refs.\n * Each ref is linked to the original property (not a copy).\n */\nexport function toRefs<T extends object>(obj: T): { [K in keyof T]: Ref<T[K]> } {\n const result = {} as { [K in keyof T]: Ref<T[K]> }\n for (const key of Object.keys(obj) as (keyof T)[]) {\n result[key] = toRef(obj, key)\n }\n return result\n}\n\n// ─── Watch ────────────────────────────────────────────────────────────────────\n\nexport interface WatchOptions {\n /** Call the callback immediately with current value. Default: false */\n immediate?: boolean\n /** Ignored in Pyreon — dependencies are tracked automatically. */\n deep?: boolean\n}\n\ntype WatchSource<T> = Ref<T> | (() => T)\n\n/**\n * Watches a reactive source and calls `cb` when it changes.\n * Tracks old and new values.\n *\n * Difference from Vue: `deep` option is ignored — Pyreon tracks dependencies automatically.\n * Returns a stop function to dispose the watcher.\n */\nexport function watch<T>(\n source: WatchSource<T>,\n cb: (newValue: T, oldValue: T | undefined) => void,\n options?: WatchOptions,\n): () => void {\n const getter = isRef(source) ? () => source.value : (source as () => T)\n let oldValue: T | undefined\n let initialized = false\n\n if (options?.immediate) {\n oldValue = undefined\n const current = getter()\n cb(current, oldValue)\n oldValue = current\n initialized = true\n }\n\n const e = effect(() => {\n const newValue = getter()\n if (initialized) {\n // Only call cb if value actually changed (or on first tracked run)\n cb(newValue, oldValue)\n }\n oldValue = newValue\n initialized = true\n })\n\n return () => e.dispose()\n}\n\n/**\n * Runs the given function reactively — re-executes whenever its tracked\n * dependencies change.\n *\n * Difference from Vue: identical to Pyreon's `effect()`.\n * Returns a stop function.\n */\nexport function watchEffect(fn: () => void): () => void {\n const e = effect(fn)\n return () => e.dispose()\n}\n\n// ─── Lifecycle ────────────────────────────────────────────────────────────────\n\n/**\n * Registers a callback to run after the component is mounted.\n *\n * Difference from Vue: maps directly to Pyreon's `onMount()`.\n * In Pyreon there is no distinction between beforeMount and mounted.\n */\nexport function onMounted(fn: () => void): void {\n onMount(() => {\n fn()\n return undefined\n })\n}\n\n/**\n * Registers a callback to run before the component is unmounted.\n *\n * Difference from Vue: maps to Pyreon's `onUnmount()`.\n * In Pyreon there is no distinction between beforeUnmount and unmounted.\n */\nexport function onUnmounted(fn: () => void): void {\n onUnmount(fn)\n}\n\n/**\n * Registers a callback to run after a reactive update.\n *\n * Difference from Vue: maps to Pyreon's `onUpdate()`.\n */\nexport function onUpdated(fn: () => void): void {\n onUpdate(fn)\n}\n\n/**\n * Registers a callback to run before mount.\n * In Pyreon there is no pre-mount phase — maps to `onMount()`.\n */\nexport function onBeforeMount(fn: () => void): void {\n onMount(() => {\n fn()\n return undefined\n })\n}\n\n/**\n * Registers a callback to run before unmount.\n * In Pyreon there is no pre-unmount phase — maps to `onUnmount()`.\n */\nexport function onBeforeUnmount(fn: () => void): void {\n onUnmount(fn)\n}\n\n// ─── nextTick ─────────────────────────────────────────────────────────────────\n\n/**\n * Returns a Promise that resolves after all pending reactive updates have flushed.\n *\n * Difference from Vue: identical to Pyreon's `nextTick()`.\n */\nexport function nextTick(): Promise<void> {\n return pyreonNextTick()\n}\n\n// ─── Provide / Inject ─────────────────────────────────────────────────────────\n\n// Registry of string/symbol keys to Pyreon context objects (created lazily)\nconst _contextRegistry = new Map<string | symbol, ReturnType<typeof createContext>>()\n\nfunction getOrCreateContext<T>(key: string | symbol, defaultValue?: T) {\n if (!_contextRegistry.has(key)) {\n _contextRegistry.set(key, createContext<T>(defaultValue as T))\n }\n return _contextRegistry.get(key) as ReturnType<typeof createContext<T>>\n}\n\n/**\n * Provides a value to all descendant components.\n *\n * Difference from Vue: backed by Pyreon's context stack (pushContext/popContext).\n * Must be called during component setup. The value is scoped to the component\n * tree — not globally shared.\n */\nexport function provide<T>(key: string | symbol, value: T): void {\n const ctx = getOrCreateContext<T>(key)\n pushContext(new Map([[ctx.id, value]]))\n onUnmount(() => popContext())\n}\n\n/**\n * Injects a value provided by an ancestor component.\n *\n * Difference from Vue: backed by Pyreon's context system (useContext).\n */\nexport function inject<T>(key: string | symbol, defaultValue?: T): T | undefined {\n const ctx = getOrCreateContext<T>(key)\n const value = useContext(ctx)\n return value !== undefined ? value : defaultValue\n}\n\n// ─── defineComponent ──────────────────────────────────────────────────────────\n\ninterface ComponentOptions<P extends Props = Props> {\n /** The setup function — called once during component initialization. */\n setup: (props: P) => (() => VNodeChild) | VNodeChild\n /** Optional name for debugging. */\n name?: string\n}\n\n/**\n * Defines a component using Vue 3 Composition API style.\n * Only supports the `setup()` function — Options API is not supported.\n *\n * Difference from Vue: returns a Pyreon `ComponentFn`. No template/render option —\n * the setup function should return a render function or VNode directly.\n */\nexport function defineComponent<P extends Props = Props>(\n options: ComponentOptions<P> | ((props: P) => VNodeChild),\n): ComponentFn<P> {\n if (typeof options === \"function\") {\n return options as ComponentFn<P>\n }\n const comp = (props: P) => {\n const result = options.setup(props)\n if (typeof result === \"function\") {\n return (result as () => VNodeChild)()\n }\n return result\n }\n if (options.name) {\n Object.defineProperty(comp, \"name\", { value: options.name })\n }\n return comp as ComponentFn<P>\n}\n\n// ─── h ────────────────────────────────────────────────────────────────────────\n\n/**\n * Re-export of Pyreon's `h()` function for creating VNodes.\n */\nexport { Fragment, pyreonH as h }\n\n// ─── createApp ────────────────────────────────────────────────────────────────\n\ninterface App {\n /** Mount the application into a DOM element. Returns an unmount function. */\n mount(el: string | Element): () => void\n}\n\n/**\n * Creates a Pyreon application instance — Vue 3 `createApp()` compatible.\n *\n * Difference from Vue: does not support plugins, directives, or global config.\n * The component receives `props` if provided.\n */\nexport function createApp(component: ComponentFn, props?: Props): App {\n return {\n mount(el: string | Element): () => void {\n const container = typeof el === \"string\" ? document.querySelector(el) : el\n if (!container) {\n throw new Error(`Cannot find mount target: ${el}`)\n }\n const vnode = pyreonH(component, props ?? null)\n return pyreonMount(vnode, container)\n },\n }\n}\n\n// ─── Additional re-exports ────────────────────────────────────────────────────\n\nexport { batch } from \"@pyreon/reactivity\"\n"],"mappings":";;;;;AA4CA,MAAM,WAAW,OAAO,YAAY;AACpC,MAAM,gBAAgB,OAAO,iBAAiB;AAC9C,MAAM,QAAQ,OAAO,UAAU;;;;;;;;AAgB/B,SAAgB,IAAO,OAAkB;CACvC,MAAM,IAAI,OAAO,MAAM;AAYvB,QAXU;GACP,WAAW;EACZ,IAAI,QAAW;AACb,UAAO,GAAG;;EAEZ,IAAI,MA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ANGED
|
@@ -55,13 +55,6 @@ function isRef(val) {
|
|
|
55
55
|
function unref(r) {
|
|
56
56
|
return isRef(r) ? r.value : r;
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Creates a computed ref. Supports both readonly and writable forms:
|
|
60
|
-
* - `computed(() => value)` — readonly
|
|
61
|
-
* - `computed({ get: () => value, set: (v) => ... })` — writable
|
|
62
|
-
*
|
|
63
|
-
* Backed by Pyreon's `computed()`, wrapped in a `.value` accessor.
|
|
64
|
-
*/
|
|
65
58
|
function computed(fnOrOptions) {
|
|
66
59
|
const getter = typeof fnOrOptions === "function" ? fnOrOptions : fnOrOptions.get;
|
|
67
60
|
const setter = typeof fnOrOptions === "object" ? fnOrOptions.set : void 0;
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["pyreonComputed","pyreonNextTick","pyreonMount"],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;AA8DA,SAAgB,GAAA,CAAO,KAAA,EAAkB;EACvC,MAAM,CAAA,GAAI,MAAA,CAAO,KAAA,CAAM;EAYvB,OAXU;KACP,QAAA,GAAW,IAAA;IACZ,IAAI,KAAA,CAAA,EAAW;MACb,OAAO,CAAA,CAAA,CAAG;;IAEZ,IAAI,KAAA,CAAM,QAAA,EAAa;MACrB,CAAA,CAAE,GAAA,CAAI,QAAA,CAAS;;IAGjB,OAAA,EAAS;GACV;;;;;;;AASH,SAAgB,UAAA,CAAc,KAAA,EAAkB;EAC9C,OAAO,GAAA,CAAI,KAAA,CAAM;;;;;AAMnB,SAAgB,UAAA,CAAc,CAAA,EAAiB;EAC7C,MAAM,QAAA,GAAW,CAAA;EACjB,IAAI,QAAA,CAAS,OAAA,EAAS;IAEpB,MAAM,OAAA,GAAU,QAAA,CAAS,OAAA,CAAQ,IAAA,CAAA,CAAM;IACvC,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,KAAA,CAAA,CAAe;IACp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AA6B,EAAA,EAAA,CAAK;MAGpD,OAAOC,KAAAA,CADO,OAAA,CAAQ,SAAA,EAAW,KAAA,IAAS,IAAA,CAAK,EACrB,SAAA,CAAU;;GAEvC"}
|
package/lib/types/index2.d.ts
CHANGED
|
@@ -36,17 +36,21 @@ declare function unref<T>(r: T | Ref<T>): T;
|
|
|
36
36
|
interface ComputedRef<T = unknown> extends Ref<T> {
|
|
37
37
|
readonly value: T;
|
|
38
38
|
}
|
|
39
|
+
interface WritableComputedRef<T = unknown> extends Ref<T> {
|
|
40
|
+
value: T;
|
|
41
|
+
}
|
|
39
42
|
/**
|
|
40
43
|
* Creates a computed ref. Supports both readonly and writable forms:
|
|
41
|
-
* - `computed(() => value)` — readonly
|
|
42
|
-
* - `computed({ get
|
|
44
|
+
* - `computed(() => value)` — readonly ComputedRef
|
|
45
|
+
* - `computed({ get, set })` — writable WritableComputedRef
|
|
43
46
|
*
|
|
44
47
|
* Backed by Pyreon's `computed()`, wrapped in a `.value` accessor.
|
|
45
48
|
*/
|
|
46
|
-
declare function computed<T>(
|
|
49
|
+
declare function computed<T>(getter: () => T): ComputedRef<T>;
|
|
50
|
+
declare function computed<T>(options: {
|
|
47
51
|
get: () => T;
|
|
48
52
|
set: (value: T) => void;
|
|
49
|
-
}):
|
|
53
|
+
}): WritableComputedRef<T>;
|
|
50
54
|
/**
|
|
51
55
|
* Creates a deeply reactive proxy from a plain object.
|
|
52
56
|
* Backed by Pyreon's `createStore()`.
|
|
@@ -185,5 +189,5 @@ interface App {
|
|
|
185
189
|
*/
|
|
186
190
|
declare function createApp(component: ComponentFn, props?: Props): App;
|
|
187
191
|
//#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 };
|
|
192
|
+
export { ComputedRef, Fragment, Ref, WatchOptions, WritableComputedRef, 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
193
|
//# sourceMappingURL=index2.d.ts.map
|
|
@@ -1 +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
|
|
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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,EAAU,CAAA,EAAG,QAAA,EAAU,CAAA,uBAC5B,OAAA,GAAU,YAAA;;;;;AAlJZ;;;iBAoLgB,WAAA,CAAY,EAAA;;;;;;;iBAaZ,SAAA,CAAU,EAAA;;;;;;;iBAaV,WAAA,CAAY,EAAA;;;AA5K5B;;;iBAqLgB,SAAA,CAAU,EAAA;;;;;iBAQV,aAAA,CAAc,EAAA;;AA/K9B;;;iBA0LgB,eAAA,CAAgB,EAAA;;;;;;iBAWhB,QAAA,CAAA,GAAY,OAAA;AAxL5B;;;;;;;AAAA,iBA+MgB,OAAA,GAAA,CAAW,GAAA,mBAAsB,KAAA,EAAO,CAAA;;;;;;iBAWxC,MAAA,GAAA,CAAU,GAAA,mBAAsB,YAAA,GAAe,CAAA,GAAI,CAAA;AAAA,UAQzD,gBAAA,WAA2B,KAAA,GAAQ,KAAA;EA1M7B;EA4Md,KAAA,GAAQ,KAAA,EAAO,CAAA,YAAa,UAAA,IAAc,UAAA;EA5MvB;EA8MnB,IAAA;AAAA;;;;;;AA/LF;;iBAyMgB,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;EArOkE;EAuO1E,KAAA,CAAM,EAAA,WAAa,OAAA;AAAA;;;;;;;iBASL,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.1.
|
|
3
|
+
"version": "0.1.2",
|
|
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": {
|
|
@@ -35,14 +35,13 @@
|
|
|
35
35
|
"dev": "vl_rolldown_build-watch",
|
|
36
36
|
"test": "vitest run",
|
|
37
37
|
"typecheck": "tsc --noEmit",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"postpack": "bun run ../../scripts/resolve-workspace-deps.ts post"
|
|
38
|
+
"lint": "biome check .",
|
|
39
|
+
"prepublishOnly": "bun run build"
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
43
|
-
"@pyreon/core": "
|
|
44
|
-
"@pyreon/reactivity": "
|
|
45
|
-
"@pyreon/runtime-dom": "
|
|
42
|
+
"@pyreon/core": "workspace:*",
|
|
43
|
+
"@pyreon/reactivity": "workspace:*",
|
|
44
|
+
"@pyreon/runtime-dom": "workspace:*"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@happy-dom/global-registrator": "^20.8.3",
|
package/src/index.ts
CHANGED
|
@@ -120,16 +120,25 @@ export interface ComputedRef<T = unknown> extends Ref<T> {
|
|
|
120
120
|
readonly value: T
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
export interface WritableComputedRef<T = unknown> extends Ref<T> {
|
|
124
|
+
value: T
|
|
125
|
+
}
|
|
126
|
+
|
|
123
127
|
/**
|
|
124
128
|
* Creates a computed ref. Supports both readonly and writable forms:
|
|
125
|
-
* - `computed(() => value)` — readonly
|
|
126
|
-
* - `computed({ get
|
|
129
|
+
* - `computed(() => value)` — readonly ComputedRef
|
|
130
|
+
* - `computed({ get, set })` — writable WritableComputedRef
|
|
127
131
|
*
|
|
128
132
|
* Backed by Pyreon's `computed()`, wrapped in a `.value` accessor.
|
|
129
133
|
*/
|
|
134
|
+
export function computed<T>(getter: () => T): ComputedRef<T>
|
|
135
|
+
export function computed<T>(options: {
|
|
136
|
+
get: () => T
|
|
137
|
+
set: (value: T) => void
|
|
138
|
+
}): WritableComputedRef<T>
|
|
130
139
|
export function computed<T>(
|
|
131
140
|
fnOrOptions: (() => T) | { get: () => T; set: (value: T) => void },
|
|
132
|
-
): ComputedRef<T> {
|
|
141
|
+
): ComputedRef<T> | WritableComputedRef<T> {
|
|
133
142
|
const getter = typeof fnOrOptions === "function" ? fnOrOptions : fnOrOptions.get
|
|
134
143
|
const setter = typeof fnOrOptions === "object" ? fnOrOptions.set : undefined
|
|
135
144
|
const c = pyreonComputed(getter)
|
|
@@ -448,7 +457,7 @@ export function defineComponent<P extends Props = Props>(
|
|
|
448
457
|
/**
|
|
449
458
|
* Re-export of Pyreon's `h()` function for creating VNodes.
|
|
450
459
|
*/
|
|
451
|
-
export { pyreonH as h
|
|
460
|
+
export { Fragment, pyreonH as h }
|
|
452
461
|
|
|
453
462
|
// ─── createApp ────────────────────────────────────────────────────────────────
|
|
454
463
|
|