@nestia/editor 11.1.0 → 11.2.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/assets/index-By6TnR5x.js +4750 -0
- package/dist/index.html +1 -1
- package/lib/NestiaEditorApplication.js +46 -131
- package/lib/NestiaEditorApplication.js.map +1 -1
- package/lib/NestiaEditorIframe.js +91 -208
- package/lib/NestiaEditorIframe.js.map +1 -1
- package/lib/NestiaEditorModule.js +60 -174
- package/lib/NestiaEditorModule.js.map +1 -1
- package/lib/NestiaEditorUploader.js +47 -104
- package/lib/NestiaEditorUploader.js.map +1 -1
- package/lib/internal/NestiaEditorComposer.js +48 -146
- package/lib/internal/NestiaEditorComposer.js.map +1 -1
- package/lib/internal/NestiaEditorFileUploader.js +25 -78
- package/lib/internal/NestiaEditorFileUploader.js.map +1 -1
- package/lib/main.js +4 -4
- package/lib/main.js.map +1 -1
- package/package.json +5 -5
- package/dist/assets/index-OWA5eAP4.js +0 -4807
|
@@ -41,189 +41,75 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
41
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
-
function step(op) {
|
|
49
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
-
switch (op[0]) {
|
|
54
|
-
case 0: case 1: t = op; break;
|
|
55
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
-
default:
|
|
59
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
-
if (t[2]) _.ops.pop();
|
|
64
|
-
_.trys.pop(); continue;
|
|
65
|
-
}
|
|
66
|
-
op = body.call(thisArg, _);
|
|
67
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var __values = (this && this.__values) || function(o) {
|
|
72
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
73
|
-
if (m) return m.call(o);
|
|
74
|
-
if (o && typeof o.length === "number") return {
|
|
75
|
-
next: function () {
|
|
76
|
-
if (o && i >= o.length) o = void 0;
|
|
77
|
-
return { value: o && o[i++], done: !o };
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
81
|
-
};
|
|
82
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
83
45
|
exports.NestiaEditorModule = void 0;
|
|
84
|
-
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
85
47
|
var NestiaEditorModule;
|
|
86
48
|
(function (NestiaEditorModule) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
_d = props.swagger;
|
|
123
|
-
_l.label = 4;
|
|
124
|
-
case 4:
|
|
125
|
-
_a = _a.concat([
|
|
126
|
-
(_h.content = _c.apply(_b, [_d, null,
|
|
127
|
-
2]),
|
|
128
|
-
_h)
|
|
129
|
-
]);
|
|
130
|
-
return [4 /*yield*/, getJavaScript()];
|
|
131
|
-
case 5:
|
|
132
|
-
staticFiles = _a.concat([
|
|
133
|
-
_l.sent()
|
|
134
|
-
]);
|
|
135
|
-
_loop_1 = function (f) {
|
|
136
|
-
adaptor.get(prefix + f.path, function (_, res) {
|
|
137
|
-
res.type(f.type);
|
|
138
|
-
return res.send(f.content);
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
try {
|
|
142
|
-
for (staticFiles_1 = __values(staticFiles), staticFiles_1_1 = staticFiles_1.next(); !staticFiles_1_1.done; staticFiles_1_1 = staticFiles_1.next()) {
|
|
143
|
-
f = staticFiles_1_1.value;
|
|
144
|
-
_loop_1(f);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
148
|
-
finally {
|
|
149
|
-
try {
|
|
150
|
-
if (staticFiles_1_1 && !staticFiles_1_1.done && (_j = staticFiles_1.return)) _j.call(staticFiles_1);
|
|
151
|
-
}
|
|
152
|
-
finally { if (e_1) throw e_1.error; }
|
|
153
|
-
}
|
|
154
|
-
try {
|
|
155
|
-
for (_e = __values(["", "/"]), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
156
|
-
p = _f.value;
|
|
157
|
-
adaptor.get(prefix + p, function (_, res) {
|
|
158
|
-
return res.redirect(prefix + "/index.html");
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
163
|
-
finally {
|
|
164
|
-
try {
|
|
165
|
-
if (_f && !_f.done && (_k = _e.return)) _k.call(_e);
|
|
166
|
-
}
|
|
167
|
-
finally { if (e_2) throw e_2.error; }
|
|
168
|
-
}
|
|
169
|
-
return [2 /*return*/];
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}); };
|
|
173
|
-
var getGlobalPrefix = function (app) {
|
|
49
|
+
NestiaEditorModule.setup = (props) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const prefix = "/" +
|
|
51
|
+
[getGlobalPrefix(props.application), props.path]
|
|
52
|
+
.join("/")
|
|
53
|
+
.split("/")
|
|
54
|
+
.filter((str) => str.length !== 0)
|
|
55
|
+
.join("/");
|
|
56
|
+
const adaptor = props.application.getHttpAdapter();
|
|
57
|
+
const staticFiles = [
|
|
58
|
+
{
|
|
59
|
+
path: "/index.html",
|
|
60
|
+
type: "text/html",
|
|
61
|
+
content: yield getIndex(props),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
path: "/swagger.json",
|
|
65
|
+
type: "application/json",
|
|
66
|
+
content: JSON.stringify(typeof props.swagger === "string"
|
|
67
|
+
? yield getSwagger(props.swagger)
|
|
68
|
+
: props.swagger, null, 2),
|
|
69
|
+
},
|
|
70
|
+
yield getJavaScript(),
|
|
71
|
+
];
|
|
72
|
+
for (const f of staticFiles) {
|
|
73
|
+
adaptor.get(prefix + f.path, (_, res) => {
|
|
74
|
+
res.type(f.type);
|
|
75
|
+
return res.send(f.content);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
for (const p of ["", "/"])
|
|
79
|
+
adaptor.get(prefix + p, (_, res) => {
|
|
80
|
+
return res.redirect(prefix + "/index.html");
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
const getGlobalPrefix = (app) => {
|
|
174
84
|
var _a;
|
|
175
85
|
return typeof ((_a = app.config) === null || _a === void 0 ? void 0 : _a.globalPrefix) === "string"
|
|
176
86
|
? app.config.globalPrefix
|
|
177
87
|
: "";
|
|
178
88
|
};
|
|
179
89
|
})(NestiaEditorModule || (exports.NestiaEditorModule = NestiaEditorModule = {}));
|
|
180
|
-
|
|
181
|
-
var content;
|
|
182
|
-
var _a;
|
|
183
|
-
return __generator(this, function (_b) {
|
|
184
|
-
switch (_b.label) {
|
|
185
|
-
case 0: return [4 /*yield*/, fs.promises.readFile("".concat(__dirname, "/../dist/index.html"), "utf8")];
|
|
186
|
-
case 1:
|
|
187
|
-
content = _b.sent();
|
|
188
|
-
return [2 /*return*/, content
|
|
189
|
-
.replace("\"@ORGANIZATION/PROJECT\"", JSON.stringify((_a = props.package) !== null && _a !== void 0 ? _a : "@ORGANIZATION/PROJECT"))
|
|
190
|
-
.replace("window.simulate = false", "window.simulate = ".concat(!!props.simulate))
|
|
191
|
-
.replace("window.e2e = false", "window.e2e = ".concat(!!props.e2e))];
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
}); };
|
|
195
|
-
var getJavaScript = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
196
|
-
var directory, path;
|
|
90
|
+
const getIndex = (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
197
91
|
var _a;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
case 1:
|
|
222
|
-
response = _a.sent();
|
|
223
|
-
if (response.status !== 200)
|
|
224
|
-
throw new Error("Failed to fetch Swagger document from ".concat(url));
|
|
225
|
-
return [2 /*return*/, response.json()];
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
}); };
|
|
92
|
+
const content = yield fs.promises.readFile(`${__dirname}/../dist/index.html`, "utf8");
|
|
93
|
+
return content
|
|
94
|
+
.replace(`"@ORGANIZATION/PROJECT"`, JSON.stringify((_a = props.package) !== null && _a !== void 0 ? _a : "@ORGANIZATION/PROJECT"))
|
|
95
|
+
.replace("window.simulate = false", `window.simulate = ${!!props.simulate}`)
|
|
96
|
+
.replace("window.e2e = false", `window.e2e = ${!!props.e2e}`);
|
|
97
|
+
});
|
|
98
|
+
const getJavaScript = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
+
const directory = yield fs.promises.readdir(`${__dirname}/../dist/assets`);
|
|
100
|
+
const path = directory[0];
|
|
101
|
+
if (path === undefined)
|
|
102
|
+
throw new Error("Unreachable code, no JS file exists.");
|
|
103
|
+
return {
|
|
104
|
+
path: `/assets/${path}`,
|
|
105
|
+
type: "application/javascript",
|
|
106
|
+
content: yield fs.promises.readFile(`${__dirname}/../dist/assets/${path}`, "utf8"),
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
const getSwagger = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
const response = yield fetch(url);
|
|
111
|
+
if (response.status !== 200)
|
|
112
|
+
throw new Error(`Failed to fetch Swagger document from ${url}`);
|
|
113
|
+
return response.json();
|
|
114
|
+
});
|
|
229
115
|
//# sourceMappingURL=NestiaEditorModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaEditorModule.js","sourceRoot":"","sources":["../src/NestiaEditorModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NestiaEditorModule.js","sourceRoot":"","sources":["../src/NestiaEditorModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,uCAAyB;AAEzB,IAAiB,kBAAkB,CAyDlC;AAzDD,WAAiB,kBAAkB;IACpB,wBAAK,GAAG,CAAO,KAY3B,EAAiB,EAAE;QAClB,MAAM,MAAM,GACV,GAAG;YACH,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC;iBAC7C,IAAI,CAAC,GAAG,CAAC;iBACT,KAAK,CAAC,GAAG,CAAC;iBACV,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;iBACjC,IAAI,CAAC,GAAG,CAAC,CAAC;QACf,MAAM,OAAO,GAAqB,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;QACrE,MAAM,WAAW,GAAkB;YACjC;gBACE,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,MAAM,QAAQ,CAAC,KAAK,CAAC;aAC/B;YACD;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,kBAAkB;gBACxB,OAAO,EAAE,IAAI,CAAC,SAAS,CACrB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;oBAC/B,CAAC,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC;oBACjC,CAAC,CAAC,KAAK,CAAC,OAAO,EACjB,IAAI,EACJ,CAAC,CACF;aACF;YACD,MAAM,aAAa,EAAE;SACtB,CAAC;QACF,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;YAC5B,OAAO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CAAC,GAAG,EAAE,CAAC,CAAC;AAClE,CAAC,CAAA,CAAC;AAEF,MAAM,aAAa,GAAG,GAA+B,EAAE;IACrD,MAAM,SAAS,GAAa,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CACnD,GAAG,SAAS,iBAAiB,CAC9B,CAAC;IACF,MAAM,IAAI,GAAuB,SAAS,CAAC,CAAC,CAAC,CAAC;IAC9C,IAAI,IAAI,KAAK,SAAS;QACpB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,OAAO;QACL,IAAI,EAAE,WAAW,IAAI,EAAE;QACvB,IAAI,EAAE,wBAAwB;QAC9B,OAAO,EAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CACjC,GAAG,SAAS,mBAAmB,IAAI,EAAE,EACrC,MAAM,CACP;KACF,CAAC;AACJ,CAAC,CAAA,CAAC;AAEF,MAAM,UAAU,GAAG,CACjB,GAAW,EAGX,EAAE;IACF,MAAM,QAAQ,GAAa,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG;QACzB,MAAM,IAAI,KAAK,CAAC,yCAAyC,GAAG,EAAE,CAAC,CAAC;IAClE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAA,CAAC"}
|
|
@@ -8,128 +8,71 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
55
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
56
13
|
};
|
|
57
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
15
|
exports.NestiaEditorUploader = NestiaEditorUploader;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
16
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
17
|
+
const material_1 = require("@mui/material");
|
|
18
|
+
const sdk_1 = __importDefault(require("@stackblitz/sdk"));
|
|
19
|
+
const react_1 = __importDefault(require("react"));
|
|
20
|
+
const NestiaEditorComposer_1 = require("./internal/NestiaEditorComposer");
|
|
21
|
+
const NestiaEditorFileUploader_1 = require("./internal/NestiaEditorFileUploader");
|
|
65
22
|
function NestiaEditorUploader(props) {
|
|
66
|
-
var _this = this;
|
|
67
23
|
// PARAMETERS
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
24
|
+
const [mode, setMode] = react_1.default.useState("sdk");
|
|
25
|
+
const [keyword, setKeyword] = react_1.default.useState(true);
|
|
26
|
+
const [simulate, setSimulate] = react_1.default.useState(true);
|
|
27
|
+
const [e2e, setE2e] = react_1.default.useState(true);
|
|
28
|
+
const [name, setName] = react_1.default.useState("@ORGINIZATION/PROJECT");
|
|
73
29
|
// RESULT
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
30
|
+
const [document, setDocument] = react_1.default.useState(null);
|
|
31
|
+
const [progress, setProgress] = react_1.default.useState(false);
|
|
32
|
+
const handleError = (error) => {
|
|
77
33
|
if (props.onError)
|
|
78
34
|
props.onError(error);
|
|
79
35
|
else
|
|
80
36
|
alert(error);
|
|
81
37
|
};
|
|
82
|
-
|
|
38
|
+
const handleSwagger = (document, error) => {
|
|
83
39
|
setDocument(document);
|
|
84
40
|
if (error !== null)
|
|
85
41
|
handleError(error);
|
|
86
42
|
};
|
|
87
|
-
|
|
88
|
-
var result, exp_1;
|
|
43
|
+
const generate = () => __awaiter(this, void 0, void 0, function* () {
|
|
89
44
|
var _a, _b;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
newWindow: true,
|
|
115
|
-
openFile: result.data.openFile,
|
|
116
|
-
startScript: result.data.startScript,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
handleError(JSON.stringify(result.errors, null, 2));
|
|
121
|
-
}
|
|
122
|
-
return [3 /*break*/, 4];
|
|
123
|
-
case 3:
|
|
124
|
-
exp_1 = _c.sent();
|
|
125
|
-
handleError(exp_1 instanceof Error ? exp_1.message : "unknown error");
|
|
126
|
-
return [3 /*break*/, 4];
|
|
127
|
-
case 4:
|
|
128
|
-
setProgress(false);
|
|
129
|
-
return [2 /*return*/];
|
|
45
|
+
if (document === null)
|
|
46
|
+
return;
|
|
47
|
+
setProgress(true);
|
|
48
|
+
try {
|
|
49
|
+
const result = yield NestiaEditorComposer_1.NestiaEditorComposer[mode]({
|
|
50
|
+
document,
|
|
51
|
+
keyword,
|
|
52
|
+
e2e,
|
|
53
|
+
simulate,
|
|
54
|
+
package: name,
|
|
55
|
+
});
|
|
56
|
+
if (result.success === true) {
|
|
57
|
+
sdk_1.default.openProject({
|
|
58
|
+
title: (_b = (_a = document.info) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : "Nestia Editor",
|
|
59
|
+
template: "node",
|
|
60
|
+
files: result.data.files,
|
|
61
|
+
}, {
|
|
62
|
+
newWindow: true,
|
|
63
|
+
openFile: result.data.openFile,
|
|
64
|
+
startScript: result.data.startScript,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
handleError(JSON.stringify(result.errors, null, 2));
|
|
130
69
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
70
|
+
}
|
|
71
|
+
catch (exp) {
|
|
72
|
+
handleError(exp instanceof Error ? exp.message : "unknown error");
|
|
73
|
+
}
|
|
74
|
+
setProgress(false);
|
|
75
|
+
});
|
|
76
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(NestiaEditorFileUploader_1.NestiaEditorFileUploader, { onChange: handleSwagger }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsxs)(material_1.FormControl, { fullWidth: true, style: { paddingLeft: 15 }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { onChange: (e) => setName(e.target.value), defaultValue: name, label: "Package Name", variant: "outlined" }), (0, jsx_runtime_1.jsx)(material_1.FormLabel, { style: { paddingTop: 20 }, children: " Mode " }), (0, jsx_runtime_1.jsxs)(material_1.RadioGroup, { defaultValue: mode, onChange: (_e, value) => setMode(value), style: { paddingLeft: 15 }, children: [(0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { value: "sdk", control: (0, jsx_runtime_1.jsx)(material_1.Radio, {}), label: "Software Development Kit" }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { value: "nest", control: (0, jsx_runtime_1.jsx)(material_1.Radio, {}), label: "NestJS Project" })] }), (0, jsx_runtime_1.jsx)(material_1.FormLabel, { style: { paddingTop: 20 }, children: " Options " }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { label: "Keyword Parameter", style: { paddingTop: 5, paddingLeft: 15 }, control: (0, jsx_runtime_1.jsx)(material_1.Switch, { checked: keyword, onChange: () => setKeyword(!keyword) }) }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { label: "Mockup Simulator", style: { paddingTop: 5, paddingLeft: 15 }, control: (0, jsx_runtime_1.jsx)(material_1.Switch, { checked: simulate, onChange: () => setSimulate(!simulate) }) }), (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { label: "E2E Test Functions", style: { paddingLeft: 15 }, control: (0, jsx_runtime_1.jsx)(material_1.Switch, { checked: e2e, onChange: () => setE2e(!e2e) }) })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(material_1.Button, { component: "a", fullWidth: true, variant: "contained", color: "info", size: "large", disabled: progress === true || document === null, onClick: () => generate(), children: progress ? "Generating..." : "Generate Editor" })] }));
|
|
134
77
|
}
|
|
135
78
|
//# sourceMappingURL=NestiaEditorUploader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaEditorUploader.js","sourceRoot":"","sources":["../src/NestiaEditorUploader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NestiaEditorUploader.js","sourceRoot":"","sources":["../src/NestiaEditorUploader.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAiBA,oDAmIC;;AApJD,4CASuB;AACvB,0DAA4C;AAE5C,kDAA0B;AAE1B,0EAAuE;AACvE,kFAA+E;AAE/E,SAAgB,oBAAoB,CAAC,KAAkC;IACrE,aAAa;IACb,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,eAAK,CAAC,QAAQ,CAAiB,KAAK,CAAC,CAAC;IAC9D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,eAAK,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