miqro 6.2.4 → 6.2.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/build/esm/src/inflate/setup-http.js +327 -324
- package/build/lib.cjs +305 -302
- package/package.json +1 -1
- package/src/inflate/setup-http.ts +341 -338
package/build/lib.cjs
CHANGED
|
@@ -15099,283 +15099,226 @@ function createStaticRouterFromDirectory(service, logger, dir, inflateDir, route
|
|
|
15099
15099
|
async function createRouterFromDirectory(server2, hotreload, service, logger, dir, errors = [], routeFileMap = {}, staticFileMap = null, inflateDir, inflateSea) {
|
|
15100
15100
|
const router = new Router();
|
|
15101
15101
|
router.use(assertGlobalTampered);
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
|
|
15109
|
-
|
|
15110
|
-
|
|
15111
|
-
|
|
15112
|
-
|
|
15113
|
-
|
|
15114
|
-
|
|
15115
|
-
|
|
15116
|
-
|
|
15117
|
-
|
|
15118
|
-
|
|
15119
|
-
routes,
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
|
|
15123
|
-
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
|
|
15127
|
-
|
|
15128
|
-
|
|
15129
|
-
|
|
15130
|
-
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
15136
|
-
|
|
15137
|
-
});
|
|
15138
|
-
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15139
|
-
(0, import_node_fs11.writeFileSync)(inflatePath, inflatedCode);
|
|
15140
|
-
}
|
|
15141
|
-
router.use(assertGlobalTampered);
|
|
15142
|
-
router.use(module2.handler, r.path, r.method, r.options);
|
|
15143
|
-
}
|
|
15144
|
-
return resolve24();
|
|
15145
|
-
}
|
|
15146
|
-
case ".json": {
|
|
15147
|
-
const module2 = await importJSONModule(file.filePath, logger);
|
|
15148
|
-
const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName + ".json", module2.apiOptions);
|
|
15149
|
-
routeFileMap[file.filePath] = {
|
|
15150
|
-
routes,
|
|
15151
|
-
service,
|
|
15152
|
-
filePath: file.filePath,
|
|
15153
|
-
previewMethod: "html"
|
|
15154
|
-
};
|
|
15155
|
-
for (const r of routes) {
|
|
15156
|
-
const contentType = CONTENT_TYPE_MAP[".json"] ? CONTENT_TYPE_MAP[".json"] : DEFAULT_CONTENT_TYPE;
|
|
15157
|
-
if (inflateDir) {
|
|
15158
|
-
if (r.inflatePath) {
|
|
15159
|
-
const rPath = r.inflatePath;
|
|
15160
|
-
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
|
|
15102
|
+
for (const file of scanFiles(dir)) {
|
|
15103
|
+
await new Promise(async (resolve24) => {
|
|
15104
|
+
try {
|
|
15105
|
+
switch (file.ext) {
|
|
15106
|
+
case ".jsx":
|
|
15107
|
+
case ".cjs":
|
|
15108
|
+
case ".js":
|
|
15109
|
+
case ".ts":
|
|
15110
|
+
case ".tsx": {
|
|
15111
|
+
switch (file.subExt) {
|
|
15112
|
+
case ".test":
|
|
15113
|
+
return resolve24();
|
|
15114
|
+
case ".ignore":
|
|
15115
|
+
logger.warn("ignoring [%s]", file.filePath);
|
|
15116
|
+
return resolve24();
|
|
15117
|
+
case ".api": {
|
|
15118
|
+
const module2 = await importAPIRoute(file.filePath, logger);
|
|
15119
|
+
const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName, module2);
|
|
15120
|
+
routeFileMap[file.filePath] = {
|
|
15121
|
+
routes,
|
|
15122
|
+
service,
|
|
15123
|
+
filePath: file.filePath,
|
|
15124
|
+
previewMethod: "api"
|
|
15125
|
+
};
|
|
15126
|
+
const inflatedCode = inflateDir ? await inflateJSX(file.filePath, {
|
|
15127
|
+
embemedJSX: false,
|
|
15128
|
+
minify: false,
|
|
15129
|
+
useExport: true,
|
|
15130
|
+
platform: "node",
|
|
15131
|
+
logger
|
|
15132
|
+
}) : "";
|
|
15133
|
+
for (const r of routes) {
|
|
15134
|
+
if (inflateDir && r.defaultInflatePath && inflateSea) {
|
|
15135
|
+
const rPath = r.defaultInflatePath;
|
|
15136
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "http", rPath + ".api.cjs");
|
|
15161
15137
|
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15162
15138
|
recursive: true
|
|
15163
15139
|
});
|
|
15164
|
-
if ((0, import_node_fs11.existsSync)(inflatePath) && (0, import_node_fs11.statSync)(inflatePath).isDirectory()) {
|
|
15165
|
-
logger.trace("ignoring writing over directory [%s] for file [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath), file.filePath);
|
|
15166
|
-
continue;
|
|
15167
|
-
}
|
|
15168
|
-
const JSON_STATIC = await getJSON({ server: server2 }, null, newURL2(r.path), module2.apiOptions?.basePath, module2.default);
|
|
15169
15140
|
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15170
|
-
(0, import_node_fs11.writeFileSync)(inflatePath,
|
|
15171
|
-
if (staticFileMap && inflateSea) {
|
|
15172
|
-
staticFileMap[file.filePath] = {
|
|
15173
|
-
contentType,
|
|
15174
|
-
filePath: file.filePath,
|
|
15175
|
-
method: r.method,
|
|
15176
|
-
previewMethod: "html",
|
|
15177
|
-
path: r.path,
|
|
15178
|
-
body: Buffer.from(JSON_STATIC),
|
|
15179
|
-
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", r.inflatePath) : void 0
|
|
15180
|
-
};
|
|
15181
|
-
}
|
|
15141
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, inflatedCode);
|
|
15182
15142
|
}
|
|
15143
|
+
router.use(assertGlobalTampered);
|
|
15144
|
+
router.use(module2.handler, r.path, r.method, r.options);
|
|
15183
15145
|
}
|
|
15184
|
-
|
|
15185
|
-
router.use(async function(req, res) {
|
|
15186
|
-
const JSON2 = await getJSON(req, res, newURL2(req.path), module2.apiOptions?.basePath, module2.default);
|
|
15187
|
-
return res.asyncEnd({
|
|
15188
|
-
status: 200,
|
|
15189
|
-
headers: {
|
|
15190
|
-
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15191
|
-
},
|
|
15192
|
-
body: JSON2
|
|
15193
|
-
});
|
|
15194
|
-
}, r.path, r.method, r.options);
|
|
15146
|
+
return resolve24();
|
|
15195
15147
|
}
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
|
|
15203
|
-
|
|
15204
|
-
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
|
|
15225
|
-
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", r.inflatePath) : void 0
|
|
15233
|
-
};
|
|
15148
|
+
case ".json": {
|
|
15149
|
+
const module2 = await importJSONModule(file.filePath, logger);
|
|
15150
|
+
const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName + ".json", module2.apiOptions);
|
|
15151
|
+
routeFileMap[file.filePath] = {
|
|
15152
|
+
routes,
|
|
15153
|
+
service,
|
|
15154
|
+
filePath: file.filePath,
|
|
15155
|
+
previewMethod: "html"
|
|
15156
|
+
};
|
|
15157
|
+
for (const r of routes) {
|
|
15158
|
+
const contentType = CONTENT_TYPE_MAP[".json"] ? CONTENT_TYPE_MAP[".json"] : DEFAULT_CONTENT_TYPE;
|
|
15159
|
+
if (inflateDir) {
|
|
15160
|
+
if (r.inflatePath) {
|
|
15161
|
+
const rPath = r.inflatePath;
|
|
15162
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
|
|
15163
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15164
|
+
recursive: true
|
|
15165
|
+
});
|
|
15166
|
+
if ((0, import_node_fs11.existsSync)(inflatePath) && (0, import_node_fs11.statSync)(inflatePath).isDirectory()) {
|
|
15167
|
+
logger.trace("ignoring writing over directory [%s] for file [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath), file.filePath);
|
|
15168
|
+
continue;
|
|
15169
|
+
}
|
|
15170
|
+
const JSON_STATIC = await getJSON({ server: server2 }, null, newURL2(r.path), module2.apiOptions?.basePath, module2.default);
|
|
15171
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15172
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, JSON_STATIC);
|
|
15173
|
+
if (staticFileMap && inflateSea) {
|
|
15174
|
+
staticFileMap[file.filePath] = {
|
|
15175
|
+
contentType,
|
|
15176
|
+
filePath: file.filePath,
|
|
15177
|
+
method: r.method,
|
|
15178
|
+
previewMethod: "html",
|
|
15179
|
+
path: r.path,
|
|
15180
|
+
body: Buffer.from(JSON_STATIC),
|
|
15181
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", r.inflatePath) : void 0
|
|
15182
|
+
};
|
|
15183
|
+
}
|
|
15234
15184
|
}
|
|
15235
15185
|
}
|
|
15186
|
+
router.use(assertGlobalTampered);
|
|
15187
|
+
router.use(async function(req, res) {
|
|
15188
|
+
const JSON2 = await getJSON(req, res, newURL2(req.path), module2.apiOptions?.basePath, module2.default);
|
|
15189
|
+
return res.asyncEnd({
|
|
15190
|
+
status: 200,
|
|
15191
|
+
headers: {
|
|
15192
|
+
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15193
|
+
},
|
|
15194
|
+
body: JSON2
|
|
15195
|
+
});
|
|
15196
|
+
}, r.path, r.method, r.options);
|
|
15236
15197
|
}
|
|
15237
|
-
|
|
15238
|
-
router.use(async function(req, res) {
|
|
15239
|
-
const toRender = typeof module2.default === "function" ? module2.default(req, res) : module2.default;
|
|
15240
|
-
const HTML = await getHTML(hotreload, req, res, newURL2(req.path), module2.apiOptions?.basePath, await toRender);
|
|
15241
|
-
return res.asyncEnd({
|
|
15242
|
-
status: 200,
|
|
15243
|
-
headers: {
|
|
15244
|
-
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15245
|
-
},
|
|
15246
|
-
body: HTML
|
|
15247
|
-
});
|
|
15248
|
-
}, r.path, r.method, r.options);
|
|
15198
|
+
return resolve24();
|
|
15249
15199
|
}
|
|
15250
|
-
|
|
15251
|
-
|
|
15252
|
-
|
|
15253
|
-
case ".js":
|
|
15254
|
-
default: {
|
|
15255
|
-
if (file.ext !== ".js" && file.ext !== ".ts") {
|
|
15256
|
-
const code = await inflateJSX(file.filePath, {
|
|
15257
|
-
embemedJSX: true,
|
|
15258
|
-
minify: file.subExt === ".min" ? true : false,
|
|
15259
|
-
useExport: false,
|
|
15260
|
-
logger
|
|
15261
|
-
});
|
|
15262
|
-
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
15263
|
-
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name + ".js");
|
|
15200
|
+
case ".html": {
|
|
15201
|
+
const module2 = await importHTMLModule(file.filePath, logger);
|
|
15202
|
+
const routes = getRoutes((0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath))), file.subName + ".html", module2.apiOptions);
|
|
15264
15203
|
routeFileMap[file.filePath] = {
|
|
15265
|
-
routes
|
|
15266
|
-
method: "GET",
|
|
15267
|
-
path
|
|
15268
|
-
}],
|
|
15204
|
+
routes,
|
|
15269
15205
|
filePath: file.filePath,
|
|
15270
15206
|
service,
|
|
15271
15207
|
previewMethod: "html"
|
|
15272
15208
|
};
|
|
15273
|
-
|
|
15274
|
-
const
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15284
|
-
|
|
15285
|
-
|
|
15286
|
-
|
|
15287
|
-
|
|
15288
|
-
|
|
15289
|
-
|
|
15209
|
+
for (const r of routes) {
|
|
15210
|
+
const contentType = CONTENT_TYPE_MAP[".html"] ? CONTENT_TYPE_MAP[".html"] : DEFAULT_CONTENT_TYPE;
|
|
15211
|
+
if (inflateDir) {
|
|
15212
|
+
if (r.inflatePath) {
|
|
15213
|
+
const rPath = r.inflatePath;
|
|
15214
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", rPath);
|
|
15215
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15216
|
+
recursive: true
|
|
15217
|
+
});
|
|
15218
|
+
if ((0, import_node_fs11.existsSync)(inflatePath) && (0, import_node_fs11.statSync)(inflatePath).isDirectory()) {
|
|
15219
|
+
logger.trace("ignoring writing over directory [%s] for file [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath), file.filePath);
|
|
15220
|
+
continue;
|
|
15221
|
+
}
|
|
15222
|
+
const toRender = typeof module2.default === "function" ? module2.default({ server: server2 }, null) : module2.default;
|
|
15223
|
+
const HTML_STATIC = await getHTML(hotreload, { server: server2 }, null, newURL2(r.path), module2.apiOptions?.basePath, await toRender);
|
|
15224
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15225
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, HTML_STATIC);
|
|
15226
|
+
if (staticFileMap && inflateSea) {
|
|
15227
|
+
staticFileMap[file.filePath + r.method + r.path] = {
|
|
15228
|
+
filePath: file.filePath,
|
|
15229
|
+
contentType,
|
|
15230
|
+
method: r.method,
|
|
15231
|
+
previewMethod: "html",
|
|
15232
|
+
path: r.path,
|
|
15233
|
+
body: Buffer.from(HTML_STATIC),
|
|
15234
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", r.inflatePath) : void 0
|
|
15235
|
+
};
|
|
15236
|
+
}
|
|
15237
|
+
}
|
|
15290
15238
|
}
|
|
15239
|
+
router.use(assertGlobalTampered);
|
|
15240
|
+
router.use(async function(req, res) {
|
|
15241
|
+
const toRender = typeof module2.default === "function" ? module2.default(req, res) : module2.default;
|
|
15242
|
+
const HTML = await getHTML(hotreload, req, res, newURL2(req.path), module2.apiOptions?.basePath, await toRender);
|
|
15243
|
+
return res.asyncEnd({
|
|
15244
|
+
status: 200,
|
|
15245
|
+
headers: {
|
|
15246
|
+
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15247
|
+
},
|
|
15248
|
+
body: HTML
|
|
15249
|
+
});
|
|
15250
|
+
}, r.path, r.method, r.options);
|
|
15291
15251
|
}
|
|
15292
|
-
router.use(assertGlobalTampered);
|
|
15293
|
-
router.get(path, async function(req, res) {
|
|
15294
|
-
return res.asyncEnd({
|
|
15295
|
-
status: 200,
|
|
15296
|
-
headers: {
|
|
15297
|
-
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15298
|
-
},
|
|
15299
|
-
body: code
|
|
15300
|
-
});
|
|
15301
|
-
});
|
|
15302
15252
|
return resolve24();
|
|
15303
15253
|
}
|
|
15304
|
-
|
|
15305
|
-
|
|
15306
|
-
|
|
15307
|
-
|
|
15308
|
-
|
|
15309
|
-
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15316
|
-
|
|
15317
|
-
|
|
15318
|
-
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
};
|
|
15322
|
-
if (inflateDir) {
|
|
15323
|
-
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15324
|
-
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15325
|
-
recursive: true
|
|
15326
|
-
});
|
|
15327
|
-
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15328
|
-
(0, import_node_fs11.writeFileSync)(inflatePath, code);
|
|
15329
|
-
if (staticFileMap && inflateSea) {
|
|
15330
|
-
staticFileMap[file.filePath] = {
|
|
15331
|
-
contentType,
|
|
15332
|
-
method: "GET",
|
|
15254
|
+
case ".min":
|
|
15255
|
+
case ".js":
|
|
15256
|
+
default: {
|
|
15257
|
+
if (file.ext !== ".js" && file.ext !== ".ts") {
|
|
15258
|
+
const code = await inflateJSX(file.filePath, {
|
|
15259
|
+
embemedJSX: true,
|
|
15260
|
+
minify: file.subExt === ".min" ? true : false,
|
|
15261
|
+
useExport: false,
|
|
15262
|
+
logger
|
|
15263
|
+
});
|
|
15264
|
+
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
15265
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name + ".js");
|
|
15266
|
+
routeFileMap[file.filePath] = {
|
|
15267
|
+
routes: [{
|
|
15268
|
+
method: "GET",
|
|
15269
|
+
path
|
|
15270
|
+
}],
|
|
15333
15271
|
filePath: file.filePath,
|
|
15334
|
-
|
|
15335
|
-
|
|
15336
|
-
body: Buffer.from(code),
|
|
15337
|
-
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
15272
|
+
service,
|
|
15273
|
+
previewMethod: "html"
|
|
15338
15274
|
};
|
|
15275
|
+
if (inflateDir) {
|
|
15276
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15277
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15278
|
+
recursive: true
|
|
15279
|
+
});
|
|
15280
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15281
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, code);
|
|
15282
|
+
if (staticFileMap && inflateSea) {
|
|
15283
|
+
staticFileMap[file.filePath] = {
|
|
15284
|
+
contentType,
|
|
15285
|
+
filePath: file.filePath,
|
|
15286
|
+
method: "GET",
|
|
15287
|
+
previewMethod: "html",
|
|
15288
|
+
path,
|
|
15289
|
+
body: Buffer.from(code),
|
|
15290
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
15291
|
+
};
|
|
15292
|
+
}
|
|
15293
|
+
}
|
|
15294
|
+
router.use(assertGlobalTampered);
|
|
15295
|
+
router.get(path, async function(req, res) {
|
|
15296
|
+
return res.asyncEnd({
|
|
15297
|
+
status: 200,
|
|
15298
|
+
headers: {
|
|
15299
|
+
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15300
|
+
},
|
|
15301
|
+
body: code
|
|
15302
|
+
});
|
|
15303
|
+
});
|
|
15304
|
+
return resolve24();
|
|
15339
15305
|
}
|
|
15340
15306
|
}
|
|
15341
|
-
router.use(assertGlobalTampered);
|
|
15342
|
-
router.get(path, async function(_req, res) {
|
|
15343
|
-
res.asyncEnd({
|
|
15344
|
-
status: 200,
|
|
15345
|
-
headers: {
|
|
15346
|
-
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15347
|
-
},
|
|
15348
|
-
body: code
|
|
15349
|
-
});
|
|
15350
|
-
});
|
|
15351
|
-
return resolve24();
|
|
15352
15307
|
}
|
|
15353
15308
|
}
|
|
15354
|
-
|
|
15355
|
-
default:
|
|
15356
|
-
if (file.ext === ".js" || file.ext === ".ts") {
|
|
15309
|
+
case ".md": {
|
|
15357
15310
|
switch (file.subExt) {
|
|
15358
|
-
case ".
|
|
15359
|
-
|
|
15360
|
-
|
|
15361
|
-
|
|
15362
|
-
case ".bundle":
|
|
15363
|
-
case ".min": {
|
|
15364
|
-
const code = await inflateJSX(file.filePath, {
|
|
15365
|
-
embemedJSX: false,
|
|
15366
|
-
minify: file.subExt === ".min" ? true : false,
|
|
15367
|
-
useExport: false,
|
|
15368
|
-
logger
|
|
15369
|
-
});
|
|
15370
|
-
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
15371
|
-
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name + ".js");
|
|
15311
|
+
case ".html": {
|
|
15312
|
+
const code = await inflateMD2HTML(file.filePath, logger);
|
|
15313
|
+
const contentType = CONTENT_TYPE_MAP[".html"];
|
|
15314
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name);
|
|
15372
15315
|
routeFileMap[file.filePath] = {
|
|
15373
15316
|
routes: [{
|
|
15374
15317
|
method: "GET",
|
|
15375
15318
|
path
|
|
15376
15319
|
}],
|
|
15377
|
-
filePath: file.filePath,
|
|
15378
15320
|
service,
|
|
15321
|
+
filePath: file.filePath,
|
|
15379
15322
|
previewMethod: "html"
|
|
15380
15323
|
};
|
|
15381
15324
|
if (inflateDir) {
|
|
@@ -15410,72 +15353,132 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15410
15353
|
return resolve24();
|
|
15411
15354
|
}
|
|
15412
15355
|
}
|
|
15413
|
-
}
|
|
15414
|
-
|
|
15415
|
-
|
|
15416
|
-
|
|
15417
|
-
|
|
15418
|
-
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15426
|
-
|
|
15427
|
-
|
|
15428
|
-
service,
|
|
15429
|
-
filePath: file.filePath,
|
|
15430
|
-
previewMethod: "html"
|
|
15431
|
-
};
|
|
15432
|
-
if (inflateDir) {
|
|
15433
|
-
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15434
|
-
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15435
|
-
recursive: true
|
|
15356
|
+
}
|
|
15357
|
+
default:
|
|
15358
|
+
if (file.ext === ".js" || file.ext === ".ts") {
|
|
15359
|
+
switch (file.subExt) {
|
|
15360
|
+
case ".ignore": {
|
|
15361
|
+
logger.warn("ignoring [%s]", file.filePath);
|
|
15362
|
+
return resolve24();
|
|
15363
|
+
}
|
|
15364
|
+
case ".bundle":
|
|
15365
|
+
case ".min": {
|
|
15366
|
+
const code = await inflateJSX(file.filePath, {
|
|
15367
|
+
embemedJSX: false,
|
|
15368
|
+
minify: file.subExt === ".min" ? true : false,
|
|
15369
|
+
useExport: false,
|
|
15370
|
+
logger
|
|
15436
15371
|
});
|
|
15437
|
-
|
|
15438
|
-
(0,
|
|
15439
|
-
|
|
15440
|
-
|
|
15441
|
-
contentType,
|
|
15372
|
+
const contentType = CONTENT_TYPE_MAP[".js"];
|
|
15373
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name + ".js");
|
|
15374
|
+
routeFileMap[file.filePath] = {
|
|
15375
|
+
routes: [{
|
|
15442
15376
|
method: "GET",
|
|
15443
|
-
|
|
15444
|
-
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15377
|
+
path
|
|
15378
|
+
}],
|
|
15379
|
+
filePath: file.filePath,
|
|
15380
|
+
service,
|
|
15381
|
+
previewMethod: "html"
|
|
15382
|
+
};
|
|
15383
|
+
if (inflateDir) {
|
|
15384
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15385
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15386
|
+
recursive: true
|
|
15387
|
+
});
|
|
15388
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15389
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, code);
|
|
15390
|
+
if (staticFileMap && inflateSea) {
|
|
15391
|
+
staticFileMap[file.filePath] = {
|
|
15392
|
+
contentType,
|
|
15393
|
+
method: "GET",
|
|
15394
|
+
filePath: file.filePath,
|
|
15395
|
+
previewMethod: "html",
|
|
15396
|
+
path,
|
|
15397
|
+
body: Buffer.from(code),
|
|
15398
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
15399
|
+
};
|
|
15400
|
+
}
|
|
15449
15401
|
}
|
|
15402
|
+
router.use(assertGlobalTampered);
|
|
15403
|
+
router.get(path, async function(_req, res) {
|
|
15404
|
+
res.asyncEnd({
|
|
15405
|
+
status: 200,
|
|
15406
|
+
headers: {
|
|
15407
|
+
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15408
|
+
},
|
|
15409
|
+
body: code
|
|
15410
|
+
});
|
|
15411
|
+
});
|
|
15412
|
+
return resolve24();
|
|
15450
15413
|
}
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
|
|
15456
|
-
|
|
15457
|
-
|
|
15458
|
-
|
|
15414
|
+
}
|
|
15415
|
+
} else if (file.ext === ".bundle") {
|
|
15416
|
+
switch (file.subExt) {
|
|
15417
|
+
case ".ignore": {
|
|
15418
|
+
logger.warn("ignoring [%s]", file.filePath);
|
|
15419
|
+
return resolve24();
|
|
15420
|
+
}
|
|
15421
|
+
case ".css": {
|
|
15422
|
+
const code = (0, import_node_fs11.readFileSync)(file.filePath).toString().split("\n").filter((c) => c).filter((c) => c.charAt(0) !== "#").map((cssPath) => (0, import_node_fs11.readFileSync)((0, import_node_path12.resolve)((0, import_node_path12.dirname)(file.filePath), cssPath)).toString()).join("\n");
|
|
15423
|
+
const contentType = CONTENT_TYPE_MAP[".css"];
|
|
15424
|
+
const path = (0, import_node_path12.join)("/", (0, import_node_path12.dirname)((0, import_node_path12.relative)(dir, file.filePath)), file.name);
|
|
15425
|
+
routeFileMap[file.filePath] = {
|
|
15426
|
+
routes: [{
|
|
15427
|
+
method: "GET",
|
|
15428
|
+
path
|
|
15429
|
+
}],
|
|
15430
|
+
service,
|
|
15431
|
+
filePath: file.filePath,
|
|
15432
|
+
previewMethod: "html"
|
|
15433
|
+
};
|
|
15434
|
+
if (inflateDir) {
|
|
15435
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "static", path);
|
|
15436
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15437
|
+
recursive: true
|
|
15438
|
+
});
|
|
15439
|
+
logger.log("writing [%s]", (0, import_node_path12.relative)((0, import_node_process8.cwd)(), inflatePath));
|
|
15440
|
+
(0, import_node_fs11.writeFileSync)(inflatePath, code);
|
|
15441
|
+
if (staticFileMap && inflateSea) {
|
|
15442
|
+
staticFileMap[file.filePath] = {
|
|
15443
|
+
contentType,
|
|
15444
|
+
method: "GET",
|
|
15445
|
+
filePath: file.filePath,
|
|
15446
|
+
previewMethod: "html",
|
|
15447
|
+
path,
|
|
15448
|
+
body: Buffer.from(code),
|
|
15449
|
+
inflatePath: inflateDir ? (0, import_node_path12.join)(inflateDir, service, "static", path) : void 0
|
|
15450
|
+
};
|
|
15451
|
+
}
|
|
15452
|
+
}
|
|
15453
|
+
router.use(assertGlobalTampered);
|
|
15454
|
+
router.get(path, async function(_req, res) {
|
|
15455
|
+
res.asyncEnd({
|
|
15456
|
+
status: 200,
|
|
15457
|
+
headers: {
|
|
15458
|
+
["Content-Type"]: contentType ? contentType : DEFAULT_CONTENT_TYPE
|
|
15459
|
+
},
|
|
15460
|
+
body: code
|
|
15461
|
+
});
|
|
15459
15462
|
});
|
|
15460
|
-
|
|
15461
|
-
|
|
15463
|
+
return resolve24();
|
|
15464
|
+
}
|
|
15462
15465
|
}
|
|
15463
15466
|
}
|
|
15464
|
-
|
|
15465
|
-
|
|
15466
|
-
|
|
15467
|
+
createStaticRoute(service, logger, router, dir, file, inflateDir, routeFileMap, staticFileMap);
|
|
15468
|
+
return resolve24();
|
|
15469
|
+
}
|
|
15470
|
+
} catch (e) {
|
|
15471
|
+
logger.error("error with " + file.filePath);
|
|
15472
|
+
logger.error(e);
|
|
15473
|
+
errors.push({
|
|
15474
|
+
filePath: file.filePath,
|
|
15475
|
+
error: e
|
|
15476
|
+
});
|
|
15477
|
+
} finally {
|
|
15478
|
+
return resolve24();
|
|
15467
15479
|
}
|
|
15468
|
-
}
|
|
15469
|
-
|
|
15470
|
-
logger.error(e);
|
|
15471
|
-
errors.push({
|
|
15472
|
-
filePath: file.filePath,
|
|
15473
|
-
error: e
|
|
15474
|
-
});
|
|
15475
|
-
} finally {
|
|
15476
|
-
return resolve24();
|
|
15477
|
-
}
|
|
15478
|
-
})));
|
|
15480
|
+
});
|
|
15481
|
+
}
|
|
15479
15482
|
router.use(assertGlobalTampered);
|
|
15480
15483
|
return {
|
|
15481
15484
|
routeFileMap,
|