@lunora/vue 1.0.0-alpha.37 → 1.0.0-alpha.39
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 +3 -3
- package/dist/packem_shared/{stable-key-wv6eP48B.mjs → stable-key-C8JHuJL7.mjs} +2 -2
- package/dist/packem_shared/{useAgentChat-DWv4kfrT.mjs → useAgentChat-DQmekE-E.mjs} +23 -8
- package/dist/packem_shared/{useFlag-Cc8rtueb.mjs → useFlag-B8Gq7oUu.mjs} +1 -1
- package/dist/packem_shared/{useInfiniteQuery-ZnvrirrF.mjs → useInfiniteQuery-CMAUPQyd.mjs} +103 -3
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2,15 +2,15 @@ export { AuthLoading, Authenticated, Unauthenticated } from './packem_shared/Aut
|
|
|
2
2
|
export { hydratePreloaded } from './packem_shared/hydratePreloaded-Cnd2GmG1.mjs';
|
|
3
3
|
export { LUNORA_INJECTION_KEY, createLunora, provideLunora, useLunora } from './packem_shared/LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
4
4
|
export { useAgent } from './packem_shared/useAgent-TEp9OWs3.mjs';
|
|
5
|
-
export { useAgentChat } from './packem_shared/useAgentChat-
|
|
5
|
+
export { useAgentChat } from './packem_shared/useAgentChat-DQmekE-E.mjs';
|
|
6
6
|
export { useAgentState } from './packem_shared/useAgentState-CeDpLTib.mjs';
|
|
7
7
|
export { useAgentToolEvents } from './packem_shared/useAgentToolEvents-DfCy9INR.mjs';
|
|
8
8
|
export { useAuth } from './packem_shared/useAuth-yXaaF-ro.mjs';
|
|
9
9
|
export { default as useConnectionStatus } from './packem_shared/useConnectionStatus-DM_TOaW5.mjs';
|
|
10
|
-
export { useFlag, useFlags } from './packem_shared/useFlag-
|
|
10
|
+
export { useFlag, useFlags } from './packem_shared/useFlag-B8Gq7oUu.mjs';
|
|
11
11
|
export { useMutation } from './packem_shared/useMutation-BKIwT8Jk.mjs';
|
|
12
12
|
export { useMutator } from './packem_shared/useMutator-B_Ahs_ZN.mjs';
|
|
13
|
-
export { useInfiniteQuery, usePaginatedQuery } from './packem_shared/useInfiniteQuery-
|
|
13
|
+
export { useInfiniteQuery, usePaginatedQuery } from './packem_shared/useInfiniteQuery-CMAUPQyd.mjs';
|
|
14
14
|
export { usePresence } from './packem_shared/usePresence-Bg671Pt0.mjs';
|
|
15
15
|
export { subscribeToQuery, useQuery } from './packem_shared/subscribeToQuery-hVYyvgOD.mjs';
|
|
16
16
|
export { useRateLimit } from './packem_shared/useRateLimit-DlPWjcX1.mjs';
|
|
@@ -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
|
|
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);
|
|
@@ -21,7 +21,7 @@ const stableStringify = (value) => {
|
|
|
21
21
|
if (proto !== null && proto !== Object.prototype) {
|
|
22
22
|
const name = value.constructor?.name ?? "value";
|
|
23
23
|
throw new TypeError(
|
|
24
|
-
`stableStringify: cannot use a ${name} in a cache key
|
|
24
|
+
`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)`
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
const record = value;
|
|
@@ -6,12 +6,15 @@ import { useSubscription } from './useSubscription-B2s-lc5e.mjs';
|
|
|
6
6
|
|
|
7
7
|
const NO_STREAM_REF = { __lunoraRef: "" };
|
|
8
8
|
const reconcileOptimistic = (optimistic, durable) => {
|
|
9
|
-
const
|
|
9
|
+
const durableUserRows = durable.filter((message) => message.role === "user");
|
|
10
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
10
11
|
return optimistic.filter((pending) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
for (let index = pending.durableUserCountAtSend; index < durableUserRows.length; index += 1) {
|
|
13
|
+
const row = durableUserRows[index];
|
|
14
|
+
if (row !== void 0 && !consumed.has(index) && row.content === pending.content) {
|
|
15
|
+
consumed.add(index);
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
15
18
|
}
|
|
16
19
|
return true;
|
|
17
20
|
});
|
|
@@ -43,6 +46,12 @@ const useAgentChat = (options) => {
|
|
|
43
46
|
if (visible.length === 0) {
|
|
44
47
|
return rows;
|
|
45
48
|
}
|
|
49
|
+
let maxDurableSeq = -1;
|
|
50
|
+
for (const message of rows) {
|
|
51
|
+
if (message.seq > maxDurableSeq) {
|
|
52
|
+
maxDurableSeq = message.seq;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
46
55
|
return [
|
|
47
56
|
...rows,
|
|
48
57
|
...visible.map((pending, index) => {
|
|
@@ -50,7 +59,7 @@ const useAgentChat = (options) => {
|
|
|
50
59
|
content: pending.content,
|
|
51
60
|
optimistic: true,
|
|
52
61
|
role: "user",
|
|
53
|
-
seq:
|
|
62
|
+
seq: maxDurableSeq + 1 + index
|
|
54
63
|
};
|
|
55
64
|
})
|
|
56
65
|
];
|
|
@@ -63,8 +72,14 @@ const useAgentChat = (options) => {
|
|
|
63
72
|
const send = async (input, arguments_) => {
|
|
64
73
|
const id = nextId;
|
|
65
74
|
nextId += 1;
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
const durableUserCountAtSend = durable.value.filter((message) => message.role === "user").length;
|
|
76
|
+
optimistic.value = [...reconcileOptimistic(optimistic.value, durable.value), { content: input, durableUserCountAtSend, id }];
|
|
77
|
+
try {
|
|
78
|
+
await sendMutation.mutate({ input, threadKey: toValue(threadKey), ...sendArgs, ...arguments_ });
|
|
79
|
+
} catch (error) {
|
|
80
|
+
optimistic.value = optimistic.value.filter((pending) => pending.id !== id);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
68
83
|
};
|
|
69
84
|
const approve = async (toolCallId, note) => {
|
|
70
85
|
const instanceId = thread.value?.instanceId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shallowRef, watch, toValue } from 'vue';
|
|
2
|
-
import { s as stableStringify } from './stable-key-
|
|
2
|
+
import { s as stableStringify } from './stable-key-C8JHuJL7.mjs';
|
|
3
3
|
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
4
4
|
|
|
5
5
|
const FLAGS_EVAL_PATH = "__lunora_flags__:eval";
|
|
@@ -1,9 +1,109 @@
|
|
|
1
1
|
import { shallowRef, watch, toValue, onScopeDispose, computed } from 'vue';
|
|
2
2
|
import { initialPages, derivePaginationStatus, rebalance, applyLoadMore } from '@lunora/client/pagination';
|
|
3
|
-
import { s as stableStringify } from './stable-key-
|
|
3
|
+
import { s as stableStringify } from './stable-key-C8JHuJL7.mjs';
|
|
4
4
|
import { useLunora } from './LUNORA_INJECTION_KEY-DQM5MgsC.mjs';
|
|
5
5
|
|
|
6
|
-
const
|
|
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(
|
|
90
|
+
`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`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
const source = value;
|
|
94
|
+
const result = {};
|
|
95
|
+
for (const key of Object.keys(source)) {
|
|
96
|
+
const field = source[key];
|
|
97
|
+
if (field !== void 0) {
|
|
98
|
+
result[key] = encodeWire(field, depth + 1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const stableWireKey = (value) => stableStringify(encodeWire(value));
|
|
105
|
+
|
|
106
|
+
const buildPageKey = (functionPath, pageArgs) => `${functionPath}::${stableWireKey(pageArgs)}`;
|
|
7
107
|
const buildPageArgs = (page, baseArgs) => {
|
|
8
108
|
return {
|
|
9
109
|
...baseArgs,
|
|
@@ -99,7 +199,7 @@ const usePaginatedCore = (function_, args, options) => {
|
|
|
99
199
|
pendingPageKeys.clear();
|
|
100
200
|
};
|
|
101
201
|
watch(
|
|
102
|
-
() =>
|
|
202
|
+
() => stableWireKey(toValue(args)),
|
|
103
203
|
() => {
|
|
104
204
|
const current = toValue(args);
|
|
105
205
|
teardownAll();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/vue",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.39",
|
|
4
4
|
"description": "Vue adapter for Lunora — live composables, optimistic mutations, and reactive loaders",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@lunora/client": "1.0.0-alpha.
|
|
58
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
59
|
-
"@lunora/ratelimit": "1.0.0-alpha.
|
|
60
|
-
"@lunora/runtime": "1.0.0-alpha.
|
|
57
|
+
"@lunora/client": "1.0.0-alpha.24",
|
|
58
|
+
"@lunora/errors": "1.0.0-alpha.5",
|
|
59
|
+
"@lunora/ratelimit": "1.0.0-alpha.8",
|
|
60
|
+
"@lunora/runtime": "1.0.0-alpha.28"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"vue": "^3.5.0"
|