remult 3.3.13 → 3.3.14
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/esm/src/context.js +8 -0
- package/esm/src/remult-proxy.js +13 -3
- package/package.json +1 -1
- package/src/context.d.ts +7 -0
- package/src/context.js +8 -0
- package/src/remult-proxy.js +13 -3
package/esm/src/context.js
CHANGED
|
@@ -170,7 +170,15 @@ export class Remult {
|
|
|
170
170
|
return this.isAllowed(allowed);
|
|
171
171
|
return undefined;
|
|
172
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated In SvelteKit, loads run in parallel, so reassigning the shared
|
|
175
|
+
* `remult` data provider here leaks across loads. Scope the fetch to the read
|
|
176
|
+
* with `withRemult` instead, e.g.
|
|
177
|
+
* `withRemult((r) => r.repo(X).find(), { dataProvider: new RestDataProvider(() => ({ httpClient: event.fetch })) })`.
|
|
178
|
+
* See the SvelteKit "Universal load & SSR" doc.
|
|
179
|
+
*/
|
|
173
180
|
useFetch(fetch) {
|
|
181
|
+
console.warn('[remult] `useFetch` is deprecated, see https://remult.dev/docs/installation/framework/sveltekit#extra-universal-load-ssr');
|
|
174
182
|
this.dataProvider = new RestDataProvider(() => ({
|
|
175
183
|
httpClient: fetch,
|
|
176
184
|
}));
|
package/esm/src/remult-proxy.js
CHANGED
|
@@ -62,6 +62,11 @@ export class RemultProxy {
|
|
|
62
62
|
clearAllCache() {
|
|
63
63
|
return remultStatic.remultFactory().clearAllCache();
|
|
64
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Mutating the shared request `remult` is unsafe (it can affect a
|
|
67
|
+
* concurrent `+page.server.ts` on the server). Scope the rest fetch to the read
|
|
68
|
+
* with `withRemult` instead - see the SvelteKit "Universal load & SSR" doc.
|
|
69
|
+
*/
|
|
65
70
|
useFetch(args) {
|
|
66
71
|
return remultStatic.remultFactory().useFetch(args);
|
|
67
72
|
}
|
|
@@ -71,9 +76,11 @@ export class RemultProxy {
|
|
|
71
76
|
let self = remultStatic;
|
|
72
77
|
let entityCache = this.repoCache.get(args[0]);
|
|
73
78
|
if (!entityCache) {
|
|
74
|
-
this.repoCache.set(args[0], (entityCache = new
|
|
79
|
+
this.repoCache.set(args[0], (entityCache = { byDataProvider: new WeakMap() }));
|
|
75
80
|
}
|
|
76
|
-
let result =
|
|
81
|
+
let result = args[1]
|
|
82
|
+
? entityCache.byDataProvider.get(args[1])
|
|
83
|
+
: entityCache.default;
|
|
77
84
|
if (result)
|
|
78
85
|
return result;
|
|
79
86
|
result = {
|
|
@@ -184,7 +191,10 @@ export class RemultProxy {
|
|
|
184
191
|
.repo(...args)
|
|
185
192
|
.update(a, b, c),
|
|
186
193
|
};
|
|
187
|
-
|
|
194
|
+
if (args[1])
|
|
195
|
+
entityCache.byDataProvider.set(args[1], result);
|
|
196
|
+
else
|
|
197
|
+
entityCache.default = result;
|
|
188
198
|
return result;
|
|
189
199
|
};
|
|
190
200
|
get user() {
|
package/package.json
CHANGED
package/src/context.d.ts
CHANGED
|
@@ -63,6 +63,13 @@ export declare class Remult {
|
|
|
63
63
|
* [Allowed](https://remult.dev/docs/allowed.html)
|
|
64
64
|
*/
|
|
65
65
|
isAllowedForInstance(instance: any, allowed?: AllowedForInstance<any>): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* @deprecated In SvelteKit, loads run in parallel, so reassigning the shared
|
|
68
|
+
* `remult` data provider here leaks across loads. Scope the fetch to the read
|
|
69
|
+
* with `withRemult` instead, e.g.
|
|
70
|
+
* `withRemult((r) => r.repo(X).find(), { dataProvider: new RestDataProvider(() => ({ httpClient: event.fetch })) })`.
|
|
71
|
+
* See the SvelteKit "Universal load & SSR" doc.
|
|
72
|
+
*/
|
|
66
73
|
useFetch(fetch: ApiClient['httpClient']): void;
|
|
67
74
|
/** The current data provider */
|
|
68
75
|
dataProvider: DataProvider;
|
package/src/context.js
CHANGED
|
@@ -274,7 +274,15 @@ var Remult = /** @class */ (function () {
|
|
|
274
274
|
return this.isAllowed(allowed);
|
|
275
275
|
return undefined;
|
|
276
276
|
};
|
|
277
|
+
/**
|
|
278
|
+
* @deprecated In SvelteKit, loads run in parallel, so reassigning the shared
|
|
279
|
+
* `remult` data provider here leaks across loads. Scope the fetch to the read
|
|
280
|
+
* with `withRemult` instead, e.g.
|
|
281
|
+
* `withRemult((r) => r.repo(X).find(), { dataProvider: new RestDataProvider(() => ({ httpClient: event.fetch })) })`.
|
|
282
|
+
* See the SvelteKit "Universal load & SSR" doc.
|
|
283
|
+
*/
|
|
277
284
|
Remult.prototype.useFetch = function (fetch) {
|
|
285
|
+
console.warn('[remult] `useFetch` is deprecated, see https://remult.dev/docs/installation/framework/sveltekit#extra-universal-load-ssr');
|
|
278
286
|
this.dataProvider = new rest_data_provider_js_1.RestDataProvider(function () { return ({
|
|
279
287
|
httpClient: fetch,
|
|
280
288
|
}); });
|
package/src/remult-proxy.js
CHANGED
|
@@ -21,9 +21,11 @@ var RemultProxy = /** @class */ (function () {
|
|
|
21
21
|
var self = remult_static_js_1.remultStatic;
|
|
22
22
|
var entityCache = _this.repoCache.get(args[0]);
|
|
23
23
|
if (!entityCache) {
|
|
24
|
-
_this.repoCache.set(args[0], (entityCache = new
|
|
24
|
+
_this.repoCache.set(args[0], (entityCache = { byDataProvider: new WeakMap() }));
|
|
25
25
|
}
|
|
26
|
-
var result =
|
|
26
|
+
var result = args[1]
|
|
27
|
+
? entityCache.byDataProvider.get(args[1])
|
|
28
|
+
: entityCache.default;
|
|
27
29
|
if (result)
|
|
28
30
|
return result;
|
|
29
31
|
result = (_a = {
|
|
@@ -245,7 +247,10 @@ var RemultProxy = /** @class */ (function () {
|
|
|
245
247
|
.repo.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)).update(a, b, c);
|
|
246
248
|
},
|
|
247
249
|
_a);
|
|
248
|
-
|
|
250
|
+
if (args[1])
|
|
251
|
+
entityCache.byDataProvider.set(args[1], result);
|
|
252
|
+
else
|
|
253
|
+
entityCache.default = result;
|
|
249
254
|
return result;
|
|
250
255
|
};
|
|
251
256
|
}
|
|
@@ -336,6 +341,11 @@ var RemultProxy = /** @class */ (function () {
|
|
|
336
341
|
RemultProxy.prototype.clearAllCache = function () {
|
|
337
342
|
return remult_static_js_1.remultStatic.remultFactory().clearAllCache();
|
|
338
343
|
};
|
|
344
|
+
/**
|
|
345
|
+
* @deprecated Mutating the shared request `remult` is unsafe (it can affect a
|
|
346
|
+
* concurrent `+page.server.ts` on the server). Scope the rest fetch to the read
|
|
347
|
+
* with `withRemult` instead - see the SvelteKit "Universal load & SSR" doc.
|
|
348
|
+
*/
|
|
339
349
|
RemultProxy.prototype.useFetch = function (args) {
|
|
340
350
|
return remult_static_js_1.remultStatic.remultFactory().useFetch(args);
|
|
341
351
|
};
|