@openrails/contentkit-ui 0.79.0 → 0.81.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.
Files changed (295) hide show
  1. package/README.md +82 -54
  2. package/dist/client/beacons.d.ts +53 -0
  3. package/dist/client/beacons.js +72 -0
  4. package/dist/client/beacons.js.map +1 -0
  5. package/dist/client/catalog.d.ts +2 -2
  6. package/dist/client/catalog.js +1 -1
  7. package/dist/client/catalog.js.map +1 -1
  8. package/dist/client/client.d.ts +24 -11
  9. package/dist/client/client.js +37 -29
  10. package/dist/client/client.js.map +1 -1
  11. package/dist/client/content/comments.d.ts +12 -8
  12. package/dist/client/content/comments.js +33 -20
  13. package/dist/client/content/comments.js.map +1 -1
  14. package/dist/client/content/favorites.d.ts +24 -9
  15. package/dist/client/content/favorites.js +21 -22
  16. package/dist/client/content/favorites.js.map +1 -1
  17. package/dist/client/content/moderation.d.ts +1 -1
  18. package/dist/client/content/moderation.js.map +1 -1
  19. package/dist/client/content/reactions.d.ts +11 -6
  20. package/dist/client/content/reactions.js +23 -18
  21. package/dist/client/content/reactions.js.map +1 -1
  22. package/dist/client/content/types.d.ts +40 -21
  23. package/dist/client/content/types.js +5 -2
  24. package/dist/client/content/types.js.map +1 -1
  25. package/dist/client/contents.d.ts +55 -0
  26. package/dist/client/contents.js +144 -0
  27. package/dist/client/contents.js.map +1 -0
  28. package/dist/client/discovery.d.ts +126 -0
  29. package/dist/client/discovery.js +125 -0
  30. package/dist/client/discovery.js.map +1 -0
  31. package/dist/client/generated/error-codes.d.ts +1 -1
  32. package/dist/client/generated/error-codes.js +12 -0
  33. package/dist/client/generated/error-codes.js.map +1 -1
  34. package/dist/client/generated/routes.d.ts +1244 -370
  35. package/dist/client/generated/routes.js +1870 -554
  36. package/dist/client/generated/routes.js.map +1 -1
  37. package/dist/client/generated/wire.d.ts +960 -134
  38. package/dist/client/generated/wire.js.map +1 -1
  39. package/dist/client/group-fields.d.ts +25 -0
  40. package/dist/client/group-fields.js +63 -0
  41. package/dist/client/group-fields.js.map +1 -0
  42. package/dist/client/groups.d.ts +58 -0
  43. package/dist/client/groups.js +119 -0
  44. package/dist/client/groups.js.map +1 -0
  45. package/dist/client/http.d.ts +24 -12
  46. package/dist/client/http.js +20 -24
  47. package/dist/client/http.js.map +1 -1
  48. package/dist/client/index.d.ts +11 -6
  49. package/dist/client/media/api.d.ts +1 -1
  50. package/dist/client/media/api.js +4 -2
  51. package/dist/client/media/api.js.map +1 -1
  52. package/dist/client/media/client.d.ts +8 -9
  53. package/dist/client/media/client.js +58 -71
  54. package/dist/client/media/client.js.map +1 -1
  55. package/dist/client/media/ref.d.ts +30 -0
  56. package/dist/client/media/ref.js +10 -3
  57. package/dist/client/media/ref.js.map +1 -1
  58. package/dist/client/offers.d.ts +41 -0
  59. package/dist/client/offers.js +66 -0
  60. package/dist/client/offers.js.map +1 -0
  61. package/dist/client/route.d.ts +2 -0
  62. package/dist/client/route.js +2 -1
  63. package/dist/client/route.js.map +1 -1
  64. package/dist/client/versions.d.ts +20 -0
  65. package/dist/client/versions.js +53 -0
  66. package/dist/client/versions.js.map +1 -0
  67. package/dist/client.js +35 -30
  68. package/dist/components/admin/content-manager.d.ts +80 -0
  69. package/dist/components/admin/content-manager.js +591 -0
  70. package/dist/components/admin/content-manager.js.map +1 -0
  71. package/dist/components/admin/group-manager.d.ts +24 -0
  72. package/dist/components/admin/group-manager.js +244 -0
  73. package/dist/components/admin/group-manager.js.map +1 -0
  74. package/dist/components/admin/media-item-panel.js +1 -1
  75. package/dist/components/admin/media-item-panel.js.map +1 -1
  76. package/dist/components/content/card.d.ts +44 -0
  77. package/dist/components/content/card.js +285 -0
  78. package/dist/components/content/card.js.map +1 -0
  79. package/dist/components/content/editors.d.ts +40 -0
  80. package/dist/components/content/editors.js +764 -0
  81. package/dist/components/content/editors.js.map +1 -0
  82. package/dist/components/content/filters.d.ts +28 -0
  83. package/dist/components/content/filters.js +134 -0
  84. package/dist/components/content/filters.js.map +1 -0
  85. package/dist/components/content/grid.d.ts +62 -0
  86. package/dist/components/content/grid.js +233 -0
  87. package/dist/components/content/grid.js.map +1 -0
  88. package/dist/components/content/index.d.ts +8 -0
  89. package/dist/components/content/listing.d.ts +20 -0
  90. package/dist/components/content/listing.js +150 -0
  91. package/dist/components/content/listing.js.map +1 -0
  92. package/dist/components/content/offer-fields.d.ts +8 -0
  93. package/dist/components/content/offer-fields.js +127 -0
  94. package/dist/components/content/offer-fields.js.map +1 -0
  95. package/dist/components/content/paywall.d.ts +53 -0
  96. package/dist/components/content/paywall.js +221 -0
  97. package/dist/components/content/paywall.js.map +1 -0
  98. package/dist/components/content/search.d.ts +27 -0
  99. package/dist/components/content/search.js +164 -0
  100. package/dist/components/content/search.js.map +1 -0
  101. package/dist/components/groups/banner.d.ts +51 -0
  102. package/dist/components/groups/banner.js +194 -0
  103. package/dist/components/groups/banner.js.map +1 -0
  104. package/dist/components/groups/directory.d.ts +37 -0
  105. package/dist/components/groups/directory.js +117 -0
  106. package/dist/components/groups/directory.js.map +1 -0
  107. package/dist/components/groups/editor.d.ts +44 -0
  108. package/dist/components/groups/editor.js +860 -0
  109. package/dist/components/groups/editor.js.map +1 -0
  110. package/dist/components/groups/fields.d.ts +13 -0
  111. package/dist/components/groups/fields.js +68 -0
  112. package/dist/components/groups/fields.js.map +1 -0
  113. package/dist/components/groups/header.d.ts +25 -0
  114. package/dist/components/groups/header.js +131 -0
  115. package/dist/components/groups/header.js.map +1 -0
  116. package/dist/components/groups/index.d.ts +6 -0
  117. package/dist/components/groups/memberships.d.ts +55 -0
  118. package/dist/components/groups/memberships.js +527 -0
  119. package/dist/components/groups/memberships.js.map +1 -0
  120. package/dist/components/groups/parts.d.ts +49 -0
  121. package/dist/components/groups/parts.js +172 -0
  122. package/dist/components/groups/parts.js.map +1 -0
  123. package/dist/components/media-folder-editor.js +153 -152
  124. package/dist/components/media-folder-editor.js.map +1 -1
  125. package/dist/components/social/comments.d.ts +7 -5
  126. package/dist/components/social/comments.js +6 -2
  127. package/dist/components/social/comments.js.map +1 -1
  128. package/dist/components/social/engagement.d.ts +4 -3
  129. package/dist/components/social/engagement.js.map +1 -1
  130. package/dist/components/social/moderation.d.ts +1 -1
  131. package/dist/components/social/moderation.js +3 -3
  132. package/dist/components/social/moderation.js.map +1 -1
  133. package/dist/editor/rich-text-editor.d.ts +4 -4
  134. package/dist/editor/rich-text-editor.js.map +1 -1
  135. package/dist/index.d.ts +4 -2
  136. package/dist/index.js +23 -9
  137. package/dist/locales/admin/de.js +5 -66
  138. package/dist/locales/admin/de.js.map +1 -1
  139. package/dist/locales/admin/en.d.ts +5 -66
  140. package/dist/locales/admin/en.js +19 -80
  141. package/dist/locales/admin/en.js.map +1 -1
  142. package/dist/locales/admin/es.js +5 -66
  143. package/dist/locales/admin/es.js.map +1 -1
  144. package/dist/locales/admin/ja.js +5 -66
  145. package/dist/locales/admin/ja.js.map +1 -1
  146. package/dist/locales/admin/ko.js +5 -66
  147. package/dist/locales/admin/ko.js.map +1 -1
  148. package/dist/locales/admin/zh.js +5 -66
  149. package/dist/locales/admin/zh.js.map +1 -1
  150. package/dist/locales/content/de.d.ts +2 -0
  151. package/dist/locales/content/de.js +98 -0
  152. package/dist/locales/content/de.js.map +1 -0
  153. package/dist/locales/content/en.d.ts +93 -0
  154. package/dist/locales/content/en.js +98 -0
  155. package/dist/locales/content/en.js.map +1 -0
  156. package/dist/locales/content/es.d.ts +2 -0
  157. package/dist/locales/content/es.js +98 -0
  158. package/dist/locales/content/es.js.map +1 -0
  159. package/dist/locales/content/ja.d.ts +2 -0
  160. package/dist/locales/content/ja.js +98 -0
  161. package/dist/locales/content/ja.js.map +1 -0
  162. package/dist/locales/content/ko.d.ts +2 -0
  163. package/dist/locales/content/ko.js +98 -0
  164. package/dist/locales/content/ko.js.map +1 -0
  165. package/dist/locales/content/zh.d.ts +2 -0
  166. package/dist/locales/content/zh.js +98 -0
  167. package/dist/locales/content/zh.js.map +1 -0
  168. package/dist/locales/de.js +11 -2
  169. package/dist/locales/de.js.map +1 -1
  170. package/dist/locales/discovery/de.d.ts +2 -0
  171. package/dist/locales/discovery/de.js +68 -0
  172. package/dist/locales/discovery/de.js.map +1 -0
  173. package/dist/locales/discovery/en.d.ts +63 -0
  174. package/dist/locales/discovery/en.js +68 -0
  175. package/dist/locales/discovery/en.js.map +1 -0
  176. package/dist/locales/discovery/es.d.ts +2 -0
  177. package/dist/locales/discovery/es.js +68 -0
  178. package/dist/locales/discovery/es.js.map +1 -0
  179. package/dist/locales/discovery/ja.d.ts +2 -0
  180. package/dist/locales/discovery/ja.js +68 -0
  181. package/dist/locales/discovery/ja.js.map +1 -0
  182. package/dist/locales/discovery/ko.d.ts +2 -0
  183. package/dist/locales/discovery/ko.js +68 -0
  184. package/dist/locales/discovery/ko.js.map +1 -0
  185. package/dist/locales/discovery/zh.d.ts +2 -0
  186. package/dist/locales/discovery/zh.js +68 -0
  187. package/dist/locales/discovery/zh.js.map +1 -0
  188. package/dist/locales/en.d.ts +288 -67
  189. package/dist/locales/en.js +11 -2
  190. package/dist/locales/en.js.map +1 -1
  191. package/dist/locales/es.js +11 -2
  192. package/dist/locales/es.js.map +1 -1
  193. package/dist/locales/groups/de.d.ts +2 -0
  194. package/dist/locales/groups/de.js +133 -0
  195. package/dist/locales/groups/de.js.map +1 -0
  196. package/dist/locales/groups/en.d.ts +128 -0
  197. package/dist/locales/groups/en.js +133 -0
  198. package/dist/locales/groups/en.js.map +1 -0
  199. package/dist/locales/groups/es.d.ts +2 -0
  200. package/dist/locales/groups/es.js +133 -0
  201. package/dist/locales/groups/es.js.map +1 -0
  202. package/dist/locales/groups/ja.d.ts +2 -0
  203. package/dist/locales/groups/ja.js +133 -0
  204. package/dist/locales/groups/ja.js.map +1 -0
  205. package/dist/locales/groups/ko.d.ts +2 -0
  206. package/dist/locales/groups/ko.js +133 -0
  207. package/dist/locales/groups/ko.js.map +1 -0
  208. package/dist/locales/groups/zh.d.ts +2 -0
  209. package/dist/locales/groups/zh.js +133 -0
  210. package/dist/locales/groups/zh.js.map +1 -0
  211. package/dist/locales/ja.js +11 -2
  212. package/dist/locales/ja.js.map +1 -1
  213. package/dist/locales/ko.js +11 -2
  214. package/dist/locales/ko.js.map +1 -1
  215. package/dist/locales/social/de.js +2 -1
  216. package/dist/locales/social/de.js.map +1 -1
  217. package/dist/locales/social/en.d.ts +2 -1
  218. package/dist/locales/social/en.js +2 -1
  219. package/dist/locales/social/en.js.map +1 -1
  220. package/dist/locales/social/es.js +2 -1
  221. package/dist/locales/social/es.js.map +1 -1
  222. package/dist/locales/social/ja.js +2 -1
  223. package/dist/locales/social/ja.js.map +1 -1
  224. package/dist/locales/social/ko.js +2 -1
  225. package/dist/locales/social/ko.js.map +1 -1
  226. package/dist/locales/social/zh.js +2 -1
  227. package/dist/locales/social/zh.js.map +1 -1
  228. package/dist/locales/zh.js +11 -2
  229. package/dist/locales/zh.js.map +1 -1
  230. package/dist/react/admin.d.ts +1 -1
  231. package/dist/react/admin.js +8 -6
  232. package/dist/react/admin.js.map +1 -1
  233. package/dist/react/comments.d.ts +9 -7
  234. package/dist/react/comments.js +42 -27
  235. package/dist/react/comments.js.map +1 -1
  236. package/dist/react/contents.d.ts +57 -0
  237. package/dist/react/contents.js +214 -0
  238. package/dist/react/contents.js.map +1 -0
  239. package/dist/react/context.d.ts +1 -1
  240. package/dist/react/context.js.map +1 -1
  241. package/dist/react/crop.js +45 -44
  242. package/dist/react/crop.js.map +1 -1
  243. package/dist/react/detail.d.ts +30 -0
  244. package/dist/react/detail.js +42 -0
  245. package/dist/react/detail.js.map +1 -0
  246. package/dist/react/discovery.d.ts +138 -0
  247. package/dist/react/discovery.js +299 -0
  248. package/dist/react/discovery.js.map +1 -0
  249. package/dist/react/engagement.d.ts +5 -5
  250. package/dist/react/engagement.js +55 -41
  251. package/dist/react/engagement.js.map +1 -1
  252. package/dist/react/folder.js +54 -53
  253. package/dist/react/folder.js.map +1 -1
  254. package/dist/react/groups.d.ts +115 -0
  255. package/dist/react/groups.js +229 -0
  256. package/dist/react/groups.js.map +1 -0
  257. package/dist/react/index.d.ts +5 -1
  258. package/dist/react/public.d.ts +6 -5
  259. package/dist/react/public.js +19 -22
  260. package/dist/react/public.js.map +1 -1
  261. package/dist/react/read.js +105 -106
  262. package/dist/react/read.js.map +1 -1
  263. package/dist/react/resources.d.ts +2 -2
  264. package/dist/react/resources.js +69 -40
  265. package/dist/react/resources.js.map +1 -1
  266. package/dist/react/store.js +41 -39
  267. package/dist/react/store.js.map +1 -1
  268. package/dist/react/upload.js +54 -53
  269. package/dist/react/upload.js.map +1 -1
  270. package/dist/react/use-resource.d.ts +2 -1
  271. package/dist/react/use-resource.js +1 -0
  272. package/dist/react/use-resource.js.map +1 -1
  273. package/dist/react/versions.d.ts +57 -0
  274. package/dist/react/versions.js +94 -0
  275. package/dist/react/versions.js.map +1 -0
  276. package/dist/react/video.js +87 -86
  277. package/dist/react/video.js.map +1 -1
  278. package/dist/react.js +9 -5
  279. package/dist/styles.css +1 -1
  280. package/package.json +1 -1
  281. package/dist/client/content/posts.d.ts +0 -52
  282. package/dist/client/content/posts.js +0 -84
  283. package/dist/client/content/posts.js.map +0 -1
  284. package/dist/client/taxonomy.d.ts +0 -34
  285. package/dist/client/taxonomy.js +0 -84
  286. package/dist/client/taxonomy.js.map +0 -1
  287. package/dist/components/admin/post-manager.d.ts +0 -45
  288. package/dist/components/admin/post-manager.js +0 -602
  289. package/dist/components/admin/post-manager.js.map +0 -1
  290. package/dist/components/admin/taxonomy-manager.d.ts +0 -54
  291. package/dist/components/admin/taxonomy-manager.js +0 -976
  292. package/dist/components/admin/taxonomy-manager.js.map +0 -1
  293. package/dist/react/posts.d.ts +0 -61
  294. package/dist/react/posts.js +0 -183
  295. package/dist/react/posts.js.map +0 -1
