@appkit/dek-plugin 0.25.0 → 0.27.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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export type { DekPlugin, DekPluginBoardItem, DekPluginComponentItem, DekPluginConfig, DekPluginElementFactoryWithProps, DekPluginElementProps, DekPluginFactory, DekPluginSchema, DekPluginSchemaItem, DekPluginScreenItem, } from './lib/plugins';
1
+ export type { DekIntegration, DekPlugin, DekPluginBoardItem, DekPluginComponentItem, DekPluginConfig, DekPluginElementFactoryWithProps, DekPluginElementProps, DekPluginFactory, DekPluginSchema, DekPluginSchemaItem, DekPluginSchemaItemOption, DekPluginSchemaType, DekPluginScreenItem, } from './lib/plugins';
2
2
  export type { DekRegistry, DekRegistryCollection, DekRegistryCollectionItem, DekRegistrySchema, DekRegistrySchemaItem, DekRegistrySchemaProps, DekRegistrySchemaPropsItem, } from './lib/registry';
3
- export type { DekApi, DekApiInfo, DekApiMessage, DekApiMessageType, DekApiPlugin, DekApiState, } from './lib/api';
3
+ export type { DekApi, DekApiInfo, DekApiMessage, DekApiMessageType, DekApiIntegration as DekApiPlugin, DekApiState, DekBoard, DekBoardBase, DekBoardProperty, DekCommand, DekCommandGroup, DekComponent, DekZone, } from './lib/api';
4
4
  export { default as usePluginState } from './lib/hooks/usePluginState';
5
5
  export { default as usePluginStateObject } from './lib/hooks/usePluginStateObject';
6
6
  export declare function __debug(): void;
