codebuff 1.0.282 → 1.0.283

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 (35) hide show
  1. package/dist/client.d.ts +3 -3
  2. package/dist/client.js +5 -0
  3. package/dist/client.js.map +1 -1
  4. package/dist/code-map/parse.d.ts.map +1 -1
  5. package/dist/code-map/parse.js.map +1 -1
  6. package/dist/code-map/tsconfig.tsbuildinfo +1 -1
  7. package/dist/common/actions.d.ts +84 -84
  8. package/dist/common/constants/analytics-events.d.ts +2 -1
  9. package/dist/common/constants/analytics-events.js +2 -1
  10. package/dist/common/constants/analytics-events.js.map +1 -1
  11. package/dist/common/constants/tools.d.ts +1 -0
  12. package/dist/common/constants/tools.js +1 -0
  13. package/dist/common/constants/tools.js.map +1 -1
  14. package/dist/common/db/schema.d.ts +4 -4
  15. package/dist/common/types/grant.d.ts +1 -1
  16. package/dist/common/types/grant.js.map +1 -1
  17. package/dist/common/types/usage.d.ts +7 -7
  18. package/dist/common/types/usage.js +2 -1
  19. package/dist/common/types/usage.js.map +1 -1
  20. package/dist/common/util/__tests__/saxy.test.js +182 -48
  21. package/dist/common/util/__tests__/saxy.test.js.map +1 -1
  22. package/dist/common/util/saxy.d.ts +0 -1
  23. package/dist/common/util/saxy.js +3 -15
  24. package/dist/common/util/saxy.js.map +1 -1
  25. package/dist/common/websockets/websocket-schema.d.ts +146 -146
  26. package/dist/display.js.map +1 -1
  27. package/dist/tool-handlers.js +1 -0
  28. package/dist/tool-handlers.js.map +1 -1
  29. package/dist/utils/__tests__/tool-renderers.test.js +4 -6
  30. package/dist/utils/__tests__/tool-renderers.test.js.map +1 -1
  31. package/dist/utils/terminal.js +1 -1
  32. package/dist/utils/terminal.js.map +1 -1
  33. package/dist/utils/tool-renderers.js +3 -0
  34. package/dist/utils/tool-renderers.js.map +1 -1
  35. package/package.json +1 -1