@@ -0,0 +1,214 @@
1
+ import { useGuarded as e } from "./context.js";
2
+ import { useMediaRead as t } from "./read.js";
3
+ import { keyOf as n, offsetPages as r, useContentScope as i, useList as a, useResource as o } from "./use-resource.js";
4
+ import { BODY_SUFFIX as s, IMAGE_SCHEME as c, imageRef as l, imageRefs as u } from "../client/contents.js";
5
+ import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
6
+ //#region src/react/contents.ts
7
+ function g(e = {}, t = {}) {
8
+ let { client: o, store: s, scope: c } = i(t.client), { pageSize: l, ...u } = e, d = l ?? 20;
9
+ return a(s, n("contents", c, u.kind, u.state, u.owner_group, u.q, u.language, d), {
10
+ type: "contents",
11
+ scope: u.state === "deleted" ? "deleted" : void 0
12
+ }, r(d, (e, t) => o.contents.manage({
13
+ ...u,
14
+ ...e
15
+ }, t)));
16
+ }
17
+ var _ = (e) => [...new Set([...(e ?? "").matchAll(u())].map((e) => e[1]))], v = (e) => {
18
+ let t = e.slice(e.lastIndexOf("/") + 1), n = t.lastIndexOf(".");
19
+ return n > 0 ? t.slice(0, n) : t;
20
+ };
21
+ function y(r, a, g, y = {}) {
22
+ let { client: b, store: ee, scope: x } = i(y.client), [te, ne] = h(null), S = r ?? te, C = S ? n("content", x, S) : null, w = o(ee, C, {
23
+ type: "content",
24
+ id: S ?? void 0
25
+ }, (e) => b.contents.get(S, g, e), { initial: y.initial }), T = w.data ?? null, [re, E] = h(0), D = e(), O = d(async (e) => {
26
+ E((e) => e + 1);
27
+ try {
28
+ return await D(e);
29
+ } finally {
30
+ E((e) => e - 1);
31
+ }
32
+ }, [D]), k = d(() => {
33
+ if (!S) throw Error("contentkit-ui: create the item first");
34
+ return S;
35
+ }, [S]), A = T?.text?.[g], j = A?.body, M = T?.cover, [N, ie] = h(/* @__PURE__ */ new Map()), P = m([]);
36
+ f(() => {
37
+ let e = P.current;
38
+ return () => {
39
+ for (let t of e) URL.revokeObjectURL(t);
40
+ };
41
+ }, []);
42
+ let F = p(() => new Map(Object.entries(T?.images ?? {})), [T?.images]), I = !!M && !M.url && !N.has(M.image) && !F.has(M.image), L = p(() => _(j).filter((e) => !N.has(e) && !F.has(e)), [
43
+ j,
44
+ N,
45
+ F
46
+ ]), R = p(() => I ? [...L, M.image] : L, [
47
+ I,
48
+ L,
49
+ M
50
+ ]), z = p(() => ({
51
+ kind: a,
52
+ id: S ?? "none"
53
+ }), [a, S]), B = p(() => ({
54
+ kind: a + s,
55
+ id: S ?? "none"
56
+ }), [a, S]), V = t(z, {
57
+ editor: !0,
58
+ read: I ? void 0 : null,
59
+ client: b
60
+ }), H = t(B, {
61
+ editor: !0,
62
+ read: L.length ? void 0 : null,
63
+ client: b
64
+ }), U = p(() => [...V.read?.files ?? [], ...H.read?.files ?? []], [V.read, H.read]), W = p(() => {
65
+ let e = /* @__PURE__ */ new Map();
66
+ for (let t of U) t.upload && t.editor_url && e.set(v(t.path), t.editor_url);
67
+ return e;
68
+ }, [U]), ae = (e) => U.some((t) => t.failed && v(t.path) === e), G = (!!V.read || !!H.read) && R.some((e) => !W.has(e) && !ae(e)), K = m(0), q = V.reload, J = H.reload, Y = d(() => {
69
+ q(), J();
70
+ }, [q, J]);
71
+ f(() => {
72
+ if (!G) {
73
+ K.current = 0;
74
+ return;
75
+ }
76
+ if (K.current >= 6) return;
77
+ let e = setTimeout(() => {
78
+ K.current++, Y();
79
+ }, 1e3 * 2 ** K.current);
80
+ return () => clearTimeout(e);
81
+ }, [
82
+ G,
83
+ U,
84
+ Y
85
+ ]);
86
+ let X = m(/* @__PURE__ */ new Map());
87
+ f(() => {
88
+ for (let e of [
89
+ N,
90
+ F,
91
+ W
92
+ ]) for (let [t, n] of e) X.current.set(n, t);
93
+ }, [
94
+ N,
95
+ F,
96
+ W
97
+ ]);
98
+ let Z = d((e) => {
99
+ if (!e) return;
100
+ let t = e.startsWith("contentkit:") ? e.slice(c.length) : e;
101
+ return N.get(t) ?? F.get(t) ?? W.get(t) ?? e;
102
+ }, [
103
+ N,
104
+ F,
105
+ W
106
+ ]), oe = p(() => A ? {
107
+ ...A,
108
+ body: (A.body ?? "").replace(u(), (e, t) => N.get(t) ?? F.get(t) ?? W.get(t) ?? e)
109
+ } : void 0, [
110
+ A,
111
+ N,
112
+ F,
113
+ W
114
+ ]), Q = d((e) => {
115
+ let t = new Map(X.current);
116
+ for (let e of [
117
+ N,
118
+ F,
119
+ W
120
+ ]) for (let [n, r] of e) t.set(r, n);
121
+ let n = e;
122
+ for (let [e, r] of t) n = n.split(e).join(l(r)).split(e.replaceAll("&", "&")).join(l(r));
123
+ return n;
124
+ }, [
125
+ N,
126
+ F,
127
+ W
128
+ ]), $ = d((e, t) => {
129
+ if (typeof URL.createObjectURL != "function") return;
130
+ let n = URL.createObjectURL(t);
131
+ return P.current.push(n), ie((t) => new Map(t).set(e, n)), n;
132
+ }, []), se = d((e) => O(async () => {
133
+ let t = await b.contents.create(e);
134
+ return ne(t.id), t;
135
+ }), [b, O]), ce = d((e) => O(() => b.contents.update(k(), e)), [
136
+ b,
137
+ O,
138
+ k
139
+ ]), le = d((e) => O(() => b.contents.putText(k(), g, e.body === void 0 ? e : {
140
+ ...e,
141
+ body: Q(e.body)
142
+ })), [
143
+ b,
144
+ O,
145
+ k,
146
+ g,
147
+ Q
148
+ ]), ue = d((e) => O(() => b.contents.publish(k(), e)), [
149
+ b,
150
+ O,
151
+ k
152
+ ]), de = d(() => O(() => b.contents.unpublish(k())), [
153
+ b,
154
+ O,
155
+ k
156
+ ]), fe = d(() => O(() => b.contents.remove(k())), [
157
+ b,
158
+ O,
159
+ k
160
+ ]), pe = d(() => O(() => b.contents.restore(k())), [
161
+ b,
162
+ O,
163
+ k
164
+ ]), me = d((e) => O(async () => {
165
+ if (!e) return await b.contents.setCover(k(), null), null;
166
+ let t = await b.media.uploadNamed({
167
+ kind: a,
168
+ id: k()
169
+ }, e), n = await b.contents.setCover(k(), t.name), r = $(t.name, e) ?? n.cover?.url ?? null;
170
+ return r && X.current.set(r, t.name), r;
171
+ }), [
172
+ b,
173
+ O,
174
+ k,
175
+ a,
176
+ $
177
+ ]), he = d((e) => O(async () => {
178
+ let t = await b.media.uploadInline({
179
+ kind: a + s,
180
+ id: k()
181
+ }, e), n = $(t.name, e) ?? t.url ?? t.ref;
182
+ return X.current.set(n, t.name), n;
183
+ }), [
184
+ b,
185
+ O,
186
+ k,
187
+ a,
188
+ $
189
+ ]);
190
+ return {
191
+ content: T,
192
+ reload: w.reload,
193
+ loading: !!C && (w.loading || !w.loaded && y.initial === void 0),
194
+ error: w.error,
195
+ saving: re > 0,
196
+ create: se,
197
+ update: ce,
198
+ putText: le,
199
+ publish: ue,
200
+ unpublish: de,
201
+ remove: fe,
202
+ restore: pe,
203
+ setCover: me,
204
+ uploadImage: he,
205
+ imageSrc: Z,
206
+ coverSrc: Z(M?.image),
207
+ text: oe,
208
+ storedBody: Q
209
+ };
210
+ }
211
+ //#endregion
212
+ export { y as useContent, g as useManagedContents };
213
+
214
+ //# sourceMappingURL=contents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contents.js","names":[],"sources":["../../src/react/contents.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ContentKitClient } from \"../client/client.js\";\nimport type { ContentKitError } from \"../client/errors.js\";\nimport type { CatalogText, Content, ContentInput, ContentPatch } from \"../client/generated/wire.js\";\nimport { BODY_SUFFIX, IMAGE_SCHEME, imageRef, imageRefs, type ManageQuery } from \"../client/contents.js\";\nimport { useMediaRead } from \"./read.js\";\nimport { useGuarded } from \"./context.js\";\nimport { keyOf, offsetPages, useContentScope, useList, useResource, type UseList } from \"./use-resource.js\";\n\nexport interface ManageFilter extends Omit<ManageQuery, \"limit\" | \"offset\"> {\n pageSize?: number;\n}\n\n/** The content items the caller manages, newest first, a page at a time. */\nexport function useManagedContents(f: ManageFilter = {}, o: { client?: ContentKitClient } = {}): UseList<Content> {\n const { client, store, scope } = useContentScope(o.client);\n const { pageSize, ...q } = f;\n const size = pageSize ?? 20;\n return useList(\n store,\n keyOf(\"contents\", scope, q.kind, q.state, q.owner_group, q.q, q.language, size),\n { type: \"contents\", scope: q.state === \"deleted\" ? \"deleted\" : undefined },\n offsetPages(size, (page, signal) => client.contents.manage({ ...q, ...page }, signal)),\n );\n}\n\nexport interface UseContent {\n /** null before create (or while loading). */\n content: Content | null;\n loading: boolean;\n error?: ContentKitError;\n /** Writes in flight. */\n saving: boolean;\n /** Reads the item again. */\n reload: () => void;\n /** Creates the item as a draft; the hook then edits it. */\n create: (input: ContentInput) => Promise<Content>;\n update: (patch: ContentPatch) => Promise<Content>;\n /** Sets the text in the hook's language; a body from the editor is stored with image references (storedBody). */\n putText: (text: CatalogText) => Promise<Content>;\n /** Publishes now, or schedules for at. */\n publish: (at?: string) => Promise<Content>;\n unpublish: () => Promise<Content>;\n remove: () => Promise<void>;\n restore: () => Promise<Content>;\n /** Uploads the cover (null clears it); resolves with a URL that shows it now. */\n setCover: (file: Blob | null) => Promise<string | null>;\n /** Uploads an image for the body; resolves with a URL that shows it now, to place in the editor. */\n uploadImage: (file: Blob) => Promise<string>;\n /**\n * A URL that shows one of the item's images now, by name (\"i-{uuid}\") or\n * reference: a fresh upload from its file, else its public file\n * (`content.images`), else, while it has none (an unpublished item's), its\n * signed editor view from an editor read. Anything else is returned as is.\n */\n imageSrc: (image: string | null | undefined) => string | undefined;\n /** The cover through imageSrc. */\n coverSrc: string | undefined;\n /** The language's stored text, its body's images through imageSrc: what an editor shows. */\n text: CatalogText | undefined;\n /** HTML from the editor with every image URL this hook showed turned back into the image's reference. */\n storedBody: (html: string) => string;\n}\n\n/** The names of the images a body references, once each. */\nconst refNames = (body: string | undefined) => [...new Set([...(body ?? \"\").matchAll(imageRefs())].map((m) => m[1]!))];\nconst uploadName = (path: string) => {\n const base = path.slice(path.lastIndexOf(\"/\") + 1);\n const dot = base.lastIndexOf(\".\");\n return dot > 0 ? base.slice(0, dot) : base;\n};\n\n/**\n * One content item of kind for its editors: read, create, text in language,\n * publish, delete, restore, cover and body images. null creates a new item.\n */\nexport function useContent(id: string | null | undefined, kind: string, language: string, o: { initial?: Content; client?: ContentKitClient } = {}): UseContent {\n const { client, store, scope } = useContentScope(o.client);\n const [created, setCreated] = useState<string | null>(null);\n const cid = id ?? created;\n const key = cid ? keyOf(\"content\", scope, cid) : null;\n const r = useResource<Content | null>(store, key, { type: \"content\", id: cid ?? undefined }, (s) => client.contents.get(cid!, language, s), { initial: o.initial });\n const content = r.data ?? null;\n const [inflight, setInflight] = useState(0);\n const guarded = useGuarded();\n const run = useCallback(async <T>(fn: () => Promise<T>): Promise<T> => {\n setInflight((n) => n + 1);\n try {\n return await guarded(fn);\n } finally {\n setInflight((n) => n - 1);\n }\n }, [guarded]);\n const need = useCallback(() => {\n if (!cid) throw new Error(\"contentkit-ui: create the item first\");\n return cid;\n }, [cid]);\n const stored = content?.text?.[language];\n const body = stored?.body;\n const cover = content?.cover;\n\n // Images: fresh uploads show from their file, published ones from\n // content.images, the rest (an unpublished item's) from an editor read.\n const [previews, setPreviews] = useState<ReadonlyMap<string, string>>(new Map());\n const blobs = useRef<string[]>([]);\n useEffect(() => {\n const urls = blobs.current;\n return () => {\n for (const u of urls) URL.revokeObjectURL(u);\n };\n }, []);\n const published = useMemo(() => new Map(Object.entries(content?.images ?? {})), [content?.images]);\n // The cover is the item's folder's; body images are its body folder's ({kind}.body).\n const coverPending = !!cover && !cover.url && !previews.has(cover.image) && !published.has(cover.image);\n const bodyPending = useMemo(() => refNames(body).filter((n) => !previews.has(n) && !published.has(n)), [body, previews, published]);\n const pending = useMemo(() => (coverPending ? [...bodyPending, cover!.image] : bodyPending), [coverPending, bodyPending, cover]);\n const folder = useMemo(() => ({ kind, id: cid ?? \"none\" }), [kind, cid]);\n const bodyFolder = useMemo(() => ({ kind: kind + BODY_SUFFIX, id: cid ?? \"none\" }), [kind, cid]);\n const coverRead = useMediaRead(folder, { editor: true, read: coverPending ? undefined : null, client });\n const bodyRead = useMediaRead(bodyFolder, { editor: true, read: bodyPending.length ? undefined : null, client });\n const files = useMemo(() => [...(coverRead.read?.files ?? []), ...(bodyRead.read?.files ?? [])], [coverRead.read, bodyRead.read]);\n const views = useMemo(() => {\n const out = new Map<string, string>();\n for (const f of files) if (f.upload && f.editor_url) out.set(uploadName(f.path), f.editor_url);\n return out;\n }, [files]);\n // Editor views render on the first editor read that misses them: read again, backing off.\n const failed = (n: string) => files.some((f) => f.failed && uploadName(f.path) === n);\n const missing = (!!coverRead.read || !!bodyRead.read) && pending.some((n) => !views.has(n) && !failed(n));\n const tries = useRef(0);\n const reloadCover = coverRead.reload;\n const reloadBody = bodyRead.reload;\n const reload = useCallback(() => {\n reloadCover();\n reloadBody();\n }, [reloadCover, reloadBody]);\n useEffect(() => {\n if (!missing) {\n tries.current = 0;\n return;\n }\n if (tries.current >= 6) return;\n const t = setTimeout(() => {\n tries.current++;\n reload();\n }, 1000 * 2 ** tries.current);\n return () => clearTimeout(t);\n }, [missing, files, reload]);\n\n // Every URL shown for an image, of this and earlier reads, back to its name.\n const shown = useRef(new Map<string, string>());\n useEffect(() => {\n for (const m of [previews, published, views]) for (const [n, u] of m) shown.current.set(u, n);\n }, [previews, published, views]);\n\n const imageSrc = useCallback(\n (image: string | null | undefined) => {\n if (!image) return undefined;\n const n = image.startsWith(IMAGE_SCHEME) ? image.slice(IMAGE_SCHEME.length) : image;\n return previews.get(n) ?? published.get(n) ?? views.get(n) ?? image;\n },\n [previews, published, views],\n );\n const text = useMemo(\n () => (stored ? { ...stored, body: (stored.body ?? \"\").replace(imageRefs(), (ref, n: string) => previews.get(n) ?? published.get(n) ?? views.get(n) ?? ref) } : undefined),\n [stored, previews, published, views],\n );\n const storedBody = useCallback(\n (html: string) => {\n const back = new Map(shown.current);\n for (const m of [previews, published, views]) for (const [n, u] of m) back.set(u, n);\n let out = html;\n for (const [u, n] of back) out = out.split(u).join(imageRef(n)).split(u.replaceAll(\"&\", \"&amp;\")).join(imageRef(n));\n return out;\n },\n [previews, published, views],\n );\n const preview = useCallback((name: string, file: Blob): string | undefined => {\n if (typeof URL.createObjectURL !== \"function\") return undefined;\n const url = URL.createObjectURL(file);\n blobs.current.push(url);\n setPreviews((m) => new Map(m).set(name, url));\n return url;\n }, []);\n\n const create = useCallback(\n (input: ContentInput) =>\n run(async () => {\n const c = await client.contents.create(input);\n setCreated(c.id);\n return c;\n }),\n [client, run],\n );\n const update = useCallback((patch: ContentPatch) => run(() => client.contents.update(need(), patch)), [client, run, need]);\n const putText = useCallback(\n (t: CatalogText) => run(() => client.contents.putText(need(), language, t.body === undefined ? t : { ...t, body: storedBody(t.body) })),\n [client, run, need, language, storedBody],\n );\n const publish = useCallback((at?: string) => run(() => client.contents.publish(need(), at)), [client, run, need]);\n const unpublish = useCallback(() => run(() => client.contents.unpublish(need())), [client, run, need]);\n const remove = useCallback(() => run(() => client.contents.remove(need())), [client, run, need]);\n const restore = useCallback(() => run(() => client.contents.restore(need())), [client, run, need]);\n const setCover = useCallback(\n (file: Blob | null) =>\n run(async () => {\n if (!file) {\n await client.contents.setCover(need(), null);\n return null;\n }\n const up = await client.media.uploadNamed({ kind, id: need() }, file);\n const saved = await client.contents.setCover(need(), up.name);\n const url = preview(up.name, file) ?? saved.cover?.url ?? null;\n if (url) shown.current.set(url, up.name);\n return url;\n }),\n [client, run, need, kind, preview],\n );\n const uploadImage = useCallback(\n (file: Blob) =>\n run(async () => {\n const up = await client.media.uploadInline({ kind: kind + BODY_SUFFIX, id: need() }, file);\n const url = preview(up.name, file) ?? up.url ?? up.ref;\n shown.current.set(url, up.name);\n return url;\n }),\n [client, run, need, kind, preview],\n );\n return {\n content,\n reload: r.reload,\n loading: !!key && (r.loading || (!r.loaded && o.initial === undefined)),\n error: r.error,\n saving: inflight > 0,\n create,\n update,\n putText,\n publish,\n unpublish,\n remove,\n restore,\n setCover,\n uploadImage,\n imageSrc,\n coverSrc: imageSrc(cover?.image),\n text,\n storedBody,\n };\n}\n"],"mappings":";;;;;;AAcA,SAAgB,EAAmB,IAAkB,CAAC,GAAG,IAAmC,CAAC,GAAqB;CAChH,IAAM,EAAE,WAAQ,UAAO,aAAU,EAAgB,EAAE,MAAM,GACnD,EAAE,aAAU,GAAG,MAAM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KAAc,GACjB,MACC,EAAI,YAAY;EACd,IAAM,IAAK,MAAM,EAAO,MAAM,aAAa;GAAE,MAAM,IAAO;GAAa,IAAI,EAAK;EAAE,GAAG,CAAI,GACnF,IAAM,EAAQ,EAAG,MAAM,CAAI,KAAK,EAAG,OAAO,EAAG;EAEnD,OADA,EAAM,QAAQ,IAAI,GAAK,EAAG,IAAI,GACvB;CACT,CAAC,GACH;EAAC;EAAQ;EAAK;EAAM;EAAM;CAAO,CACnC;CACA,OAAO;EACL;EACA,QAAQ,EAAE;EACV,SAAS,CAAC,CAAC,MAAQ,EAAE,WAAY,CAAC,EAAE,UAAU,EAAE,YAAY,KAAA;EAC5D,OAAO,EAAE;EACT,QAAQ,KAAW;EACnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU,EAAS,GAAO,KAAK;EAC/B;EACA;CACF;AACF"}
@@ -5,7 +5,7 @@ import { ReadStore } from './store.js';
5
5
  /** What failed: a component's or hook's save, load or render step. */
