talearchitect-api 1.0.0 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +26 -2
  2. package/index.d.ts +16 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Este pacote contém as definições de tipo TypeScript (`.d.ts`) para o desenvolvimento de plugins para o **TaleArchitect**.
7
7
 
8
- Ao instalar este pacote, seu editor de código (VS Code, etc.) fornecerá **Autocomplete (IntelliSense)**, documentação inline e verificação de tipos para a variável global `app`.
8
+ Ao instalar este pacote, seu editor de código (VS Code, etc.) fornecerá **Autocomplete (IntelliSense)**, documentação inline e verificação de tipos para a variável `app`.
9
9
 
10
10
  > **Nota:** Este pacote contém apenas tipos. A lógica de execução é fornecida nativamente pelo aplicativo TaleArchitect.
11
11
 
@@ -47,7 +47,19 @@ Crie um arquivo jsconfig.json na raiz da pasta do seu plugin. Isso habilita o au
47
47
  ```
48
48
 
49
49
  ## 📚 Visão Geral da API
50
- O objeto global app expõe as seguintes funcionalidades:
50
+
51
+ ### Ponto de partida
52
+ Seu script deve conter uma função `init(app)`, que atuará como uma função "main" do seu plugin.
53
+
54
+ ```bash
55
+ function init(app) {
56
+ app.ui.toast("Hello, World!", "success");
57
+ }
58
+ ```
59
+
60
+ <hr>
61
+
62
+ O objeto `app` passado em `init(app)` expõe as seguintes funcionalidades:
51
63
 
52
64
  ```app.commands```
53
65
 
@@ -97,4 +109,16 @@ Descubra o estado atual da interface (qual aba está ativa, nível de zoom, etc)
97
109
  if (app.context.getActiveTab() === 'map') { ... }
98
110
  ```
99
111
 
112
+ ```app.metadata```
113
+
114
+ Permite salvar e recuperar dados personalizados em entidades (locais, conexões, eventos ou personagens).
115
+ ```bash
116
+ const id = await app.factory.createCharacter("Novo Herói");
117
+ app.metadata.set(id, {
118
+ hp: 20,
119
+ ataque: 4,
120
+ velocidade: 10
121
+ });
122
+ ```
123
+
100
124
  https://github.com/MateusRNM/TaleArchitect - Repositório principal do aplicativo.
package/index.d.ts CHANGED
@@ -24,7 +24,6 @@ export interface Character {
24
24
  image: string | null;
25
25
  description: string;
26
26
  createdAt: string;
27
- [key: string]: any;
28
27
  }
29
28
 
30
29
  export interface Location {
@@ -32,7 +31,6 @@ export interface Location {
32
31
  name: string;
33
32
  description: string;
34
33
  coordinates: Coordinates;
35
- [key: string]: any;
36
34
  }
37
35
 
38
36
  export interface Connection {
@@ -41,7 +39,6 @@ export interface Connection {
41
39
  description: string;
42
40
  fromLocationId: UUID;
43
41
  toLocationId: UUID;
44
- [key: string]: any;
45
42
  }
46
43
 
47
44
  export interface Event {
@@ -51,7 +48,6 @@ export interface Event {
51
48
  locationId: UUID;
52
49
  date: Time;
53
50
  characters: UUID[];
54
- [key: string]: any;
55
51
  }
56
52
 
57
53
  export interface MapView {
@@ -67,7 +63,7 @@ export interface MapStateSnapshot {
67
63
  }
68
64
 
69
65
  export interface TimelineStateSnapshot {
70
- view: 'list' | 'form';
66
+ view: 'list' | 'swimlane' | 'form';
71
67
  selectedEventId: string | null;
72
68
  scrollY: number;
73
69
  }
@@ -81,7 +77,8 @@ export type ToastType = 'success' | 'error' | 'info';
81
77
 
82
78
  export interface AppAPI {
83
79
 
84
- readonly version: string;
80
+ readonly apiVersion: string;
81
+ readonly pluginInfo: { id: string };
85
82
 
86
83
  commands: {
87
84
  execute(id: string, args?: any): Promise<void>;
@@ -95,6 +92,15 @@ export interface AppAPI {
95
92
  getEvents(): Promise<Event[]>;
96
93
  getCalendar(): Promise<{ months: Month[] }>;
97
94
  getCurrentDate(): Promise<Time | null>;
95
+ updateCharacter(id: string, changes: Partial<Character>): Promise<void>;
96
+ updateLocation(id: string, changes: Partial<Location>): Promise<void>;
97
+ updateEvent(id: string, changes: Partial<Event>): Promise<void>;
98
+ updateConnection(id: string, changes: Partial<Character>): Promise<void>;
99
+ updateCalendar(months: Month[]): Promise<void>;
100
+ removeCharacter(id: string): Promise<void>;
101
+ removeLocation(id: string): Promise<void>;
102
+ removeEvent(id: string): Promise<void>;
103
+ removeConnection(id: string): Promise<void>;
98
104
  };
99
105
 
100
106
  factory: {
@@ -117,10 +123,11 @@ export interface AppAPI {
117
123
  getActiveTab(): string;
118
124
  getStates(): FullUIState;
119
125
  };
120
- }
121
126
 
122
- declare global {
123
- const app: AppAPI;
127
+ metadata: {
128
+ get(entityId: string): Promise<any>,
129
+ set(entityId: string, data: any): Promise<void>
130
+ };
124
131
  }
125
132
 
126
133
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "talearchitect-api",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Type definitions for TaleArchitect plugins",
5
5
  "types": "index.d.ts",
6
6
  "scripts": {