rsf-zero 0.3.2 → 0.3.3
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/cli/dev.d.ts +1 -1
- package/dist/cli/dev.d.ts.map +1 -1
- package/dist/cli/dev.js +4 -2
- package/dist/cli/start.d.ts.map +1 -1
- package/dist/cli/start.js +4 -2
- package/dist/utils/customRoutesHook.d.ts +4 -0
- package/dist/utils/customRoutesHook.d.ts.map +1 -0
- package/dist/utils/{customRoutes.js → customRoutesHook.js} +1 -1
- package/dist/utils/export-types.d.ts +1 -0
- package/dist/utils/export-types.d.ts.map +1 -1
- package/dist/utils/onStartHook.d.ts +4 -0
- package/dist/utils/onStartHook.d.ts.map +1 -0
- package/dist/utils/onStartHook.js +35 -0
- package/package.json +1 -1
- package/dist/utils/customRoutes.d.ts +0 -4
- package/dist/utils/customRoutes.d.ts.map +0 -1
package/dist/cli/dev.d.ts
CHANGED
package/dist/cli/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/cli/dev.ts"],"names":[],"mappings":"AAGA,OAAO,eAAe,CAAC;AAMvB,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAGvD,eAAO,MAAM,GAAG,GAAU,SAAS,aAAa,kBAiC/C,CAAA"}
|
package/dist/cli/dev.js
CHANGED
|
@@ -4,7 +4,8 @@ import "dotenv/config";
|
|
|
4
4
|
import { startVite } from "./dev/startVite.js";
|
|
5
5
|
import { createActionRoute } from "./start/createActionRoute.js";
|
|
6
6
|
import { debug } from "../utils/debug.js";
|
|
7
|
-
import {
|
|
7
|
+
import { customRoutesHook } from "../utils/customRoutesHook.js";
|
|
8
|
+
import { onStartHook } from "../utils/onStartHook.js";
|
|
8
9
|
export const dev = async (options) => {
|
|
9
10
|
const app = express();
|
|
10
11
|
const port = 3000;
|
|
@@ -22,11 +23,12 @@ export const dev = async (options) => {
|
|
|
22
23
|
debug("Loaded action handler: " + action.name);
|
|
23
24
|
};
|
|
24
25
|
// - register custom routes
|
|
25
|
-
await
|
|
26
|
+
await customRoutesHook(options, app);
|
|
26
27
|
// Serve the frontend
|
|
27
28
|
// - transform any actions found for the frontend
|
|
28
29
|
// - and inform the onActionFound callback above
|
|
29
30
|
const vite = await startVite({ app, onActionFound });
|
|
31
|
+
await onStartHook(options, app);
|
|
30
32
|
app.listen(port, () => {
|
|
31
33
|
console.log(`Server is running at http://localhost:${port}`);
|
|
32
34
|
});
|
package/dist/cli/start.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAIA,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":"AAIA,OAAO,eAAe,CAAC;AAGvB,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAMvD,eAAO,MAAM,KAAK,GAAU,SAAS,aAAa,kBAoCjD,CAAA"}
|
package/dist/cli/start.js
CHANGED
|
@@ -12,7 +12,8 @@ import morgan from "morgan";
|
|
|
12
12
|
import "dotenv/config";
|
|
13
13
|
import { createActionRoute } from "./start/createActionRoute.js";
|
|
14
14
|
import { debug } from "../utils/debug.js";
|
|
15
|
-
import {
|
|
15
|
+
import { customRoutesHook } from "../utils/customRoutesHook.js";
|
|
16
|
+
import { onStartHook } from "../utils/onStartHook.js";
|
|
16
17
|
export const start = async (options) => {
|
|
17
18
|
const app = express();
|
|
18
19
|
const port = 3000;
|
|
@@ -27,7 +28,7 @@ export const start = async (options) => {
|
|
|
27
28
|
// - register action handlers
|
|
28
29
|
setActionRegistry(actionRegistry);
|
|
29
30
|
// - register custom routes
|
|
30
|
-
await
|
|
31
|
+
await customRoutesHook(options, app);
|
|
31
32
|
// Client
|
|
32
33
|
const staticPath = path.join(process.cwd(), 'dist/client/');
|
|
33
34
|
debug('Serving static files from: ' + staticPath);
|
|
@@ -39,6 +40,7 @@ export const start = async (options) => {
|
|
|
39
40
|
res.sendFile(path.join(process.cwd(), 'dist/client/index.html'));
|
|
40
41
|
}
|
|
41
42
|
});
|
|
43
|
+
await onStartHook(options, app);
|
|
42
44
|
app.listen(port, () => {
|
|
43
45
|
console.log(`Server is running at http://localhost:${port}`);
|
|
44
46
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customRoutesHook.d.ts","sourceRoot":"","sources":["../../src/utils/customRoutesHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAGhD,eAAO,MAAM,gBAAgB,GAAU,SAAS,aAAa,EAAE,KAAK,OAAO,kBAgC1E,CAAA"}
|
|
@@ -8,7 +8,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
8
8
|
};
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import { debug } from "./debug.js";
|
|
11
|
-
export const
|
|
11
|
+
export const customRoutesHook = async (options, app) => {
|
|
12
12
|
if (options.routes) {
|
|
13
13
|
debug(`Routes config option found`);
|
|
14
14
|
if (!Array.isArray(options.routes)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-types.d.ts","sourceRoot":"","sources":["../../src/utils/export-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"export-types.d.ts","sourceRoot":"","sources":["../../src/utils/export-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onStartHook.d.ts","sourceRoot":"","sources":["../../src/utils/onStartHook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAGhD,eAAO,MAAM,WAAW,GAAU,SAAS,aAAa,EAAE,KAAK,OAAO,kBA+BrE,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import path from 'path';
|
|
10
|
+
import { debug } from "./debug.js";
|
|
11
|
+
export const onStartHook = async (options, app) => {
|
|
12
|
+
const { onStart } = options;
|
|
13
|
+
if (onStart) {
|
|
14
|
+
debug(`onStart config option found`);
|
|
15
|
+
if (typeof onStart !== 'string') {
|
|
16
|
+
throw new Error('Invalid onStart option. Must be a string.');
|
|
17
|
+
}
|
|
18
|
+
const absolutePath = path.isAbsolute(onStart)
|
|
19
|
+
? onStart
|
|
20
|
+
: path.join(process.cwd(), onStart);
|
|
21
|
+
debug(`Loading onStart from: ${absolutePath}`);
|
|
22
|
+
const module = await import(__rewriteRelativeImportExtension(absolutePath));
|
|
23
|
+
const exportNames = Object.keys(module);
|
|
24
|
+
if (exportNames.length !== 1) {
|
|
25
|
+
throw new Error(`File ${absolutePath} must contain a single export.`);
|
|
26
|
+
}
|
|
27
|
+
const [firstExportName] = exportNames;
|
|
28
|
+
const firstExport = module[firstExportName];
|
|
29
|
+
if (!(typeof firstExport === 'function')) {
|
|
30
|
+
throw new Error(`File ${absolutePath} must export a function`);
|
|
31
|
+
}
|
|
32
|
+
firstExport(app);
|
|
33
|
+
debug(`onStart loaded successfully: ${absolutePath}`);
|
|
34
|
+
}
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customRoutes.d.ts","sourceRoot":"","sources":["../../src/utils/customRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAGhD,eAAO,MAAM,YAAY,GAAU,SAAS,aAAa,EAAE,KAAK,OAAO,kBAgCtE,CAAA"}
|