@@ -12,7 +12,8 @@ export declare enum AnalyticsEvent {
12
12
  LOGIN = "cli.login",
13
13
  TERMINAL_COMMAND_COMPLETED = "cli.terminal_command_completed",
14
14
  MALFORMED_PROMPT_RESPONSE = "cli.malformed_prompt_response",
15
- PROMPT_SENT = "backend.prompt_sent",
15
+ USER_INPUT = "backend.user_input",
16
+ AGENT_STEP = "backend.agent_step",
16
17
  CREDIT_GRANT = "backend.credit_grant",
17
18
  CREDIT_CONSUMED = "backend.credit_consumed",
18
19
  TOOL_USE = "backend.tool_use",
@@ -18,7 +18,8 @@ var AnalyticsEvent;
18
18
  AnalyticsEvent["TERMINAL_COMMAND_COMPLETED"] = "cli.terminal_command_completed";
19
19
  AnalyticsEvent["MALFORMED_PROMPT_RESPONSE"] = "cli.malformed_prompt_response";
20
20
  // Backend
21
- AnalyticsEvent["PROMPT_SENT"] = "backend.prompt_sent";
21
+ AnalyticsEvent["USER_INPUT"] = "backend.user_input";
22
+ AnalyticsEvent["AGENT_STEP"] = "backend.agent_step";
22
23
  AnalyticsEvent["CREDIT_GRANT"] = "backend.credit_grant";
23
24
  AnalyticsEvent["CREDIT_CONSUMED"] = "backend.credit_consumed";
24
25
  AnalyticsEvent["TOOL_USE"] = "backend.tool_use";
@@ -1 +1 @@
1
- {"version":3,"file":"analytics-events.js","sourceRoot":"","sources":["../../src/constants/analytics-events.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,cAqBX;AArBD,WAAY,cAAc;IACxB,MAAM;IACN,mDAAiC,CAAA;IACjC,iFAA+D,CAAA;IAC/D,uEAAqD,CAAA;IACrD,mGAAiF,CAAA;IACjF,2EAAyD,CAAA;IACzD,2DAAyC,CAAA;IACzC,yEAAuD,CAAA;IACvD,qCAAmB,CAAA;IACnB,+EAA6D,CAAA;IAC7D,6EAA2D,CAAA;IAE3D,UAAU;IACV,qDAAmC,CAAA;IACnC,uDAAqC,CAAA;IACrC,6DAA2C,CAAA;IAC3C,+CAA6B,CAAA;IAE7B,MAAM;IACN,uCAAqB,CAAA;AACvB,CAAC,EArBW,cAAc,8BAAd,cAAc,QAqBzB"}
1
+ {"version":3,"file":"analytics-events.js","sourceRoot":"","sources":["../../src/constants/analytics-events.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,cAsBX;AAtBD,WAAY,cAAc;IACxB,MAAM;IACN,mDAAiC,CAAA;IACjC,iFAA+D,CAAA;IAC/D,uEAAqD,CAAA;IACrD,mGAAiF,CAAA;IACjF,2EAAyD,CAAA;IACzD,2DAAyC,CAAA;IACzC,yEAAuD,CAAA;IACvD,qCAAmB,CAAA;IACnB,+EAA6D,CAAA;IAC7D,6EAA2D,CAAA;IAE3D,UAAU;IACV,mDAAiC,CAAA;IACjC,mDAAiC,CAAA;IACjC,uDAAqC,CAAA;IACrC,6DAA2C,CAAA;IAC3C,+CAA6B,CAAA;IAE7B,MAAM;IACN,uCAAqB,CAAA;AACvB,CAAC,EAtBW,cAAc,8BAAd,cAAc,QAsBzB"}
@@ -10,6 +10,7 @@ export declare const toolSchema: {
10
10
  think_deeply: string[];
11
11
  create_plan: string[];
12
12
  browser_logs: string[];
13
+ end_turn: never[];
13
14
  };
14
15
  export type ToolName = keyof typeof toolSchema;
15
16
  export declare const TOOL_LIST: ToolName[];
@@ -17,6 +17,7 @@ exports.toolSchema = {
17
17
  think_deeply: ['thought'],
18
18
  create_plan: ['path', 'plan'],
19
19
  browser_logs: ['type', 'url', 'waitUntil'],
20
+ end_turn: [],
20
21
  };
21
22
  // List of all available tools
22
23
  exports.TOOL_LIST = Object.keys(exports.toolSchema);
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/constants/tools.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG;IACxB,yCAAyC;IACzC,WAAW,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC;IACzD,cAAc,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC;IAE/C,kBAAkB;IAClB,UAAU,EAAE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declare const ReferralStatus: import("drizzle-orm/pg-core").PgEnum<[import("../types/referral").ReferralStatus, ...import("../types/referral").ReferralStatus[]]>;
2
2
  export declare const apiKeyTypeEnum: import("drizzle-orm/pg-core").PgEnum<["anthropic", "gemini", "openai"]>;
3
- export declare const grantTypeEnum: import("drizzle-orm/pg-core").PgEnum<[import("../types/grant").GrantType, ...import("../types/grant").GrantType[]]>;
3
+ export declare const grantTypeEnum: import("drizzle-orm/pg-core").PgEnum<["free", ...("free" | "referral" | "purchase" | "admin")[]]>;
4
4
  export type GrantType = (typeof grantTypeEnum.enumValues)[number];
5
5
  export declare const user: import("drizzle-orm/pg-core").PgTableWithColumns<{
6
6
  name: "user";
@@ -569,14 +569,14 @@ export declare const creditLedger: import("drizzle-orm/pg-core").PgTableWithColu
569
569
  tableName: "credit_ledger";
570
570
  dataType: "string";
571
571
  columnType: "PgEnumColumn";
572
- data: import("../types/grant").GrantType;
572
+ data: "free" | "referral" | "purchase" | "admin";
573
573
  driverParam: string;
574
574
  notNull: true;
575
575
  hasDefault: false;
576
576
  isPrimaryKey: false;
577
577
  isAutoincrement: false;
578
578
  hasRuntimeDefault: false;
579
- enumValues: [import("../types/grant").GrantType, ...import("../types/grant").GrantType[]];
579
+ enumValues: ["free", ...("free" | "referral" | "purchase" | "admin")[]];
580
580
  baseColumn: never;
581
581
  identity: undefined;
582
582
  generated: undefined;
@@ -1385,7 +1385,7 @@ export declare const encryptedApiKeys: import("drizzle-orm/pg-core").PgTableWith
1385
1385
  tableName: "encrypted_api_keys";
1386
1386
  dataType: "string";
1387
1387
  columnType: "PgEnumColumn";
1388
- data: "gemini" | "anthropic" | "openai";
1388
+ data: "anthropic" | "gemini" | "openai";
1389
1389
  driverParam: string;
1390
1390
  notNull: true;
1391
1391
  hasDefault: false;
@@ -1,2 +1,2 @@
1
1
  export type GrantType = 'free' | 'referral' | 'purchase' | 'admin';
2
- export declare const GrantTypeValues: GrantType[];
2
+ export declare const GrantTypeValues: readonly ["free", "referral", "purchase", "admin"];
@@ -1 +1 @@
1
- {"version":3,"file":"grant.js","sourceRoot":"","sources":["../../src/types/grant.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAgB;IAC1C,MAAM;IACN,UAAU;IACV,UAAU;IACV,OAAO;CACR,CAAA"}
1
+ {"version":3,"file":"grant.js","sourceRoot":"","sources":["../../src/types/grant.ts"],"names":[],"mappings":";;;AAEa,QAAA,eAAe,GAAG;IAC7B,MAAM;IACN,UAAU;IACV,UAAU;IACV,OAAO;CACC,CAAC"}
@@ -5,36 +5,36 @@ export declare const usageDataSchema: z.ZodObject<{
5
5
  totalRemaining: z.ZodNumber;
6
6
  totalDebt: z.ZodNumber;
7
7
  netBalance: z.ZodNumber;
8
- breakdown: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
8
+ breakdown: z.ZodRecord<z.ZodEnum<["free", "referral", "purchase", "admin"]>, z.ZodNumber>;
9
9
  }, "strip", z.ZodTypeAny, {
10
10
  totalRemaining: number;
11
11
  totalDebt: number;
12
12
  netBalance: number;
13
- breakdown?: Record<string, number> | undefined;
13
+ breakdown: Partial<Record<"free" | "referral" | "purchase" | "admin", number>>;
14
14
  }, {
15
15
  totalRemaining: number;
16
16
  totalDebt: number;
17
17
  netBalance: number;
18
- breakdown?: Record<string, number> | undefined;
18
+ breakdown: Partial<Record<"free" | "referral" | "purchase" | "admin", number>>;
19
19
  }>;
20
20
  nextQuotaReset: z.ZodNullable<z.ZodDate>;
21
21
  }, "strip", z.ZodTypeAny, {
22
+ usageThisCycle: number;
22
23
  balance: {
23
24
  totalRemaining: number;
24
25
  totalDebt: number;
25
26
  netBalance: number;
26
- breakdown?: Record<string, number> | undefined;
27
+ breakdown: Partial<Record<"free" | "referral" | "purchase" | "admin", number>>;
27
28
  };
28
- usageThisCycle: number;
29
29
  nextQuotaReset: Date | null;
30
30
  }, {
31
+ usageThisCycle: number;
31
32
  balance: {
32
33
  totalRemaining: number;
33
34
  totalDebt: number;
34
35
  netBalance: number;
35
- breakdown?: Record<string, number> | undefined;
36
+ breakdown: Partial<Record<"free" | "referral" | "purchase" | "admin", number>>;
36
37
  };
37
- usageThisCycle: number;
38
38
  nextQuotaReset: Date | null;
39
39
  }>;
40
40
  export type UsageData = z.infer<typeof usageDataSchema>;
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.usageDataSchema = void 0;
4
4
  const zod_1 = require("zod");
5
+ const grant_1 = require("./grant");
5
6
  exports.usageDataSchema = zod_1.z.object({
6
7
  usageThisCycle: zod_1.z.number(),
7
8
  balance: zod_1.z.object({
8
9
  totalRemaining: zod_1.z.number(),
9
10
  totalDebt: zod_1.z.number(),
10
11
  netBalance: zod_1.z.number(),
11
- breakdown: zod_1.z.record(zod_1.z.string(), zod_1.z.number()).optional(),
12
+ breakdown: zod_1.z.record(zod_1.z.enum(grant_1.GrantTypeValues), zod_1.z.number()),
12
13
  }),
13
14
  nextQuotaReset: zod_1.z.coerce.date().nullable(),
14
15
  });
@@ -1 +1 @@
1
- {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/types/usage.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AAGV,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE;IAC1B,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE;QAC1B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;QACrB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;QACtB,SAAS,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;KACvD,CAAC;IACF,cAAc,EAAE,OAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAA"}
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/types/usage.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,mCAAyC;AAE5B,QAAA,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IACtC,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE;IAC1B,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QAChB,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE;QAC1B,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;QACrB,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;QACtB,SAAS,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,IAAI,CAAC,uBAAe,CAAC,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC;KACzD,CAAC;IACF,cAAc,EAAE,OAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAA"}
@@ -67,32 +67,42 @@ const saxy_1 = require("../saxy");
67
67
  const events = processXML(xml, schema);
68
68
  (0, bun_test_1.expect)(events).toEqual([
69
69
  {
70
- type: 'tagopen',
71
70
  data: {
72
71
  attrs: '',
73
72
  isSelfClosing: false,
74
73
  name: 'root',
74
+ rawTag: '<root>',
75
75
  },
76
+ type: 'tagopen',
76
77
  },
77
78
  {
78
- type: 'tagopen',
79
79
  data: {
80
80
  attrs: '',
81
81
  isSelfClosing: false,
82
82
  name: 'child',
83
+ rawTag: '<child>',
83
84
  },
85
+ type: 'tagopen',
84
86
  },
85
87
  {
88
+ data: {
89
+ contents: 'content',
90
+ },
86
91
  type: 'text',
87
- data: { contents: 'content' },
88
92
  },
89
93
  {
94
+ data: {
95
+ name: 'child',
96
+ rawTag: '</child>',
97
+ },
90
98
  type: 'tagclose',
91
- data: { name: 'child' },
92
99
  },
93
100
  {
101
+ data: {
102
+ name: 'root',
103
+ rawTag: '</root>',
104
+ },
94
105
  type: 'tagclose',
95
- data: { name: 'root' },
96
106
  },
97
107
  ]);
98
108
  });
@@ -182,23 +192,27 @@ const saxy_1 = require("../saxy");
182
192
  parser.end();
183
193
  (0, bun_test_1.expect)(events).toEqual([
184
194
  {
185
- type: 'text',
186
195
  data: {
187
196
  contents: 'This is < not a tag> and < another not a tag> but ',
188
197
  },
198
+ type: 'text',
189
199
  },
190
200
  {
201
+ data: {
202
+ attrs: '',
203
+ isSelfClosing: false,
204
+ name: 'valid',
205
+ rawTag: '<valid>',
206
+ },
191
207
  type: 'tagopen',
192
- data: { name: 'valid', isSelfClosing: false, attrs: '' },
193
208
  },
194
209
  {
210
+ data: {
211
+ contents: 'this is',
212
+ },
195
213
  type: 'text',
196
- data: { contents: 'this is' },
197
- },
198
- {
199
- type: 'tagclose',
200
- data: { name: 'valid' },
201
214
  },
215
+ { data: { name: 'valid', rawTag: '</valid>' }, type: 'tagclose' },
202
216
  ]);
203
217
  });
204
218
  (0, bun_test_1.it)('should handle text with angle brackets but no valid tag names', () => {
@@ -224,24 +238,38 @@ const saxy_1 = require("../saxy");
224
238
  parser.end();
225
239
  (0, bun_test_1.expect)(events).toEqual([
226
240
  {
241
+ data: {
242
+ contents: 'Text with < brackets> and ',
243
+ },
227
244
  type: 'text',
228
- data: { contents: 'Text with < brackets> and ' },
229
245
  },
230
246
  {
247
+ data: {
248
+ attrs: '',
249
+ isSelfClosing: false,
250
+ name: 'valid-tag',
251
+ rawTag: '<valid-tag>',
252
+ },
231
253
  type: 'tagopen',
232
- data: { name: 'valid-tag', isSelfClosing: false, attrs: '' },
233
254
  },
234
255
  {
256
+ data: {
257
+ contents: 'real XML',
258
+ },
235
259
  type: 'text',
236
- data: { contents: 'real XML' },
237
260
  },
238
261
  {
262
+ data: {
263
+ name: 'valid-tag',
264
+ rawTag: '</valid-tag>',
265
+ },
239
266
  type: 'tagclose',
240
- data: { name: 'valid-tag' },
241
267
  },
242
268
  {
269
+ data: {
270
+ contents: ' mixed together',
271
+ },
243
272
  type: 'text',
244
- data: { contents: ' mixed together' },
245
273
  },
246
274
  ]);
247
275
  });
@@ -285,7 +313,7 @@ const saxy_1 = require("../saxy");
285
313
  },
