@storix-js/svelte 0.1.0 → 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/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # @storix-js/svelte
2
+
3
+ Svelte adapter for Storix.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @storix-js/core @storix-js/svelte
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { toSvelteStore } from '@storix-js/svelte';
15
+ import { useCounterStore } from './store';
16
+
17
+ export const counter = toSvelteStore(useCounterStore);
18
+ ```
19
+
20
+ `toSvelteStore()` exposes a Svelte-readable store wrapper so you can use `$counter` in components.
package/package.json CHANGED
@@ -1,10 +1,17 @@
1
1
  {
2
2
  "name": "@storix-js/svelte",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
8
15
  "exports": {
9
16
  ".": {
10
17
  "types": "./dist/index.d.ts",
@@ -15,7 +22,7 @@
15
22
  "scripts": {
16
23
  "build": "vite build && tsc -p tsconfig.build.json --emitDeclarationOnly",
17
24
  "dev": "vite build --watch",
18
- "test": "vitest run",
25
+ "test": "vitest run --passWithNoTests",
19
26
  "typecheck": "tsc -p tsconfig.json --noEmit"
20
27
  },
21
28
  "dependencies": {
package/src/index.ts DELETED
@@ -1,22 +0,0 @@
1
- import type { StoreInstance } from '@storix-js/core';
2
-
3
- export function useStore<T extends (...args: never[]) => StoreInstance>(factory: T): ReturnType<T> {
4
- return factory() as ReturnType<T>;
5
- }
6
-
7
- export interface SvelteReadableStore<T> {
8
- subscribe(run: (value: T) => void): () => void;
9
- }
10
-
11
- export function toSvelteStore<T extends (...args: never[]) => StoreInstance>(factory: T): SvelteReadableStore<ReturnType<T>> {
12
- const store = factory() as ReturnType<T>;
13
-
14
- return {
15
- subscribe(run) {
16
- run(store);
17
- return store.$subscribe(() => {
18
- run(store);
19
- });
20
- }
21
- };
22
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "outDir": "dist",
6
- "paths": {}
7
- }
8
- }
package/tsconfig.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base.json",
3
- "include": ["src"]
4
- }
package/vite.config.ts DELETED
@@ -1,15 +0,0 @@
1
- import { defineConfig } from 'vite';
2
-
3
- export default defineConfig({
4
- build: {
5
- lib: {
6
- entry: 'src/index.ts',
7
- name: 'StorixSvelte',
8
- fileName: 'index',
9
- formats: ['es', 'cjs']
10
- }
11
- },
12
- test: {
13
- environment: 'node'
14
- }
15
- });