@lunora/solid 1.0.0-alpha.24 → 1.0.0-alpha.25

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/index.mjs CHANGED
@@ -5,10 +5,10 @@ export { createAgentState } from './packem_shared/createAgentState-DckYu3G8.mjs'
5
5
  export { createAgentToolEvents } from './packem_shared/createAgentToolEvents-UavTO16u.mjs';
6
6
  export { AuthLoading, Authenticated, Unauthenticated, createAuth } from './packem_shared/AuthLoading-u5QJoV-J.mjs';
7
7
  export { default as createConnectionStatus } from './packem_shared/createConnectionStatus-1poqwqR9.mjs';
8
- export { createFlag, createFlags } from './packem_shared/createFlag-Bu9YfzcJ.mjs';
8
+ export { createFlag, createFlags } from './packem_shared/createFlag-DQoGdUMB.mjs';
9
9
  export { createMutation, createMutationForClient } from './packem_shared/createMutation-LkrbhItI.mjs';
10
10
  export { createMutator } from './packem_shared/createMutator-foSnPJPt.mjs';
11
- export { createInfiniteQuery, createPaginatedQuery } from './packem_shared/createInfiniteQuery-Dy9k7Px2.mjs';
11
+ export { createInfiniteQuery, createPaginatedQuery } from './packem_shared/createInfiniteQuery-DwajCO2G.mjs';
12
12
  export { createPresence } from './packem_shared/createPresence-DM2cVkiG.mjs';
13
13
  export { createQuery } from './packem_shared/createQuery-BUldvZXj.mjs';
14
14
  export { createRateLimit } from './packem_shared/createRateLimit-BA2f8XyF.mjs';
@@ -1,5 +1,5 @@
1
1
  import { createSignal, createEffect, on, onCleanup } from 'solid-js';
2
- import { s as stableStringify } from './stable-key-CGp4e2Ux.mjs';
2
+ import { s as stableStringify } from './stable-key-DePnevIy.mjs';
3
3
  import { useLunora } from './LunoraContext-C59PzHhN.mjs';
4
4
 
5
5
  const FLAGS_EVAL_PATH = "__lunora_flags__:eval";
@@ -1,8 +1,106 @@
1
1
  import { initialPages, derivePaginationStatus, rebalance, applyLoadMore } from '@lunora/client/pagination';
2
2
  import { createMemo, createSignal, createEffect, on, onCleanup } from 'solid-js';
3
- import { s as stableStringify } from './stable-key-CGp4e2Ux.mjs';
3
+ import { s as stableStringify } from './stable-key-DePnevIy.mjs';
4
4
  import { useLunora } from './LunoraContext-C59PzHhN.mjs';
5
5
 
