@openrails/contentkit-ui 0.85.1 → 0.86.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 (154) hide show
  1. package/README.md +7 -4
  2. package/dist/client/beacons.d.ts +13 -4
  3. package/dist/client/beacons.js +14 -7
  4. package/dist/client/beacons.js.map +1 -1
  5. package/dist/client/client.d.ts +3 -0
  6. package/dist/client/client.js +29 -27
  7. package/dist/client/client.js.map +1 -1
  8. package/dist/client/codes.d.ts +6 -1
  9. package/dist/client/codes.js +4 -1
  10. package/dist/client/codes.js.map +1 -1
  11. package/dist/client/generated/error-codes.js +1 -1
  12. package/dist/client/generated/error-codes.js.map +1 -1
  13. package/dist/client/generated/routes.d.ts +14 -1
  14. package/dist/client/generated/routes.js +17 -1
  15. package/dist/client/generated/routes.js.map +1 -1
  16. package/dist/client/generated/wire.d.ts +29 -0
  17. package/dist/client/generated/wire.js.map +1 -1
  18. package/dist/client/index.d.ts +2 -1
  19. package/dist/client/media/queue.d.ts +4 -2
  20. package/dist/client/media/queue.js +18 -12
  21. package/dist/client/media/queue.js.map +1 -1
  22. package/dist/client/media/rules.d.ts +7 -1
  23. package/dist/client/media/rules.js +27 -21
  24. package/dist/client/media/rules.js.map +1 -1
  25. package/dist/client/stats.d.ts +32 -0
  26. package/dist/client/stats.js +35 -0
  27. package/dist/client/stats.js.map +1 -0
  28. package/dist/client.js +30 -29
  29. package/dist/components/admin/content-manager.js +206 -206
  30. package/dist/components/admin/content-manager.js.map +1 -1
  31. package/dist/components/admin/group-manager.js +71 -70
  32. package/dist/components/admin/group-manager.js.map +1 -1
  33. package/dist/components/admin/media-item-panel.d.ts +24 -7
  34. package/dist/components/admin/media-item-panel.js +209 -197
  35. package/dist/components/admin/media-item-panel.js.map +1 -1
  36. package/dist/components/admin/poll-manager.js +25 -25
  37. package/dist/components/admin/stats-dashboard.d.ts +22 -0
  38. package/dist/components/admin/stats-dashboard.js +257 -0
  39. package/dist/components/admin/stats-dashboard.js.map +1 -0
  40. package/dist/components/content/card.js +42 -42
  41. package/dist/components/content/card.js.map +1 -1
  42. package/dist/components/content/editors.js +455 -427
  43. package/dist/components/content/editors.js.map +1 -1
  44. package/dist/components/content/grid.js +47 -47
  45. package/dist/components/content/index.d.ts +2 -1
  46. package/dist/components/content/listing.js +34 -34
  47. package/dist/components/content/listing.js.map +1 -1
  48. package/dist/components/content/paywall.d.ts +17 -5
  49. package/dist/components/content/paywall.js +115 -100
  50. package/dist/components/content/paywall.js.map +1 -1
  51. package/dist/components/content/reader-stats.d.ts +12 -0
  52. package/dist/components/content/reader-stats.js +47 -0
  53. package/dist/components/content/reader-stats.js.map +1 -0
  54. package/dist/components/groups/banner.js +33 -33
  55. package/dist/components/groups/directory.js +11 -11
  56. package/dist/components/groups/editor.js +293 -293
  57. package/dist/components/groups/editor.js.map +1 -1
  58. package/dist/components/groups/header.js +27 -27
  59. package/dist/components/groups/header.js.map +1 -1
  60. package/dist/components/groups/memberships.js +180 -180
  61. package/dist/components/groups/parts.d.ts +0 -2
  62. package/dist/components/groups/parts.js +9 -27
  63. package/dist/components/groups/parts.js.map +1 -1
  64. package/dist/components/media-folder-editor.js +239 -189
  65. package/dist/components/media-folder-editor.js.map +1 -1
  66. package/dist/components/notifications.js +17 -17
  67. package/dist/components/slot-upload.d.ts +2 -2
  68. package/dist/components/slot-upload.js +84 -79
  69. package/dist/components/slot-upload.js.map +1 -1
  70. package/dist/components/social/bans.js +34 -34
  71. package/dist/components/social/moderation.js +52 -48
  72. package/dist/components/social/moderation.js.map +1 -1
  73. package/dist/components/video-player.d.ts +2 -0
  74. package/dist/components/video-player.js +318 -314
  75. package/dist/components/video-player.js.map +1 -1
  76. package/dist/i18n/context.d.ts +2 -0
  77. package/dist/i18n/context.js +23 -5
  78. package/dist/i18n/context.js.map +1 -1
  79. package/dist/index.d.ts +2 -1
  80. package/dist/index.js +12 -10
  81. package/dist/locales/admin/de.js +27 -0
  82. package/dist/locales/admin/de.js.map +1 -1
  83. package/dist/locales/admin/en.d.ts +27 -0
  84. package/dist/locales/admin/en.js +27 -0
  85. package/dist/locales/admin/en.js.map +1 -1
  86. package/dist/locales/admin/es.js +27 -0
  87. package/dist/locales/admin/es.js.map +1 -1
  88. package/dist/locales/admin/ja.js +27 -0
  89. package/dist/locales/admin/ja.js.map +1 -1
  90. package/dist/locales/admin/ko.js +27 -0
  91. package/dist/locales/admin/ko.js.map +1 -1
  92. package/dist/locales/admin/zh.js +27 -0
  93. package/dist/locales/admin/zh.js.map +1 -1
  94. package/dist/locales/content/de.js +6 -0
  95. package/dist/locales/content/de.js.map +1 -1
  96. package/dist/locales/content/en.d.ts +6 -0
  97. package/dist/locales/content/en.js +6 -0
  98. package/dist/locales/content/en.js.map +1 -1
  99. package/dist/locales/content/es.js +6 -0
  100. package/dist/locales/content/es.js.map +1 -1
  101. package/dist/locales/content/ja.js +6 -0
  102. package/dist/locales/content/ja.js.map +1 -1
  103. package/dist/locales/content/ko.js +6 -0
  104. package/dist/locales/content/ko.js.map +1 -1
  105. package/dist/locales/content/zh.js +6 -0
  106. package/dist/locales/content/zh.js.map +1 -1
  107. package/dist/locales/de.js +1 -0
  108. package/dist/locales/de.js.map +1 -1
  109. package/dist/locales/en.d.ts +34 -0
  110. package/dist/locales/en.js +1 -0
  111. package/dist/locales/en.js.map +1 -1
  112. package/dist/locales/es.js +1 -0
  113. package/dist/locales/es.js.map +1 -1
  114. package/dist/locales/ja.js +1 -0
  115. package/dist/locales/ja.js.map +1 -1
  116. package/dist/locales/ko.js +1 -0
  117. package/dist/locales/ko.js.map +1 -1
  118. package/dist/locales/zh.js +1 -0
  119. package/dist/locales/zh.js.map +1 -1
  120. package/dist/react/admin.js +22 -23
  121. package/dist/react/admin.js.map +1 -1
  122. package/dist/react/canonical.d.ts +4 -3
  123. package/dist/react/canonical.js +34 -33
  124. package/dist/react/canonical.js.map +1 -1
  125. package/dist/react/contents.js +144 -144
  126. package/dist/react/contents.js.map +1 -1
  127. package/dist/react/detail.d.ts +12 -6
  128. package/dist/react/detail.js +31 -24
  129. package/dist/react/detail.js.map +1 -1
  130. package/dist/react/folder.d.ts +7 -2
  131. package/dist/react/folder.js +165 -147
  132. package/dist/react/folder.js.map +1 -1
  133. package/dist/react/groups.d.ts +0 -1
  134. package/dist/react/groups.js +13 -12
  135. package/dist/react/groups.js.map +1 -1
  136. package/dist/react/index.d.ts +4 -2
  137. package/dist/react/location.d.ts +11 -0
  138. package/dist/react/location.js +18 -0
  139. package/dist/react/location.js.map +1 -0
  140. package/dist/react/public.d.ts +8 -0
  141. package/dist/react/public.js +32 -27
  142. package/dist/react/public.js.map +1 -1
  143. package/dist/react/stats.d.ts +24 -0
  144. package/dist/react/stats.js +28 -0
  145. package/dist/react/stats.js.map +1 -0
  146. package/dist/react/use-resource.js +8 -7
  147. package/dist/react/use-resource.js.map +1 -1
  148. package/dist/react/versions.js +20 -20
  149. package/dist/react.js +26 -24
  150. package/dist/styles.css +1 -1
  151. package/dist/urls/index.d.ts +35 -10
  152. package/dist/urls.js +100 -70
  153. package/dist/urls.js.map +1 -1
  154. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-resource.js","names":[],"sources":["../../src/react/use-resource.ts"],"sourcesContent":["import { useCallback, useContext, useEffect, useRef, useSyncExternalStore } from \"react\";\nimport type { ContentKitClient } from \"../client/client.js\";\nimport type { ContentKitError } from \"../client/errors.js\";\nimport { ContentKitContext, useContentKitClient, useReadScope } from \"./context.js\";\nimport { resourcesFor, type Fetcher, type Page, type Resource, type ResourceStore, type Tag } from \"./resources.js\";\n\n/** The client, its shared store, and the provider's viewer, language and sign-in. */\nexport function useContentScope(own?: ContentKitClient | null) {\n const ctx = useContext(ContentKitContext);\n const client = useContentKitClient(own);\n return { client, store: resourcesFor(client), scope: useReadScope(), viewer: ctx?.viewer, language: ctx?.language, onSignIn: ctx?.onSignIn };\n}\n\nconst IDLE: Resource<never> = { data: undefined, loading: false, loaded: false };\nconst none = () => () => {};\n\n/** A shared read: fetched once per key while shown; initial is shown (and seeds the store) until it loads. */\nexport function useResource<T>(\n store: ResourceStore,\n key: string | null,\n tag: Tag,\n fetcher: Fetcher<T>,\n o: { initial?: T; more?: (cursor: string | number, signal: AbortSignal) => Promise<Page<unknown>> } = {},\n): Resource<T> & { reload: () => void } {\n const scope = useReadScope();\n const fetch = useRef(fetcher);\n const more = useRef(o.more);\n const initial = useRef(o.initial);\n useEffect(() => {\n fetch.current = fetcher;\n more.current = o.more;\n initial.current = o.initial;\n });\n const subscribe = useCallback(\n (l: () => void) => (key ? store.subscribe(key, { ...tag, readScope: scope }, l) : none()),\n // The tag is part of the key.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [store, key, scope],\n );\n const snapshot = useCallback(() => (key ? store.snapshot<T>(key) : IDLE), [store, key]);\n const entry = useSyncExternalStore(subscribe, snapshot, snapshot);\n useEffect(() => {\n if (!key) return;\n store.bind(key, (s) => fetch.current(s), more.current && ((c, s) => more.current!(c, s)));\n if (initial.current !== undefined && !store.snapshot(key).loaded && !store.snapshot(key).loading) store.set(key, initial.current);\n else store.load(key);\n }, [store, key]);\n const reload = useCallback(() => key && store.load(key, true), [store, key]);\n if (!entry.loaded && o.initial !== undefined) return { ...entry, data: o.initial, reload };\n return { ...entry, reload };\n}\n\n/** A shared list, a page at a time. */\nexport interface UseList<T> {\n items: T[];\n /** The first page is loading (also on reload). */\n loading: boolean;\n loadingMore: boolean;\n error?: ContentKitError;\n hasMore: boolean;\n loadMore: () => Promise<void>;\n reload: () => void;\n}\n\nexport type PageFetcher<T> = (cursor: string | number | undefined, signal: AbortSignal) => Promise<Page<T>>;\n\nexport function useList<T extends { id: string }>(store: ResourceStore, key: string | null, tag: Tag, page: PageFetcher<T>): UseList<T> {\n const r = useResource<Page<T>>(store, key, tag, (s) => page(undefined, s), { more: (c, s) => page(c, s) });\n const loadMore = useCallback(() => (key ? store.loadMore(key) : Promise.resolve()), [store, key]);\n return {\n items: r.data?.items ?? [],\n loading: r.loading || (!!key && !r.loaded),\n loadingMore: !!r.loadingMore,\n error: r.error,\n hasMore: r.data ? r.data.next !== null : false,\n loadMore,\n reload: r.reload,\n };\n}\n\n/**\n * A limit/offset list as pages. A full page means more may follow; with\n * underfill (the latest feed drops items the caller may not see) only an\n * empty page ends it.\n */\nexport function offsetPages<T>(limit: number, list: (q: { limit: number; offset: number }, signal: AbortSignal) => Promise<T[]>, underfill = false): PageFetcher<T> {\n return async (cursor, signal) => {\n const offset = typeof cursor === \"number\" ? cursor : 0;\n const items = await list({ limit, offset }, signal);\n const end = underfill ? items.length === 0 : items.length < limit;\n return { items, next: end ? null : offset + limit };\n };\n}\n\n/** A stable store key. */\nexport const keyOf = (...parts: unknown[]) => JSON.stringify(parts);\n\n/** One numbered page of a list. */\nexport interface UsePaged<T> {\n items: T[];\n loading: boolean;\n error?: ContentKitError;\n /** Another page follows. */\n hasNext: boolean;\n reload: () => void;\n}\n\n/** Page `page` (from 1) of a limit/offset list: one read of limit + 1 tells whether another follows. */\nexport function usePaged<T extends { id: string }>(\n store: ResourceStore,\n key: string | null,\n tag: Tag,\n page: number,\n limit: number,\n list: (q: { limit: number; offset: number }, signal: AbortSignal) => Promise<T[]>,\n): UsePaged<T> {\n const offset = (Math.max(1, page) - 1) * limit;\n const r = useResource<Page<T>>(store, key === null ? null : `${key}#${offset}`, tag, async (signal) => {\n const items = await list({ limit: limit + 1, offset }, signal);\n return { items: items.slice(0, limit), next: items.length > limit ? offset + limit : null };\n });\n return { items: r.data?.items ?? [], loading: r.loading || (!!key && !r.loaded), error: r.error, hasNext: r.data ? r.data.next !== null : false, reload: r.reload };\n}\n"],"mappings":";;;;AAOA,SAAgB,EAAgB,GAA+B;CAC7D,IAAM,IAAM,EAAW,CAAiB,GAClC,IAAS,EAAoB,CAAG;CACtC,OAAO;EAAE;EAAQ,OAAO,EAAa,CAAM;EAAG,OAAO,EAAa;EAAG,QAAQ,GAAK;EAAQ,UAAU,GAAK;EAAU,UAAU,GAAK;CAA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AC,CAAC,KAAO,CAAC,EAAE;EAAS,OAAO,EAAE;EAAO,SAAS,EAAE,OAAO,EAAE,KAAK,SAAS,OAAO;EAAO,QAAQ,EAAE;CAAO;AACpK"}
