@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.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: () =>
|
|
126
|
+
readOrganizationMemberRows: () => readOrganizationMemberRows,
|
|
137
127
|
readOutsideShare: () => readOutsideShare,
|
|
138
128
|
reasonCsvRows: () => reasonCsvRows,
|
|
139
129
|
recordNoun: () => recordNoun,
|
|
@@ -4670,199 +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
|
-
var announced = /* @__PURE__ */ new Set();
|
|
4709
|
-
function announceStandIn(port) {
|
|
4710
|
-
if (announced.has(port)) return;
|
|
4711
|
-
announced.add(port);
|
|
4712
|
-
console.warn(
|
|
4713
|
-
`[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} }).`
|
|
4714
|
-
);
|
|
4715
|
-
}
|
|
4716
|
-
function StandIn({ port }) {
|
|
4717
|
-
(0, import_react.useEffect)(() => announceStandIn(port), [port]);
|
|
4718
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { hidden: true, "data-share-sheet-host": "unconfigured", "data-share-sheet-port": port });
|
|
4719
|
-
}
|
|
4720
|
-
function DefaultErrorMenu(_props) {
|
|
4721
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StandIn, { port: "ErrorAlchemyMenu" });
|
|
4722
|
-
}
|
|
4723
|
-
function DefaultPageCaptureButton(_props) {
|
|
4724
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StandIn, { port: "PageCaptureButton" });
|
|
4725
|
-
}
|
|
4726
|
-
function DefaultEntityDoorControls(_props) {
|
|
4727
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StandIn, { port: "EntityDoorControls" });
|
|
4728
|
-
}
|
|
4729
|
-
function DefaultInfoHint(props) {
|
|
4730
|
-
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" });
|
|
4731
|
-
}
|
|
4732
|
-
function DefaultEntityRef(props) {
|
|
4733
|
-
const href = typeof props.href === "string" ? props.href : null;
|
|
4734
|
-
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 ?? "") });
|
|
4735
|
-
}
|
|
4736
|
-
function DefaultUserAvatar(props) {
|
|
4737
|
-
const u = props.user ?? {};
|
|
4738
|
-
const name = u.displayName ?? u.display_name ?? u.email ?? "?";
|
|
4739
|
-
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() });
|
|
4740
|
-
}
|
|
4741
|
-
function DefaultConnectionsNotice(props) {
|
|
4742
|
-
if (!props.error && !(Array.isArray(props.partialFailures) && props.partialFailures.length)) return null;
|
|
4743
|
-
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: [
|
|
4744
|
-
props.error ? `Contacts could not be read: ${String(props.error)}` : `Some contacts could not be read.`,
|
|
4745
|
-
" ",
|
|
4746
|
-
props.onRetry ? (
|
|
4747
|
-
// ui-exception: moved verbatim from the web share sheet; restyling onto design-system Button is its own UI change
|
|
4748
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "underline", onClick: () => props.onRetry(), children: "Retry" })
|
|
4749
|
-
) : null
|
|
4750
|
-
] });
|
|
4751
|
-
}
|
|
4752
|
-
function DefaultUserSearchField(props) {
|
|
4753
|
-
const { onValueChange, onUserSelect: _onUserSelect, value, ...rest } = props;
|
|
4754
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.Input, { ...rest, value: value ?? "", onChange: (e) => onValueChange?.(e.target.value) });
|
|
4755
|
-
}
|
|
4756
|
-
var ORGS_EMPTY = [];
|
|
4757
|
-
var orgsCache = null;
|
|
4758
|
-
var orgListeners = /* @__PURE__ */ new Set();
|
|
4759
|
-
function useDefaultOrganizations() {
|
|
4760
|
-
const snapshot = (0, import_react.useSyncExternalStore)(
|
|
4761
|
-
(cb) => {
|
|
4762
|
-
orgListeners.add(cb);
|
|
4763
|
-
return () => orgListeners.delete(cb);
|
|
4764
|
-
},
|
|
4765
|
-
() => orgsCache ?? ORGS_EMPTY,
|
|
4766
|
-
() => ORGS_EMPTY
|
|
4767
|
-
);
|
|
4768
|
-
(0, import_react.useEffect)(() => {
|
|
4769
|
-
if (orgsCache) return;
|
|
4770
|
-
orgsCache = ORGS_EMPTY;
|
|
4771
|
-
void import("@ai-matrx/sharing/core").then(async ({ shareClient: shareClient2 }) => {
|
|
4772
|
-
const { data, error } = await shareClient2().from("organizations").select("id, name");
|
|
4773
|
-
if (error) console.error(`[share] Your organizations could not be read: ${error.message}`);
|
|
4774
|
-
orgsCache = (Array.isArray(data) ? data : []).map((o) => ({ ...o, id: String(o.id), name: String(o.name ?? "") }));
|
|
4775
|
-
orgListeners.forEach((l) => l());
|
|
4776
|
-
}).catch((err) => console.error("[share] Your organizations could not be read:", err));
|
|
4777
|
-
}, []);
|
|
4778
|
-
return snapshot;
|
|
4779
|
-
}
|
|
4780
|
-
function useDefaultCurrentUserId() {
|
|
4781
|
-
const [id, setId] = (0, import_react.useState)(null);
|
|
4782
|
-
(0, import_react.useEffect)(() => {
|
|
4783
|
-
void import("@ai-matrx/sharing/core").then(async ({ shareClient: shareClient2 }) => {
|
|
4784
|
-
const { getClaimsUser: getClaimsUser2 } = await import("@ai-matrx/sharing/core");
|
|
4785
|
-
const { data } = await getClaimsUser2(shareClient2());
|
|
4786
|
-
setId(data.user?.id ?? null);
|
|
4787
|
-
});
|
|
4788
|
-
}, []);
|
|
4789
|
-
return id;
|
|
4790
|
-
}
|
|
4791
|
-
function useDefaultConnections({ organizationId }) {
|
|
4792
|
-
const [state, setState] = (0, import_react.useState)({ rows: [], loading: Boolean(organizationId), error: null });
|
|
4793
|
-
const load = (0, import_react.useCallback)(
|
|
4794
|
-
async (fresh = false) => {
|
|
4795
|
-
if (!organizationId) return;
|
|
4796
|
-
setState((s) => ({ ...s, loading: true }));
|
|
4797
|
-
try {
|
|
4798
|
-
const rows = await (0, import_core.readOrganizationMemberRows)(organizationId, { fresh });
|
|
4799
|
-
setState({
|
|
4800
|
-
rows: rows.map((r) => ({
|
|
4801
|
-
user_id: r.user_id,
|
|
4802
|
-
email: r.user_email ?? null,
|
|
4803
|
-
display_name: r.user_display_name ?? null,
|
|
4804
|
-
avatar_url: r.user_avatar_url ?? null,
|
|
4805
|
-
source: "organization"
|
|
4806
|
-
})),
|
|
4807
|
-
loading: false,
|
|
4808
|
-
error: null
|
|
4809
|
-
});
|
|
4810
|
-
} catch (err) {
|
|
4811
|
-
setState({ rows: [], loading: false, error: err instanceof Error ? err.message : String(err) });
|
|
4812
|
-
}
|
|
4813
|
-
},
|
|
4814
|
-
[organizationId]
|
|
4815
|
-
);
|
|
4816
|
-
(0, import_react.useEffect)(() => {
|
|
4817
|
-
void load();
|
|
4818
|
-
}, [load]);
|
|
4819
|
-
return (0, import_react.useMemo)(
|
|
4820
|
-
() => ({ connections: state.rows, isLoading: state.loading, error: state.error, partialFailures: [], refresh: () => load(true) }),
|
|
4821
|
-
[state, load]
|
|
4822
|
-
);
|
|
4823
|
-
}
|
|
4824
|
-
var DEFAULTS = {
|
|
4825
|
-
toast: ({ title, description, variant }) => {
|
|
4826
|
-
const text = [title, description].filter((x) => typeof x === "string").join(" \u2014 ");
|
|
4827
|
-
if (variant === "destructive") {
|
|
4828
|
-
console.error(`[share] ${text}`);
|
|
4829
|
-
if (typeof window !== "undefined") window.alert(text);
|
|
4830
|
-
} else console.info(`[share] ${text}`);
|
|
4831
|
-
},
|
|
4832
|
-
useCurrentUserId: useDefaultCurrentUserId,
|
|
4833
|
-
useOrganizations: useDefaultOrganizations,
|
|
4834
|
-
useUserConnections: useDefaultConnections,
|
|
4835
|
-
confirm: (o) => (0, import_confirm_opener.confirm)(o),
|
|
4836
|
-
CopyButtons: DefaultCopyButtons,
|
|
4837
|
-
csvExportItem: () => {
|
|
4838
|
-
announceStandIn("csvExportItem");
|
|
4839
|
-
return null;
|
|
4840
|
-
},
|
|
4841
|
-
jsonExportItem: () => {
|
|
4842
|
-
announceStandIn("jsonExportItem");
|
|
4843
|
-
return null;
|
|
4844
|
-
},
|
|
4845
|
-
usePageCapture: () => {
|
|
4846
|
-
announceStandIn("usePageCapture");
|
|
4847
|
-
return void 0;
|
|
4848
|
-
},
|
|
4849
|
-
dialogCapture: (input) => input,
|
|
4850
|
-
PageCaptureButton: DefaultPageCaptureButton,
|
|
4851
|
-
ErrorAlchemyMenu: DefaultErrorMenu,
|
|
4852
|
-
InfoHint: DefaultInfoHint,
|
|
4853
|
-
EntityDoorControls: DefaultEntityDoorControls,
|
|
4854
|
-
EntityRef: DefaultEntityRef,
|
|
4855
|
-
UserAvatarDisplay: DefaultUserAvatar,
|
|
4856
|
-
ConnectionsReadNotice: DefaultConnectionsNotice,
|
|
4857
|
-
UserSearchField: DefaultUserSearchField,
|
|
4858
|
-
vaultIdentity: null,
|
|
4859
|
-
humanLines: (...args) => args.flat().filter(Boolean).map(String).join("\n"),
|
|
4860
|
-
usePortalContainer: () => void 0
|
|
4861
|
-
};
|
|
4862
|
-
var ui = DEFAULTS;
|
|
4863
|
-
var humanLines = (...args) => ui.humanLines(...args);
|
|
4864
|
-
|
|
4865
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
|
+
}
|
|
4866
4667
|
function sharingLocation(surface) {
|
|
4867
4668
|
return `AI Matrx \u2014 Sharing \u2014 ${surface}`;
|
|
4868
4669
|
}
|
|
@@ -5325,7 +5126,7 @@ async function setSearchEngineIndexed(resourceType, resourceId, indexed) {
|
|
|
5325
5126
|
var import_data = require("@ai-matrx/data");
|
|
5326
5127
|
var MEMBER_ROWS_TTL_MS = Number.POSITIVE_INFINITY;
|
|
5327
5128
|
var cache = /* @__PURE__ */ new Map();
|
|
5328
|
-
function
|
|
5129
|
+
function readOrganizationMemberRows(orgId, {
|
|
5329
5130
|
now = Date.now(),
|
|
5330
5131
|
fresh = false,
|
|
5331
5132
|
client
|