6
+ const toBase64 = (bytes) => {
7
+ let binary = "";
8
+ const chunk = 32768;
9
+ for (let index = 0; index < bytes.length; index += chunk) {
10
+ binary += String.fromCharCode(...bytes.subarray(index, index + chunk));
11
+ }
12
+ return btoa(binary);
13
+ };
14
+
15
+ const TAG = "$lunora.wire$";
16
+ const MAX_DEPTH = 64;
17
+ const encodeWire = (value, depth = 0) => {
18
+ if (depth > MAX_DEPTH) {
19
+ throw new RangeError(`wire-codec: value nesting exceeds the ${MAX_DEPTH}-level limit`);
20
+ }
21
+ if (value === void 0) {
22
+ return [TAG, "undefined"];
23
+ }
24
+ if (value === null) {
25
+ return null;
26
+ }
27
+ const kind = typeof value;
28
+ if (kind === "bigint") {
29
+ return [TAG, "bigint", value.toString()];
30
+ }
31
+ if (kind === "number") {
32
+ const numeric = value;
33
+ if (Number.isNaN(numeric)) {
34
+ return [TAG, "nan"];
35
+ }
36
+ if (numeric === Infinity) {
37
+ return [TAG, "inf"];
38
+ }
39
+ if (numeric === -Infinity) {
40
+ return [TAG, "-inf"];
41
+ }
42
+ return numeric;
43
+ }
44
+ if (kind !== "object") {
45
+ return value;
46
+ }
47
+ if (value instanceof Date) {
48
+ return [TAG, "date", encodeWire(value.getTime(), depth + 1)];
49
+ }
50
+ if (value instanceof Error) {
51
+ const error = value;
52
+ const properties = {};
53
+ for (const key of Object.keys(error)) {
54
+ if (error[key] !== void 0) {
55
+ properties[key] = encodeWire(error[key], depth + 1);
56
+ }
57
+ }
58
+ const encodedError = [TAG, "error", error.name, error.message, properties];
59
+ if (error.cause !== void 0) {
60
+ encodedError.push(encodeWire(error.cause, depth + 1));
61
+ }
62
+ return encodedError;
63
+ }
64
+ if (value instanceof URL) {
65
+ return [TAG, "url", value.href];
66
+ }
67
+ if (value instanceof Map) {
68
+ return [TAG, "map", [...value.entries()].map(([k, v]) => [encodeWire(k, depth + 1), encodeWire(v, depth + 1)])];
69
+ }
70
+ if (value instanceof Set) {
71
+ return [TAG, "set", [...value].map((item) => encodeWire(item, depth + 1))];
72
+ }
73
+ if (value instanceof ArrayBuffer) {
74
+ return [TAG, "bytes", toBase64(new Uint8Array(value)), "ArrayBuffer"];
75
+ }
76
+ if (ArrayBuffer.isView(value)) {
77
+ const view = value;
78
+ const ctorName = view.constructor.name;
79
+ const bytes = new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
80
+ return ctorName === "Uint8Array" ? [TAG, "bytes", toBase64(bytes)] : [TAG, "bytes", toBase64(bytes), ctorName];
81
+ }
82
+ if (Array.isArray(value)) {
83
+ const encoded = value.map((item) => encodeWire(item, depth + 1));
84
+ return encoded.length > 0 && encoded[0] === TAG ? [TAG, "arr", encoded] : encoded;
85
+ }
86
+ const proto = Object.getPrototypeOf(value);
87
+ if (proto !== null && proto !== Object.prototype) {
88
+ const name = value.constructor?.name ?? "value";
89
+ throw new TypeError(`wire-codec: cannot encode a ${name} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`);
90
+ }
91
+ const source = value;
92
+ const result = {};
93
+ for (const key of Object.keys(source)) {
94
+ const field = source[key];
95
+ if (field !== void 0) {
96
+ result[key] = encodeWire(field, depth + 1);
97
+ }
98
+ }
99
+ return result;
100
+ };
101
+
102
+ const stableWireKey = (value) => stableStringify(encodeWire(value));
103
+
6
104
  const buildPageArgs = (page, baseArgs) => {
7
105
  return {
8
106
  ...baseArgs,
@@ -13,7 +111,7 @@ const buildPageArgs = (page, baseArgs) => {
13
111
  }
14
112
  };
15
113
  };
16
- const buildPageKey = (functionPath, pageArgs) => `${functionPath}::${stableStringify(pageArgs)}`;
114
+ const buildPageKey = (functionPath, pageArgs) => `${functionPath}::${stableWireKey(pageArgs)}`;
17
115
  const createPaginatedCore = (function_, args, options) => {
18
116
  const client = useLunora();
19
117
  const {
@@ -9,7 +9,7 @@ const stableStringify = (value) => {
9
9
  return "null";
10
10
  }
11
11
  if (typeof value === "bigint") {
12
- throw new TypeError("stableStringify: cannot use a bigint in a cache key (query/subscription/shape args) — pass it as a string");
12
+ throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");
13
13
  }
14
14
  if (value === null || typeof value !== "object") {
15
15
  return JSON.stringify(value);
@@ -20,7 +20,7 @@ const stableStringify = (value) => {
20
20
  const proto = Object.getPrototypeOf(value);
21
21
  if (proto !== null && proto !== Object.prototype) {
22
22
  const name = value.constructor?.name ?? "value";
23
- throw new TypeError(`stableStringify: cannot use a ${name} in a cache key (query/subscription/shape args) — only plain objects, arrays, and JSON primitives are supported`);
23
+ throw new TypeError(`stableStringify: cannot use a ${name} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`);
24
24
  }
25
25
  const record = value;
26
26
  const keys = Object.keys(record).toSorted(compareKeys);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/solid",
3
- "version": "1.0.0-alpha.24",
3
+ "version": "1.0.0-alpha.25",
4
4
  "description": "SolidJS adapter for Lunora — live queries, optimistic mutations, and reactive loaders",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -50,9 +50,9 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@lunora/client": "1.0.0-alpha.21",
54
- "@lunora/errors": "1.0.0-alpha.4",
55
- "@lunora/ratelimit": "1.0.0-alpha.7"
53
+ "@lunora/client": "1.0.0-alpha.23",
54
+ "@lunora/errors": "1.0.0-alpha.5",
55
+ "@lunora/ratelimit": "1.0.0-alpha.8"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "solid-js": "^1.9.0"