@flighthq/command 0.5.1-next.815.cc08b93 → 0.5.1-next.903.f434bc2
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/README.md +2 -2
- package/dist/command.d.ts +5 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +57 -26
- package/dist/command.js.map +1 -1
- package/dist/commandBinding.d.ts +2 -1
- package/dist/commandBinding.d.ts.map +1 -1
- package/dist/commandBinding.js +20 -17
- package/dist/commandBinding.js.map +1 -1
- package/dist/commandHistory.d.ts +3 -2
- package/dist/commandHistory.d.ts.map +1 -1
- package/dist/commandHistory.js +15 -12
- package/dist/commandHistory.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +1 -0
- package/dist/contract.js.map +1 -1
- package/package.json +6 -6
- package/src/commandBinding.test.ts +10 -2
- package/src/commandHistory.test.ts +5 -2
- package/src/commandHistorySignals.test.ts +19 -3
- package/src/explainCommandDispatch.test.ts +39 -5
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/command`. The `@flig
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/command@0.5.1-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/command@0.5.1-next.903.f434bc2](https://github.com/flighthq/flight/tree/f434bc233778d75aeea61995df3a8cfaec459a85/packages/command)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/f434bc233778d75aeea61995df3a8cfaec459a85/LICENSE.md)
|
package/dist/command.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AddNodeChildCommand, Command, CompositeCommand, NodeAny, RemoveNodeChildCommand, ReorderNodeChildCommand, SetNodePropertyCommand } from '@flighthq/types/contract';
|
|
1
|
+
import type { AddNodeChildCommand, Command, CompositeCommand, EntityConstruction, NodeAny, RemoveNodeChildCommand, ReorderNodeChildCommand, SetNodePropertyCommand } from '@flighthq/types/contract';
|
|
2
2
|
/** Adds `child` to `parent`. `index` of `-1` appends. */
|
|
3
3
|
export declare function createAddNodeChildCommand(label: string, parent: NodeAny, child: NodeAny, index?: number): AddNodeChildCommand;
|
|
4
4
|
/** Applies `children` as one history entry, in order; undo runs them in reverse. Nesting is allowed. */
|
|
@@ -11,4 +11,8 @@ export declare function createSetNodePropertyCommandBatch(label: string, entries
|
|
|
11
11
|
target: NodeAny;
|
|
12
12
|
value: unknown;
|
|
13
13
|
}>[], mergeWindow?: number, time?: number): SetNodePropertyCommand;
|
|
14
|
+
export declare function initializeAddNodeChildCommand(out: EntityConstruction<AddNodeChildCommand>, label: string, parent: NodeAny, child: NodeAny, index: number): void;
|
|
15
|
+
export declare function initializeCompositeCommand(out: EntityConstruction<CompositeCommand>, label: string, children: readonly Command[]): void;
|
|
16
|
+
export declare function initializeRemoveNodeChildCommand(out: EntityConstruction<RemoveNodeChildCommand>, label: string, parent: NodeAny, child: NodeAny): void;
|
|
17
|
+
export declare function initializeReorderNodeChildCommand(out: EntityConstruction<ReorderNodeChildCommand>, label: string, parent: NodeAny, child: NodeAny, toIndex: number): void;
|
|
14
18
|
//# sourceMappingURL=command.d.ts.map
|
package/dist/command.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EACnB,OAAO,EAEP,gBAAgB,EAChB,OAAO,EACP,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAiBlC,yDAAyD;AACzD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAA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,6BAA6B,CAC3C,GAAG,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,EAC5C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,IAAI,CAMN;AAED,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,EACzC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,SAAS,OAAO,EAAE,GAC3B,IAAI,CAIN;AAED,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,EAC/C,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,OAAO,GACb,IAAI,CAMN;AAED,wBAAgB,iCAAiC,CAC/C,GAAG,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,EAChD,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,GACd,IAAI,CAON"}
|
package/dist/command.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { getNodeChildIndex } from '@flighthq/node/contract';
|
|
3
3
|
import { AddNodeChildCommandKind, CompositeCommandKind, RemoveNodeChildCommandKind, ReorderNodeChildCommandKind, SetNodePropertyCommandKind, } from '@flighthq/types/contract';
|
|
4
4
|
// Constructors for the built-in command kinds. Each returns PLAIN DATA — no method, no captured closure —
|
|
@@ -10,33 +10,28 @@ import { AddNodeChildCommandKind, CompositeCommandKind, RemoveNodeChildCommandKi
|
|
|
10
10
|
// command BEFORE applying the change by hand.
|
|
11
11
|
/** Adds `child` to `parent`. `index` of `-1` appends. */
|
|
12
12
|
export function createAddNodeChildCommand(label, parent, child, index = -1) {
|
|
13
|
-
|
|
13
|
+
const out = allocateEntity();
|
|
14
|
+
initializeAddNodeChildCommand(out, label, parent, child, index);
|
|
15
|
+
return finishEntity(out);
|
|
14
16
|
}
|
|
15
17
|
/** Applies `children` as one history entry, in order; undo runs them in reverse. Nesting is allowed. */
|
|
16
18
|
export function createCompositeCommand(label, children) {
|
|
17
|
-
|
|
19
|
+
const out = allocateEntity();
|
|
20
|
+
initializeCompositeCommand(out, label, children);
|
|
21
|
+
return finishEntity(out);
|
|
18
22
|
}
|
|
19
23
|
// Removes `child` from `parent`, capturing its CURRENT index so undo restores position and not merely
|
|
20
24
|
// membership. Build this before removing the child — once it is detached the index is gone.
|
|
21
25
|
export function createRemoveNodeChildCommand(label, parent, child) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
kind: RemoveNodeChildCommandKind,
|
|
26
|
-
label,
|
|
27
|
-
parent,
|
|
28
|
-
});
|
|
26
|
+
const out = allocateEntity();
|
|
27
|
+
initializeRemoveNodeChildCommand(out, label, parent, child);
|
|
28
|
+
return finishEntity(out);
|
|
29
29
|
}
|
|
30
30
|
// Moves `child` to `toIndex`, capturing where it started. Build this before moving the child.
|
|
31
31
|
export function createReorderNodeChildCommand(label, parent, child, toIndex) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
kind: ReorderNodeChildCommandKind,
|
|
36
|
-
label,
|
|
37
|
-
parent,
|
|
38
|
-
toIndex,
|
|
39
|
-
});
|
|
32
|
+
const out = allocateEntity();
|
|
33
|
+
initializeReorderNodeChildCommand(out, label, parent, child, toIndex);
|
|
34
|
+
return finishEntity(out);
|
|
40
35
|
}
|
|
41
36
|
// One property assignment. `before` is read from the node NOW, so build this before writing the value.
|
|
42
37
|
//
|
|
@@ -45,13 +40,9 @@ export function createReorderNodeChildCommand(label, parent, child, toIndex) {
|
|
|
45
40
|
// undo entry. Both default to 0, meaning every change is its own entry. `time` is supplied by the caller
|
|
46
41
|
// because this package takes no clock dependency — and a caller-supplied number stays serializable.
|
|
47
42
|
export function createSetNodePropertyCommand(label, target, property, value, mergeWindow = 0, time = 0) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
label,
|
|
52
|
-
mergeWindow,
|
|
53
|
-
time,
|
|
54
|
-
});
|
|
43
|
+
const out = allocateEntity();
|
|
44
|
+
initializeSetNodePropertyCommand(out, label, target, property, value, mergeWindow, time);
|
|
45
|
+
return finishEntity(out);
|
|
55
46
|
}
|
|
56
47
|
// Several property assignments applied together as one entry — the shape a gizmo drag produces when it
|
|
57
48
|
// writes x and y at once. Each `before` is read now, in the order given.
|
|
@@ -62,7 +53,47 @@ export function createSetNodePropertyCommandBatch(label, entries, mergeWindow =
|
|
|
62
53
|
property: entry.property,
|
|
63
54
|
target: entry.target,
|
|
64
55
|
}));
|
|
65
|
-
|
|
56
|
+
const out = allocateEntity();
|
|
57
|
+
out.entries = captured;
|
|
58
|
+
out.kind = SetNodePropertyCommandKind;
|
|
59
|
+
out.label = label;
|
|
60
|
+
out.mergeWindow = mergeWindow;
|
|
61
|
+
out.time = time;
|
|
62
|
+
return finishEntity(out);
|
|
63
|
+
}
|
|
64
|
+
export function initializeAddNodeChildCommand(out, label, parent, child, index) {
|
|
65
|
+
out.child = child;
|
|
66
|
+
out.index = index;
|
|
67
|
+
out.kind = AddNodeChildCommandKind;
|
|
68
|
+
out.label = label;
|
|
69
|
+
out.parent = parent;
|
|
70
|
+
}
|
|
71
|
+
export function initializeCompositeCommand(out, label, children) {
|
|
72
|
+
out.children = [...children];
|
|
73
|
+
out.kind = CompositeCommandKind;
|
|
74
|
+
out.label = label;
|
|
75
|
+
}
|
|
76
|
+
export function initializeRemoveNodeChildCommand(out, label, parent, child) {
|
|
77
|
+
out.child = child;
|
|
78
|
+
out.index = getNodeChildIndex(parent, child);
|
|
79
|
+
out.kind = RemoveNodeChildCommandKind;
|
|
80
|
+
out.label = label;
|
|
81
|
+
out.parent = parent;
|
|
82
|
+
}
|
|
83
|
+
export function initializeReorderNodeChildCommand(out, label, parent, child, toIndex) {
|
|
84
|
+
out.child = child;
|
|
85
|
+
out.fromIndex = getNodeChildIndex(parent, child);
|
|
86
|
+
out.kind = ReorderNodeChildCommandKind;
|
|
87
|
+
out.label = label;
|
|
88
|
+
out.parent = parent;
|
|
89
|
+
out.toIndex = toIndex;
|
|
90
|
+
}
|
|
91
|
+
function initializeSetNodePropertyCommand(out, label, target, property, value, mergeWindow, time) {
|
|
92
|
+
out.entries = [{ after: value, before: readNodeProperty(target, property), property, target }];
|
|
93
|
+
out.kind = SetNodePropertyCommandKind;
|
|
94
|
+
out.label = label;
|
|
95
|
+
out.mergeWindow = mergeWindow;
|
|
96
|
+
out.time = time;
|
|
66
97
|
}
|
|
67
98
|
function readNodeProperty(target, property) {
|
|
68
99
|
return target[property];
|
package/dist/command.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAY5D,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAElC,0GAA0G;AAC1G,sGAAsG;AACtG,2FAA2F;AAC3F,EAAE;AACF,2GAA2G;AAC3G,2GAA2G;AAC3G,8CAA8C;AAE9C,yDAAyD;AACzD,MAAM,UAAU,yBAAyB,CACvC,KAAa,EACb,MAAe,EACf,KAAc,EACd,KAAK,GAAG,CAAC,CAAC;IAEV,MAAM,GAAG,GAAG,cAAc,EAAuB,CAAC;IAClD,6BAA6B,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE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CAAC;AAED,SAAS,gBAAgB,CAAC,MAAyB,EAAE,QAAgB;IACnE,OAAQ,MAAuD,CAAC,QAAQ,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/commandBinding.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { CommandBinding, CommandBindingTable, CommandHistory, Kind } from '@flighthq/types/contract';
|
|
1
|
+
import type { CommandBinding, CommandBindingTable, CommandHistory, EntityConstruction, Kind, SetNodePropertyCommand } from '@flighthq/types/contract';
|
|
2
2
|
/** An empty command binding table. Every kind a history will dispatch must be registered into it. */
|
|
3
3
|
export declare function createCommandBindingTable(): CommandBindingTable;
|
|
4
4
|
/** The binding registered for `kind`, or `null` when nothing is. */
|
|
5
5
|
export declare function getCommandBinding(history: Readonly<CommandHistory>, kind: Kind): CommandBinding | null;
|
|
6
6
|
export declare function hasCommandBinding(history: Readonly<CommandHistory>, kind: Kind): boolean;
|
|
7
|
+
export declare function initializeSetNodePropertyCommand(out: EntityConstruction<SetNodePropertyCommand>, entries: SetNodePropertyCommand['entries'], kind: Kind, label: string, mergeWindow: number, time: number): void;
|
|
7
8
|
export declare function registerCommandBinding(history: CommandHistory, kind: Kind, binding: CommandBinding): void;
|
|
8
9
|
export declare function registerDefaultCommandBindings(history: CommandHistory): void;
|
|
9
10
|
//# sourceMappingURL=commandBinding.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandBinding.d.ts","sourceRoot":"","sources":["../src/commandBinding.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,cAAc,EACd,mBAAmB,EACnB,cAAc,
|
|
1
|
+
{"version":3,"file":"commandBinding.d.ts","sourceRoot":"","sources":["../src/commandBinding.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,cAAc,EACd,mBAAmB,EACnB,cAAc,EAEd,kBAAkB,EAClB,IAAI,EAIJ,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAWlC,qGAAqG;AACrG,wBAAgB,yBAAyB,IAAI,mBAAmB,CAE/D;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,cAAc,GAAG,IAAI,CAEtG;AAKD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAExF;AAID,wBAAgB,gCAAgC,CAC9C,GAAG,EAAE,kBAAkB,CAAC,sBAAsB,CAAC,EAC/C,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,EAC1C,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,IAAI,CAMN;AAKD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAEzG;AAED,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAM5E"}
|
package/dist/commandBinding.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { addNodeChildAt, getNodeChildCount, removeNodeChild, setNodeChildIndex } from '@flighthq/node/contract';
|
|
3
3
|
import { createKeyedTable, getRegistryTableEntry, withRegistryTableEntry } from '@flighthq/registry/contract';
|
|
4
4
|
import { AddNodeChildCommandKind, CommandBindingMissPolicy, CommandBindingRegistryId, CompositeCommandKind, RemoveNodeChildCommandKind, ReorderNodeChildCommandKind, SetNodePropertyCommandKind, } from '@flighthq/types/contract';
|
|
5
5
|
/** An empty command binding table. Every kind a history will dispatch must be registered into it. */
|
|
6
6
|
export function createCommandBindingTable() {
|
|
7
|
-
return
|
|
7
|
+
return createKeyedTable(CommandBindingRegistryId, CommandBindingMissPolicy);
|
|
8
8
|
}
|
|
9
9
|
/** The binding registered for `kind`, or `null` when nothing is. */
|
|
10
10
|
export function getCommandBinding(history, kind) {
|
|
@@ -16,14 +16,21 @@ export function getCommandBinding(history, kind) {
|
|
|
16
16
|
export function hasCommandBinding(history, kind) {
|
|
17
17
|
return getCommandBinding(history, kind) !== null;
|
|
18
18
|
}
|
|
19
|
+
// Registers the five built-in kinds. An explicit call rather than a side effect at import: a history that
|
|
20
|
+
// only dispatches a caller's own kinds never references these, so they shake out of the bundle.
|
|
21
|
+
export function initializeSetNodePropertyCommand(out, entries, kind, label, mergeWindow, time) {
|
|
22
|
+
out.entries = entries;
|
|
23
|
+
out.kind = kind;
|
|
24
|
+
out.label = label;
|
|
25
|
+
out.mergeWindow = mergeWindow;
|
|
26
|
+
out.time = time;
|
|
27
|
+
}
|
|
19
28
|
// Binds behaviour to a command kind. NOT called at module load anywhere in this package — a caller opts
|
|
20
29
|
// in, which is what keeps unused command kinds shakeable and lets a consumer override a built-in binding
|
|
21
30
|
// or add a vendor-prefixed kind of their own. Last write wins.
|
|
22
31
|
export function registerCommandBinding(history, kind, binding) {
|
|
23
|
-
history.bindings =
|
|
32
|
+
history.bindings = withRegistryTableEntry(history.bindings, kind, binding);
|
|
24
33
|
}
|
|
25
|
-
// Registers the five built-in kinds. An explicit call rather than a side effect at import: a history that
|
|
26
|
-
// only dispatches a caller's own kinds never references these, so they shake out of the bundle.
|
|
27
34
|
export function registerDefaultCommandBindings(history) {
|
|
28
35
|
registerCommandBinding(history, AddNodeChildCommandKind, addNodeChildCommandBinding);
|
|
29
36
|
registerCommandBinding(history, CompositeCommandKind, compositeCommandBinding(history));
|
|
@@ -113,18 +120,14 @@ const setNodePropertyCommandBinding = {
|
|
|
113
120
|
if (a.entries[i].property !== b.entries[i].property)
|
|
114
121
|
return null;
|
|
115
122
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
label: b.label,
|
|
125
|
-
mergeWindow: b.mergeWindow,
|
|
126
|
-
time: b.time,
|
|
127
|
-
});
|
|
123
|
+
const out = allocateEntity();
|
|
124
|
+
initializeSetNodePropertyCommand(out, a.entries.map((entry, i) => ({
|
|
125
|
+
after: b.entries[i].after,
|
|
126
|
+
before: entry.before,
|
|
127
|
+
property: entry.property,
|
|
128
|
+
target: entry.target,
|
|
129
|
+
})), a.kind, b.label, b.mergeWindow, b.time);
|
|
130
|
+
return finishEntity(out);
|
|
128
131
|
},
|
|
129
132
|
undo: (command) => {
|
|
130
133
|
const entries = command.entries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandBinding.js","sourceRoot":"","sources":["../src/commandBinding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"commandBinding.js","sourceRoot":"","sources":["../src/commandBinding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAChH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAc9G,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,0BAA0B,CAAC;AAElC,qGAAqG;AACrG,MAAM,UAAU,yBAAyB;IACvC,OAAO,gBAAgB,CAAiB,wBAAwB,EAAE,wBAAwB,CAAC,CAAC;AAC9F,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,iBAAiB,CAAC,OAAiC,EAAE,IAAU;IAC7E,OAAO,qBAAqB,CAAC,OAAO,CAAC,QAAQ,EA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
|
-
import type { Command, CommandHistory } from '@flighthq/types/contract';
|
|
1
|
+
import type { Command, CommandHistory, EntityConstruction } from '@flighthq/types/contract';
|
|
2
2
|
/** Whether there is an applied entry to reverse. */
|
|
3
3
|
export declare function canRedoCommand(history: Readonly<CommandHistory>): boolean;
|
|
4
4
|
/** Whether there is a reversed entry ahead of the cursor to re-apply. */
|
|
5
5
|
export declare function canUndoCommand(history: Readonly<CommandHistory>): boolean;
|
|
6
6
|
export declare function clearCommandHistory(history: CommandHistory): void;
|
|
7
|
-
/** An empty history with no bindings registered. `maxSize` of `0` (the default) is unbounded. */
|
|
8
7
|
export declare function createCommandHistory(maxSize?: number): CommandHistory;
|
|
9
8
|
export declare function executeCommand(history: CommandHistory, command: Command): boolean;
|
|
10
9
|
/** Every entry, oldest first, including the reversed ones ahead of the cursor. */
|
|
@@ -15,6 +14,8 @@ export declare function getCommandHistoryIndex(history: Readonly<CommandHistory>
|
|
|
15
14
|
export declare function getCommandHistoryRedoLabel(history: Readonly<CommandHistory>): string | null;
|
|
16
15
|
/** The label of the entry undo would reverse, or null. */
|
|
17
16
|
export declare function getCommandHistoryUndoLabel(history: Readonly<CommandHistory>): string | null;
|
|
17
|
+
/** An empty history with no bindings registered. `maxSize` of `0` (the default) is unbounded. */
|
|
18
|
+
export declare function initializeCommandHistory(out: EntityConstruction<CommandHistory>, maxSize?: number): void;
|
|
18
19
|
export declare function notifyCommandHistoryChanged(history: Readonly<CommandHistory>): void;
|
|
19
20
|
export declare function redoCommand(history: CommandHistory): boolean;
|
|
20
21
|
/** Reverses the most recently applied entry. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandHistory.d.ts","sourceRoot":"","sources":["../src/commandHistory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"commandHistory.d.ts","sourceRoot":"","sources":["../src/commandHistory.ts"],"names":[],"mappings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AAO,EAAE,cAAc,GAAG,OAAO,CAS5D"}
|
package/dist/commandHistory.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { emitSignal } from '@flighthq/signals/contract';
|
|
3
3
|
import { createCommandBindingTable, getCommandBinding } from './commandBinding';
|
|
4
4
|
/** Whether there is an applied entry to reverse. */
|
|
@@ -21,18 +21,10 @@ export function clearCommandHistory(history) {
|
|
|
21
21
|
history.transactionLabel = null;
|
|
22
22
|
notifyCommandHistoryChanged(history);
|
|
23
23
|
}
|
|
24
|
-
/** An empty history with no bindings registered. `maxSize` of `0` (the default) is unbounded. */
|
|
25
24
|
export function createCommandHistory(maxSize = 0) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
index: 0,
|
|
30
|
-
maxSize,
|
|
31
|
-
onChange: null,
|
|
32
|
-
transactionDepth: 0,
|
|
33
|
-
transactionIndex: 0,
|
|
34
|
-
transactionLabel: null,
|
|
35
|
-
});
|
|
25
|
+
const out = allocateEntity();
|
|
26
|
+
initializeCommandHistory(out, maxSize);
|
|
27
|
+
return finishEntity(out);
|
|
36
28
|
}
|
|
37
29
|
// Applies `command` and pushes it. Returns false and changes nothing when the command's kind has no
|
|
38
30
|
// registered binding — an unregistered kind is an expected lookup failure, so it takes a sentinel rather
|
|
@@ -81,6 +73,17 @@ export function getCommandHistoryRedoLabel(history) {
|
|
|
81
73
|
export function getCommandHistoryUndoLabel(history) {
|
|
82
74
|
return canUndoCommand(history) ? history.entries[history.index - 1].label : null;
|
|
83
75
|
}
|
|
76
|
+
/** An empty history with no bindings registered. `maxSize` of `0` (the default) is unbounded. */
|
|
77
|
+
export function initializeCommandHistory(out, maxSize = 0) {
|
|
78
|
+
out.bindings = createCommandBindingTable();
|
|
79
|
+
out.entries = [];
|
|
80
|
+
out.index = 0;
|
|
81
|
+
out.maxSize = maxSize;
|
|
82
|
+
out.onChange = null;
|
|
83
|
+
out.transactionDepth = 0;
|
|
84
|
+
out.transactionIndex = 0;
|
|
85
|
+
out.transactionLabel = null;
|
|
86
|
+
}
|
|
84
87
|
// Emits the opt-in change signal if a caller allocated one. Internal rather than exported: emitting a
|
|
85
88
|
// change nobody made is how a history panel learns to distrust the signal.
|
|
86
89
|
export function notifyCommandHistoryChanged(history) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandHistory.js","sourceRoot":"","sources":["../src/commandHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"commandHistory.js","sourceRoot":"","sources":["../src/commandHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,oDAAoD;AACpD,MAAM,UAAU,cAAc,CAAC,OAAiC;IAC9D,OAAO,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;AAChD,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,cAAc,CAAC,OAAiC;IAC9D,OAAO,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,sGAAsG;AACtG,yFAAyF;AACzF,MAAM,UAAU,mBAAmB,CAAC,OAAuB;IACzD,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,KAAK,CAAC;QAAE,OAAO;IAChE,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;IAClB,OAAO,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,g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O,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,EAAE,CAAC;IAChB,2BAA2B,CAAC,OAAO,CAAC,CAAC;IACrC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,2GAA2G;AAC3G,oEAAoE;AACpE,SAAS,kBAAkB,CAAC,OAAuB;IACjD,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO;QAAE,OAAO;IAC9E,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IACxD,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAClC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;IACpD,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,gBAAgB,GAAG,MAAM,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/contract.d.ts
CHANGED
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/contract.js
CHANGED
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/command",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.903.f434bc2",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/entity": "0.5.1-next.
|
|
42
|
-
"@flighthq/node": "0.5.1-next.
|
|
43
|
-
"@flighthq/registry": "0.5.1-next.
|
|
44
|
-
"@flighthq/signals": "0.5.1-next.
|
|
45
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.903.f434bc2",
|
|
42
|
+
"@flighthq/node": "0.5.1-next.903.f434bc2",
|
|
43
|
+
"@flighthq/registry": "0.5.1-next.903.f434bc2",
|
|
44
|
+
"@flighthq/signals": "0.5.1-next.903.f434bc2",
|
|
45
|
+
"@flighthq/types": "0.5.1-next.903.f434bc2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"typescript": "^5.3.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { addNodeChild, createNode, getNodeChildCount, getNodeChildIndex } from '@flighthq/node/contract';
|
|
3
3
|
import type { CommandBinding, NodeAny, SetNodePropertyCommand } from '@flighthq/types/contract';
|
|
4
4
|
import { SetNodePropertyCommandKind } from '@flighthq/types/contract';
|
|
@@ -50,7 +50,15 @@ describe('registerCommandBinding', () => {
|
|
|
50
50
|
execute: () => seen.push('execute'),
|
|
51
51
|
undo: () => seen.push('undo'),
|
|
52
52
|
});
|
|
53
|
-
executeCommand(
|
|
53
|
+
executeCommand(
|
|
54
|
+
history,
|
|
55
|
+
(() => {
|
|
56
|
+
const out = allocateEntity<any>();
|
|
57
|
+
out.kind = 'acme.Custom';
|
|
58
|
+
out.label = 'Custom';
|
|
59
|
+
return finishEntity(out);
|
|
60
|
+
})(),
|
|
61
|
+
);
|
|
54
62
|
undoCommand(history);
|
|
55
63
|
expect(seen).toEqual(['execute', 'undo']);
|
|
56
64
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { createNode, getNodeChildCount } from '@flighthq/node/contract';
|
|
3
3
|
import { connectSignal } from '@flighthq/signals/contract';
|
|
4
4
|
import type { Command, CommandHistory, NodeAny } from '@flighthq/types/contract';
|
|
@@ -187,7 +187,10 @@ function counter(label: string): Command {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
function command(kind: string, label: string): Command {
|
|
190
|
-
|
|
190
|
+
const out = allocateEntity<Command>();
|
|
191
|
+
out.kind = kind;
|
|
192
|
+
out.label = label;
|
|
193
|
+
return finishEntity(out);
|
|
191
194
|
}
|
|
192
195
|
|
|
193
196
|
// A history bound to one inert kind, so stack behaviour can be tested without any graph mutation.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { connectSignal } from '@flighthq/signals/contract';
|
|
3
3
|
import { describe, expect, it } from 'vitest';
|
|
4
4
|
|
|
@@ -20,7 +20,15 @@ describe('enableCommandHistorySignals', () => {
|
|
|
20
20
|
let changes = 0;
|
|
21
21
|
connectSignal(enableCommandHistorySignals(history), () => changes++);
|
|
22
22
|
|
|
23
|
-
executeCommand(
|
|
23
|
+
executeCommand(
|
|
24
|
+
history,
|
|
25
|
+
(() => {
|
|
26
|
+
const out = allocateEntity<any>();
|
|
27
|
+
out.kind = 'test.Counter';
|
|
28
|
+
out.label = 'One';
|
|
29
|
+
return finishEntity(out);
|
|
30
|
+
})(),
|
|
31
|
+
);
|
|
24
32
|
expect(changes).toBe(1);
|
|
25
33
|
undoCommand(history);
|
|
26
34
|
expect(changes).toBe(2);
|
|
@@ -31,7 +39,15 @@ describe('enableCommandHistorySignals', () => {
|
|
|
31
39
|
const history = createCommandHistory();
|
|
32
40
|
let changes = 0;
|
|
33
41
|
connectSignal(enableCommandHistorySignals(history), () => changes++);
|
|
34
|
-
executeCommand(
|
|
42
|
+
executeCommand(
|
|
43
|
+
history,
|
|
44
|
+
(() => {
|
|
45
|
+
const out = allocateEntity<any>();
|
|
46
|
+
out.kind = 'acme.Unbound';
|
|
47
|
+
out.label = 'Nope';
|
|
48
|
+
return finishEntity(out);
|
|
49
|
+
})(),
|
|
50
|
+
);
|
|
35
51
|
expect(changes).toBe(0);
|
|
36
52
|
});
|
|
37
53
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
2
|
import { describe, expect, it } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { createCompositeCommand } from './command';
|
|
@@ -9,7 +9,17 @@ import { explainCommandDispatch } from './explainCommandDispatch';
|
|
|
9
9
|
describe('explainCommandDispatch', () => {
|
|
10
10
|
it('names the unregistered kind behind a refusal', () => {
|
|
11
11
|
const history = createCommandHistory();
|
|
12
|
-
expect(
|
|
12
|
+
expect(
|
|
13
|
+
explainCommandDispatch(
|
|
14
|
+
history,
|
|
15
|
+
(() => {
|
|
16
|
+
const out = allocateEntity<any>();
|
|
17
|
+
out.kind = 'acme.Unbound';
|
|
18
|
+
out.label = 'Nope';
|
|
19
|
+
return finishEntity(out);
|
|
20
|
+
})(),
|
|
21
|
+
),
|
|
22
|
+
).toEqual({
|
|
13
23
|
missingKind: 'acme.Unbound',
|
|
14
24
|
resolved: false,
|
|
15
25
|
});
|
|
@@ -18,7 +28,17 @@ describe('explainCommandDispatch', () => {
|
|
|
18
28
|
it('resolves when the kind is registered', () => {
|
|
19
29
|
const history = createCommandHistory();
|
|
20
30
|
registerCommandBinding(history, 'acme.Bound', { execute: () => undefined, undo: () => undefined });
|
|
21
|
-
expect(
|
|
31
|
+
expect(
|
|
32
|
+
explainCommandDispatch(
|
|
33
|
+
history,
|
|
34
|
+
(() => {
|
|
35
|
+
const out = allocateEntity<any>();
|
|
36
|
+
out.kind = 'acme.Bound';
|
|
37
|
+
out.label = 'Yes';
|
|
38
|
+
return finishEntity(out);
|
|
39
|
+
})(),
|
|
40
|
+
),
|
|
41
|
+
).toEqual({
|
|
22
42
|
missingKind: null,
|
|
23
43
|
resolved: true,
|
|
24
44
|
});
|
|
@@ -29,7 +49,14 @@ describe('explainCommandDispatch', () => {
|
|
|
29
49
|
it('descends into a composite and names an unbound child kind', () => {
|
|
30
50
|
const history = createCommandHistory();
|
|
31
51
|
registerCommandBinding(history, 'CompositeCommand', { execute: () => undefined, undo: () => undefined });
|
|
32
|
-
const composite = createCompositeCommand('Group', [
|
|
52
|
+
const composite = createCompositeCommand('Group', [
|
|
53
|
+
(() => {
|
|
54
|
+
const out = allocateEntity<any>();
|
|
55
|
+
out.kind = 'acme.Unbound';
|
|
56
|
+
out.label = 'Child';
|
|
57
|
+
return finishEntity(out);
|
|
58
|
+
})(),
|
|
59
|
+
]);
|
|
33
60
|
expect(explainCommandDispatch(history, composite).missingKind).toBe('acme.Unbound');
|
|
34
61
|
});
|
|
35
62
|
|
|
@@ -37,7 +64,14 @@ describe('explainCommandDispatch', () => {
|
|
|
37
64
|
const history = createCommandHistory();
|
|
38
65
|
registerCommandBinding(history, 'CompositeCommand', { execute: () => undefined, undo: () => undefined });
|
|
39
66
|
registerCommandBinding(history, 'acme.Bound', { execute: () => undefined, undo: () => undefined });
|
|
40
|
-
const composite = createCompositeCommand('Group', [
|
|
67
|
+
const composite = createCompositeCommand('Group', [
|
|
68
|
+
(() => {
|
|
69
|
+
const out = allocateEntity<any>();
|
|
70
|
+
out.kind = 'acme.Bound';
|
|
71
|
+
out.label = 'Child';
|
|
72
|
+
return finishEntity(out);
|
|
73
|
+
})(),
|
|
74
|
+
]);
|
|
41
75
|
expect(explainCommandDispatch(history, composite).resolved).toBe(true);
|
|
42
76
|
});
|
|
43
77
|
});
|