@sdata-plugin-adapter/types 0.0.0-alpha.1 → 0.0.0-alpha.2

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.
@@ -0,0 +1,25 @@
1
+ //#region global/module.d.ts
2
+ interface ConfigJson {
3
+ id: string;
4
+ type: string;
5
+ main: string;
6
+ version: string | number;
7
+ configuration: boolean;
8
+ scriptLoadType: string;
9
+ props: {
10
+ [key: string]: any;
11
+ };
12
+ "online-development-mode"?: {
13
+ open: boolean;
14
+ host: string;
15
+ port: string | number;
16
+ entry: string;
17
+ };
18
+ templateType?: string;
19
+ "requirement-number": string;
20
+ "requirement-name": string;
21
+ }
22
+ declare module "configJson" {
23
+ const configJson: ConfigJson;
24
+ export default configJson;
25
+ }
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,95 @@
1
+ import * as ReactType from "react";
2
+ import * as ReactDOMClientType from "react-dom/client";
3
+
4
+ //#region index.d.ts
5
+ interface CustomConfig {
6
+ componentId: string;
7
+ id: string;
8
+ appId?: string;
9
+ [key: string]: any;
10
+ }
11
+ type ConfigType = "default" | "data" | "style" | "interaction";
12
+ type ActionsFunction = {
13
+ [key: string]: (...args: any[]) => any;
14
+ };
15
+ type ActionsPayload = {
16
+ key: string;
17
+ name: string;
18
+ params: {
19
+ key: string;
20
+ name: string;
21
+ dataType: string;
22
+ }[];
23
+ hasReturn: boolean;
24
+ };
25
+ type EventsPayload = {
26
+ key: string;
27
+ name: string;
28
+ payload: {
29
+ name: string;
30
+ key: string;
31
+ dataType: string;
32
+ }[];
33
+ }[];
34
+ interface EventActionDefinitions {
35
+ actions: ActionsPayload;
36
+ events: EventsPayload;
37
+ }
38
+ interface UseRegisterComponentParams {
39
+ actions?: ActionsFunction;
40
+ eventActionDefinitions?: EventActionDefinitions;
41
+ }
42
+ interface AppTriggerEventPayload {
43
+ componentId?: string;
44
+ event: string;
45
+ payload?: Record<string, any>;
46
+ [key: string]: any;
47
+ }
48
+ interface AdapterProps {
49
+ isConfig?: boolean;
50
+ changeCustomConfig?: (customConfigStr: string) => void;
51
+ onConfigChange: (config: any) => void;
52
+ componentId?: string;
53
+ customConfig: CustomConfig;
54
+ configType?: ConfigType;
55
+ type?: string;
56
+ appTriggerEvent?: (payload: AppTriggerEventPayload) => void;
57
+ triggerEvent?: (eventName: string, payload?: Record<string, any>) => void;
58
+ useRegisterComponent?: (params: UseRegisterComponentParams) => void;
59
+ [key: string]: any;
60
+ }
61
+ type PluginProps = AdapterProps & Record<string, any>;
62
+ interface startOptions {
63
+ App: React.ComponentType;
64
+ beforeBootstrap?: (callback: () => void) => void;
65
+ }
66
+ interface createPluginOptions extends startOptions {
67
+ setAttributes: (dom: Element, props: PluginProps) => Promise<any>;
68
+ adapter: (props: AdapterProps) => AdapterProps;
69
+ }
70
+ interface EventBus {
71
+ emit: (props: Record<string, any>) => void;
72
+ on: (callback: (payload?: any) => void) => void;
73
+ remove: () => void;
74
+ }
75
+ type PluginRun = (dom: Element, props: PluginProps, context?: Record<string, any>, eventBus?: EventBus, setCompRoot?: (root: ReactDOMClientType.Root) => void) => void;
76
+ declare global {
77
+ interface Window {
78
+ React: typeof ReactType;
79
+ ReactDOM: typeof ReactDOMClientType;
80
+ online_development_islocal: boolean;
81
+ CUSTOM_PLUGIN: Map<string, PluginRun>;
82
+ eventCenter: {
83
+ triggerEventNew: (payload: Record<string, any>) => void;
84
+ [key: string]: any;
85
+ };
86
+ componentCenter: {
87
+ register: (componentId: string, type: string, payload: Record<string, any>, eventsDefine: EventActionDefinitions) => void;
88
+ removeInstance: (componentId: string) => void;
89
+ [key: string]: any;
90
+ };
91
+ [key: string]: any;
92
+ }
93
+ }
94
+ //#endregion
95
+ export { type ActionsFunction, type ActionsPayload, type AdapterProps, type AppTriggerEventPayload, type CustomConfig, type EventActionDefinitions, type EventBus, type EventsPayload, type PluginProps, type PluginRun, type UseRegisterComponentParams, type createPluginOptions, type startOptions };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { };
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@sdata-plugin-adapter/types",
3
- "version": "0.0.0-alpha.1",
3
+ "version": "0.0.0-alpha.2",
4
4
  "description": "adapter types of smdata plugin",
