@dreamboard-games/sdk 0.5.0-alpha.11 → 0.5.0-alpha.13
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 +68 -1
- package/dist/{chunk-2IGXAYW4.js → chunk-W5G6VMMQ.js} +18 -15
- package/dist/chunk-W5G6VMMQ.js.map +1 -0
- package/dist/{chunk-D3F3GCMF.js → chunk-YUEMDRIH.js} +14 -4
- package/dist/chunk-YUEMDRIH.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +100 -3
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +22 -6
- package/dist/react.js +282 -33
- package/dist/react.js.map +1 -1
- package/dist/{model-BeslAXVA.d.ts → shortcuts-Chlx8o7p.d.ts} +93 -8
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2IGXAYW4.js.map +0 -1
- package/dist/chunk-D3F3GCMF.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { q as Features, E as InstanceOptions, n as CoreInstance, p as FeatureContext, G as GameInstance, C as Card,
|
|
2
|
-
export { a as AnyInput, b as AnyInteraction, B as Board, f as BoardDropTarget, i as BoardSpaceData, j as BoardSpaceId, k as BoardTarget, l as CardBase, m as CardDataOf, D as Drafts, F as Feature, r as GameSnapshot, H as Hook, s as Input, t as InputBase, u as InputControl, v as InputDomainOf, w as InputKey, x as InputKind, y as InputTarget, z as InputTargetOption, J as Interaction, K as InteractionBase, L as InteractionDropTarget, M as InteractionKey, N as InteractionParams, O as LocalState, P as NativeEvent, Q as Phase, R as PhaseName, S as PlacedTileDataOf, T as Player, U as ReadModel, V as ReadonlyData, X as RuntimeBoardDropTarget, Y as RuntimeBoardTarget, Z as RuntimeDropTarget, _ as RuntimeInteractionDropTarget, $ as RuntimeSelectionTarget, a2 as SelectionTarget, a3 as
|
|
1
|
+
import { q as Features, E as InstanceOptions, n as CoreInstance, p as FeatureContext, G as GameInstance, C as Card, af as Zone, a1 as SeatCardId, d as BoardCollection, h as BoardSpaceCollection, c as BoardBase, W as RuntimeBoard, a0 as RuntimeTargetOptions, A as ActionProps, e as BoardDataOf, I as IdOf, g as BoardSpace, aa as TargetOptions, o as DropTarget, ah as ZoneHostId } from './shortcuts-Chlx8o7p.js';
|
|
2
|
+
export { a as AnyInput, b as AnyInteraction, B as Board, f as BoardDropTarget, i as BoardSpaceData, j as BoardSpaceId, k as BoardTarget, l as CardBase, m as CardDataOf, D as Drafts, F as Feature, r as GameSnapshot, H as Hook, s as Input, t as InputBase, u as InputControl, v as InputDomainOf, w as InputKey, x as InputKind, y as InputTarget, z as InputTargetOption, J as Interaction, K as InteractionBase, L as InteractionDropTarget, M as InteractionKey, N as InteractionParams, O as LocalState, P as NativeEvent, Q as Phase, R as PhaseName, S as PlacedTileDataOf, T as Player, U as ReadModel, V as ReadonlyData, X as RuntimeBoardDropTarget, Y as RuntimeBoardTarget, Z as RuntimeDropTarget, _ as RuntimeInteractionDropTarget, $ as RuntimeSelectionTarget, a2 as SelectionTarget, a3 as ShortcutBinding, a4 as ShortcutHint, a5 as ShortcutOptions, a6 as ShortcutTarget, a7 as ShortcutZoneTarget, a8 as ShortcutsController, a9 as TableOfGame, ab as Tile, ac as TileDataOf, ad as Turn, ae as ViewOf, ag as ZoneBase, ai as shortcutsFeature } from './shortcuts-Chlx8o7p.js';
|
|
3
3
|
import { I as InteractionDescriptor, b as GameplayBasis, e as PluginSessionDescriptor, c as PluginGameplayFrame, G as GameSource, g as SourceSnapshot, C as CommandSource, P as PlayerId, R as ReducerSeatProjectionBundle } from './types-Xg_RxV1n.js';
|
|
4
4
|
export { A as ActionInteractionDescriptor, a as ApplySource, d as PluginPlayerSummary, S as SimultaneousPhaseSnapshot, f as SourceRequest, h as SourceState, i as SubmitResult, Z as ZoneHandlesSnapshot } from './types-Xg_RxV1n.js';
|
|
5
5
|
import * as z from 'zod';
|
|
@@ -97,6 +97,8 @@ declare function staticSource(input: SourceSnapshot): GameSource;
|
|
|
97
97
|
/** Pins its parent window, origin and channel at the first valid initialization. */
|
|
98
98
|
declare function iframeSource(options?: {
|
|
99
99
|
timeoutMs?: number;
|
|
100
|
+
/** Trusted pass-and-play hosts may change seats without replacing the iframe. */
|
|
101
|
+
followHostSeat?: boolean;
|
|
100
102
|
}): CommandSource;
|
|
101
103
|
|
|
102
104
|
declare const GameplayCloseCode: {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
isSameDropTarget,
|
|
7
7
|
magneticDropPoint,
|
|
8
8
|
runtimeFeatures
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-W5G6VMMQ.js";
|
|
10
10
|
import {
|
|
11
11
|
CancelInteractionCommandSchema,
|
|
12
12
|
DREAMBOARD_PLUGIN_PROTOCOL,
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
parsePluginSessionDescriptor,
|
|
41
41
|
parsePluginToHostEnvelope,
|
|
42
42
|
staticSource
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-YUEMDRIH.js";
|
|
44
44
|
import {
|
|
45
45
|
InputDomainSchema,
|
|
46
46
|
InteractionAvailabilitySchema,
|
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
} from "./chunk-ES74C2IN.js";
|
|
72
72
|
|
|
73
73
|
// src/package-set.ts
|
|
74
|
-
var DREAMBOARD_SDK_VERSION = true ? "0.5.0-alpha.
|
|
74
|
+
var DREAMBOARD_SDK_VERSION = true ? "0.5.0-alpha.13" : "0.0.0-development";
|
|
75
75
|
var DREAMBOARD_SDK_PACKAGES = {
|
|
76
76
|
"@dreamboard-games/sdk": DREAMBOARD_SDK_VERSION
|
|
77
77
|
};
|
|
@@ -103,6 +103,7 @@ function iframeSource(options = {}) {
|
|
|
103
103
|
};
|
|
104
104
|
const lifecycle = createSourceLifecycle({
|
|
105
105
|
timeoutMs: options.timeoutMs,
|
|
106
|
+
followHostSeat: options.followHostSeat,
|
|
106
107
|
send,
|
|
107
108
|
recover: () => send({ type: "runtime.resume" }),
|
|
108
109
|
close: () => target.removeEventListener("message", receive)
|
|
@@ -418,6 +419,101 @@ function asError(error) {
|
|
|
418
419
|
return error instanceof Error ? error : new Error(String(error));
|
|
419
420
|
}
|
|
420
421
|
|
|
422
|
+
// src/headless/features/shortcuts.ts
|
|
423
|
+
import { createStore } from "@tanstack/store";
|
|
424
|
+
function shortcutsFeature(_game, context) {
|
|
425
|
+
const game = context[runtimeFeatures].game;
|
|
426
|
+
const configuration = createStore(null);
|
|
427
|
+
let registration = null;
|
|
428
|
+
function bindings() {
|
|
429
|
+
return configuration.get()?.bindings ?? [];
|
|
430
|
+
}
|
|
431
|
+
let disposed = false;
|
|
432
|
+
function resolve(binding, key, target) {
|
|
433
|
+
if (disposed || !target || game.connection !== "ready" || game.request || target.kind !== binding.target)
|
|
434
|
+
return null;
|
|
435
|
+
const routes = target.kind === "card" ? game.cards.find(target.value)?.getInteractions() ?? [] : game.interactions.list();
|
|
436
|
+
const interaction = routes.find((item) => item.key === binding.interaction);
|
|
437
|
+
if (!interaction || interaction.getStatus() !== "open") return null;
|
|
438
|
+
if (target.kind === "zone") {
|
|
439
|
+
if (target.zoneId !== binding.zoneId || !game.zones.find(target.zoneId, target.hostId))
|
|
440
|
+
return null;
|
|
441
|
+
} else {
|
|
442
|
+
const input = interaction.getInputs().find((item) => item.key === binding.input);
|
|
443
|
+
if (!input || !input.getIsEligible(target.value)) return null;
|
|
444
|
+
const domain = input.getDomain();
|
|
445
|
+
if (target.kind === "card" && input.kind !== "card") return null;
|
|
446
|
+
if (target.kind === "tile" && input.kind !== "tile") return null;
|
|
447
|
+
if (target.kind === "space" || target.kind === "edge" || target.kind === "vertex") {
|
|
448
|
+
if (domain.type !== "boardTarget" || domain.targetKind !== target.kind || domain.valueKind !== target.valueKind)
|
|
449
|
+
return null;
|
|
450
|
+
if (domain.valueKind === "board-id" && target.valueKind === "board-id" && domain.boardId !== target.boardId)
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
const params = binding.inputs({ key, target });
|
|
455
|
+
return interaction.getIsAvailable(params) && interaction.getIsReady(params) ? { interaction, params } : null;
|
|
456
|
+
}
|
|
457
|
+
const controller = {
|
|
458
|
+
configuration,
|
|
459
|
+
register(options) {
|
|
460
|
+
if (registration)
|
|
461
|
+
throw new Error("Mount useGameShortcuts once per GameProvider.");
|
|
462
|
+
const owned = {};
|
|
463
|
+
registration = owned;
|
|
464
|
+
configuration.setState(() => options);
|
|
465
|
+
return {
|
|
466
|
+
update(options2) {
|
|
467
|
+
if (registration !== owned) return;
|
|
468
|
+
configuration.setState(() => options2);
|
|
469
|
+
},
|
|
470
|
+
dispose() {
|
|
471
|
+
if (registration !== owned) return;
|
|
472
|
+
registration = null;
|
|
473
|
+
configuration.setState(() => null);
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
},
|
|
477
|
+
handle(key, target) {
|
|
478
|
+
const candidates = bindings().filter((binding) => binding.keys.includes(key)).flatMap((binding) => {
|
|
479
|
+
const resolved = resolve(binding, key, target);
|
|
480
|
+
return resolved ? [resolved] : [];
|
|
481
|
+
});
|
|
482
|
+
return candidates.length === 1 ? candidates[0].interaction.submit(candidates[0].params) : null;
|
|
483
|
+
},
|
|
484
|
+
getHints(target) {
|
|
485
|
+
const eligible = bindings().map((binding) => ({
|
|
486
|
+
binding,
|
|
487
|
+
keys: binding.keys.filter((key) => resolve(binding, key, target))
|
|
488
|
+
}));
|
|
489
|
+
const counts = /* @__PURE__ */ new Map();
|
|
490
|
+
for (const { keys } of eligible)
|
|
491
|
+
for (const key of new Set(keys))
|
|
492
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
493
|
+
return eligible.flatMap(({ binding, keys }) => {
|
|
494
|
+
const unique = [...new Set(keys)].filter(
|
|
495
|
+
(key) => counts.get(key) === 1
|
|
496
|
+
);
|
|
497
|
+
return unique.length ? [
|
|
498
|
+
{
|
|
499
|
+
keys: unique,
|
|
500
|
+
label: binding.label,
|
|
501
|
+
interaction: binding.interaction
|
|
502
|
+
}
|
|
503
|
+
] : [];
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
return {
|
|
508
|
+
root: { shortcuts: controller },
|
|
509
|
+
dispose() {
|
|
510
|
+
disposed = true;
|
|
511
|
+
registration = null;
|
|
512
|
+
configuration.setState(() => null);
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
|
|
421
517
|
// src/headless/features/hand.ts
|
|
422
518
|
var seatCardId = (card) => card.id;
|
|
423
519
|
function handFeature(_game, options = {}) {
|
|
@@ -1559,6 +1655,7 @@ export {
|
|
|
1559
1655
|
parsePluginSessionDescriptor,
|
|
1560
1656
|
parsePluginToHostEnvelope,
|
|
1561
1657
|
perPlayerInstanceId,
|
|
1658
|
+
shortcutsFeature,
|
|
1562
1659
|
staticSource
|
|
1563
1660
|
};
|
|
1564
1661
|
//# sourceMappingURL=index.js.map
|