@antelopejs/dms-frontend 0.5.6 → 0.6.1

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.
Files changed (71) hide show
  1. package/README.md +376 -18
  2. package/dist/app-configs.d.ts +9 -0
  3. package/dist/app-configs.js +52 -0
  4. package/dist/asset-roots.d.ts +7 -0
  5. package/dist/asset-roots.js +34 -0
  6. package/dist/commands/build-action.js +9 -0
  7. package/dist/commands/dev-action.js +88 -19
  8. package/dist/commands/start-action.js +2 -0
  9. package/dist/common.d.ts +1 -0
  10. package/dist/common.js +1 -0
  11. package/dist/config.d.ts +2 -0
  12. package/dist/config.js +8 -3
  13. package/dist/derived-outputs.d.ts +2 -0
  14. package/dist/derived-outputs.js +38 -31
  15. package/dist/help.js +10 -3
  16. package/dist/layer-watch.js +123 -131
  17. package/dist/layers.js +2 -0
  18. package/dist/manifest-secrets.js +5 -5
  19. package/dist/manifest.js +7 -1
  20. package/dist/materialize.js +21 -1
  21. package/dist/module-set.d.ts +16 -0
  22. package/dist/module-set.js +84 -0
  23. package/dist/server-process.d.ts +1 -0
  24. package/dist/server-process.js +28 -2
  25. package/dist/verify-source-runner.js +12 -0
  26. package/dist/workspace.d.ts +9 -0
  27. package/package.json +2 -1
  28. package/templates/vue/app-runtime.ts +58 -16
  29. package/templates/vue/client-server-guard.mjs +73 -0
  30. package/templates/vue/email-renderer.ts +17 -4
  31. package/templates/vue/email-runtime.ts +1 -1
  32. package/templates/vue/frontend-module.ts +1817 -259
  33. package/templates/vue/globals.d.ts +1 -1
  34. package/templates/vue/icon-hydration.ts +106 -1
  35. package/templates/vue/index.html +0 -1
  36. package/templates/vue/layer-app-config.ts +92 -0
  37. package/templates/vue/main.ts +10 -2
  38. package/templates/vue/package.json +4 -1
  39. package/templates/vue/server/auth/backend.mjs +13 -19
  40. package/templates/vue/server/auth/client-ip.mjs +27 -0
  41. package/templates/vue/server/auth/establish-endpoints.mjs +70 -0
  42. package/templates/vue/server/auth/session.mjs +6 -97
  43. package/templates/vue/server/auth-hooks.mjs +84 -0
  44. package/templates/vue/server/backend-proxies.mjs +110 -0
  45. package/templates/vue/server/dev-private-files.mjs +99 -0
  46. package/templates/vue/server/email.mjs +11 -33
  47. package/templates/vue/server/favicon.mjs +20 -0
  48. package/templates/vue/server/inertia.mjs +48 -3
  49. package/templates/vue/server/listen-host.mjs +19 -0
  50. package/templates/vue/server/module-event.mjs +265 -0
  51. package/templates/vue/server/module-routes.mjs +513 -0
  52. package/templates/vue/server/module-server.mjs +225 -0
  53. package/templates/vue/server/module-testing.mjs +65 -0
  54. package/templates/vue/server/page-props.mjs +151 -0
  55. package/templates/vue/server/path-patterns.mjs +38 -0
  56. package/templates/vue/server/public-endpoints.mjs +69 -11
  57. package/templates/vue/server/request-routing.mjs +47 -0
  58. package/templates/vue/server/route-rules.mjs +129 -0
  59. package/templates/vue/server-module.ts +294 -0
  60. package/templates/vue/server.mjs +177 -161
  61. package/templates/vue/ssr-renderer.ts +60 -19
  62. package/templates/vue/tsconfig.json +2 -1
  63. package/templates/vue/ui-app-config.ts +18 -6
  64. package/templates/vue/ui-inertia-page.mjs +37 -0
  65. package/templates/vue/vite.config.ts +31 -10
  66. package/templates/vue/vite.email.config.ts +1 -1
  67. package/templates/vue/vite.server.config.ts +57 -0
  68. package/templates/vue/server/auth/oauth.mjs +0 -233
  69. package/templates/vue/server/auth/routes.mjs +0 -444
  70. package/templates/vue/server/render-token.mjs +0 -81
  71. package/templates/vue/server/tester.mjs +0 -227