5
5
  "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
6
+ "types": "./dist/index.d.mts",
9
7
  "exports": {
10
8
  ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
9
+ "types": "./dist/index.d.mts"
10
+ },
11
+ "./global": {
12
+ "types": "./dist/global/index.d.mts"
14
13
  }
15
14
  },
16
15
  "files": [
@@ -23,6 +22,6 @@
23
22
  },
24
23
  "scripts": {
25
24
  "test": "echo \"Error: no test specified\" && exit 1",
26
- "build": "tsup"
25
+ "build": "tsdown"
27
26
  }
28
27
  }
package/dist/index.cjs DELETED
@@ -1,17 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
-
15
- // index.ts
16
- var index_exports = {};
17
- module.exports = __toCommonJS(index_exports);
package/dist/index.d.cts DELETED
@@ -1,73 +0,0 @@
1
- import * as ReactDOMClientType from 'react-dom/client';
2
-
3
- interface CustomConfig {
4
- componentId: string;
5
- id: string;
6
- appId?: string;
7
- [key: string]: any;
8
- }
9
- type ConfigType = "default" | "data" | "style" | "interaction";
10
- type ActionsFunction = {
11
- [key: string]: (...args: any[]) => any;
12
- };
13
- type ActionsPayload = {
14
- key: string;
15
- name: string;
16
- params: {
17
- key: string;
18
- name: string;
19
- dataType: string;
20
- }[];
21
- hasReturn: boolean;
22
- };
23
- type EventsPayload = {
24
- key: string;
25
- name: string;
26
- payload: {
27
- name: string;
28
- key: string;
29
- dataType: string;
30
- }[];
31
- }[];
32
- interface EventActionDefinitions {
33
- actions: ActionsPayload;
34
- events: EventsPayload;
35
- }
36
- interface UseRegisterComponentParams {
37
- actions?: ActionsFunction;
38
- eventActionDefinitions?: EventActionDefinitions;
39
- }
40
- interface AppTriggerEventPayload {
41
- componentId?: string;
42
- event: string;
43
- payload?: Record<string, any>;
44
- [key: string]: any;
45
- }
46
- interface AdapterProps {
47
- isConfig?: boolean;
48
- changeCustomConfig?: (customConfigStr: string) => void;
49
- onConfigChange: (config: any) => void;
50
- componentId?: string;
51
- customConfig: CustomConfig;
52
- configType?: ConfigType;
53
- type?: string;
54
- appTriggerEvent?: (payload: AppTriggerEventPayload) => void;
55
- triggerEvent?: (eventName: string, payload?: Record<string, any>) => void;
56
- useRegisterComponent?: (params: UseRegisterComponentParams) => void;
57
- [key: string]: any;
58
- }
59
- type PluginProps = AdapterProps & Record<string, any>;
60
- interface createPluginOptions {
61
- App: React.ComponentType;
62
- setAttributes: (dom: Element, props: PluginProps) => Promise<any>;
63
- adapter: (props: AdapterProps) => AdapterProps;
64
- beforeBootstrap?: (callback: () => void) => void;
65
- }
66
- interface EventBus {
67
- emit: (props: Record<string, any>) => void;
68
- on: (callback: (payload?: any) => void) => void;
69
- remove: () => void;
70
- }
71
- type PluginRun = (dom: Element, props: PluginProps, context?: Record<string, any>, eventBus?: EventBus, setCompRoot?: (root: ReactDOMClientType.Root) => void) => void;
72
-
73
- export type { ActionsFunction, ActionsPayload, AdapterProps, AppTriggerEventPayload, CustomConfig, EventActionDefinitions, EventBus, EventsPayload, PluginProps, PluginRun, UseRegisterComponentParams, createPluginOptions };
package/dist/index.d.ts DELETED
@@ -1,73 +0,0 @@
1
- import * as ReactDOMClientType from 'react-dom/client';
2
-
3
- interface CustomConfig {
4
- componentId: string;
5
- id: string;
6
- appId?: string;
7
- [key: string]: any;
8
- }
9
- type ConfigType = "default" | "data" | "style" | "interaction";
10
- type ActionsFunction = {
11
- [key: string]: (...args: any[]) => any;
12
- };
13
- type ActionsPayload = {
14
- key: string;
15
- name: string;
16
- params: {
17
- key: string;
18
- name: string;
19
- dataType: string;
20
- }[];
21
- hasReturn: boolean;
22
- };
23
- type EventsPayload = {
24
- key: string;
25
- name: string;
26
- payload: {
27
- name: string;
28
- key: string;
29
- dataType: string;
30
- }[];
31
- }[];
32
- interface EventActionDefinitions {
33
- actions: ActionsPayload;
34
- events: EventsPayload;
35
- }
36
- interface UseRegisterComponentParams {
37
- actions?: ActionsFunction;
38
- eventActionDefinitions?: EventActionDefinitions;
39
- }
40
- interface AppTriggerEventPayload {
41
- componentId?: string;
42
- event: string;
43
- payload?: Record<string, any>;
44
- [key: string]: any;
45
- }
46
- interface AdapterProps {
47
- isConfig?: boolean;
48
- changeCustomConfig?: (customConfigStr: string) => void;
49
- onConfigChange: (config: any) => void;
50
- componentId?: string;
51
- customConfig: CustomConfig;
52
- configType?: ConfigType;
53
- type?: string;
54
- appTriggerEvent?: (payload: AppTriggerEventPayload) => void;
55
- triggerEvent?: (eventName: string, payload?: Record<string, any>) => void;
56
- useRegisterComponent?: (params: UseRegisterComponentParams) => void;
57
- [key: string]: any;
58
- }
59
- type PluginProps = AdapterProps & Record<string, any>;
60
- interface createPluginOptions {
61
- App: React.ComponentType;
62
- setAttributes: (dom: Element, props: PluginProps) => Promise<any>;
63
- adapter: (props: AdapterProps) => AdapterProps;
64
- beforeBootstrap?: (callback: () => void) => void;
65
- }
66
- interface EventBus {
67
- emit: (props: Record<string, any>) => void;
68
- on: (callback: (payload?: any) => void) => void;
69
- remove: () => void;
70
- }
71
- type PluginRun = (dom: Element, props: PluginProps, context?: Record<string, any>, eventBus?: EventBus, setCompRoot?: (root: ReactDOMClientType.Root) => void) => void;
72
-
73
- export type { ActionsFunction, ActionsPayload, AdapterProps, AppTriggerEventPayload, CustomConfig, EventActionDefinitions, EventBus, EventsPayload, PluginProps, PluginRun, UseRegisterComponentParams, createPluginOptions };
package/dist/index.js DELETED
File without changes