1
+ {"version":3,"file":"use-resource.js","names":[],"sources":["../../src/react/use-resource.ts"],"sourcesContent":["import { useCallback, useContext, useEffect, useRef, useSyncExternalStore } from \"react\";\nimport type { ContentKitClient } from \"../client/client.js\";\nimport type { ContentKitError } from \"../client/errors.js\";\nimport { ContentKitContext, useContentKitClient, useReadScope } from \"./context.js\";\nimport { resourcesFor, type Fetcher, type Page, type Resource, type ResourceStore, type Tag } from \"./resources.js\";\n\n/** The client, its shared store, and the provider's viewer, language and sign-in. */\nexport function useContentScope(own?: ContentKitClient | null) {\n const ctx = useContext(ContentKitContext);\n const client = useContentKitClient(own);\n return { client, store: resourcesFor(client), scope: useReadScope(), viewer: ctx?.viewer, language: ctx?.language, onSignIn: ctx?.onSignIn };\n}\n\nconst IDLE: Resource<never> = { data: undefined, loading: false, loaded: false };\nconst none = () => () => {};\n\n/** A shared read: fetched once per key while shown; initial is shown (and seeds the store) until it loads. */\nexport function useResource<T>(\n store: ResourceStore,\n key: string | null,\n tag: Tag,\n fetcher: Fetcher<T>,\n o: { initial?: T; more?: (cursor: string | number, signal: AbortSignal) => Promise<Page<unknown>> } = {},\n): Resource<T> & { reload: () => void } {\n const scope = useReadScope();\n const fetch = useRef(fetcher);\n const more = useRef(o.more);\n const initial = useRef(o.initial);\n useEffect(() => {\n fetch.current = fetcher;\n more.current = o.more;\n initial.current = o.initial;\n });\n const subscribe = useCallback(\n (l: () => void) => (key ? store.subscribe(key, { ...tag, readScope: scope }, l) : none()),\n // The tag is part of the key.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [store, key, scope],\n );\n const snapshot = useCallback(() => (key ? store.snapshot<T>(key) : IDLE), [store, key]);\n const entry = useSyncExternalStore(subscribe, snapshot, snapshot);\n useEffect(() => {\n if (!key) return;\n store.bind(key, (s) => fetch.current(s), more.current && ((c, s) => more.current!(c, s)));\n if (initial.current !== undefined && !store.snapshot(key).loaded && !store.snapshot(key).loading) store.set(key, initial.current);\n else store.load(key);\n }, [store, key]);\n const reload = useCallback(() => key && store.load(key, true), [store, key]);\n if (!entry.loaded && o.initial !== undefined) return { ...entry, data: o.initial, reload };\n return { ...entry, reload };\n}\n\n/** A shared list, a page at a time. */\nexport interface UseList<T> {\n items: T[];\n /** The first page is loading (also on reload). */\n loading: boolean;\n loadingMore: boolean;\n error?: ContentKitError;\n hasMore: boolean;\n loadMore: () => Promise<void>;\n reload: () => void;\n}\n\nexport type PageFetcher<T> = (cursor: string | number | undefined, signal: AbortSignal) => Promise<Page<T>>;\n\n// The items of a list not loaded: one array, so effects keyed on items don't run every render.\nconst NO_ITEMS: never[] = [];\n\nexport function useList<T extends { id: string }>(store: ResourceStore, key: string | null, tag: Tag, page: PageFetcher<T>): UseList<T> {\n const r = useResource<Page<T>>(store, key, tag, (s) => page(undefined, s), { more: (c, s) => page(c, s) });\n const loadMore = useCallback(() => (key ? store.loadMore(key) : Promise.resolve()), [store, key]);\n return {\n items: r.data?.items ?? NO_ITEMS,\n loading: r.loading || (!!key && !r.loaded),\n loadingMore: !!r.loadingMore,\n error: r.error,\n hasMore: r.data ? r.data.next !== null : false,\n loadMore,\n reload: r.reload,\n };\n}\n\n/**\n * A limit/offset list as pages. A full page means more may follow; with\n * underfill (the latest feed drops items the caller may not see) only an\n * empty page ends it.\n */\nexport function offsetPages<T>(limit: number, list: (q: { limit: number; offset: number }, signal: AbortSignal) => Promise<T[]>, underfill = false): PageFetcher<T> {\n return async (cursor, signal) => {\n const offset = typeof cursor === \"number\" ? cursor : 0;\n const items = await list({ limit, offset }, signal);\n const end = underfill ? items.length === 0 : items.length < limit;\n return { items, next: end ? null : offset + limit };\n };\n}\n\n/** A stable store key. */\nexport const keyOf = (...parts: unknown[]) => JSON.stringify(parts);\n\n/** One numbered page of a list. */\nexport interface UsePaged<T> {\n items: T[];\n loading: boolean;\n error?: ContentKitError;\n /** Another page follows. */\n hasNext: boolean;\n reload: () => void;\n}\n\n/** Page `page` (from 1) of a limit/offset list: one read of limit + 1 tells whether another follows. */\nexport function usePaged<T extends { id: string }>(\n store: ResourceStore,\n key: string | null,\n tag: Tag,\n page: number,\n limit: number,\n list: (q: { limit: number; offset: number }, signal: AbortSignal) => Promise<T[]>,\n): UsePaged<T> {\n const offset = (Math.max(1, page) - 1) * limit;\n const r = useResource<Page<T>>(store, key === null ? null : `${key}#${offset}`, tag, async (signal) => {\n const items = await list({ limit: limit + 1, offset }, signal);\n return { items: items.slice(0, limit), next: items.length > limit ? offset + limit : null };\n });\n return { items: r.data?.items ?? NO_ITEMS, loading: r.loading || (!!key && !r.loaded), error: r.error, hasNext: r.data ? r.data.next !== null : false, reload: r.reload };\n}\n"],"mappings":";;;;AAOA,SAAgB,EAAgB,GAA+B;CAC7D,IAAM,IAAM,EAAW,CAAiB,GAClC,IAAS,EAAoB,CAAG;CACtC,OAAO;EAAE;EAAQ,OAAO,EAAa,CAAM;EAAG,OAAO,EAAa;EAAG,QAAQ,GAAK;EAAQ,UAAU,GAAK;EAAU,UAAU,GAAK;CAAS;AAC7I;AAEA,IAAM,IAAwB;CAAE,MAAM,KAAA;CAAW,SAAS;CAAO,QAAQ;AAAM,GACzE,gBAAmB,CAAC;AAG1B,SAAgB,EACd,GACA,GACA,GACA,GACA,IAAsG,CAAC,GACjE;CACtC,IAAM,IAAQ,EAAa,GACrB,IAAQ,EAAO,CAAO,GACtB,IAAO,EAAO,EAAE,IAAI,GACpB,IAAU,EAAO,EAAE,OAAO;CAChC,QAAgB;EAGd,AAFA,EAAM,UAAU,GAChB,EAAK,UAAU,EAAE,MACjB,EAAQ,UAAU,EAAE;CACtB,CAAC;CACD,IAAM,IAAY,GACf,MAAmB,IAAM,EAAM,UAAU,GAAK;EAAE,GAAG;EAAK,WAAW;CAAM,GAAG,CAAC,IAAI,EAAK,GAGvF;EAAC;EAAO;EAAK;CAAK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GAAmF,IAAY,IAAuB;CAClK,OAAO,OAAO,GAAQ,MAAW;EAC/B,IAAM,IAAS,OAAO,KAAW,WAAW,IAAS,GAC/C,IAAQ,MAAM,EAAK;GAAE;GAAO;EAAO,GAAG,CAAM;EAElD,OAAO;GAAE;GAAO,OADJ,IAAY,EAAM,WAAW,IAAI,EAAM,SAAS,KAChC,OAAO,IAAS;EAAM;CACpD;AACF;AAGA,IAAa,KAAS,GAAG,MAAqB,KAAK,UAAU,CAAK;AAalE,SAAgB,EACd,GACA,GACA,GACA,GACA,GACA,GACa;CACb,IAAM,KAAU,KAAK,IAAI,GAAG,CAAI,IAAI,KAAK,GACnC,IAAI,EAAqB,GAAO,MAAQ,OAAO,OAAO,GAAG,EAAI,GAAG,KAAU,GAAK,OAAO,MAAW;EACrG,IAAM,IAAQ,MAAM,EAAK;GAAE,OAAO,IAAQ;GAAG;EAAO,GAAG,CAAM;EAC7D,OAAO;GAAE,OAAO,EAAM,MAAM,GAAG,CAAK;GAAG,MAAM,EAAM,SAAS,IAAQ,IAAS,IAAQ;EAAK;CAC5F,CAAC;CACD,OAAO;EAAE,OAAO,EAAE,MAAM,SAAS;EAAU,SAAS,EAAE,WAAY,CAAC,CAAC,KAAO,CAAC,EAAE;EAAS,OAAO,EAAE;EAAO,SAAS,EAAE,OAAO,EAAE,KAAK,SAAS,OAAO;EAAO,QAAQ,EAAE;CAAO;AAC1K"}
@@ -1,6 +1,6 @@
1
1
  import { toContentKitError as e } from "../client/errors.js";
