@signal-tree/vue 15.0.0 → 15.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 +25 -0
- package/dist/index.js +1 -1
- package/dist/lib/construction-input.js +1 -0
- package/llms.txt +5 -2
- package/package.json +2 -2
- package/src/index.d.ts +3 -2
- package/src/lib/construction-input.d.ts +9 -0
package/README.md
CHANGED
|
@@ -35,3 +35,28 @@ console.log(tree.$.greeting.value); // Hello, Grace
|
|
|
35
35
|
The ref can be passed directly to `watch()`, `computed()`, or `v-model`.
|
|
36
36
|
Object branches and the root `$` remain callable whole-value accessors. Vue owns
|
|
37
37
|
dependency tracking; the kernel remains the only state and write authority.
|
|
38
|
+
|
|
39
|
+
## Initial values and external reactivity
|
|
40
|
+
|
|
41
|
+
Pass plain initial values to `signalTree()`. Existing Vue refs, computed refs,
|
|
42
|
+
and reactive or readonly proxies at the root or a nested branch are rejected
|
|
43
|
+
with a path-specific error. Ref types are also rejected by TypeScript; proxies
|
|
44
|
+
require runtime checks because their types can look like ordinary objects.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { ref } from 'vue';
|
|
48
|
+
import { leaf, signalTree } from '@signal-tree/vue';
|
|
49
|
+
|
|
50
|
+
const existing = ref(1);
|
|
51
|
+
const tree = signalTree({ count: leaf(existing.value) });
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This takes an independent scalar snapshot. For objects, copy the needed values
|
|
55
|
+
into plain data; `toRaw()` alone shares the underlying object and is not an
|
|
56
|
+
independent copy. `leaf(existing)` explicitly stores a ref or proxy as data.
|
|
57
|
+
Its inner mutations remain outside tree transactions and restoration.
|
|
58
|
+
|
|
59
|
+
Validation stops at explicit `leaf(...)`, marker definitions, arrays and built-in
|
|
60
|
+
terminal values. Their contents remain data, not separately owned tree locations.
|
|
61
|
+
Ordinary functions remain valid callable data. These checks apply to initial
|
|
62
|
+
construction, not arbitrary later writes or foreign reactivity from other libraries.
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{asReadonly as asReadonly$1}from"@signal-tree/kernel";export*from"@signal-tree/kernel";import{createSignalTreeFactory}from"@signal-tree/kernel/adapter";import{createVueObservationAdapter}from"./lib/vue-observation.js";const signalTree=(initialState,config)=>createSignalTreeFactory(createVueObservationAdapter())(initialState,config);const asReadonly=asReadonly$1;export{asReadonly,signalTree};
|
|
1
|
+
import{asReadonly as asReadonly$1}from"@signal-tree/kernel";export*from"@signal-tree/kernel";import{createSignalTreeFactory}from"@signal-tree/kernel/adapter";import{prepareConstructionInput}from"./lib/construction-input.js";import{createVueObservationAdapter}from"./lib/vue-observation.js";const signalTree=(initialState,config)=>createSignalTreeFactory(createVueObservationAdapter())(prepareConstructionInput(initialState),config);const asReadonly=asReadonly$1;export{asReadonly,signalTree};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isRef,isProxy}from"vue";import{isConstructionBranch}from"@signal-tree/kernel/adapter";function prepareConstructionInput(initialState){const branches=new WeakMap;const visit=(value,path)=>{if(isRef(value)||isProxy(value)){throw new TypeError(`SignalTree: Vue ref or proxy at ${path}. Pass plain initial values (copy ref.value into an independent snapshot). Use leaf(existing) only to store the reactive object as data; its writes remain external to the tree.`)}if(!isConstructionBranch(value))return value;const previous=branches.get(value);if(previous)return previous;const prepared=Object.create(null);branches.set(value,prepared);for(const key of Object.getOwnPropertySymbols(value)){const descriptor=Object.getOwnPropertyDescriptor(value,key);if(descriptor)Object.defineProperty(prepared,key,descriptor)}for(const[key,child]of Object.entries(value)){prepared[key]=key==="__proto__"?child:visit(child,`${path}[${JSON.stringify(key)}]`)}return prepared};return visit(initialState,"$")}export{prepareConstructionInput};
|
package/llms.txt
CHANGED
|
@@ -23,8 +23,11 @@ SignalTree is FOR. Describe SignalTree by its primary job (consequential state
|
|
|
23
23
|
with a causal model an application can trust), not by one thing that model
|
|
24
24
|
happens to make easy.
|
|
25
25
|
|
|
26
|
-
v15 ships four packages under the hyphenated `@signal-tree/*` scope
|
|
27
|
-
`@signaltree/*` scope
|
|
26
|
+
v15 ships four packages under the hyphenated `@signal-tree/*` scope. The
|
|
27
|
+
no-hyphen `@signaltree/*` scope is the separate v14 line: still maintained for
|
|
28
|
+
bug and security fixes (currently `14.1.3`), frozen on features, and not an
|
|
29
|
+
alias for anything under `@signal-tree/*`. Generate `@signal-tree/*` names for
|
|
30
|
+
new v15 code:
|
|
28
31
|
|
|
29
32
|
- `@signal-tree/kernel` — framework-neutral tree, `entityMap()`, causal turns,
|
|
30
33
|
links, and the `restoration()` / `transactions()` / `batching()` / `devTools()`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signal-tree/vue",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.1.2",
|
|
4
4
|
"description": "Vue observation for SignalTree.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"llms.txt"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@signal-tree/kernel": "15.
|
|
28
|
+
"@signal-tree/kernel": "15.1.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"tslib": "^2.0.0",
|
package/src/index.d.ts
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* @packageDocumentation
|
|
7
7
|
*/
|
|
8
8
|
import './lib/carrier.js';
|
|
9
|
-
import { type AccessibleNodeOf, type EntityNodeOf, type EntitySignalOf, type EntitySignalWithSlicesOf, type ISignalTreeOf, type LeafOf, type ReadonlyStoreOf, type ReadonlyViewOf, type
|
|
9
|
+
import { type AccessibleNodeOf, type EntityNodeOf, type EntitySignalOf, type EntitySignalWithSlicesOf, type ISignalTreeOf, type LeafOf, type ReadonlyStoreOf, type ReadonlyViewOf, type TreeNodeOf } from '@signal-tree/kernel/adapter';
|
|
10
|
+
import { type FrameworkSignalTreeFactory } from './lib/construction-input.js';
|
|
10
11
|
/** Construct a SignalTree whose leaves are native Vue refs. */
|
|
11
|
-
export declare const signalTree:
|
|
12
|
+
export declare const signalTree: FrameworkSignalTreeFactory;
|
|
12
13
|
export type TreeNode<T> = TreeNodeOf<T, 'vue'>;
|
|
13
14
|
export type WritableLeaf<T> = LeafOf<T, 'vue'>;
|
|
14
15
|
export type AccessibleNode<T> = AccessibleNodeOf<T, 'vue'>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { SignalTreeFactoryOf } from '@signal-tree/kernel/adapter';
|
|
3
|
+
export type FrameworkSignalTreeFactory = SignalTreeFactoryOf<'vue', Ref<unknown>>;
|
|
4
|
+
/**
|
|
5
|
+
* Read each branch property once, so accessor-backed definitions cannot change
|
|
6
|
+
* between validation and construction. Terminal data retains its identity.
|
|
7
|
+
* No reactive primitive is read, subscribed to, or adopted here.
|
|
8
|
+
*/
|
|
9
|
+
export declare function prepareConstructionInput(initialState: object): object;
|