@rbxts/scribe-fusion 2.5.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/LICENSE CHANGED
@@ -1,21 +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.
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.
@@ -1 +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/ScribeFusion.luau":{"sourceSha256":"c7816956ceab0c26674b2282c8a56e47f46647948683a6a97c3ec738c246aae6","packedSha256":"7608f7e0848bbf6579e065b06f8f59a97a494183296bd22f92ff30bd7d447aac","segments":[[1,1]],"packagePath":"init.luau"}}}
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/ScribeFusion.luau":{"sourceSha256":"7aacc7d1a954149f7830323b8c7d76264ffa07df2783e78a63988c0255923455","packedSha256":"7aacc7d1a954149f7830323b8c7d76264ffa07df2783e78a63988c0255923455","segments":[[1,1]],"packagePath":"init.luau"}}}
package/index.d.ts CHANGED
@@ -1,41 +1,50 @@
1
- import type Scribe from "@rbxts/scribe";
2
-
3
- /** Fusion 0.2: call the returned disconnect when the UI is destroyed. */
4
- declare function ScribeFusion(fusion: ScribeFusion.LegacyFramework): ScribeFusion.Adapter;
5
- /** Fusion 0.3: the disconnect is also registered in the supplied cleanup scope. */
6
- declare function ScribeFusion<Scope extends unknown[], Framework extends ScribeFusion.ScopedFramework<Scope>>(
7
- fusion: Framework,
8
- scope: Scope,
9
- ): ScribeFusion.ScopedAdapter<ReturnType<Framework["Value"]>>;
10
-
11
- declare namespace ScribeFusion {
12
- type Adapter = <T>(this: void, accessor: Scribe.ReadableNode<T>) => LuaTuple<[LegacyValue<T>, () => void]>;
13
- type ScopedAdapter<Value extends ScopedValue<unknown> = ScopedValue<unknown>> = <T>(
14
- this: void,
15
- accessor: Scribe.ReadableNode<T>,
16
- ) => LuaTuple<[Omit<Value, "set" | "_EXTREMELY_DANGEROUS_usedAsValue"> & ScopedValue<T>, () => void]>;
17
- /** Structurally compatible with @rbxts/fusion 0.2's Value<T>. */
18
- interface LegacyValue<T> {
19
- readonly type: "State";
20
- readonly kind: "Value";
21
- get(asDependency?: boolean): T;
22
- set(value: T, force?: boolean): void;
23
- }
24
- interface LegacyFramework {
25
- readonly Value: <T>(this: void, initialValue: T) => LegacyValue<T>;
26
- }
27
- /** Public surface of a Fusion 0.3 Value. Read it through your framework's peek/use. */
28
- interface ScopedValue<T> {
29
- readonly type: "State";
30
- readonly kind: "Value";
31
- /** @internal Present for compatibility with Fusion's StateObject<T> inference. Do not read directly. */
32
- readonly _EXTREMELY_DANGEROUS_usedAsValue: T;
33
- set(value: T): void;
34
- }
35
- /** The 0.3 package is supplied by the caller; no separate framework is bundled. */
36
- interface ScopedFramework<Scope> {
37
- readonly Value: <T>(this: void, scope: Scope, initialValue: T) => ScopedValue<T>;
38
- }
39
- }
40
-
41
- export = ScribeFusion;
1
+ import type Scribe from "@rbxts/scribe";
2
+
3
+ /** Fusion 0.2: call the returned disconnect when the UI is destroyed. */
4
+ declare function ScribeFusion(fusion: ScribeFusion.LegacyFramework): ScribeFusion.Adapter;
5
+ /** Fusion 0.3: the disconnect is also registered in the supplied cleanup scope. */
6
+ declare function ScribeFusion<Scope extends unknown[], Framework extends ScribeFusion.ScopedFramework<Scope>>(
7
+ fusion: Framework,
8
+ scope: Scope,
9
+ ): ScribeFusion.ScopedAdapter<ReturnType<Framework["Value"]>>;
10
+
11
+ declare namespace ScribeFusion {
12
+ type Adapter =
13
+ /** Tracks an accessor in a Fusion value; disconnect when finished. */
14
+ <T>(this: void, accessor: Scribe.ReadableNode<T>) => LuaTuple<[LegacyValue<T>, () => void]>;
15
+ type ScopedAdapter<Value extends ScopedValue<unknown> = ScopedValue<unknown>> =
16
+ /** Tracks an accessor in a Fusion value and registers scope cleanup. */
17
+ <T>(
18
+ this: void,
19
+ accessor: Scribe.ReadableNode<T>,
20
+ ) => LuaTuple<[Omit<Value, "set" | "_EXTREMELY_DANGEROUS_usedAsValue"> & ScopedValue<T>, () => void]>;
21
+ /** Structurally compatible with @rbxts/fusion 0.2's Value<T>. */
22
+ interface LegacyValue<T> {
23
+ readonly type: "State";
24
+ readonly kind: "Value";
25
+ /** Returns the current Fusion value. */
26
+ get(asDependency?: boolean): T;
27
+ /** Updates the Fusion value without writing to Scribe. */
28
+ set(value: T, force?: boolean): void;
29
+ }
30
+ interface LegacyFramework {
31
+ /** Creates a Fusion value with the initial value. */
32
+ readonly Value: <T>(this: void, initialValue: T) => LegacyValue<T>;
33
+ }
34
+ /** Public surface of a Fusion 0.3 Value. Read it through your framework's peek/use. */
35
+ interface ScopedValue<T> {
36
+ readonly type: "State";
37
+ readonly kind: "Value";
38
+ /** @internal Present for compatibility with Fusion's StateObject<T> inference. Do not read directly. */
39
+ readonly _EXTREMELY_DANGEROUS_usedAsValue: T;
40
+ /** Updates the Fusion value without writing to Scribe. */
41
+ set(value: T): void;
42
+ }
43
+ /** The 0.3 package is supplied by the caller; no separate framework is bundled. */
44
+ interface ScopedFramework<Scope> {
45
+ /** Creates a Fusion value owned by the supplied scope. */
46
+ readonly Value: <T>(this: void, scope: Scope, initialValue: T) => ScopedValue<T>;
47
+ }
48
+ }
49
+
50
+ export = ScribeFusion;
package/init.luau CHANGED
@@ -2,18 +2,38 @@
2
2
  -- Fusion adapter. Copy into your game; not part of the Scribe package.
