edges-svelte 0.5.7 → 0.6.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/README.md CHANGED
@@ -8,7 +8,7 @@ No context boilerplate. No hydration headaches. Just drop-in SSR-compatible stat
8
8
 
9
9
  - šŸ”„ Unified state for server and client
10
10
  - 🧠 Persistent per-request memory via `AsyncLocalStorage`
11
- - šŸ’§ Tiny API — no subscriptions needed unless you want them
11
+ - šŸ’§ Tiny API
12
12
  - šŸ’„ Instant serialization without magic
13
13
  - 🧩 Provider-based dependency injection, zero runtime overhead
14
14
 
@@ -119,7 +119,15 @@ import { createProvider } from 'edges-svelte';
119
119
  const myProvider = createProvider({
120
120
  cacheKey: 'MyUniqueProviderName',
121
121
  factory: ({ createState }, params) => {
122
- const userData = createState('userData', () => fetchUserData(params.userId));
122
+ const myService = new MyService();
123
+ const someData = createState('userData', () => undefined);
124
+
125
+ const setUserData = async () => {
126
+ await myService.getData().then((user) => {
127
+ userData.set(user);
128
+ });
129
+ };
130
+
123
131
  return { userData };
124
132
  }
125
133
  });
@@ -18,7 +18,15 @@ export const edgesHandle = async (event, callback, silentChromeDevtools = false)
18
18
  RequestContext.current = () => {
19
19
  const context = storage.getStore();
20
20
  if (context === undefined) {
21
- throw new Error('Request symbol has not been initialized');
21
+ throw new Error('[Edge-S] State access attempted outside of a valid request context.\n' +
22
+ '\nThis usually happens if you are calling a provider or using `createState`/`createDerivedState` at the module (top) level.\n' +
23
+ '\nāœ… Correct usage:\n' +
24
+ ' - Inside a `load` function (page.server.ts / page.ts)\n' +
25
+ ' - Inside Svelte components (in <script>)\n' +
26
+ ' - Inside `handle` hook or other request-scoped logic\n' +
27
+ '\n🚫 Incorrect usage:\n' +
28
+ ' - Calling providers or states directly at the top level of a module (e.g., outside any function or component)\n' +
29
+ '\nTo fix this, wrap your provider or state call inside a function, component, or request handler.\n');
22
30
  }
23
31
  return context;
24
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edges-svelte",
3
- "version": "0.5.7",
3
+ "version": "0.6.1",
4
4
  "license": "MIT",
5
5
  "author": "Pixel1917",
6
6
  "description": "A blazing-fast, extremely lightweight and SSR-friendly store for Svelte",