@appkit/dek-plugin 0.10.0 → 0.12.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 +106 -23
- package/dist/index.umd.js +107 -24
- package/dist/lib/api.d.ts +46 -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,
|
|
@@ -293,7 +374,11 @@ class Api {
|
|
|
293
374
|
if (!component) {
|
|
294
375
|
return;
|
|
295
376
|
}
|
|
296
|
-
return component.element({
|
|
377
|
+
return component.element({
|
|
378
|
+
...props,
|
|
379
|
+
plugin,
|
|
380
|
+
api: new Api(integrationKey)
|
|
381
|
+
});
|
|
297
382
|
}
|
|
298
383
|
}
|
|
299
384
|
getComponentSchema(integrationKey, componentKey) {
|
|
@@ -318,7 +403,7 @@ class Api {
|
|
|
318
403
|
if (!component) {
|
|
319
404
|
return;
|
|
320
405
|
}
|
|
321
|
-
return component.element({ plugin });
|
|
406
|
+
return component.element({ plugin, api: new Api(integrationKey) });
|
|
322
407
|
}
|
|
323
408
|
}
|
|
324
409
|
}
|
|
@@ -332,18 +417,17 @@ class Api {
|
|
|
332
417
|
if (!component) {
|
|
333
418
|
return;
|
|
334
419
|
}
|
|
335
|
-
return component.element({ plugin });
|
|
420
|
+
return component.element({ plugin, api: new Api(integrationKey) });
|
|
336
421
|
}
|
|
337
422
|
}
|
|
338
423
|
}
|
|
339
424
|
}
|
|
340
|
-
const api = new
|
|
425
|
+
const api = new ApiInternal();
|
|
341
426
|
window.__dek_api = api;
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
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);
|
|
347
431
|
let value;
|
|
348
432
|
if (state && state[key]) {
|
|
349
433
|
value = state[key];
|
|
@@ -359,7 +443,7 @@ function usePluginState(plugin, key, defaultValue) {
|
|
|
359
443
|
if (typeof newValue === "object") {
|
|
360
444
|
newValue = JSON.stringify(newValue);
|
|
361
445
|
}
|
|
362
|
-
setState(
|
|
446
|
+
setState(integrationKey, key, newValue);
|
|
363
447
|
}
|
|
364
448
|
];
|
|
365
449
|
}
|
|
@@ -367,6 +451,5 @@ function __debug() {
|
|
|
367
451
|
}
|
|
368
452
|
export {
|
|
369
453
|
__debug,
|
|
370
|
-
usePluginApi,
|
|
371
454
|
usePluginState
|
|
372
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,
|
|
@@ -296,7 +377,11 @@
|
|
|
296
377
|
if (!component) {
|
|
297
378
|
return;
|
|
298
379
|
}
|
|
299
|
-
return component.element({
|
|
380
|
+
return component.element({
|
|
381
|
+
...props,
|
|
382
|
+
plugin,
|
|
383
|
+
api: new Api(integrationKey)
|
|
384
|
+
});
|
|
300
385
|
}
|
|
301
386
|
}
|
|
302
387
|
getComponentSchema(integrationKey, componentKey) {
|
|
@@ -321,7 +406,7 @@
|
|
|
321
406
|
if (!component) {
|
|
322
407
|
return;
|
|
323
408
|
}
|
|
324
|
-
return component.element({ plugin });
|
|
409
|
+
return component.element({ plugin, api: new Api(integrationKey) });
|
|
325
410
|
}
|
|
326
411
|
}
|
|
327
412
|
}
|
|
@@ -335,18 +420,17 @@
|
|
|
335
420
|
if (!component) {
|
|
336
421
|
return;
|
|
337
422
|
}
|
|
338
|
-
return component.element({ plugin });
|
|
423
|
+
return component.element({ plugin, api: new Api(integrationKey) });
|
|
339
424
|
}
|
|
340
425
|
}
|
|
341
426
|
}
|
|
342
427
|
}
|
|
343
|
-
const api = new
|
|
428
|
+
const api = new ApiInternal();
|
|
344
429
|
window.__dek_api = api;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
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);
|
|
350
434
|
let value;
|
|
351
435
|
if (state && state[key]) {
|
|
352
436
|
value = state[key];
|
|
@@ -362,14 +446,13 @@
|
|
|
362
446
|
if (typeof newValue === "object") {
|
|
363
447
|
newValue = JSON.stringify(newValue);
|
|
364
448
|
}
|
|
365
|
-
setState(
|
|
449
|
+
setState(integrationKey, key, newValue);
|
|
366
450
|
}
|
|
367
451
|
];
|
|
368
452
|
}
|
|
369
453
|
function __debug() {
|
|
370
454
|
}
|
|
371
455
|
exports2.__debug = __debug;
|
|
372
|
-
exports2.usePluginApi = usePluginApi;
|
|
373
456
|
exports2.usePluginState = usePluginState;
|
|
374
457
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
375
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;
|
|
@@ -49,6 +67,9 @@ export type DekApi = {
|
|
|
49
67
|
plugins: Record<string, DekApiPlugin>;
|
|
50
68
|
};
|
|
51
69
|
export declare class Api implements DekApi {
|
|
70
|
+
integrationKey: string;
|
|
71
|
+
constructor(integrationKey: string);
|
|
72
|
+
get internal(): DekApiInternal;
|
|
52
73
|
trace(message: string, ...data: any[]): void;
|
|
53
74
|
warn(message: string, ...data: any[]): void;
|
|
54
75
|
error(message: string, ...data: any[]): void;
|
|
@@ -64,6 +85,30 @@ export declare class Api implements DekApi {
|
|
|
64
85
|
get navigateParams(): Record<string, string | undefined>;
|
|
65
86
|
navigateBack(): void;
|
|
66
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>;
|
|
110
|
+
navigateBack(): void;
|
|
111
|
+
open(boardKey: string): void;
|
|
67
112
|
private createPluginWrapper;
|
|
68
113
|
private get globals();
|
|
69
114
|
get plugins(): Record<string, DekApiPlugin>;
|
|
@@ -73,5 +118,5 @@ export declare class Api implements DekApi {
|
|
|
73
118
|
private getScreen;
|
|
74
119
|
private getBoard;
|
|
75
120
|
}
|
|
76
|
-
declare const api:
|
|
121
|
+
declare const api: ApiInternal;
|
|
77
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<T extends DekPlugin = DekPlugin> = Record<string, any> & {
|
|
4
|
+
plugin: T;
|
|
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