@rbxts/scribe-vide 2.6.0 → 2.6.1
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/index.d.ts +3 -2
- package/init.luau +32 -6
- package/package.json +2 -2
package/Scribe-source-map.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.6.
|
|
1
|
+
{"version":"2.6.1","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/ScribeVide.luau":{"sourceSha256":"38acf84ef3e9d2facf76e91dfd06844e6f52f498f0aae70f8f5a69f1b5815793","packedSha256":"38acf84ef3e9d2facf76e91dfd06844e6f52f498f0aae70f8f5a69f1b5815793","segments":[[1,1]],"packagePath":"init.luau"}}}
|
package/index.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ import type Scribe from "@rbxts/scribe";
|
|
|
5
5
|
declare function ScribeVide(vide: Pick<typeof Vide, "source">): ScribeVide.Adapter;
|
|
6
6
|
|
|
7
7
|
declare namespace ScribeVide {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
type Adapter =
|
|
9
|
+
/** Tracks an accessor in a source; register the disconnect with vide.cleanup. */
|
|
10
|
+
<T>(this: void, accessor: Scribe.ReadableNode<T>) => LuaTuple<[Vide.Source<T>, () => void]>;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export = ScribeVide;
|
package/init.luau
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
--!strict
|
|
2
2
|
-- Vide adapter. Copy into your game; not part of the Scribe package.
|
|
3
3
|
-- local useScribe = require(path.to.ScribeVide)(vide)
|
|
4
|
-
-- local coins, disconnect = useScribe(Data.Coins)
|
|
4
|
+
-- local coins, disconnect = useScribe(Data.Coins) -- coins: Source<number>
|
|
5
|
+
-- Nullable or any-typed reads need a getter cast: (score :: () -> number?)().
|
|
5
6
|
|
|
6
7
|
export type Disconnect = () -> ()
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export type Readable<T> = {
|
|
10
|
+
--[[
|
|
11
|
+
Returns the current value.
|
|
12
|
+
]]
|
|
13
|
+
read Get: () -> T,
|
|
14
|
+
--[[
|
|
15
|
+
Runs now and on each change; returns a disconnect function.
|
|
16
|
+
]]
|
|
17
|
+
read Observe: (callback: (value: T) -> ()) -> Disconnect,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
-- Matches Vide's getter/setter overloads.
|
|
21
|
+
export type Source<T> = (() -> T) & ((value: T) -> T)
|
|
22
|
+
|
|
23
|
+
export type Vide = {
|
|
24
|
+
read source: (value: any) -> any,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
--[[
|
|
28
|
+
Creates a Vide adapter for Scribe accessors.
|
|
29
|
+
]]
|
|
30
|
+
return function(vide: Vide)
|
|
31
|
+
--[[
|
|
32
|
+
Tracks an accessor; pass the returned disconnect to vide.cleanup.
|
|
33
|
+
]]
|
|
34
|
+
return function<T>(accessor: Readable<T>): (Source<T>, Disconnect)
|
|
35
|
+
local source: Source<T> = vide.source(accessor.Get())
|
|
36
|
+
local disconnect = accessor.Observe(function(value)
|
|
37
|
+
source(value)
|
|
38
|
+
end)
|
|
13
39
|
return source, disconnect
|
|
14
40
|
end
|
|
15
41
|
end
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rbxts/scribe-vide",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Optional vide 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.6.
|
|
15
|
+
"@rbxts/scribe": "^2.6.1",
|
|
16
16
|
"@rbxts/vide": "^0.6.1"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|