@rbxts/scribe-fusion 2.6.0 → 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.
@@ -1 +1 @@
1
- {"version":"2.6.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":"7608f7e0848bbf6579e065b06f8f59a97a494183296bd22f92ff30bd7d447aac","packedSha256":"7608f7e0848bbf6579e065b06f8f59a97a494183296bd22f92ff30bd7d447aac","segments":[[1,1]],"packagePath":"init.luau"}}}
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/ScribeFusion.luau":{"sourceSha256":"7aacc7d1a954149f7830323b8c7d76264ffa07df2783e78a63988c0255923455","packedSha256":"7aacc7d1a954149f7830323b8c7d76264ffa07df2783e78a63988c0255923455","segments":[[1,1]],"packagePath":"init.luau"}}}
package/index.d.ts CHANGED
@@ -9,8 +9,12 @@ declare function ScribeFusion<Scope extends unknown[], Framework extends ScribeF
9
9
  ): ScribeFusion.ScopedAdapter<ReturnType<Framework["Value"]>>;
10
10
 
11
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>(
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>(
14
18
  this: void,
15
19
  accessor: Scribe.ReadableNode<T>,
16
20
  ) => LuaTuple<[Omit<Value, "set" | "_EXTREMELY_DANGEROUS_usedAsValue"> & ScopedValue<T>, () => void]>;
@@ -18,10 +22,13 @@ declare namespace ScribeFusion {
18
22
  interface LegacyValue<T> {
19
23
  readonly type: "State";
20
24
  readonly kind: "Value";
25
+ /** Returns the current Fusion value. */
21
26
  get(asDependency?: boolean): T;
27
+ /** Updates the Fusion value without writing to Scribe. */
22
28
  set(value: T, force?: boolean): void;
23
29
  }
24
30
  interface LegacyFramework {
31
+ /** Creates a Fusion value with the initial value. */
25
32
  readonly Value: <T>(this: void, initialValue: T) => LegacyValue<T>;
26
33
  }
27
34
  /** Public surface of a Fusion 0.3 Value. Read it through your framework's peek/use. */
@@ -30,10 +37,12 @@ declare namespace ScribeFusion {
30
37
  readonly kind: "Value";
31
38
  /** @internal Present for compatibility with Fusion's StateObject<T> inference. Do not read directly. */
32
39
  readonly _EXTREMELY_DANGEROUS_usedAsValue: T;
40
+ /** Updates the Fusion value without writing to Scribe. */
33
41
  set(value: T): void;
34
42
  }
35
43
  /** The 0.3 package is supplied by the caller; no separate framework is bundled. */
36
44
  interface ScopedFramework<Scope> {
45
+ /** Creates a Fusion value owned by the supplied scope. */
37
46
  readonly Value: <T>(this: void, scope: Scope, initialValue: T) => ScopedValue<T>;
38
47
  }
39
48
  }
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.6.0",
3
+ "version": "2.7.0",
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.6.0",
15
+ "@rbxts/scribe": "^2.7.0",
16
16
  "@rbxts/fusion": "^0.2.0"
17
17
  },
18
18
  "peerDependenciesMeta": {