286
314
  ]);
287
315
  });
288
- (0, bun_test_1.it)('should handle split HTML entities in text content', () => {
316
+ (0, bun_test_1.it)('should handle split XML entities in text content', () => {
289
317
  // Re-initialize parser and events array inside the test
290
318
  const parser = new saxy_1.Saxy();
291
319
  const events = [];
@@ -296,11 +324,36 @@ const saxy_1 = require("../saxy");
296
324
  parser.write('t; entities &g');
297
325
  parser.end();
298
326
  (0, bun_test_1.expect)(events).toEqual([
299
- { type: 'text', data: { contents: 'Text with ' } },
300
- { type: 'text', data: { contents: '& and' } },
301
- { type: 'text', data: { contents: ' ' } },
302
- { type: 'text', data: { contents: '< entities ' } },
303
- { type: 'text', data: { contents: '&g' } },
327
+ {
328
+ data: {
329
+ contents: 'Text with ',
330
+ },
331
+ type: 'text',
332
+ },
333
+ {
334
+ data: {
335
+ contents: '& and',
336
+ },
337
+ type: 'text',
338
+ },
339
+ {
340
+ data: {
341
+ contents: ' ',
342
+ },
343
+ type: 'text',
344
+ },
345
+ {
346
+ data: {
347
+ contents: '< entities ',
348
+ },
349
+ type: 'text',
350
+ },
351
+ {
352
+ data: {
353
+ contents: '&g',
354
+ },
355
+ type: 'text',
356
+ },
304
357
  ]);
305
358
  (0, bun_test_1.expect)(events.map((chunk) => chunk.data.contents).join('')).toEqual('Text with & and < entities &g');
306
359
  });
@@ -310,36 +363,58 @@ const saxy_1 = require("../saxy");
310
363
  parser.on('text', (data) => events.push({ type: 'text', data }));
311
364
  parser.on('tagopen', (data) => events.push({ type: 'tagopen', data }));
312
365
  parser.on('tagclose', (data) => events.push({ type: 'tagclose', data }));
313
- parser.write('<root> <child> text </child> </root>');
366
+ parser.write('<root> text <child> text </child> text </root>');
314
367
  parser.end();
315
368
  (0, bun_test_1.expect)(events).toEqual([
316
369
  {
370
+ data: {
371
+ attrs: '',
372
+ isSelfClosing: false,
373
+ name: 'root',
374
+ rawTag: '<root>',
375
+ },
317
376
  type: 'tagopen',
318
- data: { name: 'root', isSelfClosing: false, attrs: '' },
319
377
  },
320
378
  {
379
+ data: {
380
+ contents: ' text ',
381
+ },
321
382
  type: 'text',
322
- data: { contents: ' ' },
323
383
  },
324
384
  {
385
+ data: {
386
+ attrs: '',
387
+ isSelfClosing: false,
388
+ name: 'child',
389
+ rawTag: '<child>',
390
+ },
325
391
  type: 'tagopen',
326
- data: { name: 'child', isSelfClosing: false, attrs: '' },
327
392
  },
328
393
  {
394
+ data: {
395
+ contents: ' text ',
396
+ },
329
397
  type: 'text',
330
- data: { contents: ' text ' },
331
398
  },
332
399
  {
400
+ data: {
401
+ name: 'child',
402
+ rawTag: '</child>',
403
+ },
333
404
  type: 'tagclose',
334
- data: { name: 'child' },
335
405
  },
336
406
  {
407
+ data: {
408
+ contents: ' text ',
409
+ },
337
410
  type: 'text',
338
- data: { contents: ' ' },
339
411
  },
340
412
  {
413
+ data: {
414
+ name: 'root',
415
+ rawTag: '</root>',
416
+ },
341
417
  type: 'tagclose',
342
- data: { name: 'root' },
343
418
  },
344
419
  ]);
345
420
  });
