@ai4b-team/fsaos-gateway-sdk 5.6.1 → 5.7.0
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 +26 -0
- package/dist/iife/gateway.js +5 -5
- package/dist/iife/gateway.js.map +4 -4
- package/dist/iife/ui.js +1 -1
- package/dist/index.cjs +269 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -4
- package/dist/index.d.ts +56 -4
- package/dist/index.js +266 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/iife/ui.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @fsaos/ui v2.0.0 — FSAOS UI Primitives — 2026-11-
|
|
1
|
+
/* @fsaos/ui v2.0.0 — FSAOS UI Primitives — 2026-11-16T03:22:12.647Z */
|
|
2
2
|
"use strict";var __FSAOS_UI__=(()=>{var m=Object.create;var r=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var y=(e,i)=>()=>(i||e((i={exports:{}}).exports,i),i.exports),N=(e,i)=>{for(var a in i)r(e,a,{get:i[a],enumerable:!0})},s=(e,i,a,l)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of u(i))!h.call(e,t)&&t!==a&&r(e,t,{get:()=>i[t],enumerable:!(l=g(i,t))||l.enumerable});return e};var x=(e,i,a)=>(a=e!=null?m(f(e)):{},s(i||!e||!e.__esModule?r(a,"default",{value:e,enumerable:!0}):a,e)),b=e=>s(r({},"__esModule",{value:!0}),e);var d=y((V,c)=>{c.exports=React});var P={};N(P,{Badge:()=>z,Breadcrumbs:()=>A,Button:()=>D,Card:()=>w,DataView:()=>R,Detail:()=>_,Empty:()=>I,FilePreview:()=>O,Form:()=>F,Grid:()=>k,Image:()=>G,Link:()=>E,Page:()=>v,Router:()=>T,Sidebar:()=>S,Spinner:()=>B,Stack:()=>C,Table:()=>j,Tabs:()=>W,Video:()=>H});var n=x(d(),1);function o(){return(typeof window<"u"&&window.__FSAOS_CONFIG__||{}).edgeBaseUrl||""}function v(e){return(0,n.createElement)("div",{style:{minHeight:"100vh",display:"flex",flexDirection:"column"},className:e.className||""},e.children)}function C(e){let i=e.direction||"vertical";return(0,n.createElement)("div",{style:{display:"flex",flexDirection:i==="horizontal"?"row":"column",gap:e.gap||"0.5rem",padding:e.padding||"0",alignItems:e.align||"stretch",justifyContent:e.justify||"flex-start",flex:e.flex||"initial"},className:e.className||""},e.children)}function k(e){return(0,n.createElement)("div",{style:{display:"grid",gridTemplateColumns:"repeat("+(e.columns||3)+", 1fr)",gap:e.gap||"1rem",padding:e.padding||"0"},className:e.className||""},e.children)}function S(e){return(0,n.createElement)("div",{style:{display:"flex",flexDirection:"row",minHeight:"100vh"},className:e.className||""},e.children)}function w(e){return(0,n.createElement)("div",{style:{border:"1px solid var(--color-border, #e5e7eb)",borderRadius:"var(--border-radius, 0.5rem)",padding:e.padding||"1rem",background:"var(--color-surface, #fff)"},className:e.className||"",onClick:e.onClick},e.children)}function z(e){return(0,n.createElement)("span",{style:{display:"inline-flex",alignItems:"center",padding:"0.125rem 0.5rem",fontSize:"0.75rem",fontWeight:"500",borderRadius:"9999px",background:e.color||"#e5e7eb",color:e.textColor||"#374151"},className:e.className||""},e.children||e.label)}function B(e){let i=e.size||"1.5rem";return(0,n.createElement)("div",{style:{width:i,height:i,border:"2px solid #e5e7eb",borderTopColor:"var(--color-primary, #3b82f6)",borderRadius:"50%",animation:"fsaos-spin 0.6s linear infinite"}})}function D(e){return(0,n.createElement)("button",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",padding:"0.5rem 1rem",fontSize:"0.875rem",fontWeight:"500",borderRadius:"var(--border-radius, 0.375rem)",border:e.variant==="outline"?"1px solid var(--color-border, #d1d5db)":"none",background:e.variant==="outline"||e.variant==="ghost"?"transparent":"var(--color-primary, #3b82f6)",color:e.variant==="outline"||e.variant==="ghost"?"var(--color-text, #1a1a1a)":"#fff",cursor:e.disabled?"not-allowed":"pointer",opacity:e.disabled?"0.5":"1",gap:"0.5rem"},className:e.className||"",onClick:e.onClick,disabled:e.disabled},e.children||e.label)}function I(e){return(0,n.createElement)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"3rem",color:"var(--color-text-secondary, #6b7280)",textAlign:"center"}},e.icon?(0,n.createElement)("div",{style:{fontSize:"2rem",marginBottom:"0.5rem"}},e.icon):null,(0,n.createElement)("div",{style:{fontWeight:500,marginBottom:"0.25rem"}},e.title||e.message||e.children||"No items"),e.description?(0,n.createElement)("div",{style:{fontSize:"0.875rem",opacity:.7}},e.description):null)}function R(e){return(0,n.createElement)("div",{className:e.className||""},e.children)}function j(e){return(0,n.createElement)("table",{className:e.className||""},e.children)}function F(e){return(0,n.createElement)("form",{className:e.className||"",onSubmit:e.onSubmit},e.children)}function _(e){return(0,n.createElement)("div",{className:e.className||""},e.children)}function T(e){return(0,n.createElement)("div",null,e.children)}function E(e){return(0,n.createElement)("a",{href:e.href||e.to,className:e.className||"",onClick:e.onClick},e.children)}function W(e){return(0,n.createElement)("div",{className:e.className||""},e.children)}function A(e){return(0,n.createElement)("nav",{className:e.className||""},e.children)}function G(e){return(0,n.createElement)("img",{src:e.src||(e.path?o()+e.path:""),alt:e.alt||"",className:e.className||"",style:e.style})}function H(e){return(0,n.createElement)("video",{src:e.src||(e.path?o()+e.path:""),controls:!0,className:e.className||""})}function O(e){return(0,n.createElement)("div",{className:e.className||""},e.children||"File preview")}return b(P);})();
|
|
3
3
|
//# sourceMappingURL=ui.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -92,6 +92,8 @@ __export(src_exports, {
|
|
|
92
92
|
fetchVfsItem: () => fetchVfsItem,
|
|
93
93
|
fetchVfsItemById: () => fetchVfsItemById,
|
|
94
94
|
fetchVfsTree: () => fetchVfsTree,
|
|
95
|
+
filePurchaseNextUrl: () => filePurchaseNextUrl,
|
|
96
|
+
funnelCheckoutLink: () => funnelCheckoutLink,
|
|
95
97
|
gatewayCall: () => gatewayCall,
|
|
96
98
|
getAccessToken: () => getAccessToken,
|
|
97
99
|
getAnchor: () => getAnchor,
|
|
@@ -99,6 +101,7 @@ __export(src_exports, {
|
|
|
99
101
|
getAnchorVersion: () => getAnchorVersion,
|
|
100
102
|
getAssetUrl: () => getAssetUrl,
|
|
101
103
|
getDefaultSort: () => getDefaultSort,
|
|
104
|
+
getFilePurchase: () => getFilePurchase,
|
|
102
105
|
getHomeAnchor: () => getHomeAnchor,
|
|
103
106
|
getInvitation: () => getInvitation,
|
|
104
107
|
getMountVersion: () => getMountVersion,
|
|
@@ -166,6 +169,7 @@ __export(src_exports, {
|
|
|
166
169
|
setScope: () => setScope,
|
|
167
170
|
setupRequireShim: () => setupRequireShim,
|
|
168
171
|
signal: () => signal,
|
|
172
|
+
startFileCheckout: () => startFileCheckout,
|
|
169
173
|
startTracking: () => startTracking,
|
|
170
174
|
steerTurn: () => steerTurn,
|
|
171
175
|
submitForm: () => submitForm,
|
|
@@ -1771,7 +1775,7 @@ function normalizeItem(raw) {
|
|
|
1771
1775
|
const path = raw.path || raw.item_path || "";
|
|
1772
1776
|
const segments = path.split("/");
|
|
1773
1777
|
segments.pop();
|
|
1774
|
-
const
|
|
1778
|
+
const parentPath2 = segments.join("/");
|
|
1775
1779
|
const typeData = raw.type_data || {};
|
|
1776
1780
|
if (typeData.allowed_parent_types && !typeData.accepts) {
|
|
1777
1781
|
typeData.accepts = typeData.allowed_parent_types;
|
|
@@ -1782,7 +1786,7 @@ function normalizeItem(raw) {
|
|
|
1782
1786
|
name: raw.name || raw.item_name || "",
|
|
1783
1787
|
item_type: raw.item_type || "unknown",
|
|
1784
1788
|
path,
|
|
1785
|
-
parent_path:
|
|
1789
|
+
parent_path: parentPath2,
|
|
1786
1790
|
is_active: raw.is_active !== false,
|
|
1787
1791
|
has_children: raw.has_children ?? false,
|
|
1788
1792
|
created_at: raw.created_at || nowISO(),
|
|
@@ -2413,9 +2417,9 @@ function invalidatePathAndParent(path, fallbackParent) {
|
|
|
2413
2417
|
invalidateChildren(path);
|
|
2414
2418
|
const segments = path.split("/");
|
|
2415
2419
|
segments.pop();
|
|
2416
|
-
const
|
|
2417
|
-
if (
|
|
2418
|
-
invalidateChildren(
|
|
2420
|
+
const parentPath2 = segments.join("/") || fallbackParent;
|
|
2421
|
+
if (parentPath2) {
|
|
2422
|
+
invalidateChildren(parentPath2);
|
|
2419
2423
|
}
|
|
2420
2424
|
}
|
|
2421
2425
|
function invalidateSubtree(path) {
|
|
@@ -2553,22 +2557,22 @@ function handleVfsChange(data) {
|
|
|
2553
2557
|
if (!path) return;
|
|
2554
2558
|
const segments = path.split("/");
|
|
2555
2559
|
segments.pop();
|
|
2556
|
-
const
|
|
2557
|
-
let changes = pendingChanges.get(
|
|
2560
|
+
const parentPath2 = segments.join("/") || "/root";
|
|
2561
|
+
let changes = pendingChanges.get(parentPath2);
|
|
2558
2562
|
if (!changes) {
|
|
2559
2563
|
changes = /* @__PURE__ */ new Map();
|
|
2560
|
-
pendingChanges.set(
|
|
2564
|
+
pendingChanges.set(parentPath2, changes);
|
|
2561
2565
|
}
|
|
2562
2566
|
changes.set(path, { action, itemId: typeof data.item_id === "string" ? data.item_id : void 0 });
|
|
2563
|
-
const existing = debounceTimers.get(
|
|
2567
|
+
const existing = debounceTimers.get(parentPath2);
|
|
2564
2568
|
if (existing) clearTimeout(existing);
|
|
2565
2569
|
const timer = setTimeout(() => {
|
|
2566
|
-
debounceTimers.delete(
|
|
2567
|
-
const flushed = pendingChanges.get(
|
|
2568
|
-
pendingChanges.delete(
|
|
2569
|
-
if (flushed) applyInvalidation(
|
|
2570
|
+
debounceTimers.delete(parentPath2);
|
|
2571
|
+
const flushed = pendingChanges.get(parentPath2);
|
|
2572
|
+
pendingChanges.delete(parentPath2);
|
|
2573
|
+
if (flushed) applyInvalidation(parentPath2, flushed);
|
|
2570
2574
|
}, DEBOUNCE_MS);
|
|
2571
|
-
debounceTimers.set(
|
|
2575
|
+
debounceTimers.set(parentPath2, timer);
|
|
2572
2576
|
}
|
|
2573
2577
|
function handleCcmChange(data) {
|
|
2574
2578
|
if (!data || typeof data !== "object") return;
|
|
@@ -2590,7 +2594,7 @@ function handleCcmChange(data) {
|
|
|
2590
2594
|
}, DEBOUNCE_MS);
|
|
2591
2595
|
debounceTimers.set(debounceKey, timer);
|
|
2592
2596
|
}
|
|
2593
|
-
function applyInvalidation(
|
|
2597
|
+
function applyInvalidation(parentPath2, changes) {
|
|
2594
2598
|
const client2 = getQueryClient();
|
|
2595
2599
|
for (const [path, change] of changes) {
|
|
2596
2600
|
if ((change.action || "").toUpperCase() === "DELETE") {
|
|
@@ -2604,7 +2608,7 @@ function applyInvalidation(parentPath, changes) {
|
|
|
2604
2608
|
client2.invalidateQueries({ queryKey: vfsKeys.itemById(change.itemId) });
|
|
2605
2609
|
}
|
|
2606
2610
|
}
|
|
2607
|
-
client2.invalidateQueries({ queryKey: vfsKeys.children(
|
|
2611
|
+
client2.invalidateQueries({ queryKey: vfsKeys.children(parentPath2) });
|
|
2608
2612
|
const changed = [...changes.keys()];
|
|
2609
2613
|
client2.invalidateQueries({
|
|
2610
2614
|
predicate: (query) => {
|
|
@@ -2979,9 +2983,57 @@ function channelMessageChange(event, channelPath, parentId, messages) {
|
|
|
2979
2983
|
});
|
|
2980
2984
|
}
|
|
2981
2985
|
|
|
2982
|
-
// src/channel-realtime.ts
|
|
2986
|
+
// src/channel-transcript-realtime.ts
|
|
2983
2987
|
var watches = /* @__PURE__ */ new WeakMap();
|
|
2984
|
-
|
|
2988
|
+
var parentPath = (path) => path.slice(0, path.lastIndexOf("/"));
|
|
2989
|
+
var actionOf = (change) => change.action?.toLowerCase();
|
|
2990
|
+
function isNewPost(change, channel) {
|
|
2991
|
+
return change.item_type === "message" && actionOf(change) === "insert" && parentPath(change.path) === channel && !change.old_path;
|
|
2992
|
+
}
|
|
2993
|
+
function affectedMessages(page, ids, paths) {
|
|
2994
|
+
return page.messages.filter((message) => ids.has(message.id) || paths.has(message.path));
|
|
2995
|
+
}
|
|
2996
|
+
function updateTranscript(cached, targets, revised, tail) {
|
|
2997
|
+
const pages = cached.pages.slice();
|
|
2998
|
+
const replacements = new Map(revised?.messages.map((message) => [message.id, message]));
|
|
2999
|
+
for (const [index, affected] of targets) {
|
|
3000
|
+
const page = pages[index];
|
|
3001
|
+
const wanted = new Set(affected.map((message) => message.id));
|
|
3002
|
+
const messageCards2 = new Map(page.messageCards);
|
|
3003
|
+
for (const message of affected) {
|
|
3004
|
+
messageCards2.delete(message.path);
|
|
3005
|
+
const replacement = replacements.get(message.id);
|
|
3006
|
+
const cards = replacement && revised?.messageCards.get(replacement.path);
|
|
3007
|
+
if (replacement && cards?.length) messageCards2.set(replacement.path, cards);
|
|
3008
|
+
}
|
|
3009
|
+
pages[index] = {
|
|
3010
|
+
...page,
|
|
3011
|
+
messages: page.messages.flatMap((message) => {
|
|
3012
|
+
if (!wanted.has(message.id)) return [message];
|
|
3013
|
+
const replacement = replacements.get(message.id);
|
|
3014
|
+
return replacement ? [replacement] : [];
|
|
3015
|
+
}),
|
|
3016
|
+
messageCards: messageCards2
|
|
3017
|
+
};
|
|
3018
|
+
}
|
|
3019
|
+
const snapshot = tail ?? revised;
|
|
3020
|
+
const latest = pages[0];
|
|
3021
|
+
const messageCards = new Map(latest.messageCards);
|
|
3022
|
+
for (const message of latest.activityMessages ?? []) messageCards.delete(message.path);
|
|
3023
|
+
for (const message of [...snapshot.activityMessages ?? [], ...tail?.messages ?? []]) {
|
|
3024
|
+
const cards = snapshot.messageCards.get(message.path);
|
|
3025
|
+
if (cards?.length) messageCards.set(message.path, cards);
|
|
3026
|
+
}
|
|
3027
|
+
pages[0] = {
|
|
3028
|
+
...latest,
|
|
3029
|
+
messages: tail ? [...latest.messages, ...tail.messages] : latest.messages,
|
|
3030
|
+
activityMessages: snapshot.activityMessages,
|
|
3031
|
+
siblingCards: snapshot.siblingCards,
|
|
3032
|
+
messageCards
|
|
3033
|
+
};
|
|
3034
|
+
return { ...cached, pages };
|
|
3035
|
+
}
|
|
3036
|
+
function watchChannelTranscript(client2, key, channel, limit) {
|
|
2985
3037
|
let entries = watches.get(client2);
|
|
2986
3038
|
if (!entries) {
|
|
2987
3039
|
entries = /* @__PURE__ */ new Map();
|
|
@@ -2989,6 +3041,133 @@ function watchChannels(client2, key, normalize) {
|
|
|
2989
3041
|
}
|
|
2990
3042
|
const hash = JSON.stringify(key);
|
|
2991
3043
|
let watch = entries.get(hash);
|
|
3044
|
+
if (!watch) {
|
|
3045
|
+
let timer;
|
|
3046
|
+
let running2 = false;
|
|
3047
|
+
let stopped = false;
|
|
3048
|
+
const pending4 = /* @__PURE__ */ new Map();
|
|
3049
|
+
const current = () => client2.getQueryData(key);
|
|
3050
|
+
const query = () => client2.getQueryCache().find({ queryKey: key, exact: true });
|
|
3051
|
+
const reload = () => refreshQuery(client2, key, { exact: true });
|
|
3052
|
+
const read = (after_seq, before_seq) => fetchChannelMessagesPage(channel, { transcriptOnly: true, limit, after_seq, before_seq });
|
|
3053
|
+
const schedule2 = () => {
|
|
3054
|
+
if (stopped || running2 || timer || !pending4.size) return;
|
|
3055
|
+
timer = setTimeout(() => {
|
|
3056
|
+
timer = void 0;
|
|
3057
|
+
void flush();
|
|
3058
|
+
}, 500);
|
|
3059
|
+
};
|
|
3060
|
+
const flush = async () => {
|
|
3061
|
+
running2 = true;
|
|
3062
|
+
const changes = [...pending4.values()];
|
|
3063
|
+
pending4.clear();
|
|
3064
|
+
const owner = query();
|
|
3065
|
+
try {
|
|
3066
|
+
if (owner?.state.fetchStatus === "fetching") await owner.promise?.catch(() => void 0);
|
|
3067
|
+
if (stopped || owner !== query()) return;
|
|
3068
|
+
const cached = current();
|
|
3069
|
+
if (!cached?.pages.length) {
|
|
3070
|
+
await reload();
|
|
3071
|
+
return;
|
|
3072
|
+
}
|
|
3073
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3074
|
+
const paths = /* @__PURE__ */ new Set();
|
|
3075
|
+
const possiblyAdmitted = /* @__PURE__ */ new Set();
|
|
3076
|
+
let append = false;
|
|
3077
|
+
for (const change of changes) {
|
|
3078
|
+
if (isNewPost(change, channel)) {
|
|
3079
|
+
append = true;
|
|
3080
|
+
continue;
|
|
3081
|
+
}
|
|
3082
|
+
if (change.inserted) append = true;
|
|
3083
|
+
if (change.item_type === "message" && parentPath(change.path) === channel && !change.inserted && actionOf(change) !== "delete") possiblyAdmitted.add(change.path);
|
|
3084
|
+
if (change.item_id) ids.add(change.item_id);
|
|
3085
|
+
if (change.parent_id) ids.add(change.parent_id);
|
|
3086
|
+
for (const path of [change.path, change.old_path]) {
|
|
3087
|
+
if (path && isChannelPath(path, channel)) {
|
|
3088
|
+
paths.add(path);
|
|
3089
|
+
paths.add(parentPath(path));
|
|
3090
|
+
}
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
const targets = /* @__PURE__ */ new Map();
|
|
3094
|
+
let low = Infinity;
|
|
3095
|
+
let high = 0;
|
|
3096
|
+
if (ids.size || paths.size) {
|
|
3097
|
+
cached.pages.forEach((page, index) => {
|
|
3098
|
+
const affected = affectedMessages(page, ids, paths);
|
|
3099
|
+
if (affected.length) targets.set(index, affected);
|
|
3100
|
+
for (const message of affected) {
|
|
3101
|
+
possiblyAdmitted.delete(message.path);
|
|
3102
|
+
low = Math.min(low, message.seq);
|
|
3103
|
+
high = Math.max(high, message.seq);
|
|
3104
|
+
}
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
for (const activity of cached.pages[0].activityMessages ?? []) possiblyAdmitted.delete(activity.path);
|
|
3108
|
+
if (possiblyAdmitted.size) {
|
|
3109
|
+
await reload();
|
|
3110
|
+
return;
|
|
3111
|
+
}
|
|
3112
|
+
if (targets.size && (!Number.isSafeInteger(low) || low < 1 || !Number.isSafeInteger(high + 1))) {
|
|
3113
|
+
await reload();
|
|
3114
|
+
return;
|
|
3115
|
+
}
|
|
3116
|
+
const latest = cached.pages.find((page) => page.messages.length)?.messages.at(-1)?.seq ?? 0;
|
|
3117
|
+
const [revised, tail] = await Promise.all([
|
|
3118
|
+
targets.size ? read(low - 1, high + 1) : void 0,
|
|
3119
|
+
append || !targets.size ? read(latest) : void 0
|
|
3120
|
+
]);
|
|
3121
|
+
if (stopped || owner !== query()) return;
|
|
3122
|
+
const settled = current();
|
|
3123
|
+
if (owner?.state.fetchStatus === "fetching" || cached.pages.some((page, index) => settled?.pages[index] !== page) || revised && revised.messages.length >= limit && (revised.messages.at(-1)?.seq ?? 0) < high || tail && tail.messages.length >= limit) {
|
|
3124
|
+
await reload();
|
|
3125
|
+
return;
|
|
3126
|
+
}
|
|
3127
|
+
client2.setQueryData(key, (data) => data && updateTranscript(data, targets, revised, tail));
|
|
3128
|
+
} catch {
|
|
3129
|
+
if (!stopped && owner === query()) await reload();
|
|
3130
|
+
} finally {
|
|
3131
|
+
running2 = false;
|
|
3132
|
+
schedule2();
|
|
3133
|
+
}
|
|
3134
|
+
};
|
|
3135
|
+
const stop = subscribeToEvents("vfs_change", (change) => {
|
|
3136
|
+
const id = change.item_id ?? change.path;
|
|
3137
|
+
const previous = pending4.get(id);
|
|
3138
|
+
pending4.set(id, previous && (previous.inserted || isNewPost(previous, channel)) && actionOf(change) === "update" && previous.path === change.path ? { ...change, inserted: true } : change);
|
|
3139
|
+
schedule2();
|
|
3140
|
+
}, (change) => channelMessageChange(change, channel, void 0, []) || !!change.old_path && channelMessageChange({ ...change, path: change.old_path }, channel, void 0, []) || change.item_type === "message" && !!change.parent_id && isChannelPath(change.path, channel) && !!current()?.pages.some((page) => page.messages.some((root) => root.id === change.parent_id)));
|
|
3141
|
+
watch = { users: 0, stop: () => {
|
|
3142
|
+
stopped = true;
|
|
3143
|
+
stop();
|
|
3144
|
+
if (timer) clearTimeout(timer);
|
|
3145
|
+
pending4.clear();
|
|
3146
|
+
} };
|
|
3147
|
+
entries.set(hash, watch);
|
|
3148
|
+
}
|
|
3149
|
+
watch.users++;
|
|
3150
|
+
let released = false;
|
|
3151
|
+
return () => {
|
|
3152
|
+
if (released) return;
|
|
3153
|
+
released = true;
|
|
3154
|
+
if (--watch.users === 0) {
|
|
3155
|
+
watch.stop();
|
|
3156
|
+
entries.delete(hash);
|
|
3157
|
+
}
|
|
3158
|
+
};
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
// src/channel-realtime.ts
|
|
3162
|
+
var watches2 = /* @__PURE__ */ new WeakMap();
|
|
3163
|
+
function watchChannels(client2, key, normalize) {
|
|
3164
|
+
let entries = watches2.get(client2);
|
|
3165
|
+
if (!entries) {
|
|
3166
|
+
entries = /* @__PURE__ */ new Map();
|
|
3167
|
+
watches2.set(client2, entries);
|
|
3168
|
+
}
|
|
3169
|
+
const hash = JSON.stringify(key);
|
|
3170
|
+
let watch = entries.get(hash);
|
|
2992
3171
|
if (!watch) {
|
|
2993
3172
|
let stopped = false;
|
|
2994
3173
|
let timer;
|
|
@@ -3104,12 +3283,12 @@ function watchChannels(client2, key, normalize) {
|
|
|
3104
3283
|
}
|
|
3105
3284
|
|
|
3106
3285
|
// src/message-replies-realtime.ts
|
|
3107
|
-
var
|
|
3286
|
+
var watches3 = /* @__PURE__ */ new WeakMap();
|
|
3108
3287
|
function watchMessageReplies(client2, key, target) {
|
|
3109
|
-
let entries =
|
|
3288
|
+
let entries = watches3.get(client2);
|
|
3110
3289
|
if (!entries) {
|
|
3111
3290
|
entries = /* @__PURE__ */ new Map();
|
|
3112
|
-
|
|
3291
|
+
watches3.set(client2, entries);
|
|
3113
3292
|
}
|
|
3114
3293
|
const hash = JSON.stringify(key);
|
|
3115
3294
|
let watch = entries.get(hash);
|
|
@@ -4592,14 +4771,14 @@ function useMessageReplies(options) {
|
|
|
4592
4771
|
return { ...query, messages };
|
|
4593
4772
|
}
|
|
4594
4773
|
function useInfiniteChannelMessages(options) {
|
|
4595
|
-
useScopeKey();
|
|
4774
|
+
const scopeKey = useScopeKey();
|
|
4596
4775
|
const { channelPath, parentMessageId, limit = 50, realtime = true, enabled: enabled2 = true, conversationsOnly = false, transcriptOnly = false } = options;
|
|
4597
4776
|
const isThread = !!parentMessageId;
|
|
4598
4777
|
const queryEnabled = enabled2 && !!channelPath;
|
|
4599
4778
|
const query = reactQuery.useInfiniteQuery({
|
|
4600
4779
|
queryKey: [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit, "latest-first", ...conversationsOnly ? ["conversations"] : [], ...transcriptOnly ? ["transcript"] : []],
|
|
4601
4780
|
queryFn: async ({ pageParam }) => {
|
|
4602
|
-
|
|
4781
|
+
const page = await fetchChannelMessagesPage(channelPath, {
|
|
4603
4782
|
parentMessageId,
|
|
4604
4783
|
limit,
|
|
4605
4784
|
conversationsOnly,
|
|
@@ -4607,6 +4786,7 @@ function useInfiniteChannelMessages(options) {
|
|
|
4607
4786
|
before_seq: pageParam?.before_seq,
|
|
4608
4787
|
after_seq: pageParam?.after_seq
|
|
4609
4788
|
});
|
|
4789
|
+
return transcriptOnly && page.messages.length >= limit ? { ...page, olderBefore: page.messages[0]?.seq } : page;
|
|
4610
4790
|
},
|
|
4611
4791
|
initialPageParam: void 0,
|
|
4612
4792
|
getPreviousPageParam: (lastPage) => {
|
|
@@ -4616,6 +4796,7 @@ function useInfiniteChannelMessages(options) {
|
|
|
4616
4796
|
return maxSeq == null ? void 0 : { after_seq: maxSeq };
|
|
4617
4797
|
},
|
|
4618
4798
|
getNextPageParam: (firstPage) => {
|
|
4799
|
+
if (transcriptOnly) return firstPage.olderBefore == null ? void 0 : { before_seq: firstPage.olderBefore };
|
|
4619
4800
|
if (firstPage.messages.length < limit) return void 0;
|
|
4620
4801
|
const minSeq = firstPage.messages[0]?.seq;
|
|
4621
4802
|
return minSeq == null ? void 0 : { before_seq: minSeq };
|
|
@@ -4641,8 +4822,10 @@ function useInfiniteChannelMessages(options) {
|
|
|
4641
4822
|
const sc = [];
|
|
4642
4823
|
if (!query.data?.pages) return { messageCards: mc, siblingCards: sc };
|
|
4643
4824
|
const seenCards = /* @__PURE__ */ new Set();
|
|
4644
|
-
for (const page of query.data.pages) {
|
|
4825
|
+
for (const [index, page] of query.data.pages.entries()) {
|
|
4826
|
+
const pagePaths = transcriptOnly && index > 0 ? new Set(page.messages.map((message) => message.path)) : null;
|
|
4645
4827
|
for (const [path, cards] of page.messageCards) {
|
|
4828
|
+
if (pagePaths && !pagePaths.has(path)) continue;
|
|
4646
4829
|
for (const card of cards) {
|
|
4647
4830
|
if (seenCards.has(card.id)) continue;
|
|
4648
4831
|
seenCards.add(card.id);
|
|
@@ -4651,6 +4834,7 @@ function useInfiniteChannelMessages(options) {
|
|
|
4651
4834
|
mc.set(path, existing);
|
|
4652
4835
|
}
|
|
4653
4836
|
}
|
|
4837
|
+
if (transcriptOnly && index > 0) continue;
|
|
4654
4838
|
for (const card of page.siblingCards) {
|
|
4655
4839
|
if (seenCards.has(card.id)) continue;
|
|
4656
4840
|
seenCards.add(card.id);
|
|
@@ -4658,21 +4842,22 @@ function useInfiniteChannelMessages(options) {
|
|
|
4658
4842
|
}
|
|
4659
4843
|
}
|
|
4660
4844
|
return { messageCards: mc, siblingCards: sc };
|
|
4661
|
-
}, [query.data?.pages]);
|
|
4845
|
+
}, [query.data?.pages, transcriptOnly]);
|
|
4662
4846
|
const qc = reactQuery.useQueryClient();
|
|
4663
4847
|
const debounceRef = React.useRef(null);
|
|
4664
4848
|
const stableKey = React.useMemo(
|
|
4665
4849
|
() => [...vfsKeys.channelMessages(channelPath || "", parentMessageId), "infinite", limit, "latest-first", ...conversationsOnly ? ["conversations"] : [], ...transcriptOnly ? ["transcript"] : []],
|
|
4666
|
-
[channelPath, parentMessageId, limit, conversationsOnly, transcriptOnly]
|
|
4850
|
+
[channelPath, parentMessageId, limit, conversationsOnly, transcriptOnly, scopeKey]
|
|
4667
4851
|
);
|
|
4668
4852
|
React.useEffect(() => {
|
|
4669
4853
|
if (!realtime || !channelPath || !queryEnabled) return;
|
|
4854
|
+
if (transcriptOnly) return watchChannelTranscript(qc, stableKey, channelPath, limit);
|
|
4670
4855
|
const reload = () => void refreshQuery(qc, stableKey, { exact: true });
|
|
4671
4856
|
let tailRunning = false;
|
|
4672
4857
|
let tailAgain = false;
|
|
4673
4858
|
let disposed = false;
|
|
4674
4859
|
const tailOnce = async () => {
|
|
4675
|
-
if (conversationsOnly
|
|
4860
|
+
if (conversationsOnly) {
|
|
4676
4861
|
reload();
|
|
4677
4862
|
return;
|
|
4678
4863
|
}
|
|
@@ -4766,7 +4951,7 @@ function useInfiniteChannelMessages(options) {
|
|
|
4766
4951
|
void tail();
|
|
4767
4952
|
}, 500);
|
|
4768
4953
|
},
|
|
4769
|
-
(data) =>
|
|
4954
|
+
(data) => conversationsOnly && data?.item_type === "message" && (qc.getQueryData(stableKey)?.pages ?? []).some((page) => page.messages.some((root) => root.id === data.parent_id)) || channelMessageChange(
|
|
4770
4955
|
data,
|
|
4771
4956
|
channelPath,
|
|
4772
4957
|
parentMessageId,
|
|
@@ -4997,9 +5182,9 @@ function useCreate() {
|
|
|
4997
5182
|
return reactQuery.useMutation({
|
|
4998
5183
|
mutationFn: (params) => gatewayCall("create", params),
|
|
4999
5184
|
onSuccess: (_data, variables) => {
|
|
5000
|
-
const
|
|
5001
|
-
if (
|
|
5002
|
-
qc.invalidateQueries({ queryKey: vfsKeys.children(
|
|
5185
|
+
const parentPath2 = variables.parent_path;
|
|
5186
|
+
if (parentPath2) {
|
|
5187
|
+
qc.invalidateQueries({ queryKey: vfsKeys.children(parentPath2) });
|
|
5003
5188
|
}
|
|
5004
5189
|
}
|
|
5005
5190
|
});
|
|
@@ -5014,9 +5199,9 @@ function useUpdate() {
|
|
|
5014
5199
|
qc.invalidateQueries({ queryKey: vfsKeys.item(path) });
|
|
5015
5200
|
const segments = path.split("/");
|
|
5016
5201
|
segments.pop();
|
|
5017
|
-
const
|
|
5018
|
-
if (
|
|
5019
|
-
qc.invalidateQueries({ queryKey: vfsKeys.children(
|
|
5202
|
+
const parentPath2 = segments.join("/");
|
|
5203
|
+
if (parentPath2) {
|
|
5204
|
+
qc.invalidateQueries({ queryKey: vfsKeys.children(parentPath2) });
|
|
5020
5205
|
}
|
|
5021
5206
|
}
|
|
5022
5207
|
}
|
|
@@ -5052,9 +5237,9 @@ function useDelete() {
|
|
|
5052
5237
|
qc.removeQueries({ queryKey: vfsKeys.item(path) });
|
|
5053
5238
|
const segments = path.split("/");
|
|
5054
5239
|
segments.pop();
|
|
5055
|
-
const
|
|
5056
|
-
if (
|
|
5057
|
-
qc.invalidateQueries({ queryKey: vfsKeys.children(
|
|
5240
|
+
const parentPath2 = segments.join("/");
|
|
5241
|
+
if (parentPath2) {
|
|
5242
|
+
qc.invalidateQueries({ queryKey: vfsKeys.children(parentPath2) });
|
|
5058
5243
|
}
|
|
5059
5244
|
}
|
|
5060
5245
|
}
|
|
@@ -6127,6 +6312,49 @@ async function submitForm(capabilityId, fields, options = {}) {
|
|
|
6127
6312
|
}, fillId, pageUrl, identity, options.signal);
|
|
6128
6313
|
return payload;
|
|
6129
6314
|
}
|
|
6315
|
+
|
|
6316
|
+
// src/commerce.ts
|
|
6317
|
+
async function startFileCheckout(options) {
|
|
6318
|
+
return gatewayCall("commerce-file-sale", {
|
|
6319
|
+
action: "checkout",
|
|
6320
|
+
product_id: options.productId,
|
|
6321
|
+
expected_product_revision_id: options.productRevisionId,
|
|
6322
|
+
destination_id: options.destinationId,
|
|
6323
|
+
request_key: options.requestKey,
|
|
6324
|
+
_scope_path: options.scopePath,
|
|
6325
|
+
...options.journey ? { journey: options.journey } : {}
|
|
6326
|
+
});
|
|
6327
|
+
}
|
|
6328
|
+
async function getFilePurchase(licenseId, scopePath) {
|
|
6329
|
+
return gatewayCall("commerce-file-sale", { action: "get", license_id: licenseId, _scope_path: scopePath });
|
|
6330
|
+
}
|
|
6331
|
+
function funnelCheckoutLink(options) {
|
|
6332
|
+
const host = new URL(options.hostOrigin);
|
|
6333
|
+
if (host.protocol !== "https:" && !(host.protocol === "http:" && host.hostname === "127.0.0.1") || host.username || host.password || host.search || host.hash || host.pathname !== "/") {
|
|
6334
|
+
throw new TypeError("hostOrigin must be an HTTPS origin or the local 127.0.0.1 app");
|
|
6335
|
+
}
|
|
6336
|
+
const page = new URL(options.pageUrl ?? window.location.href);
|
|
6337
|
+
if (page.protocol !== "https:" || page.username || page.password || page.hash || page.port) {
|
|
6338
|
+
throw new TypeError("The funnel must be a published HTTPS page");
|
|
6339
|
+
}
|
|
6340
|
+
const link = new URL("/v2/revven", host);
|
|
6341
|
+
link.search = new URLSearchParams({
|
|
6342
|
+
surface: "library",
|
|
6343
|
+
offer: options.productId,
|
|
6344
|
+
sale_page: page.href,
|
|
6345
|
+
sale_action: options.capabilityId
|
|
6346
|
+
}).toString();
|
|
6347
|
+
return link.href;
|
|
6348
|
+
}
|
|
6349
|
+
function filePurchaseNextUrl(receipt) {
|
|
6350
|
+
if (receipt.success !== true || receipt.state !== "ready" || !receipt.item_id || !receipt.file_id || !receipt.journey?.next_url) return null;
|
|
6351
|
+
const next = new URL(receipt.journey.next_url);
|
|
6352
|
+
const source = new URL(receipt.journey.return_url);
|
|
6353
|
+
if (next.protocol !== "https:" || source.protocol !== "https:" || next.origin !== source.origin || next.username || next.password || next.hash || next.searchParams.getAll("funnel_id").length !== 1 || next.searchParams.get("funnel_id") !== receipt.journey.funnel_id) {
|
|
6354
|
+
throw new Error("The purchase destination could not be verified");
|
|
6355
|
+
}
|
|
6356
|
+
return next.href;
|
|
6357
|
+
}
|
|
6130
6358
|
function readItem(path) {
|
|
6131
6359
|
return gatewayCall("read", { path });
|
|
6132
6360
|
}
|
|
@@ -7277,6 +7505,8 @@ exports.fetchVfsChildrenPage = fetchVfsChildrenPage;
|
|
|
7277
7505
|
exports.fetchVfsItem = fetchVfsItem;
|
|
7278
7506
|
exports.fetchVfsItemById = fetchVfsItemById;
|
|
7279
7507
|
exports.fetchVfsTree = fetchVfsTree;
|
|
7508
|
+
exports.filePurchaseNextUrl = filePurchaseNextUrl;
|
|
7509
|
+
exports.funnelCheckoutLink = funnelCheckoutLink;
|
|
7280
7510
|
exports.gatewayCall = gatewayCall;
|
|
7281
7511
|
exports.getAccessToken = getAccessToken;
|
|
7282
7512
|
exports.getAnchor = getAnchor;
|
|
@@ -7284,6 +7514,7 @@ exports.getAnchorRef = getAnchorRef;
|
|
|
7284
7514
|
exports.getAnchorVersion = getAnchorVersion;
|
|
7285
7515
|
exports.getAssetUrl = getAssetUrl;
|
|
7286
7516
|
exports.getDefaultSort = getDefaultSort;
|
|
7517
|
+
exports.getFilePurchase = getFilePurchase;
|
|
7287
7518
|
exports.getHomeAnchor = getHomeAnchor;
|
|
7288
7519
|
exports.getInvitation = getInvitation;
|
|
7289
7520
|
exports.getMountVersion = getMountVersion;
|
|
@@ -7351,6 +7582,7 @@ exports.setQueryClient = setQueryClient;
|
|
|
7351
7582
|
exports.setScope = setScope;
|
|
7352
7583
|
exports.setupRequireShim = setupRequireShim;
|
|
7353
7584
|
exports.signal = signal;
|
|
7585
|
+
exports.startFileCheckout = startFileCheckout;
|
|
7354
7586
|
exports.startTracking = startTracking;
|
|
7355
7587
|
exports.steerTurn = steerTurn;
|
|
7356
7588
|
exports.submitForm = submitForm;
|