@ai-matrx/sharing 0.1.3 → 0.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/core.js CHANGED
@@ -4498,172 +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
- function DefaultErrorMenu(_props) {
4537
- return null;
4538
- }
4539
- function DefaultInfoHint(props) {
4540
- return /* @__PURE__ */ jsx("span", { title: String(props.text ?? ""), "aria-label": String(props.label ?? "More info"), className: "cursor-help text-muted-foreground", children: "\u24D8" });
4541
- }
4542
- function DefaultEntityRef(props) {
4543
- const href = typeof props.href === "string" ? props.href : null;
4544
- return href ? /* @__PURE__ */ jsx("a", { href, className: "underline-offset-2 hover:underline", children: String(props.name ?? "") }) : /* @__PURE__ */ jsx("span", { children: String(props.name ?? "") });
4545
- }
4546
- function DefaultUserAvatar(props) {
4547
- const u = props.user ?? {};
4548
- const name = u.displayName ?? u.display_name ?? u.email ?? "?";
4549
- 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() });
4550
- }
4551
- function DefaultConnectionsNotice(props) {
4552
- if (!props.error && !(Array.isArray(props.partialFailures) && props.partialFailures.length)) return null;
4553
- return /* @__PURE__ */ jsxs("div", { className: "rounded-md border border-destructive/30 bg-destructive/10 p-2 text-xs text-destructive", children: [
4554
- props.error ? `Contacts could not be read: ${String(props.error)}` : `Some contacts could not be read.`,
4555
- " ",
4556
- props.onRetry ? (
4557
- // ui-exception: moved verbatim from the web share sheet; restyling onto design-system Button is its own UI change
4558
- /* @__PURE__ */ jsx("button", { type: "button", className: "underline", onClick: () => props.onRetry(), children: "Retry" })
4559
- ) : null
4560
- ] });
4561
- }
4562
- function DefaultUserSearchField(props) {
4563
- const { onValueChange, onUserSelect: _onUserSelect, value, ...rest } = props;
4564
- return /* @__PURE__ */ jsx(Input, { ...rest, value: value ?? "", onChange: (e) => onValueChange?.(e.target.value) });
4565
- }
4566
- var ORGS_EMPTY = [];
4567
- var orgsCache = null;
4568
- var orgListeners = /* @__PURE__ */ new Set();
4569
- function useDefaultOrganizations() {
4570
- const snapshot = useSyncExternalStore(
4571
- (cb) => {
4572
- orgListeners.add(cb);
4573
- return () => orgListeners.delete(cb);
4574
- },
4575
- () => orgsCache ?? ORGS_EMPTY,
4576
- () => ORGS_EMPTY
4577
- );
4578
- useEffect(() => {
4579
- if (orgsCache) return;
4580
- orgsCache = ORGS_EMPTY;
4581
- void import("@ai-matrx/sharing/core").then(async ({ shareClient: shareClient2 }) => {
4582
- const { data, error } = await shareClient2().from("organizations").select("id, name");
4583
- if (error) console.error(`[share] Your organizations could not be read: ${error.message}`);
4584
- orgsCache = (Array.isArray(data) ? data : []).map((o) => ({ ...o, id: String(o.id), name: String(o.name ?? "") }));
4585
- orgListeners.forEach((l) => l());
4586
- }).catch((err) => console.error("[share] Your organizations could not be read:", err));
4587
- }, []);
4588
- return snapshot;
4589
- }
4590
- function useDefaultCurrentUserId() {
4591
- const [id, setId] = useState(null);
4592
- useEffect(() => {
4593
- void import("@ai-matrx/sharing/core").then(async ({ shareClient: shareClient2 }) => {
4594
- const { getClaimsUser: getClaimsUser2 } = await import("@ai-matrx/sharing/core");
4595
- const { data } = await getClaimsUser2(shareClient2());
4596
- setId(data.user?.id ?? null);
4597
- });
4598
- }, []);
4599
- return id;
4600
- }
4601
- function useDefaultConnections({ organizationId }) {
4602
- const [state, setState] = useState({ rows: [], loading: Boolean(organizationId), error: null });
4603
- const load = useCallback(
4604
- async (fresh = false) => {
4605
- if (!organizationId) return;
4606
- setState((s) => ({ ...s, loading: true }));
4607
- try {
4608
- const rows = await readOrganizationMemberRows(organizationId, { fresh });
4609
- setState({
4610
- rows: rows.map((r) => ({
4611
- user_id: r.user_id,
4612
- email: r.user_email ?? null,
4613
- display_name: r.user_display_name ?? null,
4614
- avatar_url: r.user_avatar_url ?? null,
4615
- source: "organization"
4616
- })),
4617
- loading: false,
4618
- error: null
4619
- });
4620
- } catch (err) {
4621
- setState({ rows: [], loading: false, error: err instanceof Error ? err.message : String(err) });
4622
- }
4623
- },
4624
- [organizationId]
4625
- );
4626
- useEffect(() => {
4627
- void load();
4628
- }, [load]);
4629
- return useMemo(
4630
- () => ({ connections: state.rows, isLoading: state.loading, error: state.error, partialFailures: [], refresh: () => load(true) }),
4631
- [state, load]
4632
- );
4633
- }
4634
- var DEFAULTS = {
4635
- toast: ({ title, description, variant }) => {
4636
- const text = [title, description].filter((x) => typeof x === "string").join(" \u2014 ");
4637
- if (variant === "destructive") {
4638
- console.error(`[share] ${text}`);
4639
- if (typeof window !== "undefined") window.alert(text);
4640
- } else console.info(`[share] ${text}`);
4641
- },
4642
- useCurrentUserId: useDefaultCurrentUserId,
4643
- useOrganizations: useDefaultOrganizations,
4644
- useUserConnections: useDefaultConnections,
4645
- confirm: (o) => kitConfirm(o),
4646
- CopyButtons: DefaultCopyButtons,
4647
- csvExportItem: () => null,
4648
- jsonExportItem: () => null,
4649
- usePageCapture: () => void 0,
4650
- dialogCapture: (input) => input,
4651
- PageCaptureButton: () => null,
4652
- ErrorAlchemyMenu: DefaultErrorMenu,
4653
- InfoHint: DefaultInfoHint,
4654
- EntityDoorControls: () => null,
4655
- EntityRef: DefaultEntityRef,
4656
- UserAvatarDisplay: DefaultUserAvatar,
4657
- ConnectionsReadNotice: DefaultConnectionsNotice,
4658
- UserSearchField: DefaultUserSearchField,
4659
- vaultIdentity: null,
4660
- humanLines: (...args) => args.flat().filter(Boolean).map(String).join("\n"),
4661
- usePortalContainer: () => void 0
4662
- };
4663
- var ui = DEFAULTS;
4664
- var humanLines = (...args) => ui.humanLines(...args);
4665
-
4666
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
+ }
4667
4505
  function sharingLocation(surface) {
4668
4506
  return `AI Matrx \u2014 Sharing \u2014 ${surface}`;
4669
4507
  }
@@ -5126,7 +4964,7 @@ async function setSearchEngineIndexed(resourceType, resourceId, indexed) {
5126
4964
  import { pgErrorToError } from "@ai-matrx/data";
5127
4965
  var MEMBER_ROWS_TTL_MS = Number.POSITIVE_INFINITY;
5128
4966
  var cache = /* @__PURE__ */ new Map();
5129
- function readOrganizationMemberRows2(orgId, {
4967
+ function readOrganizationMemberRows(orgId, {
5130
4968
  now = Date.now(),
5131
4969
  fresh = false,
5132
4970
  client
@@ -5316,7 +5154,7 @@ export {
5316
5154
  permissionLevelRank,
5317
5155
  publicLaneSelect,
5318
5156
  publicResourceUrl,
5319
- readOrganizationMemberRows2 as readOrganizationMemberRows,
5157
+ readOrganizationMemberRows,
5320
5158
  readOutsideShare,
5321
5159
  reasonCsvRows,
5322
5160
  recordNoun,