@@ -383,12 +458,33 @@ const saxy_1 = require("../saxy");
383
458
  // reconstruct the original text correctly
384
459
  (0, bun_test_1.expect)(events).toEqual([
385
460
  {
461
+ data: {
462
+ attrs: '',
463
+ isSelfClosing: false,
464
+ name: 'tag',
465
+ rawTag: '<tag>',
466
+ },
386
467
  type: 'tagopen',
387
- data: { name: 'tag', isSelfClosing: false, attrs: '' },
388
468
  },
389
- { type: 'text', data: { contents: 'before ' } },
390
- { type: 'text', data: { contents: '& after' } },
391
- { type: 'tagclose', data: { name: 'tag' } },
469
+ {
470
+ data: {
471
+ contents: 'before ',
472
+ },
473
+ type: 'text',
474
+ },
475
+ {
476
+ data: {
477
+ contents: '& after',
478
+ },
479
+ type: 'text',
480
+ },
481
+ {
482
+ data: {
483
+ name: 'tag',
484
+ rawTag: '</tag>',
485
+ },
486
+ type: 'tagclose',
487
+ },
392
488
  ]);
393
489
  // The text content should be properly reconstructed
394
490
  const textContent = events
@@ -424,17 +520,32 @@ const saxy_1 = require("../saxy");
424
520
  // The & should be treated as literal text and stay with its surrounding content
