@fluidframework/debugger 2.91.0 → 2.92.0

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 (61) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/fluidDebugger.d.ts +1 -1
  3. package/dist/fluidDebugger.d.ts.map +1 -1
  4. package/dist/fluidDebugger.js.map +1 -1
  5. package/dist/fluidDebuggerController.d.ts +4 -3
  6. package/dist/fluidDebuggerController.d.ts.map +1 -1
  7. package/dist/fluidDebuggerController.js +4 -4
  8. package/dist/fluidDebuggerController.js.map +1 -1
  9. package/dist/fluidDebuggerUi.d.ts +1 -1
  10. package/dist/fluidDebuggerUi.d.ts.map +1 -1
  11. package/dist/fluidDebuggerUi.js +25 -25
  12. package/dist/fluidDebuggerUi.js.map +1 -1
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/legacy.d.ts +1 -1
  17. package/dist/messageSchema.d.ts +1 -1
  18. package/dist/messageSchema.d.ts.map +1 -1
  19. package/dist/messageSchema.js.map +1 -1
  20. package/dist/public.d.ts +1 -1
  21. package/dist/sanitize.js.map +1 -1
  22. package/dist/sanitizer.d.ts +1 -1
  23. package/dist/sanitizer.d.ts.map +1 -1
  24. package/dist/sanitizer.js +52 -50
  25. package/dist/sanitizer.js.map +1 -1
  26. package/eslint.config.mts +13 -4
  27. package/internal.d.ts +1 -1
  28. package/legacy.d.ts +1 -1
  29. package/lib/fluidDebugger.d.ts +1 -1
  30. package/lib/fluidDebugger.d.ts.map +1 -1
  31. package/lib/fluidDebugger.js.map +1 -1
  32. package/lib/fluidDebuggerController.d.ts +4 -3
  33. package/lib/fluidDebuggerController.d.ts.map +1 -1
  34. package/lib/fluidDebuggerController.js +4 -4
  35. package/lib/fluidDebuggerController.js.map +1 -1
  36. package/lib/fluidDebuggerUi.d.ts +1 -1
  37. package/lib/fluidDebuggerUi.d.ts.map +1 -1
  38. package/lib/fluidDebuggerUi.js +25 -25
  39. package/lib/fluidDebuggerUi.js.map +1 -1
  40. package/lib/index.d.ts +2 -2
  41. package/lib/index.d.ts.map +1 -1
  42. package/lib/index.js.map +1 -1
  43. package/lib/legacy.d.ts +1 -1
  44. package/lib/messageSchema.d.ts +1 -1
  45. package/lib/messageSchema.d.ts.map +1 -1
  46. package/lib/messageSchema.js.map +1 -1
  47. package/lib/public.d.ts +1 -1
  48. package/lib/sanitize.js.map +1 -1
  49. package/lib/sanitizer.d.ts +1 -1
  50. package/lib/sanitizer.d.ts.map +1 -1
  51. package/lib/sanitizer.js +52 -50
  52. package/lib/sanitizer.js.map +1 -1
  53. package/package.json +13 -22
  54. package/src/fluidDebugger.ts +1 -1
  55. package/src/fluidDebuggerController.ts +10 -8
  56. package/src/fluidDebuggerUi.ts +26 -26
  57. package/src/index.ts +2 -2
  58. package/src/messageSchema.ts +1 -1
  59. package/src/sanitize.ts +1 -1
  60. package/src/sanitizer.ts +49 -47
  61. package/tsconfig.json +1 -1
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { assert } from "@fluidframework/core-utils/internal";
7
- import {
7
+ import type {
8
8
  IVersion,
9
9
  ISequencedDocumentMessage,
10
10
  } from "@fluidframework/driver-definitions/internal";
@@ -150,7 +150,7 @@ export class DebuggerUI {
150
150
  typeof window !== "object" ||
151
151
  window === null ||
152
152
  typeof window.document !== "object" ||
153
- window.document == null
153
+ window.document === null
154
154
  ) {
155
155
  console.log("Can't create debugger window - not running in browser!");
156
156
  return null;
@@ -218,16 +218,16 @@ export class DebuggerUI {
218
218
  false,
219
219
  );
220
220
 
221
- this.selector = doc.getElementById("selector") as HTMLSelectElement;
221
+ this.selector = doc.querySelector("#selector") as HTMLSelectElement;
222
222
 
223
- const buttonVers = doc.getElementById("buttonVers") as HTMLDivElement;
224
- buttonVers.onclick = () => {
223
+ const buttonVers = doc.querySelector("#buttonVers") as HTMLDivElement;
224
+ buttonVers.addEventListener("click", () => {
225
225
  const index = this.selector!.selectedIndex;
226
226
  // TODO Why are we non null asserting here
227
227
  controller.onVersionSelection(this.versions[index]!);
228
- };
228
+ });
229
229
 
230
- const fileSnapshot = doc.getElementById("file") as HTMLInputElement;
230
+ const fileSnapshot = doc.querySelector("#file") as HTMLInputElement;
231
231
  fileSnapshot.addEventListener(
232
232
  "change",
233
233
  () => {
@@ -240,11 +240,11 @@ export class DebuggerUI {
240
240
  false,
241
241
  );
242
242
 
243
- const opDownloadButton = doc.getElementById("downloadOps") as HTMLElement;
244
- const anonymizeCheckbox = doc.getElementById("anonymize") as HTMLInputElement;
243
+ const opDownloadButton = doc.querySelector("#downloadOps") as HTMLElement;
244
+ const anonymizeCheckbox = doc.querySelector("#anonymize") as HTMLInputElement;
245
245
  this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);
246
246
 
247
- this.versionText = doc.getElementById("versionText") as HTMLDivElement;
247
+ this.versionText = doc.querySelector("#versionText") as HTMLDivElement;
248
248
  this.versionText.textContent = "Fetching snapshots, please wait...";
249
249
 
250
250
  controller.connectToUi(this);
@@ -269,9 +269,9 @@ export class DebuggerUI {
269
269
  for (const version of versions) {
270
270
  const option = document.createElement("option");
271
271
  option.text =
272
- version.date !== undefined
273
- ? `id = ${version.id}, time = ${version.date}`
274
- : `id = ${version.id}`;
272
+ version.date === undefined
273
+ ? `id = ${version.id}`
274
+ : `id = ${version.id}, time = ${version.date}`;
275
275
  this.selector.add(option);
276
276
  }
277
277
  }
@@ -299,23 +299,23 @@ export class DebuggerUI {
299
299
  doc.write(debuggerWindowHtml2);
300
300
  doc.close();
301
301
 
302
- this.lastOpText = doc.getElementById("lastOp") as HTMLDivElement;
303
- this.text1 = doc.getElementById("text1") as HTMLDivElement;
304
- this.text2 = doc.getElementById("text2") as HTMLDivElement;
305
- this.text3 = doc.getElementById("text3") as HTMLDivElement;
302
+ this.lastOpText = doc.querySelector("#lastOp") as HTMLDivElement;
303
+ this.text1 = doc.querySelector("#text1") as HTMLDivElement;
304
+ this.text2 = doc.querySelector("#text2") as HTMLDivElement;
305
+ this.text3 = doc.querySelector("#text3") as HTMLDivElement;
306
306
 
307
- const steps = doc.getElementById("steps") as HTMLInputElement;
308
- this.buttonOps = doc.getElementById("buttonOps") as HTMLButtonElement;
307
+ const steps = doc.querySelector("#steps") as HTMLInputElement;
308
+ this.buttonOps = doc.querySelector("#buttonOps") as HTMLButtonElement;
309
309
  this.buttonOps.disabled = true;
310
- this.buttonOps.onclick = () => {
310
+ this.buttonOps.addEventListener("click", () => {
311
311
  this.controller.onOpButtonClick(Number(steps.value));
312
- };
312
+ });
313
313
 
314
- this.versionText = doc.getElementById("versionText") as HTMLDivElement;
314
+ this.versionText = doc.querySelector("#versionText") as HTMLDivElement;
315
315
  this.versionText.textContent = text;
316
316
 
317
- const opDownloadButton = doc.getElementById("downloadOps") as HTMLElement;
318
- const anonymizeCheckbox = doc.getElementById("anonymize") as HTMLInputElement;
317
+ const opDownloadButton = doc.querySelector("#downloadOps") as HTMLElement;
318
+ const anonymizeCheckbox = doc.querySelector("#anonymize") as HTMLInputElement;
319
319
  this.attachDownloadOpsListener(opDownloadButton, anonymizeCheckbox);
320
320
  }
321
321
 
@@ -361,10 +361,10 @@ export class DebuggerUI {
361
361
  element.setAttribute("download", filename);
362
362
 
363
363
  element.style.display = "none";
364
- document.body.appendChild(element);
364
+ document.body.append(element);
365
365
 
366
366
  element.click();
367
367
 
368
- document.body.removeChild(element);
368
+ element.remove();
369
369
  }
370
370
  }
package/src/index.ts CHANGED
@@ -4,5 +4,5 @@
4
4
  */
5
5
 
6
6
  export { FluidDebugger } from "./fluidDebugger.js";
7
- export { debuggerUIFactory, DebugReplayController } from "./fluidDebuggerController.js";
8
- export { DebuggerUI, IDebuggerController, IDebuggerUI } from "./fluidDebuggerUi.js";
7
+ export { type debuggerUIFactory, DebugReplayController } from "./fluidDebuggerController.js";
8
+ export { DebuggerUI, type IDebuggerController, type IDebuggerUI } from "./fluidDebuggerUi.js";
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { Schema } from "jsonschema";
6
+ import type { Schema } from "jsonschema";
7
7
 
8
8
  export const joinContentsSchema = {
9
9
  type: "null",
package/src/sanitize.ts CHANGED
@@ -21,7 +21,7 @@
21
21
  import fs from "node:fs";
22
22
  import process from "node:process";
23
23
 
24
- import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
24
+ import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
25
25
 
26
26
  import { Sanitizer } from "./sanitizer.js";
27
27
 
package/src/sanitizer.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  */
20
20
 
21
21
  import { assert } from "@fluidframework/core-utils/internal";
22
- import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
22
+ import type { ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
23
23
  import * as Validator from "jsonschema";
24
24
 
25
25
  import {
@@ -100,8 +100,8 @@ class ChunkedOpProcessor {
100
100
  // need to go deeper to get the desired contents
101
101
  parsed = parsed.contents;
102
102
  }
103
- } catch (e) {
104
- this.debugMsg(e);
103
+ } catch (error) {
104
+ this.debugMsg(error);
105
105
  this.debugMsg(message.contents);
106
106
  }
107
107
  this.validateSchemaFn(parsed, chunkedOpContentsSchema);
@@ -130,9 +130,9 @@ class ChunkedOpProcessor {
130
130
  this.concatenatedLength = contentsString.length;
131
131
  try {
132
132
  return JSON.parse(contentsString);
133
- } catch (e) {
133
+ } catch (error) {
134
134
  this.debugMsg(contentsString);
135
- this.debugMsg(e);
135
+ this.debugMsg(error);
136
136
  return undefined;
137
137
  }
138
138
  }
@@ -154,9 +154,9 @@ class ChunkedOpProcessor {
154
154
  stringified.length <= this.concatenatedLength,
155
155
  0x089 /* "Stringified length of chunk contents > total starting length" */,
156
156
  );
157
- } catch (e) {
158
- this.debugMsg(e);
159
- throw e;
157
+ } catch (error) {
158
+ this.debugMsg(error);
159
+ throw error;
160
160
  }
161
161
 
162
162
  for (let i = 0; i < this.messages.length; i++) {
@@ -179,8 +179,8 @@ class ChunkedOpProcessor {
179
179
  } else {
180
180
  stringifiedParsedContents = JSON.stringify(parsedContents);
181
181
  }
182
- } catch (e) {
183
- this.debugMsg(e);
182
+ } catch (error) {
183
+ this.debugMsg(error);
184
184
  }
185
185
 
186
186
  message.contents = stringifiedParsedContents;
@@ -201,7 +201,7 @@ class ChunkedOpProcessor {
201
201
  }
202
202
 
203
203
  isPendingProcessing(): boolean {
204
- return this.messages.length !== 0;
204
+ return this.messages.length > 0;
205
205
  }
206
206
  }
207
207
 
@@ -272,9 +272,9 @@ export class Sanitizer {
272
272
  getRandomText(len: number): string {
273
273
  let str = "";
274
274
  while (str.length < len) {
275
- str = str + Math.random().toString(36).substring(2);
275
+ str = str + Math.random().toString(36).slice(2);
276
276
  }
277
- return str.substr(0, len);
277
+ return str.slice(0, Math.max(0, len));
278
278
  }
279
279
 
280
280
  readonly wordTokenRegex = /\S+/g;
@@ -344,7 +344,7 @@ export class Sanitizer {
344
344
  }
345
345
 
346
346
  const keys = Object.keys(input);
347
- keys.forEach((key) => {
347
+ for (const key of keys) {
348
348
  if (this.fullScrub || !excludedKeys.has(key)) {
349
349
  const value = input[key];
350
350
  if (typeof value === "string") {
@@ -358,7 +358,7 @@ export class Sanitizer {
358
358
  input[key] = this.replaceObject(value, excludedKeys);
359
359
  }
360
360
  }
361
- });
361
+ }
362
362
  return input;
363
363
  }
364
364
 
@@ -392,25 +392,23 @@ export class Sanitizer {
392
392
 
393
393
  try {
394
394
  let data = JSON.parse(message.data);
395
- if (!this.objectMatchesSchema(data, joinDataSchema)) {
396
- data = this.replaceAny(data);
397
- } else {
395
+ if (this.objectMatchesSchema(data, joinDataSchema)) {
398
396
  const user = data.detail.user;
399
397
  user.id = this.replaceText(user.id, TextType.Email);
400
398
  user.email = this.replaceText(user.email, TextType.Email);
401
399
  user.name = this.replaceText(user.name, TextType.Name);
400
+ } else {
401
+ data = this.replaceAny(data);
402
402
  }
403
403
 
404
404
  message.data = JSON.stringify(data);
405
- } catch (e) {
406
- this.debugMsg(e);
405
+ } catch (error) {
406
+ this.debugMsg(error);
407
407
  }
408
408
  }
409
409
 
410
410
  fixPropose(message: any): void {
411
- if (!this.objectMatchesSchema(message.contents, proposeContentsSchema)) {
412
- message.contents = this.replaceAny(message.contents);
413
- } else {
411
+ if (this.objectMatchesSchema(message.contents, proposeContentsSchema)) {
414
412
  if (typeof message.contents === "string") {
415
413
  try {
416
414
  const data = JSON.parse(message.contents);
@@ -423,8 +421,8 @@ export class Sanitizer {
423
421
  pkg.fluid.browser.umd.files = this.replaceArray(pkg.fluid.browser.umd.files);
424
422
  }
425
423
  }
426
- } catch (e) {
427
- this.debugMsg(e);
424
+ } catch (error) {
425
+ this.debugMsg(error);
428
426
  }
429
427
  } else {
430
428
  if (this.fullScrub) {
@@ -434,11 +432,13 @@ export class Sanitizer {
434
432
  );
435
433
  }
436
434
  }
435
+ } else {
436
+ message.contents = this.replaceAny(message.contents);
437
437
  }
438
438
  }
439
439
 
440
440
  fixAttachEntries(entries: any[]): void {
441
- entries.forEach((element) => {
441
+ for (const element of entries) {
442
442
  // Tree type
443
443
  if (element.value.entries) {
444
444
  this.fixAttachEntries(element.value.entries);
@@ -450,11 +450,11 @@ export class Sanitizer {
450
450
  data = this.replaceObject(data);
451
451
  element.value.contents = JSON.stringify(data);
452
452
  }
453
- } catch (e) {
454
- this.debugMsg(e);
453
+ } catch (error) {
454
+ this.debugMsg(error);
455
455
  }
456
456
  }
457
- });
457
+ }
458
458
  }
459
459
 
460
460
  /**
@@ -466,15 +466,15 @@ export class Sanitizer {
466
466
  typeof contents === "object",
467
467
  0x08b /* "Unexpected type on contents for fix of an attach!" */,
468
468
  );
469
- if (!this.objectMatchesSchema(contents, attachContentsSchema)) {
470
- this.replaceObject(contents);
471
- } else {
469
+ if (this.objectMatchesSchema(contents, attachContentsSchema)) {
472
470
  if (this.fullScrub) {
473
471
  contents.id = this.replaceText(contents.id, TextType.FluidObject);
474
472
  contents.type = this.replaceText(contents.type, TextType.FluidObject);
475
473
  }
476
474
 
477
475
  this.fixAttachEntries(contents.snapshot.entries);
476
+ } else {
477
+ this.replaceObject(contents);
478
478
  }
479
479
  }
480
480
 
@@ -495,8 +495,8 @@ export class Sanitizer {
495
495
  const data = JSON.parse(message.contents);
496
496
  this.fixAttachContents(data);
497
497
  message.contents = JSON.stringify(data);
498
- } catch (e) {
499
- this.debugMsg(e);
498
+ } catch (error) {
499
+ this.debugMsg(error);
500
500
  return;
501
501
  }
502
502
  } else {
@@ -520,9 +520,7 @@ export class Sanitizer {
520
520
  */
521
521
  fixOpContentsObject(contents: any): void {
522
522
  // do replacement
523
- if (!this.objectMatchesSchema(contents, opContentsSchema)) {
524
- this.replaceAny(contents);
525
- } else {
523
+ if (this.objectMatchesSchema(contents, opContentsSchema)) {
526
524
  if (this.fullScrub) {
527
525
  contents.address = this.replaceText(contents.address, TextType.FluidObject);
528
526
  }
@@ -540,8 +538,8 @@ export class Sanitizer {
540
538
  const data = JSON.parse(contents.contents.content);
541
539
  this.fixAttachContents(data);
542
540
  contents.contents.content = JSON.stringify(data);
543
- } catch (e) {
544
- this.debugMsg(e);
541
+ } catch (error) {
542
+ this.debugMsg(error);
545
543
  }
546
544
  } else {
547
545
  this.fixAttachContents(contents.contents.content);
@@ -567,9 +565,9 @@ export class Sanitizer {
567
565
  if (this.fullScrub) {
568
566
  innerContent.address = this.replaceText(innerContent.address, TextType.FluidObject);
569
567
  }
570
- innerContent.contents.ops.forEach((deltaOp) => {
568
+ for (const deltaOp of innerContent.contents.ops) {
571
569
  this.fixDeltaOp(deltaOp);
572
- });
570
+ }
573
571
  } else if (
574
572
  this.validator.validate(innerContent, opContentsMergeTreeDeltaOpSchema).valid
575
573
  ) {
@@ -598,6 +596,8 @@ export class Sanitizer {
598
596
  // message contents don't match any known op format
599
597
  this.objectMatchesSchema(contents, false);
600
598
  }
599
+ } else {
600
+ this.replaceAny(contents);
601
601
  }
602
602
  }
603
603
 
@@ -607,8 +607,8 @@ export class Sanitizer {
607
607
  if (typeof message.contents === "string") {
608
608
  try {
609
609
  msgContents = JSON.parse(message.contents);
610
- } catch (e) {
611
- this.debugMsg(e);
610
+ } catch (error) {
611
+ this.debugMsg(error);
612
612
  return;
613
613
  }
614
614
  } else {
@@ -653,8 +653,8 @@ export class Sanitizer {
653
653
  if (typeof message.contents === "string") {
654
654
  try {
655
655
  message.contents = JSON.stringify(msgContents);
656
- } catch (e) {
657
- this.debugMsg(e);
656
+ } catch (error) {
657
+ this.debugMsg(error);
658
658
  return;
659
659
  }
660
660
  }
@@ -712,10 +712,12 @@ export class Sanitizer {
712
712
  case "noClient":
713
713
  case "summarize":
714
714
  case "summaryAck":
715
- case "summaryNack":
715
+ case "summaryNack": {
716
716
  break;
717
- default:
717
+ }
718
+ default: {
718
719
  this.debugMsg(`Unexpected op type ${message.type}`);
720
+ }
719
721
  }
720
722
  });
721
723
 
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "../../../common/build/build-common/tsconfig.node16.json",
3
3
  "include": ["src/**/*"],
4
- "exclude": ["dist", "node_modules"],
4
+ "exclude": ["src/test/**/*"],
5
5
  "compilerOptions": {
6
6
  "rootDir": "./src",
7
7
  "outDir": "./lib",