@@ -10,6 +10,8 @@ const output_1 = require("../output");
10
10
  const ports_1 = require("../ports");
11
11
  const server_process_1 = require("../server-process");
12
12
  const update_check_1 = require("../update-check");
13
+ const manifest_1 = require("../manifest");
14
+ const module_set_1 = require("../module-set");
13
15
  const workspace_task_1 = require("./workspace-task");
14
16
  function clientHost() {
15
17
  const host = process.env.HOST?.trim();
@@ -70,51 +72,118 @@ async function runDev(options) {
70
72
  });
71
73
  }
72
74
  }
73
- const secrets = (0, common_1.resolveManifestSecrets)(manifestSecrets);
74
- (0, common_1.reportManifestSecrets)(secrets, (count) => `Set ${count === 1 ? "it" : "them"} in the environment or the project's .env`);
75
- const stopWatchers = (0, common_1.startLayerWatchers)(workspaceDir, layers);
75
+ const session = {
76
+ backendUrl,
77
+ clientUrl,
78
+ port,
79
+ workspaceKey,
80
+ bootstrapSecret,
81
+ refreshBootstrapSecret: () => (0, common_1.resolveBootstrapSecret)(options.bootstrapSecret, backendUrl),
82
+ sessionSecret,
83
+ startedAt,
84
+ isOffline: !!offline,
85
+ };
86
+ let setup = { workspaceDir, layers, manifestSecrets };
87
+ await reserved.release();
88
+ for (;;) {
89
+ const run = await serveWorkspace(session, setup);
90
+ if (!run.isRestart) {
91
+ process.exitCode = run.code;
92
+ return;
93
+ }
94
+ ui.message("info", "Frontend modules changed on the backend: rebuilding the workspace");
95
+ session.startedAt = Date.now();
96
+ session.bootstrapSecret = session.refreshBootstrapSecret();
97
+ setup = await (0, workspace_task_1.setUpWorkspace)({
98
+ backendUrl,
99
+ force: false,
100
+ mode: "dev",
101
+ offline: false,
102
+ clientUrl,
103
+ workspaceKey,
104
+ bootstrapSecret: session.bootstrapSecret,
105
+ });
106
+ }
107
+ }
108
+ function servedModules(setup) {
109
+ return (0, manifest_1.readCachedManifest)(setup.workspaceDir)?.manifest.modules ?? [];
110
+ }
111
+ function reportServed(session, setup) {
112
+ return (0, module_set_1.reportFrontendReady)(session.backendUrl, servedModules(setup).map((module) => module.name), session.bootstrapSecret);
113
+ }
114
+ async function serveWorkspace(session, setup) {
115
+ const restart = new AbortController();
116
+ const stopFollowing = session.isOffline
117
+ ? () => undefined
118
+ : (0, module_set_1.followModuleSet)({
119
+ backendUrl: session.backendUrl,
120
+ clientUrl: session.clientUrl,
121
+ bootstrapSecret: () => {
122
+ session.bootstrapSecret = session.refreshBootstrapSecret();
123
+ return session.bootstrapSecret;
124
+ },
125
+ fingerprint: (0, module_set_1.moduleSetFingerprint)(servedModules(setup)),
126
+ onChange: () => restart.abort(),
127
+ onUnchanged: () => void reportServed(session, setup),
128
+ });
129
+ const stopWatchers = (0, common_1.startLayerWatchers)(setup.workspaceDir, setup.layers);
76
130
  const handleShutdown = async () => {
131
+ stopFollowing();
77
132
  await stopWatchers();
78
133
  };
79
134
  process.once("SIGINT", handleShutdown);
80
135
  process.once("SIGTERM", handleShutdown);
81
- const nodeModulesDir = (0, node_path_1.join)(workspaceDir, "node_modules");
82
- await reserved.release();
136
+ try {
137
+ const code = await runDevServer(session, setup, restart.signal);
138
+ return { code, isRestart: restart.signal.aborted };
139
+ }
140
+ finally {
141
+ process.off("SIGINT", handleShutdown);
142
+ process.off("SIGTERM", handleShutdown);
143
+ stopFollowing();
144
+ await stopWatchers();
145
+ }
146
+ }
147
+ function runDevServer(session, setup, stopSignal) {
148
+ const secrets = (0, common_1.resolveManifestSecrets)(setup.manifestSecrets);
149
+ (0, common_1.reportManifestSecrets)(secrets, (count) => `Set ${count === 1 ? "it" : "them"} in the environment or the project's .env`);
83
150
  const secretSources = (0, common_1.describeSecretSources)(secrets.sources);
84
- const code = await (0, server_process_1.runServer)({
151
+ const nodeModulesDir = (0, node_path_1.join)(setup.workspaceDir, "node_modules");
152
+ return (0, server_process_1.runServer)({
85
153
  name: "dev server",
86
154
  script: "server.mjs",
87
- cwd: workspaceDir,
88
- mapPath: (0, child_output_1.createPathMapper)(workspaceDir, layers),
155
+ cwd: setup.workspaceDir,
156
+ mapPath: (0, child_output_1.createPathMapper)(setup.workspaceDir, setup.layers),
157
+ stopSignal,
89
158
  env: {
90
159
  ...process.env,
91
- PORT: String(port),
160
+ PORT: String(session.port),
92
161
  DMS_DEV: "true",
93
162
  DMS_COOKIE_SECURE: process.env.DMS_COOKIE_SECURE ?? "false",
94
- DMS_API_BASE_URL: backendUrl,
95
- DMS_BOOTSTRAP_SECRET: bootstrapSecret,
96
- DMS_SESSION_SECRET: sessionSecret,
163
+ DMS_API_BASE_URL: session.backendUrl,
164
+ DMS_BOOTSTRAP_SECRET: session.bootstrapSecret,
165
+ DMS_SESSION_SECRET: session.sessionSecret,
97
166
  ...secrets.env,
98
167
  NODE_OPTIONS: "--max-old-space-size=4096",
99
168
  NODE_PATH: nodeModulesDir,
100
169
  },
101
170
  onReady: (address) => {
102
171
  (0, output_1.writeReadyBlock)({
103
- title: `Dev server ready in ${(0, cli_1.formatDuration)(Date.now() - startedAt)}`,
172
+ title: `Dev server ready in ${(0, cli_1.formatDuration)(Date.now() - session.startedAt)}`,
104
173
  lines: (0, server_process_1.readyLines)(address, [
105
- { label: "Backend", value: backendUrl },
106
- { label: "Workspace", value: (0, output_1.showWorkspace)(workspaceDir) },
174
+ { label: "Backend", value: session.backendUrl },
175
+ { label: "Workspace", value: (0, output_1.showWorkspace)(setup.workspaceDir) },
107
176
  ...(secretSources
108
177
  ? [{ label: "Secrets", value: secretSources }]
109
178
  : []),
110
179
  ]),
111
180
  footer: [
112
- `Watching ${(0, cli_1.pluralize)(layers.length, "layer source")}`,
181
+ `Watching ${(0, cli_1.pluralize)(setup.layers.length, "layer source")}`,
113
182
  "Ctrl+C to stop",
114
- ].join(ui.symbols.separator),
183
+ ].join((0, cli_1.getProcessUi)().symbols.separator),
115
184
  });
185
+ void reportServed(session, setup);
116
186
  void (0, update_check_1.reportAvailableUpdate)({ isFollowed: true });
117
187
  },
118
- }).finally(stopWatchers);
119
- process.exitCode = code;
188
+ });
120
189
  }
