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 +10 -2
- package/dist/server/EdgesHandle.js +9 -1
- package/package.json +1 -1
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
|
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
|
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('
|
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
|
};
|