@gost-kit/svelte 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @gost-kit/svelte
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [6723c38]
8
+ - @gost-kit/common@0.2.0
9
+
10
+ ## 0.1.0
11
+
12
+ ### Minor Changes
13
+
14
+ - Initial public release of the Svelte 5 createStore binding for the GOST functional core.
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+ - @gost-kit/common@0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anton Smolko
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.
package/README.md CHANGED
@@ -1,3 +1,65 @@
1
- # Temporary Holding Version
1
+ # @gost-kit/svelte
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Reactive Svelte 5 binding for `@gost-kit/common` functional core.
4
+ Requires Node 26 (`^26.0.0`) and Svelte 5.57.2 or later in the 5.x series.
5
+ The store implementation lives in `src/shell/domain/createStore.svelte.ts`.
6
+
7
+ ```ts
8
+ import { createStore } from '@gost-kit/svelte';
9
+
10
+ const counter = createStore<number, { type: 'IncrementAction' }, never>({
11
+ initState: 0,
12
+ reducer: (state) => ({ state: state + 1, effects: [] }),
13
+ effector: async () => {},
14
+ });
15
+
16
+ await counter.dispatch({ type: 'IncrementAction' });
17
+ // counter.state is now 1; reading it in a Svelte template is reactive.
18
+ ```
19
+
20
+ `createStore` accepts `StoreConfig` and returns `Store`, both exported from
21
+ `@gost-kit/common`. It replaces the complete state through `$state.raw`; it does not
22
+ merge or deeply proxy state. Each instance has independent state. Dispatch,
23
+ parallel effects, awaited nested dispatch and error reporting are implemented
24
+ by `@gost-kit/common` without a framework dependency.
25
+
26
+ The optional `onError` callback is supplied when the store is created, for example
27
+ to connect application logging. Replacing it on the original config afterwards
28
+ does not change the store's handler.
29
+
30
+ Select a feature before computing its presentation:
31
+
32
+ ```ts
33
+ const user = $derived(root.state.user);
34
+ const viewState = $derived(userPresenter(user));
35
+ ```
36
+
37
+ Replacing the root reevaluates the selection. If `user` retains its reference,
38
+ Svelte skips the downstream presenter. Replacing `user` updates its view state.
39
+ Keep the selection separate: `$derived(userPresenter(root.state.user))` depends
40
+ directly on the root and calls the presenter on unrelated root replacements.
41
+
42
+ The store keeps one ordinary snapshot, without an additional UI representation.
43
+ Root identity follows reducer commits; feature references are preserved by the
44
+ reducers. Primitive and array roots keep the same raw replacement model.
45
+ Class instances are outside the intended state contract.
46
+ Presenters stay pure; reactive bindings belong to components or Svelte adapters.
47
+
48
+ Reducers still construct immutable root snapshots. Feature selection may rerun
49
+ when the root is replaced; an unchanged selected reference does not cause
50
+ another presenter call.
51
+
52
+ The [createStore contract and test cases](docs/createStore.spec.md) describe
53
+ the Svelte integration checks; dispatch execution is tested in common.
54
+
55
+ Build common first, then run `npm run build --workspace @gost-kit/svelte` from the
56
+ repository root. Packaging follows the official
57
+ [Svelte library packaging guide](https://svelte.dev/docs/kit/packaging) using
58
+ `@sveltejs/package`. The `svelte` export condition points to JavaScript containing
59
+ runes; consumers compile it with their Svelte tooling. Declarations are shipped
60
+ alongside it. Svelte is a peer dependency, and is not bundled into the library.
61
+ The `default` condition resolves the same entry for tools without the `svelte`
62
+ condition. Calling `createStore` still requires Svelte compilation of the runes.
63
+
64
+ Source imports omit `.ts` and `.js`, retaining `.svelte` for components and rune
65
+ modules. The build resolves emitted paths to `.js` with `tsc-alias`.
@@ -0,0 +1 @@
1
+ export { createStore } from './shell/domain/createStore.svelte.js';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { createStore } from './shell/domain/createStore.svelte.js';
@@ -0,0 +1,2 @@
1
+ import { type Store, type StoreConfig, type Trigger } from '@gost-kit/common';
2
+ export declare const createStore: <TState, TAction extends Trigger, TEffect extends Trigger>({ initState, reducer, effector, onError, }: StoreConfig<TState, TAction, TEffect>) => Store<TState, TAction>;
@@ -0,0 +1,22 @@
1
+ import { createDispatch, } from '@gost-kit/common';
2
+ export const createStore = ({ initState, reducer, effector, onError, }) => {
3
+ // Reducers replace complete immutable state; deep proxies are unnecessary.
4
+ let state = $state.raw(initState);
5
+ const dispatch = createDispatch({
6
+ readState: () => {
7
+ return state;
8
+ },
9
+ writeState: (next) => {
10
+ state = next;
11
+ },
12
+ reducer,
13
+ effector,
14
+ onError,
15
+ });
16
+ return {
17
+ get state() {
18
+ return state;
19
+ },
20
+ dispatch,
21
+ };
22
+ };
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "@gost-kit/svelte",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Svelte bindings for GOST functional core.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "engines": {
8
+ "node": "^26.0.0"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "CHANGELOG.md"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "svelte": "./dist/index.js",
18
+ "default": "./dist/index.js"
19
+ }
20
+ },
21
+ "scripts": {
22
+ "build": "svelte-package -i src && tsc-alias -p tsconfig.json --outDir dist && node scripts/clean-build.ts",
23
+ "check": "tsc --noEmit",
24
+ "test": "vitest run",
25
+ "prepack": "npm run build"
26
+ },
27
+ "dependencies": {
28
+ "@gost-kit/common": "^0.2.0"
29
+ },
30
+ "peerDependencies": {
31
+ "svelte": "^5.57.2"
32
+ },
33
+ "devDependencies": {
34
+ "@sveltejs/package": "3.0.1",
35
+ "@sveltejs/vite-plugin-svelte": "7.3.1",
36
+ "@types/node": "26.6.5",
37
+ "svelte": "5.57.2",
38
+ "tsc-alias": "1.9.9",
39
+ "typescript": "5.9.3",
40
+ "vite": "8.3.5",
41
+ "vitest": "5.0.5"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/antonsmolko/gost-kit.git",
46
+ "directory": "packages/svelte"
47
+ },
48
+ "homepage": "https://github.com/antonsmolko/gost-kit/tree/main/packages/svelte#readme",
49
+ "bugs": {
50
+ "url": "https://github.com/antonsmolko/gost-kit/issues"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ }
55
+ }