talearchitect-api 1.0.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 +100 -0
  2. package/index.d.ts +126 -0
  3. package/package.json +13 -0
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # TaleArchitect API Definitions
2
+
3
+ ![NPM Version](https://img.shields.io/npm/v/talearchitect-api?style=flat-square)
4
+ ![License](https://img.shields.io/npm/l/talearchitect-api?style=flat-square)
5
+
6
+ Este pacote contém as definições de tipo TypeScript (`.d.ts`) para o desenvolvimento de plugins para o **TaleArchitect**.
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`.
9
+
10
+ > **Nota:** Este pacote contém apenas tipos. A lógica de execução é fornecida nativamente pelo aplicativo TaleArchitect.
11
+
12
+ ## 📦 Instalação
13
+
14
+ Na pasta do seu plugin, execute:
15
+
16
+ ```bash
17
+ npm install --save-dev talearchitect-api
18
+ ```
19
+
20
+ ## 🚀 Como Usar
21
+
22
+ Existem duas formas principais de habilitar o autocomplete no seu projeto:
23
+
24
+ **Opção 1:** Usando Diretiva de Referência (Mais Simples)
25
+ Adicione esta linha no topo do seu arquivo main.js:
26
+
27
+ ```bash
28
+ ///<reference types="talearchitect-api" />
29
+
30
+ app.ui.toast("Olá Mundo!");
31
+ ```
32
+
33
+ **Opção 2:** Usando jsconfig.json (Recomendado)
34
+
35
+ Crie um arquivo jsconfig.json na raiz da pasta do seu plugin. Isso habilita o autocomplete em todos os arquivos do projeto sem precisar adicionar a linha de referência em cada um.
36
+
37
+ ```bash
38
+ {
39
+ "compilerOptions": {
40
+ "checkJs": true
41
+ },
42
+ "include": [
43
+ "node_modules/talearchitect-api/index.d.ts",
44
+ "**/*.js"
45
+ ]
46
+ }
47
+ ```
48
+
49
+ ## 📚 Visão Geral da API
50
+ O objeto global app expõe as seguintes funcionalidades:
51
+
52
+ ```app.commands```
53
+
54
+ Execute comandos nativos ou registre seus próprios comandos na Paleta (Ctrl+K).
55
+
56
+ ```bash
57
+ app.commands.register('meu:comando', () => { ... });
58
+ ```
59
+
60
+ ```app.data```
61
+
62
+ Acesso de leitura aos dados do projeto (Personagens, Locais, Eventos, Calendário).
63
+
64
+ ```bash
65
+ const chars = await app.data.getCharacters();
66
+ ```
67
+
68
+ ```app.factory```
69
+
70
+ Criação segura de entidades (com suporte automático a Undo/Ctrl+Z).
71
+
72
+ ```bash
73
+ const id = await app.factory.createCharacter("Novo Herói");
74
+ ```
75
+
76
+ ```app.ui```
77
+
78
+ Interação com o usuário (Toasts, Alertas, Confirmações).
79
+
80
+ ```bash
81
+ app.ui.toast("Sucesso!", "success");
82
+ ```
83
+
84
+ ```app.events```
85
+
86
+ Escute eventos do ciclo de vida do aplicativo.
87
+
88
+ ```bash
89
+ app.events.on('project:save', () => { ... });
90
+ ```
91
+
92
+ ```app.context```
93
+
94
+ Descubra o estado atual da interface (qual aba está ativa, nível de zoom, etc).
95
+
96
+ ```bash
97
+ if (app.context.getActiveTab() === 'map') { ... }
98
+ ```
99
+
100
+ https://github.com/MateusRNM/TaleArchitect - Repositório principal do aplicativo.
package/index.d.ts ADDED
@@ -0,0 +1,126 @@
1
+ export type UUID = string;
2
+
3
+ export interface Month {
4
+ name: string;
5
+ days: number;
6
+ }
7
+
8
+ export interface Time {
9
+ day: number;
10
+ month: number;
11
+ year: number;
12
+ hour?: number;
13
+ minute?: number;
14
+ }
15
+
16
+ export interface Coordinates {
17
+ x: number;
18
+ y: number;
19
+ }
20
+
21
+ export interface Character {
22
+ id: UUID;
23
+ name: string;
24
+ image: string | null;
25
+ description: string;
26
+ createdAt: string;
27
+ [key: string]: any;
28
+ }
29
+
30
+ export interface Location {
31
+ id: UUID;
32
+ name: string;
33
+ description: string;
34
+ coordinates: Coordinates;
35
+ [key: string]: any;
36
+ }
37
+
38
+ export interface Connection {
39
+ id: UUID;
40
+ name: string;
41
+ description: string;
42
+ fromLocationId: UUID;
43
+ toLocationId: UUID;
44
+ [key: string]: any;
45
+ }
46
+
47
+ export interface Event {
48
+ id: UUID;
49
+ name: string;
50
+ description: string;
51
+ locationId: UUID;
52
+ date: Time;
53
+ characters: UUID[];
54
+ [key: string]: any;
55
+ }
56
+
57
+ export interface MapView {
58
+ x: number;
59
+ y: number;
60
+ k: number;
61
+ }
62
+
63
+ export interface MapStateSnapshot {
64
+ view: MapView;
65
+ selectedLocationId: string | null;
66
+ selectedConnectionId: string | null;
67
+ }
68
+
69
+ export interface TimelineStateSnapshot {
70
+ view: 'list' | 'form';
71
+ selectedEventId: string | null;
72
+ scrollY: number;
73
+ }
74
+
75
+ export interface FullUIState {
76
+ map: MapStateSnapshot;
77
+ timeline: TimelineStateSnapshot;
78
+ }
79
+
80
+ export type ToastType = 'success' | 'error' | 'info';
81
+
82
+ export interface AppAPI {
83
+
84
+ readonly version: string;
85
+
86
+ commands: {
87
+ execute(id: string, args?: any): Promise<void>;
88
+ register(id: string, handler: (args: any) => void, options?: any): void;
89
+ };
90
+
91
+ data: {
92
+ getCharacters(): Promise<Character[]>;
93
+ getLocations(): Promise<Location[]>;
94
+ getConnections(): Promise<Connection[]>;
95
+ getEvents(): Promise<Event[]>;
96
+ getCalendar(): Promise<{ months: Month[] }>;
97
+ getCurrentDate(): Promise<Time | null>;
98
+ };
99
+
100
+ factory: {
101
+ createCharacter(name: string, description?: string): Promise<UUID | null>;
102
+ createEvent(name: string, date: Time, description?: string): Promise<UUID | null>;
103
+ createLocation(name: string, description?: string, x?: number, y?: number): Promise<UUID | null>;
104
+ };
105
+
106
+ ui: {
107
+ toast(msg: string, type?: ToastType, duration?: number): void;
108
+ alert(msg: string, title?: string): Promise<void>;
109
+ confirm(msg: string, title?: string): Promise<boolean>;
110
+ };
111
+
112
+ events: {
113
+ on(event: string, callback: (data: any) => void): void;
114
+ };
115
+
116
+ context: {
117
+ getActiveTab(): string;
118
+ getStates(): FullUIState;
119
+ };
120
+ }
121
+
122
+ declare global {
123
+ const app: AppAPI;
124
+ }
125
+
126
+ export {};
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "talearchitect-api",
3
+ "version": "1.0.0",
4
+ "description": "Type definitions for TaleArchitect plugins",
5
+ "types": "index.d.ts",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": ["talearchitect", "plugin", "api", "types"],
10
+ "author": "Mateus RNM",
11
+ "license": "MIT",
12
+ "peerDependencies": {}
13
+ }