@sylphx/lens-solid 2.1.3 → 2.1.5
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/dist/create.d.ts.map +1 -1
- package/dist/index.js +11 -26
- package/package.json +2 -2
- package/src/create.ts +19 -27
package/dist/create.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,KAAK,QAAQ,EAA6C,MAAM,UAAU,CAAC;AAMpF,8BAA8B;AAC9B,MAAM,WAAW,qBAAqB,CAAC,MAAM;IAC5C,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;CACf;AAED,6BAA6B;AAC7B,MAAM,WAAW,oBAAoB,CAAC,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BAAgB,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;AA2J9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,YAAY,CAAC,OAAO,SAAS,SAAS,EACrD,MAAM,EAAE,gBAAgB,GAAG,iBAAiB,CAAC;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,GAC/D,WAAW,CAAC,OAAO,CAAC,CAoEtB"}
|
package/dist/index.js
CHANGED
|
@@ -1104,7 +1104,7 @@ class SubscriptionRegistry {
|
|
|
1104
1104
|
}
|
|
1105
1105
|
|
|
1106
1106
|
// src/create.ts
|
|
1107
|
-
import { createSignal, onCleanup } from "solid-js";
|
|
1107
|
+
import { createEffect, createSignal, on, onCleanup } from "solid-js";
|
|
1108
1108
|
function createQueryPrimitiveFactory(getEndpoint) {
|
|
1109
1109
|
return function createQuery(options) {
|
|
1110
1110
|
const [data, setData] = createSignal(null);
|
|
@@ -1142,6 +1142,13 @@ function createQueryPrimitiveFactory(getEndpoint) {
|
|
|
1142
1142
|
});
|
|
1143
1143
|
};
|
|
1144
1144
|
executeQuery();
|
|
1145
|
+
createEffect(on(() => ({
|
|
1146
|
+
inputKey: JSON.stringify(options?.input),
|
|
1147
|
+
selectKey: JSON.stringify(options?.select),
|
|
1148
|
+
skip: options?.skip
|
|
1149
|
+
}), () => {
|
|
1150
|
+
executeQuery();
|
|
1151
|
+
}, { defer: true }));
|
|
1145
1152
|
onCleanup(() => {
|
|
1146
1153
|
if (unsubscribe) {
|
|
1147
1154
|
unsubscribe();
|
|
@@ -1149,29 +1156,7 @@ function createQueryPrimitiveFactory(getEndpoint) {
|
|
|
1149
1156
|
}
|
|
1150
1157
|
});
|
|
1151
1158
|
const refetch = () => {
|
|
1152
|
-
|
|
1153
|
-
unsubscribe();
|
|
1154
|
-
unsubscribe = null;
|
|
1155
|
-
}
|
|
1156
|
-
setLoading(true);
|
|
1157
|
-
setError(null);
|
|
1158
|
-
const endpoint = getEndpoint();
|
|
1159
|
-
const query = endpoint({ input: options?.input, select: options?.select });
|
|
1160
|
-
if (query) {
|
|
1161
|
-
unsubscribe = query.subscribe((value) => {
|
|
1162
|
-
setData(() => value);
|
|
1163
|
-
setLoading(false);
|
|
1164
|
-
setError(null);
|
|
1165
|
-
});
|
|
1166
|
-
query.then((value) => {
|
|
1167
|
-
setData(() => value);
|
|
1168
|
-
setLoading(false);
|
|
1169
|
-
}, (err) => {
|
|
1170
|
-
const queryError = err instanceof Error ? err : new Error(String(err));
|
|
1171
|
-
setError(queryError);
|
|
1172
|
-
setLoading(false);
|
|
1173
|
-
});
|
|
1174
|
-
}
|
|
1159
|
+
executeQuery();
|
|
1175
1160
|
};
|
|
1176
1161
|
return { data, loading, error, refetch };
|
|
1177
1162
|
};
|
|
@@ -1286,7 +1271,7 @@ function useLensClient() {
|
|
|
1286
1271
|
return client;
|
|
1287
1272
|
}
|
|
1288
1273
|
// src/primitives.ts
|
|
1289
|
-
import { createEffect, createSignal as createSignal2, onCleanup as onCleanup2 } from "solid-js";
|
|
1274
|
+
import { createEffect as createEffect2, createSignal as createSignal2, onCleanup as onCleanup2 } from "solid-js";
|
|
1290
1275
|
function resolveQuery(input) {
|
|
1291
1276
|
return typeof input === "function" ? input() : input;
|
|
1292
1277
|
}
|
|
@@ -1325,7 +1310,7 @@ function createQuery(queryInput, options) {
|
|
|
1325
1310
|
};
|
|
1326
1311
|
const initialQuery = resolveQuery(queryInput);
|
|
1327
1312
|
executeQuery(initialQuery);
|
|
1328
|
-
|
|
1313
|
+
createEffect2(() => {
|
|
1329
1314
|
const queryResult = resolveQuery(queryInput);
|
|
1330
1315
|
if (queryResult !== initialQuery) {
|
|
1331
1316
|
executeQuery(queryResult);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sylphx/lens-solid",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "SolidJS bindings for Lens API framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"author": "SylphxAI",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@sylphx/lens-client": "^2.3.
|
|
34
|
+
"@sylphx/lens-client": "^2.3.1",
|
|
35
35
|
"@sylphx/lens-core": "^2.2.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
package/src/create.ts
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
type TypedClientConfig,
|
|
34
34
|
} from "@sylphx/lens-client";
|
|
35
35
|
import type { MutationDef, QueryDef, RouterDef, RouterRoutes } from "@sylphx/lens-core";
|
|
36
|
-
import { type Accessor, createSignal, onCleanup } from "solid-js";
|
|
36
|
+
import { type Accessor, createEffect, createSignal, on, onCleanup } from "solid-js";
|
|
37
37
|
|
|
38
38
|
// =============================================================================
|
|
39
39
|
// Types
|
|
@@ -185,6 +185,23 @@ function createQueryPrimitiveFactory<TInput, TOutput>(
|
|
|
185
185
|
// Execute initial query
|
|
186
186
|
executeQuery();
|
|
187
187
|
|
|
188
|
+
// Watch for input/select changes using JSON.stringify for stable comparison
|
|
189
|
+
// This prevents re-fetching when object reference changes but content is the same
|
|
190
|
+
// Using on() with defer: true to skip initial run (already executed above)
|
|
191
|
+
createEffect(
|
|
192
|
+
on(
|
|
193
|
+
() => ({
|
|
194
|
+
inputKey: JSON.stringify(options?.input),
|
|
195
|
+
selectKey: JSON.stringify(options?.select),
|
|
196
|
+
skip: options?.skip,
|
|
197
|
+
}),
|
|
198
|
+
() => {
|
|
199
|
+
executeQuery();
|
|
200
|
+
},
|
|
201
|
+
{ defer: true },
|
|
202
|
+
),
|
|
203
|
+
);
|
|
204
|
+
|
|
188
205
|
onCleanup(() => {
|
|
189
206
|
if (unsubscribe) {
|
|
190
207
|
unsubscribe();
|
|
@@ -193,32 +210,7 @@ function createQueryPrimitiveFactory<TInput, TOutput>(
|
|
|
193
210
|
});
|
|
194
211
|
|
|
195
212
|
const refetch = () => {
|
|
196
|
-
|
|
197
|
-
unsubscribe();
|
|
198
|
-
unsubscribe = null;
|
|
199
|
-
}
|
|
200
|
-
setLoading(true);
|
|
201
|
-
setError(null);
|
|
202
|
-
const endpoint = getEndpoint();
|
|
203
|
-
const query = endpoint({ input: options?.input, select: options?.select });
|
|
204
|
-
if (query) {
|
|
205
|
-
unsubscribe = query.subscribe((value) => {
|
|
206
|
-
setData(() => value);
|
|
207
|
-
setLoading(false);
|
|
208
|
-
setError(null);
|
|
209
|
-
});
|
|
210
|
-
query.then(
|
|
211
|
-
(value) => {
|
|
212
|
-
setData(() => value);
|
|
213
|
-
setLoading(false);
|
|
214
|
-
},
|
|
215
|
-
(err) => {
|
|
216
|
-
const queryError = err instanceof Error ? err : new Error(String(err));
|
|
217
|
-
setError(queryError);
|
|
218
|
-
setLoading(false);
|
|
219
|
-
},
|
|
220
|
-
);
|
|
221
|
-
}
|
|
213
|
+
executeQuery();
|
|
222
214
|
};
|
|
223
215
|
|
|
224
216
|
return { data, loading, error, refetch };
|