2
- import { useMediaRead as t } from "./read.js";
3
- import { keyOf as n, useContentScope as r, useResource as i } from "./use-resource.js";
2
+ import { keyOf as t, useContentScope as n, useResource as r } from "./use-resource.js";
3
+ import { useMediaRead as i } from "./read.js";
4
4
  import { isPending as a } from "../client/versions.js";
5
5
  import { useCallback as o, useEffect as s, useMemo as c, useState as l } from "react";
6
6
  //#region src/react/versions.ts
@@ -9,11 +9,11 @@ function d(e, t = Date.now()) {
9
9
  let n = (e?.segments ?? []).flatMap((e) => !e.released && e.release_at ? [Date.parse(e.release_at)] : []).filter((e) => e > t);
10
10
  return n.length ? Math.min(...n) : null;
11
11
  }
12
- function f(e, t, o = {}) {
13
- let { client: c, store: l, scope: f } = r(o.client), p = e && t ? n("reader-plan", f, e, t) : null, m = i(l, p, {
12
+ function f(e, i, o = {}) {
13
+ let { client: c, store: l, scope: f } = n(o.client), p = e && i ? t("reader-plan", f, e, i) : null, m = r(l, p, {
14
14
  type: "reader-plan",
15
- id: t ?? void 0
16
- }, (n) => c.versions.reader(e, t, n)), h = a(m.data), g = m.data && !h ? m.data : null, { data: _, reload: v } = m;
15
+ id: i ?? void 0
16
+ }, (t) => c.versions.reader(e, i, t)), h = a(m.data), g = m.data && !h ? m.data : null, { data: _, reload: v } = m;
17
17
  return s(() => {
18
18
  let e = a(_) ? Date.now() + (o.poll ?? 5e3) : d(_ || null);
19
19
  if (e === null) return;
@@ -31,44 +31,44 @@ function f(e, t, o = {}) {
31
31
  reload: v
32
32
  };
33
33
  }
34
- function p(e, n, r = {}) {
35
- let i = e?.item ?? null, a = t(i ?? {
34
+ function p(e, t, n = {}) {
35
+ let r = e?.item ?? null, a = i(r ?? {
36
36
  kind: "",
37
37
  id: ""
38
38
  }, {
39
- window: r.window,
40
- read: i ? void 0 : null,
41
- client: r.client
39
+ window: n.window,
40
+ read: r ? void 0 : null,
41
+ client: n.client
42
42
  });
43
43
  return {
44
44
  pages: c(() => {
45
- let t = new Map((a.read?.files ?? []).flatMap((e) => e.url ? [[e.path, e.url]] : []));
45
+ let n = new Map((a.read?.files ?? []).flatMap((e) => e.url ? [[e.path, e.url]] : []));
46
46
  return (e?.pages ?? []).map((e) => {
47
- let r = e.files[n];
47
+ let r = e.files[t];
48
48
  return {
49
49
  name: e.name,
50
50
  w: e.w,
51
51
  h: e.h,
52
- url: r ? t.get(r) : void 0
52
+ url: r ? n.get(r) : void 0
53
53
  };
54
54
  });
55
55
  }, [
56
56
  e,
57
- n,
57
+ t,
58
58
  a.read
59
59
  ]),
60
- loading: !!i && a.loading,
60
+ loading: !!r && a.loading,
61
61
  error: a.error
62
62
  };
63
63
  }
64
- function m(t, n, i = {}) {
65
- let { client: s } = r(i.client), [c, u] = l(!1), [d, f] = l();
64
+ function m(t, r, i = {}) {
65
+ let { client: s } = n(i.client), [c, u] = l(!1), [d, f] = l();
66
66
  return {
67
67
  download: o(async () => {
68
68
  f(void 0), u(!0);
69
69
  try {
70
70
  for (;;) {
71
- let e = await s.versions.download(t, n);
71
+ let e = await s.versions.download(t, r);
72
72
  if (!a(e)) return e;
73
73
  await new Promise((e) => setTimeout(e, i.poll ?? 3e3));
74
74
  }
@@ -81,7 +81,7 @@ function m(t, n, i = {}) {
81
81
  }, [
82
82
  s,
83
83
  t,
84
- n,
84
+ r,
85
85
  i.poll
86
86
  ]),
87
87
  preparing: c,
package/dist/react.js CHANGED
@@ -1,27 +1,29 @@
1
1
  import { HOVER_DELAY as e, InlinePreviewContext as t, useInlinePreview as n, useReducedMotion as r } from "./react/inline-preview.js";
2
2
  import { GuardContext as i, useContentKit as a, useContentKitClient as o, useContentURLs as s, useErrorReporter as c, useGuarded as l, useOptionalContentKitClient as u } from "./react/context.js";
3
3
  import { useCrop as d, useEncodeProgress as f, useUpload as p, useUploadQueue as m } from "./react/upload.js";
4
- import { useMediaRead as h } from "./react/read.js";
5
- import { usePresets as g, usePublicImage as _ } from "./react/public.js";
6
- import { editOutput as v, useSlotCrop as y, useSlotImage as b } from "./react/slot.js";
7
- import { round3 as x, useFrameStrip as S, useVideoFrame as C, useVideoImages as w, useVideoPoster as T } from "./react/video.js";
8
- import { GALLERY_VIEW_KEY as E, PLAYER_QUALITY_KEY as D, useCarousel as O, useGalleryView as k, useHlsPlayer as A, useRefreshBeforeExpiry as j } from "./react/gallery.js";
9
- import { useEditorCrop as M } from "./react/crop.js";
10
- import { nameIn as N, thumbnailOf as P, useMediaFolder as F } from "./react/folder.js";
11
- import { useNearViewport as I } from "./react/viewport.js";
12
- import { ResourceStore as L, resourcesFor as R } from "./react/resources.js";
13
- import { useContentScope as z, usePaged as B } from "./react/use-resource.js";
14
- import { useAdminComments as V, useBannedWords as H, useCanComment as U, useCommentBans as W, useCommentReplies as G, useComments as K, useGlobalCommentBan as q, useIPBans as J, useLatestComments as Y, useModerationQueue as X, withReaction as Z } from "./react/comments.js";
15
- import { useContentConfig as Q } from "./react/config.js";
16
- import { useFavorite as $, useReaction as ee } from "./react/engagement.js";
17
- import { usePoll as te, usePollEditor as ne, usePolls as re, withVote as ie } from "./react/polls.js";
18
- import { useAdminLocation as ae, useFlowClient as oe, useStaffAccess as se } from "./react/admin.js";
19
- import { memberId as ce, useContentGroups as le, useGroup as ue, useGroupMembers as de, useGroups as fe, useKinds as pe, useMyGroups as me } from "./react/groups.js";
20
- import { beaconsFor as he, useBeacons as ge, useContentFilters as _e, useContents as ve, useExposure as ye, useHistory as be, useMyFavorites as xe, useMyReactions as Se, useRecentSearches as Ce, useRecommendations as we, useReleaseDates as Te, useSearch as Ee, useSimilar as De, useTypeahead as Oe, useViewSignal as ke } from "./react/discovery.js";
21
- import { nextRelease as Ae, useReaderPlan as je, useSegmentPages as Me, useVersionDownload as Ne } from "./react/versions.js";
22
- import { useContent as Pe, useManagedContents as Fe } from "./react/contents.js";
23
- import { useNotificationUnread as Ie, useNotifications as Le } from "./react/notifications.js";
24
- import { ContentKitProvider as Re } from "./react/provider.js";
25
- import { useCanonicalContent as ze } from "./react/canonical.js";
26
- import { defaultVersion as Be, liveVersions as Ve, useContentDetail as He } from "./react/detail.js";
27
- export { Re as ContentKitProvider, E as GALLERY_VIEW_KEY, i as GuardContext, e as HOVER_DELAY, t as InlinePreviewContext, D as PLAYER_QUALITY_KEY, L as ResourceStore, he as beaconsFor, Be as defaultVersion, v as editOutput, Ve as liveVersions, ce as memberId, N as nameIn, Ae as nextRelease, R as resourcesFor, x as round3, P as thumbnailOf, V as useAdminComments, ae as useAdminLocation, H as useBannedWords, ge as useBeacons, U as useCanComment, ze as useCanonicalContent, O as useCarousel, W as useCommentBans, G as useCommentReplies, K as useComments, Pe as useContent, Q as useContentConfig, He as useContentDetail, _e as useContentFilters, le as useContentGroups, a as useContentKit, o as useContentKitClient, z as useContentScope, s as useContentURLs, ve as useContents, d as useCrop, M as useEditorCrop, f as useEncodeProgress, c as useErrorReporter, ye as useExposure, $ as useFavorite, oe as useFlowClient, S as useFrameStrip, k as useGalleryView, q as useGlobalCommentBan, ue as useGroup, de as useGroupMembers, fe as useGroups, l as useGuarded, be as useHistory, A as useHlsPlayer, J as useIPBans, n as useInlinePreview, pe as useKinds, Y as useLatestComments, Fe as useManagedContents, F as useMediaFolder, h as useMediaRead, X as useModerationQueue, xe as useMyFavorites, me as useMyGroups, Se as useMyReactions, I as useNearViewport, Ie as useNotificationUnread, Le as useNotifications, u as useOptionalContentKitClient, B as usePaged, te as usePoll, ne as usePollEditor, re as usePolls, g as usePresets, _ as usePublicImage, ee as useReaction, je as useReaderPlan, Ce as useRecentSearches, we as useRecommendations, r as useReducedMotion, j as useRefreshBeforeExpiry, Te as useReleaseDates, Ee as useSearch, Me as useSegmentPages, De as useSimilar, y as useSlotCrop, b as useSlotImage, se as useStaffAccess, Oe as useTypeahead, p as useUpload, m as useUploadQueue, Ne as useVersionDownload, C as useVideoFrame, w as useVideoImages, T as useVideoPoster, ke as useViewSignal, Z as withReaction, ie as withVote };
4
+ import { ResourceStore as h, resourcesFor as g } from "./react/resources.js";
5
+ import { useContentScope as _, usePaged as v } from "./react/use-resource.js";
6
+ import { memberId as y, useContentGroups as b, useGroup as x, useGroupMembers as S, useGroups as C, useKinds as w, useMyGroups as T } from "./react/groups.js";
7
+ import { useMediaRead as E } from "./react/read.js";
8
+ import { useAvatar as D, usePresets as O, usePublicImage as k } from "./react/public.js";
9
+ import { editOutput as A, useSlotCrop as j, useSlotImage as M } from "./react/slot.js";
10
+ import { round3 as N, useFrameStrip as P, useVideoFrame as F, useVideoImages as I, useVideoPoster as L } from "./react/video.js";
11
+ import { GALLERY_VIEW_KEY as R, PLAYER_QUALITY_KEY as z, useCarousel as B, useGalleryView as V, useHlsPlayer as H, useRefreshBeforeExpiry as U } from "./react/gallery.js";
12
+ import { useEditorCrop as W } from "./react/crop.js";
13
+ import { nameIn as G, thumbnailOf as K, useMediaFolder as q } from "./react/folder.js";
14
+ import { useNearViewport as J } from "./react/viewport.js";
15
+ import { useAdminComments as Y, useBannedWords as X, useCanComment as Z, useCommentBans as Q, useCommentReplies as $, useComments as ee, useGlobalCommentBan as te, useIPBans as ne, useLatestComments as re, useModerationQueue as ie, withReaction as ae } from "./react/comments.js";
16
+ import { useContentConfig as oe } from "./react/config.js";
17
+ import { useFavorite as se, useReaction as ce } from "./react/engagement.js";
18
+ import { usePoll as le, usePollEditor as ue, usePolls as de, withVote as fe } from "./react/polls.js";
19
+ import { useVersionParam as pe } from "./react/location.js";
20
+ import { useAdminLocation as me, useFlowClient as he, useStaffAccess as ge } from "./react/admin.js";
21
+ import { beaconsFor as _e, useBeacons as ve, useContentFilters as ye, useContents as be, useExposure as xe, useHistory as Se, useMyFavorites as Ce, useMyReactions as we, useRecentSearches as Te, useRecommendations as Ee, useReleaseDates as De, useSearch as Oe, useSimilar as ke, useTypeahead as Ae, useViewSignal as je } from "./react/discovery.js";
22
+ import { defaultVersion as Me, findVersion as Ne, liveVersions as Pe, useContentDetail as Fe } from "./react/detail.js";
23
+ import { nextRelease as Ie, useReaderPlan as Le, useSegmentPages as Re, useVersionDownload as ze } from "./react/versions.js";
24
+ import { useActivity as Be, useMyStats as Ve, useTopContents as He } from "./react/stats.js";
25
+ import { useContent as Ue, useManagedContents as We } from "./react/contents.js";
26
+ import { useNotificationUnread as Ge, useNotifications as Ke } from "./react/notifications.js";
27
+ import { ContentKitProvider as qe } from "./react/provider.js";
28
+ import { useCanonicalContent as Je } from "./react/canonical.js";
29
+ export { qe as ContentKitProvider, R as GALLERY_VIEW_KEY, i as GuardContext, e as HOVER_DELAY, t as InlinePreviewContext, z as PLAYER_QUALITY_KEY, h as ResourceStore, _e as beaconsFor, Me as defaultVersion, A as editOutput, Ne as findVersion, Pe as liveVersions, y as memberId, G as nameIn, Ie as nextRelease, g as resourcesFor, N as round3, K as thumbnailOf, Be as useActivity, Y as useAdminComments, me as useAdminLocation, D as useAvatar, X as useBannedWords, ve as useBeacons, Z as useCanComment, Je as useCanonicalContent, B as useCarousel, Q as useCommentBans, $ as useCommentReplies, ee as useComments, Ue as useContent, oe as useContentConfig, Fe as useContentDetail, ye as useContentFilters, b as useContentGroups, a as useContentKit, o as useContentKitClient, _ as useContentScope, s as useContentURLs, be as useContents, d as useCrop, W as useEditorCrop, f as useEncodeProgress, c as useErrorReporter, xe as useExposure, se as useFavorite, he as useFlowClient, P as useFrameStrip, V as useGalleryView, te as useGlobalCommentBan, x as useGroup, S as useGroupMembers, C as useGroups, l as useGuarded, Se as useHistory, H as useHlsPlayer, ne as useIPBans, n as useInlinePreview, w as useKinds, re as useLatestComments, We as useManagedContents, q as useMediaFolder, E as useMediaRead, ie as useModerationQueue, Ce as useMyFavorites, T as useMyGroups, we as useMyReactions, Ve as useMyStats, J as useNearViewport, Ge as useNotificationUnread, Ke as useNotifications, u as useOptionalContentKitClient, v as usePaged, le as usePoll, ue as usePollEditor, de as usePolls, O as usePresets, k as usePublicImage, ce as useReaction, Le as useReaderPlan, Te as useRecentSearches, Ee as useRecommendations, r as useReducedMotion, U as useRefreshBeforeExpiry, De as useReleaseDates, Oe as useSearch, Re as useSegmentPages, ke as useSimilar, j as useSlotCrop, M as useSlotImage, ge as useStaffAccess, He as useTopContents, Ae as useTypeahead, p as useUpload, m as useUploadQueue, ze as useVersionDownload, pe as useVersionParam, F as useVideoFrame, I as useVideoImages, L as useVideoPoster, je as useViewSignal, ae as withReaction, fe as withVote };