@vnejs/contracts.canvas.child.sprite 0.1.2 → 0.2.0

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/events.d.ts CHANGED
@@ -9,6 +9,5 @@ export declare const SUBSCRIBE_EVENTS: {
9
9
  readonly STATE_GET: "vne:layer_sprite:state_get";
10
10
  readonly STATE_ADD: "vne:layer_sprite:state_add";
11
11
  readonly STATE_RM: "vne:layer_sprite:state_rm";
12
- readonly STATE_SETTED: "vne:layer_sprite:state_setted";
13
12
  };
14
13
  export type SubscribeEvents = typeof SUBSCRIBE_EVENTS;
package/dist/events.js CHANGED
@@ -9,5 +9,4 @@ export const SUBSCRIBE_EVENTS = {
9
9
  STATE_GET: "vne:layer_sprite:state_get",
10
10
  STATE_ADD: "vne:layer_sprite:state_add",
11
11
  STATE_RM: "vne:layer_sprite:state_rm",
12
- STATE_SETTED: "vne:layer_sprite:state_setted",
13
12
  };
package/dist/index.d.ts CHANGED
@@ -8,8 +8,9 @@ export { CONSTANTS, ACTIONS, LAYER_CHILD_TYPE } from "./const.js";
8
8
  export type { Constants } from "./const.js";
9
9
  export { SUBSCRIBE_EVENTS };
10
10
  export type { SubscribeEvents } from "./events.js";
11
- export { PARAMS, TRANSITIONS_SHOW, TRANSITIONS_HIDE, POSITIONS, SPRITE_INFO } from "./params.js";
11
+ export { PARAMS, TRANSITIONS_SHOW, TRANSITIONS_HIDE, TRANSITION_SHOW_NAMES, TRANSITION_HIDE_NAMES, POSITIONS, POSITION_NAMES, SPRITE_INFO, } from "./params.js";
12
12
  export type { Params, SpriteBoxProps, SpriteInfo, SpriteTransitionProps } from "./params.js";
13
+ export { SPRITE_LINE_COMMAND } from "./scenario-command.js";
13
14
  declare module "@vnejs/shared" {
14
15
  interface VnePluginEventsMap extends Record<typeof PLUGIN_NAME, typeof SUBSCRIBE_EVENTS> {
15
16
  }
package/dist/index.js CHANGED
@@ -3,4 +3,5 @@ import { SUBSCRIBE_EVENTS } from "./events.js";
3
3
  export const PLUGIN_NAME = "LAYER_SPRITE";
4
4
  export { CONSTANTS, ACTIONS, LAYER_CHILD_TYPE } from "./const.js";
5
5
  export { SUBSCRIBE_EVENTS };
6
- export { PARAMS, TRANSITIONS_SHOW, TRANSITIONS_HIDE, POSITIONS, SPRITE_INFO } from "./params.js";
6
+ export { PARAMS, TRANSITIONS_SHOW, TRANSITIONS_HIDE, TRANSITION_SHOW_NAMES, TRANSITION_HIDE_NAMES, POSITIONS, POSITION_NAMES, SPRITE_INFO, } from "./params.js";
7
+ export { SPRITE_LINE_COMMAND } from "./scenario-command.js";
package/dist/params.d.ts CHANGED
@@ -15,11 +15,11 @@ export type SpriteTransitionProps = {
15
15
  };
16
16
  export type SpriteInfo = {
17
17
  mapParts?: (parts: Record<string, string>) => Record<string, string>;
18
- getSrc?: (variation: string, realParts: Record<string, string>, options: Record<string, unknown>, otherArgs: Record<string, unknown>) => Array<string | {
18
+ getSrc?: (variation: string, realParts: Record<string, string>, options: Record<string, unknown>, otherArgs: Record<string, unknown>) => Array<string | ({
19
19
  src?: Array<{
20
20
  url: string;
21
21
  } & Record<string, unknown>>;
22
- } & Record<string, unknown>>;
22
+ } & Record<string, unknown>)>;
23
23
  };
24
24
  export declare const TRANSITIONS_SHOW: Record<string, (boxProps: SpriteBoxProps) => SpriteTransitionProps>;
25
25
  export declare const TRANSITIONS_HIDE: Record<string, (boxProps: SpriteBoxProps) => SpriteTransitionProps>;
@@ -67,6 +67,27 @@ export declare const POSITIONS: {
67
67
  readonly transformOriginY: "100%";
68
68
  };
69
69
  };