425
521
  (0, bun_test_1.expect)(events).toEqual([
426
522
  {
523
+ data: {
524
+ attrs: '',
525
+ isSelfClosing: false,
526
+ name: 'tag',
527
+ rawTag: '<tag>',
528
+ },
427
529
  type: 'tagopen',
428
- data: { name: 'tag', isSelfClosing: false, attrs: '' },
429
530
  },
430
531
  {
532
+ data: {
533
+ contents: 'before ',
534
+ },
431
535
  type: 'text',
432
- data: { contents: 'before ' },
433
536
  },
434
- { type: 'text', data: { contents: '& after' } },
435
537
  {
538
+ data: {
539
+ contents: '& after',
540
+ },
541
+ type: 'text',
542
+ },
543
+ {
544
+ data: {
545
+ name: 'tag',
546
+ rawTag: '</tag>',
547
+ },
436
548
  type: 'tagclose',
437
- data: { name: 'tag' },
438
549
  },
439
550
  ]);
440
551
  // The text content should be properly reconstructed
@@ -478,20 +589,32 @@ const saxy_1 = require("../saxy");
478
589
  // The text content should be emitted in two chunks due to the new immediate emission behavior
479
590
  (0, bun_test_1.expect)(events).toEqual([
480
591
  {
592
+ data: {
593
+ attrs: '',
594
+ isSelfClosing: false,
595
+ name: 'tag',
596
+ rawTag: '<tag>',
597
+ },
481
598
  type: 'tagopen',
482
- data: { name: 'tag', isSelfClosing: false, attrs: '' },
483
599
  },
484
600
  {
601
+ data: {
602
+ contents: 'Some text',
603
+ },
485
604
  type: 'text',
486
- data: { contents: 'Some text' },
487
605
  },
488
606
  {
607
+ data: {
608
+ contents: ' continued',
609
+ },
489
610
  type: 'text',
490
- data: { contents: ' continued' },
491
611
  },
492
612
  {
613
+ data: {
614
+ name: 'tag',
615
+ rawTag: '</tag>',
616
+ },
493
617
  type: 'tagclose',
494
- data: { name: 'tag' },
495
618
  },
496
619
  ]);
