@benev/tact 0.1.0-2 → 0.1.0-3

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 (96) hide show
  1. package/README.md +120 -56
  2. package/package.json +3 -2
  3. package/s/core/{port → bindings}/action.ts +1 -1
  4. package/s/core/bindings/parts/defaults.ts +29 -0
  5. package/s/core/{port/resolution → bindings/parts}/lens-algo.ts +6 -7
  6. package/s/core/bindings/resolver.ts +96 -0
  7. package/s/core/bindings/types.ts +43 -42
  8. package/s/core/controllers/standard/gamepad.ts +1 -5
  9. package/s/core/controllers/standard/keyboard.ts +0 -3
  10. package/s/core/controllers/standard/pointer.ts +3 -9
  11. package/s/core/deck/deck.ts +40 -0
  12. package/s/core/deck/parts/bindings-depot.ts +24 -0
  13. package/s/core/deck/parts/local-storage-kv.ts +7 -0
  14. package/s/core/hub/bindings.ts +16 -19
  15. package/s/core/hub/hub.ts +2 -2
  16. package/s/core/hub/types.ts +14 -0
  17. package/s/core/index.ts +5 -3
  18. package/s/core/port/port.ts +1 -1
  19. package/s/core/testing/testing.ts +5 -5
  20. package/x/core/{port → bindings}/action.js +1 -1
  21. package/x/core/bindings/action.js.map +1 -0
  22. package/x/core/bindings/parts/defaults.d.ts +3 -0
  23. package/x/core/bindings/parts/defaults.js +23 -0
  24. package/x/core/bindings/parts/defaults.js.map +1 -0
  25. package/x/core/bindings/parts/is-pressed.js.map +1 -0
  26. package/x/core/bindings/parts/lens-algo.d.ts +2 -0
  27. package/x/core/{port/resolution → bindings/parts}/lens-algo.js +4 -4
  28. package/x/core/bindings/parts/lens-algo.js.map +1 -0
  29. package/x/core/{port/resolution → bindings}/resolver.d.ts +2 -3
  30. package/x/core/bindings/resolver.js +87 -0
  31. package/x/core/bindings/resolver.js.map +1 -0
  32. package/x/core/bindings/types.d.ts +29 -35
  33. package/x/core/bindings/types.js +0 -1
  34. package/x/core/bindings/types.js.map +1 -1
  35. package/x/core/controllers/standard/gamepad.d.ts +1 -2
  36. package/x/core/controllers/standard/gamepad.js +0 -4
  37. package/x/core/controllers/standard/gamepad.js.map +1 -1
  38. package/x/core/controllers/standard/keyboard.js +0 -3
  39. package/x/core/controllers/standard/keyboard.js.map +1 -1
  40. package/x/core/controllers/standard/pointer.js +3 -8
  41. package/x/core/controllers/standard/pointer.js.map +1 -1
  42. package/x/core/deck/deck.d.ts +16 -0
  43. package/x/core/deck/deck.js +31 -0
  44. package/x/core/deck/deck.js.map +1 -0
  45. package/x/core/deck/parts/bindings-depot.d.ts +9 -0
  46. package/x/core/deck/parts/bindings-depot.js +19 -0
  47. package/x/core/deck/parts/bindings-depot.js.map +1 -0
  48. package/x/core/deck/parts/local-storage-kv.d.ts +2 -0
  49. package/x/core/deck/parts/local-storage-kv.js +5 -0
  50. package/x/core/deck/parts/local-storage-kv.js.map +1 -0
  51. package/x/core/hub/bindings.d.ts +2 -2
  52. package/x/core/hub/bindings.js +15 -18
  53. package/x/core/hub/bindings.js.map +1 -1
  54. package/x/core/hub/hub.d.ts +3 -4
  55. package/x/core/hub/hub.js +1 -1
  56. package/x/core/hub/hub.js.map +1 -1
  57. package/x/core/hub/types.d.ts +9 -0
  58. package/x/core/hub/types.js +2 -0
  59. package/x/core/hub/types.js.map +1 -0
  60. package/x/core/index.d.ts +4 -3
  61. package/x/core/index.js +4 -3
  62. package/x/core/index.js.map +1 -1
  63. package/x/core/port/port.d.ts +1 -1
  64. package/x/core/port/port.js +1 -1
  65. package/x/core/port/port.js.map +1 -1
  66. package/x/core/testing/testing.d.ts +12 -32
  67. package/x/core/testing/testing.js +5 -5
  68. package/x/core/testing/testing.js.map +1 -1
  69. package/x/index.html +2 -2
  70. package/s/core/controllers/utils/modprefix.ts +0 -16
  71. package/s/core/port/resolution/defaults.ts +0 -30
  72. package/s/core/port/resolution/resolver.ts +0 -77
  73. package/s/core/port/resolution/types.ts +0 -9
  74. package/s/core/port/types.ts +0 -10
  75. package/x/core/controllers/utils/modprefix.d.ts +0 -1
  76. package/x/core/controllers/utils/modprefix.js +0 -16
  77. package/x/core/controllers/utils/modprefix.js.map +0 -1
  78. package/x/core/port/action.js.map +0 -1
  79. package/x/core/port/resolution/defaults.d.ts +0 -4
  80. package/x/core/port/resolution/defaults.js +0 -23
  81. package/x/core/port/resolution/defaults.js.map +0 -1
  82. package/x/core/port/resolution/lens-algo.d.ts +0 -2
  83. package/x/core/port/resolution/lens-algo.js.map +0 -1
  84. package/x/core/port/resolution/resolver.js +0 -64
  85. package/x/core/port/resolution/resolver.js.map +0 -1
  86. package/x/core/port/resolution/types.d.ts +0 -6
  87. package/x/core/port/resolution/types.js +0 -2
  88. package/x/core/port/resolution/types.js.map +0 -1
  89. package/x/core/port/types.d.ts +0 -7
  90. package/x/core/port/types.js +0 -2
  91. package/x/core/port/types.js.map +0 -1
  92. package/x/core/port/utils/is-pressed.js.map +0 -1
  93. /package/s/core/{port/utils → bindings/parts}/is-pressed.ts +0 -0
  94. /package/x/core/{port → bindings}/action.d.ts +0 -0
  95. /package/x/core/{port/utils → bindings/parts}/is-pressed.d.ts +0 -0
  96. /package/x/core/{port/utils → bindings/parts}/is-pressed.js +0 -0
