@dreamkit/dev 0.0.14-next.0 → 0.0.14-next.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.
- package/lib/DreamkitDevServer.d.ts +2 -0
- package/lib/DreamkitDevServer.d.ts.map +1 -1
- package/lib/DreamkitDevServer.js +25 -4
- package/lib/actions/generate-meta.d.ts +6 -0
- package/lib/actions/generate-meta.d.ts.map +1 -0
- package/lib/actions/generate-meta.js +62 -0
- package/lib/actions/generate-settings.d.ts +4 -0
- package/lib/actions/generate-settings.d.ts.map +1 -0
- package/lib/actions/generate-settings.js +12 -0
- package/lib/actions/generate.d.ts +3 -3
- package/lib/actions/generate.d.ts.map +1 -1
- package/lib/actions/generate.js +8 -58
- package/lib/adapters/solid-start/dev-server.d.ts.map +1 -1
- package/lib/adapters/solid-start/dev-server.js +25 -5
- package/lib/adapters/solid-start/prod-server.d.ts.map +1 -1
- package/lib/adapters/solid-start/prod-server.js +5 -2
- package/lib/bin.js +5 -5
- package/lib/options.d.ts +4 -0
- package/lib/options.d.ts.map +1 -1
- package/lib/options.js +2 -0
- package/lib/plugins/dreamkit.d.ts.map +1 -1
- package/lib/plugins/dreamkit.js +2 -5
- package/lib/transforms/to-solid-route.js +4 -4
- package/lib/transforms/to-solid-server-action.js +1 -1
- package/lib/utils/path.d.ts +1 -0
- package/lib/utils/path.d.ts.map +1 -1
- package/lib/utils/path.js +5 -2
- package/package.json +7 -3
- package/lib/utils/object.d.ts +0 -4
- package/lib/utils/object.d.ts.map +0 -1
- package/lib/utils/object.js +0 -20
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DreamkitPluginOptions, OutDreamkitPluginOptions } from "./options.js";
|
|
2
2
|
import { VirtualShaking } from "./utils/shaking.js";
|
|
3
3
|
import { App, Route } from "@dreamkit/app";
|
|
4
|
+
import { FSWatcher } from "chokidar";
|
|
4
5
|
import { ViteDevServer } from "vite";
|
|
5
6
|
import { ViteRuntime } from "vite/runtime";
|
|
6
7
|
export type DreamkitDevExternalOptions = {
|
|
@@ -15,6 +16,7 @@ export declare class DreamkitDevServer {
|
|
|
15
16
|
readonly entry: VirtualShaking;
|
|
16
17
|
protected runtimeServer: ViteDevServer | undefined;
|
|
17
18
|
protected runtime: ViteRuntime | undefined;
|
|
19
|
+
protected settingsFileWatcher: FSWatcher | undefined;
|
|
18
20
|
readonly options: DreamkitDevOptions;
|
|
19
21
|
constructor(inOptions: DreamkitDevInOptions);
|
|
20
22
|
static instance(): DreamkitDevServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DreamkitDevServer.d.ts","sourceRoot":"","sources":["../src/DreamkitDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAMpD,OAAO,EAAE,GAAG,EAAW,KAAK,
|
|
1
|
+
{"version":3,"file":"DreamkitDevServer.d.ts","sourceRoot":"","sources":["../src/DreamkitDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAMpD,OAAO,EAAE,GAAG,EAAW,KAAK,EAA2B,MAAM,eAAe,CAAC;AAM7E,OAAO,EAAE,SAAS,EAAS,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAmC,aAAa,EAAE,MAAM,MAAM,CAAC;AAGtE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,GACtD,0BAA0B,CAAC;AAC7B,MAAM,MAAM,kBAAkB,GAAG,wBAAwB,GACvD,0BAA0B,CAAC;AAE7B,qBAAa,iBAAiB;IAC5B,MAAM,CAAC,WAAW,SAAmB;IACrC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,SAAS,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,CAAC;IACnD,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,CAAC;IAC3C,SAAS,CAAC,mBAAmB,EAAE,SAAS,GAAG,SAAS,CAAC;IACrD,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;gBACzB,SAAS,EAAE,oBAAoB;IA+B3C,MAAM,CAAC,QAAQ,IAAI,iBAAiB;IAKpC,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,iBAAiB;IAGzC,KAAK,CAAC,IAAI,EAAE,MAAM;IAWlB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAIzC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAIxC,gBAAgB;IAyBhB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAIjD,OAAO,CAAC,uBAAuB,UAAO;IAiDtC,KAAK;IAGL,IAAI;CAMX"}
|
package/lib/DreamkitDevServer.js
CHANGED
|
@@ -4,7 +4,10 @@ import { getExt, resolvePath } from "./utils/path.js";
|
|
|
4
4
|
import { findFileRoutes } from "./utils/router.js";
|
|
5
5
|
import { VirtualShaking } from "./utils/shaking.js";
|
|
6
6
|
import { createTransformUrl, getUrlTransforms, transformAndGenerate, } from "./utils/transform.js";
|
|
7
|
-
import { App, isRoute, $route } from "@dreamkit/app";
|
|
7
|
+
import { App, isRoute, $route, SettingsHandler } from "@dreamkit/app";
|
|
8
|
+
import { is } from "@dreamkit/kind";
|
|
9
|
+
import { NodeSettingsHandler, NodeSettingsHandlerOptions, } from "@dreamkit/node-app";
|
|
10
|
+
import { watch } from "chokidar";
|
|
8
11
|
import { existsSync } from "fs";
|
|
9
12
|
import { createServer, createViteRuntime } from "vite";
|
|
10
13
|
import solidPlugin from "vite-plugin-solid";
|
|
@@ -15,6 +18,7 @@ export class DreamkitDevServer {
|
|
|
15
18
|
entry;
|
|
16
19
|
runtimeServer;
|
|
17
20
|
runtime;
|
|
21
|
+
settingsFileWatcher;
|
|
18
22
|
options;
|
|
19
23
|
constructor(inOptions) {
|
|
20
24
|
this.app = new App();
|
|
@@ -24,8 +28,10 @@ export class DreamkitDevServer {
|
|
|
24
28
|
});
|
|
25
29
|
const vars = { defaults: options.root, root: options.root };
|
|
26
30
|
options.entry = resolvePath(options.entry, vars);
|
|
31
|
+
options.settingsPath = resolvePath(options.settingsPath, vars);
|
|
27
32
|
options.metaGlobalOutput = resolvePath(options.metaGlobalOutput, vars);
|
|
28
33
|
options.metaLocalOutput = resolvePath(options.metaLocalOutput, vars);
|
|
34
|
+
options.preEntries = options.preEntries?.map((v) => resolvePath(v, vars));
|
|
29
35
|
this.entry = new VirtualShaking({
|
|
30
36
|
entry: options.entry,
|
|
31
37
|
onChange: async (changes) => {
|
|
@@ -128,11 +134,25 @@ export class DreamkitDevServer {
|
|
|
128
134
|
hmr: { logger: false },
|
|
129
135
|
});
|
|
130
136
|
this.entry.init();
|
|
131
|
-
const
|
|
137
|
+
for (const path of this.options.preEntries || [])
|
|
138
|
+
await this.app.add(await this.fetch(path));
|
|
139
|
+
await this.app.add({
|
|
132
140
|
...(await this.fetchEntryObjects()),
|
|
133
141
|
...(includeRouteFileObjects && (await this.findRouteObjects())),
|
|
134
|
-
};
|
|
135
|
-
|
|
142
|
+
});
|
|
143
|
+
if (is(this.app.settingsHandler, NodeSettingsHandler)) {
|
|
144
|
+
this.app.context.register(NodeSettingsHandlerOptions, {
|
|
145
|
+
value: new NodeSettingsHandlerOptions({
|
|
146
|
+
path: this.options.settingsPath,
|
|
147
|
+
}),
|
|
148
|
+
});
|
|
149
|
+
this.settingsFileWatcher = watch(this.options.settingsPath, {
|
|
150
|
+
ignoreInitial: false,
|
|
151
|
+
}).on("all", async () => {
|
|
152
|
+
log("settings file changed");
|
|
153
|
+
await this.app.context.resolve(SettingsHandler).load();
|
|
154
|
+
});
|
|
155
|
+
}
|
|
136
156
|
}
|
|
137
157
|
async start() {
|
|
138
158
|
await this.app.start();
|
|
@@ -140,6 +160,7 @@ export class DreamkitDevServer {
|
|
|
140
160
|
async stop() {
|
|
141
161
|
if (this.app.started)
|
|
142
162
|
await this.app.stop();
|
|
163
|
+
await this.settingsFileWatcher?.close();
|
|
143
164
|
await this.runtimeServer?.close();
|
|
144
165
|
await this.runtime?.destroy();
|
|
145
166
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-meta.d.ts","sourceRoot":"","sources":["../../src/actions/generate-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAY5D,wBAAsB,YAAY,CAAC,MAAM,EAAE,iBAAiB;;;GAwD3D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { writeFileIfDifferent } from "../utils/fs.js";
|
|
2
|
+
import { createInterface, createModuleDeclaration, createType, } from "../utils/typescript.js";
|
|
3
|
+
import { mkdir } from "fs/promises";
|
|
4
|
+
import { dirname } from "path";
|
|
5
|
+
export async function generateMeta(server) {
|
|
6
|
+
const options = server.options;
|
|
7
|
+
const output = options.metaFormat === "global"
|
|
8
|
+
? options.metaGlobalOutput
|
|
9
|
+
: options.metaLocalOutput;
|
|
10
|
+
const routeDef = [...server.app.routes]
|
|
11
|
+
.map((route) => ({
|
|
12
|
+
path: route.$options.path ?? "",
|
|
13
|
+
params: route.$options.params,
|
|
14
|
+
}))
|
|
15
|
+
.sort((a, b) => a.path.localeCompare(b.path));
|
|
16
|
+
const typeRoutes = await generateDefinition(routeDef);
|
|
17
|
+
let contents;
|
|
18
|
+
if (options.metaFormat === "global") {
|
|
19
|
+
const declarations = {
|
|
20
|
+
["dreamkit/presets/global.override.js"]: createInterface("Routing", typeRoutes, 1),
|
|
21
|
+
};
|
|
22
|
+
contents =
|
|
23
|
+
Object.entries(declarations)
|
|
24
|
+
.map(([source, body]) => `// prettier-ignore\n` + createModuleDeclaration(source, [body]))
|
|
25
|
+
.join("\n\n") + "\n";
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
contents = [
|
|
29
|
+
`// prettier-ignore`,
|
|
30
|
+
`import { defineRoutePath } from "dreamkit/presets/common.js";`,
|
|
31
|
+
`import { defineLink } from "dreamkit/presets/solid.js";`,
|
|
32
|
+
"",
|
|
33
|
+
...(options.metaLocalExports
|
|
34
|
+
? [
|
|
35
|
+
'export * from "dreamkit/presets/common.js";',
|
|
36
|
+
'export * from "dreamkit/presets/solid.js";',
|
|
37
|
+
]
|
|
38
|
+
: []),
|
|
39
|
+
createInterface("Routing", typeRoutes, 0),
|
|
40
|
+
"export const routePath = defineRoutePath<Routing>();",
|
|
41
|
+
"export const Link = defineLink<Routing>();",
|
|
42
|
+
].join("\n");
|
|
43
|
+
}
|
|
44
|
+
await mkdir(dirname(output), { recursive: true });
|
|
45
|
+
const changed = await writeFileIfDifferent(output, contents);
|
|
46
|
+
return {
|
|
47
|
+
path: output,
|
|
48
|
+
changed,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async function generateDefinition(routes) {
|
|
52
|
+
const result = {};
|
|
53
|
+
for (const route of routes) {
|
|
54
|
+
if (route.path.includes("*404"))
|
|
55
|
+
continue;
|
|
56
|
+
const params = route.params;
|
|
57
|
+
result[route.path] = Object.keys(params?.options.props || {}).length
|
|
58
|
+
? createType(params)
|
|
59
|
+
: "never";
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DreamkitDevServer } from "../DreamkitDevServer.js";
|
|
2
|
+
import { SettingsHandlerSaveResult } from "@dreamkit/app";
|
|
3
|
+
export declare function generateSettings(server: DreamkitDevServer): Promise<SettingsHandlerSaveResult>;
|
|
4
|
+
//# sourceMappingURL=generate-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-settings.d.ts","sourceRoot":"","sources":["../../src/actions/generate-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAO,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAG/D,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,yBAAyB,CAAC,CAWpC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { App } from "@dreamkit/app";
|
|
2
|
+
import { NodeSettingsHandlerOptions } from "@dreamkit/node-app";
|
|
3
|
+
export async function generateSettings(server) {
|
|
4
|
+
const $app = new App();
|
|
5
|
+
$app.context.register(NodeSettingsHandlerOptions, {
|
|
6
|
+
value: new NodeSettingsHandlerOptions({
|
|
7
|
+
path: server.options.settingsPath,
|
|
8
|
+
}),
|
|
9
|
+
});
|
|
10
|
+
await $app.add([...server.app.settings, server.app.settingsHandler].filter(Boolean));
|
|
11
|
+
return (await $app["registerAllSettings"]()) || {};
|
|
12
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DreamkitDevServer } from "../DreamkitDevServer.js";
|
|
2
|
-
export declare function generate(server: DreamkitDevServer): Promise<{
|
|
3
|
-
|
|
2
|
+
export declare function generate(server: DreamkitDevServer): Promise<Record<string, {
|
|
3
|
+
path: string;
|
|
4
4
|
changed: boolean;
|
|
5
|
-
}
|
|
5
|
+
}>>;
|
|
6
6
|
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/actions/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/actions/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CAS7D"}
|
package/lib/actions/generate.js
CHANGED
|
@@ -1,62 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { mkdir } from "fs/promises";
|
|
4
|
-
import { dirname } from "path";
|
|
1
|
+
import { generateMeta } from "./generate-meta.js";
|
|
2
|
+
import { generateSettings } from "./generate-settings.js";
|
|
5
3
|
export async function generate(server) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const routeDef = [...server.app.routes]
|
|
11
|
-
.map((route) => ({
|
|
12
|
-
path: route.$options.path ?? "",
|
|
13
|
-
params: route.$options.params,
|
|
14
|
-
}))
|
|
15
|
-
.sort((a, b) => a.path.localeCompare(b.path));
|
|
16
|
-
const typeRoutes = await generateDefinition(routeDef);
|
|
17
|
-
let contents;
|
|
18
|
-
if (options.metaFormat === "global") {
|
|
19
|
-
const declarations = {
|
|
20
|
-
["dreamkit/presets/global.override.js"]: createInterface("Routing", typeRoutes, 1),
|
|
21
|
-
};
|
|
22
|
-
contents =
|
|
23
|
-
Object.entries(declarations)
|
|
24
|
-
.map(([source, body]) => `// prettier-ignore\n` + createModuleDeclaration(source, [body]))
|
|
25
|
-
.join("\n\n") + "\n";
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
contents = [
|
|
29
|
-
`// prettier-ignore`,
|
|
30
|
-
`import { defineRoutePath } from "dreamkit/presets/common.js";`,
|
|
31
|
-
`import { defineLink } from "dreamkit/presets/solid.js";`,
|
|
32
|
-
"",
|
|
33
|
-
...(options.metaLocalExports
|
|
34
|
-
? [
|
|
35
|
-
'export * from "dreamkit/presets/common.js";',
|
|
36
|
-
'export * from "dreamkit/presets/solid.js";',
|
|
37
|
-
]
|
|
38
|
-
: []),
|
|
39
|
-
createInterface("Routing", typeRoutes, 0),
|
|
40
|
-
"export const routePath = defineRoutePath<Routing>();",
|
|
41
|
-
"export const Link = defineLink<Routing>();",
|
|
42
|
-
].join("\n");
|
|
43
|
-
}
|
|
44
|
-
await mkdir(dirname(output), { recursive: true });
|
|
45
|
-
const changed = await writeFileIfDifferent(output, contents);
|
|
4
|
+
const [meta, settings] = await Promise.all([
|
|
5
|
+
generateMeta(server),
|
|
6
|
+
generateSettings(server),
|
|
7
|
+
]);
|
|
46
8
|
return {
|
|
47
|
-
|
|
48
|
-
|
|
9
|
+
meta,
|
|
10
|
+
...settings,
|
|
49
11
|
};
|
|
50
12
|
}
|
|
51
|
-
async function generateDefinition(routes) {
|
|
52
|
-
const result = {};
|
|
53
|
-
for (const route of routes) {
|
|
54
|
-
if (route.path.includes("*404"))
|
|
55
|
-
continue;
|
|
56
|
-
const params = route.params;
|
|
57
|
-
result[route.path] = Object.keys(params?.options.props || {}).length
|
|
58
|
-
? createType(params)
|
|
59
|
-
: "never";
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../../src/adapters/solid-start/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../../src/adapters/solid-start/dev-server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAMzD,OAAO,EAML,QAAQ,EAET,MAAM,sBAAsB,CAAC;AAsB9B,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACrD,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAqDhC;AAuCD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,QAAQ,EAClB,SAAS,GAAE,qBAA0B,qBAuLtC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { DreamkitDevServer, } from "../../DreamkitDevServer.js";
|
|
2
|
-
import {
|
|
2
|
+
import { generateMeta } from "../../actions/generate-meta.js";
|
|
3
|
+
import { generateSettings } from "../../actions/generate-settings.js";
|
|
3
4
|
import { tryGenerate } from "../../utils/ast.js";
|
|
5
|
+
import { log } from "../../utils/log.js";
|
|
4
6
|
import { execute } from "../../utils/runtime.js";
|
|
5
7
|
import { createDelayedFunction } from "../../utils/timeout.js";
|
|
6
8
|
import { transformCode } from "../../utils/transform.js";
|
|
7
9
|
import { addVinxiPlugin, addVinxiRollupPlugin, isVinxiBuild, onChangeVinxiRoutes, } from "../../utils/vinxi.js";
|
|
8
|
-
import { isRoute, $route, App } from "@dreamkit/app";
|
|
10
|
+
import { isRoute, $route, App, isSettings } from "@dreamkit/app";
|
|
9
11
|
import { existsSync } from "fs";
|
|
10
12
|
import { join, normalize, relative, resolve } from "path";
|
|
11
13
|
import { fileURLToPath } from "url";
|
|
@@ -128,7 +130,8 @@ export function createDreamkitDevServer(vinxiApp, inOptions = {}) {
|
|
|
128
130
|
await server.stop();
|
|
129
131
|
}
|
|
130
132
|
async function onDevStart() {
|
|
131
|
-
const
|
|
133
|
+
const tryGenerateMeta = createDelayedFunction(async () => {
|
|
134
|
+
log("generating meta");
|
|
132
135
|
const paths = new Set();
|
|
133
136
|
server.app.routes.forEach(async (route) => {
|
|
134
137
|
const path = route.$options.path;
|
|
@@ -139,12 +142,20 @@ export function createDreamkitDevServer(vinxiApp, inOptions = {}) {
|
|
|
139
142
|
paths.add(path);
|
|
140
143
|
}
|
|
141
144
|
});
|
|
142
|
-
await
|
|
145
|
+
await generateMeta(server);
|
|
146
|
+
}, 300);
|
|
147
|
+
const tryGenerateSettings = createDelayedFunction(async () => {
|
|
148
|
+
log("generating settings");
|
|
149
|
+
await generateSettings(server);
|
|
143
150
|
}, 300);
|
|
144
151
|
server.app
|
|
145
152
|
.on("change", (data) => {
|
|
153
|
+
log("change detected", { action: data.action, id: data.id });
|
|
146
154
|
if (isRoute(data.value)) {
|
|
147
|
-
|
|
155
|
+
tryGenerateMeta();
|
|
156
|
+
}
|
|
157
|
+
else if (isSettings(data.value)) {
|
|
158
|
+
tryGenerateSettings();
|
|
148
159
|
}
|
|
149
160
|
})
|
|
150
161
|
.on("add", async ({ id, value }) => {
|
|
@@ -199,11 +210,13 @@ export function createDreamkitDevServer(vinxiApp, inOptions = {}) {
|
|
|
199
210
|
});
|
|
200
211
|
}
|
|
201
212
|
}
|
|
213
|
+
await server.start();
|
|
202
214
|
}
|
|
203
215
|
const ssrRouter = vinxiApp.getRouter("ssr");
|
|
204
216
|
ssrRouter.middleware = selfPath("middleware.js", true);
|
|
205
217
|
if (isVinxiBuild()) {
|
|
206
218
|
const dreamkitEntryId = "dk:entry";
|
|
219
|
+
const dreamkitPreEntriesId = "dk:pre-entries";
|
|
207
220
|
const dreamkitEntry = join(server.options.root, "src/dreamkit.tsx").replaceAll("\\", "/");
|
|
208
221
|
const existsDreamkitEntry = existsSync(dreamkitEntry);
|
|
209
222
|
addVinxiPlugin(vinxiApp, selfPath("prod-server.js"));
|
|
@@ -213,10 +226,17 @@ export function createDreamkitDevServer(vinxiApp, inOptions = {}) {
|
|
|
213
226
|
if (id === dreamkitEntryId) {
|
|
214
227
|
return existsDreamkitEntry ? dreamkitEntry : `\0${dreamkitEntryId}`;
|
|
215
228
|
}
|
|
229
|
+
else if (id === dreamkitPreEntriesId) {
|
|
230
|
+
return `\0${dreamkitPreEntriesId}`;
|
|
231
|
+
}
|
|
216
232
|
},
|
|
217
233
|
load(id) {
|
|
218
234
|
if (!existsDreamkitEntry && id === `\0${dreamkitEntryId}`)
|
|
219
235
|
return { code: "export {}" };
|
|
236
|
+
if (id === `\0${dreamkitPreEntriesId}`) {
|
|
237
|
+
const exports = server.options.preEntries?.map((entry, index) => `export * as entry_${index} from ${JSON.stringify(entry)};`);
|
|
238
|
+
return { code: [...exports, `export {};`].join("\n") };
|
|
239
|
+
}
|
|
220
240
|
},
|
|
221
241
|
});
|
|
222
242
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prod-server.d.ts","sourceRoot":"","sources":["../../../src/adapters/solid-start/prod-server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prod-server.d.ts","sourceRoot":"","sources":["../../../src/adapters/solid-start/prod-server.ts"],"names":[],"mappings":"AAMA,yBAA+B,MAAM,EAAE,GAAG,iBAKzC"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { App } from "@dreamkit/app";
|
|
2
2
|
// @ts-ignore
|
|
3
3
|
import * as objects from "dk:entry";
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import * as preEntries from "dk:pre-entries";
|
|
4
6
|
export default async function (_nitro) {
|
|
5
|
-
const app =
|
|
6
|
-
|
|
7
|
+
const app = App.createGlobalInstance();
|
|
8
|
+
for (const id in preEntries)
|
|
9
|
+
await app.add(preEntries[id]);
|
|
7
10
|
await app.add(objects);
|
|
8
11
|
await app.start();
|
|
9
12
|
}
|
package/lib/bin.js
CHANGED
|
@@ -24,11 +24,11 @@ program
|
|
|
24
24
|
try {
|
|
25
25
|
await server.prepare();
|
|
26
26
|
const result = await generate(server);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
!
|
|
31
|
-
|
|
27
|
+
const rel = (path) => relative(process.cwd(), path).replaceAll("\\", "/");
|
|
28
|
+
for (const key in result) {
|
|
29
|
+
const { changed, path } = result[key];
|
|
30
|
+
console.info([`Generated: ${rel(path)}`, !changed ? " (no changes)" : ""].join(""));
|
|
31
|
+
}
|
|
32
32
|
}
|
|
33
33
|
finally {
|
|
34
34
|
await server.stop();
|
package/lib/options.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
export type DreamkitPluginOptions = {
|
|
2
2
|
entry?: string;
|
|
3
|
+
preEntries?: string[];
|
|
3
4
|
metaFormat?: "global" | "local";
|
|
4
5
|
metaRouting?: boolean;
|
|
5
6
|
metaGlobalOutput?: string;
|
|
6
7
|
metaLocalExports?: boolean;
|
|
7
8
|
metaLocalOutput?: string;
|
|
9
|
+
settingsPath?: string;
|
|
8
10
|
};
|
|
9
11
|
export declare const dreamkitPluginOptions: {
|
|
10
12
|
metaFormat: "global";
|
|
11
13
|
metaRouting: true;
|
|
12
14
|
entry: string;
|
|
15
|
+
preEntries: string[];
|
|
13
16
|
metaGlobalOutput: string;
|
|
14
17
|
metaLocalOutput: string;
|
|
15
18
|
metaLocalExports: true;
|
|
19
|
+
settingsPath: string;
|
|
16
20
|
};
|
|
17
21
|
export type OutDreamkitPluginOptions = Required<Pick<DreamkitPluginOptions, keyof typeof dreamkitPluginOptions>> & Omit<DreamkitPluginOptions, keyof typeof dreamkitPluginOptions>;
|
|
18
22
|
//# sourceMappingURL=options.d.ts.map
|
package/lib/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;CASD,CAAC;AAElC,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAC7C,IAAI,CAAC,qBAAqB,EAAE,MAAM,OAAO,qBAAqB,CAAC,CAChE,GACC,IAAI,CAAC,qBAAqB,EAAE,MAAM,OAAO,qBAAqB,CAAC,CAAC"}
|
package/lib/options.js
CHANGED
|
@@ -2,7 +2,9 @@ export const dreamkitPluginOptions = {
|
|
|
2
2
|
metaFormat: "global",
|
|
3
3
|
metaRouting: true,
|
|
4
4
|
entry: "./src/dreamkit.tsx",
|
|
5
|
+
preEntries: ["dreamkit/adapters/solid-start/entry.js"],
|
|
5
6
|
metaGlobalOutput: "./src/dreamkit-global.d.ts",
|
|
6
7
|
metaLocalOutput: "./src/dreamkit-local.ts",
|
|
7
8
|
metaLocalExports: true,
|
|
9
|
+
settingsPath: "./settings.json",
|
|
8
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dreamkit.d.ts","sourceRoot":"","sources":["../../src/plugins/dreamkit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dreamkit.d.ts","sourceRoot":"","sources":["../../src/plugins/dreamkit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAItD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAE9B,wBAAgB,cAAc,CAAC,SAAS,GAAE,qBAA0B,GAAG,MAAM,CAqD5E"}
|
package/lib/plugins/dreamkit.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { createDreamkitDevServer } from "../adapters/solid-start/dev-server.js";
|
|
2
2
|
import { tryGenerate } from "../utils/ast.js";
|
|
3
3
|
import { transformCode } from "../utils/transform.js";
|
|
4
|
-
import {
|
|
4
|
+
import { onVinxiApp } from "../utils/vinxi.js";
|
|
5
5
|
export function dreamkitPlugin(inOptions = {}) {
|
|
6
6
|
let isSolidStart = false;
|
|
7
|
-
let server;
|
|
8
7
|
const cleanup = onVinxiApp(async (app) => {
|
|
9
|
-
|
|
10
|
-
if (!isVinxiBuild())
|
|
11
|
-
await server.start();
|
|
8
|
+
createDreamkitDevServer(app, inOptions);
|
|
12
9
|
});
|
|
13
10
|
return {
|
|
14
11
|
name: "dreamkit",
|
|
@@ -8,7 +8,7 @@ export function toSolidRoute(ast) {
|
|
|
8
8
|
let routeImportName;
|
|
9
9
|
const routeSpec = "$route";
|
|
10
10
|
const routeSource = "dreamkit";
|
|
11
|
-
const routeNewSource = "dreamkit/adapters/solid.js";
|
|
11
|
+
const routeNewSource = "dreamkit/adapters/solid-start/import.js";
|
|
12
12
|
replaceImportSpec(ast, {
|
|
13
13
|
newSource: routeNewSource,
|
|
14
14
|
source: routeSource,
|
|
@@ -20,7 +20,7 @@ export function toSolidRoute(ast) {
|
|
|
20
20
|
ImportDeclaration(importPath) {
|
|
21
21
|
importPath.traverse({
|
|
22
22
|
ImportSpecifier(path) {
|
|
23
|
-
// import { route as ? } from "dreamkit/adapters/solid.js";
|
|
23
|
+
// import { route as ? } from "dreamkit/adapters/solid-start/import.js";
|
|
24
24
|
const isRouteImport = path.node.imported.type === "Identifier" &&
|
|
25
25
|
path.node.imported.name === routeSpec &&
|
|
26
26
|
importPath.node.source.value === routeNewSource;
|
|
@@ -48,7 +48,7 @@ export function toSolidRoute(ast) {
|
|
|
48
48
|
// import { $route } from "dreamkit";
|
|
49
49
|
// export default route.params({}).create(() => {});
|
|
50
50
|
// [output]
|
|
51
|
-
// import { $route as _$route } from "dreamkit/adapters/solid.js"
|
|
51
|
+
// import { $route as _$route } from "dreamkit/adapters/solid-start/import.js"
|
|
52
52
|
// import { useLocation, useRouter, useParams} from "@solidjs/router"
|
|
53
53
|
// const selfRoute = _$route.params({}).clone({ deps: ? });
|
|
54
54
|
// export const route = selfRoute.createRouteDefinition();
|
|
@@ -80,7 +80,7 @@ export function toSolidRoute(ast) {
|
|
|
80
80
|
// export const route = $route.params({}).path('/path');
|
|
81
81
|
// export default function Users() { useRoute(route); }
|
|
82
82
|
// [output]
|
|
83
|
-
// import { $route as _$route } from "dreamkit/adapters/solid.js"
|
|
83
|
+
// import { $route as _$route } from "dreamkit/adapters/solid-start/import.js"
|
|
84
84
|
// import { useLocation, useRouter, useParams } from "@solidjs/router"
|
|
85
85
|
// const selfRoute = _$route.params({}).path('/path').clone({ deps: ? });
|
|
86
86
|
// export const route = selfRoute.createRouteDefinition();
|
|
@@ -9,7 +9,7 @@ export const toSolidServerAction = defineTransform({
|
|
|
9
9
|
let changes = replaceImportSpec(ast, {
|
|
10
10
|
spec: { $api: "$serverApi" },
|
|
11
11
|
source: "dreamkit",
|
|
12
|
-
newSource: "dreamkit/adapters/solid.js",
|
|
12
|
+
newSource: "dreamkit/adapters/solid-start/import.js",
|
|
13
13
|
onRenameSpec(prev, next) {
|
|
14
14
|
apiId = next;
|
|
15
15
|
},
|
package/lib/utils/path.d.ts
CHANGED
package/lib/utils/path.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,UAKpD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,sBAIlC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAS3D"}
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,WAEvC;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,UAKpD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,sBAIlC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAS3D"}
|
package/lib/utils/path.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { basename, dirname,
|
|
1
|
+
import { basename, dirname, join } from "path";
|
|
2
|
+
export function isRelative(input) {
|
|
3
|
+
return input.startsWith("./");
|
|
4
|
+
}
|
|
2
5
|
export function resolvePath(inPath, vars) {
|
|
3
6
|
let path = inPath;
|
|
4
7
|
for (const name in vars)
|
|
5
8
|
path = path.replace(`{${name}}`, vars[name]);
|
|
6
|
-
return
|
|
9
|
+
return isRelative(path) ? join(vars.defaults, path) : path;
|
|
7
10
|
}
|
|
8
11
|
export function getExt(path) {
|
|
9
12
|
const name = basename(path);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamkit/dev",
|
|
3
|
-
"version": "0.0.14-next.
|
|
3
|
+
"version": "0.0.14-next.2",
|
|
4
4
|
"description": "Development tools for DreamKit.",
|
|
5
5
|
"homepage": "https://dreamkit.dev",
|
|
6
6
|
"repository": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"@babel/types": "^7.26.0",
|
|
38
38
|
"@types/babel__generator": "^7.6.8",
|
|
39
39
|
"@types/babel__traverse": "^7.20.6",
|
|
40
|
+
"chokidar": "^4.0.1",
|
|
40
41
|
"commander": "^12.1.0",
|
|
41
42
|
"debug": "^4.3.7",
|
|
42
43
|
"es-module-lexer": "^1.5.4",
|
|
@@ -45,8 +46,11 @@
|
|
|
45
46
|
"rollup": "^4.26.0",
|
|
46
47
|
"vite-plugin-solid": "^2.10.2",
|
|
47
48
|
"vite-tsconfig-paths": "^5.1.2",
|
|
48
|
-
"@dreamkit/app": "0.0.7-next.
|
|
49
|
-
"@dreamkit/
|
|
49
|
+
"@dreamkit/app": "0.0.7-next.1",
|
|
50
|
+
"@dreamkit/kind": "0.0.2",
|
|
51
|
+
"@dreamkit/node-app": "0.0.2-next.0",
|
|
52
|
+
"@dreamkit/schema": "0.0.5-next.0",
|
|
53
|
+
"@dreamkit/utils": "0.0.5-next.0"
|
|
50
54
|
},
|
|
51
55
|
"devDependencies": {
|
|
52
56
|
"@types/debug": "^4.1.12",
|
package/lib/utils/object.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEtC,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMlC;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAYlD"}
|
package/lib/utils/object.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export function isPlainObject(value) {
|
|
2
|
-
return (!!value &&
|
|
3
|
-
!!(value = Object.getPrototypeOf(value)) &&
|
|
4
|
-
!Object.getPrototypeOf(value));
|
|
5
|
-
}
|
|
6
|
-
export function merge(object, patch) {
|
|
7
|
-
for (const key in patch) {
|
|
8
|
-
const value = patch[key];
|
|
9
|
-
if (isPlainObject(object[key]) && isPlainObject(value)) {
|
|
10
|
-
merge(object[key], value);
|
|
11
|
-
}
|
|
12
|
-
else if (value === undefined) {
|
|
13
|
-
delete object[key];
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
object[key] = value;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return object;
|
|
20
|
-
}
|