3
3
  -- local useScribe = require(path.to.ScribeFusion)(Fusion, scope) -- 0.3
4
4
  -- local useScribe = require(path.to.ScribeFusion)(Fusion) -- 0.2
5
- -- local coins, disconnect = useScribe(Data.Coins)
6
- -- With a scope the disconnect is also registered in it, so doCleanup(scope) runs it.
5
+ -- local coins: Fusion.Value<number>, disconnect = useScribe(Data.Coins)
6
+ -- Annotate the value with your Fusion version's type.
7
7
 
8
8
  export type Disconnect = () -> ()
9
9
 
10
- --- `scope` selects the calling convention: pass it on 0.3, omit it on 0.2.
11
- return function(Fusion: any, scope: any?)
12
- --- A Value tracking one accessor. The disconnect is returned either way; with a
13
- --- scope it is registered there too, and a second call is a no-op.
14
- return function(accessor: any): (any, Disconnect)
10
+ export type Readable<T> = {
11
+ --[[
12
+ Returns the current value.
13
+ ]]
14
+ read Get: () -> T,
15
+ --[[
16
+ Runs now and on each change; returns a disconnect function.
17
+ ]]
18
+ read Observe: (callback: (value: T) -> ()) -> Disconnect,
19
+ }
20
+
21
+ export type Fusion = {
22
+ read Value: (...any) -> any,
23
+ }
24
+
25
+ export type Adapter = <T>(accessor: Readable<T>) -> (any, Disconnect)
26
+
27
+ --[[
28
+ Creates a Fusion adapter; pass a scope for Fusion 0.3.
29
+ ]]
30
+ return function(Fusion: Fusion, scope: { any }?): Adapter
31
+ --[[
32
+ Tracks an accessor and registers cleanup with the supplied scope.
33
+ ]]
34
+ return function<T>(accessor: Readable<T>): (any, Disconnect)
15
35
  local value = if scope ~= nil then Fusion.Value(scope, accessor.Get()) else Fusion.Value(accessor.Get())
16
- -- Observe, not Changed: it delivers the current value before returning.
36
+ -- Observe delivers the current value immediately.
17
37
  local disconnect = accessor.Observe(function(new)
18
38
  value:set(new)
19
39
  end)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/scribe-fusion",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
4
4
  "description": "Optional fusion 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.5.0",
15
+ "@rbxts/scribe": "^2.6.1",
16
16
  "@rbxts/fusion": "^0.2.0"
17
17
  },
18
18
  "peerDependenciesMeta": {