@promptbook/markdown-utils 0.101.0-0 β†’ 0.101.0-10

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 (61) hide show
  1. package/README.md +87 -1
  2. package/esm/index.es.js +33 -5
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/components.index.d.ts +18 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  7. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +41 -3
  8. package/esm/typings/src/book-2.0/agent-source/parseParameters.d.ts +13 -0
  9. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +8 -2
  10. package/esm/typings/src/book-2.0/commitments/DELETE/DELETE.d.ts +59 -0
  11. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +8 -2
  12. package/esm/typings/src/book-2.0/commitments/GOAL/GOAL.d.ts +45 -0
  13. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +1 -1
  14. package/esm/typings/src/book-2.0/commitments/MEMORY/MEMORY.d.ts +46 -0
  15. package/esm/typings/src/book-2.0/commitments/MESSAGE/MESSAGE.d.ts +47 -0
  16. package/esm/typings/src/book-2.0/commitments/META/META.d.ts +62 -0
  17. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +8 -2
  18. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +8 -2
  19. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +8 -2
  20. package/esm/typings/src/book-2.0/commitments/SCENARIO/SCENARIO.d.ts +46 -0
  21. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +8 -2
  22. package/esm/typings/src/book-2.0/commitments/index.d.ts +7 -3
  23. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/MockedChat.d.ts +46 -0
  24. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/index.d.ts +3 -0
  25. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +10 -0
  26. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +3 -0
  27. package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +0 -5
  28. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +28 -2
  29. package/esm/typings/src/book-components/Chat/Chat/constants.d.ts +8 -0
  30. package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +16 -0
  31. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +21 -0
  32. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.test.d.ts +1 -0
  33. package/esm/typings/src/book-components/icons/ArrowIcon.d.ts +9 -0
  34. package/esm/typings/src/book-components/icons/ResetIcon.d.ts +6 -0
  35. package/esm/typings/src/book-components/icons/SendIcon.d.ts +8 -0
  36. package/esm/typings/src/book-components/icons/TemplateIcon.d.ts +8 -0
  37. package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +2 -0
  38. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +2 -0
  39. package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +1 -0
  40. package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +1 -0
  41. package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +1 -0
  42. package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +1 -0
  43. package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +8 -0
  44. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +1 -0
  45. package/esm/typings/src/utils/normalization/capitalize.d.ts +2 -0
  46. package/esm/typings/src/utils/normalization/decapitalize.d.ts +3 -1
  47. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +2 -0
  48. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +2 -0
  49. package/esm/typings/src/utils/normalization/normalizeWhitespaces.d.ts +2 -0
  50. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +2 -0
  51. package/esm/typings/src/utils/parseNumber.d.ts +1 -0
  52. package/esm/typings/src/utils/removeEmojis.d.ts +2 -0
  53. package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
  54. package/esm/typings/src/utils/serialization/deepClone.d.ts +1 -0
  55. package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
  56. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -0
  57. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
  58. package/esm/typings/src/version.d.ts +1 -1
  59. package/package.json +1 -1
  60. package/umd/index.umd.js +38 -9
  61. package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js CHANGED
