@atolljs/solidjs 0.1.12 → 0.1.14

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.
@@ -0,0 +1,25 @@
1
+ import { type Accessor } from 'solid-js';
2
+ import type { AsyncTask, ObservableValue, PathConnector, SharedMemory, SharedSpec, SpecPath, SliceOptions, TaskSnapshot } from '@atolljs/core';
3
+ /** Wrap any sdk ObservableValue (task snapshot, field observable) in an Accessor. */
4
+ export declare function createObservable<T>(source: ObservableValue<T>): Accessor<T>;
5
+ /**
6
+ * Bind one shared-memory field to an Accessor. Stays `undefined` until the
7
+ * contract is bound and the field written; updates on every write.
8
+ */
9
+ export declare function createSharedValue<S extends SharedSpec, K extends SpecPath<S>>(memory: SharedMemory<S>, key: K): Accessor<(PathConnector<S, K> extends {
10
+ read(): infer T;
11
+ } ? T : never) | undefined>;
12
+ export declare function createSharedValue<S extends SharedSpec, K extends SpecPath<S>, Sel>(memory: SharedMemory<S>, key: K, select: (value: PathConnector<S, K> extends {
13
+ read(): infer T;
14
+ } ? T : never) => Sel, options?: SliceOptions<Sel>): Accessor<Sel | undefined>;
15
+ /** Bind an AsyncTask or plain async fn (via toTask): `{ state }` is an Accessor of its snapshot; `run`/`runOnce` trigger it. */
16
+ export declare function createTask<R>(source: AsyncTask<void, R> | (() => Promise<R>)): {
17
+ state: Accessor<TaskSnapshot<R>>;
18
+ run: AsyncTask<void, R>['run'];
19
+ runOnce: AsyncTask<void, R>['runOnce'];
20
+ };
21
+ export declare function createTask<A, R>(source: AsyncTask<A, R> | ((input: A) => Promise<R>)): {
22
+ state: Accessor<TaskSnapshot<R>>;
23
+ run: AsyncTask<A, R>['run'];
24
+ runOnce: AsyncTask<A, R>['runOnce'];
25
+ };
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ // src/index.ts
2
+ import { createSignal, onCleanup } from "solid-js";
3
+ import { observe, toTask } from "@atolljs/core";
4
+ function createObservable(source) {
5
+ const [value, setValue] = createSignal(source.get(), { equals: false });
6
+ onCleanup(source.subscribe((v) => setValue(() => v)));
7
+ return value;
8
+ }
9
+ function createSharedValue(memory, key, select, options) {
10
+ return createObservable(observe(memory, key, select, options));
11
+ }
12
+ function createTask(source) {
13
+ const task = toTask(source);
14
+ return { state: createObservable(task), run: task.run, runOnce: task.runOnce };
15
+ }
16
+ export {
17
+ createObservable,
18
+ createSharedValue,
19
+ createTask
20
+ };
package/package.json CHANGED
@@ -1,21 +1,28 @@
1
1
  {
2
2
  "name": "@atolljs/solidjs",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "SolidJS bindings — createObservable, createSharedValue, createTask",
5
5
  "homepage": "https://jwhenry3.github.io/atolljs/consumer/quickstart/",
6
6
  "type": "module",
7
7
  "exports": {
8
- ".": "./src/index.ts"
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
9
12
  },
10
13
  "files": [
11
- "src"
14
+ "src",
15
+ "dist"
12
16
  ],
17
+ "scripts": {
18
+ "build": "node ../../scripts/build-lib.mjs"
19
+ },
13
20
  "publishConfig": {
14
21
  "access": "public",
15
22
  "registry": "https://registry.npmjs.org"
16
23
  },
17
24
  "peerDependencies": {
18
- "@atolljs/core": "0.1.12",
25
+ "@atolljs/core": "^0.1.14",
19
26
  "solid-js": "^1.9.15"
20
27
  },
21
28
  "repository": {