@appkit/dek-plugin 0.9.0 → 0.11.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 +1 -2
- package/dist/index.es.js +110 -24
- package/dist/index.umd.js +111 -25
- package/dist/lib/api.d.ts +48 -1
- package/dist/lib/hooks/usePluginState.d.ts +7 -6
- package/dist/lib/plugins.d.ts +8 -5
- package/dist/lib/state.d.ts +2 -2
- package/package.json +1 -1
- package/dist/lib/hooks/usePluginApi.d.ts +0 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
export type { DekPlugin, DekPluginBoardItem, DekPluginComponentItem, DekPluginConfig, DekPluginFactory, DekPluginSchema, DekPluginSchemaItem, DekPluginScreenItem, } from './lib/plugins';
|
|
1
|
+
export type { DekPlugin, DekPluginBoardItem, DekPluginComponentItem, DekPluginConfig, DekPluginElementFactoryWithProps, DekPluginElementProps, DekPluginFactory, DekPluginSchema, DekPluginSchemaItem, DekPluginScreenItem, } from './lib/plugins';
|
|
2
2
|
export type { DekRegistry, DekRegistryCollection, DekRegistryCollectionItem, DekRegistrySchema, DekRegistrySchemaItem, DekRegistrySchemaProps, DekRegistrySchemaPropsItem, } from './lib/registry';
|
|
3
3
|
export type { DekApi, DekApiInfo, DekApiMessage, DekApiMessageType, DekApiPlugin, DekApiState, } from './lib/api';
|
|
4
|
-
export { default as usePluginApi } from './lib/hooks/usePluginApi';
|
|
5
4
|
export { default as usePluginState } from './lib/hooks/usePluginState';
|
|
6
5
|
export declare function __debug(): void;
|
package/dist/index.es.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
1
7
|
import { useRef, useCallback, useEffect, useLayoutEffect, useState as useState$1 } from "react";
|
|
2
8
|
globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
3
9
|
function adopt(value) {
|
|
@@ -131,21 +137,21 @@ function parseJSON(value) {
|
|
|
131
137
|
function extractErrorMessage(err) {
|
|
132
138
|
return err instanceof Error ? err.message : JSON.stringify(err);
|
|
133
139
|
}
|
|
134
|
-
function setState(
|
|
135
|
-
const localData = getStateRoot(
|
|
140
|
+
function setState(integrationKey, key, value) {
|
|
141
|
+
const localData = getStateRoot(integrationKey);
|
|
136
142
|
localData[key] = value;
|
|
137
143
|
localStorage.setItem(
|
|
138
|
-
`api:${
|
|
144
|
+
`api:${integrationKey.toLowerCase()}`,
|
|
139
145
|
JSON.stringify(localData)
|
|
140
146
|
);
|
|
141
147
|
window.dispatchEvent(new Event("local-storage"));
|
|
142
148
|
}
|
|
143
|
-
function getState(
|
|
144
|
-
const localData = getStateRoot(
|
|
149
|
+
function getState(integrationKey, key) {
|
|
150
|
+
const localData = getStateRoot(integrationKey);
|
|
145
151
|
return localData[key];
|
|
146
152
|
}
|
|
147
|
-
function getStateRoot(
|
|
148
|
-
const local = localStorage.getItem(`api:${
|
|
153
|
+
function getStateRoot(integrationKey) {
|
|
154
|
+
const local = localStorage.getItem(`api:${integrationKey.toLowerCase()}`);
|
|
149
155
|
return tryParseJson(local || "{}");
|
|
150
156
|
}
|
|
151
157
|
function tryParseJson(jsonString, defaultValue = {}) {
|
|
@@ -176,8 +182,83 @@ function isJsonString(str) {
|
|
|
176
182
|
return true;
|
|
177
183
|
}
|
|
178
184
|
class Api {
|
|
185
|
+
constructor(integrationKey) {
|
|
186
|
+
__publicField(this, "integrationKey");
|
|
187
|
+
this.integrationKey = integrationKey;
|
|
188
|
+
}
|
|
189
|
+
get internal() {
|
|
190
|
+
return window.__dek_api;
|
|
191
|
+
}
|
|
179
192
|
trace(message, ...data) {
|
|
180
|
-
|
|
193
|
+
this.internal.trace(this.integrationKey, message, ...data);
|
|
194
|
+
}
|
|
195
|
+
warn(message, ...data) {
|
|
196
|
+
this.internal.warn(this.integrationKey, message, ...data);
|
|
197
|
+
}
|
|
198
|
+
error(message, ...data) {
|
|
199
|
+
this.internal.error(this.integrationKey, message, ...data);
|
|
200
|
+
}
|
|
201
|
+
messages() {
|
|
202
|
+
return this.internal.messages();
|
|
203
|
+
}
|
|
204
|
+
plugin(name) {
|
|
205
|
+
return this.internal.plugin(name);
|
|
206
|
+
}
|
|
207
|
+
get registry() {
|
|
208
|
+
return this.internal.registry;
|
|
209
|
+
}
|
|
210
|
+
get boardKey() {
|
|
211
|
+
return this.internal.boardKey;
|
|
212
|
+
}
|
|
213
|
+
get boards() {
|
|
214
|
+
return this.internal.boards;
|
|
215
|
+
}
|
|
216
|
+
get board() {
|
|
217
|
+
return this.internal.board;
|
|
218
|
+
}
|
|
219
|
+
get layout() {
|
|
220
|
+
return this.internal.layout;
|
|
221
|
+
}
|
|
222
|
+
get commandGroups() {
|
|
223
|
+
return this.internal.commandGroups;
|
|
224
|
+
}
|
|
225
|
+
navigate(path) {
|
|
226
|
+
this.internal.navigate(path);
|
|
227
|
+
}
|
|
228
|
+
get navigateParams() {
|
|
229
|
+
return this.internal.navigateParams;
|
|
230
|
+
}
|
|
231
|
+
navigateBack() {
|
|
232
|
+
this.internal.navigateBack();
|
|
233
|
+
}
|
|
234
|
+
open(boardKey) {
|
|
235
|
+
this.internal.open(boardKey);
|
|
236
|
+
}
|
|
237
|
+
get plugins() {
|
|
238
|
+
return this.internal.plugins;
|
|
239
|
+
}
|
|
240
|
+
get api() {
|
|
241
|
+
return this.plugin(this.integrationKey).api;
|
|
242
|
+
}
|
|
243
|
+
get state() {
|
|
244
|
+
return this.plugin(this.integrationKey).state;
|
|
245
|
+
}
|
|
246
|
+
get info() {
|
|
247
|
+
return this.plugin(this.integrationKey).info;
|
|
248
|
+
}
|
|
249
|
+
component(key, props) {
|
|
250
|
+
return this.plugin(this.integrationKey).component(key, props);
|
|
251
|
+
}
|
|
252
|
+
componentSchema(key) {
|
|
253
|
+
return this.plugin(this.integrationKey).componentSchema(key);
|
|
254
|
+
}
|
|
255
|
+
screen(path) {
|
|
256
|
+
return this.plugin(this.integrationKey).screen(path);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
class ApiInternal {
|
|
260
|
+
trace(integrationKey, message, ...data) {
|
|
261
|
+
console.log(`DEK-TRACE[${integrationKey}]: ${message}`, ...data);
|
|
181
262
|
this.globals.messages.push({
|
|
182
263
|
type: "trace",
|
|
183
264
|
body: message,
|
|
@@ -185,8 +266,8 @@ class Api {
|
|
|
185
266
|
at: Date.now()
|
|
186
267
|
});
|
|
187
268
|
}
|
|
188
|
-
warn(message, ...data) {
|
|
189
|
-
console.warn(`DEK-WARN: ${message}`, ...data);
|
|
269
|
+
warn(integrationKey, message, ...data) {
|
|
270
|
+
console.warn(`DEK-WARN[${integrationKey}]: ${message}`, ...data);
|
|
190
271
|
this.globals.messages.push({
|
|
191
272
|
type: "error",
|
|
192
273
|
body: message,
|
|
@@ -194,8 +275,8 @@ class Api {
|
|
|
194
275
|
at: Date.now()
|
|
195
276
|
});
|
|
196
277
|
}
|
|
197
|
-
error(message, ...data) {
|
|
198
|
-
console.error(`DEK-ERROR: ${message}`, ...data);
|
|
278
|
+
error(integrationKey, message, ...data) {
|
|
279
|
+
console.error(`DEK-ERROR[${integrationKey}]: ${message}`, ...data);
|
|
199
280
|
this.globals.messages.push({
|
|
200
281
|
type: "error",
|
|
201
282
|
body: message,
|
|
@@ -213,7 +294,7 @@ class Api {
|
|
|
213
294
|
return this.globals.registry;
|
|
214
295
|
}
|
|
215
296
|
get boardKey() {
|
|
216
|
-
return this.globals.boardKey;
|
|
297
|
+
return this.globals.navigateParams.boardKey || "#error";
|
|
217
298
|
}
|
|
218
299
|
get boards() {
|
|
219
300
|
return this.globals.boards;
|
|
@@ -232,6 +313,9 @@ class Api {
|
|
|
232
313
|
navigate(path) {
|
|
233
314
|
this.globals.setLocation(`/${this.boardKey}${path}`);
|
|
234
315
|
}
|
|
316
|
+
get navigateParams() {
|
|
317
|
+
return this.globals.navigateParams;
|
|
318
|
+
}
|
|
235
319
|
navigateBack() {
|
|
236
320
|
history.back();
|
|
237
321
|
}
|
|
@@ -290,7 +374,11 @@ class Api {
|
|
|
290
374
|
if (!component) {
|
|
291
375
|
return;
|
|
292
376
|
}
|
|
293
|
-
return component.element({
|
|
377
|
+
return component.element({
|
|
378
|
+
...props,
|
|
379
|
+
plugin,
|
|
380
|
+
api: new Api(integrationKey)
|
|
381
|
+
});
|
|
294
382
|
}
|
|
295
383
|
}
|
|
296
384
|
getComponentSchema(integrationKey, componentKey) {
|
|
@@ -315,7 +403,7 @@ class Api {
|
|
|
315
403
|
if (!component) {
|
|
316
404
|
return;
|
|
317
405
|
}
|
|
318
|
-
return component.element({ plugin });
|
|
406
|
+
return component.element({ plugin, api: new Api(integrationKey) });
|
|
319
407
|
}
|
|
320
408
|
}
|
|
321
409
|
}
|
|
@@ -329,18 +417,17 @@ class Api {
|
|
|
329
417
|
if (!component) {
|
|
330
418
|
return;
|
|
331
419
|
}
|
|
332
|
-
return component.element({ plugin });
|
|
420
|
+
return component.element({ plugin, api: new Api(integrationKey) });
|
|
333
421
|
}
|
|
334
422
|
}
|
|
335
423
|
}
|
|
336
424
|
}
|
|
337
|
-
const api = new
|
|
425
|
+
const api = new ApiInternal();
|
|
338
426
|
window.__dek_api = api;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const state = useState(plugin);
|
|
427
|
+
window.__dek_api_factory = (integrationKey) => new Api(integrationKey);
|
|
428
|
+
function usePluginState(api2, key, defaultValue) {
|
|
429
|
+
const integrationKey = api2.integrationKey;
|
|
430
|
+
const state = useState(integrationKey);
|
|
344
431
|
let value;
|
|
345
432
|
if (state && state[key]) {
|
|
346
433
|
value = state[key];
|
|
@@ -356,7 +443,7 @@ function usePluginState(plugin, key, defaultValue) {
|
|
|
356
443
|
if (typeof newValue === "object") {
|
|
357
444
|
newValue = JSON.stringify(newValue);
|
|
358
445
|
}
|
|
359
|
-
setState(
|
|
446
|
+
setState(integrationKey, key, newValue);
|
|
360
447
|
}
|
|
361
448
|
];
|
|
362
449
|
}
|
|
@@ -364,6 +451,5 @@ function __debug() {
|
|
|
364
451
|
}
|
|
365
452
|
export {
|
|
366
453
|
__debug,
|
|
367
|
-
usePluginApi,
|
|
368
454
|
usePluginState
|
|
369
455
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.index = {}, global.React));
|
|
3
3
|
})(this, function(exports2, react) {
|
|
4
|
-
"use strict";
|
|
4
|
+
"use strict";var __defProp = Object.defineProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => {
|
|
7
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
globalThis && globalThis.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
6
12
|
function adopt(value) {
|
|
7
13
|
return value instanceof P ? value : new P(function(resolve) {
|
|
@@ -134,21 +140,21 @@
|
|
|
134
140
|
function extractErrorMessage(err) {
|
|
135
141
|
return err instanceof Error ? err.message : JSON.stringify(err);
|
|
136
142
|
}
|
|
137
|
-
function setState(
|
|
138
|
-
const localData = getStateRoot(
|
|
143
|
+
function setState(integrationKey, key, value) {
|
|
144
|
+
const localData = getStateRoot(integrationKey);
|
|
139
145
|
localData[key] = value;
|
|
140
146
|
localStorage.setItem(
|
|
141
|
-
`api:${
|
|
147
|
+
`api:${integrationKey.toLowerCase()}`,
|
|
142
148
|
JSON.stringify(localData)
|
|
143
149
|
);
|
|
144
150
|
window.dispatchEvent(new Event("local-storage"));
|
|
145
151
|
}
|
|
146
|
-
function getState(
|
|
147
|
-
const localData = getStateRoot(
|
|
152
|
+
function getState(integrationKey, key) {
|
|
153
|
+
const localData = getStateRoot(integrationKey);
|
|
148
154
|
return localData[key];
|
|
149
155
|
}
|
|
150
|
-
function getStateRoot(
|
|
151
|
-
const local = localStorage.getItem(`api:${
|
|
156
|
+
function getStateRoot(integrationKey) {
|
|
157
|
+
const local = localStorage.getItem(`api:${integrationKey.toLowerCase()}`);
|
|
152
158
|
return tryParseJson(local || "{}");
|
|
153
159
|
}
|
|
154
160
|
function tryParseJson(jsonString, defaultValue = {}) {
|
|
@@ -179,8 +185,83 @@
|
|
|
179
185
|
return true;
|
|
180
186
|
}
|
|
181
187
|
class Api {
|
|
188
|
+
constructor(integrationKey) {
|
|
189
|
+
__publicField(this, "integrationKey");
|
|
190
|
+
this.integrationKey = integrationKey;
|
|
191
|
+
}
|
|
192
|
+
get internal() {
|
|
193
|
+
return window.__dek_api;
|
|
194
|
+
}
|
|
182
195
|
trace(message, ...data) {
|
|
183
|
-
|
|
196
|
+
this.internal.trace(this.integrationKey, message, ...data);
|
|
197
|
+
}
|
|
198
|
+
warn(message, ...data) {
|
|
199
|
+
this.internal.warn(this.integrationKey, message, ...data);
|
|
200
|
+
}
|
|
201
|
+
error(message, ...data) {
|
|
202
|
+
this.internal.error(this.integrationKey, message, ...data);
|
|
203
|
+
}
|
|
204
|
+
messages() {
|
|
205
|
+
return this.internal.messages();
|
|
206
|
+
}
|
|
207
|
+
plugin(name) {
|
|
208
|
+
return this.internal.plugin(name);
|
|
209
|
+
}
|
|
210
|
+
get registry() {
|
|
211
|
+
return this.internal.registry;
|
|
212
|
+
}
|
|
213
|
+
get boardKey() {
|
|
214
|
+
return this.internal.boardKey;
|
|
215
|
+
}
|
|
216
|
+
get boards() {
|
|
217
|
+
return this.internal.boards;
|
|
218
|
+
}
|
|
219
|
+
get board() {
|
|
220
|
+
return this.internal.board;
|
|
221
|
+
}
|
|
222
|
+
get layout() {
|
|
223
|
+
return this.internal.layout;
|
|
224
|
+
}
|
|
225
|
+
get commandGroups() {
|
|
226
|
+
return this.internal.commandGroups;
|
|
227
|
+
}
|
|
228
|
+
navigate(path) {
|
|
229
|
+
this.internal.navigate(path);
|
|
230
|
+
}
|
|
231
|
+
get navigateParams() {
|
|
232
|
+
return this.internal.navigateParams;
|
|
233
|
+
}
|
|
234
|
+
navigateBack() {
|
|
235
|
+
this.internal.navigateBack();
|
|
236
|
+
}
|
|
237
|
+
open(boardKey) {
|
|
238
|
+
this.internal.open(boardKey);
|
|
239
|
+
}
|
|
240
|
+
get plugins() {
|
|
241
|
+
return this.internal.plugins;
|
|
242
|
+
}
|
|
243
|
+
get api() {
|
|
244
|
+
return this.plugin(this.integrationKey).api;
|
|
245
|
+
}
|
|
246
|
+
get state() {
|
|
247
|
+
return this.plugin(this.integrationKey).state;
|
|
248
|
+
}
|
|
249
|
+
get info() {
|
|
250
|
+
return this.plugin(this.integrationKey).info;
|
|
251
|
+
}
|
|
252
|
+
component(key, props) {
|
|
253
|
+
return this.plugin(this.integrationKey).component(key, props);
|
|
254
|
+
}
|
|
255
|
+
componentSchema(key) {
|
|
256
|
+
return this.plugin(this.integrationKey).componentSchema(key);
|
|
257
|
+
}
|
|
258
|
+
screen(path) {
|
|
259
|
+
return this.plugin(this.integrationKey).screen(path);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
class ApiInternal {
|
|
263
|
+
trace(integrationKey, message, ...data) {
|
|
264
|
+
console.log(`DEK-TRACE[${integrationKey}]: ${message}`, ...data);
|
|
184
265
|
this.globals.messages.push({
|
|
185
266
|
type: "trace",
|
|
186
267
|
body: message,
|
|
@@ -188,8 +269,8 @@
|
|
|
188
269
|
at: Date.now()
|
|
189
270
|
});
|
|
190
271
|
}
|
|
191
|
-
warn(message, ...data) {
|
|
192
|
-
console.warn(`DEK-WARN: ${message}`, ...data);
|
|
272
|
+
warn(integrationKey, message, ...data) {
|
|
273
|
+
console.warn(`DEK-WARN[${integrationKey}]: ${message}`, ...data);
|
|
193
274
|
this.globals.messages.push({
|
|
194
275
|
type: "error",
|
|
195
276
|
body: message,
|
|
@@ -197,8 +278,8 @@
|
|
|
197
278
|
at: Date.now()
|
|
198
279
|
});
|
|
199
280
|
}
|
|
200
|
-
error(message, ...data) {
|
|
201
|
-
console.error(`DEK-ERROR: ${message}`, ...data);
|
|
281
|
+
error(integrationKey, message, ...data) {
|
|
282
|
+
console.error(`DEK-ERROR[${integrationKey}]: ${message}`, ...data);
|
|
202
283
|
this.globals.messages.push({
|
|
203
284
|
type: "error",
|
|
204
285
|
body: message,
|
|
@@ -216,7 +297,7 @@
|
|
|
216
297
|
return this.globals.registry;
|
|
217
298
|
}
|
|
218
299
|
get boardKey() {
|
|
219
|
-
return this.globals.boardKey;
|
|
300
|
+
return this.globals.navigateParams.boardKey || "#error";
|
|
220
301
|
}
|
|
221
302
|
get boards() {
|
|
222
303
|
return this.globals.boards;
|
|
@@ -235,6 +316,9 @@
|
|
|
235
316
|
navigate(path) {
|
|
236
317
|
this.globals.setLocation(`/${this.boardKey}${path}`);
|
|
237
318
|
}
|
|
319
|
+
get navigateParams() {
|
|
320
|
+
return this.globals.navigateParams;
|
|
321
|
+
}
|
|
238
322
|
navigateBack() {
|
|
239
323
|
history.back();
|
|
240
324
|
}
|
|
@@ -293,7 +377,11 @@
|
|
|
293
377
|
if (!component) {
|
|
294
378
|
return;
|
|
295
379
|
}
|
|
296
|
-
return component.element({
|
|
380
|
+
return component.element({
|
|
381
|
+
...props,
|
|
382
|
+
plugin,
|
|
383
|
+
api: new Api(integrationKey)
|
|
384
|
+
});
|
|
297
385
|
}
|
|
298
386
|
}
|
|
299
387
|
getComponentSchema(integrationKey, componentKey) {
|
|
@@ -318,7 +406,7 @@
|
|
|
318
406
|
if (!component) {
|
|
319
407
|
return;
|
|
320
408
|
}
|
|
321
|
-
return component.element({ plugin });
|
|
409
|
+
return component.element({ plugin, api: new Api(integrationKey) });
|
|
322
410
|
}
|
|
323
411
|
}
|
|
324
412
|
}
|
|
@@ -332,18 +420,17 @@
|
|
|
332
420
|
if (!component) {
|
|
333
421
|
return;
|
|
334
422
|
}
|
|
335
|
-
return component.element({ plugin });
|
|
423
|
+
return component.element({ plugin, api: new Api(integrationKey) });
|
|
336
424
|
}
|
|
337
425
|
}
|
|
338
426
|
}
|
|
339
427
|
}
|
|
340
|
-
const api = new
|
|
428
|
+
const api = new ApiInternal();
|
|
341
429
|
window.__dek_api = api;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
const state = useState(plugin);
|
|
430
|
+
window.__dek_api_factory = (integrationKey) => new Api(integrationKey);
|
|
431
|
+
function usePluginState(api2, key, defaultValue) {
|
|
432
|
+
const integrationKey = api2.integrationKey;
|
|
433
|
+
const state = useState(integrationKey);
|
|
347
434
|
let value;
|
|
348
435
|
if (state && state[key]) {
|
|
349
436
|
value = state[key];
|
|
@@ -359,14 +446,13 @@
|
|
|
359
446
|
if (typeof newValue === "object") {
|
|
360
447
|
newValue = JSON.stringify(newValue);
|
|
361
448
|
}
|
|
362
|
-
setState(
|
|
449
|
+
setState(integrationKey, key, newValue);
|
|
363
450
|
}
|
|
364
451
|
];
|
|
365
452
|
}
|
|
366
453
|
function __debug() {
|
|
367
454
|
}
|
|
368
455
|
exports2.__debug = __debug;
|
|
369
|
-
exports2.usePluginApi = usePluginApi;
|
|
370
456
|
exports2.usePluginState = usePluginState;
|
|
371
457
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
372
458
|
});
|
package/dist/lib/api.d.ts
CHANGED
|
@@ -30,6 +30,24 @@ export type DekApiMessage = {
|
|
|
30
30
|
data?: any[];
|
|
31
31
|
at: number;
|
|
32
32
|
};
|
|
33
|
+
export type DekApiInternal = {
|
|
34
|
+
trace: (integrationKey: string, message: string, ...data: any[]) => void;
|
|
35
|
+
warn: (integrationKey: string, message: string, ...data: any[]) => void;
|
|
36
|
+
error: (integrationKey: string, message: string, ...data: any[]) => void;
|
|
37
|
+
messages: () => DekApiMessage[];
|
|
38
|
+
plugin: (name: string) => DekApiPlugin;
|
|
39
|
+
registry: DekRegistry;
|
|
40
|
+
boardKey: string;
|
|
41
|
+
boards: Record<string, any>;
|
|
42
|
+
board: any;
|
|
43
|
+
layout: string;
|
|
44
|
+
commandGroups: Record<string, any>;
|
|
45
|
+
navigate: (path: string) => void;
|
|
46
|
+
navigateParams: Record<string, string | undefined>;
|
|
47
|
+
navigateBack: () => void;
|
|
48
|
+
open: (boardKey: string) => void;
|
|
49
|
+
plugins: Record<string, DekApiPlugin>;
|
|
50
|
+
};
|
|
33
51
|
export type DekApi = {
|
|
34
52
|
trace: (message: string, ...data: any[]) => void;
|
|
35
53
|
warn: (message: string, ...data: any[]) => void;
|
|
@@ -43,11 +61,15 @@ export type DekApi = {
|
|
|
43
61
|
layout: string;
|
|
44
62
|
commandGroups: Record<string, any>;
|
|
45
63
|
navigate: (path: string) => void;
|
|
64
|
+
navigateParams: Record<string, string | undefined>;
|
|
46
65
|
navigateBack: () => void;
|
|
47
66
|
open: (boardKey: string) => void;
|
|
48
67
|
plugins: Record<string, DekApiPlugin>;
|
|
49
68
|
};
|
|
50
69
|
export declare class Api implements DekApi {
|
|
70
|
+
integrationKey: string;
|
|
71
|
+
constructor(integrationKey: string);
|
|
72
|
+
get internal(): DekApiInternal;
|
|
51
73
|
trace(message: string, ...data: any[]): void;
|
|
52
74
|
warn(message: string, ...data: any[]): void;
|
|
53
75
|
error(message: string, ...data: any[]): void;
|
|
@@ -60,6 +82,31 @@ export declare class Api implements DekApi {
|
|
|
60
82
|
get layout(): string;
|
|
61
83
|
get commandGroups(): Record<string, any>;
|
|
62
84
|
navigate(path: string): void;
|
|
85
|
+
get navigateParams(): Record<string, string | undefined>;
|
|
86
|
+
navigateBack(): void;
|
|
87
|
+
open(boardKey: string): void;
|
|
88
|
+
get plugins(): Record<string, DekApiPlugin>;
|
|
89
|
+
get api(): any;
|
|
90
|
+
get state(): DekApiState;
|
|
91
|
+
get info(): DekApiInfo;
|
|
92
|
+
component(key: string, props?: any): JSX.Element | undefined;
|
|
93
|
+
componentSchema(key: string): DekPluginSchema;
|
|
94
|
+
screen(path: string): JSX.Element | undefined;
|
|
95
|
+
}
|
|
96
|
+
export declare class ApiInternal implements DekApiInternal {
|
|
97
|
+
trace(integrationKey: string, message: string, ...data: any[]): void;
|
|
98
|
+
warn(integrationKey: string, message: string, ...data: any[]): void;
|
|
99
|
+
error(integrationKey: string, message: string, ...data: any[]): void;
|
|
100
|
+
messages(): DekApiMessage[];
|
|
101
|
+
plugin(name: string): DekApiPlugin;
|
|
102
|
+
get registry(): DekRegistry;
|
|
103
|
+
get boardKey(): string;
|
|
104
|
+
get boards(): Record<string, any>;
|
|
105
|
+
get board(): any;
|
|
106
|
+
get layout(): string;
|
|
107
|
+
get commandGroups(): Record<string, any>;
|
|
108
|
+
navigate(path: string): void;
|
|
109
|
+
get navigateParams(): Record<string, string | undefined>;
|
|
63
110
|
navigateBack(): void;
|
|
64
111
|
open(boardKey: string): void;
|
|
65
112
|
private createPluginWrapper;
|
|
@@ -71,5 +118,5 @@ export declare class Api implements DekApi {
|
|
|
71
118
|
private getScreen;
|
|
72
119
|
private getBoard;
|
|
73
120
|
}
|
|
74
|
-
declare const api:
|
|
121
|
+
declare const api: ApiInternal;
|
|
75
122
|
export default api;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { DekApi } from '../api';
|
|
1
2
|
import { DekApiStateType } from '../state';
|
|
2
3
|
export type ApiSetStateAction = (value: DekApiStateType) => void;
|
|
3
|
-
declare function usePluginState(
|
|
4
|
-
declare function usePluginState(
|
|
5
|
-
declare function usePluginState(
|
|
6
|
-
declare function usePluginState(
|
|
7
|
-
declare function usePluginState(
|
|
8
|
-
declare function usePluginState(
|
|
4
|
+
declare function usePluginState(api: DekApi, key: string): [DekApiStateType | undefined, ApiSetStateAction];
|
|
5
|
+
declare function usePluginState(api: DekApi, key: string, defaultValue: string): [string, ApiSetStateAction];
|
|
6
|
+
declare function usePluginState(api: DekApi, key: string, defaultValue: number): [number, ApiSetStateAction];
|
|
7
|
+
declare function usePluginState(api: DekApi, key: string, defaultValue: boolean): [boolean, ApiSetStateAction];
|
|
8
|
+
declare function usePluginState(api: DekApi, key: string, defaultValue: Array<any>): [Array<any>, ApiSetStateAction];
|
|
9
|
+
declare function usePluginState(api: DekApi, key: string, defaultValue: Record<string, any>): [Record<string, any>, ApiSetStateAction];
|
|
9
10
|
export default usePluginState;
|
package/dist/lib/plugins.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { DekApi } from './api';
|
|
3
|
-
export type
|
|
4
|
-
|
|
3
|
+
export type DekPluginElementProps = Record<string, any> & {
|
|
4
|
+
plugin: DekPlugin;
|
|
5
|
+
api: DekApi;
|
|
6
|
+
};
|
|
7
|
+
export type DekPluginElementFactoryWithProps = (props: DekPluginElementProps) => JSX.Element;
|
|
5
8
|
export type DekPluginSchemaItem = {
|
|
6
9
|
type: string;
|
|
7
10
|
title?: string;
|
|
@@ -11,16 +14,16 @@ export type DekPluginSchema = Record<string, DekPluginSchemaItem>;
|
|
|
11
14
|
export type DekPluginComponentItem = {
|
|
12
15
|
key: string;
|
|
13
16
|
description?: string;
|
|
14
|
-
element:
|
|
17
|
+
element: DekPluginElementFactoryWithProps;
|
|
15
18
|
schema?: DekPluginSchema;
|
|
16
19
|
};
|
|
17
20
|
export type DekPluginScreenItem = {
|
|
18
21
|
path: string;
|
|
19
|
-
element:
|
|
22
|
+
element: DekPluginElementFactoryWithProps;
|
|
20
23
|
};
|
|
21
24
|
export type DekPluginBoardItem = {
|
|
22
25
|
key: string;
|
|
23
|
-
element:
|
|
26
|
+
element: DekPluginElementFactoryWithProps;
|
|
24
27
|
};
|
|
25
28
|
export type DekPluginConfig = Record<string, string>;
|
|
26
29
|
export type DekPlugin = {
|
package/dist/lib/state.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type DekApiStateType = string | number | boolean | Array<any> | Record<string, any>;
|
|
2
2
|
export type DekApiStateItem = Record<string, DekApiStateType>;
|
|
3
3
|
export type DekApiState = Record<string, DekApiStateItem>;
|
|
4
|
-
export declare function setState(
|
|
5
|
-
export declare function getState(
|
|
4
|
+
export declare function setState(integrationKey: string, key: string, value: DekApiStateType): void;
|
|
5
|
+
export declare function getState(integrationKey: string, key: string): DekApiStateType | undefined;
|
|
6
6
|
export declare function tryParseJson(jsonString: string, defaultValue?: {}): object;
|
|
7
7
|
export declare function useState(plugin: string): DekApiStateItem;
|
|
8
8
|
export declare function isJsonString(str: any): boolean;
|
package/package.json
CHANGED