6
6
  export type ContentKitOperation = "poster.load" | "poster.frame" | "poster.save" | "slot.load" | "slot.decode" | "slot.save" | "slot.remove" | "upload" | "folder.load" | "folder.commit" | "folder.update" | "folder.process" | "crop.load" | "crop.save" | SocialOperation;
7
7
  /** What failed in a content component: a load or a write. */
8
- export type SocialOperation = "comment.load" | "comment.post" | "comment.edit" | "comment.delete" | "comment.react" | "comment.restore" | "ban.save" | "ban.lift" | "reaction.save" | "favorite.save" | "poll.load" | "poll.vote" | "poll.answer" | "poll.save" | "post.load" | "post.save" | "moderation.load" | "moderation.resolve" | "taxonomy.load" | "taxonomy.save" | "media.save" | "notifications.load" | "notifications.read" | "notifications.dismiss";
8
+ export type SocialOperation = "comment.load" | "comment.post" | "comment.edit" | "comment.delete" | "comment.react" | "comment.restore" | "ban.save" | "ban.lift" | "reaction.save" | "favorite.save" | "poll.load" | "poll.vote" | "poll.answer" | "poll.save" | "post.load" | "content.save" | "moderation.load" | "moderation.resolve" | "media.save" | "notifications.load" | "notifications.read" | "notifications.dismiss" | "group.load" | "group.save" | "membership.save" | "history.forget" | "filters.save" | "offer.save" | "membership.join";
9
9
  /** The failure's context: the operation and, for one file, its name. */
