langsmith 0.5.16 → 0.5.18

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 (138) hide show
  1. package/dist/anonymizer/index.cjs +46 -20
  2. package/dist/anonymizer/index.js +46 -17
  3. package/dist/client.cjs +112 -143
  4. package/dist/client.d.ts +19 -40
  5. package/dist/client.js +112 -143
  6. package/dist/experimental/anthropic/index.cjs +4 -1
  7. package/dist/experimental/anthropic/index.js +4 -1
  8. package/dist/experimental/vercel/index.cjs +1 -0
  9. package/dist/experimental/vercel/index.js +1 -0
  10. package/dist/experimental/vercel/middleware.cjs +2 -0
  11. package/dist/experimental/vercel/middleware.js +2 -0
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.js +1 -1
  15. package/dist/schemas.d.ts +1 -3
  16. package/dist/utils/chalk/source/index.cjs +187 -0
  17. package/dist/utils/chalk/source/index.d.ts +19 -0
  18. package/dist/utils/chalk/source/index.js +173 -0
  19. package/dist/utils/chalk/source/utilities.cjs +35 -0
  20. package/dist/utils/chalk/source/utilities.d.ts +2 -0
  21. package/dist/utils/chalk/source/utilities.js +31 -0
  22. package/dist/utils/chalk/source/vendor/ansi-styles/index.cjs +193 -0
  23. package/dist/utils/chalk/source/vendor/ansi-styles/index.d.ts +58 -0
  24. package/dist/utils/chalk/source/vendor/ansi-styles/index.js +190 -0
  25. package/dist/utils/chalk/source/vendor/supports-color/browser.cjs +31 -0
  26. package/dist/utils/chalk/source/vendor/supports-color/browser.d.ts +15 -0
  27. package/dist/utils/chalk/source/vendor/supports-color/browser.js +29 -0
  28. package/dist/utils/chalk/source/vendor/supports-color/index.cjs +155 -0
  29. package/dist/utils/chalk/source/vendor/supports-color/index.d.ts +21 -0
  30. package/dist/utils/chalk/source/vendor/supports-color/index.js +149 -0
  31. package/dist/utils/console-table-printer/index.cjs +11 -0
  32. package/dist/utils/console-table-printer/index.d.ts +4 -0
  33. package/dist/utils/console-table-printer/index.js +3 -0
  34. package/dist/utils/console-table-printer/src/console-table-printer.cjs +42 -0
  35. package/dist/utils/console-table-printer/src/console-table-printer.d.ts +14 -0
  36. package/dist/utils/console-table-printer/src/console-table-printer.js +36 -0
  37. package/dist/utils/console-table-printer/src/internalTable/input-converter.cjs +25 -0
  38. package/dist/utils/console-table-printer/src/internalTable/input-converter.d.ts +6 -0
  39. package/dist/utils/console-table-printer/src/internalTable/input-converter.js +20 -0
  40. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.cjs +142 -0
  41. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.d.ts +6 -0
  42. package/dist/utils/console-table-printer/src/internalTable/internal-table-printer.js +133 -0
  43. package/dist/utils/console-table-printer/src/internalTable/internal-table.cjs +186 -0
  44. package/dist/utils/console-table-printer/src/internalTable/internal-table.d.ts +31 -0
  45. package/dist/utils/console-table-printer/src/internalTable/internal-table.js +184 -0
  46. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.cjs +53 -0
  47. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.d.ts +3 -0
  48. package/dist/utils/console-table-printer/src/internalTable/table-pre-processors.js +48 -0
  49. package/dist/utils/console-table-printer/src/models/common.cjs +2 -0
  50. package/dist/utils/console-table-printer/src/models/common.d.ts +14 -0
  51. package/dist/utils/console-table-printer/src/models/common.js +1 -0
  52. package/dist/utils/console-table-printer/src/models/external-table.cjs +2 -0
  53. package/dist/utils/console-table-printer/src/models/external-table.d.ts +99 -0
  54. package/dist/utils/console-table-printer/src/models/external-table.js +1 -0
  55. package/dist/utils/console-table-printer/src/models/internal-table.cjs +2 -0
  56. package/dist/utils/console-table-printer/src/models/internal-table.d.ts +24 -0
  57. package/dist/utils/console-table-printer/src/models/internal-table.js +1 -0
  58. package/dist/utils/console-table-printer/src/utils/colored-console-line.cjs +43 -0
  59. package/dist/utils/console-table-printer/src/utils/colored-console-line.d.ts +12 -0
  60. package/dist/utils/console-table-printer/src/utils/colored-console-line.js +39 -0
  61. package/dist/utils/console-table-printer/src/utils/console-utils.cjs +23 -0
  62. package/dist/utils/console-table-printer/src/utils/console-utils.d.ts +3 -0
  63. package/dist/utils/console-table-printer/src/utils/console-utils.js +18 -0
  64. package/dist/utils/console-table-printer/src/utils/string-utils.cjs +68 -0
  65. package/dist/utils/console-table-printer/src/utils/string-utils.d.ts +4 -0
  66. package/dist/utils/console-table-printer/src/utils/string-utils.js +62 -0
  67. package/dist/utils/console-table-printer/src/utils/table-constants.cjs +55 -0
  68. package/dist/utils/console-table-printer/src/utils/table-constants.d.ts +11 -0
  69. package/dist/utils/console-table-printer/src/utils/table-constants.js +52 -0
  70. package/dist/utils/console-table-printer/src/utils/table-helpers.cjs +101 -0
  71. package/dist/utils/console-table-printer/src/utils/table-helpers.d.ts +29 -0
  72. package/dist/utils/console-table-printer/src/utils/table-helpers.js +88 -0
  73. package/dist/utils/jestlike/reporter.cjs +23 -23
  74. package/dist/utils/jestlike/reporter.js +2 -2
  75. package/dist/utils/prompts.cjs +0 -10
  76. package/dist/utils/prompts.d.ts +0 -1
  77. package/dist/utils/prompts.js +0 -9
  78. package/dist/utils/simple-wcswidth/index.cjs +10 -0
  79. package/dist/utils/simple-wcswidth/index.d.ts +3 -0
  80. package/dist/utils/simple-wcswidth/index.js +3 -0
  81. package/dist/utils/simple-wcswidth/src/binary-search.cjs +24 -0
  82. package/dist/utils/simple-wcswidth/src/binary-search.d.ts +3 -0
  83. package/dist/utils/simple-wcswidth/src/binary-search.js +22 -0
  84. package/dist/utils/simple-wcswidth/src/models.cjs +2 -0
  85. package/dist/utils/simple-wcswidth/src/models.d.ts +4 -0
  86. package/dist/utils/simple-wcswidth/src/models.js +1 -0
  87. package/dist/utils/simple-wcswidth/src/non-spacing-chars.cjs +149 -0
  88. package/dist/utils/simple-wcswidth/src/non-spacing-chars.d.ts +3 -0
  89. package/dist/utils/simple-wcswidth/src/non-spacing-chars.js +147 -0
  90. package/dist/utils/simple-wcswidth/src/wcswidth.cjs +20 -0
  91. package/dist/utils/simple-wcswidth/src/wcswidth.d.ts +2 -0
  92. package/dist/utils/simple-wcswidth/src/wcswidth.js +15 -0
  93. package/dist/utils/simple-wcswidth/src/wcwidth.cjs +67 -0
  94. package/dist/utils/simple-wcswidth/src/wcwidth.d.ts +2 -0
  95. package/dist/utils/simple-wcswidth/src/wcwidth.js +62 -0
  96. package/package.json +5 -7
  97. package/dist/utils/lodash/assignValue.cjs +0 -29
  98. package/dist/utils/lodash/assignValue.d.ts +0 -10
  99. package/dist/utils/lodash/assignValue.js +0 -24
  100. package/dist/utils/lodash/baseAssignValue.cjs +0 -25
  101. package/dist/utils/lodash/baseAssignValue.d.ts +0 -11
  102. package/dist/utils/lodash/baseAssignValue.js +0 -23
  103. package/dist/utils/lodash/baseSet.cjs +0 -50
  104. package/dist/utils/lodash/baseSet.d.ts +0 -12
  105. package/dist/utils/lodash/baseSet.js +0 -45
  106. package/dist/utils/lodash/castPath.cjs +0 -22
  107. package/dist/utils/lodash/castPath.d.ts +0 -10
  108. package/dist/utils/lodash/castPath.js +0 -17
  109. package/dist/utils/lodash/eq.cjs +0 -36
  110. package/dist/utils/lodash/eq.d.ts +0 -32
  111. package/dist/utils/lodash/eq.js +0 -34
  112. package/dist/utils/lodash/getTag.cjs +0 -18
  113. package/dist/utils/lodash/getTag.d.ts +0 -9
  114. package/dist/utils/lodash/getTag.js +0 -16
  115. package/dist/utils/lodash/isIndex.cjs +0 -25
  116. package/dist/utils/lodash/isIndex.d.ts +0 -10
  117. package/dist/utils/lodash/isIndex.js +0 -23
  118. package/dist/utils/lodash/isKey.cjs +0 -34
  119. package/dist/utils/lodash/isKey.d.ts +0 -10
  120. package/dist/utils/lodash/isKey.js +0 -29
  121. package/dist/utils/lodash/isObject.cjs +0 -31
  122. package/dist/utils/lodash/isObject.d.ts +0 -25
  123. package/dist/utils/lodash/isObject.js +0 -29
  124. package/dist/utils/lodash/isSymbol.cjs +0 -28
  125. package/dist/utils/lodash/isSymbol.d.ts +0 -17
  126. package/dist/utils/lodash/isSymbol.js +0 -23
  127. package/dist/utils/lodash/memoizeCapped.cjs +0 -65
  128. package/dist/utils/lodash/memoizeCapped.d.ts +0 -50
  129. package/dist/utils/lodash/memoizeCapped.js +0 -63
  130. package/dist/utils/lodash/set.cjs +0 -41
  131. package/dist/utils/lodash/set.d.ts +0 -32
  132. package/dist/utils/lodash/set.js +0 -36
  133. package/dist/utils/lodash/stringToPath.cjs +0 -49
  134. package/dist/utils/lodash/stringToPath.d.ts +0 -12
  135. package/dist/utils/lodash/stringToPath.js +0 -44
  136. package/dist/utils/lodash/toKey.cjs +0 -24
  137. package/dist/utils/lodash/toKey.d.ts +0 -9
  138. package/dist/utils/lodash/toKey.js +0 -19
