@promptbook/markdown-utils 0.101.0-0 β 0.101.0-2
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/esm/index.es.js +32 -5
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +0 -5
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +8 -2
- package/esm/typings/src/book-components/Chat/Chat/constants.d.ts +8 -0
- package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +16 -0
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +21 -0
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.test.d.ts +1 -0
- package/esm/typings/src/book-components/icons/ArrowIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/ResetIcon.d.ts +6 -0
- package/esm/typings/src/book-components/icons/SendIcon.d.ts +8 -0
- package/esm/typings/src/book-components/icons/TemplateIcon.d.ts +8 -0
- package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +2 -0
- package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +1 -0
- package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +1 -0
- package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +8 -0
- package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +1 -0
- package/esm/typings/src/utils/normalization/capitalize.d.ts +2 -0
- package/esm/typings/src/utils/normalization/decapitalize.d.ts +3 -1
- package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeWhitespaces.d.ts +2 -0
- package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +2 -0
- package/esm/typings/src/utils/parseNumber.d.ts +1 -0
- package/esm/typings/src/utils/removeEmojis.d.ts +2 -0
- package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
- package/esm/typings/src/utils/serialization/deepClone.d.ts +1 -0
- package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
- package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -0
- package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +37 -9
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
|
-
import parserHtml from 'prettier/parser-html';
|
|
3
|
-
import parserMarkdown from 'prettier/parser-markdown';
|
|
4
|
-
import { format } from 'prettier/standalone';
|
|
5
2
|
import { randomBytes } from 'crypto';
|
|
6
3
|
import { Subject } from 'rxjs';
|
|
7
4
|
import { forTime } from 'waitasecond';
|
|
@@ -26,7 +23,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
23
|
* @generated
|
|
27
24
|
* @see https://github.com/webgptorg/promptbook
|
|
28
25
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-2';
|
|
30
27
|
/**
|
|
31
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
29
|
* Note: [π] Ignore a discrepancy between file name and entity name
|
|
@@ -51,6 +48,8 @@ class ParseError extends Error {
|
|
|
51
48
|
/**
|
|
52
49
|
* Makes first letter of a string uppercase
|
|
53
50
|
*
|
|
51
|
+
* Note: [π] This function is idempotent.
|
|
52
|
+
*
|
|
54
53
|
* @public exported from `@promptbook/utils`
|
|
55
54
|
*/
|
|
56
55
|
function capitalize(word) {
|
|
@@ -642,6 +641,7 @@ function isValidFilePath(filename) {
|
|
|
642
641
|
/**
|
|
643
642
|
* Tests if given string is valid URL.
|
|
644
643
|
*
|
|
644
|
+
* Note: [π] This function is idempotent.
|
|
645
645
|
* Note: Dataurl are considered perfectly valid.
|
|
646
646
|
* Note: There are two similar functions:
|
|
647
647
|
* - `isValidUrl` which tests any URL
|
|
@@ -705,8 +705,18 @@ function validatePipelineString(pipelineString) {
|
|
|
705
705
|
* @private withing the package because of HUGE size of prettier dependency
|
|
706
706
|
*/
|
|
707
707
|
function prettifyMarkdown(content) {
|
|
708
|
+
// In browser/Next.js environments, just return the original content
|
|
709
|
+
// since prettier parsers are not available and would cause bundling issues
|
|
710
|
+
if (typeof window !== 'undefined') {
|
|
711
|
+
return content;
|
|
712
|
+
}
|
|
708
713
|
try {
|
|
709
|
-
|
|
714
|
+
// Use dynamic require to avoid static imports that cause bundling issues
|
|
715
|
+
// This will only work in Node.js environments
|
|
716
|
+
const prettierStandalone = eval('require')('prettier/standalone');
|
|
717
|
+
const parserMarkdown = eval('require')('prettier/parser-markdown');
|
|
718
|
+
const parserHtml = eval('require')('prettier/parser-html');
|
|
719
|
+
return prettierStandalone.format(content, {
|
|
710
720
|
parser: 'markdown',
|
|
711
721
|
plugins: [parserMarkdown, parserHtml],
|
|
712
722
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
@@ -1054,6 +1064,7 @@ function checkSerializableAsJson(options) {
|
|
|
1054
1064
|
/**
|
|
1055
1065
|
* Creates a deep clone of the given object
|
|
1056
1066
|
*
|
|
1067
|
+
* Note: [π] This function is idempotent.
|
|
1057
1068
|
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1058
1069
|
*
|
|
1059
1070
|
* @param objectValue The object to clone.
|
|
@@ -2989,6 +3000,8 @@ function $getGlobalScope() {
|
|
|
2989
3000
|
/**
|
|
2990
3001
|
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
2991
3002
|
*
|
|
3003
|
+
* Note: [π] This function is idempotent.
|
|
3004
|
+
*
|
|
2992
3005
|
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
2993
3006
|
* @returns The normalized text in SCREAMING_CASE format.
|
|
2994
3007
|
* @example 'HELLO_WORLD'
|
|
@@ -3044,6 +3057,8 @@ function normalizeTo_SCREAMING_CASE(text) {
|
|
|
3044
3057
|
/**
|
|
3045
3058
|
* Normalizes a text string to snake_case format.
|
|
3046
3059
|
*
|
|
3060
|
+
* Note: [π] This function is idempotent.
|
|
3061
|
+
*
|
|
3047
3062
|
* @param text The text string to be converted to snake_case format.
|
|
3048
3063
|
* @returns The normalized text in snake_case format.
|
|
3049
3064
|
* @example 'hello_world'
|
|
@@ -3461,6 +3476,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
3461
3476
|
/**
|
|
3462
3477
|
* Removes diacritic marks (accents) from characters in a string.
|
|
3463
3478
|
*
|
|
3479
|
+
* Note: [π] This function is idempotent.
|
|
3480
|
+
*
|
|
3464
3481
|
* @param input The string containing diacritics to be normalized.
|
|
3465
3482
|
* @returns The string with diacritics removed or normalized.
|
|
3466
3483
|
* @public exported from `@promptbook/utils`
|
|
@@ -3615,6 +3632,8 @@ function mimeTypeToExtension(value) {
|
|
|
3615
3632
|
/**
|
|
3616
3633
|
* Removes emojis from a string and fix whitespaces
|
|
3617
3634
|
*
|
|
3635
|
+
* Note: [π] This function is idempotent.
|
|
3636
|
+
*
|
|
3618
3637
|
* @param text with emojis
|
|
3619
3638
|
* @returns text without emojis
|
|
3620
3639
|
* @public exported from `@promptbook/utils`
|
|
@@ -6616,6 +6635,8 @@ function createMarkdownChart(options) {
|
|
|
6616
6635
|
* Function escapeMarkdownBlock will escape markdown block if needed
|
|
6617
6636
|
* It is useful when you want have block in block
|
|
6618
6637
|
*
|
|
6638
|
+
* Note: [π] This function is idempotent.
|
|
6639
|
+
*
|
|
6619
6640
|
* @public exported from `@promptbook/markdown-utils`
|
|
6620
6641
|
*/
|
|
6621
6642
|
function escapeMarkdownBlock(value) {
|
|
@@ -6783,6 +6804,7 @@ function flattenMarkdown(markdown) {
|
|
|
6783
6804
|
/**
|
|
6784
6805
|
* Change ellipsis character to three dots `β¦` -> `...`
|
|
6785
6806
|
*
|
|
6807
|
+
* Note: [π] This function is idempotent.
|
|
6786
6808
|
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6787
6809
|
*
|
|
6788
6810
|
* @public exported from `@promptbook/markdown-utils`
|
|
@@ -6797,6 +6819,7 @@ function humanizeAiTextEllipsis(aiText) {
|
|
|
6797
6819
|
/**
|
|
6798
6820
|
* Change em-dashes to regular dashes `β` -> `-`
|
|
6799
6821
|
*
|
|
6822
|
+
* Note: [π] This function is idempotent.
|
|
6800
6823
|
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6801
6824
|
*
|
|
6802
6825
|
* @public exported from `@promptbook/markdown-utils`
|
|
@@ -6811,6 +6834,7 @@ function humanizeAiTextEmdashed(aiText) {
|
|
|
6811
6834
|
/**
|
|
6812
6835
|
* Change smart quotes to regular quotes
|
|
6813
6836
|
*
|
|
6837
|
+
* Note: [π] This function is idempotent.
|
|
6814
6838
|
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6815
6839
|
*
|
|
6816
6840
|
* @public exported from `@promptbook/markdown-utils`
|
|
@@ -6832,6 +6856,7 @@ function humanizeAiTextQuotes(aiText) {
|
|
|
6832
6856
|
/**
|
|
6833
6857
|
* Change unprintable hard spaces to regular spaces
|
|
6834
6858
|
*
|
|
6859
|
+
* Note: [π] This function is idempotent.
|
|
6835
6860
|
* Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
|
|
6836
6861
|
*
|
|
6837
6862
|
* @public exported from `@promptbook/markdown-utils`
|
|
@@ -6846,6 +6871,7 @@ function humanizeAiTextWhitespace(aiText) {
|
|
|
6846
6871
|
/**
|
|
6847
6872
|
* Function `humanizeAiText` will remove traces of AI text generation artifacts
|
|
6848
6873
|
*
|
|
6874
|
+
* Note: [π] This function is idempotent.
|
|
6849
6875
|
* Tip: If you want more control, look for other functions for example `humanizeAiTextEmdashed` exported `@promptbook/markdown-utils`
|
|
6850
6876
|
*
|
|
6851
6877
|
* @public exported from `@promptbook/markdown-utils`
|
|
@@ -6878,6 +6904,7 @@ function promptbookifyAiText(text) {
|
|
|
6878
6904
|
return promptbookifiedText;
|
|
6879
6905
|
}
|
|
6880
6906
|
/**
|
|
6907
|
+
* TODO: !!!!! Make the function idempotent and add "Note: [π] This function is idempotent."
|
|
6881
6908
|
* TODO: [π
ΎοΈ]!!! Use this across the project where AI text is involved
|
|
6882
6909
|
* TODO: [π§ ][βοΈ] Make some Promptbook-native token system
|
|
6883
6910
|
*/
|