@@ -1,64 +0,0 @@
1
- import { obMap, pub, WeakMapG } from "@e280/stz";
2
- import { Action } from "../action.js";
3
- import { lensAlgo } from "./lens-algo.js";
4
- import { defaultLensState } from "./defaults.js";
5
- import { tmax } from "../../../utils/quick-math.js";
6
- export class Resolver {
7
- bindings;
8
- #actions;
9
- #modes;
10
- #now = 0;
11
- #samples = new Map();
12
- #lensStates = new WeakMapG();
13
- #update = pub();
14
- constructor(bindings, modes) {
15
- this.bindings = bindings;
16
- this.#modes = modes;
17
- this.#actions = obMap(bindings, (bracket, mode) => obMap(bracket, fork => {
18
- const action = new Action();
19
- this.#update.subscribe(() => {
20
- Action.update(action, this.#resolveFork(fork, mode));
21
- });
22
- return action;
23
- }));
24
- }
25
- poll(now, samples) {
26
- this.#now = now;
27
- this.#samples = samples;
28
- this.#update();
29
- return this.#actions;
30
- }
31
- #resolveFork = (fork, mode) => {
32
- return (this.#modes.has(mode))
33
- ? tmax(fork.map(this.#resolveSpoon))
34
- : 0;
35
- };
36
- #resolveSpoon = (spoon) => {
37
- const { lenses, required = [], forbidden = [] } = spoon;
38
- const satisfiedRequirements = () => {
39
- if (required.length === 0)
40
- return true;
41
- const requiredValues = required.map(this.#resolveLens);
42
- return !requiredValues.some(value => value <= 0);
43
- };
44
- const satisfiedForbiddens = () => {
45
- if (forbidden.length === 0)
46
- return true;
47
- const forbiddenValues = forbidden.map(this.#resolveLens);
48
- return !forbiddenValues.some(value => value > 0);
49
- };
50
- const combineValues = () => {
51
- const values = lenses.map(this.#resolveLens);
52
- return tmax(values);
53
- };
54
- return (satisfiedRequirements() && satisfiedForbiddens())
55
- ? combineValues()
56
- : 0;
57
- };
58
- #resolveLens = (lens) => {
59
- const state = this.#lensStates.guarantee(lens, () => defaultLensState(lens));
60
- const v = this.#samples.get(lens.code) ?? 0;
61
- return lensAlgo(this.#now, state, v);
62
- };
63
- }
64
- //# sourceMappingURL=resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../../../s/core/port/resolution/resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAA;AAG9C,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAA;AAEnC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAC,IAAI,EAAC,MAAM,8BAA8B,CAAA;AAIjD,MAAM,OAAO,QAAQ;IASQ;IAR5B,QAAQ,CAAY;IACpB,MAAM,CAAc;IAEpB,IAAI,GAAG,CAAC,CAAA;IACR,QAAQ,GAAc,IAAI,GAAG,EAAE,CAAA;IAC/B,WAAW,GAAG,IAAI,QAAQ,EAAmB,CAAA;IAC7C,OA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@@ -1,6 +0,0 @@
1
- import { LensSettings } from "../../bindings/types.js";
2
- export type LensState = {
3
- settings: LensSettings;
4
- lastValue: number;
5
- holdStart: number;
6
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../s/core/port/resolution/types.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { Action } from "./action.js";
2
- import { Bindings } from "../bindings/types.js";
3
- export type Actions<B extends Bindings> = {
4
- [Mode in keyof B]: {
5
- [K in keyof B[Mode]]: Action;
6
- };
7
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../s/core/port/types.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-pressed.js","sourceRoot":"","sources":["../../../../s/core/port/utils/is-pressed.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,SAAS,CAAC,KAAa;IACtC,OAAO,KAAK,GAAG,CAAC,CAAA;AACjB,CAAC"}
File without changes