@rbxts/scribe-react 2.5.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/NOTICE +21 -0
- package/README.md +5 -0
- package/Scribe-source-map.json +1 -0
- package/index.d.ts +16 -0
- package/init.luau +41 -0
- package/package.json +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ericplane
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Scribe
|
|
2
|
+
Copyright (c) 2026 ericplane
|
|
3
|
+
Licensed under the MIT License (see LICENSE).
|
|
4
|
+
|
|
5
|
+
This product bundles a modified copy of ProfileStore v1.0.3:
|
|
6
|
+
|
|
7
|
+
ProfileStore
|
|
8
|
+
Copyright (c) loleris / MAD STUDIO
|
|
9
|
+
https://github.com/MadStudioRoblox/ProfileStore
|
|
10
|
+
Licensed under the Apache License, Version 2.0.
|
|
11
|
+
|
|
12
|
+
The bundled copy lives at src/Internal/Store/ProfileStore.luau and HAS BEEN
|
|
13
|
+
MODIFIED. Every modification is marked `SCRIBE PATCH` in that file and summarised
|
|
14
|
+
in its header. A copy of the Apache License, Version 2.0 is included at
|
|
15
|
+
licenses/ProfileStore-Apache-2.0.txt.
|
|
16
|
+
|
|
17
|
+
The licence text is kept OUTSIDE src/ on purpose. Everything under src/ is packed
|
|
18
|
+
into the released .rbxm, where a plain text file has no place and whose contents
|
|
19
|
+
Roblox scans for off-platform links -- and the licence is full of them. Attribution
|
|
20
|
+
travels with the code in the file header, which is what Apache-2.0 section 4
|
|
21
|
+
actually asks for; the full text travels with the source package.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"2.5.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":"129371347fee37556b753b9ba8c1ba7a20f4a5764c595b505cd53ec3d6b8eb0b","packedSha256":"6e85c1c51649d96cd3b8b3106766f782f1373103ffad31a5e1cbfea632127929","segments":[[1,1]],"packagePath":"init.luau"}}}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React = require("@rbxts/react");
|
|
2
|
+
import type Scribe from "@rbxts/scribe";
|
|
3
|
+
|
|
4
|
+
/** Bind the shared Luau adapter to the React installation used by your game. */
|
|
5
|
+
declare function ScribeReact(react: Pick<typeof React, "useState" | "useEffect" | "useBinding">): ScribeReact.Adapter;
|
|
6
|
+
|
|
7
|
+
declare namespace ScribeReact {
|
|
8
|
+
interface Adapter {
|
|
9
|
+
/** Use inside a component. Changes re-render the component. */
|
|
10
|
+
readonly useScribe: <T>(this: void, accessor: Scribe.ReadableNode<T>) => T;
|
|
11
|
+
/** Use inside a component. Changes update the binding without a re-render. */
|
|
12
|
+
readonly useScribeBinding: <T>(this: void, accessor: Scribe.ReadableNode<T>) => React.Binding<T>;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export = ScribeReact;
|
package/init.luau
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
--!strict
|
|
2
|
+
-- React adapter. Copy into your game; not part of the Scribe package.
|
|
3
|
+
-- local Scribe = require(path.to.ScribeReact)(React)
|
|
4
|
+
-- local coins = Scribe.useScribe(Data.Coins) -- re-renders
|
|
5
|
+
-- local coins = Scribe.useScribeBinding(Data.Coins) -- property only
|
|
6
|
+
--
|
|
7
|
+
-- useState + useEffect, not useSyncExternalStore: that is React 18 and jsdotlua
|
|
8
|
+
-- React 17.2.1 does not export it.
|
|
9
|
+
|
|
10
|
+
return function(React: any)
|
|
11
|
+
local Adapter = {}
|
|
12
|
+
|
|
13
|
+
--- State tracking one accessor. Re-renders on every change.
|
|
14
|
+
function Adapter.useScribe(accessor: any): any
|
|
15
|
+
local value, setValue = React.useState(accessor.Get)
|
|
16
|
+
React.useEffect(function()
|
|
17
|
+
-- Re-read before subscribing: a write landing between render and effect is
|
|
18
|
+
-- otherwise missed, and the UI sits on the stale first value forever.
|
|
19
|
+
setValue(accessor.Get())
|
|
20
|
+
return accessor.Changed(function(new)
|
|
21
|
+
setValue(new)
|
|
22
|
+
end)
|
|
23
|
+
end, { accessor })
|
|
24
|
+
return value
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
--- A binding instead of state: updates the property without re-rendering. Prefer it
|
|
28
|
+
--- for a value that only feeds Text or Size.
|
|
29
|
+
function Adapter.useScribeBinding(accessor: any): any
|
|
30
|
+
local binding, setBinding = React.useBinding(accessor.Get())
|
|
31
|
+
React.useEffect(function()
|
|
32
|
+
setBinding(accessor.Get())
|
|
33
|
+
return accessor.Changed(function(new)
|
|
34
|
+
setBinding(new)
|
|
35
|
+
end)
|
|
36
|
+
end, { accessor })
|
|
37
|
+
return binding
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
return Adapter
|
|
41
|
+
end
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rbxts/scribe-react",
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "Optional react addon for Scribe",
|
|
5
|
+
"main": "init.luau",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/ericplane/Scribe.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://scribe.ericplane.dev/",
|
|
13
|
+
"author": "ericplane",
|
|
14
|
+
"peerDependencies": {
|
|
15
|
+
"@rbxts/scribe": "^2.5.0",
|
|
16
|
+
"@rbxts/react": "^17.0.0 || ^17.3.7-ts.2"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
}
|
|
21
|
+
}
|