@promptbook/remote-server 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 +31 -6
- 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 +2 -2
- package/umd/index.umd.js +36 -10
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -11,9 +11,6 @@ import { spawn } from 'child_process';
|
|
|
11
11
|
import { stat, access, constants, readFile, writeFile, readdir, mkdir } from 'fs/promises';
|
|
12
12
|
import { join, basename, dirname, isAbsolute } from 'path';
|
|
13
13
|
import { Subject } from 'rxjs';
|
|
14
|
-
import parserHtml from 'prettier/parser-html';
|
|
15
|
-
import parserMarkdown from 'prettier/parser-markdown';
|
|
16
|
-
import { format } from 'prettier/standalone';
|
|
17
14
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
18
15
|
import sha256 from 'crypto-js/sha256';
|
|
19
16
|
import { SHA256 } from 'crypto-js';
|
|
@@ -34,7 +31,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
34
31
|
* @generated
|
|
35
32
|
* @see https://github.com/webgptorg/promptbook
|
|
36
33
|
*/
|
|
37
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
|
34
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-2';
|
|
38
35
|
/**
|
|
39
36
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
40
37
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1299,6 +1296,7 @@ function checkSerializableAsJson(options) {
|
|
|
1299
1296
|
/**
|
|
1300
1297
|
* Creates a deep clone of the given object
|
|
1301
1298
|
*
|
|
1299
|
+
* Note: [🔂] This function is idempotent.
|
|
1302
1300
|
* Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
|
|
1303
1301
|
*
|
|
1304
1302
|
* @param objectValue The object to clone.
|
|
@@ -1464,6 +1462,7 @@ function isValidPromptbookVersion(version) {
|
|
|
1464
1462
|
/**
|
|
1465
1463
|
* Tests if given string is valid URL.
|
|
1466
1464
|
*
|
|
1465
|
+
* Note: [🔂] This function is idempotent.
|
|
1467
1466
|
* Note: Dataurl are considered perfectly valid.
|
|
1468
1467
|
* Note: There are two similar functions:
|
|
1469
1468
|
* - `isValidUrl` which tests any URL
|
|
@@ -2372,8 +2371,18 @@ function validatePipelineString(pipelineString) {
|
|
|
2372
2371
|
* @private withing the package because of HUGE size of prettier dependency
|
|
2373
2372
|
*/
|
|
2374
2373
|
function prettifyMarkdown(content) {
|
|
2374
|
+
// In browser/Next.js environments, just return the original content
|
|
2375
|
+
// since prettier parsers are not available and would cause bundling issues
|
|
2376
|
+
if (typeof window !== 'undefined') {
|
|
2377
|
+
return content;
|
|
2378
|
+
}
|
|
2375
2379
|
try {
|
|
2376
|
-
|
|
2380
|
+
// Use dynamic require to avoid static imports that cause bundling issues
|
|
2381
|
+
// This will only work in Node.js environments
|
|
2382
|
+
const prettierStandalone = eval('require')('prettier/standalone');
|
|
2383
|
+
const parserMarkdown = eval('require')('prettier/parser-markdown');
|
|
2384
|
+
const parserHtml = eval('require')('prettier/parser-html');
|
|
2385
|
+
return prettierStandalone.format(content, {
|
|
2377
2386
|
parser: 'markdown',
|
|
2378
2387
|
plugins: [parserMarkdown, parserHtml],
|
|
2379
2388
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
@@ -2401,6 +2410,8 @@ function prettifyMarkdown(content) {
|
|
|
2401
2410
|
/**
|
|
2402
2411
|
* Makes first letter of a string uppercase
|
|
2403
2412
|
*
|
|
2413
|
+
* Note: [🔂] This function is idempotent.
|
|
2414
|
+
*
|
|
2404
2415
|
* @public exported from `@promptbook/utils`
|
|
2405
2416
|
*/
|
|
2406
2417
|
function capitalize(word) {
|
|
@@ -3241,6 +3252,8 @@ function $getGlobalScope() {
|
|
|
3241
3252
|
/**
|
|
3242
3253
|
* Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
|
|
3243
3254
|
*
|
|
3255
|
+
* Note: [🔂] This function is idempotent.
|
|
3256
|
+
*
|
|
3244
3257
|
* @param text The text string to be converted to SCREAMING_CASE format.
|
|
3245
3258
|
* @returns The normalized text in SCREAMING_CASE format.
|
|
3246
3259
|
* @example 'HELLO_WORLD'
|
|
@@ -3296,6 +3309,8 @@ function normalizeTo_SCREAMING_CASE(text) {
|
|
|
3296
3309
|
/**
|
|
3297
3310
|
* Normalizes a text string to snake_case format.
|
|
3298
3311
|
*
|
|
3312
|
+
* Note: [🔂] This function is idempotent.
|
|
3313
|
+
*
|
|
3299
3314
|
* @param text The text string to be converted to snake_case format.
|
|
3300
3315
|
* @returns The normalized text in snake_case format.
|
|
3301
3316
|
* @example 'hello_world'
|
|
@@ -3713,6 +3728,8 @@ for (let i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
|
3713
3728
|
/**
|
|
3714
3729
|
* Removes diacritic marks (accents) from characters in a string.
|
|
3715
3730
|
*
|
|
3731
|
+
* Note: [🔂] This function is idempotent.
|
|
3732
|
+
*
|
|
3716
3733
|
* @param input The string containing diacritics to be normalized.
|
|
3717
3734
|
* @returns The string with diacritics removed or normalized.
|
|
3718
3735
|
* @public exported from `@promptbook/utils`
|
|
@@ -3867,6 +3884,8 @@ function mimeTypeToExtension(value) {
|
|
|
3867
3884
|
/**
|
|
3868
3885
|
* Removes emojis from a string and fix whitespaces
|
|
3869
3886
|
*
|
|
3887
|
+
* Note: [🔂] This function is idempotent.
|
|
3888
|
+
*
|
|
3870
3889
|
* @param text with emojis
|
|
3871
3890
|
* @returns text without emojis
|
|
3872
3891
|
* @public exported from `@promptbook/utils`
|
|
@@ -7025,7 +7044,9 @@ new Function(`
|
|
|
7025
7044
|
*/
|
|
7026
7045
|
|
|
7027
7046
|
/**
|
|
7028
|
-
* Makes first letter of a string
|
|
7047
|
+
* Makes first letter of a string lowercase
|
|
7048
|
+
*
|
|
7049
|
+
* Note: [🔂] This function is idempotent.
|
|
7029
7050
|
*
|
|
7030
7051
|
* @public exported from `@promptbook/utils`
|
|
7031
7052
|
*/
|
|
@@ -7095,6 +7116,8 @@ function normalizeTo_PascalCase(text) {
|
|
|
7095
7116
|
/**
|
|
7096
7117
|
* Take every whitespace (space, new line, tab) and replace it with a single space
|
|
7097
7118
|
*
|
|
7119
|
+
* Note: [🔂] This function is idempotent.
|
|
7120
|
+
*
|
|
7098
7121
|
* @public exported from `@promptbook/utils`
|
|
7099
7122
|
*/
|
|
7100
7123
|
function normalizeWhitespaces(sentence) {
|
|
@@ -7104,6 +7127,7 @@ function normalizeWhitespaces(sentence) {
|
|
|
7104
7127
|
/**
|
|
7105
7128
|
* Removes quotes from a string
|
|
7106
7129
|
*
|
|
7130
|
+
* Note: [🔂] This function is idempotent.
|
|
7107
7131
|
* Tip: This is very useful for post-processing of the result of the LLM model
|
|
7108
7132
|
* Note: This function removes only the same quotes from the beginning and the end of the string
|
|
7109
7133
|
* Note: There are two similar functions:
|
|
@@ -7127,6 +7151,7 @@ function removeQuotes(text) {
|
|
|
7127
7151
|
/**
|
|
7128
7152
|
* Function trimCodeBlock will trim starting and ending code block from the string if it is present.
|
|
7129
7153
|
*
|
|
7154
|
+
* Note: [🔂] This function is idempotent.
|
|
7130
7155
|
* Note: This is useful for post-processing of the result of the chat LLM model
|
|
7131
7156
|
* when the model wraps the result in the (markdown) code block.
|
|
7132
7157
|
*
|