10
10
  export interface ContentKitErrorInfo {
11
11
  operation: ContentKitOperation;
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":[],"sources":["../../src/react/context.ts"],"sourcesContent":["import { createContext, useCallback, useContext, useLayoutEffect, useRef } from \"react\";\nimport type { ContentKitClient } from \"../client/client.js\";\nimport { toContentKitError, type ContentKitError } from \"../client/errors.js\";\nimport type { ContentURLs } from \"../urls/index.js\";\nimport type { ReadStore } from \"./store.js\";\n\n/** What failed: a component's or hook's save, load or render step. */\nexport type ContentKitOperation =\n | \"poster.load\"\n | \"poster.frame\"\n | \"poster.save\"\n | \"slot.load\"\n | \"slot.decode\"\n | \"slot.save\"\n | \"slot.remove\"\n | \"upload\"\n | \"folder.load\"\n | \"folder.commit\"\n | \"folder.update\"\n | \"folder.process\"\n | \"crop.load\"\n | \"crop.save\"\n | SocialOperation;\n\n/** What failed in a content component: a load or a write. */\nexport type SocialOperation =\n | \"comment.load\"\n | \"comment.post\"\n | \"comment.edit\"\n | \"comment.delete\"\n | \"comment.react\"\n | \"comment.restore\"\n | \"ban.save\"\n | \"ban.lift\"\n | \"reaction.save\"\n | \"favorite.save\"\n | \"poll.load\"\n | \"poll.vote\"\n | \"poll.answer\"\n | \"poll.save\"\n | \"post.load\"\n | \"post.save\"\n | \"moderation.load\"\n | \"moderation.resolve\"\n | \"taxonomy.load\"\n | \"taxonomy.save\"\n | \"media.save\"\n | \"notifications.load\"\n | \"notifications.read\"\n | \"notifications.dismiss\";\n\n/** The failure's context: the operation and, for one file, its name. */\nexport interface ContentKitErrorInfo {\n operation: ContentKitOperation;\n file?: string;\n}\n\n/**\n * Every failure a component shows is also reported here (aborts excepted), so\n * the host can toast or log it. Components still show it in place.\n */\nexport type ContentKitErrorHandler = (error: ContentKitError, info: ContentKitErrorInfo) => void;\n\n/** The host router: in-app navigation, e.g. a canonical replace. */\nexport type Navigate = (to: string, options?: { replace?: boolean }) => void;\n\nexport interface ContentKitContextValue {\n client: ContentKitClient;\n /**\n * The signed-in user's id as ContentKit sees it, null when signed out,\n * undefined when the host does not say. Content reads are kept per viewer.\n */\n viewer?: string | null;\n /** Request language; keep it in sync with the client's language callback. */\n language?: string;\n /** Change when the current viewer's permissions or entitlements change. */\n accessRevision?: string | number;\n readScope: string;\n /** Asks the visitor to sign in; with it, signed-out visitors are prompted instead of acting anonymously. */\n onSignIn?: () => void;\n /** The host's content URL config (createContentURLs). */\n urls?: ContentURLs;\n navigate?: Navigate;\n onError?: ContentKitErrorHandler;\n /** The reads hooks share. */\n store: ReadStore;\n}\n\nexport const ContentKitContext = createContext<ContentKitContextValue | null>(null);\n\n/** Values that can change a read without changing its content reference. */\nexport function useReadScope(): string {\n return useContext(ContentKitContext)?.readScope ?? \"{}\";\n}\n\n/** The ContentKitProvider's value; throws outside one. */\nexport function useContentKit(): ContentKitContextValue {\n const ctx = useContext(ContentKitContext);\n if (!ctx) throw new Error(\"contentkit-ui: wrap the tree in <ContentKitProvider client>\");\n return ctx;\n}\n\n/** The client a hook or component uses: its own, else the provider's; throws without either. */\nexport function useContentKitClient(own?: ContentKitClient | null): ContentKitClient {\n const c = useOptionalContentKitClient(own);\n if (!c) throw new Error(\"contentkit-ui: pass `client` or render inside <ContentKitProvider client>\");\n return c;\n}\n\nexport function useOptionalContentKitClient(own?: ContentKitClient | null): ContentKitClient | null {\n const ctx = useContext(ContentKitContext);\n const client = own ?? ctx?.client ?? null;\n const scope = useReadScope();\n useLayoutEffect(() => { client?.setReadScope(scope); }, [client, scope]);\n return client;\n}\n\n/** The provider's content URL helpers; throws when none were given. */\nexport function useContentURLs(): ContentURLs {\n const urls = useContext(ContentKitContext)?.urls;\n if (!urls) throw new Error(\"contentkit-ui: pass `urls` to <ContentKitProvider>\");\n return urls;\n}\n\n/** A stable reporter: the component's own `onError`, else the provider's. */\nexport function useErrorReporter(own?: ContentKitErrorHandler): (e: unknown, operation: ContentKitOperation, file?: string) => void {\n const ctx = useContext(ContentKitContext)?.onError;\n const handler = useRef(own ?? ctx);\n handler.current = own ?? ctx;\n return useCallback((e: unknown, operation: ContentKitOperation, file?: string) => {\n const error = toContentKitError(e);\n if (error.code !== \"aborted\") handler.current?.(error, file === undefined ? { operation } : { operation, file });\n }, []);\n}\n\n/** Runs a write, e.g. auth-ui's useStepUpGuard(): re-authenticates when the write asks for a recent sign-in, then retries. */\nexport type ContentKitGuard = <T>(write: () => Promise<T>) => Promise<T>;\n\n/** The admin flow's guard; hooks run their writes through it. */\nexport const GuardContext = createContext<ContentKitGuard | undefined>(undefined);\n\n/** Runs fn through the flow's guard, when the host gave one. */\nexport function useGuarded(): <T>(fn: () => Promise<T>) => Promise<T> {\n const guard = useContext(GuardContext);\n return useCallback(<T,>(fn: () => Promise<T>) => (guard ? guard(fn) : fn()), [guard]);\n}\n"],"mappings":";;;AAwFA,IAAa,IAAoB,EAA6C,IAAI;AAGlF,SAAgB,IAAuB;CACrC,OAAO,EAAW,CAAiB,CAAC,EAAE,aAAa;AACrD;AAGA,SAAgB,IAAwC;CACtD,IAAM,IAAM,EAAW,CAAiB;CACxC,IAAI,CAAC,GAAK,MAAU,MAAM,6DAA6D;CACvF,OAAO;AACT;AAGA,SAAgB,EAAoB,GAAiD;CACnF,IAAM,IAAI,EAA4B,CAAG;CACzC,IAAI,CAAC,GAAG,MAAU,MAAM,2EAA2E;CACnG,OAAO;AACT;AAEA,SAAgB,EAA4B,GAAwD;CAClG,IAAM,IAAM,EAAW,CAAiB,GAClC,IAAS,KAAO,GAAK,UAAU,MAC/B,IAAQ,EAAa;CAE3B,OADA,QAAsB;EAAE,GAAQ,aAAa,CAAK;CAAG,GAAG,CAAC,GAAQ,CAAK,CAAC,GAChE;AACT;AAGA,SAAgB,IAA8B;CAC5C,IAAM,IAAO,EAAW,CAAiB,CAAC,EAAE;CAC5C,IAAI,CAAC,GAAM,MAAU,MAAM,oDAAoD;CAC/E,OAAO;AACT;AAGA,SAAgB,EAAiB,GAAmG;CAClI,IAAM,IAAM,EAAW,CAAiB,CAAC,EAAE,SACrC,IAAU,EAAO,KAAO,CAAG;CAEjC,OADA,EAAQ,UAAU,KAAO,GAClB,GAAa,GAAY,GAAgC,MAAkB;EAChF,IAAM,IAAQ,EAAkB,CAAC;EACjC,AAAI,EAAM,SAAS,aAAW,EAAQ,UAAU,GAAO,MAAS,KAAA,IAAY,EAAE,aAAU,IAAI;GAAE;GAAW;EAAK,CAAC;CACjH,GAAG,CAAC,CAAC;AACP;AAMA,IAAa,IAAe,EAA2C,KAAA,CAAS;AAGhF,SAAgB,IAAsD;CACpE,IAAM,IAAQ,EAAW,CAAY;CACrC,OAAO,GAAiB,MAA0B,IAAQ,EAAM,CAAE,IAAI,EAAG,GAAI,CAAC,CAAK,CAAC;AACtF"}
1
+ {"version":3,"file":"context.js","names":[],"sources":["../../src/react/context.ts"],"sourcesContent":["import { createContext, useCallback, useContext, useLayoutEffect, useRef } from \"react\";\nimport type { ContentKitClient } from \"../client/client.js\";\nimport { toContentKitError, type ContentKitError } from \"../client/errors.js\";\nimport type { ContentURLs } from \"../urls/index.js\";\nimport type { ReadStore } from \"./store.js\";\n\n/** What failed: a component's or hook's save, load or render step. */\nexport type ContentKitOperation =\n | \"poster.load\"\n | \"poster.frame\"\n | \"poster.save\"\n | \"slot.load\"\n | \"slot.decode\"\n | \"slot.save\"\n | \"slot.remove\"\n | \"upload\"\n | \"folder.load\"\n | \"folder.commit\"\n | \"folder.update\"\n | \"folder.process\"\n | \"crop.load\"\n | \"crop.save\"\n | SocialOperation;\n\n/** What failed in a content component: a load or a write. */\nexport type SocialOperation =\n | \"comment.load\"\n | \"comment.post\"\n | \"comment.edit\"\n | \"comment.delete\"\n | \"comment.react\"\n | \"comment.restore\"\n | \"ban.save\"\n | \"ban.lift\"\n | \"reaction.save\"\n | \"favorite.save\"\n | \"poll.load\"\n | \"poll.vote\"\n | \"poll.answer\"\n | \"poll.save\"\n | \"post.load\"\n | \"content.save\"\n | \"moderation.load\"\n | \"moderation.resolve\"\n | \"media.save\"\n | \"notifications.load\"\n | \"notifications.read\"\n | \"notifications.dismiss\"\n | \"group.load\"\n | \"group.save\"\n | \"membership.save\"\n | \"history.forget\"\n | \"filters.save\"\n | \"offer.save\"\n | \"membership.join\";\n\n/** The failure's context: the operation and, for one file, its name. */\nexport interface ContentKitErrorInfo {\n operation: ContentKitOperation;\n file?: string;\n}\n\n/**\n * Every failure a component shows is also reported here (aborts excepted), so\n * the host can toast or log it. Components still show it in place.\n */\nexport type ContentKitErrorHandler = (error: ContentKitError, info: ContentKitErrorInfo) => void;\n\n/** The host router: in-app navigation, e.g. a canonical replace. */\nexport type Navigate = (to: string, options?: { replace?: boolean }) => void;\n\nexport interface ContentKitContextValue {\n client: ContentKitClient;\n /**\n * The signed-in user's id as ContentKit sees it, null when signed out,\n * undefined when the host does not say. Content reads are kept per viewer.\n */\n viewer?: string | null;\n /** Request language; keep it in sync with the client's language callback. */\n language?: string;\n /** Change when the current viewer's permissions or entitlements change. */\n accessRevision?: string | number;\n readScope: string;\n /** Asks the visitor to sign in; with it, signed-out visitors are prompted instead of acting anonymously. */\n onSignIn?: () => void;\n /** The host's content URL config (createContentURLs). */\n urls?: ContentURLs;\n navigate?: Navigate;\n onError?: ContentKitErrorHandler;\n /** The reads hooks share. */\n store: ReadStore;\n}\n\nexport const ContentKitContext = createContext<ContentKitContextValue | null>(null);\n\n/** Values that can change a read without changing its content reference. */\nexport function useReadScope(): string {\n return useContext(ContentKitContext)?.readScope ?? \"{}\";\n}\n\n/** The ContentKitProvider's value; throws outside one. */\nexport function useContentKit(): ContentKitContextValue {\n const ctx = useContext(ContentKitContext);\n if (!ctx) throw new Error(\"contentkit-ui: wrap the tree in <ContentKitProvider client>\");\n return ctx;\n}\n\n/** The client a hook or component uses: its own, else the provider's; throws without either. */\nexport function useContentKitClient(own?: ContentKitClient | null): ContentKitClient {\n const c = useOptionalContentKitClient(own);\n if (!c) throw new Error(\"contentkit-ui: pass `client` or render inside <ContentKitProvider client>\");\n return c;\n}\n\nexport function useOptionalContentKitClient(own?: ContentKitClient | null): ContentKitClient | null {\n const ctx = useContext(ContentKitContext);\n const client = own ?? ctx?.client ?? null;\n const scope = useReadScope();\n useLayoutEffect(() => { client?.setReadScope(scope); }, [client, scope]);\n return client;\n}\n\n/** The provider's content URL helpers; throws when none were given. */\nexport function useContentURLs(): ContentURLs {\n const urls = useContext(ContentKitContext)?.urls;\n if (!urls) throw new Error(\"contentkit-ui: pass `urls` to <ContentKitProvider>\");\n return urls;\n}\n\n/** A stable reporter: the component's own `onError`, else the provider's. */\nexport function useErrorReporter(own?: ContentKitErrorHandler): (e: unknown, operation: ContentKitOperation, file?: string) => void {\n const ctx = useContext(ContentKitContext)?.onError;\n const handler = useRef(own ?? ctx);\n handler.current = own ?? ctx;\n return useCallback((e: unknown, operation: ContentKitOperation, file?: string) => {\n const error = toContentKitError(e);\n if (error.code !== \"aborted\") handler.current?.(error, file === undefined ? { operation } : { operation, file });\n }, []);\n}\n\n/** Runs a write, e.g. auth-ui's useStepUpGuard(): re-authenticates when the write asks for a recent sign-in, then retries. */\nexport type ContentKitGuard = <T>(write: () => Promise<T>) => Promise<T>;\n\n/** The admin flow's guard; hooks run their writes through it. */\nexport const GuardContext = createContext<ContentKitGuard | undefined>(undefined);\n\n/** Runs fn through the flow's guard, when the host gave one. */\nexport function useGuarded(): <T>(fn: () => Promise<T>) => Promise<T> {\n const guard = useContext(GuardContext);\n return useCallback(<T,>(fn: () => Promise<T>) => (guard ? guard(fn) : fn()), [guard]);\n}\n"],"mappings":";;;AA6FA,IAAa,IAAoB,EAA6C,IAAI;AAGlF,SAAgB,IAAuB;CACrC,OAAO,EAAW,CAAiB,CAAC,EAAE,aAAa;AACrD;AAGA,SAAgB,IAAwC;CACtD,IAAM,IAAM,EAAW,CAAiB;CACxC,IAAI,CAAC,GAAK,MAAU,MAAM,6DAA6D;CACvF,OAAO;AACT;AAGA,SAAgB,EAAoB,GAAiD;CACnF,IAAM,IAAI,EAA4B,CAAG;CACzC,IAAI,CAAC,GAAG,MAAU,MAAM,2EAA2E;CACnG,OAAO;AACT;AAEA,SAAgB,EAA4B,GAAwD;CAClG,IAAM,IAAM,EAAW,CAAiB,GAClC,IAAS,KAAO,GAAK,UAAU,MAC/B,IAAQ,EAAa;CAE3B,OADA,QAAsB;EAAE,GAAQ,aAAa,CAAK;CAAG,GAAG,CAAC,GAAQ,CAAK,CAAC,GAChE;AACT;AAGA,SAAgB,IAA8B;CAC5C,IAAM,IAAO,EAAW,CAAiB,CAAC,EAAE;CAC5C,IAAI,CAAC,GAAM,MAAU,MAAM,oDAAoD;CAC/E,OAAO;AACT;AAGA,SAAgB,EAAiB,GAAmG;CAClI,IAAM,IAAM,EAAW,CAAiB,CAAC,EAAE,SACrC,IAAU,EAAO,KAAO,CAAG;CAEjC,OADA,EAAQ,UAAU,KAAO,GAClB,GAAa,GAAY,GAAgC,MAAkB;EAChF,IAAM,IAAQ,EAAkB,CAAC;EACjC,AAAI,EAAM,SAAS,aAAW,EAAQ,UAAU,GAAO,MAAS,KAAA,IAAY,EAAE,aAAU,IAAI;GAAE;GAAW;EAAK,CAAC;CACjH,GAAG,CAAC,CAAC;AACP;AAMA,IAAa,IAAe,EAA2C,KAAA,CAAS;AAGhF,SAAgB,IAAsD;CACpE,IAAM,IAAQ,EAAW,CAAY;CACrC,OAAO,GAAiB,MAA0B,IAAQ,EAAM,CAAE,IAAI,EAAG,GAAI,CAAC,CAAK,CAAC;AACtF"}
@@ -1,29 +1,30 @@
1
1
  import { toContentKitError as e } from "../client/errors.js";
