@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.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/core/index.ts
@@ -133,7 +123,7 @@ __export(core_exports, {
133
123
  permissionLevelRank: () => permissionLevelRank,
134
124
  publicLaneSelect: () => publicLaneSelect,
135
125
  publicResourceUrl: () => publicResourceUrl,
136
- readOrganizationMemberRows: () => readOrganizationMemberRows2,
126
+ readOrganizationMemberRows: () => readOrganizationMemberRows,
137
127
  readOutsideShare: () => readOutsideShare,
138
128
  reasonCsvRows: () => reasonCsvRows,
139
129
  recordNoun: () => recordNoun,
@@ -4670,172 +4660,10 @@ function describeAccessSummary(summary) {
4670
4660
  return `You, plus ${reasons.join(", ")}`;
4671
4661
  }
4672
4662
 
4673
- // src/react/sheet/host.tsx
4674
- var import_react = require("react");
4675
- var import_design_system = require("@ai-matrx/design-system");
4676
- var import_clipboard = require("@ai-matrx/kit/clipboard");
4677
- var import_confirm_opener = require("@ai-matrx/kit/confirm-opener");
4678
- var import_core = require("@ai-matrx/sharing/core");
4679
- var import_core2 = require("@ai-matrx/sharing/core");
4680
- var import_vault = require("@ai-matrx/vault");
4681
- var import_core3 = require("@ai-matrx/sharing/core");
4682
- var import_core4 = require("@ai-matrx/sharing/core");
4683
- var import_jsx_runtime = require("react/jsx-runtime");
4684
- function DefaultCopyButtons(props) {
4685
- const [done, setDone] = (0, import_react.useState)(false);
4686
- const text = () => {
4687
- const h = props.human ?? props.text;
4688
- const v = typeof h === "function" ? h() : h;
4689
- return Array.isArray(v) ? v.join("\n") : String(v ?? "");
4690
- };
4691
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
4692
- import_design_system.Button,
4693
- {
4694
- type: "button",
4695
- variant: "ghost",
4696
- size: "sm",
4697
- className: props.className,
4698
- onClick: () => {
4699
- void (0, import_clipboard.copyText)(text()).then(() => {
4700
- setDone(true);
4701
- setTimeout(() => setDone(false), 1500);
4702
- });
4703
- },
4704
- children: done ? "Copied" : props.label ? `Copy ${String(props.label).toLowerCase()}` : "Copy"
4705
- }
4706
- );
4707
- }
4708
- function DefaultErrorMenu(_props) {
4709
- return null;
4710
- }
4711
- function DefaultInfoHint(props) {
4712
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { title: String(props.text ?? ""), "aria-label": String(props.label ?? "More info"), className: "cursor-help text-muted-foreground", children: "\u24D8" });
4713
- }
4714
- function DefaultEntityRef(props) {
4715
- const href = typeof props.href === "string" ? props.href : null;
4716
- return href ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href, className: "underline-offset-2 hover:underline", children: String(props.name ?? "") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: String(props.name ?? "") });
4717
- }
4718
- function DefaultUserAvatar(props) {
4719
- const u = props.user ?? {};
4720
- const name = u.displayName ?? u.display_name ?? u.email ?? "?";
4721
- return /* @__PURE__ */ (0, import_jsx_runtime.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() });
4722
- }
4723
- function DefaultConnectionsNotice(props) {
4724
- if (!props.error && !(Array.isArray(props.partialFailures) && props.partialFailures.length)) return null;
4725
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rounded-md border border-destructive/30 bg-destructive/10 p-2 text-xs text-destructive", children: [
4726
- props.error ? `Contacts could not be read: ${String(props.error)}` : `Some contacts could not be read.`,
4727
- " ",
4728
- props.onRetry ? (
4729
- // ui-exception: moved verbatim from the web share sheet; restyling onto design-system Button is its own UI change
4730
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "underline", onClick: () => props.onRetry(), children: "Retry" })
4731
- ) : null
4732
- ] });
4733
- }
4734
- function DefaultUserSearchField(props) {
4735
- const { onValueChange, onUserSelect: _onUserSelect, value, ...rest } = props;
4736
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.Input, { ...rest, value: value ?? "", onChange: (e) => onValueChange?.(e.target.value) });
4737
- }
4738
- var ORGS_EMPTY = [];
4739
- var orgsCache = null;
4740
- var orgListeners = /* @__PURE__ */ new Set();
4741
- function useDefaultOrganizations() {
4742
- const snapshot = (0, import_react.useSyncExternalStore)(
4743
- (cb) => {
4744
- orgListeners.add(cb);
4745
- return () => orgListeners.delete(cb);
4746
- },
4747
- () => orgsCache ?? ORGS_EMPTY,
4748
- () => ORGS_EMPTY
4749
- );
4750
- (0, import_react.useEffect)(() => {
4751
- if (orgsCache) return;
4752
- orgsCache = ORGS_EMPTY;
4753
- void import("@ai-matrx/sharing/core").then(async ({ shareClient: shareClient2 }) => {
4754
- const { data, error } = await shareClient2().from("organizations").select("id, name");
4755
- if (error) console.error(`[share] Your organizations could not be read: ${error.message}`);
4756
- orgsCache = (Array.isArray(data) ? data : []).map((o) => ({ ...o, id: String(o.id), name: String(o.name ?? "") }));
4757
- orgListeners.forEach((l) => l());
4758
- }).catch((err) => console.error("[share] Your organizations could not be read:", err));
4759
- }, []);
4760
- return snapshot;
4761
- }
4762
- function useDefaultCurrentUserId() {
4763
- const [id, setId] = (0, import_react.useState)(null);
4764
- (0, import_react.useEffect)(() => {
4765
- void import("@ai-matrx/sharing/core").then(async ({ shareClient: shareClient2 }) => {
4766
- const { getClaimsUser: getClaimsUser2 } = await import("@ai-matrx/sharing/core");
4767
- const { data } = await getClaimsUser2(shareClient2());
4768
- setId(data.user?.id ?? null);
4769
- });
4770
- }, []);
4771
- return id;
4772
- }
4773
- function useDefaultConnections({ organizationId }) {
4774
- const [state, setState] = (0, import_react.useState)({ rows: [], loading: Boolean(organizationId), error: null });
4775
- const load = (0, import_react.useCallback)(
4776
- async (fresh = false) => {
4777
- if (!organizationId) return;
4778
- setState((s) => ({ ...s, loading: true }));
4779
- try {
4780
- const rows = await (0, import_core.readOrganizationMemberRows)(organizationId, { fresh });
4781
- setState({
4782
- rows: rows.map((r) => ({
4783
- user_id: r.user_id,
4784
- email: r.user_email ?? null,
4785
- display_name: r.user_display_name ?? null,
4786
- avatar_url: r.user_avatar_url ?? null,
4787
- source: "organization"
4788
- })),
4789
- loading: false,
4790
- error: null
4791
- });
4792
- } catch (err) {
4793
- setState({ rows: [], loading: false, error: err instanceof Error ? err.message : String(err) });
4794
- }
4795
- },
4796
- [organizationId]
4797
- );
4798
- (0, import_react.useEffect)(() => {
4799
- void load();
4800
- }, [load]);
4801
- return (0, import_react.useMemo)(
4802
- () => ({ connections: state.rows, isLoading: state.loading, error: state.error, partialFailures: [], refresh: () => load(true) }),
4803
- [state, load]
4804
- );
4805
- }
4806
- var DEFAULTS = {
4807
- toast: ({ title, description, variant }) => {
4808
- const text = [title, description].filter((x) => typeof x === "string").join(" \u2014 ");
4809
- if (variant === "destructive") {
4810
- console.error(`[share] ${text}`);
4811
- if (typeof window !== "undefined") window.alert(text);
4812
- } else console.info(`[share] ${text}`);
4813
- },
4814
- useCurrentUserId: useDefaultCurrentUserId,
4815
- useOrganizations: useDefaultOrganizations,
4816
- useUserConnections: useDefaultConnections,
4817
- confirm: (o) => (0, import_confirm_opener.confirm)(o),
4818
- CopyButtons: DefaultCopyButtons,
4819
- csvExportItem: () => null,
4820
- jsonExportItem: () => null,
4821
- usePageCapture: () => void 0,
4822
- dialogCapture: (input) => input,
4823
- PageCaptureButton: () => null,
4824
- ErrorAlchemyMenu: DefaultErrorMenu,
4825
- InfoHint: DefaultInfoHint,
4826
- EntityDoorControls: () => null,
4827
- EntityRef: DefaultEntityRef,
4828
- UserAvatarDisplay: DefaultUserAvatar,
4829
- ConnectionsReadNotice: DefaultConnectionsNotice,
4830
- UserSearchField: DefaultUserSearchField,
4831
- vaultIdentity: null,
4832
- humanLines: (...args) => args.flat().filter(Boolean).map(String).join("\n"),
4833
- usePortalContainer: () => void 0
4834
- };
4835
- var ui = DEFAULTS;
4836
- var humanLines = (...args) => ui.humanLines(...args);
4837
-
4838
4663
  // src/core/format.ts
4664
+ function humanLines(lines) {
4665
+ return lines.filter(([, value]) => value !== null && value !== void 0 && value !== "").map(([label, value]) => `${label}: ${value}`).join("\n");
4666
+ }
4839
4667
  function sharingLocation(surface) {
4840
4668
  return `AI Matrx \u2014 Sharing \u2014 ${surface}`;
4841
4669
  }
@@ -5298,7 +5126,7 @@ async function setSearchEngineIndexed(resourceType, resourceId, indexed) {
5298
5126
  var import_data = require("@ai-matrx/data");
5299
5127
  var MEMBER_ROWS_TTL_MS = Number.POSITIVE_INFINITY;
5300
5128
  var cache = /* @__PURE__ */ new Map();
5301
- function readOrganizationMemberRows2(orgId, {
5129
+ function readOrganizationMemberRows(orgId, {
5302
5130
  now = Date.now(),
5303
5131
  fresh = false,
5304
5132
  client