@ai-matrx/sharing 0.1.4 → 0.1.6
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/CHANGELOG.md +51 -1
- package/dist/access-react.cjs +113 -137
- package/dist/access-react.cjs.map +1 -1
- package/dist/access-react.js +30 -54
- package/dist/access-react.js.map +1 -1
- package/dist/core.cjs +5 -204
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +5 -194
- package/dist/core.js.map +1 -1
- package/dist/react.cjs +207 -234
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +79 -106
- package/dist/react.js.map +1 -1
- package/package.json +5 -5
package/dist/core.js
CHANGED
|
@@ -4498,199 +4498,10 @@ function describeAccessSummary(summary) {
|
|
|
4498
4498
|
return `You, plus ${reasons.join(", ")}`;
|
|
4499
4499
|
}
|
|
4500
4500
|
|
|
4501
|
-
// src/react/sheet/host.tsx
|
|
4502
|
-
import { useCallback, useEffect, useMemo, useState, useSyncExternalStore } from "react";
|
|
4503
|
-
import { Button, Input } from "@ai-matrx/design-system";
|
|
4504
|
-
import { copyText } from "@ai-matrx/kit/clipboard";
|
|
4505
|
-
import { confirm as kitConfirm } from "@ai-matrx/kit/confirm-opener";
|
|
4506
|
-
import { readOrganizationMemberRows } from "@ai-matrx/sharing/core";
|
|
4507
|
-
import { shareClient as shareClientForIdentity } from "@ai-matrx/sharing/core";
|
|
4508
|
-
import { createSupabaseIdentity } from "@ai-matrx/vault";
|
|
4509
|
-
import { passThroughDispatch as passThroughDispatch2 } from "@ai-matrx/sharing/core";
|
|
4510
|
-
import { passThroughDispatch as passThroughDispatchRef } from "@ai-matrx/sharing/core";
|
|
4511
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4512
|
-
function DefaultCopyButtons(props) {
|
|
4513
|
-
const [done, setDone] = useState(false);
|
|
4514
|
-
const text = () => {
|
|
4515
|
-
const h = props.human ?? props.text;
|
|
4516
|
-
const v = typeof h === "function" ? h() : h;
|
|
4517
|
-
return Array.isArray(v) ? v.join("\n") : String(v ?? "");
|
|
4518
|
-
};
|
|
4519
|
-
return /* @__PURE__ */ jsx(
|
|
4520
|
-
Button,
|
|
4521
|
-
{
|
|
4522
|
-
type: "button",
|
|
4523
|
-
variant: "ghost",
|
|
4524
|
-
size: "sm",
|
|
4525
|
-
className: props.className,
|
|
4526
|
-
onClick: () => {
|
|
4527
|
-
void copyText(text()).then(() => {
|
|
4528
|
-
setDone(true);
|
|
4529
|
-
setTimeout(() => setDone(false), 1500);
|
|
4530
|
-
});
|
|
4531
|
-
},
|
|
4532
|
-
children: done ? "Copied" : props.label ? `Copy ${String(props.label).toLowerCase()}` : "Copy"
|
|
4533
|
-
}
|
|
4534
|
-
);
|
|
4535
|
-
}
|
|
4536
|
-
var announced = /* @__PURE__ */ new Set();
|
|
4537
|
-
function announceStandIn(port) {
|
|
4538
|
-
if (announced.has(port)) return;
|
|
4539
|
-
announced.add(port);
|
|
4540
|
-
console.warn(
|
|
4541
|
-
`[share] The share sheet is using its built-in stand-in for "${port}": the host did not pass it, so that part of the sheet is absent. Pass it with configureShareSheetUi({ ${port} }).`
|
|
4542
|
-
);
|
|
4543
|
-
}
|
|
4544
|
-
function StandIn({ port }) {
|
|
4545
|
-
useEffect(() => announceStandIn(port), [port]);
|
|
4546
|
-
return /* @__PURE__ */ jsx("span", { hidden: true, "data-share-sheet-host": "unconfigured", "data-share-sheet-port": port });
|
|
4547
|
-
}
|
|
4548
|
-
function DefaultErrorMenu(_props) {
|
|
4549
|
-
return /* @__PURE__ */ jsx(StandIn, { port: "ErrorAlchemyMenu" });
|
|
4550
|
-
}
|
|
4551
|
-
function DefaultPageCaptureButton(_props) {
|
|
4552
|
-
return /* @__PURE__ */ jsx(StandIn, { port: "PageCaptureButton" });
|
|
4553
|
-
}
|
|
4554
|
-
function DefaultEntityDoorControls(_props) {
|
|
4555
|
-
return /* @__PURE__ */ jsx(StandIn, { port: "EntityDoorControls" });
|
|
4556
|
-
}
|
|
4557
|
-
function DefaultInfoHint(props) {
|
|
4558
|
-
return /* @__PURE__ */ jsx("span", { title: String(props.text ?? ""), "aria-label": String(props.label ?? "More info"), className: "cursor-help text-muted-foreground", children: "\u24D8" });
|
|
4559
|
-
}
|
|
4560
|
-
function DefaultEntityRef(props) {
|
|
4561
|
-
const href = typeof props.href === "string" ? props.href : null;
|
|
4562
|
-
return href ? /* @__PURE__ */ jsx("a", { href, className: "underline-offset-2 hover:underline", children: String(props.name ?? "") }) : /* @__PURE__ */ jsx("span", { children: String(props.name ?? "") });
|
|
4563
|
-
}
|
|
4564
|
-
function DefaultUserAvatar(props) {
|
|
4565
|
-
const u = props.user ?? {};
|
|
4566
|
-
const name = u.displayName ?? u.display_name ?? u.email ?? "?";
|
|
4567
|
-
return /* @__PURE__ */ jsx("span", { className: "inline-flex h-7 w-7 items-center justify-center rounded-full bg-muted text-xs font-medium", "aria-label": name, children: name.slice(0, 1).toUpperCase() });
|
|
4568
|
-
}
|
|
4569
|
-
function DefaultConnectionsNotice(props) {
|
|
4570
|
-
if (!props.error && !(Array.isArray(props.partialFailures) && props.partialFailures.length)) return null;
|
|
4571
|
-
return /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-destructive/30 bg-destructive/10 p-2 text-xs text-destructive", children: [
|
|
4572
|
-
props.error ? `Contacts could not be read: ${String(props.error)}` : `Some contacts could not be read.`,
|
|
4573
|
-
" ",
|
|
4574
|
-
props.onRetry ? (
|
|
4575
|
-
// ui-exception: moved verbatim from the web share sheet; restyling onto design-system Button is its own UI change
|
|
4576
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "underline", onClick: () => props.onRetry(), children: "Retry" })
|
|
4577
|
-
) : null
|
|
4578
|
-
] });
|
|
4579
|
-
}
|
|
4580
|
-
function DefaultUserSearchField(props) {
|
|
4581
|
-
const { onValueChange, onUserSelect: _onUserSelect, value, ...rest } = props;
|
|
4582
|
-
return /* @__PURE__ */ jsx(Input, { ...rest, value: value ?? "", onChange: (e) => onValueChange?.(e.target.value) });
|
|
4583
|
-
}
|
|
4584
|
-
var ORGS_EMPTY = [];
|
|
4585
|
-
var orgsCache = null;
|
|
4586
|
-
var orgListeners = /* @__PURE__ */ new Set();
|
|
4587
|
-
function useDefaultOrganizations() {
|
|
4588
|
-
const snapshot = useSyncExternalStore(
|
|
4589
|
-
(cb) => {
|
|
4590
|
-
orgListeners.add(cb);
|
|
4591
|
-
return () => orgListeners.delete(cb);
|
|
4592
|
-
},
|
|
4593
|
-
() => orgsCache ?? ORGS_EMPTY,
|
|
4594
|
-
() => ORGS_EMPTY
|
|
4595
|
-
);
|
|
4596
|
-
useEffect(() => {
|
|
4597
|
-
if (orgsCache) return;
|
|
4598
|
-
orgsCache = ORGS_EMPTY;
|
|
4599
|
-
void import("@ai-matrx/sharing/core").then(async ({ shareClient: shareClient2 }) => {
|
|
4600
|
-
const { data, error } = await shareClient2().from("organizations").select("id, name");
|
|
4601
|
-
if (error) console.error(`[share] Your organizations could not be read: ${error.message}`);
|
|
4602
|
-
orgsCache = (Array.isArray(data) ? data : []).map((o) => ({ ...o, id: String(o.id), name: String(o.name ?? "") }));
|
|
4603
|
-
orgListeners.forEach((l) => l());
|
|
4604
|
-
}).catch((err) => console.error("[share] Your organizations could not be read:", err));
|
|
4605
|
-
}, []);
|
|
4606
|
-
return snapshot;
|
|
4607
|
-
}
|
|
4608
|
-
function useDefaultCurrentUserId() {
|
|
4609
|
-
const [id, setId] = useState(null);
|
|
4610
|
-
useEffect(() => {
|
|
4611
|
-
void import("@ai-matrx/sharing/core").then(async ({ shareClient: shareClient2 }) => {
|
|
4612
|
-
const { getClaimsUser: getClaimsUser2 } = await import("@ai-matrx/sharing/core");
|
|
4613
|
-
const { data } = await getClaimsUser2(shareClient2());
|
|
4614
|
-
setId(data.user?.id ?? null);
|
|
4615
|
-
});
|
|
4616
|
-
}, []);
|
|
4617
|
-
return id;
|
|
4618
|
-
}
|
|
4619
|
-
function useDefaultConnections({ organizationId }) {
|
|
4620
|
-
const [state, setState] = useState({ rows: [], loading: Boolean(organizationId), error: null });
|
|
4621
|
-
const load = useCallback(
|
|
4622
|
-
async (fresh = false) => {
|
|
4623
|
-
if (!organizationId) return;
|
|
4624
|
-
setState((s) => ({ ...s, loading: true }));
|
|
4625
|
-
try {
|
|
4626
|
-
const rows = await readOrganizationMemberRows(organizationId, { fresh });
|
|
4627
|
-
setState({
|
|
4628
|
-
rows: rows.map((r) => ({
|
|
4629
|
-
user_id: r.user_id,
|
|
4630
|
-
email: r.user_email ?? null,
|
|
4631
|
-
display_name: r.user_display_name ?? null,
|
|
4632
|
-
avatar_url: r.user_avatar_url ?? null,
|
|
4633
|
-
source: "organization"
|
|
4634
|
-
})),
|
|
4635
|
-
loading: false,
|
|
4636
|
-
error: null
|
|
4637
|
-
});
|
|
4638
|
-
} catch (err) {
|
|
4639
|
-
setState({ rows: [], loading: false, error: err instanceof Error ? err.message : String(err) });
|
|
4640
|
-
}
|
|
4641
|
-
},
|
|
4642
|
-
[organizationId]
|
|
4643
|
-
);
|
|
4644
|
-
useEffect(() => {
|
|
4645
|
-
void load();
|
|
4646
|
-
}, [load]);
|
|
4647
|
-
return useMemo(
|
|
4648
|
-
() => ({ connections: state.rows, isLoading: state.loading, error: state.error, partialFailures: [], refresh: () => load(true) }),
|
|
4649
|
-
[state, load]
|
|
4650
|
-
);
|
|
4651
|
-
}
|
|
4652
|
-
var DEFAULTS = {
|
|
4653
|
-
toast: ({ title, description, variant }) => {
|
|
4654
|
-
const text = [title, description].filter((x) => typeof x === "string").join(" \u2014 ");
|
|
4655
|
-
if (variant === "destructive") {
|
|
4656
|
-
console.error(`[share] ${text}`);
|
|
4657
|
-
if (typeof window !== "undefined") window.alert(text);
|
|
4658
|
-
} else console.info(`[share] ${text}`);
|
|
4659
|
-
},
|
|
4660
|
-
useCurrentUserId: useDefaultCurrentUserId,
|
|
4661
|
-
useOrganizations: useDefaultOrganizations,
|
|
4662
|
-
useUserConnections: useDefaultConnections,
|
|
4663
|
-
confirm: (o) => kitConfirm(o),
|
|
4664
|
-
CopyButtons: DefaultCopyButtons,
|
|
4665
|
-
csvExportItem: () => {
|
|
4666
|
-
announceStandIn("csvExportItem");
|
|
4667
|
-
return null;
|
|
4668
|
-
},
|
|
4669
|
-
jsonExportItem: () => {
|
|
4670
|
-
announceStandIn("jsonExportItem");
|
|
4671
|
-
return null;
|
|
4672
|
-
},
|
|
4673
|
-
usePageCapture: () => {
|
|
4674
|
-
announceStandIn("usePageCapture");
|
|
4675
|
-
return void 0;
|
|
4676
|
-
},
|
|
4677
|
-
dialogCapture: (input) => input,
|
|
4678
|
-
PageCaptureButton: DefaultPageCaptureButton,
|
|
4679
|
-
ErrorAlchemyMenu: DefaultErrorMenu,
|
|
4680
|
-
InfoHint: DefaultInfoHint,
|
|
4681
|
-
EntityDoorControls: DefaultEntityDoorControls,
|
|
4682
|
-
EntityRef: DefaultEntityRef,
|
|
4683
|
-
UserAvatarDisplay: DefaultUserAvatar,
|
|
4684
|
-
ConnectionsReadNotice: DefaultConnectionsNotice,
|
|
4685
|
-
UserSearchField: DefaultUserSearchField,
|
|
4686
|
-
vaultIdentity: null,
|
|
4687
|
-
humanLines: (...args) => args.flat().filter(Boolean).map(String).join("\n"),
|
|
4688
|
-
usePortalContainer: () => void 0
|
|
4689
|
-
};
|
|
4690
|
-
var ui = DEFAULTS;
|
|
4691
|
-
var humanLines = (...args) => ui.humanLines(...args);
|
|
4692
|
-
|
|
4693
4501
|
// src/core/format.ts
|
|
4502
|
+
function humanLines(lines) {
|
|
4503
|
+
return lines.filter(([, value]) => value !== null && value !== void 0 && value !== "").map(([label, value]) => `${label}: ${value}`).join("\n");
|
|
4504
|
+
}
|
|
4694
4505
|
function sharingLocation(surface) {
|
|
4695
4506
|
return `AI Matrx \u2014 Sharing \u2014 ${surface}`;
|
|
4696
4507
|
}
|
|
@@ -5153,7 +4964,7 @@ async function setSearchEngineIndexed(resourceType, resourceId, indexed) {
|
|
|
5153
4964
|
import { pgErrorToError } from "@ai-matrx/data";
|
|
5154
4965
|
var MEMBER_ROWS_TTL_MS = Number.POSITIVE_INFINITY;
|
|
5155
4966
|
var cache = /* @__PURE__ */ new Map();
|
|
5156
|
-
function
|
|
4967
|
+
function readOrganizationMemberRows(orgId, {
|
|
5157
4968
|
now = Date.now(),
|
|
5158
4969
|
fresh = false,
|
|
5159
4970
|
client
|
|
@@ -5343,7 +5154,7 @@ export {
|
|
|
5343
5154
|
permissionLevelRank,
|
|
5344
5155
|
publicLaneSelect,
|
|
5345
5156
|
publicResourceUrl,
|
|
5346
|
-
|
|
5157
|
+
readOrganizationMemberRows,
|
|
5347
5158
|
readOutsideShare,
|
|
5348
5159
|
reasonCsvRows,
|
|
5349
5160
|
recordNoun,
|