@promptbook/components 0.104.0-7 โ†’ 0.104.0-8

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.
@@ -1,4 +1,4 @@
1
- import type { string_agent_name, string_agent_permanent_id, string_url_image } from '../../types/typeAliases';
1
+ import type { string_agent_name, string_agent_permanent_id, string_url, string_url_image } from '../../types/typeAliases';
2
2
  /**
3
3
  * Generates an image for the agent to use as profile image
4
4
  *
@@ -7,7 +7,7 @@ import type { string_agent_name, string_agent_permanent_id, string_url_image } f
7
7
  *
8
8
  * @public exported from `@promptbook/core`
9
9
  */
10
- export declare function generatePlaceholderAgentProfileImageUrl(agentIdOrName: string_agent_permanent_id | string_agent_name, agentsServerUrl?: URL): string_url_image;
10
+ export declare function generatePlaceholderAgentProfileImageUrl(agentIdOrName: string_agent_permanent_id | string_agent_name, agentsServerUrl?: URL | string_url): string_url_image;
11
11
  /**
12
12
  * TODO: [๐Ÿคน] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
13
13
  */
@@ -1,10 +1,11 @@
1
+ import { string_color, string_data_url, string_url_image } from '../../../types/typeAliases';
1
2
  import { Color } from '../Color';
2
3
  /**
3
4
  * Makes data url from color
4
5
  *
5
6
  * @public exported from `@promptbook/color`
6
7
  */
7
- export declare function colorToDataUrl(color: Color): string;
8
+ export declare function colorToDataUrl(color: Color | string_color): string_data_url & string_url_image;
8
9
  /**
9
10
  * TODO: Make as functions NOT const
10
11
  */
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.104.0-6`).
18
+ * It follows semantic versioning (e.g., `0.104.0-7`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/components",
3
- "version": "0.104.0-7",
3
+ "version": "0.104.0-8",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -30,7 +30,7 @@
30
30
  * @generated
31
31
  * @see https://github.com/webgptorg/promptbook
32
32
  */
33
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-7';
33
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-8';
34
34
  /**
35
35
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
36
36
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -8781,6 +8781,52 @@
8781
8781
  */
8782
8782
  const textColor = furthest(Color.get('white'), Color.from('black'));
8783
8783
 
8784
+ /**
8785
+ * Makes data url from color
8786
+ *
8787
+ * @public exported from `@promptbook/color`
8788
+ */
8789
+ function colorToDataUrl(color) {
8790
+ if (typeof color === 'string') {
8791
+ color = Color.fromHex(color);
8792
+ }
8793
+ return rgbDataURL(color.red, color.green, color.blue);
8794
+ }
8795
+ /**
8796
+ * Pixel GIF code adapted from https://stackoverflow.com/a/33919020/266535
8797
+ *
8798
+ * @private util of `colorToDataUrl`
8799
+ */
8800
+ const keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
8801
+ /**
8802
+ * Generates a base64-encoded triplet string
8803
+ *
8804
+ * @param e1 - The first element in the triplet.
8805
+ * @param e2 - The second element in the triplet.
8806
+ * @param e3 - The third element in the triplet.
8807
+ * @returns The base64-encoded triplet string.
8808
+ *
8809
+ * @private util of `colorToDataUrl`
8810
+ */
8811
+ const triplet = (e1, e2, e3) => keyStr.charAt(e1 >> 2) +
8812
+ keyStr.charAt(((e1 & 3) << 4) | (e2 >> 4)) +
8813
+ keyStr.charAt(((e2 & 15) << 2) | (e3 >> 6)) +
8814
+ keyStr.charAt(e3 & 63);
8815
+ /**
8816
+ * Converts RGB values to a data URL string
8817
+ *
8818
+ * @param r - The red channel value.
8819
+ * @param g - The green channel value.
8820
+ * @param b - The blue channel value.
8821
+ * @returns The RGB data URL string.
8822
+ *
8823
+ * @private util of `colorToDataUrl`
8824
+ */
8825
+ const rgbDataURL = (r, g, b) => `data:image/gif;base64,R0lGODlhAQABAPAA${triplet(0, r, g) + triplet(b, 255, 255)}/yH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==`;
8826
+ /**
8827
+ * TODO: Make as functions NOT const
8828
+ */
8829
+
8784
8830
  /**
8785
8831
  * Restricts an Updatable to a (2) BehaviorSubject variant
8786
8832
  *
@@ -9508,7 +9554,7 @@
9508
9554
  * @private internal subcomponent of `<Chat>` component
9509
9555
  */
9510
9556
  const ChatMessageItem = react.memo(({ message, participant, participants, isLastMessage, onMessage, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, onCopy, onCreateAgent, }) => {
9511
- const avatarSrc = (participant === null || participant === void 0 ? void 0 : participant.avatarSrc) || '';
9557
+ const avatarSrc = (participant === null || participant === void 0 ? void 0 : participant.avatarSrc) || null;
9512
9558
  const [isAvatarTooltipVisible, setIsAvatarTooltipVisible] = react.useState(false);
9513
9559
  const [avatarTooltipPosition, setAvatarTooltipPosition] = react.useState(null);
9514
9560
  const hoverTimeoutRef = react.useRef(null);
@@ -9602,9 +9648,11 @@
9602
9648
  }, children: [avatarSrc && (jsxRuntime.jsxs("div", { ref: avatarRef, className: chatStyles.avatar, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave, onClick: showTooltip, children: [jsxRuntime.jsx("img", { width: AVATAR_SIZE, src: avatarSrc, alt: `Avatar of ${message.sender.toString().toLocaleLowerCase()}`, style: {
9603
9649
  '--avatar-bg-color': color.toHex(),
9604
9650
  objectFit: 'cover',
9651
+ objectPosition: '50% 20%',
9605
9652
  width: AVATAR_SIZE,
9606
9653
  height: AVATAR_SIZE,
9607
9654
  aspectRatio: '1 / 1',
9655
+ backgroundImage: `url(${colorToDataUrl(color)})`,
9608
9656
  } }), isAvatarTooltipVisible && (participant === null || participant === void 0 ? void 0 : participant.agentSource) && avatarTooltipPosition && (jsxRuntime.jsx(AvatarProfileTooltip, { ref: tooltipRef, agentSource: participant.agentSource, position: avatarTooltipPosition }))] })), jsxRuntime.jsxs("div", { className: chatStyles.messageText, style: {
9609
9657
  '--message-bg-color': color.toHex(),
9610
9658
  '--message-text-color': colorOfText.toHex(),