@promptbook/markitdown 0.112.0-73 → 0.112.0-81
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/README.md +9 -9
- package/esm/index.es.js +313 -210
- package/esm/index.es.js.map +1 -1
- package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/esm/src/avatars/visuals/octopus3d2AvatarVisual.d.ts +7 -0
- package/esm/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +37 -0
- package/esm/src/book-components/Chat/save/_common/chatExportRendering.d.ts +47 -0
- package/esm/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +12 -0
- package/esm/src/book-components/Chat/save/index.d.ts +2 -2
- package/esm/src/book-components/Chat/save/markdown/mdSaveFormatDefinition.d.ts +5 -3
- package/esm/src/book-components/Chat/save/pdf/buildChatPdf.d.ts +3 -3
- package/esm/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +1 -1
- package/esm/src/cli/cli-commands/agent/agentProjectPaths.d.ts +8 -8
- package/esm/src/cli/cli-commands/agent/initializeAgentRunnerCommand.d.ts +1 -1
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +56 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/init.d.ts +9 -0
- package/esm/src/cli/cli-commands/agents-server/init.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/agents-server/initializeAgentsServerProjectConfiguration.d.ts +17 -0
- package/esm/src/cli/cli-commands/agents-server/printAgentsServerInitializationSummary.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/run.d.ts +14 -0
- package/esm/src/cli/cli-commands/agents-server/run.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +23 -0
- package/esm/src/cli/cli-commands/agents-server.d.ts +8 -0
- package/esm/src/cli/cli-commands/common/projectInitialization.d.ts +65 -0
- package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +44 -0
- package/esm/src/cli/common/$deprecateCliCommand.d.ts +8 -0
- package/esm/src/cli/common/$deprecateCliCommand.test.d.ts +1 -0
- package/esm/src/utils/color/Color.d.ts +4 -44
- package/esm/src/utils/color/ColorValue.d.ts +55 -0
- package/esm/src/utils/color/isHexColorString.d.ts +10 -0
- package/esm/src/utils/color/parseColorString.d.ts +11 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +313 -210
- package/umd/index.umd.js.map +1 -1
- package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/umd/src/avatars/visuals/octopus3d2AvatarVisual.d.ts +7 -0
- package/umd/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +37 -0
- package/umd/src/book-components/Chat/save/_common/chatExportRendering.d.ts +47 -0
- package/umd/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +12 -0
- package/umd/src/book-components/Chat/save/index.d.ts +2 -2
- package/umd/src/book-components/Chat/save/markdown/mdSaveFormatDefinition.d.ts +5 -3
- package/umd/src/book-components/Chat/save/pdf/buildChatPdf.d.ts +3 -3
- package/umd/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +1 -1
- package/umd/src/cli/cli-commands/agent/agentProjectPaths.d.ts +8 -8
- package/umd/src/cli/cli-commands/agent/initializeAgentRunnerCommand.d.ts +1 -1
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +56 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/init.d.ts +9 -0
- package/umd/src/cli/cli-commands/agents-server/init.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/agents-server/initializeAgentsServerProjectConfiguration.d.ts +17 -0
- package/umd/src/cli/cli-commands/agents-server/printAgentsServerInitializationSummary.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/run.d.ts +14 -0
- package/umd/src/cli/cli-commands/agents-server/run.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +23 -0
- package/umd/src/cli/cli-commands/agents-server.d.ts +8 -0
- package/umd/src/cli/cli-commands/common/projectInitialization.d.ts +65 -0
- package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +44 -0
- package/umd/src/cli/common/$deprecateCliCommand.d.ts +8 -0
- package/umd/src/cli/common/$deprecateCliCommand.test.d.ts +1 -0
- package/umd/src/utils/color/Color.d.ts +4 -44
- package/umd/src/utils/color/ColorValue.d.ts +55 -0
- package/umd/src/utils/color/isHexColorString.d.ts +10 -0
- package/umd/src/utils/color/parseColorString.d.ts +11 -0
- package/umd/src/version.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/appendBlock.d.ts +0 -6
- package/esm/src/cli/cli-commands/coder/readTextFileIfExists.d.ts +0 -6
- package/umd/src/cli/cli-commands/coder/appendBlock.d.ts +0 -6
- package/umd/src/cli/cli-commands/coder/readTextFileIfExists.d.ts +0 -6
package/esm/index.es.js
CHANGED
|
@@ -24,7 +24,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
24
24
|
* @generated
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
27
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-81';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -292,6 +292,111 @@ function checkChannelValue(channelName, value) {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Shared immutable channel storage and serialization helpers for `Color`.
|
|
297
|
+
*
|
|
298
|
+
* @private base class of Color
|
|
299
|
+
*/
|
|
300
|
+
class ColorValue {
|
|
301
|
+
constructor(red, green, blue, alpha = 255) {
|
|
302
|
+
this.red = red;
|
|
303
|
+
this.green = green;
|
|
304
|
+
this.blue = blue;
|
|
305
|
+
this.alpha = alpha;
|
|
306
|
+
checkChannelValue('Red', red);
|
|
307
|
+
checkChannelValue('Green', green);
|
|
308
|
+
checkChannelValue('Blue', blue);
|
|
309
|
+
checkChannelValue('Alpha', alpha);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Shortcut for `red` property
|
|
313
|
+
* Number from 0 to 255
|
|
314
|
+
* @alias red
|
|
315
|
+
*/
|
|
316
|
+
get r() {
|
|
317
|
+
return this.red;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Shortcut for `green` property
|
|
321
|
+
* Number from 0 to 255
|
|
322
|
+
* @alias green
|
|
323
|
+
*/
|
|
324
|
+
get g() {
|
|
325
|
+
return this.green;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Shortcut for `blue` property
|
|
329
|
+
* Number from 0 to 255
|
|
330
|
+
* @alias blue
|
|
331
|
+
*/
|
|
332
|
+
get b() {
|
|
333
|
+
return this.blue;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Shortcut for `alpha` property
|
|
337
|
+
* Number from 0 (transparent) to 255 (opaque)
|
|
338
|
+
* @alias alpha
|
|
339
|
+
*/
|
|
340
|
+
get a() {
|
|
341
|
+
return this.alpha;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Shortcut for `alpha` property
|
|
345
|
+
* Number from 0 (transparent) to 255 (opaque)
|
|
346
|
+
* @alias alpha
|
|
347
|
+
*/
|
|
348
|
+
get opacity() {
|
|
349
|
+
return this.alpha;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Shortcut for 1-`alpha` property
|
|
353
|
+
*/
|
|
354
|
+
get transparency() {
|
|
355
|
+
return 255 - this.alpha;
|
|
356
|
+
}
|
|
357
|
+
clone() {
|
|
358
|
+
return take(this.createColor(this.red, this.green, this.blue, this.alpha));
|
|
359
|
+
}
|
|
360
|
+
toString() {
|
|
361
|
+
return this.toHex();
|
|
362
|
+
}
|
|
363
|
+
toHex() {
|
|
364
|
+
if (this.alpha === 255) {
|
|
365
|
+
return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
|
|
366
|
+
.toString(16)
|
|
367
|
+
.padStart(2, '0')}`;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
|
|
371
|
+
.toString(16)
|
|
372
|
+
.padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
toRgb() {
|
|
376
|
+
if (this.alpha === 255) {
|
|
377
|
+
return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
toHsl() {
|
|
384
|
+
throw new Error(`Getting HSL is not implemented`);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Checks if the given value is a valid hex color string
|
|
390
|
+
*
|
|
391
|
+
* @param value - value to check
|
|
392
|
+
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
393
|
+
*
|
|
394
|
+
* @private function of Color
|
|
395
|
+
*/
|
|
396
|
+
function isHexColorString(value) {
|
|
397
|
+
return (typeof value === 'string' && /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
398
|
+
}
|
|
399
|
+
|
|
295
400
|
/**
|
|
296
401
|
* Constant for short hex lengths.
|
|
297
402
|
*/
|
|
@@ -503,16 +608,53 @@ function parseAlphaValue(value) {
|
|
|
503
608
|
|
|
504
609
|
/**
|
|
505
610
|
* Pattern matching hsl regex.
|
|
611
|
+
*
|
|
612
|
+
* @private function of Color
|
|
506
613
|
*/
|
|
507
614
|
const HSL_REGEX_PATTERN = /^hsl\(\s*([0-9.]+)\s*,\s*([0-9.]+)%\s*,\s*([0-9.]+)%\s*\)$/;
|
|
508
615
|
/**
|
|
509
616
|
* Pattern matching RGB regex.
|
|
617
|
+
*
|
|
618
|
+
* @private function of Color
|
|
510
619
|
*/
|
|
511
620
|
const RGB_REGEX_PATTERN = /^rgb\(\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*\)$/;
|
|
512
621
|
/**
|
|
513
622
|
* Pattern matching rgba regex.
|
|
623
|
+
*
|
|
624
|
+
* @private function of Color
|
|
514
625
|
*/
|
|
515
626
|
const RGBA_REGEX_PATTERN = /^rgba\(\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*\)$/;
|
|
627
|
+
/**
|
|
628
|
+
* Parses a supported color string into RGBA channels.
|
|
629
|
+
*
|
|
630
|
+
* @param color as a string for example `#009edd`, `rgb(0,158,221)`, `rgb(0%,62%,86.7%)`, `hsl(197.1,100%,43.3%)`, `red`, `darkgrey`,...
|
|
631
|
+
* @returns RGBA channel values.
|
|
632
|
+
*
|
|
633
|
+
* @private function of Color
|
|
634
|
+
*/
|
|
635
|
+
function parseColorString(color) {
|
|
636
|
+
const trimmed = color.trim();
|
|
637
|
+
const cssColor = CSS_COLORS[trimmed];
|
|
638
|
+
if (cssColor) {
|
|
639
|
+
return parseColorString(cssColor);
|
|
640
|
+
}
|
|
641
|
+
else if (isHexColorString(trimmed)) {
|
|
642
|
+
return parseHexColor(trimmed);
|
|
643
|
+
}
|
|
644
|
+
if (HSL_REGEX_PATTERN.test(trimmed)) {
|
|
645
|
+
return parseHslColor(trimmed);
|
|
646
|
+
}
|
|
647
|
+
else if (RGB_REGEX_PATTERN.test(trimmed)) {
|
|
648
|
+
return parseRgbColor(trimmed);
|
|
649
|
+
}
|
|
650
|
+
else if (RGBA_REGEX_PATTERN.test(trimmed)) {
|
|
651
|
+
return parseRgbaColor(trimmed);
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
throw new Error(`Can not create a new Color instance from string "${trimmed}".`);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
516
658
|
/**
|
|
517
659
|
* Color object represents an RGB color with alpha channel
|
|
518
660
|
*
|
|
@@ -520,7 +662,7 @@ const RGBA_REGEX_PATTERN = /^rgba\(\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*,\s*([0-9.
|
|
|
520
662
|
*
|
|
521
663
|
* @public exported from `@promptbook/color`
|
|
522
664
|
*/
|
|
523
|
-
class Color {
|
|
665
|
+
class Color extends ColorValue {
|
|
524
666
|
/**
|
|
525
667
|
* Creates a new Color instance from miscellaneous formats
|
|
526
668
|
* - It can receive Color instance and just return the same instance
|
|
@@ -593,25 +735,7 @@ class Color {
|
|
|
593
735
|
* @returns Color object
|
|
594
736
|
*/
|
|
595
737
|
static fromString(color) {
|
|
596
|
-
|
|
597
|
-
if (CSS_COLORS[trimmed]) {
|
|
598
|
-
return Color.fromString(CSS_COLORS[trimmed]);
|
|
599
|
-
}
|
|
600
|
-
else if (Color.isHexColorString(trimmed)) {
|
|
601
|
-
return Color.fromHex(trimmed);
|
|
602
|
-
}
|
|
603
|
-
if (HSL_REGEX_PATTERN.test(trimmed)) {
|
|
604
|
-
return Color.fromHsl(trimmed);
|
|
605
|
-
}
|
|
606
|
-
else if (RGB_REGEX_PATTERN.test(trimmed)) {
|
|
607
|
-
return Color.fromRgbString(trimmed);
|
|
608
|
-
}
|
|
609
|
-
else if (RGBA_REGEX_PATTERN.test(trimmed)) {
|
|
610
|
-
return Color.fromRgbaString(trimmed);
|
|
611
|
-
}
|
|
612
|
-
else {
|
|
613
|
-
throw new Error(`Can not create a new Color instance from string "${trimmed}".`);
|
|
614
|
-
}
|
|
738
|
+
return Color.fromColorChannels(parseColorString(color));
|
|
615
739
|
}
|
|
616
740
|
/**
|
|
617
741
|
* Gets common color
|
|
@@ -641,8 +765,7 @@ class Color {
|
|
|
641
765
|
* @returns Color object
|
|
642
766
|
*/
|
|
643
767
|
static fromHex(hex) {
|
|
644
|
-
|
|
645
|
-
return take(new Color(red, green, blue, alpha));
|
|
768
|
+
return Color.fromColorChannels(parseHexColor(hex));
|
|
646
769
|
}
|
|
647
770
|
/**
|
|
648
771
|
* Creates a new Color instance from color in hsl format
|
|
@@ -651,8 +774,7 @@ class Color {
|
|
|
651
774
|
* @returns Color object
|
|
652
775
|
*/
|
|
653
776
|
static fromHsl(hsl) {
|
|
654
|
-
|
|
655
|
-
return take(new Color(red, green, blue, alpha));
|
|
777
|
+
return Color.fromColorChannels(parseHslColor(hsl));
|
|
656
778
|
}
|
|
657
779
|
/**
|
|
658
780
|
* Creates a new Color instance from color in rgb format
|
|
@@ -661,8 +783,7 @@ class Color {
|
|
|
661
783
|
* @returns Color object
|
|
662
784
|
*/
|
|
663
785
|
static fromRgbString(rgb) {
|
|
664
|
-
|
|
665
|
-
return take(new Color(red, green, blue, alpha));
|
|
786
|
+
return Color.fromColorChannels(parseRgbColor(rgb));
|
|
666
787
|
}
|
|
667
788
|
/**
|
|
668
789
|
* Creates a new Color instance from color in rbga format
|
|
@@ -671,8 +792,7 @@ class Color {
|
|
|
671
792
|
* @returns Color object
|
|
672
793
|
*/
|
|
673
794
|
static fromRgbaString(rgba) {
|
|
674
|
-
|
|
675
|
-
return take(new Color(red, green, blue, alpha));
|
|
795
|
+
return Color.fromColorChannels(parseRgbaColor(rgba));
|
|
676
796
|
}
|
|
677
797
|
/**
|
|
678
798
|
* Creates a new Color for color channels values
|
|
@@ -684,7 +804,7 @@ class Color {
|
|
|
684
804
|
* @returns Color object
|
|
685
805
|
*/
|
|
686
806
|
static fromValues(red, green, blue, alpha = 255) {
|
|
687
|
-
return
|
|
807
|
+
return Color.fromColorChannels({ red, green, blue, alpha });
|
|
688
808
|
}
|
|
689
809
|
/**
|
|
690
810
|
* Checks if the given value is a valid Color object.
|
|
@@ -717,8 +837,7 @@ class Color {
|
|
|
717
837
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
718
838
|
*/
|
|
719
839
|
static isHexColorString(value) {
|
|
720
|
-
return (
|
|
721
|
-
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
840
|
+
return isHexColorString(value);
|
|
722
841
|
}
|
|
723
842
|
/**
|
|
724
843
|
* Creates new Color object
|
|
@@ -731,89 +850,13 @@ class Color {
|
|
|
731
850
|
* @param alpha number from 0 (transparent) to 255 (opaque)
|
|
732
851
|
*/
|
|
733
852
|
constructor(red, green, blue, alpha = 255) {
|
|
734
|
-
|
|
735
|
-
this.green = green;
|
|
736
|
-
this.blue = blue;
|
|
737
|
-
this.alpha = alpha;
|
|
738
|
-
checkChannelValue('Red', red);
|
|
739
|
-
checkChannelValue('Green', green);
|
|
740
|
-
checkChannelValue('Blue', blue);
|
|
741
|
-
checkChannelValue('Alpha', alpha);
|
|
853
|
+
super(red, green, blue, alpha);
|
|
742
854
|
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
* Number from 0 to 255
|
|
746
|
-
* @alias red
|
|
747
|
-
*/
|
|
748
|
-
get r() {
|
|
749
|
-
return this.red;
|
|
855
|
+
createColor(red, green, blue, alpha) {
|
|
856
|
+
return new Color(red, green, blue, alpha);
|
|
750
857
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
* Number from 0 to 255
|
|
754
|
-
* @alias green
|
|
755
|
-
*/
|
|
756
|
-
get g() {
|
|
757
|
-
return this.green;
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* Shortcut for `blue` property
|
|
761
|
-
* Number from 0 to 255
|
|
762
|
-
* @alias blue
|
|
763
|
-
*/
|
|
764
|
-
get b() {
|
|
765
|
-
return this.blue;
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* Shortcut for `alpha` property
|
|
769
|
-
* Number from 0 (transparent) to 255 (opaque)
|
|
770
|
-
* @alias alpha
|
|
771
|
-
*/
|
|
772
|
-
get a() {
|
|
773
|
-
return this.alpha;
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Shortcut for `alpha` property
|
|
777
|
-
* Number from 0 (transparent) to 255 (opaque)
|
|
778
|
-
* @alias alpha
|
|
779
|
-
*/
|
|
780
|
-
get opacity() {
|
|
781
|
-
return this.alpha;
|
|
782
|
-
}
|
|
783
|
-
/**
|
|
784
|
-
* Shortcut for 1-`alpha` property
|
|
785
|
-
*/
|
|
786
|
-
get transparency() {
|
|
787
|
-
return 255 - this.alpha;
|
|
788
|
-
}
|
|
789
|
-
clone() {
|
|
790
|
-
return take(new Color(this.red, this.green, this.blue, this.alpha));
|
|
791
|
-
}
|
|
792
|
-
toString() {
|
|
793
|
-
return this.toHex();
|
|
794
|
-
}
|
|
795
|
-
toHex() {
|
|
796
|
-
if (this.alpha === 255) {
|
|
797
|
-
return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
|
|
798
|
-
.toString(16)
|
|
799
|
-
.padStart(2, '0')}`;
|
|
800
|
-
}
|
|
801
|
-
else {
|
|
802
|
-
return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
|
|
803
|
-
.toString(16)
|
|
804
|
-
.padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
toRgb() {
|
|
808
|
-
if (this.alpha === 255) {
|
|
809
|
-
return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
810
|
-
}
|
|
811
|
-
else {
|
|
812
|
-
return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
toHsl() {
|
|
816
|
-
throw new Error(`Getting HSL is not implemented`);
|
|
858
|
+
static fromColorChannels({ red, green, blue, alpha }) {
|
|
859
|
+
return take(new Color(red, green, blue, alpha));
|
|
817
860
|
}
|
|
818
861
|
}
|
|
819
862
|
|
|
@@ -2222,7 +2265,7 @@ function createJokerCommands(task) {
|
|
|
2222
2265
|
*/
|
|
2223
2266
|
function createPostprocessingCommands(task) {
|
|
2224
2267
|
var _a;
|
|
2225
|
-
return ((_a = task.postprocessingFunctionNames) === null || _a === void 0 ? void 0 : _a.map((postprocessingFunctionName) => `POSTPROCESSING \`${postprocessingFunctionName}\``)) || [];
|
|
2268
|
+
return (((_a = task.postprocessingFunctionNames) === null || _a === void 0 ? void 0 : _a.map((postprocessingFunctionName) => `POSTPROCESSING \`${postprocessingFunctionName}\``)) || []);
|
|
2226
2269
|
}
|
|
2227
2270
|
/**
|
|
2228
2271
|
* Collects expectation commands.
|
|
@@ -2387,120 +2430,183 @@ function $deepFreeze(objectValue) {
|
|
|
2387
2430
|
* @public exported from `@promptbook/utils`
|
|
2388
2431
|
*/
|
|
2389
2432
|
function checkSerializableAsJson(options) {
|
|
2390
|
-
|
|
2433
|
+
checkSerializableValue(options);
|
|
2434
|
+
}
|
|
2435
|
+
// TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
|
|
2436
|
+
// TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
|
|
2437
|
+
// Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
2438
|
+
/**
|
|
2439
|
+
* Checks one value and dispatches to the appropriate specialized validator.
|
|
2440
|
+
*
|
|
2441
|
+
* @private function of `checkSerializableAsJson`
|
|
2442
|
+
*/
|
|
2443
|
+
function checkSerializableValue(options) {
|
|
2444
|
+
const { value } = options;
|
|
2445
|
+
if (isSerializablePrimitive(value)) {
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2391
2448
|
if (value === undefined) {
|
|
2392
|
-
throw new UnexpectedError(`${name} is undefined`);
|
|
2449
|
+
throw new UnexpectedError(`${options.name} is undefined`);
|
|
2393
2450
|
}
|
|
2394
|
-
|
|
2395
|
-
|
|
2451
|
+
if (typeof value === 'symbol') {
|
|
2452
|
+
throw new UnexpectedError(`${options.name} is symbol`);
|
|
2396
2453
|
}
|
|
2397
|
-
|
|
2398
|
-
|
|
2454
|
+
if (typeof value === 'function') {
|
|
2455
|
+
throw new UnexpectedError(`${options.name} is function`);
|
|
2399
2456
|
}
|
|
2400
|
-
|
|
2457
|
+
if (Array.isArray(value)) {
|
|
2458
|
+
checkSerializableArray(options, value);
|
|
2401
2459
|
return;
|
|
2402
2460
|
}
|
|
2403
|
-
|
|
2461
|
+
if (value !== null && typeof value === 'object') {
|
|
2462
|
+
checkSerializableObject(options, value);
|
|
2404
2463
|
return;
|
|
2405
2464
|
}
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2465
|
+
throwUnknownTypeError(options);
|
|
2466
|
+
}
|
|
2467
|
+
/**
|
|
2468
|
+
* Checks the primitive values that are directly JSON serializable.
|
|
2469
|
+
*
|
|
2470
|
+
* @private function of `checkSerializableAsJson`
|
|
2471
|
+
*/
|
|
2472
|
+
function isSerializablePrimitive(value) {
|
|
2473
|
+
return (value === null ||
|
|
2474
|
+
typeof value === 'boolean' ||
|
|
2475
|
+
(typeof value === 'number' && !isNaN(value)) ||
|
|
2476
|
+
typeof value === 'string');
|
|
2477
|
+
}
|
|
2478
|
+
/**
|
|
2479
|
+
* Recursively checks JSON array items.
|
|
2480
|
+
*
|
|
2481
|
+
* @private function of `checkSerializableAsJson`
|
|
2482
|
+
*/
|
|
2483
|
+
function checkSerializableArray(context, arrayValue) {
|
|
2484
|
+
for (let index = 0; index < arrayValue.length; index++) {
|
|
2485
|
+
checkSerializableAsJson({
|
|
2486
|
+
...context,
|
|
2487
|
+
name: `${context.name}[${index}]`,
|
|
2488
|
+
value: arrayValue[index],
|
|
2489
|
+
});
|
|
2416
2490
|
}
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* Checks object-like values and dispatches special unsupported built-ins.
|
|
2494
|
+
*
|
|
2495
|
+
* @private function of `checkSerializableAsJson`
|
|
2496
|
+
*/
|
|
2497
|
+
function checkSerializableObject(context, objectValue) {
|
|
2498
|
+
checkUnsupportedObjectType(context, objectValue);
|
|
2499
|
+
checkSerializableObjectEntries(context, objectValue);
|
|
2500
|
+
assertJsonStringificationSucceeds(context, objectValue);
|
|
2501
|
+
}
|
|
2502
|
+
/**
|
|
2503
|
+
* Rejects built-in objects that must be converted before JSON serialization.
|
|
2504
|
+
*
|
|
2505
|
+
* @private function of `checkSerializableAsJson`
|
|
2506
|
+
*/
|
|
2507
|
+
function checkUnsupportedObjectType(context, objectValue) {
|
|
2508
|
+
if (objectValue instanceof Date) {
|
|
2509
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2510
|
+
\`${context.name}\` is Date
|
|
2421
2511
|
|
|
2422
|
-
|
|
2512
|
+
Use \`string_date_iso8601\` instead
|
|
2423
2513
|
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2514
|
+
Additional message for \`${context.name}\`:
|
|
2515
|
+
${block(context.message || '(nothing)')}
|
|
2516
|
+
`));
|
|
2517
|
+
}
|
|
2518
|
+
if (objectValue instanceof Map) {
|
|
2519
|
+
throw new UnexpectedError(`${context.name} is Map`);
|
|
2520
|
+
}
|
|
2521
|
+
if (objectValue instanceof Set) {
|
|
2522
|
+
throw new UnexpectedError(`${context.name} is Set`);
|
|
2523
|
+
}
|
|
2524
|
+
if (objectValue instanceof RegExp) {
|
|
2525
|
+
throw new UnexpectedError(`${context.name} is RegExp`);
|
|
2526
|
+
}
|
|
2527
|
+
if (objectValue instanceof Error) {
|
|
2528
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2529
|
+
\`${context.name}\` is unserialized Error
|
|
2440
2530
|
|
|
2441
|
-
|
|
2531
|
+
Use function \`serializeError\`
|
|
2442
2532
|
|
|
2443
|
-
|
|
2444
|
-
|
|
2533
|
+
Additional message for \`${context.name}\`:
|
|
2534
|
+
${block(context.message || '(nothing)')}
|
|
2445
2535
|
|
|
2446
|
-
|
|
2536
|
+
`));
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
/**
|
|
2540
|
+
* Recursively checks object properties while preserving omitted `undefined` keys.
|
|
2541
|
+
*
|
|
2542
|
+
* @private function of `checkSerializableAsJson`
|
|
2543
|
+
*/
|
|
2544
|
+
function checkSerializableObjectEntries(context, objectValue) {
|
|
2545
|
+
for (const [subName, subValue] of Object.entries(objectValue)) {
|
|
2546
|
+
if (subValue === undefined) {
|
|
2547
|
+
// Note: undefined in object is serializable - it is just omitted
|
|
2548
|
+
continue;
|
|
2447
2549
|
}
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2550
|
+
checkSerializableAsJson({
|
|
2551
|
+
...context,
|
|
2552
|
+
name: `${context.name}.${subName}`,
|
|
2553
|
+
value: subValue,
|
|
2554
|
+
});
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
/**
|
|
2558
|
+
* Uses `JSON.stringify` as the final guard for cases like circular references.
|
|
2559
|
+
*
|
|
2560
|
+
* @private function of `checkSerializableAsJson`
|
|
2561
|
+
*/
|
|
2562
|
+
function assertJsonStringificationSucceeds(context, objectValue) {
|
|
2563
|
+
try {
|
|
2564
|
+
JSON.stringify(objectValue); // <- TODO: [0]
|
|
2565
|
+
}
|
|
2566
|
+
catch (error) {
|
|
2567
|
+
assertsError(error);
|
|
2568
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2569
|
+
\`${context.name}\` is not serializable
|
|
2463
2570
|
|
|
2464
|
-
|
|
2571
|
+
${block(error.stack || error.message)}
|
|
2465
2572
|
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2573
|
+
Additional message for \`${context.name}\`:
|
|
2574
|
+
${block(context.message || '(nothing)')}
|
|
2575
|
+
`));
|
|
2576
|
+
}
|
|
2577
|
+
/*
|
|
2578
|
+
TODO: [0] Is there some more elegant way to check circular references?
|
|
2579
|
+
const seen = new Set();
|
|
2580
|
+
const stack = [{ value }];
|
|
2581
|
+
while (stack.length > 0) {
|
|
2582
|
+
const { value } = stack.pop()!;
|
|
2583
|
+
if (typeof value === 'object' && value !== null) {
|
|
2584
|
+
if (seen.has(value)) {
|
|
2585
|
+
throw new UnexpectedError(`${name} has circular reference`);
|
|
2469
2586
|
}
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
const { value } = stack.pop()!;
|
|
2476
|
-
if (typeof value === 'object' && value !== null) {
|
|
2477
|
-
if (seen.has(value)) {
|
|
2478
|
-
throw new UnexpectedError(`${name} has circular reference`);
|
|
2479
|
-
}
|
|
2480
|
-
seen.add(value);
|
|
2481
|
-
if (Array.isArray(value)) {
|
|
2482
|
-
stack.push(...value.map((value) => ({ value })));
|
|
2483
|
-
} else {
|
|
2484
|
-
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
2485
|
-
}
|
|
2486
|
-
}
|
|
2587
|
+
seen.add(value);
|
|
2588
|
+
if (Array.isArray(value)) {
|
|
2589
|
+
stack.push(...value.map((value) => ({ value })));
|
|
2590
|
+
} else {
|
|
2591
|
+
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
2487
2592
|
}
|
|
2488
|
-
*/
|
|
2489
|
-
return;
|
|
2490
2593
|
}
|
|
2491
2594
|
}
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2595
|
+
*/
|
|
2596
|
+
}
|
|
2597
|
+
/**
|
|
2598
|
+
* Throws the fallback error for unsupported value types like `bigint` and `NaN`.
|
|
2599
|
+
*
|
|
2600
|
+
* @private function of `checkSerializableAsJson`
|
|
2601
|
+
*/
|
|
2602
|
+
function throwUnknownTypeError(context) {
|
|
2603
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
2604
|
+
\`${context.name}\` is unknown type
|
|
2495
2605
|
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
}
|
|
2606
|
+
Additional message for \`${context.name}\`:
|
|
2607
|
+
${block(context.message || '(nothing)')}
|
|
2608
|
+
`));
|
|
2500
2609
|
}
|
|
2501
|
-
// TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
|
|
2502
|
-
// TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
|
|
2503
|
-
// Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
2504
2610
|
|
|
2505
2611
|
/**
|
|
2506
2612
|
* Creates a deep clone of the given object
|
|
@@ -3064,8 +3170,7 @@ function hasTaskJokers(task) {
|
|
|
3064
3170
|
* @private internal utility of `validatePipeline`
|
|
3065
3171
|
*/
|
|
3066
3172
|
function validateTaskSupportsJokers(task, pipelineIdentification) {
|
|
3067
|
-
if (task.format ||
|
|
3068
|
-
task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
3173
|
+
if (task.format || task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
3069
3174
|
return;
|
|
3070
3175
|
}
|
|
3071
3176
|
throw new PipelineLogicError(spaceTrim$1((block) => `
|
|
@@ -7133,9 +7238,7 @@ function createFailuresSummary($failedResults) {
|
|
|
7133
7238
|
${block(quoteMultilineText(((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message) || ''))}
|
|
7134
7239
|
|
|
7135
7240
|
Result:
|
|
7136
|
-
${block(failure.result === null
|
|
7137
|
-
? 'null'
|
|
7138
|
-
: quoteMultilineText(spaceTrim$1(failure.result)))}
|
|
7241
|
+
${block(failure.result === null ? 'null' : quoteMultilineText(spaceTrim$1(failure.result)))}
|
|
7139
7242
|
`;
|
|
7140
7243
|
}))
|
|
7141
7244
|
.join('\n\n---\n\n');
|