@panyam/tsappkit-solid 0.0.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.
@@ -0,0 +1,45 @@
1
+ import { JSX, Accessor } from 'solid-js';
2
+ import { BaseComponent, EventBus } from '@panyam/tsappkit';
3
+
4
+ /**
5
+ * Mounts a Solid tree inside the tsappkit component lifecycle.
6
+ *
7
+ * The Solid root is created in `activate`, not the constructor, so the render
8
+ * function can close over dependencies injected during `setupDependencies`
9
+ * (e.g. a presenter). It is disposed in `deactivate`, which runs Solid's
10
+ * `onCleanup` handlers and removes the inserted nodes.
11
+ *
12
+ * The island owns its `rootElement`'s children while active, so give it a
13
+ * dedicated element. This class is the only place framework (Solid) reactivity
14
+ * lives; tsappkit core and any presenter behind it stay framework-neutral.
15
+ */
16
+ declare class SolidIsland extends BaseComponent {
17
+ private readonly renderRoot;
18
+ private disposeRoot?;
19
+ constructor(componentId: string, rootElement: HTMLElement, renderRoot: () => JSX.Element, eventBus?: EventBus | null, debugMode?: boolean);
20
+ /**
21
+ * Mount the Solid tree into `rootElement`. Idempotent: calling it again while
22
+ * already mounted is a no-op (the existing root is kept, not remounted).
23
+ */
24
+ activate(): void;
25
+ /**
26
+ * Dispose the Solid tree (runs `onCleanup`, removes the inserted nodes), then
27
+ * defer to the base cleanup (clears the `data-component` marker).
28
+ */
29
+ deactivate(): void;
30
+ }
31
+
32
+ /**
33
+ * Create a Solid-backed cell for the "typed view-interface method backed by a
34
+ * signal" pattern: the accessor drives JSX, the returned setter is the
35
+ * command-down method a framework-agnostic presenter calls.
36
+ *
37
+ * The setter always writes via the updater form (`set(() => next)`) rather than
38
+ * `set(next)`. Solid treats a function passed to a signal setter as an updater
39
+ * to run, not a value to store, so a plain `set(next)` would be wrong whenever
40
+ * `S` is itself a function type. Wrapping makes `signalView` a correct
41
+ * "replace the value" setter for any `S`.
42
+ */
43
+ declare function signalView<S>(initial: S): [Accessor<S>, (next: S) => void];
44
+
45
+ export { SolidIsland, signalView };
@@ -0,0 +1,45 @@
1
+ import { JSX, Accessor } from 'solid-js';
2
+ import { BaseComponent, EventBus } from '@panyam/tsappkit';
3
+
4
+ /**
5
+ * Mounts a Solid tree inside the tsappkit component lifecycle.
6
+ *
7
+ * The Solid root is created in `activate`, not the constructor, so the render
8
+ * function can close over dependencies injected during `setupDependencies`
9
+ * (e.g. a presenter). It is disposed in `deactivate`, which runs Solid's
10
+ * `onCleanup` handlers and removes the inserted nodes.
11
+ *
12
+ * The island owns its `rootElement`'s children while active, so give it a
13
+ * dedicated element. This class is the only place framework (Solid) reactivity
14
+ * lives; tsappkit core and any presenter behind it stay framework-neutral.
15
+ */
16
+ declare class SolidIsland extends BaseComponent {
17
+ private readonly renderRoot;
18
+ private disposeRoot?;
19
+ constructor(componentId: string, rootElement: HTMLElement, renderRoot: () => JSX.Element, eventBus?: EventBus | null, debugMode?: boolean);
20
+ /**
21
+ * Mount the Solid tree into `rootElement`. Idempotent: calling it again while
22
+ * already mounted is a no-op (the existing root is kept, not remounted).
23
+ */
24
+ activate(): void;
25
+ /**
26
+ * Dispose the Solid tree (runs `onCleanup`, removes the inserted nodes), then
27
+ * defer to the base cleanup (clears the `data-component` marker).
28
+ */
29
+ deactivate(): void;
30
+ }
31
+
32
+ /**
33
+ * Create a Solid-backed cell for the "typed view-interface method backed by a
34
+ * signal" pattern: the accessor drives JSX, the returned setter is the
35
+ * command-down method a framework-agnostic presenter calls.
36
+ *
37
+ * The setter always writes via the updater form (`set(() => next)`) rather than
38
+ * `set(next)`. Solid treats a function passed to a signal setter as an updater
39
+ * to run, not a value to store, so a plain `set(next)` would be wrong whenever
40
+ * `S` is itself a function type. Wrapping makes `signalView` a correct
41
+ * "replace the value" setter for any `S`.
42
+ */
43
+ declare function signalView<S>(initial: S): [Accessor<S>, (next: S) => void];
44
+
45
+ export { SolidIsland, signalView };
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ 'use strict';
2
+
3
+ var web = require('solid-js/web');
4
+ var tsappkit = require('@panyam/tsappkit');
5
+ var solidJs = require('solid-js');
6
+
7
+ // src/SolidIsland.ts
8
+ var SolidIsland = class extends tsappkit.BaseComponent {
9
+ constructor(componentId, rootElement, renderRoot, eventBus = null, debugMode = false) {
10
+ super(componentId, rootElement, eventBus, debugMode);
11
+ this.renderRoot = renderRoot;
12
+ }
13
+ /**
14
+ * Mount the Solid tree into `rootElement`. Idempotent: calling it again while
15
+ * already mounted is a no-op (the existing root is kept, not remounted).
16
+ */
17
+ activate() {
18
+ if (this.disposeRoot) return;
19
+ this.disposeRoot = web.render(this.renderRoot, this.rootElement);
20
+ }
21
+ /**
22
+ * Dispose the Solid tree (runs `onCleanup`, removes the inserted nodes), then
23
+ * defer to the base cleanup (clears the `data-component` marker).
24
+ */
25
+ deactivate() {
26
+ this.disposeRoot?.();
27
+ this.disposeRoot = void 0;
28
+ super.deactivate();
29
+ }
30
+ };
31
+ function signalView(initial) {
32
+ const [value, setValue] = solidJs.createSignal(initial);
33
+ return [value, (next) => setValue(() => next)];
34
+ }
35
+
36
+ exports.SolidIsland = SolidIsland;
37
+ exports.signalView = signalView;
38
+ //# sourceMappingURL=index.js.map
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/SolidIsland.ts","../src/signalView.ts"],"names":["BaseComponent","render","createSignal"],"mappings":";;;;;;;AAgBO,IAAM,WAAA,GAAN,cAA0BA,sBAAA,CAAc;AAAA,EAG7C,YACE,WAAA,EACA,WAAA,EACiB,YACjB,QAAA,GAA4B,IAAA,EAC5B,YAAqB,KAAA,EACrB;AACA,IAAA,KAAA,CAAM,WAAA,EAAa,WAAA,EAAa,QAAA,EAAU,SAAS,CAAA;AAJlC,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAAA,EAKnB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,QAAA,GAAiB;AACtB,IAAA,IAAI,KAAK,WAAA,EAAa;AACtB,IAAA,IAAA,CAAK,WAAA,GAAcC,UAAA,CAAO,IAAA,CAAK,UAAA,EAAY,KAAK,WAAW,CAAA;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,UAAA,GAAmB;AACxB,IAAA,IAAA,CAAK,WAAA,IAAc;AACnB,IAAA,IAAA,CAAK,WAAA,GAAc,MAAA;AACnB,IAAA,KAAA,CAAM,UAAA,EAAW;AAAA,EACnB;AACF;AClCO,SAAS,WAAc,OAAA,EAA8C;AAC1E,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIC,qBAAgB,OAAO,CAAA;AACjD,EAAA,OAAO,CAAC,KAAA,EAAO,CAAC,SAAY,QAAA,CAAS,MAAM,IAAI,CAAC,CAAA;AAClD","file":"index.js","sourcesContent":["import { render } from 'solid-js/web';\nimport type { JSX } from 'solid-js';\nimport { BaseComponent, EventBus } from '@panyam/tsappkit';\n\n/**\n * Mounts a Solid tree inside the tsappkit component lifecycle.\n *\n * The Solid root is created in `activate`, not the constructor, so the render\n * function can close over dependencies injected during `setupDependencies`\n * (e.g. a presenter). It is disposed in `deactivate`, which runs Solid's\n * `onCleanup` handlers and removes the inserted nodes.\n *\n * The island owns its `rootElement`'s children while active, so give it a\n * dedicated element. This class is the only place framework (Solid) reactivity\n * lives; tsappkit core and any presenter behind it stay framework-neutral.\n */\nexport class SolidIsland extends BaseComponent {\n private disposeRoot?: () => void;\n\n constructor(\n componentId: string,\n rootElement: HTMLElement,\n private readonly renderRoot: () => JSX.Element,\n eventBus: EventBus | null = null,\n debugMode: boolean = false,\n ) {\n super(componentId, rootElement, eventBus, debugMode);\n }\n\n /**\n * Mount the Solid tree into `rootElement`. Idempotent: calling it again while\n * already mounted is a no-op (the existing root is kept, not remounted).\n */\n public activate(): void {\n if (this.disposeRoot) return;\n this.disposeRoot = render(this.renderRoot, this.rootElement);\n }\n\n /**\n * Dispose the Solid tree (runs `onCleanup`, removes the inserted nodes), then\n * defer to the base cleanup (clears the `data-component` marker).\n */\n public deactivate(): void {\n this.disposeRoot?.();\n this.disposeRoot = undefined;\n super.deactivate();\n }\n}\n","import { createSignal, type Accessor } from 'solid-js';\n\n/**\n * Create a Solid-backed cell for the \"typed view-interface method backed by a\n * signal\" pattern: the accessor drives JSX, the returned setter is the\n * command-down method a framework-agnostic presenter calls.\n *\n * The setter always writes via the updater form (`set(() => next)`) rather than\n * `set(next)`. Solid treats a function passed to a signal setter as an updater\n * to run, not a value to store, so a plain `set(next)` would be wrong whenever\n * `S` is itself a function type. Wrapping makes `signalView` a correct\n * \"replace the value\" setter for any `S`.\n */\nexport function signalView<S>(initial: S): [Accessor<S>, (next: S) => void] {\n const [value, setValue] = createSignal<S>(initial);\n return [value, (next: S) => setValue(() => next)];\n}\n"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,36 @@
1
+ import { render } from 'solid-js/web';
2
+ import { BaseComponent } from '@panyam/tsappkit';
3
+ import { createSignal } from 'solid-js';
4
+
5
+ // src/SolidIsland.ts
6
+ var SolidIsland = class extends BaseComponent {
7
+ constructor(componentId, rootElement, renderRoot, eventBus = null, debugMode = false) {
8
+ super(componentId, rootElement, eventBus, debugMode);
9
+ this.renderRoot = renderRoot;
10
+ }
11
+ /**
12
+ * Mount the Solid tree into `rootElement`. Idempotent: calling it again while
13
+ * already mounted is a no-op (the existing root is kept, not remounted).
14
+ */
15
+ activate() {
16
+ if (this.disposeRoot) return;
17
+ this.disposeRoot = render(this.renderRoot, this.rootElement);
18
+ }
19
+ /**
20
+ * Dispose the Solid tree (runs `onCleanup`, removes the inserted nodes), then
21
+ * defer to the base cleanup (clears the `data-component` marker).
22
+ */
23
+ deactivate() {
24
+ this.disposeRoot?.();
25
+ this.disposeRoot = void 0;
26
+ super.deactivate();
27
+ }
28
+ };
29
+ function signalView(initial) {
30
+ const [value, setValue] = createSignal(initial);
31
+ return [value, (next) => setValue(() => next)];
32
+ }
33
+
34
+ export { SolidIsland, signalView };
35
+ //# sourceMappingURL=index.mjs.map
36
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/SolidIsland.ts","../src/signalView.ts"],"names":[],"mappings":";;;;;AAgBO,IAAM,WAAA,GAAN,cAA0B,aAAA,CAAc;AAAA,EAG7C,YACE,WAAA,EACA,WAAA,EACiB,YACjB,QAAA,GAA4B,IAAA,EAC5B,YAAqB,KAAA,EACrB;AACA,IAAA,KAAA,CAAM,WAAA,EAAa,WAAA,EAAa,QAAA,EAAU,SAAS,CAAA;AAJlC,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AAAA,EAKnB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,QAAA,GAAiB;AACtB,IAAA,IAAI,KAAK,WAAA,EAAa;AACtB,IAAA,IAAA,CAAK,WAAA,GAAc,MAAA,CAAO,IAAA,CAAK,UAAA,EAAY,KAAK,WAAW,CAAA;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,UAAA,GAAmB;AACxB,IAAA,IAAA,CAAK,WAAA,IAAc;AACnB,IAAA,IAAA,CAAK,WAAA,GAAc,MAAA;AACnB,IAAA,KAAA,CAAM,UAAA,EAAW;AAAA,EACnB;AACF;AClCO,SAAS,WAAc,OAAA,EAA8C;AAC1E,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,aAAgB,OAAO,CAAA;AACjD,EAAA,OAAO,CAAC,KAAA,EAAO,CAAC,SAAY,QAAA,CAAS,MAAM,IAAI,CAAC,CAAA;AAClD","file":"index.mjs","sourcesContent":["import { render } from 'solid-js/web';\nimport type { JSX } from 'solid-js';\nimport { BaseComponent, EventBus } from '@panyam/tsappkit';\n\n/**\n * Mounts a Solid tree inside the tsappkit component lifecycle.\n *\n * The Solid root is created in `activate`, not the constructor, so the render\n * function can close over dependencies injected during `setupDependencies`\n * (e.g. a presenter). It is disposed in `deactivate`, which runs Solid's\n * `onCleanup` handlers and removes the inserted nodes.\n *\n * The island owns its `rootElement`'s children while active, so give it a\n * dedicated element. This class is the only place framework (Solid) reactivity\n * lives; tsappkit core and any presenter behind it stay framework-neutral.\n */\nexport class SolidIsland extends BaseComponent {\n private disposeRoot?: () => void;\n\n constructor(\n componentId: string,\n rootElement: HTMLElement,\n private readonly renderRoot: () => JSX.Element,\n eventBus: EventBus | null = null,\n debugMode: boolean = false,\n ) {\n super(componentId, rootElement, eventBus, debugMode);\n }\n\n /**\n * Mount the Solid tree into `rootElement`. Idempotent: calling it again while\n * already mounted is a no-op (the existing root is kept, not remounted).\n */\n public activate(): void {\n if (this.disposeRoot) return;\n this.disposeRoot = render(this.renderRoot, this.rootElement);\n }\n\n /**\n * Dispose the Solid tree (runs `onCleanup`, removes the inserted nodes), then\n * defer to the base cleanup (clears the `data-component` marker).\n */\n public deactivate(): void {\n this.disposeRoot?.();\n this.disposeRoot = undefined;\n super.deactivate();\n }\n}\n","import { createSignal, type Accessor } from 'solid-js';\n\n/**\n * Create a Solid-backed cell for the \"typed view-interface method backed by a\n * signal\" pattern: the accessor drives JSX, the returned setter is the\n * command-down method a framework-agnostic presenter calls.\n *\n * The setter always writes via the updater form (`set(() => next)`) rather than\n * `set(next)`. Solid treats a function passed to a signal setter as an updater\n * to run, not a value to store, so a plain `set(next)` would be wrong whenever\n * `S` is itself a function type. Wrapping makes `signalView` a correct\n * \"replace the value\" setter for any `S`.\n */\nexport function signalView<S>(initial: S): [Accessor<S>, (next: S) => void] {\n const [value, setValue] = createSignal<S>(initial);\n return [value, (next: S) => setValue(() => next)];\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@panyam/tsappkit-solid",
3
+ "version": "0.0.1",
4
+ "description": "Solid adapter for @panyam/tsappkit: mount Solid islands inside the tsappkit component lifecycle. The framework-specific reactivity lives here so tsappkit core stays framework-neutral.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "dev": "tsup --watch",
22
+ "clean": "rm -rf dist",
23
+ "prepublishOnly": "npm run build",
24
+ "typecheck": "tsc --noEmit",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest"
27
+ },
28
+ "keywords": [
29
+ "solid",
30
+ "solid-js",
31
+ "tsappkit",
32
+ "island",
33
+ "component",
34
+ "lifecycle"
35
+ ],
36
+ "author": "panyam",
37
+ "license": "MIT",
38
+ "peerDependencies": {
39
+ "@panyam/tsappkit": "^0.0.5",
40
+ "solid-js": "^1.9.0"
41
+ },
42
+ "devDependencies": {
43
+ "@panyam/tsappkit": "^0.0.5",
44
+ "@solidjs/testing-library": "^0.8.10",
45
+ "esbuild-plugin-solid": "^0.6.0",
46
+ "jsdom": "^29.1.1",
47
+ "solid-js": "^1.9.14",
48
+ "tsup": "^8.5.1",
49
+ "typescript": "^5.9.3",
50
+ "vite-plugin-solid": "^2.11.12",
51
+ "vitest": "^4.1.9"
52
+ },
53
+ "pnpm": {
54
+ "onlyBuiltDependencies": [
55
+ "esbuild"
56
+ ]
57
+ }
58
+ }
@@ -0,0 +1,48 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { createSignal, onCleanup, type JSX } from 'solid-js';
3
+ import { SolidIsland } from './SolidIsland';
4
+
5
+ function mount(renderRoot: () => JSX.Element) {
6
+ const root = document.createElement('div');
7
+ document.body.appendChild(root);
8
+ const island = new SolidIsland('test-island', root, renderRoot);
9
+ return { root, island };
10
+ }
11
+
12
+ describe('SolidIsland', () => {
13
+ it('mounts the Solid tree on activate', () => {
14
+ const { root, island } = mount(() => <span data-testid="hi">hello</span>);
15
+ expect(root.textContent).toBe('');
16
+ island.activate();
17
+ expect(root.querySelector('[data-testid="hi"]')?.textContent).toBe('hello');
18
+ });
19
+
20
+ it('re-renders on signal update while mounted', () => {
21
+ const [count, setCount] = createSignal(0);
22
+ const { root, island } = mount(() => <span data-testid="n">{count()}</span>);
23
+ island.activate();
24
+ expect(root.querySelector('[data-testid="n"]')?.textContent).toBe('0');
25
+ setCount(2);
26
+ expect(root.querySelector('[data-testid="n"]')?.textContent).toBe('2');
27
+ });
28
+
29
+ it('disposes on deactivate: runs onCleanup and removes nodes', () => {
30
+ const cleanup = vi.fn();
31
+ const { root, island } = mount(() => {
32
+ onCleanup(cleanup);
33
+ return <span data-testid="x">x</span>;
34
+ });
35
+ island.activate();
36
+ expect(root.querySelector('[data-testid="x"]')).not.toBeNull();
37
+ island.deactivate();
38
+ expect(cleanup).toHaveBeenCalledTimes(1);
39
+ expect(root.querySelector('[data-testid="x"]')).toBeNull();
40
+ });
41
+
42
+ it('is idempotent on repeated activate', () => {
43
+ const { root, island } = mount(() => <span data-testid="one">one</span>);
44
+ island.activate();
45
+ island.activate();
46
+ expect(root.querySelectorAll('[data-testid="one"]').length).toBe(1);
47
+ });
48
+ });
@@ -0,0 +1,48 @@
1
+ import { render } from 'solid-js/web';
2
+ import type { JSX } from 'solid-js';
3
+ import { BaseComponent, EventBus } from '@panyam/tsappkit';
4
+
5
+ /**
6
+ * Mounts a Solid tree inside the tsappkit component lifecycle.
7
+ *
8
+ * The Solid root is created in `activate`, not the constructor, so the render
9
+ * function can close over dependencies injected during `setupDependencies`
10
+ * (e.g. a presenter). It is disposed in `deactivate`, which runs Solid's
11
+ * `onCleanup` handlers and removes the inserted nodes.
12
+ *
13
+ * The island owns its `rootElement`'s children while active, so give it a
14
+ * dedicated element. This class is the only place framework (Solid) reactivity
15
+ * lives; tsappkit core and any presenter behind it stay framework-neutral.
16
+ */
17
+ export class SolidIsland extends BaseComponent {
18
+ private disposeRoot?: () => void;
19
+
20
+ constructor(
21
+ componentId: string,
22
+ rootElement: HTMLElement,
23
+ private readonly renderRoot: () => JSX.Element,
24
+ eventBus: EventBus | null = null,
25
+ debugMode: boolean = false,
26
+ ) {
27
+ super(componentId, rootElement, eventBus, debugMode);
28
+ }
29
+
30
+ /**
31
+ * Mount the Solid tree into `rootElement`. Idempotent: calling it again while
32
+ * already mounted is a no-op (the existing root is kept, not remounted).
33
+ */
34
+ public activate(): void {
35
+ if (this.disposeRoot) return;
36
+ this.disposeRoot = render(this.renderRoot, this.rootElement);
37
+ }
38
+
39
+ /**
40
+ * Dispose the Solid tree (runs `onCleanup`, removes the inserted nodes), then
41
+ * defer to the base cleanup (clears the `data-component` marker).
42
+ */
43
+ public deactivate(): void {
44
+ this.disposeRoot?.();
45
+ this.disposeRoot = undefined;
46
+ super.deactivate();
47
+ }
48
+ }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ // @panyam/tsappkit-solid — Solid adapter for @panyam/tsappkit.
2
+ //
3
+ // Framework reactivity lives here so tsappkit core stays framework-neutral:
4
+ // SolidIsland bridges a Solid root into the tsappkit component lifecycle, and
5
+ // signalView backs a typed view-interface method with a Solid signal.
6
+ export { SolidIsland } from './SolidIsland';
7
+ export { signalView } from './signalView';
@@ -0,0 +1,19 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { signalView } from './signalView';
3
+
4
+ describe('signalView', () => {
5
+ it('updates the accessor when set is called', () => {
6
+ const [value, set] = signalView({ terrain: 0 });
7
+ expect(value()).toEqual({ terrain: 0 });
8
+ set({ terrain: 5 });
9
+ expect(value()).toEqual({ terrain: 5 });
10
+ });
11
+
12
+ it('stores a function value instead of treating it as a Solid updater', () => {
13
+ const fn = () => 42;
14
+ const [value, set] = signalView<() => number>(() => 0);
15
+ set(fn);
16
+ expect(value()).toBe(fn);
17
+ expect(value()()).toBe(42);
18
+ });
19
+ });
@@ -0,0 +1,17 @@
1
+ import { createSignal, type Accessor } from 'solid-js';
2
+
3
+ /**
4
+ * Create a Solid-backed cell for the "typed view-interface method backed by a
5
+ * signal" pattern: the accessor drives JSX, the returned setter is the
6
+ * command-down method a framework-agnostic presenter calls.
7
+ *
8
+ * The setter always writes via the updater form (`set(() => next)`) rather than
9
+ * `set(next)`. Solid treats a function passed to a signal setter as an updater
10
+ * to run, not a value to store, so a plain `set(next)` would be wrong whenever
11
+ * `S` is itself a function type. Wrapping makes `signalView` a correct
12
+ * "replace the value" setter for any `S`.
13
+ */
14
+ export function signalView<S>(initial: S): [Accessor<S>, (next: S) => void] {
15
+ const [value, setValue] = createSignal<S>(initial);
16
+ return [value, (next: S) => setValue(() => next)];
17
+ }
@@ -0,0 +1,22 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { render } from '@solidjs/testing-library';
3
+ import { createSignal } from 'solid-js';
4
+
5
+ function Badge(props: { label: string }) {
6
+ return <span data-testid="badge">{props.label}</span>;
7
+ }
8
+
9
+ describe('tsappkit-solid toolchain', () => {
10
+ it('compiles and renders a Solid component', () => {
11
+ const { getByTestId } = render(() => <Badge label="ready" />);
12
+ expect(getByTestId('badge').textContent).toBe('ready');
13
+ });
14
+
15
+ it('reacts to a signal update', () => {
16
+ const [count, setCount] = createSignal(0);
17
+ const { getByTestId } = render(() => <span data-testid="count">{count()}</span>);
18
+ expect(getByTestId('count').textContent).toBe('0');
19
+ setCount(3);
20
+ expect(getByTestId('count').textContent).toBe('3');
21
+ });
22
+ });