@doracli/dora-plugin-define 0.0.5

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2029 zhangzhiguo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # `cli`
2
+
3
+ > @doracli/cli
4
+ > 构建功能集合
5
+
6
+ ## Usage
@@ -0,0 +1,134 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * 插件定义
5
+ * @param plugin 插件定义对象
6
+ * @returns 插件定义对象
7
+ */
8
+ var PluginDefine = function PluginDefine(plugin) {
9
+ return plugin;
10
+ };
11
+
12
+ function _arrayLikeToArray(r, a) {
13
+ (null == a || a > r.length) && (a = r.length);
14
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
15
+ return n;
16
+ }
17
+ function _arrayWithoutHoles(r) {
18
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
19
+ }
20
+ function _classCallCheck(a, n) {
21
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
22
+ }
23
+ function _defineProperties(e, r) {
24
+ for (var t = 0; t < r.length; t++) {
25
+ var o = r[t];
26
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
27
+ }
28
+ }
29
+ function _createClass(e, r, t) {
30
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
31
+ writable: false
32
+ }), e;
33
+ }
34
+ function _defineProperty(e, r, t) {
35
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
36
+ value: t,
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true
40
+ }) : e[r] = t, e;
41
+ }
42
+ function _iterableToArray(r) {
43
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
44
+ }
45
+ function _nonIterableSpread() {
46
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
47
+ }
48
+ function ownKeys(e, r) {
49
+ var t = Object.keys(e);
50
+ if (Object.getOwnPropertySymbols) {
51
+ var o = Object.getOwnPropertySymbols(e);
52
+ r && (o = o.filter(function (r) {
53
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
54
+ })), t.push.apply(t, o);
55
+ }
56
+ return t;
57
+ }
58
+ function _objectSpread2(e) {
59
+ for (var r = 1; r < arguments.length; r++) {
60
+ var t = null != arguments[r] ? arguments[r] : {};
61
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
62
+ _defineProperty(e, r, t[r]);
63
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
64
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
65
+ });
66
+ }
67
+ return e;
68
+ }
69
+ function _toConsumableArray(r) {
70
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
71
+ }
72
+ function _toPrimitive(t, r) {
73
+ if ("object" != typeof t || !t) return t;
74
+ var e = t[Symbol.toPrimitive];
75
+ if (void 0 !== e) {
76
+ var i = e.call(t, r);
77
+ if ("object" != typeof i) return i;
78
+ throw new TypeError("@@toPrimitive must return a primitive value.");
79
+ }
80
+ return (String )(t);
81
+ }
82
+ function _toPropertyKey(t) {
83
+ var i = _toPrimitive(t, "string");
84
+ return "symbol" == typeof i ? i : i + "";
85
+ }
86
+ function _unsupportedIterableToArray(r, a) {
87
+ if (r) {
88
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
89
+ var t = {}.toString.call(r).slice(8, -1);
90
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
91
+ }
92
+ }
93
+
94
+ var PluginDefineJsonGenerator = /*#__PURE__*/function () {
95
+ function PluginDefineJsonGenerator(defaultJson) {
96
+ _classCallCheck(this, PluginDefineJsonGenerator);
97
+ _defineProperty(this, "json", {
98
+ defineVersion: 'V1',
99
+ depends: [],
100
+ scripts: '',
101
+ styles: ''
102
+ });
103
+ this.json = _objectSpread2(_objectSpread2({}, this.json), defaultJson);
104
+ }
105
+ return _createClass(PluginDefineJsonGenerator, [{
106
+ key: "update",
107
+ value: function update(json) {
108
+ this.json = _objectSpread2(_objectSpread2({}, this.json), json);
109
+ }
110
+ }, {
111
+ key: "updateDepends",
112
+ value: function updateDepends(depends) {
113
+ var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
114
+ if (force) {
115
+ this.json.depends = depends;
116
+ } else {
117
+ this.json.depends = [].concat(_toConsumableArray(this.json.depends || []), _toConsumableArray(depends));
118
+ }
119
+ }
120
+ }, {
121
+ key: "generate",
122
+ value: function generate() {
123
+ return this.json;
124
+ }
125
+ }, {
126
+ key: "generateStr",
127
+ value: function generateStr() {
128
+ return JSON.stringify(this.json, null, 2);
129
+ }
130
+ }]);
131
+ }();
132
+
133
+ exports.PluginDefine = PluginDefine;
134
+ exports.PluginDefineJsonGenerator = PluginDefineJsonGenerator;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * 插件定义
3
+ * @param plugin 插件定义对象
4
+ * @returns 插件定义对象
5
+ */
6
+ var PluginDefine = function PluginDefine(plugin) {
7
+ return plugin;
8
+ };
9
+
10
+ function _arrayLikeToArray(r, a) {
11
+ (null == a || a > r.length) && (a = r.length);
12
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
13
+ return n;
14
+ }
15
+ function _arrayWithoutHoles(r) {
16
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
17
+ }
18
+ function _classCallCheck(a, n) {
19
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
20
+ }
21
+ function _defineProperties(e, r) {
22
+ for (var t = 0; t < r.length; t++) {
23
+ var o = r[t];
24
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
25
+ }
26
+ }
27
+ function _createClass(e, r, t) {
28
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
29
+ writable: false
30
+ }), e;
31
+ }
32
+ function _defineProperty(e, r, t) {
33
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
34
+ value: t,
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true
38
+ }) : e[r] = t, e;
39
+ }
40
+ function _iterableToArray(r) {
41
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
42
+ }
43
+ function _nonIterableSpread() {
44
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
45
+ }
46
+ function ownKeys(e, r) {
47
+ var t = Object.keys(e);
48
+ if (Object.getOwnPropertySymbols) {
49
+ var o = Object.getOwnPropertySymbols(e);
50
+ r && (o = o.filter(function (r) {
51
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
52
+ })), t.push.apply(t, o);
53
+ }
54
+ return t;
55
+ }
56
+ function _objectSpread2(e) {
57
+ for (var r = 1; r < arguments.length; r++) {
58
+ var t = null != arguments[r] ? arguments[r] : {};
59
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
60
+ _defineProperty(e, r, t[r]);
61
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
62
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
63
+ });
64
+ }
65
+ return e;
66
+ }
67
+ function _toConsumableArray(r) {
68
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
69
+ }
70
+ function _toPrimitive(t, r) {
71
+ if ("object" != typeof t || !t) return t;
72
+ var e = t[Symbol.toPrimitive];
73
+ if (void 0 !== e) {
74
+ var i = e.call(t, r);
75
+ if ("object" != typeof i) return i;
76
+ throw new TypeError("@@toPrimitive must return a primitive value.");
77
+ }
78
+ return (String )(t);
79
+ }
80
+ function _toPropertyKey(t) {
81
+ var i = _toPrimitive(t, "string");
82
+ return "symbol" == typeof i ? i : i + "";
83
+ }
84
+ function _unsupportedIterableToArray(r, a) {
85
+ if (r) {
86
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
87
+ var t = {}.toString.call(r).slice(8, -1);
88
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
89
+ }
90
+ }
91
+
92
+ var PluginDefineJsonGenerator = /*#__PURE__*/function () {
93
+ function PluginDefineJsonGenerator(defaultJson) {
94
+ _classCallCheck(this, PluginDefineJsonGenerator);
95
+ _defineProperty(this, "json", {
96
+ defineVersion: 'V1',
97
+ depends: [],
98
+ scripts: '',
99
+ styles: ''
100
+ });
101
+ this.json = _objectSpread2(_objectSpread2({}, this.json), defaultJson);
102
+ }
103
+ return _createClass(PluginDefineJsonGenerator, [{
104
+ key: "update",
105
+ value: function update(json) {
106
+ this.json = _objectSpread2(_objectSpread2({}, this.json), json);
107
+ }
108
+ }, {
109
+ key: "updateDepends",
110
+ value: function updateDepends(depends) {
111
+ var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
112
+ if (force) {
113
+ this.json.depends = depends;
114
+ } else {
115
+ this.json.depends = [].concat(_toConsumableArray(this.json.depends || []), _toConsumableArray(depends));
116
+ }
117
+ }
118
+ }, {
119
+ key: "generate",
120
+ value: function generate() {
121
+ return this.json;
122
+ }
123
+ }, {
124
+ key: "generateStr",
125
+ value: function generateStr() {
126
+ return JSON.stringify(this.json, null, 2);
127
+ }
128
+ }]);
129
+ }();
130
+
131
+ export { PluginDefine, PluginDefineJsonGenerator };
@@ -0,0 +1,74 @@
1
+ import { FC } from 'react';
2
+
3
+ type TPluginDefine = {
4
+ /** 视图器 */
5
+ Viewer: FC<{
6
+ comptId: string;
7
+ }>;
8
+ /** 设计器,配置 */
9
+ Designer?: FC<{
10
+ comptId: string;
11
+ }>;
12
+ /** 代码生成器 */
13
+ Coder?: FC<{
14
+ comptId: string;
15
+ }>;
16
+ };
17
+
18
+ /**
19
+ * 插件定义
20
+ * @param plugin 插件定义对象
21
+ * @returns 插件定义对象
22
+ */
23
+ declare const PluginDefine: (plugin: TPluginDefine) => TPluginDefine;
24
+
25
+ type TDependDefineItem$1 = {
26
+ name: string;
27
+ useName: string;
28
+ version?: string;
29
+ url?: string;
30
+ type?: 'script' | 'style';
31
+ };
32
+
33
+ type TPluginDefineJsonV1 = {
34
+ /** 插件定义版本对应插件解析器版本 */
35
+ defineVersion: 'V1';
36
+ /** 插件代码 */
37
+ pluginCode?: string;
38
+ /** 插件依赖 */
39
+ depends?: TDependDefineItem$1[];
40
+ /** 插件脚本 */
41
+ scripts?: {
42
+ viewer?: string;
43
+ designer?: string;
44
+ coder?: string;
45
+ } | string;
46
+ /** 插件样式 */
47
+ styles?: {
48
+ viewer?: string;
49
+ designer?: string;
50
+ coder?: string;
51
+ } | string;
52
+ };
53
+
54
+ type TPluginDefineJson = TPluginDefineJsonV1;
55
+
56
+ type TDependDefineItem = {
57
+ name: string;
58
+ useName: string;
59
+ version?: string;
60
+ url?: string;
61
+ type?: 'script' | 'style';
62
+ };
63
+
64
+ declare class PluginDefineJsonGenerator {
65
+ private json;
66
+ constructor(defaultJson: Partial<TPluginDefineJson>);
67
+ update(json: Partial<TPluginDefineJson>): void;
68
+ updateDepends(depends: TDependDefineItem[], force?: boolean): void;
69
+ generate(): Partial<TPluginDefineJsonV1>;
70
+ generateStr(): string;
71
+ }
72
+
73
+ export { PluginDefine, PluginDefineJsonGenerator };
74
+ export type { TDependDefineItem$1 as TDependDefineItem, TPluginDefine, TPluginDefineJson, TPluginDefineJsonV1 };
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@doracli/dora-plugin-define",
3
+ "version": "0.0.5",
4
+ "description": "dora-plugin-define 用于插件化开发",
5
+ "author": "cclr <18843152354@163.com>",
6
+ "homepage": "",
7
+ "license": "MIT",
8
+ "type": "module",
9
+ "exports": {
10
+ "import": "./lib/esm/index.js",
11
+ "require": "./lib/cjs/index.js"
12
+ },
13
+ "types": "lib/type/index.d.ts",
14
+ "bin": {
15
+ "dorap": "bin/enter.mjs"
16
+ },
17
+ "directories": {
18
+ "lib": "lib"
19
+ },
20
+ "files": [
21
+ "lib",
22
+ "README.md"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org/"
27
+ },
28
+ "scripts": {
29
+ "build": "drr build",
30
+ "g:build": "drr build"
31
+ },
32
+ "dependencies": {
33
+ "@cclr/lang": "^0.1.49"
34
+ },
35
+ "devDependencies": {
36
+ "@types/react": "^18.3.27",
37
+ "@types/react-dom": "^18.3.7"
38
+ },
39
+ "gitHead": "ac4c6829b2cec621ecf66b6324843773e8b5141f"
40
+ }