497
620
  // The text content should still be properly reconstructible
@@ -513,16 +636,27 @@ const saxy_1 = require("../saxy");
513
636
  // The text content should be emitted in two chunks due to the new immediate emission behavior
514
637
  (0, bun_test_1.expect)(events).toEqual([
515
638
  {
639
+ data: {
640
+ attrs: '',
641
+ isSelfClosing: false,
642
+ name: 'tag',
643
+ rawTag: '<tag>',
644
+ },
516
645
  type: 'tagopen',
517
- data: { name: 'tag', isSelfClosing: false, attrs: '' },
518
646
  },
519
647
  {
520
- type: 'text',
521
- data: { contents: '</invalid>' },
648
+ data: {
649
+ name: 'invalid',
650
+ rawTag: '</invalid>',
651
+ },
652
+ type: 'tagclose',
522
653
  },
523
654
  {
655
+ data: {
656
+ name: 'tag',
657
+ rawTag: '</tag>',
658
+ },
524
659
  type: 'tagclose',
525
- data: { name: 'tag' },
526
660
  },
527
661
  ]);
528
662
  // The text content should still be properly reconstructible
@@ -530,7 +664,7 @@ const saxy_1 = require("../saxy");
530
664
  .filter((e) => e.type === 'text')
531
665
  .map((e) => e.data.contents)
532
666
  .join('');
533
- (0, bun_test_1.expect)(textContent).toBe('</invalid>');
667
+ (0, bun_test_1.expect)(textContent).toBe('');
534
668
  });
535
669
  });
536
670
  });