package/dist/index.es.js CHANGED
@@ -188,8 +188,8 @@ class Api {
188
188
  messages() {
189
189
  return this.internal.messages();
190
190
  }
191
- plugin(name) {
192
- return this.internal.plugin(name);
191
+ integration(key) {
192
+ return this.internal.integration(key);
193
193
  }
194
194
  get registry() {
195
195
  return this.internal.registry;
@@ -221,26 +221,26 @@ class Api {
221
221
  open(boardKey) {
222
222
  this.internal.open(boardKey);
223
223
  }
224
- get plugins() {
225
- return this.internal.plugins;
224
+ get integrations() {
225
+ return this.internal.integrations;
226
226
  }
227
227
  get api() {
228
- return this.plugin(this.integrationKey).api;
228
+ return this.integration(this.integrationKey).api;
229
229
  }
230
230
  get state() {
231
- return this.plugin(this.integrationKey).state;
231
+ return this.integration(this.integrationKey).state;
232
232
  }
233
233
  get info() {
234
- return this.plugin(this.integrationKey).info;
234
+ return this.integration(this.integrationKey).info;
235
235
  }
236
236
  component(key, props) {
237
- return this.plugin(this.integrationKey).component(key, props);
237
+ return this.integration(this.integrationKey).component(key, props);
238
238
  }
239
239
  componentSchema(key) {
240
- return this.plugin(this.integrationKey).componentSchema(key);
240
+ return this.integration(this.integrationKey).componentSchema(key);
241
241
  }
242
242
  screen(path) {
243
- return this.plugin(this.integrationKey).screen(path);
243
+ return this.integration(this.integrationKey).screen(path);
244
244
  }
245
245
  }
246
246
  class ApiInternal {
@@ -274,8 +274,8 @@ class ApiInternal {
274
274
  messages() {
275
275
  return this.globals.messages;
276
276
  }
277
- plugin(name) {
278
- return this.createPluginWrapper(name);
277
+ integration(key) {
278
+ return this.createIntegrationWrapper(key);
279
279
  }
280
280
  get registry() {
281
281
  return this.globals.registry;
@@ -288,6 +288,8 @@ class ApiInternal {
288
288
  }
289
289
  get board() {
290
290
  return this.boards.find((board) => board.key === this.boardKey) || {
291
+ title: "Missing board",
292
+ key: "#error",
291
293
  zones: []
292
294
  };
293
295
  }
@@ -309,20 +311,20 @@ class ApiInternal {
309
311
  open(boardKey) {
310
312
  this.globals.setLocation(`/${boardKey}`);
311
313
  }
312
- createPluginWrapper(integrationKey) {
313
- const plugin = this.getPluginInstance(integrationKey);
314
- const available = !!plugin;
314
+ createIntegrationWrapper(integrationKey) {
315
+ const integration = this.getIntegrationInstance(integrationKey);
316
+ const available = !!integration;
315
317
  return {
316
318
  available,
317
319
  info: {
318
- components: (plugin == null ? void 0 : plugin.components) ? plugin.components.map((component) => component.key) : [],
319
- screens: (plugin == null ? void 0 : plugin.screens) ? plugin.screens.map((screen) => screen.path) : []
320
+ components: (integration == null ? void 0 : integration.components) ? integration.components.map((component) => component.key) : [],
321
+ screens: (integration == null ? void 0 : integration.screens) ? integration.screens.map((screen) => screen.path) : []
320
322
  },
321
323
  component: (key, props) => this.getComponent(integrationKey, key, props),
322
324
  componentSchema: (key) => this.getComponentSchema(integrationKey, key),
323
325
  screen: (path) => this.getScreen(integrationKey, path),
324
326
  board: (key) => this.getBoard(integrationKey, key),
325
- api: (plugin == null ? void 0 : plugin.api) || {},
327
+ api: (integration == null ? void 0 : integration.api) || {},
326
328
  state: {
327
329
  get: (key, defaultValue) => {
328
330
  if (!available) {
@@ -342,20 +344,20 @@ class ApiInternal {
342
344
  get globals() {
343
345
  return window.__dek_globals;
344
346
  }
345
- get plugins() {
346
- const plugins = {};
347
- Object.keys(this.globals.pluginInstances).forEach((key) => {
348
- plugins[key] = this.createPluginWrapper(key);
347
+ get integrations() {
348
+ const integrations = {};
349
+ Object.keys(this.globals.integrationInstances).forEach((key) => {
350
+ integrations[key] = this.createIntegrationWrapper(key);
349
351
  });
350
- return plugins;
352
+ return integrations;
351
353
  }
352
- getPluginInstance(integrationKey) {
353
- return this.globals.pluginInstances[integrationKey];
354
+ getIntegrationInstance(integrationKey) {
355
+ return this.globals.integrationInstances[integrationKey];
354
356
  }
355
357
  getComponent(integrationKey, componentKey, props) {
356
- const plugin = this.getPluginInstance(integrationKey);
357
- if (plugin) {
358
- const component = plugin.components && plugin.components.find(
358
+ const integration = this.getIntegrationInstance(integrationKey);
359
+ if (integration) {
360
+ const component = integration.components && integration.components.find(
359
361
  (c) => c.key.toLowerCase() === componentKey.toLowerCase()
360
362
  );
361
363
  if (!component) {
@@ -363,15 +365,15 @@ class ApiInternal {
363
365
  }
364
366
  return component.element({
365
367
  ...props,
366
- plugin,
368
+ plugin: integration,
367
369
  api: new Api(integrationKey)
368
370
  });
369
371
  }
370
372
  }
371
373
  getComponentSchema(integrationKey, componentKey) {
372
- const plugin = this.getPluginInstance(integrationKey);
373
- if (plugin) {
374
- const component = plugin.components && plugin.components.find(
374
+ const integration = this.getIntegrationInstance(integrationKey);
375
+ if (integration) {
376
+ const component = integration.components && integration.components.find(
375
377
  (c) => c.key.toLowerCase() === componentKey.toLowerCase()
376
378
  );
377
379
  if (component) {
@@ -382,29 +384,35 @@ class ApiInternal {
382
384
  }
383
385
  getScreen(integrationKey, screenPath) {
384
386
  if (integrationKey) {
385
- const plugin = this.getPluginInstance(integrationKey);
386
- if (plugin) {
387
- const component = plugin.screens && plugin.screens.find(
387
+ const integration = this.getIntegrationInstance(integrationKey);
388
+ if (integration) {
389
+ const component = integration.screens && integration.screens.find(
388
390
  (s) => s.path.toLowerCase() === screenPath.toLowerCase()
389
391
  );
390
392
  if (!component) {
391
393
  return;
392
394
  }
393
- return component.element({ plugin, api: new Api(integrationKey) });
395
+ return component.element({
396
+ plugin: integration,
397
+ api: new Api(integrationKey)
398
+ });
394
399
  }
395
400
  }
396
401
  }
397
402
  getBoard(integrationKey, boardKey) {
398
403
  if (integrationKey) {
399
- const plugin = this.getPluginInstance(integrationKey);
400
- if (plugin) {
401
- const component = plugin.boards && plugin.boards.find(
404
+ const integration = this.getIntegrationInstance(integrationKey);
405
+ if (integration) {
406
+ const component = integration.boards && integration.boards.find(
402
407
  (c) => c.key.toLowerCase() === boardKey.toLowerCase()
403
408
  );
404
409
  if (!component) {
405
410
  return;
406
411
  }
407
- return component.element({ plugin, api: new Api(integrationKey) });
412
+ return component.element({
413
+ plugin: integration,
414
+ api: new Api(integrationKey)
415
+ });
408
416
  }
409
417
  }
410
418
  }
package/dist/index.umd.js CHANGED
@@ -191,8 +191,8 @@ var __publicField = (obj, key, value) => {
191
191
  messages() {
192
192
  return this.internal.messages();
193
193
  }
194
- plugin(name) {
195
- return this.internal.plugin(name);
194
+ integration(key) {
195
+ return this.internal.integration(key);
196
196
  }
197
197
  get registry() {
198
198
  return this.internal.registry;
@@ -224,26 +224,26 @@ var __publicField = (obj, key, value) => {
224
224
  open(boardKey) {
225
225
  this.internal.open(boardKey);
226
226
  }
227
- get plugins() {
228
- return this.internal.plugins;
227
+ get integrations() {
228
+ return this.internal.integrations;
229
229
  }
230
230
  get api() {
231
- return this.plugin(this.integrationKey).api;
231
+ return this.integration(this.integrationKey).api;
232
232
  }
233
233
  get state() {
234
- return this.plugin(this.integrationKey).state;
234
+ return this.integration(this.integrationKey).state;
235
235
  }
236
236
  get info() {
237
- return this.plugin(this.integrationKey).info;
237
+ return this.integration(this.integrationKey).info;
238
238
  }
239
239
  component(key, props) {
240
- return this.plugin(this.integrationKey).component(key, props);
240
+ return this.integration(this.integrationKey).component(key, props);
241
241
  }
242
242
  componentSchema(key) {
243
- return this.plugin(this.integrationKey).componentSchema(key);
243
+ return this.integration(this.integrationKey).componentSchema(key);
244
244
  }
245
245
  screen(path) {
246
- return this.plugin(this.integrationKey).screen(path);
246
+ return this.integration(this.integrationKey).screen(path);
247
247
  }
248
248
  }
249
249
  class ApiInternal {
@@ -277,8 +277,8 @@ var __publicField = (obj, key, value) => {
277
277
  messages() {
278
278
  return this.globals.messages;
279
279
  }
280
- plugin(name) {
281
- return this.createPluginWrapper(name);
280
+ integration(key) {
281
+ return this.createIntegrationWrapper(key);
282
282
  }
283
283
  get registry() {
284
284
  return this.globals.registry;
@@ -291,6 +291,8 @@ var __publicField = (obj, key, value) => {
291
291
  }
292
292
  get board() {
293
293
  return this.boards.find((board) => board.key === this.boardKey) || {
294
+ title: "Missing board",
295
+ key: "#error",
294
296
  zones: []
295
297
  };
296
298
  }
@@ -312,20 +314,20 @@ var __publicField = (obj, key, value) => {
312
314
  open(boardKey) {
313
315
  this.globals.setLocation(`/${boardKey}`);
314
316
  }
315
- createPluginWrapper(integrationKey) {
316
- const plugin = this.getPluginInstance(integrationKey);
317
- const available = !!plugin;
317
+ createIntegrationWrapper(integrationKey) {
318
+ const integration = this.getIntegrationInstance(integrationKey);
319
+ const available = !!integration;
318
320
  return {
319
321
  available,
320
322
  info: {
321
- components: (plugin == null ? void 0 : plugin.components) ? plugin.components.map((component) => component.key) : [],
322
- screens: (plugin == null ? void 0 : plugin.screens) ? plugin.screens.map((screen) => screen.path) : []
323
+ components: (integration == null ? void 0 : integration.components) ? integration.components.map((component) => component.key) : [],
324
+ screens: (integration == null ? void 0 : integration.screens) ? integration.screens.map((screen) => screen.path) : []
323
325
  },
324
326
  component: (key, props) => this.getComponent(integrationKey, key, props),
325
327
  componentSchema: (key) => this.getComponentSchema(integrationKey, key),
326
328
  screen: (path) => this.getScreen(integrationKey, path),
327
329
  board: (key) => this.getBoard(integrationKey, key),
328
- api: (plugin == null ? void 0 : plugin.api) || {},
330
+ api: (integration == null ? void 0 : integration.api) || {},
329
331
  state: {
330
332
  get: (key, defaultValue) => {
331
333
  if (!available) {
@@ -345,20 +347,20 @@ var __publicField = (obj, key, value) => {
345
347
  get globals() {
346
348
  return window.__dek_globals;
347
349
  }
348
- get plugins() {
349
- const plugins = {};
350
- Object.keys(this.globals.pluginInstances).forEach((key) => {
351
- plugins[key] = this.createPluginWrapper(key);
350
+ get integrations() {
351
+ const integrations = {};
352
+ Object.keys(this.globals.integrationInstances).forEach((key) => {
353
+ integrations[key] = this.createIntegrationWrapper(key);
352
354
  });
353
- return plugins;
355
+ return integrations;
354
356
  }
355
- getPluginInstance(integrationKey) {
356
- return this.globals.pluginInstances[integrationKey];
357
+ getIntegrationInstance(integrationKey) {
358
+ return this.globals.integrationInstances[integrationKey];
357
359
  }
358
360
  getComponent(integrationKey, componentKey, props) {
359
- const plugin = this.getPluginInstance(integrationKey);
360
- if (plugin) {
361
- const component = plugin.components && plugin.components.find(
361
+ const integration = this.getIntegrationInstance(integrationKey);
362
+ if (integration) {
363
+ const component = integration.components && integration.components.find(
362
364
  (c) => c.key.toLowerCase() === componentKey.toLowerCase()
363
365
  );
364
366
  if (!component) {
@@ -366,15 +368,15 @@ var __publicField = (obj, key, value) => {
366
368
  }
367
369
  return component.element({
368
370
  ...props,
369
- plugin,
371
+ plugin: integration,
370
372
  api: new Api(integrationKey)
371
373
  });
372
374
  }
373
375
  }
374
376
  getComponentSchema(integrationKey, componentKey) {
375
- const plugin = this.getPluginInstance(integrationKey);
376
- if (plugin) {
377
- const component = plugin.components && plugin.components.find(
377
+ const integration = this.getIntegrationInstance(integrationKey);
378
+ if (integration) {
379
+ const component = integration.components && integration.components.find(
378
380
  (c) => c.key.toLowerCase() === componentKey.toLowerCase()
379
381
  );
380
382
  if (component) {
@@ -385,29 +387,35 @@ var __publicField = (obj, key, value) => {
385
387
  }
386
388
  getScreen(integrationKey, screenPath) {
387
389
  if (integrationKey) {
388
- const plugin = this.getPluginInstance(integrationKey);
389
- if (plugin) {
390
- const component = plugin.screens && plugin.screens.find(
390
+ const integration = this.getIntegrationInstance(integrationKey);
391
+ if (integration) {
392
+ const component = integration.screens && integration.screens.find(
391
393
  (s) => s.path.toLowerCase() === screenPath.toLowerCase()
392
394
  );
393
395
  if (!component) {
394
396
  return;
395
397
  }
396
- return component.element({ plugin, api: new Api(integrationKey) });
398
+ return component.element({
399
+ plugin: integration,
400
+ api: new Api(integrationKey)
401
+ });
397
402
  }
398
403
  }
399
404
  }
400
405
  getBoard(integrationKey, boardKey) {
401
406
  if (integrationKey) {
402
- const plugin = this.getPluginInstance(integrationKey);
403
- if (plugin) {
404
- const component = plugin.boards && plugin.boards.find(
407
+ const integration = this.getIntegrationInstance(integrationKey);
408
+ if (integration) {
409
+ const component = integration.boards && integration.boards.find(
405
410
  (c) => c.key.toLowerCase() === boardKey.toLowerCase()
406
411
  );
407
412
  if (!component) {
408
413
  return;
409
414
  }
410
- return component.element({ plugin, api: new Api(integrationKey) });
415
+ return component.element({
416
+ plugin: integration,
417
+ api: new Api(integrationKey)
418
+ });
411
419
  }
412
420
  }
413
421
  }
package/dist/lib/api.d.ts CHANGED
@@ -5,6 +5,38 @@ import { DekApiStateType } from './state';
5
5
  export type SetLocationFunc = (to: string, options?: {
6
6
  replace?: boolean | undefined;
7
7
  } | undefined) => void;
8
+ export type DekBoardProperty = {
9
+ key: string;
10
+ value: string;
11
+ };
12
+ export type DekComponent = {
13
+ integration: string;
14
+ component: string;
15
+ props: DekBoardProperty[];
16
+ containerProps: DekBoardProperty[];
17
+ };
18
+ export type DekCommand = DekComponent & {
19
+ title: string;
20
+ };
21
+ export type DekCommandGroup = {
22
+ key: string;
23
+ title: string;
24
+ commands: DekCommand[];
25
+ };
26
+ export type DekZone = DekComponent & {
27
+ key: string;
28
+ };
29
+ export type DekBoardBase = {
30
+ integration: string;
31
+ key: string;
32
+ };
33
+ export type DekBoard = {
34
+ title: string;
35
+ key: string;
36
+ layout?: string | null;
37
+ base?: DekBoardBase | null;
38
+ zones: DekZone[];
39
+ };
8
40
  export type DekApiState = {
9
41
  get: (key: string, defaultValue?: DekApiStateType) => DekApiStateType | undefined;
10
42
  set: (key: string, value: DekApiStateType) => void;
@@ -13,7 +45,7 @@ export type DekApiInfo = {
13
45
  components: string[];
14
46
  screens: string[];
15
47
  };
16
- export type DekApiPlugin = {
48
+ export type DekApiIntegration = {
17
49
  available: boolean;
18
50
  component: (key: string, props?: any) => JSX.Element | undefined;
19
51
  componentSchema: (key: string) => DekPluginSchema;
@@ -35,36 +67,36 @@ export type DekApiInternal = {
35
67
  warn: (integrationKey: string, message: string, ...data: any[]) => void;
36
68
  error: (integrationKey: string, message: string, ...data: any[]) => void;
37
69
  messages: () => DekApiMessage[];
38
- plugin: (name: string) => DekApiPlugin;
70
+ integration: (key: string) => DekApiIntegration;
39
71
  registry: DekRegistry;
40
72
  boardKey: string;
41
- boards: Record<string, any>;
42
- board: any;
73
+ boards: DekBoard[];
74
+ board: DekBoard;
43
75
  layout: string;
44
- commandGroups: Record<string, any>;
76
+ commandGroups: DekCommandGroup[];
45
77
  navigate: (path: string) => void;
46
78
  navigateParams: Record<string, string | undefined>;
47
79
  navigateBack: () => void;
48
80
  open: (boardKey: string) => void;
49
- plugins: Record<string, DekApiPlugin>;
81
+ integrations: Record<string, DekApiIntegration>;
50
82
  };
51
83
  export type DekApi = {
52
84
  trace: (message: string, ...data: any[]) => void;
53
85
  warn: (message: string, ...data: any[]) => void;
54
86
  error: (message: string, ...data: any[]) => void;
55
87
  messages: () => DekApiMessage[];
56
- plugin: (name: string) => DekApiPlugin;
88
+ integration: (key: string) => DekApiIntegration;
57
89
  registry: DekRegistry;
58
90
  boardKey: string;
59
- boards: Record<string, any>;
60
- board: any;
91
+ boards: DekBoard[];
92
+ board: DekBoard;
61
93
  layout: string;
62
- commandGroups: Record<string, any>;
94
+ commandGroups: DekCommandGroup[];
63
95
  navigate: (path: string) => void;
64
96
  navigateParams: Record<string, string | undefined>;
65
97
  navigateBack: () => void;
66
98
  open: (boardKey: string) => void;
67
- plugins: Record<string, DekApiPlugin>;
99
+ integrations: Record<string, DekApiIntegration>;
68
100
  };
69
101
  export declare class Api implements DekApi {
70
102
  integrationKey: string;
@@ -74,18 +106,18 @@ export declare class Api implements DekApi {
74
106
  warn(message: string, ...data: any[]): void;
75
107
  error(message: string, ...data: any[]): void;
76
108
  messages(): DekApiMessage[];
77
- plugin(name: string): DekApiPlugin;
109
+ integration(key: string): DekApiIntegration;
78
110
  get registry(): DekRegistry;
79
111
  get boardKey(): string;
80
- get boards(): Record<string, any>;
81
- get board(): any;
112
+ get boards(): DekBoard[];
113
+ get board(): DekBoard;
82
114
  get layout(): string;
83
- get commandGroups(): Record<string, any>;
115
+ get commandGroups(): DekCommandGroup[];
84
116
  navigate(path: string): void;
85
117
  get navigateParams(): Record<string, string | undefined>;
86
118
  navigateBack(): void;
87
119
  open(boardKey: string): void;
88
- get plugins(): Record<string, DekApiPlugin>;
120
+ get integrations(): Record<string, DekApiIntegration>;
89
121
  get api(): any;
90
122
  get state(): DekApiState;
91
123
  get info(): DekApiInfo;
@@ -98,21 +130,21 @@ export declare class ApiInternal implements DekApiInternal {
98
130
  warn(integrationKey: string, message: string, ...data: any[]): void;
99
131
  error(integrationKey: string, message: string, ...data: any[]): void;
100
132
  messages(): DekApiMessage[];
101
- plugin(name: string): DekApiPlugin;
133
+ integration(key: string): DekApiIntegration;
102
134
  get registry(): DekRegistry;
103
135
  get boardKey(): string;
104
- get boards(): Record<string, any>;
105
- get board(): any;
136
+ get boards(): DekBoard[];
137
+ get board(): DekBoard;
106
138
  get layout(): string;
107
- get commandGroups(): Record<string, any>;
139
+ get commandGroups(): DekCommandGroup[];
108
140
  navigate(path: string): void;
109
141
  get navigateParams(): Record<string, string | undefined>;
110
142
  navigateBack(): void;
111
143
  open(boardKey: string): void;
112
- private createPluginWrapper;
144
+ private createIntegrationWrapper;
113
145
  private get globals();
114
- get plugins(): Record<string, DekApiPlugin>;
115
- private getPluginInstance;
146
+ get integrations(): Record<string, DekApiIntegration>;
147
+ private getIntegrationInstance;
116
148
  private getComponent;
117
149
  private getComponentSchema;
118
150
  private getScreen;
@@ -44,3 +44,4 @@ export type DekPlugin = {
44
44
  };
45
45
  export declare class DekPluginFactory implements DekPlugin {
46
46
  }
47
+ export type DekIntegration = DekPlugin;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@appkit/dek-plugin",
3
3
  "private": false,
4
- "version": "0.25.0",
4
+ "version": "0.27.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",