@@ -110,7 +110,10 @@ function wrapClaudeAgentQuery(queryFn, defaultThis, baseConfig) {
110
110
  name: "claude.conversation",
111
111
  run_type: "chain",
112
112
  ...baseConfig,
113
- metadata: { ...baseConfig?.metadata },
113
+ metadata: {
114
+ ls_integration: "claude-agent-sdk-js",
115
+ ...baseConfig?.metadata,
116
+ },
114
117
  __deferredSerializableArgOptions: { maxDepth: 1 },
115
118
  processInputs,
116
119
  processOutputs,
@@ -107,7 +107,10 @@ function wrapClaudeAgentQuery(queryFn, defaultThis, baseConfig) {
107
107
  name: "claude.conversation",
108
108
  run_type: "chain",
109
109
  ...baseConfig,
110
- metadata: { ...baseConfig?.metadata },
110
+ metadata: {
111
+ ls_integration: "claude-agent-sdk-js",
112
+ ...baseConfig?.metadata,
113
+ },
111
114
  __deferredSerializableArgOptions: { maxDepth: 1 },
112
115
  processInputs,
113
116
  processOutputs,
@@ -87,6 +87,7 @@ const _mergeConfig = (baseConfig, runtimeConfig) => {
87
87
  ...baseConfig,
88
88
  ...runtimeConfig,
89
89
  metadata: {
90
+ ls_integration: "vercel-ai-sdk",
90
91
  ...baseConfig?.metadata,
91
92
  ...runtimeConfig?.metadata,
92
93
  },
@@ -83,6 +83,7 @@ const _mergeConfig = (baseConfig, runtimeConfig) => {
83
83
  ...baseConfig,
84
84
  ...runtimeConfig,
85
85
  metadata: {
86
+ ls_integration: "vercel-ai-sdk",
86
87
  ...baseConfig?.metadata,
87
88
  ...runtimeConfig?.metadata,
88
89
  },
@@ -128,6 +128,7 @@ function LangSmithMiddleware(config) {
128
128
  name: name ?? "ai.doGenerate",
129
129
  run_type: "llm",
130
130
  metadata: {
131
+ ls_integration: "vercel-ai-sdk",
131
132
  ls_model_name: modelId,
132
133
  ai_sdk_method: "ai.doGenerate",
133
134
  ...lsConfig?.metadata,
@@ -161,6 +162,7 @@ function LangSmithMiddleware(config) {
161
162
  name: name ?? "ai.doStream",
162
163
  run_type: "llm",
163
164
  metadata: {
165
+ ls_integration: "vercel-ai-sdk",
164
166
  ls_model_name: modelId,
165
167
  ai_sdk_method: "ai.doStream",
166
168
  ...lsConfig?.metadata,
@@ -125,6 +125,7 @@ export function LangSmithMiddleware(config) {
125
125
  name: name ?? "ai.doGenerate",
126
126
  run_type: "llm",
127
127
  metadata: {
128
+ ls_integration: "vercel-ai-sdk",
128
129
  ls_model_name: modelId,
129
130
  ai_sdk_method: "ai.doGenerate",
130
131
  ...lsConfig?.metadata,
@@ -158,6 +159,7 @@ export function LangSmithMiddleware(config) {
158
159
  name: name ?? "ai.doStream",
159
160
  run_type: "llm",
160
161
  metadata: {
162
+ ls_integration: "vercel-ai-sdk",
161
163
  ls_model_name: modelId,
162
164
  ai_sdk_method: "ai.doStream",
163
165
  ...lsConfig?.metadata,
package/dist/index.cjs CHANGED
@@ -18,4 +18,4 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
18
18
  Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
19
19
  Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
20
20
  // Update using pnpm bump-version
21
- exports.__version__ = "0.5.16";
21
+ exports.__version__ = "0.5.18";
package/dist/index.d.ts CHANGED
@@ -5,4 +5,4 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
5
5
  export { getDefaultProjectName } from "./utils/project.js";
6
6
  export { uuid7, uuid7FromTime } from "./uuid.js";
7
7
  export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
8
- export declare const __version__ = "0.5.16";
8
+ export declare const __version__ = "0.5.18";
package/dist/index.js CHANGED
@@ -5,4 +5,4 @@ export { getDefaultProjectName } from "./utils/project.js";
5
5
  export { uuid7, uuid7FromTime } from "./uuid.js";
6
6
  export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
7
7
  // Update using pnpm bump-version
8
- export const __version__ = "0.5.16";
8
+ export const __version__ = "0.5.18";
package/dist/schemas.d.ts CHANGED
@@ -249,9 +249,6 @@ export interface RawExample extends BaseExample {
249
249
  }
250
250
  export interface ExampleUpdateWithId extends ExampleUpdate {
251
251
  }
252
- export interface ExampleSearch extends BaseExample {
253
- id: string;
254
- }
255
252
  export interface BaseDataset {
256
253
  name: string;
257
254
  description: string;
@@ -400,6 +397,7 @@ export interface PromptCommit {
400
397
  commit_hash: string;
401
398
  manifest: Record<string, any>;
402
399
  examples: Array<Record<any, any>>;
400
+ description?: string;
403
401
  }
404
402
  export interface Prompt {
405
403
  repo_handle: string;
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.supportsColorStderr = exports.supportsColor = exports.colors = exports.backgroundColors = exports.foregroundColors = exports.modifiers = exports.colorNames = exports.backgroundColorNames = exports.foregroundColorNames = exports.modifierNames = exports.chalkStderr = exports.Chalk = void 0;
7
+ /* eslint-disable */
8
+ // @ts-nocheck
9
+ const index_js_1 = __importDefault(require("./vendor/ansi-styles/index.cjs"));
10
+ const index_js_2 = __importDefault(require("./vendor/supports-color/index.cjs"));
11
+ const utilities_js_1 = require("./utilities.cjs");
12
+ const { stdout: stdoutColor, stderr: stderrColor } = index_js_2.default;
13
+ exports.supportsColor = stdoutColor;
14
+ exports.supportsColorStderr = stderrColor;
15
+ const GENERATOR = Symbol('GENERATOR');
16
+ const STYLER = Symbol('STYLER');
17
+ const IS_EMPTY = Symbol('IS_EMPTY');
18
+ // `supportsColor.level` → `ansiStyles.color[name]` mapping
19
+ const levelMapping = [
20
+ 'ansi',
21
+ 'ansi',
22
+ 'ansi256',
23
+ 'ansi16m',
24
+ ];
25
+ const styles = Object.create(null);
26
+ const applyOptions = (object, options = {}) => {
27
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
28
+ throw new Error('The `level` option should be an integer from 0 to 3');
29
+ }
30
+ // Detect level if not set manually
31
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
32
+ object.level = options.level === undefined ? colorLevel : options.level;
33
+ };
34
+ class Chalk {
35
+ constructor(options) {
36
+ // eslint-disable-next-line no-constructor-return
37
+ return chalkFactory(options);
38
+ }
39
+ }
40
+ exports.Chalk = Chalk;
41
+ const chalkFactory = options => {
42
+ const chalk = (...strings) => strings.join(' ');
43
+ applyOptions(chalk, options);
44
+ Object.setPrototypeOf(chalk, createChalk.prototype);
45
+ return chalk;
46
+ };
47
+ function createChalk(options) {
48
+ return chalkFactory(options);
49
+ }
50
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
51
+ for (const [styleName, style] of Object.entries(index_js_1.default)) {
52
+ styles[styleName] = {
53
+ get() {
54
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
55
+ Object.defineProperty(this, styleName, { value: builder });
56
+ return builder;
57
+ },
58
+ };
59
+ }
60
+ styles.visible = {
61
+ get() {
62
+ const builder = createBuilder(this, this[STYLER], true);
63
+ Object.defineProperty(this, 'visible', { value: builder });
64
+ return builder;
65
+ },
66
+ };
67
+ const getModelAnsi = (model, level, type, ...arguments_) => {
68
+ if (model === 'rgb') {
69
+ if (level === 'ansi16m') {
70
+ return index_js_1.default[type].ansi16m(...arguments_);
71
+ }
72
+ if (level === 'ansi256') {
73
+ return index_js_1.default[type].ansi256(index_js_1.default.rgbToAnsi256(...arguments_));
74
+ }
75
+ return index_js_1.default[type].ansi(index_js_1.default.rgbToAnsi(...arguments_));
76
+ }
77
+ if (model === 'hex') {
78
+ return getModelAnsi('rgb', level, type, ...index_js_1.default.hexToRgb(...arguments_));
79
+ }
80
+ return index_js_1.default[type][model](...arguments_);
81
+ };
82
+ const usedModels = ['rgb', 'hex', 'ansi256'];
83
+ for (const model of usedModels) {
84
+ styles[model] = {
85
+ get() {
86
+ const { level } = this;
87
+ return function (...arguments_) {
88
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), index_js_1.default.color.close, this[STYLER]);
89
+ return createBuilder(this, styler, this[IS_EMPTY]);
90
+ };
91
+ },
92
+ };
93
+ const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
94
+ styles[bgModel] = {
95
+ get() {
96
+ const { level } = this;
97
+ return function (...arguments_) {
98
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), index_js_1.default.bgColor.close, this[STYLER]);
99
+ return createBuilder(this, styler, this[IS_EMPTY]);
100
+ };
101
+ },
102
+ };
103
+ }
104
+ const proto = Object.defineProperties(() => { }, {
105
+ ...styles,
106
+ level: {
107
+ enumerable: true,
108
+ get() {
109
+ return this[GENERATOR].level;
110
+ },
111
+ set(level) {
112
+ this[GENERATOR].level = level;
113
+ },
114
+ },
115
+ });
116
+ const createStyler = (open, close, parent) => {
117
+ let openAll;
118
+ let closeAll;
119
+ if (parent === undefined) {
120
+ openAll = open;
121
+ closeAll = close;
122
+ }
123
+ else {
124
+ openAll = parent.openAll + open;
125
+ closeAll = close + parent.closeAll;
126
+ }
127
+ return {
128
+ open,
129
+ close,
130
+ openAll,
131
+ closeAll,
132
+ parent,
133
+ };
134
+ };
135
+ const createBuilder = (self, _styler, _isEmpty) => {
136
+ // Single argument is hot path, implicit coercion is faster than anything
137
+ // eslint-disable-next-line no-implicit-coercion
138
+ const builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
139
+ // We alter the prototype because we must return a function, but there is
140
+ // no way to create a function with a different prototype
141
+ Object.setPrototypeOf(builder, proto);
142
+ builder[GENERATOR] = self;
143
+ builder[STYLER] = _styler;
144
+ builder[IS_EMPTY] = _isEmpty;
145
+ return builder;
146
+ };
147
+ const applyStyle = (self, string) => {
148
+ if (self.level <= 0 || !string) {
149
+ return self[IS_EMPTY] ? '' : string;
150
+ }
151
+ let styler = self[STYLER];
152
+ if (styler === undefined) {
153
+ return string;
154
+ }
155
+ const { openAll, closeAll } = styler;
156
+ if (string.includes('\u001B')) {
157
+ while (styler !== undefined) {
158
+ // Replace any instances already present with a re-opening code
159
+ // otherwise only the part of the string until said closing code
160
+ // will be colored, and the rest will simply be 'plain'.
161
+ string = (0, utilities_js_1.stringReplaceAll)(string, styler.close, styler.open);
162
+ styler = styler.parent;
163
+ }
164
+ }
165
+ // We can move both next actions out of loop, because remaining actions in loop won't have
166
+ // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
167
+ // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
168
+ const lfIndex = string.indexOf('\n');
169
+ if (lfIndex !== -1) {
170
+ string = (0, utilities_js_1.stringEncaseCRLFWithFirstIndex)(string, closeAll, openAll, lfIndex);
171
+ }
172
+ return openAll + string + closeAll;
173
+ };
174
+ Object.defineProperties(createChalk.prototype, styles);
175
+ const chalk = createChalk();
176
+ exports.chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
177
+ var index_js_3 = require("./vendor/ansi-styles/index.cjs");
178
+ Object.defineProperty(exports, "modifierNames", { enumerable: true, get: function () { return index_js_3.modifierNames; } });
179
+ Object.defineProperty(exports, "foregroundColorNames", { enumerable: true, get: function () { return index_js_3.foregroundColorNames; } });
180
+ Object.defineProperty(exports, "backgroundColorNames", { enumerable: true, get: function () { return index_js_3.backgroundColorNames; } });
181
+ Object.defineProperty(exports, "colorNames", { enumerable: true, get: function () { return index_js_3.colorNames; } });
182
+ // TODO: Remove these aliases in the next major version
183
+ Object.defineProperty(exports, "modifiers", { enumerable: true, get: function () { return index_js_3.modifierNames; } });
184
+ Object.defineProperty(exports, "foregroundColors", { enumerable: true, get: function () { return index_js_3.foregroundColorNames; } });
185
+ Object.defineProperty(exports, "backgroundColors", { enumerable: true, get: function () { return index_js_3.backgroundColorNames; } });
186
+ Object.defineProperty(exports, "colors", { enumerable: true, get: function () { return index_js_3.colorNames; } });
187
+ exports.default = chalk;
@@ -0,0 +1,19 @@
1
+ declare const stdoutColor: boolean | {
2
+ level: any;
3
+ hasBasic: boolean;
4
+ has256: boolean;
5
+ has16m: boolean;
6
+ }, stderrColor: boolean | {
7
+ level: any;
8
+ hasBasic: boolean;
9
+ has256: boolean;
10
+ has16m: boolean;
11
+ };
12
+ export declare class Chalk {
13
+ constructor(options: any);
14
+ }
15
+ export declare const chalkStderr: (...strings: any[]) => string;
16
+ export { modifierNames, foregroundColorNames, backgroundColorNames, colorNames, modifierNames as modifiers, foregroundColorNames as foregroundColors, backgroundColorNames as backgroundColors, colorNames as colors, } from './vendor/ansi-styles/index.js';
17
+ export { stdoutColor as supportsColor, stderrColor as supportsColorStderr, };
18
+ declare const _default: any;
19
+ export default _default;
@@ -0,0 +1,173 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ import ansiStyles from './vendor/ansi-styles/index.js';
4
+ import supportsColor from './vendor/supports-color/index.js';
5
+ import { // eslint-disable-line import/order
6
+ stringReplaceAll, stringEncaseCRLFWithFirstIndex, } from './utilities.js';
7
+ const { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
8
+ const GENERATOR = Symbol('GENERATOR');
9
+ const STYLER = Symbol('STYLER');
10
+ const IS_EMPTY = Symbol('IS_EMPTY');
11
+ // `supportsColor.level` → `ansiStyles.color[name]` mapping
12
+ const levelMapping = [
13
+ 'ansi',
14
+ 'ansi',
15
+ 'ansi256',
16
+ 'ansi16m',
17
+ ];
18
+ const styles = Object.create(null);
19
+ const applyOptions = (object, options = {}) => {
20
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
21
+ throw new Error('The `level` option should be an integer from 0 to 3');
22
+ }
23
+ // Detect level if not set manually
24
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
25
+ object.level = options.level === undefined ? colorLevel : options.level;
26
+ };
27
+ export class Chalk {
28
+ constructor(options) {
29
+ // eslint-disable-next-line no-constructor-return
30
+ return chalkFactory(options);
31
+ }
32
+ }
33
+ const chalkFactory = options => {
34
+ const chalk = (...strings) => strings.join(' ');
35
+ applyOptions(chalk, options);
36
+ Object.setPrototypeOf(chalk, createChalk.prototype);
37
+ return chalk;
38
+ };
39
+ function createChalk(options) {
40
+ return chalkFactory(options);
41
+ }
42
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
43
+ for (const [styleName, style] of Object.entries(ansiStyles)) {
44
+ styles[styleName] = {
45
+ get() {
46
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
47
+ Object.defineProperty(this, styleName, { value: builder });
48
+ return builder;
49
+ },
50
+ };
51
+ }
52
+ styles.visible = {
53
+ get() {
54
+ const builder = createBuilder(this, this[STYLER], true);
55
+ Object.defineProperty(this, 'visible', { value: builder });
56
+ return builder;
57
+ },
58
+ };
59
+ const getModelAnsi = (model, level, type, ...arguments_) => {
60
+ if (model === 'rgb') {
61
+ if (level === 'ansi16m') {
62
+ return ansiStyles[type].ansi16m(...arguments_);
63
+ }
64
+ if (level === 'ansi256') {
65
+ return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
66
+ }
67
+ return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
68
+ }
69
+ if (model === 'hex') {
70
+ return getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));
71
+ }
72
+ return ansiStyles[type][model](...arguments_);
73
+ };
74
+ const usedModels = ['rgb', 'hex', 'ansi256'];
75
+ for (const model of usedModels) {
76
+ styles[model] = {
77
+ get() {
78
+ const { level } = this;
79
+ return function (...arguments_) {
80
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);
81
+ return createBuilder(this, styler, this[IS_EMPTY]);
82
+ };
83
+ },
84
+ };
85
+ const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
86
+ styles[bgModel] = {
87
+ get() {
88
+ const { level } = this;
89
+ return function (...arguments_) {
90
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
91
+ return createBuilder(this, styler, this[IS_EMPTY]);
92
+ };
93
+ },
94
+ };
95
+ }
96
+ const proto = Object.defineProperties(() => { }, {
97
+ ...styles,
98
+ level: {
99
+ enumerable: true,
100
+ get() {
101
+ return this[GENERATOR].level;
102
+ },
103
+ set(level) {
104
+ this[GENERATOR].level = level;
105
+ },
106
+ },
107
+ });
108
+ const createStyler = (open, close, parent) => {
109
+ let openAll;
110
+ let closeAll;
111
+ if (parent === undefined) {
112
+ openAll = open;
113
+ closeAll = close;
114
+ }
115
+ else {
116
+ openAll = parent.openAll + open;
117
+ closeAll = close + parent.closeAll;
118
+ }
119
+ return {
120
+ open,
121
+ close,
122
+ openAll,
123
+ closeAll,
124
+ parent,
125
+ };
126
+ };
127
+ const createBuilder = (self, _styler, _isEmpty) => {
128
+ // Single argument is hot path, implicit coercion is faster than anything
129
+ // eslint-disable-next-line no-implicit-coercion
130
+ const builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
131
+ // We alter the prototype because we must return a function, but there is
132
+ // no way to create a function with a different prototype
133
+ Object.setPrototypeOf(builder, proto);
134
+ builder[GENERATOR] = self;
135
+ builder[STYLER] = _styler;
136
+ builder[IS_EMPTY] = _isEmpty;
137
+ return builder;
138
+ };
139
+ const applyStyle = (self, string) => {
140
+ if (self.level <= 0 || !string) {
141
+ return self[IS_EMPTY] ? '' : string;
142
+ }
143
+ let styler = self[STYLER];
144
+ if (styler === undefined) {
145
+ return string;
146
+ }
147
+ const { openAll, closeAll } = styler;
148
+ if (string.includes('\u001B')) {
149
+ while (styler !== undefined) {
150
+ // Replace any instances already present with a re-opening code
151
+ // otherwise only the part of the string until said closing code
152
+ // will be colored, and the rest will simply be 'plain'.
153
+ string = stringReplaceAll(string, styler.close, styler.open);
154
+ styler = styler.parent;
155
+ }
156
+ }
157
+ // We can move both next actions out of loop, because remaining actions in loop won't have
158
+ // any/visible effect on parts we add here. Close the styling before a linebreak and reopen
159
+ // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
160
+ const lfIndex = string.indexOf('\n');
161
+ if (lfIndex !== -1) {
162
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
163
+ }
164
+ return openAll + string + closeAll;
165
+ };
166
+ Object.defineProperties(createChalk.prototype, styles);
167
+ const chalk = createChalk();
168
+ export const chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
169
+ export { modifierNames, foregroundColorNames, backgroundColorNames, colorNames,
170
+ // TODO: Remove these aliases in the next major version
171
+ modifierNames as modifiers, foregroundColorNames as foregroundColors, backgroundColorNames as backgroundColors, colorNames as colors, } from './vendor/ansi-styles/index.js';
172
+ export { stdoutColor as supportsColor, stderrColor as supportsColorStderr, };
173
+ export default chalk;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringReplaceAll = stringReplaceAll;
4
+ exports.stringEncaseCRLFWithFirstIndex = stringEncaseCRLFWithFirstIndex;
5
+ /* eslint-disable */
6
+ // @ts-nocheck
7
+ // TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
8
+ function stringReplaceAll(string, substring, replacer) {
9
+ let index = string.indexOf(substring);
10
+ if (index === -1) {
11
+ return string;
12
+ }
13
+ const substringLength = substring.length;
14
+ let endIndex = 0;
15
+ let returnValue = '';
16
+ do {
17
+ returnValue += string.slice(endIndex, index) + substring + replacer;
18
+ endIndex = index + substringLength;
19
+ index = string.indexOf(substring, endIndex);
20
+ } while (index !== -1);
21
+ returnValue += string.slice(endIndex);
22
+ return returnValue;
23
+ }
24
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
25
+ let endIndex = 0;
26
+ let returnValue = '';
27
+ do {
28
+ const gotCR = string[index - 1] === '\r';
29
+ returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
30
+ endIndex = index + 1;
31
+ index = string.indexOf('\n', endIndex);
32
+ } while (index !== -1);
33
+ returnValue += string.slice(endIndex);
34
+ return returnValue;
35
+ }
@@ -0,0 +1,2 @@
1
+ export declare function stringReplaceAll(string: any, substring: any, replacer: any): any;
2
+ export declare function stringEncaseCRLFWithFirstIndex(string: any, prefix: any, postfix: any, index: any): string;
@@ -0,0 +1,31 @@
1
+ /* eslint-disable */
2
+ // @ts-nocheck
3
+ // TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
4
+ export function stringReplaceAll(string, substring, replacer) {
5
+ let index = string.indexOf(substring);
6
+ if (index === -1) {
7
+ return string;
8
+ }
9
+ const substringLength = substring.length;
10
+ let endIndex = 0;
11
+ let returnValue = '';
12
+ do {
13
+ returnValue += string.slice(endIndex, index) + substring + replacer;
14
+ endIndex = index + substringLength;
15
+ index = string.indexOf(substring, endIndex);
16
+ } while (index !== -1);
17
+ returnValue += string.slice(endIndex);
18
+ return returnValue;
19
+ }
20
+ export function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
21
+ let endIndex = 0;
22
+ let returnValue = '';
23
+ do {
24
+ const gotCR = string[index - 1] === '\r';
25
+ returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
26
+ endIndex = index + 1;
27
+ index = string.indexOf('\n', endIndex);
28
+ } while (index !== -1);
29
+ returnValue += string.slice(endIndex);
30
+ return returnValue;
31
+ }