@@ -1,14 +1,12 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone'), require('crypto'), require('rxjs'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('papaparse')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'crypto', 'rxjs', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'papaparse'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.parserHtml, global.parserMarkdown, global.standalone, global.crypto, global.rxjs, global.waitasecond, global.hexEncoder, global.sha256, global.path, global.cryptoJs, global.mimeTypes, global.papaparse));
5
- })(this, (function (exports, spaceTrim, parserHtml, parserMarkdown, standalone, crypto, rxjs, waitasecond, hexEncoder, sha256, path, cryptoJs, mimeTypes, papaparse) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('rxjs'), require('waitasecond'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('path'), require('crypto-js'), require('mime-types'), require('papaparse')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'rxjs', 'waitasecond', 'crypto-js/enc-hex', 'crypto-js/sha256', 'path', 'crypto-js', 'mime-types', 'papaparse'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-markdown-utils"] = {}, global.spaceTrim, global.crypto, global.rxjs, global.waitasecond, global.hexEncoder, global.sha256, global.path, global.cryptoJs, global.mimeTypes, global.papaparse));
5
+ })(this, (function (exports, spaceTrim, crypto, rxjs, waitasecond, hexEncoder, sha256, path, cryptoJs, mimeTypes, papaparse) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
10
- var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
11
- var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
12
10
  var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
13
11
  var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
14
12
 
@@ -26,7 +24,7 @@
26
24
  * @generated
27
25
  * @see https://github.com/webgptorg/promptbook
28
26
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.101.0-0';
27
+ const PROMPTBOOK_ENGINE_VERSION = '0.101.0-10';
30
28
  /**
31
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
30
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -51,6 +49,8 @@
51
49
  /**
52
50
  * Makes first letter of a string uppercase
53
51
  *
52
+ * Note: [πŸ”‚] This function is idempotent.
53
+ *
54
54
  * @public exported from `@promptbook/utils`
55
55
  */
56
56
  function capitalize(word) {
@@ -642,6 +642,7 @@
642
642
  /**
643
643
  * Tests if given string is valid URL.
644
644
  *
645
+ * Note: [πŸ”‚] This function is idempotent.
645
646
  * Note: Dataurl are considered perfectly valid.
646
647
  * Note: There are two similar functions:
647
648
  * - `isValidUrl` which tests any URL
@@ -705,10 +706,20 @@
705
706
  * @private withing the package because of HUGE size of prettier dependency
706
707
  */
707
708
  function prettifyMarkdown(content) {
709
+ // In browser/Next.js environments, just return the original content
710
+ // since prettier parsers are not available and would cause bundling issues
711
+ if (typeof window !== 'undefined') {
712
+ return content;
713
+ }
708
714
  try {
709
- return standalone.format(content, {
715
+ // Use dynamic require to avoid static imports that cause bundling issues
716
+ // This will only work in Node.js environments
717
+ const prettierStandalone = eval('require')('prettier/standalone');
718
+ const parserMarkdown = eval('require')('prettier/parser-markdown');
719
+ const parserHtml = eval('require')('prettier/parser-html');
720
+ return prettierStandalone.format(content, {
710
721
  parser: 'markdown',
711
- plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
722
+ plugins: [parserMarkdown, parserHtml],
712
723
  // TODO: DRY - make some import or auto-copy of .prettierrc
713
724
  endOfLine: 'lf',
714
725
  tabWidth: 4,
@@ -1054,6 +1065,7 @@
1054
1065
  /**
1055
1066
  * Creates a deep clone of the given object
1056
1067
  *
1068
+ * Note: [πŸ”‚] This function is idempotent.
1057
1069
  * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
1058
1070
  *
1059
1071
  * @param objectValue The object to clone.
@@ -2989,6 +3001,8 @@
2989
3001
  /**
2990
3002
  * Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
2991
3003
  *
3004
+ * Note: [πŸ”‚] This function is idempotent.
3005
+ *
2992
3006
  * @param text The text string to be converted to SCREAMING_CASE format.
2993
3007
  * @returns The normalized text in SCREAMING_CASE format.
2994
3008
  * @example 'HELLO_WORLD'
@@ -3044,6 +3058,8 @@
3044
3058
  /**
3045
3059
  * Normalizes a text string to snake_case format.
3046
3060
  *
3061
+ * Note: [πŸ”‚] This function is idempotent.
3062
+ *
3047
3063
  * @param text The text string to be converted to snake_case format.
3048
3064
  * @returns The normalized text in snake_case format.
3049
3065
  * @example 'hello_world'
@@ -3461,6 +3477,8 @@
3461
3477
  /**
3462
3478
  * Removes diacritic marks (accents) from characters in a string.
3463
3479
  *
3480
+ * Note: [πŸ”‚] This function is idempotent.
3481
+ *
3464
3482
  * @param input The string containing diacritics to be normalized.
3465
3483
  * @returns The string with diacritics removed or normalized.
3466
3484
  * @public exported from `@promptbook/utils`
@@ -3615,6 +3633,8 @@
3615
3633
  /**
3616
3634
  * Removes emojis from a string and fix whitespaces
3617
3635
  *
3636
+ * Note: [πŸ”‚] This function is idempotent.
3637
+ *
3618
3638
  * @param text with emojis
3619
3639
  * @returns text without emojis
3620
3640
  * @public exported from `@promptbook/utils`
@@ -6616,6 +6636,8 @@
6616
6636
  * Function escapeMarkdownBlock will escape markdown block if needed
6617
6637
  * It is useful when you want have block in block
6618
6638
  *
6639
+ * Note: [πŸ”‚] This function is idempotent.
6640
+ *
6619
6641
  * @public exported from `@promptbook/markdown-utils`
6620
6642
  */
6621
6643
  function escapeMarkdownBlock(value) {
@@ -6783,6 +6805,7 @@
6783
6805
  /**
6784
6806
  * Change ellipsis character to three dots `…` -> `...`
6785
6807
  *
6808
+ * Note: [πŸ”‚] This function is idempotent.
6786
6809
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6787
6810
  *
6788
6811
  * @public exported from `@promptbook/markdown-utils`
@@ -6797,6 +6820,7 @@
6797
6820
  /**
6798
6821
  * Change em-dashes to regular dashes `β€”` -> `-`
6799
6822
  *
6823
+ * Note: [πŸ”‚] This function is idempotent.
6800
6824
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6801
6825
  *
6802
6826
  * @public exported from `@promptbook/markdown-utils`
@@ -6811,6 +6835,7 @@
6811
6835
  /**
6812
6836
  * Change smart quotes to regular quotes
6813
6837
  *
6838
+ * Note: [πŸ”‚] This function is idempotent.
6814
6839
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6815
6840
  *
6816
6841
  * @public exported from `@promptbook/markdown-utils`
@@ -6832,6 +6857,7 @@
6832
6857
  /**
6833
6858
  * Change unprintable hard spaces to regular spaces
6834
6859
  *
6860
+ * Note: [πŸ”‚] This function is idempotent.
6835
6861
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6836
6862
  *
6837
6863
  * @public exported from `@promptbook/markdown-utils`
@@ -6846,6 +6872,7 @@
6846
6872
  /**
6847
6873
  * Function `humanizeAiText` will remove traces of AI text generation artifacts
6848
6874
  *
6875
+ * Note: [πŸ”‚] This function is idempotent.
6849
6876
  * Tip: If you want more control, look for other functions for example `humanizeAiTextEmdashed` exported `@promptbook/markdown-utils`
6850
6877
  *
6851
6878
  * @public exported from `@promptbook/markdown-utils`
@@ -6859,6 +6886,7 @@
6859
6886
  return cleanedText;
6860
6887
  }
6861
6888
  /**
6889
+ * TODO: [🧠] Maybe this should be exported from `@promptbook/utils` not `@promptbook/markdown-utils`
6862
6890
  * TODO: [πŸ…ΎοΈ] !!! Use this across the project where AI text is involved
6863
6891
  */
6864
6892
 
@@ -6878,6 +6906,7 @@
6878
6906
  return promptbookifiedText;
6879
6907
  }
6880
6908
  /**
6909
+ * TODO: !!!!! Make the function idempotent and add "Note: [πŸ”‚] This function is idempotent."
6881
6910
  * TODO: [πŸ…ΎοΈ]!!! Use this across the project where AI text is involved
6882
6911
  * TODO: [🧠][✌️] Make some Promptbook-native token system
6883
6912
  */