2
- import { useContentKitClient as t, useErrorReporter as n } from "./context.js";
3
- import { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
2
+ import { itemKey as t } from "../client/media/ref.js";
3
+ import { useContentKitClient as n, useErrorReporter as r } from "./context.js";
4
+ import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
4
5
  //#region src/react/crop.ts
5
- function s(s, c, l = {}) {
6
- let { media: u } = t(l.client), d = n(l.onError), f = c ? `${s.kind}/${s.id}/${c}` : "", [p, m] = o(0), [h, g] = o({
6
+ function c(c, l, u = {}) {
7
+ let { media: d } = n(u.client), f = r(u.onError), p = l ? `${t(c)}:${l}` : "", [m, h] = s(0), [g, _] = s({
7
8
  key: "",
8
9
  state: { status: "idle" }
9
- }), _ = a({
10
- o: l,
11
- ref: s,
12
- path: c
10
+ }), v = o({
11
+ o: u,
12
+ ref: c,
13
+ path: l
13
14
  });
14
- _.current = {
15
- o: l,
16
- ref: s,
17
- path: c
18
- }, i(() => {
19
- let { ref: t, path: n } = _.current;
15
+ v.current = {
16
+ o: u,
17
+ ref: c,
18
+ path: l
19
+ }, a(() => {
20
+ let { ref: t, path: n } = v.current;
20
21
  if (!n) return;
21
22
  let r = new AbortController();
22
- return g({
23
- key: f,
23
+ return _({
24
+ key: p,
24
25
  state: { status: "loading" }
25
- }), u.editorView(t, n, { signal: r.signal }).then((e) => g({
26
- key: f,
26
+ }), d.editorView(t, n, { signal: r.signal }).then((e) => _({
27
+ key: p,
27
28
  state: {
28
29
  status: "cropping",
29
30
  source: {
@@ -36,27 +37,27 @@ function s(s, c, l = {}) {
36
37
  }), (t) => {
37
38
  if (r.signal.aborted) return;
38
39
  let i = e(t);
39
- g({
40
- key: f,
40
+ _({
41
+ key: p,
41
42
  state: {
42
43
  status: "error",
43
44
  error: i
44
45
  }
45
- }), d(i, "crop.load", n.split("/").pop());
46
+ }), f(i, "crop.load", n.split("/").pop());
46
47
  }), () => r.abort();
47
48
  }, [
48
- u,
49
- f,
49
+ d,
50
50
  p,
51
- d
51
+ m,
52
+ f
52
53
  ]);
53
- let v = h.key === f ? h.state : { status: f ? "loading" : "idle" }, y = a(v);
54
- y.current = v;
55
- let b = r(async (t) => {
56
- let n = y.current, { ref: r, path: i, o: a } = _.current, o = "source" in n ? n.source : void 0;
54
+ let y = g.key === p ? g.state : { status: p ? "loading" : "idle" }, b = o(y);
55
+ b.current = y;
56
+ let x = i(async (t) => {
57
+ let n = b.current, { ref: r, path: i, o: a } = v.current, o = "source" in n ? n.source : void 0;
57
58
  if (i && o) {
58
- g({
59
- key: f,
59
+ _({
60
+ key: p,
60
61
  state: {
61
62
  status: "saving",
62
63
  source: o,
@@ -64,13 +65,13 @@ function s(s, c, l = {}) {
64
65
  }
65
66
  });
66
67
  try {
67
- let e = await u.commit(r, [{
68
+ let e = await d.commit(r, [{
68
69
  op: "edit",
69
70
  path: i,
70
71
  ...t ? { edit: t } : {}
71
72
  }]);
72
- return a.wait && await u.waitFor(r, i), g({
73
- key: f,
73
+ return a.wait && await d.waitFor(r, i), _({
74
+ key: p,
74
75
  state: {
75
76
  status: "done",
76
77
  files: e
@@ -78,30 +79,30 @@ function s(s, c, l = {}) {
78
79
  }), a.onSaved?.(e), e;
79
80
  } catch (n) {
80
81
  let r = e(n);
81
- g({
82
- key: f,
82
+ _({
83
+ key: p,
83
84
  state: {
84
85
  status: "error",
85
86
  error: r,
86
87
  source: o,
87
88
  edit: t
88
89
  }
89
- }), d(r, "crop.save", i.split("/").pop());
90
+ }), f(r, "crop.save", i.split("/").pop());
90
91
  return;
91
92
  }
92
93
  }
93
94
  }, [
94
- u,
95
- f,
96
- d
97
- ]), x = r(() => m((e) => e + 1), []);
95
+ d,
96
+ p,
97
+ f
98
+ ]), S = i(() => h((e) => e + 1), []);
98
99
  return {
99
- ...v,
100
- save: b,
101
- retry: x
100
+ ...y,
101
+ save: x,
102
+ retry: S
102
103
  };
103
104
  }
104
105
  //#endregion
105
- export { s as useEditorCrop };
106
+ export { c as useEditorCrop };
106
107
 
107
108
  //# sourceMappingURL=crop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"crop.js","names":[],"sources":["../../src/react/crop.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { ContentKitClient } from \"../client/client.js\";\nimport { toContentKitError, type ContentKitError } from \"../client/errors.js\";\nimport type { Edit, FileInfo, RefBody } from \"../client/generated/wire.js\";\nimport type { CropSource } from \"../client/image.js\";\nimport { useContentKitClient, useErrorReporter, type ContentKitErrorHandler } from \"./context.js\";\n\nexport interface EditorCropOptions {\n /** save() also waits until the worker rendered the edit. Default false (an editor read shows it processing). */\n wait?: boolean;\n /** With the item's uploads after each save. */\n onSaved?: (files: FileInfo[]) => void;\n /** Every failed load or save; default the provider's. */\n onError?: ContentKitErrorHandler;\n /** Overrides the provider's client. */\n client?: ContentKitClient;\n}\n\n/** source is the upload's editor view and its oriented size; edit its current edit. */\nexport type EditorCropState =\n | { status: \"idle\" }\n | { status: \"loading\" }\n | { status: \"cropping\"; source: CropSource; edit: Edit | null }\n | { status: \"saving\"; source: CropSource; edit: Edit | null }\n | { status: \"done\"; files: FileInfo[] }\n | { status: \"error\"; error: ContentKitError; source?: CropSource; edit?: Edit | null };\n\nexport type UseEditorCrop = EditorCropState & {\n /** Commits the edit (null removes it); resolves with the item's uploads, or undefined on failure. */\n save: (edit: Edit | null) => Promise<FileInfo[] | undefined>;\n /** Loads the editor view again after a failure. */\n retry: () => void;\n};\n\n/**\n * Re-crops a kept upload: while path is set, its editor view (the original,\n * oriented, unedited) loads for a cropper; save() commits an edit op. Nothing\n * is uploaded. Clear path to close.\n */\nexport function useEditorCrop(ref: RefBody, path: string | null | undefined, o: EditorCropOptions = {}): UseEditorCrop {\n const { media } = useContentKitClient(o.client);\n const report = useErrorReporter(o.onError);\n const key = path ? `${ref.kind}/${ref.id}/${path}` : \"\";\n const [attempt, setAttempt] = useState(0);\n const [s, setS] = useState<{ key: string; state: EditorCropState }>({ key: \"\", state: { status: \"idle\" } });\n const opts = useRef({ o, ref, path });\n opts.current = { o, ref, path };\n\n useEffect(() => {\n const { ref, path } = opts.current;\n if (!path) return;\n const ctl = new AbortController();\n setS({ key, state: { status: \"loading\" } });\n media.editorView(ref, path, { signal: ctl.signal }).then(\n (v) => setS({ key, state: { status: \"cropping\", source: { url: v.url, width: v.width, height: v.height }, edit: v.edit ?? null } }),\n (e: unknown) => {\n if (ctl.signal.aborted) return;\n const error = toContentKitError(e);\n setS({ key, state: { status: \"error\", error } });\n report(error, \"crop.load\", path.split(\"/\").pop());\n },\n );\n return () => ctl.abort();\n }, [media, key, attempt, report]);\n\n const current = s.key === key ? s.state : ({ status: key ? \"loading\" : \"idle\" } as EditorCropState);\n const now = useRef(current);\n now.current = current;\n\n const save = useCallback(\n async (edit: Edit | null) => {\n const c = now.current;\n const { ref, path, o } = opts.current;\n const source = \"source\" in c ? c.source : undefined;\n if (!path || !source) return undefined;\n setS({ key, state: { status: \"saving\", source, edit } });\n try {\n const files = await media.commit(ref, [{ op: \"edit\", path, ...(edit ? { edit } : {}) }]);\n if (o.wait) await media.waitFor(ref, path);\n setS({ key, state: { status: \"done\", files } });\n o.onSaved?.(files);\n return files;\n } catch (e) {\n const error = toContentKitError(e);\n setS({ key, state: { status: \"error\", error, source, edit } });\n report(error, \"crop.save\", path.split(\"/\").pop());\n return undefined;\n }\n },\n [media, key, report],\n );\n const retry = useCallback(() => setAttempt((n) => n + 1), []);\n return { ...current, save, retry };\n}\n"],"mappings":";;;;AAuCA,SAAgB,EAAc,GAAc,GAAiC,IAAuB,CAAC,GAAkB;CACrH,IAAM,EAAE,aAAU,EAAoB,EAAE,MAAM,GACxC,IAAS,EAAiB,EAAE,OAAO,GACnC,IAAM,IAAO,GAAG,EAAI,KAAK,GAAG,EAAI,GAAG,GAAG,MAAS,IAC/C,CAAC,GAAS,KAAc,EAAS,CAAC,GAClC,CAAC,GAAG,KAAQ,EAAkD;EAAE,KAAK;EAAI,OAAO,EAAE,QAAQ,OAAO;CAAE,CAAC,GACpG,IAAO,EAAO;EAAE;EAAG;EAAK;CAAK,CAAC;CAGpC,AAFA,EAAK,UAAU;EAAE;EAAG;EAAK;CAAK,GAE9B,QAAgB;EACd,IAAM,EAAE,QAAK,YAAS,EAAK;EAC3B,IAAI,CAAC,GAAM;EACX,IAAM,IAAM,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C,GAC9C,EAAE,UAAU,CAAK,GACV;GACT,SAAS,GAAG;IACV,IAAM,IAAQ,EAAkB,CAAC;IAEjC,AADA,EAAK;KAAE;KAAK,OAAO;MAAE,QAAQ;MAAS;MAAO;MAAQ;KAAK;IAAE,CAAC,GAC7D,EAAO,GAAO,aAAa,EAAK,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC;IAChD;GACF;EAZuD;CAazD,GACA;EAAC;EAAO;EAAK;CAAM,CACrB,GACM,IAAQ,QAAkB,GAAY,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;CAC5D,OAAO;EAAE,GAAG;EAAS;EAAM;CAAM;AACnC"}
1
+ {"version":3,"file":"crop.js","names":[],"sources":["../../src/react/crop.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { itemKey } from \"../client/media/ref.js\";\nimport type { ContentKitClient } from \"../client/client.js\";\nimport { toContentKitError, type ContentKitError } from \"../client/errors.js\";\nimport type { Edit, FileInfo, RefBody } from \"../client/generated/wire.js\";\nimport type { CropSource } from \"../client/image.js\";\nimport { useContentKitClient, useErrorReporter, type ContentKitErrorHandler } from \"./context.js\";\n\nexport interface EditorCropOptions {\n /** save() also waits until the worker rendered the edit. Default false (an editor read shows it processing). */\n wait?: boolean;\n /** With the item's uploads after each save. */\n onSaved?: (files: FileInfo[]) => void;\n /** Every failed load or save; default the provider's. */\n onError?: ContentKitErrorHandler;\n /** Overrides the provider's client. */\n client?: ContentKitClient;\n}\n\n/** source is the upload's editor view and its oriented size; edit its current edit. */\nexport type EditorCropState =\n | { status: \"idle\" }\n | { status: \"loading\" }\n | { status: \"cropping\"; source: CropSource; edit: Edit | null }\n | { status: \"saving\"; source: CropSource; edit: Edit | null }\n | { status: \"done\"; files: FileInfo[] }\n | { status: \"error\"; error: ContentKitError; source?: CropSource; edit?: Edit | null };\n\nexport type UseEditorCrop = EditorCropState & {\n /** Commits the edit (null removes it); resolves with the item's uploads, or undefined on failure. */\n save: (edit: Edit | null) => Promise<FileInfo[] | undefined>;\n /** Loads the editor view again after a failure. */\n retry: () => void;\n};\n\n/**\n * Re-crops a kept upload: while path is set, its editor view (the original,\n * oriented, unedited) loads for a cropper; save() commits an edit op. Nothing\n * is uploaded. Clear path to close.\n */\nexport function useEditorCrop(ref: RefBody, path: string | null | undefined, o: EditorCropOptions = {}): UseEditorCrop {\n const { media } = useContentKitClient(o.client);\n const report = useErrorReporter(o.onError);\n const key = path ? `${itemKey(ref)}:${path}` : \"\";\n const [attempt, setAttempt] = useState(0);\n const [s, setS] = useState<{ key: string; state: EditorCropState }>({ key: \"\", state: { status: \"idle\" } });\n const opts = useRef({ o, ref, path });\n opts.current = { o, ref, path };\n\n useEffect(() => {\n const { ref, path } = opts.current;\n if (!path) return;\n const ctl = new AbortController();\n setS({ key, state: { status: \"loading\" } });\n media.editorView(ref, path, { signal: ctl.signal }).then(\n (v) => setS({ key, state: { status: \"cropping\", source: { url: v.url, width: v.width, height: v.height }, edit: v.edit ?? null } }),\n (e: unknown) => {\n if (ctl.signal.aborted) return;\n const error = toContentKitError(e);\n setS({ key, state: { status: \"error\", error } });\n report(error, \"crop.load\", path.split(\"/\").pop());\n },\n );\n return () => ctl.abort();\n }, [media, key, attempt, report]);\n\n const current = s.key === key ? s.state : ({ status: key ? \"loading\" : \"idle\" } as EditorCropState);\n const now = useRef(current);\n now.current = current;\n\n const save = useCallback(\n async (edit: Edit | null) => {\n const c = now.current;\n const { ref, path, o } = opts.current;\n const source = \"source\" in c ? c.source : undefined;\n if (!path || !source) return undefined;\n setS({ key, state: { status: \"saving\", source, edit } });\n try {\n const files = await media.commit(ref, [{ op: \"edit\", path, ...(edit ? { edit } : {}) }]);\n if (o.wait) await media.waitFor(ref, path);\n setS({ key, state: { status: \"done\", files } });\n o.onSaved?.(files);\n return files;\n } catch (e) {\n const error = toContentKitError(e);\n setS({ key, state: { status: \"error\", error, source, edit } });\n report(error, \"crop.save\", path.split(\"/\").pop());\n return undefined;\n }\n },\n [media, key, report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QAAS,EAAE,QAAQ,IAAM,YAAY,OAAO,GACxE,IAAM,EAAO,CAAO;CAC1B,EAAI,UAAU;CAEd,IAAM,IAAO,EACX,OAAO,MAAsB;EAC3B,IAAM,IAAI,EAAI,SACR,EAAE,QAAK,SAAM,SAAM,EAAK,SACxB,IAAS,YAAY,IAAI,EAAE,SAAS,KAAA;EACtC,IAAC,KAAS,GACd;KAAK;IAAE;IAAK,OAAO;KAAE,QAAQ;KAAU;KAAQ;IAAK;GAAE,CAAC;GACvD,IAAI;IACF,IAAM,IAAQ,MAAM,EAAM,OAAO,GAAK,CAAC;KAAE,IAAI;KAAQ;KAAM,GAAI,IAAO,EAAE,QAAK,IAAI,CAAC;IAAG,CAAC,CAAC;IAIvF,OAHI,EAAE,QAAM,MAAM,EAAM,QAAQ,GAAK,CAAI,GACzC,EAAK;KAAE;KAAK,OAAO;MAAE,QAAQ;MAAQ;KAAM;IAAE,CAAC,GAC9C,EAAE,UAAU,CAAK,GACV;GACT,SAAS,GAAG;IACV,IAAM,IAAQ,EAAkB,CAAC;IAEjC,AADA,EAAK;KAAE;KAAK,OAAO;MAAE,QAAQ;MAAS;MAAO;MAAQ;KAAK;IAAE,CAAC,GAC7D,EAAO,GAAO,aAAa,EAAK,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC;IAChD;GACF;EAZuD;CAazD,GACA;EAAC;EAAO;EAAK;CAAM,CACrB,GACM,IAAQ,QAAkB,GAAY,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC;CAC5D,OAAO;EAAE,GAAG;EAAS;EAAM;CAAM;AACnC"}
@@ -0,0 +1,30 @@
1
+ import { ContentKitClient } from '../client/client.js';
2
+ import { ContentKitError } from '../client/errors.js';
3
+ import { Content, Decision, Version } from '../client/generated/wire.js';
4
+ /** A content's live versions, first first. */
5
+ export declare function liveVersions(c: Content | null | undefined): Version[];
6
+ /** The version a reader of language opens by default: the first live one serving it, else the first live one. */
7
+ export declare function defaultVersion(c: Content | null | undefined, language?: string): Version | null;
8
+ export interface UseContentDetail {
9
+ content: Content | null;
10
+ /** Live versions, first first. */
11
+ versions: Version[];
12
+ /** The version shown: the one asked for when live, else the language's default. */
13
+ version: Version | null;
14
+ /** The shown version's access decision: allowed, what is sold, previews. */
15
+ decision: Decision | null;
16
+ /** Every language a live version serves, in version order. */
17
+ languages: string[];
18
+ loading: boolean;
19
+ error?: ContentKitError;
20
+ reload: () => void;
21
+ }
22
+ /**
23
+ * A content page's data: text in the reader's language, live versions with
24
+ * their segments and access decisions, groups, attributes and the version to show.
25
+ */
26
+ export declare function useContentDetail(id: string | null | undefined, o?: {
27
+ language?: string;
28
+ version?: string | null;
29
+ client?: ContentKitClient;
30
+ }): UseContentDetail;
@@ -0,0 +1,42 @@
1
+ import { keyOf as e, useContentScope as t, useResource as n } from "./use-resource.js";
2
+ import { useMemo as r } from "react";
3
+ //#region src/react/detail.ts
4
+ function i(e) {
5
+ return (e?.versions ?? []).filter((e) => e.live).sort((e, t) => e.position - t.position);
6
+ }
7
+ function a(e, t) {
8
+ let n = i(e);
9
+ return (t ? n.find((e) => e.languages.includes(t)) : void 0) ?? n[0] ?? null;
10
+ }
11
+ function o(o, s = {}) {
12
+ let { client: c, store: l, scope: u, language: d } = t(s.client), f = s.language ?? d, p = o ? e("content-detail", u, o, f) : null, m = n(l, p, {
13
+ type: "content-detail",
14
+ id: o ?? void 0
15
+ }, (e) => c.contents.get(o, f, e)), h = m.data ?? null;
16
+ return r(() => {
17
+ let e = i(h), t = e.find((e) => e.id === s.version) ?? a(h, f);
18
+ return {
19
+ content: h,
20
+ versions: e,
21
+ version: t,
22
+ decision: t?.decision ?? h?.decision ?? null,
23
+ languages: [...new Set(e.flatMap((e) => e.languages))],
24
+ loading: !!p && (m.loading || !m.loaded),
25
+ error: m.error,
26
+ reload: m.reload
27
+ };
28
+ }, [
29
+ h,
30
+ s.version,
31
+ f,
32
+ p,
33
+ m.loading,
34
+ m.loaded,
35
+ m.error,
36
+ m.reload
37
+ ]);
38
+ }
39
+ //#endregion
40
+ export { a as defaultVersion, i as liveVersions, o as useContentDetail };
41
+
42
+ //# sourceMappingURL=detail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detail.js","names":[],"sources":["../../src/react/detail.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport type { ContentKitClient } from \"../client/client.js\";\nimport type { ContentKitError } from \"../client/errors.js\";\nimport type { Content, Decision, Version } from \"../client/generated/wire.js\";\nimport { keyOf, useContentScope, useResource } from \"./use-resource.js\";\n\n/** A content's live versions, first first. */\nexport function liveVersions(c: Content | null | undefined): Version[] {\n return (c?.versions ?? []).filter((v) => v.live).sort((a, b) => a.position - b.position);\n}\n\n/** The version a reader of language opens by default: the first live one serving it, else the first live one. */\nexport function defaultVersion(c: Content | null | undefined, language?: string): Version | null {\n const live = liveVersions(c);\n return (language ? live.find((v) => v.languages.includes(language)) : undefined) ?? live[0] ?? null;\n}\n\nexport interface UseContentDetail {\n content: Content | null;\n /** Live versions, first first. */\n versions: Version[];\n /** The version shown: the one asked for when live, else the language's default. */\n version: Version | null;\n /** The shown version's access decision: allowed, what is sold, previews. */\n decision: Decision | null;\n /** Every language a live version serves, in version order. */\n languages: string[];\n loading: boolean;\n error?: ContentKitError;\n reload: () => void;\n}\n\n/**\n * A content page's data: text in the reader's language, live versions with\n * their segments and access decisions, groups, attributes and the version to show.\n */\nexport function useContentDetail(id: string | null | undefined, o: { language?: string; version?: string | null; client?: ContentKitClient } = {}): UseContentDetail {\n const { client, store, scope, language: provided } = useContentScope(o.client);\n const language = o.language ?? provided;\n const key = id ? keyOf(\"content-detail\", scope, id, language) : null;\n const r = useResource<Content>(store, key, { type: \"content-detail\", id: id ?? undefined }, (s) => client.contents.get(id!, language, s));\n const content = r.data ?? null;\n return useMemo(() => {\n const versions = liveVersions(content);\n const version = versions.find((v) => v.id === o.version) ?? defaultVersion(content, language);\n return {\n content,\n versions,\n version,\n decision: version?.decision ?? content?.decision ?? null,\n languages: [...new Set(versions.flatMap((v) => v.languages))],\n loading: !!key && (r.loading || !r.loaded),\n error: r.error,\n reload: r.reload,\n };\n }, [content, o.version, language, key, r.loading, r.loaded, r.error, r.reload]);\n}\n"],"mappings":";;;AAOA,SAAgB,EAAa,GAA0C;CACrE,QAAQ,GAAG,YAAY,CAAC,EAAA,CAAG,QAAQ,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AACzF;AAGA,SAAgB,EAAe,GAA+B,GAAmC;CAC/F,IAAM,IAAO,EAAa,CAAC;CAC3B,QAAQ,IAAW,EAAK,MAAM,MAAM,EAAE,UAAU,SAAS,CAAQ,CAAC,IAAI,KAAA,MAAc,EAAK,MAAM;AACjG;AAqBA,SAAgB,EAAiB,GAA+B,IAA+E,CAAC,GAAqB;CACnK,IAAM,EAAE,WAAQ,UAAO,UAAO,UAAU,MAAa,EAAgB,EAAE,MAAM,GACvE,IAAW,EAAE,YAAY,GACzB,IAAM,IAAK,EAAM,kBAAkB,GAAO,GAAI,CAAQ,IAAI,MAC1D,IAAI,EAAqB,GAAO,GAAK;EAAE,MAAM;EAAkB,IAAI,KAAM,KAAA;CAAU,IAAI,MAAM,EAAO,SAAS,IAAI,GAAK,GAAU,CAAC,CAAC,GAClI,IAAU,EAAE,QAAQ;CAC1B,OAAO,QAAc;EACnB,IAAM,IAAW,EAAa,CAAO,GAC/B,IAAU,EAAS,MAAM,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,EAAe,GAAS,CAAQ;EAC5F,OAAO;GACL;GACA;GACA;GACA,UAAU,GAAS,YAAY,GAAS,YAAY;GACpD,WAAW,CAAC,GAAG,IAAI,IAAI,EAAS,SAAS,MAAM,EAAE,SAAS,CAAC,CAAC;GAC5D,SAAS,CAAC,CAAC,MAAQ,EAAE,WAAW,CAAC,EAAE;GACnC,OAAO,EAAE;GACT,QAAQ,EAAE;EACZ;CACF,GAAG;EAAC;EAAS,EAAE;EAAS;EAAU;EAAK,EAAE;EAAS,E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