70
+ /** Scenario literals for sprite position tokens (keys of POSITIONS). */
71
+ export declare const POSITION_NAMES: {
72
+ readonly LEFT: "left";
73
+ readonly LEFT10: "left10";
74
+ readonly CENTER_LEFT: "centerLeft";
75
+ readonly CENTER: "center";
76
+ readonly CENTER_RIGHT: "centerRight";
77
+ readonly RIGHT: "right";
78
+ };
79
+ /** Scenario literals for show transitions (keys of TRANSITIONS_SHOW). */
80
+ export declare const TRANSITION_SHOW_NAMES: {
81
+ readonly OPACITY: "opacity";
82
+ readonly LEFT_OPACITY: "leftOpacity";
83
+ readonly RIGHT_OPACITY: "rightOpacity";
84
+ };
85
+ /** Scenario literals for hide transitions (keys of TRANSITIONS_HIDE). */
86
+ export declare const TRANSITION_HIDE_NAMES: {
87
+ readonly OPACITY: "opacity";
88
+ readonly LEFT_OPACITY: "leftOpacity";
89
+ readonly RIGHT_OPACITY: "rightOpacity";
90
+ };
70
91
  export declare const SPRITE_INFO: Record<string, SpriteInfo>;
71
92
  declare const PARAMS_DEFAULT: {
72
93
  TRANSITIONS_SHOW: Record<string, (boxProps: SpriteBoxProps) => SpriteTransitionProps>;
package/dist/params.js CHANGED
@@ -28,6 +28,27 @@ export const POSITIONS = {
28
28
  centerRight: { left: "75%", bottom: 0, translateX: "-50%", transformOriginX: "50%", transformOriginY: "100%" },
29
29
  right: { left: "100%", bottom: 0, translateX: "-100%", transformOriginX: "100%", transformOriginY: "100%" },
30
30
  };
31
+ /** Scenario literals for sprite position tokens (keys of POSITIONS). */
32
+ export const POSITION_NAMES = {
33
+ LEFT: "left",
34
+ LEFT10: "left10",
35
+ CENTER_LEFT: "centerLeft",
36
+ CENTER: "center",
37
+ CENTER_RIGHT: "centerRight",
38
+ RIGHT: "right",
39
+ };
40
+ /** Scenario literals for show transitions (keys of TRANSITIONS_SHOW). */
41
+ export const TRANSITION_SHOW_NAMES = {
42
+ OPACITY: "opacity",
43
+ LEFT_OPACITY: "leftOpacity",
44
+ RIGHT_OPACITY: "rightOpacity",
45
+ };
46
+ /** Scenario literals for hide transitions (keys of TRANSITIONS_HIDE). */
47
+ export const TRANSITION_HIDE_NAMES = {
48
+ OPACITY: "opacity",
49
+ LEFT_OPACITY: "leftOpacity",
50
+ RIGHT_OPACITY: "rightOpacity",
51
+ };
31
52
  export const SPRITE_INFO = {};
32
53
  const PARAMS_DEFAULT = {
33
54
  TRANSITIONS_SHOW,
@@ -0,0 +1,86 @@
1
+ /** Shared `$ <layer>.sprite` command surface for layer contracts. */
2
+ export declare const SPRITE_LINE_COMMAND: {
3
+ readonly actions: {
4
+ readonly SHOW: "show";
5
+ readonly HIDE: "hide";
6
+ readonly CHANGE: "change";
7
+ readonly MOVE: "move";
8
+ };
9
+ readonly argsByAction: {
10
+ readonly show: readonly [{
11
+ readonly kind: "id";
12
+ }, {
13
+ readonly kind: "enum";
14
+ readonly values: {
15
+ readonly LEFT: "left";
16
+ readonly LEFT10: "left10";
17
+ readonly CENTER_LEFT: "centerLeft";
18
+ readonly CENTER: "center";
19
+ readonly CENTER_RIGHT: "centerRight";
20
+ readonly RIGHT: "right";
21
+ };
22
+ }, {
23
+ readonly kind: "id";
24
+ readonly optional: true;
25
+ readonly delimited: true;
26
+ }, {
27
+ readonly kind: "enum";
28
+ readonly values: {
29
+ readonly OPACITY: "opacity";
30
+ readonly LEFT_OPACITY: "leftOpacity";
31
+ readonly RIGHT_OPACITY: "rightOpacity";
32
+ };
33
+ readonly optional: true;
34
+ }, {
35
+ readonly kind: "number";
36
+ readonly optional: true;
37
+ }];
38
+ readonly hide: readonly [{
39
+ readonly kind: "id";
40
+ }, {
41
+ readonly kind: "enum";
42
+ readonly values: {
43
+ readonly OPACITY: "opacity";
44
+ readonly LEFT_OPACITY: "leftOpacity";
45
+ readonly RIGHT_OPACITY: "rightOpacity";
46
+ };
47
+ readonly optional: true;
48
+ }, {
49
+ readonly kind: "number";
50
+ readonly optional: true;
51
+ }];
52
+ readonly change: readonly [{
53
+ readonly kind: "id";
54
+ }, {
55
+ readonly kind: "id";
56
+ readonly delimited: true;
57
+ }, {
58
+ readonly kind: "number";
59
+ readonly optional: true;
60
+ }];
61
+ readonly move: readonly [{
62
+ readonly kind: "id";
63
+ }, {
64
+ readonly kind: "enum";
65
+ readonly values: {
66
+ readonly LEFT: "left";
67
+ readonly LEFT10: "left10";
68
+ readonly CENTER_LEFT: "centerLeft";
69
+ readonly CENTER: "center";
70
+ readonly CENTER_RIGHT: "centerRight";
71
+ readonly RIGHT: "right";
72
+ };
73
+ }, {
74
+ readonly kind: "enum";
75
+ readonly values: {
76
+ readonly OPACITY: "opacity";
77
+ readonly LEFT_OPACITY: "leftOpacity";
78
+ readonly RIGHT_OPACITY: "rightOpacity";
79
+ };
80
+ readonly optional: true;
81
+ }, {
82
+ readonly kind: "number";
83
+ readonly optional: true;
84
+ }];
85
+ };
86
+ };
@@ -0,0 +1,18 @@
1
+ import { ACTIONS } from "./const.js";
2
+ import { POSITION_NAMES, TRANSITION_HIDE_NAMES, TRANSITION_SHOW_NAMES } from "./params.js";
3
+ const ID = { kind: "id" };
4
+ const VARIATION = { kind: "id", optional: true, delimited: true };
5
+ const POSITION = { kind: "enum", values: POSITION_NAMES };
6
+ const SHOW_TRANSITION = { kind: "enum", values: TRANSITION_SHOW_NAMES, optional: true };
7
+ const HIDE_TRANSITION = { kind: "enum", values: TRANSITION_HIDE_NAMES, optional: true };
8
+ const DURATION = { kind: "number", optional: true };
9
+ /** Shared `$ <layer>.sprite` command surface for layer contracts. */
10
+ export const SPRITE_LINE_COMMAND = {
11
+ actions: ACTIONS,
12
+ argsByAction: {
13
+ [ACTIONS.SHOW]: [ID, POSITION, VARIATION, SHOW_TRANSITION, DURATION],
14
+ [ACTIONS.HIDE]: [ID, HIDE_TRANSITION, DURATION],
15
+ [ACTIONS.CHANGE]: [ID, { kind: "id", delimited: true }, DURATION],
16
+ [ACTIONS.MOVE]: [ID, POSITION, SHOW_TRANSITION, DURATION],
17
+ },
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/contracts.canvas.child.sprite",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Contracts for @vnejs/plugins.canvas.child.sprite",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,9 +26,11 @@
26
26
  "author": "",
27
27
  "license": "ISC",
28
28
  "peerDependencies": {
29
- "@vnejs/shared": "~0.1.0"
29
+ "@vnejs/contracts.core.scenario": "~0.2.0",
30
+ "@vnejs/shared": "~0.2.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@vnejs/configs.ts-common": "~0.1.0"
33
+ "@vnejs/configs.ts-common": "~0.2.0",
34
+ "@vnejs/contracts.core.scenario": "~0.2.0"
33
35
  }
34
36
  }
package/src/events.ts CHANGED
@@ -12,7 +12,6 @@ export const SUBSCRIBE_EVENTS = {
12
12
  STATE_GET: "vne:layer_sprite:state_get",
13
13
  STATE_ADD: "vne:layer_sprite:state_add",
14
14
  STATE_RM: "vne:layer_sprite:state_rm",
15
- STATE_SETTED: "vne:layer_sprite:state_setted",
16
15
  } as const;
17
16
 
18
17
  export type SubscribeEvents = typeof SUBSCRIBE_EVENTS;
package/src/index.ts CHANGED
@@ -11,8 +11,18 @@ export { CONSTANTS, ACTIONS, LAYER_CHILD_TYPE } from "./const.js";
11
11
  export type { Constants } from "./const.js";
12
12
  export { SUBSCRIBE_EVENTS };
13
13
  export type { SubscribeEvents } from "./events.js";
14
- export { PARAMS, TRANSITIONS_SHOW, TRANSITIONS_HIDE, POSITIONS, SPRITE_INFO } from "./params.js";
14
+ export {
15
+ PARAMS,
16
+ TRANSITIONS_SHOW,
17
+ TRANSITIONS_HIDE,
18
+ TRANSITION_SHOW_NAMES,
19
+ TRANSITION_HIDE_NAMES,
20
+ POSITIONS,
21
+ POSITION_NAMES,
22
+ SPRITE_INFO,
23
+ } from "./params.js";
15
24
  export type { Params, SpriteBoxProps, SpriteInfo, SpriteTransitionProps } from "./params.js";
25
+ export { SPRITE_LINE_COMMAND } from "./scenario-command.js";
16
26
 
17
27
  declare module "@vnejs/shared" {
18
28
  interface VnePluginEventsMap extends Record<typeof PLUGIN_NAME, typeof SUBSCRIBE_EVENTS> {}
package/src/params.ts CHANGED
@@ -59,6 +59,30 @@ export const POSITIONS = {
59
59
  right: { left: "100%", bottom: 0, translateX: "-100%", transformOriginX: "100%", transformOriginY: "100%" },
60
60
  } as const;
61
61
 
62
+ /** Scenario literals for sprite position tokens (keys of POSITIONS). */
63
+ export const POSITION_NAMES = {
64
+ LEFT: "left",
65
+ LEFT10: "left10",
66
+ CENTER_LEFT: "centerLeft",
67
+ CENTER: "center",
68
+ CENTER_RIGHT: "centerRight",
69
+ RIGHT: "right",
70
+ } as const satisfies Record<string, keyof typeof POSITIONS>;
71
+
72
+ /** Scenario literals for show transitions (keys of TRANSITIONS_SHOW). */
73
+ export const TRANSITION_SHOW_NAMES = {
74
+ OPACITY: "opacity",
75
+ LEFT_OPACITY: "leftOpacity",
76
+ RIGHT_OPACITY: "rightOpacity",
77
+ } as const satisfies Record<string, keyof typeof TRANSITIONS_SHOW>;
78
+
79
+ /** Scenario literals for hide transitions (keys of TRANSITIONS_HIDE). */
80
+ export const TRANSITION_HIDE_NAMES = {
81
+ OPACITY: "opacity",
82
+ LEFT_OPACITY: "leftOpacity",
83
+ RIGHT_OPACITY: "rightOpacity",
84
+ } as const satisfies Record<string, keyof typeof TRANSITIONS_HIDE>;
85
+
62
86
  export const SPRITE_INFO: Record<string, SpriteInfo> = {};
63
87
 
64
88
  const PARAMS_DEFAULT = {
@@ -0,0 +1,22 @@
1
+ import type { ScenarioCommandEntry } from "@vnejs/contracts.core.scenario";
2
+
3
+ import { ACTIONS } from "./const.js";
4
+ import { POSITION_NAMES, TRANSITION_HIDE_NAMES, TRANSITION_SHOW_NAMES } from "./params.js";
5
+
6
+ const ID = { kind: "id" } as const;
7
+ const VARIATION = { kind: "id", optional: true, delimited: true } as const;
8
+ const POSITION = { kind: "enum", values: POSITION_NAMES } as const;
9
+ const SHOW_TRANSITION = { kind: "enum", values: TRANSITION_SHOW_NAMES, optional: true } as const;
10
+ const HIDE_TRANSITION = { kind: "enum", values: TRANSITION_HIDE_NAMES, optional: true } as const;
11
+ const DURATION = { kind: "number", optional: true } as const;
12
+
13
+ /** Shared `$ <layer>.sprite` command surface for layer contracts. */
14
+ export const SPRITE_LINE_COMMAND = {
15
+ actions: ACTIONS,
16
+ argsByAction: {
17
+ [ACTIONS.SHOW]: [ID, POSITION, VARIATION, SHOW_TRANSITION, DURATION],
18
+ [ACTIONS.HIDE]: [ID, HIDE_TRANSITION, DURATION],
19
+ [ACTIONS.CHANGE]: [ID, { kind: "id", delimited: true }, DURATION],
20
+ [ACTIONS.MOVE]: [ID, POSITION, SHOW_TRANSITION, DURATION],
21
+ },
22
+ } as const satisfies ScenarioCommandEntry;