@@ -9,6 +9,7 @@ const output_1 = require("../output");
9
9
  const ports_1 = require("../ports");
10
10
  const server_process_1 = require("../server-process");
11
11
  const update_check_1 = require("../update-check");
12
+ const module_set_1 = require("../module-set");
12
13
  const BUILD_TIME_MANIFEST = "the build-time manifest";
13
14
  async function runStart(options) {
14
15
  const startedAt = Date.now();
@@ -70,6 +71,7 @@ async function runStart(options) {
70
71
  ]),
71
72
  footer: "Ctrl+C to stop",
72
73
  });
74
+ void (0, module_set_1.reportFrontendReady)(backendUrl, ((0, common_1.readCachedManifest)(workspaceDir)?.manifest.modules ?? []).map((module) => module.name), process.env.DMS_BOOTSTRAP_SECRET);
73
75
  void (0, update_check_1.reportAvailableUpdate)({ isFollowed: true });
74
76
  },
75
77
  });
package/dist/common.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./manifest-secrets";
8
8
  export * from "./layer-watch";
9
9
  export * from "./materialize";
10
10
  export * from "./derived-outputs";
11
+ export * from "./app-configs";
11
12
  export * from "./renderer-range";
12
13
  export * from "./workspace";
13
14
  export * from "./workspace-setup";
