teamplay 0.4.0-alpha.91 → 0.4.0-alpha.93
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/orm/Compat/README.md +9 -5
- package/orm/Compat/SignalCompat.js +13 -3
- package/orm/privateData.js +11 -0
- package/package.json +2 -2
package/orm/Compat/README.md
CHANGED
|
@@ -407,7 +407,7 @@ Compatibility mode intentionally aligns mutators with Racer. This differs from c
|
|
|
407
407
|
| `set` | Uses deep-diff path (`dataTree.set` + internal `setDiffDeep`). | Path-targeted replace semantics, Racer-like. `undefined` keeps delete semantics. |
|
|
408
408
|
| `setEach` | Not a special API in core mutators. | Per-key compat `set` (not `assign` merge/delete behavior). |
|
|
409
409
|
| `setDiffDeep` | Deep-diff engine (`utils/setDiffDeep.js`). | Recursive Racer-like diff implemented via compat mutators (`set` / `del`) on nested paths. |
|
|
410
|
-
| `setDiff` | N/A as compat shim. |
|
|
410
|
+
| `setDiff` | N/A as compat shim. | Racer-like full replace with exact-equality no-op (`===` / `NaN`). Equivalent objects / arrays still replace. |
|
|
411
411
|
|
|
412
412
|
Migration note: compat behavior is intentionally Racer-aligned and may differ from core mutators.
|
|
413
413
|
Composite compat mutators (`setEach`, `setDiffDeep`) apply updates atomically for Teamplay-scheduled observers via the runtime batch scheduler.
|
|
@@ -474,13 +474,17 @@ await $.users.user1.setDiffDeep({ profile: { name: 'Kate' } }) // deep-diff path
|
|
|
474
474
|
|
|
475
475
|
### setDiff(path?, value)
|
|
476
476
|
|
|
477
|
-
|
|
478
|
-
-
|
|
479
|
-
-
|
|
477
|
+
Racer-like full replace at the target path.
|
|
478
|
+
- No-op only when previous and next values are exactly equal (`===`) or both `NaN`
|
|
479
|
+
- Equivalent objects / arrays still perform a replace
|
|
480
|
+
- Unlike `setDiffDeep`, this is not a recursive diff
|
|
480
481
|
|
|
481
482
|
```js
|
|
483
|
+
await $.users.user1.set('count', 1)
|
|
484
|
+
await $.users.user1.setDiff('count', 1) // no-op
|
|
485
|
+
|
|
482
486
|
await $.users.user1.setDiff({ profile: { name: 'Kate' } })
|
|
483
|
-
await $.users.user1.setDiff('profile', { name: 'Bob' })
|
|
487
|
+
await $.users.user1.setDiff('profile', { name: 'Bob' }) // full replace
|
|
484
488
|
```
|
|
485
489
|
|
|
486
490
|
### setEach(path?, object)
|
|
@@ -289,10 +289,16 @@ class SignalCompat extends Signal {
|
|
|
289
289
|
const forwarded = forwardRef(this, 'setDiff', arguments)
|
|
290
290
|
if (forwarded) return forwarded
|
|
291
291
|
if (arguments.length > 2) throw Error('Signal.setDiff() expects one or two arguments')
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
let segments = []
|
|
293
|
+
if (arguments.length === 2) {
|
|
294
|
+
segments = parseAtSubpath(path, 1, 'Signal.setDiff()')
|
|
295
|
+
} else if (arguments.length === 1) {
|
|
296
|
+
value = path
|
|
294
297
|
}
|
|
295
|
-
|
|
298
|
+
const $target = resolveRelativePathTarget(this, segments)
|
|
299
|
+
const before = $target.peek()
|
|
300
|
+
if (racerEqualCompat(before, value)) return
|
|
301
|
+
return setReplaceOnSignal($target, value)
|
|
296
302
|
}
|
|
297
303
|
|
|
298
304
|
async setEach (path, object) {
|
|
@@ -1090,6 +1096,10 @@ function deepEqualCompat (left, right) {
|
|
|
1090
1096
|
return true
|
|
1091
1097
|
}
|
|
1092
1098
|
|
|
1099
|
+
function racerEqualCompat (left, right) {
|
|
1100
|
+
return left === right || (Number.isNaN(left) && Number.isNaN(right))
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1093
1103
|
function getSignalValueAt ($signal, segments) {
|
|
1094
1104
|
const $target = resolveRelativePathTarget($signal, segments)
|
|
1095
1105
|
return $target.get()
|
package/orm/privateData.js
CHANGED
|
@@ -37,6 +37,7 @@ export function setPrivateData (rootId, logicalSegments, value) {
|
|
|
37
37
|
throw Error('setPrivateData expects private collection segments')
|
|
38
38
|
}
|
|
39
39
|
const context = getRootContext(rootId, true)
|
|
40
|
+
if (!context) return
|
|
40
41
|
const segments = getPrivateDataSegments(logicalSegments)
|
|
41
42
|
_set(segments, value, context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
42
43
|
}
|
|
@@ -46,6 +47,7 @@ export function setReplacePrivateData (rootId, logicalSegments, value) {
|
|
|
46
47
|
throw Error('setReplacePrivateData expects private collection segments')
|
|
47
48
|
}
|
|
48
49
|
const context = getRootContext(rootId, true)
|
|
50
|
+
if (!context) return
|
|
49
51
|
const segments = getPrivateDataSegments(logicalSegments)
|
|
50
52
|
_setReplace(segments, value, context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
51
53
|
}
|
|
@@ -61,46 +63,55 @@ export function delPrivateData (rootId, logicalSegments, options = {}) {
|
|
|
61
63
|
|
|
62
64
|
export function arrayPushPrivateData (rootId, logicalSegments, value) {
|
|
63
65
|
const context = getRequiredPrivateContext(rootId, logicalSegments, 'arrayPushPrivateData')
|
|
66
|
+
if (!context) return
|
|
64
67
|
return _arrayPush(getPrivateDataSegments(logicalSegments), value, context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
export function arrayUnshiftPrivateData (rootId, logicalSegments, value) {
|
|
68
71
|
const context = getRequiredPrivateContext(rootId, logicalSegments, 'arrayUnshiftPrivateData')
|
|
72
|
+
if (!context) return
|
|
69
73
|
return _arrayUnshift(getPrivateDataSegments(logicalSegments), value, context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
export function arrayInsertPrivateData (rootId, logicalSegments, index, values) {
|
|
73
77
|
const context = getRequiredPrivateContext(rootId, logicalSegments, 'arrayInsertPrivateData')
|
|
78
|
+
if (!context) return
|
|
74
79
|
return _arrayInsert(getPrivateDataSegments(logicalSegments), index, values, context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
export function arrayPopPrivateData (rootId, logicalSegments) {
|
|
78
83
|
const context = getRequiredPrivateContext(rootId, logicalSegments, 'arrayPopPrivateData')
|
|
84
|
+
if (!context) return
|
|
79
85
|
return _arrayPop(getPrivateDataSegments(logicalSegments), context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
export function arrayShiftPrivateData (rootId, logicalSegments) {
|
|
83
89
|
const context = getRequiredPrivateContext(rootId, logicalSegments, 'arrayShiftPrivateData')
|
|
90
|
+
if (!context) return
|
|
84
91
|
return _arrayShift(getPrivateDataSegments(logicalSegments), context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
export function arrayRemovePrivateData (rootId, logicalSegments, index, howMany = 1) {
|
|
88
95
|
const context = getRequiredPrivateContext(rootId, logicalSegments, 'arrayRemovePrivateData')
|
|
96
|
+
if (!context) return
|
|
89
97
|
return _arrayRemove(getPrivateDataSegments(logicalSegments), index, howMany, context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
export function arrayMovePrivateData (rootId, logicalSegments, from, to, howMany = 1) {
|
|
93
101
|
const context = getRequiredPrivateContext(rootId, logicalSegments, 'arrayMovePrivateData')
|
|
102
|
+
if (!context) return
|
|
94
103
|
return _arrayMove(getPrivateDataSegments(logicalSegments), from, to, howMany, context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
export function stringInsertPrivateData (rootId, logicalSegments, index, text) {
|
|
98
107
|
const context = getRequiredPrivateContext(rootId, logicalSegments, 'stringInsertPrivateData')
|
|
108
|
+
if (!context) return
|
|
99
109
|
return _stringInsertLocal(getPrivateDataSegments(logicalSegments), index, text, context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
100
110
|
}
|
|
101
111
|
|
|
102
112
|
export function stringRemovePrivateData (rootId, logicalSegments, index, howMany) {
|
|
103
113
|
const context = getRequiredPrivateContext(rootId, logicalSegments, 'stringRemovePrivateData')
|
|
114
|
+
if (!context) return
|
|
104
115
|
return _stringRemoveLocal(getPrivateDataSegments(logicalSegments), index, howMany, context.getPrivateDataRoot(), getModelEventContext(rootId, logicalSegments))
|
|
105
116
|
}
|
|
106
117
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teamplay",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.93",
|
|
4
4
|
"description": "Full-stack signals ORM with multiplayer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
]
|
|
84
84
|
},
|
|
85
85
|
"license": "MIT",
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "286165ff8cf198fe20f8ec1be416c12839f47de8"
|
|
87
87
|
}
|