@promptbook/remote-client 0.103.0-16 → 0.103.0-17

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.
@@ -0,0 +1,10 @@
1
+ import { string_book } from './string_book';
2
+ /**
3
+ * A function that adds padding to the book content
4
+ *
5
+ * @private utility function
6
+ */
7
+ export declare function padBookContent(content: string_book): string_book;
8
+ /**
9
+ * TODO: [🧠] Maybe export
10
+ */
@@ -51,6 +51,17 @@ export type BookEditorProps = {
51
51
  * @default false
52
52
  */
53
53
  readonly isReadonly?: boolean;
54
+ /**
55
+ * Optional translations for the component
56
+ */
57
+ readonly translations?: {
58
+ /**
59
+ * Message to show when trying to edit a readonly editor
60
+ *
61
+ * @default "You cannot edit this book"
62
+ */
63
+ readonly readonlyMessage?: string;
64
+ };
54
65
  /**
55
66
  * If true, shows the download button in the action bar.
56
67
  * By default, the download button is shown.
@@ -53,6 +53,7 @@ export declare const PROMPTBOOK_COLOR: import("./utils/take/interfaces/ITakeChai
53
53
  */
54
54
  export declare const PROMPTBOOK_SYNTAX_COLORS: {
55
55
  readonly TITLE: import("./utils/take/interfaces/ITakeChain").WithTake<Color>;
56
+ readonly LINE: import("./utils/take/interfaces/ITakeChain").WithTake<Color>;
56
57
  readonly COMMITMENT: import("./utils/take/interfaces/ITakeChain").WithTake<Color>;
57
58
  readonly PARAMETER: import("./utils/take/interfaces/ITakeChain").WithTake<Color>;
58
59
  };
@@ -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.103.0-15`).
18
+ * It follows semantic versioning (e.g., `0.103.0-16`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-client",
3
- "version": "0.103.0-16",
3
+ "version": "0.103.0-17",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -100,7 +100,7 @@
100
100
  "module": "./esm/index.es.js",
101
101
  "typings": "./esm/typings/src/_packages/remote-client.index.d.ts",
102
102
  "peerDependencies": {
103
- "@promptbook/core": "0.103.0-16"
103
+ "@promptbook/core": "0.103.0-17"
104
104
  },
105
105
  "dependencies": {
106
106
  "crypto": "1.0.1",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-16';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-17';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1056,17 +1056,6 @@
1056
1056
  * TODO: Maybe implement by mix+hsl
1057
1057
  */
1058
1058
 
1059
- /**
1060
- * Makes color transformer which darker the given color
1061
- *
1062
- * @param amount from 0 to 1
1063
- *
1064
- * @public exported from `@promptbook/color`
1065
- */
1066
- function darken(amount) {
1067
- return lighten(-amount);
1068
- }
1069
-
1070
1059
  /**
1071
1060
  * Calculates distance between two colors
1072
1061
  *
@@ -1241,7 +1230,8 @@
1241
1230
  * @public exported from `@promptbook/core`
1242
1231
  */
1243
1232
  ({
1244
- TITLE: PROMPTBOOK_COLOR.then(darken(0.5)),
1233
+ TITLE: Color.fromHex('#244EA8'),
1234
+ LINE: Color.fromHex('#DA0F78'),
1245
1235
  COMMITMENT: Color.fromHex('#DA0F78'),
1246
1236
  PARAMETER: Color.fromHex('#8e44ad'),
1247
1237
  });
@@ -5589,6 +5579,44 @@
5589
5579
  const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
5590
5580
  // <- TODO: [🏥] DRY
5591
5581
 
5582
+ /**
5583
+ * @private constant for `padBookContent`
5584
+ */
5585
+ const PADDING_LINES = 5;
5586
+ /**
5587
+ * A function that adds padding to the book content
5588
+ *
5589
+ * @private utility function
5590
+ */
5591
+ function padBookContent(content) {
5592
+ if (!content) {
5593
+ return '\n'.repeat(PADDING_LINES);
5594
+ }
5595
+ const lines = content.split('\n');
5596
+ let trailingEmptyLines = 0;
5597
+ for (let i = lines.length - 1; i >= 0; i--) {
5598
+ const line = lines[i];
5599
+ if (line === undefined) {
5600
+ // Note: This should not happen in reality, but it's here to satisfy TypeScript's noUncheckedIndexedAccess option
5601
+ continue;
5602
+ }
5603
+ if (line.trim() === '') {
5604
+ trailingEmptyLines++;
5605
+ }
5606
+ else {
5607
+ break;
5608
+ }
5609
+ }
5610
+ if (trailingEmptyLines >= PADDING_LINES) {
5611
+ return content;
5612
+ }
5613
+ const linesToAdd = PADDING_LINES - trailingEmptyLines;
5614
+ return (content + '\n'.repeat(linesToAdd));
5615
+ }
5616
+ /**
5617
+ * TODO: [🧠] Maybe export
5618
+ */
5619
+
5592
5620
  /**
5593
5621
  * Removes Markdown (or HTML) comments
5594
5622
  *
@@ -5634,6 +5662,7 @@
5634
5662
  if (!isFlatPipeline(pipelineString)) {
5635
5663
  return pipelineString;
5636
5664
  }
5665
+ pipelineString = spaceTrim__default["default"](pipelineString);
5637
5666
  const pipelineStringLines = pipelineString.split('\n');
5638
5667
  const potentialReturnStatement = pipelineStringLines.pop();
5639
5668
  let returnStatement;
@@ -5668,7 +5697,7 @@
5668
5697
  ${returnStatement}
5669
5698
  `));
5670
5699
  // <- TODO: Maybe use book` notation
5671
- return pipelineString;
5700
+ return padBookContent(pipelineString);
5672
5701
  }
5673
5702
  /**
5674
5703
  * TODO: Unit test