package/dist/common.js CHANGED
@@ -24,6 +24,7 @@ __exportStar(require("./manifest-secrets"), exports);
24
24
  __exportStar(require("./layer-watch"), exports);
25
25
  __exportStar(require("./materialize"), exports);
26
26
  __exportStar(require("./derived-outputs"), exports);
27
+ __exportStar(require("./app-configs"), exports);
27
28
  __exportStar(require("./renderer-range"), exports);
28
29
  __exportStar(require("./workspace"), exports);
29
30
  __exportStar(require("./workspace-setup"), exports);
package/dist/config.d.ts CHANGED
@@ -10,6 +10,8 @@ export declare const TEMPLATE_FILES: ReadonlyArray<readonly [string, string]>;
10
10
  export declare const LAYERS_SUBDIR = "frontend-modules";
11
11
  export declare const FRONTEND_MODULE_ENTRY = "dms.frontend.ts";
12
12
  export declare const FRONTEND_BUILD_ENTRY = "dms.frontend.build.ts";
13
+ export declare const SERVER_MODULE_ENTRY = "dms.server.ts";
14
+ export declare const SERVER_OPTIONS_FILE = "generated-server-options.json";
13
15
  export declare const AUTH_ESTABLISH_FILE = "generated-auth-establish.json";
14
16
  export declare const PUBLIC_ENDPOINTS_FILE = "generated-public-endpoints.json";
15
17
  export declare const LAYER_COPY_BLOCKLIST: readonly string[];
package/dist/config.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Options = exports.UsageError = exports.TAILWIND_SOURCE_GLOB = exports.PNPM_LIFECYCLE_SCRIPTS = exports.layerCopyIgnore = exports.LAYER_COPY_BLOCKLIST = exports.PUBLIC_ENDPOINTS_FILE = exports.AUTH_ESTABLISH_FILE = exports.FRONTEND_BUILD_ENTRY = exports.FRONTEND_MODULE_ENTRY = exports.LAYERS_SUBDIR = exports.TEMPLATE_FILES = exports.WORKSPACE_DIR_MODE = exports.DEPS_HASH_FILE = exports.DMS_FRONTEND_HOME = void 0;
6
+ exports.Options = exports.UsageError = exports.TAILWIND_SOURCE_GLOB = exports.PNPM_LIFECYCLE_SCRIPTS = exports.layerCopyIgnore = exports.LAYER_COPY_BLOCKLIST = exports.PUBLIC_ENDPOINTS_FILE = exports.AUTH_ESTABLISH_FILE = exports.SERVER_OPTIONS_FILE = exports.SERVER_MODULE_ENTRY = exports.FRONTEND_BUILD_ENTRY = exports.FRONTEND_MODULE_ENTRY = exports.LAYERS_SUBDIR = exports.TEMPLATE_FILES = exports.WORKSPACE_DIR_MODE = exports.DEPS_HASH_FILE = exports.DMS_FRONTEND_HOME = void 0;
7
7
  exports.writeSecretBearingFile = writeSecretBearingFile;
8
8
  exports.parseBackendUrl = parseBackendUrl;
9
9
  exports.requireBackendUrl = requireBackendUrl;
