@joai/react 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -280,6 +280,10 @@ declare function ContentProvider({
280
280
  onUnauthorized
281
281
  }: ContentProviderProp): _$react.JSX.Element;
282
282
  //#endregion
283
+ //#region src/content/context.d.ts
284
+ declare const ContentContext: _$react.Context<ContentContextValue | null>;
285
+ declare function useContent(): ContentContextValue;
286
+ //#endregion
283
287
  //#region src/content/editable-content.d.ts
284
288
  declare function EditableContent({
285
289
  field,
@@ -427,4 +431,4 @@ declare const useContentSession: ({
427
431
  team
428
432
  }: ContentSessionOptions) => ContentSession;
429
433
  //#endregion
430
- export { ContentClient, ContentContextValue, ContentDraft, ContentDraftStore, ContentEditor, ContentEditorConfig, ContentEditorMessages, ContentEditorProp, ContentImagePickerLabels, ContentProvider, ContentProviderProp, ContentResource, ContentResponse, ContentSession, ContentSessionOptions, ContentToolbar, ContentToolbarProp, EditableContent, EditableContentProp, EditableImage, EditableImageProp, EmbedChatInput, EmbedChatItem, EmbedChatList, type ImageCompressionOptions, type ImageCropOptions, type ImageCropRectangle, type ImageCropState, type ImageDimensionRules, type ImageDimensions, ImageProcessingOptions, ManagedContentEditor, ManagedContentEditorProps, SessionTokenStore, StreamDataHandler, clearRoom, containedImageDimensions, createContentDraftStore, createSessionTokenStore, cropOutputDimensions, getContentSessionReturnUrl, getOrCreateGuestId, imageCropRectangle, loadRoom, openEventSourceStream, processImageFile, readImageDimensions, saveRoom, useContentSession, useContentValue, useEmbedChat, useUnsavedNavigation, validateImageDimensions, validateImageFile };
434
+ export { ContentClient, ContentContext, ContentContextValue, ContentDraft, ContentDraftStore, ContentEditor, ContentEditorConfig, ContentEditorMessages, ContentEditorProp, ContentImagePickerLabels, ContentProvider, ContentProviderProp, ContentResource, ContentResponse, ContentSession, ContentSessionOptions, ContentToolbar, ContentToolbarProp, EditableContent, EditableContentProp, EditableImage, EditableImageProp, EmbedChatInput, EmbedChatItem, EmbedChatList, type ImageCompressionOptions, type ImageCropOptions, type ImageCropRectangle, type ImageCropState, type ImageDimensionRules, type ImageDimensions, ImageProcessingOptions, ManagedContentEditor, ManagedContentEditorProps, SessionTokenStore, StreamDataHandler, clearRoom, containedImageDimensions, createContentDraftStore, createSessionTokenStore, cropOutputDimensions, getContentSessionReturnUrl, getOrCreateGuestId, imageCropRectangle, loadRoom, openEventSourceStream, processImageFile, readImageDimensions, saveRoom, useContent, useContentSession, useContentValue, useEmbedChat, useUnsavedNavigation, validateImageDimensions, validateImageFile };
package/dist/index.mjs CHANGED
@@ -1697,6 +1697,47 @@ const useContentSession = ({ env = "mainnet", exchange, sessionStore, sessionSto
1697
1697
  };
1698
1698
  //#endregion
1699
1699
  //#region src/content/managed-content-editor.tsx
1700
+ /**
1701
+ * Anonymously rendered pages only ever use `initialContent`, so the SDK (and its wallet/chain
1702
+ * dependencies) is loaded on demand the first time an authenticated editor actually talks to JoAi.
1703
+ */
1704
+ function createLazyContentClient(env, team, apiToken) {
1705
+ let real = null;
1706
+ let unauthorized = null;
1707
+ const load = async () => {
1708
+ if (!real) {
1709
+ const { createClient } = await import("@joai/sdk");
1710
+ real = createClient({
1711
+ apiToken,
1712
+ env,
1713
+ team
1714
+ });
1715
+ if (unauthorized) real.http.onUnauthorized = unauthorized;
1716
+ }
1717
+ return real;
1718
+ };
1719
+ return {
1720
+ http: {
1721
+ get onUnauthorized() {
1722
+ return unauthorized;
1723
+ },
1724
+ set onUnauthorized(value) {
1725
+ unauthorized = value;
1726
+ if (real) real.http.onUnauthorized = value;
1727
+ }
1728
+ },
1729
+ content: {
1730
+ get: async (contentId) => (await load()).content.get(contentId),
1731
+ getPublic: async (publicSlug) => (await load()).content.getPublic(publicSlug),
1732
+ patch: async (contentId, input) => (await load()).content.patch(contentId, input),
1733
+ publish: async (contentId, expectedVersion) => (await load()).content.publish(contentId, expectedVersion)
1734
+ },
1735
+ media: {
1736
+ list: async (teamSlug, params) => (await load()).media.list(teamSlug, params),
1737
+ upload: async (data) => (await load()).media.upload(data)
1738
+ }
1739
+ };
1740
+ }
1700
1741
  function ManagedContentEditor({ authErrorClassName, authErrorMessage = "The session could not be established.", children, config, confirmLeave, confirmCancel, confirmPublish, draftStore, imagePickerLabels, initialContent, labels, messages, reauthenticateLabel = "Sign in again", reauthenticateUrl, sessionStore, sessionExpiredMessage = "Your editing session expired. Sign in again to continue; your unsaved changes will be restored.", title = "Edit content" }) {
1701
1742
  const { contentId, env = "mainnet", publicSlug, sessionStorageKey, team } = config;
1702
1743
  const { error, token } = useContentSession({
@@ -1705,11 +1746,7 @@ function ManagedContentEditor({ authErrorClassName, authErrorMessage = "The sess
1705
1746
  sessionStorageKey,
1706
1747
  team
1707
1748
  });
1708
- const client = useMemo(() => createClient({
1709
- apiToken: token ?? void 0,
1710
- env,
1711
- team
1712
- }), [
1749
+ const client = useMemo(() => createLazyContentClient(env, team, token ?? void 0), [
1713
1750
  env,
1714
1751
  team,
1715
1752
  token
@@ -1785,4 +1822,4 @@ function ManagedContentEditor({ authErrorClassName, authErrorMessage = "The sess
1785
1822
  ] });
1786
1823
  }
1787
1824
  //#endregion
1788
- export { ContentEditor, ContentProvider, ContentToolbar, EditableContent, EditableImage, EmbedChatInput, EmbedChatList, ManagedContentEditor, clearRoom, containedImageDimensions, createContentDraftStore, createSessionTokenStore, cropOutputDimensions, getContentSessionReturnUrl, getOrCreateGuestId, imageCropRectangle, loadRoom, openEventSourceStream, processImageFile, readImageDimensions, saveRoom, useContentSession, useContentValue, useEmbedChat, useUnsavedNavigation, validateImageDimensions, validateImageFile };
1825
+ export { ContentContext, ContentEditor, ContentProvider, ContentToolbar, EditableContent, EditableImage, EmbedChatInput, EmbedChatList, ManagedContentEditor, clearRoom, containedImageDimensions, createContentDraftStore, createSessionTokenStore, cropOutputDimensions, getContentSessionReturnUrl, getOrCreateGuestId, imageCropRectangle, loadRoom, openEventSourceStream, processImageFile, readImageDimensions, saveRoom, useContent, useContentSession, useContentValue, useEmbedChat, useUnsavedNavigation, validateImageDimensions, validateImageFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joai/react",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Reusable React building blocks for JoAi applications",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,8 +21,8 @@
21
21
  "test": "jest"
22
22
  },
23
23
  "dependencies": {
24
- "@joai/core": "^5.3.0",
25
- "@joai/sdk": "^12.0.0"
24
+ "@joai/core": "^5.4.0",
25
+ "@joai/sdk": "^13.0.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": ">=18.0.0"