@nerd-bible/wordgard 0.6.2-beta7 → 0.6.2-beta9

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/dist/history.js CHANGED
@@ -4,6 +4,7 @@ import { Command, undo as undo$1, redo as redo$1, Menu } from 'wordgard/command'
4
4
  import { phrases } from 'wordgard/phrases';
5
5
 
6
6
  const fromHistory = /*@__PURE__*/Transaction.Effect.define({
7
+ name: "fromHistory",
7
8
  map(value, change) {
8
9
  return {
9
10
  side: value.side,
@@ -13,6 +14,7 @@ const fromHistory = /*@__PURE__*/Transaction.Effect.define({
13
14
  }
14
15
  });
15
16
  const historyConfig = /*@__PURE__*/GardState.Facet.define({
17
+ name: "historyConfig",
16
18
  combine(configs) {
17
19
  return GardState.Facet.combineConfig(configs, {
18
20
  minDepth: 100,
@@ -26,6 +28,7 @@ const historyConfig = /*@__PURE__*/GardState.Facet.define({
26
28
  }
27
29
  });
28
30
  const historyField_ = /*@__PURE__*/GardState.Field.define({
31
+ name: "history",
29
32
  create() {
30
33
  return new HistoryState(null, null);
31
34
  },
@@ -88,8 +91,10 @@ function history(config = {}) {
88
91
  }
89
92
  ;history = /*@__PURE__*/(function (history) {
90
93
  history.field = historyField_;
91
- history.isolate = Transaction.Annotation.define();
92
- history.invertedEffects = GardState.Facet.define();
94
+ history.isolate = Transaction.Annotation.define("historyIsolate");
95
+ history.invertedEffects = GardState.Facet.define({
96
+ name: "invertedEffects"
97
+ });
93
98
  ;return history})(history);
94
99
  const undo = ({ state }) => {
95
100
  let historyState = state.field(historyField_, false);
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export * as collab from "wordgard/collab"
2
2
  export * as command from "wordgard/command"
3
3
  export * as doc from "wordgard/doc"
4
4
  export * as editor from "wordgard/editor"
5
- export * as highlight-code from "wordgard/highlight-code"
5
+ export * as highlightCode from "wordgard/highlight-code"
6
6
  export * as history from "wordgard/history"
7
7
  export * as phrases from "wordgard/phrases"
8
8
  export * as schema from "wordgard/schema"
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ export * as collab from "wordgard/collab"
2
2
  export * as command from "wordgard/command"
3
3
  export * as doc from "wordgard/doc"
4
4
  export * as editor from "wordgard/editor"
5
- export * as highlight-code from "wordgard/highlight-code"
5
+ export * as highlightCode from "wordgard/highlight-code"
6
6
  export * as history from "wordgard/history"
7
7
  export * as phrases from "wordgard/phrases"
8
8
  export * as schema from "wordgard/schema"
package/dist/phrases.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { GardState } from 'wordgard/state';
2
2
 
3
3
  const phraseOverride = /*@__PURE__*/GardState.Facet.define({
4
+ name: "phraseOverride",
4
5
  combine(records) {
5
6
  let map = new Map();
6
7
  for (let i = records.length - 1; i >= 0; i--) {
package/dist/schema.js CHANGED
@@ -365,6 +365,7 @@ const languageStyles = /*@__PURE__*/Wordgard.styles({
365
365
  }
366
366
  });
367
367
  const languageOptions = /*@__PURE__*/GardState.Facet.define({
368
+ name: "languageOptions",
368
369
  combine: input => {
369
370
  let options = [];
370
371
  for (let arr of input)
@@ -582,7 +583,7 @@ function subscript() {
582
583
  });
583
584
  ;return subscript})(subscript);
584
585
 
585
- const imageUploader = /*@__PURE__*/GardState.Facet.define();
586
+ const imageUploader = /*@__PURE__*/GardState.Facet.define({ name: "imageUploader" });
586
587
  const imageTypes = [Image, Figure, CaptionedFigure];
587
588
  function activeImage(sel) {
588
589
  if (sel.selection instanceof GardSelection.Node && imageTypes.includes(sel.selection.node.type))
@@ -825,6 +826,7 @@ const resizeTheme = /*@__PURE__*/Wordgard.theme({
825
826
  }
826
827
  });
827
828
  const setResizing = /*@__PURE__*/Transaction.Effect.define({
829
+ name: "setImageResize",
828
830
  map: (value, mapping) => {
829
831
  let newPos = mapping.mapPos(value.target, 1, "after");
830
832
  return newPos == null ? undefined : { target: newPos, resizing: value.resizing };
@@ -836,6 +838,7 @@ const handleElt = /*@__PURE__*/(() => Elt.mk("svg:svg", { class: "wg-resize-hand
836
838
  ]))();
837
839
  const resizeWrapper = /*@__PURE__*/(() => Decoration.Point.wrapper(Elt.mk("span", { class: "wg-resize-hover" }, [handleElt, 0]), { target: "img" }))();
838
840
  const resizeState = /*@__PURE__*/GardState.Field.define({
841
+ name: "imageResize",
839
842
  create: () => ({ target: -1, resizing: -1, deco: Decoration.Point.none }),
840
843
  update: (value, tr) => {
841
844
  for (let e of tr.effects) {
@@ -1188,9 +1191,11 @@ class ColorPicker {
1188
1191
  ];
1189
1192
  }
1190
1193
  ColorPicker.width = GardState.Facet.define({
1194
+ name: "colorPickerWidth",
1191
1195
  combine: values => values.length ? values[0] : 10
1192
1196
  });
1193
1197
  ColorPicker.options = GardState.Facet.define({
1198
+ name: "colorPickerOptions",
1194
1199
  combine: values => values.length ? values[0] : defaultColors()
1195
1200
  });
1196
1201
  ColorPicker.theme = Wordgard.styles({
@@ -1329,8 +1334,9 @@ function computeLinkTooltip(state) {
1329
1334
  create: () => renderLinkTooltip(link.value)
1330
1335
  };
1331
1336
  }
1332
- const closeLinkTooltip = /*@__PURE__*/Transaction.Effect.define();
1337
+ const closeLinkTooltip = /*@__PURE__*/Transaction.Effect.define({ name: "closeLinkTooltip" });
1333
1338
  const linkTooltipField = /*@__PURE__*/GardState.Field.define({
1339
+ name: "linkTooltip",
1334
1340
  create: computeLinkTooltip,
1335
1341
  update(value, tr) {
1336
1342
  if (tr.effects.some(e => e.is(closeLinkTooltip)))
@@ -1412,12 +1418,9 @@ function link() {
1412
1418
  })),
1413
1419
  linkTooltipTheme
1414
1420
  ];
1415
- link_1.pasteOver = Wordgard.pasteHandler.of((wg, event) => {
1416
- let { selection } = wg.state, data = event.dataTransfer;
1417
- if (!data || selection.empty)
1418
- return false;
1419
- let text = data.getData("text/plain") || data.getData("Text") || data.getData("text/uri-list");
1420
- if (!text || !/^(https?|mailto|xmpp|data):[^ ]+$/.test(text))
1421
+ link_1.pasteOver = Wordgard.pasteHandler.of((wg, event, slice, html, text) => {
1422
+ let { selection } = wg.state;
1423
+ if (selection.empty || !/^(https?|mailto|xmpp|data):[^ ]+$/.test(text))
1421
1424
  return false;
1422
1425
  let link = Link.of(text);
1423
1426
  let changes = ChangeSet.create(wg.state.doc, { from: selection.from, to: selection.to, add: link });
package/dist/set.js CHANGED
@@ -164,7 +164,11 @@ let SetBuilder$1 = class SetBuilder {
164
164
  addRange(value, from, to) {
165
165
  if (from >= to)
166
166
  throw new Error("Ranges cannot be empty");
167
- (this.lastTo <= from ? this : this.next).addInner(value, from, to);
167
+ for (let target = this;; target = target.next)
168
+ if (target.lastTo <= from) {
169
+ target.addInner(value, from, to);
170
+ break;
171
+ }
168
172
  }
169
173
  addInner(value, from, to) {
170
174
  let chunk;
@@ -246,13 +250,13 @@ class RangeSet extends Set {
246
250
  let replI = 0, posA = 0, posB = 0;
247
251
  let build = new SetBuilder$1();
248
252
  for (let i = 0; i < sections.length;) {
249
- let len = sections[i++], ins = sections[i++];
253
+ let len = sections[i++], ins = sections[i++], endA = posA + len;
250
254
  if (ins < 0) {
251
255
  while (i < sections.length && sections[i + 1] < 0) {
252
256
  len += sections[i];
253
257
  i += 2;
254
258
  }
255
- let upto = i == sections.length ? 1e9 : posA + len, off = posB - posA;
259
+ let upto = i == sections.length ? 1e9 : endA, off = posB - posA;
256
260
  while (cursor.cur) {
257
261
  let chunk = cursor.cur;
258
262
  if (cursor.i == 0 && chunk.end < upto) {
@@ -277,12 +281,12 @@ class RangeSet extends Set {
277
281
  if (repl.add)
278
282
  build.add(repl.add);
279
283
  }
280
- if (len)
281
- cursor.goto(posA + len - 1);
282
- copyMappedUpto$1(cursor, posA + len, map, build, replace, replStartI);
284
+ if (len && cursor.to < endA)
285
+ cursor.goto(endA - 1);
286
+ copyMappedUpto$1(cursor, endA, map, build, replace, replStartI);
283
287
  posB = endB;
284
288
  }
285
- posA += len;
289
+ posA = endA;
286
290
  }
287
291
  return build.finish(this.next && this.next.mapInner(sections, map, replace));
288
292
  }
package/dist/state.d.ts CHANGED
@@ -398,6 +398,10 @@ declare class Transaction {
398
398
  */
399
399
  readonly effects: readonly Transaction.Effect<any>[];
400
400
  /**
401
+ The annotations on this transaction.
402
+ */
403
+ readonly annotations: readonly Transaction.Annotation<any>[];
404
+ /**
401
405
  Whether the selection should be scrolled into view after this
402
406
  transaction is dispatched.
403
407
  */
@@ -569,7 +573,7 @@ declare namespace Transaction {
569
573
  /**
570
574
  Define a new type of annotation.
571
575
  */
572
- static define<T>(): Annotation.Type<T>;
576
+ static define<T>(name?: string): Annotation.Type<T>;
573
577
  private _isAnnotation;
574
578
  }
575
579
  namespace Annotation {
@@ -578,13 +582,17 @@ declare namespace Transaction {
578
582
  annotation}.
579
583
  */
580
584
  class Type<T> {
585
+ /**
586
+ This type's debug name.
587
+ */
588
+ readonly name: string | null;
589
+ private constructor();
581
590
  /**
582
591
  Create an instance of this annotation.
583
592
  */
584
593
  of(value: T): Transaction.Annotation<T>;
585
594
  }
586
595
  }
587
- const foo: number;
588
596
  /**
589
597
  Annotation used to store transaction timestamps. Automatically
590
598
  added to every transaction, holding `Date.now()`.
@@ -688,6 +696,11 @@ declare namespace Transaction {
688
696
  */
689
697
  readonly map: (value: any, mapping: ChangeSet) => any | undefined;
690
698
  /**
699
+ The debug name of this effect.
700
+ */
701
+ readonly name: string | null;
702
+ private constructor();
703
+ /**
691
704
  Create an {@link Transaction.Effect effect} instance of this
692
705
  type.
693
706
  */
@@ -697,6 +710,10 @@ declare namespace Transaction {
697
710
  Options passed when defining an effect.
698
711
  */
699
712
  interface Spec<Value> {
713
+ /**
714
+ An optional debug name to assign to this effect.
715
+ */
716
+ name?: string;
700
717
  /**
701
718
  Provides a way to map an effect like this through a position
702
719
  mapping. When not given, the effects will simply not be mapped.
@@ -976,6 +993,10 @@ declare namespace GardState {
976
993
  Define a state field.
977
994
  */
978
995
  static define<Value>(config: GardState.Field.Spec<Value>): GardState.Field<Value>;
996
+ /**
997
+ The field's debugging name, if given.
998
+ */
999
+ name: string | null;
979
1000
  private create;
980
1001
  /**
981
1002
  State field instances can be used as {@link
@@ -995,6 +1016,11 @@ declare namespace GardState {
995
1016
  The options passed when defining a state field.
996
1017
  */
997
1018
  type Spec<Value> = {
1019
+ /**
1020
+ An optional name to associate with this field for debugging
1021
+ purposes.
1022
+ */
1023
+ name?: string;
998
1024
  /**
999
1025
  Creates the initial value for the field when a state is created.
1000
1026
  */
@@ -1043,11 +1069,19 @@ declare namespace GardState {
1043
1069
  */
1044
1070
  class Derived<Value> {
1045
1071
  private compareF;
1072
+ /**
1073
+ This field's debugging name, if given.
1074
+ */
1075
+ readonly name: string | null;
1046
1076
  private constructor();
1047
1077
  /**
1048
1078
  Define a derived field.
1049
1079
  */
1050
1080
  static define<Value>(compute: (state: GardState) => Value, spec?: {
1081
+ /**
1082
+ An optional debugging name for this field.
1083
+ */
1084
+ name?: string;
1051
1085
  /**
1052
1086
  Optional function used to compare the value of the field,
1053
1087
  to prevent propagating a change when a recomputed result
@@ -1088,6 +1122,10 @@ declare namespace GardState {
1088
1122
  */
1089
1123
  readonly isStatic: boolean;
1090
1124
  /**
1125
+ The facet's debug name.
1126
+ */
1127
+ readonly name: string | null;
1128
+ /**
1091
1129
  The output of the facet when it has no inputs.
1092
1130
  */
1093
1131
  readonly default: Output;
@@ -1132,7 +1170,6 @@ declare namespace GardState {
1132
1170
  */
1133
1171
  from<T extends Input>(field: GardState.Field<T> | GardState.Field.Derived<T>): GardState.Extension;
1134
1172
  from<T>(field: GardState.Field<T> | GardState.Field.Derived<T>, get: (value: T) => Input): GardState.Extension;
1135
- tag: Output;
1136
1173
  }
1137
1174
  namespace Facet {
1138
1175
  /**
@@ -1140,6 +1177,10 @@ declare namespace GardState {
1140
1177
  facet.
1141
1178
  */
1142
1179
  type Spec<Input, Output> = {
1180
+ /**
1181
+ And optional name, to recognize the facet when debugging.
1182
+ */
1183
+ name?: string;
1143
1184
  /**
1144
1185
  How to combine the input values into a single output value. When
1145
1186
  not given, the array of input values becomes the output. This
@@ -1286,11 +1327,15 @@ declare namespace GardState {
1286
1327
  transaction.
1287
1328
  */
1288
1329
  class Compartment {
1330
+ /**
1331
+ The compartment's debugging name, if given.
1332
+ */
1333
+ readonly name: string | null;
1289
1334
  private constructor();
1290
1335
  /**
1291
1336
  Define a new compartment.
1292
1337
  */
1293
- static define(): Compartment;
1338
+ static define(name?: string): Compartment;
1294
1339
  /**
1295
1340
  Create an instance of this compartment to add to your {@link
1296
1341
  GardState.Spec.config state configuration}.
package/dist/state.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Leaf, ValidationError, Slice, Pos, ChangeSet, Plot, SchemaError, parse, Schema } from 'wordgard/doc';
1
+ import { Leaf, ValidationError, Slice, Pos, ChangeSet, Plot, SchemaError, parse, Schema, Node } from 'wordgard/doc';
2
2
  import { findClusterBreak } from '@marijn/find-cluster-break';
3
3
 
4
4
  function dec(str) {
@@ -955,6 +955,17 @@ function wordAt(state, pos, bias) {
955
955
  : GardSelection.cursor(pos, bias);
956
956
  }
957
957
 
958
+ function debugString(value) {
959
+ let tp = typeof value;
960
+ if (tp == "string")
961
+ return JSON.stringify(value);
962
+ if (tp == "function")
963
+ return /.*?\)/.exec(value.toString())?.[0] || value;
964
+ if (Array.isArray(value))
965
+ return `[${value.map(debugString)}]`;
966
+ return value;
967
+ }
968
+
958
969
  class Transaction {
959
970
  startState;
960
971
  changes;
@@ -1045,20 +1056,28 @@ class Transaction {
1045
1056
  this.type = type;
1046
1057
  this.value = value;
1047
1058
  }
1048
- static define() { return new Transaction.Annotation.Type(); }
1059
+ static define(name) { return Transaction.Annotation.Type.new(name || null); }
1060
+ toString() { return `${this.type}(${debugString(this.value)})`; }
1049
1061
  }
1050
1062
  Transaction.Annotation = Annotation;
1051
1063
  (function (Annotation) {
1052
1064
  class Type {
1065
+ name;
1066
+ constructor(
1067
+ name) {
1068
+ this.name = name;
1069
+ }
1070
+ static new(name) { return new Type(name); }
1053
1071
  of(value) { return new Transaction.Annotation(this, value); }
1072
+ toString() { return "Annotation" + (this.name ? ":" + this.name : ""); }
1054
1073
  }
1055
1074
  Annotation.Type = Type;
1056
1075
  })(Annotation = Transaction.Annotation || (Transaction.Annotation = {}));
1057
- Transaction.time = Transaction.Annotation.define();
1058
- Transaction.userEvent = Annotation.define();
1059
- Transaction.addToHistory = Annotation.define();
1060
- Transaction.remote = Annotation.define();
1061
- Transaction.appended = Annotation.define();
1076
+ Transaction.time = Transaction.Annotation.define("time");
1077
+ Transaction.userEvent = Annotation.define("userEvent");
1078
+ Transaction.addToHistory = Annotation.define("addToHistory");
1079
+ Transaction.remote = Annotation.define("remote");
1080
+ Transaction.appended = Annotation.define("appended");
1062
1081
  class Effect {
1063
1082
  type;
1064
1083
  value;
@@ -1074,8 +1093,9 @@ class Transaction {
1074
1093
  }
1075
1094
  is(type) { return this.type == type; }
1076
1095
  static define(spec = {}) {
1077
- return new Transaction.Effect.Type(spec.map || (v => v));
1096
+ return Effect.Type.new(spec.map || (v => v), spec.name || null);
1078
1097
  }
1098
+ toString() { return `${this.type}(${debugString(this.value)})`; }
1079
1099
  }
1080
1100
  Transaction.Effect = Effect;
1081
1101
  (function (Effect) {
@@ -1093,11 +1113,18 @@ class Transaction {
1093
1113
  Effect.mapEffects = mapEffects;
1094
1114
  class Type {
1095
1115
  map;
1116
+ name;
1096
1117
  constructor(
1097
- map) {
1118
+ map,
1119
+ name) {
1098
1120
  this.map = map;
1121
+ this.name = name;
1122
+ }
1123
+ static new(map, name) {
1124
+ return new Type(map, name);
1099
1125
  }
1100
1126
  of(value) { return new Transaction.Effect(this, value); }
1127
+ toString() { return "Effect" + (this.name ? ":" + this.name : ""); }
1101
1128
  }
1102
1129
  Effect.Type = Type;
1103
1130
  })(Effect = Transaction.Effect || (Transaction.Effect = {}));
@@ -1366,8 +1393,8 @@ class GardState {
1366
1393
  wordAt(pos, bias = 1) {
1367
1394
  return wordAt(this, pos, bias);
1368
1395
  }
1369
- static reconfigure = /*@__PURE__*/Transaction.Effect.define();
1370
- static appendConfig = /*@__PURE__*/Transaction.Effect.define();
1396
+ static reconfigure = /*@__PURE__*/Transaction.Effect.define({ name: "reconfigure" });
1397
+ static appendConfig = /*@__PURE__*/Transaction.Effect.define({ name: "appendConfig" });
1371
1398
  }
1372
1399
  ;GardState = /*@__PURE__*/(function (GardState) {
1373
1400
  class Field {
@@ -1385,13 +1412,15 @@ class GardState {
1385
1412
  this.updateF = updateF;
1386
1413
  this.compareF = compareF;
1387
1414
  this.spec = spec;
1415
+ this.name = spec.name || null;
1388
1416
  }
1389
1417
  static define(config) {
1390
- let field = new GardState.Field(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);
1418
+ let field = new Field(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);
1391
1419
  if (config.provide)
1392
1420
  field.provides = config.provide(field);
1393
1421
  return field;
1394
1422
  }
1423
+ name;
1395
1424
  create(state) {
1396
1425
  let init = state.facet(initField).find(i => i.field == this);
1397
1426
  return (init?.create || this.createF)(state);
@@ -1425,21 +1454,25 @@ class GardState {
1425
1454
  init(create) {
1426
1455
  return [this, initField.of({ field: this, create })];
1427
1456
  }
1457
+ toString() { return "Field" + (this.name ? ":" + this.name : ""); }
1428
1458
  }
1429
1459
  GardState.Field = Field;
1430
1460
  (function (Field) {
1431
1461
  class Derived {
1432
1462
  value;
1433
1463
  compareF;
1464
+ name;
1434
1465
  id = nextID++;
1435
1466
  dependencies = [];
1436
1467
  constructor(
1437
- value, compareF) {
1468
+ value, compareF,
1469
+ name) {
1438
1470
  this.value = value;
1439
1471
  this.compareF = compareF;
1472
+ this.name = name;
1440
1473
  }
1441
1474
  static define(compute, spec = {}) {
1442
- return new Derived(compute, spec.compare || ((a, b) => a === b));
1475
+ return new Derived(compute, spec.compare || ((a, b) => a === b), spec.name || null);
1443
1476
  }
1444
1477
  get extension() { return this; }
1445
1478
  slot(addresses) {
@@ -1483,6 +1516,7 @@ class GardState {
1483
1516
  }
1484
1517
  };
1485
1518
  }
1519
+ toString() { return "Field.Derived" + (this.name ? ":" + this.name : ""); }
1486
1520
  }
1487
1521
  Field.Derived = Derived;
1488
1522
  })(Field = GardState.Field || (GardState.Field = {}));
@@ -1491,6 +1525,7 @@ class GardState {
1491
1525
  compareInput;
1492
1526
  compare;
1493
1527
  isStatic;
1528
+ name;
1494
1529
  id = nextID++;
1495
1530
  default;
1496
1531
  extensions;
@@ -1498,17 +1533,19 @@ class GardState {
1498
1533
  combine,
1499
1534
  compareInput,
1500
1535
  compare,
1501
- isStatic, enables) {
1536
+ isStatic, enables,
1537
+ name) {
1502
1538
  this.combine = combine;
1503
1539
  this.compareInput = compareInput;
1504
1540
  this.compare = compare;
1505
1541
  this.isStatic = isStatic;
1542
+ this.name = name;
1506
1543
  this.default = combine(none);
1507
1544
  this.extensions = typeof enables == "function" ? enables(this) : enables;
1508
1545
  }
1509
1546
  get reader() { return this; }
1510
1547
  static define(config = {}) {
1511
- return new GardState.Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray : (a, b) => a === b), !!config.static, config.enables);
1548
+ return new GardState.Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray : (a, b) => a === b), !!config.static, config.enables, config.name || null);
1512
1549
  }
1513
1550
  of(value) {
1514
1551
  return new FacetProvider(this, nextID++, 1, value);
@@ -1533,6 +1570,7 @@ class GardState {
1533
1570
  return this.derive(s => get(s.field(field)));
1534
1571
  }
1535
1572
  tag;
1573
+ toString() { return "Facet" + (this.name ? ":" + this.name : ""); }
1536
1574
  }
1537
1575
  GardState.Facet = Facet;
1538
1576
  (function (Facet) {
@@ -1707,15 +1745,19 @@ class GardState {
1707
1745
  return result.reduce((a, b) => a.concat(b));
1708
1746
  }
1709
1747
  GardState.prec = {
1710
- highest: mkPrec(0),
1711
- high: mkPrec(1),
1712
- default: mkPrec(2),
1713
- low: mkPrec(3),
1714
- lowest: mkPrec(4)
1748
+ highest: mkPrec(0, "Highest"),
1749
+ high: mkPrec(1, "High"),
1750
+ default: mkPrec(2, "Default"),
1751
+ low: mkPrec(3, "Low"),
1752
+ lowest: mkPrec(4, "Lowest")
1715
1753
  };
1716
1754
  class Compartment {
1717
- constructor() { }
1718
- static define() { return new Compartment; }
1755
+ name;
1756
+ constructor(
1757
+ name) {
1758
+ this.name = name;
1759
+ }
1760
+ static define(name) { return new Compartment(name || null); }
1719
1761
  of(ext) { return new CompartmentInstance(this, ext); }
1720
1762
  reconfigure(content) {
1721
1763
  return GardState.Compartment.reconfigureCompartment.of({ compartment: this, extension: content });
@@ -1723,28 +1765,35 @@ class GardState {
1723
1765
  get(state) {
1724
1766
  return state.config.compartments.get(this);
1725
1767
  }
1726
- static reconfigureCompartment = Transaction.Effect.define();
1768
+ static reconfigureCompartment = Transaction.Effect.define({ name: "reconfigureCompartment" });
1769
+ toString() { return "Compartment" + (this.name ? ":" + this.name : ""); }
1727
1770
  }
1728
1771
  GardState.Compartment = Compartment;
1729
1772
  GardState.schemaElement = GardState.Facet.define({
1773
+ name: "schemaElement",
1730
1774
  combine: values => values.reduce((set, elt) => set.concat(elt), none),
1731
1775
  static: true
1732
1776
  });
1733
1777
  GardState.readOnly = GardState.Facet.define({
1778
+ name: "readOnly",
1734
1779
  combine: values => values.length ? values[0] : false
1735
1780
  });
1736
1781
  GardState.textLTR = GardState.Facet.define({
1782
+ name: "textLTR",
1737
1783
  combine: values => values.length ? values[0] : true,
1738
1784
  static: true
1739
1785
  });
1740
1786
  GardState.textblockLTR = GardState.Facet.define({
1787
+ name: "textblockLTR",
1741
1788
  static: true
1742
1789
  });
1743
1790
  GardState.visualCursorMotion = GardState.Facet.define({
1791
+ name: "visualCursorMotion",
1744
1792
  combine(values) { return !values.length ? true : values[0]; },
1745
1793
  static: true
1746
1794
  });
1747
1795
  GardState.isAtom = GardState.Facet.define({
1796
+ name: "isAtom",
1748
1797
  static: true,
1749
1798
  combine(inputs) {
1750
1799
  let map = new Map();
@@ -1754,22 +1803,28 @@ class GardState {
1754
1803
  }
1755
1804
  });
1756
1805
  ;return GardState})(GardState);
1757
- const initField = /*@__PURE__*/GardState.Facet.define({ static: true });
1806
+ const initField = /*@__PURE__*/GardState.Facet.define({
1807
+ name: "init",
1808
+ static: true
1809
+ });
1758
1810
  function addValue(set, value) {
1759
1811
  if (set.indexOf(value) < 0)
1760
1812
  set.push(value);
1761
1813
  }
1762
- function mkPrec(value) {
1763
- return (ext) => new PrecExtension(ext, value);
1814
+ function mkPrec(value, name) {
1815
+ return (ext) => new PrecExtension(ext, value, name);
1764
1816
  }
1765
1817
  class PrecExtension {
1766
1818
  inner;
1767
1819
  prec;
1768
- constructor(inner, prec) {
1820
+ name;
1821
+ constructor(inner, prec, name) {
1769
1822
  this.inner = inner;
1770
1823
  this.prec = prec;
1824
+ this.name = name;
1771
1825
  }
1772
1826
  extension;
1827
+ toString() { return `Prec.${this.name}(${this.inner})`; }
1773
1828
  }
1774
1829
  function sameArray(a, b) {
1775
1830
  return a == b || a.length == b.length && a.every((e, i) => e === b[i]);
@@ -1807,6 +1862,7 @@ class FacetProvider {
1807
1862
  this.flags = flags;
1808
1863
  this.value = value;
1809
1864
  }
1865
+ toString() { return `${this.facet}(${this.flags & 1 ? debugString(this.value) : "dynamic"})`; }
1810
1866
  }
1811
1867
  function compareArray(a, b, compare) {
1812
1868
  if (a.length != b.length)
@@ -1896,8 +1952,10 @@ class CompartmentInstance {
1896
1952
  this.inner = inner;
1897
1953
  }
1898
1954
  extension;
1955
+ toString() { return `${this.compartment}(${this.inner})`; }
1899
1956
  }
1900
1957
  GardSelection = /*@__PURE__*/(GardSelection => {GardSelection.selectionType = GardState.Facet.define({
1958
+ name: "selectionType",
1901
1959
  combine(values) {
1902
1960
  let types = [GardSelection.Text.type, GardSelection.Node.type, ...values];
1903
1961
  for (let i = 0; i < types.length; i++)
@@ -1909,8 +1967,8 @@ GardSelection = /*@__PURE__*/(GardSelection => {GardSelection.selectionType = Ga
1909
1967
  },
1910
1968
  static: true
1911
1969
  }); return GardSelection})(GardSelection);
1912
- Transaction = /*@__PURE__*/(Transaction => {Transaction.extender = GardState.Facet.define(); return Transaction})(Transaction);
1913
- Transaction = /*@__PURE__*/(Transaction => {Transaction.appender = GardState.Facet.define(); return Transaction})(Transaction);
1970
+ Transaction = /*@__PURE__*/(Transaction => {Transaction.extender = GardState.Facet.define({ name: "extender" }); return Transaction})(Transaction);
1971
+ Transaction = /*@__PURE__*/(Transaction => {Transaction.appender = GardState.Facet.define({ name: "appender" }); return Transaction})(Transaction);
1914
1972
 
1915
1973
  function scanChanges(changes, doc, corrections) {
1916
1974
  let buckets = [[], [], []], [childList, content, marks] = buckets;
@@ -2003,7 +2061,7 @@ function scanChanges(changes, doc, corrections) {
2003
2061
  }
2004
2062
  return plan;
2005
2063
  }
2006
- const corrections = /*@__PURE__*/GardState.Facet.define();
2064
+ const corrections = /*@__PURE__*/GardState.Facet.define({ name: "corrections" });
2007
2065
  const planCache = /*@__PURE__*/(() => new WeakMap())();
2008
2066
  class Correction {
2009
2067
  event;
@@ -2072,6 +2130,7 @@ class Correction {
2072
2130
  }
2073
2131
  return changed.length ? ChangeSet.create(doc, changed) : null;
2074
2132
  }
2133
+ toString() { return `Correction(${Node.queryToString(this.query)})`; }
2075
2134
  }
2076
2135
 
2077
2136
  export { BidiSpan, Correction, GardSelection, GardState, TextblockMap, Transaction };