@re-reduced/signals 0.2.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/dist/index.cjs ADDED
@@ -0,0 +1,18 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _preact_signals_core = require("@preact/signals-core");
3
+ //#region src/index.ts
4
+ /**
5
+ * @re-reduced/signals — façade over the signal engine (ADR-0001).
6
+ *
7
+ * Core and adapters program against THIS, never the engine directly, so the
8
+ * engine is swappable. Default engine: @preact/signals-core (ADR-0001).
9
+ */
10
+ const signal = (value) => (0, _preact_signals_core.signal)(value);
11
+ const computed = (fn) => (0, _preact_signals_core.computed)(fn);
12
+ const effect = (fn) => (0, _preact_signals_core.effect)(fn);
13
+ const batch = (fn) => (0, _preact_signals_core.batch)(fn);
14
+ //#endregion
15
+ exports.batch = batch;
16
+ exports.computed = computed;
17
+ exports.effect = effect;
18
+ exports.signal = signal;
@@ -0,0 +1,15 @@
1
+ //#region src/index.d.ts
2
+ interface ReadSignal<T> {
3
+ readonly value: T;
4
+ peek(): T;
5
+ subscribe(run: (value: T) => void): () => void;
6
+ }
7
+ interface WriteSignal<T> extends ReadSignal<T> {
8
+ value: T;
9
+ }
10
+ declare const signal: <T>(value: T) => WriteSignal<T>;
11
+ declare const computed: <T>(fn: () => T) => ReadSignal<T>;
12
+ declare const effect: (fn: () => void | (() => void)) => (() => void);
13
+ declare const batch: <T>(fn: () => T) => T;
14
+ //#endregion
15
+ export { ReadSignal, WriteSignal, batch, computed, effect, signal };
@@ -0,0 +1,15 @@
1
+ //#region src/index.d.ts
2
+ interface ReadSignal<T> {
3
+ readonly value: T;
4
+ peek(): T;
5
+ subscribe(run: (value: T) => void): () => void;
6
+ }
7
+ interface WriteSignal<T> extends ReadSignal<T> {
8
+ value: T;
9
+ }
10
+ declare const signal: <T>(value: T) => WriteSignal<T>;
11
+ declare const computed: <T>(fn: () => T) => ReadSignal<T>;
12
+ declare const effect: (fn: () => void | (() => void)) => (() => void);
13
+ declare const batch: <T>(fn: () => T) => T;
14
+ //#endregion
15
+ export { ReadSignal, WriteSignal, batch, computed, effect, signal };
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { batch as batch$1, computed as computed$1, effect as effect$1, signal as signal$1 } from "@preact/signals-core";
2
+ //#region src/index.ts
3
+ /**
4
+ * @re-reduced/signals — façade over the signal engine (ADR-0001).
5
+ *
6
+ * Core and adapters program against THIS, never the engine directly, so the
7
+ * engine is swappable. Default engine: @preact/signals-core (ADR-0001).
8
+ */
9
+ const signal = (value) => signal$1(value);
10
+ const computed = (fn) => computed$1(fn);
11
+ const effect = (fn) => effect$1(fn);
12
+ const batch = (fn) => batch$1(fn);
13
+ //#endregion
14
+ export { batch, computed, effect, signal };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@re-reduced/signals",
3
+ "version": "0.2.0",
4
+ "description": "Swappable signal-engine façade for re-reduced.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/alanrsoares/re-reduced.git",
8
+ "directory": "packages/signals"
9
+ },
10
+ "type": "module",
11
+ "main": "./src/index.ts",
12
+ "types": "./src/index.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./src/index.ts",
16
+ "default": "./src/index.ts"
17
+ }
18
+ },
19
+ "publishConfig": {
20
+ "main": "./dist/index.js",
21
+ "module": "./dist/index.mjs",
22
+ "types": "./dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.mjs",
27
+ "require": "./dist/index.js"
28
+ }
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "src"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsdown src/index.ts --format esm,cjs --dts --clean",
37
+ "typecheck": "tsc -p tsconfig.json --noEmit"
38
+ },
39
+ "license": "MIT",
40
+ "peerDependencies": {
41
+ "typescript": ">=6"
42
+ },
43
+ "dependencies": {
44
+ "@preact/signals-core": "^1.14.3"
45
+ }
46
+ }
package/src/index.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @re-reduced/signals — façade over the signal engine (ADR-0001).
3
+ *
4
+ * Core and adapters program against THIS, never the engine directly, so the
5
+ * engine is swappable. Default engine: @preact/signals-core (ADR-0001).
6
+ */
7
+ import {
8
+ batch as _batch,
9
+ computed as _computed,
10
+ effect as _effect,
11
+ signal as _signal,
12
+ } from "@preact/signals-core";
13
+
14
+ export interface ReadSignal<T> {
15
+ readonly value: T;
16
+ peek(): T;
17
+ subscribe(run: (value: T) => void): () => void;
18
+ }
19
+ export interface WriteSignal<T> extends ReadSignal<T> {
20
+ value: T;
21
+ }
22
+
23
+ export const signal = <T>(value: T): WriteSignal<T> => _signal(value);
24
+ export const computed = <T>(fn: () => T): ReadSignal<T> => _computed(fn);
25
+ export const effect = (fn: () => void | (() => void)): (() => void) =>
26
+ _effect(fn);
27
+ export const batch = <T>(fn: () => T): T => _batch(fn);