@@ -38,19 +38,24 @@ function writeSecretBearingFile(file, content) {
38
38
  exports.TEMPLATE_FILES = [
39
39
  ["vite.config.ts", "vite.config.ts"],
40
40
  ["vite.email.config.ts", "vite.email.config.ts"],
41
+ ["vite.server.config.ts", "vite.server.config.ts"],
41
42
  ["index.html", "index.html"],
42
43
  ["main.ts", "main.ts"],
43
44
  ["app-runtime.ts", "app-runtime.ts"],
44
45
  ["network-error.ts", "network-error.ts"],
45
46
  ["ui-app-config.ts", "ui-app-config.ts"],
47
+ ["layer-app-config.ts", "layer-app-config.ts"],
46
48
  ["ssr-renderer.ts", "ssr-renderer.ts"],
47
49
  ["frontend-module.ts", "frontend-module.ts"],
48
50
  ["frontend-build.ts", "frontend-build.ts"],
49
51
  ["frontend-build-loader.ts", "frontend-build-loader.ts"],
52
+ ["server-module.ts", "server-module.ts"],
50
53
  ["icon-hydration.ts", "icon-hydration.ts"],
51
54
  ["globals.d.ts", "globals.d.ts"],
52
55
  ["compress-assets.mjs", "compress-assets.mjs"],
53
56
  ["head-order.mjs", "head-order.mjs"],
57
+ ["client-server-guard.mjs", "client-server-guard.mjs"],
58
+ ["ui-inertia-page.mjs", "ui-inertia-page.mjs"],
54
59
  ["icon-api.mjs", "icon-api.mjs"],
55
60
  ["icon-scan.mjs", "icon-scan.mjs"],
56
61
  ["email-renderer.ts", "email-renderer.ts"],
@@ -72,6 +77,8 @@ exports.TEMPLATE_FILES = [
72
77
  exports.LAYERS_SUBDIR = "frontend-modules";
73
78
  exports.FRONTEND_MODULE_ENTRY = "dms.frontend.ts";
74
79
  exports.FRONTEND_BUILD_ENTRY = "dms.frontend.build.ts";
80
+ exports.SERVER_MODULE_ENTRY = "dms.server.ts";
81
+ exports.SERVER_OPTIONS_FILE = "generated-server-options.json";
75
82
  exports.AUTH_ESTABLISH_FILE = "generated-auth-establish.json";
76
83
  exports.PUBLIC_ENDPOINTS_FILE = "generated-public-endpoints.json";
77
84
  exports.LAYER_COPY_BLOCKLIST = [
@@ -81,8 +88,6 @@ exports.LAYER_COPY_BLOCKLIST = [
81
88
  "coverage",
82
89
  ".cache",
83
90
  ".turbo",
84
- "server",
85
- "**/server",
86
91
  "tsconfig.json",
87
92
  "tsconfig.*.json",
88
93
  ];
@@ -7,6 +7,7 @@ export interface FrontendModuleRegistryEntry {
7
7
  priority: number;
8
8
  entry?: string;
9
9
  build?: string;
10
+ server?: string;
10
11
  options: FrontendModuleOptions;
11
12
  }
12
13
  export interface FrontendModuleRegistry {
@@ -24,6 +25,7 @@ export interface DerivedOutput {
24
25
  name: string;
25
26
  affects(relativePath: string): boolean;
26
27
  write(workspaceDir: string, registry: FrontendModuleRegistry): boolean;
28
+ readsSourcesAsData?: boolean;
27
29
  restartHint?: string;
28
30
  }
29
31
  export declare const DERIVED_OUTPUTS: readonly DerivedOutput[];
@@ -7,6 +7,8 @@ exports.writeLocaleMessages = writeLocaleMessages;
7
7
  const node_fs_1 = require("node:fs");
8
8
  const node_path_1 = require("node:path");
9
9
  const config_1 = require("./config");
10
+ const app_configs_1 = require("./app-configs");
11
+ const asset_roots_1 = require("./asset-roots");
10
12
  const layer_aliases_1 = require("./layer-aliases");
11
13
  const layers_1 = require("./layers");
12
14
  const fs_sync_1 = require("./fs-sync");
@@ -23,6 +25,8 @@ function validateFrontendModuleRegistry(registry, workspaceDir) {
23
25
  throw new Error(`Invalid frontend module entry: ${module.id}`);
24
26
  if (module.build !== undefined && module.build !== config_1.FRONTEND_BUILD_ENTRY)
25
27
  throw new Error(`Invalid frontend module build entry: ${module.id}`);
28
+ if (module.server !== undefined && module.server !== config_1.SERVER_MODULE_ENTRY)
29
+ throw new Error(`Invalid frontend module server entry: ${module.id}`);
26
30
  if (!(0, node_path_1.resolve)(module.root).startsWith(moduleRoot))
27
31
  throw new Error(`Frontend module root escapes the workspace: ${module.id}`);
28
32
  ids.add(module.id);
@@ -32,6 +36,7 @@ function createFrontendModuleRegistry(workspaceDir, layers) {
32
36
  const modules = layers.map((layer) => {
33
37
  const sourceEntry = (0, node_path_1.join)(layer.path, config_1.FRONTEND_MODULE_ENTRY);
34
38
  const buildEntry = (0, node_path_1.join)(layer.path, config_1.FRONTEND_BUILD_ENTRY);
39
+ const serverEntry = (0, node_path_1.join)(layer.path, config_1.SERVER_MODULE_ENTRY);
35
40
  const options = layer.options ?? {};
36
41
  return {
37
42
  id: (0, layers_1.getLayerSafeName)(layer),
@@ -41,6 +46,7 @@ function createFrontendModuleRegistry(workspaceDir, layers) {
41
46
  priority: layer.priority ?? 0,
42
47
  entry: (0, node_fs_1.existsSync)(sourceEntry) ? config_1.FRONTEND_MODULE_ENTRY : undefined,
43
48
  build: (0, node_fs_1.existsSync)(buildEntry) ? config_1.FRONTEND_BUILD_ENTRY : undefined,
49
+ server: (0, node_fs_1.existsSync)(serverEntry) ? config_1.SERVER_MODULE_ENTRY : undefined,
44
50
  options: layer.configKey ? { [layer.configKey]: options } : options,
45
51
  };
46
52
  });
@@ -53,6 +59,7 @@ function writeFrontendTypePaths(workspaceDir, registry) {
53
59
  const paths = {
54
60
  "#dms/frontend-module": ["./frontend-module.ts"],
55
61
  "#dms/frontend-build": ["./frontend-build.ts"],
62
+ "#dms/server": ["./server-module.ts"],
56
63
  "@frontend/*": ["./frontend-modules/*"],
57
64
  ...(0, layer_aliases_1.frontendLayerTypePaths)([...registry.modules].reverse().map((module) => module.root), { relativeTo: workspaceDir }),
58
65
  };
@@ -81,27 +88,29 @@ function writeFrontendBuildLoader(workspaceDir, registry) {
81
88
  const content = `${imports}\n\nimport type { FrontendBuildDeclaration } from "./frontend-build-loader";\n\nexport const frontendBuilds: FrontendBuildDeclaration[] = [${declarations}];\n`;
82
89
  return (0, fs_sync_1.applyContent)(content, (0, node_path_1.join)(workspaceDir, "frontend-builds.generated.ts"));
83
90
  }
91
+ function writeServerModuleLoader(workspaceDir, registry) {
92
+ const modules = registry.modules.filter((module) => module.server);
93
+ const imports = modules
94
+ .map((module, index) => `import server${index} from "./${config_1.LAYERS_SUBDIR}/${module.id}/${module.server}";`)
95
+ .join("\n");
96
+ const declarations = modules
97
+ .map((module, index) => `{ id: ${JSON.stringify(module.id)}, priority: ${module.priority}, setup: server${index} }`)
98
+ .join(", ");
99
+ const content = `${imports}\n\nimport type { DmsServerSetup } from "./server-module";\n\nexport const serverModules: { id: string; priority: number; setup: DmsServerSetup }[] = [${declarations}];\n`;
100
+ return (0, fs_sync_1.applyContent)(content, (0, node_path_1.join)(workspaceDir, "server-modules.generated.ts"));
101
+ }
84
102
  function writeModuleRegistry(workspaceDir, registry) {
85
103
  const wroteRegistry = (0, fs_sync_1.applyContent)(`${JSON.stringify(registry, null, 2)}\n`, (0, node_path_1.join)(workspaceDir, "generated-frontend-modules.json"));
86
104
  const wroteModules = writeFrontendModuleLoader(workspaceDir, registry);
87
105
  const wroteBuilds = writeFrontendBuildLoader(workspaceDir, registry);
88
- return wroteRegistry || wroteModules || wroteBuilds;
89
- }
90
- function moduleAssetRoots(moduleRoot) {
91
- const layersRoot = (0, node_path_1.join)(moduleRoot, "layers");
92
- if (!(0, node_fs_1.existsSync)(layersRoot)) {
93
- return [{ absolutePath: moduleRoot, relativePrefix: "" }];
94
- }
95
- return (0, node_fs_1.readdirSync)(layersRoot).map((name) => ({
96
- absolutePath: (0, node_path_1.join)(layersRoot, name),
97
- relativePrefix: `layers/${name}/`,
98
- }));
106
+ const wroteServer = writeServerModuleLoader(workspaceDir, registry);
107
+ return wroteRegistry || wroteModules || wroteBuilds || wroteServer;
99
108
  }
100
109
  const PUBLIC_DIRECTORY = "public";
101
110
  function writePublicAssets(workspaceDir, registry) {
102
111
  const files = new Map();
103
112
  for (const module of [...registry.modules].reverse()) {
104
- for (const root of moduleAssetRoots(module.root)) {
113
+ for (const root of (0, asset_roots_1.moduleAssetRoots)(module.root)) {
105
114
  const source = (0, node_path_1.join)(root.absolutePath, PUBLIC_DIRECTORY);
106
115
  for (const file of (0, fs_sync_1.collectFiles)(source)) {
107
116
  files.set(file, (0, node_path_1.join)(source, file));
@@ -112,7 +121,7 @@ function writePublicAssets(workspaceDir, registry) {
112
121
  }
113
122
  function discoverAssets(registry, directory, extensions) {
114
123
  return registry.modules.flatMap((module) => {
115
- return moduleAssetRoots(module.root).flatMap((assetRoot) => {
124
+ return (0, asset_roots_1.moduleAssetRoots)(module.root).flatMap((assetRoot) => {
116
125
  const root = (0, node_path_1.join)(assetRoot.absolutePath, directory);
117
126
  return (0, fs_sync_1.collectFiles)(root)
118
127
  .filter((file) => extensions.some((extension) => file.endsWith(extension)))
@@ -170,21 +179,8 @@ function readLocaleMessages(assets, registry) {
170
179
  }
171
180
  return messages;
172
181
  }
173
- function isLayerDirectory(relativePath) {
174
- const segments = (0, fs_sync_1.toPosixPath)(relativePath).split("/");
175
- return segments[0] === layer_aliases_1.MODULE_LAYERS_DIRNAME && segments.length <= 2;
176
- }
177
- function affectsAssetDirectory(directory, relativePath) {
178
- if (isLayerDirectory(relativePath))
179
- return true;
180
- const segments = (0, fs_sync_1.toPosixPath)(relativePath).split("/");
181
- const withinRoot = segments[0] === layer_aliases_1.MODULE_LAYERS_DIRNAME ? segments.slice(2) : segments;
182
- return directory
183
- .split("/")
184
- .every((segment, index) => index >= withinRoot.length || withinRoot[index] === segment);
185
- }
186
182
  function affectsLocaleMessages(relativePath) {
187
- return affectsAssetDirectory(LOCALE_DIRECTORY, relativePath);
183
+ return (0, asset_roots_1.affectsAssetDirectory)(LOCALE_DIRECTORY, relativePath);
188
184
  }
189
185
  function localeModuleSource(supportedLocales) {
190
186
  const loaders = supportedLocales
@@ -297,12 +293,16 @@ function writeShortcutExports(workspaceDir, registry) {
297
293
  exports.DERIVED_OUTPUTS = [
298
294
  {
299
295
  name: "module registry",
300
- affects: (path) => [config_1.FRONTEND_MODULE_ENTRY, config_1.FRONTEND_BUILD_ENTRY].includes((0, fs_sync_1.toPosixPath)(path)),
296
+ affects: (path) => [
297
+ config_1.FRONTEND_MODULE_ENTRY,
298
+ config_1.FRONTEND_BUILD_ENTRY,
299
+ config_1.SERVER_MODULE_ENTRY,
300
+ ].includes((0, fs_sync_1.toPosixPath)(path)),
301
301
  write: writeModuleRegistry,
302
302
  },
303
303
  {
304
304
  name: "type paths",
305
- affects: isLayerDirectory,
305
+ affects: asset_roots_1.isLayerDirectory,
306
306
  write: writeFrontendTypePaths,
307
307
  restartHint: "Restart ajs dms dev to apply it (Vite reads the '#<layer>' aliases and the auto-imported directories at startup)",
308
308
  },
@@ -310,15 +310,22 @@ exports.DERIVED_OUTPUTS = [
310
310
  name: "locale catalogs",
311
311
  affects: affectsLocaleMessages,
312
312
  write: writeLocaleMessages,
313
+ readsSourcesAsData: true,
313
314
  },
314
315
  {
315
316
  name: "aggregated shortcuts",
316
- affects: (path) => affectsAssetDirectory(SHORTCUTS_DIRECTORY, path),
317
+ affects: (path) => (0, asset_roots_1.affectsAssetDirectory)(SHORTCUTS_DIRECTORY, path),
317
318
  write: writeShortcutExports,
318
319
  },
319
320
  {
320
321
  name: "public assets",
321
- affects: (path) => affectsAssetDirectory(PUBLIC_DIRECTORY, path),
322
+ affects: (path) => (0, asset_roots_1.affectsAssetDirectory)(PUBLIC_DIRECTORY, path),
322
323
  write: writePublicAssets,
324
+ readsSourcesAsData: true,
325
+ },
326
+ {
327
+ name: "app configs",
328
+ affects: app_configs_1.affectsAppConfigs,
329
+ write: app_configs_1.writeAppConfigs,
323
330
  },
324
331
  ];
package/dist/help.js CHANGED
@@ -16,7 +16,10 @@ exports.ENVIRONMENT_VARIABLES = [
16
16
  ["DMS_OFFLINE", "Same as --offline, unless 0, false, no or off"],
17
17
  ["DMS_PREPARE_STRICT", "Same as prepare --strict, read like DMS_OFFLINE"],
18
18
  ["PORT", "Same as -p"],
19
- ["HOST", "Address the server binds to (default: 0.0.0.0)"],
19
+ [
20
+ "HOST",
21
+ "Address the server binds to (default: 127.0.0.1 for dev, 0.0.0.0 for start)",
22
+ ],
20
23
  [
21
24
  "DMS_COOKIE_SECURE",
22
25
  "Secure cookies unless false (default: false in dev, true in start)",
@@ -31,11 +34,11 @@ exports.ENVIRONMENT_VARIABLES = [
31
34
  ],
32
35
  [
33
36
  "DMS_HTML_RENDER_SECRET",
34
- "Overrides the e-mail render secret the backend publishes",
37
+ "E-mail render secret, used when the backend publishes none in the manifest",
35
38
  ],
36
39
  [
37
40
  "DMS_OAUTH_RELAY_SECRET",
38
- "Overrides the OAuth relay secret the backend publishes",
41
+ "OAuth relay secret, used when the backend publishes none in the manifest",
39
42
  ],
40
43
  [
41
44
  "DMS_AUTH_ESTABLISH_ENDPOINTS",
@@ -45,6 +48,10 @@ exports.ENVIRONMENT_VARIABLES = [
45
48
  "DMS_PUBLIC_ENDPOINTS",
46
49
  "More backend routes the proxy serves to anyone, as a JSON array",
47
50
  ],
51
+ [
52
+ "DMS_BACKEND_PROXIES",
53
+ "More backend prefixes the server proxies, as a JSON array of { path, auth? }",
54
+ ],
48
55
  ["DMS_CLIENT_BASE_URL", "Public frontend URL used in links and e-mails"],
49
56
  ["NO_COLOR", "Same as --no-color"],
50
57
  ["ANTELOPEJS_VERBOSE", "Same as --verbose"],