@fiction/sdk 1.0.1 → 1.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.
Files changed (38) hide show
  1. package/README.md +6 -221
  2. package/dist/api.d.ts +23 -0
  3. package/dist/base-CEr2lLFg.js +194 -0
  4. package/dist/base-CEr2lLFg.js.map +1 -0
  5. package/dist/index-C-0XxdQQ.js +299 -0
  6. package/dist/{index-iLB4ucpG.js.map → index-C-0XxdQQ.js.map} +1 -1
  7. package/dist/index.d.ts +7 -0
  8. package/dist/sdk.css +1 -1
  9. package/dist/sdk.js +2616 -3397
  10. package/dist/sdk.js.map +1 -1
  11. package/dist/sdkClient.d.ts +666 -0
  12. package/dist/sdkStorage.d.ts +27 -0
  13. package/dist/self/ClientAudio.d.ts +75 -0
  14. package/dist/self/SelfController.d.ts +68 -0
  15. package/dist/self/constants.d.ts +29 -0
  16. package/dist/self/index.d.ts +7 -0
  17. package/dist/self/schema.d.ts +28 -0
  18. package/dist/self/ui/ElAudioVisualizer.vue.d.ts +19 -0
  19. package/dist/self/ui/ElSelfAbout.vue.d.ts +6 -0
  20. package/dist/self/ui/ElSelfChat.vue.d.ts +8 -0
  21. package/dist/self/ui/ElSelfHeader.vue.d.ts +9 -0
  22. package/dist/self/ui/ElSelfSidebar.vue.d.ts +11 -0
  23. package/dist/self/ui/ElSelfVoice.vue.d.ts +6 -0
  24. package/dist/self/ui/SelfAgent.vue.d.ts +19 -0
  25. package/dist/self/ui/SelfProvider.vue.d.ts +12 -0
  26. package/dist/self/ui/SelfWrap.vue.d.ts +142 -0
  27. package/dist/self/utils.d.ts +18 -0
  28. package/dist/self.js +4874 -0
  29. package/dist/self.js.map +1 -0
  30. package/dist/types/SDKAppType.stub.d.ts +6 -0
  31. package/package.json +25 -26
  32. package/dist/base-CWJerwpW.js +0 -299
  33. package/dist/base-CWJerwpW.js.map +0 -1
  34. package/dist/index-iLB4ucpG.js +0 -402
  35. package/dist/sdk.d.ts +0 -460
  36. package/dist/ui.d.ts +0 -19
  37. package/dist/ui.js +0 -30388
  38. package/dist/ui.js.map +0 -1
