@nerd-bible/wordgard 0.6.2-beta1 → 0.6.2-beta11
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/collab.js +3 -0
- package/dist/command.d.ts +15 -7
- package/dist/command.js +27 -8
- package/dist/doc.d.ts +14 -3
- package/dist/doc.js +98 -47
- package/dist/editor.d.ts +25 -10
- package/dist/editor.js +351 -205
- package/dist/history.js +7 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/phrases.js +1 -0
- package/dist/schema.js +13 -10
- package/dist/set.d.ts +3 -2
- package/dist/set.js +27 -13
- package/dist/state.d.ts +52 -7
- package/dist/state.js +92 -34
- package/dist/table.d.ts +111 -1
- package/dist/table.js +32 -22
- package/package.json +1 -1
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
|
|
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
|
|
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
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))
|
|
@@ -808,7 +809,7 @@ function figure(conf = {}) {
|
|
|
808
809
|
function imageResizing() {
|
|
809
810
|
return [GardState.schemaElement.of(ImageSize), imageResizing.keyBindings, imageResizing.dragHandle];
|
|
810
811
|
}
|
|
811
|
-
const
|
|
812
|
+
const resizeStyle = /*@__PURE__*/Wordgard.styles({
|
|
812
813
|
".wg-resize-hover": {
|
|
813
814
|
display: "inline-block",
|
|
814
815
|
lineHeight: "0.1",
|
|
@@ -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) {
|
|
@@ -936,7 +939,7 @@ const resizeHandlers = /*@__PURE__*/(() => [
|
|
|
936
939
|
GardState.prec.high(resizeHandlers),
|
|
937
940
|
resizeState,
|
|
938
941
|
Decoration.Point.source.of(s => s.field(resizeState).deco),
|
|
939
|
-
|
|
942
|
+
resizeStyle
|
|
940
943
|
];
|
|
941
944
|
;return imageResizing})(imageResizing);
|
|
942
945
|
;image = /*@__PURE__*/(function (image) {
|
|
@@ -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
|
|
1417
|
-
if (
|
|
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.d.ts
CHANGED
|
@@ -195,9 +195,10 @@ declare class PointSet<T extends PointSet.Value> implements Set<T> {
|
|
|
195
195
|
/**
|
|
196
196
|
Get the value at the given position, if any. If there's multiple
|
|
197
197
|
values at that position, the one with the lowest side is
|
|
198
|
-
returned.
|
|
198
|
+
returned. If a predicate is given, only points that satisfy it
|
|
199
|
+
are returned.
|
|
199
200
|
*/
|
|
200
|
-
at(pos: number): T | undefined;
|
|
201
|
+
at(pos: number, pred?: (value: T) => boolean): T | undefined;
|
|
201
202
|
/**
|
|
202
203
|
Adjust the points for a set of document changes. Returns a new
|
|
203
204
|
set with the adjusted points. May delete points when the content
|
package/dist/set.js
CHANGED
|
@@ -137,6 +137,7 @@ let SetBuilder$1 = class SetBuilder {
|
|
|
137
137
|
spilled = null;
|
|
138
138
|
lastTo = -1;
|
|
139
139
|
lastFrom = -1;
|
|
140
|
+
closed = false;
|
|
140
141
|
get next() {
|
|
141
142
|
return this.spilled || (this.spilled = new SetBuilder());
|
|
142
143
|
}
|
|
@@ -147,6 +148,7 @@ let SetBuilder$1 = class SetBuilder {
|
|
|
147
148
|
else {
|
|
148
149
|
this.chunks.push(chunk);
|
|
149
150
|
this.lastTo = chunk.end;
|
|
151
|
+
this.closed = true;
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
add(source, pre) {
|
|
@@ -164,17 +166,22 @@ let SetBuilder$1 = class SetBuilder {
|
|
|
164
166
|
addRange(value, from, to) {
|
|
165
167
|
if (from >= to)
|
|
166
168
|
throw new Error("Ranges cannot be empty");
|
|
167
|
-
(
|
|
169
|
+
for (let target = this;; target = target.next)
|
|
170
|
+
if (target.lastTo <= from) {
|
|
171
|
+
target.addInner(value, from, to);
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
168
174
|
}
|
|
169
175
|
addInner(value, from, to) {
|
|
170
176
|
let chunk;
|
|
171
|
-
if (this.chunks.length) {
|
|
177
|
+
if (this.chunks.length && !this.closed) {
|
|
172
178
|
chunk = this.chunks[this.chunks.length - 1];
|
|
173
179
|
if (chunk.value.length >= 512)
|
|
174
180
|
chunk = undefined;
|
|
175
181
|
}
|
|
176
182
|
if (!chunk) {
|
|
177
183
|
this.chunks.push(chunk = new Chunk$1(from, [], [], []));
|
|
184
|
+
this.closed = false;
|
|
178
185
|
}
|
|
179
186
|
chunk.from.push(from - chunk.start);
|
|
180
187
|
chunk.to.push(to - chunk.start);
|
|
@@ -246,13 +253,13 @@ class RangeSet extends Set {
|
|
|
246
253
|
let replI = 0, posA = 0, posB = 0;
|
|
247
254
|
let build = new SetBuilder$1();
|
|
248
255
|
for (let i = 0; i < sections.length;) {
|
|
249
|
-
let len = sections[i++], ins = sections[i++];
|
|
256
|
+
let len = sections[i++], ins = sections[i++], endA = posA + len;
|
|
250
257
|
if (ins < 0) {
|
|
251
258
|
while (i < sections.length && sections[i + 1] < 0) {
|
|
252
259
|
len += sections[i];
|
|
253
260
|
i += 2;
|
|
254
261
|
}
|
|
255
|
-
let upto = i == sections.length ? 1e9 :
|
|
262
|
+
let upto = i == sections.length ? 1e9 : endA, off = posB - posA;
|
|
256
263
|
while (cursor.cur) {
|
|
257
264
|
let chunk = cursor.cur;
|
|
258
265
|
if (cursor.i == 0 && chunk.end < upto) {
|
|
@@ -277,12 +284,12 @@ class RangeSet extends Set {
|
|
|
277
284
|
if (repl.add)
|
|
278
285
|
build.add(repl.add);
|
|
279
286
|
}
|
|
280
|
-
if (len)
|
|
281
|
-
cursor.goto(
|
|
282
|
-
copyMappedUpto$1(cursor,
|
|
287
|
+
if (len && cursor.to < endA)
|
|
288
|
+
cursor.goto(endA - 1);
|
|
289
|
+
copyMappedUpto$1(cursor, endA, map, build, replace, replStartI);
|
|
283
290
|
posB = endB;
|
|
284
291
|
}
|
|
285
|
-
posA
|
|
292
|
+
posA = endA;
|
|
286
293
|
}
|
|
287
294
|
return build.finish(this.next && this.next.mapInner(sections, map, replace));
|
|
288
295
|
}
|
|
@@ -466,10 +473,12 @@ class SetBuilder {
|
|
|
466
473
|
chunks = [];
|
|
467
474
|
lastPos = -1;
|
|
468
475
|
lastSide = -1;
|
|
476
|
+
closed = false;
|
|
469
477
|
addChunk(chunk) {
|
|
470
478
|
this.chunks.push(chunk);
|
|
471
479
|
this.lastPos = chunk.end;
|
|
472
480
|
this.lastSide = chunk.endSide;
|
|
481
|
+
this.closed = true;
|
|
473
482
|
}
|
|
474
483
|
add(source, pre) {
|
|
475
484
|
if (typeof source != "function") {
|
|
@@ -487,13 +496,15 @@ class SetBuilder {
|
|
|
487
496
|
}
|
|
488
497
|
addPoint(value, pos) {
|
|
489
498
|
let chunk;
|
|
490
|
-
|
|
499
|
+
let wasClosed = this.closed;
|
|
500
|
+
if (this.chunks.length && !wasClosed) {
|
|
491
501
|
chunk = this.chunks[this.chunks.length - 1];
|
|
492
502
|
if (chunk.value.length >= 512)
|
|
493
503
|
chunk = undefined;
|
|
494
504
|
}
|
|
495
505
|
if (!chunk) {
|
|
496
506
|
this.chunks.push(chunk = new Chunk(pos, [], []));
|
|
507
|
+
this.closed = false;
|
|
497
508
|
}
|
|
498
509
|
chunk.pos.push(pos - chunk.start);
|
|
499
510
|
chunk.value.push(value);
|
|
@@ -508,6 +519,8 @@ class SetBuilder {
|
|
|
508
519
|
if (!chunkI)
|
|
509
520
|
break;
|
|
510
521
|
nextChunk = this.chunks[--chunkI];
|
|
522
|
+
if (wasClosed)
|
|
523
|
+
nextChunk = this.chunks[chunkI] = new Chunk(nextChunk.start, nextChunk.pos.slice(), nextChunk.value.slice());
|
|
511
524
|
nextI = nextChunk.value.length - 1;
|
|
512
525
|
}
|
|
513
526
|
if ((pos - nextChunk.pos[nextI] || value.side - nextChunk.value[nextI].side) >= 0)
|
|
@@ -556,15 +569,16 @@ class PointSet {
|
|
|
556
569
|
cursors.push(set.cursor(from, side));
|
|
557
570
|
return cursors.length == 0 ? PointSet.empty.cursor() : cursors.length == 1 ? cursors[0] : new HeapCursor(cmpCursor, cursors);
|
|
558
571
|
}
|
|
559
|
-
at(pos) {
|
|
572
|
+
at(pos, pred) {
|
|
560
573
|
for (let chunk of this.chunks) {
|
|
561
574
|
if (chunk.start > pos)
|
|
562
575
|
break;
|
|
563
576
|
if (chunk.end < pos)
|
|
564
577
|
continue;
|
|
565
|
-
let index = findAbove(chunk.pos, 0, pos - chunk.start - 1);
|
|
566
|
-
|
|
567
|
-
|
|
578
|
+
for (let index = findAbove(chunk.pos, 0, pos - chunk.start - 1); index < chunk.pos.length && chunk.pos[index] + chunk.start == pos; index++) {
|
|
579
|
+
if (!pred || pred(chunk.value[index]))
|
|
580
|
+
return chunk.value[index];
|
|
581
|
+
}
|
|
568
582
|
}
|
|
569
583
|
return undefined;
|
|
570
584
|
}
|
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
|
*/
|
|
@@ -492,7 +496,7 @@ declare namespace Transaction {
|
|
|
492
496
|
scrollIntoView?: boolean;
|
|
493
497
|
/**
|
|
494
498
|
Only meaningful for specs that are combined with another
|
|
495
|
-
transaction spec (via {@link Transaction.merge or by being
|
|
499
|
+
transaction spec (via {@link Transaction.merge} or by being
|
|
496
500
|
returned from an {@link Transaction.extender extender}.
|
|
497
501
|
Normally, when specs are combined, the positions in `changes`
|
|
498
502
|
are taken to refer to the document positions in the initial
|
|
@@ -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.
|
|
@@ -913,9 +930,9 @@ declare class GardState {
|
|
|
913
930
|
isAtom(type: Node.Type): boolean;
|
|
914
931
|
/**
|
|
915
932
|
Return the extent of the word around the given position, as a
|
|
916
|
-
text selection.
|
|
933
|
+
text selection, or null if there is no word there.
|
|
917
934
|
*/
|
|
918
|
-
wordAt(pos: number, bias?: -1 | 1): GardSelection.Text;
|
|
935
|
+
wordAt(pos: number, bias?: -1 | 1): GardSelection.Text | null;
|
|
919
936
|
/**
|
|
920
937
|
This effect can be used to reconfigure the root extensions of
|
|
921
938
|
the editor. Doing this will discard any extensions {@link
|
|
@@ -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}.
|