@rbxts/scribe-react 2.6.1 → 2.7.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/Scribe-source-map.json +1 -1
- package/init.luau +10 -3
- package/package.json +2 -2
package/Scribe-source-map.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.
|
|
1
|
+
{"version":"2.7.0","format":1,"description":"Segments are [packedLine, sourceLine]. Use the last segment at or before the packed line, then add its line offset.","files":{"addons/ui/ScribeReact.luau":{"sourceSha256":"2331361ab5d4e08022c03adc75e8cedc7c13976f0ecd81afd810b969f858378a","packedSha256":"2331361ab5d4e08022c03adc75e8cedc7c13976f0ecd81afd810b969f858378a","segments":[[1,1]],"packagePath":"init.luau"}}}
|
package/init.luau
CHANGED
|
@@ -55,13 +55,20 @@ export type Adapter = {
|
|
|
55
55
|
Creates React hooks for Scribe accessors.
|
|
56
56
|
]]
|
|
57
57
|
return function(React: React): Adapter
|
|
58
|
+
-- Give React a new reference when a container changes in place.
|
|
59
|
+
local function snapshot<T>(value: T): T
|
|
60
|
+
return if type(value) == "table" then table.clone(value :: any) else value
|
|
61
|
+
end
|
|
62
|
+
|
|
58
63
|
local function useScribe<T>(accessor: Readable<T>): T
|
|
59
|
-
local state: T, setValue: (T) -> () = React.useState(
|
|
64
|
+
local state: T, setValue: (T) -> () = React.useState(function()
|
|
65
|
+
return snapshot(accessor.Get())
|
|
66
|
+
end)
|
|
60
67
|
React.useEffect(function()
|
|
61
68
|
-- Catch writes between render and the effect.
|
|
62
|
-
setValue(accessor.Get())
|
|
69
|
+
setValue(snapshot(accessor.Get()))
|
|
63
70
|
return accessor.Changed(function(new)
|
|
64
|
-
setValue(new)
|
|
71
|
+
setValue(snapshot(new))
|
|
65
72
|
end)
|
|
66
73
|
end, { accessor })
|
|
67
74
|
return state
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/scribe-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Optional react addon for Scribe",
|
|
5
5
|
"main": "init.luau",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"homepage": "https://scribe.ericplane.dev/",
|
|
13
13
|
"author": "ericplane",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@rbxts/scribe": "^2.
|
|
15
|
+
"@rbxts/scribe": "^2.7.0",
|
|
16
16
|
"@rbxts/react": "^17.0.0 || ^17.3.7-ts.2"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|