@@ -1,402 +0,0 @@
1
- /*! @fiction/sdk v1.0.0 | (c) 2025 Fiction.com | MIT License */
2
- const ANSI_BACKGROUND_OFFSET = 10;
3
- const wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
4
- const wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
5
- const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
6
- const styles$1 = {
7
- modifier: {
8
- reset: [0, 0],
9
- // 21 isn't widely supported and 22 does the same thing
10
- bold: [1, 22],
11
- dim: [2, 22],
12
- italic: [3, 23],
13
- underline: [4, 24],
14
- overline: [53, 55],
15
- inverse: [7, 27],
16
- hidden: [8, 28],
17
- strikethrough: [9, 29]
18
- },
19
- color: {
20
- black: [30, 39],
21
- red: [31, 39],
22
- green: [32, 39],
23
- yellow: [33, 39],
24
- blue: [34, 39],
25
- magenta: [35, 39],
26
- cyan: [36, 39],
27
- white: [37, 39],
28
- // Bright color
29
- blackBright: [90, 39],
30
- gray: [90, 39],
31
- // Alias of `blackBright`
32
- grey: [90, 39],
33
- // Alias of `blackBright`
34
- redBright: [91, 39],
35
- greenBright: [92, 39],
36
- yellowBright: [93, 39],
37
- blueBright: [94, 39],
38
- magentaBright: [95, 39],
39
- cyanBright: [96, 39],
40
- whiteBright: [97, 39]
41
- },
42
- bgColor: {
43
- bgBlack: [40, 49],
44
- bgRed: [41, 49],
45
- bgGreen: [42, 49],
46
- bgYellow: [43, 49],
47
- bgBlue: [44, 49],
48
- bgMagenta: [45, 49],
49
- bgCyan: [46, 49],
50
- bgWhite: [47, 49],
51
- // Bright color
52
- bgBlackBright: [100, 49],
53
- bgGray: [100, 49],
54
- // Alias of `bgBlackBright`
55
- bgGrey: [100, 49],
56
- // Alias of `bgBlackBright`
57
- bgRedBright: [101, 49],
58
- bgGreenBright: [102, 49],
59
- bgYellowBright: [103, 49],
60
- bgBlueBright: [104, 49],
61
- bgMagentaBright: [105, 49],
62
- bgCyanBright: [106, 49],
63
- bgWhiteBright: [107, 49]
64
- }
65
- };
66
- const modifierNames = Object.keys(styles$1.modifier);
67
- const foregroundColorNames = Object.keys(styles$1.color);
68
- const backgroundColorNames = Object.keys(styles$1.bgColor);
69
- const colorNames = [...foregroundColorNames, ...backgroundColorNames];
70
- function assembleStyles() {
71
- const codes = /* @__PURE__ */ new Map();
72
- for (const [groupName, group] of Object.entries(styles$1)) {
73
- for (const [styleName, style] of Object.entries(group)) {
74
- styles$1[styleName] = {
75
- open: `\x1B[${style[0]}m`,
76
- close: `\x1B[${style[1]}m`
77
- };
78
- group[styleName] = styles$1[styleName];
79
- codes.set(style[0], style[1]);
80
- }
81
- Object.defineProperty(styles$1, groupName, {
82
- value: group,
83
- enumerable: false
84
- });
85
- }
86
- Object.defineProperty(styles$1, "codes", {
87
- value: codes,
88
- enumerable: false
89
- });
90
- styles$1.color.close = "\x1B[39m";
91
- styles$1.bgColor.close = "\x1B[49m";
92
- styles$1.color.ansi = wrapAnsi16();
93
- styles$1.color.ansi256 = wrapAnsi256();
94
- styles$1.color.ansi16m = wrapAnsi16m();
95
- styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
96
- styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
97
- styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
98
- Object.defineProperties(styles$1, {
99
- rgbToAnsi256: {
100
- value(red, green, blue) {
101
- if (red === green && green === blue) {
102
- if (red < 8) {
103
- return 16;
104
- }
105
- if (red > 248) {
106
- return 231;
107
- }
108
- return Math.round((red - 8) / 247 * 24) + 232;
109
- }
110
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
111
- },
112
- enumerable: false
113
- },
114
- hexToRgb: {
115
- value(hex) {
116
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
117
- if (!matches) {
118
- return [0, 0, 0];
119
- }
120
- let [colorString] = matches;
121
- if (colorString.length === 3) {
122
- colorString = [...colorString].map((character) => character + character).join("");
123
- }
124
- const integer = Number.parseInt(colorString, 16);
125
- return [
126
- /* eslint-disable no-bitwise */
127
- integer >> 16 & 255,
128
- integer >> 8 & 255,
129
- integer & 255
130
- /* eslint-enable no-bitwise */
131
- ];
132
- },
133
- enumerable: false
134
- },
135
- hexToAnsi256: {
136
- value: (hex) => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
137
- enumerable: false
138
- },
139
- ansi256ToAnsi: {
140
- value(code) {
141
- if (code < 8) {
142
- return 30 + code;
143
- }
144
- if (code < 16) {
145
- return 90 + (code - 8);
146
- }
147
- let red;
148
- let green;
149
- let blue;
150
- if (code >= 232) {
151
- red = ((code - 232) * 10 + 8) / 255;
152
- green = red;
153
- blue = red;
154
- } else {
155
- code -= 16;
156
- const remainder = code % 36;
157
- red = Math.floor(code / 36) / 5;
158
- green = Math.floor(remainder / 6) / 5;
159
- blue = remainder % 6 / 5;
160
- }
161
- const value = Math.max(red, green, blue) * 2;
162
- if (value === 0) {
163
- return 30;
164
- }
165
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
166
- if (value === 2) {
167
- result += 60;
168
- }
169
- return result;
170
- },
171
- enumerable: false
172
- },
173
- rgbToAnsi: {
174
- value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
175
- enumerable: false
176
- },
177
- hexToAnsi: {
178
- value: (hex) => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
179
- enumerable: false
180
- }
181
- });
182
- return styles$1;
183
- }
184
- const ansiStyles = assembleStyles();
185
- const level = (() => {
186
- if (!("navigator" in globalThis)) {
187
- return 0;
188
- }
189
- if (globalThis.navigator.userAgentData) {
190
- const brand = navigator.userAgentData.brands.find(({ brand: brand2 }) => brand2 === "Chromium");
191
- if (brand && brand.version > 93) {
192
- return 3;
193
- }
194
- }
195
- if (/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)) {
196
- return 1;
197
- }
198
- return 0;
199
- })();
200
- const colorSupport = level !== 0 && {
201
- level,
202
- hasBasic: true,
203
- has256: level >= 2,
204
- has16m: level >= 3
205
- };
206
- const supportsColor = {
207
- stdout: colorSupport,
208
- stderr: colorSupport
209
- };
210
- function stringReplaceAll(string, substring, replacer) {
211
- let index = string.indexOf(substring);
212
- if (index === -1) {
213
- return string;
214
- }
215
- const substringLength = substring.length;
216
- let endIndex = 0;
217
- let returnValue = "";
218
- do {
219
- returnValue += string.slice(endIndex, index) + substring + replacer;
220
- endIndex = index + substringLength;
221
- index = string.indexOf(substring, endIndex);
222
- } while (index !== -1);
223
- returnValue += string.slice(endIndex);
224
- return returnValue;
225
- }
226
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
227
- let endIndex = 0;
228
- let returnValue = "";
229
- do {
230
- const gotCR = string[index - 1] === "\r";
231
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
232
- endIndex = index + 1;
233
- index = string.indexOf("\n", endIndex);
234
- } while (index !== -1);
235
- returnValue += string.slice(endIndex);
236
- return returnValue;
237
- }
238
- const { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
239
- const GENERATOR = Symbol("GENERATOR");
240
- const STYLER = Symbol("STYLER");
241
- const IS_EMPTY = Symbol("IS_EMPTY");
242
- const levelMapping = [
243
- "ansi",
244
- "ansi",
245
- "ansi256",
246
- "ansi16m"
247
- ];
248
- const styles = /* @__PURE__ */ Object.create(null);
249
- const applyOptions = (object, options = {}) => {
250
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
251
- throw new Error("The `level` option should be an integer from 0 to 3");
252
- }
253
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
254
- object.level = options.level === void 0 ? colorLevel : options.level;
255
- };
256
- class Chalk {
257
- constructor(options) {
258
- return chalkFactory(options);
259
- }
260
- }
261
- const chalkFactory = (options) => {
262
- const chalk2 = (...strings) => strings.join(" ");
263
- applyOptions(chalk2, options);
264
- Object.setPrototypeOf(chalk2, createChalk.prototype);
265
- return chalk2;
266
- };
267
- function createChalk(options) {
268
- return chalkFactory(options);
269
- }
270
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
271
- for (const [styleName, style] of Object.entries(ansiStyles)) {
272
- styles[styleName] = {
273
- get() {
274
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
275
- Object.defineProperty(this, styleName, { value: builder });
276
- return builder;
277
- }
278
- };
279
- }
280
- styles.visible = {
281
- get() {
282
- const builder = createBuilder(this, this[STYLER], true);
283
- Object.defineProperty(this, "visible", { value: builder });
284
- return builder;
285
- }
286
- };
287
- const getModelAnsi = (model, level2, type, ...arguments_) => {
288
- if (model === "rgb") {
289
- if (level2 === "ansi16m") {
290
- return ansiStyles[type].ansi16m(...arguments_);
291
- }
292
- if (level2 === "ansi256") {
293
- return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
294
- }
295
- return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
296
- }
297
- if (model === "hex") {
298
- return getModelAnsi("rgb", level2, type, ...ansiStyles.hexToRgb(...arguments_));
299
- }
300
- return ansiStyles[type][model](...arguments_);
301
- };
302
- const usedModels = ["rgb", "hex", "ansi256"];
303
- for (const model of usedModels) {
304
- styles[model] = {
305
- get() {
306
- const { level: level2 } = this;
307
- return function(...arguments_) {
308
- const styler = createStyler(getModelAnsi(model, levelMapping[level2], "color", ...arguments_), ansiStyles.color.close, this[STYLER]);
309
- return createBuilder(this, styler, this[IS_EMPTY]);
310
- };
311
- }
312
- };
313
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
314
- styles[bgModel] = {
315
- get() {
316
- const { level: level2 } = this;
317
- return function(...arguments_) {
318
- const styler = createStyler(getModelAnsi(model, levelMapping[level2], "bgColor", ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
319
- return createBuilder(this, styler, this[IS_EMPTY]);
320
- };
321
- }
322
- };
323
- }
324
- const proto = Object.defineProperties(() => {
325
- }, {
326
- ...styles,
327
- level: {
328
- enumerable: true,
329
- get() {
330
- return this[GENERATOR].level;
331
- },
332
- set(level2) {
333
- this[GENERATOR].level = level2;
334
- }
335
- }
336
- });
337
- const createStyler = (open, close, parent) => {
338
- let openAll;
339
- let closeAll;
340
- if (parent === void 0) {
341
- openAll = open;
342
- closeAll = close;
343
- } else {
344
- openAll = parent.openAll + open;
345
- closeAll = close + parent.closeAll;
346
- }
347
- return {
348
- open,
349
- close,
350
- openAll,
351
- closeAll,
352
- parent
353
- };
354
- };
355
- const createBuilder = (self, _styler, _isEmpty) => {
356
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
357
- Object.setPrototypeOf(builder, proto);
358
- builder[GENERATOR] = self;
359
- builder[STYLER] = _styler;
360
- builder[IS_EMPTY] = _isEmpty;
361
- return builder;
362
- };
363
- const applyStyle = (self, string) => {
364
- if (self.level <= 0 || !string) {
365
- return self[IS_EMPTY] ? "" : string;
366
- }
367
- let styler = self[STYLER];
368
- if (styler === void 0) {
369
- return string;
370
- }
371
- const { openAll, closeAll } = styler;
372
- if (string.includes("\x1B")) {
373
- while (styler !== void 0) {
374
- string = stringReplaceAll(string, styler.close, styler.open);
375
- styler = styler.parent;
376
- }
377
- }
378
- const lfIndex = string.indexOf("\n");
379
- if (lfIndex !== -1) {
380
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
381
- }
382
- return openAll + string + closeAll;
383
- };
384
- Object.defineProperties(createChalk.prototype, styles);
385
- const chalk = createChalk();
386
- const chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
387
- export {
388
- Chalk,
389
- backgroundColorNames,
390
- backgroundColorNames as backgroundColors,
391
- chalkStderr,
392
- colorNames,
393
- colorNames as colors,
394
- chalk as default,
395
- foregroundColorNames,
396
- foregroundColorNames as foregroundColors,
397
- modifierNames,
398
- modifierNames as modifiers,
399
- stdoutColor as supportsColor,
400
- stderrColor as supportsColorStderr
401
- };
402
- //# sourceMappingURL=index-iLB4ucpG.js.map